|
|
@ -1,5 +1,4 @@ |
|
|
|
INCLUDE "hardware.inc" |
|
|
|
INCLUDE "input.inc" |
|
|
|
INCLUDE "oam.inc" |
|
|
|
INCLUDE "util.inc" |
|
|
|
|
|
|
@ -27,6 +26,10 @@ DEF SPRITE_WIDTH EQU 2 |
|
|
|
DEF SPRITE_HEIGHT EQU 2 |
|
|
|
DEF PLAYER_SPEED EQU 2 |
|
|
|
|
|
|
|
DEF TILE_WIDTH EQU 8 ; Width of tile in bytes |
|
|
|
DEF TILE_HEIGHT EQU 8 ; Height of tile in bytes |
|
|
|
DEF TILE_SIZE EQU 16 ; Total length of tile in bytes |
|
|
|
|
|
|
|
DEF GRAVITY EQU (0 << 8) | $2e ; 0.18 |
|
|
|
DEF INIT_VY EQU (3 << 8) | $99 ; 3.60 |
|
|
|
DEF INIT_FALL_VY EQU ($ff << 8) | $1a ; a.b |
|
|
@ -36,7 +39,7 @@ Player_Init:: |
|
|
|
ld hl, PLAYER_X |
|
|
|
ld [hl], 0 |
|
|
|
inc hl |
|
|
|
ld [hl], 144-32 |
|
|
|
ld [hl], SCRN_Y - SPRITE_HEIGHT * (SCRN_Y - SPRITE_HEIGHT * TILE_HEIGHT) |
|
|
|
inc hl |
|
|
|
xor a |
|
|
|
ld [hl+], a |
|
|
@ -46,9 +49,9 @@ Player_Init:: |
|
|
|
ld [hl+], a |
|
|
|
|
|
|
|
; Copy sprite to VRAM |
|
|
|
ld bc, _VRAM8000 + SPRITE_IDX * 16 |
|
|
|
ld bc, _VRAM8000 + SPRITE_IDX * TILE_SIZE |
|
|
|
ld hl, spriteData |
|
|
|
ld d, 16 * (SPRITE_WIDTH * SPRITE_HEIGHT) |
|
|
|
ld d, TILE_SIZE * (SPRITE_WIDTH * SPRITE_HEIGHT) |
|
|
|
call memcpy |
|
|
|
|
|
|
|
; Initialize OAM entries with player state |
|
|
@ -59,7 +62,7 @@ Player_Init:: |
|
|
|
Player_Update:: |
|
|
|
; check for jump |
|
|
|
ld a, [keys] |
|
|
|
and BTN_UP |
|
|
|
and PADF_UP |
|
|
|
jr z, .jump_update_check |
|
|
|
|
|
|
|
; initialize jump state if not already jumping |
|
|
@ -147,7 +150,7 @@ Player_Update:: |
|
|
|
; check for move right |
|
|
|
.right: |
|
|
|
ld a, [keys] |
|
|
|
and BTN_RIGHT |
|
|
|
and PADF_RIGHT |
|
|
|
jr z, .left |
|
|
|
|
|
|
|
; check for right boundary |
|
|
@ -180,7 +183,7 @@ Player_Update:: |
|
|
|
; check for left button |
|
|
|
ld hl, keys |
|
|
|
ld a, [hl] |
|
|
|
and BTN_LEFT |
|
|
|
and PADF_LEFT |
|
|
|
jr z, .fall |
|
|
|
|
|
|
|
; check for left boundary |
|
|
|