From 9874209fcdc33e6abe0338903f38ca01b7f1c921 Mon Sep 17 00:00:00 2001 From: spotlessmind1975 Date: Tue, 17 Dec 2024 22:05:19 +0000 Subject: [PATCH] Preserve palette on DLOAD call under cpc #1035 --- ugbc/src/hw/cpc.c | 1 + ugbc/src/hw/cpc/dload.asm | 2 ++ ugbc/src/hw/cpc/dsave.asm | 2 ++ ugbc/src/hw/cpc/startup.asm | 25 +++++++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/ugbc/src/hw/cpc.c b/ugbc/src/hw/cpc.c index d049e7396..a6a9a97a5 100755 --- a/ugbc/src/hw/cpc.c +++ b/ugbc/src/hw/cpc.c @@ -425,6 +425,7 @@ void cpc_border_color( Environment * _environment, char * _border_color ) { outline0("LD BC,$7F10"); outline0("OUT (C), C"); outline1("LD A, (%s)", _border_color); + outline0("LD (PALETTEB), A"); outline0("OR A, 0x40"); outline0("OUT (C), A"); diff --git a/ugbc/src/hw/cpc/dload.asm b/ugbc/src/hw/cpc/dload.asm index f30b44344..e3cefd923 100755 --- a/ugbc/src/hw/cpc/dload.asm +++ b/ugbc/src/hw/cpc/dload.asm @@ -87,5 +87,7 @@ CPCDLOADDONE: EXX EI + CALL RESETPALETTE + RET diff --git a/ugbc/src/hw/cpc/dsave.asm b/ugbc/src/hw/cpc/dsave.asm index b2fbae210..bf676deea 100755 --- a/ugbc/src/hw/cpc/dsave.asm +++ b/ugbc/src/hw/cpc/dsave.asm @@ -127,5 +127,7 @@ CPCDSAVEDONE: EXX EI + CALL RESETPALETTE + RET diff --git a/ugbc/src/hw/cpc/startup.asm b/ugbc/src/hw/cpc/startup.asm index 09d087594..a7a9d29ff 100755 --- a/ugbc/src/hw/cpc/startup.asm +++ b/ugbc/src/hw/cpc/startup.asm @@ -37,6 +37,8 @@ @IF vestigialConfig.rchack_pick_the_star_1163 +PALETTEB: + DB 1 PALETTE: DB 4, 10, 19, 12 DB 11, 20, 21, 13 @@ -45,6 +47,9 @@ PALETTE: @ELSE +PALETTEB: + DB 1 + @ENDIF PALETTEUNUSED: @@ -66,6 +71,26 @@ SETHWPALETTE: POP BC RET +RESETPALETTE: + LD B, 0 + LD HL, PALETTE +RESETPALETTEL1: + LD IXH, B + LD A, (HL) + LD IXL, A + CALL SETHWPALETTE + INC HL + INC B + LD A, B + CP 16 + JR NZ, RESETPALETTEL1 + LD BC, $7F10 + OUT (C), C + LD A, (PALETTEB) + OR A, 0x40 + OUT (C), A + RET + IRQTIMERVOID: RET