[Staff][Beta] Pure TI-le

Here you can find side projects of the staff and great projects which we think should get extra support. (Note that featured projects are not projects by staff members of MaxCoderz)

Moderator: MaxCoderz Staff

necro
Calc King
Posts: 1619
Joined: Sat 26 Mar, 2005 2:45 am
Location: your shadow

Post by necro »

Ok...I dont get it:
When you walk, does it not check that tile so as to prevent you from walking through a wall? If so, couldn't you check if it's a person or a door or such?
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

Right now doors can be walked onto but the next release won't allow that, and stairs you can walk onto. If I had a ladder, or a switch, or whatnot, they'd all react differently, and a wall is not likely to be an event, but if I always, always, always checked for an event, I'd have to go through all of the events in the entire game every time the character moved, which would cause him to move extremely slow. Just because something is solid doesn't mean theres an event associated with it.

If I did a collision check AND a special tile check, I'd have to collision check, check for the special tiles, and THEN do event checking. Does that not sound immensely slow? If you still don't get it then I can't explain it to you..
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
JavaMan
New Member
Posts: 19
Joined: Thu 09 Feb, 2006 10:00 pm

Post by JavaMan »

DarkAuron,

To increase the speed of your tile map engine, you should make use of labels and gotos. For example, in your case your program calls TileData which triggers certain tiles. Within the if statements you have in there, make it goto a label that returns to the program. What's happening right now is, if T = 1 and it finishes drawing the tile, the program still executes the other ifs. You should directly goto a label that returns after you finish drawing a tile.
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

I thought BASIC would be slow if it did that?

Welcome to the forums JavaMan!! I'm assuming from your user name that you are a master of Java of some sorts?
Image Image Image
merthsoft
Extreme Poster
Posts: 496
Joined: Tue 21 Dec, 2004 6:49 am
Location: WI

Post by merthsoft »

It causes a memory leak, if I remeber this topic correctly...
Shaun
JavaMan
New Member
Posts: 19
Joined: Thu 09 Feb, 2006 10:00 pm

Post by JavaMan »

I can't say I'm an expert at Java, but you can ask me if you have any coding issues with it.

And hopefully I'll contribute to the forums. :)

Btw. Where is the irc channel for maxcoderz?
Last edited by JavaMan on Thu 09 Feb, 2006 10:13 pm, edited 1 time in total.
Liazon
Calc Guru
Posts: 962
Joined: Thu 27 Oct, 2005 8:28 pm

Post by Liazon »

It's not memory leaks, it's just that in TI-BASIC, it has to reset the program counter and look for the label from the very beginning of the program. Very bad for large programs.
Image Image Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

If you have a goto in a loop then it will produce a memory leak. Ex. If A=12:then:9->A:Goto 2:End. That will produce a memory leak. Also if you use Gotos or Labels they will make it really slow.
DA it sounds fine the way you are doing it, can't wait to try the newer version!
JavaMan
New Member
Posts: 19
Joined: Thu 09 Feb, 2006 10:00 pm

Post by JavaMan »

Right now the size of DarkAuron code for the TileData is not that large, so memory leaks will not happen.

Labels do not make the program run slower. It's the complete opposite. I've tested with this before. When you are done drawing that tile, the program still goes through your code and checks for those ifs. Goto goes straight to a point in the program which saves some time. :)
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

JavaMan wrote:Right now the size of DarkAuron code for the TileData is not that large, so memory leaks will not happen.

Labels do not make the program run slower. It's the complete opposite. I've tested with this before. When you are done drawing that tile, the program still goes through your code and checks for those ifs. Goto goes straight to a point in the program which saves some time. :)
I am unsure how to say this but you can't be any more wrong....Lbls search from the top of the program to the bottom, so it will be a lot slower...
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

I appreciate you guys trying to help out, but don't start a flamefest :P

Yes, I could theoretically use labels to jump but only if I used them outside of blocks (otherwise I'd slow down the OS until it crashes with a stack overflow, which will be an ERR:MEMORY or sometimes even a RAM clear), and even if I used a label to jump to the end of the program, the later tiles would still have to scan until the end of the program before they get drawn anyways; this way the tiles all draw at roughly the same speed. Plus to jump I'd have to make another if statement after every single tile, thus doubling all the checks, and that's just plain slow.

So really, I do appreciate your suggestions, but those recommendations won't help. I've thought about this, and I've also tested these things with my other programs before. :roll: The only way I could speed this up is if I split up the tiles into multiple programs, like 4 of them. But I havn't got that many tiles yet. *shrug*

If you don't believe me when I say it crashes if you jump outside a block, try this program:

Code: Select all

1->A:Lbl 1
If A:Then
Disp A:A+1->A
Goto 1:End
I only managed to get to 592. :) And considering I draw 63 tiles per screen, I'd get to a memory error pretty quick. It uses up 40 bytes every time; why exactly it uses up that much I'm not sure, but I've calculated it out on both my calculators and it's basically eating up 40 bytes of RAM every time it starts a new block.

Also, it gets to the error even quicker if you jump out of nested blocks. I ended up having that problem in irp!-gee whenever I needed to redraw the screen. 'twas horrible. Labels should rarely be used because often you can optimize your loops better to do the same thing. I did, however, use labels in the map editor to optimize for size using binary logic.

Now.. labels don't necessarily slow it down if I use javaman's logic. Say for example, I did this:

Goto 2
Label 1
Return
Label 2

If T=0:Then
<Draw stuff>
1->L:End
If L:Goto 1

If T=1:Then
<Draw stuff>
1->L:End
If L:Goto 1

If T=2:Then
<Draw stuff>
1->L:End
If L:Goto 1

If T=3:Then
<Draw stuff>
1->L:End
If L:Goto 1

If T=4:Then
<Draw stuff>
1->L:End
If L:Goto 1

...
...

If T=24:Then
<Draw stuff>
1->L:End
If L:Goto 1

However, see all those bolded lines? Those are extra checks, and by the time I get to tile 30 or so, I'd have 29 ADDITIONAL checks beforehand, not to mention all the If T= checks before, so I'm essentially doubling the checks, plus I'm having to scan through *more* bytes when I have 1->L and If L:Goto 1. It's just daunting, and in the end that's a lot slower. So I do appreciate the concerns, but.. basically you're all wrong in some way. :lol:

However if you'd like to suggest features for the engine, I'm all for that.
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Well DA, you explained it very well :D. Yeah using the extra checks wouldn't be worth it.
JavaMan
New Member
Posts: 19
Joined: Thu 09 Feb, 2006 10:00 pm

Post by JavaMan »

I was thinking more like this:

Code: Select all

If T=0:Then
<Draw stuff>
Goto QQ:End

If T=1:Then
<Draw stuff>
Goto QQ:End

If T=2:Then
<Draw stuff>
Goto QQ:End

If T=...:Then
<Draw stuff>
Goto QQ:End

Lbl QQ
Return
End
Also, tell me the place of your irc channel. :)
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

That would cause memory leaks.

It's on efnet's sever, and it's #tcpa
DarkAuron
Maxcoderz Staff
Posts: 1349
Joined: Sat 18 Dec, 2004 6:53 pm

Post by DarkAuron »

1. You're jumping out of the block (before the End), which will eventually use up the RAM and crash
2. Having your label and Return at the end is slowest, because TI-BASIC doesn't store the labels in a lookup table, they do as kalan said: they scan from the beginning of the program until it can find it (or not find it and crash)
3. Having the End at the very end of the program is completely useless.
4. If you were to put End before the Return, you'd get a syntax error because TI-BASIC for the 83, 83+(SE), and 84+(SE) calcs do syntax checking.

So really, your logic can't and won't work. TI-BASIC is almost nothing like Java.
[Gridwars Score] - E: 1860037 M: 716641 H: 261194
Post Reply