Home » Archimedes archive » Acorn User » AU 1998-07.adf » Regulars » StarInfo/Thoukydide/CrazySrc » Compare

Compare StarInfo/Thoukydide/CrazySrc with StarInfo/Kennedy/CrazySrc

File: Archimedes archive » Acorn User » AU 1998-07.adf » Regulars » StarInfo/Thoukydide/CrazySrc
Compared with: Archimedes archive » Acorn User » AU 1998-13 (Christmas).adf » Regulars » StarInfo/Kennedy/CrazySrc
Similarity: 96% of bytes duplicated

1237 of 1277 lines (97.1%) are identical in the two listings. Duplicated Different

Line numbers are ignored when comparing lines, so that renumbered programs still match.

StarInfo/Thoukydide/CrazySrc StarInfo/Kennedy/CrazySrc
10REM File : CrazySrc 10REM File : CrazySrc
20REM Date : 07-Jun-97 20REM Date : 10-Jun-98
30REM Author : LEN A.Thoukydides, 1997 30REM Author : LEN A.Thoukydides, 1997
40REM Description : Change the pointer appearance. 40REM Description : Change the pointer appearance.
50REM This is inspired by MouseP written by Andrew Bolt 50REM This is inspired by MouseP written by Andrew Bolt
60REM from the *Info section of Acorn User magazine, June 1997. 60REM from the *Info section of Acorn User magazine, June 1997.
70 70
80REM Modified : Nick Kennedy, 1998
90REM This now works on pre RiscOS 3.60 machines, and exits correctly
100REM if there is an error on initialisation.
110
80REM The filename to save the module under 120REM The filename to save the module under
90filename$ = "CrazyPoint" 130filename$ = "CrazyPoint"
100 140
110REM Allocate memory to assemble the module 150REM Allocate memory to assemble the module
120code_size% = &2000 160code_size% = &2000
130DIM code% code_size% 170DIM code% code_size%
140 180
190REM Interval between updates in centiseconds (minimum 2)
200interval=4
210
150REM Pointer types 220REM Pointer types
160ptr_unknown = 0 230ptr_unknown = 0
170ptr_single = 1 240ptr_single = 1
180ptr_double = 2 250ptr_double = 2
190ptr_caret = 3 260ptr_caret = 3
200ptr_menu = 4 270ptr_menu = 4
210 280
220REM Pointer colours 290REM Pointer colours
230colour_trans = 0 300colour_trans = 0
240colour_cyan = &55 310colour_cyan = &55
250colour_blue = &aa 320colour_blue = &aa
260colour_red = &ff 330colour_red = &ff
270colour_trans_cyan = &11 340colour_trans_cyan = &11
280colour_trans_blue = &22 350colour_trans_blue = &22
290colour_trans_red = &33 360colour_trans_red = &33
300 370
310REM Usage of workspace 380REM Usage of workspace
320ws_internal = 0 390ws_internal = 0
330ws_types = 4 400ws_types = 4
340ws_hpos = 12 410ws_hpos = 12
350ws_vpos = 16 420ws_vpos = 16
360ws_xeig = 20 430ws_xeig = 20
370ws_yeig = 24 440ws_yeig = 24
380ws_ceig = 28 450ws_ceig = 28
390ws_filtn = 32 460ws_filtn = 32
400ws_filtv = 36 470ws_filtv = 36
410ws_cogr = 40 480ws_cogr = 40
420ws_cogc = 44 490ws_cogc = 44
430ws_friction = 48 500ws_friction = 48
440ws_spring = 52 510ws_spring = 52
450ws_force = 56 520ws_force = 56
460ws_ptr_block = 60 + 2 530ws_ptr_block = 60 + 2
470ws_ptr_block_shape = ws_ptr_block + 1 540ws_ptr_block_shape = ws_ptr_block + 1
480ws_ptr_block_width = ws_ptr_block + 2 550ws_ptr_block_width = ws_ptr_block + 2
490ws_ptr_block_height = ws_ptr_block + 3 560ws_ptr_block_height = ws_ptr_block + 3
500ws_ptr_block_activex = ws_ptr_block + 4 570ws_ptr_block_activex = ws_ptr_block + 4
510ws_ptr_block_activey = ws_ptr_block + 5 580ws_ptr_block_activey = ws_ptr_block + 5
520ws_ptr_block_data = ws_ptr_block + 6 590ws_ptr_block_data = ws_ptr_block + 6
530ws_buffer = ws_ptr_block + 10 600ws_buffer = ws_ptr_block + 10
540ws_buffer_size = 256 610ws_buffer_size = 256
550ws_ptr_data = ws_buffer + ws_buffer_size 620ws_ptr_data = ws_buffer + ws_buffer_size
560ws_ptr_data_size = 256 630ws_ptr_data_size = 256
570ws_size = ws_ptr_data + ws_ptr_data_size 640ws_size = ws_ptr_data + ws_ptr_data_size
580 650
590REM Multi-pass assembly 660REM Multi-pass assembly
600FOR opt% = 12 TO 14 STEP 2 670FOR opt% = 12 TO 14 STEP 2
610 P% = 0 680 P% = 0
620 O% = code% 690 O% = code%
630 L% = code% + code_size% 700 L% = code% + code_size%
640 [OPT opt% 710 [OPT opt%
650 720
660 ; Module header 730 ; Module header
670 EQUD 0 ; Start code 740 EQUD 0 ; Start code
680 EQUD initialisation ; Initialisation code 750 EQUD initialisation ; Initialisation code
690 EQUD finalisation ; Finalisation code 760 EQUD finalisation ; Finalisation code
700 EQUD service ; Service call handler 770 EQUD service ; Service call handler
710 EQUD title ; Title string 780 EQUD title ; Title string
720 EQUD help ; Help string 790 EQUD help ; Help string
730 EQUD command ; Help and command table 800 EQUD command ; Help and command table
740 EQUD 0 ; SWI chunk base number 810 EQUD 0 ; SWI chunk base number
750 EQUD 0 ; SWI handler code 820 EQUD 0 ; SWI handler code
760 EQUD 0 ; SWI decoding table 830 EQUD 0 ; SWI decoding table
770 EQUD 0 ; SWI decoding code 840 EQUD 0 ; SWI decoding code
780 850
790 ; Title string 860 ; Title string
800.title EQUS "CrazyPointer" 870.title EQUS "CrazyPointer"
810 EQUB 0 880 EQUB 0
820 890
830 900
840 ; Help string 910 ; Help string
850.help EQUS "Crazy Pointer" + CHR$9 + "1.01 (07 Jun 1997)" 920.help EQUS "Crazy Pointer" + CHR$9 + "1.02 (10 Jun 1998)"
860 EQUS " " + CHR$169 + " A.Thoukydides, 1997" 930 EQUS " " + CHR$169 + " A.Thoukydides, 1997"
870 EQUB 0 940 EQUB 0
880 ALIGN 950 ALIGN
890 960
900 ; Help and command keyword table 970 ; Help and command keyword table
910.command 980.command
920 EQUS "CrazyPointer" ; Command name 990 EQUS "CrazyPointer" ; Command name
930 EQUB 0 1000 EQUB 0
940 ALIGN 1010 ALIGN
950 EQUD 0 ; Offset to code 1020 EQUD 0 ; Offset to code
960 EQUD &0 ; Information word 1030 EQUD &0 ; Information word
970 EQUD 0 ; Offset to syntax message 1040 EQUD 0 ; Offset to syntax message
980 EQUD command_help ; Offset to help text 1050 EQUD command_help ; Offset to help text
990 1060
1000 EQUS "CrazyPointerWobble" ; Command name 1070 EQUS "CrazyPointerWobble" ; Command name
1010 EQUB 0 1080 EQUB 0
1020 ALIGN 1090 ALIGN
1030 EQUD command_wobble ; Offset to code 1100 EQUD command_wobble ; Offset to code
1040 EQUD &00070001 ; Information word 1110 EQUD &00070001 ; Information word
1050 EQUD command_wobble_syntax ; Offset to syntax message 1120 EQUD command_wobble_syntax ; Offset to syntax message
1060 EQUD command_wobble_help ; Offset to help text 1130 EQUD command_wobble_help ; Offset to help text
1070 1140
1080 EQUB 0 ; Terminate the list of keywords 1150 EQUB 0 ; Terminate the list of keywords
1090 1160
1100 ; Help for the CrazyPointer keyword 1170 ; Help for the CrazyPointer keyword
1110.command_help 1180.command_help
1120 EQUS "Crazy Pointer provides animated mouse pointers." 1190 EQUS "Crazy Pointer provides animated mouse pointers."
1130 EQUS " Replacements are provided for the standard, double-click," 1200 EQUS " Replacements are provided for the standard, double-click,"
1140 EQUS " and caret pointers." 1210 EQUS " and caret pointers."
1150 EQUB 13 1220 EQUB 13
1160 EQUS "This module is inspired by MouseP written by Andrew Bolt" 1230 EQUS "This module is inspired by MouseP written by Andrew Bolt"
1170 EQUS " and published in the June 1997 *Info section of Acorn User." 1240 EQUS " and published in the June 1997 *Info section of Acorn User."
1180 EQUB 0 1250 EQUB 0
1190 ALIGN 1260 ALIGN
1200 1270
1210 ; The *CrazyPointerWobble command 1280 ; The *CrazyPointerWobble command
1220.command_wobble 1290.command_wobble
1230 STMFD r13!, {r14} ; Stack registers 1300 STMFD r13!, {r14} ; Stack registers
1240 SUB r13, r13, #48 ; Reserve some stack space 1310 SUB r13, r13, #48 ; Reserve some stack space
1250 LDR r12, [r12] ; Obtain pointer to workspace 1320 LDR r12, [r12] ; Obtain pointer to workspace
1260 MOV r1, r0 ; Copy the command tail pointer 1330 MOV r1, r0 ; Copy the command tail pointer
1270 ADR r0, command_wobble_def ; Pointer to keyword definition 1340 ADR r0, command_wobble_def ; Pointer to keyword definition
1280 MOV r2, r13 ; Pointer to output buffer 1350 MOV r2, r13 ; Pointer to output buffer
1290 MOV r3, #48 ; Size of the output buffer 1360 MOV r3, #48 ; Size of the output buffer
1300 SWI "XOS_ReadArgs" ; Scan the command string 1370 SWI "XOS_ReadArgs" ; Scan the command string
1310 BVS command_wobble_done ; Return from handler if error 1380 BVS command_wobble_done ; Return from handler if error
1320 LDR r0, [r2], #4 ; Check if wobble is disabled 1390 LDR r0, [r2], #4 ; Check if wobble is disabled
1330 TEQ r0, #0 ; Is wobble being disabled 1400 TEQ r0, #0 ; Is wobble being disabled
1340 BNE command_wobble_disable ; Disable the pointer wobble if required 1410 BNE command_wobble_disable ; Disable the pointer wobble if required
1350 LDR r0, [r2], #4 ; Read friction pointer 1420 LDR r0, [r2], #4 ; Read friction pointer
1360 TEQ r0, #0 ; Was a value specified 1430 TEQ r0, #0 ; Was a value specified
1370 BEQ command_wobble_spring ; Skip this bit if not 1440 BEQ command_wobble_spring ; Skip this bit if not
1380 LDRB r1, [r0], #1 ; Read the type 1450 LDRB r1, [r0], #1 ; Read the type
1390 TEQ r1, #0 ; Is the value an integer 1460 TEQ r1, #0 ; Is the value an integer
1400 BNE command_wobble_fail ; Generate an error if not 1470 BNE command_wobble_fail ; Generate an error if not
1410 FNldru(1, 0, 3, 4) ; Read the friction value 1480 FNldru(1, 0, 3, 4) ; Read the friction value
1420 STR r1, [r12, #ws_friction] ; Store the friction value 1490 STR r1, [r12, #ws_friction] ; Store the friction value
1430.command_wobble_spring 1500.command_wobble_spring
1440 LDR r0, [r2], #4 ; Read spring pointer 1510 LDR r0, [r2], #4 ; Read spring pointer
1450 TEQ r0, #0 ; Was a value specified 1520 TEQ r0, #0 ; Was a value specified
1460 BEQ command_wobble_force ; Skip this bit if not 1530 BEQ command_wobble_force ; Skip this bit if not
1470 LDRB r1, [r0], #1 ; Read the type 1540 LDRB r1, [r0], #1 ; Read the type
1480 TEQ r1, #0 ; Is the value an integer 1550 TEQ r1, #0 ; Is the value an integer
1490 BNE command_wobble_fail ; Generate an error if not 1560 BNE command_wobble_fail ; Generate an error if not
1500 FNldru(1, 0, 3, 4) ; Read the spring value 1570 FNldru(1, 0, 3, 4) ; Read the spring value
1510 STR r1, [r12, #ws_spring] ; Store the spring value 1580 STR r1, [r12, #ws_spring] ; Store the spring value
1520.command_wobble_force 1590.command_wobble_force
1530 LDR r0, [r2], #4 ; Read force pointer 1600 LDR r0, [r2], #4 ; Read force pointer
1540 TEQ r0, #0 ; Was a value specified 1610 TEQ r0, #0 ; Was a value specified
1550 BEQ command_wobble_done ; Skip this bit if not 1620 BEQ command_wobble_done ; Skip this bit if not
1560 LDRB r1, [r0], #1 ; Read the type 1630 LDRB r1, [r0], #1 ; Read the type
1570 TEQ r1, #0 ; Is the value an integer 1640 TEQ r1, #0 ; Is the value an integer
1580 BNE command_wobble_fail ; Generate an error if not 1650 BNE command_wobble_fail ; Generate an error if not
1590 FNldru(1, 0, 3, 4) ; Read the force value 1660 FNldru(1, 0, 3, 4) ; Read the force value
1600 STR r1, [r12, #ws_force] ; Store the force value 1670 STR r1, [r12, #ws_force] ; Store the force value
1610.command_wobble_done 1680.command_wobble_done
1620 ADD r13, r13, #48 ; Skip back over the reserved space 1690 ADD r13, r13, #48 ; Skip back over the reserved space
1630 LDMFD r13!, {pc} ; Return from the command handler 1700 LDMFD r13!, {pc} ; Return from the command handler
1640.command_wobble_disable 1710.command_wobble_disable
1650 MOV r0, #0 ; Value to clear filter with 1720 MOV r0, #0 ; Value to clear filter with
1660 STR r0, [r12, #ws_filtn] ; Clear any existing wibble 1730 STR r0, [r12, #ws_filtn] ; Clear any existing wibble
1670 STR r0, [r12, #ws_filtv] ; Clear any existing wibble velocity 1740 STR r0, [r12, #ws_filtv] ; Clear any existing wibble velocity
1680 MOV r0, #32 ; Value to disable wobble 1750 MOV r0, #32 ; Value to disable wobble
1690 STR r0, [r12, #ws_force] ; Clear the force multiplier 1760 STR r0, [r12, #ws_force] ; Clear the force multiplier
1700 B command_wobble_done ; Return from the command handler 1770 B command_wobble_done ; Return from the command handler
1710.command_wobble_fail 1780.command_wobble_fail
1720 ADR r0, command_wobble_error; Pointer to error block 1790 ADR r0, command_wobble_error; Pointer to error block
1730 CMP pc, #&80000000 ; Set the overflow flag for an error 1800 CMP pc, #&80000000 ; Set the overflow flag for an error
1740 B command_wobble_done ; Return from the command handler 1810 B command_wobble_done ; Return from the command handler
1750.command_wobble_error 1820.command_wobble_error
1760 EQUD 0 1830 EQUD 0
1770 EQUS "Invalid command parameters" 1840 EQUS "Invalid command parameters"
1780 EQUB 0 1850 EQUB 0
1790 ALIGN 1860 ALIGN
1800.command_wobble_def 1870.command_wobble_def
1810 EQUS "nowobble/s,friction/e,spring/e,force/e" 1880 EQUS "nowobble/s,friction/e,spring/e,force/e"
1820 EQUB 0 1890 EQUB 0
1830.command_wobble_help 1900.command_wobble_help
1840 EQUS "*CrazyPointerWobble allows the pointer wobble to be" 1910 EQUS "*CrazyPointerWobble allows the pointer wobble to be"
1850 EQUS " controlled by setting three constants." 1920 EQUS " controlled by setting three constants."
1860 EQUS " These are all specified on a logarithmic scale in the range" 1930 EQUS " These are all specified on a logarithmic scale in the range"
1870 EQUS " 0 to 10, with a value of 5 being the default." 1940 EQUS " 0 to 10, with a value of 5 being the default."
1880 EQUB 13 1950 EQUB 13
1890.command_wobble_syntax 1960.command_wobble_syntax
1900 EQUS "Syntax: *CrazyPointerWobble [-nowobble]" 1970 EQUS "Syntax: *CrazyPointerWobble [-nowobble]"
1910 EQUS " [[-friction] <value>]" 1980 EQUS " [[-friction] <value>]"
1920 EQUS " [[-spring] <value>]" 1990 EQUS " [[-spring] <value>]"
1930 EQUS " [[-force] <value>]" 2000 EQUS " [[-force] <value>]"
1940 EQUB 0 2010 EQUB 0
1950 ALIGN 2020 ALIGN
1960 2030
1970 ; Initialisation code 2040 ; Initialisation code
1980.initialisation 2050.initialisation
1990 STMFD r13!, {r11, r14} ; Stack registers 2060 STMFD r13!, {r11, r14} ; Stack registers
2000 MOV r0, #6 ; Reason code to claim memory 2070 MOV r0, #6 ; Reason code to claim memory
2010 MOV r3, #ws_size ; The size of workspace required 2080 MOV r3, #ws_size ; The size of workspace required
2020 SWI "XOS_Module" ; Claim some module workspace 2090 SWI "XOS_Module" ; Claim some module workspace
2030 MOVVS r0, r11 ; Copy any error pointer 2100 MOVVS r11, r0 ; Copy any error pointer
2040 BVS fail_ws ; Fail if an error was produced 2110 BVS fail_ws ; Fail if an error was produced
2050 STR r2, [r12] ; Store workspace pointer 2120 STR r2, [r12] ; Store workspace pointer
2060 MOV r12, r2 ; Copy the workspace pointer 2130 MOV r12, r2 ; Copy the workspace pointer
2070 MOV r0, #0 ; Value to clear flags with 2140 MOV r0, #0 ; Value to clear flags with
2080 STR r0, [r12, #ws_internal] ; Clear the internal operation flag 2150 STR r0, [r12, #ws_internal] ; Clear the internal operation flag
2090 STRB r0, [r12, #ws_ptr_block]; Reason code to set pointer shape 2160 STRB r0, [r12, #ws_ptr_block]; Reason code to set pointer shape
2100 STRB r0, [r12, #ws_ptr_block_activex]; Store horizontal hotspot 2170 STRB r0, [r12, #ws_ptr_block_activex]; Store horizontal hotspot
2110 STRB r0, [r12, #ws_ptr_block_activey]; Store vertical hotspot 2180 STRB r0, [r12, #ws_ptr_block_activey]; Store vertical hotspot
2120 STR r0, [r12, #ws_filtn] ; Initially no wibble 2190 STR r0, [r12, #ws_filtn] ; Initially no wibble
2130 STR r0, [r12, #ws_filtv] ; Initially no wibble velocity 2200 STR r0, [r12, #ws_filtv] ; Initially no wibble velocity
2140 MOV r0, #5 ; The default configuration 2210 MOV r0, #5 ; The default configuration
2150 STR r0, [r12, #ws_friction] ; The default friction 2220 STR r0, [r12, #ws_friction] ; The default friction
2160 STR r0, [r12, #ws_spring] ; The default spring strength 2230 STR r0, [r12, #ws_spring] ; The default spring strength
2170 STR r0, [r12, #ws_force] ; The default force 2240 STR r0, [r12, #ws_force] ; The default force
2180 MVN r0, #&9f000 ; Initial centre row offset 2250 MVN r0, #&9f000 ; Initial centre row offset
2190 STR r0, [r12, #ws_cogr] ; Initial row offset to centre 2260 STR r0, [r12, #ws_cogr] ; Initial row offset to centre
2200 MVN r0, #&4a000 ; Initial centre column offset 2270 MVN r0, #&4a000 ; Initial centre column offset
2210 STR r0, [r12, #ws_cogc] ; Initial column offset to centre 2280 STR r0, [r12, #ws_cogc] ; Initial column offset to centre
2220 MOV r0, #ptr_unknown ; Most pointers are unknown initially 2290 MOV r0, #ptr_unknown ; Most pointers are unknown initially
2230 STRB r0, [r12, #ws_types] ; Shape 0 is not a pointer 2300 STRB r0, [r12, #ws_types] ; Shape 0 is not a pointer
2240 STRB r0, [r12, #ws_types + 2]; Shape 2 is unknown 2310 STRB r0, [r12, #ws_types + 2]; Shape 2 is unknown
2250 STRB r0, [r12, #ws_types + 3]; Shape 3 is unknown 2320 STRB r0, [r12, #ws_types + 3]; Shape 3 is unknown
2260 STRB r0, [r12, #ws_types + 4]; Shape 4 is unknown 2330 STRB r0, [r12, #ws_types + 4]; Shape 4 is unknown
2270 MOV r0, #ptr_single ; The standard desktop pointer 2340 MOV r0, #ptr_single ; The standard desktop pointer
2280 STRB r0, [r12, #ws_types + 1]; Assume shape 1 is the standard one 2350 STRB r0, [r12, #ws_types + 1]; Assume shape 1 is the standard one
2290 MOV r0, #8 ; Width of pointer in bytes 2360 MOV r0, #8 ; Width of pointer in bytes
2300 STRB r0, [r12, #ws_ptr_block_width]; Store width of pointer 2370 STRB r0, [r12, #ws_ptr_block_width]; Store width of pointer
2310 MOV r0, #32 ; Height of pointer in pixels 2380 MOV r0, #32 ; Height of pointer in pixels
2320 STRB r0, [r12, #ws_ptr_block_height]; Store height of pointer 2390 STRB r0, [r12, #ws_ptr_block_height]; Store height of pointer
2330 ADD r0, r12, #ws_ptr_data ; Pointer to pointer data 2400 ADD r0, r12, #ws_ptr_data ; Pointer to pointer data
2340 STR r0, [r12, #ws_ptr_block_data]; Store pointer to the data 2410 STR r0, [r12, #ws_ptr_block_data]; Store pointer to the data
2350 MOV r0, #21 ; Reason code to read pointer position 2420 MOV r0, #21 ; Reason code to read pointer position
2360 ADD r1, r12, #ws_buffer ; Pointer to a buffer 2430 ADD r1, r12, #ws_buffer ; Pointer to a buffer
2370 MOV r2, #6 ; Reason code to read pointer position 2440 MOV r2, #6 ; Reason code to read pointer position
2380 STRB r2, [r1] ; Store reason code in buffer 2450 STRB r2, [r1] ; Store reason code in buffer
2390 SWI "XOS_Word" ; Read pointer position 2460 SWI "XOS_Word" ; Read pointer position
2400 MOVVS r0, r11 ; Copy any error pointer 2470 MOVVS r11, r0 ; Copy any error pointer
2410 BVS fail_position ; Fail if an error was produced 2480 BVS fail_position ; Fail if an error was produced
2420 LDRB r2, [r1, #1] ; Read LSB of horizontal position 2490 LDRB r2, [r1, #1] ; Read LSB of horizontal position
2430 LDRB r3, [r1, #2] ; Read MSB of horizontal position 2500 LDRB r3, [r1, #2] ; Read MSB of horizontal position
2440 ORR r2, r2, r3, ASL#8 ; Combine horizontal position 2510 ORR r2, r2, r3, ASL#8 ; Combine horizontal position
2450 MOV r2, r2, ASL#16 ; Scale the horizontal position up 2520 MOV r2, r2, ASL#16 ; Scale the horizontal position up
2460 STR r2, [r12, #ws_hpos] ; Store the initial horizontal position 2530 STR r2, [r12, #ws_hpos] ; Store the initial horizontal position
2470 LDRB r2, [r1, #3] ; Read LSB of vertical position 2540 LDRB r2, [r1, #3] ; Read LSB of vertical position
2480 LDRB r3, [r1, #4] ; Read MSB of vertical position 2550 LDRB r3, [r1, #4] ; Read MSB of vertical position
2490 ORR r2, r2, r3, ASL#8 ; Combine vertical position 2560 ORR r2, r2, r3, ASL#8 ; Combine vertical position
2500 MOV r2, r2, ASL#16 ; Scale the vertical position up 2570 MOV r2, r2, ASL#16 ; Scale the vertical position up
2510 STR r2, [r12, #ws_vpos] ; Store the initial vertical position 2580 STR r2, [r12, #ws_vpos] ; Store the initial vertical position
2520 BL read_vdu ; Read the pixel scalings 2590 BL read_vdu ; Read the pixel scalings
2530 MOVVS r0, r11 ; Copy any error pointer 2600 MOVVS r11, r0 ; Copy any error pointer
2540 BVS fail_vdu ; Fail if an error was produced 2610 BVS fail_vdu ; Fail if an error was produced
2550 MOV r0, #&10 ; Number of the EventV vector 2620 MOV r0, #interval-1 ; Time interval of 'interval' centiseconds
2560 ADR r1, eventv_handler ; Address of the handler routine 2630 ADR r1, update ; Address of the update routine
2570 MOV r2, r12 ; Value of r12 used by the handler 2640 MOV r2, r12 ; Value of r12 used by the handler
2580 SWI "XOS_Claim" ; Claim the event vector 2650 SWI "XOS_CallEvery" ; Claim the event vector
2590 MOVVS r0, r11 ; Copy any error pointer 2660 MOVVS r11, r0 ; Copy any error pointer
2600 BVS fail_eventv ; Fail if an error was produced 2670 BVS fail_eventv ; Fail if an error was produced
2610 MOV r0, #&1f ; Number of the SpriteV vector 2680 MOV r0, #&1f ; Number of the SpriteV vector
2620 ADR r1, spritev_handler ; Address of the handler routine 2690 ADR r1, spritev_handler ; Address of the handler routine
2630 MOV r2, r12 ; Value of r12 used by the handler 2700 MOV r2, r12 ; Value of r12 used by the handler
2640 SWI "XOS_Claim" ; Claim the OS_SpriteOp vector 2710 SWI "XOS_Claim" ; Claim the OS_SpriteOp vector
2650 MOVVS r0, r11 ; Copy any error pointer 2720 MOVVS r11, r0 ; Copy any error pointer
2660 BVS fail_spritev ; Fail if an error was produced 2730 BVS fail_spritev ; Fail if an error was produced
2670 MOV r0, #&07 ; Number of the WordV vector 2740 MOV r0, #&07 ; Number of the WordV vector
2680 ADR r1, wordv_handler ; Address of the handler routine 2750 ADR r1, wordv_handler ; Address of the handler routine
2690 MOV r2, r12 ; Value of r12 used by the handler 2760 MOV r2, r12 ; Value of r12 used by the handler
2700 SWI "XOS_Claim" ; Claim the OS_Word vector 2770 SWI "XOS_Claim" ; Claim the OS_Word vector
2710 MOVVS r0, r11 ; Copy any error pointer 2780 MOVVS r11, r0 ; Copy any error pointer
2720 BVS fail_wordv ; Fail if an error was produced 2790 BVS fail_wordv ; Fail if an error was produced
2730 MOV r0, #14 ; OS_Byte code to enable an event 2800; MOV r0, #14 ; OS_Byte code to enable an event
2740 MOV r1, #4 ; The vsync event number 2810; MOV r1, #4 ; The vsync event number
2750 SWI "XOS_Byte" ; Enable the vertical sync event 2820; SWI "XOS_Byte" ; Enable the vertical sync event
2760 MOVVS r0, r11 ; Copy any error pointer 2830; MOVVS r11, r0 ; Copy any error pointer
2770 BVS fail_vsync ; Fail if an error was produced 2840; BVS fail_vsync ; Fail if an error was produced
2780 LDMFD r13!, {r11, pc} ; Return to RISC OS 2850 LDMFD r13!, {r11, pc} ; Return to RISC OS
2790 2860
2800 ; Finalisation code 2870 ; Finalisation code
2810.finalisation 2880.finalisation
2820 STMFD r13!, {r11, r14} ; Stack registers 2890 STMFD r13!, {r11, r14} ; Stack registers
2830 LDR r12, [r12] ; Obtain workspace pointer 2900 LDR r12, [r12] ; Obtain workspace pointer
2840 MOV r11, #0 ; Clear the error pointer 2910 MOV r11, #0 ; Clear the error pointer
2850 MOV r0, #13 ; OS_Byte code to disable an event 2920; MOV r0, #13 ; OS_Byte code to disable an event
2860 MOV r1, #4 ; The vsync event number 2930; MOV r1, #4 ; The vsync event number
2870 SWI "XOS_Byte" ; Disable the vertical sync event 2940; SWI "XOS_Byte" ; Disable the vertical sync event
2880 BVS exit ; Exit if an error was produced 2950 BVS exit ; Exit if an error was produced
2890.fail_vsync 2960.fail_vsync
2900 MOV r0, #&07 ; Number of the WordV vector 2970 MOV r0, #&07 ; Number of the WordV vector
2910 ADR r1, wordv_handler ; Address of the handler routine 2980 ADR r1, wordv_handler ; Address of the handler routine
2920 MOV r2, r12 ; Value of r12 used by the handler 2990 MOV r2, r12 ; Value of r12 used by the handler
2930 SWI "XOS_Release" ; Release the OS_Word vector 3000 SWI "XOS_Release" ; Release the OS_Word vector
2940 BVS exit ; Exit if an error was produced 3010 BVS exit ; Exit if an error was produced
2950.fail_wordv 3020.fail_wordv
2960 MOV r0, #&1f ; Number of the SpriteV vector 3030 MOV r0, #&1f ; Number of the SpriteV vector
2970 ADR r1, spritev_handler ; Address of the handler routine 3040 ADR r1, spritev_handler ; Address of the handler routine
2980 MOV r2, r12 ; Value of r12 used by the handler 3050 MOV r2, r12 ; Value of r12 used by the handler
2990 SWI "XOS_Release" ; Release the OS_SpriteOp vector 3060 SWI "XOS_Release" ; Release the OS_SpriteOp vector
3000 BVS exit ; Exit if an error was produced 3070 BVS exit ; Exit if an error was produced
3010.fail_spritev 3080.fail_spritev
3020 MOV r0, #&10 ; Number of the EventV vector 3090 ADR r0, update ; Address of the update routine
3030 ADR r1, eventv_handler ; Address of the handler routine 3100 MOV r1, r12 ; Value of r12 used by the handler
3040 MOV r2, r12 ; Value of r12 used by the handler 3110 SWI "XOS_RemoveTickerEvent" ; Remove the ticker event
3050 SWI "XOS_Release" ; Release the event vector
3060 BVS exit ; Exit if an error was produced 3120 BVS exit ; Exit if an error was produced
3070.fail_eventv 3130.fail_eventv
3080.fail_vdu 3140.fail_vdu
3090.fail_position 3150.fail_position
3100 MOV r0, #7 ; Reason code to release memory 3160 MOV r0, #7 ; Reason code to release memory
3110 MOV r2, r12 ; Copy the workspace pointer 3170 MOV r2, r12 ; Copy the workspace pointer
3120 SWI "XOS_Module" ; Release the workspace 3180 SWI "XOS_Module" ; Release the workspace
3130 BVS exit ; Exit if an error was produced 3190 BVS exit ; Exit if an error was produced
3140.fail_ws 3200.fail_ws
3150 TEQ r11, #0 ; Is there an error pointer 3210 TEQ r11, #0 ; Is there an error pointer
3160 BEQ exit ; Exit without error if not 3220 BEQ exit ; Exit without error if not
3170 MOV r0, r11 ; Copy the error pointer 3230 MOV r0, r11 ; Copy the error pointer
3180 CMP pc, #&80000000 ; Set the overflow flag 3240 CMP pc, #&80000000 ; Set the overflow flag
3190.exit LDMFD r13!, {r11, pc} ; Return to RISC OS 3250.exit LDMFD r13!, {r11, pc} ; Return to RISC OS
3200 3260
3210 ; Service call handler 3270 ; Service call handler
3220.service 3280.service
3230 TEQ r1, #&46 ; Service_ModeChange 3290 TEQ r1, #&46 ; Service_ModeChange
3240 MOVNES pc, r14 ; Reject unrecognised calls quickly 3300 MOVNES pc, r14 ; Reject unrecognised calls quickly
3250 LDR r12, [r12] ; Obtain workspace pointer 3310 LDR r12, [r12] ; Obtain workspace pointer
3260 TEQ r1, #&46 ; Service_ModeChange 3320 TEQ r1, #&46 ; Service_ModeChange
3270 BEQ service_mode_change ; Jump to handler for mode changes 3330 BEQ service_mode_change ; Jump to handler for mode changes
3280 3340
3290 ; Handle mode changes 3350 ; Handle mode changes
3300.service_mode_change 3360.service_mode_change
3310 STMFD r13!, {r14} ; Stack registers 3370 STMFD r13!, {r14} ; Stack registers
3320 BL read_vdu ; Read the pixel scaling 3380 BL read_vdu ; Read the pixel scaling
3330 LDMFD r13!, {pc}^ ; Return from service call 3390 LDMFD r13!, {pc}^ ; Return from service call
3340 3400
3350 ; Read the pixel scalings 3410 ; Read the pixel scalings
3360.read_vdu 3420.read_vdu
3370 STMFD r13!, {r0-r3, r14} ; Stack registers 3430 STMFD r13!, {r0-r3, r14} ; Stack registers
3380 MVN r0, #0 ; Read variables for current mode 3440 MVN r0, #0 ; Read variables for current mode
3390 MOV r1, #4 ; Variable number for XEigFactor 3450 MOV r1, #4 ; Variable number for XEigFactor
3400 SWI "XOS_ReadModeVariable" ; Read the XEigFactor value 3460 SWI "XOS_ReadModeVariable" ; Read the XEigFactor value
3410 MOV r3, r2 ; Copy the XEigFactor value 3470 MOV r3, r2 ; Copy the XEigFactor value
3420 MOV r1, #5 ; Variable number for YEigFactor 3480 MOV r1, #5 ; Variable number for YEigFactor
3430 SWI "XOS_ReadModeVariable" ; Read the YEigFactor value 3490 SWI "XOS_ReadModeVariable" ; Read the YEigFactor value
3440 MOV r0, #0 ; Initialise the common eigen value 3500 MOV r0, #0 ; Initialise the common eigen value
3450.read_vdu_loop 3510.read_vdu_loop
3460 TEQ r2, #0 ; Is the YEigFactor zero 3520 TEQ r2, #0 ; Is the YEigFactor zero
3470 TEQNE r3, #0 ; Is the XEigFactor zero 3530 TEQNE r3, #0 ; Is the XEigFactor zero
3480 BEQ read_vdu_done ; Exit loop if common component removed 3540 BEQ read_vdu_done ; Exit loop if common component removed
3490 ADD r0, r0, #1 ; Increment common component 3550 ADD r0, r0, #1 ; Increment common component
3500 SUB r2, r2, #1 ; Decrement YEigFactor 3560 SUB r2, r2, #1 ; Decrement YEigFactor
3510 SUB r3, r3, #1 ; Decrement XEigFactor 3570 SUB r3, r3, #1 ; Decrement XEigFactor
3520 B read_vdu_loop ; Keep looping until finished 3580 B read_vdu_loop ; Keep looping until finished
3530.read_vdu_done 3590.read_vdu_done
3540 STR r0, [r12, #ws_ceig] ; Store the common eigen value 3600 STR r0, [r12, #ws_ceig] ; Store the common eigen value
3550 STR r3, [r12, #ws_xeig] ; Store the adjusted XEigFactor 3610 STR r3, [r12, #ws_xeig] ; Store the adjusted XEigFactor
3560 STR r2, [r12, #ws_yeig] ; Store the adjusted YEigFactor 3620 STR r2, [r12, #ws_yeig] ; Store the adjusted YEigFactor
3570 LDMFD r13!, {r0-r3, pc}^ ; Return from subroutine 3630 LDMFD r13!, {r0-r3, pc}^ ; Return from subroutine
3580 3640
3590 ; EventV handler routine 3650 ; EventV handler routine
3600.eventv_handler 3660.eventv_handler
3610 STMFD r13!, {r8-r9, r14} ; Stack registers 3670; STMFD r13!, {r8-r9, r14} ; Stack registers
3620 MOV r9, pc ; Save the current status and mode 3680; MOV r9, pc ; Save the current status and mode
3630 ORR r8, r9, #3 ; Derive the SVC-mode version 3690; ORR r8, r9, #3 ; Derive the SVC-mode version
3640 TEQP r8, #0 ; Enter SVC mode 3700; TEQP r8, #0 ; Enter SVC mode
3650 MOV r0, r0 ; Allow the processor to adapt 3710; MOV r0, r0 ; Allow the processor to adapt
3660 STMFD r13!, {r14} ; Save r14_svc 3720; STMFD r13!, {r14} ; Save r14_svc
3670 BL update ; Update the pointer shape 3730; BL update ; Update the pointer shape
3680 LDMFD r13!, {r14} ; Restore r14_svc 3740; LDMFD r13!, {r14} ; Restore r14_svc
3690 TEQP r9, #0 ; Reenter the original processor mode 3750; TEQP r9, #0 ; Reenter the original processor mode
3700 MOV r0, r0 ; Allow the processor to adapt again 3760; MOV r0, r0 ; Allow the processor to adapt again
3710 LDMFD r13!, {r8-r9, pc}^ ; Pass on the call 3770; LDMFD r13!, {r8-r9, pc}^ ; Pass on the call
3720 3780
3730 ; SpriteV handler routine 3790 ; SpriteV handler routine
3740.spritev_handler 3800.spritev_handler
3750 STMFD r13!, {r2, r8-r11, r14} ; Stack registers 3810 STMFD r13!, {r2, r8-r11, r14} ; Stack registers
3760 AND r8, r0, #&ff ; Mask out the reason code 3820 AND r8, r0, #&ff ; Mask out the reason code
3770 TEQ r8, #36 ; Reason code to set the pointer shape 3830 TEQ r8, #36 ; Reason code to set the pointer shape
3780 BNE spritev_handler_done ; Not interested in other reason codes 3840 BNE spritev_handler_done ; Not interested in other reason codes
3790 TST r3, #&10 ; Is the shape being changed 3850 TST r3, #&10 ; Is the shape being changed
3800 BNE spritev_handler_done ; Not interested otherwise 3860 BNE spritev_handler_done ; Not interested otherwise
3810 AND r8, r0, #&300 ; Get register interpretation 3870 AND r8, r0, #&300 ; Get register interpretation
3820 TEQ r8, #512 ; Is it a pointer to the sprite 3880 TEQ r8, #512 ; Is it a pointer to the sprite
3830 ADDEQ r2, r2, #4 ; Advance pointer to the name 3890 ADDEQ r2, r2, #4 ; Advance pointer to the name
3840 ADR r8, pointers_start ; Pointer to the first reference name 3900 ADR r8, pointers_start ; Pointer to the first reference name
3850.spritev_handler_loop 3910.spritev_handler_loop
3860 MOV r9, #0 ; Check from the first character 3920 MOV r9, #0 ; Check from the first character
3870.spritev_handler_char 3930.spritev_handler_char
3880 LDRB r10, [r2, r9] ; Read pointer name character 3940 LDRB r10, [r2, r9] ; Read pointer name character
3890 LDRB r11, [r8, r9] ; Read reference name character 3950 LDRB r11, [r8, r9] ; Read reference name character
3900 TEQ r11, #0 ; Is it the end of the reference 3960 TEQ r11, #0 ; Is it the end of the reference
3910 BEQ spritev_handler_found ; Complete match if it is 3970 BEQ spritev_handler_found ; Complete match if it is
3920 TEQ r10, r11 ; Do the characters match 3980 TEQ r10, r11 ; Do the characters match
3930 BNE spritev_handler_next ; Skip to the next reference if not 3990 BNE spritev_handler_next ; Skip to the next reference if not
3940 ADD r9, r9, #1 ; Advance to the next character 4000 ADD r9, r9, #1 ; Advance to the next character
3950 TEQ r9, #12 ; Maximum length is twelve characters 4010 TEQ r9, #12 ; Maximum length is twelve characters
3960 BEQ spritev_handler_found ; All matched if reached this point 4020 BEQ spritev_handler_found ; All matched if reached this point
3970 B spritev_handler_char ; Loop for the next character 4030 B spritev_handler_char ; Loop for the next character
3980.spritev_handler_next 4040.spritev_handler_next
3990 ADD r8, r8, #16 ; Advance to the next record 4050 ADD r8, r8, #16 ; Advance to the next record
4000 ADR r9, pointers_end ; Pointer to the end of the list 4060 ADR r9, pointers_end ; Pointer to the end of the list
4010 TEQ r8, r9 ; Has the end been reached 4070 TEQ r8, r9 ; Has the end been reached
4020 BNE spritev_handler_loop ; There is another name to check 4080 BNE spritev_handler_loop ; There is another name to check
4030 MOV r2, #0 ; No matching pointer name 4090 MOV r2, #0 ; No matching pointer name
4040.spritev_handler_checked 4100.spritev_handler_checked
4050 AND r8, r3, #&f ; Extract the pointer number 4110 AND r8, r3, #&f ; Extract the pointer number
4060 ADD r8, r8, #ws_types ; Offset to type details 4120 ADD r8, r8, #ws_types ; Offset to type details
4070 STRB r2, [r12, r8] ; Store the pointer type 4130 STRB r2, [r12, r8] ; Store the pointer type
4080 TEQ r2, #0 ; Was a pointer match found 4140 TEQ r2, #0 ; Was a pointer match found
4090 ORRNE r3, r3, #&10 ; Clear the shape definition flag 4150 ORRNE r3, r3, #&10 ; Clear the shape definition flag
4100.spritev_handler_done 4160.spritev_handler_done
4110 LDMFD r13!, {r2, r8-r11, pc}^ ; Pass on to the original routine 4170 LDMFD r13!, {r2, r8-r11, pc}^ ; Pass on to the original routine
4120.spritev_handler_found 4180.spritev_handler_found
4130 LDR r2, [r8, #12] ; Read the pointer index 4190 LDR r2, [r8, #12] ; Read the pointer index
4140 B spritev_handler_checked ; Handle the match 4200 B spritev_handler_checked ; Handle the match
4150 4210
4160 ; Known pointer names 4220 ; Known pointer names
4170.pointers_start 4230.pointers_start
4180 FNpointer("ptr_default", ptr_single) 4240 FNpointer("ptr_default", ptr_single)
4190 FNpointer("ptr_double", ptr_double) 4250 FNpointer("ptr_double", ptr_double)
4200 FNpointer("ptr_write", ptr_caret) 4260 FNpointer("ptr_write", ptr_caret)
4210 FNpointer("ptr_caret", ptr_caret) 4270 FNpointer("ptr_caret", ptr_caret)
4220 FNpointer("idc_ibeam", ptr_caret) 4280 FNpointer("idc_ibeam", ptr_caret)
4230 FNpointer("ptr_menu", ptr_menu) 4290 FNpointer("ptr_menu", ptr_menu)
4240.pointers_end 4300.pointers_end
4250 4310
4260 ; WordV handler routine 4320 ; WordV handler routine
4270.wordv_handler 4330.wordv_handler
4280 TEQ r0, #21 ; The reason code for pointer operations 4340 TEQ r0, #21 ; The reason code for pointer operations
4290 MOVNES pc, r14 ; Pass on other reason codes 4350 MOVNES pc, r14 ; Pass on other reason codes
4300 STMFD r13!, {r0-r1, r14} ; Stack registers 4360 STMFD r13!, {r0-r1, r14} ; Stack registers
4310 LDRB r0, [r1] ; Get the sub reason code 4370 LDRB r0, [r1] ; Get the sub reason code
4320 TEQ r0, #0 ; Reason code to define the pointer 4380 TEQ r0, #0 ; Reason code to define the pointer
4330 BNE wordv_handler_done ; Not interested in other reason codes 4390 BNE wordv_handler_done ; Not interested in other reason codes
4340 LDR r0, [r12, #ws_internal] ; Read the internal flag 4400 LDR r0, [r12, #ws_internal] ; Read the internal flag
4350 TEQ r0, #0 ; Is it an internal operation 4410 TEQ r0, #0 ; Is it an internal operation
4360 BNE wordv_handler_done ; Skip the next bit if it is 4420 BNE wordv_handler_done ; Skip the next bit if it is
4370 LDRB r0, [r1, #1] ; Read the shape number 4430 LDRB r0, [r1, #1] ; Read the shape number
4380 ADD r0, r0, #ws_types ; Offset to type details 4440 ADD r0, r0, #ws_types ; Offset to type details
4390 MOV r1, #ptr_unknown ; Code for an unknown pointer type 4450 MOV r1, #ptr_unknown ; Code for an unknown pointer type
4400 STRB r1, [r12, r0] ; Set this pointer type to unknown 4460 STRB r1, [r12, r0] ; Set this pointer type to unknown
4410.wordv_handler_done 4470.wordv_handler_done
4420 LDMFD r13!, {r0-r1, pc}^ ; Pass on the call 4480 LDMFD r13!, {r0-r1, pc}^ ; Pass on the call
4430 4490
4440 ; Update the shape of the mouse pointer 4500 ; Update the shape of the mouse pointer
4450.update STMFD r13!, {r0-r5, r14} ; Stack registers 4510.update STMFD r13!, {r0-r5, r14} ; Stack registers
4460 MOV r0, #106 ; Reason code to read pointer shape 4520 MOV r0, #106 ; Reason code to read pointer shape
4470 MOV r1, #&7f ; Invalid shape number to force read 4530 MOV r1, #&7f ; Invalid shape number to force read
4480 SWI "XOS_Byte" ; Read the current pointer shape number 4540 SWI "XOS_Byte" ; Read the current pointer shape number
4490 BVS update_done ; No update pointer if error produced 4550 BVS update_done ; No update pointer if error produced
4500 STRB r1, [r12, #ws_ptr_block_shape]; Store the pointer shape 4560 STRB r1, [r12, #ws_ptr_block_shape]; Store the pointer shape
4510 TST r1, #&80 ; Is the pointer linked 4570 TST r1, #&80 ; Is the pointer linked
4520 BNE update_done ; No update if not 4580 BNE update_done ; No update if not
4530 ADD r1, r1, #ws_types ; Offset to type details 4590 ADD r1, r1, #ws_types ; Offset to type details
4540 LDRB r3, [r12, r1] ; Discover the type of pointer required 4600 LDRB r3, [r12, r1] ; Discover the type of pointer required
4550 MOV r0, #21 ; Reason code to read pointer position 4610 MOV r0, #21 ; Reason code to read pointer position
4560 ADD r1, r12, #ws_buffer ; Pointer to a buffer 4620 ADD r1, r12, #ws_buffer ; Pointer to a buffer
4570 MOV r2, #6 ; Reason code to read pointer position 4630 MOV r2, #6 ; Reason code to read pointer position
4580 STRB r2, [r1] ; Store reason code in buffer 4640 STRB r2, [r1] ; Store reason code in buffer
4590 SWI "XOS_Word" ; Read pointer position 4650 SWI "XOS_Word" ; Read pointer position
4600 BVS update_done ; No update pointer if error produced 4660 BVS update_done ; No update pointer if error produced
4610 MOV r0, r3 ; Copy pointer shape type 4670 MOV r0, r3 ; Copy pointer shape type
4620 LDRB r4, [r1, #1] ; Read LSB of horizontal position 4680 LDRB r4, [r1, #1] ; Read LSB of horizontal position
4630 LDRB r5, [r1, #2] ; Read MSB of horizontal position 4690 LDRB r5, [r1, #2] ; Read MSB of horizontal position
4640 ORR r4, r4, r5, ASL#8 ; Combine horizontal position 4700 ORR r4, r4, r5, ASL#8 ; Combine horizontal position
4650 MOV r4, r4, ASL#16 ; Scale the horizontal position up 4710 MOV r4, r4, ASL#16 ; Scale the horizontal position up
4660 LDR r5, [r12, #ws_hpos] ; Read previous horizontal position 4720 LDR r5, [r12, #ws_hpos] ; Read previous horizontal position
4670 SUB r2, r4, r5 ; Calculate horizontal movement 4730 SUB r2, r4, r5 ; Calculate horizontal movement
4680 MOV r2, r2, ASR#1 ; Reduce the horizontal position 4740 MOV r2, r2, ASR#1 ; Reduce the horizontal position
4690 ADD r4, r5, r2 ; And modify the last known position 4750 ADD r4, r5, r2 ; And modify the last known position
4700 LDRB r3, [r1, #3] ; Read LSB of vertical position 4760 LDRB r3, [r1, #3] ; Read LSB of vertical position
4710 LDRB r5, [r1, #4] ; Read MSB of vertical position 4770 LDRB r5, [r1, #4] ; Read MSB of vertical position
4720 ORR r3, r3, r5, ASL#8 ; Combine vertical position 4780 ORR r3, r3, r5, ASL#8 ; Combine vertical position
4730 MOV r3, r3, ASL#16 ; Scale the vertical position up 4790 MOV r3, r3, ASL#16 ; Scale the vertical position up
4740 LDR r5, [r12, #ws_vpos] ; Read previous vertical position 4800 LDR r5, [r12, #ws_vpos] ; Read previous vertical position
4750 SUB r1, r5, r3 ; Calculate vertical movement 4810 SUB r1, r5, r3 ; Calculate vertical movement
4760 MOV r1, r1, ASR#1 ; Reduce the vertical movement 4820 MOV r1, r1, ASR#1 ; Reduce the vertical movement
4770 SUB r3, r5, r1 ; And modify the last known position 4830 SUB r3, r5, r1 ; And modify the last known position
4780 STR r3, [r12, #ws_vpos] ; Store the updated vertical position 4840 STR r3, [r12, #ws_vpos] ; Store the updated vertical position
4790 STR r4, [r12, #ws_hpos] ; Store the updated horizontal position 4850 STR r4, [r12, #ws_hpos] ; Store the updated horizontal position
4800 LDR r3, [r12, #ws_ceig] ; Read the common eigen value 4860 LDR r3, [r12, #ws_ceig] ; Read the common eigen value
4810 MOV r4, #1 ; Value to be shifted 4870 MOV r4, #1 ; Value to be shifted
4820 MOV r4, r4, ASL r3 ; The eigen value 4880 MOV r4, r4, ASL r3 ; The eigen value
4830 ADD r1, r1, r4, ASR#1 ; Improve vertical movement rounding 4890 ADD r1, r1, r4, ASR#1 ; Improve vertical movement rounding
4840 ADD r2, r2, r4, ASR#1 ; Improve horizontal movement rounding 4900 ADD r2, r2, r4, ASR#1 ; Improve horizontal movement rounding
4850 MOV r1, r1, ASR r3 ; Scale the vertical movement 4910 MOV r1, r1, ASR r3 ; Scale the vertical movement
4860 MOV r2, r2, ASR r3 ; Scale the horizontal movement 4920 MOV r2, r2, ASR r3 ; Scale the horizontal movement
4870 ADR r14, update_plot ; Return address to update pointer 4930 ADR r14, update_plot ; Return address to update pointer
4880 ADD pc, pc, r0, LSL#2 ; Jump to the relevant routine 4940 ADD pc, pc, r0, LSL#2 ; Jump to the relevant routine
4890 MOV r0, r0 ; This instruction is never executed 4950 MOV r0, r0 ; This instruction is never executed
4900 B update_done ; Shape 0 is unknown 4960 B update_done ; Shape 0 is unknown
4910 B update_single ; Shape 1 is a single pointer 4970 B update_single ; Shape 1 is a single pointer
4920 B update_double ; Shape 2 is a double click pointer 4980 B update_double ; Shape 2 is a double click pointer
4930 B update_write ; Shape 3 is a caret or writable icon 4990 B update_write ; Shape 3 is a caret or writable icon
4940 B update_menu ; Shape 4 is a popup menu icon 5000 B update_menu ; Shape 4 is a popup menu icon
4950.update_plot 5010.update_plot
4960 MOV r0, #21 ; Reason code to set pointer shape 5020 MOV r0, #21 ; Reason code to set pointer shape
4970 ADD r1, r12, #ws_ptr_block ; Pointer to parameter block 5030 ADD r1, r12, #ws_ptr_block ; Pointer to parameter block
4980 STR r0, [r12, #ws_internal] ; Set the internal flag 5040 STR r0, [r12, #ws_internal] ; Set the internal flag
4990 SWI "XOS_Word" ; Define the pointer 5050 SWI "XOS_Word" ; Define the pointer
5000 BVS update_done ; Skip the rest in an error produced 5060 BVS update_done ; Skip the rest in an error produced
5010 MOV r0, #106 ; Reason code to select pointer 5070 MOV r0, #106 ; Reason code to select pointer
5020 LDRB r1, [r12, #ws_ptr_block_shape]; Get the shape number 5080 LDRB r1, [r12, #ws_ptr_block_shape]; Get the shape number
5030 SWI "XOS_Byte" ; Refresh the pointer 5090 SWI "XOS_Byte" ; Refresh the pointer
5040.update_done 5100.update_done
5050 MOV r0, #0 ; Value to clear the flag with 5110 MOV r0, #0 ; Value to clear the flag with
5060 STR r0, [r12, #ws_internal] ; Clear the internal flag 5120 STR r0, [r12, #ws_internal] ; Clear the internal flag
5070 LDMFD r13!, {r0-r5, pc}^ ; Return from the subroutine 5130 LDMFD r13!, {r0-r5, pc}^ ; Return from the subroutine
5080 5140
5090 ; Generate a standard pointer shape that has moved by (r2, r1) 5150 ; Generate a standard pointer shape that has moved by (r2, r1)
5100.update_standard 5160.update_standard
5110 STMFD r13!, {r0, r3-r8, r14} ; Stack registers 5170 STMFD r13!, {r0, r3-r8, r14} ; Stack registers
5120 LDR r5, [r12, #ws_cogr] ; Read previous row pointer centre 5180 LDR r5, [r12, #ws_cogr] ; Read previous row pointer centre
5130 LDR r6, [r12, #ws_cogc] ; Read previous column pointer centre 5190 LDR r6, [r12, #ws_cogc] ; Read previous column pointer centre
5140 MOV r7, #0 ; Start by assuming no movement 5200 MOV r7, #0 ; Start by assuming no movement
5150 TEQ r1, #0 ; Is there any row motion 5210 TEQ r1, #0 ; Is there any row motion
5160 TEQEQ r2, #0 ; Is there any column motion 5220 TEQEQ r2, #0 ; Is there any column motion
5170 BEQ update_standard_still ; Do not change direction if still 5230 BEQ update_standard_still ; Do not change direction if still
5180 ADD r5, r5, r1 ; Calculate the new row offset 5240 ADD r5, r5, r1 ; Calculate the new row offset
5190 ADD r6, r6, r2 ; Calculate the new column offset 5250 ADD r6, r6, r2 ; Calculate the new column offset
5200 MOV r0, r5, ASR#8 ; Scale the new row offset 5260 MOV r0, r5, ASR#8 ; Scale the new row offset
5210 MUL r1, r0, r0 ; Square the new row offset 5270 MUL r1, r0, r0 ; Square the new row offset
5220 MOV r0, r6, ASR#8 ; Scale the new column offset 5280 MOV r0, r6, ASR#8 ; Scale the new column offset
5230 MUL r2, r0, r0 ; Square the new column offset 5290 MUL r2, r0, r0 ; Square the new column offset
5240 ADD r0, r1, r2 ; Sum the squares 5300 ADD r0, r1, r2 ; Sum the squares
5250 BL sqrt ; Calculate the new tail length 5310 BL sqrt ; Calculate the new tail length
5260 MOV r0, r0, ASL#8 ; Scale the new length back up 5320 MOV r0, r0, ASL#8 ; Scale the new length back up
5270 SUB r7, r0, #11<<16 ; Subtract the nominal length 5330 SUB r7, r0, #11<<16 ; Subtract the nominal length
5280 MOV r0, r5 ; Copy the new row offset 5340 MOV r0, r5 ; Copy the new row offset
5290 MOV r1, r6 ; Copy the new column offset 5350 MOV r1, r6 ; Copy the new column offset
5300 BL normalise ; Normalise the offset length 5360 BL normalise ; Normalise the offset length
5310 MOV r2, #11 ; The required tail mass length 5370 MOV r2, #11 ; The required tail mass length
5320 MUL r5, r2, r0 ; The scaled row offset 5380 MUL r5, r2, r0 ; The scaled row offset
5330 MUL r6, r2, r1 ; The scaled column offset 5390 MUL r6, r2, r1 ; The scaled column offset
5340 STR r5, [r12, #ws_cogr] ; Store the updated row centre 5400 STR r5, [r12, #ws_cogr] ; Store the updated row centre
5350 STR r6, [r12, #ws_cogc] ; Store the updated column centre 5410 STR r6, [r12, #ws_cogc] ; Store the updated column centre
5360.update_standard_still 5420.update_standard_still
5370 MOV r0, r7, ASR#3 ; Copy and scale the length offset 5430 MOV r0, r7, ASR#3 ; Copy and scale the length offset
5380 BL update_filter ; Update the pointer wibble 5440 BL update_filter ; Update the pointer wibble
5390 ADD r0, r0, r0, ASL#2 ; Multiply the length offset by 5 5450 ADD r0, r0, r0, ASL#2 ; Multiply the length offset by 5
5400 MOV r7, #11<<16 ; The nominal tail length 5460 MOV r7, #11<<16 ; The nominal tail length
5410 ADD r7, r7, r0 ; Add the wibble to the tail length 5470 ADD r7, r7, r0 ; Add the wibble to the tail length
5420 MOV r0, #7 ; Number of coordinates in pointer shape 5480 MOV r0, #7 ; Number of coordinates in pointer shape
5430 ADR r1, update_standard_basic; Pointer to the basic shape 5490 ADR r1, update_standard_basic; Pointer to the basic shape
5440 ADR r2, update_standard_length; Pointer to the length adjustment 5500 ADR r2, update_standard_length; Pointer to the length adjustment
5450 MOV r3, r7 ; Copy the required head length 5510 MOV r3, r7 ; Copy the required head length
5460 ADD r4, r12, #ws_buffer ; Pointer to the destination buffer 5520 ADD r4, r12, #ws_buffer ; Pointer to the destination buffer
5470 BL trans_add ; Set the required head length 5530 BL trans_add ; Set the required head length
5480 MOV r1, r4 ; New source buffer is previous output 5540 MOV r1, r4 ; New source buffer is previous output
5490 ADR r2, update_standard_tail; Pointer to tail width adjustment 5550 ADR r2, update_standard_tail; Pointer to tail width adjustment
5500 STMFD r13!, {r0-r1} ; Stack registers 5560 STMFD r13!, {r0-r1} ; Stack registers
5510 MOV r0, #100<<16 ; Area to divide by the length 5570 MOV r0, #100<<16 ; Area to divide by the length
5520 MOV r1, r7, ASR#16 ; Scale the tail length 5580 MOV r1, r7, ASR#16 ; Scale the tail length
5530 RSB r1, r1, #21 ; Calculate the tail length 5590 RSB r1, r1, #21 ; Calculate the tail length
5540 BL divide ; Calculate the tail width offset 5600 BL divide ; Calculate the tail width offset
5550 MOV r3, r0 ; Copy the tail width offset 5610 MOV r3, r0 ; Copy the tail width offset
5560 LDMFD r13!, {r0-r1} ; Restore registers 5620 LDMFD r13!, {r0-r1} ; Restore registers
5570 BL trans_add ; Set the width of the tail base 5630 BL trans_add ; Set the width of the tail base
5580 ADR r2, update_standard_head; Pointer to head width adjustment 5640 ADR r2, update_standard_head; Pointer to head width adjustment
5590 STMFD r13!, {r0-r1} ; Stack registers 5650 STMFD r13!, {r0-r1} ; Stack registers
5600 MOV r0, #132<<16 ; Area to divide by the length 5660 MOV r0, #132<<16 ; Area to divide by the length
5610 MOV r1, r7, ASR#16 ; Scale the tail length 5670 MOV r1, r7, ASR#16 ; Scale the tail length
5620 BL divide ; Calculate the head width offset 5680 BL divide ; Calculate the head width offset
5630 MOV r3, r0 ; Copy the head width offset 5690 MOV r3, r0 ; Copy the head width offset
5640 LDMFD r13!, {r0-r1} ; Restore registers 5700 LDMFD r13!, {r0-r1} ; Restore registers
5650 BL trans_add ; Set the width of the header base 5710 BL trans_add ; Set the width of the header base
5660 MOV r2, r1 ; Destination coordinates are the same 5720 MOV r2, r1 ; Destination coordinates are the same
5670 MOV r3, r5 ; Row component of desired vertical 5730 MOV r3, r5 ; Row component of desired vertical
5680 MOV r4, r6 ; Column component of desired vertical 5740 MOV r4, r6 ; Column component of desired vertical
5690 BL trans_rotate ; Rotate the pointer as required 5750 BL trans_rotate ; Rotate the pointer as required
5700 BL trans_fit ; Scale the coordinates for the pointer 5760 BL trans_fit ; Scale the coordinates for the pointer
5710 MOV r1, r0 ; Copy the number of points 5770 MOV r1, r0 ; Copy the number of points
5720 LDMFD r13!, {r0, r3-r8, pc} ; Return from subroutine 5780 LDMFD r13!, {r0, r3-r8, pc} ; Return from subroutine
5730.update_standard_basic ; The basic pointer shape 5790.update_standard_basic ; The basic pointer shape
5740 FNcoordinate(0, 0) 5800 FNcoordinate(0, 0)
5750 FNcoordinate(0, 0) 5810 FNcoordinate(0, 0)
5760 FNcoordinate(0, 2) 5820 FNcoordinate(0, 2)
5770 FNcoordinate(21, -2) 5830 FNcoordinate(21, -2)
5780 FNcoordinate(21, 2) 5840 FNcoordinate(21, 2)
5790 FNcoordinate(0, -2) 5850 FNcoordinate(0, -2)
5800 FNcoordinate(0, 0) 5860 FNcoordinate(0, 0)
5810.update_standard_length ; Offsets to change the head length 5870.update_standard_length ; Offsets to change the head length
5820 FNcoordinate(0, 0) 5880 FNcoordinate(0, 0)
5830 FNcoordinate(1, 0) 5890 FNcoordinate(1, 0)
5840 FNcoordinate(1, 0) 5900 FNcoordinate(1, 0)
5850 FNcoordinate(0, 0) 5910 FNcoordinate(0, 0)
5860 FNcoordinate(0, 0) 5920 FNcoordinate(0, 0)
5870 FNcoordinate(1, 0) 5930 FNcoordinate(1, 0)
5880 FNcoordinate(1, 0) 5940 FNcoordinate(1, 0)
5890.update_standard_tail ; Offsets to change the tail width 5950.update_standard_tail ; Offsets to change the tail width
5900 FNcoordinate(0, 0) 5960 FNcoordinate(0, 0)
5910 FNcoordinate(0, 0) 5970 FNcoordinate(0, 0)
5920 FNcoordinate(0, 0) 5980 FNcoordinate(0, 0)
5930 FNcoordinate(0, 0.5) 5990 FNcoordinate(0, 0.5)
5940 FNcoordinate(0, -0.5) 6000 FNcoordinate(0, -0.5)
5950 FNcoordinate(0, 0) 6010 FNcoordinate(0, 0)
5960 FNcoordinate(0, 0) 6020 FNcoordinate(0, 0)
5970.update_standard_head ; Offsets to change the head width 6030.update_standard_head ; Offsets to change the head width
5980 FNcoordinate(0, 0) 6040 FNcoordinate(0, 0)
5990 FNcoordinate(0, 0.5) 6050 FNcoordinate(0, 0.5)
6000 FNcoordinate(0, 0) 6060 FNcoordinate(0, 0)
6010 FNcoordinate(0, 0) 6070 FNcoordinate(0, 0)
6020 FNcoordinate(0, 0) 6080 FNcoordinate(0, 0)
6030 FNcoordinate(0, 0) 6090 FNcoordinate(0, 0)
6040 FNcoordinate(0, -0.5) 6100 FNcoordinate(0, -0.5)
6050 6110
6060 ; Plot a single pointer type r0 that has moved by (r2, r1) 6120 ; Plot a single pointer type r0 that has moved by (r2, r1)
6070.update_single 6130.update_single
6080 STMFD r13!, {r0-r2, r14} ; Stack registers 6140 STMFD r13!, {r0-r2, r14} ; Stack registers
6090 BL update_standard ; Construct the pointer shape 6150 BL update_standard ; Construct the pointer shape
6100 MOV r0, #colour_trans ; Background is transparent 6160 MOV r0, #colour_trans ; Background is transparent
6110 BL plot_fill ; Clear the pointer initially 6170 BL plot_fill ; Clear the pointer initially
6120 MOV r0, #colour_blue ; Fill the interior with solid blue 6180 MOV r0, #colour_blue ; Fill the interior with solid blue
6130 BL plot_poly_fill ; Plot the filled interior 6190 BL plot_poly_fill ; Plot the filled interior
6140 MOV r0, #colour_cyan ; Outline the pointer in cyan 6200 MOV r0, #colour_cyan ; Outline the pointer in cyan
6150 BL plot_poly_line ; Plot the pointer outline 6210 BL plot_poly_line ; Plot the pointer outline
6160 LDMFD r13!, {r0-r2, pc} ; Return from subroutine 6220 LDMFD r13!, {r0-r2, pc} ; Return from subroutine
6170 6230
6180 ; Plot a double click pointer type r0 that has moved by (r2, r1) 6240 ; Plot a double click pointer type r0 that has moved by (r2, r1)
6190.update_double 6250.update_double
6200 STMFD r13!, {r0-r2, r14} ; Stack registers 6260 STMFD r13!, {r0-r2, r14} ; Stack registers
6210 BL update_standard ; Construct the pointer shape 6270 BL update_standard ; Construct the pointer shape
6220 MOV r0, #colour_trans ; Background is transparent 6280 MOV r0, #colour_trans ; Background is transparent
6230 BL plot_fill ; Clear the pointer initially 6290 BL plot_fill ; Clear the pointer initially
6240 MOV r0, #colour_trans_blue ; Fill interior with transparent blue 6300 MOV r0, #colour_trans_blue ; Fill interior with transparent blue
6250 BL plot_poly_fill ; Plot the filled interior 6310 BL plot_poly_fill ; Plot the filled interior
6260 MOV r0, #colour_cyan ; Outline the pointer in cyan 6320 MOV r0, #colour_cyan ; Outline the pointer in cyan
6270 BL plot_poly_line ; Plot the pointer outline 6330 BL plot_poly_line ; Plot the pointer outline
6280 LDMFD r13!, {r0-r2, pc} ; Return from subroutine 6340 LDMFD r13!, {r0-r2, pc} ; Return from subroutine
6290 6350
6300 ; Plot a caret pointer type r0 that has moved by (r2, r1) 6360 ; Plot a caret pointer type r0 that has moved by (r2, r1)
6310.update_write 6370.update_write
6320 STMFD r13!, {r0-r6, r14} ; Stack registers 6380 STMFD r13!, {r0-r6, r14} ; Stack registers
6330 MOV r0, r2, ASR#3 ; Value to update position with 6390 MOV r0, r2, ASR#3 ; Value to update position with
6340 BL update_filter ; Filter the update 6400 BL update_filter ; Filter the update
6350 MOV r3, r0, ASL#2 ; Copy the filter output 6410 MOV r3, r0, ASL#2 ; Copy the filter output
6360 MOV r0, #22 ; Number of coordinates 6420 MOV r0, #22 ; Number of coordinates
6370 ADR r1, update_write_basic ; The required pointer shape 6430 ADR r1, update_write_basic ; The required pointer shape
6380 ADR r2, update_write_horizontal; Changes to add horizontal motion 6440 ADR r2, update_write_horizontal; Changes to add horizontal motion
6390 ADD r4, r12, #ws_buffer ; Pointer to destination buffer 6450 ADD r4, r12, #ws_buffer ; Pointer to destination buffer
6400 BL trans_add ; Add the motion to the shape 6460 BL trans_add ; Add the motion to the shape
6410 MOV r1, r4 ; Copy buffer pointer 6470 MOV r1, r4 ; Copy buffer pointer
6420 MOV r2, r1 ; Use the same buffer for the results 6480 MOV r2, r1 ; Use the same buffer for the results
6430 BL trans_fit ; Scale the coordinates for the pointer 6490 BL trans_fit ; Scale the coordinates for the pointer
6440 MOV r1, r0 ; Copy the number of points 6500 MOV r1, r0 ; Copy the number of points
6450 MOV r0, #colour_trans ; Background is transparent 6510 MOV r0, #colour_trans ; Background is transparent
6460 BL plot_fill ; Clear the pointer initially 6520 BL plot_fill ; Clear the pointer initially
6470 MOV r0, #colour_blue ; Fill interior with solid blue 6530 MOV r0, #colour_blue ; Fill interior with solid blue
6480 BL plot_poly_fill ; Plot the filled interior 6540 BL plot_poly_fill ; Plot the filled interior
6490 MOV r0, #colour_cyan ; Outline the pointer in cyan 6550 MOV r0, #colour_cyan ; Outline the pointer in cyan
6500 BL plot_poly_line ; Plot the pointer outline 6560 BL plot_poly_line ; Plot the pointer outline
6510 LDMFD r13!, {r0-r6, pc} ; Return from subroutine 6570 LDMFD r13!, {r0-r6, pc} ; Return from subroutine
6520.update_write_basic ; The basic pointer shape 6580.update_write_basic ; The basic pointer shape
6530 FNcoordinate(-10, -4) 6590 FNcoordinate(-10, -4)
6540 FNcoordinate(-10, -2) 6600 FNcoordinate(-10, -2)
6550 FNcoordinate(-8, 0) 6610 FNcoordinate(-8, 0)
6560 FNcoordinate(-10, 2) 6620 FNcoordinate(-10, 2)
6570 FNcoordinate(-10, 4) 6630 FNcoordinate(-10, 4)
6580 FNcoordinate(-8, 4) 6640 FNcoordinate(-8, 4)
6590 FNcoordinate(-7, 1) 6650 FNcoordinate(-7, 1)
6600 FNcoordinate(-2, 1) 6660 FNcoordinate(-2, 1)
6610 FNcoordinate(2, 1) 6670 FNcoordinate(2, 1)
6620 FNcoordinate(6, 1) 6680 FNcoordinate(6, 1)
6630 FNcoordinate(7, 4) 6690 FNcoordinate(7, 4)
6640 FNcoordinate(9, 4) 6700 FNcoordinate(9, 4)
6650 FNcoordinate(9, 2) 6710 FNcoordinate(9, 2)
6660 FNcoordinate(7, 0) 6720 FNcoordinate(7, 0)
6670 FNcoordinate(9, -2) 6730 FNcoordinate(9, -2)
6680 FNcoordinate(9, -4) 6740 FNcoordinate(9, -4)
6690 FNcoordinate(7, -4) 6750 FNcoordinate(7, -4)
6700 FNcoordinate(6, -1) 6760 FNcoordinate(6, -1)
6710 FNcoordinate(2, -1) 6770 FNcoordinate(2, -1)
6720 FNcoordinate(-2, -1) 6780 FNcoordinate(-2, -1)
6730 FNcoordinate(-7, -1) 6790 FNcoordinate(-7, -1)
6740 FNcoordinate(-8, -4) 6800 FNcoordinate(-8, -4)
6750.update_write_horizontal ; Offsets to distort horizontally 6810.update_write_horizontal ; Offsets to distort horizontally
6760 FNcoordinate(0.6, -1) 6820 FNcoordinate(0.6, -1)
6770 FNcoordinate(0.3, -0.8) 6830 FNcoordinate(0.3, -0.8)
6780 FNcoordinate(0, -0.6) 6840 FNcoordinate(0, -0.6)
6790 FNcoordinate(-0.3, -0.8) 6850 FNcoordinate(-0.3, -0.8)
6800 FNcoordinate(-0.6, -1) 6860 FNcoordinate(-0.6, -1)
6810 FNcoordinate(-0.6, -1) 6870 FNcoordinate(-0.6, -1)
6820 FNcoordinate(-0.15, -0.5) 6880 FNcoordinate(-0.15, -0.5)
6830 FNcoordinate(-0.15, -0) 6890 FNcoordinate(-0.15, -0)
6840 FNcoordinate(0.15, -0) 6900 FNcoordinate(0.15, -0)
6850 FNcoordinate(0.15, -0.5) 6910 FNcoordinate(0.15, -0.5)
6860 FNcoordinate(0.6, -1) 6920 FNcoordinate(0.6, -1)
6870 FNcoordinate(0.6, -1) 6930 FNcoordinate(0.6, -1)
6880 FNcoordinate(0.3, -0.8) 6940 FNcoordinate(0.3, -0.8)
6890 FNcoordinate(0, -0.6) 6950 FNcoordinate(0, -0.6)
6900 FNcoordinate(-0.3, -0.8) 6960 FNcoordinate(-0.3, -0.8)
6910 FNcoordinate(-0.6, -1) 6970 FNcoordinate(-0.6, -1)
6920 FNcoordinate(-0.6, -1) 6980 FNcoordinate(-0.6, -1)
6930 FNcoordinate(-0.15, -0.5) 6990 FNcoordinate(-0.15, -0.5)
6940 FNcoordinate(-0.15, -0) 7000 FNcoordinate(-0.15, -0)
6950 FNcoordinate(0.15, -0) 7010 FNcoordinate(0.15, -0)
6960 FNcoordinate(0.15, -0.5) 7020 FNcoordinate(0.15, -0.5)
6970 FNcoordinate(0.6, -1) 7030 FNcoordinate(0.6, -1)
6980 7040
6990 ; Plot a menu pointer type r0 that has moved by (r2, r1) 7050 ; Plot a menu pointer type r0 that has moved by (r2, r1)
7000.update_menu 7060.update_menu
7010 STMFD r13!, {r0-r4, r14} ; Stack registers 7070 STMFD r13!, {r0-r4, r14} ; Stack registers
7020 LDR r3, [r12, #ws_cogr] ; Read previous row direction 7080 LDR r3, [r12, #ws_cogr] ; Read previous row direction
7030 LDR r4, [r12, #ws_cogc] ; Read previous column direction 7090 LDR r4, [r12, #ws_cogc] ; Read previous column direction
7040 TEQ r1, #0 ; Is there any vertical motion 7100 TEQ r1, #0 ; Is there any vertical motion
7050 TEQEQ r2, #0 ; Is there any horizontal motion 7110 TEQEQ r2, #0 ; Is there any horizontal motion
7060 BEQ update_menu_still ; Do not change direction if still 7120 BEQ update_menu_still ; Do not change direction if still
7070 ADD r0, r3, r1, ASR#3 ; Update the row direction 7130 ADD r0, r3, r1, ASR#3 ; Update the row direction
7080 ADD r1, r4, r2, ASR#3 ; Update the column direction 7140 ADD r1, r4, r2, ASR#3 ; Update the column direction
7090 BL normalise ; Normalise the direction vector 7150 BL normalise ; Normalise the direction vector
7100 MOV r3, r0 ; Copy the row direction 7160 MOV r3, r0 ; Copy the row direction
7110 MOV r4, r1 ; Copy the column direction 7170 MOV r4, r1 ; Copy the column direction
7120 STR r3, [r12, #ws_cogr] ; Store the new row direction 7180 STR r3, [r12, #ws_cogr] ; Store the new row direction
7130 STR r4, [r12, #ws_cogc] ; Store the new column direction 7190 STR r4, [r12, #ws_cogc] ; Store the new column direction
7140.update_menu_still 7200.update_menu_still
7150 MOV r0, #8 ; Number of points to transform 7210 MOV r0, #8 ; Number of points to transform
7160 ADR r1, update_menu_frame ; Pointer to source cordinates 7220 ADR r1, update_menu_frame ; Pointer to source cordinates
7170 ADD r2, r12, #ws_buffer ; Pointer to destination buffer 7230 ADD r2, r12, #ws_buffer ; Pointer to destination buffer
7180 BL trans_fit ; Scale the coordinates for the pointer 7240 BL trans_fit ; Scale the coordinates for the pointer
7190 ADD r2, r2, r0, LSL#3 ; Pointer to destination buffer 7250 ADD r2, r2, r0, LSL#3 ; Pointer to destination buffer
7200 MOV r0, #9 ; Number of points in pointer shape 7260 MOV r0, #9 ; Number of points in pointer shape
7210 ADR r1, update_menu_ptr ; Pointer to source coordinates 7270 ADR r1, update_menu_ptr ; Pointer to source coordinates
7230 BL trans_rotate ; Rotate the pointer as required 7280 BL trans_rotate ; Rotate the pointer as required
7240 MOV r1, r2 ; Source buffer is same as destination 7290 MOV r1, r2 ; Source buffer is same as destination
7250 BL trans_fit ; Scale the coordinates for the pointer 7300 BL trans_fit ; Scale the coordinates for the pointer
7270 MOV r0, #colour_trans ; Background is transparent 7310 MOV r0, #colour_trans ; Background is transparent
7280 ADD r2, r12, #ws_buffer ; Pointer to coordinates buffer 7320 ADD r2, r12, #ws_buffer ; Pointer to coordinates buffer
7290 BL plot_fill ; Clear the pointer initially 7330 BL plot_fill ; Clear the pointer initially
7300 MOV r1, #4 ; Number of coordinates in menu shape 7340 MOV r1, #4 ; Number of coordinates in menu shape
7310 MOV r0, #colour_trans_blue ; Fill interior with solid blue 7350 MOV r0, #colour_trans_blue ; Fill interior with solid blue
7320 BL plot_poly_fill ; Plot the filled interior 7360 BL plot_poly_fill ; Plot the filled interior
7330 MOV r0, #colour_cyan ; Outline the pointer in cyan 7370 MOV r0, #colour_cyan ; Outline the pointer in cyan
7340 BL plot_poly_line ; Plot the pointer outline 7380 BL plot_poly_line ; Plot the pointer outline
7350 MOV r0, #colour_trans_cyan ; Outline the pointer in cyan 7390 MOV r0, #colour_trans_cyan ; Outline the pointer in cyan
7360 ADD r2, r2, r1, LSL#3 ; Pointer to interior shape 7400 ADD r2, r2, r1, LSL#3 ; Pointer to interior shape
7370 BL plot_poly_fill ; Plot the menu interior 7410 BL plot_poly_fill ; Plot the menu interior
7380 ADD r2, r2, r1, LSL#3 ; Pointer to pointer shape 7420 ADD r2, r2, r1, LSL#3 ; Pointer to pointer shape
7390 MOV r0, #colour_blue ; Fill interior with solid blue 7430 MOV r0, #colour_blue ; Fill interior with solid blue
7400 MOV r1, #9 ; Number of coordinates in pointer shape 7440 MOV r1, #9 ; Number of coordinates in pointer shape
7410 BL plot_poly_fill ; Plot the filled interior 7450 BL plot_poly_fill ; Plot the filled interior
7420 MOV r0, #colour_cyan ; Outline the pointer in cyan 7460 MOV r0, #colour_cyan ; Outline the pointer in cyan
7430 BL plot_poly_line ; Plot the pointer outline 7470 BL plot_poly_line ; Plot the pointer outline
7440 LDMFD r13!, {r0-r4, pc} ; Return from subroutine 7480 LDMFD r13!, {r0-r4, pc} ; Return from subroutine
7450.update_menu_frame ; The outside frame of the menu 7490.update_menu_frame ; The outside frame of the menu
7460 FNcoordinate(-3, 0) 7500 FNcoordinate(-3, 0)
7470 FNcoordinate(-3, 16) 7510 FNcoordinate(-3, 16)
7480 FNcoordinate(20, 16) 7520 FNcoordinate(20, 16)
7490 FNcoordinate(20, 0) 7530 FNcoordinate(20, 0)
7500.update_menu_entries ; The interior of the menu 7540.update_menu_entries ; The interior of the menu
7510 FNcoordinate(0.5, 1) 7550 FNcoordinate(0.5, 1)
7520 FNcoordinate(0.5, 14) 7560 FNcoordinate(0.5, 14)
7530 FNcoordinate(18.5, 14) 7570 FNcoordinate(18.5, 14)
7540 FNcoordinate(18.5, 1) 7580 FNcoordinate(18.5, 1)
7550.update_menu_ptr ; The pointer shape 7590.update_menu_ptr ; The pointer shape
7560 FNcoordinate(1, 0) 7600 FNcoordinate(1, 0)
7570 FNcoordinate(5, 4) 7610 FNcoordinate(5, 4)
7571 FNcoordinate(6, 4) 7620 FNcoordinate(6, 4)
7580 FNcoordinate(6, 2) 7630 FNcoordinate(6, 2)
7590 FNcoordinate(11, 2) 7640 FNcoordinate(11, 2)
7600 FNcoordinate(11, -2) 7650 FNcoordinate(11, -2)
7610 FNcoordinate(6, -2) 7660 FNcoordinate(6, -2)
7620 FNcoordinate(6, -4) 7670 FNcoordinate(6, -4)
7621 FNcoordinate(5, -4) 7680 FNcoordinate(5, -4)
7630 7690
7640 ; Apply an underdamped filter to the value in r0 7700 ; Apply an underdamped filter to the value in r0
7650.update_filter 7710.update_filter
7660 STMFD r13!, {r1-r3, r14} ; Stack registers 7720 STMFD r13!, {r1-r3, r14} ; Stack registers
7670 LDR r1, [r12, #ws_filtn] ; Get previous position 7730 LDR r1, [r12, #ws_filtn] ; Get previous position
7680 LDR r2, [r12, #ws_filtv] ; Get previous velocity 7740 LDR r2, [r12, #ws_filtv] ; Get previous velocity
7690 LDR r3, [r12, #ws_friction] ; The amount of friction 7750 LDR r3, [r12, #ws_friction] ; The amount of friction
7700 RSB r3, r3, #10 ; Convert to a shift value 7760 RSB r3, r3, #10 ; Convert to a shift value
7710 SUB r2, r2, r2, ASR r3 ; Apply some friction 7770 SUB r2, r2, r2, ASR r3 ; Apply some friction
7720 LDR r3, [r12, #ws_spring] ; The spring constant 7780 LDR r3, [r12, #ws_spring] ; The spring constant
7730 RSB r3, r3, #11 ; Convert to a shift value 7790 RSB r3, r3, #11 ; Convert to a shift value
7740 SUB r2, r2, r1, ASR r3 ; Include the restorative force 7800 SUB r2, r2, r1, ASR r3 ; Include the restorative force
7750 ADD r1, r1, r2 ; Add part of velocity to the position 7810 ADD r1, r1, r2 ; Add part of velocity to the position
7760 LDR r3, [r12, #ws_force] ; The force multiplier 7820 LDR r3, [r12, #ws_force] ; The force multiplier
7770 RSBS r3, r3, #13 ; Convert to a shift value 7830 RSBS r3, r3, #13 ; Convert to a shift value
7780 MOVMI r0, #0 ; No wibble if result negative 7840 MOVMI r0, #0 ; No wibble if result negative
7790 MOV r0, r0, ASR r3 ; Scale the new input 7850 MOV r0, r0, ASR r3 ; Scale the new input
7800 ADD r0, r1, r0, ASL#8 ; Add the new input 7860 ADD r0, r1, r0, ASL#8 ; Add the new input
7810 MOV r1, #1<<16 ; The maximum allowed value 7870 MOV r1, #1<<16 ; The maximum allowed value
7820 CMP r0, r1 ; Compare to the maximum 7880 CMP r0, r1 ; Compare to the maximum
7830 MOVGT r0, r1 ; Enforce the maximum position 7890 MOVGT r0, r1 ; Enforce the maximum position
7840 CMPGT r2, #0 ; Clip the velocity if maximum reached 7900 CMPGT r2, #0 ; Clip the velocity if maximum reached
7850 MOVGT r2, #0 ; Set the velocity to zero 7910 MOVGT r2, #0 ; Set the velocity to zero
7860 RSB r1, r1, #0 ; The minimum allowed value 7920 RSB r1, r1, #0 ; The minimum allowed value
7870 CMP r0, r1 ; Compare to the mimimum 7930 CMP r0, r1 ; Compare to the mimimum
7880 MOVLT r0, r1 ; Enforce the minimum 7940 MOVLT r0, r1 ; Enforce the minimum
7890 CMPLT r2, #0 ; Clip the velocity if minimum reached 7950 CMPLT r2, #0 ; Clip the velocity if minimum reached
7900 MOVLT r2, #0 ; Set the velocity to zero 7960 MOVLT r2, #0 ; Set the velocity to zero
7910 MOVS r1, r0 ; Copy the new position 7970 MOVS r1, r0 ; Copy the new position
7920 RSBMI r1, r1, #0 ; Ensure copy of position is positive 7980 RSBMI r1, r1, #0 ; Ensure copy of position is positive
7930 CMP r1, #1<<8 ; Minimum visible position 7990 CMP r1, #1<<8 ; Minimum visible position
7940 MOVLT r2, r2, ASR#1 ; Increase friction when small movement 8000 MOVLT r2, r2, ASR#1 ; Increase friction when small movement
7950 STR r0, [r12, #ws_filtn] ; Store the new position 8010 STR r0, [r12, #ws_filtn] ; Store the new position
7960 STR r2, [r12, #ws_filtv] ; Store the new velocity 8020 STR r2, [r12, #ws_filtv] ; Store the new velocity
7970.update_filter_done 8030.update_filter_done
7980 LDMFD r13!, {r1-r3, pc} ; Return from subroutine 8040 LDMFD r13!, {r1-r3, pc} ; Return from subroutine
7990 8050
8000 ; Fill the pointer image data with colour r0 8060 ; Fill the pointer image data with colour r0
8010.plot_fill 8070.plot_fill
8020 STMFD r13!, {r0-r2, r14} ; Stack registers 8080 STMFD r13!, {r0-r2, r14} ; Stack registers
8030 BL colour_expand ; Expand the colour to fill a word 8090 BL colour_expand ; Expand the colour to fill a word
8040 ADD r1, r12, #ws_ptr_data ; Start of pointer image data 8100 ADD r1, r12, #ws_ptr_data ; Start of pointer image data
8050 MOV r2, #32 ; Number of rows to clear 8110 MOV r2, #32 ; Number of rows to clear
8060.plot_fill_loop 8120.plot_fill_loop
8070 SUBS r2, r2, #1 ; Decrement number of rows remaining 8130 SUBS r2, r2, #1 ; Decrement number of rows remaining
8080 LDMMIFD r13!, {r0-r2, pc} ; Return from subroutine when finished 8140 LDMMIFD r13!, {r0-r2, pc} ; Return from subroutine when finished
8090 STR r0, [r1], #4 ; Set this word of the pointer image 8150 STR r0, [r1], #4 ; Set this word of the pointer image
8100 STR r0, [r1], #4 ; Set this word of the pointer image 8160 STR r0, [r1], #4 ; Set this word of the pointer image
8110 MOV r0, r0, ROR#2 ; Rotate pattern by a pixel for next row 8170 MOV r0, r0, ROR#2 ; Rotate pattern by a pixel for next row
8120 B plot_fill_loop ; Loop for the next word 8180 B plot_fill_loop ; Loop for the next word
8130 8190
8140 ; Plot a horizontal line in colour r0 from (r2, r1) to (r3, r1) 8200 ; Plot a horizontal line in colour r0 from (r2, r1) to (r3, r1)
8150.plot_row 8210.plot_row
8160 STMFD r13!, {r0-r4, r14} ; Stack registers 8220 STMFD r13!, {r0-r4, r14} ; Stack registers
8170 LDRB r4, [r12, #ws_ptr_block_activex]; Read horizontal hotspot 8230 LDRB r4, [r12, #ws_ptr_block_activex]; Read horizontal hotspot
8180 ADD r2, r2, r4 ; Set the horizontal origin 8240 ADD r2, r2, r4 ; Set the horizontal origin
8190 ADD r3, r3, r4 ; Set the horizontal origin 8250 ADD r3, r3, r4 ; Set the horizontal origin
8200 LDRB r4, [r12, #ws_ptr_block_activey]; Read vertical hotspot 8260 LDRB r4, [r12, #ws_ptr_block_activey]; Read vertical hotspot
8210 ADD r1, r1, r4 ; Set the vertical origin 8270 ADD r1, r1, r4 ; Set the vertical origin
8220 CMP r2, r3 ; Place limits in the correct order 8280 CMP r2, r3 ; Place limits in the correct order
8230 MOVGT r4, r2 ; Make a temporary copy 8290 MOVGT r4, r2 ; Make a temporary copy
8240 MOVGT r2, r3 ; Swap the limits 8300 MOVGT r2, r3 ; Swap the limits
8250 MOVGT r3, r4 ; Copy the temporary value back 8310 MOVGT r3, r4 ; Copy the temporary value back
8260 CMP r1, #0 ; Check lower row limit 8320 CMP r1, #0 ; Check lower row limit
8270 BLT plot_row_done ; No plotting if before first row 8330 BLT plot_row_done ; No plotting if before first row
8280 CMP r1, #31 ; Check upper row limit 8340 CMP r1, #31 ; Check upper row limit
8290 BGT plot_row_done ; No plotting if after last row 8350 BGT plot_row_done ; No plotting if after last row
8300 BL colour_expand ; Expand the colour to fill a word 8360 BL colour_expand ; Expand the colour to fill a word
8310 TST r1, #1 ; Is it an odd numbered row 8370 TST r1, #1 ; Is it an odd numbered row
8320 MOVNE r0, r0, ROR#2 ; Rotate colour pattern if it is 8380 MOVNE r0, r0, ROR#2 ; Rotate colour pattern if it is
8330 ADD r4, r12, r1, ASL#3 ; Calculate row start 8390 ADD r4, r12, r1, ASL#3 ; Calculate row start
8340 ADD r4, r4, #ws_ptr_data ; Include data start offset 8400 ADD r4, r4, #ws_ptr_data ; Include data start offset
8350 LDR r1, [r4] ; Read the existing first word 8410 LDR r1, [r4] ; Read the existing first word
8360 BL plot_row_word ; Process the first word 8420 BL plot_row_word ; Process the first word
8370 STR r1, [r4] ; Store the updated first word 8430 STR r1, [r4] ; Store the updated first word
8380 SUB r2, r2, #16 ; Adjust the start position 8440 SUB r2, r2, #16 ; Adjust the start position
8390 SUB r3, r3, #16 ; Adjust the end position 8450 SUB r3, r3, #16 ; Adjust the end position
8400 LDR r1, [r4, #4]! ; Read the existing second word 8460 LDR r1, [r4, #4]! ; Read the existing second word
8410 BL plot_row_word ; Process the second word 8470 BL plot_row_word ; Process the second word
8420 STR r1, [r4] ; Store the updated second word 8480 STR r1, [r4] ; Store the updated second word
8430.plot_row_done 8490.plot_row_done
8440 LDMFD r13!, {r0-r4, pc} ; Return from subroutine 8500 LDMFD r13!, {r0-r4, pc} ; Return from subroutine
8450.plot_row_word 8510.plot_row_word
8460 STMFD r13!, {r2-r4, r14} ; Stack registers 8520 STMFD r13!, {r2-r4, r14} ; Stack registers
8470 CMP r2, #0 ; Range check lower limit 8530 CMP r2, #0 ; Range check lower limit
8480 MOVLT r2, #0 ; Start from first pixel 8540 MOVLT r2, #0 ; Start from first pixel
8490 CMP r3, #15 ; Range check upper limit 8550 CMP r3, #15 ; Range check upper limit
8500 MOVGT r3, #15 ; End at the last pixel 8560 MOVGT r3, #15 ; End at the last pixel
8510 SUB r3, r3, r2 ; Difference between the two ends 8570 SUB r3, r3, r2 ; Difference between the two ends
8520 ADD r3, r3, #1 ; Convert to number of pixels 8580 ADD r3, r3, #1 ; Convert to number of pixels
8530 MOV r4, r2, ASL#1 ; Convert start to rotation 8590 MOV r4, r2, ASL#1 ; Convert start to rotation
8540 MOV r2, #3 ; Mask for a single pixel 8600 MOV r2, #3 ; Mask for a single pixel
8550 MOV r2, r2, LSL r4 ; Mask for the first pixel position 8610 MOV r2, r2, LSL r4 ; Mask for the first pixel position
8560 MOV r4, #0 ; No pixels set initially 8620 MOV r4, #0 ; No pixels set initially
8570.plot_row_word_loop 8630.plot_row_word_loop
8580 SUBS r3, r3, #1 ; Decrement number of pixels 8640 SUBS r3, r3, #1 ; Decrement number of pixels
8590 BMI plot_row_word_done ; Escape the loop if finished 8650 BMI plot_row_word_done ; Escape the loop if finished
8600 ORR r4, r4, r2 ; Include this pixel in the mask 8660 ORR r4, r4, r2 ; Include this pixel in the mask
8610 MOV r2, r2, LSL#2 ; Advance to the next pixel 8670 MOV r2, r2, LSL#2 ; Advance to the next pixel
8620 B plot_row_word_loop ; Loop for the next pixel 8680 B plot_row_word_loop ; Loop for the next pixel
8630.plot_row_word_done 8690.plot_row_word_done
8640 BIC r1, r1, r4 ; Clear pixels to set 8700 BIC r1, r1, r4 ; Clear pixels to set
8650 AND r4, r4, r0 ; Colour the mask 8710 AND r4, r4, r0 ; Colour the mask
8660 ORR r1, r1, r4 ; Include the new pixels in the word 8720 ORR r1, r1, r4 ; Include the new pixels in the word
8670 LDMFD r13!, {r2-r4, pc} ; Return from subroutine 8730 LDMFD r13!, {r2-r4, pc} ; Return from subroutine
8680 8740
8690 ; Plot a single point in colour r0 at (r2, r1) 8750 ; Plot a single point in colour r0 at (r2, r1)
8700.plot_point 8760.plot_point
8710 STMFD r13!, {r0-r3, r14} ; Stack registers 8770 STMFD r13!, {r0-r3, r14} ; Stack registers
8720 LDRB r3, [r12, #ws_ptr_block_activex]; Read horizontal hotspot 8780 LDRB r3, [r12, #ws_ptr_block_activex]; Read horizontal hotspot
8730 ADD r2, r2, r3 ; Set the horizontal origin 8790 ADD r2, r2, r3 ; Set the horizontal origin
8740 LDRB r3, [r12, #ws_ptr_block_activey]; Read vertical hotspot 8800 LDRB r3, [r12, #ws_ptr_block_activey]; Read vertical hotspot
8750 ADD r1, r1, r3 ; Set the vertical origin 8810 ADD r1, r1, r3 ; Set the vertical origin
8760 CMP r1, #0 ; Check lower row limit 8820 CMP r1, #0 ; Check lower row limit
8770 CMPGE r2, #0 ; Check lower column limit 8830 CMPGE r2, #0 ; Check lower column limit
8780 BLT plot_point_done ; No plotting if below visible range 8840 BLT plot_point_done ; No plotting if below visible range
8790 CMP r1, #31 ; Check upper row limit 8850 CMP r1, #31 ; Check upper row limit
8800 CMPLE r2, #31 ; Check upper column limit 8860 CMPLE r2, #31 ; Check upper column limit
8810 BGT plot_point_done ; No plotting if above visible range 8870 BGT plot_point_done ; No plotting if above visible range
8820 BL colour_expand ; Expand the colour to fill a word 8880 BL colour_expand ; Expand the colour to fill a word
8830 TST r1, #1 ; Is it an odd numbered row 8890 TST r1, #1 ; Is it an odd numbered row
8840 MOVNE r0, r0, ROR#2 ; Rotate colour pattern if it is 8900 MOVNE r0, r0, ROR#2 ; Rotate colour pattern if it is
8850 ADD r1, r12, r1, ASL#3 ; Calculate row start 8910 ADD r1, r12, r1, ASL#3 ; Calculate row start
8860 ADD r1, r1, #ws_ptr_data ; Include data start offset 8920 ADD r1, r1, #ws_ptr_data ; Include data start offset
8870 TST r2, #&10 ; Should the second word be used 8930 TST r2, #&10 ; Should the second word be used
8880 ADDNE r1, r1, #4 ; Advance if it should 8940 ADDNE r1, r1, #4 ; Advance if it should
8890 AND r2, r2, #&f ; Pixel within the word 8950 AND r2, r2, #&f ; Pixel within the word
8900 ADD r2, r2, r2 ; Convert to a rotation 8960 ADD r2, r2, r2 ; Convert to a rotation
8910 MOV r3, #3 ; Mask for a single pixel 8970 MOV r3, #3 ; Mask for a single pixel
8920 MOV r3, r3, LSL r2 ; Rotate to the correct position 8980 MOV r3, r3, LSL r2 ; Rotate to the correct position
8930 AND r0, r0, r3 ; Mask out the required colour 8990 AND r0, r0, r3 ; Mask out the required colour
8940 LDR r2, [r1] ; Read the existing image word 9000 LDR r2, [r1] ; Read the existing image word
8950 BIC r2, r2, r3 ; Clear the pixel to be set 9010 BIC r2, r2, r3 ; Clear the pixel to be set
8960 ORR r2, r2, r0 ; Set the required colour 9020 ORR r2, r2, r0 ; Set the required colour
8970 STR r2, [r1] ; Strore the updated word 9030 STR r2, [r1] ; Strore the updated word
8980.plot_point_done 9040.plot_point_done
8990 LDMFD r13!, {r0-r3, pc} ; Return from subroutine 9050 LDMFD r13!, {r0-r3, pc} ; Return from subroutine
9000 9060
9010 ; Plot a midpoint line in colour r0 from (r2, r1) to (r4, r3) 9070 ; Plot a midpoint line in colour r0 from (r2, r1) to (r4, r3)
9020.plot_line 9080.plot_line
9030 STMFD r13!, {r0-r7, r14} ; Stack registers 9090 STMFD r13!, {r0-r7, r14} ; Stack registers
9040 MOV r5, #0 ; Start with default coordinates 9100 MOV r5, #0 ; Start with default coordinates
9050 SUBS r1, r1, r3 ; Change in row number 9110 SUBS r1, r1, r3 ; Change in row number
9060 RSBMI r3, r3, #0 ; Reflect start point vertically 9120 RSBMI r3, r3, #0 ; Reflect start point vertically
9070 RSBMI r1, r1, #0 ; Reflect change in row number 9130 RSBMI r1, r1, #0 ; Reflect change in row number
9080 ORRMI r5, r5, #2 ; Record vertical flip 9140 ORRMI r5, r5, #2 ; Record vertical flip
9090 SUBS r2, r2, r4 ; Change in column number 9150 SUBS r2, r2, r4 ; Change in column number
9100 RSBMI r4, r4, #0 ; Reflect start point horizontally 9160 RSBMI r4, r4, #0 ; Reflect start point horizontally
9110 RSBMI r2, r2, #0 ; Reflect change in column number 9170 RSBMI r2, r2, #0 ; Reflect change in column number
9120 ORRMI r5, r5, #4 ; Record horizontal flip 9180 ORRMI r5, r5, #4 ; Record horizontal flip
9130 CMP r2, r1 ; Check slope of line 9190 CMP r2, r1 ; Check slope of line
9140 MOVGT r6, r3 ; Copy original row number 9200 MOVGT r6, r3 ; Copy original row number
9150 MOVGT r3, r4 ; Swap row with column 9210 MOVGT r3, r4 ; Swap row with column
9160 MOVGT r4, r6 ; Set new row number 9220 MOVGT r4, r6 ; Set new row number
9170 MOVGT r6, r1 ; Copy original row change 9230 MOVGT r6, r1 ; Copy original row change
9180 MOVGT r1, r2 ; Swap row with column 9240 MOVGT r1, r2 ; Swap row with column
9190 MOVGT r2, r6 ; Set new row change 9250 MOVGT r2, r6 ; Set new row change
9200 ORRGT r5, r5, #1 ; Record coordinate reversal 9260 ORRGT r5, r5, #1 ; Record coordinate reversal
9210 ADD r6, r2, r2 ; Horizontal step increment 9270 ADD r6, r2, r2 ; Horizontal step increment
9220 SUB r7, r6, r1 ; Initial decision variable value 9280 SUB r7, r6, r1 ; Initial decision variable value
9230 SUB r2, r2, r1 ; Half of diagonal step increment 9290 SUB r2, r2, r1 ; Half of diagonal step increment
9240 ADD r2, r2, r2 ; Diagonal step increment 9300 ADD r2, r2, r2 ; Diagonal step increment
9250 ADD r1, r3, r1 ; The last point to plot 9310 ADD r1, r3, r1 ; The last point to plot
9260.plot_line_loop 9320.plot_line_loop
9270 BL plot_line_point ; Plot the first point of the line 9330 BL plot_line_point ; Plot the first point of the line
9280 CMP r3, r1 ; Has the line been finished 9340 CMP r3, r1 ; Has the line been finished
9290 LDMGEFD r13!, {r0-r7, pc} ; Return from subroutine when finished 9350 LDMGEFD r13!, {r0-r7, pc} ; Return from subroutine when finished
9300 CMP r7, #0 ; Check the decision variable 9360 CMP r7, #0 ; Check the decision variable
9310 ADDLE r7, r7, r6 ; Increment decision variable 9370 ADDLE r7, r7, r6 ; Increment decision variable
9320 ADDGT r7, r7, r2 ; Increment decision variable 9380 ADDGT r7, r7, r2 ; Increment decision variable
9330 ADDGT r4, r4, #1 ; Perform the diagonal step 9390 ADDGT r4, r4, #1 ; Perform the diagonal step
9340 ADD r3, r3, #1 ; Advance to the next pixel 9400 ADD r3, r3, #1 ; Advance to the next pixel
9350 B plot_line_loop ; Loop for the next pixel 9410 B plot_line_loop ; Loop for the next pixel
9360.plot_line_point 9420.plot_line_point
9370 STMFD r13!, {r1-r2, r14} ; Stack registers 9430 STMFD r13!, {r1-r2, r14} ; Stack registers
9380 TST r5, #1 ; Have coordinates been reversed 9440 TST r5, #1 ; Have coordinates been reversed
9390 MOVEQ r1, r3 ; Copy unreversed row 9450 MOVEQ r1, r3 ; Copy unreversed row
9400 MOVEQ r2, r4 ; Copy unreversed column 9460 MOVEQ r2, r4 ; Copy unreversed column
9410 MOVNE r1, r4 ; Copy reversed row 9470 MOVNE r1, r4 ; Copy reversed row
9420 MOVNE r2, r3 ; Copy reversed column 9480 MOVNE r2, r3 ; Copy reversed column
9430 TST r5, #2 ; Has row been negated 9490 TST r5, #2 ; Has row been negated
9440 RSBNE r1, r1, #0 ; Negate row if required 9500 RSBNE r1, r1, #0 ; Negate row if required
9450 TST r5, #4 ; Has column been negated 9510 TST r5, #4 ; Has column been negated
9460 RSBNE r2, r2, #0 ; Negate column if required 9520 RSBNE r2, r2, #0 ; Negate column if required
9470 BL plot_point ; Plot the point 9530 BL plot_point ; Plot the point
9480 LDMFD r13!, {r1-r2, pc} ; Return from subroutine 9540 LDMFD r13!, {r1-r2, pc} ; Return from subroutine
9490 9550
9500 ; Plot a closed polyline in colour r0 using r1 vertices starting at r2 9560 ; Plot a closed polyline in colour r0 using r1 vertices starting at r2
9510.plot_poly_line 9570.plot_poly_line
9520 STMFD r13!, {r0-r7, r14} ; Stack registers 9580 STMFD r13!, {r0-r7, r14} ; Stack registers
9530 MOV r5, r2 ; Pointer to the current vertex 9590 MOV r5, r2 ; Pointer to the current vertex
9540 MOV r6, r2 ; Keep a pointer to the first vertex 9600 MOV r6, r2 ; Keep a pointer to the first vertex
9550 MOV r7, r1 ; Copy number of segments 9610 MOV r7, r1 ; Copy number of segments
9560.plot_poly_line_loop 9620.plot_poly_line_loop
9570 SUBS r7, r7, #1 ; Decrement remaining segments 9630 SUBS r7, r7, #1 ; Decrement remaining segments
9580 LDMMIFD r13!, {r0-r7, pc} ; Return from subroutine when finished 9640 LDMMIFD r13!, {r0-r7, pc} ; Return from subroutine when finished
9590 LDMIA r5!, {r1-r2} ; Read line start coordinates 9650 LDMIA r5!, {r1-r2} ; Read line start coordinates
9600 MOVEQ r5, r6 ; Wrap around to the start for the end 9660 MOVEQ r5, r6 ; Wrap around to the start for the end
9610 LDMIA r5, {r3-r4} ; Read line end coordinates 9670 LDMIA r5, {r3-r4} ; Read line end coordinates
9620 BL plot_line ; Plot this line 9680 BL plot_line ; Plot this line
9630 B plot_poly_line_loop ; Loop for the next line segment 9690 B plot_poly_line_loop ; Loop for the next line segment
9640 9700
9650 ; Fill a polygon in colour r0 using r1 vertices starting at r2 9710 ; Fill a polygon in colour r0 using r1 vertices starting at r2
9660.plot_poly_fill 9720.plot_poly_fill
9670 STMFD r13!, {r0-r6, r14} ; Stack registers 9730 STMFD r13!, {r0-r6, r14} ; Stack registers
9680 SUB r13, r13, r1, LSL#4 ; Reserve space for edge details 9740 SUB r13, r13, r1, LSL#4 ; Reserve space for edge details
9690 MOV r3, r13 ; Copy edge details pointer 9750 MOV r3, r13 ; Copy edge details pointer
9700 SUB r13, r13, r1, LSL#2 ; Reserve space for intersections 9760 SUB r13, r13, r1, LSL#2 ; Reserve space for intersections
9710 MOV r4, r13 ; Copy intersections pointer 9770 MOV r4, r13 ; Copy intersections pointer
9720 BL plot_poly_fill_preprocess; Construct the edge details 9780 BL plot_poly_fill_preprocess; Construct the edge details
9730.plot_poly_fill_loop 9790.plot_poly_fill_loop
9740 MOV r2, #0 ; No intersections found yet 9800 MOV r2, #0 ; No intersections found yet
9750 BL plot_poly_fill_inter ; Find any intersecting edges 9810 BL plot_poly_fill_inter ; Find any intersecting edges
9760 BL plot_poly_fill_plot ; Perform the plotting 9820 BL plot_poly_fill_plot ; Perform the plotting
9770 ADD r5, r5, #1 ; Advance to the next row 9830 ADD r5, r5, #1 ; Advance to the next row
9780 CMP r5, r6 ; Has the last row been reached 9840 CMP r5, r6 ; Has the last row been reached
9790 BLE plot_poly_fill_loop ; Loop until all finished 9850 BLE plot_poly_fill_loop ; Loop until all finished
9800.plot_poly_fill_done 9860.plot_poly_fill_done
9810 ADD r13, r13, r1, LSL#2 ; Release the intersections space 9870 ADD r13, r13, r1, LSL#2 ; Release the intersections space
9820 ADD r13, r13, r1, LSL#4 ; Release the edge details space 9880 ADD r13, r13, r1, LSL#4 ; Release the edge details space
9830 LDMFD r13!, {r0-r6, pc} ; Return from subroutine 9890 LDMFD r13!, {r0-r6, pc} ; Return from subroutine
9840.plot_poly_fill_preprocess 9900.plot_poly_fill_preprocess
9850 STMFD r13!, {r0-r4, r7-r10, r14}; Stack registers 9910 STMFD r13!, {r0-r4, r7-r10, r14}; Stack registers
9860 LDR r5, [r2] ; Initialise first row number 9920 LDR r5, [r2] ; Initialise first row number
9870 LDR r6, [r2] ; Initialise last row number 9930 LDR r6, [r2] ; Initialise last row number
9880 MOV r0, r2 ; Copy vertex pointer 9940 MOV r0, r2 ; Copy vertex pointer
9890.plot_poly_fill_preprocess_loop 9950.plot_poly_fill_preprocess_loop
9900 SUBS r1, r1, #1 ; Decrement number of edges 9960 SUBS r1, r1, #1 ; Decrement number of edges
9910 LDMMIFD r13!, {r0-r4, r7-r10, pc}; Return from subroutine when finished 9970 LDMMIFD r13!, {r0-r4, r7-r10, pc}; Return from subroutine when finished
9920 LDMIA r0!, {r7-r8} ; Read line start coordinates 9980 LDMIA r0!, {r7-r8} ; Read line start coordinates
9930 MOVEQ r0, r2 ; Wrap around to the start for the end 9990 MOVEQ r0, r2 ; Wrap around to the start for the end
9940 LDMIA r0, {r9-r10} ; Read line end coordinates 10000 LDMIA r0, {r9-r10} ; Read line end coordinates
9950 CMP r7, r9 ; Do the coordinates need reversing 10010 CMP r7, r9 ; Do the coordinates need reversing
9960 MOVGT r4, r7 ; Copy first row to temporary 10020 MOVGT r4, r7 ; Copy first row to temporary
9970 MOVGT r7, r9 ; Swap row numbers 10030 MOVGT r7, r9 ; Swap row numbers
9980 MOVGT r9, r4 ; Set end row number 10040 MOVGT r9, r4 ; Set end row number
9990 MOVGT r4, r8 ; Copy first column to temporary 10050 MOVGT r4, r8 ; Copy first column to temporary
10000 MOVGT r8, r10 ; Swap column numbers 10060 MOVGT r8, r10 ; Swap column numbers
10010 MOVGT r10, r4 ; Set end column number 10070 MOVGT r10, r4 ; Set end column number
10020 CMP r7, r5 ; Compare with first row 10080 CMP r7, r5 ; Compare with first row
10030 MOVLT r5, r7 ; Update first row number is required 10090 MOVLT r5, r7 ; Update first row number is required
10040 CMP r9, r6 ; Compare with last row 10100 CMP r9, r6 ; Compare with last row
10050 MOVGT r6, r9 ; Update last row number is required 10110 MOVGT r6, r9 ; Update last row number is required
10060 MOV r8, r8, ASL#16 ; Scale start column 10120 MOV r8, r8, ASL#16 ; Scale start column
10070 MOV r10, r10, ASL#16 ; Scale end column 10130 MOV r10, r10, ASL#16 ; Scale end column
10080 STR r7, [r3] ; Store start row number 10140 STR r7, [r3] ; Store start row number
10090 STR r9, [r3, #4] ; Store end row number 10150 STR r9, [r3, #4] ; Store end row number
10100 STR r8, [r3, #8] ; Store start column number 10160 STR r8, [r3, #8] ; Store start column number
10110 STMFD r13!, {r0-r1} ; Stack registers 10170 STMFD r13!, {r0-r1} ; Stack registers
10120 SUB r0, r10, r8 ; Required column change 10180 SUB r0, r10, r8 ; Required column change
10130 SUBS r1, r9, r7 ; Required row change 10190 SUBS r1, r9, r7 ; Required row change
10140 MOVEQ r0, #0 ; Fake horizontal lines 10200 MOVEQ r0, #0 ; Fake horizontal lines
10150 BLNE divide ; Calculate column increment 10210 BLNE divide ; Calculate column increment
10160 STR r0, [r3, #12] ; Store start column number 10220 STR r0, [r3, #12] ; Store start column number
10170 LDMFD r13!, {r0-r1} ; Restore registers 10230 LDMFD r13!, {r0-r1} ; Restore registers
10180 ADD r3, r3, #16 ; Advance edge details pointer 10240 ADD r3, r3, #16 ; Advance edge details pointer
10190 B plot_poly_fill_preprocess_loop; Loop for the next edge 10250 B plot_poly_fill_preprocess_loop; Loop for the next edge
10200.plot_poly_fill_inter 10260.plot_poly_fill_inter
10210 STMFD r13!, {r0-r1, r3-r9, r14}; Stack registers 10270 STMFD r13!, {r0-r1, r3-r9, r14}; Stack registers
10220.plot_poly_fill_inter_loop 10280.plot_poly_fill_inter_loop
10230 SUBS r1, r1, #1 ; Decrement number of edges 10290 SUBS r1, r1, #1 ; Decrement number of edges
10240 LDMMIFD r13!, {r0-r1, r3-r9, pc}; Return from subroutine when finished 10300 LDMMIFD r13!, {r0-r1, r3-r9, pc}; Return from subroutine when finished
10250 LDMIA r3!, {r6-r9} ; Read the details for this edge 10310 LDMIA r3!, {r6-r9} ; Read the details for this edge
10260 CMP r6, r5 ; Is start row early enough 10320 CMP r6, r5 ; Is start row early enough
10270 BGT plot_poly_fill_inter_loop; Loop for next edge if not 10330 BGT plot_poly_fill_inter_loop; Loop for next edge if not
10280 CMP r7, r5 ; Is end row late enough 10340 CMP r7, r5 ; Is end row late enough
10290 BLE plot_poly_fill_inter_loop; Loop for next edge if not 10350 BLE plot_poly_fill_inter_loop; Loop for next edge if not
10300 SUB r6, r5, r6 ; Number of rows from start of edge 10360 SUB r6, r5, r6 ; Number of rows from start of edge
10310 MLA r8, r6, r9, r8 ; Calculate intercept column 10370 MLA r8, r6, r9, r8 ; Calculate intercept column
10320 MOV r0, r8, ASR#16 ; Scale the intercept column 10380 MOV r0, r8, ASR#16 ; Scale the intercept column
10330 ADD r6, r4, r2, LSL#2 ; The next available intersection entry 10390 ADD r6, r4, r2, LSL#2 ; The next available intersection entry
10340.plot_poly_fill_inter_insert 10400.plot_poly_fill_inter_insert
10350 TEQ r4, r6 ; Is this the start of the list 10410 TEQ r4, r6 ; Is this the start of the list
10360 BEQ plot_poly_fill_inter_done; Exit loop if the start reached 10420 BEQ plot_poly_fill_inter_done; Exit loop if the start reached
10370 LDR r7, [r6, #-4] ; Read the previous intersection 10430 LDR r7, [r6, #-4] ; Read the previous intersection
10380 CMP r0, r7 ; Should this intersection be ealier 10440 CMP r0, r7 ; Should this intersection be ealier
10390 STRLT r7, [r6], #-4 ; Shuffle down to next intersection 10450 STRLT r7, [r6], #-4 ; Shuffle down to next intersection
10400 BLT plot_poly_fill_inter_insert 10460 BLT plot_poly_fill_inter_insert
10410.plot_poly_fill_inter_done 10470.plot_poly_fill_inter_done
10420 STR r0, [r6] ; Store this intersection in the list 10480 STR r0, [r6] ; Store this intersection in the list
10430 ADD r2, r2, #1 ; Increment intersection count 10490 ADD r2, r2, #1 ; Increment intersection count
10440 B plot_poly_fill_inter_loop; Loop for next edge 10500 B plot_poly_fill_inter_loop; Loop for next edge
10450.plot_poly_fill_plot 10510.plot_poly_fill_plot
10460 STMFD r13!, {r1-r5, r14} ; Stack registers 10520 STMFD r13!, {r1-r5, r14} ; Stack registers
10470 MOV r1, r5 ; Copy row number 10530 MOV r1, r5 ; Copy row number
10480 MOV r5, r2, LSR#1 ; Calculate number of segments 10540 MOV r5, r2, LSR#1 ; Calculate number of segments
10490.plot_poly_fill_plot_loop 10550.plot_poly_fill_plot_loop
10500 SUBS r5, r5, #1 ; Decrement segment count 10560 SUBS r5, r5, #1 ; Decrement segment count
10510 LDMMIFD r13!, {r1-r5, pc} ; Return from subroutine 10570 LDMMIFD r13!, {r1-r5, pc} ; Return from subroutine
10520 LDMIA r4!, {r2-r3} ; Read segment details 10580 LDMIA r4!, {r2-r3} ; Read segment details
10530 ADD r2, r2, #1 ; Advance the start position 10590 ADD r2, r2, #1 ; Advance the start position
10540 CMP r2, r3 ; Is the segment visible 10600 CMP r2, r3 ; Is the segment visible
10550 BLLE plot_row ; Plot this segment if visible 10610 BLLE plot_row ; Plot this segment if visible
10560 B plot_poly_fill_plot_loop; Loop for the next segment 10620 B plot_poly_fill_plot_loop; Loop for the next segment
10570 10630
10580 ; Expand a single byte colour description into a full word 10640 ; Expand a single byte colour description into a full word
10590.colour_expand 10650.colour_expand
10600 ORR r0, r0, r0, LSL#8 ; Expand to 16 bits 10660 ORR r0, r0, r0, LSL#8 ; Expand to 16 bits
10610 ORR r0, r0, r0, LSL#16 ; Expand to 32 bits 10670 ORR r0, r0, r0, LSL#16 ; Expand to 32 bits
10620 MOV pc, r14 ; Return from subroutine 10680 MOV pc, r14 ; Return from subroutine
10630 10690
10640 ; Divide r0 by r1 to give r0 10700 ; Divide r0 by r1 to give r0
10650.divide STMFD r13!, {r2-r3, r14} ; Stack registers 10710.divide STMFD r13!, {r2-r3, r14} ; Stack registers
10660 CMP r0, #0 ; Is dividend negative 10720 CMP r0, #0 ; Is dividend negative
10670 RSBMI r0, r0, #0 ; Ensure dividend is positive 10730 RSBMI r0, r0, #0 ; Ensure dividend is positive
10680 BL divide_unsigned ; Perform the division 10740 BL divide_unsigned ; Perform the division
10690 RSBMI r0, r0, #0 ; Correct the sign of the result 10750 RSBMI r0, r0, #0 ; Correct the sign of the result
10700 LDMFD r13!, {r2-r3, pc} ; Return from subroutine 10760 LDMFD r13!, {r2-r3, pc} ; Return from subroutine
10710.divide_unsigned 10770.divide_unsigned
10720 MOV r3, r1 ; Copy the divisor 10780 MOV r3, r1 ; Copy the divisor
10730 CMP r3, r0, LSR#1 ; Is divisor larger than double dividend 10790 CMP r3, r0, LSR#1 ; Is divisor larger than double dividend
10740.divide_unsigned_double 10800.divide_unsigned_double
10750 MOVLS r3, r3, LSL#1 ; Double the divisor 10810 MOVLS r3, r3, LSL#1 ; Double the divisor
10760 CMPLS r3, r0, LSR#1 ; Is divisor larger than double dividend 10820 CMPLS r3, r0, LSR#1 ; Is divisor larger than double dividend
10770 BLS divide_unsigned_double ; Loop again if not large enough 10830 BLS divide_unsigned_double ; Loop again if not large enough
10780 MOV r2, #0 ; Clear the quotient 10840 MOV r2, #0 ; Clear the quotient
10790.divide_unsigned_loop 10850.divide_unsigned_loop
10800 CMP r0, r3 ; Can the divisor be subtracted 10860 CMP r0, r3 ; Can the divisor be subtracted
10810 SUBCS r0, r0, r3 ; Subtract divisor if possible 10870 SUBCS r0, r0, r3 ; Subtract divisor if possible
10820 ADC r2, r2, r2 ; Double quotient and add the new bit 10880 ADC r2, r2, r2 ; Double quotient and add the new bit
10830 MOV r3, r3, LSR#1 ; Halve the divisor 10890 MOV r3, r3, LSR#1 ; Halve the divisor
10840 CMP r3, r1 ; Has the original divisor been exceeded 10900 CMP r3, r1 ; Has the original divisor been exceeded
10850 BCS divide_unsigned_loop ; Loop if it has not 10910 BCS divide_unsigned_loop ; Loop if it has not
10860 MOV r0, r2 ; Copy the result 10920 MOV r0, r2 ; Copy the result
10870 MOVS pc, r14 ; Return from subroutine 10930 MOVS pc, r14 ; Return from subroutine
10880 10940
10890 ; Calculate the square root of an unsigned integer in r0 to give r0 10950 ; Calculate the square root of an unsigned integer in r0 to give r0
10900.sqrt STMFD r13!, {r1-r4, r14} ; Stack registers 10960.sqrt STMFD r13!, {r1-r4, r14} ; Stack registers
10910 MOV r1, r0 ; Copy the original integer 10970 MOV r1, r0 ; Copy the original integer
10920 MOV r0, #0 ; Initialise the result 10980 MOV r0, #0 ; Initialise the result
10930 MOV r2, #1<<15 ; The first bit to test 10990 MOV r2, #1<<15 ; The first bit to test
10940.sqrt_loop 11000.sqrt_loop
10950 ORR r3, r0, r2 ; Construct the current guess 11010 ORR r3, r0, r2 ; Construct the current guess
10960 MUL r4, r3, r3 ; Square the current guess 11020 MUL r4, r3, r3 ; Square the current guess
10970 CMP r4, r1 ; Compare with the required value 11030 CMP r4, r1 ; Compare with the required value
10980 MOVLS r0, r3 ; Keep the current guess if suitable 11040 MOVLS r0, r3 ; Keep the current guess if suitable
10990 MOVS r2, r2, LSR#1 ; Advance to the next bit 11050 MOVS r2, r2, LSR#1 ; Advance to the next bit
11000 BNE sqrt_loop ; Loop until all bits tested 11060 BNE sqrt_loop ; Loop until all bits tested
11010 LDMFD r13!, {r1-r4, pc} ; Return from subroutine 11070 LDMFD r13!, {r1-r4, pc} ; Return from subroutine
11020 11080
11030 ; Normalise a vector (r0, r1) to have a magnitude of 1<<16 11090 ; Normalise a vector (r0, r1) to have a magnitude of 1<<16
11040.normalise 11100.normalise
11050 STMFD r13!, {r2-r5, r14} ; Stack registers 11110 STMFD r13!, {r2-r5, r14} ; Stack registers
11060 TEQ r0, #0 ; Check horizontal component 11120 TEQ r0, #0 ; Check horizontal component
11070 TEQEQ r1, #0 ; Check vertical component 11130 TEQEQ r1, #0 ; Check vertical component
11080 BEQ normalise_done ; Unable to normalise zero vectors 11140 BEQ normalise_done ; Unable to normalise zero vectors
11090 MOVS r2, r0 ; Copy the horizontal component 11150 MOVS r2, r0 ; Copy the horizontal component
11100 RSBMI r0, r0, #0 ; Keep a positive copy 11160 RSBMI r0, r0, #0 ; Keep a positive copy
11110 MOVS r3, r1 ; Copy the vertical component 11170 MOVS r3, r1 ; Copy the vertical component
11120 RSBMI r1, r1, #0 ; Keep a positive copy 11180 RSBMI r1, r1, #0 ; Keep a positive copy
11130.normalise_prescale 11190.normalise_prescale
11140 TST r0, #1<<30 ; Is the horizontal component large 11200 TST r0, #1<<30 ; Is the horizontal component large
11150 TSTEQ r1, #1<<30 ; Is the vertical component large 11210 TSTEQ r1, #1<<30 ; Is the vertical component large
11160 BNE normalise_prescale_done ; Skip loop if large enough 11220 BNE normalise_prescale_done ; Skip loop if large enough
11170 MOV r2, r2, ASL#1 ; Double the horizontal component 11230 MOV r2, r2, ASL#1 ; Double the horizontal component
11180 MOV r0, r0, ASL#1 ; Double the horizontal component copy 11240 MOV r0, r0, ASL#1 ; Double the horizontal component copy
11190 MOV r3, r3, ASL#1 ; Double the vertical component 11250 MOV r3, r3, ASL#1 ; Double the vertical component
11200 MOV r1, r1, ASL#1 ; Double the vertical component copy 11260 MOV r1, r1, ASL#1 ; Double the vertical component copy
11210 B normalise_prescale ; Loop until large enough 11270 B normalise_prescale ; Loop until large enough
11220.normalise_prescale_done 11280.normalise_prescale_done
11230 MOV r4, r2, ASR#16 ; Scale down horizontal component 11290 MOV r4, r2, ASR#16 ; Scale down horizontal component
11240 MOV r5, r3, ASR#16 ; Scale down vertical component 11300 MOV r5, r3, ASR#16 ; Scale down vertical component
11250 MUL r0, r4, r4 ; Square the horizontal component 11310 MUL r0, r4, r4 ; Square the horizontal component
11260 MUL r1, r5, r5 ; Square the vertical component 11320 MUL r1, r5, r5 ; Square the vertical component
11270 ADD r0, r0, r1 ; Sum the squares of the lengths 11330 ADD r0, r0, r1 ; Sum the squares of the lengths
11280 BL sqrt ; Calculate the length of the vector 11340 BL sqrt ; Calculate the length of the vector
11290 TEQ r0, #0 ; Is the length zero 11350 TEQ r0, #0 ; Is the length zero
11300 MOVEQ r0, #1 ; Force a minimum length 11360 MOVEQ r0, #1 ; Force a minimum length
11310 MOV r1, r0 ; Copy length to divide by 11370 MOV r1, r0 ; Copy length to divide by
11320 MOV r0, r3 ; Copy the vertical component 11380 MOV r0, r3 ; Copy the vertical component
11330 BL divide ; Scale the vertical component 11390 BL divide ; Scale the vertical component
11340 MOV r3, r0 ; Store the scaled vertical component 11400 MOV r3, r0 ; Store the scaled vertical component
11350 MOV r0, r2 ; Copy the horizontal component 11410 MOV r0, r2 ; Copy the horizontal component
11360 BL divide ; Scale the horizontal component 11420 BL divide ; Scale the horizontal component
11370 MOV r1, r3 ; Restore the scaled vertical component 11430 MOV r1, r3 ; Restore the scaled vertical component
11380.normalise_done 11440.normalise_done
11390 LDMFD r13!, {r2-r5, pc} ; Return from subroutine 11450 LDMFD r13!, {r2-r5, pc} ; Return from subroutine
11400 11460
11410 ; Scale and translate r0 coordinates from at r1 to at r2 for the pointer 11470 ; Scale and translate r0 coordinates from at r1 to at r2 for the pointer
11420.trans_fit 11480.trans_fit
11430 STMFD r13!, {r0-r10, r14} ; Stack registers 11490 STMFD r13!, {r0-r10, r14} ; Stack registers
11440 MOV r3, #0 ; Initialise minimum row number 11500 MOV r3, #0 ; Initialise minimum row number
11450 MOV r4, #0 ; Initialise maximum row number 11510 MOV r4, #0 ; Initialise maximum row number
11460 MOV r5, #0 ; Initialise minimum column number 11520 MOV r5, #0 ; Initialise minimum column number
11470 MOV r6, #0 ; Initialise maximum column number 11530 MOV r6, #0 ; Initialise maximum column number
11480 LDR r9, [r12, #ws_yeig] ; Read the YEigFactor value 11540 LDR r9, [r12, #ws_yeig] ; Read the YEigFactor value
11490 LDR r10, [r12, #ws_xeig] ; Read the XEigFactor value 11550 LDR r10, [r12, #ws_xeig] ; Read the XEigFactor value
11500.trans_fit_loop 11560.trans_fit_loop
11510 SUBS r0, r0, #1 ; Decrement number of coordinates 11570 SUBS r0, r0, #1 ; Decrement number of coordinates
11520 BMI trans_fit_hotspot ; Exit loop when all coordinates done 11580 BMI trans_fit_hotspot ; Exit loop when all coordinates done
11530 LDMIA r1!, {r7-r8} ; Read the next coordinate pair 11590 LDMIA r1!, {r7-r8} ; Read the next coordinate pair
11540 ADD r7, r7, #1<<15 ; Improve horizontal rounding 11600 ADD r7, r7, #1<<15 ; Improve horizontal rounding
11550 MOV r7, r7, ASR#16 ; Scale column number 11610 MOV r7, r7, ASR#16 ; Scale column number
11560 MOV r7, r7, ASR r9 ; Scale by eigen value also 11620 MOV r7, r7, ASR r9 ; Scale by eigen value also
11570 ADD r8, r8, #1<<15 ; Improve horizontal rounding 11630 ADD r8, r8, #1<<15 ; Improve horizontal rounding
11580 MOV r8, r8, ASR#16 ; Scale column number 11640 MOV r8, r8, ASR#16 ; Scale column number
11590 MOV r8, r8, ASR r10 ; Scale by eigen value also 11650 MOV r8, r8, ASR r10 ; Scale by eigen value also
11600 STMIA r2!, {r7-r8} ; Write the transformed coordinates 11660 STMIA r2!, {r7-r8} ; Write the transformed coordinates
11610 CMP r7, r3 ; Compare with minimum row 11670 CMP r7, r3 ; Compare with minimum row
11620 MOVLT r3, r7 ; Update minimum row if required 11680 MOVLT r3, r7 ; Update minimum row if required
11630 CMP r7, r4 ; Compare with maximum row 11690 CMP r7, r4 ; Compare with maximum row
11640 MOVGT r4, r7 ; Update maximum row if required 11700 MOVGT r4, r7 ; Update maximum row if required
11650 CMP r8, r5 ; Compare with minimum column 11710 CMP r8, r5 ; Compare with minimum column
11660 MOVLT r5, r8 ; Update minimum column if required 11720 MOVLT r5, r8 ; Update minimum column if required
11670 CMP r8, r6 ; Compare with maximum column 11730 CMP r8, r6 ; Compare with maximum column
11680 MOVGT r6, r8 ; Update maximum column if required 11740 MOVGT r6, r8 ; Update maximum column if required
11690 B trans_fit_loop ; Loop for the next coordinate pair 11750 B trans_fit_loop ; Loop for the next coordinate pair
11700.trans_fit_hotspot 11760.trans_fit_hotspot
11710 LDRB r0, [r12, #ws_ptr_block_activey]; Read last vertical hotspot 11770 LDRB r0, [r12, #ws_ptr_block_activey]; Read last vertical hotspot
11720 LDRB r1, [r12, #ws_ptr_block_activex]; Read last horizontal hotspot 11780 LDRB r1, [r12, #ws_ptr_block_activex]; Read last horizontal hotspot
11730 ADD r7, r4, r0 ; Calculate last used row 11790 ADD r7, r4, r0 ; Calculate last used row
11740 RSBS r7, r7, #31 ; Number of spare pixels at the bottom 11800 RSBS r7, r7, #31 ; Number of spare pixels at the bottom
11750 ADDMI r0, r0, r7 ; Force last row within pointer 11810 ADDMI r0, r0, r7 ; Force last row within pointer
11760 ADDS r7, r3, r0 ; Calculate first used row 11820 ADDS r7, r3, r0 ; Calculate first used row
11770 SUBMI r0, r0, r7 ; Force first row within pointer 11830 SUBMI r0, r0, r7 ; Force first row within pointer
11780 CMP r0, #0 ; Is hotspot within the pointer 11840 CMP r0, #0 ; Is hotspot within the pointer
11790 MOVLT r0, #0 ; Hotspot must be positive 11850 MOVLT r0, #0 ; Hotspot must be positive
11800 CMP r0, #31 ; Is hotspot within the pointer 11860 CMP r0, #31 ; Is hotspot within the pointer
11810 MOVGT r0, #31 ; Restrict hotspot to within pointer 11870 MOVGT r0, #31 ; Restrict hotspot to within pointer
11820 ADD r8, r6, r1 ; Calculate last used column 11880 ADD r8, r6, r1 ; Calculate last used column
11830 RSBS r8, r8, #31 ; Number of spare pixels at the right 11890 RSBS r8, r8, #31 ; Number of spare pixels at the right
11840 ADDMI r1, r1, r8 ; Force last column within pointer 11900 ADDMI r1, r1, r8 ; Force last column within pointer
11850 ADDS r8, r5, r1 ; Calculate first used column 11910 ADDS r8, r5, r1 ; Calculate first used column
11860 SUBMI r1, r1, r8 ; Force first column within pointer 11920 SUBMI r1, r1, r8 ; Force first column within pointer
11870 CMP r1, #0 ; Is hotspot within the pointer 11930 CMP r1, #0 ; Is hotspot within the pointer
11880 MOVLT r1, #0 ; Hotspot must be positive 11940 MOVLT r1, #0 ; Hotspot must be positive
11890 CMP r1, #31 ; Is hotspot within the pointer 11950 CMP r1, #31 ; Is hotspot within the pointer
11900 MOVGT r1, #31 ; Restrict hotspot to within pointer 11960 MOVGT r1, #31 ; Restrict hotspot to within pointer
11910 STRB r0, [r12, #ws_ptr_block_activey]; Store vertical hotspot 11970 STRB r0, [r12, #ws_ptr_block_activey]; Store vertical hotspot
11920 STRB r1, [r12, #ws_ptr_block_activex]; Store horizontal hotspot 11980 STRB r1, [r12, #ws_ptr_block_activex]; Store horizontal hotspot
11930.trans_fit_done 11990.trans_fit_done
11940 LDMFD r13!, {r0-r10, pc} ; Return from subroutine 12000 LDMFD r13!, {r0-r10, pc} ; Return from subroutine
11950 12010
11960 ; Rotate r0 coordinates from at r1 to at r2 with vertical (r4, r3) 12020 ; Rotate r0 coordinates from at r1 to at r2 with vertical (r4, r3)
11970.trans_rotate 12030.trans_rotate
11980 STMFD r13!, {r0-r8, r14} ; Stack registers 12040 STMFD r13!, {r0-r8, r14} ; Stack registers
11990 STMFD r13!, {r0-r1} ; Stack registers 12050 STMFD r13!, {r0-r1} ; Stack registers
12000 MOV r0, r3 ; Copy vertical row 12060 MOV r0, r3 ; Copy vertical row
12010 MOV r1, r4 ; Copy vertical column 12070 MOV r1, r4 ; Copy vertical column
12020 BL normalise ; Normalise the vertical vector 12080 BL normalise ; Normalise the vertical vector
12030 MOV r3, r0, ASR#8 ; Copy and scale normalised row 12090 MOV r3, r0, ASR#8 ; Copy and scale normalised row
12040 MOV r4, r1, ASR#8 ; Copy and scale normalised column 12100 MOV r4, r1, ASR#8 ; Copy and scale normalised column
12050 LDMFD r13!, {r0-r1} ; Restore registers 12110 LDMFD r13!, {r0-r1} ; Restore registers
12060.trans_rotate_loop 12120.trans_rotate_loop
12070 SUBS r0, r0, #1 ; Decrement number of coordinates 12130 SUBS r0, r0, #1 ; Decrement number of coordinates
12080 LDMMIFD r13!, {r0-r8, pc} ; Return from subroutine when finished 12140 LDMMIFD r13!, {r0-r8, pc} ; Return from subroutine when finished
12090 LDMIA r1!, {r5-r6} ; Read the next coordinate pair 12150 LDMIA r1!, {r5-r6} ; Read the next coordinate pair
12100 MOV r5, r5, ASR#8 ; Prescale the row number 12160 MOV r5, r5, ASR#8 ; Prescale the row number
12110 MOV r6, r6, ASR#8 ; Prescale the column number 12170 MOV r6, r6, ASR#8 ; Prescale the column number
12120 MUL r7, r5, r3 ; Rotate row to row 12180 MUL r7, r5, r3 ; Rotate row to row
12130 RSB r7, r7, #0 ; Correct sign of row rotation 12190 RSB r7, r7, #0 ; Correct sign of row rotation
12140 MUL r8, r5, r4 ; Rotate row to column 12200 MUL r8, r5, r4 ; Rotate row to column
12150 MLA r7, r6, r4, r7 ; Rotate column to row 12210 MLA r7, r6, r4, r7 ; Rotate column to row
12160 MLA r8, r6, r3, r8 ; Rotate column to column 12220 MLA r8, r6, r3, r8 ; Rotate column to column
12170 RSB r8, r8, #0 ; Correct sign of column rotation 12230 RSB r8, r8, #0 ; Correct sign of column rotation
12180 STMIA r2!, {r7-r8} ; Write the transformed coordinates 12240 STMIA r2!, {r7-r8} ; Write the transformed coordinates
12190 B trans_rotate_loop ; Keep looping until all processed 12250 B trans_rotate_loop ; Keep looping until all processed
12200 12260
12210 ; Add r0 coordinates at r1 to r3 fraction of those at r2 to give at r4 12270 ; Add r0 coordinates at r1 to r3 fraction of those at r2 to give at r4
12220.trans_add 12280.trans_add
12230 STMFD r13!, {r0-r8, r14} ; Stack registers 12290 STMFD r13!, {r0-r8, r14} ; Stack registers
12240 MOV r3, r3, ASR#8 ; Prescale the required fraction 12300 MOV r3, r3, ASR#8 ; Prescale the required fraction
12250.trans_add_loop 12310.trans_add_loop
12260 SUBS r0, r0, #1 ; Decrement number of coordinates 12320 SUBS r0, r0, #1 ; Decrement number of coordinates
12270 LDMMIFD r13!, {r0-r8, pc} ; Return from subroutine when finished 12330 LDMMIFD r13!, {r0-r8, pc} ; Return from subroutine when finished
12280 LDMIA r1!, {r5-r6} ; Read the original coordinates 12340 LDMIA r1!, {r5-r6} ; Read the original coordinates
12290 LDMIA r2!, {r7-r8} ; Read the new coordinates 12350 LDMIA r2!, {r7-r8} ; Read the new coordinates
12300 MOV r7, r7, ASR#8 ; Prescale the new row number 12360 MOV r7, r7, ASR#8 ; Prescale the new row number
12310 MOV r8, r8, ASR#8 ; Prescale the new column number 12370 MOV r8, r8, ASR#8 ; Prescale the new column number
12320 MLA r5, r7, r3, r5 ; Add the required row fraction 12380 MLA r5, r7, r3, r5 ; Add the required row fraction
12330 MLA r6, r8, r3, r6 ; Add the required column fraction 12390 MLA r6, r8, r3, r6 ; Add the required column fraction
12340 STMIA r4!, {r5-r6} ; Write the updated coordinates 12400 STMIA r4!, {r5-r6} ; Write the updated coordinates
12350 B trans_add_loop ; Keep looping until all processed 12410 B trans_add_loop ; Keep looping until all processed
12360 12420
12370 ] 12430 ]
12380NEXT 12440NEXT
12390 12450
12400REM Save the resulting module 12460REM Save the resulting module
12410SYS "OS_File", 10, filename$, &ffA,, code%, code% + P% 12470SYS "OS_File", 10, filename$, &ffA,, code%, code% + P%
12420END 12480END
12430 12490
12440REM The name and corresponding type of a pointer 12500REM The name and corresponding type of a pointer
12450DEFFNpointer(name$, type%) 12510DEFFNpointer(name$, type%)
12460 [OPT opt% 12520 [OPT opt%
12470 EQUS name$ + STRING$(12 - LEN(name$), CHR$0) 12530 EQUS name$ + STRING$(12 - LEN(name$), CHR$0)
12480 EQUD type% 12540 EQUD type%
12490 ] 12550 ]
12500= 0 12560= 0
12510 12570
12520REM Literal fixed point coordinate pair 12580REM Literal fixed point coordinate pair
12530DEFFNcoordinate(row, column) 12590DEFFNcoordinate(row, column)
12540 [OPT opt% 12600 [OPT opt%
12550 EQUD INT(row * (1 << 16)) 12610 EQUD INT(row * (1 << 16))
12560 EQUD INT(column * (1 << 16)) 12620 EQUD INT(column * (1 << 16))
12570 ] 12630 ]
12580= 0 12640= 0
12590 12650
12600REM Read a word from a non-aligned address 12660REM Read a word from a non-aligned address
12610DEFFNldru(rd, ra, rb, rc) 12670DEFFNldru(rd, ra, rb, rc)
12620 [OPT opt% 12680 [OPT opt%
12630 BIC rb, ra, #3 ; Get word aligned address 12690 BIC rb, ra, #3 ; Get word aligned address
12640 LDMIA rb, {rd, rc} ; Get 64 bits containing answer 12700 LDMIA rb, {rd, rc} ; Get 64 bits containing answer
12650 AND rb, ra, #3 ; Correction factor in bytes 12710 AND rb, ra, #3 ; Correction factor in bytes
12660 MOVS rb, rb, LSL#3 ; and in bits, so check if aligned 12720 MOVS rb, rb, LSL#3 ; and in bits, so check if aligned
12670 MOVNE rd, rd, LSR rb ; If not, produce bottom bits of result 12730 MOVNE rd, rd, LSR rb ; If not, produce bottom bits of result
12680 RSBNE rb, rb, #32 ; Get other shift amount 12740 RSBNE rb, rb, #32 ; Get other shift amount
12690 ORRNE rd, rd, rc, LSL rb ; Combine two halves for result 12750 ORRNE rd, rd, rc, LSL rb ; Combine two halves for result
12700 ] 12760 ]
12710= 0 12770= 0