Author Topic: Help for displaying Pics from AppVar  (Read 2426 times)

0 Members and 1 Guest are viewing this topic.

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Help for displaying Pics from AppVar
« on: November 14, 2014, 04:21:49 am »
Hey there,


I´m working at an Engine for Games and tried to store then tiles in an appvar ,but it didn´t work.
Here my Code:


mtrxlib:
Code: [Select]
..
...
ASMATRIX
An Lib By thababo01(C)
...
lbl ENTERMATRIX
r1*r2->A
A+2->A
GetCalc("appvASMtrx",A*3)->Z
r1->{Z}^r
r2->{1+Z}^r
Return


Lbl WRITE
{Z}^r->A
((A*(r2-1))+r1)->A
A+1->A
r3->O
O->{A+Z}^r
Return


Lbl GET
{Z}^r->A
((A*(r2-1))+r1)->A
A++
{A+Z}->A
Return


Lbl EXITMATRIX
DelVar "appvASMtrx"

[/size][size=78%]main[/size]
[/size]
Code: [Select]
.abc
clrdraw
[0000000000000000]->pic1
ENTERMATRIX(8,1)
WRITE(1,1,"FFFFFFFFFFFFFFFF")
WRITE(2,1,"00000000000000")
Repeat getkey(15)
DRAW(1)
End


Lbl Draw
ClrDraw
If r1=1
GET(1,1)
Copy(A,pic1,length(A))
pt-on(1,1,pic1)
DispGraph
Return


prgmMTRXLIB

[/size]
[/size][size=78%]well this is the test code.Synthax on the Calc is right ,but it shows just weird pixl images at 1,1.[/size]
[/size]
[/size][size=78%]Thanx for help[/size]
[/size]
[/size][size=78%]alex99(thababo01)[/size]
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Help for displaying Pics from AppVar
« Reply #1 on: November 14, 2014, 07:13:20 am »
I haven't read it thoroughly but I see an issue how with your functions you take a hex string and, I think, threat it as hex data, though it are actually string characters.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Help for displaying Pics from AppVar
« Reply #2 on: November 14, 2014, 08:27:31 am »
It's been a while since I coded Axe but I think I would write a program that can either read or write tiles to an appvar in this way:
Code: (let me dust off my rusty axe) [Select]
.piclib
Lbl InitAppv
.syntax: r1: Maximum amount of tiles you want to store. Max 255.
.output: returns pointer to appvar
!if GetCalc("appvTILES")->A  :.not a thing from the var menu bc you can't redefine these afaik
   GetCalc("appvTILES",r1*8+2)->A  :.You can store 96 sprites in this appvar. Why the extra 2 bytes? I'll show you in a bit ;)
   0->{A}   :.the amount of tiles currently stored in the appvar
   r1->{A+1} :.the maximum amount of tiles the appvar can hold
End
Return A
LBL StorTile :.I have no clue how long labels can be in the current version of Axe. If this doesn't work figure out how to call this yourself, it's only a label name :P
.syntax:
r1: pointer to 8bytes of tile data to store in the appvar.
r2: Pointer to appvar. Expects the first byte of the appvar to be the amount of sprites stored, and the second byte the maximum amount of sprites the appvar can hold.
.output: appends 8 bytes of tile data to the end of the appvar. Returns one if successful, zero if fail (appvar is full)
{r2+1}->r3  :.because I'm too lazy to type r2+1 every time

!If (r2 < r3)
   Return 0
Else
   For(I,0,7)
       {r1+I}->{{r2}*8+2+r2+I}    :.This should copy the contents of r1 to the end of r2. Might or might not work, please prod me if it doesn't.
   End
   {r2}++ :.adds one to the tile count
End
Return 1

Lbl GetTile
.syntax:
.r1: pointer to appvar. Expects the same format as mentioned before.
.r2: tile # to fetch
.Outputs:  Returns the pointer to the desired tile. The first tile in the appvar is number zero, not one.
.This function is almost a joke. It instantly returns :P
Return ((8*{r1})+(8*r2)+r1+2)
This is a very general library and I would actually advise to strip non-needed parts but I'll leave that as an exercise for the reader. Also note that the appvar doesn't get initialized if it already exists. You might want to make sure the size of the appvar is correct.
An example use of this in action is this:
Code: [Select]
.RANDGFX
.fills an appvar with bullshit tiles and displays a random one from the appvar in the middle of the screen
.where do you include programs again? at the start or at the end of the program? edit turns out that if you include at the start it gets run before start.
InitAppv(12)->P
For(12)
   For(r1,0,7)
      rand^255->{L1+r1}
   End
   StorTile(L1, P)
End
Repeat getKey(15)
   Pt-On(44,28,GetTile(P, rand^11))
   DispGraphClrDraw
End
DispgraphClrDraw
Pause 100
Return
prgmPICLIB

Just tested and debugged the above code. I'm licensing it into public domain. Do whatever you want with it.

edit: fixing bugssss -.-
« Last Edit: November 14, 2014, 09:09:12 am by aeTIos »
I'm not a nerd but I pretend: