Genesis-Plus-GX/source/cart_hw/svp/svp.c

51 lines
1.3 KiB
C
Raw Normal View History

/*
basic, incomplete SSP160x (SSP1601?) interpreter
with SVP memory controller emu
2008-08-07 14:26:07 +02:00
(c) Copyright 2008, Grazvydas "notaz" Ignotas
Free for non-commercial use.
2008-08-07 14:26:07 +02:00
For commercial use, separate licencing terms must be obtained.
2008-08-07 14:26:07 +02:00
Modified for Genesis Plus GX (Eke-Eke): added BIG ENDIAN support, fixed addr/code inversion
*/
2008-08-07 14:26:07 +02:00
#include "shared.h"
svp_t *svp = NULL;
2010-11-01 19:01:51 +01:00
int16 SVP_cycles = 800;
2008-08-07 14:26:07 +02:00
void svp_init(void)
{
svp = (void *) ((char *)cart.rom + 0x200000);
2008-12-11 18:38:29 +01:00
memset(svp, 0, sizeof(*svp));
2008-08-07 14:26:07 +02:00
}
void svp_reset(void)
{
memcpy(svp->iram_rom + 0x800, cart.rom + 0x800, 0x20000 - 0x800);
2008-12-11 18:38:29 +01:00
ssp1601_reset(&svp->ssp1601);
2008-08-07 14:26:07 +02:00
}
2008-12-04 20:32:22 +01:00
void svp_write_dram(uint32 address, uint32 data)
{
*(uint16 *)(svp->dram + (address & 0x1fffe)) = data;
if ((address == 0x30fe06) && data) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE06;
if ((address == 0x30fe08) && data) svp->ssp1601.emu_status &= ~SSP_WAIT_30FE08;
}
uint32 svp_read_cell_1(uint32 address)
{
address >>= 1;
address = (address & 0x7001) | ((address & 0x3e) << 6) | ((address & 0xfc0) >> 5);
return *(uint16 *)(svp->dram + (address & 0x1fffe));
}
uint32 svp_read_cell_2(uint32 address)
{
address >>= 1;
address = (address & 0x7801) | ((address & 0x1e) << 6) | ((address & 0x7e0) >> 4);
return *(uint16 *)(svp->dram + (address & 0x1fffe));
}