It is currently Tue Feb 20, 2018 12:59 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Mon Jan 01, 2018 5:50 pm 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 100
Location: Southern California
dougeff wrote:
Passing arguments to functions is incredibly slow for the 6502.

In what way did you have in mind? I cover parameter-passing via stacks in chapter 6 of the 6502 stacks treatise. The efficiency shows through more in the listings for recursive functions in chapter 15.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


Top
 Profile  
 
PostPosted: Mon Jan 01, 2018 5:57 pm 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6788
Location: Seattle
Unfortunately, we're talking about the default cc65 software stack.

Everything that's not explicitly global, static, or {local and compiled with --static-locals} gets put on the stack, and when every single variable involves stack manipulation it's an awful lot of added computational overhead.


Top
 Profile  
 
PostPosted: Mon Jan 01, 2018 6:11 pm 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 100
Location: Southern California
Got it.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 12:31 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 401
If you really need functions with parameters so your code is less of a mess, and you can afford a bit of overhead, have a set of multi-purpose global variables (and be careful ;) ) and copy the parameters to the globals at the beginning of your function.

Anyways, I have a set of multi-purpose global variables and 75% of the "strange bugs" I spend hours fetching have to do with it :lol: :lol: :lol: :lol:

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 6:32 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1528
Location: Fukuoka, Japan
DRW wrote:
Something like "Nekketsu Kakutou Densetsu"?


I like Kunio games but this was not what I had in mind. I want the game to be fast, no dept in the screen so you have to move from platform to platform very fast and attack the other player(s).

I did a quick search to try to find back the screenshot that inspired the idea and I think it was the game Towerfall on the ouya. I only saw a screenshot of (maybe) that game and I like the limited scope of the screen but I'm not sure if this is exactly what I had in mind since I never saw the gameplay so it may be similar.

I want to create characters with different skill set (strengths, speed, range, size etc) that can battle in a limited stage. Some passage would allow you to go from top to bottom (or left to right depending of the stage selected), there would be traps, part that help you move faster etc. You can kick-jump on wall to go higher, use the environment to move or attack, etc. That could be a good small project to create a code base for bigger projects.

Now that there is a windows version of towerfall (didn't know about that) I may give it a try and look at some of the video online and check if this is what I had in mind or not.

na_th_an wrote:
Anyways, I have a set of multi-purpose global variables and 75% of the "strange bugs" I spend hours fetching have to do with it :lol: :lol: :lol: :lol:


I remember that trying parameters that way in assembler too many bugs came out because of that. I guess I will to figure out the balance of usability and how buggy it may become because of such feature.


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 7:04 am 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1570
na_th_an wrote:
Anyways, I have a set of multi-purpose global variables and 75% of the "strange bugs" I spend hours fetching have to do with it :lol: :lol: :lol: :lol:

Here's a hint: Mark the function name with the highest number of variable that is used.

If you use var1, var2 and var3 in the function, call your function MyFunction_var3.
This way, any function that calls MyFunction_var3 knows that it shouldn't use var1, var2 and var3 if it wants those values to remain consistent before and after the function call.

Of course, this also counts for outer functions. If MyOtherFunction doesn't use any variables itself, but calls MyFunction_var3, then of course you have to rename it MyOtherFunction_var3 so that any code that calls this function knows that var1, var2 and var3 are used somewhere inside.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 7:10 am 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1570
@Banshaku:

O.k., so in this case, you first have to write a general platformer engine and then a way for the characters to attack each other.

Advantage: You can use the same basic engine to program a platform fighting game and also a common sidescroller jump'n'run.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 2:45 pm 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 401
DRW wrote:
na_th_an wrote:
Anyways, I have a set of multi-purpose global variables and 75% of the "strange bugs" I spend hours fetching have to do with it :lol: :lol: :lol: :lol:

Here's a hint: Mark the function name with the highest number of variable that is used.

If you use var1, var2 and var3 in the function, call your function MyFunction_var3.
This way, any function that calls MyFunction_var3 knows that it shouldn't use var1, var2 and var3 if it wants those values to remain consistent before and after the function call.

Of course, this also counts for outer functions. If MyOtherFunction doesn't use any variables itself, but calls MyFunction_var3, then of course you have to rename it MyOtherFunction_var3 so that any code that calls this function knows that var1, var2 and var3 are used somewhere inside.


Now that's a great idea, thanks. I'll try and come up with a nomenclature for my next project.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 4:18 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 133
dougeff wrote:
Quote:
How do you debug the C code of an NES game?

cc65 command line directive --add-source


I built a tool on top of this, called annotatecc65, that adds the original C source into FCEUX's debugger, which makes debugging very straight-forward. I'm interested if anyone has tried it out and found it useful.

https://github.com/dustmop/annotatecc65


Top
 Profile  
 
PostPosted: Tue Jan 02, 2018 4:21 pm 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 401
How come I didn't know this? This will come extremely handy, thanks!

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Wed Jan 03, 2018 2:38 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 133
na_th_an wrote:
This will come extremely handy, thanks!


Cool! Welcome! If you have any questions or issues please feel free to DM me or file a github issue.


Top
 Profile  
 
PostPosted: Wed Jan 03, 2018 3:38 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1957
Location: DIGDUG
nice!

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Jan 03, 2018 3:55 pm 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 401
All I have to say is that I used it today and it was bliss. Great job!

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Wed Jan 10, 2018 8:25 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1073
Location: Pennsylvania, USA
I made an earnest attempt over a 3 month period to adapt to C in early 2016 or so, for my current project. While I can imagine smarter folks benefiting from it, I just couldn't get used to it. I had too many weird problems I didn't know how to solve. Either something with syntax, or I didn't understand whether something allocated ram or rom, or I just had to bastardize the C language so horribly and mangle it beyond comprehension I might as well be coding in asm anyway. And finally, I attempted to write a metasprite routine in C, and drawing a large 18 sprite metasprite took a frame and a half. Rewriting the same routine in assembly and drawing the same large sprite took about 1/10th of a frame. Obviously nobody would write a metasprite routine in C to begin with, but that difference in speed was so alarming I became afraid that I would run into performance issues way more often than I'd like if I adopted C. I'm also terrible at reading code and if there's ever a problem, I really didn't want to pore over the code cc65 generates...OH! And things like sub pixel precision, like 8.8 velocities added on 8.8.8 coordinates? That comes out so naturally in asm. The pointer math or other workarounds one must do in C are rather unpleasant.

The bottom line for me though is the "feeling" of coding in assembly just makes me happier, period. Totally irrational, perhaps, but that's a good enough reason for a hobby where nothing matters but whether one is happy anyway.

Use what you like, not trying to discourage anyone from using C, I think it's really awesome it's being used so well by many excellent fellow homebrew devs.


Top
 Profile  
 
PostPosted: Wed Jan 10, 2018 8:44 pm 
Offline

Joined: Wed Nov 30, 2016 4:45 pm
Posts: 100
Location: Southern California
GradualGames, I had those problems and a lot more. I have partly come to the opinion that even for intelligent people, which programming language approach works best for a person depends partly on what kind of brain they're born with. For me, Forth was a natural. My enjoyment of assembly has also increased in recent years as I have done more to raise the level of the language, using macros to make nestable program structures. I really cannot understand how anyone could go for C.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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