Search found 1913 matches

by DRW
Sun Nov 24, 2019 6:51 am
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

Ok you are right. They will all expand at the same time and the same way. Not sure if this is supposed to be sarcasm, but in case it is, I'll repeat the gist of it one last time: No, macros won't always expand in the same way . But they will always expand at the same time : Always when they are cal...
by DRW
Sat Nov 23, 2019 11:56 am
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

the argument tokens are examined for macro calls, and expanded as necessary, just before insertion This is what you are seeing and what you would expect.. however the bit of text before it Unless the parameter in there placement sequence is preceded by #, or preceded or followed by ##, which is wha...
by DRW
Sat Nov 23, 2019 4:52 am
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

Your new example does have undefine which as noted in my post is needed. But going by the example as posted this is technically illigal. as you can't #define CurrentPostfix A #define CurrentPostfix B without an undefine in between. Well, yes in this context I do have an undefine. However: This unde...
by DRW
Fri Nov 22, 2019 4:27 am
Forum: General Stuff
Topic: NESMaker reviews?
Replies: 50
Views: 10298

Re: NESMaker reviews?

And yeah, he used the community with a super positive attitude, charging a considerably high amount of money to build a tool for a very niche market (where tools are traditionally released for free), and once the tool is done (or far from it) -surprise- he adds DRM to it to protect it? Doesn't he w...
by DRW
Fri Nov 22, 2019 3:58 am
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

What you want is basically illegal. You can not redefine a preprocessor value again, it should give you an error. I don't really want to redefine a preprocessor value, I want the macro to put together the correct name. And the thing that I do works with every compiler I tried out, including that we...
by DRW
Sun Nov 17, 2019 4:20 am
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

Thanks for your information. I did it like this now: #define DefNameX_(name1, name2, name3, name4, name5, name6)\ name1##name2##name3##name4##name5##name6 #define DefName6(name1, name2, name3, name4, name5, name6)\ DefNameX_(name1, name2, name3, name4, name5, name6) ... #define DefName2(name1, name2...
by DRW
Thu Nov 14, 2019 7:13 pm
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Re: Putting together variable names with macros in cc65

I'm a little bit confused by your post, but isn't this enough? #define DECLARE_NUMBER_WITH_POSTFIX(postfix) \ int Number##postfix DECLARE_NUMBER_WITH_POSTFIX(A); The idea is that you don't simply write the postfix, but that the postfix is the value inside another macro. This is what I want: #define...
by DRW
Mon Nov 11, 2019 3:22 am
Forum: General Stuff
Topic: NESMaker reviews?
Replies: 50
Views: 10298

Re: NESMaker reviews?

Thanks for the detailed review. This is pretty much what I would have expected from this tool. After all, it was invented by someone - with no prior programming knowledge - who tried a "Zelda"-like game as his first ever attempt - who never finished this project and who now claims that his little de...
by DRW
Fri Nov 08, 2019 10:22 pm
Forum: NESdev
Topic: Putting together variable names with macros in cc65
Replies: 15
Views: 2944

Putting together variable names with macros in cc65

I have some C source code (in cc65) where I connect variable names by macros: #define DECLARE_NUMBER_WITH_POSTFIX()\ int Number##CurrentPostfix #define CurrentPostfix A DECLARE_NUMBER_WITH_POSTFIX(); void Function(void) { NumberA = 1; } The problem is: In this case, the variable is still called Numb...
by DRW
Tue Sep 10, 2019 1:37 am
Forum: NESdev
Topic: Fast 2D Array access in C (with inline Assembly?)
Replies: 3
Views: 4140

Re: Fast 2D Array access in C (with inline Assembly?)

I would only use one-dimensional arrays for NES programming. This makes it clearer what's going on below. The advantage that a two-dimensional array only has single-byte indices is not really an advantage. Because for the compiler, it's all just one long stripe of data. (No, a two-dimensional array ...
by DRW
Tue Sep 10, 2019 1:21 am
Forum: NESdev
Topic: How can I benchmark my C code?
Replies: 17
Views: 9937

Re: How can I benchmark my C code?

Getting rid of function parameters and return values resulted in a huge speed boost. Return values actually shouldn't be an issue. Unlike function parameters, they aren't on the stack, but are saved in A (low byte) and X (high byte). (Only if you return a long is the stack used as well.) So, writin...
by DRW
Mon Sep 09, 2019 12:54 am
Forum: NESdev
Topic: How can I benchmark my C code?
Replies: 17
Views: 9937

Re: How can I benchmark my C code?

The first performance improvements can be done without having to dig into pure Assembly: Use unsigned char as a type whenever possible. int is mostly a waste. This is true for regular variables as well as for array indices. I.e. make sure that your arrays have mostly no more than 255 entries. (I wou...
by DRW
Sun Sep 08, 2019 4:47 am
Forum: NESdev
Topic: How can I benchmark my C code?
Replies: 17
Views: 9937

Re: How can I benchmark my C code?

As far as I'm aware, you cannot just read from PPUMASK (i.e. 0x2001). On the NES, it's a write-only address. So, you should save the value that you originally set to PPUMASK in a variable. (Or, since the value will probably not change throughout the game, in a constant/macro.) And then you write the...
by DRW
Fri Sep 06, 2019 4:35 pm
Forum: NESdev
Topic: How can I benchmark my C code?
Replies: 17
Views: 9937

Re: How can I benchmark my C code?

Indeed, playing around with the frame count doesn't help you much and the NES doesn't have an internal time value as far as I know. As gauauu suggested, the easiest way to see how much time a specific code requires is indeed the PPUMASK bit setting. Let me explain it a bit more in detail: The PPUMAS...
by DRW
Sat Aug 31, 2019 5:26 pm
Forum: NES Music
Topic: Error in the latest version of FamiTone2?
Replies: 5
Views: 3044

Re: Error in the latest version of FamiTone2?

Well, the information that there's another version out there doesn't clear up the question whether the current official FamiTone2 from shiru's website is actually buggy or whether I did something wrong or what's up here. Also, I already said that the previous version of the official FamiTone2 works ...