trunk/src/mess/machine/coco.c
| r21783 | r21784 | |
| 162 | 162 | { |
| 163 | 163 | m_maincpu->debug()->set_dasm_override(dasm_override); |
| 164 | 164 | } |
| 165 | |
| 166 | // miscellaneous |
| 167 | m_in_floating_bus_read = false; |
| 165 | 168 | } |
| 166 | 169 | |
| 167 | 170 | |
| r21783 | r21784 | |
| 254 | 257 | |
| 255 | 258 | UINT8 coco_state::floating_bus_read(void) |
| 256 | 259 | { |
| 257 | | UINT8 byte; |
| 260 | UINT8 result; |
| 258 | 261 | |
| 259 | | // set up the ability to read address spaces |
| 260 | | address_space &program = m_maincpu->space(AS_PROGRAM); |
| 262 | // this method calls program.read_byte() - therefore we run the risk of a stack overflow if we don't check for |
| 263 | // a reentrant invocation |
| 264 | if (m_in_floating_bus_read) |
| 265 | { |
| 266 | // not sure what should really happen in this extremely degenerate scenario (the PC is probably |
| 267 | // in $FFxx never-never land), but I guess 0xFF is as good as anything. |
| 268 | result = 0xFF; |
| 269 | } |
| 270 | else |
| 271 | { |
| 272 | // prevent stack overflows |
| 273 | m_in_floating_bus_read = true; |
| 261 | 274 | |
| 262 | | // get the previous and current PC |
| 263 | | UINT16 prev_pc = m_maincpu->pcbase(); |
| 264 | | UINT16 pc = m_maincpu->pc(); |
| 275 | // set up the ability to read address spaces |
| 276 | address_space &program = m_maincpu->space(AS_PROGRAM); |
| 265 | 277 | |
| 266 | | // get the byte; and skip over header bytes |
| 267 | | byte = program.read_byte(prev_pc); |
| 268 | | if ((byte == 0x10) || (byte == 0x11)) |
| 269 | | byte = program.read_byte(++prev_pc); |
| 278 | // get the previous and current PC |
| 279 | UINT16 prev_pc = m_maincpu->pcbase(); |
| 280 | UINT16 pc = m_maincpu->pc(); |
| 270 | 281 | |
| 271 | | // check to see if the opcode specifies the indexed addressing mode, and the secondary byte |
| 272 | | // specifies no-offset |
| 273 | | bool is_nooffset_indexed = (((byte & 0xF0) == 0x60) || ((byte & 0xF0) == 0xA0) || ((byte & 0xF0) == 0xE0)) |
| 274 | | && ((program.read_byte(prev_pc + 1) & 0xBF) == 0x84); |
| 282 | // get the byte; and skip over header bytes |
| 283 | UINT8 byte = program.read_byte(prev_pc); |
| 284 | if ((byte == 0x10) || (byte == 0x11)) |
| 285 | byte = program.read_byte(++prev_pc); |
| 275 | 286 | |
| 276 | | // finally read the byte |
| 277 | | return program.read_byte(is_nooffset_indexed ? pc : 0xFFFF); |
| 287 | // check to see if the opcode specifies the indexed addressing mode, and the secondary byte |
| 288 | // specifies no-offset |
| 289 | bool is_nooffset_indexed = (((byte & 0xF0) == 0x60) || ((byte & 0xF0) == 0xA0) || ((byte & 0xF0) == 0xE0)) |
| 290 | && ((program.read_byte(prev_pc + 1) & 0xBF) == 0x84); |
| 291 | |
| 292 | // finally read the byte |
| 293 | result = program.read_byte(is_nooffset_indexed ? pc : 0xFFFF); |
| 294 | |
| 295 | // we're done reading |
| 296 | m_in_floating_bus_read = false; |
| 297 | } |
| 298 | return result; |
| 278 | 299 | } |
| 279 | 300 | |
| 280 | 301 | |