Calculator Community > Axe

Routines

<< < (124/125) > >>

Hayleia:

--- Quote from: jacobly on December 11, 2011, 02:31:21 am ---Due to multiple requests, I wrote an axe clock library, LIBCLOCK. See CLOCKTST for example code.

Axe Code Function on calculators with a clock (function on calculators without a clock).

Main functions:
ClkOf() Turns the clock off (does nothing).
ClkOn() Turns the clock on (does nothing).
IsClk() Returns 1 if the clock is on, 0 if off (returns 0).
°A:GetDT() Gets the current date and time. Sets 6 consecutive variables, or 6 consecutive words, starting at the passed in address.  In this example, A = year, B = month, C = day, D = hour, E = minute, F = second (returns midnight of January 1, 1997). Do not pass in °r₁.
SetDT(year,month,day,hour,minute,second) Sets the current date and time (does nothing relatively slowly).
DOfWk(year,month,day) Returns the day of the week of the specified date, 1 = Sunday, ..., 7 = Saturday.

Low level functions:
°A:GetRT() Gets the current raw time. Sets 2 consecutive variables, or 2 consecutive words, starting at the passed in address.  In this example, AB = seconds since January 1, 1997 (AB = 0).
°A:SetRT() Sets the current raw time.  Uses 2 consecutive variables, or 2 consecutive words, starting at the passed in address (does nothing).

Bonus functions:
Mul21(r₁,r₂,r₃) Multiplies r₁r₂ by r₃ and stores the result in r₁r₂.
Div21(r₁,r₂,r₃) Divides r₁r₂ by r₃ and stores the result in r₁r₂, and the remainder in r₄. Edit: I think r₃ must be < 256.

--- End quote ---
Reading the clock works great :)
But why does setting it does nothing (as mentionned in your post) ?

Matrefeytontias:
Mega bump,

I wrote this for TheMachine02's GLib, and thought it could be useful to others (even if I doubt so :P). So here's a clipped triangle filler that takes arguments between -512 and 511 (might be a bit inaccurate though, and is surely unoptimized) :

Triangle(x1,y1,x2,y2,x3,y3)

E90D3→°DX1+2→°DX2+2→°SX1+2→°SX2

Lbl Triangle
If r2>>r4
Exch(°r1,°r3,4)
End
If r4>>r6
Exch(°r3,°r5,4)
End
If r2>>r4
Exch(°r1,°r3,4)
End

If r4-r2→X
r3-r1*64//X
Else
r3-r1*64
End
→DX1
If r6-r2→X
r5-r1*64//X
Else
r5-r1*64
End
→DX2

r1*64→SX1→SX2
r2→Y

For(2)
While 1
If Y<64
!If SX1·SX2ee0
min(max(SX1,0)r/64,95)→Z
min(max(SX2,0)r/64,95)→Θ
.Remember that HLine(Y,X1,X) is broken in 1.2.1, so remember to update it with the next versions of Axe
Line(Z,Y,Θ,Y)
End
End
DX1+SX1→SX1
DX2+SX2→SX2
Y++
EndIf Y+1>>r4
If r6-r4→X
r5-r3*64//X
Else
r5-r3*64
End
→DX1
r6→r4
End
And yeah. This routine uses 10.6 fixed point numbers.

TheMachine02:
there is just a little problem in your routine  :P , wich is, in other part very good
You don't do a perfect clipping due to one line :


--- Code: ---If Y<64

--- End code ---

who let enter in the drawing part even if y<0 ...
you can do this instead :


--- Code: ---!If Y.π1111111111000000

--- End code ---

if y<0 or Y>64 it will not draw anything  ;D

Matrefeytontias:
You're wrong : I test if the unsigned value of Y is lesser than 64. If Y is lesser than 0, the 15th bit will be set, making it at least 32768. So it's okay. I would have been wrong if I had used :

If Y<<64

TheMachine02:
Oh yes effectively.   I take Y<64 for Y<<64    ;D
I don't know if   !If Y.π1111111111000000  is more faster  ,thought

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version