mirror of https://github.com/pret/pokecrystal.git
Harmonize engine/overworld with pokegold
This commit is contained in:
parent
cc460a17b0
commit
50e182e831
|
@ -148,7 +148,7 @@ CMDQUEUE_CAPACITY EQU 4
|
|||
; HandleQueuedCommand.Jumptable indexes (see engine/overworld/events.asm)
|
||||
const_def
|
||||
const CMDQUEUE_NULL
|
||||
const CMDQUEUE_NULL2
|
||||
const CMDQUEUE_TYPE1
|
||||
const CMDQUEUE_STONETABLE
|
||||
const CMDQUEUE_TYPE3
|
||||
const CMDQUEUE_TYPE4
|
||||
|
|
|
@ -0,0 +1,302 @@
|
|||
ClearCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
xor a
|
||||
.loop
|
||||
ld [hl], a
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
HandleCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
xor a
|
||||
.loop
|
||||
ldh [hMapObjectIndexBuffer], a
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .skip
|
||||
push hl
|
||||
ld b, h
|
||||
ld c, l
|
||||
call HandleQueuedCommand
|
||||
pop hl
|
||||
|
||||
.skip
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
add hl, de
|
||||
ldh a, [hMapObjectIndexBuffer]
|
||||
inc a
|
||||
cp CMDQUEUE_CAPACITY
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
Unreferenced_GetNthCmdQueueEntry:
|
||||
ld hl, wCmdQueue
|
||||
ld bc, CMDQUEUE_ENTRY_SIZE
|
||||
call AddNTimes
|
||||
ld b, h
|
||||
ld c, l
|
||||
ret
|
||||
|
||||
WriteCmdQueue::
|
||||
push bc
|
||||
push de
|
||||
call .GetNextEmptyEntry
|
||||
ld d, h
|
||||
ld e, l
|
||||
pop hl
|
||||
pop bc
|
||||
ret c
|
||||
ld a, b
|
||||
ld bc, CMDQUEUE_ENTRY_SIZE - 1
|
||||
call FarCopyBytes
|
||||
xor a
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
.GetNextEmptyEntry:
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
.loop
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .done
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
scf
|
||||
ret
|
||||
|
||||
.done
|
||||
ld a, CMDQUEUE_CAPACITY
|
||||
sub c
|
||||
and a
|
||||
ret
|
||||
|
||||
DelCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
.loop
|
||||
ld a, [hl]
|
||||
cp b
|
||||
jr z, .done
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
and a
|
||||
ret
|
||||
|
||||
.done
|
||||
xor a
|
||||
ld [hl], a
|
||||
scf
|
||||
ret
|
||||
|
||||
_DelCmdQueue:
|
||||
ld hl, CMDQUEUE_TYPE
|
||||
add hl, bc
|
||||
ld [hl], 0
|
||||
ret
|
||||
|
||||
HandleQueuedCommand:
|
||||
ld hl, CMDQUEUE_TYPE
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
cp NUM_CMDQUEUE_TYPES
|
||||
jr c, .okay
|
||||
xor a
|
||||
|
||||
.okay
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, .Jumptable
|
||||
add hl, de
|
||||
add hl, de
|
||||
add hl, de
|
||||
ld a, [hli]
|
||||
push af
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
pop af
|
||||
rst FarCall
|
||||
ret
|
||||
|
||||
.Jumptable:
|
||||
dba CmdQueue_Null
|
||||
dba CmdQueue_Type1
|
||||
dba CmdQueue_StoneTable
|
||||
dba CmdQueue_Type3
|
||||
dba CmdQueue_Type4
|
||||
|
||||
CmdQueueAnonymousJumptable:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
pop hl
|
||||
rst JumpTable
|
||||
ret
|
||||
|
||||
CmdQueueAnonJT_Increment:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
inc [hl]
|
||||
ret
|
||||
|
||||
CmdQueueAnonJT_Decrement:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
dec [hl]
|
||||
ret
|
||||
|
||||
CmdQueue_Null:
|
||||
ret
|
||||
|
||||
CmdQueue_Type1:
|
||||
call ret_2f3e
|
||||
ret
|
||||
|
||||
CmdQueue_Type4:
|
||||
call CmdQueueAnonymousJumptable
|
||||
; anonymous dw
|
||||
dw .zero
|
||||
dw .one
|
||||
|
||||
.zero
|
||||
ldh a, [hSCY]
|
||||
ld hl, CMDQUEUE_04
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
call CmdQueueAnonJT_Increment
|
||||
.one
|
||||
ld hl, CMDQUEUE_ADDR
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
dec a
|
||||
ld [hl], a
|
||||
jr z, .finish
|
||||
and 1
|
||||
jr z, .add
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ldh a, [hSCY]
|
||||
sub [hl]
|
||||
ldh [hSCY], a
|
||||
ret
|
||||
|
||||
.add
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ldh a, [hSCY]
|
||||
add [hl]
|
||||
ldh [hSCY], a
|
||||
ret
|
||||
|
||||
.finish
|
||||
ld hl, CMDQUEUE_04
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ldh [hSCY], a
|
||||
call _DelCmdQueue
|
||||
ret
|
||||
|
||||
CmdQueue_Type3:
|
||||
call CmdQueueAnonymousJumptable
|
||||
; anonymous dw
|
||||
dw .zero
|
||||
dw .one
|
||||
dw .two
|
||||
|
||||
.zero
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Increment
|
||||
.one
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Increment
|
||||
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wd173], a
|
||||
ret
|
||||
|
||||
.two
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Decrement
|
||||
|
||||
ld hl, CMDQUEUE_03
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wd173], a
|
||||
ret
|
||||
|
||||
.PlayerNotFacingDown:
|
||||
ld a, $7f
|
||||
ld [wd173], a
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
ld [hl], 0
|
||||
ret
|
||||
|
||||
.IsPlayerFacingDown:
|
||||
push bc
|
||||
ld bc, wPlayerStruct
|
||||
call GetSpriteDirection
|
||||
and a
|
||||
pop bc
|
||||
ret
|
||||
|
||||
CmdQueue_StoneTable:
|
||||
ld de, wPlayerStruct
|
||||
ld a, NUM_OBJECT_STRUCTS
|
||||
.loop
|
||||
push af
|
||||
|
||||
ld hl, OBJECT_SPRITE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .next
|
||||
|
||||
ld hl, OBJECT_MOVEMENTTYPE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp SPRITEMOVEDATA_STRENGTH_BOULDER
|
||||
jr nz, .next
|
||||
|
||||
ld hl, OBJECT_NEXT_TILE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
call CheckPitTile
|
||||
jr nz, .next
|
||||
|
||||
ld hl, OBJECT_DIRECTION_WALKING
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp STANDING
|
||||
jr nz, .next
|
||||
call HandleStoneQueue
|
||||
jr c, .fall_down_hole
|
||||
|
||||
.next
|
||||
ld hl, OBJECT_LENGTH
|
||||
add hl, de
|
||||
ld d, h
|
||||
ld e, l
|
||||
|
||||
pop af
|
||||
dec a
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
.fall_down_hole
|
||||
pop af
|
||||
ret
|
|
@ -1338,305 +1338,4 @@ DoBikeStep::
|
|||
xor a
|
||||
ret
|
||||
|
||||
ClearCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
xor a
|
||||
.loop
|
||||
ld [hl], a
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
HandleCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
xor a
|
||||
.loop
|
||||
ldh [hMapObjectIndexBuffer], a
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .skip
|
||||
push hl
|
||||
ld b, h
|
||||
ld c, l
|
||||
call HandleQueuedCommand
|
||||
pop hl
|
||||
|
||||
.skip
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
add hl, de
|
||||
ldh a, [hMapObjectIndexBuffer]
|
||||
inc a
|
||||
cp CMDQUEUE_CAPACITY
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
Unreferenced_GetNthCmdQueueEntry:
|
||||
ld hl, wCmdQueue
|
||||
ld bc, CMDQUEUE_ENTRY_SIZE
|
||||
call AddNTimes
|
||||
ld b, h
|
||||
ld c, l
|
||||
ret
|
||||
|
||||
WriteCmdQueue::
|
||||
push bc
|
||||
push de
|
||||
call .GetNextEmptyEntry
|
||||
ld d, h
|
||||
ld e, l
|
||||
pop hl
|
||||
pop bc
|
||||
ret c
|
||||
ld a, b
|
||||
ld bc, CMDQUEUE_ENTRY_SIZE - 1
|
||||
call FarCopyBytes
|
||||
xor a
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
.GetNextEmptyEntry:
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
.loop
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .done
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
scf
|
||||
ret
|
||||
|
||||
.done
|
||||
ld a, CMDQUEUE_CAPACITY
|
||||
sub c
|
||||
and a
|
||||
ret
|
||||
|
||||
DelCmdQueue::
|
||||
ld hl, wCmdQueue
|
||||
ld de, CMDQUEUE_ENTRY_SIZE
|
||||
ld c, CMDQUEUE_CAPACITY
|
||||
.loop
|
||||
ld a, [hl]
|
||||
cp b
|
||||
jr z, .done
|
||||
add hl, de
|
||||
dec c
|
||||
jr nz, .loop
|
||||
and a
|
||||
ret
|
||||
|
||||
.done
|
||||
xor a
|
||||
ld [hl], a
|
||||
scf
|
||||
ret
|
||||
|
||||
_DelCmdQueue:
|
||||
ld hl, CMDQUEUE_TYPE
|
||||
add hl, bc
|
||||
ld [hl], 0
|
||||
ret
|
||||
|
||||
HandleQueuedCommand:
|
||||
ld hl, CMDQUEUE_TYPE
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
cp NUM_CMDQUEUE_TYPES
|
||||
jr c, .okay
|
||||
xor a
|
||||
|
||||
.okay
|
||||
ld e, a
|
||||
ld d, 0
|
||||
ld hl, .Jumptable
|
||||
add hl, de
|
||||
add hl, de
|
||||
add hl, de
|
||||
ld a, [hli]
|
||||
push af
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
pop af
|
||||
rst FarCall
|
||||
ret
|
||||
|
||||
.Jumptable:
|
||||
dba CmdQueue_Null
|
||||
dba CmdQueue_Null2
|
||||
dba CmdQueue_StoneTable
|
||||
dba CmdQueue_Type3
|
||||
dba CmdQueue_Type4
|
||||
|
||||
CmdQueueAnonymousJumptable:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
pop hl
|
||||
rst JumpTable
|
||||
ret
|
||||
|
||||
CmdQueueAnonJT_Increment:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
inc [hl]
|
||||
ret
|
||||
|
||||
CmdQueueAnonJT_Decrement:
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
dec [hl]
|
||||
ret
|
||||
|
||||
CmdQueue_Null:
|
||||
ret
|
||||
|
||||
CmdQueue_Null2:
|
||||
call ret_2f3e
|
||||
ret
|
||||
|
||||
CmdQueue_Type4:
|
||||
call CmdQueueAnonymousJumptable
|
||||
; anonymous dw
|
||||
dw .zero
|
||||
dw .one
|
||||
|
||||
.zero
|
||||
ldh a, [hSCY]
|
||||
ld hl, CMDQUEUE_04
|
||||
add hl, bc
|
||||
ld [hl], a
|
||||
call CmdQueueAnonJT_Increment
|
||||
.one
|
||||
ld hl, CMDQUEUE_ADDR
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
dec a
|
||||
ld [hl], a
|
||||
jr z, .finish
|
||||
and 1
|
||||
jr z, .add
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ldh a, [hSCY]
|
||||
sub [hl]
|
||||
ldh [hSCY], a
|
||||
ret
|
||||
|
||||
.add
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ldh a, [hSCY]
|
||||
add [hl]
|
||||
ldh [hSCY], a
|
||||
ret
|
||||
|
||||
.finish
|
||||
ld hl, CMDQUEUE_04
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ldh [hSCY], a
|
||||
call _DelCmdQueue
|
||||
ret
|
||||
|
||||
CmdQueue_Type3:
|
||||
call CmdQueueAnonymousJumptable
|
||||
; anonymous dw
|
||||
dw .zero
|
||||
dw .one
|
||||
dw .two
|
||||
|
||||
.zero
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Increment
|
||||
.one
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Increment
|
||||
|
||||
ld hl, CMDQUEUE_02
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wd173], a
|
||||
ret
|
||||
|
||||
.two
|
||||
call .IsPlayerFacingDown
|
||||
jr z, .PlayerNotFacingDown
|
||||
call CmdQueueAnonJT_Decrement
|
||||
|
||||
ld hl, CMDQUEUE_03
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
ld [wd173], a
|
||||
ret
|
||||
|
||||
.PlayerNotFacingDown:
|
||||
ld a, $7f
|
||||
ld [wd173], a
|
||||
ld hl, CMDQUEUE_05
|
||||
add hl, bc
|
||||
ld [hl], 0
|
||||
ret
|
||||
|
||||
.IsPlayerFacingDown:
|
||||
push bc
|
||||
ld bc, wPlayerStruct
|
||||
call GetSpriteDirection
|
||||
and a
|
||||
pop bc
|
||||
ret
|
||||
|
||||
CmdQueue_StoneTable:
|
||||
ld de, wPlayerStruct
|
||||
ld a, NUM_OBJECT_STRUCTS
|
||||
.loop
|
||||
push af
|
||||
|
||||
ld hl, OBJECT_SPRITE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
and a
|
||||
jr z, .next
|
||||
|
||||
ld hl, OBJECT_MOVEMENTTYPE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp SPRITEMOVEDATA_STRENGTH_BOULDER
|
||||
jr nz, .next
|
||||
|
||||
ld hl, OBJECT_NEXT_TILE
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
call CheckPitTile
|
||||
jr nz, .next
|
||||
|
||||
ld hl, OBJECT_DIRECTION_WALKING
|
||||
add hl, de
|
||||
ld a, [hl]
|
||||
cp STANDING
|
||||
jr nz, .next
|
||||
call HandleStoneQueue
|
||||
jr c, .fall_down_hole
|
||||
|
||||
.next
|
||||
ld hl, OBJECT_LENGTH
|
||||
add hl, de
|
||||
ld d, h
|
||||
ld e, l
|
||||
|
||||
pop af
|
||||
dec a
|
||||
jr nz, .loop
|
||||
ret
|
||||
|
||||
.fall_down_hole
|
||||
pop af
|
||||
ret
|
||||
INCLUDE "engine/overworld/cmd_queue.asm"
|
||||
|
|
|
@ -16,6 +16,7 @@ ReanchorBGMap_NoOAMUpdate::
|
|||
ldh [hBGMapMode], a
|
||||
pop af
|
||||
ldh [hOAMUpdate], a
|
||||
|
||||
ld hl, wVramState
|
||||
set 6, [hl]
|
||||
ret
|
||||
|
|
|
@ -1846,7 +1846,7 @@ Function5015:
|
|||
ld e, [hl]
|
||||
inc [hl]
|
||||
ld d, 0
|
||||
ld hl, wc2e2
|
||||
ld hl, wMovementObject
|
||||
ld a, [hli]
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
|
|
|
@ -142,10 +142,10 @@ LoadUsedSpritesGFX:
|
|||
ld a, MAPCALLBACK_SPRITES
|
||||
call RunMapCallback
|
||||
call GetUsedSprites
|
||||
call .LoadMiscTiles
|
||||
call LoadMiscTiles
|
||||
ret
|
||||
|
||||
.LoadMiscTiles:
|
||||
LoadMiscTiles:
|
||||
ld a, [wSpriteFlags]
|
||||
bit 6, a
|
||||
ret nz
|
||||
|
@ -234,7 +234,7 @@ GetMonSprite:
|
|||
|
||||
farcall LoadOverworldMonIcon
|
||||
|
||||
ld l, 1
|
||||
ld l, WALKING_SPRITE
|
||||
ld h, 0
|
||||
scf
|
||||
ret
|
||||
|
@ -250,8 +250,8 @@ GetMonSprite:
|
|||
jp nz, GetMonSprite
|
||||
|
||||
.NoBreedmon:
|
||||
ld a, 1
|
||||
ld l, 1
|
||||
ld a, WALKING_SPRITE
|
||||
ld l, WALKING_SPRITE
|
||||
ld h, 0
|
||||
and a
|
||||
ret
|
||||
|
|
|
@ -225,7 +225,7 @@ CopyMapObjectToObjectStruct:
|
|||
ret
|
||||
|
||||
InitializeVisibleSprites:
|
||||
ld bc, wMapObjects + MAPOBJECT_LENGTH
|
||||
ld bc, wMap1Object
|
||||
ld a, 1
|
||||
.loop
|
||||
ldh [hMapObjectIndexBuffer], a
|
||||
|
@ -312,7 +312,7 @@ CheckObjectEnteringVisibleRange::
|
|||
ld d, a
|
||||
ld a, [wXCoord]
|
||||
ld e, a
|
||||
ld bc, wMapObjects + MAPOBJECT_LENGTH
|
||||
ld bc, wMap1Object
|
||||
ld a, 1
|
||||
.loop_v
|
||||
ldh [hMapObjectIndexBuffer], a
|
||||
|
@ -368,7 +368,7 @@ CheckObjectEnteringVisibleRange::
|
|||
ld e, a
|
||||
ld a, [wYCoord]
|
||||
ld d, a
|
||||
ld bc, wMapObjects + MAPOBJECT_LENGTH
|
||||
ld bc, wMap1Object
|
||||
ld a, 1
|
||||
.loop_h
|
||||
ldh [hMapObjectIndexBuffer], a
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -106,11 +106,11 @@ _GetVarAction::
|
|||
|
||||
.UnownCaught:
|
||||
; Number of unique Unown caught.
|
||||
call .count
|
||||
call .count_unown
|
||||
ld a, b
|
||||
jp .loadstringbuffer2
|
||||
|
||||
.count
|
||||
.count_unown
|
||||
ld hl, wUnownDex
|
||||
ld b, 0
|
||||
.loop
|
||||
|
|
Loading…
Reference in New Issue