Author Topic: Routines  (Read 313393 times)

0 Members and 1 Guest are viewing this topic.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Routines
« Reply #615 on: February 10, 2013, 02:19:35 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.
Reading the clock works great :)
But why does setting it does nothing (as mentionned in your post) ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Routines
« Reply #616 on: July 04, 2013, 06:04:00 am »
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.
« Last Edit: July 04, 2013, 06:04:42 am by Matrefeytontias »

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Routines
« Reply #617 on: July 04, 2013, 12:20:06 pm »
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: [Select]
If Y<64

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

Code: [Select]
!If Y.π1111111111000000

if y<0 or Y>64 it will not draw anything  ;D
« Last Edit: July 04, 2013, 12:21:03 pm by TheMachine02 »
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Routines
« Reply #618 on: July 04, 2013, 12:26:23 pm »
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

Offline TheMachine02

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 452
  • Rating: +105/-0
  • me = EF99+F41A
    • View Profile
Re: Routines
« Reply #619 on: July 04, 2013, 12:30:29 pm »
Oh yes effectively.   I take Y<64 for Y<<64    ;D
I don't know if   !If Y.π1111111111000000  is more faster  ,thought
AXE/asm programmer - unleash the power of z80 //C++//C

epic 3D things http://www.ntu.edu.sg/home/ehchua/programming/opengl/CG_BasicsTheory.html

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Routines
« Reply #620 on: July 04, 2013, 12:31:16 pm »
I don't know ... I guess we'll have to test it ;D (I won't do it though :P)

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Routines
« Reply #621 on: August 09, 2013, 05:32:08 pm »
Asm(DB02CB7FC8)
This opcode is a conditional Return. If run on an 83+BE it will return else it will continue along. More efficient than Return!If Full:Normal. ;)

Offline nikitouzz

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 215
  • Rating: +22/-1
    • View Profile
Re: Routines
« Reply #622 on: May 08, 2014, 04:49:25 pm »
Runer112 : "Decimal display: Disp Pointer to number to display sub(DEC) - Note that this does not return a string of a fixed length padded on the left with spaces like the usual Disp ►Dec. The string returned has any leading zeros clipped and consists only of the number itself."

When i try to use the fonctions dec.... text(32,71,°Osub(DEC^^r)) the programm don't function and the calto crash.... but on another programme, it work...

Then i want replace all the E8499 and Eblabla by L2 and L2+100 i've make this :

L2→r1
L2+100→r2
and i replace all the E... by r1 or r2 but... the calculator crash...


Code: [Select]
:Lbl DEC
:L2→r1
:L2+100→r2
:  conj(,R1,3)
:  0→{R2}r
:  Fill(1+R2,8)
:  R2→{10+R1}r
:  0+R1→r1
:  4+R1→r2
:  0+R1→r3
:  ([806967])
:  sub(DE0)
:  ([C0BDF0])
:  sub(DE0)
:  ([6079FE])
:  sub(DE0)
:  ([F0D8FF])
 :  sub(DE0)
:  ([18FCFF])
:  sub(DE0)
:  ([9CFFFF])
:  sub(DE0)
:  ([F6FFFF])
:  sub(DE0)
:  ([FFFFFF])
:  sub(DE0)
:  R2
:  Return
:  Lbl DE0
:  conj(,4+R1,3)
:  '0'-1→{8+R1}r
:  Lbl DE1
:  {8+R1}r+1→{8+R1}r
:  If {2+R1}≥{sub(ADD)}
:       Goto DE1
:  End
:  sub(SUB)
:  Return!If {4+R1}+1/256+{8+R1}r-'0'+{R2}r
:     {8+R1}r→{{10+R1}r}+1→{10+R1}r
:Return








PS : i don't use L2 in my programme
« Last Edit: May 08, 2014, 05:05:53 pm by nikitouzz »
mes records personels :

2x2x2 : 2.18 secondes / 2x2x2 une main : 21.15 secondes / 2x2x2 yeux bandés : 47.59
3x3x3 : 5.97 secondes / 3x3x3 une main : 49.86 secondes
4x4x4 : 1.49 minutes / 4x4x4 une main : 6.50 minutes
5x5x5 : 4.10 minutes / 5x5x5 une main : 18.02 minutes
6x6x6 : 8.10 minutes
7x7x7 : 16.03 minutes
9x9x9 : 58.26 minutes

megaminx : 5.59 minutes / pyraminx : 7.91 secondes / square-one : 1.07 minutes

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Routines
« Reply #623 on: March 11, 2015, 04:41:47 pm »
-German Kuznetsov
The impossible chemical compound.