From f56f340ce115d049374678bffc7509e89a6d31ca Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 20 Feb 2013 02:46:40 -0500 Subject: [PATCH] Label hw registers --- audio/engine.asm | 180 +++++++++++++++++++++++------------------------ joypad.asm | 22 +++--- main.asm | 128 ++++++++++++++++----------------- vblank.asm | 78 ++++++++++---------- 4 files changed, 204 insertions(+), 204 deletions(-) diff --git a/audio/engine.asm b/audio/engine.asm index a45f6564c..ddb20a986 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -16,27 +16,27 @@ SoundRestart: ; e8000 push bc push af call MusicOff - ld hl, $ff24 ; channel control registers + ld hl, rNR50 ; channel control registers xor a - ld [hli], a ; ff24 ; volume/vin - ld [hli], a ; ff25 ; sfx channels + ld [hli], a ; rNR50 ; volume/vin + ld [hli], a ; rNR51 ; sfx channels ld a, $80 ; all channels on ld [hli], a ; ff26 ; music channels - ld hl, $ff10 ; sound channel registers + ld hl, rNR10 ; sound channel registers ld e, $04 ; number of channels .clearsound ; sound channel 1 2 3 4 xor a - ld [hli], a ; $ff10, $ff15, $ff1a, $ff1f ; sweep = 0 + ld [hli], a ; rNR10, $ff15, rNR30, $ff1f ; sweep = 0 - ld [hli], a ; $ff11, $ff16, $ff1b, $ff20 ; length/wavepattern = 0 + ld [hli], a ; rNR11, rNR21, rNR31, rNR41 ; length/wavepattern = 0 ld a, $08 - ld [hli], a ; $ff12, $ff17, $ff1c, $ff21 ; envelope = 0 + ld [hli], a ; rNR12, rNR22, rNR32, rNR42 ; envelope = 0 xor a - ld [hli], a ; $ff13, $ff18, $ff1d, $ff22 ; frequency lo = 0 + ld [hli], a ; rNR13, rNR23, rNR33, rNR43 ; frequency lo = 0 ld a, $80 - ld [hli], a ; $ff14, $ff19, $ff1e, $ff23 ; restart sound (freq hi = 0) + ld [hli], a ; rNR14, rNR24, rNR34, rNR44 ; restart sound (freq hi = 0) dec e jr nz, .clearsound @@ -208,10 +208,10 @@ UpdateSound: ; e805c call FadeMusic ; write volume to hardware register ld a, [Volume] - ld [$ff24], a + ld [rNR50], a ; write SO on/off to hardware register ld a, [SoundOutput] - ld [$ff25], a + ld [rNR51], a ret ; e8125 @@ -251,7 +251,7 @@ UpdateChannels: ; e8125 jr z, .asm_e8159 ; ld a, [SoundInput] - ld [$ff10], a + ld [rNR10], a .asm_e8159 bit 5, [hl] ; rest jr nz, .ch1rest @@ -264,48 +264,48 @@ UpdateChannels: ; e8125 jr .asm_e8175 .asm_e816b ld a, [$c294] - ld [$ff13], a + ld [rNR13], a ld a, [$c295] - ld [$ff14], a + ld [rNR14], a .asm_e8175 bit 0, [hl] ret z ld a, [$c292] ld d, a - ld a, [$ff11] + ld a, [rNR11] and a, $3f ; sound length or d - ld [$ff11], a + ld [rNR11], a ret .asm_e8184 ld a, [$c292] ld d, a - ld a, [$ff11] + ld a, [rNR11] and a, $3f ; sound length or d - ld [$ff11], a + ld [rNR11], a ld a, [$c294] - ld [$ff13], a + ld [rNR13], a ret .ch1rest - ld a, [$ff26] + ld a, [rNR52] and a, %10001110 ; ch1 off - ld [$ff26], a - ld hl, $ff10 + ld [rNR52], a + ld hl, rNR10 call ClearChannel ret .asm_e81a2 ld hl, $c292 ld a, $3f ; sound length or [hl] - ld [$ff11], a + ld [rNR11], a ld a, [$c293] - ld [$ff12], a + ld [rNR12], a ld a, [$c294] - ld [$ff13], a + ld [rNR13], a ld a, [$c295] or a, $80 - ld [$ff14], a + ld [rNR14], a ret .Channel2 @@ -322,31 +322,31 @@ UpdateChannels: ; e8125 ret z ld a, [$c292] ld d, a - ld a, [$ff16] + ld a, [rNR21] and a, $3f ; sound length or d - ld [$ff16], a + ld [rNR21], a ret .asm_e81db ; unused ld a, [$c294] - ld [$ff18], a + ld [rNR23], a ld a, [$c295] - ld [$ff19], a + ld [rNR24], a ret .asm_e81e6 ld a, [$c292] ld d, a - ld a, [$ff16] + ld a, [rNR21] and a, $3f ; sound length or d - ld [$ff16], a + ld [rNR21], a ld a, [$c294] - ld [$ff18], a + ld [rNR23], a ret .ch2rest - ld a, [$ff26] + ld a, [rNR52] and a, %10001101 ; ch2 off - ld [$ff26], a + ld [rNR52], a ld hl, $ff15 call ClearChannel ret @@ -354,14 +354,14 @@ UpdateChannels: ; e8125 ld hl, $c292 ld a, $3f ; sound length or [hl] - ld [$ff16], a + ld [rNR21], a ld a, [$c293] - ld [$ff17], a + ld [rNR22], a ld a, [$c294] - ld [$ff18], a + ld [rNR23], a ld a, [$c295] or a, $80 ; initial (restart) - ld [$ff19], a + ld [rNR24], a ret .Channel3 @@ -377,34 +377,34 @@ UpdateChannels: ; e8125 ret .asm_e822f ; unused ld a, [$c294] - ld [$ff1d], a + ld [rNR33], a ld a, [$c295] - ld [$ff1e], a + ld [rNR34], a ret .asm_e823a ld a, [$c294] - ld [$ff1d], a + ld [rNR33], a ret .ch3rest - ld a, [$ff26] + ld a, [rNR52] and a, %10001011 ; ch3 off - ld [$ff26], a - ld hl, $ff1a + ld [rNR52], a + ld hl, rNR30 call ClearChannel ret .asm_e824d ld a, $3f - ld [$ff1b], a + ld [rNR31], a xor a - ld [$ff1a], a + ld [rNR30], a call .asm_e8268 ld a, $80 - ld [$ff1a], a + ld [rNR30], a ld a, [$c294] - ld [$ff1d], a + ld [rNR33], a ld a, [$c295] or a, $80 - ld [$ff1e], a + ld [rNR34], a ret .asm_e8268 push hl @@ -458,7 +458,7 @@ UpdateChannels: ; e8125 ld a, [$c293] and a, $f0 sla a - ld [$ff1c], a + ld [rNR32], a ret .Channel4 @@ -472,24 +472,24 @@ UpdateChannels: ; e8125 ret .asm_e82c1 ; unused ld a, [$c294] - ld [$ff22], a + ld [rNR43], a ret .ch4rest - ld a, [$ff26] + ld a, [rNR52] and a, %10000111 ; ch4 off - ld [$ff26], a + ld [rNR52], a ld hl, $ff1f call ClearChannel ret .asm_e82d4 ld a, $3f ; sound length - ld [$ff20], a + ld [rNR41], a ld a, [$c293] - ld [$ff21], a + ld [rNR42], a ld a, [$c294] - ld [$ff22], a + ld [rNR43], a ld a, $80 - ld [$ff23], a + ld [rNR44], a ret ; e82e7 @@ -535,15 +535,15 @@ Functione8307: ; e8307 ld hl, Tablee8350 .updatehw xor a - ld [$ff10], a ; sweep off + ld [rNR10], a ; sweep off ld a, [hli] - ld [$ff11], a ; sound length / duty cycle + ld [rNR11], a ; sound length / duty cycle ld a, [hli] - ld [$ff12], a ; ch1 volume envelope + ld [rNR12], a ; ch1 volume envelope ld a, [hli] - ld [$ff13], a ; ch1 frequency lo + ld [rNR13], a ; ch1 frequency lo ld a, [hli] - ld [$ff14], a ; ch1 frequency hi + ld [rNR14], a ; ch1 frequency hi .asm_e8335 ld a, d inc a @@ -1192,7 +1192,7 @@ ParseMusic: ; e85e1 jr nz, .ok ; ???? xor a - ld [$ff10], a ; sweep = 0 + ld [rNR10], a ; sweep = 0 .ok ; stop playing ; turn channel off @@ -2454,56 +2454,56 @@ LoadSFX: ; e8c04 jr z, .ch6 res 0, [hl] ; turn it off xor a - ld [$ff11], a ; length/wavepattern = 0 + ld [rNR11], a ; length/wavepattern = 0 ld a, $08 - ld [$ff12], a ; envelope = 0 + ld [rNR12], a ; envelope = 0 xor a - ld [$ff13], a ; frequency lo = 0 + ld [rNR13], a ; frequency lo = 0 ld a, $80 - ld [$ff14], a ; restart sound (freq hi = 0) + ld [rNR14], a ; restart sound (freq hi = 0) xor a ld [SoundInput], a ; global sound off - ld [$ff10], a ; sweep = 0 + ld [rNR10], a ; sweep = 0 .ch6 ld hl, $c1fe ; ch6 on? bit 0, [hl] jr z, .ch7 res 0, [hl] ; turn it off xor a - ld [$ff16], a ; length/wavepattern = 0 + ld [rNR21], a ; length/wavepattern = 0 ld a, $08 - ld [$ff17], a ; envelope = 0 + ld [rNR22], a ; envelope = 0 xor a - ld [$ff18], a ; frequency lo = 0 + ld [rNR23], a ; frequency lo = 0 ld a, $80 - ld [$ff19], a ; restart sound (freq hi = 0) + ld [rNR24], a ; restart sound (freq hi = 0) .ch7 ld hl, $c230 ; ch7 on? bit 0, [hl] jr z, .ch8 res 0, [hl] ; turn it off xor a - ld [$ff1a], a ; sound mode #3 off - ld [$ff1b], a ; length/wavepattern = 0 + ld [rNR30], a ; sound mode #3 off + ld [rNR31], a ; length/wavepattern = 0 ld a, $08 - ld [$ff1c], a ; envelope = 0 + ld [rNR32], a ; envelope = 0 xor a - ld [$ff1d], a ; frequency lo = 0 + ld [rNR33], a ; frequency lo = 0 ld a, $80 - ld [$ff1e], a ; restart sound (freq hi = 0) + ld [rNR34], a ; restart sound (freq hi = 0) .ch8 ld hl, $c262 ; ch8 on? bit 0, [hl] jr z, .chscleared res 0, [hl] ; turn it off xor a - ld [$ff20], a ; length/wavepattern = 0 + ld [rNR41], a ; length/wavepattern = 0 ld a, $08 - ld [$ff21], a ; envelope = 0 + ld [rNR42], a ; envelope = 0 xor a - ld [$ff22], a ; frequency lo = 0 + ld [rNR43], a ; frequency lo = 0 ld a, $80 - ld [$ff23], a ; restart sound (freq hi = 0) + ld [rNR44], a ; restart sound (freq hi = 0) xor a ld [NoiseSampleAddressLo], a ld [NoiseSampleAddressHi], a @@ -3126,13 +3126,13 @@ ChannelPointers: ; e8fd9 ClearChannels: ; e8fe9 ; runs ClearChannel for all 4 channels ; doesn't seem to be used, but functionally identical to SoundRestart - ld hl, $ff24 + ld hl, rNR50 xor a ld [hli], a ld [hli], a ld a, $80 ld [hli], a - ld hl, $ff10 + ld hl, rNR10 ld e, $04 .loop call ClearChannel @@ -3142,19 +3142,19 @@ ClearChannels: ; e8fe9 ; e8ffe ClearChannel: ; e8ffe -; input: hl = beginning hw sound register ($ff10, $ff15, $ff1a, $ff1f) +; input: hl = beginning hw sound register (rNR10, $ff15, rNR30, $ff1f) ; output: 00 00 80 00 80 ; sound channel 1 2 3 4 xor a - ld [hli], a ; $ff10, $ff15, $ff1a, $ff1f ; sweep = 0 + ld [hli], a ; rNR10, $ff15, rNR30, $ff1f ; sweep = 0 - ld [hli], a ; $ff11, $ff16, $ff1b, $ff20 ; length/wavepattern = 0 + ld [hli], a ; rNR11, rNR21, rNR31, rNR41 ; length/wavepattern = 0 ld a, $08 - ld [hli], a ; $ff12, $ff17, $ff1c, $ff21 ; envelope = 0 + ld [hli], a ; rNR12, rNR22, rNR32, rNR42 ; envelope = 0 xor a - ld [hli], a ; $ff13, $ff18, $ff1d, $ff22 ; frequency lo = 0 + ld [hli], a ; rNR13, rNR23, rNR33, rNR43 ; frequency lo = 0 ld a, $80 - ld [hli], a ; $ff14, $ff19, $ff1e, $ff23 ; restart sound (freq hi = 0) + ld [hli], a ; rNR14, rNR24, rNR34, rNR44 ; restart sound (freq hi = 0) ret ; e900a diff --git a/joypad.asm b/joypad.asm index 2488ba1df..099bfbef6 100644 --- a/joypad.asm +++ b/joypad.asm @@ -40,10 +40,10 @@ Joypad: ; 935 ; We can only get four inputs at a time. ; We take d-pad first for no particular reason. ld a, D_PAD - ld [$ff00], a + ld [rJOYP], a ; Read twice to give the request time to take. - ld a, [$ff00] - ld a, [$ff00] + ld a, [rJOYP] + ld a, [rJOYP] ; The Joypad register output is in the lo nybble (inversed). ; We make the hi nybble of our new container d-pad input. @@ -57,14 +57,14 @@ Joypad: ; 935 ; Buttons make 8 total inputs (A, B, Select, Start). ; We can fit this into one byte. ld a, BUTTONS - ld [$ff00], a + ld [rJOYP], a ; Wait for input to stabilize. - ld a, [$ff00] - ld a, [$ff00] - ld a, [$ff00] - ld a, [$ff00] - ld a, [$ff00] - ld a, [$ff00] + ld a, [rJOYP] + ld a, [rJOYP] + ld a, [rJOYP] + ld a, [rJOYP] + ld a, [rJOYP] + ld a, [rJOYP] ; Buttons take the lo nybble. cpl and $f @@ -73,7 +73,7 @@ Joypad: ; 935 ; Reset the joypad register since we're done with it. ld a, $30 - ld [$ff00], a + ld [rJOYP], a ; To get the delta we xor the last frame's input with the new one. ld a, [$ffa4] ; last frame diff --git a/main.asm b/main.asm index fd2a1965f..10c1a3c8d 100644 --- a/main.asm +++ b/main.asm @@ -150,47 +150,47 @@ DisableLCD: ; 568 ; Most of this is just going through the motions ; don't need to do anything if lcd is already off - ld a, [$ff40] ; LCDC + ld a, [rLCDC] bit 7, a ; lcd enable ret z ; reset ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; save enabled ints - ld a, [$ffff] ; IE + ld a, [rIE] ld b, a ; disable vblank res 0, a ; vblank - ld [$ffff], a ; IE + ld [rIE], a .wait ; wait until vblank - ld a, [$ff44] ; LY + ld a, [rLY] cp 145 ; >144 (ensure beginning of vblank) jr nz, .wait ; turn lcd off - ld a, [$ff40] ; LCDC + ld a, [rLCDC] and %01111111 ; lcd enable off - ld [$ff40], a ; LCDC + ld [rLCDC], a ; reset ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; restore enabled ints ld a, b - ld [$ffff], a ; IE + ld [rIE], a ret ; 58a EnableLCD: ; 58a - ld a, [$ff40] ; LCDC + ld a, [rLCDC] set 7, a ; lcd enable - ld [$ff40], a ; LCDC + ld [rLCDC], a ret ; 591 @@ -822,18 +822,18 @@ UpdateCGBPals: ; c33 ForceUpdateCGBPals: ; c37 ; save wram bank - ld a, [$ff70] ; wram bank + ld a, [rSVBK] push af ; bankswitch ld a, 5 ; BANK(BGPals) - ld [$ff70], a ; wram bank + ld [rSVBK], a ; get bg pal buffer ld hl, BGPals ; 5:d080 ; update bg pals ld a, %10000000 ; auto increment, index 0 - ld [$ff68], a ; BGPI - ld c, $69 ; $ff69 + ld [rBGPI], a + ld c, rBGPD - rJOYP ld b, 4 ; NUM_PALS / 2 .bgp @@ -878,8 +878,8 @@ ForceUpdateCGBPals: ; c37 ; update obj pals ld a, %10000000 ; auto increment, index 0 - ld [$ff6a], a - ld c, $6b ; $ff6b - $ff00 + ld [rOBPI], a + ld c, rOBPD - rJOYP ld b, 4 ; NUM_PALS / 2 .obp @@ -922,7 +922,7 @@ ForceUpdateCGBPals: ; c37 ; restore wram bank pop af - ld [$ff70], a ; wram bank + ld [rSVBK], a ; clear pal update queue xor a ld [$ffe5], a @@ -936,7 +936,7 @@ DmgToCgbBGPals: ; c9f ; exists to forego reinserting cgb-converted image data ; input: a -> bgp - ld [$ff47], a ; bgp + ld [rBGP], a push af ; check cgb @@ -958,7 +958,7 @@ DmgToCgbBGPals: ; c9f ld hl, BGPals ; to ld de, Unkn1Pals ; from ; order - ld a, [$ff47] ; bgp + ld a, [rBGP] ld b, a ; # pals ld c, 8 ; all pals @@ -984,9 +984,9 @@ DmgToCgbObjPals: ; ccb ; input: d -> obp1 ; e -> obp2 ld a, e - ld [$ff48], a ; obp0 + ld [rOBP0], a ld a, d - ld [$ff49], a ; obp1 + ld [rOBP1], a ; check cgb ld a, [$ffe6] @@ -1009,7 +1009,7 @@ DmgToCgbObjPals: ; ccb ; from ld de, Unkn2Pals ; order - ld a, [$ff48] ; obp0 + ld a, [rOBP0] ld b, a ; # pals ld c, 8 ; all pals @@ -1137,7 +1137,7 @@ ClearTileMap: ; fc8 call ByteFill ; We aren't done if the LCD is on - ld a, [$ff40] ; LCDC + ld a, [rLCDC] bit 7, a ret z jp WaitBGMap @@ -1427,7 +1427,7 @@ DMATransfer: ; 15d8 and a ret z ; start transfer - ld [$ff55], a ; hdma5 + ld [rHDMA5], a ; indicate that transfer has occurred xor a ld [$ffe8], a @@ -1448,7 +1448,7 @@ UpdateBGMapBuffer: ; 15e3 and a ret z ; save wram bank - ld a, [$ff4f] ; vram bank + ld a, [rVBK] push af ; save sp ld [$ffd9], sp @@ -1471,7 +1471,7 @@ UpdateBGMapBuffer: ; 15e3 pop bc ; update palettes ld a, $1 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; tile 1 ld a, [hli] ld [bc], a @@ -1482,7 +1482,7 @@ UpdateBGMapBuffer: ; 15e3 dec c ; update tiles ld a, $0 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; tile 1 ld a, [de] inc de @@ -1499,7 +1499,7 @@ UpdateBGMapBuffer: ; 15e3 pop bc ; update palettes ld a, $1 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; tile 1 ld a, [hli] ld [bc], a @@ -1510,7 +1510,7 @@ UpdateBGMapBuffer: ; 15e3 dec c ; update tiles ld a, $0 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; tile 1 ld a, [de] inc de @@ -1540,7 +1540,7 @@ UpdateBGMapBuffer: ; 15e3 ; restore vram bank pop af - ld [$ff4f], a ; vram bank + ld [rVBK], a ; we don't need to update bg map until new tiles are loaded xor a @@ -1618,13 +1618,13 @@ UpdateBGMap: ; 164c .attr ; switch vram banks ld a, 1 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; bg map 1 ld hl, AttrMap call .getthird ; restore vram bank ld a, 0 - ld [$ff4f], a ; vram bank + ld [rVBK], a ret .tiles @@ -1771,7 +1771,7 @@ SafeLoadTiles2: ; 170a and a ret z ; abort if too far into vblank - ld a, [$ff44] ; LY + ld a, [rLY] ; ly = 144-145? cp 144 ret c @@ -1873,7 +1873,7 @@ SafeLoadTiles: ; 1769 and a ret z ; abort if too far into vblank - ld a, [$ff44] ; LY + ld a, [rLY] ; ly = 144-145? cp 144 ret c @@ -1989,7 +1989,7 @@ SafeTileAnimation: ; 17d3 ret z ; abort if too far into vblank - ld a, [$ff44] ; LY + ld a, [rLY] ; ret unless ly = 144-150 cp 144 ret c @@ -2003,24 +2003,24 @@ SafeTileAnimation: ; 17d3 ld a, BANK(DoTileAnimation) rst Bankswitch ; bankswitch - ld a, [$ff70] ; wram bank + ld a, [rSVBK] push af ; save wram bank ld a, $1 ; wram bank 1 - ld [$ff70], a ; wram bank + ld [rSVBK], a - ld a, [$ff4f] ; vram bank + ld a, [rVBK] push af ; save vram bank ld a, $0 ; vram bank 0 - ld [$ff4f], a ; vram bank + ld [rVBK], a ; take care of tile animation queue call DoTileAnimation ; restore affected banks pop af - ld [$ff4f], a ; vram bank + ld [rVBK], a pop af - ld [$ff70], a ; wram bank + ld [rSVBK], a pop af rst Bankswitch ; bankswitch ret @@ -2078,15 +2078,15 @@ AskSerial: ; 2063 ; handshake ld a, $88 - ld [$ff01], a + ld [rSB], a ; switch to internal clock ld a, %00000001 - ld [$ff02], a + ld [rSC], a ; start transfer ld a, %10000001 - ld [$ff02], a + ld [rSC], a ret ; 208a @@ -2098,17 +2098,17 @@ GameTimer: ; 209e nop ; save wram bank - ld a, [$ff70] ; wram bank + ld a, [rSVBK] push af ld a, $1 - ld [$ff70], a ; wram bank + ld [rSVBK], a call UpdateGameTimer ; restore wram bank pop af - ld [$ff70], a ; wram bank + ld [rSVBK], a ret ; 20ad @@ -2523,13 +2523,13 @@ RNG: ; 2f8c push bc ; Added value - ld a, [$ff04] ; divider + ld a, [rDIV] ld b, a ld a, [$ffe1] adc b ld [$ffe1], a ; Subtracted value - ld a, [$ff04] ; divider + ld a, [rDIV] ld b, a ld a, [$ffe2] sbc b @@ -2975,9 +2975,9 @@ ClearPalettes: ; 3317 ; In DMG mode, we can just change palettes to 0 (white) xor a - ld [$ff47], a ; BGP - ld [$ff48], a ; OBP0 - ld [$ff49], a ; OBP1 + ld [rBGP], a + ld [rOBP0], a + ld [rOBP1], a ret .cgb @@ -8827,11 +8827,11 @@ TimeOfDayPals: ; 8c011 ld hl, $d038 ; Unkn1Pals + 7 pals ; save wram bank - ld a, [$ff70] ; wram bank + ld a, [rSVBK] ld b, a ; wram bank 5 ld a, 5 - ld [$ff70], a ; wram bank + ld [rSVBK], a ; push palette ld c, 4 ; NUM_PAL_COLORS @@ -8846,7 +8846,7 @@ TimeOfDayPals: ; 8c011 ; restore wram bank ld a, b - ld [$ff70], a ; wram bank + ld [rSVBK], a ; update sgb pals @@ -8858,11 +8858,11 @@ TimeOfDayPals: ; 8c011 ld hl, $d03f ; last byte in Unkn1Pals ; save wram bank - ld a, [$ff70] ; wram bank + ld a, [rSVBK] ld d, a ; wram bank 5 ld a, 5 - ld [$ff70], a ; wram bank + ld [rSVBK], a ; pop palette ld e, 4 ; NUM_PAL_COLORS @@ -8877,7 +8877,7 @@ TimeOfDayPals: ; 8c011 ; restore wram bank ld a, d - ld [$ff70], a ; wram bank + ld [rSVBK], a ; update palettes call UpdateTimePals @@ -12683,7 +12683,7 @@ TitleScreen: ; 10ed67 ; VRAM bank 1 ld a, 1 - ld [$ff4f], a + ld [rVBK], a ; Decompress running Suicune gfx @@ -12756,7 +12756,7 @@ TitleScreen: ; 10ed67 ; Back to VRAM bank 0 ld a, $0 - ld [$ff4f], a + ld [rVBK], a ; Decompress logo @@ -12852,7 +12852,7 @@ TitleScreen: ; 10ed67 call ByteFill ; Let LCD Stat know we're messing around with SCX - ld a, $43 ; ff43 ; SCX + ld a, rSCX - rJOYP ld [$ffc6], a ; Restore WRAM bank @@ -12865,9 +12865,9 @@ TitleScreen: ; 10ed67 call $058a ; Set sprite size to 8x16 - ld a, [$ff40] ; LCDC + ld a, [rLCDC] set 2, a - ld [$ff40], a ; LCDC + ld [rLCDC], a ; ld a, $70 diff --git a/vblank.asm b/vblank.asm index 78d7151f0..8201c1e5c 100644 --- a/vblank.asm +++ b/vblank.asm @@ -69,13 +69,13 @@ VBlank0: ; 2b1 inc [hl] ; advance rng - ld a, [$ff04] ; divider + ld a, [rDIV] ld b, a ld a, [$ffe1] adc b ld [$ffe1], a - ld a, [$ff04] ; divider + ld a, [rDIV] ld b, a ld a, [$ffe2] sbc b @@ -87,16 +87,16 @@ VBlank0: ; 2b1 ; scroll x ld a, [$ffcf] - ld [$ff43], a ; scx + ld [rSCX], a ; scroll y ld a, [$ffd0] - ld [$ff42], a ; scy + ld [rSCY], a ; window y ld a, [$ffd2] - ld [$ff4a], a ; wy + ld [rWY], a ; window x + 7 ld a, [$ffd1] - ld [$ff4b], a ; wx + ld [rWX], a ; some time management is in order ; only have time for one of these during vblank @@ -131,7 +131,7 @@ VBlank0: ; 2b1 call $ff80 ; 403f: ; ld a, $c4 -; ld [$ff46], a ; oam dma +; ld [rDMA], a ; ld a, $28 ; .loop ; dec a @@ -216,11 +216,11 @@ VBlank1: ; 337 ; scroll x ld a, [$ffcf] - ld [$ff43], a ; scx + ld [rSCX], a ; scroll y ld a, [$ffd0] - ld [$ff42], a ; scy + ld [rSCY], a ; time-sensitive fns call UpdatePals @@ -233,7 +233,7 @@ VBlank1: ; 337 call $ff80 ; 403f: ; ld a, $c4 -; ld [$ff46], a ; oam dma +; ld [rDMA], a ; ld a, $28 ; .loop ; dec a @@ -246,20 +246,20 @@ VBlank1: ; 337 ld [VBlankOccurred], a ; get requested ints - ld a, [$ff0f] ; IF + ld a, [rIF] ld b, a ; discard requested ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; enable lcd stat ld a, %10 ; lcd stat - ld [$ffff], a ; IE + ld [rIE], a ; rerequest serial int if applicable (still disabled) ; request lcd stat ld a, b and %1000 ; serial or %10 ; lcd stat - ld [$ff0f], a ; IF + ld [rIF], a ei ; update sound @@ -272,17 +272,17 @@ VBlank1: ; 337 di ; get requested ints - ld a, [$ff0f] ; IF + ld a, [rIF] ld b, a ; discard requested ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; enable ints besides joypad ld a, %1111 ; serial timer lcdstat vblank - ld [$ffff], a ; IE + ld [rIE], a ; rerequest ints ld a, b - ld [$ff0f], a ; IF + ld [rIF], a ret ; 37f @@ -297,13 +297,13 @@ UpdatePals: ; 37f ; update gb pals ld a, [$cfc7] - ld [$ff47], a ; BGP + ld [rBGP], a ld a, [$cfc8] - ld [$ff48], a ; OBP0 + ld [rOBP0], a ld a, [$cfc9] - ld [$ff49], a ; 0BP1 + ld [rOBP1], a and a ret @@ -324,10 +324,10 @@ VBlank3: ; 396 ; scroll x ld a, [$ffcf] - ld [$ff43], a ; scx + ld [rSCX], a ; scroll y ld a, [$ffd0] - ld [$ff42], a ; scy + ld [rSCY], a ; any pals to update? ld a, [$ffe5] @@ -342,7 +342,7 @@ VBlank3: ; 396 call $ff80 ; 403f: ; ld a, $c4 ; Sprites / $100 -; ld [$ff46], a ; oam dma +; ld [rDMA], a ; ld a, $28 ; .loop ; dec a @@ -355,15 +355,15 @@ VBlank3: ; 396 ld [VBlankOccurred], a ; save int flag - ld a, [$ff0f] ; IF + ld a, [rIF] push af ; reset ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; force lcdstat int during sound update ld a, %10 ; lcd stat - ld [$ffff], a ; IE - ld [$ff0f], a ; IF + ld [rIE], a + ld [rIF], a ei ; update sound @@ -376,7 +376,7 @@ VBlank3: ; 396 di ; request lcdstat - ld a, [$ff0f] ; IF + ld a, [rIF] ld b, a ; and any other ints pop af @@ -384,13 +384,13 @@ VBlank3: ; 396 ld b, a ; reset ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; enable ints besides joypad ld a, %1111 ; serial timer lcdstat vblank - ld [$ffff], a ; IE + ld [rIE], a ; request ints ld a, b - ld [$ff0f], a ; IF + ld [rIF], a ret ; 3df @@ -414,7 +414,7 @@ VBlank4: ; 3df call $ff80 ; 403f: ; ld a, $c4 -; ld [$ff46], a ; oam dma +; ld [rDMA], a ; ld a, $28 ; .loop ; dec a @@ -456,7 +456,7 @@ VBlank5: ; 400 ; scroll x ld a, [$ffcf] - ld [$ff43], a ; scx + ld [rSCX], a ; if we can update pals, skip this part call UpdatePalsIfCGB @@ -475,12 +475,12 @@ VBlank5: ; 400 ; discard requested ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; enable lcd stat ld a, %10 ; lcd stat - ld [$ffff], a ; IE + ld [rIE], a ; request lcd stat - ld [$ff0f], a ; IF + ld [rIF], a ei ; update sound @@ -494,10 +494,10 @@ VBlank5: ; 400 ; discard requested ints xor a - ld [$ff0f], a ; IF + ld [rIF], a ; enable ints besides joypad ld a, %1111 ; serial timer lcdstat vblank - ld [$ffff], a ; IE + ld [rIE], a ret ; 436