Mapper 176 sub mapper # 2

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Mapper 176 sub mapper # 2

Post by aquasnake »

Fceux or Mesen has not implemented this emulation, and Nestopia-plus, a Chinese modified branch of nestopia, has already supported this mapper.

I'm sorting out the hardware emulation of maper176. Due to the obvious differences among several sub mappers, some features can be downward compatible, but the PRG bank register swapping of # $46 and # $47 is different from other features and cannot be compatible with each other. This exclusivity requires the assignment of a mapper number.

Does anyone feel the same about it?
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

Suppose that it is detected by ($8000.6 && $A001.5), and if no other sub mapper will write 1 to $A001.5, it should be expected to be compatible
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Mapper 176 sub mapper # 2

Post by NewRisingSun »

but the PRG bank register swapping of # $46 and # $47 is different from other features and cannot be compatible with each other. This exclusivity requires the assignment of a mapper number.
I don't understand --- the submapper was assigned because the variants are not fully compatible to each other. So why would a new mapper number be required? Submappers exist to denote similar-yet-incompatible boards; there is no requirement that the several submappers within a mapper definition are compatible to each other.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

NewRisingSun wrote: Tue May 04, 2021 10:43 pm
but the PRG bank register swapping of # $46 and # $47 is different from other features and cannot be compatible with each other. This exclusivity requires the assignment of a mapper number.
I don't understand --- the submapper was assigned because the variants are not fully compatible to each other. So why would a new mapper number be required? Submappers exist to denote similar-yet-incompatible boards; there is no requirement that the several submappers within a mapper definition are compatible to each other.
Sub mapper 0 and 1 are supersets of sub mapper 3. I have implemented a single logic control to merge these three into one mapper.

The identification of sub maper2 needs more logic elements, only the identification itself, not including a series of function groups of the expantion at $A001. Sub mapper 2 itself is quite different from the other three sub mappers.

If it is a software emulator, the code occupation of the identification logic does not involve a large cost. In terms of hardware, if the internal logic is used for heuristic identification, the increased resource cost is higher than that of directly defining a mapper number. If a simpler and lower cost method can be used, it is meaningful.

I think about it for practical manufacturing purpose, not for educational or systematic purpose.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Mapper 176 sub mapper # 2

Post by NewRisingSun »

In that case, yes, if $A001.5 is set, it can be assumed to be submapper 2 (Waixing FS00x).

However, I have done more hardware tests, and found that the current submapper and other aspects of the specification are insufficient. You might want to delay finalizing your hardware implementation for a week or two until I have revised the description in the wiki.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

Waixing's Shuang Yue Zhuan (Ch).nes uses 256K only 8K cram to load all the chr data during initialization. The game should be composed of a mapper4 core and a mapper176 out loader. At present, the only dumped revision is a combined ROM, which has not been completely split to remove the loader. By analyzing the structure of prg bank, this dump should be an over dump
Last edited by aquasnake on Sat May 22, 2021 6:14 pm, edited 1 time in total.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Mapper 176 sub mapper # 2

Post by NewRisingSun »

The dumps of Shuang Yue Zhuan (双月传: 095D8678 and "Shen Feng Jian" 神风剑 D5F7AAEF) are nothing like that; they need 32 KiB PRG-RAM and 8 KiB CHR-RAM, although typically a 32 KiB CHR-RAM is mounted. Since they are the Chinese translation of the original Japanese game "Double Moon Densetsu", which is TNROM (512 KiB PRG-ROM +8 KiB CHR-RAM, expanded to 1024 KiB PRG-ROM for the Chinese translation), I don't see where 256 KiB of CHR-ROM data to be put into 256 KiB of CHR-RAM would ever come from. I think you might be dealing with a mis-named file.

The only known Waixing cartridges that have 128 KiB of 256 KiB of CHR-RAM are their multicarts. The only single-game cartridges I have seen that have CHR-ROM data in PRG-ROM, which is then copied into 128 or 256 KiB of CHR-RAM by a loader, are mapper 268-based releases from Retro-Bit and Mindkids.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

If it is 8K cram, there is no need to switch the chr bank, but debugging on the emulator indicates that there exists writing to chr bank registers. At present, neither fceux nor mesen can emulate this rom. FCE ultra supports however.

Strangely, when switching chr bank, it only loads waixing logo and copyright information. After entering the game, havn't found the chr bank switching yet. The prg bank switching is not controlled by registers of mmc3, but by $5011 external. And the PRG bank mode of this game is 32KB
aaa.jpg
It seems that it is 8K cram, but it will switch the bank. I'm not sure the significance of doing so
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Mapper 176 sub mapper # 2

Post by NewRisingSun »

When designing circuit boards with 8 KiB of CHR-RAM, the CHR-RAM's CHR A10-A12 can be connected straight to PPU A10-12 which means that MMC3 registers 0-5 are ignored ("unbanked 8 KiB CHR-RAM"), or CHR-RAM A10-A12 can be connnected to MMC3 CHR A10-A12 ("banked 8 KiB CHR-RAM"). Those writes set up MMC3 registers 0-5 to act as "unbanked 8 KiB CHR-RAM" to be compatible with both connection variants.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

"Shuang Yue Zhuan" runs on fceu and fceux in different ways.

The former can emulate correctly, while the latter displays nothing on screen. Since fceux is inherited from fceu, the fk23c.cpp file is basically the same. I found that fceu initializes iram to all FF but fceux to all 0. I don't know whether the difference leads to different compatibility
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

Wiki describes how to write three values in $100 - $102 and jump to $100 for execution. I cannot track the writing of these three values during initialization. Maybe the default bank setting of $e000 - $ffff is incorrect.

The three values of $100 - $102, I suspect, are exploiting the stack underflow. They might be the 3 bytes of the status register and PC pointer. The PC pointer position can be the indirect jump address to be scheduled. First copy three values into it, then set the stack pointer to #$00, and then execute RTI.

If $100 - $102 is not written correctly in advance, these three bytes will be the power up value, which may be 0 or FF on some one emulator. If FF, it will jump to the last byte of IRQ vector. If it is 0, it will jump to the first byte of the zero page, and the zero page is also initialized to 0, then it will be parsed as a BRK instruction and jump to the IRQ vector again. Usually, the IRQ service program fills with one instruction RTI, which will result in infinite IRQ/BRK
Last edited by aquasnake on Sat May 22, 2021 6:16 pm, edited 1 time in total.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Mapper 176 sub mapper # 2

Post by NewRisingSun »

First, make sure you have the right ROM for testing. I think none of them are in GoodNES, for GoodNES only has "fixed" versions that patch out the JMP to 0100. If you never see a write of $A1 to $A001, then the ROM is not suitable for testing this aspect.

For example, "Age of Empires", with copyright number 970493 (not 0100725), PRG-ROM CRC32 5EE2EF97. At PC=863B, it disables extra registers and writes three values to WRAM in the 5xxx range. Later, at PC=8665, it copies the same WRAM content from 7000+x to 6000+x, then from 6000/6010/6013 to 0100-0102, and JMPs to 0100. This has absolutely nothing to do with stack underflow.
User avatar
aquasnake
Posts: 515
Joined: Fri Sep 13, 2019 11:22 pm

Re: Mapper 176 sub mapper # 2

Post by aquasnake »

NewRisingSun wrote: Wed May 19, 2021 11:45 pm First, make sure you have the right ROM for testing. I think none of them are in GoodNES, for GoodNES only has "fixed" versions that patch out the JMP to 0100. If you never see a write of $A1 to $A001, then the ROM is not suitable for testing this aspect.

For example, "Age of Empires", with copyright number 970493 (not 0100725), PRG-ROM CRC32 5EE2EF97. At PC=863B, it disables extra registers and writes three values to WRAM in the 5xxx range. Later, at PC=8665, it copies the same WRAM content from 7000+x to 6000+x, then from 6000/6010/6013 to 0100-0102, and JMPs to 0100. This has absolutely nothing to do with stack underflow.
thanks, you are correct, my cart works fine on this game now
Post Reply