From 1cf79b6f15761ec95ba1b0f9d6d83781c4240612 Mon Sep 17 00:00:00 2001 From: yenatch Date: Thu, 7 Aug 2014 21:17:44 -0700 Subject: Fix static banks passed into GetName. This appears to be the only other use of wPredefBank. Chances are there are more uncaught banks. Known cases are marked as "hardcoded" or similar. --- engine/battle/4_2.asm | 2 +- engine/battle/core.asm | 13 ++++++++----- engine/battle/e.asm | 2 +- engine/evos_moves.asm | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index c5c62796..b53ea6e4 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -391,7 +391,7 @@ GetTrainerName_: ; 13a58 (4:7a58) ld [wd0b5], a ld a, TRAINER_NAME ld [W_LISTTYPE], a - ld a, $e + ld a, BANK(TrainerNames) ld [wPredefBank], a call GetName ld hl, wcd6d diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b3495a29..399a8ee7 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2184,7 +2184,9 @@ asm_3d00e: ; 3d00e (f:500e) jr Func_3d03c OldManItemList: ; 3d02d (f:502d) - db $01, POKE_BALL, 50, $ff + db 1 ; # items + db POKE_BALL, 50 + db -1 Func_3d031 ld hl, wNumBagItems ; wNumBagItems @@ -5471,7 +5473,7 @@ asm_3e70b: ; 3e70b (f:670b) res 6, [hl] ; no longer invulnerable to typcial attacks ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM ld [wd0b5], a - ld a, $2c + ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME ld [W_LISTTYPE], a @@ -5950,10 +5952,11 @@ GetCurrentMove: ; 3eabe (f:6abe) call AddNTimes ld a, BANK(Moves) call FarCopyData - ld a, $2c + + ld a, BANK(MoveNames) ld [wPredefBank], a - ld a, $2 - ld [W_LISTTYPE], a ; list type 2 = move name + ld a, MOVE_NAME + ld [W_LISTTYPE], a call GetName ld de, wcd6d jp CopyStringToCF4B diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 8b0476ca..a0d9d80c 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -587,7 +587,7 @@ Func_39b87: ; 39b87 (e:5b87) jr z, .asm_39bc1 push hl ld [wd0b5], a - ld a, $2c + ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME ld [W_LISTTYPE], a diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index fd93fa14..9869153e 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -135,7 +135,7 @@ Func_3ad71: ; 3ad71 (e:6d71) ld [wHPBarMaxHP + 1], a ld a, MONSTER_NAME ld [W_LISTTYPE], a - ld a, $e + ld a, BANK(TrainerNames) ; bank is not used for monster names ld [wPredefBank], a call GetName push hl -- cgit v1.3.1-sl0p From 365ae68d80683deab0e2e721b8ff79dda4047513 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 22 Aug 2014 23:17:47 -0700 Subject: Use PARTY_LENGTH and related constants in menu and hud code. This should allow reducing PARTY_LENGTH to work as intended. Increasing it also works provided space is provided in wram, but breaks pc/saving. --- engine/battle/e.asm | 6 ++-- engine/give_pokemon.asm | 16 +++++------ engine/items/items.asm | 6 ++-- engine/menu/bills_pc.asm | 74 +++++++++++++++++++++--------------------------- engine/save.asm | 10 +++---- main.asm | 10 +++---- scripts/daycarem.asm | 8 +++--- scripts/route5gate.asm | 8 +++--- 8 files changed, 64 insertions(+), 74 deletions(-) (limited to 'engine') diff --git a/engine/battle/e.asm b/engine/battle/e.asm index a0d9d80c..9abeeec8 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1407,14 +1407,14 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887) ld [hl], $20 ld a, $f8 ld [wTrainerEngageDistance], a - ld hl, wOAMBuffer + $18 + ld hl, wOAMBuffer + PARTY_LENGTH * 4 jp Func_3a8e1 SetupPokeballs: ; 0x3a8a6 ld a, [de] push af ld de, wBuffer - ld c, $6 ; max num of partymons + ld c, PARTY_LENGTH ld a, $34 ; empty pokeball .emptyloop ld [de], a @@ -1462,7 +1462,7 @@ PickPokeball: ; 3a8c2 (e:68c2) Func_3a8e1: ; 3a8e1 (e:68e1) ld de, wHPBarMaxHP - ld c, $6 + ld c, PARTY_LENGTH .asm_3a8e6 ld a, [W_BASECOORDY] ; wd082 ld [hli], a diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 9399fb05..f3bd7f78 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -3,10 +3,10 @@ _GivePokemon: ; 4fda5 (13:7da5) xor a ld [wccd3], a ld a, [wPartyCount] ; wPartyCount - cp $6 + cp PARTY_LENGTH jr c, .asm_4fe01 ld a, [W_NUMINBOX] ; wda80 - cp $14 + cp MONS_PER_BOX jr nc, .asm_4fdf9 xor a ld [W_ENEMYBATTSTATUS3], a ; W_ENEMYBATTSTATUS3 @@ -18,18 +18,18 @@ _GivePokemon: ; 4fda5 (13:7da5) ld hl, wcf4b ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_4fdec - sub $9 - ld [hl], $f7 + sub 9 + ld [hl], "1" inc hl - add $f6 + add "0" jr .asm_4fdee .asm_4fdec - add $f7 + add "1" .asm_4fdee ld [hli], a - ld [hl], $50 + ld [hl], "@" ld hl, SetToBoxText call PrintText scf diff --git a/engine/items/items.asm b/engine/items/items.asm index 830f0dfc..0609e685 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -110,10 +110,10 @@ ItemUseBall: ; d687 (3:5687) dec a jr z,.UseBall ld a,[wPartyCount] ;is Party full? - cp a,6 + cp a,PARTY_LENGTH jr nz,.UseBall ld a,[W_NUMINBOX] ;is Box full? - cp a,20 + cp a,MONS_PER_BOX jp z,BoxFullCannotThrowBall .UseBall ;$56a7 ;ok, you can use a ball @@ -421,7 +421,7 @@ ItemUseBall: ; d687 (3:5687) predef ShowPokedexData .checkParty ;$58f4 ld a,[wPartyCount] - cp a,6 ;is party full? + cp a,PARTY_LENGTH ;is party full? jr z,.sendToBox xor a ld [wcc49],a diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 3edaadd8..b06927d8 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -88,25 +88,13 @@ Func_213c8:: ; 213c8 (8:53c8) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ret -SomeonesPCText: ; 2148b (8:548b) - db "SOMEONE's PC@" +SomeonesPCText: db "SOMEONE's PC@" +BillsPCText: db "BILL's PC@" +PlayersPCText: db "'s PC@" +OaksPCText: db "PROF.OAK's PC@" +PKMNLeaguePCText: db $4a, "LEAGUE@" +LogOffPCText: db "LOG OFF@" -BillsPCText: ; 21497 (8:5497) - db "BILL's PC@" - -PlayersPCText: ; 214a0 (8:54a0) - db "'s PC@" - -OaksPCText: ; 214a5 (8:54a5) - db "PROF.OAK's PC@" - -PKMNLeaguePCText: ; 214b2 (8:54b2) - db $4a,"LEAGUE@" - -LogOffPCText: ; 214ba (8:54ba) - db "LOG OFF@" - -Func_214c2:: ; 214c2 (8:54c2) BillsPC_:: ; 0x214c2 ld hl, wd730 set 6, [hl] @@ -167,15 +155,15 @@ BillsPCMenu: call TextBoxBorder ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_2154f - sub $9 + sub 9 hlCoord 17, 16 - ld [hl], $f7 - add $f6 + ld [hl], "1" + add "0" jr .asm_21551 .asm_2154f - add $f7 + add "1" .asm_21551 Coorda 18, 16 hlCoord 10, 16 @@ -227,7 +215,7 @@ BillsPCDeposit: jp BillsPCMenu .asm_215bb ld a, [W_NUMINBOX] ; wda80 - cp $14 + cp MONS_PER_BOX jr nz, .asm_215cb ld hl, BoxFullText ; $5802 call PrintText @@ -251,15 +239,15 @@ BillsPCDeposit: ld hl, wWhichTrade ; wWhichTrade ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_2160a - sub $9 - ld [hl], $f7 + sub 9 + ld [hl], "1" inc hl - add $f6 + add "0" jr .asm_2160c .asm_2160a - add $f7 + add "1" .asm_2160c ld [hli], a ld [hl], $50 @@ -276,7 +264,7 @@ Func_21618: ; 21618 (8:5618) jp Func_214e8 .asm_21627 ld a, [wPartyCount] ; wPartyCount - cp $6 + cp PARTY_LENGTH jr nz, .asm_21637 ld hl, CantTakeMonText ; $5811 call PrintText @@ -353,7 +341,12 @@ Func_216be: ; 216be (8:56be) ret BillsPCMenuText: ; 216e1 (8:56e1) - db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" + db "WITHDRAW ", $4a + next "DEPOSIT ", $4a + next "RELEASE ", $4a + next "CHANGE BOX" + next "SEE YA!" + db "@" BoxNoPCText: ; 21713 (8:5713) db "BOX No.@" @@ -389,7 +382,7 @@ HMMoveArray: ; 21745 (8:5745) db SURF db STRENGTH db FLASH - db $ff + db -1 Func_2174b: ; 2174b (8:574b) hlCoord 9, 10 @@ -458,14 +451,11 @@ Func_2174b: ; 2174b (8:574b) call LoadGBPal jr .asm_2178f -DepositPCText: ; 217cb (8:57cb) - db "DEPOSIT@" - -WithdrawPCText: ; 217d3 (8:57d3) - db "WITHDRAW@" - -StatsCancelPCText: ; 217dc (8:57dc) - db "STATS",$4e,"CANCEL@" +DepositPCText: db "DEPOSIT@" +WithdrawPCText: db "WITHDRAW@" +StatsCancelPCText: + db "STATS" + next "CANCEL@" SwitchOnText: ; 0x217e9 TX_FAR _SwitchOnText @@ -523,7 +513,7 @@ PrintJustAMomentText1:: ; 5824 (8:5825) cp $c ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2183a inc a @@ -541,7 +531,7 @@ PrintJustAMomentText2:: ; 5845 (8:5845) cp $8 ret nz ld a, [W_CURMAP] - cp $ef + cp BATTLE_CENTER ld a, $2 jr z, .asm_2185a inc a diff --git a/engine/save.asm b/engine/save.asm index fcfbd133..b473f1cd 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -445,15 +445,15 @@ Func_7393f: ; 7393f (1c:793f) res 2, [hl] ld a, [wd5a0] and $7f - cp $9 + cp 9 jr c, .asm_739a6 - sub $9 + sub 9 hlCoord 8, 2 - ld [hl], $f7 - add $f6 + ld [hl], "1" + add "0" jr .asm_739a8 .asm_739a6 - add $f7 + add "1" .asm_739a8 Coorda 9, 2 hlCoord 1, 2 diff --git a/main.asm b/main.asm index 32a3db2c..96a1df8e 100755 --- a/main.asm +++ b/main.asm @@ -3419,7 +3419,7 @@ _AddPartyMon: ; f2e5 (3:72e5) .asm_f2f2 ld a, [de] inc a - cp $7 + cp PARTY_LENGTH + 1 ret nc ld [de], a ld a, [de] @@ -3681,7 +3681,7 @@ AddPartyMon_WriteMovePP: ; f476 (3:7476) _AddEnemyMonToPlayerParty: ; f49d (3:749d) ld hl, wPartyCount ld a, [hl] - cp $6 + cp PARTY_LENGTH scf ret z ; party full, return failure inc a @@ -3750,13 +3750,13 @@ Func_f51e: ; f51e (3:751e) jr z, .asm_f575 ld hl, W_NUMINBOX ; wda80 ld a, [hl] - cp $14 + cp MONS_PER_BOX jr nz, .partyOrBoxNotFull jr .boxFull .checkPartyMonSlots ld hl, wPartyCount ; wPartyCount ld a, [hl] - cp $6 + cp PARTY_LENGTH jr nz, .partyOrBoxNotFull .boxFull scf @@ -3899,7 +3899,7 @@ Func_f51e: ; f51e (3:751e) ld a, d ld [W_CURENEMYLVL], a ; W_CURENEMYLVL pop hl - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 add hl, bc ld [hli], a ld d, h diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index e463d380..373a9349 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -67,9 +67,9 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) call LoadMonData callab Func_58f43 ld a, d - cp $64 + cp MAX_LEVEL jr c, .asm_56315 - ld d, $64 + ld d, MAX_LEVEL callab CalcExperience ld hl, wDayCareMonExp ld a, [H_NUMTOPRINT] @@ -78,7 +78,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld [hli], a ld a, [$ff98] ld [hl], a - ld d, $64 + ld d, MAX_LEVEL .asm_56315 xor a @@ -100,7 +100,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) .asm_56333 call PrintText ld a, [wPartyCount] - cp $6 + cp PARTY_LENGTH ld hl, DayCareMText_56440 jp z, .asm_56403 ld de, wTrainerFacingDirection diff --git a/scripts/route5gate.asm b/scripts/route5gate.asm index d7abeff5..0e8d0d1c 100755 --- a/scripts/route5gate.asm +++ b/scripts/route5gate.asm @@ -27,11 +27,11 @@ Route5GateScript0: ; 1df50 (7:5f50) xor a ld [hJoyHeld], a callba RemoveGuardDrink - ld a, [$ff00+$db] + ld a, [$ffdb] and a jr nz, .asm_1df82 ; 0x1df70 $10 ld a, $2 - ld [$ff00+$8c], a + ld [$ff8c], a call DisplayTextID call Route5GateScript_1df43 ld a, $1 @@ -39,7 +39,7 @@ Route5GateScript0: ; 1df50 (7:5f50) ret .asm_1df82 ld a, $3 - ld [$ff00+$8c], a + ld [$ff8c], a call DisplayTextID ld hl, wd728 set 6, [hl] @@ -74,7 +74,7 @@ Route5GateText1: ; 1dfaa (7:5faa) bit 6, a jr nz, .asm_88856 ; 0x1dfb0 $2c callba RemoveGuardDrink - ld a, [$ff00+$db] + ld a, [$ffdb] and a jr nz, .asm_768a2 ; 0x1dfbd $11 ld hl, Route5GateText2 -- cgit v1.3.1-sl0p From 8f49e37b82a90bbef8c7133c4adea8f82abf00e7 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 30 Aug 2014 19:48:49 -0700 Subject: Use hram constants for remaining joypad variables. --- engine/cable_club.asm | 4 +-- engine/evolution.asm | 2 +- engine/menu/main_menu.asm | 4 +-- engine/menu/pokedex.asm | 6 ++-- engine/slot_machine.asm | 2 +- engine/town_map.asm | 8 ++--- home.asm | 74 +++++++++++++++++++++++------------------------ hram.asm | 41 ++++++++++++++------------ 8 files changed, 72 insertions(+), 69 deletions(-) (limited to 'engine') diff --git a/engine/cable_club.asm b/engine/cable_club.asm index fc049ceb..06f69a73 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -537,7 +537,7 @@ TradeCenter_SelectMon: ld [wTileMap + $141], a .asm_574a call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] and a jr z, .asm_574a ; 0x5750 $f8 bit 0, a @@ -896,7 +896,7 @@ Func_5a5f: ; 5a5f (1:5a5f) ld [W_GRASSRATE], a ; W_GRASSRATE inc a ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE - ld [$ffb5], a + ld [hJoy5], a ld a, $a ld [wMusicHeaderPointer], a ld a, BANK(Music_Celadon) diff --git a/engine/evolution.asm b/engine/evolution.asm index 07ccdbda..a52e0071 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -140,7 +140,7 @@ asm_7befa: ; 7befa (1e:7efa) call DelayFrame push bc call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] pop bc and $2 jr nz, .asm_7bf0d diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 4044da43..5f8f0c1d 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -307,7 +307,7 @@ Func_5d5f: ; 5d5f (1:5d5f) xor a ld [hJoyPressed], a ld [hJoyHeld], a - ld [$ffb5], a + ld [hJoy5], a ld [wd72d], a ld hl, wd732 set 0, [hl] @@ -461,7 +461,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a) call SetOptionsFromCursorPositions .getJoypadStateLoop call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] ld b,a and a,%11111011 ; any key besides select pressed? jr z,.getJoypadStateLoop diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 63e440f8..f35b93e0 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -10,7 +10,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wLastMenuItem],a inc a ld [wd11e],a - ld [$ffb7],a + ld [hJoy7],a .setUpGraphics ld b,$08 call GoPAL_SET @@ -35,7 +35,7 @@ ShowPokedexMenu: ; 40000 (10:4000) ld [wcc37],a ld [wCurrentMenuItem],a ld [wLastMenuItem],a - ld [$ffb7],a + ld [hJoy7],a ld [wcd3a],a ld [wcd3b],a pop af @@ -550,7 +550,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld [$fff4],a .waitForButtonPress call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] and a,%00000011 ; A button and B button jr z,.waitForButtonPress pop af diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index e43cc9ab..9ded4f36 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -797,7 +797,7 @@ SlotMachine_3784e: ; 3784e (d:784e) SlotMachine_37882: ; 37882 (d:7882) call DelayFrame call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] and $1 ret z ld hl, wTrainerSpriteOffset diff --git a/engine/town_map.asm b/engine/town_map.asm index 2cd37284..5e8b77de 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -6,7 +6,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) ld [hl], $ff push hl ld a, $1 - ld [$ffb7], a + ld [hJoy7], a ld a, [W_CURMAP] ; W_CURMAP push af ld b, $0 @@ -66,7 +66,7 @@ Func_70e92: ; 70e92 (1c:4e92) .asm_70ec8 call Func_716c6 call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] ld b, a and $c3 jr z, .asm_70ec8 @@ -78,7 +78,7 @@ Func_70e92: ; 70e92 (1c:4e92) jr nz, .asm_70f01 xor a ld [wd09b], a - ld [$ffb7], a + ld [hJoy7], a ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM call Func_711ab pop hl @@ -188,7 +188,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) push hl call DelayFrame call JoypadLowSensitivity - ld a, [$ffb5] + ld a, [hJoy5] ld b, a pop hl and $c3 diff --git a/home.asm b/home.asm index ad010cde..f83662ca 100644 --- a/home.asm +++ b/home.asm @@ -102,34 +102,34 @@ Start:: INCLUDE "home/joypad.asm" - INCLUDE "data/map_header_pointers.asm" - INCLUDE "home/overworld.asm" -; this is used to check if the player wants to interrupt the opening sequence at several points -; XXX is this used anywhere else? -; INPUT: -; c = number of frames to wait -; sets carry if Up+Select+B, Start, or A is pressed within c frames -; unsets carry otherwise + CheckForUserInterruption:: ; 12f8 (0:12f8) +; Return carry if Up+Select+B, Start or A are pressed in c frames. +; Used only in the intro and title screen. call DelayFrame + push bc call JoypadLowSensitivity pop bc - ld a,[hJoyHeld] ; currently pressed buttons - cp a,%01000110 ; Up, Select button, B button - jr z,.setCarry ; if all three keys are pressed - ld a,[$ffb5] ; either newly pressed buttons or currently pressed buttons at low sampling rate - and a,%00001001 ; Start button, A button - jr nz,.setCarry ; if either key is pressed + + ld a, [hJoyHeld] + cp D_UP + SELECT + B_BUTTON + jr z, .input + + ld a, [hJoy5] + and START | A_BUTTON + jr nz, .input + dec c - jr nz,CheckForUserInterruption -.unsetCarry + jr nz, CheckForUserInterruption + and a ret -.setCarry + +.input scf ret @@ -1347,7 +1347,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) xor a ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer ld a,1 - ld [$ffb7],a ; joypad state update flag + ld [hJoy7],a ; joypad state update flag ld a,[W_BATTLETYPE] and a ; is it the Old Man battle? jr nz,.specialBattleType @@ -1501,7 +1501,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) ld a,[wCurrentMenuItem] ld [wd12d],a xor a - ld [$ffb7],a ; joypad state update flag + ld [hJoy7],a ; joypad state update flag ld hl,wd730 res 6,[hl] ; turn on letter printing delay jp BankswitchBack @@ -1662,7 +1662,7 @@ ExitListMenu:: ; 2e3b (0:2e3b) ld [wd12e],a ld [wcc37],a xor a - ld [$ffb7],a + ld [hJoy7],a ld hl,wd730 res 6,[hl] call BankswitchBack @@ -3347,29 +3347,29 @@ CopyString:: ; 3829 (0:3829) ret ; this function is used when lower button sensitivity is wanted (e.g. menus) -; OUTPUT: [$ffb5] = pressed buttons in usual format -; there are two flags that control its functionality, [$ffb6] and [$ffb7] +; OUTPUT: [hJoy5] = pressed buttons in usual format +; there are two flags that control its functionality, [hJoy6] and [hJoy7] ; there are esentially three modes of operation ; 1. Get newly pressed buttons only -; ([$ffb7] == 0, [$ffb6] == any) -; Just copies [hJoyPressed] to [$ffb5]. +; ([hJoy7] == 0, [hJoy6] == any) +; Just copies [hJoyPressed] to [hJoy5]. ; 2. Get currently pressed buttons at low sample rate with delay -; ([$ffb7] == 1, [$ffb6] != 0) +; ([hJoy7] == 1, [hJoy6] != 0) ; If the user holds down buttons for more than half a second, ; report buttons as being pressed up to 12 times per second thereafter. ; If the user holds down buttons for less than half a second, ; report only one button press. ; 3. Same as 2, but report no buttons as pressed if A or B is held down. -; ([$ffb7] == 1, [$ffb6] == 0) +; ([hJoy7] == 1, [hJoy6] == 0) JoypadLowSensitivity:: ; 3831 (0:3831) call Joypad - ld a,[$ffb7] ; flag + ld a,[hJoy7] ; flag and a ; get all currently pressed buttons or only newly pressed buttons? ld a,[hJoyPressed] ; newly pressed buttons jr z,.storeButtonState ld a,[hJoyHeld] ; all currently pressed buttons .storeButtonState - ld [$ffb5],a + ld [hJoy5],a ld a,[hJoyPressed] ; newly pressed buttons and a ; have any buttons been newly pressed since last check? jr z,.noNewlyPressedButtons @@ -3383,18 +3383,18 @@ JoypadLowSensitivity:: ; 3831 (0:3831) jr z,.delayOver .delayNotOver xor a - ld [$ffb5],a ; report no buttons as pressed + ld [hJoy5],a ; report no buttons as pressed ret .delayOver -; if [$ffb6] = 0 and A or B is pressed, report no buttons as pressed +; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed ld a,[hJoyHeld] and a,%00000011 ; A and B buttons jr z,.setShortDelay - ld a,[$ffb6] ; flag + ld a,[hJoy6] ; flag and a jr nz,.setShortDelay xor a - ld [$ffb5],a + ld [hJoy5],a .setShortDelay ld a,5 ; 1/12 of a second delay ld [H_FRAMECOUNTER],a @@ -3421,7 +3421,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) pop hl call JoypadLowSensitivity predef Func_5a5f - ld a, [$ffb5] + ld a, [hJoy5] and A_BUTTON | B_BUTTON jr z, .asm_3872 pop af @@ -3888,7 +3888,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) .getJoypadState pop hl call JoypadLowSensitivity - ld a,[$ffb5] + ld a,[hJoy5] and a ; was a key pressed? jr nz,.keyPressed push hl @@ -3911,7 +3911,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) .keyPressed xor a ld [wcc4b],a - ld a,[$ffb5] + ld a,[hJoy5] ld b,a bit 6,a ; pressed Up key? jr z,.checkIfDownPressed @@ -3953,7 +3953,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) and b ; does the menu care about any of the pressed keys? jp z,.loop1 .checkIfAButtonOrBButtonPressed - ld a,[$ffb5] + ld a,[hJoy5] and a,%00000011 ; pressed A button or B button? jr z,.skipPlayingSound .AButtonOrBButtonPressed @@ -3971,7 +3971,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) ld [H_DOWNARROWBLINKCNT1],a ; restore previous values xor a ld [wMenuWrappingEnabled],a ; disable menu wrapping - ld a,[$ffb5] + ld a,[hJoy5] ret .noWrappingAround ld a,[wcc37] diff --git a/hram.asm b/hram.asm index b88c248b..4599e950 100644 --- a/hram.asm +++ b/hram.asm @@ -1,8 +1,8 @@ -H_SPRITEWIDTH EQU $FF8B ; in bytes +H_SPRITEWIDTH EQU $FF8B ; in tiles H_SPRITEINTERLACECOUNTER EQU $FF8B -H_SPRITEHEIGHT EQU $FF8C ; in bytes -H_SPRITEOFFSET EQU $FF8D +H_SPRITEHEIGHT EQU $FF8C ; in tiles +H_SPRITEOFFSET EQU $FF8D hSoftReset EQU $FF8A ; Initialized to 16. @@ -14,28 +14,31 @@ hSoftReset EQU $FF8A H_DOWNARROWBLINKCNT1 EQU $FF8B H_DOWNARROWBLINKCNT2 EQU $FF8C -; Note: the following multiplication and division addresses are used for multiple purposes -; and so they overlap with each other +; Multiplcation and division variables are meant +; to overlap for back-to-back usage. Big endian. -H_MULTIPLICAND EQU $FF96 ; 3 bytes, big endian order +H_MULTIPLICAND EQU $FF96 ; 3 bytes H_MULTIPLIER EQU $FF99 ; 1 byte -H_PRODUCT EQU $FF95 ; 4 bytes, big endian order +H_PRODUCT EQU $FF95 ; 4 bytes -H_DIVIDEND EQU $FF95 ; 4 bytes, big endian order +H_DIVIDEND EQU $FF95 ; 4 bytes H_DIVISOR EQU $FF99 ; 1 byte -H_QUOTIENT EQU $FF95 ; 4 bytes, big endian order +H_QUOTIENT EQU $FF95 ; 4 bytes H_REMAINDER EQU $FF99 ; 1 byte -; used to convert numbers to decimal -H_PASTLEADINGZEROES EQU $FF95 ; flag to indicate that a nonzero digit has been printed -H_NUMTOPRINT EQU $FF96 ; 3 bytes, big endian order -H_POWEROFTEN EQU $FF99 ; 3 bytes, big endian order -H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes, big endian order (to back out of a subtraction) - -hJoyHeldLast EQU $FFB1 -hJoyReleased EQU $FFB2 -hJoyPressed EQU $FFB3 -hJoyHeld EQU $FFB4 +; PrintNumber (big endian). +H_PASTLEADINGZEROES EQU $FF95 ; last char printed +H_NUMTOPRINT EQU $FF96 ; 3 bytes +H_POWEROFTEN EQU $FF99 ; 3 bytes +H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes + +hJoyHeldLast EQU $FFB1 +hJoyReleased EQU $FFB2 +hJoyPressed EQU $FFB3 +hJoyHeld EQU $FFB4 +hJoy5 EQU $FFB5 +hJoy6 EQU $FFB6 +hJoy7 EQU $FFB7 H_LOADEDROMBANK EQU $FFB8 -- cgit v1.3.1-sl0p From aa361c3bf7a302dd9a883ff869c06305f3fc0436 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 17 Sep 2014 12:37:47 -0700 Subject: Use move animation constants instead of static values. This allows new moves and animations to be added without overlap. --- engine/battle/animations.asm | 14 +++++++------- engine/battle/core.asm | 24 ++++++++++++------------ engine/trade.asm | 12 ++++++------ 3 files changed, 25 insertions(+), 25 deletions(-) (limited to 'engine') diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index cc598de4..a8ed3865 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -525,9 +525,9 @@ Func_78e23: ; 78e23 (1e:4e23) ld [wcc79], a ld b, $e4 ld a, [W_ANIMATIONID] ; W_ANIMATIONID - cp $aa + cp ANIM_AA jr c, .asm_78e3f - cp $ae + cp ANIM_AD + 1 jr nc, .asm_78e3f ld b, $f0 .asm_78e3f @@ -697,13 +697,13 @@ AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5) db ROCK_SLIDE dw DoRockSlideSpecialEffects - db $AA + db ANIM_AA dw Func_79041 - db $AB + db ANIM_AB dw Func_7904c - db $AC + db ANIM_AC dw Func_7907c db TOSS_ANIM @@ -2855,10 +2855,10 @@ TossBallAnimation: ; 79e16 (1e:5e16) .PokeBallAnimations: ; 79e50 (1e:5e50) ; sequence of animations that make up the Poké Ball toss - db POOF_ANIM,HIDEPIC_ANIM,$C2,POOF_ANIM,SHOWPIC_ANIM + db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM .BlockBall ; 5E55 - ld a,$C1 + ld a,TOSS_ANIM ld [W_ANIMATIONID],a call PlayAnimation ld a,(SFX_08_43 - SFX_Headers_08) / 3 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 399a8ee7..4baa7a76 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -7062,16 +7062,16 @@ PoisonEffect: ; 3f24f (f:724f) dec de ld a, [H_WHOSETURN] ; $fff3 and a - ld b, $c7 + ld b, ANIM_C7 ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 ld a, [de] ld de, W_PLAYERTOXICCOUNTER ; wd06c jr nz, .asm_3f2b0 - ld b, $a9 + ld b, ANIM_A9 ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 ld de, W_ENEMYTOXICCOUNTER ; wd071 .asm_3f2b0 - cp $5c + cp TOXIC jr nz, .asm_3f2bd set 0, [hl] xor a @@ -7173,14 +7173,14 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld a, 1 << PAR ld [wEnemyMonStatus], a call Func_3ed27 ;quarter speed of affected monster - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation jp PrintMayNotAttackText ;print paralysis text .burn ld a, 1 << BRN ld [wEnemyMonStatus], a call Func_3ed64 - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation ld hl, BurnedText jp PrintText @@ -7188,7 +7188,7 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) call Func_3f9cf ;resets bit 5 of the D063/D068 flags ld a, 1 << FRZ ld [wEnemyMonStatus], a - ld a, $a9 + ld a, ANIM_A9 call Func_3fbb9 ;animation ld hl, FrozenText jp PrintText @@ -7726,7 +7726,7 @@ BideEffect: ; 3f6e5 (f:76e5) inc a ld [bc], a ld a, [H_WHOSETURN] - add $ae + add XSTATITEM_ANIM jp Func_3fb96 ThrashPetalDanceEffect: ; 3f717 (f:7717) @@ -7745,7 +7745,7 @@ ThrashPetalDanceEffect: ; 3f717 (f:7717) inc a ld [de], a ld a, [H_WHOSETURN] ; $fff3 - add $b0 + add ANIM_B0 jp Func_3fb96 SwitchAndTeleportEffect: ; 3f739 (f:7739) @@ -7941,11 +7941,11 @@ ChargeEffect: ; 3f88c (f:788c) ld de, W_PLAYERMOVEEFFECT ; wcfd3 ld a, [H_WHOSETURN] ; $fff3 and a - ld b, $ae + ld b, XSTATITEM_ANIM jr z, .asm_3f8a1 ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT - ld b, $af + ld b, ANIM_AF .asm_3f8a1 set 4, [hl] ld a, [de] @@ -7953,13 +7953,13 @@ ChargeEffect: ; 3f88c (f:788c) cp FLY_EFFECT jr nz, .asm_3f8ad set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, $64 + ld b, TELEPORT .asm_3f8ad ld a, [de] cp DIG jr nz, .asm_3f8b6 set 6, [hl] ; mon is now invulnerable to typical attacks (fly/dig) - ld b, $c0 + ld b, ANIM_C0 .asm_3f8b6 xor a ld [wcc5b], a diff --git a/engine/trade.asm b/engine/trade.asm index 54abdab6..199513af 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -203,9 +203,9 @@ Func_41245: ; 41245 (10:5245) and a jr nz, .asm_41273 call Delay50 - ld a, $ad + ld a, ANIM_AD call Func_41676 - ld a, $aa + ld a, ANIM_AA call Func_41676 ld a, [wWhichTrade] ; wWhichTrade call PlayCry @@ -242,9 +242,9 @@ Func_41298: ; 41298 (10:5298) ret Func_412d2: ; 412d2 (10:52d2) - ld a, $ab + ld a, ANIM_AB call Func_41676 - ld c, $a + ld c, 10 call DelayFrames ld a, $e4 ld [rOBP0], a ; $ff48 @@ -295,7 +295,7 @@ UnknownOAM_4132e: ; 4132e (10:532e) db $7E,$40,$7E,$60 Func_41336: ; 41336 (10:5336) - ld a, $ac + ld a, ANIM_AC call Func_41676 call Func_415c8 hlCoord 4, 10 @@ -308,7 +308,7 @@ Func_41336: ; 41336 (10:5336) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ld a, [wTrainerEngageDistance] call Func_415a4 - ld a, $ad + ld a, ANIM_AD call Func_41676 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba -- cgit v1.3.1-sl0p