mirror of
https://github.com/thornAvery/kep-hack.git
synced 2026-02-22 07:02:17 +13:00
Move more code from home.asm to home/
This commit is contained in:
parent
6ef36800b0
commit
053afc4634
19 changed files with 2836 additions and 2854 deletions
141
home/names.asm
Normal file
141
home/names.asm
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
GetMonName::
|
||||
push hl
|
||||
ld a, [hLoadedROMBank]
|
||||
push af
|
||||
ld a, BANK(MonsterNames)
|
||||
ld [hLoadedROMBank], a
|
||||
ld [MBC1RomBank], a
|
||||
ld a, [wd11e]
|
||||
dec a
|
||||
ld hl, MonsterNames
|
||||
ld c, 10
|
||||
ld b, 0
|
||||
call AddNTimes
|
||||
ld de, wcd6d
|
||||
push de
|
||||
ld bc, 10
|
||||
call CopyData
|
||||
ld hl, wcd6d + 10
|
||||
ld [hl], "@"
|
||||
pop de
|
||||
pop af
|
||||
ld [hLoadedROMBank], a
|
||||
ld [MBC1RomBank], a
|
||||
pop hl
|
||||
ret
|
||||
|
||||
GetItemName::
|
||||
; given an item ID at [wd11e], store the name of the item into a string
|
||||
; starting at wcd6d
|
||||
push hl
|
||||
push bc
|
||||
ld a, [wd11e]
|
||||
cp HM_01 ; is this a TM/HM?
|
||||
jr nc, .Machine
|
||||
|
||||
ld [wd0b5], a
|
||||
ld a, ITEM_NAME
|
||||
ld [wNameListType], a
|
||||
ld a, BANK(ItemNames)
|
||||
ld [wPredefBank], a
|
||||
call GetName
|
||||
jr .Finish
|
||||
|
||||
.Machine
|
||||
call GetMachineName
|
||||
.Finish
|
||||
ld de, wcd6d ; pointer to where item name is stored in RAM
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
|
||||
GetMachineName::
|
||||
; copies the name of the TM/HM in [wd11e] to wcd6d
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
ld a, [wd11e]
|
||||
push af
|
||||
cp TM_01 ; is this a TM? [not HM]
|
||||
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 [wd11e], a
|
||||
ld hl, HiddenPrefix ; points to "HM"
|
||||
ld bc, 2
|
||||
jr .WriteMachinePrefix
|
||||
.WriteTM
|
||||
ld hl, TechnicalPrefix ; points to "TM"
|
||||
ld bc, 2
|
||||
.WriteMachinePrefix
|
||||
ld de, wcd6d
|
||||
call CopyData
|
||||
|
||||
; now get the machine number and convert it to text
|
||||
ld a, [wd11e]
|
||||
sub TM_01 - 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 [wd11e], a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
ret
|
||||
|
||||
TechnicalPrefix::
|
||||
db "TM"
|
||||
HiddenPrefix::
|
||||
db "HM"
|
||||
|
||||
; sets carry if item is HM, clears carry if item is not HM
|
||||
; Input: a = item ID
|
||||
IsItemHM::
|
||||
cp HM_01
|
||||
jr c, .notHM
|
||||
cp TM_01
|
||||
ret
|
||||
.notHM
|
||||
and a
|
||||
ret
|
||||
|
||||
; sets carry if move is an HM, clears carry if move is not an HM
|
||||
; Input: a = move ID
|
||||
IsMoveHM::
|
||||
ld hl, HMMoves
|
||||
ld de, 1
|
||||
jp IsInArray
|
||||
|
||||
HMMoves::
|
||||
INCLUDE "data/moves/hm_moves.asm"
|
||||
|
||||
GetMoveName::
|
||||
push hl
|
||||
ld a, MOVE_NAME
|
||||
ld [wNameListType], a
|
||||
ld a, [wd11e]
|
||||
ld [wd0b5], a
|
||||
ld a, BANK(MoveNames)
|
||||
ld [wPredefBank], a
|
||||
call GetName
|
||||
ld de, wcd6d ; pointer to where move name is stored in RAM
|
||||
pop hl
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue