From c635e30777ba57e3fd4249862fd562936d0d47bd Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 14 Dec 2015 11:12:18 -0500 Subject: [PATCH] map setup and warps --- battle/core.asm | 32 +- constants/map_setup_constants.asm | 2 +- constants/misc_constants.asm | 2 + data/sprite_engine.asm | 4 +- engine/anim_hp_bar.asm | 430 +++++++++++++++++++++ engine/battle_start.asm | 4 +- engine/link.asm | 2 +- engine/map_objects.asm | 2 +- engine/map_setup.asm | 20 +- engine/party_menu.asm | 2 +- engine/predef.asm | 2 +- engine/sprite_anims.asm | 2 +- engine/sprites.asm | 2 +- engine/startmenu.asm | 2 +- engine/stats_screen.asm | 2 +- engine/timeofdaypals.asm | 28 +- engine/warp_connection.asm | 4 +- event/field_moves.asm | 17 +- home/map.asm | 129 +++---- lib/mobile/main.asm | 2 +- main.asm | 618 +++++------------------------- misc/crystal_misc.asm | 2 +- misc/mobile_40.asm | 2 +- tilesets/animations.asm | 2 +- wram.asm | 11 +- 25 files changed, 657 insertions(+), 668 deletions(-) create mode 100755 engine/anim_hp_bar.asm diff --git a/battle/core.asm b/battle/core.asm index dd01268f6..926b7681c 100644 --- a/battle/core.asm +++ b/battle/core.asm @@ -1889,26 +1889,26 @@ SubtractHP: ; 3cc45 .ok inc hl ld a, [hl] - ld [wd1ec], a + ld [Buffer3], a sub c ld [hld], a - ld [wd1ee], a + ld [Buffer5], a ld a, [hl] - ld [wd1ed], a + ld [Buffer4], a sbc b ld [hl], a - ld [wd1ef], a + ld [Buffer6], a ret nc - ld a, [wd1ec] + ld a, [Buffer3] ld c, a - ld a, [wd1ed] + ld a, [Buffer4] ld b, a xor a ld [hli], a ld [hl], a - ld [wd1ee], a - ld [wd1ef], a + ld [Buffer5], a + ld [Buffer6], a ret ; 3cc76 @@ -4508,13 +4508,13 @@ HandleHPHealingItem: ; 3dd2f .go push bc ld a, [de] - ld [wd1ec], a + ld [Buffer3], a add a ld c, a dec de ld a, [de] inc de - ld [wd1ed], a + ld [Buffer4], a adc a ld b, a ld a, b @@ -4539,12 +4539,12 @@ HandleHPHealingItem: ; 3dd2f ld [Buffer1], a ld a, [de] add c - ld [wd1ee], a + ld [Buffer5], a ld c, a dec de ld a, [de] adc $0 - ld [wd1ef], a + ld [Buffer6], a ld b, a ld a, [hld] cp c @@ -4552,15 +4552,15 @@ HandleHPHealingItem: ; 3dd2f sbc b jr nc, .okay ld a, [hli] - ld [wd1ef], a + ld [Buffer6], a ld a, [hl] - ld [wd1ee], a + ld [Buffer5], a .okay - ld a, [wd1ef] + ld a, [Buffer6] ld [de], a inc de - ld a, [wd1ee] + ld a, [Buffer5] ld [de], a ld a, [hBattleTurn] ld [wd10a], a diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm index cc81a15cc..f739830f0 100644 --- a/constants/map_setup_constants.asm +++ b/constants/map_setup_constants.asm @@ -61,4 +61,4 @@ const_value SET $f1 const map_keep_palettes ; 2b const map_text_scroll_off ; 2c const map_stop_script ; 2d -map_end_setup_script EQU -1 +map_end EQU -1 diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index 3bc7024ab..4787f97ef 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -93,6 +93,8 @@ SCREEN_HEIGHT_PX EQU SCREEN_HEIGHT * 8 BG_MAP_WIDTH EQU 32 BG_MAP_HEIGHT EQU 32 +WMISC_WIDTH EQU 6 * 4 +WMISC_HEIGHT EQU 5 * 4 TILE_WIDTH EQU 8 diff --git a/data/sprite_engine.asm b/data/sprite_engine.asm index 6decfc79a..7c2854cdd 100755 --- a/data/sprite_engine.asm +++ b/data/sprite_engine.asm @@ -36,7 +36,7 @@ SpriteAnimFrameData: ; 8d6e6 dw Unknown_8d87d ; 22 dw Unknown_8d880 ; 23 dw Unknown_8d883 ; 24 - dw Unknown_8d890 ; 25 + dw Unknown_8d890 ; 25 headbutt dw Unknown_8d899 ; 26 dw Unknown_8d89c ; 27 dw Unknown_8d89f ; 28 @@ -238,7 +238,7 @@ Unknown_8d883: db $56, $0a db $58, $09 db $5a, $0a db -2 -Unknown_8d890: db $50, $02 +Unknown_8d890: db $50, $02 ; center db $5b, $02 db $50, $02 db $5b, $42 diff --git a/engine/anim_hp_bar.asm b/engine/anim_hp_bar.asm new file mode 100755 index 000000000..3075ef323 --- /dev/null +++ b/engine/anim_hp_bar.asm @@ -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 diff --git a/engine/battle_start.asm b/engine/battle_start.asm index 4ef26cae3..69b08fb41 100644 --- a/engine/battle_start.asm +++ b/engine/battle_start.asm @@ -264,8 +264,8 @@ StartTrainerBattle_Flash: ; 8c3ab (23:43ab) ret .DoFlashAnimation: ; 8c3b3 (23:43b3) - ld a, [wd847] - cp -1 + ld a, [wTimeOfDayPalset] + cp %11111111 ; dark cave jr z, .done ld hl, wcf64 ld a, [hl] diff --git a/engine/link.asm b/engine/link.asm index 222d1eedb..2255133cb 100755 --- a/engine/link.asm +++ b/engine/link.asm @@ -2349,7 +2349,7 @@ Function29dba: ; 29dba ld a, [ScriptVar] and a jr z, .asm_29e08 - ld bc, rIE + ld bc, -1 .asm_29de0 dec bc ld a, b diff --git a/engine/map_objects.asm b/engine/map_objects.asm index 13e4f73bf..8e3bd49f0 100644 --- a/engine/map_objects.asm +++ b/engine/map_objects.asm @@ -3040,7 +3040,7 @@ Function579d: ; 579d ld [wd04e], a ld [PlayerObjectStepFrame], a call Function57bc - callba CheckWarpCollision + callba CheckWarpFacingDown call c, SpawnInFacingDown call SpawnInCustomFacing ret diff --git a/engine/map_setup.asm b/engine/map_setup.asm index e8b8c0090..8f7b0e333 100644 --- a/engine/map_setup.asm +++ b/engine/map_setup.asm @@ -33,11 +33,9 @@ MapSetupScripts: ; 15377 MapSetupScript_Teleport: ; 1538f db map_prolong_sprites - MapSetupScript_Fly: ; 15390 db map_fade_out_palettes db map_keep_roam - MapSetupScript_Warp: ; 15392 db map_lcd_off db map_sound_off @@ -61,7 +59,7 @@ MapSetupScript_Warp: ; 15392 db map_fade_in_palettes db map_animations_on db map_wildmons - db map_end_setup_script + db map_end MapSetupScript_BadWarp: ; 153a9 db map_load_spawn @@ -85,7 +83,7 @@ MapSetupScript_BadWarp: ; 153a9 db map_fade_in_palettes db map_animations_on db map_wildmons - db map_end_setup_script + db map_end MapSetupScript_Connection: ; 153bf db map_animations_off @@ -104,14 +102,12 @@ MapSetupScript_Connection: ; 153bf db map_wildmons db map_update_roam db map_animations_on - db map_end_setup_script + db map_end MapSetupScript_Fall: ; 153d0 db map_prolong_sprites - MapSetupScript_Door: ; 153d1 db map_fade_out_palettes - MapSetupScript_Train: ; 153d2 db map_load_warp db map_attributes @@ -133,7 +129,7 @@ MapSetupScript_Train: ; 153d2 db map_animations_on db map_wildmons db map_update_roam - db map_end_setup_script + db map_end MapSetupScript_ReloadMap: ; 153e7 db map_fade @@ -151,7 +147,7 @@ MapSetupScript_ReloadMap: ; 153e7 db map_fade_in_palettes db map_animations_on db map_wildmons - db map_end_setup_script + db map_end MapSetupScript_LinkReturn: ; 153f7 db map_fade @@ -170,7 +166,7 @@ MapSetupScript_LinkReturn: ; 153f7 db map_animations_on db map_wildmons db map_text_scroll_off - db map_end_setup_script + db map_end MapSetupScript_Continue: ; 15408 db map_lcd_off @@ -190,12 +186,12 @@ MapSetupScript_Continue: ; 15408 db map_fade_in_palettes db map_animations_on db map_wildmons - db map_end_setup_script + db map_end MapSetupScript_Submenu: ; 1541a db map_load_blocks db map_connection_blocks - db map_end_setup_script + db map_end ReadMapSetupScript: ; 1541d diff --git a/engine/party_menu.asm b/engine/party_menu.asm index 0da558272..5d28eb949 100644 --- a/engine/party_menu.asm +++ b/engine/party_menu.asm @@ -190,7 +190,7 @@ PlacePartymonHPBar: ; 50117 ld d, a ld a, [hli] ld e, a - predef DrawPartyMenuHPBar + predef ComputeHPBarPixels ret ; 50138 diff --git a/engine/predef.asm b/engine/predef.asm index f812d1d9e..f459747bb 100644 --- a/engine/predef.asm +++ b/engine/predef.asm @@ -34,7 +34,7 @@ PredefPointers:: ; 856b add_predef Predef1 add_predef HealParty add_predef FlagPredef - add_predef DrawPartyMenuHPBar + add_predef ComputeHPBarPixels add_predef FillPP add_predef TryAddMonToParty add_predef AddTempmonToParty diff --git a/engine/sprite_anims.asm b/engine/sprite_anims.asm index dc2a0ffd8..54af5db37 100755 --- a/engine/sprite_anims.asm +++ b/engine/sprite_anims.asm @@ -16,7 +16,7 @@ endr .Jumptable: ; 8d25b (23:525b) jumptable_start - jumptable .zero ; town map + jumptable .zero ; null jumptable .one ; bouncing mon icon jumptable .two ; bouncing mon icon, selected jumptable .three ; bouncing mon icon, menu open diff --git a/engine/sprites.asm b/engine/sprites.asm index 4c07a2b9e..60d81112e 100755 --- a/engine/sprites.asm +++ b/engine/sprites.asm @@ -585,7 +585,7 @@ SpriteAnimSeqData: ; 8d1c4 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_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_26, SPRITE_ANIM_SEQ_1A, $00 ; 1d db SPRITE_ANIM_FRAMESET_2D, SPRITE_ANIM_SEQ_00, $00 ; 1e diff --git a/engine/startmenu.asm b/engine/startmenu.asm index 7093165af..b9f5462d7 100755 --- a/engine/startmenu.asm +++ b/engine/startmenu.asm @@ -1280,7 +1280,7 @@ MonMenu_Fly: ; 12e30 ; 12e55 MonMenu_Flash: ; 12e55 - callba Functionc8ac + callba OWFlash ld a, [wFieldMoveSucceeded] cp $1 jr nz, .Fail diff --git a/engine/stats_screen.asm b/engine/stats_screen.asm index e0faa54a3..84e1cf9ea 100755 --- a/engine/stats_screen.asm +++ b/engine/stats_screen.asm @@ -407,7 +407,7 @@ Function4df45: ; 4df45 (13:5f45) ld a, [hli] ld d, a ld e, [hl] - callba DrawPartyMenuHPBar + callba ComputeHPBarPixels ld hl, wcda1 call SetHPPal ld b, SCGB_03 diff --git a/engine/timeofdaypals.asm b/engine/timeofdaypals.asm index 368636758..e45b38479 100644 --- a/engine/timeofdaypals.asm +++ b/engine/timeofdaypals.asm @@ -1,4 +1,4 @@ -Function8c001:: ; 8c001 +UpdateTimeOfDayPal:: ; 8c001 call UpdateTime ld a, [TimeOfDay] ld [CurTimeOfDay], a @@ -12,7 +12,7 @@ _TimeOfDayPals:: ; 8c011 ; return carry if pals are changed ; forced pals? - ld hl, wd846 + ld hl, wTimeOfDayPalFlags bit 7, [hl] jr nz, .dontchange @@ -198,7 +198,7 @@ brightlevel: MACRO db (\1 << 6) | (\2 << 4) | (\3 << 2) | \4 ENDM -Function8c0e5: ; 8c0e5 +ReplaceTimeOfDayPals: ; 8c0e5 ld hl, .BrightnessLevels ld a, [wc2d0] cp $4 ; Dark cave, needs Flash @@ -210,18 +210,20 @@ Function8c0e5: ; 8c0e5 adc h ld h, a ld a, [hl] - ld [wd847], a + ld [wTimeOfDayPalset], a ret + .DarkCave ld a, [StatusFlags] - bit 2, a + bit 2, a ; Flash jr nz, .UsedFlash - ld a, $ff ; 3, 3, 3, 3 - ld [wd847], a + ld a, %11111111 ; 3, 3, 3, 3 + ld [wTimeOfDayPalset], a ret + .UsedFlash - ld a, $aa ; 2, 2, 2, 2 - ld [wd847], a + ld a, %10101010 ; 2, 2, 2, 2 + ld [wTimeOfDayPalset], a ret ; 8c10f (23:410f) @@ -257,25 +259,25 @@ endr dw .DarknessPalette .MorningPalette - ld a, [wd847] + ld a, [wTimeOfDayPalset] and %00000011 ; 0 ret .DayPalette - ld a, [wd847] + ld a, [wTimeOfDayPalset] and %00001100 ; 1 srl a srl a ret .NitePalette - ld a, [wd847] + ld a, [wTimeOfDayPalset] and %00110000 ; 2 swap a ret .DarknessPalette - ld a, [wd847] + ld a, [wTimeOfDayPalset] and %11000000 ; 3 rlca rlca diff --git a/engine/warp_connection.asm b/engine/warp_connection.asm index 1a857ab43..7ea596637 100755 --- a/engine/warp_connection.asm +++ b/engine/warp_connection.asm @@ -237,8 +237,8 @@ LoadMapTimeOfDay: ; 104750 res 6, [hl] ld a, $1 ld [wSpriteUpdatesEnabled], a - callba Function8c0e5 - callba Function8c001 + callba ReplaceTimeOfDayPals + callba UpdateTimeOfDayPal call OverworldTextModeSwitch call Function104770 call Function1047a3 diff --git a/event/field_moves.asm b/event/field_moves.asm index d1635078e..82b1c2b25 100755 --- a/event/field_moves.asm +++ b/event/field_moves.asm @@ -9,12 +9,12 @@ PlayWhirlpoolSound: ; 8c7d4 BlindingFlash: ; 8c7e1 callba FadeOutPalettes ld hl, StatusFlags - set 2, [hl] - callba Function8c0e5 - callba Function8c001 + set 2, [hl] ; Flash + callba ReplaceTimeOfDayPals + callba UpdateTimeOfDayPal ld b, SCGB_09 call GetSGBLayout - callba Function49409 + callba LoadOW_BGPal7 callba FadeInPalettes ret ; 8c80a @@ -32,13 +32,13 @@ ShakeHeadbuttTree: ; 8c80a call Cut_Headbutt_GetPixelFacing ld a, SPRITE_ANIM_INDEX_1B call _InitSpriteAnimStruct - ld hl, $3 + ld hl, SPRITEANIMSTRUCT_TILE_ID add hl, bc ld [hl], $84 ld a, 36 * 4 ld [wCurrSpriteOAMAddr], a callba DoNextFrameForAllSprites - call GetHeadbuttTreeRelativeLocation + call HideHeadbuttTree ld a, $20 ld [wcf64], a call WaitSFX @@ -78,7 +78,7 @@ HeadbuttTreeGFX: ; 8c893 INCBIN "gfx/unknown/08c893.2bpp" ; 8c913 -GetHeadbuttTreeRelativeLocation: ; 8c913 +HideHeadbuttTree: ; 8c913 xor a ld [hBGMapMode], a ld a, [PlayerDirection] @@ -113,6 +113,9 @@ TreeRelativeLocationTable: ; 8c938 ; 8c940 OWCutAnimation: ; 8c940 + ; Animation index in e + ; 0: Split tree in half + ; 1: Mow the lawn ld a, e and $1 ld [wJumptableIndex], a diff --git a/home/map.asm b/home/map.asm index d049623e6..0f72b235d 100644 --- a/home/map.asm +++ b/home/map.asm @@ -114,9 +114,9 @@ LoadMapPart:: ; 217a ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill - ld a, BANK(Function4d15b) + ld a, BANK(_LoadMapPart) rst Bankswitch - call Function4d15b + call _LoadMapPart pop af rst Bankswitch @@ -124,38 +124,40 @@ LoadMapPart:: ; 217a ; 2198 LoadMetatiles:: ; 2198 -; de <- wOverworldMapAnchor + ; de <- wOverworldMapAnchor ld a, [wOverworldMapAnchor] ld e, a ld a, [wOverworldMapAnchor + 1] ld d, a ld hl, wMisc - ld b, 5 ; SCREEN_WIDTH / 4 + ld b, WMISC_HEIGHT / 4 ; 5 -.loop +.row push de push hl - ld c, 6 ; SCREEN_HEIGHT / 3 + ld c, WMISC_WIDTH / 4 ; 6 -.loop2 +.col push de push hl + ; Load the current map block. + ; If the current map block is a border block, load the border block. ld a, [de] and a jr nz, .ok ld a, [MapBorderBlock] .ok + ; Load the current wMisc address into de. ld e, l 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 ld l, a ld h, 0 rept 3 - add hl,hl + add hl, hl endr -; hl <- hl + [TilesetBlocksAddress] ld a, [TilesetBlocksAddress] add l ld l, a @@ -163,37 +165,36 @@ endr adc h ld h, a + ; copy the 4x4 metatile rept 3 -; copy 4 bytes from hl to de rept 4 ld a, [hli] ld [de], a inc de endr -; next row ld a, e - add SCREEN_WIDTH + add WMISC_WIDTH - 4 ld e, a jr nc, .next\@ inc d .next\@ endr -; copy 4 more bytes from hl to de rept 4 ld a, [hli] ld [de], a inc de endr - + ; Next metatile pop hl ld de, 4 add hl, de pop de inc de dec c - jp nz, .loop2 + jp nz, .col + ; Next metarow pop hl - ld de, $60 + ld de, WMISC_WIDTH * 4 add hl, de pop de ld a, [MapWidth] @@ -202,10 +203,9 @@ endr ld e, a jr nc, .ok2 inc d - .ok2 dec b - jp nz, .loop + jp nz, .row ret ; 222a @@ -223,7 +223,7 @@ CheckWarpTile:: ; 2238 ret nc push bc - callba Function149af + callba CheckDirectionalWarp pop bc ret nc @@ -232,8 +232,6 @@ CheckWarpTile:: ; 2238 ret ; 224a - - WarpCheck:: ; 224a call GetDestinationWarpNumber ret nc @@ -242,7 +240,7 @@ WarpCheck:: ; 224a ; 2252 GetDestinationWarpNumber:: ; 2252 - callba Function1499a + callba CheckWarpCollision ret nc ld a, [hROMBank] @@ -366,8 +364,6 @@ CopyWarpData:: ; 22a7 ret ; 22ee - - CheckOutdoorMap:: ; 22ee cp ROUTE ret z @@ -395,7 +391,6 @@ Function2300:: ; unreferenced ret ; 2309 - LoadMapAttributes:: ; 2309 call CopyMapHeaders call SwitchToMapScriptHeaderBank @@ -503,7 +498,6 @@ GetMapConnections:: ; 2368 ret ; 23a3 - GetMapConnection:: ; 23a3 ; Load map connection struct at hl into de. ld c, SouthMapConnection - NorthMapConnection @@ -516,7 +510,6 @@ GetMapConnection:: ; 23a3 ret ; 23ac - ReadMapTriggers:: ; 23ac ld a, [hli] ; trigger count ld c, a @@ -749,8 +742,6 @@ LoadBlockData:: ; 24cd ret ; 24e4 - - ChangeMap:: ; 24e4 ld a, [hROMBank] push af @@ -801,8 +792,6 @@ endr ret ; 2524 - - FillMapConnections:: ; 2524 ; North @@ -901,7 +890,6 @@ FillMapConnections:: ; 2524 ret ; 25d3 - FillNorthConnectionStrip:: FillSouthConnectionStrip:: ; 25d3 @@ -938,7 +926,6 @@ FillSouthConnectionStrip:: ; 25d3 ret ; 25f6 - FillWestConnectionStrip:: FillEastConnectionStrip:: ; 25f6 @@ -983,7 +970,6 @@ LoadMapStatus:: ; 261b ret ; 261f - CallScript:: ; 261f ; Call a script at a:hl. @@ -1138,7 +1124,6 @@ GetMovementData:: ; 26c7 ret ; 26d4 - GetScriptByte:: ; 0x26d4 ; Return byte at ScriptBank:ScriptPos in a. @@ -1170,7 +1155,6 @@ GetScriptByte:: ; 0x26d4 ret ; 0x26ef - ObjectEvent:: ; 0x26ef jumptextfaceplayer ObjectEventText ; 0x26f2 @@ -1180,7 +1164,6 @@ ObjectEventText:: db "@" ; 0x26f7 - BGEvent:: ; 26f7 jumptext BGEventText ; 26fa @@ -1190,7 +1173,6 @@ BGEventText:: ; 26fa db "@" ; 26ff - CoordinatesEvent:: ; 26ff jumptext CoordinatesEventText ; 2702 @@ -1200,7 +1182,6 @@ CoordinatesEventText:: ; 2702 db "@" ; 2707 - CheckObjectMask:: ; 2707 ld a, [hMapObjectIndexBuffer] ld e, a @@ -1231,7 +1212,6 @@ UnmaskObject:: ; 271e ret ; 272a - ScrollMapDown:: ; 272a hlcoord 0, 0 ld de, BGMapBuffer @@ -1472,7 +1452,7 @@ BufferScreen:: ; 2879 ld a, [hli] ld h, [hl] ld l, a - ld de, XCoord + 1 + ld de, wScreenSave ld c, $5 ld b, $6 .asm_2886 @@ -1501,9 +1481,9 @@ SaveScreen:: ; 289d ld a, [hli] ld h, [hl] ld l, a - ld de, XCoord + 1 + ld de, wScreenSave ld a, [MapWidth] - add $6 + add 6 ld [hMapObjectIndexBuffer], a ld a, [wPlayerStepDirection] and a @@ -1517,7 +1497,7 @@ SaveScreen:: ; 289d ret .up - ld de, wdcbf + ld de, wScreenSave + 6 ld a, [hMapObjectIndexBuffer] ld c, a ld b, $0 @@ -1525,26 +1505,23 @@ SaveScreen:: ; 289d jr .vertical .down - ld de, XCoord + 1 - + ld de, wScreenSave .vertical - ld b, $6 - ld c, $4 - jr Function28f7 + ld b, 6 + ld c, 4 + jr SaveScreen_LoadNeighbor .left - ld de, XCoord + 2 + ld de, wScreenSave + 1 inc hl jr .horizontal .right - ld de, XCoord + 1 - + ld de, wScreenSave .horizontal - ld b, $5 - ld c, $5 - jr Function28f7 - + ld b, 5 + ld c, 5 + jr SaveScreen_LoadNeighbor LoadNeighboringBlockData:: ; 28e3 ld hl, wOverworldMapAnchor @@ -1552,26 +1529,26 @@ LoadNeighboringBlockData:: ; 28e3 ld h, [hl] ld l, a ld a, [MapWidth] - add $6 + add 6 ld [hConnectionStripLength], a - ld de, XCoord + 1 - ld b, $6 - ld c, $5 + ld de, wScreenSave + ld b, 6 + ld c, 5 -Function28f7:: ; 28f7 -.loop1 +SaveScreen_LoadNeighbor:: ; 28f7 +.row push bc push hl push de -.loop2 +.col ld a, [de] inc de ld [hli], a dec b - jr nz, .loop2 + jr nz, .col pop de ld a, e - add $6 + add 6 ld e, a jr nc, .okay inc d @@ -1580,11 +1557,11 @@ Function28f7:: ; 28f7 pop hl ld a, [hConnectionStripLength] ld c, a - ld b, $0 + ld b, 0 add hl, bc pop bc dec c - jr nz, .loop1 + jr nz, .row ret ; 2914 @@ -1746,7 +1723,6 @@ Function29ff:: ; 29ff ret ; 2a07 - GetFacingTileCoord:: ; 2a07 ; Return map coordinates in (d, e) and tile id in a ; of the tile the player is facing. @@ -1793,7 +1769,6 @@ endr dw TileRight ; 2a3c - GetCoordTile:: ; 2a3c ; Get the collision byte for tile d, e call GetBlockLocation @@ -1861,7 +1836,6 @@ GetBlockLocation:: ; 2a66 ret ; 2a8b - CheckFacingSign:: ; 2a8b call GetFacingTileCoord ; Load facing into b. @@ -2002,7 +1976,6 @@ CheckStandingOnXYTrigger:: ; 2ae7 ret ; 2b29 - FadeToMenu:: ; 2b29 xor a ld [hBGMapMode], a @@ -2013,7 +1986,6 @@ FadeToMenu:: ; 2b29 ret ; 2b3c - CloseSubmenu:: ; 2b3c call ClearBGPalettes call Function2bae @@ -2032,14 +2004,13 @@ ExitAllMenus:: ; 2b4d Function2b5c:: ; 2b5c ld b, SCGB_09 call GetSGBLayout - callba Function49409 + callba LoadOW_BGPal7 call WaitBGMap2 callba FadeInPalettes call EnableSpriteUpdates ret ; 2b74 - Function2b74:: ; 0x2b74 push af ld a, $1 @@ -2056,7 +2027,7 @@ Function2b74:: ; 0x2b74 call WaitBGMap2 ld b, SCGB_09 call GetSGBLayout - callba Function49409 + callba LoadOW_BGPal7 call UpdateTimePals call DelayFrame ld a, $1 @@ -2078,7 +2049,7 @@ Function2bae:: ; 2bae ld a, [MapNumber] ld c, a call SwitchToAnyMapBank - callba Function8c001 + callba UpdateTimeOfDayPal call OverworldTextModeSwitch call LoadTileset ld a, 9 @@ -2090,7 +2061,6 @@ Function2bae:: ; 2bae ret ; 2be5 - GetMapHeaderPointer:: ; 2be5 ld a, [MapGroup] ld b, a @@ -2167,7 +2137,6 @@ GetAnyMapHeaderMember:: ; 0x2c0c ret ; 0x2c1c - SwitchToMapBank:: ; 2c1c ld a, [MapGroup] ld b, a @@ -2181,7 +2150,6 @@ SwitchToAnyMapBank:: ; 2c24 ret ; 2c29 - GetMapBank:: ; 2c29 ld a, [MapGroup] ld b, a @@ -2224,7 +2192,6 @@ SwitchToMapScriptHeaderBank:: ; 2c52 ret ; 2c57 - GetMapScriptHeaderBank:: ; 2c57 ld a, [MapScriptHeaderBank] ret diff --git a/lib/mobile/main.asm b/lib/mobile/main.asm index c41b25d36..2fb46295d 100644 --- a/lib/mobile/main.asm +++ b/lib/mobile/main.asm @@ -2697,7 +2697,7 @@ Function1111d7: ; 1111d7 dec hl .asm_1111ee - ld bc, rIE + ld bc, -1 .asm_1111f1 ld a, [hli] inc bc diff --git a/main.asm b/main.asm index 1c680b53c..d262e0627 100644 --- a/main.asm +++ b/main.asm @@ -89,7 +89,7 @@ Function6473: ; 6473 ld a, VBGMap1 / $100 call Function64b9 call Function2e20 - callba Function49409 + callba LoadOW_BGPal7 callba Function96a4 ld a, $1 ld [hCGBPalUpdate], a @@ -2078,7 +2078,8 @@ endr ret ; c699 -DrawPartyMenuHPBar: ; c699 +ComputeHPBarPixels: ; c699 +; bc * (6 * 8) / de ld a, b or c jr z, .zero @@ -2089,12 +2090,14 @@ DrawPartyMenuHPBar: ; c699 ld [hMultiplicand + 1], a ld a, c ld [hMultiplicand + 2], a - ld a, $30 + ld a, 6 * 8 ld [hMultiplier], a call Multiply + ; We need de to be under 256 because hDivisor is only 1 byte. ld a, d and a jr z, .divide + ; divide de and hProduct by 4 srl d rr e srl d @@ -2109,22 +2112,21 @@ DrawPartyMenuHPBar: ; c699 ld [hDividend + 3], a ld a, b ld [hDividend + 2], a - .divide ld a, e ld [hDivisor], a - ld b, $4 + ld b, 4 call Divide ld a, [hQuotient + 2] ld e, a pop hl and a ret nz - ld e, $1 + ld e, 1 ret .zero - ld e, $0 + ld e, 0 ret ; c6e0 @@ -2193,13 +2195,13 @@ CheckBadge: ; c731 ; Display "Badge required" text and return carry if the badge is not owned call CheckEngineFlag ret nc - ld hl, BadgeRequiredText + ld hl, .BadgeRequiredText call MenuTextBoxBackup ; push text to queue scf ret ; c73d -BadgeRequiredText: ; c73d +.BadgeRequiredText: ; c73d ; Sorry! A new BADGE ; is required. text_jump _BadgeRequiredText @@ -2252,12 +2254,13 @@ CheckPartyMove: ; c742 ; c779 FieldMoveFailed: ; c779 - ld hl, UnknownText_0xc780 + ld hl, .CantUseHere call MenuTextBoxBackup ret ; c780 -UnknownText_0xc780: ; 0xc780 +.CantUseHere: ; 0xc780 + ; Can't use that here. text_jump UnknownText_0x1c05c8 db "@" ; 0xc785 @@ -2274,9 +2277,10 @@ CutFunction: ; c785 ; c796 .Jumptable: ; c796 (3:4796) - dw .CheckAble - dw .DoCut - dw .FailCut + jumptable_start + jumptable .CheckAble + jumptable .DoCut + jumptable .FailCut .CheckAble: ; c79c (3:479c) ld de, ENGINE_HIVEBADGE @@ -2286,9 +2290,11 @@ CutFunction: ; c785 jr c, .nothingtocut ld a, $1 ret + .nohivebadge ld a, $80 ret + .nothingtocut ld a, $2 ret @@ -2300,45 +2306,51 @@ CutFunction: ; c785 ret .FailCut: ; c7bb (3:47bb) - ld hl, UnknownText_0xc7c9 + ld hl, Text_NothingToCut call MenuTextBoxBackup ld a, $80 ret -UnknownText_0xc7c4: ; 0xc7c4 +Text_UsedCut: ; 0xc7c4 ; used CUT! text_jump UnknownText_0x1c05dd db "@" ; 0xc7c9 -UnknownText_0xc7c9: ; 0xc7c9 +Text_NothingToCut: ; 0xc7c9 ; There's nothing to CUT here. text_jump UnknownText_0x1c05ec db "@" ; 0xc7ce CheckMapForSomethingToCut: ; c7ce + ; Does the collision data of the facing tile permit cutting? call GetFacingTileCoord ld c, a push de callba CheckCutCollision pop de jr nc, .fail + ; Get the location of the current block in OverworldMap. call GetBlockLocation ld c, [hl] + ; See if that block contains something that can be cut. push hl ld hl, CutTreeBlockPointers call CheckOverworldTileArrays pop hl jr nc, .fail + ; Back up the OverworldMap address to Buffer3 ld a, l - ld [wd1ec], a + ld [Buffer3], a ld a, h - ld [wd1ed], a + ld [Buffer4], a + ; Back up the replacement tile to Buffer5 ld a, b - ld [wd1ee], a + ld [Buffer5], a + ; Back up the animation index to Buffer6 ld a, c - ld [wd1ef], a + ld [Buffer6], a xor a ret @@ -2353,7 +2365,7 @@ Script_CutFromMenu: ; c7fe Script_Cut: ; 0xc802 callasm GetPartyNick - writetext UnknownText_0xc7c4 + writetext Text_UsedCut reloadmappart callasm CutDownTreeOrGrass closetext @@ -2361,18 +2373,18 @@ Script_Cut: ; 0xc802 ; 0xc810 CutDownTreeOrGrass: ; c810 - ld hl, wd1ec + ld hl, Buffer3 ; OverworldMapTile ld a, [hli] ld h, [hl] ld l, a - ld a, [wd1ee] + ld a, [Buffer5] ; ReplacementTile ld [hl], a xor a ld [hBGMapMode], a call OverworldTextModeSwitch call UpdateSprites call DelayFrame - ld a, [wd1ef] + ld a, [Buffer6] ; Animation type ld e, a callba OWCutAnimation call BufferScreen @@ -2384,22 +2396,32 @@ CutDownTreeOrGrass: ; c810 ; 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 ld a, [wTileset] ld de, 3 call IsInArray pop bc jr nc, .nope + ; Load the pointer inc hl ld a, [hli] ld h, [hl] ld l, a + ; Look up the tile you're facing ld de, 3 ld a, c call IsInArray jr nc, .nope + ; Load the replacement to b inc hl ld b, [hl] + ; Load the animation type parameter to c inc hl ld c, [hl] scf @@ -2412,16 +2434,16 @@ CheckOverworldTileArrays: ; c840 CutTreeBlockPointers: ; c862 ; Which tileset are we in? - dbw TILESET_JOHTO_1, .one - dbw TILESET_JOHTO_2, .two - dbw TILESET_KANTO, .three - dbw TILESET_PARK, .twentyfive - dbw TILESET_ILEX_FOREST, .thirtyone + dbw TILESET_JOHTO_1, .johto1 + dbw TILESET_JOHTO_2, .johto2 + dbw TILESET_KANTO, .kanto + dbw TILESET_PARK, .park + dbw TILESET_ILEX_FOREST, .ilex db -1 ; c872 -.one: ; Johto OW -; Which meta tile are we facing, which should we replace it with, and does it affect encounters? +.johto1: ; Johto OW +; Which meta tile are we facing, which should we replace it with, and which animation? db $03, $02, $01 ; grass db $5b, $3c, $00 ; tree db $5f, $3d, $00 ; tree @@ -2430,12 +2452,12 @@ CutTreeBlockPointers: ; c862 db -1 ; c882 -.two: ; Goldenrod area +.johto2: ; Goldenrod area db $03, $02, $01 ; grass db -1 ; c886 -.three: ; Kanto OW +.kanto: ; Kanto OW db $0b, $0a, $01 ; grass db $32, $6d, $00 ; tree db $33, $6c, $00 ; tree @@ -2445,35 +2467,35 @@ CutTreeBlockPointers: ; c862 db -1 ; c899 -.twentyfive: ; National Park +.park: ; National Park db $13, $03, $01 ; grass db $03, $04, $01 ; grass db -1 ; c8a0 -.thirtyone: ; Ilex Forest +.ilex: ; Ilex Forest db $0f, $17, $00 db -1 ; c8a4 WhirlpoolBlockPointers: ; c8a4 - dbw TILESET_JOHTO_1, .one + dbw TILESET_JOHTO_1, .johto db -1 ; c8a8 -.one: ; c8a8 +.johto: ; c8a8 db $07, $36, $00 db -1 ; c8ac -Functionc8ac: ; c8ac - call Functionc8b5 +OWFlash: ; c8ac + call .CheckUseFlash and $7f ld [wd0ec], a ret ; c8b5 -Functionc8b5: ; c8b5 +.CheckUseFlash: ; c8b5 ; Flash ld de, ENGINE_ZEPHYRBADGE callba CheckBadge @@ -2482,10 +2504,9 @@ Functionc8b5: ; c8b5 callba SpecialAerodactylChamber pop hl jr c, .useflash - ld a, [wd847] - cp -1 + ld a, [wTimeOfDayPalset] + cp %11111111 ; 3, 3, 3, 3 jr nz, .notadarkcave - .useflash call UseFlash ld a, $81 @@ -2522,11 +2543,11 @@ UnknownText_0xc8f3: ; 0xc8f3 ld de, SFX_FLASH call PlaySFX call WaitSFX - ld hl, UnknownText_0xc908 + ld hl, .BlankText ret ; c908 -UnknownText_0xc908: ; 0xc908 +.BlankText: ; 0xc908 db "@" ; 0xc909 @@ -3268,7 +3289,7 @@ Functioncd1d: ; cd1d ld hl, PartySpecies add hl, de ld a, [hl] - ld [wd1ef], a + ld [Buffer6], a call GetPartyNick ret ; cd29 @@ -3280,7 +3301,7 @@ Script_StrengthFromMenu: ; 0xcd29 Script_UsedStrength: ; 0xcd2d callasm Functioncd12 writetext UnknownText_0xcd41 - copybytetovar wd1ef + copybytetovar Buffer6 cry 0 pause 3 writetext UnknownText_0xcd46 @@ -3438,13 +3459,13 @@ TryWhirlpoolMenu: ; cdde pop hl jr nc, .failed ld a, l - ld [wd1ec], a + ld [Buffer3], a ld a, h - ld [wd1ed], a + ld [Buffer4], a ld a, b - ld [wd1ee], a + ld [Buffer5], a ld a, c - ld [wd1ef], a + ld [Buffer6], a xor a ret @@ -3467,16 +3488,16 @@ Script_UsedWhirlpool: ; 0xce0f ; 0xce1d DisappearWhirlpool: ; ce1d - ld hl, wd1ec + ld hl, Buffer3 ld a, [hli] ld h, [hl] ld l, a - ld a, [wd1ee] + ld a, [Buffer5] ld [hl], a xor a ld [hBGMapMode], a call OverworldTextModeSwitch - ld a, [wd1ef] + ld a, [Buffer6] ld e, a callba PlayWhirlpoolSound call BufferScreen @@ -3816,7 +3837,7 @@ FishFunction: ; cf8e .FishGotSomething: ; cff4 ld a, $1 - ld [wd1ef], a + ld [Buffer6], a ld hl, Script_GotABite call QueueScript ld a, $81 @@ -3825,7 +3846,7 @@ FishFunction: ; cf8e .FishNoBite: ; d002 ld a, $2 - ld [wd1ef], a + ld [Buffer6], a ld hl, Script_NotEvenANibble call QueueScript ld a, $81 @@ -3834,7 +3855,7 @@ FishFunction: ; cf8e .FailFish: ; d010 ld a, $0 - ld [wd1ef], a + ld [Buffer6], a ld hl, Script_NotEvenANibble2 call QueueScript ld a, $81 @@ -4160,7 +4181,7 @@ AskCutScript: ; 0xd1a9 ld [ScriptVar], a call CheckMapForSomethingToCut ret c - ld a, 1 + ld a, TRUE ld [ScriptVar], a ret ; d1c8 @@ -5077,439 +5098,7 @@ UpdateOverworldMap: ; d536 (3:5536) inc [hl] ret -_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 $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 +INCLUDE "engine/anim_hp_bar.asm" TryAddMonToParty: ; d88c ; Check if to copy wild Pkmn or generate new Pkmn @@ -8380,7 +7969,8 @@ Function140ed:: ; 140ed INCLUDE "engine/overworld.asm" -Function1499a:: ; 1499a +CheckWarpCollision:: ; 1499a +; Is this tile a warp? ld a, [PlayerNextTile] cp $60 jr z, .warp @@ -8397,15 +7987,17 @@ Function1499a:: ; 1499a ret ; 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] - cp $70 + cp $70 ; Warp on down jr z, .not_warp - cp $76 + cp $76 ; Warp on left jr z, .not_warp - cp $78 + cp $78 ; Warp on up jr z, .not_warp - cp $7e + cp $7e ; Warp on right jr z, .not_warp scf ret @@ -8415,7 +8007,7 @@ Function149af:: ; 149af ret ; 149c6 -CheckWarpCollision: ; 149c6 +CheckWarpFacingDown: ; 149c6 ld de, 1 ld hl, .blocks ld a, [PlayerNextTile] @@ -11508,7 +11100,7 @@ Function49351: ; 49351 (12:5351) ld a, $5 ; BANK(UnknBGPals) call FarCopyWRAM ld de, UnknBGPals + $38 - ld hl, Palette_49418 + ld hl, Palette_TextBG7 ld bc, $8 ld a, $5 ; BANK(UnknBGPals) call FarCopyWRAM @@ -11587,8 +11179,8 @@ Palette_493e1: ; 493e1 RGB 00, 00, 00 ; 49409 -Function49409:: ; 49409 - ld hl, Palette_49418 +LoadOW_BGPal7:: ; 49409 + ld hl, Palette_TextBG7 ld de, UnknBGPals + 8 * 7 ld bc, 8 ld a, $5 @@ -11596,7 +11188,7 @@ Function49409:: ; 49409 ret ; 49418 -Palette_49418: ; 49418 +Palette_TextBG7: ; 49418 RGB 31, 31, 31 RGB 08, 19, 28 RGB 05, 05, 16 @@ -12400,23 +11992,23 @@ CheckSave:: ; 4cffe INCLUDE "engine/map_triggers.asm" -Function4d15b:: ; 4d15b - ld hl, wc608 +_LoadMapPart:: ; 4d15b + ld hl, wMisc ld a, [wMetatileStandingY] and a - jr z, .skip - ld bc, $30 + jr z, .top_row + ld bc, WMISC_WIDTH * 2 add hl, bc -.skip +.top_row ld a, [wMetatileStandingX] and a - jr z, .next_dw + jr z, .left_column rept 2 inc hl endr -.next_dw +.left_column decoord 0, 0 ld b, SCREEN_HEIGHT .loop @@ -14362,7 +13954,7 @@ DrawHP: ; 50b10 ld c, e .asm_50b41 - predef DrawPartyMenuHPBar + predef ComputeHPBarPixels ld a, 6 ld d, a ld c, a @@ -15065,7 +14657,7 @@ ENDM _SwitchPartyMons: ld a, [wd0e3] dec a - ld [wd1ec], a + ld [Buffer3], a ld b, a ld a, [MenuSelection2] dec a @@ -15073,7 +14665,7 @@ _SwitchPartyMons: cp b jr z, .skip call .SwapMonAndMail - ld a, [wd1ec] + ld a, [Buffer3] call .ClearSprite ld a, [Buffer2] ; wd1eb (aliases: MovementType) call .ClearSprite diff --git a/misc/crystal_misc.asm b/misc/crystal_misc.asm index 662c1788a..01538a3d6 100644 --- a/misc/crystal_misc.asm +++ b/misc/crystal_misc.asm @@ -49,7 +49,7 @@ Function17a6a8: ; 17a6a8 (5e:66a8) call Function17ac0c callba Function104000 call Function17abcf - callba Function49409 + callba LoadOW_BGPal7 callba Function49420 call SetPalettes call DelayFrame diff --git a/misc/mobile_40.asm b/misc/mobile_40.asm index 6e0988f41..f0ba0f957 100644 --- a/misc/mobile_40.asm +++ b/misc/mobile_40.asm @@ -428,7 +428,7 @@ Function1002dc: ; 1002dc ; 1002ed Function1002ed: ; 1002ed - callba Function49409 + callba LoadOW_BGPal7 callba Function96a4 ld a, $1 ld [hCGBPalUpdate], a diff --git a/tilesets/animations.asm b/tilesets/animations.asm index 19f457c09..277735391 100644 --- a/tilesets/animations.asm +++ b/tilesets/animations.asm @@ -997,7 +997,7 @@ FlickeringCaveEntrancePalette: ; fc71e cp %11100100 ret nz ; 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 ret nz diff --git a/wram.asm b/wram.asm index 888bb3957..511078b39 100644 --- a/wram.asm +++ b/wram.asm @@ -548,7 +548,7 @@ wBT_OTTemp:: battle_tower_struct wBT_OTTemp hall_of_fame wHallOfFameTemp ds wHallOfFameTemp - @ -wMisc:: ; ds $28 * 6 +wMisc:: ; ds (SCREEN_WIDTH + 4) * (SCREEN_HEIGHT + 2) wBattle:: wc608:: @@ -2560,8 +2560,8 @@ TimeOfDayPal:: ; d841 ds 1 ds 4 ; d846 -wd846:: ds 1 -wd847:: ds 1 +wTimeOfDayPalFlags:: ds 1 +wTimeOfDayPalset:: ds 1 CurTimeOfDay:: ; d848 ds 1 @@ -2949,10 +2949,7 @@ YCoord:: ; dcb7 ds 1 ; current y coordinate relative to top-left corner of current map XCoord:: ; dcb8 ds 1 ; current x coordinate relative to top-left corner of current map - - ds 6 -wdcbf:: ds 1 - ds 23 +wScreenSave:: ds 6 * 5 wMapDataEnd::