Previous 199869 Revisions Next

r21571 Monday 4th March, 2013 at 16:49:22 UTC by Fabio Priuli
snes: shuffling some code around (part 1). nw.
[src/mame/includes]snes.h
[src/mame/machine]snes.c
[src/mess/drivers]snes.c

trunk/src/mess/drivers/snes.c
r21570r21571
5858}
5959
6060
61static READ8_HANDLER( snes_lo_r )
62{
63   if (offset < 0x300000)
64      return snes_r_bank1(space, offset, 0xff);
65   else if (offset < 0x400000)
66      return snes_r_bank2(space, offset - 0x300000, 0xff);
67   else if (offset < 0x600000)
68      return snes_r_bank3(space, offset - 0x400000, 0xff);
69   else if (offset < 0x700000)
70      return snes_r_bank4(space, offset - 0x600000, 0xff);
71   else
72      return snes_r_bank5(space, offset - 0x700000, 0xff);
73}   
6174
75static READ8_HANDLER( snes_hi_r )
76{
77   if (offset < 0x400000)
78      return snes_r_bank6(space, offset, 0xff);
79   else
80      return snes_r_bank7(space, offset - 0x400000, 0xff);
81}   
82
83static WRITE8_HANDLER( snes_lo_w )
84{
85   if (offset < 0x300000)
86      snes_w_bank1(space, offset, data, 0xff);
87   else if (offset < 0x400000)
88      snes_w_bank2(space, offset - 0x300000, data, 0xff);
89   else if (offset < 0x600000)
90      return;
91   else if (offset < 0x700000)
92      snes_w_bank4(space, offset - 0x600000, data, 0xff);
93   else
94      snes_w_bank5(space, offset - 0x700000, data, 0xff);
95}   
96
97static WRITE8_HANDLER( snes_hi_w )
98{
99   if (offset < 0x400000)
100      snes_w_bank6(space, offset, data, 0xff);
101   else
102      snes_w_bank7(space, offset, data - 0x400000, 0xff);
103}   
104
105static READ8_HANDLER( superfx_r_bank1 )
106{
107   return snes_ram[offset | 0x8000];
108}
109
110static READ8_HANDLER( superfx_r_bank2 )
111{
112   return snes_ram[0x400000 + offset];
113}
114
115static READ8_HANDLER( superfx_r_bank3 )
116{
117   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
118    has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
119    as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
120   //printf("superfx_r_bank3: %08x = %02x\n", offset, snes_ram[0xe00000 + offset]);
121   return snes_ram[0xe00000 + offset];
122}
123
124static WRITE8_HANDLER( superfx_w_bank1 )
125{
126   printf("Attempting to write to cart ROM: %08x = %02x\n", offset, data);
127   // Do nothing; can't write to cart ROM.
128}
129
130static WRITE8_HANDLER( superfx_w_bank2 )
131{
132   printf("Attempting to write to cart ROM: %08x = %02x\n", 0x400000 + offset, data);
133   // Do nothing; can't write to cart ROM.
134}
135
136static WRITE8_HANDLER( superfx_w_bank3 )
137{
138   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
139    has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
140    as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
141   //printf("superfx_w_bank3: %08x = %02x\n", offset, data);
142   snes_ram[0xe00000 + offset] = data;
143}
144
62145/*************************************
63146 *
64147 *  Address maps
r21570r21571
66149 *************************************/
67150
68151static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, snes_state )
69   AM_RANGE(0x000000, 0x2fffff) AM_READWRITE_LEGACY(snes_r_bank1, snes_w_bank1)    /* I/O and ROM (repeats for each bank) */
70   AM_RANGE(0x300000, 0x3fffff) AM_READWRITE_LEGACY(snes_r_bank2, snes_w_bank2)    /* I/O and ROM (repeats for each bank) */
71   AM_RANGE(0x400000, 0x5fffff) AM_READ_LEGACY(snes_r_bank3)       /* ROM (and reserved in Mode 20) */
72   AM_RANGE(0x600000, 0x6fffff) AM_READWRITE_LEGACY(snes_r_bank4, snes_w_bank4)    /* used by Mode 20 DSP-1 */
73   AM_RANGE(0x700000, 0x7dffff) AM_READWRITE_LEGACY(snes_r_bank5, snes_w_bank5)
152   AM_RANGE(0x000000, 0x7dffff) AM_READWRITE_LEGACY(snes_lo_r, snes_lo_w)
74153   AM_RANGE(0x7e0000, 0x7fffff) AM_RAM                 /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */
75   AM_RANGE(0x800000, 0xbfffff) AM_READWRITE_LEGACY(snes_r_bank6, snes_w_bank6)    /* Mirror and ROM */
76   AM_RANGE(0xc00000, 0xffffff) AM_READWRITE_LEGACY(snes_r_bank7, snes_w_bank7)    /* Mirror and ROM */
154   AM_RANGE(0x800000, 0xffffff) AM_READWRITE_LEGACY(snes_hi_r, snes_hi_w)
77155ADDRESS_MAP_END
78156
79157static ADDRESS_MAP_START( superfx_map, AS_PROGRAM, 8, snes_state )
trunk/src/mame/machine/snes.c
r21570r21571
22422242   }
22432243
22442244}
2245
2246READ8_HANDLER( superfx_r_bank1 )
2247{
2248   return snes_ram[offset | 0x8000];
2249}
2250
2251READ8_HANDLER( superfx_r_bank2 )
2252{
2253   return snes_ram[0x400000 + offset];
2254}
2255
2256READ8_HANDLER( superfx_r_bank3 )
2257{
2258   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
2259   has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
2260   as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
2261   //printf("superfx_r_bank3: %08x = %02x\n", offset, snes_ram[0xe00000 + offset]);
2262   return snes_ram[0xe00000 + offset];
2263}
2264
2265WRITE8_HANDLER( superfx_w_bank1 )
2266{
2267   printf("Attempting to write to cart ROM: %08x = %02x\n", offset, data);
2268   // Do nothing; can't write to cart ROM.
2269}
2270
2271WRITE8_HANDLER( superfx_w_bank2 )
2272{
2273   printf("Attempting to write to cart ROM: %08x = %02x\n", 0x400000 + offset, data);
2274   // Do nothing; can't write to cart ROM.
2275}
2276
2277WRITE8_HANDLER( superfx_w_bank3 )
2278{
2279   /* IMPORTANT: SFX RAM sits in 0x600000-0x7fffff, and it's mirrored in 0xe00000-0xffffff. However, SNES
2280   has only access to 0x600000-0x7dffff (because there is WRAM after that), hence we directly use the mirror
2281   as the place where to write & read SFX RAM. SNES handlers have been setup accordingly. */
2282   //printf("superfx_w_bank3: %08x = %02x\n", offset, data);
2283   snes_ram[0xe00000 + offset] = data;
2284}
trunk/src/mame/includes/snes.h
r21570r21571
764764extern DECLARE_WRITE8_HANDLER( snes_w_bank6 );
765765extern DECLARE_WRITE8_HANDLER( snes_w_bank7 );
766766
767extern DECLARE_READ8_HANDLER( superfx_r_bank1 );
768extern DECLARE_READ8_HANDLER( superfx_r_bank2 );
769extern DECLARE_READ8_HANDLER( superfx_r_bank3 );
770extern DECLARE_WRITE8_HANDLER( superfx_w_bank1 );
771extern DECLARE_WRITE8_HANDLER( superfx_w_bank2 );
772extern DECLARE_WRITE8_HANDLER( superfx_w_bank3 );
773
774767extern UINT8  *snes_ram;            /* Main memory */
775768
776769

Previous 199869 Revisions Next


© 1997-2024 The MAME Team