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.dougeff wrote:Passing arguments to functions is incredibly slow for the 6502.
Limitiation or compromise if write program in c
Moderator: Moderators
Re: Limitiation or compromise if write program in c
http://WilsonMinesCo.com/ lots of 6502 resources
Re: Limitiation or compromise if write program in c
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.
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.
Re: Limitiation or compromise if write program in c
Got it.
http://WilsonMinesCo.com/ lots of 6502 resources
Re: Limitiation or compromise if write program in c
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
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
Re: Limitiation or compromise if write program in c
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).DRW wrote: Something like "Nekketsu Kakutou Densetsu"?
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.
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.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
Re: Limitiation or compromise if write program in c
Here's a hint: Mark the function name with the highest number of variable that is used.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
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.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Re: Limitiation or compromise if write program in c
@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.
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.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
Re: Limitiation or compromise if write program in c
Now that's a great idea, thanks. I'll try and come up with a nomenclature for my next project.DRW wrote:Here's a hint: Mark the function name with the highest number of variable that is used.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
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.
Re: Limitiation or compromise if write program in c
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.dougeff wrote:cc65 command line directive --add-sourceHow do you debug the C code of an NES game?
https://github.com/dustmop/annotatecc65
Re: Limitiation or compromise if write program in c
How come I didn't know this? This will come extremely handy, thanks!
Re: Limitiation or compromise if write program in c
Cool! Welcome! If you have any questions or issues please feel free to DM me or file a github issue.na_th_an wrote:This will come extremely handy, thanks!
Re: Limitiation or compromise if write program in c
nice!
nesdoug.com -- blog/tutorial on programming for the NES
Re: Limitiation or compromise if write program in c
All I have to say is that I used it today and it was bliss. Great job!
- GradualGames
- Posts: 1106
- Joined: Sun Nov 09, 2008 9:18 pm
- Location: Pennsylvania, USA
- Contact:
Re: Limitiation or compromise if write program in c
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.
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.
Re: Limitiation or compromise if write program in c
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