comparison genesis.c @ 1987:71732f2f6f42

Fix handling of unmapped reads/writes to the cart/expansion port region
author Mike Pavone <pavone@retrodev.com>
date Mon, 01 Jun 2020 23:59:59 -0700
parents 81df9aa2de9b
children 0740d90812ee
comparison
equal deleted inserted replaced
1986:a042e046f7f2 1987:71732f2f6f42
1087 1087
1088 static uint16_t unused_read(uint32_t location, void *vcontext) 1088 static uint16_t unused_read(uint32_t location, void *vcontext)
1089 { 1089 {
1090 m68k_context *context = vcontext; 1090 m68k_context *context = vcontext;
1091 genesis_context *gen = context->system; 1091 genesis_context *gen = context->system;
1092 if ((location >= 0xA13000 && location < 0xA13100) || (location >= 0xA12000 && location < 0xA12100)) { 1092 if (location < 0x800000 || (location >= 0xA13000 && location < 0xA13100) || (location >= 0xA12000 && location < 0xA12100)) {
1093 //Only called if the cart/exp doesn't have a more specific handler for this region 1093 //Only called if the cart/exp doesn't have a more specific handler for this region
1094 return get_open_bus_value(&gen->header); 1094 return get_open_bus_value(&gen->header);
1095 } else if (location == 0xA14000 || location == 0xA14002) { 1095 } else if (location == 0xA14000 || location == 0xA14002) {
1096 if (gen->version_reg & 0xF) { 1096 if (gen->version_reg & 0xF) {
1097 return gen->tmss_lock[location >> 1 & 1]; 1097 return gen->tmss_lock[location >> 1 & 1];
1129 uint8_t has_tmss = gen->version_reg & 0xF; 1129 uint8_t has_tmss = gen->version_reg & 0xF;
1130 if (has_tmss && (location == 0xA14000 || location == 0xA14002)) { 1130 if (has_tmss && (location == 0xA14000 || location == 0xA14002)) {
1131 gen->tmss_lock[location >> 1 & 1] = value; 1131 gen->tmss_lock[location >> 1 & 1] = value;
1132 } else if (has_tmss && location == 0xA14100) { 1132 } else if (has_tmss && location == 0xA14100) {
1133 //TODO: implement TMSS control register 1133 //TODO: implement TMSS control register
1134 } else if (location < 0xA12000 || location >= 0xA13100 || (location >= 0xA12100 && location < 0xA13000)) { 1134 } else if (location < 0x800000 || (location >= 0xA13000 && location < 0xA13100) || (location >= 0xA12000 && location < 0xA12100)) {
1135 //these writes are ignored when no relevant hardware is present
1136 } else {
1135 fatal_error("Machine freeze due to unmapped write to %X\n", location); 1137 fatal_error("Machine freeze due to unmapped write to %X\n", location);
1136 } 1138 }
1137 return vcontext; 1139 return vcontext;
1138 } 1140 }
1139 1141
1151 gen->tmss_lock[offset] &= 0xFF; 1153 gen->tmss_lock[offset] &= 0xFF;
1152 gen->tmss_lock[offset] |= value << 8; 1154 gen->tmss_lock[offset] |= value << 8;
1153 } 1155 }
1154 } else if (has_tmss && (location == 0xA14100 || location == 0xA14101)) { 1156 } else if (has_tmss && (location == 0xA14100 || location == 0xA14101)) {
1155 //TODO: implement TMSS control register 1157 //TODO: implement TMSS control register
1156 } else if (location < 0xA12000 || location >= 0xA13100 || (location >= 0xA12100 && location < 0xA13000)) { 1158 } else if (location < 0x800000 || (location >= 0xA13000 && location < 0xA13100) || (location >= 0xA12000 && location < 0xA12100)) {
1159 //these writes are ignored when no relevant hardware is present
1160 } else {
1157 fatal_error("Machine freeze due to unmapped byte write to %X\n", location); 1161 fatal_error("Machine freeze due to unmapped byte write to %X\n", location);
1158 } 1162 }
1159 return vcontext; 1163 return vcontext;
1160 } 1164 }
1161 1165