Reformat, add comments from S.Elliott@AppleFritter

This commit is contained in:
Christopher RYU 2023-07-28 10:09:51 +09:00
parent 49fa0c2180
commit 8f415a7306

View File

@ -1,27 +1,49 @@
; da65 V2.11.0 - (C) Copyright 2000-2005, Ullrich von Bassewitz
; Created: 2022-01-26 21:00:18
; Input file: xaa
; Page: 1
; Micro-SCI / Franklin "Technician Mode" firmware
;
; Thanks to S.Elliott@AppleFritter for comments/analysis
.setcpu "6502"
.org $c600
.setcpu "6502"
.org $c600
A2L := $3e
SLOTx16 := $fd
A2L := $3e
MON_WAIT := $FCA8
GETLNZ := $FD67
BELL := $FF3A
IORTS := $FF58
GETNUM := $FFA7
; motherboard IO ports
KBD := $C000
KBDSTRB := $C010
; DEVSEL ports, accessed via SLOTx16 in X reg
STEPOFF := $C080
STEPON := $C081
MOTOROFF := $C088
MOTORON := $C089
Q6OFF := $C08C
Q6ON := $C08D
Q7OFF := $C08E
Q7ON := $C08F
lda #$A3 ; '#'
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
sta $33 ; set input-prompt character to '#'
LC604: jsr BELL
LC607: jsr GETLNZ ; start new line and take input
lda #$00
sta $F2
LC60E: sta $C010 ; clear keyboard strobe
LC60E: sta KBDSTRB ; clear keyboard strobe
sta $F3
ldy $F2
jsr GETNUM ; parse hex into A2, A has last char xor $b0
@ -29,128 +51,135 @@ LC60E: sta $C010 ; clear keyboard strobe
sty $F2
cmp #$C6 ; $C6 from $8D (return)
beq LC607 ; no more input, go prompt for new input
cmp #$EC ; 'S'
cmp #KEY_S ; 'S'
beq CMD_S
cmp #$F0 ; 'W'
cmp #KEY_W ; 'W'
beq CMD_W
cmp #$F3 ; 'Z'
cmp #KEY_Z ; 'Z'
beq CMD_Z
ldy #$7F
cmp #$06 ; 'M'
cmp #KEY_M ; 'M'
beq CMD_MX
cmp #$EB ; 'R'
cmp #KEY_R ; 'R'
beq CMD_R
ldx #$06
stx $F3
cmp #$F1 ; 'X'
cmp #KEY_X ; 'X'
beq CMD_MX
cmp #$EA ; 'Q'
cmp #KEY_Q ; 'Q'
bne LC604 ; BEEP and prompt for new input
brk ; 'Q' exits out
; 'R'
CMD_R: lda #$50
sta $FC
txa
adc #$00
sta $F3
lda #$00
beq LC651
; '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
; 'S': seek logical-track index in A2L ('22S' seeks logical track $22)
CMD_S: lda A2L
asl a
LC651: sta $F0
ldy #$FF
bne CMD_MX
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
; 'Z'
CMD_Z: lda A2L
asl a
sta $F1
ldy #$00
beq CMD_MX
; '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
LC660: lda #$50
jsr MON_WAIT
sta $C088,x
sta MOTOROFF,x
ldy A2L
LC66A: jsr MON_WAIT
dey
bpl LC66A
bmi LC68E
; EXIT THRU GIFT SHOP, current command finished, go back to parser
LC672: lda #$00
beq LC60E
; 'W'
; 'W' command, write nibble-pattern in A2L (eg: "96W" writes 96 96 96...)
CMD_W: lda A2L
sta $FF
ldy #$0F
CMD_MX: sty $09
jsr IORTS
; '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
tsx
lda $0100,x
lda $0100,x ; derive our DEVSEL index
asl a
asl a
asl a
asl a
sta $FD
sta SLOTx16 ; save DEVSEL index for future IO
adc $F3
tax
LC68E: sta $C089,x
LC68E: sta MOTORON,x
lda $09
beq LC6BA
bmi LC6BA
beq LC6BA ; Y=00, branch for 'Z'
bmi LC6BA ; Y=FF, branch for 'S'
asl a
bmi LC6AC
sta $C08F,x
LC69D: lda $09
asl a
bmi LC660
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
nop
nop
lda $FF
sta $C08D,x
cmp $C08C,x
LC6AC: lda $C000
eor #$9B
bne LC69D
ldx $FD
sta $C08E,x
LC6B8: beq LC672
LC6BA: ldx $FD
sta $C089,x
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
LC6BF: ldy $FC
LC6C1: cpy $F0
bne LC6E3
lda $F0
sta $FC
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
lda $09
bne LC672
lda $F0
bne LC672 ; Y=00, branch for 'Z'
lda $F0 ; exchange target track indexes in $F0 vs $F1
ldy $F1
sta $F1
sty $F0
lda $C000
eor #$9B
beq LC6B8
lda KBD ; read current key value
eor #$9B ; $9B = <esc>
beq LC6B8 ; if current key is <esc> then branch
lda #$73
jsr MON_WAIT
jsr MON_WAIT ; delay for mechanical seek time
bcs LC6BF
LC6E3: bcs LC6E7
iny
iny
LC6E3: bcs LC6E7 ; track numbers increasing or decreasing?
iny ; increment track number in Y reg
iny ; decrement track number in Y reg
LC6E7: dey
tya
and #$03
asl a
ora $FD
tax
lsr a
lsr a
sta $C081,x
nop
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
nop
lda #$56
jsr MON_WAIT
sta $C080,x
bcs LC6C1
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