It is currently Wed Dec 13, 2017 2:27 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Sep 01, 2016 11:03 am 
Offline
User avatar

Joined: Sun Jun 05, 2016 1:41 pm
Posts: 74
I recently implemented mapper 58 in my own emulator, which seems fairly straightforward according to the specs at http://wiki.nesdev.com/w/index.php/INES_Mapper_058. I managed to get the Game Star 68-in-1 ROM working (CRC: 2BA377FC), except for the game Galaxin 00, Galaxin 01 etc., which for some reason is switching to the game selection menu. The PRG, CHR, Mirroring and PRG mode registers are all encoded in the lower byte of the address when written from $8000 upwards. I am aware that for the 32K PRG mode, the bank number has to be right-shifted so I don't think that's the problem. I'm beginning to wonder if it's a case of implementing a latch of some sort but I could not determine that from the specs.

Does anyone have any experience with this mapper? I can share code if that helps.

Thanks

_________________
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 11:57 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19335
Location: NE Indiana, USA (NTSC)
Problems with Galaxian in pirate multis often happen when the menu is in the same PRG ROM bank as Galaxian, whose PRG ROM is only 8 KiB. (Every other commercial-era NES game I can think of has at least a 16 KiB PRG ROM.) Does the mapper have an 8K mode that you aren't enabling?


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 4:21 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3968
According to the wiki page, there's a 16k mode and a 32k mode, and that's it.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 4:41 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6513
Location: Seattle
The multicart seems to work correctly in FCEUX...


Top
 Profile  
 
PostPosted: Thu Sep 01, 2016 6:12 pm 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 750
Location: New York, NY
The wiki is a little vague about the program mode. Maybe you misinterpreted the information there.

In program mode 1, the program bank comes from the lower 3 bits of the address, not the value written to that address. And, the bank value is used twice; both 16K blocks reference the same bank (there are 8 of them).

In program mode 0, only bits 2 and 1 of the address are relevant; bit 0 is ignored. It is used to establish a 32K bank (there are only 4 of them).


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 6:21 am 
Offline
User avatar

Joined: Sun Jun 05, 2016 1:41 pm
Posts: 74
I think my mapper 58 implementation is already in line with all your suggestions. Here's the relevant code (C#) for reading and writing to the mapper:

Code:
        public override byte this[ushort address]
        {
            get
            {
                if (address < 0x2000)
                {
                    return Cartridge.CharacterRom[characterBank * 0x2000 + address];
                }
                else if (address >= 0x8000)
                {
                    int bankSize = programMode == 0 ? 0x8000 : 0x4000;
                    int bankOffset = address % bankSize;
                    int selectedBank = programMode == 0 ? (programBank >> 1) : programBank;
                    int flataddress = selectedBank * bankSize + bankOffset;
                    return Cartridge.ProgramRom[flataddress];
                }
                else
                {
                    return base[address]; // default - returns open bus
                }
            }

            set
            {
                if (address >= 0x8000)
                {
                    // $8000 - FFFF:  A~[.... .... MOCC CPPP]
                    // P = PRG page select
                    // C = CHR page select (8k @ $0000)
                    // O = PRG Mode
                    // M = Mirroring(0 = Vert, 1 = Horz)
                    programBank = address & Bin.B00000111;
                    characterBank = (address >> 3) & Bin.B00000111;
                    programMode = (address >> 6) & Bin.Bit0;
                    MirrorMode = (address & Bin.Bit7) != 0 ? MirrorMode.Horizontal : MirrorMode.Vertical;

                    Debug.WriteLine(" ........MOCCCPPP");
                    Debug.WriteLine(Bin.Format(address));
                }
                else
                {
                    base[address] = value; // default - do nothing
                }
            }
        }


Note: Bin.B00000111 is just a byte constant of value 0x07 - they are convenient mask values that I find handy. Similarly Bin.Bit0, Bin.Bit1, bin.Bit2 etc. correspond to values 0x01, 0x02, 0x04 etc.

_________________
Tile IDE and tile engine for XNA: http://tide.codeplex.com/
Fancy Fish Mod - Minecraft Mod: http://fancyfishmod.weebly.com/


Top
 Profile  
 
PostPosted: Sat Sep 03, 2016 1:39 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6513
Location: Seattle
Since I don't see anything obviously wrong with your code, and Galaxian usually shares a bank with the menu, I have a hunch that whatever problem you're having, it's not in your mapper implementation.


Tangential unasked-for not-so-humble-opinion: I'm not clear that thinking in terms of "remainder" and "multiplication" is the best design decision. In late-80s electronics, bit shifts, multiplexers, and boolean logic are cheap and it might be more useful to represent it that way, rather than thinking in terms of ordinary math on a file offset.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

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