gb_test1

view 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 source
1 ; vi:ft=rgbasm:
2 REG_LCDC equ $ff40
3 REG_STAT equ $ff41
4 REG_SCY equ $ff42
5 REG_SCX equ $ff43
6 REG_LY equ $ff44
7 REG_LYC equ $ff45
8 REG_BGP equ $ff47
9 REG_OBP0 equ $ff48
10 REG_OBP1 equ $ff49
11 REG_WY equ $ff4a
12 REG_WX equ $ff4b
14 LCDC_BGON equ $01
15 LCDC_OBJON equ $02
16 LCDC_OBJ16 equ $04
17 LCDC_BGMAP_9C00 equ $08
18 LCDC_CHAR_8000 equ $10
19 LCDC_WON equ $20
20 LCDC_WMAP_9C00 equ $40
21 LCDC_DISPON equ $80
23 section "hdr", ROM0[$100]
24 nop
25 jp main
27 rept $150 - $104
28 db 0
29 endr
31 section "text", ROM0
33 main:
34 ldh a, [REG_LY]
35 cp a, 144
36 jr c, main
38 ; disable the display
39 xor a, a
40 ldh [REG_LCDC], a
42 ld hl, $8000 ; point hl to character data area (tiles)
43 ld de, tile0
44 ld c, tiles_end - tile0
45 .copytile:
46 ld a, [de]
47 ld [hl+], a
48 inc de
49 dec c
50 jr nz, .copytile
52 ld hl, $9800 ; point hl to BG vram
53 ld b, 18
54 .fillscr:
55 ld c, 32
56 .fillrow:
57 ld a, b
58 add a, c
59 and a, 1
61 ld [hl+], a
62 dec c
63 jr nz, .fillrow
65 dec b
66 jr nz, .fillscr
68 ; setup identity palette
69 ld a, $e4 ; 0:00 1:01 2:10 3:11
70 ldh [REG_BGP], a
72 ; reset scroll to 0
73 xor a, a
74 ldh [REG_SCY], a
75 ldh [REG_SCX], a
77 ; setup the LCDC and enable the display
78 ld a, LCDC_DISPON | LCDC_CHAR_8000 | LCDC_BGON
79 ldh [REG_LCDC], a
81 di
82 .end: halt
83 nop
84 jp .end
86 section "data", ROM0
88 ; lower bit,upper bit, for each row of 8 pixels
89 tile0: db $55,$00
90 db $aa,$00
91 db $55,$00
92 db $aa,$00
93 db $55,$00
94 db $aa,$00
95 db $55,$00
96 db $aa,$00
97 tile1: db $ff,$aa
98 db $ff,$55
99 db $ff,$aa
100 db $ff,$55
101 db $ff,$aa
102 db $ff,$55
103 db $ff,$aa
104 db $ff,$55
105 tiles_end: