ref: 1abb020335e89ace4f51e1c81902e9bbe95c6af2
parent: e0e902b1c7612a582a945fd4b0bb31e3b19d5945
parent: d7757676513e9e02fc67d99a7c60c02f74344292
author: Bryan Bishop <[email protected]>
date: Wed Mar 20 16:12:48 EDT 2013
Merge pull request #124 from yenatch/master hram labels + png make target
--- a/Makefile
+++ b/Makefile
@@ -44,15 +44,15 @@
lzs: ${VERTGFX} ${HORIZGFX}
pngs:
- cd extras; python gfx.py mass-decompress; python gfx.py dump-pngs
+ cd extras && python gfx.py mass-decompress && python gfx.py dump-pngs
front.png: tiles.png
- cd extras; python gfx.py png-to-lz --front $@ $(OBJECT_DIRECTORY)/tiles.2bpp
+ cd extras && python gfx.py png-to-lz --front $@ $(OBJECT_DIRECTORY)/tiles.2bpp
tiles.png:
- cd extras; python gfx.py png-to-2bpp $@
+ cd extras && python gfx.py png-to-2bpp $@
.png: ${VERTGFX}
- cd extras; python gfx.py png-to-lz --vert $@
+ cd extras && python gfx.py png-to-lz --vert $@
.png: ${HORIZGFX}
- cd extras; python gfx.py png-to-lz $@
+ cd extras && python gfx.py png-to-lz $@
--- a/extras/gfx.py
+++ b/extras/gfx.py
@@ -1436,8 +1436,8 @@
for name in files:
if debug: print os.path.splitext(name), os.path.join(root, name)
if os.path.splitext(name)[1] == '.2bpp':
- if name[:5]+'.pal' in files:
- to_png(os.path.join(root, name), None, os.path.join(root, name[:-5]+'.pal'))
+ if os.path.splitext(name)[0]+'.pal' in files:
+ to_png(os.path.join(root, name), None, os.path.join(root, os.path.splitext(name)[0]+'.pal'))
else:
to_png(os.path.join(root, name))
@@ -1459,26 +1459,26 @@
def mass_decompress(debug=False):
for root, dirs, files in os.walk('../gfx/'):
- for file in files:
- if 'lz' in file:
+ for name in files:
+ if 'lz' in name:
if '/pics' in root:
- if 'front' in file:
+ if 'front' in name:
id = root.split('pics/')[1][:3]
if id != 'egg':
- with open(root+'/'+file, 'rb') as lz: de = Decompressed(lz.read(), 'vert', sizes[int(id)-1])
+ with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read(), 'vert', sizes[int(id)-1])
else:
- with open(root+'/'+file, 'rb') as lz: de = Decompressed(lz.read(), 'vert', 4)
- to_file(root+'/'+'front.2bpp', de.pic)
- to_file(root+'/'+'tiles.2bpp', de.animtiles)
- elif 'back' in file:
- with open(root+'/'+file, 'rb') as lz: de = Decompressed(lz.read(), 'vert')
- to_file(root+'/'+'back.2bpp', de.output)
+ with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read(), 'vert', 4)
+ to_file(os.path.join(root, 'front.2bpp'), de.pic)
+ to_file(os.path.join(root, 'tiles.2bpp'), de.animtiles)
+ elif 'back' in name:
+ with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read(), 'vert')
+ to_file(os.path.join(root, 'back.2bpp'), de.output)
elif '/trainers' in root or '/fx' in root:
- with open(root+'/'+file, 'rb') as lz: de = Decompressed(lz.read(), 'vert')
- to_file(root+'/'+file[:-3]+'.2bpp', de.output)
+ with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read(), 'vert')
+ to_file(os.path.join(root, os.path.splitext(name)[0]+'.2bpp'), de.output)
else:
- with open(root+'/'+file, 'rb') as lz: de = Decompressed(lz.read())
- to_file(root+file[:-3]+'.2bpp', de.output)
+ with open(os.path.join(root, name), 'rb') as lz: de = Decompressed(lz.read())
+ to_file(os.path.join(root, os.path.splitext(name)[0]+'.2bpp'), de.output)
def append_terminator_to_lzs(directory):
# fix lzs that were extracted with a missing terminator
--- /dev/null
+++ b/hram.asm
@@ -1,0 +1,50 @@
+hPushOAM EQU $ff80
+
+hBuffer EQU $ff8b
+
+hRTCDayHi EQU $ff8d
+hRTCDayLo EQU $ff8e
+hRTCHours EQU $ff8f
+hRTCMinutes EQU $ff90
+hRTCSeconds EQU $ff91
+
+hHours EQU $ff94
+
+hMinutes EQU $ff96
+
+hSeconds EQU $ff98
+
+hROMBank EQU $ff9d
+
+hJoypadReleased EQU $ffa2
+hJoypadPressed EQU $ffa3
+hJoypadDown EQU $ffa4
+hJoypadSum EQU $ffa5
+hJoyReleased EQU $ffa6
+hJoyPressed EQU $ffa7
+hJoyDown EQU $ffa8
+
+hPastLeadingZeroes EQU $ffb3
+
+hLCDStatCustom EQU $ffc6
+
+hBGMapMode EQU $ffd4
+hBGMapThird EQU $ffd5
+hBGMapAddress EQU $ffd6
+
+hOAMUpdate EQU $ffd8
+hSPBuffer EQU $ffd9
+
+hBGMapUpdate EQU $ffdb
+
+hTileAnimFrame EQU $ffdf
+
+hRandomAdd EQU $ffe1
+hRandomSub EQU $ffe2
+
+hBattleTurn EQU $ffe4
+hCGBPalUpdate EQU $ffe5
+hCGB EQU $ffe6
+hSGB EQU $ffe7
+hDMATransfer EQU $ffe8
+
--- a/joypad.asm
+++ b/joypad.asm
@@ -9,9 +9,9 @@
ClearJoypadPublic: ; 92f
xor a
; Pressed this frame (delta)
- ld [$ffa7], a
+ ld [hJoyPressed], a
; Currently pressed
- ld [$ffa8], a
+ ld [hJoyDown], a
ret
; 935
@@ -22,10 +22,10 @@
; Updates:
-; $ffa2: released this frame (delta)
-; $ffa3: pressed this frame (delta)
-; $ffa4: currently pressed
-; $ffa5: pressed so far
+; hJoypadReleased: released this frame (delta)
+; hJoypadPressed: pressed this frame (delta)
+; hJoypadDown: currently pressed
+; hJoypadSum: pressed so far
; Any of these three bits can be used to disable input.
ld a, [$cfbe]
@@ -76,27 +76,27 @@
ld [rJOYP], a
; To get the delta we xor the last frame's input with the new one.
- ld a, [$ffa4] ; last frame
+ ld a, [hJoypadDown] ; last frame
ld e, a
xor b
ld d, a
; Released this frame:
and e
- ld [$ffa2], a
+ ld [hJoypadReleased], a
; Pressed this frame:
ld a, d
and b
- ld [$ffa3], a
+ ld [hJoypadPressed], a
; Add any new presses to the list of collective presses:
ld c, a
- ld a, [$ffa5]
+ ld a, [hJoypadSum]
or c
- ld [$ffa5], a
+ ld [hJoypadSum], a
; Currently pressed:
ld a, b
- ld [$ffa4], a
+ ld [hJoypadDown], a
; Now that we have the input, we can do stuff with it.
@@ -110,11 +110,11 @@
GetJoypadPublic: ; 984
-; Update mirror joypad input from $ffa4 (real input)
+; Update mirror joypad input from hJoypadDown (real input)
-; $ffa6: released this frame (delta)
-; $ffa7: pressed this frame (delta)
-; $ffa8: currently pressed
+; hJoyReleased: released this frame (delta)
+; hJoyPressed: pressed this frame (delta)
+; hJoyDown: currently pressed
; bit 0 A
; 1 B
@@ -137,9 +137,9 @@
jr z, .auto
; To get deltas, take this and last frame's input.
- ld a, [$ffa4] ; real input
+ ld a, [hJoypadDown] ; real input
ld b, a
- ld a, [$ffa8] ; last frame mirror
+ ld a, [hJoyDown] ; last frame mirror
ld e, a
; Released this frame:
@@ -146,12 +146,12 @@
xor b
ld d, a
and e
- ld [$ffa6], a
+ ld [hJoyReleased], a
; Pressed this frame:
ld a, d
and b
- ld [$ffa7], a
+ ld [hJoyPressed], a
; It looks like the collective presses got commented out here.
ld c, a
@@ -158,7 +158,7 @@
; Currently pressed:
ld a, b
- ld [$ffa8], a ; frame input
+ ld [hJoyDown], a ; frame input
.quit
pop bc
@@ -174,7 +174,7 @@
; A value of $ff will immediately end the stream.
; Read from the input stream.
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
ld a, [AutoInputBank]
rst Bankswitch
@@ -232,8 +232,8 @@
pop af
rst Bankswitch
ld a, b
- ld [$ffa7], a ; pressed
- ld [$ffa8], a ; input
+ ld [hJoyPressed], a ; pressed
+ ld [hJoyDown], a ; input
jr .quit
; 9ee
@@ -251,9 +251,9 @@
ld [AutoInputLength], a
; Reset input mirrors.
xor a
- ld [$ffa7], a ; pressed this frame
- ld [$ffa6], a ; released this frame
- ld [$ffa8], a ; currently pressed
+ ld [hJoyPressed], a ; pressed this frame
+ ld [hJoyReleased], a ; released this frame
+ ld [hJoyDown], a ; currently pressed
ld a, AUTO_INPUT
ld [InputType], a
--- a/main.asm
+++ b/main.asm
@@ -7,7 +7,7 @@
jp FarJpHl
SECTION "rst10",HOME[$10] ; Bankswitch
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a
ret
@@ -219,7 +219,7 @@
; 5b7
GetClock: ; 5b7
-; store clock data in $ff8d-$ff91
+; store clock data in hRTCDayHi-hRTCSeconds
; enable clock r/w
ld a, $a
@@ -236,25 +236,25 @@
ld [hl], $8 ; S
ld a, [de]
and $3f
- ld [$ff91], a
+ ld [hRTCSeconds], a
; minutes
ld [hl], $9 ; M
ld a, [de]
and $3f
- ld [$ff90], a
+ ld [hRTCMinutes], a
; hours
ld [hl], $a ; H
ld a, [de]
and $1f
- ld [$ff8f], a
+ ld [hRTCHours], a
; day lo
ld [hl], $b ; DL
ld a, [de]
- ld [$ff8e], a
+ ld [hRTCDayLo], a
; day hi
ld [hl], $c ; DH
ld a, [de]
- ld [$ff8d], a
+ ld [hRTCDayHi], a
; cleanup
call CloseSRAM ; unlatch clock, disable clock r/w
@@ -267,16 +267,16 @@
; mod by 140
; check if day count > 255 (bit 8 set)
- ld a, [$ff8d] ; DH
+ ld a, [hRTCDayHi] ; DH
bit 0, a
jr z, .daylo
; reset dh (bit 8)
res 0, a
- ld [$ff8d], a ; DH
+ ld [hRTCDayHi], a ; DH
; mod 140
; mod twice since bit 8 (DH) was set
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
.modh
sub 140
jr nc, .modh
@@ -286,7 +286,7 @@
add 140
; update dl
- ld [$ff8e], a ; DL
+ ld [hRTCDayLo], a ; DL
; unknown output
ld a, $40 ; %1000000
@@ -294,7 +294,7 @@
.daylo
; quit if fewer than 140 days have passed
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
cp 140
jr c, .quit
@@ -305,7 +305,7 @@
add 140
; update dl
- ld [$ff8e], a ; DL
+ ld [hRTCDayLo], a ; DL
; unknown output
ld a, $20 ; %100000
@@ -327,10 +327,10 @@
FixTime: ; 61d
; add ingame time (set at newgame) to current time
; day hr min sec
-; store time in CurDay, $ff94, $ff96, $ff98
+; store time in CurDay, hHours, hMinutes, hSeconds
; second
- ld a, [$ff91] ; S
+ ld a, [hRTCSeconds] ; S
ld c, a
ld a, [StartSecond]
add c
@@ -338,11 +338,11 @@
jr nc, .updatesec
add 60
.updatesec
- ld [$ff98], a
+ ld [hSeconds], a
; minute
ccf ; carry is set, so turn it off
- ld a, [$ff90] ; M
+ ld a, [hRTCMinutes] ; M
ld c, a
ld a, [StartMinute]
adc c
@@ -350,11 +350,11 @@
jr nc, .updatemin
add 60
.updatemin
- ld [$ff96], a
+ ld [hMinutes], a
; hour
ccf ; carry is set, so turn it off
- ld a, [$ff8f] ; H
+ ld a, [hRTCHours] ; H
ld c, a
ld a, [StartHour]
adc c
@@ -362,11 +362,11 @@
jr nc, .updatehr
add 24
.updatehr
- ld [$ff94], a
+ ld [hHours], a
; day
ccf ; carry is set, so turn it off
- ld a, [$ff8e] ; DL
+ ld a, [hRTCDayLo] ; DL
ld c, a
ld a, [StartDay]
adc c
@@ -399,23 +399,23 @@
; seconds
ld [hl], $8 ; S
- ld a, [$ff91]
+ ld a, [hRTCSeconds]
ld [de], a
; minutes
ld [hl], $9 ; M
- ld a, [$ff90]
+ ld a, [hRTCMinutes]
ld [de], a
; hours
ld [hl], $a ; H
- ld a, [$ff8f]
+ ld a, [hRTCHours]
ld [de], a
; day lo
ld [hl], $b ; DL
- ld a, [$ff8e]
+ ld a, [hRTCDayLo]
ld [de], a
; day hi
ld [hl], $c ; DH
- ld a, [$ff8d]
+ ld a, [hRTCDayHi]
res 6, a ; make sure timer is active
ld [de], a
@@ -438,7 +438,7 @@
; put a away for a sec
ld [$c2c4], a
; save bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
; bankswitch
ld a, [$c2c4]
@@ -808,7 +808,7 @@
; return carry if successful
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
ret z
@@ -815,7 +815,7 @@
UpdateCGBPals: ; c33
; return carry if successful
; any pals to update?
- ld a, [$ffe5]
+ ld a, [hCGBPalUpdate]
and a
ret z
@@ -924,7 +924,7 @@
ld [rSVBK], a
; clear pal update queue
xor a
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
; successfully updated palettes
scf
ret
@@ -939,7 +939,7 @@
push af
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr z, .end
@@ -964,7 +964,7 @@
call CopyPals
; request pal update
ld a, $1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
; restore wram bank
pop af
ld [$ff70], a
@@ -988,7 +988,7 @@
ld [rOBP1], a
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
ret z
@@ -1015,7 +1015,7 @@
call CopyPals
; request pal update
ld a, $1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
; restore wram bank
pop af
ld [$ff70], a
@@ -1083,10 +1083,10 @@
; copy bc bytes from a:hl to de
FarCopyBytes: ; e8d
- ld [$ff8b], a
- ld a, [$ff9d] ; save old bank
+ ld [hBuffer], a
+ ld a, [hROMBank] ; save old bank
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
call CopyBytes
pop af
@@ -1096,10 +1096,10 @@
; copy bc*2 source bytes from a:hl to de, doubling each byte in process
FarCopyBytesDouble: ; e9b
- ld [$ff8b], a
- ld a, [$ff9d] ; save current bank
+ ld [hBuffer], a
+ ld a, [hROMBank] ; save current bank
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch ; bankswitch
ld a, h ; switcheroo, de <> hl
ld h, d
@@ -1332,7 +1332,7 @@
INCBIN "baserom.gbc",$117b,$1203 - $117b
Char5D:
- ld a, [$ffe4]
+ ld a, [hBattleTurn]
push de
and a
jr nz, .asm_120e ; 0x1207 $5
@@ -1422,7 +1422,7 @@
; return carry if successful
; anything to transfer?
- ld a, [$ffe8]
+ ld a, [hDMATransfer]
and a
ret z
; start transfer
@@ -1429,7 +1429,7 @@
ld [rHDMA5], a
; indicate that transfer has occurred
xor a
- ld [$ffe8], a
+ ld [hDMATransfer], a
; successful transfer
scf
ret
@@ -1443,7 +1443,7 @@
; return carry if successful
; any tiles to update?
- ld a, [$ffdb]
+ ld a, [hBGMapUpdate]
and a
ret z
; save wram bank
@@ -1450,7 +1450,7 @@
ld a, [rVBK]
push af
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; temp stack
ld hl, BGMapBufferPtrs
@@ -1531,7 +1531,7 @@
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1543,7 +1543,7 @@
; we don't need to update bg map until new tiles are loaded
xor a
- ld [$ffdb], a
+ ld [hBGMapUpdate], a
; successfully updated bg map
scf
@@ -1552,12 +1552,12 @@
WaitTop: ; 163a
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
and a
ret z
; wait until top third of bg map can be updated
- ld a, [$ffd5]
+ ld a, [hBGMapThird]
and a
jr z, .quit
@@ -1566,7 +1566,7 @@
.quit
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ret
; 164c
@@ -1573,7 +1573,7 @@
UpdateBGMap: ; 164c
; get mode
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
and a
ret z
@@ -1585,7 +1585,7 @@
dec a ; ?
; save bg map address
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
ld a, [$ffd7]
ld h, a
@@ -1593,12 +1593,12 @@
; bg map 1 ($9c00)
xor a
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, $9c
ld [$ffd7], a
; get mode again
- ld a, [$ffd4]
+ ld a, [hBGMapMode]
push af
cp 3
call z, .tiles
@@ -1609,7 +1609,7 @@
; restore bg map address
pop hl
ld a, l
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, h
ld [$ffd7], a
ret
@@ -1632,10 +1632,10 @@
.getthird
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; # tiles to move down * 6 (which third?)
- ld a, [$ffd5]
+ ld a, [hBGMapThird]
and a ; 0
jr z, .top
dec a ; 1
@@ -1650,7 +1650,7 @@
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; move 12 tiles down
ld de, $0180 ; bgm(0,12)
@@ -1668,7 +1668,7 @@
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; move 6 tiles down
ld de, $00c0 ; bgm(0,6)
@@ -1683,7 +1683,7 @@
; get bg map address
ld a, [$ffd7]
ld h, a
- ld a, [$ffd6]
+ ld a, [hBGMapAddress]
ld l, a
; start at middle next time
ld a, 1
@@ -1690,7 +1690,7 @@
.start
; which third to draw next update
- ld [$ffd5], a
+ ld [hBGMapThird], a
; # rows per third
ld a, 6 ; SCREEN_HEIGHT / 3
; # tiles from the edge of the screen to the next row
@@ -1754,7 +1754,7 @@
jr nz, .row
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1780,7 +1780,7 @@
GetTiles2: ; 1717
; load [$cf6c] tiles from [$cf6d-e] to [$cf6f-70]
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; sp = [$cf6d-e] tile source
ld hl, $cf6d
@@ -1856,7 +1856,7 @@
ld [$cf6d], sp
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1892,7 +1892,7 @@
; load [$cf67] tiles from [$cf68-9] to [$cf6a-b]
; save sp
- ld [$ffd9], sp
+ ld [hSPBuffer], sp
; sp = [$cf68-9] tile source
ld hl, $cf68
@@ -1971,7 +1971,7 @@
ld [$cf68], sp
; restore sp
- ld a, [$ffd9]
+ ld a, [hSPBuffer]
ld l, a
ld a, [$ffda]
ld h, a
@@ -1997,7 +1997,7 @@
; save affected banks
; switch to new banks
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af ; save bank
ld a, BANK(DoTileAnimation)
rst Bankswitch ; bankswitch
@@ -2036,7 +2036,7 @@
ld e, a
ld d, $00
add hl, de
- ld a, [$ff9d] ; current bank
+ ld a, [hROMBank] ; current bank
push af
ld a, BANK(TileTypeTable)
rst Bankswitch
@@ -2252,7 +2252,7 @@
push hl
push bc
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
ld a, [ScriptBank]
@@ -2342,7 +2342,7 @@
GetAnyMapHeaderMember: ; 0x2c0c
; bankswitch
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
ld a, BANK(MapGroupPointers)
rst Bankswitch
@@ -2396,10 +2396,10 @@
; Preserves all registers besides a.
; Switch to the new bank.
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
call .hl
@@ -2451,7 +2451,7 @@
ld [$cfb4], a
; save bank
- ld a, [$ff9d] ; current bank
+ ld a, [hROMBank] ; current bank
push af
; get Predef function to call
@@ -2595,15 +2595,15 @@
; Added value
ld a, [rDIV]
ld b, a
- ld a, [$ffe1]
+ ld a, [hRandomAdd]
adc b
- ld [$ffe1], a
+ ld [hRandomAdd], a
; Subtracted value
ld a, [rDIV]
ld b, a
- ld a, [$ffe2]
+ ld a, [hRandomSub]
sbc b
- ld [$ffe2], a
+ ld [hRandomSub], a
pop bc
ret
; 2f9f
@@ -2614,7 +2614,7 @@
; allowing link battles to remain in sync using a shared PRNG.
; Save bank
- ld a, [$ff9d] ; bank
+ ld a, [hROMBank] ; bank
push af
; Bankswitch
ld a, BANK(BattleRNG)
@@ -2642,7 +2642,7 @@
push bc
.asm_2fbb
call $2f8c
- ld a, [$ffe1]
+ ld a, [hRandomAdd]
ld c, a
add b
jr c, .asm_2fbb
@@ -2775,15 +2775,15 @@
GetFarByte: ; 0x304d
; retrieve a single byte from a:hl, and return it in a.
; bankswitch to new bank
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
; get byte from new bank
ld a, [hl]
- ld [$ff8b], a
+ ld [hBuffer], a
; bankswitch to previous bank
pop af
@@ -2790,16 +2790,16 @@
rst Bankswitch
; return retrieved value in a
- ld a, [$ff8b]
+ ld a, [hBuffer]
ret
GetFarHalfword: ; 0x305d
; retrieve a halfword from a:hl, and return it in hl.
; bankswitch to new bank
- ld [$ff8b], a
- ld a, [$ff9d]
+ ld [hBuffer], a
+ ld a, [hROMBank]
push af
- ld a, [$ff8b]
+ ld a, [hBuffer]
rst Bankswitch
; get halfword from new bank, put it in hl
@@ -2926,7 +2926,7 @@
push bc
; save oam update status
- ld hl, $ffd8
+ ld hl, hOAMUpdate
ld a, [hl]
push af
; orginally turned oam update off, commented out
@@ -2957,7 +2957,7 @@
jr nz, .wait
; wait one frame if holding a
- ld a, [$ffa8] ; joypad
+ ld a, [hJoyDown] ; joypad
bit 0, a ; A
jr z, .checkb
jr .delay
@@ -2981,7 +2981,7 @@
.end
; restore oam update flag (not touched in this fn anymore)
pop af
- ld [$ffd8], a
+ ld [hOAMUpdate], a
pop bc
pop de
pop hl
@@ -3026,7 +3026,7 @@
WaitBGMap: ; 31f6
; Tell VBlank to update BG Map
ld a, 1 ; BG Map 0 tiles
- ld [$ffd4], a
+ ld [hBGMapMode], a
; Wait for it to do its magic
ld c, 4
call DelayFrames
@@ -3039,7 +3039,7 @@
; Make all palettes white
; For CGB we make all the palette colors white
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
@@ -3067,7 +3067,7 @@
ld [$ff70], a
; Request palette update
ld a, 1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
ret
; 333e
@@ -3077,12 +3077,12 @@
; load sgb packets unless dmg
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .dosgb
; check sgb
- ld a, [$ffe7]
+ ld a, [hSGB]
and a
ret z
@@ -3132,7 +3132,7 @@
dbw $04, $4b52
GetName: ; 33c3
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
push hl
push bc
@@ -3230,7 +3230,7 @@
push hl
; Save bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
; Bankswitch
ld a, BANK(BaseStats)
@@ -3422,12 +3422,12 @@
; input:
; a: bank
; de: address
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a ; bankswitch
ld a, [de]
ld [CurMusicByte], a
ld a, $3a ; manual bank restore
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a ; bankswitch
ret
; 3b97
@@ -3439,10 +3439,10 @@
push de
push bc
push af
- ld a, [$ff9d] ; save bank
+ ld a, [hROMBank] ; save bank
push af
ld a, BANK(LoadMusic)
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a ; bankswitch
ld a, e ; song number
and a
@@ -3453,7 +3453,7 @@
call SoundRestart
.end
pop af
- ld [$ff9d], a ; restore bank
+ ld [hROMBank], a ; restore bank
ld [$2000], a
pop af
pop bc
@@ -3473,12 +3473,12 @@
push af
; Save current bank
- ld a, [$ff9d]
+ ld a, [hROMBank]
push af
; Cry headers are stuck in one bank.
ld a, BANK(CryHeaders)
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a
; Each header is 6 bytes long:
@@ -3511,13 +3511,13 @@
; That's it for the header
ld a, BANK(PlayCry)
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a
call PlayCry
; Restore bank
pop af
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a
pop af
@@ -3544,16 +3544,16 @@
cp e
jr c, .quit
.asm_3c32
- ld a, [$ff9d] ; save bank
+ ld a, [hROMBank] ; save bank
push af
ld a, $3a ; music bank
- ld [$ff9d], a
+ ld [hROMBank], a
ld [$2000], a ; bankswitch
ld a, e
ld [CurSFX], a
call LoadSFX
pop af
- ld [$ff9d], a ; restore bank
+ ld [hROMBank], a ; restore bank
ld [$2000], a ; bankswitch
.quit
pop af
@@ -3723,7 +3723,7 @@
ld hl, $cf63
inc [hl]
xor a
- ld [$ffc6], a
+ ld [hLCDStatCustom], a
; Play the title screen music.
ld de, MUSIC_TITLE
@@ -4326,11 +4326,11 @@
SpecialGameboyCheck: ; c478
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
; check sgb
- ld a, [$ffe7]
+ ld a, [hSGB]
and a
jr nz, .sgb
; gb
@@ -4376,7 +4376,7 @@
jr nz, .incrementPointer\@
bit 6, d ; left alignment or right alignment?
jr z, .incrementPointer\@
- ld a, [$ffb3] ; was H_PASTLEADINGZEROES
+ ld a, [hPastLeadingZeroes]
and a
ret z
.incrementPointer\@
@@ -4898,7 +4898,7 @@
GetTimeOfDay: ; 14032
; get time of day based on the current hour
- ld a, [$ff94] ; hour
+ ld a, [hHours] ; hour
ld hl, TimeOfDayTable
.check
@@ -6538,7 +6538,7 @@
xor a
ld [$cfca], a
ld a, $1
- ld [$ffe4], a
+ ld [hBattleTurn], a
ld a, $1
ld [$c689], a
ld de, $0101
@@ -7614,7 +7614,7 @@
EggStatsScreen: ; 4e33a
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld hl, $cda1
call $334e ; SetHPPal
ld b, $3
@@ -7706,7 +7706,7 @@
push af
set 4, [hl] ; Disable text delay
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld hl, TileMap
ld bc, $0168
ld a, " "
@@ -10090,7 +10090,7 @@
GetTimePalFade: ; 8c17c
; check cgb
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr nz, .cgb
@@ -11000,18 +11000,18 @@
; BG Map address
ld a, l
- ld [$ffd6], a
+ ld [hBGMapAddress], a
ld a, h
ld [$ffd7], a
; Only update palettes on CGB
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
jr z, .tiles
; BG Map mode 2 (palettes)
ld a, 2
- ld [$ffd4], a
+ ld [hBGMapMode], a
; The BG Map is updated in thirds, so we wait
; 3 frames to update the whole screen's palettes.
@@ -11024,7 +11024,7 @@
; Turn off BG Map update
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
ret
; 91eff
@@ -13751,10 +13751,10 @@
ld d, a
; Play this frame.
- ld a, [$ffdf] ; frame count
+ ld a, [hTileAnimFrame] ; frame count
ld l, a
inc a
- ld [$ffdf], a
+ ld [hTileAnimFrame], a
; Each pointer has:
ld h, 0
@@ -13978,7 +13978,7 @@
DoneTileAnimation: ; fc2fb
; Reset the animation command loop.
xor a
- ld [$ffdf], a
+ ld [hTileAnimFrame], a
WaitTileAnimation: ; fc2fe
; Do nothing this frame.
@@ -14050,7 +14050,7 @@
ld e, a
; CGB has different color mappings for flowers.
- ld a, [$ffe6]
+ ld a, [hCGB]
and 1
add e
@@ -14194,7 +14194,7 @@
; Transition between color values 0-2 for color 0 in palette 3.
; No palette changes on DMG.
- ld a, [$ffe6]
+ ld a, [hCGB]
and a
ret z
@@ -14367,7 +14367,7 @@
; Turn BG Map update off
xor a
- ld [$ffd4], a
+ ld [hBGMapMode], a
; Reset timing variables
ld hl, $cf63
@@ -14552,7 +14552,7 @@
; Let LCD Stat know we're messing around with SCX
ld a, rSCX - rJOYP
- ld [$ffc6], a
+ ld [hLCDStatCustom], a
; Restore WRAM bank
pop af
@@ -14579,10 +14579,10 @@
ld [$ffd2], a
ld a, $1
- ld [$ffe5], a
+ ld [hCGBPalUpdate], a
; Update BG Map 0 (bank 0)
- ld [$ffd4], a
+ ld [hBGMapMode], a
xor a
ld [$d002], a
@@ -14869,7 +14869,7 @@
jp Function117cdd
Function117b4f:
- ld a, [$ffa7]
+ ld a, [hJoyPressed]
cp $2
jr z, .asm_117ba4 ; 0x117b53 $4f
cp $1
@@ -14927,7 +14927,7 @@
Function117bb6:
call Function117c89
ld a, $1
- ld [$ffd4], a
+ ld [hBGMapMode], a
ld a, $46
ld hl, $4284
rst FarCall
--- a/pokecrystal.asm
+++ b/pokecrystal.asm
@@ -1,4 +1,5 @@
INCLUDE "wram.asm"
INCLUDE "constants.asm"
INCLUDE "gbhw.asm"
+INCLUDE "hram.asm"
INCLUDE "main.tx"
--- a/vblank.asm
+++ b/vblank.asm
@@ -128,7 +128,7 @@
jr nz, .vblankoccurred
; update oam by dma transfer
- call $ff80
+ call hPushOAM
; 403f:
; ld a, $c4
; ld [rDMA], a
@@ -230,7 +230,7 @@
call UpdateBGMap
call LoadTiles
; update oam by dma transfer
- call $ff80
+ call hPushOAM
; 403f:
; ld a, $c4
; ld [rDMA], a
@@ -339,7 +339,7 @@
call LoadTiles
; update oam by dma transfer
- call $ff80
+ call hPushOAM
; 403f:
; ld a, $c4 ; Sprites / $100
; ld [rDMA], a
@@ -411,7 +411,7 @@
call SafeLoadTiles
; update oam by dma transfer
- call $ff80
+ call hPushOAM
; 403f:
; ld a, $c4
; ld [rDMA], a