29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8.14 TRAP Filter Illustrated<br />

;TRAP/ASM - Filter <strong>to</strong> trap a single character - 07/31/83<br />

;<br />

COM ''<br />

;*=*=*<br />

; This FILTER will trap a single character<br />

; as specified by the command line entry.<br />

;<br />

; A single byte <strong>to</strong> trap can be passed in the<br />

; command line as a parameter. If not entered,<br />

; it will default <strong>to</strong> X'0E', the infamous cursor<br />

; on character which if sent <strong>to</strong> a printer, will<br />

; cause expanded character mode on a lot of dot<br />

; matrix printers if CURSOR ON is sent <strong>to</strong> *PR.<br />

;<br />

; To filter the printer output, issue:<br />

; SET *TP <strong>to</strong> TRAP (CHAR=dd)<br />

; FILTER *PR using *TP<br />

;<br />

;*=*=*<br />

LF EQU 10 ;Line feed<br />

CR EQU 13 ;Carriage return<br />

@CHNIO EQU 20<br />

@HIGH$ EQU 100<br />

@DSPLY EQU 10<br />

@FLAGS$ EQU 101<br />

@PARAM EQU 17<br />

@LOGOT EQU 12<br />

;<br />

ORG 3000H<br />

BEGIN PUSH DE<br />

POP IX ;Get DCB pointer in<strong>to</strong> IX<br />

LD (MODDCB),DE ;Stuff DCB pointer<br />

PUSH HL ;Save command line ptr<br />

LD HL,HELLO$<br />

LD A,@DSPLY ;Display hello<br />

RST 40<br />

POP HL ;Rcvr command line ptr<br />

;*=*=*<br />

; Check if entry from SET command<br />

;*=*=*<br />

LD A,@FLAGS$ ;Get flag pointer<br />

RST 40<br />

BIT 3,(IY+'C'-'A') ;System request?<br />

JP Z,VIASET<br />

LD DE,PRMTBL$ ;Point <strong>to</strong> parameter table<br />

LD A,@PARAM ;Get parms if any<br />

RST 40<br />

JR NZ,PRMERR<br />

CPARM LD BC,14 ;Init <strong>to</strong> X'0E'<br />

LD A,(CRESP) ;P/u the response<br />

OR A ; & see if any entry<br />

JR Z,CDEFLT ;Default if none<br />

BIT 7,A ;Value entry?<br />

JR NZ,CDEFLT ;Value is in reg C<br />

BIT 5,A ;String value?<br />

JP NZ,PRMERR ;Error if anything else<br />

LD A,(BC) ;BC contains a pointer<br />

LD C,A ;Shorter than a jump<br />

CDEFLT LD A,C ;Xfer the value <strong>to</strong> reg A<br />

LD (TRAPBYT+1),A ; & stuff in filter<br />

;*=*=*<br />

; install new HIGH$ and move filter code<br />

;*=*=*<br />

LD HL,0 ;Get current HIGH$<br />

LD B,L<br />

LD A,@HIGH$<br />

RST 40<br />

JR NZ,NOMEM<br />

LD (OLDHI),HL ;Put in filter header<br />

;*=*=*<br />

; Move module in<strong>to</strong> memory<br />

;*=*=*<br />

8-36

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!