diff options
Diffstat (limited to 'home')
-rw-r--r-- | home/compare.asm | 35 | ||||
-rw-r--r-- | home/joypad.asm | 6 | ||||
-rw-r--r-- | home/map.asm | 2 | ||||
-rw-r--r-- | home/names.asm | 24 | ||||
-rw-r--r-- | home/predef.asm | 2 | ||||
-rw-r--r-- | home/print_level.asm | 4 | ||||
-rw-r--r-- | home/queue_script.asm | 12 | ||||
-rw-r--r-- | home/text.asm | 150 |
8 files changed, 144 insertions, 91 deletions
diff --git a/home/compare.asm b/home/compare.asm new file mode 100644 index 000000000..26b7567fd --- /dev/null +++ b/home/compare.asm @@ -0,0 +1,35 @@ +CompareBytes:: +; Compare c bytes at de and hl. +; Return z if they all match. +.loop + ld a, [de] + cp [hl] + ret nz + inc de + inc hl + dec c + jr nz, .loop + ret + +CompareBytesLong:: +; Compare bc bytes at de and hl. +; Return carry if they all match. +.loop + ld a, [de] + cp [hl] + jr nz, .diff + + inc de + inc hl + dec bc + + ld a, b + or c + jr nz, .loop + + scf + ret + +.diff: + and a + ret diff --git a/home/joypad.asm b/home/joypad.asm index 87fc60d7e..392be760b 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -213,7 +213,7 @@ GetJoypad:: ld a, l ld [wAutoInputAddress], a ld a, h - ld [wAutoInputAddress+1], a + ld [wAutoInputAddress + 1], a jr .finishauto .stopauto @@ -235,7 +235,7 @@ StartAutoInput:: ld a, l ld [wAutoInputAddress], a ld a, h - ld [wAutoInputAddress+1], a + ld [wAutoInputAddress + 1], a ; Start reading the stream immediately. xor a ld [wAutoInputLength], a @@ -254,7 +254,7 @@ StopAutoInput:: xor a ld [wAutoInputBank], a ld [wAutoInputAddress], a - ld [wAutoInputAddress+1], a + ld [wAutoInputAddress + 1], a ld [wAutoInputLength], a ; Back to normal input. ld [wInputType], a diff --git a/home/map.asm b/home/map.asm index 550486081..a38b791fb 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1176,7 +1176,7 @@ ScrollMapUp:: ld l, a ld a, [wBGMapAnchor + 1] ld h, a - ld bc, $0200 + ld bc, BG_MAP_WIDTH tiles add hl, bc ; cap d at HIGH(vBGMap0) ld a, h diff --git a/home/names.asm b/home/names.asm index e9c36fc1d..63043863d 100644 --- a/home/names.asm +++ b/home/names.asm @@ -2,10 +2,10 @@ NamesPointers:: ; entries correspond to GetName constants (see constants/text_constants.asm) dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName) dba MoveNames ; MOVE_NAME - dbw 0, NULL ; DUMMY_NAME + dba NULL ; DUMMY_NAME dba ItemNames ; ITEM_NAME - dbw 0, wPartyMonOT ; PARTY_OT_NAME - dbw 0, wOTPartyMonOT ; ENEMY_OT_NAME + dbw 0, wPartyMonOT ; PARTY_OT_NAME + dbw 0, wOTPartyMonOT ; ENEMY_OT_NAME dba TrainerClassNames ; TRAINER_NAME dbw 4, MoveDescriptions ; MOVE_DESC_NAME_BROKEN (wrong bank) @@ -23,7 +23,7 @@ GetName:: jr nz, .NotPokeName ld a, [wCurSpecies] - ld [wd265], a + ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, MON_NAME_LENGTH add hl, de @@ -110,7 +110,7 @@ GetBasePokemonName:: ret GetPokemonName:: -; Get Pokemon name wd265. +; Get Pokemon name for wNamedObjectIndexBuffer. ld a, [hROMBank] push af @@ -119,7 +119,7 @@ GetPokemonName:: rst Bankswitch ; Each name is ten characters - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] dec a ld d, 0 ld e, a @@ -147,11 +147,11 @@ GetPokemonName:: ret GetItemName:: -; Get item name wd265. +; Get item name for wNamedObjectIndexBuffer. push hl push bc - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] cp TM01 jr nc, .TM @@ -170,12 +170,12 @@ GetItemName:: ret GetTMHMName:: -; Get TM/HM name by item id wd265. +; Get TM/HM name for item wNamedObjectIndexBuffer. push hl push de push bc - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] push af ; TM/HM prefix @@ -197,7 +197,7 @@ GetTMHMName:: ; TM/HM number push de - ld a, [wd265] + ld a, [wNamedObjectIndexBuffer] ld c, a callfar GetTMHMNumber pop de @@ -235,7 +235,7 @@ GetTMHMName:: ld [de], a pop af - ld [wd265], a + ld [wNamedObjectIndexBuffer], a pop bc pop de pop hl diff --git a/home/predef.asm b/home/predef.asm index e829bdc00..bfb5e4690 100644 --- a/home/predef.asm +++ b/home/predef.asm @@ -39,7 +39,7 @@ Predef:: ld a, h ld [wPredefTemp], a ld a, l - ld [wPredefTemp+1], a + ld [wPredefTemp + 1], a pop hl ld a, h diff --git a/home/print_level.asm b/home/print_level.asm index 2ebbbf980..d10b8f8a1 100644 --- a/home/print_level.asm +++ b/home/print_level.asm @@ -22,7 +22,7 @@ PrintLevel_Force3Digits:: ld c, 3 Print8BitNumRightAlign:: - ld [wd265], a - ld de, wd265 + ld [wDeciramBuffer], a + ld de, wDeciramBuffer ld b, PRINTNUM_RIGHTALIGN | 1 jp PrintNum diff --git a/home/queue_script.asm b/home/queue_script.asm new file mode 100644 index 000000000..40a971dc9 --- /dev/null +++ b/home/queue_script.asm @@ -0,0 +1,12 @@ +QueueScript:: +; Push pointer hl in the current bank to wQueuedScriptBank. + ld a, [hROMBank] + +FarQueueScript:: +; Push pointer a:hl to wQueuedScriptBank. + ld [wQueuedScriptBank], a + ld a, l + ld [wQueuedScriptAddr], a + ld a, h + ld [wQueuedScriptAddr + 1], a + ret diff --git a/home/text.asm b/home/text.asm index d74af02af..ef952942d 100644 --- a/home/text.asm +++ b/home/text.asm @@ -178,26 +178,30 @@ NextChar:: CheckDict:: dict: MACRO -if \1 == 0 +if \1 == "<NULL>" and a else cp \1 endc - jp z, \2 -ENDM -dict2: MACRO - cp \1 +if STRSUB("\2", 1, 1) == "\"" +; Replace a character with another one jr nz, ._\@ ld a, \2 ._\@: +elif STRSUB("\2", 1, 1) == "." +; Locals can use a short jump + jr z, \2 +else + jp z, \2 +endc ENDM - dict TX_DAY, DayOfWeekChar + dict "<MOBILE>", MobileScriptChar dict "<LINE>", LineChar dict "<NEXT>", NextLineChar - dict TX_FAR, TextFar - dict TX_START, NullChar + dict "<CR>", CarriageReturnChar + dict "<NULL>", NullChar dict "<SCROLL>", _ContTextNoPause dict "<_CONT>", _ContText dict "<PARA>", Paragraph @@ -215,7 +219,7 @@ ENDM dict "<TM>", TMChar dict "<TRAINER>", TrainerChar dict "<KOUGEKI>", PlaceKougeki - dict "<LNBRK>", LineBreakChar + dict "<LF>", LineFeedChar dict "<CONT>", ContText dict "<……>", SixDotsChar dict "<DONE>", DoneText @@ -223,17 +227,14 @@ ENDM dict "<PKMN>", PlacePKMN dict "<POKE>", PlacePOKE dict "%", NextChar - dict2 "¯", " " + dict "¯", " " dict "<DEXEND>", PlaceDexEnd dict "<TARGET>", PlaceMoveTargetsName dict "<USER>", PlaceMoveUsersName dict "<ENEMY>", PlaceEnemysName dict "<PLAY_G>", PlaceGenderedPlayerName - - cp "゚" - jr z, .place ; should be .diacritic - cp "゙" - jr z, .place ; should be .diacritic + dict "゚", .place ; should be .diacritic + dict "゙", .place ; should be .diacritic jr .not_diacritic .diacritic @@ -276,10 +277,10 @@ ENDM call PrintLetterDelay jp NextChar -DayOfWeekChar:: +MobileScriptChar:: ld c, l ld b, h - farcall Function17f036 + farcall RunMobileScript jp PlaceNextChar print_name: MACRO @@ -409,14 +410,14 @@ NextLineChar:: push hl jp NextChar -LineBreakChar:: +LineFeedChar:: pop hl ld bc, SCREEN_WIDTH add hl, bc push hl jp NextChar -TextFar:: +CarriageReturnChar:: pop hl push de ld bc, -wTileMap + $10000 @@ -681,32 +682,32 @@ DoTextUntilTerminator:: TextCommands:: ; entries correspond to TX_* constants (see macros/scripts/text.asm) - dw Text_TX ; TX_START - dw Text_TX_RAM ; TX_RAM - dw Text_TX_BCD ; TX_BCD - dw Text_TX_MOVE ; TX_MOVE - dw Text_TX_BOX ; TX_BOX - dw Text_TX_LOW ; TX_LOW - dw Text_WAIT_BUTTON ; WAIT_BUTTON - dw Text_TX_SCROLL ; TX_SCROLL - dw Text_START_ASM ; START_ASM - dw Text_TX_NUM ; TX_NUM - dw Text_TX_EXIT ; TX_EXIT - dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_50_79 - dw Text_TX_DOTS ; TX_DOTS - dw Text_LINK_WAIT_BUTTON ; TX_LINK_WAIT_BUTTON - dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_20_49 - dw Text_PlaySound ; TX_SOUND_ITEM - dw Text_PlaySound ; TX_SOUND_CAUGHT_MON - dw Text_PlaySound ; TX_SOUND_DEX_FANFARE_80_109 - dw Text_PlaySound ; TX_SOUND_FANFARE - dw Text_PlaySound ; TX_SOUND_SLOT_MACHINE_START - dw Text_TX_STRINGBUFFER ; TX_STRINGBUFFER - dw Text_TX_DAY ; TX_DAY - dw Text_TX_FAR ; TX_FAR - -Text_TX:: -; TX + 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_WAIT_BUTTON ; TX_WAIT_BUTTON + dw TextCommand_SCROLL ; TX_SCROLL + dw TextCommand_START_ASM ; TX_START_ASM + dw TextCommand_NUM ; TX_NUM + dw TextCommand_EXIT ; TX_EXIT + dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_50_79 + dw TextCommand_DOTS ; TX_DOTS + dw TextCommand_LINK_WAIT_BUTTON ; TX_LINK_WAIT_BUTTON + dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_20_49 + dw TextCommand_SOUND ; TX_SOUND_ITEM + dw TextCommand_SOUND ; TX_SOUND_CAUGHT_MON + dw TextCommand_SOUND ; TX_SOUND_DEX_FANFARE_80_109 + dw TextCommand_SOUND ; TX_SOUND_FANFARE + dw TextCommand_SOUND ; TX_SOUND_SLOT_MACHINE_START + dw TextCommand_STRINGBUFFER ; TX_STRINGBUFFER + dw TextCommand_DAY ; TX_DAY + dw TextCommand_FAR ; TX_FAR + +TextCommand_START:: +; text_start ; write text until "@" ; [$00]["...@"] @@ -720,7 +721,7 @@ Text_TX:: inc hl ret -Text_TX_RAM:: +TextCommand_RAM:: ; text_from_ram ; write text from a ram address ; little endian @@ -737,7 +738,7 @@ Text_TX_RAM:: pop hl ret -Text_TX_FAR:: +TextCommand_FAR:: ; text_jump ; write text from a different bank ; little endian @@ -766,8 +767,8 @@ Text_TX_FAR:: ld [MBC3RomBank], a ret -Text_TX_BCD:: -; TX_BCD +TextCommand_BCD:: +; text_bcd ; write bcd from address, typically ram ; [$02][addr][flags] ; flags: see PrintBCDNumber @@ -787,8 +788,8 @@ Text_TX_BCD:: pop hl ret -Text_TX_MOVE:: -; TX_MOVE +TextCommand_MOVE:: +; text_move ; move to a new tile ; [$03][addr] @@ -800,8 +801,8 @@ Text_TX_MOVE:: ld b, a ret -Text_TX_BOX:: -; TX_BOX +TextCommand_BOX:: +; text_box ; draw a box ; little endian ; [$04][addr][height][width] @@ -821,25 +822,25 @@ Text_TX_BOX:: pop hl ret -Text_TX_LOW:: -; TX_LOW +TextCommand_LOW:: +; text_low ; write text at (1,16) ; [$05] bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ret -Text_WAIT_BUTTON:: -; TX_WAITBUTTON +TextCommand_WAIT_BUTTON:: +; text_waitbutton ; wait for button press ; show arrow ; [06] ld a, [wLinkMode] cp LINK_COLOSSEUM - jp z, Text_LINK_WAIT_BUTTON + jp z, TextCommand_LINK_WAIT_BUTTON cp LINK_MOBILE - jp z, Text_LINK_WAIT_BUTTON + jp z, TextCommand_LINK_WAIT_BUTTON push hl call LoadBlinkingCursor @@ -850,7 +851,8 @@ Text_WAIT_BUTTON:: pop hl ret -Text_TX_SCROLL:: +TextCommand_SCROLL:: +; text_scroll ; pushes text up two lines and sets the BC cursor to the border tile ; below the first character column of the text box. push hl @@ -861,8 +863,8 @@ Text_TX_SCROLL:: bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ret -Text_START_ASM:: -; TX_ASM +TextCommand_START_ASM:: +; start_asm bit 7, h jr nz, .not_rom @@ -873,8 +875,8 @@ Text_START_ASM:: ld [hl], a ret -Text_TX_NUM:: -; TX_NUM +TextCommand_NUM:: +; deciram ; [$09][addr][hi:bytes lo:digits] ld a, [hli] ld e, a @@ -898,7 +900,8 @@ Text_TX_NUM:: pop hl ret -Text_TX_EXIT:: +TextCommand_EXIT:: +; interpret_data push hl push bc call GetJoypad @@ -912,7 +915,7 @@ Text_TX_EXIT:: pop hl ret -Text_PlaySound:: +TextCommand_SOUND:: ; chars: ; $0b, $0e, $0f, $10, $11, $12, $13 ; see TextSFX @@ -948,7 +951,7 @@ Text_PlaySound:: ret Unreferenced_Function1522:: -; TX_CRY +; play_cry push de ld e, [hl] inc hl @@ -969,7 +972,8 @@ TextSFX:: dbw TX_SOUND_SLOT_MACHINE_START, SFX_SLOT_MACHINE_START db -1 -Text_TX_DOTS:: +TextCommand_DOTS:: +; limited_interpret_data ; [$0C][num] ld a, [hli] ld d, a @@ -997,7 +1001,8 @@ Text_TX_DOTS:: pop hl ret -Text_LINK_WAIT_BUTTON:: +TextCommand_LINK_WAIT_BUTTON:: +; link_wait_button ; wait for key down ; display arrow push hl @@ -1007,7 +1012,8 @@ Text_LINK_WAIT_BUTTON:: pop hl ret -Text_TX_STRINGBUFFER:: +TextCommand_STRINGBUFFER:: +; text_buffer ; Print a string from one of the following: ; 0: wStringBuffer3 ; 1: wStringBuffer4 @@ -1035,8 +1041,8 @@ Text_TX_STRINGBUFFER:: pop hl ret -Text_TX_DAY:: -; TX_DAY +TextCommand_DAY:: +; current_day call GetWeekday push hl |