This commit is contained in:
YamaArashi 2015-07-19 17:52:26 -07:00
parent e607199397
commit 1d86932cc9
29 changed files with 225 additions and 174 deletions

View file

@ -121,6 +121,18 @@ BOX_DATA EQU 2
DAYCARE_DATA EQU 3 DAYCARE_DATA EQU 3
BATTLE_MON_DATA EQU 4 BATTLE_MON_DATA EQU 4
; player direction constants
PLAYER_DIR_BIT_RIGHT EQU 0
PLAYER_DIR_BIT_LEFT EQU 1
PLAYER_DIR_BIT_DOWN EQU 2
PLAYER_DIR_BIT_UP EQU 3
PLAYER_DIR_RIGHT EQU (1 << PLAYER_DIR_BIT_RIGHT)
PLAYER_DIR_LEFT EQU (1 << PLAYER_DIR_BIT_LEFT)
PLAYER_DIR_DOWN EQU (1 << PLAYER_DIR_BIT_DOWN)
PLAYER_DIR_UP EQU (1 << PLAYER_DIR_BIT_UP)
; serial ; serial
ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01 ESTABLISH_CONNECTION_WITH_INTERNAL_CLOCK EQU $01

View file

@ -6296,7 +6296,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
predef WriteMonMoves ; get moves based on current level predef WriteMonMoves ; get moves based on current level
.loadMovePPs .loadMovePPs
ld hl, wEnemyMonMoves ld hl, wEnemyMonMoves
ld de, wEnemyMonSpecial + 1 ld de, wEnemyMonPP - 1
predef LoadMovePPs predef LoadMovePPs
ld hl, W_MONHBASESTATS ld hl, W_MONHBASESTATS
ld de, wEnemyMonBaseStats ld de, wEnemyMonBaseStats
@ -6957,7 +6957,7 @@ InitBattle_Common: ; 3efeb (f:6feb)
ld [wLetterPrintingDelayFlags], a ld [wLetterPrintingDelayFlags], a
pop af pop af
ld [wMapPalOffset], a ld [wMapPalOffset], a
ld a, [wd0d4] ld a, [wSavedTilesetType]
ld [hTilesetType], a ld [hTilesetType], a
scf scf
ret ret

View file

@ -1,6 +1,6 @@
InitBattleVariables: ; 525af (14:65af) InitBattleVariables: ; 525af (14:65af)
ld a, [hTilesetType] ld a, [hTilesetType]
ld [wd0d4], a ld [wSavedTilesetType], a
xor a xor a
ld [wActionResultOrTookBattleTurn], a ld [wActionResultOrTookBattleTurn], a
ld [wBattleResult], a ld [wBattleResult], a

View file

@ -78,7 +78,7 @@ SafariZoneGameOver: ; 1e9b0 (7:69b0)
ld [H_DOWNARROWBLINKCNT2], a ld [H_DOWNARROWBLINKCNT2], a
call DisplayTextID call DisplayTextID
xor a xor a
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SAFARI_ZONE_ENTRANCE ld a, SAFARI_ZONE_ENTRANCE
ld [H_DOWNARROWBLINKCNT1], a ld [H_DOWNARROWBLINKCNT1], a
ld a, $3 ld a, $3

View file

@ -591,14 +591,14 @@ ItemUseSurfboard: ; d9b4 (3:59b4)
jp LoadWalkingPlayerSpriteGraphics jp LoadWalkingPlayerSpriteGraphics
; uses a simulated button press to make the player move forward ; uses a simulated button press to make the player move forward
.makePlayerMoveForward .makePlayerMoveForward
ld a,[wd52a] ; direction the player is going ld a,[wPlayerDirection] ; direction the player is going
bit 3,a bit PLAYER_DIR_BIT_UP,a
ld b,D_UP ld b,D_UP
jr nz,.storeSimulatedButtonPress jr nz,.storeSimulatedButtonPress
bit 2,a bit PLAYER_DIR_BIT_DOWN,a
ld b,D_DOWN ld b,D_DOWN
jr nz,.storeSimulatedButtonPress jr nz,.storeSimulatedButtonPress
bit 1,a bit PLAYER_DIR_BIT_LEFT,a
ld b,D_LEFT ld b,D_LEFT
jr nz,.storeSimulatedButtonPress jr nz,.storeSimulatedButtonPress
ld b,D_RIGHT ld b,D_RIGHT

View file

@ -107,8 +107,8 @@ MainMenu: ; 5af2 (1:5af2)
.pressedA .pressedA
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call ClearScreen call ClearScreen
ld a,4 ld a,PLAYER_DIR_DOWN
ld [wd52a],a ld [wPlayerDirection],a
ld c,10 ld c,10
call DelayFrames call DelayFrames
ld a,[wNumHoFTeams] ld a,[wNumHoFTeams]

View file

@ -25,24 +25,24 @@ UpdatePlayerSprite: ; 4e31 (1:4e31)
ld a, [wWalkCounter] ld a, [wWalkCounter]
and a and a
jr nz, .moving jr nz, .moving
ld a, [wd528] ld a, [wPlayerMovingDirection]
; check if down ; check if down
bit 2, a bit PLAYER_DIR_BIT_DOWN, a
jr z, .checkIfUp jr z, .checkIfUp
xor a ; ld a, SPRITE_FACING_DOWN xor a ; ld a, SPRITE_FACING_DOWN
jr .next jr .next
.checkIfUp .checkIfUp
bit 3, a bit PLAYER_DIR_BIT_UP, a
jr z, .checkIfLeft jr z, .checkIfLeft
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
jr .next jr .next
.checkIfLeft .checkIfLeft
bit 1, a bit PLAYER_DIR_BIT_LEFT, a
jr z, .checkIfRight jr z, .checkIfRight
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
jr .next jr .next
.checkIfRight .checkIfRight
bit 0, a bit PLAYER_DIR_BIT_RIGHT, a
jr z, .notMoving jr z, .notMoving
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
jr .next jr .next
@ -405,23 +405,23 @@ InitializeSpriteFacingDirection: ; 507f (1:507f)
bit 5, a bit 5, a
jr nz, notYetMoving jr nz, notYetMoving
res 7, [hl] res 7, [hl]
ld a, [wd52a] ld a, [wPlayerDirection]
bit 3, a bit PLAYER_DIR_BIT_UP, a
jr z, .notFacingDown jr z, .notFacingDown
ld c, $0 ; make sprite face down ld c, SPRITE_FACING_DOWN
jr .facingDirectionDetermined jr .facingDirectionDetermined
.notFacingDown .notFacingDown
bit 2, a bit PLAYER_DIR_BIT_DOWN, a
jr z, .notFacingUp jr z, .notFacingUp
ld c, $4 ; make sprite face up ld c, SPRITE_FACING_UP
jr .facingDirectionDetermined jr .facingDirectionDetermined
.notFacingUp .notFacingUp
bit 1, a bit PLAYER_DIR_BIT_LEFT, a
jr z, .notFacingRight jr z, .notFacingRight
ld c, $c ; make sprite face right ld c, SPRITE_FACING_RIGHT
jr .facingDirectionDetermined jr .facingDirectionDetermined
.notFacingRight .notFacingRight
ld c, $8 ; make sprite face left ld c, SPRITE_FACING_LEFT
.facingDirectionDetermined .facingDirectionDetermined
ld a, [H_CURRENTSPRITEOFFSET] ld a, [H_CURRENTSPRITEOFFSET]
add $9 add $9

View file

@ -134,52 +134,52 @@ OverworldLoopLessDelay::
call UpdateSprites call UpdateSprites
ld a,$01 ld a,$01
ld [wcc4b],a ld [wcc4b],a
ld a,[wd528] ; the direction that was pressed last time ld a,[wPlayerMovingDirection] ; the direction that was pressed last time
and a and a
jp z,OverworldLoop jp z,OverworldLoop
; if a direction was pressed last time ; if a direction was pressed last time
ld [wd529],a ; save the last direction ld [wPlayerLastStopDirection],a ; save the last direction
xor a xor a
ld [wd528],a ; zero the direction ld [wPlayerMovingDirection],a ; zero the direction
jp OverworldLoop jp OverworldLoop
.checkIfDownButtonIsPressed .checkIfDownButtonIsPressed
ld a,[hJoyHeld] ; current joypad state ld a,[hJoyHeld] ; current joypad state
bit 7,a ; down button bit 7,a ; down button
jr z,.checkIfUpButtonIsPressed jr z,.checkIfUpButtonIsPressed
ld a,$01 ld a,1
ld [wSpriteStateData1 + 3],a ld [wSpriteStateData1 + 3],a ; delta Y
ld a,$04 ld a,PLAYER_DIR_DOWN
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfUpButtonIsPressed .checkIfUpButtonIsPressed
bit 6,a ; up button bit 6,a ; up button
jr z,.checkIfLeftButtonIsPressed jr z,.checkIfLeftButtonIsPressed
ld a,$ff ld a,-1
ld [wSpriteStateData1 + 3],a ld [wSpriteStateData1 + 3],a ; delta Y
ld a,$08 ld a,PLAYER_DIR_UP
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfLeftButtonIsPressed .checkIfLeftButtonIsPressed
bit 5,a ; left button bit 5,a ; left button
jr z,.checkIfRightButtonIsPressed jr z,.checkIfRightButtonIsPressed
ld a,$ff ld a,-1
ld [wSpriteStateData1 + 5],a ld [wSpriteStateData1 + 5],a ; delta X
ld a,$02 ld a,PLAYER_DIR_LEFT
jr .handleDirectionButtonPress jr .handleDirectionButtonPress
.checkIfRightButtonIsPressed .checkIfRightButtonIsPressed
bit 4,a ; right button bit 4,a ; right button
jr z,.noDirectionButtonsPressed jr z,.noDirectionButtonsPressed
ld a,$01 ld a,1 ; PLAYER_DIR_RIGHT
ld [wSpriteStateData1 + 5],a ld [wSpriteStateData1 + 5],a ; delta X
.handleDirectionButtonPress .handleDirectionButtonPress
ld [wd52a],a ; new direction ld [wPlayerDirection],a ; new direction
ld a,[wd730] ld a,[wd730]
bit 7,a ; are we simulating button presses? bit 7,a ; are we simulating button presses?
jr nz,.noDirectionChange ; ignore direction changes if we are jr nz,.noDirectionChange ; ignore direction changes if we are
ld a,[wcc4b] ld a,[wcc4b]
and a and a
jr z,.noDirectionChange jr z,.noDirectionChange
ld a,[wd52a] ; new direction ld a,[wPlayerDirection] ; new direction
ld b,a ld b,a
ld a,[wd529] ; old direction ld a,[wPlayerLastStopDirection] ; old direction
cp b cp b
jr z,.noDirectionChange jr z,.noDirectionChange
; the code below is strange ; the code below is strange
@ -187,42 +187,42 @@ OverworldLoopLessDelay::
; also, it does a seemingly pointless loop afterwards ; also, it does a seemingly pointless loop afterwards
swap a ; put old direction in upper half swap a ; put old direction in upper half
or b ; put new direction in lower half or b ; put new direction in lower half
cp a,$48 ; change dir from down to up cp a,(PLAYER_DIR_DOWN << 4) | PLAYER_DIR_UP ; change dir from down to up
jr nz,.notDownToUp jr nz,.notDownToUp
ld a,$02 ld a,PLAYER_DIR_LEFT
ld [wd528],a ld [wPlayerMovingDirection],a
jr .oddLoop jr .oddLoop
.notDownToUp .notDownToUp
cp a,$84 ; change dir from up to down cp a,(PLAYER_DIR_UP << 4) | PLAYER_DIR_DOWN ; change dir from up to down
jr nz,.notUpToDown jr nz,.notUpToDown
ld a,$01 ld a,PLAYER_DIR_RIGHT
ld [wd528],a ld [wPlayerMovingDirection],a
jr .oddLoop jr .oddLoop
.notUpToDown .notUpToDown
cp a,$12 ; change dir from right to left cp a,(PLAYER_DIR_RIGHT << 4) | PLAYER_DIR_LEFT ; change dir from right to left
jr nz,.notRightToLeft jr nz,.notRightToLeft
ld a,$04 ld a,PLAYER_DIR_DOWN
ld [wd528],a ld [wPlayerMovingDirection],a
jr .oddLoop jr .oddLoop
.notRightToLeft .notRightToLeft
cp a,$21 ; change dir from left to right cp a,(PLAYER_DIR_LEFT << 4) | PLAYER_DIR_RIGHT ; change dir from left to right
jr nz,.oddLoop jr nz,.oddLoop
ld a,$08 ld a,PLAYER_DIR_UP
ld [wd528],a ld [wPlayerMovingDirection],a
.oddLoop .oddLoop
ld hl,wFlags_0xcd60 ld hl,wFlags_0xcd60
set 2,[hl] set 2,[hl]
ld hl,wcc4b ld hl,wcc4b
dec [hl] dec [hl]
jr nz,.oddLoop jr nz,.oddLoop
ld a,[wd52a] ld a,[wPlayerDirection]
ld [wd528],a ld [wPlayerMovingDirection],a
call NewBattle call NewBattle
jp c,.battleOccurred jp c,.battleOccurred
jp OverworldLoop jp OverworldLoop
.noDirectionChange .noDirectionChange
ld a,[wd52a] ; current direction ld a,[wPlayerDirection] ; current direction
ld [wd528],a ; save direction ld [wPlayerMovingDirection],a ; save direction
call UpdateSprites call UpdateSprites
ld a,[wWalkBikeSurfState] ld a,[wWalkBikeSurfState]
cp a,$02 ; surfing cp a,$02 ; surfing
@ -566,7 +566,7 @@ CheckMapConnections:: ; 07ba (0:07ba)
jp .loadNewMap jp .loadNewMap
.checkEastMap .checkEastMap
ld b,a ld b,a
ld a,[wd525] ; map width ld a,[wCurrentMapWidth2] ; map width
cp b cp b
jr nz,.checkNorthMap jr nz,.checkNorthMap
ld a,[W_MAPCONN4PTR] ld a,[W_MAPCONN4PTR]
@ -628,7 +628,7 @@ CheckMapConnections:: ; 07ba (0:07ba)
jp .loadNewMap jp .loadNewMap
.checkSouthMap .checkSouthMap
ld b,a ld b,a
ld a,[wd524] ld a,[wCurrentMapHeight2]
cp b cp b
jr nz,.didNotEnterConnectedMap jr nz,.didNotEnterConnectedMap
ld a,[W_MAPCONN2PTR] ld a,[W_MAPCONN2PTR]
@ -864,7 +864,7 @@ LoadTilesetTilePatternData:: ; 09e8 (0:09e8)
LoadTileBlockMap:: ; 09fc (0:09fc) LoadTileBlockMap:: ; 09fc (0:09fc)
; fill C6E8-CBFB with the background tile ; fill C6E8-CBFB with the background tile
ld hl,wOverworldMap ld hl,wOverworldMap
ld a,[wd3ad] ; background tile number ld a,[wMapBackgroundTile]
ld d,a ld d,a
ld bc,$0514 ld bc,$0514
.backgroundTileLoop .backgroundTileLoop
@ -1057,15 +1057,15 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02)
IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23) IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
xor a xor a
ld [hSpriteIndexOrTextID],a ld [hSpriteIndexOrTextID],a
ld a,[wd4b0] ; number of signs in the map ld a,[wNumSigns]
and a and a
jr z,.extendRangeOverCounter jr z,.extendRangeOverCounter
; if there are signs ; if there are signs
predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de predef GetTileAndCoordsInFrontOfPlayer ; get the coordinates in front of the player in de
ld hl,wd4b1 ; start of sign coordinates ld hl,wSignCoords
ld a,[wd4b0] ; number of signs in the map ld a,[wNumSigns]
ld b,a ld b,a
ld c,$00 ld c,0
.signLoop .signLoop
inc c inc c
ld a,[hli] ; sign Y ld a,[hli] ; sign Y
@ -1081,8 +1081,8 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
; found sign ; found sign
push hl push hl
push bc push bc
ld hl,wd4d1 ; start of sign text ID's ld hl,wSignTextIDs
ld b,$00 ld b,0
dec c dec c
add hl,bc add hl,bc
ld a,[hl] ld a,[hl]
@ -1097,7 +1097,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
.extendRangeOverCounter .extendRangeOverCounter
predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player in c
ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles) ld hl,W_TILESETTALKINGOVERTILES ; list of tiles that extend talking range (counter tiles)
ld b,$03 ld b,3
ld d,$20 ; talking range in pixels (long range) ld d,$20 ; talking range in pixels (long range)
.counterTilesLoop .counterTilesLoop
ld a,[hli] ld a,[hli]
@ -1111,7 +1111,7 @@ IsSpriteOrSignInFrontOfPlayer:: ; 0b23 (0:0b23)
IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b) IsSpriteInFrontOfPlayer:: ; 0b6b (0:0b6b)
ld d,$10 ; talking range in pixels (normal range) ld d,$10 ; talking range in pixels (normal range)
IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d) IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
ld bc,$3c40 ; Y and X position of player sprite lb bc, $3c, $40 ; Y and X position of player sprite
ld a,[wSpriteStateData1 + 9] ; direction the player is facing ld a,[wSpriteStateData1 + 9] ; direction the player is facing
.checkIfPlayerFacingUp .checkIfPlayerFacingUp
cp SPRITE_FACING_UP cp SPRITE_FACING_UP
@ -1120,7 +1120,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
ld a,b ld a,b
sub d sub d
ld b,a ld b,a
ld a,$08 ld a,PLAYER_DIR_UP
jr .doneCheckingDirection jr .doneCheckingDirection
.checkIfPlayerFacingDown .checkIfPlayerFacingDown
cp SPRITE_FACING_DOWN cp SPRITE_FACING_DOWN
@ -1129,7 +1129,7 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
ld a,b ld a,b
add d add d
ld b,a ld b,a
ld a,$04 ld a,PLAYER_DIR_DOWN
jr .doneCheckingDirection jr .doneCheckingDirection
.checkIfPlayerFacingRight .checkIfPlayerFacingRight
cp SPRITE_FACING_RIGHT cp SPRITE_FACING_RIGHT
@ -1138,16 +1138,16 @@ IsSpriteInFrontOfPlayer2:: ; 0b6d (0:0b6d)
ld a,c ld a,c
add d add d
ld c,a ld c,a
ld a,$01 ld a,PLAYER_DIR_RIGHT
jr .doneCheckingDirection jr .doneCheckingDirection
.playerFacingLeft .playerFacingLeft
; facing left ; facing left
ld a,c ld a,c
sub d sub d
ld c,a ld c,a
ld a,$02 ld a,PLAYER_DIR_LEFT
.doneCheckingDirection .doneCheckingDirection
ld [wd52a],a ld [wPlayerDirection],a
ld a,[W_NUMSPRITES] ; number of sprites ld a,[W_NUMSPRITES] ; number of sprites
and a and a
ret z ret z
@ -1202,7 +1202,7 @@ CollisionCheckOnLand:: ; 0bd1 (0:0bd1)
ld a,[wSimulatedJoypadStatesIndex] ld a,[wSimulatedJoypadStatesIndex]
and a and a
jr nz,.noCollision ; no collisions when the player's movements are being controlled by the game jr nz,.noCollision ; no collisions when the player's movements are being controlled by the game
ld a,[wd52a] ; the direction that the player is trying to go in ld a,[wPlayerDirection] ; the direction that the player is trying to go in
ld d,a ld d,a
ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) 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 and d ; check if a sprite is in the direction the player is trying to go
@ -1893,7 +1893,7 @@ CollisionCheckOnWater:: ; 0fb7 (0:0fb7)
ld a,[wd730] ld a,[wd730]
bit 7,a bit 7,a
jp nz,.noCollision ; return and clear carry if button presses are being simulated 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 a,[wPlayerDirection] ; the direction that the player is trying to go in
ld d,a ld d,a
ld a,[wSpriteStateData1 + 12] ; the player sprite's collision data (bit field) (set in the sprite movement code) 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 and d ; check if a sprite is in the direction the player is trying to go
@ -2073,17 +2073,17 @@ LoadMapHeader:: ; 107c (0:107c)
call CopyMapConnectionHeader call CopyMapConnectionHeader
.getObjectDataPointer .getObjectDataPointer
ld a,[hli] ld a,[hli]
ld [wd3a9],a ld [wObjectDataPointerTemp],a
ld a,[hli] ld a,[hli]
ld [wd3aa],a ld [wObjectDataPointerTemp + 1],a
push hl push hl
ld a,[wd3a9] ld a,[wObjectDataPointerTemp]
ld l,a ld l,a
ld a,[wd3aa] ld a,[wObjectDataPointerTemp + 1]
ld h,a ; hl = base of object data ld h,a ; hl = base of object data
ld de,wd3ad ; background tile ID ld de,wMapBackgroundTile
ld a,[hli] ld a,[hli]
ld [de],a ; save background tile ID ld [de],a
.loadWarpData .loadWarpData
ld a,[hli] ld a,[hli]
ld [wNumberOfWarps],a ld [wNumberOfWarps],a
@ -2103,16 +2103,16 @@ LoadMapHeader:: ; 107c (0:107c)
jr nz,.warpLoop jr nz,.warpLoop
.loadSignData .loadSignData
ld a,[hli] ; number of signs ld a,[hli] ; number of signs
ld [wd4b0],a ; save the number of signs ld [wNumSigns],a
and a ; are there any signs? and a ; are there any signs?
jr z,.loadSpriteData ; if not, skip this jr z,.loadSpriteData ; if not, skip this
ld c,a ld c,a
ld de,wd4d1 ; base address of sign text IDs ld de,wSignTextIDs
ld a,d ld a,d
ld [$ff95],a ld [hSignCoordPointer],a
ld a,e ld a,e
ld [$ff96],a ld [hSignCoordPointer + 1],a
ld de,wd4b1 ; base address of sign coordinates ld de,wSignCoords
.signLoop .signLoop
ld a,[hli] ld a,[hli]
ld [de],a ld [de],a
@ -2121,17 +2121,17 @@ LoadMapHeader:: ; 107c (0:107c)
ld [de],a ld [de],a
inc de inc de
push de push de
ld a,[$ff95] ld a,[hSignCoordPointer]
ld d,a ld d,a
ld a,[$ff96] ld a,[hSignCoordPointer + 1]
ld e,a ld e,a
ld a,[hli] ld a,[hli]
ld [de],a ld [de],a
inc de inc de
ld a,d ld a,d
ld [$ff95],a ld [hSignCoordPointer],a
ld a,e ld a,e
ld [$ff96],a ld [hSignCoordPointer + 1],a
pop de pop de
dec c dec c
jr nz,.signLoop jr nz,.signLoop
@ -2259,10 +2259,10 @@ LoadMapHeader:: ; 107c (0:107c)
pop hl ; restore hl from before going to the warp/sign/sprite data (this value was saved for seemingly no purpose) 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 ld a,[W_CURMAPHEIGHT] ; map height in 4x4 tile blocks
add a ; double it add a ; double it
ld [wd524],a ; store map height in 2x2 tile blocks ld [wCurrentMapHeight2],a ; store map height in 2x2 tile blocks
ld a,[W_CURMAPWIDTH] ; map width in 4x4 tile blocks ld a,[W_CURMAPWIDTH] ; map width in 4x4 tile blocks
add a ; double it add a ; double it
ld [wd525],a ; map width in 2x2 tile blocks ld [wCurrentMapWidth2],a ; map width in 2x2 tile blocks
ld a,[W_CURMAP] ld a,[W_CURMAP]
ld c,a ld c,a
ld b,$00 ld b,$00

View file

@ -82,6 +82,9 @@ hTilePlayerStandingOn EQU $FF93
hSpritePriority EQU $FF94 hSpritePriority EQU $FF94
; 2 bytes
hSignCoordPointer EQU $FF95
hNPCMovementDirections2Index EQU $FF95 hNPCMovementDirections2Index EQU $FF95
; CalcPositionOfPlayerRelativeToNPC ; CalcPositionOfPlayerRelativeToNPC

View file

@ -44,15 +44,15 @@ CeruleanCityScript0: ; 194c8 (6:54c8)
jr nc, .asm_194f7 jr nc, .asm_194f7
ld a, [wCoordIndex] ld a, [wCoordIndex]
cp $1 cp $1
ld a, $8 ld a, PLAYER_DIR_UP
ld b, SPRITE_FACING_DOWN ld b, SPRITE_FACING_DOWN
jr nz, .asm_194e6 jr nz, .asm_194e6
ld a, $4 ld a, PLAYER_DIR_DOWN
ld b, SPRITE_FACING_UP ld b, SPRITE_FACING_UP
.asm_194e6 .asm_194e6
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, b ld a, b
ld [wSpriteStateData1 + $29], a ld [wSpriteStateData1 + 2 * $10 + $9], a
call Delay3 call Delay3
ld a, $2 ld a, $2
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a

View file

@ -54,14 +54,14 @@ CinnabarGymScript0: ; 757ae (1d:57ae)
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
cp $4 cp $4
jr nz, .asm_757c3 jr nz, .asm_757c3
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld de, MovementData_757d7 ld de, MovementData_757d7
jr .asm_757cb jr .asm_757cb
.asm_757c3 .asm_757c3
ld de, MovementData_757da ld de, MovementData_757da
ld a, $1 ld a, PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
.asm_757cb .asm_757cb
call MoveSprite call MoveSprite
ld a, $1 ld a, $1

View file

@ -24,8 +24,8 @@ CinnabarIslandScript0: ; 1ca38 (7:4a38)
ld a, [W_XCOORD] ld a, [W_XCOORD]
cp $12 cp $12
ret nz ret nz
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $8 ld a, $8
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID

View file

@ -42,8 +42,8 @@ FightingDojoScript1: ; 5cd83 (17:4d83)
ret nz ret nz
ld a, $1 ld a, $1
ld [wcf0d], a ld [wcf0d], a
ld a, $1 ld a, PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT
@ -61,8 +61,8 @@ FightingDojoScript3: ; 5cdc6 (17:4dc6)
ld a, [wcf0d] ld a, [wcf0d]
and a and a
jr z, .asm_5cde4 jr z, .asm_5cde4
ld a, $1 ld a, PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT

View file

@ -139,8 +139,8 @@ GaryScript5: ; 7601a (1d:601a)
ld a, [wd730] ld a, [wd730]
bit 0, a bit 0, a
ret nz ret nz
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_LEFT ld a, SPRITE_FACING_LEFT

View file

@ -80,19 +80,19 @@ HallofFameRoomScript1: ; 5a52b (16:652b)
ld a, [wSimulatedJoypadStatesIndex] ld a, [wSimulatedJoypadStatesIndex]
and a and a
ret nz ret nz
ld a, $1 ld a, PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
call SetSpriteMovementBytesToFF call SetSpriteMovementBytesToFF
ld a, $8 ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
call Delay3 call Delay3
xor a xor a
ld [wJoyIgnore], a ld [wJoyIgnore], a
inc a inc a ; PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [hSpriteIndexOrTextID], a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID

View file

@ -178,8 +178,8 @@ OaksLabScript6: ; 1cc36 (7:4c36)
ld a, D_UP ld a, D_UP
ld [wSimulatedJoypadStatesEnd], a ld [wSimulatedJoypadStatesEnd], a
call StartSimulatingJoypadStates call StartSimulatingJoypadStates
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $7 ld a, $7
ld [W_OAKSLABCURSCRIPT], a ld [W_OAKSLABCURSCRIPT], a
@ -354,8 +354,8 @@ OaksLabScript10: ; 1cd6d (7:4d6d)
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
ld c, BANK(Music_MeetRival) ld c, BANK(Music_MeetRival)
ld a, MUSIC_MEET_RIVAL ld a, MUSIC_MEET_RIVAL
call PlayMusic call PlayMusic
@ -414,8 +414,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
set 7, [hl] set 7, [hl]
xor a xor a
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $c ld a, $c
ld [W_OAKSLABCURSCRIPT], a ld [W_OAKSLABCURSCRIPT], a
ret ret
@ -423,8 +423,8 @@ OaksLabScript11: ; 1cdb9 (7:4db9)
OaksLabScript12: ; 1ce03 (7:4e03) OaksLabScript12: ; 1ce03 (7:4e03)
ld a, $f0 ld a, $f0
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
call UpdateSprites call UpdateSprites
ld a, $1 ld a, $1
ld [wSpriteIndex], a ld [wSpriteIndex], a

View file

@ -28,8 +28,8 @@ PalletTownScript0: ; 18e81 (6:4e81)
ret nz ret nz
xor a xor a
ld [hJoyHeld],a ld [hJoyHeld],a
ld a,4 ld a,PLAYER_DIR_DOWN
ld [wd528],a ld [wPlayerMovingDirection],a
ld a,$FF ld a,$FF
call PlaySound ; stop music call PlaySound ; stop music
ld a, BANK(Music_MeetProfOak) ld a, BANK(Music_MeetProfOak)
@ -190,8 +190,8 @@ OakAppearsText: ; 18fb0 (6:4fb0)
ld [wEmotionBubbleSpriteIndex],a ; player's sprite ld [wEmotionBubbleSpriteIndex],a ; player's sprite
ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE
predef EmotionBubble predef EmotionBubble
ld a,4 ld a,PLAYER_DIR_DOWN
ld [wd528],a ld [wPlayerMovingDirection],a
jp TextScriptEnd jp TextScriptEnd
OakWalksUpText: ; 18fce (6:4fce) OakWalksUpText: ; 18fce (6:4fce)

View file

@ -33,15 +33,15 @@ PokemonTower2Script0: ; 6050f (18:450f)
res 6, [hl] res 6, [hl]
ld a, [wCoordIndex] ld a, [wCoordIndex]
cp $1 cp $1
ld a, $8 ld a, PLAYER_DIR_UP
ld b, SPRITE_FACING_DOWN ld b, SPRITE_FACING_DOWN
jr nz, .asm_60544 jr nz, .asm_60544
ld hl, wd764 ld hl, wd764
set 6, [hl] set 6, [hl]
ld a, $2 ld a, PLAYER_DIR_LEFT
ld b, SPRITE_FACING_RIGHT ld b, SPRITE_FACING_RIGHT
.asm_60544 .asm_60544
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $1 ld a, $1
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, b ld a, b

View file

@ -11,8 +11,8 @@ RedsHouse2FScriptPointers: ; 5c0bc (17:40bc)
RedsHouse2FScript0: ; 5c0c0 (17:40c0) RedsHouse2FScript0: ; 5c0c0 (17:40c0)
xor a xor a
ld [hJoyHeld],a ld [hJoyHeld],a
ld a,8 ld a,PLAYER_DIR_UP
ld [wd528],a ld [wPlayerMovingDirection],a
ld a,1 ld a,1
ld [W_REDSHOUSE2CURSCRIPT],a ld [W_REDSHOUSE2CURSCRIPT],a
ret ret

View file

@ -67,8 +67,8 @@ Route22Script0: ; 50f00 (14:4f00)
ld [hJoyHeld], a ld [hJoyHeld], a
ld a, $f0 ld a, $f0
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, [wd7eb] ld a, [wd7eb]
bit 0, a ; is this the rival battle at the beginning of the game? bit 0, a ; is this the rival battle at the beginning of the game?
jr nz, .firstRivalBattle jr nz, .firstRivalBattle
@ -111,8 +111,8 @@ Route22Script1: ; 50f62 (14:4f62)
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr nz, .asm_50f78 jr nz, .asm_50f78
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
jr .asm_50f7a jr .asm_50f7a
.asm_50f78 .asm_50f78
@ -270,13 +270,13 @@ Route22Script4: ; 51087 (14:5087)
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr nz, .asm_510a1 jr nz, .asm_510a1
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
jr .asm_510a8 jr .asm_510a8
.asm_510a1 .asm_510a1
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
.asm_510a8 .asm_510a8
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a
@ -314,13 +314,13 @@ Route22Script5: ; 510df (14:50df)
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr nz, .asm_510fb jr nz, .asm_510fb
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP
jr .asm_51102 jr .asm_51102
.asm_510fb .asm_510fb
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
.asm_51102 .asm_51102
ld [hSpriteFacingDirection], a ld [hSpriteFacingDirection], a

View file

@ -22,8 +22,8 @@ Route5GateScript0: ; 1df50 (7:5f50)
ld hl, CoordsData_1df8f ld hl, CoordsData_1df8f
call ArePlayerCoordsInArray call ArePlayerCoordsInArray
ret nc ret nc
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
callba RemoveGuardDrink callba RemoveGuardDrink

View file

@ -16,8 +16,8 @@ Route6GateScript0: ; 1e04e (7:604e)
ld hl, CoordsData_1e08c ld hl, CoordsData_1e08c
call ArePlayerCoordsInArray call ArePlayerCoordsInArray
ret nc ret nc
ld a, $1 ld a, PLAYER_DIR_RIGHT
ld [wd528], a ld [wPlayerMovingDirection], a
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
callba RemoveGuardDrink callba RemoveGuardDrink

View file

@ -28,8 +28,8 @@ Route7GateScript0: ; 1e128 (7:6128)
ld hl, CoordsData_1e167 ld hl, CoordsData_1e167
call ArePlayerCoordsInArray call ArePlayerCoordsInArray
ret nc ret nc
ld a, $8 ld a, PLAYER_DIR_UP
ld [wd528], a ld [wPlayerMovingDirection], a
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
callba RemoveGuardDrink callba RemoveGuardDrink

View file

@ -27,8 +27,8 @@ Route8GateScript0: ; 1e1ee (7:61ee)
ld hl, CoordsData_1e22c ld hl, CoordsData_1e22c
call ArePlayerCoordsInArray call ArePlayerCoordsInArray
ret nc ret nc
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
xor a xor a
ld [hJoyHeld], a ld [hJoyHeld], a
callba RemoveGuardDrink callba RemoveGuardDrink

View file

@ -72,8 +72,8 @@ SafariZoneEntranceScriptPointers: ; 751d9 (1d:51d9)
ret ret
.SafariZoneEntranceScript5 .SafariZoneEntranceScript5
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld hl, wd790 ld hl, wd790
bit 6, [hl] bit 6, [hl]
res 6, [hl] res 6, [hl]

View file

@ -199,7 +199,7 @@ MovementData_62216: ; 62216 (18:6216)
db $FF db $FF
SilphCo11Script_6221a: ; 6221a (18:621a) SilphCo11Script_6221a: ; 6221a (18:621a)
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $3 ld a, $3
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, b ld a, b
@ -213,11 +213,11 @@ SilphCo11Script5: ; 62227 (18:6227)
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr z, .asm_6223c jr z, .asm_6223c
ld a, $2 ld a, PLAYER_DIR_LEFT
ld b, SPRITE_FACING_RIGHT ld b, SPRITE_FACING_RIGHT
jr .asm_62240 jr .asm_62240
.asm_6223c .asm_6223c
ld a, $8 ld a, PLAYER_DIR_UP
ld b, SPRITE_FACING_DOWN ld b, SPRITE_FACING_DOWN
.asm_62240 .asm_62240
call SilphCo11Script_6221a call SilphCo11Script_6221a
@ -247,11 +247,11 @@ SilphCo11Script3: ; 6226a (18:626a)
ld a, [wcf0d] ld a, [wcf0d]
cp $1 cp $1
jr z, .asm_62284 jr z, .asm_62284
ld a, $2 ld a, PLAYER_DIR_LEFT
ld b, SPRITE_FACING_RIGHT ld b, SPRITE_FACING_RIGHT
jr .asm_62288 jr .asm_62288
.asm_62284 .asm_62284
ld a, $8 ld a, PLAYER_DIR_UP
ld b, SPRITE_FACING_DOWN ld b, SPRITE_FACING_DOWN
.asm_62288 .asm_62288
call SilphCo11Script_6221a call SilphCo11Script_6221a

View file

@ -127,8 +127,8 @@ SilphCo7Script0: ; 51c23 (14:5c23)
ld [hJoyHeld], a ld [hJoyHeld], a
ld a, $f0 ld a, $f0
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $ff ld a, $ff
ld [wc0ee], a ld [wc0ee], a
call PlaySound call PlaySound
@ -209,8 +209,8 @@ SilphCo7Script4: ; 51cc8 (14:5cc8)
ld [wJoyIgnore], a ld [wJoyIgnore], a
ld hl, wd82f ld hl, wd82f
set 0, [hl] set 0, [hl]
ld a, $4 ld a, PLAYER_DIR_DOWN
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, $9 ld a, $9
ld [H_SPRITEINDEX], a ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_UP ld a, SPRITE_FACING_UP

View file

@ -74,8 +74,8 @@ SSAnne2Script_61416: ; 61416 (18:5416)
ld a, [W_XCOORD] ld a, [W_XCOORD]
cp $25 cp $25
jr nz, .asm_61426 jr nz, .asm_61426
ld a, $2 ld a, PLAYER_DIR_LEFT
ld [wd528], a ld [wPlayerMovingDirection], a
ld a, SPRITE_FACING_RIGHT ld a, SPRITE_FACING_RIGHT
jr .asm_61427 jr .asm_61427
.asm_61426 .asm_61426

View file

@ -1701,7 +1701,11 @@ W_MONHLEARNSET:: ; d0cc
flag_array 50 + 5 flag_array 50 + 5
ds 1 ds 1
wd0d4:: ds 3 ; temp storage for hTilesetType wSavedTilesetType:: ; d0d4
; saved at the start of a battle and then written back at the end of the battle
ds 1
ds 2
W_MONHPADDING:: ; d0d7 W_MONHPADDING:: ; d0d7
@ -2066,9 +2070,14 @@ W_SPRITESETID:: ; d3a8
; sprite set ID for the current map ; sprite set ID for the current map
ds 1 ds 1
wd3a9:: ds 1 ; used when getting the object data pointer wObjectDataPointerTemp:: ; d3a9
wd3aa:: ds 3 ; second part of the pointer ds 2
wd3ad:: ds 1 ; used as the beginning value for copying warp data
ds 2
wMapBackgroundTile:: ; d3ad
; the tile shown outside the boundaries of the map
ds 1
wNumberOfWarps:: ; d3ae wNumberOfWarps:: ; d3ae
; number of warps in current map ; number of warps in current map
@ -2084,9 +2093,17 @@ wDestinationWarpID:: ; d42f
ds 128 ds 128
wd4b0:: ds 1 ; number of signs on the map wNumSigns:: ; d4b0
wd4b1:: ds 32 ; starting address for sign coords ; number of signs in the current map (up to 16)
wd4d1:: ds 16 ; starting address for sign text IDs ds 1
wSignCoords:: ; d4b1
; 2 bytes each
; Y, X
ds 32
wSignTextIDs:: ; d4d1
ds 16
W_NUMSPRITES:: ; d4e1 W_NUMSPRITES:: ; d4e1
; number of sprites on the current map ; number of sprites on the current map
@ -2107,16 +2124,35 @@ W_MAPSPRITEEXTRADATA:: ; d504
; two bytes per sprite (trainer class/item ID, trainer set ID) ; two bytes per sprite (trainer class/item ID, trainer set ID)
ds 32 ds 32
wd524:: ds 1 ; map height in 2x2 metatiles, also used with checking connections wCurrentMapHeight2:: ; d524
wd525:: ds 1 ; map width in 2x2 metatiles, also used with checking connections ; map height in 2x2 meta-tiles
ds 1
wCurrentMapWidth2:: ; d525
; map width in 2x2 meta-tiles
ds 1
wMapViewVRAMPointer:: ; d526 wMapViewVRAMPointer:: ; d526
; the address of the upper left corner of the visible portion of the BG tile map in VRAM ; the address of the upper left corner of the visible portion of the BG tile map in VRAM
ds 2 ds 2
wd528:: ds 1 ; additional storage for directions ; In the comments for the player direction variables below, "moving" refers to
wd529:: ds 1 ; same case as above, but used differently ; both walking and changing facing direction without taking a step.
wd52a:: ds 1 ; same case as above
wPlayerMovingDirection:: ; d528
; if the player is moving, the current direction
; if the player is not moving, zero
; map scripts write to this in order to change the player's facing direction
ds 1
wPlayerLastStopDirection:: ; d529
; the direction in which the player was moving before the player last stopped
ds 1
wPlayerDirection:: ; d52a
; if the player is moving, the current direction
; if the player is not moving, the last the direction in which the player moved
ds 1
W_TILESETBANK:: ; d52b W_TILESETBANK:: ; d52b
ds 1 ds 1