From 56b2c59624daf22000fa5b4fcfc96e353fb35aef Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Sat, 17 Sep 2005 21:58:14 +0100 Subject: [PATCH] Cleaned up a little. --- README | 8 +++----- playtest.s | 4 +--- sine-oscillator.s | 2 +- ymamoto.s | 39 +++++++++++++++++++++++---------------- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/README b/README index 0e4e910..79cd3ae 100644 --- a/README +++ b/README @@ -14,13 +14,11 @@ am more familiar with the ST and the YM. So, YMamoto, when finished, should be suitable at least for music disks and parts of demos where cycles aren't too scarce. -You may need the m68k-atari-mint binutils to compile this. - USING YMAMOTO IN ANOTHER PROGRAM Call ymamoto_init with A0 pointing to the song data, and D0 set to the -track index to play. +track index to play. Note that the first track index is 1, not 0. Call ymamoto_update once per frame until it returns $FFFF in D0. @@ -42,7 +40,7 @@ pointer to arpeggio table (word, relative, >>2) pointer to volume envelope table (word, relative, >>2) pointer to vibrato table (word, relative, >>2) number of tracks (byte) - Should always be >1. + Should always be >=1. offset to track 0 (word, relative, >>2) offset to track ... @@ -73,7 +71,7 @@ Global commands: (can occur in any channel; need only occur once) 10rr rccc xxxx xxxx r => reserved. c => -every track must end \ 000 => track end +every track must end \ 000 => track end (not followed by any data) with one of these. / 001 => track loop 010 => trigger external event x => command data diff --git a/playtest.s b/playtest.s index 9225546..1f488d2 100644 --- a/playtest.s +++ b/playtest.s @@ -2,9 +2,6 @@ * Simple ST application to playback YMamoto tunes. * This is based on some simple code that Michael Bricout gave me. * - * Also, this is tweaked to work with GNU as, which means that - * it's not only my fault that the style is ugly. - * * Julian Squires / 2004-2005 * @@ -355,3 +352,4 @@ one_bpp_font: incbin "readable.f08" 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! " scroll_text_len = (. - scroll_text) hex_xlat: DC.B "0123456789abcdef" + * vim:syn=asm68k diff --git a/sine-oscillator.s b/sine-oscillator.s index ba6b6ff..0056d55 100644 --- a/sine-oscillator.s +++ b/sine-oscillator.s @@ -11,7 +11,7 @@ global reset_sine_oscillator reset_sine_oscillator: - MOVE.W #256, cosine ; Fairly arbitrary max amplitude. + MOVE.W #$100, cosine ; Fairly arbitrary max amplitude. MOVE.W #0, sine RTS diff --git a/ymamoto.s b/ymamoto.s index 75d020d..fee0a43 100644 --- a/ymamoto.s +++ b/ymamoto.s @@ -23,12 +23,6 @@ ;; CONSTANT SYMBOLS number_of_channels = 3 - * This playback /was/ dependant on this value, but now all durations - * are fixed cycles, so to change this, you should really just - * recompile the songs with mumble. I don't think there's any reason - * this is here anymore, except to provide something to attach to - * this historical note. -playback_frequency = 50 ; Hertz ;; song data structure song_data_arpeggio_pointer = 0 @@ -102,6 +96,8 @@ ymamoto_init: MOVEM.L D0-D1/A0-A2, -(A7) BSR ymamoto_reset + MOVE.L A0, songptr + ;; FIXME verify that the supplied track is not out of bounds. ;; setup pointers: channels for this track, tables. @@ -142,11 +138,12 @@ ymamoto_reset: RTS -;; ymamoto_update: call once per frame, a0 = song pointer. +;; ymamoto_update: call once per frame. GLOBAL ymamoto_update ymamoto_update: MOVEM.L D0-D6/A0-A1, -(A7) + MOVE.L songptr, A0 LEA song_status, A1 MOVE.B #13-1, song_registers_to_write(A1) @@ -208,7 +205,7 @@ update_channel: MOVE.W (A2)+, D1 BPL .process_new_note ;; otherwise, this is a command. - BTST #14, D1 + BTST.L #14, D1 BEQ .global_command @@ -254,7 +251,6 @@ command_jump_table_len = (. - .command_jump_table)/4 BRA .load_new_command .env_follow_command: - BRA .load_new_command ; XXX HACK TEST BTST.B #0, D1 BEQ .disable_env_follow BSET.B #channel_state_env_follow, channel_state(A1) @@ -300,9 +296,14 @@ command_jump_table_len = (. - .command_jump_table)/4 .track_loop_command: CMP.B #1, D2 BNE .trigger_command - BSR reset_channel + MOVE.L songptr, A0 + MOVE.B #1, D0 + BSR ymamoto_init + BRA .update_end + ;; XXX below unused, potentially flaky MOVEQ #0, D2 MOVE.W (A2)+, D2 + BSR reset_channel ADD.W D2, D2 ADD.L D2, channel_data_ptr(A1) MOVEA.L channel_data_ptr(A1), A2 @@ -466,7 +467,7 @@ command_jump_table_len = (. - .command_jump_table)/4 MOVE.B D1, $C(A3) ; Env rough adjustment. BTST.B #channel_state_first_frame, channel_state(A1) BEQ .set_frequency ; only update on first frame of note. - MOVE.B #$E, $D(A3) ; Env shape: CONT;ATT;ALT + MOVE.B #$E, $D(A3) ; Env shape: CONT;ATT LEA song_status, A2 MOVE.B #14-1, song_registers_to_write(A2) @@ -482,7 +483,6 @@ command_jump_table_len = (. - .command_jump_table)/4 ADD.B D0, D1 MOVE.B D3, (A3,D1) - ;; Volume effects. .lookup_volume: MOVE.B channel_current_volume(A1), D3 @@ -515,9 +515,12 @@ command_jump_table_len = (. - .command_jump_table)/4 ;;; End of main playroutine. - ;; Takes D0 = channel number, A0 = song ptr. + ;; Takes D0 = channel number. + ;; Returns channel status pointer in A1. reset_channel: - MOVEM.L D0-D1/A0-A2, -(A7) ; save registers + MOVEM.L D0-D1/A0/A2, -(A7) ; save registers + + MOVE.L songptr, A0 ;; load appropriate track address. LEA song_status, A1 @@ -555,7 +558,7 @@ reset_channel: ;; enable channel. BSET.B #channel_state_enabled, channel_state(A1) - MOVEM.L (A7)+, D0-D1/A0-A2 ; restore registers + MOVEM.L (A7)+, D0-D1/A0/A2 ; restore registers RTS @@ -600,10 +603,14 @@ note_to_ymval_xlate: ; GLOBAL VARIABLES -; Don't put these in BSS! The sc68 replay will be broken. + + SECTION BSS EVEN channel_status: DS.B channel_status_size*number_of_channels EVEN song_status: DS.B song_status_size + EVEN +songptr: DS.L 1 + * vim:syn=asm68k -- 2.11.4.GIT