diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-06-17 22:11:49 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-06-17 22:11:49 -0400 |
commit | e5ee8ec7c019426b0f29c9b463bb142358856d76 (patch) | |
tree | 925be91d5d5e8b7b72ac9decfe0484f61a56cc51 | |
parent | 451f529b0d6311fc0b6c507d8ccb5336e2984889 (diff) |
Harmonize engine/overworld with pokecrystal
-rw-r--r-- | constants/script_constants.asm | 2 | ||||
-rw-r--r-- | engine/overworld/cmd_queue.asm | 256 | ||||
-rw-r--r-- | engine/overworld/events.asm | 258 | ||||
-rw-r--r-- | engine/overworld/load_map_part.asm | 8 | ||||
-rw-r--r-- | engine/overworld/map_objects.asm | 2 | ||||
-rw-r--r-- | engine/overworld/map_setup.asm | 4 | ||||
-rw-r--r-- | engine/overworld/movement.asm | 2 | ||||
-rw-r--r-- | engine/overworld/overworld.asm | 9 | ||||
-rw-r--r-- | engine/overworld/player_object.asm | 6 | ||||
-rw-r--r-- | engine/overworld/scripting.asm | 444 |
10 files changed, 280 insertions, 711 deletions
diff --git a/constants/script_constants.asm b/constants/script_constants.asm index e850d4fe..89e03dcf 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -142,7 +142,7 @@ CMDQUEUE_CAPACITY EQU 4 ; HandleQueuedCommand.Jumptable indexes (see engine/overworld/events.asm) const_def const CMDQUEUE_NULL - const CMDQUEUE_NULL2 + const CMDQUEUE_TYPE1 const CMDQUEUE_STONETABLE const CMDQUEUE_TYPE3 const CMDQUEUE_TYPE4 diff --git a/engine/overworld/cmd_queue.asm b/engine/overworld/cmd_queue.asm new file mode 100644 index 00000000..29919ee7 --- /dev/null +++ b/engine/overworld/cmd_queue.asm @@ -0,0 +1,256 @@ +ClearCmdQueue:: + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY + xor a +.loop + ld [hl], a + add hl, de + dec c + jr nz, .loop + ret + +HandleCmdQueue:: + ld hl, wCmdQueue + xor a +.loop + ldh [hMapObjectIndexBuffer], a + ld a, [hl] + and a + jr z, .skip + push hl + ld b, h + ld c, l + call HandleQueuedCommand + pop hl + +.skip + ld de, CMDQUEUE_ENTRY_SIZE + add hl, de + ldh a, [hMapObjectIndexBuffer] + inc a + cp CMDQUEUE_CAPACITY + jr nz, .loop + ret + +Unreferenced_GetNthCmdQueueEntry: + ld hl, wCmdQueue + ld bc, CMDQUEUE_ENTRY_SIZE + call AddNTimes + ld b, h + ld c, l + ret + +WriteCmdQueue:: + push bc + push de + call .GetNextEmptyEntry + ld d, h + ld e, l + pop hl + pop bc + ret c + ld a, b + ld bc, CMDQUEUE_ENTRY_SIZE - 1 + call FarCopyBytes + xor a + ld [hl], a + ret + +.GetNextEmptyEntry: + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY +.loop + ld a, [hl] + and a + jr z, .done + add hl, de + dec c + jr nz, .loop + scf + ret + +.done + ld a, CMDQUEUE_CAPACITY + sub c + and a + ret + +DelCmdQueue:: + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld c, CMDQUEUE_CAPACITY +.loop + ld a, [hl] + cp b + jr z, .done + add hl, de + dec c + jr nz, .loop + and a + ret + +.done + xor a + ld [hl], a + scf + ret + +_DelCmdQueue: + ld hl, CMDQUEUE_TYPE + add hl, bc + ld [hl], 0 + ret + +HandleQueuedCommand: + ld hl, CMDQUEUE_TYPE + add hl, bc + ld a, [hl] + cp NUM_CMDQUEUE_TYPES + jr c, .okay + xor a + +.okay + ld e, a + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + add hl, de + ld a, [hli] + push af + ld a, [hli] + ld h, [hl] + ld l, a + pop af + rst FarCall + ret + +.Jumptable: + dba CmdQueue_Null + dba CmdQueue_Type1 + dba CmdQueue_StoneTable + dba CmdQueue_Type3 + dba CmdQueue_Type4 + +CmdQueueAnonymousJumptable: + ld hl, CMDQUEUE_05 + add hl, bc + ld a, [hl] + pop hl + rst JumpTable + ret + +CmdQueueAnonJT_Increment: + ld hl, CMDQUEUE_05 + add hl, bc + inc [hl] + ret + +CmdQueueAnonJT_Decrement: + ld hl, CMDQUEUE_05 + add hl, bc + dec [hl] + ret + +CmdQueue_Null: + ret + +CmdQueue_Type1: + call Function2ffe + ret + +CmdQueue_Type4: + call CmdQueueAnonymousJumptable + ; anonymous dw + dw .zero + dw .one + +.zero + ldh a, [hSCY] + ld hl, CMDQUEUE_04 + add hl, bc + ld [hl], a + call CmdQueueAnonJT_Increment +.one + ld hl, CMDQUEUE_ADDR + add hl, bc + ld a, [hl] + dec a + ld [hl], a + jr z, .finish + and 1 + jr z, .add + ld hl, CMDQUEUE_02 + add hl, bc + ldh a, [hSCY] + sub [hl] + ldh [hSCY], a + ret + +.add + ld hl, CMDQUEUE_02 + add hl, bc + ldh a, [hSCY] + add [hl] + ldh [hSCY], a + ret + +.finish + ld hl, CMDQUEUE_04 + add hl, bc + ld a, [hl] + ldh [hSCY], a + call _DelCmdQueue + ret + +CmdQueue_Type3: + ret + +CmdQueue_StoneTable: + ld de, wPlayerStruct + ld a, NUM_OBJECT_STRUCTS +.loop + push af + + ld hl, OBJECT_SPRITE + add hl, de + ld a, [hl] + and a + jr z, .next + + ld hl, OBJECT_MOVEMENTTYPE + add hl, de + ld a, [hl] + cp SPRITEMOVEDATA_STRENGTH_BOULDER + jr nz, .next + + ld hl, OBJECT_NEXT_TILE + add hl, de + ld a, [hl] + call CheckPitTile + jr nz, .next + + ld hl, OBJECT_DIRECTION_WALKING + add hl, de + ld a, [hl] + cp STANDING + jr nz, .next + call HandleStoneQueue + jr c, .fall_down_hole + +.next + ld hl, OBJECT_LENGTH + add hl, de + ld d, h + ld e, l + + pop af + dec a + jr nz, .loop + ret + +.fall_down_hole + pop af + ret diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 794fa074..ea69bc3e 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -272,6 +272,7 @@ PlayerEvents: push af farcall EnableScriptMode pop af + ld [wScriptRunning], a call DoPlayerEvent scf @@ -1325,261 +1326,6 @@ DoBikeStep:: xor a ret -ClearCmdQueue:: - ld hl, wCmdQueue - ld de, CMDQUEUE_ENTRY_SIZE - ld c, CMDQUEUE_CAPACITY - xor a -.loop - ld [hl], a - add hl, de - dec c - jr nz, .loop - ret - -HandleCmdQueue:: - ld hl, wCmdQueue - xor a -.loop - ldh [hMapObjectIndexBuffer], a - ld a, [hl] - and a - jr z, .skip - push hl - ld b, h - ld c, l - call HandleQueuedCommand - pop hl - -.skip - ld de, CMDQUEUE_ENTRY_SIZE - add hl, de - ldh a, [hMapObjectIndexBuffer] - inc a - cp CMDQUEUE_CAPACITY - jr nz, .loop - ret - -Unreferenced_GetNthCmdQueueEntry: - ld hl, wCmdQueue - ld bc, CMDQUEUE_ENTRY_SIZE - call AddNTimes - ld b, h - ld c, l - ret - -WriteCmdQueue:: - push bc - push de - call .GetNextEmptyEntry - ld d, h - ld e, l - pop hl - pop bc - ret c - ld a, b - ld bc, CMDQUEUE_ENTRY_SIZE - 1 - call FarCopyBytes - xor a - ld [hl], a - ret - -.GetNextEmptyEntry: - ld hl, wCmdQueue - ld de, CMDQUEUE_ENTRY_SIZE - ld c, CMDQUEUE_CAPACITY -.loop - ld a, [hl] - and a - jr z, .done - add hl, de - dec c - jr nz, .loop - scf - ret - -.done - ld a, CMDQUEUE_CAPACITY - sub c - and a - ret - -DelCmdQueue:: - ld hl, wCmdQueue - ld de, CMDQUEUE_ENTRY_SIZE - ld c, CMDQUEUE_CAPACITY -.loop - ld a, [hl] - cp b - jr z, .done - add hl, de - dec c - jr nz, .loop - and a - ret - -.done - xor a - ld [hl], a - scf - ret - -_DelCmdQueue: - ld hl, CMDQUEUE_TYPE - add hl, bc - ld [hl], 0 - ret - -HandleQueuedCommand: - ld hl, CMDQUEUE_TYPE - add hl, bc - ld a, [hl] - cp NUM_CMDQUEUE_TYPES - jr c, .okay - xor a - -.okay - ld e, a - ld d, 0 - ld hl, .Jumptable - add hl, de - add hl, de - add hl, de - ld a, [hli] - push af - ld a, [hli] - ld h, [hl] - ld l, a - pop af - rst FarCall - ret - -.Jumptable: - dba CmdQueue_Null - dba CmdQueue_Type2 - dba CmdQueue_StoneTable - dba CmdQueue_Null2 - dba CmdQueue_Type4 - -CmdQueueAnonymousJumptable: - ld hl, CMDQUEUE_05 - add hl, bc - ld a, [hl] - pop hl - rst JumpTable - ret - -CmdQueueAnonJT_Increment: - ld hl, CMDQUEUE_05 - add hl, bc - inc [hl] - ret - -CmdQueueAnonJT_Decrement: - ld hl, CMDQUEUE_05 - add hl, bc - dec [hl] - ret - -CmdQueue_Null: - ret - -CmdQueue_Type2: - call Function2ffe - ret - -CmdQueue_Type4: - call CmdQueueAnonymousJumptable - ; anonymous dw - dw .zero - dw .one - -.zero - ldh a, [hSCY] - ld hl, CMDQUEUE_04 - add hl, bc - ld [hl], a - call CmdQueueAnonJT_Increment -.one - ld hl, CMDQUEUE_ADDR - add hl, bc - ld a, [hl] - dec a - ld [hl], a - jr z, .finish - and 1 - jr z, .add - ld hl, CMDQUEUE_02 - add hl, bc - ldh a, [hSCY] - sub [hl] - ldh [hSCY], a - ret - -.add - ld hl, CMDQUEUE_02 - add hl, bc - ldh a, [hSCY] - add [hl] - ldh [hSCY], a - ret - -.finish - ld hl, CMDQUEUE_04 - add hl, bc - ld a, [hl] - ldh [hSCY], a - call _DelCmdQueue - ret - -CmdQueue_Null2: - ret - -CmdQueue_StoneTable: - ld de, wPlayerStruct - ld a, NUM_OBJECT_STRUCTS -.loop - push af - - ld hl, OBJECT_SPRITE - add hl, de - ld a, [hl] - and a - jr z, .next - - ld hl, OBJECT_MOVEMENTTYPE - add hl, de - ld a, [hl] - cp SPRITEMOVEDATA_STRENGTH_BOULDER - jr nz, .next - - ld hl, OBJECT_NEXT_TILE - add hl, de - ld a, [hl] - call CheckPitTile - jr nz, .next - - ld hl, OBJECT_DIRECTION_WALKING - add hl, de - ld a, [hl] - cp STANDING - jr nz, .next - call HandleStoneQueue - jr c, .fall_down_hole - -.next - ld hl, OBJECT_LENGTH - add hl, de - ld d, h - ld e, l - - pop af - dec a - jr nz, .loop - ret - -.fall_down_hole - pop af - ret +INCLUDE "engine/overworld/cmd_queue.asm" INCLUDE "engine/events/trainer_scripts.asm" diff --git a/engine/overworld/load_map_part.asm b/engine/overworld/load_map_part.asm index 23758f28..2150df1c 100644 --- a/engine/overworld/load_map_part.asm +++ b/engine/overworld/load_map_part.asm @@ -35,7 +35,7 @@ _LoadMapPart:: jr nz, .loop ret -UnusedFunction153ba: +Unreferenced_Function153ba: decoord 2, 2 ld bc, (SURROUNDING_WIDTH + 1) * 2 add hl, bc @@ -66,7 +66,7 @@ UnusedFunction153ba: jr nz, .loop ret -UnusedFunction153dd: +Unreferenced_Function153dd: decoord 4, 4 ld bc, (SURROUNDING_WIDTH + 1) * 4 add hl, bc @@ -97,7 +97,7 @@ UnusedFunction153dd: jr nz, .loop ret -UnusedFunction15400: +Ureferenced_Function15400: decoord 6, 6 ld bc, (SURROUNDING_WIDTH + 1) * 6 add hl, bc @@ -128,7 +128,7 @@ UnusedFunction15400: jr nz, .loop ret -UnusedFunction15423: +Unreferenced_Function15423: decoord 8, 8 ld bc, (SURROUNDING_WIDTH + 1) * 8 add hl, bc diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 5559dde7..a3899f05 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2369,7 +2369,7 @@ HandleNPCStep:: ld [wPlayerStepVectorX], a ld [wPlayerStepVectorY], a ld [wPlayerStepFlags], a - ld a, $ff + ld a, STANDING ld [wPlayerStepDirection], a ret diff --git a/engine/overworld/map_setup.asm b/engine/overworld/map_setup.asm index 206f2358..1b0a6c08 100644 --- a/engine/overworld/map_setup.asm +++ b/engine/overworld/map_setup.asm @@ -111,12 +111,12 @@ EnableTextAcceleration: ld [wDisableTextAcceleration], a ret -UnusedActivateMapAnims: +Unreferenced_ActivateMapAnims: ld a, $1 ldh [hMapAnims], a ret -UnusedSuspendMapAnims: +Unreferenced_SuspendMapAnims: xor a ldh [hMapAnims], a ret diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 1a819acb..3789ff51 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -749,7 +749,9 @@ JumpStep: ld hl, OBJECT_ACTION add hl, bc ld [hl], OBJECT_ACTION_STEP + call SpawnShadow + ld hl, wCenteredObject ldh a, [hMapObjectIndexBuffer] cp [hl] diff --git a/engine/overworld/overworld.asm b/engine/overworld/overworld.asm index 4c5dbcf6..1a5d96db 100644 --- a/engine/overworld/overworld.asm +++ b/engine/overworld/overworld.asm @@ -36,7 +36,7 @@ RefreshSprites:: .Refresh: xor a - ld bc, SPRITE_GFX_LIST_CAPACITY * 2 + ld bc, wUsedSpritesEnd - wUsedSprites ld hl, wUsedSprites call ByteFill call GetPlayerSprite @@ -44,9 +44,9 @@ RefreshSprites:: ret GetPlayerSprite: +; Get Chris's sprite. ld a, [wPlayerState] ld c, a -; Get Chris's sprite. ld hl, ChrisStateSprites .loop ld a, [hli] @@ -265,13 +265,16 @@ GetSprite: ld b, 0 ld a, NUM_SPRITEDATA_FIELDS call AddNTimes + ; load the address into de ld a, [hli] ld e, a ld a, [hli] ld d, a + ; load the length into c ld a, [hli] swap a ld c, a + ; load the sprite bank into both b and h ld b, [hl] pop hl ret @@ -437,10 +440,12 @@ Unreferenced_Function1438a: ld a, c jr GetUsedSprite +Unreferenced_Function1438d: ld a, c ld b, 0 jr GetUsedSprite +Unreferenced_Function14392: ld a, c ld b, SPRITE_GFX_LIST_CAPACITY jr GetUsedSprite diff --git a/engine/overworld/player_object.asm b/engine/overworld/player_object.asm index cd886bc3..07cbf28b 100644 --- a/engine/overworld/player_object.asm +++ b/engine/overworld/player_object.asm @@ -113,15 +113,15 @@ RefreshPlayerCoords: ret nz ret -SpawnPlayer2: +Unreferenced_SpawnObject1: ld a, 1 - ld hl, .PlayerObjectTemplate + ld hl, UnusedObject1Template call CopyPlayerObjectTemplate ld b, 1 call PlayerSpawn_ConvertCoords ret -.PlayerObjectTemplate: +UnusedObject1Template: object_event -4, -4, SPRITE_CHRIS, SPRITEMOVEDATA_12, 15, 15, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, 0, -1 CopyObjectStruct:: diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index e52ceac0..f758a6a3 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -242,9 +242,6 @@ StopScript: ret Script_callasm: -; script command 0xe -; parameters: asm - call GetScriptByte ld b, a call GetScriptByte @@ -256,9 +253,6 @@ Script_callasm: ret Script_special: -; script command 0xf -; parameters: predefined_script - call GetScriptByte ld e, a call GetScriptByte @@ -267,9 +261,6 @@ Script_special: ret Script_memcallasm: -; script command 0x10 -; parameters: asm - call GetScriptByte ld l, a call GetScriptByte @@ -284,9 +275,6 @@ Script_memcallasm: ret Script_jumptextfaceplayer: -; script command 0x51 -; parameters: text_pointer - ld a, [wScriptBank] ld [wScriptTextBank], a call GetScriptByte @@ -298,9 +286,6 @@ Script_jumptextfaceplayer: jp ScriptJump Script_jumptext: -; script command 0x52 -; parameters: text_pointer - ld a, [wScriptBank] ld [wScriptTextBank], a call GetScriptByte @@ -321,9 +306,6 @@ JumpTextScript: end Script_writetext: -; script command 0x4c -; parameters: text_pointer - call GetScriptByte ld l, a call GetScriptByte @@ -334,9 +316,6 @@ Script_writetext: ret Script_farwritetext: -; script command 0x4b -; parameters: text_pointer - call GetScriptByte ld b, a call GetScriptByte @@ -347,9 +326,6 @@ Script_farwritetext: ret Script_repeattext: -; script command 0x4d -; parameters: byte, byte - call GetScriptByte ld l, a call GetScriptByte @@ -372,13 +348,9 @@ Script_repeattext: ret Script_waitbutton: -; script command 0x53 - jp WaitButton Script_promptbutton: -; script command 0x54 - ldh a, [hOAMUpdate] push af ld a, $1 @@ -390,8 +362,6 @@ Script_promptbutton: ret Script_yesorno: -; script command 0x4e - call YesNoBox ld a, FALSE jr c, .no @@ -401,9 +371,6 @@ Script_yesorno: ret Script_loadmenu: -; script command 0x4f -; parameters: menu_header - call GetScriptByte ld l, a call GetScriptByte @@ -415,16 +382,11 @@ Script_loadmenu: ret Script_closewindow: -; script command 0x50 - call CloseWindow call UpdateSprites ret Script_pokepic: -; script command 0x55 -; parameters: pokemon - call GetScriptByte and a jr nz, .ok @@ -435,14 +397,10 @@ Script_pokepic: ret Script_closepokepic: -; script command 0x56 - farcall ClosePokepic ret Script_verticalmenu: -; script command 0x58 - ld a, [wScriptBank] ld hl, VerticalMenu rst FarCall @@ -454,8 +412,6 @@ Script_verticalmenu: ret Script__2dmenu: -; script command 0x57 - ld a, [wScriptBank] ld hl, _2DMenu rst FarCall @@ -467,9 +423,6 @@ Script__2dmenu: ret Script_verbosegiveitem: -; script command 0x9d -; parameters: item, quantity - call Script_giveitem call CurItemName ld de, wStringBuffer1 @@ -502,8 +455,6 @@ GiveItemScript: text_end Script_itemnotify: -; script command 0x45 - call GetPocketName call CurItemName ld b, BANK(PutItemInPocketText) @@ -512,8 +463,6 @@ Script_itemnotify: ret Script_pocketisfull: -; script command 0x46 - call GetPocketName call CurItemName ld b, BANK(PocketIsFullText) @@ -522,8 +471,6 @@ Script_pocketisfull: ret Script_specialsound: -; script command 0x87 - farcall CheckItemPocket ld a, [wItemAttributeParamBuffer] cp TM_HM @@ -569,9 +516,6 @@ PocketIsFullText: text_end Script_pokemart: -; script command 0x93 -; parameters: mart_type, mart_id - call GetScriptByte ld c, a call GetScriptByte @@ -584,9 +528,6 @@ Script_pokemart: ret Script_elevator: -; script command 0x94 -; parameters: floor_list_pointer - xor a ld [wScriptVar], a call GetScriptByte @@ -602,18 +543,12 @@ Script_elevator: ret Script_trade: -; script command 0x95 -; parameters: trade_id - call GetScriptByte ld e, a farcall NPCTrade ret Script_phonecall: -; script command 0x97 -; parameters: caller_name - call GetScriptByte ld e, a call GetScriptByte @@ -624,15 +559,10 @@ Script_phonecall: ret Script_hangup: -; script command 0x98 - farcall HangUp ret Script_askforphonenumber: -; script command 0x96 -; parameters: number - call YesNoBox jr c, .refused call GetScriptByte @@ -652,9 +582,6 @@ Script_askforphonenumber: ret Script_describedecoration: -; script command 0x99 -; parameters: byte - call GetScriptByte ld b, a farcall DescribeDecoration @@ -663,9 +590,6 @@ Script_describedecoration: jp ScriptJump Script_fruittree: -; script command 0x9a -; parameters: tree_id - call GetScriptByte ld [wCurFruitTree], a ld b, BANK(FruitTreeScript) @@ -673,9 +597,6 @@ Script_fruittree: jp ScriptJump Script_swarm: -; script command 0x9e -; parameters: map_group, map_id - call GetScriptByte ld d, a call GetScriptByte @@ -684,9 +605,6 @@ Script_swarm: ret Script_trainertext: -; script command 0x61 -; parameters: text_id - call GetScriptByte ld c, a ld b, 0 @@ -702,8 +620,6 @@ Script_trainertext: ret Script_scripttalkafter: -; script command 0x64 - ld hl, wScriptAfterPointer ld a, [hli] ld h, [hl] @@ -713,9 +629,6 @@ Script_scripttalkafter: jp ScriptJump Script_trainerflagaction: -; script command 0x62 -; parameters: action - xor a ld [wScriptVar], a ld hl, wTempTrainerEventFlag @@ -733,9 +646,6 @@ Script_trainerflagaction: ret Script_winlosstext: -; script command 0x63 -; parameters: win_text_pointer, loss_text_pointer - ld hl, wWinTextPointer call GetScriptByte ld [hli], a @@ -749,16 +659,12 @@ Script_winlosstext: ret Script_endifjustbattled: -; script command 0x65 - ld a, [wRunningTrainerBattleScript] and a ret z jp Script_end Script_checkjustbattled: -; script command 0x66 - ld a, TRUE ld [wScriptVar], a ld a, [wRunningTrainerBattleScript] @@ -769,23 +675,16 @@ Script_checkjustbattled: ret Script_encountermusic: -; script command 0x7f - ld a, [wOtherTrainerClass] ld e, a farcall PlayTrainerEncounterMusic ret Script_playmapmusic: -; script command 0x81 - call PlayMapMusic ret Script_playmusic: -; script command 0x7e -; parameters: music_pointer - ld de, MUSIC_NONE call PlayMusic xor a @@ -799,9 +698,6 @@ Script_playmusic: ret Script_musicfadeout: -; script command 0x80 -; parameters: music, fadetime - call GetScriptByte ld [wMusicFadeID], a call GetScriptByte @@ -812,9 +708,6 @@ Script_musicfadeout: ret Script_playsound: -; script command 0x84 -; parameters: sound_pointer - call GetScriptByte ld e, a call GetScriptByte @@ -823,22 +716,15 @@ Script_playsound: ret Script_waitsfx: -; script command 0x85 - call WaitSFX ret Script_warpsound: -; script command 0x86 - farcall GetWarpSFX call PlaySFX ret Script_cry: -; script command 0x83 -; parameters: cry_id - call GetScriptByte push af call GetScriptByte @@ -851,17 +737,11 @@ Script_cry: ret Script_setlasttalked: -; script command 0x67 -; parameters: object_id - call GetScriptByte ldh [hLastTalked], a ret Script_applymovement: -; script command 0x68 -; parameters: object_id, data - call GetScriptByte ld c, a @@ -894,8 +774,6 @@ SetFlagsForMovement_2: ret Script_applymovementlasttalked: -; script command 0x69 -; parameters: data ; apply movement to last talked ldh a, [hLastTalked] @@ -903,8 +781,6 @@ Script_applymovementlasttalked: jp ApplyMovement Script_faceplayer: -; script command 0x6a - ldh a, [hLastTalked] and a ret z @@ -922,9 +798,6 @@ Script_faceplayer: ret Script_faceobject: -; script command 0x6b -; parameters: object1, object2 - call GetScriptByte cp LAST_TALKED jr c, .ok @@ -950,9 +823,6 @@ Script_faceobject: ret Script_turnobject: -; script command 0x75 -; parameters: object_id, facing - call GetScriptByte cp LAST_TALKED jr nz, .ok @@ -994,9 +864,6 @@ ApplyObjectFacing: ret Script_variablesprite: -; script command 0x6c -; parameters: byte, sprite - call GetScriptByte ld e, a ld d, $0 @@ -1007,9 +874,6 @@ Script_variablesprite: ret Script_appear: -; script command 0x6e -; parameters: object_id - call GetScriptByte call _CopyObjectStruct ldh a, [hMapObjectIndexBuffer] @@ -1018,9 +882,6 @@ Script_appear: ret Script_disappear: -; script command 0x6d -; parameters: object_id - call GetScriptByte cp LAST_TALKED jr nz, .ok @@ -1054,9 +915,6 @@ ApplyEventActionAppearDisappear: ret Script_follow: -; script command 0x6f -; parameters: object2, object1 - call GetScriptByte ld b, a call GetScriptByte @@ -1065,15 +923,10 @@ Script_follow: ret Script_stopfollow: -; script command 0x70 - farcall StopFollow ret Script_moveobject: -; script command 0x71 -; parameters: object id, x, y - call GetScriptByte ld b, a call GetScriptByte @@ -1086,9 +939,6 @@ Script_moveobject: ret Script_writeobjectxy: -; script command 0x72 -; parameters: object_id - call GetScriptByte cp LAST_TALKED jr nz, .ok @@ -1099,9 +949,6 @@ Script_writeobjectxy: ret Script_follownotexact: -; script command 0x76 -; parameters: object2, object1 - call GetScriptByte ld b, a call GetScriptByte @@ -1110,9 +957,6 @@ Script_follownotexact: ret Script_loademote: -; script command 0x73 -; parameters: bubble - call GetScriptByte cp EMOTE_FROM_MEM jr nz, .not_var_emote @@ -1123,9 +967,6 @@ Script_loademote: ret Script_showemote: -; script command 0x74 -; parameters: bubble, object_id, time - call GetScriptByte ld [wScriptVar], a call GetScriptByte @@ -1157,9 +998,6 @@ ShowEmoteScript: step_end Script_earthquake: -; script command 0x77 -; parameters: param - ld hl, EarthquakeMovement ld de, wEarthquakeMovementDataBuffer ld bc, EarthquakeMovement.End - EarthquakeMovement @@ -1183,8 +1021,6 @@ EarthquakeMovement: .End Script_loadpikachudata: -; script command 0x59 - ld a, PIKACHU ld [wTempWildMonSpecies], a ld a, 5 @@ -1192,15 +1028,11 @@ Script_loadpikachudata: ret Script_randomwildmon: -; script command 0x5a - xor a ld [wBattleScriptFlags], a ret Script_loadtemptrainer: -; script command 0x5b - ld a, (1 << 7) | 1 ld [wBattleScriptFlags], a ld a, [wTempTrainerClass] @@ -1210,9 +1042,6 @@ Script_loadtemptrainer: ret Script_loadwildmon: -; script command 0x5c -; parameters: pokemon, level - ld a, (1 << 7) ld [wBattleScriptFlags], a call GetScriptByte @@ -1222,9 +1051,6 @@ Script_loadwildmon: ret Script_loadtrainer: -; script command 0x5d -; parameters: trainer_group, trainer_id - ld a, (1 << 7) | 1 ld [wBattleScriptFlags], a call GetScriptByte @@ -1234,8 +1060,6 @@ Script_loadtrainer: ret Script_startbattle: -; script command 0x5e - call BufferScreen predef StartBattle ld a, [wBattleResult] @@ -1244,9 +1068,6 @@ Script_startbattle: ret Script_catchtutorial: -; script command 0x60 -; parameters: byte - call GetScriptByte ld [wBattleType], a call BufferScreen @@ -1254,8 +1075,6 @@ Script_catchtutorial: jp Script_reloadmap Script_reloadmapafterbattle: -; script command 0x5f - ld hl, wBattleScriptFlags ld d, [hl] ld [hl], 0 @@ -1284,8 +1103,6 @@ Script_reloadmapafterbattle: jp Script_reloadmap Script_reloadmap: -; script command 0x7a - xor a ld [wBattleScriptFlags], a ld a, MAPSETUP_RELOADMAP @@ -1296,9 +1113,6 @@ Script_reloadmap: ret Script_scall: -; script command 0x0 -; parameters: pointer - ld a, [wScriptBank] ld b, a call GetScriptByte @@ -1308,9 +1122,6 @@ Script_scall: jr ScriptCall Script_farscall: -; script command 0x1 -; parameters: pointer - call GetScriptByte ld b, a call GetScriptByte @@ -1320,9 +1131,6 @@ Script_farscall: jr ScriptCall Script_memcall: -; script command 0x2 -; parameters: pointer - call GetScriptByte ld l, a call GetScriptByte @@ -1372,9 +1180,6 @@ CallCallback:: jp ScriptCall Script_sjump: -; script command 0x3 -; parameters: pointer - call GetScriptByte ld l, a call GetScriptByte @@ -1384,9 +1189,6 @@ Script_sjump: jp ScriptJump Script_farsjump: -; script command 0x4 -; parameters: pointer - call GetScriptByte ld b, a call GetScriptByte @@ -1396,9 +1198,6 @@ Script_farsjump: jp ScriptJump Script_memjump: -; script command 0x5 -; parameters: pointer - call GetScriptByte ld l, a call GetScriptByte @@ -1411,27 +1210,18 @@ Script_memjump: jp ScriptJump Script_iffalse: -; script command 0x8 -; parameters: pointer - ld a, [wScriptVar] and a jp nz, SkipTwoScriptBytes jp Script_sjump Script_iftrue: -; script command 0x9 -; parameters: pointer - ld a, [wScriptVar] and a jp nz, Script_sjump jp SkipTwoScriptBytes Script_ifequal: -; script command 0x6 -; parameters: byte, pointer - call GetScriptByte ld hl, wScriptVar cp [hl] @@ -1439,9 +1229,6 @@ Script_ifequal: jr SkipTwoScriptBytes Script_ifnotequal: -; script command 0x7 -; parameters: byte, pointer - call GetScriptByte ld hl, wScriptVar cp [hl] @@ -1449,9 +1236,6 @@ Script_ifnotequal: jr SkipTwoScriptBytes Script_ifgreater: -; script command 0xa -; parameters: byte, pointer - ld a, [wScriptVar] ld b, a call GetScriptByte @@ -1460,9 +1244,6 @@ Script_ifgreater: jr SkipTwoScriptBytes Script_ifless: -; script command 0xb -; parameters: byte, pointer - call GetScriptByte ld b, a ld a, [wScriptVar] @@ -1471,16 +1252,10 @@ Script_ifless: jr SkipTwoScriptBytes Script_jumpstd: -; script command 0xc -; parameters: predefined_script - call StdScript jr ScriptJump Script_callstd: -; script command 0xd -; parameters: predefined_script - call StdScript ld d, h ld e, l @@ -1518,9 +1293,6 @@ ScriptJump: ret Script_prioritysjump: -; script command 0x8c -; parameters: pointer - ld a, [wScriptBank] ld [wPriorityScriptBank], a call GetScriptByte @@ -1532,8 +1304,6 @@ Script_prioritysjump: ret Script_checkscene: -; script command 0x13 - call CheckScenes jr z, .no_scene ld [wScriptVar], a @@ -1545,9 +1315,6 @@ Script_checkscene: ret Script_checkmapscene: -; script command 0x11 -; parameters: map_group, map_id - call GetScriptByte ld b, a call GetScriptByte @@ -1566,9 +1333,6 @@ Script_checkmapscene: ret Script_setscene: -; script command 0x14 -; parameters: scene_id - ld a, [wMapGroup] ld b, a ld a, [wMapNumber] @@ -1576,9 +1340,6 @@ Script_setscene: jr DoScene Script_setmapscene: -; script command 0x12 -; parameters: map_group, map_id, scene_id - call GetScriptByte ld b, a call GetScriptByte @@ -1594,9 +1355,6 @@ DoScene: ret Script_readmem: -; script command 0x19 -; parameters: address - call GetScriptByte ld l, a call GetScriptByte @@ -1606,9 +1364,6 @@ Script_readmem: ret Script_writemem: -; script command 0x1a -; parameters: address - call GetScriptByte ld l, a call GetScriptByte @@ -1618,9 +1373,6 @@ Script_writemem: ret Script_loadmem: -; script command 0x1b -; parameters: address, value - call GetScriptByte ld l, a call GetScriptByte @@ -1630,17 +1382,11 @@ Script_loadmem: ret Script_setval: -; script command 0x15 -; parameters: value - call GetScriptByte ld [wScriptVar], a ret Script_addval: -; script command 0x16 -; parameters: value - call GetScriptByte ld hl, wScriptVar add [hl] @@ -1648,9 +1394,6 @@ Script_addval: ret Script_random: -; script command 0x17 -; parameters: input - call GetScriptByte ld [wScriptVar], a and a @@ -1701,9 +1444,6 @@ Script_random: ret Script_readvar: -; script command 0x1c -; parameters: variable_id - call GetScriptByte call GetVarAction ld a, [de] @@ -1711,9 +1451,6 @@ Script_readvar: ret Script_writevar: -; script command 0x1d -; parameters: variable_id - call GetScriptByte call GetVarAction ld a, [wScriptVar] @@ -1721,9 +1458,6 @@ Script_writevar: ret Script_loadvar: -; script command 0x1e -; parameters: variable_id, value - call GetScriptByte call GetVarAction call GetScriptByte @@ -1736,8 +1470,6 @@ GetVarAction: ret Script_checkver: -; script command 0x18 - ld a, [.gs_version] ld [wScriptVar], a ret @@ -1746,9 +1478,6 @@ Script_checkver: db GS_VERSION Script_getmonname: -; script command 0x40 -; parameters: string_buffer, mon_id (0 aka USE_SCRIPT_VAR to use wScriptVar) - call GetScriptByte and a jr nz, .gotit @@ -1773,9 +1502,6 @@ CopyConvertedText: ret Script_getitemname: -; script command 0x41 -; parameters: string_buffer, item_id (0 aka USE_SCRIPT_VAR to use wScriptVar) - call GetScriptByte and a ; USE_SCRIPT_VAR jr nz, .ok @@ -1787,9 +1513,6 @@ Script_getitemname: jr GetStringBuffer Script_getcurlandmarkname: -; script command 0x42 -; parameters: string_buffer - ld a, [wMapGroup] ld b, a ld a, [wMapNumber] @@ -1803,9 +1526,6 @@ ConvertLandmarkToText: jp GetStringBuffer Script_gettrainername: -; script command 0x43 -; parameters: string_buffer, trainer_group, trainer_id - call GetScriptByte ld c, a call GetScriptByte @@ -1814,9 +1534,6 @@ Script_gettrainername: jr GetStringBuffer Script_getmoney: -; script command 0x3d -; parameters: string_buffer, account - call ResetStringBuffer1 call GetMoneyAccount ld hl, wStringBuffer1 @@ -1826,9 +1543,6 @@ Script_getmoney: jp GetStringBuffer Script_getcoins: -; script command 0x3e -; parameters: string_buffer - call ResetStringBuffer1 ld hl, wStringBuffer1 ld de, wCoins @@ -1838,9 +1552,6 @@ Script_getcoins: jp GetStringBuffer Script_getnum: -; script command 0x3f -; parameters: string_buffer - call ResetStringBuffer1 ld de, wScriptVar ld hl, wStringBuffer1 @@ -1851,15 +1562,12 @@ Script_getnum: ResetStringBuffer1: ld hl, wStringBuffer1 - ld bc, NAME_LENGTH + 2 + ld bc, MOVE_NAME_LENGTH ld a, "@" call ByteFill ret Script_getstring: -; script command 0x44 -; parameters: string_buffer, text_pointer - call GetScriptByte ld e, a call GetScriptByte @@ -1871,9 +1579,6 @@ Script_getstring: jp GetStringBuffer Script_givepokemail: -; script command 0x2f -; parameters: pointer - call GetScriptByte ld l, a call GetScriptByte @@ -1892,9 +1597,6 @@ Script_givepokemail: ret Script_checkpokemail: -; script command 0x30 -; parameters: pointer - call GetScriptByte ld e, a call GetScriptByte @@ -1905,9 +1607,6 @@ Script_checkpokemail: ret Script_giveitem: -; script command 0x1f -; parameters: item, quantity - call GetScriptByte cp ITEM_FROM_MEM jr nz, .ok @@ -1928,9 +1627,6 @@ Script_giveitem: ret Script_takeitem: -; script command 0x20 -; parameters: item, quantity - xor a ld [wScriptVar], a call GetScriptByte @@ -1947,9 +1643,6 @@ Script_takeitem: ret Script_checkitem: -; script command 0x21 -; parameters: item - xor a ld [wScriptVar], a call GetScriptByte @@ -1962,27 +1655,18 @@ Script_checkitem: ret Script_givemoney: -; script command 0x22 -; parameters: account, money - call GetMoneyAccount call LoadMoneyAmountToMem farcall GiveMoney ret Script_takemoney: -; script command 0x23 -; parameters: account, money - call GetMoneyAccount call LoadMoneyAmountToMem farcall TakeMoney ret Script_checkmoney: -; script command 0x24 -; parameters: account, money - call GetMoneyAccount call LoadMoneyAmountToMem farcall CompareMoney @@ -2024,25 +1708,16 @@ LoadMoneyAmountToMem: ret Script_givecoins: -; script command 0x25 -; parameters: coins - call LoadCoinAmountToMem farcall GiveCoins ret Script_takecoins: -; script command 0x26 -; parameters: coins - call LoadCoinAmountToMem farcall TakeCoins ret Script_checkcoins: -; script command 0x27 -; parameters: coins - call LoadCoinAmountToMem farcall CheckCoins jr CompareMoneyAction @@ -2056,9 +1731,6 @@ LoadCoinAmountToMem: ret Script_checktime: -; script command 0x2b -; parameters: time - xor a ld [wScriptVar], a farcall CheckTime @@ -2070,9 +1742,6 @@ Script_checktime: ret Script_checkpoke: -; script command 0x2c -; parameters: pokemon - xor a ld [wScriptVar], a call GetScriptByte @@ -2085,9 +1754,6 @@ Script_checkpoke: ret Script_addcellnum: -; script command 0x28 -; parameters: person - xor a ld [wScriptVar], a call GetScriptByte @@ -2099,9 +1765,6 @@ Script_addcellnum: ret Script_delcellnum: -; script command 0x29 -; parameters: person - xor a ld [wScriptVar], a call GetScriptByte @@ -2113,8 +1776,6 @@ Script_delcellnum: ret Script_checkcellnum: -; script command 0x2a -; parameters: person ; returns false if the cell number is not in your phone xor a @@ -2128,9 +1789,6 @@ Script_checkcellnum: ret Script_specialphonecall: -; script command 0x9b -; parameters: call_id - call GetScriptByte ld [wSpecialPhoneCallID], a call GetScriptByte @@ -2138,7 +1796,6 @@ Script_specialphonecall: ret Script_checkphonecall: -; script command 0x9c ; returns false if no special phone call is stored ld a, [wSpecialPhoneCallID] @@ -2150,9 +1807,6 @@ Script_checkphonecall: ret Script_givepoke: -; script command 0x2d -; parameters: pokemon, level, item, trainer, trainer_name_pointer, pkmn_nickname - call GetScriptByte ld [wCurPartySpecies], a call GetScriptByte @@ -2178,8 +1832,6 @@ Script_givepoke: ret Script_giveegg: -; script command 0x2e -; parameters: pokemon, level ; if no room in the party, return 0 in wScriptVar; else, return 2 xor a ; PARTYMON @@ -2196,9 +1848,6 @@ Script_giveegg: ret Script_setevent: -; script command 0x33 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2208,9 +1857,6 @@ Script_setevent: ret Script_clearevent: -; script command 0x32 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2220,9 +1866,6 @@ Script_clearevent: ret Script_checkevent: -; script command 0x31 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2238,9 +1881,6 @@ Script_checkevent: ret Script_setflag: -; script command 0x36 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2250,9 +1890,6 @@ Script_setflag: ret Script_clearflag: -; script command 0x35 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2262,9 +1899,6 @@ Script_clearflag: ret Script_checkflag: -; script command 0x34 -; parameters: bit_number - call GetScriptByte ld e, a call GetScriptByte @@ -2284,23 +1918,16 @@ _EngineFlagAction: ret Script_wildoff: -; script command 0x38 - ld hl, wStatusFlags set STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl] ret Script_wildon: -; script command 0x37 - ld hl, wStatusFlags res STATUSFLAGS_NO_WILD_ENCOUNTERS_F, [hl] ret Script_xycompare: -; script command 0x39 -; parameters: pointer - call GetScriptByte ld [wXYComparePointer], a call GetScriptByte @@ -2308,9 +1935,6 @@ Script_xycompare: ret Script_warpfacing: -; script command 0xa1 -; parameters: facing, map_group, map_id, x, y - call GetScriptByte maskbits NUM_DIRECTIONS ld c, a @@ -2321,9 +1945,6 @@ Script_warpfacing: ; fallthrough Script_warp: -; script command 0x3c -; parameters: map_group, map_id, x, y - ; This seems to be some sort of error handling case. call GetScriptByte and a @@ -2358,9 +1979,6 @@ Script_warp: ret Script_warpmod: -; script command 0x3a -; parameters: warp_id, map_group, map_id - call GetScriptByte ld [wBackupWarpNumber], a call GetScriptByte @@ -2370,9 +1988,6 @@ Script_warpmod: ret Script_blackoutmod: -; script command 0x3b -; parameters: map_group, map_id - call GetScriptByte ld [wLastSpawnMapGroup], a call GetScriptByte @@ -2380,16 +1995,11 @@ Script_blackoutmod: ret Script_dontrestartmapmusic: -; script command 0x82 - ld a, TRUE ld [wDontPlayMapMusicOnReload], a ret Script_writecmdqueue: -; script command 0x7c -; parameters: queue_pointer - call GetScriptByte ld e, a call GetScriptByte @@ -2400,9 +2010,6 @@ Script_writecmdqueue: ret Script_delcmdqueue: -; script command 0x7d -; parameters: byte - xor a ld [wScriptVar], a call GetScriptByte @@ -2414,9 +2021,6 @@ Script_delcmdqueue: ret Script_changemapblocks: -; script command 0x78 -; parameters: map_data_pointer - call GetScriptByte ld [wMapBlocksBank], a call GetScriptByte @@ -2428,9 +2032,6 @@ Script_changemapblocks: ret Script_changeblock: -; script command 0x79 -; parameters: x, y, block - call GetScriptByte add 4 ld d, a @@ -2444,8 +2045,6 @@ Script_changeblock: ret Script_reloadmappart:: -; script command 0x7b - xor a ldh [hBGMapMode], a call OverworldTextModeSwitch @@ -2455,8 +2054,6 @@ Script_reloadmappart:: ret Script_warpcheck: -; script command 0x8d - call WarpCheck ret nc farcall EnableEvents @@ -2468,9 +2065,6 @@ Script_enableevents: ret Script_newloadmap: -; script command 0x89 -; parameters: which_method - call GetScriptByte ldh [hMapEntryMethod], a ld a, MAPSTATUS_ENTER @@ -2479,29 +2073,19 @@ Script_newloadmap: ret Script_reloadandreturn: -; script command 0x91 - call Script_newloadmap jp Script_end Script_opentext: -; script command 0x47 - call OpenText ret Script_refreshscreen: -; script command 0x48 -; parameters: dummy - call RefreshScreen call GetScriptByte ret Script_writeunusedbytebuffer: -; script command 0x4a -; parameters: byte - call GetScriptByte ld [wUnusedScriptByteBuffer], a ret @@ -2509,11 +2093,9 @@ Script_writeunusedbytebuffer: db closetext_command ; unused Script_closetext: -; script command 0x49 - ldh a, [hOAMUpdate] push af - ld a, $01 + ld a, $1 ldh [hOAMUpdate], a call WaitBGMap pop af @@ -2522,9 +2104,6 @@ Script_closetext: ret Script_autoinput: -; script command 0x88 -; parameters: input_pointer - call GetScriptByte push af call GetScriptByte @@ -2536,9 +2115,6 @@ Script_autoinput: ret Script_pause: -; script command 0x8a -; parameters: length - call GetScriptByte and a jr z, .loop @@ -2552,9 +2128,6 @@ Script_pause: ret Script_deactivatefacing: -; script command 0x8b -; parameters: time - call GetScriptByte and a jr z, .no_time @@ -2566,15 +2139,10 @@ Script_deactivatefacing: ret Script_stopandsjump: -; script command 0x8e -; parameters: pointer - call StopScript jp Script_sjump Script_end: -; script command 0x90 - call ExitScriptSubroutine jr c, .resume ret @@ -2590,8 +2158,6 @@ Script_end: ret Script_return: -; script command 0x8f - call ExitScriptSubroutine jr c, .dummy .dummy @@ -2631,8 +2197,6 @@ ExitScriptSubroutine: ret Script_endall: -; script command 0x92 - xor a ld [wScriptStackSize], a ld [wScriptRunning], a @@ -2644,8 +2208,6 @@ Script_endall: ret Script_halloffame: -; script command 0x9f - ld hl, wGameTimerPause res GAMETIMERPAUSE_TIMER_PAUSED_F, [hl] farcall HallOfFame @@ -2654,8 +2216,6 @@ Script_halloffame: jr ReturnFromCredits Script_credits: -; script command 0xa0 - farcall RedCredits ReturnFromCredits: call Script_endall |