INCLUDE "hardware.inc" INCLUDE "input.inc" Section "Player Data", WRAM0 playerWorldX: dw playerWorldY: dw Section "Player Code", ROM0 spriteData: INCBIN "png/player.2bpp" Player_Init:: ld a, 8 ld hl, _OAM + 1 ld [hl], a ld bc, _VRAM8000 ld hl, spriteData ld d, 16 call memcpy ld hl, _OAM ld a, 144-8 ld [hli], a ld a, 8 ld [hli], a xor a ld [hli], a ld [hli], a ld bc, _OAMRAM ld hl, _OAM ld d, 4 call memcpy ret Player_Update:: ; Only update every 2 frames ld hl, frame ld a, [hl] and %1 cp %1 jr nz, .done ld hl, keys ld b, [hl] ; check for move right ld a, b and BTN_RIGHT jr z, .left ; check for right boundary ld hl, _OAM + 1 ld a, [hl] cp 160 jr nc, .done ; Update x-position and set x-flip = false inc [hl] ld hl, _OAM + 3 res 5, [hl] .left: ; check for left button ld a, b and BTN_LEFT jr z, .done ; check for left boundary ld hl, _OAM + 1 ld a, [hl] cp 9 jr c, .done ; Update x-position and set x-flip = true dec [hl] ld hl, _OAM + 3 set 5, [hl] .done: ret