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