This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Your Projects subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Project Ideas/Start New Projects => Your Projects
Author Message
Rhynomite


Member


Joined: 08 Oct 2005
Posts: 122

Posted: 09 Dec 2005 08:16:10 pm    Post subject:

Okay, I have finally decided to start my first project, Pong-off (tournament). As of today, the title screen is all that is complete. I suck at every language I know, so I will probably need some help.

The demo is below (requires omnicalc). Yes I know the flashing title screen is pretty sad, but future improvements will be made. Any suggestions?
----------------
My code is very inefficient- could use an optimizer.
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 09 Dec 2005 08:27:25 pm    Post subject:

[quote name='"BASIC Code"']::"Pongoff V0.2
:Lbl 1
:ClrDraw
:20P
:94Xmax
:0Xmin
:62YMax
:0Ymin
:62X
:Lbl 2
:If X=(-)1
:Then
:StorePic 3
:Goto 3
:End
:Horizontal(X
:X-1X
:Goto 2
:Lbl 3
:real(20,2,8,0,8,8,28,0,0
:For(A,0,50
:End
:real(20,2,16,0,8,8,33,0,0
:For(A,0,50
:End
:real(20,2,24,0,8,8,38,0,0
:For(A,0,50
:End
:real(20,2,32,0,8,8,43,0,0
:For(A,0,50
:End
:real(20,2,16,0,8,8,53,0,0
:For(A,0,50
:End
:real(20,2,40,0,8,8,58,0,0
:For(A,0,50
:End
:real(20,2,40,0,8,8,63,0,0
:For(A,0,50
:End
:Lbl 4
:RecallPic 3
:For(A,0,500
:End
:real(20,2,8,0,8,8,28,0,0
:real(20,2,16,0,8,8,33,0,0
:real(20,2,24,0,8,8,38,0,0
:real(20,2,32,0,8,8,43,0,0
:real(20,2,16,0,8,8,53,0,0
:real(20,2,40,0,8,8,58,0,0
:real(20,2,40,0,8,8,63,0,0
:For(A,0,500
:End
:getKeyK
:If K=105 or K=21
:Goto 5
:Goto 4
:Lbl 5
:real(20,2,16,8,80,8,11,20,0
:real(20,2,16,16,32,8,34,35,0
:real(20,2,16,24,24,8,39,50,0
:real(20,2,8,8,8,16,1,P
:real(20,2,8,8,8,16,89,P
I
:Lbl 6
:DecI)T
:If T60
:real(33,"3E01D303C9
:getKeyK
:If K=45
:Then
:Disp
:Stop
:End
:If K=25
:Then
:If P20
:Goto 6
:real(20,2,8,8,8,16,1,P,2
:real(20,2,8,8,8,16,89,P,2
:p-15P
:real(20,2,8,8,8,16,1,P,0
:real(20,2,8,8,8,16,89,P,0
:End
:If K=34
:Then
:If P50
:Goto 6
:real(20,2,8,8,8,16,1,P,2
:real(20,2,8,8,8,16,89,P,2
:p+15P
:real(20,2,8,8,8,16,1,P,0
:real(20,2,8,8,8,16,89,P,0
:End
:If K=21 or K=105
:Then
:If P=50
:Then
:Disp
:Stop
:End
:If P=35
:Then
:ClrHome
:Disp "****************
:Disp "
:Disp "    Coding by
:Disp " Ryan Pruitt of
:Disp " United TI.
:Disp "
:Disp "****************
:Pause
:Disp "
:Disp "****************
:Disp "
:Disp " With help from
:Disp " the UTI team!!
:Disp "
:Disp "****************
:Pause
:DispG
:End
:If P=20
:Goto 7
:End
:Goto 6
:Lbl 7
:ClrHome
:Disp "Gameplay is not","yet complete...
:For(A,0,500
:End
:Disp "
:Disp "I'm working on","it as fast as I","can!
:Pause
:DispG
:
Generated by SourceCoder, © 2005 Cemetech[/quote]


Run it through SourceCoder


Last edited by Guest on 09 Dec 2005 08:28:15 pm; edited 1 time in total
Back to top
Rhynomite


Member


Joined: 08 Oct 2005
Posts: 122

Posted: 09 Dec 2005 09:05:56 pm    Post subject:

Useful.

I was in dire need of an optimization!


Last edited by Guest on 09 Dec 2005 09:08:27 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 09 Dec 2005 09:37:27 pm    Post subject:

There's something not quite right with that code (several things, in fact). No offense intended, but if this is how a simple program will turn out with each pass, I should refrain from using SourceCoder until these kinks are worked out of it.

Plus, I would hardly call this code optimized. For one, replace the [font="courier new"]For()
loops with [font="courier new"]rand(3. [font="courier new"]If K=105 or K=21 converts to [font="courier new"]If 42=abs(K-63. Begin learning how to use other looping functions so [font="courier new"]Lbl/[font="courier new"]Goto doesn't become as much of a hassle. In reality, they shouldn't even be placed inside conditional statements anyway! If you've ever heard of memory leaks being caused in Basic programs, this is what starts them.

I'd work on this more, but I haven't the time right now. Sorry for being such a negative person tonight. Sad
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 09 Dec 2005 09:48:59 pm    Post subject:

heeeheeee...I noticed that
Back to top
kalan_vod


Advanced Member


Joined: 04 Sep 2005
Posts: 446

Posted: 09 Dec 2005 11:24:35 pm    Post subject:

A suggestion: you could use xLIB, as it will do what omnicalc would and then some (concerning graphics).
Back to top
Rhynomite


Member


Joined: 08 Oct 2005
Posts: 122

Posted: 10 Dec 2005 12:54:13 pm    Post subject:

Although I've been programming basic for a few years, I guess I never really learned how to write efficient code. I just always tend to write everything out the long way.
I also realized that I should probably finish the project first before optimizations are made. That way I won't have to write code, get it optimized, repeat over and over until project is finished...
Anyway, I've deleted and modified the code so the program looks better and is a little smaller. Now I'll have to start working on the main gameplay.

@kalan_vod:
I haven't used xlib before, I suppose I should start using it. I'll look into that tonight.
Back to top
Radical Pi


Advanced Member


Joined: 23 Nov 2005
Posts: 455

Posted: 11 Dec 2005 02:20:11 pm    Post subject:

This looks good, but needs to be optimized alot.
1. Eliminate the lowercase letters. They use alot more memory than their capital counterparts.
2. Put Disps on the same line:

Code:
:Disp "****************"," ","    CODING BY"," RYAN PRUITT OF","  UNITED TI."," ","****************

3. Turn Lbl 3 into some type of For loop containing all the sprite placements until Lbl 4.

Code:
:For(A,1,7
:If A=1:real(20,2,8,0,8,8,28,0,0
:If A=2:real(20,2,16,0,8,8,33,0,0
:If A=3:real(20,2,24,0,8,8,38,0,0
:If A=4:real(20,2,32,0,8,8,43,0,0
:If A=5:real(20,2,16,0,8,8,53,0,0
:If A=6:real(20,2,40,0,8,8,58,0,0
:If A=7:real(20,2,40,0,8,8,63,0,0
:For(A,0,50
:End
:End


I'm sure you could do alot more than my sloppy 2 minute optimizations.
Back to top
Radical Pi


Advanced Member


Joined: 23 Nov 2005
Posts: 455

Posted: 11 Dec 2005 04:01:46 pm    Post subject:

NOOOOOOO!!!
You can put all the Disps on one line separated by commas.

Wow, the original code just gave me a 9KB memory leak. I just archived everything and reset, but is there an easier way to regain leaked memory?
Back to top
Radical Pi


Advanced Member


Joined: 23 Nov 2005
Posts: 455

Posted: 11 Dec 2005 04:12:54 pm    Post subject:

Hmm
I thought it saved memory. Smile
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 11 Dec 2005 04:15:55 pm    Post subject:

I realized I was using sourcecoder 1 :blush: sourcecoder 2 is here


..try running it through again :)


EDIT:
====
Link fixed, our keyboard is being screwed up


Last edited by Guest on 11 Dec 2005 04:37:25 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 11 Dec 2005 04:23:34 pm    Post subject:

Radical Pi, the maximum memory leak from improperly nested [font="courier new"]Goto's amounts to 128 bytes. Smile
Since this program makes no use of lists or matrices, I'm thinking the problem lies elsewhere...

elfprince13, check the link. :P

[EDIT]

Kerm Martian, my apologies—the SourceCoder rendering is fine.
The actual errors ([font="courier new"]º→I, [font="courier new"]►DecI)→T) are within the program itself.

Last edited by Guest on 11 Dec 2005 04:37:12 pm; edited 1 time in total
Back to top
Radical Pi


Advanced Member


Joined: 23 Nov 2005
Posts: 455

Posted: 11 Dec 2005 05:20:14 pm    Post subject:

Well, I think I had over 20000 bytes before I downloaded and tested the program. Then I ran the demo, posted about some optimizations, and went to delete it. That's when I saw I was missing half my RAM.
I'm pretty sure it was this.

*please note that I didn't say 100% sure, things like this happen alot to me
Back to top
Rhynomite


Member


Joined: 08 Oct 2005
Posts: 122

Posted: 12 Dec 2005 05:09:43 pm    Post subject:

Thanks to a RAM clear, I lost the little additions I have been making since the demo. Oh well, my code wasn't doing so well anyway because basic is too slow. I'm seriously considering using the Basic to Assembler utility (that is, if it even works) to speed up the thing, because when I moved the paddle, it couldn't possibly be fast enough for the game (yes, I tried increasing the number of pixels moved, but that didn't help much and made the paddle move less smoothly).

Last edited by Guest on 12 Dec 2005 05:10:54 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 12 Dec 2005 05:20:09 pm    Post subject:

The Basic to Assembler utility probably works but probably doesn't help with speed; also, it should be incompatible with Omnicalc. I would suggest trying to optimize the code.
Back to top
kermmartian
Site Admin Kemetech


Calc Guru


Joined: 20 Mar 2004
Posts: 1220

Posted: 12 Dec 2005 06:31:57 pm    Post subject:

PLEASe USE SOURCECODER2!! I should link it...
http://www.cemetech.net/projects/basicelite/sourcecoder2.php
Back to top
Rhynomite


Member


Joined: 08 Oct 2005
Posts: 122

Posted: 12 Dec 2005 09:33:44 pm    Post subject:

Impressive...11.1% optimization...although it removed the quotation marks from all the Disp "s, and that causes the program to display the homescreen without actually writing a blank line (which is what I want).
Besides optimizations, I probably will need another way to speed up the program if I am ever to get it up to a decent framerate. I also should have realized that there was no way basic to assembler would be compatible with Omnicalc.
Any speed-related suggestions?
Back to top
Vinthian
formerly known as shortround4271


Advanced Member


Joined: 24 May 2005
Posts: 258

Posted: 12 Dec 2005 09:39:01 pm    Post subject:

try to get rid of your labels somehow, just rewrite the code's structure, it helped me a lot on re-writing my 2000 byte TTT game into a 700 byte TTT game that ran much faster with less memory. also helped me in optimizing bryan's connect4 game, which iwas slow, and increase its speed, a lot.
Back to top
elfprince13
Retired


Super Elite (Last Title)


Joined: 11 Apr 2005
Posts: 3500

Posted: 12 Dec 2005 09:45:09 pm    Post subject:

elfprince13 wrote:
I realized I was using sourcecoder 1  :blush: sourcecoder 2 is here


..try running it through again :)


EDIT:
====
Link fixed, our keyboard is being screwed up
[post="64078"]<{POST_SNAPBACK}>[/post]



kermmartian wrote:
PLEASe USE SOURCECODER2!! I should link it...
http://www.cemetech.net/projects/basicelite/sourcecoder2.php
[post="64235"]<{POST_SNAPBACK}>[/post]


??????????
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 12 Dec 2005 09:46:33 pm    Post subject:

It really does come down to coding structure—optimization comes second. Every time the interpreter is faced with
a [font="courier new"]Goto
, the only way it knows how to handle it is by searching the entire program from top to bottom, line by line!
Back to top
Display posts from previous:   
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement