-
Notifications
You must be signed in to change notification settings - Fork 2
/
ws_test.asm
88 lines (69 loc) · 1.23 KB
/
ws_test.asm
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.include "x16.inc"
.org $080D
.segment "STARTUP"
.segment "INIT"
.segment "ONCE"
.segment "CODE"
jmp start
.include "filenames.asm"
.include "loadvram.asm"
.include "globals.asm"
.include "timer.asm"
.include "winscreen.asm"
vsync_trig: .byte 0
def_irq: .word $0000
init_irq:
lda IRQVec
sta def_irq
lda IRQVec+1
sta def_irq+1
lda #<handle_irq
sta IRQVec
lda #>handle_irq
sta IRQVec+1
rts
handle_irq:
; check for VSYNC
lda VERA_isr
and #$01
beq @done_vsync
sta vsync_trig
@done_vsync:
jmp (def_irq)
start:
; set display to 2x scale
lda #64
sta VERA_dc_hscale
sta VERA_dc_vscale
lda #>(VRAM_TILEMAP>>4)
ldx #<(VRAM_TILEMAP>>4)
ldy #<tilemap_fn
jsr loadvram
lda #>(VRAM_TILES>>4)
ldx #<(VRAM_TILES>>4)
ldy #<tiles_fn
jsr loadvram
lda #>(VRAM_palette>>4)
ldx #<(VRAM_palette>>4)
ldy #<palette_fn
jsr loadvram
; Setup interrupts
jsr init_irq
; request winscreen
lda #1
sta winscreen_req
mainloop:
wai
lda vsync_trig
beq mainloop
; VSYNC has occurred, handle
inc frame_num
lda frame_num
cmp #60
bne @do_tick
stz frame_num
@do_tick:
jsr winscreen_tick
stz vsync_trig
bra mainloop ; loop forever
brk