Join us on Discord!
You can help CodeWalrus stay online by donating here.

Some super crappy Axe code...

Started by p2, August 24, 2016, 11:41:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

p2

This block:
If getKey(1) and (W<5600):W+100->W:End
.LeftArrowKey
If getKey(2) and (V>0):V-100->V:End
.RightArrowKey
If getKey(3) and (V<8600):V+100->V:End
.UpArrowKey
If getKey(4) and (W>0):W-100->W:End



Can be:
If W<5600 and getKey(1):W+100->W:End
If V>0 and getKey(2):V-100->V:End
If V<8600 and getKey(3):V+100->V:End
If  W>0 and getKey(4):W-100->W:End

Would this already speed it up, or did you just remove my stupid comments? ^^


which can further be optimized to:
W<5600 and andgetKey(1)-(W>0 and getKey(4))*100+W->W
V<8600 and getKey(3)-(V>0 and getKey(2))*100+V->V

I'm not sure, but if I pressed only the UP arrow key, then this first line should become the following:
0-(1)*100+W->W which would be the same as 65535*100+W->W which would result in ((2^16-1)*100)-99*(2^16) (no Axe) which is 65436 which iiiis 2^16-100 which equals (0-100) in Axe so it' the same as (0-100)+W->W which means this code is awesome ^.^ And I even under stood it *-*


could be even further optimized to:
W<5600?getKey(1)-(W?getkey(4))*100+W->W
V<8600?getKey(3)-(V?getKey(2))*100+V->V

Okey now I definitely need an explanation? ;D



Quote from: E37 on August 24, 2016, 05:43:08 PMAs for learning to program Axe I still find it helpful to program with a paper or electronic copy of the Axe command list nearby. http://axe.eeems.ca/Commands.html
Oh... by the way, your code isn't bad at all! It is heaps better than my first code! It took me weeks to grasp the concepts of how lists are structured.
I only learned this List stuff so fast because Sorunome took the time to explain it to me... twice ;D
I also asked others in the IRC, too, but didnt get it 100% back then (Thanks to all of them!) ^^

Also I got my Axe command list right next to me ;) But it's a pain to search stuff since it's such a long list xD


Sory for not replying to the last three posts yet, you're too fast for me xD
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

p2

Quote from: Hayleia on August 24, 2016, 06:08:02 PM
They are exactly the same. A new line or a ":" is the same thing.
You can even write something after the return if you want (and it can be useful in some cases). Like

...
...
Lbl Stuffs
r1*r2->r5
r3*r4->r6
Return r5+r6
...
...

Well yeah, not so useful here, but you see what I mean.
Quote from: E37 on August 24, 2016, 06:10:32 PM
You got it!
Subroutines don't need to return anything.
They can just hold code. They will always return the result of the last line of code. Nobody said you had to do anything with it.
You nailed memory locations on the head.
Thanks c4ooo, my mind seemed to edit in an if at the beginning.
You don't need the greater than zero c4ooo it is unsigned.


So this should return 5 and save it as X:
...
...
DoStuff( )->X
...
...
Return

Lbl DoStuff
6->C
5->A->B:Return




And this should return 5, too, but ignore it:
...
...
DoStuff( )
...
...
Return

Lbl DoStuff
6->C
5->A->B
Return




And this one will return 6 instead of 5 and ignore it, too:
...
...
DoStuff( )
...
...
Return

Lbl DoStuff
6->C
5->A->B
Return C




And it's impossible to get an error from the DoStuff()->X except in this example, in which it wouldn't try to save "Stupid" as X since it's waiting for a returned value from DoStuff() ;D
...
...
"Stupid"->Str01
DoStuff( )->X
...
...
Return

Lbl DoStuff
Return



You guys really are awesome teachers!! ;D  :thumbsup:


Sorry for the douplepost... It's just that I was too slow ^^
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

E37

You can replace and with * and or with +
It never waist for a value, it just uses whatever is in hl when it returns. Hl is Axes answer.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

p2

Quote from: E37 on August 24, 2016, 06:41:22 PM
You can replace and with * and or with +
It never waist for a value, it just uses whatever is in hl when it returns. Hl is Axes answer.
What do you men by HL? ^^ I never heard of it... ^^
Abd does replacing AND with * and replacing OR with + speed up the code? Or is it just to shorten it? :)

By the way... could anyone tell me if I understood it corectly now (my last 2 posts) :)
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Hayleia

Quote from: p2 on August 25, 2016, 09:24:12 AM
What do you men by HL? ^^ I never heard of it... ^^
Abd does replacing AND with * and replacing OR with + speed up the code? Or is it just to shorten it? :)
HL is the z80's main 16-bit register. That's why Axe uses it for "everything".
When you write "3", it loads 3 in HL. When you write "+5", it adds 5 to HL. When you write "->A", it stores HL in the location that corresponds to A.
So "3+5->A" does what you expect, and

3
+5
->A

does the same thing but wastes two lines.

And about * and +, this doesn't make the code faster nor smaller. And it doesn't give the same result either actually :P
* and + work on 16 bits, "and" and "or" work on 8 only for example.

Quote from: p2 on August 24, 2016, 06:38:47 PM
So this should return 5 and save it as X:
And this should return 5, too, but ignore it:
And this one will return 6 instead of 5 and ignore it, too:
Yes for all of these ones. Except that "5->A->B:Return" is ugly, I only wrote that in my posts because I didn't want to open a code tag and write two lines :P
And

6->C
5->A->B
Return C

is unoptimized (well I know it's just an example but still, if that helps you do basic optimizations, that's good to know). You can just write that instead

5->A->B
6->C
Return

You saved 3 bytes just by inverting two lines. That's not really one of these unreadable optimizations :P

Quote from: p2 on August 24, 2016, 06:38:47 PM
And it's impossible to get an error from the DoStuff()->X except in this example, in which it wouldn't try to save "Stupid" as X since it's waiting for a returned value from DoStuff() ;D
Depends what you call an "error". Axe won't give you an error, it will always "return" the last value it "returned" in HL. Then maybe your program will do stupid stuff since it will receive a value it didn't expect, but technically you don't do "DoStuff()->X" if you don't know exactly what DoStuff returns and want it in X :P

p2

Quote from: Hayleia on August 25, 2016, 10:26:03 AM
Quote from: p2 on August 25, 2016, 09:24:12 AM
What do you men by HL? ^^ I never heard of it... ^^
Abd does replacing AND with * and replacing OR with + speed up the code? Or is it just to shorten it? :)
HL is the z80's main 16-bit register. That's why Axe uses it for "everything".
When you write "3", it loads 3 in HL. When you write "+5", it adds 5 to HL. When you write "->A", it stores HL in the location that corresponds to A.
So "3+5->A" does what you expect, and

3
+5
->A

does the same thing but wastes two lines.
So HL is like what you call the Register in ASM? ^^ okey thx ^^ So This should do 5->A : A->B : B+1->C : C->D right? :)
:Whatever()->D
:Return
:Lbl Whatever
:5->A->B:+1->C:Return



Quote from: Hayleia on August 25, 2016, 10:26:03 AM
Quote from: p2 on August 24, 2016, 06:38:47 PM
And it's impossible to get an error from the DoStuff()->X except in this example, in which it wouldn't try to save "Stupid" as X since it's waiting for a returned value from DoStuff() ;D
Depends what you call an "error". Axe won't give you an error, it will always "return" the last value it "returned" in HL. Then maybe your program will do stupid stuff since it will receive a value it didn't expect, but technically you don't do "DoStuff()->X" if you don't know exactly what DoStuff returns and want it in X :P
Okeyy But then what would it do in my example code:
Quote from: p2 on August 24, 2016, 06:38:47 PM
...
...
"Stupid"->Str01
DoStuff( )->X
...
...
Return

Lbl DoStuff
Return
would it actually try to save "Stupid" as X since nothing else was saved as HL ???


And by the way... would it even be slower to write it like this...? Or would it result in the same but look stupid? ^^
Quote from: Hayleia on August 25, 2016, 10:26:03 AM
3
+5
->A

does the same thing but wastes two lines.
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Hayleia

Quote from: p2 on August 25, 2016, 11:19:23 AM
So HL is like what you call the Register in ASM? ^^ okey thx ^^ So This should do 5->A : A->B : B+1->C : C->D right? :)
:Whatever()->D
:Return
:Lbl Whatever
:5->A->B:+1->C:Return

Yes, it's the same. With a useless call and without useless loads but the result from the point of view of your variables is the same.
But avoid putting the Return at the end of the line like this, it doesn't make more sense and is less readable since you can't visually align the Lbl with the Return.

Quote from: p2 on August 25, 2016, 11:19:23 AM
Okeyy But then what would it do in my example code:
Quote from: p2 on August 24, 2016, 06:38:47 PM

<snip>
would it actually try to save "Stupid" as X since nothing else was saved as HL ???
I don't remember if "Stupid"->Str01only declares the string and registers the pointer name or if it loads the pointer in HL too. So let's replace the Str01 in your code with A for example, to be sure it's loaded in HL (and in A).
In that case yes, it will also be loaded in X since that's still what's in HL after calling DoStuff (which didn't do stuff).

Quote from: p2 on August 25, 2016, 11:19:23 AM
And by the way... would it even be slower to write it like this...? Or would it result in the same but look stupid? ^^
Quote from: Hayleia on August 25, 2016, 10:26:03 AM
3
+5
->A

does the same thing but wastes two lines.
No, not slower or anything. Maybe slower to compile due to skipping more newlines, but you won't make the difference, and no one cares about compilation time anyway if execution is fast and readability saves more time.

p2

I modified the entire code as far as I understand it by now :)
I'm sure it's still far from being perfect, so please tell me if you notice anything that still can be modified :) Thank you!  :thumbsup:
.TRY07AXE
ClrDraw
[3C7EFFFFFFFF7E3C]->Pic01
[FF818181818181FF]->Pic02
L1->°BposX
L1+2->°BposY
1280->BposX->BposY
L1+4->°BmovX
L1+6->°BmovY
128->BmovY:*2->BmovX
L1+8->°BdirX
L1+10->°BdirY
1->BdirX->BdirY

.Pos Player *128 = V,W
6400->V
1280->W
.Gravitation=G
.N=NotCollide to prevent double collision
.C=Counter
0->G->N->C
while 1
C++
Pt-On(BposX/128,BposY/128,Pic01)
Pt-On(V/128,W/128,Pic02)
DispGraph:ClrDraw
BmovX*BdirX+BposX->BposX
BmovY*BdirY+BposY->BposY
Movement()
Collision()
Gravity()
EndIf getKey(15)
Return

Lbl Movement
.moveX
V<11008 and getKey(3)-(V>0 and getKey(2))*128+V->V
.moveY
W<7168 and getKey(1)-(W>0 and getKey(4))*128+W->W
Return


Lbl Collision
N>0?N--->N
.COLLIDE
.Top Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:(0-1)->BdirX->BdirY:5->N:0->G:End
.Top Right
If (N=0) and ((BposX/128)>=((V/128)+7)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:1->BdirX:(0-1)->BdirY:5->N:0->G:End
.Bottom Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:(0-1)->BdirX:1->BdirY:5->N:End
.Bottom Right
If (N=0) and ((BposX/128)>=((V/128)+6)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:1->BdirX->BdirY:5->N:End
.Top
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((V/128)-8)) and ((BposY/128)<=((V/128)-6))
BmovY+128->BmovY:(0-1)->BdirY:5->N:0->G:End
.Left
If (N=0) and ((BposX/128)>=((V/128)-8)) and ((BposX/128)<=((V/128)-7)) and ((BposY/128)>=((V/128)-5)) and ((BposY/128)<=((V/128)+5))
BmovX+102->BmovX:5->N:If (BposY>5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Right
If (N=0) and ((BposX/128)>=((V/128)+7)) and ((BposX/128)<=((V/128)+8)) and ((BposY/128)>=((V/128)-5)) and ((BposY/128)<=((V/128)+5))
BmovX+102->BmovX:5->N:If (BposY>5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Bottom
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((V/128)+7)) and ((BposY/128)<=((V/128)+8))
1->BdirY:G/5+BmovY/2+64->BmovY:0->G:End

.BORDERS
.Left
If (BposX<128) or (BposX>(0-1280)):128->BposX:1->BdirX:End
.Right
If (BposX>11008):11008->BposX:(0-1)->BdirX:End
.Top
If (BposY)<128):128->BposY:1->BdirY:(BmovY/2)->BmovY:End
.Bottom
If (BposY)>7168):7168->BposY:(G/10+BmovY)->BmovY:0->G:-1->BDirY:End
Return

Lbl Gravity
.Friction
If BmovX>50:BmovX*127/128->BmovX:Else:If BmovX<20:If (C/4+4)=C:BmovX*127/128->BmovX:End:Else:If (C/2+2)=C:BmovX*127/128->BmovX:End:End:End
.Slow down and speed up
If BdirY=1:102:Else:97:End:*BmovY/128->BmovY
.Add Gravity
G+3->G:/10+BposY->BposY
Return
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

c4ooo

Dont want to optimize the whole thing for you, but heres another tip:
(BposX<128) or (BposX>(0-1280)) can be optimized by simply switching some stuff around and removing unnecessary brackets.
BposX>-1280 or (BposX<128)

p2

Thx ^^ Gonna change that, too ;D

Finally got a GIF of my code. This is the unmodified old code:
Still buggy, I know... ^^
*pls remember its not ment to be perfect physics but perfect for a 1:1 soccer game I wanted to create for myself just for learning purposes ^^

  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Hayleia

Quote from: p2 on August 25, 2016, 08:51:30 PM
I modified the entire code as far as I understand it by now :)
I'm sure it's still far from being perfect, so please tell me if you notice anything that still can be modified :) Thank you!  :thumbsup:
.TRY07AXE
ClrDraw
[3C7EFFFFFFFF7E3C]->Pic01
[FF818181818181FF]->Pic02
L1->°BposX
L1+2->°BposY
1280->BposX->BposY
L1+4->°BmovX
L1+6->°BmovY
128->BmovY:*2->BmovX
L1+8->°BdirX
L1+10->°BdirY
1->BdirX->BdirY

.Pos Player *128 = V,W
6400->V
1280->W
.Gravitation=G
.N=NotCollide to prevent double collision
.C=Counter
0->G->N->C
while 1
C++
Pt-On(BposX/128,BposY/128,Pic01)
Pt-On(V/128,W/128,Pic02)
DispGraph:ClrDraw
BmovX*BdirX+BposX->BposX
BmovY*BdirY+BposY->BposY
Movement()
Collision()
Gravity()
EndIf getKey(15)
Return

Lbl Movement
.moveX
V<11008 and getKey(3)-(V>0 and getKey(2))*128+V->V
.moveY
W<7168 and getKey(1)-(W>0 and getKey(4))*128+W->W
Return


Lbl Collision
N>0?N--->N
.COLLIDE
.Top Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:(0-1)->BdirX->BdirY:5->N:0->G:End
.Top Right
If (N=0) and ((BposX/128)>=((V/128)+7)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:1->BdirX:(0-1)->BdirY:5->N:0->G:End
.Bottom Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:(0-1)->BdirX:1->BdirY:5->N:End
.Bottom Right
If (N=0) and ((BposX/128)>=((V/128)+6)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:1->BdirX->BdirY:5->N:End
.Top
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((V/128)-8)) and ((BposY/128)<=((V/128)-6))
BmovY+128->BmovY:(0-1)->BdirY:5->N:0->G:End
.Left
If (N=0) and ((BposX/128)>=((V/128)-8)) and ((BposX/128)<=((V/128)-7)) and ((BposY/128)>=((V/128)-5)) and ((BposY/128)<=((V/128)+5))
BmovX+102->BmovX:5->N:If (BposY>5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Right
If (N=0) and ((BposX/128)>=((V/128)+7)) and ((BposX/128)<=((V/128)+8)) and ((BposY/128)>=((V/128)-5)) and ((BposY/128)<=((V/128)+5))
BmovX+102->BmovX:5->N:If (BposY>5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Bottom
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((V/128)+7)) and ((BposY/128)<=((V/128)+8))
1->BdirY:G/5+BmovY/2+64->BmovY:0->G:End

.BORDERS
.Left
If (BposX<128) or (BposX>(0-1280)):128->BposX:1->BdirX:End
.Right
If (BposX>11008):11008->BposX:(0-1)->BdirX:End
.Top
If (BposY)<128):128->BposY:1->BdirY:(BmovY/2)->BmovY:End
.Bottom
If (BposY)>7168):7168->BposY:(G/10+BmovY)->BmovY:0->G:-1->BDirY:End
Return

Lbl Gravity
.Friction
If BmovX>50:BmovX*127/128->BmovX:Else:If BmovX<20:If (C/4+4)=C:BmovX*127/128->BmovX:End:Else:If (C/2+2)=C:BmovX*127/128->BmovX:End:End:End
.Slow down and speed up
If BdirY=1:102:Else:97:End:*BmovY/128->BmovY
.Add Gravity
G+3->G:/10+BposY->BposY
Return

Well you still didn't replace Pic01 and Pic02 with custom names like °BallSprite for readability :P
And to answer your question on IRC, no, you can't do L1->°Wat:+2->°Lol, because they are preprocessor directives (which isn't an excuse actually, but it explains why A->B:+2->C works and not L1->°Wat:+2->°Lol).

Also, really, avoid putting End or Return at the end of a line. I mean, if you put everything on the line, it may be ok, like this
If A>B:A->C:Else:B->C:End
(even though one-liners are usually reserved to ternary operators, and even though that one line here could just be max(A,B)->C).
And putting it on several lines is ok too, which is why everyone does it, like this
If A>B
A->C
Else
B->C
End

because it allows indentation like that
If A>B
    A->C
Else
    B->C
End

But almost no one will agree with the following. Only people programming in Pico and Lisp.
If A>B
A->C
Else
B->C:End

So in short version, always either put the whole If and it's Else/ElseIf and End on the same line, or put every Else/ElseIf and End on a new line (but the code between the Else/ElseIf/End can be on one line, no one cares as long as it doesn't kill indentation).

And obviously, this doesn't change anything from the compiler's point of view, but if you ask for help in a C forum and write code like this

    while(
1)
{
sleep(4);}

no one will read and no one will help. And you'll have problems reading too I'm sure. So really, keep the code a minimum readable (even if all lines in an Axe code are unreadable, the code as a whole can be "readable").

Dream of Omnimaga

Wait, Axe now supports custom pointer names instead of just Pic1 and so on? O.O
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Hayleia

Quote from: DJ Omnimaga on August 26, 2016, 03:58:24 PM
Wait, Axe now supports custom pointer names instead of just Pic1 and so on? O.O
Yes, custom pointers and variables.
Pointers start with a °, variables don't.
And it follows the rule that says that °<whatever> is the pointer to <whatever>. Like °A being the pointer to A (so {°A)^r is the same as A, but longer), or L1->°Toaster meaning that Toaster is a variable which value is stored in L1, etc.
If you're compiling as a program, you could even write [0000]->°Var and have a custom variable here. It will trigger writeback in shells that support it, but maybe you don't care or that's exactly what you want ;)

p2

#28
Didnt know you could use the ° everywhere, thought it was just ment for var declaration but this as awesome :D
so It's like this? :)
{X} returns the value of memory position X (1 Byte)
{X}^r returns the value of the memory positions X and X+1 (2 Bytes)
°X returns the memory position of the pointer called X
And when using this stuff:
L1+123->°Var sets a new pointer named "Var" pointing at the memory position L1+123
Var->A gets the value of the memory position the pointer is pointing at and stores it as A
{{L1+123}}^r+Var->Var This would actually just double the value and store it again as {{L1+123}} is the memory position that "Var" is pointing at


Back to my crappy program:
I'm now using this source (I found a couple of mistakes when I copied the code by hand the first time):
*Also added the Source program and the compiled Axe Asm as files below*
.TRY08AXE
ClrDraw
[3C7EFFFFFFFF7E3C]->Pic01
[FF818181818181FF]->Pic02
L1->°BposX
L1+2->°BposY
1280->BposX->BposY
L1+4->°BmovX
L1+6->°BmovY
128->BmovY:*2->BmovX
L1+8->°BdirX
L1+10->°BdirY
1->BdirX->BdirY

.Pos Player *128 = V,W
6400->V
1280->W
.Gravitation=G
.N=NotCollide to prevent double collision
.C=Counter
0->G->N->C
while 1
C++
Pt-On(BposX/128,BposY/128,Pic01)
Pt-On(V/128,W/128,Pic02)
DispGraph:ClrDraw
BmovX*BdirX+BposX->BposX
BmovY*BdirY+BposY->BposY
Movement()
Collision()
Gravity()
EndIf getKey(15)
Return

Lbl Movement
.moveX
V<11008 and getKey(3)-(V>0 and getKey(2))*128+V->V
.moveY
W<7168 and getKey(1)-(W>0 and getKey(4))*128+W->W
Return


Lbl Collision
N>0?N--->N
.COLLIDE
.Top Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:(0-1)->BdirX->BdirY:5->N:0->G:End
.Top Right
If (N=0) and ((BposX/128)>=((V/128)+6)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)-7)) and ((BposY/128)<=((W/128)-6))
BmovX+102->BmovX:BmovY+102->BmovY:1->BdirX:(0-1)->BdirY:5->N:0->G:End
.Bottom Left
If (N=0) and ((BposX/128)>=((V/128)-7)) and ((BposX/128)<=((V/128)-6)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:(0-1)->BdirX:1->BdirY:5->N:End
.Bottom Right
If (N=0) and ((BposX/128)>=((V/128)+6)) and ((BposX/128)<=((V/128)+7)) and ((BposY/128)>=((W/128)+6)) and ((BposY/128)<=((W/128)+7))
BmovX+128->BmovX:BmovY+128->BmovY:1->BdirX->BdirY:5->N:End
.Top
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((W/128)-8)) and ((BposY/128)<=((W/128)-6))
BmovY+128->BmovY:(0-1)->BdirY:5->N:0->G:End
.Left
If (N=0) and ((BposX/128)>=((V/128)-8)) and ((BposX/128)<=((V/128)-7)) and ((BposY/128)>=((W/128)-5)) and ((BposY/128)<=((W/128)+5))
BmovX+102->BmovX:5->N:(0-1)->BdirX:If (BposY>=5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Right
If (N=0) and ((BposX/128)>=((V/128)+7)) and ((BposX/128)<=((V/128)+8)) and ((BposY/128)>=((W/128)-5)) and ((BposY/128)<=((W/128)+5))
BmovX+102->BmovX:5->N:^->BdirX:If (BposY>=5500):(0-1)->BdirY:BmovY+102->BmovY:BmovX+20->BmovX:End:End
.Bottom
If (N=0) and ((BposX/128)>=((V/128)-5)) and ((BposX/128)<=((V/128)+5)) and ((BposY/128)>=((W/128)+7)) and ((BposY/128)<=((W/128)+8))
1->BdirY:G/5+BmovY/2+64->BmovY:0->G:End

.BORDERS
.Left
If (BposX<128) or (BposX>(0-1280)):128->BposX:1->BdirX:End
.Right
If (BposX>11008):11008->BposX:(0-1)->BdirX:End
.Top
If (BposY)<128):128->BposY:1->BdirY:(BmovY/2)->BmovY:End
.Bottom
If (BposY)>7168):7168->BposY:(G/10+BmovY)->BmovY:0->G:-1->BDirY:End
Return

Lbl Gravity
.Friction
If BmovX>64:BmovX*127/128->BmovX:Else:If BmovX<26:If (C/4*4)=C:BmovX*127/128->BmovX:End:Else:If (C/2*2)=C:BmovX*127/128->BmovX:End:End:End
.Slow down and speed up
If BdirY=1:102:Else:97:End:*BmovY/128->BmovY
.Add Gravity
G+3->G:/10+BposY->BposY
Return

It seems to work fine for the X-axis but for some reason everything on the Y-axis is totally messed up... Can you maybe find the bug...? :(
Back in the old unmodified source there was no problem so it got to be because of some of the modifications...
See a picture of it:




Edit: I got to admit I forgot to add the collision-below... but all edges as well as left, right and top are there :)

Edit 2: Having added teh colision for ball below player, too, it didnt change anything... Still cant find the bug :( Any of you guys found something?
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Hayleia

Quote from: p2 on August 26, 2016, 05:50:59 PM
Didnt know you could use the ° everywhere, thought it was just ment for var declaration but this as awesome :D
so It's like this? :)
{X} returns the value of memory position X (1 Byte)
{X}^r returns the value of the memory positions X and X+1 (2 Bytes)
°X returns the memory position of the pointer called X
And when using this stuff:
L1+123->°Var sets a new pointer named "Var" pointing at the memory position L1+123
Var->A gets the value of the memory position the pointer is pointing at and stores it as A
Yes for all of that.
Quote from: p2 on August 26, 2016, 05:50:59 PM
{{L1+123}}^r+Var->Var This would actually just double the value and store it again as {{L1+123}} is the memory position that "Var" is pointing at
Well, no, why do you double the "{}"? Var is the same as {°Var}^r which is {L1+123}^r, not {{L1+123}}^r.

And for your problem, go back to the unmodified code (that you said worked) then do the modifications one by one until it stops working. You'll know what caused the problem ;)
Yes, that's annoying, that's debugging :P
But that's also why I didn't advise any optimization. Yes, an optimized code is better than a non-optimized code for the same result... but for the same result :P

Powered by EzPortal