source: git/src/riscos/armrot.s @ 91912b4

RELEASE/1.0RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernlogstereowalls-datawalls-data-hanging-as-warning
Last change on this file since 91912b4 was c0563da, checked in by Olly Betts <olly@…>, 23 years ago

Assorted minor fettles.

git-svn-id: file:///home/survex-svn/survex/trunk@583 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 14.6 KB
Line 
1; > s.armrot
2; Copyright (C) Olly Betts 1990,1993,1994,1995,1997,2001
3;
4; This program is free software; you can redistribute it and/or modify
5; it under the terms of the GNU General Public License as published by
6; the Free Software Foundation; either version 2 of the License, or
7; (at your option) any later version.
8;
9; This program is distributed in the hope that it will be useful,
10; but WITHOUT ANY WARRANTY; without even the implied warranty of
11; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12; GNU General Public License for more details.
13;
14; You should have received a copy of the GNU General Public License
15; along with this program; if not, write to the Free Software
16; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17;
18;***************************************************************************
19;
20
21        GET     stdh.RegNames
22
23        GET     stdh.SWInames
24
25; Area name C$$code advisable if wanted to link with C output
26
27        AREA    |C$$code|, CODE
28;, READONLY
29; and pray the linker doesn't take that READONLY part seriously... !HACK!
30
31; Export global symbols
32
33        EXPORT  |plot|,  |plot_no_tilt|,  |plot_plan|
34        EXPORT  |splot|, |splot_no_tilt|, |splot_plan|
35        EXPORT  |lplot|, |lplot_no_tilt|, |lplot_plan|
36        EXPORT  |fastline_init|, |do_trans|
37        EXPORT  |ol_setcol|
38
39        IMPORT  |fancy_label|
40; some reg names
41
42opt RN 0
43XS  RN 1
44YS  RN 2
45x1  RN 3
46x2  RN 4
47y1  RN 5
48y2  RN 6
49y3  RN 7
50x   RN 8
51y   RN 9
52z   RN 10
53ptr RN 11
54
55; r0 - r3 can be altered
56; Since these are leaf fns (ie calls no others), don't set up stack frames
57
58; The following bytes contain the name of the following procedure to
59; make stack backtracing work, eg. when an address exception occurs!
60
61        DCB     "plot", 0
62        DCB     &00, &00, &00              ;align
63        DCD     &ff000008
64
65|plot|
66        STMFD   sp!,{r4-r12,r14}
67        BL      fl_init
68        MOV     ptr,r0
69        MOV     y1,r3
70        MOV     x2,r2
71        MOV     x1,r1
72        LDR     y2,[sp,#40]
73        LDR     y3,[sp,#44]
74        LDR     r12,[sp,#48]
75plot_loop
76        LDMIA   ptr!,{opt,x,y,z}
77        TEQ     opt,#0 ; exit if option is 0
78        MULNE   XS,x,x1
79        MLANE   XS,y,x2,XS
80        MULNE   YS,x,y1
81        MLANE   YS,y,y2,YS
82        MLANE   YS,z,y3,YS
83        MOVNE   XS,XS,ASR r12
84        MOVNE   YS,YS,ASR r12
85        BLNE    ol_plot
86        BNE     plot_loop
87        LDMFD   sp!,{r4-r12,pc}^
88
89|splot|
90        STMFD   sp!,{r4-r12,r14}
91        BL      fl_init
92        MOV     ptr,r0
93        MOV     y1,r3
94        MOV     x2,r2
95        MOV     x1,r1
96        LDR     y2,[sp,#40]
97        LDR     y3,[sp,#44]
98        LDR     r12,[sp,#48]
99splot_loop
100        LDMIA   ptr!,{opt,x,y,z}
101        TEQ     opt,#0 ; exit if option is 0
102        MULNE   XS,x,x1
103        MLANE   XS,y,x2,XS
104        MULNE   YS,x,y1
105        MLANE   YS,y,y2,YS
106        MLANE   YS,z,y3,YS
107        MOVNE   XS,XS,ASR r12
108        MOVNE   YS,YS,ASR r12
109        BLNE    plot_cross
110        BNE     splot_loop
111        LDMFD   sp!,{r4-r12,pc}^
112
113|lplot|
114        STMFD   sp!,{r4-r12,r14}
115        BL      fl_init
116        MOV     ptr,r0
117        MOV     y1,r3
118        MOV     x2,r2
119        MOV     x1,r1
120        LDR     y2,[sp,#40]
121        LDR     y3,[sp,#44]
122        LDR     r12,[sp,#48]
123;        LDR     r2,xeig
124;        MOV     x1,x1,ASL r2
125;        MOV     x2,x2,ASL r2
126;        LDR     r2,yeig
127;        MOV     y1,y1,ASL r2
128;        MOV     y2,y2,ASL r2
129;        MOV     y3,y3,ASL r2
130lplot_loop
131        LDMIA   ptr!,{opt,x,y,z}
132        TEQ     opt,#0 ; exit if option is 0
133        MULNE   XS,x,x1
134        MLANE   XS,y,x2,XS
135        MULNE   YS,x,y1
136        MLANE   YS,y,y2,YS
137        MLANE   YS,z,y3,YS
138        MOVNE   XS,XS,ASR r12
139        MOVNE   YS,YS,ASR r12
140        BLNE    plot_label
141        BNE     lplot_loop
142        LDMFD   sp!,{r4-r12,pc}^
143
144        DCB     "plot_no_tilt", 0
145        DCB     &00, &00, &00              ;align
146        DCD     &ff000010
147
148|plot_no_tilt|
149        STMFD   sp!,{r4-r12,r14}
150        BL      fl_init
151        MOV     ptr,r0
152        MOV     y3,r3
153        MOV     x2,r2
154        MOV     x1,r1
155        LDR     r12,[sp,#40]
156plot_no_tilt_loop
157        LDMIA   ptr!,{opt,x,y,z}
158        TEQ     opt,#0 ; exit if option is 0
159        MULNE   XS,x,x1
160        MLANE   XS,y,x2,XS
161        MULNE   YS,z,y3
162        MOVNE   XS,XS,ASR r12
163        MOVNE   YS,YS,ASR r12
164        BLNE    ol_plot
165        BNE     plot_no_tilt_loop
166        LDMFD   sp!,{r4-r12,pc}^
167
168|splot_no_tilt|
169        STMFD   sp!,{r4-r12,r14}
170        BL      fl_init
171        MOV     ptr,r0
172        MOV     y3,r3
173        MOV     x2,r2
174        MOV     x1,r1
175        LDR     r12,[sp,#40]
176splot_no_tilt_loop
177        LDMIA   ptr!,{opt,x,y,z}
178        TEQ     opt,#0 ; exit if option is 0
179        MULNE   XS,x,x1
180        MLANE   XS,y,x2,XS
181        MULNE   YS,z,y3
182        MOVNE   XS,XS,ASR r12
183        MOVNE   YS,YS,ASR r12
184        BLNE    plot_cross
185        BNE     splot_no_tilt_loop
186        LDMFD   sp!,{r4-r12,pc}^
187
188|lplot_no_tilt|
189        STMFD   sp!,{r4-r12,r14}
190        BL      fl_init
191        MOV     ptr,r0
192        MOV     y3,r3
193        MOV     x2,r2
194        MOV     x1,r1
195        LDR     r12,[sp,#40]
196;        LDR     r2,xeig
197;        MOV     x1,x1,ASL r2
198;        MOV     x2,x2,ASL r2
199;        LDR     r2,yeig
200;        MOV     y3,y3,ASL r2
201lplot_no_tilt_loop
202        LDMIA   ptr!,{opt,x,y,z}
203        TEQ     opt,#0 ; exit if option is 0
204        MULNE   XS,x,x1
205        MLANE   XS,y,x2,XS
206        MULNE   YS,z,y3
207        MOVNE   XS,XS,ASR r12
208        MOVNE   YS,YS,ASR r12
209        BLNE    plot_label
210        BNE     lplot_no_tilt_loop
211        LDMFD   sp!,{r4-r12,pc}^
212
213        DCB     "plot_plan", 0
214        DCB     &00, &00              ;align
215        DCD     &ff00000c
216
217|plot_plan|
218        STMFD   sp!,{r4-r12,r14}
219        BL      fl_init
220        MOV     ptr,r0
221        MOV     y1,r3
222        MOV     x2,r2
223        MOV     x1,r1
224        LDR     y2,[sp,#40]
225        LDR     r12,[sp,#44]
226plot_plan_loop
227        LDMIA   ptr!,{opt,x,y,z}
228        TEQ     opt,#0 ; exit if option is 0
229        MULNE   XS,x,x1
230        MLANE   XS,y,x2,XS
231        MULNE   YS,x,y1
232        MLANE   YS,y,y2,YS
233        MOVNE   XS,XS,ASR r12
234        MOVNE   YS,YS,ASR r12
235        BLNE    ol_plot
236        BNE     plot_plan_loop
237        LDMFD   sp!,{r4-r12,pc}^
238
239|splot_plan|
240        STMFD   sp!,{r4-r12,r14}
241        BL      fl_init
242        MOV     ptr,r0
243        MOV     y1,r3
244        MOV     x2,r2
245        MOV     x1,r1
246        LDR     y2,[sp,#40]
247        LDR     r12,[sp,#44]
248splot_plan_loop
249        LDMIA   ptr!,{opt,x,y,z}
250        TEQ     opt,#0 ; exit if option is 0
251        MULNE   XS,x,x1
252        MLANE   XS,y,x2,XS
253        MULNE   YS,x,y1
254        MLANE   YS,y,y2,YS
255        MOVNE   XS,XS,ASR r12
256        MOVNE   YS,YS,ASR r12
257        BLNE    plot_cross
258        BNE     splot_plan_loop
259        LDMFD   sp!,{r4-r12,pc}^
260
261|lplot_plan|
262        STMFD   sp!,{r4-r12,r14}
263        BL      fl_init
264        MOV     ptr,r0
265        MOV     y1,r3
266        MOV     x2,r2
267        MOV     x1,r1
268        LDR     y2,[sp,#40]
269        LDR     r12,[sp,#44]
270;        LDR     r2,xeig
271;        MOV     x1,x1,ASL r2
272;        MOV     x2,x2,ASL r2
273;        LDR     r2,yeig
274;        MOV     y1,y1,ASL r2
275;        MOV     y2,y2,ASL r2
276lplot_plan_loop
277        LDMIA   ptr!,{opt,x,y,z}
278        TEQ     opt,#0 ; exit if option is 0
279        MULNE   XS,x,x1
280        MLANE   XS,y,x2,XS
281        MULNE   YS,x,y1
282        MLANE   YS,y,y2,YS
283        MOVNE   XS,XS,ASR r12
284        MOVNE   YS,YS,ASR r12
285        BLNE    plot_label
286        BNE     lplot_plan_loop
287        LDMFD   sp!,{r4-r12,pc}^
288
289        DCB     "do_trans", 0
290        DCB     &00, &00, &00              ;align
291        DCD     &ff00000C
292
293|do_trans|
294        STMFD   sp!,{x,y,z,r14}
295        MOV     r14,r0
296do_trans_loop
297        LDMIA   r14,{r0,x,y,z}
298        TEQ     r0,#0 ; exit if option is 0 (which NULL pointer on ARM)
299        ADDNE   x,x,r1
300        ADDNE   y,y,r2
301        ADDNE   z,z,r3
302        ADDNE   r14,r14,#4 ; option is unchanged, so skip it
303        STMNEIA r14!,{x,y,z}
304        BNE     do_trans_loop
305        LDMFD   sp!,{x,y,z,pc}^
306
307;ppData
308;        IMPORT  pData
309;        DCD     pData
310
311X0   RN 0
312Y0   RN 1
313X1   RN 2
314Y1   RN 3
315col  RN 4
316dX   RN 5
317dY   RN 6
318D    RN 7
319c    RN 8
320llen RN 9
321Ymin RN 10
322Ymax RN 11
323Xmax RN 12
324
325blk_in
326        DCD   6
327        DCD 148
328        DCD   7
329        DCD  11
330        DCD  12
331        DCD   9
332        DCD   0
333        DCD   4
334        DCD   5
335        DCD  -1
336
337blk_out
338LLen     DCD 0 ; llen  r9
339pScrn    DCD 0 ; Ymin r10
340ScrnLen  DCD 0 ; Ymax r11 (becomes pScrnMax = ptr to bottom right pixel)
341Width    DCD 0 ; Xmax r12
342Depth    DCD 0 ;      r14
343Log2BPP  DCD 0
344ModeFlgs DCD 0
345xeig     DCD 0
346yeig     DCD 0
347
348xclabmax DCD 0
349yclabmax DCD 0
350
351; initialisation code
352|fastline_init|
353; may corrupt r0-r3
354        MOV     r3,r14
355        BL      fl_init
356; make sure we're in a 256 colour graphics mode...
357        LDR     r14,ModeFlgs
358        TST     r14,#7 ;%111
359        LDREQ   r14,Log2BPP
360        TEQEQ   r14,#3 ; ie 8bpp
361        MOVEQ   pc,r3
362        ADR     r0,badmode
363        SWI     OS_GenerateError
364
365badmode DCD 0
366        = "Sorry, not in a 256 colour graphics mode",0
367        ALIGN
368
369fl_init
370        STMFD   r13!,{r0-r1,r14}
371        ADR     r0,blk_in
372        ADR     r1,blk_out
373        SWI     OS_ReadVduVariables
374; change screen bank size entry to be a ptr to the bottom-right pixel
375        LDR     r0,pScrn
376        LDR     r1,ScrnLen
377        ADD     r0,r0,r1
378        SUB     r0,r0,#1
379        STR     r0,ScrnLen
380        LDR     r0,Width
381;        LDR     r1,xeig
382        ADD     r0,r0,#1
383;        MOV     r0,r0,ASL r1
384        MOV     r0,r0,LSR#1
385        STR     r0,xclabmax
386        LDR     r0,Depth
387;        LDR     r1,yeig
388        ADD     r0,r0,#1
389;        MOV     r0,r0,ASL r1
390        MOV     r0,r0,LSR#1
391        STR     r0,yclabmax
392        LDMFD   r13!,{r0-r1,pc}
393
394last_x  DCD 0
395last_y  DCD 0
396
397plot_cross
398        STMFD   r13!,{r1-r2,r14}
399        SUB     r1,r1,#2
400        SUB     r2,r2,#2
401        STR     r1,last_x
402        STR     r2,last_y
403        ADD     r1,r1,#4
404        ADD     r2,r2,#4
405        BL      ol_draw
406        SUB     r1,r1,#4
407        STR     r1,last_x
408        STR     r2,last_y
409        ADD     r1,r1,#4
410        SUB     r2,r2,#4
411        BL      ol_draw
412        SUB     r1,r1,#2
413        ADD     r2,r2,#2 ; and fall thru'
414        STR     r1,last_x
415        STR     r2,last_y
416        LDMFD   r13!,{r1-r2,pc}^
417
418; /E r0 -> label (or NULL); r1,r2 are coordinates - (0,0) is centre of screen
419; /X corrupts r0-r2,r8-r10 (opt, XS, YS, x, y, z)
420plot_label
421        MOVS    r8,r1
422        RSBMI   r8,r8,#0    ; r8=ABS(X)
423        LDR     r9,xclabmax
424        CMP     r8,r9
425        MOVGTS  pc,r14
426        MOVS    r8,r2
427        RSBMI   r8,r8,#0    ; r8=ABS(Y)
428        LDR     r9,yclabmax
429        CMP     r8,r9
430        MOVGES  pc,r14
431        MOV     r8,r14
432        MOV     r10,r12
433        MOV     r9,r3
434        BL      fancy_label
435        MOV     r3,r9
436        MOV     r12,r10
437        TST     r0,#0
438        MOVEQS  pc,r8
439        MOVS    r14,r0
440        LDRNE   r0,xeig
441        MOVNE   r1,r1,ASL r0
442        LDRNE   r0,yeig
443        MOVNE   r2,r2,ASL r0
444        MOVNE   r0,#4
445        SWINE   OS_Plot
446        MOVNE   r0,r14
447        SWINE   OS_Write0
448        MOVS    pc,r8
449
450fastmove
451        STR     r1,last_x
452        STR     r2,last_y
453        MOVS    pc,r14
454;
455label
456        = "Label",0
457        ALIGN
458
459ol_setcol
460        STR r0,colour
461        MOVS pc,r14
462
463colour
464        DCD 31
465;
466ol_plot
467;        TEQ     r0,#69
468;        BEQ     plot_cross
469        TEQ     r0,#4
470        BEQ     fastmove
471ol_draw
472        STMFD   r13!,{r1-r7,r11,r12,r14}
473        MOV     r0,r1
474        MOV     r1,r2
475        LDR     r2,last_x
476        LDR     r3,last_y
477        STR     r0,last_x
478        STR     r1,last_y
479
480        ADR     llen,LLen
481        LDMIA   llen,{llen,Ymin,Ymax,Xmax,r14} ; r14 is the width in pixels-1
482
483        ADD     r2,r2,Xmax,LSR #1 ; add on half screen width
484        ADDS    r0,r0,Xmax,LSR #1 ; add on half screen width
485;        CMP     X0,#0
486        CMPLT   X1,#0
487        LDMLTFD r13!,{r1-r7,r11,r12,pc}^ ; off the bottom
488
489        RSB     r3,r3,r14,LSR #1 ; subtract from half screen depth
490        RSBS    r1,r1,r14,LSR #1 ; subtract from half screen depth
491;        CMP     Y0,#0
492        CMPLT   Y1,#0
493        LDMLTFD r13!,{r1-r7,r11,r12,pc}^ ; off the left
494
495        CMP     X0,Xmax
496        CMPGT   X1,Xmax
497        LDMGTFD r13!,{r1-r7,r11,r12,pc}^ ; off the top
498
499        CMP     Y0,r14
500        CMPGT   Y1,r14
501        LDMGTFD r13!,{r1-r7,r11,r12,pc}^ ; off the right
502
503        LDR     col,colour
504;
505        SUBS    dX,X1,X0
506        RSBMI   dX,dX,#0    ; dX=abs(dX)
507        MVNMI   X1,#0 ;NOT(-1) ; X1 is now step for X
508        MOVPL   X1,#1
509;
510        SUBS    dY,Y1,Y0
511        RSBMI   dY,dY,#0    ; dY=abs(dY)
512        RSBMI   Y1,llen,#0  ; Y1 is now step for Y address
513        MOVPL   Y1,llen
514        MLA     c,Y0,llen,Ymin
515        MOV     Y0,c ; sigh
516;
517        CMP     dX,dY
518        BLT     steepline   ; branch if line > 45 degrees
519;
520        RSB     D,dX,#0     ; D=-dX
521        SUB     c,dX,#1     ; counter
522;
523; first loop counts until line is on screen
524loop
525        CMP     X0,#0
526        CMPGE   Y0,Ymin
527        CMPGE   Xmax,X0
528        CMPGE   Ymax,Y0
529        BGE     on
530;
531        ADDS    D,D,dY,ASL #1
532        SUBGE   D,D,dX,ASL #1
533        ADDGE   Y0,Y0,Y1
534        ADD     X0,X0,X1
535;
536        SUBS    c,c,#1
537        BPL     loop
538        LDMFD   r13!,{r1-r7,r11,r12,pc}^
539
540;when we get to on, D = [ dX + |dist moved|*2.dY ] mod 2.dX - 2.dX
541; or -dX if we start on screen
542
543; line is now on screen - loop until end of line or line goes off screen
544on
545        STRB    col,[Y0,X0]
546loop1
547        ADDS    D,D,dY,ASL #1
548        SUBGE   D,D,dX,ASL #1
549        ADDGE   Y0,Y0,Y1
550        ADDS    X0,X0,X1
551
552        ; CMP     X0,#0 ; unneeded
553        CMPGE   Y0,Ymin
554        CMPGE   Xmax,X0
555        CMPGE   Ymax,Y0
556
557        STRGEB  col,[Y0,X0]
558
559        SUBGES  c,c,#1
560        BGE     loop1
561        LDMFD   r13!,{r1-r7,r11,r12,pc}^
562
563steepline
564        RSB     D,dY,#0    ; D=-dY
565        SUB     c,dY,#1    ; counter
566
567; first loop counts until line is on screen
568stloop
569        CMP     X0,#0
570        CMPGE   Y0,Ymin
571        CMPGE   Xmax,X0
572        CMPGE   Ymax,Y0
573        BGE     ston
574
575        ADDS    D,D,dX,ASL #1
576        SUBGE   D,D,dY,ASL #1
577        ADDGE   X0,X0,X1
578        ADD     Y0,Y0,Y1
579
580        SUBS    c,c,#1
581        BPL     stloop
582        LDMFD   r13!,{r1-r7,r11,r12,pc}^
583
584; line is now on screen - loop until end of line or line goes off screen
585ston
586        STRB    col,[Y0,X0]
587stloop1
588        ADDS    D,D,dX,ASL #1
589        SUBGE   D,D,dY,ASL #1
590        ADD     Y0,Y0,Y1
591        ADDGE   X0,X0,X1
592
593        CMP     X0,#0
594        CMPGE   Y0,Ymin
595        CMPGE   Xmax,X0
596        CMPGE   Ymax,Y0
597
598        STRGEB  col,[Y0,X0]
599
600        SUBGES  c,c,#1
601        BGE     stloop1
602        LDMFD   r13!,{r1-r7,r11,r12,pc}^
603
604        END
Note: See TracBrowser for help on using the repository browser.