\ F21FILE.SEQ 7/20/93 \ textfiles added 11/22/94 \ Routines to Load and Save MUP21 memory area files Jeff Fox 6/6/91 \ based on Routines to save a graphics screen, by Mark Smiley v.1.2a 13July88mds comment: this routine is setup to access data from any segment. to a binary file whose name the user inputs. I suggest using the extension .F21 for F21 files and .P21 for MuP21 instruction files. This method uses file handles rather than FCBs and is quite fast. MUPSIZE is the size of the buffer comment; \ 0 CONSTANT BUF.SEG HEX ASSEMBLER ALSO POSTFIX \ CODE @DS DS PUSH NEXT C; \ : setseg @DS IS BUF.SEG ; \ I am using data in the data segment \ with an offset of the start of the array MUPMEM \ Mark used DOS allocated memory in a different segment here \ setseg \ this must be done at execution time because the seg will be \ different in different dos environments \ this can be easily converted to access allocated DOS memory or expanded memory \ SEGMENT-ADDR returns the Segment and Address of our buffer \ : SEGMENT-ADDR BUF.SEG MUPMEM ; \ NOW FOR THE SIMPLIFIED DOS ALLOCATED MEMORY ACCESS : SEGMENT-ADDR MUPSEG @ 0 ; HEX : CARRY 1 AND ; \ get carry flag from flag registers : >ASCIIZ ( addr -- addr ) Dup C@ Over 1+ + 0 Swap C! 1+ ; CODE (HOPEN) ( addr access -- handle fl | return-code fl ) AX POP 3D00 # AX ADD DX POP 21 INT AX PUSH PUSHF NEXT C; : HOPEN ( addr access -- handle flag | code flag ) SWAP >ASCIIZ SWAP (HOPEN) CARRY ; CODE (HOPEN/CREATE) ( addr -- handle fl | return-code fl ) 3C00 # AX MOV CX CX XOR DX POP 21 INT AX PUSH PUSHF NEXT C; DECIMAL comment: HOPEN access = 0 for read only 1 for write only 2 for read or write >ASCIIZ converts a packed string to a string ending in a 0 comment; HEX : HOPEN/CREATE ( addr -- handle | code ) >ASCIIZ (HOPEN/CREATE) CARRY ABORT" Unable to create or open file" ; CODE HWRITE ( seg offset handle count -- ) CX POP BX POP DX POP AX POP DS PUSH AX DS MOV 4000 # AX MOV 21 INT DS POP NEXT C; CODE HREAD ( seg offset handle count -- ) CX POP BX POP DX POP AX POP DS PUSH AX DS MOV 3F00 # AX MOV 21 INT DS POP NEXT C; DECIMAL hex CODE HCLOSE ( handle -- ) 3E00 # AX MOV BX POP 21 INT NEXT C; decimal : FILE.NAME CR ." InPut the file name and hit " CR ; : F21DIR \ f21 @ if " DIR *.F21 " \ else " DIR *.P21 " then " DIR *.?21 " BL [ HIDDEN ] "SYSCOMMAND ; : TXTDIR \ 11/22/94 " DIR *.* /P " BL [ HIDDEN ] "SYSCOMMAND ; comment: F21DIR gives a directory of all files with extension .F21 comment; : BSV SEGMENT-ADDR FILE.NAME QUERY BL WORD HOPEN/CREATE >R R@ MUPSIZE HWRITE R> HCLOSE ; : BSAVE ( -- ) CLS F21DIR BSV ; : BLD \ BLD factored out 11/22/94 SEGMENT-ADDR BEGIN FILE.NAME QUERY BL WORD 0 HOPEN ( seg 0 n f ) WHILE DROP REPEAT ( seg 0 handle ) >R R@ MUPSIZE HREAD R> HCLOSE ; : BLOAD ( -- ) CLS F21DIR BLD ; comment: BSAVE saves a F21 instruction file to disk BLOAD LOADs a F21 instruction file from disk to memory. comment; PREFIX