2 * Simple
ST application to playback YMamoto tunes.
3 * This is based on some simple code that Michael Bricout gave me.
5 * Julian Squires
<tek@wiw.org
> / 2004-2005
10 _main
: MOVE.
L #super_main, -(SP)
12 TRAP #14 ; XBIOS Supexec
19 extern ymamoto_init
, ymamoto_reset
, ymamoto_update
20 extern sine
, cosine
, step_sine_oscillator
, reset_sine_oscillator
29 MOVEM.
L D0-D7
/A0-A1
, -(SP
)
31 .0: CMPI.
B #$39, $FFFC02 ; The ol' hit-space-to-continue bit.
34 MOVEM.
L (SP
)+, D0-D7
/A0-A1
38 init
: BTST
#1, $FFFC00 ; ACIA Tx buffer full?
40 MOVE.
B #$12, $FFFC02 ; I *hate* mice.
43 ; Setup music playback routine.
48 ; Save system palette.
49 MOVEM.
L $FF8240
, D0-D7
50 MOVEM.
L D0-D7
, saved_system_palette
53 LEA saved_system_res
, A0
56 MOVE.W
#$2700, SR ; Mask interrupts.
58 MOVE.
B #0, $FF8260 ; Shifter resolution -- low res.
60 MOVE.
B $FF8201
, D0 ; Video RAM address.
64 ; XXX One more byte available on the STe.
67 MOVE.
L D0
, vram_address
74 ; Save TOS VBL
, HBL vectors
, interrupt settings.
76 MOVE.
L hbl_vector
, (A0
)+
77 MOVE.
L vbl_vector
, (A0
)+
78 MOVE.
L timer_b_vector
, (A0
)+
79 MOVE.
B $FFFA07
, (A0
)+ ; Timers.
87 ; Setup our own vbl
, hbl handlers
(HBL
not called by default
).
88 MOVE.
L #raster_bars_vbl, vbl_vector
89 MOVE.
L #hbl_handler, hbl_vector
91 BSR reset_sine_oscillator
94 MOVE.W
#$2300, SR ; Unmask most interrupts.
99 MOVE.W
#$2700, SR ; Mask interrupts.
101 MOVE.
B saved_system_res
, $FF8260 ; Restore shifter res.
102 MOVEM.
L saved_system_palette
, D0-D7 ; Restore palette.
103 MOVEM.
L D0-D7
, $FF8240
105 ; Restore TOS VBL
, timer
B vectors.
107 MOVE.
L (A0
)+, hbl_vector
108 MOVE.
L (A0
)+, vbl_vector
109 MOVE.
L (A0
)+, timer_b_vector
110 MOVE.
B (A0
)+, $FFFA07 ; Timers.
111 MOVE.
B (A0
)+, $FFFA09
112 MOVE.
B (A0
)+, $FFFA15
113 MOVE.
B (A0
)+, $FFFA17
114 MOVE.
B (A0
)+, $FFFA19
115 MOVE.
B (A0
)+, $FFFA1b
116 MOVE.
B (A0
)+, $FFFA1f
117 MOVE.
B (A0
)+, $FFFA21
119 MOVE.W
#$2300, SR ; Unmask interrupts.
121 BSR ymamoto_reset ; Mute YM.
123 MOVE.
B #%10010110, $FFFC00 ; Interrupts on, 8N1, clock/64.
124 .0: BTST
#1, $FFFC00 ; ACIA Tx buffer full?
126 MOVE.
B #8, $FFFC02 ; I suppose we'd better restore the mouse.
130 * Called each vertical blank.
132 MOVEM.
L D0-D2
/A0-A2
, -(SP
)
134 MOVE.W
#0, $FF8240 ; Black by default.
135 MOVE.W
#$FFFF, $FF8242 ; White text.
137 ; Update sine values.
138 BSR step_sine_oscillator
140 ; Update positions of bars.
141 MOVE.W sine
, D0 ; Circular motion around X axis.
149 MOVE.W sine
, D0 ; Circular motion around X axis.
158 ; Setup scanline
/hblank routine.
159 CLR.
B $FFFA1B ; Disable timer B.
160 MOVE.
B bar_a_y+
1, $FFFA21
161 MOVE.
L #scanline_bar_a, timer_b_vector
162 MOVE.
B #$18, $FFFA1B ; Enable timer B (event mode).
163 BSET
#0, $FFFA07 ; intA enable timer B.
164 BSET
#0, $FFFA13 ; intA mask, unmask timer B.
166 MOVE.W bar_a_y
, scanline
167 MOVE.W
#$310, next_palette_value
176 MOVEM.
L (SP
)+, D0-D2
/A0-A2
181 MOVE.W
#$2300, SR ; disable ourselves.
185 MOVE.W next_palette_value
, $FF8240
186 MOVEM.
L D0-D2
/A0
, -(SP
)
187 .0: ; get delta of current scanline to initial y
190 SUB.W D1
, D0 ; D0
= scanline
- y_a
200 .1: ;MOVE.
L #scanline_bar_b, timer_b_vector
203 ;MOVE.
B #$18, $FFFA1B
207 .2: MOVE.
B #0, $FFFA1B
212 .3: ; get color according to delta
221 .5: DC.W $
310, $
421, $
421, $
632, $
632, $
632, $
632
222 DC.W $
421, $
421, $
310, 0
223 .6: ; XXX modify by Z
224 MOVE.W D1
, next_palette_value
226 MOVEM.
L (SP
)+, D0-D2
/A0
227 BCLR #0, $FFFA0F ; Ack interrupt?
231 ;
1bpp scrolltext along middle of screen.
234 MOVE.
L vram_address
, A0
237 MOVE.W scrolly_pos
, D0
238 CMP.W
#(scroll_text_len<<3), D0
241 MOVE.W D0
, scrolly_pos
245 MOVE.W scrolly_pos
, D0
254 LEA scrolly_buffer
, A2
255 .1 MOVE.
B (A1
)+, (A2
)+
260 LEA scrolly_buffer
, A1
285 ADD.W
#1, scrolly_pos
288 GLOBAL plot_debug_dword
290 MOVEM.
L D0-D2
/A0-A2
, -(SP
)
291 LEA debug_string_buf
, A2
298 MOVE.
B (A1
,D2
), (A2
)+
301 LEA debug_string_buf
, A2
302 BSR plot_debug_string
303 MOVEM.
L (SP
)+, D0-D2
/A0-A2
307 ; A2
= address of string
, NUL terminated.
309 MOVE.
L vram_address
, A0
317 .2: MOVE.
B (A1
)+, (A0
)
335 saved_system_palette
: ds.
b 32
336 saved_system_res
: ds.
b 1
339 scrolly_buffer
: ds.
b 16
345 next_palette_value
: ds.w
1
346 debug_string_buf
: ds.
b 10
350 tune_data
: incbin
"ch-1.bin"
351 one_bpp_font
: incbin
"readable.f08"
352 scroll_text
: DC.
B "The mandatory scrolltext... tek speaking. Yes, it's unbelievable that I'm so lazy that I didn't implement any cool effects in this scrolly. I've been struggling with these damned MiNT cross-targetted binutils for the past two weeks -- I can never be sure whether the bugs are in my code or in the tools, because each available version of the binutils produces different eccentric behavior. Next time, I'll have all this stuff fixed, and probably will have jettisoned these fucking binutils for a real assembler/linker. Greets? Of course. Greets go out to the lonely St. John's scene, such as it is -- Retsyn, Michael (you need a new handle)... uh, and how about all the people who were sceners in some sense but then disappeared... off the top of my head I'm thinking of mr. nemo, jason, flyer, rubix... Anyway. Write more code! "
353 scroll_text_len
= (. - scroll_text)
354 hex_xlat
: DC.
B "0123456789abcdef"