-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
184 lines (152 loc) · 3.18 KB
/
main.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
;**************************************
; SUPER FX DEMO
;**************************************
.65816
.include define.inc
.include registers.inc
.include macros.inc
.include var.asm
.include assets.asm
.include superfx/main.asm
.65816
.org 808000
.base 0000
.include vectors.asm
.include clear.asm
.include dma.asm
.include joypad.asm
.include level.asm
.include object.asm
InitGSU_ROM:
; phb needed ?
lda #02 ; set pbr to bank 02 (GSU ROM)
sta PBR ; Program bank register
lda #04 ; gsu/2
sta VCR
stz RAMBR
stz ROMBR
lda #08 ; screen base register = 70:0000 + N * 0x400
; can use double buffering by switching scbr on two successive frame ?
; double buffering in VRAM seems to be the norm when looking at starfox
sta SCBR ; = 70:2000
; nil nil HT1 RON RAN HT0 MD1 MD0
; 0 0 1 0 0 0 0 1 ; (MD 0b01) => 16 colors, (HT 0b10) => y=192
lda #21 ; w/ RON
sta @scmr_mirror
lda #a0
sta CFGR ; config, enable IRQ on STOP
lda #01
sta CLSR ; clock select register
; reset stack pointer
ldx #1fff
stx R10L
rtl
InitGSU_ROM_end:
CallGSUFunction_ROM:
; give GSU access to ROM/RAM
lda @scmr_mirror
ora #18
sta SCMR
sta @scmr_mirror
stx R15L
wait_for_gsu:
lda SFRL
bit #20
bne @wait_for_gsu
; give back SNES access to ROM/RAM
lda @scmr_mirror
eor #18
sta SCMR
sta @scmr_mirror
rtl
CallGSUFunction_ROM_end:
MainEntry:
jsl !InitGSU
; ldx #@GSU_entry
; jsl !CallGSUFunction
ldx #@GSU_clear_buffer
jsl !CallGSUFunction
; draw_hline(96, 213, 184)
ldx #0060 ; x0=96
stx R01L
ldx #00d5 ; x1=213
stx R03L
ldx #00b8 ; y=184
stx R02L
ldx #00b8 ; y=184
stx R04L
ldx #C_MAGENTA
stx R00L
ldx #@GSU_draw_line
jsl !CallGSUFunction
; ---- ***
; LOOP_1A
; r0=color
ldx #C_MAGENTA
stx R00L
; r1=x0
ldx #002c
stx R01L
; r2=y0
ldx #0080
stx R02L
; r3=x1
ldx #0068
stx R03L
; r4=y1
ldx #001c
stx R04L
ldx #@GSU_draw_line
jsl !CallGSUFunction
; LOOP_1B
; r0=color
ldx #C_YELLOW
stx R00L
; r1=x0
ldx #0068
stx R01L
; r2=y0
ldx #001c
stx R02L
; r3=x1
ldx #009c
stx R03L
; r4=y1
ldx #0057
stx R04L
ldx #@GSU_draw_line
jsl !CallGSUFunction
; LOOP_2
; r0=color
ldx #C_BLUE
stx R00L
; r1=x0
ldx #009c
stx R01L
; r2=y0
ldx #0057
stx R02L
; r3=x1
ldx #002c
stx R03L
; r4=y1
ldx #0080
stx R04L
ldx #@GSU_draw_line
jsl !CallGSUFunction
; ---- ***
; ---- Release Forced Blank
.call VRAM_DMA_TRANSFER 0000, screen_base, 5400; BG1_SCBR_SIZE
; .call VRAM_DMA_TRANSFER 0000, screen_base, 5400 ; 5400 is enough to copy first 672 tiles coposing the center screen
lda #0f ; release forced blanking, set screen to full brightness
sta INIDISP
lda #cf ; trigger IRQ on line 207
sta VTIMEL
lda #a1 ; enable VIRQ, NMI, turn on automatic joypad polling
sta NMITIMEN
cli
MainLoop:
jsr @WaitNextVBlank
jsr @HandleInput
jmp @MainLoop
.include info.asm