;======================================================================= ; ; ; H P V I D ; ; VLIB4D+ Video Graphics Full Screen Version of ; A Programmers Integer RPN Calculator ; ; by ; Terry Hazen ; 21460 Bear Creek Road ; Los Gatos, CA 95030 ; ; Voice.......... (408) 354-7188 ; Zee-Machine.... (408) 245-1420 ; Ladera Znode... (213) 670-9465 ; ; ;======================================================================= ; ; Revision History ; ---------------- ; ; 02/08/91 Initial release. ; v1.0 - Terry Hazen ; ;======================================================================= ; ; This file is an overlay for HP14.COM. Assemble and link it to a HEX ; file: ; ; Z80ASM HPVID/M;SLRNKP HPVID/H,/A:100/J,HPVID,/E ; ; and use MLOAD to overlay it on HP14.COM (Type 3 at 100h): ; ; MLOAD HPVID=HP14.COM,HPVID.HEX ; ;======================================================================= ; ; System equates ; OFF EQU 0 ON EQU 0FFH NO EQU 0 YES EQU NOT NO ; ; Version ; VERS EQU 10 ; Version number MONTH EQU 02 ; Revision month DAY EQU 08 ; ...day YEAR EQU 91 ; ...year ; ; System addresses ; BDOS EQU 0005H ; BDOS entry address ; ; ASCII values ; BELL EQU 7 ; Ring console bell BS EQU 8 ; Back space TAB EQU 9 ; Tab over CR EQU 13 ; Carriage return ESC EQU 1BH ; Escape SPACE EQU 32 ; Space ; CTRLC EQU 'C'-040H ; Quit program execution CTRLX EQU 'X'-040H ; Clear stack ; ; Calculator box equates ; TCOL EQU 20 ; Start at column 20 TLINE EQU 2 ; Second line BOXWID EQU 36 ; Width of boxes ;======================================================================= .REQUEST VLIB,Z3LIB,SYSLIB ; VLIB4D+ routines EXT Z3VINIT,CLS EXT VPRINT,VPSTR,GXYMSG EXT AT,@GOXY,TINIT,DINIT ; VLIB line graphics routines EXT DRBOX,CUROFF,CURON,GRXOFF,GRXON EXT @GHL,@GRTI,@GLTI ; SYSLIB routines EXT COUT,CIN ;======================================================================= ; ; Addresses in HP14.COM ; noenter equ 017ah chkran equ 01ach range equ 01cdh delast equ 01ebh modck equ 02f0h sethex equ 0303h setdec equ 0312h setbin equ 0321h setchr equ 0326h mdset equ 032dh mset1 equ mdset+7 mult equ 03a3h prsbuf equ 03fdh zspace equ 0401h decin equ 0442h chrin equ 0478h initb equ 0482h dispb equ 048bh chrout equ 04f3h type equ 051eh initix equ 052ah cdisp equ 0533h print equ 0536h getkey equ 053fh movhex equ 0560h done equ 05d9h srx equ 05ddh sry equ 05dfh wpntr equ 05f8h hpend equ 05fah ENTRY: JP ZSTART DB 'Z3ENV' ; ZCPR3 Utility DB 1 ; Type 1 Z3EADR: DW 0 ; Z3ENV address provided by ZCPR33+ ; org entry-100h+noenter+10 LD HL,DDIG8 ; org entry-100h+chkran CALL CHKRANGE NOP ; org entry-100h+range+2 LD HL,DDIG1 ; org entry-100h+range+16 LD (DDIG1),A ; org entry-100h+delast LD HL,DDIG2 LD DE,DDIG1 ; org entry-100h+delast+13 LD (DDIG8),A ; org entry-100h+modck CALL MODECK NOP ; org entry-100h+sethex JP HEXSET ; org entry-100h+setdec JP DECSET ; org entry-100h+setbin JP BINSET ; org entry-100h+setchr JP CHRSET ; org entry-100h+mdset JP MODESET ; org entry-100h+prsbuf LD HL,DDIG8 ; org entry-100h+zspace JP ZEROSPACE ; org entry-100h+decin JP INDEC ; org entry-100h+initb LD HL,DDIG8 ; org entry-100h+type CALL COUT JP entry-100h+initix ; org entry-100h+cdisp JP CALCDISP ; org entry-100h+print JP VPSTR ; org entry-100h+getkey CALL CURENT JP entry-100h+getkey+8 ; org entry-100h+movhex ; ; Test for character mode ; CHKRANGE: EXX LD HL,MODE BIT 0,(HL) EXX RET ;----------------------------------------------------------------------- ; ; Test for character mode ; MODECK: EXX LD HL,MODE BIT 0,(HL) EXX RET ; org entry-100h+done JP ZEXIT ; org entry-100h+hpend ;======================================================================= ; ; Local routines ;----------------------------------------------------------------------- ; ; Set hex mode ; HEXSET: LD DE,3 ; Number of digits allowed - 1 LD HL,HMODE JR MODESET ;----------------------------------------------------------------------- ; ; Set decimal mode ; DECSET: LD DE,4 ; Number of digits allowed - 1 LD HL,DMODE JR MODESET ;----------------------------------------------------------------------- ; ; Set binary mode ; BINSET: LD DE,7 ; Number of digits allowed - 1 LD HL,BMODE JR MODESET ;----------------------------------------------------------------------- ; ; Set character mode ; CHRSET: LD HL,entry-100h+chrin; Point to character mode routines LD DE,entry-100h+chrout; and fall thru to MODESET EXX LD HL,CMODE ;----------------------------------------------------------------------- ; ; Set mode by modifying jump or call destinations to point to the mode ; routines for the newly specified calculator mode. ; MODESET:LD (entry-100h+range),DE ; Set number of allowable digits-1 LD DE,MODE ; Move mode message to display LD BC,MODELEN LDIR EXX ; PUSH HL LD HL,MODE-2 ; Display new mode CALL @XYMSG POP HL JP entry-100h+mset1 ;----------------------------------------------------------------------- ; ; Zero display buffer ; ZEROSPACE: LD B,8 ; Buffer length ; ZLOOP: LD A,(HL) ; Get character CP SPACE ; Space? JR NZ,NOTSPACE ; No, we're at the highest digit ; LD (HL),'0' ; Space, so store a zero INC HL ; Point to next character DJNZ ZEROSPACE ; And continue ; NOTSPACE: JP entry-100h+zspace+13 ;----------------------------------------------------------------------- ; ; Decimal input routine, result in HL. ; INDEC: LD B,5 ; Length of buffer ; DECIN0: PUSH BC LD A,(HL) ; Get digit ; ; Multiply DE by 10 ; MUL10: SUB '0' ; Convert to binary PUSH AF ; Save value PUSH HL ; Save HL LD HL,10 CALL entry-100h+mult ; DE*10 EX DE,HL ; Result in DE POP HL ; Restore HL POP AF ; Restore value ; ADD A,E ; A=A+E LD E,A LD A,D ; Add to D if necessary ADC A,0 LD D,A ; INC HL ; Point to next digit POP BC DJNZ DECIN0 ; EX DE,HL ; Put value in HL RET ;----------------------------------------------------------------------- ; ; Position cursor and get next command ; CURENT: CALL AT DB TLINE+19,TCOL+26 JP CIN ;----------------------------------------------------------------------- ; ; CALCDISP ; ; Description: ; Display register panel ; CALCDISP: LD HL,entry-100h+sry; Point to start of registers LD DE,REGY ; Point to start of displays LD B,11 ; Number of registers ; DISPF: PUSH HL ; Save register pointer PUSH DE ; Save display pointer PUSH BC ; Save register count LD (entry-100h+wpntr),DE ; Save buffer pointer LD A,(HL) INC HL LD H,(HL) LD L,A ; HL=(register) CALL entry-100h+dispb; Convert HL to ASCII in buffer POP BC ; Restore register count POP HL ; Restore display pointer LD DE,DISPOFF ADD HL,DE ; Point to next display EX DE,HL POP HL ; Restore register pointer INC HL ; Point to next register INC HL DJNZ DISPF ; DISP0: LD HL,DISPLAY ; Point to display JP DPANEL ;----------------------------------------------------------------------- ; ; Do ZCPR3 initialization ; ZSTART: LD (STACK),SP ; Use our stack LD SP,STACK ; LD HL,(Z3EADR) ; Point to environment CALL Z3VINIT ; Initialize environment CALL TINIT ; Initialize terminal CALL CLS ; Start with clear screen CALL BOX ; Draw box JP entry-100h+noenter-3 ;----------------------------------------------------------------------- ; ; Draw calculator box and display calculator messages ; BOX: CALL CUROFF CALL DRBOX DB TLINE,TCOL,5,BOXWID ; CALL DRBOX DB TLINE+5,TCOL,8,BOXWID CALL AT DB TLINE+7,TCOL CALL DRHOR ; CALL DRBOX DB TLINE+13,TCOL,8,BOXWID CALL AT DB TLINE+15,TCOL CALL DRHOR ; LD HL,SCREEN ; Point to screen panel and fall thru ;----------------------------------------------------------------------- ; ; Screen display subroutine ; ; Entry with HL=pointer to screen table ; DPANEL: CALL CUROFF ; Turn off cursor LD B,(HL) ; Get number of messages INC HL ; Point to first message ; DLOOP: CALL @XYMSG ; Position cursor and display message DJNZ DLOOP ; Repeat for all messages JP CURON ; Restore cursor ;----------------------------------------------------------------------- ; ; Position cursor and display trailing message string, where ; HL=row,col,'msg',0 ; @XYMSG: CALL @GOXY ; Position cursor JP VPSTR ;----------------------------------------------------------------------- ; ; Horizontal line starting at current cursor positon, with intersections ; DRHOR: CALL GRXON LD A,(@GLTI) CALL COUT LD B,34 CALL GHLN LD A,(@GRTI) CALL COUT JP GRXOFF ; GHLN: LD A,(@GHL) ; Horizontal line character ; GHLN0: CALL COUT ; Draw actual line DJNZ GHLN0 RET ;----------------------------------------------------------------------- ; ; Set up for exit ; ZEXIT: CALL AT ; Position cursor for exit DB 23,1 CALL DINIT ; Deinitialize terminal ; LD SP,(STACK) ; Restore system stack pointer RET ;----------------------------------------------------------------------- ; ; Display calculator box panel ; SCREEN: DB 17 ; Number of messages DB TLINE+01,TCOL+15,'- H P -',0 DB TLINE+02,TCOL+01,'Programmers Integer RPN Calculator',0 DB TLINE+03,TCOL+01,1,' + - * / RR ^ & | ~ L = < > Sn Rn ',2,0 DB TLINE+06,TCOL+11,'Memory Registers',0 DB TLINE+08,TCOL+02,'0>',1,' ',2,0 DB TLINE+08,TCOL+19,'4>',1,' ',2,0 DB TLINE+09,TCOL+02,'1>',1,' ',2,0 DB TLINE+09,TCOL+19,'5>',1,' ',2,0 DB TLINE+10,TCOL+02,'2>',1,' ',2,0 DB TLINE+10,TCOL+19,'R>',1,' ',2,0 DB TLINE+11,TCOL+02,'3>',1,' ',2,0 DB TLINE+11,TCOL+19,'L>',1,' ',2,0 DB TLINE+14,TCOL+11,'Stack Registers',0 DB TLINE+16,TCOL+11,'T>',1,' ',2,0 DB TLINE+17,TCOL+11,'Z>',1,' ',2,0 DB TLINE+18,TCOL+11,'Y>',1,' ',2,0 DB TLINE+19,TCOL+02 ; ; Calculator mode display ; MODE: DB 'HEX: X>',0 ; Note: Check MODE using BIT x,(IX-xx). ; - Bit 0 identifies Character mode ; - Bit 2 identifies Decimal mode ; - Bit 3 identifies Hex mode ; (Binary mode 'B' has no single id bit) HMODE: DB 'HEX: ' MODELEN EQU $-HMODE DMODE: DB 'DECIMAL:' BMODE: DB 'BINARY: ' CMODE: DB 'CHAR: ' ;----------------------------------------------------------------------- ; ; Display register panel ; DISPLAY:DB 12 ; Number of registers DISP: DB TLINE+19,TCOL+14,2 DB ' ' REGX: DDIG8: DB ' ' ; Display digit 8 DDIG7: DB ' ' ; Display digit 7 DDIG6: DB ' ' ; Display digit 6 DDIG5: DB ' ' ; Display digit 5 DDIG4: DB ' ' ; Display digit 4 DDIG3: DB ' ' ; Display digit 3 DDIG2: DB ' ' ; Display digit 2 DDIG1: DB ' ' ; Display digit 1 DB 2,0 DISPOFF EQU $-DISP ; DB TLINE+18,TCOL+14,1 DB ' ' REGY: DB ' ',2,0 ; 8 digits + space ; DB TLINE+17,TCOL+14,1 DB ' ' REGZ: DB ' ',2,0 ; 8 digits + space ; DB TLINE+16,TCOL+14,1 DB ' ' REGT: DB ' ',2,0 ; 8 digits + space ; DB TLINE+11,TCOL+22,1 DB ' ' REGL: DB ' ',2,0 ; 8 digits + space ; DB TLINE+08,TCOL+05,1 DB ' ' REG0: DB ' ',2,0 ; 8 digits + space ; DB TLINE+09,TCOL+05,1 DB ' ' REG1: DB ' ',2,0 ; 8 digits + space ; DB TLINE+10,TCOL+05,1 DB ' ' REG2: DB ' ',2,0 ; 8 digits + space ; DB TLINE+11,TCOL+05,1 DB ' ' REG3: DB ' ',2,0 ; 8 digits + space ; DB TLINE+08,TCOL+22,1 DB ' ' REG4: DB ' ',2,0 ; 8 digits + space ; DB TLINE+09,TCOL+22,1 DB ' ' REG5: DB ' ',2,0 ; 8 digits + space ; DB TLINE+10,TCOL+22,1 DB ' ' REGR: DB ' ',2,0 ; 8 digits + space ;----------------------------------------------------------------------- ; ; Data area ; DSEG DS 64 ; Local stack STACK: DS 2 ; System stack pointer END