From 24ebb224a11d31bfe039352fd29d2b89368583ac Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 15 Apr 2016 15:58:09 +0100 Subject: Started on Gameboy support. --- src/example/Makefile | 5 ++- src/example/gb.asm | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/example/gb.asm (limited to 'src/example') diff --git a/src/example/Makefile b/src/example/Makefile index 7c53209..d184de0 100644 --- a/src/example/Makefile +++ b/src/example/Makefile @@ -20,7 +20,7 @@ # Makefile for examples # -ALL = spectrum.tap c64.t64 zx81.p +ALL = spectrum.tap c64.t64 zx81.p gb.rom CASM = ../casm all: $(ALL) $(CASM) @@ -39,5 +39,8 @@ c64.t64: c64.asm $(CASM) zx81.p: zx81.asm $(CASM) $(CASM) zx81.asm +gb.rom: gb.asm $(CASM) + $(CASM) gb.asm + clean: rm -f $(ALL) diff --git a/src/example/gb.asm b/src/example/gb.asm new file mode 100644 index 0000000..15cc50b --- /dev/null +++ b/src/example/gb.asm @@ -0,0 +1,92 @@ + + cpu gameboy + option +list + option list-labels,all + + option output-file,gb.rom + option output-format,gameboy + + option gameboy-irq,vbl,vbl_code + +VRAM equ $8000 +SCRN equ $9800 +OAM equ $fe00 +LCDC equ $ff40 +STAT equ $ff41 + +READY equ $ff81 +XPOS equ $ff82 + +VBLANK macro + push af +.wait + ldh a,(LCDC) + cp $91 + jr nz,wait + + pop af + + endm + + + ; + ; ********** + ; CODE START + ; ********** + ; + org $150 + + di + xor a + ldh (READY),a + ld sp,$fffe + + ; Set LCD so only sprites show + ; + ld a,$82 + ldh (LCDC),a + ld a,$10 + ldh (STAT),a + + ; Copy to VRAM + ; + ld hl,VRAM + ld de,sprite + ld a,16 + + VBLANK + +.copy + ld a,(hl+) + ld (de),a + inc de + dec a + jr nz,copy + + ld a,1 + ldh (READY),a + +.idle + halt + nop + jr idle + +vbl_code: + ldh a,(READY) + jr z,finish + + ldh a,(XPOS) + inc a + ldh (XPOS),a + ld (OAM+1),a + xor a + ld (OAM),a + ld (OAM+2),a + ld (OAM+3),a + +.finish + reti + +sprite: + defs 16,$ff + -- cgit v1.2.3