2018-12-03 12:26:02 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
|
|
|
This file is licensed under the Snes9x License.
|
|
|
|
For further information, consult the LICENSE file in the root directory.
|
|
|
|
\*****************************************************************************/
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2009-11-30 09:14:38 +01:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#include "snes9x.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "memmap.h"
|
2009-11-30 09:14:38 +01:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
uint8 S9xGetOBC1 (uint16 Address)
|
2009-11-30 09:14:38 +01:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
switch (Address)
|
|
|
|
{
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff0:
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)]);
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff1:
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1]);
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff2:
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2]);
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff3:
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3]);
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff4:
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200]);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM[Address - 0x6000]);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xSetOBC1 (uint8 Byte, uint16 Address)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
switch (Address)
|
|
|
|
{
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff0:
|
2010-01-27 23:08:56 +01:00
|
|
|
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2)] = Byte;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff1:
|
2010-01-27 23:08:56 +01:00
|
|
|
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 1] = Byte;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff2:
|
2010-01-27 23:08:56 +01:00
|
|
|
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 2] = Byte;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff3:
|
2010-01-27 23:08:56 +01:00
|
|
|
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address << 2) + 3] = Byte;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff4:
|
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
uint8 Temp;
|
|
|
|
Temp = Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200];
|
|
|
|
Temp = (Temp & ~(3 << OBC1.shift)) | ((Byte & 3) << OBC1.shift);
|
|
|
|
Memory.OBC1RAM[OBC1.basePtr + (OBC1.address >> 2) + 0x200] = Temp;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff5:
|
2008-09-10 07:57:37 +02:00
|
|
|
if (Byte & 1)
|
2010-01-27 23:08:56 +01:00
|
|
|
OBC1.basePtr = 0x1800;
|
2008-08-06 03:09:59 +02:00
|
|
|
else
|
2010-01-27 23:08:56 +01:00
|
|
|
OBC1.basePtr = 0x1c00;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
2008-09-10 07:57:37 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
case 0x7ff6:
|
2010-01-27 23:08:56 +01:00
|
|
|
OBC1.address = Byte & 0x7f;
|
|
|
|
OBC1.shift = (Byte & 3) << 1;
|
2008-08-06 03:09:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
Memory.OBC1RAM[Address - 0x6000] = Byte;
|
|
|
|
}
|
|
|
|
|
|
|
|
void S9xResetOBC1 (void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i <= 0x1fff; i++)
|
|
|
|
Memory.OBC1RAM[i] = 0xff;
|
|
|
|
|
|
|
|
if (Memory.OBC1RAM[0x1ff5] & 1)
|
|
|
|
OBC1.basePtr = 0x1800;
|
|
|
|
else
|
|
|
|
OBC1.basePtr = 0x1c00;
|
|
|
|
|
|
|
|
OBC1.address = Memory.OBC1RAM[0x1ff6] & 0x7f;
|
|
|
|
OBC1.shift = (Memory.OBC1RAM[0x1ff6] & 3) << 1;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-10-22 20:50:26 +02:00
|
|
|
uint8 * S9xGetBasePointerOBC1 (uint16 Address)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-10-22 20:50:26 +02:00
|
|
|
if (Address >= 0x7ff0 && Address <= 0x7ff6)
|
|
|
|
return (NULL);
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM - 0x6000);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-10-22 20:50:26 +02:00
|
|
|
uint8 * S9xGetMemPointerOBC1 (uint16 Address)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-10-22 20:50:26 +02:00
|
|
|
if (Address >= 0x7ff0 && Address <= 0x7ff6)
|
|
|
|
return (NULL);
|
2010-01-27 23:08:56 +01:00
|
|
|
return (Memory.OBC1RAM + Address - 0x6000);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|