gb_test1
changeset 0:1b77ae3b7c5f tip
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 03 Jan 2019 08:20:10 +0200 |
parents | |
children | |
files | Makefile test.asm |
diffstat | 2 files changed, 123 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Makefile Thu Jan 03 08:20:10 2019 +0200 1.3 @@ -0,0 +1,18 @@ 1.4 +src = test.asm 1.5 +obj = test.o 1.6 +bin = test 1.7 +img = test.gb 1.8 + 1.9 +$(img): $(bin) 1.10 + cp $< $@ 1.11 + rgbfix -v -p 0 $@ 1.12 + 1.13 +$(bin): $(obj) 1.14 + rgblink -o $@ $(obj) 1.15 + 1.16 +%.o: %.asm 1.17 + rgbasm -o $@ $< 1.18 + 1.19 +.PHONY: clean 1.20 +clean: 1.21 + rm -f $(obj) $(bin) $(img)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test.asm Thu Jan 03 08:20:10 2019 +0200 2.3 @@ -0,0 +1,105 @@ 2.4 +; vi:ft=rgbasm: 2.5 +REG_LCDC equ $ff40 2.6 +REG_STAT equ $ff41 2.7 +REG_SCY equ $ff42 2.8 +REG_SCX equ $ff43 2.9 +REG_LY equ $ff44 2.10 +REG_LYC equ $ff45 2.11 +REG_BGP equ $ff47 2.12 +REG_OBP0 equ $ff48 2.13 +REG_OBP1 equ $ff49 2.14 +REG_WY equ $ff4a 2.15 +REG_WX equ $ff4b 2.16 + 2.17 +LCDC_BGON equ $01 2.18 +LCDC_OBJON equ $02 2.19 +LCDC_OBJ16 equ $04 2.20 +LCDC_BGMAP_9C00 equ $08 2.21 +LCDC_CHAR_8000 equ $10 2.22 +LCDC_WON equ $20 2.23 +LCDC_WMAP_9C00 equ $40 2.24 +LCDC_DISPON equ $80 2.25 + 2.26 +section "hdr", ROM0[$100] 2.27 + nop 2.28 + jp main 2.29 + 2.30 +rept $150 - $104 2.31 + db 0 2.32 +endr 2.33 + 2.34 +section "text", ROM0 2.35 + 2.36 +main: 2.37 + ldh a, [REG_LY] 2.38 + cp a, 144 2.39 + jr c, main 2.40 + 2.41 + ; disable the display 2.42 + xor a, a 2.43 + ldh [REG_LCDC], a 2.44 + 2.45 + ld hl, $8000 ; point hl to character data area (tiles) 2.46 + ld de, tile0 2.47 + ld c, tiles_end - tile0 2.48 +.copytile: 2.49 + ld a, [de] 2.50 + ld [hl+], a 2.51 + inc de 2.52 + dec c 2.53 + jr nz, .copytile 2.54 + 2.55 + ld hl, $9800 ; point hl to BG vram 2.56 + ld b, 18 2.57 +.fillscr: 2.58 + ld c, 32 2.59 +.fillrow: 2.60 + ld a, b 2.61 + add a, c 2.62 + and a, 1 2.63 + 2.64 + ld [hl+], a 2.65 + dec c 2.66 + jr nz, .fillrow 2.67 + 2.68 + dec b 2.69 + jr nz, .fillscr 2.70 + 2.71 + ; setup identity palette 2.72 + ld a, $e4 ; 0:00 1:01 2:10 3:11 2.73 + ldh [REG_BGP], a 2.74 + 2.75 + ; reset scroll to 0 2.76 + xor a, a 2.77 + ldh [REG_SCY], a 2.78 + ldh [REG_SCX], a 2.79 + 2.80 + ; setup the LCDC and enable the display 2.81 + ld a, LCDC_DISPON | LCDC_CHAR_8000 | LCDC_BGON 2.82 + ldh [REG_LCDC], a 2.83 + 2.84 + di 2.85 +.end: halt 2.86 + nop 2.87 + jp .end 2.88 + 2.89 +section "data", ROM0 2.90 + 2.91 + ; lower bit,upper bit, for each row of 8 pixels 2.92 +tile0: db $55,$00 2.93 + db $aa,$00 2.94 + db $55,$00 2.95 + db $aa,$00 2.96 + db $55,$00 2.97 + db $aa,$00 2.98 + db $55,$00 2.99 + db $aa,$00 2.100 +tile1: db $ff,$aa 2.101 + db $ff,$55 2.102 + db $ff,$aa 2.103 + db $ff,$55 2.104 + db $ff,$aa 2.105 + db $ff,$55 2.106 + db $ff,$aa 2.107 + db $ff,$55 2.108 +tiles_end: