|
@ -12,6 +12,8 @@ spriteData: |
|
|
INCBIN "png/player.2bpp" |
|
|
INCBIN "png/player.2bpp" |
|
|
|
|
|
|
|
|
DEF SPRITE_IDX EQU 32 |
|
|
DEF SPRITE_IDX EQU 32 |
|
|
|
|
|
DEF SPRITE_WIDTH EQU 2 |
|
|
|
|
|
DEF SPRITE_HEIGHT EQU 2 |
|
|
|
|
|
|
|
|
Player_Init:: |
|
|
Player_Init:: |
|
|
ld a, 8 |
|
|
ld a, 8 |
|
@ -20,11 +22,12 @@ Player_Init:: |
|
|
|
|
|
|
|
|
ld bc, _VRAM8000 + SPRITE_IDX * 16 |
|
|
ld bc, _VRAM8000 + SPRITE_IDX * 16 |
|
|
ld hl, spriteData |
|
|
ld hl, spriteData |
|
|
ld d, 16 |
|
|
|
|
|
|
|
|
ld d, 16 * (SPRITE_WIDTH * SPRITE_HEIGHT) |
|
|
call memcpy |
|
|
call memcpy |
|
|
|
|
|
|
|
|
|
|
|
; top left |
|
|
ld hl, _OAM |
|
|
ld hl, _OAM |
|
|
ld a, 144-8 |
|
|
|
|
|
|
|
|
ld a, 144-8-8 |
|
|
ld [hli], a |
|
|
ld [hli], a |
|
|
ld a, 8 |
|
|
ld a, 8 |
|
|
ld [hli], a |
|
|
ld [hli], a |
|
@ -33,9 +36,39 @@ Player_Init:: |
|
|
xor a |
|
|
xor a |
|
|
ld [hli], a |
|
|
ld [hli], a |
|
|
|
|
|
|
|
|
|
|
|
; top right |
|
|
|
|
|
ld a, 144-8-8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, 8 + 8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, SPRITE_IDX + 1 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
xor a |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
|
|
|
|
|
|
; bottom left |
|
|
|
|
|
ld a, 144-8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, 8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, SPRITE_IDX + 2 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
xor a |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
|
|
|
|
|
|
; bottom right |
|
|
|
|
|
ld a, 144-8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, 8 + 8 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
ld a, SPRITE_IDX + 3 |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
xor a |
|
|
|
|
|
ld [hli], a |
|
|
|
|
|
|
|
|
ld bc, _OAMRAM |
|
|
ld bc, _OAMRAM |
|
|
ld hl, _OAM |
|
|
ld hl, _OAM |
|
|
ld d, 4 |
|
|
|
|
|
|
|
|
ld d, 4 * (SPRITE_WIDTH * SPRITE_HEIGHT) |
|
|
call memcpy |
|
|
call memcpy |
|
|
|
|
|
|
|
|
ret |
|
|
ret |
|
@ -59,12 +92,41 @@ Player_Update:: |
|
|
; check for right boundary |
|
|
; check for right boundary |
|
|
ld hl, _OAM + 1 |
|
|
ld hl, _OAM + 1 |
|
|
ld a, [hl] |
|
|
ld a, [hl] |
|
|
cp 160 |
|
|
|
|
|
|
|
|
cp 160 - 8 |
|
|
jr nc, .done |
|
|
jr nc, .done |
|
|
|
|
|
|
|
|
; Update x-position and set x-flip = false |
|
|
|
|
|
|
|
|
; update top left sprite |
|
|
|
|
|
inc [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX |
|
|
|
|
|
inc hl |
|
|
|
|
|
res 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update top right sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 1 |
|
|
|
|
|
inc hl |
|
|
|
|
|
res 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update bottom left sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 2 |
|
|
|
|
|
inc hl |
|
|
|
|
|
res 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update bottom right sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
inc [hl] |
|
|
inc [hl] |
|
|
ld hl, _OAM + 3 |
|
|
|
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 3 |
|
|
|
|
|
inc hl |
|
|
res 5, [hl] |
|
|
res 5, [hl] |
|
|
|
|
|
|
|
|
.left: |
|
|
.left: |
|
@ -79,9 +141,38 @@ Player_Update:: |
|
|
cp 9 |
|
|
cp 9 |
|
|
jr c, .done |
|
|
jr c, .done |
|
|
|
|
|
|
|
|
; Update x-position and set x-flip = true |
|
|
|
|
|
|
|
|
; update top left sprite |
|
|
|
|
|
dec [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 1 |
|
|
|
|
|
inc hl |
|
|
|
|
|
set 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update top right sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
|
|
|
dec [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX |
|
|
|
|
|
inc hl |
|
|
|
|
|
set 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update bottom left sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
|
|
|
dec [hl] |
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 3 |
|
|
|
|
|
inc hl |
|
|
|
|
|
set 5, [hl] |
|
|
|
|
|
|
|
|
|
|
|
; update bottom right sprite |
|
|
|
|
|
inc hl |
|
|
|
|
|
inc hl |
|
|
dec [hl] |
|
|
dec [hl] |
|
|
ld hl, _OAM + 3 |
|
|
|
|
|
|
|
|
inc hl |
|
|
|
|
|
ld [hl], SPRITE_IDX + 2 |
|
|
|
|
|
inc hl |
|
|
set 5, [hl] |
|
|
set 5, [hl] |
|
|
|
|
|
|
|
|
.done: |
|
|
.done: |
|
|