diff options
Diffstat (limited to 'home')
-rw-r--r-- | home/overworld.asm | 48 | ||||
-rw-r--r-- | home/overworld_text.asm | 28 | ||||
-rw-r--r-- | home/pokemon.asm | 4 | ||||
-rw-r--r-- | home/text.asm | 471 | ||||
-rw-r--r-- | home/text_script.asm (renamed from home/predef_text.asm) | 74 | ||||
-rw-r--r-- | home/trainers.asm | 4 |
6 files changed, 272 insertions, 357 deletions
diff --git a/home/overworld.asm b/home/overworld.asm index 79e4ea97..be4af6ee 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -75,8 +75,8 @@ OverworldLoopLessDelay:: bit 3, a ; start button jr z, .startButtonNotPressed ; if START is pressed - xor a - ld [hSpriteIndexOrTextID], a ; start menu text ID + xor a ; TEXT_START_MENU + ld [hSpriteIndexOrTextID], a jp .displayDialogue .startButtonNotPressed bit 0, a ; A button @@ -88,7 +88,7 @@ OverworldLoopLessDelay:: call IsPlayerCharacterBeingControlledByGame jr nz, .checkForOpponent call CheckForHiddenObjectOrBookshelfOrCardKeyDoor - ld a, [hFoundHiddenObjectOrBookshelf] + ld a, [hItemAlreadyFound] and a jp z, OverworldLoop ; jump if a hidden object or bookshelf was found, but not if a card key door was found call IsSpriteOrSignInFrontOfPlayer @@ -149,7 +149,7 @@ OverworldLoopLessDelay:: bit 7, a ; down button jr z, .checkIfUpButtonIsPressed ld a, 1 - ld [wSpriteStateData1 + 3], a ; delta Y + ld [wSpritePlayerStateData1YStepVector], a ld a, PLAYER_DIR_DOWN jr .handleDirectionButtonPress @@ -157,7 +157,7 @@ OverworldLoopLessDelay:: bit 6, a ; up button jr z, .checkIfLeftButtonIsPressed ld a, -1 - ld [wSpriteStateData1 + 3], a ; delta Y + ld [wSpritePlayerStateData1YStepVector], a ld a, PLAYER_DIR_UP jr .handleDirectionButtonPress @@ -165,7 +165,7 @@ OverworldLoopLessDelay:: bit 5, a ; left button jr z, .checkIfRightButtonIsPressed ld a, -1 - ld [wSpriteStateData1 + 5], a ; delta X + ld [wSpritePlayerStateData1XStepVector], a ld a, PLAYER_DIR_LEFT jr .handleDirectionButtonPress @@ -173,7 +173,7 @@ OverworldLoopLessDelay:: bit 4, a ; right button jr z, .noDirectionButtonsPressed ld a, 1 - ld [wSpriteStateData1 + 5], a ; delta X + ld [wSpritePlayerStateData1XStepVector], a .handleDirectionButtonPress @@ -1133,7 +1133,7 @@ IsSpriteInFrontOfPlayer:: ld d, $10 ; talking range in pixels (normal range) IsSpriteInFrontOfPlayer2:: lb bc, $3c, $40 ; Y and X position of player sprite - ld a, [wSpriteStateData1 + 9] ; direction the player is facing + ld a, [wSpritePlayerStateData1FacingDirection] .checkIfPlayerFacingUp cp SPRITE_FACING_UP jr nz, .checkIfPlayerFacingDown @@ -1176,7 +1176,7 @@ IsSpriteInFrontOfPlayer2:: and a ret z ; if there are sprites - ld hl, wSpriteStateData1 + $10 + ld hl, wSprite01StateData1 ld d, a ld e, $01 .spriteLoop @@ -1228,7 +1228,7 @@ CollisionCheckOnLand:: jr nz, .noCollision ; no collisions when the player's movements are being controlled by the game ld a, [wPlayerDirection] ; the direction that the player is trying to go in ld d, a - ld a, [wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) + ld a, [wSpritePlayerStateData1CollisionData] and d ; check if a sprite is in the direction the player is trying to go jr nz, .collision xor a @@ -1462,9 +1462,9 @@ LoadCurrentMapView:: ret AdvancePlayerSprite:: - ld a, [wSpriteStateData1 + 3] ; delta Y + ld a, [wSpritePlayerStateData1YStepVector] ld b, a - ld a, [wSpriteStateData1 + 5] ; delta X + ld a, [wSpritePlayerStateData1XStepVector] ld c, a ld hl, wWalkCounter ; walking animation counter dec [hl] @@ -1596,7 +1596,7 @@ AdvancePlayerSprite:: call MoveTileBlockMapPointerNorth .updateMapView call LoadCurrentMapView - ld a, [wSpriteStateData1 + 3] ; delta Y + ld a, [wSpritePlayerStateData1YStepVector] cp $01 jr nz, .checkIfMovingNorth2 ; if moving south @@ -1609,7 +1609,7 @@ AdvancePlayerSprite:: call ScheduleNorthRowRedraw jr .scrollBackgroundAndSprites .checkIfMovingEast2 - ld a, [wSpriteStateData1 + 5] ; delta X + ld a, [wSpritePlayerStateData1XStepVector] cp $01 jr nz, .checkIfMovingWest2 ; if moving east @@ -1621,9 +1621,9 @@ AdvancePlayerSprite:: ; if moving west call ScheduleWestColumnRedraw .scrollBackgroundAndSprites - ld a, [wSpriteStateData1 + 3] ; delta Y + ld a, [wSpritePlayerStateData1YStepVector] ld b, a - ld a, [wSpriteStateData1 + 5] ; delta X + ld a, [wSpritePlayerStateData1XStepVector] ld c, a sla b sla c @@ -1635,7 +1635,7 @@ AdvancePlayerSprite:: ld [hSCX], a ; update background scroll X ; shift all the sprites in the direction opposite of the player's motion ; so that the player appears to move relative to them - ld hl, wSpriteStateData1 + $14 + ld hl, wSprite01StateData1YPixels ld a, [wNumSprites] ; number of sprites and a ; are there any sprites? jr z, .done @@ -1845,8 +1845,8 @@ DrawTileBlock:: ; function to update joypad state and simulate button presses JoypadOverworld:: xor a - ld [wSpriteStateData1 + 3], a - ld [wSpriteStateData1 + 5], a + ld [wSpritePlayerStateData1YStepVector], a + ld [wSpritePlayerStateData1XStepVector], a call RunMapScript call Joypad ld a, [wFlags_D733] @@ -1920,7 +1920,7 @@ CollisionCheckOnWater:: jp nz, .noCollision ; return and clear carry if button presses are being simulated ld a, [wPlayerDirection] ; the direction that the player is trying to go in ld d, a - ld a, [wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) + ld a, [wSpritePlayerStateData1CollisionData] and d ; check if a sprite is in the direction the player is trying to go jr nz, .checkIfNextTileIsPassable ; bug? ld hl, TilePairCollisionsWater @@ -2168,8 +2168,8 @@ LoadMapHeader:: ld [wNumSprites], a ; save the number of sprites push hl ; zero C110-C1FF and C210-C2FF - ld hl, wSpriteStateData1 + $10 - ld de, wSpriteStateData2 + $10 + ld hl, wSprite01StateData1 + ld de, wSprite01StateData2 xor a ld b, $f0 .zeroSpriteDataLoop @@ -2179,7 +2179,7 @@ LoadMapHeader:: dec b jr nz, .zeroSpriteDataLoop ; initialize all C100-C1FF sprite entries to disabled (other than player's) - ld hl, wSpriteStateData1 + $12 + ld hl, wSprite01StateData1ImageIndex ld de, $10 ld c, $0f .disableSpriteEntriesLoop @@ -2188,7 +2188,7 @@ LoadMapHeader:: dec c jr nz, .disableSpriteEntriesLoop pop hl - ld de, wSpriteStateData1 + $10 + ld de, wSprite01StateData1 ld a, [wNumSprites] ; number of sprites and a ; are there any sprites? jp z, .finishUp ; if there are no sprites, skip the rest diff --git a/home/overworld_text.asm b/home/overworld_text.asm index b32335f7..7ea23fe4 100644 --- a/home/overworld_text.asm +++ b/home/overworld_text.asm @@ -1,31 +1,31 @@ -TextScriptEndingChar:: - db "@" +TextScriptEndingText:: + text_end TextScriptEnd:: - ld hl, TextScriptEndingChar + ld hl, TextScriptEndingText ret ExclamationText:: - TX_FAR _ExclamationText - db "@" + text_far _ExclamationText + text_end GroundRoseText:: - TX_FAR _GroundRoseText - db "@" + text_far _GroundRoseText + text_end BoulderText:: - TX_FAR _BoulderText - db "@" + text_far _BoulderText + text_end MartSignText:: - TX_FAR _MartSignText - db "@" + text_far _MartSignText + text_end PokeCenterSignText:: - TX_FAR _PokeCenterSignText - db "@" + text_far _PokeCenterSignText + text_end PickUpItemText:: - TX_ASM + text_asm predef PickUpItem jp TextScriptEnd diff --git a/home/pokemon.asm b/home/pokemon.asm index 141baa65..539632d4 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -342,7 +342,7 @@ PrintStatusConditionNotFainted:: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevel:: - ld a, $6e ; ":L" tile ID + ld a, "<LV>" ; ":L" tile ID ld [hli], a ld c, 2 ; number of digits ld a, [wLoadedMonLevel] ; level @@ -358,7 +358,7 @@ PrintLevel:: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevelFull:: - ld a, $6e ; ":L" tile ID + ld a, "<LV>" ; ":L" tile ID ld [hli], a ld c, 3 ; number of digits ld a, [wLoadedMonLevel] ; level diff --git a/home/text.asm b/home/text.asm index 0d2ed0a2..d0fc8042 100644 --- a/home/text.asm +++ b/home/text.asm @@ -5,9 +5,9 @@ TextBoxBorder:: push hl ld a, "┌" ld [hli], a - inc a ; ─ - call NPlaceChar - inc a ; ┐ + inc a ; "─" + call .PlaceChars + inc a ; "┐" ld [hl], a pop hl @@ -20,7 +20,7 @@ TextBoxBorder:: ld a, "│" ld [hli], a ld a, " " - call NPlaceChar + call .PlaceChars ld [hl], "│" pop hl @@ -33,11 +33,11 @@ TextBoxBorder:: ld a, "└" ld [hli], a ld a, "─" - call NPlaceChar + call .PlaceChars ld [hl], "┘" ret -NPlaceChar:: +.PlaceChars:: ; Place char a c times. ld d, c .loop @@ -48,19 +48,19 @@ NPlaceChar:: PlaceString:: push hl + PlaceNextChar:: ld a, [de] - cp "@" - jr nz, Char4ETest + jr nz, .NotTerminator ld b, h ld c, l pop hl ret -Char4ETest:: - cp $4E ; next - jr nz, .char4FTest +.NotTerminator + cp "<NEXT>" + jr nz, .NotNext ld bc, 2 * SCREEN_WIDTH ld a, [hFlagsFFF6] bit 2, a @@ -70,142 +70,101 @@ Char4ETest:: pop hl add hl, bc push hl - jp PlaceNextChar_inc + jp NextChar -.char4FTest - cp $4F ; line - jr nz, .next3 +.NotNext + cp "<LINE>" + jr nz, .NotLine pop hl coord hl, 1, 16 push hl - jp PlaceNextChar_inc - -.next3 ; Check against a dictionary -dict: macro -if \1 == 0 - and a -else - cp \1 -endc - jp z, \2 -endm - - dict $00, Char00 ; error - dict $4C, Char4C ; autocont - dict $4B, Char4B ; cont_ - dict $51, Char51 ; para - dict $49, Char49 ; page - dict $52, Char52 ; player - dict $53, Char53 ; rival - dict $54, Char54 ; POKé - dict $5B, Char5B ; PC - dict $5E, Char5E ; ROCKET - dict $5C, Char5C ; TM - dict $5D, Char5D ; TRAINER - dict $55, Char55 ; cont - dict $56, Char56 ; 6 dots - dict $57, Char57 ; done - dict $58, Char58 ; prompt - dict $4A, Char4A ; PKMN - dict $5F, Char5F ; dex - dict $59, Char59 ; TARGET - dict $5A, Char5A ; USER + jp NextChar + +.NotLine + +; Check against a dictionary + dict "<NULL>", NullChar + dict "<SCROLL>", _ContTextNoPause + dict "<_CONT>", _ContText + dict "<PARA>", Paragraph + dict "<PAGE>", PageChar + dict "<PLAYER>", PrintPlayerName + dict "<RIVAL>", PrintRivalName + dict "#", PlacePOKe + dict "<PC>", PCChar + dict "<ROCKET>", RocketChar + dict "<TM>", TMChar + dict "<TRAINER>", TrainerChar + dict "<CONT>", ContText + dict "<……>", SixDotsChar + dict "<DONE>", DoneText + dict "<PROMPT>", PromptText + dict "<PKMN>", PlacePKMN + dict "<DEXEND>", PlaceDexEnd + dict "<TARGET>", PlaceMoveTargetsName + dict "<USER>", PlaceMoveUsersName ld [hli], a call PrintLetterDelay -PlaceNextChar_inc:: + +NextChar:: inc de jp PlaceNextChar -Char00:: +NullChar:: ld b, h ld c, l pop hl - ld de, Char00Text + ld de, TextIDErrorText dec de ret -Char00Text:: ; “%d ERROR.” - TX_FAR _Char00Text - db "@" - -Char52:: ; player’s name - push de - ld de, wPlayerName - jr FinishDTE - -Char53:: ; rival’s name - push de - ld de, wRivalName - jr FinishDTE - -Char5D:: ; TRAINER - push de - ld de, Char5DText - jr FinishDTE - -Char5C:: ; TM - push de - ld de, Char5CText - jr FinishDTE - -Char5B:: ; PC - push de - ld de, Char5BText - jr FinishDTE - -Char5E:: ; ROCKET - push de - ld de, Char5EText - jr FinishDTE - -Char54:: ; POKé - push de - ld de, Char54Text - jr FinishDTE +TextIDErrorText:: ; "[hSpriteIndexOrTextID] ERROR." + text_far _TextIDErrorText + text_end -Char56:: ; …… +print_name: MACRO push de - ld de, Char56Text - jr FinishDTE - -Char4A:: ; PKMN - push de - ld de, Char4AText - jr FinishDTE - -Char59:: -; depending on whose turn it is, print -; enemy active monster’s name, prefixed with “Enemy ” -; or -; player active monster’s name -; (like Char5A but flipped) + ld de, \1 + jr PlaceCommandCharacter +ENDM + +PrintPlayerName:: print_name wPlayerName +PrintRivalName:: print_name wRivalName + +TrainerChar:: print_name TrainerCharText +TMChar:: print_name TMCharText +PCChar:: print_name PCCharText +RocketChar:: print_name RocketCharText +PlacePOKe:: print_name PlacePOKeText +SixDotsChar:: print_name SixDotsCharText +PlacePKMN:: print_name PlacePKMNText + +PlaceMoveTargetsName:: ld a, [hWhoseTurn] xor 1 - jr MonsterNameCharsCommon + jr PlaceMoveUsersName.place -Char5A:: -; depending on whose turn it is, print -; player active monster’s name -; or -; enemy active monster’s name, prefixed with “Enemy ” +PlaceMoveUsersName:: ld a, [hWhoseTurn] -MonsterNameCharsCommon:: + +.place: push de and a - jr nz, .Enemy - ld de, wBattleMonNick ; player active monster name - jr FinishDTE + jr nz, .enemy -.Enemy - ; print “Enemy ” - ld de, Char5AText + ld de, wBattleMonNick + jr PlaceCommandCharacter + +.enemy + ld de, EnemyText call PlaceString ld h, b ld l, c - ld de, wEnemyMonNick ; enemy active monster name + ld de, wEnemyMonNick + ; fallthrough -FinishDTE:: +PlaceCommandCharacter:: call PlaceString ld h, b ld l, c @@ -213,28 +172,20 @@ FinishDTE:: inc de jp PlaceNextChar -Char5CText:: - db "TM@" -Char5DText:: - db "TRAINER@" -Char5BText:: - db "PC@" -Char5EText:: - db "ROCKET@" -Char54Text:: - db "POKé@" -Char56Text:: - db "……@" -Char5AText:: - db "Enemy @" -Char4AText:: - db $E1,$E2,"@" ; PKMN - -Char55:: +TMCharText:: db "TM@" +TrainerCharText:: db "TRAINER@" +PCCharText:: db "PC@" +RocketCharText:: db "ROCKET@" +PlacePOKeText:: db "POKé@" +SixDotsCharText:: db "……@" +EnemyText:: db "Enemy @" +PlacePKMNText:: db "<PK><MN>@" + +ContText:: push de ld b, h ld c, l - ld hl, Char55Text + ld hl, ContCharText call TextCommandProcessor ld h, b ld l, c @@ -242,18 +193,16 @@ Char55:: inc de jp PlaceNextChar -Char55Text:: -; equivalent to Char4B - TX_FAR _Char55Text - db "@" +ContCharText:: + text_far _ContCharText + text_end -Char5F:: -; ends a Pokédex entry +PlaceDexEnd:: ld [hl], "." pop hl ret -Char58:: ; prompt +PromptText:: ld a, [wLinkState] cp LINK_STATE_BATTLING jp z, .ok @@ -264,16 +213,17 @@ Char58:: ; prompt call ManualTextScroll ld a, " " Coorda 18, 16 -Char57:: ; done + +DoneText:: pop hl - ld de, Char58Text + ld de, .stop dec de ret -Char58Text:: - db "@" +.stop: + text_end -Char51:: ; para +Paragraph:: push de ld a, "▼" Coorda 18, 16 @@ -286,9 +236,9 @@ Char51:: ; para call DelayFrames pop de coord hl, 1, 14 - jp PlaceNextChar_inc + jp NextChar -Char49:: +PageChar:: push de ld a, "▼" Coorda 18, 16 @@ -303,9 +253,9 @@ Char49:: pop hl coord hl, 1, 11 push hl - jp PlaceNextChar_inc + jp NextChar -Char4B:: +_ContText:: ld a, "▼" Coorda 18, 16 call ProtectedDelay3 @@ -314,14 +264,13 @@ Char4B:: pop de ld a, " " Coorda 18, 16 - ;fall through -Char4C:: +_ContTextNoPause:: push de call ScrollTextUpOneLine call ScrollTextUpOneLine coord hl, 1, 16 pop de - jp PlaceNextChar_inc + jp NextChar ; move both rows of text in the normal text box up one row ; always called twice in a row @@ -345,7 +294,6 @@ ScrollTextUpOneLine:: dec b jr nz, .clearText - ; wait five frames ld b, 5 .WaitFrame call DelayFrame @@ -375,18 +323,18 @@ TextCommandProcessor:: NextTextCommand:: ld a, [hli] - cp "@" ; terminator - jr nz, .doTextCommand + cp TX_END + jr nz, .TextCommand pop af ld [wLetterPrintingDelayFlags], a ret -.doTextCommand + +.TextCommand: push hl - cp $17 - jp z, TextCommand17 - cp $0e - jp nc, TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB -; if a < 0xE, use a jump table + cp TX_FAR + jp z, TextCommand_FAR + cp TX_SOUND_POKEDEX_RATING + jp nc, TextCommand_SOUND ld hl, TextCommandJumpTable push bc add a @@ -399,12 +347,8 @@ NextTextCommand:: ld l, a jp hl -; draw box -; 04AAAABBCC -; AAAA = address of upper left corner -; BB = height -; CC = width -TextCommand04:: +TextCommand_BOX:: +; draw a box (height, width) pop hl ld a, [hli] ld e, a @@ -421,9 +365,8 @@ TextCommand04:: pop hl jr NextTextCommand -; place string inline -; 00{string} -TextCommand00:: +TextCommand_START:: +; write text until "@" pop hl ld d, h ld e, l @@ -435,10 +378,8 @@ TextCommand00:: inc hl jr NextTextCommand -; place string from RAM -; 01AAAA -; AAAA = address of string -TextCommand01:: +TextCommand_RAM:: +; write text from a ram address (little endian) pop hl ld a, [hli] ld e, a @@ -451,13 +392,8 @@ TextCommand01:: pop hl jr NextTextCommand -; print BCD number -; 02AAAABB -; AAAA = address of BCD number -; BB -; bits 0-4 = length in bytes -; bits 5-7 = unknown flags -TextCommand02:: +TextCommand_BCD:: +; write bcd from address, typically ram pop hl ld a, [hli] ld e, a @@ -474,10 +410,8 @@ TextCommand02:: pop hl jr NextTextCommand -; repoint destination address -; 03AAAA -; AAAA = new destination address -TextCommand03:: +TextCommand_MOVE:: +; move to a new tile pop hl ld a, [hli] ld [wTextDest], a @@ -487,21 +421,17 @@ TextCommand03:: ld b, a jp NextTextCommand -; repoint destination to second line of dialogue text box -; 05 -; (no arguments) -TextCommand05:: +TextCommand_LOW:: +; write text at (1,16) pop hl - coord bc, 1, 16 ; address of second line of dialogue text box + coord bc, 1, 16 ; second line of dialogue text box jp NextTextCommand -; blink arrow and wait for A or B to be pressed -; 06 -; (no arguments) -TextCommand06:: +TextCommand_PROMPT_BUTTON:: +; wait for button press; show arrow ld a, [wLinkState] cp LINK_STATE_BATTLING - jp z, TextCommand0D + jp z, TextCommand_LINK_PROMPT_BUTTON ld a, "▼" Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box push bc @@ -512,33 +442,26 @@ TextCommand06:: pop hl jp NextTextCommand -; scroll text up one line -; 07 -; (no arguments) -TextCommand07:: +TextCommand_SCROLL:: +; pushes text up two lines and sets the BC cursor to the border tile +; below the first character column of the text box. ld a, " " Coorda 18, 16 ; place blank space in lower right corner of dialogue text box call ScrollTextUpOneLine call ScrollTextUpOneLine pop hl - coord bc, 1, 16 ; address of second line of dialogue text box + coord bc, 1, 16 ; second line of dialogue text box jp NextTextCommand -; execute asm inline -; 08{code} -TextCommand08:: +TextCommand_START_ASM:: +; run assembly code pop hl ld de, NextTextCommand - push de ; return address + push de jp hl -; print decimal number (converted from binary number) -; 09AAAABB -; AAAA = address of number -; BB -; bits 0-3 = how many digits to display -; bits 4-7 = how long the number is in bytes -TextCommand09:: +TextCommand_NUM:: +; print a number pop hl ld a, [hli] ld e, a @@ -554,7 +477,7 @@ TextCommand09:: ld a, b and $f0 swap a - set BIT_LEFT_ALIGN,a + set BIT_LEFT_ALIGN, a ld b, a call PrintNumber ld b, h @@ -562,45 +485,42 @@ TextCommand09:: pop hl jp NextTextCommand -; wait half a second if the user doesn't hold A or B -; 0A -; (no arguments) -TextCommand0A:: +TextCommand_PAUSE:: +; wait for button press or 30 frames push bc call Joypad ld a, [hJoyHeld] and A_BUTTON | B_BUTTON - jr nz, .skipDelay - ld c, 30 + jr nz, .done + ld c, 30 ; half a second call DelayFrames -.skipDelay +.done pop bc pop hl jp NextTextCommand -; plays sounds -; this actually handles various command ID's, not just 0B -; (no arguments) -TextCommand0B:: +TextCommand_SOUND:: +; play a sound effect from TextCommandSounds pop hl push bc dec hl ld a, [hli] - ld b, a ; b = command number that got us here + ld b, a ; b = text command number that got us here push hl ld hl, TextCommandSounds .loop ld a, [hli] cp b - jr z, .matchFound + jr z, .play inc hl jr .loop -.matchFound - cp $14 + +.play + cp TX_SOUND_CRY_NIDORINA jr z, .pokemonCry - cp $15 + cp TX_SOUND_CRY_PIDGEOT jr z, .pokemonCry - cp $16 + cp TX_SOUND_CRY_DEWGONG jr z, .pokemonCry ld a, [hl] call PlaySound @@ -608,6 +528,7 @@ TextCommand0B:: pop hl pop bc jp NextTextCommand + .pokemonCry push de ld a, [hl] @@ -617,29 +538,27 @@ TextCommand0B:: pop bc jp NextTextCommand -; format: text command ID, sound ID or cry ID TextCommandSounds:: - db $0B, SFX_GET_ITEM_1 ; actually plays SFX_LEVEL_UP when the battle music engine is loaded - db $12, SFX_CAUGHT_MON - db $0E, SFX_POKEDEX_RATING ; unused? - db $0F, SFX_GET_ITEM_1 ; unused? - db $10, SFX_GET_ITEM_2 - db $11, SFX_GET_KEY_ITEM - db $13, SFX_DEX_PAGE_ADDED - db $14, NIDORINA ; used in OakSpeech - db $15, PIDGEOT ; used in SaffronCityText12 - db $16, DEWGONG ; unused? - -; draw ellipses -; 0CAA -; AA = number of ellipses to draw -TextCommand0C:: + db TX_SOUND_GET_ITEM_1, SFX_GET_ITEM_1 ; actually plays SFX_LEVEL_UP when the battle music engine is loaded + db TX_SOUND_CAUGHT_MON, SFX_CAUGHT_MON + db TX_SOUND_POKEDEX_RATING, SFX_POKEDEX_RATING ; unused + db TX_SOUND_GET_ITEM_1_DUPLICATE, SFX_GET_ITEM_1 ; unused + db TX_SOUND_GET_ITEM_2, SFX_GET_ITEM_2 + db TX_SOUND_GET_KEY_ITEM, SFX_GET_KEY_ITEM + db TX_SOUND_DEX_PAGE_ADDED, SFX_DEX_PAGE_ADDED + db TX_SOUND_CRY_NIDORINA, NIDORINA ; used in OakSpeech + db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12 + db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused + +TextCommand_DOTS:: +; wait for button press or 30 frames while printing "…"s pop hl ld a, [hli] ld d, a push hl ld h, b ld l, c + .loop ld a, "…" ld [hli], a @@ -648,64 +567,66 @@ TextCommand0C:: pop de ld a, [hJoyHeld] ; joypad state and A_BUTTON | B_BUTTON - jr nz, .skipDelay ; if so, skip the delay + jr nz, .next ; if so, skip the delay ld c, 10 call DelayFrames -.skipDelay +.next dec d jr nz, .loop + ld b, h ld c, l pop hl jp NextTextCommand -; wait for A or B to be pressed -; 0D -; (no arguments) -TextCommand0D:: +TextCommand_LINK_PROMPT_BUTTON:: +; wait for button press; display arrow push bc - call ManualTextScroll ; wait for A or B to be pressed + call ManualTextScroll pop bc pop hl jp NextTextCommand -; process text commands in another ROM bank -; 17AAAABB -; AAAA = address of text commands -; BB = bank -TextCommand17:: +TextCommand_FAR:: +; write text from a different bank (little endian) pop hl ld a, [hLoadedROMBank] push af + ld a, [hli] ld e, a ld a, [hli] ld d, a ld a, [hli] + ld [hLoadedROMBank], a ld [MBC1RomBank], a + push hl ld l, e ld h, d call TextCommandProcessor pop hl + pop af ld [hLoadedROMBank], a ld [MBC1RomBank], a jp NextTextCommand TextCommandJumpTable:: - dw TextCommand00 - dw TextCommand01 - dw TextCommand02 - dw TextCommand03 - dw TextCommand04 - dw TextCommand05 - dw TextCommand06 - dw TextCommand07 - dw TextCommand08 - dw TextCommand09 - dw TextCommand0A - dw TextCommand0B - dw TextCommand0C - dw TextCommand0D +; entries correspond to TX_* constants (see macros/scripts/text.asm) + dw TextCommand_START ; TX_START + dw TextCommand_RAM ; TX_RAM + dw TextCommand_BCD ; TX_BCD + dw TextCommand_MOVE ; TX_MOVE + dw TextCommand_BOX ; TX_BOX + dw TextCommand_LOW ; TX_LOW + dw TextCommand_PROMPT_BUTTON ; TX_PROMPT_BUTTON + dw TextCommand_SCROLL ; TX_SCROLL + dw TextCommand_START_ASM ; TX_START_ASM + dw TextCommand_NUM ; TX_NUM + dw TextCommand_PAUSE ; TX_PAUSE + dw TextCommand_SOUND ; TX_SOUND_GET_ITEM_1 (also handles other TX_SOUND_* commands) + dw TextCommand_DOTS ; TX_DOTS + dw TextCommand_LINK_PROMPT_BUTTON ; TX_LINK_PROMPT_BUTTON + ; greater TX_* constants are handled directly by NextTextCommand diff --git a/home/predef_text.asm b/home/text_script.asm index 059e23ab..2dd2dbde 100644 --- a/home/predef_text.asm +++ b/home/text_script.asm @@ -20,16 +20,13 @@ DisplayTextID:: ld d, $00 ld a, [hSpriteIndexOrTextID] ; text ID ld [wSpriteIndex], a - and a - jp z, DisplayStartMenu - cp TEXT_SAFARI_GAME_OVER - jp z, DisplaySafariGameOverText - cp TEXT_MON_FAINTED - jp z, DisplayPokemonFaintedText - cp TEXT_BLACKED_OUT - jp z, DisplayPlayerBlackedOutText - cp TEXT_REPEL_WORE_OFF - jp z, DisplayRepelWoreOffText + + dict TEXT_START_MENU, DisplayStartMenu + dict TEXT_SAFARI_GAME_OVER, DisplaySafariGameOverText + dict TEXT_MON_FAINTED, DisplayPokemonFaintedText + dict TEXT_BLACKED_OUT, DisplayPlayerBlackedOutText + dict TEXT_REPEL_WORE_OFF, DisplayRepelWoreOffText + ld a, [wNumSprites] ld e, a ld a, [hSpriteIndexOrTextID] ; sprite ID @@ -66,29 +63,26 @@ DisplayTextID:: ld h, [hl] ld l, a ; hl = address of the text ld a, [hl] ; a = first byte of text + ; check first byte of text for special cases - cp $fe ; Pokemart NPC - jp z, DisplayPokemartDialogue - cp $ff ; Pokemon Center NPC - jp z, DisplayPokemonCenterDialogue - cp $fc ; Item Storage PC - jp z, FuncTX_ItemStoragePC - cp $fd ; Bill's PC - jp z, FuncTX_BillsPC - cp $f9 ; Pokemon Center PC - jp z, FuncTX_PokemonCenterPC - cp $f5 ; Vending Machine - jr nz, .notVendingMachine - callba VendingMachineMenu ; jump banks to vending machine routine - jr AfterDisplayingTextID -.notVendingMachine - cp $f7 ; prize menu - jp z, FuncTX_GameCornerPrizeMenu - cp $f6 ; cable connection NPC in Pokemon Center - jr nz, .notSpecialCase - callab CableClubNPC + +dict2: MACRO + cp \1 + jr nz, .not\@ + \2 jr AfterDisplayingTextID -.notSpecialCase +.not\@ +ENDM + + dict TX_SCRIPT_MART, DisplayPokemartDialogue + dict TX_SCRIPT_POKECENTER_NURSE, DisplayPokemonCenterDialogue + dict TX_SCRIPT_PLAYERS_PC, TextScript_ItemStoragePC + dict TX_SCRIPT_BILLS_PC, TextScript_BillsPC + dict TX_SCRIPT_POKECENTER_PC, TextScript_PokemonCenterPC + dict2 TX_SCRIPT_VENDING_MACHINE, callba VendingMachineMenu + dict TX_SCRIPT_PRIZE_VENDOR, TextScript_GameCornerPrizeMenu + dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callab CableClubNPC + call PrintText_NoCreatingTextBox ; display the text ld a, [wDoNotWaitForButtonPressAfterDisplayingText] and a @@ -117,7 +111,7 @@ CloseTextDisplay:: xor a ld [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank ; loop to make sprites face the directions they originally faced before the dialogue - ld hl, wSpriteStateData2 + $19 + ld hl, wSprite01StateData2 + 9 ; should be wSprite01StateData1FacingDirection? ld c, $0f ld de, $10 .restoreSpriteFacingDirectionLoop @@ -164,8 +158,8 @@ DisplayPokemartDialogue:: jp AfterDisplayingTextID PokemartGreetingText:: - TX_FAR _PokemartGreetingText - db "@" + text_far _PokemartGreetingText + text_end LoadItemList:: ld a, 1 @@ -212,8 +206,8 @@ DisplayPokemonFaintedText:: jp AfterDisplayingTextID PokemonFaintedText:: - TX_FAR _PokemonFaintedText - db "@" + text_far _PokemonFaintedText + text_end DisplayPlayerBlackedOutText:: ld hl, PlayerBlackedOutText @@ -224,8 +218,8 @@ DisplayPlayerBlackedOutText:: jp HoldTextDisplayOpen PlayerBlackedOutText:: - TX_FAR _PlayerBlackedOutText - db "@" + text_far _PlayerBlackedOutText + text_end DisplayRepelWoreOffText:: ld hl, RepelWoreOffText @@ -233,5 +227,5 @@ DisplayRepelWoreOffText:: jp AfterDisplayingTextID RepelWoreOffText:: - TX_FAR _RepelWoreOffText - db "@" + text_far _RepelWoreOffText + text_end diff --git a/home/trainers.asm b/home/trainers.asm index 9c3519a2..22601db8 100644 --- a/home/trainers.asm +++ b/home/trainers.asm @@ -371,8 +371,8 @@ GetSavedEndBattleTextPointer:: ret TrainerEndBattleText:: - TX_FAR _TrainerNameText - TX_ASM + text_far _TrainerNameText + text_asm call GetSavedEndBattleTextPointer call TextCommandProcessor jp TextScriptEnd |