mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-26 07:29:22 +00:00
updated music examples
This commit is contained in:
parent
0b9da464cd
commit
575943ea6a
449
presets/vcs/examples/music2.a
Normal file
449
presets/vcs/examples/music2.a
Normal file
@ -0,0 +1,449 @@
|
||||
processor 6502
|
||||
include "vcs.h"
|
||||
include "macro.h"
|
||||
include "xmacro.h"
|
||||
|
||||
org $f000
|
||||
|
||||
Chan0dur equ $e0 ; current note duration channel 0
|
||||
Chan1dur equ $e1 ; current note duration channel 1
|
||||
Chan0note equ $e2 ; current note pitch channel 0
|
||||
Chan1note equ $e3 ; current note pitch channel 1
|
||||
Chan0duty equ $e4 ; current duty bits channel 0
|
||||
Chan1duty equ $e5 ; current duty bits channel 1
|
||||
DurationTimer equ $e6 ; duration until next cmd
|
||||
CurChannel equ $e7 ; next channel to add note
|
||||
SongPtr equ $e8 ; ptr to next song byte
|
||||
|
||||
BitmapY equ $f0 ; next line of bitmap
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
MAC PULSE
|
||||
TIMER_SETUP 35
|
||||
jsr DutyCycle ; cycle notes
|
||||
jsr Pulse ; decrement duration timer
|
||||
lda Chan0note
|
||||
sta COLUBK
|
||||
lda Chan1note
|
||||
sta COLUPF
|
||||
jsr DrawBitmap ; draw ~34 lines of bitmap
|
||||
ENDM
|
||||
|
||||
MAC DUTYCYCLE
|
||||
TIMER_SETUP 34
|
||||
jsr DutyCycle ; cycle notes
|
||||
jsr DrawBitmap ; draw ~33 lines of bitmap
|
||||
ENDM
|
||||
|
||||
Start
|
||||
CLEAN_START
|
||||
jsr ResetTrack
|
||||
|
||||
NextFrame
|
||||
VERTICAL_SYNC
|
||||
lda #$d0
|
||||
sta BitmapY ; top of bitmap
|
||||
; 35*2 + 34*6 = 274 lines (264 b/c we exit timer early)
|
||||
PULSE
|
||||
DUTYCYCLE
|
||||
DUTYCYCLE
|
||||
DUTYCYCLE
|
||||
PULSE
|
||||
DUTYCYCLE
|
||||
DUTYCYCLE
|
||||
DUTYCYCLE
|
||||
lda #0
|
||||
sta COLUBK
|
||||
jmp NextFrame
|
||||
|
||||
DrawBitmap
|
||||
ldy BitmapY
|
||||
ScanLoop
|
||||
; WSYNC and store playfield registers
|
||||
sta WSYNC
|
||||
lda PFBitmap0,y
|
||||
sta PF0 ; store first playfield byte
|
||||
lda PFBitmap1,y
|
||||
sta PF1 ; store 2nd byte
|
||||
lda PFBitmap2,y
|
||||
sta PF2 ; store 3rd byte
|
||||
; Here's the asymmetric part -- by this time the TIA clock
|
||||
; is far enough that we can rewrite the same PF registers
|
||||
; and display new data on the right side of the screen
|
||||
nop
|
||||
nop
|
||||
nop ; pause to let playfield finish drawing
|
||||
lda PFBitmap3,y
|
||||
sta PF0 ; store 4th byte
|
||||
lda PFBitmap4,y
|
||||
sta PF1 ; store 5th byte
|
||||
lda PFBitmap5,y
|
||||
sta PF2 ; store 6th byte
|
||||
dey
|
||||
lda INTIM
|
||||
cmp #2
|
||||
bcs ScanLoop ; repeat until all scanlines drawn
|
||||
TIMER_WAIT
|
||||
sty BitmapY
|
||||
lda #0
|
||||
sta PF0
|
||||
sta PF1
|
||||
sta PF2
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Table of AUDF base values for each note
|
||||
FREQZ .byte 30, 30, 30, 30, 30, 28, 26, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 10, 10, 9, 8, 8, 7, 7, 6, 6, 5, 5, 30, 29, 27, 25, 24, 22, 21, 20, 19, 18, 16, 15, 15, 14, 13, 12, 11, 11, 10, 31, 29, 27, 25, 24, 23, 21, 20, 19, 18, 16, 15, 15
|
||||
; Table of duty-cycle bits for each note
|
||||
DUTYZ .byte 247, 247, 247, 247, 1, 73, 219, 1, 219, 73, 0, 219, 181, 85, 85, 85, 181, 219, 247, 1, 73, 181, 0, 73, 219, 17, 219, 17, 219, 73, 247, 85, 247, 1, 85, 247, 73, 247, 181, 17, 1, 0, 247, 247, 0, 1, 17, 73, 181, 0, 17, 0, 1, 85, 247, 73, 0, 181, 73, 1, 0, 247, 247, 0
|
||||
; Table of AUDC values for each note
|
||||
TONEZ .byte 0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
|
||||
|
||||
; Cycle the pitches of each channel
|
||||
DutyCycle
|
||||
; set playfield colors
|
||||
lda Chan0duty
|
||||
ora #$07
|
||||
sta COLUBK
|
||||
lda Chan1duty
|
||||
and #$f0
|
||||
sta COLUPF
|
||||
; update channel 0
|
||||
ldx #0
|
||||
jsr MusicFrame
|
||||
; update channel 1
|
||||
ldx #1
|
||||
jsr MusicFrame
|
||||
rts
|
||||
|
||||
; Play a note
|
||||
; X = channel (0,1)
|
||||
; Y = note index (0-63)
|
||||
PlayNote
|
||||
lda FREQZ,y
|
||||
sta Chan0note,x
|
||||
lda DUTYZ,y
|
||||
sta Chan0duty,x
|
||||
lda TONEZ,y
|
||||
sta AUDC0,x
|
||||
lda #31
|
||||
sta Chan0dur,x
|
||||
lda #15
|
||||
sta AUDV0,x
|
||||
rts
|
||||
|
||||
; Reset to start of song
|
||||
ResetTrack
|
||||
lda #<NOTEZ
|
||||
sta SongPtr+0
|
||||
lda #>NOTEZ
|
||||
sta SongPtr+1
|
||||
rts
|
||||
|
||||
; Called 2x per frame
|
||||
; Decrement the volumes for each channel
|
||||
; Also decrement next-note timer, fetch next note
|
||||
Pulse
|
||||
lda Chan0dur
|
||||
beq NoDec0
|
||||
lsr
|
||||
sta AUDV0
|
||||
dec Chan0dur
|
||||
NoDec0
|
||||
lda Chan1dur
|
||||
beq NoDec1
|
||||
lsr
|
||||
sta AUDV1
|
||||
dec Chan1dur
|
||||
NoDec1
|
||||
lda DurationTimer
|
||||
beq NextData
|
||||
dec DurationTimer
|
||||
rts
|
||||
|
||||
; Timer ran out, so fetch next note
|
||||
NextData
|
||||
ldx #0
|
||||
lda (SongPtr,x)
|
||||
bmi LoadDuration
|
||||
; < $80, play next note
|
||||
ldx CurChannel ; next channel
|
||||
tay
|
||||
jsr PlayNote
|
||||
inx
|
||||
txa
|
||||
and #1
|
||||
sta CurChannel ; inc next channel
|
||||
jmp IncDataPtr
|
||||
; >= $80, load next duration
|
||||
LoadDuration
|
||||
cmp #$ff ; $ff = end of song
|
||||
beq ResetTrack
|
||||
and #$7f
|
||||
asl
|
||||
sta DurationTimer ; store duration * 2
|
||||
IncDataPtr
|
||||
; increment song pointer
|
||||
inc SongPtr
|
||||
bne NoIncHi
|
||||
inc SongPtr+1
|
||||
NoIncHi
|
||||
rts
|
||||
|
||||
; Update channel pitch in AUDF0
|
||||
MusicFrame
|
||||
; 8-bit rotation of duty cycle bits
|
||||
lda Chan0duty,x
|
||||
asl
|
||||
bcc NoCarry
|
||||
ora #1
|
||||
NoCarry
|
||||
sta Chan0duty,x
|
||||
lda Chan0note,x
|
||||
; If next bit is set, add 1 to AUDF0
|
||||
adc #0
|
||||
sta AUDF0,x
|
||||
VolZero
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; MUSIC DATA - "The Easy Winners" by Scott Joplin
|
||||
|
||||
NOTEZ
|
||||
hex 2a1e983327a431258c2f238c2e228c2c
|
||||
hex 208c2a1e98281c8c271b9825198c2317
|
||||
hex 8c22128c238c258c278c281e8c2a1c8c
|
||||
hex 2c1b8c2e198c2f17981e9812981e982f
|
||||
hex 17983327981298361e9838178c368c1e
|
||||
hex 8c388c33128c388c361e983d108c3b8c
|
||||
hex 208c378c3b108c3d8c3b288c368c1798
|
||||
hex 2a1e8c2c8c2e128c2f8c311e8c328c33
|
||||
hex 1798331e981298331e9838178c368c27
|
||||
hex 8c388c36188c368c33219836198c2e8c
|
||||
hex 228c368c2f198c368c2f25982e1e981c
|
||||
hex 981b8c2a8c2e258c348c331798331e98
|
||||
hex 129833279838178c368c1e8c388c3612
|
||||
hex 8c388c331e983d108c3b8c208c3d8c3b
|
||||
hex 1c8c3b8c381c8c3f8c1b8c338c37228c
|
||||
hex 3a8c3f0f983a8c3b8c3d108c3b8c208c
|
||||
hex 3d8c38108c3d8c3b288c368c178c348c
|
||||
hex 361e8c348c33178c368c278c368c3012
|
||||
hex 8c348c1e8c368c34128c338c281e982f
|
||||
hex 1e981298149816983317983327981298
|
||||
hex 331e9838178c368c1e8c388c36128c38
|
||||
hex 8c331e983d108c3b8c208c3d8c3b108c
|
||||
hex 3d8c38288c368c17982a1e8c2c8c2e12
|
||||
hex 8c2f8c311e8c328c331798331e981298
|
||||
hex 361e9838178c368c278c328c36188c36
|
||||
hex 8c36219836198c2e8c228c368c35198c
|
||||
hex 368c2f2598361e981c981b8c2a8c2e25
|
||||
hex 8c348c2f1798331e981298361e983817
|
||||
hex 8c368c1e8c328c36128c388c361e983d
|
||||
hex 108c388c288c3d8c3b1c8c3b8c3d1c8c
|
||||
hex 378c1b8c338c37168c3a8c3f1b983a8c
|
||||
hex 3b8c3d108c3b8c208c3d8c3b108c3d8c
|
||||
hex 38288c368c178c388c361e8c348c2f17
|
||||
hex 8c368c278c368c36128c348c1e8c308c
|
||||
hex 34128c338c311e982f179812982f0b98
|
||||
hex 2a8c2b8c2c128c2d8c2e288c2e8c168c
|
||||
hex 368c341e8c318c2c198c2d8c2e288c2e
|
||||
hex 8c198c318c2c1a8c2e8c2f1b8c2a8c2c
|
||||
hex 278c2e8c2f128c308c311e8c328c3323
|
||||
hex 8c328c331e8c338c128c368c311e8c33
|
||||
hex 8c34258c3d8c1e8c338c34128c3d8c1e
|
||||
hex 8c338c34258c3d8c1e8c3b8c3a128c38
|
||||
hex 8c36168c348c33178c3b8c278c328c33
|
||||
hex 128c3b8c1e8c328c33178c3b8c278c38
|
||||
hex 8c36128c338c311e8c2f8c2e148c2f8c
|
||||
hex 302a8c308c188c368c33208c308c2e1b
|
||||
hex 8c2f8c302a8c308c148c338c38208c33
|
||||
hex 8c31198c308c31288c2c8c1c8c308c31
|
||||
hex 208c348c38198c338c34208c318c258c
|
||||
hex 2c8c288c258c261d8c29208c2c238c2f
|
||||
hex 268c32298c322998322998358c388c32
|
||||
hex 8c3eb03f8c3b8c368c338c338c2f8c27
|
||||
hex 8c2a8c28128c288c128c2f8c17982a8c
|
||||
hex 2b8c2c128c2d8c2e288c318c168c368c
|
||||
hex 341e8c318c2c198c2d8c2e288c2e8c19
|
||||
hex 8c318c2c1a8c2e8c2f1b8c2a8c2c278c
|
||||
hex 2e8c2f128c308c311e8c328c33178c32
|
||||
hex 8c33278c338c128c368c311e8c338c34
|
||||
hex 198c3d8c288c338c34128c3d8c1e8c33
|
||||
hex 8c34198c3d8c288c3b8c3a128c388c36
|
||||
hex 168c348c33178c3b8c278c328c33128c
|
||||
hex 3b8c1e8c328c33178c3b8c278c388c36
|
||||
hex 128c338c311e8c2f8c2e148c2f8c302a
|
||||
hex 8c308c188c368c33208c308c2e1b8c2f
|
||||
hex 8c302a8c308c148c338c38208c338c31
|
||||
hex 198c308c31288c2c8c1c8c308c31208c
|
||||
hex 348c38198c338c34208c318c258c2c8c
|
||||
hex 288c258c261d8c29208c2c238c2f268c
|
||||
hex 32298c322998322998358c2f8c3b8c3e
|
||||
hex b03f8c3b8c368c338c338c2f8c278c2a
|
||||
hex 8c281e8c288c128c2f8c17982a983317
|
||||
hex 98331e981298331e9838178c368c1e8c
|
||||
hex 388c36128c388c3327983d108c3b8c20
|
||||
hex 8c3d8c3b108c378c3b208c368c17982a
|
||||
hex 1e8c2c8c2e128c2f8c311e8c328c3317
|
||||
hex 983327981298361e9838178c338c278c
|
||||
hex 388c36188c368c36219836198c318c22
|
||||
hex 8c368c2f198c368c2f2598361e981c98
|
||||
hex 1b8c2a8c2e258c348c331798331e9812
|
||||
hex 9836279838178c338c1e8c388c36128c
|
||||
hex 388c361e983d108c388c208c3d8c3b1c
|
||||
hex 8c3b8c3d1c8c378c1b8c338c37228c3a
|
||||
hex 8c3f0f983a8c3b8c37108c3b8c208c3d
|
||||
hex 8c3b1c8c3d8c3b208c338c178c388c36
|
||||
hex 1e8c348c2f238c368c1e8c368c36128c
|
||||
hex 348c1e8c368c311e8c338c3112982f17
|
||||
hex 9812982f0bb03428983428a42f238c34
|
||||
hex 288c362a8c38982ca42f8c348c388c2f
|
||||
hex 8c3698338c178c338c2d17982c1c9810
|
||||
hex 9812982f148c308c31158c398c2d8c36
|
||||
hex 8c301e8c398c1f8c368c2f208c348c38
|
||||
hex 2c8c3d8c1c8c3b8c38238c348c33178c
|
||||
hex 3b8c362d8c338c311e8c338c1f8c2f8c
|
||||
hex 34208c348c381c8c3b8c238c3d8c3b14
|
||||
hex 8c388c31158c398c258c368c302a8c39
|
||||
hex 8c1f8c368c2f208c348c38238c3d8c1c
|
||||
hex 8c3b8c382c8c348c36198c388c36288c
|
||||
hex 348c33128c348c2e8c318c2f2398321d
|
||||
hex 8c361e8c3317982f209831218c398c25
|
||||
hex 8c368c301e8c398c1f8c368c2c8c2f8c
|
||||
hex 34238c388c3d1c8c3b8c38238c348c33
|
||||
hex 238c3b8c36238c338c311e8c338c1f8c
|
||||
hex 2f8c2c8c348c381c8c3b8c38178c3d8c
|
||||
hex 3b148c388c31158c398c258c368c301e
|
||||
hex 8c398c218c368c208c2f8c341c8c388c
|
||||
hex 3d238c3b8c381c8c2f8c2e198c318c12
|
||||
hex 982d0b8c33982c8c1c98381c8c348c36
|
||||
hex 178c388c2f148c308c31158c398c2d8c
|
||||
hex 368c301e8c398c1f8c368c2f208c348c
|
||||
hex 382c8c3d8c1c8c3b8c38238c348c3317
|
||||
hex 8c3b8c362d8c338c311e8c338c1f8c2f
|
||||
hex 8c34208c348c381c8c3b8c238c3d8c3b
|
||||
hex 148c388c31158c398c258c368c302a8c
|
||||
hex 398c1f8c368c2f208c348c38238c3d8c
|
||||
hex 288c3b8c38238c348c36198c388c3628
|
||||
hex 8c348c331e8c348c288c318c2f239832
|
||||
hex 1d8c331e8c3b17982f289831158c398c
|
||||
hex 258c368c301e8c398c2b8c368c208c2f
|
||||
hex 8c34238c388c3d1c8c3b8c382c8c348c
|
||||
hex 33178c3b8c36238c338c311e8c338c2b
|
||||
hex 8c2f8c208c348c381c8c3b8c38178c3d
|
||||
hex 8c32148c388c31218c398c198c368c30
|
||||
hex 1e8c398c218c368c208c2f8c34288c38
|
||||
hex 8c3d178c3b8c381c8c2f8c2e198c318c
|
||||
hex 12982d178c36982c8c1098179834108c
|
||||
hex 2f8c318c3e8c331e982f238c318c2398
|
||||
hex 23983312982f238c318c1e8c2f178c31
|
||||
hex 168c33158c3414983b2c8c318c1c9823
|
||||
hex 983414983b2c8c318c1c981d981e983d
|
||||
hex 2d8c3b8c179823981b983d2d8c338c17
|
||||
hex 9823981c983d2c8c348c179823981c98
|
||||
hex 3d2c8c3b8c208c2f8c311f8c328c3f1e
|
||||
hex 982f2d8c318c179823983f12982f2d8c
|
||||
hex 318c128c2f178c3d168c33158c342098
|
||||
hex 2f238c3d8c1c9823982c8c348c381c8c
|
||||
hex 3b8c38178c3d8c32148c388c31158c39
|
||||
hex 8c258c368c301e8c398c218c368c208c
|
||||
hex 2f8c341c8c388c3d238c3b8c381c8c2f
|
||||
hex 8c2e198c318c12982d178c36982c8c2c
|
||||
hex 1098179834208c2f8c3d1f8c328c332a
|
||||
hex 982f238c3d8c17982398331e982f238c
|
||||
hex 3d8c128c2f178c31168c33218c381498
|
||||
hex 2f238c318c1c982c983814982f238c31
|
||||
hex 8c1c9829981e983d238c338c17982d98
|
||||
hex 1b983d238c338c17982d981c983d238c
|
||||
hex 348c17982c981c983d238c3b8c208c2f
|
||||
hex 8c312b8c328c3f1e982f238c318c1798
|
||||
hex 2d983f12982f238c318c128c3b238c31
|
||||
hex 168c33158c3414982f238c3d8c289823
|
||||
hex 98208c348c381c8c3b8c38238c3d8c3b
|
||||
hex 148c388c31158c398c198c368c301e8c
|
||||
hex 398c2d8c368c208c2f8c341c8c388c3d
|
||||
hex 178c3b8c381c8c2f8c2e258c318c1298
|
||||
hex 2d0b8c33982c8c2c109817983410ff
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; BITMAP DATA - Bob
|
||||
|
||||
PFBitmap0
|
||||
hex 000000808080c0c0c0c0c0e0e0e0e0e0
|
||||
hex e0e0e020000040c0c0c0808080000000
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000800000008000
|
||||
hex 80000000800000008000800080000000
|
||||
hex 00000000800080008000800080008000
|
||||
hex 80008000800080008000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
PFBitmap1
|
||||
hex 0000c0e0e0f0f0f8b8f8b8bcbcbcbcbe
|
||||
hex be3e7ebf7f7f7f7fbfb7b7d3a3030101
|
||||
hex 01010100020001020201060306050505
|
||||
hex 0d020e0b0a0d0a0e0a0a1e0e0f1e0f0e
|
||||
hex 1f0e0c0c0c0c08080828686028205040
|
||||
hex b040d08068c0d0c0d1e0d0e0d0e5d0e6
|
||||
hex dae6d3f5d7f9eafcfcfcfafffbfbfdf8
|
||||
hex f9f8fcf0fcf8faf8f8f8fcf1fcf1fcf8
|
||||
hex f4f8fcf8f4f8fcf9f4f8fdfdfdfefdff
|
||||
hex ffffff7fff7f7f7f7f3f3f3f3f3e3f1f
|
||||
hex 1f0f0f0f0f0707030301010000000000
|
||||
PFBitmap2
|
||||
hex 000000000000000000000000000000f0
|
||||
hex f8f8fc3cbc16bc173b5f3b9b3b377b37
|
||||
hex 776ff7effffffe7e7e3cfc78fcfc3c7c
|
||||
hex fc3e1c1e0c0ecefcfefefffefffefdfd
|
||||
hex fd79fa7a7a502c282830102060002040
|
||||
hex 2040c02040514247466c4870c833e672
|
||||
hex f6777f7f78793fba1c3c1f1f1f0f1782
|
||||
hex 00200000890020008110400000200000
|
||||
hex 400000200000800001a0cafafefbfeff
|
||||
hex ffffffffffffffffbfffbfdf5bd55944
|
||||
hex 4d696f2f7fbffffffffffffefe200000
|
||||
PFBitmap3
|
||||
hex 00000000000000000000000000c0f0f0
|
||||
hex f0f0a050004000000000000000000010
|
||||
hex 4000b070b0f0a04000100010f0408000
|
||||
hex 50800000000050f0c080101030303070
|
||||
hex 70f0e0e080000040004000a000004000
|
||||
hex 000000000000000000000000004000c0
|
||||
hex 80c0c080808000400000000000008000
|
||||
hex 00000000800040000040000000004000
|
||||
hex 00004000008000001070f0f0f0f0f0f0
|
||||
hex f0f0f0f0d0f0b0c090c08080c0404040
|
||||
hex 60406070a070f0f0f0f0f0f0f0000000
|
||||
PFBitmap4
|
||||
hex 000000000000000000000000000080c0
|
||||
hex c06060e0303010380818080c040c0406
|
||||
hex 04064606820342038303010341014101
|
||||
hex 41614160703130f9f8fc787d060f0e1f
|
||||
hex 0a1b1a199090a060a040000000000000
|
||||
hex 00000000000008101820202010149a11
|
||||
hex d9fffefea2f8a8c040f97f7f7f3e1c10
|
||||
hex 00000000000000400800000080000000
|
||||
hex 00880000000000000000008080c0f0f8
|
||||
hex 7cfeffffffffffbfbf5d3f5d177d972d
|
||||
hex b62ea3afb3aff7fffefefcf8e0000000
|
||||
PFBitmap5
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
hex 00000000000000000000000000000100
|
||||
hex 01000101030103020301030203020302
|
||||
hex 03050301030202000200101808200800
|
||||
hex 1028201030102830303832383a703a78
|
||||
hex 3a78327a3a793a793b7b797a7d7a397c
|
||||
hex 7b7c7d797d797d797c797a787c78687a
|
||||
hex 6c787c7a687c6c7c3c7c7c3c7e3c7e3e
|
||||
hex 3e3e3e3f3f1f1f1f1f0f0f0f0703030b
|
||||
hex 03070101010100000000000000000000
|
||||
|
||||
; Epilogue
|
||||
org $fffc
|
||||
.word Start
|
||||
.word Start
|
@ -6,6 +6,7 @@
|
||||
seg.u Variables
|
||||
org $80
|
||||
|
||||
; 16-bit wavetable offset
|
||||
Cycle0Lo byte
|
||||
Cycle1Lo byte
|
||||
Cycle2Lo byte
|
||||
@ -14,6 +15,7 @@ Cycle0Hi byte
|
||||
Cycle1Hi byte
|
||||
Cycle2Hi byte
|
||||
Cycle3Hi byte
|
||||
; 16-bit wavetable delta
|
||||
Delta0Lo byte
|
||||
Delta1Lo byte
|
||||
Delta2Lo byte
|
||||
@ -22,35 +24,63 @@ Delta0Hi byte
|
||||
Delta1Hi byte
|
||||
Delta2Hi byte
|
||||
Delta3Hi byte
|
||||
; 8-bit wavetable offset (volume)
|
||||
WaveOfs0 byte
|
||||
WaveOfs1 byte
|
||||
WaveOfs2 byte
|
||||
WaveOfs3 byte
|
||||
|
||||
SongPtr word ; ptr to next song byte
|
||||
DurationTimer byte ; duration until next song byte
|
||||
CurChannel byte ; next channel to write
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
seg Code
|
||||
org $f000
|
||||
|
||||
; Macro that decrements volume for a channel
|
||||
MAC DECVOLUME
|
||||
lda WaveOfs0+{1}
|
||||
sec
|
||||
beq .ChannelOff
|
||||
sbc #$20
|
||||
.ChannelOff
|
||||
sta WaveOfs0+{1}
|
||||
ENDM
|
||||
|
||||
|
||||
Start
|
||||
CLEAN_START
|
||||
lda #0
|
||||
sta Delta0Hi
|
||||
lda #137
|
||||
sta Delta0Lo
|
||||
lda #0
|
||||
sta Delta1Hi
|
||||
lda #172
|
||||
sta Delta1Lo
|
||||
lda #0
|
||||
sta Delta2Hi
|
||||
lda #217
|
||||
sta Delta2Lo
|
||||
lda #1
|
||||
sta Delta2Hi
|
||||
lda #273-256
|
||||
sta Delta2Lo
|
||||
lda #$FF
|
||||
sta COLUPF
|
||||
sta ENABL
|
||||
jsr ResetTrack
|
||||
NextFrame
|
||||
sta WSYNC
|
||||
jsr NextSamples
|
||||
DECVOLUME 0
|
||||
jsr Pulse
|
||||
jsr PlayFrame
|
||||
DECVOLUME 1
|
||||
jsr Pulse
|
||||
jsr PlayFrame
|
||||
DECVOLUME 2
|
||||
jsr Pulse
|
||||
jsr PlayFrame
|
||||
DECVOLUME 3
|
||||
jsr Pulse
|
||||
jsr PlayFrame
|
||||
jmp NextFrame
|
||||
|
||||
; Play a frame's worth of samples
|
||||
PlayFrame
|
||||
TIMER_SETUP 212
|
||||
TimerLoop1
|
||||
jsr NextSamples
|
||||
lda INTIM
|
||||
cmp #3
|
||||
bcs TimerLoop1
|
||||
rts
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Macro that mixes two software voices
|
||||
@ -64,8 +94,10 @@ NextFrame
|
||||
sta Cycle0Lo+{2}
|
||||
lda Cycle0Hi+{2}
|
||||
adc Delta0Hi+{2}
|
||||
and #$1F
|
||||
sta Cycle0Hi+{2}
|
||||
and #$1F
|
||||
clc
|
||||
adc WaveOfs0+{2}
|
||||
tax
|
||||
; Get second channel phase, put in Y
|
||||
lda Cycle0Lo+{3}
|
||||
@ -74,8 +106,10 @@ NextFrame
|
||||
sta Cycle0Lo+{3}
|
||||
lda Cycle0Hi+{3}
|
||||
adc Delta0Hi+{3}
|
||||
and #$1F
|
||||
sta Cycle0Hi+{3}
|
||||
and #$1F
|
||||
clc
|
||||
adc WaveOfs0+{3}
|
||||
tay
|
||||
; Lookup wavetable entry and sum
|
||||
lda Wavetable,y
|
||||
@ -83,6 +117,7 @@ NextFrame
|
||||
adc Wavetable,x
|
||||
; Divide by 2 and store to volume register
|
||||
lsr
|
||||
; sta COLUBK
|
||||
sta AUDV0+{1}
|
||||
ENDM
|
||||
|
||||
@ -91,25 +126,292 @@ NextSamples
|
||||
NEXTSAMPLEPAIR 1,2,3 ; mix voices 2 and 3
|
||||
rts
|
||||
|
||||
; Play a note
|
||||
; X = channel (0,1)
|
||||
; Y = note index (0-63)
|
||||
PlayNote
|
||||
tya
|
||||
asl
|
||||
tay
|
||||
lda NoteDeltas,y
|
||||
sta Delta0Lo,x
|
||||
lda NoteDeltas+1,y
|
||||
sta Delta0Hi,x
|
||||
lda #$e0
|
||||
sta WaveOfs0,x
|
||||
rts
|
||||
|
||||
; Reset to start of song
|
||||
ResetTrack
|
||||
lda #<NOTEZ
|
||||
sta SongPtr+0
|
||||
lda #>NOTEZ
|
||||
sta SongPtr+1
|
||||
rts
|
||||
|
||||
; Called every frame
|
||||
; Decrement next-note timer, fetch next note
|
||||
Pulse
|
||||
lda DurationTimer
|
||||
beq NextData
|
||||
dec DurationTimer
|
||||
rts
|
||||
|
||||
; Timer ran out, so fetch next note
|
||||
NextData
|
||||
jsr NextSamples
|
||||
ldx #0
|
||||
lda (SongPtr,x) ; get next song byte
|
||||
bmi LoadDuration
|
||||
; < $80, so play next note
|
||||
ldx CurChannel ; load next channel #
|
||||
tay
|
||||
jsr PlayNote ; play note
|
||||
inx
|
||||
txa
|
||||
and #3
|
||||
sta CurChannel ; inc to next channel
|
||||
jmp IncDataPtr
|
||||
; >= $80 so load next duration
|
||||
LoadDuration
|
||||
cmp #$ff
|
||||
beq ResetTrack ; $ff = end of song
|
||||
and #$7f
|
||||
asl
|
||||
sta DurationTimer ; store duration * 2
|
||||
IncDataPtr
|
||||
; increment song pointer
|
||||
inc SongPtr
|
||||
bne NoIncHi
|
||||
inc SongPtr+1
|
||||
NoIncHi
|
||||
rts
|
||||
|
||||
; 32-byte wavetable
|
||||
align $100
|
||||
Wavetable
|
||||
hex 00010203 04050607 08090a0b 0c0d0e0f
|
||||
hex 0f0e0d0c 0b0a0908 07060504 03020100
|
||||
hex 00000000 00000000 00000000 00000000
|
||||
hex 00000000 00000000 00000000 00000000
|
||||
hex 04040404 04040404 04040404 04040404
|
||||
hex 04040404 04040404 00000000 00000000
|
||||
hex 06060606 06060606 06060606 06060606
|
||||
hex 06060606 06060606 00000000 00000000
|
||||
hex 08080808 08080808 08080808 08080808
|
||||
hex 08080808 08080808 00000000 00000000
|
||||
hex 0b0b0b0b 0b0b0b0b 0b0b0b0b 0b0b0b0b
|
||||
hex 0b0b0b0b 0b0b0b0b 0b0b0b0b 00000000
|
||||
hex 0d0d0d0d 0d0d0d0d 0d0d0d0d 0d0d0d0d
|
||||
hex 0d0d0d0d 0d0d0d0d 00000000 00000000
|
||||
hex 0f0f0f0f 0f0f0f0f 0f0f0f0f 0f0f0f0f
|
||||
hex 0f0f0f0f 00000000 00000000 00000000
|
||||
hex 0f0f0f0f 0f0f0f0f 0f0f0f0f 0f0f0f0f
|
||||
hex 00000000 00000000 00000000 00000000
|
||||
; hex 00010203 04050607 08090a0b 0c0d0e0f
|
||||
; hex 0f0e0d0c 0b0a0908 07060504 03020100
|
||||
|
||||
; Table of note periods
|
||||
align $100
|
||||
NoteDeltas
|
||||
word 9, 9, 10, 10, 11, 11, 12, 13, 14, 14, 15, 16
|
||||
word 17, 18, 19, 20, 22, 23, 24, 26, 27, 29, 30, 32
|
||||
word 34, 36, 38, 41, 43, 46, 48, 51, 54, 57, 61, 65
|
||||
word 68, 72, 77, 81, 86, 91, 97, 102, 108, 115, 122, 129
|
||||
word 137, 145, 153, 163, 172, 182, 193, 205, 217, 230, 244, 258
|
||||
word 273, 290, 307, 325, 344, 365, 387, 410, 434, 460, 487, 516
|
||||
word 547, 579, 614, 650, 689, 730, 773, 819, 868, 920, 974, 1032
|
||||
word 1093, 1159, 1227, 1300, 1378, 1460, 1546, 1638, 1736, 1839, 1948, 2064
|
||||
word 2187, 2317, 2455, 2601, 2755, 2919, 3093, 3277, 3472, 3678, 3897, 4128
|
||||
word 4374, 4634, 4910, 5202, 5511, 5839, 6186, 6554, 6943, 7356, 7793, 8257
|
||||
word 8748, 9268, 9819, 10403, 11022, 11677, 12371, 13107
|
||||
word 17, 18, 19, 20, 22, 23, 24, 26, 27, 29, 31, 32,
|
||||
word 34, 36, 39, 41, 43, 46, 49, 51, 54, 58, 61, 65,
|
||||
word 69, 73, 77, 82, 86, 92, 97, 103, 109, 115, 122, 130,
|
||||
word 137, 145, 154, 163, 173, 183, 194, 206, 218, 231, 245, 259,
|
||||
word 274, 291, 308, 326, 346, 366, 388, 411, 436, 462, 489, 518,
|
||||
word 549, 582, 616, 653, 692, 733, 776, 823, 871, 923, 978, 1036,
|
||||
word 1098, 1163, 1232, 1306, 1383, 1466, 1553, 1645, 1743, 1847, 1956, 2073,
|
||||
word 2196, 2327, 2465, 2611, 2767, 2931, 3106, 3290, 3486, 3693, 3913, 4145,
|
||||
word 4392, 4653, 4930, 5223, 5533, 5862, 6211, 6580, 6972, 7386, 7825, 8291,
|
||||
word 8784, 9306, 9859, 10446, 11067, 11725, 12422, 13161, 13943, 14772, 15651, 16582,
|
||||
word 17568, 18612, 19719, 20891, 22134, 23450, 24844, 26322,
|
||||
|
||||
NOTEZ
|
||||
hex 358a378a333f8a303c943e328a3a2e94
|
||||
hex 35298a372b8a33278a30249432268a2e
|
||||
hex 2294291d8a2b1f8a271b8a2418941a26
|
||||
hex 8a18248a17238a1622a83a35322e9429
|
||||
hex 26228a2a8a2b1b8a338a221f278a2b8a
|
||||
hex 332216942b2725228a338a2014942724
|
||||
hex 941f138a3f37338a383527228a39368a
|
||||
hex 3a37168a3f37338a353822278a3a378a
|
||||
hex 168a3e35328a38352622943f33371b94
|
||||
hex 1f22279427221f942926228a2a8a2b1b
|
||||
hex 8a338a1f22278a2b8a332216942b2725
|
||||
hex 228a338a2014942427941f13943c3330
|
||||
hex 1e8a3a332e8a39332d1d8a3c308a3f33
|
||||
hex 1d248a378a1d8a358a3f3327218a3c30
|
||||
hex 8a353826229422169424189429261a8a
|
||||
hex 2a8a2b1b8a338a27221f8a2b8a331622
|
||||
hex 942b2725228a338a201494272494131f
|
||||
hex 8a3f33378a383527228a39368a373a16
|
||||
hex 8a3f37338a383527228a3a378a168a3e
|
||||
hex 35328a38352026943f37331b9427221f
|
||||
hex 942b2722943f338a358a37271b8a3f33
|
||||
hex 8a352b22278a378a25198a3f338a352b
|
||||
hex 27228a3f338a3724188a3f338a352c27
|
||||
hex 248a378a23178a3f338a352c27238a3f
|
||||
hex 338a3a3722168a3f37338a38352b278a
|
||||
hex 3a378a168a3e32358a35382622943f33
|
||||
hex 371b9422169424189429261a8a2a8a2b
|
||||
hex 1b8a338a27221f8a2b8a332216942b25
|
||||
hex 22278a338a2014942724941f138a3f37
|
||||
hex 338a353827228a39368a3a37168a3f37
|
||||
hex 338a383527228a3a378a168a3e35328a
|
||||
hex 353820229437333f1b9427221f942722
|
||||
hex 1f942926228a2a8a2b1b8a338a221f27
|
||||
hex 8a2b8a332216942b2725228a338a2014
|
||||
hex 942724941f13943c33301e8a3a332e8a
|
||||
hex 2d33391d8a3c308a3f3327248a378a1d
|
||||
hex 8a358a333f27248a3c308a3835262294
|
||||
hex 22169424189429261a8a2a8a2b1b8a33
|
||||
hex 8a22271f8a2b8a332216942b2725228a
|
||||
hex 338a2014942427941f138a3f37338a38
|
||||
hex 3527228a36398a3a37168a3f37338a38
|
||||
hex 3527228a373a8a168a3e35328a383522
|
||||
hex 209433373f1b9427221f9422272b943f
|
||||
hex 338a358a37271b8a3f338a352b27228a
|
||||
hex 378a25198a3f338a352b22278a3f338a
|
||||
hex 3724188a333f8a352c27248a378a2317
|
||||
hex 8a3f338a352c27238a3f338a3a372216
|
||||
hex 8a3f37338a38352b278a373a8a168a3e
|
||||
hex 35328a383522269433373f2794221694
|
||||
hex 1b0f8a372b338a382c358a39362d8a3a
|
||||
hex 372e0f943c37302b8a3a2e378a168a37
|
||||
hex 332b8a2c38352b8a39362d8a3a372e1b
|
||||
hex 943c3730278a2e373a8a168a378a3327
|
||||
hex 2b228a2e8a30148a328a332c27248a35
|
||||
hex 8a37208a358a332c27238a358a2e1f8a
|
||||
hex 378a382b27228a3a8a3c168a3a8a3722
|
||||
hex 2b278a388a3a372e1b943c30372b8a3a
|
||||
hex 372e8a168a37332b8a382c35228a3936
|
||||
hex 2d8a3a372e1b943c37302b8a2e373a8a
|
||||
hex 1f8a3a8a3c1e8a3d8a3e3a351d8a3e35
|
||||
hex 3a8a2229268a3e33398a1d8a3c8a3933
|
||||
hex 29278a358a3a322926942014941f138a
|
||||
hex 372b338a38352c1d8a39362d8a2e3a37
|
||||
hex 1b943c3730228a3a372e8a168a332b37
|
||||
hex 8a38352c2b8a39362d8a3a372e1b9430
|
||||
hex 373c2b8a3a2e378a168a378a332b2722
|
||||
hex 8a2e8a30148a328a332c27248a358a37
|
||||
hex 208a358a33232c278a358a331f942b22
|
||||
hex 27941b8a2e8a2d2b27258a2e8a332c27
|
||||
hex 2494302c27248a338a21242a278a308a
|
||||
hex 332a27248a308a2e2b27228a338a372b
|
||||
hex 22278a3a8a2b27228a378a332b27228a
|
||||
hex 2e8a302d1d2794332d241d94372c2622
|
||||
hex 8a352c8a26228a332b8a271b94221694
|
||||
hex 1f138a3f378a381d118a398a3a372e1b
|
||||
hex 943c3037228a3a372e8a168a37332b8a
|
||||
hex 382c352b8a39362d8a3a372e1b943c37
|
||||
hex 302b8a2e373a8a168a378a332b27228a
|
||||
hex 2e8a30148a328a332c27248a358a3720
|
||||
hex 8a358a3323272c8a358a2e1f8a378a38
|
||||
hex 272b228a3a8a3c168a3a8a372b27228a
|
||||
hex 388a3a372e1b943c30372b8a3a372e8a
|
||||
hex 168a37332b8a382c352b8a39362d8a3a
|
||||
hex 372e1b943c3730228a2e373a8a1f8a3a
|
||||
hex 8a3c1e8a3d8a3e3a351d8a3e353a8a29
|
||||
hex 26228a3e33398a1d8a3c8a393327248a
|
||||
hex 358a3a322926942014941f138a372b33
|
||||
hex 8a38352c118a39362d8a2e3a371b943c
|
||||
hex 37302b8a3a372e8a168a332b378a3835
|
||||
hex 2c2b8a39362d8a3a372e1b94303c372b
|
||||
hex 8a372e3a8a168a378a332b27228a2e8a
|
||||
hex 30148a328a3327242c8a358a37208a35
|
||||
hex 8a332c27238a358a331f942b2722941b
|
||||
hex 8a2e8a2d2b27258a2e8a332c27249430
|
||||
hex 2c20278a338a2a2724218a308a332a27
|
||||
hex 248a308a2e2b22278a338a372b27228a
|
||||
hex 3a8a2b27228a378a332b22278a2e8a30
|
||||
hex 2d271d94332d241d94372c26228a352c
|
||||
hex 8a26228a332b8a271b942216941b0f94
|
||||
hex 298a2a8a2b1b8a338a271f228a2b8a33
|
||||
hex 2216942b2725228a338a201494272494
|
||||
hex 1f138a3f37338a383527228a39368a3a
|
||||
hex 37168a3f37338a383527228a3a378a16
|
||||
hex 8a3e35328a38352220943f37331b9427
|
||||
hex 221f94221f27942926228a2a8a2b1b8a
|
||||
hex 338a27221f8a2b8a332216942b272225
|
||||
hex 8a338a2014942724941f1394333c301e
|
||||
hex 8a3a332e8a39332d1d8a3c308a3f3327
|
||||
hex 248a378a1d8a358a3f3327248a3c308a
|
||||
hex 353826229422169424189429261a8a2a
|
||||
hex 8a2b1b8a338a1f22278a2b8a33221694
|
||||
hex 2b2725228a338a2014942427941f138a
|
||||
hex 3f37338a383527228a39368a373a168a
|
||||
hex 3f33378a353827228a3a378a168a3e35
|
||||
hex 328a38352622943f37331b9427221f94
|
||||
hex 222b27943f338a358a37271b8a3f338a
|
||||
hex 352b27228a378a25198a333f8a352722
|
||||
hex 2b8a3f338a3724188a3f338a352c2724
|
||||
hex 8a378a23178a3f338a3523272c8a3f33
|
||||
hex 8a3a3716228a33373f8a38352b278a3a
|
||||
hex 378a168a32353e8a38352622943f3733
|
||||
hex 27942216943f37331ba8383c148a3b8a
|
||||
hex 3c382427941b943f3c382c94383d1994
|
||||
hex 312c29258a308a31208a338a352c2529
|
||||
hex 943835118a378a38352c299418943c38
|
||||
hex 352494353a3d16942e25298a2d8a2e1d
|
||||
hex 8a308a3129258a3a8a352519943a2529
|
||||
hex 8a358a22168a3a8a3523179433241894
|
||||
hex 24272c94381d942c292494371f8a3b8a
|
||||
hex 3e26292b8a8a238a8a3e2b29268a3f8a
|
||||
hex 3c2b2724a83d22272b941b943c38148a
|
||||
hex 3b8a383c2c27941b943f3c382c943d38
|
||||
hex 1994312c25298a308a31208a338a352c
|
||||
hex 2925943835118a378a38352c24941894
|
||||
hex 353c382c943d3a3516942e29258a2d8a
|
||||
hex 2e1d8a308a3129258a3a8a352519943a
|
||||
hex 29258a358a16228a3a8a352317943324
|
||||
hex 188a20148a1f138a111d8a38322f1c9e
|
||||
hex 388a3c33301b8a3f338a2c27248a3a31
|
||||
hex 8a271b8a338a35311b0f8a378a383020
|
||||
hex 1494328a338a358a378a388a3a8a3c38
|
||||
hex 148a3b8a383c2c27941b943f3c382c94
|
||||
hex 3d381994312c29258a308a31208a338a
|
||||
hex 35292c25943835118a378a38352c2994
|
||||
hex 18943c35382c94353d3a16942e29258a
|
||||
hex 2d8a2e1d8a308a3129258a3a8a352519
|
||||
hex 943a29258a358a22168a3a8a35231794
|
||||
hex 332418942c272494381d942c29249437
|
||||
hex 1f8a3b8a3e262b298a8a238a8a3e2b29
|
||||
hex 268a3f8a3c2b2724a83d2b2722941b94
|
||||
hex 3c38148a3b8a383c242c941b943f3c38
|
||||
hex 2c943d381994312c29258a308a31208a
|
||||
hex 338a352c2925943538118a378a38352c
|
||||
hex 299418943c383524943d3a3516942e25
|
||||
hex 298a2d8a2e1d8a308a3129258a3a8a35
|
||||
hex 2519943a29258a358a22168a3a8a3523
|
||||
hex 17943324188a20148a1f138a1d118a38
|
||||
hex 322f1c9e388a30333c1b8a3f338a2c27
|
||||
hex 248a3a318a271b8a338a35311b0f8a37
|
||||
hex 8a30382014a83f3c3814a83320272494
|
||||
hex 302c27248a338a2a2724218a308a332a
|
||||
hex 21248a308a2e2b27228a338a3722272b
|
||||
hex 8a3a8a2b27228a378a332b27228a2e8a
|
||||
hex 302d271d94332d241d94372c26228a35
|
||||
hex 2c8a26228a332b8a271ba833373a3fa8
|
||||
hex 2c2914942b2820248a2c298a188a2b28
|
||||
hex 8a292c242094148a308a2c3524208a30
|
||||
hex 8a33188a358a3324208a308a2e2b1b94
|
||||
hex 2d2a27228a2e2b8a168a2d2a8a2e2b1f
|
||||
hex 27941b8a338a372e27228a338a35168a
|
||||
hex 378a351f22278a338a35321694343126
|
||||
hex 228a35328a1a8a34318a323526229416
|
||||
hex 8a388a3c3222268a388a3a1d8a3c8a3a
|
||||
hex 2622208a388a3f3327218a3f338a3f33
|
||||
hex 2721a83c332721943a331f27942e2b8a
|
||||
hex 2e2b8a2e2b942b2e942c2914942b2824
|
||||
hex 208a2c298a188a2b288a2c2924209414
|
||||
hex 8a308a352c20248a308a33188a358a33
|
||||
hex 24208a308a2e2b1b942a2d27228a2e2b
|
||||
hex 8a168a2d2a8a2e2b1f27941b8a338a37
|
||||
hex 2e271f8a338a35168a378a3527221f8a
|
||||
hex 338a3020148a2f8a301d118a3a308a1f
|
||||
hex 138a38308a20148a33308a372e22168a
|
||||
hex 368a37222b278a3c8a2a27218a3f8a3a
|
||||
hex 2b27228a378a332d182494332d1d1194
|
||||
hex 372c32228a35322c8a261a8a332e2b8a
|
||||
hex 271b942b2e8a2e2b8a2e2b942e2b942c
|
||||
hex 1b942216943f3a3733ff
|
||||
|
||||
; Epilogue
|
||||
org $fffc
|
||||
|
File diff suppressed because one or more lines are too long
@ -27,6 +27,7 @@ var VCS_PRESETS = [
|
||||
{id:'examples/road', chapter:33, name:'Pseudo 3D Road'},
|
||||
{id:'examples/bankswitching', chapter:35, name:'Bankswitching'},
|
||||
{id:'examples/wavetable', chapter:36, name:'Wavetable Sound'},
|
||||
// {id:'examples/music2', name:'Pitch-Accurate Music'},
|
||||
// {id:'examples/fullgame', name:'Thru Hike: The Game', title:'Thru Hike'},
|
||||
];
|
||||
|
||||
|
@ -874,7 +874,6 @@ function setupDebugControls(){
|
||||
$("#dbg_toline").click(runToCursor);
|
||||
$("#dbg_stepout").click(runUntilReturn);
|
||||
$("#dbg_stepback").click(runStepBackwards);
|
||||
// TODO: vcs platform seems to show them regardless
|
||||
if (platform_id == 'vcs') {
|
||||
$("#dbg_timing").click(traceTiming).show();
|
||||
}
|
||||
|
19
tools/midi2song.py
Normal file → Executable file
19
tools/midi2song.py
Normal file → Executable file
@ -6,15 +6,25 @@ import mido
|
||||
min_note = 21
|
||||
max_note = 21+63
|
||||
max_voices = 3
|
||||
one_voice_per_channel = 1
|
||||
one_voice_per_channel = 0
|
||||
tempo = 48
|
||||
compress = 0
|
||||
transpose = 0
|
||||
coutput = 1
|
||||
|
||||
# for 2600
|
||||
#max_voices = 2
|
||||
#coutput = 0
|
||||
# for 2600 wavetable
|
||||
#max_voices = 4
|
||||
#one_voice_per_channel = 0
|
||||
|
||||
fn = sys.argv[1]
|
||||
|
||||
mid = mido.MidiFile(fn)
|
||||
|
||||
def hex1(n):
|
||||
return '%02x'%n
|
||||
def hex2(n):
|
||||
return '0x%02x'%n
|
||||
|
||||
@ -128,7 +138,12 @@ else:
|
||||
nvoices += 1
|
||||
curchans |= 1<<msg.channel
|
||||
output.append(0xff)
|
||||
print string.join([hex2(x) for x in output], ',')
|
||||
if coutput:
|
||||
print string.join([hex2(x) for x in output], ',')
|
||||
else:
|
||||
bighex = string.join([hex1(x) for x in output], '')
|
||||
for i in range(0,len(bighex)+32,32):
|
||||
print '\thex', bighex[i:i+32]
|
||||
if compress:
|
||||
# replace common substrings
|
||||
bout = ''.join(chr(i) for i in output)
|
||||
|
0
tools/mknotes.py
Normal file → Executable file
0
tools/mknotes.py
Normal file → Executable file
89
tools/mknotes2600.py
Executable file
89
tools/mknotes2600.py
Executable file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys, math
|
||||
|
||||
test_notes = int(sys.argv[1]) or 49
|
||||
final_notes = int(sys.argv[2]) or 64
|
||||
|
||||
basehz = 15720.0 #4
|
||||
basehz2 = 5240.0 #12
|
||||
basehz3 = 1014.2 #6
|
||||
s = 8
|
||||
|
||||
bittable = [
|
||||
0b00000000,
|
||||
0b00000001,
|
||||
0b00010001,
|
||||
0b01001001,
|
||||
0b01010101,
|
||||
0b10110101,
|
||||
0b11011011,
|
||||
0b11101111,
|
||||
]
|
||||
|
||||
results = []
|
||||
|
||||
for a440 in range(4200,4600):
|
||||
error = 0
|
||||
for note in range(4,test_notes):
|
||||
notehz = a440 / 10.0 * math.pow(2.0, (note - 49) / 12.0);
|
||||
period = round(basehz * s / notehz) / s
|
||||
tonehz = basehz / period
|
||||
if period < s or period > 32*s:
|
||||
tonehz = -10000
|
||||
period2 = round(basehz2 * s / notehz) / s
|
||||
tonehz2 = basehz2 / period
|
||||
if period2 < s or period2 > 32*s:
|
||||
tonehz2 = -10000
|
||||
period3 = round(basehz3 * s / notehz) / s
|
||||
tonehz3 = basehz3 / period
|
||||
if period3 < s or period3 > 32*s:
|
||||
tonehz3 = -10000
|
||||
error += min(abs(notehz-tonehz), abs(notehz-tonehz2), abs(notehz-tonehz3))
|
||||
#print a440,note,notehz,notehz-tonehz,period
|
||||
#if a440 == 4405:
|
||||
# print '%d,%f,%d' % (note,tonehz-notehz,period)
|
||||
results.append((error, a440))
|
||||
|
||||
results.sort()
|
||||
best_error, best_a440 = results[0]
|
||||
best_a440 /= 10.0
|
||||
print '//', best_a440, best_error, test_notes
|
||||
|
||||
periods = []
|
||||
tones = []
|
||||
bits = []
|
||||
|
||||
print "const int note_table[%d] = {" % final_notes
|
||||
for note in range(0,final_notes):
|
||||
notehz = best_a440 * math.pow(2.0, (note - 49) / 12.0);
|
||||
bestperiod = 255
|
||||
bestscore = 999999
|
||||
besthz = -1
|
||||
for hz in [basehz, basehz2, basehz3]:
|
||||
period = int(round(hz * s / notehz))
|
||||
if period >= s and period <= 32*s:
|
||||
tonehz = hz / period
|
||||
error = notehz - hz
|
||||
if error < bestscore:
|
||||
bestscore = error
|
||||
bestperiod = period
|
||||
besthz = hz
|
||||
|
||||
#print '%d,' % period,
|
||||
print note, besthz, bestperiod, notehz
|
||||
periods.append(bestperiod / s - 1)
|
||||
bits.append(bittable[bestperiod & (s-1)])
|
||||
if besthz==basehz:
|
||||
tones.append(4)
|
||||
elif besthz==basehz2:
|
||||
tones.append(12)
|
||||
elif besthz==basehz3:
|
||||
tones.append(6)
|
||||
else:
|
||||
tones.append(0)
|
||||
print "};"
|
||||
|
||||
print periods
|
||||
print bits
|
||||
print tones
|
@ -49,9 +49,9 @@ with open(sys.argv[1],'rb') as f:
|
||||
|
||||
# output bitmap tables
|
||||
for c in range(0,6):
|
||||
print "\talign $100"
|
||||
#print "\talign $100"
|
||||
print "PFBitmap%d" % c
|
||||
print "\thex 00"
|
||||
#print "\thex 00"
|
||||
s = '\thex '
|
||||
for i in range(0,height):
|
||||
s += '%02x' % output[c][height-i-1]
|
||||
|
Loading…
Reference in New Issue
Block a user