prepare to move files

This commit is contained in:
godzil 2008-02-21 00:01:40 +00:00
parent 3f4b4990ea
commit bc118baac8
6 changed files with 69 additions and 692 deletions

View File

@ -12,52 +12,8 @@
*
*/
unsigned char aorom_load_bank;
#define __TINES_MAPPERS__
#include <mappers/manager.h>
void aorom_MapperWriteHook(register byte Addr, register byte Value);
extern byte *ppu_mem_nameTables;
int aorom_InitMapper(NesCart * cart)
{
int i;
set_prom_bank_32k(0x8000,0);
ppu_setScreenMode(PPU_SCMODE_SINGLE);
aorom_load_bank = 0;
/* Register the write hook */
for (i = 0x80; i < 0x100; i++)
{
set_page_wr_hook(i, aorom_MapperWriteHook);
set_page_writeable(i, true);
}
return 0;
}
void aorom_MapperWriteHook(register byte Addr, register byte Value)
{
int BankNb;
if (Value & (1 << 4))
ppu_setSingleScreen(PPU_SCREEN_000);
else
ppu_setSingleScreen(PPU_SCREEN_400);
BankNb = Value & 0x0F;
aorom_load_bank = BankNb;
//printf("aorom: Asking bank %d (giving %d & %d) - mirror is %d\n",BankNb,BankNb,(Value<<1)+1,Value&0x0F);
set_prom_bank_32k(0x8000,BankNb);
}
void aorom_MapperDump(FILE *fp)
{
fprintf(fp,"aorom: bank:%d\n",aorom_load_bank);
}
int aorom_InitMapper(NesCart * cart);
void aorom_MapperDump(FILE *fp);

View File

@ -12,36 +12,8 @@
*
*/
unsigned char cnrom_load_bank;
#define __TINES_MAPPERS__
#include <mappers/manager.h>
void cnrom_MapperWriteHook(register byte Addr, register byte Value);
int cnrom_InitMapper(NesCart * cart)
{
int i;
set_prom_bank_16k(0x8000, 0);
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart)); /* Set the last one */
cnrom_load_bank = 0;
/* Register the write hook */
for (i = 0x80; i < 0x100; i++)
{
set_page_wr_hook(i, cnrom_MapperWriteHook);
set_page_writeable(i, true);
}
return 0;
}
void cnrom_MapperWriteHook(register byte Addr, register byte Value)
{
set_prom_bank_16k(0x8000,Value);
cnrom_load_bank = Value;
}
void cnrom_MapperDump(FILE *fp)
{
fprintf(fp,"cnrom: bank:%d\n",cnrom_load_bank);
}
int cnrom_InitMapper(NesCart * cart);
void cnrom_MapperDump(FILE *fp);

View File

@ -12,114 +12,10 @@
*
*/
unsigned short iremh3001_prom_slot[3];
#define __TINES_MAPPERS__
#include <mappers/manager.h>
unsigned short iremh3001_vrom_slot[8];
int iremh3001_InitMapper(NesCart * cart)
{
set_prom_bank_16k(0x8000, 0);
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
iremh3001_prom_slot[0] = 0;
iremh3001_prom_slot[1] = 1;
iremh3001_prom_slot[2] = GETLAST16KBANK(cart);
set_vrom_bank_8k(0x0000,4);
iremh3001_vrom_slot[0] = 0;
iremh3001_vrom_slot[1] = 0;
iremh3001_vrom_slot[2] = 0;
iremh3001_vrom_slot[3] = 0;
iremh3001_vrom_slot[4] = 0;
iremh3001_vrom_slot[5] = 0;
iremh3001_vrom_slot[6] = 0;
iremh3001_vrom_slot[7] = 0;
return 0;
}
int iremh3001_MapperWriteHook(register word Addr, register byte Value)
{
switch(Addr)
{
case 0x8000: /* Set 8k PROM @ 8000 */
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
set_prom_bank_8k(0x8000, Value);
iremh3001_prom_slot[0] = Value;
break;
case 0x9003: /* Mirroring ??? */
printf("iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
break;
case 0x9005: /* IRQ ??? */
printf("iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
break;
case 0x9006: /* IRQ ??? */
printf("iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
break;
case 0xA000: /* Set 8k PROM @ A000 */
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
set_prom_bank_8k(0xA000, Value);
iremh3001_prom_slot[1] = Value;
break;
case 0xB000: /* Set 1k VROM @ 0000 */
case 0xB001: /* Set 1k VROM @ 0400 */
case 0xB002: /* Set 1k VROM @ 0800 */
case 0xB003: /* Set 1k VROM @ 0C00 */
case 0xB004: /* Set 1k VROM @ 1000 */
case 0xB005: /* Set 1k VROM @ 1400 */
case 0xB006: /* Set 1k VROM @ 1800 */
case 0xB007: /* Set 1k VROM @ 1C00 */
printf("iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
set_vrom_bank_1k((Addr&0xF)<<10, Value);
iremh3001_vrom_slot[Addr&0x0F] = Value;
break;
case 0xC000: /* Set 8k PROM @ C000 */
printf("iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
set_prom_bank_8k(0xC000, Value);
iremh3001_prom_slot[2] = Value;
break;
default:
printf("@:%X -- V:%X", Addr, Value);
return 0;
}
return 1;
}
void iremh3001_MapperDump(FILE *fp)
{
fprintf(fp,"iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
iremh3001_prom_slot[0],
iremh3001_prom_slot[1],
iremh3001_prom_slot[2]);
fprintf(fp,"iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
" $1000:%d $1400:%d $1800:%d $1C00:%d\n",
iremh3001_vrom_slot[0],
iremh3001_vrom_slot[1],
iremh3001_vrom_slot[2],
iremh3001_vrom_slot[3],
iremh3001_vrom_slot[4],
iremh3001_vrom_slot[5],
iremh3001_vrom_slot[6],
iremh3001_prom_slot[7]);
}
int iremh3001_MapperIRQ(int cycledone)
{
return 0;
}
int iremh3001_InitMapper(NesCart * cart);
int iremh3001_MapperWriteHook(register word Addr, register byte Value);
void iremh3001_MapperDump(FILE *fp);
int iremh3001_MapperIRQ(int cycledone);

View File

@ -12,306 +12,9 @@
*
*/
unsigned short mmc3_command;
#define __TINES_MAPPERS__
#include <mappers/manager.h>
unsigned char mmc3_irq_counter;
unsigned char mmc3_irq_counter_reload;
unsigned char mmc3_irq_enable;
unsigned short mmc3_first_prom_page;
unsigned short mmc3_second_prom_page;
unsigned char mmc3_use_xor;
unsigned char mmc3_last_vrom[6];
unsigned char mmc3_last_prom[2];
unsigned char mmc3_last_prom_switch;
unsigned short dummy;
void mmc3_MapperWrite80Hook(byte addr, byte value);
void mmc3_MapperWriteA0Hook(byte addr, byte value);
void mmc3_MapperWriteC0Hook(byte addr, byte value);
void mmc3_MapperWriteE0Hook(byte addr, byte value);
void mmc3_MapperDump(FILE *fp)
{
fprintf(fp,"MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n",mmc3_command,mmc3_irq_counter,mmc3_irq_counter_reload,mmc3_irq_enable,mmc3_first_prom_page,mmc3_second_prom_page,mmc3_use_xor);
fprintf(fp,"MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n",mmc3_last_vrom[0],mmc3_last_vrom[1],mmc3_last_vrom[2],mmc3_last_vrom[3],mmc3_last_vrom[4],mmc3_last_vrom[5]);
fprintf(fp,"MMC3: LP0:%d LP1:%d LPS:%d\n",mmc3_last_prom[0],mmc3_last_prom[1],mmc3_last_prom_switch);
}
int mmc3_InitMapper(NesCart * cart)
{
int i;
set_prom_bank_16k(0x8000, 0);
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
if ( Cart->VROMSize > 0)
{
set_vrom_bank_8k(0, 0x0000);
}
mmc3_command = -1;
mmc3_irq_counter = -1;
mmc3_irq_enable = 1;
mmc3_irq_counter_reload = 0;
mmc3_use_xor = 0x42;
mmc3_last_prom_switch = 0x42;
mmc3_last_prom[0] = 0;
mmc3_last_prom[1] = 1;
mmc3_last_vrom[0] = 0;
mmc3_last_vrom[1] = 2;
mmc3_last_vrom[2] = 3;
mmc3_last_vrom[3] = 4;
mmc3_last_vrom[4] = 5;
mmc3_last_vrom[5] = 6;
mmc3_first_prom_page = 0x8000;
mmc3_second_prom_page = 0xA000;
//mmc3_first_prom_page = 0; // Set it to 0x8000
/* Register mapper write hook */
set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
set_page_writeable(0x80, true);
set_page_wr_hook(0xA0, mmc3_MapperWriteA0Hook);
set_page_writeable(0xA0, true);
set_page_wr_hook(0xC0, mmc3_MapperWriteC0Hook);
set_page_writeable(0xC0, true);
set_page_wr_hook(0xE0, mmc3_MapperWriteE0Hook);
set_page_writeable(0xE0, true);
return 0;
}
void mmc3_MapperWrite80Hook(byte addr, byte Value)
{
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
if (addr > 0x01)
return;
if (!addr)
{
if ((Cart->VROMSize > 0) && ( mmc3_use_xor != (Value & 0x80) ))
{
if (Value & 0x80)
{
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
}
else
{
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
}
mmc3_use_xor = (Value & 0x80);
}
if (mmc3_last_prom_switch != (Value & 0x40))
{
if (!(Value & 0x40))
{
printf("MMC3: Switch -> 8/A\n");
mmc3_first_prom_page = 0x8000;
mmc3_second_prom_page = 0xA000;
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart)-1);
//set_prom_bank_8k(0xE000, GETLAST08KBANK(cart));
//prg_bank(prg0,prg1,max_prg-1,max_prg);
}
else
{
printf("MMC3: Switch -> C/A\n");
mmc3_first_prom_page = 0xC000;
mmc3_second_prom_page = 0xA000;
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart)-1);
//prg_bank(max_prg-1,prg1,prg0,max_prg);
}
mmc3_last_prom_switch = (Value & 0x40);
}
mmc3_command = Value & 0x07;
} else { /* 8001 */
switch (mmc3_command)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
if (Cart->VROMSize == 0)
return;
mmc3_last_vrom[mmc3_command] = Value;
if (mmc3_use_xor)
{
set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
}
else
{
set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
}
break;
case 6:
mmc3_last_prom[0] = Value;
set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
break;
case 7:
mmc3_last_prom[1] = Value;
set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
break;
}
/*if(mmc3_use_xor)
chr_bank(chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1);
else
chr_bank(chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7);*/
}
}
void mmc3_MapperWriteA0Hook(byte addr, byte Value)
{
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
if (addr > 0x01)
return;
if (!addr)
{
//printf("MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
if (Value & 0x1)
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
else
ppu_setMirroring(PPU_MIRROR_VERTICAL);
}
else
{
//printf("MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
if (Value)
map_sram();
else
unmap_sram();
}
}
extern unsigned short ScanLine;
void mmc3_MapperWriteC0Hook(byte addr, byte Value)
{
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
if (addr > 0x01)
return;
if (!addr)
{
mmc3_irq_counter_reload = Value;
mmc3_irq_counter = Value;
//printf("MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
}else{ /* C001 */
//printf("MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
//printf("MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
mmc3_irq_counter = Value;
}
}
void mmc3_MapperWriteE0Hook(byte addr, byte Value)
{
//printf("%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
if (addr > 0x01)
return;
if (!addr)
{
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
//printf("MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
mmc3_irq_enable = 0;
//MapperWantIRQ = 1;
// Add a way to raise an IRQ
}else{ /* E001 */
//printf("MMC3: Writing to 0xE001 : 0x%X\n",Value);
//printf("MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
//printf("MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
mmc3_irq_enable = 1;
}
}
int mmc3_MapperIRQ(int cycledone)
{
if (((cycledone > 0) && (cycledone < 241)) /*&&
(ppu.ControlRegister2.b & (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)) == (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)*/)
{
if ((mmc3_irq_counter --) > 0 )return 0;
/* Load next counter position */
mmc3_irq_counter = mmc3_irq_counter_reload;
if (mmc3_irq_enable == 0) return 0;
mmc3_irq_enable = 0;
//printf("MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
return 1;
}
return 0;
}
void mmc3_MapperDump(FILE *fp);
int mmc3_InitMapper(NesCart * cart);
int mmc3_MapperIRQ(int cycledone);

View File

@ -12,126 +12,8 @@
*
*/
byte mmc4_RegA;
byte mmc4_RegB;
byte mmc4_RegC;
byte mmc4_RegD;
byte mmc4_RegE;
byte mmc4_RegF;
#ifdef DEBUG
#define LOG
//printf
#else
#define LOG
#endif
void mmc4_MapperWriteRegA(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegA = Value;
set_prom_bank_16k(0x8000, Value & 0x0F);
}
void mmc4_MapperWriteRegB(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegB = Value;
set_vrom_bank_4k(0x0000, Value & 0x1F);
}
void mmc4_MapperWriteRegC(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegC = Value;
set_vrom_bank_4k(0x0000, Value & 0x1F);
}
void mmc4_MapperWriteRegD(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegD = Value;
set_vrom_bank_4k(0x1000, Value & 0x1F);
}
void mmc4_MapperWriteRegE(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegE = Value;
set_vrom_bank_4k(0x1000, Value & 0x1F);
}
void mmc4_MapperWriteRegF(register byte Addr, register byte Value)
{
LOG("%s(%02X, %02X)\n", __func__, Addr, Value);
mmc4_RegF = Value;
if (Value & 0x01)
ppu_setMirroring(PPU_MIRROR_HORIZTAL);
else
ppu_setMirroring(PPU_MIRROR_VERTICAL);
}
void mmc4_MapperDump(FILE *fp)
{
}
int mmc4_InitMapper(NesCart * cart)
{
int i;
set_prom_bank_16k(0x8000,0);
set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
if (cart->VROMSize > 0) set_vrom_bank_8k(0x0000,0);
/* Mapper should register itself for write hook */
for (i = 0xA0; i < 0xB0 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegA);
set_page_writeable(i, true);
}
for (i = 0xB0; i < 0xC0 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegB);
set_page_writeable(i, true);
}
for (i = 0xC0; i < 0xD0 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegC);
set_page_writeable(i, true);
}
for (i = 0xD0; i < 0xE0 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegD);
set_page_writeable(i, true);
}
for (i = 0xE0; i < 0xF0 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegE);
set_page_writeable(i, true);
}
for (i = 0xF0; i < 0x100 ; i++)
{
set_page_wr_hook(i, mmc4_MapperWriteRegF);
set_page_writeable(i, true);
}
for (i = 0x60; i < 0x80 ; i++)
{
set_page_writeable(i, true);
set_page_readable(i, true);
}
//ppu_setScreenMode(PPU_SCMODE_NORMAL);
//ppu_setMirroring(PPU_MIRROR_HORIZTAL);
return 0;
}
#define __TINES_MAPPERS__
#include <mappers/manager.h>
void mmc4_MapperDump(FILE *fp);
int mmc4_InitMapper(NesCart * cart);

View File

@ -12,40 +12,8 @@
*
*/
unsigned char unrom_load_vbank;
#define __TINES_MAPPERS__
#include <mappers/manager.h>
void unrom_MapperWriteHook(register byte Addr, register byte Value);
int unrom_InitMapper(NesCart * cart)
{
int i;
set_prom_bank_16k(0xC000, 0);
set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
if (Cart->VROMSize > 0)
set_vrom_bank_8k(0x0000,0);
unrom_load_vbank = 0;
/* Register the write hook */
for (i = 0x80; i < 0x100; i++)
{
set_page_wr_hook(i, unrom_MapperWriteHook);
set_page_writeable(i, true);
}
return 0;
}
void unrom_MapperWriteHook(register byte Addr, register byte Value)
{
set_vrom_bank_8k(0x0000,Value);
unrom_load_vbank = Value;
}
void unrom_MapperDump(FILE *fp)
{
fprintf(fp,"unrom: vbank:%d\n",unrom_load_vbank);
}
int unrom_InitMapper(NesCart * cart);
void unrom_MapperDump(FILE *fp);