mem89tm.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* Hey EMACS -*- linux-c -*- */
  2. /* $Id: mem89tm.c 2268 2006-11-06 17:18:51Z roms $ */
  3. /* TiEmu - Tiemu Is an EMUlator
  4. *
  5. * Copyright (c) 2000-2001, Thomas Corvazier, Romain Liévin
  6. * Copyright (c) 2001-2003, Romain Liévin
  7. * Copyright (c) 2003, Julien Blache
  8. * Copyright (c) 2004, Romain Liévin
  9. * Copyright (c) 2005, Romain Liévin, Kevin Kofler
  10. * Copyright (c) 2007, Kevin Kofler
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. /*
  27. Memory management: TI89 Titanium without any HW protection
  28. Some values may be hard-coded for performance reasons !
  29. */
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <stdio.h>
  33. #include "mem.h"
  34. #include "mem89tm.h"
  35. #include "ti68k_def.h"
  36. #include "mem_size.h"
  37. #include "main.h"
  38. // 000000-03ffff : RAM (256 KB), not mirrored
  39. // 100000-1fffff : unused
  40. // 200000-2fffff : image of 0x000000 (ghost, not mirrored)
  41. // 300000-3fffff : unused
  42. // 400000-4fffff : image of 0x000000 (ghost, not mirrored)
  43. // 500000-5fffff : unused
  44. // 600000-6fffff : memory mapped I/O (all HW)
  45. // 700000-7fffff : memory mapped I/O (HW2, HW3), non ghost'ed
  46. // 800000-8fffff : ROM (TI89 Titanium)
  47. // 900000-9fffff : idem
  48. // a00000-afffff : idem
  49. // b00000-bfffff : idem
  50. // c00000-cfffff : unused
  51. // d00000-dfffff : ...
  52. // e00000-efffff : ...
  53. // d00000-ffffff : unused
  54. int ti89t_mem_init(void)
  55. {
  56. // set mappers
  57. mem_get_byte_ptr = ti89t_get_byte;
  58. mem_get_word_ptr = ti89t_get_word;
  59. mem_get_long_ptr = ti89t_get_long;
  60. mem_get_real_addr_ptr = ti89t_get_real_addr;
  61. return 0;
  62. }
  63. uint8_t* ti89t_get_real_addr(uint32_t adr)
  64. {
  65. // RAM access
  66. if(IN_BOUNDS(0x000000, adr, 0x03ffff) ||
  67. IN_BOUNDS(0x200000, adr, 0x23ffff) ||
  68. IN_BOUNDS(0x400000, adr, 0x43ffff))
  69. {
  70. return get_p(ram, adr, 0x03ffff);
  71. }
  72. // FLASH access
  73. else if(IN_BOUNDS(0x800000, adr, 0xbfffff))
  74. {
  75. return get_p(rom, adr, ROM_SIZE_TI89T - 1);
  76. }
  77. return unused;
  78. }
  79. uint32_t ti89t_get_long(uint32_t adr)
  80. {
  81. // RAM access
  82. if(IN_BOUNDS(0x000000, adr, 0x03ffff) ||
  83. IN_BOUNDS(0x200000, adr, 0x23ffff) ||
  84. IN_BOUNDS(0x400000, adr, 0x43ffff))
  85. {
  86. return get_l(ram, adr, 0x03ffff);
  87. }
  88. // FLASH access
  89. else if(IN_BOUNDS(0x800000, adr, 0xbfffff))
  90. {
  91. return get_l(rom, adr, ROM_SIZE_TI89T - 1);
  92. }
  93. return 0x14141414;
  94. }
  95. uint16_t ti89t_get_word(uint32_t adr)
  96. {
  97. // RAM access
  98. if(IN_BOUNDS(0x000000, adr, 0x03ffff) ||
  99. IN_BOUNDS(0x200000, adr, 0x23ffff) ||
  100. IN_BOUNDS(0x400000, adr, 0x43ffff))
  101. {
  102. return get_w(ram, adr, 0x03ffff);
  103. }
  104. // FLASH access
  105. else if(IN_BOUNDS(0x800000, adr, 0xbfffff))
  106. {
  107. return get_w(rom, adr, ROM_SIZE_TI89T - 1);
  108. }
  109. return 0x1414;
  110. }
  111. uint8_t ti89t_get_byte(uint32_t adr)
  112. {
  113. // RAM access
  114. if(IN_BOUNDS(0x000000, adr, 0x03ffff) ||
  115. IN_BOUNDS(0x200000, adr, 0x23ffff) ||
  116. IN_BOUNDS(0x400000, adr, 0x43ffff))
  117. {
  118. return get_b(ram, adr, 0x03ffff);
  119. }
  120. // FLASH access
  121. else if(IN_BOUNDS(0x800000, adr, 0xbfffff))
  122. {
  123. return get_b(rom, adr, ROM_SIZE_TI89T - 1);
  124. }
  125. return 0x14;
  126. }