Mi capita spesso di vedere dei bei player di musiche e ho voluto provare a farmene uno.
In questo player ho voluto mettere un po' di tutto: visualizzazione in (quasi) realtime dei bytes in memoria, navigazione con i cursori+spc+c=, visualizzazione del valore attualmente puntato sia come valori hex che come bande colorate (nibble alto e basso), visualizzazione del rastertime impiegato dalla routine di play sia come banda con scala graduata che come valore hex e valore massimo raggiunto.
Nel sorgente c'e' un po' di tutto: come settare piu' di una raster irq - il piu' stabilmente possibile -, visualizzazione di valori da binario a hex, gestione della tastiera, salvataggio e ripristino della zero page per evitare strani comportamenti al ritorno al basic... fatene buon uso.
;--------------------------------------
;very lame sid player(tm)
;iAN CooG/HokutoForce 31/10/06
;--------------------------------------
ptr = $02
ZPPTR1 = $ae
ZPPTR2 = $af
init = $0ffe
play = $1006
startpage = $1000
LINE1 = $91
LINE2 = $b8
LINE3 = $fa
;--------------------------------------
* = $0801
word eop
word 7102
byte $9e
byte "2061"
byte 0
eop word 0
;--------------------------------------
lda #0
sta $d020
sta $d011
lda #$ea
sta $0328
lda #$17
sta $d018
lda #<title
ldy #>title
jsr $ab1e
;--------------------------------------
ldy #$3f
trframe
lda safezone+$100,y
sta $500,y
dey
bpl trframe
lda #<[$0400+[17*40]]
sta ZPPTR1
lda #>[$0400+[17*40]]
sta ZPPTR2
ldx #1
ldy #0
lda #$64
sta [$0400+[16*40]+1]
repts
txa
ora #$30
pts sta (ZPPTR1),y
iny
lda #$64
sta (ZPPTR1),y
dey
lda ZPPTR1
clc
adc #$28
sta ZPPTR1
bcc nohpts
inc ZPPTR2
nohpts
inx
cpx #$09
bne repts
;--------------------------------------
; save the ZP
; some music players mess with it
ldx #0
tr1
lda $00,x
sta safezone,x
inx
bne tr1
stx ZPPTR1
stx ZPPTR2
;--------------------------------------
;init raster irq
sei
lda #$01
sta $d019
sta $d01a
sta $dc0d
lda $dc0d
lda #<irq1
ldx #>irq1
sta $0314
stx $0315
lda #0
tay
tax
sta ptr
jsr init
; set line to trigger 1st irq
lda #LINE1
sta $d012
lda #$1b
sta $d011
cli
;--------------------------------------
loop
ldy #0
trsc1
;sei ;just in case
;ldx #$35;we want to play
;stx $01 ;musics under ROMs
trsc
lda startpage,y
;ldx #$37
;stx $01
;cli
sta $0400,y
cpy ptr
beq thiswhite
lda #$0f
byte $2c
thiswhite
lda #$01
sta $d800,y
iny
bne trsc1
ldy ptr
lda $0400,y
sta ptr+1
lsr
lsr
lsr
lsr
sta ptr+2
;--------------------------------------
;print pointed location and value
jsr printval
;print current and max rastertime
jsr printrast
;--------------------------------------
;keyboard scan
lda #%11111110
jsr setcia
;left-right inc/dec ptr
cmp #%11111011
bne updown
jsr shifts
bcs decptr
bcc incptr
updown
;up-down +/- row
cmp #%01111111
bne plusmin
jsr shifts
bcs decptr40
;bcc incptr40
incptr40
lda ptr
adc #40
sta ptr
jmp preloo1
decptr40
lda ptr
sbc #40
sta ptr
jmp preloo1
plusmin
lda #%11011111
jsr setcia
;+ ptr++
cmp #%11111110
bne pchk1
incptr
inc ptr
preloo1 ldy #05
byte $2c
preloop ldy #30
jsr wnok
jmp loop
pchk1
;- ptr--
cmp #%11110111
bne chk0
decptr
dec ptr
jmp preloo1
chk0
lda #%01111111
jsr setcia
;space viewblock++
cmp #%11101111
bne chk1
inc trsc+2
jmp preloop
chk1
;c= viewblock--
cmp #%11011111
bne chk2
dec trsc+2
jmp preloop
chk2
;r/s exit
cmp #%01111111
beq exitnow
jmp loop
;--------------------------------------
exitnow
;prepare to exit
sei
lda #$31
ldx #$ea
sta $0314
stx $0315
lda #$81
sta $dc0d
lda $dc0d
lda #0
sta $d01a
; restore ZP
ldx #0
tr2
lda safezone,x
sta $00,x
inx
bne tr2
cli
;clear kbdbuff and sid vol
jsr $ffe4
bne *-3
;jsr $ffe4
;beq *-3
lda #0
sta $c6
sta $d418
lda #$ed
sta $0328
rts
;-----------------
wnok
ldx #0
wn1 dex
bne wn2
dey
beq wx
wn2
lda #0
jsr setcia
cmp #$ff
bne wn1
wx rts
;--------------------------------------
setcia sta $dc00
lda $dc01
rts
;--------------------------------------
shifts
lda #%11111101
jsr setcia
cmp #%01111111;+shiftleft
beq setshift
nextshift
lda #%10111111
jsr setcia
cmp #%11101111;+shiftright
bne unset
setshift
sec
rts
unset clc
rts
;--------------------------------------
irq1
asl $d019
bit $ea;timing
bit $ea
bit $ea
bit $ea
lda ptr+2
sta $d020
sta $d021
lda #LINE2
cmp $d012
bne *-3
lda #$00
sta $d020
sta $d021
;set new irq and new trigger line
lda #LINE2+1
sta $d012
lda #<irq2
ldx #>irq2
sta $0314
stx $0315
jmp $ea81; simple irq exit
;--------------------------------------
irq2
asl $d019
bit $ea;timing
bit $ea
bit $ea
bit $ea
nop
lda #$0f
sta $d021
sta $d020
jsr play
; save curent rasterline
ldx $d012
stx ptr+3
lda #$00
sta $d021
sta $d020
;set new irq and new trigger line
lda #LINE3
sta $d012
lda #<irq3
ldx #>irq3
sta $0314
stx $0315
jmp $ea81; simple irq exit
;--------------------------------------
irq3
asl $d019
bit $ea;timing
bit $ea
bit $ea
bit $ea
nop
lda ptr+1
sta $d021
sta $d020
lda $d011
bpl *-3
lda $d011
bmi *-3
lda #$00
sta $d020
sta $d021
;set old irq and old line
lda #LINE1
sta $d012
lda #<irq1
ldx #>irq1
sta $0314
stx $0315
; exit irq but also process kbd
jmp $ea7e
;--------------------------------------
printval
scrnpos = $051a
ldx #0
lda trsc+2
lsr
lsr
lsr
lsr
jsr printit
lda trsc+2
and #$0f
jsr printit
lda ptr
lsr
lsr
lsr
lsr
jsr printit
lda ptr
and #$0f
jsr printit
inx
inx
lda ptr+2
jsr printit
lda ptr+1
and #$0f
printit
tay
lda hexbytes,y
sta scrnpos,x
inx
rts
;--------------------------------------
printrast
scrnpos2 = $0509
scrnpos3 = $0512
lda ptr+3
sec
sbc #LINE2
sta ZPPTR1
cmp ZPPTR2
;bcc nosetmaxr
bmi nosetmaxr
sta ZPPTR2
nosetmaxr
lsr
lsr
lsr
lsr
tay
lda hexbytes,y
sta scrnpos2
lda ZPPTR1
and #$0f
tay
lda hexbytes,y
sta scrnpos2+1
lda ZPPTR2
lsr
lsr
lsr
lsr
tay
lda hexbytes,y
sta scrnpos3
lda ZPPTR2
and #$0f
tay
lda hexbytes,y
sta scrnpos3+1
rts
;--------------------------------------
title
byte $05,$93
byte $0d,$0d,$0d,$0d
byte $0d,$0d,$0d,$0d
byte $12
byte $9f
petc "Spc/C= "
byte $9e
byte $92
petc " Forward/Back one page "
byte $0d
byte $12
byte $9f
petc "Cursors"
byte $9e
byte $92
petc " Move pointer"
byte $0d
byte $12
byte $9f
petc "RunStop"
byte $9e
byte $92
petc " Exit to Basic"
byte $0d,$05
byte 0
;--------------------------------------
hexbytes
byte "0123456789",1,2,3,4,5,6
;--------------------------------------
safezone
ds $0100,0
;--------------------------------------
byte $70,"@@"
scrl "Curr:$00"
byte "@@"
scrl "Max:$00"
byte "@@@@@"
scrl "$0000=$00"
byte "@@@@@@",$7d
scrl "Flag Player v1.3 iAN/HF"
;--------------------------------------
;load $1000 / init $0ffe / play $1006
incprg Genesis_Notemaker.prg,l
;-[eof]--------------------------------
Sorgente e binarioPS: prendete appunti, non sono eterno