d2: working on stuff
This commit is contained in:
parent
6a3480a2c5
commit
ef90e30287
|
@ -0,0 +1,49 @@
|
|||
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: tiny_tracker.dsk text_to_tiny
|
||||
|
||||
tiny_tracker.dsk: HELLO D2
|
||||
cp $(EMPTY_DISK)/empty.dsk ./tiny_tracker.dsk
|
||||
$(DOS33) -y tiny_tracker.dsk SAVE A HELLO
|
||||
$(DOS33) -y tiny_tracker.dsk -t BIN -a 0x6000 BSAVE D2
|
||||
|
||||
####
|
||||
|
||||
HELLO: hello.bas
|
||||
$(TOKENIZE) < hello.bas > HELLO
|
||||
|
||||
####
|
||||
|
||||
peasant_music.s: peasant.txt text_to_tiny
|
||||
./text_to_tiny peasant.txt > peasant_music.s
|
||||
|
||||
####
|
||||
|
||||
D2: d2.o
|
||||
ld65 -o D2 d2.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
d2.o: d2.s \
|
||||
zp.inc hardware.inc \
|
||||
peasant_music.s \
|
||||
interrupt_handler.s mockingboard_setup.s
|
||||
ca65 -o d2.o d2.s -l d2.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 YANKEE PEASANT HELLO text_to_tiny peasant_music.s
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
; Tiny Mockingboard Player
|
||||
|
||||
; 514B -- Initial implementation
|
||||
; 423B -- inline everything
|
||||
; 400B -- put register init at end of song
|
||||
; 381B -- generate the frequency table
|
||||
|
||||
; proposed format
|
||||
; CCOONNNN -- c=channel, o=octave, n=note
|
||||
; 11LLLLLL -- L=length
|
||||
; 11LLLLLL -- wait time
|
||||
|
||||
; by deater (Vince Weaver) <vince@deater.net>
|
||||
|
||||
; Zero Page
|
||||
.include "zp.inc"
|
||||
.include "hardware.inc"
|
||||
|
||||
|
||||
;==========================================
|
||||
|
||||
tiny_music:
|
||||
|
||||
;===================
|
||||
;
|
||||
|
||||
;===================
|
||||
; Player Setup
|
||||
|
||||
|
||||
lda #<peasant_song
|
||||
sta SONG_L
|
||||
lda #>peasant_song
|
||||
sta SONG_H
|
||||
|
||||
; assume mockingboard in slot#4
|
||||
jsr mockingboard_init
|
||||
|
||||
start_interrupts:
|
||||
cli
|
||||
|
||||
forever:
|
||||
jmp moving
|
||||
|
||||
|
||||
.include "moving.s"
|
||||
|
||||
; music
|
||||
.include "peasant_music.s"
|
||||
.include "interrupt_handler.s"
|
||||
; must be last
|
||||
.include "mockingboard_setup.s"
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
;; 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
|
||||
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
|
||||
|
||||
|
||||
|
||||
;; 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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
5 HOME
|
||||
10 PRINT CHR$(4);"CATALOG"
|
|
@ -0,0 +1,165 @@
|
|||
;================================
|
||||
;================================
|
||||
; mockingboard interrupt handler
|
||||
;================================
|
||||
;================================
|
||||
; On Apple II/6502 the interrupt handler jumps to address in 0xfffe
|
||||
; This is in the ROM, which saves the registers
|
||||
; on older IIe it saved A to $45 (which could mess with DISK II)
|
||||
; newer IIe doesn't do that.
|
||||
; It then calculates if it is a BRK or not (which trashes A)
|
||||
; Then it sets up the stack like an interrupt and calls 0x3fe
|
||||
|
||||
; Note: the IIc is much more complicated
|
||||
; its firmware tries to decode the proper source
|
||||
; based on various things, including screen hole values
|
||||
; we bypass that by switching out ROM and replacing the
|
||||
; $fffe vector with this, but that does mean we have
|
||||
; to be sure status flag and accumulator set properly
|
||||
|
||||
interrupt_handler:
|
||||
php ; save status flags
|
||||
cld ; clear decimal mode
|
||||
pha ; save A ; 3
|
||||
; A is saved in $45 by firmware
|
||||
txa
|
||||
pha ; save X
|
||||
tya
|
||||
pha ; save Y
|
||||
|
||||
inc $0404 ; debug (flashes char onscreen)
|
||||
|
||||
|
||||
ay3_irq_handler:
|
||||
bit MOCK_6522_T1CL ; clear 6522 interrupt by reading T1C-L ; 4
|
||||
|
||||
; see if still counting down
|
||||
lda SONG_COUNTDOWN
|
||||
bpl done_update_song
|
||||
|
||||
try_again:
|
||||
ldy SONG_OFFSET
|
||||
set_notes_loop:
|
||||
|
||||
; see if hit end
|
||||
lda (SONG_L),Y
|
||||
cmp #$C0
|
||||
bne all_ok
|
||||
|
||||
; if at end, loop
|
||||
|
||||
loop_forever:
|
||||
jmp loop_forever
|
||||
|
||||
; lda #0
|
||||
; sta SONG_OFFSET
|
||||
; beq try_again
|
||||
all_ok:
|
||||
|
||||
; see if note
|
||||
|
||||
tax
|
||||
and #$C0
|
||||
cmp #$C0
|
||||
beq handle_timing
|
||||
|
||||
note_only:
|
||||
txa
|
||||
; CCOONNNN -- c=channel, o=octave, n=note
|
||||
; TODO: OONNNNCC instead?
|
||||
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta octave_smc+1
|
||||
lsr
|
||||
and #$FE
|
||||
sta out_smc+1
|
||||
|
||||
txa
|
||||
|
||||
and #$3F
|
||||
|
||||
tax
|
||||
lda frequency_lookup_low,X
|
||||
sty y_smc+1
|
||||
out_smc:
|
||||
ldx #$00
|
||||
jsr ay3_write_reg ; trashes A/Y
|
||||
|
||||
; set coarse note A
|
||||
; hack: if octave=0 (C2) then coarse=1
|
||||
; else coarse=0
|
||||
|
||||
inx
|
||||
octave_smc:
|
||||
lda #$dd
|
||||
and #$3 ; if 0 then 1
|
||||
; if 1,2,3 then 0
|
||||
bne blah0
|
||||
blah1:
|
||||
lda #1
|
||||
bne blah_blah
|
||||
blah0:
|
||||
lda #0
|
||||
blah_blah:
|
||||
|
||||
jsr ay3_write_reg ; trashes A/Y
|
||||
|
||||
y_smc:
|
||||
ldy #0
|
||||
iny
|
||||
bne not_wrap2
|
||||
inc SONG_H
|
||||
not_wrap2:
|
||||
jmp set_notes_loop
|
||||
|
||||
handle_timing:
|
||||
; was timing
|
||||
|
||||
txa
|
||||
|
||||
and #$3f
|
||||
sta SONG_COUNTDOWN
|
||||
iny
|
||||
sty SONG_OFFSET
|
||||
bne not_wrap1
|
||||
|
||||
inc SONG_H
|
||||
|
||||
not_wrap1:
|
||||
|
||||
done_update_song:
|
||||
dec SONG_COUNTDOWN
|
||||
|
||||
|
||||
;=================================
|
||||
; Finally done with this interrupt
|
||||
;=================================
|
||||
|
||||
done_ay3_irq_handler:
|
||||
|
||||
pla
|
||||
tay ; restore Y
|
||||
pla
|
||||
tax ; restore X
|
||||
pla ; restore a ; 4
|
||||
|
||||
; on II+/IIe (but not IIc) we need to do this?
|
||||
interrupt_smc:
|
||||
lda $45 ; restore A
|
||||
plp ; restore flags
|
||||
|
||||
rti ; return from interrupt ; 6
|
||||
|
||||
;============
|
||||
; typical
|
||||
; ???? cycles
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
; 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
|
||||
;========================
|
||||
;========================
|
||||
|
||||
mockingboard_init:
|
||||
|
||||
;=========================
|
||||
; Initialize the 6522s
|
||||
; set the data direction for all pins of PortA/PortB to be output
|
||||
|
||||
|
||||
lda #$ff ; all output (1)
|
||||
|
||||
sta MOCK_6522_DDRB1 ; set for 6522 #1
|
||||
sta MOCK_6522_DDRA1
|
||||
|
||||
sta MOCK_6522_DDRB2 ; set for 6522 #2
|
||||
sta MOCK_6522_DDRA2
|
||||
|
||||
|
||||
mockingboard_setup_interrupt:
|
||||
|
||||
;=========================
|
||||
; Setup Interrupt Handler
|
||||
;=========================
|
||||
|
||||
; NOTE: we don't support IIc as it's a hack
|
||||
; traditionally Mockingboard on IIc was rare
|
||||
|
||||
;========================
|
||||
; set up interrupt
|
||||
; Vector address goes to 0x3fe/0x3ff
|
||||
|
||||
lda #<interrupt_handler
|
||||
sta $03fe
|
||||
lda #>interrupt_handler
|
||||
sta $03ff
|
||||
|
||||
;============================
|
||||
; Enable 50Hz clock on 6522
|
||||
;============================
|
||||
|
||||
|
||||
; Note, on Apple II the clock isn't 1MHz but is actually closer to
|
||||
; roughly 1.023MHz, and every 65th clock is stretched (it's complicated)
|
||||
|
||||
; 9c40 / 1.023e6 = .040s, 25Hz
|
||||
; 8534 / 1.023e6 = .033s, 30Hz
|
||||
; 4fe7 / 1.023e6 = .020s, 50Hz
|
||||
; 411a / 1.023e6 = .016s, 60Hz
|
||||
|
||||
; French Touch uses
|
||||
; 4e20 / 1.000e6 = .020s, 50Hz, which assumes 1MHz clock freq
|
||||
|
||||
sei ; disable interrupts just in case
|
||||
|
||||
lda #$40 ; Continuous interrupts, don't touch PB7
|
||||
sta MOCK_6522_ACR ; ACR register
|
||||
|
||||
lda #$7F ; clear all interrupt flags
|
||||
sta MOCK_6522_IER ; IER register (interrupt enable)
|
||||
|
||||
lda #$C0
|
||||
sta MOCK_6522_IFR ; IFR: 1100, enable interrupt on timer one oflow
|
||||
sta MOCK_6522_IER ; IER: 1100, enable timer one interrupt
|
||||
|
||||
lda #$34
|
||||
; lda #$E7
|
||||
sta MOCK_6522_T1CL ; write into low-order latch
|
||||
|
||||
lda #$85
|
||||
; lda #$4f
|
||||
sta MOCK_6522_T1CH ; write into high-order latch,
|
||||
; load both values into counter
|
||||
; clear interrupt and start counting
|
||||
|
||||
|
||||
|
||||
;===================================
|
||||
;===================================
|
||||
; Reset Both AY-3-8910s
|
||||
;===================================
|
||||
;===================================
|
||||
|
||||
;===========================
|
||||
; Reset Right/Left AY-3-8910
|
||||
;===========================
|
||||
lda #MOCK_AY_RESET
|
||||
sta MOCK_6522_ORB1
|
||||
sta MOCK_6522_ORB2
|
||||
lda #MOCK_AY_INACTIVE
|
||||
sta MOCK_6522_ORB1
|
||||
sta MOCK_6522_ORB2
|
||||
|
||||
init_registers:
|
||||
|
||||
; init song data
|
||||
|
||||
lda #0
|
||||
sta SONG_OFFSET
|
||||
sta SONG_COUNTDOWN
|
||||
|
||||
; read 14 bytes from beginning of song to init
|
||||
|
||||
ldx #13
|
||||
init_loop:
|
||||
init_smc:
|
||||
txa
|
||||
tay
|
||||
lda (SONG_L),Y
|
||||
jsr ay3_write_reg ; trashes Y
|
||||
dex
|
||||
bne init_loop
|
||||
|
||||
; update SONG_L to point past the init
|
||||
lda SONG_L
|
||||
clc
|
||||
adc #14
|
||||
sta SONG_L
|
||||
bcc no_oflo
|
||||
inc SONG_H
|
||||
no_oflo:
|
||||
|
||||
; create Frequency Table
|
||||
ldx #11
|
||||
make_freq_loop:
|
||||
sec
|
||||
lda frequency_lookup_low,X
|
||||
ror
|
||||
sta frequency_lookup_low+16,X
|
||||
lsr
|
||||
sta frequency_lookup_low+32,X
|
||||
lsr
|
||||
sta frequency_lookup_low+48,X
|
||||
|
||||
dex
|
||||
bpl make_freq_loop
|
||||
|
||||
inx
|
||||
stx frequency_lookup_low+28
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;=====================
|
||||
;=====================
|
||||
;=====================
|
||||
; ay3 write reg
|
||||
;=====================
|
||||
;=====================
|
||||
;=====================
|
||||
; writes to both chips (so same output to both Right/Left)
|
||||
; address in X (preserved)
|
||||
; value in A
|
||||
|
||||
; NOTE: it looks like you could interleave things to save bytes
|
||||
; but technically this violates the AY-3-8910 spec sheet on
|
||||
; finishing accesses in less than 10us (10 cycles)
|
||||
|
||||
ay3_write_reg:
|
||||
pha
|
||||
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
|
||||
|
||||
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
|
||||
sta MOCK_6522_ORB2 ; latch_address on PB2 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
pla
|
||||
|
||||
; value
|
||||
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
|
||||
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
|
||||
lda #MOCK_AY_WRITE ; ; 2
|
||||
|
||||
sta MOCK_6522_ORB1 ; write on PB1 ; 4
|
||||
sty MOCK_6522_ORB1 ; 4
|
||||
|
||||
sta MOCK_6522_ORB2 ; write on PB2 ; 4
|
||||
sty MOCK_6522_ORB2 ; 4
|
||||
|
||||
rts
|
||||
|
||||
|
||||
; starts at C4
|
||||
frequency_lookup_low:
|
||||
.byte $E8,$CD,$B3,$9B,$83,$6E,$59,$46,$33,$22,$12,$02
|
||||
|
||||
;$1E8,$1CD,$1B3,$19B,$183,$16E,$159,$146,$133,$122,$112,$102,
|
||||
;.byte $F4,$E6,$D9,$CD,$C1,$B7,$AC,$A3,$99,$91,$89,$81,$00,$00,$00,$00
|
||||
;.byte $7A,$73,$6C,$66,$60,$5B,$56,$51,$4C,$48,$44,$40,$00,$00,$00,$00
|
||||
;.byte $3D,$39,$36,$33,$30,$2D,$2B,$28,$26,$24,$22,$20,$00,$00,$00,$00
|
|
@ -0,0 +1,165 @@
|
|||
; Moving
|
||||
; moving, orange and green
|
||||
|
||||
;================================
|
||||
; Clear screen and setup graphics
|
||||
;================================
|
||||
moving:
|
||||
|
||||
jsr HGR2 ; set hi-res 140x192, page2, fullscreen
|
||||
; A and Y both 0 at end
|
||||
;==================
|
||||
; create sinetable
|
||||
|
||||
;ldy #0 ; Y is 0
|
||||
sinetable_loop:
|
||||
tya ; 2
|
||||
and #$3f ; wrap sine at 63 entries ; 2
|
||||
|
||||
cmp #$20
|
||||
php ; save pos/negative for later
|
||||
|
||||
and #$1f
|
||||
|
||||
cmp #$10
|
||||
bcc sin_left ; blt
|
||||
|
||||
sin_right:
|
||||
; sec carry should be set here
|
||||
eor #$FF
|
||||
adc #$20 ; 32-X
|
||||
sin_left:
|
||||
tax
|
||||
lda sinetable_base,X ; 4+
|
||||
|
||||
plp
|
||||
bcc sin_done
|
||||
|
||||
sin_negate:
|
||||
; carry set here
|
||||
eor #$ff
|
||||
; adc #0 ; FIXME: this makes things off by 1
|
||||
|
||||
sin_done:
|
||||
sta sinetable,Y
|
||||
|
||||
iny
|
||||
bne sinetable_loop
|
||||
|
||||
|
||||
; NOTE: making gbash/gbasl table wasn't worth it
|
||||
|
||||
;============================
|
||||
; main loop
|
||||
;============================
|
||||
|
||||
draw_oval:
|
||||
inc FRAME
|
||||
|
||||
lda #191 ; YY
|
||||
|
||||
create_yloop:
|
||||
; HGR_Y (YY) is in A here
|
||||
|
||||
; ldx #39 ; X is don't care?
|
||||
; ldy #0 ; Y is also don't care?
|
||||
|
||||
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
|
||||
|
||||
; restore values
|
||||
|
||||
lda HGR_Y ; YY
|
||||
tax
|
||||
|
||||
calcsine_div4:
|
||||
lsr
|
||||
lsr ; 2
|
||||
sec
|
||||
sbc FRAME
|
||||
tay
|
||||
lda sinetable,y
|
||||
sta row_sum_smc+1
|
||||
|
||||
; ldx HGR_Y ; YY
|
||||
|
||||
ldy #39 ; XX
|
||||
create_xloop:
|
||||
|
||||
;=====================
|
||||
; critical inner loop
|
||||
; every cycle here is 40x192 cycles
|
||||
;=====================
|
||||
|
||||
clc
|
||||
tya
|
||||
adc FRAME
|
||||
tax
|
||||
lda sinetable,X
|
||||
|
||||
adc sinetable,Y ; 4+
|
||||
row_sum_smc:
|
||||
adc #$dd ; row base value ; 2
|
||||
|
||||
lsr ; double colors ; 2
|
||||
; also puts bit in carry
|
||||
; which helps proper color gen
|
||||
and #$7 ; 2
|
||||
tax ; 2
|
||||
lda colorlookup,X ; lookup in table ; 5
|
||||
|
||||
ror_nop_smc:
|
||||
ror ; $6A/$EA ; 2
|
||||
sta (GBASL),Y ; 6
|
||||
|
||||
lda ror_nop_smc ; toggle ror/nop ; 4
|
||||
eor #$80 ; 2
|
||||
sta ror_nop_smc ; 4
|
||||
|
||||
dey ; 2
|
||||
bpl create_xloop ; 2/3
|
||||
|
||||
dec HGR_Y
|
||||
lda HGR_Y
|
||||
cmp #$ff ; blah want to draw line 0
|
||||
bne create_yloop
|
||||
|
||||
flip_pages:
|
||||
|
||||
; Y should be $FF here
|
||||
|
||||
lda HGR_PAGE ; will be $20/$40
|
||||
cmp #$20
|
||||
bne done_page
|
||||
dey
|
||||
done_page:
|
||||
ldx PAGE1-$FE,Y ; set display page to PAGE1 or PAGE2
|
||||
|
||||
eor #$60 ; flip draw page between $2000/$4000
|
||||
sta HGR_PAGE
|
||||
|
||||
bne draw_oval ; bra
|
||||
|
||||
|
||||
colorlookup:
|
||||
.byte $22,$aa,$ba,$ff,$ba,$aa,$22 ; use 00 from sinetable
|
||||
;.byte $00
|
||||
|
||||
;.byte $11,$55,$5d,$7f,$5d,$55,$11 ; use 00 from sinetable
|
||||
;.byte $00
|
||||
|
||||
|
||||
;sinetable_base = $F5BA
|
||||
|
||||
sinetable_base:
|
||||
; this is actually (32*sin(x))
|
||||
.byte $00,$03,$06,$09,$0C,$0F,$11,$14
|
||||
.byte $16,$18,$1A,$1C,$1D,$1E,$1F,$1F
|
||||
.byte $20
|
||||
|
||||
; for bot
|
||||
; 3F5 - 7d = 378
|
||||
; jmp oval
|
||||
|
||||
sinetable=$8000
|
||||
|
||||
|
|
@ -0,0 +1,654 @@
|
|||
'
|
||||
' TITLE: Peasant's Quest Theme
|
||||
' AUTHOR: (tracked by) Vince Weaver <vince@deater.net>
|
||||
' COMMENTS: based on MIDI found online
|
||||
'
|
||||
' LOOP: 640
|
||||
'
|
||||
' BPM: 250
|
||||
' TEMPO: 6
|
||||
' FREQ: 1000000
|
||||
' IRQ: 50
|
||||
'
|
||||
' LYRICS: 0
|
||||
'
|
||||
' ENDHEADER
|
||||
-------
|
||||
' 0
|
||||
0 C 2-- R---- R----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2-- ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 C 2-- ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 C 2-- ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 C 2-- ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 C 2-- ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 C 2-- ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C C 2-- ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F R---- ----- -----
|
||||
' 0 again
|
||||
0 C 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 C 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 C 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 C 2 3 ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 C 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 C 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C C 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 1
|
||||
0 F 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C F 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 F 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 F 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 F 2 3 ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 F 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 F 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C F 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 2
|
||||
0 G 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C G 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 G 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 G 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 G 2 3 ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 G 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 G 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C G 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 3
|
||||
0 C 2 3 C 4 4 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 C 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 C 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 C 2 3 R---- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 C 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 C 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C C 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F R---- ----- -----
|
||||
' 4
|
||||
0 C 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- G 4-- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- R---- -----
|
||||
C C 2 3 G 4 4 -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 C 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 C 2 3 F 4 3 -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- R---- -----
|
||||
18 C 2 3 F 4 4 -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- R---- -----
|
||||
20 ----- E 4 3 -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 ----- R---- -----
|
||||
24 C 2 3 E 4 4 -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 C 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C C 2 3 F 4 3 -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 5
|
||||
0 F 2 3 C 4 4 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C F 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 F 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 F 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- R---- -----
|
||||
18 F 2 3 ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 ----- ----- -----
|
||||
24 F 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 F 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C F 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 6
|
||||
0 G 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- G 4 3 -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B ----- R---- -----
|
||||
C G 2 3 G 4 4 -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 G 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 G 2 3 F 4-- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- R---- -----
|
||||
18 G 2 3 F 4 4 -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- E 4 3 -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 ----- R---- -----
|
||||
24 G 2 3 E 4 4 -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 G 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C G 2 3 F 4 3 -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 7
|
||||
0 C 2 3 D 4 3 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- R---- -----
|
||||
3 ----- D 4 6 -----
|
||||
4 ----- D 4 8 -----
|
||||
5 ----- R---- -----
|
||||
6 ----- D 4 3 -----
|
||||
7 ----- ----- -----
|
||||
8 ----- R---- -----
|
||||
9 ----- D 4 3 -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2 3 A#4 4 -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- R---- -----
|
||||
10 C 2 3 A#4 4 -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- R---- -----
|
||||
14 C 2 3 A#4 3 -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 C 2 3 D 4 3 -----
|
||||
19 ----- ----- -----
|
||||
1A ----- R---- -----
|
||||
1B ----- D 4 6 -----
|
||||
1C ----- D 4 8 -----
|
||||
1D ----- R---- -----
|
||||
1E ----- D 4 4 -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- D 4 8 -----
|
||||
23 R---- ----- -----
|
||||
24 C 2 3 G 4 4 -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- R---- -----
|
||||
28 C 2 3 G 4 4 -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- R---- -----
|
||||
2C C 2 3 G 4 3 -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F R---- ----- -----
|
||||
' 8
|
||||
0 C 2 3 D 4 3 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- R---- -----
|
||||
3 ----- D 4 6 -----
|
||||
4 ----- D 4 8 -----
|
||||
5 ----- R---- -----
|
||||
6 ----- D 4 8 -----
|
||||
7 ----- R---- -----
|
||||
8 ----- D 4 4 -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2 3 A#4 4 -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- R---- -----
|
||||
10 C 2 3 A#4 8 -----
|
||||
11 ----- ----- -----
|
||||
12 ----- D 4 4 -----
|
||||
13 R---- ----- -----
|
||||
14 C 2 3 ----- -----
|
||||
15 ----- R---- -----
|
||||
16 ----- D 4 8 -----
|
||||
17 R---- ----- -----
|
||||
18 C 2 3 G 4 4 -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- R---- -----
|
||||
1C ----- G 4 8 -----
|
||||
1D ----- ----- -----
|
||||
1E ----- D 4 4 -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- R---- -----
|
||||
22 ----- D 4 8 -----
|
||||
23 R---- ----- -----
|
||||
24 C 2 3 F 4 4 -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- R---- -----
|
||||
28 C 2 3 F 4 8 -----
|
||||
29 ----- ----- -----
|
||||
2A ----- G 4 4 -----
|
||||
2B R---- ----- -----
|
||||
2C C 2 3 ----- -----
|
||||
2D ----- R---- -----
|
||||
2E ----- G 4 8 -----
|
||||
2F R---- ----- -----
|
||||
' 5
|
||||
0 F 2 3 C 4 4 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C F 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 F 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 F 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- R---- -----
|
||||
18 F 2 3 ----- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 F 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 F 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C F 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 6
|
||||
0 G 2 3 ----- -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- G 4 3 -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- R---- -----
|
||||
C G 2 3 G 4 4 -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 G 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 G 2 3 F 4 3 -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- R---- -----
|
||||
18 G 2 3 F 4 4 -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- R---- -----
|
||||
1C ----- F 4 3 -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- E 4 3 -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 G 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- R---- -----
|
||||
28 G 2 3 E 4 3 -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- R---- -----
|
||||
2C G 2 3 F 4 3 -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F ----- ----- -----
|
||||
' 9
|
||||
0 C 2 3 G 4 4 -----
|
||||
1 ----- ----- -----
|
||||
2 ----- ----- -----
|
||||
3 ----- ----- -----
|
||||
4 ----- ----- -----
|
||||
5 ----- ----- -----
|
||||
6 ----- ----- -----
|
||||
7 ----- ----- -----
|
||||
8 ----- ----- -----
|
||||
9 ----- ----- -----
|
||||
A ----- ----- -----
|
||||
B R---- ----- -----
|
||||
C C 2 3 ----- -----
|
||||
D ----- ----- -----
|
||||
E ----- ----- -----
|
||||
F R---- ----- -----
|
||||
10 C 2 3 ----- -----
|
||||
11 ----- ----- -----
|
||||
12 ----- ----- -----
|
||||
13 R---- ----- -----
|
||||
14 C 2 3 ----- -----
|
||||
15 ----- ----- -----
|
||||
16 ----- ----- -----
|
||||
17 R---- ----- -----
|
||||
18 C 2 3 R---- -----
|
||||
19 ----- ----- -----
|
||||
1A ----- ----- -----
|
||||
1B ----- ----- -----
|
||||
1C ----- ----- -----
|
||||
1D ----- ----- -----
|
||||
1E ----- ----- -----
|
||||
1F ----- ----- -----
|
||||
20 ----- ----- -----
|
||||
21 ----- ----- -----
|
||||
22 ----- ----- -----
|
||||
23 R---- ----- -----
|
||||
24 C 2 3 ----- -----
|
||||
25 ----- ----- -----
|
||||
26 ----- ----- -----
|
||||
27 R---- ----- -----
|
||||
28 C 2 3 ----- -----
|
||||
29 ----- ----- -----
|
||||
2A ----- ----- -----
|
||||
2B R---- ----- -----
|
||||
2C C 2 3 ----- -----
|
||||
2D ----- ----- -----
|
||||
2E ----- ----- -----
|
||||
2F R---- R---- R----
|
||||
' LOOP TO FRAME 8
|
|
@ -0,0 +1,372 @@
|
|||
/* 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=1;
|
||||
|
||||
// CCOONNNN -- c=channel, o=octave, n=note
|
||||
|
||||
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)-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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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)||(b.ed_freq>=0)||(c.ed_freq>=0)) {
|
||||
if (!first) {
|
||||
printf("\t.byte $%02X ; L = %d\n",
|
||||
current_length|0xc0,current_length);
|
||||
printf("\n");
|
||||
current_length=0;
|
||||
}
|
||||
|
||||
first=0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (a.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; A = %c%c%d\n",
|
||||
a.ed_freq,
|
||||
a.note,sharp_char[a.sharp+2*a.flat],
|
||||
a.octave);
|
||||
}
|
||||
if (b.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; B = %c%c%d\n",
|
||||
b.ed_freq|0x40,
|
||||
b.note,sharp_char[b.sharp+2*b.flat],
|
||||
b.octave);
|
||||
}
|
||||
if (c.ed_freq>=0) {
|
||||
printf("\t.byte $%02X ; C = %c%c%d\n",
|
||||
c.ed_freq|0x80,
|
||||
c.note,sharp_char[c.sharp+2*c.flat],
|
||||
c.octave);
|
||||
}
|
||||
|
||||
current_length++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
printf("\t.byte $C0 ; end\n");
|
||||
|
||||
(void) irq;
|
||||
(void) loop;
|
||||
(void) external_frequency;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
; zero page
|
||||
|
||||
; pre-defined applesoft vars
|
||||
|
||||
CH = $24
|
||||
CV = $25
|
||||
GBASL = $26
|
||||
GBASH = $27
|
||||
BASL = $28
|
||||
BASH = $29
|
||||
|
||||
SONG_L = $70
|
||||
SONG_H = $71
|
||||
SONG_OFFSET = $72
|
||||
SONG_COUNTDOWN = $73
|
||||
|
||||
HGR_X = $E0
|
||||
HGR_XH = $E1
|
||||
HGR_Y = $E2
|
||||
HGR_COLOR = $E4
|
||||
HGR_PAGE = $E6
|
||||
|
||||
FRAME = $FC
|
||||
|
Loading…
Reference in New Issue