more movement stuff

This commit is contained in:
YamaArashi 2015-07-15 13:58:21 -07:00
parent 7b676f5851
commit ac78dda7d8
9 changed files with 192 additions and 137 deletions

View file

@ -188,7 +188,7 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
call LoadDEPlusA ; a = [wNPCMovementDirections + $fe] (?)
jr .determineDirection
.randomMovement
call getTileSpriteStandsOn
call GetTileSpriteStandsOn
call Random
.determineDirection
ld b, a
@ -504,7 +504,7 @@ CheckSpriteAvailability: ; 50dc (1:50dc)
.skipXVisibilityTest
; make the sprite invisible if a text box is in front of it
; $5F is the maximum number for map tiles
call getTileSpriteStandsOn
call GetTileSpriteStandsOn
ld d, $60
ld a, [hli]
cp d
@ -685,7 +685,7 @@ CanWalkOntoTile: ; 516e (1:516e)
; calculates the tile pointer pointing to the tile the current sprite stancs on
; this is always the lower left tile of the 2x2 tile blocks all sprites are snapped to
; hl: output pointer
getTileSpriteStandsOn: ; 5207 (1:5207)
GetTileSpriteStandsOn: ; 5207 (1:5207)
ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET]
add $4
@ -724,6 +724,10 @@ LoadDEPlusA: ; 522f (1:522f)
ret
DoScriptedNPCMovement: ; 5236 (1:5236)
; This is an alternative method of scripting an NPC's movement and is only used
; a few times in the game. It is used when the NPC and player must walk together
; in sync, such as when the player is following the NPC somewhere. An NPC can't
; be moved in sync with the player using the other method.
ld a, [wd730]
bit 7, a
ret z
@ -740,28 +744,28 @@ DoScriptedNPCMovement: ; 5236 (1:5236)
.noCarry
ld a, [hl]
; check if moving up
cp $40
cp NPC_MOVEMENT_UP
jr nz, .checkIfMovingDown
call GetSpriteScreenYPointer
ld c, SPRITE_FACING_UP
ld a, -2
jr .move
.checkIfMovingDown
cp $0
cp NPC_MOVEMENT_DOWN
jr nz, .checkIfMovingLeft
call GetSpriteScreenYPointer
ld c, SPRITE_FACING_DOWN
ld a, 2
jr .move
.checkIfMovingLeft
cp $80
cp NPC_MOVEMENT_LEFT
jr nz, .checkIfMovingRight
call GetSpriteScreenXPointer
ld c, SPRITE_FACING_LEFT
ld a, -2
jr .move
.checkIfMovingRight
cp $c0
cp NPC_MOVEMENT_RIGHT
jr nz, .noMatch
call GetSpriteScreenXPointer
ld c, SPRITE_FACING_RIGHT
@ -781,11 +785,11 @@ DoScriptedNPCMovement: ; 5236 (1:5236)
ld a, c
ld [hl], a ; facing direction
call AnimScriptedNPCMovement
ld hl, wcf18
ld hl, wScriptedNPCWalkCounter
dec [hl]
ret nz
ld a, $8
ld [wcf18], a
ld a, 8
ld [wScriptedNPCWalkCounter], a
ld hl, wNPCMovementDirections2Index
inc [hl]
ret
@ -793,8 +797,8 @@ DoScriptedNPCMovement: ; 5236 (1:5236)
InitScriptedNPCMovement: ; 52a6 (1:52a6)
xor a
ld [wNPCMovementDirections2Index], a
ld a, $8
ld [wcf18], a
ld a, 8
ld [wScriptedNPCWalkCounter], a
jp AnimScriptedNPCMovement
GetSpriteScreenYPointer: ; 52b2 (1:52b2)

View file

@ -44,22 +44,25 @@ _EndNPCMovementScript: ; 1a41d (6:641d)
ld [wSimulatedJoypadStatesEnd], a
ret
ProfOakMovementScriptPointerTable: ; 1a442 (6:6442)
dw Func_1a44c
dw Func_1a485
dw Func_1a4a1
dw Func_1a4a6
dw Func_1a4f4
PalletMovementScriptPointerTable: ; 1a442 (6:6442)
dw PalletMovementScript_OakMoveLeft
dw PalletMovementScript_PlayerMoveLeft
dw PalletMovementScript_WaitAndWalkToLab
dw PalletMovementScript_WalkToLab
dw PalletMovementScript_Done
Func_1a44c: ; 1a44c (6:644c)
PalletMovementScript_OakMoveLeft: ; 1a44c (6:644c)
ld a, [W_XCOORD]
sub $a
ld [wcca1], a
jr z, .asm_1a475
ld b, $0
ld [wNumStepsToTake], a
jr z, .playerOnLeftTile
; The player is on the right tile of the northern path out of Pallet Town and
; Prof. Oak is below.
; Make Prof. Oak step to the left.
ld b, 0
ld c, a
ld hl, wNPCMovementDirections2
ld a, $80
ld a, NPC_MOVEMENT_LEFT
call FillMemory
ld [hl], $ff
ld a, [wSpriteIndex]
@ -68,36 +71,39 @@ Func_1a44c: ; 1a44c (6:644c)
call MoveSprite
ld a, $1
ld [wNPCMovementScriptFunctionNum], a
jr .asm_1a47a
.asm_1a475
jr .done
; The player is on the left tile of the northern path out of Pallet Town and
; Prof. Oak is below.
; Prof. Oak is already on the right tile.
.playerOnLeftTile
ld a, $3
ld [wNPCMovementScriptFunctionNum], a
.asm_1a47a
.done
ld hl, W_FLAGS_D733
set 1, [hl]
ld a, $fc
ld [wJoyIgnore], a
ret
Func_1a485: ; 1a485 (6:6485)
PalletMovementScript_PlayerMoveLeft: ; 1a485 (6:6485)
ld a, [wd730]
bit 0, a
ret nz
ld a, [wcca1]
bit 0, a ; is an NPC being moved by a script?
ret nz ; return if Oak is still moving
ld a, [wNumStepsToTake]
ld [wSimulatedJoypadStatesIndex], a
ld [$ff95], a
ld [hNPCMovementDirections2Index], a
predef ConvertNPCMovementDirectionsToJoypadMasks
call StartSimulatingJoypadStates
ld a, $2
ld [wNPCMovementScriptFunctionNum], a
ret
Func_1a4a1: ; 1a4a1 (6:64a1)
PalletMovementScript_WaitAndWalkToLab: ; 1a4a1 (6:64a1)
ld a, [wSimulatedJoypadStatesIndex]
and a
and a ; is the player done moving left yet?
ret nz
Func_1a4a6: ; 1a4a6 (6:64a6)
PalletMovementScript_WalkToLab: ; 1a4a6 (6:64a6)
xor a
ld [wOverrideSimulatedJoypadStatesMask], a
ld a, [wSpriteIndex]
@ -122,12 +128,12 @@ Func_1a4a6: ; 1a4a6 (6:64a6)
ret
RLEList_ProfOakWalkToLab: ; 1a4dc (6:64dc)
db $00, $05
db $80, $01
db $00, $05
db $C0, $03
db $40, $01
db $E0, $01
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_LEFT, $01
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_RIGHT, $03
db NPC_MOVEMENT_UP, $01
db $E0, $01 ; stand still
db $FF
RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
@ -138,7 +144,7 @@ RLEList_PlayerWalkToLab: ; 1a4e9 (6:64e9)
db D_DOWN, $06
db $FF
Func_1a4f4: ; 1a4f4 (6:64f4)
PalletMovementScript_Done: ; 1a4f4 (6:64f4)
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
@ -152,10 +158,10 @@ Func_1a4f4: ; 1a4f4 (6:64f4)
jp EndNPCMovementScript
PewterMuseumGuyMovementScriptPointerTable: ; 1a510 (6:6510)
dw Func_1a514
dw PewterMovementScriptDone
dw PewterMovementScript_WalkToMuseum
dw PewterMovementScript_Done
Func_1a514: ; 1a514 (6:6514)
PewterMovementScript_WalkToMuseum: ; 1a514 (6:6514)
ld a, BANK(Music_MuseumGuy)
ld [wc0ef], a
ld [wc0f0], a
@ -191,13 +197,13 @@ RLEList_PewterMuseumPlayer: ; 1a559 (6:6559)
db $FF
RLEList_PewterMuseumGuy: ; 1a562 (6:6562)
db $40, $06
db $80, $0D
db $40, $03
db $80, $01
db NPC_MOVEMENT_UP, $06
db NPC_MOVEMENT_LEFT, $0D
db NPC_MOVEMENT_UP, $03
db NPC_MOVEMENT_LEFT, $01
db $FF
PewterMovementScriptDone: ; 1a56b (6:656b)
PewterMovementScript_Done: ; 1a56b (6:656b)
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
@ -208,10 +214,10 @@ PewterMovementScriptDone: ; 1a56b (6:656b)
jp EndNPCMovementScript
PewterGymGuyMovementScriptPointerTable: ; 1a57d (6:657d)
dw Func_1a581
dw PewterMovementScriptDone
dw PewterMovementScript_WalkToGym
dw PewterMovementScript_Done
Func_1a581: ; 1a581 (6:6581)
PewterMovementScript_WalkToGym: ; 1a581 (6:6581)
ld a, BANK(Music_MuseumGuy)
ld [wc0ef], a
ld [wc0f0], a
@ -252,12 +258,12 @@ RLEList_PewterGymPlayer: ; 1a5cd (6:65cd)
db $FF
RLEList_PewterGymGuy: ; 1a5da (6:65da)
db $00, $02
db $80, $0F
db $40, $05
db $80, $0B
db $00, $05
db $C0, $03
db NPC_MOVEMENT_DOWN, $02
db NPC_MOVEMENT_LEFT, $0F
db NPC_MOVEMENT_UP, $05
db NPC_MOVEMENT_LEFT, $0B
db NPC_MOVEMENT_DOWN, $05
db NPC_MOVEMENT_RIGHT, $03
db $FF
FreezeEnemyTrainerSprite: ; 1a5e7 (6:65e7)

View file

@ -16,10 +16,10 @@ PrepareOAMData:
ld [hOAMBufferOffset], a
.spriteLoop
ld [hSpriteDataOffset2], a
ld [hSpriteOffset2], a
ld d, wSpriteStateData1 / $100
ld a, [hSpriteDataOffset2]
ld a, [hSpriteOffset2]
ld e, a
ld a, [de] ; c1x0
and a
@ -139,7 +139,7 @@ PrepareOAMData:
ld [hOAMBufferOffset], a
.nextSprite
ld a, [hSpriteDataOffset2]
ld a, [hSpriteOffset2]
add $10
cp $100 % $100
jp nz, .spriteLoop