-
Notifications
You must be signed in to change notification settings - Fork 2
/
startscreen_browse.asm
129 lines (115 loc) · 2.17 KB
/
startscreen_browse.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.include "x16.inc"
.org $080D
.segment "STARTUP"
.segment "INIT"
.segment "ONCE"
.segment "CODE"
jmp start
.include "filenames.asm"
.include "loadvram.asm"
.include "irq.asm"
.include "game.asm"
.include "globals.asm"
.include "joystick.asm"
.include "vsync.asm"
hscroll: .word 0
vscroll: .word 0
start:
; Disable layers and sprites
lda VERA_dc_video
and #$8F
sta VERA_dc_video
; Setup tiles on layer 1
lda #$12 ; 64x32 map of 4bpp tiles
sta VERA_L1_config
lda #((VRAM_STARTSCRN >> 9) & $FF)
sta VERA_L1_mapbase
lda #((((VRAM_TILES >> 11) & $3F) << 2) | $03) ; 16x16 tiles
sta VERA_L1_tilebase
stz VERA_L1_hscroll_l ; set scroll position to 0,0
stz VERA_L1_hscroll_h
stz VERA_L1_vscroll_l
stz VERA_L1_vscroll_h
; set display to 2x scale
lda #64
sta VERA_dc_hscale
sta VERA_dc_vscale
; load VRAM data from binaries
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
; enable layer 1
lda VERA_dc_video
ora #$20
sta VERA_dc_video
; setup interrupts
jsr init_irq
mainloop:
wai
lda vsync_trig
beq mainloop
; VSYNC occurred
jsr joystick_tick
lda joystick1_right
cmp #0
beq @check_left
lda hscroll
clc
adc #1
sta hscroll
lda hscroll+1
adc #0
sta hscroll+1
@check_left:
lda joystick1_left
cmp #0
beq @check_down
lda hscroll
sec
sbc #1
sta hscroll
lda hscroll+1
sbc #0
sta hscroll+1
@check_down:
lda joystick1_down
cmp #0
beq @check_up
lda vscroll
clc
adc #1
sta vscroll
lda vscroll+1
adc #0
sta vscroll+1
@check_up:
lda joystick1_up
cmp #0
beq @set_scroll
lda vscroll
sec
sbc #1
sta vscroll
lda vscroll+1
sbc #0
sta vscroll+1
@set_scroll:
lda hscroll
sta VERA_L1_hscroll_l
lda hscroll+1
sta VERA_L1_hscroll_h
lda vscroll
sta VERA_L1_vscroll_l
lda vscroll+1
sta VERA_L1_vscroll_h
stz vsync_trig
jmp mainloop ; loop forever