Blahtune -------- Quick Reference, last revised 7/14/97 Version A# Latest binaries and documentation at http://stratus.esam.nwu.edu/~judd/fridge/ Email sjudd@nwu.edu ----- Play saved tune from BASIC: SYS 4102 Warm restart: $7C00 (SYS 31744) - Don't forget to set device # on a reboot! Cold restart: $7C03 Kernal ------ $1000 MAINPLAY - The main player routine $1003 PLAYINIT - Initialize the player $1006 SETIRQ - Wedge player into current IRQ routine $1009 LOADINST - Load instrument (inst # in .X) $100C GETP - Get field pointer for current voice (.A,.X = lo,hi) $100F SETP - Set field pointer for current voice $1012 V1GETP - Get field pointer for voice 1 (.A,.X) $1015 V2GETP $1018 V3GETP $101B V1SETP - Set field pointer for voice 1 (.A,.X) $101E V2SETP $1021 V3SETP $1024 RETURN - Macro exit Keywords -------- Compiler is CASE SENSITIVE AND EXPECTS lower CASE. ; Comment <- (Backarrow) Continue on next line BADD/WADD SRC > DEST DEST + SRC -> DEST BAND/WAND SRC > DEST DEST AND SRC -> DEST BDEC/WDEC ARG ARG + 1 -> ARG BEOR/WEOR SRC > DEST DEST EOR SRC -> DEST BINC/WINC ARG ARG - 1 -> ARG BMOVE/WMOVE SRC > DEST SRC -> DEST BOR/WOR SRC > DEST DEST OR SRC -> DEST BSUB/WSUB SRC > DEST DEST - SRC -> DEST BTEST/WTEST SRC > DEST DEST - SRC nothing is stored, just sets the flags COMMENT string Place STRING directly into the code DATA User defined label, can be referenced as a variable DONE Halt macro EMBED byte byte ...Places bytes directly into code ENTRY Set initial macro entry point ILOAD ARG Load current voice with instrument number ARG LOOP Repeat following code... UNTIL FLAG ...until FLAG is true (set) FOREVER ...forever (until macro is deactivated or restarted) GETP ARG Place current field data pointer into ARG SETP ARG Set current field pointer to ARG,ARG+1 (lo,hi) V1GETP ARG Load specific field pointer into ARG,ARG+1 V2GETP . V3GETP . V1SETP Load ARG,ARG+1 into a specific field pointer V2SETP . V3SETP . WAIT Return control to player routine WHEN/LWHEN FLAG Execute block if FLAG is true ELSE Execute block if FLAG is false WEND End WHEN block Flags EQU NEQ POS NEG Arguments: --------- # #$ #% - Immediate $ - Address ,ARG - Indexed mode + - - Offsets (#immediate values only!) &ARG - Additionals Variables: ATDK attack/decay register for the current voice (SHADOW+#5,COFFSET) COFFSET SID offset (0 7 14) for current voice CREG control register for the current voice (SHADOW+#4,COFFSET) CURFIELD current field (global macros are field 0) CURVOICE current voice (1 2 3) DATA user-defined variable DUR (remaining) duration of the current note for the current field FLOTAB table of the low bytes of frequencies FHITAB table of the high bytes of frequencies FREQ frequency of the current voice (word, SHADOW,COFFSET) INST instrument for the current field NOTE note value for the current field PWIDTH pulse width of the current voice (word, SHADOW+#2,COFFSET) SHADOW shadow SID maintained by the system SID the real SID, $D400 SUREL sustain/release register for the current voice (SHADOW+#6,COFFSET) V1STOP if it is set to a nonzero value, voice will not be processed at all V2STOP . V3STOP . G0, G1, ..., G15 Global variables. L0, L1, ..., L7 Local variables. M0, M1, ..., M31 Markers. SID registers ------------- Offsets from $D400 (Voice 1) $00,$01 Frequency, low/high byte $02,$03 Pulse width, low/high byte (only bits 0..3 of $03 are used) $04 Voice 1 control register bits 0 gate bit (turn voice on/off) 1 hard sync (synchronize to voice 3) 2 ring modulation (modulate to voice 3) 3 test bit (reset voice) 4 triangle (waveforms) 5 saw 6 pulse 7 noise $05 Attack/decay bits 0..3 decay (0-15) 7..4 attack (0-15) $06 Sustain/release bits 0..3 release (0-15) 7..4 sustain (0-15) $07 - $0D Voice 2 (same as above) $0E - $14 Voice 3 (same as above) $15-$16 Filter cutoff $15 bits 0..2 Low bits of cutoff frequency 3..7 Unused $16 High byte of cutoff frequency $17 Filter control register bits 0 Filter voice 1 1 Filter voice 2 2 Filter voice 3 3 Filter external voice 4..7 Filter resonance (0-15) $18 bits 0..3 Main volume (0-15) 4 Low pass filter 5 Band pass filter 6 High pass filter 7 Disable voice 3 output Read-only registers: $19 X potentiometer $1A Y potentiometer $1B Voice 3 waveform $1C Voice 3 envelope SPED ---- Return Insert line C=-d Delete line Sh-clr Clear all text R/S Exit SPED / abort command C=-x Exit F7 Disk menu (load/save individual macros) C=-c Compile macro (to temporary buffer at $E000) Instrument Editor ----------------- 1,2,3 Select voice 1 2 or 3 a Move to Attack f Move to Frequency shift-f Move to filter toggles tspn Toggle triangle/sawtooth/pulse/noise bits gyre Toggle gate/sync/ring/test bits CRSR UP/DN Quite obvious I think Space Toggle +/- Inc/Dec value Shift +/- Inc/Dec value by large amount < > Mult/Div value by 2 (pulse width, frequency, and cutoff) shift-l Load instrument (from instrument table) shift-s Save instrument (to inst table) F1 Music editor F5 Macro manager (One key, * or Lira or some such, toggles the disable voice 3 output bit) Macro Manager ------------- CRSR UP/DN Delete all files on current drive and reset computer CRSR RT Edit macro name e or Return Edit macro c Compile all macros d Delete macro Shift-CLR Reset (delete) all macros CTRL-p Play song from beginning/Stop playing song F1 Music editor F3 Instrument editor F7 Disk menu Music Editor ------------ CRSR UP/DN,L/R Navigate Return Insert line and move cursor forward Space Accept current value INST Insert DEL Delete C=-x Set block/cut to clipboard C=-c Set block/copy to clipboard C=-p Paste from clipboard C=-f Set fold block/end fold block % Open/close fold toggle C=-5 (C=-%) Dissolve fold @ Goto line Shift-@ Goto marker HOME Set home (bookmark) C=-HOME Go home < Page up > Page down C=-< Go to beginning of field C=-> Go to end of field . (Play note under cursor/Transpose note under cursor and) advance cursor Shift-CLR Clear all data shift-^ (pi) Clear SID * Toggle gate bit for current voice a-w,y Notes 0-24 a-l,a#-l# Notes 0-24, alternate form x Hold note 0-7 Octave 0-9,A-N Duration +/- Increment/decrement default octave <- (backarrow) Back up one level in note-octave-dur sequence Other: CTRL- e Exit to BASIC (RS/RESTORE to re-enter editor) CTRL- i Set interrupt CTRL- d Edit duration table (Run/Stop or 'e' to exit) CTRL- n Edit note table (Run/Stop or 'e' to exit) CTRL- z Display instrument table CTRL- p Play song SHIFT-CTRL-p Play song from current location C=+, C=- Double/halve current play speed (temporary, playback only) = Toggle border raster CTRL- a Audible (play notes as they are entered) CTRL- t Enable transpose shift-CTRL-t Set transpose values (negative values allowed) . Play note under cursor (if audible), transpose under cursor (if transpose active), and advance cursor CTRL- s Single step - space, (s)kip, (c)hange skip value, return=exit SHIFT-CTRL-s Single step from current location F3 Instrument editor F5 Macro manager F7 Disk menu F8 Load old version data disk menu -- DON'T forget to recompile! :) Player directives: Shift-w Set volume (The nuclear wessel displaces a large wolume) Shift-l Activate local macro (0-23) C=- l Deactivate local (0-23) Shift-g Activate global macro (0-23) C=- g Deactivate global (0-23) Shift-v Load local variable with value (0-7, 0-255) C=- v Load global variable (0-15, 0-255) Shift-m Set marker (0-31) C=- m Clear marker (0-31) Shift-i Load instrument (0-13) Shift-j Jump to marker C=-j Jump to subroutine at marker C=-s Return from Subroutine Shift-r Repeat begin (0-255 repetitions) C=- r End repeat Shift-o Gate on C=- o Gate off Shift-s Stop voice Shift-z Restart player Pressing Run/Stop-RESTORE resets Tunesmith. R/S-RESTORE will get you out of a jam in most cases. Everything -- music, instruments, tables, macros, etc. -- is preserved as best as can be. Things that bite: - When a song is playing the cursor will not flash and Run/Stop is not scanned. - Calling uncompiled macros can lead to disaster. The Macro pointer in the status box is highlighted when macros have not been compiled. - Missing macro ENTRY points can lead to disaster. - Saving music does not save macro text, and vice versa. - Instruments should be saved before being used. - If no volume is set then no volume will be heard. - SID is read only, so use the Shadow SID for modifications - Be sure to write values to both the Shadow and real SID if you want to see and hear them! - Macros _always_ preserve .Y -- if they jump to an outside program, make sure it preserves .Y as well! - There at least eight different versions of SID, not to mention different filter capacitors; some instrument settings (combinations of waveforms, certain filter settings, etc.) may not work at all on some SIDs! Memory layout: $0800 Editor stuff $1000-$19xx or so Player $19xx Compiled macros Field 1 data Field 2 data Field 3 data FIELDEND Fold stuff FREBOT Free memory ... Clipboard FRETOP End of free memory Macro text $7A7E Macro names and addresses (hot date tonight!) $7C00 Beginning of main program $CDFF End of main program $CE00-$CFFF Used by compiler $E000 Free mem, spare compile buffer Macro text builds downwards from the top of memory; folds, fields and compiled macros build upwards. The clipboard is stored in the top of free memory. There is typically around 22k of free memory (which is quite a lot of room). Converting between PAL and NTSC ------------------------------- The editor uses a default timer setting of $42C6, which synchronizes the player with an NTSC screen. PAL users (and some NTSC users) will need to set a different value using CTRL-i. The values are: 100% screen sync: 6567R56A: 64*262-1 $417F NTSC (rare) 6567R8+: 65*263-1 $42C6 NTSC (default) 6569: 63*312-1 $4CC7 PAL The player is synchronized with the screen when the border raster does not move. PAL and NTSC machines run at slightly different frequencies. Therefore to hear PAL tunes at PAL speeds on an NTSC machine the timer value should be multiplied by approximately 0.963353. Similarly, PAL users should multiply by 1.03804 to hear NTSC tunes at NTSC speeds. It's not MUCH of a difference, but it's a difference :). Finally, the PAL note values are different than the (default) NTSC values -- that is, identical pitches (to the ear) require different frequency settings using CTRL-n on PAL/NTSC machines. (It's not *necessary* to change them, but it's worth being aware of :).