From 845e69d88914edabfd770ab53a9e6fb5dc8dacba Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Mon, 20 Aug 2018 09:11:01 -0600 Subject: [PATCH] revert remainder of snes9x code back --- source/preferences.cpp | 1 - source/snes9x/65c816.h | 25 +- source/snes9x/c4.cpp | 26 +- source/snes9x/c4.h | 25 +- source/snes9x/c4emu.cpp | 25 +- source/snes9x/cheats2.cpp | 2 +- source/snes9x/clip.cpp | 25 +- source/snes9x/controls.cpp | 6 +- source/snes9x/cpu.cpp | 4 +- source/snes9x/cpuaddr.h | 27 +- source/snes9x/dma.h | 25 +- source/snes9x/dsp.cpp | 25 +- source/snes9x/dsp.h | 25 +- source/snes9x/dsp1.cpp | 35 +- source/snes9x/dsp2.cpp | 25 +- source/snes9x/dsp3.cpp | 27 +- source/snes9x/dsp4.cpp | 25 +- source/snes9x/font.h | 25 +- source/snes9x/fxemu.h | 25 +- source/snes9x/fxinst.cpp | 44 +-- source/snes9x/fxinst.h | 25 +- source/snes9x/getset.h | 3 +- source/snes9x/gfx.cpp | 237 ++++++------ source/snes9x/gfx.h | 25 +- source/snes9x/globals.cpp | 25 +- source/snes9x/language.h | 27 +- source/snes9x/logger.cpp | 33 +- source/snes9x/logger.h | 25 +- source/snes9x/memmap.cpp | 74 ++-- source/snes9x/messages.h | 25 +- source/snes9x/missing.h | 25 +- source/snes9x/movie.cpp | 69 ++-- source/snes9x/movie.h | 27 +- source/snes9x/msu1.cpp | 58 ++- source/snes9x/msu1.h | 18 +- source/snes9x/obc1.cpp | 25 +- source/snes9x/obc1.h | 25 +- source/snes9x/pixform.h | 25 +- source/snes9x/port.h | 78 ++-- source/snes9x/ppu.cpp | 79 ++-- source/snes9x/ppu.h | 1 + source/snes9x/reader.cpp | 3 + source/snes9x/sar.h | 25 +- source/snes9x/screenshot.cpp | 25 +- source/snes9x/screenshot.h | 25 +- source/snes9x/sdd1.cpp | 25 +- source/snes9x/sdd1.h | 25 +- source/snes9x/sdd1emu.cpp | 25 +- source/snes9x/sdd1emu.h | 25 +- source/snes9x/seta.cpp | 25 +- source/snes9x/seta.h | 25 +- source/snes9x/seta010.cpp | 677 +++++++++++++++++++---------------- source/snes9x/seta011.cpp | 25 +- source/snes9x/seta018.cpp | 25 +- source/snes9x/snapshot.cpp | 3 +- source/snes9x/snes9x.h | 1 - source/snes9x/spc7110.cpp | 25 +- source/snes9x/spc7110.h | 25 +- source/snes9x/spc7110dec.cpp | 4 +- source/snes9x/spc7110emu.cpp | 2 +- source/snes9x/srtc.cpp | 25 +- source/snes9x/srtc.h | 25 +- source/snes9x/tile.cpp | 117 +++--- source/snes9x/tile.h | 25 +- 64 files changed, 934 insertions(+), 1649 deletions(-) diff --git a/source/preferences.cpp b/source/preferences.cpp index 1d33aac..0e97e5d 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -489,7 +489,6 @@ DefaultSettings () // Graphics Settings.Transparency = true; Settings.SupportHiRes = true; - Settings.MaxSpriteTilesPerLine = 34; Settings.SkipFrames = AUTO_FRAMERATE; Settings.TurboSkipFrames = 19; Settings.DisplayFrameRate = false; diff --git a/source/snes9x/65c816.h b/source/snes9x/65c816.h index 183c695..995fcbb 100644 --- a/source/snes9x/65c816.h +++ b/source/snes9x/65c816.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/c4.cpp b/source/snes9x/c4.cpp index 922c205..d586e79 100644 --- a/source/snes9x/c4.cpp +++ b/source/snes9x/c4.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -309,6 +294,7 @@ void C4Op1F (void) { tanval = (double) C41FYVal / C41FXVal; C41FAngleRes = (int16) (atan(tanval) / (C4_PI * 2) * 512); + C41FAngleRes = C41FAngleRes; if (C41FXVal< 0) C41FAngleRes += 0x100; C41FAngleRes &= 0x1FF; diff --git a/source/snes9x/c4.h b/source/snes9x/c4.h index bbd3780..9b4c607 100644 --- a/source/snes9x/c4.h +++ b/source/snes9x/c4.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/c4emu.cpp b/source/snes9x/c4emu.cpp index 4efb531..65e0f55 100644 --- a/source/snes9x/c4emu.cpp +++ b/source/snes9x/c4emu.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/cheats2.cpp b/source/snes9x/cheats2.cpp index 76756e2..d174c5c 100644 --- a/source/snes9x/cheats2.cpp +++ b/source/snes9x/cheats2.cpp @@ -373,7 +373,7 @@ bool8 S9xSaveCheatFile (const char *filename) for (uint32 i = 0; i < Cheat.num_cheats; i++) { - memset(data, 0, 28); + ZeroMemory(data, 28); if (i == 0) { diff --git a/source/snes9x/clip.cpp b/source/snes9x/clip.cpp index 5ff8c8a..8e6baa3 100644 --- a/source/snes9x/clip.cpp +++ b/source/snes9x/clip.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/controls.cpp b/source/snes9x/controls.cpp index 5f093ca..b94a402 100644 --- a/source/snes9x/controls.cpp +++ b/source/snes9x/controls.cpp @@ -627,7 +627,7 @@ void S9xUnmapAllControls (void) if (!(superscope.crosshair.set & 4)) superscope.crosshair.bg = 1; - memset(pseudobuttons, 0, sizeof(pseudobuttons)); + ZeroMemory(pseudobuttons, sizeof(pseudobuttons)); turbo_time = 1; } @@ -1244,7 +1244,7 @@ s9xcommand_t S9xGetCommandT (const char *name) int i, j; const char *s; - memset(&cmd, 0, sizeof(cmd)); + ZeroMemory(&cmd, sizeof(cmd)); cmd.type = S9xBadMapping; cmd.multi_press = 0; cmd.button_norpt = 0; @@ -3467,7 +3467,7 @@ void S9xGetControllerCrosshair (enum crosscontrols ctl, int8 *idx, const char ** void S9xControlPreSaveState (struct SControlSnapshot *s) { - memset(s, 0, sizeof(*s)); + ZeroMemory(s, sizeof(*s)); s->ver = 3; for (int j = 0; j < 2; j++) diff --git a/source/snes9x/cpu.cpp b/source/snes9x/cpu.cpp index 4e63e5a..3eeede1 100644 --- a/source/snes9x/cpu.cpp +++ b/source/snes9x/cpu.cpp @@ -273,7 +273,7 @@ void S9xReset (void) memset(Memory.RAM, 0x55, 0x20000); memset(Memory.VRAM, 0x00, 0x10000); - memset(Memory.FillRAM, 0, 0x8000); + ZeroMemory(Memory.FillRAM, 0x8000); if (Settings.BS) S9xResetBSX(); @@ -310,7 +310,7 @@ void S9xSoftReset (void) { S9xResetSaveTimer(FALSE); - memset(Memory.FillRAM, 0, 0x8000); + ZeroMemory(Memory.FillRAM, 0x8000); if (Settings.BS) S9xResetBSX(); diff --git a/source/snes9x/cpuaddr.h b/source/snes9x/cpuaddr.h index 5662788..3ae55c4 100644 --- a/source/snes9x/cpuaddr.h +++ b/source/snes9x/cpuaddr.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -302,8 +287,6 @@ static inline uint32 AbsoluteIndexedIndirectSlow (AccessMode a) // (a,X) static inline uint32 AbsoluteIndexedIndirect (AccessMode a) // (a,X) { uint16 addr = Immediate16Slow(READ); - - AddCycles(ONE_CYCLE); addr += Registers.X.W; // Address load wraps within the bank diff --git a/source/snes9x/dma.h b/source/snes9x/dma.h index b5fa5c1..c779a79 100644 --- a/source/snes9x/dma.h +++ b/source/snes9x/dma.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp.cpp b/source/snes9x/dsp.cpp index ab54185..b6e23ff 100644 --- a/source/snes9x/dsp.cpp +++ b/source/snes9x/dsp.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp.h b/source/snes9x/dsp.h index 7b9d371..be4d073 100644 --- a/source/snes9x/dsp.h +++ b/source/snes9x/dsp.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp1.cpp b/source/snes9x/dsp1.cpp index 1628744..85f9512 100644 --- a/source/snes9x/dsp1.cpp +++ b/source/snes9x/dsp1.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -896,9 +881,9 @@ static void DSP1_Project (int16 X, int16 Y, int16 Z, int16 *H, int16 *V, int16 * Py = DSP1_ShiftR(Py, E - refE); Pz = DSP1_ShiftR(Pz, E3 - refE); - C11 = -(Px * DSP1.Nx >> 15); - C8 = -(Py * DSP1.Ny >> 15); - C9 = -(Pz * DSP1.Nz >> 15); + C11 =- (Px * DSP1.Nx >> 15); + C8 =- (Py * DSP1.Ny >> 15); + C9 =- (Pz * DSP1.Nz >> 15); C12 = C11 + C8 + C9; // this cannot overflow! aux4 = C12; // de-normalization with 32-bits arithmetic @@ -1369,7 +1354,7 @@ void DSP1SetByte (uint8 byte, uint16 address) case 0x17: case 0x37: case 0x3F: - DSP1.command = 0x1f; // Fall through + DSP1.command = 0x1f; case 0x1f: DSP1.in_count = 1; break; default: #ifdef DEBUGGER @@ -1900,7 +1885,7 @@ uint8 DSP1GetByte (uint16 address) DSP1.waiting4command = TRUE; } else - t = 0x80; + t = 0xff; } else t = 0x80; diff --git a/source/snes9x/dsp2.cpp b/source/snes9x/dsp2.cpp index fb6c9f8..477209b 100644 --- a/source/snes9x/dsp2.cpp +++ b/source/snes9x/dsp2.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp3.cpp b/source/snes9x/dsp3.cpp index 9ee6a5d..5c79240 100644 --- a/source/snes9x/dsp3.cpp +++ b/source/snes9x/dsp3.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -1154,7 +1139,7 @@ static void DSP3_OP10 (void) DSP3_Reset(); else // absorb 2 bytes - DSP3.DR = DSP3.DR; // FIXME? + DSP3.DR = DSP3.DR; } /* diff --git a/source/snes9x/dsp4.cpp b/source/snes9x/dsp4.cpp index 63530db..9d6f3fd 100644 --- a/source/snes9x/dsp4.cpp +++ b/source/snes9x/dsp4.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/font.h b/source/snes9x/font.h index 9614f45..27011f6 100644 --- a/source/snes9x/font.h +++ b/source/snes9x/font.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/fxemu.h b/source/snes9x/fxemu.h index ac73d11..b2ce64e 100644 --- a/source/snes9x/fxemu.h +++ b/source/snes9x/fxemu.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/fxinst.cpp b/source/snes9x/fxinst.cpp index b25251c..5f7df2b 100644 --- a/source/snes9x/fxinst.cpp +++ b/source/snes9x/fxinst.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -906,14 +891,14 @@ static void fx_plot_2bit (void) return; #endif - if (!(GSU.vPlotOptionReg & 0x01) && !(COLR & 0xf)) - return; - if (GSU.vPlotOptionReg & 0x02) - c = ((x ^ y) & 1) ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg; + c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg; else c = (uint8) GSU.vColorReg; + if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf)) + return; + a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1); v = 128 >> (x & 7); @@ -970,14 +955,14 @@ static void fx_plot_4bit (void) return; #endif - if (!(GSU.vPlotOptionReg & 0x01) && !(COLR & 0xf)) - return; - if (GSU.vPlotOptionReg & 0x02) - c = ((x ^ y) & 1) ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg; + c = (x ^ y) & 1 ? (uint8) (GSU.vColorReg >> 4) : (uint8) GSU.vColorReg; else c = (uint8) GSU.vColorReg; + if (!(GSU.vPlotOptionReg & 0x01) && !(c & 0xf)) + return; + a = GSU.apvScreen[y >> 3] + GSU.x[x >> 3] + ((y & 7) << 1); v = 128 >> (x & 7); @@ -1186,7 +1171,7 @@ static void fx_cmode (void) { GSU.vPlotOptionReg = SREG; - if (GSU.vPlotOptionReg & 0x10) + if (GSU.vPlotOptionReg & 0x10) GSU.vScreenHeight = 256; // OBJ Mode (for drawing into sprites) else GSU.vScreenHeight = GSU.vScreenRealHeight; @@ -4152,6 +4137,7 @@ static void fx_sm_r15 (void) uint32 fx_run (uint32 nInstructions) { GSU.vCounter = nInstructions; + READR14; while (TF(G) && (GSU.vCounter-- > 0)) FX_STEP; #if 0 diff --git a/source/snes9x/fxinst.h b/source/snes9x/fxinst.h index d2124bd..dd3736e 100644 --- a/source/snes9x/fxinst.h +++ b/source/snes9x/fxinst.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/getset.h b/source/snes9x/getset.h index 0236c30..14fef5e 100644 --- a/source/snes9x/getset.h +++ b/source/snes9x/getset.h @@ -931,7 +931,8 @@ inline void S9xSetPCBase (uint32 Address) Registers.PBPC = Address & 0xffffff; ICPU.ShiftedPB = Address & 0xff0000; - uint8 *GetAddress = Memory.Map[(int)((Address & 0xffffff) >> MEMMAP_SHIFT)]; + int block; + uint8 *GetAddress = Memory.Map[block = ((Address & 0xffffff) >> MEMMAP_SHIFT)]; CPU.MemSpeed = memory_speed(Address); CPU.MemSpeedx2 = CPU.MemSpeed << 1; diff --git a/source/snes9x/gfx.cpp b/source/snes9x/gfx.cpp index 046aaf0..579aa52 100644 --- a/source/snes9x/gfx.cpp +++ b/source/snes9x/gfx.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -230,7 +215,7 @@ static uint16 get_crosshair_color (uint8); bool8 S9xGraphicsInit (void) { S9xInitTileRenderer(); - memset(BlackColourMap, 0, 256 * sizeof(uint16)); + ZeroMemory(BlackColourMap, 256 * sizeof(uint16)); #ifdef GFX_MULTI_FORMAT if (GFX.BuildPixel == NULL) @@ -241,9 +226,9 @@ bool8 S9xGraphicsInit (void) GFX.InterlaceFrame = 0; GFX.RealPPL = GFX.Pitch >> 1; IPPU.OBJChanged = TRUE; + IPPU.DirectColourMapsNeedRebuild = TRUE; Settings.BG_Forced = 0; S9xFixColourBrightness(); - S9xBuildDirectColourMaps(); GFX.X2 = (uint16 *) malloc(sizeof(uint16) * 0x10000); GFX.ZERO = (uint16 *) malloc(sizeof(uint16) * 0x10000); @@ -260,7 +245,7 @@ bool8 S9xGraphicsInit (void) } // Lookup table for color addition - memset(GFX.X2, 0, 0x10000 * sizeof(uint16)); + ZeroMemory(GFX.X2, 0x10000 * sizeof(uint16)); for (uint32 r = 0; r <= MAX_RED; r++) { uint32 r2 = r << 1; @@ -286,7 +271,7 @@ bool8 S9xGraphicsInit (void) } // Lookup table for 1/2 color subtraction - memset(GFX.ZERO, 0, 0x10000 * sizeof(uint16)); + ZeroMemory(GFX.ZERO, 0x10000 * sizeof(uint16)); for (uint32 r = 0; r <= MAX_RED; r++) { uint32 r2 = r; @@ -336,14 +321,15 @@ void S9xBuildDirectColourMaps (void) for (uint32 p = 0; p < 8; p++) for (uint32 c = 0; c < 256; c++) DirectColourMaps[p][c] = BUILD_PIXEL(IPPU.XB[((c & 7) << 2) | ((p & 1) << 1)], IPPU.XB[((c & 0x38) >> 1) | (p & 2)], IPPU.XB[((c & 0xc0) >> 3) | (p & 4)]); + + IPPU.DirectColourMapsNeedRebuild = FALSE; } void S9xStartScreenRefresh (void) { - GFX.InterlaceFrame = !GFX.InterlaceFrame; - if (IPPU.RenderThisFrame) { + GFX.InterlaceFrame = !GFX.InterlaceFrame; if (!GFX.DoInterlace || !GFX.InterlaceFrame) { if (!S9xInitUpdate()) @@ -369,13 +355,12 @@ void S9xStartScreenRefresh (void) } else { - #ifdef USE_OPENGL + #ifdef USE_OPENGL if (Settings.OpenGLEnable) GFX.RealPPL = SNES_WIDTH; else - #endif + #endif GFX.RealPPL = GFX.Pitch >> 1; - IPPU.DoubleWidthPixels = FALSE; IPPU.RenderedScreenWidth = SNES_WIDTH; } @@ -401,8 +386,8 @@ void S9xStartScreenRefresh (void) PPU.RecomputeClipWindows = TRUE; IPPU.PreviousLine = IPPU.CurrentLine = 0; - memset(GFX.ZBuffer, 0, GFX.ScreenSize); - memset(GFX.SubZBuffer, 0, GFX.ScreenSize); + ZeroMemory(GFX.ZBuffer, GFX.ScreenSize); + ZeroMemory(GFX.SubZBuffer, GFX.ScreenSize); } if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0) @@ -686,7 +671,7 @@ void S9xUpdateScreen (void) { if (!IPPU.DoubleWidthPixels && (PPU.BGMode == 5 || PPU.BGMode == 6 || IPPU.PseudoHires)) { - #ifdef USE_OPENGL + #ifdef USE_OPENGL if (Settings.OpenGLEnable && GFX.RealPPL == 256) { // Have to back out of the speed up hack where the low res. @@ -706,30 +691,42 @@ void S9xUpdateScreen (void) GFX.PPL = GFX.RealPPL; // = GFX.Pitch >> 1 above } else - #endif - // Have to back out of the regular speed hack - for (register uint32 y = 0; y < GFX.StartY; y++) + #endif { - register uint16 *p = GFX.Screen + y * GFX.PPL + 255; - register uint16 *q = GFX.Screen + y * GFX.PPL + 510; + // Have to back out of the regular speed hack + for (register uint32 y = 0; y < GFX.StartY; y++) + { + register uint16 *p = GFX.Screen + y * GFX.PPL + 255; + register uint16 *q = GFX.Screen + y * GFX.PPL + 510; - for (register int x = 255; x >= 0; x--, p--, q -= 2) - *q = *(q + 1) = *p; + for (register int x = 255; x >= 0; x--, p--, q -= 2) + *q = *(q + 1) = *p; + } } IPPU.DoubleWidthPixels = TRUE; IPPU.RenderedScreenWidth = 512; } - if (!IPPU.DoubleHeightPixels && IPPU.Interlace && (PPU.BGMode == 5 || PPU.BGMode == 6)) + if (!IPPU.DoubleHeightPixels && IPPU.Interlace) { IPPU.DoubleHeightPixels = TRUE; IPPU.RenderedScreenHeight = PPU.ScreenHeight << 1; GFX.PPL = GFX.RealPPL << 1; GFX.DoInterlace = 2; - for (register int32 y = (int32) GFX.StartY - 2; y >= 0; y--) - memmove(GFX.Screen + (y + 1) * GFX.PPL, GFX.Screen + y * GFX.RealPPL, GFX.PPL * sizeof(uint16)); + for (register int32 y = (int32) GFX.StartY - 1; y >= 0; y--) + memmove(GFX.Screen + y * GFX.PPL, GFX.Screen + y * GFX.RealPPL, IPPU.RenderedScreenWidth * sizeof(uint16)); + } + else if (IPPU.DoubleHeightPixels && !IPPU.Interlace) + { + for (register int32 y = 0; y < (int32) GFX.StartY; y++) + memmove(GFX.Screen + y * GFX.RealPPL, GFX.Screen + y * GFX.PPL, IPPU.RenderedScreenWidth * sizeof(uint16)); + + IPPU.DoubleHeightPixels = FALSE; + IPPU.RenderedScreenHeight = PPU.ScreenHeight; + GFX.PPL = GFX.RealPPL; + GFX.DoInterlace = 0; } } @@ -822,12 +819,12 @@ static void SetupOBJ (void) if (!PPU.OAMPriorityRotation || !(PPU.OAMFlip & PPU.OAMAddr & 1)) // normal case { uint8 LineOBJ[SNES_HEIGHT_EXTENDED]; - memset(LineOBJ, 0, sizeof(LineOBJ)); + ZeroMemory(LineOBJ, sizeof(LineOBJ)); for (int i = 0; i < SNES_HEIGHT_EXTENDED; i++) { GFX.OBJLines[i].RTOFlags = 0; - GFX.OBJLines[i].Tiles = Settings.MaxSpriteTilesPerLine; + GFX.OBJLines[i].Tiles = 34; for (int j = 0; j < 32; j++) GFX.OBJLines[i].OBJ[j].Sprite = -1; } @@ -898,14 +895,8 @@ static void SetupOBJ (void) else // evil FirstSprite+Y case { // First, find out which sprites are on which lines - uint8 OBJOnLine[SNES_HEIGHT_EXTENDED][128]; - // memset(OBJOnLine, 0, sizeof(OBJOnLine)); - /* Hold on here, that's a lot of bytes to initialise at once! - * So we only initialise them per line, as needed. [Neb] - * Bonus: We can quickly avoid looping if a line has no OBJs. - */ - bool8 AnyOBJOnLine[SNES_HEIGHT_EXTENDED]; - memset(AnyOBJOnLine, FALSE, sizeof(AnyOBJOnLine)); // better + uint8 OBJOnLine[SNES_HEIGHT_EXTENDED][128]; + ZeroMemory(OBJOnLine, sizeof(OBJOnLine)); for (S = 0; S < 128; S++) { @@ -939,11 +930,6 @@ static void SetupOBJ (void) if (Y >= SNES_HEIGHT_EXTENDED) continue; - if (!AnyOBJOnLine[Y]) { - memset(OBJOnLine[Y], 0, sizeof(OBJOnLine[Y])); - AnyOBJOnLine[Y] = TRUE; - } - if (PPU.OBJ[S].VFlip) // Yes, Width not Height. It so happens that the // sprites with H=2*W flip as two WxW sprites. @@ -959,34 +945,31 @@ static void SetupOBJ (void) for (int Y = 0; Y < SNES_HEIGHT_EXTENDED; Y++) { GFX.OBJLines[Y].RTOFlags = Y ? GFX.OBJLines[Y - 1].RTOFlags : 0; - GFX.OBJLines[Y].Tiles = Settings.MaxSpriteTilesPerLine; + GFX.OBJLines[Y].Tiles = 34; uint8 FirstSprite = (PPU.FirstSprite + Y) & 0x7f; S = FirstSprite; j = 0; - if (AnyOBJOnLine[Y]) + do { - do + if (OBJOnLine[Y][S]) { - if (OBJOnLine[Y][S]) + if (j >= 32) { - if (j >= 32) - { - GFX.OBJLines[Y].RTOFlags |= 0x40; - break; - } - - GFX.OBJLines[Y].Tiles -= GFX.OBJVisibleTiles[S]; - if (GFX.OBJLines[Y].Tiles < 0) - GFX.OBJLines[Y].RTOFlags |= 0x80; - GFX.OBJLines[Y].OBJ[j].Sprite = S; - GFX.OBJLines[Y].OBJ[j++].Line = OBJOnLine[Y][S] & ~0x80; + GFX.OBJLines[Y].RTOFlags |= 0x40; + break; } - S = (S + 1) & 0x7f; - } while (S != FirstSprite); - } + GFX.OBJLines[Y].Tiles -= GFX.OBJVisibleTiles[S]; + if (GFX.OBJLines[Y].Tiles < 0) + GFX.OBJLines[Y].RTOFlags |= 0x80; + GFX.OBJLines[Y].OBJ[j].Sprite = S; + GFX.OBJLines[Y].OBJ[j++].Line = OBJOnLine[Y][S] & ~0x80; + } + + S = (S + 1) & 0x7f; + } while (S != FirstSprite); if (j < 32) GFX.OBJLines[Y].OBJ[j].Sprite = -1; @@ -996,8 +979,6 @@ static void SetupOBJ (void) IPPU.OBJChanged = FALSE; } -#pragma GCC push_options -#pragma GCC optimize ("no-tree-vrp") static void DrawOBJS (int D) { void (*DrawTile) (uint32, uint32, uint32, uint32) = NULL; @@ -1090,8 +1071,6 @@ static void DrawOBJS (int D) } } } -#pragma GCC pop_options - static void DrawBackground (int bg, uint8 Zh, uint8 Zl) { @@ -1350,8 +1329,8 @@ static void DrawBackgroundMosaic (int bg, uint8 Zh, uint8 Zl) for (uint32 Y = GFX.StartY - MosaicStart; Y <= GFX.EndY; Y += PPU.Mosaic) { uint32 Y2 = HiresInterlace ? Y * 2 : Y; - uint32 VOffset = LineData[Y + MosaicStart].BG[bg].VOffset + (HiresInterlace ? 1 : 0); - uint32 HOffset = LineData[Y + MosaicStart].BG[bg].HOffset; + uint32 VOffset = LineData[Y].BG[bg].VOffset + (HiresInterlace ? 1 : 0); + uint32 HOffset = LineData[Y].BG[bg].HOffset; Lines = PPU.Mosaic - MosaicStart; if (Y + MosaicStart + Lines > GFX.EndY) @@ -1514,6 +1493,7 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff) int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1; bool8 HiresInterlace = IPPU.Interlace && IPPU.DoubleWidthPixels; + void (*DrawTile) (uint32, uint32, uint32, uint32); void (*DrawClippedTile) (uint32, uint32, uint32, uint32, uint32, uint32); for (int clip = 0; clip < GFX.Clip[bg].Count; clip++) @@ -1522,10 +1502,12 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff) if (BG.EnableMath && (GFX.Clip[bg].DrawMode[clip] & 2)) { + DrawTile = GFX.DrawTileMath; DrawClippedTile = GFX.DrawClippedTileMath; } else { + DrawTile = GFX.DrawTileNomath; DrawClippedTile = GFX.DrawClippedTileNomath; } @@ -1557,8 +1539,8 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff) uint32 Left = GFX.Clip[bg].Left[clip]; uint32 Right = GFX.Clip[bg].Right[clip]; uint32 Offset = Left * PixWidth + Y * GFX.PPL; - uint32 HScroll = LineData[Y].BG[bg].HOffset; - bool8 left_edge = (Left < (8 - (HScroll & 7))); + uint32 LineHOffset = LineData[Y].BG[bg].HOffset; + bool8 left_edge = (Left < (8 - (LineHOffset & 7))); uint32 Width = Right - Left; while (Left < Right) @@ -1569,12 +1551,12 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff) { // SNES cannot do OPT for leftmost tile column VOffset = LineData[Y].BG[bg].VOffset; - HOffset = HScroll; + HOffset = LineHOffset; left_edge = FALSE; } else { - int HOffTile = ((HOff + Left - 1) & Offset2Mask) >> 3; + int HOffTile = ((HOff + Left - 1) & Offset2Mask) >> 3; if (BG.OffsetSizeH == 8) { @@ -1613,9 +1595,9 @@ static void DrawBackgroundOffset (int bg, uint8 Zh, uint8 Zl, int VOffOff) VOffset = LineData[Y].BG[bg].VOffset; if (HCellOffset & OffsetEnableMask) - HOffset = (HCellOffset & ~7) | (HScroll & 7); + HOffset = (HCellOffset & ~7) | (LineHOffset & 7); else - HOffset = HScroll; + HOffset = LineHOffset; } if (HiresInterlace) @@ -1737,6 +1719,7 @@ static void DrawBackgroundOffsetMosaic (int bg, uint8 Zh, uint8 Zl, int VOffOff) int Lines; int OffsetMask = (BG.TileSizeH == 16) ? 0x3ff : 0x1ff; int OffsetShift = (BG.TileSizeV == 16) ? 4 : 3; + int Offset2Mask = (BG.OffsetSizeH == 16) ? 0x3ff : 0x1ff; int Offset2Shift = (BG.OffsetSizeV == 16) ? 4 : 3; int OffsetEnableMask = 0x2000 << bg; int PixWidth = IPPU.DoubleWidthPixels ? 2 : 1; @@ -1758,8 +1741,8 @@ static void DrawBackgroundOffsetMosaic (int bg, uint8 Zh, uint8 Zl, int VOffOff) for (uint32 Y = GFX.StartY - MosaicStart; Y <= GFX.EndY; Y += PPU.Mosaic) { uint32 Y2 = HiresInterlace ? Y * 2 : Y; - uint32 VOff = LineData[Y + MosaicStart].BG[2].VOffset - 1; - uint32 HOff = LineData[Y + MosaicStart].BG[2].HOffset; + uint32 VOff = LineData[Y].BG[2].VOffset - 1; + uint32 HOff = LineData[Y].BG[2].HOffset; Lines = PPU.Mosaic - MosaicStart; if (Y + MosaicStart + Lines > GFX.EndY) @@ -1788,22 +1771,24 @@ static void DrawBackgroundOffsetMosaic (int bg, uint8 Zh, uint8 Zl, int VOffOff) uint32 Left = GFX.Clip[bg].Left[clip]; uint32 Right = GFX.Clip[bg].Right[clip]; uint32 Offset = Left * PixWidth + (Y + MosaicStart) * GFX.PPL; - uint32 HScroll = LineData[Y + MosaicStart].BG[bg].HOffset; + uint32 LineHOffset = LineData[Y].BG[bg].HOffset; + bool8 left_edge = (Left < (8 - (LineHOffset & 7))); uint32 Width = Right - Left; while (Left < Right) { uint32 VOffset, HOffset; - if (Left < (8 - (HScroll & 7))) + if (left_edge) { // SNES cannot do OPT for leftmost tile column - VOffset = LineData[Y + MosaicStart].BG[bg].VOffset; - HOffset = HScroll; + VOffset = LineData[Y].BG[bg].VOffset; + HOffset = LineHOffset; + left_edge = FALSE; } else { - int HOffTile = (((Left + (HScroll & 7)) - 8) + (HOff & ~7)) >> 3; + int HOffTile = ((HOff + Left - 1) & Offset2Mask) >> 3; if (BG.OffsetSizeH == 8) { @@ -1839,12 +1824,12 @@ static void DrawBackgroundOffsetMosaic (int bg, uint8 Zh, uint8 Zl, int VOffOff) if (VCellOffset & OffsetEnableMask) VOffset = VCellOffset + 1; else - VOffset = LineData[Y + MosaicStart].BG[bg].VOffset; + VOffset = LineData[Y].BG[bg].VOffset; if (HCellOffset & OffsetEnableMask) - HOffset = (HCellOffset & ~7) | (HScroll & 7); + HOffset = (HCellOffset & ~7) | (LineHOffset & 7); else - HOffset = HScroll; + HOffset = LineHOffset; } if (HiresInterlace) @@ -2067,7 +2052,7 @@ static void DisplayPressedKeys (void) static int KeyOrder[] = { 8, 10, 7, 9, 0, 6, 14, 13, 5, 1, 4, 3, 2, 11, 12 }; // < ^ > v A B Y X L R S s enum controllers controller; - int line = Settings.DisplayMovieFrame && S9xMovieActive() ? 2 : 1; + int line = 1; int8 ids[4]; char string[255]; @@ -2266,37 +2251,43 @@ void S9xDrawCrosshair (const char *crosshair, uint8 fgcolor, uint8 bgcolor, int1 fg = get_crosshair_color(fgcolor); bg = get_crosshair_color(bgcolor); - uint16 *s = GFX.Screen + y * (int32)GFX.RealPPL + x; - - for (r = 0; r < 15 * rx; r++, s += GFX.RealPPL - 15 * cx) + // XXX: FIXME: why does it crash without this on Linux port? There are no out-of-bound writes without it... +#if (defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP)) + if (x >= 0 && y >= 0) +#endif { - if (y + r < 0) + uint16 *s = GFX.Screen + y * GFX.RealPPL + x; + + for (r = 0; r < 15 * rx; r++, s += GFX.RealPPL - 15 * cx) { - s += 15 * cx; - continue; - } - - if (y + r >= H) - break; - - for (c = 0; c < 15 * cx; c++, s++) - { - if (x + c < 0 || s < GFX.Screen) - continue; - - if (x + c >= W) + if (y + r < 0) { - s += 15 * cx - c; - break; + s += 15 * cx; + continue; } - uint8 p = crosshair[(r / rx) * 15 + (c / cx)]; + if (y + r >= H) + break; - if (p == '#' && fgcolor) - *s = (fgcolor & 0x10) ? COLOR_ADD1_2(fg, *s) : fg; - else - if (p == '.' && bgcolor) - *s = (bgcolor & 0x10) ? COLOR_ADD1_2(*s, bg) : bg; + for (c = 0; c < 15 * cx; c++, s++) + { + if (x + c < 0 || s < GFX.Screen) + continue; + + if (x + c >= W) + { + s += 15 * cx - c; + break; + } + + uint8 p = crosshair[(r / rx) * 15 + (c / cx)]; + + if (p == '#' && fgcolor) + *s = (fgcolor & 0x10) ? COLOR_ADD1_2(fg, *s) : fg; + else + if (p == '.' && bgcolor) + *s = (bgcolor & 0x10) ? COLOR_ADD1_2(*s, bg) : bg; + } } } } diff --git a/source/snes9x/gfx.h b/source/snes9x/gfx.h index 64e93b3..75981cc 100644 --- a/source/snes9x/gfx.h +++ b/source/snes9x/gfx.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/globals.cpp b/source/snes9x/globals.cpp index a89e74c..54312dc 100644 --- a/source/snes9x/globals.cpp +++ b/source/snes9x/globals.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/language.h b/source/snes9x/language.h index 408a914..49a30ae 100644 --- a/source/snes9x/language.h +++ b/source/snes9x/language.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -210,7 +195,7 @@ #define SAVE_INFO_LOAD "Loaded" #define SAVE_INFO_OOPS "Auto-saving 'oops' snapshot" #define SAVE_ERR_WRONG_FORMAT "File not in Snes9x snapshot format" -#define SAVE_ERR_WRONG_VERSION "Incompatible snapshot version" +#define SAVE_ERR_WRONG_VERSION "Incompatable snapshot version" #define SAVE_ERR_ROM_NOT_FOUND "ROM image \"%s\" for snapshot not found" #define SAVE_ERR_SAVE_NOT_FOUND "Snapshot %s does not exist" diff --git a/source/snes9x/logger.cpp b/source/snes9x/logger.cpp index 6a0edb4..235c533 100644 --- a/source/snes9x/logger.cpp +++ b/source/snes9x/logger.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -189,12 +174,6 @@ Nintendo Co., Limited and its subsidiary companies. ***********************************************************************************/ -#ifdef GEKKO -void S9xResetLogger (void) { } -void S9xCloseLogger (void) { } -void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_per_line) { } -void S9xAudioLogger (void *samples, int length) { } -#else #include "snes9x.h" #include "movie.h" @@ -286,5 +265,3 @@ void S9xAudioLogger (void *samples, int length) ignore = fwrite(samples, 1, length, audio); } } - -#endif diff --git a/source/snes9x/logger.h b/source/snes9x/logger.h index a4dd102..63aa30b 100644 --- a/source/snes9x/logger.h +++ b/source/snes9x/logger.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/memmap.cpp b/source/snes9x/memmap.cpp index 82a4af0..2aa1d0a 100644 --- a/source/snes9x/memmap.cpp +++ b/source/snes9x/memmap.cpp @@ -183,6 +183,14 @@ #include #include +#ifdef UNZIP_SUPPORT +#include "unzip/unzip.h" +#endif + +#ifdef JMA_SUPPORT +#include "jma/s9x-jma.h" +#endif + #include "snes9x.h" #include "memmap.h" #include "apu/apu.h" @@ -1107,26 +1115,26 @@ bool8 CMemory::Init (void) return (FALSE); } - memset(RAM, 0, 0x20000); - memset(SRAM, 0, 0x20000); - memset(VRAM, 0, 0x10000); - memset(ROM, 0, MAX_ROM_SIZE + 0x200 + 0x8000); + ZeroMemory(RAM, 0x20000); + ZeroMemory(SRAM, 0x20000); + ZeroMemory(VRAM, 0x10000); + ZeroMemory(ROM, MAX_ROM_SIZE + 0x200 + 0x8000); - memset(IPPU.TileCache[TILE_2BIT], 0, MAX_2BIT_TILES * 64); - memset(IPPU.TileCache[TILE_4BIT], 0, MAX_4BIT_TILES * 64); - memset(IPPU.TileCache[TILE_8BIT], 0, MAX_8BIT_TILES * 64); - memset(IPPU.TileCache[TILE_2BIT_EVEN], 0, MAX_2BIT_TILES * 64); - memset(IPPU.TileCache[TILE_2BIT_ODD], 0, MAX_2BIT_TILES * 64); - memset(IPPU.TileCache[TILE_4BIT_EVEN], 0, MAX_4BIT_TILES * 64); - memset(IPPU.TileCache[TILE_4BIT_ODD], 0, MAX_4BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_2BIT], MAX_2BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_4BIT], MAX_4BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_8BIT], MAX_8BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_2BIT_EVEN], MAX_2BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_2BIT_ODD], MAX_2BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_4BIT_EVEN], MAX_4BIT_TILES * 64); + ZeroMemory(IPPU.TileCache[TILE_4BIT_ODD], MAX_4BIT_TILES * 64); - memset(IPPU.TileCached[TILE_2BIT], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT], 0, MAX_4BIT_TILES); - memset(IPPU.TileCached[TILE_8BIT], 0, MAX_8BIT_TILES); - memset(IPPU.TileCached[TILE_2BIT_EVEN], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_2BIT_ODD], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT_EVEN], 0, MAX_4BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT_ODD], 0, MAX_4BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_2BIT], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT], MAX_4BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_8BIT], MAX_8BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_2BIT_EVEN], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_2BIT_ODD], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT_EVEN], MAX_4BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT_ODD], MAX_4BIT_TILES); // FillRAM uses first 32K of ROM image area, otherwise space just // wasted. Might be read by the SuperFX code. @@ -1512,8 +1520,8 @@ bool8 CMemory::LoadROM (const char *filename) if (!filename || !*filename) return (FALSE); - memset(ROM,0, MAX_ROM_SIZE); - memset(&Multi, 0,sizeof(Multi)); + ZeroMemory(ROM, MAX_ROM_SIZE); + ZeroMemory(&Multi, sizeof(Multi)); again: Settings.DisplayColor = BUILD_PIXEL(31, 31, 31); @@ -1729,7 +1737,7 @@ again: LastRomFilename[PATH_MAX] = 0; } - memset(&SNESGameFixes, 0, sizeof(SNESGameFixes)); + ZeroMemory(&SNESGameFixes, sizeof(SNESGameFixes)); SNESGameFixes.SRAMInitialValue = 0x60; #ifdef GEKKO WiiSetupCheats(); @@ -1750,8 +1758,8 @@ bool8 CMemory::LoadMultiCart (const char *cartA, const char *cartB) { bool8 r = TRUE; - memset(ROM, 0, MAX_ROM_SIZE); - memset(&Multi, 0, sizeof(Multi)); + ZeroMemory(ROM, MAX_ROM_SIZE); + ZeroMemory(&Multi, sizeof(Multi)); Settings.DisplayColor = BUILD_PIXEL(31, 31, 31); SET_UI_COLOR(255, 255, 255); @@ -1801,11 +1809,11 @@ bool8 CMemory::LoadMultiCart (const char *cartA, const char *cartB) if (!r) { - memset(&Multi, 0, sizeof(Multi)); + ZeroMemory(&Multi, sizeof(Multi)); return (FALSE); } - memset(&SNESGameFixes, 0, sizeof(SNESGameFixes)); + ZeroMemory(&SNESGameFixes, sizeof(SNESGameFixes)); SNESGameFixes.SRAMInitialValue = 0x60; S9xLoadCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); @@ -2808,18 +2816,8 @@ void CMemory::map_WRAM (void) void CMemory::map_LoROMSRAM (void) { - uint32 hi; - - if (SRAMSize == 0) - return; - - if (ROMSize > 11 || SRAMSize > 5) - hi = 0x7fff; - else - hi = 0xffff; - - map_index(0x70, 0x7d, 0x0000, hi, MAP_LOROM_SRAM, MAP_TYPE_RAM); - map_index(0xf0, 0xff, 0x0000, hi, MAP_LOROM_SRAM, MAP_TYPE_RAM); + map_index(0x70, 0x7f, 0x0000, 0x7fff, MAP_LOROM_SRAM, MAP_TYPE_RAM); + map_index(0xf0, 0xff, 0x0000, 0x7fff, MAP_LOROM_SRAM, MAP_TYPE_RAM); } void CMemory::map_HiROMSRAM (void) @@ -2971,7 +2969,7 @@ void CMemory::Map_JumboLoROMMap (void) map_System(); map_lorom_offset(0x00, 0x3f, 0x8000, 0xffff, CalculatedSize - 0x400000, 0x400000); - map_lorom_offset(0x40, 0x7f, 0x0000, 0xffff, CalculatedSize - 0x600000, 0x600000); + map_lorom_offset(0x40, 0x7f, 0x0000, 0xffff, CalculatedSize - 0x400000, 0x400000); map_lorom_offset(0x80, 0xbf, 0x8000, 0xffff, 0x400000, 0); map_lorom_offset(0xc0, 0xff, 0x0000, 0xffff, 0x400000, 0x200000); diff --git a/source/snes9x/messages.h b/source/snes9x/messages.h index 168ec52..f346a7c 100644 --- a/source/snes9x/messages.h +++ b/source/snes9x/messages.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/missing.h b/source/snes9x/missing.h index 8c2dd11..9a41fab 100644 --- a/source/snes9x/missing.h +++ b/source/snes9x/missing.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/movie.cpp b/source/snes9x/movie.cpp index d68cbbe..31d0765 100644 --- a/source/snes9x/movie.cpp +++ b/source/snes9x/movie.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -452,14 +437,14 @@ static void reset_controllers (void) MovieSetJoypad(i, 0); uint8 clearedMouse[MOUSE_DATA_SIZE]; - memset(clearedMouse, 0, MOUSE_DATA_SIZE); + ZeroMemory(clearedMouse, MOUSE_DATA_SIZE); clearedMouse[4] = 1; uint8 clearedScope[SCOPE_DATA_SIZE]; - memset(clearedScope, 0, SCOPE_DATA_SIZE); + ZeroMemory(clearedScope, SCOPE_DATA_SIZE); uint8 clearedJustifier[JUSTIFIER_DATA_SIZE]; - memset(clearedJustifier, 0, JUSTIFIER_DATA_SIZE); + ZeroMemory(clearedJustifier, JUSTIFIER_DATA_SIZE); for (int p = 0; p < 2; p++) { @@ -654,7 +639,7 @@ static void write_movie_header (FILE *fd, SMovie *movie) { uint8 buf[SMV_HEADER_SIZE], *ptr = buf; - memset(buf, 0, sizeof(buf)); + ZeroMemory(buf, sizeof(buf)); Write32(SMV_MAGIC, ptr); Write32(SMV_VERSION, ptr); @@ -786,8 +771,7 @@ int S9xMovieUnfreeze (uint8 *buf, uint32 size) } else { - uint32 space_processed = (Movie.BytesPerSample * (current_sample + 1)); - if (current_frame > Movie.MaxFrame || current_sample > Movie.MaxSample || memcmp(Movie.InputBuffer, ptr, space_processed)) + if (current_frame > Movie.MaxFrame || current_sample > Movie.MaxSample || memcmp(Movie.InputBuffer, ptr, space_needed)) return (SNAPSHOT_INCONSISTENT); change_state(MOVIE_STATE_PLAY); @@ -828,16 +812,14 @@ int S9xMovieOpen (const char *filename, bool8 read_only) read_movie_extrarominfo(fd, &Movie); - fflush(fd); - fn = fileno(fd); + fn = dup(fileno(fd)); + fclose(fd); store_previous_settings(); restore_movie_settings(); lseek(fn, Movie.SaveStateOffset, SEEK_SET); - - // reopen stream to access as gzipped data - stream = REOPEN_STREAM(fn, "rb"); + stream = REOPEN_STREAM(fn, "rb"); if (!stream) return (FILE_NOT_FOUND); @@ -850,11 +832,7 @@ int S9xMovieOpen (const char *filename, bool8 read_only) else result = S9xUnfreezeFromStream(stream); - // do not close stream but close FILE * - // (msvcrt will try to close all open FILE *handles on exit - if we do CLOSE_STREAM here - // the underlying file will be closed by zlib, causing problems when msvcrt tries to do it) - delete stream; - fclose(fd); + CLOSE_STREAM(stream); if (result != SUCCESS) return (result); @@ -868,10 +846,7 @@ int S9xMovieOpen (const char *filename, bool8 read_only) } if (fseek(fd, Movie.ControllerDataOffset, SEEK_SET)) - { - fclose(fd); return (WRONG_FORMAT); - } Movie.File = fd; Movie.BytesPerSample = bytes_per_sample(); @@ -904,6 +879,7 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co { FILE *fd; STREAM stream; + int fn; if (controllers_mask == 0) return (WRONG_FORMAT); @@ -952,9 +928,10 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co write_movie_extrarominfo(fd, &Movie); + fn = dup(fileno(fd)); fclose(fd); - stream = OPEN_STREAM(filename, "ab"); + stream = REOPEN_STREAM(fn, "ab"); if (!stream) return (FILE_NOT_FOUND); @@ -1012,17 +989,14 @@ int S9xMovieGetInfo (const char *filename, struct MovieInfo *info) flush_movie(); - memset(info, 0, sizeof(*info)); + ZeroMemory(info, sizeof(*info)); if (!(fd = fopen(filename, "rb"))) return (FILE_NOT_FOUND); result = read_movie_header(fd, &local_movie); if (result != SUCCESS) - { - fclose(fd); return (result); - } info->TimeCreated = (time_t) local_movie.MovieId; info->Version = local_movie.Version; @@ -1061,10 +1035,9 @@ int S9xMovieGetInfo (const char *filename, struct MovieInfo *info) strncpy(info->ROMName, local_movie.ROMName, 23); fclose(fd); - if ((fd = fopen(filename, "r+")) == NULL) + + if (access(filename, W_OK)) info->ReadOnly = true; - else - fclose(fd); return (SUCCESS); } @@ -1144,7 +1117,7 @@ void S9xMovieUpdateOnReset (void) void S9xMovieInit (void) { - memset(&Movie, 0, sizeof(Movie)); + ZeroMemory(&Movie, sizeof(Movie)); Movie.State = MOVIE_STATE_NONE; } diff --git a/source/snes9x/movie.h b/source/snes9x/movie.h index ff8eed5..f1fb2bb 100644 --- a/source/snes9x/movie.h +++ b/source/snes9x/movie.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -199,8 +184,10 @@ #define MOVIE_OPT_NOSAVEDATA (1 << 2) #define MOVIE_SYNC_DATA_EXISTS 0x01 #define MOVIE_SYNC_OBSOLETE 0x02 +#define MOVIE_SYNC_LEFTRIGHT 0x04 #define MOVIE_SYNC_VOLUMEENVX 0x08 #define MOVIE_SYNC_FAKEMUTE 0x10 +#define MOVIE_SYNC_SYNCSOUND 0x20 #define MOVIE_SYNC_HASROMINFO 0x40 #define MOVIE_SYNC_NOCPUSHUTDOWN 0x80 #define MOVIE_MAX_METADATA 512 diff --git a/source/snes9x/msu1.cpp b/source/snes9x/msu1.cpp index d071b99..546dc0e 100644 --- a/source/snes9x/msu1.cpp +++ b/source/snes9x/msu1.cpp @@ -22,12 +22,10 @@ (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2016 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -140,7 +138,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2016 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,14 +146,14 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2016 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles (c) Copyright 2001 - 2011 zones Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -192,13 +190,12 @@ Nintendo Co., Limited and its subsidiary companies. ***********************************************************************************/ -#include "snes9x.h" -#include "memmap.h" -#include "display.h" #include "msu1.h" +#include "display.h" +#include "filebrowser.h" +#include "memmap.h" +#include "snes9xgx.h" #include "apu/blargg_endian.h" -#include -#include STREAM dataStream = NULL; STREAM audioStream = NULL; @@ -244,7 +241,7 @@ static int unzFindExtension(unzFile &file, const char *ext, bool restart = TRUE, STREAM S9xMSU1OpenFile(const char *msu_ext, bool skip_unpacked) { - char filename[1024]; + char filename[MAXPATHLEN]; sprintf(filename, "%s%s%s", Memory.ROMFilePath, Memory.ROMFilename, msu_ext); STREAM file = 0; @@ -260,15 +257,10 @@ STREAM S9xMSU1OpenFile(const char *msu_ext, bool skip_unpacked) // look for msu1 pack file in the rom or patch dir if msu data file not found in rom dir if (!file) { - const char *zip_filename = S9xGetFilename(".msu1", ROMFILENAME_DIR); + char zip_filename[MAXPATHLEN]; + sprintf(zip_filename, "%s%s.msu1", Memory.ROMFilePath, Memory.ROMFilename); unzFile unzFile = unzOpen(zip_filename); - if (!unzFile) - { - zip_filename = S9xGetFilename(".msu1", PATCH_DIR); - unzFile = unzOpen(zip_filename); - } - if (unzFile) { int port = unzFindExtension(unzFile, msu_ext, true, true, true); @@ -320,8 +312,8 @@ static bool AudioOpen() audioLoopPos = GET_LE32(&audioLoopPos); audioLoopPos <<= 2; audioLoopPos += 8; - - MSU1.MSU1_AUDIO_POS = 8; + + MSU1.MSU1_AUDIO_POS = 8; MSU1.MSU1_STATUS &= ~AudioError; return true; @@ -389,6 +381,7 @@ void S9xMSU1DeInit(void) AudioClose(); } + bool S9xMSU1ROMExists(void) { STREAM s = S9xMSU1OpenFile(".msu"); @@ -398,15 +391,9 @@ bool S9xMSU1ROMExists(void) return true; } #ifdef UNZIP_SUPPORT - char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1]; - _splitpath(Memory.ROMFilename, drive, dir, def, ext); - if (!strcasecmp(ext, ".msu1")) - return true; - - unzFile unzFile = unzOpen(S9xGetFilename(".msu1", ROMFILENAME_DIR)); - - if(!unzFile) - unzFile = unzOpen(S9xGetFilename(".msu1", PATCH_DIR)); + char fname[MAXPATHLEN]; + sprintf(fname, "%s%s.msu1", Memory.ROMFilePath, Memory.ROMFilename); + unzFile unzFile = unzOpen(fname); if (unzFile) { @@ -429,15 +416,14 @@ void S9xMSU1Generate(size_t sample_count) int16* left = (int16*)&sample; int16* right = left + 1; - int bytes_read = READ_STREAM((char *)&sample, 4, audioStream); + int bytes_read = READ_STREAM((char *)&sample, 4, audioStream); if (bytes_read == 4) { *left = ((int32)(int16)GET_LE16(left) * MSU1.MSU1_VOLUME / 255); *right = ((int32)(int16)GET_LE16(right) * MSU1.MSU1_VOLUME / 255); - *(bufPos++) = *left; - *(bufPos++) = *right; + *(bufPos++) = *right; MSU1.MSU1_AUDIO_POS += 4; partial_frames -= 3204; } @@ -447,12 +433,12 @@ void S9xMSU1Generate(size_t sample_count) if (MSU1.MSU1_STATUS & AudioRepeating) { MSU1.MSU1_AUDIO_POS = audioLoopPos; - REVERT_STREAM(audioStream, MSU1.MSU1_AUDIO_POS, 0); + REVERT_STREAM(audioStream, MSU1.MSU1_AUDIO_POS, 0); } else { MSU1.MSU1_STATUS &= ~(AudioPlaying | AudioRepeating); - REVERT_STREAM(audioStream, 8, 0); + REVERT_STREAM(audioStream, 8, 0); } } else diff --git a/source/snes9x/msu1.h b/source/snes9x/msu1.h index 8537613..add366b 100644 --- a/source/snes9x/msu1.h +++ b/source/snes9x/msu1.h @@ -22,12 +22,10 @@ (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2016 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -140,7 +138,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2016 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,14 +146,14 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2016 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles (c) Copyright 2001 - 2011 zones Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -195,6 +193,8 @@ #ifndef _MSU1_H_ #define _MSU1_H_ #include "snes9x.h" +#include +#include #define MSU1_REVISION 0x02 @@ -215,8 +215,8 @@ struct SMSU1 enum SMSU1_FLAG { Revision = 0x07, // bitmask, not the actual version number AudioError = 0x08, - AudioPlaying = 0x10, - AudioRepeating = 0x20, + AudioPlaying = 0x10, + AudioRepeating = 0x20, AudioBusy = 0x40, DataBusy = 0x80 }; diff --git a/source/snes9x/obc1.cpp b/source/snes9x/obc1.cpp index 803f6a1..9fe98de 100644 --- a/source/snes9x/obc1.cpp +++ b/source/snes9x/obc1.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/obc1.h b/source/snes9x/obc1.h index a8de868..836850b 100644 --- a/source/snes9x/obc1.h +++ b/source/snes9x/obc1.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/pixform.h b/source/snes9x/pixform.h index 51b143e..1760899 100644 --- a/source/snes9x/pixform.h +++ b/source/snes9x/pixform.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/port.h b/source/snes9x/port.h index f884d03..ef94ded 100644 --- a/source/snes9x/port.h +++ b/source/snes9x/port.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -196,7 +181,7 @@ #include #include #include -#ifndef __LIBRETRO__ +#ifndef GEKKO #include #endif #include @@ -216,14 +201,7 @@ #define RIGHTSHIFT_int8_IS_SAR #define RIGHTSHIFT_int16_IS_SAR #define RIGHTSHIFT_int32_IS_SAR -#ifndef __LIBRETRO__ #define SNES_JOY_READ_CALLBACKS -#define GFX_MULTI_FORMAT -#endif //__LIBRETRO__ -#endif - -#ifdef __LIBRETRO__ -#define GFX_MULTI_FORMAT #endif #ifdef __MACOSX__ @@ -252,22 +230,30 @@ typedef uint64_t uint64; #else // HAVE_STDINT_H #ifdef __WIN32__ typedef intptr_t pint; +#else // __WIN32__ +#ifdef PTR_NOT_INT +typedef long pint; +#else +typedef int pint; +#endif +#endif // __WIN32__ +#ifdef __WIN32__ +#ifdef __BORLANDC__ +#include +#else typedef signed char int8; typedef unsigned char uint8; typedef signed short int16; typedef unsigned short uint16; -typedef signed int int32; +#ifndef WSAAP +// winsock2.h typedefs int32 as well +typedef signed int int32; +#endif typedef unsigned int uint32; +#endif +typedef unsigned char uint8_t; typedef signed __int64 int64; typedef unsigned __int64 uint64; -typedef int8 int8_t; -typedef uint8 uint8_t; -typedef int16 int16_t; -typedef uint16 uint16_t; -typedef int32 int32_t; -typedef uint32 uint32_t; -typedef int64 int64_t; -typedef uint64 uint64_t; typedef int socklen_t; #else // __WIN32__ typedef signed char int8; @@ -282,11 +268,6 @@ __extension__ #endif typedef long long int64; typedef unsigned long long uint64; -#ifdef PTR_NOT_INT -typedef size_t pint; -#else // __PTR_NOT_INT -typedef size_t pint; -#endif // __PTR_NOT_INT #endif // __WIN32__ #endif // HAVE_STDINT_H #endif // snes9x_types_defined @@ -317,24 +298,21 @@ typedef size_t pint; #endif #ifndef __WIN32__ +#define ZeroMemory(a, b) memset((a), 0, (b)) void _splitpath (const char *, char *, char *, char *, char *); void _makepath (char *, const char *, const char *, const char *, const char *); #define S9xDisplayString DisplayStringFromBottom -#else // __WIN32__ +#else #define snprintf _snprintf #define strcasecmp stricmp #define strncasecmp strnicmp -#ifndef __LIBRETRO__ void WinDisplayStringFromBottom(const char *string, int linesFromBottom, int pixelsFromLeft, bool allowWrap); #define S9xDisplayString WinDisplayStringFromBottom void SetInfoDlgColor(unsigned char, unsigned char, unsigned char); #define SET_UI_COLOR(r,g,b) SetInfoDlgColor(r,g,b) -#else // __LIBRETRO__ -#define S9xDisplayString DisplayStringFromBottom -#endif // __LIBRETRO__ -#endif // __WIN32__ +#endif -#if defined(__DJGPP) || defined(__WIN32__) +#ifdef __DJGPP #define SLASH_STR "\\" #define SLASH_CHAR '\\' #else @@ -355,7 +333,7 @@ void SetInfoDlgColor(unsigned char, unsigned char, unsigned char); #define TITLE "Snes9x" #endif -#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86) || defined(_M_X64) || defined(_XBOX1) || defined(ARM) || defined(ANDROID) +#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__x86_64__) || defined(__alpha__) || defined(__MIPSEL__) || defined(_M_IX86) || defined(_M_X64) #define LSB_FIRST #define FAST_LSB_WORD_ACCESS #else diff --git a/source/snes9x/ppu.cpp b/source/snes9x/ppu.cpp index a1a31e7..b28ed8d 100644 --- a/source/snes9x/ppu.cpp +++ b/source/snes9x/ppu.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -219,6 +204,9 @@ static inline void S9xLatchCounters (bool force) #ifdef DEBUGGER missing.h_v_latch = 1; #endif + #if 0 // #ifdef CPU_SHUTDOWN + CPU.WaitAddress = CPU.PCAtOpcodeStart; + #endif PPU.HVBeamCounterLatched = 1; PPU.VBeamPosLatched = (uint16) CPU.V_Counter; @@ -257,6 +245,9 @@ static inline void S9xTryGunLatch (bool force) #ifdef DEBUGGER missing.h_v_latch = 1; #endif + #if 0 // #ifdef CPU_SHUTDOWN + CPU.WaitAddress = CPU.PCAtOpcodeStart; + #endif PPU.HVBeamCounterLatched = 1; PPU.VBeamPosLatched = (uint16) PPU.GunVLatch; @@ -523,9 +514,9 @@ void S9xSetPPU (uint8 Byte, uint16 Address) if (PPU.Brightness != (Byte & 0xf)) { IPPU.ColorsChanged = TRUE; + IPPU.DirectColourMapsNeedRebuild = TRUE; PPU.Brightness = Byte & 0xf; S9xFixColourBrightness(); - S9xBuildDirectColourMaps(); if (PPU.Brightness > IPPU.MaxBrightness) IPPU.MaxBrightness = PPU.Brightness; } @@ -630,10 +621,7 @@ void S9xSetPPU (uint8 Byte, uint16 Address) PPU.BGMode = Byte & 7; // BJ: BG3Priority only takes effect if BGMode == 1 and the bit is set PPU.BG3Priority = ((Byte & 0x0f) == 0x09); - if (PPU.BGMode == 6 || PPU.BGMode == 5 || PPU.BGMode == 7) - IPPU.Interlace = Memory.FillRAM[0x2133] & 1; - else - IPPU.Interlace = 0; + IPPU.Interlace = Memory.FillRAM[0x2133] & 1; #ifdef DEBUGGER missing.modes[PPU.BGMode] = 1; #endif @@ -1158,20 +1146,13 @@ void S9xSetPPU (uint8 Byte, uint16 Address) #endif } else - { PPU.ScreenHeight = SNES_HEIGHT; - if (IPPU.DoubleHeightPixels) - IPPU.RenderedScreenHeight = PPU.ScreenHeight << 1; - else - IPPU.RenderedScreenHeight = PPU.ScreenHeight; - } if ((Memory.FillRAM[0x2133] ^ Byte) & 3) { FLUSH_REDRAW(); if ((Memory.FillRAM[0x2133] ^ Byte) & 2) IPPU.OBJChanged = TRUE; - IPPU.Interlace = Byte & 1; IPPU.InterlaceOBJ = Byte & 2; } @@ -1279,9 +1260,9 @@ uint8 S9xGetPPU (uint16 Address) { // MAP_PPU: $2000-$3FFF - if (Settings.MSU1 && (Address & 0xfff8) == 0x2000) + if (Settings.MSU1 && (Address & 0xfff8) == 0x2000) return (S9xMSU1ReadPort(Address & 7)); - else + if (Address < 0x2100) return (OpenBus); @@ -1560,7 +1541,7 @@ uint8 S9xGetPPU (uint16 Address) else if (Settings.BS && Address >= 0x2188 && Address <= 0x219f) return (S9xGetBSXPPU(Address)); - else + else if (Settings.SRTC && Address == 0x2800) return (S9xGetSRTC(Address)); else @@ -2128,7 +2109,7 @@ void S9xSoftResetPPU (void) PPU.OAMReadFlip = 0; PPU.OAMTileAddress = 0; PPU.OAMWriteRegister = 0; - memset(PPU.OAMData, 0, 512 + 32); + ZeroMemory(PPU.OAMData, 512 + 32); PPU.FirstSprite = 0; PPU.LastSprite = 127; @@ -2202,19 +2183,19 @@ void S9xSoftResetPPU (void) memset(&IPPU.Clip[c], 0, sizeof(struct ClipData)); IPPU.ColorsChanged = TRUE; IPPU.OBJChanged = TRUE; - memset(IPPU.TileCached[TILE_2BIT], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT], 0, MAX_4BIT_TILES); - memset(IPPU.TileCached[TILE_8BIT], 0, MAX_8BIT_TILES); - memset(IPPU.TileCached[TILE_2BIT_EVEN], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_2BIT_ODD], 0, MAX_2BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT_EVEN], 0, MAX_4BIT_TILES); - memset(IPPU.TileCached[TILE_4BIT_ODD], 0, MAX_4BIT_TILES); + IPPU.DirectColourMapsNeedRebuild = TRUE; + ZeroMemory(IPPU.TileCached[TILE_2BIT], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT], MAX_4BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_8BIT], MAX_8BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_2BIT_EVEN], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_2BIT_ODD], MAX_2BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT_EVEN], MAX_4BIT_TILES); + ZeroMemory(IPPU.TileCached[TILE_4BIT_ODD], MAX_4BIT_TILES); #ifdef CORRECT_VRAM_READS IPPU.VRAMReadBuffer = 0; // XXX: FIXME: anything better? #else IPPU.FirstVRAMRead = FALSE; #endif - GFX.InterlaceFrame = 0; IPPU.Interlace = FALSE; IPPU.InterlaceOBJ = FALSE; IPPU.DoubleWidthPixels = FALSE; @@ -2235,16 +2216,14 @@ void S9xSoftResetPPU (void) IPPU.FrameSkip = 0; S9xFixColourBrightness(); - S9xBuildDirectColourMaps(); for (int c = 0; c < 0x8000; c += 0x100) memset(&Memory.FillRAM[c], c >> 8, 0x100); - memset(&Memory.FillRAM[0x2100], 0, 0x100); - memset(&Memory.FillRAM[0x4200], 0, 0x100); - memset(&Memory.FillRAM[0x4000], 0, 0x100); + ZeroMemory(&Memory.FillRAM[0x2100], 0x100); + ZeroMemory(&Memory.FillRAM[0x4200], 0x100); + ZeroMemory(&Memory.FillRAM[0x4000], 0x100); // For BS Suttehakkun 2... - memset(&Memory.FillRAM[0x1000], 0, 0x1000); + ZeroMemory(&Memory.FillRAM[0x1000], 0x1000); Memory.FillRAM[0x4201] = Memory.FillRAM[0x4213] = 0xff; - Memory.FillRAM[0x2126] = Memory.FillRAM[0x2128] = 1; } diff --git a/source/snes9x/ppu.h b/source/snes9x/ppu.h index a3dd083..7f20e89 100644 --- a/source/snes9x/ppu.h +++ b/source/snes9x/ppu.h @@ -215,6 +215,7 @@ struct InternalPPU struct ClipData Clip[2][6]; bool8 ColorsChanged; bool8 OBJChanged; + bool8 DirectColourMapsNeedRebuild; uint8 *TileCache[7]; uint8 *TileCached[7]; #ifdef CORRECT_VRAM_READS diff --git a/source/snes9x/reader.cpp b/source/snes9x/reader.cpp index 8c2f7b5..fa7ba1e 100644 --- a/source/snes9x/reader.cpp +++ b/source/snes9x/reader.cpp @@ -178,6 +178,9 @@ // Abstract the details of reading from zip files versus FILE *'s. #include +#ifdef UNZIP_SUPPORT +#include "unzip.h" +#endif #include "snes9x.h" #include "reader.h" diff --git a/source/snes9x/sar.h b/source/snes9x/sar.h index 9bc6555..f53de57 100644 --- a/source/snes9x/sar.h +++ b/source/snes9x/sar.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/screenshot.cpp b/source/snes9x/screenshot.cpp index 8410944..ec8f750 100644 --- a/source/snes9x/screenshot.cpp +++ b/source/snes9x/screenshot.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/screenshot.h b/source/snes9x/screenshot.h index 1cb6efc..6839ba0 100644 --- a/source/snes9x/screenshot.h +++ b/source/snes9x/screenshot.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1.cpp b/source/snes9x/sdd1.cpp index f56b4b1..40cd4c9 100644 --- a/source/snes9x/sdd1.cpp +++ b/source/snes9x/sdd1.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1.h b/source/snes9x/sdd1.h index 244704f..7419b5b 100644 --- a/source/snes9x/sdd1.h +++ b/source/snes9x/sdd1.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1emu.cpp b/source/snes9x/sdd1emu.cpp index 00e0c79..c4f4d36 100644 --- a/source/snes9x/sdd1emu.cpp +++ b/source/snes9x/sdd1emu.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1emu.h b/source/snes9x/sdd1emu.h index a53c9b9..5722b4b 100644 --- a/source/snes9x/sdd1emu.h +++ b/source/snes9x/sdd1emu.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta.cpp b/source/snes9x/seta.cpp index c726399..e7fd24c 100644 --- a/source/snes9x/seta.cpp +++ b/source/snes9x/seta.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta.h b/source/snes9x/seta.h index 2cd64ea..ee49097 100644 --- a/source/snes9x/seta.h +++ b/source/snes9x/seta.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta010.cpp b/source/snes9x/seta010.cpp index dce3ee6..45cf877 100644 --- a/source/snes9x/seta010.cpp +++ b/source/snes9x/seta010.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -231,72 +216,72 @@ static const int16 ST010_SinTable[256] = -0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324 }; -static const uint8 ST010_ArcTan[32][32] = +static const uint8 ST010_ArcTan[32][32] = { - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 0x40, 0x20, 0x13, 0x0D, 0x0A, 0x08, 0x07, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01 }, - { 0x40, 0x2D, 0x20, 0x18, 0x13, 0x10, 0x0D, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x07, 0x06, 0x06, 0x05, - 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }, - { 0x40, 0x33, 0x28, 0x20, 0x1A, 0x16, 0x13, 0x10, 0x0F, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x09, 0x08, - 0x08, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04 }, - { 0x40, 0x36, 0x2D, 0x26, 0x20, 0x1B, 0x18, 0x15, 0x13, 0x11, 0x10, 0x0E, 0x0D, 0x0C, 0x0B, 0x0B, - 0x0A, 0x09, 0x09, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05 }, - { 0x40, 0x38, 0x30, 0x2A, 0x25, 0x20, 0x1C, 0x19, 0x17, 0x15, 0x13, 0x11, 0x10, 0x0F, 0x0E, 0x0D, - 0x0C, 0x0C, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07 }, - { 0x40, 0x39, 0x33, 0x2D, 0x28, 0x24, 0x20, 0x1D, 0x1A, 0x18, 0x16, 0x14, 0x13, 0x12, 0x10, 0x10, - 0x0F, 0x0E, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08 }, - { 0x40, 0x3A, 0x35, 0x30, 0x2B, 0x27, 0x23, 0x20, 0x1D, 0x1B, 0x19, 0x17, 0x16, 0x14, 0x13, 0x12, - 0x11, 0x10, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A, 0x0A, 0x09, 0x09 }, - { 0x40, 0x3B, 0x36, 0x31, 0x2D, 0x29, 0x26, 0x23, 0x20, 0x1E, 0x1B, 0x1A, 0x18, 0x16, 0x15, 0x14, - 0x13, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0B, 0x0A }, - { 0x40, 0x3B, 0x37, 0x33, 0x2F, 0x2B, 0x28, 0x25, 0x22, 0x20, 0x1E, 0x1C, 0x1A, 0x19, 0x17, 0x16, - 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0C }, - { 0x40, 0x3C, 0x38, 0x34, 0x30, 0x2D, 0x2A, 0x27, 0x25, 0x20, 0x20, 0x1E, 0x1C, 0x1B, 0x19, 0x18, - 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x11, 0x10, 0x10, 0x0F, 0x0E, 0x0E, 0x0E, 0x0D, 0x0D }, - { 0x40, 0x3C, 0x39, 0x35, 0x32, 0x2F, 0x2C, 0x29, 0x26, 0x24, 0x22, 0x20, 0x1E, 0x1D, 0x1B, 0x1A, - 0x19, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E }, - { 0x40, 0x3D, 0x39, 0x36, 0x33, 0x30, 0x2D, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1E, 0x1D, 0x1B, - 0x1A, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x0F }, - { 0x40, 0x3D, 0x3A, 0x37, 0x34, 0x31, 0x2E, 0x2C, 0x2A, 0x27, 0x25, 0x23, 0x22, 0x20, 0x1E, 0x1D, - 0x1C, 0x1B, 0x19, 0x18, 0x17, 0x17, 0x16, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12, 0x11, 0x11, 0x10 }, - { 0x40, 0x3D, 0x3A, 0x37, 0x35, 0x32, 0x30, 0x2D, 0x2B, 0x29, 0x27, 0x25, 0x23, 0x22, 0x20, 0x1F, - 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x16, 0x15, 0x14, 0x13, 0x13, 0x12, 0x12, 0x11 }, - { 0x40, 0x3D, 0x3B, 0x38, 0x35, 0x33, 0x30, 0x2E, 0x2C, 0x2A, 0x28, 0x26, 0x25, 0x23, 0x21, 0x20, - 0x1F, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16, 0x15, 0x15, 0x14, 0x13, 0x13, 0x12 }, - { 0x40, 0x3D, 0x3B, 0x38, 0x36, 0x34, 0x31, 0x2F, 0x2D, 0x2B, 0x29, 0x27, 0x26, 0x24, 0x23, 0x21, - 0x20, 0x1F, 0x1E, 0x1D, 0x1B, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x13 }, - { 0x40, 0x3E, 0x3B, 0x39, 0x37, 0x34, 0x32, 0x30, 0x2E, 0x2C, 0x2A, 0x29, 0x27, 0x25, 0x24, 0x23, - 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16, 0x16, 0x15, 0x14 }, - { 0x40, 0x3E, 0x3B, 0x39, 0x37, 0x35, 0x33, 0x31, 0x2F, 0x2D, 0x2B, 0x2A, 0x28, 0x27, 0x25, 0x24, - 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17, 0x17, 0x16, 0x15 }, - { 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2E, 0x2C, 0x2B, 0x29, 0x28, 0x26, 0x25, - 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x1A, 0x19, 0x18, 0x18, 0x17, 0x16 }, - { 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2F, 0x2D, 0x2C, 0x2A, 0x29, 0x27, 0x26, - 0x25, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17 }, - { 0x40, 0x3E, 0x3C, 0x3A, 0x38, 0x36, 0x35, 0x33, 0x31, 0x30, 0x2E, 0x2C, 0x2B, 0x29, 0x28, 0x27, - 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1C, 0x1B, 0x1A, 0x1A, 0x19, 0x18 }, - { 0x40, 0x3E, 0x3C, 0x3A, 0x39, 0x37, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2D, 0x2C, 0x2A, 0x29, 0x28, - 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1D, 0x1C, 0x1B, 0x1A, 0x1A, 0x19 }, - { 0x40, 0x3E, 0x3C, 0x3B, 0x39, 0x37, 0x36, 0x34, 0x32, 0x31, 0x2F, 0x2E, 0x2C, 0x2B, 0x2A, 0x28, - 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B, 0x1A }, - { 0x40, 0x3E, 0x3D, 0x3B, 0x39, 0x38, 0x36, 0x34, 0x33, 0x31, 0x30, 0x2E, 0x2D, 0x2C, 0x2A, 0x29, - 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1B, 0x1B }, - { 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2C, 0x2B, 0x2A, - 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C, 0x1C }, - { 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x38, 0x37, 0x35, 0x34, 0x32, 0x31, 0x30, 0x2E, 0x2D, 0x2C, 0x2B, - 0x2A, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1E, 0x1D, 0x1C }, - { 0x40, 0x3E, 0x3D, 0x3B, 0x3A, 0x39, 0x37, 0x36, 0x34, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2D, 0x2B, - 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1F, 0x1E, 0x1D }, - { 0x40, 0x3F, 0x3D, 0x3C, 0x3A, 0x39, 0x37, 0x36, 0x35, 0x33, 0x32, 0x31, 0x30, 0x2E, 0x2D, 0x2C, - 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x22, 0x21, 0x20, 0x1F, 0x1F, 0x1E }, - { 0x40, 0x3F, 0x3D, 0x3C, 0x3A, 0x39, 0x38, 0x36, 0x35, 0x34, 0x32, 0x31, 0x30, 0x2F, 0x2E, 0x2D, - 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1F, 0x1F }, - { 0x40, 0x3F, 0x3D, 0x3C, 0x3B, 0x39, 0x38, 0x37, 0x35, 0x34, 0x33, 0x32, 0x30, 0x2F, 0x2E, 0x2D, - 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x25, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1F }, - { 0x40, 0x3F, 0x3D, 0x3C, 0x3B, 0x39, 0x38, 0x37, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2F, 0x2E, - 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x24, 0x23, 0x22, 0x21, 0x21, 0x20 } + { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }, + { 0x80, 0xa0, 0xad, 0xb3, 0xb6, 0xb8, 0xb9, 0xba, 0xbb, 0xbb, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, + 0xbd, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbf, 0xbf, 0xbf, 0xbf }, + { 0x80, 0x93, 0xa0, 0xa8, 0xad, 0xb0, 0xb3, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, + 0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd }, + { 0x80, 0x8d, 0x98, 0xa0, 0xa6, 0xaa, 0xad, 0xb0, 0xb1, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb7, 0xb8, + 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xba, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbc, 0xbc, 0xbc, 0xbc }, + { 0x80, 0x8a, 0x93, 0x9a, 0xa0, 0xa5, 0xa8, 0xab, 0xad, 0xaf, 0xb0, 0xb2, 0xb3, 0xb4, 0xb5, 0xb5, + 0xb6, 0xb7, 0xb7, 0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xba, 0xba, 0xba, 0xba, 0xba, 0xbb, 0xbb }, + { 0x80, 0x88, 0x90, 0x96, 0x9b, 0xa0, 0xa4, 0xa7, 0xa9, 0xab, 0xad, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, + 0xb4, 0xb4, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb8, 0xb8, 0xb8, 0xb9, 0xb9, 0xb9, 0xb9, 0xb9 }, + { 0x80, 0x87, 0x8d, 0x93, 0x98, 0x9c, 0xa0, 0xa3, 0xa6, 0xa8, 0xaa, 0xac, 0xad, 0xae, 0xb0, 0xb0, + 0xb1, 0xb2, 0xb3, 0xb4, 0xb4, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb8, 0xb8 }, + { 0x80, 0x86, 0x8b, 0x90, 0x95, 0x99, 0x9d, 0xa0, 0xa3, 0xa5, 0xa7, 0xa9, 0xaa, 0xac, 0xad, 0xae, + 0xaf, 0xb0, 0xb1, 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb4, 0xb5, 0xb5, 0xb6, 0xb6, 0xb6, 0xb7, 0xb7 }, + { 0x80, 0x85, 0x8a, 0x8f, 0x93, 0x97, 0x9a, 0x9d, 0xa0, 0xa2, 0xa5, 0xa6, 0xa8, 0xaa, 0xab, 0xac, + 0xad, 0xae, 0xaf, 0xb0, 0xb0, 0xb1, 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb4, 0xb5, 0xb5, 0xb5, 0xb5 }, + { 0x80, 0x85, 0x89, 0x8d, 0x91, 0x95, 0x98, 0x9b, 0x9e, 0xa0, 0xa0, 0xa4, 0xa6, 0xa7, 0xa9, 0xaa, + 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb0, 0xb1, 0xb1, 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb4, 0xb4 }, + { 0x80, 0x84, 0x88, 0x8c, 0x90, 0x93, 0x96, 0x99, 0x9b, 0x9e, 0xa0, 0xa2, 0xa4, 0xa5, 0xa7, 0xa8, + 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaf, 0xb0, 0xb0, 0xb1, 0xb2, 0xb2, 0xb2, 0xb3, 0xb3 }, + { 0x80, 0x84, 0x87, 0x8b, 0x8e, 0x91, 0x94, 0x97, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa3, 0xa5, 0xa6, + 0xa7, 0xa9, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xae, 0xae, 0xaf, 0xb0, 0xb0, 0xb1, 0xb1, 0xb2, 0xb2 }, + { 0x80, 0x83, 0x87, 0x8a, 0x8d, 0x90, 0x93, 0x96, 0x98, 0x9a, 0x9c, 0x9e, 0xa0, 0xa2, 0xa3, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xae, 0xae, 0xaf, 0xb0, 0xb0, 0xb0, 0xb1 }, + { 0x80, 0x83, 0x86, 0x89, 0x8c, 0x8f, 0x92, 0x94, 0x96, 0x99, 0x9b, 0x9d, 0x9e, 0xa0, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xae, 0xae, 0xaf, 0xaf, 0xb0 }, + { 0x80, 0x83, 0x86, 0x89, 0x8b, 0x8e, 0x90, 0x93, 0x95, 0x97, 0x99, 0x9b, 0x9d, 0x9e, 0xa0, 0xa1, + 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xaa, 0xab, 0xac, 0xad, 0xad, 0xae, 0xae, 0xaf }, + { 0x80, 0x83, 0x85, 0x88, 0x8b, 0x8d, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9b, 0x9d, 0x9f, 0xa0, + 0xa1, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa8, 0xa9, 0xaa, 0xab, 0xab, 0xac, 0xad, 0xad, 0xae }, + { 0x80, 0x83, 0x85, 0x88, 0x8a, 0x8c, 0x8f, 0x91, 0x93, 0x95, 0x97, 0x99, 0x9a, 0x9c, 0x9d, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa5, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xaa, 0xab, 0xab, 0xac, 0xad }, + { 0x80, 0x82, 0x85, 0x87, 0x89, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x97, 0x99, 0x9b, 0x9c, 0x9d, + 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa8, 0xa9, 0xaa, 0xaa, 0xab, 0xac }, + { 0x80, 0x82, 0x85, 0x87, 0x89, 0x8b, 0x8d, 0x8f, 0x91, 0x93, 0x95, 0x96, 0x98, 0x99, 0x9b, 0x9c, + 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa7, 0xa8, 0xa9, 0xa9, 0xaa, 0xab }, + { 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x95, 0x97, 0x98, 0x9a, 0x9b, + 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa8, 0xa9, 0xaa }, + { 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x91, 0x93, 0x94, 0x96, 0x97, 0x99, 0x9a, + 0x9b, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa5, 0xa6, 0xa7, 0xa7, 0xa8, 0xa9 }, + { 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8b, 0x8d, 0x8f, 0x90, 0x92, 0x94, 0x95, 0x97, 0x98, 0x99, + 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8 }, + { 0x80, 0x82, 0x84, 0x86, 0x87, 0x89, 0x8b, 0x8d, 0x8e, 0x90, 0x91, 0x93, 0x94, 0x96, 0x97, 0x98, + 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa3, 0xa4, 0xa5, 0xa6, 0xa6, 0xa7 }, + { 0x80, 0x82, 0x84, 0x85, 0x87, 0x89, 0x8a, 0x8c, 0x8e, 0x8f, 0x91, 0x92, 0x94, 0x95, 0x96, 0x98, + 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa2, 0xa3, 0xa4, 0xa5, 0xa5, 0xa6 }, + { 0x80, 0x82, 0x83, 0x85, 0x87, 0x88, 0x8a, 0x8c, 0x8d, 0x8f, 0x90, 0x92, 0x93, 0x94, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa2, 0xa3, 0xa4, 0xa5, 0xa5 }, + { 0x80, 0x82, 0x83, 0x85, 0x86, 0x88, 0x8a, 0x8b, 0x8d, 0x8e, 0x90, 0x91, 0x92, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa2, 0xa3, 0xa4, 0xa4 }, + { 0x80, 0x82, 0x83, 0x85, 0x86, 0x88, 0x89, 0x8b, 0x8c, 0x8e, 0x8f, 0x90, 0x92, 0x93, 0x94, 0x95, + 0x96, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa2, 0xa3, 0xa4 }, + { 0x80, 0x82, 0x83, 0x85, 0x86, 0x87, 0x89, 0x8a, 0x8c, 0x8d, 0x8e, 0x90, 0x91, 0x92, 0x93, 0x95, + 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9e, 0x9f, 0xa0, 0xa1, 0xa1, 0xa2, 0xa3 }, + { 0x80, 0x81, 0x83, 0x84, 0x86, 0x87, 0x89, 0x8a, 0x8b, 0x8d, 0x8e, 0x8f, 0x90, 0x92, 0x93, 0x94, + 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9e, 0x9f, 0xa0, 0xa1, 0xa1, 0xa2 }, + { 0x80, 0x81, 0x83, 0x84, 0x86, 0x87, 0x88, 0x8a, 0x8b, 0x8c, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, + 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x9f, 0xa0, 0xa1, 0xa1 }, + { 0x80, 0x81, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8b, 0x8c, 0x8d, 0x8e, 0x90, 0x91, 0x92, 0x93, + 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x9f, 0xa0, 0xa1 }, + { 0x80, 0x81, 0x83, 0x84, 0x85, 0x87, 0x88, 0x89, 0x8a, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, + 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9c, 0x9d, 0x9e, 0x9f, 0x9f, 0xa0 } }; // Mode 7 scaling constants for all raster lines @@ -331,7 +316,6 @@ static const int16 ST010_M7Scale[176] = #endif #define ST010_WORD(offset) (Memory.SRAM[offset + 1] << 8) | Memory.SRAM[offset] -#define ST010_DWORD(offset) (Memory.SRAM[offset + 3] << 24) | (Memory.SRAM[offset + 2] << 16) | (Memory.SRAM[offset + 1] << 8) | Memory.SRAM[offset] static int16 ST010_Sin (int16 Theta) @@ -344,43 +328,47 @@ static int16 ST010_Cos (int16 Theta) return (ST010_SinTable[((Theta + 0x4000) >> 8) & 0xff]); } -void ST010_Compass(int16 x0, int16 y0, int16 &x1, int16 &y1, int16 &Quadrant, int16 &Theta) -{ - if ((x0 <= 0) && (y0 < 0)) - { +static void ST010_OP01 (int16 x0, int16 y0, int16 &x1, int16 &y1, int16 &Quadrant, int16 &Theta) +{ + if ((x0 < 0) && (y0 < 0)) + { x1 = -x0; y1 = -y0; Quadrant = -0x8000; } - else if (x0 < 0) + else + if (x0 < 0) { - x1 = y0; + x1 = y0; y1 = -x0; Quadrant = -0x4000; } - else if (y0 < 0) + else + if (y0 < 0) { x1 = -y0; - y1 = x0; - Quadrant = 0x4000; + y1 = x0; + Quadrant = 0x4000; } else { - x1 = x0; - y1 = y0; - Quadrant = 0x0000; + x1 = x0; + y1 = y0; + Quadrant = 0x0000; } - while ((x1 > 0x1f) || (y1 > 0x1f)) + while ((x1 > 0x1f) || (y1 > 0x1f)) { - if (x1 > 1) x1 >>= 1; - if (y1 > 1) y1 >>= 1; + if (x1 > 1) + x1 >>= 1; + if (y1 > 1) + y1 >>= 1; } - Theta = ST010_ArcTan[x1 & 0x1f][y1 & 0x1f] << 8; - Theta = (Theta | Quadrant) ^ 0x8000; + if (y1 == 0) + Quadrant += 0x4000; - if ((x0 == 0) && (y0 < 0)) Quadrant = 0x4000; + Theta = (ST010_ArcTan[y1][x1] << 8) ^ Quadrant; } static void ST010_Scale (int16 Multiplier, int16 X0, int16 Y0, int32 &X1, int32 &Y1) @@ -433,108 +421,17 @@ static void ST010_SortDrivers (uint16 Positions, uint16 Places[32], uint16 Drive } } -static void ST010_Raster(int16 Theta) +/* +static void SETA_Distance (int16 Y0, int16 X0, int16 &Distance) { - int16 data; - int offset = 0; + if (X0 < 0) + X0 = -X0; + if (Y0 < 0) + Y0 = -Y0; - for (int i = 0; i < 176; i++) - { - data = ST010_M7Scale[i] * ST010_Cos(Theta) >> 15; - - Memory.SRAM[0x00f0 + offset] = data; - Memory.SRAM[0x00f1 + offset] = data >> 8; - - Memory.SRAM[0x0510 + offset] = data; - Memory.SRAM[0x0511 + offset] = data >> 8; - - data = ST010_M7Scale[i] * ST010_Sin(Theta) >> 15; - - Memory.SRAM[0x0250 + offset] = data; - Memory.SRAM[0x0251 + offset] = data >> 8; - - if (data) data = ~data; - - Memory.SRAM[0x03b0 + offset] = data; - Memory.SRAM[0x03b1 + offset] = data >> 8; - - offset += 2; - } -} - -static void ST010_Distance(int16 x0, int16 y0, int16 &Distance) -{ - int32 Product; - - x0 = (x0 < 0) ? -x0 : x0; - y0 = (y0 < 0) ? -y0 : y0; - - if((uint16) x0 >= ((uint16) y0)) - Product = ((x0 * 0x3d78 << 1) + (y0 * 0x1976 << 1)) << 1; - else - Product = ((y0 * 0x3d78 << 1) + (x0 * 0x1976 << 1)) << 1; - - Distance = (Product + 0x8000) >> 16; -} - -static void ST010_Navigation(int16 &MaxX, int16 &MaxY, int32 &x0, int32 &y0, int16 &Theta0, int16 &Theta1, int16 &x1, int16 &y1, uint16 &Radius, uint16 Increment, uint16 MaxRadius, int16 &Compass, int16 &Flags, int16 NewMaxX, int16 NewMaxY) -{ - int16 dummy1,dummy2,dummy3; - uint16 utemp16; - int32 temp32; - - - x1 = MaxX - (x0 >> 16); - y1 = MaxY - (y0 >> 16); - - ST010_Compass(x1, y1, dummy1, dummy2, dummy3, Theta1); - Theta1 -= Theta0; - - if (Theta1 & 0xff00) - Theta0 += (Theta1 & 0x8000) ? 0xfd80 : 0x0280; - - // compiler notice: -0x8000 ==> +0x8000 - utemp16 = ((Theta1 < 0) ? (int16) -Theta1 : Theta1) >> 4; - - if (utemp16 < 0x0100) - { - temp32 = Radius + Increment; - Radius = (temp32 >= MaxRadius) ? MaxRadius : (uint16) temp32; - } - - else - { - temp32 = Radius - utemp16; - Radius = (temp32 <= 0) ? 0 : (uint16) temp32; - } - - x0 -= ((ST010_Sin(Theta0) >> 5) * (Radius >> 8)) << 1; - y0 -= ((ST010_Cos(Theta0) >> 5) * (Radius >> 8)) << 1; - - x0 &= 0x1fffffff; - y0 &= 0x1fffffff; - - - int16 MaxRadiusX, MaxRadiusY; - if (Compass & 0x8000) - { - MaxRadiusX = 0x0008; - MaxRadiusY = 0x0080; - } - else - { - MaxRadiusX = 0x0080; - MaxRadiusY = 0x0008; - } - - if ((abs(x1) < MaxRadiusX) && (abs(y1) < MaxRadiusY)) - { - MaxX = NewMaxX; - MaxY = NewMaxY & 0x0fff; - Compass = (NewMaxY & 0x8000) ? 0xffff : 0x0000; - Flags |= 0x0008; - } + Distance = ((X0 * 0x7af0) + 0x4000) >> 15; } +*/ uint8 S9xGetST010 (uint32 Address) { @@ -574,32 +471,16 @@ void S9xSetST010 (uint32 Address, uint8 Byte) { switch (ST010.op_reg) { - // Heading - case 0x01: - { - Memory.SRAM[0x0006] = Memory.SRAM[0x0002]; - Memory.SRAM[0x0007] = Memory.SRAM[0x0003]; - - #ifdef FAST_LSB_WORD_ACCESS - ST010_Compass(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0000], (int16 &) Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0004], (int16 &) Memory.SRAM[0x0010]); - #else - int16 x1, y1, Quadrant, Theta; - - ST010_Compass(ST010_WORD(0x0000), ST010_WORD(0x0002), x1, y1, Quadrant, Theta); - - Memory.SRAM[0x0000] = (uint8) (x1); - Memory.SRAM[0x0001] = (uint8) (x1 >> 8); - Memory.SRAM[0x0002] = (uint8) (y1); - Memory.SRAM[0x0003] = (uint8) (y1 >> 8); - Memory.SRAM[0x0004] = (uint8) (Quadrant); - Memory.SRAM[0x0005] = (uint8) (Quadrant >> 8); - Memory.SRAM[0x0010] = (uint8) (Theta); - Memory.SRAM[0x0011] = (uint8) (Theta >> 8); - #endif - break; - } - // Sorts Driver Placements + // + // Input + // 0x0024-0x0025 : Positions + // 0x0040-0x007f : Places + // 0x0080-0x00ff : Drivers + // Output + // 0x0040-0x007f : Places + // 0x0080-0x00ff : Drivers + // case 0x02: { #ifdef FAST_LSB_WORD_ACCESS @@ -632,6 +513,15 @@ void S9xSetST010 (uint32 Address, uint8 Byte) } // Two Dimensional Coordinate Scale + // + // Input + // 0x0000-0x0001 : X0 (signed) + // 0x0002-0x0003 : Y0 (signed) + // 0x0004-0x0005 : Multiplier (signed) + // Output + // 0x0010-0x0013 : X1 (signed) + // 0x0014-0x0017 : Y1 (signed) + // case 0x03: { #ifdef FAST_LSB_WORD_ACCESS @@ -653,74 +543,14 @@ void S9xSetST010 (uint32 Address, uint8 Byte) break; } - // calculate the vector length of (x, y) - case 0x04: - { - #ifdef FAST_LSB_WORD_ACCESS - ST010_Distance(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0010]); - #else - int16 square; - - ST010_Distance(ST010_WORD(0x0000), ST010_WORD(0x0002), square); - - Memory.SRAM[0x10] = (uint8) (square); - Memory.SRAM[0x11] = (uint8) (square >> 8); - #endif - break; - } - - // calculate AI orientation based on specific guidelines - case 0x05: - { - #ifdef FAST_LSB_WORD_ACCESS - ST010_Navigation((int16 &) Memory.SRAM[0x00c0], (int16 &) Memory.SRAM[0x00c2], (int32 &) Memory.SRAM[0x00c4], (int32 &) Memory.SRAM[0x00c8], (int16 &) Memory.SRAM[0x00cc], (int16 &) Memory.SRAM[0x00ce], (int16 &) Memory.SRAM[0x00d0], (int16 &) Memory.SRAM[0x00d2], (uint16 &) Memory.SRAM[0x00d4], *(uint16 *) &Memory.SRAM[0x00d6], *(uint16 *) &Memory.SRAM[0x00d8], (int16 &) Memory.SRAM[0x00da], (int16 &) Memory.SRAM[0x00dc], *(int16 *) &Memory.SRAM[0x00de], *(int16 *) &Memory.SRAM[0x00e0]); - #else - int32 x0,y0; - int16 MaxX,MaxY,Theta0,Theta1,x1,y1,Compass,Flags; - uint16 Radius; - - MaxX = ST010_WORD(0x00c0); - MaxY = ST010_WORD(0x00c2); - x0 = ST010_DWORD(0x00c4); - y0 = ST010_DWORD(0x00c8); - Theta0 = ST010_WORD(0x00cc); - Radius = ST010_WORD(0x00d4); - Compass = ST010_WORD(0x00da); - Flags = ST010_WORD(0x00dc); - - ST010_Navigation(MaxX, MaxY, x0, y0, Theta0, Theta1, x1, y1, Radius, ST010_WORD(0x00d6), ST010_WORD(0x00d8), Compass, Flags, ST010_WORD(0x00de), ST010_WORD(0x00e0)); - - Memory.SRAM[0x00c0] = (uint8) (MaxX); - Memory.SRAM[0x00c1] = (uint8) (MaxX >> 8); - Memory.SRAM[0x00c2] = (uint8) (MaxY); - Memory.SRAM[0x00c3] = (uint8) (MaxY >> 8); - Memory.SRAM[0x00c4] = (uint8) (x0); - Memory.SRAM[0x00c5] = (uint8) (x0 >> 8); - Memory.SRAM[0x00c6] = (uint8) (x0 >> 16); - Memory.SRAM[0x00c7] = (uint8) (x0 >> 24); - Memory.SRAM[0x00c8] = (uint8) (y0); - Memory.SRAM[0x00c9] = (uint8) (y0 >> 8); - Memory.SRAM[0x00ca] = (uint8) (y0 >> 16); - Memory.SRAM[0x00cb] = (uint8) (y0 >> 24); - Memory.SRAM[0x00cc] = (uint8) (Theta0); - Memory.SRAM[0x00cd] = (uint8) (Theta0 >> 8); - Memory.SRAM[0x00ce] = (uint8) (Theta1); - Memory.SRAM[0x00cf] = (uint8) (Theta1 >> 8); - Memory.SRAM[0x00d0] = (uint8) (x1); - Memory.SRAM[0x00d1] = (uint8) (x1 >> 8); - Memory.SRAM[0x00d2] = (uint8) (y1); - Memory.SRAM[0x00d3] = (uint8) (y1 >> 8); - Memory.SRAM[0x00d4] = (uint8) (Radius); - Memory.SRAM[0x00d5] = (uint8) (Radius >> 8); - Memory.SRAM[0x00da] = (uint8) (Compass); - Memory.SRAM[0x00db] = (uint8) (Compass >> 8); - Memory.SRAM[0x00dc] = (uint8) (Flags); - Memory.SRAM[0x00dd] = (uint8) (Flags >> 8); - #endif - break; - } - // 16-bit Multiplication + // + // Input + // 0x0000-0x0001 : Multiplcand (signed) + // 0x0002-0x0003 : Multiplier (signed) + // Output + // 0x0010-0x0013 : Product (signed) + // case 0x06: { #ifdef FAST_LSB_WORD_ACCESS @@ -739,13 +569,45 @@ void S9xSetST010 (uint32 Address, uint8 Byte) } // Mode 7 Raster Data Calculation + // + // Input + // 0x0000-0x0001 : Angle (signed) + // Output + // 0x00f0-0x024f : Mode 7 Matrix A + // 0x0250-0x03af : Mode 7 Matrix B + // 0x03b0-0x050f : Mode 7 Matrix C + // 0x0510-0x066f : Mode 7 Matrix D + // case 0x07: { - #ifdef FAST_LSB_WORD_ACCESS - ST010_Raster(*(int16 *) &Memory.SRAM[0x0000]); - #else - ST010_Raster(ST010_WORD(0x0000)); - #endif + int16 data; + int32 offset = 0; + int16 Theta = ST010_WORD(0x0000); + + for (int32 line = 0; line < 176; line++) + { + // Calculate Mode 7 Matrix A/D data + data = ST010_M7Scale[line] * ST010_Cos(Theta) >> 15; + + Memory.SRAM[0x00f0 + offset] = (uint8) (data); + Memory.SRAM[0x00f1 + offset] = (uint8) (data >> 8); + Memory.SRAM[0x0510 + offset] = (uint8) (data); + Memory.SRAM[0x0511 + offset] = (uint8) (data >> 8); + + // Calculate Mode 7 Matrix B/C data + data = ST010_M7Scale[line] * ST010_Sin(Theta) >> 15; + + Memory.SRAM[0x0250 + offset] = (uint8) (data); + Memory.SRAM[0x0251 + offset] = (uint8) (data >> 8); + + if (data) + data = ~data; + + Memory.SRAM[0x03b0 + offset] = (uint8) (data); + Memory.SRAM[0x03b1 + offset] = (uint8) (data >> 8); + + offset += 2; + } // Shift Angle for use with Lookup table Memory.SRAM[0x00] = Memory.SRAM[0x01]; @@ -755,6 +617,15 @@ void S9xSetST010 (uint32 Address, uint8 Byte) } // Two dimensional Coordinate Rotation + // + // Input + // 0x0000-0x0001 : X0 (signed) + // 0x0002-0x0003 : Y0 (signed) + // 0x0004-0x0005 : Angle (signed) + // Output + // 0x0010-0x0011 : X1 (signed) + // 0x0012-0x0013 : Y1 (signed) + // case 0x08: { #ifdef FAST_LSB_WORD_ACCESS @@ -772,6 +643,212 @@ void S9xSetST010 (uint32 Address, uint8 Byte) break; } + // Input + // 0x0000-0x0001 : DX (signed) + // 0x0002-0x0003 : DY (signed) + // Output + // 0x0010-0x0011 : Angle (signed) + // + case 0x01: + { + Memory.SRAM[0x0006] = Memory.SRAM[0x0002]; + Memory.SRAM[0x0007] = Memory.SRAM[0x0003]; + + #ifdef FAST_LSB_WORD_ACCESS + ST010_OP01(*(int16 *) &Memory.SRAM[0x0000], *(int16 *) &Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0000], (int16 &) Memory.SRAM[0x0002], (int16 &) Memory.SRAM[0x0004], (int16 &) Memory.SRAM[0x0010]); + #else + int16 x1, y1, Quadrant, Theta; + + ST010_OP01(ST010_WORD(0x0000), ST010_WORD(0x0002), x1, y1, Quadrant, Theta); + + Memory.SRAM[0x0000] = (uint8) (x1); + Memory.SRAM[0x0001] = (uint8) (x1 >> 8); + Memory.SRAM[0x0002] = (uint8) (y1); + Memory.SRAM[0x0003] = (uint8) (y1 >> 8); + Memory.SRAM[0x0004] = (uint8) (Quadrant); + Memory.SRAM[0x0005] = (uint8) (Quadrant >> 8); + Memory.SRAM[0x0010] = (uint8) (Theta); + Memory.SRAM[0x0011] = (uint8) (Theta >> 8); + #endif + break; + } + + // calculate the vector length of (x, y) + case 0x04: + { + int16 square, x, y; + #ifdef FAST_LSB_WORD_ACCESS + x = *((int16 *) Memory.SRAM); + y = *((int16 *) &Memory.SRAM[2]); + #else + x = Memory.SRAM[0] | (Memory.SRAM[1] << 8); + y = Memory.SRAM[2] | (Memory.SRAM[3] << 8); + #endif + square = (int16) sqrt((double) (y * y + x * x)); + //SETA_Distance(x, y, square); + + #ifdef FAST_LSB_WORD_ACCESS + *((int16 *) &Memory.SRAM[0x10]) = square; + #else + Memory.SRAM[0x10] = (uint8) (square); + Memory.SRAM[0x11] = (uint8) (square >> 8); + #endif + break; + } + + // calculate AI orientation based on specific guidelines + case 0x05: + { + int32 dx, dy; + int16 a1, b1, c1; + uint16 o1; + bool wrap = false; + + // target (x, y) coordinates + int16 ypos_max = ST010_WORD(0x00C0); + int16 xpos_max = ST010_WORD(0x00C2); + + // current coordinates and direction + int32 ypos = Memory.SRAM[0xC4] | (Memory.SRAM[0xC5] << 8) | (Memory.SRAM[0xC6] << 16) | (Memory.SRAM[0xC7] << 24); + int32 xpos = Memory.SRAM[0xC8] | (Memory.SRAM[0xC9] << 8) | (Memory.SRAM[0xCA] << 16) | (Memory.SRAM[0xCB] << 24); + uint16 rot = Memory.SRAM[0xCC] | (Memory.SRAM[0xCD] << 8); + + // physics + uint16 speed = ST010_WORD(0x00D4); + uint16 accel = ST010_WORD(0x00D6); + uint16 speed_max = ST010_WORD(0x00D8); + + // special condition acknowledgment + int16 system = ST010_WORD(0x00DA); + int16 flags = ST010_WORD(0x00DC); + + // new target coordinates + int16 ypos_new = ST010_WORD(0x00DE); + int16 xpos_new = ST010_WORD(0x00E0); + + // mask upper bit + xpos_new &= 0x7FFF; + + // get the current distance + dx = xpos_max - (xpos >> 16); + dy = ypos_max - (ypos >> 16); + + // quirk: clear and move in9 + Memory.SRAM[0xD2] = 0xFF; + Memory.SRAM[0xD3] = 0xFF; + Memory.SRAM[0xDA] = 0; + Memory.SRAM[0xDB] = 0; + + // grab the target angle + ST010_OP01(dy, dx, a1, b1, c1, (int16 &) o1); + + // check for wrapping + //if ((o1 < 0x6000 && rot > 0xA000) || (rot < 0x6000 && o1 > 0xA000)) + //if (o1 < rot) + if (abs(o1 - rot) > 0x8000) + { + o1 += 0x8000; + rot += 0x8000; + wrap = true; + } + //o1 = 0x0000; + //rot = 0xFF00; + + uint16 old_speed; + + old_speed = speed; + + // special case + if (abs(o1 - rot) == 0x8000) + speed = 0x100; + // slow down for sharp curves + else + if (abs(o1 - rot) >= 0x1000) + { + uint32 slow = abs(o1 - rot); + slow >>= 4; // scaling + speed -= slow; + } + // otherwise accelerate + else + { + speed += accel; + if (speed > speed_max) + { + // clip speed + speed = speed_max; + } + } + + // prevent negative/positive overflow + if (abs(old_speed - speed) > 0x8000) + { + if (old_speed < speed) + speed = 0; + else + speed = 0xff00; + } + + // adjust direction by so many degrees + // be careful of negative adjustments + if ((o1 > rot && (o1 - rot) > 0x80) || (o1 < rot && (rot - o1) >= 0x80)) + { + if (o1 < rot) + rot -= 0x280; + else + if (o1 > rot) + rot += 0x280; + } + + // turn off wrapping + if (wrap) + rot -= 0x8000; + + // now check the distances (store for later) + dx = (xpos_max << 16) - xpos; + dy = (ypos_max << 16) - ypos; + dx >>= 16; + dy >>= 16; + + // if we're in so many units of the target, signal it + if ((system && (dy <= 6 && dy >= -8) && (dx <= 126 && dx >= -128)) || (!system && (dx <= 6 && dx >= -8) && (dy <= 126 && dy >= -128))) + { + // announce our new destination and flag it + xpos_max = xpos_new & 0x7FFF; + ypos_max = ypos_new; + flags |= 0x08; + } + + // update position + xpos -= (ST010_Cos(rot) * 0x400 >> 15) * (speed >> 8) << 1; + ypos -= (ST010_Sin(rot) * 0x400 >> 15) * (speed >> 8) << 1; + + // quirk: mask upper byte + xpos &= 0x1FFFFFFF; + ypos &= 0x1FFFFFFF; + + Memory.SRAM[0x00C0] = (uint8) (ypos_max); + Memory.SRAM[0x00C1] = (uint8) (ypos_max >> 8); + Memory.SRAM[0x00C2] = (uint8) (xpos_max); + Memory.SRAM[0x00C3] = (uint8) (xpos_max >> 8); + Memory.SRAM[0x00C4] = (uint8) (ypos); + Memory.SRAM[0x00C5] = (uint8) (ypos >> 8); + Memory.SRAM[0x00C6] = (uint8) (ypos >> 16); + Memory.SRAM[0x00C7] = (uint8) (ypos >> 24); + Memory.SRAM[0x00C8] = (uint8) (xpos); + Memory.SRAM[0x00C9] = (uint8) (xpos >> 8); + Memory.SRAM[0x00CA] = (uint8) (xpos >> 16); + Memory.SRAM[0x00CB] = (uint8) (xpos >> 24); + Memory.SRAM[0x00CC] = (uint8) (rot); + Memory.SRAM[0x00CD] = (uint8) (rot >> 8); + Memory.SRAM[0x00D4] = (uint8) (speed); + Memory.SRAM[0x00D5] = (uint8) (speed >> 8); + Memory.SRAM[0x00DC] = (uint8) (flags); + Memory.SRAM[0x00DD] = (uint8) (flags >> 8); + + break; + } + default: #ifdef DEBUGGER printf("Unknown Op\n"); diff --git a/source/snes9x/seta011.cpp b/source/snes9x/seta011.cpp index 3590692..b49a8b8 100644 --- a/source/snes9x/seta011.cpp +++ b/source/snes9x/seta011.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta018.cpp b/source/snes9x/seta018.cpp index 80d24bd..24efb5c 100644 --- a/source/snes9x/seta018.cpp +++ b/source/snes9x/seta018.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/snapshot.cpp b/source/snes9x/snapshot.cpp index 08b579a..eb2a349 100644 --- a/source/snes9x/snapshot.cpp +++ b/source/snes9x/snapshot.cpp @@ -1705,7 +1705,6 @@ int S9xUnfreezeFromStream (STREAM stream) CPU.HDMARanInDMA = 0; S9xFixColourBrightness(); - S9xBuildDirectColourMaps(); IPPU.ColorsChanged = TRUE; IPPU.OBJChanged = TRUE; IPPU.RenderThisFrame = TRUE; @@ -2044,7 +2043,7 @@ static int UnfreezeBlock (STREAM stream, const char *name, uint8 *block, int siz len = size; } - memset(block, 0, size); + ZeroMemory(block, size); if (READ_STREAM(block, len, stream) != len) { diff --git a/source/snes9x/snes9x.h b/source/snes9x/snes9x.h index e24834c..dbf9e65 100644 --- a/source/snes9x/snes9x.h +++ b/source/snes9x/snes9x.h @@ -449,7 +449,6 @@ struct SSettings bool8 OpenGLEnable; float SuperFXSpeedPerLine; - int MaxSpriteTilesPerLine; }; struct SSNESGameFixes diff --git a/source/snes9x/spc7110.cpp b/source/snes9x/spc7110.cpp index 533f45f..5ead658 100644 --- a/source/snes9x/spc7110.cpp +++ b/source/snes9x/spc7110.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/spc7110.h b/source/snes9x/spc7110.h index 8e7ecd2..7002b50 100644 --- a/source/snes9x/spc7110.h +++ b/source/snes9x/spc7110.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/spc7110dec.cpp b/source/snes9x/spc7110dec.cpp index ab7521b..65d5586 100644 --- a/source/snes9x/spc7110dec.cpp +++ b/source/snes9x/spc7110dec.cpp @@ -42,7 +42,7 @@ void SPC7110Decomp::write(uint8 data) { } uint8 SPC7110Decomp::dataread() { - unsigned size = memory_cartrom_size() > 0x500000 ? memory_cartrom_size() - 0x200000 : memory_cartrom_size() - 0x100000; + unsigned size = memory_cartrom_size() - 0x100000; while(decomp_offset >= size) decomp_offset -= size; return memory_cartrom_read(0x100000 + decomp_offset++); } @@ -498,7 +498,7 @@ void SPC7110Decomp::reset() { } SPC7110Decomp::SPC7110Decomp() { - decomp_buffer = new uint8[decomp_buffer_size]; + decomp_buffer = new uint8_t[decomp_buffer_size]; reset(); //initialize reverse morton lookup tables diff --git a/source/snes9x/spc7110emu.cpp b/source/snes9x/spc7110emu.cpp index 8ce99b8..69b3e7d 100644 --- a/source/snes9x/spc7110emu.cpp +++ b/source/snes9x/spc7110emu.cpp @@ -91,7 +91,7 @@ void SPC7110::reset() { } unsigned SPC7110::datarom_addr(unsigned addr) { - unsigned size = memory_cartrom_size() > 0x500000 ? memory_cartrom_size() - 0x200000 : memory_cartrom_size() - 0x100000; + unsigned size = memory_cartrom_size() - 0x100000; while(addr >= size) addr -= size; return addr + 0x100000; } diff --git a/source/snes9x/srtc.cpp b/source/snes9x/srtc.cpp index 978a207..ca7b91c 100644 --- a/source/snes9x/srtc.cpp +++ b/source/snes9x/srtc.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/srtc.h b/source/snes9x/srtc.h index d21ea98..8bc441c 100644 --- a/source/snes9x/srtc.h +++ b/source/snes9x/srtc.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/tile.cpp b/source/snes9x/tile.cpp index fad941e..f8d2082 100644 --- a/source/snes9x/tile.cpp +++ b/source/snes9x/tile.cpp @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in @@ -489,6 +474,7 @@ static uint8 ConvertTile4h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile) #undef DOBIT // First-level include: Get all the renderers. + #include "tile.cpp" // Functions to select which converter and renderer to use. @@ -711,11 +697,13 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) } #define IS_BLANK_TILE() \ - ( ( (Tile & H_FLIP) ? BG.BufferedFlip[TileNumber] : BG.Buffered[TileNumber]) == BLANK_TILE) + (BG.Buffered[TileNumber] == BLANK_TILE) #define SELECT_PALETTE() \ if (BG.DirectColourMode) \ { \ + if (IPPU.DirectColourMapsNeedRebuild) \ + S9xBuildDirectColourMaps(); \ GFX.RealScreenColors = DirectColourMaps[(Tile >> 10) & 7]; \ } \ else \ @@ -761,7 +749,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & (V_FLIP | H_FLIP))) \ { \ bp = pCache + BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp += 8 * PITCH, Offset += GFX.PPL) \ { \ DRAW_PIXEL(0, Pix = bp[0]); \ @@ -778,7 +765,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & V_FLIP)) \ { \ bp = pCache + BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp += 8 * PITCH, Offset += GFX.PPL) \ { \ DRAW_PIXEL(0, Pix = bp[7]); \ @@ -795,7 +781,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & H_FLIP)) \ { \ bp = pCache + 56 - BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp -= 8 * PITCH, Offset += GFX.PPL) \ { \ DRAW_PIXEL(0, Pix = bp[0]); \ @@ -811,7 +796,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) else \ { \ bp = pCache + 56 - BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp -= 8 * PITCH, Offset += GFX.PPL) \ { \ DRAW_PIXEL(0, Pix = bp[7]); \ @@ -856,19 +840,18 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & (V_FLIP | H_FLIP))) \ { \ bp = pCache + BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp += 8 * PITCH, Offset += GFX.PPL) \ { \ w = Width; \ switch (StartPixel) \ { \ - case 0: DRAW_PIXEL(0, Pix = bp[0]); if (!--w) break; /* Fall through */ \ - case 1: DRAW_PIXEL(1, Pix = bp[1]); if (!--w) break; /* Fall through */ \ - case 2: DRAW_PIXEL(2, Pix = bp[2]); if (!--w) break; /* Fall through */ \ - case 3: DRAW_PIXEL(3, Pix = bp[3]); if (!--w) break; /* Fall through */ \ - case 4: DRAW_PIXEL(4, Pix = bp[4]); if (!--w) break; /* Fall through */ \ - case 5: DRAW_PIXEL(5, Pix = bp[5]); if (!--w) break; /* Fall through */ \ - case 6: DRAW_PIXEL(6, Pix = bp[6]); if (!--w) break; /* Fall through */ \ + case 0: DRAW_PIXEL(0, Pix = bp[0]); if (!--w) break; \ + case 1: DRAW_PIXEL(1, Pix = bp[1]); if (!--w) break; \ + case 2: DRAW_PIXEL(2, Pix = bp[2]); if (!--w) break; \ + case 3: DRAW_PIXEL(3, Pix = bp[3]); if (!--w) break; \ + case 4: DRAW_PIXEL(4, Pix = bp[4]); if (!--w) break; \ + case 5: DRAW_PIXEL(5, Pix = bp[5]); if (!--w) break; \ + case 6: DRAW_PIXEL(6, Pix = bp[6]); if (!--w) break; \ case 7: DRAW_PIXEL(7, Pix = bp[7]); break; \ } \ } \ @@ -877,19 +860,18 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & V_FLIP)) \ { \ bp = pCache + BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp += 8 * PITCH, Offset += GFX.PPL) \ { \ w = Width; \ switch (StartPixel) \ { \ - case 0: DRAW_PIXEL(0, Pix = bp[7]); if (!--w) break; /* Fall through */ \ - case 1: DRAW_PIXEL(1, Pix = bp[6]); if (!--w) break; /* Fall through */ \ - case 2: DRAW_PIXEL(2, Pix = bp[5]); if (!--w) break; /* Fall through */ \ - case 3: DRAW_PIXEL(3, Pix = bp[4]); if (!--w) break; /* Fall through */ \ - case 4: DRAW_PIXEL(4, Pix = bp[3]); if (!--w) break; /* Fall through */ \ - case 5: DRAW_PIXEL(5, Pix = bp[2]); if (!--w) break; /* Fall through */ \ - case 6: DRAW_PIXEL(6, Pix = bp[1]); if (!--w) break; /* Fall through */ \ + case 0: DRAW_PIXEL(0, Pix = bp[7]); if (!--w) break; \ + case 1: DRAW_PIXEL(1, Pix = bp[6]); if (!--w) break; \ + case 2: DRAW_PIXEL(2, Pix = bp[5]); if (!--w) break; \ + case 3: DRAW_PIXEL(3, Pix = bp[4]); if (!--w) break; \ + case 4: DRAW_PIXEL(4, Pix = bp[3]); if (!--w) break; \ + case 5: DRAW_PIXEL(5, Pix = bp[2]); if (!--w) break; \ + case 6: DRAW_PIXEL(6, Pix = bp[1]); if (!--w) break; \ case 7: DRAW_PIXEL(7, Pix = bp[0]); break; \ } \ } \ @@ -898,19 +880,18 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) if (!(Tile & H_FLIP)) \ { \ bp = pCache + 56 - BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp -= 8 * PITCH, Offset += GFX.PPL) \ { \ w = Width; \ switch (StartPixel) \ { \ - case 0: DRAW_PIXEL(0, Pix = bp[0]); if (!--w) break; /* Fall through */ \ - case 1: DRAW_PIXEL(1, Pix = bp[1]); if (!--w) break; /* Fall through */ \ - case 2: DRAW_PIXEL(2, Pix = bp[2]); if (!--w) break; /* Fall through */ \ - case 3: DRAW_PIXEL(3, Pix = bp[3]); if (!--w) break; /* Fall through */ \ - case 4: DRAW_PIXEL(4, Pix = bp[4]); if (!--w) break; /* Fall through */ \ - case 5: DRAW_PIXEL(5, Pix = bp[5]); if (!--w) break; /* Fall through */ \ - case 6: DRAW_PIXEL(6, Pix = bp[6]); if (!--w) break; /* Fall through */ \ + case 0: DRAW_PIXEL(0, Pix = bp[0]); if (!--w) break; \ + case 1: DRAW_PIXEL(1, Pix = bp[1]); if (!--w) break; \ + case 2: DRAW_PIXEL(2, Pix = bp[2]); if (!--w) break; \ + case 3: DRAW_PIXEL(3, Pix = bp[3]); if (!--w) break; \ + case 4: DRAW_PIXEL(4, Pix = bp[4]); if (!--w) break; \ + case 5: DRAW_PIXEL(5, Pix = bp[5]); if (!--w) break; \ + case 6: DRAW_PIXEL(6, Pix = bp[6]); if (!--w) break; \ case 7: DRAW_PIXEL(7, Pix = bp[7]); break; \ } \ } \ @@ -918,19 +899,18 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) else \ { \ bp = pCache + 56 - BPSTART; \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, bp -= 8 * PITCH, Offset += GFX.PPL) \ { \ w = Width; \ switch (StartPixel) \ { \ - case 0: DRAW_PIXEL(0, Pix = bp[7]); if (!--w) break; /* Fall through */ \ - case 1: DRAW_PIXEL(1, Pix = bp[6]); if (!--w) break; /* Fall through */ \ - case 2: DRAW_PIXEL(2, Pix = bp[5]); if (!--w) break; /* Fall through */ \ - case 3: DRAW_PIXEL(3, Pix = bp[4]); if (!--w) break; /* Fall through */ \ - case 4: DRAW_PIXEL(4, Pix = bp[3]); if (!--w) break; /* Fall through */ \ - case 5: DRAW_PIXEL(5, Pix = bp[2]); if (!--w) break; /* Fall through */ \ - case 6: DRAW_PIXEL(6, Pix = bp[1]); if (!--w) break; /* Fall through */ \ + case 0: DRAW_PIXEL(0, Pix = bp[7]); if (!--w) break; \ + case 1: DRAW_PIXEL(1, Pix = bp[6]); if (!--w) break; \ + case 2: DRAW_PIXEL(2, Pix = bp[5]); if (!--w) break; \ + case 3: DRAW_PIXEL(3, Pix = bp[4]); if (!--w) break; \ + case 4: DRAW_PIXEL(4, Pix = bp[3]); if (!--w) break; \ + case 5: DRAW_PIXEL(5, Pix = bp[2]); if (!--w) break; \ + case 6: DRAW_PIXEL(6, Pix = bp[1]); if (!--w) break; \ case 7: DRAW_PIXEL(7, Pix = bp[0]); break; \ } \ } \ @@ -975,7 +955,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) \ if (Pix) \ { \ - OFFSET_IN_LINE; \ for (l = LineCount; l > 0; l--, Offset += GFX.PPL) \ { \ for (w = Width - 1; w >= 0; w--) \ @@ -1012,7 +991,6 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic) GFX.RealScreenColors = IPPU.ScreenColors; \ GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors; \ \ - OFFSET_IN_LINE; \ for (l = GFX.StartY; l <= GFX.EndY; l++, Offset += GFX.PPL) \ { \ for (x = Left; x < Right; x++) \ @@ -1058,6 +1036,8 @@ extern struct SLineMatrixData LineMatrixData[240]; \ if (DCMODE) \ { \ + if (IPPU.DirectColourMapsNeedRebuild) \ + S9xBuildDirectColourMaps(); \ GFX.RealScreenColors = DirectColourMaps[0]; \ } \ else \ @@ -1071,7 +1051,6 @@ extern struct SLineMatrixData LineMatrixData[240]; uint32 Offset = GFX.StartY * GFX.PPL; \ struct SLineMatrixData *l = &LineMatrixData[GFX.StartY]; \ \ - OFFSET_IN_LINE; \ for (uint32 Line = GFX.StartY; Line <= GFX.EndY; Line++, Offset += GFX.PPL, l++) \ { \ int yy, starty; \ @@ -1154,6 +1133,8 @@ extern struct SLineMatrixData LineMatrixData[240]; \ if (DCMODE) \ { \ + if (IPPU.DirectColourMapsNeedRebuild) \ + S9xBuildDirectColourMaps(); \ GFX.RealScreenColors = DirectColourMaps[0]; \ } \ else \ @@ -1185,7 +1166,6 @@ extern struct SLineMatrixData LineMatrixData[240]; uint32 Offset = StartY * GFX.PPL; \ struct SLineMatrixData *l = &LineMatrixData[StartY]; \ \ - OFFSET_IN_LINE; \ for (uint32 Line = StartY; Line <= GFX.EndY; Line += VMosaic, Offset += VMosaic * GFX.PPL, l += VMosaic) \ { \ if (Line + VMosaic > GFX.EndY) \ @@ -1361,7 +1341,6 @@ extern struct SLineMatrixData LineMatrixData[240]; // The 1x1 pixel plotter, for speedhacking modes. -#define OFFSET_IN_LINE #define DRAW_PIXEL(N, M) \ if (Z1 > GFX.DB[Offset + N] && (M)) \ { \ @@ -1396,7 +1375,6 @@ extern struct SLineMatrixData LineMatrixData[240]; #undef NAME2 #undef DRAW_PIXEL -#undef OFFSET_IN_LINE // Hires pixel plotter, this combines the main and subscreen pixels as appropriate to render hires or pseudo-hires images. // Use it only on the main screen, subscreen should use Normal2x1 instead. @@ -1410,16 +1388,11 @@ extern struct SLineMatrixData LineMatrixData[240]; #define DRAW_PIXEL_H2x1(N, M) \ if (Z1 > GFX.DB[Offset + 2 * N] && (M)) \ { \ + GFX.S[Offset + 2 * N] = MATH((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); \ GFX.S[Offset + 2 * N + 1] = MATH(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]); \ - if ((OffsetInLine + 2 * N ) != (SNES_WIDTH - 1) << 1) \ - GFX.S[Offset + 2 * N + 2] = MATH((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N + 2]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); \ - if ((OffsetInLine + 2 * N) == 0 || (OffsetInLine + 2 * N) == GFX.RealPPL) \ - GFX.S[Offset + 2 * N] = MATH((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]); \ GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2; \ } -#define OFFSET_IN_LINE \ - uint32 OffsetInLine = Offset % GFX.RealPPL; #define DRAW_PIXEL(N, M) DRAW_PIXEL_H2x1(N, M) #define NAME2 Hires @@ -1429,7 +1402,6 @@ extern struct SLineMatrixData LineMatrixData[240]; #undef NAME2 #undef DRAW_PIXEL -#undef OFFSET_IN_LINE // Interlace: Only draw every other line, so we'll redefine BPSTART and PITCH to do so. // Otherwise, it's the same as Normal2x1/Hires2x1. @@ -1442,7 +1414,6 @@ extern struct SLineMatrixData LineMatrixData[240]; #ifndef NO_INTERLACE -#define OFFSET_IN_LINE #define DRAW_PIXEL(N, M) DRAW_PIXEL_N2x1(N, M) #define NAME2 Interlace @@ -1452,10 +1423,7 @@ extern struct SLineMatrixData LineMatrixData[240]; #undef NAME2 #undef DRAW_PIXEL -#undef OFFSET_IN_LINE -#define OFFSET_IN_LINE \ - uint32 OffsetInLine = Offset % GFX.RealPPL; #define DRAW_PIXEL(N, M) DRAW_PIXEL_H2x1(N, M) #define NAME2 HiresInterlace @@ -1465,7 +1433,6 @@ extern struct SLineMatrixData LineMatrixData[240]; #undef NAME2 #undef DRAW_PIXEL -#undef OFFSET_IN_LINE #endif diff --git a/source/snes9x/tile.h b/source/snes9x/tile.h index 04b5075..d4bd94f 100644 --- a/source/snes9x/tile.h +++ b/source/snes9x/tile.h @@ -17,20 +17,13 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - - (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) + zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2018 BearOso, + (c) Copyright 2009 - 2010 BearOso, OV2 - (c) Copyright 2017 qwertymodo - - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) - BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, @@ -124,9 +117,6 @@ Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) - S-SMP emulator code used in 1.54+ - (c) Copyright 2016 byuu - SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) @@ -140,7 +130,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2018 BearOso + (c) Copyright 2004 - 2010 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -148,16 +138,11 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2018 OV2 + (c) Copyright 2009 - 2010 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2011 zones - - Libretro port - (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, - Daniel De Matteis - (Under no circumstances will commercial rights be given) + (c) Copyright 2001 - 2010 zones Specific ports contains the works of other authors. See headers in