Hope some newbie can benefit from this
Contributions, criticism and ideas are welcome!
http://tachdaun.com.ar/rnes/rNES-0.1.zip


Moderator: Moderators


Fx3 wrote:- My emu displays wrong colors:
OH! now that I see your screenshot, your emulator shows the first and last rows of tiles...Fx3 wrote:
Thanks!Banshaku wrote:It's good to see some effort done for the C version of CC65...Good work!
Thanks! Good advice, I'll give it a lookBregalad wrote:Looks promising. However you should learn some assembly. Also I'd have to go to GBA dev seeing how they do games in C, and maybe try to do similar libraries for the NES, so that they are suitable for game use.
He is the author of RockNES, so he probably meant the lastest version.Petruza wrote:What emulator and version is it?
You should configure your emulator like this when developing too. Not being able to see many scanlines can easily make you miss errors, like in this case.OH! now that I see your screenshot, your emulator shows the first and last rows of tiles...
Yeah, that's the correct way to hide unused sprites. For better performance, you don't even have to clear the whole page, simply setting the Y coordinates to $F0 or more will hide them, you don't even have to touch the other bytes, so don't waste precious CPU time with that.I should make them all off-screen.
Oh, that was he meant by "My" emu. =Dtokumaru wrote:He is the author of RockNES, so he probably meant the lastest version.
Very true.tokumaru wrote:Yeah, that's the correct way to hide unused sprites. For better performance, you don't even have to clear the whole page, simply setting the Y coordinates to $F0 or more will hide them, you don't even have to touch the other bytes, so don't waste precious CPU time with that.
Yes, it's strange, my progs run perfectly on FCEUXD but not at all on FCEUX.Fx3 wrote:- Probably a bug in my emulator (RockNES), I still need to trace the code. Well, it works on Nintendulator and Nestopia, but not on FCEUX.
Well, it has to be something with the background pallete. And one pallete only, because the two other palletes are just like the other emus.Fx3 wrote: EDIT: hmm, it's buggy from beta 8, works fine on beta <= 7... Interesting.
Code: Select all
/* Compile error if a has too many bits or any are not 0 or 1.
Always evaluates to 0. */
#define BIN8_VALID_(a) (0 * sizeof (char [(01##a & 0111111111) == 01##a]))
#define BIN8_(n) ((n & 0x01) |\
(n >> 2 & 0x02) |\
(n >> 4 & 0x04) |\
(n >> 6 & 0x08) |\
(n >> 8 & 0x10) |\
(n >> 10 & 0x20) |\
(n >> 12 & 0x40) |\
(n >> 14 & 0x80))
#define BIN8(a) (BIN8_( 0##a ) + BIN8_VALID_( a ))ooops, never actually tested 2nd controllerblargg wrote:Some things that I noticed:
- rNES_get_joy: both controllers are strobed by $4016; $4017 controls the APU. Also, you could accept the joypad selector as an enumeration, for better type-safety. But it makes more sense to me to select it as an index, 0 or 1.
Sorry, I don't get it. "near the end" of what?- rNES_waitvblank() should read rNES_PPU_status once before the loop, in case you're already in vblank. Without this clearing, if you were already in vblank right near the end, rNES_waitvblank() wouldn't delay and your code might run outside it unexpectedly. Also, there's no reason to make this a macro, as efficiency isn't an issue for a routine that waits for something in a loop.
Don't have any idea. I'll check.- times2: does cc65 really not optimize n*2 to n+n, n*4 to n<<2, etc.?
Never heard of that, do you mean the empty parenthesis mean the function can accept any number and type of arguments??- In C, "void rNES_init();" declares a function that can accept any arguments. Better to make it "void rNES_init( void );"
- Why do many of the files have lots of newlines at the end?
Wow that was twisted.- For your bin macro, you could use this instead, which is easier to use and does checking:Examples: BIN8(10000000) = 0x80. BIN8(100) = 7, BIN8(100000000) is error (too many bits), BIN8(200) is error (invalid bit).Code: Select all
/* Compile error if a has too many bits or any are not 0 or 1. Always evaluates to 0. */ #define BIN8_VALID_(a) (0 * sizeof (char [(01##a & 0111111111) == 01##a])) #define BIN8_(n) ((n & 0x01) |\ (n >> 2 & 0x02) |\ (n >> 4 & 0x04) |\ (n >> 6 & 0x08) |\ (n >> 8 & 0x10) |\ (n >> 10 & 0x20) |\ (n >> 12 & 0x40) |\ (n >> 14 & 0x80)) #define BIN8(a) (BIN8_( 0##a ) + BIN8_VALID_( a ))
Is this a C89 thing? I always thought empty parenthesis meant no aruments, and an elipsis was any number of arguments. But maybe that was just C++ (and C99?).blargg wrote: - In C, "void rNES_init();" declares a function that can accept any arguments. Better to make it "void rNES_init( void );"