Author Topic: Routines  (Read 314099 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #390 on: August 26, 2010, 11:07:09 pm »
That said, it is very possible to do cool stuff with the old functions already. A lot of the new stuff that got added is much more low level or technical, like fixed points, which I never got able to understand, even with the tutorials. I still recommend using the latest Axe, though, for optimization and safety.


Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Routines
« Reply #391 on: September 04, 2010, 02:27:28 pm »
By the way, I think I forgot to mention during the last update the additional uses for the inData() command because its more powerful than it looks.

First thing, yes, it can be used to find the position of a character in a string:
Code: [Select]
inData('I',"IGNITION")->L
To find the second, third, etc. instance of 'I', you could loop through this.
Code: [Select]
inData('I',"IGNITION"+L)->L
This moves the pointer to the spot directly after the last character found so it starts looking at the 'G' until it gets to the end.

Another use for this is to see if a number is part of a specific group.  The only problem with this is that 0 is always found at the end since its the terminating character.  So you should check for 0 before using the inData() command usually.  Another thing to mention is that inData() only works with bytes so make sure you guarantee that your input is restricted to numbers between 0 to 255 or -128 to 127.

Code: [Select]
.Inefficient
If (A=3 or (A=5) or (A=20) or (A=28) or (A=61))
.Some code
End

.Efficient
If A
  If inData(A,Data(3,5,20,28,61,0))
  .Some code
  End
End
This is probably unnoticeable slower, but its much smaller and the routine is a subroutine so using it more than once in your program will definitely be a large size optimization.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Routines
« Reply #392 on: September 04, 2010, 02:36:50 pm »
wow! nice hint! I myself wouldn't have thought of it. I'm really gonna use this.
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline coolsnake

  • LV2 Member (Next: 40)
  • **
  • Posts: 36
  • Rating: +2/-0
    • View Profile
Re: Routines
« Reply #393 on: September 04, 2010, 04:14:19 pm »
Ow just the thing I needed, thank you :D
Unpretty Integrals
This program gives you a graphical representation of the "fnint(" function, which allows you to calculate definite integrals. It is extremely similar to the functionality MathPrint provides, minus the extreme bloat that slows your calculator down to a crawl.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #394 on: September 04, 2010, 04:24:42 pm »
Wow, looks like the inData is a really powerful command!  Im going to have to use this now in all of my programs :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #395 on: September 04, 2010, 07:49:37 pm »
Nice, that could become useful eventually :)

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 #396 on: September 07, 2010, 07:57:31 pm »
Wow, inData( is pretty useful...




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 #397 on: September 29, 2010, 04:08:42 pm »
I've seen some people wanting to use Text input routines, so here's the one I use in Axe Snake, SpiderAx, and Jump.  Press Second when done typing, del to backspace, and Clear to quit.
At the end of the routine, the string is null terminated and begins at L1.  It also Displays it again because I wanted to show how to display it and waits for you to press second again. :)

If you use this routine, you may credit me, but it is not necessary. ;D

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Routines
« Reply #398 on: September 29, 2010, 06:02:06 pm »
Is there a length limit on the input?

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 #399 on: September 29, 2010, 06:50:21 pm »
Yes.  There's a comment in the source just before the line that would need to be changed. :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #400 on: September 29, 2010, 11:40:08 pm »
Wow nice! Thanks a lot for this. :)

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Routines
« Reply #401 on: September 30, 2010, 01:40:03 am »
/\Very! thanks
since i havent seen one put out for display yet, here is a smoothscrolling tilemapper(works for left/right and up/down)
this is also partially for my own benefit because i have a lot riding on this routine and if there's anywhere it can be optimized it would be nice to know =D
Code: [Select]
:0->A->BClrDraw
:For(L,0,11:For(M,0,7
:Pt-on(L*8,M*8,{M*[MapWidth]+8+[MapData]}*8+[TileData]
:End:End
:StorePic
:Repeat getkey(15)
:If getkey(3) xor getkey(2)
::If getkey(3)
:Horizontal -
:For(L,0,8
:Pt-Off(95-(A^8),L*8-(B^8),{B/8+L*[MapWidth]+12+(A/8)+[MapData]}*8+[TileData]
:End:A+1->AElse
:Horizontal +
:For(L,0,8
:Pt-Off(1-(A^8),L*8-(B^8),{B/8+L*[MapWidth]+(A/8)+[MapData]}*8+[TileData]
:End:A-1->AEnd
:End
:If getkey(1) xor getkey(4)
:If getkey(1)
:Vertical -
:For(L,0,12
:Pt-Off(L*8-(A^8-(A^8),63-(B^8),{B/8+8*[MapWidth]+L+(A/8)+[MapData]}*8+[TileData]
:End:B+1->BElse
:Vertical+
:For(L,0,12
:Pt-Off(L*8-(A^8),1-(B^8),{B/8*[MapWidth]+L+(A/8)+[MapData]}*8+[TileData]
:End:B-1->BEnd
:End
:Dispgraph
:End
this can be easily converted to do gray as well, although you shouldn't use vertical scrolling and the axe grayscale routines together as the result will look gross. also, make sure that A and B remain greater than 0, or you'll end up with errors
« Last Edit: November 09, 2010, 10:37:50 pm by shmibs »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #402 on: September 30, 2010, 01:46:06 am »
Nice! I assume I can try this right away with no other code?

EDIT: You should maybe post a 8xp or SourceCoder-compatible code, because I do not feel like typing everything out x.x
« Last Edit: September 30, 2010, 01:46:38 am by DJ Omnimaga »

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Routines
« Reply #403 on: September 30, 2010, 09:55:11 pm »
well, you do need a tileset(8*8 monochrome) and map data(anything larger than 13*9) as well, but all the code is there, yes.
if you really want one i can post an .8xp tomorrow-ish. i have work to do right now, though.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #404 on: September 30, 2010, 10:11:06 pm »
Ah ok, I guess I could quickly do a map or something when I have some time.