Skip to content

Commit

Permalink
Preserve palette on DLOAD call under cpc #1035
Browse files Browse the repository at this point in the history
  • Loading branch information
spotlessmind1975 committed Dec 17, 2024
1 parent e0507e8 commit 9874209
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions ugbc/src/hw/cpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 2 additions & 0 deletions ugbc/src/hw/cpc/dload.asm
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,7 @@ CPCDLOADDONE:
EXX
EI

CALL RESETPALETTE

RET

2 changes: 2 additions & 0 deletions ugbc/src/hw/cpc/dsave.asm
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,7 @@ CPCDSAVEDONE:
EXX
EI

CALL RESETPALETTE

RET

25 changes: 25 additions & 0 deletions ugbc/src/hw/cpc/startup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,6 +47,9 @@ PALETTE:

@ELSE

PALETTEB:
DB 1

@ENDIF

PALETTEUNUSED:
Expand All @@ -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

Expand Down

0 comments on commit 9874209

Please sign in to comment.