Una delle minicanzoni della
TinySid compo, organizzata da Ice00, e' scritta in basic. Parlando con Slarti/Onslaught, che vuole realizzare un programma menu' che riunisca tutte le musice della compo in un unico programma, mi e' venuto in mente di convertire questa musica in asm.
Ho preso spunto da un articolo di Ice00 sulla sua SidIn per replicare le temporizzazioni delle istruzioni basic.
;---------------------------------------
; Repetitive Tune: bas -> asm
; original 2005 Peter Weighill
; iAN CooG/HokutoForce 2/05/05
;---------------------------------------
h = $02
l = $03
d = $04
c = $05
;---------------------------------------
*= $801
word eop
word 7102
byte $9e,$32,$30,$35,$39
eop
byte 0
;---------------------------------------
ldy #0
sty c
;1 m=54272:POKEm+24,15:
ldx #15
stx 54272+24
jsr C2600
;POKEm+5,9:
lda #9
sta 54272+5
jsr C2600
;POKEm+6,15
stx 54272+6
jsr C2600
;2 p=2226
restart
lda #<musictable
sta $fb
lda #>musictable
sta $fc
;3 h=PEEK(p):l=PEEK(p+1):d=PEEK(p+2):p=p+3:
loop
ldy #0
ldx #0
copyptr
lda ($fb),y
sta h,x
inc $fb
bne noh
inc $fc
noh
inx
cpx #3
bne copyptr
;IFd=0THEN5
lda d
beq line5
;4 POKEm+1,h:POKEm,l:POKEm+4,33:
lda h
sta 54272+1
jsr C2600
lda l
sta 54272
jsr C2600
ldx #33
stx 54272+4
jsr C2600
;FORt=1TOd:NEXT:POKEm+4,32:
lda d
jsr delay
ldx #32
stx 54272+4
;FORt=1TO300:NEXT:GOTO3
lda #80
jsr delay
jmp loop
;5 c=c+1:IFc=1THENc=-1:
line5
inc c
lda c
cmp #1
;6 GOTO3
bne loop
lda #$fe
sta c
;GOTO2
jmp restart
;--------------------------------------
delay
tax
duration
jsr C2600
dex
bne duration
rts
;---------------------------------------
; waste about 2600 cycles
; by Ice00, from Telengard.asm
;---------------------------------------
C2600
pha
txa
pha
tya
pha
ldx #129 ; 2
rep20
lda ($33,x) ; 6
lda ($34,x) ; 6
lda $3334 ; 4
dex ; 2
bne rep20 ; 2
pla
tay
pla
tax
pla
rts ; 6
;--------------------------------------
; note table originally at 2226
;--------------------------------------
musictable
byte $03,$F4,$18
byte $04,$B4,$18
byte $05,$47,$90
byte $04,$B4,$C0
byte $03,$F4,$18
byte $04,$B4,$18
byte $05,$47,$90
byte $04,$B4,$60
byte $04,$B4,$60
byte $00,$00,$00
byte $05,$47,$18
byte $06,$47,$18
byte $07,$0C,$90
byte $06,$47,$C0
byte $05,$47,$18
byte $06,$47,$18
byte $07,$0C,$90
byte $06,$47,$60
byte $06,$47,$60
byte $00,$00,$00
;---------------------------------------
Il risultato e' abbastanza soddisfacente