Browse Source

Start player draw code

master
Forest Belton 3 years ago
parent
commit
f0daf2ca11
6 changed files with 87 additions and 5 deletions
  1. +2
    -1
      .gitignore
  2. +15
    -3
      Makefile
  3. BIN
      png/player.png
  4. +14
    -1
      src/main.s
  5. +43
    -0
      src/player.s
  6. +13
    -0
      src/util.s

+ 2
- 1
.gitignore View File

@ -1,3 +1,4 @@
is.gb is.gb
is.gb.sym is.gb.sym
*.o
*.o
*.2bpp

+ 15
- 3
Makefile View File

@ -1,10 +1,22 @@
PNGFILES := $(shell find png -type f -name '*.png')
IMGFILES := $(PNGFILES:%.png=%.2bpp)
SFILES := $(shell find src -type f -name '*.s') SFILES := $(shell find src -type f -name '*.s')
OFILES := $(SFILES:%.s=%.o) OFILES := $(SFILES:%.s=%.o)
OUTPUT := is.gb
$(OUTPUT): $(OFILES)
.PHONY: clean
is.gb is.gb.sym: $(IMGFILES) $(OFILES)
rgblink -o $@ -n $@.sym $(OFILES) rgblink -o $@ -n $@.sym $(OFILES)
rgbfix -v $@ rgbfix -v $@
$(OFILES): $(IMGFILES)
%.o: %.s %.o: %.s
rgbasm -o $@ $<
rgbasm -o $@ $<
%.2bpp: %.png
rgbgfx -o $@ $<
clean:
rm -f is.gb is.gb.sym $(IMGFILES) $(OFILES)

BIN
png/player.png View File

Before After
Width: 8  |  Height: 8  |  Size: 135 B

+ 14
- 1
src/main.s View File

@ -13,5 +13,18 @@ endr
SECTION "Code", ROM0 SECTION "Code", ROM0
start: start:
call PlayerInit
; enable lcd and interrupts
ld hl, rLCDC
set 7, [hl]
ei
.vbl:
ld a, [$ff41]
and 3
cp 1
jr nz, .vbl
halt halt
jp start
jp .vbl

+ 43
- 0
src/player.s View File

@ -0,0 +1,43 @@
INCLUDE "hardware.inc"
Section "Player Data", WRAM0
playerWorldX: dw
playerWorldY: dw
; Sprite data
playerScreenX: db
playerScreenY: db
playerTileIndex: db
playerFlags: db
Section "Player Code", ROM0
spriteData:
INCBIN "png/player.2bpp"
PlayerInit::
ld a, 8
ld hl, playerScreenX
ld [hl], a
ld bc, _VRAM8800
ld hl, spriteData
ld d, 16
call memcpy
ld hl, playerScreenX
ld a, 8
ld [hli], a
ld a, 144-8*3
ld [hli], a
ld bc, _OAMRAM
ld hl, playerScreenX
ld d, 4
call memcpy
ret
PlayerDraw::
ret

+ 13
- 0
src/util.s View File

@ -0,0 +1,13 @@
SECTION "Utilities", ROM0
; Copies data between two regions
; @param d Size (in bytes) to copy. Must be >0
; @param bc Pointer to the destination region
; @param hl Pointer to the source region
memcpy::
ld a, [hli]
ld [bc], a
inc bc
dec d
jr nz, memcpy
ret

Loading…
Cancel
Save