Skip to content

Commit b42421f

Browse files
committed
gb: fix ldh for RGBDS 0.9
1 parent 82fecf4 commit b42421f

11 files changed

Lines changed: 46 additions & 46 deletions

File tree

gameboy/src/gbctests.z80

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ gradient_push_palette:
461461
halt
462462
rept 4
463463
ld a,l
464-
ld [$FF00+c],a
464+
ldh [c],a
465465
ld a,h
466-
ld [$FF00+c],a
466+
ldh [c],a
467467
add hl,de
468468
endr
469469
dec b

gameboy/src/huffnib.z80

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ canohuff_decode_symbol:
3232
.loop:
3333
; 4 Fetch number of codes of this length
3434
inc c
35-
ld a, [$ff00 + c]
35+
ldh a, [c]
3636
ld d, a ; D: ncodesofthislength
3737

3838
; 2 Set range_end to the total number of codes seen so far,
@@ -97,7 +97,7 @@ canohuff_read_lengths:
9797
ld a, [hl+]
9898
swap a
9999
and $0F
100-
ld [$FF00 + c], a
100+
ldh [c], a
101101
inc c
102102
cp $0F
103103
jr c, .headerloop
@@ -226,7 +226,7 @@ walk_huff_tree:
226226
push de
227227
ld c, low(hTree)
228228
; Read initial literal bits from tree header
229-
ld a, [$FF00 + c]
229+
ldh a, [c]
230230
and $0C ; only initial literal bits matter
231231
.get_next_node:
232232
; A.1-0: offset to next node
@@ -237,7 +237,7 @@ walk_huff_tree:
237237
add c
238238
ld c, a
239239
inc c
240-
ld a, [$FF00 + c]
240+
ldh a, [c]
241241

242242
; A: next node
243243
; 10 Handle next bit

gameboy/src/mdfourier.z80

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ load_waveram_hl::
103103
lb bc, 16, _AUD3WAVERAM
104104
.loop:
105105
ld a, [hl+]
106-
ld [$FF00+c], a
106+
ldh [c], a
107107
inc c
108108
djnz .loop
109109
ld a, $80
@@ -134,7 +134,7 @@ mdfourier_push_apubuffer:
134134
.loop:
135135
ld c, a
136136
ld a, [hl+]
137-
ld [$FF00+c], a
137+
ldh [c], a
138138
.loopcontinue:
139139
ld a, [hl+]
140140
or a

gameboy/src/megaton.z80

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ activity_megaton_complete:
274274
ld bc,MAX_TESTS*$100+low(framecounts)
275275
.sumloop:
276276
ld d,a
277-
ld a,[$FF00+c]
277+
ldh a, [c]
278278
add d
279279
inc c
280280
dec b
@@ -431,7 +431,7 @@ grade_press:
431431
add low(framecounts)
432432
ld c, a ; C = where to write result
433433
ld a, d
434-
ld [$FF00+c],a
434+
ldh [c],a
435435
fallthrough draw_result_b
436436

437437
draw_result_b:
@@ -444,7 +444,7 @@ draw_result_b:
444444
ld a,low(framecounts)
445445
add b
446446
ld c,a
447-
ld a,[$FF00+C]
447+
ldh a, [c]
448448

449449
; Bit 7: Early
450450
push af ; Stack: raw value, which result

gameboy/src/motionblur.z80

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ motionblur_handle_dpad::
227227
; Ranges differ between mono and GBC
228228
ld a,[help_cursor_y]
229229
call de_index_a ; Valid values are L <= x < H
230-
ld a,[$FF00+c]
230+
ldh a, [c]
231231

232232
; Left/Right: Change value on this row. D = old value
233233
ld d, a
@@ -245,7 +245,7 @@ motionblur_handle_dpad::
245245
cp h
246246
ret nc
247247
add l
248-
ld [$FF00+c],a
248+
ldh [c],a
249249
ret
250250

251251

@@ -291,7 +291,7 @@ make_help_vram:
291291
ld bc,5*256+low(back_shade)
292292
ld hl,help_line_buffer
293293
.loop:
294-
ld a,[$FF00+c]
294+
ldh a, [c]
295295
push bc
296296
call bcd8bit_ac
297297
jr nz,.has_tens
@@ -332,7 +332,7 @@ motionblur_calc_bgp:
332332
add a
333333
add low(on_time)
334334
ld c,a
335-
ld a,[$FF00+c]
335+
ldh a, [c]
336336
ldh [frames_left],a
337337

338338
; And toggle to the other frame
@@ -448,10 +448,10 @@ motionblur_calc_bgp:
448448
add hl,de
449449
; write to
450450
ld a,l
451-
ld [$FF00+c],a
451+
ldh [c],a
452452
inc c
453453
ld a,h
454-
ld [$FF00+c],a
454+
ldh [c],a
455455
inc c
456456
ret
457457

gameboy/src/overscan.z80

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ activity_overscan::
138138
; Regs at this point:
139139
; C: HRAM pointer to border position
140140
; B: Direction (0: decrease; 1: increase; 2: Nothing)
141-
ld a,[$FF00+c]
141+
ldh a, [c]
142142
srl b ; direction in carry, z true if valid
143143
jr nz,.a_done
144144
jr c,.dir_is_increase
@@ -151,7 +151,7 @@ activity_overscan::
151151
; Regs: C is HRAM pointer; A is new value to write if valid
152152
cp 25
153153
jr nc,.a_done
154-
ld [$FF00+c],a
154+
ldh [c],a
155155
.a_done:
156156

157157
call overscan_draw_sprites
@@ -244,7 +244,7 @@ overscan_draw_sprites:
244244
ld a,low(right_border)
245245
add b
246246
ld c,a
247-
ld a,[$FF00+c]
247+
ldh a, [c]
248248
ld c,a ; C = size of this border
249249

250250
; Regmap:

gameboy/src/ppuclear.z80

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ SECTION "load_gbc_palette", ROM0
133133
; @param HL data source
134134
; @return HL at end, C increased by 1, B = 0, DE unchanged
135135
set_gbc_palette::
136-
ld [$FF00+c],a
136+
ldh [c],a
137137
inc c
138138
.loop:
139139
ld a,[hl+]
140-
ld [$FF00+c],a
140+
ldh [c],a
141141
dec b
142142
jr nz,.loop
143143
ret
@@ -208,7 +208,7 @@ set_gbc_mono_palette::
208208
rlca
209209
ld e,a
210210
ld a,b ; Regmap now: E=BGP<<1, A=palette offset, C=address port
211-
ld [$FF00+c],a
211+
ldh [c],a
212212
inc c ; C=data port
213213
ld b,4 ; color count
214214
ld h,high(gbmonopalette)
@@ -220,9 +220,9 @@ set_gbc_mono_palette::
220220
or low(gbmonopalette)
221221
ld l,a ; now L points to this color so stuff it into the palette
222222
ld a,[hl+]
223-
ld [$FF00+c],a
223+
ldh [c],a
224224
ld a,[hl-]
225-
ld [$FF00+c],a
225+
ldh [c],a
226226
ld a, e ; move to next bitfield of BGP
227227
rrca
228228
rrca

gameboy/src/scrolltest.z80

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,11 @@ load_kiki_bg:
781781
rla ; A=1 if alternate palette else 0
782782
ld d,a
783783
ld a,b
784-
ld [$FF00+c],a
784+
ldh [c],a
785785
ld a,d
786786
ld [hl+],a
787787
xor a
788-
ld [$FF00+c],a
788+
ldh [c],a
789789
ld a,h
790790
cp high(_SCRN1)
791791
jr c,.attrloop

gameboy/src/sgbtests.z80

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,13 @@ sgb_sound_draw_values:
800800
call .do3rows
801801
dec hl
802802
.do3rows:
803-
ld a, [$FF00+c]
803+
ldh a, [c]
804804
inc c
805805
call puthex_raw
806806
add hl, de
807807
call .do1row
808808
.do1row:
809-
ld a, [$FF00+c]
809+
ldh a, [c]
810810
inc c
811811
call putnibble_raw
812812
add hl, de

gameboy/src/stills.z80

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ activity_solid_screen::
796796

797797
add low(customred)
798798
ld c,a
799-
ld a,[$FF00+c]
799+
ldh a, [c]
800800
ld e, a ; E = last value
801801
bit PADB_RIGHT,b
802802
jr z,.not_custom_increase
@@ -809,7 +809,7 @@ activity_solid_screen::
809809
; if the new value is valid, write it back
810810
cp 32
811811
jr nc, .custom_no_change
812-
ld [$FF00+c],a
812+
ldh [c],a
813813
xor e ; set E iff changed
814814
ldh [lastlcdc], a
815815
.custom_no_change:
@@ -899,7 +899,7 @@ solid_update_rgb:
899899
.componentloop:
900900
push de
901901
ld c,e
902-
ld a,[$FF00+c]
902+
ldh a, [c]
903903
call bcd8bit_ac ; A: tens; C: ones
904904
jr z,.lessthanten
905905
push bc
@@ -1433,22 +1433,22 @@ activity_convergence::
14331433
.gbc_have_bcps:
14341434
ld hl, convergence_gbc_palette
14351435
ld bc, $0400 + low(rBCPS)
1436-
ld [$FF00+c], a
1436+
ldh [c], a
14371437
inc c
14381438
.gbcpalloop:
14391439
xor a
1440-
ld [$FF00+c], a
1441-
ld [$FF00+c], a
1442-
ld [$FF00+c], a
1443-
ld [$FF00+c], a
1440+
ldh [c], a
1441+
ldh [c], a
1442+
ldh [c], a
1443+
ldh [c], a
14441444
ld a, [hl+]
1445-
ld [$FF00+c], a
1445+
ldh [c], a
14461446
ld a, [hl-]
1447-
ld [$FF00+c], a
1447+
ldh [c], a
14481448
ld a, [hl+]
1449-
ld [$FF00+c], a
1449+
ldh [c], a
14501450
ld a, [hl+]
1451-
ld [$FF00+c], a
1451+
ldh [c], a
14521452
dec b
14531453
jr nz, .gbcpalloop
14541454
jr .palette_done

0 commit comments

Comments
 (0)