2013-11-28 23:30:08 -08:00
|
|
|
INCLUDE "includes.asm"
|
|
|
|
|
2013-12-19 22:06:01 -08:00
|
|
|
SECTION "NULL", ROM0[0]
|
2014-02-01 17:26:39 -08:00
|
|
|
NULL::
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
INCLUDE "rst.asm"
|
|
|
|
INCLUDE "interrupts.asm"
|
|
|
|
|
|
|
|
SECTION "Header", ROM0[$100]
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Start::
|
2013-11-28 23:30:08 -08:00
|
|
|
nop
|
|
|
|
jp _Start
|
|
|
|
|
|
|
|
SECTION "Home", ROM0[$150]
|
|
|
|
|
|
|
|
INCLUDE "home/init.asm"
|
|
|
|
INCLUDE "home/vblank.asm"
|
|
|
|
INCLUDE "home/delay.asm"
|
|
|
|
INCLUDE "home/rtc.asm"
|
|
|
|
INCLUDE "home/fade.asm"
|
|
|
|
INCLUDE "home/lcd.asm"
|
|
|
|
INCLUDE "home/time.asm"
|
|
|
|
INCLUDE "home/serial.asm"
|
|
|
|
INCLUDE "home/joypad.asm"
|
|
|
|
INCLUDE "home/decompress.asm"
|
|
|
|
INCLUDE "home/palettes.asm"
|
|
|
|
INCLUDE "home/copy.asm"
|
|
|
|
INCLUDE "home/text.asm"
|
|
|
|
INCLUDE "home/video.asm"
|
|
|
|
INCLUDE "home/map_objects.asm"
|
|
|
|
INCLUDE "home/sine.asm"
|
|
|
|
INCLUDE "home/movement.asm"
|
|
|
|
INCLUDE "home/tilemap.asm"
|
|
|
|
INCLUDE "home/menu.asm"
|
|
|
|
INCLUDE "home/handshake.asm"
|
|
|
|
INCLUDE "home/game_time.asm"
|
|
|
|
INCLUDE "home/map.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function2d43:: ; 2d43
|
2013-11-28 23:30:08 -08:00
|
|
|
; Inexplicably empty.
|
|
|
|
; Seen in PredefPointers.
|
|
|
|
rept 16
|
|
|
|
nop
|
|
|
|
endr
|
|
|
|
ret
|
|
|
|
; 2d54
|
|
|
|
|
|
|
|
INCLUDE "home/farcall.asm"
|
|
|
|
INCLUDE "home/predef.asm"
|
|
|
|
INCLUDE "home/window.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function2e4e:: ; 2e4e
|
2014-05-21 13:21:46 -07:00
|
|
|
; Unreferenced.
|
2013-11-28 23:30:08 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 2e50
|
|
|
|
|
|
|
|
INCLUDE "home/flag.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function2ebb:: ; 2ebb
|
2015-12-26 15:11:55 -08:00
|
|
|
; unreferenced
|
|
|
|
ld a, [wMonStatusFlags]
|
2013-11-28 23:30:08 -08:00
|
|
|
bit 1, a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hJoyDown]
|
2015-12-26 15:11:55 -08:00
|
|
|
bit B_BUTTON_F, a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 2ec6
|
|
|
|
|
2015-10-11 09:15:03 -07:00
|
|
|
xor_a:: ; 2ec6
|
2013-11-28 23:30:08 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 2ec8
|
|
|
|
|
2015-10-11 09:15:03 -07:00
|
|
|
xor_a_dec_a:: ; 2ec8
|
2013-11-28 23:30:08 -08:00
|
|
|
xor a
|
|
|
|
dec a
|
|
|
|
ret
|
|
|
|
; 2ecb
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function2ecb:: ; 2ecb
|
2015-12-26 15:11:55 -08:00
|
|
|
; unreferenced
|
2013-11-28 23:30:08 -08:00
|
|
|
push hl
|
2015-12-26 15:11:55 -08:00
|
|
|
ld hl, wMonStatusFlags
|
2013-11-28 23:30:08 -08:00
|
|
|
bit 1, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 2ed3
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
DisableSpriteUpdates:: ; 0x2ed3
|
2013-11-28 23:30:08 -08:00
|
|
|
; disables overworld sprite updating?
|
|
|
|
xor a
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [VramState]
|
|
|
|
res 0, a
|
|
|
|
ld [VramState], a
|
|
|
|
ld a, $0
|
2015-11-25 07:16:29 -08:00
|
|
|
ld [wSpriteUpdatesEnabled], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 0x2ee4
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
EnableSpriteUpdates:: ; 2ee4
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, $1
|
2015-11-25 07:16:29 -08:00
|
|
|
ld [wSpriteUpdatesEnabled], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [VramState]
|
|
|
|
set 0, a
|
|
|
|
ld [VramState], a
|
|
|
|
ld a, $1
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 2ef6
|
|
|
|
|
|
|
|
INCLUDE "home/string.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
IsInJohto:: ; 2f17
|
2013-11-28 23:30:08 -08:00
|
|
|
; Return 0 if the player is in Johto, and 1 in Kanto.
|
|
|
|
|
|
|
|
ld a, [MapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [MapNumber]
|
|
|
|
ld c, a
|
|
|
|
call GetWorldMapLocation
|
|
|
|
|
|
|
|
cp FAST_SHIP
|
|
|
|
jr z, .Johto
|
|
|
|
|
|
|
|
cp SPECIAL_MAP
|
|
|
|
jr nz, .CheckRegion
|
|
|
|
|
|
|
|
ld a, [BackupMapGroup]
|
|
|
|
ld b, a
|
|
|
|
ld a, [BackupMapNumber]
|
|
|
|
ld c, a
|
|
|
|
call GetWorldMapLocation
|
|
|
|
|
|
|
|
.CheckRegion
|
|
|
|
cp KANTO_LANDMARK
|
|
|
|
jr nc, .Kanto
|
|
|
|
|
|
|
|
.Johto
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Kanto
|
|
|
|
ld a, 1
|
|
|
|
ret
|
|
|
|
; 2f3e
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
ret_2f3e:: ; 2f3e
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 2f3f
|
|
|
|
|
|
|
|
INCLUDE "home/item.asm"
|
|
|
|
INCLUDE "home/random.asm"
|
|
|
|
INCLUDE "home/sram.asm"
|
|
|
|
|
|
|
|
; Register aliases
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
_hl_:: ; 2fec
|
2013-11-28 23:30:08 -08:00
|
|
|
jp [hl]
|
|
|
|
; 2fed
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
_de_:: ; 2fed
|
2013-11-28 23:30:08 -08:00
|
|
|
push de
|
|
|
|
ret
|
|
|
|
; 2fef
|
|
|
|
|
|
|
|
INCLUDE "home/double_speed.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
ClearSprites:: ; 300b
|
2013-11-28 23:30:08 -08:00
|
|
|
; Erase OAM data
|
|
|
|
ld hl, Sprites
|
|
|
|
ld b, SpritesEnd - Sprites
|
|
|
|
xor a
|
|
|
|
.loop
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 3016
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
HideSprites:: ; 3016
|
2013-11-28 23:30:08 -08:00
|
|
|
; Set all OAM y-positions to 160 to hide them offscreen
|
|
|
|
ld hl, Sprites
|
|
|
|
ld de, 4 ; length of an OAM struct
|
|
|
|
ld b, (SpritesEnd - Sprites) / 4 ; number of OAM structs
|
|
|
|
ld a, 160 ; y
|
|
|
|
.loop
|
|
|
|
ld [hl], a
|
|
|
|
add hl, de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 3026
|
|
|
|
|
|
|
|
INCLUDE "home/copy2.asm"
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
LoadTileMapToTempTileMap:: ; 309d
|
|
|
|
; Load TileMap into TempTileMap
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2015-11-07 06:48:32 -08:00
|
|
|
ld a, BANK(TempTileMap)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rSVBK], a
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0
|
2015-11-07 06:48:32 -08:00
|
|
|
decoord 0, 0, TempTileMap
|
2014-05-21 13:21:46 -07:00
|
|
|
ld bc, TileMapEnd - TileMap
|
2013-11-28 23:30:08 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 30b4
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
Call_LoadTempTileMapToTileMap:: ; 30b4
|
2013-11-28 23:30:08 -08:00
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTempTileMapToTileMap
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
; 30bf
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
LoadTempTileMapToTileMap:: ; 30bf
|
|
|
|
; Load TempTileMap into TileMap
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2015-11-07 06:48:32 -08:00
|
|
|
ld a, BANK(TempTileMap)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rSVBK], a
|
2015-11-07 06:48:32 -08:00
|
|
|
hlcoord 0, 0, TempTileMap
|
2015-07-22 12:57:02 -07:00
|
|
|
decoord 0, 0
|
2014-05-21 13:21:46 -07:00
|
|
|
ld bc, TileMapEnd - TileMap
|
2013-11-28 23:30:08 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 30d6
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CopyName1:: ; 30d6
|
2015-07-25 11:25:37 -07:00
|
|
|
; Copies the name from de to StringBuffer2
|
2013-11-28 23:30:08 -08:00
|
|
|
ld hl, StringBuffer2
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CopyName2:: ; 30d9
|
2015-07-25 11:25:37 -07:00
|
|
|
; Copies the name from de to hl
|
2013-11-28 23:30:08 -08:00
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
cp "@"
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 30e1
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
IsInArray:: ; 30e1
|
2013-11-28 23:30:08 -08:00
|
|
|
; Find value a for every de bytes in array hl.
|
|
|
|
; Return index in b and carry if found.
|
|
|
|
|
|
|
|
ld b, 0
|
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
2015-07-22 12:57:02 -07:00
|
|
|
cp -1
|
2013-11-28 23:30:08 -08:00
|
|
|
jr z, .NotInArray
|
|
|
|
cp c
|
|
|
|
jr z, .InArray
|
|
|
|
inc b
|
|
|
|
add hl, de
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.NotInArray
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.InArray
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 30f4
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
SkipNames:: ; 0x30f4
|
2014-05-21 13:21:46 -07:00
|
|
|
; Skip a names.
|
|
|
|
ld bc, NAME_LENGTH
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
.loop
|
|
|
|
add hl, bc
|
|
|
|
dec a
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
; 0x30fe
|
|
|
|
|
|
|
|
INCLUDE "home/math.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PrintLetterDelay:: ; 313d
|
2013-11-28 23:30:08 -08:00
|
|
|
; Wait before printing the next letter.
|
|
|
|
|
|
|
|
; The text speed setting in Options is actually a frame count:
|
|
|
|
; fast: 1 frame
|
|
|
|
; mid: 3 frames
|
|
|
|
; slow: 5 frames
|
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
; TextBoxFlags[!0] and A or B override text speed with a one-frame delay.
|
|
|
|
; Options[4] and TextBoxFlags[!1] disable the delay.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld a, [Options]
|
2013-12-18 15:04:55 -08:00
|
|
|
bit NO_TEXT_SCROLL, a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
; non-scrolling text?
|
2015-11-28 12:13:40 -08:00
|
|
|
ld a, [TextBoxFlags]
|
2013-11-28 23:30:08 -08:00
|
|
|
bit 1, a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
ld hl, hOAMUpdate
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
|
|
|
|
; orginally turned oam update off...
|
|
|
|
; ld a, 1
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
; force fast scroll?
|
2015-11-28 12:13:40 -08:00
|
|
|
ld a, [TextBoxFlags]
|
2013-11-28 23:30:08 -08:00
|
|
|
bit 0, a
|
|
|
|
jr z, .fast
|
|
|
|
|
|
|
|
; text speed
|
|
|
|
ld a, [Options]
|
|
|
|
and %111
|
|
|
|
jr .updatedelay
|
|
|
|
|
|
|
|
.fast
|
|
|
|
ld a, 1
|
|
|
|
|
|
|
|
.updatedelay
|
|
|
|
ld [TextDelayFrames], a
|
|
|
|
|
|
|
|
.checkjoypad
|
2013-12-22 14:30:35 -08:00
|
|
|
call GetJoypad
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
; input override
|
2015-02-10 15:14:41 -08:00
|
|
|
ld a, [wc2d7]
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
jr nz, .wait
|
|
|
|
|
|
|
|
; Wait one frame if holding A or B.
|
|
|
|
ld a, [hJoyDown]
|
|
|
|
bit 0, a ; A_BUTTON
|
|
|
|
jr z, .checkb
|
|
|
|
jr .delay
|
|
|
|
.checkb
|
|
|
|
bit 1, a ; B_BUTTON
|
|
|
|
jr z, .wait
|
|
|
|
|
|
|
|
.delay
|
|
|
|
call DelayFrame
|
|
|
|
jr .end
|
|
|
|
|
|
|
|
.wait
|
|
|
|
ld a, [TextDelayFrames]
|
|
|
|
and a
|
|
|
|
jr nz, .checkjoypad
|
|
|
|
|
|
|
|
.end
|
|
|
|
pop af
|
|
|
|
ld [hOAMUpdate], a
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 318c
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CopyDataUntil:: ; 318c
|
2014-05-21 13:21:46 -07:00
|
|
|
; Copy [hl .. bc) to de.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
; In other words, the source data is
|
|
|
|
; from hl up to but not including bc,
|
|
|
|
; and the destination is de.
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, h
|
|
|
|
cp b
|
|
|
|
jr nz, CopyDataUntil
|
|
|
|
ld a, l
|
|
|
|
cp c
|
|
|
|
jr nz, CopyDataUntil
|
|
|
|
ret
|
|
|
|
; 0x3198
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PrintNum:: ; 3198
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, BANK(_PrintNum)
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
call _PrintNum
|
|
|
|
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 31a4
|
|
|
|
|
2015-11-05 11:06:03 -08:00
|
|
|
MobilePrintNum:: ; 31a4
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
2015-11-05 11:06:03 -08:00
|
|
|
ld a, BANK(_MobilePrintNum)
|
2013-11-28 23:30:08 -08:00
|
|
|
rst Bankswitch
|
|
|
|
|
2015-11-05 11:06:03 -08:00
|
|
|
call _MobilePrintNum
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 31b0
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
FarPrintText:: ; 31b0
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [hBuffer], a
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, [hBuffer]
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
call PrintText
|
|
|
|
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 31be
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CallPointerAt:: ; 31be
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, [hli]
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
|
|
|
call _hl_
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
ld a, h
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 31cd
|
|
|
|
|
2015-11-01 09:44:30 -08:00
|
|
|
QueueScript:: ; 31cd
|
|
|
|
; Push pointer hl in the current bank to wQueuedScriptBank.
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
|
2015-11-01 09:44:30 -08:00
|
|
|
FarQueueScript:: ; 31cf
|
|
|
|
; Push pointer a:hl to wQueuedScriptBank.
|
|
|
|
ld [wQueuedScriptBank], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, l
|
2015-11-01 09:44:30 -08:00
|
|
|
ld [wQueuedScriptAddr], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, h
|
2015-11-01 09:44:30 -08:00
|
|
|
ld [wQueuedScriptAddr + 1], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 31db
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
StringCmp:: ; 31db
|
2013-11-28 23:30:08 -08:00
|
|
|
; Compare c bytes at de and hl.
|
|
|
|
; Return z if they all match.
|
2015-07-16 15:10:10 -07:00
|
|
|
.loop
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
|
|
|
ret nz
|
|
|
|
inc de
|
|
|
|
inc hl
|
|
|
|
dec c
|
2015-07-16 15:10:10 -07:00
|
|
|
jr nz, .loop
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 0x31e4
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CompareLong:: ; 31e4
|
2013-11-28 23:30:08 -08:00
|
|
|
; Compare bc bytes at de and hl.
|
|
|
|
; Return carry if they all match.
|
|
|
|
|
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .Diff
|
|
|
|
|
|
|
|
inc de
|
|
|
|
inc hl
|
|
|
|
dec bc
|
|
|
|
|
|
|
|
ld a, b
|
|
|
|
or c
|
|
|
|
jr nz, CompareLong
|
|
|
|
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Diff
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 31f3
|
|
|
|
|
2015-11-11 20:38:57 -08:00
|
|
|
ClearBGPalettes:: ; 31f3
|
2013-11-28 23:30:08 -08:00
|
|
|
call ClearPalettes
|
2014-02-01 17:26:39 -08:00
|
|
|
WaitBGMap:: ; 31f6
|
2013-11-28 23:30:08 -08:00
|
|
|
; Tell VBlank to update BG Map
|
|
|
|
ld a, 1 ; BG Map 0 tiles
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
; Wait for it to do its magic
|
|
|
|
ld c, 4
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
; 3200
|
|
|
|
|
2015-12-11 13:59:40 -08:00
|
|
|
WaitBGMap2:: ; 0x3200
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
2014-05-21 13:21:46 -07:00
|
|
|
jr z, .bg0
|
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, 2
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, 4
|
|
|
|
call DelayFrames
|
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.bg0
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, 4
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
; 0x3218
|
|
|
|
|
2015-11-11 11:12:46 -08:00
|
|
|
IsCGB:: ; 3218
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 321c
|
|
|
|
|
2015-11-25 07:16:29 -08:00
|
|
|
ApplyTilemap:: ; 321c
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
2014-05-21 13:21:46 -07:00
|
|
|
jr z, .dmg
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-25 07:16:29 -08:00
|
|
|
ld a, [wSpriteUpdatesEnabled]
|
2013-11-28 23:30:08 -08:00
|
|
|
cp 0
|
2014-05-21 13:21:46 -07:00
|
|
|
jr z, .dmg
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld a, 1
|
|
|
|
ld [hBGMapMode], a
|
2015-11-20 08:47:52 -08:00
|
|
|
jr LoadEDTile
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.dmg
|
2015-11-11 11:12:46 -08:00
|
|
|
; WaitBGMap
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, 4
|
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
; 3238
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
CGBOnly_LoadEDTile:: ; 3238
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
|
|
|
jr z, WaitBGMap
|
|
|
|
|
2015-11-20 08:47:52 -08:00
|
|
|
LoadEDTile:: ; 323d
|
|
|
|
jr .LoadEDTile
|
2013-11-28 23:30:08 -08:00
|
|
|
; 323f
|
|
|
|
|
2016-01-27 09:25:12 -08:00
|
|
|
; XXX
|
2013-11-28 23:30:08 -08:00
|
|
|
callba Function104000
|
|
|
|
ret
|
|
|
|
; 3246
|
|
|
|
|
2015-11-20 08:47:52 -08:00
|
|
|
.LoadEDTile ; 3246
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hBGMapMode]
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2015-11-05 11:06:03 -08:00
|
|
|
ld a, [hMapAnims]
|
2013-11-28 23:30:08 -08:00
|
|
|
push af
|
|
|
|
xor a
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.wait
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [rLY]
|
|
|
|
cp $7f
|
2014-05-21 13:21:46 -07:00
|
|
|
jr c, .wait
|
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
di
|
2015-10-17 09:58:26 -07:00
|
|
|
ld a, 1 ; BANK(VTiles3)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rVBK], a
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0, AttrMap
|
2015-11-11 11:12:46 -08:00
|
|
|
call .StackPointerMagic
|
2015-10-17 09:58:26 -07:00
|
|
|
ld a, 0 ; BANK(VTiles0)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rVBK], a
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0
|
2015-11-11 11:12:46 -08:00
|
|
|
call .StackPointerMagic
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.wait2
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [rLY]
|
|
|
|
cp $7f
|
2014-05-21 13:21:46 -07:00
|
|
|
jr c, .wait2
|
2013-11-28 23:30:08 -08:00
|
|
|
ei
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
; 327b
|
|
|
|
|
2015-11-11 11:12:46 -08:00
|
|
|
.StackPointerMagic ; 327b
|
2015-10-24 07:34:19 -07:00
|
|
|
; Copy all tiles to VBGMap
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [hSPBuffer], sp
|
|
|
|
ld sp, hl
|
2015-10-17 09:58:26 -07:00
|
|
|
ld a, [hBGMapAddress + 1]
|
2013-11-28 23:30:08 -08:00
|
|
|
ld h, a
|
2014-09-30 11:19:33 -07:00
|
|
|
ld l, 0
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, SCREEN_HEIGHT
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hTilesPerCycle], a
|
2014-09-30 11:19:33 -07:00
|
|
|
ld b, 1 << 1 ; not in v/hblank
|
|
|
|
ld c, rSTAT % $100
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2014-05-21 13:21:46 -07:00
|
|
|
.loop
|
2015-10-24 07:34:19 -07:00
|
|
|
rept SCREEN_WIDTH / 2
|
2014-05-21 13:21:46 -07:00
|
|
|
pop de
|
2015-10-24 07:34:19 -07:00
|
|
|
; if in v/hblank, wait until not in v/hblank
|
2013-11-28 23:30:08 -08:00
|
|
|
.loop\@
|
|
|
|
ld a, [$ff00+c]
|
|
|
|
and b
|
|
|
|
jr nz, .loop\@
|
2015-10-24 07:34:19 -07:00
|
|
|
; load BGMap0
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [hl], e
|
|
|
|
inc l
|
|
|
|
ld [hl], d
|
|
|
|
inc l
|
|
|
|
endr
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
ld de, $20 - SCREEN_WIDTH
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
2015-11-05 11:06:03 -08:00
|
|
|
ld a, [hTilesPerCycle]
|
2013-11-28 23:30:08 -08:00
|
|
|
dec a
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hTilesPerCycle], a
|
2014-05-21 13:21:46 -07:00
|
|
|
jr nz, .loop
|
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hSPBuffer]
|
|
|
|
ld l, a
|
2014-05-21 13:21:46 -07:00
|
|
|
ld a, [hSPBuffer + 1]
|
2013-11-28 23:30:08 -08:00
|
|
|
ld h, a
|
|
|
|
ld sp, hl
|
|
|
|
ret
|
|
|
|
; 32f9
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
SetPalettes:: ; 32f9
|
|
|
|
; Inits the Palettes
|
|
|
|
; depending on the system the monochromes palettes or color palettes
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
2015-09-09 16:27:07 -07:00
|
|
|
jr nz, .SetPalettesForGameBoyColor
|
2016-01-27 09:25:12 -08:00
|
|
|
ld a, %11100100
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rBGP], a
|
2016-01-27 09:25:12 -08:00
|
|
|
ld a, %11010000
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rOBP0], a
|
|
|
|
ld [rOBP1], a
|
|
|
|
ret
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
.SetPalettesForGameBoyColor
|
2013-11-28 23:30:08 -08:00
|
|
|
push de
|
2016-01-27 09:25:12 -08:00
|
|
|
ld a, %11100100
|
2013-11-28 23:30:08 -08:00
|
|
|
call DmgToCgbBGPals
|
2016-01-27 09:25:12 -08:00
|
|
|
lb de, %11100100, %11100100
|
2013-11-28 23:30:08 -08:00
|
|
|
call DmgToCgbObjPals
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 3317
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
ClearPalettes:: ; 3317
|
2013-11-28 23:30:08 -08:00
|
|
|
; Make all palettes white
|
|
|
|
|
|
|
|
; CGB: make all the palette colors white
|
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
|
|
|
jr nz, .cgb
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
; DMG: just change palettes to 0 (white)
|
|
|
|
xor a
|
|
|
|
ld [rBGP], a
|
|
|
|
ld [rOBP0], a
|
|
|
|
ld [rOBP1], a
|
|
|
|
ret
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
.cgb
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
|
2015-07-25 11:25:37 -07:00
|
|
|
ld a, BANK(BGPals)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
; Fill BGPals and OBPals with $ffff (white)
|
|
|
|
ld hl, BGPals
|
2016-01-27 09:25:12 -08:00
|
|
|
ld bc, 16 palettes
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, $ff
|
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
|
|
|
|
; Request palette update
|
|
|
|
ld a, 1
|
|
|
|
ld [hCGBPalUpdate], a
|
|
|
|
ret
|
|
|
|
; 333e
|
|
|
|
|
2015-11-20 12:15:32 -08:00
|
|
|
GetMemSGBLayout:: ; 333e
|
|
|
|
ld b, SCGB_RAM
|
2014-02-01 17:26:39 -08:00
|
|
|
GetSGBLayout:: ; 3340
|
2013-11-28 23:30:08 -08:00
|
|
|
; load sgb packets unless dmg
|
|
|
|
|
|
|
|
ld a, [hCGB]
|
|
|
|
and a
|
2014-06-16 11:20:01 -07:00
|
|
|
jr nz, .sgb
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hSGB]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2014-06-16 11:20:01 -07:00
|
|
|
.sgb
|
2015-07-22 12:57:02 -07:00
|
|
|
predef_jump Predef_LoadSGBLayout ; LoadSGBLayout
|
2013-11-28 23:30:08 -08:00
|
|
|
; 334e
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
SetHPPal:: ; 334e
|
2013-11-28 23:30:08 -08:00
|
|
|
; Set palette for hp bar pixel length e at hl.
|
|
|
|
call GetHPPal
|
|
|
|
ld [hl], d
|
|
|
|
ret
|
|
|
|
; 3353
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetHPPal:: ; 3353
|
2013-11-28 23:30:08 -08:00
|
|
|
; Get palette for hp bar pixel length e in d.
|
|
|
|
|
2014-06-16 22:52:59 -07:00
|
|
|
ld d, HP_GREEN
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, e
|
|
|
|
cp 24
|
|
|
|
ret nc
|
|
|
|
inc d ; yellow
|
|
|
|
cp 10
|
|
|
|
ret nc
|
|
|
|
inc d ; red
|
|
|
|
ret
|
|
|
|
; 335f
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CountSetBits:: ; 0x335f
|
2013-11-28 23:30:08 -08:00
|
|
|
; Count the number of set bits in b bytes starting from hl.
|
2015-02-10 15:14:41 -08:00
|
|
|
; Return in a, c and [wd265].
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld c, 0
|
|
|
|
.next
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld d, 8
|
|
|
|
|
|
|
|
.count
|
|
|
|
srl e
|
|
|
|
ld a, 0
|
|
|
|
adc c
|
|
|
|
ld c, a
|
|
|
|
dec d
|
|
|
|
jr nz, .count
|
|
|
|
|
|
|
|
dec b
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
ld a, c
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd265], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 0x3376
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetWeekday:: ; 3376
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [CurDay]
|
|
|
|
.mod
|
|
|
|
sub 7
|
|
|
|
jr nc, .mod
|
|
|
|
add 7
|
|
|
|
ret
|
|
|
|
; 3380
|
|
|
|
|
|
|
|
INCLUDE "home/pokedex_flags.asm"
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
NamesPointers:: ; 33ab
|
2015-11-03 16:43:47 -08:00
|
|
|
dba PokemonNames
|
|
|
|
dba MoveNames
|
2013-11-28 23:30:08 -08:00
|
|
|
dbw 0, 0
|
2015-11-03 16:43:47 -08:00
|
|
|
dba ItemNames
|
2013-11-28 23:30:08 -08:00
|
|
|
dbw 0, PartyMonOT
|
|
|
|
dbw 0, OTPartyMonOT
|
2015-11-03 16:43:47 -08:00
|
|
|
dba TrainerClassNames
|
2015-07-20 00:51:52 -07:00
|
|
|
; 33c0
|
|
|
|
|
|
|
|
Function33c0:
|
|
|
|
inc b
|
|
|
|
ld d, d
|
|
|
|
ld c, e
|
2013-11-28 23:30:08 -08:00
|
|
|
; 33c3
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetName:: ; 33c3
|
2015-10-17 14:18:52 -07:00
|
|
|
; Return name CurSpecies from name list wNamedObjectTypeBuffer in StringBuffer1.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
|
2015-10-17 14:18:52 -07:00
|
|
|
ld a, [wNamedObjectTypeBuffer]
|
2014-09-30 11:19:33 -07:00
|
|
|
cp PKMN_NAME
|
2013-11-28 23:30:08 -08:00
|
|
|
jr nz, .NotPokeName
|
|
|
|
|
|
|
|
ld a, [CurSpecies]
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd265], a
|
2013-11-28 23:30:08 -08:00
|
|
|
call GetPokemonName
|
2014-09-30 11:19:33 -07:00
|
|
|
ld hl, PKMN_NAME_LENGTH
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.NotPokeName
|
2015-10-17 14:18:52 -07:00
|
|
|
ld a, [wNamedObjectTypeBuffer]
|
2013-11-28 23:30:08 -08:00
|
|
|
dec a
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, NamesPointers
|
2015-07-20 08:28:05 -07:00
|
|
|
rept 3
|
|
|
|
add hl, de
|
|
|
|
endr
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
rst Bankswitch
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
|
|
|
ld a, [CurSpecies]
|
|
|
|
dec a
|
|
|
|
call GetNthString
|
|
|
|
|
|
|
|
ld de, StringBuffer1
|
2015-07-16 15:10:10 -07:00
|
|
|
ld bc, ITEM_NAME_LENGTH
|
2013-11-28 23:30:08 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, e
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd102], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, d
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd103], a
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 3411
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetNthString:: ; 3411
|
2013-11-28 23:30:08 -08:00
|
|
|
; Return the address of the
|
|
|
|
; ath string starting from hl.
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push bc
|
|
|
|
ld b, a
|
|
|
|
ld c, "@"
|
|
|
|
.readChar
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr nz, .readChar
|
|
|
|
dec b
|
|
|
|
jr nz, .readChar
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3420
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetBasePokemonName:: ; 3420
|
2013-11-28 23:30:08 -08:00
|
|
|
; Discards gender (Nidoran).
|
|
|
|
|
|
|
|
push hl
|
|
|
|
call GetPokemonName
|
|
|
|
|
|
|
|
ld hl, StringBuffer1
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
cp "@"
|
|
|
|
jr z, .quit
|
|
|
|
cp "♂"
|
|
|
|
jr z, .end
|
|
|
|
cp "♀"
|
|
|
|
jr z, .end
|
|
|
|
inc hl
|
|
|
|
jr .loop
|
|
|
|
.end
|
|
|
|
ld [hl], "@"
|
|
|
|
.quit
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
; 343b
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetPokemonName:: ; 343b
|
2015-02-10 15:14:41 -08:00
|
|
|
; Get Pokemon name wd265.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld a, BANK(PokemonNames)
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
; Each name is ten characters
|
2015-02-10 15:14:41 -08:00
|
|
|
ld a, [wd265]
|
2013-11-28 23:30:08 -08:00
|
|
|
dec a
|
|
|
|
ld d, 0
|
|
|
|
ld e, a
|
|
|
|
ld h, 0
|
|
|
|
ld l, a
|
2015-09-09 16:27:07 -07:00
|
|
|
add hl, hl ; hl = hl * 4
|
2015-12-26 18:59:03 -08:00
|
|
|
add hl, hl ; hl = hl * 4
|
2015-09-09 16:27:07 -07:00
|
|
|
add hl, de ; hl = (hl*4) + de
|
|
|
|
add hl, hl ; hl = (5*hl) + (5*hl)
|
2013-11-28 23:30:08 -08:00
|
|
|
ld de, PokemonNames
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; Terminator
|
|
|
|
ld de, StringBuffer1
|
|
|
|
push de
|
|
|
|
ld bc, PKMN_NAME_LENGTH - 1
|
|
|
|
call CopyBytes
|
|
|
|
ld hl, StringBuffer1 + PKMN_NAME_LENGTH - 1
|
|
|
|
ld [hl], "@"
|
|
|
|
pop de
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 3468
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetItemName:: ; 3468
|
2015-02-10 15:14:41 -08:00
|
|
|
; Get item name wd265.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2015-02-10 15:14:41 -08:00
|
|
|
ld a, [wd265]
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-06-29 19:24:45 -07:00
|
|
|
cp TM01
|
2013-11-28 23:30:08 -08:00
|
|
|
jr nc, .TM
|
|
|
|
|
|
|
|
ld [CurSpecies], a
|
2014-09-30 11:19:33 -07:00
|
|
|
ld a, ITEM_NAME
|
2015-10-17 14:18:52 -07:00
|
|
|
ld [wNamedObjectTypeBuffer], a
|
2013-11-28 23:30:08 -08:00
|
|
|
call GetName
|
|
|
|
jr .Copied
|
|
|
|
.TM
|
|
|
|
call GetTMHMName
|
|
|
|
.Copied
|
|
|
|
ld de, StringBuffer1
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 3487
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetTMHMName:: ; 3487
|
2015-02-10 15:14:41 -08:00
|
|
|
; Get TM/HM name by item id wd265.
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2015-02-10 15:14:41 -08:00
|
|
|
ld a, [wd265]
|
2013-11-28 23:30:08 -08:00
|
|
|
push af
|
|
|
|
|
|
|
|
; TM/HM prefix
|
2015-06-29 19:24:45 -07:00
|
|
|
cp HM01
|
2013-11-28 23:30:08 -08:00
|
|
|
push af
|
|
|
|
jr c, .TM
|
|
|
|
|
|
|
|
ld hl, .HMText
|
|
|
|
ld bc, .HMTextEnd - .HMText
|
|
|
|
jr .asm_34a1
|
|
|
|
|
|
|
|
.TM
|
|
|
|
ld hl, .TMText
|
|
|
|
ld bc, .TMTextEnd - .TMText
|
|
|
|
|
|
|
|
.asm_34a1
|
|
|
|
ld de, StringBuffer1
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
; TM/HM number
|
|
|
|
push de
|
2015-02-10 15:14:41 -08:00
|
|
|
ld a, [wd265]
|
2013-11-28 23:30:08 -08:00
|
|
|
ld c, a
|
|
|
|
callab GetTMHMNumber
|
|
|
|
pop de
|
|
|
|
|
|
|
|
; HM numbers start from 51, not 1
|
|
|
|
pop af
|
|
|
|
ld a, c
|
|
|
|
jr c, .asm_34b9
|
|
|
|
sub NUM_TMS
|
2014-09-30 11:19:33 -07:00
|
|
|
.asm_34b9
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
; Divide and mod by 10 to get the top and bottom digits respectively
|
|
|
|
ld b, "0"
|
|
|
|
.mod10
|
|
|
|
sub 10
|
|
|
|
jr c, .asm_34c2
|
|
|
|
inc b
|
|
|
|
jr .mod10
|
|
|
|
.asm_34c2
|
|
|
|
add 10
|
|
|
|
|
|
|
|
push af
|
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
pop af
|
|
|
|
|
|
|
|
ld b, "0"
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
; End the string
|
|
|
|
inc de
|
|
|
|
ld a, "@"
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
pop af
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd265], a
|
2013-11-28 23:30:08 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
.TMText
|
|
|
|
db "TM"
|
|
|
|
.TMTextEnd
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
.HMText
|
|
|
|
db "HM"
|
|
|
|
.HMTextEnd
|
|
|
|
db "@"
|
|
|
|
; 34df
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
IsHM:: ; 34df
|
2015-06-29 19:24:45 -07:00
|
|
|
cp HM01
|
2013-11-28 23:30:08 -08:00
|
|
|
jr c, .NotHM
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
.NotHM
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 34e7
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
IsHMMove:: ; 34e7
|
2013-11-28 23:30:08 -08:00
|
|
|
ld hl, .HMMoves
|
|
|
|
ld de, 1
|
|
|
|
jp IsInArray
|
|
|
|
|
|
|
|
.HMMoves
|
|
|
|
db CUT
|
|
|
|
db FLY
|
|
|
|
db SURF
|
|
|
|
db STRENGTH
|
|
|
|
db FLASH
|
|
|
|
db WATERFALL
|
|
|
|
db WHIRLPOOL
|
2015-10-12 09:33:24 -07:00
|
|
|
db -1
|
2013-11-28 23:30:08 -08:00
|
|
|
; 34f8
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetMoveName:: ; 34f8
|
2013-11-28 23:30:08 -08:00
|
|
|
push hl
|
2014-09-30 11:19:33 -07:00
|
|
|
|
|
|
|
ld a, MOVE_NAME
|
2015-10-17 14:18:52 -07:00
|
|
|
ld [wNamedObjectTypeBuffer], a
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-10-12 09:33:24 -07:00
|
|
|
ld a, [wNamedObjectIndexBuffer] ; move id
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [CurSpecies], a
|
|
|
|
|
|
|
|
call GetName
|
|
|
|
ld de, StringBuffer1
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 350c
|
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
ScrollingMenu:: ; 350c
|
2015-11-10 13:53:37 -08:00
|
|
|
call CopyMenuData2
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
ld a, BANK(_ScrollingMenu)
|
2013-11-28 23:30:08 -08:00
|
|
|
rst Bankswitch
|
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
call _InitScrollingMenu
|
|
|
|
call .UpdatePalettes
|
|
|
|
call _ScrollingMenu
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuJoypad]
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 3524
|
|
|
|
|
2015-12-17 19:31:16 -08:00
|
|
|
.UpdatePalettes ; 3524
|
2013-11-28 23:30:08 -08:00
|
|
|
ld hl, VramState
|
|
|
|
bit 0, [hl]
|
|
|
|
jp nz, UpdateTimePals
|
2015-09-09 16:27:07 -07:00
|
|
|
jp SetPalettes
|
2013-11-28 23:30:08 -08:00
|
|
|
; 352f
|
|
|
|
|
2015-11-17 12:54:03 -08:00
|
|
|
InitScrollingMenu:: ; 352f
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderTopCoord]
|
2013-11-28 23:30:08 -08:00
|
|
|
dec a
|
|
|
|
ld b, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderBottomCoord]
|
2013-11-28 23:30:08 -08:00
|
|
|
sub b
|
|
|
|
ld d, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderLeftCoord]
|
2013-11-28 23:30:08 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wMenuBorderRightCoord]
|
2013-11-28 23:30:08 -08:00
|
|
|
sub c
|
|
|
|
ld e, a
|
|
|
|
push de
|
2015-11-10 13:53:37 -08:00
|
|
|
call Coord2Tile
|
2013-11-28 23:30:08 -08:00
|
|
|
pop bc
|
|
|
|
jp TextBox
|
|
|
|
; 354b
|
|
|
|
|
2015-11-17 12:54:03 -08:00
|
|
|
Function354b:: ; 354b joypad
|
2013-11-28 23:30:08 -08:00
|
|
|
call DelayFrame
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, [hInMenu]
|
2013-11-28 23:30:08 -08:00
|
|
|
push af
|
|
|
|
ld a, $1
|
2015-10-16 10:35:43 -07:00
|
|
|
ld [hInMenu], a
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyTextDelay
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
2015-10-16 10:35:43 -07:00
|
|
|
ld [hInMenu], a
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, [hJoyLast]
|
2014-09-30 11:19:33 -07:00
|
|
|
and D_RIGHT + D_LEFT + D_UP + D_DOWN
|
2013-11-28 23:30:08 -08:00
|
|
|
ld c, a
|
|
|
|
ld a, [hJoyPressed]
|
2014-09-30 11:19:33 -07:00
|
|
|
and A_BUTTON + B_BUTTON + SELECT + START
|
2013-11-28 23:30:08 -08:00
|
|
|
or c
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
; 3567
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
HandleStoneQueue:: ; 3567
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
call SwitchToMapScriptHeaderBank
|
2015-11-18 20:16:25 -08:00
|
|
|
call .WarpAction
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 3574
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.WarpAction ; 3574
|
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp $ff
|
2015-11-18 20:16:25 -08:00
|
|
|
jr z, .nope
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
ld l, a
|
|
|
|
push hl
|
2015-11-18 20:16:25 -08:00
|
|
|
call .IsPersonOnWarp
|
2013-11-28 23:30:08 -08:00
|
|
|
pop hl
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nc, .nope
|
2013-11-28 23:30:08 -08:00
|
|
|
ld d, a
|
|
|
|
ld e, l
|
2015-11-18 20:16:25 -08:00
|
|
|
call .IsObjectInStoneTable
|
|
|
|
jr nc, .nope
|
2015-11-05 12:08:00 -08:00
|
|
|
call CallMapScript
|
2015-07-15 12:48:44 -07:00
|
|
|
callba EnableScriptMode
|
2013-11-28 23:30:08 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.nope
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3599
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.IsPersonOnWarp ; 3599
|
2013-11-28 23:30:08 -08:00
|
|
|
push de
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-11-18 20:16:25 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld e, [hl]
|
2014-09-30 11:19:33 -07:00
|
|
|
|
|
|
|
sub 4
|
2013-11-28 23:30:08 -08:00
|
|
|
ld d, a
|
|
|
|
ld a, e
|
2014-09-30 11:19:33 -07:00
|
|
|
sub 4
|
2013-11-28 23:30:08 -08:00
|
|
|
ld e, a
|
2015-11-18 20:16:25 -08:00
|
|
|
call .check_on_warp
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 35b0
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.check_on_warp ; 35b0
|
|
|
|
ld hl, wCurrMapWarpHeaderPointer
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-18 20:16:25 -08:00
|
|
|
ld a, [wCurrMapWarpCount]
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
2015-11-18 20:16:25 -08:00
|
|
|
jr z, .nope2
|
2014-09-30 11:19:33 -07:00
|
|
|
|
|
|
|
.loop
|
2013-11-28 23:30:08 -08:00
|
|
|
push af
|
|
|
|
ld a, [hl]
|
|
|
|
cp e
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nz, .not_on_warp
|
2013-11-28 23:30:08 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp d
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nz, .not_on_warp
|
|
|
|
jr .found_warp
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.not_on_warp
|
|
|
|
ld a, 5
|
2013-11-28 23:30:08 -08:00
|
|
|
add l
|
|
|
|
ld l, a
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nc, .no_carry
|
2013-11-28 23:30:08 -08:00
|
|
|
inc h
|
2015-11-18 20:16:25 -08:00
|
|
|
.no_carry
|
2014-09-30 11:19:33 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
dec a
|
2014-09-30 11:19:33 -07:00
|
|
|
jr nz, .loop
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.nope2
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.found_warp
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
ld d, a
|
2015-11-18 20:16:25 -08:00
|
|
|
ld a, [wCurrMapWarpCount]
|
2013-11-28 23:30:08 -08:00
|
|
|
sub d
|
|
|
|
inc a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 35de
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.IsObjectInStoneTable ; 35de
|
2013-11-28 23:30:08 -08:00
|
|
|
inc e
|
2015-11-18 20:16:25 -08:00
|
|
|
ld hl, CMDQUEUE_ADDR
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-18 20:16:25 -08:00
|
|
|
.loop2
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
cp $ff
|
2015-11-18 20:16:25 -08:00
|
|
|
jr z, .nope3
|
2013-11-28 23:30:08 -08:00
|
|
|
cp d
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nz, .next_inc3
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
2015-11-18 20:16:25 -08:00
|
|
|
jr nz, .next_inc2
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2015-11-18 20:16:25 -08:00
|
|
|
jr .yes
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.next_inc3
|
2013-11-28 23:30:08 -08:00
|
|
|
inc hl
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.next_inc2
|
2013-11-28 23:30:08 -08:00
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
inc hl
|
2015-11-18 20:16:25 -08:00
|
|
|
jr .loop2
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.nope3
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-18 20:16:25 -08:00
|
|
|
.yes
|
2013-11-28 23:30:08 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3600
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CheckTrainerBattle2:: ; 3600
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
|
2015-07-16 15:10:10 -07:00
|
|
|
call SwitchToMapScriptHeaderBank
|
2013-11-28 23:30:08 -08:00
|
|
|
call CheckTrainerBattle
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
; 360d
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
CheckTrainerBattle:: ; 360d
|
2013-11-28 23:30:08 -08:00
|
|
|
; Check if any trainer on the map sees the player and wants to battle.
|
|
|
|
|
|
|
|
; Skip the player object.
|
|
|
|
ld a, 1
|
|
|
|
ld de, MapObjects + OBJECT_LENGTH
|
|
|
|
|
|
|
|
.loop
|
|
|
|
|
|
|
|
; Start a battle if the object:
|
|
|
|
|
|
|
|
push af
|
|
|
|
push de
|
|
|
|
|
|
|
|
; Has a sprite
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_SPRITE
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .next
|
|
|
|
|
|
|
|
; Is a trainer
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_COLOR
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and $f
|
|
|
|
cp $2
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
; Is visible on the map
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2015-07-18 20:45:39 -07:00
|
|
|
cp -1
|
2013-11-28 23:30:08 -08:00
|
|
|
jr z, .next
|
|
|
|
|
|
|
|
; Is facing the player...
|
2015-07-15 12:48:44 -07:00
|
|
|
call GetObjectStruct
|
2013-11-28 23:30:08 -08:00
|
|
|
call FacingPlayerDistance_bc
|
|
|
|
jr nc, .next
|
|
|
|
|
|
|
|
; ...within their sight range
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_RANGE
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
cp b
|
|
|
|
jr c, .next
|
|
|
|
|
|
|
|
; And hasn't already been beaten
|
|
|
|
push bc
|
|
|
|
push de
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
ld b, CHECK_FLAG
|
|
|
|
call EventFlagAction
|
|
|
|
ld a, c
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
and a
|
2015-07-18 20:45:39 -07:00
|
|
|
jr z, .startbattle
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
.next
|
|
|
|
pop de
|
|
|
|
ld hl, OBJECT_LENGTH
|
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
pop af
|
|
|
|
inc a
|
|
|
|
cp NUM_OBJECTS
|
|
|
|
jr nz, .loop
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
.startbattle
|
2013-11-28 23:30:08 -08:00
|
|
|
pop de
|
|
|
|
pop af
|
2015-07-21 23:49:18 -07:00
|
|
|
ld [hLastTalked], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, b
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [EngineBuffer2], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, c
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [EngineBuffer3], a
|
2015-11-15 11:59:38 -08:00
|
|
|
jr LoadTrainer_continue
|
2013-11-28 23:30:08 -08:00
|
|
|
; 3674
|
|
|
|
|
2015-11-15 11:59:38 -08:00
|
|
|
TalkToTrainer:: ; 3674
|
2015-07-18 20:45:39 -07:00
|
|
|
ld a, 1
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [EngineBuffer2], a
|
2015-07-18 20:45:39 -07:00
|
|
|
ld a, -1
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [EngineBuffer3], a
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-15 11:59:38 -08:00
|
|
|
LoadTrainer_continue:: ; 367e
|
2013-11-28 23:30:08 -08:00
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
ld [EngineBuffer1], a
|
2015-11-15 11:59:38 -08:00
|
|
|
|
2015-07-21 23:49:18 -07:00
|
|
|
ld a, [hLastTalked]
|
2013-11-28 23:30:08 -08:00
|
|
|
call GetMapObject
|
2015-11-15 11:59:38 -08:00
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [EngineBuffer1]
|
|
|
|
call GetFarHalfword
|
2015-11-15 11:59:38 -08:00
|
|
|
ld de, wTempTrainerHeader
|
|
|
|
ld bc, wTempTrainerHeaderEnd - wTempTrainerHeader
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [EngineBuffer1]
|
|
|
|
call FarCopyBytes
|
|
|
|
xor a
|
2015-11-25 07:16:29 -08:00
|
|
|
ld [wRunningTrainerBattleScript], a
|
2013-11-28 23:30:08 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 36a5
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
FacingPlayerDistance_bc:: ; 36a5
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
push de
|
|
|
|
call FacingPlayerDistance
|
|
|
|
ld b, d
|
|
|
|
ld c, e
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 36ad
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
FacingPlayerDistance:: ; 36ad
|
2013-11-28 23:30:08 -08:00
|
|
|
; Return carry if the sprite at bc is facing the player,
|
|
|
|
; and its distance in d.
|
|
|
|
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_X ; x
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
|
|
|
|
2015-11-14 11:41:47 -08:00
|
|
|
ld hl, OBJECT_NEXT_MAP_Y ; y
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld e, [hl]
|
|
|
|
|
2016-01-10 23:28:09 -08:00
|
|
|
ld a, [PlayerStandingMapX]
|
2013-11-28 23:30:08 -08:00
|
|
|
cp d
|
|
|
|
jr z, .CheckY
|
|
|
|
|
2016-01-10 23:28:09 -08:00
|
|
|
ld a, [PlayerStandingMapY]
|
2013-11-28 23:30:08 -08:00
|
|
|
cp e
|
|
|
|
jr z, .CheckX
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.CheckY
|
2016-01-10 23:28:09 -08:00
|
|
|
ld a, [PlayerStandingMapY]
|
2013-11-28 23:30:08 -08:00
|
|
|
sub e
|
|
|
|
jr z, .NotFacing
|
|
|
|
jr nc, .Above
|
|
|
|
|
|
|
|
; Below
|
|
|
|
cpl
|
|
|
|
inc a
|
|
|
|
ld d, a
|
2015-11-15 11:59:38 -08:00
|
|
|
ld e, OW_UP
|
2013-11-28 23:30:08 -08:00
|
|
|
jr .CheckFacing
|
|
|
|
|
|
|
|
.Above
|
|
|
|
ld d, a
|
2015-11-15 11:59:38 -08:00
|
|
|
ld e, OW_DOWN
|
2013-11-28 23:30:08 -08:00
|
|
|
jr .CheckFacing
|
|
|
|
|
|
|
|
.CheckX
|
2016-01-10 23:28:09 -08:00
|
|
|
ld a, [PlayerStandingMapX]
|
2013-11-28 23:30:08 -08:00
|
|
|
sub d
|
|
|
|
jr z, .NotFacing
|
|
|
|
jr nc, .Left
|
|
|
|
|
|
|
|
; Right
|
|
|
|
cpl
|
|
|
|
inc a
|
|
|
|
ld d, a
|
2015-11-15 11:59:38 -08:00
|
|
|
ld e, OW_LEFT
|
2013-11-28 23:30:08 -08:00
|
|
|
jr .CheckFacing
|
|
|
|
|
|
|
|
.Left
|
|
|
|
ld d, a
|
2015-11-15 11:59:38 -08:00
|
|
|
ld e, OW_RIGHT
|
2013-11-28 23:30:08 -08:00
|
|
|
|
|
|
|
.CheckFacing
|
|
|
|
call GetSpriteDirection
|
|
|
|
cp e
|
|
|
|
jr nz, .NotFacing
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.NotFacing
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 36f5
|
|
|
|
|
2015-07-18 20:45:39 -07:00
|
|
|
CheckTrainerFlag:: ; 36f5
|
2013-11-28 23:30:08 -08:00
|
|
|
push bc
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, OBJECT_MAP_OBJECT_INDEX
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
call GetMapObject
|
2015-07-18 20:45:39 -07:00
|
|
|
ld hl, MAPOBJECT_SCRIPT_POINTER
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call GetFarHalfword
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
push de
|
2015-07-18 20:45:39 -07:00
|
|
|
ld b, CHECK_FLAG
|
2013-11-28 23:30:08 -08:00
|
|
|
call EventFlagAction
|
|
|
|
pop de
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3718
|
|
|
|
|
2015-11-04 12:35:29 -08:00
|
|
|
PrintWinLossText:: ; 3718
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [BattleType]
|
2014-06-13 22:53:20 -07:00
|
|
|
cp BATTLETYPE_CANLOSE
|
2015-11-04 12:35:29 -08:00
|
|
|
jr .canlose ; ??????????
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-04 12:35:29 -08:00
|
|
|
; unreferenced
|
|
|
|
ld hl, wWinTextPointer
|
2015-07-18 12:46:38 -07:00
|
|
|
jr .ok
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-07-18 12:46:38 -07:00
|
|
|
.canlose
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2015-11-04 12:35:29 -08:00
|
|
|
ld hl, wWinTextPointer
|
2013-11-28 23:30:08 -08:00
|
|
|
and $f
|
2015-07-18 12:46:38 -07:00
|
|
|
jr z, .ok
|
2015-11-04 12:35:29 -08:00
|
|
|
ld hl, wLossTextPointer
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-07-18 12:46:38 -07:00
|
|
|
.ok
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
call GetMapScriptHeaderBank
|
|
|
|
call FarPrintText
|
|
|
|
call WaitBGMap
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
; 3741
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
IsAPokemon:: ; 3741
|
2013-11-28 23:30:08 -08:00
|
|
|
; Return carry if species a is not a Pokemon.
|
|
|
|
and a
|
|
|
|
jr z, .NotAPokemon
|
|
|
|
cp EGG
|
|
|
|
jr z, .Pokemon
|
|
|
|
cp NUM_POKEMON + 1
|
|
|
|
jr c, .Pokemon
|
|
|
|
|
|
|
|
.NotAPokemon
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Pokemon
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3750
|
|
|
|
|
2015-11-08 07:59:28 -08:00
|
|
|
DrawBattleHPBar:: ; 3750
|
2013-11-28 23:30:08 -08:00
|
|
|
; Draw an HP bar d tiles long at hl
|
|
|
|
; Fill it up to e pixels
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
|
|
|
|
; Place 'HP:'
|
|
|
|
ld a, $60
|
|
|
|
ld [hli], a
|
|
|
|
ld a, $61
|
|
|
|
ld [hli], a
|
|
|
|
|
|
|
|
; Draw a template
|
|
|
|
push hl
|
|
|
|
ld a, $62 ; empty bar
|
|
|
|
.template
|
|
|
|
ld [hli], a
|
|
|
|
dec d
|
|
|
|
jr nz, .template
|
|
|
|
ld a, $6b ; bar end
|
|
|
|
add b
|
|
|
|
ld [hl], a
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
; Safety check # pixels
|
|
|
|
ld a, e
|
|
|
|
and a
|
|
|
|
jr nz, .fill
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
ld e, 1
|
|
|
|
|
|
|
|
.fill
|
|
|
|
; Keep drawing tiles until pixel length is reached
|
|
|
|
ld a, e
|
|
|
|
sub TILE_WIDTH
|
|
|
|
jr c, .lastbar
|
|
|
|
|
|
|
|
ld e, a
|
|
|
|
ld a, $6a ; full bar
|
|
|
|
ld [hli], a
|
|
|
|
ld a, e
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
jr .fill
|
|
|
|
|
|
|
|
.lastbar
|
|
|
|
ld a, $62 ; empty bar
|
|
|
|
add e ; + e
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 3786
|
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
PrepMonFrontpic:: ; 3786
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, $1
|
2015-12-19 11:48:30 -08:00
|
|
|
ld [wBoxAlignment], a
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
_PrepMonFrontpic:: ; 378b
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [CurPartySpecies]
|
|
|
|
call IsAPokemon
|
2014-06-23 12:45:30 -07:00
|
|
|
jr c, .not_pokemon
|
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
push hl
|
|
|
|
ld de, VTiles2
|
2014-06-18 00:55:44 -07:00
|
|
|
predef GetFrontpic
|
2013-11-28 23:30:08 -08:00
|
|
|
pop hl
|
|
|
|
xor a
|
2016-01-12 09:46:18 -08:00
|
|
|
ld [hGraphicStartTile], a
|
2014-06-23 12:45:30 -07:00
|
|
|
lb bc, 7, 7
|
2016-01-12 09:46:18 -08:00
|
|
|
predef PlaceGraphic
|
2013-11-28 23:30:08 -08:00
|
|
|
xor a
|
2015-12-19 11:48:30 -08:00
|
|
|
ld [wBoxAlignment], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ret
|
|
|
|
|
2014-06-23 12:45:30 -07:00
|
|
|
.not_pokemon
|
2013-11-28 23:30:08 -08:00
|
|
|
xor a
|
2015-12-19 11:48:30 -08:00
|
|
|
ld [wBoxAlignment], a
|
2013-11-28 23:30:08 -08:00
|
|
|
inc a
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ret
|
|
|
|
; 37b6
|
|
|
|
|
2014-07-18 10:26:15 -07:00
|
|
|
INCLUDE "home/cry.asm"
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PrintLevel:: ; 382d
|
2013-11-28 23:30:08 -08:00
|
|
|
; Print TempMonLevel at hl
|
|
|
|
|
|
|
|
ld a, [TempMonLevel]
|
2015-10-17 14:18:52 -07:00
|
|
|
ld [hl], "<LV>"
|
2013-11-28 23:30:08 -08:00
|
|
|
inc hl
|
|
|
|
|
|
|
|
; How many digits?
|
|
|
|
ld c, 2
|
|
|
|
cp 100
|
|
|
|
jr c, Function3842
|
|
|
|
|
|
|
|
; 3-digit numbers overwrite the :L.
|
|
|
|
dec hl
|
|
|
|
inc c
|
|
|
|
jr Function3842
|
|
|
|
; 383d
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function383d:: ; 383d
|
2013-11-28 23:30:08 -08:00
|
|
|
; Print :L and all 3 digits
|
2015-10-17 14:18:52 -07:00
|
|
|
ld [hl], "<LV>"
|
2013-11-28 23:30:08 -08:00
|
|
|
inc hl
|
|
|
|
ld c, 3
|
|
|
|
; 3842
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function3842:: ; 3842
|
2015-02-10 15:14:41 -08:00
|
|
|
ld [wd265], a
|
|
|
|
ld de, wd265
|
2015-10-11 09:15:03 -07:00
|
|
|
ld b, PRINTNUM_RIGHTALIGN | 1
|
2013-11-28 23:30:08 -08:00
|
|
|
jp PrintNum
|
|
|
|
; 384d
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function384d:: ; 384d
|
2015-10-17 14:18:52 -07:00
|
|
|
ld hl, wListMoves_MoveIndicesBuffer
|
2013-11-28 23:30:08 -08:00
|
|
|
ld c, a
|
2014-09-30 11:19:33 -07:00
|
|
|
ld b, 0
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
; 3856
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetBaseData:: ; 3856
|
2013-11-28 23:30:08 -08:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
|
|
|
ld a, BANK(BaseData)
|
|
|
|
rst Bankswitch
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
; Egg doesn't have BaseData
|
|
|
|
ld a, [CurSpecies]
|
|
|
|
cp EGG
|
|
|
|
jr z, .egg
|
|
|
|
|
|
|
|
; Get BaseData
|
|
|
|
dec a
|
|
|
|
ld bc, BaseData1 - BaseData0
|
|
|
|
ld hl, BaseData
|
|
|
|
call AddNTimes
|
|
|
|
ld de, CurBaseData
|
|
|
|
ld bc, BaseData1 - BaseData0
|
|
|
|
call CopyBytes
|
|
|
|
jr .end
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
.egg
|
|
|
|
; ????
|
2014-04-17 20:11:47 -07:00
|
|
|
ld de, UnknownEggPic
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
; Sprite dimensions
|
|
|
|
ld b, $55 ; 5x5
|
|
|
|
ld hl, BasePicSize
|
|
|
|
ld [hl], b
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
; ????
|
|
|
|
ld hl, BasePadding
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
jr .end
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
.end
|
|
|
|
; Replace Pokedex # with species
|
|
|
|
ld a, [CurSpecies]
|
|
|
|
ld [BaseDexNo], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 389c
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetCurNick:: ; 389c
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld hl, PartyMonNicknames
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetNick:: ; 38a2
|
2013-11-28 23:30:08 -08:00
|
|
|
; Get nickname a from list hl.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
|
|
|
|
call SkipNames
|
|
|
|
ld de, StringBuffer1
|
|
|
|
|
|
|
|
push de
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop de
|
|
|
|
|
|
|
|
callab CheckNickErrors
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 38bb
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PrintBCDNumber:: ; 38bb
|
2013-11-28 23:30:08 -08:00
|
|
|
; function to print a BCD (Binary-coded decimal) number
|
|
|
|
; de = address of BCD number
|
|
|
|
; hl = destination address
|
|
|
|
; c = flags and length
|
|
|
|
; bit 7: if set, do not print leading zeroes
|
|
|
|
; if unset, print leading zeroes
|
|
|
|
; bit 6: if set, left-align the string (do not pad empty digits with spaces)
|
|
|
|
; if unset, right-align the string
|
|
|
|
; bit 5: if set, print currency symbol at the beginning of the string
|
|
|
|
; if unset, do not print the currency symbol
|
|
|
|
; bits 0-4: length of BCD number in bytes
|
|
|
|
; Note that bits 5 and 7 are modified during execution. The above reflects
|
|
|
|
; their meaning at the beginning of the functions's execution.
|
|
|
|
ld b, c ; save flags in b
|
|
|
|
res 7, c
|
|
|
|
res 6, c
|
|
|
|
res 5, c ; c now holds the length
|
|
|
|
bit 5, b
|
|
|
|
jr z, .loop
|
|
|
|
bit 7, b
|
2015-11-11 11:12:46 -08:00
|
|
|
jr nz, .loop ; skip currency symbol
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [hl], "Â¥"
|
|
|
|
inc hl
|
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
swap a
|
|
|
|
call PrintBCDDigit ; print upper digit
|
|
|
|
ld a, [de]
|
|
|
|
call PrintBCDDigit ; print lower digit
|
|
|
|
inc de
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
bit 7, b ; were any non-zero digits printed?
|
|
|
|
jr z, .done ; if so, we are done
|
|
|
|
.numberEqualsZero ; if every digit of the BCD number is zero
|
|
|
|
bit 6, b ; left or right alignment?
|
|
|
|
jr nz, .skipRightAlignmentAdjustment
|
|
|
|
dec hl ; if the string is right-aligned, it needs to be moved back one space
|
|
|
|
.skipRightAlignmentAdjustment
|
|
|
|
bit 5, b
|
|
|
|
jr z, .skipCurrencySymbol
|
|
|
|
ld [hl], "Â¥" ; currency symbol
|
|
|
|
inc hl
|
|
|
|
.skipCurrencySymbol
|
|
|
|
ld [hl], "0"
|
|
|
|
call PrintLetterDelay
|
|
|
|
inc hl
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
; 0x38f2
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
PrintBCDDigit:: ; 38f2
|
2013-11-28 23:30:08 -08:00
|
|
|
and a, %00001111
|
|
|
|
and a
|
|
|
|
jr z, .zeroDigit
|
|
|
|
.nonzeroDigit
|
|
|
|
bit 7, b ; have any non-space characters been printed?
|
|
|
|
jr z, .outputDigit
|
|
|
|
; if bit 7 is set, then no numbers have been printed yet
|
|
|
|
bit 5, b ; print the currency symbol?
|
|
|
|
jr z, .skipCurrencySymbol
|
|
|
|
ld [hl], "Â¥"
|
|
|
|
inc hl
|
|
|
|
res 5, b
|
|
|
|
.skipCurrencySymbol
|
|
|
|
res 7, b ; unset 7 to indicate that a nonzero digit has been reached
|
|
|
|
.outputDigit
|
|
|
|
add a, "0"
|
|
|
|
ld [hli], a
|
|
|
|
jp PrintLetterDelay
|
2015-11-11 11:12:46 -08:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
.zeroDigit
|
|
|
|
bit 7, b ; either printing leading zeroes or already reached a nonzero digit?
|
|
|
|
jr z, .outputDigit ; if so, print a zero digit
|
|
|
|
bit 6, b ; left or right alignment?
|
|
|
|
ret nz
|
|
|
|
ld a, " "
|
|
|
|
ld [hli], a ; if right-aligned, "print" a space by advancing the pointer
|
|
|
|
ret
|
|
|
|
; 0x3917
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetPartyParamLocation:: ; 3917
|
2013-11-28 23:30:08 -08:00
|
|
|
; Get the location of parameter a from CurPartyMon in hl
|
|
|
|
push bc
|
|
|
|
ld hl, PartyMons
|
|
|
|
ld c, a
|
2014-03-03 02:43:25 -08:00
|
|
|
ld b, 0
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3927
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
GetPartyLocation:: ; 3927
|
2013-11-28 23:30:08 -08:00
|
|
|
; Add the length of a PartyMon struct to hl a times.
|
2015-11-04 08:19:58 -08:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
2013-11-28 23:30:08 -08:00
|
|
|
jp AddNTimes
|
|
|
|
; 392d
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function392d:: ; 392d
|
2013-11-28 23:30:08 -08:00
|
|
|
push hl
|
|
|
|
ld a, b
|
|
|
|
dec a
|
2014-03-03 02:43:25 -08:00
|
|
|
ld b, 0
|
2013-11-28 23:30:08 -08:00
|
|
|
add hl, bc
|
2014-03-03 02:43:25 -08:00
|
|
|
ld hl, BaseData + 0
|
2013-11-28 23:30:08 -08:00
|
|
|
ld bc, $0020
|
|
|
|
call AddNTimes
|
2014-03-03 02:43:25 -08:00
|
|
|
ld a, BANK(BaseData)
|
2013-11-28 23:30:08 -08:00
|
|
|
call GetFarHalfword
|
|
|
|
ld b, l
|
|
|
|
ld c, h
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 3945
|
|
|
|
|
2014-05-21 13:37:18 -07:00
|
|
|
INCLUDE "home/battle.asm"
|
2013-11-28 23:30:08 -08:00
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
Function3b0c:: ; 3b0c
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-12-26 18:59:03 -08:00
|
|
|
ld a, [hFFC6]
|
2013-11-28 23:30:08 -08:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
2013-12-08 13:22:35 -08:00
|
|
|
ld a, LYOverridesBackup % $100
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [Requested2bppSource], a
|
2013-12-08 13:22:35 -08:00
|
|
|
ld a, LYOverridesBackup / $100
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [Requested2bppSource + 1], a
|
|
|
|
|
2013-12-08 13:22:35 -08:00
|
|
|
ld a, LYOverrides % $100
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [Requested2bppDest], a
|
2013-12-08 13:22:35 -08:00
|
|
|
ld a, LYOverrides / $100
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [Requested2bppDest + 1], a
|
|
|
|
|
2013-12-08 13:22:35 -08:00
|
|
|
ld a, (LYOverridesEnd - LYOverrides) / 16
|
2013-11-28 23:30:08 -08:00
|
|
|
ld [Requested2bpp], a
|
|
|
|
ret
|
|
|
|
; 3b2a
|
|
|
|
|
2015-11-13 07:48:49 -08:00
|
|
|
_InitSpriteAnimStruct:: ; 3b2a
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-12-04 05:46:11 -08:00
|
|
|
ld [wSpriteAnimIDBuffer], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-11-13 07:48:49 -08:00
|
|
|
ld a, BANK(InitSpriteAnimStruct)
|
2013-11-28 23:30:08 -08:00
|
|
|
rst Bankswitch
|
2015-12-04 05:46:11 -08:00
|
|
|
ld a, [wSpriteAnimIDBuffer]
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-11-13 07:48:49 -08:00
|
|
|
call InitSpriteAnimStruct
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
ret
|
|
|
|
; 3b3c
|
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
ReinitSpriteAnimFrame:: ; 3b3c
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-12-04 05:46:11 -08:00
|
|
|
ld [wSpriteAnimIDBuffer], a
|
2013-11-28 23:30:08 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
push af
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
ld a, BANK(_ReinitSpriteAnimFrame)
|
2013-11-28 23:30:08 -08:00
|
|
|
rst Bankswitch
|
2015-12-04 05:46:11 -08:00
|
|
|
ld a, [wSpriteAnimIDBuffer]
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2015-12-05 12:38:25 -08:00
|
|
|
call _ReinitSpriteAnimFrame
|
2014-05-21 13:21:46 -07:00
|
|
|
|
2013-11-28 23:30:08 -08:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
ret
|
|
|
|
; 3b4e
|
|
|
|
|
2014-05-21 13:26:28 -07:00
|
|
|
INCLUDE "home/audio.asm"
|
2014-08-22 10:57:06 -07:00
|
|
|
INCLUDE "home/mobile.asm"
|