| 581 | } |
| 582 | |
| 583 | static void lcd_write(const uint16_t pio, const uint8_t value, bool poke) { |
| 584 | uint16_t index = pio & 0xFFC; |
| 585 | |
| 586 | uint8_t byte_offset = pio & 3; |
| 587 | uint8_t bit_offset = byte_offset << 3; |
| 588 | |
| 589 | uint32_t old; |
| 590 | |
| 591 | if (index < 0x200) { |
| 592 | if (index < 0x010) { |
| 593 | write8(lcd.timing[index >> 2], bit_offset, value); |
| 594 | if (!poke) { |
| 595 | lcd_write_ctrl_delay(); |
| 596 | } |
| 597 | } else if (index == 0x010) { |
| 598 | write8(lcd.upbase, bit_offset, value); |
| 599 | if (lcd.upbase & 7) { |
| 600 | gui_console_err_printf("[CEmu] Warning: Aligning LCD panel\n"); |
| 601 | } |
| 602 | lcd.upbase &= ~7U; |
| 603 | lcd_update(); |
| 604 | } else if (index == 0x014) { |
| 605 | write8(lcd.lpbase, bit_offset, value); |
| 606 | lcd.lpbase &= ~7U; |
| 607 | } else if (index == 0x018) { |
| 608 | if (!poke) { |
| 609 | lcd_write_ctrl_delay(); |
| 610 | sched_process_pending_dma(0); |
| 611 | } |
| 612 | old = lcd.control; |
| 613 | write8(lcd.control, bit_offset, value); |
| 614 | if ((lcd.control ^ old) & 1 << 0) { /* lcdEn changed */ |
| 615 | if (lcd.control & 1 << 0) { |
| 616 | lcd.compare = LCD_SYNC; |
| 617 | sched_set(SCHED_LCD, 0); |
| 618 | } else { |
| 619 | sched_clear(SCHED_LCD); |
| 620 | } |
| 621 | } |
| 622 | } else if (index == 0x01C) { |
| 623 | write8(lcd.imsc, bit_offset, value); |
| 624 | lcd.imsc &= 0x1E; |
| 625 | intrpt_set(INT_LCD, lcd.ris & lcd.imsc); |
| 626 | } else if (index == 0x028) { |
| 627 | lcd.ris &= ~(value << bit_offset); |
| 628 | intrpt_set(INT_LCD, lcd.ris & lcd.imsc); |
| 629 | } |
| 630 | lcd_update(); |
| 631 | } else if (index < 0x400) { |
| 632 | if (!poke) { |
| 633 | cpu.cycles += (4 - 2); |
| 634 | sched_process_pending_dma(0); |
| 635 | } |
| 636 | uint16_t paletteIndex = pio - 0x200; |
| 637 | if (lcd.paletteBytes[paletteIndex] != value) { |
| 638 | lcd.paletteBytes[paletteIndex] = value; |
| 639 | /* Convert to RGB565 in native endianness */ |
| 640 | paletteIndex >>= 1; |
nothing calls this directly
no test coverage detected