It is currently Mon Feb 20, 2017 1:31 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Ludum Dare
PostPosted: Wed Dec 21, 2016 11:39 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2770
Location: Tampere, Finland
Deja vu: viewtopic.php?p=155070#p155070

Were you using some kind of a template code to start the project? If so, it might be worth fixing it at the source.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
 Post subject: Re: Ludum Dare
PostPosted: Wed Dec 21, 2016 11:47 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 4757
Location: Canada
While you're in there, make sure you're also doing jsr copydata or equivalent in your startup as well.


Top
 Profile  
 
 Post subject: Re: Ludum Dare
PostPosted: Thu Dec 22, 2016 1:57 am 
Offline

Joined: Sat Oct 15, 2016 8:52 am
Posts: 46
Ha, I would it say it is precisely because I am not using template code that I am not initializing the stack. Consider it fixed at source!

Looking back at all of the C tutorials, I can see that section in there. Adding it in and the comparison works as expected.

Thanks!

Interestingly, even with the stack initialized, making two index comparisons seems to take up more cycles then assigning one half of the comparison to a var and then making the comparison,

Is it considered bad practice for any reason to do this? As it would seem it only costs me a char I can reuse and has a visible performance benefit.

yes i am using jsr copydata as previously recommended, thanks!


Top
 Profile  
 
 Post subject: Re: Ludum Dare
PostPosted: Thu Dec 22, 2016 2:47 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 4757
Location: Canada
Just as a quick check, are you using -O as a compiler flag? With CC65 optimization is recommended even when debugging.

There are lots of unfortunate ways that it might generate worse code one way than another. In particular it seems to have problems keeping efficient track of arrays and pointers, especially with 16-bit indexing. (In general advice: use 8-bit types as much as possible, and use array types rather than pointers when possible.)

Anyhow, presuming you've already got optimization turned on, there are often cases where doing things one way or a trivially different way might result in much better or worse (but functionally equivalent) code. This is just an unfortunate fact about this compiler.

Measure the performance of your code frequently; when it makes something unusually slow it'll be easier to figure it out if you've been checking. Whenever something runs unexpectedly slow, take a peek at the assembly.


Top
 Profile  
 
 Post subject: Re: Ludum Dare
PostPosted: Fri Dec 23, 2016 1:25 am 
Offline

Joined: Sat Oct 15, 2016 8:52 am
Posts: 46
Yes, I'm compiling with the flags O and i.

I've stuck pretty exclusively to 8 bit variables and constants and it seems to be fairly snappy so far.

For any one else using C, I'd highly recommend having a var you can assign to to avoid a direct array to array comparison. Even with only three enemies on the screen, it seems to be saving a good chunk of cycles. Which, ironically, seems to be because it avoids the C stack.

Thanks for all of the help!


Top
 Profile  
 
 Post subject: Re: Ludum Dare
PostPosted: Fri Jan 06, 2017 11:28 am 
Offline
User avatar

Joined: Sat Jun 29, 2013 4:36 am
Posts: 25
team_disposable wrote:
Is there anything in it you where interested in?


I'm just a noob hoping to someday bang out a working nes game and trying to absorb as much source as possible.

Many thanks for your code explanation!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group