gb_test1

diff test.asm @ 0:1b77ae3b7c5f

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 03 Jan 2019 08:20:10 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test.asm	Thu Jan 03 08:20:10 2019 +0200
     1.3 @@ -0,0 +1,105 @@
     1.4 +; vi:ft=rgbasm:
     1.5 +REG_LCDC	equ $ff40
     1.6 +REG_STAT	equ $ff41
     1.7 +REG_SCY		equ $ff42
     1.8 +REG_SCX		equ $ff43
     1.9 +REG_LY		equ $ff44
    1.10 +REG_LYC		equ $ff45
    1.11 +REG_BGP		equ $ff47
    1.12 +REG_OBP0	equ $ff48
    1.13 +REG_OBP1	equ $ff49
    1.14 +REG_WY		equ $ff4a
    1.15 +REG_WX		equ $ff4b
    1.16 +
    1.17 +LCDC_BGON	equ $01
    1.18 +LCDC_OBJON	equ $02
    1.19 +LCDC_OBJ16	equ $04
    1.20 +LCDC_BGMAP_9C00	equ $08
    1.21 +LCDC_CHAR_8000	equ $10
    1.22 +LCDC_WON	equ $20
    1.23 +LCDC_WMAP_9C00	equ $40
    1.24 +LCDC_DISPON	equ $80
    1.25 +
    1.26 +section "hdr", ROM0[$100]
    1.27 +	nop
    1.28 +	jp main
    1.29 +
    1.30 +rept $150 - $104
    1.31 +	db 0
    1.32 +endr
    1.33 +
    1.34 +section "text", ROM0
    1.35 +	
    1.36 +main:
    1.37 +	ldh a, [REG_LY]
    1.38 +	cp a, 144
    1.39 +	jr c, main
    1.40 +
    1.41 +	; disable the display
    1.42 +	xor a, a
    1.43 +	ldh [REG_LCDC], a
    1.44 +
    1.45 +	ld hl, $8000	; point hl to character data area (tiles)
    1.46 +	ld de, tile0
    1.47 +	ld c, tiles_end - tile0
    1.48 +.copytile:
    1.49 +	ld a, [de]
    1.50 +	ld [hl+], a
    1.51 +	inc de
    1.52 +	dec c
    1.53 +	jr nz, .copytile
    1.54 +
    1.55 +	ld hl, $9800	; point hl to BG vram
    1.56 +	ld b, 18
    1.57 +.fillscr:
    1.58 +	ld c, 32
    1.59 +.fillrow:
    1.60 +	ld a, b
    1.61 +	add a, c
    1.62 +	and a, 1
    1.63 +
    1.64 +	ld [hl+], a
    1.65 +	dec c
    1.66 +	jr nz, .fillrow
    1.67 +
    1.68 +	dec b
    1.69 +	jr nz, .fillscr
    1.70 +
    1.71 +	; setup identity palette
    1.72 +	ld a, $e4  ; 0:00 1:01 2:10 3:11
    1.73 +	ldh [REG_BGP], a
    1.74 +
    1.75 +	; reset scroll to 0
    1.76 +	xor a, a
    1.77 +	ldh [REG_SCY], a
    1.78 +	ldh [REG_SCX], a
    1.79 +
    1.80 +	; setup the LCDC and enable the display
    1.81 +	ld a, LCDC_DISPON | LCDC_CHAR_8000 | LCDC_BGON
    1.82 +	ldh [REG_LCDC], a
    1.83 +
    1.84 +	di
    1.85 +.end:	halt
    1.86 +	nop
    1.87 +	jp .end
    1.88 +
    1.89 +section "data", ROM0
    1.90 +
    1.91 +	; lower bit,upper bit, for each row of 8 pixels
    1.92 +tile0: db $55,$00
    1.93 +	db $aa,$00
    1.94 +	db $55,$00
    1.95 +	db $aa,$00
    1.96 +	db $55,$00
    1.97 +	db $aa,$00
    1.98 +	db $55,$00
    1.99 +	db $aa,$00
   1.100 +tile1: db $ff,$aa
   1.101 +	db $ff,$55
   1.102 +	db $ff,$aa
   1.103 +	db $ff,$55
   1.104 +	db $ff,$aa
   1.105 +	db $ff,$55
   1.106 +	db $ff,$aa
   1.107 +	db $ff,$55
   1.108 +tiles_end: