aboutsummaryrefslogtreecommitdiff
path: root/source/sa1.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/sa1.c')
-rw-r--r--source/sa1.c204
1 files changed, 3 insertions, 201 deletions
diff --git a/source/sa1.c b/source/sa1.c
index 5a95862..18540fb 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -1,93 +1,4 @@
-/*******************************************************************************
- Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
-
- (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and
- Jerremy Koot (jkoot@snes9x.com)
-
- (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net)
-
- (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net),
- funkyass (funkyass@spam.shaw.ca),
- Joel Yliluoma (http://iki.fi/bisqwit/)
- Kris Bleakley (codeviolation@hotmail.com),
- Matthew Kendora,
- Nach (n-a-c-h@users.sourceforge.net),
- Peter Bortas (peter@bortas.org) and
- zones (kasumitokoduck@yahoo.com)
-
- C4 x86 assembler and some C emulation code
- (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com),
- _Demo_ (_demo_@zsnes.com), and Nach
-
- C4 C++ code
- (c) Copyright 2003 Brad Jorsch
-
- DSP-1 emulator code
- (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson,
- John Weidman, neviksti (neviksti@hotmail.com),
- Kris Bleakley, Andreas Naive
-
- DSP-2 emulator code
- (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and
- Lord Nightmare (lord_nightmare@users.sourceforge.net
-
- OBC1 emulator code
- (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and
- Kris Bleakley
- Ported from x86 assembler to C by sanmaiwashi
-
- SPC7110 and RTC C++ emulator code
- (c) Copyright 2002 Matthew Kendora with research by
- zsKnight, John Weidman, and Dark Force
-
- S-DD1 C emulator code
- (c) Copyright 2003 Brad Jorsch with research by
- Andreas Naive and John Weidman
-
- S-RTC C emulator code
- (c) Copyright 2001 John Weidman
-
- ST010 C++ emulator code
- (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora
-
- Super FX x86 assembler emulator code
- (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault
-
- Super FX C emulator code
- (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman
-
-
- SH assembler code partly based on x86 assembler code
- (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
-
- (c) Copyright 2014 - 2016 Daniel De Matteis. (UNDER NO CIRCUMSTANCE
- WILL COMMERCIAL RIGHTS EVER BE APPROPRIATED TO ANY PARTY)
-
- Specific ports contains the works of other authors. See headers in
- individual files.
-
- Snes9x homepage: http://www.snes9x.com
-
- Permission to use, copy, modify and distribute Snes9x in both binary and
- source form, for non-commercial purposes, is hereby granted without fee,
- providing that this license information and copyright notice appear with
- all copies and any derived work.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event shall the authors be held liable for any damages
- arising from the use of this software.
-
- Snes9x is freeware for PERSONAL USE only. Commercial users should
- seek permission of the copyright holders first. Commercial use includes
- charging money for Snes9x or software derived from Snes9x.
-
- The copyright holders request that bug fixes and improvements to the code
- should be forwarded to them so everyone can benefit from the modifications
- in future versions.
-
- Super NES and Super Nintendo Entertainment System are trademarks of
- Nintendo Co., Limited and its subsidiary companies.
-*******************************************************************************/
+#include "../copyright"
#include "snes9x.h"
#include "ppu.h"
@@ -351,20 +262,6 @@ void S9xSA1SetPCBase(uint32_t address)
}
}
-void S9xSA1ExecuteDuringSleep()
-{
-#if 0
- if (SA1.Executing)
- {
- while (CPU.Cycles < CPU.NextEvent)
- {
- S9xSA1MainLoop();
- CPU.Cycles += TWO_CYCLES * 2;
- }
- }
-#endif
-}
-
void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
{
int c;
@@ -395,7 +292,6 @@ void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
uint8_t S9xGetSA1(uint32_t address)
{
- // printf ("R: %04x\n", address);
switch (address)
{
case 0x2300:
@@ -433,12 +329,10 @@ uint8_t S9xGetSA1(uint32_t address)
void S9xSetSA1(uint8_t byte, uint32_t address)
{
- //printf ("W: %02x -> %04x\n", byte, address);
switch (address)
{
case 0x2200:
SA1.Waiting = (byte & 0x60) != 0;
- // SA1.Executing = !SA1.Waiting && SA1.S9xOpcodes;
if (!(byte & 0x20) && (Memory.FillRAM [0x2200] & 0x20))
S9xSA1Reset();
@@ -455,9 +349,6 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
if (byte & 0x10)
{
Memory.FillRAM [0x2301] |= 0x10;
- if (Memory.FillRAM [0x220a] & 0x10)
- {
- }
}
break;
@@ -481,25 +372,13 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
S9xClearIRQ(SA1_DMA_IRQ_SOURCE);
}
break;
+
case 0x2203:
- // printf ("SA1 reset vector: %04x\n", byte | (Memory.FillRAM [0x2204] << 8));
- break;
case 0x2204:
- // printf ("SA1 reset vector: %04x\n", (byte << 8) | Memory.FillRAM [0x2203]);
- break;
-
case 0x2205:
- // printf ("SA1 NMI vector: %04x\n", byte | (Memory.FillRAM [0x2206] << 8));
- break;
case 0x2206:
- // printf ("SA1 NMI vector: %04x\n", (byte << 8) | Memory.FillRAM [0x2205]);
- break;
-
case 0x2207:
- // printf ("SA1 IRQ vector: %04x\n", byte | (Memory.FillRAM [0x2208] << 8));
- break;
case 0x2208:
- // printf ("SA1 IRQ vector: %04x\n", (byte << 8) | Memory.FillRAM [0x2207]);
break;
case 0x2209:
@@ -516,28 +395,18 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
{
SA1.Flags |= IRQ_PENDING_FLAG;
SA1.IRQActive |= SNES_IRQ_SOURCE;
- // SA1.Executing = !SA1.Waiting;
}
if (((byte ^ Memory.FillRAM [0x220a]) & 0x40) &&
(Memory.FillRAM [0x2301] & byte & 0x40))
{
SA1.Flags |= IRQ_PENDING_FLAG;
SA1.IRQActive |= TIMER_IRQ_SOURCE;
- // SA1.Executing = !SA1.Waiting;
}
if (((byte ^ Memory.FillRAM [0x220a]) & 0x20) &&
(Memory.FillRAM [0x2301] & byte & 0x20))
{
SA1.Flags |= IRQ_PENDING_FLAG;
SA1.IRQActive |= DMA_IRQ_SOURCE;
- // SA1.Executing = !SA1.Waiting;
- }
- if (((byte ^ Memory.FillRAM [0x220a]) & 0x10) &&
- (Memory.FillRAM [0x2301] & byte & 0x10))
- {
-#if 0
- printf("###SA1 NMI\n");
-#endif
}
break;
case 0x220b:
@@ -565,26 +434,12 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
SA1.Flags &= ~IRQ_PENDING_FLAG;
break;
case 0x220c:
- // printf ("SNES NMI vector: %04x\n", byte | (Memory.FillRAM [0x220d] << 8));
- break;
case 0x220d:
- // printf ("SNES NMI vector: %04x\n", (byte << 8) | Memory.FillRAM [0x220c]);
- break;
-
case 0x220e:
- // printf ("SNES IRQ vector: %04x\n", byte | (Memory.FillRAM [0x220f] << 8));
- break;
case 0x220f:
- // printf ("SNES IRQ vector: %04x\n", (byte << 8) | Memory.FillRAM [0x220e]);
- break;
-
case 0x2210:
-#if 0
- printf("Timer %s\n", (byte & 0x80) ? "linear" : "HV");
- printf("Timer H-IRQ %s\n", (byte & 1) ? "enabled" : "disabled");
- printf("Timer V-IRQ %s\n", (byte & 2) ? "enabled" : "disabled");
-#endif
break;
+
case 0x2211:
printf("Timer reset\n");
break;
@@ -605,62 +460,28 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
case 0x2222:
case 0x2223:
S9xSetSA1MemMap(address - 0x2220, byte);
- // printf ("MMC: %02x\n", byte);
break;
case 0x2224:
- // printf ("BWRAM image SNES %02x -> 0x6000\n", byte);
Memory.BWRAM = Memory.SRAM + (byte & 7) * 0x2000;
break;
case 0x2225:
- // printf ("BWRAM image SA1 %02x -> 0x6000 (%02x)\n", byte, Memory.FillRAM [address]);
if (byte != Memory.FillRAM [address])
S9xSA1SetBWRAMMemMap(byte);
break;
case 0x2226:
- // printf ("BW-RAM SNES write %s\n", (byte & 0x80) ? "enabled" : "disabled");
- break;
case 0x2227:
- // printf ("BW-RAM SA1 write %s\n", (byte & 0x80) ? "enabled" : "disabled");
- break;
-
case 0x2228:
- // printf ("BW-RAM write protect area %02x\n", byte);
- break;
case 0x2229:
- // printf ("I-RAM SNES write protect area %02x\n", byte);
- break;
case 0x222a:
- // printf ("I-RAM SA1 write protect area %02x\n", byte);
- break;
case 0x2230:
-#if 0
- printf("SA1 DMA %s\n", (byte & 0x80) ? "enabled" : "disabled");
- printf("DMA priority %s\n", (byte & 0x40) ? "DMA" : "SA1");
- printf("DMA %s\n", (byte & 0x20) ? "char conv" : "normal");
- printf("DMA type %s\n", (byte & 0x10) ? "BW-RAM -> I-RAM" : "SA1 -> I-RAM");
- printf("DMA distination %s\n", (byte & 4) ? "BW-RAM" : "I-RAM");
- printf("DMA source %s\n", DMAsource [byte & 3]);
-#endif
break;
case 0x2231:
if (byte & 0x80)
SA1.in_char_dma = false;
-#if 0
- printf("CHDEND %s\n", (byte & 0x80) ? "complete" : "incomplete");
- printf("DMA colour mode %d\n", byte & 3);
- printf("virtual VRAM width %d\n", (byte >> 2) & 7);
-#endif
break;
case 0x2232:
case 0x2233:
case 0x2234:
- Memory.FillRAM [address] = byte;
-#if 0
- printf("DMA source start %06x\n",
- Memory.FillRAM [0x2232] | (Memory.FillRAM [0x2233] << 8) |
- (Memory.FillRAM [0x2234] << 16));
-#endif
- break;
case 0x2235:
Memory.FillRAM [address] = byte;
break;
@@ -686,23 +507,13 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
// Normal DMA to BW-RAM
S9xSA1DMA();
}
-#if 0
- printf("DMA dest address %06x\n",
- Memory.FillRAM [0x2235] | (Memory.FillRAM [0x2236] << 8) |
- (Memory.FillRAM [0x2237] << 16));
-#endif
break;
case 0x2238:
case 0x2239:
Memory.FillRAM [address] = byte;
-#if 0
- printf("DMA length %04x\n",
- Memory.FillRAM [0x2238] | (Memory.FillRAM [0x2239] << 8));
-#endif
break;
case 0x223f:
SA1.VirtualBitmapFormat = (byte & 0x80) ? 2 : 4;
- //printf ("virtual VRAM depth %d\n", (byte & 0x80) ? 2 : 4);
break;
case 0x2240:
@@ -720,13 +531,6 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
case 0x224c:
case 0x224d:
case 0x224e:
-#if 0
- if (!(SA1.Flags & TRACE_FLAG))
- {
- TraceSA1();
- Trace();
- }
-#endif
Memory.FillRAM [address] = byte;
break;
@@ -795,7 +599,6 @@ void S9xSetSA1(uint8_t byte, uint32_t address)
S9xSA1ReadVariableLengthData(false, true);
return;
default:
- // printf ("W: %02x->%04x\n", byte, address);
break;
}
if (address >= 0x2200 && address <= 0x22ff)
@@ -896,7 +699,6 @@ static void S9xSA1DMA()
{
SA1.Flags |= IRQ_PENDING_FLAG;
SA1.IRQActive |= DMA_IRQ_SOURCE;
- // SA1.Executing = !SA1.Waiting;
}
}