💾 Archived View for spam.works › mirrors › textfiles › apple › ANATOMY › t.dos.b65d.b7ff.txt captured on 2023-06-16 at 21:12:03.

View Raw

More Information

-=-=-=-=-=-=-



APPNDFLG HEX 00 ;APPEND FLAG.



OTHRERR JSR GETBUFF ;LOCATE BUFFER BELONGING TO THE
;FILE. (PUT ADR IN A3L/H PTR.)
 BCS TOERRMSG ;NO BUFFER WAS ASSIGNED, SO NO
;NEED 2 RELEASE THE FILE'S BUF OR
;TURN OFF THE APPEND FLAG.
 LDA #0 ;ZERO OUT THE APPEND FLAG & SET
 TAY ;(Y) TO NDEX THE 1RST BYTE OF THE
 STA APPNDFLG ;DOS NAME BUFFER.
 STA (A3L),Y ;RELEASE FILE'S DOS BUFFER.
TOERRMSG LDA RTNCODFM ;GET ERROR CODE TO INDEX ERR MSG.
 JMP ERRHNDLR ;EXIT & GO PRINT ERROR MESSAGE.






CKAPFLG LDA APPNDFLG ;IS APPEND FLAG ON?
 BEQ CLRAPFLG ;NO - FLAG IS OFF.
 INC RECNMBFM ;YES -SO INCREMENT THE FILE MGR'S
 BNE CLRAPFLG ;VERSION OF THE RECORD # BECAUSE
 INC RECNMBFM+1 ;RECNMBFM IS POINTING AT THE LAST
;VALID DATA BYTE AND WE WANT IT 2
;POINT AT THE NEXT POTENTIAL
;RECORD NUMBER.  (P.S.  REMEMBER
;THAT RECNMBFM LAGS RECNMBWA BY
;ONE BYTE.)
CLRAPFLG LDA #0 ;DON'T NEED THE APPEND FLAG ANY
 STA APPNDFLG ;MORE, SO TURN IT OFF.
 JMP RSETPTRS ;GO BACK UP THE FILE POINTER.




VRFYRWNG STA SUBCODFM ;PUT RANGE-OF-BYTES SUBCODE IN
;RWTS'S IOB.
 JSR FMDRIVER ;CALL FM DRIVER TO READ/WRITE A
;RANGE OF BYTES.
 JSR CMDCLOSE ;CLOSE FILE & THEN VERIFY DATA.
 JMP CMDVERFY








APNDPTCH LDY #$13
CK4ZEROS LDA (A4L),Y
 BNE SETAPFLG ;UNLESS WE ARE DEALING WITH A
;USELESS FILE THAT WAS PREVIOUSLY
;OPENED. BUT NEVER CLOSED, THIS
;INSTRUCTION IS ALWAYS TAKEN.
 INY
 CPY #$17
 BNE CK4ZEROS



 LDY #$19 ;COPY IMAGE OF RECNMBWA/+1 AND
COPYRECS LDA (A4L),Y ;BYTOFFWA/+1 THAT WERE JUST
 STA RECLENFM-$19,Y ;STORED IN THE WORK BUFFER TO
 INY ;RECNMBFM/+1 AND BYTOFFFM/+1 IN
 CPY #$1D ;THE FM PARAMETER LIST.
 BNE COPYRECS
FMDVRTN JMP BK2FMDRV




SETAPFLG LDX #$FF
 STX APPNDFLG ;SET THE APPEND FLAG.
 BNE FMDVRTN ;ALWAYS.






RSETPTRS LDA RECNMBFM ;RECONCILE RECORD NUMBER VERSIONS
 STA FILPTBYT ;AND LOWEST TWO BYTE OF THE FILE
 STA RECNMBWA ;POINTER.
 LDA RECNMBFM+1
 STA WASTEBYT ;APPEARS TO BE IRRELEVANT.
;OBVIOUSLY HAS SOMETHING TO DO
;WITH CK4ZEROS ROUTINE DESCRIBED
;ABOVE.
 STA RECNMBWA+1
 STA FILPTSEC
 TSX ;RESET THE STK POINTER SO WE CAN
 STX STKSAV ;USE THE FMEXIT ROUTINE TO RETURN
;TO THE CALLER OF THE APPEND CMD.
;(NOTE: THIS WILL BE EXCEPTIONAL
;EXIT ROUTE FOR FMEXIT.)
 JMP GOODFMXT ;EXIT THE APPEND CMD VIA FMEXIT
;ROUTINE. EXECUTION ACTUALLY RTNS
;2 AFTRCMD ($A17D) LOCATED IN THE
;CMD PARSING AND PROCESSING
;ROUTINES.




 DS 1 ;($B6CF)






 JSR HOME
 LDA #"B"
 JSR COUT
 LDA #$01
 JSR PRBYTE
 LDA #"-"
 JSR COUT
 LDA #$00
 JSR PRBYTE
 RTS




 DS 21 ;($B6E8-$B6FC.)




IMG8FD DA $B600 ;VARIES FROM $B600-$BF00 ON 48K
;SLAVE.  (EVENTUALLY POINTS TO THE
;START OF BOOT2 AT $B700.  IMAGE
;OF BT1LDADR AT $8FD.)
IMG8FF DS 1 ;CONTAINS # OF PAGES TO READ WHEN
;EXECUTING BOOT1.  ALSO DOUBLES AS
;LOGICAL SEC#.  INITIALLY = $01.
;VARIES FROM:$09 --> $00 --> $FF.
;(IMAGE OF BT1PG2RD AT $8FF.)









BOOT2 STX IBSLOT ;(X) = SLOT*16 WANTED.
 STX IOBPSN ;LAST-USED SLOT*16.
 LDA #1 ;DESIGNATE BOTH LAST-USED & WNTD
 STA IOBPDN ;DRIVES TO BE DRIVE#1.
 STA IBDRVN
 LDA NMPG2RD ;SET NUMBER OF PAGES TO READ.
 STA BT2PGCTR ;COUNTER 4 NUMBER OF PGS 2 READ.
 LDA #2 ;START WITH TRK$02/SEC$04.
 STA IBTRK ;TRACK.
 LDA #4
 STA IBSECT ;SECTOR.
 LDY BT1MGADR+1 ;(Y)=HI BYTE OF ADDR OF IMAGE OF
;BOOT1 (#$B6 ON 48K SLAVE).
 DEY ;DEFINE I/O BUF AS 1 PAGE BELOW
 STY IBBUFP+1 ;BOOT1.
 LDA #1 ;OPCODE FOR READ.
 STA IBCMD



 TXA ;(X) = SLOT * 16.
 LSR ;DIVIDE BY 16.
 LSR
 LSR
 LSR
 TAX ;(X) = SLOT.



 LDA #0
 STA TRK4DRV2,X
 STA TRK4DRV1,X



 JSR RWPAGES ;GO READ A GROUP OF PAGES (SECS).
 LDX #$FF ;COMPLETELY CLEAR OUT THE STACK.
 TXS
 STX IBVOL ;SET VOL TO $FF (COMPLEMENT OF 0)
 JMP CLOBCARD ;GO CLOBBER THE LANGUAGE CARD AND
;SET VIDEO OUTPUT (SIMUL8 PR#0).
;(RETURNS TO NEXT INSTRUC BELOW.)

BK2BOOT2 JSR SETKBD ;SIMULATE "IN#0" STATEMENT.
;(THAT IS, SELECT KEYBOARD.)
 JMP DOSCOLD ;JUMP IN2 DOS'S COLDSTART ROUTINE
;(AT $9DE4) TO BUILD THE DOS BUFS
;AND THE PAGE-3 VECTOR TABLE AND
;THEN RUN THE "HELLO" PROGRAM.
;************* NOTE *************
;* THIS INSTRUC IS A HACKER'S   *
;* DREAM.  FOR INSTANCE, YOU CAN*
;* CHANGE THE JUMP TO POINT TO  *
;* YOUR OWN PASSWORD OR TIME-   *
;* BOMB PRGM THAT YOU HAVE      *
;* DEVIOUSLY IMBEDDED IN AN     *
;* UNUSED SECTION OF DOS.       *
;********************************




WRDOSIMG LDA BTSTAGE+1 ;CALC # OF PAGES TO WRITE:
 SEC ;    (#$B6 - #$9D = #$19 OR #25.)
 SBC IBBUFP+1
 STA BT2PGCTR ;SET COUNTER FOR 25 PAGES.
 LDA BTSTAGE+1
 STA IBBUFP+1
 DEC IBBUFP+1 ;START WITH PAGE #$B5.
 LDA #2 ;START WITH TRK02/SEC04.
 STA IBTRK
 LDA #4
 STA IBSECT
 LDA #2 ;SET WRITE COMMAND.
 STA IBCMD
 JSR RWPAGES ;WRT TRK02/SEC04 TO TRK00/SEC00.



 LDA BTSTAGE+1 ;STORE HI BYTE OF ADRRESS OF THE
 STA IMG8FD+1 ;START OF BOOT1 (#$B6).
 CLC ;CALC HI BYTE ADR OF TRK00/SEC09
 ADC #9 ;(#$B6 + #$09 = #$BF).
 STA IBBUFP+1 ;SET BUF 2 SEND INFO 2 PAGE #$BF.
 LDA #10 ;DESIGNATE 10 PAGES TO WRITE.
 STA BT2PGCTR ;(#$BFFF - #$B600).
 SEC
 SBC #1
 STA IMG8FF ;SIGNIFY THAT THERE ARE 9 PAGES 2
;BE READ WHEN BOOT1 IS EXECUTED.
 STA IBSECT ;START WRITING WITH TRK00/SEC09.
 JSR RWPAGES ;WRITE TRK00/SEC09 2 TRK00/SEC00.
 RTS




 HEX 000000000000 ;UNUSED.




RWPAGES LDA ADROFIOB+1 ;INIT (A)/(Y) WITH HI/LOW BYTS OF
 LDY ADROFIOB ;ADR OF RWTS'S IOB 4 NTRY 2 RWTS.
 JSR ENTERWTS ;ENTER IN2 RWTS 2 READ/WRITE SEC.
 LDY IBSECT ;GET # OF SEC JUST RD OR WRITTEN
 DEY ;VAL 4 NXT SEC 2 READ/WRITE (WHEN
;EXECUTING BOOT1, #$09 --> #$FF).
 BPL SAMETRK ;BRANCH TO USE THE SAME TRACK.



 LDY #$0F ;START WITH SEC 15.
 NOP
 NOP
 DEC IBTRK ;REDUCE TRK# WANTED.



SAMETRK STY IBSECT ;STORE NUMBER OF SEC WANTED.
 DEC IBBUFP+1 ;REDUCE BUFFER'S PAGE ADR.
 DEC BT2PGCTR ;REDUCE CNTR 4 # OF SECS 2 READ.
 BNE RWPAGES ;MORE SECS TO READ.
 RTS






ENTERWTS PHP ;SAVE STATUS ON STK.
;(C)=0 IF SEEKING OR READING.
;(C)=1 IF WRITING OR FORMATTING.
 SEI ;SET INTERRUPT DISABLE FLAG TO
;PREVENT ANY FURTHER MASKABLE
;INTERRUPTS WHEN DOING REAL-TIME
;PROGRAMMING.
 JSR RWTS ;ENTER RWTS PROPER 2 DO OPERAT'N:
;          $00=SEEK, $01=READ,
;          $02=WRITE, $03=FORMAT.
 BCS ERRENTER ;OPERATION WAS NOT SUCCESSFUL.
;NVR TAKEN IF JUST SEEKING CAUSE
;NO ERROR SIGNALLING ROUTINES ARE
;ASSOCIATED WITH THAT OPERATION.
 PLP ;THROW STATUS OFF STACK.
 CLC ;SIGNAL SUCCESSFUL.
 RTS

ERRENTER PLP ;THROW STATUS OFF STACK.
 SEC ;SIGNAL UNSUCCESSFUL.
 RTS




PRPWRDOS LDA FIRDOSPG+1 ;DESIGNATE START OF DOS AS ADR OF
 STA IBBUFP+1 ;I/O BUF IN RWTS'S IOB.
 LDA #0
 STA IBBUFP
 LDA VOLWA ;COMPLEMENT VOL#.
 EOR #$FF
 STA IBVOL
 RTS




ZCURBUF LDA #0
 TAY
ZCURBUF1 STA (A4L),Y
 INY
 BNE ZCURBUF1
 RTS




 DS 1 ;UNUSED ($B7DF).
NMPG2RD HEX 1B ;# OF PAGES TO READ (#27).
BT2PGCTR DS 1 ;# OF PAGES LEFT 2 READ (VARIES).
BT1RSTSC HEX 0A ;FIRST SEC # IN STAGE (#10).

 DS 1 ;UNUSED ($B7E3).
ADROFIOB DA IBTYPE ;ADR OF RWTS'S IOB (NORM $B7E8).
BTSTAGE DA SEC2RDB6 ;ADR OF START OF IMAGE OF BOOT1.
;(NORMALLY, $B600.)
BT1MGADR = BTSTAGE




IBTYPE HEX 01 ;TABLE TYPE (SHOULD BE $01).
IBSLOT DS 1 ;SLOT WANTED * 16.
IBDRVN DS 1 ;DRIVE WANTED ($01 OR $02).
IBVOL DS 1 ;VOL WANTED ($00 GOOD FOR ALL).
IBTRK DS 1 ;TRK WANTED.
IBSECT DS 1 ;LOGICAL SEC WANTED.
IBDCTP DA DEVTPC ;PTS 2 DEVICE CHARACTERISTIC TBL.
;(NORMALLY, $B7FB).
IBBUFP DS 2 ;PTS 2 RWTS'S I/O BUFFER.
IBSECSZ HEX 0001 ;SEC SIZ IN BYTS (LOW/HI FORMAT).
IBCMD DS 1 ;RWTS COMMAND CODE:
;          $00=SEEK, $01=READ,
;          $02=WRITE, $04=FORMAT.
IBSTAT DS 1 ;ERROR CODE:
;$00=NO ERRS, $10=WRIT PROT,
;$20=VOL MISMTCH, $40=I/O(DRV)ERR
;$80=READ ERR.
IBSMOD DS 1 ;VOLUME FOUND.
IOBPSN DS 1 ;SLOT*16 OF LAST ACCESS (FOUND).
IOBPDN DS 1 ;DRIVE # OF LAST ACCESS (FOUND).
 HEX 0000 ;UNUSED ($B7F9-$B7FA).




DEVTPC HEX 00 ;DEVICE TYPE.
PPTC HEX 01 ;PHASES/TRK. (EVEN VAL = 1PHASE,
;ODD VAL = 2PHASE.)  THEREFORE,
;$01=2 PHASE (WHICH TRANSLATES TO
;2 ARM MOVEMENTS PER TRACK).
MONTC HEX EFD8 ;MOTOR-ON-TIME COUNT.
 DS 1 ;UNUSED ($B7FF).
D