| 424 | } |
| 425 | |
| 426 | static uint8_t lcd_read(const uint16_t pio, bool peek) { |
| 427 | uint16_t index = pio; |
| 428 | uint8_t bit_offset = (index & 3) << 3; |
| 429 | |
| 430 | if (index < 0x200) { |
| 431 | if (index < 0x010) { return read8(lcd.timing[index >> 2], bit_offset); } |
| 432 | if (index < 0x014 && index >= 0x010) { return read8(lcd.upbase, bit_offset); } |
| 433 | if (index < 0x018 && index >= 0x014) { return read8(lcd.lpbase, bit_offset); } |
| 434 | if (index < 0x01C && index >= 0x018) { return read8(lcd.control, bit_offset); } |
| 435 | if (index < 0x020 && index >= 0x01C) { return read8(lcd.imsc, bit_offset); } |
| 436 | if (index < 0x024 && index >= 0x020) { return read8(lcd.ris, bit_offset); } |
| 437 | if (index < 0x028 && index >= 0x024) { return read8(lcd.imsc & lcd.ris, bit_offset); } |
| 438 | if (index < 0x030 && index >= 0x02C) { |
| 439 | if (!peek) { |
| 440 | sched_process_pending_dma(0); |
| 441 | } |
| 442 | return read8(lcd.upcurr, bit_offset); |
| 443 | } |
| 444 | if (index < 0x034 && index >= 0x030) { return read8(lcd.lpcurr, bit_offset); } |
| 445 | } else if (index < 0x400) { |
| 446 | if (!peek) { |
| 447 | cpu.cycles++; |
| 448 | } |
| 449 | return lcd.paletteBytes[index - 0x200]; |
| 450 | } else if (index < 0xC00) { |
| 451 | if (index >= 0x800) { return lcd.crsrImageBytes[index - 0x800]; } |
| 452 | } else if (index < 0xE00) { |
| 453 | if (!peek) { |
| 454 | cpu.cycles--; |
| 455 | } |
| 456 | if (index == 0xC00) { return read8(lcd.crsrControl, bit_offset); } |
| 457 | if (index == 0xC04) { return read8(lcd.crsrConfig, bit_offset); } |
| 458 | if (index < 0xC0C && index >= 0xC08) { return read8(lcd.crsrPalette0, bit_offset); } |
| 459 | if (index < 0xC10 && index >= 0xC0C) { return read8(lcd.crsrPalette1, bit_offset); } |
| 460 | if (index < 0xC14 && index >= 0xC10) { return read8(lcd.crsrXY, bit_offset); } |
| 461 | if (index < 0xC16 && index >= 0xC14) { return read8(lcd.crsrClip, bit_offset); } |
| 462 | if (index == 0xC20) { return read8(lcd.crsrImsc, bit_offset); } |
| 463 | if (index == 0xC28) { return read8(lcd.crsrRis, bit_offset); } |
| 464 | if (index == 0xC2C) { return read8(lcd.crsrRis & lcd.crsrImsc, bit_offset); } |
| 465 | } else if (index >= 0xFE0) { |
| 466 | static const uint8_t id[1][8] = { |
| 467 | { 0x11, 0x11, 0x14, 0x00, 0x0D, 0xF0, 0x05, 0xB1 } |
| 468 | }; |
| 469 | return read8(id[0][(index - 0xFE0) >> 2], bit_offset); |
| 470 | } |
| 471 | |
| 472 | /* Return 0 if bad read */ |
| 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | void lcd_disable(void) { |
| 477 | lcd.data = NULL; |
nothing calls this directly
no test coverage detected