133248cabcaf55c0a35b2ac8137ee5e569cfef24
[h316.git] / lib / hachti / src / pl$mv.asm
1 * (PL$MV) REV 1.0 INCREMENTAL PLOTTER ROUTINES
2 *
3 *
4 * PROGRAM TITLE:
5 * PL$MV (PL$MV,PL$RST,PL$LN,PL$X,PL$Y,PL$RMR)
6 *
7 * PLOTTER MOVEMENT ROUTINES
8 *
9 *
10 * REVISIONS:
11 * 1.0 (2007-05-28) - INITIAL REVISION
12 *
13 * 1.1 (2007-11-08) - ADDED INTELLIGENT LINE DRAWING ROUTINE
14 *
15 * 1.2 (2007-12-15) - ADDED PL$X and PL$Y POSITION EXPORTS
16 * ADDED PL$RMR TRANSLATIION ROUTINE
17 *
18 * 1.3 (2007-12-19) - ADDED TRANSFORMATION MATRIX SUPPORT TO PL$MV.
19 * MATRIX PL$MAT IS NOW APPLIED BEFORE
20 * ANY MOVE INSTRUCTION.
21 *
22 *
23 * AUTHOR:
24 *
25 * PHILIPP HACHTMANN
26 *
27 *
28 * PURPOSE:
29 *
30 * PROVIDE DRAWING AND COORDINATE TRANSFORMATION
31 * ROUTINES FOR INCREMENTAL PLOTTERS
32 *
33 *
34 * STORAGE:
35 *
36 * ??? (OCTAL)
37 * ??? (DECIMAL)
38 *
39 *
40 * USAGE
41 *
42 * CALL PL$RST - SET VIRTUAL PLOT POSITION TO ZERO
43 *
44 * CALL PL$MV - MOVE TO POINT SPECIFIED
45 * DAC XN BY XN
46 * DAC YN AND YN VALUE
47 * DAC 0
48 *
49 * CALL PL$LN - DRAW LINE AND LEAVE PEN DOWN
50 * DAC X1
51 * DAC Y1
52 * DAC X2
53 * DAC Y2
54 * DAC 0
55 *
56 * CALL PL$RMR - MOVE ORIGIN RELATIVELY
57 * DAC DX
58 * DAC DY
59 * DAC 0
60 *
61 * CALL PL$SCL - SCALE TRANSFORMATION
62 * DAC SCALE SCALE FACTOR, FLOAT
63 * DAC 0
64 *
65 * CALL PL$IDN - RESET TRANSFORMATION MATRIX
66 *
67 ********************************************************************************
68 *
69 SUBR PL$MV,MOVE
70 SUBR PL$X,XU
71 SUBR PL$Y,YU
72 SUBR PL$MVR,MVR
73 SUBR PL$RST,RST
74 SUBR PL$LN,LINE
75 SUBR LINE
76 SUBR PL$RMR,RMR
77 SUBR PL$MAT,ATRA
78 SUBR PL$SCL,SCLE
79 SUBR PL$SCI,SCLI
80 SUBR PL$ROT,ROT
81 SUBR PL$ROI,ROTI
82 SUBR PL$PUS,PUSH
83 SUBR PL$POP,POP
84 SUBR PL$INI,INIT
85 *
86 *
87 *
88 REL THIS IS A RELOCATABLE OBJECT
89 ORG '0
90 *
91 *
92 ********************************************************************************
93 *
94 **** PL$MVR - MOVE PEN RELATIVELY
95 *
96 MVR DAC **
97 *
98 LDA* MVR
99 STA TMPX
100 IRS MVR
101 LDA* MVR
102 STA TMPY
103 IRS MVR
104 *
105 LDA* TMPX
106 * CALL OCT
107 ADD XU
108 STA XU
109 *
110 LDA* TMPY
111 * CALL OCT
112 ADD YU
113 STA YU
114 *
115 IRS RELA SET FLAG
116 NOP
117 IRS MVR
118 JMP* MVR RETURN
119 *
120 *
121 *
122 **** PL$INI - GRAPHICS INITIALISATION
123 *
124 * THIS ROUTINE SETS THE HARDWARE ORIGIN TO THE CURRENT PlOTTER POSITION.
125 * IT ALSO INITIALISES THE TRANSFORMATION.
126 *
127 ****************************************
128 *
129 INIT DAC **
130 CRA
131 STA XU
132 STA YU
133 STA X
134 STA Y
135 STA RELA
136 CALL T$INIT
137 DAC ATRA
138 CALL PL$PU
139 JMP* INIT
140 *
141 *
142 **** PL$PUS - PUSH GRAPHIC CONTEXT ONTO THE STACK
143 *
144 PUSH DAC ** ENTRY
145 LDA* PUSH
146 STA SD1
147 IRS PUSH
148 CALL S$PUSM PUSH MEMORY ROUTINE
149 SD1 DAC **
150 DAC ATRA
151 DEC 12 12 WORDS OF DATA.
152 JMP* PUSH
153 *
154 *
155 ********************************************************************************
156 *
157 *
158 **** PL$POP - POP GRAPHIC CONTEXT FROM THE STACK
159 *
160 POP DAC ** ENTRY
161 LDA* POP
162 STA SD2
163 IRS POP
164 CALL S$POPM POP MEMORY ROUTINE
165 SD2 DAC **
166 DAC ATRA
167 DEC 12 12 WORDS OF DATA.
168 JMP* POP
169 *
170 *
171 * *******************************************************************************
172 *
173 *
174 **** PL$LN - DRAW A LINE
175 *
176 LINE DAC 0 DRAW A LINE FROM NEAREST STARTING POINT
177 LDA* LINE X1
178 STA X1P
179 IRS LINE
180 LDA* LINE Y1
181 STA Y1P
182 IRS LINE
183 LDA* LINE X2
184 STA X2P
185 IRS LINE
186 LDA* LINE Y2
187 STA Y2P
188 IRS LINE TALLY RETURN ADDRESS
189 IRS LINE AGAIN FOR FORTRAN IV COMPATIBILITY
190 *
191 CALL T$APII APPLY MATRIX
192 DAC ATRA
193 DAC X1
194 DAC Y1
195 X1P DAC **
196 Y1P DAC **
197 DAC 0
198 *
199 CALL T$APII APPLY MATRIX
200 DAC ATRA
201 DAC X2
202 DAC Y2
203 X2P DAC **
204 Y2P DAC **
205 DAC 0
206 *
207 *
208 LDA X
209 SUB X1
210 SPL SKIP IF SIGN PLUS
211 TCA TWO'S COMPLEMENT IF NEEDED
212 STA D1
213 LDA Y
214 SUB Y1
215 SPL
216 TCA
217 ADD D1
218 STA D1
219 *
220 LDA X
221 SUB X2
222 SPL SKIP IF SIGN PLUS
223 TCA TWO'S COMPLEMENT IF NEEDED
224 STA D2
225 LDA Y
226 SUB Y2
227 SPL
228 TCA
229 ADD D2
230 CAS D1
231 JMP D2BG D2 IS BIGGER!
232 NOP
233 *
234 D1BG LDA X2 DIFFERENCE 1 IS BIGGER, SO START AT POINT X2,Y2
235 STA XA
236 LDA Y2
237 STA YA
238 LDA X1
239 STA XB
240 LDA Y1
241 STA YB
242 JMP WOKI WORK!
243 *
244 D2BG LDA X1 DIFFERENCE 2 IS BIGGER, SO START AT POINT X1,Y1
245 STA XA
246 LDA Y1
247 STA YA
248 LDA X2
249 STA XB
250 LDA Y2
251 STA YB
252 *
253 WOKI LDA X TEST IF STARTING POINT IST CURRENT POSITION
254 CAS XA
255 JMP MV1
256 JMP *+2
257 JMP MV1
258 LDA Y
259 CAS YA
260 JMP MV1
261 JMP *+2
262 JMP MV1
263 JMP NM1
264 *
265 MV1 CALL PL$PU MOVE TO THE STARTING POSITION
266 LDA XA
267 STA XN
268 LDA YA
269 STA YN
270 JST RMOV REAL MOVE
271 *
272 NM1 CALL PL$PD WE ARE AT BEGINNING OF LINE
273 LDA XB
274 STA XN
275 LDA YB
276 STA YN
277 JST RMOV REAL MOVE
278 JMP* LINE END OF THE LINE :-)
279 *
280 *
281 ********************************************************************************
282 *
283 **** MAKE CURRENT X AND Y THE ORIGIN
284 *
285 RST DAC **
286 *
287 **** FIRST TRANSLATE THE CURRENT USER POSITION:
288 CALL T$TRAN
289 DAC ATRA
290 DAC XU
291 DAC YU
292 DAC 0
293 CRA
294 STA XU
295 STA YU
296 *
297 JMP* RST
298 *
299 *
300 ********************************************************************************
301 *
302 *
303 **** PL$MV - BASIC MOVE ROUTINE
304 *
305 MOVE DAC ** MOVE YA!
306 *
307 LDX MOVE GET PARAMETERS
308 LDA* 0,1 X VALUE
309 STA XU
310 STA XN
311 LDA* 1,1 Y VALUE
312 STA YU
313 STA YN
314 LDA MOVE
315 ADD =3
316 STA MOVE CORRECT RETURN ADDRESS
317 *
318 CALL T$APII APPLY TRANSFORMATION MATRIX TO POSITION
319 DAC ATRA
320 DAC XN
321 DAC YN
322 DAC XN
323 DAC YN
324 DAC 0
325 *
326 JST RMOV CALL INTO REAL MOVE SUBROUTINE
327 JMP* MOVE RETURN
328 *
329 ****************************************
330 *
331 RMOV DAC ** REAL MOVE SUBROUTINE
332 LDA XN
333 SUB X
334 STA DX
335 LDA YN
336 SUB Y
337 STA DY
338 *
339 LDA DX
340 SMI
341 JMP DXP DX POSITIVE
342 * DX NEGATIVE
343 TCA
344 STA DX NOW, DX IS POSITIVE!
345 LDA ML
346 STA STPX
347 LDA MUL
348 STA DIYP
349 LDA MDL
350 STA DIYN
351 JMP DXNP
352 DXP LDA MR
353 STA STPX
354 LDA MUR
355 STA DIYP
356 LDA MDR
357 STA DIYN
358 JMP DXNP
359 *
360 DXNP LDA DY
361 SMI
362 JMP DYP DY POSITIVE
363 * DY NEGATIVE
364 TCA
365 STA DY NOW, DY IS POSITIVE!
366 LDA MD
367 STA STPY
368 LDA DIYN
369 STA STPD
370 JMP DYNP
371 DYP LDA MU
372 STA STPY
373 LDA DIYP
374 STA STPD
375 *
376 DYNP LDA DX
377 CAS DY
378 JMP XGTY DX GREATER DY
379 YGTX NOP DY GREATER OR EQUAL DX
380 LDA STPY
381 STA STPL
382 LDA STPX
383 STA STPS
384 LDA DX
385 STA DS
386 STA DS0
387 LDA DY
388 STA DL
389 STA DL0
390 JMP GTE
391 *
392 XGTY LDA STPY
393 STA STPS
394 LDA STPX
395 STA STPL
396 LDA DX
397 STA DL
398 STA DL0
399 LDA DY
400 STA DS
401 STA DS0
402 *
403 ****************************************
404 *
405 * NOW ALL STEP ROUTINES, DL0, DS0, DL0, DS0 ETC.
406 * ARE READY TO USE.
407 *
408 GTE LDA DL0 LONG DISTANCE
409 LGR 1 DIVIDE BY TWO
410 STA ERR INITIALIZE ERROR COUNTER
411 *
412 *
413 *** MOVE LOOP
414 *
415 LOOP LDA DL LONG DISTANCE
416 SNZ
417 JMP FNSH END OF WORK - HOPE SO....
418 *
419 SUB =1 DECREMENT LONG DISTANCE
420 STA DL
421 *
422 LDA ERR ERROR COUNTER
423 SUB DS0
424 STA ERR
425 SMI SKIP IF NOT OVERFLOWN (MINUS)
426 JMP NDIA NO DIAG STEP
427 *
428 *** DIAG STEP TO DO
429 *
430 ADD DL0
431 STA ERR
432 LDA DS
433 SUB =1
434 STA DS
435 JST* STPD DO DIAGONAL STEP
436 JMP LOOP RELOOP
437 *
438 *** NO DIAGONAL STEP TO DO
439 *
440 NDIA JST* STPL DO LONG DIRECTION STEP
441 STEN JMP LOOP RELOOP
442 *
443 *
444 *** END OF LOOP
445 FNSH LDA XN
446 STA X
447 LDA YN
448 STA Y
449 JMP* RMOV END OF THE ROUTINE
450 *
451 *
452 ********************************************************************************
453 *
454 *
455 **** SCALE OUTPUT
456 *
457 SCLE DAC **
458 LDA* SCLE
459 STA FCTR
460 IRS SCLE
461 CALL T$SCLE
462 DAC ATRA
463 FCTR DAC 0
464 DAC 0
465 JMP* SCLE
466 *
467 *
468 ********************************************************************************
469 *
470 *
471 **** ROTATE - RADIANT
472 *
473 ROT DAC **
474 LDA* ROT
475 STA FCR2
476 IRS ROT
477 IRS ROT
478 CALL T$ROT
479 DAC ATRA
480 FCR2 DAC 0
481 DAC 0
482 JMP* ROT
483 *
484 *
485 ********************************************************************************
486 *
487 *
488 **** RLUP - UPDATE LATENT POSITION TO REAL POSITION
489 *
490 RLUP DAC **
491 LDA RELA LOAD FLAG
492 SNZ
493 JMP* RLUP NOTHING TO DO
494 JST MOVE
495 DAC XU
496 DAC YU
497 DAC 0
498 CRA
499 STA RELA CLEAR FLAG
500 JMP* RLUP
501 *
502 *
503 ********************************************************************************
504 *
505 *
506 **** ROTATE - INTEGER DEGREES
507 *
508 ROTI DAC **
509 LDA* ROTI
510 STA FCR3
511 IRS ROTI
512 CALL T$ROTI
513 DAC ATRA
514 FCR3 DAC 0
515 DAC 0
516 JMP* ROTI
517 *
518 *
519 ********************************************************************************
520 *
521 *
522 **** SCALE - INTEGER PERCENTS
523 *
524 SCLI DAC **
525 LDA* SCLI
526 STA FCR4
527 IRS SCLI
528 *
529 CALL T$SCLI
530 DAC ATRA
531 FCR4 DAC 0
532 DAC 0
533 JMP* SCLI
534 *
535 ********************************************************************************
536 *
537 *** MOVE COORDINATE SYSTEM RELATIVELY
538 *
539 RMR DAC **
540 LDA* RMR
541 STA XTR
542 IRS RMR
543 LDA* RMR
544 STA YTR
545 IRS RMR
546 IRS RMR
547 *
548 CALL T$TRAN
549 DAC ATRA
550 XTR DAC **
551 YTR DAC **
552 DAC 0
553 *
554 JMP* RMR
555 *
556 *
557 **********************
558 *
559 * VARIABLES
560 *
561 X DEC 0 HARDWARE VIEW PEN POSITION, X VALUE
562 Y DEC 0 HARDWARE VIEW PEN POSITION, Y VALUE
563 XN DEC 0 NEW PEN POSITION, X VALUE
564 YN DEC 0 NEW PEN POSITION, Y VALUE
565 DX DEC 0 X DIFFERENCE TO GO
566 DY DEC 0 Y DIFFERENCE TO GO
567 TMPX DEC 0 TEMPORARY X VALUE
568 TMPY DEC 0 TEMPORARY Y VALUE
569 *
570 DL0 DEC 0 INITIAL LONG DISTANCE
571 DS0 DEC 0 INITIAL SHORT DISTANCE
572 DL DEC 0 LONG DISTANCE
573 DS DEC 0 SHORT DISTANCE
574 STPL DAC ** ROUTINE TO LONG DISTANCE STEP
575 STPS DAC ** ROUTINE TO SHORT DISTANCE STEP
576 STPD DAC ** ROUTINE TO DIAGONAL STEP
577 ERR DEC 0 ERROR COUNTER
578 *
579 STPX DAC ** X STEP ROUTINE
580 STPY DAC ** Y STEP ROUTINE
581 DIYP DAC ** DIAGONAL X-DIR+UP STEP ROUTINE
582 DIYN DAC ** DIAGONAL X-DIR+DOWN STEP ROUTINE
583 *
584 X1 DEC 0 LINE START POINT, X
585 Y1 DEC 0 LINE START POINT, Y
586 X2 DEC 0 LINE END POINT, X
587 Y2 DEC 0 LINE END POINT, Y
588 *
589 XA DEC 0 REAL FIRST POINT X COORDINATE
590 YA DEC 0 REAL FIRST POINT Y COORDINATE
591 XB DEC 0 REAL SECOND POINT X COORDINATE
592 YB DEC 0 REAL SECOND POINT Y COORDINATE
593 D1 DEC 0 ORTHOGONAL WAY LENGTH FROM CURRENT POS TO P1
594 D2 DEC 0 ORTHOGONAL WAY LENGTH FROM CURRENT POS TO P2
595 RELA DEC 0 FLAG INDICATING THAT RELATIVE POSITIONING HAS OCCURED
596 *
597 **** GLUE IN THE MOVEMENT ROUTINES
598 *
599 MU XAC PL$U
600 MD XAC PL$D
601 ML XAC PL$L
602 MR XAC PL$R
603 MUL XAC PL$UL
604 MUR XAC PL$UR
605 MDL XAC PL$DL
606 MDR XAC PL$DR
607 *
608 ********************************************************************************
609 *
610 *
611 **** AFFINE TRASFORMATION DATA AND REST OF GRAPHIC CONTEXT
612 *
613 * OLD PROGRAMS DON'T HAVE TO WORRY ABOUT THAT. NEWER PROGRAMS SHOULD.
614 *
615 *** HERE THE TRANSFORMATION MATRIX, INITIALLY NO TRANSFORMATION, OLD PROGRAMS
616 *** DON'T HAVE TO CARE ABOUT THAT (HOPE SO)
617 ATRA OCT '040300 A11 (CONSTANT 1.0)
618 OCT '000000
619 OCT '000000 A12
620 OCT '000000
621 OCT '000000 A21
622 OCT '000000
623 OCT '040300 A22 (CONSTANT 1.0)
624 OCT '000000
625 *
626 VECT DEC 0 X TRANSLATION
627 DEC 0 Y TRANSLATION
628 XU DEC 0 USER VIEW PEN POSITION, X VALUE
629 YU DEC 0 USER VIEW PEN POSITION, Y VALUE
630 *
631 VECX EQU VECT
632 VECY EQU VECT+1
633 *
634 ********************************************************************************
635 *
636 *
637 END