.RADIX 8
.PABS
.XLINK
.XSYM
.SALL
CONFIG=	\"Config <0/zh,3/cpml,5/trs,6/tpm>?- "
;
.IFE CONFIG,[
CALCOM=1
TRS80=0
PLT76=	PLTLOC
DISCRN=	^H0EC00
;
PARAM=	^H400
$COM=	^H100
Z80=1
RSTINT=0
BEGIN=	^H8000
PRINIT=	BEGIN+^D12
;
CHLT=	177
DISLOC=	^H0FC00
DISCLR=	DISLOC+3*3]
;
.IFE CONFIG-3,[
CALCOM=1
TRS80=0
PLT76=	^H3000
DISCRN=	^H0EC00
;
PARAM=	^H3400
$COM=	^H100
Z80=1
RSTINT=0
BEGIN=	^H1000
PRINIT=	BEGIN+^D12
;
CHLT=	177
DISLOC=	^H0FC00
DISCLR=	DISLOC+3*3]
;
.IFE CONFIG-5,[
CALCOM=0
TRS80=1
PLT76=	^H4D00
DISCRN=	^H3C00
;
PARAM=	^H7100
$COM=	^H4200
Z80=1
RSTINT=1
BEGIN=	^H5100
PRINIT=	BEGIN+^D12
CHLT=	377
;
TRSIOT=^H4500
DISCLR=	TRSIOT+3*^D7]
;
COMMON=	1
;
;****** boiler plate starts *******
	.XLIST
$$SAE=	^D1
$$SAS=	^D2
$$SWA=	^D3
$$SRB=	^D4
$$SER=	^D5
$$SLK=	^D6
$$RXQ=	^D7
$$SGT=	^D8
$$SXX=	^D9
$$RQQ=	^D10
$$SNQ=	^D11
$$SRA=	^D12
$$RVA=	^D13
$$SHK=	^D14
$$SPK=	^D15
$$SLF=	^D16
$$RNA=	^D17
$$RNH=	^D18
$$SAT=	^D19
$$SFA=	^D20
$$SDS=	^D21
$$SDD=	^D22
$$SWS=	^D23
$$SAN=	^D24
$$SFS=	^D25
$$SGV=	^D26
$$SSB=	^D27
$$SPA=	^D28
$$SRQ=	^D29
$$SPL=	^D30
$$RAC=	^D31
$$RAD=	^D32
$$RAY=	^D33
$$RAZ=	^D34
$$STO=	^D35
$$STI=	^D36
$$STL=	^D37
$$SPR=	^D38
$$SHR=	^D39
$$SG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C
.SYN JC,.JRC
.SYN JNZ,.JRNZ
.SYN JZ,.JRZ
;
.DEFINE MJSSA[FROM,TO,LNGTH]=
[	LXI	B,LNGTH
	LXI	H,FROM
	LXI	D,TO
;
	CALL	MSSA]
.DEFINE .DJNZ[ADR]=
[	DCR	B
	JNZ	ADR]
;
.DEFINE MDSBCD=
[	MOV	A,L
	SUB	E
	MOV	L,A
	MOV	A,H
	SBB	D
	MOV	H,A]
 ]
;
;
.IFG Z80,[
.SYN JMPR,.JMPR
.SYN JRNC,.JRNC
.SYN JRC,.JRC
.SYN JRNZ,.JRNZ
.SYN JRZ,.JRZ
;
.DEFINE MJSSA[FROM,TO,LNGTH]=
[	LXI	B,LNGTH
	LXI	H,FROM
	LXI	D,TO
	LDIR]
.DEFINE .DJNZ[ADR]=
[	DJNZ	ADR]
.DEFINE MDSBCD=
[	JCLA
	DSBC	D]
 ]
;
;
P=PARAM
VAR1=	P+14
BOOT=	P+15
MSCI=	P+17
MSRI=	P+22
MSCO=	P+25
MSPO=	P+30
MSLO=	P+33
mscsts=	P+36
MSCHK=	P+41
MSSET=	P+44
MSMCK=	P+47
MSBDOS=	P+52
PSEsym=	P+55
PUIsym=	P+57
PUOsym=	P+61
PULsym=	P+63
TAMsym=	P+65
POAsym=	P+67
POBsym=	P+71
POCsym=	P+73
PODsym=	P+75
PSWsym=	P+77
PSYsym=	P+101
PWAsym=	P+103
tr=	P+105
te=	P+106
RIX=	P+107
BIX=	P+110
MCH=	P+111
TCE=	P+112
CE=	P+114
INPsym=	P+116
OUTsym=	P+120
SPRW3=	P+122
LDRCNL=	P+123
LDRCNH=	P+124
RUBOT=	P+125
RUBO1=	P+126
RUBO2=	P+127
NULCH=	P+130
NULCT=	P+131
PLIN=	P+132
KYN1=	P+133
KYN2=	P+134
CWSAF=	P+135
CWSNF=	P+136
CWSEF=	P+137
CWSPF=	P+140
CWMBF=	P+141
CWMAF=	P+142
CWMNF=	P+143
CWCAS=	P+144
CWCQC=	P+145
CWUNP=	P+146
CWBP1=	P+147
CWEP1=	P+150
CWBP2=	P+151
CWEP2=	P+152
CWBMF=	P+153
CWEMF=	P+154
ENDWC=	P+155
FUTUR0=	P+156
FUTUR1=	P+157
SYN=	P+161
CPCM=	P+167
SYN1=	P+171
SYNR=	P+173
SYNR1=	P+175
CPRP=	P+177
SCEK=	P+204
S1=	P+211
S2=	P+212
S3=	P+213
DSYS1=	P+215
DSYS2=	P+217
DSYS3=	P+221
DSYS4=	P+223
DEXT=	P+225
JMP1TS=	P+230
JMP2TS=	P+231
TAEsym=	P+232
TAHsym=	P+234
TALsym=	P+236
PWR=	P+240
PAE=	P+242
PEL=	P+244
PFL=	P+246
ZERO=	P+250
EXFLG=	P+251
PG1=	P+252
PG1A=	P+253
PG2=	P+254
PG2A=	P+255
BASE=	P+256
LT=	P+257
CH=	P+261
PFI=	P+262
PFF=	P+264
PFN=	P+266
PFT=	P+270
T1=	P+272
T2=	P+274
T3=	P+276
PAL2=	P+300
PAN2=	P+302
PAL=	P+304
PAN=	P+306
PALPL=	P+310
PANPN=	P+312
T4=	P+314
T5=	P+316
T6=	P+320
T7=	P+322
T8=	P+324
T9=	P+326
ADS32=	P+330
ADS33=	P+332
RAND=	P+334
CHA1=	P+336
CHA2=	P+340
PAL21=	P+342
SMSW=	P+344
NULF=	P+345
PNF=	P+346
PNFI=	P+347
ARG1=	P+350
ARG2=	P+352
ARG3=	P+354
TM1=	P+356
MOQOV=	P+357
PCNT=	P+362
ZCNT=	P+363
IOBYT=	P+421
SAMBYT=	P+422
KTRAK=	P+423
DISK1=	P+425
DISK2=	P+427
DISK3=	P+431
DISK4=	P+433
DISK5=	P+435
DISK6=	P+437
DISK7=	P+441
CALDA=	P+443
SAMJM1=	P+446
JMP1AD=	P+447
QWSD0=	P+451
PLTNX=	P+454
PLTNY=	P+456
PLTQD=	P+460
PLTPN=	P+462
PLTCM=	P+463
PLTSX=	P+464
PLTSY=	P+465
PLTWL=	P+466
PLTWR=	P+470
PLTVM=	P+472
TM2=	P+473
TC3=	P+475
TCECT=	P+477
TCEAN=	P+501
SERFLG=	P+502
PKFLG=	P+503
RSTHLD=	P+504
USER1=	P+513
USER1A=	P+514
USER2=	P+515
USER2A=	P+516
USER3=	P+517
USER3A=	P+520
USER4=	P+521
USER4A=	P+522
REGSAV=	P+523
;[CONSTANTS]
;
N10=10
N11=11
N12=12
N13=13
N14=14
N15=15
N16=16
N17=17
N20=20
N21=21
N24=24
N30=30
N34=34
N37=37
N40=40
N50=50
N51=51
N60=60
N70=70
N74=74
N76=76
N77=77
N100=100
N110=110
N137=137
N144=144
N133=133
N135=135
N177=177
N200=200
N202=202
N277=277
N300=300
N340=340
N34=34
N377=377
N1K=1000
N1750=1750
N10K=10000
N100K=100000
N2342=23420
;
K400K=200
K500K=240
K600K=300
K700K=340
;
KABM=	K600K<N10
KABN=	K700K<N10
KABF=	K400K<N10
KACM=	K500K<N10
;
N400=400
N47=47
;
KCRLF=4215
;
;[DEU2]
;
.IFE RSTINT,[
.DEFINE JSLK=
[	RST	6]
.DEFINE JSER=
[	RST	5]
.DEFINE JSWA=
[	RST	3]
.DEFINE JSAS=
[	RST	2]
.DEFINE JSRB=
[	RST	4]
.DEFINE JSAE=
[	RST	1]
]
;
.IFG RSTINT,[
.DEFINE JSAE=
[	CALL	MSAE]
.DEFINE JSAS=
[	CALL	MSAS]
.DEFINE JSWA=
[	CALL	MSWA]
.DEFINE JSRB=
[	CALL	MSRB]
.DEFINE JSER=
[	CALL	MSER]
.DEFINE JSLK=
[	CALL	MSLK]
]
;
;
;
.IFDEF COMMON,[
MSAE=	$COM+3*$$SAE
MSAS=	$COM+3*$$SAS
MSWA=	$COM+3*$$SWA
MSRB=	$COM+3*$$SRB
MSER=	$COM+3*$$SER
MSLK=	$COM+3*$$SLK
 ]
;
;
	.LIST
;******** boiler plate ends *******
.TITLE /PLOT76/
;
.LOC	POCsym+PRINIT-VAR1
;
.WORD	PLT76
;
.LOC	PLT76
;[$PLT]
;
OUTPL=USER1
STSPL=USER1A
MSKPL=USER2
;
PLTTAB:
.T "P","L","T",PLTQQ; Plotter
;
PMSCRN:	.WORD	DISCRN
;
PLTQQ:	.BYTE	(PLTQE - PLTQB) / 4
PLTQB:
.T "P","L"," ",$174;	Plot
.T "W","I"," ",$175;	Write Initialize
.T "W","L"," ",$179;	Width Left
.T "W","R"," ",$178;	Width Right
.T "W","S"," ",$180;	Write Straight line
.T "W","X"," ",$176;	Write "X" axis total
.T "W","Y"," ",$177;	Write "Y" axis total
PLTQE:
QPLLQ:	.BYTE	(QPLLE - QPLLB) / 4
QPLLB:
.T "A","B","S",QPLAD;	Absolute Display
.IFG CALCOM,[
.T "A","S"," ",QPLAS;	Assign Ports & Mask
.T "C","A","L",QPLCAL;	Calcomp Plotter]
.IFE TRS80-1,[
.T "C","W","C",$250;	Change Warning Character]
.T "L","F"," ",QPLLF;	List Functions
.T "M","Q"," ",QPLMQ;	Modify Quadrant
.T "N","M"," ",QPLNM;	Null Mode - OUTPUT
.IFE TRS80-1,[
.T "T","R","S",QPLTRS;	TRS80 Display]
.IFE TRS80,[
.T "P","O","L",QPLPOL;	Polymorphic Display]
.T "V","M"," ",QPLVM;	Value Mode
QPLLE:
PLTQ0:	.BYTE	"D","H","A","B"
	.BYTE	"E","I","F","J"
;
	.BYTE	"B","A","D","H"
	.BYTE	"F","E","J","I"
;
	.BYTE	"H","D","B","A"
	.BYTE	"J","F","I","E"
;
	.BYTE	"A","B","H","D"
	.BYTE	"I","J","E","F"
;
	.BYTE	"D","H","B","A"
	.BYTE	"F","J","E","I"
;
	.BYTE	"A","B","D","H"
	.BYTE	"E","F","I","J"
;
	.BYTE	"H","D","A","B"
	.BYTE	"I","E","J","F"
;
	.BYTE	"B","A","H","D"
	.BYTE	"J","I","F","E"
;
;
;	-Y+X,+Y-X,-Y-X,+Y+X,+Y,+X,-Y,-X
;	DUPR,DDPL,DUPL,DDPR,DD,DR,DU,PL
;	"I","F","J","E","D","A","H","B"
;
PLTINI:	LXI	H,JMP1TS
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A:	RAR
	.JRNC	PMPLTB
	DCR	M
PMPLTB:	LXI	H,YABS
	RAR
	.JRNC	PMPLTC
	INR	M
PMPLTC:	RAR
	.JRNC	PMPLTD
	DCR	M
;
PMPLTD:	LDA	PMPEN
	TSTA
	RNZ	; test for pen
;
;
PMPLT2:	LDA	YABS
	LXI	B,KPMP1
	ANI	3
	CPI	3
	.JRZ	PMPLT4
	DCR	C
	TSTA
	.JRZ	PMPLT4
	MVI	B,KPMP2
	DCR	A
	.JRZ	PMPLT4
	MVI	B,KPMP4
PMPLT4:	PUSH	B; dot code 1/2/4 or 20/8/2
	LDA	YABS
	RRC
	RRC
	ADD	C
	ANI	17
	MOV	B,A
	MVI	A,20
	SUB	B	; origin bottom of screen
	STA	YPOS
;
	LDA	XABS
	ANI	1
	.JRNZ	PMPLT3
	POP	PSW
.IFE TRS80,[
	RLC
	RLC
	RLC]
.IFE TRS80-1,[
	RAR]
	PUSH	PSW
PMPLT3:	LDA	XABS
	RRC
	ANI	177
	STA	XPOS
;
	LDA	YPOS
	PUSH	PSW
	RRC
	RRC
	ANI	3
	MOV	B,A
	POP	PSW
	ANI	3
	RRC
	RRC
	MOV	C,A	; Y is now in BC
;
	LDA	XPOS
	ADD	C
	MOV	C,A	; X,Y are in BC
;
	LHLD	PMSCRN
	DAD	B
;
	MOV	A,M
	RAL
.IFE TRS80,[
	.JRNC	PMPLT7]
.IFE TRS80-1,[
	.JRC	PMPLT7]
	MVI	M,CHLT	; was not dots
PMPLT7:	LDA	PNF	; test for neutral
	TSTA
	MOV	A,M	; old bits
	POP	B
.IFE TRS80,[
	.JRNZ	PMPLT9]
.IFE TRS80-1,[
	.JRZ	PMPLT9]
	CMA
	ORA	B	; combine new bits
	CMA
	SKIP1
PMPLT9:	ORA	B	; remove new bits
;
.IFE TRS80-1,[
	ORI	200]
	MOV	M,A
	RET
;
;
;[CALOUT]
;
;
.IFG CALCOM,[
CALOUT:	MOV	A,C
	MOV	B,C
	ANI	N60
	.JRNZ	PLD35
;
	CALL	MSPXL
	CALL	DEL25
	MVI	B,0
	CALL	MSPXL
DEL25:	MVI	B,3
	CALL	MSDLY
	RET
;
PLD35:	CALL	MSPXL
	CALL	DEL35
	MVI	B,0
	CALL	MSPXL
DEL35:	MVI	B,43
	CALL	MSDLY
	RET
;
;
MSPXL:	LDA	OUTPL
	MOV	C,A
	OUTP	B	;Z80 only
	RET
;
;
;
MSDLY:
MSDLY1:	LDA	STSPL
MSDLY0:	DCR	A
	.JRNZ	MSDLY0
	.DJNZ	MSDLY1
	RET
]
;
;
.IFE TRS80-1,[
;[$250/CWC]
$250:	MTAB	CWSAF
$2501:	LINKC	$$SRA
	.JRC	$2502
	MOV	M,C
	INX	H
	MOV	A,M
	TSTA
	.JRZ	$2501
;
$2502:	LDA	CWSAF
	STA	SYN+1
	STA	SYN1+1
	LDA	CWSEF
	STA	CPRP+1
	STA	CPRP+3
	LDA	CWCAS
	STA	CPCM+1
	RET]
;
;

	.END
