;
;
; CLIB - A COLLECTION OF MACROS & DEFINITIONS USED IN ICRT AND OTHER THINGS.
;
; ________________________________________________________________
; DONALD E. KILLEN VERSION 2.02 JAN 21, 1981 |
; -- FOR THE Z80 ONLY -- PREF. MACRO-80 |
; ________________________________________________________________
;
.Z80
;
TRUE EQU 0FFFFH ; DEFINE VALUE OF .TRUE. FOR THOSE WHO NEED IT.
FALSE EQU NOT TRUE
;
MSIZE EQU 55 ; DECIMAL KBYTES ... REQUIRED FOR SGEN.
;
;
;
; ASCII VALUES DEFINED:
;
BS EQU 08H ; BACKSPACE
LF EQU 0AH ; LINE FEED
CR EQU 0DH ; CARRIAGE RETURN
;
DEL EQU 7FH ; => DELETE CHAR. (KEY R1)
ENQ EQU 05H ; => PHYSICAL END LINE
NAK EQU 15H ; => DELETE LINE
ETX EQU 03H ; => CODE + C => WARM BOOT
SUB EQU 1AH ; => CODE + Z => END INPUT ED & PIP
DLE EQU 10H ; => CODE + P => TOGGLE COPY TO PRINTER
DC3 EQU 13H ; => CODE + S => START/STOP CONSOLE OUTPUT
TAB EQU 09H ; = (HORIZ) TAB KEY.
CODEZ EQU 1AH ; => CODE + Z SEE ABOVE
CODES EQU 13H ; => CODE + S SEE ABOVE
ACCENT EQU 60H ; => ` => ACCENT MARK
TILDE EQU 7EH ; => ~ => TILDE
UPAROW EQU 5EH ; => ^ => UP ARROW
LBRAK EQU 5BH ; => [ => LEFT BRACKET
RBRAK EQU 5DH ; => ] => RIGHT BRACKET
BSLASH EQU 5CH ; => \ => BACK SLASH
LOGOR EQU 7CH ; => | => LOGICAL INCLUSIVE OR
LBRACE EQU 7BH ; => { => LEFT BRACE (CODE + LN PAREN.)
RBRACE EQU 7DH ; => } => RIGHT BRACE (CODE + R. PAREN.)
CODEX EQU 18H ; => CODE + X => DELETE LINE
CODEP EQU 10H ; => CODE + P => TOGGLE COPY TO PRINTER
NULL EQU 00H ; NULL - SHOULD NEVER BE ENCOUNTERED.
;
;
; ICRT DEFINITIONS & SUCHLIKE
;
VT EQU 0BH ; VERTICAL TAB
HT EQU 09H ; HORIZONTAL TAB
ESC EQU 1BH ; ESCAPE CODE
ICH EQU 40H ; INSERT CHARACTER
CUU EQU 41H ; CURSOR UP
CUD EQU 42H ; CURSOR DOWN
CUF EQU 43H ; CURSOR FORWARD
CUB EQU 44H ; CURSOR BACKWARDS
CNL EQU 45H ; CURSOR NEXT LINE
CPL EQU 46H ; CURSOR PRECEDING LINE
CHA EQU 47H ; CURSOR HORIZONTAL ABSOLUTE
CUP EQU 48H ; CURSOR POSITION
CHT EQU 49H ; CURSOR HORIZONTAL TAB
ED EQU 4AH ; ERASE IN DISPLAY
EL EQU 4BH ; ERASE IN LINE
IL EQU 4CH ; INSERT LINE
DL EQU 4DH ; DELETE LINE
DCH EQU 50H ; DELETE CHARACTER
SU EQU 53H ; SCROLL UP
SD EQU 54H ; SCROLL DOWN
CTC EQU 57H ; CURSOR TAB CONTROL
CVT EQU 59H ; CURSOR VERTICAL TAB
CBT EQU 5AH ; CURSOR BACKWARDS TAB
CVA EQU 5BH ; CURSOR VERTICAL ABSOLUTE
SGR EQU 6DH ; SELECT GRAPHIC RENDITION
;
;
; VB3 ATTRIBUTE DEFINITIONS:
;
NORMAL EQU 3 ; NORMAL ATTRIBUTE
REVERSE EQU 4 ; BLACK ON WHITE
BLANK EQU 8 ; NOTHING..
UNDERLINE EQU 16 ; ___ EVERYTHING
BLINK EQU 32 ; BLINK THE CHAR.
STRIKE$THRU EQU 64 ; / THROUGH THE CHAR.
REDUCE EQU 128 ; GREY ZONE.
;
;*** 80X33.LIB -- 80 COLUMNS BY 33 ROWS, TV STANDARDS
;
;*** HARDWARE CONFIGURATION
;
; 16 MHZ DOT CLOCK
; 9 DOTS PER CHARACTER
; 80 CHARACTER PROMS (STANDARD OR WHATEVER -- )
;
;*** DEFINE THE EQUATES NEEDED FOR THE VB3 BOARD:
;
VIDEOX EQU 0E000H ;RELATIVE ADDRESS OF THE VIDEO MEMORY
OFFSET EQU 01000H ;RELATIVE OFFSET TO THE ATTRIBUTE
VTAC EQU 0D0H ;I/O ADDRESS OF THE (VTAC) VIDEO CONTROLLER
KSTAT EQU 0E0H ;KEYBOARD STATUS / VB3 BOARD DISABLE PORT
KDATA EQU 0E1H ;KEYBOARD DATA / VB3 BOARD ENABLE PORT
;
NCOLS EQU 80 ;DEFINE SCREEN WIDTH
CODE EQU 5 ; THE 'CODE' FOR 80 COLUMNS...
NROWS EQU 33 ;DEFINE SCREEN HEIGTH (NO. LINES)
SKEW EQU 0 ;NO SKEW BELEIVED REQUIRED --
SCANF EQU 525 ;SCANS PER FRAME (RASTER)
SCANR EQU 15 ;SCANS PER DATA ROW (LINE)
HCOUNT EQU 113 ;CHARACTER TIMES IN ONE HORIZ. SCAN LINE --
CRT5027 EQU FALSE
CRT5037 EQU TRUE ;THIS IS THE TYPE OF VTAC USED --
INTERLACED EQU TRUE ;WE ARE INTERLACING -----
;
;
PUSHALL MACRO ;PUSH EVERYTHING IN THE PLACE ONTO THE STACK.
PUSH AF
PUSH HL
PUSH DE
PUSH BC
ENDM
;
POPALL MACRO ;LIKEWISE, POP EVERYTHING FROM THE STACK.
POP BC
POP DE
POP HL
POP AF
ENDM
;
; SWIN OLD,NEW
;
; SWAP OUT WORLD, STORE STACK POINTER AT PLACCE 'OLD',
; GET NEW ONE FROM 'NEW', STORE REGISTERS:
;
SWIN MACRO OLD,NEW
LD (OLD),SP ; SAVE CALLER'S POINTER
LD SP,(NEW) ; GET NEW POINTER
PUSH AF
PUSH HL
PUSH DE
PUSH BC
ENDM
;
; SWOT OLD,NEW
;
; SWAP WORLD BACK - REVERSE OF SWIN.
;
SWOT MACRO OLD2,NEW2
POP BC
POP DE
POP HL
POP AF
LD (NEW2),SP ; SAVE THIS PROGRAM'S POINTER
LD SP,(OLD2) ; GET THE CALLING POINTER
ENDM
;
;
; STORE CURRENT SP, GET CALLING PROGRAM'S SP --
; PREPARATORY TO CALLING A PROGRAM KNOWN TO REQUIRE ITS
; OWN STACK, SUCH AS CP/M OR CBIOS.
;
; SPOT => PRIOR TO CALL, STORE OLD, GET NEW:
;
; SPOT OLDSP,TEMPNEWSP
;
; SPIN => FOLLOWING THE CALL, INVERSE:
;
; SPIN OLDSP,TEMPNEWSP ; RESTORES OWN SP
;
SPOT MACRO OSP,NSP
LD (NSP),SP
LD SP,(OSP)
ENDM
;
SPIN MACRO OSP,NSP
LD (OSP),SP
LD SP,(NSP) ;; & GET OWN (NEW) SP BACK.
ENDM
;
;
; STORE A REGISTER (SINGLE):
; -- IF USING ANY OTHER THAN -A-, THIS DESTROYS .
;
STORE MACRO LOC,REG
LOCAL LABA
LABA EQU 'A'
IF '®' EQ LABA
LD (LOC),A ;; STORE A.
ELSE
LD A,REG ;; DESTROYS
LD (LOC),A
ENDIF
ENDM
;
;
; **** ICRT-UNIQUE DEFINITIONS & MACROS ******
;
;
; MACRO TO DO A 16-BIT COMPARE ON THE HL REGISTER.
; - WORKS WITH: BC, DE, AF, IX, IY
;
; CMPD REGP ; COMPARES -HL- WITH -REGP-
;
CMPD MACRO REGP
LOCAL L1,L2,L3,L4,L5,L6,L7,CMPD1,CMPD2
.8080
L1 SET 'BC'
L2 SET 'DE'
L3 SET 'IX'
L4 SET 'IY'
L5 SET 'AF'
L6 SET 'PC'
L7 SET 'SP'
.Z80
;
IF '®P' EQ L1
LD A,H
CP B
JR NZ,CMPD1
LD A,L
CP C
ENDIF
;
IF '®P' EQ L2
LD A,H
CP D
JR NZ,CMPD1
LD A,L
CP E
ENDIF
;
IF '®P' EQ L3
PUSH BC
PUSH IX ;; PUT IX IN BC
POP BC
LD A,H
CP B
JR NZ,CMPD2 ;; MUST POP BC
LD A,L
CP C
JR CMPD2 ;; MUST POP BC
ENDIF
;
IF '®P' EQ L4
PUSH BC
PUSH IY
POP BC
LD A,H
CP B
JR NZ,CMPD2 ;; MUST POP BC
LD A,L
CP C
JR CMPD2 ;; MUST POP BC
ENDIF
;
IF '®P' EQ L5
PUSH BC
PUSH AF
POP BC ;; PUT AF IN BC
LD A,H
CP B
JR NZ,CMPD2 ;; MUST POP BC
LD A,L
CP C
JR CMPD2 ;; MUST POP BC
ENDIF
;
IF '®P' EQ L6
PUSH BC ;; DOING PC, SAVE BC
CALL ZZZZ
LD A,H
CP B
JR NZ,CMPD2
LD A,L
CP C
JR CMPD2 ;; MUST RESTORE BC
;
ZZZZ: POP BC ;; GET PC FROM STACK TO BC.
PUSH BC ;; PUT IT BACK GOING TO
RET ;; RETURN...
;
;
ENDIF
;
IF '®P' EQ L7
PUSH BC
PUSH SP
POP BC
LD A,H
CP B
JR NZ,CMPD2
LD A,L
CP B
JR CMPD2 ;; SAVE BC BEFORE EXITING
ENDIF
;
IF '®P' NE L1 AND '®P' NE L2
CMPD2: POP BC ;; RESTORE BC
ENDIF
CMPD1:
ENDM
;
; MXI REGP,ROW,COL ; SETS THE 16-BIT REGISTER TO THE
; ; VALUE ROW*256 + COL.
; ; CAN NE USED WITH ANY LOADABLE PAIR.
;
MXI MACRO REGP,ROW,COL
LOCAL X,Y,Z
.8080
X SET ROW
Y SET COL
Z SET (X * 256 + Y) AND 0FFFFH
.Z80
LD REGP,Z
ENDM
;
;
; CIJR: COMPARE (A) IMMEDIATE, AND DO A CONDITIONAL RELATIVE JUMP:
;
; CIJR DATA,CONDITION,LOCATION
;
; GENERATES:
;
; CP DATA
; JP CONDITION,LOCATION
; NOTE: NO TEST IS MADE FOR OUT-OF-RANGE CONDITIONAL JUMP.
; ____
;
CIJR MACRO DATA,COND,PLACE
CP DATA
JP COND,PLACE
ENDM
;
; DOIT: A MACRO TO PERFORM LOTS OF OTHERWISE REDUNDANT CODE IN ICRT,
; AND MAKE SOME TESTS AND CALL AN OPTIONAL ROUTINE.
;
; DOIT VALUE,CONDITION,ROUTINE
;
DOIT MACRO VALUE,COND,ROUT
LOCAL XX
LD A,VALUE
CALL GET1P ;; THIS IS AN ICRT SUBROUTINE.
RET COND
LD B,A
XX: PUSH BC
CALL ROUT
POP BC
DJNZ XX
RET
ENDM
;
;
; DOSP: A SPECIAL-PURPOSE MACRO TO SUPPORT ICRT:
;
DOSP MACRO V1,C1,R1,R2,H2,L2,REG
LOCAL XX1,XX2,Y,Z
.8080
Y SET NORMAL
Z SET ' '
.Z80
;
LD A,V1
CALL GET1P
JP C1,R1 ; CONDITIONAL JUMP TO ROUTINE R1.
PUSH HL
CP 1
JR NZ,XX1
EX DE,HL
LD H,H2 ; VALUE GOES IN REG. H
LD L,L2 ; VALUE GOES IN REG. L
MXI BC,Y,Z
CALL FILLS
JR XX2
XX1: CP 2
JR NZ,XX2
LD REG,0 ; LOAD ZERO IN SPECIFIED REGISTER.
CALL R2 ; CALL ROUTINE R2.
XX2: POP HL
RET
ENDM
;
; WCTC: THIS MACRO SUPPORTS ICRT SUBROUTINES CTC0...CTC6.
;
; 'OPT' IS A BINARY QUANTUM AND MAY BE NULL OR ANY CHAR(S).
;
WCTC MACRO NAM,QUAN,OPT
;
IFNB
LD L,H
ENDIF
;
LD H,0
LD DE,NAM
ADD HL,DE
LD (HL),QUAN
RET
;
ENDM
;
; GGP: THIS MACRO EXPANDS TO:
;
; LD A,QUAN
; CALL GET1P
;
; PLUS RET COND ; DO A CONDITIONAL RETURN IF THE CONDITION
; IS SPECIFIED IN THE MACRO CALL. IF IT IS NULL,
; DO NOT PERFORM THE RETURN.
;
;
GGP MACRO QUAN2,COND2
LD A,QUAN2
CALL GET1P
;
IFNB
RET COND2
ENDIF
;
ENDM
;
; MAPX: GENERATES A TABLE OF VIDEO LOCATIONS BASED
;
; ON VIDEOX, NCOLS, & NROWS
;
MAPX MACRO
LOCAL I,J
.8080
J SET (NCOLS + 15) AND 0FFF0H
I SET 0
;
REPT NROWS
DW VIDEOX + J * I
I SET I + 1
ENDM
;
ENDM
.Z80
;
;
;
;
;
;