-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.asm
288 lines (238 loc) · 8.67 KB
/
demo.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
; ------------------------------------------------------------------------------
;
; Copyright 2022 Nameless Algorithm
; See https://namelessalgorithm.com/ for more information.
;
; LICENSE
; You may use this source code for any purpose. If you do so, please attribute
; 'Nameless Algorithm' in your source, or mention us in your game/demo credits.
; Thank you.
;
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; ROM HEADER
; ------------------------------------------------------------------------------
; {{{
rom_header:
dc.l $00FFFFFE ; Initial stack pointer value
dc.l entry_point ; Start of program
dc.l ignore_handler ; Bus error
dc.l ignore_handler ; Address error
dc.l ignore_handler ; Illegal instruction
dc.l ignore_handler ; Division by zero
dc.l ignore_handler ; CHK exception
dc.l ignore_handler ; TRAPV exception
dc.l ignore_handler ; Privilege violation
dc.l ignore_handler ; TRACE exception
dc.l ignore_handler ; Line-A emulator
dc.l ignore_handler ; Line-F emulator
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Spurious exception
dc.l ignore_handler ; IRQ level 1
dc.l ignore_handler ; IRQ level 2
dc.l ignore_handler ; IRQ level 3
dc.l ignore_handler ; IRQ level 4 (horizontal retrace interrupt)
dc.l ignore_handler ; IRQ level 5
dc.l ignore_handler ; IRQ level 6 (vertical retrace interrupt)
dc.l ignore_handler ; IRQ level 7
dc.l ignore_handler ; TRAP #00 exception
dc.l ignore_handler ; TRAP #01 exception
dc.l ignore_handler ; TRAP #02 exception
dc.l ignore_handler ; TRAP #03 exception
dc.l ignore_handler ; TRAP #04 exception
dc.l ignore_handler ; TRAP #05 exception
dc.l ignore_handler ; TRAP #06 exception
dc.l ignore_handler ; TRAP #07 exception
dc.l ignore_handler ; TRAP #08 exception
dc.l ignore_handler ; TRAP #09 exception
dc.l ignore_handler ; TRAP #10 exception
dc.l ignore_handler ; TRAP #11 exception
dc.l ignore_handler ; TRAP #12 exception
dc.l ignore_handler ; TRAP #13 exception
dc.l ignore_handler ; TRAP #14 exception
dc.l ignore_handler ; TRAP #15 exception
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.l ignore_handler ; Unused (reserved)
dc.b "SEGA GENESIS " ; Console name
dc.b "(C) NAMELESS " ; Copyright holder and release date
dc.b "FRAMEBUF DEMO BY NAMELESS ALGORITHM " ; Domest. name
dc.b "FRAMEBUF DEMO BY NAMELESS ALGORITHM " ; Intern. name
dc.b "2022-10-12 " ; Version number
dc.w $0000 ; Checksum
dc.b "J " ; I/O support
dc.l $00000000 ; Start address of ROM
dc.l __end ; End address of ROM
dc.l $00FF0000 ; Start address of RAM
dc.l $00FFFFFF ; End address of RAM
dc.l $00000000 ; SRAM enabled
dc.l $00000000 ; Unused
dc.l $00000000 ; Start address of SRAM
dc.l $00000000 ; End address of SRAM
dc.l $00000000 ; Unused
dc.l $00000000 ; Unused
dc.b " " ; Notes (unused)
dc.b "JUE " ; Country codes
; }}}
; ----------------------------------------------------------------------------
; MEMORY MAP
; ----------------------------------------------------------------------------
vblanks = $E0FF10
palette_offset = $E0FF14
conf_offset = $E0FF18
; VRAM MAP:
; $0000-$6FFF framebuf
; $7000-$7A00 font
; $8000-$8FFF empty
; $A000-????? window playfield
; $E000-$E800 plane A fixed playfield
; text.asm config
TEXT_VRAM_ADDR_PRINT = $A000 ; Address of plane to print char indices to
TEXT_VRAM_ADDR_FONT = $7000 ; Where in VRAM is font data loaded?
; ----------------------------------------------------------------------------
; STATIC DATA
; ----------------------------------------------------------------------------
text
dc.b 'FRAMBUFFER DEMO NAMELESS ALGORITHM 2022 ',0
even
; ------------------------------------------------------------------------------
; MAIN PROGRAM
; ------------------------------------------------------------------------------
align 4
.marker dc.b "__main "
__main
entry_point
jsr init_all
jsr clear_vram_all ; set all of VRAM to 0s
; set_plane_a_addr( vram_addr (D0.w) )
move.w #$E000,d0
jsr set_plane_a_addr
; set_plane_b_addr( vram_addr (D0.w) )
move.w #$E000,d0
jsr set_plane_b_addr
; set_window_addr( vram_addr (D0.w) )
move.w #$A000,d0
jsr set_window_addr
move.w #$7000,d0
jsr load_font
; set Window Base Point Y = 2
; set_vdp_control( reg (D0.b), data (D1.b) )
move.b #$12,d0
move.b #$02,d1
jsr set_vdp_control
; print_at( x (D1), y (D2), str (A0), strlen (D0), palette (D5.b) [0-3] )
move.w #0,d1
move.w #0,d2
lea text,a0
move.w #64,d0
move.w #1,d5
jsr print_at_col
; load_palette( palette_data (a0.l), palette_idx (D0.w) [0-3] )
lea pattern_palette,a0
move.w #0,d0
jsr load_palette
lea text_palette,a0
move.w #1,d0
jsr load_palette
move.w #$8B70,VDP_CONTROL ; Plane A address = $E000
; gen_playfield( VRAM_address (d0.w) )
move.w #$E000,d0
jsr gen_playfield ; fixed plane A playfield
move.l #$11111111,d0 ; pattern
mainloop
render_buf ; Draw a pattern
lea $E00800,a0 ; Offset below the text
move.w #$10-1,d6
.render_loop1
move.w #$180-1,d7
.render_loop2
add.l d0,(a0)+ ; Read framebuffer pixels and update
dbra d7,.render_loop2
add.l #$11223344,d0
dbra d6,.render_loop1
output_buf
; copy_framebuf( framebuf_addr (A0.L), VRAM_char_memory (D0.w) )
lea $E00000,a0 ; a0 : Framebuf RAM ptr
move.w #$0000,d0 ; VRAM write to address $0000
jsr copy_framebuf ; copy RAM framebuffer to VRAM
jmp mainloop
; ------------------------------------------------------------------------------
; EXCEPTION AND INTERRUPT HANDLERS
; ----------------------------------------------------------------------------
align 2 ; word-align code
ignore_handler
rte ; return from exception (seems to restore PC)
; ------------------------------------------------------------------------------
; PALETTE
; ------------------------------------------------------------------------------
; {{{
even
pattern_palette: ; BGR
dc.w $0000 ; Colour 0 - Transparent
dc.w $0e00
dc.w $0c02
dc.w $0a04
dc.w $0806
dc.w $0608
dc.w $040a
dc.w $020c
dc.w $000e
dc.w $002e
dc.w $004c
dc.w $006a
dc.w $0088
dc.w $00a6
dc.w $00c4
dc.w $00e0
text_palette: ; BGR
dc.w $0000 ; Colour 0 - Transparent
dc.w $0e00
dc.w $0c02
dc.w $0a04
dc.w $0806
dc.w $0608
dc.w $040a
dc.w $020c
dc.w $000e
dc.w $002e
dc.w $004c
dc.w $006a
dc.w $0088
dc.w $00a6
dc.w $00c4
dc.w $00e0
; }}}
; ----------------------------------------------------------------------------
; INCLUDES
; ----------------------------------------------------------------------------
incdir '../include'
include 'init.asm'
include 'vdp.asm'
include 'text.asm'
include 'raster.asm'
__end
; vim: tw=80 tabstop=4 expandtab ft=asm68k fdm=marker