updates for fastchip program

This commit is contained in:
mgcaret 2017-10-06 10:36:37 -07:00
parent 8b06e85f08
commit 0f0c7d2c56
1 changed files with 107 additions and 59 deletions

View File

@ -1,12 +1,14 @@
; %help ; %help
; fastchip -- Control A2Heaven FastChip //e ; fastchip -- Control A2Heaven FastChip //e
; ;
; THIS PROGRAM IS ALPHA AND DOESN'T WORK YET!
;
; options: ; options:
; -l List speeds and exit ; -l List speeds and exit
; -e <num> Enable FastChip, 1 = on, 0 = off (sync) ; -e <num> Enable FastChip, 1 = on, 0 = off (sync)
; -s <num> Set speed, 0-40, see -l for list of speed values ; -s <num> Set speed, 0-40, see -l for list of speed values
; -p <str> Set slot speeds, slot numbers in str are set to fast, rest slow ; -p <str> Set slot speeds, slot numbers in str are set to fast, rest slow
; To set all slow, use -p 0 ; To set all slow, use -p 0. Will not set Disk IIs to fast.
; -a <num> Set audio (speaker) delay, 0-4 (Off/Fast/Normal/Music/Hifi) ; -a <num> Set audio (speaker) delay, 0-4 (Off/Fast/Normal/Music/Hifi)
; -j <num> Set joystick delay, 0-2 (Off/Short/Long) ; -j <num> Set joystick delay, 0-2 (Off/Short/Long)
; -b <num> Set backlight, 0-5 (Off/Fade/Speed/R/G/B) ; -b <num> Set backlight, 0-5 (Off/Fade/Speed/R/G/B)
@ -30,11 +32,18 @@ CFG_LIGHT = $07
ch = $24 ch = $24
fcbase = $c06a fcbase = $c06a
fcenable = fcbase+1
fcslots = fcbase+2
fcspeed = fcbase+3
fcregnum = fcbase+4
fcregval = fcbase+5
showall = xczpage ; if nonzero, don't show all settings showall = xczpage ; if nonzero, don't show all settings
myidx = showall+1 ; index variable myidx = showall+1 ; index variable
mytemp = myidx+1 ; temp for use in setting/showing/misc mytemp = myidx+1 ; temp for use in setting/showing/misc
mytemp1 = mytemp+1 mytemp1 = mytemp+2 ; temp for Disk II check
savex = mytemp1+2 ; place to save x reg
savey = savex+1 ; place to save y reg
;cout = $fded ;cout = $fded
prbyte = $fdda prbyte = $fdda
@ -78,13 +87,12 @@ exiterr: lda #$ff
; meat and potatoes now follow ; meat and potatoes now follow
jsr fcdetect jsr fcdetect
bcc doit bcc doit
bcs doit ; TESTING!
lda #$01 lda #$01
jsr xredirect jsr xredirect
jsr xmess jsr xmess
asc_hi "No FastChip detected!" asc_hi "No FastChip detected!"
.byte $8d,$00 .byte $8d,$00
jmp exiterr ; jmp exiterr ; comment out for basic emulator testing
doit: lda #$00 doit: lda #$00
sta showall sta showall
jsr try_all jsr try_all
@ -95,6 +103,8 @@ doit: lda #$00
; Try all config setting options ; Try all config setting options
.proc try_all .proc try_all
php
sei
jsr fcunlock jsr fcunlock
jsr try_state jsr try_state
jsr try_speed jsr try_speed
@ -103,6 +113,7 @@ doit: lda #$00
jsr try_joystick jsr try_joystick
jsr try_backlight jsr try_backlight
jsr fclock jsr fclock
plp
rts rts
.endproc .endproc
@ -115,7 +126,7 @@ doit: lda #$00
cpy #$01 cpy #$01
bne :+ ; want disable bne :+ ; want disable
lda #$01 lda #$01
sta fcbase+1 ; enable sta fcenable ; enable
bne diddone bne diddone
: lda #$01 ; anything but $a6 or $6a : lda #$01 ; anything but $a6 or $6a
sta fcbase ; disable sta fcbase ; disable
@ -131,8 +142,8 @@ done: rts
cpy #41 ; too big? cpy #41 ; too big?
bcs done bcs done
lda #CFG_SPEED lda #CFG_SPEED
sta fcbase+5 ; config reg sta fcregnum ; config reg
sty fcbase+6 ; value sty fcregval ; value
jsr show_speed jsr show_speed
inc showall inc showall
done: rts done: rts
@ -141,8 +152,9 @@ done: rts
.proc try_slots .proc try_slots
lda #'p'|$80 lda #'p'|$80
jsr xgetparm_ch jsr xgetparm_ch
bcs done bcc :+
sta mytemp+1 ; save string pointer rts
: sta mytemp+1 ; save string pointer
sty mytemp sty mytemp
ldy #$00 ldy #$00
sty myidx ; we'll keep calculated value here sty myidx ; we'll keep calculated value here
@ -155,8 +167,21 @@ lp: lda (mytemp),y ; get char
bcc next bcc next
cmp #'7'+1 cmp #'7'+1
bcs next bcs next
and #$0f ; get the bits we need to shift and #$0f ; get the bits containing slot #
tax jsr is_disk_ii ; check if Disk II
bcc :+ ; nope, go ahead
sty savey ; otherwise, warn user
jsr xmess
asc_hi "Not setting fast Disk II for slot "
.byte $00
ldy savey
lda (mytemp),y ; get slot number back
ora #$80 ; make printable
jsr cout ; print it
lda #$8d ; and cr
jsr cout
jmp next ; go to next number
: tax
lda #$01 lda #$01
: asl ; shift left for the slot : asl ; shift left for the slot
dex dex
@ -167,8 +192,8 @@ next: dey
bne lp bne lp
ldy myidx ; get computed value ldy myidx ; get computed value
lda #CFG_SPEED lda #CFG_SPEED
sta fcbase+5 ; config reg sta fcregnum ; config reg
sty fcbase+6 ; value sty fcregval ; value
;lda #$00 ; DEBUG ;lda #$00 ; DEBUG
;jsr xprdec_2 ; DEBUG ;jsr xprdec_2 ; DEBUG
jsr show_slots jsr show_slots
@ -183,8 +208,8 @@ done: rts
cpy #05 ; too big? cpy #05 ; too big?
bcs done bcs done
lda #CFG_SPKR lda #CFG_SPKR
sta fcbase+5 ; config reg sta fcregnum ; config reg
sty fcbase+6 ; value sty fcregval ; value
jsr show_speaker jsr show_speaker
inc showall inc showall
done: rts done: rts
@ -197,8 +222,8 @@ done: rts
cpy #03 ; too big? cpy #03 ; too big?
bcs done bcs done
lda #CFG_JSTCK lda #CFG_JSTCK
sta fcbase+5 ; config reg sta fcregnum ; config reg
sty fcbase+6 ; value sty fcregval ; value
jsr show_joystick jsr show_joystick
inc showall inc showall
done: rts done: rts
@ -211,8 +236,8 @@ done: rts
cpy #06 ; too big? cpy #06 ; too big?
bcs done bcs done
lda #CFG_LIGHT lda #CFG_LIGHT
sta fcbase+5 ; config reg sta fcregnum ; config reg
sty fcbase+6 ; value sty fcregval ; value
jsr show_backlight jsr show_backlight
inc showall inc showall
done: rts done: rts
@ -220,6 +245,8 @@ done: rts
; Show all current settings ; Show all current settings
.proc show_all .proc show_all
php
sei
jsr fcunlock jsr fcunlock
jsr show_state jsr show_state
jsr show_speed jsr show_speed
@ -230,6 +257,7 @@ done: rts
jsr show_slinky jsr show_slinky
jsr show_aux jsr show_aux
jsr fclock jsr fclock
plp
rts rts
.endproc .endproc
@ -237,12 +265,12 @@ done: rts
jsr xmess jsr xmess
asc_hi "FastChip: " asc_hi "FastChip: "
.byte $00 .byte $00
lda fcbase+1 lda fcenable
rol rol
rol rol
and #$01 and #$01
jsr pr_onoff jsr pr_onoff
: lda #$8d lda #$8d
jsr cout jsr cout
rts rts
.endproc .endproc
@ -252,8 +280,8 @@ done: rts
asc_hi "Speed: " asc_hi "Speed: "
.byte $00 .byte $00
lda #CFG_SPEED lda #CFG_SPEED
sta fcbase+5 ; config reg sta fcregnum ; config reg
lda fcbase+6 ; get speed lda fcregval ; get speed
pha ; save it pha ; save it
tay ; and put in y for printing tay ; and put in y for printing
lda #$00 ; high byte for printing lda #$00 ; high byte for printing
@ -277,8 +305,8 @@ done: rts
asc_hi "Slots: " asc_hi "Slots: "
.byte $00 .byte $00
lda #CFG_SLOTS lda #CFG_SLOTS
sta fcbase+5 sta fcregnum
lda fcbase+6 lda fcregval
lsr ; slot zero bit unused lsr ; slot zero bit unused
sta temp sta temp
lda #'1'|$80 lda #'1'|$80
@ -307,8 +335,8 @@ lp: jsr cout ; myidx reloaded at end of loop
asc_hi "Speaker: " asc_hi "Speaker: "
.byte $00 .byte $00
lda #CFG_SPKR lda #CFG_SPKR
sta fcbase+5 sta fcregnum
ldx fcbase+6 ldx fcregval
bne :+ bne :+
jsr pr_off jsr pr_off
lda #$8d lda #$8d
@ -349,8 +377,8 @@ lp: jsr cout ; myidx reloaded at end of loop
asc_hi "Joystick: " asc_hi "Joystick: "
.byte $00 .byte $00
lda #CFG_JSTCK lda #CFG_JSTCK
sta fcbase+5 sta fcregnum
ldx fcbase+6 ldx fcregval
bne :+ bne :+
jsr pr_off jsr pr_off
lda #$8d lda #$8d
@ -379,8 +407,8 @@ lp: jsr cout ; myidx reloaded at end of loop
asc_hi "Backlight: " asc_hi "Backlight: "
.byte $00 .byte $00
lda #CFG_LIGHT lda #CFG_LIGHT
sta fcbase+5 sta fcregnum
ldx fcbase+6 ldx fcregval
bne :+ bne :+
jsr pr_off jsr pr_off
lda #$8d lda #$8d
@ -427,15 +455,15 @@ lp: jsr cout ; myidx reloaded at end of loop
asc_hi "Slinky: " asc_hi "Slinky: "
.byte $00 .byte $00
lda #CFG_RFENA lda #CFG_RFENA
sta fcbase+5 sta fcregnum
lda fcbase+6 lda fcregval
jsr pr_onoff jsr pr_onoff
jsr xmess jsr xmess
asc_hi ", slot " asc_hi ", slot "
.byte $00 .byte $00
lda #CFG_RFSLT lda #CFG_RFSLT
sta fcbase+5 sta fcregnum
ldy fcbase+6 ldy fcregval
lda #$00 lda #$00
jsr xprdec_2 jsr xprdec_2
lda #$8d lda #$8d
@ -448,8 +476,8 @@ lp: jsr cout ; myidx reloaded at end of loop
asc_hi "Aux RAM: " asc_hi "Aux RAM: "
.byte $00 .byte $00
lda #CFG_RWENA lda #CFG_RWENA
sta fcbase+5 sta fcregnum
lda fcbase+6 lda fcregval
jsr pr_onoff jsr pr_onoff
lda #$8d lda #$8d
jsr cout jsr cout
@ -459,34 +487,41 @@ lp: jsr cout ; myidx reloaded at end of loop
; detect fastchip //e. If present, return carry clear ; detect fastchip //e. If present, return carry clear
; otherwise return carry set. ; otherwise return carry set.
.proc fcdetect .proc fcdetect
php
sei
jsr fcunlock jsr fcunlock
lda fcbase+1 ; current state lda fcenable ; current state
php ; save it (S flag) php ; save it (S flag)
sta fcbase+1 ; enable FC sta fcenable ; enable FC
lda fcbase+1 ; now see if it's there lda fcenable ; now see if it's there
bpl notfound ; bit 7 set if present and enabled bpl notfound ; bit 7 set if present and enabled
ldy fcbase+4 ; speed reg ldy fcspeed ; speed reg
lda #$21 ; 5.0 MHz iny ; increment
sta fcbase+4 tya ; put in accum
eor fcbase+4 ; should be 0 now dey ; fix value back for later restore
sty fcbase+4 ; restore value and #$1f ; at this point value is not what we read out
sta fcspeed ; set speed reg
eor fcspeed ; a should be 0 now
sty fcspeed ; restore value
bne notfound ; or not found bne notfound ; or not found
sta fcbase+5 ; config register select, 0 = speed sta fcregnum ; config register select, 0 = speed
ldx fcbase+6 ; config register data cpy fcregval ; config register data, saved speed
eor fcbase+4 ; should be 0 again bne notfound ; no match, no fastchip
bne notfound ; if not, no fastchip
; at this point we have a high degree of confidence that FC is there ; at this point we have a high degree of confidence that FC is there
plp ; get initial state plp ; get initial state
bpl setslow ; was it disabled? bpl setslow ; was it disabled?
bmi found bmi found
setslow: sta fcbase ; a=0 from above; disable it setslow: sta fcbase ; a=0 from above; disable it
found: jsr fclock found: jsr fclock ; lock it back up
clc plp ; restore IRQs
clc ; indicate found
rts rts
notfound: plp ; clean stack and get orig notfound: plp ; clean stack
sec plp ; restore IRQs
sec ; indicate not found
rts rts
.endproc .endproc
.proc fcunlock .proc fcunlock
lda #UNLOCKV lda #UNLOCKV
sta fcbase sta fcbase
@ -495,11 +530,13 @@ notfound: plp ; clean stack and get orig
sta fcbase sta fcbase
rts rts
.endproc .endproc
.proc fclock .proc fclock
lda #LOCKV lda #LOCKV
sta fcbase sta fcbase
rts rts
.endproc .endproc
.proc listspeeds .proc listspeeds
lda #$00 lda #$00
sta num+2 ; clear upper bytes of num sta num+2 ; clear upper bytes of num
@ -534,6 +571,7 @@ done: jsr xmess
rts rts
tabstops: .byte 0,30,20,10 tabstops: .byte 0,30,20,10
.endproc .endproc
; print fastchip speed in MHz from value in A ; print fastchip speed in MHz from value in A
; returns carry clear if a number was printed ; returns carry clear if a number was printed
; carry set otherwise ; carry set otherwise
@ -545,8 +583,7 @@ tabstops: .byte 0,30,20,10
asl asl
tax tax
ldy spdtab,x ; MHz ldy spdtab,x ; MHz
inx lda spdtab+1,x ; decimal
lda spdtab,x ; decimal
pha ; save it pha ; save it
lda #$00 lda #$00
jsr xprdec_2 ; print MHz in AY jsr xprdec_2 ; print MHz in AY
@ -580,12 +617,14 @@ spdtab: .byte 0,0,0,2,0,3
.byte 7,1,8,3,10,0 .byte 7,1,8,3,10,0
.byte 12,5,16,6 .byte 12,5,16,6
.endproc .endproc
.proc pr_err .proc pr_err
jsr xmess jsr xmess
asc_hi "Err!" asc_hi "Err!"
.byte $00 .byte $00
rts rts
.endproc .endproc
.proc pr_onoff .proc pr_onoff
ora #$00 ora #$00
beq pr_off beq pr_off
@ -596,28 +635,37 @@ spdtab: .byte 0,0,0,2,0,3
.byte $00 .byte $00
rts rts
.endproc .endproc
.proc pr_off .proc pr_off
jsr xmess jsr xmess
asc_hi "Off" asc_hi "Off"
.byte $00 .byte $00
rts rts
.endproc .endproc
; check slot referenced by A, set carry if disk II, clear carry if not ; check slot referenced by A, set carry if disk II, clear carry if not
; saves all regs
.proc is_disk_ii .proc is_disk_ii
pha
stx savex
sty savey
ora #$c0 ora #$c0
sta mytemp+1 sta mytemp1+1
lda #$00 lda #$00
sta mytemp sta mytemp1
ldx #$03 ldx #$03
: ldy idloc,x : ldy idloc,x
lda (mytemp),y lda (mytemp1),y
cmp idval,x cmp idval,x
bne :+ bne :+
dex dex
bpl :- bpl :-
sec sec
rts bcs getxy
: clc : clc
getxy: ldx savex
ldy savey
pla
rts rts
idloc: .byte $01,$03,$05,$ff idloc: .byte $01,$03,$05,$ff
idval: .byte $20,$00,$03,$00 idval: .byte $20,$00,$03,$00