Author Topic: Total noob question  (Read 19534 times)

0 Members and 2 Guests are viewing this topic.

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #15 on: July 15, 2010, 08:56:39 am »
My second noob question is this: how do I use pointers to make animated sprites? Say I have this sprite [FFFFFFFFFFFFFFFF] and this one [3C7EFFFFFFFF7E3C] and both are stored into Pic0 thus making: [FFFFFFFFFFFFFFFF3C7EFFFFFFFF7E3C]. Now everytime I hit the <right> or <left>  key I want to alter between them, thus creating the illusion of animation. I am pretty usre this can be done through pointers but I seem unable to figure it out. I do not request a entire example (albeit that would be useful) but some guidance would be very much appreciated!

And thanks so far already for the great and fast help.
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Total noob question
« Reply #16 on: July 15, 2010, 09:05:37 am »
try this:
Code: (Axe) [Select]
.SPRITE                   . header
DiagnosticOff             . turn off indicator/done
10->X->Y                  . initialize sprite position
[FFFFFFFFFFFFFFFF]→Pic0   . squares are for squares. therefore, a black circle is stored to pic0.
[3C7EFFFFFFFF7E3C]       .add more data after the spritedata
Repeat getKey(15)         . repeat until clear is pressed
X+getkey(3)-getkey(2)->X  . movement
Y+getkey(1)-getkey(4)->Y  . code
Pt-Change(X,Y,8*getKey(2)+Pic0        . draw sprite to buffer
DispGraph                 . display what's on the buffer
Pt-Change(X,Y,8*getKey(2)+Pic0        . draw same sprite to buffer. since it's pt-change, the sprite is erased on the buffer, leaving no
End                       . residue from movement.
ClrHome                   . clear the screen, move cursor to upper left corner of the screen.
ClrDraw                   . clear the buffer.
the '8*getKey(2)' points to 8 bytes further than Pic0 when key 2 is pressed (getKey is 1) and has no effect when any other key is pressed...
« Last Edit: July 15, 2010, 09:06:02 am by LordConiupiter »
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 matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #17 on: July 15, 2010, 12:08:00 pm »
ok thanks. I actually figured that doing walkcycle can not be done through pointers, it needs indexing so I will give that a try...
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #18 on: July 16, 2010, 12:44:51 pm »
question no3!
Code: [Select]
.ATST
11->N
0->O
DiagnosticOff
ClrDraw
[0000000000000000]->Pic00
[FFFF03030303FFFF]
[FFFFC0C0C0C0FFFF]
[386CD6AAFED6D67C]
[FFFFE7C3C3E7FFFF]
[FFE7C38181C3E7FF]
Data(1,4,4,4,4,4,4,4,2,1,1,1,1,1,4,4,4,4,2,4,1,2,4,4,3,3,1,2)->GDB1 .this is just random and the fact that it is, is irrelevant
repeat getKey(15)
N+(getkey(3))->N
O+(getkey(3))->O
N-(getkey(2))->N
O-(getkey(2))->O
ClrDraw
For(A,O,N)
pt-on((A*8),56,((({GDB1}+A)*8)+Pic00))
DispGraph
End

Now this doesn't work. I get strange and random sprites whenever I move too far to the left or right. It is supposed to do this:

Iterate 12 times through GDB1.
If the element is 1 then draw the 8x8 sprite 8 bytes after pic00
If the element is 2 then draw the 8x8 sprite 16 bytes after pic00
If the element is 3 then draw the 8x8 sprite 24 bytes after pic00
etc.
If the right key is pressed then look up the values in GDB1 corresponding to the new X coordinate (e.g. when you start the program it shows the sprites that are reffered to by the data in GDB1 from 0 to 11, if you go right once then you have to look at 1-12, one more time to the right is 2-13 etc until the end of the list. So actually you move trough the list and the display is updated accordingly)
If the left key is pressed do the inverse of the right key si pressed action
If the clear key is pressed stop else go to the beggining.

Now this is not what it does. on a side note I don't think I need pic00 and I yet have to include the feature that stops you from "stepping" outside the list (GDB1) by pressing left or right too often but I can't seem to get the "Length()" command to work...

O yes, this is for my Axe contest entry so I am not sure to what extend you may help me..(but if I don't get help there won't be a entry :P)

Tyvm
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Total noob question
« Reply #19 on: July 16, 2010, 12:54:42 pm »
It seems like it'd be legal. To use Length, you'll have to add a meaningless 0 to the end of GDB1. (Length searches for a zero) You'd also have to make sure none of the other bytes in GDB1 are 0.
Since I don't feel like comprehending your code, I'll just tell you that the lines with getkey's on them can be N+getkey(3)-getkey(2)->N and O+getkey(3)-getkey(2)->O. Actually, because the keys might be released just in time to be different (I've had this problem) you should use the lines
Code: [Select]
N+(getkey(3)-getkey(2)->T)->N
O+T->O
Provided you don't need T elsewhere, of course.
I might try to resolve your main problem later.
Good luck with your entry!
Edit: For clarification, that code stores the result of the keypresses in T, then reuses the value. (Embedded store statements are allowed, and can often be more optimized)
« Last Edit: July 16, 2010, 12:56:19 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

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: Total noob question
« Reply #20 on: July 16, 2010, 12:58:12 pm »
Instead of {GDB1}+A you want {GDB1+A}.  Also, you're using way too many parenthesis, they actually do add to the code size usually.  The getkey's don't need the extra pair, A*8 doesn't, and the thing after it has a lot.  Axe reads strictly left to right for its order of operations so most of those parenthesis are unnecessary.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #21 on: July 16, 2010, 04:56:21 pm »
problem is still unsolved. thanks for the optimizations though. Let me try to explain it again. I have a list (GDB1) which contains numbers. Each number represents a tile. Now the first value in GDB1 is the first tile the second value the second tile etc. The thirteenth tile is not drawn because only twelve fit on the screen. The thirteenth tile is drawn when you press the <right> key, however the first tile is NOT drawn then (because all the tiles shifted left once. So basically the list contains the tiles and now I want to be able to scroll through the tiles by pressing left or right. By pressing right the tiles shift to the left once and by pressing left the tiles shift right once. This is what I am trying to accomplish and so far has failed epically :(.
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Total noob question
« Reply #22 on: July 16, 2010, 05:09:33 pm »
Instead of {GDB1}+A you want {GDB1+A}.  Also, you're using way too many parenthesis, they actually do add to the code size usually.  The getkey's don't need the extra pair, A*8 doesn't, and the thing after it has a lot.  Axe reads strictly left to right for its order of operations so most of those parenthesis are unnecessary.
What Quigibo means by 'Strict Order of Operations' is that when doing a series of operations, instead of worrying about the 'normal' order like you were taught in school (PEMDAS) Axe will read the equation starting from the left and doing each operator as it reads it, which is very helpful to remove all the parentheses that otherwise plague large equations.
Example:
Code: (PEMDAS) [Select]
7+8*3-9*2=13
Code: (Axe) [Select]
7+8*3-9*2=72
Keep in mind though that Axe still supports parentheses and will calculate those before anything else, so if you are a little confused about the strict order of operations, you can still use:
Code: (Axe) [Select]
7+(8*3)-(9*2)=13
Although, that kinda ruins the point of using strict order of operations to optimize code.  :P

EDIT:Hold on, let me see what's going on in your program and I'll get back to you.

EDIT2:Okay, can you post your source code, because I seem to be getting something completely different than what you described.  ???
« Last Edit: July 16, 2010, 05:37:44 pm by Magic Banana »
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #23 on: July 16, 2010, 05:49:29 pm »
OK this are getting slightly out of hand here, this:
problem is still unsolved. thanks for the optimizations though. Let me try to explain it again. I have a list (GDB1) which contains numbers. Each number represents a tile. Now the first value in GDB1 is the first tile the second value the second tile etc. The thirteenth tile is not drawn because only twelve fit on the screen. The thirteenth tile is drawn when you press the <right> key, however the first tile is NOT drawn then (because all the tiles shifted left once. So basically the list contains the tiles and now I want to be able to scroll through the tiles by pressing left or right. By pressing right the tiles shift to the left once and by pressing left the tiles shift right once. This is what I am trying to accomplish and so far has failed epically :(.
is what it is SUPPOSED to do/what I want it to do.
and this is my source (which doesn't do what i want it to do):
Quote
Code: [Select]
.ATST
11->N
0->O
DiagnosticOff
ClrDraw
[0000000000000000]->Pic00
[FFFF03030303FFFF]
[FFFFC0C0C0C0FFFF]
[386CD6AAFED6D67C]
[FFFFE7C3C3E7FFFF]
[FFE7C38181C3E7FF]
Data(1,4,4,4,4,4,4,4,2,1,1,1,1,1,4,4,4,4,2,4,1,2,4,4,3,3,1,2)->GDB1 .[s]this is just random and the fact that it is, is irrelevant[/s] [i]not entirely random each number is a sprite but it is random in the sense that i choose the numbers randomly (within a range from 1-5)[/i]
repeat getKey(15)
N+getkey(3)-getKey(2)->N
O+getkey(3)-getKey(2)->O
ClrDraw
For(A,O,N)
pt-on(A*8,56,({GDB1+A}*8)+Pic00)
DispGraph
End

What I get is this. There is one sprite showing in the bottom right corner bu as soon as I press either left or right it fills up. Clearly all kinds of other sprites are drawn over it (this can be better seen if you make pt-on() into pt-change()). Now that is NOT what I want it to do but I can't find my problem, this is what I need help for.
« Last Edit: July 16, 2010, 05:50:53 pm by matthias1992 »
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline Magic Banana

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 371
  • Rating: +77/-1
  • It's not an apple, it's a ... magic banana.
    • View Profile
Re: Total noob question
« Reply #24 on: July 16, 2010, 06:11:41 pm »
Hmm, Well when I run it, I get a line of sprites that blink at the bottom. when pressing left, they seem to be shifting to the left, but once the right end of this line of sprites hits the end, then the random garbage comes up and I have to pull the battery.

First off, can you change the variable 'O' to something different? It's very hard to distinguish it from zero in the code. Also, why is there no 'End' to end the Repeat getkey(15)? with the code you posted, it won't even compile. Also, what exactly are you trying to get done with this code? Perhaps there is another way of going about doing it.
I do sprites and stuff, so yeah.

Quote from: yunhua98
i'M NOT SURE WHAT A SWORD SKILL IS BUT HERE'S THE SWORD ANIMATION FROM THE TWO SPRITES ON PG 13

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Total noob question
« Reply #25 on: July 16, 2010, 06:53:00 pm »
Code: [Select]
.ATST
0->C       . Since we're always displaying 12 sprites on the screen, you only need one var to keep track of position in the data.
DiagnosticOff
ClrDraw
Zeroes(8)->Pic1     . just a different way of writing it.
[FFFF03030303FFFF]
[FFFFC0C0C0C0FFFF]
[386CD6AAFED6D67C]
[FFFFE7C3C3E7FFFF]
[FFE7C38181C3E7FF]
Data(1,4,4,4,4,4,4,4,2,1,1,1,1,1,4,4,4,4,2,4,1,2,4,4,3,3,1,2)->GDB1  . unchanged data.
Repeat getKey(15)
C!=16 and getKey(3) - (C!=0 and getKey(2))+C->C  . "!=" is does not equal. they're used to be boundaries, so we don't scroll into undefined data.
Pause 150       . pauses for 150 milliseconds to slow the program down.
ClrDraw
For(A,C,C+12
pt-On(A-C*8,56,{GDB1+A}*8+Pic00     . A-C instead of A so we always start displaying the sprites at (0,56).
End
DispGraph
End

i think this gives the desired effect. i got the 16 as a boundary from the number of pieces of data in GDB1 (there are 28). since in the for loop i have the ending value 12 higher than C, the maximum boundary before we start scrolling into random data is the amount of data (28) minus how far in front of our counter variable (C) we're going to use. (12). therefore the boundary of C is 16. you can adjust the pause to make the program scroll faster/slower. one last thing to explain, {GDB1+A}*8+Pic00. {GDB1} returns 1, because it's the first number in the sequence in Data(). it's also defined as the number starting at the static pointer GDB1. {GDB1+A} returns whatever number is A spaces after the beginning of Data() so if A is 3, {GDB1+A} returns a 4. We multiply by 8 because each sprite takes up 8 bytes of space. Since {GDB1+A} returns the byte at the pointer (think that it returns the number A spaces in front of the 1 in Data() if you're confused on pointers), we multiply by 8 to skip through the sprites. I think you already understand this, matthias, i'm just checking anyway.
« Last Edit: July 16, 2010, 06:58:48 pm by nemo »


Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #26 on: July 16, 2010, 07:07:55 pm »
Thanks i'll try that...well i get some sleep whether it works or not but it surely looks good! I ahve new hopes :P
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Total noob question
« Reply #27 on: July 16, 2010, 07:09:59 pm »
no problem. what exactly are you trying to make?


Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #28 on: July 17, 2010, 07:43:06 am »
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Re: Total noob question
« Reply #29 on: July 26, 2010, 02:09:16 pm »
Here is my latest noob question. I succeeded once in writing to appvars but I lost the program somehow, I have no notes of it either and the Axe documentation doesn't give a appvar specific writing example.

I tried this:
Code: [Select]
"vPBWMAP1"->Str0
Getcalc(Str0,16)->P
If P
[FFFF03030303FFFF]->{P}
End

I also tried
Code: [Select]
For(A,0,15)
1->{P+A}
End

Neither of which works. Any suggestions?
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-