; ; SuperBasic extension written in assembler. ; Purpose : List file to screen. Similar to MS Dos TYPE command. ; Syntax : TYPE devn_filename ; OUT FLP1_TYPE BV_BFBAS EQU $00 basic buffer BV_NTBAS EQU $18 basic name table base BV_NLBAS EQU $20 basic name list base BV_BRK EQU $8F break pressed flag MOVE.W BP_INIT,A0 link in basic procedure TYPE LEA.L PROCS(PC),A1 pointer to parameters JSR (A0) do it RTS back to SuperBasic PROCS DC.W 1 one procedure DC.W TYPE-* relative location DC.B 4,'TYPE' name length and ascii of name DC.W 0 no functions DC.W 0 DC.W 0 ; MAIN program TYPE MOVE.L A5,D0 subtract a3 from a5 SUB.L A3,D0 if zero then TST.L D0 no parameter was given BEQ BAD_PAR must be at least one parameter GETNAM MOVE.W 2(A6,A3.L),D0 get position in name table LSL.W #3,D0 multiply by entry size (8 bytes) ADD.L BV_NTBAS(A6),D0 d0 -> name entry in name table MOVE.W 2(A6,D0.L),A1 offset into name list ADDA.L BV_NLBAS(A6),A1 a1 -> name CLR.L D1 put zero in d1 MOVE.B 0(A6,A1.L),D1 get strlen for string copy BSR WRITE write name to screen ENDE MOVE.L #0,D0 clear d0 before EREX RTS return to SuperBasic BAD_PAR MOVEQ #-15,D0 signal bad parameter RTS return to SuperBasic ; SUBROUTINE to put filename in Basic buffer, open file and print to scr WRITE MOVE.L D1,D2 nr of chars to write SUB.B #1,D1 decrement by one for loop MOVE.L BV_BFBAS(A6),A2 get pointer to basicbuffer MOVE.W D2,(A6,A2.L) put in strlen in QDos format ADDA.L #2,A2 and then the ascii itself COPYSTR MOVE.B 1(A6,A1.L),(A6,A2.L) copy ascii of name to buffer ADDA.W #1,A2 increment buffer pointer ADDA.W #1,A1 increment pointer to string DBF D1,COPYSTR copy next char MOVEQ #IO_OPEN,D0 open file trap MOVEQ #0,D3 open old exclusive MOVEQ #0,D1 owner = this job (basic) MOVE.L BV_BFBAS(A6),A0 get address of channel name TRAP #4 add a6 to a0 TRAP #2 do it TST.L D0 error? BNE ERMES if so exit MOVE.L A0,A5 save input channel-id MOVE.W UT_SCR,A2 open window vector call LEA.L PBLOCK(PC),A1 get parameter block JSR (A2) do open scr_ BNE ERMES MOVE.L A0,A4 save output channel-id WRTFIL MOVE.L A5,A0 retrieve input channel-id MOVEQ #IO_FSTRG,D0 get string trap MOVEQ #100,D2 length of buffer MOVEQ #-1,D3 no timeout MOVE.L BV_BFBAS(A6),A1 base of buffer (a6 relative) TRAP #4 add a6 to a1 TRAP #3 read data from file MOVE.L D0,D7 save error code on stack MOVE.W D1,D2 nr of bytes to send MOVEQ #IO_SSTRG,D0 send string trap MOVEQ #-1,D3 infinite timeout MOVE.L BV_BFBAS(A6),A1 get pointer to basicbuffer MOVE.L A4,A0 get output channel-nr TRAP #4 add a6 to a1 TRAP #3 write name to screen TST.L D0 error? BNE CLOSE if so, exit CLR.L D0 MOVE.L D7,D0 retrieve error code TST.L D0 error? BNE CLOSE if so, close file and exit BRA WRTFIL next read from file CLOSE MOVE.L A5,A0 retrieve file channel-id MOVEQ #IO_CLOSE,D0 close file TRAP #2 do it MOVEQ #IO_CLOSE,D0 close file MOVE.L A4,A0 retrieve con_ channel-id TRAP #2 do it RTS return from write-subroutine ERMES MOVE.W UT_ERR0,A4 write errormessage to #0 JSR (A4) do it RTS return from subroutine ; DATA SECTION PBLOCK DC.B 255 border color DC.B 1 border width DC.B 0 paper/strip color DC.B 7 ink color DC.W 497 window width DC.W 172 window height DC.W 9 x-coordinate DC.W 20 y-coordinate END