diff options
Diffstat (limited to 'home')
-rwxr-xr-x | home/items.asm | 94 | ||||
-rw-r--r-- | home/map.asm | 35 | ||||
-rw-r--r-- | home/names.asm | 226 | ||||
-rw-r--r-- | home/pokemon.asm | 6 | ||||
-rwxr-xr-x | home/tables.asm | 6 |
5 files changed, 266 insertions, 101 deletions
diff --git a/home/items.asm b/home/items.asm index 0edd72b..498edc6 100755 --- a/home/items.asm +++ b/home/items.asm @@ -40,7 +40,7 @@ GiveItem:: ; and copy the item's name to wcf4b.
; Return carry on success.
ld a, b
- ld [wce37], a
+ ld [wNamedObjectIndexBuffer], a
ld [wCurItem], a
ld a, c
ld [wItemQuantity], a
@@ -51,95 +51,3 @@ GiveItem:: call CopyStringToCD31
scf
ret
-
-if DEBUG
-SECTION "GetItemName", ROM0[$376F]
-else
-SECTION "GetItemName", ROM0[$3733]
-endc
-
-GetItemName:: ; 376F
-; given an item ID at [wce37], store the name of the item into a string
-; starting at wcd26
- push hl
- push bc
- ld a, [wce37]
- cp ITEM_HM01_RED
- jr nc, .machine
-
- ld [wcb5b], a
- ld a, ITEM_NAME
- ld [wNameCategory], a
- call GetName
- jr .finish
-
-.machine
- call GetMachineName
-.finish
- ld de, wcd26 ; pointer to where item name is stored in RAM
- pop bc
- pop hl
- ret
-
-if DEBUG
-SECTION "GetMachineName", ROM0[$378E]
-else
-SECTION "GetMachineName", ROM0[$3752]
-endc
-
-GetMachineName::
-; copies the name of the TM/HM in [wce37] to wcd26
- push hl
- push de
- push bc
- ld a, [wce37]
- push af
- cp ITEM_TM01_RED
- jr nc, .WriteTM
-; if HM, then write "HM" and add 5 to the item ID, so we can reuse the
-; TM printing code
- add 5
- ld [wce37], a
- ld hl, HiddenPrefix
- ld bc, 6
- jr .WriteMachinePrefix
-.WriteTM
- ld hl, TechnicalPrefix
- ld bc, 5
-.WriteMachinePrefix
- ld de, wcd26
- call CopyBytes
-; now get the machine number and convert it to text
- ld a, [wce37]
- sub ITEM_TM01_RED - 1
- ld b, "0"
-.FirstDigit
- sub 10
- jr c, .SecondDigit
- inc b
- jr .FirstDigit
-.SecondDigit
- add 10
- push af
- ld a, b
- ld [de], a
- inc de
- pop af
- ld b, "0"
- add b
- ld [de], a
- inc de
- ld a, "@"
- ld [de], a
- pop af
- ld [wce37], a
- pop bc
- pop de
- pop hl
- ret
-
-TechnicalPrefix:
- db "わざマシン@"
-
-HiddenPrefix:
- db "ひでんマシン@"
diff --git a/home/map.asm b/home/map.asm new file mode 100644 index 0000000..8ec34be --- /dev/null +++ b/home/map.asm @@ -0,0 +1,35 @@ +INCLUDE "constants.asm" + +SECTION "Map functions", ROM0[$20FF] + +; Runs a map script indexed by wMapScriptNumber +RunMapScript:: ; 20ff + push hl + push de + push bc + ld a, [wMapScriptNumber] + add a, a + add a, a + ld d, 0 + ld e, a + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ld de, .return + push de + jp hl + +.return + pop bc + pop de + pop hl + ret + +SECTION "ClearMapBuffer", ROM0[$2123] +ClearMapBuffer:: ; 00:2123 + ld hl, wMapBuffer + ld bc, wMapBufferEnd - wMapBuffer + ld a, 0 + call ByteFill + ret diff --git a/home/names.asm b/home/names.asm index 7ce5767..f0ee433 100644 --- a/home/names.asm +++ b/home/names.asm @@ -1,11 +1,80 @@ INCLUDE "constants.asm" if DEBUG -SECTION "GetNthString", ROM0[$3732] +SECTION "Names", ROM0[$36c8] else -SECTION "GetNthString", ROM0[$36F6] +SECTION "Names", ROM0[$368c] ; Unsure endc +NamesPointers:: ; 00:36c8 +; 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, 0 ; DUMMY_NAME + dba ItemNames ; ITEM_NAME + dbw $00, wPartyMonOT ; PARTY_OT_NAME + dbw $00, wOTPartyMonOT ; ENEMY_OT_NAME + dba TrainerClassNames ; TRAINER_NAME + dbw $04, $5677 ; MOVE_DESC_NAME_BROKEN (wrong bank..?) + +GetName:: ; 00:36e0 +; Return name wCurSpecies from name list wNamedObjectTypeBuffer in wStringBuffer1. + + ldh a, [hROMBank] + push af + push hl + push bc + push de + + ld a, [wNamedObjectTypeBuffer] + cp MON_NAME + jr nz, .not_mon_name + + ld a, [wCurSpecies] + ld [wNamedObjectIndexBuffer], a + call GetPokemonName + ld hl, MON_NAME_LENGTH + add hl, de + ld e, l + ld d, h + jr .done + +.not_mon_name + ld a, [wNamedObjectTypeBuffer] + dec a + ld e, a + ld d, 0 + ld hl, NamesPointers + add hl, de + add hl, de + add hl, de + ld a, [hli] + call Bankswitch + ld a, [hli] + ld h, [hl] + ld l, a + + ld a, [wCurSpecies] + dec a + call GetNthString + + ld de, wStringBuffer1 + ld bc, ITEM_NAME_LENGTH + call CopyBytes + +.done + ld a, e + ld [wcd72], a + ld a, d + ld [wcd72 + 1], a + + pop de + pop bc + pop hl + pop af + call Bankswitch + ret + GetNthString:: ; Return the address of the ath string starting from hl. and a @@ -21,3 +90,156 @@ GetNthString:: jr nz, .readChar pop bc ret + +GetPokemonName: ; 00:3741 +; Get Pokemon name wNamedObjectIndexBuffer. + + ldh a, [hROMBank] + push af + push hl + ld a, BANK(PokemonNames) + call Bankswitch + + ; Each name is five characters + ld a, [wNamedObjectIndexBuffer] + dec a + ld hl, PokemonNames + ld e, a + ld d, 0 +rept 5 + add hl, de +endr + + ; Terminator + ld de, wStringBuffer1 + push de + ld bc, MON_NAME_LENGTH - 1 + call CopyBytes + ld hl, wStringBuffer1 + MON_NAME_LENGTH - 1 + ld [hl], "@" + pop de + pop hl + pop af + call Bankswitch + ret + +GetItemName:: ; 376F +; given an item ID at [wNamedObjectIndexBuffer], store the name of the item into a string +; starting at wStringBuffer1 + push hl + push bc + ld a, [wNamedObjectIndexBuffer] + cp ITEM_HM01_RED + jr nc, .machine + + ld [wCurSpecies], a + ld a, ITEM_NAME + ld [wNamedObjectTypeBuffer], a + call GetName + jr .finish + +.machine + call GetMachineName +.finish + ld de, wStringBuffer1 + pop bc + pop hl + ret + +GetMachineName:: +; copies the name of the TM/HM in [wNamedObjectIndexBuffer] to wStringBuffer1 + push hl + push de + push bc + ld a, [wNamedObjectIndexBuffer] + push af + cp ITEM_TM01_RED + jr nc, .write_tm +; if HM, then write "HM" and add 5 to the item ID, so we can reuse the +; TM printing code + add 5 + ld [wNamedObjectIndexBuffer], a + + ld hl, .HMText + ld bc, .HMTextEnd - .HMText + jr .write_machine_prefix + +.write_tm + ld hl, .TMText + ld bc, .TMTextEnd - .TMText + +.write_machine_prefix + ld de, wStringBuffer1 + call CopyBytes +; now get the machine number and convert it to text + ld a, [wNamedObjectIndexBuffer] + sub ITEM_TM01_RED - 1 + ld b, "0" +.first_digit + sub 10 + jr c, .second_digit + inc b + jr .first_digit +.second_digit + add 10 + push af + ld a, b + ld [de], a + inc de + pop af + ld b, "0" + add b + ld [de], a + inc de + ld a, "@" + ld [de], a + pop af + ld [wNamedObjectIndexBuffer], a + pop bc + pop de + pop hl + ret + +.TMText: + db "わざマシン" +.TMTextEnd: + db "@" + +.HMText: + db "ひでんマシン" +.HMTextEnd: + db "@" + +IsHM:: ; 00:37e4 + cp ITEM_TM01 ; ??? + jr c, .false + cp ITEM_TM05 ; ??? + ret + +.false + and a + ret + +IsHMMove:: ; 00:37ed + ld hl, .HMMoves + ld de, 1 + jp FindItemInTable + +.HMMoves: + db MOVE_CUT + db MOVE_FLY + db MOVE_SURF + db MOVE_STRENGTH + db MOVE_FLASH + db -1 + +Unreferenced_GetMoveName:: ; 00:37fc + push hl + ld a, MOVE_NAME + ld [wNamedObjectTypeBuffer], a + ld a, [wNamedObjectIndexBuffer] + ld [wCurSpecies], a + call GetName + ld de, wStringBuffer1 + pop hl + ret diff --git a/home/pokemon.asm b/home/pokemon.asm index bb1bcc5..d2add97 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -8,7 +8,7 @@ endc GetMonHeader:: ; 3a4b (0:3a4b) ; copies the base stat data of a pokemon to wMonHeader ; INPUT: -; [wcb5b] = pokemon ID in dex order +; [wCurSpecies] = pokemon ID in dex order push bc push de push hl @@ -16,7 +16,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) push af ld a, BANK(MonBaseStats) call Bankswitch - ld a, [wcb5b] + ld a, [wCurSpecies] cp DEX_FD jr z, .egg dec a @@ -38,7 +38,7 @@ GetMonHeader:: ; 3a4b (0:3a4b) ld [hl], d jr .done .done - ld a, [wcb5b] + ld a, [wCurSpecies] ld [wMonHIndex], a pop af call Bankswitch diff --git a/home/tables.asm b/home/tables.asm index dc9cebe..5c35a4f 100755 --- a/home/tables.asm +++ b/home/tables.asm @@ -7,7 +7,7 @@ SECTION "FindItemInTable", ROM0[$35F8] FindItemInTable: ; 00:35F8
ld b, 0
ld c, a
-
+
.loop
ld a, [hl]
cp -1
@@ -17,11 +17,11 @@ FindItemInTable: ; 00:35F8 inc b
add hl, de
jr .loop
-
+
.fail
and a
ret
-
+
.success
scf
ret
|