1. Taking that1-UP music data, converting it to a decimal array
2. Converting the frequency lookup table to a decimal array
3. Use each index value +1 of the 1-UP music to associate which index to use on the frequency lookup table
4. Playing back that value as a sine wave frequency * 16.
Note that I'm not using any timing data. It's not a concern for now, and once I figure out how to use the music and frequency table, I'm sure I'll figure out how the timing works. Other music does not quite work with the process I have above. First off, many of the indices that result from the music values to reference a freq table index are out of range.
Right now I'm just using the squarewave 2 portion of music. The comments say:
This is the ground music part one:;MUSIC DATA
;square 2/triangle format
;d7 - length byte flag (0-note, 1-length)
;if d7 is set to 0 and d6-d0 is nonzero:
;d6-d0 - note offset in frequency look-up table (must be even)
;if d7 is set to 1:
;d6-d3 - unused
;d2-d0 - length offset in length look-up table
;value of $00 in square 2 data is used as null terminator, affects all sound channels
;value of $00 in triangle data causes routine to skip note
Code: Select all
GroundM_P1Data:
.db $85, $2c, $22, $1c, $84, $26, $2a, $82, $28, $26, $04
.db $87, $22, $34, $3a, $82, $40, $04, $36, $84, $3a, $34
.db $82, $2c, $30, $85, $2a
Looking at the frequencies, I see now that maybe converting this into a linear array was the wrong approach?
Code: Select all
FreqRegLookupTbl:
.db $00, $88, $00, $2f, $00, $00
.db $02, $a6, $02, $80, $02, $5c, $02, $3a
.db $02, $1a, $01, $df, $01, $c4, $01, $ab
.db $01, $93, $01, $7c, $01, $67, $01, $53
.db $01, $40, $01, $2e, $01, $1d, $01, $0d
.db $00, $fe, $00, $ef, $00, $e2, $00, $d5
.db $00, $c9, $00, $be, $00, $b3, $00, $a9
.db $00, $a0, $00, $97, $00, $8e, $00, $86
.db $00, $77, $00, $7e, $00, $71, $00, $54
.db $00, $64, $00, $5f, $00, $59, $00, $50
.db $00, $47, $00, $43, $00, $3b, $00, $35
.db $00, $2a, $00, $23, $04, $75, $03, $57
.db $02, $f9, $02, $cf, $01, $fc, $00, $6a
So in the end, how do I derive a linear sequence of frequencies to play for any given piece of music that uses that square 2 waveform?