beneath-apple-dos/D2S1/FTS.S#040000.s
T. Joseph Carter 93dd3e1ecd Add the .s files (may be broken)
I would not swear these dumped correctly using the procedure described in the
README files.
2017-07-20 15:10:56 -07:00

196 lines
4.3 KiB
ArmAsm

SBTL 'F T S -- FIND T/S LISTS UTILITY'
ORG $900
SKP 1
***********************************************************
* *
* FTS: THIS PROGRAM SCANS THE ENTIRE DISKETTE FOR WHAT *
* APPEAR TO BE TRACK/SECTOR LISTS AND PRINTS THE *
* TRACK AND SECTOR OF EACH ONE IT FINDS. *
* *
* INPUT: NONE *
* *
* ENTRY POINT: $900 *
* *
* PROGRAMMER: DON D WORTH 2/15/81 *
* *
***********************************************************
SKP 2
BELL EQU $87 BELL CHARACTER
RETURN EQU $8D CARRIAGE RETURN
SKP 1
* ZPAGE DEFINITIONS
SKP 1
PTR EQU $0 WORK POINTER
A1L EQU $3C MONITOR POINTER
A2L EQU $3E MONITOR POINTER
PREG EQU $48 MONITOR STATUS REGISTER
SKP 1
* OTHER ADDRESSES
SKP 1
BUFFER EQU $800 SECTOR DATA BUFFER
LOCRPL EQU $3E3 LOCATE RWTS PARMLIST SUBRTN
RWTS EQU $3D9 RWTS SUBROUTINE
COUT EQU $FDED PRINT ONE CHAR SUBROUTINE
PRBYTE EQU $FDDA PRINT ONE HEX BYTE SUBRTN
SKP 1
* RWTS PARMLIST DEFINITION
SKP 1
DSECT
RPLIOB DS 1 IOB TYPE ($01)
RPLSLT DS 1 SLOT*16
RPLDRV DS 1 DRIVE
RPLVOL DS 1 VOLUME
RPLTRK DS 1 TRACK
RPLSEC DS 1 SECTOR
RPLDCT DS 2 ADDRESS OF DCT
RPLBUF DS 2 ADDRESS OF BUFFER
RPLSIZ DS 2 SECTOR SIZE
RPLCMD DS 1 COMMAND CODE
RPLCNL EQU $00 NULL COMMAND
RPLCRD EQU $01 READ COMMAND
RPLCWR EQU $02 WRITE COMMAND
RPLCFM EQU $04 FORMAT COMMAND
RPLRCD DS 1 RETURN CODE
RPLRWP EQU $10 WRITE PROTECTED
RPLRVM EQU $20 VOLUME MISMATCH
RPLRDE EQU $40 DRIVE ERROR
RPLRRE EQU $80 READ ERROR
RPLTVL DS 1 TRUE VOLUME
RPLPSL DS 1 PREVIOUS SLOT
RPLPDR DS 1 PREVIOUS DRIVE
DEND
SKP 2
* START TRACK/SECTOR JUST PAST DOS (TRACK 3)
SKP 1
FTS JSR LOCRPL LOCATE RWTS PARMLIST
STY PTR AND SAVE POINTER
STA PTR+1
SKP 1
LDA #3 FIRST NON-DOS TRACK
LDY #RPLTRK STORE IN RWTS LIST
STA (PTR),Y
SKP 1
LDY #RPLBUF
LDA #>BUFFER STORE BUFFER PTR IN LIST
STA (PTR),Y
INY
LDA #<BUFFER
STA (PTR),Y
SKP 1
LDA #RPLCRD GET COMMAND CODE FOR READ
LDY #RPLCMD AND STORE IN LIST
STA (PTR),Y
SKP 1
LDA #0 ANY VOLUME WILL DO
LDY #RPLVOL
STA (PTR),Y
SKP 1
* NEW TRACK, START SECTOR AT ZERO
SKP 1
NEWTRK LDY #RPLSEC
LDA #0
STA (PTR),Y
SKP 1
* NOW CALL RWTS TO READ THE SECTOR
SKP 1
NEWSEC JSR LOCRPL RELOAD POINTER TO PARMS
JSR RWTS CALL RWTS
LDA #0
STA PREG FIX P REG SO DOS IS HAPPY
BCC SCAN ALL IS WELL
SKP 1
* ERROR OCCURED, PRINT "RC=XX"
SKP 1
JSR PRTTS PRINT TRACK/SECTOR
LDA #BELL BEEP THE SPEAKER
JSR COUT
LDA #'R PRINT THE "RC="
JSR COUT
LDA #'C
JSR COUT
LDA #'=
JSR COUT
LDY #RPLRCD
LDA (PTR),Y GET RWTS RETURN CODE
JSR PRBYTE PRINT RETURN CODE IN HEX
LDA #RETURN
JSR COUT
JMP NXTSEC GO ON
SKP 1
* NO ERROR, SEE IF SECTOR LOOKS LIKE A T/S LIST
SKP 1
SCAN LDX #0
SCLP0 LDA BUFFER,X MAKE SURE ITS NOT ALL ZERO
BNE SCAN1
INX
BNE SCLP0
BEQ NXTSEC IF IT IS, SKIP IT
SKP 1
SCAN1 LDX #5 START AT OFFSET 5
SCLP1 LDA BUFFER,X
BNE NXTSEC HEADER OF T/S MUST BE ZERO
INX
CPX #12 AT THE T/S PAIRS YET?
BCC SCLP1 NO, KEEP CHECKING
SKP 1
SCLP2 LDA BUFFER,X GET TRK
CMP #35 MUST BE 0-34
BCS NXTSEC
INX
LDA BUFFER,X GET SECTOR
CMP #16 MUST BE 0-15
BCS NXTSEC
INX
BNE SCLP2
SKP 1
JSR PRTTS ALL CONDITIONS MET
LDA #RETURN
JSR COUT
SKP 1
* BUMP SECTOR NUMBER OR TRACK AND CONTINUE
SKP 1
NXTSEC LDY #RPLSEC
LDA (PTR),Y GET LAST SECTOR
CLC
ADC #1 BUMP BY ONE
STA (PTR),Y AND PUT IT BACK IN LIST
CMP #16 TOO BIG?
BCS NXTTRK
JMP NEWSEC NO, GO READ IT
SKP 1
NXTTRK LDY #RPLTRK
LDA (PTR),Y GET LAST TRACK
CLC
ADC #1 BUMP BY ONE
STA (PTR),Y AND PUT IT BACK IN LIST
CMP #$11 CATALOG TRACK?
BEQ NXTTRK YES, SKIP OVER THAT ONE
CMP #35 DONE ALL 35 TRACKS?
BCS EXIT YES, LEAVE
JMP NEWTRK NO, GO READ FIRST SECTOR
EXIT RTS
SKP 2
* PRTTS: PRINT "T=XX S=XX"
SKP 1
PRTTS LDA #'T PRINT "T"
JSR COUT
LDY #RPLTRK
LDA (PTR),Y
JSR PRTEQ PRINT "=XX "
SKP 1
LDA #'S PRINT "S"
JSR COUT
LDY #RPLSEC
LDA (PTR),Y
JSR PRTEQ PRINT "=XX "
RTS
SKP 1
PRTEQ PHA
LDA #'=
JSR COUT
PLA
JSR PRBYTE
LDA #'
JSR COUT
RTS