mem92p.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* Hey EMACS -*- linux-c -*- */
  2. /* $Id: mem92p.c 2428 2007-04-04 17:05:38Z 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
  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: TI92+ FLASH without Hardware 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 "mem92p.h"
  35. #include "ti68k_def.h"
  36. #include "mem_size.h"
  37. #include "main.h"
  38. // 000000-0fffff : RAM (256 KB)
  39. // 100000-1fffff :
  40. // 200000-2fffff : mirror of FLASH (HW2)
  41. // 300000-3fffff :
  42. // 400000-4fffff : external FLASH (2 MB)
  43. // 500000-5fffff :
  44. // 600000-6fffff : memory mapped I/O (all HW)
  45. // 700000-7fffff : memory mapped I/O (HW2)
  46. // 800000-8fffff : unused
  47. // 900000-9fffff : ...
  48. // a00000-afffff :
  49. // b00000-bfffff :
  50. // c00000-cfffff :
  51. // d00000-dfffff :
  52. // e00000-efffff : ...
  53. // d00000-ffffff : unused
  54. int ti92p_mem_init(void)
  55. {
  56. // set mappers
  57. mem_get_byte_ptr = ti92p_get_byte;
  58. mem_get_word_ptr = ti92p_get_word;
  59. mem_get_long_ptr = ti92p_get_long;
  60. mem_get_real_addr_ptr = ti92p_get_real_addr;
  61. return 0;
  62. }
  63. uint8_t* ti92p_get_real_addr(uint32_t adr)
  64. {
  65. // RAM access
  66. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  67. {
  68. return get_p(ram, adr, RAM_SIZE_TI92P - 1);
  69. }
  70. // FLASH access
  71. else if(IN_BOUNDS(0x200000, adr, 0x5fffff))
  72. {
  73. return get_p(rom, adr, ROM_SIZE_TI92P - 1);
  74. }
  75. return unused;
  76. }
  77. uint32_t ti92p_get_long(uint32_t adr)
  78. {
  79. // RAM access
  80. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  81. {
  82. return get_l(ram, adr, RAM_SIZE_TI92P - 1);
  83. }
  84. // FLASH access
  85. else if(IN_BOUNDS(0x200000, adr, 0x5fffff))
  86. {
  87. return get_l(rom, adr, ROM_SIZE_TI92P - 1);
  88. }
  89. return 0x14141414;
  90. }
  91. uint16_t ti92p_get_word(uint32_t adr)
  92. {
  93. // RAM access
  94. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  95. {
  96. return get_w(ram, adr, RAM_SIZE_TI92P - 1);
  97. }
  98. // FLASH access
  99. else if(IN_BOUNDS(0x200000, adr, 0x5fffff))
  100. {
  101. return get_w(rom, adr, ROM_SIZE_TI92P - 1);
  102. }
  103. return 0x1414;
  104. }
  105. uint8_t ti92p_get_byte(uint32_t adr)
  106. {
  107. // RAM access
  108. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  109. {
  110. return get_b(ram, adr, RAM_SIZE_TI92P - 1);
  111. }
  112. // FLASH access
  113. else if(IN_BOUNDS(0x200000, adr, 0x5fffff))
  114. {
  115. return get_b(rom, adr, ROM_SIZE_TI92P - 1);
  116. }
  117. return 0x14;
  118. }