Skip to content

Instantly share code, notes, and snippets.

@aji aji/tonecloud.2a03 Secret

Created Jan 26, 2015
Embed
What would you like to do?
.data
tick: .byt 0 ; tick counter
rnum: .byt 0 ; row number
sidx: .byt 0 ; scales index
.text
_init:
; reset playroutine variables
lda #0
sta tick
sta rnum
rts
_play: .(
; check if tick counter has overflowed
lda tick
inc tick
cmp #12
beq run_row
; return if it hasn't
rts
_text:
run_row:
; if it has, reset to 0 and increment row counter
lda #0
sta tick
lda rnum
inc rnum
tax
and #$7
lda _text,x
lsr
lsr
lsr
and #$3
tax
inc
lda pulse,x
sta $4000
and #$3
tax
lda pulse,x
sta $4004
lda #%10111111
sta $4008
lda rnum
lsr
lsr
lsr
lsr
and #$7
tax
lda song,x
asl
asl
asl
sta sidx
lda rnum
and #$15
tax
lda p1_pat,x
and #$7
clc
adc sidx
tax
lda p1_scales,x
tax
lda freq_lo,x
sta $4002
lda freq_hi,x
sta $4003
p2_pat:
lda rnum
and #$15
tax
lda p2_pat,x
and #$7
clc
adc sidx
tax
lda p2_scales,x
tax
lda freq_lo,x
sta $4006
lda freq_hi,x
sta $4007
p1_pat:
lda rnum
and #$7
tax
lda tri_pat,x
and #$7
clc
adc sidx
tax
lda tri_scales,x
tax
lda freq_lo,x
sta $400a
lda freq_hi,x
sta $400b
rts
.)
; auto-generated frequency tables
freq_hi:
.byt $03,$03,$03,$03,$03,$02,$02,$02,$02,$02,$02,$02,$01,$01,$01,$01,
.byt $01,$01,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,
.byt $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
.byt $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
freq_lo:
.byt $d4,$9c,$69,$37,$09,$dd,$b4,$8d,$69,$46,$25,$06,$e9,$cd,$b4,$9b,
.byt $84,$6e,$59,$46,$34,$22,$12,$02,$f4,$e6,$d9,$cd,$c1,$b6,$ac,$a2,
.byt $99,$90,$88,$80,$79,$72,$6c,$66,$60,$5a,$55,$50,$4c,$47,$43,$3f,
.byt $3c,$38,$35,$32,$2f,$2c,$2a,$27,$25,$23,$21,$1f,$1d,$1b,$1a,$18,
p1_scales:
.byt 12,15,19,22,24,27,31,34
.byt 15,19,22,15,19,22,15,19
.byt 15,19,22,15,19,22,15,19
.byt 15,19,22,15,19,22,15,19
p2_scales:
.byt 31,34,12,15,19,22,24,27
.byt 12,15,19,22,15,19,22,15
.byt 12,15,19,22,15,19,22,15
.byt 31,34,12,15,19,22,24,27
tri_scales:
.byt 0,24, 0,12, 0,12,19,22
.byt 27, 3,10, 3,15,15,27,27
.byt 20, 8,12, 8,20, 8, 8, 8
.byt 6, 6, 6, 6,18,18,18,18
tri_pat:
.byt 7, 0, 1, 2, 3, 4, 5, 6
song:
.byt 0, 1, 0, 1, 2, 1, 2, 3
pulse:
.byt %00110111
.byt %11110110
.byt %10110111
.byt %01110100
_end:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.