|
@ -4,9 +4,6 @@ INCLUDE "util.inc" |
|
|
|
|
|
|
|
|
Section "Player Data", WRAM0 |
|
|
Section "Player Data", WRAM0 |
|
|
|
|
|
|
|
|
playerWorldX: dw |
|
|
|
|
|
playerWorldY: dw |
|
|
|
|
|
|
|
|
|
|
|
; player data |
|
|
; player data |
|
|
PLAYER_X:: db |
|
|
PLAYER_X:: db |
|
|
PLAYER_Y:: dw |
|
|
PLAYER_Y:: dw |
|
@ -35,18 +32,12 @@ DEF INIT_VY EQU (3 << 8) | $99 ; 3.60 |
|
|
DEF INIT_FALL_VY EQU ($ff << 8) | $1a ; a.b |
|
|
DEF INIT_FALL_VY EQU ($ff << 8) | $1a ; a.b |
|
|
|
|
|
|
|
|
Player_Init:: |
|
|
Player_Init:: |
|
|
; Clear player data |
|
|
|
|
|
ld hl, PLAYER_X |
|
|
|
|
|
ld [hl], 0 |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SCRN_Y - SPRITE_HEIGHT * (SCRN_Y - SPRITE_HEIGHT * TILE_HEIGHT) |
|
|
|
|
|
inc hl |
|
|
|
|
|
|
|
|
; Clear player data (X/Y initialized by map engine) |
|
|
|
|
|
ld hl, PLAYER_DIR |
|
|
xor a |
|
|
xor a |
|
|
ld [hl+], a |
|
|
|
|
|
ld [hl+], a |
|
|
|
|
|
ld [hl+], a |
|
|
|
|
|
ld [hl+], a |
|
|
|
|
|
ld [hl+], a |
|
|
|
|
|
|
|
|
REPT 7 |
|
|
|
|
|
ld [hl+], a |
|
|
|
|
|
ENDR |
|
|
|
|
|
|
|
|
; Copy sprite to VRAM |
|
|
; Copy sprite to VRAM |
|
|
ld bc, _VRAM8000 + SPRITE_IDX * TILE_SIZE |
|
|
ld bc, _VRAM8000 + SPRITE_IDX * TILE_SIZE |
|
@ -111,7 +102,11 @@ Player_Update:: |
|
|
|
|
|
|
|
|
; roll back jump if there was a collision |
|
|
; roll back jump if there was a collision |
|
|
call player_bg_collides |
|
|
call player_bg_collides |
|
|
jr z, .jump_Player_UpdateOAM |
|
|
|
|
|
|
|
|
jr nz, .jump_rollback |
|
|
|
|
|
|
|
|
|
|
|
; TODO: Enable once scroll zones are implemented |
|
|
|
|
|
; ld a, [PLAYER_VY] |
|
|
|
|
|
; check if VY < 0 and call Map_ScrollUp / Map_ScrollDown |
|
|
|
|
|
|
|
|
.jump_rollback: |
|
|
.jump_rollback: |
|
|
ld hl, PLAYER_VY |
|
|
ld hl, PLAYER_VY |
|
@ -160,13 +155,17 @@ Player_Update:: |
|
|
jr nc, .left |
|
|
jr nc, .left |
|
|
|
|
|
|
|
|
.move_right: |
|
|
.move_right: |
|
|
ld hl, PLAYER_X |
|
|
|
|
|
inc [hl] |
|
|
|
|
|
inc [hl] |
|
|
|
|
|
|
|
|
ld a, [PLAYER_X] |
|
|
|
|
|
add PLAYER_SPEED |
|
|
|
|
|
ld [PLAYER_X], a |
|
|
|
|
|
|
|
|
call player_bg_collides |
|
|
call player_bg_collides |
|
|
jr nz, .right_rollback |
|
|
jr nz, .right_rollback |
|
|
|
|
|
|
|
|
|
|
|
; TODO: Enable once scroll zones are implemented |
|
|
|
|
|
; ld d, PLAYER_SPEED |
|
|
|
|
|
; call Map_ScrollRight |
|
|
|
|
|
|
|
|
xor a |
|
|
xor a |
|
|
ld [PLAYER_DIR], a |
|
|
ld [PLAYER_DIR], a |
|
|
|
|
|
|
|
@ -174,9 +173,9 @@ Player_Update:: |
|
|
ret |
|
|
ret |
|
|
|
|
|
|
|
|
.right_rollback: |
|
|
.right_rollback: |
|
|
ld hl, PLAYER_X |
|
|
|
|
|
dec [hl] |
|
|
|
|
|
dec [hl] |
|
|
|
|
|
|
|
|
ld a, [PLAYER_X] |
|
|
|
|
|
sub PLAYER_SPEED |
|
|
|
|
|
ld [PLAYER_X], a |
|
|
ret |
|
|
ret |
|
|
|
|
|
|
|
|
.left: |
|
|
.left: |
|
@ -197,6 +196,10 @@ Player_Update:: |
|
|
call player_bg_collides |
|
|
call player_bg_collides |
|
|
jr nz, .left_rollback |
|
|
jr nz, .left_rollback |
|
|
|
|
|
|
|
|
|
|
|
; TODO: Enable once scroll zones are implemented |
|
|
|
|
|
; ld d, PLAYER_SPEED |
|
|
|
|
|
; call Map_ScrollLeft |
|
|
|
|
|
|
|
|
ld a, $ff |
|
|
ld a, $ff |
|
|
ld [PLAYER_DIR], a |
|
|
ld [PLAYER_DIR], a |
|
|
|
|
|
|
|
|