Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65.

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by gutomaia » Mon Dec 07, 2020 6:48 pm

rainwarrior wrote:
Mon Dec 07, 2020 4:30 pm
lidnariq wrote:
Mon Dec 07, 2020 12:50 pm
I've tried [removing CONDES], but a receive the following error, might be something wrong with my compiler parameters.
Then don't link in condes.s ?
If condes.o is getting linked it means there's a reference to initlib or donelib in your crt0.o. You could remove it from the library archive with ar65 but you wouldn't be able to explicitly unlink it. You have to rebuild crt0 without the reference to those two functions. Once that's done it won't matter if condes.o remains in the library, as it won't get linked without any references.

The FEATURES / CONDES stuff is useless for NES. It adds an ability for linked modules to have a startup/shutdown routine at program start and exit. The shutdown part doesn't really make sense on any platform where you don't return to an operating system on exit. The startup part might be useful, but AFAIK as a feature it's only used for an IRQ implementation on a few systems. I recommend getting rid of this feature from your library.


FWIW I don't really like any of the platform libraries that come with cc65. My approach is generally to take everything in libsrc/runtime and libsrc/common, and write my own crt0 that's part of my program rather than a library. That's enough to get all the basic stuff going. If you want to use some library functions like printf, etc. you might need to write some of the dependent routines, but if you're going to be making a game you probably don't need any of it. All ctr0.s really needs to do is handle a reset, jsr copydata, set up the C stack pointer, and jmp _main. (Example: dgolf.s)
Thanks. I manage to remove the condes.o from nes.lib and the references of initlib on crt0.o, also removed features on nes.cfg. Although, the compiled ROM, seems to bring the same error and basic structure.

Aboute the example, still studying it. Not sure how to make it useful yet. But really thanks for the help!

User avatar
dougeff
Posts: 2825
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by dougeff » Mon Dec 07, 2020 8:19 pm

Did you remove jsr donelib and any import of initlib or donelib?
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
rainwarrior
Posts: 8006
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by rainwarrior » Mon Dec 07, 2020 8:43 pm

To be clear: removing FEATURES / CONDES is just a tangent here, nothing to do with the problem you're trying to solve, but a good thing to get rid of anyway.

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by gutomaia » Tue Dec 08, 2020 6:46 am

Guys, first of all, thank you all: dougeff, lidnariq, rainwarrior and tepples.

So far, I've
I do understand that wont fix yet, but now I kind of see the light. Still learning how to create a crt0.s. Any tips on how to solve it.

tepples
Posts: 22288
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by tepples » Tue Dec 08, 2020 8:13 am

In practice, you don't need to worry about an operating system on the NES. But for the sake of completeness:

Occasionally there's an OS of sorts. A multicart has its menu, for instance, and Nintendo World Championships has its shell and countdown timer. I admit these are uncommon situations, and any exit to OS tends to be implemented in hardware (with Reset Button action) or by patching exit code into each game when a multicart is built.

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by gutomaia » Tue Dec 08, 2020 4:45 pm

WARNING: The following post contains scripts that may be disturbing to some programmers.

Guys,

Now I'm definitely lost. I know the problem, but I don't know how to fix it. What I know:
  • I got something wrong with the packing;
  • and I need to fix it on crt0.s file.
  • also, I don't know the order of the databanks
Then, I tried one approach, rearrange the databank myself using brute force:

Code: Select all

dd bs=16 skip=1 if=bankswitch.nes of=bankswitch_noinesheader.nes
dd bs=16 count=1 if=bankswitch.nes of=ines_header
split -b 8192 bankswitch_noinesheader.nes

cat ines_header xaa xab xac xad xae xaf xag xah xai > t1.nes
cat ines_header xaa xab xac xad xae xaf xag xai xah > t2.nes
cat ines_header xaa xab xac xad xae xaf xah xai xag > t3.nes
cat ines_header xaa xab xac xad xae xag xah xai xaf > t4.nes
cat ines_header xaa xab xac xad xaf xag xah xai xae > t5.nes
; here goes the combined analyses.
Well, I didn't find a suitable order. You guess it right when we try things at random, it's cause we are out of cards, and here I am!

Searching for docs over crt0.s and MMC3 and how the databanks are organized.

BTW. MMC3 does need any kind of init setup on reset?

lidnariq
Posts: 10273
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by lidnariq » Tue Dec 08, 2020 5:05 pm

At this point, you're really going to have to sit down with an emulator with a debugger - Mesen's amazing but heavy-weight, and FCEUX just in the past month grew a cross-platform one - and get comfortable with reading 6502 assembly. There's just too many places that something could be wrong.

As far as MMC3 init - you should assume that every register will be set to the worst possible value for you on boot or reset.

User avatar
rainwarrior
Posts: 8006
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by rainwarrior » Tue Dec 08, 2020 6:29 pm

gutomaia wrote:
Tue Dec 08, 2020 4:45 pm
MMC3 does need any kind of init setup on reset?
It absolutely does. (This is true of most/all mappers.)

I don't have the time to write out a tutorial for it at this moment, but this thread might have helpful suggestions:
How do I set up MMC3?

Otherwise just go through the list of MMC3 registers on the wiki and make sure every one of them is assigned a value at startup.
gutomaia wrote:Then, I tried one approach, rearrange the databank myself using brute force...
On a lot of real mappers, the startup position of banks is literally randomized by chaotic electrical differences in the latch at power-on. You can't rely on anything that isn't fixed until you've actually set its value.

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by gutomaia » Wed Dec 09, 2020 7:17 pm

rainwarrior wrote:
Tue Dec 08, 2020 6:29 pm
It absolutely does. (This is true of most/all mappers.)
I made some peek and started MMC3 on the main, like tutorial and code found at https://nesdoug.com/2019/11/11/23-advanced-mapper-mmc3/ and https://github.com/nesdoug/33_MMC3

rainwarrior wrote:
Tue Dec 08, 2020 6:29 pm
I don't have the time to write out a tutorial for it at this moment, but this thread might have helpful suggestions:
How do I set up MMC3?
Thanks, I'm checking all the answers!

rainwarrior wrote:
Tue Dec 08, 2020 6:29 pm
Otherwise just go through the list of MMC3 registers on the wiki and make sure every one of them is assigned a value at startup.
Okay, I will double-check this.
rainwarrior wrote:
Tue Dec 08, 2020 6:29 pm
On a lot of real mappers, the startup position of banks is literally randomized by chaotic electrical differences in the latch at power-on. You can't rely on anything that isn't fixed until you've actually set its value.
Thanks, I will also double-check this.
Last edited by gutomaia on Wed Dec 09, 2020 7:31 pm, edited 1 time in total.

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65 (50 USD bounty).

Post by gutomaia » Wed Dec 09, 2020 7:30 pm

lidnariq wrote:
Tue Dec 08, 2020 5:05 pm
At this point, you're really going to have to sit down with an emulator with a debugger - Mesen's amazing but heavy-weight, and FCEUX just in the past month grew a cross-platform one - and get comfortable with reading 6502 assembly. There's just too many places that something could be wrong.

As far as MMC3 init - you should assume that every register will be set to the worst possible value for you on boot or reset.
Thanks, I'm double-checking this.

As I state in the first post, I'm trying to run the game on some specific clone devices, then what I notice is the emulator seems to be some version of nestopia with some gimmicks.

Therefore, I'm trying to improve the ROM compatibility with nestopia. Problem is, it does not have any debug tool.

User avatar
gutomaia
Posts: 23
Joined: Fri Jun 15, 2012 10:12 am

Re: Help on define MMC3 mapper with 8 PGR roms and CHR RAM with CC65.

Post by gutomaia » Wed Dec 16, 2020 7:05 am

The bounty is off.

Despite all the good support on the forum, I wasn't able to improve the compatibility with some clone devices using MMC3 with several banks.

Although I did not achieve the goal, I decided to reward all the members that answered this thread with the first bounty amount (30 USD). The tips they gave were invaluable.

Post Reply