incdir _include: include sys.i ProgStart: bsr.w Opendos lea filename(pc),a0 bsr.b TypeFile bsr.w Closedos rts ;/* [TypeFile] ***************************************************************/ ; ; This function displays a textfile of any length to the active console screen ; regardless of memory available.. It uses buffered File IO & hence reads the ; file in 1/2 k blocks, displays the block, then re-uses that memory.. All this ; is handled by 'FRead' function in the DOS of OS2.x+... While reading hold ; down CTRL+C and the showing will be aborted and '***Break' will be shown... ; ; Warning! This routine *REQUIRES* at least 512 bytes of free stack overwise ; it wil crash!! This however is not much since the default stack on startup ; of a process is 4096 bytes! The 512 bytes are used as the read buffer.. ; ; $Inputs: a0.l = ptr to filename ; $Outputs: d0.l = success = 0 ; open failed = 1 ; read error = 2 TypeFile: link a5,#-512 ; Get 1k of stack memory.. lea -512(a5),a5 ;a5.l = ptr 1k of memory.. *-------------- Open file.. move.l a0,d1 ;filename move.l #MODE_OLDFILE,d2 ;open mode move.l _DOSBase,a6 ;get dosbase.. CALL Open ;open file move.l d0,d6 ;save fh beq.s FileErr ;open error result? *-------------- Main loop.. showloop: move.l d6,d1 ;fh move.l a5,d2 ;buffer moveq #1,d3 ;blocksize move.l #512,d4 ;1 block CALL FRead ;read 1k of blocks.. tst.l d0 beq.s EOF *-------------- send file blocks to screen.. move.l Output(pc),d1 ;d1.l = output move.l a5,d2 ;d2.l = buffer ptr move.l d0,d3 CALL Write *-------------- if CTRL+C break requested abort.. bsr.s CheckBreak bne.s showloop *-------------- Show file show aborted... lea break.txt(pc),a0 move.l Output(pc),d1 ;d1.l = output move.l a0,d2 moveq #11,d3 CALL Write *-------------- Close the file if End_Of_File Reached.. EOF: move.l d6,d1 ;fh CALL Close ;Close File FileErr: lea 512(a5),a5 ; free our stack memory.. unlk a5 rts ;/* [CheckBreak] *************************************************************/ CheckBreak: moveq #0,d0 moveq #0,d1 bset.l #SIGBREAKB_CTRL_C,d1 ;check for CTRL_C CALL CheckSignal,_DOSBase ;did user signal a break?? btst.l #SIGBREAKB_CTRL_C,d0 beq.s NoBreak WasBroken: moveq #0,d0 ;yes.. user tried to break.. rts NoBreak: moveq #1,d0 ;no break rts break.txt: dc.b LF,"***Break",LF,LF,0 even Opendos: move.l 4.w,a6 lea DosName(pc),a1 jsr -408(a6) move.l d0,_DOSBase beq.s no_dos move.l d0,a6 CALL Output ;get output base move.l d0,Output no_dos: rts Closedos: move.l 4.w,a6 move.l _DOSBase(pc),a1 jmp -414(a6) DosName: dc.b 'dos.library',0 even _DOSBase: dc.l 0 Output: dc.l 0 filename: dc.b 'BBS:BBSTexts/BBSTitle.txt',0 even end