aboutsummaryrefslogtreecommitdiff
path: root/src/example/gb.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/example/gb.asm')
-rw-r--r--src/example/gb.asm92
1 files changed, 92 insertions, 0 deletions
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
+