80-Bus News

  

July–October 1982, Volume 1, Issue 3











Page 20 of 51











20

Note: Example 3 has used Microsoft’s MBASIC in a CP/M environment. Other versions of Basic may be used in a similar way, but the syntax may need adjusting to suit. (eg The Nascom version of Basic supports only a single USR function which is accessed ina slightly different way). The same technique may be employed in other langauges, the exact approach to take depending upon the way the language executes. If there is a poll of the keyboard inbetween statements (as in the Basic interpreter), then the machine code subroutine approach will be necessary, otherwise the direct port access (WAIT/INP etc) can be used satisfactorily.

EXAMPLE 4 – "SINGLE SHOT" OPERATION

This example is in fact an extension to example 3, and uses the ESC L and ESC U commands to provide a "single shot" operation of the light pen switch. This is done by downloading a very short program to the IVC and calling it before requesting (or after reading) the light pen coordinates. What the routine does to sit ina loop until the switch on the light pen is released, and so the switch has to be released before another pair of coordinates can be read.

Subroutine for the USER area of the IVC card.

This subroutine does nothing other than sit in a loop if the light pen switch is found to be operated.

The code will be loaded to the user area at O&400H put it is position independent anyway.

we we we we we

LPENSW EQU 4 ;Bit number of LPEN switch on status port USER: BXX :Get the alternate register set LPENW: BIT LPENSW, (HL) ;Is the switch operated?

JR Z, LPENW 3Yes, loop

EXX *No, reset registers

RET y..and return

END

3000 REM KKK EE EEE REAR ESE LEIANLA AIA ANAELIAAAREEAEOES

3001 REM Subroutine to set up a “User” command on the IVC ZOO2 REM #X#RRELERAR AREER REALE ERE RE KLARA NEE REL ER ERE LER ERE

3010 U$="" :REM Clear US$

3010 FOR I=1 to 11 :REM 11 bytes to send

3020 READ B sREM Read a byte

4030 U$S=U$+CHRS$(B) :REM Add to string

3050 NEXT I

3060 PRINT U$;"ESC U now set up" :REM Set command and say so 3070 RETURN

3080 REM “HSC” "L" 7 0 +machine code routine 3090 DATA 27,76,7,0, 217,203, 102,40, 252,217,201

Try adding the above subroutine to the code of example 3. Also include 125 GOSUB 3000

2015 PRINT CHR$(27);"U"; :REM Do ESC U. (ie Hang up until he/she lifts his/her finger).

These are only suggestions – take and develop as you see fit.


This is an OCR’d version of the scanned page and likely contains recognition errors.











Page 20 of 51