diff options
author | Ian C <ianc@noddybox.co.uk> | 2016-04-15 15:58:09 +0100 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2016-04-15 15:58:09 +0100 |
commit | 24ebb224a11d31bfe039352fd29d2b89368583ac (patch) | |
tree | ee34d23fc3f10a47591ef5d0c027a7efa881be1e /src/example | |
parent | 044adfa27731c0314bc4c9340fd1eebfaf3cf270 (diff) |
Started on Gameboy support.
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/Makefile | 5 | ||||
-rw-r--r-- | src/example/gb.asm | 92 |
2 files changed, 96 insertions, 1 deletions
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 + |