Author Topic: Routines  (Read 293443 times)

0 Members and 1 Guest are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Routines
« Reply #450 on: November 03, 2010, 06:50:58 pm »
Yeah, and I really like the way you did the grayscale, Builderboy.

[/offtopic]Right, I just uploaded that pic today, though :P[/offtopic]
« Last Edit: November 03, 2010, 06:53:30 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #451 on: November 04, 2010, 03:51:35 am »
Well, dungeon generation would require a lot of changes, though, so rooms won't look weird.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Routines
« Reply #452 on: November 08, 2010, 10:48:51 pm »
This is a variant of Bresenham's line algorithm that radiates lines outwards (which you could use for raycasting (*cough*) and can draw points at intervals.
Arrows to move, clear to quit, plus and minus to increase/decrease interval.
I purposely added a pause so you can see how it radiates outwards.
(It needs optimization, though, and I'd really appreciate it if anybody could find a way to increase its speed)

Code: [Select]
.LINE
ClrDraw
50->A->B
2->L

Repeat getKey(15)
  If getKey
    getKey(3)-getKey(2)+A->A
    getKey(1)-getKey(4)+B->B
    getKey(10)-getKey(11)+L->L
    L=0+L->L
    sub(LIN,30,30,A,B,L)    //r1 and r2 are the x and y coordinates of the starting point - it radiates out to (r3,r4).  r5 is the interval between points and 1 is minimum.
  End
  DispGraph
End
Return

Lbl LIN
  If abs(r4-r2)>abs(r3-r1)
    Exch(°r1,°r2,2)
    Exch(°r3,°r2,2)
  End
  r1>r3->K
  abs(r3-r1)->S/2->V
  abs(r4-r2)->T
  r2->Y<r4*2-1->W
  For(Z,0,abs(r3-r1)/r5)
    Z*r5->X
    If K
      -X->X
    End
    If U
      Pxl-On(Y,X+r1)
    Else
      Pxl-On(X+r1,Y)
    End
    R5->I
    While I
      I-1->I
      If V-T->V>99
        Y+W->Y
        V+S->V
      End
    End
    DispGraph  //DispGraph and Pause are added to show how the line radiates outwards
    Pause 50
  End
Return
« Last Edit: November 08, 2010, 10:54:04 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Routines
« Reply #453 on: November 08, 2010, 10:51:54 pm »
Looks great Michael!  Nice job. :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #454 on: November 08, 2010, 11:19:23 pm »
Hmm interesting stuff

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #455 on: November 14, 2010, 09:50:35 pm »
This is hardly a routine, as it's only a one-liner, but it can be quite useful to know if you use any Shade() commands in your program to change the contrast. No more exiting your program with a contrast value you hope was close to the original value! The following line of code will set the screen's contrast to the value the user/OS previously had it set at:

Code: [Select]
Shade({ᴇ8447}ʳ+24)
Note: The contrast value is actually only one byte, not two as the ʳ would suggest. The ʳ is just included as an optimization.
« Last Edit: November 14, 2010, 09:53:17 pm by Runer112 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #456 on: November 15, 2010, 02:07:26 am »
Ooooh I never thought about doing that before! I tried figuring out from WikiTI how to change the contrast directly by setting a different value to the memory address, but it did not update the LCD contrast itself, just its value in the memory. Should be useful for game fade-in/out effects. :)

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Routines
« Reply #457 on: November 15, 2010, 02:31:43 pm »
Speaking of fade in/out effects, here's a variant that doesn't mess with the contrast (the ones that do always look weird to me, I don't know why :P)

Code: [Select]
RecallPic
DrawInv ʳ
For(E,0,15
DispGraphʳ
End
Clrdraw
DrawInv
For(E,0,10)
DispGraph
End
« Last Edit: November 28, 2010, 09:42:30 am by squidgetx »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Routines
« Reply #458 on: November 15, 2010, 06:31:23 pm »
Speaking of fade in/out effects, here's a variant that doesn't mess with the contrast (the ones that do always look weird to me, I don't know why :P)

Code: [Select]
RecallPic
ClrDrawʳ
DrawInv ʳ
For(E,0,15
DispGraphʳ
End
Clrdraw
DrawInv
For(E,0,10)
DispGraph
End

Nice, and an added benefit is that interrupts get disabled temporarily with Shade(.




Offline Kiligolo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 218
  • Rating: +10/-1
    • View Profile
Re: Routines
« Reply #459 on: November 22, 2010, 05:29:41 am »
Hello, I have a problem:
In the input routine, I have ERR:BAD SYMBOL on :
Code: (Axe) [Select]
Output(1+{Pic99+2}-A,{E844B},{Pic99}r^10+48?Frac
Thanks for your help. :)
« Last Edit: November 22, 2010, 05:31:00 am by Kiligolo »
Spoiler For Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler For Some screen shots:
       
The screenshots are in french but there is an english version

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #460 on: November 22, 2010, 01:40:11 pm »
That looks fine to me. Make sure the program is in RAM, try to compile it again, and press PRGM when you get the error. Where does the cursor scroll to?

Offline Kiligolo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 218
  • Rating: +10/-1
    • View Profile
Re: Routines
« Reply #461 on: November 22, 2010, 02:15:20 pm »
To O (the output( 's beginning)

I it help you. I put the whole code:
Code: [Select]
Lbl A
[000000000000000→Pic99
A→{Pic99}r
If {Pic99}r>9
1→{Pic99+2
End
If {Pic99}r>99
2→{Pic99+2
End
If {Pic99}r>999
3→{Pic99+2
End
If {Pic99}r>9999
4→{Pic99+2
End
For(A,0,{Pic99+2
Output(1+{Pic99+2}-A,{ᴱ844B},{Pic99}r^10+48►Frac
{Pic99}r/10→{Pic99}r
End
ᴱ is on the bouton , (EE)
« Last Edit: November 22, 2010, 02:22:38 pm by Kiligolo »
Spoiler For Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler For Some screen shots:
       
The screenshots are in french but there is an english version

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #462 on: November 22, 2010, 02:20:37 pm »
Output(1+{Pic99+2}-A,{E844B},{Pic99}r^10+48►Frac) with the closed parenthesis doesn't work either?

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #463 on: November 22, 2010, 02:27:31 pm »
This is an excellent example of why it is best NOT to omit closing parentheses and brackets. I wasn't kidding when I made this post :P. The error is occuring because you didn't add a closing bracket on {Pic99+2 in the line immediately before it.
« Last Edit: November 22, 2010, 02:31:11 pm by Runer112 »

Offline Kiligolo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 218
  • Rating: +10/-1
    • View Profile
Re: Routines
« Reply #464 on: November 22, 2010, 02:35:23 pm »
I'm going to try it...

It works! Thanks you for your help. :D
Spoiler For Calcul Mental:
Version 1.3 :100%!!
Here is a program that reduces your dependence on the calculator! Click here!
Spoiler For Some screen shots:
       
The screenshots are in french but there is an english version