Decompiled the rest of bank 05, definitively labelled the map object struct

This commit is contained in:
DrippingYellow 2025-09-04 13:28:26 -05:00
parent e384ea25ec
commit d7eb11cf06
40 changed files with 1016 additions and 320 deletions

View File

@ -43,6 +43,7 @@ DEF CANT_TOSS EQU 1 << CANT_TOSS_F
DEF NUM_POCKETS EQU const_value
DEF MAX_ITEMS EQU 20
DEF MAX_BALLS EQU 10
DEF MAX_KEY_ITEMS EQU 20
DEF MAX_PC_ITEMS EQU 50

View File

@ -32,7 +32,7 @@ DEF OBJECT_JUMPTABLE_INDEX rb ; 1d
DEF OBJECT_1E rb ; 1e
DEF OBJECT_JUMP_HEIGHT rb ; 1f
DEF OBJECT_RANGE rb ; 20
DEF OBJECT_21 rb ; 21
DEF OBJECT_SIGHT_RANGE rb ; 21
rb_skip 6
DEF OBJECT_LENGTH EQU _RS
DEF NUM_OBJECT_STRUCTS EQU 10
@ -151,11 +151,10 @@ DEF MAPOBJECT_MOVEMENT rb ; 4
DEF MAPOBJECT_RADIUS rb ; 5
DEF MAPOBJECT_HOUR rb ; 6
DEF MAPOBJECT_TIMEOFDAY rb ; 7
DEF MAPOBJECT_PALETTE rb ; 8
DEF MAPOBJECT_SIGHT_RANGE rb ; 9
DEF MAPOBJECT_SCRIPT_POINTER rw ; a
DEF MAPOBJECT_EVENT_FLAG rw
rb_skip 2
DEF MAPOBJECT_TYPE rb ; 8, set to anything but 0 to skip trainer checks
rb_skip 2
DEF MAPOBJECT_SIGHT_RANGE rb ; b
rb_skip 4
DEF MAPOBJECT_LENGTH EQU _RS
DEF NUM_OBJECTS EQU 16
DEF PLAYER_OBJECT EQU 0

View File

@ -1,5 +1,15 @@
; serial
; wLinkMode
const_def
const LINK_NULL ; 0
const LINK_TIMECAPSULE ; 1
const LINK_TRADECENTER ; 2
const LINK_COLOSSEUM ; 3
; hSerialReceive high nybbles
DEF SERIAL_TRADECENTER EQU $60
DEF SERIAL_BATTLE EQU $70
; serial
DEF ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01
DEF ESTABLISH_CONNECTION_WITH_EXTERNAL_CLOCK EQU $02
@ -15,3 +25,6 @@ DEF SERIAL_NO_DATA_BYTE EQU $FE
; signals the end of one part of a patch list (there are two parts) for player/enemy party data
DEF SERIAL_PATCH_LIST_PART_TERMINATOR EQU $FF
; timeout duration after exchanging a byte
DEF SERIAL_LINK_BYTE_TIMEOUT EQU $5000

View File

@ -120,6 +120,17 @@ DEF PLAYER_SURF_PIKA EQU 8
const DEBUG_BATTLE_F
const DEBUG_FIELD_F
const CONTINUED_F
const SAVE_FILE_EXISTS_F ; Set but not read anywhere.
const_skip 2
; These two are reset by Function2b39, but otherwise unreferenced.
const UNK_DEBUG_FLAG_6_F
const UNK_DEBUG_FLAG_7_F
; wSaveFileFlags::
const_def
const SAVED_FILE_F
const NEW_FILE_F
const ANOTHER_FILE_EXISTS_F
; wJumptableIndex::
DEF JUMPTABLE_INDEX_MASK EQU %01111111

View File

@ -81,12 +81,12 @@ GiveItemPredef::
add_predef ChangeBGPalColor0_4Frames
add_predef PredefShakeScreenVertically
add_predef PredefShakeScreenHorizontally
add_predef Function145b8
add_predef Function146dc
add_predef Function145de
add_predef SavePokemonData
add_predef TryLoadPokemonData
add_predef Dummy_SaveBox
add_predef ExecuteBGEffects ; 48
add_predef Function1457a
add_predef Function143e0
add_predef SaveOptionsAndGameData
add_predef SaveMenu
add_predef CheckSGB
add_predef LoadSGBLayout
add_predef Pokedex_GetArea

View File

@ -2,7 +2,6 @@ INCLUDE "constants.asm"
SECTION "engine/battle_anims/functions.asm", ROMX
; TODO: Uncomment the asserts once we have all the framesets labelled
DoBattleAnimFrame:
ld hl, BATTLEANIMSTRUCT_FUNCTION
@ -4083,7 +4082,8 @@ BattleAnimFunction_RainSandstorm:
ld hl, BATTLEANIMSTRUCT_JUMPTABLE_INDEX
add hl, bc
ld [hl], a
; Seems to make some kind of assert-worthy assumption... investigate after decompiling the framesets.
assert BATTLE_ANIM_FRAMESET_RAIN_1 + 1 == BATTLE_ANIM_FRAMESET_RAIN_2 \
&& BATTLE_ANIM_FRAMESET_RAIN_2 + 1 == BATTLE_ANIM_FRAMESET_RAIN_3
ld hl, BATTLEANIMSTRUCT_FRAMESET_ID
add hl, bc
inc [hl]

View File

@ -73,7 +73,7 @@ DebugMenuItems:
DebugMenuOptionField::
ld hl, wDebugFlags
set DEBUG_FIELD_F, [hl] ; set debug mode
jp StartNewGame
jp NewGame
DebugMenuOptionFight::
ld hl, wDebugFlags
@ -138,17 +138,17 @@ SetDemoEventFlags:
ld hl, wd41b
set 2, [hl] ; chose a starter
ld a, 1
ld [wd29a], a
ld [wPlayerHouse2FCurScript], a
ld a, 1
ld [wd29b], a
ld [wPlayerHouse1FCurScript], a
ld a, 6
ld [wd29c], a
ld [wSilentHillCurScript], a
ld a, 18
ld [wd29d], a
ld [wSilentHillLabFrontCurScript], a
ld a, 6
ld [wd29e], a
ld [wSilentHillLabBackCurScript], a
ld a, 2
ld [wd2a0], a
ld [wSilentHillHouseCurScript], a
ret
SECTION "engine/menu/debug_menu.asm@Sound Test", ROMX

View File

@ -72,7 +72,7 @@ DebugMapViewer::
.do_jumptable
ld a, [wDebugFlags]
bit 1, a
bit DEBUG_FIELD_F, a
ret z
ldh a, [hDebugMapViewerJumptable]
and a

View File

@ -1,10 +1,10 @@
INCLUDE "constants.asm"
SECTION "engine/dumps/bank03.asm@Functionc9c1", ROMX
SECTION "engine/dumps/bank03.asm@CheckTrainerBattle", ROMX
_Functionc9c1:
_CheckTrainerBattle:
xor a
ld bc, $0020 ; presumably size of wCurrMapInlineTrainers
ld bc, NUM_OBJECTS * 2
ld hl, wCurrMapInlineTrainers
call ByteFill
ld de, wMap2Object
@ -12,10 +12,10 @@ _Functionc9c1:
.loop
push af
push de
ld hl, MAPOBJECT_PALETTE
ld hl, MAPOBJECT_TYPE
add hl, de
ld a, [hl]
cp 0
cp 0 ; 1 or greater == not a trainer
jr nz, .skip
ld hl, MAPOBJECT_OBJECT_STRUCT_ID

200
engine/dumps/bank05.asm Normal file
View File

@ -0,0 +1,200 @@
INCLUDE "constants.asm"
SECTION "engine/dumps/bank05.asm", ROMX
; Early duplicate of PlayerHouse2FRadioText, which is present in the map's bank in the final game.
; Uses the long "ポケモン" and "⋯⋯⋯⋯" instead of their shortcuts, and lacks the final sentence.
_Unreferenced_PokemonNewsScript::
ld hl, .DuplicatePokemonNewsText
call OpenTextbox
ret
.DuplicatePokemonNewsText
text "<PLAYER>は"
line "ラジオのスイッチを おした!"
para "ジェイ オー ピー エム"
line "こちらは"
cont "ポケモン ほうそうきょく です"
para "ポケモンニュースを おおくりします"
para "⋯⋯ ポケモンの せかいてきな"
line "けんきゅうしゃ オーキドはかせが"
cont "カントーから すがたを けしました"
cont "あらたな けんきゅうの ばしょを"
cont "もとめて いどうした との"
cont "みかたも ありますが"
cont "なんらかの じけんに まきこまれた"
cont "かのうせいも あり"
cont "かんけいしゃは とても"
cont "しんぱい しています"
para "⋯⋯⋯⋯いじょう"
line "ポケモンニュースでした"
para "⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯⋯"
done
_PokemonBooksScript::
ld hl, .PokemonBooksText
call OpenTextbox
ret
; "Crammed full of POKéMON books!" flavor text
.PokemonBooksText:
text "ポケモンえほんが そろってる!"
done
_PlayerHouse1FFridgeScript::
ld hl, .PlayerHouse1FFridgeText
call OpenTextbox
ret
; Player's empty fridge flavor text
.PlayerHouse1FFridgeText:
text "なかは<⋯⋯>"
line "ほとんど からっぽだ<⋯⋯>"
done
_SilentHillHouseStoveScript::
ld hl, .SilentHillHouseStoveText
call OpenTextbox
ret
; Player's stove
.SilentHillHouseStoveText:
text "ガスコンロの ひは きえている"
line "あんぜん だいいち!"
done
_SilentHillHouseSinkScript::
ld hl, .SilentHillHouseSinkText
call OpenTextbox
ret
.SilentHillHouseSinkText:
text "ピカピカの ながしだい!"
line "こんやの メニューは なんだろう?"
done
_PokecenterSignScript::
ld hl, .PokecenterSignText
call OpenTextbox
ret
.PokecenterSignText:
text "ポケモンの たいりょく かいふく!"
line "ポケモンセンター"
done
_RivalHouseWindowScript::
ld hl, .RivalHouseWindowText
call OpenTextbox
ret
.RivalHouseWindowText:
text "まどが よごれているぞ?"
done
; Various scenes from the Pokemon anime that play on the player and rival's TVs
_SilentHillHouseTVScript::
ld a, [wTimeOfDay]
and a
jr nz, .not_day
ld hl, .SilentHillHouseTVDayText
jr .done
.not_day
dec a
jr nz, .not_night
ld hl, .SilentHillHouseTVNightText
jr .done
.not_night
ld hl, .SilentHillHouseTVMorningText
.done
call OpenTextbox
ret
; Scene from "Pokémon: I Choose You!"
.SilentHillHouseTVDayText:
text "ピカチュウが オニスズメと"
line "たたかっている<⋯⋯>"
cont "サトシが なみだ ぐんでいる<⋯⋯>"
cont "#アニメだ!"
done
; Scene from "Primeape Goes Bananas"
.SilentHillHouseTVNightText:
text "オコりザルが あばれている<⋯⋯>"
cont "サトシが にげまわってる!<⋯⋯>"
cont "#アニメだ!"
done
; Scene from "Bulbasaur's Mysterious Garden"
.SilentHillHouseTVMorningText:
text "フシギダネが すねている<⋯⋯>"
cont "サトシが こまっている<⋯⋯>"
cont "#アニメだ!"
done
Unreferenced_CheckInlineTrainers:
ld a, [wDebugFlags]
set UNK_DEBUG_FLAG_6_F, a ; Should probably be "bit UNK_DEBUG_FLAG_6_F, a"?
ret nz
xor a
ldh [hSeenTrainerDistance], a
ldh [hSeenTrainerDirection], a
ld a, FOLLOWER + 1
ldh [hSeenTrainerObject], a
ld hl, wCurrMapInlineTrainers + (2 * FOLLOWER_OBJECT_INDEX) ; Skip wReservedObjectStruct and the player's struct
ld de, 2 ; Length of wCurrMapInlineTrainers entries
ld b, NUM_OBJECTS - FOLLOWER_OBJECT_INDEX
.loop
ld a, [hl]
and a
jr nz, .found
add hl, de
ldh a, [hSeenTrainerObject]
inc a
ldh [hSeenTrainerObject], a
dec b
jr nz, .loop
ret
.found
ldh [hSeenTrainerDistance], a
inc hl
ld a, [hl]
ldh [hSeenTrainerDirection], a
ld hl, wDebugFlags
set UNK_DEBUG_FLAG_6_F, [hl]
ret
Unreferenced_TestTrainerWalkToPlayer:
ld hl, wJoypadFlags
set 6, [hl]
ldh a, [hSeenTrainerObject]
call FreezeAllOtherObjects
ldh a, [hSeenTrainerObject]
ld hl, .MovementData
ldh a, [hSeenTrainerDistance]
dec a
ld e, a
ld d, 0
add hl, de
call LoadMovementDataPointer
ld hl, wc5ed
set 7, [hl]
ld a, 1
call WriteIntod637
ret
.MovementData:
big_step LEFT
big_step LEFT
big_step LEFT
step_end
Bank05_FillerStart::

View File

@ -24,7 +24,7 @@ StartBattle:
ld a, [wLinkMode]
and a
jr z, .asm_3c02e
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 2
jr z, .asm_3c03f
.asm_3c02e
@ -92,7 +92,7 @@ StartBattle:
ld a, [wLinkMode]
and a
jr z, .to_battle
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 2
jr nz, .to_battle
call EnemySwitch
@ -178,7 +178,7 @@ EnemyPokemonFledText:
asm_3c183:
call UpdateBattleMonInParty
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 1
jr z, asm_3c1a9
call sub_3c492
@ -394,7 +394,7 @@ asm_3c339:
jp asm_3c3c7
asm_3c347:
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 2
jr z, asm_3c35d
call BattleRandom
@ -424,7 +424,7 @@ asm_3c36d:
jr asm_3c3c7
asm_3c37f:
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 2
jr z, asm_3c38f
call BattleRandom
@ -443,7 +443,7 @@ sub_3c399:
dec a
jr nz, asm_3c3b6
ld a, [wDebugFlags]
bit 0, a
bit DEBUG_BATTLE_F, a
jr nz, asm_3c3b6
ld a, [wEnemySubStatus5]
bit 7, a
@ -748,7 +748,7 @@ SandstormHitsText:
prompt
sub_3c61e:
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 1
jr z, asm_3c632
xor a
@ -1352,7 +1352,7 @@ asm_3ca0a:
jr nz, asm_3ca18
ld b, 0
ld hl, wDebugFlags
set 1, [hl]
set DEBUG_FIELD_F, [hl]
asm_3ca18:
ld a, [wLinkMode]
@ -2649,7 +2649,7 @@ UpdateBattleMonInParty:
jp CopyBytes
sub_3d40b:
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 1
jr z, asm_3d418
call sub_3d41f
@ -2783,7 +2783,7 @@ RecoveredWithItemText:
prompt
sub_3d50b:
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp 1
jr z, asm_3d518
call sub_3d51f
@ -3614,7 +3614,7 @@ MoveSelectionScreen::
.battle_player_moves
ld a, [wDebugFlags]
bit 0, a
bit DEBUG_BATTLE_F, a
jr nz, .interpret_joypad
call MoveInfoBox

View File

@ -151,10 +151,6 @@ _Breeder::
jp PrintText
.CheckBreedmonCompatibility:
; Assumes that wBreedMonGenders has already been set from opening the Breeder menu with 1 or fewer Pokémon.
; If you open the breeder after saving and resetting the game while they have two Pokémon
; (assuming the BreedMons GET saved at this point in development),
; then this check will fail until you change out the BreedMons again.
ld a, [wBreedMonGenders]
ld b, a
srl b

View File

@ -14,7 +14,7 @@ PokemonCenterPC:
; Also used for player's PC (both in debug and in demo mode)
ld a, [wDebugFlags]
bit 1, a
bit DEBUG_FIELD_F, a
jp z, PC_Demo
call PC_PlayBootSound
@ -25,7 +25,7 @@ PokemonCenterPC:
ld hl, .TurnOnText
call MenuTextBoxBackup
ld hl, wDebugFlags
bit 1, [hl]
bit DEBUG_FIELD_F, [hl]
jr nz, .DisplayMenu
ld hl, .NotConnectedText
call MenuTextBoxBackup
@ -258,7 +258,7 @@ PlayerWithdrawItemMenu:
jr c, .done
.Withdraw:
ld hl, wUnknownListLengthd1ea
ld hl, wNumPCItems
ld a, [wItemIndex]
call TossItem
ld hl, wNumBagItems
@ -272,7 +272,7 @@ PlayerWithdrawItemMenu:
.PackFull:
ld hl, .NoRoomWithdrawText
call MenuTextBoxBackup
ld hl, wUnknownListLengthd1ea
ld hl, wNumPCItems
call ReceiveItem
ret
@ -306,7 +306,7 @@ PlayerTossItemMenu:
.loop
call PCItemsJoypad
jr c, .quit
ld de, wUnknownListLengthd1ea
ld de, wNumPCItems
callfar TryTossItem
jr .loop
.quit
@ -422,7 +422,7 @@ PlayerDepositItemMenu:
ld hl, wNumBagItems
ld a, [wItemIndex]
call TossItem
ld hl, wUnknownListLengthd1ea
ld hl, wNumPCItems
call ReceiveItem
jr nc, .NoRoomInPC
predef LoadItemData
@ -502,7 +502,23 @@ PCItemsJoypad:
db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT
db 4, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_QUANTITY ; type
dbw 0, wUnknownListLengthd1ea
dbw 0, wNumPCItems
dba PlaceMenuItemName
dba PlaceMenuItemQuantity
dba UpdateItemDescription
; Leftover menu data for a Gen I-styled deposit menu (with the addition of the item's description)
.UnusedDepositMenuHeader:
db MENU_BACKUP_TILES
menu_coords 4, 1, 19, 10
dw .UnusedDepositMenuData
db 1 ; default selection
.UnusedDepositMenuData:
db SCROLLINGMENU_ENABLE_SELECT | SCROLLINGMENU_ENABLE_FUNCTION3 | SCROLLINGMENU_ENABLE_RIGHT | SCROLLINGMENU_ENABLE_LEFT
db 4, 8 ; rows, columns
db SCROLLINGMENU_ITEMS_QUANTITY ; type
dbw 0, wItems
dba PlaceMenuItemName
dba PlaceMenuItemQuantity
dba UpdateItemDescription

418
engine/menu/empty_sram.asm Normal file
View File

@ -0,0 +1,418 @@
INCLUDE "constants.asm"
SECTION "engine/menu/empty_sram.asm", ROMX
Checksum::
push de
xor a
ld d, a
.loop
ld a, [hli]
add d
ld d, a
dec bc
ld a, b
or c
jr nz, .loop
ld a, d
cpl
pop de
ret
EmptyAllSRAMBanks::
ld a, 0
call .EmptyBank
call InitOptions
ld a, 1
call .EmptyBank
ld a, 2
call .EmptyBank
ld a, 3
call .EmptyBank
call CloseSRAM
ret
.EmptyBank:
call OpenSRAM
ld hl, SRAM_Begin
ld bc, SRAM_End - SRAM_Begin
ld a, $ff
call ByteFill
ret
SaveMenu::
call PrintSaveScreenText
ld hl, WouldYouLikeToSaveTheGameText
call SaveTheGame_yesorno
and a
jr nz, .done
call VerifyChecksum
ld hl, wSaveFileFlags
bit NEW_FILE_F, [hl]
res NEW_FILE_F, [hl]
jr nz, .next
bit ANOTHER_FILE_EXISTS_F, [hl]
res ANOTHER_FILE_EXISTS_F, [hl]
jr nz, .another_save_file
ld hl, AlreadyASaveFileText
call SaveTheGame_yesorno
and a
jr nz, .done
jr .next
.another_save_file:
ld hl, AnotherSaveFileText
call SaveTheGame_yesorno
and a
jr nz, .done
.next
ld hl, wSaveFileFlags
set 0, [hl]
ld hl, wDebugFlags
set SAVE_FILE_EXISTS_F, [hl]
call SaveOptionsAndGameData
call SavePokemonData
call Dummy_SaveBox
ld c, 32
call DelayFrames
ld hl, SavedTheGameText
call MenuTextBox
ld de, SFX_SAVE
call WaitPlaySFX
call WaitSFX
ld c, 30
call DelayFrames
call ExitMenu
.done
call ExitMenu
ret
SaveTheGame_yesorno:
call MenuTextBox
lb bc, 0, 7
call PlaceYesNoBox
ld a, [wMenuCursorY]
dec a
call CloseWindow
ret
WouldYouLikeToSaveTheGameText:
text "ここまでの かつやくを"
line "#レポートに かきこみますか?"
done
SavedTheGameText:
text "<PLAYER>は"
line "レポートに しっかり かきのこした!"
done
AlreadyASaveFileText:
text "まえに かかれた レポートが"
line "きえて しまいますが"
cont "うえから かいても いいですか?"
done
AnotherSaveFileText:
text "まえに かかれた レポート が"
line "こんかいと ちがう もの ですが"
cont "うえから かいても いいですか?"
done
VerifyChecksum::
ld a, BANK(sChecksum)
call OpenSRAM
ld a, [sChecksum + 2]
ldh [hChecksum], a
cp $ff
jr nz, .file_exists
ld hl, wSaveFileFlags
set NEW_FILE_F, [hl]
jr .done
.file_exists
ld a, BANK(sGameData)
call OpenSRAM
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
call Checksum
ld b, a
ldh a, [hChecksum]
cp b
jr z, .done
ld hl, wSaveFileFlags
set ANOTHER_FILE_EXISTS_F, [hl]
.done
call CloseSRAM
ret
PrintSaveScreenText::
xor a
ldh [hBGMapMode], a
ld hl, .MenuHeader
call LoadMenuHeader
call MenuBox
call PlaceVerticalMenuItems
farcall PrintSaveScreenNumbers
call LoadFontExtra
call UpdateSprites
ld a, 1
ldh [hBGMapMode], a
ld c, 20
call DelayFrames
ret
.MenuHeader:
db MENU_BACKUP_TILES
menu_coords 5, 0, 19, 9
dw .MenuData
db 1
.MenuData:
db STATICMENU_PLACE_TITLE
db 4
db "しゅじんこう <PLAYER>@"
db "もっているバッジ    こ@"
db "#ずかん    ひき@"
db "プレイじかん@"
db 6
db "テスト@" ; "TEST"
SaveOptionsAndGameData::
ld a, BANK(sOptions)
call OpenSRAM
ld hl, wOptions
ld de, sOptions
ld bc, wGameDataEnd - wOptions
call CopyBytes
ld hl, wGameData2
ld de, sGameData2
ld bc, wGameData2End - wGameData2
call CopyBytes
ld a, BANK(sChecksum)
call OpenSRAM
ld hl, wGameData
ld bc, wGameDataEnd - wGameData
call Checksum
ld [sChecksum + 2], a
ld hl, wGameData2
ld bc, wGameData2End - wGameData2
call Checksum
ld [sChecksum + 1], a
call CloseSRAM
ret
SavePokemonData::
ld a, BANK(sPokemonData)
call OpenSRAM
ld hl, wPokemonData
ld de, sPokemonData
ld bc, wPokemonDataEnd - wPokemonData
call CopyBytes
ld a, BANK(sChecksum)
call OpenSRAM
ld hl, wPokemonData
ld bc, wPokemonDataEnd - wPokemonData
call Checksum
ld [sChecksum], a
call CloseSRAM
ret
; Dummied out with a ret, but it seemingly works.
Dummy_SaveBox::
ret
ld a, [wCurBox]
ldh [hTempCurBox], a
call .SaveBox
ret
.SaveBox:
ldh a, [hTempCurBox]
dec a
push af
cp NUM_BOXES / 2
ld a, BANK("Boxes 6-10")
jr nc, .next
ld a, BANK("Boxes 1-5")
.next
call OpenSRAM
pop af
add a
ld d, 0
ld e, a
ld hl, .BoxAddresses
add hl, de
ld a, [hli]
ld d, [hl]
ld e, a
ld hl, wBox
ld bc, wBoxEnd - wBox
call CopyBytes
call CloseSRAM
ret
.BoxAddresses:
for n, 1, NUM_BOXES + 1
dw sBox{d:n}
endr
; Note that unlike the release versions of Red & Green or Gold & Silver, there's nothing to stop you from loading
; a corrupted file. The message will be displayed, but otherwise the game continues as normal.
TryLoadSaveFile::
call ClearTileMap
call LoadFont
call LoadFontExtra
call TryLoadSaveData
jr c, .corrupt
call TryLoadPokemonData
jr c, .corrupt
ret
.corrupt
ld hl, wOptions
push hl
set NO_TEXT_SCROLL_F, [hl]
ld hl, .SaveFileCorruptedText
call PrintText
ld c, 100
call DelayFrames
pop hl
res NO_TEXT_SCROLL_F, [hl]
ret
.SaveFileCorruptedText:
text "レポートの ないようが"
line "こわれています!!"
prompt
TryLoadSaveData:
call CheckSaveFileChecksum
jr nz, .corrupt
ld a, BANK(sGameData)
call OpenSRAM
ld hl, sGameData
ld de, wGameData
ld bc, wGameDataEnd - wGameData
call CopyBytes
ld hl, sGameData2
ld de, wGameData2
ld bc, wGameData2End - wGameData2
call CopyBytes
jr .done
.corrupt
scf
.done
call CloseSRAM
ret
CheckSaveFileChecksum:
ld a, BANK(sChecksum)
call OpenSRAM
ld a, [sChecksum + 2]
ldh [hChecksum], a
ld a, [sChecksum + 1]
ldh [hChecksum + 1], a
ld a, [sChecksum + 0]
ldh [hChecksum + 2], a
ld a, BANK(sGameData)
call OpenSRAM
ld hl, sGameData
ld bc, wGameDataEnd - wGameData
call Checksum
ld b, a
ldh a, [hChecksum]
cp b
jr nz, .corrupt
ld hl, sGameData2
ld bc, wGameData2End - wGameData2
call Checksum
ld b, a
ldh a, [hChecksum + 1]
cp b
jr nz, .corrupt
ld a, BANK(sPokemonData)
call OpenSRAM
ld hl, sPokemonData
ld bc, wPokemonDataEnd - wPokemonData
call Checksum
ld b, a
ldh a, [hChecksum + 2]
cp b
.corrupt
push af
call CloseSRAM
pop af
ret
TryLoadPokemonData:
ld a, BANK(sChecksum)
call OpenSRAM
ld a, [sChecksum]
ldh [hChecksum + 2], a
ld a, BANK(sPokemonData)
call OpenSRAM
ld hl, sPokemonData
ld bc, wPokemonDataEnd - wPokemonData
call Checksum
ld b, a
ldh a, [hChecksum + 2]
cp b
jr nz, .corrupt
ld hl, sPokemonData
ld de, wPokemonData
ld bc, wPokemonDataEnd - wPokemonData
call CopyBytes
jr .done
.corrupt
scf
.done
call CloseSRAM
ret
; Unreferenced
ret
MACRO map_buffer_pointers
db GROUP_\1, MAP_\1
dw \2, \3, \4
ENDM
UnknownMapBufferPointers:
map_buffer_pointers PLAYER_HOUSE_2F, wPlayerHouse2FCurScript, PlayerHouse2FScriptPointers, $d39a
;db $01, $09, $9A, $D2, $95, $41, $9A, $D3
db $01, $08, $9B, $D2, $A6, $40, $9B, $D3 ; PLAYER_HOUSE_1F
db $01, $04, $9C, $D2, $7E, $76, $9C, $D3 ; SILENT_HILL
db $01, $0C, $9D, $D2, $C6, $4B, $9D, $D3 ; SILENT_HILL_LAB_FRONT
db $01, $0D, $9E, $D2, $73, $5C, $9E, $D3 ; SILENT_HILL_LAB_BACK
db $01, $0A, $9F, $D2, $8C, $46, $9F, $D3 ; SILENT_HILL_POKECENTER
db $01, $0B, $A0, $D2, $43, $48, $A0, $D3 ; SILENT_HILL_HOUSE
db $01, $01, $A1, $D2, $A2, $7B, $A1, $D3 ; ROUTE1P1
db $01, $02, $A2, $D2, $72, $7C, $A2, $D3 ; ROUTE1P2
db $01, $05, $A3, $D2, $6B, $40, $A3, $D3 ; ROUTE1_GATE_1F
db $01, $06, $A4, $D2, $29, $41, $A4, $D3 ; ROUTE1_GATE_2F
db $01, $0F, $A5, $D2, $55, $56, $A5, $D3 ; SHIZUKANA_OKA
db $02, $11, $A6, $D2, $8F, $47, $A6, $D3 ; OLD_CITY_POKECENTER_2F
db -1
Function14777:
ld a, $00
call WriteIntod637
ret

View File

@ -57,7 +57,7 @@ InitializeNewGameWRAM:
call .InitList
ld hl, wNumKeyItems
call .InitList
ld hl, wUnknownListLengthd1ea
ld hl, wNumPCItems
call .InitList
xor a
@ -76,7 +76,7 @@ endc
ld a, LOW(START_MONEY)
ld [wMoney + 2], a
ld hl, wUnknownListLengthd1ea
ld hl, wNumPCItems
ld a, ITEM_REPEL
ld [wCurItem], a
ld a, 1
@ -121,10 +121,10 @@ LoadOptions:
ret
; Copies the contents of wDebugFlags - wce66 to... themselves.
; Presumably, the debug flags were originally saved to the save file (evidenced by SRAM being opened and closed),
; Presumably, the debug flags were originally read from the save file (evidenced by SRAM being opened and closed),
; but the source address was dummied out.
Dummy_LoadDebugFlags:
ld a, BANK(s0_a600)
ld a, BANK(sOptions)
call OpenSRAM
ld hl, wDebugFlags
ld a, [hli]
@ -181,10 +181,10 @@ MainMenuHeader:
db 1 ; default option
.MenuData:
db $80
db STATICMENU_CURSOR
db 0 ; items
dw MainMenuItems
db $8a, $1f
dw PlaceMenuStrings
dw .Strings
.Strings:
@ -195,10 +195,10 @@ MainMenuHeader:
db "じかんセット@"
MainMenuJumptable:
dw MainMenuOptionContinue
dw StartNewGame
dw Continue
dw NewGame
dw MenuCallSettings
dw StartNewGame
dw NewGame
dw MainMenuOptionSetTime
MainMenuItems:
@ -233,9 +233,9 @@ MainMenuOptionSetTime::
callfar SetTime
ret
MainMenuOptionContinue::
callfar Function14624
call DisplayContinueGameInfo
Continue::
callfar TryLoadSaveFile
call DisplaySaveInfoOnContinue
.loop
call ClearJoypad
call GetJoypad
@ -251,7 +251,7 @@ MainMenuOptionContinue::
ld hl, wDebugFlags
res DEBUG_FIELD_F, [hl]
set CONTINUED_F, [hl]
set 3, [hl]
set SAVE_FILE_EXISTS_F, [hl]
ldh a, [hJoyState]
bit SELECT_F, a
jr z, .skip
@ -259,16 +259,16 @@ MainMenuOptionContinue::
.skip
call ClearBGPalettes
call ClearTileMap
ld c, $0A
ld c, 10
call DelayFrames
jp OverworldStart
DisplayContinueGameInfo::
DisplaySaveInfoOnContinue::
xor a
ldh [hBGMapMode], a
hlcoord 4, 7
ld b, $08
ld c, $0D
ld b, 8
ld c, 13
call DrawTextBox
hlcoord 5, 9
ld de, PlayerInfoText
@ -284,38 +284,38 @@ DisplayContinueGameInfo::
call PrintPlayTime
ld a, $01
ldh [hBGMapMode], a
ld c, $1E
ld c, 30
call DelayFrames
ret
PrintNumBadges::
push hl
ld hl, wJohtoBadges
ld b, $01 ; only Johto Badges
ld b, 1 ; only Johto Badges
call CountSetBits
pop hl
ld de, wNumSetBits
ld bc, $0102 ; flags and constants for this? 1 byte source, 2 digit display
lb bc, 1, 2
jp PrintNumber
PrintNumOwnedMons::
push hl
ld hl, wPokedexCaught
ld b, $20 ; flag_array NUM_POKEMON?
ld b, (NUM_POKEMON + 7) / 8 ; flag_array NUM_POKEMON
call CountSetBits
pop hl
ld de, wNumSetBits
ld bc, $0103 ; 1 byte, 3 digit
lb bc, 1, 3
jp PrintNumber
PrintPlayTime::
ld de, hRTCHours
ld bc, $0103 ; 1 byte, 3 digit
lb bc, 1, 3
call PrintNumber
ld [hl], ""
inc hl
ld de, hRTCMinutes
ld bc, $8102 ; PRINTNUM_LEADINGZEROS, 1 byte, 2 digit
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
jp PrintNumber
PlayerInfoText:
@ -325,7 +325,7 @@ PlayerInfoText:
next "プレイじかん"
text_end
StartNewGame::
NewGame::
ld de, MUSIC_NONE
call PlayMusic
ld de, MUSIC_OAK_INTRO

View File

@ -189,7 +189,7 @@ StartMenu_Reset:
ret
StartMenu_Save:
predef Function143e0
predef SaveMenu
call UpdateSprites
ld a, 0
ret

View File

@ -540,7 +540,7 @@ SRAMClearMenu::
cp $01
jp z, Init
callfar InitAllSRAMBanks
callfar EmptyAllSRAMBanks
jp Init
SRAMClear_Message::

View File

@ -280,10 +280,10 @@ CopyMapObjectToObjectStruct::
ld a, [hl]
call CopyMapObject_Radius
ld hl, MAPOBJECT_SCRIPT_POINTER + 1
ld hl, MAPOBJECT_SIGHT_RANGE
add hl, bc
ld a, [hl]
ld hl, OBJECT_21
ld hl, OBJECT_SIGHT_RANGE
add hl, de
ld [hl], a
and a

View File

@ -172,7 +172,7 @@ HandlePlayerStep::
.Jumptable:
dw RefreshTiles
dw Functionc9c1
dw CheckTrainerBattle
dw BufferScreen
dw .fail
dw .fail
@ -186,8 +186,8 @@ HandlePlayerStep::
.fail
ret
Functionc9c1:
callfar _Functionc9c1
CheckTrainerBattle:
callfar _CheckTrainerBattle
ret
UpdateOverworldMap_Old:

View File

@ -18,7 +18,7 @@ AskName_Old:
call GetPokemonName
; Test for being in debug field mode that doesn't go anywhere... maybe the name screen was skipped in debug mode?
ld a, [wDebugFlags]
bit 1, a
bit DEBUG_FIELD_F, a
pop hl
push hl
ld hl, AskGiveNickname_Old

View File

@ -91,10 +91,10 @@ Init:
ldh [rWX], a
ld a, $ff
ldh [hLinkPlayerNumber], a
ld h, HIGH($9800)
ldh [hSerialConnectionStatus], a
ld h, HIGH(vBGMap0)
call BlankBGMap
ld h, HIGH($9C00)
ld h, HIGH(vBGMap1)
call BlankBGMap
ld a, LCDC_DEFAULT
ldh [rLCDC], a
@ -104,7 +104,7 @@ Init:
predef CheckSGB
ld a, $1F
ldh [rIE], a
ld a, HIGH($9C00)
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
xor a
ldh [hBGMapAddress], a

View File

@ -26,7 +26,6 @@ RunMapScript::
pop hl
ret
; TODO: is this used?
WriteIntod637::
push af
; TODO: figure out what variables are concerned here
@ -955,6 +954,7 @@ InitObjectMasks::
ld bc, NUM_OBJECTS - 2
ld a, $ff
call ByteFill
ld hl, wUnknownMapPointer
ld e, [hl]
inc hl
@ -1635,8 +1635,8 @@ Function2b39::
res 4, [hl]
res 6, [hl]
ld hl, wDebugFlags
res 6, [hl]
res 7, [hl]
res UNK_DEBUG_FLAG_6_F, [hl]
res UNK_DEBUG_FLAG_7_F, [hl]
ld hl, wStateFlags
res SCRIPTED_MOVEMENT_STATE_F, [hl]
ld a, $0
@ -1716,7 +1716,7 @@ Function2ba8::
Function2be5:: ; TODO
ld a, [wDebugFlags]
bit 7, a
bit UNK_DEBUG_FLAG_7_F, a
ret nz
ld a, [wMapGroup]
ld b, a

View File

@ -2,49 +2,59 @@ INCLUDE "constants.asm"
SECTION "home/serial.asm", ROM0
; The serial interrupt.
Serial::
push af
push bc
push de
push hl
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
inc a
jr z, .init_player_number
jr z, .establish_connection
ldh a, [rSB]
ldh [hSerialReceive], a
ldh a, [hSerialSend]
ldh [rSB], a
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
jr z, .done
jr z, .player2
ld a, 1 << rSC_ON
ldh [rSC], a
jr .done
jr .player2
.init_player_number
.establish_connection
ldh a, [rSB]
ldh [hSerialReceive], a
ldh [hLinkPlayerNumber], a
ldh [hSerialConnectionStatus], a
cp USING_INTERNAL_CLOCK
jr z, .master
jr z, ._player2
xor a
ldh [rSB], a
ld a, 3
ldh [rDIV], a
.wait
.delay_loop
ldh a, [rDIV]
bit 7, a
jr nz, .wait
jr nz, .delay_loop ; wait until rDIV has incremented from 3 to $80 or more
ld a, 1 << rSC_ON
ldh [rSC], a
jr .done
.master
jr .player2
._player2
xor a
ldh [rSB], a
.done
.player2
ld a, TRUE
ldh [hSerialReceived], a
ldh [hSerialReceivedNewData], a
ld a, SERIAL_NO_DATA_BYTE
ldh [hSerialSend], a
pop hl
@ -53,8 +63,9 @@ Serial::
pop af
reti
; Send bc bytes from hl, receive bc bytes to de.
Serial_ExchangeBytes::
ld a, $1
ld a, TRUE
ldh [hSerialIgnoringInitialData], a
.loop
ld a, [hl]
@ -63,10 +74,12 @@ Serial_ExchangeBytes::
push bc
ld b, a
inc hl
ld a, $30
ld a, 48
.wait
dec a
jr nz, .wait
ldh a, [hSerialIgnoringInitialData]
and a
ld a, b
@ -75,7 +88,7 @@ Serial_ExchangeBytes::
dec hl
cp SERIAL_PREAMBLE_BYTE
jr nz, .loop
xor a
xor a ; FALSE
ldh [hSerialIgnoringInitialData], a
jr .loop
@ -89,25 +102,25 @@ Serial_ExchangeBytes::
ret
Serial_ExchangeByte::
.loop
.timeout_loop
xor a
ldh [hSerialReceived], a
ldh a, [hLinkPlayerNumber]
ldh [hSerialReceivedNewData], a
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
jr nz, .not_player_2
ld a, (1 << rSC_ON) | 1
ldh [rSC], a
.not_player_2
.loop2
ldh a, [hSerialReceived]
.loop
ldh a, [hSerialReceivedNewData]
and a
jr nz, .reset_ffca
ldh a, [hLinkPlayerNumber]
cp $1
jr nz, .not_player_1_or_wLinkTimeoutFrames_zero
jr nz, .await_new_data
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
jr nz, .not_player_1_or_timed_out
call CheckwLinkTimeoutFramesNonzero
jr z, .not_player_1_or_wLinkTimeoutFrames_zero
call .delay_15_cycles
jr z, .not_player_1_or_timed_out
call .ShortDelay
push hl
ld hl, wLinkTimeoutFrames + 1
inc [hl]
@ -118,50 +131,51 @@ Serial_ExchangeByte::
.no_rollover_up
pop hl
call CheckwLinkTimeoutFramesNonzero
jr nz, .loop2
jr nz, .loop
jp SerialDisconnected
.not_player_1_or_wLinkTimeoutFrames_zero
.not_player_1_or_timed_out
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp 1 << SERIAL
jr nz, .loop2
ld a, [wcb58]
jr nz, .loop
ld a, [wLinkByteTimeout]
dec a
ld [wcb58], a
jr nz, .loop2
ld a, [wcb58 + 1]
ld [wLinkByteTimeout], a
jr nz, .loop
ld a, [wLinkByteTimeout + 1]
dec a
ld [wcb58 + 1], a
jr nz, .loop2
ldh a, [hLinkPlayerNumber]
ld [wLinkByteTimeout + 1], a
jr nz, .loop
ldh a, [hSerialConnectionStatus]
cp USING_EXTERNAL_CLOCK
jr z, .reset_ffca
jr z, .await_new_data
ld a, 255
.delay_255_cycles
.long_delay_loop
dec a
jr nz, .delay_255_cycles
jr nz, .long_delay_loop
.reset_ffca
.await_new_data
xor a
ldh [hSerialReceived], a
ldh [hSerialReceivedNewData], a
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
sub 1 << SERIAL
jr nz, .rIE_not_equal_8
jr nz, .non_serial_interrupts_enabled
; LOW($5000)
ld [wcb58], a
ld a, HIGH($5000)
ld [wcb58 + 1], a
assert LOW(SERIAL_LINK_BYTE_TIMEOUT) == 0
; LOW(SERIAL_LINK_BYTE_TIMEOUT)
ld [wLinkByteTimeout], a
ld a, HIGH(SERIAL_LINK_BYTE_TIMEOUT)
ld [wLinkByteTimeout + 1], a
.rIE_not_equal_8
.non_serial_interrupts_enabled
ldh a, [hSerialReceive]
cp SERIAL_NO_DATA_BYTE
ret nz
call CheckwLinkTimeoutFramesNonzero
jr z, .linkTimeoutFrames_zero
jr z, .timed_out
push hl
ld hl, wLinkTimeoutFrames + 1
ld a, [hl]
@ -176,7 +190,7 @@ Serial_ExchangeByte::
call CheckwLinkTimeoutFramesNonzero
jr z, SerialDisconnected
.linkTimeoutFrames_zero
.timed_out
ldh a, [rIE]
and (1 << SERIAL) | (1 << TIMER) | (1 << LCD_STAT) | (1 << VBLANK)
cp 1 << SERIAL
@ -185,16 +199,16 @@ Serial_ExchangeByte::
ld a, [hl]
ldh [hSerialSend], a
call DelayFrame
jp .loop
jp .timeout_loop
.delay_15_cycles:
.ShortDelay:
ld a, 15
.delay_cycles
dec a
jr nz, .delay_cycles
ret
CheckwLinkTimeoutFramesNonzero:
CheckwLinkTimeoutFramesNonzero::
push hl
ld hl, wLinkTimeoutFrames
ld a, [hli]
@ -202,7 +216,9 @@ CheckwLinkTimeoutFramesNonzero:
pop hl
ret
SerialDisconnected:
; This sets wLinkTimeoutFrames to $ffff, since
; a is always 0 when it is called.
SerialDisconnected::
dec a
ld [wLinkTimeoutFrames], a
ld [wLinkTimeoutFrames + 1], a
@ -211,12 +227,12 @@ SerialDisconnected:
; This is used to exchange the button press and selected menu item on the link menu.
; The data is sent thrice and read twice to increase reliability.
Serial_ExchangeLinkMenuSelection::
ld hl, wPlayerLinkAction
ld de, wOtherPlayerLinkMode
ld hl, wLinkPlayerSyncBuffer
ld de, wLinkReceivedSyncBuffer
ld c, 2
ld a, TRUE
ldh [hSerialIgnoringInitialData], a
.asm_0730
.exchange
call DelayFrame
ld a, [hl]
ldh [hSerialSend], a
@ -227,12 +243,12 @@ Serial_ExchangeLinkMenuSelection::
and a
ld a, FALSE
ldh [hSerialIgnoringInitialData], a
jr nz, .asm_0730
jr nz, .exchange
ld a, b
ld [de], a
inc de
dec c
jr nz, .asm_0730
jr nz, .exchange
ret
Serial_PrintWaitingTextAndSyncAndExchangeNybble::
@ -288,18 +304,18 @@ WaitLinkTransfer::
LinkTransfer::
push bc
ld b, $60
ld b, SERIAL_TRADECENTER
ld a, [wLinkMode]
cp $2
jr c, .asm_07ac
ld b, $70
cp LINK_TRADECENTER
jr c, .got_high_nybble
ld b, SERIAL_BATTLE
.asm_07ac
.got_high_nybble
call .Receive
ld a, [wPlayerLinkAction]
add b
ldh [hSerialSend], a
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
jr nz, .player_1
ld a, (1 << rSC_ON) | 1
@ -327,14 +343,15 @@ LinkDataReceived::
; Let the other system know that the data has been received.
xor a
ldh [hSerialSend], a
ldh a, [hLinkPlayerNumber]
ldh a, [hSerialConnectionStatus]
cp USING_INTERNAL_CLOCK
ret nz
ld a, (1 << rSC_ON) | 1
ldh [rSC], a
ret
Unreferenced_Function7e6::
; Unreferenced in the final game, but used here.
SetBitsForTimeCapsuleRequestIfNotLinked::
ld a, [wLinkMode]
and a
ret nz

View File

@ -37,7 +37,7 @@ CallMapTextSubroutine::
ret
Function3055::
ldh a, [hFFEA]
ldh a, [hLastTalked]
ld b, a
.Loop:
ld a, [hli]
@ -81,7 +81,7 @@ PrintTextboxDebugNumbers::
ld a, [wTalkingTargetType]
bit 0, a
jr z, .CheckSign
ld de, hFFEA
ld de, hLastTalked
jr .PrintNum
.CheckSign:
@ -247,7 +247,7 @@ TurnNPCTalkingTo::
add hl, bc
ld a, [hl]
sub 02
ldh [hFFEA], a
ldh [hLastTalked], a
ret
Function31C3::
@ -261,7 +261,7 @@ CheckInlineTrainer::
call GetObjectStruct
call GetInlineMapObject
jr nc, .Escape
ld hl, MAPOBJECT_SCRIPT_POINTER + 1
ld hl, MAPOBJECT_SIGHT_RANGE
add hl, de
ld a, [hl]
cp b

View File

@ -17,10 +17,12 @@ endr
SECTION "home/unknown.asm@Unknown functions", ROM0
_1FF4::
ld a, BANK(s0_a600)
; Init the options with values of $00 because EmptyAllSRAMBanks sets them to $FF, and that's no good!
; Final game gets around this by filling the entirety of SRAM banks with $00, which this demo probably should've done.
InitOptions::
ld a, BANK(sOptions)
call OpenSRAM
ld hl, s0_a600 ; TODO: label this.
ld hl, sOptions ; TODO: label this.
ld bc, 7
xor a
call ByteFill

View File

@ -6,35 +6,35 @@ Function388f::
ret
Function3890::
farcall Function14cac
farcall _Unreferenced_PokemonNewsScript
ret
Function3899::
farcall Function14dac
PokemonBooksScript::
farcall _PokemonBooksScript
ret
Function38a2::
farcall Function14dc4
PlayerHouse1FFridgeScript::
farcall _PlayerHouse1FFridgeScript
ret
Function38ab::
farcall Function14ddd
SilentHillHouseStoveScript::
farcall _SilentHillHouseStoveScript
ret
Function38b4::
farcall Function14e00
SilentHillHouseSinkScript::
farcall _SilentHillHouseSinkScript
ret
Function38bd::
farcall Function14e5f
SilentHillHouseTVScript::
farcall _SilentHillHouseTVScript
ret
Function38c6::
farcall Function14e27
PokecenterSignScript::
farcall _PokecenterSignScript
ret
Function38cf::
farcall Function14e4a
RivalHouseWindowScript::
farcall _RivalHouseWindowScript
ret
Function38d8::

View File

@ -146,7 +146,7 @@ ROMX $03
"engine/overworld/spawn_points.asm"
"data/maps/spawn_points.asm"
"data/tileset_headers.asm"
"engine/dumps/bank03.asm@Functionc9c1"
"engine/dumps/bank03.asm@CheckTrainerBattle"
"engine/items/inventory.asm@Inventory"
"engine/smallflag.asm"
"engine/pokemon/health.asm@HealParty"
@ -188,8 +188,9 @@ ROMX $05
"engine/sprites/sprites.asm@RefreshSprites"
"data/maps/sprite_sets.asm"
"data/overworld_sprites.asm"
org $477d
"engine/menu/empty_sram.asm"
"engine/events/pokecenter_pc.asm"
"engine/dumps/bank05.asm"
ROMX $06
org $4000
@ -1010,7 +1011,12 @@ SRAM 0
org $b800
"SRAM Window Stack"
SRAM 1
"Save Pokemon Data"
SRAM $02
"Boxes 1-5"
SRAM $03
"Boxes 6-10"
org $bffd
"Checksum"

View File

@ -136,8 +136,6 @@ ENDM
MACRO channel_struct
; TODO: CH1 isn't at C101, please rebase all of these
; Addreses are Channel1 (c101).
\1MusicID:: dw
\1MusicBank:: db
\1Flags1:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest
@ -160,7 +158,7 @@ MACRO channel_struct
\1LoopCount:: db
\1Tempo:: dw
\1Tracks:: db ; hi:left lo:right
\1SFXDutyLoop:: ds 1
\1SFXDutyLoop:: ds 1
\1VibratoDelayCount:: db ; initialized by \1VibratoDelay
\1VibratoDelay:: db ; number of frames a note plays until vibrato starts
\1VibratoExtent:: db
@ -313,11 +311,10 @@ MACRO map_object
\1ObjectRadius:: db
\1ObjectHour:: db
\1ObjectTimeOfDay:: db
\1ObjectPalette:: db ; ...Questionable. Needs investigation
\1ObjectSightRange:: db
\1ObjectScript:: dw
\1ObjectEventFlag:: dw
\1ObjectType:: db
ds 2
\1ObjectSightRange:: db
ds 4
ENDM
MACRO minor_object

View File

@ -3,7 +3,7 @@ SECTION "HRAM", HRAM
hOAMDMA::
ds 10
ds 3 ; TODO
hChecksum:: ds 3
hRTCHours:: db
hRTCMinutes:: db
@ -62,9 +62,9 @@ hJoypadState2:: db
UNION
hFFA7:: db
hFFA8:: db
hFFA9:: db
hSeenTrainerDistance:: db
hSeenTrainerDirection:: db
hSeenTrainerObject:: db
NEXTU
@ -113,6 +113,10 @@ NEXTU
hPokedexTempWeight:: dw
NEXTU
hTempCurBox:: db
ENDU
UNION
@ -188,20 +192,11 @@ hLYOverrideEnd:: db
ds 1 ; TODO
hSerialReceived::
db
hLinkPlayerNumber::
db
hSerialIgnoringInitialData::
db
hSerialSend::
db
hSerialReceive::
db
hSerialReceivedNewData:: db
hSerialConnectionStatus:: db
hSerialIgnoringInitialData:: db
hSerialSend:: db
hSerialReceive:: db
hSCX:: db
@ -267,7 +262,7 @@ hMapAnims::
hTileAnimFrame::
db
hFFEA::
hLastTalked::
db
hFFEB:: db

View File

@ -12,12 +12,19 @@ ENDU
SECTION "Unknown, bank 0", SRAM
UNION
sOptions:: ds 4
NEXTU
s0_a600:: ds 7 ; TODO: properly label this and figure out exact size
ENDU
sOptions:: ds 7
ds 1
; TODO: Replace the big ds blocks with proper RAM ranges when rgbds stops throwing errors.
sGameData:: ds $7d2 ; wGameDataEnd - wGameData
sGameDataEnd::
sGameData2:: ds $71 ; wGameData2End - wGameData2
sGameData2End::
SECTION "Save Pokemon Data", SRAM
sPokemonData:: ds $3d9 ; wPokemonDataEnd - wPokemonData
SECTION "SRAM Window Stack", SRAM
@ -49,3 +56,6 @@ SECTION "Boxes 6-10", SRAM
; All 10 boxes fit exactly within 2 SRAM banks
assert box_n == NUM_BOXES, \
"boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
SECTION "Checksum", SRAM
sChecksum:: ds 3

View File

@ -458,6 +458,7 @@ wBattleAnimTempXOffset:: db
wBattleAnimTempYOffset:: db
wBattleAnimTempFrameOAMFlags:: db
wBattleAnimTempPalette:: db
wBattleAnimEnd::
NEXTU
wBattleAnimGFXTempTileID::
@ -466,8 +467,8 @@ wBattlePicResizeTempPointer:: dw
ENDU
ds $32
wBattleAnimEnd::
ds 50
wActualBattleAnimEnd::
ds $1a3 ; TODO
@ -479,8 +480,11 @@ wEnemyMonNickname:: ds 6
wBattleMonNickname:: ds 6
UNION
; battle mon
wBattleMon:: battle_struct wBattleMon
NEXTU
; intro water/grass/fire cutscene data
ds 14
wIntroJumptableIndex:: db
wIntroBGMapPointer:: ds 2
@ -490,6 +494,7 @@ wIntroFrameCounter1:: ds 1
wIntroFrameCounter2:: ds 1
wIntroSpriteStateFlag:: ds 1
ENDU
wca22:: ds 1
wca23:: ds 1
wca24:: ds 1
@ -718,15 +723,20 @@ wRedrawFlashlightWidthHeight:: db
ENDU
SECTION "CB56", WRAM0[$CB4C]
UNION
wOtherPlayerLinkMode:: db
wOtherPlayerLinkAction:: db
ds 3 ; TODO
wPlayerLinkAction:: db
ds 4 ; TODO
NEXTU
wLinkReceivedSyncBuffer:: ds 5
wLinkPlayerSyncBuffer:: ds 5
ENDU
wLinkTimeoutFrames:: dw
wcb58:: ds 2
wLinkByteTimeout:: dw
wMonType:: db
wSelectedItem::
@ -1113,9 +1123,11 @@ wBattlePlayerAction:: db
wStateFlags:: db
ds 3 ; TODO
ds 3
wcd5d:: db
db
ds 1
wChosenStarter:: db
wcd60:: db
@ -1402,9 +1414,11 @@ wOptions::
; bit 7: battle scene off/on
db
; A buffer for sOptions that is used to check if a save file exists.
; Only checks the bottom bit, for whatever reason.
wSaveFileExists:: db
; Used as a buffer for sOptions to check if a save file exists.
; Only checks the bottom bit (since all valid text speeds have that bit set).
wSaveFileExists::
wSaveFileFlags:: db
wActiveFrame:: db
@ -1421,19 +1435,14 @@ wce64:: ds 1
wce65:: ds 1
wce66:: ds 1
wGameData::
wPlayerName:: ds 6
wMomsName:: ds 6
SECTION "CE73", WRAM0[$CE73]
UNION
wPlayerID:: dw
NEXTU
wce73: ds 1
wce74: ds 1
ENDU
wce75: ds 1
ds 1
wObjectFollow_Leader::
db
@ -1502,21 +1511,12 @@ wTimeOfDayPalset:: db
wCurTimeOfDay:: db
SECTION "D15B", WRAM0[$D15B]
wCoins:: db
wd15c:: db
ds 1
wCoins:: dw
wMoney:: ds 3
;wd15d:: db
;wd15e:: db
;wd15f:: db
SECTION "D163", WRAM0[$D163]
ds 3
wBadges::
wJohtoBadges::
@ -1528,23 +1528,19 @@ wTMsHMs:: ds NUM_TM_HM
wItems::
wNumBagItems:: db
SECTION "D1C8", WRAM0[$D1C8]
wBagItems:: ds MAX_ITEMS * 2 + 1
wNumKeyItems:: db
wKeyItems:: db
SECTION "D1DE", WRAM0[$D1DE]
wKeyItems:: ds MAX_KEY_ITEMS + 1
wNumBallItems:: db
wBallQuantities:: db
wBallQuantities:: ds MAX_BALLS + 1
ds 10
wNumPCItems:: db
wPCItems:: ds MAX_PC_ITEMS * 2 + 1
wUnknownListLengthd1ea:: db
wUnknownListd1eb:: db
ds 6
SECTION "Rival's Name", WRAM0[$D256]
wRegisteredItem:: db
wRegisteredItemQuantity:: db
wRivalName:: ds 6
@ -1561,18 +1557,26 @@ wd266:: db
;The starting house's map script number is stored at d29a. Others are probably nearby.
SECTION "D29A", WRAM0[$D29A]
wd29a:: db
wd29b:: db
wd29c:: db
wd29d:: db
wd29e:: db
db
wd2a0:: db
wPlayerHouse2FCurScript:: db
wPlayerHouse1FCurScript:: db
wSilentHillCurScript:: db
wSilentHillLabFrontCurScript:: db
wSilentHillLabBackCurScript:: db
wSilentHillPokecenterCurScript:: db
wSilentHillHouseCurScript:: db
wRoute1P1CurScript:: db
wRoute1P2CurScript:: db
wRoute1Gate1FCurScript:: db
wRoute1Gate2FCurScript:: db
wShizukanaOkaCurScript:: db
wd2a6:: db
SECTION "D35F", WRAM0[$D35F]
wd35f:: db
SECTION "D39D", WRAM0[$D39D]
SECTION "D39D", WRAM0[$D39A]
wd39a:: db
wd39b:: db
wd39c:: db
wd39d:: db
SECTION "D3A5", WRAM0[$D3A5]
@ -1653,15 +1657,22 @@ wCurrMapObjectCount::
db
wCurrMapInlineTrainers::
REPT 32 ; TODO: confirm this
REPT NUM_OBJECTS
ds 2 ; inline trainers. each pair of bytes is direction, distance
ENDR
ds 32
SECTION "D637", WRAM0[$D637]
wd637:: db ;OW battle state? $3 wild battle, $8 is trainer battle $4 is left battle, $B is load overworld? $0 is in overworld
wd638:: db ;wd637's last written-to value
SECTION "Used sprites", WRAM0[$D642]
wGameDataEnd::
; Sort of redundant to separate data like this when they're right next to each other.
wGameData2::
wd639:: db ; ???
ds 8
wUnusedAddOutdoorSpritesReturnValue:: db
wBGMapAnchor::
dw
@ -1743,6 +1754,8 @@ wTilesetAnim::
ds 2 ; TODO
wTilesetEnd::
wGameData2End::
wPokemonData::
wPartyCount:: db
wPartySpecies:: ds PARTY_LENGTH
@ -1838,6 +1851,8 @@ endr
wOTPartyDataEnd::
ENDU
wPokemonDataEnd::
wBox:: box wBox
SECTION "Stack Bottom", WRAM0

View File

@ -3,7 +3,7 @@ INCLUDE "constants.asm"
SECTION "scripts/OldCityPokecenter2F.asm", ROMX
OldCityPokecenter2F_ScriptLoader:
call Unreferenced_Function7e6
call SetBitsForTimeCapsuleRequestIfNotLinked
ld hl, OldCityPokecenter2FScriptPointers
call RunMapScript
call WriteBackMapScriptNumber

View File

@ -3,7 +3,7 @@ INCLUDE "constants.asm"
SECTION "scripts/OldCityPokecenterTimeMachine.asm", ROMX
OldCityPokecenterTimeMachine_ScriptLoader:
call Unreferenced_Function7e6
call SetBitsForTimeCapsuleRequestIfNotLinked
ld hl, OldCityPokecenterTimeMachineScriptPointers
call RunMapScript
call WriteBackMapScriptNumber

View File

@ -34,11 +34,11 @@ PlayerHouse1FScript2:
ret
PlayerHouse1FSignPointers:
dw Function38ab
dw Function38b4
dw Function38a2
dw Function38bd
dw Function3899
dw SilentHillHouseStoveScript
dw SilentHillHouseSinkScript
dw PlayerHouse1FFridgeScript
dw SilentHillHouseTVScript
dw PokemonBooksScript
PlayerHouse1F_TextPointers::
dw PlayerHouse1FNPCText1

View File

@ -28,10 +28,10 @@ PlayerHouse2FNPCIDs2:
db $FF
PlayerHouse2FSignPointers:
dw Function3899
dw PokemonBooksScript
dw PlayerHouse2FRadioText
dw PlayerHouse2FComputerText
dw Function3899
dw PokemonBooksScript
dw PlayerHouse2FN64Text
PlayerHouse2FScript1:

View File

@ -168,7 +168,7 @@ Function776a:
ld hl, wd41a
set 7, [hl]
ld a, 1
ld hl, wd29d
ld hl, wSilentHillLabFrontCurScript
ld [hl], a
ret
@ -275,7 +275,7 @@ SilentHillScript6:
bit 2, [hl]
ret z
ld a, $12
ld [wd29d], a
ld [wSilentHillLabFrontCurScript], a
ld a, 6
ld [wMapScriptNumber], a
ret
@ -333,7 +333,7 @@ SilentHillMovement7:
SilentHillSignPointers::
dw SilentHillPlayerHouseText
dw Function38c6
dw PokecenterSignScript
dw SilentHillSignText1
dw SilentHillLabText
dw SilentHillRivalHouseText

View File

@ -45,11 +45,11 @@ SilentHillHouseNPCIDs2:
SilentHillHouseTextPointers2::
dw SilentHillHouseNPCText1
dw Function38bd
dw Function3899
dw Function38b4
dw Function38ab
dw Function38cf
dw SilentHillHouseTVScript
dw PokemonBooksScript
dw SilentHillHouseSinkScript
dw SilentHillHouseStoveScript
dw RivalHouseWindowScript
SilentHillHouseNPCText1:
ld hl, wd41a

View File

@ -217,11 +217,11 @@ ConfirmPokemonSelection:
ld hl, wd41b
set 2, [hl]
ld a, 1
ld [wd29b], a
ld [wPlayerHouse1FCurScript], a
ld a, 1
ld [wd29a], a
ld [wPlayerHouse2FCurScript], a
ld a, 1
ld [wd2a0], a
ld [wSilentHillHouseCurScript], a
ld hl, SilentHillLabBackTextString8
call PrintText
ld hl, wJoypadFlags
@ -305,7 +305,7 @@ SilentHillLabBackFunc4:
ld hl, wd41b
bit 2, [hl]
jr nz, .bigjump
ldh a, [hFFEA]
ldh a, [hLastTalked]
sub 2
ld [wChosenStarter], a
ld d, 0
@ -359,8 +359,8 @@ SilentHillLabBackTextString15:
done
SilentHillLabBackTextPointers2:
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw MapDefaultText

View File

@ -640,18 +640,18 @@ SilentHillLabFrontScript19:
SilentHillLabFrontTextPointers2:
dw SilentHillLabFrontText1
dw SilentHillLabFrontText2
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw Function3899
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw PokemonBooksScript
dw SilentHillLabFrontText3
SilentHillLabFrontText1:

View File

@ -1,28 +1,28 @@
05:43B6 InitAllSRAMBanks
05:43E0 Function143e0
05:451B PrintSaveScreenText
05:457A Function1457a
05:45B8 Function145b8
05:45DE Function145de
05:4624 Function14624
05:46DC Function146dc
;05:43E0 SaveMenu
;05:44E9 VerifyChecksum
;05:451B PrintSaveScreenText
;05:457A SaveOptionsAndGameData
;05:45B8 SavePokemonData
;05:45DE Dummy_SaveBox
;05:4624 TryLoadSaveFile
;05:46DC TryLoadPokemonData
; Structure:
; byte Map group ($ff = end)
; byte Map ID
; ptr Copied to c5e9, also byte pointed to written at wMapScriptNumber
; ptr Copied to c5eb
; word Unknown (2 bytes)
05:470E UnknownMapBufferPointers
05:4777 Function14777
05:4C94 Data14c94
05:4CAC Function14cac
05:4DAC Function14dac
05:4DC4 Function14dc4
05:4DDD Function14ddd
05:4E00 Function14e00
05:4E5F Function14e5f
05:4E27 Function14e27
05:4E4A Function14e4a
;05:470E UnknownMapBufferPointers
;05:4777 Function14777
;05:4C94 Data14c94
;05:4CAC _Unreferenced_PokemonNewsScript
;05:4DAC _PokemonBooksScript
;05:4DC4 _PlayerHouse1FFridgeScript
;05:4DDD _SilentHillHouseStoveScript
;05:4E00 _SilentHillHouseSinkScript
;05:4E5F _SilentHillHouseTVScript
;05:4E27 _PokecenterSignScript
;05:4E4A _RivalHouseWindowScript
; all these probably print text
0A:4000 Function28000