summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--constants/pokemon_data_constants.asm6
-rw-r--r--constants/text_constants.asm15
-rwxr-xr-xhome/items.asm94
-rw-r--r--home/names.asm227
-rw-r--r--home/overworld.asm34
-rw-r--r--home/pokemon.asm6
-rwxr-xr-xhome/tables.asm6
-rw-r--r--shim.sym6
-rw-r--r--wram.asm31
9 files changed, 291 insertions, 134 deletions
diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm
index 65be31a..0b00f47 100644
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -104,9 +104,9 @@ MONS_PER_BOX EQU 20
NUM_BOXES EQU 14
; hall of fame
-HOF_MON_LENGTH = 1 + 2 + 2 + 1 + (MON_NAME_LENGTH + -1) ; species, id, dvs, level, nick
-HOF_LENGTH = 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator
-NUM_HOF_TEAMS = 30
+HOF_MON_LENGTH EQUS "(wHallOfFamePokemonListMon1End - wHallOfFamePokemonListMon1)"
+HOF_LENGTH EQUS "(wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1)"
+NUM_HOF_TEAMS EQU 30
; evolution types (used in data/pokemon/evos_attacks.asm)
diff --git a/constants/text_constants.asm b/constants/text_constants.asm
index b026e91..f899ea3 100644
--- a/constants/text_constants.asm
+++ b/constants/text_constants.asm
@@ -1,12 +1,11 @@
; name lengths
-NAME_LENGTH EQU 11
-PLAYER_NAME_LENGTH EQU 8
-BOX_NAME_LENGTH EQU 9
-MON_NAME_LENGTH EQU 11
-MOVE_NAME_LENGTH EQU 13
-ITEM_NAME_LENGTH EQU 13
-TRAINER_CLASS_NAME_LENGTH EQU 13
-NAME_LENGTH_JAPANESE EQU 6
+NAME_LENGTH EQU 11 ; English
+PLAYER_NAME_LENGTH EQU 8 ; English
+BOX_NAME_LENGTH EQU 9 ; English
+MON_NAME_LENGTH EQU 6
+MOVE_NAME_LENGTH EQU 13 ; English
+ITEM_NAME_LENGTH EQU 11
+TRAINER_CLASS_NAME_LENGTH EQU 13 ; English
; GetName types (see home/names.asm)
const_def 1
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/names.asm b/home/names.asm
index 7ce5767..901d13a 100644
--- a/home/names.asm
+++ b/home/names.asm
@@ -1,11 +1,81 @@
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 +91,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/overworld.asm b/home/overworld.asm
index 4b10b72..56e4e90 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -1,5 +1,39 @@
INCLUDE "constants.asm"
+SECTION "RunMapScript", ROM0[$20ff]
+RunMapScript:: ; 00:20ff
+ push hl
+ push de
+ push bc
+ ld a, [wMapScriptNumber]
+ add a
+ add 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
+
+
if DEBUG
SECTION "Startmenu and Select Button Check", ROM0[$2C05]
else
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
diff --git a/shim.sym b/shim.sym
index ac185f2..f704139 100644
--- a/shim.sym
+++ b/shim.sym
@@ -18,7 +18,6 @@
00:1F9E ClearWindowData
00:1FCC ClearWindowData.bytefill
-00:20ff RunMapScript
00:23dc LoadWildMons
00:23e5 FadeIn ; This is not OverworldFadeIn, but I don't know what it is
00:2C05 StartMenuCheck
@@ -29,8 +28,6 @@
00:363E GetSGBLayout
00:3648 SetHPPal
00:3655 SetHPPal.done
-00:36C8 NamesPointers
-00:36E0 GetName
00:39BA PlayCry
00:3D86 WaitSFX
00:3D87 WaitSFX.wait
@@ -205,7 +202,6 @@
3F:6750 PicTestMenu
3F:6755 PicTestMenu.loop
-00:C5E8 wMapScriptNumber
00:CBF2 wWindowData
00:CBF2 wWindowStackPointer
00:CC02 wMenuDataHeader
@@ -222,4 +218,4 @@
01:d656 wMapGroup
01:d657 wMapId
01:D7D2 wPartyMonOT
-01:DA3B wUnk_DA3B
+01:DA3B wOTPartyMonOT
diff --git a/wram.asm b/wram.asm
index 8042d4d..0dd872f 100644
--- a/wram.asm
+++ b/wram.asm
@@ -96,18 +96,12 @@ ENDU
SECTION "Unknown map buffer?", WRAM0[$C5E8]
-; TODO: this is probably not related to the map script. Figure out what it actually is
-wUnknownIdC5E8:: ; c5e8
- db
-
-wUnknownIdC5E8Location::
- dw ; c5e9 ; TODO
-
-wUnknownMapPointer::
- dw ; c5eb ; TODO
-
+wMapBuffer::
+wMapScriptNumber:: db ; c5e8
+wUnknownIdC5E8Location:: dw ; c5e9
+wUnknownMapPointer:: dw ; c5eb
ds 19 ; TODO
-wUnknownMapBufferEnd:: ; c600
+wMapBufferEnd:: ; c600
UNION
@@ -207,9 +201,9 @@ wRedrawFlashlightWidthHeight:: db ; cb20
; in units of two tiles (people event meta tile)
ENDU
-SECTION "CB56", WRAM0[$CB5B]
-wcb5b:: ds 1 ; multipurpose, also wName, wMonDexIndex2
-wNameCategory:: ds 1
+SECTION "CB5B", WRAM0[$CB5B]
+wCurSpecies:: db ; cb5b
+wNamedObjectTypeBuffer:: db ; cb5c
SECTION "CB62", WRAM0[$CB62]
@@ -311,8 +305,7 @@ wcccf:: db
SECTION "CD26", WRAM0[$CD26]
-wcd26:: ; cd26
- db
+wStringBuffer1:: ds 1 ; How long is this? ; cd26
SECTION "CD31", WRAM0[$CD31]
@@ -347,7 +340,10 @@ wPredefBC:: ; cd54
wFarCallBCBuffer:: ; cd54
dw
-SECTION "CD76", WRAM0[$CD76]
+SECTION "CD72", WRAM0[$CD72]
+wcd72:: dw ; cd72
+
+ ds 2 ; TODO
wCurItem:: db ; cd76
wItemIndex:: db ;cd77
@@ -450,6 +446,7 @@ wMonHLearnset:: ; ce1e
SECTION "CE37", WRAM0[$CE37]
+wNamedObjectIndexBuffer::
wce37:: ; ce37
db