map setup and warps

This commit is contained in:
PikalaxALT 2015-12-14 11:12:18 -05:00
parent 8a439dbd05
commit c635e30777
25 changed files with 657 additions and 668 deletions

View File

@ -1889,26 +1889,26 @@ SubtractHP: ; 3cc45
.ok .ok
inc hl inc hl
ld a, [hl] ld a, [hl]
ld [wd1ec], a ld [Buffer3], a
sub c sub c
ld [hld], a ld [hld], a
ld [wd1ee], a ld [Buffer5], a
ld a, [hl] ld a, [hl]
ld [wd1ed], a ld [Buffer4], a
sbc b sbc b
ld [hl], a ld [hl], a
ld [wd1ef], a ld [Buffer6], a
ret nc ret nc
ld a, [wd1ec] ld a, [Buffer3]
ld c, a ld c, a
ld a, [wd1ed] ld a, [Buffer4]
ld b, a ld b, a
xor a xor a
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld [wd1ee], a ld [Buffer5], a
ld [wd1ef], a ld [Buffer6], a
ret ret
; 3cc76 ; 3cc76
@ -4508,13 +4508,13 @@ HandleHPHealingItem: ; 3dd2f
.go .go
push bc push bc
ld a, [de] ld a, [de]
ld [wd1ec], a ld [Buffer3], a
add a add a
ld c, a ld c, a
dec de dec de
ld a, [de] ld a, [de]
inc de inc de
ld [wd1ed], a ld [Buffer4], a
adc a adc a
ld b, a ld b, a
ld a, b ld a, b
@ -4539,12 +4539,12 @@ HandleHPHealingItem: ; 3dd2f
ld [Buffer1], a ld [Buffer1], a
ld a, [de] ld a, [de]
add c add c
ld [wd1ee], a ld [Buffer5], a
ld c, a ld c, a
dec de dec de
ld a, [de] ld a, [de]
adc $0 adc $0
ld [wd1ef], a ld [Buffer6], a
ld b, a ld b, a
ld a, [hld] ld a, [hld]
cp c cp c
@ -4552,15 +4552,15 @@ HandleHPHealingItem: ; 3dd2f
sbc b sbc b
jr nc, .okay jr nc, .okay
ld a, [hli] ld a, [hli]
ld [wd1ef], a ld [Buffer6], a
ld a, [hl] ld a, [hl]
ld [wd1ee], a ld [Buffer5], a
.okay .okay
ld a, [wd1ef] ld a, [Buffer6]
ld [de], a ld [de], a
inc de inc de
ld a, [wd1ee] ld a, [Buffer5]
ld [de], a ld [de], a
ld a, [hBattleTurn] ld a, [hBattleTurn]
ld [wd10a], a ld [wd10a], a

View File

@ -61,4 +61,4 @@ const_value SET $f1
const map_keep_palettes ; 2b const map_keep_palettes ; 2b
const map_text_scroll_off ; 2c const map_text_scroll_off ; 2c
const map_stop_script ; 2d const map_stop_script ; 2d
map_end_setup_script EQU -1 map_end EQU -1

View File

@ -93,6 +93,8 @@ SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * 8
BG_MAP_WIDTH EQU 32 BG_MAP_WIDTH EQU 32
BG_MAP_HEIGHT EQU 32 BG_MAP_HEIGHT EQU 32
WMISC_WIDTH EQU 6 * 4
WMISC_HEIGHT EQU 5 * 4
TILE_WIDTH EQU 8 TILE_WIDTH EQU 8

View File

@ -36,7 +36,7 @@ SpriteAnimFrameData: ; 8d6e6
dw Unknown_8d87d ; 22 dw Unknown_8d87d ; 22
dw Unknown_8d880 ; 23 dw Unknown_8d880 ; 23
dw Unknown_8d883 ; 24 dw Unknown_8d883 ; 24
dw Unknown_8d890 ; 25 dw Unknown_8d890 ; 25 headbutt
dw Unknown_8d899 ; 26 dw Unknown_8d899 ; 26
dw Unknown_8d89c ; 27 dw Unknown_8d89c ; 27
dw Unknown_8d89f ; 28 dw Unknown_8d89f ; 28
@ -238,7 +238,7 @@ Unknown_8d883: db $56, $0a
db $58, $09 db $58, $09
db $5a, $0a db $5a, $0a
db -2 db -2
Unknown_8d890: db $50, $02 Unknown_8d890: db $50, $02 ; center
db $5b, $02 db $5b, $02
db $50, $02 db $50, $02
db $5b, $42 db $5b, $42

430
engine/anim_hp_bar.asm Executable file
View File

@ -0,0 +1,430 @@
_AnimateHPBar: ; d627
call Functiond65f
jr c, .do_player
call Functiond670
.enemy_loop
push bc
push hl
call Functiond6e2
pop hl
pop bc
push af
push bc
push hl
call Functiond730
call Functiond7c9
pop hl
pop bc
pop af
jr nc, .enemy_loop
ret
.do_player
call Functiond670
.player_loop
push bc
push hl
call Functiond6f5
pop hl
pop bc
ret c
push af
push bc
push hl
call Functiond749
call Functiond7c9
pop hl
pop bc
pop af
jr nc, .player_loop
ret
; d65f
Functiond65f: ; d65f
ld a, [Buffer2]
and a
jr nz, .player
ld a, [Buffer1]
cp 6 * 8
jr nc, .player
and a
ret
.player
scf
ret
; d670
Functiond670: ; d670
; Buffer1-2: Max HP
; Buffer3-4: Old HP
; Buffer5-6: New HP
push hl
ld hl, Buffer1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
pop hl
call ComputeHPBarPixels
ld a, e
ld [wd1f1], a
ld a, [Buffer5]
ld c, a
ld a, [Buffer6]
ld b, a
ld a, [Buffer1]
ld e, a
ld a, [Buffer2]
ld d, a
call ComputeHPBarPixels
ld a, e
ld [wd1f2], a
push hl
ld hl, Buffer3
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
pop hl
ld a, e
sub c
ld e, a
ld a, d
sbc b
ld d, a
jr c, .asm_d6c1
ld a, [Buffer3]
ld [wd1f5], a
ld a, [Buffer5]
ld [wd1f6], a
ld bc, 1
jr .asm_d6d9
.asm_d6c1
ld a, [Buffer3]
ld [wd1f6], a
ld a, [Buffer5]
ld [wd1f5], a
ld a, e
xor $ff
inc a
ld e, a
ld a, d
xor $ff
ld d, a
ld bc, rIE
.asm_d6d9
ld a, d
ld [wd1f3], a
ld a, e
ld [wd1f4], a
ret
; d6e2
Functiond6e2: ; d6e2
ld hl, wd1f1
ld a, [wd1f2]
cp [hl]
jr nz, .asm_d6ed
scf
ret
.asm_d6ed
ld a, c
add [hl]
ld [hl], a
call Functiond839
and a
ret
; d6f5
Functiond6f5: ; d6f5
.asm_d6f5
ld hl, Buffer3
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, e
cp [hl]
jr nz, .asm_d707
inc hl
ld a, d
cp [hl]
jr nz, .asm_d707
scf
ret
.asm_d707
ld l, e
ld h, d
add hl, bc
ld a, l
ld [Buffer3], a
ld a, h
ld [wd1ed], a
push hl
push de
push bc
ld hl, Buffer1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
call ComputeHPBarPixels
pop bc
pop de
pop hl
ld a, e
ld hl, wd1f1
cp [hl]
jr z, .asm_d6f5
ld [hl], a
and a
ret
; d730
Functiond730: ; d730
call Functiond784
ld d, $6
ld a, [wd10a]
and $1
ld b, a
ld a, [wd1f1]
ld e, a
ld c, a
push de
call Functiond771
pop de
call Functiond7b4
ret
; d749
Functiond749: ; d749
call Functiond784
ld a, [Buffer3]
ld c, a
ld a, [wd1ed]
ld b, a
ld a, [Buffer1]
ld e, a
ld a, [Buffer2]
ld d, a
call ComputeHPBarPixels
ld c, e
ld d, $6
ld a, [wd10a]
and $1
ld b, a
push de
call Functiond771
pop de
call Functiond7b4
ret
; d771
Functiond771: ; d771
ld a, [wd10a]
cp $2
jr nz, .skip
ld a, $28
add l
ld l, a
ld a, $0
adc h
ld h, a
.skip
call DrawBattleHPBar
ret
; d784
Functiond784: ; d784
ld a, [wd10a]
and a
ret z
cp $1
jr z, .load_15
ld de, $16
jr .loaded_de
.load_15
ld de, $15
.loaded_de
push hl
add hl, de
ld a, " "
rept 2
ld [hli], a
endr
ld [hld], a
dec hl
ld a, [Buffer3]
ld [StringBuffer2 + 1], a
ld a, [wd1ed]
ld [StringBuffer2], a
ld de, StringBuffer2
lb bc, 2, 3
call PrintNum
pop hl
ret
; d7b4
Functiond7b4: ; d7b4
ld a, [hCGB]
and a
ret z
ld hl, wd1f0
call SetHPPal
ld a, [wd1f0]
ld c, a
callba Function8c43
ret
; d7c9
Functiond7c9: ; d7c9
ld a, [hCGB]
and a
jr nz, .cgb
call DelayFrame
call DelayFrame
ret
.cgb
ld a, [wd10a]
and a
jr z, .load_0
cp $1
jr z, .load_1
ld a, [CurPartyMon]
cp $3
jr nc, .c_is_1
ld c, $0
jr .c_is_0
.c_is_1
ld c, $1
.c_is_0
push af
cp $2
jr z, .skip_delay
cp $5
jr z, .skip_delay
ld a, $2
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
.skip_delay
ld a, $1
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
pop af
cp $2
jr z, .two_frames
cp $5
jr z, .two_frames
ret
.two_frames
inc c
ld a, $2
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
ld a, $1
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
ret
.load_0
ld c, $0
jr .finish
.load_1
ld c, $1
.finish
call DelayFrame
ld a, c
ld [hBGMapThird], a
call DelayFrame
ret
; d839
Functiond839: ; d839
ld a, [Buffer1]
ld c, a
ld b, 0
ld hl, 0
ld a, [wd1f1]
cp 6 * 8
jr nc, .coppy_buffer
and a
jr z, .return_zero
call AddNTimes
ld b, 0
.loop
ld a, l
sub 6 * 8
ld l, a
ld a, h
sbc $0
ld h, a
jr c, .done
inc b
jr .loop
.done
push bc
ld bc, $80
add hl, bc
pop bc
ld a, l
sub 6 * 8
ld l, a
ld a, h
sbc $0
ld h, a
jr c, .no_carry
inc b
.no_carry
ld a, [wd1f5]
cp b
jr nc, .finish
ld a, [wd1f6]
cp b
jr c, .finish
ld a, b
.finish
ld [Buffer3], a
ret
.return_zero
xor a
ld [Buffer3], a
ret
.coppy_buffer
ld a, [Buffer1]
ld [Buffer3], a
ret
; d88c

View File

@ -264,8 +264,8 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab)
ret ret
.DoFlashAnimation: ; 8c3b3 (23:43b3) .DoFlashAnimation: ; 8c3b3 (23:43b3)
ld a, [wd847] ld a, [wTimeOfDayPalset]
cp -1 cp %11111111 ; dark cave
jr z, .done jr z, .done
ld hl, wcf64 ld hl, wcf64
ld a, [hl] ld a, [hl]

View File

@ -2349,7 +2349,7 @@ Function29dba: ; 29dba
ld a, [ScriptVar] ld a, [ScriptVar]
and a and a
jr z, .asm_29e08 jr z, .asm_29e08
ld bc, rIE ld bc, -1
.asm_29de0 .asm_29de0
dec bc dec bc
ld a, b ld a, b

View File

@ -3040,7 +3040,7 @@ Function579d: ; 579d
ld [wd04e], a ld [wd04e], a
ld [PlayerObjectStepFrame], a ld [PlayerObjectStepFrame], a
call Function57bc call Function57bc
callba CheckWarpCollision callba CheckWarpFacingDown
call c, SpawnInFacingDown call c, SpawnInFacingDown
call SpawnInCustomFacing call SpawnInCustomFacing
ret ret

View File

@ -33,11 +33,9 @@ MapSetupScripts: ; 15377
MapSetupScript_Teleport: ; 1538f MapSetupScript_Teleport: ; 1538f
db map_prolong_sprites db map_prolong_sprites
MapSetupScript_Fly: ; 15390 MapSetupScript_Fly: ; 15390
db map_fade_out_palettes db map_fade_out_palettes
db map_keep_roam db map_keep_roam
MapSetupScript_Warp: ; 15392 MapSetupScript_Warp: ; 15392
db map_lcd_off db map_lcd_off
db map_sound_off db map_sound_off
@ -61,7 +59,7 @@ MapSetupScript_Warp: ; 15392
db map_fade_in_palettes db map_fade_in_palettes
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_end_setup_script db map_end
MapSetupScript_BadWarp: ; 153a9 MapSetupScript_BadWarp: ; 153a9
db map_load_spawn db map_load_spawn
@ -85,7 +83,7 @@ MapSetupScript_BadWarp: ; 153a9
db map_fade_in_palettes db map_fade_in_palettes
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_end_setup_script db map_end
MapSetupScript_Connection: ; 153bf MapSetupScript_Connection: ; 153bf
db map_animations_off db map_animations_off
@ -104,14 +102,12 @@ MapSetupScript_Connection: ; 153bf
db map_wildmons db map_wildmons
db map_update_roam db map_update_roam
db map_animations_on db map_animations_on
db map_end_setup_script db map_end
MapSetupScript_Fall: ; 153d0 MapSetupScript_Fall: ; 153d0
db map_prolong_sprites db map_prolong_sprites
MapSetupScript_Door: ; 153d1 MapSetupScript_Door: ; 153d1
db map_fade_out_palettes db map_fade_out_palettes
MapSetupScript_Train: ; 153d2 MapSetupScript_Train: ; 153d2
db map_load_warp db map_load_warp
db map_attributes db map_attributes
@ -133,7 +129,7 @@ MapSetupScript_Train: ; 153d2
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_update_roam db map_update_roam
db map_end_setup_script db map_end
MapSetupScript_ReloadMap: ; 153e7 MapSetupScript_ReloadMap: ; 153e7
db map_fade db map_fade
@ -151,7 +147,7 @@ MapSetupScript_ReloadMap: ; 153e7
db map_fade_in_palettes db map_fade_in_palettes
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_end_setup_script db map_end
MapSetupScript_LinkReturn: ; 153f7 MapSetupScript_LinkReturn: ; 153f7
db map_fade db map_fade
@ -170,7 +166,7 @@ MapSetupScript_LinkReturn: ; 153f7
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_text_scroll_off db map_text_scroll_off
db map_end_setup_script db map_end
MapSetupScript_Continue: ; 15408 MapSetupScript_Continue: ; 15408
db map_lcd_off db map_lcd_off
@ -190,12 +186,12 @@ MapSetupScript_Continue: ; 15408
db map_fade_in_palettes db map_fade_in_palettes
db map_animations_on db map_animations_on
db map_wildmons db map_wildmons
db map_end_setup_script db map_end
MapSetupScript_Submenu: ; 1541a MapSetupScript_Submenu: ; 1541a
db map_load_blocks db map_load_blocks
db map_connection_blocks db map_connection_blocks
db map_end_setup_script db map_end
ReadMapSetupScript: ; 1541d ReadMapSetupScript: ; 1541d

View File

@ -190,7 +190,7 @@ PlacePartymonHPBar: ; 50117
ld d, a ld d, a
ld a, [hli] ld a, [hli]
ld e, a ld e, a
predef DrawPartyMenuHPBar predef ComputeHPBarPixels
ret ret
; 50138 ; 50138

View File

@ -34,7 +34,7 @@ PredefPointers:: ; 856b
add_predef Predef1 add_predef Predef1
add_predef HealParty add_predef HealParty
add_predef FlagPredef add_predef FlagPredef
add_predef DrawPartyMenuHPBar add_predef ComputeHPBarPixels
add_predef FillPP add_predef FillPP
add_predef TryAddMonToParty add_predef TryAddMonToParty
add_predef AddTempmonToParty add_predef AddTempmonToParty

View File

@ -16,7 +16,7 @@ endr
.Jumptable: ; 8d25b (23:525b) .Jumptable: ; 8d25b (23:525b)
jumptable_start jumptable_start
jumptable .zero ; town map jumptable .zero ; null
jumptable .one ; bouncing mon icon jumptable .one ; bouncing mon icon
jumptable .two ; bouncing mon icon, selected jumptable .two ; bouncing mon icon, selected
jumptable .three ; bouncing mon icon, menu open jumptable .three ; bouncing mon icon, menu open

View File

@ -585,7 +585,7 @@ SpriteAnimSeqData: ; 8d1c4
db SPRITE_ANIM_FRAMESET_1D, SPRITE_ANIM_SEQ_17, $00 ; 18 flying leaves db SPRITE_ANIM_FRAMESET_1D, SPRITE_ANIM_SEQ_17, $00 ; 18 flying leaves
db SPRITE_ANIM_FRAMESET_1F, SPRITE_ANIM_SEQ_00, $00 ; 19 db SPRITE_ANIM_FRAMESET_1F, SPRITE_ANIM_SEQ_00, $00 ; 19
db SPRITE_ANIM_FRAMESET_24, SPRITE_ANIM_SEQ_19, $00 ; 1a db SPRITE_ANIM_FRAMESET_24, SPRITE_ANIM_SEQ_19, $00 ; 1a
db SPRITE_ANIM_FRAMESET_25, SPRITE_ANIM_SEQ_00, $00 ; 1b db SPRITE_ANIM_FRAMESET_25, SPRITE_ANIM_SEQ_00, $00 ; 1b headbutt
db SPRITE_ANIM_FRAMESET_20, SPRITE_ANIM_SEQ_13, $00 ; 1c db SPRITE_ANIM_FRAMESET_20, SPRITE_ANIM_SEQ_13, $00 ; 1c
db SPRITE_ANIM_FRAMESET_26, SPRITE_ANIM_SEQ_1A, $00 ; 1d db SPRITE_ANIM_FRAMESET_26, SPRITE_ANIM_SEQ_1A, $00 ; 1d
db SPRITE_ANIM_FRAMESET_2D, SPRITE_ANIM_SEQ_00, $00 ; 1e db SPRITE_ANIM_FRAMESET_2D, SPRITE_ANIM_SEQ_00, $00 ; 1e

View File

@ -1280,7 +1280,7 @@ MonMenu_Fly: ; 12e30
; 12e55 ; 12e55
MonMenu_Flash: ; 12e55 MonMenu_Flash: ; 12e55
callba Functionc8ac callba OWFlash
ld a, [wFieldMoveSucceeded] ld a, [wFieldMoveSucceeded]
cp $1 cp $1
jr nz, .Fail jr nz, .Fail

View File

@ -407,7 +407,7 @@ Function4df45: ; 4df45 (13:5f45)
ld a, [hli] ld a, [hli]
ld d, a ld d, a
ld e, [hl] ld e, [hl]
callba DrawPartyMenuHPBar callba ComputeHPBarPixels
ld hl, wcda1 ld hl, wcda1
call SetHPPal call SetHPPal
ld b, SCGB_03 ld b, SCGB_03

View File

@ -1,4 +1,4 @@
Function8c001:: ; 8c001 UpdateTimeOfDayPal:: ; 8c001
call UpdateTime call UpdateTime
ld a, [TimeOfDay] ld a, [TimeOfDay]
ld [CurTimeOfDay], a ld [CurTimeOfDay], a
@ -12,7 +12,7 @@ _TimeOfDayPals:: ; 8c011
; return carry if pals are changed ; return carry if pals are changed
; forced pals? ; forced pals?
ld hl, wd846 ld hl, wTimeOfDayPalFlags
bit 7, [hl] bit 7, [hl]
jr nz, .dontchange jr nz, .dontchange
@ -198,7 +198,7 @@ brightlevel: MACRO
db (\1 << 6) | (\2 << 4) | (\3 << 2) | \4 db (\1 << 6) | (\2 << 4) | (\3 << 2) | \4
ENDM ENDM
Function8c0e5: ; 8c0e5 ReplaceTimeOfDayPals: ; 8c0e5
ld hl, .BrightnessLevels ld hl, .BrightnessLevels
ld a, [wc2d0] ld a, [wc2d0]
cp $4 ; Dark cave, needs Flash cp $4 ; Dark cave, needs Flash
@ -210,18 +210,20 @@ Function8c0e5: ; 8c0e5
adc h adc h
ld h, a ld h, a
ld a, [hl] ld a, [hl]
ld [wd847], a ld [wTimeOfDayPalset], a
ret ret
.DarkCave .DarkCave
ld a, [StatusFlags] ld a, [StatusFlags]
bit 2, a bit 2, a ; Flash
jr nz, .UsedFlash jr nz, .UsedFlash
ld a, $ff ; 3, 3, 3, 3 ld a, %11111111 ; 3, 3, 3, 3
ld [wd847], a ld [wTimeOfDayPalset], a
ret ret
.UsedFlash .UsedFlash
ld a, $aa ; 2, 2, 2, 2 ld a, %10101010 ; 2, 2, 2, 2
ld [wd847], a ld [wTimeOfDayPalset], a
ret ret
; 8c10f (23:410f) ; 8c10f (23:410f)
@ -257,25 +259,25 @@ endr
dw .DarknessPalette dw .DarknessPalette
.MorningPalette .MorningPalette
ld a, [wd847] ld a, [wTimeOfDayPalset]
and %00000011 ; 0 and %00000011 ; 0
ret ret
.DayPalette .DayPalette
ld a, [wd847] ld a, [wTimeOfDayPalset]
and %00001100 ; 1 and %00001100 ; 1
srl a srl a
srl a srl a
ret ret
.NitePalette .NitePalette
ld a, [wd847] ld a, [wTimeOfDayPalset]
and %00110000 ; 2 and %00110000 ; 2
swap a swap a
ret ret
.DarknessPalette .DarknessPalette
ld a, [wd847] ld a, [wTimeOfDayPalset]
and %11000000 ; 3 and %11000000 ; 3
rlca rlca
rlca rlca

View File

@ -237,8 +237,8 @@ LoadMapTimeOfDay: ; 104750
res 6, [hl] res 6, [hl]
ld a, $1 ld a, $1
ld [wSpriteUpdatesEnabled], a ld [wSpriteUpdatesEnabled], a
callba Function8c0e5 callba ReplaceTimeOfDayPals
callba Function8c001 callba UpdateTimeOfDayPal
call OverworldTextModeSwitch call OverworldTextModeSwitch
call Function104770 call Function104770
call Function1047a3 call Function1047a3

View File

@ -9,12 +9,12 @@ PlayWhirlpoolSound: ; 8c7d4
BlindingFlash: ; 8c7e1 BlindingFlash: ; 8c7e1
callba FadeOutPalettes callba FadeOutPalettes
ld hl, StatusFlags ld hl, StatusFlags
set 2, [hl] set 2, [hl] ; Flash
callba Function8c0e5 callba ReplaceTimeOfDayPals
callba Function8c001 callba UpdateTimeOfDayPal
ld b, SCGB_09 ld b, SCGB_09
call GetSGBLayout call GetSGBLayout
callba Function49409 callba LoadOW_BGPal7
callba FadeInPalettes callba FadeInPalettes
ret ret
; 8c80a ; 8c80a
@ -32,13 +32,13 @@ ShakeHeadbuttTree: ; 8c80a
call Cut_Headbutt_GetPixelFacing call Cut_Headbutt_GetPixelFacing
ld a, SPRITE_ANIM_INDEX_1B ld a, SPRITE_ANIM_INDEX_1B
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, $3 ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc add hl, bc
ld [hl], $84 ld [hl], $84
ld a, 36 * 4 ld a, 36 * 4
ld [wCurrSpriteOAMAddr], a ld [wCurrSpriteOAMAddr], a
callba DoNextFrameForAllSprites callba DoNextFrameForAllSprites
call GetHeadbuttTreeRelativeLocation call HideHeadbuttTree
ld a, $20 ld a, $20
ld [wcf64], a ld [wcf64], a
call WaitSFX call WaitSFX
@ -78,7 +78,7 @@ HeadbuttTreeGFX: ; 8c893
INCBIN "gfx/unknown/08c893.2bpp" INCBIN "gfx/unknown/08c893.2bpp"
; 8c913 ; 8c913
GetHeadbuttTreeRelativeLocation: ; 8c913 HideHeadbuttTree: ; 8c913
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
ld a, [PlayerDirection] ld a, [PlayerDirection]
@ -113,6 +113,9 @@ TreeRelativeLocationTable: ; 8c938
; 8c940 ; 8c940
OWCutAnimation: ; 8c940 OWCutAnimation: ; 8c940
; Animation index in e
; 0: Split tree in half
; 1: Mow the lawn
ld a, e ld a, e
and $1 and $1
ld [wJumptableIndex], a ld [wJumptableIndex], a

View File

@ -114,9 +114,9 @@ LoadMapPart:: ; 217a
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill call ByteFill
ld a, BANK(Function4d15b) ld a, BANK(_LoadMapPart)
rst Bankswitch rst Bankswitch
call Function4d15b call _LoadMapPart
pop af pop af
rst Bankswitch rst Bankswitch
@ -124,38 +124,40 @@ LoadMapPart:: ; 217a
; 2198 ; 2198
LoadMetatiles:: ; 2198 LoadMetatiles:: ; 2198
; de <- wOverworldMapAnchor ; de <- wOverworldMapAnchor
ld a, [wOverworldMapAnchor] ld a, [wOverworldMapAnchor]
ld e, a ld e, a
ld a, [wOverworldMapAnchor + 1] ld a, [wOverworldMapAnchor + 1]
ld d, a ld d, a
ld hl, wMisc ld hl, wMisc
ld b, 5 ; SCREEN_WIDTH / 4 ld b, WMISC_HEIGHT / 4 ; 5
.loop .row
push de push de
push hl push hl
ld c, 6 ; SCREEN_HEIGHT / 3 ld c, WMISC_WIDTH / 4 ; 6
.loop2 .col
push de push de
push hl push hl
; Load the current map block.
; If the current map block is a border block, load the border block.
ld a, [de] ld a, [de]
and a and a
jr nz, .ok jr nz, .ok
ld a, [MapBorderBlock] ld a, [MapBorderBlock]
.ok .ok
; Load the current wMisc address into de.
ld e, l ld e, l
ld d, h ld d, h
; double a, load hl <- a, multiply hl by 8 ; Set hl to the address of the current metatile data ([TilesetBlocksAddress] + (a) tiles).
add a add a
ld l, a ld l, a
ld h, 0 ld h, 0
rept 3 rept 3
add hl,hl add hl, hl
endr endr
; hl <- hl + [TilesetBlocksAddress]
ld a, [TilesetBlocksAddress] ld a, [TilesetBlocksAddress]
add l add l
ld l, a ld l, a
@ -163,37 +165,36 @@ endr
adc h adc h
ld h, a ld h, a
; copy the 4x4 metatile
rept 3 rept 3
; copy 4 bytes from hl to de
rept 4 rept 4
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a
inc de inc de
endr endr
; next row
ld a, e ld a, e
add SCREEN_WIDTH add WMISC_WIDTH - 4
ld e, a ld e, a
jr nc, .next\@ jr nc, .next\@
inc d inc d
.next\@ .next\@
endr endr
; copy 4 more bytes from hl to de
rept 4 rept 4
ld a, [hli] ld a, [hli]
ld [de], a ld [de], a
inc de inc de
endr endr
; Next metatile
pop hl pop hl
ld de, 4 ld de, 4
add hl, de add hl, de
pop de pop de
inc de inc de
dec c dec c
jp nz, .loop2 jp nz, .col
; Next metarow
pop hl pop hl
ld de, $60 ld de, WMISC_WIDTH * 4
add hl, de add hl, de
pop de pop de
ld a, [MapWidth] ld a, [MapWidth]
@ -202,10 +203,9 @@ endr
ld e, a ld e, a
jr nc, .ok2 jr nc, .ok2
inc d inc d
.ok2 .ok2
dec b dec b
jp nz, .loop jp nz, .row
ret ret
; 222a ; 222a
@ -223,7 +223,7 @@ CheckWarpTile:: ; 2238
ret nc ret nc
push bc push bc
callba Function149af callba CheckDirectionalWarp
pop bc pop bc
ret nc ret nc
@ -232,8 +232,6 @@ CheckWarpTile:: ; 2238
ret ret
; 224a ; 224a
WarpCheck:: ; 224a WarpCheck:: ; 224a
call GetDestinationWarpNumber call GetDestinationWarpNumber
ret nc ret nc
@ -242,7 +240,7 @@ WarpCheck:: ; 224a
; 2252 ; 2252
GetDestinationWarpNumber:: ; 2252 GetDestinationWarpNumber:: ; 2252
callba Function1499a callba CheckWarpCollision
ret nc ret nc
ld a, [hROMBank] ld a, [hROMBank]
@ -366,8 +364,6 @@ CopyWarpData:: ; 22a7
ret ret
; 22ee ; 22ee
CheckOutdoorMap:: ; 22ee CheckOutdoorMap:: ; 22ee
cp ROUTE cp ROUTE
ret z ret z
@ -395,7 +391,6 @@ Function2300:: ; unreferenced
ret ret
; 2309 ; 2309
LoadMapAttributes:: ; 2309 LoadMapAttributes:: ; 2309
call CopyMapHeaders call CopyMapHeaders
call SwitchToMapScriptHeaderBank call SwitchToMapScriptHeaderBank
@ -503,7 +498,6 @@ GetMapConnections:: ; 2368
ret ret
; 23a3 ; 23a3
GetMapConnection:: ; 23a3 GetMapConnection:: ; 23a3
; Load map connection struct at hl into de. ; Load map connection struct at hl into de.
ld c, SouthMapConnection - NorthMapConnection ld c, SouthMapConnection - NorthMapConnection
@ -516,7 +510,6 @@ GetMapConnection:: ; 23a3
ret ret
; 23ac ; 23ac
ReadMapTriggers:: ; 23ac ReadMapTriggers:: ; 23ac
ld a, [hli] ; trigger count ld a, [hli] ; trigger count
ld c, a ld c, a
@ -749,8 +742,6 @@ LoadBlockData:: ; 24cd
ret ret
; 24e4 ; 24e4
ChangeMap:: ; 24e4 ChangeMap:: ; 24e4
ld a, [hROMBank] ld a, [hROMBank]
push af push af
@ -801,8 +792,6 @@ endr
ret ret
; 2524 ; 2524
FillMapConnections:: ; 2524 FillMapConnections:: ; 2524
; North ; North
@ -901,7 +890,6 @@ FillMapConnections:: ; 2524
ret ret
; 25d3 ; 25d3
FillNorthConnectionStrip:: FillNorthConnectionStrip::
FillSouthConnectionStrip:: ; 25d3 FillSouthConnectionStrip:: ; 25d3
@ -938,7 +926,6 @@ FillSouthConnectionStrip:: ; 25d3
ret ret
; 25f6 ; 25f6
FillWestConnectionStrip:: FillWestConnectionStrip::
FillEastConnectionStrip:: ; 25f6 FillEastConnectionStrip:: ; 25f6
@ -983,7 +970,6 @@ LoadMapStatus:: ; 261b
ret ret
; 261f ; 261f
CallScript:: ; 261f CallScript:: ; 261f
; Call a script at a:hl. ; Call a script at a:hl.
@ -1138,7 +1124,6 @@ GetMovementData:: ; 26c7
ret ret
; 26d4 ; 26d4
GetScriptByte:: ; 0x26d4 GetScriptByte:: ; 0x26d4
; Return byte at ScriptBank:ScriptPos in a. ; Return byte at ScriptBank:ScriptPos in a.
@ -1170,7 +1155,6 @@ GetScriptByte:: ; 0x26d4
ret ret
; 0x26ef ; 0x26ef
ObjectEvent:: ; 0x26ef ObjectEvent:: ; 0x26ef
jumptextfaceplayer ObjectEventText jumptextfaceplayer ObjectEventText
; 0x26f2 ; 0x26f2
@ -1180,7 +1164,6 @@ ObjectEventText::
db "@" db "@"
; 0x26f7 ; 0x26f7
BGEvent:: ; 26f7 BGEvent:: ; 26f7
jumptext BGEventText jumptext BGEventText
; 26fa ; 26fa
@ -1190,7 +1173,6 @@ BGEventText:: ; 26fa
db "@" db "@"
; 26ff ; 26ff
CoordinatesEvent:: ; 26ff CoordinatesEvent:: ; 26ff
jumptext CoordinatesEventText jumptext CoordinatesEventText
; 2702 ; 2702
@ -1200,7 +1182,6 @@ CoordinatesEventText:: ; 2702
db "@" db "@"
; 2707 ; 2707
CheckObjectMask:: ; 2707 CheckObjectMask:: ; 2707
ld a, [hMapObjectIndexBuffer] ld a, [hMapObjectIndexBuffer]
ld e, a ld e, a
@ -1231,7 +1212,6 @@ UnmaskObject:: ; 271e
ret ret
; 272a ; 272a
ScrollMapDown:: ; 272a ScrollMapDown:: ; 272a
hlcoord 0, 0 hlcoord 0, 0
ld de, BGMapBuffer ld de, BGMapBuffer
@ -1472,7 +1452,7 @@ BufferScreen:: ; 2879
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld de, XCoord + 1 ld de, wScreenSave
ld c, $5 ld c, $5
ld b, $6 ld b, $6
.asm_2886 .asm_2886
@ -1501,9 +1481,9 @@ SaveScreen:: ; 289d
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld de, XCoord + 1 ld de, wScreenSave
ld a, [MapWidth] ld a, [MapWidth]
add $6 add 6
ld [hMapObjectIndexBuffer], a ld [hMapObjectIndexBuffer], a
ld a, [wPlayerStepDirection] ld a, [wPlayerStepDirection]
and a and a
@ -1517,7 +1497,7 @@ SaveScreen:: ; 289d
ret ret
.up .up
ld de, wdcbf ld de, wScreenSave + 6
ld a, [hMapObjectIndexBuffer] ld a, [hMapObjectIndexBuffer]
ld c, a ld c, a
ld b, $0 ld b, $0
@ -1525,26 +1505,23 @@ SaveScreen:: ; 289d
jr .vertical jr .vertical
.down .down
ld de, XCoord + 1 ld de, wScreenSave
.vertical .vertical
ld b, $6 ld b, 6
ld c, $4 ld c, 4
jr Function28f7 jr SaveScreen_LoadNeighbor
.left .left
ld de, XCoord + 2 ld de, wScreenSave + 1
inc hl inc hl
jr .horizontal jr .horizontal
.right .right
ld de, XCoord + 1 ld de, wScreenSave
.horizontal .horizontal
ld b, $5 ld b, 5
ld c, $5 ld c, 5
jr Function28f7 jr SaveScreen_LoadNeighbor
LoadNeighboringBlockData:: ; 28e3 LoadNeighboringBlockData:: ; 28e3
ld hl, wOverworldMapAnchor ld hl, wOverworldMapAnchor
@ -1552,26 +1529,26 @@ LoadNeighboringBlockData:: ; 28e3
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [MapWidth] ld a, [MapWidth]
add $6 add 6
ld [hConnectionStripLength], a ld [hConnectionStripLength], a
ld de, XCoord + 1 ld de, wScreenSave
ld b, $6 ld b, 6
ld c, $5 ld c, 5
Function28f7:: ; 28f7 SaveScreen_LoadNeighbor:: ; 28f7
.loop1 .row
push bc push bc
push hl push hl
push de push de
.loop2 .col
ld a, [de] ld a, [de]
inc de inc de
ld [hli], a ld [hli], a
dec b dec b
jr nz, .loop2 jr nz, .col
pop de pop de
ld a, e ld a, e
add $6 add 6
ld e, a ld e, a
jr nc, .okay jr nc, .okay
inc d inc d
@ -1580,11 +1557,11 @@ Function28f7:: ; 28f7
pop hl pop hl
ld a, [hConnectionStripLength] ld a, [hConnectionStripLength]
ld c, a ld c, a
ld b, $0 ld b, 0
add hl, bc add hl, bc
pop bc pop bc
dec c dec c
jr nz, .loop1 jr nz, .row
ret ret
; 2914 ; 2914
@ -1746,7 +1723,6 @@ Function29ff:: ; 29ff
ret ret
; 2a07 ; 2a07
GetFacingTileCoord:: ; 2a07 GetFacingTileCoord:: ; 2a07
; Return map coordinates in (d, e) and tile id in a ; Return map coordinates in (d, e) and tile id in a
; of the tile the player is facing. ; of the tile the player is facing.
@ -1793,7 +1769,6 @@ endr
dw TileRight dw TileRight
; 2a3c ; 2a3c
GetCoordTile:: ; 2a3c GetCoordTile:: ; 2a3c
; Get the collision byte for tile d, e ; Get the collision byte for tile d, e
call GetBlockLocation call GetBlockLocation
@ -1861,7 +1836,6 @@ GetBlockLocation:: ; 2a66
ret ret
; 2a8b ; 2a8b
CheckFacingSign:: ; 2a8b CheckFacingSign:: ; 2a8b
call GetFacingTileCoord call GetFacingTileCoord
; Load facing into b. ; Load facing into b.
@ -2002,7 +1976,6 @@ CheckStandingOnXYTrigger:: ; 2ae7
ret ret
; 2b29 ; 2b29
FadeToMenu:: ; 2b29 FadeToMenu:: ; 2b29
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
@ -2013,7 +1986,6 @@ FadeToMenu:: ; 2b29
ret ret
; 2b3c ; 2b3c
CloseSubmenu:: ; 2b3c CloseSubmenu:: ; 2b3c
call ClearBGPalettes call ClearBGPalettes
call Function2bae call Function2bae
@ -2032,14 +2004,13 @@ ExitAllMenus:: ; 2b4d
Function2b5c:: ; 2b5c Function2b5c:: ; 2b5c
ld b, SCGB_09 ld b, SCGB_09
call GetSGBLayout call GetSGBLayout
callba Function49409 callba LoadOW_BGPal7
call WaitBGMap2 call WaitBGMap2
callba FadeInPalettes callba FadeInPalettes
call EnableSpriteUpdates call EnableSpriteUpdates
ret ret
; 2b74 ; 2b74
Function2b74:: ; 0x2b74 Function2b74:: ; 0x2b74
push af push af
ld a, $1 ld a, $1
@ -2056,7 +2027,7 @@ Function2b74:: ; 0x2b74
call WaitBGMap2 call WaitBGMap2
ld b, SCGB_09 ld b, SCGB_09
call GetSGBLayout call GetSGBLayout
callba Function49409 callba LoadOW_BGPal7
call UpdateTimePals call UpdateTimePals
call DelayFrame call DelayFrame
ld a, $1 ld a, $1
@ -2078,7 +2049,7 @@ Function2bae:: ; 2bae
ld a, [MapNumber] ld a, [MapNumber]
ld c, a ld c, a
call SwitchToAnyMapBank call SwitchToAnyMapBank
callba Function8c001 callba UpdateTimeOfDayPal
call OverworldTextModeSwitch call OverworldTextModeSwitch
call LoadTileset call LoadTileset
ld a, 9 ld a, 9
@ -2090,7 +2061,6 @@ Function2bae:: ; 2bae
ret ret
; 2be5 ; 2be5
GetMapHeaderPointer:: ; 2be5 GetMapHeaderPointer:: ; 2be5
ld a, [MapGroup] ld a, [MapGroup]
ld b, a ld b, a
@ -2167,7 +2137,6 @@ GetAnyMapHeaderMember:: ; 0x2c0c
ret ret
; 0x2c1c ; 0x2c1c
SwitchToMapBank:: ; 2c1c SwitchToMapBank:: ; 2c1c
ld a, [MapGroup] ld a, [MapGroup]
ld b, a ld b, a
@ -2181,7 +2150,6 @@ SwitchToAnyMapBank:: ; 2c24
ret ret
; 2c29 ; 2c29
GetMapBank:: ; 2c29 GetMapBank:: ; 2c29
ld a, [MapGroup] ld a, [MapGroup]
ld b, a ld b, a
@ -2224,7 +2192,6 @@ SwitchToMapScriptHeaderBank:: ; 2c52
ret ret
; 2c57 ; 2c57
GetMapScriptHeaderBank:: ; 2c57 GetMapScriptHeaderBank:: ; 2c57
ld a, [MapScriptHeaderBank] ld a, [MapScriptHeaderBank]
ret ret

View File

@ -2697,7 +2697,7 @@ Function1111d7: ; 1111d7
dec hl dec hl
.asm_1111ee .asm_1111ee
ld bc, rIE ld bc, -1
.asm_1111f1 .asm_1111f1
ld a, [hli] ld a, [hli]
inc bc inc bc

618
main.asm
View File

@ -89,7 +89,7 @@ Function6473: ; 6473
ld a, VBGMap1 / $100 ld a, VBGMap1 / $100
call Function64b9 call Function64b9
call Function2e20 call Function2e20
callba Function49409 callba LoadOW_BGPal7
callba Function96a4 callba Function96a4
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ld [hCGBPalUpdate], a
@ -2078,7 +2078,8 @@ endr
ret ret
; c699 ; c699
DrawPartyMenuHPBar: ; c699 ComputeHPBarPixels: ; c699
; bc * (6 * 8) / de
ld a, b ld a, b
or c or c
jr z, .zero jr z, .zero
@ -2089,12 +2090,14 @@ DrawPartyMenuHPBar: ; c699
ld [hMultiplicand + 1], a ld [hMultiplicand + 1], a
ld a, c ld a, c
ld [hMultiplicand + 2], a ld [hMultiplicand + 2], a
ld a, $30 ld a, 6 * 8
ld [hMultiplier], a ld [hMultiplier], a
call Multiply call Multiply
; We need de to be under 256 because hDivisor is only 1 byte.
ld a, d ld a, d
and a and a
jr z, .divide jr z, .divide
; divide de and hProduct by 4
srl d srl d
rr e rr e
srl d srl d
@ -2109,22 +2112,21 @@ DrawPartyMenuHPBar: ; c699
ld [hDividend + 3], a ld [hDividend + 3], a
ld a, b ld a, b
ld [hDividend + 2], a ld [hDividend + 2], a
.divide .divide
ld a, e ld a, e
ld [hDivisor], a ld [hDivisor], a
ld b, $4 ld b, 4
call Divide call Divide
ld a, [hQuotient + 2] ld a, [hQuotient + 2]
ld e, a ld e, a
pop hl pop hl
and a and a
ret nz ret nz
ld e, $1 ld e, 1
ret ret
.zero .zero
ld e, $0 ld e, 0
ret ret
; c6e0 ; c6e0
@ -2193,13 +2195,13 @@ CheckBadge: ; c731
; Display "Badge required" text and return carry if the badge is not owned ; Display "Badge required" text and return carry if the badge is not owned
call CheckEngineFlag call CheckEngineFlag
ret nc ret nc
ld hl, BadgeRequiredText ld hl, .BadgeRequiredText
call MenuTextBoxBackup ; push text to queue call MenuTextBoxBackup ; push text to queue
scf scf
ret ret
; c73d ; c73d
BadgeRequiredText: ; c73d .BadgeRequiredText: ; c73d
; Sorry! A new BADGE ; Sorry! A new BADGE
; is required. ; is required.
text_jump _BadgeRequiredText text_jump _BadgeRequiredText
@ -2252,12 +2254,13 @@ CheckPartyMove: ; c742
; c779 ; c779
FieldMoveFailed: ; c779 FieldMoveFailed: ; c779
ld hl, UnknownText_0xc780 ld hl, .CantUseHere
call MenuTextBoxBackup call MenuTextBoxBackup
ret ret
; c780 ; c780
UnknownText_0xc780: ; 0xc780 .CantUseHere: ; 0xc780
; Can't use that here.
text_jump UnknownText_0x1c05c8 text_jump UnknownText_0x1c05c8
db "@" db "@"
; 0xc785 ; 0xc785
@ -2274,9 +2277,10 @@ CutFunction: ; c785
; c796 ; c796
.Jumptable: ; c796 (3:4796) .Jumptable: ; c796 (3:4796)
dw .CheckAble jumptable_start
dw .DoCut jumptable .CheckAble
dw .FailCut jumptable .DoCut
jumptable .FailCut
.CheckAble: ; c79c (3:479c) .CheckAble: ; c79c (3:479c)
ld de, ENGINE_HIVEBADGE ld de, ENGINE_HIVEBADGE
@ -2286,9 +2290,11 @@ CutFunction: ; c785
jr c, .nothingtocut jr c, .nothingtocut
ld a, $1 ld a, $1
ret ret
.nohivebadge .nohivebadge
ld a, $80 ld a, $80
ret ret
.nothingtocut .nothingtocut
ld a, $2 ld a, $2
ret ret
@ -2300,45 +2306,51 @@ CutFunction: ; c785
ret ret
.FailCut: ; c7bb (3:47bb) .FailCut: ; c7bb (3:47bb)
ld hl, UnknownText_0xc7c9 ld hl, Text_NothingToCut
call MenuTextBoxBackup call MenuTextBoxBackup
ld a, $80 ld a, $80
ret ret
UnknownText_0xc7c4: ; 0xc7c4 Text_UsedCut: ; 0xc7c4
; used CUT! ; used CUT!
text_jump UnknownText_0x1c05dd text_jump UnknownText_0x1c05dd
db "@" db "@"
; 0xc7c9 ; 0xc7c9
UnknownText_0xc7c9: ; 0xc7c9 Text_NothingToCut: ; 0xc7c9
; There's nothing to CUT here. ; There's nothing to CUT here.
text_jump UnknownText_0x1c05ec text_jump UnknownText_0x1c05ec
db "@" db "@"
; 0xc7ce ; 0xc7ce
CheckMapForSomethingToCut: ; c7ce CheckMapForSomethingToCut: ; c7ce
; Does the collision data of the facing tile permit cutting?
call GetFacingTileCoord call GetFacingTileCoord
ld c, a ld c, a
push de push de
callba CheckCutCollision callba CheckCutCollision
pop de pop de
jr nc, .fail jr nc, .fail
; Get the location of the current block in OverworldMap.
call GetBlockLocation call GetBlockLocation
ld c, [hl] ld c, [hl]
; See if that block contains something that can be cut.
push hl push hl
ld hl, CutTreeBlockPointers ld hl, CutTreeBlockPointers
call CheckOverworldTileArrays call CheckOverworldTileArrays
pop hl pop hl
jr nc, .fail jr nc, .fail
; Back up the OverworldMap address to Buffer3
ld a, l ld a, l
ld [wd1ec], a ld [Buffer3], a
ld a, h ld a, h
ld [wd1ed], a ld [Buffer4], a
; Back up the replacement tile to Buffer5
ld a, b ld a, b
ld [wd1ee], a ld [Buffer5], a
; Back up the animation index to Buffer6
ld a, c ld a, c
ld [wd1ef], a ld [Buffer6], a
xor a xor a
ret ret
@ -2353,7 +2365,7 @@ Script_CutFromMenu: ; c7fe
Script_Cut: ; 0xc802 Script_Cut: ; 0xc802
callasm GetPartyNick callasm GetPartyNick
writetext UnknownText_0xc7c4 writetext Text_UsedCut
reloadmappart reloadmappart
callasm CutDownTreeOrGrass callasm CutDownTreeOrGrass
closetext closetext
@ -2361,18 +2373,18 @@ Script_Cut: ; 0xc802
; 0xc810 ; 0xc810
CutDownTreeOrGrass: ; c810 CutDownTreeOrGrass: ; c810
ld hl, wd1ec ld hl, Buffer3 ; OverworldMapTile
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [wd1ee] ld a, [Buffer5] ; ReplacementTile
ld [hl], a ld [hl], a
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
call UpdateSprites call UpdateSprites
call DelayFrame call DelayFrame
ld a, [wd1ef] ld a, [Buffer6] ; Animation type
ld e, a ld e, a
callba OWCutAnimation callba OWCutAnimation
call BufferScreen call BufferScreen
@ -2384,22 +2396,32 @@ CutDownTreeOrGrass: ; c810
; c840 ; c840
CheckOverworldTileArrays: ; c840 CheckOverworldTileArrays: ; c840
; Input: c contains the tile you're facing
; Output: Replacement tile in b and effect on wild encounters in c, plus carry set.
; Carry is not set if the facing tile cannot be replaced, or if the tileset
; does not contain a tile you can replace.
; Dictionary lookup for pointer to tile replacement table
push bc push bc
ld a, [wTileset] ld a, [wTileset]
ld de, 3 ld de, 3
call IsInArray call IsInArray
pop bc pop bc
jr nc, .nope jr nc, .nope
; Load the pointer
inc hl inc hl
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
; Look up the tile you're facing
ld de, 3 ld de, 3
ld a, c ld a, c
call IsInArray call IsInArray
jr nc, .nope jr nc, .nope
; Load the replacement to b
inc hl inc hl
ld b, [hl] ld b, [hl]
; Load the animation type parameter to c
inc hl inc hl
ld c, [hl] ld c, [hl]
scf scf
@ -2412,16 +2434,16 @@ CheckOverworldTileArrays: ; c840
CutTreeBlockPointers: ; c862 CutTreeBlockPointers: ; c862
; Which tileset are we in? ; Which tileset are we in?
dbw TILESET_JOHTO_1, .one dbw TILESET_JOHTO_1, .johto1
dbw TILESET_JOHTO_2, .two dbw TILESET_JOHTO_2, .johto2
dbw TILESET_KANTO, .three dbw TILESET_KANTO, .kanto
dbw TILESET_PARK, .twentyfive dbw TILESET_PARK, .park
dbw TILESET_ILEX_FOREST, .thirtyone dbw TILESET_ILEX_FOREST, .ilex
db -1 db -1
; c872 ; c872
.one: ; Johto OW .johto1: ; Johto OW
; Which meta tile are we facing, which should we replace it with, and does it affect encounters? ; Which meta tile are we facing, which should we replace it with, and which animation?
db $03, $02, $01 ; grass db $03, $02, $01 ; grass
db $5b, $3c, $00 ; tree db $5b, $3c, $00 ; tree
db $5f, $3d, $00 ; tree db $5f, $3d, $00 ; tree
@ -2430,12 +2452,12 @@ CutTreeBlockPointers: ; c862
db -1 db -1
; c882 ; c882
.two: ; Goldenrod area .johto2: ; Goldenrod area
db $03, $02, $01 ; grass db $03, $02, $01 ; grass
db -1 db -1
; c886 ; c886
.three: ; Kanto OW .kanto: ; Kanto OW
db $0b, $0a, $01 ; grass db $0b, $0a, $01 ; grass
db $32, $6d, $00 ; tree db $32, $6d, $00 ; tree
db $33, $6c, $00 ; tree db $33, $6c, $00 ; tree
@ -2445,35 +2467,35 @@ CutTreeBlockPointers: ; c862
db -1 db -1
; c899 ; c899
.twentyfive: ; National Park .park: ; National Park
db $13, $03, $01 ; grass db $13, $03, $01 ; grass
db $03, $04, $01 ; grass db $03, $04, $01 ; grass
db -1 db -1
; c8a0 ; c8a0
.thirtyone: ; Ilex Forest .ilex: ; Ilex Forest
db $0f, $17, $00 db $0f, $17, $00
db -1 db -1
; c8a4 ; c8a4
WhirlpoolBlockPointers: ; c8a4 WhirlpoolBlockPointers: ; c8a4
dbw TILESET_JOHTO_1, .one dbw TILESET_JOHTO_1, .johto
db -1 db -1
; c8a8 ; c8a8
.one: ; c8a8 .johto: ; c8a8
db $07, $36, $00 db $07, $36, $00
db -1 db -1
; c8ac ; c8ac
Functionc8ac: ; c8ac OWFlash: ; c8ac
call Functionc8b5 call .CheckUseFlash
and $7f and $7f
ld [wd0ec], a ld [wd0ec], a
ret ret
; c8b5 ; c8b5
Functionc8b5: ; c8b5 .CheckUseFlash: ; c8b5
; Flash ; Flash
ld de, ENGINE_ZEPHYRBADGE ld de, ENGINE_ZEPHYRBADGE
callba CheckBadge callba CheckBadge
@ -2482,10 +2504,9 @@ Functionc8b5: ; c8b5
callba SpecialAerodactylChamber callba SpecialAerodactylChamber
pop hl pop hl
jr c, .useflash jr c, .useflash
ld a, [wd847] ld a, [wTimeOfDayPalset]
cp -1 cp %11111111 ; 3, 3, 3, 3
jr nz, .notadarkcave jr nz, .notadarkcave
.useflash .useflash
call UseFlash call UseFlash
ld a, $81 ld a, $81
@ -2522,11 +2543,11 @@ UnknownText_0xc8f3: ; 0xc8f3
ld de, SFX_FLASH ld de, SFX_FLASH
call PlaySFX call PlaySFX
call WaitSFX call WaitSFX
ld hl, UnknownText_0xc908 ld hl, .BlankText
ret ret
; c908 ; c908
UnknownText_0xc908: ; 0xc908 .BlankText: ; 0xc908
db "@" db "@"
; 0xc909 ; 0xc909
@ -3268,7 +3289,7 @@ Functioncd1d: ; cd1d
ld hl, PartySpecies ld hl, PartySpecies
add hl, de add hl, de
ld a, [hl] ld a, [hl]
ld [wd1ef], a ld [Buffer6], a
call GetPartyNick call GetPartyNick
ret ret
; cd29 ; cd29
@ -3280,7 +3301,7 @@ Script_StrengthFromMenu: ; 0xcd29
Script_UsedStrength: ; 0xcd2d Script_UsedStrength: ; 0xcd2d
callasm Functioncd12 callasm Functioncd12
writetext UnknownText_0xcd41 writetext UnknownText_0xcd41
copybytetovar wd1ef copybytetovar Buffer6
cry 0 cry 0
pause 3 pause 3
writetext UnknownText_0xcd46 writetext UnknownText_0xcd46
@ -3438,13 +3459,13 @@ TryWhirlpoolMenu: ; cdde
pop hl pop hl
jr nc, .failed jr nc, .failed
ld a, l ld a, l
ld [wd1ec], a ld [Buffer3], a
ld a, h ld a, h
ld [wd1ed], a ld [Buffer4], a
ld a, b ld a, b
ld [wd1ee], a ld [Buffer5], a
ld a, c ld a, c
ld [wd1ef], a ld [Buffer6], a
xor a xor a
ret ret
@ -3467,16 +3488,16 @@ Script_UsedWhirlpool: ; 0xce0f
; 0xce1d ; 0xce1d
DisappearWhirlpool: ; ce1d DisappearWhirlpool: ; ce1d
ld hl, wd1ec ld hl, Buffer3
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [wd1ee] ld a, [Buffer5]
ld [hl], a ld [hl], a
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
call OverworldTextModeSwitch call OverworldTextModeSwitch
ld a, [wd1ef] ld a, [Buffer6]
ld e, a ld e, a
callba PlayWhirlpoolSound callba PlayWhirlpoolSound
call BufferScreen call BufferScreen
@ -3816,7 +3837,7 @@ FishFunction: ; cf8e
.FishGotSomething: ; cff4 .FishGotSomething: ; cff4
ld a, $1 ld a, $1
ld [wd1ef], a ld [Buffer6], a
ld hl, Script_GotABite ld hl, Script_GotABite
call QueueScript call QueueScript
ld a, $81 ld a, $81
@ -3825,7 +3846,7 @@ FishFunction: ; cf8e
.FishNoBite: ; d002 .FishNoBite: ; d002
ld a, $2 ld a, $2
ld [wd1ef], a ld [Buffer6], a
ld hl, Script_NotEvenANibble ld hl, Script_NotEvenANibble
call QueueScript call QueueScript
ld a, $81 ld a, $81
@ -3834,7 +3855,7 @@ FishFunction: ; cf8e
.FailFish: ; d010 .FailFish: ; d010
ld a, $0 ld a, $0
ld [wd1ef], a ld [Buffer6], a
ld hl, Script_NotEvenANibble2 ld hl, Script_NotEvenANibble2
call QueueScript call QueueScript
ld a, $81 ld a, $81
@ -4160,7 +4181,7 @@ AskCutScript: ; 0xd1a9
ld [ScriptVar], a ld [ScriptVar], a
call CheckMapForSomethingToCut call CheckMapForSomethingToCut
ret c ret c
ld a, 1 ld a, TRUE
ld [ScriptVar], a ld [ScriptVar], a
ret ret
; d1c8 ; d1c8
@ -5077,439 +5098,7 @@ UpdateOverworldMap: ; d536 (3:5536)
inc [hl] inc [hl]
ret ret
_AnimateHPBar: ; d627 INCLUDE "engine/anim_hp_bar.asm"
call Functiond65f
jr c, .do_player
call Functiond670
.enemy_loop
push bc
push hl
call Functiond6e2
pop hl
pop bc
push af
push bc
push hl
call Functiond730
call Functiond7c9
pop hl
pop bc
pop af
jr nc, .enemy_loop
ret
.do_player
call Functiond670
.player_loop
push bc
push hl
call Functiond6f5
pop hl
pop bc
ret c
push af
push bc
push hl
call Functiond749
call Functiond7c9
pop hl
pop bc
pop af
jr nc, .player_loop
ret
; d65f
Functiond65f: ; d65f
ld a, [Buffer2]
and a
jr nz, .player
ld a, [Buffer1]
cp $30
jr nc, .player
and a
ret
.player
scf
ret
; d670
Functiond670: ; d670
push hl
ld hl, Buffer1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
pop hl
call DrawPartyMenuHPBar
ld a, e
ld [wd1f1], a
ld a, [wd1ee]
ld c, a
ld a, [wd1ef]
ld b, a
ld a, [Buffer1]
ld e, a
ld a, [Buffer2]
ld d, a
call DrawPartyMenuHPBar
ld a, e
ld [wd1f2], a
push hl
ld hl, wd1ec
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
pop hl
ld a, e
sub c
ld e, a
ld a, d
sbc b
ld d, a
jr c, .asm_d6c1
ld a, [wd1ec]
ld [wd1f5], a
ld a, [wd1ee]
ld [wd1f6], a
ld bc, 1
jr .asm_d6d9
.asm_d6c1
ld a, [wd1ec]
ld [wd1f6], a
ld a, [wd1ee]
ld [wd1f5], a
ld a, e
xor $ff
inc a
ld e, a
ld a, d
xor $ff
ld d, a
ld bc, rIE
.asm_d6d9
ld a, d
ld [wd1f3], a
ld a, e
ld [wd1f4], a
ret
; d6e2
Functiond6e2: ; d6e2
ld hl, wd1f1
ld a, [wd1f2]
cp [hl]
jr nz, .asm_d6ed
scf
ret
.asm_d6ed
ld a, c
add [hl]
ld [hl], a
call Functiond839
and a
ret
; d6f5
Functiond6f5: ; d6f5
.asm_d6f5
ld hl, wd1ec
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, e
cp [hl]
jr nz, .asm_d707
inc hl
ld a, d
cp [hl]
jr nz, .asm_d707
scf
ret
.asm_d707
ld l, e
ld h, d
add hl, bc
ld a, l
ld [wd1ec], a
ld a, h
ld [wd1ed], a
push hl
push de
push bc
ld hl, Buffer1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
call DrawPartyMenuHPBar
pop bc
pop de
pop hl
ld a, e
ld hl, wd1f1
cp [hl]
jr z, .asm_d6f5
ld [hl], a
and a
ret
; d730
Functiond730: ; d730
call Functiond784
ld d, $6
ld a, [wd10a]
and $1
ld b, a
ld a, [wd1f1]
ld e, a
ld c, a
push de
call Functiond771
pop de
call Functiond7b4
ret
; d749
Functiond749: ; d749
call Functiond784
ld a, [wd1ec]
ld c, a
ld a, [wd1ed]
ld b, a
ld a, [Buffer1]
ld e, a
ld a, [Buffer2]
ld d, a
call DrawPartyMenuHPBar
ld c, e
ld d, $6
ld a, [wd10a]
and $1
ld b, a
push de
call Functiond771
pop de
call Functiond7b4
ret
; d771
Functiond771: ; d771
ld a, [wd10a]
cp $2
jr nz, .asm_d780
ld a, $28
add l
ld l, a
ld a, $0
adc h
ld h, a
.asm_d780
call DrawBattleHPBar
ret
; d784
Functiond784: ; d784
ld a, [wd10a]
and a
ret z
cp $1
jr z, .load_15
ld de, $16
jr .loaded_de
.load_15
ld de, $15
.loaded_de
push hl
add hl, de
ld a, " "
rept 2
ld [hli], a
endr
ld [hld], a
dec hl
ld a, [wd1ec]
ld [StringBuffer2 + 1], a
ld a, [wd1ed]
ld [StringBuffer2], a
ld de, StringBuffer2
lb bc, 2, 3
call PrintNum
pop hl
ret
; d7b4
Functiond7b4: ; d7b4
ld a, [hCGB]
and a
ret z
ld hl, wd1f0
call SetHPPal
ld a, [wd1f0]
ld c, a
callba Function8c43
ret
; d7c9
Functiond7c9: ; d7c9
ld a, [hCGB]
and a
jr nz, .cgb
call DelayFrame
call DelayFrame
ret
.cgb
ld a, [wd10a]
and a
jr z, .load_0
cp $1
jr z, .load_1
ld a, [CurPartyMon]
cp $3
jr nc, .c_is_1
ld c, $0
jr .c_is_0
.c_is_1
ld c, $1
.c_is_0
push af
cp $2
jr z, .skip_delay
cp $5
jr z, .skip_delay
ld a, $2
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
.skip_delay
ld a, $1
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
pop af
cp $2
jr z, .two_frames
cp $5
jr z, .two_frames
ret
.two_frames
inc c
ld a, $2
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
ld a, $1
ld [hBGMapMode], a
ld a, c
ld [hBGMapThird], a
call DelayFrame
ret
.load_0
ld c, $0
jr .finish
.load_1
ld c, $1
.finish
call DelayFrame
ld a, c
ld [hBGMapThird], a
call DelayFrame
ret
; d839
Functiond839: ; d839
ld a, [Buffer1]
ld c, a
ld b, $0
ld hl, 0
ld a, [wd1f1]
cp $30
jr nc, .coppy_buffer
and a
jr z, .return_zero
call AddNTimes
ld b, $0
.loop
ld a, l
sub $30
ld l, a
ld a, h
sbc $0
ld h, a
jr c, .done
inc b
jr .loop
.done
push bc
ld bc, $80
add hl, bc
pop bc
ld a, l
sub $30
ld l, a
ld a, h
sbc $0
ld h, a
jr c, .no_carry
inc b
.no_carry
ld a, [wd1f5]
cp b
jr nc, .finish
ld a, [wd1f6]
cp b
jr c, .finish
ld a, b
.finish
ld [wd1ec], a
ret
.return_zero
xor a
ld [wd1ec], a
ret
.coppy_buffer
ld a, [Buffer1]
ld [wd1ec], a
ret
; d88c
TryAddMonToParty: ; d88c TryAddMonToParty: ; d88c
; Check if to copy wild Pkmn or generate new Pkmn ; Check if to copy wild Pkmn or generate new Pkmn
@ -8380,7 +7969,8 @@ Function140ed:: ; 140ed
INCLUDE "engine/overworld.asm" INCLUDE "engine/overworld.asm"
Function1499a:: ; 1499a CheckWarpCollision:: ; 1499a
; Is this tile a warp?
ld a, [PlayerNextTile] ld a, [PlayerNextTile]
cp $60 cp $60
jr z, .warp jr z, .warp
@ -8397,15 +7987,17 @@ Function1499a:: ; 1499a
ret ret
; 149af ; 149af
Function149af:: ; 149af CheckDirectionalWarp:: ; 149af
; If this is a directional warp, clear carry (press the designated button to warp).
; Else, set carry (immediate warp).
ld a, [PlayerNextTile] ld a, [PlayerNextTile]
cp $70 cp $70 ; Warp on down
jr z, .not_warp jr z, .not_warp
cp $76 cp $76 ; Warp on left
jr z, .not_warp jr z, .not_warp
cp $78 cp $78 ; Warp on up
jr z, .not_warp jr z, .not_warp
cp $7e cp $7e ; Warp on right
jr z, .not_warp jr z, .not_warp
scf scf
ret ret
@ -8415,7 +8007,7 @@ Function149af:: ; 149af
ret ret
; 149c6 ; 149c6
CheckWarpCollision: ; 149c6 CheckWarpFacingDown: ; 149c6
ld de, 1 ld de, 1
ld hl, .blocks ld hl, .blocks
ld a, [PlayerNextTile] ld a, [PlayerNextTile]
@ -11508,7 +11100,7 @@ Function49351: ; 49351 (12:5351)
ld a, $5 ; BANK(UnknBGPals) ld a, $5 ; BANK(UnknBGPals)
call FarCopyWRAM call FarCopyWRAM
ld de, UnknBGPals + $38 ld de, UnknBGPals + $38
ld hl, Palette_49418 ld hl, Palette_TextBG7
ld bc, $8 ld bc, $8
ld a, $5 ; BANK(UnknBGPals) ld a, $5 ; BANK(UnknBGPals)
call FarCopyWRAM call FarCopyWRAM
@ -11587,8 +11179,8 @@ Palette_493e1: ; 493e1
RGB 00, 00, 00 RGB 00, 00, 00
; 49409 ; 49409
Function49409:: ; 49409 LoadOW_BGPal7:: ; 49409
ld hl, Palette_49418 ld hl, Palette_TextBG7
ld de, UnknBGPals + 8 * 7 ld de, UnknBGPals + 8 * 7
ld bc, 8 ld bc, 8
ld a, $5 ld a, $5
@ -11596,7 +11188,7 @@ Function49409:: ; 49409
ret ret
; 49418 ; 49418
Palette_49418: ; 49418 Palette_TextBG7: ; 49418
RGB 31, 31, 31 RGB 31, 31, 31
RGB 08, 19, 28 RGB 08, 19, 28
RGB 05, 05, 16 RGB 05, 05, 16
@ -12400,23 +11992,23 @@ CheckSave:: ; 4cffe
INCLUDE "engine/map_triggers.asm" INCLUDE "engine/map_triggers.asm"
Function4d15b:: ; 4d15b _LoadMapPart:: ; 4d15b
ld hl, wc608 ld hl, wMisc
ld a, [wMetatileStandingY] ld a, [wMetatileStandingY]
and a and a
jr z, .skip jr z, .top_row
ld bc, $30 ld bc, WMISC_WIDTH * 2
add hl, bc add hl, bc
.skip .top_row
ld a, [wMetatileStandingX] ld a, [wMetatileStandingX]
and a and a
jr z, .next_dw jr z, .left_column
rept 2 rept 2
inc hl inc hl
endr endr
.next_dw .left_column
decoord 0, 0 decoord 0, 0
ld b, SCREEN_HEIGHT ld b, SCREEN_HEIGHT
.loop .loop
@ -14362,7 +13954,7 @@ DrawHP: ; 50b10
ld c, e ld c, e
.asm_50b41 .asm_50b41
predef DrawPartyMenuHPBar predef ComputeHPBarPixels
ld a, 6 ld a, 6
ld d, a ld d, a
ld c, a ld c, a
@ -15065,7 +14657,7 @@ ENDM
_SwitchPartyMons: _SwitchPartyMons:
ld a, [wd0e3] ld a, [wd0e3]
dec a dec a
ld [wd1ec], a ld [Buffer3], a
ld b, a ld b, a
ld a, [MenuSelection2] ld a, [MenuSelection2]
dec a dec a
@ -15073,7 +14665,7 @@ _SwitchPartyMons:
cp b cp b
jr z, .skip jr z, .skip
call .SwapMonAndMail call .SwapMonAndMail
ld a, [wd1ec] ld a, [Buffer3]
call .ClearSprite call .ClearSprite
ld a, [Buffer2] ; wd1eb (aliases: MovementType) ld a, [Buffer2] ; wd1eb (aliases: MovementType)
call .ClearSprite call .ClearSprite

View File

@ -49,7 +49,7 @@ Function17a6a8: ; 17a6a8 (5e:66a8)
call Function17ac0c call Function17ac0c
callba Function104000 callba Function104000
call Function17abcf call Function17abcf
callba Function49409 callba LoadOW_BGPal7
callba Function49420 callba Function49420
call SetPalettes call SetPalettes
call DelayFrame call DelayFrame

View File

@ -428,7 +428,7 @@ Function1002dc: ; 1002dc
; 1002ed ; 1002ed
Function1002ed: ; 1002ed Function1002ed: ; 1002ed
callba Function49409 callba LoadOW_BGPal7
callba Function96a4 callba Function96a4
ld a, $1 ld a, $1
ld [hCGBPalUpdate], a ld [hCGBPalUpdate], a

View File

@ -997,7 +997,7 @@ FlickeringCaveEntrancePalette: ; fc71e
cp %11100100 cp %11100100
ret nz ret nz
; We only want to be here if we're in a dark cave. ; We only want to be here if we're in a dark cave.
ld a, [wd847] ld a, [wTimeOfDayPalset]
cp $ff ; 3,3,3,3 cp $ff ; 3,3,3,3
ret nz ret nz

View File

@ -548,7 +548,7 @@ wBT_OTTemp:: battle_tower_struct wBT_OTTemp
hall_of_fame wHallOfFameTemp hall_of_fame wHallOfFameTemp
ds wHallOfFameTemp - @ ds wHallOfFameTemp - @
wMisc:: ; ds $28 * 6 wMisc:: ; ds (SCREEN_WIDTH + 4) * (SCREEN_HEIGHT + 2)
wBattle:: wBattle::
wc608:: wc608::
@ -2560,8 +2560,8 @@ TimeOfDayPal:: ; d841
ds 1 ds 1
ds 4 ds 4
; d846 ; d846
wd846:: ds 1 wTimeOfDayPalFlags:: ds 1
wd847:: ds 1 wTimeOfDayPalset:: ds 1
CurTimeOfDay:: ; d848 CurTimeOfDay:: ; d848
ds 1 ds 1
@ -2949,10 +2949,7 @@ YCoord:: ; dcb7
ds 1 ; current y coordinate relative to top-left corner of current map ds 1 ; current y coordinate relative to top-left corner of current map
XCoord:: ; dcb8 XCoord:: ; dcb8
ds 1 ; current x coordinate relative to top-left corner of current map ds 1 ; current x coordinate relative to top-left corner of current map
wScreenSave:: ds 6 * 5
ds 6
wdcbf:: ds 1
ds 23
wMapDataEnd:: wMapDataEnd::