* ******************************** * * * -< FILEIO DEMO >- * * * * VERSION 00.02.00 * * * * 22-DEC-2018 * * * ******************************** * * * NATHAN D. RIGGS * * NATHAN.RIGGS@OUTLOOK.COM * * * ******************************** * ** ASSEMBLER DIRECTIVES * CYC AVE EXP ONLY DSK FILEIO.DEMO * OBJ $BFE0 ORG $6000 * *``````````````````````````````* * TOP INCLUDES (HOOKS,MACROS) * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * USE REQUIRED.MAC PUT REQUIRED.HOOKS * USE FILEIO.MAC PUT FILEIO.HOOKS * *``````````````````````````````* * PROGRAM MAIN BODY * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * ******************************** ******************************** * * * NOTE: FOR THIS TO WORK * * PROPERLY, THE DEMO HAS TO BE * * BLOADED, THEN EXECUTED VIA * * THE MONITOR (6000G). IF THIS * * IS NOT DONE, YOU WILL GET A * * "FILE NOT FOUND" ERROR WHEN * * DOING FILE OPERATIONS. * * * * FOR YOUR OWN PROJECTS, A WAY * * TO WORK AROUND THIS IS TO * * USE AN EXEC FILE TO BLOAD * * AND EXECUTE THE CODE. * * * ******************************** ******************************** * _PRNT " ",8D8D8D8D8D _PRNT "FILE INPUT/OUTPUT MACROS",8D _PRNT "------------------------",8D8D _PRNT "THE BSAVE MACRO SAVES THE GIVEN",8D _PRNT "ADDRESS RANGE UNDER THE SPECIFIED",8D _PRNT "BINARY FILE. THE ARGUMENT IS SIMPLY",8D _PRNT "A STRING THAT WOULD MATCH THE ARGUMENTS",8D _PRNT "OF A TYPICAL BSAVE STATEMENT IN DOS.",8D8D _PRNT "BSAVE 'TEST,A$800,L$100' SAVES THE",8D _PRNT "$100 BYTES LOCATED AT $800 IN THE FILE",8D _PRNT "TEST.",8D8D _PRNT "LET'S PUT SOMETHING INTO $300 TO",8D _PRNT "TEST IT OUT.",8D8D LDY #0 LP TYA STA $800,Y INY CPY #$100 BNE LP _WAIT _DUMP $800;#$100 _WAIT _PRNT "BSAVE 'TEST,A$800,L$100'...." BSAVE "TEST,A$800,L$100" _PRNT "DONE!",8D8D _PRNT "NOW LET'S CLEAR $100 BYTES AT",8D _PRNT "$800 BEFORE WE RELOAD IT WITH BLOAD.",8D8D LDY #0 LP2 LDA #0 STA $800,Y INY CPY #$100 BNE LP2 _DUMP $800;#$100 * _PRNT " ",8D8D _PRNT "NOW WE CAN BLOAD TEST TO GET $800",8D _PRNT "BACK INTO THE STATE WE PUT IT.",8D8D _PRNT "BLOAD 'TEST'...",8D _WAIT BLOAD "TEST" _PRNT " ",8D8D _PRNT "DONE!",8D8D _DUMP $0800;#$100 _PRNT " ",8D8D _WAIT * _PRNT "THE CMD MACRO SIMPLY EXECUTES A",8D _PRNT "DOS COMMAND, ALONG WITH ANY ARGUMENTS",8D _PRNT "PASSED TO IT. CMD 'CATALOG', FOR INSTANCE,",8D _PRNT "RETURNS:",8D8D _WAIT CMD "CATALOG" _WAIT * _PRNT " ",8D8D8D _PRNT "TYPICALLY, THE CMD MACRO IS ALSO",8D _PRNT "USED FOR PREPARING TO READ OR WRITE",8D _PRNT "TEXT FILES. HOWEVER, BEFORE THIS CAN",8D _PRNT "BE ACCOMPLISHED, THE TMODE MACRO",8D _PRNT "MUST BE RUN TO TRICK APPLESOFT INTO",8D _PRNT "BELIEVING IT ISN'T IN IMMEDIATE MODE.",8D8D _PRNT "TMODE HAS NO ARGUMENTS. THUS, THE",8D _PRNT "FOLLOWING PREPARES US TO OPEN A TEXT",8D _PRNT "FILE TO BE WRITTEN TO:",8D8D _PRNT "TMDOE",8D _PRNT "CMD 'OPEN T.TEXTFILE'",8D _PRNT "CMD 'WRITE T.TEXTFILE'",8D8D _WAIT * _PRNT "WE CAN NOW PRINT TO THIS FILE WITH",8D _PRNT "THE FPRN MACRO. THIS MACRO EITHER",8D _PRNT "PRINTS A GIVEN LINE OF TEXT TO THE FILE,",8D _PRNT "FOLLOWED BY A RETURN ($8D), OR PRINTS",8D _PRNT "THE CHARACTERS IN A STRING AT A GIVEN",8D _PRNT "ADDRESS. IN THE LATTER CASE, THE LENGTH",8D _PRNT "OF THE STRING IS NOT PRESERVED; ONLY",8D _PRNT "THE ASCII IS.",8D8D _PRNT "FPRN 'ALL IS WELL THAT ENDS WELL.'",8D _PRNT "FPRN RETORT",8D8D TMODE CMD "OPEN T.TEXTFILE" CMD "WRITE T.TEXTFILE" FPRN "ALL IS WELL THAT ENDS WELL." FPRN RETORT CMD "CLOSE T.TEXTFILE" _PRNT " ",8D8D8D _PRNT "PUTS THE LITERAL PHRASE AND A PHRASE",8D _PRNT "STORED IN THE RETORT ADDRESS INTO",8D _PRNT "THE FILE.",8D _WAIT _PRNT " ",8D8D8D _PRNT "THEN, LIKE ALWAYS, WE MUST CLOSE",8D _PRNT "THE FILE VIA CMD:",8D8D _PRNT "CMD 'CLOSE T.TEXTFILE'",8D8D8D _WAIT _PRNT "FINALLY, TO READ THIS TEXT FILE",8D _PRNT "WE SIMPLY NEED TO OPEN THE",8D _PRNT "FILE FOR READING VIA THE CMD MACRO,",8D _PRNT "THEN USE THE FINP MACRO TO READ A ",8D _PRNT "LINE OF TEXT AND STORE IT IN",8D _PRNT "MEMORY:",8D8D _PRNT "CMD 'OPEN T.TEXTFILE'",8D _PRNT "CMD 'READ T.TEXTFILE'",8D _PRNT "FINP RETURN",8D _PRNT "FINP PARAM",8D _PRNT "CMD 'CLOSE T.TEXTFILE'",8D8D CMD "OPEN T.TEXTFILE" CMD "READ T.TEXTFILE" FINP RETURN FINP PARAM CMD "CLOSE T.TEXTFILE" _WAIT _DUMP RETURN;RETURN _DUMP PARAM;PARAM _WAIT * _PRNT " ",8D8D _PRNT "THESE STRINGS ARE NOW STORED IN",8D _PRNT "[RETURN] AND [PARAM], RESPECTIVELY,",8D _PRNT "WITH A PRECEDING LENGTH BYTE. THESE",8D _PRNT "CAN BE PRINTED WITH THE SPRN MACRO",8D _PRNT "FOUND IN THE STRINGS LIBRARY.",8D8D8D _WAIT * ******************************** ******************************** ******************************** * * * W A R N I N G * * * ******************************** ******************************** ******************************** * _PRNT "********************************",8D _PRNT "********************************",8D8D _PRNT " WARNING!!!",8D8D _PRNT "********************************",8D _PRNT "********************************",8D8D _PRNT "AT THIS POINT, YOU WANT TO EJECT",8D _PRNT "THE CURRENT DISK, AND PUT IN",8D _PRNT "A DISK THAT YOU DON'T MIND ",8D _PRNT "HAVING TO REFORMAT. ",8D8D _PRNT "THE REST OF THE ROUTINES ARE",8D _PRNT "LOW LEVEL DISK ACCESS PROCEDURES,",8D _PRNT "AND CAN SERIOUSLY DAMAGE A DISK!",8D8D _PRNT "<<< PRESS A KEY ONCE YOU'RE READY >>>",8D8D _WAIT * _PRNT "LOW-LEVEL DISK ACCESS IS DONE VIA",8D _PRNT "THE STANDARD RWTS ROUTINE, WITH A",8D _PRNT "FEW MACROS THROWN IN TO MAKE IT *FEEL*",8D _PRNT "MORE SERIALIZED. THE FOLLOWING MACROS",8D _PRNT "ALTER THE RWTS ROUTINE'S BEAHVIOR:",8D8D _PRNT "SLOT : SETS THE RWTS SLOT",8D _PRNT "DRIVE: SETS THE RWTS DRIVE",8D _PRNT "TRACK: SETS THE TRACK TO BE WRITTEN/READ",8D _PRNT "SECT : SETS THE SECTOR TO BE READ/WRITTEN",8D _PRNT "SETDR: SET RWTS TO READ MODE",8D _PRNT "SETDW: SET RWTS TO WRITE MODE",8D _PRNT "DBUFF: SET THE READ/WRITE BUFFER ADDRESS",8D8D _WAIT _PRNT "EACH OF THESE SETTINGS ARE INHERITED",8D _PRNT "FROM THE PREVIOUS STATE; IF YOU ARE",8D _PRNT "ALREADY USING SECTOR 6, DRIVE 1, FOR",8D _PRNT "EXAMPLE, THEN YOU DON'T HAVE TO SET IT AGAIN",8D _PRNT "UNLESS YOU WANT THOSE SETTINGS CHANGED.",8D _PRNT "THIS LIBRARY ALSO USES THE SAME IOB",8D _PRNT "TABLE AS THE OPERATING SYSTEM (DOS OR",8D _PRNT "PRODOS) TO CARRY OVER ANY PREVIOUS SETTINGS.",8D8D _WAIT * _PRNT "ONCE THE SETTINGS ARE AS DESIRED,",8D _PRNT "YOU USE THE DRWTS MACRO TO CALL",8D _PRNT "THE RWTS ROUTINE TO MAKE THE ",8D _PRNT "APPROPRIATE READ OR WRITE CHANGE TO",8D _PRNT "THE DISK.",8D8D _PRNT "FOR THE SAKE OF PLAYING IT SAFE,",8D _PRNT "WE WON'T BE DOING THAT HERE--YOU CAN",8D _PRNT "EXPERIMENT ON YOUR OWN WITH THESE CALLS;",8D _PRNT "THAT WAY IF SOMETHING BAD HAPPENS,",8D _PRNT "IT'S ON YOU--NOT ME! :)",8D8D8D _WAIT * JMP REENTRY * *``````````````````````````````* * BOTTOM INCLUDES * *,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,* * PUT FILEIO.LIB PUT REQUIRED.LIB * RETORT STR "IF YOU ARE RICH, ANYHOW..." *