I am programming a 2048 game, and have a decent one that works right now, however it runs dreadfully slow. I wonder if anyone can help optimize it so it runs faster?
I expected to use output and random more, that is why they are separate, I will combine in future though. Output just outputs the numbers on the screen, and random picks a random unoccupied spot to put another 2.
EDIT: I do not know the source code for prgmASM, since I got it off the internet, but all it does is switch the prgm and home commands, allowing me to use Archive and UnArchive within the program. I run this from mirageOS so that it doesn't take up RAM, and have the other programs(except ASM which is really small) archived as well.
EDIT2: Pic3 is the grid which I drew, and GDB0 is the standard graph screen, in case of functions interfering.


Code:

:ClrDraw
Asm(prgmASM)
UnArchive GDB0
RecallGDB 0
Archive GDB0
Asm(prgmASM)
AxesOff
RecallPic 3
0->|LZ048(1)
0->|LZ048(2)
0->|LZ048(3)
0->|LZ048(4)
0->|LZ048(5)
0->|LZ048(6)
0->|LZ048(7)
0->|LZ048(8)
0->|LZ048(9)
0->|LZ048(10)
0->|LZ048(11)
0->|LZ048(12)
0->|LZ048(13)
0->|LZ048(14)
0->|LZ048(15)
0->|LZ048(16)
2->|LZ048(randInt(1,16))
0->Q
While Q!=3.232
Asm(prgmASM)
UnArchive prgmRANDOM
UnArchive prgmOUTPUT
Asm(prgmASM)
prgmRANDOM
prgmOUTPUT
Asm(prgmASM)
Archive prgmRANDOM
Archive prgmOUTPUT
Asm(prgmASM)
0->G
While G!=24 and G!=25 and G!=26 and G!=34
getKey->G
End
If G=24
Then
If |LZ048(1)!=0 or |LZ048(2)!=0 or |LZ048(3)!=0 or |LZ048(4)!=0
Then
While |LZ048(1)=0
|LZ048(2)->|LZ048(1)
|LZ048(3)->|LZ048(2)
|LZ048(4)->|LZ048(3)
0->|LZ048(4)
End
If |LZ048(3)!=0 or |LZ048(4)!=0
Then
While |LZ048(2)=0
|LZ048(3)->|LZ048(2)
|LZ048(4)->|LZ048(3)
0->|LZ048(4)
End
End
If |LZ048(4)!=0
Then
While |LZ048(3)=0
|LZ048(4)->|LZ048(3)
0->|LZ048(4)
End
End
If |LZ048(1)=|LZ048(2) and |LZ048(1)!=0
Then
2(|LZ048(1))->|LZ048(1)
|LZ048(3)->|LZ048(2)
|LZ048(4)->|LZ048(3)
0->|LZ048(4)
End
If |LZ048(2)=|LZ048(3) and |LZ048(2)!=0
Then
2(|LZ048(2))->|LZ048(2)
|LZ048(4)->|LZ048(3)
0->|LZ048(4)
End
If |LZ048(3)=|LZ048(4) and |LZ048(3)!=0
Then
2(|LZ048(3))->|LZ048(3)
0->|LZ048(4)
End
End
If |LZ048(5)!=0 or |LZ048(6)!=0 or |LZ048(7)!=0 or |LZ048(8)!=0
Then
While |LZ048(5)=0
|LZ048(6)->|LZ048(5)
|LZ048(7)->|LZ048(6)
|LZ048(8)->|LZ048(7)
0->|LZ048(8)
End
If |LZ048(7)!=0 or |LZ048(8)!=0
Then
While |LZ048(6)=0
|LZ048(7)->|LZ048(6)
|LZ048(8)->|LZ048(7)
0->|LZ048(8)
End
End
If |LZ048(8)!=0
Then
While |LZ048(7)=0
|LZ048(8)->|LZ048(7)
0->|LZ048(8)
End
End
If |LZ048(5)=|LZ048(6) and |LZ048(5)!=0
Then
2(|LZ048(5))->|LZ048(5)
|LZ048(7)->|LZ048(6)
|LZ048(8)->|LZ048(7)
0->|LZ048(8)
End
If |LZ048(6)=|LZ048(7) and |LZ048(6)!=0
Then
2(|LZ048(6))->|LZ048(6)
|LZ048(8)->|LZ048(7)
0->|LZ048(8)
End
If |LZ048(7)=|LZ048(8) and |LZ048(7)!=0
Then
2(|LZ048(7))->|LZ048(7)
0->|LZ048(8)
End
End
If |LZ048(9)!=0 or |LZ048(10)!=0 or |LZ048(11)!=0 or |LZ048(12)!=0
Then
While |LZ048(9)=0
|LZ048(10)->|LZ048(9)
|LZ048(11)->|LZ048(10)
|LZ048(12)->|LZ048(11)
0->|LZ048(12)
End
If |LZ048(11)!=0 or |LZ048(12)!=0
Then
While |LZ048(10)=0
|LZ048(11)->|LZ048(10)
|LZ048(12)->|LZ048(11)
0->|LZ048(12)
End
End
If |LZ048(12)!=0
Then
While |LZ048(11)=0
|LZ048(12)->|LZ048(11)
0->|LZ048(12)
End
End
If |LZ048(9)=|LZ048(10) and |LZ048(9)!=0
Then
2(|LZ048(9))->|LZ048(9)
|LZ048(11)->|LZ048(10)
|LZ048(12)->|LZ048(11)
0->|LZ048(12)
End
If |LZ048(10)=|LZ048(11) and |LZ048(10)!=0
Then
2(|LZ048(10))->|LZ048(10)
|LZ048(12)->|LZ048(11)
0->|LZ048(12)
End
If |LZ048(11)=|LZ048(12) and |LZ048(11)!=0
Then
2(|LZ048(11))->|LZ048(11)
0->|LZ048(12)
End
End
If |LZ048(13)!=0 or |LZ048(14)!=0 or |LZ048(15)!=0 or |LZ048(16)!=0
Then
While |LZ048(13)=0
|LZ048(14)->|LZ048(13)
|LZ048(15)->|LZ048(14)
|LZ048(16)->|LZ048(15)
0->|LZ048(16)
End
If |LZ048(15)!=0 or |LZ048(16)!=0
Then
While |LZ048(14)=0
|LZ048(15)->|LZ048(14)
|LZ048(16)->|LZ048(15)
0->|LZ048(16)
End
End
If |LZ048(16)!=0
Then
While |LZ048(15)=0
|LZ048(16)->|LZ048(15)
0->|LZ048(16)
End
End
If |LZ048(13)=|LZ048(14) and |LZ048(13)!=0
Then
2(|LZ048(13))->|LZ048(13)
|LZ048(15)->|LZ048(14)
|LZ048(16)->|LZ048(15)
0->|LZ048(16)
End
If |LZ048(14)=|LZ048(15) and |LZ048(14)!=0
Then
2(|LZ048(14))->|LZ048(14)
|LZ048(16)->|LZ048(15)
0->|LZ048(16)
End
If |LZ048(15)=|LZ048(16) and |LZ048(15)!=0
Then
2(|LZ048(15))->|LZ048(15)
0->|LZ048(16)
End
End
End
If G=25
Then
If |LZ048(1)!=0 or |LZ048(5)!=0 or |LZ048(9)!=0 or |LZ048(13)!=0
Then
While |LZ048(1)=0
|LZ048(5)->|LZ048(1)
|LZ048(9)->|LZ048(5)
|LZ048(13)->|LZ048(9)
0->|LZ048(13)
End
If |LZ048(9)!=0 or |LZ048(13)!=0
Then
While |LZ048(5)=0
|LZ048(9)->|LZ048(5)
|LZ048(13)->|LZ048(9)
0->|LZ048(13)
End
End
If |LZ048(13)!=0
Then
While |LZ048(9)=0
|LZ048(13)->|LZ048(9)
0->|LZ048(13)
End
End
If |LZ048(1)=|LZ048(5) and |LZ048(1)!=0
Then
2(|LZ048(1))->|LZ048(1)
|LZ048(9)->|LZ048(5)
|LZ048(13)->|LZ048(9)
0->|LZ048(13)
End
If |LZ048(5)=|LZ048(9) and |LZ048(5)!=0
Then
2(|LZ048(5))->|LZ048(5)
|LZ048(13)->|LZ048(9)
0->|LZ048(13)
End
If |LZ048(9)=|LZ048(13) and |LZ048(9)!=0
Then
2(|LZ048(9))->|LZ048(9)
0->|LZ048(13)
End
End
If |LZ048(2)!=0 or |LZ048(6)!=0 or |LZ048(10)!=0 or |LZ048(14)!=0
Then
While |LZ048(2)=0
|LZ048(6)->|LZ048(2)
|LZ048(10)->|LZ048(6)
|LZ048(14)->|LZ048(10)
0->|LZ048(14)
End
If |LZ048(10)!=0 or |LZ048(14)!=0
Then
While |LZ048(6)=0
|LZ048(10)->|LZ048(6)
|LZ048(14)->|LZ048(10)
0->|LZ048(14)
End
End
If |LZ048(14)!=0
Then
While |LZ048(10)=0
|LZ048(14)->|LZ048(10)
0->|LZ048(14)
End
End
If |LZ048(2)=|LZ048(6) and |LZ048(2)!=0
Then
2(|LZ048(2))->|LZ048(2)
|LZ048(10)->|LZ048(6)
|LZ048(14)->|LZ048(10)
0->|LZ048(14)
End
If |LZ048(6)=|LZ048(10) and |LZ048(6)!=0
Then
2(|LZ048(6))->|LZ048(6)
|LZ048(14)->|LZ048(10)
0->|LZ048(14)
End
If |LZ048(10)=|LZ048(14) and |LZ048(10)!=0
Then
2(|LZ048(10))->|LZ048(10)
0->|LZ048(14)
End
End
If |LZ048(3)!=0 or |LZ048(7)!=0 or |LZ048(11)!=0 or |LZ048(15)!=0
Then
While |LZ048(3)=0
|LZ048(7)->|LZ048(3)
|LZ048(11)->|LZ048(7)
|LZ048(15)->|LZ048(11)
0->|LZ048(15)
End
If |LZ048(11)!=0 or |LZ048(15)!=0
Then
While |LZ048(7)=0
|LZ048(11)->|LZ048(7)
|LZ048(15)->|LZ048(11)
0->|LZ048(15)
End
End
If |LZ048(15)!=0
Then
While |LZ048(11)=0
|LZ048(15)->|LZ048(11)
0->|LZ048(15)
End
End
If |LZ048(3)=|LZ048(7) and |LZ048(3)!=0
Then
2(|LZ048(3))->|LZ048(3)
|LZ048(11)->|LZ048(7)
|LZ048(15)->|LZ048(11)
0->|LZ048(15)
End
If |LZ048(7)=|LZ048(11) and |LZ048(7)!=0
Then
2(|LZ048(7))->|LZ048(7)
|LZ048(15)->|LZ048(11)
0->|LZ048(15)
End
If |LZ048(11)=|LZ048(15) and |LZ048(11)!=0
Then
2(|LZ048(11))->|LZ048(11)
0->|LZ048(15)
End
End
If |LZ048(4)!=0 or |LZ048(8)!=0 or |LZ048(12)!=0 or |LZ048(16)!=0
Then
While |LZ048(4)=0
|LZ048(8)->|LZ048(4)
|LZ048(12)->|LZ048(8)
|LZ048(16)->|LZ048(12)
0->|LZ048(16)
End
If |LZ048(12)!=0 or |LZ048(16)!=0
Then
While |LZ048(8)=0
|LZ048(12)->|LZ048(8)
|LZ048(16)->|LZ048(12)
0->|LZ048(16)
End
End
If |LZ048(16)!=0
Then
While |LZ048(12)=0
|LZ048(16)->|LZ048(12)
0->|LZ048(16)
End
End
If |LZ048(4)=|LZ048(8) and |LZ048(4)!=0
Then
2(|LZ048(4))->|LZ048(4)
|LZ048(12)->|LZ048(8)
|LZ048(16)->|LZ048(12)
0->|LZ048(16)
End
If |LZ048(8)=|LZ048(12) and |LZ048(8)!=0
Then
2(|LZ048(8))->|LZ048(8)
|LZ048(16)->|LZ048(12)
0->|LZ048(16)
End
If |LZ048(12)=|LZ048(16) and |LZ048(12)!=0
Then
2(|LZ048(12))->|LZ048(12)
0->|LZ048(16)
End
End
End
If G=26
Then
If |LZ048(4)!=0 or |LZ048(3)!=0 or |LZ048(2)!=0 or |LZ048(1)!=0
Then
While |LZ048(4)=0
|LZ048(3)->|LZ048(4)
|LZ048(2)->|LZ048(3)
|LZ048(1)->|LZ048(2)
0->|LZ048(1)
End
If |LZ048(2)!=0 or |LZ048(1)!=0
Then
While |LZ048(3)=0
|LZ048(2)->|LZ048(3)
|LZ048(1)->|LZ048(2)
0->|LZ048(1)
End
End
If |LZ048(1)!=0
Then
While |LZ048(2)=0
|LZ048(1)->|LZ048(2)
0->|LZ048(1)
End
End
If |LZ048(4)=|LZ048(3) and |LZ048(4)!=0
Then
2(|LZ048(4))->|LZ048(4)
|LZ048(2)->|LZ048(3)
|LZ048(1)->|LZ048(2)
0->|LZ048(1)
End
If |LZ048(3)=|LZ048(2) and |LZ048(3)!=0
Then
2(|LZ048(3))->|LZ048(3)
|LZ048(1)->|LZ048(2)
0->|LZ048(1)
End
If |LZ048(2)=|LZ048(1) and |LZ048(2)!=0
Then
2(|LZ048(2))->|LZ048(2)
0->|LZ048(1)
End
End
If |LZ048(8)!=0 or |LZ048(7)!=0 or |LZ048(6)!=0 or |LZ048(5)!=0
Then
While |LZ048(8)=0
|LZ048(7)->|LZ048(8)
|LZ048(6)->|LZ048(7)
|LZ048(5)->|LZ048(6)
0->|LZ048(5)
End
If |LZ048(6)!=0 or |LZ048(5)!=0
Then
While |LZ048(7)=0
|LZ048(6)->|LZ048(7)
|LZ048(5)->|LZ048(6)
0->|LZ048(5)
End
End
If |LZ048(5)!=0
Then
While |LZ048(6)=0
|LZ048(5)->|LZ048(6)
0->|LZ048(5)
End
End
If |LZ048(8)=|LZ048(7) and |LZ048(8)!=0
Then
2(|LZ048(8))->|LZ048(8)
|LZ048(6)->|LZ048(7)
|LZ048(5)->|LZ048(6)
0->|LZ048(5)
End
If |LZ048(7)=|LZ048(6) and |LZ048(7)!=0
Then
2(|LZ048(7))->|LZ048(7)
|LZ048(5)->|LZ048(6)
0->|LZ048(5)
End
If |LZ048(6)=|LZ048(5) and |LZ048(6)!=0
Then
2(|LZ048(6))->|LZ048(6)
0->|LZ048(5)
End
End
If |LZ048(12)!=0 or |LZ048(11)!=0 or |LZ048(10)!=0 or |LZ048(9)!=0
Then
While |LZ048(12)=0
|LZ048(11)->|LZ048(12)
|LZ048(10)->|LZ048(11)
|LZ048(9)->|LZ048(10)
0->|LZ048(9)
End
If |LZ048(10)!=0 or |LZ048(9)!=0
Then
While |LZ048(11)=0
|LZ048(10)->|LZ048(11)
|LZ048(9)->|LZ048(10)
0->|LZ048(9)
End
End
If |LZ048(9)!=0
Then
While |LZ048(10)=0
|LZ048(9)->|LZ048(10)
0->|LZ048(9)
End
End
If |LZ048(12)=|LZ048(11) and |LZ048(12)!=0
Then
2(|LZ048(12))->|LZ048(12)
|LZ048(10)->|LZ048(11)
|LZ048(9)->|LZ048(10)
0->|LZ048(9)
End
If |LZ048(11)=|LZ048(10) and |LZ048(11)!=0
Then
2(|LZ048(11))->|LZ048(11)
|LZ048(9)->|LZ048(10)
0->|LZ048(9)
End
If |LZ048(10)=|LZ048(9) and |LZ048(10)!=0
Then
2(|LZ048(10))->|LZ048(10)
0->|LZ048(9)
End
End
If |LZ048(16)!=0 or |LZ048(15)!=0 or |LZ048(14)!=0 or |LZ048(13)!=0
Then
While |LZ048(16)=0
|LZ048(15)->|LZ048(16)
|LZ048(14)->|LZ048(15)
|LZ048(13)->|LZ048(14)
0->|LZ048(13)
End
If |LZ048(14)!=0 or |LZ048(13)!=0
Then
While |LZ048(15)=0
|LZ048(14)->|LZ048(15)
|LZ048(13)->|LZ048(14)
0->|LZ048(13)
End
End
If |LZ048(13)!=0
Then
While |LZ048(14)=0
|LZ048(13)->|LZ048(14)
0->|LZ048(13)
End
End
If |LZ048(16)=|LZ048(15) and |LZ048(16)!=0
Then
2(|LZ048(16))->|LZ048(16)
|LZ048(14)->|LZ048(15)
|LZ048(13)->|LZ048(14)
0->|LZ048(13)
End
If |LZ048(15)=|LZ048(14) and |LZ048(15)!=0
Then
2(|LZ048(15))->|LZ048(15)
|LZ048(13)->|LZ048(14)
0->|LZ048(13)
End
If |LZ048(14)=|LZ048(13) and |LZ048(14)!=0
Then
2(|LZ048(14))->|LZ048(14)
0->|LZ048(13)
End
End
End
If G=34
Then
If |LZ048(13)!=0 or |LZ048(9)!=0 or |LZ048(5)!=0 or |LZ048(1)!=0
Then
While |LZ048(13)=0
|LZ048(9)->|LZ048(13)
|LZ048(5)->|LZ048(9)
|LZ048(1)->|LZ048(5)
0->|LZ048(1)
End
If |LZ048(5)!=0 or |LZ048(1)!=0
Then
While |LZ048(9)=0
|LZ048(5)->|LZ048(9)
|LZ048(1)->|LZ048(5)
0->|LZ048(1)
End
End
If |LZ048(1)!=0
Then
While |LZ048(5)=0
|LZ048(1)->|LZ048(5)
0->|LZ048(1)
End
End
If |LZ048(13)=|LZ048(9) and |LZ048(13)!=0
Then
2(|LZ048(13))->|LZ048(13)
|LZ048(5)->|LZ048(9)
|LZ048(1)->|LZ048(5)
0->|LZ048(1)
End
If |LZ048(9)=|LZ048(5) and |LZ048(9)!=0
Then
2(|LZ048(9))->|LZ048(9)
|LZ048(1)->|LZ048(5)
0->|LZ048(1)
End
If |LZ048(5)=|LZ048(1) and |LZ048(5)!=0
Then
2(|LZ048(5))->|LZ048(5)
0->|LZ048(1)
End
End
If |LZ048(14)!=0 or |LZ048(10)!=0 or |LZ048(6)!=0 or |LZ048(2)!=0
Then
While |LZ048(14)=0
|LZ048(10)->|LZ048(14)
|LZ048(6)->|LZ048(10)
|LZ048(2)->|LZ048(6)
0->|LZ048(2)
End
If |LZ048(6)!=0 or |LZ048(2)!=0
Then
While |LZ048(10)=0
|LZ048(6)->|LZ048(10)
|LZ048(2)->|LZ048(6)
0->|LZ048(2)
End
End
If |LZ048(2)!=0
Then
While |LZ048(6)=0
|LZ048(2)->|LZ048(6)
0->|LZ048(2)
End
End
If |LZ048(14)=|LZ048(10) and |LZ048(14)!=0
Then
2(|LZ048(14))->|LZ048(14)
|LZ048(6)->|LZ048(10)
|LZ048(2)->|LZ048(6)
0->|LZ048(2)
End
If |LZ048(10)=|LZ048(6) and |LZ048(10)!=0
Then
2(|LZ048(10))->|LZ048(10)
|LZ048(2)->|LZ048(6)
0->|LZ048(2)
End
If |LZ048(6)=|LZ048(2) and |LZ048(6)!=0
Then
2(|LZ048(6))->|LZ048(6)
0->|LZ048(2)
End
End
If |LZ048(15)!=0 or |LZ048(11)!=0 or |LZ048(7)!=0 or |LZ048(3)!=0
Then
While |LZ048(15)=0
|LZ048(11)->|LZ048(15)
|LZ048(7)->|LZ048(11)
|LZ048(3)->|LZ048(7)
0->|LZ048(3)
End
If |LZ048(7)!=0 or |LZ048(3)!=0
Then
While |LZ048(11)=0
|LZ048(7)->|LZ048(11)
|LZ048(3)->|LZ048(7)
0->|LZ048(3)
End
End
If |LZ048(3)!=0
Then
While |LZ048(7)=0
|LZ048(3)->|LZ048(7)
0->|LZ048(3)
End
End
If |LZ048(15)=|LZ048(11) and |LZ048(15)!=0
Then
2(|LZ048(15))->|LZ048(15)
|LZ048(7)->|LZ048(11)
|LZ048(3)->|LZ048(7)
0->|LZ048(3)
End
If |LZ048(11)=|LZ048(7) and |LZ048(11)!=0
Then
2(|LZ048(11))->|LZ048(11)
|LZ048(3)->|LZ048(7)
0->|LZ048(3)
End
If |LZ048(7)=|LZ048(3) and |LZ048(7)!=0
Then
2(|LZ048(7))->|LZ048(7)
0->|LZ048(3)
End
End
If |LZ048(16)!=0 or |LZ048(12)!=0 or |LZ048(8)!=0 or |LZ048(4)!=0
Then
While |LZ048(16)=0
|LZ048(12)->|LZ048(16)
|LZ048(8)->|LZ048(12)
|LZ048(4)->|LZ048(8)
0->|LZ048(4)
End
If |LZ048(8)!=0 or |LZ048(4)!=0
Then
While |LZ048(12)=0
|LZ048(8)->|LZ048(12)
|LZ048(4)->|LZ048(8)
0->|LZ048(4)
End
End
If |LZ048(4)!=0
Then
While |LZ048(8)=0
|LZ048(4)->|LZ048(8)
0->|LZ048(4)
End
End
If |LZ048(16)=|LZ048(12) and |LZ048(16)!=0
Then
2(|LZ048(16))->|LZ048(16)
|LZ048(8)->|LZ048(12)
|LZ048(4)->|LZ048(8)
0->|LZ048(4)
End
If |LZ048(12)=|LZ048(8) and |LZ048(12)!=0
Then
2(|LZ048(12))->|LZ048(12)
|LZ048(4)->|LZ048(8)
0->|LZ048(4)
End
If |LZ048(8)=|LZ048(4) and |LZ048(8)!=0
Then
2(|LZ048(8))->|LZ048(8)
0->|LZ048(4)
End
End
End
End


prgmOUTPUT code:

Code:

Text(5,6,"    ")
Text(5,30,"    ")
Text(5,54,"    ")
Text(20,77,"    ")
Text(20,6,"    ")
Text(20,30,"    ")
Text(20,54,"    ")
Text(20,77,"    ")
Text(35,6,"    ")
Text(35,30,"    ")
Text(35,54,"    ")
Text(35,77,"    ")
Text(50,6,"    ")
Text(50,30,"    ")
Text(50,54,"    ")
Text(50,77,"    ")
If |LZ048(1)!=0
Then
Text(5,6,|LZ048(1))
End
If |LZ048(2)!=0
Then
Text(5,30,|LZ048(2))
End
If |LZ048(3)!=0
Then
Text(5,54,|LZ048(3))
End
If |LZ048(4)!=0
Then
Text(5,77,|LZ048(4))
End
If |LZ048(5)!=0
Then
Text(20,6,|LZ048(5))
End
If |LZ048(6)!=0
Then
Text(20,30,|LZ048(6))
End
If |LZ048(7)!=0
Then
Text(20,54,|LZ048(7))
End
If |LZ048(8)!=0
Then
Text(20,77,|LZ048(8))
End
If |LZ048(9)!=0
Then
Text(35,6,|LZ048(9))
End
If |LZ048(10)!=0
Then
Text(35,30,|LZ048(10))
End
If |LZ048(11)!=0
Then
Text(35,54,|LZ048(11))
End
If |LZ048(12)!=0
Then
Text(35,77,|LZ048(12))
End
If |LZ048(13)!=0
Then
Text(50,6,|LZ048(13))
End
If |LZ048(14)!=0
Then
Text(50,30,|LZ048(14))
End
If |LZ048(15)!=0
Then
Text(50,54,|LZ048(15))
End
If |LZ048(16)!=0
Then
Text(50,77,|LZ048(16))
End


prgmRANDOM code:

Code:

0->X
1->A
While A<=16
If |LZ048(A)=0
Then
1+X->X
A->|LRNDM(X)
End
1+A->A
End
If X=0
Then
3.232->Q
Return
Else
randInt(1,X)->B
|LRNDM(B)->C
2->|LZ048(C)
End
Can you post the dode for prgmRANDOM, prgmOUTPUT, and the source to prgmASM?

Code:
0->|LZ048(1)
0->|LZ048(2)
0->|LZ048(3)
0->|LZ048(4)
0->|LZ048(5)
0->|LZ048(6)
0->|LZ048(7)
0->|LZ048(8)
0->|LZ048(9)
0->|LZ048(10)
0->|LZ048(11)
0->|LZ048(12)
0->|LZ048(13)
0->|LZ048(14)
0->|LZ048(15)
0->|LZ048(16)


Can be Fill(0,|LZ048

UnArchive and Archive take a bit of time to do, if the programs have any decent size at all to them. You're better off with a program or routine to copy them from archive to ram as a temp program.

All those conditionals in the first program.. Might look into creating something a bit more dynamic in searching and manipulating.

As to your second program, you realize that if you are only doing one thing, in your case using Text( after a conditional, you don't need Then and End. If blah:Text(blah

Will let you do some thinking and modifying based on those thoughts first, and we'll go from there. Smile
Thanks, didn't know about the fill command. I am going to just get rid of subprograms, originally I thought I would use output more than once, so that'll get rid of the archives. I could use while and variables to do each line in each direction instead of doing each line manually, which would shorten it, but I think that that makes it go slower? Maybe I don't know what u mean by something dynamic, but I don't think it would go faster, since it would add another layer of while/if.
As far as archiving and unarchiving from within programs, I strongly suggest that you make it a Doors CS program instead of a MirageOS program. This will allow you to use ExecArcPrgm and all of the other BASIC libraries that Doors CS offers (including sprite routines if you want tile sprites for your game. As far as programming suggestions for your existing code, you have a great deal of conditional repetition that could be combined into For() loops. Fixing this wouldn't help the speed, but it would drastically reduce the size of your program. Have you considered looking at some existing 2048 clones for reference, like my color version?
Ok, I made some changes and now it is all one program and drastically reduced in size. Now it takes a while to reoutput all of the numbers, resulting in a split-second of no numbers on the screen when it clears then reoutputs the numbers. I have an idea on how to fix this, using if else statements, but that would have the cleartext code twice, and wouldn't that take longer on an already slow program?


Code:
:ClrDraw
Asm(prgmASM)
UnArchive GDB0
RecallGDB 0
Archive GDB0
Asm(prgmASM)
AxesOff
RecallPic 3
ClrList |LZ048
16->dim(|LZ048)
2->|LZ048(randInt(1,16))
0->Q
While Q!=3.232
0->X
1->A
While A<=16
If |LZ048(A)=0
Then
1+X->X
A->|LRNDM(X)
End
1+A->A
End
If X=0
Then
3.232->Q
Return
Else
randInt(1,X)->B
|LRNDM(B)->C
2->|LZ048(C)
End
Text(5,6,"                ")
Text(5,30,"                ")
Text(5,54,"                ")
Text(5,77,"                ")
Text(20,6,"                ")
Text(20,30,"                ")
Text(20,54,"                ")
Text(20,77,"                ")
Text(35,6,"                ")
Text(35,30,"                ")
Text(35,54,"                ")
Text(35,77,"                ")
Text(50,6,"                ")
Text(50,30,"                ")
Text(50,54,"                ")
Text(50,77,"                ")
If |LZ048(1)!=0
Text(5,6,|LZ048(1))
If |LZ048(2)!=0
Text(5,30,|LZ048(2))
If |LZ048(3)!=0
Text(5,54,|LZ048(3))
If |LZ048(4)!=0
Text(5,77,|LZ048(4))
If |LZ048(5)!=0
Text(20,6,|LZ048(5))
If |LZ048(6)!=0
Text(20,30,|LZ048(6))
If |LZ048(7)!=0
Text(20,54,|LZ048(7))
If |LZ048(8)!=0
Text(20,77,|LZ048(8))
If |LZ048(9)!=0
Text(35,6,|LZ048(9))
If |LZ048(10)!=0
Text(35,30,|LZ048(10))
If |LZ048(11)!=0
Text(35,54,|LZ048(11))
If |LZ048(12)!=0
Text(35,77,|LZ048(12))
If |LZ048(13)!=0
Text(50,6,|LZ048(13))
If |LZ048(14)!=0
Text(50,30,|LZ048(14))
If |LZ048(15)!=0
Text(50,54,|LZ048(15))
If |LZ048(16)!=0
Text(50,77,|LZ048(16))
0->G
While G!=24 and G!=25 and G!=26 and G!=34
getKey->G
End
If G=24
Then
For(X,1,13,4)
If |LZ048(X)!=0 or |LZ048(X+1)!=0 or |LZ048(X+2)!=0 or |LZ048(X+3)!=0
Then
While |LZ048(X)=0
|LZ048(X+1)->|LZ048(X)
|LZ048(X+2)->|LZ048(X+1)
|LZ048(X+3)->|LZ048(X+2)
0->|LZ048(X+3)
End
If |LZ048(X+2)!=0 or |LZ048(X+3)!=0
Then
While |LZ048(X+1)=0
|LZ048(X+2)->|LZ048(X+1)
|LZ048(X+3)->|LZ048(X+2)
0->|LZ048(X+3)
End
End
If |LZ048(X+3)!=0
Then
While |LZ048(X+2)=0
|LZ048(X+3)->|LZ048(X+2)
0->|LZ048(X+3)
End
End
If |LZ048(X)=|LZ048(X+1) and |LZ048(X)!=0
Then
2(|LZ048(X))->|LZ048(X)
|LZ048(X+2)->|LZ048(X+1)
|LZ048(X+3)->|LZ048(X+2)
0->|LZ048(X+3)
End
If |LZ048(X+1)=|LZ048(X+2) and |LZ048(X+1)!=0
Then
2(|LZ048(X+1))->|LZ048(X+1)
|LZ048(X+3)->|LZ048(X+2)
0->|LZ048(X+3)
End
If |LZ048(X+2)=|LZ048(X+3) and |LZ048(X+2)!=0
Then
2(|LZ048(X+2))->|LZ048(X+2)
0->|LZ048(X+3)
End
End
End
End
If G=25
Then
For(X,1,4)
If |LZ048(X)!=0 or |LZ048(X+4)!=0 or |LZ048(X+8)!=0 or |LZ048(X+12)!=0
Then
While |LZ048(X)=0
|LZ048(X+4)->|LZ048(X)
|LZ048(X+8)->|LZ048(X+4)
|LZ048(X+12)->|LZ048(X+8)
0->|LZ048(X+12)
End
If |LZ048(X+8)!=0 or |LZ048(X+12)!=0
Then
While |LZ048(X+4)=0
|LZ048(X+8)->|LZ048(X+4)
|LZ048(X+12)->|LZ048(X+8)
0->|LZ048(X+12)
End
End
If |LZ048(X+12)!=0
Then
While |LZ048(X+8)=0
|LZ048(X+12)->|LZ048(X+8)
0->|LZ048(X+12)
End
End
If |LZ048(X)=|LZ048(X+4) and |LZ048(X)!=0
Then
2(|LZ048(X))->|LZ048(X)
|LZ048(X+8)->|LZ048(X+4)
|LZ048(X+12)->|LZ048(X+8)
0->|LZ048(X+12)
End
If |LZ048(X+4)=|LZ048(X+8) and |LZ048(X+4)!=0
Then
2(|LZ048(X+4))->|LZ048(X+4)
|LZ048(X+12)->|LZ048(X+8)
0->|LZ048(X+12)
End
If |LZ048(X+8)=|LZ048(X+12) and |LZ048(X+8)!=0
Then
2(|LZ048(X+8))->|LZ048(X+8)
0->|LZ048(X+12)
End
End
End
End
If G=26
Then
For(X,1,13,4)
If |LZ048(3+X)!=0 or |LZ048(2+X)!=0 or |LZ048(1+X)!=0 or |LZ048(X)!=0
Then
While |LZ048(3+X)=0
|LZ048(2+X)->|LZ048(3+X)
|LZ048(1+X)->|LZ048(2+X)
|LZ048(X)->|LZ048(1+X)
0->|LZ048(X)
End
If |LZ048(1+X)!=0 or |LZ048(X)!=0
Then
While |LZ048(2+X)=0
|LZ048(1+X)->|LZ048(2+X)
|LZ048(X)->|LZ048(1+X)
0->|LZ048(X)
End
End
If |LZ048(X)!=0
Then
While |LZ048(1+X)=0
|LZ048(X)->|LZ048(1+X)
0->|LZ048(X)
End
End
If |LZ048(3+X)=|LZ048(2+X) and |LZ048(3+X)!=0
Then
2(|LZ048(3+X))->|LZ048(3+X)
|LZ048(1+X)->|LZ048(2+X)
|LZ048(X)->|LZ048(1+X)
0->|LZ048(X)
End
If |LZ048(2+X)=|LZ048(1+X) and |LZ048(2+X)!=0
Then
2(|LZ048(2+X))->|LZ048(2+X)
|LZ048(X)->|LZ048(1+X)
0->|LZ048(X)
End
If |LZ048(1+X)=|LZ048(X) and |LZ048(1+X)!=0
Then
2(|LZ048(1+X))->|LZ048(1+X)
0->|LZ048(X)
End
End
End
End
If G=34
Then
For(X,1,4)
If |LZ048(X+12)!=0 or |LZ048(X+8)!=0 or |LZ048(X+4)!=0 or |LZ048(X)!=0
Then
While |LZ048(X+12)=0
|LZ048(X+8)->|LZ048(X+12)
|LZ048(X+4)->|LZ048(X+8)
|LZ048(X)->|LZ048(X+4)
0->|LZ048(X)
End
If |LZ048(X+4)!=0 or |LZ048(X)!=0
Then
While |LZ048(X+8)=0
|LZ048(X+4)->|LZ048(X+8)
|LZ048(X)->|LZ048(X+4)
0->|LZ048(X)
End
End
If |LZ048(X)!=0
Then
While |LZ048(X+4)=0
|LZ048(X)->|LZ048(X+4)
0->|LZ048(X)
End
End
If |LZ048(X+12)=|LZ048(X+8) and |LZ048(X+12)!=0
Then
2(|LZ048(X+12))->|LZ048(X+12)
|LZ048(X+4)->|LZ048(X+8)
|LZ048(X)->|LZ048(X+4)
0->|LZ048(X)
End
If |LZ048(X+8)=|LZ048(X+4) and |LZ048(X+8)!=0
Then
2(|LZ048(X+8))->|LZ048(X+8)
|LZ048(X)->|LZ048(X+4)
0->|LZ048(X)
End
If |LZ048(X+4)=|LZ048(X) and |LZ048(X+4)!=0
Then
2(|LZ048(X+4))->|LZ048(X+4)
0->|LZ048(X)
End
End
End
End
End
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement