MACHINE CODE SUBROUTINE TO GET COORDINATES
Subroutine to request and get the coordinates of
the light pen from the IVC.
This routine is for Microsoft’s MBASIC
os we ee
MAKINT EQU 105H s;Address of MAKINT routine
Ivest QU OB2H ;IVC status register
IvepDt EQU OBIH sIVC data register
ESCAPE EQU 01 BH sAscii "ESC" code
This routine is invoked by the USR command and returns the
coordinates as an integer of the form:---
ROW*256 + COLUMN
ee we fee
LPEN: IN A, (IVcstT) 3;See if IVC ready to rec.
RRCA ;Plag to carry
JR C,LPEN sLoop if not
LD A, ESCAPE ;Send “ESC"
LPENO: IN A, (Ivest) ;Wait again
JR C, LPENO
LD A,"P" ;Now send the "P"
3 Command sent, now wait for coordinates
LPEN1: IN A, (Ivcst) ;Wait for ROW
IN A, (IvcDT) s;Read ROW
LD H,A ;Put in H
LPEN2: IN A, (1Ivcest) sWait for COL
JR C, LPEN2
IN A, (IveDT) sRead COL
LD L,A ;Put in L
PUSH HL sSave the value
LD HL, (MAKINT) sGet address of return routine
EX (SP),HL ;Reset HL (MAKINT on stack)
RET ‘ sReturn the value
EXAMPLE 3 – MBASIC
This Basic program, which is well sprinkled with REM statements, is provided as a
guide that others can follow. As it is purely for demonstration purposes the
program has been coded for clarity.
Note: In line 1020 ADDR holds the address of where the USR routine is stored.
Nascom Basic/Nas-Sys users should pick an area within the workspace RAM
(0C80H-OFFFH). GM809 users on a Nascom can use the workspace RAM as well, though in
their case it is located at OFCOOH-OFFFFH. (NB Your CP/M system size should be 63K
or less if you intend to use the workspace RAM).
Por Multiboard users the problem is slightly more complex. Either a CP/M system can
be used that is 1K less than the available memory size, or the /M option can be
used when loading MBASIC to leave an area of RAM free for the machine code program.