beneath-apple-dos/D2S1/INIT.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

173 lines
4.5 KiB
ArmAsm

SBTL 'I N I T -- REFORMAT A SINGLE TRACK'
ORG $800
SKP 1
***********************************************************
* *
* INIT: THIS PROGRAM WILL ALLOW ITS USER TO INITIALIZE A *
* SINGLE TRACK WITH ANY VOLUME NUMBER DESIRED. *
* *
* INPUT: $02 = TRACK TO BE INITIALIZED *
* *
* $03 = VOLUME NUMBER *
* *
* ENTRY POINT: $800 *
* *
* PROGRAMMER: PIETER LECHNER 2/19/81 *
* *
***********************************************************
SKP 1
* ZPAGE DEFINITIONS
SKP 1
PTR EQU $0 WORK POINTER
TRACK EQU $2 TRACK TO BE READ/WRITTEN
VOLUME EQU $3 VOLUME NUMBER
SECFND EQU $2D SECTOR FOUND BY RDADR16
AA EQU $3E ZPAGE CONSTANT FOR TIMING
VOL EQU $41 VOLUME USED BY WRADR16
TRK EQU $44 TRACK USED BY WRADR16
SYNCNT EQU $45 SYNC COUNT USED BY DSKF2
PREG EQU $48 MONITOR P REGISTER SAVEAREA
BELL EQU $87 ASCII BELL
SKP 1
* OTHER ADDRESSES
SKP 1
LOCRPL EQU $3E3 LOCATE RWTS PARMLIST SUBRTN
RWTS EQU $3D9 RWTS SUBROUTINE
RTRYCNT EQU $578 RETRY COUNT FOR DSKF2
NBUF1 EQU $BB00 PRIMARY SECTOR BUFFER
NBUF2 EQU $BC00 SECONDARY SECTOR BUFFER
READ16 EQU $B8DC READ DATA FIELD ROUTINE
RDADR16 EQU $B944 READ ADDRESS FIELD ROUTINE
DSKF2 EQU $BF0D FORMAT ONE TRACK ROUTINE
COUT EQU $FDED MONITOR CHARACTER OUTPUT
PRBYTE EQU $FDDA MONITOR HEX OUTPUT
SKP 1
* DISK I/O SELECTS
SKP 1
DRVSM0 EQU $C080 STEP MOTOR POSITIONS
DRVSM1 EQU $C081
DRVSM2 EQU $C082
DRVSM3 EQU $C083
DRVSM4 EQU $C084
DRVSM5 EQU $C085
DRVSM6 EQU $C086
DRVSM7 EQU $C087
DRVOFF EQU $C088 TURN DRIVE OFF AFTER 6 REVS
DRVON EQU $C089 TURN DRIVE ON
DRVSL1 EQU $C08A SELECT DRIVE 1
DRVSL2 EQU $C08B SELECT DRIVE 2
DRVRD EQU $C08C READ DATA LATCH
DRVWR EQU $C08D WRITE DATA LATCH
DRVRDM EQU $C08E SET READ MODE
DRVWRM EQU $C08F SET WRITE MODE
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
* USE RWTS TO POSITION THE ARM TO THE DESIRED TRACK
SKP 1
DUMP JSR LOCRPL LOCATE RWTS PARMLIST
STY PTR AND SAVE POINTER
STA PTR+1
SKP 1
LDA TRACK GET TRACK TO READ/WRITE
LDY #RPLTRK STORE IN RWTS LIST
STA (PTR),Y
SKP 1
LDA #RPLCNL NULL OPERATION
LDY #RPLCMD AND STORE IN LIST
STA (PTR),Y
SKP 1
LDA #0 ANY VOLUME WILL DO
LDY #RPLVOL
STA (PTR),Y
JSR LOCRPL RELOAD POINTER TO PARMS
JSR RWTS CALL RWTS
LDA DRVON,X LEAVE DRIVE ON
SKP 1
* ESTABLISH ENVIRONMENT FOR DSKF2 ROUTINE
SKP 1
LDA TRACK PASS TRACK TO DSKF2
STA TRK
LDA VOLUME AND VOLUME
STA VOL
LDA #$AA STORE CONSTANT FOR ZPAGE..
STA AA TIMING
LDA #$28 START WITH 40 SYNCS..
STA SYNCNT BETWEEN SECTORS
LDY #$56
LDA #$00
ZNBUF2 STA NBUF2-1,Y ZERO SECONDARY BUFFER
DEY
BNE ZNBUF2
ZNBUF1 STA NBUF1,Y AND PRIMARY BUFFER
DEY
BNE ZNBUF1
SKP 1
* INITIALIZE TRACK
SKP 1
JSR DSKF2 FORMAT TRACK AND VERIFY
LDA #$08 IN CASE OF ERROR...
BCS HNDERR ERROR?
SKP 1
* READ SECTOR ZERO TO VERIFY FORMATTING
SKP 1
LDA #$30 NO, DOUBLE CHECK TRACK
STA RTRYCNT ALLOW 48 RETRIES
NOGOOD SEC
DEC RTRYCNT COUNT RETRIES
BEQ HNDERR
JSR RDADR16 READ AN ADDRESS FIELD
BCS NOGOOD ERROR, TRY AGAIN
LDA SECFND IS THIS SECTOR ZERO?
BNE NOGOOD NO, TRY AGAIN
JSR READ16 YES, READ DATA FIELD
BCC DONETRK ALL IS WELL, DONE.
HNDERR LDY #RPLRCD ELSE, PHONEY UP A RC
STA (PTR),Y
SKP 1
* ERROR OCCURED, PRINT "RC=XX"
SKP 1
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
SKP 1
* WHEN DONE, EXIT TO CALLER
SKP 1
DONETRK LDA DRVOFF,X TURN DRIVE OFF
LDA #$00
STA PREG CLEAR P REGISTER FOR DOS
RTS ; RETURN TO CALLER