nesdev.com
http://forums.nesdev.com/

Mapper 235?
http://forums.nesdev.com/viewtopic.php?f=3&t=16199
Page 1 of 1

Author:  Zepper [ Tue Jul 11, 2017 6:18 am ]
Post subject:  Mapper 235?

Back in early times, it was assigned mapper 235 for a 150-in-1 cart, and probably others since my implementation brings different stuff for each PRG size. There's some non-sense on it, but not my fault.
Code:
/*
Address

1--A B-mS -M-p pppp
       
M: PPU mirroring control, one screen ($2000).
m: if M=0, PPU mirroring vertical/horizontal.
p: PRG page select.

mS: PRG bank mode?

B: select PRG 32k mode
A: (B=0) select PRG 16k mode
         A=0 low 16k at $8000 and $C000
         A=1 high 16k at $8000 and $C000
*/

static void map235(const unsigned int addr, const unsigned char data)
{
   /* mirroring
    */
   if(addr&0x400)       set_custom_mirror(0,0,0,0);
   else if(addr&0x2000) set_hmirror();
   else                 set_vmirror();

   /* rom bankswitch
    */
   unsigned char pdata = addr & 0x1f;
   switch(prg_banks << 1)
   {
      case 128:
        if(addr & 0x300) { //$8000-$FFFF is ALL openbus!?
           cpu_setopenbus(4);
           cpu_setopenbus(5);
           cpu_setopenbus(6);
           cpu_setopenbus(7);
           return;
        } break;

      case 256:
        switch(addr & 0x300) {
           case 0:
             break;
           case 2:
             pdata |= 0x20;
             break;
           default:
             cpu_setopenbus(4);
             cpu_setopenbus(5);
             cpu_setopenbus(6);
             cpu_setopenbus(7);
             return;
        } break;

      case 384:
        switch(addr & 0x300) {
           case 0:
             break;
           case 2:
             pdata |= 0x20;
             break;
           case 3:
             pdata |= 0x40;
             break;
           default:
             cpu_setopenbus(4);
             cpu_setopenbus(5);
             cpu_setopenbus(6);
             cpu_setopenbus(7); /* todo- what's the point of this? */
             return;
        } break;

      case 512:
        pdata |= (addr & 0x300) >> 3;
        break;

      default:    //unsupported
        return;
   }

   /* prg cpu_swap
    */
   if(0 == (addr&0x800)) {
      cpu_swap32k(pdata);
   } else {
      pdata <<= 2;
      if(addr&0x1000) {
         cpu_swap8k(4,pdata+2);
         cpu_swap8k(5,pdata+3);
         cpu_swap8k(6,pdata+2);
         cpu_swap8k(7,pdata+3);
      } else {
         cpu_swap8k(4,pdata+0);
         cpu_swap8k(5,pdata+1);
         cpu_swap8k(6,pdata+0);
         cpu_swap8k(7,pdata+1);
      }
   }
}

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/