mem92.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Hey EMACS -*- linux-c -*- */
  2. /* $Id: mem92.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 ROM v1.x & v2.x
  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 "mem92.h"
  35. #include "ti68k_def.h"
  36. #include "mem_size.h"
  37. #include "main.h"
  38. // 000000-1fffff : RAM (128 or 256 KB)
  39. // 200000-3fffff : internal ROM or unused (1.x: 1 MB)
  40. // 400000-5fffff : external ROM or unused (1.x: 1 MB or 2.x: 2 MB)
  41. // 600000-6fffff : memory mapped I/O
  42. // 700000-ffffff : unused
  43. int ti92_mem_init(void)
  44. {
  45. // set mappers
  46. mem_get_byte_ptr = ti92_get_byte;
  47. mem_get_word_ptr = ti92_get_word;
  48. mem_get_long_ptr = ti92_get_long;
  49. mem_get_real_addr_ptr = ti92_get_real_addr;
  50. return 0;
  51. }
  52. uint8_t* ti92_get_real_addr(uint32_t adr)
  53. {
  54. // RAM access
  55. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  56. {
  57. return get_p(ram, adr, ram_size - 1);
  58. }
  59. // PROM access
  60. else if(IN_RANGE(adr, rom_base, 2*MB))
  61. {
  62. return get_p(rom, adr, rom_size - 1);
  63. }
  64. return unused;
  65. }
  66. uint32_t ti92_get_long(uint32_t adr)
  67. {
  68. // RAM access
  69. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  70. {
  71. return get_l(ram, adr, ram_size - 1);
  72. }
  73. // PROM access
  74. else if(IN_RANGE(adr, rom_base, 2*MB))
  75. {
  76. return get_l(rom, adr, rom_size - 1);
  77. }
  78. return 0x14141414;
  79. }
  80. uint16_t ti92_get_word(uint32_t adr)
  81. {
  82. // RAM access
  83. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  84. {
  85. return get_w(ram, adr, ram_size - 1);
  86. }
  87. // PROM access
  88. else if(IN_RANGE(adr, rom_base, 2*MB))
  89. {
  90. return get_w(rom, adr, rom_size - 1);
  91. }
  92. return 0x1414;
  93. }
  94. uint8_t ti92_get_byte(uint32_t adr)
  95. {
  96. // RAM access
  97. if(IN_BOUNDS(0x000000, adr, 0x1fffff))
  98. {
  99. return get_b(ram, adr, ram_size - 1);
  100. }
  101. // PROM access
  102. else if(IN_RANGE(adr, rom_base, 2*MB))
  103. {
  104. return get_b(rom, adr, rom_size - 1);
  105. }
  106. return 0x14;
  107. }