Sync latest changes from upstream repo

This commit is contained in:
rdanbrook 2022-11-02 21:32:16 -06:00
parent 8ea127c38d
commit 1365c2cbbc
16 changed files with 473 additions and 12 deletions

View file

@ -666,6 +666,10 @@ nestopia_SOURCES = \
source/core/board/NstBoardAction53.hpp \
source/core/board/NstBoardWaixingFs304.cpp \
source/core/board/NstBoardWaixingFs304.hpp \
source/core/board/NstBoardUnl158b.cpp \
source/core/board/NstBoardUnl158b.hpp \
source/core/board/NstBoardUnlRetX7Gbl.cpp \
source/core/board/NstBoardUnlRetX7Gbl.hpp \
source/core/NstPins.hpp \
source/core/NstNsf.hpp \
source/core/NstTrackerRewinder.hpp \

View file

@ -7062,6 +7062,9 @@
</cartridge>
</game>
<game>
<peripherals>
<device type="pachinko" />
</peripherals>
<cartridge system="Famicom" dump="unknown" crc="44F92026" sha1="9266BE2FD5D0C712FE7BF873D32AE50506A9B277">
<board mapper="1">
<prg size="128k" />
@ -15981,6 +15984,9 @@
</cartridge>
</game>
<game>
<peripherals>
<device type="pachinko" />
</peripherals>
<cartridge system="Famicom" dump="unknown" crc="9B3C5124" sha1="A96BFC7B51E2F7FF69F42B024CC9FB85CA9A943D">
<board mapper="4">
<prg size="256k" />
@ -20371,6 +20377,9 @@
</cartridge>
</game>
<game>
<peripherals>
<device type="pachinko" />
</peripherals>
<cartridge system="Famicom" dump="unknown" crc="C22C23AB" sha1="4CEA0ECDF0A22E678B827C9BFD8D80B5DEBB4094">
<board mapper="1">
<prg size="128k" />
@ -23635,6 +23644,9 @@
</cartridge>
</game>
<game>
<peripherals>
<device type="pachinko" />
</peripherals>
<cartridge system="Famicom" dump="unknown" crc="E08C8A60" sha1="BAF3A4E0423A86E53234E806843149EF7D0974A9">
<board mapper="4">
<prg size="512k" />
@ -27170,4 +27182,27 @@
</board>
</cartridge>
</game>
<game>
<peripherals>
<device type="zapper" />
</peripherals>
<cartridge system="NES-NTSC" dump="unknown" crc="1CA9C322" sha1="17869C4F55461D50E134CC3A4D15B89E7CAF8DE3">
<board mapper="258">
<prg size="128k" />
<chr size="128k" />
</board>
</cartridge>
</game>
<game>
<peripherals>
<device type="pokkunmoguraa" />
</peripherals>
<cartridge system="Famicom" dump="unknown" crc="C7BCC981" sha1="8A0DEADD84A0967B1D2DB0634262C7BDBBB732B7">
<board mapper="3">
<prg size="32k" />
<chr size="32k" />
<pad h="0" v="1" />
</board>
</cartridge>
</game>
</database>

View file

@ -147,7 +147,7 @@ namespace Nes
Log::Flush( "Ines: PRG-ROM was patched" NST_LINEBREAK );
if (Load( chr, 16 + prg.Size() ))
Log::Flush( "Ines: PRG-ROM was patched" NST_LINEBREAK );
Log::Flush( "Ines: CHR-ROM was patched" NST_LINEBREAK );
}
private:

View file

@ -221,17 +221,36 @@ namespace Nes
{
NST_ASSERT( it->length );
bool underflow = false;
dword uflow_length = 0;
if (it->offset < offset)
continue;
{
if (it->offset + it->length > offset)
{
underflow = true;
uflow_length = offset - it->offset;
}
else
{
continue;
}
}
if (it->offset >= offset + length)
break;
const dword pos = it->offset - offset;
const dword part = NST_MIN(it->length,length-pos);
dword pos = it->offset - offset;
dword part = NST_MIN(it->length,length-pos);
if (underflow)
{
part -= uflow_length;
pos += uflow_length;
}
if (it->fill == NO_FILL)
std::memcpy( dst + pos, it->data, part );
std::memcpy( dst + pos, it->data + uflow_length, part );
else
std::memset( dst + pos, it->fill, part );

View file

@ -400,6 +400,8 @@ namespace Nes
state.End();
}
output.bgColor = palette.ram[0] & uint(Palette::COLOR);
UpdateStates();
}
@ -992,7 +994,7 @@ namespace Nes
palette.ram[address ^ 0x10] = data;
output.palette[address ^ 0x10] = final;
}
output.bgColor = palette.ram[0] & uint(Palette::COLOR);
}
else

View file

@ -42,7 +42,7 @@ namespace Nes
void Renderer::FilterNtsc::BlitType(const Input& input,const Output& output,uint phase) const
{
NST_ASSERT( phase < 3 );
const uint bgcolor = this->bgColor;
const Input::Pixel* NST_RESTRICT src = input.pixels;
Pixel* NST_RESTRICT dst = static_cast<Pixel*>(output.pixels);

View file

@ -823,7 +823,7 @@ namespace Nes
if (Output::lockCallback( output ))
{
NST_VERIFY( std::labs(output.pitch) >= dword(state.width) << (filter->format.bpp / 16) );
filter->bgColor = bgColor;
if (std::labs(output.pitch) >= dword(state.width) << (filter->format.bpp / 16))

View file

@ -67,7 +67,7 @@ namespace Nes
HEIGHT = Input::HEIGHT,
PIXELS = Input::PIXELS,
PALETTE = Input::PALETTE,
DEFAULT_PALETTE = PALETTE_YUV
NST_DEFAULT_PALETTE = PALETTE_YUV
};
Result SetState(const RenderState&);

View file

@ -320,7 +320,7 @@ namespace Nes
Video::Palette::Mode Video::Palette::GetDefaultMode() const throw()
{
NST_COMPILE_ASSERT( Core::Video::Renderer::DEFAULT_PALETTE - Core::Video::Renderer::PALETTE_YUV == 0 );
NST_COMPILE_ASSERT( Core::Video::Renderer::NST_DEFAULT_PALETTE - Core::Video::Renderer::PALETTE_YUV == 0 );
return MODE_YUV;
}

View file

@ -97,6 +97,7 @@
#include "NstBoardWaixing.hpp"
#include "NstBoardWhirlwind.hpp"
#include "NstBoardBenshengBs5.hpp"
#include "NstBoardUnl158b.hpp"
#include "NstBoardUnlA9746.hpp"
#include "NstBoardUnlCc21.hpp"
#include "NstBoardUnlEdu2000.hpp"
@ -105,6 +106,7 @@
#include "NstBoardUnlMmc3BigPrgRom.hpp"
#include "NstBoardUnlMortalKombat2.hpp"
#include "NstBoardUnlN625092.hpp"
#include "NstBoardUnlRetX7Gbl.hpp"
#include "NstBoardUnlSuperFighter3.hpp"
#include "NstBoardUnlTf1201.hpp"
#include "NstBoardUnlWorldHero.hpp"
@ -1097,6 +1099,7 @@ namespace Nes
{ "TENGEN-800032", Type::TENGEN_800032 },
{ "TENGEN-800037", Type::TENGEN_800037 },
{ "TENGEN-800042", Type::TENGEN_800042 },
{ "UNL-158B", Type::UNL_158B },
{ "UNL-22211", Type::TXC_22211A },
{ "UNL-603-5052", Type::BTL_6035052 },
{ "UNL-8237", Type::SUPERGAME_POCAHONTAS2 },
@ -3393,6 +3396,12 @@ namespace Nes
id = Type::BMC_110IN1;
break;
case 258:
name = "UNL-158B";
id = Type::UNL_158B;
break;
case 262:
name = "UNL-SHERO";
@ -3502,6 +3511,12 @@ namespace Nes
id = Type::BMC_SUPER_40IN1;
break;
case 400:
name = "UNL-RET-X7-GBL";
id = Type::UNL_RETX7GBL;
break;
case 521:
name = "DREAMTECH01";
@ -3895,6 +3910,7 @@ namespace Nes
case Type::TXC_MXMDHTWO : return new Txc::Mxmdhtwo(c);
case Type::TXC_POLICEMAN : return new Txc::Policeman(c);
case Type::TXC_TW : return new Txc::Tw(c);
case Type::UNL_158B : return new Unlicensed::Gd98158b(c);
case Type::UNL_A9746 : return new Unlicensed::A9746(c);
case Type::UNL_CC21 : return new Unlicensed::Cc21(c);
case Type::UNL_EDU2000 : return new Unlicensed::Edu2000(c);
@ -3904,6 +3920,7 @@ namespace Nes
case Type::UNL_MMC3BIGPRGROM : return new Unlicensed::Mmc3BigPrgRom(c);
case Type::UNL_MORTALKOMBAT2 : return new Unlicensed::MortalKombat2(c);
case Type::UNL_N625092 : return new Unlicensed::N625092(c);
case Type::UNL_RETX7GBL : return new Unlicensed::RetX7Gbl(c);
case Type::UNL_SUPERFIGHTER3 : return new Unlicensed::SuperFighter3(c);
case Type::UNL_SHERO : return new Sachen::StreetHeroes(c);
case Type::UNL_TF1201 : return new Unlicensed::Tf1201(c);

View file

@ -540,6 +540,7 @@ namespace Nes
TXC_POLICEMAN = MakeId< 36, 512, 128, 0, 0, CRM_0, NMT_X, 0 >::ID,
TXC_TW = MakeId< 189, 128, 256, 0, 0, CRM_0, NMT_X, 0 >::ID,
// Unlicensed
UNL_158B = MakeId< 258, 128, 128, 0, 0, CRM_0, NMT_X, 0 >::ID,
UNL_A9746 = MakeId< 219, 128, 256, 0, 0, CRM_0, NMT_X, 0 >::ID,
UNL_CC21 = MakeId< 27, 32, 8, 0, 0, CRM_0, NMT_Z, 0 >::ID,
UNL_EDU2000 = MakeId< 329, 1024, 0, 0, 32, CRM_8, NMT_Z, 0 >::ID,
@ -548,6 +549,7 @@ namespace Nes
UNL_KINGOFFIGHTERS97 = MakeId< 263, 256, 256, 0, 0, CRM_0, NMT_X, 0 >::ID,
UNL_MORTALKOMBAT2 = MakeId< 91, 256, 512, 0, 0, CRM_0, NMT_X, 0 >::ID,
UNL_N625092 = MakeId< 221, 1024, 8, 0, 0, CRM_0, NMT_V, 0 >::ID,
UNL_RETX7GBL = MakeId< 400, 2048, 0, 0, 0, CRM_32, NMT_X, 0 >::ID,
UNL_SUPERFIGHTER3 = MakeId< 197, 512, 512, 0, 0, CRM_0, NMT_X, 0 >::ID,
UNL_SHERO = MakeId< 262, 512, 512, 0, 0, CRM_8, NMT_4, 0 >::ID,
UNL_TF1201 = MakeId< 298, 128, 128, 0, 0, CRM_0, NMT_V, 0 >::ID,

View file

@ -34,7 +34,7 @@ namespace Nes
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("s", on)
#endif
void InlNsf::SubReset(const bool hard)
{
Map ( 0x5000U, 0x5FFFU, &InlNsf::Poke_5000 );
@ -86,7 +86,7 @@ namespace Nes
{
Bank(address & 7, data);
}
NES_PEEK_A(InlNsf,8000)
{
// Not an ideal way to do this, but Nestopia does not seem to support 4K banks directly?

View file

@ -0,0 +1,129 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2022 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nestopia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#include "NstBoard.hpp"
#include "NstBoardUnl158b.hpp"
/* References:
https://github.com/SourMesen/Mesen/blob/master/Core/Unl158B.h
https://github.com/TASVideos/fceux/blob/master/src/boards/158B.cpp
*/
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Unlicensed
{
Gd98158b::Gd98158b(const Context& c)
: Mmc3(c) {}
void Gd98158b::SubReset(const bool hard)
{
lut[0] = lut[1] = lut[2] = lut[7] = 0x00;
lut[3] = 0x01;
lut[4] = 0x02;
lut[5] = 0x04;
lut[6] = 0x0F;
if (hard)
reg = 0;
banks.prg[0] = 0x00;
banks.prg[1] = 0x01;
banks.prg[2] = 0x3E;
banks.prg[3] = 0x3F;
Mmc3::SubReset( hard );
Map( 0x5000U, 0x5FFFU, &Gd98158b::Peek_5000 );
Map( 0x5000U, 0x5FFFU, &Gd98158b::Poke_5000 );
}
void Gd98158b::SubLoad(State::Loader& state,const dword baseChunk)
{
if (baseChunk == AsciiId<'1','5','8'>::V)
{
while (const dword chunk = state.Begin())
{
if (chunk == AsciiId<'R','E','G'>::V)
reg = state.Read8();
state.End();
}
}
else
{
Mmc3::SubLoad( state, baseChunk );
}
}
void Gd98158b::SubSave(State::Saver& state) const
{
Mmc3::SubSave( state );
state.Begin( AsciiId<'1','5','8'>::V ).Begin( AsciiId<'R','E','G'>::V ).Write8( reg ).End().End();
}
void NST_FASTCALL Gd98158b::UpdatePrg(uint address, uint data)
{
if (reg & 0x80)
{
const uint bank = reg & 0x7;
if (reg & 0x20)
{
prg.SwapBank<SIZE_32K>( 0x0000, bank >> 1 );
}
else
{
prg.SwapBank<SIZE_16K>( 0x0000, bank );
prg.SwapBank<SIZE_16K>( 0x4000, bank );
}
}
else
{
prg.SwapBank<SIZE_8K>( (address & 0x6000), data & 0xF );
}
}
NES_PEEK_A(Gd98158b,5000)
{
// Fake Open Bus read by always using 0x50
return 0x50 | lut[address & 0x7];
}
NES_POKE_AD(Gd98158b,5000)
{
if ((address & 0x7) == 0)
{
reg = data;
Mmc3::UpdatePrg();
}
}
}
}
}
}

View file

@ -0,0 +1,67 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2022 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nestopia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#ifndef NST_BOARD_UNL_158B_H
#define NST_BOARD_UNL_158B_H
#ifdef NST_PRAGMA_ONCE
#pragma once
#endif
#include "NstBoardMmc3.hpp"
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Unlicensed
{
class Gd98158b : public Mmc3
{
public:
explicit Gd98158b(const Context&);
private:
void SubReset(bool);
void SubLoad(State::Loader&,dword);
void SubSave(State::Saver&) const;
void UpdatePrg(uint, uint);
NES_DECL_PEEK( 5000 );
NES_DECL_POKE( 5000 );
byte lut[8];
uint reg;
};
}
}
}
}
#endif

View file

@ -0,0 +1,119 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2022 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nestopia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
/* References:
https://github.com/NovaSquirrel/Mesen-X/blob/master/Core/Mapper400.h
*/
#include "NstBoard.hpp"
#include "NstBoardUnlRetX7Gbl.hpp"
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Unlicensed
{
void RetX7Gbl::SubReset(bool)
{
Map( 0x7800U, 0x7FFFU, &RetX7Gbl::Poke_7800 );
Map( 0x8000U, 0xBFFFU, &RetX7Gbl::Poke_8000 );
Map( 0xC000U, 0xFFFFU, &RetX7Gbl::Poke_C000 );
regs[0] = 0x80;
regs[1] = 0x00;
UpdatePrg();
}
void RetX7Gbl::SubLoad(State::Loader& state,const dword baseChunk)
{
if (baseChunk == AsciiId<'R','X','G'>::V)
{
while (const dword chunk = state.Begin())
{
if (chunk == AsciiId<'R','E','G'>::V)
{
State::Loader::Data<3> data( state );
regs[0] = data[0];
regs[1] = data[1];
led = data[2];
}
state.End();
}
}
UpdatePrg();
}
void RetX7Gbl::SubSave(State::Saver& state) const
{
state.Begin( AsciiId<'R','X','G'>::V );
const byte data[3] =
{
regs[0], regs[1], led
};
state.Begin( AsciiId<'R','E','G'>::V ).Write( data ).End();
state.End();
}
void RetX7Gbl::UpdatePrg()
{
prg.SwapBank<SIZE_16K,0x0000>( (regs[0] & 0x78) | (regs[1] & 0x7) );
prg.SwapBank<SIZE_16K,0x4000>( (regs[0] & 0x78) | 0x7 );
if (regs[0] != 0x80)
{
ppu.SetMirroring( regs[0] & 0x20 ? Ppu::NMT_H : Ppu::NMT_V );
}
}
NES_POKE_D(RetX7Gbl,7800)
{
regs[0] = data;
UpdatePrg();
}
NES_POKE_D(RetX7Gbl,8000)
{
led = data;
}
NES_POKE_D(RetX7Gbl,C000)
{
regs[1] = data;
UpdatePrg();
chr.SwapBank<SIZE_8K,0x0000>( (data >> 5) & 0x3 );
}
}
}
}
}

View file

@ -0,0 +1,67 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2022 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nestopia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#ifndef NST_BOARD_UNL_RETX7GBL_H
#define NST_BOARD_UNL_RETX7GBL_H
#ifdef NST_PRAGMA_ONCE
#pragma once
#endif
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Unlicensed
{
class RetX7Gbl : public Board
{
public:
explicit RetX7Gbl(const Context& c)
: Board(c) {}
private:
void SubReset(bool);
void SubLoad(State::Loader&,dword);
void SubSave(State::Saver&) const;
void UpdatePrg();
NES_DECL_POKE( 7800 );
NES_DECL_POKE( 8000 );
NES_DECL_POKE( C000 );
uint regs[2];
uint led;
};
}
}
}
}
#endif