2023-07-28 01:09:51 +00:00
|
|
|
; Micro-SCI / Franklin "Technician Mode" firmware
|
|
|
|
;
|
|
|
|
; Thanks to S.Elliott@AppleFritter for comments/analysis
|
2023-07-09 20:59:05 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
.setcpu "6502"
|
|
|
|
.org $c600
|
2023-07-09 20:59:05 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
A2L := $3e
|
|
|
|
SLOTx16 := $fd
|
2023-07-09 20:59:05 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
; motherboard IO ports
|
|
|
|
KBD := $C000
|
|
|
|
KBDSTRB := $C010
|
2023-07-09 20:59:05 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
; DEVSEL ports, accessed via SLOTx16 in X reg
|
|
|
|
STEPOFF := $C080
|
|
|
|
STEPON := $C081
|
|
|
|
MOTOROFF := $C088
|
|
|
|
MOTORON := $C089
|
|
|
|
Q6OFF := $C08C
|
|
|
|
Q6ON := $C08D
|
|
|
|
Q7OFF := $C08E
|
|
|
|
Q7ON := $C08F
|
2023-07-09 20:59:05 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
MON_WAIT := $FCA8
|
|
|
|
GETLNZ := $FD67
|
|
|
|
BELL := $FF3A
|
|
|
|
IORTS := $FF58
|
|
|
|
GETNUM := $FFA7
|
|
|
|
|
|
|
|
KEY_POUND := $A3
|
|
|
|
KEY_S := $EC
|
|
|
|
KEY_W := $F0
|
|
|
|
KEY_Z := $F3
|
|
|
|
KEY_M := $06
|
|
|
|
KEY_R := $EB
|
|
|
|
KEY_X := $F1
|
|
|
|
KEY_Q := $EA
|
|
|
|
|
|
|
|
lda #KEY_POUND
|
2023-07-16 02:28:35 +00:00
|
|
|
sta $33 ; set input-prompt character to '#'
|
2023-07-09 20:59:05 +00:00
|
|
|
LC604: jsr BELL
|
2023-07-16 02:28:35 +00:00
|
|
|
LC607: jsr GETLNZ ; start new line and take input
|
2023-07-09 20:59:05 +00:00
|
|
|
lda #$00
|
|
|
|
sta $F2
|
2023-07-28 01:09:51 +00:00
|
|
|
LC60E: sta KBDSTRB ; clear keyboard strobe
|
2023-07-09 20:59:05 +00:00
|
|
|
sta $F3
|
|
|
|
ldy $F2
|
2023-07-16 02:28:35 +00:00
|
|
|
jsr GETNUM ; parse hex into A2, A has last char xor $b0
|
|
|
|
; plus $89
|
2023-07-09 20:59:05 +00:00
|
|
|
sty $F2
|
2023-07-16 02:28:35 +00:00
|
|
|
cmp #$C6 ; $C6 from $8D (return)
|
|
|
|
beq LC607 ; no more input, go prompt for new input
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_S ; 'S'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_S
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_W ; 'W'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_W
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_Z ; 'Z'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_Z
|
2023-07-09 20:59:05 +00:00
|
|
|
ldy #$7F
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_M ; 'M'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_MX
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_R ; 'R'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_R
|
2023-07-09 20:59:05 +00:00
|
|
|
ldx #$06
|
|
|
|
stx $F3
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_X ; 'X'
|
2023-07-16 02:28:35 +00:00
|
|
|
beq CMD_MX
|
2023-07-28 01:09:51 +00:00
|
|
|
cmp #KEY_Q ; 'Q'
|
2023-07-16 02:28:35 +00:00
|
|
|
bne LC604 ; BEEP and prompt for new input
|
|
|
|
brk ; 'Q' exits out
|
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
; 'R': recalibrate by seeking track $00 from track $50
|
|
|
|
CMD_R: lda #$50 ; set starting track to #$50
|
|
|
|
sta $FC ; store accumulator as 'current' track at $FC
|
|
|
|
txa ; set accumulator to 0
|
|
|
|
adc #$00 ; inc A (carry still set from CMP #$EB)
|
|
|
|
sta $F3 ; set ($F3)=01
|
|
|
|
lda #$00 ; pass target track #$00 through accumulator
|
|
|
|
beq LC651 ; branch to end of 'S' command to finish
|
2023-07-16 02:28:35 +00:00
|
|
|
|
|
|
|
; 'S': seek logical-track index in A2L ('22S' seeks logical track $22)
|
2023-07-28 01:09:51 +00:00
|
|
|
CMD_S: lda A2L ; load logical track-index from A2L
|
|
|
|
asl a ; convert to physical track-index
|
|
|
|
LC651: sta $F0 ; store accumulator as target track at $F0
|
|
|
|
ldy #$FF ; value to be stored at $09 = #$FF
|
|
|
|
bne CMD_MX ; branch to 'M' command for next step
|
2023-07-16 02:28:35 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
; 'Z': seek logical-track index in A2L (eg: "22Z" seeks logical track $22)
|
|
|
|
CMD_Z: lda A2L ; load logical track-index from A2L
|
|
|
|
asl a ; convert to physical track-index
|
|
|
|
sta $F1 ; store as target track in $F1
|
|
|
|
ldy #$00 ; value to stored at $09 = #$00
|
|
|
|
beq CMD_MX ; branch to 'M' command for next step
|
|
|
|
; temporarily stop motor, then branch to turn it on again
|
2023-07-09 20:59:05 +00:00
|
|
|
LC660: lda #$50
|
|
|
|
jsr MON_WAIT
|
2023-07-28 01:09:51 +00:00
|
|
|
sta MOTOROFF,x
|
2023-07-16 02:28:35 +00:00
|
|
|
ldy A2L
|
2023-07-09 20:59:05 +00:00
|
|
|
LC66A: jsr MON_WAIT
|
|
|
|
dey
|
|
|
|
bpl LC66A
|
|
|
|
bmi LC68E
|
2023-07-28 01:09:51 +00:00
|
|
|
|
|
|
|
; EXIT THRU GIFT SHOP, current command finished, go back to parser
|
2023-07-09 20:59:05 +00:00
|
|
|
LC672: lda #$00
|
|
|
|
beq LC60E
|
2023-07-16 02:28:35 +00:00
|
|
|
|
2023-07-28 01:09:51 +00:00
|
|
|
; 'W' command, write nibble-pattern in A2L (eg: "96W" writes 96 96 96...)
|
2023-07-16 02:28:35 +00:00
|
|
|
CMD_W: lda A2L
|
2023-07-09 20:59:05 +00:00
|
|
|
sta $FF
|
|
|
|
ldy #$0F
|
2023-07-28 01:09:51 +00:00
|
|
|
|
|
|
|
; 'M' command while Y=#7F and X=#00
|
|
|
|
; 'X' command while Y=#7F and X=#06 and ($f3)=#06
|
|
|
|
|
|
|
|
CMD_MX: sty $09 ; preserve actual command
|
|
|
|
jsr IORTS ; put our address on stack
|
2023-07-09 20:59:05 +00:00
|
|
|
tsx
|
2023-07-28 01:09:51 +00:00
|
|
|
lda $0100,x ; derive our DEVSEL index
|
2023-07-09 20:59:05 +00:00
|
|
|
asl a
|
|
|
|
asl a
|
|
|
|
asl a
|
|
|
|
asl a
|
2023-07-28 01:09:51 +00:00
|
|
|
sta SLOTx16 ; save DEVSEL index for future IO
|
2023-07-09 20:59:05 +00:00
|
|
|
adc $F3
|
|
|
|
tax
|
2023-07-28 01:09:51 +00:00
|
|
|
LC68E: sta MOTORON,x
|
2023-07-09 20:59:05 +00:00
|
|
|
lda $09
|
2023-07-28 01:09:51 +00:00
|
|
|
beq LC6BA ; Y=00, branch for 'Z'
|
|
|
|
bmi LC6BA ; Y=FF, branch for 'S'
|
2023-07-09 20:59:05 +00:00
|
|
|
asl a
|
|
|
|
bmi LC6AC
|
2023-07-28 01:09:51 +00:00
|
|
|
sta Q7ON,x ; start writing/erasing
|
|
|
|
LC69D: lda $09 ; [3 cycles] reload saved Y byte
|
|
|
|
asl a ; [2] shift-left to test second bit
|
|
|
|
bmi LC660 ; [2] branch to stop motor for 'M' and 'X' and 'S' commands
|
2023-07-09 20:59:05 +00:00
|
|
|
nop
|
|
|
|
nop
|
2023-07-28 01:09:51 +00:00
|
|
|
lda $FF ; byte value to be written
|
|
|
|
sta Q6ON,x ; store into data register (wrong timing for Disk II, it would probably write $DD instead)
|
|
|
|
cmp Q6OFF,x ; [4] shift data-out
|
|
|
|
LC6AC: lda KBD ; get keypress
|
|
|
|
eor #$9B ; ESC?
|
|
|
|
bne LC69D ; if not, continue loop
|
|
|
|
ldx SLOTx16
|
|
|
|
sta Q7OFF,x
|
|
|
|
LC6B8: beq LC672 ; all done, branch to branch-to-parser
|
|
|
|
LC6BA: ldx SLOTx16
|
|
|
|
sta MOTORON,x
|
2023-07-09 20:59:05 +00:00
|
|
|
LC6BF: ldy $FC
|
2023-07-28 01:09:51 +00:00
|
|
|
LC6C1: cpy $F0 ; compare track index in Y to target track (result in carry flag)
|
|
|
|
bne LC6E3 ; track doesn't match, go to stepper routine
|
|
|
|
lda $F0 ; load current track into accumulator (redundant, same value is already in Y reg)
|
|
|
|
sta $FC ; store current track
|
2023-07-09 20:59:05 +00:00
|
|
|
lda $09
|
2023-07-28 01:09:51 +00:00
|
|
|
bne LC672 ; Y=00, branch for 'Z'
|
|
|
|
lda $F0 ; exchange target track indexes in $F0 vs $F1
|
2023-07-09 20:59:05 +00:00
|
|
|
ldy $F1
|
|
|
|
sta $F1
|
|
|
|
sty $F0
|
2023-07-28 01:09:51 +00:00
|
|
|
lda KBD ; read current key value
|
|
|
|
eor #$9B ; $9B = <esc>
|
|
|
|
beq LC6B8 ; if current key is <esc> then branch
|
2023-07-09 20:59:05 +00:00
|
|
|
lda #$73
|
2023-07-28 01:09:51 +00:00
|
|
|
jsr MON_WAIT ; delay for mechanical seek time
|
2023-07-09 20:59:05 +00:00
|
|
|
bcs LC6BF
|
2023-07-28 01:09:51 +00:00
|
|
|
LC6E3: bcs LC6E7 ; track numbers increasing or decreasing?
|
|
|
|
iny ; increment track number in Y reg
|
|
|
|
iny ; decrement track number in Y reg
|
2023-07-09 20:59:05 +00:00
|
|
|
LC6E7: dey
|
|
|
|
tya
|
2023-07-28 01:09:51 +00:00
|
|
|
and #$03 ; mask track to just 4 low bits, numbers 00-01-02-03
|
|
|
|
asl a ; shift left, convert to stepper-motor phases 02-04-06-08
|
|
|
|
ora SLOTx16 ; bitwise-OR to make it into a DEVSEL-relative IO address
|
|
|
|
tax ; move it into X reg for IO
|
|
|
|
lsr a ; shift right to make track number again
|
|
|
|
lsr a ; now shift low-bit into carry flag (odd vs even)
|
|
|
|
sta STEPON,x ; turn on stepper motor phase indicated in X reg
|
|
|
|
nop ; dead code
|
2023-07-09 20:59:05 +00:00
|
|
|
nop
|
|
|
|
lda #$56
|
2023-07-28 01:09:51 +00:00
|
|
|
jsr MON_WAIT ; wait stepper delay (returns with A=00, carry set)
|
|
|
|
sta STEPOFF,x ; turn off stepper motor phase indicated in X reg
|
|
|
|
bcs LC6C1 ; branch always
|