Skip to content

Commit

Permalink
Identify some map object related constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Aug 17, 2020
1 parent 3b00396 commit f82097b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 55 deletions.
13 changes: 8 additions & 5 deletions constants/map_object_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ TRAINER EQU $40
WALK EQU $FE
STAY EQU $FF

DOWN EQU $D0
UP EQU $D1
LEFT EQU $D2
RIGHT EQU $D3
NONE EQU $FF
ANY_DIR EQU $00
UP_DOWN EQU $01
LEFT_RIGHT EQU $02
DOWN EQU $D0
UP EQU $D1
LEFT EQU $D2
RIGHT EQU $D3
NONE EQU $FF

BOULDER_MOVEMENT_BYTE_2 EQU $10
5 changes: 5 additions & 0 deletions constants/script_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ SLOTSFISH EQU $0E0C
SLOTSBIRD EQU $1210
SLOTSMOUSE EQU $1614

; StartSlotMachine dialogs
SLOTS_OUTOFORDER EQU $fd
SLOTS_OUTTOLUNCH EQU $fe
SLOTS_SOMEONESKEYS EQU $ff

; in game trades
; TradeMons indexes (see data/events/trades.asm)
const_def
Expand Down
12 changes: 6 additions & 6 deletions data/events/hidden_objects.asm
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ GameCornerHiddenObjects:
hidden_object 18, 13, $d0, StartSlotMachine
hidden_object 18, 12, $d0, StartSlotMachine
hidden_object 18, 11, $d0, StartSlotMachine
hidden_object 18, 10, $ff, StartSlotMachine ; "Someone's Keys"
hidden_object 18, 10, SLOTS_SOMEONESKEYS, StartSlotMachine
hidden_object 13, 10, $d0, StartSlotMachine
hidden_object 13, 11, $d0, StartSlotMachine
hidden_object 13, 12, $fe, StartSlotMachine ; "Out To Lunch"
hidden_object 13, 12, SLOTS_OUTTOLUNCH, StartSlotMachine
hidden_object 13, 13, $d0, StartSlotMachine
hidden_object 13, 14, $d0, StartSlotMachine
hidden_object 13, 15, $d0, StartSlotMachine
Expand All @@ -338,7 +338,7 @@ GameCornerHiddenObjects:
hidden_object 6, 15, $d0, StartSlotMachine
hidden_object 6, 14, $d0, StartSlotMachine
hidden_object 6, 13, $d0, StartSlotMachine
hidden_object 6, 12, $fd, StartSlotMachine ; "Out Of Order"
hidden_object 6, 12, SLOTS_OUTOFORDER, StartSlotMachine
hidden_object 6, 11, $d0, StartSlotMachine
hidden_object 6, 10, $d0, StartSlotMachine
hidden_object 1, 10, $d0, StartSlotMachine
Expand Down Expand Up @@ -416,8 +416,8 @@ MtMoon3HiddenObjects:
db -1 ; end

IndigoPlateauHiddenObjects:
hidden_object 8, 13, $ff, PrintIndigoPlateauHQText
hidden_object 11, 13, SPRITE_FACING_DOWN, PrintIndigoPlateauHQText
hidden_object 8, 13, $ff, PrintIndigoPlateauHQText ; inaccessible
hidden_object 11, 13, SPRITE_FACING_DOWN, PrintIndigoPlateauHQText ; inaccessible
db -1 ; end

Route25HiddenObjects:
Expand Down Expand Up @@ -471,7 +471,7 @@ Route13HiddenObjects:
db -1 ; end

SafariZoneEntranceHiddenObjects:
hidden_object 10, 1, NUGGET, HiddenItems
hidden_object 10, 1, NUGGET, HiddenItems ; inaccessible
db -1 ; end

SafariZoneWestHiddenObjects:
Expand Down
82 changes: 41 additions & 41 deletions engine/overworld/movement.asm
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ UpdatePlayerSprite:
ld c, a
ld a, [wGrassTile]
cp c
ld a, $0
ld a, 0
jr nz, .next2
ld a, $80
ld a, OAM_BEHIND_BG
.next2
ld [wSpritePlayerStateData2GrassPriority], a
ret
Expand Down Expand Up @@ -150,15 +150,15 @@ UpdateNPCSprite:
and a
ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability)
call InitializeSpriteScreenPosition
ld h, $c2
ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add $6
ld l, a
ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1
inc a
jr z, .randomMovement ; value $FF
jr z, .randomMovement ; value STAY
inc a
jr z, .randomMovement ; value $FE
jr z, .randomMovement ; value WALK
; scripted movement
dec a
ld [hl], a ; increment movement byte 1 (movement data index)
Expand All @@ -184,7 +184,7 @@ UpdateNPCSprite:
.next
cp WALK
jr nz, .determineDirection
; current NPC movement data is $fe. this seems buggy
; current NPC movement data is WALK ($fe). this seems buggy
ld [hl], $1 ; set movement byte 1 to $1
ld de, wNPCMovementDirections
call LoadDEPlusA ; a = [wNPCMovementDirections + $fe] (?)
Expand All @@ -195,54 +195,54 @@ UpdateNPCSprite:
.determineDirection
ld b, a
ld a, [wCurSpriteMovement2]
cp $d0
jr z, .moveDown ; movement byte 2 = $d0 forces down
cp $d1
jr z, .moveUp ; movement byte 2 = $d1 forces up
cp $d2
jr z, .moveLeft ; movement byte 2 = $d2 forces left
cp $d3
jr z, .moveRight ; movement byte 2 = $d3 forces right
cp DOWN
jr z, .moveDown
cp UP
jr z, .moveUp
cp LEFT
jr z, .moveLeft
cp RIGHT
jr z, .moveRight
ld a, b
cp $40 ; a < $40: down (or left)
cp NPC_MOVEMENT_UP ; NPC_MOVEMENT_DOWN <= a < NPC_MOVEMENT_UP: down (or left)
jr nc, .notDown
ld a, [wCurSpriteMovement2]
cp $2
jr z, .moveLeft ; movement byte 2 = $2 only allows left or right
cp LEFT_RIGHT
jr z, .moveLeft
.moveDown
ld de, 2*SCREEN_WIDTH
add hl, de ; move tile pointer two rows down
lb de, 1, 0
lb bc, 4, SPRITE_FACING_DOWN
jr TryWalking
.notDown
cp $80 ; $40 <= a < $80: up (or right)
cp NPC_MOVEMENT_LEFT ; NPC_MOVEMENT_UP <= a < NPC_MOVEMENT_LEFT: up (or right)
jr nc, .notUp
ld a, [wCurSpriteMovement2]
cp $2
jr z, .moveRight ; movement byte 2 = $2 only allows left or right
cp LEFT_RIGHT
jr z, .moveRight
.moveUp
ld de, -2*SCREEN_WIDTH
add hl, de ; move tile pointer two rows up
lb de, -1, 0
lb bc, 8, SPRITE_FACING_UP
jr TryWalking
.notUp
cp $c0 ; $80 <= a < $c0: left (or up)
cp NPC_MOVEMENT_RIGHT ; NPC_MOVEMENT_LEFT <= a < NPC_MOVEMENT_RIGHT: left (or up)
jr nc, .notLeft
ld a, [wCurSpriteMovement2]
cp $1
jr z, .moveUp ; movement byte 2 = $1 only allows up or down
cp UP_DOWN
jr z, .moveUp
.moveLeft
dec hl
dec hl ; move tile pointer two columns left
lb de, 0, -1
lb bc, 2, SPRITE_FACING_LEFT
jr TryWalking
.notLeft ; $c0 <= a: right (or down)
.notLeft ; NPC_MOVEMENT_RIGHT <= a: right (or down)
ld a, [wCurSpriteMovement2]
cp $1
jr z, .moveDown ; movement byte 2 = $1 only allows up or down
cp UP_DOWN
jr z, .moveDown
.moveRight
inc hl
inc hl ; move tile pointer two columns right
Expand Down Expand Up @@ -281,7 +281,7 @@ TryWalking:
call CanWalkOntoTile
pop de
ret c ; cannot walk there (reinitialization of delay values already done)
ld h, $c2
ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add $4
ld l, a
Expand Down Expand Up @@ -341,8 +341,8 @@ UpdateSpriteInWalkingAnimation:
add l
ld l, a
ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1
cp $fe
jr nc, .initNextMovementCounter ; values $fe and $ff
cp WALK
jr nc, .initNextMovementCounter ; values WALK or STAY
ldh a, [hCurrentSpriteOffset]
inc a
ld l, a
Expand Down Expand Up @@ -383,8 +383,8 @@ UpdateSpriteMovementDelay:
ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1
inc l
inc l
cp $fe
jr nc, .tickMoveCounter ; values $fe or $ff
cp WALK
jr nc, .tickMoveCounter ; values WALK or STAY
ld [hl], $0
jr .moving
.tickMoveCounter
Expand Down Expand Up @@ -485,8 +485,8 @@ CheckSpriteAvailability:
add SPRITESTATEDATA2_MOVEMENTBYTE1
ld l, a
ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1
cp $fe
jr c, .skipXVisibilityTest ; movement byte 1 < $fe (i.e. the sprite's movement is scripted)
cp WALK
jr c, .skipXVisibilityTest ; movement byte 1 < WALK (i.e. the sprite's movement is scripted)
ldh a, [hCurrentSpriteOffset]
add SPRITESTATEDATA2_MAPY
ld l, a
Expand All @@ -495,7 +495,7 @@ CheckSpriteAvailability:
cp b
jr z, .skipYVisibilityTest
jr nc, .spriteInvisible ; above screen region
add $8 ; screen is 9 tiles high
add SCREEN_HEIGHT / 2 - 1
cp b
jr c, .spriteInvisible ; below screen region
.skipYVisibilityTest
Expand All @@ -505,7 +505,7 @@ CheckSpriteAvailability:
cp b
jr z, .skipXVisibilityTest
jr nc, .spriteInvisible ; left of screen region
add $9 ; screen is 10 tiles wide
add SCREEN_WIDTH / 2 - 1
cp b
jr c, .spriteInvisible ; right of screen region
.skipXVisibilityTest
Expand All @@ -519,7 +519,7 @@ CheckSpriteAvailability:
ld a, [hld]
cp d
jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom right tile)
ld bc, -20
ld bc, -SCREEN_WIDTH
add hl, bc ; go back one row of tiles
ld a, [hli]
cp d
Expand Down Expand Up @@ -547,9 +547,9 @@ CheckSpriteAvailability:
ld l, a
ld a, [wGrassTile]
cp c
ld a, $0
ld a, 0
jr nz, .notInGrass
ld a, $80
ld a, OAM_BEHIND_BG
.notInGrass
ld [hl], a ; x#SPRITESTATEDATA2_GRASSPRIORITY
and a
Expand Down Expand Up @@ -587,8 +587,8 @@ CanWalkOntoTile:
add SPRITESTATEDATA2_MOVEMENTBYTE1
ld l, a
ld a, [hl] ; x#SPRITESTATEDATA2_MOVEMENTBYTE1
cp $fe
jr nc, .notScripted ; values $fe and $ff
cp WALK
jr nc, .notScripted ; values WALK or STAY
; always allow walking if the movement is scripted
and a
ret
Expand All @@ -603,7 +603,7 @@ CanWalkOntoTile:
jr z, .impassable
cp c
jr nz, .tilePassableLoop
ld h, $c2
ld h, HIGH(wSpriteStateData2)
ldh a, [hCurrentSpriteOffset]
add $6
ld l, a
Expand Down
6 changes: 3 additions & 3 deletions engine/slots/game_corner_slots.asm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
StartSlotMachine:
ld a, [wHiddenObjectFunctionArgument]
cp $fd
cp SLOTS_OUTOFORDER
jr z, .printOutOfOrder
cp $fe
cp SLOTS_OUTTOLUNCH
jr z, .printOutToLunch
cp $ff
cp SLOTS_SOMEONESKEYS
jr z, .printSomeonesKeys
farcall AbleToPlaySlotsCheck
ld a, [wCanPlaySlots]
Expand Down

0 comments on commit f82097b

Please sign in to comment.