Skip to content

Commit

Permalink
gb: fix ldh for RGBDS 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed Dec 28, 2024
1 parent 82fecf4 commit b42421f
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions gameboy/src/gbctests.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions gameboy/src/huffnib.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gameboy/src/mdfourier.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gameboy/src/megaton.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions gameboy/src/motionblur.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -245,7 +245,7 @@ motionblur_handle_dpad::
cp h
ret nc
add l
ld [$FF00+c],a
ldh [c],a
ret


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions gameboy/src/overscan.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions gameboy/src/ppuclear.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gameboy/src/scrolltest.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gameboy/src/sgbtests.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions gameboy/src/stills.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions gameboy/src/stopwatch.z80
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b42421f

Please sign in to comment.