Author Topic: Routines  (Read 313270 times)

0 Members and 4 Guests are viewing this topic.

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: Routines
« Reply #345 on: June 28, 2010, 04:12:57 am »
Incredible.
The fractal is completely recognizable.
Hobbing in calculator projects.

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 #346 on: July 01, 2010, 10:33:55 pm »
Automated Sound Loader/Player:

Code: [Select]
:.Setup Code
:DiagnosticOff
:0→L
:fnInt(I,6)


:.QuitCode
:LnReg
:Return


:.To Play Music that is pointed to
:Ptr→L


:.To Stop All Music
:0→L


:.To see if any music is currently playing
:If L


:.Music Loader/Player
:Lbl I
:!If L
:1→C
:Return
:End
:ReturnIf C-1→C
:If {L+1}
:Freq({L},2000)
:{L+2→L-1}→C
:Else
:0→L
:End
:Return


:.Music Data should be in this form
:Data(note1,time1,note2,time2,...,lastenote,0)→GDB1


Typical note times in this case are maybe 10 or 20, these aren't the same times as the pause command or anything.  The routines uses L for the loader and C for the counter, you can change these letters to anything you desire.  This can be used for sound effects too, especially with low frequencies (high wave values) and short wait times.
« Last Edit: July 01, 2010, 10:35:46 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

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 #347 on: July 01, 2010, 10:43:03 pm »
Ooh, thanks. Didn't really understand music in Axe until now.




Offline Michael.3545

  • LV3 Member (Next: 100)
  • ***
  • Posts: 69
  • Rating: +13/-7
    • View Profile
Re: Routines
« Reply #348 on: July 01, 2010, 11:43:16 pm »
DJ, I can answer the question about the BASIC Mandelbrot set.  I made this program a while ago.  It is cool, because it can estimate (very accurately  :D) how long it will take.  25 iterations takes about 22 minutes to graph.  Big speed difference.


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 #349 on: July 02, 2010, 02:39:06 am »
@Quigibo nice! It should make it easier to make sound programs that uses interrupts.

@Michael I see. Huge speed difference indeed in BASIC XD

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 #350 on: July 13, 2010, 06:36:19 pm »
Quote
StoreGDB
StorePic
For(Z,0,63)
Copy(Z*12+L3,L6+756-(Z*12),12)
End
DispGraph

This inverts the screen content, like they wanted to do in this topic: http://ourl.ca/6348 . However, it poses no compatibility issues between each calc hardwares. Screenshot below (added Repeat getkey(15):End inside the code).

Offline TC01

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 344
  • Rating: +9/-0
    • View Profile
Re: Routines
« Reply #351 on: July 13, 2010, 07:23:23 pm »
Quote
StoreGDB
StorePic
For(Z,0,63)
Copy(Z*12+L3,L6+756-(Z*12),12)
End
DispGraph

This inverts the screen content, like they wanted to do in this topic: http://ourl.ca/6348 . However, it poses no compatibility issues between each calc hardwares. Screenshot below (added Repeat getkey(15):End inside the code).

When I try compiling just that in WabbitEmu (due to my calc's link port being broken), I get an Err:Out of Mem at 53%, pointing to that last DispGraph command.

What's strange about this is that the only thing I have on WabbitEmu is Axe and prgmLCDFLIP (what I called it).
« Last Edit: July 13, 2010, 08:49:29 pm by TC01 »



The userbars in my sig are links embedded links.

And in addition to calculator (and Python!) stuff, I mod Civilization 4 (frequently with Python).

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 #352 on: July 13, 2010, 07:27:22 pm »
o.O? Really?

Are you sure you are typing the program right?

Btw if by suspicious you mean that I am trying to crash people calcs, I do not understand why you think I would do this, considering I have been doing calc stuff for 9 years, got 7 programs featured on ticalc.org and am not the person to make junk programs.

If it still fails after double-checking, could you add the following after the DispGraph?

Repeat Getkey(15)
End

EDIT: Btw don't use SourceCoder to copy this. I did not copy the code with it, but by hand
« Last Edit: July 13, 2010, 07:29:02 pm by DJ Omnimaga »

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 #353 on: July 13, 2010, 08:47:51 pm »
Its a bug that doesn't allow you to have the last line of code be a command which can possibly use the r modifier, you have to add an extra [Enter] at the end.  I've already fixed it, but it won't be updated until 0.4.0

Nice job DJ!  I think I can optimize it a little though:
Code: [Select]
StoreGDB
For(Z,0,31)
Exch(Z*12+L6,L6+756-(Z*12),12)
End
DispGraph

That way it doesn't need the back buffer.
___Axe_Parser___
Today the calculator, tomorrow the world!

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 #354 on: July 13, 2010, 08:51:48 pm »
Strange, it worked fine for me. I noticed the compile screen shifted down 8 pixels (see screenshot above), tho

I guess that could explain why it didn't work x.x

And thanks for the optimization, I didn't thought about that one.

Offline TC01

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 344
  • Rating: +9/-0
    • View Profile
Re: Routines
« Reply #355 on: July 13, 2010, 08:53:28 pm »
o.O? Really?

Are you sure you are typing the program right?

Btw if by suspicious you mean that I am trying to crash people calcs, I do not understand why you think I would do this, considering I have been doing calc stuff for 9 years, got 7 programs featured on ticalc.org and am not the person to make junk programs.

If it still fails after double-checking, could you add the following after the DispGraph?

Repeat Getkey(15)
End

EDIT: Btw don't use SourceCoder to copy this. I did not copy the code with it, but by hand

Poorly-chosen word- I meant "why I think it's probably related to Axe and not the program/WabbitEmu's memory". Changed it to "strange". I didn't mean to imply anything, sorry.

It compiles if I add the extra Enter at the end, thanks Quigibo.



The userbars in my sig are links embedded links.

And in addition to calculator (and Python!) stuff, I mod Civilization 4 (frequently with Python).

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 #356 on: July 13, 2010, 08:55:08 pm »
Aaah ok  x.x

As for the bug, it's funny because it reminds me so much the first time I tried learning ASM and compiling Hello World. Silly No End Directive Before EOF errors due to that TASM bug x.x

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #357 on: July 17, 2010, 10:12:07 pm »
let's rotate some sprites, shall we?

Code: [Select]
[AAAAAAAAAAAAAAFF->Pic1    .your sprite!
Pt-On(0,0,Pic1
For(Y,0,7
For(X,0,7
If pxl-Test(X,Y
Pxl-On(Y+9,7-X
End:End:End
DispGraph
currently trying to figure out how to not use any graphics commands and rotate the sprite's data... i'm having very minimal luck with this, though.



and some cool trickery with flipping:
Code: [Select]
[0102040810204080->Pic1 . your sprite data.
Pt-On(0,0,Pic1
For(A,0,3
Exch(Pic1+A,Pic1+8-A,1
End
Pt-On(9,0,Pic1
DispGraph

EDIT:
this is a triumph, i'm making a note here: huge success.

i can rotate sprites 90 degrees... by just rotating their data (: of course my routine requires 8 bytes of memory to store the rotated sprite. Observe  ;)
Code: [Select]
.YYYEAHHH
[4875038562839462->Pic1 . This data doesn't matter, cause this routine will rotate any sprite (:
ClrDraw
For(A,0,7
{Pic1+A}->T
For(B,0,1
If B
T^16->D
Else
T/16->D
End
If D>7
e^(A)->C+{4*B->E+L1}->{E+L1}
End
If D>3 and (D<8) or (D>11)
C+{E+L1+1}->{E+L1+1}
End
If D!=1 and (D!=4) and (D!=5) and (D!=8) and (D!=9) and (D!=12) and (D!=13) and (D!=0)
C+{E+L1+2}->{E+L1+2}
End
If D^2
C+{E+L1+3}->{E+L1+3}
End
End
End

memory efficient? No. it's 750 bytes or so, i believe. i'm sure there is a vast field of optimizations to make. for instance, that long conditional that draws the 3rd and 7th row of the translated sprite. and since you save to a byte L1+(num), you can probably substitute that for A with some tricky logic... i'm lazy to optimize this right now, though.

edit: optimized a bit. it's now 520 ish bytes.
« Last Edit: July 19, 2010, 10:10:01 pm by nemo »


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 #358 on: July 18, 2010, 12:28:53 am »
Still nice, though.

Runer112 also had a routine to rotate/flip sprites in his sprite editor, but for some reasons, he hasn't been posting on the forums in almost 2 weeks :(

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #359 on: July 19, 2010, 09:49:41 pm »
RLE map decompression where the first half-byte is frequency and the second half-byte is the tile number 1-F. this is a quick example:
Code: (Map Data) [Select]
.Uncompressed (24 bytes. each pair is a byte.)
[010101010101
[010303000001
[010200000201
[010101010101
.Compressed (8 bytes. each pair is a byte.)
[7123202112201271->GDB1
Code: (Decompression Routine) [Select]
Zeroes(8)
[FFFFFFFFFFFFFFFF->Pic1    .Your tiles
[0102030405060708
[0123456789ABCDEF
0->X->Y
For(A,0,7                  .7 is the number of bytes your compressed map is, minus one.
For(W,1,{GDB1+A}->Z/16     .GDB1 is where the map is housed
Pt-On(8*X,8*Y,Z^16-1*8+Pic1
Z^16->{6*Y+X+L1}           .L1 will house the uncompressed map. 6 is used as the width of the map.
!If X+1->X^6               . again, 6 is the width of the uncompressed map.
0->X:Y+1->Y
End
End
End

i'll post RLE compression once i get it working, but it's a routine i doubt anyone would need in axe.