More HOME

This commit is contained in:
pikalaxalt
2016-06-16 17:50:02 -04:00
parent dba4875d29
commit fd4792ae5b
11 changed files with 298 additions and 1242 deletions

View File

@@ -1,6 +1,6 @@
; rst vectors
INCLUDE "constants.asm"
; rst vectors
INCLUDE "rst.asm"
INCLUDE "interrupts.asm"
@@ -19,22 +19,11 @@ INCLUDE "home/time.asm"
INCLUDE "home/init.asm"
INCLUDE "home/serial.asm"
INCLUDE "home/joypad.asm"
INCLUDE "home/decompress.asm"
INCLUDE "home/palettes.asm"
Functionaf0:: ; af0
dr $af0, $bdf
UpdatePalsIfCGB::
ld a, [hCGB]
and a
ret z
UpdateCGBPals::
dr $be3, $c61
Functionc61::
dr $c61, $c83
Functionc83::
dr $c83, $1458
Functiond70::
dr $d70, $1458
UpdateBGMapBuffer::
dr $1458, $14bb
@@ -76,16 +65,36 @@ CloseSRAM::
dr $30f1, $30ff
Function30ff::
dr $30ff, $314c
dr $30ff, $311a
CopyBytes::
dr $311a, $314c
ByteFill::
dr $314c, $3158
BackUpTilesToBuffer::
dr $3158, $3164
hlcoord 0, 0
decoord 0, 0, wTileMapBackup
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
jp CopyBytes
ReloadTilesFromBuffer::
dr $3164, $344c
xor a
ld [hBGMapMode], a
call ReloadTilesFromBuffer_
ld a, $1
ld [hBGMapMode], a
ret
ReloadTilesFromBuffer_::
hlcoord 0, 0, wTileMapBackup
decoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
jp CopyBytes
Function317b::
dr $317b, $344c
Function344c::
dr $344c, $3564
@@ -93,8 +102,4 @@ Function344c::
Function3564::
dr $3564, $3d4f
DisableAudio::
dr $3d4f, $3e24
Function3e24::
dr $3e24, $3fee
INCLUDE "home/audio.asm"

View File

@@ -1,596 +1,5 @@
; Audio interfaces.
DisableAudio::
dr $3d4f, $3e24
MapSetup_Sound_Off:: ; 3b4e
push hl
push de
push bc
push af
ld a, [hROMBank]
push af
ld a, BANK(_MapSetup_Sound_Off)
ld [hROMBank], a
ld [MBC3RomBank], a
call _MapSetup_Sound_Off
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
pop af
pop bc
pop de
pop hl
ret
; 3b6a
UpdateSound:: ; 3b6a
push hl
push de
push bc
push af
ld a, [hROMBank]
push af
ld a, BANK(_UpdateSound)
ld [hROMBank], a
ld [MBC3RomBank], a
call _UpdateSound
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
pop af
pop bc
pop de
pop hl
ret
; 3b86
_LoadMusicByte:: ; 3b86
; CurMusicByte = [a:de]
GLOBAL LoadMusicByte
ld [hROMBank], a
ld [MBC3RomBank], a
ld a, [de]
ld [CurMusicByte], a
ld a, BANK(LoadMusicByte)
ld [hROMBank], a
ld [MBC3RomBank], a
ret
; 3b97
PlayMusic:: ; 3b97
; Play music de.
push hl
push de
push bc
push af
ld a, [hROMBank]
push af
ld a, BANK(_PlayMusic) ; and BANK(_MapSetup_Sound_Off)
ld [hROMBank], a
ld [MBC3RomBank], a
ld a, e
and a
jr z, .nomusic
call _PlayMusic
jr .end
.nomusic
call _MapSetup_Sound_Off
.end
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
pop af
pop bc
pop de
pop hl
ret
; 3bbc
PlayMusic2:: ; 3bbc
; Stop playing music, then play music de.
push hl
push de
push bc
push af
ld a, [hROMBank]
push af
ld a, BANK(_PlayMusic)
ld [hROMBank], a
ld [MBC3RomBank], a
push de
ld de, MUSIC_NONE
call _PlayMusic
call DelayFrame
pop de
call _PlayMusic
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
pop af
pop bc
pop de
pop hl
ret
; 3be3
PlayCryHeader:: ; 3be3
; Play cry header de.
push hl
push de
push bc
push af
ld a, [hROMBank]
push af
; Cry headers are stuck in one bank.
ld a, BANK(CryHeaders)
ld [hROMBank], a
ld [MBC3RomBank], a
ld hl, CryHeaders
rept 6
add hl, de
endr
ld e, [hl]
inc hl
ld d, [hl]
inc hl
ld a, [hli]
ld [CryPitch], a
ld a, [hli]
ld [CryPitch + 1], a
ld a, [hli]
ld [CryLength], a
ld a, [hl]
ld [CryLength + 1], a
ld a, BANK(_PlayCryHeader)
ld [hROMBank], a
ld [MBC3RomBank], a
call _PlayCryHeader
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
pop af
pop bc
pop de
pop hl
ret
; 3c23
PlaySFX:: ; 3c23
; Play sound effect de.
; Sound effects are ordered by priority (lowest to highest)
push hl
push de
push bc
push af
; Is something already playing?
call CheckSFX
jr nc, .play
; Does it have priority?
ld a, [CurSFX]
cp e
jr c, .done
.play
ld a, [hROMBank]
push af
ld a, BANK(_PlaySFX)
ld [hROMBank], a
ld [MBC3RomBank], a
ld a, e
ld [CurSFX], a
call _PlaySFX
pop af
ld [hROMBank], a
ld [MBC3RomBank], a
.done
pop af
pop bc
pop de
pop hl
ret
; 3c4e
WaitPlaySFX:: ; 3c4e
call WaitSFX
call PlaySFX
ret
; 3c55
WaitSFX:: ; 3c55
; infinite loop until sfx is done playing
push hl
.wait
ld hl, Channel5Flags
bit 0, [hl]
jr nz, .wait
ld hl, Channel6Flags
bit 0, [hl]
jr nz, .wait
ld hl, Channel7Flags
bit 0, [hl]
jr nz, .wait
ld hl, Channel8Flags
bit 0, [hl]
jr nz, .wait
pop hl
ret
; 3c74
IsSFXPlaying:: ; 3c74
; Return carry if no sound effect is playing.
; The inverse of CheckSFX.
push hl
ld hl, Channel5Flags
bit 0, [hl]
jr nz, .playing
ld hl, Channel6Flags
bit 0, [hl]
jr nz, .playing
ld hl, Channel7Flags
bit 0, [hl]
jr nz, .playing
ld hl, Channel8Flags
bit 0, [hl]
jr nz, .playing
pop hl
scf
ret
.playing
pop hl
and a
ret
; 3c97
MaxVolume:: ; 3c97
ld a, $77 ; max
ld [Volume], a
ret
; 3c9d
LowVolume:: ; 3c9d
ld a, $33 ; 40%
ld [Volume], a
ret
; 3ca3
VolumeOff:: ; 3ca3
xor a
ld [Volume], a
ret
; 3ca8
Unused_FadeOutMusic:: ; 3ca8
ld a, 4
ld [MusicFade], a
ret
; 3cae
FadeInMusic:: ; 3cae
ld a, 4 | 1 << 7
ld [MusicFade], a
ret
; 3cb4
SkipMusic:: ; 3cb4
; Skip a frames of music.
.loop
and a
ret z
dec a
call UpdateSound
jr .loop
; 3cbc
FadeToMapMusic:: ; 3cbc
push hl
push de
push bc
push af
call GetMapMusic
ld a, [wMapMusic]
cp e
jr z, .done
ld a, 8
ld [MusicFade], a
ld a, e
ld [MusicFadeIDLo], a
ld a, d
ld [MusicFadeIDHi], a
ld a, e
ld [wMapMusic], a
.done
pop af
pop bc
pop de
pop hl
ret
; 3cdf
PlayMapMusic:: ; 3cdf
push hl
push de
push bc
push af
call GetMapMusic
ld a, [wMapMusic]
cp e
jr z, .done
push de
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
pop de
ld a, e
ld [wMapMusic], a
call PlayMusic
.done
pop af
pop bc
pop de
pop hl
ret
; 3d03
EnterMapMusic:: ; 3d03
push hl
push de
push bc
push af
xor a
ld [wDontPlayMapMusicOnReload], a
ld de, MUSIC_BICYCLE
ld a, [PlayerState]
cp PLAYER_BIKE
jr z, .play
call GetMapMusic
.play
push de
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
pop de
ld a, e
ld [wMapMusic], a
call PlayMusic
pop af
pop bc
pop de
pop hl
ret
; 3d2f
TryRestartMapMusic:: ; 3d2f
ld a, [wDontPlayMapMusicOnReload]
and a
jr z, RestartMapMusic
xor a
ld [wMapMusic], a
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
xor a
ld [wDontPlayMapMusicOnReload], a
ret
; 3d47
RestartMapMusic:: ; 3d47
push hl
push de
push bc
push af
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
ld a, [wMapMusic]
ld e, a
ld d, 0
call PlayMusic
pop af
pop bc
pop de
pop hl
ret
; 3d62
SpecialMapMusic:: ; 3d62
ld a, [PlayerState]
cp PLAYER_SURF
jr z, .surf
cp PLAYER_SURF_PIKA
jr z, .surf
ld a, [StatusFlags2]
bit 2, a
jr nz, .contest
.no
and a
ret
.bike
ld de, MUSIC_BICYCLE
scf
ret
.surf
ld de, MUSIC_SURF
scf
ret
.contest
ld a, [MapGroup]
cp GROUP_ROUTE_35_NATIONAL_PARK_GATE
jr nz, .no
ld a, [MapNumber]
cp MAP_ROUTE_35_NATIONAL_PARK_GATE
jr z, .ranking
cp MAP_ROUTE_36_NATIONAL_PARK_GATE
jr nz, .no
.ranking
ld de, MUSIC_BUG_CATCHING_CONTEST_RANKING
scf
ret
; 3d97
GetMapMusic:: ; 3d97
call SpecialMapMusic
ret c
call GetMapHeaderMusic
ret
; 3d9f
Function3d9f:: ; 3d9f
; Places a BCD number at the
; upper center of the screen.
; Unreferenced.
ld a, 4 * 8
ld [Sprites + 38 * 4], a
ld [Sprites + 39 * 4], a
ld a, 10 * 8
ld [Sprites + 38 * 4 + 1], a
ld a, 11 * 8
ld [Sprites + 39 * 4 + 1], a
xor a
ld [Sprites + 38 * 4 + 3], a
ld [Sprites + 39 * 4 + 3], a
ld a, [wc296]
cp 100
jr nc, .max
add 1
daa
ld b, a
swap a
and $f
add "0"
ld [Sprites + 38 * 4 + 2], a
ld a, b
and $f
add "0"
ld [Sprites + 39 * 4 + 2], a
ret
.max
ld a, "9"
ld [Sprites + 38 * 4 + 2], a
ld [Sprites + 39 * 4 + 2], a
ret
; 3dde
CheckSFX:: ; 3dde
; Return carry if any SFX channels are active.
ld a, [Channel5Flags]
bit 0, a
jr nz, .playing
ld a, [Channel6Flags]
bit 0, a
jr nz, .playing
ld a, [Channel7Flags]
bit 0, a
jr nz, .playing
ld a, [Channel8Flags]
bit 0, a
jr nz, .playing
and a
ret
.playing
scf
ret
; 3dfe
TerminateExpBarSound:: ; 3dfe
xor a
ld [Channel5Flags], a
ld [SoundInput], a
ld [rNR10], a
ld [rNR11], a
ld [rNR12], a
ld [rNR13], a
ld [rNR14], a
ret
; 3e10
ChannelsOff:: ; 3e10
; Quickly turn off music channels
xor a
ld [Channel1Flags], a
ld [Channel2Flags], a
ld [Channel3Flags], a
ld [Channel4Flags], a
ld [SoundInput], a
ret
; 3e21
SFXChannelsOff:: ; 3e21
; Quickly turn off sound effect channels
xor a
ld [Channel5Flags], a
ld [Channel6Flags], a
ld [Channel7Flags], a
ld [Channel8Flags], a
ld [SoundInput], a
ret
; 3e32
PlaySound::
dr $3e24, $3fee

View File

@@ -46,12 +46,12 @@ RotatePalettesRight::
.loop
push de
ld a, [hli]
call Functionc61
call DmgToCgbBGPals
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
call Functionc83
call DmgToCgbObjPals
ld c, 8
call DelayFrames
pop de
@@ -89,9 +89,9 @@ RotatePalettesLeft::
ld d, a
ld a, [hld]
ld e, a
call Functionc83
call DmgToCgbObjPals
ld a, [hld]
call Functionc61
call DmgToCgbBGPals
ld c, 8
call DelayFrames
pop de

View File

@@ -4,11 +4,12 @@ JoypadInt:: ; 8df (0:08df)
ld [hJoyPressed], a
ld [hJoyDown], a
ret
Joypad:: ; 8e6 (0:08e6)
ld a, [wd8ba]
and $d0
ret nz
ld a, [wc1cc]
ld a, [wGameLogicPaused]
and a
ret nz
ld a, $20
@@ -52,14 +53,15 @@ Joypad:: ; 8e6 (0:08e6)
cp $f
jp z, Reset
ret
Function935:: ; 935 (0:0935)
GetJoypad:: ; 935 (0:0935)
push af
push hl
push de
push bc
ld a, [wc1c6]
ld a, [wInputType]
cp $ff
jr z, .asm_958
jr z, .auto
ld a, [hJoypadDown]
ld b, a
ld a, [hJoyDown]
@@ -74,141 +76,163 @@ Function935:: ; 935 (0:0935)
ld c, a
ld a, b
ld [hJoyDown], a
.asm_953
.quit
pop bc
pop de
pop hl
pop af
ret
.asm_958
.auto
ld a, [hROMBank]
push af
ld a, [wc1c9]
ld a, [wAutoInputBank]
rst Bankswitch
ld hl, wc1c7
ld hl, wAutoInputAddress
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wc1ca]
ld a, [wAutoInputLength]
and a
jr z, .asm_973
jr z, .updateauto
dec a
ld [wc1ca], a
ld [wAutoInputLength], a
pop af
rst Bankswitch
jr .asm_953
.asm_973
jr .quit
.updateauto
ld a, [hli]
cp $ff
jr z, .asm_991
jr z, .stopauto
ld b, a
ld a, [hli]
ld [wc1ca], a
ld [wAutoInputLength], a
cp $ff
jr nz, .asm_987
jr nz, .next
dec hl
dec hl
ld b, $0
jr .asm_996
.asm_987
jr .finishauto
.next
ld a, l
ld [wc1c7], a
ld [wAutoInputAddress], a
ld a, h
ld [wc1c8], a
jr .asm_996
.asm_991
call Function9bb
ld [wAutoInputAddress + 1], a
jr .finishauto
.stopauto
call StopAutoInput
ld b, $0
.asm_996
.finishauto
pop af
rst Bankswitch
ld a, b
ld [hJoyPressed], a
ld [hJoyDown], a
jr .asm_953
ld [wc1c9], a
jr .quit
StartAutoInput::
ld [wAutoInputBank], a
ld a, l
ld [wc1c7], a
ld [wAutoInputAddress], a
ld a, h
ld [wc1c8], a
ld [wAutoInputAddress + 1], a
xor a
ld [wc1ca], a
ld [wAutoInputLength], a
xor a
ld [hJoyPressed], a
ld [hJoyReleased], a
ld [hJoyDown], a
ld a, $ff
ld [wc1c6], a
ld [wInputType], a
ret
Function9bb:: ; 9bb (0:09bb)
StopAutoInput:: ; 9bb (0:09bb)
xor a
ld [wc1c9], a
ld [wc1c7], a
ld [wc1c8], a
ld [wc1ca], a
ld [wc1c6], a
ld [wAutoInputBank], a
ld [wAutoInputAddress], a
ld [wAutoInputAddress + 1], a
ld [wAutoInputLength], a
ld [wInputType], a
ret
.asm_9cc
JoyTitleScreenInput::
.loop
call DelayFrame
push bc
call Functiona08
call JoyTextDelay
pop bc
ld a, [hJoyDown]
cp $46
jr z, .asm_9e5
cp D_UP | SELECT | B_BUTTON
jr z, .keycombo
ld a, [hJoyLast]
and $9
jr nz, .asm_9e5
and START | A_BUTTON
jr nz, .keycombo
dec c
jr nz, .asm_9cc
jr nz, .loop
and a
ret
.asm_9e5
.keycombo
scf
ret
.asm_9e7
JoyWaitAorB::
call DelayFrame
call Function935
call GetJoypad
ld a, [hJoyPressed]
and $3
and A_BUTTON | B_BUTTON
ret nz
call Function343
jr .asm_9e7
call RTC
jr JoyWaitAorB
WaitButton::
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
call Function344c
call .asm_9e7
call JoyWaitAorB
pop af
ld [hOAMUpdate], a
ret
Functiona08:: ; a08 (0:0a08)
call Function935
JoyTextDelay:: ; a08 (0:0a08)
call GetJoypad
ld a, [hInMenu]
and a
ld a, [hJoyPressed]
jr z, .asm_a14
jr z, .ok
ld a, [hJoyDown]
.asm_a14
.ok
ld [hJoyLast], a
ld a, [hJoyPressed]
and a
jr z, .asm_a21
ld a, $f
jr z, .checkframedelay
ld a, 15
ld [wTextDelayFrames], a
ret
.asm_a21
.checkframedelay
ld a, [wTextDelayFrames]
and a
jr z, .asm_a2b
jr z, .restartframedelay
xor a
ld [hJoyLast], a
ret
.asm_a2b
ld a, $5
.restartframedelay
ld a, 5
ld [wTextDelayFrames], a
ret
WaitPressAorB_BlinkCursor::
ld a, [hMapObjectIndexBuffer]
push af
ld a, [hObjectStructIndexBuffer]
@@ -217,66 +241,72 @@ Functiona08:: ; a08 (0:0a08)
ld [hMapObjectIndexBuffer], a
ld a, $6
ld [hObjectStructIndexBuffer], a
.asm_a3e
.loop
push hl
hlcoord 18, 17
call Functionab6
call BlinkCursor
pop hl
call Functiona08
call JoyTextDelay
ld a, [hJoyLast]
and $3
jr z, .asm_a3e
and A_BUTTON | B_BUTTON
jr z, .loop
pop af
ld [hObjectStructIndexBuffer], a
pop af
ld [hMapObjectIndexBuffer], a
ret
.asm_a56
call Functiona08
SimpleWaitPressAorB::
.loop
call JoyTextDelay
ld a, [hJoyLast]
and $3
jr z, .asm_a56
and A_BUTTON | B_BUTTON
jr z, .loop
ret
ButtonSound::
ld a, [wLinkMode]
and a
jr nz, .asm_a72
call Functiona77
jr nz, .link_delay
call JoyWaitInput
push de
ld de, $8
call Function3e24
ld de, SFX_READ_TEXT_2
call PlaySound
pop de
ret
.asm_a72
ld c, $41
.link_delay
ld c, 65
jp DelayFrames
Functiona77:: ; a77 (0:0a77)
JoyWaitInput:: ; a77 (0:0a77)
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
ld a, [wc1c6]
ld a, [wInputType]
or a
jr z, .asm_a8a
ld a, $70
ld hl, $4de9
rst FarCall
.asm_a8a
call Functionaa6
call Functiona08
jr z, .wait_loop
callba _DudeAutoInput_A
.wait_loop
call JoyBlinkCursor
call JoyTextDelay
ld a, [hJoyPressed]
and $3
jr nz, .asm_aa2
call Function343
and A_BUTTON | B_BUTTON
jr nz, .received_input
call RTC
ld a, $1
ld [hBGMapMode], a
call DelayFrame
jr .asm_a8a
.asm_aa2
jr .wait_loop
.received_input
pop af
ld [hOAMUpdate], a
ret
Functionaa6:: ; aa6 (0:0aa6)
JoyBlinkCursor:: ; aa6 (0:0aa6)
ld a, [hVBlankCounter]
and $10
jr z, .cursor_off
@@ -289,7 +319,7 @@ Functionaa6:: ; aa6 (0:0aa6)
Coorda 18, 17
ret
Functionab6:: ; ab6 (0:0ab6)
BlinkCursor:: ; ab6 (0:0ab6)
push bc
ld a, [hl]
ld b, a

View File

@@ -1,365 +1,219 @@
; Functions dealing with palettes.
UpdatePalsIfCGB:: ; c2f
; update bgp data from BGPals
; update obp data from OBPals
; return carry if successful
; check cgb
UpdatePalsIfCGB:: ; bdf (0:0bdf)
ld a, [hCGB]
and a
ret z
UpdateCGBPals:: ; c33
; return carry if successful
; any pals to update?
UpdateCGBPals:: ; be3 (0:0be3)
ld a, [hCGBPalUpdate]
and a
ret z
ForceUpdateCGBPals:: ; c37
ld a, [rSVBK]
push af
ld a, 5 ; BANK(BGPals)
ld [rSVBK], a
ld hl, BGPals ; 5:d080
; copy 8 pals to bgpd
ld a, %10000000 ; auto increment, index 0
ForceUpdateCGBPals::
ld hl, wBGPals
ld a, $80
ld [rBGPI], a
ld c, rBGPD % $100
ld b, 4 ; NUM_PALS / 2
ld c, 8 / 2
.bgp
rept 2 palettes
ld a, [hli]
ld [$ff00+c], a
ld [rBGPD], a
endr
dec b
dec c
jr nz, .bgp
; hl is now 5:d0c0 OBPals
; copy 8 pals to obpd
ld a, %10000000 ; auto increment, index 0
ld a, $80
ld [rOBPI], a
ld c, rOBPD % $100
ld b, 4 ; NUM_PALS / 2
ld c, 8 / 2
.obp
rept 2 palettes
ld a, [hli]
ld [$ff00+c], a
ld [rOBPD], a
endr
dec b
dec c
jr nz, .obp
pop af
ld [rSVBK], a
; clear pal update queue
xor a
ld [hCGBPalUpdate], a
scf
ret
; c9f
DmgToCgbBGPals:: ; c9f
; exists to forego reinserting cgb-converted image data
; input: a -> bgp
DmgToCgbBGPals:: ; c61 (0:0c61)
ld [rBGP], a
push af
; Don't need to be here if DMG
ld a, [hCGB]
and a
jr z, .end
push hl
push de
push bc
ld a, [rSVBK]
push af
ld a, 5 ; gfx
ld [rSVBK], a
; copy & reorder bg pal buffer
ld hl, BGPals ; to
ld de, UnknBGPals ; from
; order
ld hl, wBGPals
ld de, wUnknBGPals
ld a, [rBGP]
ld b, a
; all pals
ld c, 8
ld c, $8
call CopyPals
; request pal update
ld a, 1
ld a, $1
ld [hCGBPalUpdate], a
pop af
ld [rSVBK], a
pop bc
pop de
pop hl
.end
pop af
ret
; ccb
DmgToCgbObjPals:: ; ccb
; exists to forego reinserting cgb-converted image data
; input: d -> obp1
; e -> obp2
DmgToCgbObjPals:: ; c83 (0:0c83)
ld a, e
ld [rOBP0], a
ld a, d
ld [rOBP1], a
ld a, [hCGB]
and a
ret z
push hl
push de
push bc
ld a, [rSVBK]
push af
ld a, 5
ld [rSVBK], a
; copy & reorder obj pal buffer
ld hl, OBPals ; to
ld de, UnknOBPals ; from
; order
ld hl, wOBPals
ld de, wUnknOBPals
ld a, [rOBP0]
ld b, a
; all pals
ld c, 8
ld c, $8
call CopyPals
; request pal update
ld a, 1
ld a, $1
ld [hCGBPalUpdate], a
pop af
ld [rSVBK], a
pop bc
pop de
pop hl
ret
; cf8
DmgToCgbObjPal0:: ; cf8
DmgToCgbObjPal0::
ld [rOBP0], a
push af
; Don't need to be here if not CGB
ld a, [hCGB]
and a
jr z, .dmg
jr z, .end
push hl
push de
push bc
ld a, [rSVBK]
push af
ld a, 5 ; gfx
ld [rSVBK], a
ld hl, OBPals
ld de, UnknOBPals
ld hl, wOBPals
ld de, wUnknOBPals
ld a, [rOBP0]
ld b, a
ld c, 1
ld c, $1
call CopyPals
ld a, 1
ld a, $1
ld [hCGBPalUpdate], a
pop af
ld [rSVBK], a
pop bc
pop de
pop hl
.dmg
.end
pop af
ret
; d24
DmgToCgbObjPal1:: ; d24
DmgToCgbObjPal1::
ld [rOBP1], a
push af
ld a, [hCGB]
and a
jr z, .dmg
jr z, .end
push hl
push de
push bc
ld a, [rSVBK]
push af
ld a, 5 ; gfx
ld [rSVBK], a
ld hl, OBPals + 1 palettes
ld de, UnknOBPals + 1 palettes
ld hl, wOBPals + 1 palettes
ld de, wUnknOBPals + 1 palettes
ld a, [rOBP1]
ld b, a
ld c, 1
ld c, $1
call CopyPals
ld a, 1
ld a, $1
ld [hCGBPalUpdate], a
pop af
ld [rSVBK], a
pop bc
pop de
pop hl
.dmg
.end
pop af
ret
; d50
CopyPals:: ; d50
; copy c palettes in order b from de to hl
CopyPals:: ; cea (0:0cea)
push bc
ld c, 4 ; NUM_PAL_COLORS
ld c, $4
.loop
push de
push hl
; get pal color
ld a, b
and %11 ; color
; 2 bytes per color
and $3
add a
ld l, a
ld h, 0
ld h, $0
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
; dest
pop hl
; write color
ld [hl], e
inc hl
ld [hl], d
inc hl
; next pal color
srl b
srl b
; source
pop de
; done pal?
dec c
jr nz, .loop
; de += 8 (next pal)
ld a, 1 palettes ; NUM_PAL_COLORS * 2 ; bytes per pal
ld a, $8
add e
jr nc, .ok
inc d
.ok
ld e, a
; how many more pals?
pop bc
dec c
jr nz, CopyPals
ret
; d79
ClearVBank1:: ; d79
ClearVBank1::
ld a, [hCGB]
and a
ret z
ld a, 1
ld a, $1
ld [rVBK], a
ld hl, VTiles0
ld bc, VRAM_End - VTiles0
ld hl, $8000
ld bc, $2000
xor a
call ByteFill
ld a, 0
ld a, $0
ld [rVBK], a
ret
; d90
ret_d90:: ; d90
Functiond2a::
ld hl, wTileMap
ld de, wccd9
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
.asm_d33
ld a, [hli]
cp $60
jr c, .asm_d3b
ld a, $7
ld [de], a
.asm_d3b
inc de
dec bc
ld a, b
or c
jr nz, .asm_d33
ret
; d91
Special_ReloadSpritesNoPalettes:: ; d91
Functiond42::
ld a, [hCGB]
and a
ret z
ld a, [rSVBK]
push af
ld a, 5 ; BANK(BGPals)
ld [rSVBK], a
ld hl, BGPals
ld bc, $40 + $10
ld hl, wBGPals
ld bc, $50
xor a
call ByteFill
pop af
ld [rSVBK], a
ld a, 1
ld a, $1
ld [hCGBPalUpdate], a
call DelayFrame
ret
; db1
FarCallSwapTextboxPalettes:: ; db1
ld a, [hROMBank]
push af
ld a, BANK(SwapTextboxPalettes)
rst Bankswitch
call SwapTextboxPalettes
pop af
rst Bankswitch
FarCallSwapTextboxPalettes::
homecall SwapTextboxPalettes
ret
; dbd
FarCallScrollBGMapPalettes:: ; dbd
ld a, [hROMBank]
push af
ld a, BANK(ScrollBGMapPalettes)
rst Bankswitch
call ScrollBGMapPalettes
pop af
rst Bankswitch
FarCallScrollBGMapPalettes::
homecall ScrollBGMapPalettes
ret
; dc9

View File

@@ -1,4 +1,4 @@
Function343:: ; 343
RTC:: ; 343
; update time and time-sensitive palettes
; rtc enabled?

View File

@@ -18,9 +18,9 @@ Serial:: ; 6aa (0:06aa)
ld a, [hLinkPlayerNumber]
cp $2
jr z, .player2
ld a, $0
ld a, 0 << rSC_ON
ld [rSC], a
ld a, $80
ld a, 1 << rSC_ON
ld [rSC], a
jr .player2
@@ -174,7 +174,7 @@ Function73b:: ; 73b (0:073b)
jr nz, .rIE_not_equal_8
ld [wce5d], a
ld a, $50
ld a, 80
ld [wce5d + 1], a
.rIE_not_equal_8
@@ -201,7 +201,7 @@ Function73b:: ; 73b (0:073b)
ld a, [rIE]
and $f
cp $8
ld a, $fe
ld a, SERIAL_NO_DATA_BYTE
ret z
ld a, [hl]
ld [hSerialSend], a
@@ -230,8 +230,8 @@ SerialDisconnected:: ; 7e4 (0:07e4)
ret
Function7ec:: ; 7ec
ld hl, wce56
ld de, wce51
ld hl, wPlayerLinkAction
ld de, wOtherPlayerLinkMode
ld c, $2
ld a, $1
ld [hFFCE], a
@@ -269,7 +269,7 @@ Function822:: ; 822
WaitLinkTransfer:: ; 82e (0:082e)
ld a, $ff
ld [wce52], a
ld [wOtherPlayerLinkAction], a
.loop
call LinkTransfer
call DelayFrame
@@ -290,7 +290,7 @@ WaitLinkTransfer:: ; 82e (0:082e)
pop hl
.check
ld a, [wce52]
ld a, [wOtherPlayerLinkAction]
inc a
jr z, .loop
@@ -308,25 +308,26 @@ WaitLinkTransfer:: ; 82e (0:082e)
dec b
jr nz, .acknowledge
ld a, [wce52]
ld [wce51], a
ld a, [wOtherPlayerLinkAction]
ld [wOtherPlayerLinkMode], a
ret
LinkTransfer:: ; 872 (0:0872)
push bc
ld b, $60
ld b, SERIAL_TIMECAPSULE
ld a, [wLinkMode]
cp $1
jr z, .asm_888
ld b, $60
jr c, .asm_888
cp $2
ld b, $70
jr z, .asm_888
ld b, $80
.asm_888
cp LINK_TIMECAPSULE
jr z, .got_high_nybble
ld b, SERIAL_TIMECAPSULE
jr c, .got_high_nybble
cp LINK_TRADECENTER
ld b, SERIAL_TRADECENTER
jr z, .got_high_nybble
ld b, SERIAL_BATTLE
.got_high_nybble
call LinkTransferReceive
ld a, [wce56]
ld a, [wPlayerLinkAction]
add b
ld [hSerialSend], a
ld a, [hLinkPlayerNumber]
@@ -343,15 +344,15 @@ LinkTransfer:: ; 872 (0:0872)
LinkTransferReceive:: ; 8a4 (0:08a4)
ld a, [hSerialReceive]
ld [wce51], a
ld [wOtherPlayerLinkMode], a
and $f0
cp b
ret nz
xor a
ld [hSerialReceive], a
ld a, [wce51]
ld a, [wOtherPlayerLinkMode]
and $f
ld [wce52], a
ld [wOtherPlayerLinkAction], a
ret
LinkDataReceived:: ; 8b9 (0:08b9)

View File

@@ -27,18 +27,6 @@ ENDC
ENDC
ENDM
callba_hc: macro
ld a, \1
ld hl, \2
rst FarCall
endm
callab_hc: macro
ld hl, \2
ld a, \1
rst FarCall
endm
RGB: MACRO
dw ((\3) << 10) + ((\2) << 5) + (\1)
ENDM

View File

@@ -15,3 +15,13 @@ callab: MACRO ; address, bank
ld a, BANK(\1)
rst FarCall
ENDM
homecall: macro
ld a, [hROMBank]
push af
ld a, BANK(\1)
rst Bankswitch
call \1
pop af
rst Bankswitch
endm

View File

@@ -18,7 +18,10 @@ GameInit::
ENDC
SECTION "bank2", DATA, BANK[$2]
dr $8000, $9cfd
SwapTextboxPalettes::
dr $8000, $804f
ScrollBGMapPalettes::
dr $804f, $9cfd
InitCGBPals:: ; 9cfd
dr $9cfd, $c000
@@ -365,7 +368,9 @@ SECTION "bank6f", DATA, BANK[$6f]
dr $1bc000, $1c0000
SECTION "bank70", DATA, BANK[$70]
dr $1c0000, $1c4000
dr $1c0000, $1c0de9
_DudeAutoInput_A::
dr $1c0de9, $1c4000
SECTION "bank71", DATA, BANK[$71]
dr $1c4000, $1c8000

300
wram.asm
View File

@@ -125,23 +125,21 @@ wDontPlayMapMusicOnReload:: ds 1
wMusicEnd::
SECTION "WRAM", WRAM0
wc1c2:: ds 1 ; c1c2
wc1c3:: ds 1 ; c1c3
wc1c4:: ds 1 ; c1c4
wLZAddress:: dw ; c1c2
wLZBank:: ds 1 ; c1c4
wc1c5:: ds 1 ; c1c5
wc1c6:: ds 1 ; c1c6
wc1c7:: ds 1 ; c1c7
wc1c8:: ds 1 ; c1c8
wc1c9:: ds 1 ; c1c9
wc1ca:: ds 1 ; c1ca
wInputType:: ds 1 ; c1c6
wAutoInputAddress:: dw ; c1c7
wAutoInputBank:: ds 1 ; c1c9
wAutoInputLength:: ds 1 ; c1ca
wc1cb:: ds 1 ; c1cb
wc1cc:: ds 1 ; c1cc
wGameLogicPaused:: ds 1 ; c1cc
wRTCEnabled:: ds 1
wc1ce:: ds 1 ; c1ce
wc1cf:: ds 1 ; c1cf
wc1d0:: ds 1 ; c1d0
wc1d1:: ds 1 ; c1d1
wc1d2:: ds 1 ; c1d2
wMapTimeOfDay:: ds 1 ; c1cf
ds 3
wPrinterConnectionOpen:: ds 1
wc1d4:: ds 1 ; c1d4
wc1d5:: ds 1 ; c1d5
@@ -187,262 +185,12 @@ wc1fc:: ds 1 ; c1fc
wc1fd:: ds 1 ; c1fd
wc1fe:: ds 1 ; c1fe
wc1ff:: ds 1 ; c1ff
wc200:: ds 1 ; c200
wc201:: ds 1 ; c201
wc202:: ds 1 ; c202
wc203:: ds 1 ; c203
wc204:: ds 1 ; c204
wc205:: ds 1 ; c205
wc206:: ds 1 ; c206
wc207:: ds 1 ; c207
wc208:: ds 1 ; c208
wc209:: ds 1 ; c209
wc20a:: ds 1 ; c20a
wc20b:: ds 1 ; c20b
wc20c:: ds 1 ; c20c
wc20d:: ds 1 ; c20d
wc20e:: ds 1 ; c20e
wc20f:: ds 1 ; c20f
wc210:: ds 1 ; c210
wc211:: ds 1 ; c211
wc212:: ds 1 ; c212
wc213:: ds 1 ; c213
wc214:: ds 1 ; c214
wc215:: ds 1 ; c215
wc216:: ds 1 ; c216
wc217:: ds 1 ; c217
wc218:: ds 1 ; c218
wc219:: ds 1 ; c219
wc21a:: ds 1 ; c21a
wc21b:: ds 1 ; c21b
wc21c:: ds 1 ; c21c
wc21d:: ds 1 ; c21d
wc21e:: ds 1 ; c21e
wc21f:: ds 1 ; c21f
wc220:: ds 1 ; c220
wc221:: ds 1 ; c221
wc222:: ds 1 ; c222
wc223:: ds 1 ; c223
wc224:: ds 1 ; c224
wc225:: ds 1 ; c225
wc226:: ds 1 ; c226
wc227:: ds 1 ; c227
wc228:: ds 1 ; c228
wc229:: ds 1 ; c229
wc22a:: ds 1 ; c22a
wc22b:: ds 1 ; c22b
wc22c:: ds 1 ; c22c
wc22d:: ds 1 ; c22d
wc22e:: ds 1 ; c22e
wc22f:: ds 1 ; c22f
wc230:: ds 1 ; c230
wc231:: ds 1 ; c231
wc232:: ds 1 ; c232
wc233:: ds 1 ; c233
wc234:: ds 1 ; c234
wc235:: ds 1 ; c235
wc236:: ds 1 ; c236
wc237:: ds 1 ; c237
wc238:: ds 1 ; c238
wc239:: ds 1 ; c239
wc23a:: ds 1 ; c23a
wc23b:: ds 1 ; c23b
wc23c:: ds 1 ; c23c
wc23d:: ds 1 ; c23d
wc23e:: ds 1 ; c23e
wc23f:: ds 1 ; c23f
wc240:: ds 1 ; c240
wc241:: ds 1 ; c241
wc242:: ds 1 ; c242
wc243:: ds 1 ; c243
wc244:: ds 1 ; c244
wc245:: ds 1 ; c245
wc246:: ds 1 ; c246
wc247:: ds 1 ; c247
wc248:: ds 1 ; c248
wc249:: ds 1 ; c249
wc24a:: ds 1 ; c24a
wc24b:: ds 1 ; c24b
wc24c:: ds 1 ; c24c
wc24d:: ds 1 ; c24d
wc24e:: ds 1 ; c24e
wc24f:: ds 1 ; c24f
wc250:: ds 1 ; c250
wc251:: ds 1 ; c251
wc252:: ds 1 ; c252
wc253:: ds 1 ; c253
wc254:: ds 1 ; c254
wc255:: ds 1 ; c255
wc256:: ds 1 ; c256
wc257:: ds 1 ; c257
wc258:: ds 1 ; c258
wc259:: ds 1 ; c259
wc25a:: ds 1 ; c25a
wc25b:: ds 1 ; c25b
wc25c:: ds 1 ; c25c
wc25d:: ds 1 ; c25d
wc25e:: ds 1 ; c25e
wc25f:: ds 1 ; c25f
wc260:: ds 1 ; c260
wc261:: ds 1 ; c261
wc262:: ds 1 ; c262
wc263:: ds 1 ; c263
wc264:: ds 1 ; c264
wc265:: ds 1 ; c265
wc266:: ds 1 ; c266
wc267:: ds 1 ; c267
wc268:: ds 1 ; c268
wc269:: ds 1 ; c269
wc26a:: ds 1 ; c26a
wc26b:: ds 1 ; c26b
wc26c:: ds 1 ; c26c
wc26d:: ds 1 ; c26d
wc26e:: ds 1 ; c26e
wc26f:: ds 1 ; c26f
wc270:: ds 1 ; c270
wc271:: ds 1 ; c271
wc272:: ds 1 ; c272
wc273:: ds 1 ; c273
wc274:: ds 1 ; c274
wc275:: ds 1 ; c275
wc276:: ds 1 ; c276
wc277:: ds 1 ; c277
wc278:: ds 1 ; c278
wc279:: ds 1 ; c279
wc27a:: ds 1 ; c27a
wc27b:: ds 1 ; c27b
wc27c:: ds 1 ; c27c
wc27d:: ds 1 ; c27d
wc27e:: ds 1 ; c27e
wc27f:: ds 1 ; c27f
wc280:: ds 1 ; c280
wc281:: ds 1 ; c281
wc282:: ds 1 ; c282
wc283:: ds 1 ; c283
wc284:: ds 1 ; c284
wc285:: ds 1 ; c285
wc286:: ds 1 ; c286
wc287:: ds 1 ; c287
wc288:: ds 1 ; c288
wc289:: ds 1 ; c289
wc28a:: ds 1 ; c28a
wc28b:: ds 1 ; c28b
wc28c:: ds 1 ; c28c
wc28d:: ds 1 ; c28d
wc28e:: ds 1 ; c28e
wc28f:: ds 1 ; c28f
wc290:: ds 1 ; c290
wc291:: ds 1 ; c291
wc292:: ds 1 ; c292
wc293:: ds 1 ; c293
wc294:: ds 1 ; c294
wc295:: ds 1 ; c295
wc296:: ds 1 ; c296
wc297:: ds 1 ; c297
wc298:: ds 1 ; c298
wc299:: ds 1 ; c299
wc29a:: ds 1 ; c29a
wc29b:: ds 1 ; c29b
wc29c:: ds 1 ; c29c
wc29d:: ds 1 ; c29d
wc29e:: ds 1 ; c29e
wc29f:: ds 1 ; c29f
wc2a0:: ds 1 ; c2a0
wc2a1:: ds 1 ; c2a1
wc2a2:: ds 1 ; c2a2
wc2a3:: ds 1 ; c2a3
wc2a4:: ds 1 ; c2a4
wc2a5:: ds 1 ; c2a5
wc2a6:: ds 1 ; c2a6
wc2a7:: ds 1 ; c2a7
wc2a8:: ds 1 ; c2a8
wc2a9:: ds 1 ; c2a9
wc2aa:: ds 1 ; c2aa
wc2ab:: ds 1 ; c2ab
wc2ac:: ds 1 ; c2ac
wc2ad:: ds 1 ; c2ad
wc2ae:: ds 1 ; c2ae
wc2af:: ds 1 ; c2af
wc2b0:: ds 1 ; c2b0
wc2b1:: ds 1 ; c2b1
wc2b2:: ds 1 ; c2b2
wc2b3:: ds 1 ; c2b3
wc2b4:: ds 1 ; c2b4
wc2b5:: ds 1 ; c2b5
wc2b6:: ds 1 ; c2b6
wc2b7:: ds 1 ; c2b7
wc2b8:: ds 1 ; c2b8
wc2b9:: ds 1 ; c2b9
wc2ba:: ds 1 ; c2ba
wc2bb:: ds 1 ; c2bb
wc2bc:: ds 1 ; c2bc
wc2bd:: ds 1 ; c2bd
wc2be:: ds 1 ; c2be
wc2bf:: ds 1 ; c2bf
wc2c0:: ds 1 ; c2c0
wc2c1:: ds 1 ; c2c1
wc2c2:: ds 1 ; c2c2
wc2c3:: ds 1 ; c2c3
wc2c4:: ds 1 ; c2c4
wc2c5:: ds 1 ; c2c5
wc2c6:: ds 1 ; c2c6
wc2c7:: ds 1 ; c2c7
wc2c8:: ds 1 ; c2c8
wc2c9:: ds 1 ; c2c9
wc2ca:: ds 1 ; c2ca
wc2cb:: ds 1 ; c2cb
wc2cc:: ds 1 ; c2cc
wc2cd:: ds 1 ; c2cd
wc2ce:: ds 1 ; c2ce
wc2cf:: ds 1 ; c2cf
wc2d0:: ds 1 ; c2d0
wc2d1:: ds 1 ; c2d1
wc2d2:: ds 1 ; c2d2
wc2d3:: ds 1 ; c2d3
wc2d4:: ds 1 ; c2d4
wc2d5:: ds 1 ; c2d5
wc2d6:: ds 1 ; c2d6
wc2d7:: ds 1 ; c2d7
wc2d8:: ds 1 ; c2d8
wc2d9:: ds 1 ; c2d9
wc2da:: ds 1 ; c2da
wc2db:: ds 1 ; c2db
wc2dc:: ds 1 ; c2dc
wc2dd:: ds 1 ; c2dd
wc2de:: ds 1 ; c2de
wc2df:: ds 1 ; c2df
wc2e0:: ds 1 ; c2e0
wc2e1:: ds 1 ; c2e1
wc2e2:: ds 1 ; c2e2
wc2e3:: ds 1 ; c2e3
wc2e4:: ds 1 ; c2e4
wc2e5:: ds 1 ; c2e5
wc2e6:: ds 1 ; c2e6
wc2e7:: ds 1 ; c2e7
wc2e8:: ds 1 ; c2e8
wc2e9:: ds 1 ; c2e9
wc2ea:: ds 1 ; c2ea
wc2eb:: ds 1 ; c2eb
wc2ec:: ds 1 ; c2ec
wc2ed:: ds 1 ; c2ed
wc2ee:: ds 1 ; c2ee
wc2ef:: ds 1 ; c2ef
wc2f0:: ds 1 ; c2f0
wc2f1:: ds 1 ; c2f1
wc2f2:: ds 1 ; c2f2
wc2f3:: ds 1 ; c2f3
wc2f4:: ds 1 ; c2f4
wc2f5:: ds 1 ; c2f5
wc2f6:: ds 1 ; c2f6
wc2f7:: ds 1 ; c2f7
wc2f8:: ds 1 ; c2f8
wc2f9:: ds 1 ; c2f9
wc2fa:: ds 1 ; c2fa
wc2fb:: ds 1 ; c2fb
wc2fc:: ds 1 ; c2fc
wc2fd:: ds 1 ; c2fd
wc2fe:: ds 1 ; c2fe
wc2ff:: ds 1 ; c2ff
SECTION "GBC Palettes", WRAM0
wUnknBGPals:: ds 8 * 8 ; c200
wUnknOBPals:: ds 8 * 8 ; c240
wBGPals:: ds 8 * 8 ; c280
wOBPals:: ds 8 * 8 ; c2c0
SECTION "OAM Buffer", WRAM0
wOAMBuffer:: ; c300
@@ -453,6 +201,8 @@ wTileMap:: ; c3a0
ds SCREEN_HEIGHT * SCREEN_WIDTH
SECTION "Animated Objects", WRAM0
wTileMapBackup:: ; c508
; ds SCREEN_HEIGHT * SCREEN_WIDTH
wAnimatedObjectDynamicVTileOffsets:: ds 10 * 2 ; c508
wAnimatedObjectStructs:: ; c51c
; Field 0: Index
@@ -2675,12 +2425,12 @@ wce4d:: ds 1 ; ce4d
wce4e:: ds 1 ; ce4e
wce4f:: ds 1 ; ce4f
wce50:: ds 1 ; ce50
wce51:: ds 1 ; ce51
wce52:: ds 1 ; ce52
wOtherPlayerLinkMode:: ds 1 ; ce51
wOtherPlayerLinkAction:: ds 1 ; ce52
wce53:: ds 1 ; ce53
wce54:: ds 1 ; ce54
wce55:: ds 1 ; ce55
wce56:: ds 1 ; ce56
wPlayerLinkAction:: ds 1 ; ce56
wce57:: ds 1 ; ce57
wce58:: ds 1 ; ce58
wce59:: ds 1 ; ce59
@@ -3086,7 +2836,11 @@ wd03e:: ds 1 ; d03e
wd03f:: ds 1 ; d03f
wd040:: ds 1 ; d040
wd041:: ds 1 ; d041
wLinkMode:: ds 1
wLinkMode:: ds 1 ; d042
; 0 not in link battle
; 1 link battle
wd043:: ds 1 ; d043
wd044:: ds 1 ; d044
wd045:: ds 1 ; d045