From 93b1361dffaff4fae83f4f283fa7a39ab414d73d Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 30 May 2014 18:30:25 -0700 Subject: Split out joypad and overworld code from home.asm. --- home/joypad.asm | 39 + home/overworld.asm | 2419 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2458 insertions(+) create mode 100644 home/joypad.asm create mode 100644 home/overworld.asm (limited to 'home') diff --git a/home/joypad.asm b/home/joypad.asm new file mode 100644 index 00000000..2002bb29 --- /dev/null +++ b/home/joypad.asm @@ -0,0 +1,39 @@ +ReadJoypad:: +; Poll joypad input. +; Unlike the hardware register, button +; presses are indicated by a set bit. + + ld a, 1 << 5 ; select direction keys + ld c, 0 + + ld [rJOYP], a + rept 6 + ld a, [rJOYP] + endr + cpl + and %1111 + swap a + ld b, a + + ld a, 1 << 4 ; select button keys + ld [rJOYP], a + rept 10 + ld a, [rJOYP] + endr + cpl + and %1111 + or b + + ld [hJoyInput], a + + ld a, 1 << 4 + 1 << 5 ; deselect keys + ld [rJOYP], a + ret + +Joypad:: +; Update the joypad state variables: +; [hJoyReleased] keys released since last time +; [hJoyPressed] keys pressed since last time +; [hJoyHeld] currently pressed keys + homecall _Joypad + ret diff --git a/home/overworld.asm b/home/overworld.asm new file mode 100644 index 00000000..84c96f3e --- /dev/null +++ b/home/overworld.asm @@ -0,0 +1,2419 @@ +HandleMidJump:: +; Handle the player jumping down +; a ledge in the overworld. + ld b, BANK(_HandleMidJump) + ld hl, _HandleMidJump + jp Bankswitch + +EnterMap:: +; Load a new map. + ld a, $ff + ld [wJoyIgnore], a + call LoadMapData + callba Func_c335 ; initialize map variables + ld hl, wd72c + bit 0, [hl] + jr z, .doNotCountSteps + ld a, 3 + ld [wd13c], a ; some kind of step counter (counts up to 3 steps?) +.doNotCountSteps + ld hl, wd72e + bit 5, [hl] ; did a battle happen immediately before this? + res 5, [hl] ; unset the "battle just happened" flag + call z, Func_12e7 + call nz, MapEntryAfterBattle + ld hl, wd732 + ld a, [hl] + and 1 << 4 | 1 << 3 + jr z, .didNotFlyOrTeleportIn + res 3, [hl] + callba Func_70510 ; display fly/teleport in graphical effect + call UpdateSprites +.didNotFlyOrTeleportIn + callba CheckForceBikeOrSurf ; handle currents in SF islands and forced bike riding in cycling road + ld hl, wd72d + res 5, [hl] + call UpdateSprites + ld hl, wd126 + set 5, [hl] + set 6, [hl] + xor a + ld [wJoyIgnore], a + +OverworldLoop:: + call DelayFrame +OverworldLoopLessDelay:: + call DelayFrame + call LoadGBPal + ld a,[wd736] + bit 6,a ; jumping down a ledge? + call nz, HandleMidJump + ld a,[wWalkCounter] + and a + jp nz,.moveAhead ; if the player sprite has not yet completed the walking animation + call JoypadOverworld ; get joypad state (which is possibly simulated) + callba SafariZoneCheck + ld a,[wda46] + and a + jp nz,WarpFound2 + ld hl,wd72d + bit 3,[hl] + res 3,[hl] + jp nz,WarpFound2 + ld a,[wd732] + and a,$18 + jp nz,HandleFlyOrTeleportAway + ld a,[W_CUROPPONENT] + and a + jp nz,.newBattle + ld a,[wd730] + bit 7,a ; are we simulating button presses? + jr z,.notSimulating + ld a,[hJoyHeld] + jr .checkIfStartIsPressed +.notSimulating + ld a,[hJoyPressed] +.checkIfStartIsPressed + bit 3,a ; start button + jr z,.startButtonNotPressed +; if START is pressed + xor a + ld [$ff8c],a ; the $2920 ID for the start menu is 0 + jp .displayDialogue +.startButtonNotPressed + bit 0,a ; A button + jp z,.checkIfDownButtonIsPressed +; if A is pressed + ld a,[wd730] + bit 2,a + jp nz,.noDirectionButtonsPressed + call Func_30fd + jr nz,.checkForOpponent + call Func_3eb5 ; check for hidden items, PC's, etc. + ld a,[$ffeb] + and a + jp z,OverworldLoop + call IsSpriteOrSignInFrontOfPlayer ; check for sign or sprite in front of the player + ld a,[$ff8c] ; $2920 ID for NPC/sign text, if any + and a + jp z,OverworldLoop +.displayDialogue + ld a,$35 + call Predef ; check what is in front of the player + call UpdateSprites ; move sprites + ld a,[wFlags_0xcd60] + bit 2,a + jr nz,.checkForOpponent + bit 0,a + jr nz,.checkForOpponent + FuncCoord 8, 9 + ld a,[Coord] + ld [wcf0e],a + call DisplayTextID ; display either the start menu or the NPC/sign text + ld a,[wcc47] + and a + jr z,.checkForOpponent + dec a + ld a,$00 + ld [wcc47],a + jr z,.changeMap + ld a,$52 + call Predef + ld a,[W_CURMAP] + ld [wd71a],a + call Func_62ce + ld a,[W_CURMAP] + call SwitchToMapRomBank ; switch to the ROM bank of the current map + ld hl,W_CURMAPTILESET + set 7,[hl] +.changeMap + jp EnterMap +.checkForOpponent + ld a,[W_CUROPPONENT] + and a + jp nz,.newBattle + jp OverworldLoop +.noDirectionButtonsPressed + ld hl,wFlags_0xcd60 + res 2,[hl] + call UpdateSprites ; move sprites + ld a,$01 + ld [wcc4b],a + ld a,[wd528] ; the direction that was pressed last time + and a + jp z,OverworldLoop +; if a direction was pressed last time + ld [wd529],a ; save the last direction + xor a + ld [wd528],a ; zero the direction + jp OverworldLoop +.checkIfDownButtonIsPressed + ld a,[hJoyHeld] ; current joypad state + bit 7,a ; down button + jr z,.checkIfUpButtonIsPressed + ld a,$01 + ld [wSpriteStateData1 + 3],a + ld a,$04 + jr .handleDirectionButtonPress +.checkIfUpButtonIsPressed + bit 6,a ; up button + jr z,.checkIfLeftButtonIsPressed + ld a,$ff + ld [wSpriteStateData1 + 3],a + ld a,$08 + jr .handleDirectionButtonPress +.checkIfLeftButtonIsPressed + bit 5,a ; left button + jr z,.checkIfRightButtonIsPressed + ld a,$ff + ld [wSpriteStateData1 + 5],a + ld a,$02 + jr .handleDirectionButtonPress +.checkIfRightButtonIsPressed + bit 4,a ; right button + jr z,.noDirectionButtonsPressed + ld a,$01 + ld [wSpriteStateData1 + 5],a +.handleDirectionButtonPress + ld [wd52a],a ; new direction + ld a,[wd730] + bit 7,a ; are we simulating button presses? + jr nz,.noDirectionChange ; ignore direction changes if we are + ld a,[wcc4b] + and a + jr z,.noDirectionChange + ld a,[wd52a] ; new direction + ld b,a + ld a,[wd529] ; old direction + cp b + jr z,.noDirectionChange +; the code below is strange +; it computes whether or not the player did a 180 degree turn, but then overwrites the result +; also, it does a seemingly pointless loop afterwards + swap a ; put old direction in upper half + or b ; put new direction in lower half + cp a,$48 ; change dir from down to up + jr nz,.notDownToUp + ld a,$02 + ld [wd528],a + jr .oddLoop +.notDownToUp + cp a,$84 ; change dir from up to down + jr nz,.notUpToDown + ld a,$01 + ld [wd528],a + jr .oddLoop +.notUpToDown + cp a,$12 ; change dir from right to left + jr nz,.notRightToLeft + ld a,$04 + ld [wd528],a + jr .oddLoop +.notRightToLeft + cp a,$21 ; change dir from left to right + jr nz,.oddLoop + ld a,$08 + ld [wd528],a +.oddLoop + ld hl,wFlags_0xcd60 + set 2,[hl] + ld hl,wcc4b + dec [hl] + jr nz,.oddLoop + ld a,[wd52a] + ld [wd528],a + call NewBattle + jp c,.battleOccurred + jp OverworldLoop +.noDirectionChange + ld a,[wd52a] ; current direction + ld [wd528],a ; save direction + call UpdateSprites ; move sprites + ld a,[wd700] + cp a,$02 ; surfing + jr z,.surfing +; not surfing + call CollisionCheckOnLand + jr nc,.noCollision + push hl + ld hl,wd736 + bit 2,[hl] + pop hl + jp z,OverworldLoop + push hl + call ExtraWarpCheck ; sets carry if there is a potential to warp + pop hl + jp c,CheckWarpsCollision + jp OverworldLoop +.surfing + call CollisionCheckOnWater + jp c,OverworldLoop +.noCollision + ld a,$08 + ld [wWalkCounter],a + jr .moveAhead2 +.moveAhead + ld a,[wd736] + bit 7,a + jr z,.noSpinning + callba LoadSpinnerArrowTiles ; spin while moving +.noSpinning + call UpdateSprites ; move sprites +.moveAhead2 + ld hl,wFlags_0xcd60 + res 2,[hl] + ld a,[wd700] + dec a ; riding a bike? + jr nz,.normalPlayerSpriteAdvancement + ld a,[wd736] + bit 6,a ; jumping a ledge? + jr nz,.normalPlayerSpriteAdvancement + call BikeSpeedup ; if riding a bike and not jumping a ledge +.normalPlayerSpriteAdvancement + call AdvancePlayerSprite + ld a,[wWalkCounter] + and a + jp nz,CheckMapConnections ; it seems like this check will never succeed (the other place where CheckMapConnections is run works) +; walking animation finished + ld a,[wd730] + bit 7,a + jr nz,.doneStepCounting ; if button presses are being simulated, don't count steps +; step counting + ld hl,wd13b ; step counter + dec [hl] + ld a,[wd72c] + bit 0,a + jr z,.doneStepCounting + ld hl,wd13c + dec [hl] + jr nz,.doneStepCounting + ld hl,wd72c + res 0,[hl] +.doneStepCounting + ld a,[wd790] + bit 7,a ; in the safari zone? + jr z,.notSafariZone + callba SafariZoneCheckSteps + ld a,[wda46] + and a + jp nz,WarpFound2 +.notSafariZone + ld a,[W_ISINBATTLE] + and a + jp nz,CheckWarpsNoCollision + ld a,$13 + call Predef ; decrement HP of poisoned pokemon + ld a,[wd12d] + and a + jp nz,HandleBlackOut ; if all pokemon fainted +.newBattle + call NewBattle + ld hl,wd736 + res 2,[hl] + jp nc,CheckWarpsNoCollision ; check for warps if there was no battle +.battleOccurred + ld hl,wd72d + res 6,[hl] + ld hl,W_FLAGS_D733 + res 3,[hl] + ld hl,wd126 + set 5,[hl] + set 6,[hl] + xor a + ld [hJoyHeld],a ; clear joypad state + ld a,[W_CURMAP] + cp a,CINNABAR_GYM + jr nz,.notCinnabarGym + ld hl,wd79b + set 7,[hl] +.notCinnabarGym + ld hl,wd72e + set 5,[hl] + ld a,[W_CURMAP] + cp a,OAKS_LAB + jp z,.noFaintCheck + callab AnyPlayerPokemonAliveCheck ; check if all the player's pokemon fainted + ld a,d + and a + jr z,.allPokemonFainted +.noFaintCheck + ld c,$0a + call DelayFrames + jp EnterMap +.allPokemonFainted + ld a,$ff + ld [W_ISINBATTLE],a + call RunMapScript + jp HandleBlackOut + +; function to determine if there will be a battle and execute it (either a trainer battle or wild battle) +; sets carry if a battle occurred and unsets carry if not +NewBattle:: ; 0683 (0:0683) + ld a,[wd72d] + bit 4,a + jr nz,.noBattle + call Func_30fd + jr nz,.noBattle + ld a,[wd72e] + bit 4,a + jr nz,.noBattle + ld b, BANK(InitBattle) + ld hl, InitBattle + jp Bankswitch ; determines if a battle will occur and runs the battle if so +.noBattle + and a + ret + +; function to make bikes twice as fast as walking +BikeSpeedup:: ; 06a0 (0:06a0) + ld a,[wcc57] + and a + ret nz + ld a,[W_CURMAP] + cp a,ROUTE_17 ; Cycling Road + jr nz,.goFaster + ld a,[hJoyHeld] ; current joypad state + and a,%01110000 ; bit mask for up, left, right buttons + ret nz +.goFaster + jp AdvancePlayerSprite + +; check if the player has stepped onto a warp after having not collided +CheckWarpsNoCollision:: ; 06b4 (0:06b4) + ld a,[wd3ae] ; number of warps + and a + jp z,CheckMapConnections + ld a,[wd3ae] ; number of warps + ld b,$00 + ld c,a + ld a,[W_YCOORD] + ld d,a + ld a,[W_XCOORD] + ld e,a + ld hl,wd3af ; start of warp entries +CheckWarpsNoCollisionLoop:: ; 06cc (0:06cc) + ld a,[hli] ; check if the warp's Y position matches + cp d + jr nz,CheckWarpsNoCollisionRetry1 + ld a,[hli] ; check if the warp's X position matches + cp e + jr nz,CheckWarpsNoCollisionRetry2 +; if a match was found + push hl + push bc + ld hl,wd736 + set 2,[hl] + callba Func_c49d ; check if the player sprite is standing on a "door" tile + pop bc + pop hl + jr c,WarpFound1 ; if it is, go to 0735 + push hl + push bc + call ExtraWarpCheck ; sets carry if the warp is confirmed + pop bc + pop hl + jr nc,CheckWarpsNoCollisionRetry2 +; if the extra check passed + ld a,[W_FLAGS_D733] + bit 2,a + jr nz,WarpFound1 + push de + push bc + call Joypad + pop bc + pop de + ld a,[hJoyHeld] ; current joypad state + and a,%11110000 ; bit mask for directional buttons + jr z,CheckWarpsNoCollisionRetry2 ; if directional buttons aren't being pressed, do not pass through the warp + jr WarpFound1 + +; check if the player has stepped onto a warp after having collided +CheckWarpsCollision:: ; 0706 (0:0706) + ld a,[wd3ae] ; number of warps + ld c,a + ld hl,wd3af ; start of warp entries +.loop + ld a,[hli] ; Y coordinate of warp + ld b,a + ld a,[W_YCOORD] + cp b + jr nz,.retry1 + ld a,[hli] ; X coordinate of warp + ld b,a + ld a,[W_XCOORD] + cp b + jr nz,.retry2 + ld a,[hli] + ld [wd42f],a ; save target warp ID + ld a,[hl] + ld [$ff8b],a ; save target map + jr WarpFound2 +.retry1 + inc hl +.retry2 + inc hl + inc hl + dec c + jr nz,.loop + jp OverworldLoop + +CheckWarpsNoCollisionRetry1:: ; 072f (0:072f) + inc hl +CheckWarpsNoCollisionRetry2:: ; 0730 (0:0730) + inc hl + inc hl + jp ContinueCheckWarpsNoCollisionLoop + +WarpFound1:: ; 0735 (0:0735) + ld a,[hli] + ld [wd42f],a ; save target warp ID + ld a,[hli] + ld [$ff8b],a ; save target map + +WarpFound2:: ; 073c (0:073c) + ld a,[wd3ae] ; number of warps + sub c + ld [wd73b],a ; save ID of used warp + ld a,[W_CURMAP] + ld [wd73c],a + call CheckIfInOutsideMap + jr nz,.indoorMaps +; this is for handling "outside" maps that can't have the 0xFF destination map + ld a,[W_CURMAP] + ld [wLastMap],a + ld a,[W_CURMAPWIDTH] + ld [wd366],a + ld a,[$ff8b] ; destination map number + ld [W_CURMAP],a ; change current map to destination map + cp a,ROCK_TUNNEL_1 + jr nz,.notRockTunnel + ld a,$06 + ld [wd35d],a + call GBFadeIn1 +.notRockTunnel + call PlayMapChangeSound + jr .done +; for maps that can have the 0xFF destination map, which means to return to the outside map; not all these maps are necessarily indoors, though +.indoorMaps + ld a,[$ff8b] ; destination map + cp a,$ff + jr z,.goBackOutside +; if not going back to the previous map + ld [W_CURMAP],a ; current map number + callba Func_70787 ; check if the warp was a Silph Co. teleporter + ld a,[wcd5b] + dec a + jr nz,.notTeleporter +; if it's a Silph Co. teleporter + ld hl,wd732 + set 3,[hl] + call DoFlyOrTeleportAwayGraphics + jr .skipMapChangeSound +.notTeleporter + call PlayMapChangeSound +.skipMapChangeSound + ld hl,wd736 + res 0,[hl] + res 1,[hl] + jr .done +.goBackOutside + ld a,[wLastMap] + ld [W_CURMAP],a + call PlayMapChangeSound + xor a + ld [wd35d],a +.done + ld hl,wd736 + set 0,[hl] + call Func_12da + jp EnterMap + +ContinueCheckWarpsNoCollisionLoop:: ; 07b5 (0:07b5) + inc b ; increment warp number + dec c ; decrement number of warps + jp nz,CheckWarpsNoCollisionLoop + +; if no matching warp was found +CheckMapConnections:: ; 07ba (0:07ba) +.checkWestMap + ld a,[W_XCOORD] + cp a,$ff + jr nz,.checkEastMap + ld a,[W_MAPCONN3PTR] + ld [W_CURMAP],a + ld a,[wd38f] ; new X coordinate upon entering west map + ld [W_XCOORD],a + ld a,[W_YCOORD] + ld c,a + ld a,[wd38e] ; Y adjustment upon entering west map + add c + ld c,a + ld [W_YCOORD],a + ld a,[wd390] ; pointer to upper left corner of map without adjustment for Y position + ld l,a + ld a,[wd391] + ld h,a + srl c + jr z,.savePointer1 +.pointerAdjustmentLoop1 + ld a,[wd38d] ; width of connected map + add a,$06 + ld e,a + ld d,$00 + ld b,$00 + add hl,de + dec c + jr nz,.pointerAdjustmentLoop1 +.savePointer1 + ld a,l + ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld a,h + ld [wd360],a + jp .loadNewMap +.checkEastMap + ld b,a + ld a,[wd525] ; map width + cp b + jr nz,.checkNorthMap + ld a,[W_MAPCONN4PTR] + ld [W_CURMAP],a + ld a,[wd39a] ; new X coordinate upon entering east map + ld [W_XCOORD],a + ld a,[W_YCOORD] + ld c,a + ld a,[wd399] ; Y adjustment upon entering east map + add c + ld c,a + ld [W_YCOORD],a + ld a,[wd39b] ; pointer to upper left corner of map without adjustment for Y position + ld l,a + ld a,[wd39c] + ld h,a + srl c + jr z,.savePointer2 +.pointerAdjustmentLoop2 + ld a,[wd398] + add a,$06 + ld e,a + ld d,$00 + ld b,$00 + add hl,de + dec c + jr nz,.pointerAdjustmentLoop2 +.savePointer2 + ld a,l + ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld a,h + ld [wd360],a + jp .loadNewMap +.checkNorthMap + ld a,[W_YCOORD] + cp a,$ff + jr nz,.checkSouthMap + ld a,[W_MAPCONN1PTR] + ld [W_CURMAP],a + ld a,[wd378] ; new Y coordinate upon entering north map + ld [W_YCOORD],a + ld a,[W_XCOORD] + ld c,a + ld a,[wd379] ; X adjustment upon entering north map + add c + ld c,a + ld [W_XCOORD],a + ld a,[wd37a] ; pointer to upper left corner of map without adjustment for X position + ld l,a + ld a,[wd37b] + ld h,a + ld b,$00 + srl c + add hl,bc + ld a,l + ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld a,h + ld [wd360],a + jp .loadNewMap +.checkSouthMap + ld b,a + ld a,[wd524] + cp b + jr nz,.didNotEnterConnectedMap + ld a,[W_MAPCONN2PTR] + ld [W_CURMAP],a + ld a,[wd383] ; new Y coordinate upon entering south map + ld [W_YCOORD],a + ld a,[W_XCOORD] + ld c,a + ld a,[wd384] ; X adjustment upon entering south map + add c + ld c,a + ld [W_XCOORD],a + ld a,[wd385] ; pointer to upper left corner of map without adjustment for X position + ld l,a + ld a,[wd386] + ld h,a + ld b,$00 + srl c + add hl,bc + ld a,l + ld [wd35f],a ; pointer to upper left corner of current tile block map section + ld a,h + ld [wd360],a +.loadNewMap ; load the connected map that was entered + call LoadMapHeader + call Func_2312 ; music + ld b,$09 + call GoPAL_SET +; Since the sprite set shouldn't change, this will just update VRAM slots at +; $C2XE without loading any tile patterns. + callba InitMapSprites + call LoadTileBlockMap + jp OverworldLoopLessDelay +.didNotEnterConnectedMap + jp OverworldLoop + +; function to play a sound when changing maps +PlayMapChangeSound:: ; 08c9 (0:08c9) + FuncCoord 8, 8 + ld a,[Coord] ; upper left tile of the 4x4 square the player's sprite is standing on + cp a,$0b ; door tile in tileset 0 + jr nz,.didNotGoThroughDoor + ld a,(SFX_02_57 - SFX_Headers_02) / 3 + jr .playSound +.didNotGoThroughDoor + ld a,(SFX_02_5c - SFX_Headers_02) / 3 +.playSound + call PlaySound + ld a,[wd35d] + and a + ret nz + jp GBFadeIn1 + +CheckIfInOutsideMap:: ; 08e1 (0:08e1) +; If the player is in an outside map (a town or route), set the z flag + ld a, [W_CURMAPTILESET] + and a ; most towns/routes have tileset 0 (OVERWORLD) + ret z + cp PLATEAU ; Route 23 / Indigo Plateau + ret + +; this function is an extra check that sometimes has to pass in order to warp, beyond just standing on a warp +; the "sometimes" qualification is necessary because of CheckWarpsNoCollision's behavior +; depending on the map, either "function 1" or "function 2" is used for the check +; "function 1" passes when the player is at the edge of the map and is facing towards the outside of the map +; "function 2" passes when the the tile in front of the player is among a certain set +; sets carry if the check passes, otherwise clears carry +ExtraWarpCheck:: ; 08e9 (0:08e9) + ld a, [W_CURMAP] + cp SS_ANNE_3 + jr z, .useFunction1 + cp ROCKET_HIDEOUT_1 + jr z, .useFunction2 + cp ROCKET_HIDEOUT_2 + jr z, .useFunction2 + cp ROCKET_HIDEOUT_4 + jr z, .useFunction2 + cp ROCK_TUNNEL_1 + jr z, .useFunction2 + ld a, [W_CURMAPTILESET] + and a ; outside tileset (OVERWORLD) + jr z, .useFunction2 + cp SHIP ; S.S. Anne tileset + jr z, .useFunction2 + cp SHIP_PORT ; Vermilion Port tileset + jr z, .useFunction2 + cp PLATEAU ; Indigo Plateau tileset + jr z, .useFunction2 +.useFunction1 + ld hl, Func_c3ff + jr .doBankswitch +.useFunction2 + ld hl, Func_c44e +.doBankswitch + ld b, BANK(Func_c44e) + jp Bankswitch + +MapEntryAfterBattle:: ; 091f (0:091f) + callba Func_c35f ; function that appears to disable warp testing after collisions if the player is standing on a warp + ld a,[wd35d] + and a + jp z,GBFadeIn2 + jp LoadGBPal + +HandleBlackOut:: +; For when all the player's pokemon faint. +; Does not print the "blacked out" message. + + call GBFadeIn1 + ld a, $08 + call StopMusic + ld hl, wd72e + res 5, [hl] + ld a, Bank(Func_40b0) ; also Bank(Func_62ce) and Bank(Func_5d5f) + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + call Func_40b0 + call Func_62ce + call Func_2312 + jp Func_5d5f + +StopMusic:: + ld [wMusicHeaderPointer], a + ld a, $ff + ld [wc0ee], a + call PlaySound +.wait + ld a, [wMusicHeaderPointer] + and a + jr nz, .wait + jp StopAllSounds + +HandleFlyOrTeleportAway:: + call UpdateSprites + call Delay3 + xor a + ld [wcf0b], a + ld [wd700], a + ld [W_ISINBATTLE], a + ld [wd35d], a + ld hl, wd732 + set 2, [hl] + res 5, [hl] + call DoFlyOrTeleportAwayGraphics + ld a, Bank(Func_62ce) + ld [H_LOADEDROMBANK], a + ld [$2000], a + call Func_62ce + jp Func_5d5f + +DoFlyOrTeleportAwayGraphics:: + ld b, BANK(_DoFlyOrTeleportAwayGraphics) + ld hl, _DoFlyOrTeleportAwayGraphics + jp Bankswitch + +LoadPlayerSpriteGraphics:: +; Load sprite graphics based on whether the player is standing, biking, or surfing. + + ; 0: standing + ; 1: biking + ; 2: surfing + + ld a, [wd700] + dec a + jr z, .ridingBike + + ld a, [$ffd7] + and a + jr nz, .determineGraphics + jr .startWalking + +.ridingBike + ; If the bike can't be used, + ; start walking instead. + call IsBikeRidingAllowed + jr c, .determineGraphics + +.startWalking + xor a + ld [wd700], a + ld [wd11a], a + jp LoadWalkingPlayerSpriteGraphics + +.determineGraphics + ld a, [wd700] + and a + jp z, LoadWalkingPlayerSpriteGraphics + dec a + jp z, LoadBikePlayerSpriteGraphics + dec a + jp z, LoadSurfingPlayerSpriteGraphics + jp LoadWalkingPlayerSpriteGraphics + +IsBikeRidingAllowed:: +; The bike can be used on Route 23 and Indigo Plateau, +; or maps with tilesets in BikeRidingTilesets. +; Return carry if biking is allowed. + + ld a, [W_CURMAP] + cp ROUTE_23 + jr z, .allowed + cp INDIGO_PLATEAU + jr z, .allowed + + ld a, [W_CURMAPTILESET] + ld b, a + ld hl, BikeRidingTilesets +.loop + ld a, [hli] + cp b + jr z, .allowed + inc a + jr nz, .loop + and a + ret + +.allowed + scf + ret + +INCLUDE "data/bike_riding_tilesets.asm" + +; load the tile pattern data of the current tileset into VRAM +LoadTilesetTilePatternData:: ; 09e8 (0:09e8) + ld a,[W_TILESETGFXPTR] + ld l,a + ld a,[W_TILESETGFXPTR + 1] + ld h,a + ld de,vTileset + ld bc,$600 + ld a,[W_TILESETBANK] + jp FarCopyData2 + +; this loads the current maps complete tile map (which references blocks, not individual tiles) to C6E8 +; it can also load partial tile maps of connected maps into a border of length 3 around the current map +LoadTileBlockMap:: ; 09fc (0:09fc) +; fill C6E8-CBFB with the background tile + ld hl,wOverworldMap + ld a,[wd3ad] ; background tile number + ld d,a + ld bc,$0514 +.backgroundTileLoop + ld a,d + ld [hli],a + dec bc + ld a,c + or b + jr nz,.backgroundTileLoop +; load tile map of current map (made of tile block IDs) +; a 3-byte border at the edges of the map is kept so that there is space for map connections + ld hl,wOverworldMap + ld a,[W_CURMAPWIDTH] + ld [$ff8c],a + add a,$06 ; border (east and west) + ld [$ff8b],a ; map width + border + ld b,$00 + ld c,a +; make space for north border (next 3 lines) + add hl,bc + add hl,bc + add hl,bc + ld c,$03 + add hl,bc ; this puts us past the (west) border + ld a,[W_MAPDATAPTR] ; tile map pointer + ld e,a + ld a,[W_MAPDATAPTR + 1] + ld d,a ; de = tile map pointer + ld a,[W_CURMAPHEIGHT] + ld b,a +.rowLoop ; copy one row each iteration + push hl + ld a,[$ff8c] ; map width (without border) + ld c,a +.rowInnerLoop + ld a,[de] + inc de + ld [hli],a + dec c + jr nz,.rowInnerLoop +; add the map width plus the border to the base address of the current row to get the next row's address + pop hl + ld a,[$ff8b] ; map width + border + add l + ld l,a + jr nc,.noCarry + inc h +.noCarry + dec b + jr nz,.rowLoop +.northConnection + ld a,[W_MAPCONN1PTR] + cp a,$ff + jr z,.southConnection + call SwitchToMapRomBank + ld a,[wd372] + ld l,a + ld a,[wd373] + ld h,a + ld a,[wd374] + ld e,a + ld a,[wd375] + ld d,a + ld a,[wd376] + ld [$ff8b],a + ld a,[wd377] + ld [$ff8c],a + call LoadNorthSouthConnectionsTileMap +.southConnection + ld a,[W_MAPCONN2PTR] + cp a,$ff + jr z,.westConnection + call SwitchToMapRomBank + ld a,[wd37d] + ld l,a + ld a,[wd37e] + ld h,a + ld a,[wd37f] + ld e,a + ld a,[wd380] + ld d,a + ld a,[wd381] + ld [$ff8b],a + ld a,[wd382] + ld [$ff8c],a + call LoadNorthSouthConnectionsTileMap +.westConnection + ld a,[W_MAPCONN3PTR] + cp a,$ff + jr z,.eastConnection + call SwitchToMapRomBank + ld a,[wd388] + ld l,a + ld a,[wd389] + ld h,a + ld a,[wd38a] + ld e,a + ld a,[wd38b] + ld d,a + ld a,[wd38c] + ld b,a + ld a,[wd38d] + ld [$ff8b],a + call LoadEastWestConnectionsTileMap +.eastConnection + ld a,[W_MAPCONN4PTR] + cp a,$ff + jr z,.done + call SwitchToMapRomBank + ld a,[wd393] + ld l,a + ld a,[wd394] + ld h,a + ld a,[wd395] + ld e,a + ld a,[wd396] + ld d,a + ld a,[wd397] + ld b,a + ld a,[wd398] + ld [$ff8b],a + call LoadEastWestConnectionsTileMap +.done + ret + +LoadNorthSouthConnectionsTileMap:: ; 0ade (0:0ade) + ld c,$03 +.loop + push de + push hl + ld a,[$ff8b] ; width of connection + ld b,a +.innerLoop + ld a,[hli] + ld [de],a + inc de + dec b + jr nz,.innerLoop + pop hl + pop de + ld a,[$ff8c] ; width of connected map + add l + ld l,a + jr nc,.noCarry1 + inc h +.noCarry1 + ld a,[W_CURMAPWIDTH] + add a,$06 + add e + ld e,a + jr nc,.noCarry2 + inc d +.noCarry2 + dec c + jr nz,.loop + ret + +LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02) + push hl + push de + ld c,$03 +.innerLoop + ld a,[hli] + ld [de],a + inc de + dec c + jr nz,.innerLoop + pop de + pop hl + ld a,[$ff8b] ; width of connected map + add l + ld l,a + jr nc,.noCarry1 + inc h +.noCarry1 + ld a,[W_CURMAPWIDTH] + add a,$06 + add e + ld e,a + jr nc,.noCarry2 + inc d +.noCarry2 + dec b + jr nz,LoadEastWestConnectionsTileMap + ret + +; function to check if there is a sign or sprite in front of the player +; if so, it is stored in [$FF8C] +; if not, [$FF8C] is set to 0 +IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) + xor a + ld [$ff8c],a + ld a,[wd4b0] ; number of signs in the map + and a + jr z,.extendRangeOverCounter +; if there are signs + ld a,$35 + call Predef ; get the coordinates in front of the player in de + ld hl,wd4b1 ; start of sign coordinates + ld a,[wd4b0] ; number of signs in the map + ld b,a + ld c,$00 +.signLoop + inc c + ld a,[hli] ; sign Y + cp d + jr z,.yCoordMatched + inc hl + jr .retry +.yCoordMatched + ld a,[hli] ; sign X + cp e + jr nz,.retry +.xCoordMatched +; found sign + push hl + push bc + ld hl,wd4d1 ; start of sign text ID's + ld b,$00 + dec c + add hl,bc + ld a,[hl] + ld [$ff8c],a ; store sign text ID + pop bc + pop hl + ret +.retry + dec b + jr nz,.signLoop +; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC +.extendRangeOverCounter + ld a,$35 + call Predef ; get the tile in front of the player in c + ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) + ld b,$03 + ld d,$20 ; talking range in pixels (long range) +.counterTilesLoop + ld a,[hli] + cp c + jr z,IsSpriteInFrontOfPlayer2 ; jumps if the tile in front of the player is a counter tile + dec b + jr nz,.counterTilesLoop + +; part of the above function, but sometimes its called on its own, when signs are irrelevant +; the caller must zero [$FF8C] +IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b) + ld d,$10 ; talking range in pixels (normal range) +IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) + ld bc,$3c40 ; Y and X position of player sprite + ld a,[wSpriteStateData1 + 9] ; direction the player is facing +.checkIfPlayerFacingUp + cp a,$04 + jr nz,.checkIfPlayerFacingDown +; facing up + ld a,b + sub d + ld b,a + ld a,$08 + jr .doneCheckingDirection +.checkIfPlayerFacingDown + cp a,$00 + jr nz,.checkIfPlayerFacingRight +; facing down + ld a,b + add d + ld b,a + ld a,$04 + jr .doneCheckingDirection +.checkIfPlayerFacingRight + cp a,$0c + jr nz,.playerFacingLeft +; facing right + ld a,c + add d + ld c,a + ld a,$01 + jr .doneCheckingDirection +.playerFacingLeft +; facing left + ld a,c + sub d + ld c,a + ld a,$02 +.doneCheckingDirection + ld [wd52a],a + ld a,[W_NUMSPRITES] ; number of sprites + and a + ret z +; if there are sprites + ld hl,wSpriteStateData1 + $10 + ld d,a + ld e,$01 +.spriteLoop + push hl + ld a,[hli] ; image (0 if no sprite) + and a + jr z,.nextSprite + inc l + ld a,[hli] ; sprite visibility + inc a + jr z,.nextSprite + inc l + ld a,[hli] ; Y location + cp b + jr nz,.nextSprite + inc l + ld a,[hl] ; X location + cp c + jr z,.foundSpriteInFrontOfPlayer +.nextSprite + pop hl + ld a,l + add a,$10 + ld l,a + inc e + dec d + jr nz,.spriteLoop + ret +.foundSpriteInFrontOfPlayer + pop hl + ld a,l + and a,$f0 + inc a + ld l,a + set 7,[hl] + ld a,e + ld [$ff8c],a ; store sprite ID + ret + +; function to check if the player will jump down a ledge and check if the tile ahead is passable (when not surfing) +; sets the carry flag if there is a collision, and unsets it if there isn't a collision +CollisionCheckOnLand:: ; 0bd1 (0:0bd1) + ld a,[wd736] + bit 6,a ; is the player jumping? + jr nz,.noCollision +; if not jumping a ledge + ld a,[wcd38] + and a + jr nz,.noCollision + ld a,[wd52a] ; the direction that the player is trying to go in + ld d,a + ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) + and d ; check if a sprite is in the direction the player is trying to go + jr nz,.collision + xor a + ld [$ff8c],a + call IsSpriteInFrontOfPlayer ; check for sprite collisions again? when does the above check fail to detect a sprite collision? + ld a,[$ff8c] + and a ; was there a sprite collision? + jr nz,.collision +; if no sprite collision + ld hl,TilePairCollisionsLand + call CheckForJumpingAndTilePairCollisions + jr c,.collision + call CheckTilePassable + jr nc,.noCollision +.collision + ld a,[wc02a] + cp a,(SFX_02_5b - SFX_Headers_02) / 3 ; check if collision sound is already playing + jr z,.setCarry + ld a,(SFX_02_5b - SFX_Headers_02) / 3 + call PlaySound ; play collision sound (if it's not already playing) +.setCarry + scf + ret +.noCollision + and a + ret + +; function that checks if the tile in front of the player is passable +; clears carry if it is, sets carry if not +CheckTilePassable:: ; 0c10 (0:0c10) + ld a,$35 + call Predef ; get tile in front of player + ld a,[wcfc6] ; tile in front of player + ld c,a + ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles + ld a,[hli] + ld h,[hl] + ld l,a ; hl now points to passable tiles +.loop + ld a,[hli] + cp a,$ff + jr z,.tileNotPassable + cp c + ret z + jr .loop +.tileNotPassable + scf + ret + +; check if the player is going to jump down a small ledge +; and check for collisions that only occur between certain pairs of tiles +; Input: hl - address of directional collision data +; sets carry if there is a collision and unsets carry if not +CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) + push hl + ld a,$35 + call Predef ; get the tile in front of the player + push de + push bc + callba HandleLedges ; check if the player is trying to jump a ledge + pop bc + pop de + pop hl + and a + ld a,[wd736] + bit 6,a ; is the player jumping? + ret nz +; if not jumping + +Func_c44:: ; 0c44 (0:0c44) + FuncCoord 8, 9 + ld a,[Coord] ; tile the player is on + ld [wcf0e],a + +CheckForTilePairCollisions:: ; 0c4a (0:0c4a) + ld a,[wcfc6] ; tile in front of the player + ld c,a +.tilePairCollisionLoop + ld a,[W_CURMAPTILESET] ; tileset number + ld b,a + ld a,[hli] + cp a,$ff + jr z,.noMatch + cp b + jr z,.tilesetMatches + inc hl +.retry + inc hl + jr .tilePairCollisionLoop +.tilesetMatches + ld a,[wcf0e] ; tile the player is on + ld b,a + ld a,[hl] + cp b + jr z,.currentTileMatchesFirstInPair + inc hl + ld a,[hl] + cp b + jr z,.currentTileMatchesSecondInPair + jr .retry +.currentTileMatchesFirstInPair + inc hl + ld a,[hl] + cp c + jr z,.foundMatch + jr .tilePairCollisionLoop +.currentTileMatchesSecondInPair + dec hl + ld a,[hli] + cp c + inc hl + jr nz,.tilePairCollisionLoop +.foundMatch + scf + ret +.noMatch + and a + ret + +; FORMAT: tileset number, tile 1, tile 2 +; terminated by 0xFF +; these entries indicate that the player may not cross between tile 1 and tile 2 +; it's mainly used to simulate differences in elevation + +TilePairCollisionsLand:: ; 0c7e (0:0c7e) + db CAVERN, $20, $05 + db CAVERN, $41, $05 + db FOREST, $30, $2E + db CAVERN, $2A, $05 + db CAVERN, $05, $21 + db FOREST, $52, $2E + db FOREST, $55, $2E + db FOREST, $56, $2E + db FOREST, $20, $2E + db FOREST, $5E, $2E + db FOREST, $5F, $2E + db $FF + +TilePairCollisionsWater:: ; 0ca0 (0:0ca0) + db FOREST, $14, $2E + db FOREST, $48, $2E + db CAVERN, $14, $05 + db $FF + +; this builds a tile map from the tile block map based on the current X/Y coordinates of the player's character +LoadCurrentMapView:: ; 0caa (0:0caa) + ld a,[H_LOADEDROMBANK] + push af + ld a,[W_TILESETBANK] ; tile data ROM bank + ld [H_LOADEDROMBANK],a + ld [$2000],a ; switch to ROM bank that contains tile data + ld a,[wd35f] ; address of upper left corner of current map view + ld e,a + ld a,[wd360] + ld d,a + ld hl,wTileMapBackup + ld b,$05 +.rowLoop ; each loop iteration fills in one row of tile blocks + push hl + push de + ld c,$06 +.rowInnerLoop ; loop to draw each tile block of the current row + push bc + push de + push hl + ld a,[de] + ld c,a ; tile block number + call DrawTileBlock + pop hl + pop de + pop bc + inc hl + inc hl + inc hl + inc hl + inc de + dec c + jr nz,.rowInnerLoop +; update tile block map pointer to next row's address + pop de + ld a,[W_CURMAPWIDTH] + add a,$06 + add e + ld e,a + jr nc,.noCarry + inc d +.noCarry +; update tile map pointer to next row's address + pop hl + ld a,$60 + add l + ld l,a + jr nc,.noCarry2 + inc h +.noCarry2 + dec b + jr nz,.rowLoop + ld hl,wTileMapBackup + ld bc,$0000 +.adjustForYCoordWithinTileBlock + ld a,[W_YBLOCKCOORD] + and a + jr z,.adjustForXCoordWithinTileBlock + ld bc,$0030 + add hl,bc +.adjustForXCoordWithinTileBlock + ld a,[W_XBLOCKCOORD] + and a + jr z,.copyToVisibleAreaBuffer + ld bc,$0002 + add hl,bc +.copyToVisibleAreaBuffer + ld de,wTileMap ; base address for the tiles that are directly transfered to VRAM during V-blank + ld b,$12 +.rowLoop2 + ld c,$14 +.rowInnerLoop2 + ld a,[hli] + ld [de],a + inc de + dec c + jr nz,.rowInnerLoop2 + ld a,$04 + add l + ld l,a + jr nc,.noCarry3 + inc h +.noCarry3 + dec b + jr nz,.rowLoop2 + pop af + ld [H_LOADEDROMBANK],a + ld [$2000],a ; restore previous ROM bank + ret + +AdvancePlayerSprite:: ; 0d27 (0:0d27) + ld a,[wSpriteStateData1 + 3] ; delta Y + ld b,a + ld a,[wSpriteStateData1 + 5] ; delta X + ld c,a + ld hl,wWalkCounter ; walking animation counter + dec [hl] + jr nz,.afterUpdateMapCoords +; if it's the end of the animation, update the player's map coordinates + ld a,[W_YCOORD] + add b + ld [W_YCOORD],a + ld a,[W_XCOORD] + add c + ld [W_XCOORD],a +.afterUpdateMapCoords + ld a,[wWalkCounter] ; walking animation counter + cp a,$07 + jp nz,.scrollBackgroundAndSprites +; if this is the first iteration of the animation + ld a,c + cp a,$01 + jr nz,.checkIfMovingWest +; moving east + ld a,[wd526] + ld e,a + and a,$e0 + ld d,a + ld a,e + add a,$02 + and a,$1f + or d + ld [wd526],a + jr .adjustXCoordWithinBlock +.checkIfMovingWest + cp a,$ff + jr nz,.checkIfMovingSouth +; moving west + ld a,[wd526] + ld e,a + and a,$e0 + ld d,a + ld a,e + sub a,$02 + and a,$1f + or d + ld [wd526],a + jr .adjustXCoordWithinBlock +.checkIfMovingSouth + ld a,b + cp a,$01 + jr nz,.checkIfMovingNorth +; moving south + ld a,[wd526] + add a,$40 + ld [wd526],a + jr nc,.adjustXCoordWithinBlock + ld a,[wd527] + inc a + and a,$03 + or a,$98 + ld [wd527],a + jr .adjustXCoordWithinBlock +.checkIfMovingNorth + cp a,$ff + jr nz,.adjustXCoordWithinBlock +; moving north + ld a,[wd526] + sub a,$40 + ld [wd526],a + jr nc,.adjustXCoordWithinBlock + ld a,[wd527] + dec a + and a,$03 + or a,$98 + ld [wd527],a +.adjustXCoordWithinBlock + ld a,c + and a + jr z,.pointlessJump ; mistake? +.pointlessJump + ld hl,W_XBLOCKCOORD + ld a,[hl] + add c + ld [hl],a + cp a,$02 + jr nz,.checkForMoveToWestBlock +; moved into the tile block to the east + xor a + ld [hl],a + ld hl,wd4e3 + inc [hl] + ld de,wd35f + call MoveTileBlockMapPointerEast + jr .updateMapView +.checkForMoveToWestBlock + cp a,$ff + jr nz,.adjustYCoordWithinBlock +; moved into the tile block to the west + ld a,$01 + ld [hl],a + ld hl,wd4e3 + dec [hl] + ld de,wd35f + call MoveTileBlockMapPointerWest + jr .updateMapView +.adjustYCoordWithinBlock + ld hl,W_YBLOCKCOORD + ld a,[hl] + add b + ld [hl],a + cp a,$02 + jr nz,.checkForMoveToNorthBlock +; moved into the tile block to the south + xor a + ld [hl],a + ld hl,wd4e2 + inc [hl] + ld de,wd35f + ld a,[W_CURMAPWIDTH] + call MoveTileBlockMapPointerSouth + jr .updateMapView +.checkForMoveToNorthBlock + cp a,$ff + jr nz,.updateMapView +; moved into the tile block to the north + ld a,$01 + ld [hl],a + ld hl,wd4e2 + dec [hl] + ld de,wd35f + ld a,[W_CURMAPWIDTH] + call MoveTileBlockMapPointerNorth +.updateMapView + call LoadCurrentMapView + ld a,[wSpriteStateData1 + 3] ; delta Y + cp a,$01 + jr nz,.checkIfMovingNorth2 +; if moving south + call ScheduleSouthRowRedraw + jr .scrollBackgroundAndSprites +.checkIfMovingNorth2 + cp a,$ff + jr nz,.checkIfMovingEast2 +; if moving north + call ScheduleNorthRowRedraw + jr .scrollBackgroundAndSprites +.checkIfMovingEast2 + ld a,[wSpriteStateData1 + 5] ; delta X + cp a,$01 + jr nz,.checkIfMovingWest2 +; if moving east + call ScheduleEastColumnRedraw + jr .scrollBackgroundAndSprites +.checkIfMovingWest2 + cp a,$ff + jr nz,.scrollBackgroundAndSprites +; if moving west + call ScheduleWestColumnRedraw +.scrollBackgroundAndSprites + ld a,[wSpriteStateData1 + 3] ; delta Y + ld b,a + ld a,[wSpriteStateData1 + 5] ; delta X + ld c,a + sla b + sla c + ld a,[$ffaf] + add b + ld [$ffaf],a ; update background scroll Y + ld a,[$ffae] + add c + ld [$ffae],a ; update background scroll X +; shift all the sprites in the direction opposite of the player's motion +; so that the player appears to move relative to them + ld hl,wSpriteStateData1 + $14 + ld a,[W_NUMSPRITES] ; number of sprites + and a ; are there any sprites? + jr z,.done + ld e,a +.spriteShiftLoop + ld a,[hl] + sub b + ld [hli],a + inc l + ld a,[hl] + sub c + ld [hl],a + ld a,$0e + add l + ld l,a + dec e + jr nz,.spriteShiftLoop +.done + ret + +; the following four functions are used to move the pointer to the upper left +; corner of the tile block map in the direction of motion + +MoveTileBlockMapPointerEast:: ; 0e65 (0:0e65) + ld a,[de] + add a,$01 + ld [de],a + ret nc + inc de + ld a,[de] + inc a + ld [de],a + ret + +MoveTileBlockMapPointerWest:: ; 0e6f (0:0e6f) + ld a,[de] + sub a,$01 + ld [de],a + ret nc + inc de + ld a,[de] + dec a + ld [de],a + ret + +MoveTileBlockMapPointerSouth:: ; 0e79 (0:0e79) + add a,$06 + ld b,a + ld a,[de] + add b + ld [de],a + ret nc + inc de + ld a,[de] + inc a + ld [de],a + ret + +MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85) + add a,$06 + ld b,a + ld a,[de] + sub b + ld [de],a + ret nc + inc de + ld a,[de] + dec a + ld [de],a + ret + +; the following 6 functions are used to tell the V-blank handler to redraw +; the portion of the map that was newly exposed due to the player's movement + +ScheduleNorthRowRedraw:: ; 0e91 (0:0e91) + FuncCoord 0, 0 + ld hl,Coord + call ScheduleRowRedrawHelper + ld a,[wd526] + ld [H_SCREENEDGEREDRAWADDR],a + ld a,[wd527] + ld [H_SCREENEDGEREDRAWADDR + 1],a + ld a,REDRAWROW + ld [H_SCREENEDGEREDRAW],a + ret + +ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) + ld de,wScreenEdgeTiles + ld c,$28 +.loop + ld a,[hli] + ld [de],a + inc de + dec c + jr nz,.loop + ret + +ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) + FuncCoord 0,16 + ld hl,Coord + call ScheduleRowRedrawHelper + ld a,[wd526] + ld l,a + ld a,[wd527] + ld h,a + ld bc,$0200 + add hl,bc + ld a,h + and a,$03 + or a,$98 + ld [H_SCREENEDGEREDRAWADDR + 1],a + ld a,l + ld [H_SCREENEDGEREDRAWADDR],a + ld a,REDRAWROW + ld [H_SCREENEDGEREDRAW],a + ret + +ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) + FuncCoord 18,0 + ld hl,Coord + call ScheduleColumnRedrawHelper + ld a,[wd526] + ld c,a + and a,$e0 + ld b,a + ld a,c + add a,18 + and a,$1f + or b + ld [H_SCREENEDGEREDRAWADDR],a + ld a,[wd527] + ld [H_SCREENEDGEREDRAWADDR + 1],a + ld a,REDRAWCOL + ld [H_SCREENEDGEREDRAW],a + ret + +ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2) + ld de,wScreenEdgeTiles + ld c,$12 +.loop + ld a,[hli] + ld [de],a + inc de + ld a,[hl] + ld [de],a + inc de + ld a,19 + add l + ld l,a + jr nc,.noCarry + inc h +.noCarry + dec c + jr nz,.loop + ret + +ScheduleWestColumnRedraw:: ; 0f08 (0:0f08) + FuncCoord 0,0 + ld hl,Coord + call ScheduleColumnRedrawHelper + ld a,[wd526] + ld [H_SCREENEDGEREDRAWADDR],a + ld a,[wd527] + ld [H_SCREENEDGEREDRAWADDR + 1],a + ld a,REDRAWCOL + ld [H_SCREENEDGEREDRAW],a + ret + +; function to write the tiles that make up a tile block to memory +; Input: c = tile block ID, hl = destination address +DrawTileBlock:: ; 0f1d (0:0f1d) + push hl + ld a,[W_TILESETBLOCKSPTR] ; pointer to tiles + ld l,a + ld a,[W_TILESETBLOCKSPTR + 1] + ld h,a + ld a,c + swap a + ld b,a + and a,$f0 + ld c,a + ld a,b + and a,$0f + ld b,a ; bc = tile block ID * 0x10 + add hl,bc + ld d,h + ld e,l ; de = address of the tile block's tiles + pop hl + ld c,$04 ; 4 loop iterations +.loop ; each loop iteration, write 4 tile numbers + push bc + ld a,[de] + ld [hli],a + inc de + ld a,[de] + ld [hli],a + inc de + ld a,[de] + ld [hli],a + inc de + ld a,[de] + ld [hl],a + inc de + ld bc,$0015 + add hl,bc + pop bc + dec c + jr nz,.loop + ret + +; function to update joypad state and simulate button presses +JoypadOverworld:: ; 0f4d (0:0f4d) + xor a + ld [wSpriteStateData1 + 3],a + ld [wSpriteStateData1 + 5],a + call RunMapScript + call Joypad + ld a,[W_FLAGS_D733] + bit 3,a ; check if a trainer wants a challenge + jr nz,.notForcedDownwards + ld a,[W_CURMAP] + cp a,ROUTE_17 ; Cycling Road + jr nz,.notForcedDownwards + ld a,[hJoyHeld] ; current joypad state + and a,%11110011 ; bit mask for all directions and A/B + jr nz,.notForcedDownwards + ld a,%10000000 ; down pressed + ld [hJoyHeld],a ; on the cycling road, if there isn't a trainer and the player isn't pressing buttons, simulate a down press +.notForcedDownwards + ld a,[wd730] + bit 7,a + ret z +; if simulating button presses + ld a,[hJoyHeld] ; current joypad state + ld b,a + ld a,[wcd3b] ; bit mask for button presses that override simulated ones + and b + ret nz ; return if the simulated button presses are overridden + ld hl,wcd38 ; index of current simulated button press + dec [hl] + ld a,[hl] + cp a,$ff + jr z,.doneSimulating ; if the end of the simulated button presses has been reached + ld hl,wccd3 ; base address of simulated button presses +; add offset to base address + add l + ld l,a + jr nc,.noCarry + inc h +.noCarry + ld a,[hl] + ld [hJoyHeld],a ; store simulated button press in joypad state + and a + ret nz + ld [hJoyPressed],a + ld [hJoyReleased],a + ret +; if done simulating button presses +.doneSimulating + xor a + ld [wcd3a],a + ld [wcd38],a + ld [wccd3],a + ld [wJoyIgnore],a + ld [hJoyHeld],a + ld hl,wd736 + ld a,[hl] + and a,$f8 + ld [hl],a + ld hl,wd730 + res 7,[hl] + ret + +; function to check the tile ahead to determine if the character should get on land or keep surfing +; sets carry if there is a collision and clears carry otherwise +; It seems that this function has a bug in it, but due to luck, it doesn't +; show up. After detecting a sprite collision, it jumps to the code that +; checks if the next tile is passable instead of just directly jumping to the +; "collision detected" code. However, it doesn't store the next tile in c, +; so the old value of c is used. 2429 is always called before this function, +; and 2429 always sets c to 0xF0. There is no 0xF0 background tile, so it +; is considered impassable and it is detected as a collision. +CollisionCheckOnWater:: ; 0fb7 (0:0fb7) + ld a,[wd730] + bit 7,a + jp nz,.noCollision ; return and clear carry if button presses are being simulated + ld a,[wd52a] ; the direction that the player is trying to go in + ld d,a + ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) + and d ; check if a sprite is in the direction the player is trying to go + jr nz,.checkIfNextTileIsPassable ; bug? + ld hl,TilePairCollisionsWater + call CheckForJumpingAndTilePairCollisions + jr c,.collision + ld a,$35 + call Predef ; get tile in front of player (puts it in c and [wcfc6]) + ld a,[wcfc6] ; tile in front of player + cp a,$14 ; water tile + jr z,.noCollision ; keep surfing if it's a water tile + cp a,$32 ; either the left tile of the S.S. Anne boarding platform or the tile on eastern coastlines (depending on the current tileset) + jr z,.checkIfVermilionDockTileset + cp a,$48 ; tile on right on coast lines in Safari Zone + jr z,.noCollision ; keep surfing +; check if the [land] tile in front of the player is passable +.checkIfNextTileIsPassable + ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles + ld a,[hli] + ld h,[hl] + ld l,a +.loop + ld a,[hli] + cp a,$ff + jr z,.collision + cp c + jr z,.stopSurfing ; stop surfing if the tile is passable + jr .loop +.collision + ld a,[wc02a] + cp a,(SFX_02_5b - SFX_Headers_02) / 3 ; check if collision sound is already playing + jr z,.setCarry + ld a,(SFX_02_5b - SFX_Headers_02) / 3 + call PlaySound ; play collision sound (if it's not already playing) +.setCarry + scf + jr .done +.noCollision + and a +.done + ret +.stopSurfing + xor a + ld [wd700],a + call LoadPlayerSpriteGraphics + call Func_2307 + jr .noCollision +.checkIfVermilionDockTileset + ld a, [W_CURMAPTILESET] ; tileset + cp SHIP_PORT ; Vermilion Dock tileset + jr nz, .noCollision ; keep surfing if it's not the boarding platform tile + jr .stopSurfing ; if it is the boarding platform tile, stop surfing + +; function to run the current map's script +RunMapScript:: ; 101b (0:101b) + push hl + push de + push bc + callba Func_f225 ; check if the player is pushing a boulder + ld a,[wFlags_0xcd60] + bit 1,a ; is the player pushing a boulder? + jr z,.afterBoulderEffect + callba Func_f2b5 ; displays dust effect when pushing a boulder +.afterBoulderEffect + pop bc + pop de + pop hl + call Func_310e + ld a,[W_CURMAP] ; current map number + call SwitchToMapRomBank ; change to the ROM bank the map's data is in + ld hl,W_MAPSCRIPTPTR + ld a,[hli] + ld h,[hl] + ld l,a + ld de,.return + push de + jp [hl] ; jump to script +.return + ret + +LoadWalkingPlayerSpriteGraphics:: ; 104d (0:104d) + ld de,RedSprite ; $4180 + ld hl,vNPCSprites + jr LoadPlayerSpriteGraphicsCommon + +LoadSurfingPlayerSpriteGraphics:: ; 1055 (0:1055) + ld de,SeelSprite + ld hl,vNPCSprites + jr LoadPlayerSpriteGraphicsCommon + +LoadBikePlayerSpriteGraphics:: ; 105d (0:105d) + ld de,RedCyclingSprite + ld hl,vNPCSprites + +LoadPlayerSpriteGraphicsCommon:: ; 1063 (0:1063) + push de + push hl + ld bc,(BANK(RedSprite) << 8) + $0c + call CopyVideoData + pop hl + pop de + ld a,$c0 + add e + ld e,a + jr nc,.noCarry + inc d +.noCarry + set 3,h + ld bc,$050c + jp CopyVideoData + +; function to load data from the map header +LoadMapHeader:: ; 107c (0:107c) + callba Func_f113 + ld a,[W_CURMAPTILESET] + ld [wd119],a + ld a,[W_CURMAP] + call SwitchToMapRomBank + ld a,[W_CURMAPTILESET] + ld b,a + res 7,a + ld [W_CURMAPTILESET],a + ld [$ff8b],a + bit 7,b + ret nz + ld hl,MapHeaderPointers + ld a,[W_CURMAP] + sla a + jr nc,.noCarry1 + inc h +.noCarry1 + add l + ld l,a + jr nc,.noCarry2 + inc h +.noCarry2 + ld a,[hli] + ld h,[hl] + ld l,a ; hl = base of map header +; copy the first 10 bytes (the fixed area) of the map data to D367-D370 + ld de,W_CURMAPTILESET + ld c,$0a +.copyFixedHeaderLoop + ld a,[hli] + ld [de],a + inc de + dec c + jr nz,.copyFixedHeaderLoop +; initialize all the connected maps to disabled at first, before loading the actual values + ld a,$ff + ld [W_MAPCONN1PTR],a + ld [W_MAPCONN2PTR],a + ld [W_MAPCONN3PTR],a + ld [W_MAPCONN4PTR],a +; copy connection data (if any) to WRAM + ld a,[W_MAPCONNECTIONS] + ld b,a +.checkNorth + bit 3,b + jr z,.checkSouth + ld de,W_MAPCONN1PTR + call CopyMapConnectionHeader +.checkSouth + bit 2,b + jr z,.checkWest + ld de,W_MAPCONN2PTR + call CopyMapConnectionHeader +.checkWest + bit 1,b + jr z,.checkEast + ld de,W_MAPCONN3PTR + call CopyMapConnectionHeader +.checkEast + bit 0,b + jr z,.getObjectDataPointer + ld de,W_MAPCONN4PTR + call CopyMapConnectionHeader +.getObjectDataPointer + ld a,[hli] + ld [wd3a9],a + ld a,[hli] + ld [wd3aa],a + push hl + ld a,[wd3a9] + ld l,a + ld a,[wd3aa] + ld h,a ; hl = base of object data + ld de,wd3ad ; background tile ID + ld a,[hli] + ld [de],a ; save background tile ID +.loadWarpData + ld a,[hli] ; number of warps + ld [wd3ae],a ; save the number of warps + and a ; are there any warps? + jr z,.loadSignData ; if not, skip this + ld c,a + ld de,wd3af ; base address of warps +.warpLoop ; one warp per loop iteration + ld b,$04 +.warpInnerLoop + ld a,[hli] + ld [de],a + inc de + dec b + jr nz,.warpInnerLoop + dec c + jr nz,.warpLoop +.loadSignData + ld a,[hli] ; number of signs + ld [wd4b0],a ; save the number of signs + and a ; are there any signs? + jr z,.loadSpriteData ; if not, skip this + ld c,a + ld de,wd4d1 ; base address of sign text IDs + ld a,d + ld [$ff95],a + ld a,e + ld [$ff96],a + ld de,wd4b1 ; base address of sign coordinates +.signLoop + ld a,[hli] + ld [de],a + inc de + ld a,[hli] + ld [de],a + inc de + push de + ld a,[$ff95] + ld d,a + ld a,[$ff96] + ld e,a + ld a,[hli] + ld [de],a + inc de + ld a,d + ld [$ff95],a + ld a,e + ld [$ff96],a + pop de + dec c + jr nz,.signLoop +.loadSpriteData + ld a,[wd72e] + bit 5,a ; did a battle happen immediately before this? + jp nz,.finishUp ; if so, skip this because battles don't destroy this data + ld a,[hli] + ld [W_NUMSPRITES],a ; save the number of sprites + push hl +; zero C110-C1FF and C210-C2FF + ld hl,wSpriteStateData1 + $10 + ld de,wSpriteStateData2 + $10 + xor a + ld b,$f0 +.zeroSpriteDataLoop + ld [hli],a + ld [de],a + inc e + dec b + jr nz,.zeroSpriteDataLoop +; initialize all C100-C1FF sprite entries to disabled (other than player's) + ld hl,wSpriteStateData1 + $12 + ld de,$0010 + ld c,$0f +.disableSpriteEntriesLoop + ld [hl],$ff + add hl,de + dec c + jr nz,.disableSpriteEntriesLoop + pop hl + ld de,wSpriteStateData1 + $10 + ld a,[W_NUMSPRITES] ; number of sprites + and a ; are there any sprites? + jp z,.finishUp ; if there are no sprites, skip the rest + ld b,a + ld c,$00 +.loadSpriteLoop + ld a,[hli] + ld [de],a ; store picture ID at C1X0 + inc d + ld a,$04 + add e + ld e,a + ld a,[hli] + ld [de],a ; store Y position at C2X4 + inc e + ld a,[hli] + ld [de],a ; store X position at C2X5 + inc e + ld a,[hli] + ld [de],a ; store movement byte 1 at C2X6 + ld a,[hli] + ld [$ff8d],a ; save movement byte 2 + ld a,[hli] + ld [$ff8e],a ; save text ID and flags byte + push bc + push hl + ld b,$00 + ld hl,W_MAPSPRITEDATA + add hl,bc + ld a,[$ff8d] + ld [hli],a ; store movement byte 2 in byte 0 of sprite entry + ld a,[$ff8e] + ld [hl],a ; this appears pointless, since the value is overwritten immediately after + ld a,[$ff8e] + ld [$ff8d],a + and a,$3f + ld [hl],a ; store text ID in byte 1 of sprite entry + pop hl + ld a,[$ff8d] + bit 6,a + jr nz,.trainerSprite + bit 7,a + jr nz,.itemBallSprite + jr .regularSprite +.trainerSprite + ld a,[hli] + ld [$ff8d],a ; save trainer class + ld a,[hli] + ld [$ff8e],a ; save trainer number (within class) + push hl + ld hl,W_MAPSPRITEEXTRADATA + add hl,bc + ld a,[$ff8d] + ld [hli],a ; store trainer class in byte 0 of the entry + ld a,[$ff8e] + ld [hl],a ; store trainer number in byte 1 of the entry + pop hl + jr .nextSprite +.itemBallSprite + ld a,[hli] + ld [$ff8d],a ; save item number + push hl + ld hl,W_MAPSPRITEEXTRADATA + add hl,bc + ld a,[$ff8d] + ld [hli],a ; store item number in byte 0 of the entry + xor a + ld [hl],a ; zero byte 1, since it is not used + pop hl + jr .nextSprite +.regularSprite + push hl + ld hl,W_MAPSPRITEEXTRADATA + add hl,bc +; zero both bytes, since regular sprites don't use this extra space + xor a + ld [hli],a + ld [hl],a + pop hl +.nextSprite + pop bc + dec d + ld a,$0a + add e + ld e,a + inc c + inc c + dec b + jp nz,.loadSpriteLoop +.finishUp + ld a,$19 + call Predef ; load tileset data + callab LoadWildData ; load wild pokemon data + pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) + ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks + add a ; double it + ld [wd524],a ; store map height in 2x2 tile blocks + ld a,[W_CURMAPWIDTH] ; map width in 4x4 tile blocks + add a ; double it + ld [wd525],a ; map width in 2x2 tile blocks + ld a,[W_CURMAP] + ld c,a + ld b,$00 + ld a,[H_LOADEDROMBANK] + push af + ld a, BANK(MapSongBanks) + ld [H_LOADEDROMBANK],a + ld [$2000],a + ld hl, MapSongBanks + add hl,bc + add hl,bc + ld a,[hli] + ld [wd35b],a ; music 1 + ld a,[hl] + ld [wd35c],a ; music 2 + pop af + ld [H_LOADEDROMBANK],a + ld [$2000],a + ret + +; function to copy map connection data from ROM to WRAM +; Input: hl = source, de = destination +CopyMapConnectionHeader:: ; 1238 (0:1238) + ld c,$0b +.loop + ld a,[hli] + ld [de],a + inc de + dec c + jr nz,.loop + ret + +; function to load map data +LoadMapData:: ; 1241 (0:1241) + ld a,[H_LOADEDROMBANK] + push af + call DisableLCD + ld a,$98 + ld [wd527],a + xor a + ld [wd526],a + ld [$ffaf],a + ld [$ffae],a + ld [wWalkCounter],a + ld [wd119],a + ld [wd11a],a + ld [W_SPRITESETID],a + call LoadTextBoxTilePatterns + call LoadMapHeader + callba InitMapSprites ; load tile pattern data for sprites + call LoadTileBlockMap + call LoadTilesetTilePatternData + call LoadCurrentMapView +; copy current map view to VRAM + ld hl,wTileMap + ld de,vBGMap0 + ld b,18 +.vramCopyLoop + ld c,20 +.vramCopyInnerLoop + ld a,[hli] + ld [de],a + inc e + dec c + jr nz,.vramCopyInnerLoop + ld a,32 - 20 + add e + ld e,a + jr nc,.noCarry + inc d +.noCarry + dec b + jr nz,.vramCopyLoop + ld a,$01 + ld [wcfcb],a + call EnableLCD + ld b,$09 + call GoPAL_SET + call LoadPlayerSpriteGraphics + ld a,[wd732] + and a,$18 ; did the player fly or teleport in? + jr nz,.restoreRomBank + ld a,[W_FLAGS_D733] + bit 1,a + jr nz,.restoreRomBank + call Func_235f ; music related + call Func_2312 ; music related +.restoreRomBank + pop af + ld [H_LOADEDROMBANK],a + ld [$2000],a + ret + +; function to switch to the ROM bank that a map is stored in +; Input: a = map number +SwitchToMapRomBank:: ; 12bc (0:12bc) + push hl + push bc + ld c,a + ld b,$00 + ld a,Bank(MapHeaderBanks) + call BankswitchHome ; switch to ROM bank 3 + ld hl,MapHeaderBanks + add hl,bc + ld a,[hl] + ld [$ffe8],a ; save map ROM bank + call BankswitchBack + ld a,[$ffe8] + ld [H_LOADEDROMBANK],a + ld [$2000],a ; switch to map ROM bank + pop bc + pop hl + ret + +Func_12da:: ; 12da (0:12da) + ld a, $1e + ld [wd13a], a + ld hl, wd730 + ld a, [hl] + or $26 + ld [hl], a + ret + +Func_12e7:: ; 12e7 (0:12e7) + ld hl, wd728 + res 0, [hl] + ret + +ForceBikeOrSurf:: ; 12ed (0:12ed) + ld b, BANK(RedSprite) + ld hl, LoadPlayerSpriteGraphics + call Bankswitch + jp Func_2307 ; update map/player state? -- cgit v1.3.1-sl0p From 6d64c3e01d43819b7e5628ee3ecc3a1cae529b05 Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 30 May 2014 19:52:24 -0700 Subject: Split the text engine out of home.asm. --- home.asm | 738 +--------------------------------------------------------- home/text.asm | 738 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 739 insertions(+), 737 deletions(-) create mode 100644 home/text.asm (limited to 'home') diff --git a/home.asm b/home.asm index 4dcb8c82..1e14740f 100644 --- a/home.asm +++ b/home.asm @@ -1165,744 +1165,8 @@ ClearScreen:: jp Delay3 -TextBoxBorder:: -; Draw a cxb text box at hl. +INCLUDE "home/text.asm" - ; top row - push hl - ld a, "┌" - ld [hli], a - inc a ; ─ - call NPlaceChar - inc a ; ┐ - ld [hl], a - pop hl - - ld de, 20 - add hl, de - - ; middle rows -.next - push hl - ld a, "│" - ld [hli],a - ld a, " " - call NPlaceChar - ld [hl], "│" - pop hl - - ld de, 20 - add hl, de - dec b - jr nz, .next - - ; bottom row - ld a, "└" - ld [hli], a - ld a, "─" - call NPlaceChar - ld [hl], "┘" - ret - -NPlaceChar:: -; Place char a c times. - ld d, c -.loop - ld [hli], a - dec d - jr nz, .loop - ret - -PlaceString:: ; 1955 (0:1955) - push hl -PlaceNextChar:: ; 1956 (0:1956) - ld a,[de] - - cp "@" - jr nz,.PlaceText - ld b,h - ld c,l - pop hl - ret - -.PlaceText - cp $4E - jr nz,.next - ld bc,$0028 - ld a,[$FFF6] - bit 2,a - jr z,.next2 - ld bc,$14 -.next2 - pop hl - add hl,bc - push hl - jp Next19E8 - -.next - cp $4F - jr nz,.next3 - pop hl - FuncCoord 1, 16 - ld hl,Coord - push hl - jp Next19E8 - -.next3 ; Check against a dictionary - and a - jp z,Char00 - cp $4C - jp z,Char4C - cp $4B - jp z,Char4B - cp $51 - jp z,Char51 - cp $49 - jp z,Char49 - cp $52 - jp z,Char52 - cp $53 - jp z,Char53 - cp $54 - jp z,Char54 - cp $5B - jp z,Char5B - cp $5E - jp z,Char5E - cp $5C - jp z,Char5C - cp $5D - jp z,Char5D - cp $55 - jp z,Char55 - cp $56 - jp z,Char56 - cp $57 - jp z,Char57 - cp $58 - jp z,Char58 - cp $4A - jp z,Char4A - cp $5F - jp z,Char5F - cp $59 - jp z,Char59 - cp $5A - jp z,Char5A - ld [hli],a - call PrintLetterDelay -Next19E8:: ; 19e8 (0:19e8) - inc de - jp PlaceNextChar - -Char00:: ; 19ec (0:19ec) - ld b,h - ld c,l - pop hl - ld de,Char00Text - dec de - ret - -Char00Text:: ; 0x19f4 “%d ERROR.” - TX_FAR _Char00Text - db "@" - -Char52:: ; 0x19f9 player’s name - push de - ld de,W_PLAYERNAME - jr FinishDTE - -Char53:: ; 19ff (0:19ff) ; rival’s name - push de - ld de,W_RIVALNAME - jr FinishDTE - -Char5D:: ; 1a05 (0:1a05) ; TRAINER - push de - ld de,Char5DText - jr FinishDTE - -Char5C:: ; 1a0b (0:1a0b) ; TM - push de - ld de,Char5CText - jr FinishDTE - -Char5B:: ; 1a11 (0:1a11) ; PC - push de - ld de,Char5BText - jr FinishDTE - -Char5E:: ; 1a17 (0:1a17) ; ROCKET - push de - ld de,Char5EText - jr FinishDTE - -Char54:: ; 1a1d (0:1a1d) ; POKé - push de - ld de,Char54Text - jr FinishDTE - -Char56:: ; 1a23 (0:1a23) ; …… - push de - ld de,Char56Text - jr FinishDTE - -Char4A:: ; 1a29 (0:1a29) ; PKMN - push de - ld de,Char4AText - jr FinishDTE - -Char59:: ; 1a2f (0:1a2f) -; depending on whose turn it is, print -; enemy active monster’s name, prefixed with “Enemy ” -; or -; player active monster’s name -; (like Char5A but flipped) - ld a,[H_WHOSETURN] - xor 1 - jr MonsterNameCharsCommon - -Char5A:: ; 1a35 (0:1a35) -; depending on whose turn it is, print -; player active monster’s name -; or -; enemy active monster’s name, prefixed with “Enemy ” - ld a,[H_WHOSETURN] -MonsterNameCharsCommon:: ; 1a37 (0:1a37) - push de - and a - jr nz,.Enemy - ld de,W_PLAYERMONNAME ; player active monster name - jr FinishDTE - -.Enemy ; 1A40 - ; print “Enemy ” - ld de,Char5AText - call PlaceString - - ld h,b - ld l,c - ld de,W_ENEMYMONNAME ; enemy active monster name - -FinishDTE:: ; 1a4b (0:1a4b) - call PlaceString - ld h,b - ld l,c - pop de - inc de - jp PlaceNextChar - -Char5CText:: ; 1a55 (0:1a55) - db "TM@" -Char5DText:: ; 1a58 (0:1a58) - db "TRAINER@" -Char5BText:: ; 1a60 (0:1a60) - db "PC@" -Char5EText:: ; 1a63 (0:1a63) - db "ROCKET@" -Char54Text:: ; 1a6a (0:1a6a) - db "POKé@" -Char56Text:: ; 1a6f (0:1a6f) - db "……@" -Char5AText:: ; 1a72 (0:1a72) - db "Enemy @" -Char4AText:: ; 1a79 (0:1a79) - db $E1,$E2,"@" ; PKMN - -Char55:: ; 1a7c (0:1a7c) - push de - ld b,h - ld c,l - ld hl,Char55Text - call TextCommandProcessor - ld h,b - ld l,c - pop de - inc de - jp PlaceNextChar - -Char55Text:: ; 1a8c (0:1a8c) -; equivalent to Char4B - TX_FAR _Char55Text - db "@" - -Char5F:: ; 1a91 (0:1a91) -; ends a Pokédex entry - ld [hl],"." - pop hl - ret - -Char58:: ; 1a95 (0:1a95) - ld a,[W_ISLINKBATTLE] - cp 4 - jp z,Next1AA2 - ld a,$EE - FuncCoord 18, 16 - ld [Coord],a -Next1AA2:: ; 1aa2 (0:1aa2) - call ProtectedDelay3 - call ManualTextScroll - ld a,$7F - FuncCoord 18, 16 - ld [Coord],a -Char57:: ; 1aad (0:1aad) - pop hl - ld de,Char58Text - dec de - ret - -Char58Text:: ; 1ab3 (0:1ab3) - db "@" - -Char51:: ; 1ab4 (0:1ab4) - push de - ld a,$EE - FuncCoord 18, 16 - ld [Coord],a - call ProtectedDelay3 - call ManualTextScroll - FuncCoord 1, 13 - ld hl,Coord - ld bc,$0412 - call ClearScreenArea - ld c,$14 - call DelayFrames - pop de - FuncCoord 1, 14 - ld hl,Coord - jp Next19E8 - -Char49:: ; 1ad5 (0:1ad5) - push de - ld a,$EE - FuncCoord 18, 16 - ld [Coord],a - call ProtectedDelay3 - call ManualTextScroll - FuncCoord 1, 10 - ld hl,Coord - ld bc,$0712 - call ClearScreenArea - ld c,$14 - call DelayFrames - pop de - pop hl - FuncCoord 1, 11 - ld hl,Coord - push hl - jp Next19E8 - -Char4B:: ; 1af8 (0:1af8) - ld a,$EE - FuncCoord 18, 16 - ld [Coord],a - call ProtectedDelay3 - push de - call ManualTextScroll - pop de - ld a,$7F - FuncCoord 18, 16 - ld [Coord],a - ;fall through -Char4C:: ; 1b0a (0:1b0a) - push de - call Next1B18 - call Next1B18 - FuncCoord 1, 16 - ld hl,Coord - pop de - jp Next19E8 - -Next1B18:: ; 1b18 (0:1b18) - FuncCoord 0, 14 - ld hl,Coord - FuncCoord 0, 13 - ld de,Coord - ld b,$3C -.next - ld a,[hli] - ld [de],a - inc de - dec b - jr nz,.next - FuncCoord 1, 16 - ld hl,Coord - ld a,$7F - ld b,$12 -.next2 - ld [hli],a - dec b - jr nz,.next2 - - ; wait five frames - ld b,5 -.WaitFrame - call DelayFrame - dec b - jr nz,.WaitFrame - - ret - -ProtectedDelay3:: ; 1b3a (0:1b3a) - push bc - call Delay3 - pop bc - ret - -TextCommandProcessor:: ; 1b40 (0:1b40) - ld a,[wd358] - push af - set 1,a - ld e,a - ld a,[$fff4] - xor e - ld [wd358],a - ld a,c - ld [wcc3a],a - ld a,b - ld [wcc3b],a - -NextTextCommand:: ; 1b55 (0:1b55) - ld a,[hli] - cp a, "@" ; terminator - jr nz,.doTextCommand - pop af - ld [wd358],a - ret -.doTextCommand - push hl - cp a,$17 - jp z,TextCommand17 - cp a,$0e - jp nc,TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB -; if a < 0xE, use a jump table - ld hl,TextCommandJumpTable - push bc - add a - ld b,$00 - ld c,a - add hl,bc - pop bc - ld a,[hli] - ld h,[hl] - ld l,a - jp [hl] - -; draw box -; 04AAAABBCC -; AAAA = address of upper left corner -; BB = height -; CC = width -TextCommand04:: ; 1b78 (0:1b78) - pop hl - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - ld a,[hli] - ld b,a - ld a,[hli] - ld c,a - push hl - ld h,d - ld l,e - call TextBoxBorder - pop hl - jr NextTextCommand - -; place string inline -; 00{string} -TextCommand00:: ; 1b8a (0:1b8a) - pop hl - ld d,h - ld e,l - ld h,b - ld l,c - call PlaceString - ld h,d - ld l,e - inc hl - jr NextTextCommand - -; place string from RAM -; 01AAAA -; AAAA = address of string -TextCommand01:: ; 1b97 (0:1b97) - pop hl - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - push hl - ld h,b - ld l,c - call PlaceString - pop hl - jr NextTextCommand - -; print BCD number -; 02AAAABB -; AAAA = address of BCD number -; BB -; bits 0-4 = length in bytes -; bits 5-7 = unknown flags -TextCommand02:: ; 1ba5 (0:1ba5) - pop hl - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - ld a,[hli] - push hl - ld h,b - ld l,c - ld c,a - call PrintBCDNumber - ld b,h - ld c,l - pop hl - jr NextTextCommand - -; repoint destination address -; 03AAAA -; AAAA = new destination address -TextCommand03:: ; 1bb7 (0:1bb7) - pop hl - ld a,[hli] - ld [wcc3a],a - ld c,a - ld a,[hli] - ld [wcc3b],a - ld b,a - jp NextTextCommand - -; repoint destination to second line of dialogue text box -; 05 -; (no arguments) -TextCommand05:: ; 1bc5 (0:1bc5) - pop hl - FuncCoord 1, 16 - ld bc,Coord ; address of second line of dialogue text box - jp NextTextCommand - -; blink arrow and wait for A or B to be pressed -; 06 -; (no arguments) -TextCommand06:: ; 1bcc (0:1bcc) - ld a,[W_ISLINKBATTLE] - cp a,$04 - jp z,TextCommand0D - ld a,$ee ; down arrow - FuncCoord 18, 16 - ld [Coord],a ; place down arrow in lower right corner of dialogue text box - push bc - call ManualTextScroll ; blink arrow and wait for A or B to be pressed - pop bc - ld a," " - FuncCoord 18, 16 - ld [Coord],a ; overwrite down arrow with blank space - pop hl - jp NextTextCommand - -; scroll text up one line -; 07 -; (no arguments) -TextCommand07:: ; 1be7 (0:1be7) - ld a," " - FuncCoord 18, 16 - ld [Coord],a ; place blank space in lower right corner of dialogue text box - call Next1B18 ; scroll up text - call Next1B18 - pop hl - FuncCoord 1, 16 - ld bc,Coord ; address of second line of dialogue text box - jp NextTextCommand - -; execute asm inline -; 08{code} -TextCommand08:: ; 1bf9 (0:1bf9) - pop hl - ld de,NextTextCommand - push de ; return address - jp [hl] - -; print decimal number (converted from binary number) -; 09AAAABB -; AAAA = address of number -; BB -; bits 0-3 = how many digits to display -; bits 4-7 = how long the number is in bytes -TextCommand09:: ; 1bff (0:1bff) - pop hl - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - ld a,[hli] - push hl - ld h,b - ld l,c - ld b,a - and a,$0f - ld c,a - ld a,b - and a,$f0 - swap a - set 6,a - ld b,a - call PrintNumber - ld b,h - ld c,l - pop hl - jp NextTextCommand - -; wait half a second if the user doesn't hold A or B -; 0A -; (no arguments) -TextCommand0A:: ; 1c1d (0:1c1d) - push bc - call Joypad - ld a,[hJoyHeld] - and a,%00000011 ; A and B buttons - jr nz,.skipDelay - ld c,30 - call DelayFrames -.skipDelay - pop bc - pop hl - jp NextTextCommand - -; plays sounds -; this actually handles various command ID's, not just 0B -; (no arguments) -TextCommand0B:: ; 1c31 (0:1c31) - pop hl - push bc - dec hl - ld a,[hli] - ld b,a ; b = command number that got us here - push hl - ld hl,TextCommandSounds -.loop - ld a,[hli] - cp b - jr z,.matchFound - inc hl - jr .loop -.matchFound - cp a,$14 - jr z,.pokemonCry - cp a,$15 - jr z,.pokemonCry - cp a,$16 - jr z,.pokemonCry - ld a,[hl] - call PlaySound - call WaitForSoundToFinish - pop hl - pop bc - jp NextTextCommand -.pokemonCry - push de - ld a,[hl] - call PlayCry - pop de - pop hl - pop bc - jp NextTextCommand - -; format: text command ID, sound ID or cry ID -TextCommandSounds:: ; 1c64 (0:1c64) - db $0B,(SFX_02_3a - SFX_Headers_02) / 3 - db $12,(SFX_02_46 - SFX_Headers_02) / 3 - db $0E,(SFX_02_41 - SFX_Headers_02) / 3 - db $0F,(SFX_02_3a - SFX_Headers_02) / 3 - db $10,(SFX_02_3b - SFX_Headers_02) / 3 - db $11,(SFX_02_42 - SFX_Headers_02) / 3 - db $13,(SFX_02_44 - SFX_Headers_02) / 3 - db $14,NIDORINA ; used in OakSpeech - db $15,PIDGEOT ; used in SaffronCityText12 - db $16,DEWGONG ; unused? - -; draw ellipses -; 0CAA -; AA = number of ellipses to draw -TextCommand0C:: ; 1c78 (0:1c78) - pop hl - ld a,[hli] - ld d,a - push hl - ld h,b - ld l,c -.loop - ld a,$75 ; ellipsis - ld [hli],a - push de - call Joypad - pop de - ld a,[hJoyHeld] ; joypad state - and a,%00000011 ; is A or B button pressed? - jr nz,.skipDelay ; if so, skip the delay - ld c,10 - call DelayFrames -.skipDelay - dec d - jr nz,.loop - ld b,h - ld c,l - pop hl - jp NextTextCommand - -; wait for A or B to be pressed -; 0D -; (no arguments) -TextCommand0D:: ; 1c9a (0:1c9a) - push bc - call ManualTextScroll ; wait for A or B to be pressed - pop bc - pop hl - jp NextTextCommand - -; process text commands in another ROM bank -; 17AAAABB -; AAAA = address of text commands -; BB = bank -TextCommand17:: ; 1ca3 (0:1ca3) - pop hl - ld a,[H_LOADEDROMBANK] - push af - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - ld a,[hli] - ld [H_LOADEDROMBANK],a - ld [$2000],a - push hl - ld l,e - ld h,d - call TextCommandProcessor - pop hl - pop af - ld [H_LOADEDROMBANK],a - ld [$2000],a - jp NextTextCommand - -TextCommandJumpTable:: ; 1cc1 (0:1cc1) - dw TextCommand00 - dw TextCommand01 - dw TextCommand02 - dw TextCommand03 - dw TextCommand04 - dw TextCommand05 - dw TextCommand06 - dw TextCommand07 - dw TextCommand08 - dw TextCommand09 - dw TextCommand0A - dw TextCommand0B - dw TextCommand0C - dw TextCommand0D ; this function seems to be used only once ; it store the address of a row and column of the VRAM background map in hl diff --git a/home/text.asm b/home/text.asm new file mode 100644 index 00000000..7d8ea61b --- /dev/null +++ b/home/text.asm @@ -0,0 +1,738 @@ +TextBoxBorder:: +; Draw a cxb text box at hl. + + ; top row + push hl + ld a, "┌" + ld [hli], a + inc a ; ─ + call NPlaceChar + inc a ; ┐ + ld [hl], a + pop hl + + ld de, 20 + add hl, de + + ; middle rows +.next + push hl + ld a, "│" + ld [hli],a + ld a, " " + call NPlaceChar + ld [hl], "│" + pop hl + + ld de, 20 + add hl, de + dec b + jr nz, .next + + ; bottom row + ld a, "└" + ld [hli], a + ld a, "─" + call NPlaceChar + ld [hl], "┘" + ret + +NPlaceChar:: +; Place char a c times. + ld d, c +.loop + ld [hli], a + dec d + jr nz, .loop + ret + +PlaceString:: ; 1955 (0:1955) + push hl +PlaceNextChar:: ; 1956 (0:1956) + ld a,[de] + + cp "@" + jr nz,.PlaceText + ld b,h + ld c,l + pop hl + ret + +.PlaceText + cp $4E + jr nz,.next + ld bc,$0028 + ld a,[$FFF6] + bit 2,a + jr z,.next2 + ld bc,$14 +.next2 + pop hl + add hl,bc + push hl + jp Next19E8 + +.next + cp $4F + jr nz,.next3 + pop hl + FuncCoord 1, 16 + ld hl,Coord + push hl + jp Next19E8 + +.next3 ; Check against a dictionary + and a + jp z,Char00 + cp $4C + jp z,Char4C + cp $4B + jp z,Char4B + cp $51 + jp z,Char51 + cp $49 + jp z,Char49 + cp $52 + jp z,Char52 + cp $53 + jp z,Char53 + cp $54 + jp z,Char54 + cp $5B + jp z,Char5B + cp $5E + jp z,Char5E + cp $5C + jp z,Char5C + cp $5D + jp z,Char5D + cp $55 + jp z,Char55 + cp $56 + jp z,Char56 + cp $57 + jp z,Char57 + cp $58 + jp z,Char58 + cp $4A + jp z,Char4A + cp $5F + jp z,Char5F + cp $59 + jp z,Char59 + cp $5A + jp z,Char5A + ld [hli],a + call PrintLetterDelay +Next19E8:: ; 19e8 (0:19e8) + inc de + jp PlaceNextChar + +Char00:: ; 19ec (0:19ec) + ld b,h + ld c,l + pop hl + ld de,Char00Text + dec de + ret + +Char00Text:: ; 0x19f4 “%d ERROR.” + TX_FAR _Char00Text + db "@" + +Char52:: ; 0x19f9 player’s name + push de + ld de,W_PLAYERNAME + jr FinishDTE + +Char53:: ; 19ff (0:19ff) ; rival’s name + push de + ld de,W_RIVALNAME + jr FinishDTE + +Char5D:: ; 1a05 (0:1a05) ; TRAINER + push de + ld de,Char5DText + jr FinishDTE + +Char5C:: ; 1a0b (0:1a0b) ; TM + push de + ld de,Char5CText + jr FinishDTE + +Char5B:: ; 1a11 (0:1a11) ; PC + push de + ld de,Char5BText + jr FinishDTE + +Char5E:: ; 1a17 (0:1a17) ; ROCKET + push de + ld de,Char5EText + jr FinishDTE + +Char54:: ; 1a1d (0:1a1d) ; POKé + push de + ld de,Char54Text + jr FinishDTE + +Char56:: ; 1a23 (0:1a23) ; …… + push de + ld de,Char56Text + jr FinishDTE + +Char4A:: ; 1a29 (0:1a29) ; PKMN + push de + ld de,Char4AText + jr FinishDTE + +Char59:: ; 1a2f (0:1a2f) +; depending on whose turn it is, print +; enemy active monster’s name, prefixed with “Enemy ” +; or +; player active monster’s name +; (like Char5A but flipped) + ld a,[H_WHOSETURN] + xor 1 + jr MonsterNameCharsCommon + +Char5A:: ; 1a35 (0:1a35) +; depending on whose turn it is, print +; player active monster’s name +; or +; enemy active monster’s name, prefixed with “Enemy ” + ld a,[H_WHOSETURN] +MonsterNameCharsCommon:: ; 1a37 (0:1a37) + push de + and a + jr nz,.Enemy + ld de,W_PLAYERMONNAME ; player active monster name + jr FinishDTE + +.Enemy ; 1A40 + ; print “Enemy ” + ld de,Char5AText + call PlaceString + + ld h,b + ld l,c + ld de,W_ENEMYMONNAME ; enemy active monster name + +FinishDTE:: ; 1a4b (0:1a4b) + call PlaceString + ld h,b + ld l,c + pop de + inc de + jp PlaceNextChar + +Char5CText:: ; 1a55 (0:1a55) + db "TM@" +Char5DText:: ; 1a58 (0:1a58) + db "TRAINER@" +Char5BText:: ; 1a60 (0:1a60) + db "PC@" +Char5EText:: ; 1a63 (0:1a63) + db "ROCKET@" +Char54Text:: ; 1a6a (0:1a6a) + db "POKé@" +Char56Text:: ; 1a6f (0:1a6f) + db "……@" +Char5AText:: ; 1a72 (0:1a72) + db "Enemy @" +Char4AText:: ; 1a79 (0:1a79) + db $E1,$E2,"@" ; PKMN + +Char55:: ; 1a7c (0:1a7c) + push de + ld b,h + ld c,l + ld hl,Char55Text + call TextCommandProcessor + ld h,b + ld l,c + pop de + inc de + jp PlaceNextChar + +Char55Text:: ; 1a8c (0:1a8c) +; equivalent to Char4B + TX_FAR _Char55Text + db "@" + +Char5F:: ; 1a91 (0:1a91) +; ends a Pokédex entry + ld [hl],"." + pop hl + ret + +Char58:: ; 1a95 (0:1a95) + ld a,[W_ISLINKBATTLE] + cp 4 + jp z,Next1AA2 + ld a,$EE + FuncCoord 18, 16 + ld [Coord],a +Next1AA2:: ; 1aa2 (0:1aa2) + call ProtectedDelay3 + call ManualTextScroll + ld a,$7F + FuncCoord 18, 16 + ld [Coord],a +Char57:: ; 1aad (0:1aad) + pop hl + ld de,Char58Text + dec de + ret + +Char58Text:: ; 1ab3 (0:1ab3) + db "@" + +Char51:: ; 1ab4 (0:1ab4) + push de + ld a,$EE + FuncCoord 18, 16 + ld [Coord],a + call ProtectedDelay3 + call ManualTextScroll + FuncCoord 1, 13 + ld hl,Coord + ld bc,$0412 + call ClearScreenArea + ld c,$14 + call DelayFrames + pop de + FuncCoord 1, 14 + ld hl,Coord + jp Next19E8 + +Char49:: ; 1ad5 (0:1ad5) + push de + ld a,$EE + FuncCoord 18, 16 + ld [Coord],a + call ProtectedDelay3 + call ManualTextScroll + FuncCoord 1, 10 + ld hl,Coord + ld bc,$0712 + call ClearScreenArea + ld c,$14 + call DelayFrames + pop de + pop hl + FuncCoord 1, 11 + ld hl,Coord + push hl + jp Next19E8 + +Char4B:: ; 1af8 (0:1af8) + ld a,$EE + FuncCoord 18, 16 + ld [Coord],a + call ProtectedDelay3 + push de + call ManualTextScroll + pop de + ld a,$7F + FuncCoord 18, 16 + ld [Coord],a + ;fall through +Char4C:: ; 1b0a (0:1b0a) + push de + call Next1B18 + call Next1B18 + FuncCoord 1, 16 + ld hl,Coord + pop de + jp Next19E8 + +Next1B18:: ; 1b18 (0:1b18) + FuncCoord 0, 14 + ld hl,Coord + FuncCoord 0, 13 + ld de,Coord + ld b,$3C +.next + ld a,[hli] + ld [de],a + inc de + dec b + jr nz,.next + FuncCoord 1, 16 + ld hl,Coord + ld a,$7F + ld b,$12 +.next2 + ld [hli],a + dec b + jr nz,.next2 + + ; wait five frames + ld b,5 +.WaitFrame + call DelayFrame + dec b + jr nz,.WaitFrame + + ret + +ProtectedDelay3:: ; 1b3a (0:1b3a) + push bc + call Delay3 + pop bc + ret + +TextCommandProcessor:: ; 1b40 (0:1b40) + ld a,[wd358] + push af + set 1,a + ld e,a + ld a,[$fff4] + xor e + ld [wd358],a + ld a,c + ld [wcc3a],a + ld a,b + ld [wcc3b],a + +NextTextCommand:: ; 1b55 (0:1b55) + ld a,[hli] + cp a, "@" ; terminator + jr nz,.doTextCommand + pop af + ld [wd358],a + ret +.doTextCommand + push hl + cp a,$17 + jp z,TextCommand17 + cp a,$0e + jp nc,TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB +; if a < 0xE, use a jump table + ld hl,TextCommandJumpTable + push bc + add a + ld b,$00 + ld c,a + add hl,bc + pop bc + ld a,[hli] + ld h,[hl] + ld l,a + jp [hl] + +; draw box +; 04AAAABBCC +; AAAA = address of upper left corner +; BB = height +; CC = width +TextCommand04:: ; 1b78 (0:1b78) + pop hl + ld a,[hli] + ld e,a + ld a,[hli] + ld d,a + ld a,[hli] + ld b,a + ld a,[hli] + ld c,a + push hl + ld h,d + ld l,e + call TextBoxBorder + pop hl + jr NextTextCommand + +; place string inline +; 00{string} +TextCommand00:: ; 1b8a (0:1b8a) + pop hl + ld d,h + ld e,l + ld h,b + ld l,c + call PlaceString + ld h,d + ld l,e + inc hl + jr NextTextCommand + +; place string from RAM +; 01AAAA +; AAAA = address of string +TextCommand01:: ; 1b97 (0:1b97) + pop hl + ld a,[hli] + ld e,a + ld a,[hli] + ld d,a + push hl + ld h,b + ld l,c + call PlaceString + pop hl + jr NextTextCommand + +; print BCD number +; 02AAAABB +; AAAA = address of BCD number +; BB +; bits 0-4 = length in bytes +; bits 5-7 = unknown flags +TextCommand02:: ; 1ba5 (0:1ba5) + pop hl + ld a,[hli] + ld e,a + ld a,[hli] + ld d,a + ld a,[hli] + push hl + ld h,b + ld l,c + ld c,a + call PrintBCDNumber + ld b,h + ld c,l + pop hl + jr NextTextCommand + +; repoint destination address +; 03AAAA +; AAAA = new destination address +TextCommand03:: ; 1bb7 (0:1bb7) + pop hl + ld a,[hli] + ld [wcc3a],a + ld c,a + ld a,[hli] + ld [wcc3b],a + ld b,a + jp NextTextCommand + +; repoint destination to second line of dialogue text box +; 05 +; (no arguments) +TextCommand05:: ; 1bc5 (0:1bc5) + pop hl + FuncCoord 1, 16 + ld bc,Coord ; address of second line of dialogue text box + jp NextTextCommand + +; blink arrow and wait for A or B to be pressed +; 06 +; (no arguments) +TextCommand06:: ; 1bcc (0:1bcc) + ld a,[W_ISLINKBATTLE] + cp a,$04 + jp z,TextCommand0D + ld a,$ee ; down arrow + FuncCoord 18, 16 + ld [Coord],a ; place down arrow in lower right corner of dialogue text box + push bc + call ManualTextScroll ; blink arrow and wait for A or B to be pressed + pop bc + ld a," " + FuncCoord 18, 16 + ld [Coord],a ; overwrite down arrow with blank space + pop hl + jp NextTextCommand + +; scroll text up one line +; 07 +; (no arguments) +TextCommand07:: ; 1be7 (0:1be7) + ld a," " + FuncCoord 18, 16 + ld [Coord],a ; place blank space in lower right corner of dialogue text box + call Next1B18 ; scroll up text + call Next1B18 + pop hl + FuncCoord 1, 16 + ld bc,Coord ; address of second line of dialogue text box + jp NextTextCommand + +; execute asm inline +; 08{code} +TextCommand08:: ; 1bf9 (0:1bf9) + pop hl + ld de,NextTextCommand + push de ; return address + jp [hl] + +; print decimal number (converted from binary number) +; 09AAAABB +; AAAA = address of number +; BB +; bits 0-3 = how many digits to display +; bits 4-7 = how long the number is in bytes +TextCommand09:: ; 1bff (0:1bff) + pop hl + ld a,[hli] + ld e,a + ld a,[hli] + ld d,a + ld a,[hli] + push hl + ld h,b + ld l,c + ld b,a + and a,$0f + ld c,a + ld a,b + and a,$f0 + swap a + set 6,a + ld b,a + call PrintNumber + ld b,h + ld c,l + pop hl + jp NextTextCommand + +; wait half a second if the user doesn't hold A or B +; 0A +; (no arguments) +TextCommand0A:: ; 1c1d (0:1c1d) + push bc + call Joypad + ld a,[hJoyHeld] + and a,%00000011 ; A and B buttons + jr nz,.skipDelay + ld c,30 + call DelayFrames +.skipDelay + pop bc + pop hl + jp NextTextCommand + +; plays sounds +; this actually handles various command ID's, not just 0B +; (no arguments) +TextCommand0B:: ; 1c31 (0:1c31) + pop hl + push bc + dec hl + ld a,[hli] + ld b,a ; b = command number that got us here + push hl + ld hl,TextCommandSounds +.loop + ld a,[hli] + cp b + jr z,.matchFound + inc hl + jr .loop +.matchFound + cp a,$14 + jr z,.pokemonCry + cp a,$15 + jr z,.pokemonCry + cp a,$16 + jr z,.pokemonCry + ld a,[hl] + call PlaySound + call WaitForSoundToFinish + pop hl + pop bc + jp NextTextCommand +.pokemonCry + push de + ld a,[hl] + call PlayCry + pop de + pop hl + pop bc + jp NextTextCommand + +; format: text command ID, sound ID or cry ID +TextCommandSounds:: ; 1c64 (0:1c64) + db $0B,(SFX_02_3a - SFX_Headers_02) / 3 + db $12,(SFX_02_46 - SFX_Headers_02) / 3 + db $0E,(SFX_02_41 - SFX_Headers_02) / 3 + db $0F,(SFX_02_3a - SFX_Headers_02) / 3 + db $10,(SFX_02_3b - SFX_Headers_02) / 3 + db $11,(SFX_02_42 - SFX_Headers_02) / 3 + db $13,(SFX_02_44 - SFX_Headers_02) / 3 + db $14,NIDORINA ; used in OakSpeech + db $15,PIDGEOT ; used in SaffronCityText12 + db $16,DEWGONG ; unused? + +; draw ellipses +; 0CAA +; AA = number of ellipses to draw +TextCommand0C:: ; 1c78 (0:1c78) + pop hl + ld a,[hli] + ld d,a + push hl + ld h,b + ld l,c +.loop + ld a,$75 ; ellipsis + ld [hli],a + push de + call Joypad + pop de + ld a,[hJoyHeld] ; joypad state + and a,%00000011 ; is A or B button pressed? + jr nz,.skipDelay ; if so, skip the delay + ld c,10 + call DelayFrames +.skipDelay + dec d + jr nz,.loop + ld b,h + ld c,l + pop hl + jp NextTextCommand + +; wait for A or B to be pressed +; 0D +; (no arguments) +TextCommand0D:: ; 1c9a (0:1c9a) + push bc + call ManualTextScroll ; wait for A or B to be pressed + pop bc + pop hl + jp NextTextCommand + +; process text commands in another ROM bank +; 17AAAABB +; AAAA = address of text commands +; BB = bank +TextCommand17:: ; 1ca3 (0:1ca3) + pop hl + ld a,[H_LOADEDROMBANK] + push af + ld a,[hli] + ld e,a + ld a,[hli] + ld d,a + ld a,[hli] + ld [H_LOADEDROMBANK],a + ld [$2000],a + push hl + ld l,e + ld h,d + call TextCommandProcessor + pop hl + pop af + ld [H_LOADEDROMBANK],a + ld [$2000],a + jp NextTextCommand + +TextCommandJumpTable:: ; 1cc1 (0:1cc1) + dw TextCommand00 + dw TextCommand01 + dw TextCommand02 + dw TextCommand03 + dw TextCommand04 + dw TextCommand05 + dw TextCommand06 + dw TextCommand07 + dw TextCommand08 + dw TextCommand09 + dw TextCommand0A + dw TextCommand0B + dw TextCommand0C + dw TextCommand0D -- cgit v1.3.1-sl0p From 6d8c6055b5d5910d4da6997199f0984f8cd9149f Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 31 May 2014 01:22:15 -0700 Subject: Split more code out of home.asm. --- data/collision.asm | 24 + home.asm | 2284 ++++++++-------------------------------------------- home/audio.asm | 183 +++++ home/fade.asm | 73 ++ home/init.asm | 139 ++++ home/pic.asm | 591 ++++++++++++++ home/predef.asm | 50 ++ home/vblank.asm | 105 +++ home/vcopy.asm | 450 +++++++++++ 9 files changed, 1952 insertions(+), 1947 deletions(-) create mode 100644 data/collision.asm create mode 100644 home/audio.asm create mode 100644 home/fade.asm create mode 100644 home/init.asm create mode 100644 home/pic.asm create mode 100644 home/predef.asm create mode 100644 home/vblank.asm create mode 100644 home/vcopy.asm (limited to 'home') diff --git a/data/collision.asm b/data/collision.asm new file mode 100644 index 00000000..78579242 --- /dev/null +++ b/data/collision.asm @@ -0,0 +1,24 @@ +Underground_Coll:: INCBIN "gfx/tilesets/underground.tilecoll" +Overworld_Coll:: INCBIN "gfx/tilesets/overworld.tilecoll" +RedsHouse1_Coll:: +RedsHouse2_Coll:: INCBIN "gfx/tilesets/reds_house.tilecoll" +Mart_Coll:: +Pokecenter_Coll:: INCBIN "gfx/tilesets/pokecenter.tilecoll" +Dojo_Coll:: +Gym_Coll:: INCBIN "gfx/tilesets/gym.tilecoll" +Forest_Coll:: INCBIN "gfx/tilesets/forest.tilecoll" +House_Coll:: INCBIN "gfx/tilesets/house.tilecoll" +ForestGate_Coll:: +Museum_Coll:: +Gate_Coll:: INCBIN "gfx/tilesets/gate.tilecoll" +Ship_Coll:: INCBIN "gfx/tilesets/ship.tilecoll" +ShipPort_Coll:: INCBIN "gfx/tilesets/ship_port.tilecoll" +Cemetery_Coll:: INCBIN "gfx/tilesets/cemetery.tilecoll" +Interior_Coll:: INCBIN "gfx/tilesets/interior.tilecoll" +Cavern_Coll:: INCBIN "gfx/tilesets/cavern.tilecoll" +Lobby_Coll:: INCBIN "gfx/tilesets/lobby.tilecoll" +Mansion_Coll:: INCBIN "gfx/tilesets/mansion.tilecoll" +Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll" +Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll" +Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll" +Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll" diff --git a/home.asm b/home.asm index dd2433ad..e3d4309b 100644 --- a/home.asm +++ b/home.asm @@ -909,30 +909,7 @@ InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea) jp CopyVideoData -Underground_Coll:: INCBIN "gfx/tilesets/underground.tilecoll" -Overworld_Coll:: INCBIN "gfx/tilesets/overworld.tilecoll" -RedsHouse1_Coll:: -RedsHouse2_Coll:: INCBIN "gfx/tilesets/reds_house.tilecoll" -Mart_Coll:: -Pokecenter_Coll:: INCBIN "gfx/tilesets/pokecenter.tilecoll" -Dojo_Coll:: -Gym_Coll:: INCBIN "gfx/tilesets/gym.tilecoll" -Forest_Coll:: INCBIN "gfx/tilesets/forest.tilecoll" -House_Coll:: INCBIN "gfx/tilesets/house.tilecoll" -ForestGate_Coll:: -Museum_Coll:: -Gate_Coll:: INCBIN "gfx/tilesets/gate.tilecoll" -Ship_Coll:: INCBIN "gfx/tilesets/ship.tilecoll" -ShipPort_Coll:: INCBIN "gfx/tilesets/ship_port.tilecoll" -Cemetery_Coll:: INCBIN "gfx/tilesets/cemetery.tilecoll" -Interior_Coll:: INCBIN "gfx/tilesets/interior.tilecoll" -Cavern_Coll:: INCBIN "gfx/tilesets/cavern.tilecoll" -Lobby_Coll:: INCBIN "gfx/tilesets/lobby.tilecoll" -Mansion_Coll:: INCBIN "gfx/tilesets/mansion.tilecoll" -Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll" -Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll" -Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll" -Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll" +INCLUDE "data/collision.asm" FarCopyData2:: @@ -1166,1918 +1143,380 @@ ClearScreen:: INCLUDE "home/text.asm" +INCLUDE "home/vcopy.asm" +INCLUDE "home/init.asm" +INCLUDE "home/vblank.asm" +INCLUDE "home/fade.asm" -; this function seems to be used only once -; it store the address of a row and column of the VRAM background map in hl -; INPUT: h - row, l - column, b - high byte of background tile map address in VRAM -GetRowColAddressBgMap:: ; 1cdd (0:1cdd) - xor a - srl h - rr a - srl h - rr a - srl h - rr a - or l - ld l,a - ld a,b - or h - ld h,a - ret - -; clears a VRAM background map with blank space tiles -; INPUT: h - high byte of background tile map address in VRAM -ClearBgMap:: ; 1cf0 (0:1cf0) - ld a," " - jr .next - ld a,l -.next - ld de,$400 ; size of VRAM background map - ld l,e -.loop - ld [hli],a - dec e - jr nz,.loop - dec d - jr nz,.loop - ret - -; When the player takes a step, a row or column of 2x2 tile blocks at the edge -; of the screen toward which they moved is exposed and has to be redrawn. -; This function does the redrawing. -RedrawExposedScreenEdge:: ; 1d01 (0:1d01) - ld a,[H_SCREENEDGEREDRAW] - and a - ret z - ld b,a - xor a - ld [H_SCREENEDGEREDRAW],a - dec b - jr nz,.redrawRow -.redrawColumn - ld hl,wScreenEdgeTiles - ld a,[H_SCREENEDGEREDRAWADDR] - ld e,a - ld a,[H_SCREENEDGEREDRAWADDR + 1] - ld d,a - ld c,18 ; screen height -.loop1 - ld a,[hli] - ld [de],a - inc de - ld a,[hli] - ld [de],a - ld a,31 - add e - ld e,a - jr nc,.noCarry - inc d -.noCarry -; the following 4 lines wrap us from bottom to top if necessary - ld a,d - and a,$03 - or a,$98 - ld d,a - dec c - jr nz,.loop1 - xor a - ld [H_SCREENEDGEREDRAW],a - ret -.redrawRow - ld hl,wScreenEdgeTiles - ld a,[H_SCREENEDGEREDRAWADDR] - ld e,a - ld a,[H_SCREENEDGEREDRAWADDR + 1] - ld d,a - push de - call .drawHalf ; draw upper half - pop de - ld a,32 ; width of VRAM background map - add e - ld e,a - ; draw lower half -.drawHalf - ld c,10 -.loop2 - ld a,[hli] - ld [de],a - inc de - ld a,[hli] - ld [de],a - ld a,e - inc a -; the following 6 lines wrap us from the right edge to the left edge if necessary - and a,$1f - ld b,a - ld a,e - and a,$e0 - or b - ld e,a - dec c - jr nz,.loop2 - ret - -; This function automatically transfers tile number data from the tile map at -; wTileMap to VRAM during V-blank. Note that it only transfers one third of the -; background per V-blank. It cycles through which third it draws. -; This transfer is turned off when walking around the map, but is turned -; on when talking to sprites, battling, using menus, etc. This is because -; the above function, RedrawExposedScreenEdge, is used when walking to -; improve efficiency. -AutoBgMapTransfer:: ; 1d57 (0:1d57) - ld a,[H_AUTOBGTRANSFERENABLED] - and a - ret z - ld hl,[sp + 0] - ld a,h - ld [H_SPTEMP],a - ld a,l - ld [H_SPTEMP + 1],a ; save stack pinter - ld a,[H_AUTOBGTRANSFERPORTION] - and a - jr z,.transferTopThird - dec a - jr z,.transferMiddleThird -.transferBottomThird - FuncCoord 0,12 - ld hl,Coord - ld sp,hl - ld a,[H_AUTOBGTRANSFERDEST + 1] - ld h,a - ld a,[H_AUTOBGTRANSFERDEST] - ld l,a - ld de,(12 * 32) - add hl,de - xor a ; TRANSFERTOP - jr .doTransfer -.transferTopThird - FuncCoord 0,0 - ld hl,Coord - ld sp,hl - ld a,[H_AUTOBGTRANSFERDEST + 1] - ld h,a - ld a,[H_AUTOBGTRANSFERDEST] - ld l,a - ld a,TRANSFERMIDDLE - jr .doTransfer -.transferMiddleThird - FuncCoord 0,6 - ld hl,Coord - ld sp,hl - ld a,[H_AUTOBGTRANSFERDEST + 1] - ld h,a - ld a,[H_AUTOBGTRANSFERDEST] - ld l,a - ld de,(6 * 32) - add hl,de - ld a,TRANSFERBOTTOM -.doTransfer - ld [H_AUTOBGTRANSFERPORTION],a ; store next portion - ld b,6 - -TransferBgRows:: ; 1d9e (0:1d9e) -; unrolled loop and using pop for speed - - rept 20 / 2 - 1 - pop de - ld [hl], e - inc l - ld [hl], d - inc l - endr - - pop de - ld [hl], e - inc l - ld [hl], d - -i ld a, 32 - (20 - 1) - add l - ld l, a - jr nc, .ok - inc h -.ok - dec b - jr nz, TransferBgRows - - ld a, [H_SPTEMP] - ld h, a - ld a, [H_SPTEMP + 1] - ld l, a - ld sp, hl - ret - -; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST. -; If H_VBCOPYBGSRC is XX00, the transfer is disabled. -VBlankCopyBgMap:: ; 1de1 (0:1de1) - ld a,[H_VBCOPYBGSRC] ; doubles as enabling byte - and a - ret z - ld hl,[sp + 0] - ld a,h - ld [H_SPTEMP],a - ld a,l - ld [H_SPTEMP + 1],a ; save stack pointer - ld a,[H_VBCOPYBGSRC] - ld l,a - ld a,[H_VBCOPYBGSRC + 1] - ld h,a - ld sp,hl - ld a,[H_VBCOPYBGDEST] - ld l,a - ld a,[H_VBCOPYBGDEST + 1] - ld h,a - ld a,[H_VBCOPYBGNUMROWS] - ld b,a - xor a - ld [H_VBCOPYBGSRC],a ; disable transfer so it doesn't continue next V-blank - jr TransferBgRows - - -VBlankCopyDouble:: -; Copy [H_VBCOPYDOUBLESIZE] 1bpp tiles -; from H_VBCOPYDOUBLESRC to H_VBCOPYDOUBLEDEST. - -; While we're here, convert to 2bpp. -; The process is straightforward: -; copy each byte twice. - - ld a, [H_VBCOPYDOUBLESIZE] - and a - ret z - - ld hl, [sp + 0] - ld a, h - ld [H_SPTEMP], a - ld a, l - ld [H_SPTEMP + 1], a - - ld a, [H_VBCOPYDOUBLESRC] - ld l, a - ld a, [H_VBCOPYDOUBLESRC + 1] - ld h, a - ld sp, hl - - ld a, [H_VBCOPYDOUBLEDEST] - ld l, a - ld a, [H_VBCOPYDOUBLEDEST + 1] - ld h, a - - ld a, [H_VBCOPYDOUBLESIZE] - ld b, a - xor a ; transferred - ld [H_VBCOPYDOUBLESIZE], a - -.loop - rept 3 - pop de - ld [hl], e - inc l - ld [hl], e - inc l - ld [hl], d - inc l - ld [hl], d - inc l - endr - - pop de - ld [hl], e - inc l - ld [hl], e - inc l - ld [hl], d - inc l - ld [hl], d - inc hl - dec b - jr nz, .loop - - ld a, l - ld [H_VBCOPYDOUBLEDEST], a - ld a, h - ld [H_VBCOPYDOUBLEDEST + 1], a - - ld hl, [sp + 0] - ld a, l - ld [H_VBCOPYDOUBLESRC], a - ld a, h - ld [H_VBCOPYDOUBLESRC + 1], a - - ld a, [H_SPTEMP] - ld h, a - ld a, [H_SPTEMP + 1] - ld l, a - ld sp, hl - - ret - - -VBlankCopy:: -; Copy [H_VBCOPYSIZE] 2bpp tiles -; from H_VBCOPYSRC to H_VBCOPYDEST. - -; Source and destination addresses -; are updated, so transfer can -; continue in subsequent calls. - - ld a, [H_VBCOPYSIZE] - and a - ret z - - ld hl, [sp + 0] - ld a, h - ld [H_SPTEMP], a - ld a, l - ld [H_SPTEMP + 1], a - - ld a, [H_VBCOPYSRC] - ld l, a - ld a, [H_VBCOPYSRC + 1] - ld h, a - ld sp, hl - - ld a, [H_VBCOPYDEST] - ld l, a - ld a, [H_VBCOPYDEST + 1] - ld h, a - - ld a, [H_VBCOPYSIZE] - ld b, a - xor a ; transferred - ld [H_VBCOPYSIZE], a - -.loop - rept 7 - pop de - ld [hl], e - inc l - ld [hl], d - inc l - endr - - pop de - ld [hl], e - inc l - ld [hl], d - inc hl - dec b - jr nz, .loop - - ld a, l - ld [H_VBCOPYDEST], a - ld a, h - ld [H_VBCOPYDEST + 1], a - - ld hl, [sp + 0] - ld a, l - ld [H_VBCOPYSRC], a - ld a, h - ld [H_VBCOPYSRC + 1], a - - ld a, [H_SPTEMP] - ld h, a - ld a, [H_SPTEMP + 1] - ld l, a - ld sp, hl - - ret - - -UpdateMovingBgTiles:: -; Animate water and flower -; tiles in the overworld. - - ld a, [$ffd7] - and a - ret z - - ld a, [$ffd8] - inc a - ld [$ffd8], a - cp $14 - ret c - cp $15 - jr z, .flower - - ld hl, vTileset + $14 * $10 - ld c, $10 - - ld a, [wd085] - inc a - and 7 - ld [wd085], a - - and 4 - jr nz, .left -.right - ld a, [hl] - rrca - ld [hli], a - dec c - jr nz, .right - jr .done -.left - ld a, [hl] - rlca - ld [hli], a - dec c - jr nz, .left -.done - ld a, [$ffd7] - rrca - ret nc - xor a - ld [$ffd8], a - ret - -.flower - xor a - ld [$ffd8], a - - ld a, [wd085] - and 3 - cp 2 - ld hl, FlowerTile1 - jr c, .copy - ld hl, FlowerTile2 - jr z, .copy - ld hl, FlowerTile3 -.copy - ld de, vTileset + $3 * $10 - ld c, $10 -.loop - ld a, [hli] - ld [de], a - inc de - dec c - jr nz, .loop - ret - -FlowerTile1: INCBIN "gfx/tilesets/flower/flower1.2bpp" -FlowerTile2: INCBIN "gfx/tilesets/flower/flower2.2bpp" -FlowerTile3: INCBIN "gfx/tilesets/flower/flower3.2bpp" - - -SoftReset:: - call StopAllSounds - call GBPalWhiteOut - ld c, $20 - call DelayFrames - ; fallthrough - -Init:: -; Program init. - -rLCDC_DEFAULT EQU %11100011 -; * LCD enabled -; * Window tile map at $9C00 -; * Window display enabled -; * BG and window tile data at $8800 -; * BG tile map at $9800 -; * 8x8 OBJ size -; * OBJ display enabled -; * BG display enabled - - di - - xor a - ld [rIF], a - ld [rIE], a - ld [$ff43], a - ld [$ff42], a - ld [$ff01], a - ld [$ff02], a - ld [$ff4b], a - ld [$ff4a], a - ld [$ff06], a - ld [$ff07], a - ld [$ff47], a - ld [$ff48], a - ld [$ff49], a - - ld a, rLCDC_ENABLE_MASK - ld [rLCDC], a - call DisableLCD - - ld sp, wStack - - ld hl, $c000 ; start of WRAM - ld bc, $2000 ; size of WRAM -.loop - ld [hl], 0 - inc hl - dec bc - ld a, b - or c - jr nz, .loop - - call ClearVram - - ld hl, $ff80 - ld bc, $ffff - $ff80 - call FillMemory - - call ClearSprites - - ld a, Bank(WriteDMACodeToHRAM) - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - call WriteDMACodeToHRAM - - xor a - ld [$ffd7], a - ld [$ff41], a - ld [$ffae], a - ld [$ffaf], a - ld [$ff0f], a - ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL - ld [rIE], a - - ld a, 144 ; move the window off-screen - ld [$ffb0], a - ld [rWY], a - ld a, 7 - ld [rWX], a - - ld a, $ff - ld [$ffaa], a - - ld h, vBGMap0 / $100 - call ClearBgMap - ld h, vBGMap1 / $100 - call ClearBgMap - - ld a, rLCDC_DEFAULT - ld [rLCDC], a - ld a, 16 - ld [hSoftReset], a - call StopAllSounds - - ei - - ld a, $40 ; PREDEF_SGB_BORDER - call Predef - - ld a, $1f - ld [wc0ef], a - ld [wc0f0], a - ld a, $9c - ld [$ffbd], a - xor a - ld [$ffbc], a - dec a - ld [wcfcb], a - - ld a, $32 ; PREDEF_INTRO - call Predef - - call DisableLCD - call ClearVram - call GBPalNormal - call ClearSprites - ld a, rLCDC_DEFAULT - ld [rLCDC], a - - jp SetDefaultNamesBeforeTitlescreen - -ClearVram: - ld hl, $8000 - ld bc, $2000 - xor a - jp FillMemory - - -StopAllSounds:: - ld a, Bank(Func_9876) - ld [wc0ef], a - ld [wc0f0], a - xor a - ld [wMusicHeaderPointer], a - ld [wc0ee], a - ld [wcfca], a - dec a - jp PlaySound - - -VBlank:: - - push af - push bc - push de - push hl - - ld a, [H_LOADEDROMBANK] - ld [wd122], a - - ld a, [$ffae] - ld [rSCX], a - ld a, [$ffaf] - ld [rSCY], a - - ld a, [wd0a0] - and a - jr nz, .ok - ld a, [$ffb0] - ld [rWY], a -.ok - - call AutoBgMapTransfer - call VBlankCopyBgMap - call RedrawExposedScreenEdge - call VBlankCopy - call VBlankCopyDouble - call UpdateMovingBgTiles - call $ff80 ; hOAMDMA - ld a, Bank(PrepareOAMData) - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - call PrepareOAMData - - ; VBlank-sensitive operations end. - - call Random - - ld a, [H_VBLANKOCCURRED] - and a - jr z, .vblanked - xor a - ld [H_VBLANKOCCURRED], a -.vblanked - - ld a, [H_FRAMECOUNTER] - and a - jr z, .decced - dec a - ld [H_FRAMECOUNTER], a -.decced - - call Func_28cb - - ld a, [wc0ef] ; music ROM bank - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - - cp BANK(Func_9103) - jr nz, .notbank2 -.bank2 - call Func_9103 - jr .afterMusic -.notbank2 - cp 8 - jr nz, .bank1F -.bank8 - call Func_2136e - call Func_21879 - jr .afterMusic -.bank1F - call Func_7d177 -.afterMusic - - callba Func_18dee ; keep track of time played - - ld a, [$fff9] - and a - call z, ReadJoypad - - ld a, [wd122] - ld [H_LOADEDROMBANK], a - ld [MBC3RomBank], a - - pop hl - pop de - pop bc - pop af - reti - - -DelayFrame:: -; Wait for the next vblank interrupt. -; As a bonus, this saves battery. - -NOT_VBLANKED EQU 1 - - ld a, NOT_VBLANKED - ld [H_VBLANKOCCURRED], a -.halt - halt - ld a, [H_VBLANKOCCURRED] - and a - jr nz, .halt - ret - - -; These routines manage gradual fading -; (e.g., entering a doorway) -LoadGBPal:: - ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?) - ld b, a - ld hl, FadePal4 - ld a, l - sub b - ld l, a - jr nc, .ok - dec h -.ok - ld a, [hli] - ld [rBGP], a - ld a, [hli] - ld [rOBP0], a - ld a, [hli] - ld [rOBP1], a - ret - -GBFadeOut1:: - ld hl, FadePal1 - ld b, 4 - jr GBFadeOutCommon - -GBFadeOut2:: - ld hl, FadePal6 - ld b, 3 - -GBFadeOutCommon:: - ld a, [hli] - ld [rBGP], a - ld a, [hli] - ld [rOBP0], a - ld a, [hli] - ld [rOBP1], a - ld c, 8 - call DelayFrames - dec b - jr nz, GBFadeOutCommon - ret - -GBFadeIn1:: - ld hl, FadePal4 + 2 - ld b, 4 - jr GBFadeInCommon - -GBFadeIn2:: - ld hl, FadePal7 + 2 - ld b, 3 - -GBFadeInCommon:: - ld a, [hld] - ld [rOBP1], a - ld a, [hld] - ld [rOBP0], a - ld a, [hld] - ld [rBGP], a - ld c, 8 - call DelayFrames - dec b - jr nz, GBFadeInCommon - ret - -FadePal1:: db %11111111, %11111111, %11111111 -FadePal2:: db %11111110, %11111110, %11111000 -FadePal3:: db %11111001, %11100100, %11100100 -FadePal4:: db %11100100, %11010000, %11100000 -; rBGP rOBP0 rOBP1 -FadePal5:: db %11100100, %11010000, %11100000 -FadePal6:: db %10010000, %10000000, %10010000 -FadePal7:: db %01000000, %01000000, %01000000 -FadePal8:: db %00000000, %00000000, %00000000 - - -Serial:: ; 2125 (0:2125) - push af - push bc - push de - push hl - ld a, [$ffaa] - inc a - jr z, .asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld a, [$ffac] - ld [$ff01], a - ld a, [$ffaa] - cp $2 - jr z, .asm_2162 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_2142 - ld a, [$ff01] - ld [$ffad], a - ld [$ffaa], a - cp $2 - jr z, .asm_215f - xor a - ld [$ff01], a - ld a, $3 - ld [rDIV], a ; $ff04 -.asm_2153 - ld a, [rDIV] ; $ff04 - bit 7, a - jr nz, .asm_2153 - ld a, $80 - ld [$ff02], a - jr .asm_2162 -.asm_215f - xor a - ld [$ff01], a -.asm_2162 - ld a, $1 - ld [$ffa9], a - ld a, $fe - ld [$ffac], a - pop hl - pop de - pop bc - pop af - reti - -Func_216f:: ; 216f (0:216f) - ld a, $1 - ld [$ffab], a -.asm_2173 - ld a, [hl] - ld [$ffac], a - call Func_219a - push bc - ld b, a - inc hl - ld a, $30 -.asm_217e - dec a - jr nz, .asm_217e - ld a, [$ffab] - and a - ld a, b - pop bc - jr z, .asm_2192 - dec hl - cp $fd - jr nz, .asm_2173 - xor a - ld [$ffab], a - jr .asm_2173 -.asm_2192 - ld [de], a - inc de - dec bc - ld a, b - or c - jr nz, .asm_2173 - ret - -Func_219a:: ; 219a (0:219a) - xor a - ld [$ffa9], a - ld a, [$ffaa] - cp $2 - jr nz, .asm_21a7 - ld a, $81 - ld [$ff02], a -.asm_21a7 - ld a, [$ffa9] - and a - jr nz, .asm_21f1 - ld a, [$ffaa] - cp $1 - jr nz, .asm_21cc - call Func_2237 - jr z, .asm_21cc - call Func_2231 - push hl - ld hl, wcc48 - inc [hl] - jr nz, .asm_21c3 - dec hl - inc [hl] -.asm_21c3 - pop hl - call Func_2237 - jr nz, .asm_21a7 - jp Func_223f -.asm_21cc - ld a, [rIE] ; $ffff - and $f - cp $8 - jr nz, .asm_21a7 - ld a, [W_NUMHITS] ; wd074 - dec a - ld [W_NUMHITS], a ; wd074 - jr nz, .asm_21a7 - ld a, [wd075] - dec a - ld [wd075], a - jr nz, .asm_21a7 - ld a, [$ffaa] - cp $1 - jr z, .asm_21f1 - ld a, $ff -.asm_21ee - dec a - jr nz, .asm_21ee -.asm_21f1 - xor a - ld [$ffa9], a - ld a, [rIE] ; $ffff - and $f - sub $8 - jr nz, .asm_2204 - ld [W_NUMHITS], a ; wd074 - ld a, $50 - ld [wd075], a -.asm_2204 - ld a, [$ffad] - cp $fe - ret nz - call Func_2237 - jr z, .asm_221f - push hl - ld hl, wcc48 - ld a, [hl] - dec a - ld [hld], a - inc a - jr nz, .asm_2219 - dec [hl] -.asm_2219 - pop hl - call Func_2237 - jr z, Func_223f -.asm_221f - ld a, [rIE] ; $ffff - and $f - cp $8 - ld a, $fe - ret z - ld a, [hl] - ld [$ffac], a - call DelayFrame - jp Func_219a - -Func_2231:: ; 2231 (0:2231) - ld a, $f -.asm_2233 - dec a - jr nz, .asm_2233 - ret - -Func_2237:: ; 2237 (0:2237) - push hl - ld hl, wcc47 - ld a, [hli] - or [hl] - pop hl - ret - -Func_223f:: ; 223f (0:223f) - dec a - ld [wcc47], a - ld [wcc48], a - ret - -Func_2247:: ; 2247 (0:2247) - ld hl, wcc42 - ld de, wcc3d - ld c, $2 - ld a, $1 - ld [$ffab], a -.asm_2253 - call DelayFrame - ld a, [hl] - ld [$ffac], a - call Func_219a - ld b, a - inc hl - ld a, [$ffab] - and a - ld a, $0 - ld [$ffab], a - jr nz, .asm_2253 - ld a, b - ld [de], a - inc de - dec c - jr nz, .asm_2253 - ret - -Func_226e:: ; 226e (0:226e) - call SaveScreenTilesToBuffer1 - callab PrintWaitingText - call Func_227f - jp LoadScreenTilesFromBuffer1 - -Func_227f:: ; 227f (0:227f) - ld a, $ff - ld [wcc3e], a -.asm_2284 - call Func_22c3 - call DelayFrame - call Func_2237 - jr z, .asm_22a0 - push hl - ld hl, wcc48 - dec [hl] - jr nz, .asm_229f - dec hl - dec [hl] - jr nz, .asm_229f - pop hl - xor a - jp Func_223f -.asm_229f - pop hl -.asm_22a0 - ld a, [wcc3e] - inc a - jr z, .asm_2284 - ld b, $a -.asm_22a8 - call DelayFrame - call Func_22c3 - dec b - jr nz, .asm_22a8 - ld b, $a -.asm_22b3 - call DelayFrame - call Func_22ed - dec b - jr nz, .asm_22b3 - ld a, [wcc3e] - ld [wcc3d], a - ret - -Func_22c3:: ; 22c3 (0:22c3) - call asm_22d7 - ld a, [wcc42] - add $60 - ld [$ffac], a - ld a, [$ffaa] - cp $2 - jr nz, asm_22d7 - ld a, $81 - ld [$ff02], a -asm_22d7:: ; 22d7 (0:22d7) - ld a, [$ffad] - ld [wcc3d], a - and $f0 - cp $60 - ret nz - xor a - ld [$ffad], a - ld a, [wcc3d] - and $f - ld [wcc3e], a - ret - -Func_22ed:: ; 22ed (0:22ed) - xor a - ld [$ffac], a - ld a, [$ffaa] - cp $2 - ret nz - ld a, $81 - ld [$ff02], a - ret - -Func_22fa:: ; 22fa (0:22fa) - ld a, $2 - ld [$ff01], a - xor a - ld [$ffad], a - ld a, $80 - ld [$ff02], a - ret - -; timer interrupt is apparently not invoked anyway -Timer:: ; 2306 (0:2306) - reti - -Func_2307:: ; 2307 (0:2307) - call WaitForSoundToFinish - xor a - ld c, a - ld d, a - ld [wcfca], a - jr asm_2324 - -Func_2312:: ; 2312 (0:2312) - ld c, $a - ld d, $0 - ld a, [wd72e] - bit 5, a - jr z, asm_2324 - xor a - ld [wcfca], a - ld c, $8 - ld d, c -asm_2324:: ; 2324 (0:2324) - ld a, [wd700] - and a - jr z, .asm_2343 - cp $2 - jr z, .asm_2332 - ld a, MUSIC_BIKE_RIDING - jr .asm_2334 -.asm_2332 - ld a, MUSIC_SURFING -.asm_2334 - ld b, a - ld a, d - and a - ld a, Bank(Func_7d8ea) - jr nz, .asm_233e - ld [wc0ef], a -.asm_233e - ld [wc0f0], a - jr .asm_234c -.asm_2343 - ld a, [wd35b] - ld b, a - call Func_2385 - jr c, .asm_2351 -.asm_234c - ld a, [wcfca] - cp b - ret z -.asm_2351 - ld a, c - ld [wMusicHeaderPointer], a - ld a, b - ld [wcfca], a - ld [wc0ee], a - jp PlaySound - -Func_235f:: ; 235f (0:235f) - ld a, [wc0ef] - ld b, a - cp $2 - jr nz, .checkForBank08 -.bank02 - ld hl, Func_9103 - jr .asm_2378 -.checkForBank08 - cp $8 - jr nz, .bank1F -.bank08 - ld hl, Func_21879 - jr .asm_2378 -.bank1F - ld hl, Func_7d177 -.asm_2378 - ld c, $6 -.asm_237a - push bc - push hl - call Bankswitch - pop hl - pop bc - dec c - jr nz, .asm_237a - ret - -Func_2385:: ; 2385 (0:2385) - ld a, [wd35c] - ld e, a - ld a, [wc0ef] - cp e - jr nz, .asm_2394 - ld [wc0f0], a - and a - ret -.asm_2394 - ld a, c - and a - ld a, e - jr nz, .asm_239c - ld [wc0ef], a -.asm_239c - ld [wc0f0], a - scf - ret - -PlayMusic:: ; 23a1 (0:23a1) - ld b, a - ld [wc0ee], a - xor a - ld [wMusicHeaderPointer], a - ld a, c - ld [wc0ef], a - ld [wc0f0], a - ld a, b - -; plays music specified by a. If value is $ff, music is stopped -PlaySound:: ; 23b1 (0:23b1) - push hl - push de - push bc - ld b, a - ld a, [wc0ee] - and a - jr z, .asm_23c8 - xor a - ld [wc02a], a - ld [wc02b], a - ld [wc02c], a - ld [wc02d], a -.asm_23c8 - ld a, [wMusicHeaderPointer] - and a - jr z, .asm_23e3 - ld a, [wc0ee] - and a - jr z, .asm_2425 - xor a - ld [wc0ee], a - ld a, [wcfca] - cp $ff - jr nz, .asm_2414 - xor a - ld [wMusicHeaderPointer], a -.asm_23e3 - xor a - ld [wc0ee], a - ld a, [H_LOADEDROMBANK] - ld [$ffb9], a - ld a, [wc0ef] - ld [H_LOADEDROMBANK], a - ld [$2000], a - cp $2 - jr nz, .checkForBank08 -.bank02 - ld a, b - call Func_9876 - jr .asm_240b -.checkForBank08 - cp $8 - jr nz, .bank1F -.bank08 - ld a, b - call Func_22035 - jr .asm_240b -.bank1F - ld a, b - call Func_7d8ea -.asm_240b - ld a, [$ffb9] - ld [H_LOADEDROMBANK], a - ld [$2000], a - jr .asm_2425 -.asm_2414 - ld a, b - ld [wcfca], a - ld a, [wMusicHeaderPointer] - ld [wcfc8], a - ld [wcfc9], a - ld a, b - ld [wMusicHeaderPointer], a -.asm_2425 - pop bc - pop de - pop hl - ret - -UpdateSprites:: ; 2429 (0:2429) - ld a, [wcfcb] - dec a - ret nz - ld a, [H_LOADEDROMBANK] - push af - ld a, Bank(_UpdateSprites) - ld [H_LOADEDROMBANK], a - ld [$2000], a - call _UpdateSprites - pop af - ld [H_LOADEDROMBANK], a - ld [$2000], a - ret - -INCLUDE "data/mart_inventories.asm" - -TextScriptEndingChar:: ; 24d6 (0:24d6) - db "@" -TextScriptEnd:: ; 24d7 (0:24d7) - ld hl,TextScriptEndingChar - ret - -ExclamationText:: ; 24db (0:24db) - TX_FAR _ExclamationText - db "@" - -GroundRoseText:: ; 24e0 (0:24e0) - TX_FAR _GroundRoseText - db "@" - -BoulderText:: ; 24e5 (0:24e5) - TX_FAR _BoulderText - db "@" - -MartSignText:: ; 24ea (0:24ea) - TX_FAR _MartSignText - db "@" - -PokeCenterSignText:: ; 24ef (0:24ef) - TX_FAR _PokeCenterSignText - db "@" - -Predef5CText:: ; 24f4 (0:24f4) -; XXX better label (what does predef $5C do?) - db $08 ; asm - ld a, $5c - call Predef - jp TextScriptEnd - -; bankswitches and runs _UncompressSpriteData -; bank is given in a, sprite input stream is pointed to in W_SPRITEINPUTPTR -UncompressSpriteData:: ; 24fd (0:24fd) - ld b, a - ld a, [H_LOADEDROMBANK] - push af - ld a, b - ld [H_LOADEDROMBANK], a - ld [$2000], a - ld a, $a - ld [$0], a - xor a - ld [$4000], a - call _UncompressSpriteData - pop af - ld [H_LOADEDROMBANK], a - ld [$2000], a - ret - -; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop -_UncompressSpriteData:: ; 251a (0:251a) - ld hl, S_SPRITEBUFFER1 - ld c, (2*SPRITEBUFFERSIZE) % $100 - ld b, (2*SPRITEBUFFERSIZE) / $100 - xor a - call FillMemory ; clear sprite buffer 1 and 2 - ld a, $1 - ld [W_SPRITEINPUTBITCOUNTER], a - ld a, $3 - ld [W_SPRITEOUTPUTBITOFFSET], a - xor a - ld [W_SPRITECURPOSX], a - ld [W_SPRITECURPOSY], a - ld [W_SPRITELOADFLAGS], a ; wd0a8 - call ReadNextInputByte ; first byte of input determines sprite width (high nybble) and height (low nybble) in tiles (8x8 pixels) - ld b, a - and $f - add a - add a - add a - ld [W_SPRITEHEIGHT], a - ld a, b - swap a - and $f - add a - add a - add a - ld [W_SPRITEWITDH], a - call ReadNextInputBit - ld [W_SPRITELOADFLAGS], a ; initialite bit1 to 0 and bit0 to the first input bit - ; this will load two chunks of data to S_SPRITEBUFFER1 and S_SPRITEBUFFER2 - ; bit 0 decides in which one the first chunk is placed - ; fall through - -; uncompresses a chunk from the sprite input data stream (pointed to at wd0da) into S_SPRITEBUFFER1 or S_SPRITEBUFFER2 -; each chunk is a 1bpp sprite. A 2bpp sprite consist of two chunks which are merged afterwards -; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack -UncompressSpriteDataLoop:: ; 2556 (0:2556) - ld hl, S_SPRITEBUFFER1 - ld a, [W_SPRITELOADFLAGS] ; wd0a8 - bit 0, a - jr z, .useSpriteBuffer1 ; check which buffer to use - ld hl, S_SPRITEBUFFER2 -.useSpriteBuffer1 - call StoreSpriteOutputPointer - ld a, [W_SPRITELOADFLAGS] ; wd0a8 - bit 1, a - jr z, .startDecompression ; check if last iteration - call ReadNextInputBit ; if last chunk, read 1-2 bit unpacking mode - and a - jr z, .unpackingMode0 ; 0 -> mode 0 - call ReadNextInputBit ; 1 0 -> mode 1 - inc a ; 1 1 -> mode 2 -.unpackingMode0 - ld [W_SPRITEUNPACKMODE], a -.startDecompression - call ReadNextInputBit - and a - jr z, .readRLEncodedZeros ; if first bit is 0, the input starts with zeroes, otherwise with (non-zero) input -.readNextInput - call ReadNextInputBit - ld c, a - call ReadNextInputBit - sla c - or c ; read next two bits into c - and a - jr z, .readRLEncodedZeros ; 00 -> RLEncoded zeroes following - call WriteSpriteBitsToBuffer ; otherwise write input to output and repeat - call MoveToNextBufferPosition - jr .readNextInput -.readRLEncodedZeros - ld c, $0 ; number of zeroes it length encoded, the number -.countConsecutiveOnesLoop ; of consecutive ones determines the number of bits the number has - call ReadNextInputBit - and a - jr z, .countConsecutiveOnesFinished - inc c - jr .countConsecutiveOnesLoop -.countConsecutiveOnesFinished - ld a, c - add a - ld hl, LengthEncodingOffsetList - add l - ld l, a - jr nc, .noCarry - inc h -.noCarry - ld a, [hli] ; read offset that is added to the number later on - ld e, a ; adding an offset of 2^length - 1 makes every integer uniquely - ld d, [hl] ; representable in the length encoding and saves bits +Serial:: ; 2125 (0:2125) + push af + push bc push de - inc c - ld e, $0 - ld d, e -.readNumberOfZerosLoop ; reads the next c+1 bits of input - call ReadNextInputBit - or e - ld e, a - dec c - jr z, .readNumberOfZerosDone - sla e - rl d - jr .readNumberOfZerosLoop -.readNumberOfZerosDone - pop hl ; add the offset - add hl, de - ld e, l - ld d, h -.writeZerosLoop - ld b, e - xor a ; write 00 to buffer - call WriteSpriteBitsToBuffer - ld e, b - call MoveToNextBufferPosition - dec de - ld a, d - and a - jr nz, .continueLoop - ld a, e - and a -.continueLoop - jr nz, .writeZerosLoop - jr .readNextInput - -; moves output pointer to next position -; also cancels the calling function if the all output is done (by removing the return pointer from stack) -; and calls postprocessing functions according to the unpack mode -MoveToNextBufferPosition:: ; 25d8 (0:25d8) - ld a, [W_SPRITEHEIGHT] - ld b, a - ld a, [W_SPRITECURPOSY] - inc a - cp b - jr z, .curColumnDone - ld [W_SPRITECURPOSY], a - ld a, [W_SPRITEOUTPUTPTR] - inc a - ld [W_SPRITEOUTPUTPTR], a - ret nz - ld a, [W_SPRITEOUTPUTPTR+1] + push hl + ld a, [$ffaa] inc a - ld [W_SPRITEOUTPUTPTR+1], a - ret -.curColumnDone + jr z, .asm_2142 + ld a, [$ff01] + ld [$ffad], a + ld a, [$ffac] + ld [$ff01], a + ld a, [$ffaa] + cp $2 + jr z, .asm_2162 + ld a, $80 + ld [$ff02], a + jr .asm_2162 +.asm_2142 + ld a, [$ff01] + ld [$ffad], a + ld [$ffaa], a + cp $2 + jr z, .asm_215f xor a - ld [W_SPRITECURPOSY], a - ld a, [W_SPRITEOUTPUTBITOFFSET] - and a - jr z, .bitOffsetsDone - dec a - ld [W_SPRITEOUTPUTBITOFFSET], a - ld hl, W_SPRITEOUTPUTPTRCACHED - ld a, [hli] - ld [W_SPRITEOUTPUTPTR], a - ld a, [hl] - ld [W_SPRITEOUTPUTPTR+1], a - ret -.bitOffsetsDone + ld [$ff01], a ld a, $3 - ld [W_SPRITEOUTPUTBITOFFSET], a - ld a, [W_SPRITECURPOSX] - add $8 - ld [W_SPRITECURPOSX], a - ld b, a - ld a, [W_SPRITEWITDH] - cp b - jr z, .allColumnsDone - ld a, [W_SPRITEOUTPUTPTR] - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a - inc hl - jp StoreSpriteOutputPointer -.allColumnsDone - pop hl + ld [rDIV], a ; $ff04 +.asm_2153 + ld a, [rDIV] ; $ff04 + bit 7, a + jr nz, .asm_2153 + ld a, $80 + ld [$ff02], a + jr .asm_2162 +.asm_215f xor a - ld [W_SPRITECURPOSX], a - ld a, [W_SPRITELOADFLAGS] ; wd0a8 - bit 1, a - jr nz, .done ; test if there is one more sprite to go - xor $1 - set 1, a - ld [W_SPRITELOADFLAGS], a ; wd0a8 - jp UncompressSpriteDataLoop -.done - jp UnpackSprite + ld [$ff01], a +.asm_2162 + ld a, $1 + ld [$ffa9], a + ld a, $fe + ld [$ffac], a + pop hl + pop de + pop bc + pop af + reti -; writes 2 bits (from a) to the output buffer (pointed to from W_SPRITEOUTPUTPTR) -WriteSpriteBitsToBuffer:: ; 2649 (0:2649) - ld e, a - ld a, [W_SPRITEOUTPUTBITOFFSET] - and a - jr z, .offset0 - cp $2 - jr c, .offset1 - jr z, .offset2 - rrc e ; offset 3 - rrc e - jr .offset0 -.offset1 - sla e - sla e - jr .offset0 -.offset2 - swap e -.offset0 - ld a, [W_SPRITEOUTPUTPTR] - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a +Func_216f:: ; 216f (0:216f) + ld a, $1 + ld [$ffab], a +.asm_2173 ld a, [hl] - or e - ld [hl], a - ret - -; reads next bit from input stream and returns it in a -ReadNextInputBit:: ; 2670 (0:2670) - ld a, [W_SPRITEINPUTBITCOUNTER] - dec a - jr nz, .curByteHasMoreBitsToRead - call ReadNextInputByte - ld [W_SPRITEINPUTCURBYTE], a - ld a, $8 -.curByteHasMoreBitsToRead - ld [W_SPRITEINPUTBITCOUNTER], a - ld a, [W_SPRITEINPUTCURBYTE] - rlca - ld [W_SPRITEINPUTCURBYTE], a - and $1 - ret - -; reads next byte from input stream and returns it in a -ReadNextInputByte:: ; 268b (0:268b) - ld a, [W_SPRITEINPUTPTR] - ld l, a - ld a, [W_SPRITEINPUTPTR+1] - ld h, a - ld a, [hli] + ld [$ffac], a + call Func_219a + push bc ld b, a - ld a, l - ld [W_SPRITEINPUTPTR], a - ld a, h - ld [W_SPRITEINPUTPTR+1], a + inc hl + ld a, $30 +.asm_217e + dec a + jr nz, .asm_217e + ld a, [$ffab] + and a + ld a, b + pop bc + jr z, .asm_2192 + dec hl + cp $fd + jr nz, .asm_2173 + xor a + ld [$ffab], a + jr .asm_2173 +.asm_2192 + ld [de], a + inc de + dec bc ld a, b + or c + jr nz, .asm_2173 ret -; the nth item is 2^n - 1 -LengthEncodingOffsetList:: ; 269f (0:269f) - dw %0000000000000001 - dw %0000000000000011 - dw %0000000000000111 - dw %0000000000001111 - dw %0000000000011111 - dw %0000000000111111 - dw %0000000001111111 - dw %0000000011111111 - dw %0000000111111111 - dw %0000001111111111 - dw %0000011111111111 - dw %0000111111111111 - dw %0001111111111111 - dw %0011111111111111 - dw %0111111111111111 - dw %1111111111111111 - -; unpacks the sprite data depending on the unpack mode -UnpackSprite:: ; 26bf (0:26bf) - ld a, [W_SPRITEUNPACKMODE] - cp $2 - jp z, UnpackSpriteMode2 - and a - jp nz, XorSpriteChunks - ld hl, S_SPRITEBUFFER1 - call SpriteDifferentialDecode - ld hl, S_SPRITEBUFFER2 - ; fall through - -; decodes differential encoded sprite data -; input bit value 0 preserves the current bit value and input bit value 1 toggles it (starting from initial value 0). -SpriteDifferentialDecode:: ; 26d4 (0:26d4) +Func_219a:: ; 219a (0:219a) xor a - ld [W_SPRITECURPOSX], a - ld [W_SPRITECURPOSY], a - call StoreSpriteOutputPointer - ld a, [W_SPRITEFLIPPED] + ld [$ffa9], a + ld a, [$ffaa] + cp $2 + jr nz, .asm_21a7 + ld a, $81 + ld [$ff02], a +.asm_21a7 + ld a, [$ffa9] and a - jr z, .notFlipped - ld hl, DecodeNybble0TableFlipped - ld de, DecodeNybble1TableFlipped - jr .storeDecodeTablesPointers -.notFlipped - ld hl, DecodeNybble0Table - ld de, DecodeNybble1Table -.storeDecodeTablesPointers - ld a, l - ld [W_SPRITEDECODETABLE0PTR], a - ld a, h - ld [W_SPRITEDECODETABLE0PTR+1], a - ld a, e - ld [W_SPRITEDECODETABLE1PTR], a - ld a, d - ld [W_SPRITEDECODETABLE1PTR+1], a - ld e, $0 ; last decoded nybble, initialized to 0 -.decodeNextByteLoop - ld a, [W_SPRITEOUTPUTPTR] - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a - ld a, [hl] - ld b, a - swap a - and $f - call DifferentialDecodeNybble ; decode high nybble - swap a - ld d, a - ld a, b + jr nz, .asm_21f1 + ld a, [$ffaa] + cp $1 + jr nz, .asm_21cc + call Func_2237 + jr z, .asm_21cc + call Func_2231 + push hl + ld hl, wcc48 + inc [hl] + jr nz, .asm_21c3 + dec hl + inc [hl] +.asm_21c3 + pop hl + call Func_2237 + jr nz, .asm_21a7 + jp Func_223f +.asm_21cc + ld a, [rIE] ; $ffff and $f - call DifferentialDecodeNybble ; decode low nybble - or d - ld b, a - ld a, [W_SPRITEOUTPUTPTR] - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a - ld a, b - ld [hl], a ; write back decoded data - ld a, [W_SPRITEHEIGHT] - add l ; move on to next column - jr nc, .noCarry - inc h -.noCarry - ld [W_SPRITEOUTPUTPTR], a - ld a, h - ld [W_SPRITEOUTPUTPTR+1], a - ld a, [W_SPRITECURPOSX] - add $8 - ld [W_SPRITECURPOSX], a - ld b, a - ld a, [W_SPRITEWITDH] - cp b - jr nz, .decodeNextByteLoop ; test if current row is done + cp $8 + jr nz, .asm_21a7 + ld a, [W_NUMHITS] ; wd074 + dec a + ld [W_NUMHITS], a ; wd074 + jr nz, .asm_21a7 + ld a, [wd075] + dec a + ld [wd075], a + jr nz, .asm_21a7 + ld a, [$ffaa] + cp $1 + jr z, .asm_21f1 + ld a, $ff +.asm_21ee + dec a + jr nz, .asm_21ee +.asm_21f1 xor a - ld e, a - ld [W_SPRITECURPOSX], a - ld a, [W_SPRITECURPOSY] ; move on to next row + ld [$ffa9], a + ld a, [rIE] ; $ffff + and $f + sub $8 + jr nz, .asm_2204 + ld [W_NUMHITS], a ; wd074 + ld a, $50 + ld [wd075], a +.asm_2204 + ld a, [$ffad] + cp $fe + ret nz + call Func_2237 + jr z, .asm_221f + push hl + ld hl, wcc48 + ld a, [hl] + dec a + ld [hld], a inc a - ld [W_SPRITECURPOSY], a - ld b, a - ld a, [W_SPRITEHEIGHT] - cp b - jr z, .done ; test if all rows finished - ld a, [W_SPRITEOUTPUTPTRCACHED] - ld l, a - ld a, [W_SPRITEOUTPUTPTRCACHED+1] - ld h, a - inc hl - call StoreSpriteOutputPointer - jr .decodeNextByteLoop -.done - xor a - ld [W_SPRITECURPOSY], a + jr nz, .asm_2219 + dec [hl] +.asm_2219 + pop hl + call Func_2237 + jr z, Func_223f +.asm_221f + ld a, [rIE] ; $ffff + and $f + cp $8 + ld a, $fe + ret z + ld a, [hl] + ld [$ffac], a + call DelayFrame + jp Func_219a + +Func_2231:: ; 2231 (0:2231) + ld a, $f +.asm_2233 + dec a + jr nz, .asm_2233 + ret + +Func_2237:: ; 2237 (0:2237) + push hl + ld hl, wcc47 + ld a, [hli] + or [hl] + pop hl ret -; decodes the nybble stored in a. Last decoded data is assumed to be in e (needed to determine if initial value is 0 or 1) -DifferentialDecodeNybble:: ; 276d (0:276d) - srl a ; c=a%2, a/=2 - ld c, $0 - jr nc, .evenNumber - ld c, $1 -.evenNumber - ld l, a - ld a, [W_SPRITEFLIPPED] - and a - jr z, .notFlipped ; determine if initial value is 0 or one - bit 3, e ; if flipped, consider MSB of last data - jr .selectLookupTable -.notFlipped - bit 0, e ; else consider LSB -.selectLookupTable - ld e, l - jr nz, .initialValue1 ; load the appropriate table - ld a, [W_SPRITEDECODETABLE0PTR] - ld l, a - ld a, [W_SPRITEDECODETABLE0PTR+1] - jr .tableLookup -.initialValue1 - ld a, [W_SPRITEDECODETABLE1PTR] - ld l, a - ld a, [W_SPRITEDECODETABLE1PTR+1] -.tableLookup - ld h, a - ld a, e - add l - ld l, a - jr nc, .noCarry - inc h -.noCarry +Func_223f:: ; 223f (0:223f) + dec a + ld [wcc47], a + ld [wcc48], a + ret + +Func_2247:: ; 2247 (0:2247) + ld hl, wcc42 + ld de, wcc3d + ld c, $2 + ld a, $1 + ld [$ffab], a +.asm_2253 + call DelayFrame ld a, [hl] - bit 0, c - jr nz, .selectLowNybble - swap a ; select high nybble -.selectLowNybble - and $f - ld e, a ; update last decoded data - ret - -DecodeNybble0Table:: ; 27a7 (0:27a7) - dn $0, $1 - dn $3, $2 - dn $7, $6 - dn $4, $5 - dn $f, $e - dn $c, $d - dn $8, $9 - dn $b, $a -DecodeNybble1Table:: ; 27af (0:27af) - dn $f, $e - dn $c, $d - dn $8, $9 - dn $b, $a - dn $0, $1 - dn $3, $2 - dn $7, $6 - dn $4, $5 -DecodeNybble0TableFlipped:: ; 27b7 (0:27b7) - dn $0, $8 - dn $c, $4 - dn $e, $6 - dn $2, $a - dn $f, $7 - dn $3, $b - dn $1, $9 - dn $d, $5 -DecodeNybble1TableFlipped:: ; 27bf (0:27bf) - dn $f, $7 - dn $3, $b - dn $1, $9 - dn $d, $5 - dn $0, $8 - dn $c, $4 - dn $e, $6 - dn $2, $a - -; combines the two loaded chunks with xor (the chunk loaded second is the destination). The source chunk is differeintial decoded beforehand. -XorSpriteChunks:: ; 27c7 (0:27c7) - xor a - ld [W_SPRITECURPOSX], a - ld [W_SPRITECURPOSY], a - call ResetSpriteBufferPointers - ld a, [W_SPRITEOUTPUTPTR] ; points to buffer 1 or 2, depending on flags - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a - call SpriteDifferentialDecode ; decode buffer 1 or 2, depending on flags - call ResetSpriteBufferPointers - ld a, [W_SPRITEOUTPUTPTR] ; source buffer, points to buffer 1 or 2, depending on flags - ld l, a - ld a, [W_SPRITEOUTPUTPTR+1] - ld h, a - ld a, [W_SPRITEOUTPUTPTRCACHED] ; destination buffer, points to buffer 2 or 1, depending on flags - ld e, a - ld a, [W_SPRITEOUTPUTPTRCACHED+1] - ld d, a -.xorChunksLoop - ld a, [W_SPRITEFLIPPED] - and a - jr z, .notFlipped - push de - ld a, [de] + ld [$ffac], a + call Func_219a ld b, a - swap a - and $f - call ReverseNybble ; if flipped reverse the nybbles in the destination buffer - swap a - ld c, a + inc hl + ld a, [$ffab] + and a + ld a, $0 + ld [$ffab], a + jr nz, .asm_2253 ld a, b - and $f - call ReverseNybble - or c - pop de - ld [de], a -.notFlipped - ld a, [hli] - ld b, a - ld a, [de] - xor b ld [de], a inc de - ld a, [W_SPRITECURPOSY] - inc a - ld [W_SPRITECURPOSY], a ; go to next row - ld b, a - ld a, [W_SPRITEHEIGHT] - cp b - jr nz, .xorChunksLoop ; test if column finished + dec c + jr nz, .asm_2253 + ret + +Func_226e:: ; 226e (0:226e) + call SaveScreenTilesToBuffer1 + callab PrintWaitingText + call Func_227f + jp LoadScreenTilesFromBuffer1 + +Func_227f:: ; 227f (0:227f) + ld a, $ff + ld [wcc3e], a +.asm_2284 + call Func_22c3 + call DelayFrame + call Func_2237 + jr z, .asm_22a0 + push hl + ld hl, wcc48 + dec [hl] + jr nz, .asm_229f + dec hl + dec [hl] + jr nz, .asm_229f + pop hl xor a - ld [W_SPRITECURPOSY], a - ld a, [W_SPRITECURPOSX] - add $8 - ld [W_SPRITECURPOSX], a ; go to next column - ld b, a - ld a, [W_SPRITEWITDH] - cp b - jr nz, .xorChunksLoop ; test if all columns finished + jp Func_223f +.asm_229f + pop hl +.asm_22a0 + ld a, [wcc3e] + inc a + jr z, .asm_2284 + ld b, $a +.asm_22a8 + call DelayFrame + call Func_22c3 + dec b + jr nz, .asm_22a8 + ld b, $a +.asm_22b3 + call DelayFrame + call Func_22ed + dec b + jr nz, .asm_22b3 + ld a, [wcc3e] + ld [wcc3d], a + ret + +Func_22c3:: ; 22c3 (0:22c3) + call asm_22d7 + ld a, [wcc42] + add $60 + ld [$ffac], a + ld a, [$ffaa] + cp $2 + jr nz, asm_22d7 + ld a, $81 + ld [$ff02], a +asm_22d7:: ; 22d7 (0:22d7) + ld a, [$ffad] + ld [wcc3d], a + and $f0 + cp $60 + ret nz xor a - ld [W_SPRITECURPOSX], a + ld [$ffad], a + ld a, [wcc3d] + and $f + ld [wcc3e], a ret -; reverses the bits in the nybble given in register a -ReverseNybble:: ; 2837 (0:2837) - ld de, NybbleReverseTable - add e - ld e, a - jr nc, .asm_283f - inc d -.asm_283f - ld a, [de] +Func_22ed:: ; 22ed (0:22ed) + xor a + ld [$ffac], a + ld a, [$ffaa] + cp $2 + ret nz + ld a, $81 + ld [$ff02], a ret -; resets sprite buffer pointers to buffer 1 and 2, depending on W_SPRITELOADFLAGS -ResetSpriteBufferPointers:: ; 2841 (0:2841) - ld a, [W_SPRITELOADFLAGS] ; wd0a8 - bit 0, a - jr nz, .buffer2Selected - ld de, S_SPRITEBUFFER1 - ld hl, S_SPRITEBUFFER2 - jr .storeBufferPointers -.buffer2Selected - ld de, S_SPRITEBUFFER2 - ld hl, S_SPRITEBUFFER1 -.storeBufferPointers - ld a, l - ld [W_SPRITEOUTPUTPTR], a - ld a, h - ld [W_SPRITEOUTPUTPTR+1], a - ld a, e - ld [W_SPRITEOUTPUTPTRCACHED], a - ld a, d - ld [W_SPRITEOUTPUTPTRCACHED+1], a +Func_22fa:: ; 22fa (0:22fa) + ld a, $2 + ld [$ff01], a + xor a + ld [$ffad], a + ld a, $80 + ld [$ff02], a ret -; maps each nybble to its reverse -NybbleReverseTable:: ; 2867 (0:2867) - db $0, $8, $4, $c, $2, $a, $6 ,$e, $1, $9, $5, $d, $3, $b, $7 ,$f -; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand. -UnpackSpriteMode2:: ; 2877 (0:2877) - call ResetSpriteBufferPointers - ld a, [W_SPRITEFLIPPED] +; timer interrupt is apparently not invoked anyway +Timer:: ; 2306 (0:2306) + reti + + +INCLUDE "home/audio.asm" + + +UpdateSprites:: ; 2429 (0:2429) + ld a, [wcfcb] + dec a + ret nz + ld a, [H_LOADEDROMBANK] push af - xor a - ld [W_SPRITEFLIPPED], a ; temporarily clear flipped flag for decoding the destination chunk - ld a, [W_SPRITEOUTPUTPTRCACHED] - ld l, a - ld a, [W_SPRITEOUTPUTPTRCACHED+1] - ld h, a - call SpriteDifferentialDecode - call ResetSpriteBufferPointers + ld a, Bank(_UpdateSprites) + ld [H_LOADEDROMBANK], a + ld [$2000], a + call _UpdateSprites pop af - ld [W_SPRITEFLIPPED], a - jp XorSpriteChunks + ld [H_LOADEDROMBANK], a + ld [$2000], a + ret -; stores hl into the output pointers -StoreSpriteOutputPointer:: ; 2897 (0:2897) - ld a, l - ld [W_SPRITEOUTPUTPTR], a - ld [W_SPRITEOUTPUTPTRCACHED], a - ld a, h - ld [W_SPRITEOUTPUTPTR+1], a - ld [W_SPRITEOUTPUTPTRCACHED+1], a +INCLUDE "data/mart_inventories.asm" + +TextScriptEndingChar:: ; 24d6 (0:24d6) + db "@" +TextScriptEnd:: ; 24d7 (0:24d7) + ld hl,TextScriptEndingChar ret +ExclamationText:: ; 24db (0:24db) + TX_FAR _ExclamationText + db "@" + +GroundRoseText:: ; 24e0 (0:24e0) + TX_FAR _GroundRoseText + db "@" + +BoulderText:: ; 24e5 (0:24e5) + TX_FAR _BoulderText + db "@" + +MartSignText:: ; 24ea (0:24ea) + TX_FAR _MartSignText + db "@" + +PokeCenterSignText:: ; 24ef (0:24ef) + TX_FAR _PokeCenterSignText + db "@" + +Predef5CText:: ; 24f4 (0:24f4) +; XXX better label (what does predef $5C do?) + db $08 ; asm + ld a, $5c + call Predef + jp TextScriptEnd + + +INCLUDE "home/pic.asm" + + ResetPlayerSpriteData:: ; 28a6 (0:28a6) ld hl, wSpriteStateData1 call ResetPlayerSpriteData_ClearSpriteData @@ -6721,56 +5160,7 @@ Random:: ret -Predef:: -; Call predefined function a. -; To preserve other registers, have the -; destination call GetPredefRegisters. - - ; Save the predef id for GetPredefPointer. - ld [wPredefID], a - - ; A hack for LoadDestinationWarpPosition. - ; See Func_c754 (predef $19). - ld a, [H_LOADEDROMBANK] - ld [wPredefParentBank], a - - push af - ld a, BANK(GetPredefPointer) - ld [H_LOADEDROMBANK], a - ld [$2000], a - - call GetPredefPointer - - ld a, [wPredefBank] - ld [H_LOADEDROMBANK], a - ld [$2000], a - - ld de, .done - push de - jp [hl] -.done - - pop af - ld [H_LOADEDROMBANK], a - ld [$2000], a - ret - -GetPredefRegisters:: -; Restore the contents of register pairs -; when GetPredefPointer was called. - ld a, [wPredefRegisters + 0] - ld h, a - ld a, [wPredefRegisters + 1] - ld l, a - ld a, [wPredefRegisters + 2] - ld d, a - ld a, [wPredefRegisters + 3] - ld e, a - ld a, [wPredefRegisters + 4] - ld b, a - ld a, [wPredefRegisters + 5] - ld c, a - ret +INCLUDE "home/predef.asm" Func_3ead:: ; 3ead (0:3ead) diff --git a/home/audio.asm b/home/audio.asm new file mode 100644 index 00000000..724b8c5f --- /dev/null +++ b/home/audio.asm @@ -0,0 +1,183 @@ +Func_2307:: ; 2307 (0:2307) + call WaitForSoundToFinish + xor a + ld c, a + ld d, a + ld [wcfca], a + jr asm_2324 + +Func_2312:: ; 2312 (0:2312) + ld c, $a + ld d, $0 + ld a, [wd72e] + bit 5, a + jr z, asm_2324 + xor a + ld [wcfca], a + ld c, $8 + ld d, c +asm_2324:: ; 2324 (0:2324) + ld a, [wd700] + and a + jr z, .asm_2343 + cp $2 + jr z, .asm_2332 + ld a, MUSIC_BIKE_RIDING + jr .asm_2334 +.asm_2332 + ld a, MUSIC_SURFING +.asm_2334 + ld b, a + ld a, d + and a + ld a, Bank(Func_7d8ea) + jr nz, .asm_233e + ld [wc0ef], a +.asm_233e + ld [wc0f0], a + jr .asm_234c +.asm_2343 + ld a, [wd35b] + ld b, a + call Func_2385 + jr c, .asm_2351 +.asm_234c + ld a, [wcfca] + cp b + ret z +.asm_2351 + ld a, c + ld [wMusicHeaderPointer], a + ld a, b + ld [wcfca], a + ld [wc0ee], a + jp PlaySound + +Func_235f:: ; 235f (0:235f) + ld a, [wc0ef] + ld b, a + cp $2 + jr nz, .checkForBank08 +.bank02 + ld hl, Func_9103 + jr .asm_2378 +.checkForBank08 + cp $8 + jr nz, .bank1F +.bank08 + ld hl, Func_21879 + jr .asm_2378 +.bank1F + ld hl, Func_7d177 +.asm_2378 + ld c, $6 +.asm_237a + push bc + push hl + call Bankswitch + pop hl + pop bc + dec c + jr nz, .asm_237a + ret + +Func_2385:: ; 2385 (0:2385) + ld a, [wd35c] + ld e, a + ld a, [wc0ef] + cp e + jr nz, .asm_2394 + ld [wc0f0], a + and a + ret +.asm_2394 + ld a, c + and a + ld a, e + jr nz, .asm_239c + ld [wc0ef], a +.asm_239c + ld [wc0f0], a + scf + ret + +PlayMusic:: ; 23a1 (0:23a1) + ld b, a + ld [wc0ee], a + xor a + ld [wMusicHeaderPointer], a + ld a, c + ld [wc0ef], a + ld [wc0f0], a + ld a, b + +; plays music specified by a. If value is $ff, music is stopped +PlaySound:: ; 23b1 (0:23b1) + push hl + push de + push bc + ld b, a + ld a, [wc0ee] + and a + jr z, .asm_23c8 + xor a + ld [wc02a], a + ld [wc02b], a + ld [wc02c], a + ld [wc02d], a +.asm_23c8 + ld a, [wMusicHeaderPointer] + and a + jr z, .asm_23e3 + ld a, [wc0ee] + and a + jr z, .asm_2425 + xor a + ld [wc0ee], a + ld a, [wcfca] + cp $ff + jr nz, .asm_2414 + xor a + ld [wMusicHeaderPointer], a +.asm_23e3 + xor a + ld [wc0ee], a + ld a, [H_LOADEDROMBANK] + ld [$ffb9], a + ld a, [wc0ef] + ld [H_LOADEDROMBANK], a + ld [$2000], a + cp $2 + jr nz, .checkForBank08 +.bank02 + ld a, b + call Func_9876 + jr .asm_240b +.checkForBank08 + cp $8 + jr nz, .bank1F +.bank08 + ld a, b + call Func_22035 + jr .asm_240b +.bank1F + ld a, b + call Func_7d8ea +.asm_240b + ld a, [$ffb9] + ld [H_LOADEDROMBANK], a + ld [$2000], a + jr .asm_2425 +.asm_2414 + ld a, b + ld [wcfca], a + ld a, [wMusicHeaderPointer] + ld [wcfc8], a + ld [wcfc9], a + ld a, b + ld [wMusicHeaderPointer], a +.asm_2425 + pop bc + pop de + pop hl + ret diff --git a/home/fade.asm b/home/fade.asm new file mode 100644 index 00000000..9b55eaf2 --- /dev/null +++ b/home/fade.asm @@ -0,0 +1,73 @@ +; These routines manage gradual fading +; (e.g., entering a doorway) +LoadGBPal:: + ld a, [wd35d] ;tells if cur.map is dark (requires HM5_FLASH?) + ld b, a + ld hl, FadePal4 + ld a, l + sub b + ld l, a + jr nc, .ok + dec h +.ok + ld a, [hli] + ld [rBGP], a + ld a, [hli] + ld [rOBP0], a + ld a, [hli] + ld [rOBP1], a + ret + +GBFadeOut1:: + ld hl, FadePal1 + ld b, 4 + jr GBFadeOutCommon + +GBFadeOut2:: + ld hl, FadePal6 + ld b, 3 + +GBFadeOutCommon:: + ld a, [hli] + ld [rBGP], a + ld a, [hli] + ld [rOBP0], a + ld a, [hli] + ld [rOBP1], a + ld c, 8 + call DelayFrames + dec b + jr nz, GBFadeOutCommon + ret + +GBFadeIn1:: + ld hl, FadePal4 + 2 + ld b, 4 + jr GBFadeInCommon + +GBFadeIn2:: + ld hl, FadePal7 + 2 + ld b, 3 + +GBFadeInCommon:: + ld a, [hld] + ld [rOBP1], a + ld a, [hld] + ld [rOBP0], a + ld a, [hld] + ld [rBGP], a + ld c, 8 + call DelayFrames + dec b + jr nz, GBFadeInCommon + ret + +FadePal1:: db %11111111, %11111111, %11111111 +FadePal2:: db %11111110, %11111110, %11111000 +FadePal3:: db %11111001, %11100100, %11100100 +FadePal4:: db %11100100, %11010000, %11100000 +; rBGP rOBP0 rOBP1 +FadePal5:: db %11100100, %11010000, %11100000 +FadePal6:: db %10010000, %10000000, %10010000 +FadePal7:: db %01000000, %01000000, %01000000 +FadePal8:: db %00000000, %00000000, %00000000 diff --git a/home/init.asm b/home/init.asm new file mode 100644 index 00000000..939e81b5 --- /dev/null +++ b/home/init.asm @@ -0,0 +1,139 @@ +SoftReset:: + call StopAllSounds + call GBPalWhiteOut + ld c, $20 + call DelayFrames + ; fallthrough + +Init:: +; Program init. + +rLCDC_DEFAULT EQU %11100011 +; * LCD enabled +; * Window tile map at $9C00 +; * Window display enabled +; * BG and window tile data at $8800 +; * BG tile map at $9800 +; * 8x8 OBJ size +; * OBJ display enabled +; * BG display enabled + + di + + xor a + ld [rIF], a + ld [rIE], a + ld [$ff43], a + ld [$ff42], a + ld [$ff01], a + ld [$ff02], a + ld [$ff4b], a + ld [$ff4a], a + ld [$ff06], a + ld [$ff07], a + ld [$ff47], a + ld [$ff48], a + ld [$ff49], a + + ld a, rLCDC_ENABLE_MASK + ld [rLCDC], a + call DisableLCD + + ld sp, wStack + + ld hl, $c000 ; start of WRAM + ld bc, $2000 ; size of WRAM +.loop + ld [hl], 0 + inc hl + dec bc + ld a, b + or c + jr nz, .loop + + call ClearVram + + ld hl, $ff80 + ld bc, $ffff - $ff80 + call FillMemory + + call ClearSprites + + ld a, Bank(WriteDMACodeToHRAM) + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + call WriteDMACodeToHRAM + + xor a + ld [$ffd7], a + ld [$ff41], a + ld [$ffae], a + ld [$ffaf], a + ld [$ff0f], a + ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL + ld [rIE], a + + ld a, 144 ; move the window off-screen + ld [$ffb0], a + ld [rWY], a + ld a, 7 + ld [rWX], a + + ld a, $ff + ld [$ffaa], a + + ld h, vBGMap0 / $100 + call ClearBgMap + ld h, vBGMap1 / $100 + call ClearBgMap + + ld a, rLCDC_DEFAULT + ld [rLCDC], a + ld a, 16 + ld [hSoftReset], a + call StopAllSounds + + ei + + ld a, $40 ; PREDEF_SGB_BORDER + call Predef + + ld a, $1f + ld [wc0ef], a + ld [wc0f0], a + ld a, $9c + ld [$ffbd], a + xor a + ld [$ffbc], a + dec a + ld [wcfcb], a + + ld a, $32 ; PREDEF_INTRO + call Predef + + call DisableLCD + call ClearVram + call GBPalNormal + call ClearSprites + ld a, rLCDC_DEFAULT + ld [rLCDC], a + + jp SetDefaultNamesBeforeTitlescreen + +ClearVram: + ld hl, $8000 + ld bc, $2000 + xor a + jp FillMemory + + +StopAllSounds:: + ld a, Bank(Func_9876) + ld [wc0ef], a + ld [wc0f0], a + xor a + ld [wMusicHeaderPointer], a + ld [wc0ee], a + ld [wcfca], a + dec a + jp PlaySound diff --git a/home/pic.asm b/home/pic.asm new file mode 100644 index 00000000..6aa2e5c0 --- /dev/null +++ b/home/pic.asm @@ -0,0 +1,591 @@ +; bankswitches and runs _UncompressSpriteData +; bank is given in a, sprite input stream is pointed to in W_SPRITEINPUTPTR +UncompressSpriteData:: ; 24fd (0:24fd) + ld b, a + ld a, [H_LOADEDROMBANK] + push af + ld a, b + ld [H_LOADEDROMBANK], a + ld [$2000], a + ld a, $a + ld [$0], a + xor a + ld [$4000], a + call _UncompressSpriteData + pop af + ld [H_LOADEDROMBANK], a + ld [$2000], a + ret + +; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop +_UncompressSpriteData:: ; 251a (0:251a) + ld hl, S_SPRITEBUFFER1 + ld c, (2*SPRITEBUFFERSIZE) % $100 + ld b, (2*SPRITEBUFFERSIZE) / $100 + xor a + call FillMemory ; clear sprite buffer 1 and 2 + ld a, $1 + ld [W_SPRITEINPUTBITCOUNTER], a + ld a, $3 + ld [W_SPRITEOUTPUTBITOFFSET], a + xor a + ld [W_SPRITECURPOSX], a + ld [W_SPRITECURPOSY], a + ld [W_SPRITELOADFLAGS], a ; wd0a8 + call ReadNextInputByte ; first byte of input determines sprite width (high nybble) and height (low nybble) in tiles (8x8 pixels) + ld b, a + and $f + add a + add a + add a + ld [W_SPRITEHEIGHT], a + ld a, b + swap a + and $f + add a + add a + add a + ld [W_SPRITEWITDH], a + call ReadNextInputBit + ld [W_SPRITELOADFLAGS], a ; initialite bit1 to 0 and bit0 to the first input bit + ; this will load two chunks of data to S_SPRITEBUFFER1 and S_SPRITEBUFFER2 + ; bit 0 decides in which one the first chunk is placed + ; fall through + +; uncompresses a chunk from the sprite input data stream (pointed to at wd0da) into S_SPRITEBUFFER1 or S_SPRITEBUFFER2 +; each chunk is a 1bpp sprite. A 2bpp sprite consist of two chunks which are merged afterwards +; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack +UncompressSpriteDataLoop:: ; 2556 (0:2556) + ld hl, S_SPRITEBUFFER1 + ld a, [W_SPRITELOADFLAGS] ; wd0a8 + bit 0, a + jr z, .useSpriteBuffer1 ; check which buffer to use + ld hl, S_SPRITEBUFFER2 +.useSpriteBuffer1 + call StoreSpriteOutputPointer + ld a, [W_SPRITELOADFLAGS] ; wd0a8 + bit 1, a + jr z, .startDecompression ; check if last iteration + call ReadNextInputBit ; if last chunk, read 1-2 bit unpacking mode + and a + jr z, .unpackingMode0 ; 0 -> mode 0 + call ReadNextInputBit ; 1 0 -> mode 1 + inc a ; 1 1 -> mode 2 +.unpackingMode0 + ld [W_SPRITEUNPACKMODE], a +.startDecompression + call ReadNextInputBit + and a + jr z, .readRLEncodedZeros ; if first bit is 0, the input starts with zeroes, otherwise with (non-zero) input +.readNextInput + call ReadNextInputBit + ld c, a + call ReadNextInputBit + sla c + or c ; read next two bits into c + and a + jr z, .readRLEncodedZeros ; 00 -> RLEncoded zeroes following + call WriteSpriteBitsToBuffer ; otherwise write input to output and repeat + call MoveToNextBufferPosition + jr .readNextInput +.readRLEncodedZeros + ld c, $0 ; number of zeroes it length encoded, the number +.countConsecutiveOnesLoop ; of consecutive ones determines the number of bits the number has + call ReadNextInputBit + and a + jr z, .countConsecutiveOnesFinished + inc c + jr .countConsecutiveOnesLoop +.countConsecutiveOnesFinished + ld a, c + add a + ld hl, LengthEncodingOffsetList + add l + ld l, a + jr nc, .noCarry + inc h +.noCarry + ld a, [hli] ; read offset that is added to the number later on + ld e, a ; adding an offset of 2^length - 1 makes every integer uniquely + ld d, [hl] ; representable in the length encoding and saves bits + push de + inc c + ld e, $0 + ld d, e +.readNumberOfZerosLoop ; reads the next c+1 bits of input + call ReadNextInputBit + or e + ld e, a + dec c + jr z, .readNumberOfZerosDone + sla e + rl d + jr .readNumberOfZerosLoop +.readNumberOfZerosDone + pop hl ; add the offset + add hl, de + ld e, l + ld d, h +.writeZerosLoop + ld b, e + xor a ; write 00 to buffer + call WriteSpriteBitsToBuffer + ld e, b + call MoveToNextBufferPosition + dec de + ld a, d + and a + jr nz, .continueLoop + ld a, e + and a +.continueLoop + jr nz, .writeZerosLoop + jr .readNextInput + +; moves output pointer to next position +; also cancels the calling function if the all output is done (by removing the return pointer from stack) +; and calls postprocessing functions according to the unpack mode +MoveToNextBufferPosition:: ; 25d8 (0:25d8) + ld a, [W_SPRITEHEIGHT] + ld b, a + ld a, [W_SPRITECURPOSY] + inc a + cp b + jr z, .curColumnDone + ld [W_SPRITECURPOSY], a + ld a, [W_SPRITEOUTPUTPTR] + inc a + ld [W_SPRITEOUTPUTPTR], a + ret nz + ld a, [W_SPRITEOUTPUTPTR+1] + inc a + ld [W_SPRITEOUTPUTPTR+1], a + ret +.curColumnDone + xor a + ld [W_SPRITECURPOSY], a + ld a, [W_SPRITEOUTPUTBITOFFSET] + and a + jr z, .bitOffsetsDone + dec a + ld [W_SPRITEOUTPUTBITOFFSET], a + ld hl, W_SPRITEOUTPUTPTRCACHED + ld a, [hli] + ld [W_SPRITEOUTPUTPTR], a + ld a, [hl] + ld [W_SPRITEOUTPUTPTR+1], a + ret +.bitOffsetsDone + ld a, $3 + ld [W_SPRITEOUTPUTBITOFFSET], a + ld a, [W_SPRITECURPOSX] + add $8 + ld [W_SPRITECURPOSX], a + ld b, a + ld a, [W_SPRITEWITDH] + cp b + jr z, .allColumnsDone + ld a, [W_SPRITEOUTPUTPTR] + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + inc hl + jp StoreSpriteOutputPointer +.allColumnsDone + pop hl + xor a + ld [W_SPRITECURPOSX], a + ld a, [W_SPRITELOADFLAGS] ; wd0a8 + bit 1, a + jr nz, .done ; test if there is one more sprite to go + xor $1 + set 1, a + ld [W_SPRITELOADFLAGS], a ; wd0a8 + jp UncompressSpriteDataLoop +.done + jp UnpackSprite + +; writes 2 bits (from a) to the output buffer (pointed to from W_SPRITEOUTPUTPTR) +WriteSpriteBitsToBuffer:: ; 2649 (0:2649) + ld e, a + ld a, [W_SPRITEOUTPUTBITOFFSET] + and a + jr z, .offset0 + cp $2 + jr c, .offset1 + jr z, .offset2 + rrc e ; offset 3 + rrc e + jr .offset0 +.offset1 + sla e + sla e + jr .offset0 +.offset2 + swap e +.offset0 + ld a, [W_SPRITEOUTPUTPTR] + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + ld a, [hl] + or e + ld [hl], a + ret + +; reads next bit from input stream and returns it in a +ReadNextInputBit:: ; 2670 (0:2670) + ld a, [W_SPRITEINPUTBITCOUNTER] + dec a + jr nz, .curByteHasMoreBitsToRead + call ReadNextInputByte + ld [W_SPRITEINPUTCURBYTE], a + ld a, $8 +.curByteHasMoreBitsToRead + ld [W_SPRITEINPUTBITCOUNTER], a + ld a, [W_SPRITEINPUTCURBYTE] + rlca + ld [W_SPRITEINPUTCURBYTE], a + and $1 + ret + +; reads next byte from input stream and returns it in a +ReadNextInputByte:: ; 268b (0:268b) + ld a, [W_SPRITEINPUTPTR] + ld l, a + ld a, [W_SPRITEINPUTPTR+1] + ld h, a + ld a, [hli] + ld b, a + ld a, l + ld [W_SPRITEINPUTPTR], a + ld a, h + ld [W_SPRITEINPUTPTR+1], a + ld a, b + ret + +; the nth item is 2^n - 1 +LengthEncodingOffsetList:: ; 269f (0:269f) + dw %0000000000000001 + dw %0000000000000011 + dw %0000000000000111 + dw %0000000000001111 + dw %0000000000011111 + dw %0000000000111111 + dw %0000000001111111 + dw %0000000011111111 + dw %0000000111111111 + dw %0000001111111111 + dw %0000011111111111 + dw %0000111111111111 + dw %0001111111111111 + dw %0011111111111111 + dw %0111111111111111 + dw %1111111111111111 + +; unpacks the sprite data depending on the unpack mode +UnpackSprite:: ; 26bf (0:26bf) + ld a, [W_SPRITEUNPACKMODE] + cp $2 + jp z, UnpackSpriteMode2 + and a + jp nz, XorSpriteChunks + ld hl, S_SPRITEBUFFER1 + call SpriteDifferentialDecode + ld hl, S_SPRITEBUFFER2 + ; fall through + +; decodes differential encoded sprite data +; input bit value 0 preserves the current bit value and input bit value 1 toggles it (starting from initial value 0). +SpriteDifferentialDecode:: ; 26d4 (0:26d4) + xor a + ld [W_SPRITECURPOSX], a + ld [W_SPRITECURPOSY], a + call StoreSpriteOutputPointer + ld a, [W_SPRITEFLIPPED] + and a + jr z, .notFlipped + ld hl, DecodeNybble0TableFlipped + ld de, DecodeNybble1TableFlipped + jr .storeDecodeTablesPointers +.notFlipped + ld hl, DecodeNybble0Table + ld de, DecodeNybble1Table +.storeDecodeTablesPointers + ld a, l + ld [W_SPRITEDECODETABLE0PTR], a + ld a, h + ld [W_SPRITEDECODETABLE0PTR+1], a + ld a, e + ld [W_SPRITEDECODETABLE1PTR], a + ld a, d + ld [W_SPRITEDECODETABLE1PTR+1], a + ld e, $0 ; last decoded nybble, initialized to 0 +.decodeNextByteLoop + ld a, [W_SPRITEOUTPUTPTR] + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + ld a, [hl] + ld b, a + swap a + and $f + call DifferentialDecodeNybble ; decode high nybble + swap a + ld d, a + ld a, b + and $f + call DifferentialDecodeNybble ; decode low nybble + or d + ld b, a + ld a, [W_SPRITEOUTPUTPTR] + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + ld a, b + ld [hl], a ; write back decoded data + ld a, [W_SPRITEHEIGHT] + add l ; move on to next column + jr nc, .noCarry + inc h +.noCarry + ld [W_SPRITEOUTPUTPTR], a + ld a, h + ld [W_SPRITEOUTPUTPTR+1], a + ld a, [W_SPRITECURPOSX] + add $8 + ld [W_SPRITECURPOSX], a + ld b, a + ld a, [W_SPRITEWITDH] + cp b + jr nz, .decodeNextByteLoop ; test if current row is done + xor a + ld e, a + ld [W_SPRITECURPOSX], a + ld a, [W_SPRITECURPOSY] ; move on to next row + inc a + ld [W_SPRITECURPOSY], a + ld b, a + ld a, [W_SPRITEHEIGHT] + cp b + jr z, .done ; test if all rows finished + ld a, [W_SPRITEOUTPUTPTRCACHED] + ld l, a + ld a, [W_SPRITEOUTPUTPTRCACHED+1] + ld h, a + inc hl + call StoreSpriteOutputPointer + jr .decodeNextByteLoop +.done + xor a + ld [W_SPRITECURPOSY], a + ret + +; decodes the nybble stored in a. Last decoded data is assumed to be in e (needed to determine if initial value is 0 or 1) +DifferentialDecodeNybble:: ; 276d (0:276d) + srl a ; c=a%2, a/=2 + ld c, $0 + jr nc, .evenNumber + ld c, $1 +.evenNumber + ld l, a + ld a, [W_SPRITEFLIPPED] + and a + jr z, .notFlipped ; determine if initial value is 0 or one + bit 3, e ; if flipped, consider MSB of last data + jr .selectLookupTable +.notFlipped + bit 0, e ; else consider LSB +.selectLookupTable + ld e, l + jr nz, .initialValue1 ; load the appropriate table + ld a, [W_SPRITEDECODETABLE0PTR] + ld l, a + ld a, [W_SPRITEDECODETABLE0PTR+1] + jr .tableLookup +.initialValue1 + ld a, [W_SPRITEDECODETABLE1PTR] + ld l, a + ld a, [W_SPRITEDECODETABLE1PTR+1] +.tableLookup + ld h, a + ld a, e + add l + ld l, a + jr nc, .noCarry + inc h +.noCarry + ld a, [hl] + bit 0, c + jr nz, .selectLowNybble + swap a ; select high nybble +.selectLowNybble + and $f + ld e, a ; update last decoded data + ret + +DecodeNybble0Table:: ; 27a7 (0:27a7) + dn $0, $1 + dn $3, $2 + dn $7, $6 + dn $4, $5 + dn $f, $e + dn $c, $d + dn $8, $9 + dn $b, $a +DecodeNybble1Table:: ; 27af (0:27af) + dn $f, $e + dn $c, $d + dn $8, $9 + dn $b, $a + dn $0, $1 + dn $3, $2 + dn $7, $6 + dn $4, $5 +DecodeNybble0TableFlipped:: ; 27b7 (0:27b7) + dn $0, $8 + dn $c, $4 + dn $e, $6 + dn $2, $a + dn $f, $7 + dn $3, $b + dn $1, $9 + dn $d, $5 +DecodeNybble1TableFlipped:: ; 27bf (0:27bf) + dn $f, $7 + dn $3, $b + dn $1, $9 + dn $d, $5 + dn $0, $8 + dn $c, $4 + dn $e, $6 + dn $2, $a + +; combines the two loaded chunks with xor (the chunk loaded second is the destination). The source chunk is differeintial decoded beforehand. +XorSpriteChunks:: ; 27c7 (0:27c7) + xor a + ld [W_SPRITECURPOSX], a + ld [W_SPRITECURPOSY], a + call ResetSpriteBufferPointers + ld a, [W_SPRITEOUTPUTPTR] ; points to buffer 1 or 2, depending on flags + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + call SpriteDifferentialDecode ; decode buffer 1 or 2, depending on flags + call ResetSpriteBufferPointers + ld a, [W_SPRITEOUTPUTPTR] ; source buffer, points to buffer 1 or 2, depending on flags + ld l, a + ld a, [W_SPRITEOUTPUTPTR+1] + ld h, a + ld a, [W_SPRITEOUTPUTPTRCACHED] ; destination buffer, points to buffer 2 or 1, depending on flags + ld e, a + ld a, [W_SPRITEOUTPUTPTRCACHED+1] + ld d, a +.xorChunksLoop + ld a, [W_SPRITEFLIPPED] + and a + jr z, .notFlipped + push de + ld a, [de] + ld b, a + swap a + and $f + call ReverseNybble ; if flipped reverse the nybbles in the destination buffer + swap a + ld c, a + ld a, b + and $f + call ReverseNybble + or c + pop de + ld [de], a +.notFlipped + ld a, [hli] + ld b, a + ld a, [de] + xor b + ld [de], a + inc de + ld a, [W_SPRITECURPOSY] + inc a + ld [W_SPRITECURPOSY], a ; go to next row + ld b, a + ld a, [W_SPRITEHEIGHT] + cp b + jr nz, .xorChunksLoop ; test if column finished + xor a + ld [W_SPRITECURPOSY], a + ld a, [W_SPRITECURPOSX] + add $8 + ld [W_SPRITECURPOSX], a ; go to next column + ld b, a + ld a, [W_SPRITEWITDH] + cp b + jr nz, .xorChunksLoop ; test if all columns finished + xor a + ld [W_SPRITECURPOSX], a + ret + +; reverses the bits in the nybble given in register a +ReverseNybble:: ; 2837 (0:2837) + ld de, NybbleReverseTable + add e + ld e, a + jr nc, .asm_283f + inc d +.asm_283f + ld a, [de] + ret + +; resets sprite buffer pointers to buffer 1 and 2, depending on W_SPRITELOADFLAGS +ResetSpriteBufferPointers:: ; 2841 (0:2841) + ld a, [W_SPRITELOADFLAGS] ; wd0a8 + bit 0, a + jr nz, .buffer2Selected + ld de, S_SPRITEBUFFER1 + ld hl, S_SPRITEBUFFER2 + jr .storeBufferPointers +.buffer2Selected + ld de, S_SPRITEBUFFER2 + ld hl, S_SPRITEBUFFER1 +.storeBufferPointers + ld a, l + ld [W_SPRITEOUTPUTPTR], a + ld a, h + ld [W_SPRITEOUTPUTPTR+1], a + ld a, e + ld [W_SPRITEOUTPUTPTRCACHED], a + ld a, d + ld [W_SPRITEOUTPUTPTRCACHED+1], a + ret + +; maps each nybble to its reverse +NybbleReverseTable:: ; 2867 (0:2867) + db $0, $8, $4, $c, $2, $a, $6 ,$e, $1, $9, $5, $d, $3, $b, $7 ,$f + +; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand. +UnpackSpriteMode2:: ; 2877 (0:2877) + call ResetSpriteBufferPointers + ld a, [W_SPRITEFLIPPED] + push af + xor a + ld [W_SPRITEFLIPPED], a ; temporarily clear flipped flag for decoding the destination chunk + ld a, [W_SPRITEOUTPUTPTRCACHED] + ld l, a + ld a, [W_SPRITEOUTPUTPTRCACHED+1] + ld h, a + call SpriteDifferentialDecode + call ResetSpriteBufferPointers + pop af + ld [W_SPRITEFLIPPED], a + jp XorSpriteChunks + +; stores hl into the output pointers +StoreSpriteOutputPointer:: ; 2897 (0:2897) + ld a, l + ld [W_SPRITEOUTPUTPTR], a + ld [W_SPRITEOUTPUTPTRCACHED], a + ld a, h + ld [W_SPRITEOUTPUTPTR+1], a + ld [W_SPRITEOUTPUTPTRCACHED+1], a + ret diff --git a/home/predef.asm b/home/predef.asm new file mode 100644 index 00000000..1777d09f --- /dev/null +++ b/home/predef.asm @@ -0,0 +1,50 @@ +Predef:: +; Call predefined function a. +; To preserve other registers, have the +; destination call GetPredefRegisters. + + ; Save the predef id for GetPredefPointer. + ld [wPredefID], a + + ; A hack for LoadDestinationWarpPosition. + ; See Func_c754 (predef $19). + ld a, [H_LOADEDROMBANK] + ld [wPredefParentBank], a + + push af + ld a, BANK(GetPredefPointer) + ld [H_LOADEDROMBANK], a + ld [$2000], a + + call GetPredefPointer + + ld a, [wPredefBank] + ld [H_LOADEDROMBANK], a + ld [$2000], a + + ld de, .done + push de + jp [hl] +.done + + pop af + ld [H_LOADEDROMBANK], a + ld [$2000], a + ret + +GetPredefRegisters:: +; Restore the contents of register pairs +; when GetPredefPointer was called. + ld a, [wPredefRegisters + 0] + ld h, a + ld a, [wPredefRegisters + 1] + ld l, a + ld a, [wPredefRegisters + 2] + ld d, a + ld a, [wPredefRegisters + 3] + ld e, a + ld a, [wPredefRegisters + 4] + ld b, a + ld a, [wPredefRegisters + 5] + ld c, a + ret diff --git a/home/vblank.asm b/home/vblank.asm new file mode 100644 index 00000000..ec82eb7d --- /dev/null +++ b/home/vblank.asm @@ -0,0 +1,105 @@ +VBlank:: + + push af + push bc + push de + push hl + + ld a, [H_LOADEDROMBANK] + ld [wd122], a + + ld a, [$ffae] + ld [rSCX], a + ld a, [$ffaf] + ld [rSCY], a + + ld a, [wd0a0] + and a + jr nz, .ok + ld a, [$ffb0] + ld [rWY], a +.ok + + call AutoBgMapTransfer + call VBlankCopyBgMap + call RedrawExposedScreenEdge + call VBlankCopy + call VBlankCopyDouble + call UpdateMovingBgTiles + call $ff80 ; hOAMDMA + ld a, Bank(PrepareOAMData) + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + call PrepareOAMData + + ; VBlank-sensitive operations end. + + call Random + + ld a, [H_VBLANKOCCURRED] + and a + jr z, .vblanked + xor a + ld [H_VBLANKOCCURRED], a +.vblanked + + ld a, [H_FRAMECOUNTER] + and a + jr z, .decced + dec a + ld [H_FRAMECOUNTER], a +.decced + + call Func_28cb + + ld a, [wc0ef] ; music ROM bank + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + + cp BANK(Func_9103) + jr nz, .notbank2 +.bank2 + call Func_9103 + jr .afterMusic +.notbank2 + cp 8 + jr nz, .bank1F +.bank8 + call Func_2136e + call Func_21879 + jr .afterMusic +.bank1F + call Func_7d177 +.afterMusic + + callba Func_18dee ; keep track of time played + + ld a, [$fff9] + and a + call z, ReadJoypad + + ld a, [wd122] + ld [H_LOADEDROMBANK], a + ld [MBC3RomBank], a + + pop hl + pop de + pop bc + pop af + reti + + +DelayFrame:: +; Wait for the next vblank interrupt. +; As a bonus, this saves battery. + +NOT_VBLANKED EQU 1 + + ld a, NOT_VBLANKED + ld [H_VBLANKOCCURRED], a +.halt + halt + ld a, [H_VBLANKOCCURRED] + and a + jr nz, .halt + ret diff --git a/home/vcopy.asm b/home/vcopy.asm new file mode 100644 index 00000000..9f152841 --- /dev/null +++ b/home/vcopy.asm @@ -0,0 +1,450 @@ +; this function seems to be used only once +; it store the address of a row and column of the VRAM background map in hl +; INPUT: h - row, l - column, b - high byte of background tile map address in VRAM +GetRowColAddressBgMap:: ; 1cdd (0:1cdd) + xor a + srl h + rr a + srl h + rr a + srl h + rr a + or l + ld l,a + ld a,b + or h + ld h,a + ret + +; clears a VRAM background map with blank space tiles +; INPUT: h - high byte of background tile map address in VRAM +ClearBgMap:: ; 1cf0 (0:1cf0) + ld a," " + jr .next + ld a,l +.next + ld de,$400 ; size of VRAM background map + ld l,e +.loop + ld [hli],a + dec e + jr nz,.loop + dec d + jr nz,.loop + ret + +; When the player takes a step, a row or column of 2x2 tile blocks at the edge +; of the screen toward which they moved is exposed and has to be redrawn. +; This function does the redrawing. +RedrawExposedScreenEdge:: ; 1d01 (0:1d01) + ld a,[H_SCREENEDGEREDRAW] + and a + ret z + ld b,a + xor a + ld [H_SCREENEDGEREDRAW],a + dec b + jr nz,.redrawRow +.redrawColumn + ld hl,wScreenEdgeTiles + ld a,[H_SCREENEDGEREDRAWADDR] + ld e,a + ld a,[H_SCREENEDGEREDRAWADDR + 1] + ld d,a + ld c,18 ; screen height +.loop1 + ld a,[hli] + ld [de],a + inc de + ld a,[hli] + ld [de],a + ld a,31 + add e + ld e,a + jr nc,.noCarry + inc d +.noCarry +; the following 4 lines wrap us from bottom to top if necessary + ld a,d + and a,$03 + or a,$98 + ld d,a + dec c + jr nz,.loop1 + xor a + ld [H_SCREENEDGEREDRAW],a + ret +.redrawRow + ld hl,wScreenEdgeTiles + ld a,[H_SCREENEDGEREDRAWADDR] + ld e,a + ld a,[H_SCREENEDGEREDRAWADDR + 1] + ld d,a + push de + call .drawHalf ; draw upper half + pop de + ld a,32 ; width of VRAM background map + add e + ld e,a + ; draw lower half +.drawHalf + ld c,10 +.loop2 + ld a,[hli] + ld [de],a + inc de + ld a,[hli] + ld [de],a + ld a,e + inc a +; the following 6 lines wrap us from the right edge to the left edge if necessary + and a,$1f + ld b,a + ld a,e + and a,$e0 + or b + ld e,a + dec c + jr nz,.loop2 + ret + +; This function automatically transfers tile number data from the tile map at +; wTileMap to VRAM during V-blank. Note that it only transfers one third of the +; background per V-blank. It cycles through which third it draws. +; This transfer is turned off when walking around the map, but is turned +; on when talking to sprites, battling, using menus, etc. This is because +; the above function, RedrawExposedScreenEdge, is used when walking to +; improve efficiency. +AutoBgMapTransfer:: ; 1d57 (0:1d57) + ld a,[H_AUTOBGTRANSFERENABLED] + and a + ret z + ld hl,[sp + 0] + ld a,h + ld [H_SPTEMP],a + ld a,l + ld [H_SPTEMP + 1],a ; save stack pinter + ld a,[H_AUTOBGTRANSFERPORTION] + and a + jr z,.transferTopThird + dec a + jr z,.transferMiddleThird +.transferBottomThird + FuncCoord 0,12 + ld hl,Coord + ld sp,hl + ld a,[H_AUTOBGTRANSFERDEST + 1] + ld h,a + ld a,[H_AUTOBGTRANSFERDEST] + ld l,a + ld de,(12 * 32) + add hl,de + xor a ; TRANSFERTOP + jr .doTransfer +.transferTopThird + FuncCoord 0,0 + ld hl,Coord + ld sp,hl + ld a,[H_AUTOBGTRANSFERDEST + 1] + ld h,a + ld a,[H_AUTOBGTRANSFERDEST] + ld l,a + ld a,TRANSFERMIDDLE + jr .doTransfer +.transferMiddleThird + FuncCoord 0,6 + ld hl,Coord + ld sp,hl + ld a,[H_AUTOBGTRANSFERDEST + 1] + ld h,a + ld a,[H_AUTOBGTRANSFERDEST] + ld l,a + ld de,(6 * 32) + add hl,de + ld a,TRANSFERBOTTOM +.doTransfer + ld [H_AUTOBGTRANSFERPORTION],a ; store next portion + ld b,6 + +TransferBgRows:: ; 1d9e (0:1d9e) +; unrolled loop and using pop for speed + + rept 20 / 2 - 1 + pop de + ld [hl], e + inc l + ld [hl], d + inc l + endr + + pop de + ld [hl], e + inc l + ld [hl], d + +i ld a, 32 - (20 - 1) + add l + ld l, a + jr nc, .ok + inc h +.ok + dec b + jr nz, TransferBgRows + + ld a, [H_SPTEMP] + ld h, a + ld a, [H_SPTEMP + 1] + ld l, a + ld sp, hl + ret + +; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST. +; If H_VBCOPYBGSRC is XX00, the transfer is disabled. +VBlankCopyBgMap:: ; 1de1 (0:1de1) + ld a,[H_VBCOPYBGSRC] ; doubles as enabling byte + and a + ret z + ld hl,[sp + 0] + ld a,h + ld [H_SPTEMP],a + ld a,l + ld [H_SPTEMP + 1],a ; save stack pointer + ld a,[H_VBCOPYBGSRC] + ld l,a + ld a,[H_VBCOPYBGSRC + 1] + ld h,a + ld sp,hl + ld a,[H_VBCOPYBGDEST] + ld l,a + ld a,[H_VBCOPYBGDEST + 1] + ld h,a + ld a,[H_VBCOPYBGNUMROWS] + ld b,a + xor a + ld [H_VBCOPYBGSRC],a ; disable transfer so it doesn't continue next V-blank + jr TransferBgRows + + +VBlankCopyDouble:: +; Copy [H_VBCOPYDOUBLESIZE] 1bpp tiles +; from H_VBCOPYDOUBLESRC to H_VBCOPYDOUBLEDEST. + +; While we're here, convert to 2bpp. +; The process is straightforward: +; copy each byte twice. + + ld a, [H_VBCOPYDOUBLESIZE] + and a + ret z + + ld hl, [sp + 0] + ld a, h + ld [H_SPTEMP], a + ld a, l + ld [H_SPTEMP + 1], a + + ld a, [H_VBCOPYDOUBLESRC] + ld l, a + ld a, [H_VBCOPYDOUBLESRC + 1] + ld h, a + ld sp, hl + + ld a, [H_VBCOPYDOUBLEDEST] + ld l, a + ld a, [H_VBCOPYDOUBLEDEST + 1] + ld h, a + + ld a, [H_VBCOPYDOUBLESIZE] + ld b, a + xor a ; transferred + ld [H_VBCOPYDOUBLESIZE], a + +.loop + rept 3 + pop de + ld [hl], e + inc l + ld [hl], e + inc l + ld [hl], d + inc l + ld [hl], d + inc l + endr + + pop de + ld [hl], e + inc l + ld [hl], e + inc l + ld [hl], d + inc l + ld [hl], d + inc hl + dec b + jr nz, .loop + + ld a, l + ld [H_VBCOPYDOUBLEDEST], a + ld a, h + ld [H_VBCOPYDOUBLEDEST + 1], a + + ld hl, [sp + 0] + ld a, l + ld [H_VBCOPYDOUBLESRC], a + ld a, h + ld [H_VBCOPYDOUBLESRC + 1], a + + ld a, [H_SPTEMP] + ld h, a + ld a, [H_SPTEMP + 1] + ld l, a + ld sp, hl + + ret + + +VBlankCopy:: +; Copy [H_VBCOPYSIZE] 2bpp tiles +; from H_VBCOPYSRC to H_VBCOPYDEST. + +; Source and destination addresses +; are updated, so transfer can +; continue in subsequent calls. + + ld a, [H_VBCOPYSIZE] + and a + ret z + + ld hl, [sp + 0] + ld a, h + ld [H_SPTEMP], a + ld a, l + ld [H_SPTEMP + 1], a + + ld a, [H_VBCOPYSRC] + ld l, a + ld a, [H_VBCOPYSRC + 1] + ld h, a + ld sp, hl + + ld a, [H_VBCOPYDEST] + ld l, a + ld a, [H_VBCOPYDEST + 1] + ld h, a + + ld a, [H_VBCOPYSIZE] + ld b, a + xor a ; transferred + ld [H_VBCOPYSIZE], a + +.loop + rept 7 + pop de + ld [hl], e + inc l + ld [hl], d + inc l + endr + + pop de + ld [hl], e + inc l + ld [hl], d + inc hl + dec b + jr nz, .loop + + ld a, l + ld [H_VBCOPYDEST], a + ld a, h + ld [H_VBCOPYDEST + 1], a + + ld hl, [sp + 0] + ld a, l + ld [H_VBCOPYSRC], a + ld a, h + ld [H_VBCOPYSRC + 1], a + + ld a, [H_SPTEMP] + ld h, a + ld a, [H_SPTEMP + 1] + ld l, a + ld sp, hl + + ret + + +UpdateMovingBgTiles:: +; Animate water and flower +; tiles in the overworld. + + ld a, [$ffd7] + and a + ret z + + ld a, [$ffd8] + inc a + ld [$ffd8], a + cp $14 + ret c + cp $15 + jr z, .flower + + ld hl, vTileset + $14 * $10 + ld c, $10 + + ld a, [wd085] + inc a + and 7 + ld [wd085], a + + and 4 + jr nz, .left +.right + ld a, [hl] + rrca + ld [hli], a + dec c + jr nz, .right + jr .done +.left + ld a, [hl] + rlca + ld [hli], a + dec c + jr nz, .left +.done + ld a, [$ffd7] + rrca + ret nc + xor a + ld [$ffd8], a + ret + +.flower + xor a + ld [$ffd8], a + + ld a, [wd085] + and 3 + cp 2 + ld hl, FlowerTile1 + jr c, .copy + ld hl, FlowerTile2 + jr z, .copy + ld hl, FlowerTile3 +.copy + ld de, vTileset + $3 * $10 + ld c, $10 +.loop + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop + ret + +FlowerTile1: INCBIN "gfx/tilesets/flower/flower1.2bpp" +FlowerTile2: INCBIN "gfx/tilesets/flower/flower2.2bpp" +FlowerTile3: INCBIN "gfx/tilesets/flower/flower3.2bpp" -- cgit v1.3.1-sl0p From fadac928bccb9be1010e73df3253021312f5a2fb Mon Sep 17 00:00:00 2001 From: "U-Fish-PC\\Daniel" Date: Mon, 9 Jun 2014 16:18:29 -0400 Subject: Clean up music bank references --- audio/engine_1.asm | 2 +- audio/engine_2.asm | 2 +- audio/engine_3.asm | 2 +- engine/intro.asm | 2 +- engine/overworld/healing_machine.asm | 2 +- engine/overworld/npc_movement.asm | 4 ++-- engine/titlescreen.asm | 2 +- home/audio.asm | 16 ++++++++-------- home/init.asm | 2 +- home/vblank.asm | 10 +++++----- 10 files changed, 22 insertions(+), 22 deletions(-) (limited to 'home') diff --git a/audio/engine_1.asm b/audio/engine_1.asm index c1c4999b..4177e14d 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -1,6 +1,6 @@ ; The first of three duplicated sound engines. -Func_9103:: ; 0x9103 +Music2_UpdateMusic:: ; 0x9103 ld c, CH0 .loop ld b, $0 diff --git a/audio/engine_2.asm b/audio/engine_2.asm index b5a07c0f..037c8741 100644 --- a/audio/engine_2.asm +++ b/audio/engine_2.asm @@ -1,6 +1,6 @@ ; The second of three duplicated sound engines. -Func_21879:: ; 21879 (8:5879) +Music8_UpdateMusic:: ; 21879 (8:5879) ld c, CH0 .loop ld b, $0 diff --git a/audio/engine_3.asm b/audio/engine_3.asm index 45f890df..fabdecef 100644 --- a/audio/engine_3.asm +++ b/audio/engine_3.asm @@ -1,6 +1,6 @@ ; The third of three duplicated sound engines. -Func_7d177:: ; 7d177 (1f:5177) +Music1f_UpdateMusic:: ; 7d177 (1f:5177) ld c, CH0 .loop ld b, $0 diff --git a/engine/intro.asm b/engine/intro.asm index 8e344e48..00907065 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -322,7 +322,7 @@ PlayShootingStar: ; 4188a (10:588a) ld c, $28 call DelayFrames .asm_418d0 - ld a, Bank(Func_7d8ea) + ld a, BANK(Music_IntroBattle) ld [wc0ef], a ld [wc0f0], a ld a, MUSIC_INTRO_BATTLE diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index f9636fcb..a30a5dff 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -41,7 +41,7 @@ AnimateHealingMachine: ; 70433 (1c:4433) ld a, $ff ld [wc0ee], a call PlaySound - ld a, Bank(Func_9876) + ld a, BANK(Music_PkmnHealed) ld [wc0ef], a .asm_70495 ld a, MUSIC_PKMN_HEALED diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index 234b7645..260dafd9 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -158,7 +158,7 @@ PointerTable_1a510: ; 1a510 (6:6510) dw Func_1a56b Func_1a514: ; 1a514 (6:6514) - ld a, Bank(Func_9876) + ld a, BANK(Music_MuseumGuy) ld [wc0ef], a ld [wc0f0], a ld a, MUSIC_MUSEUM_GUY @@ -215,7 +215,7 @@ PointerTable_1a57d: ; 1a57d (6:657d) dw Func_1a56b Func_1a581: ; 1a581 (6:6581) - ld a, Bank(Func_9876) + ld a, BANK(Music_MuseumGuy) ld [wc0ef], a ld [wc0f0], a ld a, MUSIC_MUSEUM_GUY diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 10081d63..e281af31 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -17,7 +17,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7) ld [hli], a ld [hli], a ld [hl], a - ld a, Bank(Func_7d8ea) + ld a, BANK(Music_TitleScreen) ld [wc0ef], a ld [wc0f0], a diff --git a/home/audio.asm b/home/audio.asm index 724b8c5f..fa62cc8a 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -30,7 +30,7 @@ asm_2324:: ; 2324 (0:2324) ld b, a ld a, d and a - ld a, Bank(Func_7d8ea) + ld a, BANK(Music_BikeRiding) jr nz, .asm_233e ld [wc0ef], a .asm_233e @@ -56,19 +56,19 @@ asm_2324:: ; 2324 (0:2324) Func_235f:: ; 235f (0:235f) ld a, [wc0ef] ld b, a - cp $2 + cp BANK(Music2_UpdateMusic) jr nz, .checkForBank08 .bank02 - ld hl, Func_9103 + ld hl, Music2_UpdateMusic jr .asm_2378 .checkForBank08 - cp $8 + cp BANK(Music8_UpdateMusic) jr nz, .bank1F .bank08 - ld hl, Func_21879 + ld hl, Music8_UpdateMusic jr .asm_2378 .bank1F - ld hl, Func_7d177 + ld hl, Music1f_UpdateMusic .asm_2378 ld c, $6 .asm_237a @@ -147,14 +147,14 @@ PlaySound:: ; 23b1 (0:23b1) ld a, [wc0ef] ld [H_LOADEDROMBANK], a ld [$2000], a - cp $2 + cp BANK(Func_9876) jr nz, .checkForBank08 .bank02 ld a, b call Func_9876 jr .asm_240b .checkForBank08 - cp $8 + cp BANK(Func_22035) jr nz, .bank1F .bank08 ld a, b diff --git a/home/init.asm b/home/init.asm index 939e81b5..ef5b5bb9 100644 --- a/home/init.asm +++ b/home/init.asm @@ -128,7 +128,7 @@ ClearVram: StopAllSounds:: - ld a, Bank(Func_9876) + ld a, BANK(Music2_UpdateMusic) ld [wc0ef], a ld [wc0f0], a xor a diff --git a/home/vblank.asm b/home/vblank.asm index ec82eb7d..15f91437 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -56,20 +56,20 @@ VBlank:: ld [H_LOADEDROMBANK], a ld [MBC3RomBank], a - cp BANK(Func_9103) + cp BANK(Music2_UpdateMusic) jr nz, .notbank2 .bank2 - call Func_9103 + call Music2_UpdateMusic jr .afterMusic .notbank2 - cp 8 + cp BANK(Music8_UpdateMusic) jr nz, .bank1F .bank8 call Func_2136e - call Func_21879 + call Music8_UpdateMusic jr .afterMusic .bank1F - call Func_7d177 + call Music1f_UpdateMusic .afterMusic callba Func_18dee ; keep track of time played -- cgit v1.3.1-sl0p From f4e2814381364f295367d1b8da0ad9f73fc565d1 Mon Sep 17 00:00:00 2001 From: "U-Fish-PC\\Daniel" Date: Tue, 10 Jun 2014 01:10:11 -0400 Subject: More music bank references Now the AUDIO constants in audio.asm can be edited freely --- engine/oak_speech.asm | 2 +- home/init.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'home') diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 03c41e12..a85449df 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -131,7 +131,7 @@ Func_61bc: ; 61bc (1:61bc) call ResetPlayerSpriteData ld a,[H_LOADEDROMBANK] push af - ld a,2 + ld a, BANK(Music_PalletTown) ld [wc0ef],a ld [wc0f0],a ld a,$A diff --git a/home/init.asm b/home/init.asm index ef5b5bb9..1518218e 100644 --- a/home/init.asm +++ b/home/init.asm @@ -98,7 +98,7 @@ rLCDC_DEFAULT EQU %11100011 ld a, $40 ; PREDEF_SGB_BORDER call Predef - ld a, $1f + ld a, BANK(SFX_1f_67) ld [wc0ef], a ld [wc0f0], a ld a, $9c -- cgit v1.3.1-sl0p From 53ae0e93fad9f4c3eaef92f102b1eeb531e59d68 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 14 Jun 2014 04:12:40 -0700 Subject: Use monster struct macros in wram. Rename related labels for consistency. --- constants/misc_constants.asm | 4 + constants/move_constants.asm | 2 +- engine/battle/1.asm | 8 +- engine/battle/14.asm | 8 +- engine/battle/15.asm | 64 ++--- engine/battle/16.asm | 14 +- engine/battle/1a.asm | 4 +- engine/battle/1c.asm | 6 +- engine/battle/4_2.asm | 30 +- engine/battle/5.asm | 4 +- engine/battle/a.asm | 4 +- engine/battle/animations.asm | 18 +- engine/battle/b_2.asm | 4 +- engine/battle/c.asm | 8 +- engine/battle/core.asm | 538 +++++++++++++++++------------------ engine/battle/d.asm | 2 +- engine/battle/e.asm | 90 +++--- engine/battle/e_2.asm | 20 +- engine/battle/safari_zone.asm | 2 +- engine/cable_club.asm | 34 +-- engine/evolve_trade.asm | 2 +- engine/evos_moves.asm | 10 +- engine/give_pokemon.asm | 4 +- engine/hall_of_fame.asm | 10 +- engine/in_game_trades.asm | 14 +- engine/items/items.asm | 124 ++++---- engine/items/tmhm.asm | 2 +- engine/learn_move.asm | 8 +- engine/menu/bills_pc.asm | 22 +- engine/menu/diploma.asm | 4 +- engine/menu/league_pc.asm | 2 +- engine/menu/main_menu.asm | 4 +- engine/menu/naming_screen.asm | 2 +- engine/menu/party_menu.asm | 6 +- engine/menu/start_sub_menus.asm | 34 +-- engine/menu/status_screen.asm | 12 +- engine/mon_party_sprites.asm | 2 +- engine/oak_speech.asm | 4 +- engine/oak_speech2.asm | 4 +- engine/overworld/cut.asm | 2 +- engine/overworld/healing_machine.asm | 2 +- engine/palettes.asm | 4 +- engine/predefs17_2.asm | 2 +- engine/save.asm | 8 +- engine/titlescreen.asm | 2 +- engine/trade.asm | 6 +- home.asm | 30 +- home/text.asm | 6 +- main.asm | 182 ++++++------ scripts/daycarem.asm | 20 +- scripts/namerater.asm | 6 +- text.asm | 56 ++-- wram.asm | 416 +++++++++------------------ 53 files changed, 859 insertions(+), 1017 deletions(-) (limited to 'home') diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm index c1d00464..9621b843 100644 --- a/constants/misc_constants.asm +++ b/constants/misc_constants.asm @@ -8,3 +8,7 @@ D_UP EQU %01000000 D_DOWN EQU %10000000 MAX_LEVEL EQU 100 +NUM_MOVES EQU 4 + +MONS_PER_BOX EQU 20 +NUM_BOXES EQU 12 diff --git a/constants/move_constants.asm b/constants/move_constants.asm index 9fdb1ce7..816bd115 100644 --- a/constants/move_constants.asm +++ b/constants/move_constants.asm @@ -1,4 +1,4 @@ -NUM_MOVES EQU $A4 +NUM_ATTACKS EQU $A4 POUND EQU $01 KARATE_CHOP EQU $02 diff --git a/engine/battle/1.asm b/engine/battle/1.asm index 3ae20351..8c0466d4 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -11,13 +11,13 @@ DrainHPEffect_: ; 783f (1:783f) inc hl inc [hl] .asm_784f - ld hl, W_PLAYERMONCURHP ; wd015 - ld de, W_PLAYERMONMAXHP ; wd023 + ld hl, wBattleMonHP ; wd015 + ld de, wBattleMonMaxHP ; wd023 ld a, [H_WHOSETURN] ; $fff3 and a jp z, Func_7861 - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP - ld de, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonHP ; wEnemyMonHP + ld de, wEnemyMonMaxHP ; wEnemyMonMaxHP Func_7861: ; 7861 (1:7861) ld bc, wHPBarOldHP+1 diff --git a/engine/battle/14.asm b/engine/battle/14.asm index 473afac0..01d115a6 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -11,8 +11,8 @@ Func_525af: ; 525af (14:65af) ld [hl], a ld [wListScrollOffset], a ; wcc36 ld [wd05e], a - ld [W_PLAYERMONID], a - ld [W_PLAYERMONSALIVEFLAGS], a + ld [wBattleMonSpecies], a + ld [wPartyAliveFlags], a ld [wPlayerMonNumber], a ; wPlayerMonNumber ld [wd078], a ld [wd35d], a @@ -40,12 +40,12 @@ Func_525af: ; 525af (14:65af) jp Bankswitch ParalyzeEffect_: ; 52601 (14:6601) - ld hl, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonStatus ; wcfe9 ld de, W_PLAYERMOVETYPE ; wcfd5 ld a, [H_WHOSETURN] ; $fff3 and a jp z, .asm_52613 - ld hl, W_PLAYERMONSTATUS ; W_PLAYERMONSTATUS + ld hl, wBattleMonStatus ; wBattleMonStatus ld de, W_ENEMYMOVETYPE ; wcfcf .asm_52613 diff --git a/engine/battle/15.asm b/engine/battle/15.asm index 7966e634..d6d59d5f 100755 --- a/engine/battle/15.asm +++ b/engine/battle/15.asm @@ -1,11 +1,11 @@ GainExperience: ; 5524f (15:524f) - ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE + ld a, [W_ISLINKBATTLE] cp $4 ret z call Func_5546c - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMons xor a - ld [wWhichPokemon], a ; wWhichPokemon + ld [wWhichPokemon], a Func_5525f: ; 5525f (15:525f) inc hl @@ -13,8 +13,8 @@ Func_5525f: ; 5525f (15:525f) or [hl] jp z, Func_55436 push hl - ld hl, W_PLAYERMONSALIVEFLAGS - ld a, [wWhichPokemon] ; wWhichPokemon + ld hl, wPartyAliveFlags + ld a, [wWhichPokemon] ld c, a ld b, $2 ld a, $10 ; FlagActionPredef @@ -56,26 +56,26 @@ Func_5525f: ; 5525f (15:525f) jr .asm_55285 .asm_552a1 xor a - ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld [$ff97], a + ld [H_MULTIPLICAND], a + ld [H_MULTIPLICAND + 1], a ld a, [wd008] - ld [$ff98], a - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) + ld [H_MULTIPLICAND + 2], a + ld a, [wEnemyMonLevel] + ld [H_MULTIPLIER], a call Multiply - ld a, $7 - ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) - ld b, $4 + ld a, 7 + ld [H_DIVISOR], a + ld b, 4 call Divide ld hl, $fff2 add hl, de ld b, [hl] inc hl - ld a, [wPlayerID] ; wPlayerID + ld a, [wPlayerID] cp b jr nz, .asm_552d1 ld b, [hl] - ld a, [wPlayerID + 1] ; wd35a + ld a, [wPlayerID + 1] cp b ld a, $0 jr z, .asm_552d6 @@ -84,7 +84,7 @@ Func_5525f: ; 5525f (15:525f) ld a, $1 .asm_552d6 ld [wcf4d], a - ld a, [W_ISINBATTLE] ; W_ISINBATTLE + ld a, [W_ISINBATTLE] dec a call nz, Func_5549f inc hl @@ -107,17 +107,17 @@ Func_5525f: ; 5525f (15:525f) .asm_552f8 inc hl push hl - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] ld c, a - ld b, $0 - ld hl, W_PARTYMON1 ; W_PARTYMON1 + ld b, 0 + ld hl, wPartySpecies add hl, bc ld a, [hl] ld [wd0b5], a call GetMonHeader ld d, MAX_LEVEL callab CalcExperience - ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND) + ld a, [$ff96] ld b, a ld a, [$ff97] ld c, a @@ -140,8 +140,8 @@ Func_5525f: ; 5525f (15:525f) dec hl .asm_5532e push hl - ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld a, [wWhichPokemon] + ld hl, wPartyMonNicks call GetPartyMonName ld hl, GainedText call PrintText @@ -157,11 +157,11 @@ Func_5525f: ; 5525f (15:525f) ld a, [hl] cp d jp z, Func_55436 - ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL + ld a, [W_CURENEMYLVL] push af push hl ld a, d - ld [W_CURENEMYLVL], a ; W_CURENEMYLVL + ld [W_CURENEMYLVL], a ld [hl], a ld bc, $ffdf add hl, bc @@ -198,12 +198,12 @@ Func_5525f: ; 5525f (15:525f) ld a, [hl] adc b ld [hl], a - ld a, [wPlayerMonNumber] ; wPlayerMonNumber + ld a, [wPlayerMonNumber] ld b, a - ld a, [wWhichPokemon] ; wWhichPokemon + ld a, [wWhichPokemon] cp b jr nz, .asm_553f7 - ld de, W_PLAYERMONCURHP ; wd015 + ld de, wBattleMonHP ld a, [hli] ld [de], a inc de @@ -212,7 +212,7 @@ Func_5525f: ; 5525f (15:525f) ld bc, $1f add hl, bc push hl - ld de, W_PLAYERMONLEVEL ; W_PLAYERMONLEVEL + ld de, wBattleMonLevel ; wBattleMonLevel ld bc, $b call CopyData pop hl @@ -258,7 +258,7 @@ Func_5525f: ; 5525f (15:525f) ld [W_CURENEMYLVL], a ; W_CURENEMYLVL Func_55436: ; 55436 (15:5436) - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount ld b, a ld a, [wWhichPokemon] ; wWhichPokemon inc a @@ -266,11 +266,11 @@ Func_55436: ; 55436 (15:5436) jr z, .asm_55450 ld [wWhichPokemon], a ; wWhichPokemon ld bc, $2c - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) call AddNTimes jp Func_5525f .asm_55450 - ld hl, W_PLAYERMONSALIVEFLAGS + ld hl, wPartyAliveFlags xor a ld [hl], a ld a, [wPlayerMonNumber] ; wPlayerMonNumber @@ -287,7 +287,7 @@ Func_55436: ; 55436 (15:5436) jp Predef Func_5546c: ; 5546c (15:546c) - ld a, [W_PLAYERMONSALIVEFLAGS] + ld a, [wPartyAliveFlags] ld b, a xor a ld c, $8 diff --git a/engine/battle/16.asm b/engine/battle/16.asm index 0b41d875..1500d003 100755 --- a/engine/battle/16.asm +++ b/engine/battle/16.asm @@ -8,7 +8,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) cp LAVENDER_HOUSE_1 jr c, .pokemonTower .notPokemonTower - ld a, [W_ENEMYMONID] + ld a, [wEnemyMonSpecies2] call PlayCry ld hl, WildMonAppearedText ld a, [W_MOVEMISSED] ; W_MOVEMISSED @@ -31,7 +31,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) .pokemonTower ld b, SILPH_SCOPE call IsItemInBag - ld a, [W_ENEMYMONID] + ld a, [wEnemyMonSpecies2] ld [wcf91], a cp MAROWAK jr z, .isMarowak @@ -95,14 +95,14 @@ GhostCantBeIDdText: ; 58e54 (16:4e54) db "@" SendOutMon: ; 58e59 (16:4e59) - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] or [hl] ld hl, GoText jr z, .printText xor a ld [H_NUMTOPRINT], a ; $ff96 (aliases: H_MULTIPLICAND) - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] ld [wcce3], a ld [$ff97], a @@ -112,7 +112,7 @@ SendOutMon: ; 58e59 (16:4e59) ld a, $19 ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) call Multiply - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP ld a, [hli] ld b, [hl] srl a @@ -173,7 +173,7 @@ PlayerMon2Text: ; 58ed7 (16:4ed7) db $08 ; asm push de push bc - ld hl, W_ENEMYMONCURHP + 1 + ld hl, wEnemyMonHP + 1 ld de, wcce4 ld b, [hl] dec hl @@ -188,7 +188,7 @@ PlayerMon2Text: ; 58ed7 (16:4ed7) ld a, $19 ld [H_POWEROFTEN], a call Multiply - ld hl, W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ld a, [hli] ld b, [hl] srl a diff --git a/engine/battle/1a.asm b/engine/battle/1a.asm index 2578621c..6b502a31 100755 --- a/engine/battle/1a.asm +++ b/engine/battle/1a.asm @@ -11,7 +11,7 @@ DecrementPP: ; 68000 (1a:4000) ret nz ; if any of these statuses are true, don't decrement PP bit 6, [hl] ; check 6th bit status flag on W_PLAYERBATTSTATUS2 ret nz ; and return if it is set - ld hl, W_PLAYERMONPP ; PP of first move (in battle) + ld hl, wBattleMonPP ; PP of first move (in battle) call .DecrementPP ld a, [W_PLAYERBATTSTATUS3] ; load pokemon status bits? @@ -26,7 +26,7 @@ DecrementPP: ; 68000 (1a:4000) ; its opponent, which is *not* the same as its real PP as part of your ; party. So we return, and don't do that part. - ld hl, W_PARTYMON1_MOVE1PP ; PP of first move (in party) + ld hl, wPartyMon1PP ; PP of first move (in party) ld a, [wPlayerMonNumber] ; which mon in party is active ld bc, $2C ; XXX probably size of party pokemon's data structure call AddNTimes ; calculate address of the mon to modify diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index d936c7e5..242b8d66 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -170,16 +170,16 @@ GetBattleTransitionID_WildOrTrainer: ; 709e2 (1c:49e2) ret GetBattleTransitionID_CompareLevels: ; 709ef (1c:49ef) - ld hl, W_PARTYMON1_HP + ld hl, wPartyMon1HP .faintedLoop ld a, [hli] or [hl] jr nz, .notFainted - ld de, W_PARTYMON2DATA - (W_PARTYMON1DATA + 1) + ld de, wPartyMon2 - (wPartyMon1 + 1) add hl, de jr .faintedLoop .notFainted - ld de, W_PARTYMON1_LEVEL - (W_PARTYMON1_HP + 1) + ld de, wPartyMon1Level - (wPartyMon1HP + 1) add hl, de ld a, [hl] add $3 diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index 881a0f60..d7625a59 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -2,11 +2,11 @@ Func_137aa: ; 137aa (4:77aa) ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE cp $4 jr nz, .asm_137eb - ld a, [W_ENEMYMONNUMBER] ; W_ENEMYMONNUMBER - ld hl, wd8a8 - ld bc, $2c + ld a, [wEnemyMonPartyPos] + ld hl, wEnemyMon1Status + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes - ld a, [W_ENEMYMONSTATUS] ; wcfe9 + ld a, [wEnemyMonStatus] ; wcfe9 ld [hl], a call ClearScreen callab Func_372d6 @@ -151,7 +151,7 @@ Func_13870: ; 13870 (4:7870) ld a, [Coord] cp $14 jr nz, .asm_138e5 - ld hl, W_WATERMONS ; wd8a5 (aliases: W_ENEMYMON1HP) + ld hl, W_WATERMONS ; wd8a5 (aliases: wEnemyMon1HP) .asm_138e5 ld b, $0 add hl, bc @@ -159,11 +159,11 @@ Func_13870: ; 13870 (4:7870) ld [W_CURENEMYLVL], a ; W_CURENEMYLVL ld a, [hl] ld [wcf91], a - ld [W_ENEMYMONID], a + ld [wEnemyMonSpecies2], a ld a, [wd0db] and a jr z, .asm_13916 - ld a, [W_PARTYMON1_LEVEL] ; W_PARTYMON1_LEVEL + ld a, [wPartyMon1Level] ; wPartyMon1Level ld b, a ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL cp b @@ -203,10 +203,10 @@ RecoilEffect_: ; 1392c (4:792c) ld a, [H_WHOSETURN] ; $fff3 and a ld a, [W_PLAYERMOVENUM] ; wcfd2 - ld hl, W_PLAYERMONMAXHP ; wd023 + ld hl, wBattleMonMaxHP ; wd023 jr z, .asm_1393d ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP .asm_1393d ld d, a ld a, [W_DAMAGE] ; W_DAMAGE @@ -272,8 +272,8 @@ HitWithRecoilText: ; 1399e (4:799e) db "@" ConversionEffect_: ; 139a3 (4:79a3) - ld hl, W_ENEMYMONTYPE1 - ld de, W_PLAYERMONTYPE1 + ld hl, wEnemyMonType1 + ld de, wBattleMonType1 ld a, [H_WHOSETURN] and a ld a, [W_ENEMYBATTSTATUS1] @@ -313,17 +313,17 @@ HazeEffect_: ; 139da (4:79da) ld hl, wEnemyMonAttackMod call Func_13a43 ld hl, wcd12 - ld de, W_PLAYERMONATK + ld de, wBattleMonAttack call Func_13a4a ld hl, wcd26 - ld de, W_ENEMYMONATTACK + ld de, wEnemyMonAttack call Func_13a4a - ld hl, W_ENEMYMONSTATUS + ld hl, wEnemyMonStatus ld de, wEnemySelectedMove ld a, [H_WHOSETURN] and a jr z, .asm_13a09 - ld hl, W_PLAYERMONSTATUS + ld hl, wBattleMonStatus dec de .asm_13a09 diff --git a/engine/battle/5.asm b/engine/battle/5.asm index 18e74ff1..6c7a642e 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -1,13 +1,13 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld c, 50 call DelayFrames - ld hl, W_PLAYERMONMAXHP + ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, W_PLAYERBATTSTATUS2 ld a, [$fff3] ;whose turn? and a jr z, .notEnemy - ld hl, W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ld de, wEnemySubstituteHP ld bc, W_ENEMYBATTSTATUS2 .notEnemy diff --git a/engine/battle/a.asm b/engine/battle/a.asm index cd1b34dc..fd3ef40b 100755 --- a/engine/battle/a.asm +++ b/engine/battle/a.asm @@ -4,12 +4,12 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) and a jr nz, .asm_2bee7 ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 - ld de, W_ENEMYMONTYPE1 ; wcfea (aliases: W_ENEMYMONTYPES) + ld de, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_2bec8 ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld de, W_PLAYERMONTYPE1 ; wd019 (aliases: W_PLAYERMONTYPES) + ld de, wBattleMonType1 ; wd019 (aliases: wBattleMonType) .asm_2bec8 ld a, [de] cp GRASS diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index e3ee4fe0..6e5e9903 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1488,9 +1488,9 @@ AnimationBlinkMon: ; 7936f (1e:536f) AnimationFlashMonPic: ; 79389 (1e:5389) ; Flashes the mon's sprite on and off - ld a, [W_PLAYERMONID] + ld a, [wBattleMonSpecies] ld [wHPBarMaxHP + 1], a - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wHPBarMaxHP], a jp Func_79793 @@ -2117,9 +2117,9 @@ AnimationBoundUpAndDown: ; 7977a (1e:577a) AnimationTransformMon: ; 79787 (1e:5787) ; Redraws this mon's sprite as the back/front sprite of the opposing mon. ; Used in Transform. - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wHPBarMaxHP + 1], a - ld a, [W_PLAYERMONID] + ld a, [wBattleMonSpecies] ld [wHPBarMaxHP], a Func_79793: ; 79793 (1e:5793) @@ -2137,10 +2137,10 @@ Func_79793: ; 79793 (1e:5793) call LoadFrontSpriteByMonIndex jr .asm_797d3 .asm_797b0 - ld a, [wcfd9] + ld a, [wBattleMonSpecies2] push af ld a, [wHPBarMaxHP + 1] - ld [wcfd9], a + ld [wBattleMonSpecies2], a ld [wd0b5], a call GetMonHeader ld a, $4 @@ -2150,7 +2150,7 @@ Func_79793: ; 79793 (1e:5793) call Func_79820 call Func_79aae pop af - ld [wcfd9], a + ld [wBattleMonSpecies2], a .asm_797d3 ld b, $1 jp GoPAL_SET @@ -2291,10 +2291,10 @@ Func_7986f: ; 7986f (1e:586f) ld a,[H_WHOSETURN] and a jr nz,.next - ld a,[W_PLAYERMONID] ; get number of current monster + ld a,[wBattleMonSpecies] ; get number of current monster jr .Continue .next - ld a,[wcfe5] + ld a,[wEnemyMonSpecies] .Continue push hl call GetCryData diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm index 6ec58cc0..3c839cba 100755 --- a/engine/battle/b_2.asm +++ b/engine/battle/b_2.asm @@ -90,9 +90,9 @@ PayDayEffect_ ; 2feb8 (b:7eb8) ld [hli], a ld a, [$fff3] and a - ld a, [W_PLAYERMONLEVEL] + ld a, [wBattleMonLevel] jr z, .asm_2fec8 ; 0x2fec3 $3 - ld a, [W_ENEMYMONLEVEL] + ld a, [wEnemyMonLevel] .asm_2fec8 add a ld [$ff98], a diff --git a/engine/battle/c.asm b/engine/battle/c.asm index bc3788de..c1347d24 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -27,13 +27,13 @@ OneHitKOEffect_: ; 33f57 (c:7f57) ld [hl], a ; set the damage output to zero dec a ld [wd05e], a - ld hl, W_PLAYERMONSPEED + 1 - ld de, W_ENEMYMONSPEED + 1 + ld hl, wBattleMonSpeed + 1 + ld de, wEnemyMonSpeed + 1 ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_33f72 - ld hl, W_ENEMYMONSPEED + 1 - ld de, W_PLAYERMONSPEED + 1 + ld hl, wEnemyMonSpeed + 1 + ld de, wBattleMonSpeed + 1 .asm_33f72 ld a, [de] dec de diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b6d8b78e..a9f681de 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -216,12 +216,12 @@ Func_3c110: ; 3c110 (f:4110) Func_3c11e: ; 3c11e (f:411e) xor a - ld [W_PLAYERMONSALIVEFLAGS], a + ld [wPartyAliveFlags], a ld [wccf5], a ld [wcd6a], a inc a ld [wd11d], a - ld hl, W_ENEMYMON1HP ; wd8a5 + ld hl, wEnemyMon1HP ; wd8a5 ld bc, $2b ld d, $3 .asm_3c134 @@ -263,7 +263,7 @@ Func_3c11e: ; 3c11e (f:411e) jp PrintText .asm_3c17a callab PrintSafariZoneBattleText - ld a, [W_ENEMYMONSPEED + 1] + ld a, [wEnemyMonSpeed + 1] add a ld b, a jp c, asm_3c202 @@ -302,13 +302,13 @@ Func_3c1ad: ; 3c1ad (f:41ad) ld a, [wWhichPokemon] ; wWhichPokemon ld [wPlayerMonNumber], a ; wPlayerMonNumber inc a - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount ld c, a ld b, $0 add hl, bc ld a, [hl] ld [wcf91], a - ld [wcfd9], a + ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 FuncCoord 1, 5 ld hl, Coord @@ -319,7 +319,7 @@ Func_3c1ad: ; 3c1ad (f:41ad) ld c, a ld b, $1 push bc - ld hl, W_PLAYERMONSALIVEFLAGS + ld hl, wPartyAliveFlags ld a, $10 ; FlagActionPredef call Predef ld hl, wccf5 @@ -359,11 +359,11 @@ EnemyRanText: ; 3c22e (f:422e) MainInBattleLoop: ; 3c233 (f:4233) call ReadPlayerMonCurHPAndStatus - ld hl, W_PLAYERMONCURHP + ld hl, wBattleMonHP ld a, [hli] or [hl] jp z, HandlePlayerMonFainted ; test if current player mon is fainted - ld hl, W_ENEMYMONCURHP + ld hl, wEnemyMonHP ld a, [hli] or [hl] jp z, HandleEnemyMonFainted @@ -385,7 +385,7 @@ MainInBattleLoop: ; 3c233 (f:4233) ld a, [wd078] and a ret nz - ld a, [W_PLAYERMONSTATUS] + ld a, [wBattleMonStatus] and $27 jr nz, .asm_3c2a6 ; 0x3c271 $33 ld a, [W_PLAYERBATTSTATUS1] @@ -430,7 +430,7 @@ MainInBattleLoop: ; 3c233 (f:4233) bit 5, a jr z, .asm_3c2dd ; 0x3c2c9 $12 ld a, [wPlayerMoveListIndex] - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves ld c, a ld b, $0 add hl, bc @@ -464,8 +464,8 @@ MainInBattleLoop: ; 3c233 (f:4233) cp COUNTER jr z, .playerMovesFirst .compareSpeed - ld de, W_PLAYERMONSPEED ; player speed value - ld hl, W_ENEMYMONSPEED ; enemy speed value + ld de, wBattleMonSpeed ; player speed value + ld hl, wEnemyMonSpeed ; enemy speed value ld c, $2 call StringCmp ; compare speed values jr z, .speedEqual @@ -542,13 +542,13 @@ MainInBattleLoop: ; 3c233 (f:4233) jp MainInBattleLoop HandlePoisonBurnLeechSeed: ; 3c3bd (f:43bd) - ld hl, W_PLAYERMONCURHP ; wd015 - ld de, W_PLAYERMONSTATUS ; W_PLAYERMONSTATUS + ld hl, wBattleMonHP ; wd015 + ld de, wBattleMonStatus ; wBattleMonStatus ld a, [H_WHOSETURN] ; $fff3 and a jr z, .playersTurn - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP - ld de, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonHP ; wEnemyMonHP + ld de, wEnemyMonStatus ; wcfe9 .playersTurn ld a, [de] and (1 << BRN) | (1 << PSN) @@ -690,11 +690,11 @@ HandlePoisonBurnLeechSeed_DecreaseOwnHP: ; 3c43d (f:443d) ; adds bc to enemy HP HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) push hl - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP ld a, [H_WHOSETURN] ; $fff3 and a jr z, .playersTurn - ld hl, W_PLAYERMONMAXHP ; wd023 + ld hl, wBattleMonMaxHP ; wd023 .playersTurn ld a, [hli] ld [wHPBarMaxHP+1], a @@ -778,7 +778,7 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) ld a, d and a jp z, HandlePlayerBlackOut - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld a, [hli] or [hl] call nz, Func_3cd60 @@ -787,7 +787,7 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) ret z call AnyEnemyPokemonAliveCheck jp z, TrainerBattleVictory - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld a, [hli] or [hl] jr nz, .asm_3c555 @@ -808,8 +808,8 @@ FaintEnemyPokemon ; 0x3c567 ld a, [W_ISINBATTLE] ; W_ISINBATTLE dec a jr z, .wild - ld a, [W_ENEMYMONNUMBER] ; W_ENEMYMONNUMBER - ld hl, W_ENEMYMON1HP + ld a, [wEnemyMonPartyPos] + ld hl, wEnemyMon1HP ld bc, $2c ; mon struct len call AddNTimes xor a @@ -861,7 +861,7 @@ FaintEnemyPokemon ; 0x3c567 ld a, MUSIC_DEFEATED_WILD_MON call PlayBattleVictoryMusic .sfxplayed - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld a, [hli] or [hl] jr nz, .playermonnotfaint @@ -899,7 +899,7 @@ FaintEnemyPokemon ; 0x3c567 ret z ld a, $1 ld [wcc5b], a - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount ld b, $0 .asm_3c62c scf @@ -907,7 +907,7 @@ FaintEnemyPokemon ; 0x3c567 dec a jr nz, .asm_3c62c ld a, b - ld [W_PLAYERMONSALIVEFLAGS], a + ld [wPartyAliveFlags], a ld hl, GainExperience ld b, BANK(GainExperience) jp Bankswitch @@ -928,7 +928,7 @@ AnyEnemyPokemonAliveCheck: ; 3c64f (f:464f) ld a, [wEnemyPartyCount] ; wEnemyPartyCount ld b, a xor a - ld hl, W_ENEMYMON1HP ; wd8a5 + ld hl, wEnemyMon1HP ; wd8a5 ld de, $2c .asm_3c65a or [hl] @@ -1025,7 +1025,7 @@ HandlePlayerMonFainted: ; 3c700 (f:4700) ld a, d and a jp z, HandlePlayerBlackOut - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] or [hl] jr nz, .enemyMonNotFainted @@ -1051,7 +1051,7 @@ HandlePlayerMonFainted: ; 3c700 (f:4700) Func_3c741: ; 3c741 (f:4741) ld a, [wPlayerMonNumber] ; wPlayerMonNumber ld c, a - ld hl, W_PLAYERMONSALIVEFLAGS ; clear fainted mon's alive flag + ld hl, wPartyAliveFlags ; clear fainted mon's alive flag ld b, $0 ld a, $10 ; FlagActionPredef call Predef @@ -1067,7 +1067,7 @@ Func_3c741: ; 3c741 (f:4741) ld hl, wcd05 ld [hli], a ld [hl], a - ld [W_PLAYERMONSTATUS], a ; W_PLAYERMONSTATUS + ld [wBattleMonStatus], a ; wBattleMonStatus call ReadPlayerMonCurHPAndStatus FuncCoord 9, 7 ld hl, Coord @@ -1083,7 +1083,7 @@ Func_3c741: ; 3c741 (f:4741) ld a, [wccf0] and a ret z - ld a, [W_PLAYERMONID] + ld a, [wBattleMonSpecies] call PlayCry ld hl, PlayerMonFaintedText jp PrintText @@ -1117,8 +1117,8 @@ Func_3c79b: ; 3c79b (f:479b) ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a jr z, .asm_3c7ad - ld hl, W_PARTYMON1_SPEED ; wd193 - ld de, W_ENEMYMONSPEED + ld hl, wPartyMon1Speed + ld de, wEnemyMonSpeed jp Func_3cab9 UseNextMonText: ; 3c7d3 (f:47d3) @@ -1150,7 +1150,7 @@ Func_3c7d8: ; 3c7d8 (f:47d8) ld a, [wWhichPokemon] ; wWhichPokemon ld [wPlayerMonNumber], a ; wPlayerMonNumber ld c, a - ld hl, W_PLAYERMONSALIVEFLAGS + ld hl, wPartyAliveFlags ld b, $1 push bc ld a, $10 ; FlagActionPredef @@ -1166,7 +1166,7 @@ Func_3c7d8: ; 3c7d8 (f:47d8) call GoPAL_SET_CF1C call GBPalNormal call Func_3cc91 - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] or [hl] ret @@ -1310,7 +1310,7 @@ Func_3c8df: ; 3c8df (f:48df) ; XXX this needs cleaning up. it's what runs when a juggler switches pokemon EnemySendOut: ; 3c90e (f:490e) - ld hl,W_PLAYERMONSALIVEFLAGS + ld hl,wPartyAliveFlags xor a ld [hl],a ld a,[wPlayerMonNumber] @@ -1360,14 +1360,14 @@ Func_3c92a: ; 3c92a (f:492a) ld b,$FF .next2 inc b - ld a,[W_ENEMYMONNUMBER] + ld a,[wEnemyMonPartyPos] cp b jr z,.next2 - ld hl,wEnemyMon1Species + ld hl,wEnemyMon1 ld a,b ld [wWhichPokemon],a push bc - ld bc,$2C + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes pop bc inc hl @@ -1378,8 +1378,8 @@ Func_3c92a: ; 3c92a (f:492a) jr z,.next2 .next3 ld a,[wWhichPokemon] - ld hl,wd8c5 - ld bc,$2C + ld hl,wEnemyMon1Level + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes ld a,[hl] ld [W_CURENEMYLVL],a @@ -1390,10 +1390,10 @@ Func_3c92a: ; 3c92a (f:492a) ld b,0 add hl,bc ld a,[hl] - ld [W_ENEMYMONID],a + ld [wEnemyMonSpecies2],a ld [wcf91],a call Func_3eb01 - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld a,[hli] ld [wcce3],a ld a,[hl] @@ -1403,7 +1403,7 @@ Func_3c92a: ; 3c92a (f:492a) ld a,[wd11d] dec a jr z,.next4 - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] dec a jr z,.next4 ld a,[W_ISLINKBATTLE] @@ -1458,7 +1458,7 @@ Func_3c92a: ; 3c92a (f:492a) call GBPalNormal ld hl,TrainerSentOutText call PrintText - ld a,[W_ENEMYMONID] + ld a,[wEnemyMonSpecies2] ld [wcf91],a ld [wd0b5],a call GetMonHeader @@ -1470,14 +1470,14 @@ Func_3c92a: ; 3c92a (f:492a) ld hl,Coord ld a,2 call Predef - ld a,[W_ENEMYMONID] + ld a,[wEnemyMonSpecies2] call PlayCry call Func_3cdec ld a,[wCurrentMenuItem] and a ret nz xor a - ld [W_PLAYERMONSALIVEFLAGS],a + ld [wPartyAliveFlags],a ld [wccf5],a call SaveScreenTilesToBuffer1 jp Func_3d1ba @@ -1493,11 +1493,11 @@ TrainerSentOutText: ; 3ca7e (f:4a7e) ; tests if the player has any pokemon that are not fainted ; sets d = 0 if all fainted, d != 0 if some mons are still alive AnyPlayerPokemonAliveCheck: ; 3ca83 (f:4a83) - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount ld e, a xor a - ld hl, W_PARTYMON1_HP ; wd16c - ld bc, W_PARTYMON2DATA - W_PARTYMON1DATA - 1 + ld hl, wPartyMon1HP ; wd16c + ld bc, wPartyMon2 - wPartyMon1 - 1 .partyMonsLoop or [hl] inc hl @@ -1510,7 +1510,7 @@ AnyPlayerPokemonAliveCheck: ; 3ca83 (f:4a83) Func_3ca97: ; 3ca97 (f:4a97) ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1_HP ; wd16c + ld hl, wPartyMon1HP ; wd16c ld bc, $2c call AddNTimes ld a, [hli] @@ -1656,32 +1656,32 @@ GotAwayText: ; 3cba1 (f:4ba1) Func_3cba6: ; 3cba6 (f:4ba6) ld a, [wWhichPokemon] ; wWhichPokemon ld bc, $2c - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) call AddNTimes - ld de, W_PLAYERMONID + ld de, wBattleMonSpecies ld bc, $c call CopyData ld bc, $f add hl, bc - ld de, W_PLAYERMONIVS + ld de, wBattleMonDVs ld bc, $2 call CopyData - ld de, W_PLAYERMONPP ; W_PLAYERMONPP + ld de, wBattleMonPP ; wBattleMonPP ld bc, $4 call CopyData - ld de, W_PLAYERMONLEVEL ; W_PLAYERMONLEVEL + ld de, wBattleMonLevel ; wBattleMonLevel ld bc, $b call CopyData - ld a, [wcfd9] + ld a, [wBattleMonSpecies2] ld [wd0b5], a call GetMonHeader - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [wPlayerMonNumber] ; wPlayerMonNumber call SkipFixedLengthTextEntries - ld de, W_PLAYERMONNAME + ld de, wBattleMonNick ld bc, $b call CopyData - ld hl, W_PLAYERMONLEVEL ; W_PLAYERMONLEVEL + ld hl, wBattleMonLevel ; wBattleMonLevel ld de, wcd0f ld bc, $b call CopyData @@ -1701,30 +1701,30 @@ Func_3cc13: ; 3cc13 (f:4c13) ld bc, $2c ld hl, wEnemyMons ; wEnemyMon1Species call AddNTimes - ld de, wcfe5 + ld de, wEnemyMonSpecies ld bc, $c call CopyData ld bc, $f add hl, bc - ld de, W_ENEMYMONATKDEFIV + ld de, wEnemyMonDVs ld bc, $2 call CopyData - ld de, W_ENEMYMONPP ; wcffe + ld de, wEnemyMonPP ; wcffe ld bc, $4 call CopyData - ld de, W_ENEMYMONLEVEL ; W_ENEMYMONLEVEL + ld de, wEnemyMonLevel ; wEnemyMonLevel ld bc, $b call CopyData - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wd0b5], a call GetMonHeader - ld hl, W_ENEMYMON1NAME + ld hl, wEnemyMonNicks ld a, [wWhichPokemon] ; wWhichPokemon call SkipFixedLengthTextEntries - ld de, W_ENEMYMONNAME + ld de, wEnemyMonNick ld bc, $b call CopyData - ld hl, W_ENEMYMONLEVEL ; W_ENEMYMONLEVEL + ld hl, wEnemyMonLevel ; wEnemyMonLevel ld de, wcd23 ld bc, $b call CopyData @@ -1746,12 +1746,12 @@ Func_3cc13: ; 3cc13 (f:4c13) dec b jr nz, .asm_3cc86 ld a, [wWhichPokemon] ; wWhichPokemon - ld [W_ENEMYMONNUMBER], a ; W_ENEMYMONNUMBER + ld [wEnemyMonPartyPos], a ret Func_3cc91: ; 3cc91 (f:4c91) callab SendOutMon - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] or [hl] jp z, Func_3cca4 @@ -1835,15 +1835,15 @@ Func_3cd3a: ; 3cd3a (f:4d3a) ld bc, $707 jp ClearScreenArea -; reads player's current mon's HP into W_PLAYERMONCURHP +; reads player's current mon's HP into wBattleMonHP ReadPlayerMonCurHPAndStatus: ; 3cd43 (f:4d43) ld a, [wPlayerMonNumber] ; wPlayerMonNumber - ld hl, W_PARTYMON1_HP ; wd16c - ld bc, W_PARTYMON2DATA - W_PARTYMON1DATA + ld hl, wPartyMon1HP ; wd16c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld d, h ld e, l - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status jp CopyData @@ -1862,16 +1862,16 @@ Func_3cd60: ; 3cd60 (f:4d60) FuncCoord 18, 9 ld hl, Coord ld [hl], $73 - ld de, W_PLAYERMONNAME + ld de, wBattleMonNick FuncCoord 10, 7 ld hl, Coord call Func_3ce9c call PlaceString - ld hl, W_PLAYERMONID + ld hl, wBattleMonSpecies ld de, wcf98 ld bc, $c call CopyData - ld hl, W_PLAYERMONLEVEL ; W_PLAYERMONLEVEL + ld hl, wBattleMonLevel ; wBattleMonLevel ld de, wcfb9 ld bc, $b call CopyData @@ -1895,7 +1895,7 @@ Func_3cd60: ; 3cd60 (f:4d60) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ld hl, wcf1d call GetBattleHealthBarColor - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld a, [hli] or [hl] jr z, .asm_3cdd9 @@ -1925,7 +1925,7 @@ Func_3cdec: ; 3cdec (f:4dec) ld bc, $40c call ClearScreenArea callab PlaceEnemyHUDTiles - ld de, W_ENEMYMONNAME + ld de, wEnemyMonNick FuncCoord 1, 0 ld hl, Coord call Func_3ce9c @@ -1934,15 +1934,15 @@ Func_3cdec: ; 3cdec (f:4dec) ld hl, Coord push hl inc hl - ld de, W_ENEMYMONSTATUS ; wcfe9 + ld de, wEnemyMonStatus ; wcfe9 call PrintStatusConditionNotFainted pop hl jr nz, .asm_3ce23 - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL + ld a, [wEnemyMonLevel] ; wEnemyMonLevel ld [wcfb9], a call PrintLevel .asm_3ce23 - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld a, [hli] ld [$ff97], a ld a, [hld] @@ -1959,7 +1959,7 @@ Func_3cdec: ; 3cdec (f:4dec) ld a, $30 ld [H_REMAINDER], a ; $ff99 (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN) call Multiply - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP ld a, [hli] ld b, a ld a, [hl] @@ -2058,7 +2058,7 @@ InitBattleMenu: ; 3ceb3 (f:4eb3) dec a jp nz, RegularBattleMenu ; regular battle ; the following happens for the old man tutorial - ld hl, W_PLAYERNAME ; wd158 + ld hl, wPlayerName ; wd158 ld de, W_GRASSRATE ; W_GRASSRATE ld bc, $b call CopyData ; temporarily save the player name in unused space, @@ -2067,7 +2067,7 @@ InitBattleMenu: ; 3ceb3 (f:4eb3) ; may not get overwritten (cinnabar) and the infamous ; missingno. glitch can show up. ld hl, OldManName ; $4f12 - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 ld bc, $b call CopyData ; the following simulates the keystrokes by drawing menus on screen @@ -2382,7 +2382,7 @@ Func_3d119: ; 3d119 (f:5119) jr z, .asm_3d18a xor a ld [wcc49], a - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) call ClearSprites ld a, $36 call Predef ; indirect jump to StatusScreen (12953 (4:6953)) @@ -2396,7 +2396,7 @@ Func_3d119: ; 3d119 (f:5119) and a ld hl, AnimationMinimizeMon jr nz, .asm_3d182 - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wcf91], a ld [wd0b5], a call GetMonHeader @@ -2439,7 +2439,7 @@ Func_3d1ba: ; 3d1ba (f:51ba) ld c, a ld b, $1 push bc - ld hl, W_PLAYERMONSALIVEFLAGS + ld hl, wPartyAliveFlags ld a, $10 ; FlagActionPredef call Predef pop bc @@ -2462,8 +2462,8 @@ Func_3d1fa: ; 3d1fa (f:51fa) call LoadScreenTilesFromBuffer1 ld a, $3 ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld hl, W_PLAYERMONSPEED - ld de, W_ENEMYMONSPEED + ld hl, wBattleMonSpeed + ld de, wEnemyMonSpeed call Func_3cab9 ld a, $0 ld [wd11f], a @@ -2502,7 +2502,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) .regularmenu call Func_3d3f5 ret z - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves call .loadmoves FuncCoord 4, 12 ld hl, Coord @@ -2524,7 +2524,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld a, $c jr .menuset .mimicmenu - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves call .loadmoves FuncCoord 0, 7 ld hl, Coord @@ -2539,7 +2539,7 @@ MoveSelectionMenu: ; 3d219 (f:5219) jr .menuset .relearnmenu ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1_MOVE1 ; W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ; wPartyMon1Moves ld bc, $2c call AddNTimes call .loadmoves @@ -2658,7 +2658,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) .moveselected pop af ret nz - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP ld a, [wCurrentMenuItem] ; wCurrentMenuItem ld c, a ld b, $0 @@ -2677,7 +2677,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) jr nz, .dummy ; game freak derp .dummy ld a, [wCurrentMenuItem] ; wCurrentMenuItem - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves ld c, a ld b, $0 add hl, bc @@ -2734,7 +2734,7 @@ Func_3d3f5: ; 3d3f5 (f:53f5) ld [wPlayerSelectedMove], a ; wPlayerSelectedMove ld a, [W_PLAYERDISABLEDMOVE] ; W_PLAYERDISABLEDMOVE and a - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP jr nz, .asm_3d40e ld a, [hli] or [hl] @@ -2779,9 +2779,9 @@ Func_3d435: ; 3d435 (f:5435) ld a, [wcc35] and a jr z, asm_3d4ad - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves call Func_3d493 - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP call Func_3d493 ld hl, W_PLAYERDISABLEDMOVE ; W_PLAYERDISABLEDMOVE ld a, [hl] @@ -2811,7 +2811,7 @@ Func_3d435: ; 3d435 (f:5435) add b ld [hl], a .asm_3d474 - ld hl, W_PARTYMON1_MOVE1 ; W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ; wPartyMon1Moves ld a, [wPlayerMonNumber] ; wPlayerMonNumber ld bc, $2c call AddNTimes @@ -2878,7 +2878,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) dec [hl] xor a ld [H_WHOSETURN], a ; $fff3 - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves ld a, [wCurrentMenuItem] ; wCurrentMenuItem ld c, a ld b, $0 @@ -2894,7 +2894,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld c, [hl] inc [hl] ld b, $0 - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP add hl, bc ld a, [hl] and $3f @@ -2951,7 +2951,7 @@ SelectEnemyMove: ; 3d564 (f:5564) ret nc ld [wEnemyMoveListIndex], a ld c, a - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves ld b, $0 add hl, bc ld a, [hl] @@ -2964,7 +2964,7 @@ SelectEnemyMove: ; 3d564 (f:5564) ld a, [hl] and $12 ; using multi-turn move or bide ret nz - ld a, [W_ENEMYMONSTATUS] + ld a, [wEnemyMonStatus] and SLP | 1 << FRZ ; sleeping or frozen ret nz ld a, [W_ENEMYBATTSTATUS1] @@ -2977,7 +2977,7 @@ SelectEnemyMove: ; 3d564 (f:5564) ld a, $ff jr .done .notCaughtInWrap - ld hl, W_ENEMYMONMOVES+1 ; 2nd enemy move + ld hl, wEnemyMonMoves+1 ; 2nd enemy move ld a, [hld] and a jr nz, .atLeastTwoMovesAvailable @@ -3233,7 +3233,7 @@ asm_3d766 ld de,1 call IsInArray call c,Func_3f132 - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld a,[hli] ld b,[hl] or b @@ -3280,7 +3280,7 @@ PrintGhostText: ; 3d811 (f:5811) ld a,[H_WHOSETURN] and a jr nz,.Ghost - ld a,[W_PLAYERMONSTATUS] ; player’s turn + ld a,[wBattleMonStatus] ; player’s turn and a,SLP | (1 << FRZ) ret nz ld hl,ScaredText @@ -3319,13 +3319,13 @@ IsGhostBattle: ; 3d83a (f:583a) ret Func_3d854: ; 3d854 (f:5854) - ld hl,W_PLAYERMONSTATUS + ld hl,wBattleMonStatus ld a,[hl] and a,SLP jr z,.FrozenCheck ; to 5884 dec a - ld [W_PLAYERMONSTATUS],a ; decrement sleep count + ld [wBattleMonStatus],a ; decrement sleep count and a jr z,.WakeUp ; to 5874 @@ -3435,7 +3435,7 @@ HyperBeamCheck: ; 3d8c2 (f:58c2) ld hl,Func_3d80a ; $580a jp Func_3da37 .ParalysisCheck - ld hl,W_PLAYERMONSTATUS + ld hl,wBattleMonStatus bit PAR,[hl] jr z,.next7 ; 5975 call BattleRandom @@ -3652,14 +3652,14 @@ MoveIsDisabledText: ; 3daa8 (f:5aa8) PrintHurtItselfText: ; 3daad (f:5aad) ld hl, HurtItselfText call PrintText - ld hl, W_ENEMYMONDEFENSE ; wcff8 + ld hl, wEnemyMonDefense ; wcff8 ld a, [hli] push af ld a, [hld] push af - ld a, [W_PLAYERMONDEF] + ld a, [wBattleMonDefense] ld [hli], a - ld a, [W_PLAYERMONDEF + 1] + ld a, [wBattleMonDefense + 1] ld [hl], a ld hl, W_PLAYERMOVEEFFECT ; wcfd3 push hl @@ -3677,7 +3677,7 @@ PrintHurtItselfText: ; 3daad (f:5aad) pop af pop hl ld [hl], a - ld hl, W_ENEMYMONDEFENSE + 1 + ld hl, wEnemyMonDefense + 1 pop af ld [hld], a pop af @@ -3943,7 +3943,7 @@ Func_3dc88: ; 3dc88 (f:5c88) and a ret .asm_3dc97 - ld hl, W_PARTYMON1_OTID ; W_PARTYMON1_OTID + ld hl, wPartyMon1OTID ; wPartyMon1OTID ld bc, $2c ld a, [wPlayerMonNumber] ; wPlayerMonNumber call AddNTimes @@ -3973,7 +3973,7 @@ Func_3dc88: ; 3dc88 (f:5c88) .asm_3dcce ld b, a ld c, a - ld a, [W_PLAYERMONLEVEL] ; W_PLAYERMONLEVEL + ld a, [wBattleMonLevel] ; wBattleMonLevel ld d, a add b ld b, a @@ -4015,7 +4015,7 @@ Func_3dc88: ; 3dc88 (f:5c88) swap a and $7 jr z, .asm_3dd0e - ld [W_PLAYERMONSTATUS], a ; W_PLAYERMONSTATUS + ld [wBattleMonStatus], a ; wBattleMonStatus ld hl, BeganToNapText jr .asm_3dd3a .asm_3dd20 @@ -4035,7 +4035,7 @@ Func_3dc88: ; 3dc88 (f:5c88) call PrintText jr Func_3ddb4 .asm_3dd3f - ld a, [W_PLAYERMONMOVES + 1] + ld a, [wBattleMonMoves + 1] and a jr z, .asm_3dd20 ld a, [wccee] @@ -4044,7 +4044,7 @@ Func_3dc88: ; 3dc88 (f:5c88) ld a, [wPlayerSelectedMove] ; wPlayerSelectedMove cp $a5 jr z, .asm_3dd20 - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP push hl ld a, [hli] and $3f @@ -4086,7 +4086,7 @@ Func_3dc88: ; 3dc88 (f:5c88) cp c jr z, .asm_3dd86 ld [wCurrentMenuItem], a ; wCurrentMenuItem - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP ld e, a ld d, $0 add hl, de @@ -4096,7 +4096,7 @@ Func_3dc88: ; 3dc88 (f:5c88) ld a, [wCurrentMenuItem] ; wCurrentMenuItem ld c, a ld b, $0 - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves add hl, bc ld a, [hl] ld [wPlayerSelectedMove], a ; wPlayerSelectedMove @@ -4145,7 +4145,7 @@ CalculateDamage: ; 3ddcf (f:5dcf) cp a, $14 ;types >= $14 are all special jr nc, .specialAttack .physicalAttack - ld hl, W_ENEMYMONDEFENSE ;opponent defense + ld hl, wEnemyMonDefense ;opponent defense ld a, [hli] ;*BC = opponent defense used later ld b, a ld c, [hl] @@ -4156,7 +4156,7 @@ CalculateDamage: ; 3ddcf (f:5dcf) sla c ;x2 defense if bit2 of D069 is set rl b .next - ld hl, W_PLAYERMONATK ;attack pointer + ld hl, wBattleMonAttack ;attack pointer ld a, [wd05e] and a jr z, .next3 @@ -4167,14 +4167,14 @@ CalculateDamage: ; 3ddcf (f:5dcf) ld a, [$ff98] ld c, a push bc - ld hl, W_PARTYMON1_ATACK + ld hl, wPartyMon1Attack ld a, [wPlayerMonNumber] - ld bc, $002c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes pop bc jr .next3 .specialAttack - ld hl, W_ENEMYMONSPECIAL ;opponent special + ld hl, wEnemyMonSpecial ;opponent special ld a, [hli] ;*BC = opponent special defense used later ld b, a ld c, [hl] @@ -4185,7 +4185,7 @@ CalculateDamage: ; 3ddcf (f:5dcf) sla c ;x2 special defense if bit1 of D069 set rl b .next2 - ld hl, W_PLAYERMONSPECIAL + ld hl, wBattleMonSpecial ld a, [wd05e] ;XXX and a jr z, .next3 ;skip portion of code that pulls up inactive pokemon @@ -4197,9 +4197,9 @@ CalculateDamage: ; 3ddcf (f:5dcf) ld a, [$ff98] ld c, a push bc - ld hl, W_PARTYMON1_SPECIAL + ld hl, wPartyMon1Special ld a, [wPlayerMonNumber] - ld bc, $002c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes pop bc .next3 @@ -4222,7 +4222,7 @@ CalculateDamage: ; 3ddcf (f:5dcf) inc l ;minimum HL = 1 .next4 ld b, l ;*B = attack [possibly scaled] [C contains defense] - ld a, [W_PLAYERMONLEVEL] ;*E = level + ld a, [wBattleMonLevel] ;*E = level ld e, a ld a, [wd05e] ;critical hit? and a @@ -4246,7 +4246,7 @@ Func_3de75: ; 3de75 (f:5e75) ld a, [hl] cp $14 jr nc, .asm_3debc - ld hl, W_PLAYERMONDEF + ld hl, wBattleMonDefense ld a, [hli] ld b, a ld c, [hl] @@ -4256,11 +4256,11 @@ Func_3de75: ; 3de75 (f:5e75) sla c rl b .asm_3de98 - ld hl, W_ENEMYMONATTACK + ld hl, wEnemyMonAttack ld a, [wd05e] and a jr z, .asm_3deef - ld hl, W_PARTYMON1_DEFENSE ; wd191 + ld hl, wPartyMon1Defense ld a, [wPlayerMonNumber] ; wPlayerMonNumber ld bc, $2c call AddNTimes @@ -4274,7 +4274,7 @@ Func_3de75: ; 3de75 (f:5e75) pop bc jr .asm_3deef .asm_3debc - ld hl, W_PLAYERMONSPECIAL + ld hl, wBattleMonSpecial ld a, [hli] ld b, a ld c, [hl] @@ -4284,11 +4284,11 @@ Func_3de75: ; 3de75 (f:5e75) sla c rl b .asm_3decd - ld hl, W_ENEMYMONSPECIAL ; wcffc + ld hl, wEnemyMonSpecial ; wcffc ld a, [wd05e] and a jr z, .asm_3deef - ld hl, W_PARTYMON1_SPECIAL ; W_PARTYMON1_SPECIAL + ld hl, wPartyMon1Special ; wPartyMon1Special ld a, [wPlayerMonNumber] ; wPlayerMonNumber ld bc, $2c call AddNTimes @@ -4320,7 +4320,7 @@ Func_3de75: ; 3de75 (f:5e75) inc l .asm_3df0a ld b, l - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL + ld a, [wEnemyMonLevel] ; wEnemyMonLevel ld e, a ld a, [wd05e] and a @@ -4338,13 +4338,13 @@ Func_3df1c: ; 3df1c (f:5f1c) ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE cp $4 jr nz, .asm_3df40 - ld hl, wd8c6 + ld hl, wEnemyMon1Stats dec c sla c ld b, $0 add hl, bc - ld a, [W_ENEMYMONNUMBER] ; W_ENEMYMONNUMBER - ld bc, $2c + ld a, [wEnemyMonPartyPos] + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] ld [$ff97], a @@ -4354,12 +4354,12 @@ Func_3df1c: ; 3df1c (f:5f1c) pop de ret .asm_3df40 - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL + ld a, [wEnemyMonLevel] ; wEnemyMonLevel ld [W_CURENEMYLVL], a ; W_CURENEMYLVL - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wd0b5], a call GetMonHeader - ld hl, W_ENEMYMONATKDEFIV + ld hl, wEnemyMonDVs ld de, wcfaf ld a, [hli] ld [de], a @@ -4555,9 +4555,9 @@ CriticalHitTest: ; 3e023 (f:6023) ld [wd05e], a ld a, [H_WHOSETURN] ; $fff3 and a - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] jr nz, .asm_3e032 - ld a, [W_PLAYERMONID] + ld a, [wBattleMonSpecies] .asm_3e032 ld [wd0b5], a call GetMonHeader @@ -4697,7 +4697,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) jr ApplyDamageToEnemyPokemon .superFangEffect ; set the damage to half the target's HP - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld de,W_DAMAGE ld a,[hli] srl a @@ -4714,7 +4714,7 @@ ApplyAttackToEnemyPokemon: ; 3e0df (f:60df) ld [de],a jr ApplyDamageToEnemyPokemon .specialDamage - ld hl,W_PLAYERMONLEVEL + ld hl,wBattleMonLevel ld a,[hl] ld b,a ld a,[W_PLAYERMOVENUM] @@ -4763,16 +4763,16 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ; also, save the current HP at wHPBarOldHP ld a,[hld] ld b,a - ld a,[W_ENEMYMONCURHP + 1] + ld a,[wEnemyMonHP + 1] ld [wHPBarOldHP],a sub b - ld [W_ENEMYMONCURHP + 1],a + ld [wEnemyMonHP + 1],a ld a,[hl] ld b,a - ld a,[W_ENEMYMONCURHP] + ld a,[wEnemyMonHP] ld [wHPBarOldHP+1],a sbc b - ld [W_ENEMYMONCURHP],a + ld [wEnemyMonHP],a jr nc,.animateHpBar ; if more damage was done than the current HP, zero the HP and set the damage ; equal to how much HP the pokemon had before the attack @@ -4781,16 +4781,16 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld a,[wHPBarOldHP] ld [hl],a xor a - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld [hli],a ld [hl],a .animateHpBar - ld hl,W_ENEMYMONMAXHP + ld hl,wEnemyMonMaxHP ld a,[hli] ld [wHPBarMaxHP+1],a ld a,[hl] ld [wHPBarMaxHP],a - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld a,[hli] ld [wHPBarNewHP+1],a ld a,[hl] @@ -4818,7 +4818,7 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0) jr ApplyDamageToPlayerPokemon .superFangEffect ; set the damage to half the target's HP - ld hl,W_PLAYERMONCURHP + ld hl,wBattleMonHP ld de,W_DAMAGE ld a,[hli] srl a @@ -4835,7 +4835,7 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0) ld [de],a jr ApplyDamageToPlayerPokemon .specialDamage - ld hl,W_ENEMYMONLEVEL + ld hl,wEnemyMonLevel ld a,[hl] ld b,a ld a,[W_ENEMYMOVENUM] @@ -4884,16 +4884,16 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP ld a,[hld] ld b,a - ld a,[W_PLAYERMONCURHP + 1] + ld a,[wBattleMonHP + 1] ld [wHPBarOldHP],a sub b - ld [W_PLAYERMONCURHP + 1],a + ld [wBattleMonHP + 1],a ld [wHPBarNewHP],a ld b,[hl] - ld a,[W_PLAYERMONCURHP] + ld a,[wBattleMonHP] ld [wHPBarOldHP+1],a sbc b - ld [W_PLAYERMONCURHP],a + ld [wBattleMonHP],a ld [wHPBarNewHP+1],a jr nc,.animateHpBar ; if more damage was done than the current HP, zero the HP and set the damage @@ -4903,14 +4903,14 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld a,[wHPBarOldHP] ld [hl],a xor a - ld hl,W_PLAYERMONCURHP + ld hl,wBattleMonHP ld [hli],a ld [hl],a ld hl,wHPBarNewHP ld [hli],a ld [hl],a .animateHpBar - ld hl,W_PLAYERMONMAXHP + ld hl,wBattleMonMaxHP ld a,[hli] ld [wHPBarMaxHP+1],a ld a,[hl] @@ -5093,7 +5093,7 @@ MetronomePickMove: ; 3e348 (f:6348) call BattleRandom and a jr z,.pickMoveLoop - cp a,NUM_MOVES + 1 ; max normal move number + 1 (this is Struggle's move number) + cp a,NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number) jr nc,.pickMoveLoop cp a,METRONOME jr z,.pickMoveLoop @@ -5107,13 +5107,13 @@ IncrementMovePP: ; 3e373 (f:6373) ld a,[H_WHOSETURN] and a ; values for player turn - ld hl,W_PLAYERMONPP - ld de,W_PARTYMON1_MOVE1PP + ld hl,wBattleMonPP + ld de,wPartyMon1PP ld a,[wPlayerMoveListIndex] jr z,.next ; values for enemy turn - ld hl,W_ENEMYMONPP - ld de,wd8c1 ; enemy party pokemon 1 PP + ld hl,wEnemyMonPP + ld de,wEnemyMon1PP ld a,[wEnemyMoveListIndex] .next ld b,$00 @@ -5127,9 +5127,9 @@ IncrementMovePP: ; 3e373 (f:6373) and a ld a,[wPlayerMonNumber] ; value for player turn jr z,.next2 - ld a,[W_ENEMYMONNUMBER] ; value for enemy turn + ld a,[wEnemyMonPartyPos] ; value for enemy turn .next2 - ld bc,$002c + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes inc [hl] ; increment PP in the party memory location ret @@ -5137,11 +5137,11 @@ IncrementMovePP: ; 3e373 (f:6373) ; function to adjust the base damage of an attack to account for type effectiveness AdjustDamageForMoveType: ; 3e3a5 (f:63a5) ; values for player turn - ld hl,W_PLAYERMONTYPES + ld hl,wBattleMonType ld a,[hli] ld b,a ; b = type 1 of attacker ld c,[hl] ; c = type 2 of attacker - ld hl,W_ENEMYMONTYPES + ld hl,wEnemyMonType ld a,[hli] ld d,a ; d = type 1 of defender ld e,[hl] ; e = type 2 of defender @@ -5151,11 +5151,11 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) and a jr z,.next ; values for enemy turn - ld hl,W_ENEMYMONTYPES + ld hl,wEnemyMonType ld a,[hli] ld b,a ; b = type 1 of attacker ld c,[hl] ; c = type 2 of attacker - ld hl,W_PLAYERMONTYPES + ld hl,wBattleMonType ld a,[hli] ld d,a ; d = type 1 of defender ld e,[hl] ; e = type 2 of defender @@ -5256,7 +5256,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5) AIGetTypeEffectiveness: ; 3e449 (f:6449) ld a,[W_ENEMYMOVETYPE] ld d,a ; d = type of enemy move - ld hl,W_PLAYERMONTYPES + ld hl,wBattleMonType ld b,[hl] ; b = type 1 of player's pokemon inc hl ld c,[hl] ; c = type 2 of player's pokemon @@ -5292,14 +5292,14 @@ MoveHitTest: ; 3e56b (f:656b) ; player's turn ld hl,W_ENEMYBATTSTATUS1 ld de,W_PLAYERMOVEEFFECT - ld bc,W_ENEMYMONSTATUS + ld bc,wEnemyMonStatus ld a,[H_WHOSETURN] and a jr z,.dreamEaterCheck ; enemy's turn ld hl,W_PLAYERBATTSTATUS1 ld de,W_ENEMYMOVEEFFECT - ld bc,W_PLAYERMONSTATUS + ld bc,wBattleMonStatus .dreamEaterCheck ld a,[de] cp a,DREAM_EATER_EFFECT @@ -5691,7 +5691,7 @@ asm_3e7ef: ; 3e7ef (f:67ef) ld de, $1 call IsInArray call c, Func_3f132 - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld a, [hli] ld b, [hl] or b @@ -5729,12 +5729,12 @@ Func_3e88c: ; 3e88c (f:688c) ret Func_3e88f: ; 3e88f (f:688f) - ld hl, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonStatus ; wcfe9 ld a, [hl] and $7 jr z, .asm_3e8bf dec a - ld [W_ENEMYMONSTATUS], a ; wcfe9 + ld [wEnemyMonStatus], a ; wcfe9 and a jr z, .asm_3e8af ld hl, FastAsleepText @@ -5830,14 +5830,14 @@ Func_3e8fd: ; 3e8fd (f:68fd) ld [hl], a ld hl, HurtItselfText call PrintText - ld hl, W_PLAYERMONDEF + ld hl, wBattleMonDefense ld a, [hli] push af ld a, [hld] push af - ld a, [W_ENEMYMONDEFENSE] ; wcff8 + ld a, [wEnemyMonDefense] ; wcff8 ld [hli], a - ld a, [W_ENEMYMONDEFENSE + 1] + ld a, [wEnemyMonDefense + 1] ld [hl], a ld hl, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT push hl @@ -5855,7 +5855,7 @@ Func_3e8fd: ; 3e8fd (f:68fd) pop af pop hl ld [hl], a - ld hl, W_PLAYERMONDEF + 1 + ld hl, wBattleMonDefense + 1 pop af ld [hld], a pop af @@ -5881,7 +5881,7 @@ Func_3e9aa: ; 3e9aa (f:69aa) ld hl, Func_3e88c ; $688c jp Func_3eab8 .asm_3e9bf - ld hl, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonStatus ; wcfe9 bit 6, [hl] jr z, asm_3e9f6 call BattleRandom @@ -6047,8 +6047,8 @@ Func_3eb01: ; 3eb01 (f:6b01) ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE cp $4 jp z, Func_3cc13 - ld a, [W_ENEMYMONID] - ld [wcfe5], a + ld a, [wEnemyMonSpecies2] + ld [wEnemyMonSpecies], a ld [wd0b5], a call GetMonHeader ld a, [W_ENEMYBATTSTATUS3] ; W_ENEMYBATTSTATUS3 @@ -6066,15 +6066,15 @@ Func_3eb01: ; 3eb01 (f:6b01) ld b, a call BattleRandom .asm_3eb33 - ld hl, W_ENEMYMONATKDEFIV + ld hl, wEnemyMonDVs ld [hli], a ld [hl], b - ld de, W_ENEMYMONLEVEL ; W_ENEMYMONLEVEL + ld de, wEnemyMonLevel ; wEnemyMonLevel ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL ld [de], a inc de ld b, $0 - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP push hl call CalcStats pop hl @@ -6084,32 +6084,32 @@ Func_3eb01: ; 3eb01 (f:6b01) ld a, [W_ENEMYBATTSTATUS3] ; W_ENEMYBATTSTATUS3 bit 3, a jr nz, .asm_3eb86 - ld a, [W_ENEMYMONMAXHP] ; W_ENEMYMONMAXHP + ld a, [wEnemyMonMaxHP] ; wEnemyMonMaxHP ld [hli], a - ld a, [W_ENEMYMONMAXHP+1] + ld a, [wEnemyMonMaxHP+1] ld [hli], a xor a inc hl ld [hl], a jr .asm_3eb86 .asm_3eb65 - ld hl, W_ENEMYMON1HP ; wd8a5 (aliases: W_WATERMONS) + ld hl, wEnemyMon1HP ; wd8a5 (aliases: W_WATERMONS) ld a, [wWhichPokemon] ; wWhichPokemon - ld bc, $2c + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes ld a, [hli] - ld [W_ENEMYMONCURHP], a ; W_ENEMYMONCURHP + ld [wEnemyMonHP], a ; wEnemyMonHP ld a, [hli] - ld [W_ENEMYMONCURHP + 1], a + ld [wEnemyMonHP + 1], a ld a, [wWhichPokemon] ; wWhichPokemon - ld [W_ENEMYMONNUMBER], a ; W_ENEMYMONNUMBER + ld [wEnemyMonPartyPos], a inc hl ld a, [hl] - ld [W_ENEMYMONSTATUS], a ; wcfe9 + ld [wEnemyMonStatus], a ; wcfe9 jr .asm_3eb86 .asm_3eb86 ld hl, W_MONHTYPES - ld de, W_ENEMYMONTYPES ; wcfea + ld de, wEnemyMonType ; wcfea ld a, [hli] ; copy type 1 ld [de], a inc de @@ -6122,11 +6122,11 @@ Func_3eb01: ; 3eb01 (f:6b01) ld a, [W_ISINBATTLE] ; W_ISINBATTLE cp $2 jr nz, .asm_3ebb0 - ld hl, wd8ac + ld hl, wEnemyMon1Moves ld a, [wWhichPokemon] ; wWhichPokemon - ld bc, $2c + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes - ld bc, $4 + ld bc, NUM_MOVES call CopyData jr .asm_3ebca .asm_3ebb0 @@ -6150,8 +6150,8 @@ Func_3eb01: ; 3eb01 (f:6b01) ld a, $3e call Predef ; indirect jump to WriteMonMoves (3afb8 (e:6fb8)) .asm_3ebca - ld hl, W_ENEMYMONMOVES - ld de, W_ENEMYMONSPECIAL + 1 + ld hl, wEnemyMonMoves + ld de, wEnemyMonSpecial + 1 ld a, $5e call Predef ; indirect jump to LoadMovePPs (f473 (3:7473)) ld hl, W_MONHBASESTATS @@ -6169,14 +6169,14 @@ Func_3eb01: ; 3eb01 (f:6b01) inc de ld a, [hl] ; base exp ld [de], a - ld a, [W_ENEMYMONID] + ld a, [wEnemyMonSpecies2] ld [wd11e], a call GetMonName ld hl, wcd6d - ld de, W_ENEMYMONNAME + ld de, wEnemyMonNick ld bc, $b call CopyData - ld a, [W_ENEMYMONID] + ld a, [wEnemyMonSpecies2] ld [wd11e], a ld a, $3a call Predef ; indirect jump to IndexToPokedex (41010 (10:5010)) @@ -6187,7 +6187,7 @@ Func_3eb01: ; 3eb01 (f:6b01) ld hl, wPokedexSeen ; wd30a ld a, $10 ; FlagActionPredef call Predef - ld hl, W_ENEMYMONLEVEL ; W_ENEMYMONLEVEL + ld hl, wEnemyMonLevel ; wEnemyMonLevel ld de, wcd23 ld bc, $b call CopyData @@ -6237,12 +6237,12 @@ Func_3ec32: ; 3ec32 (f:6c32) Func_3ec81: ; 3ec81 (f:6c81) push bc - ld a, [W_PLAYERMONLEVEL] ; W_PLAYERMONLEVEL + ld a, [wBattleMonLevel] ; wBattleMonLevel ld b, a - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL - ld [W_PLAYERMONLEVEL], a ; W_PLAYERMONLEVEL + ld a, [wEnemyMonLevel] ; wEnemyMonLevel + ld [wBattleMonLevel], a ; wBattleMonLevel ld a, b - ld [W_ENEMYMONLEVEL], a ; W_ENEMYMONLEVEL + ld [wEnemyMonLevel], a ; wEnemyMonLevel pop bc ret @@ -6335,10 +6335,10 @@ Func_3ed27: ; 3ed27 (f:6d27) ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3ed48 - ld a, [W_PLAYERMONSTATUS] ; W_PLAYERMONSTATUS + ld a, [wBattleMonStatus] ; wBattleMonStatus and $40 ret z - ld hl, W_PLAYERMONSPEED + 1 + ld hl, wBattleMonSpeed + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6354,10 +6354,10 @@ Func_3ed27: ; 3ed27 (f:6d27) ld [hl], b ret .asm_3ed48 - ld a, [W_ENEMYMONSTATUS] ; wcfe9 + ld a, [wEnemyMonStatus] ; wcfe9 and $40 ret z - ld hl, W_ENEMYMONSPEED + 1 + ld hl, wEnemyMonSpeed + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6377,10 +6377,10 @@ Func_3ed64: ; 3ed64 (f:6d64) ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3ed81 - ld a, [W_PLAYERMONSTATUS] ; W_PLAYERMONSTATUS + ld a, [wBattleMonStatus] ; wBattleMonStatus and $10 ret z - ld hl, W_PLAYERMONATK + 1 + ld hl, wBattleMonAttack + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6394,10 +6394,10 @@ Func_3ed64: ; 3ed64 (f:6d64) ld [hl], b ret .asm_3ed81 - ld a, [W_ENEMYMONSTATUS] ; wcfe9 + ld a, [wEnemyMonStatus] ; wcfe9 and $10 ret z - ld hl, W_ENEMYMONATTACK + 1 + ld hl, wEnemyMonAttack + 1 ld a, [hld] ld b, a ld a, [hl] @@ -6427,11 +6427,11 @@ Func_3eda5: ; 3eda5 (f:6da5) ld a, [wd11e] and a ld a, c - ld hl, W_PLAYERMONATK + ld hl, wBattleMonAttack ld de, wcd12 ld bc, wPlayerMonAttackMod ; wcd1a jr z, .asm_3edc0 - ld hl, W_ENEMYMONATTACK + ld hl, wEnemyMonAttack ld de, wcd26 ld bc, wEnemyMonStatMods ; wcd2e .asm_3edc0 @@ -6505,7 +6505,7 @@ Func_3ee19: ; 3ee19 (f:6e19) ret z ld a, [W_OBTAINEDBADGES] ld b, a - ld hl, W_PLAYERMONATK + ld hl, wBattleMonAttack ld c, $4 .asm_3ee28 srl b @@ -6630,11 +6630,11 @@ BattleRandom: Func_3eed3: ; 3eed3 (f:6ed3) ld a, [H_WHOSETURN] ; $fff3 and a - ld hl, W_ENEMYMONTYPE1 ; wcfea (aliases: W_ENEMYMONTYPES) + ld hl, wEnemyMonType1 ; wcfea (aliases: wEnemyMonType) ld de, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 ld a, [W_PLAYERMOVENUM] ; wcfd2 jr z, .asm_3eeea - ld hl, W_PLAYERMONTYPE1 ; wd019 (aliases: W_PLAYERMONTYPES) + ld hl, wBattleMonType1 ; wd019 (aliases: wBattleMonType) ld de, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM .asm_3eeea @@ -6671,7 +6671,7 @@ InitBattle: ; 3ef12 (f:6f12) InitOpponent: ; 3ef18 (f:6f18) ld a, [W_CUROPPONENT] ; wd059 ld [wcf91], a - ld [W_ENEMYMONID], a + ld [wEnemyMonSpecies2], a jr asm_3ef3d asm_3ef23: ; 3ef23 (f:6f23) ld a, [wd732] @@ -6694,7 +6694,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) push af res 1, [hl] callab Func_525af - ld a, [W_ENEMYMONID] + ld a, [wEnemyMonSpecies2] sub $c8 jp c, InitWildBattle ld [W_TRAINERCLASS], a ; wd031 @@ -6703,7 +6703,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) call Func_3ec32 call _LoadTrainerPic xor a - ld [W_ENEMYMONID], a + ld [wEnemyMonSpecies2], a ld [$ffe1], a dec a ld [wAICount], a ; wccdf @@ -6712,7 +6712,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld a, $1 call Predef ; indirect jump to Func_3f0c6 (3f0c6 (f:70c6)) ld a, $ff - ld [W_ENEMYMONNUMBER], a ; W_ENEMYMONNUMBER + ld [wEnemyMonPartyPos], a ld a, $2 ld [W_ISINBATTLE], a ; W_ISINBATTLE jp Func_3efeb @@ -6735,7 +6735,7 @@ InitWildBattle: ; 3ef8b (f:6f8b) ld a, c ld [hli], a ; write front sprite pointer ld [hl], b - ld hl, W_ENEMYMONNAME ; set name to "GHOST" + ld hl, wEnemyMonNick ; set name to "GHOST" ld a, "G" ld [hli], a ld a, "H" @@ -6933,7 +6933,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0) LoadMonBackSprite: ; Assumes the monster's attributes have ; been loaded with GetMonHeader. - ld a, [wcfd9] + ld a, [wBattleMonSpecies2] ld [wcf91], a FuncCoord 1, 5 ld hl, Coord @@ -7065,12 +7065,12 @@ MoveEffectPointerTable: ; 3f150 (f:7150) dw DisableEffect ; DISABLE_EFFECT SleepEffect: ; 3f1fc (f:71fc) - ld de, W_ENEMYMONSTATUS ; wcfe9 + ld de, wEnemyMonStatus ; wcfe9 ld bc, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 ld a, [H_WHOSETURN] ; $fff3 and a jp z, .asm_3f20e - ld de, W_PLAYERMONSTATUS ; W_PLAYERMONSTATUS + ld de, wBattleMonStatus ; wBattleMonStatus ld bc, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 .asm_3f20e @@ -7115,12 +7115,12 @@ AlreadyAsleepText: ; 3f24a (f:724a) db "@" PoisonEffect: ; 3f24f (f:724f) - ld hl, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonStatus ; wcfe9 ld de, W_PLAYERMOVEEFFECT ; wcfd3 ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3f260 - ld hl, W_PLAYERMONSTATUS ; W_PLAYERMONSTATUS + ld hl, wBattleMonStatus ; wBattleMonStatus ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT .asm_3f260 call CheckTargetSubstitute @@ -7214,12 +7214,12 @@ DrainHPEffect: ; 3f2e9 (f:72e9) jp Bankswitch ExplodeEffect: ; 3f2f1 (f:72f1) - ld hl, W_PLAYERMONCURHP ; wd015 + ld hl, wBattleMonHP ; wd015 ld de, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3f302 - ld hl, W_ENEMYMONCURHP ; W_ENEMYMONCURHP + ld hl, wEnemyMonHP ; wEnemyMonHP ld de, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 .asm_3f302 xor a @@ -7240,16 +7240,16 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) ld a, [$fff3] ;whose turn? and a jp nz, opponentAttacker - ld a, [W_ENEMYMONSTATUS] + ld a, [wEnemyMonStatus] and a jp nz, CheckDefrost ;opponent has no existing status ld a, [W_PLAYERMOVETYPE] ld b, a - ld a, [W_ENEMYMONTYPE1] + ld a, [wEnemyMonType1] cp b ret z ;return if they match [can't freeze an ice type etc.] - ld a, [W_ENEMYMONTYPE2] + ld a, [wEnemyMonType2] cp b ret z ;return.. ld a, [W_PLAYERMOVEEFFECT] @@ -7271,14 +7271,14 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) cp a, FREEZE_SIDE_EFFECT jr z, .freeze ld a, 1 << PAR - ld [W_ENEMYMONSTATUS], a + ld [wEnemyMonStatus], a call Func_3ed27 ;quarter speed of affected monster ld a, $a9 call Func_3fbb9 ;animation jp PrintMayNotAttackText ;print paralysis text .burn ld a, 1 << BRN - ld [W_ENEMYMONSTATUS], a + ld [wEnemyMonStatus], a call Func_3ed64 ld a, $a9 call Func_3fbb9 ;animation @@ -7287,21 +7287,21 @@ FreezeBurnParalyzeEffect: ; 3f30c (f:730c) .freeze call Func_3f9cf ;resets bit 5 of the D063/D068 flags ld a, 1 << FRZ - ld [W_ENEMYMONSTATUS], a + ld [wEnemyMonStatus], a ld a, $a9 call Func_3fbb9 ;animation ld hl, FrozenText jp PrintText opponentAttacker: ; 3f382 (f:7382) - ld a, [W_PLAYERMONSTATUS] ;this appears to the same as above with addresses swapped for opponent + ld a, [wBattleMonStatus] ;this appears to the same as above with addresses swapped for opponent and a jp nz, CheckDefrost ld a, [W_ENEMYMOVETYPE] ld b, a - ld a, [W_PLAYERMONTYPE1] + ld a, [wBattleMonType1] cp b ret z - ld a, [W_PLAYERMONTYPE2] + ld a, [wBattleMonType2] cp b ret z ld a, [W_ENEMYMOVEEFFECT] @@ -7322,18 +7322,18 @@ opponentAttacker: ; 3f382 (f:7382) cp a, FREEZE_SIDE_EFFECT jr z, .freeze ld a, 1 << PAR - ld [W_PLAYERMONSTATUS], a + ld [wBattleMonStatus], a call Func_3ed27 jp PrintMayNotAttackText .burn ld a, 1 << BRN - ld [W_PLAYERMONSTATUS], a + ld [wBattleMonStatus], a call Func_3ed64 ld hl, BurnedText jp PrintText .freeze ld a, 1 << FRZ - ld [W_PLAYERMONSTATUS], a + ld [wBattleMonStatus], a ld hl, FrozenText jp PrintText @@ -7357,10 +7357,10 @@ CheckDefrost: ; 3f3e2 (f:73e2) sub a, FIRE ret nz ;return if it isn't fire ;type is fire - ld [W_ENEMYMONSTATUS], a ;set opponent status to 00 ["defrost" a frozen monster] - ld hl, wd8a8 ;status of first opponent monster in their roster - ld a, [W_ENEMYMONNUMBER] - ld bc, $002c ;$2C bytes per roster entry + ld [wEnemyMonStatus], a ;set opponent status to 00 ["defrost" a frozen monster] + ld hl, wEnemyMon1Status + ld a, [wEnemyMonPartyPos] + ld bc, wEnemyMon2 - wEnemyMon1 call AddNTimes xor a ld [hl], a ;clear status in roster @@ -7370,10 +7370,10 @@ CheckDefrost: ; 3f3e2 (f:73e2) ld a, [W_ENEMYMOVETYPE] ;same as above with addresses swapped sub a, FIRE ret nz - ld [W_PLAYERMONSTATUS], a - ld hl, W_PARTYMON1_STATUS + ld [wBattleMonStatus], a + ld hl, wPartyMon1Status ld a, [wPlayerMonNumber] - ld bc, $002c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes xor a ld [hl], a @@ -7422,12 +7422,12 @@ StatModifierUpEffect: ; 3f428 (f:7428) cp $4 jr nc, asm_3f4ca push hl - ld hl, W_PLAYERMONATK + 1 + ld hl, wBattleMonAttack + 1 ld de, wcd12 ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3f472 - ld hl, W_ENEMYMONATTACK + 1 + ld hl, wEnemyMonAttack + 1 ld de, wcd26 .asm_3f472 push bc @@ -7634,12 +7634,12 @@ StatModifierDownEffect: ; 3f54c (f:754c) jr nc, asm_3f62c push hl push de - ld hl, W_ENEMYMONATTACK + 1 + ld hl, wEnemyMonAttack + 1 ld de, wcd26 ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3f5d8 - ld hl, W_PLAYERMONATK + 1 + ld hl, wBattleMonAttack + 1 ld de, wcd12 .asm_3f5d8 push bc @@ -7857,7 +7857,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) jr nz, .asm_3f77e ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL ld b, a - ld a, [W_PLAYERMONLEVEL] ; W_PLAYERMONLEVEL + ld a, [wBattleMonLevel] ; wBattleMonLevel cp b jr nc, .asm_3f76e add b @@ -7897,7 +7897,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739) ld a, [W_ISINBATTLE] ; W_ISINBATTLE dec a jr nz, .asm_3f7d1 - ld a, [W_PLAYERMONLEVEL] ; W_PLAYERMONLEVEL + ld a, [wBattleMonLevel] ; wBattleMonLevel ld b, a ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL cp b @@ -8259,13 +8259,13 @@ MimicEffect: ; 3f9ed (f:79ed) jr nz, .asm_3fa74 ld a, [H_WHOSETURN] and a - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves ld a, [W_PLAYERBATTSTATUS1] jr nz, .asm_3fa13 ld a, [W_ISLINKBATTLE] cp $4 jr nz, .asm_3fa3a - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves ld a, [W_ENEMYBATTSTATUS1] .asm_3fa13 bit 6, a @@ -8284,10 +8284,10 @@ MimicEffect: ; 3f9ed (f:79ed) ld d, a ld a, [H_WHOSETURN] and a - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves ld a, [wPlayerMoveListIndex] jr z, .asm_3fa5f - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves ld a, [wEnemyMoveListIndex] jr .asm_3fa5f .asm_3fa3a @@ -8300,14 +8300,14 @@ MimicEffect: ; 3f9ed (f:79ed) ld [wMoveMenuType], a call MoveSelectionMenu call LoadScreenTilesFromBuffer1 - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves ld a, [wCurrentMenuItem] ld c, a ld b, $0 add hl, bc ld d, [hl] pop af - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves .asm_3fa5f ld c, a ld b, $0 @@ -8341,12 +8341,12 @@ DisableEffect: ; 3fa8a (f:7a8a) and a jr nz, .asm_3fb06 ld de, W_ENEMYDISABLEDMOVE ; W_ENEMYDISABLEDMOVE - ld hl, W_ENEMYMONMOVES + ld hl, wEnemyMonMoves ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3faa4 ld de, W_PLAYERDISABLEDMOVE ; W_PLAYERDISABLEDMOVE - ld hl, W_PLAYERMONMOVES + ld hl, wBattleMonMoves .asm_3faa4 ld a, [de] and a @@ -8366,14 +8366,14 @@ DisableEffect: ; 3fa8a (f:7a8a) push hl ld a, [H_WHOSETURN] ; $fff3 and a - ld hl, W_PLAYERMONPP ; W_PLAYERMONPP + ld hl, wBattleMonPP ; wBattleMonPP jr nz, .asm_3facf ld a, [W_ISLINKBATTLE] ; W_ISLINKBATTLE cp $4 pop hl jr nz, .asm_3fae1 push hl - ld hl, W_ENEMYMONPP ; wcffe + ld hl, wEnemyMonPP ; wcffe .asm_3facf push hl ld a, [hli] diff --git a/engine/battle/d.asm b/engine/battle/d.asm index 01753813..5a1010b8 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -7,7 +7,7 @@ Func_372d6: ; 372d6 (d:72d6) call TextBoxBorder FuncCoord 4, 5 ld hl, Coord - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call PlaceString FuncCoord 4, 10 ld hl, Coord diff --git a/engine/battle/e.asm b/engine/battle/e.asm index fbede5dd..f3eac4c9 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -2,10 +2,10 @@ Func_39680: ; 39680 (e:5680) ld a, [H_WHOSETURN] ; $fff3 and a ld a, [wd060] - ld hl, W_PLAYERMONATK + 1 + ld hl, wBattleMonAttack + 1 jr z, .asm_39691 ld a, [wd065] - ld hl, W_ENEMYMONATTACK + 1 + ld hl, wEnemyMonAttack + 1 .asm_39691 ld c, $4 ld b, a @@ -31,10 +31,10 @@ Func_396a7: ; 396a7 (e:56a7) ld a, [H_WHOSETURN] ; $fff3 and a ld a, [wd061] - ld hl, W_PLAYERMONATK + ld hl, wBattleMonAttack jr z, .asm_396b8 ld a, [wd066] - ld hl, W_ENEMYMONATTACK + ld hl, wEnemyMonAttack .asm_396b8 ld c, $4 ld b, a @@ -63,7 +63,7 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) ; Load the enemy trainer's pic and scrolls it into ; the screen from the right. xor a - ld [W_ENEMYMONID], a + ld [wEnemyMonSpecies2], a ld b, $1 call GoPAL_SET callab _LoadTrainerPic @@ -166,7 +166,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) jp [hl] ; execute modification function .loopFindMinimumEntries ; all entries will be decremented sequentially until one of them is zero ld hl, wHPBarMaxHP ; temp move selection array - ld de, W_ENEMYMONMOVES ; enemy moves + ld de, wEnemyMonMoves ; enemy moves ld c, $4 .loopDecrementEntries ld a, [de] @@ -188,7 +188,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) cp $5 jr nz, .loopUndoPartialIteration ld hl, wHPBarMaxHP ; temp move selection array - ld de, W_ENEMYMONMOVES ; enemy moves + ld de, wEnemyMonMoves ; enemy moves ld c, $4 .filterMinimalEntries ; all minimal entries now have value 1. All other slots will be disabled (move set to 0) ld a, [de] @@ -212,7 +212,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719) ld hl, wHPBarMaxHP ; use created temporary array as move set ret .useOriginalMoveSet - ld hl, W_ENEMYMONMOVES ; use original move set + ld hl, wEnemyMonMoves ; use original move set ret AIMoveChoiceModificationFunctionPointers: ; 397a3 (e:57a3) @@ -223,11 +223,11 @@ AIMoveChoiceModificationFunctionPointers: ; 397a3 (e:57a3) ; discourages moves that cause no damage but only a status ailment if player's mon already has one AIMoveChoiceModification1: ; 397ab (e:57ab) - ld a, [W_PLAYERMONSTATUS] + ld a, [wBattleMonStatus] and a ret z ; return if no status ailment on player's mon ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, W_ENEMYMONMOVES ; enemy moves + ld de, wEnemyMonMoves ; enemy moves ld b, $5 .nextMove dec b @@ -270,7 +270,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) cp $1 ret nz ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, W_ENEMYMONMOVES ; enemy moves + ld de, wEnemyMonMoves ; enemy moves ld b, $5 .nextMove dec b @@ -298,7 +298,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7) ; encourages moves that are effective against the player's mon AIMoveChoiceModification3: ; 39817 (e:5817) ld hl, wBuffer - 1 ; temp move selection array (-1 byte offest) - ld de, W_ENEMYMONMOVES ; enemy moves + ld de, wEnemyMonMoves ; enemy moves ld b, $5 .nextMove dec b @@ -328,7 +328,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817) push bc ld a, [W_ENEMYMOVETYPE] ld d, a - ld hl, W_ENEMYMONMOVES ; enemy moves + ld hl, wEnemyMonMoves ; enemy moves ld b, $5 ld c, $0 .loopMoves @@ -635,14 +635,14 @@ Func_39bd5: ; 39bd5 (e:5bd5) cp $1 jr nz, .asm_39be6 ld hl, wEnemyPartyCount ; wEnemyPartyCount - ld de, W_ENEMYMON1OT ; wd9ac OT names of other player + ld de, wEnemyMonOT ; wd9ac OT names of other player ld a, $6 jr .asm_39c18 .asm_39be6 cp $4 jr nz, .calcAttackStat4 - ld hl, W_NUMINPARTY ; W_NUMINPARTY - ld de, W_PARTYMON1OT ; wd273 + ld hl, wPartyCount ; wPartyCount + ld de, wPartyMonOT ; wd273 ld a, $5 jr .asm_39c18 .calcAttackStat4 @@ -681,13 +681,13 @@ Func_39bd5: ; 39bd5 (e:5bd5) ret Func_39c37: ; 39c37 (e:5c37) - ld hl, W_PARTYMON1 ; W_PARTYMON1 + ld hl, wPartySpecies ld a, [wcc49] and a jr z, .asm_39c4b dec a jr z, .asm_39c48 - ld hl, wda81 + ld hl, wBoxSpecies jr .asm_39c4b .asm_39c48 ld hl, wEnemyPartyMons @@ -791,8 +791,8 @@ ReadTrainer: ; 39c53 (e:5c53) add hl,bc ld a,[hli] ld d,[hl] - ld hl,W_ENEMYMON1MOVE3 - ld bc,W_ENEMYMON2MOVE3 - W_ENEMYMON1MOVE3 + ld hl,wEnemyMon1Moves + 2 + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes ld [hl],d jr .FinishUp @@ -821,13 +821,13 @@ ReadTrainer: ; 39c53 (e:5c53) jr .FinishUp ; nope .GiveTeamMoves ld a,[hl] - ld [W_ENEMYMON5MOVE3],a + ld [wEnemyMon5Moves + 2],a jr .FinishUp .ChampionRival ; give moves to his team ; pidgeot ld a,SKY_ATTACK - ld [W_ENEMYMON1MOVE3],a + ld [wEnemyMon1Moves + 2],a ; starter ld a,[W_RIVALSTARTER] @@ -840,7 +840,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld b,BLIZZARD ; must be squirtle .GiveStarterMove ld a,b - ld [W_ENEMYMON6MOVE3],a + ld [wEnemyMon6Moves + 2],a .FinishUp ; XXX this needs documenting xor a ; clear D079-D07B ld de,wd079 @@ -985,7 +985,7 @@ CooltrainerFAI: ; 3a601 (e:6601) BrockAI: ; 3a614 (e:6614) ; if his active monster has a status condition, use a full heal - ld a,[W_ENEMYMONSTATUS] + ld a,[wEnemyMonStatus] and a ret z jp AIUseFullHeal @@ -1094,23 +1094,23 @@ AIUseFullRestore: ; 3a6a0 (e:66a0) ld a,FULL_RESTORE ld [wcf05],a ld de,wHPBarOldHP - ld hl,W_ENEMYMONCURHP + 1 + ld hl,wEnemyMonHP + 1 ld a,[hld] ld [de],a inc de ld a,[hl] ld [de],a inc de - ld hl,W_ENEMYMONMAXHP + 1 + ld hl,wEnemyMonMaxHP + 1 ld a,[hld] ld [de],a inc de ld [wHPBarMaxHP],a - ld [W_ENEMYMONCURHP + 1],a + ld [wEnemyMonHP + 1],a ld a,[hl] ld [de],a ld [wHPBarMaxHP+1],a - ld [W_ENEMYMONCURHP],a + ld [wEnemyMonHP],a jr Func_3a718 AIUsePotion: ; 3a6ca (e:66ca) @@ -1134,7 +1134,7 @@ AIUseHyperPotion: ; 3a6d6 (e:66d6) AIRecoverHP: ; 3a6da (e:66da) ; heal b HP and print "trainer used $(a) on pokemon!" ld [wcf05],a - ld hl,W_ENEMYMONCURHP + 1 + ld hl,wEnemyMonHP + 1 ld a,[hl] ld [wHPBarOldHP],a add b @@ -1151,7 +1151,7 @@ AIRecoverHP: ; 3a6da (e:66da) inc hl ld a,[hld] ld b,a - ld de,W_ENEMYMONMAXHP + 1 + ld de,wEnemyMonMaxHP + 1 ld a,[de] dec de ld [wHPBarMaxHP],a @@ -1185,7 +1185,7 @@ Func_3a718: ; 3a718 (e:6718) Func_3a72a: ; 3a72a (e:672a) ld a,[wEnemyPartyCount] ld c,a - ld hl,W_ENEMYMON1HP + ld hl,wEnemyMon1HP ld d,0 ; keep count of unfainted monsters @@ -1215,13 +1215,13 @@ Func_3a74b: ; 3a74b (e:674b) ; prepare to withdraw the active monster: copy hp, number, and status to roster - ld a,[W_ENEMYMONNUMBER] - ld hl,W_ENEMYMON1HP - ld bc,$2C + ld a,[wEnemyMonPartyPos] + ld hl,wEnemyMon1HP + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes ld d,h ld e,l - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld bc,4 call CopyData @@ -1252,13 +1252,13 @@ AIUseFullHeal: ; 3a786 (e:6786) AICureStatus: ; 3a791 (e:6791) ; cures the status of enemy's active pokemon - ld a,[W_ENEMYMONNUMBER] - ld hl,wd8a8 - ld bc,$2C + ld a,[wEnemyMonPartyPos] + ld hl,wEnemyMon1Status + ld bc,wEnemyMon2 - wEnemyMon1 call AddNTimes xor a ld [hl],a ; clear status in enemy team roster - ld [W_ENEMYMONSTATUS],a ; clear status of active enemy + ld [wEnemyMonStatus],a ; clear status of active enemy ld hl,W_ENEMYBATTSTATUS3 res 0,[hl] ret @@ -1286,7 +1286,7 @@ AIUseDireHit: ; 0x3a7c2 unused Func_3a7cf: ; 3a7cf (e:67cf) ld [H_DIVISOR],a - ld hl,W_ENEMYMONMAXHP + ld hl,wEnemyMonMaxHP ld a,[hli] ld [H_DIVIDEND],a ld a,[hl] @@ -1297,7 +1297,7 @@ Func_3a7cf: ; 3a7cf (e:67cf) ld c,a ld a,[H_QUOTIENT + 2] ld b,a - ld hl,W_ENEMYMONCURHP + 1 + ld hl,wEnemyMonHP + 1 ld a,[hld] ld e,a ld a,[hl] @@ -1388,8 +1388,8 @@ LoadPartyPokeballGfx: ; 3a85d (e:685d) SetupOwnPartyPokeballs: ; 3a869 (e:6869) call PlacePlayerHUDTiles - ld hl, W_PARTYMON1DATA - ld de, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyMon1 + ld de, wPartyCount ; wPartyCount call SetupPokeballs ld a, $60 ld hl, W_BASECOORDX ; wd081 @@ -1537,8 +1537,8 @@ PlaceHUDTiles: ; 3a930 (e:6930) SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) call LoadPartyPokeballGfx - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) - ld de, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) + ld de, wPartyCount ; wPartyCount call SetupPokeballs ld hl, W_BASECOORDX ; wd081 ld a, $50 diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index ded22347..37b6a0a3 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -1,12 +1,12 @@ HealEffect_: ; 3b9ec (e:79ec) ld a, [H_WHOSETURN] ; $fff3 and a - ld de, W_PLAYERMONCURHP ; wd015 - ld hl, W_PLAYERMONMAXHP ; wd023 + ld de, wBattleMonHP ; wd015 + ld hl, wBattleMonMaxHP ; wd023 ld a, [W_PLAYERMOVENUM] ; wcfd2 jr z, .asm_3ba03 - ld de, W_ENEMYMONCURHP ; W_ENEMYMONCURHP - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld de, wEnemyMonHP ; wEnemyMonHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM .asm_3ba03 ld b, a @@ -25,11 +25,11 @@ HealEffect_: ; 3b9ec (e:79ec) push af ld c, $32 call DelayFrames - ld hl, W_PLAYERMONSTATUS ; W_PLAYERMONSTATUS + ld hl, wBattleMonStatus ; wBattleMonStatus ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_3ba25 - ld hl, W_ENEMYMONSTATUS ; wcfe9 + ld hl, wEnemyMonStatus ; wcfe9 .asm_3ba25 ld a, [hl] and a @@ -120,15 +120,15 @@ RegainedHealthText: ; 3baac (e:7aac) db "@" TransformEffect_: ; 3bab1 (e:7ab1) - ld hl, W_PLAYERMONID - ld de, wcfe5 + ld hl, wBattleMonSpecies + ld de, wEnemyMonSpecies ld bc, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 ld a, [W_ENEMYBATTSTATUS1] ; W_ENEMYBATTSTATUS1 ld a, [H_WHOSETURN] ; $fff3 and a jr nz, .asm_3bad1 - ld hl, wcfe5 - ld de, W_PLAYERMONID + ld hl, wEnemyMonSpecies + ld de, wBattleMonSpecies ld bc, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm index ea7249da..99e1492d 100755 --- a/engine/battle/safari_zone.asm +++ b/engine/battle/safari_zone.asm @@ -15,7 +15,7 @@ PrintSafariZoneBattleText: ; 4277 (1:4277) ld hl, SafariZoneAngryText jr nz, .asm_429f push hl - ld a, [wcfe5] + ld a, [wEnemyMonSpecies] ld [wd0b5], a call GetMonHeader ld a, [W_MONHCATCHRATE] diff --git a/engine/cable_club.asm b/engine/cable_club.asm index a09a3b06..afca9392 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -63,7 +63,7 @@ Func_5345: ; 5345 ld a, b or c jr nz, .asm_537d - ld hl, W_PARTYMONEND + ld hl, wPartyMons - 1 ld de, wTileMapBackup + 10 ld bc, $0 .asm_538d @@ -191,7 +191,7 @@ Func_5345: ; 5345 or c jr nz, .asm_5456 ld de, wTileMapBackup - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMons ld c, $2 .asm_546a ld a, [de] @@ -206,7 +206,7 @@ Func_5345: ; 5345 jr z, .asm_5489 push hl push bc - ld b, $0 + ld b, 0 dec a ld c, a add hl, bc @@ -216,11 +216,11 @@ Func_5345: ; 5345 pop hl jr .asm_546a .asm_5489 - ld hl, W_PARTYMON6DATA + W_PARTYMON1_MOVE4PP - W_PARTYMON1DATA ; wd267 + ld hl, wPartyMons + $fc ; wd267 dec c jr nz, .asm_546a ld de, wTileMapBackup + 200 - ld hl, W_WATERRATE ; wEnemyMon1Species + ld hl, wEnemyMons ld c, $2 .asm_5497 ld a, [de] @@ -245,7 +245,7 @@ Func_5345: ; 5345 pop hl jr .asm_5497 .asm_54b6 - ld hl, wd9a0 + ld hl, wEnemyMons + $fc dec c jr nz, .asm_5497 ld a, $ac @@ -370,7 +370,7 @@ TradeCenter_SelectMon: ld [hl], a ld a, [wCurrentMenuItem] ld b, a - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] dec a cp b jr nc, .asm_55dc ; 0x55cd $d @@ -386,7 +386,7 @@ TradeCenter_SelectMon: ld [wcc37], a ld a, $91 ld [wMenuWatchedKeys], a - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] ld [wMaxMenuItem], a ld a, $1 ld [wTopMenuItemY], a @@ -550,7 +550,7 @@ TradeCenter_SelectMon: jr z, .asm_574a ; 0x5758 $f0 ld a, $7f ld [wTileMap + $141], a - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] dec a ld [wCurrentMenuItem], a jp .asm_55dc @@ -629,13 +629,13 @@ Func_57f2: ld c, $12 call Func_5ab3 ld hl, wTileMap + $5 - ld de, W_PLAYERNAME + ld de, wPlayerName call PlaceString ld hl, wTileMap + $a5 ld de, W_GRASSRATE call PlaceString ld hl, wTileMap + $16 - ld de, W_PARTYMON1 + ld de, wPartySpecies call Func_5827 ld hl, wTileMap + $b6 ld de, wEnemyPartyMons @@ -678,7 +678,7 @@ TradeCenter_Trade: ld c, $12 call Func_5ab3 ld a, [wWhichTrade] - ld hl, W_PARTYMON1 + ld hl, wPartySpecies ld c, a ld b, $0 add hl, bc @@ -740,12 +740,12 @@ TradeCenter_Trade: jp Func_5a18 .asm_58fd ld a, [wWhichTrade] - ld hl, W_PARTYMON1OT ; OT names of player + ld hl, wPartyMonOT ; OT names of player call SkipFixedLengthTextEntries ld de, wTrainerScreenX ld bc, $000b call CopyData - ld hl, W_PARTYMON1_NUM + ld hl, wPartyMon1Species ld a, [wWhichTrade] ld bc, $002c call AddNTimes @@ -756,7 +756,7 @@ TradeCenter_Trade: ld a, [hl] ld [wcd4d], a ld a, [wTrainerEngageDistance] - ld hl, W_ENEMYMON1OT ; OT names of other player + ld hl, wEnemyMonOT ; OT names of other player call SkipFixedLengthTextEntries ld de, wcd4e ld bc, $000b @@ -773,7 +773,7 @@ TradeCenter_Trade: ld [wcd5a], a ld a, [wWhichTrade] ld [wWhichPokemon], a - ld hl, W_PARTYMON1 + ld hl, wPartySpecies ld b, $0 ld c, a add hl, bc @@ -799,7 +799,7 @@ TradeCenter_Trade: ld bc, $002c call CopyData call AddEnemyMonToPlayerParty - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] dec a ld [wWhichPokemon], a ld a, $1 diff --git a/engine/evolve_trade.asm b/engine/evolve_trade.asm index 792d8cec..ffb8a778 100755 --- a/engine/evolve_trade.asm +++ b/engine/evolve_trade.asm @@ -31,7 +31,7 @@ EvolveTradeMon: ; 17d7d (5:7d7d) ret nz .ok - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount dec a ld [wWhichPokemon], a ; wWhichPokemon ld a, $1 diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 660d838e..432e488f 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -17,7 +17,7 @@ Func_3ad1c: ; 3ad1c (e:6d1c) push hl push bc push de - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount push hl asm_3ad2e: ; 3ad2e (e:6d2e) ld hl, wWhichPokemon ; wWhichPokemon @@ -107,7 +107,7 @@ Func_3ad71: ; 3ad71 (e:6d71) ld a, [hl] ld [wHPBarMaxHP + 1], a ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call GetPartyMonName call CopyStringToCF4B ld hl, IsEvolvingText @@ -170,7 +170,7 @@ Func_3ad71: ; 3ad71 (e:6d71) ld b, $1 call CalcStats ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) ld bc, $2c call AddNTimes ld e, l @@ -275,7 +275,7 @@ Func_3aef7: ; 3aef7 (e:6ef7) jr nz, .asm_3af0e ld a, [wWhichPokemon] ; wWhichPokemon ld bc, $b - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call AddNTimes push hl call GetName @@ -344,7 +344,7 @@ Func_3af5b: ; 3af5b (e:6f5b) ld a, [wcc49] and a jr nz, .asm_3af96 - ld hl, W_PARTYMON1_MOVE1 ; W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ; wPartyMon1Moves ld a, [wWhichPokemon] ; wWhichPokemon ld bc, $2c call AddNTimes diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 8cd58421..14d75472 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -2,7 +2,7 @@ _GivePokemon: ; 4fda5 (13:7da5) call EnableAutoTextBoxDrawing xor a ld [wccd3], a - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount cp $6 jr c, .asm_4fe01 ld a, [W_NUMINBOX] ; wda80 @@ -11,7 +11,7 @@ _GivePokemon: ; 4fda5 (13:7da5) xor a ld [W_ENEMYBATTSTATUS3], a ; W_ENEMYBATTSTATUS3 ld a, [wcf91] - ld [W_ENEMYMONID], a + ld [wEnemyMonSpecies2], a callab Func_3eb01 call SetPokedexOwnedFlag callab Func_e7a4 diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 981e1db5..b44a88e1 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -36,7 +36,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld c, BANK(Music_HallOfFame) ld a, MUSIC_HALL_OF_FAME call PlayMusic - ld hl, W_PARTYMON1 ; W_PARTYMON1 + ld hl, wPartySpecies ld c, $ff .asm_701fb ld a, [hli] @@ -48,7 +48,7 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) ld [wWhichTrade], a ; wWhichTrade ld a, c ld [wTrainerEngageDistance], a - ld hl, W_PARTYMON1_LEVEL ; W_PARTYMON1_LEVEL + ld hl, wPartyMon1Level ; wPartyMon1Level ld bc, $2c call AddNTimes ld a, [hl] @@ -105,7 +105,7 @@ Func_70278: ; 70278 (1c:4278) ld a, [wWhichTrade] ; wWhichTrade ld [wcf91], a ld [wd0b5], a - ld [wcfd9], a + ld [wBattleMonSpecies2], a ld [wcf1d], a ld a, [wTrainerScreenY] and a @@ -152,7 +152,7 @@ Func_70278: ; 70278 (1c:4278) Func_702e1: ; 702e1 (1c:42e1) ld a, [wTrainerEngageDistance] - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call GetPartyMonName call Func_702f0 jp Func_70404 @@ -232,7 +232,7 @@ Func_70377: ; 70377 (1c:4377) call TextBoxBorder FuncCoord 7, 2 ld hl, Coord - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call PlaceString FuncCoord 1, 6 ld hl, Coord diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index 822606b7..e39cdb67 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -103,7 +103,7 @@ Func_71c07: ; 71c07 (1c:5c07) ld a,$2 jr nz,.asm_c4bc2 ; 0x71c26 $75 ld a,[wWhichPokemon] - ld hl,W_PARTYMON1_LEVEL + ld hl,wPartyMon1Level ld bc,$002c call AddNTimes ld a,[hl] @@ -170,7 +170,7 @@ Func_71cc1: ; 71cc1 (1c:5cc1) ld [hli], a ld a, [wcd34] ld [hl], a - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld bc, $b ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes @@ -182,7 +182,7 @@ Func_71cc1: ; 71cc1 (1c:5cc1) call Func_71d11 ld de, W_GRASSRATE ; W_GRASSRATE call Func_71d11 - ld hl, W_PARTYMON1_OTID ; W_PARTYMON1_OTID + ld hl, wPartyMon1OTID ; wPartyMon1OTID ld bc, $2c ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes @@ -203,19 +203,19 @@ Func_71d11: ; 71d11 (1c:5d11) ret Func_71d19: ; 71d19 (1c:5d19) - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld bc, $b call Func_71d4f ld hl, wcd29 ld bc, $b call CopyData - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld bc, $b call Func_71d4f ld hl, String_71d59 ; $5d59 ld bc, $b call CopyData - ld hl, W_PARTYMON1_OTID ; W_PARTYMON1_OTID + ld hl, wPartyMon1OTID ; wPartyMon1OTID ld bc, $2c call Func_71d4f ld hl, wcd59 @@ -223,7 +223,7 @@ Func_71d19: ; 71d19 (1c:5d19) jp CopyData Func_71d4f: ; 71d4f (1c:5d4f) - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount dec a call AddNTimes ld e, l diff --git a/engine/items/items.asm b/engine/items/items.asm index e5a6c210..fbf013c4 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -109,7 +109,7 @@ ItemUseBall: ; d687 (3:5687) ld a,[W_BATTLETYPE] dec a jr z,.UseBall - ld a,[W_NUMINPARTY] ;is Party full? + ld a,[wPartyCount] ;is Party full? cp a,6 jr nz,.UseBall ld a,[W_NUMINBOX] ;is Box full? @@ -141,7 +141,7 @@ ItemUseBall: ; d687 (3:5687) jr nz,.notOldManBattle .oldManBattle ld hl,W_GRASSRATE - ld de,W_PLAYERNAME + ld de,wPlayerName ld bc,11 call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno glitch) jp .BallSuccess ;$578b @@ -149,7 +149,7 @@ ItemUseBall: ; d687 (3:5687) ld a,[W_CURMAP] cp a,POKEMONTOWER_6 jr nz,.loop - ld a,[W_ENEMYMONID] + ld a,[wEnemyMonSpecies2] cp a,MAROWAK ld b,$10 jp z,.next12 @@ -178,7 +178,7 @@ ItemUseBall: ; d687 (3:5687) ; Frozen/Asleep pokemon are relatively even easier to catch ; for Frozen/Asleep pokemon, any random number from 0-24 ensures a catch. ; for the others, a random number from 0-11 ensures a catch. - ld a,[W_ENEMYMONSTATUS] ;status ailments + ld a,[wEnemyMonStatus] ;status ailments and a jr z,.noAilments and a, 1 << FRZ | SLP ;is frozen and/or asleep? @@ -194,7 +194,7 @@ ItemUseBall: ; d687 (3:5687) push bc ;save RANDOM number xor a ld [H_MULTIPLICAND],a - ld hl,W_ENEMYMONMAXHP + ld hl,wEnemyMonMaxHP ld a,[hli] ld [H_MULTIPLICAND + 1],a ld a,[hl] @@ -211,7 +211,7 @@ ItemUseBall: ; d687 (3:5687) ld [H_DIVISOR],a ld b,4 ; number of bytes in dividend call Divide - ld hl,W_ENEMYMONCURHP + ld hl,wEnemyMonHP ld a,[hli] ld b,a ld a,[hl] @@ -287,7 +287,7 @@ ItemUseBall: ; d687 (3:5687) ld [H_DIVISOR],a ld b,4 call Divide - ld a,[W_ENEMYMONSTATUS] ;status ailments + ld a,[wEnemyMonStatus] ;status ailments and a jr z,.next13 and a, 1 << FRZ | SLP @@ -348,7 +348,7 @@ ItemUseBall: ; d687 (3:5687) cp a,$63 ld hl,ItemUseBallText04 jp z,.printText0 - ld hl,W_ENEMYMONCURHP ;current HP + ld hl,wEnemyMonHP ;current HP ld a,[hli] push af ld a,[hli] @@ -361,21 +361,21 @@ ItemUseBall: ; d687 (3:5687) bit 3,[hl] jr z,.next15 ld a,$4c - ld [W_ENEMYMONID],a + ld [wEnemyMonSpecies2],a jr .next16 .next15 ;$5871 set 3,[hl] ld hl,wcceb - ld a,[W_ENEMYMONATKDEFIV] + ld a,[wEnemyMonDVs] ld [hli],a - ld a,[W_ENEMYMONSPDSPCIV] + ld a,[wEnemyMonDVs + 1] ld [hl],a .next16 ;$587e ld a,[wcf91] push af - ld a,[W_ENEMYMONID] + ld a,[wEnemyMonSpecies2] ld [wcf91],a - ld a,[W_ENEMYMONLEVEL] + ld a,[wEnemyMonLevel] ld [W_CURENEMYLVL],a callab Func_3eb01 pop af @@ -388,7 +388,7 @@ ItemUseBall: ; d687 (3:5687) ld [hld],a pop af ld [hl],a - ld a,[wcfe5] ;enemy + ld a,[wEnemyMonSpecies] ;enemy ld [wd11c],a ld [wcf91],a ld [wd11e],a @@ -420,12 +420,12 @@ ItemUseBall: ; d687 (3:5687) ld hl,ItemUseBallText06 call PrintText call ClearSprites - ld a,[wcfe5] ;caught mon_ID + ld a,[wEnemyMonSpecies] ;caught mon_ID ld [wd11e],a ld a,$3d call Predef .checkParty ;$58f4 - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] cp a,6 ;is party full? jr z,.sendToBox xor a @@ -677,7 +677,7 @@ ItemUseVitamin: ; dab4 (3:5ab4) jp nz,ItemUseNotTime ItemUseMedicine: ; dabb (3:5abb) - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] and a jp z,.emptyParty ld a,[wWhichPokemon] @@ -707,8 +707,8 @@ ItemUseMedicine: ; dabb (3:5abb) call DisplayPartyMenu .getPartyMonDataAddress jp c,.canceledItemUse - ld hl,W_PARTYMON1DATA - ld bc,44 + ld hl,wPartyMons + ld bc,wPartyMon2 - wPartyMon1 ld a,[wWhichPokemon] call AddNTimes ld a,[wWhichPokemon] @@ -773,14 +773,14 @@ ItemUseMedicine: ; dabb (3:5abb) jp nz,.doneHealing ; if it is active in battle xor a - ld [W_PLAYERMONSTATUS],a ; remove the status ailment in the in-battle pokemon data + ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data push hl ld hl,W_PLAYERBATTSTATUS3 res 0,[hl] ; heal Toxic status pop hl ld bc,30 add hl,bc ; hl now points to party stats - ld de,W_PLAYERMONMAXHP + ld de,wBattleMonMaxHP ld bc,10 call CopyData ; copy party stats to in-battle stat data ld a,$28 @@ -821,7 +821,7 @@ ItemUseMedicine: ; dabb (3:5abb) jr z,.next ld a,[wcf06] ld c,a - ld hl,W_PLAYERMONSALIVEFLAGS + ld hl,wPartyAliveFlags ld b,$01 ld a,$10 call Predef @@ -890,9 +890,9 @@ ItemUseMedicine: ; dabb (3:5abb) push af ld a,[hl] push af - ld hl,W_PARTYMON1_MAXHP + ld hl,wPartyMon1MaxHP ld a,[wWhichPokemon] - ld bc,44 + ld bc,wPartyMon2 - wPartyMon1 call AddNTimes ld a,[hli] ld [wHPBarMaxHP + 1],a @@ -904,7 +904,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [H_DIVISOR],a ld b,2 ; number of bytes call Divide ; get 1/5 of max HP of pokemon that used Softboiled - ld bc,-33 + ld bc,wPartyMon1HP - wPartyMon1MaxHP add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled ; subtract 1/5 of max HP from current HP of pokemon that used Softboiled ld a,[H_QUOTIENT + 3] @@ -1045,14 +1045,14 @@ ItemUseMedicine: ; dabb (3:5abb) jr nz,.calculateHPBarCoords ; copy party HP to in-battle HP ld a,[hli] - ld [W_PLAYERMONCURHP],a + ld [wBattleMonHP],a ld a,[hld] - ld [W_PLAYERMONCURHP + 1],a + ld [wBattleMonHP + 1],a ld a,[wcf91] cp a,FULL_RESTORE jr nz,.calculateHPBarCoords xor a - ld [W_PLAYERMONSTATUS],a ; remove the status ailment in the in-battle pokemon data + ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data .calculateHPBarCoords ld hl,wOAMBuffer + $90 ld bc,2 * 20 @@ -1143,7 +1143,7 @@ ItemUseMedicine: ; dabb (3:5abb) call GetMonHeader push de ld a,d - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName pop de pop hl @@ -1634,20 +1634,20 @@ ItemUsePokeflute: ; e140 (3:6140) xor a ld [wWhichTrade],a ; initialize variable that indicates if any pokemon were woken up to zero ld b,~SLP & $FF - ld hl,W_PARTYMON1_STATUS + ld hl,wPartyMon1Status call WakeUpEntireParty ld a,[W_ISINBATTLE] dec a ; is it a trainer battle? jr z,.skipWakingUpEnemyParty ; if it's a trainer battle - ld hl,wd8a8 ; enemy party pokemon 1 status + ld hl,wEnemyMon1Status call WakeUpEntireParty .skipWakingUpEnemyParty - ld hl,W_PLAYERMONSTATUS + ld hl,wBattleMonStatus ld a,[hl] and b ; remove Sleep status ld [hl],a - ld hl,W_ENEMYMONSTATUS + ld hl,wEnemyMonStatus ld a,[hl] and b ; remove Sleep status ld [hl],a @@ -1916,7 +1916,7 @@ ItemUsePPRestore: ; e31e (3:631e) ld a,0 ld [wPlayerMoveListIndex],a jr nz,.chooseMon - ld hl,W_PARTYMON1_MOVE1 + ld hl,wPartyMon1Moves ld bc,44 call GetSelectedMoveOffset push hl @@ -1958,10 +1958,10 @@ ItemUsePPRestore: ; e31e (3:631e) ld a,[wPlayerMonNumber] cp b ; is the pokemon whose PP was restored active in battle? jr nz,.skipUpdatingInBattleData - ld hl,W_PARTYMON1_MOVE1PP + ld hl,wPartyMon1PP ld bc,44 call AddNTimes - ld de,W_PLAYERMONPP + ld de,wBattleMonPP ld bc,4 call CopyData ; copy party data to in-battle data .skipUpdatingInBattleData @@ -1980,7 +1980,7 @@ ItemUsePPRestore: ; e31e (3:631e) xor a ld [wcc49],a ; party pokemon call GetMaxPP - ld hl,W_PARTYMON1_MOVE1 + ld hl,wPartyMon1Moves ld bc,44 call GetSelectedMoveOffset ld bc,21 @@ -2030,7 +2030,7 @@ ItemUsePPRestore: ; e31e (3:631e) ; loop through each move and restore PP .elixirLoop push bc - ld hl,W_PARTYMON1_MOVE1 + ld hl,wPartyMon1Moves ld bc,44 call GetSelectedMoveOffset ld a,[hl] @@ -2156,7 +2156,7 @@ ItemUseTMHM: ; e479 (3:6479) call Predef ; check if the pokemon can learn the move push bc ld a,[wWhichPokemon] - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName pop bc ld a,c @@ -2315,7 +2315,7 @@ GotOffBicycleText: ; e5fc (3:65fc) ; 1: using a PP Up ; [wCurrentMenuItem] = index of move (when using a PP Up) RestoreBonusPP: ; e606 (3:6606) - ld hl,W_PARTYMON1_MOVE1 + ld hl,wPartyMon1Moves ld bc,44 ld a,[wWhichPokemon] call AddNTimes @@ -2411,20 +2411,20 @@ AddBonusPP: ; e642 (3:6642) GetMaxPP: ; e677 (3:6677) ld a,[wcc49] and a - ld hl,W_PARTYMON1_MOVE1 - ld bc,44 + ld hl,wPartyMon1Moves + ld bc,wPartyMon2 - wPartyMon1 jr z,.sourceWithMultipleMon - ld hl,wd8ac ; enemy party + ld hl,wEnemyMon1Moves dec a jr z,.sourceWithMultipleMon - ld hl,wda9e ; current box - ld bc,33 + ld hl,wBoxMon1Moves + ld bc,wBoxMon2 - wBoxMon1 dec a jr z,.sourceWithMultipleMon - ld hl,wda67 ; daycare + ld hl,wDayCareMonMoves dec a jr z,.sourceWithOneMon - ld hl,W_PLAYERMONMOVES ; player's in-battle pokemon + ld hl,wBattleMonMoves ; player's in-battle pokemon .sourceWithOneMon call GetSelectedMoveOffset2 jr .next @@ -2607,7 +2607,7 @@ Func_e7a4: ; e7a4 (3:67a4) cp $ff jr nz, .asm_e7b1 call GetMonHeader - ld hl, W_BOXMON1OT + ld hl, wBoxMonOT ld bc, $b ld a, [W_NUMINBOX] ; wda80 dec a @@ -2637,14 +2637,14 @@ Func_e7a4: ; e7a4 (3:67a4) dec b jr nz, .asm_e7db .asm_e7ee - ld hl, W_PLAYERNAME ; wd158 - ld de, W_BOXMON1OT + ld hl, wPlayerName ; wd158 + ld de, wBoxMonOT ld bc, $b call CopyData ld a, [W_NUMINBOX] ; wda80 dec a jr z, .asm_e82a - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks ld bc, $b dec a call AddNTimes @@ -2671,7 +2671,7 @@ Func_e7a4: ; e7a4 (3:67a4) dec b jr nz, .asm_e817 .asm_e82a - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks ld a, $2 ld [wd07d], a ld a, $4e @@ -2679,12 +2679,12 @@ Func_e7a4: ; e7a4 (3:67a4) ld a, [W_NUMINBOX] ; wda80 dec a jr z, .asm_e867 - ld hl, W_BOXMON1DATA - ld bc, $21 + ld hl, wBoxMons + ld bc, wBoxMon2 - wBoxMon1 dec a call AddNTimes push hl - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 add hl, bc ld d, h ld e, l @@ -2695,7 +2695,7 @@ Func_e7a4: ; e7a4 (3:67a4) .asm_e854 push bc push hl - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 call CopyData pop hl ld d, h @@ -2706,10 +2706,10 @@ Func_e7a4: ; e7a4 (3:67a4) dec b jr nz, .asm_e854 .asm_e867 - ld a, [W_ENEMYMONLEVEL] ; W_ENEMYMONLEVEL - ld [W_ENEMYMONNUMBER], a ; W_ENEMYMONNUMBER - ld hl, wcfe5 - ld de, W_BOXMON1DATA + ld a, [wEnemyMonLevel] ; wEnemyMonLevel + ld [wEnemyMonBoxLevel], a + ld hl, wEnemyMon + ld de, wBoxMon1 ld bc, $c call CopyData ld hl, wPlayerID ; wPlayerID @@ -2740,13 +2740,13 @@ Func_e7a4: ; e7a4 (3:67a4) inc de dec b jr nz, .asm_e89f - ld hl, W_ENEMYMONATKDEFIV + ld hl, wEnemyMonDVs ld a, [hli] ld [de], a inc de ld a, [hli] ld [de], a - ld hl, W_ENEMYMONPP ; wcffe + ld hl, wEnemyMonPP ; wcffe ld b, $4 .asm_e8b1 ld a, [hli] diff --git a/engine/items/tmhm.asm b/engine/items/tmhm.asm index 20e5786b..01a48ebb 100755 --- a/engine/items/tmhm.asm +++ b/engine/items/tmhm.asm @@ -1,7 +1,7 @@ ; checks if the mon in wWhichPokemon already knows the move in wd0e0 CheckIfMoveIsKnown: ; 2fe18 (b:7e18) ld a, [wWhichPokemon] - ld hl, W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ld bc, $2c call AddNTimes ld a, [wd0e0] diff --git a/engine/learn_move.asm b/engine/learn_move.asm index 3d72fdaa..0561abcd 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -1,7 +1,7 @@ LearnMove: ; 6e43 (1:6e43) call SaveScreenTilesToBuffer1 ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call GetPartyMonName ld hl, wcd6d ld de, wd036 @@ -9,7 +9,7 @@ LearnMove: ; 6e43 (1:6e43) call CopyData DontAbandonLearning: ; 6e5b (1:6e5b) - ld hl, W_PARTYMON1_MOVE1 ; W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ; wPartyMon1Moves ld bc, $2c ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes @@ -63,12 +63,12 @@ DontAbandonLearning: ; 6e5b (1:6e5b) jp nz, PrintLearnedMove ld h, d ld l, e - ld de, W_PLAYERMONMOVES + ld de, wBattleMonMoves ld bc, $4 call CopyData ld bc, $11 add hl, bc - ld de, W_PLAYERMONPP ; W_PLAYERMONPP + ld de, wBattleMonPP ; wBattleMonPP ld bc, $4 call CopyData jp PrintLearnedMove diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index bfcdcb9b..e48f6bd3 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -44,7 +44,7 @@ Func_213c8:: ; 213c8 (8:53c8) call PlaceString FuncCoord 2, 4 ld hl, Coord - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call PlaceString ld l, c ld h, b @@ -232,7 +232,7 @@ Func_21588: ; 21588 (8:5588) Func_215ac: ; 215ac (8:55ac) BillsPCDeposit: - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount dec a jr nz, .asm_215bb ld hl, CantDepositLastMonText @@ -246,7 +246,7 @@ BillsPCDeposit: call PrintText jp BillsPCMenu .asm_215cb - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount call Func_216be jp c, BillsPCMenu call Func_2174b @@ -288,7 +288,7 @@ Func_21618: ; 21618 (8:5618) call PrintText jp Func_214e8 .asm_21627 - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount cp $6 jr nz, .asm_21637 ld hl, CantTakeMonText ; $5811 @@ -301,7 +301,7 @@ Func_21618: ; 21618 (8:5618) call Func_2174b jp nc, Func_214e8 ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks call GetPartyMonName ld a, [wcf91] call GetCryData @@ -372,21 +372,21 @@ BoxNoPCText: ; 21713 (8:5713) db "BOX No.@" Func_2171b:: ; 2171b (8:571b) - ld hl, W_PARTYMON1_MOVE1 - ld bc, $002c + ld hl, wPartyMon1Moves + ld bc, wPartyMon2 - wPartyMon1 jr .asm_21729 ; 0x21721 $6 - ld hl, wda9e - ld bc, $0021 + ld hl, wBoxMon1Moves + ld bc, wBoxMon2 - wBoxMon1 .asm_21729 ld a, [wWhichPokemon] call AddNTimes - ld b, $4 + ld b, NUM_MOVES .asm_21731 ld a, [hli] push hl push bc ld hl, HMMoveArray ; $5745 - ld de, $0001 + ld de, 1 call IsInArray pop bc pop hl diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index 58b613c5..e31e31aa 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -36,7 +36,7 @@ DisplayDiploma: ; 566e2 (15:66e2) jr nz, .asm_56715 ; 0x56725 $ee FuncCoord 10, 4 ld hl, Coord - ld de, W_PLAYERNAME + ld de, wPlayerName call PlaceString callba Func_44dd ld hl, wOAMBuffer + $01 @@ -68,7 +68,7 @@ DisplayDiploma: ; 566e2 (15:66e2) jp GBPalNormal Func_56777: ; 56777 (15:6777) - ld hl, W_PLAYERNAME + ld hl, wPlayerName ld bc, $ff00 .asm_5677d ld a, [hli] diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index a98f5f3f..9048fc39 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -83,7 +83,7 @@ Func_76610: ; 76610 (1d:6610) ld [wWhichTrade], a ld [wcf91], a ld [wd0b5], a - ld [wcfd9], a + ld [wBattleMonSpecies2], a ld [wcf1d], a ld a, [hli] ld [wTrainerFacingDirection], a diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index ef6e9899..5f2c1cd5 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -355,7 +355,7 @@ ContinueGame: ; 5db5 (1:5db5) call PlaceString FuncCoord 12, 9 ld hl, Coord - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call PlaceString FuncCoord 17, 11 ld hl, Coord @@ -384,7 +384,7 @@ PrintSaveScreenText: ; 5def (1:5def) ld de, SaveScreenInfoText call PlaceString ld hl, wTileMap + $34 - ld de, W_PLAYERNAME + ld de, wPlayerName call PlaceString ld hl, wTileMap + $61 call Func_5e2f diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 26e7227f..35c8be12 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -67,7 +67,7 @@ Func_655c: ; 655c (1:655c) ld a, [wcf4b] cp $50 jr z, .asm_6594 - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld bc, $b ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index aefb2438..8ad5260d 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -32,7 +32,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) callba SendBlkPacket_PartyMenu ; loads some data to wcf2e FuncCoord 3,0 ld hl,Coord - ld de,W_PARTYMON1 + ld de,wPartySpecies xor a ld c,a ld [$FF8C],a ; loop counter @@ -46,7 +46,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) push hl ld a,c push hl - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName pop hl call PlaceString ; print the pokemon's name @@ -231,7 +231,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) ld l,a push hl ld a,[wcf06] - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName pop hl call PrintText diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 931de340..6a21a50e 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -8,7 +8,7 @@ StartMenu_Pokedex: ; 13095 (4:7095) jp RedisplayStartMenu StartMenu_Pokemon: ; 130a9 (4:70a9) - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] and a jp z,RedisplayStartMenu xor a @@ -86,7 +86,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) add hl,bc jp .choseOutOfBattleMove .choseSwitch - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] cp a,2 ; is there more than one pokemon in the party? jp c,StartMenu_Pokemon ; if not, no switching call SwitchPartyMon_Stats @@ -107,7 +107,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) .choseOutOfBattleMove push hl ld a,[wWhichPokemon] - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName pop hl ld a,[hl] @@ -138,7 +138,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) call CheckIfInOutsideMap jr z,.canFly ld a,[wWhichPokemon] - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName ld hl,.cannotFlyHereText call PrintText @@ -211,7 +211,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) call CheckIfInOutsideMap jr z,.canTeleport ld a,[wWhichPokemon] - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks call GetPartyMonName ld hl,.cannotUseTeleportNowText call PrintText @@ -239,9 +239,9 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) TX_FAR _CannotFlyHereText db "@" .softboiled - ld hl,W_PARTYMON1_MAXHP + ld hl,wPartyMon1MaxHP ld a,[wWhichPokemon] - ld bc,44 + ld bc,wPartyMon2 - wPartyMon1 call AddNTimes ld a,[hli] ld [H_DIVIDEND],a @@ -251,7 +251,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ld [H_DIVISOR],a ld b,2 ; number of bytes call Divide - ld bc,-33 + ld bc,wPartyMon1HP - wPartyMon1MaxHP add hl,bc ld a,[hld] ld b,a @@ -615,7 +615,7 @@ DrawTrainerInfo: ; 1349a (4:749a) call PlaceString FuncCoord 7,2 ld hl,Coord - ld de,W_PLAYERNAME + ld de,wPlayerName call PlaceString FuncCoord 8,4 ld hl,Coord @@ -788,7 +788,7 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld [wcc35], a push hl push de - ld hl, W_PARTYMON1 ; W_PARTYMON1 + ld hl, wPartySpecies ld d, h ld e, l ld a, [wCurrentMenuItem] ; wCurrentMenuItem @@ -809,15 +809,15 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld [hl], a ld a, [H_DIVIDEND] ; $ff95 (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT) ld [de], a - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) - ld bc, $2c + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 ld a, [wCurrentMenuItem] ; wCurrentMenuItem call AddNTimes push hl ld de, wcc97 ld bc, $2c call CopyData - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMons ld bc, $2c ld a, [wcc35] call AddNTimes @@ -829,14 +829,14 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld hl, wcc97 ld bc, $2c call CopyData - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld a, [wCurrentMenuItem] ; wCurrentMenuItem call SkipFixedLengthTextEntries push hl ld de, wcc97 ld bc, $b call CopyData - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld a, [wcc35] call SkipFixedLengthTextEntries pop de @@ -847,14 +847,14 @@ SwitchPartyMon_Stats: ; 13653 (4:7653) ld hl, wcc97 ld bc, $b call CopyData - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [wCurrentMenuItem] ; wCurrentMenuItem call SkipFixedLengthTextEntries push hl ld de, wcc97 ld bc, $b call CopyData - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [wcc35] call SkipFixedLengthTextEntries pop de diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index ed042480..2d33e79f 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -143,15 +143,15 @@ StatusScreen: ; 12953 (4:6953) jp SkipFixedLengthTextEntries OTPointers: ; 12a95 (4:6a95) - dw W_PARTYMON1OT - dw W_ENEMYMON1OT - dw W_BOXMON1OT + dw wPartyMonOT + dw wEnemyMonOT + dw wBoxMonOT dw W_DAYCAREMONOT NamePointers2: ; 12a9d (4:6a9d) - dw W_PARTYMON1NAME - dw W_ENEMYMON1NAME - dw W_BOXMON1NAME + dw wPartyMonNicks + dw wEnemyMonNicks + dw wBoxMonNicks dw W_DAYCAREMONNAME Type1Text: ; 12aa5 (4:6aa5) diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index cfe34512..5b6a11a3 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -298,7 +298,7 @@ Func_71868: ; 71868 (1c:5868) push de push bc ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c - ld hl, W_PARTYMON1 ; W_PARTYMON1 + ld hl, wPartySpecies ld e, a ld d, $0 add hl, de diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index a85449df..8ca82b0b 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -5,7 +5,7 @@ SetDefaultNames: ; 60ca (1:60ca) push af ld a, [wd732] push af - ld hl, W_PLAYERNAME ; wd158 + ld hl, wPlayerName ; wd158 ld bc, $d8a xor a call FillMemory @@ -23,7 +23,7 @@ SetDefaultNames: ; 60ca (1:60ca) and a call z, Func_5bff ld hl, NintenText - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 ld bc, $b call CopyData ld hl, SonyText diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm index d7d13c47..380ff7bf 100755 --- a/engine/oak_speech2.asm +++ b/engine/oak_speech2.asm @@ -7,11 +7,11 @@ LoadDefaultNamesPlayer: ; 695d (1:695d) jr z, .asm_697a ld hl, DefaultNamesPlayerList ; $6af2 call Func_6ad6 - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call Func_69ec jr .asm_6999 .asm_697a - ld hl, W_PLAYERNAME ; wd158 + ld hl, wPlayerName ; wd158 xor a ld [wd07d], a call DisplayNamingScreen diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm index 922d01e7..29b52eb9 100755 --- a/engine/overworld/cut.asm +++ b/engine/overworld/cut.asm @@ -30,7 +30,7 @@ asm_ef82: ; ef82 (3:6f82) ld a, $1 ld [wcd6a], a ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call GetPartyMonName ld hl, wd730 set 6, [hl] diff --git a/engine/overworld/healing_machine.asm b/engine/overworld/healing_machine.asm index a30a5dff..9c93583d 100755 --- a/engine/overworld/healing_machine.asm +++ b/engine/overworld/healing_machine.asm @@ -24,7 +24,7 @@ AnimateHealingMachine: ; 70433 (1c:4433) ld a, [wMusicHeaderPointer] and a jr nz, .asm_70464 - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount ld b, a .asm_7046e call Func_70503 diff --git a/engine/palettes.asm b/engine/palettes.asm index 33f241d1..5eae18bd 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -31,11 +31,11 @@ BuildBattlePalPacket: ; 71e06 (1c:5e06) ld bc, $10 call CopyData ld a, [W_PLAYERBATTSTATUS3] - ld hl, W_PLAYERMONID + ld hl, wBattleMonSpecies call DeterminePaletteID ld b, a ld a, [W_ENEMYBATTSTATUS3] - ld hl, W_ENEMYMONID + ld hl, wEnemyMonSpecies2 call DeterminePaletteID ld c, a ld hl, wcf2e diff --git a/engine/predefs17_2.asm b/engine/predefs17_2.asm index 4cda1db3..a2dac120 100755 --- a/engine/predefs17_2.asm +++ b/engine/predefs17_2.asm @@ -1,7 +1,7 @@ ; updates the types of a party mon (pointed to in hl) to the ones of the mon specified in wd11e SetPartyMonTypes: ; 5db5e (17:5b5e) call GetPredefRegisters - ld bc, W_PARTYMON1_TYPE1 - W_PARTYMON1DATA ; $5 + ld bc, wPartyMon1Type - wPartyMon1 ; $5 add hl, bc ld a, [wd11e] ld [wd0b5], a diff --git a/engine/save.asm b/engine/save.asm index f2441ee3..9f7e326a 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -54,7 +54,7 @@ LoadSAVCheckSum: ; 73623 (1c:7623) .Func_73652 ; 73652 (1c:7652) ld hl, $a598 - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 ld bc, $b call CopyData ld hl, $a5a3 @@ -110,7 +110,7 @@ LoadSAVCheckSum2: ; 736bd (1c:76bd) cp c jp nz, SAVBadCheckSum ld hl, $af2c - ld de, W_NUMINPARTY ; W_NUMINPARTY + ld de, wPartyCount ; wPartyCount ld bc, $194 call CopyData ld hl, $a5a3 @@ -201,7 +201,7 @@ SaveSAVtoSRAM0: ; 7378c (1c:778c) ld a, $1 ld [$6000], a ld [$4000], a - ld hl, W_PLAYERNAME ; wd158 + ld hl, wPlayerName ; wd158 ld de, $a598 ld bc, $b call CopyData @@ -254,7 +254,7 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f) ld a, $1 ld [$6000], a ld [$4000], a - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount ld de, $af2c ld bc, $194 call CopyData diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index e281af31..d8a00e6f 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -5,7 +5,7 @@ CopyFixedLengthText: ; 42b1 (1:42b1) SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7) ld hl, NintenText - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call CopyFixedLengthText ld hl, SonyText ld de, W_RIVALNAME ; wd34a diff --git a/engine/trade.asm b/engine/trade.asm index 41f50bde..1a984ceb 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -151,12 +151,12 @@ Func_4120b: ; 4120b (10:520b) jp Bankswitch Func_41217: ; 41217 (10:5217) - ld hl, W_PLAYERNAME + ld hl, wPlayerName ld de, wHPBarMaxHP ld bc, $000b call CopyData ld hl, W_GRASSRATE - ld de, W_PLAYERNAME + ld de, wPlayerName ld bc, $000b call CopyData ld hl, wHPBarMaxHP @@ -427,7 +427,7 @@ Func_4142d: ; 4142d (10:542d) call TextBoxBorder FuncCoord 5, 14 ld hl, Coord - ld de, W_PLAYERNAME ; wd158 + ld de, wPlayerName ; wd158 call PlaceString jp DelayFrame diff --git a/home.asm b/home.asm index e3d4309b..9478fa62 100644 --- a/home.asm +++ b/home.asm @@ -383,11 +383,11 @@ PartyMenuInit:: ; 1420 (0:1420) push af ld [hli],a ; current menu item ID inc hl - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] and a ; are there more than 0 pokemon in the party? jr z,.storeMaxMenuItemID dec a -; if party is not empty, the max menu item ID is ([W_NUMINPARTY] - 1) +; if party is not empty, the max menu item ID is ([wPartyCount] - 1) ; otherwise, it is 0 .storeMaxMenuItemID ld [hli],a ; max menu item ID @@ -425,18 +425,18 @@ HandlePartyMenuInput:: ; 145a (0:145a) ld [$ffd7],a bit 1,b jr nz,.noPokemonChosen - ld a,[W_NUMINPARTY] + ld a,[wPartyCount] and a jr z,.noPokemonChosen ld a,[wCurrentMenuItem] ld [wWhichPokemon],a - ld hl,W_PARTYMON1 + ld hl,wPartySpecies ld b,0 ld c,a add hl,bc ld a,[hl] ld [wcf91],a - ld [wcfd9],a + ld [wBattleMonSpecies2],a call BankswitchBack and a ret @@ -617,7 +617,7 @@ GetMonHeader:: ; 1537 (0:1537) ; copy party pokemon's name to wcd6d GetPartyMonName2:: ; 15b4 (0:15b4) ld a,[wWhichPokemon] ; index within party - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks ; this is called more often GetPartyMonName:: ; 15ba (0:15ba) @@ -2055,12 +2055,12 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) call GetName jr .storeChosenEntry .pokemonList - ld hl,W_NUMINPARTY + ld hl,wPartyCount ld a,[wcf8b] cp l ; is it a list of party pokemon or box pokemon? - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks jr z,.getPokemonName - ld hl, W_BOXMON1NAME ; box pokemon names + ld hl, wBoxMonNicks ; box pokemon names .getPokemonName ld a,[wWhichPokemon] call GetPartyMonName @@ -2303,12 +2303,12 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) jr .placeNameString .pokemonPCMenu push hl - ld hl,W_NUMINPARTY + ld hl,wPartyCount ld a,[wcf8b] cp l ; is it a list of party pokemon or box pokemon? - ld hl,W_PARTYMON1NAME + ld hl,wPartyMonNicks jr z,.getPokemonName - ld hl, W_BOXMON1NAME ; box pokemon names + ld hl, wBoxMonNicks ; box pokemon names .getPokemonName ld a,[wWhichPokemon] ld b,a @@ -2348,7 +2348,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) ld a,[wd11e] push af push hl - ld hl,W_NUMINPARTY + ld hl,wPartyCount ld a,[wcf8b] cp l ; is it a list of party pokemon or box pokemon? ld a,$00 @@ -3794,8 +3794,8 @@ NamePointers:: ; 375d (0:375d) dw MoveNames dw UnusedNames dw ItemNames - dw W_PARTYMON1OT ; player's OT names list - dw W_ENEMYMON1OT ; enemy's OT names list + dw wPartyMonOT ; player's OT names list + dw wEnemyMonOT ; enemy's OT names list dw TrainerNames GetName:: ; 376b (0:376b) diff --git a/home/text.asm b/home/text.asm index 7d8ea61b..46c17b07 100644 --- a/home/text.asm +++ b/home/text.asm @@ -142,7 +142,7 @@ Char00Text:: ; 0x19f4 “%d ERROR.” Char52:: ; 0x19f9 player’s name push de - ld de,W_PLAYERNAME + ld de,wPlayerName jr FinishDTE Char53:: ; 19ff (0:19ff) ; rival’s name @@ -205,7 +205,7 @@ MonsterNameCharsCommon:: ; 1a37 (0:1a37) push de and a jr nz,.Enemy - ld de,W_PLAYERMONNAME ; player active monster name + ld de,wBattleMonNick ; player active monster name jr FinishDTE .Enemy ; 1A40 @@ -215,7 +215,7 @@ MonsterNameCharsCommon:: ; 1a37 (0:1a37) ld h,b ld l,c - ld de,W_ENEMYMONNAME ; enemy active monster name + ld de,wEnemyMonNick ; enemy active monster name FinishDTE:: ; 1a4b (0:1a4b) call PlaceString diff --git a/main.asm b/main.asm index f6a021ad..6df502f9 100755 --- a/main.asm +++ b/main.asm @@ -90,7 +90,7 @@ LoadMonData_: ; Return monster id at wcf91 and its data at wcf98. ; Also load base stats at W_MONHDEXNUM for convenience. - ld a, [W_DAYCAREMONDATA] + ld a, [wDayCareMonSpecies] ld [wcf91], a ld a, [wcc49] cp 3 @@ -105,8 +105,8 @@ LoadMonData_: ld [wd0b5], a ; input for GetMonHeader call GetMonHeader - ld hl, W_PARTYMON1DATA - ld bc, 44 + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 ld a, [wcc49] cp 1 jr c, .getMonEntry @@ -115,11 +115,11 @@ LoadMonData_: jr z, .getMonEntry cp 2 - ld hl, W_BOXMON1DATA - ld bc, 33 + ld hl, wBoxMons + ld bc, wBoxMon2 - wBoxMon1 jr z, .getMonEntry - ld hl, W_DAYCAREMONDATA + ld hl, wDayCareMon jr .copyMonData .getMonEntry @@ -472,7 +472,7 @@ TestBattle: set 0, [hl] ; Reset the party. - ld hl, W_NUMINPARTY + ld hl, wPartyCount xor a ld [hli], a dec a @@ -1039,7 +1039,7 @@ DrawStartMenu: ; 710b (1:710b) call PrintStartMenuItem ld de,StartMenuItemText call PrintStartMenuItem - ld de,W_PLAYERNAME ; player's name + ld de,wPlayerName ; player's name call PrintStartMenuItem ld a,[wd72e] bit 6,a ; is the player using the link feature? @@ -1756,7 +1756,7 @@ PokemonMenuEntries: ; 77c2 (1:77c2) GetMonFieldMoves: ; 77d6 (1:77d6) ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1_MOVE1 ; W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves ; wPartyMon1Moves ld bc, $2c call AddNTimes ld d, h @@ -1830,7 +1830,7 @@ INCLUDE "engine/battle/1.asm" INCLUDE "engine/menu/players_pc.asm" _RemovePokemon: ; 7b68 (1:7b68) - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount ld a, [wcf95] and a jr z, .asm_7b74 @@ -1852,12 +1852,12 @@ _RemovePokemon: ; 7b68 (1:7b68) ld [hli], a inc a jr nz, .asm_7b81 - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld d, $5 ld a, [wcf95] and a jr z, .asm_7b97 - ld hl, W_BOXMON1OT + ld hl, wBoxMonOT ld d, $13 .asm_7b97 ld a, [wWhichPokemon] ; wWhichPokemon @@ -1872,20 +1872,20 @@ _RemovePokemon: ; 7b68 (1:7b68) ld e, l ld bc, $b add hl, bc - ld bc, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld bc, wPartyMonNicks ; wPartyMonNicks ld a, [wcf95] and a jr z, .asm_7bb8 - ld bc, W_BOXMON1NAME + ld bc, wBoxMonNicks .asm_7bb8 call CopyDataUntil - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) - ld bc, $2c + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 ld a, [wcf95] and a jr z, .asm_7bcd - ld hl, W_BOXMON1DATA - ld bc, $21 + ld hl, wBoxMons + ld bc, wBoxMon2 - wBoxMon1 .asm_7bcd ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes @@ -1894,21 +1894,21 @@ _RemovePokemon: ; 7b68 (1:7b68) ld a, [wcf95] and a jr z, .asm_7be4 - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 add hl, bc - ld bc, W_BOXMON1OT + ld bc, wBoxMonOT jr .asm_7beb .asm_7be4 - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 add hl, bc - ld bc, W_PARTYMON1OT ; wd273 + ld bc, wPartyMonOT ; wd273 .asm_7beb call CopyDataUntil - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [wcf95] and a jr z, .asm_7bfa - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks .asm_7bfa ld bc, $b ld a, [wWhichPokemon] ; wWhichPokemon @@ -1921,7 +1921,7 @@ _RemovePokemon: ; 7b68 (1:7b68) ld a, [wcf95] and a jr z, .asm_7c15 - ld bc, wdee2 + ld bc, wBoxMonNicksEnd .asm_7c15 jp CopyDataUntil @@ -2448,7 +2448,7 @@ Func_c69c: ; c69c (3:469c) ld a, [wd730] add a jp c, .asm_c74f - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld a, [wPartyCount] ; wPartyCount and a jp z, .asm_c74f call Func_c8de @@ -2456,8 +2456,8 @@ Func_c69c: ; c69c (3:469c) and $3 jp nz, .asm_c74f ld [wWhichPokemon], a ; wWhichPokemon - ld hl, W_PARTYMON1_STATUS ; W_PARTYMON1_STATUS - ld de, W_PARTYMON1 ; W_PARTYMON1 + ld hl, wPartyMon1Status ; wPartyMon1Status + ld de, wPartySpecies ; wPartySpecies .asm_c6be ld a, [hl] and $8 @@ -2489,7 +2489,7 @@ Func_c69c: ; c69c (3:469c) ld [wd11e], a push de ld a, [wWhichPokemon] ; wWhichPokemon - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks call GetPartyMonName xor a ld [wJoyIgnore], a @@ -2515,8 +2515,8 @@ Func_c69c: ; c69c (3:469c) pop hl jr .asm_c6be .asm_c70e - ld hl, W_PARTYMON1_STATUS ; W_PARTYMON1_STATUS - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld hl, wPartyMon1Status ; wPartyMon1Status + ld a, [wPartyCount] ; wPartyCount ld d, a ld e, $0 .asm_c717 @@ -2621,7 +2621,7 @@ Func_c8de: ; c8de (3:48de) ld a, [W_DAYCARE_IN_USE] and a ret z - ld hl, wda6f + ld hl, wDayCareMonExp + 2 inc [hl] ret nz dec hl @@ -3453,7 +3453,7 @@ Func_f2dd: ; f2dd (3:72dd) ret _AddPokemonToParty: ; f2e5 (3:72e5) - ld de, W_NUMINPARTY ; W_NUMINPARTY + ld de, wPartyCount ; wPartyCount ld a, [wcc49] and $f jr z, .asm_f2f2 @@ -3476,24 +3476,24 @@ _AddPokemonToParty: ; f2e5 (3:72e5) inc de ld a, $ff ld [de], a - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 ld a, [wcc49] and $f jr z, .asm_f315 - ld hl, W_ENEMYMON1OT + ld hl, wEnemyMonOT .asm_f315 ld a, [$ffe4] dec a call SkipFixedLengthTextEntries ld d, h ld e, l - ld hl, W_PLAYERNAME ; wd158 + ld hl, wPlayerName ; wd158 ld bc, $b call CopyData ld a, [wcc49] and a jr nz, .asm_f33f - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks ld a, [$ffe4] dec a call SkipFixedLengthTextEntries @@ -3502,15 +3502,15 @@ _AddPokemonToParty: ; f2e5 (3:72e5) ld a, $4e call Predef ; indirect jump to Func_64eb (64eb (1:64eb)) .asm_f33f - ld hl, W_PARTYMON1_NUM ; W_PARTYMON1_NUM (aliases: W_PARTYMON1DATA) + ld hl, wPartyMons ld a, [wcc49] and $f jr z, .asm_f34c - ld hl, wEnemyMons ; wEnemyMon1Species + ld hl, wEnemyMons .asm_f34c ld a, [$ffe4] dec a - ld bc, $2c + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld e, l ld d, h @@ -3589,20 +3589,20 @@ _AddPokemonToParty: ; f2e5 (3:72e5) .copyEnemyMonData ld bc, $1b add hl, bc - ld a, [W_ENEMYMONATKDEFIV] ; copy IVs from cur enemy mon + ld a, [wEnemyMonDVs] ; copy IVs from cur enemy mon ld [hli], a - ld a, [W_ENEMYMONSPDSPCIV] + ld a, [wEnemyMonDVs + 1] ld [hl], a - ld a, [W_ENEMYMONCURHP] ; copy HP from cur enemy mon + ld a, [wEnemyMonHP] ; copy HP from cur enemy mon ld [de], a inc de - ld a, [W_ENEMYMONCURHP+1] + ld a, [wEnemyMonHP+1] ld [de], a inc de xor a ld [de], a ; level (?) inc de - ld a, [W_ENEMYMONSTATUS] ; copy status ailments from cur enemy mon + ld a, [wEnemyMonStatus] ; copy status ailments from cur enemy mon ld [de], a inc de .copyMonTypesAndMoves @@ -3676,7 +3676,7 @@ _AddPokemonToParty: ; f2e5 (3:72e5) ld a, [W_ISINBATTLE] ; W_ISINBATTLE dec a jr nz, .calcFreshStats - ld hl, W_ENEMYMONMAXHP ; W_ENEMYMONMAXHP + ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP ld bc, $a call CopyData ; copy stats of cur enemy mon pop hl @@ -3724,7 +3724,7 @@ AddPokemonToParty_WriteMovePP: ; f476 (3:7476) ; adds enemy mon [wcf91] (at position [wWhichPokemon] in enemy list) to own party ; used in the cable club trade center _AddEnemyMonToPlayerParty: ; f49d (3:749d) - ld hl, W_NUMINPARTY + ld hl, wPartyCount ld a, [hl] cp $6 scf @@ -3737,33 +3737,33 @@ _AddEnemyMonToPlayerParty: ; f49d (3:749d) ld a, [wcf91] ld [hli], a ; add mon as last list entry ld [hl], $ff ; write new sentinel - ld hl, W_PARTYMON1DATA - ld a, [W_NUMINPARTY] + ld hl, wPartyMons + ld a, [wPartyCount] dec a - ld bc, W_PARTYMON2DATA - W_PARTYMON1DATA + ld bc, wPartyMon2 - wPartyMon1 call AddNTimes ld e, l ld d, h ld hl, wcf98 call CopyData ; write new mon's data (from wcf98) - ld hl, W_PARTYMON1OT - ld a, [W_NUMINPARTY] + ld hl, wPartyMonOT + ld a, [wPartyCount] dec a call SkipFixedLengthTextEntries ld d, h ld e, l - ld hl, W_ENEMYMON1OT + ld hl, wEnemyMonOT ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld bc, $000b call CopyData ; write new mon's OT name (from an enemy mon) - ld hl, W_PARTYMON1NAME - ld a, [W_NUMINPARTY] + ld hl, wPartyMonNicks + ld a, [wPartyCount] dec a call SkipFixedLengthTextEntries ld d, h ld e, l - ld hl, W_ENEMYMON1NAME + ld hl, wEnemyMonNicks ld a, [wWhichPokemon] call SkipFixedLengthTextEntries ld bc, $000b @@ -3792,7 +3792,7 @@ Func_f51e: ; f51e (3:751e) cp $2 jr z, .checkPartyMonSlots cp $3 - ld hl, W_DAYCAREMONDATA + ld hl, wDayCareMon jr z, .asm_f575 ld hl, W_NUMINBOX ; wda80 ld a, [hl] @@ -3800,7 +3800,7 @@ Func_f51e: ; f51e (3:751e) jr nz, .partyOrBoxNotFull jr .boxFull .checkPartyMonSlots - ld hl, W_NUMINPARTY ; W_NUMINPARTY + ld hl, wPartyCount ; wPartyCount ld a, [hl] cp $6 jr nz, .partyOrBoxNotFull @@ -3815,7 +3815,7 @@ Func_f51e: ; f51e (3:751e) add hl, bc ld a, [wcf95] cp $2 - ld a, [W_DAYCAREMONDATA] + ld a, [wDayCareMon] jr z, .asm_f556 ld a, [wcf91] .asm_f556 @@ -3823,12 +3823,12 @@ Func_f51e: ; f51e (3:751e) ld [hl], $ff ; write new sentinel ld a, [wcf95] dec a - ld hl, W_PARTYMON1DATA ; W_PARTYMON1_NUM - ld bc, W_PARTYMON2DATA - W_PARTYMON1DATA ; $2c - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 ; $2c + ld a, [wPartyCount] ; wPartyCount jr nz, .skipToNewMonEntry - ld hl, W_BOXMON1DATA - ld bc, W_BOXMON2DATA - W_BOXMON1DATA ; $21 + ld hl, wBoxMons + ld bc, wBoxMon2 - wBoxMon1 ; $21 ld a, [W_NUMINBOX] ; wda80 .skipToNewMonEntry dec a @@ -3839,21 +3839,21 @@ Func_f51e: ; f51e (3:751e) ld d, h ld a, [wcf95] and a - ld hl, W_BOXMON1DATA - ld bc, W_BOXMON2DATA - W_BOXMON1DATA ; $21 + ld hl, wBoxMons + ld bc, wBoxMon2 - wBoxMon1 ; $21 jr z, .asm_f591 cp $2 - ld hl, W_DAYCAREMONDATA + ld hl, wDayCareMon jr z, .asm_f597 - ld hl, W_PARTYMON1DATA ; W_PARTYMON1_NUM - ld bc, W_PARTYMON2DATA - W_PARTYMON1DATA ; $2c + ld hl, wPartyMons + ld bc, wPartyMon2 - wPartyMon1 ; $2c .asm_f591 ld a, [wWhichPokemon] ; wWhichPokemon call AddNTimes .asm_f597 push hl push de - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 call CopyData pop de pop hl @@ -3862,7 +3862,7 @@ Func_f51e: ; f51e (3:751e) jr z, .asm_f5b4 cp $2 jr z, .asm_f5b4 - ld bc, $21 + ld bc, wBoxMon2 - wBoxMon1 add hl, bc ld a, [hl] inc de @@ -3875,10 +3875,10 @@ Func_f51e: ; f51e (3:751e) ld de, W_DAYCAREMONOT jr z, .asm_f5d3 dec a - ld hl, W_PARTYMON1OT ; wd273 - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld hl, wPartyMonOT ; wd273 + ld a, [wPartyCount] ; wPartyCount jr nz, .asm_f5cd - ld hl, W_BOXMON1OT + ld hl, wBoxMonOT ld a, [W_NUMINBOX] ; wda80 .asm_f5cd dec a @@ -3886,14 +3886,14 @@ Func_f51e: ; f51e (3:751e) ld d, h ld e, l .asm_f5d3 - ld hl, W_BOXMON1OT + ld hl, wBoxMonOT ld a, [wcf95] and a jr z, .asm_f5e6 ld hl, W_DAYCAREMONOT cp $2 jr z, .asm_f5ec - ld hl, W_PARTYMON1OT ; wd273 + ld hl, wPartyMonOT ; wd273 .asm_f5e6 ld a, [wWhichPokemon] ; wWhichPokemon call SkipFixedLengthTextEntries @@ -3905,10 +3905,10 @@ Func_f51e: ; f51e (3:751e) ld de, W_DAYCAREMONNAME jr z, .asm_f611 dec a - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME - ld a, [W_NUMINPARTY] ; W_NUMINPARTY + ld hl, wPartyMonNicks ; wPartyMonNicks + ld a, [wPartyCount] ; wPartyCount jr nz, .asm_f60b - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks ld a, [W_NUMINBOX] ; wda80 .asm_f60b dec a @@ -3916,14 +3916,14 @@ Func_f51e: ; f51e (3:751e) ld d, h ld e, l .asm_f611 - ld hl, W_BOXMON1NAME + ld hl, wBoxMonNicks ld a, [wcf95] and a jr z, .asm_f624 ld hl, W_DAYCAREMONNAME cp $2 jr z, .asm_f62a - ld hl, W_PARTYMON1NAME ; W_PARTYMON1NAME + ld hl, wPartyMonNicks ; wPartyMonNicks .asm_f624 ld a, [wWhichPokemon] ; wWhichPokemon call SkipFixedLengthTextEntries @@ -4037,8 +4037,8 @@ FlagAction: HealParty: ; Restore HP and PP. - ld hl, W_PARTYMON1 - ld de, W_PARTYMON1_HP + ld hl, wPartySpecies + ld de, wPartyMon1HP .healmon ld a, [hli] cp $ff @@ -4047,15 +4047,15 @@ HealParty: push hl push de - ld hl, $0003 ; status + ld hl, wPartyMon1Status - wPartyMon1HP add hl, de xor a ld [hl], a push de - ld b, $4 ; A Pokémon has 4 moves + ld b, NUM_MOVES ; A Pokémon has 4 moves .pp - ld hl, $0007 ; moves + ld hl, wPartyMon1Moves - wPartyMon1HP add hl, de ld a, [hl] @@ -4063,7 +4063,7 @@ HealParty: jr z, .nextmove dec a - ld hl, $001c ; pp + ld hl, wPartyMon1PP - wPartyMon1HP add hl, de push hl @@ -4096,7 +4096,7 @@ HealParty: jr nz, .pp pop de - ld hl, $0021 ; max hp - cur hp + ld hl, wPartyMon1MaxHP - wPartyMon1HP add hl, de ld a, [hli] ld [de], a @@ -4108,7 +4108,7 @@ HealParty: pop hl push hl - ld bc, $002c ; next mon + ld bc, wPartyMon2 - wPartyMon1 ld h, d ld l, e add hl, bc @@ -4122,7 +4122,7 @@ HealParty: ld [wWhichPokemon], a ld [wd11e], a - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] ld b, a .ppup push bc @@ -4359,7 +4359,7 @@ InitializePlayerData: ld a, $ff ld [wd71b], a ; XXX what's this? - ld hl, W_NUMINPARTY + ld hl, wPartyCount call InitializeEmptyList ld hl, W_NUMINBOX call InitializeEmptyList diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index d2a07418..d2a70578 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -17,7 +17,7 @@ DayCareMText1: ; 56254 (15:6254) and a ld hl, DayCareMText_5643b jp nz, DayCareMScript_56409 - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] dec a ld hl, DayCareMText_56445 jp z, DayCareMScript_56409 @@ -41,7 +41,7 @@ DayCareMText1: ; 56254 (15:6254) xor a ld [wcc2b], a ld a, [wWhichPokemon] - ld hl, W_PARTYMON1NAME + ld hl, wPartyMonNicks call GetPartyMonName ld hl, DayCareMText_56419 call PrintText @@ -71,7 +71,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) jr c, .asm_56315 ld d, $64 callab CalcExperience - ld hl, wda6d + ld hl, wDayCareMonExp ld a, [H_NUMTOPRINT] ld [hli], a ld a, [$ff97] @@ -83,7 +83,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) .asm_56315 xor a ld [wTrainerEngageDistance], a - ld hl, wda62 + ld hl, wDayCareMonBoxLevel ld a, [hl] ld [wTrainerSpriteOffset], a cp d @@ -99,7 +99,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) .asm_56333 call PrintText - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] cp $6 ld hl, DayCareMText_56440 jp z, .asm_56403 @@ -168,14 +168,14 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld a, $2 ld [wcf95], a call Func_3a68 - ld a, [W_DAYCAREMONDATA] + ld a, [wDayCareMonSpecies] ld [wcf91], a - ld a, [W_NUMINPARTY] + ld a, [wPartyCount] dec a push af ld bc, $002c push bc - ld hl, W_PARTYMON1_MOVE1 + ld hl, wPartyMon1Moves call AddNTimes ld d, h ld e, l @@ -185,7 +185,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) call Predef pop bc pop af - ld hl, W_PARTYMON1_HP + ld hl, wPartyMon1HP call AddNTimes ld d, h ld e, l @@ -203,7 +203,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) .asm_56403 ld a, [wTrainerSpriteOffset] - ld [wda62], a + ld [wDayCareMonBoxLevel], a DayCareMScript_56409: ; 56409 (15:6409) call PrintText diff --git a/scripts/namerater.asm b/scripts/namerater.asm index 31bb5fcb..ca357ad1 100755 --- a/scripts/namerater.asm +++ b/scripts/namerater.asm @@ -9,15 +9,15 @@ NameRaterScript_1da15: ; 1da15 (7:5a15) ret NameRaterScript_1da20: ; 1da20 (7:5a20) - ld hl, W_PARTYMON1OT + ld hl, wPartyMonOT ld bc, $000b ld a, [wWhichPokemon] call AddNTimes - ld de, W_PLAYERNAME + ld de, wPlayerName ld c, $b call .asm_1da47 jr c, .asm_1da52 ; 0x1da34 $1c - ld hl, W_PARTYMON1_OTID + ld hl, wPartyMon1OTID ld bc, $002c ld a, [wWhichPokemon] call AddNTimes diff --git a/text.asm b/text.asm index 0e93652b..57793c42 100644 --- a/text.asm +++ b/text.asm @@ -239,7 +239,7 @@ _AIBattleWithdrawText:: ; 880be (22:40be) TX_RAM W_TRAINERNAME text " with-" line "drew @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text "!" prompt @@ -250,7 +250,7 @@ _AIBattleUseItemText:: ; 880d5 (22:40d5) TX_RAM wcd6d db $0 cont "on @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text "!" prompt @@ -1055,14 +1055,14 @@ _OutOfSafariBallsText:: ; 89639 (22:5639) _WildRanText:: ; 89666 (22:5666) text "Wild @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "ran!" prompt _EnemyRanText:: ; 89677 (22:5677) text "Enemy @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "ran!" prompt @@ -1084,7 +1084,7 @@ _HurtByLeechSeedText:: ; 896b3 (22:56b3) _EnemyMonFaintedText:: ; 0x896c7 text "Enemy @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "fainted!" prompt @@ -1104,7 +1104,7 @@ _TrainerDefeatedText:: ; 896f9 (22:56f9) prompt _PlayerMonFaintedText:: ; 8970c (22:570c) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick db $0 line "fainted!" prompt @@ -1138,7 +1138,7 @@ _TrainerAboutToUseText:: ; 89784 (22:5784) text " is" line "about to use" cont"@" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text "!" para "Will ", $52 @@ -1149,7 +1149,7 @@ _TrainerSentOutText:: ; 897b4 (22:57b4) TX_RAM W_TRAINERNAME text " sent" line "out @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text "!" done @@ -1178,7 +1178,7 @@ _ItemsCantBeUsedHereText:: ; 89831 (22:5831) prompt _AlreadyOutText:: ; 8984b (22:584b) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " is" line "already out!" prompt @@ -1194,7 +1194,7 @@ _MoveDisabledText:: ; 8987b (22:587b) prompt _NoMovesLeftText:: ; 89892 (22:5892) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " has no" line "moves left!" done @@ -1207,7 +1207,7 @@ _MultiHitText:: ; 898aa (22:58aa) prompt _ScaredText:: ; 898c7 (22:58c7) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " is too" line "scared to move!" prompt @@ -1369,31 +1369,31 @@ _OHKOText:: ; 89ad8 (22:5ad8) prompt _LoafingAroundText:: ; 89ae5 (22:5ae5) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " is" line "loafing around." prompt _BeganToNapText:: ; 89afd (22:5afd) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " began" line "to nap!" prompt _WontObeyText:: ; 89b10 (22:5b10) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " won't" line "obey!" prompt _TurnedAwayText:: ; 89b20 (22:5b20) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " turned" line "away!" prompt _IgnoredOrdersText:: ; 89b32 (22:5b32) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick db $0 line "ignored orders!" prompt @@ -1451,7 +1451,7 @@ _GrewLevelText:: ; 89c01 (22:5c01) _WildMonAppearedText:: ; 89c1d (22:5c1d) text "Wild @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "appeared!" prompt @@ -1459,13 +1459,13 @@ _WildMonAppearedText:: ; 89c1d (22:5c1d) _HookedMonAttackedText:: ; 89c33 (22:5c33) text "The hooked" line "@" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 cont "attacked!" prompt _EnemyAppearedText:: ; 89c4f (22:5c4f) - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "appeared!" prompt @@ -1501,12 +1501,12 @@ _EnemysWeakText:: ; 89cd6 (22:5cd6) line "Get'm! @@" _PlayerMon1Text:: ; 89cf0 (22:5cf0) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text "!" done _PlayerMon2Text:: ; 89cf6 (22:5cf6) - TX_RAM W_PLAYERMONNAME + TX_RAM wBattleMonNick text " @@" _EnoughText:: ; 89cfd (22:5cfd) @@ -1535,14 +1535,14 @@ _NotVeryEffectiveText:: ; 89d38 (22:5d38) _SafariZoneEatingText:: ; 89d53 (22:5d53) text "Wild @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "is eating!" prompt _SafariZoneAngryText:: ; 89d6a (22:5d6a) text "Wild @" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick db $0 line "is angry!" prompt @@ -2736,7 +2736,7 @@ _SetToBoxText:: ; a418f (29:418f) text "There's no more" line "room for #MON!" cont "@" - TX_RAM W_BOXMON1NAME + TX_RAM wBoxMonNicks text " was" cont "sent to #MON" cont "BOX @" @@ -2798,19 +2798,19 @@ _ItemUseBallText04:: ; a67b2 (29:67b2) _ItemUseBallText05:: ; a67cf (29:67cf) text "All right!" line "@" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text " was" cont "caught!@@" _ItemUseBallText07:: ; a67ee (29:67ee) - TX_RAM W_BOXMON1NAME + TX_RAM wBoxMonNicks text " was" line "transferred to" cont "BILL's PC!" prompt _ItemUseBallText08:: ; a6810 (29:6810) - TX_RAM W_BOXMON1NAME + TX_RAM wBoxMonNicks text " was" line "transferred to" cont "someone's PC!" @@ -2820,7 +2820,7 @@ _ItemUseBallText06:: ; a6835 (29:6835) text "New #DEX data" line "will be added for" cont "@" - TX_RAM W_ENEMYMONNAME + TX_RAM wEnemyMonNick text "!@@" _SurfingGotOnText:: ; a685e (29:685e) diff --git a/wram.asm b/wram.asm index ad9bb491..ea22394b 100755 --- a/wram.asm +++ b/wram.asm @@ -1,10 +1,63 @@ -INCLUDE "constants/wram_constants.asm" +INCLUDE "constants.asm" flag_array: MACRO ds ((\1) + 7) / 8 ENDM +box_struct_length EQU 25 + NUM_MOVES * 2 +box_struct: MACRO +\1Species:: db +\1HP:: dw +\1BoxLevel:: db +\1Status:: db +\1Type:: +\1Type1:: db +\1Type2:: db +\1CatchRate:: db +\1Moves:: ds NUM_MOVES +\1OTID:: dw +\1Exp:: ds 3 +\1HPExp:: dw +\1AttackExp:: dw +\1DefenseExp:: dw +\1SpeedExp:: dw +\1SpecialExp:: dw +\1DVs:: ds 2 +\1PP:: ds NUM_MOVES +ENDM + +party_struct: MACRO + box_struct \1 +\1Level:: db +\1Stats:: +\1MaxHP:: dw +\1Attack:: dw +\1Defense:: dw +\1Speed:: dw +\1Special:: dw +ENDM + +battle_struct: MACRO +\1Species:: db +\1HP:: dw +\1BoxLevel:: db +\1Status:: db +\1Type:: +\1Type1:: db +\1Type2:: db +\1CatchRate:: db +\1Moves:: ds NUM_MOVES +\1DVs:: ds 2 +\1Level:: db +\1MaxHP:: dw +\1Attack:: dw +\1Defense:: dw +\1Speed:: dw +\1Special:: dw +\1PP:: ds NUM_MOVES +ENDM + SECTION "WRAM Bank 0", WRAM0 @@ -577,100 +630,53 @@ W_PLAYERMOVEACCURACY:: ; cfd6 W_PLAYERMOVEMAXPP:: ; cfd7 ds 1 -W_ENEMYMONID:: ; cfd8 - ds 1 - -wcfd9:: ds 1 -W_ENEMYMONNAME:: ; cfda - ds 11 - -wcfe5:: ds 1 - -W_ENEMYMONCURHP:: ; cfe6 -; active opponent's hp (16 bits) - ds 2 -W_ENEMYMONNUMBER:: ; cfe8 -; active opponent's position in team (0 to 5) - ds 1 -W_ENEMYMONSTATUS:: ; cfe9 -; active opponent's status condition +wEnemyMonSpecies2:: ; cfd8 ds 1 -W_ENEMYMONTYPES:: ; cfea -W_ENEMYMONTYPE1:: ; cfea - ds 1 -W_ENEMYMONTYPE2:: ; cfeb - ds 1 - ds 1 -W_ENEMYMONMOVES:: ; cfed - ds 4 -W_ENEMYMONATKDEFIV:: ; cff1 +wBattleMonSpecies2:: ; cfd9 ds 1 -W_ENEMYMONSPDSPCIV:: ; cff2 - ds 1 -W_ENEMYMONLEVEL:: ; cff3 - ds 1 -W_ENEMYMONMAXHP:: ; cff4 - ds 2 -W_ENEMYMONATTACK:: ; cff6 - ds 2 -W_ENEMYMONDEFENSE:: ; cff8 - ds 2 -W_ENEMYMONSPEED:: ; cffa - ds 2 -W_ENEMYMONSPECIAL:: ; cffc - ds 2 -W_ENEMYMONPP:: ; cffe -; four moves (extends past $cfff) - ds 2 +wEnemyMonNick:: ds 11 ; cfda +wEnemyMon:: ; cfe5 +; The wEnemyMon struct reaches past 0xcfff, +; the end of wram bank 0 on cgb. +; This has no significance on dmg, where wram +; isn't banked (c000-dfff is contiguous). +; However, recent versions of rgbds have replaced +; dmg-style wram with cgb wram banks. -SECTION "WRAM Bank 1", WRAMX, BANK[1] +; Until this is fixed, this struct will have +; to be declared manually. - ds 2 ; W_ENEMYMONPP +wEnemyMonSpecies:: db +wEnemyMonHP:: dw +wEnemyMonPartyPos:: +wEnemyMonBoxLevel:: db +wEnemyMonStatus:: db +wEnemyMonType:: +wEnemyMonType1:: db +wEnemyMonType2:: db +wEnemyMonCatchRate:: db +wEnemyMonMoves:: ds NUM_MOVES +wEnemyMonDVs:: ds 2 +wEnemyMonLevel:: db +wEnemyMonMaxHP:: dw +wEnemyMonAttack:: dw +wEnemyMonDefense:: dw +wEnemyMonSpeed:: dw +wEnemyMonSpecial:: dw +wEnemyMonPP:: ds 2 ; NUM_MOVES - 2 +SECTION "WRAM Bank 1", WRAMX, BANK[1] + ds 2 ; NUM_MOVES - 2 wd002:: ds 5 wd007:: ds 1 wd008:: ds 1 -W_PLAYERMONNAME:: ; d009 - ds 11 - -W_PLAYERMONID:: ; d014 - ds 1 +wBattleMonNick:: ds 11 ; d009 +wBattleMon:: battle_struct wBattleMon ; d014 -W_PLAYERMONCURHP:: ; d015 - ds 2 - ds 1 -W_PLAYERMONSTATUS:: ; d018 -; the status of the player’s current monster - ds 1 -W_PLAYERMONTYPES:: ; d019 -W_PLAYERMONTYPE1:: ; d019 - ds 1 -W_PLAYERMONTYPE2:: ; d01a - ds 1 - ds 1 -W_PLAYERMONMOVES:: ; d01c - ds 4 -W_PLAYERMONIVS:: ; d020 -; 4x 4 bit: atk, def, spd, spc - ds 2 -W_PLAYERMONLEVEL:: ; d022 - ds 1 -W_PLAYERMONMAXHP:: ; d023 - ds 2 -W_PLAYERMONATK:: ; d025 - ds 2 -W_PLAYERMONDEF:: ; d027 - ds 2 -W_PLAYERMONSPEED:: ; d029 - ds 2 -W_PLAYERMONSPECIAL:: ; d02b - ds 2 -W_PLAYERMONPP:: ; d02d - ds 4 W_TRAINERCLASS:: ; d031 ds 1 @@ -696,9 +702,8 @@ W_ISINBATTLE:: ; d057 ; trainer battle, this is 2 ds 1 -W_PLAYERMONSALIVEFLAGS:: ; d058 -; 6 bit array, 1 if player mon is alive - ds 1 +wPartyAliveFlags:: ; d058 + flag_array 6 W_CUROPPONENT:: ; d059 ; in a wild battle, this is the species of pokemon @@ -1056,122 +1061,24 @@ wd153:: ds 3 wd156:: ds 1 wd157:: ds 1 -W_PLAYERNAME:: ; d158 - ds 11 -W_NUMINPARTY:: ; d163 - ds 1 -W_PARTYMON1:: ; d164 - ds 1 -W_PARTYMON2:: ; d165 - ds 1 -W_PARTYMON3:: ; d166 - ds 1 -W_PARTYMON4:: ; d167 - ds 1 -W_PARTYMON5:: ; d168 - ds 1 -W_PARTYMON6:: ; d169 - ds 1 -W_PARTYMONEND:: ; d16a - ds 1 +wPlayerName:: ; d158 + ds 11 -W_PARTYMON1DATA:: ; d16b -W_PARTYMON1_NUM:: ; d16b - ds 1 -W_PARTYMON1_HP:: ; d16c - ds 2 -W_PARTYMON1_BOXLEVEL:: ; d16e - ds 1 -W_PARTYMON1_STATUS:: ; d16f - ds 1 -W_PARTYMON1_TYPE1:: ; d170 - ds 1 -W_PARTYMON1_TYPE2:: ; d171 - ds 1 -W_PARTYMON1_CRATE:: ; d172 - ds 1 -W_PARTYMON1_MOVE1:: ; d173 - ds 1 -W_PARTYMON1_MOVE2:: ; d174 - ds 1 -W_PARTYMON1_MOVE3:: ; d175 - ds 1 -W_PARTYMON1_MOVE4:: ; d176 - ds 1 -W_PARTYMON1_OTID:: ; d177 - ds 2 -W_PARTYMON1_EXP:: ; d179 - ds 3 -W_PARTYMON1_EVHP:: ; d17c - ds 2 -W_PARTYMON1_EVATTACK:: ; d17e - ds 2 -W_PARTYMON1_EVDEFENSE:: ; d180 - ds 2 -W_PARTYMON1_EVSPEED:: ; d182 - ds 2 -W_PARTYMON1_EVSECIAL:: ; d184 - ds 2 -W_PARTYMON1_IV:: ; d186 - ds 2 -W_PARTYMON1_MOVE1PP:: ; d188 - ds 1 -W_PARTYMON1_MOVE2PP:: ; d189 - ds 1 -W_PARTYMON1_MOVE3PP:: ; d18a - ds 1 -W_PARTYMON1_MOVE4PP:: ; d18b - ds 1 -W_PARTYMON1_LEVEL:: ; d18c - ds 1 -W_PARTYMON1_MAXHP:: ; d18d - ds 2 -W_PARTYMON1_ATACK:: ; d18f - ds 2 -W_PARTYMON1_DEFENSE:: ; d191 - ds 2 -W_PARTYMON1_SPEED:: ; d193 - ds 2 -W_PARTYMON1_SPECIAL:: ; d195 - ds 2 +wPartyCount:: ds 1 ; d163 +wPartySpecies:: ds 6 ; d164 +wPartyEnd:: ds 1 ; d16a -W_PARTYMON2DATA:: ; d197 - ds 44 -W_PARTYMON3DATA:: ; d1c3 - ds 44 -W_PARTYMON4DATA:: ; d1ef - ds 44 -W_PARTYMON5DATA:: ; d21b - ds 44 -W_PARTYMON6DATA:: ; d247 - ds 44 - -W_PARTYMON1OT:: ; d273 - ds 11 -W_PARTYMON2OT:: ; d27e - ds 11 -W_PARTYMON3OT:: ; d289 - ds 11 -W_PARTYMON4OT:: ; d294 - ds 11 -W_PARTYMON5OT:: ; d29f - ds 11 -W_PARTYMON6OT:: ; d2aa - ds 11 +wPartyMons:: +wPartyMon1:: party_struct wPartyMon1 ; d16b +wPartyMon2:: party_struct wPartyMon2 ; d197 +wPartyMon3:: party_struct wPartyMon3 ; d1c3 +wPartyMon4:: party_struct wPartyMon4 ; d1ef +wPartyMon5:: party_struct wPartyMon5 ; d21b +wPartyMon6:: party_struct wPartyMon6 ; d247 -W_PARTYMON1NAME:: ; d2b5 - ds 11 -W_PARTYMON2NAME:: ; d2c0 - ds 11 -W_PARTYMON3NAME:: ; d2cb - ds 11 -W_PARTYMON4NAME:: ; d2d6 - ds 11 -W_PARTYMON5NAME:: ; d2e1 - ds 11 -W_PARTYMON6NAME:: ; d2ec - ds 11 +wPartyMonOT:: ds 11 * 6 ; d273 +wPartyMonNicks:: ds 11 * 6 ; d2b5 wPokedexOwned:: ; d2f7 @@ -1835,69 +1742,21 @@ W_GRASSRATE:: ; d887 W_GRASSMONS:: ; d888 ds 20 -wEnemyPartyCount:: ; d89c - ds 1 -wEnemyPartyMons:: ; d89d - ds 6 - ds 1 ; end - -wEnemyMons:: +wEnemyPartyCount:: ds 1 ; d89c +wEnemyPartyMons:: ds 6 + 1 ; d89d -wEnemyMon1:: ; d8a4 -wEnemyMon1Species:: ; d8a4 - ds 1 -W_ENEMYMON1HP:: ; d8a5 - ds 2 +wEnemyMons:: ; d8a4 +wEnemyMon1:: party_struct wEnemyMon1 +wEnemyMon2:: party_struct wEnemyMon2 +wEnemyMon3:: party_struct wEnemyMon3 +wEnemyMon4:: party_struct wEnemyMon4 +wEnemyMon5:: party_struct wEnemyMon5 +wEnemyMon6:: party_struct wEnemyMon6 - ds 1 +wEnemyMonOT:: ds 11 * 6 ; d9ac +wEnemyMonNicks:: ds 11 * 6 ; d9ee -wd8a8:: ds 4 -wd8ac:: ds 2 - -W_ENEMYMON1MOVE3:: ; d8ae - ds 19 -wd8c1:: ds 4 -wd8c5:: ds 1 -wd8c6:: ds 20 - -W_ENEMYMON2MOVE3:: ; d8da - ds 44 -W_ENEMYMON3MOVE3:: ; d906 - ds 44 -W_ENEMYMON4MOVE3:: ; d932 - ds 44 -W_ENEMYMON5MOVE3:: ; d95e - ds 44 -W_ENEMYMON6MOVE3:: ; d98a - ds 22 -wd9a0:: ds 12 - -W_ENEMYMON1OT:: ; d9ac - ds 11 -W_ENEMYMON2OT:: ; d9b7 - ds 11 -W_ENEMYMON3OT:: ; d9c2 - ds 11 -W_ENEMYMON4OT:: ; d9cd - ds 11 -W_ENEMYMON5OT:: ; d9d8 - ds 11 -W_ENEMYMON6OT:: ; d9e3 - ds 11 - -W_ENEMYMON1NAME:: ; d9ee - ds 11 -W_ENEMYMON2NAME:: ; d9f9 - ds 11 -W_ENEMYMON3NAME:: ; da04 - ds 11 -W_ENEMYMON4NAME:: ; da0f - ds 11 -W_ENEMYMON5NAME:: ; da1a - ds 11 -W_ENEMYMON6NAME:: ; da25 - ds 11 W_TRAINERHEADERPTR:: ; da30 ds 2 @@ -1927,50 +1786,29 @@ wda46:: ds 1 W_NUMSAFARIBALLS:: ; da47 ds 1 + W_DAYCARE_IN_USE:: ; da48 ; 0 if no pokemon is in the daycare ; 1 if pokemon is in the daycare ds 1 -W_DAYCAREMONNAME:: ; da49 - ds 11 - -W_DAYCAREMONOT:: ; da54 - ds 11 - -W_DAYCAREMONDATA:: ; da5f - ds 3 -wda62:: ds 5 -wda67:: ds 6 -wda6d:: ds 2 -wda6f:: ds 17 +W_DAYCAREMONNAME:: ds 11 ; da49 +W_DAYCAREMONOT:: ds 11 ; da54 +wDayCareMon:: box_struct wDayCareMon ; da5f -W_NUMINBOX:: ; da80 -; number of mons in current box - ds 1 -wda81:: - ds 20 - ds 1 -W_BOXMON1DATA:: ; da96 - ds 8 -wda9e:: ds 25 -W_BOXMON2DATA:: ; dab7 - ds 33 * 19 +W_NUMINBOX:: ds 1 ; da80 +wBoxSpecies:: ds MONS_PER_BOX + 1 -W_BOXMON1OT:: ; dd2a - ds 11 -W_BOXMON2OT:: ; dd35 - ds 11 * 19 +wBoxMons:: +wBoxMon1:: box_struct wBoxMon1 ; da96 +wBoxMon2:: ds box_struct_length * (MONS_PER_BOX + -1) ; dab7 -W_BOXMON1NAME:: ; de06 - ds 11 -W_BOXMON2NAME:: ; de11 - ds 11 * 19 +wBoxMonOT:: ds 11 * MONS_PER_BOX ; dd2a +wBoxMonNicks:: ds 11 * MONS_PER_BOX ; de06 +wBoxMonNicksEnd:: ; dee2 -wdee2:: - ds 1 SECTION "Stack", WRAMX[$dfff], BANK[1] wStack:: ; dfff -- cgit v1.3.1-sl0p From 35f2bb90d4a8f8e4dcac3fbab7d89cbc590285e8 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 16 Jun 2014 13:03:05 -0700 Subject: Rename predef functions so they aren't excessive in length. This is mostly because of an rgbasm bug that prevents macro arguments from exceeding 16 characters, but the names were bad anyway. --- engine/HoF_room_pc.asm | 2 +- engine/battle/1c.asm | 1 + engine/battle/core.asm | 12 +++--- engine/battle/e.asm | 4 +- engine/give_pokemon.asm | 2 +- engine/hp_bar.asm | 8 ++-- engine/in_game_trades.asm | 2 +- engine/items/items.asm | 2 +- engine/items/tms.asm | 2 +- engine/menu/naming_screen.asm | 2 +- engine/menu/pokedex.asm | 2 +- engine/menu/vending_machine.asm | 2 +- engine/overworld/emotion_bubbles.asm | 2 +- engine/overworld/item.asm | 2 +- engine/overworld/player_animations.asm | 2 +- engine/overworld/trainers.asm | 2 +- engine/palettes.asm | 2 +- engine/predefs.asm | 73 ++++++++++++---------------------- engine/predefs17.asm | 2 +- engine/slot_machine.asm | 2 +- home.asm | 4 +- home/overworld.asm | 12 +++--- main.asm | 26 ++++++------ scripts/celadongamecorner.asm | 2 +- scripts/daycarem.asm | 2 +- scripts/mtmoonpokecenter.asm | 2 +- scripts/museum1f.asm | 2 +- scripts/oakslab.asm | 4 +- scripts/safarizoneentrance.asm | 2 +- 29 files changed, 81 insertions(+), 103 deletions(-) (limited to 'home') diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index a6b3f4d5..0ebb3b61 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -1,4 +1,4 @@ -HallOfFameComputer: ; 7405c (1d:405c) +HallOfFamePC: ; 7405c (1d:405c) callba AnimateHallOfFame call ClearScreen ld c, $64 diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 242b8d66..5523ba7d 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -430,6 +430,7 @@ BattleTransition_OutwardSpiral_: ; 70af9 (1c:4af9) ld [wd09f], a jr .done2_ +FlashScreen: BattleTransition_FlashScreen_: ; 70b5d (1c:4b5d) ld hl, BattleTransition_FlashScreenPalettes .loop diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 15102340..21ee9d0d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -241,7 +241,7 @@ Func_3c11e: ; 3c11e (f:411e) call DelayFrames call SaveScreenTilesToBuffer1 .asm_3c14f - call AnyPlayerPokemonAliveCheck + call AnyPartyAlive ld a, d and a jp z, HandlePlayerBlackOut @@ -774,7 +774,7 @@ HandleEnemyMonFainted: ; 3c525 (f:4525) xor a ld [wccf0], a call FaintEnemyPokemon - call AnyPlayerPokemonAliveCheck + call AnyPartyAlive ld a, d and a jp z, HandlePlayerBlackOut @@ -870,7 +870,7 @@ FaintEnemyPokemon ; 0x3c567 jr nz, .playermonnotfaint call Func_3c741 .playermonnotfaint - call AnyPlayerPokemonAliveCheck + call AnyPartyAlive ld a, d and a ret z @@ -1021,7 +1021,7 @@ HandlePlayerMonFainted: ; 3c700 (f:4700) ld a, $1 ld [wccf0], a call Func_3c741 - call AnyPlayerPokemonAliveCheck ; test if any more mons are alive + call AnyPartyAlive ; test if any more mons are alive ld a, d and a jp z, HandlePlayerBlackOut @@ -1492,7 +1492,7 @@ TrainerSentOutText: ; 3ca7e (f:4a7e) ; tests if the player has any pokemon that are not fainted ; sets d = 0 if all fainted, d != 0 if some mons are still alive -AnyPlayerPokemonAliveCheck: ; 3ca83 (f:4a83) +AnyPartyAlive: ; 3ca83 (f:4a83) ld a, [wPartyCount] ; wPartyCount ld e, a xor a @@ -6930,7 +6930,7 @@ asm_3f0d0: ; 3f0d0 (f:70d0) jr nz, .asm_3f0f4 ret -LoadMonBackSprite: +LoadMonBackPic: ; Assumes the monster's attributes have ; been loaded with GetMonHeader. ld a, [wBattleMonSpecies2] diff --git a/engine/battle/e.asm b/engine/battle/e.asm index f3eac4c9..0cea797d 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -758,7 +758,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld a,1 ld [wcc49],a push hl - call AddPokemonToParty + call AddPartyMon pop hl jr .LoopTrainerData .SpecialTrainer @@ -775,7 +775,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld a,1 ld [wcc49],a push hl - call AddPokemonToParty + call AddPartyMon pop hl jr .SpecialTrainer .AddLoneMove diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 3bda4729..21b56bf3 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -41,7 +41,7 @@ _GivePokemon: ; 4fda5 (13:7da5) ret .asm_4fe01 call SetPokedexOwnedFlag - call AddPokemonToParty + call AddPartyMon ld a, $1 ld [wcc3c], a ld [wccd3], a diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm index b4d7125c..de0c4e41 100755 --- a/engine/hp_bar.asm +++ b/engine/hp_bar.asm @@ -1,9 +1,9 @@ -UpdateHPBar_LoadRegisters: ; f9dc (3:79dc) +HPBarLength: ; f9dc (3:79dc) call GetPredefRegisters ; calculates bc * 48 / de, the number of pixels the HP bar has ; the result is always at least 1 -UpdateHPBar_CalcNumberOfHPBarPixels: ; f9df (3:79df) +GetHPBarLength: ; f9df (3:79df) push hl xor a ld hl, H_MULTIPLICAND @@ -254,12 +254,12 @@ UpdateHPBar_CalcOldNewHPBarPixels: ; fb30 (3:7b30) ld l, a push hl push de - call UpdateHPBar_CalcNumberOfHPBarPixels ; calc num pixels for old HP + call GetHPBarLength ; calc num pixels for old HP ld a, e pop de pop bc push af - call UpdateHPBar_CalcNumberOfHPBarPixels ; calc num pixels for new HP + call GetHPBarLength ; calc num pixels for new HP pop af ld d, e ld e, a diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index e39cdb67..e1b6f757 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -136,7 +136,7 @@ Func_71c07: ; 71c07 (1c:5c07) call RemovePokemon ld a,$80 ld [wcc49],a - call AddPokemonToParty + call AddPartyMon call Func_71d19 callab EvolveTradeMon call ClearScreen diff --git a/engine/items/items.asm b/engine/items/items.asm index 194b7733..6b1bf8b3 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -431,7 +431,7 @@ ItemUseBall: ; d687 (3:5687) xor a ld [wcc49],a call ClearSprites - call AddPokemonToParty ;add mon to Party + call AddPartyMon ;add mon to Party jr .End .sendToBox ;$5907 call ClearSprites diff --git a/engine/items/tms.asm b/engine/items/tms.asm index 53b338d6..7a13250b 100755 --- a/engine/items/tms.asm +++ b/engine/items/tms.asm @@ -1,5 +1,5 @@ ; tests if mon [wcf91] can learn move [wd0e0] -TestMonMoveCompatibility: ; 1373e (4:773e) +CanLearnTM: ; 1373e (4:773e) ld a, [wcf91] ld [wd0b5], a call GetMonHeader diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index 35c8be12..e065d98d 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -1,4 +1,4 @@ -AskForMonNickname: ; 64eb (1:64eb) +AskName: ; 64eb (1:64eb) call SaveScreenTilesToBuffer1 call GetPredefRegisters push hl diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 3f50d8c5..2336cb47 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -1,4 +1,4 @@ -DisplayPokedexMenu_: ; 40000 (10:4000) +ShowPokedexMenu: ; 40000 (10:4000) call GBPalWhiteOut call ClearScreen call UpdateSprites ; move sprites diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm index 8a84c5e2..19550899 100755 --- a/engine/menu/vending_machine.asm +++ b/engine/menu/vending_machine.asm @@ -71,7 +71,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld hl, $ffde ld de, wPlayerMoney + 2 ; wd349 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef ld a, $13 ld [wd125], a diff --git a/engine/overworld/emotion_bubbles.asm b/engine/overworld/emotion_bubbles.asm index a8d863df..ae7702b4 100755 --- a/engine/overworld/emotion_bubbles.asm +++ b/engine/overworld/emotion_bubbles.asm @@ -1,4 +1,4 @@ -PrintEmotionBubble: ; 17c47 (5:7c47) +EmotionBubble: ; 17c47 (5:7c47) ld a, [wcd50] ld c, a ld b, $0 diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm index c66fc143..a75c393c 100644 --- a/engine/overworld/item.asm +++ b/engine/overworld/item.asm @@ -32,7 +32,7 @@ PickupItem: ld a, [$ffdb] ld [wcc4d], a - ld a, $11 ; RemoveMissableObject + ld a, $11 ; HideObject call Predef ld a, 1 ld [wcc3c], a diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 68a6b170..184d38f4 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -89,7 +89,7 @@ Func_705aa: ; 705aa (1c:45aa) ld [hl], a jp Func_70755 -_DoFlyOrTeleportAwayGraphics: ; 705ba (1c:45ba) +_LeaveMapAnim: ; 705ba (1c:45ba) call Func_706ef call Func_70787 ld a, b diff --git a/engine/overworld/trainers.asm b/engine/overworld/trainers.asm index 583decb9..b05ddbf1 100755 --- a/engine/overworld/trainers.asm +++ b/engine/overworld/trainers.asm @@ -159,7 +159,7 @@ Func_56903: ; 56903 (15:6903) ret ; tests if this trainer is in the right position to engage the player and do so if she is. -CheckEngagePlayer: ; 5690f (15:690f) +TrainerEngage: ; 5690f (15:690f) push hl push de ld a, [wTrainerSpriteOffset] ; wWhichTrade diff --git a/engine/palettes.asm b/engine/palettes.asm index 5eae18bd..5835f483 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -379,7 +379,7 @@ SendSGBPacket: ; 71feb (1c:5feb) ; else send 16 more bytes jr .loop2 -LoadSGBBorderAndPalettes: ; 7202b (1c:602b) +LoadSGB: ; 7202b (1c:602b) xor a ld [wcf1b], a call Func_7209b diff --git a/engine/predefs.asm b/engine/predefs.asm index e0df874f..7081df53 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -56,8 +56,7 @@ PredefPointers: ; 4fe79 (13:7e79) dbw BANK(Func_3f0c6),Func_3f0c6 dbw BANK(Func_3f073),Func_3f073 dbw BANK(ScaleSpriteByTwo), ScaleSpriteByTwo - db BANK(LoadMonBackSprite) ; dbw macro gives an error for some reason - dw LoadMonBackSprite + dbw BANK(LoadMonBackPic), LoadMonBackPic dbw BANK(Func_79aba),Func_79aba dbw BANK(Func_f132),Func_f132 HealPartyPredef: ; 4fe8e (13:7e8e) @@ -66,32 +65,24 @@ MoveAnimationPredef: ; 4fe91 (13:7e91) dbw BANK(MoveAnimation),MoveAnimation; 08 play move animation dbw BANK(DivideBCDPredef),DivideBCDPredef dbw BANK(DivideBCDPredef),DivideBCDPredef - dbw BANK(AddBCDPredef),AddBCDPredef - db BANK(SubtractBCDPredef) - dw SubtractBCDPredef + dbw BANK(AddBCDPredef), AddBCDPredef + dbw BANK(SubBCDPredef), SubBCDPredef dbw BANK(DivideBCDPredef),DivideBCDPredef dbw BANK(DivideBCDPredef),DivideBCDPredef - db BANK(InitializePlayerData) - dw InitializePlayerData + dbw BANK(InitPlayerData), InitPlayerData dbw BANK(FlagActionPredef),FlagActionPredef - db BANK(RemoveMissableObject) - dw RemoveMissableObject - db BANK(IsMissableObjectHidden) - dw IsMissableObjectHidden + dbw BANK(HideObject), HideObject + dbw BANK(IsObjectHidden), IsObjectHidden dbw BANK(Func_c69c),Func_c69c - db BANK(AnyPlayerPokemonAliveCheck) - dw AnyPlayerPokemonAliveCheck - db BANK(AddMissableObject) - dw AddMissableObject - db BANK(AddMissableObject) - dw AddMissableObject + dbw BANK(AnyPartyAlive), AnyPartyAlive + dbw BANK(ShowObject), ShowObject + dbw BANK(ShowObject), ShowObject dbw BANK(Func_ee9e),Func_ee9e - db BANK(InitializePlayerData) - dw InitializePlayerData + dbw BANK(InitPlayerData), InitPlayerData dbw BANK(Func_c754),Func_c754 dbw BANK(Func_3af5b),Func_3af5b dbw BANK(LearnMove),LearnMove - dbw BANK(IsItemInBag_),IsItemInBag_; 1C, used in Pokémon Tower + dbw BANK(IsItemInBag_),IsItemInBag_ ; 1C, used in Pokémon Tower dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 dbw $03,GiveItem dbw BANK(Func_480eb),Func_480eb @@ -101,12 +92,10 @@ MoveAnimationPredef: ; 4fe91 (13:7e91) dbw BANK(Func_f9a0),Func_f9a0 dbw BANK(Func_48125),Func_48125 dbw BANK(UpdateHPBar),UpdateHPBar - db BANK(UpdateHPBar_LoadRegisters) - dw UpdateHPBar_LoadRegisters + dbw BANK(HPBarLength), HPBarLength dbw BANK(Func_5ab0),Func_5ab0 dbw BANK(Func_3ed02),Func_3ed02 - db BANK(DisplayPokedexMenu_) - dw DisplayPokedexMenu_ + dbw BANK(ShowPokedexMenu), ShowPokedexMenu dbw BANK(Func_3ad1c),Func_3ad1c dbw BANK(SaveSAVtoSRAM0),SaveSAVtoSRAM0 dbw BANK(InitOpponent),InitOpponent @@ -117,58 +106,46 @@ MoveAnimationPredef: ; 4fe91 (13:7e91) dbw BANK(Func_79dda),Func_79dda dbw BANK(PlayIntro),PlayIntro dbw BANK(Func_79869),Func_79869 - db BANK(BattleTransition_FlashScreen_) - dw BattleTransition_FlashScreen_ + dbw BANK(FlashScreen), FlashScreen dbw BANK(Func_c586),Func_c586 dbw BANK(StatusScreen),StatusScreen ; 37 0x12953 dbw BANK(StatusScreen2),StatusScreen2 ; 38 dbw BANK(Func_410e2),Func_410e2 - db BANK(CheckEngagePlayer) - dw CheckEngagePlayer + dbw BANK(TrainerEngage), TrainerEngage dbw BANK(IndexToPokedex),IndexToPokedex dbw BANK(Predef3B),Predef3B; 3B display pic? dbw BANK(UsedCut),UsedCut dbw BANK(ShowPokedexData),ShowPokedexData dbw BANK(WriteMonMoves),WriteMonMoves dbw BANK(SaveSAV),SaveSAV - db BANK(LoadSGBBorderAndPalettes) - dw LoadSGBBorderAndPalettes + dbw BANK(LoadSGB), LoadSGB dbw BANK(Func_f113),Func_f113 dbw BANK(SetPartyMonTypes),SetPartyMonTypes - db BANK(TestMonMoveCompatibility) - dw TestMonMoveCompatibility + dbw BANK(CanLearnTM), CanLearnTM dbw BANK(TMToMove),TMToMove dbw BANK(Func_71ddf),Func_71ddf - db BANK(DisplayStarterMonDex) - dw DisplayStarterMonDex; 46 load dex screen - db BANK(_AddPokemonToParty) - dw _AddPokemonToParty + dbw BANK(StarterDex), StarterDex ; 46 + dbw BANK(_AddPartyMon), _AddPartyMon dbw BANK(UpdateHPBar),UpdateHPBar dbw BANK(Func_3cdec),Func_3cdec dbw BANK(LoadTownMap_Nest),LoadTownMap_Nest dbw BANK(Func_27d6b),Func_27d6b - db BANK(PrintEmotionBubble) - dw PrintEmotionBubble; 4C player exclamation + dbw BANK(EmotionBubble), EmotionBubble; 4C player exclamation dbw BANK(Func_5aaf),Func_5aaf; return immediately - db BANK(AskForMonNickname) - dw AskForMonNickname + dbw BANK(AskName), AskName dbw BANK(PewterGuys),PewterGuys dbw BANK(SaveSAVtoSRAM2),SaveSAVtoSRAM2 dbw BANK(LoadSAVCheckSum2),LoadSAVCheckSum2 dbw BANK(LoadSAV),LoadSAV dbw BANK(SaveSAVtoSRAM1),SaveSAVtoSRAM1 dbw BANK(Predef54),Predef54 ; 54 initiate trade - db BANK(HallOfFameComputer) - dw HallOfFameComputer + dbw BANK(HallOfFamePC), HallOfFamePC dbw BANK(DisplayDexRating),DisplayDexRating - db $1E ; uses wrong bank number - dw _DoFlyOrTeleportAwayGraphics - db $1E ; uses wrong bank number - dw Func_70510 + dbw $1E, _LeaveMapAnim ; wrong bank + dbw $1E, Func_70510 ; wrong bank dbw BANK(Func_c5be),Func_c5be dbw BANK(Func_c60b),Func_c60b - db BANK(PrintUsedStrengthText) - dw PrintUsedStrengthText + dbw BANK(PrintStrengthTxt), PrintStrengthTxt dbw BANK(PickupItem),PickupItem dbw BANK(Func_27d98),Func_27d98 dbw BANK(LoadMovePPs),LoadMovePPs diff --git a/engine/predefs17.asm b/engine/predefs17.asm index 91a6f7fe..11e67aff 100755 --- a/engine/predefs17.asm +++ b/engine/predefs17.asm @@ -1,6 +1,6 @@ ; this function temporarily makes the starters (and Ivysaur) seen ; so that the full Pokedex information gets displayed in Oak's lab -DisplayStarterMonDex: ; 5c0dc (17:40dc) +StarterDex: ; 5c0dc (17:40dc) ld a, %01001011 ; set starter flags ld [wPokedexOwned], a ; wPokedexOwned ld a, $3d diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 68a15a18..0e17d13f 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -618,7 +618,7 @@ SlotMachine_37741: ; 37741 (d:7741) ld [hli], a ld de, wPlayerCoins + 1 ld c, $2 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef SlotMachine_37754: ; 37754 (d:7754) diff --git a/home.asm b/home.asm index f1dd60b4..5062b18c 100644 --- a/home.asm +++ b/home.asm @@ -4146,11 +4146,11 @@ RemovePokemon:: ; 391f (0:391f) ld b, BANK(_RemovePokemon) jp Bankswitch -AddPokemonToParty:: ; 3927 (0:3927) +AddPartyMon:: ; 3927 (0:3927) push hl push de push bc - callba _AddPokemonToParty + callba _AddPartyMon pop bc pop de pop hl diff --git a/home/overworld.asm b/home/overworld.asm index 84c96f3e..941b50cb 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -332,7 +332,7 @@ OverworldLoopLessDelay:: ld a,[W_CURMAP] cp a,OAKS_LAB jp z,.noFaintCheck - callab AnyPlayerPokemonAliveCheck ; check if all the player's pokemon fainted + callab AnyPartyAlive ; check if all the player's pokemon fainted ld a,d and a jr z,.allPokemonFainted @@ -507,7 +507,7 @@ WarpFound2:: ; 073c (0:073c) ; if it's a Silph Co. teleporter ld hl,wd732 set 3,[hl] - call DoFlyOrTeleportAwayGraphics + call LeaveMapAnim jr .skipMapChangeSound .notTeleporter call PlayMapChangeSound @@ -778,16 +778,16 @@ HandleFlyOrTeleportAway:: ld hl, wd732 set 2, [hl] res 5, [hl] - call DoFlyOrTeleportAwayGraphics + call LeaveMapAnim ld a, Bank(Func_62ce) ld [H_LOADEDROMBANK], a ld [$2000], a call Func_62ce jp Func_5d5f -DoFlyOrTeleportAwayGraphics:: - ld b, BANK(_DoFlyOrTeleportAwayGraphics) - ld hl, _DoFlyOrTeleportAwayGraphics +LeaveMapAnim:: + ld b, BANK(_LeaveMapAnim) + ld hl, _LeaveMapAnim jp Bankswitch LoadPlayerSpriteGraphics:: diff --git a/main.asm b/main.asm index 9d612cd2..ef17ad63 100755 --- a/main.asm +++ b/main.asm @@ -487,7 +487,7 @@ TestBattle: xor a ld [wcc49], a ld [W_CURMAP], a - call AddPokemonToParty + call AddPartyMon ; Fight against a ; level 20 Rhydon. @@ -686,7 +686,7 @@ SetIshiharaTeam: ; 64ca (1:64ca) ld a, [de] ld [W_CURENEMYLVL], a inc de - call AddPokemonToParty + call AddPartyMon jr .loop IshiharaTeam: ; 64df (1:64df) @@ -2638,7 +2638,7 @@ Func_c8de: ; c8de (3:48de) INCLUDE "data/hide_show_data.asm" -PrintUsedStrengthText: ; cd99 (3:4d99) +PrintStrengthTxt: ; cd99 (3:4d99) ld hl, wd728 set 0, [hl] ld hl, UsedStrengthText @@ -3231,7 +3231,7 @@ InitializeMissableObjectsFlags: ; f175 (3:7175) jr .missableObjectsLoop ; tests if current sprite is a missable object that is hidden/has been removed -IsMissableObjectHidden: ; f1a6 (3:71a6) +IsObjectHidden: ; f1a6 (3:71a6) ld a, [H_CURRENTSPRITEOFFSET] swap a ld b, a @@ -3258,7 +3258,7 @@ IsMissableObjectHidden: ; f1a6 (3:71a6) ; adds missable object (items, leg. pokemon, etc.) to the map ; [wcc4d]: index of the missable object to be added (global index) -AddMissableObject: ; f1c8 (3:71c8) +ShowObject: ; f1c8 (3:71c8) ld hl, W_MISSABLEOBJECTFLAGS ld a, [wcc4d] ld c, a @@ -3268,7 +3268,7 @@ AddMissableObject: ; f1c8 (3:71c8) ; removes missable object (items, leg. pokemon, etc.) from the map ; [wcc4d]: index of the missable object to be removed (global index) -RemoveMissableObject: ; f1d7 (3:71d7) +HideObject: ; f1d7 (3:71d7) ld hl, W_MISSABLEOBJECTFLAGS ld a, [wcc4d] ld c, a @@ -3452,7 +3452,7 @@ Func_f2dd: ; f2dd (3:72dd) res 6, [hl] ret -_AddPokemonToParty: ; f2e5 (3:72e5) +_AddPartyMon: ; f2e5 (3:72e5) ld de, wPartyCount ; wPartyCount ld a, [wcc49] and $f @@ -3668,7 +3668,7 @@ _AddPokemonToParty: ; f2e5 (3:72e5) inc de inc de pop hl - call AddPokemonToParty_WriteMovePP + call AddPartyMon_WriteMovePP inc de ld a, [W_CURENEMYLVL] ; W_CURENEMYLVL ld [de], a @@ -3694,7 +3694,7 @@ _AddPokemonToParty: ; f2e5 (3:72e5) LoadMovePPs: ; f473 (3:7473) call GetPredefRegisters ; fallthrough -AddPokemonToParty_WriteMovePP: ; f476 (3:7476) +AddPartyMon_WriteMovePP: ; f476 (3:7476) ld b, $4 .pploop ld a, [hli] ; read move ID @@ -4286,7 +4286,7 @@ Func_f800: ; f800 (3:7800) ld de, $ffa1 ld hl, $ffa4 push bc - call SubtractBCD + call SubBCD pop bc jr .asm_f803 @@ -4318,10 +4318,10 @@ AddBCD:: ret -SubtractBCDPredef:: +SubBCDPredef:: call GetPredefRegisters -SubtractBCD:: +SubBCD:: and a ld b, c .sub @@ -4346,7 +4346,7 @@ SubtractBCD:: ret -InitializePlayerData: +InitPlayerData: call Random ld a, [hRandomSub] diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 039abe42..4cb001e6 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -157,7 +157,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9) ld hl, $ffa1 ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef xor a ldh [$9f], a diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index d2a70578..b584c4ed 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -156,7 +156,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) inc hl ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent diff --git a/scripts/mtmoonpokecenter.asm b/scripts/mtmoonpokecenter.asm index e4515a61..6bbe7a1b 100755 --- a/scripts/mtmoonpokecenter.asm +++ b/scripts/mtmoonpokecenter.asm @@ -55,7 +55,7 @@ MtMoonPokecenterText4: ; 492ec (12:52ec) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef ld a, $13 ld [wd125], a diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index ed36973d..5e1bb792 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -103,7 +103,7 @@ Museum1FText1: ; 5c135 (17:4135) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef ld a, $13 ld [wd125], a diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 0a54082d..194eb1a8 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -847,7 +847,7 @@ OaksLabScript_1d157: ; 1d157 (7:5157) ld hl, wd730 set 6, [hl] ld a, $46 - call Predef ; DisplayStarterMonDex + call Predef ; StarterDex ld hl, wd730 res 6, [hl] call ReloadMapData @@ -921,7 +921,7 @@ asm_1d1e5: ; 1d1e5 (7:51e5) ld [W_CURENEMYLVL], a ld a, [wcf91] ld [wd11e], a - call AddPokemonToParty + call AddPartyMon ld hl, wd72e set 3, [hl] ld a, $fc diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index b560c53d..7140f67b 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -176,7 +176,7 @@ SafariZoneEntranceText4: ; 752ca (1d:52ca) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubtractBCDPredef + ld a, $c ; SubBCDPredef call Predef ld a, $13 ld [wd125], a -- cgit v1.3.1-sl0p From 94dc6955431171d4dba5833e5784e102dd045b49 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 16 Jun 2014 13:05:16 -0700 Subject: Fix a typo in home/vcopy.asm. This must have happened when the file got split out of home.asm. Since it was the first character on the line, it was interpreted as a label. --- home/vcopy.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'home') diff --git a/home/vcopy.asm b/home/vcopy.asm index 9f152841..71487cf1 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -182,7 +182,7 @@ TransferBgRows:: ; 1d9e (0:1d9e) inc l ld [hl], d -i ld a, 32 - (20 - 1) + ld a, 32 - (20 - 1) add l ld l, a jr nc, .ok -- cgit v1.3.1-sl0p From d10108a066c102bf2d167ac656d79308e41f304e Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 16 Jun 2014 13:25:46 -0700 Subject: Use macros to define predefs. --- engine/battle/4.asm | 2 +- engine/battle/core.asm | 2 +- engine/hp_bar.asm | 1 + engine/menu/status_screen.asm | 2 +- engine/overworld/pokecenter.asm | 2 +- engine/predefs.asm | 193 ++++++++++++++++++++-------------------- home/init.asm | 6 +- macros.asm | 18 +++- main.asm | 8 +- scripts/redshouse1f.asm | 2 +- 10 files changed, 123 insertions(+), 113 deletions(-) (limited to 'home') diff --git a/engine/battle/4.asm b/engine/battle/4.asm index 6e2bad34..11772a15 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -15,7 +15,7 @@ Func_128ea: ; 128ea (4:68ea) inc b ret -Func_128ef: ; 128ef (4:68ef) +DrawHP: ; 128ef (4:68ef) call GetPredefRegisters ld a, $1 jr asm_128fb diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 21ee9d0d..a1a69a4f 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -6661,7 +6661,7 @@ Func_3eed3: ; 3eed3 (f:6ed3) PlayMoveAnimation: ; 3ef07 (f:6f07) ld [W_ANIMATIONID],a call Delay3 - PREDEF_JUMP MoveAnimationPredef ; predef 8 + predef_jump MoveAnimation InitBattle: ; 3ef12 (f:6f12) ld a, [W_CUROPPONENT] ; wd059 diff --git a/engine/hp_bar.asm b/engine/hp_bar.asm index de0c4e41..9ff9e3cf 100755 --- a/engine/hp_bar.asm +++ b/engine/hp_bar.asm @@ -46,6 +46,7 @@ GetHPBarLength: ; f9df (3:79df) ; predef $48 UpdateHPBar: ; fa1d (3:7a1d) +UpdateHPBar2: push hl ld hl, wHPBarOldHP ld a, [hli] diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 2d33e79f..3bacd306 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -59,7 +59,7 @@ StatusScreen: ; 12953 (4:6953) call PlaceString ; "TYPE1/" FuncCoord 11,3 ld hl, Coord - PREDEF DrawHPBarPredef ; predef $5f + predef DrawHP ; predef $5f ld hl, wcf25 call GetHealthBarColor ld b, $3 diff --git a/engine/overworld/pokecenter.asm b/engine/overworld/pokecenter.asm index 2dedc437..3c640d8e 100755 --- a/engine/overworld/pokecenter.asm +++ b/engine/overworld/pokecenter.asm @@ -21,7 +21,7 @@ DisplayPokemonCenterDialogue_: ; 6fe6 (1:6fe6) ld a, $18 ld [wSpriteStateData1 + $12], a ; make the nurse turn to face the machine call Delay3 - PREDEF HealPartyPredef + predef HealParty callba AnimateHealingMachine ; do the healing machine animation xor a ld [wMusicHeaderPointer], a diff --git a/engine/predefs.asm b/engine/predefs.asm index 7081df53..53022bc4 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -52,105 +52,102 @@ GetPredefPointer: PredefPointers: ; 4fe79 (13:7e79) ; these are pointers to ASM routines. ; they appear to be used in overworld map scripts. - dbw BANK(Func_3cd60),Func_3cd60 - dbw BANK(Func_3f0c6),Func_3f0c6 - dbw BANK(Func_3f073),Func_3f073 - dbw BANK(ScaleSpriteByTwo), ScaleSpriteByTwo - dbw BANK(LoadMonBackPic), LoadMonBackPic - dbw BANK(Func_79aba),Func_79aba - dbw BANK(Func_f132),Func_f132 -HealPartyPredef: ; 4fe8e (13:7e8e) - dbw BANK(HealParty),HealParty -MoveAnimationPredef: ; 4fe91 (13:7e91) - dbw BANK(MoveAnimation),MoveAnimation; 08 play move animation - dbw BANK(DivideBCDPredef),DivideBCDPredef - dbw BANK(DivideBCDPredef),DivideBCDPredef - dbw BANK(AddBCDPredef), AddBCDPredef - dbw BANK(SubBCDPredef), SubBCDPredef - dbw BANK(DivideBCDPredef),DivideBCDPredef - dbw BANK(DivideBCDPredef),DivideBCDPredef - dbw BANK(InitPlayerData), InitPlayerData - dbw BANK(FlagActionPredef),FlagActionPredef - dbw BANK(HideObject), HideObject - dbw BANK(IsObjectHidden), IsObjectHidden - dbw BANK(Func_c69c),Func_c69c - dbw BANK(AnyPartyAlive), AnyPartyAlive - dbw BANK(ShowObject), ShowObject - dbw BANK(ShowObject), ShowObject - dbw BANK(Func_ee9e),Func_ee9e - dbw BANK(InitPlayerData), InitPlayerData - dbw BANK(Func_c754),Func_c754 - dbw BANK(Func_3af5b),Func_3af5b - dbw BANK(LearnMove),LearnMove - dbw BANK(IsItemInBag_),IsItemInBag_ ; 1C, used in Pokémon Tower + add_predef Func_3cd60 + add_predef Func_3f0c6 + add_predef Func_3f073 + add_predef ScaleSpriteByTwo + add_predef LoadMonBackPic + add_predef Func_79aba + add_predef Func_f132 + add_predef HealParty + add_predef MoveAnimation; 08 play move animation + add_predef DivideBCDPredef + add_predef DivideBCDPredef2 + add_predef AddBCDPredef + add_predef SubBCDPredef + add_predef DivideBCDPredef3 + add_predef DivideBCDPredef4 + add_predef InitPlayerData + add_predef FlagActionPredef + add_predef HideObject + add_predef IsObjectHidden + add_predef Func_c69c + add_predef AnyPartyAlive + add_predef ShowObject + add_predef ShowObject2 + add_predef Func_ee9e + add_predef InitPlayerData2 + add_predef Func_c754 + add_predef Func_3af5b + add_predef LearnMove + add_predef IsItemInBag_ ; 1C, used in Pokémon Tower dbw $03,Func_3eb5 ; for these two, the bank number is actually 0 dbw $03,GiveItem - dbw BANK(Func_480eb),Func_480eb - dbw BANK(Func_f8ba),Func_f8ba - dbw BANK(Func_480ff),Func_480ff - dbw BANK(Func_f929),Func_f929 - dbw BANK(Func_f9a0),Func_f9a0 - dbw BANK(Func_48125),Func_48125 - dbw BANK(UpdateHPBar),UpdateHPBar - dbw BANK(HPBarLength), HPBarLength - dbw BANK(Func_5ab0),Func_5ab0 - dbw BANK(Func_3ed02),Func_3ed02 - dbw BANK(ShowPokedexMenu), ShowPokedexMenu - dbw BANK(Func_3ad1c),Func_3ad1c - dbw BANK(SaveSAVtoSRAM0),SaveSAVtoSRAM0 - dbw BANK(InitOpponent),InitOpponent - dbw BANK(Func_5a5f),Func_5a5f - dbw BANK(DrawBadges), DrawBadges - dbw BANK(Func_410f3),Func_410f3 - dbw BANK(BattleTransition),BattleTransition - dbw BANK(Func_79dda),Func_79dda - dbw BANK(PlayIntro),PlayIntro - dbw BANK(Func_79869),Func_79869 - dbw BANK(FlashScreen), FlashScreen - dbw BANK(Func_c586),Func_c586 - dbw BANK(StatusScreen),StatusScreen ; 37 0x12953 - dbw BANK(StatusScreen2),StatusScreen2 ; 38 - dbw BANK(Func_410e2),Func_410e2 - dbw BANK(TrainerEngage), TrainerEngage - dbw BANK(IndexToPokedex),IndexToPokedex - dbw BANK(Predef3B),Predef3B; 3B display pic? - dbw BANK(UsedCut),UsedCut - dbw BANK(ShowPokedexData),ShowPokedexData - dbw BANK(WriteMonMoves),WriteMonMoves - dbw BANK(SaveSAV),SaveSAV - dbw BANK(LoadSGB), LoadSGB - dbw BANK(Func_f113),Func_f113 - dbw BANK(SetPartyMonTypes),SetPartyMonTypes - dbw BANK(CanLearnTM), CanLearnTM - dbw BANK(TMToMove),TMToMove - dbw BANK(Func_71ddf),Func_71ddf - dbw BANK(StarterDex), StarterDex ; 46 - dbw BANK(_AddPartyMon), _AddPartyMon - dbw BANK(UpdateHPBar),UpdateHPBar - dbw BANK(Func_3cdec),Func_3cdec - dbw BANK(LoadTownMap_Nest),LoadTownMap_Nest - dbw BANK(Func_27d6b),Func_27d6b - dbw BANK(EmotionBubble), EmotionBubble; 4C player exclamation - dbw BANK(Func_5aaf),Func_5aaf; return immediately - dbw BANK(AskName), AskName - dbw BANK(PewterGuys),PewterGuys - dbw BANK(SaveSAVtoSRAM2),SaveSAVtoSRAM2 - dbw BANK(LoadSAVCheckSum2),LoadSAVCheckSum2 - dbw BANK(LoadSAV),LoadSAV - dbw BANK(SaveSAVtoSRAM1),SaveSAVtoSRAM1 - dbw BANK(Predef54),Predef54 ; 54 initiate trade - dbw BANK(HallOfFamePC), HallOfFamePC - dbw BANK(DisplayDexRating),DisplayDexRating + add_predef Func_480eb + add_predef Func_f8ba + add_predef Func_480ff + add_predef Func_f929 + add_predef Func_f9a0 + add_predef Func_48125 + add_predef UpdateHPBar + add_predef HPBarLength + add_predef Func_5ab0 + add_predef Func_3ed02 + add_predef ShowPokedexMenu + add_predef Func_3ad1c + add_predef SaveSAVtoSRAM0 + add_predef InitOpponent + add_predef Func_5a5f + add_predef DrawBadges + add_predef Func_410f3 + add_predef BattleTransition + add_predef Func_79dda + add_predef PlayIntro + add_predef Func_79869 + add_predef FlashScreen + add_predef Func_c586 + add_predef StatusScreen + add_predef StatusScreen2 + add_predef Func_410e2 + add_predef TrainerEngage + add_predef IndexToPokedex + add_predef Predef3B; 3B display pic? + add_predef UsedCut + add_predef ShowPokedexData + add_predef WriteMonMoves + add_predef SaveSAV + add_predef LoadSGB + add_predef Func_f113 + add_predef SetPartyMonTypes + add_predef CanLearnTM + add_predef TMToMove + add_predef Func_71ddf + add_predef StarterDex ; 46 + add_predef _AddPartyMon + add_predef UpdateHPBar2 + add_predef Func_3cdec + add_predef LoadTownMap_Nest + add_predef Func_27d6b + add_predef EmotionBubble; 4C player exclamation + add_predef Func_5aaf; return immediately + add_predef AskName + add_predef PewterGuys + add_predef SaveSAVtoSRAM2 + add_predef LoadSAVCheckSum2 + add_predef LoadSAV + add_predef SaveSAVtoSRAM1 + add_predef Predef54 ; 54 initiate trade + add_predef HallOfFamePC + add_predef DisplayDexRating dbw $1E, _LeaveMapAnim ; wrong bank dbw $1E, Func_70510 ; wrong bank - dbw BANK(Func_c5be),Func_c5be - dbw BANK(Func_c60b),Func_c60b - dbw BANK(PrintStrengthTxt), PrintStrengthTxt - dbw BANK(PickupItem),PickupItem - dbw BANK(Func_27d98),Func_27d98 - dbw BANK(LoadMovePPs),LoadMovePPs -DrawHPBarPredef: ; 4ff96 (13:7f96) - dbw BANK(Func_128ef),Func_128ef ; 5F draw HP bar - dbw BANK(Func_128f6),Func_128f6 - dbw BANK(Func_1c9c6),Func_1c9c6 - dbw BANK(OaksAideScript),OaksAideScript + add_predef Func_c5be + add_predef Func_c60b + add_predef PrintStrengthTxt + add_predef PickupItem + add_predef Func_27d98 + add_predef LoadMovePPs + add_predef DrawHP ; 5F + add_predef Func_128f6 + add_predef Func_1c9c6 + add_predef OaksAideScript diff --git a/home/init.asm b/home/init.asm index 1518218e..b79b19d9 100644 --- a/home/init.asm +++ b/home/init.asm @@ -95,8 +95,7 @@ rLCDC_DEFAULT EQU %11100011 ei - ld a, $40 ; PREDEF_SGB_BORDER - call Predef + predef LoadSGB ld a, BANK(SFX_1f_67) ld [wc0ef], a @@ -108,8 +107,7 @@ rLCDC_DEFAULT EQU %11100011 dec a ld [wcfcb], a - ld a, $32 ; PREDEF_INTRO - call Predef + predef PlayIntro call DisableLCD call ClearVram diff --git a/macros.asm b/macros.asm index 2c0d3dfb..a99a80ea 100644 --- a/macros.asm +++ b/macros.asm @@ -138,13 +138,23 @@ TX_BCD: MACRO ENDM ; Predef macro. -PREDEF: MACRO - ld a, (\1 - PredefPointers) / 3 +add_predef: MACRO +\1Predef:: + db BANK(\1) + dw \1 + ENDM + +predef_id: MACRO + ld a, (\1Predef - PredefPointers) / 3 + ENDM + +predef: MACRO + predef_id \1 call Predef ENDM -PREDEF_JUMP: MACRO - ld a, (\1 - PredefPointers) / 3 +predef_jump: MACRO + predef_id \1 jp Predef ENDM diff --git a/main.asm b/main.asm index ef17ad63..324f6a11 100755 --- a/main.asm +++ b/main.asm @@ -494,8 +494,7 @@ TestBattle: ld a, RHYDON ld [W_CUROPPONENT], a - ld a, $2c ; PREDEF_BATTLE - call Predef + predef InitOpponent ; When the battle ends, ; do it all again. @@ -3259,6 +3258,7 @@ IsObjectHidden: ; f1a6 (3:71a6) ; adds missable object (items, leg. pokemon, etc.) to the map ; [wcc4d]: index of the missable object to be added (global index) ShowObject: ; f1c8 (3:71c8) +ShowObject2: ld hl, W_MISSABLEOBJECTFLAGS ld a, [wcc4d] ld c, a @@ -4136,6 +4136,9 @@ HealParty: DivideBCDPredef:: +DivideBCDPredef2:: +DivideBCDPredef3:: +DivideBCDPredef4:: call GetPredefRegisters DivideBCD:: @@ -4347,6 +4350,7 @@ SubBCD:: InitPlayerData: +InitPlayerData2: call Random ld a, [hRandomSub] diff --git a/scripts/redshouse1f.asm b/scripts/redshouse1f.asm index 4bab98fe..0e3e331b 100755 --- a/scripts/redshouse1f.asm +++ b/scripts/redshouse1f.asm @@ -27,7 +27,7 @@ MomHealPokemon: ; 4818a (12:418a) call PrintText call GBFadeOut2 call ReloadMapData - PREDEF HealPartyPredef + predef HealParty ld a, MUSIC_PKMN_HEALED ld [wc0ee], a call PlaySound ; play sound? -- cgit v1.3.1-sl0p From b36f793667924f868282ce979fabab3e95d642a5 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 16 Jun 2014 13:57:26 -0700 Subject: Use macros for predef calls/jumps instead of static ids. --- engine/battle/1.asm | 9 +-- engine/battle/15.asm | 15 ++-- engine/battle/4.asm | 3 +- engine/battle/4_2.asm | 9 +-- engine/battle/animations.asm | 15 ++-- engine/battle/b_2.asm | 3 +- engine/battle/core.asm | 111 ++++++++++-------------------- engine/battle/e.asm | 6 +- engine/battle/e_2.asm | 3 +- engine/cable_club.asm | 24 +++---- engine/evos_moves.asm | 15 ++-- engine/game_corner_slots2.asm | 3 +- engine/give_pokemon.asm | 6 +- engine/hall_of_fame.asm | 15 ++-- engine/hidden_object_functions17.asm | 3 +- engine/hidden_object_functions7.asm | 9 +-- engine/in_game_trades.asm | 9 +-- engine/intro.asm | 6 +- engine/items/itemfinder.asm | 3 +- engine/items/items.asm | 60 ++++++---------- engine/items/tms.asm | 3 +- engine/menu/bills_pc.asm | 6 +- engine/menu/diploma.asm | 3 +- engine/menu/main_menu.asm | 3 +- engine/menu/oaks_pc.asm | 3 +- engine/menu/party_menu.asm | 6 +- engine/menu/pokedex.asm | 6 +- engine/menu/prize_menu.asm | 3 +- engine/menu/start_sub_menus.asm | 24 +++---- engine/menu/status_screen.asm | 6 +- engine/menu/vending_machine.asm | 3 +- engine/mon_party_sprites.asm | 3 +- engine/oak_speech.asm | 6 +- engine/overworld/card_key.asm | 6 +- engine/overworld/hidden_items.asm | 18 ++--- engine/overworld/item.asm | 3 +- engine/overworld/ledges.asm | 3 +- engine/overworld/movement.asm | 3 +- engine/overworld/npc_movement.asm | 12 ++-- engine/overworld/player_animations.asm | 3 +- engine/palettes.asm | 3 +- engine/predefs.asm | 2 +- engine/predefs17.asm | 3 +- engine/slot_machine.asm | 9 +-- engine/trade.asm | 3 +- engine/trade2.asm | 6 +- home.asm | 39 ++++------- home/overworld.asm | 27 +++----- main.asm | 45 ++++-------- scripts/agatha.asm | 3 +- scripts/billshouse.asm | 12 ++-- scripts/blueshouse.asm | 3 +- scripts/bruno.asm | 3 +- scripts/celadongamecorner.asm | 24 +++---- scripts/celadonmansion5.asm | 3 +- scripts/celadonmartelevator.asm | 3 +- scripts/celadonmartroof.asm | 3 +- scripts/ceruleancity.asm | 9 +-- scripts/ceruleancity2.asm | 9 +-- scripts/ceruleanhouse1.asm | 3 +- scripts/ceruleanhousetrashed.asm | 3 +- scripts/cinnabargym.asm | 3 +- scripts/daycarem.asm | 9 +-- scripts/fightingdojo.asm | 6 +- scripts/gary.asm | 6 +- scripts/halloffameroom.asm | 6 +- scripts/lab2.asm | 3 +- scripts/lab4.asm | 6 +- scripts/lance.asm | 3 +- scripts/lorelei.asm | 3 +- scripts/mansion1.asm | 3 +- scripts/mansion2.asm | 3 +- scripts/mtmoon3.asm | 9 +-- scripts/mtmoonpokecenter.asm | 3 +- scripts/museum1f.asm | 6 +- scripts/oakslab.asm | 54 +++++---------- scripts/pallettown.asm | 18 ++--- scripts/pewtercity.asm | 12 ++-- scripts/pewtergym.asm | 6 +- scripts/pokemontower2.asm | 3 +- scripts/pokemontower5.asm | 3 +- scripts/pokemontower7.asm | 15 ++-- scripts/rockethideout1.asm | 3 +- scripts/rockethideout4.asm | 12 ++-- scripts/rockethideoutelevator.asm | 3 +- scripts/route11gateupstairs.asm | 6 +- scripts/route12.asm | 3 +- scripts/route15gateupstairs.asm | 3 +- scripts/route16.asm | 3 +- scripts/route18gateupstairs.asm | 3 +- scripts/route20.asm | 6 +- scripts/route22.asm | 12 ++-- scripts/route23.asm | 15 ++-- scripts/route25.asm | 12 ++-- scripts/route2gate.asm | 3 +- scripts/route2house.asm | 3 +- scripts/safarizoneentrance.asm | 3 +- scripts/seafoamislands1.asm | 6 +- scripts/seafoamislands2.asm | 6 +- scripts/seafoamislands3.asm | 6 +- scripts/seafoamislands4.asm | 6 +- scripts/silphco1.asm | 3 +- scripts/silphco10.asm | 3 +- scripts/silphco11.asm | 9 +-- scripts/silphco2.asm | 6 +- scripts/silphco3.asm | 6 +- scripts/silphco4.asm | 6 +- scripts/silphco5.asm | 9 +-- scripts/silphco6.asm | 3 +- scripts/silphco7.asm | 12 ++-- scripts/silphco8.asm | 3 +- scripts/silphco9.asm | 15 ++-- scripts/silphcoelevator.asm | 3 +- scripts/ssanne2.asm | 6 +- scripts/undergroundpathentranceroute5.asm | 3 +- scripts/vermilioncity.asm | 6 +- scripts/vermiliongym.asm | 3 +- scripts/vermilionhouse3.asm | 3 +- scripts/victoryroad1.asm | 3 +- scripts/victoryroad2.asm | 3 +- scripts/victoryroad3.asm | 9 +-- scripts/viridiangym.asm | 6 +- 122 files changed, 360 insertions(+), 719 deletions(-) (limited to 'home') diff --git a/engine/battle/1.asm b/engine/battle/1.asm index ace29477..7e744dba 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -76,12 +76,9 @@ Func_7861: ; 7861 (1:7861) xor a .asm_78aa ld [wListMenuID], a ; wListMenuID - ld a, $48 - call Predef - ld a, $0 - call Predef - ld a, $49 - call Predef + predef UpdateHPBar2 + predef Func_3cd60 + predef Func_3cdec callab ReadPlayerMonCurHPAndStatus ld hl, SuckedHealthText ; $78dc ld a, [H_WHOSETURN] ; $fff3 diff --git a/engine/battle/15.asm b/engine/battle/15.asm index ba79d77e..69d8ff3f 100755 --- a/engine/battle/15.asm +++ b/engine/battle/15.asm @@ -17,8 +17,7 @@ Func_5525f: ; 5525f (15:525f) ld a, [wWhichPokemon] ld c, a ld b, $2 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld a, c and a pop hl @@ -245,14 +244,12 @@ Func_5525f: ; 5525f (15:525f) ld [wcc49], a ld a, [wd0b5] ld [wd11e], a - ld a, $1a - call Predef + predef Func_3af5b ld hl, wccd3 ld a, [wWhichPokemon] ; wWhichPokemon ld c, a ld b, $1 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef pop hl pop af ld [W_CURENEMYLVL], a ; W_CURENEMYLVL @@ -277,14 +274,12 @@ Func_55436: ; 55436 (15:5436) ld c, a ld b, $1 push bc - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld hl, wccf5 xor a ld [hl], a pop bc - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef Func_5546c: ; 5546c (15:546c) ld a, [wPartyAliveFlags] diff --git a/engine/battle/4.asm b/engine/battle/4.asm index 11772a15..db6614cc 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -43,8 +43,7 @@ asm_128fb: ; 128fb (4:68fb) ld d, a ld a, [wcfbb] ld e, a - ld a, $26 - call Predef + predef HPBarLength ld a, $6 ld d, a ld c, a diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index d96fb87c..db9d076f 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -36,15 +36,13 @@ Func_137aa: ; 137aa (4:77aa) jr z, .asm_1380a ld de, wPlayerMoney + 2 ; wd349 ld c, $3 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, PickUpPayDayMoneyText call PrintText .asm_1380a xor a ld [wccd4], a - ld a, $2a - call Predef + predef Func_3ad1c .asm_13813 xor a ld [wd083], a @@ -263,8 +261,7 @@ RecoilEffect_: ; 1392c (4:792c) xor a .asm_13990 ld [wListMenuID], a ; wListMenuID - ld a, $48 - call Predef + predef UpdateHPBar2 ld hl, HitWithRecoilText ; $799e jp PrintText HitWithRecoilText: ; 1399e (4:799e) diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index a5fb0253..8fad427a 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -831,11 +831,9 @@ DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9) ; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically .shakeScreen ld b,1 - ld a,$24 - call Predef ; shake horizontally + predef Func_48125 ; shake horizontally ld b,1 - ld a,$21 - jp Predef ; shake vertically + predef_jump Func_480ff ; shake vertically FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7) ld a,[W_SUBANIMCOUNTER] @@ -1227,16 +1225,14 @@ Func_791fc: ; 791fc (1e:51fc) ld b, $5 Func_79209: ; 79209 (1e:5209) - ld a, $21 - jp Predef + predef_jump Func_480ff AnimationShakeScreen: ; 7920e (1e:520e) ; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations. ld b, $8 Func_79210: ; 79210 (1e:5210) - ld a, $24 - jp Predef + predef_jump Func_48125 AnimationWaterDropletsEverywhere: ; 79215 (1e:5215) ; Draws water droplets all over the screen and makes them @@ -2143,8 +2139,7 @@ Func_79793: ; 79793 (1e:5793) ld [wBattleMonSpecies2], a ld [wd0b5], a call GetMonHeader - ld a, $4 - call Predef + predef LoadMonBackPic xor a call Func_79842 call Func_79820 diff --git a/engine/battle/b_2.asm b/engine/battle/b_2.asm index 3c839cba..e343f1aa 100755 --- a/engine/battle/b_2.asm +++ b/engine/battle/b_2.asm @@ -120,8 +120,7 @@ PayDayEffect_ ; 2feb8 (b:7eb8) ld [hl], a ld de, wcce7 ld c, $3 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, CoinsScatteredText ; $7f04 jp PrintText diff --git a/engine/battle/core.asm b/engine/battle/core.asm index a1a69a4f..4f382df7 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -173,8 +173,7 @@ Func_3c04c: ; 3c04c (f:404c) ld [$ffe1], a FuncCoord 1, 5 ld hl, Coord - ld a, $1 - call Predef + predef Func_3f0c6 xor a ld [$ffb0], a ld [rWY], a ; $ff4a @@ -320,12 +319,10 @@ Func_3c1ad: ; 3c1ad (f:41ad) ld b, $1 push bc ld hl, wPartyAliveFlags - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld hl, wccf5 pop bc - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef call Func_3cba6 call LoadScreenTilesFromBuffer1 call Func_3cc91 @@ -751,8 +748,7 @@ UpdateCurMonHPBar: ; 3c4f6 (f:44f6) .playersTurn push bc ld [wListMenuID], a ; wListMenuID - ld a, $48 - call Predef + predef UpdateHPBar2 pop bc ret @@ -996,8 +992,7 @@ TrainerBattleVictory: ; 3c696 (f:4696) ld de, wPlayerMoney + 2 ; wd349 ld hl, wd07b ld c, $3 - ld a, $b ; AddBCDPredef - jp Predef + predef_jump AddBCDPredef MoneyForWinningText: ; 3c6e4 (f:46e4) TX_FAR _MoneyForWinningText @@ -1053,8 +1048,7 @@ Func_3c741: ; 3c741 (f:4741) ld c, a ld hl, wPartyAliveFlags ; clear fainted mon's alive flag ld b, $0 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld hl, W_ENEMYBATTSTATUS1 ; W_ENEMYBATTSTATUS1 res 2, [hl] ; reset "attacking multiple times" flag ld a, [wd083] @@ -1153,12 +1147,10 @@ Func_3c7d8: ; 3c7d8 (f:47d8) ld hl, wPartyAliveFlags ld b, $1 push bc - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef pop bc ld hl, wccf5 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef call Func_3cba6 call GBPalWhiteOut call Func_3ee5b @@ -1317,14 +1309,12 @@ EnemySendOut: ; 3c90e (f:490e) ld c,a ld b,1 push bc - ld a,$10 - call Predef + predef FlagActionPredef ld hl,wccf5 xor a ld [hl],a pop bc - ld a,$10 - call Predef + predef FlagActionPredef Func_3c92a: ; 3c92a (f:492a) xor a ld hl,wd065 @@ -1468,8 +1458,7 @@ Func_3c92a: ; 3c92a (f:492a) ld [$FFE1],a FuncCoord 15, 6 ld hl,Coord - ld a,2 - call Predef + predef Func_3f073 ld a,[wEnemyMonSpecies2] call PlayCry call Func_3cdec @@ -1759,8 +1748,7 @@ Func_3cc91: ; 3cc91 (f:4c91) Func_3cca4: ; 3cca4 (f:4ca4) call Func_3cd60 - ld a, $4 - call Predef + predef LoadMonBackPic xor a ld [$ffe1], a ld hl, wcc2d @@ -1791,8 +1779,7 @@ Func_3cca4: ; 3cca4 (f:4ca4) call PlayMoveAnimation FuncCoord 4, 11 ld hl, Coord - ld a, $2 - call Predef + predef Func_3f073 ld a, [wcf91] call PlayCry call Func_3ee94 @@ -1809,8 +1796,7 @@ Func_3ccfa: ; 3ccfa (f:4cfa) xor a ld [wcd6c], a ld [H_DOWNARROWBLINKCNT1], a ; $ff8b - ld a, $5 - call Predef + predef Func_79aba ld c, $4 call DelayFrames call Func_3cd3a @@ -1821,8 +1807,7 @@ Func_3ccfa: ; 3ccfa (f:4cfa) ld [wcd6c], a xor a ld [H_DOWNARROWBLINKCNT1], a ; $ff8b - ld a, $5 - call Predef + predef Func_79aba call Delay3 call Func_3cd3a ld a, $4c @@ -1889,8 +1874,7 @@ Func_3cd60: ; 3cd60 (f:4d60) ld [wcf91], a FuncCoord 10, 9 ld hl, Coord - ld a, $5f - call Predef + predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ld hl, wcf1d @@ -2384,10 +2368,8 @@ Func_3d119: ; 3d119 (f:5119) ld [wcc49], a ld hl, wPartyMon1Species ; wPartyMon1Species (aliases: wPartyMon1) call ClearSprites - ld a, $36 - call Predef - ld a, $37 - call Predef + predef StatusScreen + predef StatusScreen2 ld a, [W_ENEMYBATTSTATUS2] ; W_ENEMYBATTSTATUS2 bit 4, a ld hl, AnimationSubstitute @@ -2440,12 +2422,10 @@ Func_3d1ba: ; 3d1ba (f:51ba) ld b, $1 push bc ld hl, wPartyAliveFlags - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef pop bc ld hl, wccf5 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef call Func_3cba6 call Func_3cc91 call SaveScreenTilesToBuffer1 @@ -2922,8 +2902,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) call GetCurrentMove FuncCoord 2, 10 ld hl, Coord - ld a, $5d - call Predef + predef Func_27d98 .asm_3d54e ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -3872,8 +3851,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2) ld hl, KeptGoingAndCrashedText ; $5c47 call PrintText ld b, $4 - ld a, $24 - call Predef + predef Func_48125 ld a, [H_WHOSETURN] ; $fff3 and a jr nz, .asm_3dc3f @@ -4799,8 +4777,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld hl,Coord xor a ld [wListMenuID],a - ld a,$48 - call Predef ; animate the HP bar shortening + predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d) jp Func_3cd5a ; redraw pokemon names and HP bars @@ -4919,8 +4896,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld hl,Coord ld a,$01 ld [wListMenuID],a - ld a,$48 - call Predef ; animate the HP bar shortening + predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToPlayerPokemonDone jp Func_3cd5a ; redraw pokemon names and HP bars @@ -6147,13 +6123,11 @@ Func_3eb01: ; 3eb01 (f:6b01) dec de xor a ld [wHPBarMaxHP], a - ld a, $3e - call Predef + predef WriteMonMoves .asm_3ebca ld hl, wEnemyMonMoves ld de, wEnemyMonSpecial + 1 - ld a, $5e - call Predef + predef LoadMovePPs ld hl, W_MONHBASESTATS ld de, wd002 ld b, $5 @@ -6178,15 +6152,13 @@ Func_3eb01: ; 3eb01 (f:6b01) call CopyData ld a, [wEnemyMonSpecies2] ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld c, a ld b, $1 ld hl, wPokedexSeen ; wd30a - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld hl, wEnemyMonLevel ; wEnemyMonLevel ld de, wcd23 ld bc, $b @@ -6212,8 +6184,7 @@ Func_3ec32: ; 3ec32 (f:6c32) call ClearScreen .asm_3ec4d call DelayFrame - ld a, $30 - call Predef + predef BattleTransition callab Func_3ee58 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -6255,8 +6226,7 @@ Func_3ec92: ; 3ec92 (f:6c92) .asm_3ec9e ld a, BANK(RedPicBack) call UncompressSpriteFromDE - ld a, $3 - call Predef + predef ScaleSpriteByTwo ld hl, wOAMBuffer xor a ld [H_DOWNARROWBLINKCNT1], a ; $ff8b @@ -6306,8 +6276,7 @@ Func_3ec92: ; 3ec92 (f:6c92) ld [$ffe1], a FuncCoord 1, 5 ld hl, Coord - ld a, $1 - jp Predef + predef_jump Func_3f0c6 Func_3ed02: ; 3ed02 (f:6d02) callab Func_39680 @@ -6709,8 +6678,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld [wAICount], a ; wccdf FuncCoord 12, 0 ld hl, Coord - ld a, $1 - call Predef + predef Func_3f0c6 ld a, $ff ld [wEnemyMonPartyPos], a ld a, $2 @@ -6765,8 +6733,7 @@ InitWildBattle: ; 3ef8b (f:6f8b) ld [$ffe1], a FuncCoord 12, 0 ld hl, Coord - ld a, $1 - call Predef + predef Func_3f0c6 Func_3efeb: ; 3efeb (f:6feb) ld b, $0 @@ -6855,8 +6822,7 @@ Func_3f073: ; 3f073 (f:7073) ld a, $1 ld [wcd6c], a ld bc, $303 - ld a, $5 - call Predef + predef Func_79aba ld c, $4 call DelayFrames ld bc, $ffd7 @@ -6864,8 +6830,7 @@ Func_3f073: ; 3f073 (f:7073) xor a ld [wcd6c], a ld bc, $505 - ld a, $5 - call Predef + predef Func_79aba ld c, $5 call DelayFrames ld bc, $ffd7 @@ -6942,8 +6907,7 @@ LoadMonBackPic: call ClearScreenArea ld hl, W_MONHBACKSPRITE - W_MONHEADER call UncompressMonSprite - ld a, $3 - call Predef + predef ScaleSpriteByTwo ld de, vBackPic call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite ld hl, vSprites @@ -8546,8 +8510,7 @@ Func_3fbbc: ; 3fbbc (f:7bbc) push hl push de push bc - ld a, $8 - call Predef + predef MoveAnimation pop bc pop de pop hl diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 0cea797d..3e9f3685 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -855,8 +855,7 @@ ReadTrainer: ; 39c53 (e:5c53) ld hl,wd047 ld c,2 push bc - ld a,$B - call Predef + predef AddBCDPredef pop bc inc de inc de @@ -1178,8 +1177,7 @@ Func_3a718: ; 3a718 (e:6718) ld hl,Coord xor a ld [wListMenuID],a - ld a,$48 - call Predef + predef UpdateHPBar2 jp DecrementAICount Func_3a72a: ; 3a72a (e:672a) diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index f35b4e3a..f6d65301 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -94,8 +94,7 @@ HealEffect_: ; 3b9ec (e:79ec) xor a .asm_3ba83 ld [wListMenuID], a ; wListMenuID - ld a, $48 - call Predef + predef UpdateHPBar2 ld hl, Func_3cd5a ; $4d5a call BankswitchEtoF ld hl, RegainedHealthText ; $7aac diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 1762d2be..75d8bd00 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -273,10 +273,8 @@ Func_5345: ; 5345 call Delay3 ld hl, W_OPTIONS ; W_OPTIONS res 7, [hl] - ld a, $2c - call Predef - ld a, $7 - call Predef + predef InitOpponent + predef HealParty jp Func_577d .asm_5506 ld c, BANK(Music_GameCorner) @@ -610,10 +608,8 @@ Func_57c7: Func_57d6: ld a, [wCurrentMenuItem] ld [wWhichPokemon], a - ld a, $36 - call Predef - ld a, $37 - call Predef + predef StatusScreen + predef StatusScreen2 call GBPalNormal call LoadTrainerInfoTextBoxTiles call Func_57f2 @@ -827,12 +823,10 @@ TradeCenter_Trade: ld a, [$ffaa] cp $1 jr z, .asm_59d9 ; 0x59d0 $7 - ld a, $38 - call Predef + predef Func_410e2 jr .asm_59de ; 0x59d7 $5 .asm_59d9 - ld a, $2f - call Predef + predef Func_410f3 .asm_59de callab Func_3ad0e call ClearScreen @@ -847,8 +841,7 @@ TradeCenter_Trade: ld hl, wTileMap + $119 ld de, TradeCompleted call PlaceString - ld a, $50 - call Predef + predef SaveSAVtoSRAM2 ld c, $32 call DelayFrames xor a @@ -885,8 +878,7 @@ Func_5a5f: ; 5a5f (1:5a5f) jr z, .asm_5a75 cp $5 ret nz - ld a, $4d - call Predef + predef Func_5aaf jp Init .asm_5a75 call Func_5317 diff --git a/engine/evos_moves.asm b/engine/evos_moves.asm index 9cd2612b..fd93fa14 100755 --- a/engine/evos_moves.asm +++ b/engine/evos_moves.asm @@ -152,8 +152,7 @@ Func_3ad71: ; 3ad71 (e:6d71) push af ld a, [wd0b5] ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld hl, BaseStats @@ -205,13 +204,11 @@ Func_3ad71: ; 3ad71 (e:6d71) ld [wcc49], a call Func_3af5b pop hl - ld a, $42 - call Predef + predef SetPartyMonTypes ld a, [W_ISINBATTLE] ; W_ISINBATTLE and a call z, Func_3af52 - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld c, a @@ -361,8 +358,7 @@ Func_3af5b: ; 3af5b (e:6f5b) ld [wd11e], a call GetMoveName call CopyStringToCF4B - ld a, $1b - call Predef + predef LearnMove .asm_3afb1 ld a, [wcf91] ld [wd11e], a @@ -489,7 +485,6 @@ WriteMonMoves_ShiftMoveData: ; 3b04e (e:704e) ret Func_3b057: ; 3b057 (e:7057) - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef INCLUDE "data/evos_moves.asm" diff --git a/engine/game_corner_slots2.asm b/engine/game_corner_slots2.asm index 0eff01b9..66e51237 100755 --- a/engine/game_corner_slots2.asm +++ b/engine/game_corner_slots2.asm @@ -3,8 +3,7 @@ AbleToPlaySlotsCheck ; 2ff09 (b:7f09) and $8 jr z, .done ; not able ld b, COIN_CASE - ld a, $1c - call Predef ; IsItemInBag_ + predef IsItemInBag_ ; IsItemInBag_ ld a, b and a ld b, $33 ; GameCornerCoinCaseText diff --git a/engine/give_pokemon.asm b/engine/give_pokemon.asm index 21b56bf3..9399fb05 100755 --- a/engine/give_pokemon.asm +++ b/engine/give_pokemon.asm @@ -52,15 +52,13 @@ SetPokedexOwnedFlag: ; 4fe11 (13:7e11) ld a, [wcf91] push af ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld c, a ld hl, wPokedexOwned ; wPokedexOwned ld b, $1 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef pop af ld [wd11e], a call GetMonName diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index de0ff19a..caadce13 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -117,8 +117,7 @@ Func_70278: ; 70278 (1c:4278) ld hl, Coord call GetMonHeader call LoadFrontSpriteByMonIndex - ld a, $4 - call Predef + predef LoadMonBackPic .asm_702ab ld b, $b ld c, $0 @@ -179,8 +178,7 @@ Func_702f0: ; 702f0 (1c:42f0) ld [wd0b5], a FuncCoord 3, 9 ld hl, Coord - ld a, $4b - call Predef + predef Func_27d6b ld a, [wWhichTrade] ; wWhichTrade jp PlayCry @@ -202,8 +200,7 @@ Func_7033e: ; 7033e (1c:433e) ld de, RedPicBack ; $7e0a ld a, BANK(RedPicBack) call UncompressSpriteFromDE - ld a, $3 - call Predef + predef ScaleSpriteByTwo ld de, vBackPic call InterlaceMergeSpriteBuffers ld c, $1 @@ -212,14 +209,12 @@ Func_7036d: ; 7036d (1c:436d) ld b, $0 FuncCoord 12, 5 ld hl, Coord - ld a, $31 - jp Predef + predef_jump Func_79dda Func_70377: ; 70377 (1c:4377) ld hl, wd747 set 3, [hl] - ld a, $56 - call Predef + predef DisplayDexRating FuncCoord 0, 4 ld hl, Coord ld b, $6 diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index 8c0b6a0a..d2408a5b 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -79,8 +79,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) ld [$ffe1], a FuncCoord 10, 11 ld hl, Coord - ld a, $2 - call Predef + predef Func_3f073 call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 call Delay3 diff --git a/engine/hidden_object_functions7.asm b/engine/hidden_object_functions7.asm index 4d1e0339..848f6f3d 100755 --- a/engine/hidden_object_functions7.asm +++ b/engine/hidden_object_functions7.asm @@ -194,8 +194,7 @@ CinnabarQuizQuestionsText6: ; 1ea85 (7:6a85) CinnabarGymQuiz_1ea8a: ; 1ea8a (7:6a8a) ld hl, wd79c - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92) call YesNoChoice @@ -227,8 +226,7 @@ CinnabarGymQuiz_1ea92: ; 1ea92 (7:6a92) ld c, a ld b, $2 ld hl, wd79a - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld a, c and a ret nz @@ -293,8 +291,7 @@ CinnabarGymQuiz_1eb0a: ; 1eb0a (7:6b0a) .asm_1eb38 pop bc ld [wd09f], a - ld a, $17 - call Predef + predef Func_ee9e ld hl, $ffdb dec [hl] jr nz, .asm_1eb0e diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index e1b6f757..7f0b21c1 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -39,8 +39,7 @@ Predef54: ; 71ad9 (1c:5ad9) ld a,[wWhichTrade] ld c,a ld b,$2 - ld a,$10 - call Predef + predef FlagActionPredef ld a,c and a ld a,$4 @@ -112,8 +111,7 @@ Func_71c07: ; 71c07 (1c:5c07) ld a,[wWhichTrade] ld c,a ld b,$1 - ld a,$10 - call Predef + predef FlagActionPredef ld hl, ConnectCableText call PrintText ld a,[wWhichPokemon] @@ -122,8 +120,7 @@ Func_71c07: ; 71c07 (1c:5c07) push af call LoadHpBarAndStatusTilePatterns call Func_71cc1 - ld a,$38 - call Predef + predef Func_410e2 pop af ld [W_CURENEMYLVL],a pop af diff --git a/engine/intro.asm b/engine/intro.asm index c3449c0b..2b8c2dbf 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -264,12 +264,10 @@ Func_4183f: ; 4183f (10:583f) Func_41842: ; 41842 (10:5842) ld c, $0 - ld a, $31 - jp Predef + predef_jump Func_79dda Func_41849: ; 41849 (10:5849) - ld a, $33 - call Predef + predef Func_79869 ld a, b jp PlaySound diff --git a/engine/items/itemfinder.asm b/engine/items/itemfinder.asm index 87acf48c..d7e5b3ce 100755 --- a/engine/items/itemfinder.asm +++ b/engine/items/itemfinder.asm @@ -11,8 +11,7 @@ HiddenItemNear: ; 7481f (1d:481f) ld hl, wd6f0 ld c, b ld b, $2 - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld a, c pop hl pop bc diff --git a/engine/items/items.asm b/engine/items/items.asm index 6b1bf8b3..fbb2ec8f 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -326,8 +326,7 @@ ItemUseBall: ; d687 (3:5687) push af ld a,[wcf91] push af - ld a,$08 ;probably animations - call Predef + predef MoveAnimation pop af ld [wcf91],a pop af @@ -397,23 +396,20 @@ ItemUseBall: ; d687 (3:5687) jr z,.printText1 ld hl,ItemUseBallText05 call PrintText - ld a,$3a ;convert order: Internal->Dex - call Predef + predef IndexToPokedex ld a,[wd11e] dec a ld c,a ld b,2 ld hl,wPokedexOwned ;Dex_own_flags (pokemon) - ld a,$10 - call Predef ;check Dex flag (own already or not) + predef FlagActionPredef ld a,c push af ld a,[wd11e] dec a ld c,a ld b,1 - ld a,$10 ;set Dex_own_flag? - call Predef + predef FlagActionPredef pop af and a jr nz,.checkParty @@ -422,8 +418,7 @@ ItemUseBall: ; d687 (3:5687) call ClearSprites ld a,[wEnemyMonSpecies] ;caught mon_ID ld [wd11e],a - ld a,$3d - call Predef + predef ShowPokedexData .checkParty ;$58f4 ld a,[wPartyCount] cp a,6 ;is party full? @@ -627,8 +622,7 @@ SurfingNoPlaceToGetOffText: ; da51 (3:5a51) db "@" ItemUsePokedex: ; da56 (3:5a56) - ld a,$29 - jp Predef + predef_jump ShowPokedexMenu ItemUseEvoStone: ; da5b (3:5a5b) ld a,[W_ISINBATTLE] @@ -783,8 +777,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld de,wBattleMonMaxHP ld bc,10 call CopyData ; copy party stats to in-battle stat data - ld a,$28 - call Predef + predef Func_3ed02 jp .doneHealing .healHP inc hl ; hl = address of current HP @@ -814,8 +807,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld c,a ld hl,wccf5 ld b,$02 - ld a,$10 - call Predef + predef FlagActionPredef ld a,c and a jr z,.next @@ -823,8 +815,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld c,a ld hl,wPartyAliveFlags ld b,$01 - ld a,$10 - call Predef + predef FlagActionPredef .next pop bc pop de @@ -934,8 +925,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [$fff6],a ld a,$02 ld [wListMenuID],a - ld a,$48 - call Predef ; animate HP bar decrease of pokemon that used Softboiled + predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled ld a,[$fff6] res 0,a ld [$fff6],a @@ -1085,8 +1075,7 @@ ItemUseMedicine: ; dabb (3:5abb) ld [$fff6],a ld a,$02 ld [wListMenuID],a - ld a,$48 - call Predef ; animate the HP bar lengthening + predef UpdateHPBar2 ; animate the HP bar lengthening ld a,[$fff6] res 0,a ld [$fff6],a @@ -1285,8 +1274,7 @@ ItemUseMedicine: ; dabb (3:5abb) call WaitForTextScrollButtonPress ; wait for button press xor a ld [wcc49],a - ld a,$1a - call Predef ; learn level up move, if any + predef Func_3af5b ; learn level up move, if any xor a ld [wccd4],a callab Func_3ad0e ; evolve pokemon, if appropriate @@ -1356,8 +1344,7 @@ BaitRockCommon: ; df7f (3:5f7f) ld a,$ff .noCarry ld [hl],a - ld a,$08 - call Predef ; do animation + predef MoveAnimation ; do animation ld c,70 jp DelayFrames @@ -2096,8 +2083,7 @@ ItemUseTMHM: ; e479 (3:6479) .skipAdding inc a ld [wd11e],a - ld a,$44 - call Predef ; get move ID from TM/HM ID + predef TMToMove ; get move ID from TM/HM ID ld a,[wd11e] ld [wd0e0],a call GetMoveName @@ -2152,8 +2138,7 @@ ItemUseTMHM: ; e479 (3:6479) call GoPAL_SET_CF1C jp LoadScreenTilesFromBuffer1 ; restore saved screen .checkIfAbleToLearnMove - ld a,$43 - call Predef ; check if the pokemon can learn the move + predef CanLearnTM ; check if the pokemon can learn the move push bc ld a,[wWhichPokemon] ld hl,wPartyMonNicks @@ -2171,8 +2156,7 @@ ItemUseTMHM: ; e479 (3:6479) .checkIfAlreadyLearnedMove callab CheckIfMoveIsKnown ; check if the pokemon already knows the move jr c,.chooseMon - ld a,$1b - call Predef ; teach move + predef LearnMove ; teach move pop af ld [wcf91],a pop af @@ -2232,8 +2216,7 @@ ThrowBallAtTrainerMon: ; e58b (3:658b) call Delay3 ld a,TOSS_ANIM ld [W_ANIMATIONID],a - ld a,$08 - call Predef ; do animation + predef MoveAnimation ; do animation ld hl,ThrowBallAtTrainerMonText1 call PrintText ld hl,ThrowBallAtTrainerMonText2 @@ -2321,8 +2304,7 @@ RestoreBonusPP: ; e606 (3:6606) call AddNTimes push hl ld de,wcd78 - 1 - ld a,$5e - call Predef ; loads the normal max PP of each of the pokemon's moves to wcd78 + predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wcd78 pop hl ld c,21 ld b,0 @@ -2574,8 +2556,7 @@ IsKeyItem_: ; e764 (3:6764) ld c,a ld hl,wHPBarMaxHP ld b,$02 ; test bit - ld a,$10 - call Predef ; bitfield operation function + predef FlagActionPredef ; bitfield operation function ld a,c and a ret nz @@ -2674,8 +2655,7 @@ Func_e7a4: ; e7a4 (3:67a4) ld hl, wBoxMonNicks ld a, $2 ld [wd07d], a - ld a, $4e - call Predef + predef AskName ld a, [W_NUMINBOX] ; wda80 dec a jr z, .asm_e867 diff --git a/engine/items/tms.asm b/engine/items/tms.asm index 7a13250b..ef427860 100755 --- a/engine/items/tms.asm +++ b/engine/items/tms.asm @@ -18,8 +18,7 @@ CanLearnTM: ; 1373e (4:773e) .TMfoundLoop pop hl ld b, $2 ; read corresponding bit from TM compatibility array - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef ; converts TM/HM number in wd11e into move number ; HMs start at 51 diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 3c813861..2640bada 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -466,10 +466,8 @@ Func_2174b: ; 2174b (8:574b) ld a, $2 .asm_217b0 ld [wcc49], a - ld a, $36 - call Predef - ld a, $37 - call Predef + predef StatusScreen + predef StatusScreen2 call LoadScreenTilesFromBuffer1 call ReloadTilesetTilePatterns call GoPAL_SET_CF1C diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index e31e31aa..3bf185fd 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -14,8 +14,7 @@ DisplayDiploma: ; 566e2 (15:66e2) call FarCopyData2 ld hl, wTileMap ld bc, $1012 - ld a, $27 - call Predef + predef Func_5ab0 ld hl, DiplomaTextPointersAndCoords ; $6784 ld c, $5 .asm_56715 diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 5f2c1cd5..06c85096 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -9,8 +9,7 @@ MainMenu: ; 5af2 (1:5af2) jr nc,.next0 ; Predef 52 loads the save from SRAM to RAM - ld a,$52 - call Predef + predef LoadSAV .next0 ld c,20 diff --git a/engine/menu/oaks_pc.asm b/engine/menu/oaks_pc.asm index 1d591d1d..6e7edda2 100755 --- a/engine/menu/oaks_pc.asm +++ b/engine/menu/oaks_pc.asm @@ -8,8 +8,7 @@ OpenOaksPC: ; 1e915 (7:6915) ld a, [wCurrentMenuItem] ; wCurrentMenuItem and a jr nz, .asm_1e932 - ld a, $56 - call Predef + predef DisplayDexRating .asm_1e932 ld hl, ClosedOaksPCText call PrintText diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index 8ad5260d..d0a74c11 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -93,8 +93,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) set 0,a ld [$FFF6],a add hl,bc - ld a,$60 - call Predef ; draw HP bar and prints current / max HP + predef Func_128f6 ; draw HP bar and prints current / max HP ld a,[$FFF6] res 0,a ld [$FFF6],a @@ -103,8 +102,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) jr .printLevel .teachMoveMenu push hl - ld a,$43 - call Predef ; check if the pokemon can learn the move + predef CanLearnTM ; check if the pokemon can learn the move pop hl ld de,.ableToLearnMoveText ld a,c diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 2336cb47..4d3f5aaa 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -145,8 +145,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d) call PlaySound ; play sound jr .handleMenuInput .choseArea - ld a,$4a - call Predef ; display pokemon areas + predef LoadTownMap_Nest ; display pokemon areas ld b,0 jr .exitSideMenu @@ -392,8 +391,7 @@ IsPokemonBitSet: ; 402c2 (10:42c2) dec a ld c,a ld b,2 - ld a,$10 - call Predef + predef FlagActionPredef ld a,c and a ret diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index 7ceabbed..63bdedee 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -257,8 +257,7 @@ HandlePrizeChoice: ; 528c6 (14:68c6) ld hl,$FFA1 ld de,wPlayerCoins + 1 ld c,$02 ; how many bytes - ld a,$0C - call Predef ; subtract coins (BCD daa operations) + predef SubBCDPredef ; subtract coins (BCD daa operations) jp PrintPrizePrice .BagFull ld hl,PrizeRoomBagIsFullTextPtr diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 6a21a50e..bb23321b 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -1,6 +1,5 @@ StartMenu_Pokedex: ; 13095 (4:7095) - ld a,$29 - call Predef + predef ShowPokedexMenu call LoadScreenTilesFromBuffer2 ; restore saved screen call Delay3 call LoadGBPal @@ -98,10 +97,8 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) call ClearSprites xor a ld [wcc49],a - ld a,$36 - call Predef - ld a,$37 - call Predef + predef StatusScreen + predef StatusScreen2 call ReloadMapData jp StartMenu_Pokemon .choseOutOfBattleMove @@ -155,8 +152,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) .cut bit 1,a ; does the player have the Cascade Badge? jp z,.newBadgeRequired - ld a,$3c - call Predef + predef UsedCut ld a,[wcd6a] and a jp z,.loop @@ -181,8 +177,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) .strength bit 3,a ; does the player have the Rainbow Badge? jp z,.newBadgeRequired - ld a,$5b - call Predef + predef PrintStrengthTxt call GBPalWhiteOutWithDelay3 jp .goBackToMap .flash @@ -515,8 +510,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) xor a ld [$ffd7],a call DrawTrainerInfo - ld a,$2e - call Predef ; draw badges + predef DrawBadges ; draw badges ld b,$0d call GoPAL_SET call GBPalNormal @@ -535,8 +529,7 @@ StartMenu_TrainerInfo: ; 13460 (4:7460) DrawTrainerInfo: ; 1349a (4:749a) ld de,RedPicFront ld bc,(BANK(RedPicFront) << 8) | $01 - ld a,$3b - call Predef + predef Predef3B call DisableLCD FuncCoord 0,2 ld hl,Coord @@ -711,8 +704,7 @@ StartMenu_SaveReset: ; 135e3 (4:75e3) ld a,[wd72e] bit 6,a ; is the player using the link feature? jp nz,Init - ld a,$3f - call Predef ; save the game + predef SaveSAV ; save the game call LoadScreenTilesFromBuffer2 ; restore saved screen jp HoldTextDisplayOpen diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 3bacd306..3b830244 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -84,8 +84,7 @@ StatusScreen: ; 12953 (4:6953) ld a, [W_MONHDEXNUM] ld [wd11e], a ld [wd0b5], a - ld a, $3a - call Predef + predef IndexToPokedex FuncCoord 3,7 ld hl, Coord ld de, wd11e @@ -93,8 +92,7 @@ StatusScreen: ; 12953 (4:6953) call PrintNumber ; Pokémon no. FuncCoord 11,10 ld hl, Coord - ld a, $4b - call Predef ; Prints the type (?) + predef Func_27d6b ; Prints the type (?) ld hl, NamePointers2 ; $6a9d call .unk_12a7e ld d, h diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm index 19550899..73dece40 100755 --- a/engine/menu/vending_machine.asm +++ b/engine/menu/vending_machine.asm @@ -71,8 +71,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld hl, $ffde ld de, wPlayerMoney + 2 ; wd349 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef ld a, $13 ld [wd125], a jp DisplayTextBoxID diff --git a/engine/mon_party_sprites.asm b/engine/mon_party_sprites.asm index c27c65b5..e05bdd55 100755 --- a/engine/mon_party_sprites.asm +++ b/engine/mon_party_sprites.asm @@ -377,8 +377,7 @@ Func_718c3: ; 718c3 (1c:58c3) GetPartyMonSpriteID: ; 718e9 (1c:58e9) ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] ld c, a dec a diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index c7f2abf7..314c34df 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -41,8 +41,7 @@ OakSpeech: ; 6115 (1:6115) call ClearScreen call LoadTextBoxTilePatterns call SetDefaultNames - ld a,$18 - call Predef + predef InitPlayerData2 ld hl,wNumBoxItems ld a,POTION ld [wcf91],a @@ -234,5 +233,4 @@ IntroPredef3B: ; 62a4 (1:62a4) .next xor a ld [$FFE1],a - ld a,1 - jp Predef + predef_jump Func_3f0c6 diff --git a/engine/overworld/card_key.asm b/engine/overworld/card_key.asm index 991512bb..f48c26f4 100755 --- a/engine/overworld/card_key.asm +++ b/engine/overworld/card_key.asm @@ -8,8 +8,7 @@ PrintCardKeyText: ; 52673 (14:6673) ret z cp b jr nz, .asm_5267a - ld a, $35 - call Predef + predef Func_c586 ld a, [wcfc6] cp $18 jr z, .asm_5269c @@ -49,8 +48,7 @@ PrintCardKeyText: ; 52673 (14:6673) ld a, $e .asm_526ca ld [wd09f], a - ld a, $17 - call Predef + predef Func_ee9e ld hl, wd126 set 5, [hl] ld a, (SFX_1f_57 - SFX_Headers_1f) / 3 diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm index 21ccdaad..77bd8fe6 100755 --- a/engine/overworld/hidden_items.asm +++ b/engine/overworld/hidden_items.asm @@ -6,8 +6,7 @@ HiddenItems: ; 76688 (1d:6688) ld a, [wTrainerScreenX] ld c, a ld b, $2 - ld a, $10 - call Predef + predef FlagActionPredef ld a, c and a ret nz @@ -35,8 +34,7 @@ FoundHiddenItemText: ; 7675b (1d:675b) ld a, [wTrainerScreenX] ld c, a ld b, $1 - ld a, $10 - call Predef + predef FlagActionPredef ld a, (SFX_02_3b - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ; play sound call WaitForSoundToFinish ; wait for sound to finish playing @@ -55,8 +53,7 @@ HiddenItemBagFullText: ; 76794 (1d:6794) HiddenCoins: ; 76799 (1d:6799) ld b, COIN_CASE - ld a, $1c - call Predef + predef IsItemInBag_ ld a, b and a ret z @@ -67,8 +64,7 @@ HiddenCoins: ; 76799 (1d:6799) ld a, [wTrainerScreenX] ld c, a ld b, $2 - ld a, $10 - call Predef + predef FlagActionPredef ld a, c and a ret nz @@ -104,14 +100,12 @@ HiddenCoins: ; 76799 (1d:6799) ld de, wPlayerCoins + 1 ld hl, $ffa1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, wd6fe ld a, [wTrainerScreenX] ld c, a ld b, $1 - ld a, $10 - call Predef + predef FlagActionPredef call EnableAutoTextBoxDrawing ld a, [wPlayerCoins] cp $99 diff --git a/engine/overworld/item.asm b/engine/overworld/item.asm index a75c393c..a69ec106 100644 --- a/engine/overworld/item.asm +++ b/engine/overworld/item.asm @@ -32,8 +32,7 @@ PickupItem: ld a, [$ffdb] ld [wcc4d], a - ld a, $11 ; HideObject - call Predef + predef HideObject ld a, 1 ld [wcc3c], a ld hl, FoundItemText diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index c1db3d43..b64a1174 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -5,8 +5,7 @@ HandleLedges: ; 1a672 (6:6672) ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET and a ; OVERWORLD ret nz - ld a, $35 - call Predef + predef Func_c586 ld a, [wSpriteStateData1 + 9] ld b, a FuncCoord 8, 9 diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index 374b8ea6..f8dd5fc4 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -458,8 +458,7 @@ InitializeSpriteScreenPosition: ; 50bd (1:50bd) ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: ; 50dc (1:50dc) - ld a, $12 - call Predef + predef IsObjectHidden ld a, [$ffe5] and a jp nz, .spriteInvisible diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index d228df76..2cf6fea9 100755 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -86,8 +86,7 @@ Func_1a485: ; 1a485 (6:6485) ld a, [wcca1] ld [wcd38], a ld [$ff95], a - ld a, $23 - call Predef + predef Func_f9a0 call Func_3486 ld a, $2 ld [wcf10], a @@ -145,8 +144,7 @@ Func_1a4f4: ; 1a4f4 (6:64f4) ret nz ld a, $0 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd730 res 7, [hl] ld hl, wd72e @@ -175,8 +173,7 @@ Func_1a514: ; 1a514 (6:6514) ld [wcd38], a xor a ld [wd12f], a - ld a, $4f - call Predef + predef PewterGuys ld hl, wcc97 ld de, RLEList_PewterMuseumGuy call DecodeRLEList @@ -233,8 +230,7 @@ Func_1a581: ; 1a581 (6:6581) ld [wcd38], a ld a, $1 ld [wd12f], a - ld a, $4f - call Predef + predef PewterGuys ld hl, wcc97 ld de, RLEList_PewterGymGuy call DecodeRLEList diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index 184d38f4..ee4c999d 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -421,8 +421,7 @@ Func_707b6: ; 707b6 (1c:47b6) xor a ld [hli], a ld [hl], a - ld a, $4c - call Predef + predef EmotionBubble ld a, [wSpriteStateData1 + 2] cp $4 jr nz, .asm_70833 diff --git a/engine/palettes.asm b/engine/palettes.asm index 5835f483..eafd8ef6 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -268,8 +268,7 @@ DeterminePaletteIDOutOfBattle: ; 71f9d (1c:5f9d) and a jr z, .idZero push bc - ld a, $3A - call Predef ; turn Pokemon ID number into Pokedex number + predef IndexToPokedex ; turn Pokemon ID number into Pokedex number pop bc ld a, [wd11e] .idZero diff --git a/engine/predefs.asm b/engine/predefs.asm index 53022bc4..3ac99585 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -49,7 +49,7 @@ GetPredefPointer: ret -PredefPointers: ; 4fe79 (13:7e79) +PredefPointers:: ; 4fe79 (13:7e79) ; these are pointers to ASM routines. ; they appear to be used in overworld map scripts. add_predef Func_3cd60 diff --git a/engine/predefs17.asm b/engine/predefs17.asm index 11e67aff..74977ee8 100755 --- a/engine/predefs17.asm +++ b/engine/predefs17.asm @@ -3,8 +3,7 @@ StarterDex: ; 5c0dc (17:40dc) ld a, %01001011 ; set starter flags ld [wPokedexOwned], a ; wPokedexOwned - ld a, $3d - call Predef + predef ShowPokedexData xor a ; unset starter flags ld [wPokedexOwned], a ; wPokedexOwned ret diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm index 0e17d13f..e43cc9ab 100755 --- a/engine/slot_machine.asm +++ b/engine/slot_machine.asm @@ -17,8 +17,7 @@ PromptUserToPlaySlots: ; 3730e (d:730e) xor a ld [hli], a ld [hl], $2 - ld a, $4c - call Predef + predef EmotionBubble call GBPalWhiteOutWithDelay3 call LoadSlotMachineTiles call LoadFontTilePatterns @@ -618,8 +617,7 @@ SlotMachine_37741: ; 37741 (d:7741) ld [hli], a ld de, wPlayerCoins + 1 ld c, $2 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef SlotMachine_37754: ; 37754 (d:7754) ld hl, wTileMap + $19 @@ -660,8 +658,7 @@ SlotMachine_3776b: ; 3776b (d:776b) ld hl, wcd47 ld de, wPlayerCoins + 1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef call SlotMachine_37754 call SlotMachine_3775f ld a, (SFX_1f_65 - SFX_Headers_1f) / 3 diff --git a/engine/trade.asm b/engine/trade.asm index 977656b5..3da1760f 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -766,5 +766,4 @@ Func_41676: ; 41676 (10:5676) ld [W_ANIMATIONID], a ; W_ANIMATIONID xor a ld [wcc5b], a - ld a, $8 - jp Predef + predef_jump MoveAnimation diff --git a/engine/trade2.asm b/engine/trade2.asm index 40b86747..496ce24b 100755 --- a/engine/trade2.asm +++ b/engine/trade2.asm @@ -5,8 +5,7 @@ Func_42769: ; 42769 (10:6769) call PlaceString ld a,[wWhichTrade] ld [wd11e],a - ld a,$3A - call Predef + predef IndexToPokedex FuncCoord 9, 0 ld hl,Coord ld de,wd11e @@ -33,8 +32,7 @@ Func_427a7: ; 427a7 (10:67a7) call PlaceString ld a,[wTrainerEngageDistance] ld [wd11e],a - ld a,$3A - call Predef + predef IndexToPokedex FuncCoord 9, 10 ld hl,Coord ld de,wd11e diff --git a/home.asm b/home.asm index 5062b18c..e9dc60c3 100644 --- a/home.asm +++ b/home.asm @@ -275,8 +275,7 @@ LoadFrontSpriteByMonIndex:: ; 1389 (0:1389) push af ld a, [wcf91] ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld hl, wd11e ld a, [hl] pop bc @@ -576,8 +575,7 @@ GetMonHeader:: ; 1537 (0:1537) jr z,.specialID cp a,MEW jr z,.mew - ld a,$3a - call Predef ; convert pokemon ID in [wd11e] to pokedex number + predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number ld a,[wd11e] dec a ld bc,28 @@ -1509,8 +1507,7 @@ PokeCenterSignText:: ; 24ef (0:24ef) Predef5CText:: ; 24f4 (0:24f4) ; XXX better label (what does predef $5C do?) db $08 ; asm - ld a, $5c - call Predef + predef PickupItem jp TextScriptEnd @@ -1862,8 +1859,7 @@ AddAmountSoldToMoney:: ; 2b9e (0:2b9e) ld de,wPlayerMoney + 2 ld hl,$ffa1 ; total price of items ld c,3 ; length of money in bytes - ld a,$0b - call Predef ; add total price to money + predef AddBCDPredef ; add total price to money ld a,$13 ld [wd125],a call DisplayTextBoxID ; redraw money text box @@ -2182,8 +2178,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld de,$ffa1 ld hl,$ff8d push bc - ld a,$0b - call Predef ; add the individual price to the current sum + predef AddBCDPredef ; add the individual price to the current sum pop bc dec b jr nz,.addLoop @@ -2195,8 +2190,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld [$ffa3],a ld a,$02 ld [$ffa4],a - ld a,$0d - call Predef ; halves the price + predef DivideBCDPredef3 ; halves the price ; store the halved price ld a,[$ffa2] ld [$ff9f],a @@ -2843,8 +2837,7 @@ ReadTrainerHeaderInfo:: ; 3193 (0:3193) ret TrainerFlagAction:: - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef ; direct talking to a trainer (rather than getting seen by one) TalkToTrainer:: ; 31cc (0:31cc) @@ -2900,8 +2893,7 @@ CheckFightingMapTrainers:: ; 3219 (0:3219) ld [wcd4f], a xor a ld [wcd50], a - ld a, $4c - call Predef + predef EmotionBubble ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a xor a @@ -2960,8 +2952,7 @@ EndTrainerBattle:: ; 3275 (0:3275) inc hl ld a, [hl] ld [wcc4d], a ; load corresponding missable object index and remove it - ld a, $11 - call Predef + predef HideObject .skipRemoveSprite ld hl, wd730 bit 4, [hl] @@ -3048,8 +3039,7 @@ CheckForEngagingTrainers:: ; 3306 (0:3306) ld a, [wcf13] swap a ld [wTrainerSpriteOffset], a ; wWhichTrade - ld a, $39 - call Predef + predef TrainerEngage pop de pop hl ld a, [wTrainerSpriteOffset] ; wWhichTrade @@ -3258,8 +3248,7 @@ IsItemInBag:: ; 3493 (0:3493) ; set zero flag if item isn't in player's bag ; else reset zero flag ; related to Pokémon Tower and ghosts - ld a,$1C - call Predef + predef IsItemInBag_ ld a,b and a ret @@ -4011,8 +4000,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) call HandleDownArrowBlinkTiming pop hl call JoypadLowSensitivity - ld a, $2d - call Predef + predef Func_5a5f ld a, [$ffb5] and A_BUTTON | B_BUTTON jr z, .asm_3872 @@ -5079,8 +5067,7 @@ GoPAL_SET:: ; 3def (0:3def) ld a,[wcf1b] and a ret z - ld a,$45 - jp Predef + predef_jump Func_71ddf GetHealthBarColor:: ; Return at hl the palette of diff --git a/home/overworld.asm b/home/overworld.asm index 941b50cb..872d63ee 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -98,8 +98,7 @@ OverworldLoopLessDelay:: and a jp z,OverworldLoop .displayDialogue - ld a,$35 - call Predef ; check what is in front of the player + predef Func_c586 ; check what is in front of the player call UpdateSprites ; move sprites ld a,[wFlags_0xcd60] bit 2,a @@ -117,8 +116,7 @@ OverworldLoopLessDelay:: ld a,$00 ld [wcc47],a jr z,.changeMap - ld a,$52 - call Predef + predef LoadSAV ld a,[W_CURMAP] ld [wd71a],a call Func_62ce @@ -301,8 +299,7 @@ OverworldLoopLessDelay:: ld a,[W_ISINBATTLE] and a jp nz,CheckWarpsNoCollision - ld a,$13 - call Predef ; decrement HP of poisoned pokemon + predef Func_c69c ; decrement HP of poisoned pokemon ld a,[wd12d] and a jp nz,HandleBlackOut ; if all pokemon fainted @@ -1070,8 +1067,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) and a jr z,.extendRangeOverCounter ; if there are signs - ld a,$35 - call Predef ; get the coordinates in front of the player in de + predef Func_c586 ; get the coordinates in front of the player in de ld hl,wd4b1 ; start of sign coordinates ld a,[wd4b0] ; number of signs in the map ld b,a @@ -1105,8 +1101,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) jr nz,.signLoop ; check if the player is front of a counter in a pokemon center, pokemart, etc. and if so, extend the range at which he can talk to the NPC .extendRangeOverCounter - ld a,$35 - call Predef ; get the tile in front of the player in c + predef Func_c586 ; get the tile in front of the player in c ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) ld b,$03 ld d,$20 ; talking range in pixels (long range) @@ -1246,8 +1241,7 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1) ; function that checks if the tile in front of the player is passable ; clears carry if it is, sets carry if not CheckTilePassable:: ; 0c10 (0:0c10) - ld a,$35 - call Predef ; get tile in front of player + predef Func_c586 ; get tile in front of player ld a,[wcfc6] ; tile in front of player ld c,a ld hl,W_TILESETCOLLISIONPTR ; pointer to list of passable tiles @@ -1271,8 +1265,7 @@ CheckTilePassable:: ; 0c10 (0:0c10) ; sets carry if there is a collision and unsets carry if not CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) push hl - ld a,$35 - call Predef ; get the tile in front of the player + predef Func_c586 ; get the tile in front of the player push de push bc callba HandleLedges ; check if the player is trying to jump a ledge @@ -1920,8 +1913,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7) ld hl,TilePairCollisionsWater call CheckForJumpingAndTilePairCollisions jr c,.collision - ld a,$35 - call Predef ; get tile in front of player (puts it in c and [wcfc6]) + predef Func_c586 ; get tile in front of player (puts it in c and [wcfc6]) ld a,[wcfc6] ; tile in front of player cp a,$14 ; water tile jr z,.noCollision ; keep surfing if it's a water tile @@ -2274,8 +2266,7 @@ LoadMapHeader:: ; 107c (0:107c) dec b jp nz,.loadSpriteLoop .finishUp - ld a,$19 - call Predef ; load tileset data + predef Func_c754 ; load tileset data callab LoadWildData ; load wild pokemon data pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks diff --git a/main.asm b/main.asm index 324f6a11..df42f937 100755 --- a/main.asm +++ b/main.asm @@ -49,8 +49,7 @@ Func_40b0:: ld [$ffa3], a ld a, 2 ld [$ffa4], a - ld a, $d ; DivideBCDPredef - call Predef + predef DivideBCDPredef3 ld a, [$ffa2] ld [wPlayerMoney], a ld a, [$ffa2 + 1] @@ -65,8 +64,7 @@ Func_40b0:: set 6, [hl] ld a, %11111111 ld [wJoyIgnore], a - ld a, $7 ; HealParty - jp Predef + predef_jump HealParty MewPicFront:: INCBIN "pic/bmon/mew.pic" @@ -520,8 +518,7 @@ INCLUDE "engine/oak_speech.asm" Func_62ce: ; 62ce (1:62ce) call Func_62ff - ld a,$19 - call Predef + predef Func_c754 ld hl,wd732 bit 2,[hl] res 2,[hl] @@ -714,8 +711,7 @@ SubtractAmountPaidFromMoney_: ; 6b21 (1:6b21) ld de,wPlayerMoney + 2 ld hl,$ffa1 ; total price of items ld c,3 ; length of money in bytes - ld a,$0c - call Predef ; subtract total price from money + predef SubBCDPredef ; subtract total price from money ld a,$13 ld [wd125],a call DisplayTextBoxID ; redraw money text box @@ -1927,22 +1923,19 @@ _RemovePokemon: ; 7b68 (1:7b68) Func_7c18: ; 7c18 (1:7c18) ld hl, wd730 set 6, [hl] - ld a, $3d - call Predef + predef ShowPokedexData ld hl, wd730 res 6, [hl] call ReloadMapData ld c, $a call DelayFrames - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld c, a ld b, $1 ld hl, wPokedexSeen - ld a, $10 - call Predef + predef FlagActionPredef ld a, $1 ld [wcc3c], a ret @@ -2531,13 +2524,11 @@ Func_c69c: ; c69c (3:469c) and a jr z, .asm_c733 ld b, $2 - ld a, $1f - call Predef + predef Func_480eb ld a, (SFX_02_43 - SFX_Headers_02) / 3 call PlaySound .asm_c733 - ld a, $14 - call Predef + predef AnyPartyAlive ld a, d and a jr nz, .asm_c74f @@ -3137,8 +3128,7 @@ Func_f113: ; f113 (3:7113) ld c, a ld b, $1 ld hl, W_TOWNVISITEDFLAG ; mark town as visited (for flying) - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef .notInTown ld hl, MapHSPointers ld a, [W_CURMAP] ; W_CURMAP @@ -3378,8 +3368,7 @@ Func_f225: ; f225 (3:7225) ld a, [hJoyHeld] and $f0 ret z - ld a, $5a - call Predef + predef Func_c60b ld a, [wd71c] and a jp nz, Func_f2dd @@ -3499,8 +3488,7 @@ _AddPartyMon: ; f2e5 (3:72e5) call SkipFixedLengthTextEntries ld a, $2 ld [wd07d], a - ld a, $4e - call Predef + predef AskName .asm_f33f ld hl, wPartyMons ld a, [wcc49] @@ -3532,8 +3520,7 @@ _AddPartyMon: ; f2e5 (3:72e5) ld a, [wcf91] ld [wd11e], a push de - ld a, $3a - call Predef + predef IndexToPokedex pop de ld a, [wd11e] dec a @@ -3635,8 +3622,7 @@ _AddPartyMon: ; f2e5 (3:72e5) dec de xor a ld [wHPBarMaxHP], a - ld a, $3e - call Predef + predef WriteMonMoves pop de ld a, [wPlayerID] ; set trainer ID to player ID inc de @@ -3770,8 +3756,7 @@ _AddEnemyMonToPlayerParty: ; f49d (3:749d) call CopyData ; write new mon's nickname (from an enemy mon) ld a, [wcf91] ld [wd11e], a - ld a, $3a - call Predef + predef IndexToPokedex ld a, [wd11e] dec a ld c, a diff --git a/scripts/agatha.asm b/scripts/agatha.asm index e80e7d32..b31fc412 100755 --- a/scripts/agatha.asm +++ b/scripts/agatha.asm @@ -24,8 +24,7 @@ AgathaScript_76443: ; 76443 (1d:6443) AgathaScript_76459: ; 76459 (1d:6459) ld [wd09f], a ld bc, $2 - ld a, $17 - jp Predef + predef_jump Func_ee9e AgathaScript_76464: ; 76464 (1d:6464) xor a diff --git a/scripts/billshouse.asm b/scripts/billshouse.asm index 1e5d1555..3a8a33c0 100755 --- a/scripts/billshouse.asm +++ b/scripts/billshouse.asm @@ -41,8 +41,7 @@ BillsHouseScript2: ; 1e7a6 (7:67a6) ret nz ld a, $61 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7f2 set 6, [hl] xor a @@ -70,8 +69,7 @@ BillsHouseScript3: ; 1e7c5 (7:67c5) call Func_32f9 ld a, $62 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld c, $8 call DelayFrames ld a, $2 @@ -165,12 +163,10 @@ BillsHouseText2: ; 1e874 (7:6874) set 4, [hl] ld a, $7 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $9 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject .asm_5491f ; 0x1e8a9 ld hl, BillsHouseText_1e8cb call PrintText diff --git a/scripts/blueshouse.asm b/scripts/blueshouse.asm index 1055f47a..4f336ea9 100755 --- a/scripts/blueshouse.asm +++ b/scripts/blueshouse.asm @@ -44,8 +44,7 @@ BluesHouseText1: ; 19b5d (6:5b5d) jr nc, .BagFull ld a,$29 ld [wcc4d],a - ld a,$11 - call Predef ; hide table map object + predef HideObject ; hide table map object ld hl,GotMapText call PrintText ld hl,wd74a diff --git a/scripts/bruno.asm b/scripts/bruno.asm index 7f9dd1b6..d0382fa4 100755 --- a/scripts/bruno.asm +++ b/scripts/bruno.asm @@ -24,8 +24,7 @@ BrunoScript_762ec: ; 762ec (1d:62ec) BrunoScript_76302: ; 76302 (1d:6302) ld [wd09f], a ld bc, $2 - ld a, $17 - jp Predef + predef_jump Func_ee9e BrunoScript_7630d: ; 7630d (1d:630d) xor a diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 4cb001e6..2d638044 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -34,8 +34,7 @@ CeladonGameCornerScript_48bec: ; 48bec (12:4bec) ld a, $2a ld [wd09f], a ld bc, $0208 - ld a, $17 - jp Predef + predef_jump Func_ee9e CeladonGameCornerScript_48c07: ; 48c07 (12:4c07) xor a @@ -97,8 +96,7 @@ CeladonGameCornerScript2: ; 48c69 (12:4c69) ld [wJoyIgnore], a ld a, $46 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd126 set 5, [hl] set 6, [hl] @@ -157,8 +155,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9) ld hl, $ffa1 ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef xor a ldh [$9f], a ldh [$a0], a @@ -167,8 +164,7 @@ CeladonGameCornerText2: ; 48ca9 (12:4ca9) ld de, wPlayerCoins + 1 ld hl, $ffa1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef call CeladonGameCornerScript_48f1e ld hl, CeladonGameCornerText_48d27 jr .asm_e2afd ; 0x48d0d @@ -236,8 +232,7 @@ CeladonGameCornerText5: ; 48d4a (12:4d4a) ld de, wPlayerCoins + 1 ld hl, $ffa1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, wd77e set 2, [hl] ld a, $1 @@ -319,8 +314,7 @@ CeladonGameCornerText9: ; 48dd9 (12:4dd9) ld de, wPlayerCoins + 1 ld hl, $ffa1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, wd77e set 4, [hl] ld hl, Received20CoinsText @@ -373,8 +367,7 @@ CeladonGameCornerText10: ; 48e3b (12:4e3b) ld de, wPlayerCoins + 1 ld hl, $ffa1 ld c, $2 - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef ld hl, wd77e set 3, [hl] ld hl, CeladonGameCornerText_48e8d @@ -456,8 +449,7 @@ CeladonGameCornerText12: ; 48edd (12:4edd) ld a, $43 ld [wd09f], a ld bc, $0208 - ld a, $17 - call Predef + predef Func_ee9e jp TextScriptEnd CeladonGameCornerText_48f09: ; 48f09 (12:4f09) diff --git a/scripts/celadonmansion5.asm b/scripts/celadonmansion5.asm index b8cd77ee..66ef96d8 100755 --- a/scripts/celadonmansion5.asm +++ b/scripts/celadonmansion5.asm @@ -16,7 +16,6 @@ CeladonMansion5Text2: ; 1dd46 (7:5d46) jr nc, .asm_24365 ; 0x1dd4d ld a, $45 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject .asm_24365 ; 0x1dd59 jp TextScriptEnd diff --git a/scripts/celadonmartelevator.asm b/scripts/celadonmartelevator.asm index 723eab36..1e32647d 100755 --- a/scripts/celadonmartelevator.asm +++ b/scripts/celadonmartelevator.asm @@ -66,6 +66,5 @@ CeladonMartElevatorText1: ; 4865e (12:465e) db $08 ; asm call CeladonMartElevatorScript_48631 ld hl, CeldaonMartElevatorWarpMaps ; $464a - ld a, $61 - call Predef + predef Func_1c9c6 jp TextScriptEnd diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index 1eb02dc2..02f2959d 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -14,8 +14,7 @@ CeladonMartRoofScript_483d8: ; 483d8 (12:43d8) push de ld [wd11e], a ld b, a - ld a, $1c - call Predef + predef IsItemInBag_ pop de pop hl ld a, b diff --git a/scripts/ceruleancity.asm b/scripts/ceruleancity.asm index c2ecf26c..419dbd8c 100755 --- a/scripts/ceruleancity.asm +++ b/scripts/ceruleancity.asm @@ -10,8 +10,7 @@ CeruleanCityScript_1948c: ; 1948c (6:548c) ld [W_CERULEANCITYCURSCRIPT], a ld a, $5 ld [wcc4d], a - ld a, $11 - jp Predef + predef_jump HideObject CeruleanCityScriptPointers: ; 1949d (6:549d) dw CeruleanCityScript0 @@ -91,8 +90,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) .asm_19535 ld a, $5 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld de, CeruleanCityMovement1 ld a, $1 ld [$ff8c], a @@ -208,8 +206,7 @@ CeruleanCityScript3: ; 19610 (6:5610) ret nz ld a, $5 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject xor a ld [wJoyIgnore], a call Func_2307 diff --git a/scripts/ceruleancity2.asm b/scripts/ceruleancity2.asm index cb7eee15..57c9ea4a 100755 --- a/scripts/ceruleancity2.asm +++ b/scripts/ceruleancity2.asm @@ -5,15 +5,12 @@ Func_74872: ; 74872 (1d:4872) call GBFadeIn1 ld a, $07 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $09 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $06 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call GBFadeOut1 ret diff --git a/scripts/ceruleanhouse1.asm b/scripts/ceruleanhouse1.asm index 6bc1cd30..27a91ab5 100755 --- a/scripts/ceruleanhouse1.asm +++ b/scripts/ceruleanhouse1.asm @@ -13,6 +13,5 @@ CeruleanHouse1Text2: ; 1d702 (7:5702) db $08 ; asm ld a, $6 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd diff --git a/scripts/ceruleanhousetrashed.asm b/scripts/ceruleanhousetrashed.asm index 1bb60564..02b40dcb 100755 --- a/scripts/ceruleanhousetrashed.asm +++ b/scripts/ceruleanhousetrashed.asm @@ -10,8 +10,7 @@ CeruleanHouseTrashedTextPointers: ; 1d689 (7:5689) CeruleanHouseTrashedText1: ; 1d68f (7:568f) db $08 ; asm ld b, $e4 - ld a, $1c - call Predef + predef IsItemInBag_ and b jr z, .asm_f8734 ; 0x1d698 ld hl, CeruleanHouseTrashedText_1d6b0 diff --git a/scripts/cinnabargym.asm b/scripts/cinnabargym.asm index 8d1cb2d6..8ce02e81 100755 --- a/scripts/cinnabargym.asm +++ b/scripts/cinnabargym.asm @@ -87,8 +87,7 @@ CinnabarGymScript1: ; 757dc (1d:57dc) jp DisplayTextID CinnabarGymScript_757f1: ; 757f1 (1d:57f1) - ld a, $10 ; FlagActionPredef - jp Predef + predef_jump FlagActionPredef CinnabarGymScript2: ; 757f6 (1d:57f6) ld a, [W_ISINBATTLE] diff --git a/scripts/daycarem.asm b/scripts/daycarem.asm index b584c4ed..e463d380 100755 --- a/scripts/daycarem.asm +++ b/scripts/daycarem.asm @@ -120,8 +120,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) push hl push de push bc - ld a, $b ; AddBCDPredef - call Predef + predef AddBCDPredef pop bc pop de pop hl @@ -156,8 +155,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) inc hl ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef ld a, (SFX_02_5a - SFX_Headers_02) / 3 call PlaySoundWaitForCurrent ld a, $13 @@ -181,8 +179,7 @@ DayCareMScript_562e1: ; 562e1 (15:62e1) ld e, l ld a, $1 ld [wHPBarMaxHP], a - ld a, $3e - call Predef + predef WriteMonMoves pop bc pop af ld hl, wPartyMon1HP diff --git a/scripts/fightingdojo.asm b/scripts/fightingdojo.asm index 23816925..5f244781 100755 --- a/scripts/fightingdojo.asm +++ b/scripts/fightingdojo.asm @@ -281,8 +281,7 @@ FightingDojoText6: ; 5cf06 (17:4f06) ; once Poké Ball is taken, hide sprite ld a, $4a ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7b1 set 6, [hl] set 0, [hl] @@ -323,8 +322,7 @@ FightingDojoText7: ; 5cf4e (17:4f4e) ; once Poké Ball is taken, hide sprite ld a, $4b ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject .done jp TextScriptEnd diff --git a/scripts/gary.asm b/scripts/gary.asm index 20140cf7..f909a618 100755 --- a/scripts/gary.asm +++ b/scripts/gary.asm @@ -122,8 +122,7 @@ GaryScript4: ; 75fe4 (1d:5fe4) call MoveSprite ld a, $d6 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $5 ld [W_GARYCURSCRIPT], a ret @@ -193,8 +192,7 @@ GaryScript8: ; 76083 (1d:6083) ret nz ld a, $d6 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $9 ld [W_GARYCURSCRIPT], a ret diff --git a/scripts/halloffameroom.asm b/scripts/halloffameroom.asm index f88d8498..1273305e 100755 --- a/scripts/halloffameroom.asm +++ b/scripts/halloffameroom.asm @@ -25,8 +25,7 @@ HallofFameRoomScript2: ; 5a4bb (16:64bb) push af xor a ld [wJoyIgnore], a - ld a, $55 - call Predef + predef HallOfFamePC pop af ld [wd358], a ld hl, W_FLAGS_D733 @@ -101,8 +100,7 @@ HallofFameRoomScript1: ; 5a52b (16:652b) ld [wJoyIgnore], a ld a, $8 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $2 ld [W_HALLOFFAMEROOMCURSCRIPT], a ret diff --git a/scripts/lab2.asm b/scripts/lab2.asm index a626de98..4075f737 100755 --- a/scripts/lab2.asm +++ b/scripts/lab2.asm @@ -21,6 +21,5 @@ Lab2Text3: ; 75c37 (1d:5c37) ld a, $8 ld [wWhichTrade], a asm_78552: ; 75c3d (1d:5c3d) - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd diff --git a/scripts/lab4.asm b/scripts/lab4.asm index 6a025f03..a1df3387 100755 --- a/scripts/lab4.asm +++ b/scripts/lab4.asm @@ -18,8 +18,7 @@ Lab4Script_75d38: ; 75d38 (1d:5d38) push de ld [wd11e], a ld b, a - ld a, $1c - call Predef + predef IsItemInBag_ pop de pop hl ld a, b @@ -105,8 +104,7 @@ Lab4Text2: ; 75dda (1d:5dda) db $08 ; asm ld a, $3 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd LoadFossilItemAndMonNameBank1D: ; 75de8 (1d:5de8) diff --git a/scripts/lance.asm b/scripts/lance.asm index 26d42788..90295042 100755 --- a/scripts/lance.asm +++ b/scripts/lance.asm @@ -34,8 +34,7 @@ LanceScript_5a2de: ; 5a2de (16:62de) ld bc, $603 LanceScript_5a2f0: ; 5a2f0 (16:62f0) - ld a, $17 - jp Predef + predef_jump Func_ee9e LanceScript_5a2f5: ; 5a2f5 (16:62f5) xor a diff --git a/scripts/lorelei.asm b/scripts/lorelei.asm index fb10a17d..670b6b66 100755 --- a/scripts/lorelei.asm +++ b/scripts/lorelei.asm @@ -25,8 +25,7 @@ LoreleiScript_76191: ; 76191 (1d:6191) .asm_761ab ld [wd09f], a ld bc, $2 - ld a, $17 - jp Predef + predef_jump Func_ee9e LoreleiScript_761b6: ; 761b6 (1d:61b6) xor a diff --git a/scripts/mansion1.asm b/scripts/mansion1.asm index 7f314634..ee1b42b4 100755 --- a/scripts/mansion1.asm +++ b/scripts/mansion1.asm @@ -43,8 +43,7 @@ Mansion1Script_4430b: ; 4430b (11:430b) ld a, $e ld [wd09f], a asm_44310: ; 44310 (11:4310) - ld a, $17 - call Predef + predef Func_ee9e ret Mansion1Script_Switches: ; 44316 (11:4316) diff --git a/scripts/mansion2.asm b/scripts/mansion2.asm index 679dd70a..30261637 100755 --- a/scripts/mansion2.asm +++ b/scripts/mansion2.asm @@ -40,8 +40,7 @@ Mansion2Script_51fee: ; 51fee (14:5fee) Mansion2Script_5202f: ; 5202f (14:602f) ld [wd09f], a - ld a, $17 - jp Predef + predef_jump Func_ee9e Mansion2Script_Switches: ; 52037 (14:6037) ld a, [wSpriteStateData1 + 9] diff --git a/scripts/mtmoon3.asm b/scripts/mtmoon3.asm index 732294cc..8d6aaeed 100755 --- a/scripts/mtmoon3.asm +++ b/scripts/mtmoon3.asm @@ -151,8 +151,7 @@ MtMoon3Script5: ; 49dfb (12:5dfb) ld a, $6d .asm_49e1f ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject xor a ld [wJoyIgnore], a ld a, $0 @@ -284,8 +283,7 @@ MtMoon3Text6: ; 49ee9 (12:5ee9) call MtMoon3Script_49f69 ld a, $6d ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7f6 set 6, [hl] ld a, $4 @@ -314,8 +312,7 @@ MtMoon3Text7: ; 49f29 (12:5f29) call MtMoon3Script_49f69 ld a, $6e ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7f6 set 7, [hl] ld a, $4 diff --git a/scripts/mtmoonpokecenter.asm b/scripts/mtmoonpokecenter.asm index 6bbe7a1b..94054561 100755 --- a/scripts/mtmoonpokecenter.asm +++ b/scripts/mtmoonpokecenter.asm @@ -55,8 +55,7 @@ MtMoonPokecenterText4: ; 492ec (12:52ec) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef ld a, $13 ld [wd125], a call DisplayTextBoxID diff --git a/scripts/museum1f.asm b/scripts/museum1f.asm index 5e1bb792..e593cf39 100755 --- a/scripts/museum1f.asm +++ b/scripts/museum1f.asm @@ -103,8 +103,7 @@ Museum1FText1: ; 5c135 (17:4135) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef ld a, $13 ld [wd125], a call DisplayTextBoxID @@ -203,8 +202,7 @@ Museum1FText3: ; 5c256 (17:4256) set 1, [hl] ld a, $34 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, ReceivedOldAmberText jr .asm_52e0f ; 0x5c27e .BagFull diff --git a/scripts/oakslab.asm b/scripts/oakslab.asm index 194eb1a8..fb56aade 100755 --- a/scripts/oakslab.asm +++ b/scripts/oakslab.asm @@ -40,8 +40,7 @@ OaksLabScript0: ; 1cb4e (7:4b4e) ret nz ld a, $31 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld hl, wd72e res 4, [hl] @@ -68,12 +67,10 @@ OaksLabScript2: ; 1cb82 (7:4b82) ret nz ld a, $31 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $2e ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $3 ld [W_OAKSLABCURSCRIPT], a @@ -294,8 +291,7 @@ OaksLabScript9: ; 1cd00 (7:4d00) ld a, $2d .asm_1cd32 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call Delay3 ld a, [wWhichTrade] ld [W_RIVALSTARTER], a @@ -341,13 +337,11 @@ OaksLabScript10: ; 1cd6d (7:4d6d) ld a, $1 swap a ld [$ff95], a - ld a, $22 - call Predef + predef Func_f929 ld a, [$ff95] dec a ld [$ff95], a - ld a, $20 - call Predef + predef Func_f8ba ld de, wcc97 ld a, $1 ld [$ff8c], a @@ -410,8 +404,7 @@ OaksLabScript12: ; 1ce03 (7:4e03) xor a ld [$ff8d], a call Func_34a6 ; face object - ld a, $7 - call Predef + predef HealParty ld hl, wd74b set 3, [hl] @@ -454,8 +447,7 @@ OaksLabScript14: ; 1ce6d (7:4e6d) jr nz, .asm_1ce8c ; 0x1ce72 $18 ld a, $2a ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject xor a ld [wJoyIgnore], a call Func_2307 ; reset to map music @@ -498,8 +490,7 @@ OaksLabScript15: ; 1ceb0 (7:4eb0) call OaksLabScript_1d02b ld a, $2a ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, [wcd37] ld [wd157], a ld b, $0 @@ -558,12 +549,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) call Delay3 ld a, $2f ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $30 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call OaksLabScript_1cefd ld a, $1a ld [$ff8c], a @@ -583,12 +572,10 @@ OaksLabScript16: ; 1cf12 (7:4f12) set 0, [hl] ld a, $1 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $2 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, [wd157] ld b, $0 ld c, a @@ -616,16 +603,14 @@ OaksLabScript17: ; 1cfd4 (7:4fd4) call Func_2307 ld a, $2a ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7eb set 0, [hl] res 1, [hl] set 7, [hl] ld a, $22 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $5 ld [W_PALLETTOWNCURSCRIPT], a xor a @@ -846,8 +831,7 @@ OaksLabScript_1d157: ; 1d157 (7:5157) ld [hl], $c ld hl, wd730 set 6, [hl] - ld a, $46 - call Predef ; StarterDex + predef StarterDex ; StarterDex ld hl, wd730 res 6, [hl] call ReloadMapData @@ -907,8 +891,7 @@ asm_1d1e3: ; 1d1e3 (7:51e3) ld a, $2d asm_1d1e5: ; 1d1e5 (7:51e5) ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $1 ld [wcc3c], a ld hl, OaksLabMonEnergeticText @@ -974,8 +957,7 @@ OaksLabText5: ; 1d248 (7:5248) call PrintText ld a, $1 ld [wcc3c], a - ld a, $56 - call Predef + predef DisplayDexRating jp .asm_0f042 .asm_b28b0 ; 0x1d279 ld b,POKE_BALL diff --git a/scripts/pallettown.asm b/scripts/pallettown.asm index d87668fd..16098dcf 100755 --- a/scripts/pallettown.asm +++ b/scripts/pallettown.asm @@ -56,8 +56,7 @@ PalletTownScript1: ; 18eb2 (6:4eb2) ld [wJoyIgnore],a ld a,0 ld [wcc4d],a - ld a,$15 - call Predef + predef ShowObject ; trigger the next script ld a,2 @@ -78,12 +77,10 @@ PalletTownScript2: ; 18ed2 (6:4ed2) ld a,1 swap a ld [$FF95],a - ld a,$22 - call Predef + predef Func_f929 ld hl,$FF95 dec [hl] - ld a,$20 - call Predef ; load Oak’s movement into wcc97 + predef Func_f8ba ; load Oak’s movement into wcc97 ld de,wcc97 ld a,1 ; oak ld [$FF8C],a @@ -146,12 +143,10 @@ PalletTownScript5: ; 18f56 (6:4f56) set 2,[hl] ld a,$27 ld [wcc4d],a - ld a,$11 - call Predef + predef HideObject ld a,$28 ld [wcc4d],a - ld a,$15 - jp Predef + predef_jump ShowObject .next ld a,[wd74b] bit 4,a @@ -193,8 +188,7 @@ OakAppearsText: ; 18fb0 (6:4fb0) xor a ld [wcd4f],a ld [wcd50],a - ld a,$4C - call Predef ; display ! over head + predef EmotionBubble ; display ! over head ld a,4 ld [wd528],a jp TextScriptEnd diff --git a/scripts/pewtercity.asm b/scripts/pewtercity.asm index 5f4fea82..e7a143f9 100755 --- a/scripts/pewtercity.asm +++ b/scripts/pewtercity.asm @@ -87,8 +87,7 @@ PewterCityScript2: ; 192d3 (6:52d3) ret nz ld a, $3 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $3 ld [W_PEWTERCITYCURSCRIPT], a ret @@ -99,8 +98,7 @@ PewterCityScript3: ; 192e9 (6:52e9) call Func_32fe ld a, $3 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject xor a ld [wJoyIgnore], a ld a, $0 @@ -153,8 +151,7 @@ PewterCityScript5: ; 19359 (6:5359) ret nz ld a, $4 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $6 ld [W_PEWTERCITYCURSCRIPT], a ret @@ -165,8 +162,7 @@ PewterCityScript6: ; 1936f (6:536f) call Func_32fe ld a, $4 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject xor a ld [wJoyIgnore], a ld a, $0 diff --git a/scripts/pewtergym.asm b/scripts/pewtergym.asm index 4d148906..2feb9817 100755 --- a/scripts/pewtergym.asm +++ b/scripts/pewtergym.asm @@ -69,12 +69,10 @@ PewterGymScript_5c3df: ; 5c3df (17:43df) ld a, $4 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $22 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld hl, wd7eb res 0, [hl] diff --git a/scripts/pokemontower2.asm b/scripts/pokemontower2.asm index e1357b34..f370d7b7 100755 --- a/scripts/pokemontower2.asm +++ b/scripts/pokemontower2.asm @@ -101,8 +101,7 @@ PokemonTower2Script2: ; 605bb (18:45bb) ret nz ld a, $38 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject xor a ld [wJoyIgnore], a call Func_2307 diff --git a/scripts/pokemontower5.asm b/scripts/pokemontower5.asm index ff084349..317690a2 100755 --- a/scripts/pokemontower5.asm +++ b/scripts/pokemontower5.asm @@ -32,8 +32,7 @@ PokemonTower5Script0: ; 6094b (18:494b) ld [wJoyIgnore], a ld hl, wd72e set 4, [hl] - ld a, $7 - call Predef + predef HealParty call GBFadeOut2 call Delay3 call Delay3 diff --git a/scripts/pokemontower7.asm b/scripts/pokemontower7.asm index 381d1c64..431855cb 100755 --- a/scripts/pokemontower7.asm +++ b/scripts/pokemontower7.asm @@ -52,8 +52,7 @@ PokemonTower7Script3: ; 60d56 (18:4d56) ld a, [hli] jr nz, .missableObjectsListLoop ld [wcc4d], a ; remove missable object - ld a, $11 - call Predef + predef HideObject xor a ld [wJoyIgnore], a ld [wcf13], a @@ -69,8 +68,7 @@ PokemonTower7Script4: ; 60d86 (18:4d86) ld [wJoyIgnore], a ld a, $43 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $4 ld [wSpriteStateData1 + 9], a ld a, $95 @@ -226,16 +224,13 @@ PokemonTower7Text4: ; 60e8a (18:4e8a) set 7, [hl] ld a, $44 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $17 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $18 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $4 ld [W_POKEMONTOWER7CURSCRIPT], a ld [W_CURMAPSCRIPT], a diff --git a/scripts/rockethideout1.asm b/scripts/rockethideout1.asm index 9f9c03b0..43e4fd26 100755 --- a/scripts/rockethideout1.asm +++ b/scripts/rockethideout1.asm @@ -30,8 +30,7 @@ RocketHideout1Script_44be0: ; 44be0 (11:4be0) .asm_44c03 ld [wd09f], a ld bc, $080c - ld a, $17 - jp Predef + predef_jump Func_ee9e RocketHideout1ScriptPointers: ; 44c0e (11:4c0e) dw CheckFightingMapTrainers diff --git a/scripts/rockethideout4.asm b/scripts/rockethideout4.asm index 3faa566e..5c99f3a1 100755 --- a/scripts/rockethideout4.asm +++ b/scripts/rockethideout4.asm @@ -31,8 +31,7 @@ RocketHideout4Script_45473: ; 45473 (11:5473) .asm_45498 ld [wd09f], a ld bc, $050c - ld a, $17 - jp Predef + predef_jump Func_ee9e RocketHideout4Script_454a3: ; 454a3 (11:54a3) xor a @@ -62,12 +61,10 @@ RocketHideout4Script3: ; 454b6 (11:54b6) call GBFadeIn1 ld a, $83 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $87 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject call UpdateSprites call GBFadeOut1 xor a @@ -222,8 +219,7 @@ RocketHideout4AfterBattleText4: ; 455cf (11:55cf) jr nz, .asm_455e9 ; 0x455dd $a ld a, $88 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject .asm_455e9 jp TextScriptEnd diff --git a/scripts/rockethideoutelevator.asm b/scripts/rockethideoutelevator.asm index fa208a5e..73313dd7 100755 --- a/scripts/rockethideoutelevator.asm +++ b/scripts/rockethideoutelevator.asm @@ -68,8 +68,7 @@ RocketHideoutElevatorText1: ; 4576d (11:576d) jr z, .asm_8d8f0 ; 0x45773 call RocketHideoutElevatorScript_45741 ld hl, RocketHideoutElevatorWarpMaps ; $5759 - ld a, $61 - call Predef + predef Func_1c9c6 jr .asm_46c43 ; 0x45780 .asm_8d8f0 ; 0x45782 ld hl, RocketHideoutElevatorText_4578b diff --git a/scripts/route11gateupstairs.asm b/scripts/route11gateupstairs.asm index e6d7eba9..5c0cc574 100755 --- a/scripts/route11gateupstairs.asm +++ b/scripts/route11gateupstairs.asm @@ -11,8 +11,7 @@ Route11GateUpstairsText1: ; 4945f (12:545f) db $08 ; asm xor a ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 asm_49469: ; 49469 (12:5469) jp TextScriptEnd @@ -32,8 +31,7 @@ Route11GateUpstairsText2: ; 4946c (12:546c) ld de, wcc5b ld bc, $000d call CopyData - ld a, $62 - call Predef ; call oak's aide script + predef OaksAideScript ; call oak's aide script ld a, [$ffdb] dec a jr nz, .asm_494a1 ; 0x49494 $b diff --git a/scripts/route12.asm b/scripts/route12.asm index e722f15d..b7ec451a 100755 --- a/scripts/route12.asm +++ b/scripts/route12.asm @@ -36,8 +36,7 @@ Route12Script0: ; 59619 (16:5619) ld [W_CURENEMYLVL], a ; W_CURENEMYLVL ld a, $1d ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $3 ld [W_ROUTE12CURSCRIPT], a ld [W_CURMAPSCRIPT], a diff --git a/scripts/route15gateupstairs.asm b/scripts/route15gateupstairs.asm index 88b6576f..2d328122 100755 --- a/scripts/route15gateupstairs.asm +++ b/scripts/route15gateupstairs.asm @@ -20,8 +20,7 @@ Route15GateUpstairsText1: ; 49651 (12:5651) ld de, wcc5b ld bc, $000d call CopyData - ld a, $62 - call Predef ; call oak's aide script + predef OaksAideScript ; call oak's aide script ld a, [$ffdb] cp $1 jr nz, .asm_49689 ; 0x4967c $b diff --git a/scripts/route16.asm b/scripts/route16.asm index afae25c9..01bd35ad 100755 --- a/scripts/route16.asm +++ b/scripts/route16.asm @@ -36,8 +36,7 @@ Route16Script0: ; 59959 (16:5959) ld [W_CURENEMYLVL], a ; W_CURENEMYLVL ld a, $21 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call UpdateSprites ld a, $3 ld [W_ROUTE16CURSCRIPT], a diff --git a/scripts/route18gateupstairs.asm b/scripts/route18gateupstairs.asm index d9164d1d..9db16aeb 100755 --- a/scripts/route18gateupstairs.asm +++ b/scripts/route18gateupstairs.asm @@ -10,8 +10,7 @@ Route18GateUpstairsText1: ; 4997e (12:597e) db $08 ; asm ld a, $5 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd Route18GateUpstairsText2: ; 4998c (12:598c) diff --git a/scripts/route20.asm b/scripts/route20.asm index 376d7da9..7e8df3da 100755 --- a/scripts/route20.asm +++ b/scripts/route20.asm @@ -50,13 +50,11 @@ Route20Script_50cc6: ; 50cc6 (14:4cc6) Route20Script_50d0c: ; 50d0c (14:4d0c) ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject Route20Script_50d14: ; 50d14 (14:4d14) ld [wcc4d], a - ld a, $11 - jp Predef + predef_jump HideObject Route20ScriptPointers: ; 50d1c (14:4d1c) dw CheckFightingMapTrainers diff --git a/scripts/route22.asm b/scripts/route22.asm index d9fce630..aba6a479 100755 --- a/scripts/route22.asm +++ b/scripts/route22.asm @@ -82,8 +82,7 @@ Route22Script0: ; 50f00 (14:4f00) ld [wcd4f], a xor a ld [wcd50], a - ld a, $4c - call Predef + predef EmotionBubble ld a, [wd700] and a jr z, .asm_50f4e ; 0x50f44 $8 @@ -208,8 +207,7 @@ Route22Script3: ; 5102a (14:502a) ld [wJoyIgnore], a ld a, $22 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call Func_2307 ld hl, wd7eb res 0, [hl] @@ -223,8 +221,7 @@ Route22Script_5104e: ; 5104e (14:504e) ld [wcd4f], a xor a ld [wcd50], a - ld a, $4c - call Predef + predef EmotionBubble ld a, [wd700] and a jr z, .skipYVisibilityTesta @@ -355,8 +352,7 @@ Route22Script6: ; 51151 (14:5151) ld [wJoyIgnore], a ld a, $23 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call Func_2307 ld hl, wd7eb res 1, [hl] diff --git a/scripts/route23.asm b/scripts/route23.asm index 507db5ce..55184600 100755 --- a/scripts/route23.asm +++ b/scripts/route23.asm @@ -18,12 +18,10 @@ Route23Script_511e9: ; 511e9 (14:51e9) res 6, [hl] ld a, $7a ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld a, $60 ld [wcc4d], a - ld a, $11 - jp Predef + predef_jump HideObject Route23ScriptPointers: ; 51213 (14:5213) dw Route23Script0 @@ -56,8 +54,7 @@ Route23Script0: ; 51219 (14:5219) ld [wWhichTrade], a ld b, $2 ld hl, wd7ed - ld a, $10 - call Predef + predef FlagActionPredef ld a, c and a ret nz @@ -198,8 +195,7 @@ Route23Script_51346: ; 51346 (14:5346) ld c, a ld b, $2 ld hl, W_OBTAINEDBADGES - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld a, c and a jr nz, .asm_5136e @@ -216,8 +212,7 @@ Route23Script_51346: ; 51346 (14:5346) ld c, a ld b, $1 ld hl, wd7ed - ld a, $10 ; FlagActionPredef - call Predef + predef FlagActionPredef ld a, $2 ld [W_ROUTE23CURSCRIPT], a ret diff --git a/scripts/route25.asm b/scripts/route25.asm index 609205ec..088be3a2 100755 --- a/scripts/route25.asm +++ b/scripts/route25.asm @@ -21,24 +21,20 @@ Route25Script_515e1: ; 515e1 (14:55e1) res 6, [hl] ld a, $61 ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject .asm_515ff bit 4, [hl] ret z set 7, [hl] ld a, $24 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $62 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $63 ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject Route25ScriptPointers: ; 51622 (14:5622) dw CheckFightingMapTrainers diff --git a/scripts/route2gate.asm b/scripts/route2gate.asm index b6e00b51..8ee087c8 100755 --- a/scripts/route2gate.asm +++ b/scripts/route2gate.asm @@ -20,8 +20,7 @@ Route2GateText1: ; 5d5db (17:55db) ld de, wcc5b ld bc, $000d call CopyData - ld a, $62 - call Predef ; call oak's aide script + predef OaksAideScript ; call oak's aide script ldh a, [$db] cp $1 jr nz, .asm_ad646 ; 0x5d606 diff --git a/scripts/route2house.asm b/scripts/route2house.asm index 50a058b8..75da399b 100755 --- a/scripts/route2house.asm +++ b/scripts/route2house.asm @@ -13,6 +13,5 @@ Route2HouseText2: ; 1def9 (7:5ef9) db $08 ; asm ld a, $1 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd diff --git a/scripts/safarizoneentrance.asm b/scripts/safarizoneentrance.asm index 7140f67b..ffc7f402 100755 --- a/scripts/safarizoneentrance.asm +++ b/scripts/safarizoneentrance.asm @@ -176,8 +176,7 @@ SafariZoneEntranceText4: ; 752ca (1d:52ca) ld hl, wTrainerFacingDirection ld de, wPlayerMoney + 2 ld c, $3 - ld a, $c ; SubBCDPredef - call Predef + predef SubBCDPredef ld a, $13 ld [wd125], a call DisplayTextBoxID diff --git a/scripts/seafoamislands1.asm b/scripts/seafoamislands1.asm index 3558226b..55bbd43e 100755 --- a/scripts/seafoamislands1.asm +++ b/scripts/seafoamislands1.asm @@ -28,12 +28,10 @@ SeafoamIslands1Script: ; 447e9 (11:47e9) .asm_44825 ld a, [wd079] ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, [wd07a] ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject .asm_4483b ld a, $9f ld [wd71d], a diff --git a/scripts/seafoamislands2.asm b/scripts/seafoamislands2.asm index 9ee8fd28..b14c16d8 100755 --- a/scripts/seafoamislands2.asm +++ b/scripts/seafoamislands2.asm @@ -26,12 +26,10 @@ SeafoamIslands2Script: ; 46315 (11:6315) .asm_4634c ld a, [wd079] ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, [wd07a] ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject .asm_46362 ld a, $a0 ld [wd71d], a diff --git a/scripts/seafoamislands3.asm b/scripts/seafoamislands3.asm index 46f9a74e..aa7b3615 100755 --- a/scripts/seafoamislands3.asm +++ b/scripts/seafoamislands3.asm @@ -26,12 +26,10 @@ SeafoamIslands3Script: ; 46451 (11:6451) .asm_46488 ld a, [wd079] ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, [wd07a] ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject .asm_4649e ld a, $a1 ld [wd71d], a diff --git a/scripts/seafoamislands4.asm b/scripts/seafoamislands4.asm index 3c2be99c..ac573994 100755 --- a/scripts/seafoamislands4.asm +++ b/scripts/seafoamislands4.asm @@ -26,12 +26,10 @@ SeafoamIslands4Script: ; 4658d (11:658d) .asm_465c4 ld a, [wd079] ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, [wd07a] ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject jr .asm_465ed ; 0x465da $11 .asm_465dc ld a, $a2 diff --git a/scripts/silphco1.asm b/scripts/silphco1.asm index 0ac616c0..990e5c2a 100755 --- a/scripts/silphco1.asm +++ b/scripts/silphco1.asm @@ -9,8 +9,7 @@ SilphCo1Script: ; 5d44e (17:544e) ret nz ld a, $4c ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject SilphCo1TextPointers: ; 5d469 (17:5469) dw SilphCo1Text1 diff --git a/scripts/silphco10.asm b/scripts/silphco10.asm index b3264520..c831655f 100755 --- a/scripts/silphco10.asm +++ b/scripts/silphco10.asm @@ -22,8 +22,7 @@ SilphCo10Script_5a14f: ; 5a14f (16:614f) ld a, $54 ld [wd09f], a ld bc, $405 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_5a173: ; 5a173 (16:6173) db $04,$05,$FF diff --git a/scripts/silphco11.asm b/scripts/silphco11.asm index 44918bea..b63bc523 100755 --- a/scripts/silphco11.asm +++ b/scripts/silphco11.asm @@ -22,8 +22,7 @@ SilphCo11Script_62110: ; 62110 (18:6110) ld a, $20 ld [wd09f], a ld bc, $603 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_62134: ; 62134 (18:6134) db $06,$03,$FF @@ -80,8 +79,7 @@ SilphCo11Script_6216d: ; 6216d (18:616d) jr z, .asm_62181 push hl ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject pop hl jr .asm_62170 .asm_62181 @@ -92,8 +90,7 @@ SilphCo11Script_6216d: ; 6216d (18:616d) ret z push hl ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject pop hl jr .asm_62184 diff --git a/scripts/silphco2.asm b/scripts/silphco2.asm index 755b5138..20d689e6 100755 --- a/scripts/silphco2.asm +++ b/scripts/silphco2.asm @@ -23,8 +23,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0202 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_59d2e bit 6, a @@ -32,8 +31,7 @@ SilphCo2Script_59d07: ; 59d07 (16:5d07) ld a, $54 ld [wd09f], a ld bc, $0502 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_59d3e: ; 59d3e (16:5d3e) db $02,$02,$05,$02,$FF diff --git a/scripts/silphco3.asm b/scripts/silphco3.asm index 4ea577a5..5527d923 100755 --- a/scripts/silphco3.asm +++ b/scripts/silphco3.asm @@ -23,8 +23,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $404 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_59f98 bit 1, a @@ -32,8 +31,7 @@ SilphCo3Script_59f71: ; 59f71 (16:5f71) ld a, $5f ld [wd09f], a ld bc, $408 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_59fa8: ; 59fa8 (16:5fa8) db $04,$04,$04,$08,$FF diff --git a/scripts/silphco4.asm b/scripts/silphco4.asm index 7b6992fa..718077ce 100755 --- a/scripts/silphco4.asm +++ b/scripts/silphco4.asm @@ -23,8 +23,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0602 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_19d48 bit 1, a @@ -32,8 +31,7 @@ SilphCo4Script_19d21: ; 19d21 (6:5d21) ld a, $54 ld [wd09f], a ld bc, $0406 - ld a, $17 - jp Predef + predef_jump Func_ee9e SilphCo4Data19d58: ; 19d58 (6:5d58) db $06, $02, $04, $06, $ff diff --git a/scripts/silphco5.asm b/scripts/silphco5.asm index d586ae94..709af20b 100755 --- a/scripts/silphco5.asm +++ b/scripts/silphco5.asm @@ -23,8 +23,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0203 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_19f74 bit 1, a @@ -33,8 +32,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0603 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_19f87 bit 2, a @@ -42,8 +40,7 @@ SilphCo5Script_19f4d: ; 19f4d (6:5f4d) ld a, $5f ld [wd09f], a ld bc, $0507 - ld a, $17 - jp Predef + predef_jump Func_ee9e SilphCo5Coords: ; 19f97 (6:5f97) ; coords? db $02, $03, $06, $03, $05, $07, $ff diff --git a/scripts/silphco6.asm b/scripts/silphco6.asm index 5bea4eae..4a9477c6 100755 --- a/scripts/silphco6.asm +++ b/scripts/silphco6.asm @@ -22,8 +22,7 @@ SilphCo6Script_1a1bf: ; 1a1bf (6:61bf) ld a, $5f ld [wd09f], a ld bc, $0602 - ld a, $17 - jp Predef + predef_jump Func_ee9e SilphCo6Coords1: ; 1a1e3 (6:61e3) db $06, $02 diff --git a/scripts/silphco7.asm b/scripts/silphco7.asm index 6f2b306c..bd611763 100755 --- a/scripts/silphco7.asm +++ b/scripts/silphco7.asm @@ -23,8 +23,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $305 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_51b9e bit 5, a @@ -33,8 +32,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $20a - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_51bb1 bit 6, a @@ -42,8 +40,7 @@ SilphCo7Script_51b77: ; 51b77 (14:5b77) ld a, $54 ld [wd09f], a ld bc, $60a - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_51bc1: ; 51bc1 (14:5bc1) db $03,$05,$02,$0A,$06,$0A,$FF @@ -246,8 +243,7 @@ SilphCo7Script5: ; 51d25 (14:5d25) ret nz ld a, $a7 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call Func_2307 xor a ld [wJoyIgnore], a diff --git a/scripts/silphco8.asm b/scripts/silphco8.asm index a1d05fd6..cc508e61 100755 --- a/scripts/silphco8.asm +++ b/scripts/silphco8.asm @@ -22,8 +22,7 @@ SilphCo8Script_5651a: ; 5651a (15:651a) ld a, $5f ld [wd09f], a ld bc, $403 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_5653e: ; 5653e (15:653e) db $04,$03,$FF diff --git a/scripts/silphco9.asm b/scripts/silphco9.asm index 2247a00f..c4f7a895 100755 --- a/scripts/silphco9.asm +++ b/scripts/silphco9.asm @@ -23,8 +23,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $401 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_5d7f8 bit 1, a @@ -33,8 +32,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $209 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_5d80b bit 2, a @@ -43,8 +41,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $54 ld [wd09f], a ld bc, $509 - ld a, $17 - call Predef + predef Func_ee9e pop af .asm_5d81e bit 3, a @@ -52,8 +49,7 @@ SilphCo9Script_5d7d1: ; 5d7d1 (17:57d1) ld a, $5f ld [wd09f], a ld bc, $605 - ld a, $17 - jp Predef + predef_jump Func_ee9e DataTable_5d82e: ; 5d82e (17:582e) db $04,$01,$02,$09,$05,$09,$06,$05,$FF @@ -167,8 +163,7 @@ SilphCo9Text1: ; 5d8b8 (17:58b8) jr nz, .asm_a14c3 ; 0x5d8be ld hl, SilphCo9Text_5d8e5 call PrintText - ld a, $7 - call Predef + predef HealParty call GBFadeOut2 call Delay3 call GBFadeIn2 diff --git a/scripts/silphcoelevator.asm b/scripts/silphcoelevator.asm index 64240c26..853d7357 100755 --- a/scripts/silphcoelevator.asm +++ b/scripts/silphcoelevator.asm @@ -73,6 +73,5 @@ SilphCoElevatorText1: ; 45835 (11:5835) db $08 ; asm call SilphCoElevatorScript_457f1 ld hl, SilphCoElevatorWarpMaps ; $5811 - ld a, $61 - call Predef + predef Func_1c9c6 jp TextScriptEnd diff --git a/scripts/ssanne2.asm b/scripts/ssanne2.asm index 22e4408f..f3822ec7 100755 --- a/scripts/ssanne2.asm +++ b/scripts/ssanne2.asm @@ -34,8 +34,7 @@ SSAnne2Script0: ; 613be (18:53be) ld [$ffdb], a ld a, $71 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject call Delay3 ld a, $2 ld [$ff8c], a @@ -163,8 +162,7 @@ SSAnne2Script3: ; 614be (18:54be) ld [wJoyIgnore], a ld a, $71 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call Func_2307 ld a, $4 ld [W_SSANNE2CURSCRIPT], a diff --git a/scripts/undergroundpathentranceroute5.asm b/scripts/undergroundpathentranceroute5.asm index 9a437e85..1fb62f48 100755 --- a/scripts/undergroundpathentranceroute5.asm +++ b/scripts/undergroundpathentranceroute5.asm @@ -13,7 +13,6 @@ UndergroundPathEntranceRoute5Text1: ; 5d6b2 (17:56b2) db $08 ; asm ld a, $9 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 ld hl, UndergroundPathEntranceRoute5_5d6af ret diff --git a/scripts/vermilioncity.asm b/scripts/vermilioncity.asm index 06143eab..da70b819 100755 --- a/scripts/vermilioncity.asm +++ b/scripts/vermilioncity.asm @@ -55,8 +55,7 @@ VermilionCityScript0: ; 197e6 (6:57e6) bit 2, a jr nz, .asm_19810 ; 0x19804 $a ld b, $3f - ld a, $1c - call Predef + predef IsItemInBag_ ld a, b and a ret nz @@ -176,8 +175,7 @@ VermilionCityText3: ; 198b1 (6:58b1) ld hl, SSAnneWelcomeText9 call PrintText ld b, S_S__TICKET - ld a, $1c - call Predef + predef IsItemInBag_ ld a, b and a jr nz, .asm_0419b ; 0x198df diff --git a/scripts/vermiliongym.asm b/scripts/vermiliongym.asm index a76d34d8..fa6b2fc2 100755 --- a/scripts/vermiliongym.asm +++ b/scripts/vermiliongym.asm @@ -40,8 +40,7 @@ VermilionGymScript_5ca6d: ; 5ca6d (17:4a6d) .asm_5ca7f ld [wd09f], a ld bc, $202 - ld a, $17 - jp Predef + predef_jump Func_ee9e VermilionGymScript_5ca8a: ; 5ca8a (17:4a8a) xor a diff --git a/scripts/vermilionhouse3.asm b/scripts/vermilionhouse3.asm index b6bceeea..7b4e95fd 100755 --- a/scripts/vermilionhouse3.asm +++ b/scripts/vermilionhouse3.asm @@ -8,6 +8,5 @@ VermilionHouse3Text1: ; 19c17 (6:5c17) db $08 ; asm ld a, $4 ld [wWhichTrade], a - ld a, $54 - call Predef + predef Predef54 jp TextScriptEnd diff --git a/scripts/victoryroad1.asm b/scripts/victoryroad1.asm index 21b87faa..cebd8070 100755 --- a/scripts/victoryroad1.asm +++ b/scripts/victoryroad1.asm @@ -17,8 +17,7 @@ VictoryRoad1Script: ; 5da0a (17:5a0a) ld a, $1d ld [wd09f], a ld bc, $604 - ld a, $17 - jp Predef + predef_jump Func_ee9e VictoryRoad1ScriptPointers: ; 5da3a (17:5a3a) dw VictoryRoad1Script0 diff --git a/scripts/victoryroad2.asm b/scripts/victoryroad2.asm index 034c7545..cf52e3a3 100755 --- a/scripts/victoryroad2.asm +++ b/scripts/victoryroad2.asm @@ -36,8 +36,7 @@ VictoryRoad2Script_517c9: ; 517c9 (14:57c9) VictoryRoad2Script_517e2: ; 517e2 (14:57e2) ld [wd09f], a - ld a, $17 - call Predef + predef Func_ee9e ret VictoryRoad2ScriptPointers: ; 517eb (14:57eb) diff --git a/scripts/victoryroad3.asm b/scripts/victoryroad3.asm index ea04671c..e35e9131 100755 --- a/scripts/victoryroad3.asm +++ b/scripts/victoryroad3.asm @@ -19,8 +19,7 @@ VictoryRoad3Script_44996: ; 44996 (11:4996) ld a, $1d ld [wd09f], a ld bc, $503 - ld a, $17 - jp Predef + predef_jump Func_ee9e VictoryRoad3ScriptPointers: ; 449b1 (11:49b1) dw VictoryRoad3Script0 @@ -50,12 +49,10 @@ VictoryRoad3Script0: ; 449b7 (11:49b7) jr nz, .asm_449fe ld a, $7a ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject ld a, $60 ld [wcc4d], a - ld a, $15 - jp Predef + predef_jump ShowObject .coordsData_449f9: ; 449f9 (11:49f9) db $05,$03 diff --git a/scripts/viridiangym.asm b/scripts/viridiangym.asm index e0c59e61..65ad3553 100755 --- a/scripts/viridiangym.asm +++ b/scripts/viridiangym.asm @@ -177,8 +177,7 @@ ViridianGymScript3_74995: ; 74995 (1d:4995) ld a, $23 ld [wcc4d], a - ld a, $15 - call Predef + predef ShowObject ld hl, wd7eb set 1, [hl] set 7, [hl] @@ -293,8 +292,7 @@ ViridianGymText1: ; 74a69 (1d:4a69) call GBFadeIn1 ld a, $32 ld [wcc4d], a - ld a, $11 - call Predef + predef HideObject call UpdateSprites call Delay3 call GBFadeOut1 -- cgit v1.3.1-sl0p From bd533aa79bbe1998fd2b699bd7205da2de4fe55c Mon Sep 17 00:00:00 2001 From: "U-Fish-PC\\Daniel" Date: Wed, 25 Jun 2014 16:58:27 -0400 Subject: Use *Coord instead of FuncCoord Using 'Coord =' doesn't like using wTileMap So use hlCoord, deCoord, bcCoord, aCoord, Coorda, or dwCoord to avoid static addresses --- engine/HoF_room_pc.asm | 18 +-- engine/battle/1.asm | 6 +- engine/battle/1c.asm | 114 +++++++------------ engine/battle/4_2.asm | 15 +-- engine/battle/animations.asm | 33 ++---- engine/battle/core.asm | 201 +++++++++++---------------------- engine/battle/d.asm | 12 +- engine/battle/e.asm | 12 +- engine/battle/e_2.asm | 6 +- engine/cable_club.asm | 6 +- engine/clear_save.asm | 3 +- engine/evolution.asm | 6 +- engine/hall_of_fame.asm | 48 +++----- engine/hidden_object_functions17.asm | 3 +- engine/hidden_object_functions3.asm | 3 +- engine/intro.asm | 9 +- engine/items/items.asm | 9 +- engine/learn_move.asm | 12 +- engine/menu/bills_pc.asm | 48 +++----- engine/menu/diploma.asm | 3 +- engine/menu/league_pc.asm | 12 +- engine/menu/main_menu.asm | 78 +++++-------- engine/menu/naming_screen.asm | 30 ++--- engine/menu/party_menu.asm | 3 +- engine/menu/players_pc.asm | 3 +- engine/menu/pokedex.asm | 99 ++++++---------- engine/menu/prize_menu.asm | 45 +++----- engine/menu/start_sub_menus.asm | 48 +++----- engine/menu/status_screen.asm | 93 +++++---------- engine/menu/vending_machine.asm | 9 +- engine/oak_speech.asm | 12 +- engine/oak_speech2.asm | 12 +- engine/overworld/cinnabar_lab.asm | 3 +- engine/overworld/doors.asm | 3 +- engine/overworld/ledges.asm | 3 +- engine/overworld/movement.asm | 3 +- engine/overworld/player_animations.asm | 3 +- engine/overworld/pokemart.asm | 6 +- engine/save.asm | 27 ++--- engine/titlescreen.asm | 18 +-- engine/town_map.asm | 36 ++---- engine/trade.asm | 45 +++----- engine/trade2.asm | 30 ++--- home.asm | 53 +++------ home/overworld.asm | 21 ++-- home/text.asm | 60 ++++------ home/vcopy.asm | 9 +- macros.asm | 34 +++++- main.asm | 93 +++++---------- scripts/bikeshop.asm | 6 +- scripts/celadongamecorner.asm | 24 ++-- scripts/celadonmartroof.asm | 3 +- scripts/vermiliondock.asm | 3 +- 53 files changed, 519 insertions(+), 975 deletions(-) (limited to 'home') diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 0ebb3b61..16a3c3f9 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -16,8 +16,7 @@ HallOfFamePC: ; 7405c (1d:405c) call FillMemory ld hl, wTileMap call Func_7417b - FuncCoord 0, 14 - ld hl, Coord + hlCoord 0, 14 call Func_7417b ld a, $c0 ld [rBGP], a ; $ff47 @@ -62,8 +61,7 @@ DisplayCreditsMon: ; 740cb (1d:40cb) ld a,[hl] ld [wcf91],a ld [wd0b5],a - FuncCoord 8, 6 - ld hl,Coord + hlCoord 8, 6 call GetMonHeader call LoadFrontSpriteByMonIndex ld hl,vBGMap0 + $c @@ -153,8 +151,7 @@ Func_7417b: ; 7417b (1d:417b) jp FillMemory FillMiddleOfScreenWithWhite: ; 74183 (1d:4183) - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld bc, $c8 ; 10 rows of 20 tiles each ld a, $7f ; blank white tile jp FillMemory @@ -164,8 +161,7 @@ Credits: ; 7418e (1d:418e) push de .asm_74192 pop de - FuncCoord 9, 6 - ld hl, Coord + hlCoord 9, 6 push hl call FillMiddleOfScreenWithWhite pop hl @@ -241,12 +237,10 @@ Credits: ; 7418e (1d:418e) ld hl, vChars2 + $600 ld bc, (BANK(TheEndGfx) << 8) + $0a call CopyVideoData - FuncCoord 4, 8 - ld hl, Coord + hlCoord 4, 8 ld de, TheEndTextString call PlaceString - FuncCoord 4, 9 - ld hl, Coord + hlCoord 4, 9 inc de call PlaceString jp Func_740ba diff --git a/engine/battle/1.asm b/engine/battle/1.asm index 7e744dba..04546313 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -67,12 +67,10 @@ Func_7861: ; 7861 (1:7861) .asm_789c ld a, [H_WHOSETURN] ; $fff3 and a - FuncCoord 10, 9 - ld hl, Coord + hlCoord 10, 9 ld a, $1 jr z, .asm_78aa - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 xor a .asm_78aa ld [wListMenuID], a ; wListMenuID diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index 5523ba7d..b3b24007 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -2,8 +2,7 @@ Func_708ca: ; 708ca (1c:48ca) ld a, $e4 ld [rOBP1], a ; $ff49 call Func_7092a - FuncCoord 12, 0 - ld hl, Coord + hlCoord 12, 0 ld bc, $707 call ClearScreenArea call Delay3 @@ -287,8 +286,7 @@ BattleTransition_Spiral: ; 70a72 (1c:4a72) call BattleTransition_InwardSpiral jr .done .outwardSpiral - FuncCoord 10, 10 - ld hl, Coord + hlCoord 10, 10 ld a, $3 ld [wd09f], a ld a, l @@ -457,28 +455,20 @@ BattleTransition_Shrink: ; 70b7f (1c:4b7f) push bc xor a ld [H_AUTOBGTRANSFERENABLED], a - FuncCoord 0, 7 - ld hl, Coord - FuncCoord 0, 8 - ld de, Coord + hlCoord 0, 7 + deCoord 0, 8 ld bc, $ffd8 call BattleTransition_CopyTiles1 - FuncCoord 0, 10 - ld hl, Coord - FuncCoord 0, 9 - ld de, Coord + hlCoord 0, 10 + deCoord 0, 9 ld bc, $28 call BattleTransition_CopyTiles1 - FuncCoord 8, 0 - ld hl, Coord - FuncCoord 9, 0 - ld de, Coord + hlCoord 8, 0 + deCoord 9, 0 ld bc, $fffe call BattleTransition_CopyTiles2 - FuncCoord 11, 0 - ld hl, Coord - FuncCoord 10, 0 - ld de, Coord + hlCoord 11, 0 + deCoord 10, 0 ld bc, $2 call BattleTransition_CopyTiles2 ld a, $1 @@ -499,25 +489,19 @@ BattleTransition_Split: ; 70bca (1c:4bca) ld [H_AUTOBGTRANSFERENABLED], a .loop push bc - FuncCoord 0, 16 - ld hl, Coord - FuncCoord 0, 17 - ld de, Coord + hlCoord 0, 16 + deCoord 0, 17 ld bc, $ffd8 call BattleTransition_CopyTiles1 - FuncCoord 0, 1 - ld hl, Coord + hlCoord 0, 1 ld de, wTileMap ld bc, $28 call BattleTransition_CopyTiles1 - FuncCoord 18, 0 - ld hl, Coord - FuncCoord 19, 0 - ld de, Coord + hlCoord 18, 0 + deCoord 19, 0 ld bc, $fffe call BattleTransition_CopyTiles2 - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 ld de, wTileMap ld bc, $2 call BattleTransition_CopyTiles2 @@ -615,8 +599,7 @@ BattleTransition_CopyTiles2: ; 70c3f (1c:4c3f) BattleTransition_VerticalStripes: ; 70c7e (1c:4c7e) ld c, $12 ld hl, wTileMap - FuncCoord 1, 17 - ld de, Coord + deCoord 1, 17 xor a ld [H_AUTOBGTRANSFERENABLED], a .loop @@ -655,8 +638,7 @@ BattleTransition_VerticalStripes_: ; 70caa (1c:4caa) BattleTransition_HorizontalStripes: ; 70cb4 (1c:4cb4) ld c, $14 ld hl, wTileMap - FuncCoord 19, 1 - ld de, Coord + deCoord 19, 1 xor a ld [H_AUTOBGTRANSFERENABLED], a .loop @@ -777,104 +759,84 @@ BattleTransition_Circle_Sub2: ; 70d50 (1c:4d50) BattleTransition_HalfCircle1: ; 70d61 (1c:4d61) db $01 dw BattleTransition_CircleData1 - FuncCoord 18, 6 - dw Coord + dwCoord 18, 6 db $01 dw BattleTransition_CircleData2 - FuncCoord 19, 3 - dw Coord + dwCoord 19, 3 db $01 dw BattleTransition_CircleData3 - FuncCoord 18, 0 - dw Coord + dwCoord 18, 0 db $01 dw BattleTransition_CircleData4 - FuncCoord 14, 0 - dw Coord + dwCoord 14, 0 db $01 dw BattleTransition_CircleData5 - FuncCoord 10, 0 - dw Coord + dwCoord 10, 0 db $00 dw BattleTransition_CircleData5 - FuncCoord 9, 0 - dw Coord + dwCoord 9, 0 db $00 dw BattleTransition_CircleData4 - FuncCoord 5, 0 - dw Coord + dwCoord 5, 0 db $00 dw BattleTransition_CircleData3 - FuncCoord 1, 0 - dw Coord + dwCoord 1, 0 db $00 dw BattleTransition_CircleData2 - FuncCoord 0, 3 - dw Coord + dwCoord 0, 3 db $00 dw BattleTransition_CircleData1 - FuncCoord 1, 6 - dw Coord + dwCoord 1, 6 BattleTransition_HalfCircle2: ; 70d93 (1c:4d93) db $00 dw BattleTransition_CircleData1 - FuncCoord 1, 11 - dw Coord + dwCoord 1, 11 db $00 dw BattleTransition_CircleData2 - FuncCoord 0, 14 - dw Coord + dwCoord 0, 14 db $00 dw BattleTransition_CircleData3 - FuncCoord 1, 17 - dw Coord + dwCoord 1, 17 db $00 dw BattleTransition_CircleData4 - FuncCoord 5, 17 - dw Coord + dwCoord 5, 17 db $00 dw BattleTransition_CircleData5 - FuncCoord 9, 17 - dw Coord + dwCoord 9, 17 db $01 dw BattleTransition_CircleData5 - FuncCoord 10, 17 - dw Coord + dwCoord 10, 17 db $01 dw BattleTransition_CircleData4 - FuncCoord 14, 17 - dw Coord + dwCoord 14, 17 db $01 dw BattleTransition_CircleData3 - FuncCoord 18, 17 - dw Coord + dwCoord 18, 17 db $01 dw BattleTransition_CircleData2 - FuncCoord 19, 14 - dw Coord + dwCoord 19, 14 db $01 dw BattleTransition_CircleData1 - FuncCoord 18, 11 - dw Coord + dwCoord 18, 11 BattleTransition_Circle_Sub3: ; 70dc5 (1c:4dc5) push hl diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index db9d076f..c5c62796 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -18,8 +18,7 @@ Func_137aa: ; 137aa (4:77aa) jr z, .asm_137de ld de, DrawText .asm_137de - FuncCoord 6, 8 - ld hl, Coord + hlCoord 6, 8 call PlaceString ld c, $c8 call DelayFrames @@ -110,8 +109,7 @@ Func_13870: ; 13870 (4:7870) jr z, .asm_13905 ld [wd0db], a .asm_1389e - FuncCoord 9, 9 - ld hl, Coord + hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] cp c @@ -145,8 +143,7 @@ Func_13870: ; 13870 (4:7870) .asm_138d7 ld c, [hl] ld hl, W_GRASSMONS ; wd888 - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 cp $14 jr nz, .asm_138e5 ld hl, W_WATERMONS ; wd8a5 (aliases: wEnemyMon1HP) @@ -250,14 +247,12 @@ RecoilEffect_: ; 1392c (4:792c) ld [hli], a ld [hl], a .asm_13982 - FuncCoord 10, 9 - ld hl, Coord + hlCoord 10, 9 ld a, [H_WHOSETURN] ; $fff3 and a ld a, $1 jr z, .asm_13990 - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 xor a .asm_13990 ld [wListMenuID], a ; wListMenuID diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 8fad427a..cc598de4 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -754,8 +754,7 @@ DoBallTossSpecialEffects: ; 78f3e (1e:4f3e) cp a,1 ret nz .moveGhostMarowakLeft - FuncCoord 17,0 - ld hl,Coord + hlCoord 17, 0 ld de,20 ld bc,$0707 ; 7 rows and 7 columns .loop @@ -854,8 +853,7 @@ DoExplodeSpecialEffects: ; 79009 (1e:5009) cp a,1 ; is it the end of the subanimation? jr nz,FlashScreenEveryFourFrameBlocks ; if it's the end of the subanimation, make the attacking pokemon disappear - FuncCoord 1, 5 - ld hl,Coord + hlCoord 1, 5 jp AnimationHideMonPic ; make pokemon disappear ; flashes the screen when subanimation counter is 1 modulo 4 @@ -1561,11 +1559,9 @@ AnimationMoveMonHorizontally: ; 793f9 (1e:53f9) call AnimationHideMonPic ld a, [H_WHOSETURN] ; $fff3 and a - FuncCoord 2, 5 - ld hl, Coord + hlCoord 2, 5 jr z, .asm_79407 - FuncCoord 11, 0 - ld hl, Coord + hlCoord 11, 0 .asm_79407 xor a push hl @@ -1676,16 +1672,12 @@ AnimationSquishMonPic: ; 794a1 (1e:54a1) ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_794b1 - FuncCoord 16, 0 - ld hl, Coord - FuncCoord 14, 0 - ld de, Coord + hlCoord 16, 0 + deCoord 14, 0 jr .asm_794b7 .asm_794b1 - FuncCoord 5, 5 - ld hl, Coord - FuncCoord 3, 5 - ld de, Coord + hlCoord 5, 5 + deCoord 3, 5 .asm_794b7 push de xor a @@ -1889,12 +1881,10 @@ Func_795f8: ; 795f8 (1e:55f8) ld a, [H_WHOSETURN] ; $fff3 and a jr z, .asm_79602 - FuncCoord 12, 0 - ld hl, Coord + hlCoord 12, 0 jr .asm_79605 .asm_79602 - FuncCoord 0, 5 - ld hl, Coord + hlCoord 0, 5 .asm_79605 ld d, $8 .asm_79607 @@ -2128,8 +2118,7 @@ Func_79793: ; 79793 (1e:5793) xor a ld [W_SPRITEFLIPPED], a call GetMonHeader - FuncCoord 12, 0 - ld hl, Coord + hlCoord 12, 0 call LoadFrontSpriteByMonIndex jr .asm_797d3 .asm_797b0 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 4f382df7..b3495a29 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -96,8 +96,7 @@ Func_3c04c: ; 3c04c (f:404c) ld a, $1 ld [wd125], a call DisplayTextBoxID - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 ld bc, $307 call ClearScreenArea call DisableLCD @@ -171,8 +170,7 @@ Func_3c04c: ; 3c04c (f:404c) ld [H_AUTOBGTRANSFERENABLED], a ; $ffba ld a, $31 ld [$ffe1], a - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 predef Func_3f0c6 xor a ld [$ffb0], a @@ -309,8 +307,7 @@ Func_3c1ad: ; 3c1ad (f:41ad) ld [wcf91], a ld [wBattleMonSpecies2], a call LoadScreenTilesFromBuffer1 - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 ld a, $9 call Func_3c8df call SaveScreenTilesToBuffer1 @@ -736,14 +733,12 @@ HandlePoisonBurnLeechSeed_IncreaseEnemyHP: ; 3c4a3 (f:44a3) ret UpdateCurMonHPBar: ; 3c4f6 (f:44f6) - FuncCoord 10, 9 - ld hl, Coord ; tile pointer to player HP bar + hlCoord 10, 9 ; tile pointer to player HP bar ld a, [H_WHOSETURN] ; $fff3 and a ld a, $1 jr z, .playersTurn - FuncCoord 2, 2 - ld hl, Coord ; tile pointer to enemy HP bar + hlCoord 2, 2 ; tile pointer to enemy HP bar xor a .playersTurn push bc @@ -828,10 +823,8 @@ FaintEnemyPokemon ; 0x3c567 ld hl, wccf1 ld [hli], a ld [hl], a - FuncCoord 12, 5 - ld hl, Coord - FuncCoord 12, 6 - ld de, Coord + hlCoord 12, 5 + deCoord 12, 6 call Func_3c893 ld hl, wTileMap ld bc, $40b @@ -1063,14 +1056,11 @@ Func_3c741: ; 3c741 (f:4741) ld [hl], a ld [wBattleMonStatus], a ; wBattleMonStatus call ReadPlayerMonCurHPAndStatus - FuncCoord 9, 7 - ld hl, Coord + hlCoord 9, 7 ld bc, $50b call ClearScreenArea - FuncCoord 1, 10 - ld hl, Coord - FuncCoord 1, 11 - ld de, Coord + hlCoord 1, 10 + deCoord 1, 11 call Func_3c893 ld a, $1 ld [wcf0b], a @@ -1096,8 +1086,7 @@ Func_3c79b: ; 3c79b (f:479b) ld hl, UseNextMonText call PrintText .asm_3c7ad - FuncCoord 13, 9 - ld hl, Coord + hlCoord 13, 9 ld bc, $a0e ld a, $14 ld [wd125], a @@ -1333,8 +1322,7 @@ Func_3c92a: ; 3c92a (f:492a) ld [wAICount],a ld hl,W_PLAYERBATTSTATUS1 res 5,[hl] - FuncCoord 18, 0 - ld hl,Coord + hlCoord 18, 0 ld a,8 call Func_3c8df call Func_3ee94 @@ -1404,8 +1392,7 @@ Func_3c92a: ; 3c92a (f:492a) jr nz,.next4 ld hl, TrainerAboutToUseText call PrintText - FuncCoord 0, 7 - ld hl,Coord + hlCoord 0, 7 ld bc,$0801 ld a,$14 ld [wd125],a @@ -1456,8 +1443,7 @@ Func_3c92a: ; 3c92a (f:492a) call LoadMonFrontSprite ld a,$CF ld [$FFE1],a - FuncCoord 15, 6 - ld hl,Coord + hlCoord 15, 6 predef Func_3f073 ld a,[wEnemyMonSpecies2] call PlayCry @@ -1777,8 +1763,7 @@ Func_3cca4: ; 3cca4 (f:4ca4) ld [H_WHOSETURN], a ; $fff3 ld a, POOF_ANIM call PlayMoveAnimation - FuncCoord 4, 11 - ld hl, Coord + hlCoord 4, 11 predef Func_3f073 ld a, [wcf91] call PlayCry @@ -1786,12 +1771,10 @@ Func_3cca4: ; 3cca4 (f:4ca4) jp SaveScreenTilesToBuffer1 Func_3ccfa: ; 3ccfa (f:4cfa) - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 ld bc, $707 call ClearScreenArea - FuncCoord 3, 7 - ld hl, Coord + hlCoord 3, 7 ld bc, $505 xor a ld [wcd6c], a @@ -1800,8 +1783,7 @@ Func_3ccfa: ; 3ccfa (f:4cfa) ld c, $4 call DelayFrames call Func_3cd3a - FuncCoord 4, 9 - ld hl, Coord + hlCoord 4, 9 ld bc, $303 ld a, $1 ld [wcd6c], a @@ -1811,12 +1793,10 @@ Func_3ccfa: ; 3ccfa (f:4cfa) call Delay3 call Func_3cd3a ld a, $4c - FuncCoord 5, 11 - ld [Coord], a + Coorda 5, 11 Func_3cd3a: ; 3cd3a (f:4d3a) - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 ld bc, $707 jp ClearScreenArea @@ -1839,17 +1819,14 @@ Func_3cd5a: ; 3cd5a (f:4d5a) Func_3cd60: ; 3cd60 (f:4d60) xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - FuncCoord 9, 7 - ld hl, Coord + hlCoord 9, 7 ld bc, $50b call ClearScreenArea callab PlacePlayerHUDTiles - FuncCoord 18, 9 - ld hl, Coord + hlCoord 18, 9 ld [hl], $73 ld de, wBattleMonNick - FuncCoord 10, 7 - ld hl, Coord + hlCoord 10, 7 call Func_3ce9c call PlaceString ld hl, wBattleMonSpecies @@ -1860,8 +1837,7 @@ Func_3cd60: ; 3cd60 (f:4d60) ld de, wcfb9 ld bc, $b call CopyData - FuncCoord 14, 8 - ld hl, Coord + hlCoord 14, 8 push hl inc hl ld de, wcf9c @@ -1872,8 +1848,7 @@ Func_3cd60: ; 3cd60 (f:4d60) .asm_3cdae ld a, [wcf98] ld [wcf91], a - FuncCoord 10, 9 - ld hl, Coord + hlCoord 10, 9 predef DrawHP ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -1910,12 +1885,10 @@ Func_3cdec: ; 3cdec (f:4dec) call ClearScreenArea callab PlaceEnemyHUDTiles ld de, wEnemyMonNick - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 call Func_3ce9c call PlaceString - FuncCoord 4, 1 - ld hl, Coord + hlCoord 4, 1 push hl inc hl ld de, wEnemyMonStatus ; wcfe9 @@ -1984,8 +1957,7 @@ Func_3cdec: ; 3cdec (f:4dec) Func_3ce7f: ; 3ce7f (f:4e7f) xor a ld [wListMenuID], a ; wListMenuID - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 call DrawHPBar ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -2055,14 +2027,12 @@ InitBattleMenu: ; 3ceb3 (f:4eb3) ld bc, $b call CopyData ; the following simulates the keystrokes by drawing menus on screen - FuncCoord 9, 14 - ld hl, Coord + hlCoord 9, 14 ld [hl], "▶" ld c, $50 call DelayFrames ld [hl], $7f - FuncCoord 9, 16 - ld hl, Coord + hlCoord 9, 16 ld [hl], "▶" ld c, $32 call DelayFrames @@ -2087,19 +2057,14 @@ RegularBattleMenu: ; 3cf1a (f:4f1a) cp $2 ld a, " " jr z, .safaribattle - FuncCoord 15, 14 - ld [Coord], a - FuncCoord 15, 16 - ld [Coord], a + Coorda 15, 14 + Coorda 15, 16 ld b, $9 jr .notsafari .safaribattle - FuncCoord 13, 14 - ld [Coord], a - FuncCoord 13, 16 - ld [Coord], a - FuncCoord 7, 14 - ld hl, Coord + Coorda 13, 14 + Coorda 13, 16 + hlCoord 7, 14 ld de, W_NUMSAFARIBALLS ; W_NUMSAFARIBALLS ld bc, $102 call PrintNumber @@ -2124,19 +2089,14 @@ RegularBattleMenu: ; 3cf1a (f:4f1a) cp $2 ld a, " " jr z, .safarirightcolumn - FuncCoord 9, 14 - ld [Coord], a - FuncCoord 9, 16 - ld [Coord], a + Coorda 9, 14 + Coorda 9, 16 ld b, $f jr .notsafarirightcolumn .safarirightcolumn - FuncCoord 1, 14 - ld [Coord], a - FuncCoord 1, 16 - ld [Coord], a - FuncCoord 7, 14 - ld hl, Coord + Coorda 1, 14 + Coorda 1, 16 + hlCoord 7, 14 ld de, W_NUMSAFARIBALLS ; W_NUMSAFARIBALLS ld bc, $102 call PrintNumber @@ -2328,8 +2288,7 @@ asm_3d0f0: ; 3d0f0 (f:50f0) jp InitBattleMenu Func_3d105: ; 3d105 (f:5105) - FuncCoord 11, 11 - ld hl, Coord + hlCoord 11, 11 ld bc, $81 ld a, $7f call FillMemory @@ -2484,21 +2443,17 @@ MoveSelectionMenu: ; 3d219 (f:5219) ret z ld hl, wBattleMonMoves call .loadmoves - FuncCoord 4, 12 - ld hl, Coord + hlCoord 4, 12 ld b, $4 ld c, $e di call TextBoxBorder - FuncCoord 4, 12 - ld hl, Coord + hlCoord 4, 12 ld [hl], $7a - FuncCoord 10, 12 - ld hl, Coord + hlCoord 10, 12 ld [hl], $7e ei - FuncCoord 6, 13 - ld hl, Coord + hlCoord 6, 13 call .writemoves ld b, $5 ld a, $c @@ -2506,13 +2461,11 @@ MoveSelectionMenu: ; 3d219 (f:5219) .mimicmenu ld hl, wEnemyMonMoves call .loadmoves - FuncCoord 0, 7 - ld hl, Coord + hlCoord 0, 7 ld b, $4 ld c, $e call TextBoxBorder - FuncCoord 2, 8 - ld hl, Coord + hlCoord 2, 8 call .writemoves ld b, $1 ld a, $7 @@ -2523,13 +2476,11 @@ MoveSelectionMenu: ; 3d219 (f:5219) ld bc, $2c call AddNTimes call .loadmoves - FuncCoord 4, 7 - ld hl, Coord + hlCoord 4, 7 ld b, $4 ld c, $e call TextBoxBorder - FuncCoord 6, 8 - ld hl, Coord + hlCoord 6, 8 call .writemoves ld b, $5 ld a, $7 @@ -2584,8 +2535,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) jr z, .battleselect dec a jr nz, .select - FuncCoord 1, 14 - ld hl, Coord + hlCoord 1, 14 ld de, WhichTechniqueString ; $53b8 call PlaceString jr .select @@ -2597,8 +2547,7 @@ Func_3d2fe: ; 3d2fe (f:52fe) ld a, [wcc35] and a jr z, .select - FuncCoord 5, 13 - ld hl, Coord + hlCoord 5, 13 dec a ld bc, $14 call AddNTimes @@ -2834,8 +2783,7 @@ asm_3d4ad: ; 3d4ad (f:54ad) Func_3d4b6: ; 3d4b6 (f:54b6) xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - FuncCoord 0, 8 - ld hl, Coord + hlCoord 0, 8 ld b, $3 ld c, $9 call TextBoxBorder @@ -2848,8 +2796,7 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld a, [wCurrentMenuItem] ; wCurrentMenuItem cp b jr nz, .asm_3d4df - FuncCoord 1, 10 - ld hl, Coord + hlCoord 1, 10 ld de, DisabledText call PlaceString jr .asm_3d54e @@ -2879,29 +2826,23 @@ Func_3d4b6: ; 3d4b6 (f:54b6) ld a, [hl] and $3f ld [wcd6d], a - FuncCoord 1, 9 - ld hl, Coord + hlCoord 1, 9 ld de, TypeText call PlaceString - FuncCoord 7, 11 - ld hl, Coord + hlCoord 7, 11 ld [hl], "/" - FuncCoord 5, 9 - ld hl, Coord + hlCoord 5, 9 ld [hl], "/" - FuncCoord 5, 11 - ld hl, Coord + hlCoord 5, 11 ld de, wcd6d ld bc, $102 call PrintNumber - FuncCoord 8, 11 - ld hl, Coord + hlCoord 8, 11 ld de, wd11e ld bc, $102 call PrintNumber call GetCurrentMove - FuncCoord 2, 10 - ld hl, Coord + hlCoord 2, 10 predef Func_27d98 .asm_3d54e ld a, $1 @@ -4773,8 +4714,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld [wHPBarNewHP+1],a ld a,[hl] ld [wHPBarNewHP],a - FuncCoord 2, 2 - ld hl,Coord + hlCoord 2, 2 xor a ld [wListMenuID],a predef UpdateHPBar2 ; animate the HP bar shortening @@ -4892,8 +4832,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wHPBarMaxHP+1],a ld a,[hl] ld [wHPBarMaxHP],a - FuncCoord 10, 9 - ld hl,Coord + hlCoord 10, 9 ld a,$01 ld [wListMenuID],a predef UpdateHPBar2 ; animate the HP bar shortening @@ -6274,8 +6213,7 @@ Func_3ec92: ; 3ec92 (f:6c92) ld [$0], a ld a, $31 ld [$ffe1], a - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 predef_jump Func_3f0c6 Func_3ed02: ; 3ed02 (f:6d02) @@ -6676,8 +6614,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld [$ffe1], a dec a ld [wAICount], a ; wccdf - FuncCoord 12, 0 - ld hl, Coord + hlCoord 12, 0 predef Func_3f0c6 ld a, $ff ld [wEnemyMonPartyPos], a @@ -6731,8 +6668,7 @@ InitWildBattle: ; 3ef8b (f:6f8b) xor a ld [W_TRAINERCLASS], a ; wd031 ld [$ffe1], a - FuncCoord 12, 0 - ld hl, Coord + hlCoord 12, 0 predef Func_3f0c6 Func_3efeb: ; 3efeb (f:6feb) @@ -6753,12 +6689,10 @@ Func_3efeb: ; 3efeb (f:6feb) ld a, $9c ld [$ffbd], a call LoadScreenTilesFromBuffer1 - FuncCoord 9, 7 - ld hl, Coord + hlCoord 9, 7 ld bc, $50a call ClearScreenArea - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 ld bc, $40a call ClearScreenArea call ClearSprites @@ -6900,8 +6834,7 @@ LoadMonBackPic: ; been loaded with GetMonHeader. ld a, [wBattleMonSpecies2] ld [wcf91], a - FuncCoord 1, 5 - ld hl, Coord + hlCoord 1, 5 ld b, $7 ld c, $8 call ClearScreenArea diff --git a/engine/battle/d.asm b/engine/battle/d.asm index 5a1010b8..d23c9114 100755 --- a/engine/battle/d.asm +++ b/engine/battle/d.asm @@ -1,20 +1,16 @@ Func_372d6: ; 372d6 (d:72d6) call LoadTextBoxTilePatterns - FuncCoord 3, 4 - ld hl, Coord + hlCoord 3, 4 ld b, $7 ld c, $c call TextBoxBorder - FuncCoord 4, 5 - ld hl, Coord + hlCoord 4, 5 ld de, wPlayerName ; wd158 call PlaceString - FuncCoord 4, 10 - ld hl, Coord + hlCoord 4, 10 ld de, W_GRASSRATE ; W_GRASSRATE call PlaceString - FuncCoord 9, 8 - ld hl, Coord + hlCoord 9, 8 ld a, $69 ld [hli], a ld [hl], $6a diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 3e9f3685..8b0476ca 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -67,8 +67,7 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) ld b, $1 call GoPAL_SET callab _LoadTrainerPic - FuncCoord 19, 0 - ld hl, Coord + hlCoord 19, 0 ld c, $0 .asm_396e9 inc c @@ -1173,8 +1172,7 @@ AIRecoverHP: ; 3a6da (e:66da) Func_3a718: ; 3a718 (e:6718) call AIPrintItemUse_ - FuncCoord 2, 2 - ld hl,Coord + hlCoord 2, 2 xor a ld [wListMenuID],a predef UpdateHPBar2 @@ -1489,8 +1487,7 @@ PlacePlayerHUDTiles: ; 3a902 (e:6902) ld de, wTrainerFacingDirection ld bc, $3 call CopyData - FuncCoord 18, 10 - ld hl, Coord + hlCoord 18, 10 ld de, rIE ; $ffff jr PlaceHUDTiles @@ -1505,8 +1502,7 @@ PlaceEnemyHUDTiles: ; 3a919 (e:6919) ld de, wTrainerFacingDirection ld bc, $3 call CopyData - FuncCoord 1, 2 - ld hl, Coord + hlCoord 1, 2 ld de, $1 jr PlaceHUDTiles diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index f6d65301..665807fe 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -85,12 +85,10 @@ HealEffect_: ; 3b9ec (e:79ec) call BankswitchEtoF ld a, [H_WHOSETURN] ; $fff3 and a - FuncCoord 10, 9 - ld hl, Coord + hlCoord 10, 9 ld a, $1 jr z, .asm_3ba83 - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 xor a .asm_3ba83 ld [wListMenuID], a ; wListMenuID diff --git a/engine/cable_club.asm b/engine/cable_club.asm index 75d8bd00..fc049ceb 100755 --- a/engine/cable_club.asm +++ b/engine/cable_club.asm @@ -6,13 +6,11 @@ Func_5317: ; 5317 (1:5317) call LoadFontTilePatterns call LoadHpBarAndStatusTilePatterns call LoadTrainerInfoTextBoxTiles - FuncCoord 3, 8 - ld hl, Coord + hlCoord 3, 8 ld b, $2 ld c, $c call Func_5ab3 - FuncCoord 4, 10 - ld hl, Coord + hlCoord 4, 10 ld de, PleaseWaitString ; $550f call PlaceString ld hl, W_NUMHITS ; wd074 diff --git a/engine/clear_save.asm b/engine/clear_save.asm index 3a296e2e..5ef0d475 100755 --- a/engine/clear_save.asm +++ b/engine/clear_save.asm @@ -5,8 +5,7 @@ Func_1c98a: ; 1c98a (7:498a) call LoadTextBoxTilePatterns ld hl, ClearSaveDataText call PrintText - FuncCoord 14, 7 - ld hl, Coord + hlCoord 14, 7 ld bc, $80f ld a, $7 ld [wd12c], a diff --git a/engine/evolution.asm b/engine/evolution.asm index 8e511182..07ccdbda 100755 --- a/engine/evolution.asm +++ b/engine/evolution.asm @@ -99,8 +99,7 @@ Func_7beb4: ; 7beb4 (1e:7eb4) Func_7beb9: ; 7beb9 (1e:7eb9) call GetMonHeader - FuncCoord 7, 2 - ld hl, Coord + hlCoord 7, 2 jp LoadFlippedFrontSpriteByMonIndex asm_7bec2: ; 7bec2 (1e:7ec2) ld a, $31 @@ -117,8 +116,7 @@ Func_7bed6: ; 7bed6 (1e:7ed6) push bc xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - FuncCoord 7, 2 - ld hl, Coord + hlCoord 7, 2 ld bc, $707 ld de, $d .asm_7bee3 diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index caadce13..f4384b91 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -57,13 +57,11 @@ AnimateHallOfFame: ; 701a0 (1c:41a0) call Func_702e1 ld c, $50 call DelayFrames - FuncCoord 2, 13 - ld hl, Coord + hlCoord 2, 13 ld b, $3 ld c, $e call TextBoxBorder - FuncCoord 4, 15 - ld hl, Coord + hlCoord 4, 15 ld de, HallOfFameText call PlaceString ld c, 180 @@ -113,8 +111,7 @@ Func_70278: ; 70278 (1c:4278) call Func_7033e jr .asm_702ab .asm_7029d - FuncCoord 12, 5 - ld hl, Coord + hlCoord 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex predef LoadMonBackPic @@ -157,27 +154,22 @@ Func_702e1: ; 702e1 (1c:42e1) jp Func_70404 Func_702f0: ; 702f0 (1c:42f0) - FuncCoord 0, 2 - ld hl, Coord + hlCoord 0, 2 ld b, $9 ld c, $a call TextBoxBorder - FuncCoord 2, 6 - ld hl, Coord + hlCoord 2, 6 ld de, HoFMonInfoText call PlaceString - FuncCoord 1, 4 - ld hl, Coord + hlCoord 1, 4 ld de, wcd6d call PlaceString ld a, [wTrainerFacingDirection] - FuncCoord 8, 7 - ld hl, Coord + hlCoord 8, 7 call PrintLevelCommon ld a, [wWhichTrade] ; wWhichTrade ld [wd0b5], a - FuncCoord 3, 9 - ld hl, Coord + hlCoord 3, 9 predef Func_27d6b ld a, [wWhichTrade] ; wWhichTrade jp PlayCry @@ -207,34 +199,28 @@ Func_7033e: ; 7033e (1c:433e) Func_7036d: ; 7036d (1c:436d) ld b, $0 - FuncCoord 12, 5 - ld hl, Coord + hlCoord 12, 5 predef_jump Func_79dda Func_70377: ; 70377 (1c:4377) ld hl, wd747 set 3, [hl] predef DisplayDexRating - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld b, $6 ld c, $a call TextBoxBorder - FuncCoord 5, 0 - ld hl, Coord + hlCoord 5, 0 ld b, $2 ld c, $9 call TextBoxBorder - FuncCoord 7, 2 - ld hl, Coord + hlCoord 7, 2 ld de, wPlayerName ; wd158 call PlaceString - FuncCoord 1, 6 - ld hl, Coord + hlCoord 1, 6 ld de, HoFPlayTimeText call PlaceString - FuncCoord 5, 7 - ld hl, Coord + hlCoord 5, 7 ld de, W_PLAYTIMEHOURS + 1 ld bc, $103 call PrintNumber @@ -243,12 +229,10 @@ Func_70377: ; 70377 (1c:4377) ld de, W_PLAYTIMEMINUTES + 1 ld bc, $8102 call PrintNumber - FuncCoord 1, 9 - ld hl, Coord + hlCoord 1, 9 ld de, HoFMoneyText call PlaceString - FuncCoord 4, 10 - ld hl, Coord + hlCoord 4, 10 ld de, wPlayerMoney ; wPlayerMoney ld c, $a3 call PrintBCDNumber diff --git a/engine/hidden_object_functions17.asm b/engine/hidden_object_functions17.asm index d2408a5b..f0126b65 100755 --- a/engine/hidden_object_functions17.asm +++ b/engine/hidden_object_functions17.asm @@ -77,8 +77,7 @@ DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9) call LoadMonFrontSprite ld a, $80 ld [$ffe1], a - FuncCoord 10, 11 - ld hl, Coord + hlCoord 10, 11 predef Func_3f073 call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 diff --git a/engine/hidden_object_functions3.asm b/engine/hidden_object_functions3.asm index a71ef667..e613df2e 100755 --- a/engine/hidden_object_functions3.asm +++ b/engine/hidden_object_functions3.asm @@ -5,8 +5,7 @@ PrintBookshelfText: ; fb50 (3:7b50) jr nz, .asm_fb7f ld a, [W_CURMAPTILESET] ; W_CURMAPTILESET ld b, a - FuncCoord 8, 7 - ld a, [Coord] + aCoord 8, 7 ld c, a ld hl, BookshelfTileIDs ; $7b8b .asm_fb62 diff --git a/engine/intro.asm b/engine/intro.asm index 2b8c2dbf..801324a5 100755 --- a/engine/intro.asm +++ b/engine/intro.asm @@ -204,8 +204,7 @@ Func_417f0: ; 417f0 (10:57f0) jr asm_417fe Func_417f8: ; 417f8 (10:57f8) - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld bc, $c8 asm_417fe: ; 417fe (10:57fe) ld [hl], $0 @@ -259,8 +258,7 @@ Func_4180e: ; 4180e (10:580e) ret Func_4183f: ; 4183f (10:583f) - FuncCoord 13, 7 - ld hl, Coord + hlCoord 13, 7 Func_41842: ; 41842 (10:5842) ld c, $0 @@ -335,8 +333,7 @@ Func_418e9: ; 418e9 (10:58e9) ld hl, wTileMap ld c, $50 call Func_41807 - FuncCoord 0, 14 - ld hl, Coord + hlCoord 0, 14 ld c, $50 call Func_41807 ld hl, vBGMap1 diff --git a/engine/items/items.asm b/engine/items/items.asm index fbb2ec8f..830f0dfc 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -913,8 +913,7 @@ ItemUseMedicine: ; dabb (3:5abb) sbc b ld [hl],a ld [wHPBarNewHP+1],a - FuncCoord 4, 1 - ld hl,Coord + hlCoord 4, 1 ld a,[wWhichPokemon] ld bc,2 * 20 call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled @@ -2096,8 +2095,7 @@ ItemUseTMHM: ; e479 (3:6479) call PrintText ld hl,TeachMachineMoveText call PrintText - FuncCoord 14,7 - ld hl,Coord + hlCoord 14, 7 ld bc,$080f ld a,$14 ld [wd125],a @@ -2488,8 +2486,7 @@ TossItem_: ; e6f1 (3:66f1) call CopyStringToCF4B ; copy name to wcf4b ld hl,IsItOKToTossItemText call PrintText - FuncCoord 14,7 - ld hl,Coord + hlCoord 14, 7 ld bc,$080f ld a,$14 ld [wd125],a diff --git a/engine/learn_move.asm b/engine/learn_move.asm index 0561abcd..bbfb41a3 100755 --- a/engine/learn_move.asm +++ b/engine/learn_move.asm @@ -76,8 +76,7 @@ DontAbandonLearning: ; 6e5b (1:6e5b) AbandonLearning: ; 6eda (1:6eda) ld hl, AbandonLearningText call PrintText - FuncCoord 14, 7 - ld hl, Coord + hlCoord 14, 7 ld bc, $80f ld a, $14 ld [wd125], a @@ -100,8 +99,7 @@ TryingToLearn: ; 6f07 (1:6f07) push hl ld hl, TryingToLearnText call PrintText - FuncCoord 14, 7 - ld hl, Coord + hlCoord 14, 7 ld bc, $80f ld a, $14 ld [wd125], a @@ -122,13 +120,11 @@ TryingToLearn: ; 6f07 (1:6f07) push hl ld hl, WhichMoveToForgetText call PrintText - FuncCoord 4, 7 - ld hl, Coord + hlCoord 4, 7 ld b, $4 ld c, $e call TextBoxBorder - FuncCoord 6, 8 - ld hl, Coord + hlCoord 6, 8 ld de, wd0e1 ld a, [$fff6] set 2, a diff --git a/engine/menu/bills_pc.asm b/engine/menu/bills_pc.asm index 2640bada..3edaadd8 100644 --- a/engine/menu/bills_pc.asm +++ b/engine/menu/bills_pc.asm @@ -32,18 +32,15 @@ Func_213c8:: ; 213c8 (8:53c8) ld a, [wd7f1] bit 0, a jr nz, .asm_21414 - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld de, SomeonesPCText ; $548b jr .asm_2141a .asm_21414 - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld de, BillsPCText ; $5497 .asm_2141a call PlaceString - FuncCoord 2, 4 - ld hl, Coord + hlCoord 2, 4 ld de, wPlayerName ; wd158 call PlaceString ld l, c @@ -53,8 +50,7 @@ Func_213c8:: ; 213c8 (8:53c8) ld a, [wd74b] bit 5, a jr z, .asm_21462 - FuncCoord 2, 6 - ld hl, Coord + hlCoord 2, 6 ld de, OaksPCText ; $54a5 call PlaceString ld a, [wd5a2] @@ -62,24 +58,20 @@ Func_213c8:: ; 213c8 (8:53c8) jr z, .asm_2145a ld a, $4 ld [wMaxMenuItem], a ; wMaxMenuItem - FuncCoord 2, 8 - ld hl, Coord + hlCoord 2, 8 ld de, PKMNLeaguePCText ; $54b2 call PlaceString - FuncCoord 2, 10 - ld hl, Coord + hlCoord 2, 10 ld de, LogOffPCText ; $54ba jr .asm_2146d .asm_2145a - FuncCoord 2, 8 - ld hl, Coord + hlCoord 2, 8 ld de, LogOffPCText ; $54ba jr .asm_2146d .asm_21462 ld a, $2 ld [wMaxMenuItem], a ; wMaxMenuItem - FuncCoord 2, 6 - ld hl, Coord + hlCoord 2, 6 ld de, LogOffPCText ; $54ba .asm_2146d call PlaceString @@ -146,8 +138,7 @@ BillsPCMenu: ld b, $a ld c, $c call TextBoxBorder - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld de, BillsPCMenuText ; $56e1 call PlaceString ld hl, wTopMenuItemY ; wTopMenuItemY @@ -170,8 +161,7 @@ BillsPCMenu: ld [wPlayerMonNumber], a ; wPlayerMonNumber ld hl, WhatText call PrintText - FuncCoord 9, 14 - ld hl, Coord + hlCoord 9, 14 ld b, $2 ld c, $9 call TextBoxBorder @@ -180,18 +170,15 @@ BillsPCMenu: cp $9 jr c, .asm_2154f sub $9 - FuncCoord 17, 16 - ld hl, Coord + hlCoord 17, 16 ld [hl], $f7 add $f6 jr .asm_21551 .asm_2154f add $f7 .asm_21551 - FuncCoord 18, 16 - ld [Coord], a - FuncCoord 10, 16 - ld hl, Coord + Coorda 18, 16 + hlCoord 10, 16 ld de, BoxNoPCText ; $5713 call PlaceString ld a, $1 @@ -405,8 +392,7 @@ HMMoveArray: ; 21745 (8:5745) db $ff Func_2174b: ; 2174b (8:574b) - FuncCoord 9, 10 - ld hl, Coord + hlCoord 9, 10 ld b, $6 ld c, $9 call TextBoxBorder @@ -416,11 +402,9 @@ Func_2174b: ; 2174b (8:574b) jr nz, .asm_21761 ld de, WithdrawPCText ; $57d3 .asm_21761 - FuncCoord 11, 12 - ld hl, Coord + hlCoord 11, 12 call PlaceString - FuncCoord 11, 14 - ld hl, Coord + hlCoord 11, 14 ld de, StatsCancelPCText ; $57dc call PlaceString ld hl, wTopMenuItemY ; wTopMenuItemY diff --git a/engine/menu/diploma.asm b/engine/menu/diploma.asm index 3bf185fd..023c6177 100755 --- a/engine/menu/diploma.asm +++ b/engine/menu/diploma.asm @@ -33,8 +33,7 @@ DisplayDiploma: ; 566e2 (15:66e2) pop bc dec c jr nz, .asm_56715 ; 0x56725 $ee - FuncCoord 10, 4 - ld hl, Coord + hlCoord 10, 4 ld de, wPlayerName call PlaceString callba Func_44dd diff --git a/engine/menu/league_pc.asm b/engine/menu/league_pc.asm index 46f63420..4833e57d 100755 --- a/engine/menu/league_pc.asm +++ b/engine/menu/league_pc.asm @@ -93,22 +93,18 @@ Func_76610: ; 76610 (1d:6610) ld b, $0B ld c, 0 call GoPAL_SET - FuncCoord 12, 5 - ld hl, Coord + hlCoord 12, 5 call GetMonHeader call LoadFrontSpriteByMonIndex call GBPalNormal - FuncCoord 0, 13 - ld hl, Coord + hlCoord 0, 13 ld b, 2 ld c, $12 call TextBoxBorder - FuncCoord 1, 15 - ld hl, Coord + hlCoord 1, 15 ld de, HallOfFameNoText call PlaceString - FuncCoord 16, 15 - ld hl, Coord + hlCoord 16, 15 ld de, wcd42 ld bc, $0103 call PrintNumber diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index 06c85096..4044da43 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -33,24 +33,20 @@ MainMenu: ; 5af2 (1:5af2) ld a,[wd088] cp a,1 jr z,.next1 - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 ld b,6 ld c,13 call TextBoxBorder - FuncCoord 2,2 - ld hl,Coord + hlCoord 2, 2 ld de,ContinueText call PlaceString jr .next2 .next1 - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 ld b,4 ld c,13 call TextBoxBorder - FuncCoord 2,2 - ld hl,Coord + hlCoord 2, 2 ld de,NewGameText call PlaceString .next2 @@ -142,14 +138,12 @@ LinkMenu: ; 5c0a (1:5c0a) call SaveScreenTilesToBuffer1 ld hl, WhereWouldYouLikeText call PrintText - FuncCoord 5, 5 - ld hl, Coord + hlCoord 5, 5 ld b, $6 ld c, $d call TextBoxBorder call UpdateSprites - FuncCoord 7, 7 - ld hl, Coord + hlCoord 7, 7 ld de, TradeCenterText call PlaceString xor a @@ -238,14 +232,11 @@ LinkMenu: ; 5c0a (1:5c0a) ld c, d .asm_5ccc ld a, b - FuncCoord 6, 7 - ld [Coord], a + Coorda 6, 7 ld a, c - FuncCoord 6, 9 - ld [Coord], a + Coorda 6, 9 ld a, d - FuncCoord 6, 11 - ld [Coord], a + Coorda 6, 11 ld c, $28 call DelayFrames call LoadScreenTilesFromBuffer1 @@ -343,27 +334,21 @@ TradeCenterText: ; 5d97 (1:5d97) ContinueGame: ; 5db5 (1:5db5) xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - FuncCoord 4, 7 - ld hl, Coord + hlCoord 4, 7 ld b, $8 ld c, $e call TextBoxBorder - FuncCoord 5, 9 - ld hl, Coord + hlCoord 5, 9 ld de, SaveScreenInfoText call PlaceString - FuncCoord 12, 9 - ld hl, Coord + hlCoord 12, 9 ld de, wPlayerName ; wd158 call PlaceString - FuncCoord 17, 11 - ld hl, Coord + hlCoord 17, 11 call Func_5e2f - FuncCoord 16, 13 - ld hl, Coord + hlCoord 16, 13 call Func_5e42 - FuncCoord 13, 15 - ld hl, Coord + hlCoord 13, 15 call Func_5e55 ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba @@ -433,35 +418,28 @@ SaveScreenInfoText: ; 5e6a (1:5e6a) next "TIME@" DisplayOptionMenu: ; 5e8a (1:5e8a) - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 ld b,3 ld c,18 call TextBoxBorder - FuncCoord 0,5 - ld hl,Coord + hlCoord 0, 5 ld b,3 ld c,18 call TextBoxBorder - FuncCoord 0,10 - ld hl,Coord + hlCoord 0, 10 ld b,3 ld c,18 call TextBoxBorder - FuncCoord 1,1 - ld hl,Coord + hlCoord 1, 1 ld de,TextSpeedOptionText call PlaceString - FuncCoord 1,6 - ld hl,Coord + hlCoord 1, 6 ld de,BattleAnimationOptionText call PlaceString - FuncCoord 1,11 - ld hl,Coord + hlCoord 1, 11 ld de,BattleStyleOptionText call PlaceString - FuncCoord 2,16 - ld hl,Coord + hlCoord 2, 16 ld de,OptionMenuCancelText call PlaceString xor a @@ -655,8 +633,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) dec hl ld a,[hl] ld [wWhichTrade],a ; text speed cursor X coordinate - FuncCoord 0,3 - ld hl,Coord + hlCoord 0, 3 call .placeUnfilledRightArrow sla c ld a,1 ; On @@ -664,8 +641,7 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) ld a,10 ; Off .storeBattleAnimationCursorX ld [wTrainerEngageDistance],a ; battle animation cursor X coordinate - FuncCoord 0,8 - ld hl,Coord + hlCoord 0, 8 call .placeUnfilledRightArrow sla c ld a,1 @@ -673,12 +649,10 @@ SetCursorPositionsFromOptions: ; 604c (1:604c) ld a,10 .storeBattleStyleCursorX ld [wTrainerFacingDirection],a ; battle style cursor X coordinate - FuncCoord 0,13 - ld hl,Coord + hlCoord 0, 13 call .placeUnfilledRightArrow ; cursor in front of Cancel - FuncCoord 0,16 - ld hl,Coord + hlCoord 0, 16 ld a,1 .placeUnfilledRightArrow ld e,a diff --git a/engine/menu/naming_screen.asm b/engine/menu/naming_screen.asm index e065d98d..17aa96e6 100755 --- a/engine/menu/naming_screen.asm +++ b/engine/menu/naming_screen.asm @@ -13,8 +13,7 @@ AskName: ; 64eb (1:64eb) call GetMonName ld hl, DoYouWantToNicknameText call PrintText - FuncCoord 14, 7 - ld hl, Coord + hlCoord 14, 7 ld bc, $80f ld a, $14 ld [wd125], a @@ -94,8 +93,7 @@ DisplayNamingScreen: ; 6596 (1:6596) call LoadHpBarAndStatusTilePatterns call LoadEDTile callba Func_7176c - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld b, $9 ld c, $12 call TextBoxBorder @@ -341,8 +339,7 @@ PrintAlphabet: ; 676f (1:676f) jr nz, .asm_677e ld de, UpperCaseAlphabet ; $67d6 .asm_677e - FuncCoord 2, 5 - ld hl, Coord + hlCoord 2, 5 ld bc, $509 .asm_6784 push bc @@ -373,16 +370,13 @@ Func_680e: ; 680e (1:680e) call CalcStringLength ld a, c ld [wHPBarMaxHP], a - FuncCoord 10, 2 - ld hl, Coord + hlCoord 10, 2 ld bc, $10a call ClearScreenArea - FuncCoord 10, 2 - ld hl, Coord + hlCoord 10, 2 ld de, wcf4b call PlaceString - FuncCoord 10, 3 - ld hl, Coord + hlCoord 10, 3 ld a, [wd07d] cp $2 jr nc, .asm_6835 @@ -419,8 +413,7 @@ Func_680e: ; 680e (1:680e) .asm_6867 ld c, a ld b, $0 - FuncCoord 10, 3 - ld hl, Coord + hlCoord 10, 3 add hl, bc ld [hl], $77 ret @@ -468,8 +461,7 @@ CalcStringLength: ; 68eb (1:68eb) jr .asm_68f0 PrintNamingText: ; 68f8 (1:68f8) - FuncCoord 0, 1 - ld hl, Coord + hlCoord 0, 1 ld a, [wd07d] ld de, YourTextString ; $693f and a @@ -484,14 +476,12 @@ PrintNamingText: ; 68f8 (1:68f8) pop af ld [wd11e], a call GetMonName - FuncCoord 4, 1 - ld hl, Coord + hlCoord 4, 1 call PlaceString ld hl, $1 add hl, bc ld [hl], $c9 - FuncCoord 1, 3 - ld hl, Coord + hlCoord 1, 3 ld de, NicknameTextString ; $6953 jr .placeString .notNickname diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index d0a74c11..4e47361b 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -30,8 +30,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3) jp z,.printMessage call ErasePartyMenuCursors callba SendBlkPacket_PartyMenu ; loads some data to wcf2e - FuncCoord 3,0 - ld hl,Coord + hlCoord 3, 0 ld de,wPartySpecies xor a ld c,a diff --git a/engine/menu/players_pc.asm b/engine/menu/players_pc.asm index f29ef258..4ff1b16f 100755 --- a/engine/menu/players_pc.asm +++ b/engine/menu/players_pc.asm @@ -26,8 +26,7 @@ Func_790c: ; 790c (1:790c) ld c, $e call TextBoxBorder call UpdateSprites - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld de, PlayersPCMenuEntries ; $7af5 call PlaceString ld hl, wTopMenuItemY ; wTopMenuItemY diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index 4d3f5aaa..63e440f8 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -118,8 +118,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d) pop af ld [wCurrentMenuItem],a push bc - FuncCoord 0,3 - ld hl,Coord + hlCoord 0, 3 ld de,20 ld bc,$7f0d ; 13 blank tiles call DrawTileLine ; cover up the menu cursor in the pokemon list @@ -127,8 +126,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d) ret .buttonBPressed push bc - FuncCoord 15,10 - ld hl,Coord + hlCoord 15, 10 ld de,20 ld bc,$7f07 ; 7 blank tiles call DrawTileLine ; cover up the menu cursor in the side menu @@ -155,53 +153,43 @@ HandlePokedexListMenu: ; 40111 (10:4111) xor a ld [H_AUTOBGTRANSFERENABLED],a ; draw the horizontal line separating the seen and owned amounts from the menu - FuncCoord 15,8 - ld hl,Coord + hlCoord 15, 8 ld a,$7a ; horizontal line tile ld [hli],a ld [hli],a ld [hli],a ld [hli],a ld [hli],a - FuncCoord 14,0 - ld hl,Coord + hlCoord 14, 0 ld [hl],$71 ; vertical line tile - FuncCoord 14,1 - ld hl,Coord + hlCoord 14, 1 call DrawPokedexVerticalLine - FuncCoord 14,9 - ld hl,Coord + hlCoord 14, 9 call DrawPokedexVerticalLine ld hl,wPokedexSeen ld b,wPokedexSeenEnd - wPokedexSeen call CountSetBits ld de,wd11e - FuncCoord 16,3 - ld hl,Coord + hlCoord 16, 3 ld bc,$0103 call PrintNumber ; print number of seen pokemon ld hl,wPokedexOwned ld b,wPokedexOwnedEnd - wPokedexOwned call CountSetBits ld de,wd11e - FuncCoord 16,6 - ld hl,Coord + hlCoord 16, 6 ld bc,$0103 call PrintNumber ; print number of owned pokemon - FuncCoord 16,2 - ld hl,Coord + hlCoord 16, 2 ld de,PokedexSeenText call PlaceString - FuncCoord 16,5 - ld hl,Coord + hlCoord 16, 5 ld de,PokedexOwnText call PlaceString - FuncCoord 1,1 - ld hl,Coord + hlCoord 1, 1 ld de,PokedexContentsText call PlaceString - FuncCoord 16,10 - ld hl,Coord + hlCoord 16, 10 ld de,PokedexMenuItemsText call PlaceString ; find the highest pokedex number among the pokemon the player has seen @@ -223,12 +211,10 @@ HandlePokedexListMenu: ; 40111 (10:4111) .loop xor a ld [H_AUTOBGTRANSFERENABLED],a - FuncCoord 4,2 - ld hl,Coord + hlCoord 4, 2 ld bc,$0e0a call ClearScreenArea - FuncCoord 1,3 - ld hl,Coord + hlCoord 1, 3 ld a,[wListScrollOffset] ld [wd11e],a ld d,7 @@ -422,47 +408,36 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) push af xor a ld [$ffd7],a - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 ld de,1 ld bc,$6414 call DrawTileLine ; draw top border - FuncCoord 0,17 - ld hl,Coord + hlCoord 0, 17 ld b,$6f call DrawTileLine ; draw bottom border - FuncCoord 0,1 - ld hl,Coord + hlCoord 0, 1 ld de,20 ld bc,$6610 call DrawTileLine ; draw left border - FuncCoord 19,1 - ld hl,Coord + hlCoord 19, 1 ld b,$67 call DrawTileLine ; draw right border - FuncCoord 0,0 ld a,$63 ; upper left corner tile - ld [Coord],a - FuncCoord 19,0 + Coorda 0, 0 ld a,$65 ; upper right corner tile - ld [Coord],a - FuncCoord 0,17 + Coorda 19, 0 ld a,$6c ; lower left corner tile - ld [Coord],a - FuncCoord 19,17 + Coorda 0, 17 ld a,$6e ; lower right corner tile - ld [Coord],a - FuncCoord 0,9 - ld hl,Coord + Coorda 19, 17 + hlCoord 0, 9 ld de,PokedexDataDividerLine call PlaceString ; draw horizontal divider line - FuncCoord 9,6 - ld hl,Coord + hlCoord 9, 6 ld de,HeightWeightText call PlaceString call GetMonName - FuncCoord 9,2 - ld hl,Coord + hlCoord 9, 2 call PlaceString ld hl,PokedexEntryPointers ld a,[wd11e] @@ -474,8 +449,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld a,[hli] ld e,a ld d,[hl] ; de = address of pokedex entry - FuncCoord 9,4 - ld hl,Coord + hlCoord 9, 4 call PlaceString ; print species name ld h,b ld l,c @@ -483,8 +457,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld a,[wd11e] push af call IndexToPokedex - FuncCoord 2,8 - ld hl,Coord + hlCoord 2, 8 ld a, "№" ld [hli],a ld a,$f2 @@ -506,8 +479,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) call Delay3 call GBPalNormal call GetMonHeader ; load pokemon picture location - FuncCoord 1,1 - ld hl,Coord + hlCoord 1, 1 call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture ld a,[wcf91] call PlayCry ; play pokemon cry @@ -520,16 +492,14 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description inc de ; de = address of feet (height) ld a,[de] ; reads feet, but a is overwritten without being used - FuncCoord 12,6 - ld hl,Coord + hlCoord 12, 6 ld bc,$0102 call PrintNumber ; print feet (height) ld a,$60 ; feet symbol tile (one tick) ld [hl],a inc de inc de ; de = address of inches (height) - FuncCoord 15,6 - ld hl,Coord + hlCoord 15, 6 ld bc,$8102 call PrintNumber ; print inches (height) ld a,$61 ; inches symbol tile (two ticks) @@ -550,13 +520,11 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) dec de ld a,[de] ; a = lower byte of weight ld [hl],a ; store lower byte of weight in [$ff8c] - FuncCoord 11,8 ld de,$ff8b - ld hl,Coord + hlCoord 11, 8 ld bc,$0205 ; no leading zeroes, right-aligned, 2 bytes, 5 digits call PrintNumber ; print weight - FuncCoord 14,8 - ld hl,Coord + hlCoord 14, 8 ld a,[$ff8c] sub a,10 ld a,[$ff8b] @@ -574,8 +542,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2) ld [$ff8b],a ; restore original value of [$ff8b] pop hl inc hl ; hl = address of pokedex description text - FuncCoord 1,11 - ld bc,Coord + bcCoord 1, 11 ld a,2 ld [$fff4],a call TextCommandProcessor ; print pokedex description text diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index 63bdedee..141b9beb 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -22,8 +22,7 @@ CeladonPrizeMenu: ; 5271b (14:671b) ld a,$01 ld [wTopMenuItemX],a call PrintPrizePrice ; 687A - FuncCoord 0,2 - ld hl,Coord + hlCoord 0, 2 ld b,$08 ld c,$10 call TextBoxBorder @@ -94,50 +93,42 @@ GetPrizeMenuId: ; 5278e (14:678e) ld a,[W_PRIZE1] ld [wd11e],a call GetItemName - FuncCoord 2,4 - ld hl,Coord + hlCoord 2, 4 call PlaceString ld a,[W_PRIZE2] ld [wd11e],a call GetItemName - FuncCoord 2,6 - ld hl,Coord + hlCoord 2, 6 call PlaceString ld a,[W_PRIZE3] ld [wd11e],a call GetItemName - FuncCoord 2,8 - ld hl,Coord + hlCoord 2, 8 call PlaceString jr .putNoThanksText .putMonName ; 14:67EC ld a,[W_PRIZE1] ld [wd11e],a call GetMonName - FuncCoord 2,4 - ld hl,Coord + hlCoord 2, 4 call PlaceString ld a,[W_PRIZE2] ld [wd11e],a call GetMonName - FuncCoord 2,6 - ld hl,Coord + hlCoord 2, 6 call PlaceString ld a,[W_PRIZE3] ld [wd11e],a call GetMonName - FuncCoord 2,8 - ld hl,Coord + hlCoord 2, 8 call PlaceString .putNoThanksText ; 14:6819 - FuncCoord 2,10 - ld hl,Coord + hlCoord 2, 10 ld de,NoThanksText call PlaceString ; put prices on the right side of the textbox ld de,wd141 - FuncCoord 13,5 - ld hl,Coord + hlCoord 13, 5 ; reg. c: ; [low nybble] number of bytes ; [bit 765 = %100] space-padding (not zero-padding) @@ -146,35 +137,29 @@ GetPrizeMenuId: ; 5278e (14:678e) ; used by text-command $02) call PrintBCDNumber ; Print_BCD ld de,wd143 - FuncCoord 13,7 - ld hl,Coord + hlCoord 13, 7 ld c,(%1 << 7 | 2) call PrintBCDNumber ld de,wd145 - FuncCoord 13,9 - ld hl,Coord + hlCoord 13, 9 ld c,(1 << 7 | 2) jp PrintBCDNumber INCLUDE "data/prizes.asm" PrintPrizePrice: ; 5287a (14:687a) - FuncCoord 11,0 - ld hl,Coord + hlCoord 11, 0 ld b,$01 ld c,$07 call TextBoxBorder call UpdateSprites ; XXX save OAM? - FuncCoord 12,0 - ld hl,Coord + hlCoord 12, 0 ld de,.CoinText call PlaceString - FuncCoord 13,1 - ld hl,Coord + hlCoord 13, 1 ld de,.SixSpacesText call PlaceString - FuncCoord 13,1 - ld hl,Coord + hlCoord 13, 1 ld de,wPlayerCoins ld c,%10000010 call PrintBCDNumber diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index bb23321b..7c6fe4d6 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -285,8 +285,7 @@ StartMenu_Pokemon: ; 130a9 (4:70a9) ; writes a blank tile to all possible menu cursor positions on the party menu ErasePartyMenuCursors: ; 132ed (4:72ed) - FuncCoord 0,1 - ld hl,Coord + hlCoord 0, 1 ld bc,2 * 20 ; menu cursor positions are 2 rows apart ld a,6 ; 6 menu cursor positions .loop @@ -331,14 +330,10 @@ StartMenu_Item: ; 13302 (4:7302) .choseItem ; erase menu cursor (blank each tile in front of an item name) ld a," " - FuncCoord 5,4 - ld [Coord],a - FuncCoord 5,6 - ld [Coord],a - FuncCoord 5,8 - ld [Coord],a - FuncCoord 5,10 - ld [Coord],a + Coorda 5, 4 + Coorda 5, 6 + Coorda 5, 8 + Coorda 5, 10 call PlaceUnfilledArrowMenuCursor xor a ld [wcc35],a @@ -531,12 +526,10 @@ DrawTrainerInfo: ; 1349a (4:749a) ld bc,(BANK(RedPicFront) << 8) | $01 predef Predef3B call DisableLCD - FuncCoord 0,2 - ld hl,Coord + hlCoord 0, 2 ld a," " call TrainerInfo_DrawVerticalLine - FuncCoord 1,2 - ld hl,Coord + hlCoord 1, 2 call TrainerInfo_DrawVerticalLine ld hl,vChars2 + $70 ld de,vChars2 @@ -579,8 +572,7 @@ DrawTrainerInfo: ; 1349a (4:749a) dec a ld [hli],a ld [hl],1 - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 call TrainerInfo_DrawTextBox ld hl,wWhichTrade ld a,16 + 1 @@ -588,35 +580,27 @@ DrawTrainerInfo: ; 1349a (4:749a) dec a ld [hli],a ld [hl],3 - FuncCoord 1,10 - ld hl,Coord + hlCoord 1, 10 call TrainerInfo_DrawTextBox - FuncCoord 0,10 - ld hl,Coord + hlCoord 0, 10 ld a,$d7 call TrainerInfo_DrawVerticalLine - FuncCoord 19,10 - ld hl,Coord + hlCoord 19, 10 call TrainerInfo_DrawVerticalLine - FuncCoord 6,9 - ld hl,Coord + hlCoord 6, 9 ld de,TrainerInfo_BadgesText call PlaceString - FuncCoord 2,2 - ld hl,Coord + hlCoord 2, 2 ld de,TrainerInfo_NameMoneyTimeText call PlaceString - FuncCoord 7,2 - ld hl,Coord + hlCoord 7, 2 ld de,wPlayerName call PlaceString - FuncCoord 8,4 - ld hl,Coord + hlCoord 8, 4 ld de,wPlayerMoney ld c,$e3 call PrintBCDNumber - FuncCoord 9,6 - ld hl,Coord + hlCoord 9, 6 ld de,W_PLAYTIMEHOURS + 1 ; hours ld bc,$4103 call PrintNumber diff --git a/engine/menu/status_screen.asm b/engine/menu/status_screen.asm index 3b830244..65b06e9d 100755 --- a/engine/menu/status_screen.asm +++ b/engine/menu/status_screen.asm @@ -40,8 +40,7 @@ StatusScreen: ; 12953 (4:6953) push af xor a ld [$ffd7], a - FuncCoord 19,1 - ld hl, Coord + hlCoord 19, 1 ld bc, $060a call DrawLineBox ; Draws the box around name, HP and status ld de, $fffa @@ -49,66 +48,54 @@ StatusScreen: ; 12953 (4:6953) ld [hl], $f2 ; . after No ("." is a different one) dec hl ld [hl], "№" - FuncCoord 19,9 - ld hl, Coord + hlCoord 19, 9 ld bc, $0806 call DrawLineBox ; Draws the box around types, ID No. and OT - FuncCoord 10,9 - ld hl, Coord + hlCoord 10, 9 ld de, Type1Text call PlaceString ; "TYPE1/" - FuncCoord 11,3 - ld hl, Coord + hlCoord 11, 3 predef DrawHP ; predef $5f ld hl, wcf25 call GetHealthBarColor ld b, $3 call GoPAL_SET ; SGB palette - FuncCoord 16,6 - ld hl, Coord + hlCoord 16, 6 ld de, wcf9c call PrintStatusCondition jr nz, .StatusWritten ; 0x129fc $9 - FuncCoord 16,6 - ld hl, Coord + hlCoord 16, 6 ld de, OKText call PlaceString ; "OK" .StatusWritten - FuncCoord 9,6 - ld hl, Coord + hlCoord 9, 6 ld de, StatusText call PlaceString ; "STATUS/" - FuncCoord 14,2 - ld hl, Coord + hlCoord 14, 2 call PrintLevel ; Pokémon level ld a, [W_MONHDEXNUM] ld [wd11e], a ld [wd0b5], a predef IndexToPokedex - FuncCoord 3,7 - ld hl, Coord + hlCoord 3, 7 ld de, wd11e ld bc, $8103 ; Zero-padded, 3 call PrintNumber ; Pokémon no. - FuncCoord 11,10 - ld hl, Coord + hlCoord 11, 10 predef Func_27d6b ; Prints the type (?) ld hl, NamePointers2 ; $6a9d call .unk_12a7e ld d, h ld e, l - FuncCoord 9,1 - ld hl, Coord + hlCoord 9, 1 call PlaceString ; Pokémon name ld hl, OTPointers ; $6a95 call .unk_12a7e ld d, h ld e, l - FuncCoord 12,16 - ld hl, Coord + hlCoord 12, 16 call PlaceString ; OT - FuncCoord 12,14 - ld hl, Coord + hlCoord 12, 14 ld de, wcfa4 ld bc, $8205 ; 5 call PrintNumber ; ID Number @@ -116,8 +103,7 @@ StatusScreen: ; 12953 (4:6953) call PrintStatsBox call Delay3 call GBPalNormal - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 call LoadFlippedFrontSpriteByMonIndex ; draw Pokémon picture ld a, [wcf91] call PlayCry ; play Pokémon cry @@ -195,23 +181,19 @@ PrintStatsBox: ; 12ae4 (4:6ae4) ld a, d and a ; a is 0 from the status screen jr nz, .DifferentBox ; 0x12ae6 $12 - FuncCoord 0,8 - ld hl, Coord + hlCoord 0, 8 ld b, $8 ld c, $8 call TextBoxBorder ; Draws the box - FuncCoord 1,9 ; Start printing stats from here - ld hl, Coord + hlCoord 1, 9 ; Start printing stats from here ld bc, $0019 ; Number offset jr .PrintStats ; 0x12af8 $10 .DifferentBox - FuncCoord 9,2 - ld hl, Coord + hlCoord 9, 2 ld b, $8 ld c, $9 call TextBoxBorder - FuncCoord 11, 3 - ld hl, Coord + hlCoord 11, 3 ld bc, $0018 .PrintStats push bc @@ -258,20 +240,16 @@ StatusScreen2: ; 12b57 (4:6b57) ld bc, $0004 call CopyData callab Func_39b87 - FuncCoord 9,2 - ld hl, Coord + hlCoord 9, 2 ld bc, $050a call ClearScreenArea ; Clear under name - FuncCoord 19, 3 - ld hl, Coord + hlCoord 19, 3 ld [hl], $78 - FuncCoord 0,8 - ld hl, Coord + hlCoord 0, 8 ld b, $8 ld c, $12 call TextBoxBorder ; Draw move container - FuncCoord 2,9 - ld hl, Coord + hlCoord 2, 9 ld de, wd0e1 call PlaceString ; Print moves ld a, [wcd6c] @@ -280,8 +258,7 @@ StatusScreen2: ; 12b57 (4:6b57) ld a, $4 sub c ld b, a ; Number of moves ? - FuncCoord 11,10 - ld hl, Coord + hlCoord 11, 10 ld de, $0028 ld a, $72 call Func_12ccb ; Print "PP" @@ -293,8 +270,7 @@ StatusScreen2: ; 12b57 (4:6b57) call Func_12ccb ; Fill the rest with -- .InitPP ; 12bbb ld hl, wcfa0 - FuncCoord 14,10 - ld de, Coord + deCoord 14, 10 ld b, $0 .PrintPP ; 12bc3 ld a, [hli] @@ -344,8 +320,7 @@ StatusScreen2: ; 12b57 (4:6b57) cp $4 jr nz, .PrintPP ; 0x12c0f $b2 .PPDone - FuncCoord 9,3 - ld hl, Coord + hlCoord 9, 3 ld de, EXPPointsText call PlaceString ld a, [wcfb9] ; level @@ -355,8 +330,7 @@ StatusScreen2: ; 12b57 (4:6b57) inc a ld [wcfb9], a ; Increase temporarily if not 100 .Level100 - FuncCoord 14,6 - ld hl, Coord + hlCoord 14, 6 ld [hl], $70 ; 1-tile "to" inc hl inc hl @@ -364,27 +338,22 @@ StatusScreen2: ; 12b57 (4:6b57) pop af ld [wcfb9], a ld de, wcfa6 - FuncCoord 12,4 - ld hl, Coord + hlCoord 12, 4 ld bc, $0307 call PrintNumber ; exp call .asm_12c86 ld de, wcfa6 - FuncCoord 7,6 - ld hl, Coord + hlCoord 7, 6 ld bc, $0307 call PrintNumber - FuncCoord 9,0 - ld hl, Coord + hlCoord 9, 0 call Func_12cc3 - FuncCoord 9,1 - ld hl, Coord + hlCoord 9, 1 call Func_12cc3 ld a, [W_MONHDEXNUM] ld [wd11e], a call GetMonName - FuncCoord 9,1 - ld hl, Coord + hlCoord 9, 1 call PlaceString ld a, $1 ld [$ffba], a diff --git a/engine/menu/vending_machine.asm b/engine/menu/vending_machine.asm index 73dece40..c2968e2f 100755 --- a/engine/menu/vending_machine.asm +++ b/engine/menu/vending_machine.asm @@ -17,18 +17,15 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0) ld [wTopMenuItemX], a ; wTopMenuItemX ld hl, wd730 set 6, [hl] - FuncCoord 0, 3 - ld hl, Coord + hlCoord 0, 3 ld b, $8 ld c, $c call TextBoxBorder call UpdateSprites - FuncCoord 2, 5 - ld hl, Coord + hlCoord 2, 5 ld de, DrinkText call PlaceString - FuncCoord 9, 6 - ld hl, Coord + hlCoord 9, 6 ld de, DrinkPriceText call PlaceString ld hl, wd730 diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 314c34df..767b8b5a 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -68,8 +68,7 @@ OakSpeech: ; 6115 (1:6115) ld [wd0b5],a ; pic displayed is stored at this location ld [wcf91],a call GetMonHeader ; this is also related to the pic - FuncCoord 6, 4 - ld hl,Coord ; position on tilemap the pic is displayed + hlCoord 6, 4 ; position on tilemap the pic is displayed call LoadFlippedFrontSpriteByMonIndex ; displays pic? call MovePicLeft ld hl,OakSpeechText2 @@ -143,8 +142,7 @@ Func_61bc: ; 61bc (1:61bc) ld [$2000],a ld c,$14 call DelayFrames - FuncCoord 6, 5 - ld hl,Coord + hlCoord 6, 5 ld b,7 ld c,7 call ClearScreenArea @@ -225,11 +223,9 @@ IntroPredef3B: ; 62a4 (1:62a4) pop bc ld a,c and a - FuncCoord 15, 1 - ld hl,Coord + hlCoord 15, 1 jr nz,.next - FuncCoord 6, 4 - ld hl,Coord + hlCoord 6, 4 .next xor a ld [$FFE1],a diff --git a/engine/oak_speech2.asm b/engine/oak_speech2.asm index 380ff7bf..9d994047 100755 --- a/engine/oak_speech2.asm +++ b/engine/oak_speech2.asm @@ -76,15 +76,13 @@ Func_69ec: ; 69ec (1:69ec) ld bc, $b call CopyData call Delay3 - FuncCoord 12, 4 - ld hl, Coord + hlCoord 12, 4 ld de, $67d ld a, $ff jr asm_6a19 Func_6a12: ; 6a12 (1:6a12) - FuncCoord 5, 4 - ld hl, Coord + hlCoord 5, 4 ld de, $67d xor a asm_6a19: ; 6a19 (1:6a19) @@ -161,13 +159,11 @@ DisplayIntroNameTextBox: ; 6a6c (1:6a6c) ld b, $a ld c, $9 call TextBoxBorder - FuncCoord 3, 0 - ld hl, Coord + hlCoord 3, 0 ld de, .namestring ; $6aa3 call PlaceString pop de - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 call PlaceString call UpdateSprites xor a diff --git a/engine/overworld/cinnabar_lab.asm b/engine/overworld/cinnabar_lab.asm index bb202333..eefa2176 100755 --- a/engine/overworld/cinnabar_lab.asm +++ b/engine/overworld/cinnabar_lab.asm @@ -101,8 +101,7 @@ Func_610c2: ; 610c2 (18:50c2) push hl ld [wd11e], a call GetItemName - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld a, [$ffdb] ld bc, $28 call AddNTimes diff --git a/engine/overworld/doors.asm b/engine/overworld/doors.asm index 6337f511..42ebb174 100755 --- a/engine/overworld/doors.asm +++ b/engine/overworld/doors.asm @@ -10,8 +10,7 @@ HandleDoors: ; 1a609 (6:6609) ld a, [hli] ld h, [hl] ld l, a - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 ld b, a .asm_1a621 ld a, [hli] diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm index b64a1174..43df82e2 100755 --- a/engine/overworld/ledges.asm +++ b/engine/overworld/ledges.asm @@ -8,8 +8,7 @@ HandleLedges: ; 1a672 (6:6672) predef Func_c586 ld a, [wSpriteStateData1 + 9] ld b, a - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 ld c, a ld a, [wcfc6] ld d, a diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index f8dd5fc4..f08a20cb 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -8,8 +8,7 @@ UpdatePlayerSprite: ; 4e31 (1:4e31) ld [wSpriteStateData2], a jr .asm_4e4a .asm_4e41 - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 ld [$ff93], a cp $60 jr c, .asm_4e50 diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm index ee4c999d..a0d8175f 100755 --- a/engine/overworld/player_animations.asm +++ b/engine/overworld/player_animations.asm @@ -349,8 +349,7 @@ Func_70787: ; 70787 (1c:4787) jr z, .asm_707a4 cp c jr nz, .asm_7079e - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 cp [hl] jr z, .asm_707a2 .asm_7079e diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index adae76de..3b06bd2c 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -77,8 +77,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) ld hl,PokemartTellSellPriceText ld bc,$0e01 call PrintText - FuncCoord 14,7 - ld hl,Coord + hlCoord 14, 7 ld bc,$080f ld a,$14 ld [wd125],a @@ -149,8 +148,7 @@ DisplayPokemartDialogue_: ; 6c20 (1:6c20) call CopyStringToCF4B ; copy name to wcf4b ld hl,PokemartTellBuyPriceText call PrintText - FuncCoord 14,7 - ld hl,Coord + hlCoord 14, 7 ld bc,$080f ld a,$14 ld [wd125],a diff --git a/engine/save.asm b/engine/save.asm index 1b8f1467..fcfbd133 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -151,12 +151,10 @@ SaveSAV: ;$770a ret nz .save ;$772d call SaveSAVtoSRAM ;$7848 - FuncCoord 1,13 - ld hl,Coord + hlCoord 1, 13 ld bc,$0412 call ClearScreenArea ; clear area 4x12 starting at 13,1 - FuncCoord 1,14 - ld hl,Coord + hlCoord 1, 14 ld de,NowSavingString call PlaceString ld c,$78 @@ -174,8 +172,7 @@ NowSavingString: SaveSAVConfirm: ; 73768 (1c:7768) call PrintText - FuncCoord 0, 7 - ld hl,Coord + hlCoord 0, 7 ld bc,$0801 ;arrow's coordinates |b = Y|c = X| ld a,$14 ;one line shifting ($28 = 2 lines) ld [wd125],a @@ -435,16 +432,14 @@ Func_7393f: ; 7393f (1c:793f) call TextBoxBorder ld hl, ChooseABoxText call PrintText - FuncCoord 11, 0 - ld hl, Coord + hlCoord 11, 0 ld b, $c ld c, $7 call TextBoxBorder ld hl, $fff6 set 2, [hl] ld de, BoxNames ; $79d9 - FuncCoord 13, 1 - ld hl, Coord + hlCoord 13, 1 call PlaceString ld hl, $fff6 res 2, [hl] @@ -453,23 +448,19 @@ Func_7393f: ; 7393f (1c:793f) cp $9 jr c, .asm_739a6 sub $9 - FuncCoord 8, 2 - ld hl, Coord + hlCoord 8, 2 ld [hl], $f7 add $f6 jr .asm_739a8 .asm_739a6 add $f7 .asm_739a8 - FuncCoord 9, 2 - ld [Coord], a - FuncCoord 1, 2 - ld hl, Coord + Coorda 9, 2 + hlCoord 1, 2 ld de, BoxNoText call PlaceString call Func_73a84 - FuncCoord 18, 1 - ld hl, Coord + hlCoord 18, 1 ld de, wWhichTrade ; wWhichTrade ld bc, $14 ld a, $c diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index 9698da56..10c5fad4 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -68,8 +68,7 @@ ENDC ld a, BANK(Version_GFX) call FarCopyDataDouble call Func_4519 - FuncCoord 2, 1 - ld hl, Coord + hlCoord 2, 1 ld a, $80 ld de, $14 ld c, $6 @@ -85,8 +84,7 @@ ENDC add hl, de dec c jr nz, .asm_434d - FuncCoord 2, 7 - ld hl, Coord + hlCoord 2, 7 ld a, $31 ld b, $10 .asm_4361 @@ -98,8 +96,7 @@ ENDC ld hl, wOAMBuffer + $28 ld a, $74 ld [hl], a - FuncCoord 2, 17 - ld hl, Coord + hlCoord 2, 17 ld de, .titlescreenTilemap ; $437f ld b, $10 .asm_4377 @@ -346,8 +343,7 @@ Func_4519: ; 4519 (1:4519) Func_4524: ; 4524 (1:4524) ld [wcf91], a ld [wd0b5], a - FuncCoord 5, 10 - ld hl, Coord + hlCoord 5, 10 call GetMonHeader jp LoadFrontSpriteByMonIndex @@ -366,8 +362,7 @@ LoadCopyrightTiles: ; 4541 (1:4541) ld hl, vChars2 + $600 ld bc, (BANK(NintendoCopyrightLogoGraphics) << 8) + $1c call CopyVideoData - FuncCoord 2, 7 - ld hl, Coord + hlCoord 2, 7 ld de, CopyrightTextString ; $4556 jp PlaceString @@ -381,8 +376,7 @@ INCLUDE "data/title_mons.asm" ; prints version text (red, blue) PrintGameVersionOnTitleScreen: ; 4598 (1:4598) - FuncCoord 7, 8 - ld hl, Coord + hlCoord 7, 8 ld de, VersionOnTitleScreenText jp PlaceString diff --git a/engine/town_map.asm b/engine/town_map.asm index ea2d3171..2cd37284 100755 --- a/engine/town_map.asm +++ b/engine/town_map.asm @@ -11,8 +11,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e) push af ld b, $0 call Func_711c4 - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 ld de, wcd6d call PlaceString ld hl, wOAMBuffer @@ -57,8 +56,7 @@ Func_70e92: ; 70e92 (1c:4e92) inc de cp $50 jr nz, .asm_70eac - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 ld de, wcd6d call PlaceString ld hl, wOAMBuffer + $10 @@ -120,8 +118,7 @@ LoadTownMap_Nest: ; 70f60 (1c:4f60) push hl call Func_711ef call GetMonName - FuncCoord 1, 0 - ld hl, Coord + hlCoord 1, 0 call PlaceString ld h, b ld l, c @@ -163,33 +160,28 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld b, $0 call Func_711c4 ld hl, wTrainerEngageDistance - FuncCoord 18, 0 - ld de, Coord + deCoord 18, 0 .townMapFlyLoop ld a, $7f ld [de], a push hl push hl - FuncCoord 3, 0 - ld hl, Coord + hlCoord 3, 0 ld bc, $10f call ClearScreenArea pop hl ld a, [hl] ld b, $4 call Func_711c4 - FuncCoord 3, 0 - ld hl, Coord + hlCoord 3, 0 ld de, wcd6d call PlaceString ld c, $f call DelayFrames - FuncCoord 18, 0 - ld hl, Coord + hlCoord 18, 0 ld [hl], $ed - FuncCoord 19, 0 - ld hl, Coord + hlCoord 19, 0 ld [hl], $ee pop hl .asm_71004 @@ -228,8 +220,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld [hl], a ret .asm_71042 - FuncCoord 18, 0 - ld de, Coord + deCoord 18, 0 inc hl ld a, [hl] cp $ff @@ -241,8 +232,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90) ld hl, wTrainerEngageDistance jp .townMapFlyLoop .asm_71058 - FuncCoord 19, 0 - ld de, Coord + deCoord 19, 0 dec hl ld a, [hl] cp $ff @@ -402,13 +392,11 @@ Func_711ef: ; 711ef (1c:51ef) ld a, l and a jr nz, .asm_71236 - FuncCoord 1, 7 - ld hl, Coord + hlCoord 1, 7 ld b, $2 ld c, $f call TextBoxBorder - FuncCoord 2, 9 - ld hl, Coord + hlCoord 2, 9 ld de, AreaUnknownText call PlaceString jr .asm_7123e diff --git a/engine/trade.asm b/engine/trade.asm index 3da1760f..54abdab6 100755 --- a/engine/trade.asm +++ b/engine/trade.asm @@ -181,8 +181,7 @@ Func_41245: ; 41245 (10:5245) ld [$ffae], a xor a ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - FuncCoord 4, 0 - ld hl, Coord + hlCoord 4, 0 ld b, $6 ld c, $a call TextBoxBorder @@ -227,8 +226,7 @@ Func_41298: ; 41298 (10:5298) call DelayFrame ld a, $8b ld [rLCDC], a ; $ff40 - FuncCoord 6, 2 - ld hl, Coord + hlCoord 6, 2 ld b, $7 call Func_41842 call Func_41186 @@ -300,8 +298,7 @@ Func_41336: ; 41336 (10:5336) ld a, $ac call Func_41676 call Func_415c8 - FuncCoord 4, 10 - ld hl, Coord + hlCoord 4, 10 ld b, $6 ld c, $a call TextBoxBorder @@ -318,8 +315,7 @@ Func_41336: ; 41336 (10:5336) ld a, [wTrainerEngageDistance] call PlayCry call Func_41181 - FuncCoord 4, 10 - ld hl, Coord + hlCoord 4, 10 ld bc, $80c call ClearScreenArea jp PrintTradeTakeCareText @@ -406,8 +402,7 @@ Func_41411: ; 41411 (10:5411) Func_4142d: ; 4142d (10:542d) call Func_41196 - FuncCoord 11, 4 - ld hl, Coord + hlCoord 11, 4 ld a, $5d ld [hli], a ld a, $5e @@ -416,25 +411,21 @@ Func_4142d: ; 4142d (10:542d) ld [hli], a dec c jr nz, .asm_4143a - FuncCoord 5, 3 - ld hl, Coord + hlCoord 5, 3 ld b, $6 call Func_41842 - FuncCoord 4, 12 - ld hl, Coord + hlCoord 4, 12 ld b, $2 ld c, $7 call TextBoxBorder - FuncCoord 5, 14 - ld hl, Coord + hlCoord 5, 14 ld de, wPlayerName ; wd158 call PlaceString jp DelayFrame Func_4145c: ; 4145c (10:545c) call Func_41196 - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld a, $5e ld c, $e .asm_41466 @@ -458,25 +449,21 @@ Func_4145c: ; 4145c (10:545c) ld [hld], a ld a, $5d ld [hl], a - FuncCoord 7, 8 - ld hl, Coord + hlCoord 7, 8 ld b, $6 call Func_41842 - FuncCoord 6, 0 - ld hl, Coord + hlCoord 6, 0 ld b, $2 ld c, $7 call TextBoxBorder - FuncCoord 7, 2 - ld hl, Coord + hlCoord 7, 2 ld de, W_GRASSRATE ; W_GRASSRATE call PlaceString jp DelayFrame Func_4149f: ; 4149f (10:549f) call Func_41196 - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 ld a, $5e ld c, $14 .asm_414a9 @@ -487,8 +474,7 @@ Func_4149f: ; 4149f (10:549f) Func_414ae: ; 414ae (10:54ae) push hl - FuncCoord 0, 4 - ld hl, Coord + hlCoord 0, 4 call ScheduleRowRedrawHelper pop hl ld a, h @@ -655,8 +641,7 @@ Func_415a4: ; 415a4 (10:55a4) xor $1 ld [H_AUTOBGTRANSFERENABLED], a ; $ffba call GetMonHeader - FuncCoord 7, 2 - ld hl, Coord + hlCoord 7, 2 call LoadFlippedFrontSpriteByMonIndex ld c, $a jp DelayFrames diff --git a/engine/trade2.asm b/engine/trade2.asm index 496ce24b..b13a18b6 100755 --- a/engine/trade2.asm +++ b/engine/trade2.asm @@ -1,53 +1,43 @@ Func_42769: ; 42769 (10:6769) - FuncCoord 5,0 - ld hl,Coord + hlCoord 5, 0 ld de,OTString67E5 call PlaceString ld a,[wWhichTrade] ld [wd11e],a predef IndexToPokedex - FuncCoord 9, 0 - ld hl,Coord + hlCoord 9, 0 ld de,wd11e ld bc,$8103 call PrintNumber - FuncCoord 5,2 - ld hl,Coord + hlCoord 5, 2 ld de,wcf4b call PlaceString - FuncCoord 8,4 - ld hl,Coord + hlCoord 8, 4 ld de,wTrainerScreenX call PlaceString - FuncCoord 8, 6 - ld hl,Coord + hlCoord 8, 6 ld de,wcd4c ld bc,$8205 jp PrintNumber Func_427a7: ; 427a7 (10:67a7) - FuncCoord 5,10 - ld hl,Coord + hlCoord 5, 10 ld de,OTString67E5 call PlaceString ld a,[wTrainerEngageDistance] ld [wd11e],a predef IndexToPokedex - FuncCoord 9, 10 - ld hl,Coord + hlCoord 9, 10 ld de,wd11e ld bc,$8103 call PrintNumber - FuncCoord 5,12 - ld hl,Coord + hlCoord 5, 12 ld de,wcd6d call PlaceString - FuncCoord 8,14 - ld hl,Coord + hlCoord 8, 14 ld de,wcd4e call PlaceString - FuncCoord 8, 16 - ld hl,Coord + hlCoord 8, 16 ld de,wcd59 ld bc,$8205 jp PrintNumber diff --git a/home.asm b/home.asm index e9dc60c3..dc0b0889 100644 --- a/home.asm +++ b/home.asm @@ -1937,8 +1937,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6) ld [wd125],a call DisplayTextBoxID ; draw the menu text box call UpdateSprites ; move sprites - FuncCoord 4,2 ; coordinates of upper left corner of menu text box - ld hl,Coord + hlCoord 4, 2 ; coordinates of upper left corner of menu text box ld de,$090e ; height and width of menu text box ld a,[wListMenuID] and a ; is it a PC pokemon list? @@ -1974,13 +1973,12 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) jr z,.notOldManBattle .oldManBattle ld a,"▶" - FuncCoord 5,4 - ld [Coord],a ; place menu cursor in front of first menu entry + Coorda 5, 4 ; place menu cursor in front of first menu entry ld c,80 call DelayFrames xor a ld [wCurrentMenuItem],a - ld hl,Coord + hlCoord 5, 4 ld a,l ld [wMenuCursorLocation],a ld a,h @@ -2099,27 +2097,23 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53) DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ; text box dimensions/coordinates for just quantity - FuncCoord 15,9 - ld hl,Coord + hlCoord 15, 9 ld b,1 ; height ld c,3 ; width ld a,[wListMenuID] cp a,PRICEDITEMLISTMENU jr nz,.drawTextBox ; text box dimensions/coordinates for quantity and price - FuncCoord 7,9 - ld hl,Coord + hlCoord 7, 9 ld b,1 ; height ld c,11 ; width .drawTextBox call TextBoxBorder - FuncCoord 16,10 - ld hl,Coord + hlCoord 16, 10 ld a,[wListMenuID] cp a,PRICEDITEMLISTMENU jr nz,.printInitialQuantity - FuncCoord 8,10 - ld hl,Coord + hlCoord 8, 10 .printInitialQuantity ld de,InitialQuantityText call PlaceString @@ -2159,8 +2153,7 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld a,[wcf97] ; max quantity ld [hl],a .handleNewQuantity - FuncCoord 17,10 - ld hl,Coord + hlCoord 17, 10 ld a,[wListMenuID] cp a,PRICEDITEMLISTMENU jr nz,.printQuantity @@ -2199,15 +2192,13 @@ DisplayChooseQuantityMenu:: ; 2d57 (0:2d57) ld a,[$ffa4] ld [$ffa1],a .skipHalvingPrice - FuncCoord 12,10 - ld hl,Coord + hlCoord 12, 10 ld de,SpacesBetweenQuantityAndPriceText call PlaceString ld de,$ff9f ; total price ld c,$a3 call PrintBCDNumber - FuncCoord 9,10 - ld hl,Coord + hlCoord 9, 10 .printQuantity ld de,wcf96 ; current quantity ld bc,$8102 ; print leading zeroes, 1 byte, 2 digits @@ -2246,8 +2237,7 @@ ExitListMenu:: ; 2e3b (0:2e3b) ret PrintListMenuEntries:: ; 2e5a (0:2e5a) - FuncCoord 5, 3 - ld hl,Coord + hlCoord 5, 3 ld b,$09 ld c,$0e call ClearScreenArea @@ -2272,8 +2262,7 @@ PrintListMenuEntries:: ; 2e5a (0:2e5a) jr nc,.noCarry inc d .noCarry - FuncCoord 6,4 ; coordinates of first list entry name - ld hl,Coord + hlCoord 6, 4 ; coordinates of first list entry name ld b,4 ; print 4 names .loop ld a,b @@ -3539,8 +3528,7 @@ Func_35f4:: ; 35f4 (0:35f4) InitYesNoTextBoxParameters:: ; 35ff (0:35ff) xor a ld [wd12c], a - FuncCoord 14, 7 - ld hl, Coord + hlCoord 14, 7 ld bc, $80f ret @@ -3548,8 +3536,7 @@ YesNoChoicePokeCenter:: ; 360a (0:360a) call SaveScreenTilesToBuffer1 ld a, $6 ld [wd12c], a - FuncCoord 11, 6 - ld hl, Coord + hlCoord 11, 6 ld bc, $80c jr DisplayYesNoChoice @@ -3557,8 +3544,7 @@ Func_361a:: ; 361a (0:361a) call SaveScreenTilesToBuffer1 ld a, $3 ld [wd12c], a - FuncCoord 12, 7 - ld hl, Coord + hlCoord 12, 7 ld bc, $080d DisplayYesNoChoice:: ; 3628 (0:3628) ld a, $14 @@ -3995,8 +3981,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865) jr z, .asm_387c call Func_716c6 .asm_387c - FuncCoord 18, 16 - ld hl, Coord + hlCoord 18, 16 call HandleDownArrowBlinkTiming pop hl call JoypadLowSensitivity @@ -4472,8 +4457,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2) and a ; was a key pressed? jr nz,.keyPressed push hl - FuncCoord 18,11 ; coordinates of blinking down arrow in some menus - ld hl,Coord + hlCoord 18, 11 ; coordinates of blinking down arrow in some menus call HandleDownArrowBlinkTiming ; blink down arrow (if any) pop hl ld a,[wMenuJoypadPollCount] @@ -4734,8 +4718,7 @@ PrintText:: ; 3c49 (0:3c49) call Delay3 pop hl Func_3c59:: ; 3c59 (0:3c59) - FuncCoord 1,14 - ld bc,Coord + bcCoord 1, 14 jp TextCommandProcessor ; converts a big-endian binary number into decimal and prints it diff --git a/home/overworld.asm b/home/overworld.asm index 872d63ee..cf36aba8 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -105,8 +105,7 @@ OverworldLoopLessDelay:: jr nz,.checkForOpponent bit 0,a jr nz,.checkForOpponent - FuncCoord 8, 9 - ld a,[Coord] + aCoord 8, 9 ld [wcf0e],a call DisplayTextID ; display either the start menu or the NPC/sign text ld a,[wcc47] @@ -670,8 +669,7 @@ CheckMapConnections:: ; 07ba (0:07ba) ; function to play a sound when changing maps PlayMapChangeSound:: ; 08c9 (0:08c9) - FuncCoord 8, 8 - ld a,[Coord] ; upper left tile of the 4x4 square the player's sprite is standing on + aCoord 8, 8 ; upper left tile of the 4x4 square the player's sprite is standing on cp a,$0b ; door tile in tileset 0 jr nz,.didNotGoThroughDoor ld a,(SFX_02_57 - SFX_Headers_02) / 3 @@ -1279,8 +1277,7 @@ CheckForJumpingAndTilePairCollisions:: ; 0c2a (0:0c2a) ; if not jumping Func_c44:: ; 0c44 (0:0c44) - FuncCoord 8, 9 - ld a,[Coord] ; tile the player is on + aCoord 8, 9 ; tile the player is on ld [wcf0e],a CheckForTilePairCollisions:: ; 0c4a (0:0c4a) @@ -1694,8 +1691,7 @@ MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85) ; the portion of the map that was newly exposed due to the player's movement ScheduleNorthRowRedraw:: ; 0e91 (0:0e91) - FuncCoord 0, 0 - ld hl,Coord + hlCoord 0, 0 call ScheduleRowRedrawHelper ld a,[wd526] ld [H_SCREENEDGEREDRAWADDR],a @@ -1717,8 +1713,7 @@ ScheduleRowRedrawHelper:: ; 0ea6 (0:0ea6) ret ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) - FuncCoord 0,16 - ld hl,Coord + hlCoord 0, 16 call ScheduleRowRedrawHelper ld a,[wd526] ld l,a @@ -1737,8 +1732,7 @@ ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2) ret ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3) - FuncCoord 18,0 - ld hl,Coord + hlCoord 18, 0 call ScheduleColumnRedrawHelper ld a,[wd526] ld c,a @@ -1776,8 +1770,7 @@ ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2) ret ScheduleWestColumnRedraw:: ; 0f08 (0:0f08) - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 call ScheduleColumnRedrawHelper ld a,[wd526] ld [H_SCREENEDGEREDRAWADDR],a diff --git a/home/text.asm b/home/text.asm index 46c17b07..abcac9fd 100644 --- a/home/text.asm +++ b/home/text.asm @@ -76,8 +76,7 @@ PlaceNextChar:: ; 1956 (0:1956) cp $4F jr nz,.next3 pop hl - FuncCoord 1, 16 - ld hl,Coord + hlCoord 1, 16 push hl jp Next19E8 @@ -270,14 +269,12 @@ Char58:: ; 1a95 (0:1a95) cp 4 jp z,Next1AA2 ld a,$EE - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 Next1AA2:: ; 1aa2 (0:1aa2) call ProtectedDelay3 call ManualTextScroll ld a,$7F - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 Char57:: ; 1aad (0:1aad) pop hl ld de,Char58Text @@ -290,67 +287,56 @@ Char58Text:: ; 1ab3 (0:1ab3) Char51:: ; 1ab4 (0:1ab4) push de ld a,$EE - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 call ProtectedDelay3 call ManualTextScroll - FuncCoord 1, 13 - ld hl,Coord + hlCoord 1, 13 ld bc,$0412 call ClearScreenArea ld c,$14 call DelayFrames pop de - FuncCoord 1, 14 - ld hl,Coord + hlCoord 1, 14 jp Next19E8 Char49:: ; 1ad5 (0:1ad5) push de ld a,$EE - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 call ProtectedDelay3 call ManualTextScroll - FuncCoord 1, 10 - ld hl,Coord + hlCoord 1, 10 ld bc,$0712 call ClearScreenArea ld c,$14 call DelayFrames pop de pop hl - FuncCoord 1, 11 - ld hl,Coord + hlCoord 1, 11 push hl jp Next19E8 Char4B:: ; 1af8 (0:1af8) ld a,$EE - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 call ProtectedDelay3 push de call ManualTextScroll pop de ld a,$7F - FuncCoord 18, 16 - ld [Coord],a + Coorda 18, 16 ;fall through Char4C:: ; 1b0a (0:1b0a) push de call Next1B18 call Next1B18 - FuncCoord 1, 16 - ld hl,Coord + hlCoord 1, 16 pop de jp Next19E8 Next1B18:: ; 1b18 (0:1b18) - FuncCoord 0, 14 - ld hl,Coord - FuncCoord 0, 13 - ld de,Coord + hlCoord 0, 14 + deCoord 0, 13 ld b,$3C .next ld a,[hli] @@ -358,8 +344,7 @@ Next1B18:: ; 1b18 (0:1b18) inc de dec b jr nz,.next - FuncCoord 1, 16 - ld hl,Coord + hlCoord 1, 16 ld a,$7F ld b,$12 .next2 @@ -514,8 +499,7 @@ TextCommand03:: ; 1bb7 (0:1bb7) ; (no arguments) TextCommand05:: ; 1bc5 (0:1bc5) pop hl - FuncCoord 1, 16 - ld bc,Coord ; address of second line of dialogue text box + bcCoord 1, 16 ; address of second line of dialogue text box jp NextTextCommand ; blink arrow and wait for A or B to be pressed @@ -526,14 +510,12 @@ TextCommand06:: ; 1bcc (0:1bcc) cp a,$04 jp z,TextCommand0D ld a,$ee ; down arrow - FuncCoord 18, 16 - ld [Coord],a ; place down arrow in lower right corner of dialogue text box + Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box push bc call ManualTextScroll ; blink arrow and wait for A or B to be pressed pop bc ld a," " - FuncCoord 18, 16 - ld [Coord],a ; overwrite down arrow with blank space + Coorda 18, 16 ; overwrite down arrow with blank space pop hl jp NextTextCommand @@ -542,13 +524,11 @@ TextCommand06:: ; 1bcc (0:1bcc) ; (no arguments) TextCommand07:: ; 1be7 (0:1be7) ld a," " - FuncCoord 18, 16 - ld [Coord],a ; place blank space in lower right corner of dialogue text box + Coorda 18, 16 ; place blank space in lower right corner of dialogue text box call Next1B18 ; scroll up text call Next1B18 pop hl - FuncCoord 1, 16 - ld bc,Coord ; address of second line of dialogue text box + bcCoord 1, 16 ; address of second line of dialogue text box jp NextTextCommand ; execute asm inline diff --git a/home/vcopy.asm b/home/vcopy.asm index 71487cf1..81fcb991 100644 --- a/home/vcopy.asm +++ b/home/vcopy.asm @@ -130,8 +130,7 @@ AutoBgMapTransfer:: ; 1d57 (0:1d57) dec a jr z,.transferMiddleThird .transferBottomThird - FuncCoord 0,12 - ld hl,Coord + hlCoord 0, 12 ld sp,hl ld a,[H_AUTOBGTRANSFERDEST + 1] ld h,a @@ -142,8 +141,7 @@ AutoBgMapTransfer:: ; 1d57 (0:1d57) xor a ; TRANSFERTOP jr .doTransfer .transferTopThird - FuncCoord 0,0 - ld hl,Coord + hlCoord 0, 0 ld sp,hl ld a,[H_AUTOBGTRANSFERDEST + 1] ld h,a @@ -152,8 +150,7 @@ AutoBgMapTransfer:: ; 1d57 (0:1d57) ld a,TRANSFERMIDDLE jr .doTransfer .transferMiddleThird - FuncCoord 0,6 - ld hl,Coord + hlCoord 0, 6 ld sp,hl ld a,[H_AUTOBGTRANSFERDEST + 1] ld h,a diff --git a/macros.asm b/macros.asm index a99a80ea..8244c8c9 100644 --- a/macros.asm +++ b/macros.asm @@ -37,8 +37,38 @@ callab: MACRO ;\1 = X ;\2 = Y -FuncCoord: MACRO -Coord = $C3A0 + 20 * \2 + \1 +hlCoord: MACRO + ld hl, wTileMap + 20 * \2 + \1 + ENDM + +;\1 = X +;\2 = Y +deCoord: MACRO + ld de, wTileMap + 20 * \2 + \1 + ENDM + +;\1 = X +;\2 = Y +bcCoord: MACRO + ld bc, wTileMap + 20 * \2 + \1 + ENDM + +;\1 = X +;\2 = Y +aCoord: MACRO + ld a, [wTileMap + 20 * \2 + \1] + ENDM + +;\1 = X +;\2 = Y +Coorda: MACRO + ld [wTileMap + 20 * \2 + \1], a + ENDM + +;\1 = X +;\2 = Y +dwCoord: MACRO + dw wTileMap + 20 * \2 + \1 ENDM ;\1 = Map Width diff --git a/main.asm b/main.asm index df42f937..32a3db2c 100755 --- a/main.asm +++ b/main.asm @@ -158,8 +158,7 @@ INCLUDE "engine/overworld/oam.asm" INCLUDE "engine/oam_dma.asm" PrintWaitingText: - FuncCoord 3, 10 - ld hl, Coord + hlCoord 3, 10 ld b, $1 ld c, $b ld a, [W_ISINBATTLE] @@ -170,8 +169,7 @@ PrintWaitingText: .asm_4c17 call Func_5ab3 .asm_4c1a - FuncCoord 4, 11 - ld hl, Coord + hlCoord 4, 11 ld de, WaitingText call PlaceString ld c, 50 @@ -920,21 +918,18 @@ DisplayTextIDInit: ; 7096 (1:7096) ld a,[wd74b] bit 5,a ; does the player have the pokedex? ; start menu with pokedex - FuncCoord 10, 0 - ld hl,Coord + hlCoord 10, 0 ld b,$0e ld c,$08 jr nz,.drawTextBoxBorder ; start menu without pokedex - FuncCoord 10, 0 - ld hl,Coord + hlCoord 10, 0 ld b,$0c ld c,$08 jr .drawTextBoxBorder ; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box .notStartMenu - FuncCoord 0, 12 - ld hl,Coord + hlCoord 0, 12 ld b,$04 ld c,$12 .drawTextBoxBorder @@ -992,14 +987,12 @@ DrawStartMenu: ; 710b (1:710b) ld a,[wd74b] bit 5,a ; does the player have the pokedex? ; menu with pokedex - FuncCoord 10, 0 - ld hl,Coord + hlCoord 10, 0 ld b,$0e ld c,$08 jr nz,.drawTextBoxBorder ; shorter menu if the player doesn't have the pokedex - FuncCoord 10, 0 - ld hl,Coord + hlCoord 10, 0 ld b,$0c ld c,$08 .drawTextBoxBorder @@ -1017,8 +1010,7 @@ DrawStartMenu: ; 710b (1:710b) ld [wcc37],a ld hl,wd730 set 6,[hl] ; no pauses between printing each letter - FuncCoord 12, 2 - ld hl,Coord + hlCoord 12, 2 ld a,[wd74b] bit 5,a ; does the player have the pokedex? ; case for not having pokdex @@ -1360,13 +1352,11 @@ Func_74ba: ; 74ba (1:74ba) ld a, $f ld [wd125], a call DisplayTextBoxID - FuncCoord 13, 1 - ld hl, Coord + hlCoord 13, 1 ld b, $1 ld c, $6 call ClearScreenArea - FuncCoord 12, 1 - ld hl, Coord + hlCoord 12, 1 ld de, wPlayerMoney ; wPlayerMoney ld c, $a3 call PrintBCDNumber @@ -1637,22 +1627,19 @@ Func_76e1: ; 76e1 (1:36e1) ld a, [wTrainerScreenX] and a jr nz, .asm_770f - FuncCoord 11, 11 - ld hl, Coord + hlCoord 11, 11 ld b, $5 ld c, $7 call TextBoxBorder call UpdateSprites ld a, $c ld [$fff7], a - FuncCoord 13, 12 - ld hl, Coord + hlCoord 13, 12 ld de, PokemonMenuEntries ; $77c2 jp PlaceString .asm_770f push af - FuncCoord 0, 11 - ld hl, Coord + hlCoord 0, 11 ld a, [wcd42] dec a ld e, a @@ -1675,8 +1662,7 @@ Func_76e1: ; 76e1 (1:36e1) inc b call TextBoxBorder call UpdateSprites - FuncCoord 0, 12 - ld hl, Coord + hlCoord 0, 12 ld a, [wcd42] inc a ld e, a @@ -1723,8 +1709,7 @@ Func_76e1: ; 76e1 (1:36e1) pop hl ld a, [wcd42] ld [$fff7], a - FuncCoord 0, 12 - ld hl, Coord + hlCoord 0, 12 ld a, [wcd42] inc a ld e, a @@ -2191,8 +2176,7 @@ Func_c49d: ; c49d (3:449d) ld h, [hl] ld l, a ld de, $1 - FuncCoord 8, 9 - ld a, [Coord] + aCoord 8, 9 call IsInArray jr nc, .asm_c4c8 ld hl, wd736 @@ -2215,29 +2199,24 @@ PrintSafariZoneSteps: ; c52f (3:452f) ld b, $3 ld c, $7 call TextBoxBorder - FuncCoord 1, 1 - ld hl, Coord + hlCoord 1, 1 ld de, wSafariSteps ; wd70d ld bc, $203 call PrintNumber - FuncCoord 4, 1 - ld hl, Coord + hlCoord 4, 1 ld de, SafariSteps ; $4579 call PlaceString - FuncCoord 1, 3 - ld hl, Coord + hlCoord 1, 3 ld de, SafariBallText call PlaceString ld a, [W_NUMSAFARIBALLS] ; W_NUMSAFARIBALLS cp $a jr nc, .asm_c56d - FuncCoord 5, 3 - ld hl, Coord + hlCoord 5, 3 ld a, $7f ld [hl], a .asm_c56d - FuncCoord 6, 3 - ld hl, Coord + hlCoord 6, 3 ld de, W_NUMSAFARIBALLS ; W_NUMSAFARIBALLS ld bc, $102 jp PrintNumber @@ -2259,29 +2238,25 @@ Func_c589: ; c589 (3:4589) ld a, [wSpriteStateData1 + 9] and a jr nz, .asm_c59d - FuncCoord 8, 11 - ld a, [Coord] + aCoord 8, 11 inc d jr .asm_c5b9 .asm_c59d cp $4 jr nz, .asm_c5a7 - FuncCoord 8, 7 - ld a, [Coord] + aCoord 8, 7 dec d jr .asm_c5b9 .asm_c5a7 cp $8 jr nz, .asm_c5b1 - FuncCoord 6, 9 - ld a, [Coord] + aCoord 6, 9 dec e jr .asm_c5b9 .asm_c5b1 cp $c jr nz, .asm_c5b9 - FuncCoord 10, 9 - ld a, [Coord] + aCoord 10, 9 inc e .asm_c5b9 ld c, a @@ -2300,8 +2275,7 @@ Func_c5be: ; c5be (3:45be) jr nz, .asm_c5d8 ld hl, $ffdb set 0, [hl] - FuncCoord 8, 13 - ld a, [Coord] + aCoord 8, 13 inc d jr .asm_c603 .asm_c5d8 @@ -2309,8 +2283,7 @@ Func_c5be: ; c5be (3:45be) jr nz, .asm_c5e7 ld hl, $ffdb set 1, [hl] - FuncCoord 8, 5 - ld a, [Coord] + aCoord 8, 5 dec d jr .asm_c603 .asm_c5e7 @@ -2318,8 +2291,7 @@ Func_c5be: ; c5be (3:45be) jr nz, .asm_c5f6 ld hl, $ffdb set 2, [hl] - FuncCoord 4, 9 - ld a, [Coord] + aCoord 4, 9 dec e jr .asm_c603 .asm_c5f6 @@ -2327,8 +2299,7 @@ Func_c5be: ; c5be (3:45be) jr nz, .asm_c603 ld hl, $ffdb set 3, [hl] - FuncCoord 12, 9 - ld a, [Coord] + aCoord 12, 9 inc e .asm_c603 ld c, a @@ -2919,13 +2890,11 @@ DrawBadges: ; ea03 (3:6a03) ld [hli], a ld [hl], $60 ; First name - FuncCoord 2, 11 - ld hl, Coord + hlCoord 2, 11 ld de, wcd49 call .DrawBadgeRow - FuncCoord 2, 14 - ld hl, Coord + hlCoord 2, 14 ld de, wcd49 + 4 ; call .DrawBadgeRow ; ret diff --git a/scripts/bikeshop.asm b/scripts/bikeshop.asm index c30829e9..4bd26a7e 100755 --- a/scripts/bikeshop.asm +++ b/scripts/bikeshop.asm @@ -56,12 +56,10 @@ BikeShopText1: ; 1d745 (7:5745) ld c, $f call TextBoxBorder call UpdateSprites - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld de, BikeShopMenuText call PlaceString - FuncCoord 8, 3 - ld hl, Coord + hlCoord 8, 3 ld de, BikeShopMenuPrice call PlaceString ld hl, BikeShopText_1d815 diff --git a/scripts/celadongamecorner.asm b/scripts/celadongamecorner.asm index 2d638044..9746f54e 100755 --- a/scripts/celadongamecorner.asm +++ b/scripts/celadongamecorner.asm @@ -467,40 +467,32 @@ CeladonGameCornerText_48f19: ; 48f19 (12:4f19) CeladonGameCornerScript_48f1e: ; 48f1e (12:4f1e) ld hl, wd730 set 6, [hl] - FuncCoord 11, 0 - ld hl, Coord + hlCoord 11, 0 ld b, $5 ld c, $7 call TextBoxBorder call UpdateSprites - FuncCoord 12, 1 - ld hl, Coord + hlCoord 12, 1 ld b, $4 ld c, $7 call ClearScreenArea - FuncCoord 12, 2 - ld hl, Coord + hlCoord 12, 2 ld de, GameCornerMoneyText call PlaceString - FuncCoord 12, 3 - ld hl, Coord + hlCoord 12, 3 ld de, GameCornerBlankText1 call PlaceString - FuncCoord 12, 3 - ld hl, Coord + hlCoord 12, 3 ld de, wPlayerMoney ld c, $a3 call PrintBCDNumber - FuncCoord 12, 4 - ld hl, Coord + hlCoord 12, 4 ld de, GameCornerCoinText call PlaceString - FuncCoord 12, 5 - ld hl, Coord + hlCoord 12, 5 ld de, GameCornerBlankText2 call PlaceString - FuncCoord 15, 5 - ld hl, Coord + hlCoord 15, 5 ld de, wPlayerCoins ld c, $82 call PrintBCDNumber diff --git a/scripts/celadonmartroof.asm b/scripts/celadonmartroof.asm index 02f2959d..37025525 100755 --- a/scripts/celadonmartroof.asm +++ b/scripts/celadonmartroof.asm @@ -200,8 +200,7 @@ CeladonMartRoofScript_48532: ; 48532 (12:4532) push hl ld [wd11e], a call GetItemName - FuncCoord 2, 2 - ld hl, Coord + hlCoord 2, 2 ld a, [$ffdb] ld bc, $28 call AddNTimes diff --git a/scripts/vermiliondock.asm b/scripts/vermiliondock.asm index 215bf467..03dc4377 100755 --- a/scripts/vermiliondock.asm +++ b/scripts/vermiliondock.asm @@ -53,8 +53,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) call DelayFrames ld b, $9c call CopyScreenTileBufferToVRAM - FuncCoord 0, 10 - ld hl, Coord + hlCoord 0, 10 ld bc, $0078 ld a, $14 call FillMemory -- cgit v1.3.1-sl0p