From b42421fb6c5175326b1fe446eebe22dcaa8f73e1 Mon Sep 17 00:00:00 2001 From: Damian Yerrick Date: Fri, 27 Dec 2024 23:14:53 -0500 Subject: [PATCH] gb: fix ldh for RGBDS 0.9 --- gameboy/src/gbctests.z80 | 4 ++-- gameboy/src/huffnib.z80 | 8 ++++---- gameboy/src/mdfourier.z80 | 4 ++-- gameboy/src/megaton.z80 | 6 +++--- gameboy/src/motionblur.z80 | 12 ++++++------ gameboy/src/overscan.z80 | 6 +++--- gameboy/src/ppuclear.z80 | 10 +++++----- gameboy/src/scrolltest.z80 | 4 ++-- gameboy/src/sgbtests.z80 | 4 ++-- gameboy/src/stills.z80 | 24 ++++++++++++------------ gameboy/src/stopwatch.z80 | 10 +++++----- 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/gameboy/src/gbctests.z80 b/gameboy/src/gbctests.z80 index 9cb96af..ae89674 100644 --- a/gameboy/src/gbctests.z80 +++ b/gameboy/src/gbctests.z80 @@ -461,9 +461,9 @@ gradient_push_palette: halt rept 4 ld a,l - ld [$FF00+c],a + ldh [c],a ld a,h - ld [$FF00+c],a + ldh [c],a add hl,de endr dec b diff --git a/gameboy/src/huffnib.z80 b/gameboy/src/huffnib.z80 index 3673753..eaf36db 100644 --- a/gameboy/src/huffnib.z80 +++ b/gameboy/src/huffnib.z80 @@ -32,7 +32,7 @@ canohuff_decode_symbol: .loop: ; 4 Fetch number of codes of this length inc c - ld a, [$ff00 + c] + ldh a, [c] ld d, a ; D: ncodesofthislength ; 2 Set range_end to the total number of codes seen so far, @@ -97,7 +97,7 @@ canohuff_read_lengths: ld a, [hl+] swap a and $0F - ld [$FF00 + c], a + ldh [c], a inc c cp $0F jr c, .headerloop @@ -226,7 +226,7 @@ walk_huff_tree: push de ld c, low(hTree) ; Read initial literal bits from tree header - ld a, [$FF00 + c] + ldh a, [c] and $0C ; only initial literal bits matter .get_next_node: ; A.1-0: offset to next node @@ -237,7 +237,7 @@ walk_huff_tree: add c ld c, a inc c - ld a, [$FF00 + c] + ldh a, [c] ; A: next node ; 10 Handle next bit diff --git a/gameboy/src/mdfourier.z80 b/gameboy/src/mdfourier.z80 index 5641d87..46cd0c3 100644 --- a/gameboy/src/mdfourier.z80 +++ b/gameboy/src/mdfourier.z80 @@ -103,7 +103,7 @@ load_waveram_hl:: lb bc, 16, _AUD3WAVERAM .loop: ld a, [hl+] - ld [$FF00+c], a + ldh [c], a inc c djnz .loop ld a, $80 @@ -134,7 +134,7 @@ mdfourier_push_apubuffer: .loop: ld c, a ld a, [hl+] - ld [$FF00+c], a + ldh [c], a .loopcontinue: ld a, [hl+] or a diff --git a/gameboy/src/megaton.z80 b/gameboy/src/megaton.z80 index def9a15..aba2a01 100644 --- a/gameboy/src/megaton.z80 +++ b/gameboy/src/megaton.z80 @@ -274,7 +274,7 @@ activity_megaton_complete: ld bc,MAX_TESTS*$100+low(framecounts) .sumloop: ld d,a - ld a,[$FF00+c] + ldh a, [c] add d inc c dec b @@ -431,7 +431,7 @@ grade_press: add low(framecounts) ld c, a ; C = where to write result ld a, d - ld [$FF00+c],a + ldh [c],a fallthrough draw_result_b draw_result_b: @@ -444,7 +444,7 @@ draw_result_b: ld a,low(framecounts) add b ld c,a - ld a,[$FF00+C] + ldh a, [c] ; Bit 7: Early push af ; Stack: raw value, which result diff --git a/gameboy/src/motionblur.z80 b/gameboy/src/motionblur.z80 index 0bdc212..caac5f7 100644 --- a/gameboy/src/motionblur.z80 +++ b/gameboy/src/motionblur.z80 @@ -227,7 +227,7 @@ motionblur_handle_dpad:: ; Ranges differ between mono and GBC ld a,[help_cursor_y] call de_index_a ; Valid values are L <= x < H - ld a,[$FF00+c] + ldh a, [c] ; Left/Right: Change value on this row. D = old value ld d, a @@ -245,7 +245,7 @@ motionblur_handle_dpad:: cp h ret nc add l - ld [$FF00+c],a + ldh [c],a ret @@ -291,7 +291,7 @@ make_help_vram: ld bc,5*256+low(back_shade) ld hl,help_line_buffer .loop: - ld a,[$FF00+c] + ldh a, [c] push bc call bcd8bit_ac jr nz,.has_tens @@ -332,7 +332,7 @@ motionblur_calc_bgp: add a add low(on_time) ld c,a - ld a,[$FF00+c] + ldh a, [c] ldh [frames_left],a ; And toggle to the other frame @@ -448,10 +448,10 @@ motionblur_calc_bgp: add hl,de ; write to ld a,l - ld [$FF00+c],a + ldh [c],a inc c ld a,h - ld [$FF00+c],a + ldh [c],a inc c ret diff --git a/gameboy/src/overscan.z80 b/gameboy/src/overscan.z80 index 11f26c6..fc69998 100644 --- a/gameboy/src/overscan.z80 +++ b/gameboy/src/overscan.z80 @@ -138,7 +138,7 @@ activity_overscan:: ; Regs at this point: ; C: HRAM pointer to border position ; B: Direction (0: decrease; 1: increase; 2: Nothing) - ld a,[$FF00+c] + ldh a, [c] srl b ; direction in carry, z true if valid jr nz,.a_done jr c,.dir_is_increase @@ -151,7 +151,7 @@ activity_overscan:: ; Regs: C is HRAM pointer; A is new value to write if valid cp 25 jr nc,.a_done - ld [$FF00+c],a + ldh [c],a .a_done: call overscan_draw_sprites @@ -244,7 +244,7 @@ overscan_draw_sprites: ld a,low(right_border) add b ld c,a - ld a,[$FF00+c] + ldh a, [c] ld c,a ; C = size of this border ; Regmap: diff --git a/gameboy/src/ppuclear.z80 b/gameboy/src/ppuclear.z80 index 81aa2b4..188207b 100644 --- a/gameboy/src/ppuclear.z80 +++ b/gameboy/src/ppuclear.z80 @@ -133,11 +133,11 @@ SECTION "load_gbc_palette", ROM0 ; @param HL data source ; @return HL at end, C increased by 1, B = 0, DE unchanged set_gbc_palette:: - ld [$FF00+c],a + ldh [c],a inc c .loop: ld a,[hl+] - ld [$FF00+c],a + ldh [c],a dec b jr nz,.loop ret @@ -208,7 +208,7 @@ set_gbc_mono_palette:: rlca ld e,a ld a,b ; Regmap now: E=BGP<<1, A=palette offset, C=address port - ld [$FF00+c],a + ldh [c],a inc c ; C=data port ld b,4 ; color count ld h,high(gbmonopalette) @@ -220,9 +220,9 @@ set_gbc_mono_palette:: or low(gbmonopalette) ld l,a ; now L points to this color so stuff it into the palette ld a,[hl+] - ld [$FF00+c],a + ldh [c],a ld a,[hl-] - ld [$FF00+c],a + ldh [c],a ld a, e ; move to next bitfield of BGP rrca rrca diff --git a/gameboy/src/scrolltest.z80 b/gameboy/src/scrolltest.z80 index a03de44..c41b4aa 100644 --- a/gameboy/src/scrolltest.z80 +++ b/gameboy/src/scrolltest.z80 @@ -781,11 +781,11 @@ load_kiki_bg: rla ; A=1 if alternate palette else 0 ld d,a ld a,b - ld [$FF00+c],a + ldh [c],a ld a,d ld [hl+],a xor a - ld [$FF00+c],a + ldh [c],a ld a,h cp high(_SCRN1) jr c,.attrloop diff --git a/gameboy/src/sgbtests.z80 b/gameboy/src/sgbtests.z80 index 54d4c6e..93af30e 100644 --- a/gameboy/src/sgbtests.z80 +++ b/gameboy/src/sgbtests.z80 @@ -800,13 +800,13 @@ sgb_sound_draw_values: call .do3rows dec hl .do3rows: - ld a, [$FF00+c] + ldh a, [c] inc c call puthex_raw add hl, de call .do1row .do1row: - ld a, [$FF00+c] + ldh a, [c] inc c call putnibble_raw add hl, de diff --git a/gameboy/src/stills.z80 b/gameboy/src/stills.z80 index 4ba6825..076257e 100644 --- a/gameboy/src/stills.z80 +++ b/gameboy/src/stills.z80 @@ -796,7 +796,7 @@ activity_solid_screen:: add low(customred) ld c,a - ld a,[$FF00+c] + ldh a, [c] ld e, a ; E = last value bit PADB_RIGHT,b jr z,.not_custom_increase @@ -809,7 +809,7 @@ activity_solid_screen:: ; if the new value is valid, write it back cp 32 jr nc, .custom_no_change - ld [$FF00+c],a + ldh [c],a xor e ; set E iff changed ldh [lastlcdc], a .custom_no_change: @@ -899,7 +899,7 @@ solid_update_rgb: .componentloop: push de ld c,e - ld a,[$FF00+c] + ldh a, [c] call bcd8bit_ac ; A: tens; C: ones jr z,.lessthanten push bc @@ -1433,22 +1433,22 @@ activity_convergence:: .gbc_have_bcps: ld hl, convergence_gbc_palette ld bc, $0400 + low(rBCPS) - ld [$FF00+c], a + ldh [c], a inc c .gbcpalloop: xor a - ld [$FF00+c], a - ld [$FF00+c], a - ld [$FF00+c], a - ld [$FF00+c], a + ldh [c], a + ldh [c], a + ldh [c], a + ldh [c], a ld a, [hl+] - ld [$FF00+c], a + ldh [c], a ld a, [hl-] - ld [$FF00+c], a + ldh [c], a ld a, [hl+] - ld [$FF00+c], a + ldh [c], a ld a, [hl+] - ld [$FF00+c], a + ldh [c], a dec b jr nz, .gbcpalloop jr .palette_done diff --git a/gameboy/src/stopwatch.z80 b/gameboy/src/stopwatch.z80 index bd79347..ecd5956 100644 --- a/gameboy/src/stopwatch.z80 +++ b/gameboy/src/stopwatch.z80 @@ -272,26 +272,26 @@ activity_stopwatch:: sw_inc_counter: lb bc, frames_bcd - hours, low(frames_bcd) .loop: - ld a, [$FF00+c] + ldh a, [c] inc a daa - ld [$FF00+C], a + ldh [c], a cp $60 ret c ; If increased past 60, clear it and continue to the next digit xor a - ld [$FF00+C], a + ldh [c], a dec c dec b jr nz, .loop - ld a,[$FF00+C] ; Hours wrap at 10, not 60 + ldh a, [c] ; Hours wrap at 10, not 60 inc a cp 10 jr c,.not_wrap_hours xor a .not_wrap_hours: - ld [$FF00+C],a + ldh [c],a ret digits_label_msg: