2025-04-07 21:33:51 +02:00
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file :
* Copyright ( C ) 2025 NewRisingSun
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
*/
# include "mapinc.h"
2025-09-01 01:13:46 +02:00
# include "asic_vrc2and4.h"
2025-09-12 11:22:37 +02:00
# include "cartram.h"
2025-04-07 21:33:51 +02:00
static void sync ( ) {
2025-04-07 22:39:03 +02:00
VRC24_syncWRAM ( 0 ) ;
2025-04-11 16:10:27 +02:00
VRC24_syncPRG ( 0x03F , 0x000 ) ; /* A real VRC4 has a PRG-ROM maximum of 256 KiB, but some hacks use more than that. */
2025-04-07 21:33:51 +02:00
VRC24_syncCHR ( 0x1FF , 0x000 ) ;
VRC24_syncMirror ( ) ;
2025-04-11 16:10:27 +02:00
if ( ROM_size & 1 ) setprg16 ( 0xC000 , ROM_size - 1 ) ; /* A number of Contra hacks have a PRG-ROM size of 400 KiB, expecting the last 16 KiB to be determined via subtraction. They would not work on real hardware. */
2025-04-07 21:33:51 +02:00
}
void Mapper21_Init ( CartInfo * info ) {
switch ( info - > submapper ) {
2025-09-01 01:13:46 +02:00
case 1 : VRC4_init ( info , sync , 0x02 , 0x04 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
case 2 : VRC4_init ( info , sync , 0x40 , 0x80 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
default : VRC4_init ( info , sync , 0x42 , 0x84 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
2025-04-07 21:33:51 +02:00
}
2025-09-01 01:13:46 +02:00
WRAM_init ( info , 8 ) ;
2025-04-07 21:33:51 +02:00
}
2025-09-01 01:13:46 +02:00
static int Mapper22_getCHRBank ( uint8 bank ) {
return VRC24_getCHRBank ( bank & 7 ) > > 1 ;
2025-04-07 21:33:51 +02:00
}
void Mapper22_Init ( CartInfo * info ) {
2025-09-01 01:13:46 +02:00
VRC2_init ( info , sync , 0x02 , 0x01 , NULL , Mapper22_getCHRBank , NULL , NULL ) ;
WRAM_init ( info , 8 ) ;
2025-04-07 21:33:51 +02:00
}
void Mapper23_Init ( CartInfo * info ) {
switch ( info - > submapper ) {
2025-09-01 01:13:46 +02:00
case 1 : VRC4_init ( info , sync , 0x01 , 0x02 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
case 2 : VRC4_init ( info , sync , 0x04 , 0x08 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
case 3 : VRC2_init ( info , sync , 0x01 , 0x02 , NULL , NULL , NULL , NULL ) ; break ;
default : VRC4_init ( info , sync , 0x05 , 0x0A , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
2025-04-07 21:33:51 +02:00
}
2025-09-01 01:13:46 +02:00
WRAM_init ( info , 8 ) ;
2025-04-07 21:33:51 +02:00
}
void Mapper25_Init ( CartInfo * info ) {
switch ( info - > submapper ) {
2025-09-01 01:13:46 +02:00
case 1 : VRC4_init ( info , sync , 0x02 , 0x01 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
case 2 : VRC4_init ( info , sync , 0x08 , 0x04 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
case 3 : VRC2_init ( info , sync , 0x02 , 0x01 , NULL , NULL , NULL , NULL ) ; break ;
default : VRC4_init ( info , sync , 0x0A , 0x05 , 1 , NULL , NULL , NULL , NULL , NULL ) ; break ;
2025-04-07 21:33:51 +02:00
}
2025-09-01 01:13:46 +02:00
WRAM_init ( info , 8 ) ;
2025-04-07 21:33:51 +02:00
}