2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
|
|
|
|
* *
|
|
|
|
* FILEIO.MAC *
|
|
|
|
* *
|
|
|
|
* AUTHOR: NATHAN RIGGS *
|
|
|
|
* CONTACT: NATHAN.RIGGS@ *
|
|
|
|
* OUTLOOK.COM *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* VERSION: 0.2.0 *
|
|
|
|
* DATE: 22-DEC-2018 *
|
2018-11-17 02:47:02 +00:00
|
|
|
* ASSEMBLER: MERLIN 8 PRO *
|
2018-12-24 08:14:04 +00:00
|
|
|
* OS: DOS 3.3 *
|
|
|
|
* LICENSE: APACHE 2.0 *
|
2018-11-17 02:47:02 +00:00
|
|
|
* *
|
|
|
|
*------------------------------*
|
|
|
|
* *
|
|
|
|
* THIS IS A MACRO LIBRARY FOR *
|
|
|
|
* FILE INPUT AND OUTPUT, AS *
|
2018-12-24 08:14:04 +00:00
|
|
|
* WELL AS DISK OPERATIONS. *
|
2018-11-17 02:47:02 +00:00
|
|
|
* *
|
|
|
|
*------------------------------*
|
|
|
|
* *
|
|
|
|
* LIST OF MACROS *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* BSAVE : BINARY SAVE *
|
|
|
|
* BLOAD : BINARY LOAD *
|
|
|
|
* TMODE : TEXT FILE OP MODE *
|
|
|
|
* CMD : EXECUTE DOS COMMAND *
|
|
|
|
* FPRN : PRINT TO FILE *
|
|
|
|
* FINP : INPUT LINE FROM FILE *
|
|
|
|
* SLOT : SET RWTS SLOT *
|
|
|
|
* DRIVE : SET RWTS DRIVE *
|
|
|
|
* TRACK : SET RWTS TRACK *
|
|
|
|
* SECT : SET RWTS SECTOR *
|
|
|
|
* SETDR : SET RWTS READ *
|
|
|
|
* SETDW : SET RWTS WRITE *
|
|
|
|
* DBUFF : SET BUFFER ADDRESS *
|
|
|
|
* DRWTS : CALL THE RWTS ROUTE *
|
2018-11-17 02:47:02 +00:00
|
|
|
* *
|
|
|
|
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* BLOAD : LOAD A BINARY FILE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* LOAD INTO THE GIVEN ADDRESS *
|
|
|
|
* THE SPECIFIED BINARY FILE. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = ADDRESS OF CMD STR *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* BLOAD "TEST,A$300" *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
BLOAD MAC
|
|
|
|
_ISSTR ]1
|
|
|
|
JSR BINLOAD
|
2018-11-17 02:47:02 +00:00
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* BSAVE : SAVE TO BINARY FILE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAVE THE GIVEN ADDRESS RANGE *
|
|
|
|
* TO THE SPECIFIED FILE NAME. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = ADDRESS OF CDM STR *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* BSAVE "TEST,A$300,L$100" *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
BSAVE MAC
|
|
|
|
_ISSTR ]1
|
|
|
|
JSR BINSAVE
|
2018-11-17 02:47:02 +00:00
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* TMODE : INIT TXTFILE OP MODE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* FOOLS DOS INTO THINKING THAT *
|
|
|
|
* WE ARE IN INDIRECT MODE TO *
|
|
|
|
* ALLOW FOR TEXT FILE READ AND *
|
|
|
|
* WRITE OPERATIONS. *
|
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* TMODE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
TMODE MAC
|
|
|
|
JSR TXTMODE
|
2018-11-17 02:47:02 +00:00
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* CMD : EXECUTE DOS COMMAND *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SIMPLY EXECUTES THE DOS CMD *
|
|
|
|
* AS IT IS PROVIDED IN THE *
|
|
|
|
* STRING PASSED AS PARAMETER 1 *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = COMMAND STRING *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* CMD "CATALOG" *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
CMD MAC
|
|
|
|
JSR DOSCMD
|
2018-11-17 02:47:02 +00:00
|
|
|
ASC ]1
|
|
|
|
HEX 8D00
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* FPRN : PRINT LINE TO FILE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* PRINTS THE GIVEN STRING TO *
|
|
|
|
* THE FILE THAT IS OPEN FOR *
|
|
|
|
* WRITING. IF MEMORY ADDRESS *
|
|
|
|
* IS PASSED, THEN PRINT THE *
|
|
|
|
* STRING THAT IS AT THAT *
|
|
|
|
* LOCATION. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = EITHER A STRING OR *
|
2018-11-17 02:47:02 +00:00
|
|
|
* MEMLOC OF STRING *
|
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* FPRN "TESTING" *
|
|
|
|
* FPRN $300 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
FPRN MAC
|
|
|
|
IF ",]1
|
|
|
|
JSR FPRINT
|
|
|
|
ASC ]1
|
|
|
|
HEX 8D00
|
|
|
|
ELSE ; IF PARAM IS ADDR
|
2018-11-17 02:47:02 +00:00
|
|
|
LDA #>]1
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
JSR FPSTR ; PRINT STRING
|
|
|
|
FIN
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* FINP : GET LINE FROM TXTFILE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* GETS A LINE OF TEXT FROM THE *
|
|
|
|
* FILE OPEN FOR READING AND *
|
|
|
|
* STORES IT AD THE ADDRRESS *
|
|
|
|
* SPECIFIED IN THE PARAMETERS. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = ADDRESS OF CDM STR *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* FINP $300 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
FINP MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
LDA #>]1
|
|
|
|
PHA
|
|
|
|
LDA #<]1
|
|
|
|
PHA
|
|
|
|
JSR FINPUT
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* SLOT : CHANGE RWTS IOB SLOT *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
2018-12-24 08:14:04 +00:00
|
|
|
* CHANGES THE SLOT VALUE IN *
|
2018-11-17 02:47:02 +00:00
|
|
|
* THE IOB TABLE FOR THE RWTS *
|
|
|
|
* ROUTINE. JUST USES DOS IOB. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = SLOT NUMBER *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* SLOT #6 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
SLOT MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
LDA ]1
|
|
|
|
STA SCRATCH
|
|
|
|
ASL SCRATCH
|
|
|
|
ASL SCRATCH
|
|
|
|
ASL SCRATCH
|
|
|
|
ASL SCRATCH ; MUL BY 16
|
|
|
|
LDA SCRATCH
|
|
|
|
STA IOB_SLOT
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* DRIVE : CHANGE RWTSIOB DRIVE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* CHANGES THE DRIVE VALUE IN *
|
|
|
|
* THE IOB TABLE FOR THE RWTS *
|
|
|
|
* ROUTINE. JUST USES DOS IOB. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = DRIVE NUMBER *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* DRIVE #1 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
DRIVE MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
LDA ]1
|
|
|
|
STA IOB_DRIV
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* TRACK : CHANGE RWTSIOB TRACK *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* CHANGES THE TRACK VALUE IN *
|
|
|
|
* THE IOB TABLE FOR THE RWTS *
|
|
|
|
* ROUTINE. JUST USES DOS IOB. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = TRACK NUMBER *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* TRACK #5 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
TRACK MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
LDA ]1
|
|
|
|
STA IOB_TRAK
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* SECT : CHANGE RWTS SECTOR *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* CHANGES THE SECTOR VALUE IN *
|
|
|
|
* THE IOB TABLE FOR THE RWTS *
|
|
|
|
* ROUTINE. JUST USES DOS IOB. *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = SECTOR NUMBER *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* SECT #3 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
SECT MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
LDA ]1
|
|
|
|
STA IOB_SECT
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* SETDR : SET RWTS TO READMODE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* CHANGES THE RWTS COMMAND TO *
|
2018-12-24 08:14:04 +00:00
|
|
|
* READ ($01). *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
2018-12-24 08:14:04 +00:00
|
|
|
* SAMPLE USAGE: *
|
|
|
|
* SETDR *
|
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
|
|
|
SETDR MAC
|
|
|
|
*
|
|
|
|
LDA $01
|
|
|
|
STA IOB_COMM
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
|
|
|
* SETDW : SET RWTS TO WRITE *
|
|
|
|
*- -*
|
|
|
|
* CHANGES THE RWTS COMMAND TO *
|
|
|
|
* WRITE ($02). *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* SETDW *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
SETDW MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
LDA $02
|
2018-11-17 02:47:02 +00:00
|
|
|
STA IOB_COMM
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* DBUFF : CHANGE RWTS BUFFADDR *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* CHANGES THE BUFFER ADDRESS *
|
|
|
|
* FOR THE RWTS SUBROUTINE *
|
|
|
|
*- -*
|
|
|
|
* PARAMETERS: *
|
|
|
|
* *
|
2018-12-24 08:14:04 +00:00
|
|
|
* ]1 = BUFFER ADDRESS *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* DBUFF $300 *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
DBUFF MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
LDA #<]1
|
|
|
|
STA IOB_BUFL
|
|
|
|
LDA #>]1
|
|
|
|
STA IOB_BUFH
|
|
|
|
<<<
|
|
|
|
*
|
|
|
|
*``````````````````````````````*
|
2018-12-24 08:14:04 +00:00
|
|
|
* DRWTS : EXECUTE RWTS ROUTINE *
|
2018-11-17 02:47:02 +00:00
|
|
|
*- -*
|
|
|
|
* RUNS THE RWTS ROUTINE AFTER *
|
|
|
|
* THE APPROPRIATE VARIABLES IN *
|
|
|
|
* THE IOB TABLE ARE SET. *
|
|
|
|
*- -*
|
|
|
|
* SAMPLE USAGE: *
|
2018-12-24 08:14:04 +00:00
|
|
|
* RWTS *
|
2018-11-17 02:47:02 +00:00
|
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
|
|
*
|
2018-12-24 08:14:04 +00:00
|
|
|
DRWTS MAC
|
2018-11-17 02:47:02 +00:00
|
|
|
*
|
|
|
|
JSR DISKOP
|
|
|
|
<<<
|