From e1fabcfbff78533cd1a5f75f4da3ede3b8a04d8f Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 18 May 2018 19:36:22 -0400 Subject: [PATCH 01/22] Fix comments --- constants/map_constants.asm | 4 +-- gfx/tilesets/roofs.pal | 54 ++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/constants/map_constants.asm b/constants/map_constants.asm index 3efc8e30b..7c07c9e9e 100644 --- a/constants/map_constants.asm +++ b/constants/map_constants.asm @@ -5,8 +5,8 @@ ENDM map_const: MACRO ;\1: map id -;\2: height: in blocks -;\3: width: in blocks +;\2: width: in blocks +;\3: height: in blocks GROUP_\1 EQU const_value enum MAP_\1 \1_WIDTH EQU \2 diff --git a/gfx/tilesets/roofs.pal b/gfx/tilesets/roofs.pal index 6daf87cb6..652b152c1 100644 --- a/gfx/tilesets/roofs.pal +++ b/gfx/tilesets/roofs.pal @@ -1,107 +1,107 @@ ; group 0 (unused) RGB 21,21,21, 11,11,11 ; morn/day - RGB 21,21,21, 11,11,11; nite + RGB 21,21,21, 11,11,11 ; nite ; group 1 (Olivine) RGB 14,17,31, 07,11,15 ; morn/day - RGB 09,09,17, 05,07,13; nite + RGB 09,09,17, 05,07,13 ; nite ; group 2 (Mahogany) RGB 12,19,00, 06,10,00 ; morn/day - RGB 06,09,07, 04,05,06; nite + RGB 06,09,07, 04,05,06 ; nite ; group 3 (dungeons) RGB 21,21,21, 11,11,11 ; morn/day - RGB 21,21,21, 17,08,07; nite + RGB 21,21,21, 17,08,07 ; nite ; group 4 (Ecruteak) RGB 31,19,00, 27,10,05 ; morn/day - RGB 15,07,02, 11,04,02; nite + RGB 15,07,02, 11,04,02 ; nite ; group 5 (Blackthorn) RGB 11,10,16, 05,06,07 ; morn/day - RGB 03,04,08, 00,00,00; nite + RGB 03,04,08, 00,00,00 ; nite ; group 6 (Cinnabar) RGB 31,10,00, 18,06,00 ; morn/day - RGB 18,05,09, 17,08,07; nite + RGB 18,05,09, 17,08,07 ; nite ; group 7 (Cerulean) RGB 17,27,31, 05,15,31 ; morn/day - RGB 07,08,22, 07,07,16; nite + RGB 07,08,22, 07,07,16 ; nite ; group 8 (Azalea) RGB 22,20,10, 17,14,03 ; morn/day - RGB 11,11,05, 10,09,07; nite + RGB 11,11,05, 10,09,07 ; nite ; group 9 (Lake of Rage) RGB 31,08,04, 09,09,08 ; morn/day - RGB 18,05,09, 09,09,08; nite + RGB 18,05,09, 09,09,08 ; nite ; group 10 (Violet) RGB 24,14,31, 13,07,21 ; morn/day - RGB 12,03,18, 09,03,15; nite + RGB 12,03,18, 09,03,15 ; nite ; group 11 (Goldenrod) RGB 25,25,00, 20,17,08 ; morn/day - RGB 12,12,00, 10,09,05; nite + RGB 12,12,00, 10,09,05 ; nite ; group 12 (Vermilion) RGB 27,23,01, 23,11,00 ; morn/day - RGB 15,11,01, 11,10,01; nite + RGB 15,11,01, 11,10,01 ; nite ; group 13 (Pallet) RGB 27,28,31, 17,19,22 ; morn/day - RGB 14,14,18, 10,09,13; nite + RGB 14,14,18, 10,09,13 ; nite ; group 14 (Pewter) RGB 19,19,16, 10,12,15 ; morn/day - RGB 09,09,11, 04,05,07; nite + RGB 09,09,11, 04,05,07 ; nite ; group 15 (Mount Moon Square) RGB 14,17,31, 07,11,15 ; morn/day - RGB 09,13,19, 07,07,16; nite + RGB 09,13,19, 07,07,16 ; nite ; group 16 (Indigo) RGB 21,21,21, 13,13,13 ; morn/day - RGB 11,11,19, 07,07,12; nite + RGB 11,11,19, 07,07,12 ; nite ; group 17 (Fuchsia) RGB 31,18,29, 17,13,20 ; morn/day - RGB 14,06,12, 11,03,10; nite + RGB 14,06,12, 11,03,10 ; nite ; group 18 (Lavender) RGB 23,15,31, 16,05,31 ; morn/day - RGB 12,07,17, 08,06,10; nite + RGB 12,07,17, 08,06,10 ; nite ; group 19 (Silver Cave) RGB 21,21,25, 16,16,16 ; morn/day - RGB 13,13,13, 07,07,07; nite + RGB 13,13,13, 07,07,07 ; nite ; group 20 (Cable Club) RGB 21,21,21, 11,11,11 ; morn/day - RGB 21,21,21, 11,11,11; nite + RGB 21,21,21, 11,11,11 ; nite ; group 21 (Celadon) RGB 19,31,15, 31,22,02 ; morn/day - RGB 12,13,09, 09,12,03; nite + RGB 12,13,09, 09,12,03 ; nite ; group 22 (Cianwood) RGB 15,10,31, 07,05,15 ; morn/day - RGB 06,05,17, 02,02,08; nite + RGB 06,05,17, 02,02,08 ; nite ; group 23 (Viridian) RGB 21,31,07, 13,25,04 ; morn/day - RGB 09,14,08, 06,10,04; nite + RGB 09,14,08, 06,10,04 ; nite ; group 24 (New Bark) RGB 20,31,14, 11,23,05 ; morn/day - RGB 09,13,08, 06,09,04; nite + RGB 09,13,08, 06,09,04 ; nite ; group 25 (Saffron) RGB 31,26,00, 31,15,00 ; morn/day - RGB 13,13,01, 08,08,01; nite + RGB 13,13,01, 08,08,01 ; nite ; group 26 (Cherrygrove) RGB 31,14,28, 31,05,21 ; morn/day - RGB 14,07,17, 13,00,08; nite + RGB 14,07,17, 13,00,08 ; nite From d5fff8aa96f556264da03f0a7f70e090e13c713c Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 18 May 2018 22:18:00 -0400 Subject: [PATCH 02/22] Constants for PC menu indexes 'db ' -> 'db ' --- data/battle_anims/object_gfx.asm | 2 +- data/events/collision_stdscripts.asm | 2 +- data/items/catch_rate_items.asm | 2 +- data/wild/treemon_maps.asm | 2 +- engine/events/pokecenter_pc.asm | 102 ++++++++++++++++----------- maps/Route35GoldenrodGate.asm | 6 +- 6 files changed, 68 insertions(+), 48 deletions(-) diff --git a/data/battle_anims/object_gfx.asm b/data/battle_anims/object_gfx.asm index 133298d13..441692b03 100644 --- a/data/battle_anims/object_gfx.asm +++ b/data/battle_anims/object_gfx.asm @@ -1,6 +1,6 @@ anim_obj_gfx: MACRO ; # tiles, label - db \1 + db \1 dba \2 ENDM diff --git a/data/events/collision_stdscripts.asm b/data/events/collision_stdscripts.asm index 8156d039d..dff26dd85 100644 --- a/data/events/collision_stdscripts.asm +++ b/data/events/collision_stdscripts.asm @@ -10,4 +10,4 @@ TileCollisionStdScripts: dbw COLL_TV, tv dbw COLL_WINDOW, window dbw COLL_INCENSE_BURNER, incenseburner - db -1 ; end + db -1 ; end diff --git a/data/items/catch_rate_items.asm b/data/items/catch_rate_items.asm index fbab7d434..d7ef4cf2b 100644 --- a/data/items/catch_rate_items.asm +++ b/data/items/catch_rate_items.asm @@ -15,5 +15,5 @@ TimeCapsule_CatchRateItems: ; 28785 db ITEM_DC, BERRY db ITEM_FA, BERRY db -1, BERRY - db 0 ; end + db 0 ; end ; 2879e diff --git a/data/wild/treemon_maps.asm b/data/wild/treemon_maps.asm index 59eba43cc..8bc742a3e 100644 --- a/data/wild/treemon_maps.asm +++ b/data/wild/treemon_maps.asm @@ -1,6 +1,6 @@ treemon_map: MACRO map_id \1 - db \2 ; treemon set + db \2 ; treemon set ENDM TreeMonMaps: ; b825e diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm index 42284aeab..6e33d376c 100644 --- a/engine/events/pokecenter_pc.asm +++ b/engine/events/pokecenter_pc.asm @@ -39,12 +39,19 @@ PokemonCenterPC: ; 1559a dw PlaceNthMenuStrings dw .JumpTable +PCPC_PLAYERS_PC EQU 0 +PCPC_BILLS_PC EQU 1 +PCPC_OAKS_PC EQU 2 +PCPC_HALL_OF_FAME EQU 3 +PCPC_TURN_OFF EQU 4 + .JumpTable: - dw PlayersPC, .String_PlayersPC - dw BillsPC, .String_BillsPC - dw OaksPC, .String_OaksPC +; entries correspond to PCPC_* constants + dw PlayersPC, .String_PlayersPC + dw BillsPC, .String_BillsPC + dw OaksPC, .String_OaksPC dw HallOfFamePC, .String_HallOfFame - dw TurnOffPC, .String_TurnOff + dw TurnOffPC, .String_TurnOff .String_PlayersPC: db "'s PC@" .String_BillsPC: db "BILL's PC@" @@ -53,33 +60,42 @@ PokemonCenterPC: ; 1559a .String_TurnOff: db "TURN OFF@" .WhichPC: - ; before pokedex - db 3 ; items - db 1, 0, 4 ; bill's, player's, turn off - db -1 + ; before Pokédex + db 3 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_TURN_OFF + db -1 ; end ; before Hall Of Fame - db 4 ; items - db 1, 0, 2, 4 ; bill's, player's, oak's, turn off - db -1 + db 4 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_OAKS_PC + db PCPC_TURN_OFF + db -1 ; end ; postgame - db 5 ; items - db 1, 0, 2, 3, 4 ; bill's, player's, oak's, hall of fame, turn off - db -1 + db 5 + db PCPC_BILLS_PC + db PCPC_PLAYERS_PC + db PCPC_OAKS_PC + db PCPC_HALL_OF_FAME + db PCPC_TURN_OFF + db -1 ; end .ChooseWhichPCListToUse: call CheckReceivedDex jr nz, .got_dex - ld a, $0 + ld a, 0 ; before Pokédex ret .got_dex ld a, [wHallOfFameCount] and a - ld a, $1 + ld a, 1 ; before Hall Of Fame ret z - ld a, $2 + ld a, 2 ; postgame ret ; 15650 @@ -244,7 +260,16 @@ PlayersPCMenuData: ; 0x15736 dw PlaceNthMenuStrings dw .PlayersPCMenuPointers +PLAYERSPC_WITHDRAW_ITEM EQU 0 +PLAYERSPC_DEPOSIT_ITEM EQU 1 +PLAYERSPC_TOSS_ITEM EQU 2 +PLAYERSPC_MAIL_BOX EQU 3 +PLAYERSPC_DECORATION EQU 4 +PLAYERSPC_TURN_OFF EQU 5 +PLAYERSPC_LOG_OFF EQU 6 + .PlayersPCMenuPointers: ; 0x15746 +; entries correspond to PLAYERSPC_* constants dw PlayerWithdrawItemMenu, .WithdrawItem dw PlayerDepositItemMenu, .DepositItem dw PlayerTossItemMenu, .TossItem @@ -261,32 +286,24 @@ PlayersPCMenuData: ; 0x15736 .TurnOff: db "TURN OFF@" .LogOff: db "LOG OFF@" -WITHDRAW_ITEM EQU 0 -DEPOSIT_ITEM EQU 1 -TOSS_ITEM EQU 2 -MAIL_BOX EQU 3 -DECORATION EQU 4 -TURN_OFF EQU 5 -LOG_OFF EQU 6 - .PlayersPCMenuList1: db 5 - db WITHDRAW_ITEM - db DEPOSIT_ITEM - db TOSS_ITEM - db MAIL_BOX - db TURN_OFF - db -1 + db PLAYERSPC_WITHDRAW_ITEM + db PLAYERSPC_DEPOSIT_ITEM + db PLAYERSPC_TOSS_ITEM + db PLAYERSPC_MAIL_BOX + db PLAYERSPC_TURN_OFF + db -1 ; end .PlayersPCMenuList2: db 6 - db WITHDRAW_ITEM - db DEPOSIT_ITEM - db TOSS_ITEM - db MAIL_BOX - db DECORATION - db LOG_OFF - db -1 + db PLAYERSPC_WITHDRAW_ITEM + db PLAYERSPC_DEPOSIT_ITEM + db PLAYERSPC_TOSS_ITEM + db PLAYERSPC_MAIL_BOX + db PLAYERSPC_DECORATION + db PLAYERSPC_LOG_OFF + db -1 ; end PC_DisplayTextWaitMenu: ; 157bb ld a, [wOptions] @@ -461,13 +478,14 @@ PlayerDepositItemMenu: ; 0x1588b ret .dw - dw .tossable +; entries correspond to ITEMMENU_* constants + dw .tossable ; ITEMMENU_NOUSE dw .no_toss dw .no_toss dw .no_toss - dw .tossable - dw .tossable - dw .tossable + dw .tossable ; ITEMMENU_CURRENT + dw .tossable ; ITEMMENU_PARTY + dw .tossable ; ITEMMENU_CLOSE .no_toss ret diff --git a/maps/Route35GoldenrodGate.asm b/maps/Route35GoldenrodGate.asm index 52089c4db..71a1e510b 100644 --- a/maps/Route35GoldenrodGate.asm +++ b/maps/Route35GoldenrodGate.asm @@ -63,15 +63,17 @@ RandyScript: end GiftSpearowMail: - db FLOWER_MAIL + db FLOWER_MAIL db "DARK CAVE leads" next "to another road@" + GiftSpearowName: db "KENYA@" + GiftSpearowOTName: db "RANDY@" - db 0 + db 0 ; filler Route35GoldenrodGatePokefanFScript: faceplayer From ae50b1148ae48aa083e6d26dd27a662fffb950ed Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 19 May 2018 13:11:50 -0400 Subject: [PATCH 03/22] 1 << FRZ == $20 --- engine/battle/ai/scoring.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index 7af2db8ad..e83682427 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -1569,7 +1569,7 @@ AI_Smart_DefrostOpponent: ; 38ccb ; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused. ld a, [wEnemyMonStatus] - and $20 + and 1 << FRZ ret z dec [hl] dec [hl] From 03570a514e0bd4c64205b904b528b00d888a6d7f Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 19 May 2018 13:16:18 -0400 Subject: [PATCH 04/22] Correct comment --- data/types/type_matchups.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/types/type_matchups.asm b/data/types/type_matchups.asm index 90e38ae2c..3cd0f609b 100644 --- a/data/types/type_matchups.asm +++ b/data/types/type_matchups.asm @@ -109,11 +109,11 @@ TypeMatchups: ; 34bb1 db STEEL, ROCK, SUPER_EFFECTIVE db STEEL, STEEL, NOT_VERY_EFFECTIVE - db -2 ; end + db -2 ; end (with Foresight) ; Foresight removes Ghost's immunities. db NORMAL, GHOST, NO_EFFECT db FIGHTING, GHOST, NO_EFFECT - db -1 ; end (with Foresight) + db -1 ; end ; 34cfd From 9afacc7842a733770ec73893bb6c14d434c828e7 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sun, 20 May 2018 17:50:53 -0400 Subject: [PATCH 05/22] Use REGISTERED_* constants 128px wide pack_menu.png matches BGB VRAM viewer, and rows+cols match hex tile IDs (e.g. $24 = row 3 col 5) --- engine/items/pack.asm | 6 +++--- gfx/pack/pack_menu.png | Bin 360 -> 356 bytes 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/items/pack.asm b/engine/items/pack.asm index ea3a051ac..9f0e82f66 100644 --- a/engine/items/pack.asm +++ b/engine/items/pack.asm @@ -571,11 +571,11 @@ RegisterItem: ; 103c2 ld a, [wCurrPocket] rrca rrca - and $c0 + and REGISTERED_POCKET ld b, a ld a, [wCurItemQuantity] inc a - and $3f + and REGISTERED_NUMBER or b ld [wWhichRegisteredItem], a ld a, [wCurItem] @@ -1283,7 +1283,7 @@ DrawPackGFX: ; 1089d ld a, [wCurrPocket] maskbits NUM_POCKETS ld e, a - ld d, $0 + ld d, 0 ld a, [wBattleType] cp BATTLETYPE_TUTORIAL jr z, .male_dude diff --git a/gfx/pack/pack_menu.png b/gfx/pack/pack_menu.png index 52e2bcdd5e2a6b03b05597adee0994cb9cb7d6fa..aa693cc40be5c0907ea9fa844d889547db236657 100644 GIT binary patch literal 356 zcmV-q0h|7bP);&)}Epw*NEudVCEI>%n$hti_ zD5Ihlz(N2-zjcs=7*i>khQ#9VfqTJHv6gL9$gb7x13Uw6A_Ou<4vAsW;vO1_z5%rl z+=LmpIwY(8Ghm6by*ns7>_sS=Ba$Wm3P{zyWV9+v6FfqXIJ0$H3pvkX+>v;ii0k#hBiwNvQJfB!{0^IG?D9GYrqG( zna<|EU%*BCp2dEDVK(9)2cvbRWKj;fbCavr_4JZ--0000K77W2H>>(ZPcCcLtL~a7NGGO*5P)4%7cC-m5w;VDcus_c{ z`46Mi0CeLB3~<0#PzvRwETDpGL7joqSOQCA4aY0g>fRKP>d^)UFusD;>;ybV%be)} z7b6RV6pgH@gHcfnSO_5c2Xu_7gr+{RbbPF#vZ2Cp7Xe;ja5Ev0F@nUf7>IUI3ru1? z*N#-d5@ow|sAWXaHj)}h+2Z-g-Fox_``zIO(7u7b?Vz^9orZn~wXWA(>j{@j1GoEG z$NeSay@B&x_LBdMxYx?gygt8{w;fCj@CzjE3uy8O-~wAm8NqR+grbD9$1jWKc_z1i z9>52h%z80<=LLf8*XtRXO9$!w^VJdg-43A~j-mhc$LkYuv#so&#FD}Q0000 Date: Sun, 20 May 2018 17:55:27 -0400 Subject: [PATCH 06/22] =?UTF-8?q?adc=20a,=200=20=E2=86=92=20adc=200;=20fix?= =?UTF-8?q?=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- audio/engine.asm | 2 +- engine/pokemon/bills_pc_top.asm | 4 ++-- home/copy2.asm | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/audio/engine.asm b/audio/engine.asm index 50f2f5843..1560cbd8b 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -1775,7 +1775,7 @@ Music_Vibrato: ; e8882 swap a srl a ; halve ld e, a - adc a, 0; round up + adc 0 ; round up swap a or e ld [hl], a diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm index 1e808c02c..e25381e29 100644 --- a/engine/pokemon/bills_pc_top.asm +++ b/engine/pokemon/bills_pc_top.asm @@ -96,9 +96,9 @@ _BillsPC: ; e3fd dw BillsPC_SeeYa .items ; e4c4 - db 5 + db 5 ; # items db 0 ; WITHDRAW - db 1; DEPOSIT + db 1 ; DEPOSIT db 2 ; CHANGE BOX db 3 ; MOVE PKMN db 4 ; SEE YA! diff --git a/home/copy2.asm b/home/copy2.asm index 23e1eca7f..63f3cfafb 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -1,7 +1,7 @@ CopyBytes:: ; 0x3026 ; copy bc bytes from hl to de - inc b ; we bail the moment b hits 0, so include the last run - inc c ; same thing; include last byte + inc b ; we bail the moment b hits 0, so include the last run + inc c ; same thing; include last byte jr .HandleLoop .CopyByte: ld a, [hli] @@ -39,8 +39,8 @@ SwapBytes:: ; 0x3034 ByteFill:: ; 0x3041 ; fill bc bytes with the value of a, starting at hl - inc b ; we bail the moment b hits 0, so include the last run - inc c ; same thing; include last byte + inc b ; we bail the moment b hits 0, so include the last run + inc c ; same thing; include last byte jr .HandleLoop .PutByte: ld [hli], a From 5c064746f60cc2dc0d46539692f771ece03dd765 Mon Sep 17 00:00:00 2001 From: Rangi Date: Mon, 21 May 2018 21:54:56 -0400 Subject: [PATCH 07/22] =?UTF-8?q?Gme=20=E2=86=92=20Game?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maps/GoldenrodGameCorner.asm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/maps/GoldenrodGameCorner.asm b/maps/GoldenrodGameCorner.asm index dee306ba7..2e49a874b 100644 --- a/maps/GoldenrodGameCorner.asm +++ b/maps/GoldenrodGameCorner.asm @@ -46,10 +46,10 @@ GoldenrodGameCornerPokefanM3Script: turnobject GOLDENRODGAMECORNER_POKEFAN_M3, RIGHT end -GoldenrodGmeCornerCoinVendorScript: +GoldenrodGameCornerCoinVendorScript: jumpstd gamecornercoinvendor -GoldenrodGmeCornerTMVendorScript: +GoldenrodGameCornerTMVendorScript: faceplayer opentext writetext GoldenrodGameCornerPrizeVendorIntroText @@ -57,7 +57,7 @@ GoldenrodGmeCornerTMVendorScript: checkitem COIN_CASE iffalse GoldenrodGameCornerPrizeVendor_NoCoinCaseScript writetext GoldenrodGameCornerPrizeVendorWhichPrizeText -GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36 +GoldenrodGameCornerTMVendor_LoopScript: ; 056c36 special DisplayCoinCaseBalance loadmenu GoldenrodGameCornerTMVendorMenuHeader verticalmenu @@ -76,7 +76,7 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36 giveitem TM_THUNDER iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript takecoins 5500 - jump GoldenrodGmeCornerTMVendor_FinishScript + jump GoldenrodGameCornerTMVendor_FinishScript .Blizzard: checkcoins 5500 @@ -87,7 +87,7 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36 giveitem TM_BLIZZARD iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript takecoins 5500 - jump GoldenrodGmeCornerTMVendor_FinishScript + jump GoldenrodGameCornerTMVendor_FinishScript .FireBlast: checkcoins 5500 @@ -98,19 +98,19 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36 giveitem TM_FIRE_BLAST iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript takecoins 5500 - jump GoldenrodGmeCornerTMVendor_FinishScript + jump GoldenrodGameCornerTMVendor_FinishScript GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript: writetext GoldenrodGameCornerPrizeVendorConfirmPrizeText yesorno end -GoldenrodGmeCornerTMVendor_FinishScript: +GoldenrodGameCornerTMVendor_FinishScript: waitsfx playsound SFX_TRANSACTION writetext GoldenrodGameCornerPrizeVendorHereYouGoText waitbutton - jump GoldenrodGmeCornerTMVendor_LoopScript + jump GoldenrodGameCornerTMVendor_LoopScript GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript: writetext GoldenrodGameCornerPrizeVendorNeedMoreCoinsText @@ -477,8 +477,8 @@ GoldenrodGameCorner_MapEvents: bg_event 12, 1, BGEVENT_LEFT, GoldenrodGameCornerLeftTheirDrinkScript db 12 ; object events - object_event 3, 2, SPRITE_CLERK, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGmeCornerCoinVendorScript, -1 - object_event 16, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGmeCornerTMVendorScript, -1 + object_event 3, 2, SPRITE_CLERK, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerCoinVendorScript, -1 + object_event 16, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerTMVendorScript, -1 object_event 18, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPrizeMonVendorScript, -1 object_event 8, 7, SPRITE_PHARMACIST, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, DAY, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1 object_event 8, 7, SPRITE_PHARMACIST, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, NITE, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1 From ad5337863ddbb7b821f57a0c8af2c767cc767f19 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 00:05:07 -0400 Subject: [PATCH 08/22] Use SPRITE_VARS --- wram.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wram.asm b/wram.asm index 6ddcf2f42..9158a4047 100644 --- a/wram.asm +++ b/wram.asm @@ -2421,7 +2421,7 @@ wMapObjectsEnd:: wObjectMasks:: ds NUM_OBJECTS ; d81e -wVariableSprites:: ds 16; d82e +wVariableSprites:: ds $100 - SPRITE_VARS ; d82e wEnteredMapFromContinue:: db ; d83e ds 2 From d2880d1981876b06bc867ae17376e31f2d4df60d Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 11:08:23 -0400 Subject: [PATCH 09/22] =?UTF-8?q?Factor=20out=20GetHPPals=20and=20SetHPPal?= =?UTF-8?q?s=20from=20home.asm=20The=20remaining=20code=20in=20home.asm=20?= =?UTF-8?q?is=20almost=20all=20"generic",=20unrelated=20to=20Pok=C3=A9mon-?= =?UTF-8?q?specific=20game=20logic,=20so=20leaving=20it=20as-is=20might=20?= =?UTF-8?q?be=20neater=20than=20little=20home/*.asm=20files=20for=20each?= =?UTF-8?q?=20routine.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home.asm | 21 +-------------------- home/hp_pals.asm | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 home/hp_pals.asm diff --git a/home.asm b/home.asm index 1963e2f6a..9aaa50098 100644 --- a/home.asm +++ b/home.asm @@ -227,26 +227,7 @@ CompareLong:: ; 31e4 ; 31f3 INCLUDE "home/tilemap.asm" - -SetHPPal:: ; 334e -; Set palette for hp bar pixel length e at hl. - call GetHPPal - ld [hl], d - ret -; 3353 - -GetHPPal:: ; 3353 -; Get palette for hp bar pixel length e in d. - ld d, HP_GREEN - ld a, e - cp (50 * 48 / 100) - ret nc - inc d ; HP_YELLOW - cp (21 * 48 / 100) - ret nc - inc d ; HP_RED - ret -; 335f +INCLUDE "home/hp_pals.asm" CountSetBits:: ; 0x335f ; Count the number of set bits in b bytes starting from hl. diff --git a/home/hp_pals.asm b/home/hp_pals.asm new file mode 100644 index 000000000..527ec860e --- /dev/null +++ b/home/hp_pals.asm @@ -0,0 +1,19 @@ +SetHPPal:: ; 334e +; Set palette for hp bar pixel length e at hl. + call GetHPPal + ld [hl], d + ret +; 3353 + +GetHPPal:: ; 3353 +; Get palette for hp bar pixel length e in d. + ld d, HP_GREEN + ld a, e + cp (50 * 48 / 100) + ret nc + inc d ; HP_YELLOW + cp (21 * 48 / 100) + ret nc + inc d ; HP_RED + ret +; 335f From 4e776d4fa6bb0510fa06416ad7a6dd9ffe0ff724 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 11:14:15 -0400 Subject: [PATCH 10/22] Use constants --- home/hp_pals.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/hp_pals.asm b/home/hp_pals.asm index 527ec860e..221b93da0 100644 --- a/home/hp_pals.asm +++ b/home/hp_pals.asm @@ -9,10 +9,10 @@ GetHPPal:: ; 3353 ; Get palette for hp bar pixel length e in d. ld d, HP_GREEN ld a, e - cp (50 * 48 / 100) + cp (HP_BAR_LENGTH_PX * 50 / 100) ; 24 ret nc inc d ; HP_YELLOW - cp (21 * 48 / 100) + cp (HP_BAR_LENGTH_PX * 21 / 100) ; 10 ret nc inc d ; HP_RED ret From 32b92ca51c73f1ad9be169bef476b9c93687e2a4 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 12:48:14 -0400 Subject: [PATCH 11/22] Start improving sprite movement engine (to do: identify bit flags) Introduce maskbits N[, S]: optionally shift the bitmask --- constants/map_object_constants.asm | 11 +- data/sprites/map_objects.asm | 228 ++++++++++++++--------------- engine/battle/ai/scoring.asm | 4 +- engine/battle/effect_commands.asm | 2 +- engine/pokemon/move_mon.asm | 10 +- home/map_objects.asm | 20 +-- macros/code.asm | 8 +- mobile/mobile_40.asm | 2 +- 8 files changed, 150 insertions(+), 135 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 73685d4ec..43207a4dd 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -75,6 +75,16 @@ OVERHEAD EQU 3 const MAPOBJECT_F ; unused OBJECT_LENGTH EQU const_value +; SpriteMovementData struct members (see data/sprites/map_objects.asm) + const_def + const SPRITEMOVEATTR_MOVEMENT ; 0 + const SPRITEMOVEATTR_FACING ; 1 + const SPRITEMOVEATTR_ACTION ; 2 + const SPRITEMOVEATTR_FLAGS1 ; 3 + const SPRITEMOVEATTR_FLAGS2 ; 4 + const SPRITEMOVEATTR_PALFLAGS ; 5 +NUM_SPRITEMOVEDATA_FIELDS EQU const_value + MAPOBJECT_SCREEN_HEIGHT EQU 11 MAPOBJECT_SCREEN_WIDTH EQU 12 @@ -119,7 +129,6 @@ MAPOBJECT_SCREEN_WIDTH EQU 12 const SPRITEMOVEDATA_GRASS ; 23 const SPRITEMOVEDATA_SWIM_WANDER ; 24 NUM_SPRITEMOVEDATA EQU const_value -SPRITEMOVEDATA_FIELDS EQU 6 ; MapObjectMovementPattern.Pointers indexes (see engine/overworld/map_objects.asm) const_def diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 8821f8a1b..0e19b3787 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -5,304 +5,304 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STILL db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00001100 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 2 | 1 << 3 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WANDER db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINRANDOM_SLOW db SPRITEMOVEFN_SLOW_RANDOM_SPIN ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WALK_UP_DOWN db SPRITEMOVEFN_RANDOM_WALK_Y ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_WALK_LEFT_RIGHT db SPRITEMOVEFN_RANDOM_WALK_X ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_DOWN db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_UP db SPRITEMOVEFN_STANDING ; movement function db UP ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_LEFT db SPRITEMOVEFN_STANDING ; movement function db LEFT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STANDING_RIGHT db SPRITEMOVEFN_STANDING ; movement function db RIGHT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINRANDOM_FAST db SPRITEMOVEFN_FAST_RANDOM_SPIN ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_PLAYER db SPRITEMOVEFN_OBEY_DPAD ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0C db SPRITEMOVEFN_08 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0D db SPRITEMOVEFN_09 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0E db SPRITEMOVEFN_0A ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_0F db SPRITEMOVEFN_0B ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_10 db SPRITEMOVEFN_0C ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_11 db SPRITEMOVEFN_0D ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_12 db SPRITEMOVEFN_0E ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_FOLLOWING db SPRITEMOVEFN_FOLLOW ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SCRIPTED db SPRITEMOVEFN_SCRIPTED ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_BIGDOLLSYM db SPRITEMOVEFN_BIG_SNORLAX ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_SYM ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_POKEMON db SPRITEMOVEFN_BOUNCE ; movement function db DOWN ; facing db OBJECT_ACTION_BOUNCE ; action - db %00101110 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SUDOWOODO db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00001100 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 2 | 1 << 3 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SMASHABLE_ROCK db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00101110 ; flags1 - db %00010000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 4 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_STRENGTH_BOULDER db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00101110 ; flags1 - db %00000000 ; flags2 - db %01000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 0 ; flags2 + db 1 << 6 ; palette flags ; SPRITEMOVEDATA_FOLLOWNOTEXACT db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SHADOW db SPRITEMOVEFN_SHADOW ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db %10001110 ; flags1 - db %00000001 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_EMOTE db SPRITEMOVEFN_EMOTE ; movement function db DOWN ; facing db OBJECT_ACTION_EMOTE ; action - db %10001110 ; flags1 - db %00000010 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 1 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SCREENSHAKE db SPRITEMOVEFN_SCREENSHAKE ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db %10000010 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 7 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; movement function db LEFT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SPINCLOCKWISE db SPRITEMOVEFN_SPIN_CLOCKWISE ; movement function db RIGHT ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_BIGDOLLASYM db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_ASYM ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BIGDOLL db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL ; action - db %00101110 ; flags1 - db %00000001 ; flags2 - db %11000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 0 ; flags2 + db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BOULDERDUST db SPRITEMOVEFN_BOULDERDUST ; movement function db DOWN ; facing db OBJECT_ACTION_BOULDER_DUST ; action - db %10001110 ; flags1 - db %00000001 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 0 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_GRASS db SPRITEMOVEFN_GRASS ; movement function db DOWN ; facing db OBJECT_ACTION_GRASS_SHAKE ; action - db %10001110 ; flags1 - db %00000010 ; flags2 - db %00000000 ; palette flags + db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 + db 1 << 1 ; flags2 + db 0 ; palette flags ; SPRITEMOVEDATA_SWIM_WANDER db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00100000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 1 << 5 ; palette flags ; 25 db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db %00000000 ; flags1 - db %00000000 ; flags2 - db %00000000 ; palette flags + db 0 ; flags1 + db 0 ; flags2 + db 0 ; palette flags ; 4357 diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm index e83682427..567737c1f 100644 --- a/engine/battle/ai/scoring.asm +++ b/engine/battle/ai/scoring.asm @@ -1055,7 +1055,7 @@ AI_Smart_TrapTarget: ; 38a71 jr nz, .asm_38a91 ld a, [wPlayerSubStatus1] - and 1< Date: Wed, 23 May 2018 13:15:07 -0400 Subject: [PATCH 12/22] Use known sprite movement data flag constants --- constants/map_object_constants.asm | 22 +++++++++----- data/sprites/map_objects.asm | 40 +++++++++++++------------- engine/overworld/map_object_action.asm | 14 ++++----- engine/overworld/map_objects.asm | 18 ++++++------ engine/overworld/movement.asm | 14 ++++----- engine/overworld/scripting.asm | 2 +- 6 files changed, 59 insertions(+), 51 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 43207a4dd..5a6c446c8 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -44,16 +44,24 @@ OW_LEFT EQU LEFT << 2 OW_RIGHT EQU RIGHT << 2 ; object_struct OBJECT_FLAGS1 bit flags -INVISIBLE EQU 0 -FIXED_FACING EQU 2 -SLIDING EQU 3 -EMOTE_OBJECT EQU 7 +INVISIBLE_F EQU 0 +FIXED_FACING_F EQU 2 +SLIDING_F EQU 3 +EMOTE_OBJECT_F EQU 7 + +INVISIBLE EQU 1 << INVISIBLE_F +FIXED_FACING EQU 1 << FIXED_FACING_F +SLIDING EQU 1 << SLIDING_F +EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F ; object_struct OBJECT_FLAGS2 bit flags -LOW_PRIORITY EQU 0 -HIGH_PRIORITY EQU 1 -OVERHEAD EQU 3 +LOW_PRIORITY_F EQU 0 +HIGH_PRIORITY_F EQU 1 +OVERHEAD_F EQU 3 +LOW_PRIORITY EQU 1 << LOW_PRIORITY_F +HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F +OVERHEAD EQU 1 << OVERHEAD_F ; map_object struct members (see macros/wram.asm) const_def diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 0e19b3787..9410caea4 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -13,7 +13,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 2 | 1 << 3 ; flags1 + db FIXED_FACING | SLIDING ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -173,15 +173,15 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_BIG_SNORLAX ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_SYM ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 - db 1 << 0 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db LOW_PRIORITY ; flags2 db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_POKEMON db SPRITEMOVEFN_BOUNCE ; movement function db DOWN ; facing db OBJECT_ACTION_BOUNCE ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -189,7 +189,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 2 | 1 << 3 ; flags1 + db FIXED_FACING | SLIDING ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -197,7 +197,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db 1 << 4 ; flags2 db 0 ; palette flags @@ -205,7 +205,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db 0 ; flags2 db 1 << 6 ; palette flags @@ -221,23 +221,23 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_SHADOW ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 - db 1 << 0 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db LOW_PRIORITY ; flags2 db 0 ; palette flags ; SPRITEMOVEDATA_EMOTE db SPRITEMOVEFN_EMOTE ; movement function db DOWN ; facing db OBJECT_ACTION_EMOTE ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 - db 1 << 1 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db HIGH_PRIORITY ; flags2 db 0 ; palette flags ; SPRITEMOVEDATA_SCREENSHAKE db SPRITEMOVEFN_SCREENSHAKE ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db 1 << 1 | 1 << 7 ; flags1 + db 1 << 1 | EMOTE_OBJECT ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -261,32 +261,32 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_ASYM ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 - db 1 << 0 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db LOW_PRIORITY ; flags2 db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BIGDOLL db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 5 ; flags1 - db 1 << 0 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db LOW_PRIORITY ; flags2 db 1 << 6 | 1 << 7 ; palette flags ; SPRITEMOVEDATA_BOULDERDUST db SPRITEMOVEFN_BOULDERDUST ; movement function db DOWN ; facing db OBJECT_ACTION_BOULDER_DUST ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 - db 1 << 0 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db LOW_PRIORITY ; flags2 db 0 ; palette flags ; SPRITEMOVEDATA_GRASS db SPRITEMOVEFN_GRASS ; movement function db DOWN ; facing db OBJECT_ACTION_GRASS_SHAKE ; action - db 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7 ; flags1 - db 1 << 1 ; flags2 + db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db HIGH_PRIORITY ; flags2 db 0 ; palette flags ; SPRITEMOVEDATA_SWIM_WANDER diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm index c82cd80a2..8c897d25a 100644 --- a/engine/overworld/map_object_action.asm +++ b/engine/overworld/map_object_action.asm @@ -47,7 +47,7 @@ SetFacingStandAction: ; 44b5 SetFacingStepAction: ; 44c1 ld hl, OBJECT_FLAGS1 add hl, bc - bit SLIDING, [hl] + bit SLIDING_F, [hl] jp nz, SetFacingCurrent ld hl, OBJECT_STEP_FRAME @@ -59,7 +59,7 @@ SetFacingStepAction: ; 44c1 rrca rrca - and %00000011 + maskbits NUM_DIRECTIONS ld d, a call GetSpriteDirection @@ -74,7 +74,7 @@ SetFacingStepAction: ; 44c1 SetFacingSkyfall: ; 44e4 ld hl, OBJECT_FLAGS1 add hl, bc - bit SLIDING, [hl] + bit SLIDING_F, [hl] jp nz, SetFacingCurrent ld hl, OBJECT_STEP_FRAME @@ -86,7 +86,7 @@ SetFacingSkyfall: ; 44e4 rrca rrca - and %00000011 + maskbits NUM_DIRECTIONS ld d, a call GetSpriteDirection @@ -101,7 +101,7 @@ SetFacingSkyfall: ; 44e4 SetFacingBumpAction: ; 4508 ld hl, OBJECT_FLAGS1 add hl, bc - bit SLIDING, [hl] + bit SLIDING_F, [hl] jp nz, SetFacingCurrent ld hl, OBJECT_STEP_FRAME @@ -112,7 +112,7 @@ SetFacingBumpAction: ; 4508 rrca rrca rrca - and %00000011 + maskbits NUM_DIRECTIONS ld d, a call GetSpriteDirection @@ -245,7 +245,7 @@ SetFacingWeirdTree: ; 45ab ld a, [hl] inc a ld [hl], a - and %00001100 + maskbits NUM_DIRECTIONS, 2 rrca rrca add FACING_WEIRD_TREE_0 diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 1573a27b5..c9f1d7d1b 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -146,7 +146,7 @@ Function437b: ; 437b .HandleObjectAction: ld hl, OBJECT_FLAGS1 add hl, bc - bit INVISIBLE, [hl] + bit INVISIBLE_F, [hl] jr nz, SetFacingStanding ld hl, OBJECT_FLAGS2 add hl, bc @@ -161,7 +161,7 @@ Function437b: ; 437b Function4440: ; 4440 ld hl, OBJECT_FLAGS1 add hl, bc - bit INVISIBLE, [hl] + bit INVISIBLE_F, [hl] jr nz, SetFacingStanding asm_4448: ld de, ObjectActionPairPointers + 2 ; use second column @@ -233,7 +233,7 @@ Function462a: ; 462a UpdateTallGrassFlags: ; 463f ld hl, OBJECT_FLAGS2 add hl, bc - bit OVERHEAD, [hl] + bit OVERHEAD_F, [hl] jr z, .ok ld hl, OBJECT_NEXT_TILE add hl, bc @@ -260,13 +260,13 @@ SetTallGrassFlags: ; 4661 .set ld hl, OBJECT_FLAGS2 add hl, bc - set OVERHEAD, [hl] + set OVERHEAD_F, [hl] ret .reset ld hl, OBJECT_FLAGS2 add hl, bc - res OVERHEAD, [hl] + res OVERHEAD_F, [hl] ret ; 4679 @@ -298,7 +298,7 @@ InitStep: ; 4690 ld [hl], a ld hl, OBJECT_FLAGS1 add hl, bc - bit FIXED_FACING, [hl] + bit FIXED_FACING_F, [hl] jr nz, GetNextTile add a add a @@ -2155,7 +2155,7 @@ DespawnEmote: ; 5579 push af ld hl, OBJECT_FLAGS1 add hl, de - bit EMOTE_OBJECT, [hl] + bit EMOTE_OBJECT_F, [hl] jr z, .next ld hl, OBJECT_SPRITE add hl, de @@ -2918,10 +2918,10 @@ InitSprites: ; 5991 ld e, PRIORITY_LOW ld hl, OBJECT_FLAGS2 add hl, bc - bit LOW_PRIORITY, [hl] + bit LOW_PRIORITY_F, [hl] jr nz, .add ld e, PRIORITY_NORM - bit HIGH_PRIORITY, [hl] + bit HIGH_PRIORITY_F, [hl] jr z, .add ld e, PRIORITY_HIGH jr .add diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 3dbb0b83a..fcb8d55fb 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -377,42 +377,42 @@ Movement_tree_shake: ; 5279 Movement_remove_sliding: ; 5293 ld hl, OBJECT_FLAGS1 add hl, bc - res SLIDING, [hl] + res SLIDING_F, [hl] jp ContinueReadingMovement ; 529c Movement_set_sliding: ; 529c ld hl, OBJECT_FLAGS1 add hl, bc - set SLIDING, [hl] + set SLIDING_F, [hl] jp ContinueReadingMovement ; 52a5 Movement_remove_fixed_facing: ; 52a5 ld hl, OBJECT_FLAGS1 add hl, bc - res FIXED_FACING, [hl] + res FIXED_FACING_F, [hl] jp ContinueReadingMovement ; 52ae Movement_fix_facing: ; 52ae ld hl, OBJECT_FLAGS1 add hl, bc - set FIXED_FACING, [hl] + set FIXED_FACING_F, [hl] jp ContinueReadingMovement ; 52b7 Movement_show_object: ; 52b7 ld hl, OBJECT_FLAGS1 add hl, bc - res INVISIBLE, [hl] + res INVISIBLE_F, [hl] jp ContinueReadingMovement ; 52c0 Movement_hide_object: ; 52c0 ld hl, OBJECT_FLAGS1 add hl, bc - set INVISIBLE, [hl] + set INVISIBLE_F, [hl] jp ContinueReadingMovement ; 52c9 @@ -838,7 +838,7 @@ JumpStep: ; 548a ld hl, OBJECT_FLAGS2 add hl, bc - res OVERHEAD, [hl] + res OVERHEAD_F, [hl] ld hl, OBJECT_ACTION add hl, bc diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm index a18be2e6c..a2315a541 100644 --- a/engine/overworld/scripting.asm +++ b/engine/overworld/scripting.asm @@ -1071,7 +1071,7 @@ ApplyObjectFacing: jr c, .not_visible ; STILL_SPRITE ld hl, OBJECT_FLAGS1 add hl, bc - bit FIXED_FACING, [hl] + bit FIXED_FACING_F, [hl] jr nz, .not_visible pop de ld a, e From c85b32ed8035ce51dd9d3bd52440cebd912ce92c Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 19:06:04 -0400 Subject: [PATCH 13/22] More sprite movement data flag constants --- constants/map_object_constants.asm | 9 +++++++++ data/sprites/map_objects.asm | 10 +++++----- engine/overworld/map_objects.asm | 2 +- engine/overworld/npc_movement.asm | 8 ++++---- engine/overworld/player_movement.asm | 4 ++-- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 5a6c446c8..bcf70b428 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -63,6 +63,15 @@ LOW_PRIORITY EQU 1 << LOW_PRIORITY_F HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F OVERHEAD EQU 1 << OVERHEAD_F +; object_struct OBJECT_PALETTE bit flags +WALK_ON_WATER_F EQU 5 +STRENGTH_BOULDER_F EQU 6 +BIG_OBJECT_F EQU 7 + +WALK_ON_WATER EQU 1 << WALK_ON_WATER_F +STRENGTH_BOULDER EQU 1 << STRENGTH_BOULDER_F +BIG_OBJECT EQU 1 << BIG_OBJECT_F + ; map_object struct members (see macros/wram.asm) const_def const MAPOBJECT_OBJECT_STRUCT_ID ; 0 diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 9410caea4..8136fcdf8 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -175,7 +175,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_BIG_DOLL_SYM ; action db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db LOW_PRIORITY ; flags2 - db 1 << 6 | 1 << 7 ; palette flags + db STRENGTH_BOULDER | BIG_OBJECT ; palette flags ; SPRITEMOVEDATA_POKEMON db SPRITEMOVEFN_BOUNCE ; movement function @@ -207,7 +207,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_STAND ; action db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db 0 ; flags2 - db 1 << 6 ; palette flags + db STRENGTH_BOULDER ; palette flags ; SPRITEMOVEDATA_FOLLOWNOTEXACT db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function @@ -263,7 +263,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_BIG_DOLL_ASYM ; action db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db LOW_PRIORITY ; flags2 - db 1 << 6 | 1 << 7 ; palette flags + db STRENGTH_BOULDER | BIG_OBJECT ; palette flags ; SPRITEMOVEDATA_BIGDOLL db SPRITEMOVEFN_STRENGTH ; movement function @@ -271,7 +271,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_BIG_DOLL ; action db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 db LOW_PRIORITY ; flags2 - db 1 << 6 | 1 << 7 ; palette flags + db STRENGTH_BOULDER | BIG_OBJECT ; palette flags ; SPRITEMOVEDATA_BOULDERDUST db SPRITEMOVEFN_BOULDERDUST ; movement function @@ -295,7 +295,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_STAND ; action db 0 ; flags1 db 0 ; flags2 - db 1 << 5 ; palette flags + db WALK_ON_WATER ; palette flags ; 25 db SPRITEMOVEFN_00 ; movement function diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index c9f1d7d1b..74b82880d 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2444,7 +2444,7 @@ Function56cd: ; 56cd ld [hUsedSpriteTile], a ld hl, OBJECT_PALETTE add hl, bc - bit 7, [hl] + bit BIG_OBJECT_F, [hl] jr z, .ok7 ld a, d add 2 diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 5670935e8..d54061919 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -2,8 +2,8 @@ Function6ec1: ; 6ec1 ld hl, OBJECT_PALETTE add hl, bc - bit 5, [hl] - jr z, .not_bit_5 + bit WALK_ON_WATER_F, [hl] + jr z, .walks_on_land ld hl, OBJECT_FLAGS1 add hl, bc @@ -17,7 +17,7 @@ Function6ec1: ; 6ec1 ret c jr .resume -.not_bit_5 +.walks_on_land ld hl, OBJECT_FLAGS1 add hl, bc bit 4, [hl] @@ -331,7 +331,7 @@ IsNPCAtCoord: ; 7041 ld hl, OBJECT_PALETTE add hl, bc - bit 7, [hl] + bit BIG_OBJECT_F, [hl] jr z, .got call Function7171 diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm index ef9afc7ad..f8bbe4952 100644 --- a/engine/overworld/player_movement.asm +++ b/engine/overworld/player_movement.asm @@ -684,7 +684,7 @@ DoPlayerMovement:: ; 80000 ld hl, OBJECT_PALETTE add hl, bc - bit 6, [hl] + bit STRENGTH_BOULDER_F, [hl] jr z, .not_boulder ld hl, OBJECT_FLAGS2 @@ -696,7 +696,7 @@ DoPlayerMovement:: ; 80000 ld hl, OBJECT_RANGE add hl, bc ld a, [hl] - and $fc + and %11111100 or d ld [hl], a From 50ea6d6e22804441c028e8bbbdd3e0720b4478c5 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 19:10:15 -0400 Subject: [PATCH 14/22] =?UTF-8?q?WALKS=5FON=5FWATER=20=E2=86=92=20SWIMMING?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/map_object_constants.asm | 4 ++-- data/sprites/map_objects.asm | 2 +- engine/overworld/npc_movement.asm | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index bcf70b428..191b3af9c 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -64,11 +64,11 @@ HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F OVERHEAD EQU 1 << OVERHEAD_F ; object_struct OBJECT_PALETTE bit flags -WALK_ON_WATER_F EQU 5 +SWIMMING_F EQU 5 STRENGTH_BOULDER_F EQU 6 BIG_OBJECT_F EQU 7 -WALK_ON_WATER EQU 1 << WALK_ON_WATER_F +SWIMMING EQU 1 << SWIMMING_F STRENGTH_BOULDER EQU 1 << STRENGTH_BOULDER_F BIG_OBJECT EQU 1 << BIG_OBJECT_F diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 8136fcdf8..ad712b967 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -295,7 +295,7 @@ SpriteMovementData:: ; 4273 db OBJECT_ACTION_STAND ; action db 0 ; flags1 db 0 ; flags2 - db WALK_ON_WATER ; palette flags + db SWIMMING ; palette flags ; 25 db SPRITEMOVEFN_00 ; movement function diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index d54061919..a8bb5e138 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -2,8 +2,8 @@ Function6ec1: ; 6ec1 ld hl, OBJECT_PALETTE add hl, bc - bit WALK_ON_WATER_F, [hl] - jr z, .walks_on_land + bit SWIMMING_F, [hl] + jr z, .not_swimming ld hl, OBJECT_FLAGS1 add hl, bc @@ -17,7 +17,7 @@ Function6ec1: ; 6ec1 ret c jr .resume -.walks_on_land +.not_swimming ld hl, OBJECT_FLAGS1 add hl, bc bit 4, [hl] From 85f7328bf853d30c23149151718c2ccef337ced5 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 20:44:32 -0400 Subject: [PATCH 15/22] Identify USE_OBP1_F --- constants/map_object_constants.asm | 2 ++ data/sprites/map_objects.asm | 2 +- engine/overworld/map_objects.asm | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 191b3af9c..6b9d3cacf 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -58,10 +58,12 @@ EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F LOW_PRIORITY_F EQU 0 HIGH_PRIORITY_F EQU 1 OVERHEAD_F EQU 3 +USE_OBP1_F EQU 4 LOW_PRIORITY EQU 1 << LOW_PRIORITY_F HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F OVERHEAD EQU 1 << OVERHEAD_F +USE_OBP1 EQU 1 << USE_OBP1_F ; object_struct OBJECT_PALETTE bit flags SWIMMING_F EQU 5 diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index ad712b967..c6070272b 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -198,7 +198,7 @@ SpriteMovementData:: ; 4273 db DOWN ; facing db OBJECT_ACTION_STAND ; action db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 - db 1 << 4 ; flags2 + db USE_OBP1 ; flags2 db 0 ; palette flags ; SPRITEMOVEDATA_STRENGTH_BOULDER diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 74b82880d..765f3f93c 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2973,35 +2973,35 @@ InitSprites: ; 5991 ld hl, OBJECT_SPRITE_TILE add hl, bc ld a, [hl] - and %01111111 + and $ff ^ (1 << 7) ld [hFFC1], a xor a bit 7, [hl] jr nz, .skip1 - or %00001000 + or VRAM_BANK_1 .skip1 ld hl, OBJECT_FLAGS2 add hl, bc ld e, [hl] bit 7, e jr z, .skip2 - or %10000000 + or PRIORITY .skip2 - bit 4, e + bit USE_OBP1_F, e jr z, .skip3 - or %00010000 + or OBP_NUM .skip3 ld hl, OBJECT_PALETTE add hl, bc ld d, a ld a, [hl] - and %00000111 + and PALETTE_MASK or d ld d, a xor a - bit 3, e + bit OVERHEAD_F, e jr z, .skip4 - or %10000000 + or PRIORITY .skip4 ld [hFFC2], a ld hl, OBJECT_SPRITE_X From 1840af8b4f02d6b8f748ea917344c64cb1c5ff2d Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 22:01:21 -0400 Subject: [PATCH 16/22] Identify more sprite move data flag bits --- constants/map_object_constants.asm | 53 ++++++++++----- data/sprites/facings.asm | 100 ++++++++++++++--------------- data/sprites/map_objects.asm | 32 ++++----- docs/bugs_and_glitches.md | 6 +- engine/overworld/map_objects.asm | 6 +- engine/overworld/npc_movement.asm | 39 +++++------ 6 files changed, 128 insertions(+), 108 deletions(-) diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm index 6b9d3cacf..ee0b21356 100644 --- a/constants/map_object_constants.asm +++ b/constants/map_object_constants.asm @@ -44,21 +44,32 @@ OW_LEFT EQU LEFT << 2 OW_RIGHT EQU RIGHT << 2 ; object_struct OBJECT_FLAGS1 bit flags -INVISIBLE_F EQU 0 -FIXED_FACING_F EQU 2 -SLIDING_F EQU 3 -EMOTE_OBJECT_F EQU 7 + const_def + const INVISIBLE_F ; 0 + const WONT_DELETE_F ; 1 + const FIXED_FACING_F ; 2 + const SLIDING_F ; 3 + const NOCLIP_TILES_F ; 4 + const MOVE_ANYWHERE_F ; 5 + const NOCLIP_OBJS_F ; 6 + const EMOTE_OBJECT_F ; 7 -INVISIBLE EQU 1 << INVISIBLE_F -FIXED_FACING EQU 1 << FIXED_FACING_F -SLIDING EQU 1 << SLIDING_F -EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F +INVISIBLE EQU 1 << INVISIBLE_F +WONT_DELETE EQU 1 << WONT_DELETE_F +FIXED_FACING EQU 1 << FIXED_FACING_F +SLIDING EQU 1 << SLIDING_F +NOCLIP_TILES EQU 1 << NOCLIP_TILES_F +MOVE_ANYWHERE EQU 1 << MOVE_ANYWHERE_F +NOCLIP_OBJS EQU 1 << NOCLIP_OBJS_F +EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F ; object_struct OBJECT_FLAGS2 bit flags -LOW_PRIORITY_F EQU 0 -HIGH_PRIORITY_F EQU 1 -OVERHEAD_F EQU 3 -USE_OBP1_F EQU 4 + const_def + const LOW_PRIORITY_F ; 0 + const HIGH_PRIORITY_F ; 1 + const OBJ_FLAGS2_2 ; 2 + const OVERHEAD_F ; 3 + const USE_OBP1_F ; 4 LOW_PRIORITY EQU 1 << LOW_PRIORITY_F HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F @@ -66,14 +77,22 @@ OVERHEAD EQU 1 << OVERHEAD_F USE_OBP1 EQU 1 << USE_OBP1_F ; object_struct OBJECT_PALETTE bit flags -SWIMMING_F EQU 5 -STRENGTH_BOULDER_F EQU 6 -BIG_OBJECT_F EQU 7 + const_def 5 + const SWIMMING_F ; 5 + const STRENGTH_BOULDER_F ; 6 + const BIG_OBJECT_F ; 7 SWIMMING EQU 1 << SWIMMING_F STRENGTH_BOULDER EQU 1 << STRENGTH_BOULDER_F BIG_OBJECT EQU 1 << BIG_OBJECT_F +; facing attribute bit flags +RELATIVE_ATTRIBUTES_F EQU 1 +ABSOLUTE_TILE_ID_F EQU 2 + +RELATIVE_ATTRIBUTES EQU 1 << RELATIVE_ATTRIBUTES_F +ABSOLUTE_TILE_ID EQU 1 << ABSOLUTE_TILE_ID_F + ; map_object struct members (see macros/wram.asm) const_def const MAPOBJECT_OBJECT_STRUCT_ID ; 0 @@ -104,8 +123,8 @@ OBJECT_LENGTH EQU const_value const SPRITEMOVEATTR_PALFLAGS ; 5 NUM_SPRITEMOVEDATA_FIELDS EQU const_value -MAPOBJECT_SCREEN_HEIGHT EQU 11 -MAPOBJECT_SCREEN_WIDTH EQU 12 +MAPOBJECT_SCREEN_WIDTH EQU (SCREEN_WIDTH / 2) + 2 +MAPOBJECT_SCREEN_HEIGHT EQU (SCREEN_HEIGHT / 2) + 2 ; SpriteMovementData indexes (see data/sprites/map_objects.asm) diff --git a/data/sprites/facings.asm b/data/sprites/facings.asm index 166455707..c321ca462 100644 --- a/data/sprites/facings.asm +++ b/data/sprites/facings.asm @@ -50,24 +50,24 @@ FacingWeirdTree2: ; standing down db 4 ; # db 0, 0, 0, $00 db 0, 8, 0, $01 - db 8, 0, 2, $02 - db 8, 8, 2, $03 + db 8, 0, RELATIVE_ATTRIBUTES, $02 + db 8, 8, RELATIVE_ATTRIBUTES, $03 ; 409c FacingStepDown1: ; walking down 1 db 4 ; # db 0, 0, 0, $80 db 0, 8, 0, $81 - db 8, 0, 2, $82 - db 8, 8, 2, $83 + db 8, 0, RELATIVE_ATTRIBUTES, $82 + db 8, 8, RELATIVE_ATTRIBUTES, $83 ; 40ad FacingStepDown3: ; walking down 2 db 4 ; # db 0, 8, X_FLIP, $80 db 0, 0, X_FLIP, $81 - db 8, 8, 2 | X_FLIP, $82 - db 8, 0, 2 | X_FLIP, $83 + db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $82 + db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $83 ; 40be FacingStepUp0: @@ -75,24 +75,24 @@ FacingStepUp2: ; standing up db 4 ; # db 0, 0, 0, $04 db 0, 8, 0, $05 - db 8, 0, 2, $06 - db 8, 8, 2, $07 + db 8, 0, RELATIVE_ATTRIBUTES, $06 + db 8, 8, RELATIVE_ATTRIBUTES, $07 ; 40cf FacingStepUp1: ; walking up 1 db 4 ; # db 0, 0, 0, $84 db 0, 8, 0, $85 - db 8, 0, 2, $86 - db 8, 8, 2, $87 + db 8, 0, RELATIVE_ATTRIBUTES, $86 + db 8, 8, RELATIVE_ATTRIBUTES, $87 ; 40e0 FacingStepUp3: ; walking up 2 db 4 ; # db 0, 8, X_FLIP, $84 db 0, 0, X_FLIP, $85 - db 8, 8, 2 | X_FLIP, $86 - db 8, 0, 2 | X_FLIP, $87 + db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $86 + db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $87 ; 40f1 FacingStepLeft0: @@ -100,8 +100,8 @@ FacingStepLeft2: ; standing left db 4 ; # db 0, 0, 0, $08 db 0, 8, 0, $09 - db 8, 0, 2, $0a - db 8, 8, 2, $0b + db 8, 0, RELATIVE_ATTRIBUTES, $0a + db 8, 8, RELATIVE_ATTRIBUTES, $0b ; 4102 FacingStepRight0: @@ -109,8 +109,8 @@ FacingStepRight2: ; standing right db 4 ; # db 0, 8, X_FLIP, $08 db 0, 0, X_FLIP, $09 - db 8, 8, 2 | X_FLIP, $0a - db 8, 0, 2 | X_FLIP, $0b + db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $0a + db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $0b ; 4113 FacingStepLeft1: @@ -118,8 +118,8 @@ FacingStepLeft3: ; walking left db 4 ; # db 0, 0, 0, $88 db 0, 8, 0, $89 - db 8, 0, 2, $8a - db 8, 8, 2, $8b + db 8, 0, RELATIVE_ATTRIBUTES, $8a + db 8, 8, RELATIVE_ATTRIBUTES, $8b ; 4124 FacingStepRight1: @@ -127,58 +127,58 @@ FacingStepRight3: ; walking right db 4 ; # db 0, 8, X_FLIP, $88 db 0, 0, X_FLIP, $89 - db 8, 8, 2 | X_FLIP, $8a - db 8, 0, 2 | X_FLIP, $8b + db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $8a + db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $8b ; 4135 FacingFishDown: ; fishing down db 5 ; # db 0, 0, 0, $00 db 0, 8, 0, $01 - db 8, 0, 2, $02 - db 8, 8, 2, $03 - db 16, 0, 4, $fc + db 8, 0, RELATIVE_ATTRIBUTES, $02 + db 8, 8, RELATIVE_ATTRIBUTES, $03 + db 16, 0, ABSOLUTE_TILE_ID, $fc ; 414a FacingFishUp: ; fishing up db 5 ; # db 0, 0, 0, $04 db 0, 8, 0, $05 - db 8, 0, 2, $06 - db 8, 8, 2, $07 - db -8, 0, 4, $fc + db 8, 0, RELATIVE_ATTRIBUTES, $06 + db 8, 8, RELATIVE_ATTRIBUTES, $07 + db -8, 0, ABSOLUTE_TILE_ID, $fc ; 415f FacingFishLeft: ; fishing left db 5 ; # db 0, 0, 0, $08 db 0, 8, 0, $09 - db 8, 0, 2, $0a - db 8, 8, 2, $0b - db 5, -8, 4 | X_FLIP, $fd + db 8, 0, RELATIVE_ATTRIBUTES, $0a + db 8, 8, RELATIVE_ATTRIBUTES, $0b + db 5, -8, ABSOLUTE_TILE_ID | X_FLIP, $fd ; 4174 FacingFishRight: ; fishing right db 5 ; # db 0, 8, X_FLIP, $08 db 0, 0, X_FLIP, $09 - db 8, 8, 2 | X_FLIP, $0a - db 8, 0, 2 | X_FLIP, $0b - db 5, 16, 4, $fd + db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $0a + db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $0b + db 5, 16, ABSOLUTE_TILE_ID, $fd ; 4189 FacingEmote: ; emote db 4 ; # - db 0, 0, 4, $f8 - db 0, 8, 4, $f9 - db 8, 0, 4, $fa - db 8, 8, 4, $fb + db 0, 0, ABSOLUTE_TILE_ID, $f8 + db 0, 8, ABSOLUTE_TILE_ID, $f9 + db 8, 0, ABSOLUTE_TILE_ID, $fa + db 8, 8, ABSOLUTE_TILE_ID, $fb ; 419a FacingShadow: ; shadow db 2 ; # - db 0, 0, 4, $fc - db 0, 8, 4 | X_FLIP, $fc + db 0, 0, ABSOLUTE_TILE_ID, $fc + db 0, 8, ABSOLUTE_TILE_ID | X_FLIP, $fc ; 41a3 FacingBigDollSymmetric: ; big snorlax or lapras doll @@ -237,28 +237,28 @@ FacingBigDollAsymmetric: ; big doll other than snorlax or lapras FacingBoulderDust1: ; boulder dust 1 db 4 ; # - db 0, 0, 4, $fe - db 0, 8, 4, $fe - db 8, 0, 4, $fe - db 8, 8, 4, $fe + db 0, 0, ABSOLUTE_TILE_ID, $fe + db 0, 8, ABSOLUTE_TILE_ID, $fe + db 8, 0, ABSOLUTE_TILE_ID, $fe + db 8, 8, ABSOLUTE_TILE_ID, $fe ; 4250 FacingBoulderDust2: ; boulder dust 2 db 4 ; # - db 0, 0, 4, $ff - db 0, 8, 4, $ff - db 8, 0, 4, $ff - db 8, 8, 4, $ff + db 0, 0, ABSOLUTE_TILE_ID, $ff + db 0, 8, ABSOLUTE_TILE_ID, $ff + db 8, 0, ABSOLUTE_TILE_ID, $ff + db 8, 8, ABSOLUTE_TILE_ID, $ff ; 4261 FacingGrass1: ; 4261 db 2 ; # - db 8, 0, 4, $fe - db 8, 8, 4 | X_FLIP, $fe + db 8, 0, ABSOLUTE_TILE_ID, $fe + db 8, 8, ABSOLUTE_TILE_ID | X_FLIP, $fe ; 426a FacingGrass2: ; 426a db 2 ; # - db 9, -1, 4, $fe - db 9, 9, 4 | X_FLIP, $fe + db 9, -1, ABSOLUTE_TILE_ID, $fe + db 9, 9, ABSOLUTE_TILE_ID | X_FLIP, $fe ; 4273 diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index c6070272b..cf577869a 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -5,7 +5,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 ; flags1 + db WONT_DELETE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -93,7 +93,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_OBEY_DPAD ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 ; flags1 + db WONT_DELETE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -157,7 +157,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_FOLLOW ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 ; flags1 + db WONT_DELETE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -165,7 +165,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_SCRIPTED ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 ; flags1 + db WONT_DELETE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -173,7 +173,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_BIG_SNORLAX ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_SYM ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db LOW_PRIORITY ; flags2 db STRENGTH_BOULDER | BIG_OBJECT ; palette flags @@ -181,7 +181,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_BOUNCE ; movement function db DOWN ; facing db OBJECT_ACTION_BOUNCE ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -197,7 +197,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STANDING ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db USE_OBP1 ; flags2 db 0 ; palette flags @@ -205,7 +205,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db 0 ; flags2 db STRENGTH_BOULDER ; palette flags @@ -213,7 +213,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action - db 1 << 1 ; flags1 + db WONT_DELETE ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -221,7 +221,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_SHADOW ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 db LOW_PRIORITY ; flags2 db 0 ; palette flags @@ -229,7 +229,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_EMOTE ; movement function db DOWN ; facing db OBJECT_ACTION_EMOTE ; action - db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 db HIGH_PRIORITY ; flags2 db 0 ; palette flags @@ -237,7 +237,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_SCREENSHAKE ; movement function db DOWN ; facing db OBJECT_ACTION_00 ; action - db 1 << 1 | EMOTE_OBJECT ; flags1 + db WONT_DELETE | EMOTE_OBJECT ; flags1 db 0 ; flags2 db 0 ; palette flags @@ -261,7 +261,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL_ASYM ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db LOW_PRIORITY ; flags2 db STRENGTH_BOULDER | BIG_OBJECT ; palette flags @@ -269,7 +269,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_STRENGTH ; movement function db DOWN ; facing db OBJECT_ACTION_BIG_DOLL ; action - db 1 << 1 | FIXED_FACING | SLIDING | 1 << 5 ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1 db LOW_PRIORITY ; flags2 db STRENGTH_BOULDER | BIG_OBJECT ; palette flags @@ -277,7 +277,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_BOULDERDUST ; movement function db DOWN ; facing db OBJECT_ACTION_BOULDER_DUST ; action - db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 db LOW_PRIORITY ; flags2 db 0 ; palette flags @@ -285,7 +285,7 @@ SpriteMovementData:: ; 4273 db SPRITEMOVEFN_GRASS ; movement function db DOWN ; facing db OBJECT_ACTION_GRASS_SHAKE ; action - db 1 << 1 | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 + db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1 db HIGH_PRIORITY ; flags2 db 0 ; palette flags diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index f7675ae78..b78244d4c 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -1194,11 +1194,11 @@ In [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm): ```asm ld hl, OBJECT_FLAGS1 add hl, bc - bit 4, [hl] ; lost, uncomment next line to fix -; jr nz, .resume + bit NOCLIP_TILES_F, [hl] ; lost, uncomment next line to fix + ; jr nz, .noclip_tiles ``` -**Fix:** Uncomment `jr nz, .resume`. +**Fix:** Uncomment `jr nz, .noclip_tiles`. ## `CheckOwnMon` only checks the first five letters of OT names diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 765f3f93c..d2ce598e1 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -93,7 +93,7 @@ Function437b: ; 437b .ok2 ld hl, OBJECT_FLAGS1 add hl, bc - bit 1, [hl] + bit WONT_DELETE_F, [hl] jr nz, .yes2 call DeleteMapObject scf @@ -3063,7 +3063,7 @@ InitSprites: ; 5991 ld e, [hl] inc hl ld a, [hFFC1] - bit 2, e + bit ABSOLUTE_TILE_ID_F, e jr z, .nope1 xor a .nope1 @@ -3072,7 +3072,7 @@ InitSprites: ; 5991 ld [bc], a ; tile id inc c ld a, e - bit 1, a + bit RELATIVE_ATTRIBUTES_F, a jr z, .nope2 ld a, [hFFC2] or e diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index a8bb5e138..66b64037c 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -7,31 +7,32 @@ Function6ec1: ; 6ec1 ld hl, OBJECT_FLAGS1 add hl, bc - bit 4, [hl] ; lost, uncomment next line to fix -; jr nz, .resume + bit NOCLIP_TILES_F, [hl] ; lost, uncomment next line to fix + ; jr nz, .noclip_tiles push hl push bc - call Function6f2c + call WillObjectBumpIntoLand pop bc pop hl ret c - jr .resume + jr .continue .not_swimming ld hl, OBJECT_FLAGS1 add hl, bc - bit 4, [hl] - jr nz, .resume + bit NOCLIP_TILES_F, [hl] + jr nz, .noclip_tiles push hl push bc - call Function6f07 + call WillObjectBumpIntoWater pop bc pop hl ret c -.resume - bit 6, [hl] - jr nz, .bit_6 +.noclip_tiles +.continue + bit NOCLIP_OBJS_F, [hl] + jr nz, .noclip_objs push hl push bc @@ -40,9 +41,9 @@ Function6ec1: ; 6ec1 pop hl ret c -.bit_6 - bit 5, [hl] - jr nz, .bit_5 +.noclip_objs + bit MOVE_ANYWHERE_F, [hl] + jr nz, .move_anywhere push hl call HasObjectReachedMovementLimit pop hl @@ -53,13 +54,13 @@ Function6ec1: ; 6ec1 pop hl ret c -.bit_5 +.move_anywhere and a ret ; 6f07 -Function6f07: ; 6f07 +WillObjectBumpIntoWater: ; 6f07 call Function6f5f ret c ld hl, OBJECT_NEXT_MAP_X @@ -78,12 +79,12 @@ Function6f07: ; 6f07 ld d, a call GetTileCollision and a ; LANDTILE - jr z, Function6f3e + jr z, WillObjectBumpIntoTile scf ret ; 6f2c -Function6f2c: ; 6f2c +WillObjectBumpIntoLand: ; 6f2c call Function6f5f ret c ld hl, OBJECT_NEXT_TILE @@ -91,12 +92,12 @@ Function6f2c: ; 6f2c ld a, [hl] call GetTileCollision cp WATERTILE - jr z, Function6f3e + jr z, WillObjectBumpIntoTile scf ret ; 6f3e -Function6f3e: ; 6f3e +WillObjectBumpIntoTile: ; 6f3e ld hl, OBJECT_NEXT_TILE add hl, bc ld a, [hl] From a91aa18daeb7fdd24fe512468d549ca49fe524fc Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 23 May 2018 22:13:46 -0400 Subject: [PATCH 17/22] Use constants more --- engine/overworld/map_objects.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index d2ce598e1..e38112db9 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2574,7 +2574,7 @@ ContinueSpawnFacing: ; 57db _SetPlayerPalette: ; 57e2 ld a, d - and %10000000 + and 1 << 7 ret z ld bc, 0 ; debug? ld hl, OBJECT_FACING @@ -2584,13 +2584,13 @@ _SetPlayerPalette: ; 57e2 ld [hl], a ld a, d swap a - and %00000111 + and PALETTE_MASK ld d, a ld bc, wPlayerStruct ld hl, OBJECT_PALETTE add hl, bc ld a, [hl] - and %11111000 + and $ff ^ PALETTE_MASK or d ld [hl], a ret From 3927bcdb9d0429b5ff303cb787e522878bd01749 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 24 May 2018 12:36:35 -0400 Subject: [PATCH 18/22] =?UTF-8?q?Function6ec1=20=E2=86=92=20CanObjectMoveI?= =?UTF-8?q?nDirection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bugs_and_glitches.md | 6 +++--- engine/overworld/map_objects.asm | 4 ++-- engine/overworld/npc_movement.asm | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md index b78244d4c..2b5a6a152 100644 --- a/docs/bugs_and_glitches.md +++ b/docs/bugs_and_glitches.md @@ -44,7 +44,7 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th - [Two tiles in the `port` tileset are drawn incorrectly](#two-tiles-in-the-port-tileset-are-drawn-incorrectly) - [`LoadMetatiles` wraps around past 128 blocks](#loadmetatiles-wraps-around-past-128-blocks) - [Surfing directly across a map connection does not load the new map](#surfing-directly-across-a-map-connection-does-not-load-the-new-map) -- [`Function6ec1` does not correctly limit object movement](#function6ec1-does-not-correctly-limit-object-movement) +- [Swimming NPCs aren't limited by their movement radius](#swimming-npcs-arent-limited-by-their-movement-radius) - [`CheckOwnMon` only checks the first five letters of OT names](#checkownmon-only-checks-the-first-five-letters-of-ot-names) - [Catching a Transformed Pokémon always catches a Ditto](#catching-a-transformed-pokémon-always-catches-a-ditto) - [Using a Park Ball in normal battles has a corrupt animation](#using-a-park-ball-in-normal-battles-has-a-corrupt-animation) @@ -1185,11 +1185,11 @@ In [home/map.asm](/home/map.asm): *To do:* Identify specific code causing this bug and fix it. -## `Function6ec1` does not correctly limit object movement +## Swimming NPCs aren't limited by their movement radius This bug is why the Lapras in [maps/UnionCaveB2F.asm](/maps/UnionCaveB2F.asm), which uses `SPRITEMOVEDATA_SWIM_WANDER`, is not restricted by its `1, 1` movement radius. -In [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm): +This is a bug with `CanObjectMoveInDirection` in [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm): ```asm ld hl, OBJECT_FLAGS1 diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index e38112db9..6652beead 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -696,7 +696,7 @@ MapObjectMovementPattern: ; 47dd and %00000011 or 0 call InitStep - call Function6ec1 + call CanObjectMoveInDirection jr c, .ok2 ld de, SFX_STRENGTH call PlaySFX @@ -1049,7 +1049,7 @@ MapObjectMovementPattern: ; 47dd .RandomWalkContinue: call InitStep - call Function6ec1 ; check whether the object can move in that direction + call CanObjectMoveInDirection ; check whether the object can move in that direction jr c, .NewDuration call UpdateTallGrassFlags ld hl, OBJECT_ACTION diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 66b64037c..40ced1a5f 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -1,4 +1,4 @@ -Function6ec1: ; 6ec1 +CanObjectMoveInDirection: ; 6ec1 ld hl, OBJECT_PALETTE add hl, bc From a71b7a92b7443ef60df96890e56917d67db9b80b Mon Sep 17 00:00:00 2001 From: Rangi Date: Tue, 29 May 2018 19:14:04 -0400 Subject: [PATCH 19/22] Same pic bank solution as pokecrystal --- engine/gfx/load_pics.asm | 50 ++++++++++++++++++++-------------------- gfx/pics.asm | 1 - 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index b533ee56b..2b9a7bb08 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -252,7 +252,7 @@ GLOBAL PICS_FIX push hl push bc - sub BANK(Pics_1) - PICS_FIX + sub BANK("Pics 1") - PICS_FIX ld c, a ld b, 0 ld hl, .PicsBanks @@ -263,30 +263,30 @@ GLOBAL PICS_FIX ret .PicsBanks: ; 511d4 - db BANK(Pics_1) + 0 - db BANK(Pics_1) + 1 - db BANK(Pics_1) + 2 - db BANK(Pics_1) + 3 - db BANK(Pics_1) + 4 - db BANK(Pics_1) + 5 - db BANK(Pics_1) + 6 - db BANK(Pics_1) + 7 - db BANK(Pics_1) + 8 - db BANK(Pics_1) + 9 - db BANK(Pics_1) + 10 - db BANK(Pics_1) + 11 - db BANK(Pics_1) + 12 - db BANK(Pics_1) + 13 - db BANK(Pics_1) + 14 - db BANK(Pics_1) + 15 - db BANK(Pics_1) + 16 - db BANK(Pics_1) + 17 - db BANK(Pics_1) + 18 - db BANK(Pics_1) + 19 - db BANK(Pics_1) + 20 - db BANK(Pics_1) + 21 - db BANK(Pics_1) + 22 - db BANK(Pics_1) + 23 + db BANK("Pics 1") + 0 + db BANK("Pics 1") + 1 + db BANK("Pics 1") + 2 + db BANK("Pics 1") + 3 + db BANK("Pics 1") + 4 + db BANK("Pics 1") + 5 + db BANK("Pics 1") + 6 + db BANK("Pics 1") + 7 + db BANK("Pics 1") + 8 + db BANK("Pics 1") + 9 + db BANK("Pics 1") + 10 + db BANK("Pics 1") + 11 + db BANK("Pics 1") + 12 + db BANK("Pics 1") + 13 + db BANK("Pics 1") + 14 + db BANK("Pics 1") + 15 + db BANK("Pics 1") + 16 + db BANK("Pics 1") + 17 + db BANK("Pics 1") + 18 + db BANK("Pics 1") + 19 + db BANK("Pics 1") + 20 + db BANK("Pics 1") + 21 + db BANK("Pics 1") + 22 + db BANK("Pics 1") + 23 Function511ec: ; 511ec ld a, c diff --git a/gfx/pics.asm b/gfx/pics.asm index 198569a76..1dd606643 100644 --- a/gfx/pics.asm +++ b/gfx/pics.asm @@ -20,7 +20,6 @@ INCLUDE "data/trainers/pic_pointers.asm" SECTION "Pics 1", ROMX -Pics_1:: HoOhFrontpic: INCBIN "gfx/pokemon/ho_oh/front.animated.2bpp.lz" MachampFrontpic: INCBIN "gfx/pokemon/machamp/front.animated.2bpp.lz" From 4df72a8474a24ebd261e2768c7f21273435364e4 Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 1 Jun 2018 02:11:44 -0400 Subject: [PATCH 20/22] SGB palette roles discovered from Spaceworld beta G/S --- constants/scgb_constants.asm | 44 +++++++++---------- engine/gfx/cgb_layouts.asm | 8 ++-- engine/gfx/color.asm | 8 ++-- engine/gfx/sgb_layouts.asm | 12 ++--- .../b789.pal => beta_poker/beta_poker.pal} | 0 gfx/sgb/pal_packets.asm | 18 ++++---- gfx/sgb/predef.pal | 38 ++++++++-------- 7 files changed, 64 insertions(+), 64 deletions(-) rename gfx/{unknown/b789.pal => beta_poker/beta_poker.pal} (100%) diff --git a/constants/scgb_constants.asm b/constants/scgb_constants.asm index e7d987113..807b5003c 100644 --- a/constants/scgb_constants.asm +++ b/constants/scgb_constants.asm @@ -15,9 +15,9 @@ const SCGB_GS_TITLE_SCREEN const SCGB_0D const SCGB_MOVE_LIST - const SCGB_0F + const SCGB_BETA_PIKACHU_MINIGAME const SCGB_POKEDEX_SEARCH_OPTION - const SCGB_11 + const SCGB_BETA_POKER const SCGB_POKEPIC const SCGB_13 const SCGB_PACKPALS @@ -75,40 +75,40 @@ SCGB_RAM EQU -1 const PREDEFPAL_RB_PINKMON const PREDEFPAL_RB_YELLOWMON const PREDEFPAL_CGB_BADGE ; RB_GREYMON - const PREDEFPAL_MEWMON_NITE - const PREDEFPAL_BLUEMON_NITE - const PREDEFPAL_REDMON_NITE - const PREDEFPAL_CYANMON_NITE - const PREDEFPAL_PURPLEMON_NITE - const PREDEFPAL_BROWNMON_NITE - const PREDEFPAL_GREENMON_NITE - const PREDEFPAL_PINKMON_NITE - const PREDEFPAL_YELLOWMON_NITE - const PREDEFPAL_PARTY_ICON ; GREYMON_NITE + const PREDEFPAL_BETA_SHINY_MEWMON + const PREDEFPAL_BETA_SHINY_BLUEMON + const PREDEFPAL_BETA_SHINY_REDMON + const PREDEFPAL_BETA_SHINY_CYANMON + const PREDEFPAL_BETA_SHINY_PURPLEMON + const PREDEFPAL_BETA_SHINY_BROWNMON + const PREDEFPAL_BETA_SHINY_GREENMON + const PREDEFPAL_BETA_SHINY_PINKMON + const PREDEFPAL_BETA_SHINY_YELLOWMON + const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GREYMON const PREDEFPAL_HP_GREEN const PREDEFPAL_HP_YELLOW const PREDEFPAL_HP_RED const PREDEFPAL_POKEGEAR - const PREDEFPAL_33 - const PREDEFPAL_34 + const PREDEFPAL_BETA_LOGO_1 + const PREDEFPAL_BETA_LOGO_2 const PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO const PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS - const PREDEFPAL_37 + const PREDEFPAL_BETA_INTRO_LAPRAS const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB const PREDEFPAL_GS_INTRO_STARTERS_TRANSITION - const PREDEFPAL_3B + const PREDEFPAL_BETA_INTRO_VENUSAUR const PREDEFPAL_PACK ; GS_INTRO_CHARIZARD const PREDEFPAL_SLOT_MACHINE_0 const PREDEFPAL_SLOT_MACHINE_1 const PREDEFPAL_SLOT_MACHINE_2 const PREDEFPAL_SLOT_MACHINE_3 - const PREDEFPAL_SCGB_11_0 - const PREDEFPAL_SCGB_11_1 - const PREDEFPAL_SCGB_11_2 - const PREDEFPAL_SCGB_11_3 - const PREDEFPAL_45 - const PREDEFPAL_46 + const PREDEFPAL_BETA_POKER_0 + const PREDEFPAL_BETA_POKER_1 + const PREDEFPAL_BETA_POKER_2 + const PREDEFPAL_BETA_POKER_3 + const PREDEFPAL_BETA_RADIO + const PREDEFPAL_BETA_POKEGEAR const PREDEFPAL_47 const PREDEFPAL_GS_TITLE_SCREEN_0 const PREDEFPAL_GS_TITLE_SCREEN_1 diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index b36dceeb6..6ab676cda 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -48,7 +48,7 @@ LoadSGBLayoutCGB: ; 8d59 dw _CGB_GSTitleScreen dw _CGB0d dw _CGB_MoveList - dw _CGB0f + dw _CGB_BetaPikachuMinigame dw _CGB_PokedexSearchOption dw _CGB11 dw _CGB_Pokepic @@ -532,7 +532,7 @@ _CGB_GSIntro: ; 9122 ; 9195 _CGB11: ; 9195 - ld hl, Palettes_SCGB_11 + ld hl, BetaPokerPals ld de, wBGPals1 ld bc, 5 palettes ld a, BANK(wBGPals1) @@ -790,8 +790,8 @@ _CGB_MoveList: ; 9373 ret ; 93a6 -_CGB0f: ; 93a6 - ld hl, PalPacket_SCGB_0F + 1 +_CGB_BetaPikachuMinigame: ; 93a6 + ld hl, PalPacket_BetaPikachuMinigame + 1 call CopyFourPalettes call WipeAttrMap call ApplyAttrMap diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 6cf896ff4..6d60357a5 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -182,12 +182,12 @@ Unreferenced_Function8b4d: ld a, [hSGB] and a ret z - ld hl, PalPacket_Function8b4d + ld hl, PalPacket_BetaIntroVenusaur jp PushSGBPals_ .cgb ld de, wOBPals1 - ld a, PREDEFPAL_3B + ld a, PREDEFPAL_BETA_INTRO_VENUSAUR call GetPredefPal jp LoadHLPaletteIntoDE @@ -1349,8 +1349,8 @@ INCLUDE "gfx/pokegear/pokegear.pal" FemalePokegearPals: INCLUDE "gfx/pokegear/pokegear_f.pal" -Palettes_SCGB_11: -INCLUDE "gfx/unknown/b789.pal" +BetaPokerPals: +INCLUDE "gfx/beta_poker/beta_poker.pal" SlotMachinePals: INCLUDE "gfx/slots/slots.pal" diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm index 24bdc952e..d53be908f 100644 --- a/engine/gfx/sgb_layouts.asm +++ b/engine/gfx/sgb_layouts.asm @@ -38,9 +38,9 @@ LoadSGBLayout: ; 864c dw .SGB_GSTitleScreen dw .SGB0d dw .SGB_MoveList - dw .SGB0f + dw .SGB_BetaPikachuMinigame dw .SGB_PokedexSearchOption - dw .SGB11 + dw .SGB_BetaPoker dw .SGB12 dw .SGB13 dw .SGB_PackPals @@ -346,18 +346,18 @@ endr ret ; 8897 -.SGB0f: ; 8897 - ld hl, PalPacket_SCGB_0F +.SGB_BetaPikachuMinigame: ; 8897 + ld hl, PalPacket_BetaPikachuMinigame ld de, BlkPacket_9a86 ret ; 889e -.SGB11: ; 889e +.SGB_BetaPoker: ; 889e ld hl, BlkPacket_9a86 ld de, wPlayerLightScreenCount ; ??? ld bc, PALPACKET_LENGTH call CopyBytes - ld hl, PalPacket_SCGB_11 + ld hl, PalPacket_BetaPoker ld de, BlkPacket_9a86 ret ; 88b1 diff --git a/gfx/unknown/b789.pal b/gfx/beta_poker/beta_poker.pal similarity index 100% rename from gfx/unknown/b789.pal rename to gfx/beta_poker/beta_poker.pal diff --git a/gfx/sgb/pal_packets.asm b/gfx/sgb/pal_packets.asm index fa3b386da..0a392fb22 100644 --- a/gfx/sgb/pal_packets.asm +++ b/gfx/sgb/pal_packets.asm @@ -21,10 +21,10 @@ PalPacket_GSTitleScreen: sgb_pal_set GS_TITLE_SCREEN_0, GS_TITLE_SCREEN_1, GS_TITLE_SCREEN_2, GS_TITLE_SCREEN_3 PalPacket_SCGB_13: - sgb_pal_set GREENMON_NITE, CGB_BADGE, RB_BROWNMON, 00 + sgb_pal_set BETA_SHINY_GREENMON, CGB_BADGE, RB_BROWNMON, 00 -PalPacket_SCGB_11: - sgb_pal_set SCGB_11_0, SCGB_11_1, SCGB_11_2, SCGB_11_3 +PalPacket_BetaPoker: + sgb_pal_set BETA_POKER_0, BETA_POKER_1, BETA_POKER_2, BETA_POKER_3 PalPacket_UnownPuzzle: sgb_pal_set UNOWN_PUZZLE, UNOWN_PUZZLE, UNOWN_PUZZLE, UNOWN_PUZZLE @@ -35,8 +35,8 @@ PalPacket_9bd6: PalPacket_GSIntroShellderLapras: sgb_pal_set GS_INTRO_SHELLDER_LAPRAS, 00, 00, 00 -UnreferencedPalPacket_9bf6: - sgb_pal_set 37, 00, 00, 00 +UnreferencedPalPacket_BetaIntroLapras: + sgb_pal_set BETA_INTRO_LAPRAS, 00, 00, 00 PalPacket_GSIntroJigglypuffPikachu: sgb_pal_set GS_INTRO_JIGGLYPUFF_PIKACHU_BG, GS_INTRO_JIGGLYPUFF_PIKACHU_OB, 00, 00 @@ -44,13 +44,13 @@ PalPacket_GSIntroJigglypuffPikachu: PalPacket_GSIntroStartersTransition: sgb_pal_set GS_INTRO_STARTERS_TRANSITION, 00, 00, 00 -PalPacket_Function8b4d: - sgb_pal_set 3B, 00, 00, 00 +PalPacket_BetaIntroVenusaur: + sgb_pal_set BETA_INTRO_VENUSAUR, 00, 00, 00 PalPacket_Pack: sgb_pal_set PACK, 00, 00, 00 -PalPacket_SCGB_0F: +PalPacket_BetaPikachuMinigame: sgb_pal_set GS_INTRO_JIGGLYPUFF_PIKACHU_OB, 00, 00, 00 PalPacket_PartyMenu: @@ -69,7 +69,7 @@ PalPacket_SlotMachine: sgb_pal_set SLOT_MACHINE_0, SLOT_MACHINE_1, SLOT_MACHINE_2, SLOT_MACHINE_3 PalPacket_SCGB_06: - sgb_pal_set 33, 34, DIPLOMA, RB_PURPLEMON + sgb_pal_set BETA_LOGO_1, BETA_LOGO_2, DIPLOMA, RB_PURPLEMON PalPacket_Diploma: sgb_pal_set DIPLOMA, 00, 00, 00 diff --git a/gfx/sgb/predef.pal b/gfx/sgb/predef.pal index 67d19baec..9c86e2459 100644 --- a/gfx/sgb/predef.pal +++ b/gfx/sgb/predef.pal @@ -35,40 +35,40 @@ RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_RB_PINKMON RGB 31,31,31, 31,28,14, 26,20,00, 00,00,00 ; PREDEFPAL_RB_YELLOWMON RGB 31,31,31, 26,21,22, 15,15,18, 00,00,00 ; PREDEFPAL_CGB_BADGE - RGB 31,31,31, 23,19,13, 14,12,17, 00,00,00 ; PREDEFPAL_MEWMON_NITE - RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_BLUEMON_NITE - RGB 31,31,31, 22,15,16, 17,02,05, 00,00,00 ; PREDEFPAL_REDMON_NITE - RGB 31,31,31, 15,20,20, 05,16,16, 00,00,00 ; PREDEFPAL_CYANMON_NITE - RGB 31,31,31, 23,15,19, 14,04,12, 00,00,00 ; PREDEFPAL_PURPLEMON_NITE - RGB 31,31,31, 20,17,18, 18,13,11, 00,00,00 ; PREDEFPAL_BROWNMON_NITE - RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_GREENMON_NITE - RGB 31,31,31, 21,25,29, 30,22,24, 00,00,00 ; PREDEFPAL_PINKMON_NITE - RGB 31,31,31, 26,23,16, 29,14,09, 00,00,00 ; PREDEFPAL_YELLOWMON_NITE + RGB 31,31,31, 23,19,13, 14,12,17, 00,00,00 ; PREDEFPAL_SHINY_MEWMON + RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_SHINY_BLUEMON + RGB 31,31,31, 22,15,16, 17,02,05, 00,00,00 ; PREDEFPAL_SHINY_REDMON + RGB 31,31,31, 15,20,20, 05,16,16, 00,00,00 ; PREDEFPAL_SHINY_CYANMON + RGB 31,31,31, 23,15,19, 14,04,12, 00,00,00 ; PREDEFPAL_SHINY_PURPLEMON + RGB 31,31,31, 20,17,18, 18,13,11, 00,00,00 ; PREDEFPAL_SHINY_BROWNMON + RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_SHINY_GREENMON + RGB 31,31,31, 21,25,29, 30,22,24, 00,00,00 ; PREDEFPAL_SHINY_PINKMON + RGB 31,31,31, 26,23,16, 29,14,09, 00,00,00 ; PREDEFPAL_SHINY_YELLOWMON RGB 31,31,31, 18,18,18, 10,10,10, 00,00,00 ; PREDEFPAL_PARTY_ICON RGB 31,31,31, 30,26,15, 00,23,00, 00,00,00 ; PREDEFPAL_HP_GREEN RGB 31,31,31, 30,26,15, 31,23,00, 00,00,00 ; PREDEFPAL_HP_YELLOW RGB 31,31,31, 30,26,15, 31,00,00, 00,00,00 ; PREDEFPAL_HP_RED RGB 31,31,31, 29,26,19, 27,20,14, 00,00,00 ; PREDEFPAL_POKEGEAR - RGB 31,31,31, 24,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_33 - RGB 31,31,31, 31,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_34 + RGB 31,31,31, 24,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_BETA_LOGO_1 + RGB 31,31,31, 31,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_BETA_LOGO_2 RGB 31,31,31, 30,26,16, 16,12,09, 00,00,00 ; PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO RGB 31,31,31, 15,28,26, 12,22,26, 03,16,14 ; PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS - RGB 31,31,31, 15,28,26, 23,24,24, 00,00,00 ; PREDEFPAL_37 + RGB 31,31,31, 15,28,26, 23,24,24, 00,00,00 ; PREDEFPAL_BETA_INTRO_LAPRAS RGB 31,31,24, 07,27,19, 26,20,10, 19,12,08 ; PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG RGB 31,31,31, 31,28,14, 31,13,31, 00,00,00 ; PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_GS_INTRO_STARTERS_TRANSITION - RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_3B + RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_BETA_INTRO_VENUSAUR RGB 31,31,31, 31,14,00, 07,11,15, 00,00,00 ; PREDEFPAL_PACK RGB 31,31,31, 26,21,22, 26,10,06, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_0 RGB 31,31,31, 30,27,04, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_1 RGB 31,31,31, 31,13,25, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_2 RGB 31,31,31, 16,19,29, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_3 - RGB 31,31,31, 30,22,24, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_0 - RGB 31,31,31, 21,25,29, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_1 - RGB 31,31,31, 20,26,16, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_2 - RGB 31,31,31, 31,28,14, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_3 - RGB 31,31,31, 18,18,18, 26,10,06, 00,00,00 ; PREDEFPAL_45 - RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_46 + RGB 31,31,31, 30,22,24, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_0 + RGB 31,31,31, 21,25,29, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_1 + RGB 31,31,31, 20,26,16, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_2 + RGB 31,31,31, 31,28,14, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_3 + RGB 31,31,31, 18,18,18, 26,10,06, 00,00,00 ; PREDEFPAL_BETA_RADIO + RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_BETA_POKEGEAR RGB 31,31,31, 26,20,00, 16,19,29, 00,00,00 ; PREDEFPAL_47 RGB 31,31,31, 16,02,30, 15,20,31, 00,00,00 ; PREDEFPAL_GS_TITLE_SCREEN_0 RGB 31,31,31, 16,13,04, 15,20,31, 00,00,00 ; PREDEFPAL_GS_TITLE_SCREEN_1 From 7cd5bcbae4a35471fe8473a63526d73e71b193cc Mon Sep 17 00:00:00 2001 From: Rangi Date: Sun, 3 Jun 2018 23:18:31 -0400 Subject: [PATCH 21/22] Change FixPicBank bank array --- docs/design_flaws.md | 52 ++++++++++++++++++++-------------------- engine/gfx/load_pics.asm | 38 ++++++++++++++--------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/docs/design_flaws.md b/docs/design_flaws.md index e4a81123b..aee6a1daa 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -36,7 +36,7 @@ GLOBAL PICS_FIX push hl push bc - sub BANK(Pics_1) - PICS_FIX + sub BANK("Pics 1") - PICS_FIX ld c, a ld b, 0 ld hl, .PicsBanks @@ -47,33 +47,33 @@ GLOBAL PICS_FIX ret .PicsBanks: ; 511d4 - db BANK(Pics_1) + 0 - db BANK(Pics_1) + 1 - db BANK(Pics_1) + 2 - db BANK(Pics_1) + 3 - db BANK(Pics_1) + 4 - db BANK(Pics_1) + 5 - db BANK(Pics_1) + 6 - db BANK(Pics_1) + 7 - db BANK(Pics_1) + 8 - db BANK(Pics_1) + 9 - db BANK(Pics_1) + 10 - db BANK(Pics_1) + 11 - db BANK(Pics_1) + 12 - db BANK(Pics_1) + 13 - db BANK(Pics_1) + 14 - db BANK(Pics_1) + 15 - db BANK(Pics_1) + 16 - db BANK(Pics_1) + 17 - db BANK(Pics_1) + 18 - db BANK(Pics_1) + 19 - db BANK(Pics_1) + 20 - db BANK(Pics_1) + 21 - db BANK(Pics_1) + 22 - db BANK(Pics_1) + 23 + db BANK("Pics 1") ; BANK("Pics 1") + 0 + db BANK("Pics 2") ; BANK("Pics 1") + 1 + db BANK("Pics 3") ; BANK("Pics 1") + 2 + db BANK("Pics 4") ; BANK("Pics 1") + 3 + db BANK("Pics 5") ; BANK("Pics 1") + 4 + db BANK("Pics 6") ; BANK("Pics 1") + 5 + db BANK("Pics 7") ; BANK("Pics 1") + 6 + db BANK("Pics 8") ; BANK("Pics 1") + 7 + db BANK("Pics 9") ; BANK("Pics 1") + 8 + db BANK("Pics 10") ; BANK("Pics 1") + 9 + db BANK("Pics 11") ; BANK("Pics 1") + 10 + db BANK("Pics 12") ; BANK("Pics 1") + 11 + db BANK("Pics 13") ; BANK("Pics 1") + 12 + db BANK("Pics 14") ; BANK("Pics 1") + 13 + db BANK("Pics 15") ; BANK("Pics 1") + 14 + db BANK("Pics 16") ; BANK("Pics 1") + 15 + db BANK("Pics 17") ; BANK("Pics 1") + 16 + db BANK("Pics 18") ; BANK("Pics 1") + 17 + db BANK("Pics 19") ; BANK("Pics 1") + 18 + db BANK("Pics 1") + 19 + db BANK("Pics 1") + 20 + db BANK("Pics 1") + 21 + db BANK("Pics 1") + 22 + db BANK("Pics 1") + 23 ``` -**Fix:** Use `dba` instead of `dba_pic`, and don't call `FixPicBank` to modify `a`. +**Fix:** Use `dba` instead of `dba_pic`, delete `FixPicBank`, and remove all four calls to `FixPicBank`. ## `PokemonPicPointers` and `UnownPicPointers` are assumed to start at the same address diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index 2b9a7bb08..438f64f87 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -263,25 +263,25 @@ GLOBAL PICS_FIX ret .PicsBanks: ; 511d4 - db BANK("Pics 1") + 0 - db BANK("Pics 1") + 1 - db BANK("Pics 1") + 2 - db BANK("Pics 1") + 3 - db BANK("Pics 1") + 4 - db BANK("Pics 1") + 5 - db BANK("Pics 1") + 6 - db BANK("Pics 1") + 7 - db BANK("Pics 1") + 8 - db BANK("Pics 1") + 9 - db BANK("Pics 1") + 10 - db BANK("Pics 1") + 11 - db BANK("Pics 1") + 12 - db BANK("Pics 1") + 13 - db BANK("Pics 1") + 14 - db BANK("Pics 1") + 15 - db BANK("Pics 1") + 16 - db BANK("Pics 1") + 17 - db BANK("Pics 1") + 18 + db BANK("Pics 1") ; BANK("Pics 1") + 0 + db BANK("Pics 2") ; BANK("Pics 1") + 1 + db BANK("Pics 3") ; BANK("Pics 1") + 2 + db BANK("Pics 4") ; BANK("Pics 1") + 3 + db BANK("Pics 5") ; BANK("Pics 1") + 4 + db BANK("Pics 6") ; BANK("Pics 1") + 5 + db BANK("Pics 7") ; BANK("Pics 1") + 6 + db BANK("Pics 8") ; BANK("Pics 1") + 7 + db BANK("Pics 9") ; BANK("Pics 1") + 8 + db BANK("Pics 10") ; BANK("Pics 1") + 9 + db BANK("Pics 11") ; BANK("Pics 1") + 10 + db BANK("Pics 12") ; BANK("Pics 1") + 11 + db BANK("Pics 13") ; BANK("Pics 1") + 12 + db BANK("Pics 14") ; BANK("Pics 1") + 13 + db BANK("Pics 15") ; BANK("Pics 1") + 14 + db BANK("Pics 16") ; BANK("Pics 1") + 15 + db BANK("Pics 17") ; BANK("Pics 1") + 16 + db BANK("Pics 18") ; BANK("Pics 1") + 17 + db BANK("Pics 19") ; BANK("Pics 1") + 18 db BANK("Pics 1") + 19 db BANK("Pics 1") + 20 db BANK("Pics 1") + 21 From c7bb2d15cfb32a5e965933b90e0acb497c7bf7b2 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sun, 3 Jun 2018 23:25:21 -0400 Subject: [PATCH 22/22] Create empty sections for the remaining FixPicBank array entries --- docs/design_flaws.md | 10 +++++----- engine/gfx/load_pics.asm | 10 +++++----- gfx/pics.asm | 18 ++++++++++++++++++ pokecrystal.link | 5 +++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/docs/design_flaws.md b/docs/design_flaws.md index aee6a1daa..6b015a56a 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -66,11 +66,11 @@ GLOBAL PICS_FIX db BANK("Pics 17") ; BANK("Pics 1") + 16 db BANK("Pics 18") ; BANK("Pics 1") + 17 db BANK("Pics 19") ; BANK("Pics 1") + 18 - db BANK("Pics 1") + 19 - db BANK("Pics 1") + 20 - db BANK("Pics 1") + 21 - db BANK("Pics 1") + 22 - db BANK("Pics 1") + 23 + db BANK("Pics 20") ; BANK("Pics 1") + 19 + db BANK("Pics 21") ; BANK("Pics 1") + 20 + db BANK("Pics 22") ; BANK("Pics 1") + 21 + db BANK("Pics 23") ; BANK("Pics 1") + 22 + db BANK("Pics 24") ; BANK("Pics 1") + 23 ``` **Fix:** Use `dba` instead of `dba_pic`, delete `FixPicBank`, and remove all four calls to `FixPicBank`. diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index 438f64f87..9c909a5cd 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -282,11 +282,11 @@ GLOBAL PICS_FIX db BANK("Pics 17") ; BANK("Pics 1") + 16 db BANK("Pics 18") ; BANK("Pics 1") + 17 db BANK("Pics 19") ; BANK("Pics 1") + 18 - db BANK("Pics 1") + 19 - db BANK("Pics 1") + 20 - db BANK("Pics 1") + 21 - db BANK("Pics 1") + 22 - db BANK("Pics 1") + 23 + db BANK("Pics 20") ; BANK("Pics 1") + 19 + db BANK("Pics 21") ; BANK("Pics 1") + 20 + db BANK("Pics 22") ; BANK("Pics 1") + 21 + db BANK("Pics 23") ; BANK("Pics 1") + 22 + db BANK("Pics 24") ; BANK("Pics 1") + 23 Function511ec: ; 511ec ld a, c diff --git a/gfx/pics.asm b/gfx/pics.asm index 1dd606643..043e41489 100644 --- a/gfx/pics.asm +++ b/gfx/pics.asm @@ -793,3 +793,21 @@ INCBIN "gfx/pokemon/unown_y/back.2bpp.lz" INCBIN "gfx/pokemon/unown_p/back.2bpp.lz" INCBIN "gfx/pokemon/unown_i/back.2bpp.lz" INCBIN "gfx/pokemon/unown_r/back.2bpp.lz" + + +; Sections "Pics 20" to "Pics 24" are not used for any graphics, +; but entries for their banks exist in FixPicBank (see engine/gfx/load_pics.asm). + +SECTION "Pics 20", ROMX + + +SECTION "Pics 21", ROMX + + +SECTION "Pics 22", ROMX + + +SECTION "Pics 23", ROMX + + +SECTION "Pics 24", ROMX diff --git a/pokecrystal.link b/pokecrystal.link index fc8fbb38a..157b39197 100644 --- a/pokecrystal.link +++ b/pokecrystal.link @@ -234,17 +234,22 @@ ROMX $5a "Pics 19" ROMX $5b "bank5B" + "Pics 20" ROMX $5c "Mobile 5C" + "Pics 21" ROMX $5d "Crystal Phone Text 2" + "Pics 22" ROMX $5e "UpdateBattleHUDs" "Songs 5" "Crystal Sound Effects" "Mobile 5E" + "Pics 23" ROMX $5f "Mobile 5F" + "Pics 24" ROMX $60 "Map Scripts 13" "Pokedex Entries 001-064"