From e8f261384170a590b31c38abc1a7f5d5995d3441 Mon Sep 17 00:00:00 2001 From: Daryl Borth Date: Fri, 10 Aug 2018 10:25:56 -0600 Subject: [PATCH] backport some files from snes9x master --- source/snes9x/65c816.h | 25 +- source/snes9x/bsx.cpp | 1189 +++++++++++++++++++++++----------- source/snes9x/bsx.h | 43 +- source/snes9x/c4.cpp | 26 +- source/snes9x/c4.h | 25 +- source/snes9x/c4emu.cpp | 25 +- source/snes9x/clip.cpp | 25 +- source/snes9x/crosshairs.cpp | 25 +- source/snes9x/crosshairs.h | 29 +- source/snes9x/display.h | 31 +- 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/fxdbg.cpp | 25 +- source/snes9x/fxemu.h | 25 +- source/snes9x/fxinst.cpp | 44 +- source/snes9x/fxinst.h | 25 +- source/snes9x/gfx.h | 25 +- source/snes9x/globals.cpp | 25 +- source/snes9x/language.h | 27 +- source/snes9x/logger.cpp | 25 +- source/snes9x/logger.h | 25 +- 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/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/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.h | 25 +- 55 files changed, 2199 insertions(+), 1082 deletions(-) diff --git a/source/snes9x/65c816.h b/source/snes9x/65c816.h index 995fcbb..183c695 100644 --- a/source/snes9x/65c816.h +++ b/source/snes9x/65c816.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/bsx.cpp b/source/snes9x/bsx.cpp index abee8a7..0070627 100644 --- a/source/snes9x/bsx.cpp +++ b/source/snes9x/bsx.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -182,11 +197,12 @@ #include "snes9x.h" #include "memmap.h" #include "display.h" +#include //#define BSX_DEBUG #define BIOS_SIZE 0x100000 -#define FLASH_SIZE 0x200000 +#define FLASH_SIZE 0x100000 #define PSRAM_SIZE 0x80000 #define Map Memory.Map @@ -205,6 +221,10 @@ struct SBSX_RTC { + int year; + int month; + int dayweek; + int day; int hours; int minutes; int seconds; @@ -218,7 +238,7 @@ static const uint8 flashcard[20] = { 0x4D, 0x00, 0x50, 0x00, // vendor id 0x00, 0x00, // ? - 0x2B, 0x00, // 2MB Flash (1MB = 0x2A) + 0x1A, 0x00, // 2MB Flash (1MB = 0x2A) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -248,10 +268,7 @@ static void BSX_Map_SRAM (void); static void BSX_Map_PSRAM (void); static void BSX_Map_BIOS (void); static void BSX_Map_RAM (void); -static void BSX_Map_Dirty (void); static void BSX_Map (void); -static void BSX_Set_Bypass_FlashIO (uint16, uint8); -static uint8 BSX_Get_Bypass_FlashIO (uint16); static bool8 BSX_LoadBIOS (void); static void map_psram_mirror_sub (uint32); static int is_bsx (unsigned char *); @@ -357,18 +374,32 @@ static void BSX_Map_MMC (void) static void BSX_Map_FlashIO (void) { - int c; + int i, c; - if (BSX.MMC[0x0C] || BSX.MMC[0x0D]) + if (BSX.prevMMC[0x0C]) { - // Bank C0:0000, 2AAA, 5555, FF00-FF1F - for (c = 0; c < 16; c++) + // Banks 00->3F and 80->BF + for (c = 0; c < 0x400; c += 16) { - Map[c + 0xC00] = (uint8 *) MAP_BSX; - BlockIsRAM[c + 0xC00] = TRUE; - BlockIsROM[c + 0xC00] = FALSE; + for (i = c + 8; i < c + 16; i++) + { + Map[i] = Map[i + 0x800] = (uint8 *)MAP_BSX; + BlockIsRAM[i] = BlockIsRAM[i + 0x800] = TRUE; + BlockIsROM[i] = BlockIsROM[i + 0x800] = FALSE; + } } - } + + // Banks 40->7F and C0->FF + for (c = 0; c < 0x400; c += 16) + { + for (i = c; i < c + 16; i++) + { + Map[i + 0x400] = Map[i + 0xC00] = (uint8 *)MAP_BSX; + BlockIsRAM[i + 0x400] = BlockIsRAM[i + 0xC00] = TRUE; + BlockIsROM[i + 0x400] = BlockIsROM[i + 0xC00] = FALSE; + } + } + } } static void BSX_Map_SRAM (void) @@ -390,30 +421,49 @@ static void map_psram_mirror_sub (uint32 bank) bank <<= 4; - if (BSX.MMC[0x02]) + if (BSX.prevMMC[0x02]) { - for (c = 0; c < 0x100; c += 16) + //HiROM + for (c = 0; c < 0x80; c += 16) { - for (i = c; i < c + 16; i++) + if ((bank & 0x7F0) >= 0x400) { - Map[i + bank] = &PSRAM[(c << 12) % PSRAM_SIZE]; - BlockIsRAM[i + bank] = TRUE; - BlockIsROM[i + bank] = FALSE; + for (i = c; i < c + 16; i++) + { + Map[i + bank] = &PSRAM[(c << 12) % PSRAM_SIZE]; + BlockIsRAM[i + bank] = TRUE; + BlockIsROM[i + bank] = FALSE; + } + } + else + { + for (i = c + 8; i < c + 16; i++) + { + Map[i + bank] = &PSRAM[(c << 12) % PSRAM_SIZE]; + BlockIsRAM[i + bank] = TRUE; + BlockIsROM[i + bank] = FALSE; + } } } } else { + //LoROM for (c = 0; c < 0x100; c += 16) { - for (i = c; i < c + 8; i++) - Map[i + bank] = &PSRAM[(c << 11) % PSRAM_SIZE]; + if ((bank & 0x7F0) >= 0x400) + { + for (i = c; i < c + 8; i++) + { + Map[i + bank] = &PSRAM[(c << 11) % PSRAM_SIZE]; + BlockIsRAM[i + bank] = TRUE; + BlockIsROM[i + bank] = FALSE; + } + } for (i = c + 8; i < c + 16; i++) - Map[i + bank] = &PSRAM[(c << 11) % PSRAM_SIZE] - 0x8000; - - for (i = c; i < c + 16; i++) { + Map[i + bank] = &PSRAM[(c << 11) % PSRAM_SIZE] - 0x8000; BlockIsRAM[i + bank] = TRUE; BlockIsROM[i + bank] = FALSE; } @@ -421,42 +471,149 @@ static void map_psram_mirror_sub (uint32 bank) } } -static void BSX_Map_PSRAM (void) +static void BSX_Map_PSRAM(void) { int c; - // Banks 70->77:0000-FFFF - // FIXME: could be toggled by $03 - for (c = 0; c < 0x80; c++) + if (!BSX.prevMMC[0x02]) { - Map[c + 0x700] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; - BlockIsRAM[c + 0x700] = TRUE; - BlockIsROM[c + 0x700] = FALSE; - } + //LoROM Mode + if (!BSX.prevMMC[0x05] && !BSX.prevMMC[0x06]) + { + //Map PSRAM to 00-0F/80-8F + if (BSX.prevMMC[0x03]) + map_psram_mirror_sub(0x00); - // Banks 20->3F:6000-7FFF mirrors 70->77:6000-7FFF - for (c = 0x200; c < 0x400; c += 16) + if (BSX.prevMMC[0x04]) + map_psram_mirror_sub(0x80); + } + else if (BSX.prevMMC[0x05] && !BSX.prevMMC[0x06]) + { + //Map PSRAM to 20-2F/A0-AF + if (BSX.prevMMC[0x03]) + map_psram_mirror_sub(0x20); + + if (BSX.prevMMC[0x04]) + map_psram_mirror_sub(0xA0); + } + else if (!BSX.prevMMC[0x05] && BSX.prevMMC[0x06]) + { + //Map PSRAM to 40-4F/C0-CF + if (BSX.prevMMC[0x03]) + map_psram_mirror_sub(0x40); + + if (BSX.prevMMC[0x04]) + map_psram_mirror_sub(0xC0); + } + else + { + //Map PSRAM to 60-6F/E0-EF + if (BSX.prevMMC[0x03]) + map_psram_mirror_sub(0x60); + + if (BSX.prevMMC[0x04]) + map_psram_mirror_sub(0xE0); + } + + //Map PSRAM to 70-7D/F0-FF + if (BSX.prevMMC[0x03]) + map_psram_mirror_sub(0x70); + + if (BSX.prevMMC[0x04]) + map_psram_mirror_sub(0xF0); + } + else { - Map[c + 6] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; - Map[c + 7] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; - BlockIsRAM[c + 6] = TRUE; - BlockIsRAM[c + 7] = TRUE; - BlockIsROM[c + 6] = FALSE; - BlockIsROM[c + 7] = FALSE; + //HiROM Mode + if (!BSX.prevMMC[0x05] && !BSX.prevMMC[0x06]) + { + //Map PSRAM to 00-07/40-47 / 80-87/C0-C7 + if (BSX.prevMMC[0x03]) + { + map_psram_mirror_sub(0x00); + map_psram_mirror_sub(0x40); + } + + if (BSX.prevMMC[0x04]) + { + map_psram_mirror_sub(0x80); + map_psram_mirror_sub(0xC0); + } + } + else if (BSX.prevMMC[0x05] && !BSX.prevMMC[0x06]) + { + //Map PSRAM to 10-17/50-57 / 90-97-D0-D7 + if (BSX.prevMMC[0x03]) + { + map_psram_mirror_sub(0x10); + map_psram_mirror_sub(0x50); + } + + if (BSX.prevMMC[0x04]) + { + map_psram_mirror_sub(0x90); + map_psram_mirror_sub(0xD0); + } + } + else if (!BSX.prevMMC[0x05] && BSX.prevMMC[0x06]) + { + //Map PSRAM to 20-27/60-67 / A0-A7/E0-E7 + if (BSX.prevMMC[0x03]) + { + map_psram_mirror_sub(0x20); + map_psram_mirror_sub(0x60); + } + + if (BSX.prevMMC[0x04]) + { + map_psram_mirror_sub(0xA0); + map_psram_mirror_sub(0xE0); + } + } + else + { + //Map PSRAM to 30-37/70-77 / B0-B7/F0-F7 + if (BSX.prevMMC[0x03]) + { + map_psram_mirror_sub(0x30); + map_psram_mirror_sub(0x70); + } + + if (BSX.prevMMC[0x04]) + { + map_psram_mirror_sub(0xB0); + map_psram_mirror_sub(0xF0); + } + } + + if (BSX.prevMMC[0x03]) + { + //Map PSRAM to 20->3F:6000-7FFF + for (c = 0x200; c < 0x400; c += 16) + { + Map[c + 6] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; + Map[c + 7] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; + BlockIsRAM[c + 6] = TRUE; + BlockIsRAM[c + 7] = TRUE; + BlockIsROM[c + 6] = FALSE; + BlockIsROM[c + 7] = FALSE; + } + } + + if (BSX.prevMMC[0x04]) + { + //Map PSRAM to A0->BF:6000-7FFF + for (c = 0xA00; c < 0xC00; c += 16) + { + Map[c + 6] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; + Map[c + 7] = &PSRAM[((c & 0x70) << 12) % PSRAM_SIZE]; + BlockIsRAM[c + 6] = TRUE; + BlockIsRAM[c + 7] = TRUE; + BlockIsROM[c + 6] = FALSE; + BlockIsROM[c + 7] = FALSE; + } + } } - - if (!BSX.MMC[0x05]) - // Banks 40->4F:0000-FFFF mirrors 70->77:0000-7FFF - map_psram_mirror_sub(0x40); - - if (!BSX.MMC[0x06]) - // Banks 50->5F:0000-FFFF mirrors 70->77:0000-7FFF - map_psram_mirror_sub(0x50); - - // FIXME - if (!BSX.MMC[0x03]) - // Banks 60->6F:0000-FFFF mirrors 70->77:0000-7FFF (?) - map_psram_mirror_sub(0x60); } static void BSX_Map_BIOS (void) @@ -464,7 +621,7 @@ static void BSX_Map_BIOS (void) int i,c; // Banks 00->1F:8000-FFFF - if (BSX.MMC[0x07]) + if (BSX.prevMMC[0x07]) { for (c = 0; c < 0x200; c += 16) { @@ -478,7 +635,7 @@ static void BSX_Map_BIOS (void) } // Banks 80->9F:8000-FFFF - if (BSX.MMC[0x08]) + if (BSX.prevMMC[0x08]) { for (c = 0; c < 0x200; c += 16) { @@ -508,39 +665,6 @@ static void BSX_Map_RAM (void) } } -static void BSX_Map_Dirty (void) -{ - // for the quick bank change - - int i, c; - - // Banks 00->1F and 80->9F:8000-FFFF - if (BSX.MMC[0x02]) - { - for (c = 0; c < 0x200; c += 16) - { - for (i = c + 8; i < c + 16; i++) - { - Map[i] = Map[i + 0x800] = &MapROM[(c << 12) % FlashSize]; - BlockIsRAM[i] = BlockIsRAM[i + 0x800] = BSX.write_enable; - BlockIsROM[i] = BlockIsROM[i + 0x800] = !BSX.write_enable; - } - } - } - else - { - for (c = 0; c < 0x200; c += 16) - { - for (i = c + 8; i < c + 16; i++) - { - Map[i] = Map[i + 0x800] = &MapROM[(c << 11) % FlashSize] - 0x8000; - BlockIsRAM[i] = BlockIsRAM[i + 0x800] = BSX.write_enable; - BlockIsROM[i] = BlockIsROM[i + 0x800] = !BSX.write_enable; - } - } - } -} - static void BSX_Map (void) { #ifdef BSX_DEBUG @@ -551,42 +675,22 @@ static void BSX_Map (void) memcpy(BSX.prevMMC, BSX.MMC, sizeof(BSX.MMC)); - // Do a quick bank change - if (BSX.dirty2 && !BSX.dirty) - { - BSX_Map_Dirty(); - BSX_Map_BIOS(); - - BSX.dirty2 = FALSE; - - Memory.map_WriteProtectROM(); - return; - } - - if (BSX.MMC[0x01]) - { - MapROM = PSRAM; - FlashSize = PSRAM_SIZE; - } - else - { - MapROM = FlashROM; - FlashSize = FLASH_SIZE; - } - - BSX_Map_SNES(); - - if (BSX.MMC[0x02]) + MapROM = FlashROM; + FlashSize = FLASH_SIZE; + + if (BSX.prevMMC[0x02]) BSX_Map_HiROM(); else BSX_Map_LoROM(); - + + BSX_Map_FlashIO(); BSX_Map_PSRAM(); + + BSX_Map_SNES(); BSX_Map_SRAM(); BSX_Map_RAM(); BSX_Map_BIOS(); - BSX_Map_FlashIO(); BSX_Map_MMC(); // Monitor new register changes @@ -596,30 +700,26 @@ static void BSX_Map (void) Memory.map_WriteProtectROM(); } -static uint8 BSX_Get_Bypass_FlashIO (uint16 offset) +static uint8 BSX_Get_Bypass_FlashIO (uint32 offset) { - if (BSX.MMC[0x02]) - return (MapROM[offset]); + //For games other than BS-X + FlashROM = Memory.ROM + Multi.cartOffsetB; + + if (BSX.prevMMC[0x02]) + return (FlashROM[offset & 0x0FFFFF]); else - { - if (offset < 0x8000) - return (MapROM[offset]); - else - return (MapROM[offset - 0x8000]); - } + return (FlashROM[(offset & 0x1F0000) >> 1 | (offset & 0x7FFF)]); } -static void BSX_Set_Bypass_FlashIO (uint16 offset, uint8 byte) +static void BSX_Set_Bypass_FlashIO (uint32 offset, uint8 byte) { - if (BSX.MMC[0x02]) - MapROM[offset] = byte; + //For games other than BS-X + FlashROM = Memory.ROM + Multi.cartOffsetB; + + if (BSX.prevMMC[0x02]) + FlashROM[offset & 0x0FFFFF] = FlashROM[offset & 0x0FFFFF] & byte; else - { - if (offset < 0x8000) - MapROM[offset] = byte; - else - MapROM[offset - 0x8000] = byte; - } + FlashROM[(offset & 0x1F0000) >> 1 | (offset & 0x7FFF)] = FlashROM[(offset & 0x1F0000) >> 1 | (offset & 0x7FFF)] & byte; } uint8 S9xGetBSX (uint32 address) @@ -629,43 +729,54 @@ uint8 S9xGetBSX (uint32 address) uint8 t = 0; // MMC - if ((bank >= 0x01 && bank <= 0x0E) && (offset == 0x5000)) + if ((bank >= 0x01 && bank <= 0x0E) && ((address & 0xF000) == 0x5000)) return (BSX.MMC[bank]); - // Flash IO - if (bank == 0xC0) + // Flash Mapping + + // default: read-through mode + t = BSX_Get_Bypass_FlashIO(address); + + // note: may be more registers, purposes unknown + switch (offset) { - // default: read-through mode - t = BSX_Get_Bypass_FlashIO(offset); + case 0x0002: + case 0x8002: + if (BSX.flash_bsr) + t = 0xC0; // Page Status Register + break; - // note: may be more registers, purposes unknown - switch (offset) - { - case 0x0002: - if (BSX.flash_enable) - t = 0x80; // status register? - break; + case 0x0004: + case 0x8004: + if (BSX.flash_gsr) + t = 0x82; // Global Status Register + break; - case 0x5555: - if (BSX.flash_enable) - t = 0x80; // ??? - break; + case 0x5555: + if (BSX.flash_enable) + t = 0x80; // ??? + break; - case 0xFF00: - case 0xFF02: - case 0xFF04: - case 0xFF06: - case 0xFF08: - case 0xFF0A: - case 0xFF0C: - case 0xFF0E: - case 0xFF10: - case 0xFF12: - // return flash vendor information - if (BSX.read_enable) - t = flashcard[offset - 0xFF00]; - break; - } + case 0xFF00: + case 0xFF02: + case 0xFF04: + case 0xFF06: + case 0xFF08: + case 0xFF0A: + case 0xFF0C: + case 0xFF0E: + case 0xFF10: + case 0xFF12: + // return flash vendor information + if (BSX.read_enable) + t = flashcard[offset - 0xFF00]; + break; + } + + if (BSX.flash_csr) + { + t = 0x80; // Compatible Status Register + BSX.flash_csr = false; } return (t); @@ -674,120 +785,236 @@ uint8 S9xGetBSX (uint32 address) void S9xSetBSX (uint8 byte, uint32 address) { uint8 bank = (address >> 16) & 0xFF; - uint16 offset = address & 0xFFFF; // MMC - if ((bank >= 0x01 && bank <= 0x0E) && (offset == 0x5000)) + if ((bank >= 0x01 && bank <= 0x0E) && ((address & 0xF000) == 0x5000)) { - switch (bank) + //Avoid updating the memory map when it is not needed + if (bank == 0x0E && BSX.dirty) { - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - if (BSX.MMC[bank] != byte) - { - BSX.MMC[bank] = byte; - BSX.dirty = TRUE; - } - break; - - case 0x07: - case 0x08: - if (BSX.MMC[bank] != byte) - { - BSX.MMC[bank] = byte; - BSX.dirty2 = TRUE; - } - break; - - case 0x0E: - BSX.MMC[bank] = byte; - if (byte && (BSX.dirty || BSX.dirty2)) - BSX_Map(); - break; + BSX_Map(); + BSX.dirty = FALSE; } + else if (bank != 0x0E && BSX.MMC[bank] != byte) + { + BSX.dirty = TRUE; + } + + BSX.MMC[bank] = byte; } // Flash IO - if (bank == 0xC0) + + // Write to Flash + if (BSX.write_enable) { - BSX.old_write = BSX.new_write; - BSX.new_write = address; - - // ???: double writes to the desired address will bypass - // flash registers - if (BSX.old_write == BSX.new_write && BSX.write_enable) - { - BSX_Set_Bypass_FlashIO(offset, byte); - return; - } - - // flash command handling - // note: incomplete - switch (offset) - { - case 0x0000: - BSX.flash_command <<= 8; - BSX.flash_command |= byte; - if ((BSX.flash_command & 0xFFFF) == 0x38D0) - { - // retrieve information about the flash card - BSX.flash_enable = TRUE; - BSX.read_enable = TRUE; - } - break; - - case 0x2AAA: - BSX.flash_command <<= 8; - BSX.flash_command |= byte; - break; - - case 0x5555: - BSX.flash_command <<= 8; - BSX.flash_command |= byte; - - switch (BSX.flash_command & 0xFFFFFF) - { - case 0xAA55F0: - // turn off flash i/o - BSX.flash_enable = FALSE; - BSX.write_enable = FALSE; - BSX.read_enable = FALSE; - break; - - case 0xAA55A0: - // enable writing to flash - BSX.old_write = 0; - BSX.new_write = 0; - BSX.flash_enable = TRUE; - BSX.write_enable = TRUE; - BSX_Map(); - break; - - case 0xAA5570: - // turn on write-protection - BSX.write_enable = FALSE; - BSX_Map(); - break; - - case 0xAA5580: - case 0xAA5510: - // ??? - break; - - } - - break; - } + BSX_Set_Bypass_FlashIO(address, byte); + BSX.write_enable = false; + return; } + + // Flash Command Handling + + //Memory Pack Type 1 & 3 & 4 + BSX.flash_command <<= 8; + BSX.flash_command |= byte; + + switch (BSX.flash_command & 0xFF) + { + case 0x00: + case 0xFF: + //Reset to normal + BSX.flash_enable = false; + BSX.flash_bsr = false; + BSX.flash_csr = false; + BSX.flash_gsr = false; + BSX.read_enable = false; + BSX.write_enable = false; + BSX.flash_cmd_done = true; + break; + + case 0x10: + case 0x40: + //Write Byte + BSX.flash_enable = false; + BSX.flash_bsr = false; + BSX.flash_csr = true; + BSX.flash_gsr = false; + BSX.read_enable = false; + BSX.write_enable = true; + BSX.flash_cmd_done = true; + break; + + case 0x50: + //Clear Status Register + BSX.flash_enable = false; + BSX.flash_bsr = false; + BSX.flash_csr = false; + BSX.flash_gsr = false; + BSX.flash_cmd_done = true; + break; + + case 0x70: + //Read CSR + BSX.flash_enable = false; + BSX.flash_bsr = false; + BSX.flash_csr = true; + BSX.flash_gsr = false; + BSX.read_enable = false; + BSX.write_enable = false; + BSX.flash_cmd_done = true; + break; + + case 0x71: + //Read Extended Status Registers (Page and Global) + BSX.flash_enable = false; + BSX.flash_bsr = true; + BSX.flash_csr = false; + BSX.flash_gsr = true; + BSX.read_enable = false; + BSX.write_enable = false; + BSX.flash_cmd_done = true; + break; + + case 0x75: + //Show Page Buffer / Vendor Info + BSX.flash_csr = false; + BSX.read_enable = true; + BSX.flash_cmd_done = true; + break; + + case 0xD0: + //DO COMMAND + switch (BSX.flash_command & 0xFFFF) + { + case 0x20D0: //Block Erase + uint32 x; + for (x = 0; x < 0x10000; x++) { + //BSX_Set_Bypass_FlashIO(((address & 0xFF0000) + x), 0xFF); + if (BSX.MMC[0x02]) + FlashROM[(address & 0x0F0000) + x] = 0xFF; + else + FlashROM[((address & 0x1E0000) >> 1) + x] = 0xFF; + } + break; + + case 0xA7D0: //Chip Erase (ONLY IN TYPE 1 AND 4) + if ((flashcard[6] & 0xF0) == 0x10 || (flashcard[6] & 0xF0) == 0x40) + { + uint32 x; + for (x = 0; x < FLASH_SIZE; x++) { + //BSX_Set_Bypass_FlashIO(x, 0xFF); + FlashROM[x] = 0xFF; + } + } + break; + + case 0x38D0: //Flashcart Reset + break; + } + break; + } +} + +void S9xBSXSetStream1 (uint8 count) +{ + if (BSX.sat_stream1.is_open()) + BSX.sat_stream1.close(); //If Stream already opened for one file: Close it. + + char path[PATH_MAX + 1], name[PATH_MAX + 1]; + + strcpy(path, S9xGetDirectory(SAT_DIR)); + strcat(path, SLASH_STR); + + snprintf(name, PATH_MAX + 1, "BSX%04X-%d.bin", (BSX.PPU[0x2188 - BSXPPUBASE] | (BSX.PPU[0x2189 - BSXPPUBASE] * 256)), count); //BSXHHHH-DDD.bin + strcat(path, name); + + BSX.sat_stream1.clear(); + BSX.sat_stream1.open(path, std::ios::in | std::ios::binary); + if (BSX.sat_stream1.good()) + { + BSX.sat_stream1.seekg(0, BSX.sat_stream1.end); + long str1size = BSX.sat_stream1.tellg(); + BSX.sat_stream1.seekg(0, BSX.sat_stream1.beg); + float QueueSize = str1size / 22.; + BSX.sat_stream1_queue = (uint16)(ceil(QueueSize)); + BSX.PPU[0x218D - BSXPPUBASE] = 0; + BSX.sat_stream1_first = TRUE; + BSX.sat_stream1_loaded = TRUE; + } + else + { + BSX.sat_stream1_loaded = FALSE; + } +} + +void S9xBSXSetStream2 (uint8 count) +{ + if (BSX.sat_stream2.is_open()) + BSX.sat_stream2.close(); //If Stream already opened for one file: Close it. + + char path[PATH_MAX + 1], name[PATH_MAX + 1]; + + strcpy(path, S9xGetDirectory(SAT_DIR)); + strcat(path, SLASH_STR); + + snprintf(name, PATH_MAX + 1, "BSX%04X-%d.bin", (BSX.PPU[0x218E - BSXPPUBASE] | (BSX.PPU[0x218F - BSXPPUBASE] * 256)), count); //BSXHHHH-DDD.bin + strcat(path, name); + + BSX.sat_stream2.clear(); + BSX.sat_stream2.open(path, std::ios::in | std::ios::binary); + if (BSX.sat_stream2.good()) + { + BSX.sat_stream2.seekg(0, BSX.sat_stream2.end); + long str2size = BSX.sat_stream2.tellg(); + BSX.sat_stream2.seekg(0, BSX.sat_stream2.beg); + float QueueSize = str2size / 22.; + BSX.sat_stream2_queue = (uint16)(ceil(QueueSize)); + BSX.PPU[0x2193 - BSXPPUBASE] = 0; + BSX.sat_stream2_first = TRUE; + BSX.sat_stream2_loaded = TRUE; + } + else + { + BSX.sat_stream2_loaded = FALSE; + } +} + +uint8 S9xBSXGetRTC (void) +{ + //Get Time + time_t t; + struct tm *tmr; + + time(&t); + tmr = localtime(&t); + + BSX.test2192[0] = 0x00; + BSX.test2192[1] = 0x00; + BSX.test2192[2] = 0x00; + BSX.test2192[3] = 0x00; + BSX.test2192[4] = 0x10; + BSX.test2192[5] = 0x01; + BSX.test2192[6] = 0x01; + BSX.test2192[7] = 0x00; + BSX.test2192[8] = 0x00; + BSX.test2192[9] = 0x00; + BSX.test2192[10] = BSX_RTC.seconds = tmr->tm_sec; + BSX.test2192[11] = BSX_RTC.minutes = tmr->tm_min; + BSX.test2192[12] = BSX_RTC.hours = tmr->tm_hour; + BSX.test2192[13] = BSX_RTC.dayweek = (tmr->tm_wday) + 1; + BSX.test2192[14] = BSX_RTC.day = tmr->tm_mday; + BSX.test2192[15] = BSX_RTC.month = (tmr->tm_mon) + 1; + BSX_RTC.year = tmr->tm_year + 1900; + BSX.test2192[16] = (BSX_RTC.year) & 0xFF; + BSX.test2192[17] = (BSX_RTC.year) >> 8; + + t = BSX.test2192[BSX.out_index++]; + + if (BSX.out_index > 22) + BSX.out_index = 0; + + return t; } uint8 S9xGetBSXPPU (uint16 address) @@ -797,95 +1024,268 @@ uint8 S9xGetBSXPPU (uint16 address) // known read registers switch (address) { - // Test register low? (r/w) + //Stream 1 + // Logical Channel 1 + Data Structure (R/W) case 0x2188: t = BSX.PPU[0x2188 - BSXPPUBASE]; break; - // Test register high? (r/w) + // Logical Channel 2 (R/W) [6bit] case 0x2189: t = BSX.PPU[0x2189 - BSXPPUBASE]; break; + // Prefix Count (R) case 0x218A: - t = BSX.PPU[0x218A - BSXPPUBASE]; + if (!BSX.sat_pf_latch1_enable || !BSX.sat_dt_latch1_enable) + { + t = 0; + break; + } + + if (BSX.PPU[0x2188 - BSXPPUBASE] == 0 && BSX.PPU[0x2189 - BSXPPUBASE] == 0) + { + t = 1; + break; + } + + if (BSX.sat_stream1_queue <= 0) + { + BSX.sat_stream1_count++; + S9xBSXSetStream1(BSX.sat_stream1_count - 1); + } + + if (!BSX.sat_stream1_loaded && (BSX.sat_stream1_count - 1) > 0) + { + BSX.sat_stream1_count = 1; + S9xBSXSetStream1(BSX.sat_stream1_count - 1); + } + + if (BSX.sat_stream1_loaded) + { + //Lock at 0x7F for bigger packets + if (BSX.sat_stream1_queue >= 128) + BSX.PPU[0x218A - BSXPPUBASE] = 0x7F; + else + BSX.PPU[0x218A - BSXPPUBASE] = BSX.sat_stream1_queue; + t = BSX.PPU[0x218A - BSXPPUBASE]; + } + else + t = 0; break; + // Prefix Latch (R/W) + case 0x218B: + if (BSX.sat_pf_latch1_enable) + { + if (BSX.PPU[0x2188 - BSXPPUBASE] == 0 && BSX.PPU[0x2189 - BSXPPUBASE] == 0) + { + BSX.PPU[0x218B - BSXPPUBASE] = 0x90; + } + + if (BSX.sat_stream1_loaded) + { + uint8 temp = 0; + if (BSX.sat_stream1_first) + { + // First packet + temp |= 0x10; + BSX.sat_stream1_first = FALSE; + } + + BSX.sat_stream1_queue--; + + if (BSX.sat_stream1_queue == 0) + { + //Last packet + temp |= 0x80; + } + + BSX.PPU[0x218B - BSXPPUBASE] = temp; + } + + BSX.PPU[0x218D - BSXPPUBASE] |= BSX.PPU[0x218B - BSXPPUBASE]; + t = BSX.PPU[0x218B - BSXPPUBASE]; + } + else + { + t = 0; + } + break; + + // Data Latch (R/W) case 0x218C: - t = BSX.PPU[0x218C - BSXPPUBASE]; + if (BSX.sat_dt_latch1_enable) + { + if (BSX.PPU[0x2188 - BSXPPUBASE] == 0 && BSX.PPU[0x2189 - BSXPPUBASE] == 0) + { + BSX.PPU[0x218C - BSXPPUBASE] = S9xBSXGetRTC(); + } + else if (BSX.sat_stream1_loaded) + { + if (BSX.sat_stream1.eof()) + BSX.PPU[0x218C - BSXPPUBASE] = 0xFF; + else + BSX.PPU[0x218C - BSXPPUBASE] = BSX.sat_stream1.get(); + } + t = BSX.PPU[0x218C - BSXPPUBASE]; + } + else + { + t = 0; + } break; - // Transmission number low? (r/w) + // OR gate (R) + case 0x218D: + t = BSX.PPU[0x218D - BSXPPUBASE]; + BSX.PPU[0x218D - BSXPPUBASE] = 0; + break; + + //Stream 2 + // Logical Channel 1 + Data Structure (R/W) case 0x218E: t = BSX.PPU[0x218E - BSXPPUBASE]; break; - // Transmission number high? (r/w) + // Logical Channel 2 (R/W) [6bit] case 0x218F: t = BSX.PPU[0x218F - BSXPPUBASE]; break; - // Status register? (r) + // Prefix Count (R) case 0x2190: - t = BSX.PPU[0x2190 - BSXPPUBASE]; + if (!BSX.sat_pf_latch2_enable || !BSX.sat_dt_latch2_enable) + { + t = 0; + break; + } + + if (BSX.PPU[0x218E - BSXPPUBASE] == 0 && BSX.PPU[0x218F - BSXPPUBASE] == 0) + { + t = 1; + break; + } + + if (BSX.sat_stream2_queue <= 0) + { + BSX.sat_stream2_count++; + S9xBSXSetStream2(BSX.sat_stream2_count - 1); + } + + if (!BSX.sat_stream2_loaded && (BSX.sat_stream2_count - 1) > 0) + { + BSX.sat_stream2_count = 1; + S9xBSXSetStream2(BSX.sat_stream2_count - 1); + } + + if (BSX.sat_stream2_loaded) + { + if (BSX.sat_stream2_queue >= 128) + BSX.PPU[0x2190 - BSXPPUBASE] = 0x7F; + else + BSX.PPU[0x2190 - BSXPPUBASE] = BSX.sat_stream2_queue; + t = BSX.PPU[0x2190 - BSXPPUBASE]; + } + else + t = 0; break; - // Data register? (r/w) + // Prefix Latch (R/W) + case 0x2191: + if (BSX.sat_pf_latch2_enable) + { + if (BSX.PPU[0x218E - BSXPPUBASE] == 0 && BSX.PPU[0x218F - BSXPPUBASE] == 0) + { + BSX.PPU[0x2191 - BSXPPUBASE] = 0x90; + } + + if (BSX.sat_stream2_loaded) + { + uint8 temp = 0; + if (BSX.sat_stream2_first) + { + // First packet + temp |= 0x10; + BSX.sat_stream2_first = FALSE; + } + + BSX.sat_stream2_queue--; + + if (BSX.sat_stream2_queue == 0) + { + //Last packet + temp |= 0x80; + } + + BSX.PPU[0x2191 - BSXPPUBASE] = temp; + } + + BSX.PPU[0x2193 - BSXPPUBASE] |= BSX.PPU[0x2191 - BSXPPUBASE]; + t = BSX.PPU[0x2191 - BSXPPUBASE]; + } + else + { + t = 0; + } + break; + + // Data Latch (R/W) case 0x2192: - t = BSX.PPU[0x2192 - BSXPPUBASE]; - - // test - t = BSX.test2192[BSX.out_index++]; - if (BSX.out_index == 32) - BSX.out_index = 0; - - BSX_RTC.ticks++; - if (BSX_RTC.ticks >= 1000) + if (BSX.sat_dt_latch2_enable) { - BSX_RTC.ticks = 0; - BSX_RTC.seconds++; + if (BSX.PPU[0x218E - BSXPPUBASE] == 0 && BSX.PPU[0x218F - BSXPPUBASE] == 0) + { + BSX.PPU[0x2192 - BSXPPUBASE] = S9xBSXGetRTC(); + } + else if (BSX.sat_stream2_loaded) + { + if (BSX.sat_stream2.eof()) + BSX.PPU[0x2192 - BSXPPUBASE] = 0xFF; + else + BSX.PPU[0x2192 - BSXPPUBASE] = BSX.sat_stream2.get(); + } + t = BSX.PPU[0x2192 - BSXPPUBASE]; } - if (BSX_RTC.seconds >= 60) + else { - BSX_RTC.seconds = 0; - BSX_RTC.minutes++; + t = 0; } - if (BSX_RTC.minutes >= 60) - { - BSX_RTC.minutes = 0; - BSX_RTC.hours++; - } - if (BSX_RTC.hours >= 24) - BSX_RTC.hours = 0; - - BSX.test2192[10] = BSX_RTC.seconds; - BSX.test2192[11] = BSX_RTC.minutes; - BSX.test2192[12] = BSX_RTC.hours; - break; - // Transmission status? (r/w) + // OR gate (R) case 0x2193: - // Data ready when bits 2/3 clear? - t = BSX.PPU[0x2193 - BSXPPUBASE] & ~0x0C; + t = BSX.PPU[0x2193 - BSXPPUBASE]; + BSX.PPU[0x2193 - BSXPPUBASE] = 0; break; - // Reset? (r/w) + //Other + // Satellaview LED / Stream Enable (R/W) [4bit] case 0x2194: t = BSX.PPU[0x2194 - BSXPPUBASE]; break; - // Unknown (r) + // Unknown + case 0x2195: + t = BSX.PPU[0x2195 - BSXPPUBASE]; + break; + + // Satellaview Status (R) case 0x2196: t = BSX.PPU[0x2196 - BSXPPUBASE]; break; - // Unknown (r/w) + // Soundlink Settings (R/W) case 0x2197: t = BSX.PPU[0x2197 - BSXPPUBASE]; break; - // Modem protocol? (r/w) + // Serial I/O - Serial Number (R/W) + case 0x2198: + t = BSX.PPU[0x2198 - BSXPPUBASE]; + break; + + // Serial I/O - Unknown (R/W) case 0x2199: t = BSX.PPU[0x2199 - BSXPPUBASE]; break; @@ -903,78 +1303,82 @@ void S9xSetBSXPPU (uint8 byte, uint16 address) // known write registers switch (address) { - // Test register low? (r/w) + //Stream 1 + // Logical Channel 1 + Data Structure (R/W) case 0x2188: + if (BSX.PPU[0x2188 - BSXPPUBASE] == byte) + { + BSX.sat_stream1_count = 0; + } BSX.PPU[0x2188 - BSXPPUBASE] = byte; break; - // Test register high? (r/w) + // Logical Channel 2 (R/W) [6bit] case 0x2189: - BSX.PPU[0x2189 - BSXPPUBASE] = byte; - break; - - case 0x218A: - BSX.PPU[0x218A - BSXPPUBASE] = byte; + if (BSX.PPU[0x2188 - BSXPPUBASE] == (byte & 0x3F)) + { + BSX.sat_stream1_count = 0; + } + BSX.PPU[0x2189 - BSXPPUBASE] = byte & 0x3F; break; + // Prefix Latch (R/W) case 0x218B: - BSX.PPU[0x218B - BSXPPUBASE] = byte; + BSX.sat_pf_latch1_enable = (byte != 0); break; + // Data Latch (R/W) case 0x218C: - BSX.PPU[0x218C - BSXPPUBASE] = byte; + if (BSX.PPU[0x2188 - BSXPPUBASE] == 0 && BSX.PPU[0x2189 - BSXPPUBASE] == 0) + { + BSX.out_index = 0; + } + BSX.sat_dt_latch1_enable = (byte != 0); break; - // Transmission number low? (r/w) + //Stream 2 + // Logical Channel 1 + Data Structure (R/W) case 0x218E: + if (BSX.PPU[0x218E - BSXPPUBASE] == byte) + { + BSX.sat_stream2_count = 0; + } BSX.PPU[0x218E - BSXPPUBASE] = byte; break; - // Transmission number high? (r/w) + // Logical Channel 2 (R/W) [6bit] case 0x218F: - BSX.PPU[0x218F - BSXPPUBASE] = byte; - - // ? - BSX.PPU[0x218E - BSXPPUBASE] >>= 1; - BSX.PPU[0x218E - BSXPPUBASE] = BSX.PPU[0x218F - BSXPPUBASE] - BSX.PPU[0x218E - BSXPPUBASE]; - BSX.PPU[0x218F - BSXPPUBASE] >>= 1; - - BSX.PPU[0x2190 - BSXPPUBASE] = 0x80; // ? + if (BSX.PPU[0x218F - BSXPPUBASE] == (byte & 0x3F)) + { + BSX.sat_stream2_count = 0; + } + BSX.PPU[0x218F - BSXPPUBASE] = byte & 0x3F; break; - // Strobe assert? (w) + // Prefix Latch (R/W) case 0x2191: - BSX.PPU[0x2191 - BSXPPUBASE] = byte; - BSX.out_index = 0; + BSX.sat_pf_latch2_enable = (byte != 0); break; - // Data register? (r/w) + // Data Latch (R/W) case 0x2192: - BSX.PPU[0x2192 - BSXPPUBASE] = 0x01; // ? - BSX.PPU[0x2190 - BSXPPUBASE] = 0x80; // ? + if (BSX.PPU[0x218E - BSXPPUBASE] == 0 && BSX.PPU[0x218F - BSXPPUBASE] == 0) + { + BSX.out_index = 0; + } + BSX.sat_dt_latch2_enable = (byte != 0); break; - // Transmission status? (r/w) - case 0x2193: - BSX.PPU[0x2193 - BSXPPUBASE] = byte; - break; - - // Reset? (r/w) + //Other + // Satellaview LED / Stream Enable (R/W) [4bit] case 0x2194: - BSX.PPU[0x2194 - BSXPPUBASE] = byte; + BSX.PPU[0x2194 - BSXPPUBASE] = byte & 0x0F; break; - // Unknown (r/w) + // Soundlink Settings (R/W) case 0x2197: BSX.PPU[0x2197 - BSXPPUBASE] = byte; break; - - // Modem protocol? (r/w) - case 0x2199: - // Lots of modem strings written here when - // connection is lost or no uplink established - BSX.PPU[0x2199 - BSXPPUBASE] = byte; - break; } } @@ -985,10 +1389,6 @@ uint8 * S9xGetBasePointerBSX (uint32 address) static bool8 BSX_LoadBIOS (void) { -#ifdef GEKKO - return FALSE; // We're not loading the BIOS! -#endif - FILE *fp; char path[PATH_MAX + 1], name[PATH_MAX + 1]; bool8 r = FALSE; @@ -1026,11 +1426,19 @@ static bool8 BSX_LoadBIOS (void) return (r); } +static bool8 is_BSX_BIOS (const uint8 *data, uint32 size) +{ + if (size == BIOS_SIZE && strncmp((char *) (data + 0x7FC0), "Satellaview BS-X ", 21) == 0) + return (TRUE); + else + return (FALSE); +} + void S9xInitBSX (void) { Settings.BS = FALSE; - if (!memcmp(&Memory.ROM[0x7FC0], "Satellaview BS-X ", 21)) + if (is_BSX_BIOS(Memory.ROM,Memory.CalculatedSize)) { // BS-X itself @@ -1067,7 +1475,13 @@ void S9xInitBSX (void) uint8 *header = r1 ? Memory.ROM + 0x7FC0 : Memory.ROM + 0xFFC0; FlashMode = (header[0x18] & 0xEF) == 0x20 ? FALSE : TRUE; - FlashSize = (header[0x19] & 0x20) ? PSRAM_SIZE : FLASH_SIZE; + FlashSize = FLASH_SIZE; + + // Fix Block Allocation Flags + // (for games that don't have it setup properly, + // for exemple when taken seperately from the upper memory of the Memory Pack, + // else the game will error out on BS-X) + for (; (((header[0x10] & 1) == 0) && header[0x10] != 0); (header[0x10] >>= 1)); #ifdef BSX_DEBUG for (int i = 0; i <= 0x1F; i++) @@ -1077,7 +1491,7 @@ void S9xInitBSX (void) BSX.bootup = Settings.BSXBootup; - if (!BSX_LoadBIOS()) + if (!BSX_LoadBIOS() && !is_BSX_BIOS(BIOSROM,BIOS_SIZE)) { BSX.bootup = FALSE; memset(BIOSROM, 0, BIOS_SIZE); @@ -1089,7 +1503,7 @@ void S9xInitBSX (void) { MapROM = NULL; FlashROM = Memory.ROM; - + /* time_t t; struct tm *tmr; @@ -1104,6 +1518,7 @@ void S9xInitBSX (void) #ifdef BSX_DEBUG printf("BS: Current Time: %02d:%02d:%02d\n", BSX_RTC.hours, BSX_RTC.minutes, BSX_RTC.seconds); #endif + */ SNESGameFixes.SRAMInitialValue = 0x00; } } @@ -1130,34 +1545,32 @@ void S9xResetBSX (void) memset(BSX.output, 0, sizeof(BSX.output)); // starting from the bios - if (BSX.bootup) - BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80; - else - { - BSX.MMC[0x02] = FlashMode ? 0x80: 0; + BSX.MMC[0x02] = BSX.MMC[0x03] = BSX.MMC[0x05] = BSX.MMC[0x06] = 0x80; + BSX.MMC[0x09] = BSX.MMC[0x0B] = 0x80; - // per bios: run from psram or flash card - if (FlashSize == PSRAM_SIZE) - { - memcpy(PSRAM, FlashROM, PSRAM_SIZE); + BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80; + BSX.MMC[0x0E] = 0x80; - BSX.MMC[0x01] = 0x80; - BSX.MMC[0x03] = 0x80; - BSX.MMC[0x04] = 0x80; - BSX.MMC[0x0C] = 0x80; - BSX.MMC[0x0D] = 0x80; - } - else - { - BSX.MMC[0x03] = 0x80; - BSX.MMC[0x05] = 0x80; - BSX.MMC[0x06] = 0x80; - } + // default register values + BSX.PPU[0x2196 - BSXPPUBASE] = 0x10; + BSX.PPU[0x2197 - BSXPPUBASE] = 0x80; - BSX.MMC[0x0E] = 0x80; - } + // stream reset + BSX.sat_pf_latch1_enable = BSX.sat_dt_latch1_enable = FALSE; + BSX.sat_pf_latch2_enable = BSX.sat_dt_latch2_enable = FALSE; - BSX_Map(); + BSX.sat_stream1_loaded = BSX.sat_stream2_loaded = FALSE; + BSX.sat_stream1_first = BSX.sat_stream2_first = FALSE; + BSX.sat_stream1_count = BSX.sat_stream2_count = 0; + + if (BSX.sat_stream1.is_open()) + BSX.sat_stream1.close(); + + if (BSX.sat_stream2.is_open()) + BSX.sat_stream2.close(); + + if (Settings.BS) + BSX_Map(); } void S9xBSXPostLoadState (void) diff --git a/source/snes9x/bsx.h b/source/snes9x/bsx.h index d88bb19..03bdd17 100644 --- a/source/snes9x/bsx.h +++ b/source/snes9x/bsx.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -178,6 +193,8 @@ #ifndef _BSX_H_ #define _BSX_H_ +#include + struct SBSX { bool8 dirty; // Changed register values @@ -195,6 +212,22 @@ struct SBSX uint8 MMC[16]; uint8 prevMMC[16]; uint8 test2192[32]; + + bool flash_csr; + bool flash_gsr; + bool flash_bsr; + bool flash_cmd_done; + + std::ifstream sat_stream1; + std::ifstream sat_stream2; + + bool sat_pf_latch1_enable, sat_dt_latch1_enable; + bool sat_pf_latch2_enable, sat_dt_latch2_enable; + + bool sat_stream1_loaded, sat_stream2_loaded; + bool sat_stream1_first, sat_stream2_first; + uint8 sat_stream1_count, sat_stream2_count; + uint16 sat_stream1_queue, sat_stream2_queue; }; extern struct SBSX BSX; diff --git a/source/snes9x/c4.cpp b/source/snes9x/c4.cpp index d586e79..922c205 100644 --- a/source/snes9x/c4.cpp +++ b/source/snes9x/c4.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -294,7 +309,6 @@ 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 9b4c607..bbd3780 100644 --- a/source/snes9x/c4.h +++ b/source/snes9x/c4.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/c4emu.cpp b/source/snes9x/c4emu.cpp index 65e0f55..4efb531 100644 --- a/source/snes9x/c4emu.cpp +++ b/source/snes9x/c4emu.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/clip.cpp b/source/snes9x/clip.cpp index 8e6baa3..5ff8c8a 100644 --- a/source/snes9x/clip.cpp +++ b/source/snes9x/clip.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/crosshairs.cpp b/source/snes9x/crosshairs.cpp index 7c3f385..f3b8d35 100644 --- a/source/snes9x/crosshairs.cpp +++ b/source/snes9x/crosshairs.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/crosshairs.h b/source/snes9x/crosshairs.h index 16c3811..d5de800 100644 --- a/source/snes9x/crosshairs.h +++ b/source/snes9x/crosshairs.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -199,6 +214,7 @@ const char * S9xGetCrosshair (int idx); // Superscope: 2 White Black // Justifier 1: 4 Blue Black // Justifier 2: 4 MagicPink Black +// Macs Rifle: 2 White Black // // Available colors are: Trans, Black, 25Grey, 50Grey, 75Grey, White, Red, Orange, // Yellow, Green, Cyan, Sky, Blue, Violet, MagicPink, and Purple. @@ -211,7 +227,8 @@ enum crosscontrols X_MOUSE2, X_SUPERSCOPE, X_JUSTIFIER1, - X_JUSTIFIER2 + X_JUSTIFIER2, + X_MACSRIFLE }; void S9xSetControllerCrosshair (enum crosscontrols ctl, int8 idx, const char *fg, const char *bg); diff --git a/source/snes9x/display.h b/source/snes9x/display.h index fa78408..b41c11e 100644 --- a/source/snes9x/display.h +++ b/source/snes9x/display.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -178,6 +193,8 @@ #ifndef _DISPLAY_H_ #define _DISPLAY_H_ +#include "snes9x.h" + enum s9x_getdirtype { DEFAULT_DIR = 0, @@ -189,14 +206,16 @@ enum s9x_getdirtype SCREENSHOT_DIR, SPC_DIR, CHEAT_DIR, - IPS_DIR, + PATCH_DIR, BIOS_DIR, LOG_DIR, + SAT_DIR, LAST_DIR }; void S9xUsage (void); char * S9xParseArgs (char **, int); +void S9xParseArgsForCheats (char **, int); void S9xLoadConfigFiles (char **, int); void S9xSetInfoString (const char *); diff --git a/source/snes9x/dma.h b/source/snes9x/dma.h index c779a79..b5fa5c1 100644 --- a/source/snes9x/dma.h +++ b/source/snes9x/dma.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp.cpp b/source/snes9x/dsp.cpp index b6e23ff..ab54185 100644 --- a/source/snes9x/dsp.cpp +++ b/source/snes9x/dsp.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp.h b/source/snes9x/dsp.h index be4d073..7b9d371 100644 --- a/source/snes9x/dsp.h +++ b/source/snes9x/dsp.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp1.cpp b/source/snes9x/dsp1.cpp index 85f9512..1628744 100644 --- a/source/snes9x/dsp1.cpp +++ b/source/snes9x/dsp1.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -881,9 +896,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 @@ -1354,7 +1369,7 @@ void DSP1SetByte (uint8 byte, uint16 address) case 0x17: case 0x37: case 0x3F: - DSP1.command = 0x1f; + DSP1.command = 0x1f; // Fall through case 0x1f: DSP1.in_count = 1; break; default: #ifdef DEBUGGER @@ -1885,7 +1900,7 @@ uint8 DSP1GetByte (uint16 address) DSP1.waiting4command = TRUE; } else - t = 0xff; + t = 0x80; } else t = 0x80; diff --git a/source/snes9x/dsp2.cpp b/source/snes9x/dsp2.cpp index 477209b..fb6c9f8 100644 --- a/source/snes9x/dsp2.cpp +++ b/source/snes9x/dsp2.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/dsp3.cpp b/source/snes9x/dsp3.cpp index 5c79240..9ee6a5d 100644 --- a/source/snes9x/dsp3.cpp +++ b/source/snes9x/dsp3.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -1139,7 +1154,7 @@ static void DSP3_OP10 (void) DSP3_Reset(); else // absorb 2 bytes - DSP3.DR = DSP3.DR; + DSP3.DR = DSP3.DR; // FIXME? } /* diff --git a/source/snes9x/dsp4.cpp b/source/snes9x/dsp4.cpp index 9d6f3fd..63530db 100644 --- a/source/snes9x/dsp4.cpp +++ b/source/snes9x/dsp4.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/font.h b/source/snes9x/font.h index 27011f6..9614f45 100644 --- a/source/snes9x/font.h +++ b/source/snes9x/font.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/fxdbg.cpp b/source/snes9x/fxdbg.cpp index ed97123..0b7fb77 100644 --- a/source/snes9x/fxdbg.cpp +++ b/source/snes9x/fxdbg.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/fxemu.h b/source/snes9x/fxemu.h index b2ce64e..ac73d11 100644 --- a/source/snes9x/fxemu.h +++ b/source/snes9x/fxemu.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/fxinst.cpp b/source/snes9x/fxinst.cpp index 5f7df2b..b25251c 100644 --- a/source/snes9x/fxinst.cpp +++ b/source/snes9x/fxinst.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -891,14 +906,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); @@ -955,14 +970,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); @@ -1171,7 +1186,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; @@ -4137,7 +4152,6 @@ 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 dd3736e..d2124bd 100644 --- a/source/snes9x/fxinst.h +++ b/source/snes9x/fxinst.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/gfx.h b/source/snes9x/gfx.h index 75981cc..64e93b3 100644 --- a/source/snes9x/gfx.h +++ b/source/snes9x/gfx.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/globals.cpp b/source/snes9x/globals.cpp index 54312dc..a89e74c 100644 --- a/source/snes9x/globals.cpp +++ b/source/snes9x/globals.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/language.h b/source/snes9x/language.h index 49a30ae..408a914 100644 --- a/source/snes9x/language.h +++ b/source/snes9x/language.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -195,7 +210,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 "Incompatable snapshot version" +#define SAVE_ERR_WRONG_VERSION "Incompatible 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 235c533..12dc923 100644 --- a/source/snes9x/logger.cpp +++ b/source/snes9x/logger.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/logger.h b/source/snes9x/logger.h index 63aa30b..a4dd102 100644 --- a/source/snes9x/logger.h +++ b/source/snes9x/logger.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/messages.h b/source/snes9x/messages.h index f346a7c..168ec52 100644 --- a/source/snes9x/messages.h +++ b/source/snes9x/messages.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/missing.h b/source/snes9x/missing.h index 9a41fab..8c2dd11 100644 --- a/source/snes9x/missing.h +++ b/source/snes9x/missing.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/movie.cpp b/source/snes9x/movie.cpp index 31d0765..d68cbbe 100644 --- a/source/snes9x/movie.cpp +++ b/source/snes9x/movie.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -437,14 +452,14 @@ static void reset_controllers (void) MovieSetJoypad(i, 0); uint8 clearedMouse[MOUSE_DATA_SIZE]; - ZeroMemory(clearedMouse, MOUSE_DATA_SIZE); + memset(clearedMouse, 0, MOUSE_DATA_SIZE); clearedMouse[4] = 1; uint8 clearedScope[SCOPE_DATA_SIZE]; - ZeroMemory(clearedScope, SCOPE_DATA_SIZE); + memset(clearedScope, 0, SCOPE_DATA_SIZE); uint8 clearedJustifier[JUSTIFIER_DATA_SIZE]; - ZeroMemory(clearedJustifier, JUSTIFIER_DATA_SIZE); + memset(clearedJustifier, 0, JUSTIFIER_DATA_SIZE); for (int p = 0; p < 2; p++) { @@ -639,7 +654,7 @@ static void write_movie_header (FILE *fd, SMovie *movie) { uint8 buf[SMV_HEADER_SIZE], *ptr = buf; - ZeroMemory(buf, sizeof(buf)); + memset(buf, 0, sizeof(buf)); Write32(SMV_MAGIC, ptr); Write32(SMV_VERSION, ptr); @@ -771,7 +786,8 @@ int S9xMovieUnfreeze (uint8 *buf, uint32 size) } else { - if (current_frame > Movie.MaxFrame || current_sample > Movie.MaxSample || memcmp(Movie.InputBuffer, ptr, space_needed)) + uint32 space_processed = (Movie.BytesPerSample * (current_sample + 1)); + if (current_frame > Movie.MaxFrame || current_sample > Movie.MaxSample || memcmp(Movie.InputBuffer, ptr, space_processed)) return (SNAPSHOT_INCONSISTENT); change_state(MOVIE_STATE_PLAY); @@ -812,14 +828,16 @@ int S9xMovieOpen (const char *filename, bool8 read_only) read_movie_extrarominfo(fd, &Movie); - fn = dup(fileno(fd)); - fclose(fd); + fflush(fd); + fn = fileno(fd); store_previous_settings(); restore_movie_settings(); lseek(fn, Movie.SaveStateOffset, SEEK_SET); - stream = REOPEN_STREAM(fn, "rb"); + + // reopen stream to access as gzipped data + stream = REOPEN_STREAM(fn, "rb"); if (!stream) return (FILE_NOT_FOUND); @@ -832,7 +850,11 @@ int S9xMovieOpen (const char *filename, bool8 read_only) else result = S9xUnfreezeFromStream(stream); - CLOSE_STREAM(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); if (result != SUCCESS) return (result); @@ -846,7 +868,10 @@ 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(); @@ -879,7 +904,6 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co { FILE *fd; STREAM stream; - int fn; if (controllers_mask == 0) return (WRONG_FORMAT); @@ -928,10 +952,9 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co write_movie_extrarominfo(fd, &Movie); - fn = dup(fileno(fd)); fclose(fd); - stream = REOPEN_STREAM(fn, "ab"); + stream = OPEN_STREAM(filename, "ab"); if (!stream) return (FILE_NOT_FOUND); @@ -989,14 +1012,17 @@ int S9xMovieGetInfo (const char *filename, struct MovieInfo *info) flush_movie(); - ZeroMemory(info, sizeof(*info)); + memset(info, 0, 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; @@ -1035,9 +1061,10 @@ int S9xMovieGetInfo (const char *filename, struct MovieInfo *info) strncpy(info->ROMName, local_movie.ROMName, 23); fclose(fd); - - if (access(filename, W_OK)) + if ((fd = fopen(filename, "r+")) == NULL) info->ReadOnly = true; + else + fclose(fd); return (SUCCESS); } @@ -1117,7 +1144,7 @@ void S9xMovieUpdateOnReset (void) void S9xMovieInit (void) { - ZeroMemory(&Movie, sizeof(Movie)); + memset(&Movie, 0, sizeof(Movie)); Movie.State = MOVIE_STATE_NONE; } diff --git a/source/snes9x/movie.h b/source/snes9x/movie.h index f1fb2bb..ff8eed5 100644 --- a/source/snes9x/movie.h +++ b/source/snes9x/movie.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -184,10 +199,8 @@ #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 6f63bcb..837626b 100644 --- a/source/snes9x/msu1.cpp +++ b/source/snes9x/msu1.cpp @@ -22,10 +22,12 @@ (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2016 BearOso, + (c) Copyright 2009 - 2018 BearOso, OV2 - (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, + (c) Copyright 2017 qwertymodo + + (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -138,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2016 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -146,14 +148,14 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2016 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles (c) Copyright 2001 - 2011 zones Libretro port - (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -190,12 +192,13 @@ Nintendo Co., Limited and its subsidiary companies. ***********************************************************************************/ -#include "msu1.h" -#include "display.h" -#include "filebrowser.h" +#include "snes9x.h" #include "memmap.h" -#include "snes9xgx.h" +#include "display.h" +#include "msu1.h" #include "apu/bapu/dsp/blargg_endian.h" +#include +#include STREAM dataStream = NULL; STREAM audioStream = NULL; @@ -241,7 +244,7 @@ static int unzFindExtension(unzFile &file, const char *ext, bool restart = TRUE, STREAM S9xMSU1OpenFile(const char *msu_ext, bool skip_unpacked) { - char filename[MAXPATHLEN]; + char filename[1024]; sprintf(filename, "%s%s%s", Memory.ROMFilePath, Memory.ROMFilename, msu_ext); STREAM file = 0; @@ -257,10 +260,15 @@ 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) { - char zip_filename[MAXPATHLEN]; - sprintf(zip_filename, "%s%s.msu1", Memory.ROMFilePath, Memory.ROMFilename); + const char *zip_filename = S9xGetFilename(".msu1", ROMFILENAME_DIR); 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); @@ -312,8 +320,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; @@ -381,7 +389,6 @@ void S9xMSU1DeInit(void) AudioClose(); } - bool S9xMSU1ROMExists(void) { STREAM s = S9xMSU1OpenFile(".msu"); @@ -391,9 +398,15 @@ bool S9xMSU1ROMExists(void) return true; } #ifdef UNZIP_SUPPORT - char fname[MAXPATHLEN]; - sprintf(fname, "%s%s.msu1", Memory.ROMFilePath, Memory.ROMFilename); - unzFile unzFile = unzOpen(fname); + 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)); if (unzFile) { @@ -416,14 +429,15 @@ 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; } @@ -433,12 +447,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 add366b..8537613 100644 --- a/source/snes9x/msu1.h +++ b/source/snes9x/msu1.h @@ -22,10 +22,12 @@ (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2016 BearOso, + (c) Copyright 2009 - 2018 BearOso, OV2 - (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, + (c) Copyright 2017 qwertymodo + + (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -138,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2016 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -146,14 +148,14 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2016 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles (c) Copyright 2001 - 2011 zones Libretro port - (c) Copyright 2011 - 2016 Hans-Kristian Arntzen, + (c) Copyright 2011 - 2017 Hans-Kristian Arntzen, Daniel De Matteis (Under no circumstances will commercial rights be given) @@ -193,8 +195,6 @@ #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 9fe98de..803f6a1 100644 --- a/source/snes9x/obc1.cpp +++ b/source/snes9x/obc1.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/obc1.h b/source/snes9x/obc1.h index 836850b..a8de868 100644 --- a/source/snes9x/obc1.h +++ b/source/snes9x/obc1.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/pixform.h b/source/snes9x/pixform.h index 1760899..51b143e 100644 --- a/source/snes9x/pixform.h +++ b/source/snes9x/pixform.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sar.h b/source/snes9x/sar.h index f53de57..9bc6555 100644 --- a/source/snes9x/sar.h +++ b/source/snes9x/sar.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/screenshot.cpp b/source/snes9x/screenshot.cpp index ec8f750..8410944 100644 --- a/source/snes9x/screenshot.cpp +++ b/source/snes9x/screenshot.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/screenshot.h b/source/snes9x/screenshot.h index 6839ba0..1cb6efc 100644 --- a/source/snes9x/screenshot.h +++ b/source/snes9x/screenshot.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1.cpp b/source/snes9x/sdd1.cpp index 40cd4c9..f56b4b1 100644 --- a/source/snes9x/sdd1.cpp +++ b/source/snes9x/sdd1.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1.h b/source/snes9x/sdd1.h index 7419b5b..244704f 100644 --- a/source/snes9x/sdd1.h +++ b/source/snes9x/sdd1.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1emu.cpp b/source/snes9x/sdd1emu.cpp index c4f4d36..00e0c79 100644 --- a/source/snes9x/sdd1emu.cpp +++ b/source/snes9x/sdd1emu.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/sdd1emu.h b/source/snes9x/sdd1emu.h index 5722b4b..a53c9b9 100644 --- a/source/snes9x/sdd1emu.h +++ b/source/snes9x/sdd1emu.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta.cpp b/source/snes9x/seta.cpp index e7fd24c..c726399 100644 --- a/source/snes9x/seta.cpp +++ b/source/snes9x/seta.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta.h b/source/snes9x/seta.h index ee49097..2cd64ea 100644 --- a/source/snes9x/seta.h +++ b/source/snes9x/seta.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta010.cpp b/source/snes9x/seta010.cpp index 45cf877..dce3ee6 100644 --- a/source/snes9x/seta010.cpp +++ b/source/snes9x/seta010.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in @@ -216,72 +231,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] = { - { 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 } + { 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 } }; // Mode 7 scaling constants for all raster lines @@ -316,6 +331,7 @@ 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) @@ -328,47 +344,43 @@ static int16 ST010_Cos (int16 Theta) return (ST010_SinTable[((Theta + 0x4000) >> 8) & 0xff]); } -static void ST010_OP01 (int16 x0, int16 y0, int16 &x1, int16 &y1, int16 &Quadrant, int16 &Theta) -{ - if ((x0 < 0) && (y0 < 0)) - { +void ST010_Compass(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; } - if (y1 == 0) - Quadrant += 0x4000; + Theta = ST010_ArcTan[x1 & 0x1f][y1 & 0x1f] << 8; + Theta = (Theta | Quadrant) ^ 0x8000; - Theta = (ST010_ArcTan[y1][x1] << 8) ^ Quadrant; + if ((x0 == 0) && (y0 < 0)) Quadrant = 0x4000; } static void ST010_Scale (int16 Multiplier, int16 X0, int16 Y0, int32 &X1, int32 &Y1) @@ -421,17 +433,108 @@ static void ST010_SortDrivers (uint16 Positions, uint16 Places[32], uint16 Drive } } -/* -static void SETA_Distance (int16 Y0, int16 X0, int16 &Distance) +static void ST010_Raster(int16 Theta) { - if (X0 < 0) - X0 = -X0; - if (Y0 < 0) - Y0 = -Y0; + int16 data; + int offset = 0; - Distance = ((X0 * 0x7af0) + 0x4000) >> 15; + 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; + } } -*/ uint8 S9xGetST010 (uint32 Address) { @@ -471,16 +574,32 @@ 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 @@ -513,15 +632,6 @@ 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 @@ -543,14 +653,74 @@ 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 @@ -569,45 +739,13 @@ 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: { - 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; - } + #ifdef FAST_LSB_WORD_ACCESS + ST010_Raster(*(int16 *) &Memory.SRAM[0x0000]); + #else + ST010_Raster(ST010_WORD(0x0000)); + #endif // Shift Angle for use with Lookup table Memory.SRAM[0x00] = Memory.SRAM[0x01]; @@ -617,15 +755,6 @@ 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 @@ -643,212 +772,6 @@ 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 b49a8b8..3590692 100644 --- a/source/snes9x/seta011.cpp +++ b/source/snes9x/seta011.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/seta018.cpp b/source/snes9x/seta018.cpp index 24efb5c..80d24bd 100644 --- a/source/snes9x/seta018.cpp +++ b/source/snes9x/seta018.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/spc7110.cpp b/source/snes9x/spc7110.cpp index 5ead658..533f45f 100644 --- a/source/snes9x/spc7110.cpp +++ b/source/snes9x/spc7110.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/spc7110.h b/source/snes9x/spc7110.h index 7002b50..8e7ecd2 100644 --- a/source/snes9x/spc7110.h +++ b/source/snes9x/spc7110.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/spc7110dec.cpp b/source/snes9x/spc7110dec.cpp index 65d5586..ab7521b 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() - 0x100000; + unsigned size = memory_cartrom_size() > 0x500000 ? memory_cartrom_size() - 0x200000 : 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_t[decomp_buffer_size]; + decomp_buffer = new uint8[decomp_buffer_size]; reset(); //initialize reverse morton lookup tables diff --git a/source/snes9x/spc7110emu.cpp b/source/snes9x/spc7110emu.cpp index 69b3e7d..8ce99b8 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() - 0x100000; + unsigned size = memory_cartrom_size() > 0x500000 ? memory_cartrom_size() - 0x200000 : 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 ca7b91c..978a207 100644 --- a/source/snes9x/srtc.cpp +++ b/source/snes9x/srtc.cpp @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/srtc.h b/source/snes9x/srtc.h index 8bc441c..d21ea98 100644 --- a/source/snes9x/srtc.h +++ b/source/snes9x/srtc.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in diff --git a/source/snes9x/tile.h b/source/snes9x/tile.h index d4bd94f..04b5075 100644 --- a/source/snes9x/tile.h +++ b/source/snes9x/tile.h @@ -17,13 +17,20 @@ (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja - (c) Copyright 2009 - 2010 BearOso, + (c) Copyright 2009 - 2018 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, @@ -117,6 +124,9 @@ 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) @@ -130,7 +140,7 @@ (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code - (c) Copyright 2004 - 2010 BearOso + (c) Copyright 2004 - 2018 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, @@ -138,11 +148,16 @@ Matthew Kendora, Nach, nitsuja - (c) Copyright 2009 - 2010 OV2 + (c) Copyright 2009 - 2018 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2010 zones + (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) Specific ports contains the works of other authors. See headers in