/
example.s
67 lines (54 loc) · 1.05 KB
/
example.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.include "memory_map.inc"
.smstag ; automatically adds the TMR SEGA header so real consoles recognize it
.define RAM_TOP = $dff8
.define MEM_CTL_PORT = $3e
.define IO_CTL_PORT = $3f
.define JS_PORT_A = $dc
.define JS_PORT_B = $dd
.define VDP_CMD = $bf
.define VDP_DATA = $be
.ramsection "port_3e_status" slot "RAM_SLOT" org 0 force
port_3e_status db ; set by BIOS on cartridge boot
.ends
.ramsection "pause_vars" slot "RAM_SLOT"
paused db
.ends
.ramsection "user_vars" slot "RAM_SLOT"
counter db
.ends
.orga 0
di
im 1
ld sp, RAM_TOP
jp init
.orga $0038
in a, (VDP_CMD)
reti
.orga $0066
ld a, (paused)
xor 1
ld (paused), a
retn
init:
xor a
ld (paused), a
; set up counter
xor a
ld (counter), a
@loop:
ei
halt ; wait for interrupt
; check pause status and do nothing if set
ld a, (paused)
or a
jr nz, @loop
; increment counter and use to change background color
ld a, $10
out (VDP_CMD), a
ld a, $c0
out (VDP_CMD), a
ld a, (counter)
inc a
ld (counter), a
out (VDP_DATA), a
jr @loop