diff options
Diffstat (limited to 'engine/bank3c')
-rw-r--r-- | engine/bank3c/main.asm | 116 | ||||
-rw-r--r-- | engine/bank3c/overworld.asm | 242 |
2 files changed, 358 insertions, 0 deletions
diff --git a/engine/bank3c/main.asm b/engine/bank3c/main.asm new file mode 100644 index 00000000..92f5634c --- /dev/null +++ b/engine/bank3c/main.asm @@ -0,0 +1,116 @@ +INCLUDE "engine/bank3c/overworld.asm" + +ResetStatusAndHalveMoneyOnBlackout:: ; f0274 (3c:4274) +; Reset player status on blackout. + xor a + ld [wd435],a + xor a ; gamefreak copypasting functions (double xor a) + ld [wBattleResult], a + ld [wWalkBikeSurfState], a + ld [W_ISINBATTLE], a + ld [wMapPalOffset], a + ld [wNPCMovementScriptFunctionNum], a + ld [hJoyHeld], a + ld [wNPCMovementScriptPointerTableNum], a + ld [wFlags_0xcd60], a + + ld [$ff9f], a + ld [$ff9f + 1], a + ld [$ff9f + 2], a + call HasEnoughMoney + jr c, .lostmoney ; never happens + + ; Halve the player's money. + ld a, [wPlayerMoney] + ld [$ff9f], a + ld a, [wPlayerMoney + 1] + ld [$ff9f + 1], a + ld a, [wPlayerMoney + 2] + ld [$ff9f + 2], a + xor a + ld [$ffa2], a + ld [$ffa3], a + ld a, 2 + ld [$ffa4], a + predef DivideBCDPredef3 + ld a, [$ffa2] + ld [wPlayerMoney], a + ld a, [$ffa2 + 1] + ld [wPlayerMoney + 1], a + ld a, [$ffa2 + 2] + ld [wPlayerMoney + 2], a + +.lostmoney + ld hl, wd732 + set 2, [hl] + res 3, [hl] + set 6, [hl] + ld a, %11111111 + ld [wJoyIgnore], a + predef_jump HealParty + +Func_f02da:: ; f02da (3c:42da) + ld a,[W_CURMAP] + cp VERMILION_GYM ; ??? new thing about verm gym? + jr z,.asm_f02ee + ld c,a + ld hl,Pointer_f02fa +.asm_f02e5 + ld a,[hli] + cp c + jr z,.asm_f02f4 + cp a,$ff + jr nz,.asm_f02e5 + ret +.asm_f02ee + ld hl,wd126 + set 6,[hl] + ret +.asm_f02f4 + ld hl,wd126 + set 5,[hl] + ret + +Pointer_f02fa:: ; f02fa (3c:42fa) + db $cf,$d0,$d1,$d2,$d3,$d4 + db $d5,$e9,$ea,$eb,$d6,$d7 + db $d8,$a5,$a6,$87,$c7,$ca + db $c6,$6c,$c2,$71,$f5,$f6 + db $f7,$ff + +BeachHouse_GFX:: ; f0314 (3c:4314) + INCBIN "gfx/tilesets/beachhouse.2bpp" + +BeachHouse_Block:: ; f0914 (3c:4914) + INCBIN "gfx/blocksets/beachhouse.bst" + +Func_f0a55:: ; f0a55 (3c:4a55) + ld hl,Pointer_f0a76 ; 3c:4a76 +.loop + ld a,[hli] + cp a,$ff + ret z + ld b,a + ld a,[W_CURMAP] + cp b + jr z,.asm_f0a68 + inc hl + inc hl + inc hl + jr .loop + +.asm_f0a68 + ld a,[hli] + ld c,a + ld b,$0 + ld a,[hli] + ld h,[hl] + ld l,a + ld de,W_MISSABLEOBJECTLIST + call CopyData + ret + +Pointer_f0a76:: ; f0a76 (3c:4a76) + db $27,$07,$7b,$4a,$ff + db $01,$ec,$02,$ed,$03,$ee,$ff + diff --git a/engine/bank3c/overworld.asm b/engine/bank3c/overworld.asm new file mode 100644 index 00000000..778244d6 --- /dev/null +++ b/engine/bank3c/overworld.asm @@ -0,0 +1,242 @@ +_AdvancePlayerSprite:: ; f010c (3c:410c) + 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,[wMapViewVRAMPointer] + ld e,a + and a,$e0 + ld d,a + ld a,e + add a,$02 + and a,$1f + or d + ld [wMapViewVRAMPointer],a + jr .adjustXCoordWithinBlock +.checkIfMovingWest + cp a,$ff + jr nz,.checkIfMovingSouth +; moving west + ld a,[wMapViewVRAMPointer] + ld e,a + and a,$e0 + ld d,a + ld a,e + sub a,$02 + and a,$1f + or d + ld [wMapViewVRAMPointer],a + jr .adjustXCoordWithinBlock +.checkIfMovingSouth + ld a,b + cp a,$01 + jr nz,.checkIfMovingNorth +; moving south + ld a,[wMapViewVRAMPointer] + add a,$40 + ld [wMapViewVRAMPointer],a + jr nc,.adjustXCoordWithinBlock + ld a,[wMapViewVRAMPointer + 1] + inc a + and a,$03 + or a,$98 + ld [wMapViewVRAMPointer + 1],a + jr .adjustXCoordWithinBlock +.checkIfMovingNorth + cp a,$ff + jr nz,.adjustXCoordWithinBlock +; moving north + ld a,[wMapViewVRAMPointer] + sub a,$40 + ld [wMapViewVRAMPointer],a + jr nc,.adjustXCoordWithinBlock + ld a,[wMapViewVRAMPointer + 1] + dec a + and a,$03 + or a,$98 + ld [wMapViewVRAMPointer + 1],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,wXOffsetSinceLastSpecialWarp + inc [hl] + ld de,wCurrentTileBlockMapViewPointer + 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,wXOffsetSinceLastSpecialWarp + dec [hl] + ld de,wCurrentTileBlockMapViewPointer + 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,wYOffsetSinceLastSpecialWarp + inc [hl] + ld de,wCurrentTileBlockMapViewPointer + 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,wYOffsetSinceLastSpecialWarp + dec [hl] + ld de,wCurrentTileBlockMapViewPointer + 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,[hSCY] + add b + ld [hSCY],a ; update background scroll Y + ld a,[hSCX] + add c + ld [hSCX],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 + +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
\ No newline at end of file |