source: git/src/riscos/armrot.s @ bfc4c77

RELEASE/1.0
Last change on this file since bfc4c77 was bfc4c77, checked in by Olly Betts <olly@…>, 13 years ago

Backport changes from 1.2.0:
doc/index.htm.in,doc/manual.sgml,doc/survex.ent,lib/print.ini,
src/printwx.cc,survex.iss.in: Use http://survex.com/ rather than
http://www.survex.com/ - the former is the canonical name and
www.survex.com just redirects.
COPYING,lib/print.ini,src/riscos/armrot.s,tests/: Update FSF address.

git-svn-id: file:///home/survex-svn/survex/branches/1.0@3704 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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_translate|, |do_translate_stns|
37        EXPORT  |ol_setcol|
38
39        IMPORT  |labels_plot|
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_translate", 0
290        DCB     &00, &00, &00              ;align
291        DCD     &ff000010
292
293|do_translate|
294|do_translate_stns|
295        STMFD   sp!,{x,y,z,r14}
296        MOV     r14,r0
297do_translate_loop
298        LDMIA   r14,{r0,x,y,z}
299        TEQ     r0,#0 ; exit if option is 0 (which is NULL pointer on ARM)
300        ADDNE   x,x,r1
301        ADDNE   y,y,r2
302        ADDNE   z,z,r3
303        ADDNE   r14,r14,#4 ; option is unchanged, so skip it
304        STMNEIA r14!,{x,y,z}
305        BNE     do_translate_loop
306        LDMFD   sp!,{x,y,z,pc}^
307
308;ppData
309;        IMPORT  pData
310;        DCD     pData
311
312X0   RN 0
313Y0   RN 1
314X1   RN 2
315Y1   RN 3
316col  RN 4
317dX   RN 5
318dY   RN 6
319D    RN 7
320c    RN 8
321llen RN 9
322Ymin RN 10
323Ymax RN 11
324Xmax RN 12
325
326blk_in
327        DCD   6
328        DCD 148
329        DCD   7
330        DCD  11
331        DCD  12
332        DCD   9
333        DCD   0
334        DCD   4
335        DCD   5
336        DCD  -1
337
338blk_out
339LLen     DCD 0 ; llen  r9
340pScrn    DCD 0 ; Ymin r10
341ScrnLen  DCD 0 ; Ymax r11 (becomes pScrnMax = ptr to bottom right pixel)
342Width    DCD 0 ; Xmax r12
343Depth    DCD 0 ;      r14
344Log2BPP  DCD 0
345ModeFlgs DCD 0
346xeig     DCD 0
347yeig     DCD 0
348
349xclabmax DCD 0
350yclabmax DCD 0
351
352; initialisation code
353|fastline_init|
354; may corrupt r0-r3
355        MOV     r3,r14
356        BL      fl_init
357; make sure we're in a 256 colour graphics mode...
358        LDR     r14,ModeFlgs
359        TST     r14,#7 ;%111
360        LDREQ   r14,Log2BPP
361        TEQEQ   r14,#3 ; ie 8bpp
362        MOVEQ   pc,r3
363        ADR     r0,badmode
364        SWI     OS_GenerateError
365
366badmode DCD 0
367        = "Sorry, not in a 256 colour graphics mode",0
368        ALIGN
369
370fl_init
371        STMFD   r13!,{r0-r1,r14}
372        ADR     r0,blk_in
373        ADR     r1,blk_out
374        SWI     OS_ReadVduVariables
375; change screen bank size entry to be a ptr to the bottom-right pixel
376        LDR     r0,pScrn
377        LDR     r1,ScrnLen
378        ADD     r0,r0,r1
379        SUB     r0,r0,#1
380        STR     r0,ScrnLen
381        LDR     r0,Width
382;        LDR     r1,xeig
383        ADD     r0,r0,#1
384;        MOV     r0,r0,ASL r1
385        MOV     r0,r0,LSR#1
386        STR     r0,xclabmax
387        LDR     r0,Depth
388;        LDR     r1,yeig
389        ADD     r0,r0,#1
390;        MOV     r0,r0,ASL r1
391        MOV     r0,r0,LSR#1
392        STR     r0,yclabmax
393        LDMFD   r13!,{r0-r1,pc}
394
395last_x  DCD 0
396last_y  DCD 0
397
398plot_cross
399        STMFD   r13!,{r1-r2,r14}
400        SUB     r1,r1,#2
401        SUB     r2,r2,#2
402        STR     r1,last_x
403        STR     r2,last_y
404        ADD     r1,r1,#4
405        ADD     r2,r2,#4
406        BL      ol_draw
407        SUB     r1,r1,#4
408        STR     r1,last_x
409        STR     r2,last_y
410        ADD     r1,r1,#4
411        SUB     r2,r2,#4
412        BL      ol_draw
413        SUB     r1,r1,#2
414        ADD     r2,r2,#2 ; and fall thru'
415        STR     r1,last_x
416        STR     r2,last_y
417        LDMFD   r13!,{r1-r2,pc}^
418
419; /E r0 -> label (or NULL); r1,r2 are coordinates - (0,0) is centre of screen
420; /X corrupts r0-r2,r8-r10 (opt, XS, YS, x, y, z)
421plot_label
422        MOVS    r8,r1
423        RSBMI   r8,r8,#0    ; r8=ABS(X)
424        LDR     r9,xclabmax
425        CMP     r8,r9
426        MOVGTS  pc,r14
427        MOVS    r8,r2
428        RSBMI   r8,r8,#0    ; r8=ABS(Y)
429        LDR     r9,yclabmax
430        CMP     r8,r9
431        MOVGES  pc,r14
432        MOV     r8,r14
433        MOV     r10,r12
434        MOV     r9,r3
435        BL      labels_plot
436        MOV     r3,r9
437        MOV     r12,r10
438        TST     r0,#0
439        MOVEQS  pc,r8
440        MOVS    r14,r0
441        LDRNE   r0,xeig
442        MOVNE   r1,r1,ASL r0
443        LDRNE   r0,yeig
444        MOVNE   r2,r2,ASL r0
445        MOVNE   r0,#4
446        SWINE   OS_Plot
447        MOVNE   r0,r14
448        SWINE   OS_Write0
449        MOVS    pc,r8
450
451fastmove
452        STR     r1,last_x
453        STR     r2,last_y
454        MOVS    pc,r14
455;
456label
457        = "Label",0
458        ALIGN
459
460ol_setcol
461        STR r0,colour
462        MOVS pc,r14
463
464colour
465        DCD 31
466;
467ol_plot
468;        TEQ     r0,#69
469;        BEQ     plot_cross
470        TEQ     r0,#4
471        BEQ     fastmove
472ol_draw
473        STMFD   r13!,{r1-r7,r11,r12,r14}
474        MOV     r0,r1
475        MOV     r1,r2
476        LDR     r2,last_x
477        LDR     r3,last_y
478        STR     r0,last_x
479        STR     r1,last_y
480
481        ADR     llen,LLen
482        LDMIA   llen,{llen,Ymin,Ymax,Xmax,r14} ; r14 is the width in pixels-1
483
484        ADD     r2,r2,Xmax,LSR #1 ; add on half screen width
485        ADDS    r0,r0,Xmax,LSR #1 ; add on half screen width
486;        CMP     X0,#0
487        CMPLT   X1,#0
488        LDMLTFD r13!,{r1-r7,r11,r12,pc}^ ; off the bottom
489
490        RSB     r3,r3,r14,LSR #1 ; subtract from half screen depth
491        RSBS    r1,r1,r14,LSR #1 ; subtract from half screen depth
492;        CMP     Y0,#0
493        CMPLT   Y1,#0
494        LDMLTFD r13!,{r1-r7,r11,r12,pc}^ ; off the left
495
496        CMP     X0,Xmax
497        CMPGT   X1,Xmax
498        LDMGTFD r13!,{r1-r7,r11,r12,pc}^ ; off the top
499
500        CMP     Y0,r14
501        CMPGT   Y1,r14
502        LDMGTFD r13!,{r1-r7,r11,r12,pc}^ ; off the right
503
504        LDR     col,colour
505;
506        SUBS    dX,X1,X0
507        RSBMI   dX,dX,#0    ; dX=abs(dX)
508        MVNMI   X1,#0 ;NOT(-1) ; X1 is now step for X
509        MOVPL   X1,#1
510;
511        SUBS    dY,Y1,Y0
512        RSBMI   dY,dY,#0    ; dY=abs(dY)
513        RSBMI   Y1,llen,#0  ; Y1 is now step for Y address
514        MOVPL   Y1,llen
515        MLA     c,Y0,llen,Ymin
516        MOV     Y0,c ; sigh
517;
518        CMP     dX,dY
519        BLT     steepline   ; branch if line > 45 degrees
520;
521        RSB     D,dX,#0     ; D=-dX
522        SUB     c,dX,#1     ; counter
523;
524; first loop counts until line is on screen
525loop
526        CMP     X0,#0
527        CMPGE   Y0,Ymin
528        CMPGE   Xmax,X0
529        CMPGE   Ymax,Y0
530        BGE     on
531;
532        ADDS    D,D,dY,ASL #1
533        SUBGE   D,D,dX,ASL #1
534        ADDGE   Y0,Y0,Y1
535        ADD     X0,X0,X1
536;
537        SUBS    c,c,#1
538        BPL     loop
539        LDMFD   r13!,{r1-r7,r11,r12,pc}^
540
541;when we get to on, D = [ dX + |dist moved|*2.dY ] mod 2.dX - 2.dX
542; or -dX if we start on screen
543
544; line is now on screen - loop until end of line or line goes off screen
545on
546        STRB    col,[Y0,X0]
547loop1
548        ADDS    D,D,dY,ASL #1
549        SUBGE   D,D,dX,ASL #1
550        ADDGE   Y0,Y0,Y1
551        ADDS    X0,X0,X1
552
553        ; CMP     X0,#0 ; unneeded
554        CMPGE   Y0,Ymin
555        CMPGE   Xmax,X0
556        CMPGE   Ymax,Y0
557
558        STRGEB  col,[Y0,X0]
559
560        SUBGES  c,c,#1
561        BGE     loop1
562        LDMFD   r13!,{r1-r7,r11,r12,pc}^
563
564steepline
565        RSB     D,dY,#0    ; D=-dY
566        SUB     c,dY,#1    ; counter
567
568; first loop counts until line is on screen
569stloop
570        CMP     X0,#0
571        CMPGE   Y0,Ymin
572        CMPGE   Xmax,X0
573        CMPGE   Ymax,Y0
574        BGE     ston
575
576        ADDS    D,D,dX,ASL #1
577        SUBGE   D,D,dY,ASL #1
578        ADDGE   X0,X0,X1
579        ADD     Y0,Y0,Y1
580
581        SUBS    c,c,#1
582        BPL     stloop
583        LDMFD   r13!,{r1-r7,r11,r12,pc}^
584
585; line is now on screen - loop until end of line or line goes off screen
586ston
587        STRB    col,[Y0,X0]
588stloop1
589        ADDS    D,D,dX,ASL #1
590        SUBGE   D,D,dY,ASL #1
591        ADD     Y0,Y0,Y1
592        ADDGE   X0,X0,X1
593
594        CMP     X0,#0
595        CMPGE   Y0,Ymin
596        CMPGE   Xmax,X0
597        CMPGE   Ymax,Y0
598
599        STRGEB  col,[Y0,X0]
600
601        SUBGES  c,c,#1
602        BGE     stloop1
603        LDMFD   r13!,{r1-r7,r11,r12,pc}^
604
605        END
Note: See TracBrowser for help on using the repository browser.