; decasteljau recursive algorithm for 'drawing' a
; bezier curve.
;-----------------------------------------------------
AREA bezier, CODE
ENTRY
Start ldfs F0, X0
stfs F0, [SP, #-4]!
ldfs F0, Y0
stfs F0, [SP, #-4]!
ldfs F0, X1
stfs F0, [SP, #-4]!
ldfs F0, Y1
stfs F0, [SP, #-4]!
ldfs F0, X2
stfs F0, [SP, #-4]!
ldfs F0, Y2
stfs F0, [SP, #-4]!
ldfs F0, X3
stfs F0, [SP, #-4]!
ldfs F0, Y3
stfs F0, [SP, #-4]!
bl DeCasteljau
add SP, SP, #32
swi &11
;-----------------------------------------------------
X0 DCFS 0
Y0 DCFS 0
X1 DCFS 10
Y1 DCFS 10
X2 DCFS 5
Y2 DCFS 2
X3 DCFS 10
Y3 DCFS 1
Thresh DCFS 2
;-----------------------------------------------------
sX0 EQU 36
sY0 EQU 32
sX1 EQU 28
sY1 EQU 24
sX2 EQU 20
sY2 EQU 16
sX3 EQU 12
sY3 EQU 8
DeCasteljau str LR, [SP, #-4]! ; +4
str ip, [SP, #-4]! ; +0
mov ip, SP
stfs F0, [SP, #-4]! ; -4
stfs F1, [SP, #-4]! ; -8
stfs F2, [SP, #-4]! ; -12
stfs F3, [SP, #-4]! ; -16
ldfs F0, [ip, #sX0]
ldfs F1, [ip, #sY0]
ldfs F2, [ip, #sX3]
ldfs F3, [ip, #sY3]
bl Distance
ldfs F1, Thresh
cmf F0, F1
bge iterjau
ldfs F0, [ip, #sX0]
ldfs F1, [ip, #sY0]
bl Plot_Line
ldfs F3, [SP], #4
ldfs F2, [SP], #4
ldfs F1, [SP], #4
ldfs F0, [SP], #4
ldr ip, [SP], #4
ldr PC, [SP], #4
iterjau stfs F4, [SP, #-4]! ; -20
stfs F5, [SP, #-4]! ; -24
stfs F6, [SP, #-4]! ; -28
stfs F7, [SP, #-4]! ; -32
sub SP, SP, #16 ; -36, -40, -44, -48
ldfs F0, [ip, #sX0]
ldfs F1, [ip, #sX1]
adfs F0, F0, F1 ; P01x
dvfs F7, F0, #2 ; X0 + X1 / 2
ldfs F0, [ip, #sY0]
ldfs F1, [ip, #sY1]
adfs F0, F0, F1 ; P01y
dvfs F6, F0, #2 ; Y0 + Y1 / 2
ldfs F0, [ip, #sX1]
ldfs F1, [ip, #sX2]
adfs F0, F0, F1 ; P12x
dvfs F5, F0, #2 ; X1 + X2 / 2
ldfs F0, [ip, #sY1]
ldfs F1, [ip, #sY2]
adfs F0, F0, F1 ; P12y
dvfs F4, F0, #2 ; Y1 + Y2 / 2
ldfs F0, [ip, #sX2]
ldfs F1, [ip, #sX3]
adfs F0, F0, F1 ; P23x
dvfs F3, F0, #2 ; X2 + X3 / 2
ldfs F0, [ip, #sY2]
ldfs F1, [ip, #sY3]
adfs F0, F0, F1 ; P23y
dvfs F2, F0, #2 ; Y2 + Y3 / 2
adfs F1, F7, F5 ; P012x
dvfs F1, F1, #2 ; P01x + P12x / 2
adfs F0, F6, F4 ; P012y
dvfs F0, F0, #2 ; P01y + P12y / 2
adfs F5, F5, F3 ; P123x
dvfs F5, F5, #2 ; P12x + P23x / 2
adfs F4, F4, F2 ; P123y
dvfs F4, F4, #2 ; P12y + P23y / 2
stfs F5, [ip, #-36]
stfs F4, [ip, #-40]
stfs F3, [ip, #-44]
stfs F2, [ip, #-48]
adfs F3, F1, F5 ; P0123x
dvfs F3, F3, #2 ; P012x + P123x / 2
adfs F2, F0, F4 ; P0123y
dvfs F2, F2, #2 ; P012y + P123y / 2
ldfs F5, [ip, #sX0]
ldfs F4, [ip, #sY0]
stfs F5, [SP, #-4]!
stfs F4, [SP, #-4]!
stfs F7, [SP, #-4]!
stfs F6, [SP, #-4]!
stfs F1, [SP, #-4]!
stfs F0, [SP, #-4]!
stfs F3, [SP, #-4]!
stfs F2, [SP, #-4]!
bl DeCasteljau ; don't add to SP..
ldfs F5, [ip, #-36]
ldfs F4, [ip, #-40]
ldfs F7, [ip, #-44]
ldfs F6, [ip, #-48]
ldfs F1, [ip, #sX3]
ldfs F0, [ip, #sY3]
stfs F3, [SP, #28] ; ..just change the
stfs F2, [SP, #24] ; values on the stack.
stfs F5, [SP, #20]
stfs F4, [SP, #16]
stfs F7, [SP, #12]
stfs F6, [SP, #8]
stfs F1, [SP, #4]
stfs F0, [SP]
bl DeCasteljau
add SP, SP, #48
ldfs F7, [SP], #4
ldfs F6, [SP], #4
ldfs F5, [SP], #4
ldfs F4, [SP], #4
ldfs F3, [SP], #4
ldfs F2, [SP], #4
ldfs F1, [SP], #4
ldfs F0, [SP], #4
ldr ip, [SP], #4
ldr PC, [SP], #4
;-----------------------------------------------------
Plot_Line str LR, [SP, #-4]!
str R0, [SP, #-4]!
mov R0, #'<'
swi &0
fix R0, F0
str R0, [SP, #-4]!
bl Print_Number
mov R0, #','
swi &0
fix R0, F1
str R0, [SP]
bl Print_Number
mov R0, #'>'
swi &0
mov R0, #' '
swi &0
mov R0, #'-'
swi &0
swi &0
mov R0, #' '
swi &0
mov R0, #'<'
swi &0
fix R0, F2
str R0, [SP]
bl Print_Number
mov R0, #','
swi &0
fix R0, F3
str R0, [SP]
bl Print_Number
mov R0, #'>'
swi &0
mov R0, #10
swi &0
add SP, SP, #4
ldr R0, [SP], #4
ldr PC, [SP], #4
;-----------------------------------------------------
Distance stfs F1, [SP, #-4]!
sufs F0, F2, F0
sufs F1, F3, F1
mufs F1, F1, F1
mufs F0, F0, F0
adfs F0, F0, F1
sqts F0, F0
ldfs F1, [SP], #4
mov PC, LR
;-----------------------------------------------------
Print_Number str LR, [SP, #-4]! ; +20
str ip, [SP, #-4]! ; +16
str R0, [SP, #-4]! ; +12
str R1, [SP, #-4]! ; +8
str R2, [SP, #-4]! ; +4
str R3, [SP, #-4]! ; +0
mov ip, SP
ldr R0, [ip, #24] ; number, via stack
mov R3, #0
tst R0, #2,2
beq skipNegLp
sub R1, R0, #1
mov R0, #'-'
swi &0
mvn R0, R1
skipNegLp add R3, R3, #1
bl UDiv10
str R1, [SP, #-4]!
cmp R0, #0
bne skipNegLp
pDigitsLp ldr R0, [SP], #4
add R0, R0, #'0'
swi &0
sub R3, R3, #1
cmp R3, #0
bne pDigitsLp
ldr R3, [SP], #4
ldr R2, [SP], #4
ldr R1, [SP], #4
ldr R0, [SP], #4
ldr ip, [SP], #4
ldr PC, [SP], #4
;-----------------------------------------------------
UDiv10 sub R1, R0, #10
sub R0, R0, R0, LSR #2
add R0, R0, R0, LSR #4
add R0, R0, R0, LSR #8
add R0, R0, R0, LSR #16
mov R0, R0, LSR #3
add R2, R0, R0, LSL #2
subs R1, R1, R2, LSL #1
addpl R0, R0, #1
addmi R1, R1, #10
mov PC, LR
;-----------------------------------------------------
END
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.