mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-05 21:34:30 +00:00
tiny_tracker: working on things
This commit is contained in:
parent
15e5495d24
commit
28fb6d13ba
@ -1,10 +1,10 @@
|
||||
include ../../../Makefile.inc
|
||||
include ../../Makefile.inc
|
||||
|
||||
DOS33 = ../../../utils/dos33fs-utils/dos33
|
||||
EMPTY_DISK = ../../../empty_disk
|
||||
HGR2PNG = ../../../utils/hgr-utils/png2hgr
|
||||
LINKER_SCRIPTS = ../../../linker_scripts
|
||||
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
|
||||
DOS33 = ../../utils/dos33fs-utils/dos33
|
||||
EMPTY_DISK = ../../empty_disk
|
||||
HGR2PNG = ../../utils/hgr-utils/png2hgr
|
||||
LINKER_SCRIPTS = ../../linker_scripts
|
||||
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
|
||||
|
||||
all: hgr_d2.dsk text_to_tiny
|
||||
|
||||
@ -12,10 +12,12 @@ submit: hgr_d2_1k.zip
|
||||
|
||||
####
|
||||
|
||||
hgr_d2.dsk: HELLO D2
|
||||
hgr_d2.dsk: HELLO D2 D3 D4
|
||||
cp $(EMPTY_DISK)/empty.dsk ./hgr_d2.dsk
|
||||
$(DOS33) -y hgr_d2.dsk SAVE A HELLO
|
||||
$(DOS33) -y hgr_d2.dsk -t BIN -a 0x6000 BSAVE D2
|
||||
$(DOS33) -y hgr_d2.dsk -t BIN -a 0x6000 BSAVE D3
|
||||
$(DOS33) -y hgr_d2.dsk -t BIN -a 0x6000 BSAVE D4
|
||||
|
||||
####
|
||||
|
||||
@ -37,6 +39,11 @@ mA2E_2.s: mA2E_2.txt text_to_tiny
|
||||
mA2E_3.s: mA2E_3.txt text_to_tiny
|
||||
./text_to_tiny mA2E_3.txt > mA2E_3.s
|
||||
|
||||
####
|
||||
|
||||
mA2E_4.s: mA2E_4.txt text_to_tiny
|
||||
./text_to_tiny mA2E_4.txt > mA2E_4.s
|
||||
|
||||
|
||||
####
|
||||
|
||||
@ -45,11 +52,37 @@ D2: d2.o
|
||||
|
||||
d2.o: d2.s \
|
||||
zp.inc hardware.inc \
|
||||
mA2E_2.s mA2E_3.s \
|
||||
mA2E_2.s \
|
||||
mockingboard_init.s play_frame.s \
|
||||
tracker_init.s ay3_write_regs.s
|
||||
ca65 -o d2.o d2.s -l d2.lst
|
||||
|
||||
####
|
||||
|
||||
D3: d3.o
|
||||
ld65 -o D3 d3.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
d3.o: d3.s \
|
||||
zp.inc hardware.inc \
|
||||
mA2E_3.s \
|
||||
mockingboard_init.s play_frame.s \
|
||||
tracker_init.s ay3_write_regs.s
|
||||
ca65 -o d3.o d3.s -l d3.lst
|
||||
|
||||
####
|
||||
|
||||
D4: d4.o
|
||||
ld65 -o D4 d4.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
d4.o: d4.s \
|
||||
zp.inc hardware.inc \
|
||||
mA2E_4.s \
|
||||
mockingboard_init.s play_frame.s \
|
||||
tracker_init.s ay3_write_regs.s
|
||||
ca65 -o d4.o d4.s -l d4.lst
|
||||
|
||||
|
||||
|
||||
####
|
||||
|
||||
text_to_tiny: text_to_tiny.o
|
||||
@ -61,4 +94,4 @@ text_to_tiny.o: text_to_tiny.c
|
||||
####
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.lst D2 HELLO text_to_tiny mA2E_2.s
|
||||
rm -f *~ *.o *.lst D2 HELLO text_to_tiny mA2E_2.s mA2E_3.s mA2E_4.s
|
||||
|
57
music/tiny_tracker5/d3.s
Normal file
57
music/tiny_tracker5/d3.s
Normal file
@ -0,0 +1,57 @@
|
||||
; Apple II graphics/music in 1k
|
||||
|
||||
; by deater (Vince Weaver) <vince@deater.net>
|
||||
|
||||
; Zero Page
|
||||
.include "zp.inc"
|
||||
.include "hardware.inc"
|
||||
|
||||
; for a 256 entry we need to fit in 252 bytes
|
||||
|
||||
; 310 bytes -- initial
|
||||
; 268 bytes -- strip out interrupts
|
||||
; 262 bytes -- simplify init
|
||||
; 261 bytes -- optimize init more
|
||||
; 253 bytes -- optimize var init
|
||||
; 252 bytes -- bne vs jmp
|
||||
; 250 bytes -- song only has 16 notes so can never be negative
|
||||
; 249 bytes -- make terminating value $80 instead of $FF
|
||||
; 247 bytes -- combine note loop. makes song a bit faster
|
||||
; 245 bytes -- try to optimize writing out volume
|
||||
; 255 bytes -- add in some visualization
|
||||
; 252 bytes -- re-arrange decode code
|
||||
d2:
|
||||
|
||||
;===================
|
||||
; music Player Setup
|
||||
|
||||
tracker_song = peasant_song
|
||||
|
||||
; assume mockingboard in slot#4
|
||||
|
||||
; inline mockingboard_init
|
||||
|
||||
.include "mockingboard_init.s"
|
||||
|
||||
.include "tracker_init.s"
|
||||
|
||||
jsr SETGR ; enable lo-res graphics
|
||||
|
||||
game_loop:
|
||||
; typically A=0, X=FF, Y=0 here
|
||||
|
||||
; play a frame of music
|
||||
|
||||
.include "play_frame.s"
|
||||
.include "ay3_write_regs.s"
|
||||
|
||||
; delay 20Hz, or 1/20s = 50ms
|
||||
|
||||
lda #140
|
||||
jsr WAIT
|
||||
|
||||
beq game_loop
|
||||
|
||||
; music
|
||||
.include "mA2E_3.s"
|
||||
|
57
music/tiny_tracker5/d4.s
Normal file
57
music/tiny_tracker5/d4.s
Normal file
@ -0,0 +1,57 @@
|
||||
; Apple II graphics/music in 1k
|
||||
|
||||
; by deater (Vince Weaver) <vince@deater.net>
|
||||
|
||||
; Zero Page
|
||||
.include "zp.inc"
|
||||
.include "hardware.inc"
|
||||
|
||||
; for a 256 entry we need to fit in 252 bytes
|
||||
|
||||
; 310 bytes -- initial
|
||||
; 268 bytes -- strip out interrupts
|
||||
; 262 bytes -- simplify init
|
||||
; 261 bytes -- optimize init more
|
||||
; 253 bytes -- optimize var init
|
||||
; 252 bytes -- bne vs jmp
|
||||
; 250 bytes -- song only has 16 notes so can never be negative
|
||||
; 249 bytes -- make terminating value $80 instead of $FF
|
||||
; 247 bytes -- combine note loop. makes song a bit faster
|
||||
; 245 bytes -- try to optimize writing out volume
|
||||
; 255 bytes -- add in some visualization
|
||||
; 252 bytes -- re-arrange decode code
|
||||
d2:
|
||||
|
||||
;===================
|
||||
; music Player Setup
|
||||
|
||||
tracker_song = peasant_song
|
||||
|
||||
; assume mockingboard in slot#4
|
||||
|
||||
; inline mockingboard_init
|
||||
|
||||
.include "mockingboard_init.s"
|
||||
|
||||
.include "tracker_init.s"
|
||||
|
||||
jsr SETGR ; enable lo-res graphics
|
||||
|
||||
game_loop:
|
||||
; typically A=0, X=FF, Y=0 here
|
||||
|
||||
; play a frame of music
|
||||
|
||||
.include "play_frame.s"
|
||||
.include "ay3_write_regs.s"
|
||||
|
||||
; delay 20Hz, or 1/20s = 50ms
|
||||
|
||||
lda #140
|
||||
jsr WAIT
|
||||
|
||||
beq game_loop
|
||||
|
||||
; music
|
||||
.include "mA2E_4.s"
|
||||
|
@ -3,4 +3,4 @@
|
||||
20 PRINT CHR$(4);"CATALOG"
|
||||
25 PRINT:PRINT "AUTOMATICALLY STARTING"
|
||||
30 PRINT "]BRUN D2"
|
||||
40 PRINT CHR$(4);"BRUN D2"
|
||||
|
||||
|
145
music/tiny_tracker5/mA2E_4.txt
Normal file
145
music/tiny_tracker5/mA2E_4.txt
Normal file
@ -0,0 +1,145 @@
|
||||
'' TITLE: Mockingboard Tune 4 - 2022
|
||||
' AUTHOR: mA2E / dSr
|
||||
' COMMENTS:
|
||||
'
|
||||
' LOOP: 640
|
||||
'
|
||||
' BPM: 250
|
||||
' TEMPO: 6
|
||||
' FREQ: 1000000
|
||||
' IRQ: 50
|
||||
'
|
||||
' LYRICS: 0
|
||||
'
|
||||
' ENDHEADER
|
||||
-------
|
||||
' 1
|
||||
0 C 2-- ----- G-5--
|
||||
1 ----- ----- -----
|
||||
2 C 2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 C 3-- ----- E 6--
|
||||
5 ----- ----- -----
|
||||
6 C 2-- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 A#1-- ----- D 6--
|
||||
9 ----- ----- -----
|
||||
A C 2-- ----- C 6--
|
||||
B ----- ----- -----
|
||||
C D#2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- ----- A#5--
|
||||
F ----- ----- -----
|
||||
10 A#1-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 A#1-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 A#2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 A#1-- ----- A#5--
|
||||
17 ----- ----- -----
|
||||
18 G#1-- ----- A 5--
|
||||
19 ----- ----- -----
|
||||
1A G 1-- ----- A#5--
|
||||
1B ----- ----- -----
|
||||
1C F 1-- ----- A 5--
|
||||
1D ----- ----- -----
|
||||
1E D#1-- ----- G 5--
|
||||
1F ----- ----- -----
|
||||
20 C 2-- ----- F 5--
|
||||
21 ----- ----- -----
|
||||
22 C 2-- ----- E 5--
|
||||
23 ----- ----- -----
|
||||
24 C 3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 C 2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 A#1-- ----- G 5--
|
||||
29 ----- ----- -----
|
||||
2A C 2-- ----- -----
|
||||
2B ----- ----- -----
|
||||
2C D#2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- ----- -----
|
||||
2F ----- ----- -----
|
||||
30 F 2-- ----- -----
|
||||
31 ----- ----- -----
|
||||
32 F 2-- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 F 3-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 F 3-- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 D#3-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A D 3-- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C C 3-- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E A#2-- ----- -----
|
||||
3F ----- ----- -----
|
||||
' 1
|
||||
0 C 2-- ----- G 5--
|
||||
1 ----- ----- -----
|
||||
2 C 2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 C 3-- ----- E 6--
|
||||
5 ----- ----- -----
|
||||
6 C 2- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 A#1-- ----- D 6--
|
||||
9 ----- ----- -----
|
||||
A C 2-- ----- E 6--
|
||||
B ----- ----- -----
|
||||
C D#2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- ----- F 6--
|
||||
F ----- ----- -----
|
||||
10 A#1-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 A#1-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 A#2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 A#1-- ----- E 6--
|
||||
17 ----- ----- -----
|
||||
18 G#1-- ----- F 6--
|
||||
19 ----- ----- -----
|
||||
1A G 1-- ----- E 6--
|
||||
1B ----- ----- -----
|
||||
1C F 1-- ----- D 6--
|
||||
1D ----- ----- -----
|
||||
1E D#1-- ----- C 6--
|
||||
1F ----- ----- -----
|
||||
20 C 2-- ----- E 5--
|
||||
21 ----- ----- -----
|
||||
22 C 2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 C 3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 C 2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 A#1-- ----- -----
|
||||
29 ----- ----- -----
|
||||
2A C 2-- ----- -----
|
||||
2B ----- ----- -----
|
||||
2C D#2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- ----- -----
|
||||
2F ----- ----- -----
|
||||
30 F 2-- ----- -----
|
||||
31 ----- ----- -----
|
||||
32 F 2-- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 F 3-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 F 3-- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 D#3-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A D 3-- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C C 3-- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E A#2-- ----- -----
|
||||
3F ----- ----- -----
|
56
music/tiny_tracker6/Makefile
Normal file
56
music/tiny_tracker6/Makefile
Normal file
@ -0,0 +1,56 @@
|
||||
include ../../Makefile.inc
|
||||
|
||||
DOS33 = ../../utils/dos33fs-utils/dos33
|
||||
EMPTY_DISK = ../../empty_disk
|
||||
HGR2PNG = ../../utils/hgr-utils/png2hgr
|
||||
LINKER_SCRIPTS = ../../linker_scripts
|
||||
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
|
||||
|
||||
all: hgr_d2.dsk text_to_tiny
|
||||
|
||||
submit: hgr_d2_1k.zip
|
||||
|
||||
####
|
||||
|
||||
hgr_d2.dsk: HELLO D4
|
||||
cp $(EMPTY_DISK)/empty.dsk ./hgr_d2.dsk
|
||||
$(DOS33) -y hgr_d2.dsk SAVE A HELLO
|
||||
$(DOS33) -y hgr_d2.dsk -t BIN -a 0x6000 BSAVE D4
|
||||
|
||||
####
|
||||
|
||||
HELLO: hello.bas
|
||||
$(TOKENIZE) < hello.bas > HELLO
|
||||
|
||||
####
|
||||
|
||||
mA2E_4.s: mA2E_4.txt text_to_tiny
|
||||
./text_to_tiny mA2E_4.txt > mA2E_4.s
|
||||
|
||||
|
||||
####
|
||||
|
||||
D4: d4.o
|
||||
ld65 -o D4 d4.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
d4.o: d4.s \
|
||||
zp.inc hardware.inc \
|
||||
mA2E_4.s \
|
||||
mockingboard_init.s play_frame.s \
|
||||
tracker_init.s ay3_write_regs.s
|
||||
ca65 -o d4.o d4.s -l d4.lst
|
||||
|
||||
|
||||
|
||||
####
|
||||
|
||||
text_to_tiny: text_to_tiny.o
|
||||
$(CC) -o text_to_tiny text_to_tiny.o -lm
|
||||
|
||||
text_to_tiny.o: text_to_tiny.c
|
||||
$(CC) $(CFLAGS) -c text_to_tiny.c
|
||||
|
||||
####
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.lst D2 HELLO text_to_tiny mA2E_2.s mA2E_3.s mA2E_4.s
|
5
music/tiny_tracker6/TODO
Normal file
5
music/tiny_tracker6/TODO
Normal file
@ -0,0 +1,5 @@
|
||||
hard-coded volume change channel A
|
||||
|
||||
have pattern table and follow it
|
||||
have volume trigger and action for channel B
|
||||
|
34
music/tiny_tracker6/ay3_write_regs.s
Normal file
34
music/tiny_tracker6/ay3_write_regs.s
Normal file
@ -0,0 +1,34 @@
|
||||
;=====================
|
||||
;=====================
|
||||
;=====================
|
||||
; ay3 write regs
|
||||
;=====================
|
||||
;=====================
|
||||
;=====================
|
||||
; write all 14 registers at AY_REGS
|
||||
|
||||
ay3_write_regs:
|
||||
|
||||
ldx #13
|
||||
ay3_write_reg_loop:
|
||||
|
||||
lda #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
|
||||
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
|
||||
|
||||
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
|
||||
sta MOCK_6522_ORB1 ; latch_address on PB1 ; 4
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
|
||||
; value
|
||||
lda AY_REGS,X
|
||||
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||
lda #MOCK_AY_WRITE ; ; 2
|
||||
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
|
||||
dex
|
||||
bpl ay3_write_reg_loop
|
||||
|
||||
; rts
|
||||
|
||||
|
63
music/tiny_tracker6/d4.s
Normal file
63
music/tiny_tracker6/d4.s
Normal file
@ -0,0 +1,63 @@
|
||||
; Apple II graphics/music in 1k
|
||||
|
||||
; by deater (Vince Weaver) <vince@deater.net>
|
||||
|
||||
; Zero Page
|
||||
.include "zp.inc"
|
||||
.include "hardware.inc"
|
||||
|
||||
; for a 256 entry we need to fit in 252 bytes
|
||||
|
||||
; 310 bytes -- initial
|
||||
; 268 bytes -- strip out interrupts
|
||||
; 262 bytes -- simplify init
|
||||
; 261 bytes -- optimize init more
|
||||
; 253 bytes -- optimize var init
|
||||
; 252 bytes -- bne vs jmp
|
||||
; 250 bytes -- song only has 16 notes so can never be negative
|
||||
; 249 bytes -- make terminating value $80 instead of $FF
|
||||
; 247 bytes -- combine note loop. makes song a bit faster
|
||||
; 245 bytes -- try to optimize writing out volume
|
||||
; 255 bytes -- add in some visualization
|
||||
; 252 bytes -- re-arrange decode code
|
||||
d2:
|
||||
|
||||
;===================
|
||||
; music Player Setup
|
||||
|
||||
tracker_song = peasant_song
|
||||
|
||||
; assume mockingboard in slot#4
|
||||
|
||||
; inline mockingboard_init
|
||||
|
||||
.include "mockingboard_init.s"
|
||||
|
||||
.include "tracker_init.s"
|
||||
|
||||
jsr SETGR ; enable lo-res graphics
|
||||
|
||||
game_loop:
|
||||
; typically A=0, X=FF, Y=0 here
|
||||
|
||||
; play a frame of music
|
||||
|
||||
.include "play_frame.s"
|
||||
.include "ay3_write_regs.s"
|
||||
|
||||
; delay 20Hz, or 1/20s = 50ms
|
||||
|
||||
lda #140
|
||||
jsr WAIT
|
||||
|
||||
lda #140
|
||||
jsr WAIT
|
||||
|
||||
lda #140
|
||||
jsr WAIT
|
||||
|
||||
beq game_loop
|
||||
|
||||
; music
|
||||
.include "mA2E_4.s"
|
||||
|
92
music/tiny_tracker6/hardware.inc
Normal file
92
music/tiny_tracker6/hardware.inc
Normal file
@ -0,0 +1,92 @@
|
||||
;; HARDWARE LOCATIONS
|
||||
|
||||
KEYPRESS = $C000
|
||||
KEYRESET = $C010
|
||||
|
||||
;; SOFT SWITCHES
|
||||
CLR80COL = $C000 ; PAGE0/PAGE1 normal
|
||||
SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
|
||||
EIGHTYCOLOFF = $C00C
|
||||
EIGHTYCOLON = $C00D
|
||||
SPEAKER = $C030
|
||||
SET_GR = $C050
|
||||
SET_TEXT = $C051
|
||||
FULLGR = $C052
|
||||
TEXTGR = $C053
|
||||
PAGE1 = $C054
|
||||
PAGE2 = $C055
|
||||
LORES = $C056 ; Enable LORES graphics
|
||||
HIRES = $C057 ; Enable HIRES graphics
|
||||
AN3 = $C05E ; Annunciator 3
|
||||
|
||||
PADDLE_BUTTON0 = $C061
|
||||
PADDL0 = $C064
|
||||
PTRIG = $C070
|
||||
|
||||
;; BASIC ROUTINES
|
||||
|
||||
NORMAL = $F273
|
||||
HGR2 = $F3D8
|
||||
HCLR = $F3F2
|
||||
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
|
||||
XDRAW0 = $F65D
|
||||
|
||||
|
||||
;; MONITOR ROUTINES
|
||||
|
||||
HLINE = $F819 ;; HLINE Y,$2C at A
|
||||
VLINE = $F828 ;; VLINE A,$2D at Y
|
||||
CLRSCR = $F832 ;; Clear low-res screen
|
||||
CLRTOP = $F836 ;; clear only top of low-res screen
|
||||
SETGR = $FB40 ;; GR
|
||||
SETCOL = $F864 ;; COLOR=A
|
||||
TEXT = $FB36
|
||||
TABV = $FB5B ;; VTAB to A
|
||||
BELL = $FBDD ;; ring the bell
|
||||
BASCALC = $FBC1 ;;
|
||||
VTAB = $FC22 ;; VTAB to CV
|
||||
HOME = $FC58 ;; Clear the text screen
|
||||
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
||||
CROUT1 = $FD8B
|
||||
SETINV = $FE80 ;; INVERSE
|
||||
SETNORM = $FE84 ;; NORMAL
|
||||
COUT = $FDED ;; output A to screen
|
||||
COUT1 = $FDF0 ;; output A to screen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
COLOR_BLACK = 0
|
||||
COLOR_RED = 1
|
||||
COLOR_DARKBLUE = 2
|
||||
COLOR_PURPLE = 3
|
||||
COLOR_DARKGREEN = 4
|
||||
COLOR_GREY = 5
|
||||
COLOR_MEDIUMBLUE = 6
|
||||
COLOR_LIGHTBLUE = 7
|
||||
COLOR_BROWN = 8
|
||||
COLOR_ORANGE = 9
|
||||
COLOR_GREY2 = 10
|
||||
COLOR_PINK = 11
|
||||
COLOR_LIGHTGREEN = 12
|
||||
COLOR_YELLOW = 13
|
||||
COLOR_AQUA = 14
|
||||
COLOR_WHITE = 15
|
||||
|
||||
COLOR_BOTH_BLACK = $00
|
||||
COLOR_BOTH_RED = $11
|
||||
COLOR_BOTH_DARKBLUE = $22
|
||||
COLOR_BOTH_DARKGREEN = $44
|
||||
COLOR_BOTH_GREY = $55
|
||||
COLOR_BOTH_MEDIUMBLUE = $66
|
||||
COLOR_BOTH_LIGHTBLUE = $77
|
||||
COLOR_BOTH_BROWN = $88
|
||||
COLOR_BOTH_ORANGE = $99
|
||||
COLOR_BOTH_PINK = $BB
|
||||
COLOR_BOTH_LIGHTGREEN = $CC
|
||||
COLOR_BOTH_YELLOW = $DD
|
||||
COLOR_BOTH_AQUA = $EE
|
||||
COLOR_BOTH_WHITE = $FF
|
||||
|
6
music/tiny_tracker6/hello.bas
Normal file
6
music/tiny_tracker6/hello.bas
Normal file
@ -0,0 +1,6 @@
|
||||
5 HOME
|
||||
10 PRINT "HGR DEMO2 - 1K DEMO AT DEMOSPLASH 2021"
|
||||
20 PRINT CHR$(4);"CATALOG"
|
||||
25 PRINT:PRINT "AUTOMATICALLY STARTING"
|
||||
30 PRINT "]BRUN D2"
|
||||
|
342
music/tiny_tracker6/mA2E_4.txt
Normal file
342
music/tiny_tracker6/mA2E_4.txt
Normal file
@ -0,0 +1,342 @@
|
||||
'' TITLE: Mockingboard Tune 4 - 2022
|
||||
' AUTHOR: mA2E / dSr
|
||||
' COMMENTS:
|
||||
'
|
||||
' LOOP: 640
|
||||
'
|
||||
' BPM: 250
|
||||
' TEMPO: 6
|
||||
' FREQ: 1000000
|
||||
' IRQ: 50
|
||||
'
|
||||
' LYRICS: 0
|
||||
'
|
||||
' ENDHEADER
|
||||
-------
|
||||
' 0
|
||||
0 C 2-- G 5-- -----
|
||||
1 ----- ----- -----
|
||||
2 C 2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 C 3-- E 6-- -----
|
||||
5 ----- ----- -----
|
||||
6 C 2-- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 A#1-- D 6-- -----
|
||||
9 ----- ----- -----
|
||||
A C 2-- C 6-- -----
|
||||
B ----- ----- -----
|
||||
C D#2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- A#5-- -----
|
||||
F ----- ----- -----
|
||||
10 A#1-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 A#1-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 A#2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 A#1-- A 5-- -----
|
||||
17 ----- ----- -----
|
||||
18 G#1-- A#5-- -----
|
||||
19 ----- ----- -----
|
||||
1A G 1-- A 5-- -----
|
||||
1B ----- ----- -----
|
||||
1C F 1-- G 5-- -----
|
||||
1D ----- ----- -----
|
||||
1E D#1-- F 5-- -----
|
||||
1F ----- ----- -----
|
||||
20 C 2-- E 5-- -----
|
||||
21 ----- ----- -----
|
||||
22 C 2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 C 3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 C 2-- G 5-- -----
|
||||
27 ----- ----- -----
|
||||
28 A#1-- ----- -----
|
||||
29 ----- ----- -----
|
||||
2A C 2-- ----- -----
|
||||
2B ----- ----- -----
|
||||
2C D#2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- ----- -----
|
||||
2F ----- ----- -----
|
||||
30 F 2-- ----- -----
|
||||
31 ----- ----- -----
|
||||
32 F 2-- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 F 3-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 F 3-- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 D#3-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A D 3-- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C C 3-- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E A#2-- ----- -----
|
||||
3F ----- ----- -----
|
||||
' 1
|
||||
0 C 2-- G 5-- -----
|
||||
1 ----- ----- -----
|
||||
2 C 2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 C 3-- E 6-- -----
|
||||
5 ----- ----- -----
|
||||
6 C 2- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 A#1-- D 6-- -----
|
||||
9 ----- ----- -----
|
||||
A C 2-- E 6-- -----
|
||||
B ----- ----- -----
|
||||
C D#2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- F 6-- -----
|
||||
F ----- ----- -----
|
||||
10 A#1-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 A#1-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 A#2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 A#1-- E 6-- -----
|
||||
17 ----- ----- -----
|
||||
18 G#1-- F 6-- -----
|
||||
19 ----- ----- -----
|
||||
1A G 1-- E 6-- -----
|
||||
1B ----- ----- -----
|
||||
1C F 1-- D 6-- -----
|
||||
1D ----- ----- -----
|
||||
1E D#1-- C 6-- -----
|
||||
1F ----- ----- -----
|
||||
20 C 2-- E 5-- -----
|
||||
21 ----- ----- -----
|
||||
22 C 2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 C 3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 C 2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 A#1-- ----- -----
|
||||
29 ----- ----- -----
|
||||
2A C 2-- ----- -----
|
||||
2B ----- ----- -----
|
||||
2C D#2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- ----- -----
|
||||
2F ----- ----- -----
|
||||
30 F 2-- ----- -----
|
||||
31 ----- ----- -----
|
||||
32 F 2-- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 F 3-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 F 3-- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 D#3-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A D 3-- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C C 3-- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E A#2-- ----- -----
|
||||
3F ----- ----- -----
|
||||
' 2
|
||||
0 D#2-- D#6-- -----
|
||||
1 ----- ----- -----
|
||||
2 D#2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 D#3-- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 D#2-- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 F 2-- D 6-- -----
|
||||
9 ----- ----- -----
|
||||
A F 2-- C 6-- -----
|
||||
B ----- ----- -----
|
||||
C F 3-- A#5-- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- F 5-- -----
|
||||
F ----- ----- -----
|
||||
10 C 2-- G 5-- -----
|
||||
11 ----- ----- -----
|
||||
12 C 2-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 C 3-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 C 2-- ----- -----
|
||||
17 ----- ----- -----
|
||||
18 C 2-- ----- -----
|
||||
19 ----- ----- -----
|
||||
1A C 2-- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C C 3-- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E C 2-- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 D#2-- D#5-- -----
|
||||
21 ----- ----- -----
|
||||
22 D#2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 D#3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 D#2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 F 2-- G 5-- -----
|
||||
29 ----- ----- -----
|
||||
2A F 2-- F 5-- -----
|
||||
2B ----- ----- -----
|
||||
2C F 3-- D#5-- -----
|
||||
2D ----- D 5-- -----
|
||||
2E F 2-- C 5-- -----
|
||||
2F ----- A#4-- -----
|
||||
30 C 2-- C 5-- -----
|
||||
31 ----- ----- -----
|
||||
32 ----- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 A#1-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 ----- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 C 2-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A ----- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C ----- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E ----- ----- -----
|
||||
3F ----- ----- -----
|
||||
' 3
|
||||
0 D#2-- D#4-- -----
|
||||
1 ----- ----- -----
|
||||
2 D#2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 D#3-- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 D#2- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 F 2-- F 4-- -----
|
||||
9 ----- ----- -----
|
||||
A F 2-- G 4-- -----
|
||||
B ----- ----- -----
|
||||
C F 3-- A#4-- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- C 5-- -----
|
||||
F ----- ----- -----
|
||||
10 C 2-- G 4-- -----
|
||||
11 ----- ----- -----
|
||||
12 C 2-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 C 3-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 C 2-- ----- -----
|
||||
17 ----- ----- -----
|
||||
18 C 2-- ----- -----
|
||||
19 ----- ----- -----
|
||||
1A C 2-- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C C 3-- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E C 2-- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 D#2-- D#5-- -----
|
||||
21 ----- ----- -----
|
||||
22 D#2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 D#3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 D#2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 F 2-- C 5-- -----
|
||||
29 ----- ----- -----
|
||||
2A F 2-- D#5-- -----
|
||||
2B ----- ----- -----
|
||||
2C F 3-- F 5-- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- A#5-- -----
|
||||
2F ----- ----- -----
|
||||
30 C 2-- G 5-- -----
|
||||
31 ----- ----- -----
|
||||
32 C 2-- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 C 3-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 C 2-- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 C 2-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A C 2-- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C C 3-- ----- -----
|
||||
3D ----- ----- -----
|
||||
3E C 2-- ----- -----
|
||||
3F ----- ----- -----
|
||||
' 4
|
||||
0 C 2-- ----- -----
|
||||
1 ----- ----- -----
|
||||
2 C 2-- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 C 3-- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 C 2- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 A#1-- ----- -----
|
||||
9 ----- ----- -----
|
||||
A C 2-- ----- -----
|
||||
B ----- ----- -----
|
||||
C D#2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E F 2-- ----- -----
|
||||
F ----- ----- -----
|
||||
10 A#1-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 A#1-- ----- -----
|
||||
13 ----- ----- -----
|
||||
14 A#2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 A#1-- ----- -----
|
||||
17 ----- ----- -----
|
||||
18 G#1-- ----- -----
|
||||
19 ----- ----- -----
|
||||
1A G 1-- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C F 1-- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E D#1-- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 C 2-- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 C 2-- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 C 3-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 C 2-- ----- -----
|
||||
27 ----- ----- -----
|
||||
28 A#1-- ----- -----
|
||||
29 ----- ----- -----
|
||||
2A C 2-- ----- -----
|
||||
2B ----- ----- -----
|
||||
2C D#2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E F 2-- ----- -----
|
||||
2F ----- ----- -----
|
||||
30 F 2-- ----- -----
|
||||
31 ----- ----- -----
|
||||
32 ----- ----- -----
|
||||
33 ----- ----- -----
|
||||
34 D#2-- ----- -----
|
||||
35 ----- ----- -----
|
||||
36 ----- ----- -----
|
||||
37 ----- ----- -----
|
||||
38 C 2-- ----- -----
|
||||
39 ----- ----- -----
|
||||
3A ----- ----- -----
|
||||
3B ----- ----- -----
|
||||
3C ----- D#5-- -----
|
||||
3D ----- ----- -----
|
||||
3E ----- F 5-- -----
|
||||
3F ----- ----- -----
|
||||
|
||||
|
77
music/tiny_tracker6/mockingboard_init.s
Normal file
77
music/tiny_tracker6/mockingboard_init.s
Normal file
@ -0,0 +1,77 @@
|
||||
; Mockingboad programming:
|
||||
; + Has two 6522 I/O chips connected to two AY-3-8910 chips
|
||||
; + Optionally has some speech chips controlled via the outport on the AY
|
||||
; + Often in slot 4
|
||||
; TODO: how to auto-detect?
|
||||
; References used:
|
||||
; http://macgui.com/usenet/?group=2&id=8366
|
||||
; 6522 Data Sheet
|
||||
; AY-3-8910 Data Sheet
|
||||
|
||||
;========================
|
||||
; Mockingboard card
|
||||
; Essentially two 6522s hooked to the Apple II bus
|
||||
; Connected to AY-3-8910 chips
|
||||
; PA0-PA7 on 6522 connected to DA0-DA7 on AY
|
||||
; PB0 on 6522 connected to BC1
|
||||
; PB1 on 6522 connected to BDIR
|
||||
; PB2 on 6522 connected to RESET
|
||||
|
||||
|
||||
; left speaker
|
||||
MOCK_6522_ORB1 = $C400 ; 6522 #1 port b data
|
||||
MOCK_6522_ORA1 = $C401 ; 6522 #1 port a data
|
||||
MOCK_6522_DDRB1 = $C402 ; 6522 #1 data direction port B
|
||||
MOCK_6522_DDRA1 = $C403 ; 6522 #1 data direction port A
|
||||
MOCK_6522_T1CL = $C404 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1CH = $C405 ; 6522 #1 t1 high order counter
|
||||
MOCK_6522_T1LL = $C406 ; 6522 #1 t1 low order latches
|
||||
MOCK_6522_T1LH = $C407 ; 6522 #1 t1 high order latches
|
||||
MOCK_6522_T2CL = $C408 ; 6522 #1 t2 low order latches
|
||||
MOCK_6522_T2CH = $C409 ; 6522 #1 t2 high order counters
|
||||
MOCK_6522_SR = $C40A ; 6522 #1 shift register
|
||||
MOCK_6522_ACR = $C40B ; 6522 #1 auxilliary control register
|
||||
MOCK_6522_PCR = $C40C ; 6522 #1 peripheral control register
|
||||
MOCK_6522_IFR = $C40D ; 6522 #1 interrupt flag register
|
||||
MOCK_6522_IER = $C40E ; 6522 #1 interrupt enable register
|
||||
MOCK_6522_ORANH = $C40F ; 6522 #1 port a data no handshake
|
||||
|
||||
|
||||
; right speaker
|
||||
MOCK_6522_ORB2 = $C480 ; 6522 #2 port b data
|
||||
MOCK_6522_ORA2 = $C481 ; 6522 #2 port a data
|
||||
MOCK_6522_DDRB2 = $C482 ; 6522 #2 data direction port B
|
||||
MOCK_6522_DDRA2 = $C483 ; 6522 #2 data direction port A
|
||||
|
||||
; AY-3-8910 commands on port B
|
||||
; RESET BDIR BC1
|
||||
MOCK_AY_RESET = $0 ; 0 0 0
|
||||
MOCK_AY_INACTIVE = $4 ; 1 0 0
|
||||
MOCK_AY_READ = $5 ; 1 0 1
|
||||
MOCK_AY_WRITE = $6 ; 1 1 0
|
||||
MOCK_AY_LATCH_ADDR = $7 ; 1 1 1
|
||||
|
||||
|
||||
;========================
|
||||
;========================
|
||||
; Mockingboard Init
|
||||
;========================
|
||||
;========================
|
||||
; Left channel only
|
||||
|
||||
mockingboard_init:
|
||||
|
||||
;=========================
|
||||
; Initialize the 6522s
|
||||
; Reset Left AY-3-8910
|
||||
;===========================
|
||||
|
||||
ldx #$FF
|
||||
stx MOCK_6522_DDRB1
|
||||
stx MOCK_6522_DDRA1
|
||||
|
||||
inx ; #MOCK_AY_RESET $0
|
||||
stx MOCK_6522_ORB1
|
||||
ldx #MOCK_AY_INACTIVE ; $4
|
||||
stx MOCK_6522_ORB1
|
||||
|
78
music/tiny_tracker6/play_frame.s
Normal file
78
music/tiny_tracker6/play_frame.s
Normal file
@ -0,0 +1,78 @@
|
||||
play_frame:
|
||||
|
||||
;============================
|
||||
; see if still counting down
|
||||
|
||||
lda SONG_COUNTDOWN
|
||||
bpl done_update_song
|
||||
|
||||
set_notes_loop:
|
||||
|
||||
;==================
|
||||
; load next byte
|
||||
|
||||
ldy SONG_OFFSET
|
||||
lda tracker_song,Y
|
||||
|
||||
;==================
|
||||
; see if hit end
|
||||
|
||||
; this song only 16 notes so valid notes always positive
|
||||
; cmp #$80
|
||||
bpl not_end
|
||||
|
||||
;====================================
|
||||
; if at end, loop back to beginning
|
||||
|
||||
asl ; reset song offset to 0
|
||||
sta SONG_OFFSET
|
||||
beq set_notes_loop
|
||||
|
||||
not_end:
|
||||
|
||||
; NNNNNNEC -- c=channel, e=end, n=note
|
||||
|
||||
pha ; save note
|
||||
|
||||
and #1
|
||||
tax
|
||||
ldy #$0E
|
||||
sty AY_REGS+8,X ; $08 set volume A,B
|
||||
|
||||
asl
|
||||
tax ; put channel offset in X
|
||||
|
||||
|
||||
pla ; restore note
|
||||
tay
|
||||
and #$2
|
||||
sta SONG_COUNTDOWN ; always 2 long?
|
||||
|
||||
tya
|
||||
lsr
|
||||
lsr ; get note in A
|
||||
|
||||
tay ; lookup in table
|
||||
|
||||
lda frequencies_high,Y
|
||||
sta AY_REGS+1,X
|
||||
; sta $500,X
|
||||
|
||||
lda frequencies_low,Y
|
||||
sta AY_REGS,X ; set proper register value
|
||||
|
||||
; visualization
|
||||
blah_urgh:
|
||||
sta $400,Y
|
||||
inc blah_urgh+1
|
||||
|
||||
|
||||
;============================
|
||||
; point to next
|
||||
|
||||
; assume less than 256 bytes
|
||||
inc SONG_OFFSET
|
||||
|
||||
done_update_song:
|
||||
dec SONG_COUNTDOWN
|
||||
bmi set_notes_loop
|
513
music/tiny_tracker6/text_to_tiny.c
Normal file
513
music/tiny_tracker6/text_to_tiny.c
Normal file
@ -0,0 +1,513 @@
|
||||
/* make music for tiny_music player */
|
||||
|
||||
#define VERSION "1.0"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
static int octave_adjust=0;
|
||||
|
||||
static int notes_used[12*8];
|
||||
static int allocated_notes[12*8];
|
||||
static int notes_allocated=0;
|
||||
static int total_len=0;
|
||||
|
||||
|
||||
unsigned short frequencies[]={
|
||||
//C C# D D# E F F# G G# A A# B
|
||||
0x7A3,0x735,0x6CD,0x66C,0x60F,0x5B8,0x566,0x518,0x4CF,0x48A,0x449,0x40B,
|
||||
0x3D1,0x39A,0x366,0x336,0x307,0x2DC,0x2B3,0x28C,0x267,0x245,0x224,0x205, //2
|
||||
0x1E8,0x1CD,0x1B3,0x19B,0x183,0x16E,0x159,0x146,0x133,0x122,0x112,0x102, //3
|
||||
0x0F4,0x0E6,0x0D9,0x0CD,0x0C1,0x0B7,0x0AC,0x0A3,0x099,0x091,0x089,0x081, //4
|
||||
0x07A,0x073,0x06C,0x066,0x060,0x05B,0x056,0x051,0x04C,0x048,0x044,0x040, //5
|
||||
0x03D,0x039,0x036,0x033,0x030,0x02D,0x02B,0x028,0x026,0x024,0x022,0x020, //6
|
||||
//0x01E,0x01C,0x01B,0x019,0x018,0x016,0x015,0x014,0x013,0x012,0x011,0x010,
|
||||
//0x00F,0x00E,0x00D,0x00C,0x00C,0x00B,0x00A,0x00A,0x009,0x009,0x008,0x008,
|
||||
};
|
||||
|
||||
// CLLNNNN
|
||||
|
||||
int note_to_ed(char note, int flat, int sharp, int octave) {
|
||||
|
||||
int offset;
|
||||
|
||||
switch(note) {
|
||||
case 'C': offset=0; break;
|
||||
case 'D': offset=2; break;
|
||||
case 'E': offset=4; break;
|
||||
case 'F': offset=5; break;
|
||||
case 'G': offset=7; break;
|
||||
case 'A': offset=9; break;
|
||||
case 'B': offset=11; break;
|
||||
|
||||
case 'R': offset=12; flat=0; sharp=0; octave=3; break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"Unknown note %c\n",note);
|
||||
return -1;
|
||||
}
|
||||
if (flat==1) offset--;
|
||||
if (sharp==1) offset++;
|
||||
if (sharp==2) offset+=2;
|
||||
|
||||
|
||||
offset=((((octave+octave_adjust)-1)&0x7)*12)+offset;
|
||||
// offset=((((octave+octave_adjust)-3)&0x3)<<4)|offset;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int debug=0;
|
||||
|
||||
static int line=0;
|
||||
|
||||
static int header_version=0;
|
||||
|
||||
|
||||
struct note_type {
|
||||
unsigned char which;
|
||||
unsigned char note;
|
||||
int sharp,flat;
|
||||
int octave;
|
||||
int len;
|
||||
int enabled;
|
||||
int freq;
|
||||
int length;
|
||||
int left;
|
||||
int ed_freq;
|
||||
int offset;
|
||||
};
|
||||
|
||||
|
||||
static int allocate_note(int which) {
|
||||
|
||||
int i;
|
||||
for(i=0;i<notes_allocated;i++) {
|
||||
if (allocated_notes[i]==which) return i;
|
||||
}
|
||||
|
||||
allocated_notes[notes_allocated]=which;
|
||||
notes_allocated++;
|
||||
|
||||
return notes_allocated-1;
|
||||
|
||||
}
|
||||
|
||||
static int get_note(char *string, int sp, struct note_type *n, int line) {
|
||||
|
||||
int freq;
|
||||
int ch;
|
||||
|
||||
// fprintf(stderr,"VMW: Entering, sp=%d\n",sp);
|
||||
|
||||
/* Skip white space */
|
||||
while((string[sp]==' ' || string[sp]=='\t')) sp++;
|
||||
|
||||
if (string[sp]=='\n') return -1;
|
||||
|
||||
/* return early if no change */
|
||||
ch=string[sp];
|
||||
|
||||
// fprintf(stderr,"VMW: %d %d\n",ch,sp);
|
||||
|
||||
if (ch=='-') {
|
||||
if (header_version==0) return sp+6;
|
||||
else {
|
||||
return sp+11;
|
||||
}
|
||||
}
|
||||
|
||||
/* get note info */
|
||||
n->sharp=0;
|
||||
n->flat=0;
|
||||
n->ed_freq=-1;
|
||||
n->note=ch;
|
||||
sp++;
|
||||
if (string[sp]==' ') ;
|
||||
else if (string[sp]=='#') n->sharp=1;
|
||||
else if (string[sp]=='-') n->flat=1;
|
||||
else if (string[sp]=='=') n->flat=2;
|
||||
else {
|
||||
fprintf(stderr,"Unknown note modifier %c, line %d:%d\n",
|
||||
string[sp],line,sp);
|
||||
fprintf(stderr,"String: %s\n",string);
|
||||
}
|
||||
// printf("Sharp=%d Flat=%d\n",n->sharp,n->flat);
|
||||
sp++;
|
||||
n->octave=string[sp]-'0';
|
||||
sp++;
|
||||
sp++;
|
||||
n->len=string[sp]-'0';
|
||||
sp++;
|
||||
|
||||
|
||||
if (n->note!='-') {
|
||||
|
||||
freq=note_to_ed(n->note,n->flat,n->sharp,
|
||||
n->octave);
|
||||
|
||||
n->enabled=1;
|
||||
n->length=0;
|
||||
n->ed_freq=freq;
|
||||
}
|
||||
|
||||
if (header_version==2) sp+=6;
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
static int get_string(char *string, char *key, char *output, int strip_linefeed) {
|
||||
|
||||
char *found;
|
||||
|
||||
found=strstr(string,key);
|
||||
found=found+strlen(key);
|
||||
|
||||
/* get rid of leading whitespace */
|
||||
while(1) {
|
||||
if ((*found==' ') || (*found=='\t')) found++;
|
||||
else break;
|
||||
}
|
||||
|
||||
strcpy(output,found);
|
||||
|
||||
/* remove trailing linefeed */
|
||||
if (strip_linefeed) output[strlen(output)-1]=0;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void print_help(int just_version, char *exec_name) {
|
||||
|
||||
printf("\ntext_to_ed version %s by Vince Weaver <vince@deater.net>\n\n",VERSION);
|
||||
if (just_version) exit(0);
|
||||
|
||||
printf("This created Electric Duet files\n\n");
|
||||
|
||||
printf("Usage:\n");
|
||||
printf("\t%s [-h] [-v] [-d] [-o X] [-i X] textfile outbase\n\n",
|
||||
exec_name);
|
||||
printf("\t-h: this help message\n");
|
||||
printf("\t-v: version info\n");
|
||||
printf("\t-d: print debug messages\n");
|
||||
printf("\t-o: Offset octave by X\n");
|
||||
printf("\t-i: set second instrument to X\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static int write_note(int *a_last,int *b_last,int *c_last,int *total_len) {
|
||||
|
||||
// NNNNNNEC
|
||||
|
||||
unsigned char temp_value;
|
||||
|
||||
if (*a_last>=0) {
|
||||
temp_value=(*a_last<<2)|0;
|
||||
if ((*b_last<0) && (*c_last<0)) {
|
||||
temp_value|=2;
|
||||
}
|
||||
printf("\t.byte $%02X ; A=%d L=%d\n",
|
||||
temp_value,
|
||||
*a_last,(*b_last<0)||(*c_last<0));
|
||||
(*total_len)++;
|
||||
*a_last=-1;
|
||||
}
|
||||
|
||||
if (*b_last>=0) {
|
||||
temp_value=(*b_last<<2)|1;
|
||||
if (*c_last<0) temp_value|=2;
|
||||
|
||||
printf("\t.byte $%02X ; B=%d L=%d\n",
|
||||
temp_value,
|
||||
*b_last,(*c_last<0));
|
||||
(*total_len)++;
|
||||
*b_last=-1;
|
||||
}
|
||||
|
||||
if (*c_last>=0) {
|
||||
fprintf(stderr,"Unsupported C!\n");
|
||||
// printf("\t.byte $%02X ; C=%d L=%d\n",
|
||||
// (unsigned char)(*c_last<<3)|4|2,
|
||||
// *c_last,1);
|
||||
// (*total_len)++;
|
||||
// *c_last=-1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char string[BUFSIZ];
|
||||
char *result;
|
||||
char *in_filename;
|
||||
char temp[BUFSIZ];
|
||||
FILE *in_file=NULL;
|
||||
//int attributes=0;
|
||||
int loop=0;
|
||||
int sp,external_frequency,irq;
|
||||
struct note_type a,b,c;
|
||||
int copt;
|
||||
|
||||
char song_name[BUFSIZ];
|
||||
char author_name[BUFSIZ];
|
||||
char comments[BUFSIZ];
|
||||
char *comments_ptr=comments;
|
||||
|
||||
// unsigned char sharp_char[]=" #-=";
|
||||
|
||||
/* Parse command line arguments */
|
||||
while ((copt = getopt(argc, argv, "dhvo:i:"))!=-1) {
|
||||
switch (copt) {
|
||||
case 'd':
|
||||
/* Debug messages */
|
||||
printf("Debug enabled\n");
|
||||
debug=1;
|
||||
break;
|
||||
case 'h':
|
||||
/* help */
|
||||
print_help(0,argv[0]);
|
||||
break;
|
||||
case 'v':
|
||||
/* version */
|
||||
print_help(1,argv[0]);
|
||||
break;
|
||||
case 'o':
|
||||
/* octave offset */
|
||||
octave_adjust=atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
print_help(0,argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argv[optind]!=NULL) {
|
||||
/* Open the input file */
|
||||
if (argv[optind][0]=='-') {
|
||||
in_file=stdin;
|
||||
}
|
||||
else {
|
||||
in_filename=strdup(argv[optind]);
|
||||
in_file=fopen(in_filename,"r");
|
||||
if (in_file==NULL) {
|
||||
fprintf(stderr,"Couldn't open %s\n",in_filename);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Get the info for the header */
|
||||
|
||||
while(1) {
|
||||
result=fgets(string,BUFSIZ,in_file);
|
||||
if (result==NULL) break;
|
||||
line++;
|
||||
if (strstr(string,"ENDHEADER")) break;
|
||||
if (strstr(string,"HEADER:")) {
|
||||
get_string(string,"HEADER:",temp,1);
|
||||
header_version=atoi(temp);
|
||||
printf("Found header version %d\n",header_version);
|
||||
}
|
||||
if (strstr(string,"TITLE:")) {
|
||||
get_string(string,"TITLE:",song_name,1);
|
||||
}
|
||||
if (strstr(string,"AUTHOR:")) {
|
||||
get_string(string,"AUTHOR:",author_name,1);
|
||||
}
|
||||
if (strstr(string,"COMMENTS:")) {
|
||||
get_string(string,"COMMENTS:",comments_ptr,0);
|
||||
comments_ptr=&comments[strlen(comments)];
|
||||
}
|
||||
|
||||
if (strstr(string,"FREQ:")) {
|
||||
get_string(string,"FREQ:",temp,1);
|
||||
external_frequency=atoi(temp);
|
||||
}
|
||||
if (strstr(string,"IRQ:")) {
|
||||
get_string(string,"IRQ:",temp,1);
|
||||
irq=atoi(temp);
|
||||
}
|
||||
if (strstr(string,"LOOP:")) {
|
||||
get_string(string,"LOOP:",temp,1);
|
||||
loop=atoi(temp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
a.which='A'; b.which='B'; c.which='C';
|
||||
|
||||
|
||||
// algorithm
|
||||
// get A,B,C
|
||||
|
||||
|
||||
// int first=1;
|
||||
// int a_last=0,b_last=0,same_count=0;
|
||||
// int a_len=0,b_len=0,a_freq=0,b_freq=0;
|
||||
int current_length=0;
|
||||
int first=1;
|
||||
int a_last=-1,b_last=-1,c_last=-1;
|
||||
|
||||
printf("peasant_song:\n");
|
||||
printf("; register init\n");
|
||||
//printf("\t.byte $00,$00,$00,$00,$00,$00 ; $00: A/B/C fine/coarse\n");
|
||||
//printf("\t.byte $00 ; $06\n");
|
||||
//printf("\t.byte $38 ; $07 mixer (ABC on)\n");
|
||||
//printf("\t.byte $0E,$0C,$0C ; $08 volume A/B/C\n");
|
||||
//printf("\t.byte $00,$00,$00,$00 ; $09\n");
|
||||
printf("\n");
|
||||
|
||||
while(1) {
|
||||
result=fgets(string,BUFSIZ,in_file);
|
||||
if (result==NULL) break;
|
||||
line++;
|
||||
|
||||
a.ed_freq=-1;
|
||||
b.ed_freq=-1;
|
||||
c.ed_freq=-1;
|
||||
a.length=0;
|
||||
b.length=0;
|
||||
c.length=0;
|
||||
|
||||
/* skip comments */
|
||||
if (string[0]=='\'') continue;
|
||||
if (string[0]=='-') continue;
|
||||
if (string[0]=='*') continue;
|
||||
|
||||
sp=0;
|
||||
|
||||
/* Skip line number */
|
||||
while((string[sp]!=' ' && string[sp]!='\t')) sp++;
|
||||
|
||||
sp=get_note(string,sp,&a,line);
|
||||
if (sp!=-1) sp=get_note(string,sp,&b,line);
|
||||
if (sp!=-1) sp=get_note(string,sp,&c,line);
|
||||
|
||||
if (a.ed_freq>=0) {
|
||||
a.offset=allocate_note(a.ed_freq);
|
||||
notes_used[a.ed_freq]++;
|
||||
printf("; A: %d\n",a.ed_freq);
|
||||
}
|
||||
if (b.ed_freq>=0) {
|
||||
b.offset=allocate_note(b.ed_freq);
|
||||
notes_used[b.ed_freq]++;
|
||||
printf("; B: %d\n",b.ed_freq);
|
||||
}
|
||||
if (c.ed_freq>=0) {
|
||||
c.offset=allocate_note(c.ed_freq);
|
||||
notes_used[c.ed_freq]++;
|
||||
printf("; C: %d\n",c.ed_freq);
|
||||
}
|
||||
|
||||
if ((a.ed_freq>=0)||(b.ed_freq>=0)||(c.ed_freq>=0)) {
|
||||
printf("; none: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
||||
|
||||
// now NNNNNNEC
|
||||
|
||||
if (!first) {
|
||||
write_note(&a_last,&b_last,&c_last,&total_len);
|
||||
}
|
||||
current_length=0;
|
||||
|
||||
//if (!first) {
|
||||
// printf("\t.byte $%02X ; L = %d\n",
|
||||
// current_length|0xc0,current_length);
|
||||
// printf("\n");
|
||||
// current_length=0;
|
||||
// total_len++;
|
||||
//}
|
||||
|
||||
|
||||
first=0;
|
||||
}
|
||||
|
||||
|
||||
if (a.ed_freq>=0) {
|
||||
a_last=a.offset;
|
||||
}
|
||||
if (b.ed_freq>=0) {
|
||||
b_last=b.offset;
|
||||
}
|
||||
if (c.ed_freq>=0) {
|
||||
c_last=c.offset;
|
||||
}
|
||||
|
||||
current_length++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
printf("; last: a=%d c=%d len=%d\n",a_last,c_last,current_length);
|
||||
write_note(&a_last,&b_last,&c_last,&total_len);
|
||||
|
||||
// printf("\t.byte $FF ; end\n");
|
||||
|
||||
/* assume 32 notes or fewer */
|
||||
printf("\t.byte $80 ; end\n");
|
||||
total_len++;
|
||||
|
||||
int o,n;
|
||||
|
||||
for(o=0;o<6;o++) {
|
||||
printf("; Octave %d : ",o);
|
||||
for(n=0;n<12;n++) {
|
||||
printf("%d ",notes_used[(o*12)+n]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("; %d notes allocated\n",notes_allocated);
|
||||
|
||||
printf(";.byte ");
|
||||
for(n=0;n<notes_allocated;n++) {
|
||||
printf("%d,",allocated_notes[n]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/* put these first as we use the high bit to end things? */
|
||||
printf("frequencies_low:\n");
|
||||
printf(".byte ");
|
||||
for(n=0;n<notes_allocated;n++) {
|
||||
printf("$%02X",(frequencies[allocated_notes[n]])&0xff);
|
||||
if (n!=(notes_allocated-1)) printf(",");
|
||||
total_len++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("frequencies_high:\n");
|
||||
printf(".byte ");
|
||||
for(n=0;n<notes_allocated;n++) {
|
||||
printf("$%02X",(frequencies[allocated_notes[n]]>>8));
|
||||
if (n!=(notes_allocated-1)) printf(",");
|
||||
total_len++;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
|
||||
printf("; total len=%d\n",total_len);
|
||||
|
||||
(void) irq;
|
||||
(void) loop;
|
||||
(void) external_frequency;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
music/tiny_tracker6/tracker_init.s
Normal file
22
music/tiny_tracker6/tracker_init.s
Normal file
@ -0,0 +1,22 @@
|
||||
tracker_init:
|
||||
|
||||
; setup initial ay-3-8910 values (this depends on song)
|
||||
|
||||
init_registers_to_zero:
|
||||
ldx #$13 ; zero $70--$83
|
||||
lda #0
|
||||
; sta SONG_OFFSET ; also init song stuff
|
||||
; sta SONG_COUNTDOWN
|
||||
init_loop:
|
||||
sta AY_REGS,X
|
||||
dex
|
||||
bpl init_loop
|
||||
|
||||
lda #$38
|
||||
sta AY_REGS+7 ; $07 mixer (ABC on)
|
||||
; lda #$0E
|
||||
; sta AY_REGS+8 ; $08 volume A
|
||||
; lda #$0C
|
||||
; sta AY_REGS+9 ; $09 volume B
|
||||
; sta AY_REGS+10 ; $0A volume C
|
||||
|
32
music/tiny_tracker6/zp.inc
Normal file
32
music/tiny_tracker6/zp.inc
Normal file
@ -0,0 +1,32 @@
|
||||
; zero page
|
||||
|
||||
; pre-defined applesoft vars
|
||||
|
||||
CH = $24
|
||||
CV = $25
|
||||
GBASL = $26
|
||||
GBASH = $27
|
||||
BASL = $28
|
||||
BASH = $29
|
||||
|
||||
AY_REGS = $70
|
||||
|
||||
SONG_L = $80
|
||||
SONG_H = $81
|
||||
SONG_OFFSET = $82
|
||||
SONG_COUNTDOWN = $83
|
||||
OCTAVE = $84
|
||||
REGISTER = $85
|
||||
|
||||
OUR_ROT = $A5
|
||||
|
||||
HGR_X = $E0
|
||||
HGR_XH = $E1
|
||||
HGR_Y = $E2
|
||||
HGR_COLOR = $E4
|
||||
HGR_PAGE = $E6
|
||||
HGR_SCALE = $E7
|
||||
|
||||
COUNT = $FB
|
||||
FRAME = $FC
|
||||
|
Loading…
x
Reference in New Issue
Block a user