2016-08-17 12:31:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//license: GPLv3
|
|
|
|
//started: 2016-08-17
|
|
|
|
|
|
|
|
#include <emulator/emulator.hpp>
|
|
|
|
#include <emulator/thread.hpp>
|
|
|
|
#include <emulator/scheduler.hpp>
|
Update to v102r10 release.
byuu says:
Changelog:
- removed Emulator::Interface::Capabilities¹
- MS: improved the PSG emulation a bit
- MS: added cheat code support
- MS: added save state support²
- MD: emulated the PSG³
¹: there's really no point to it anymore. I intend to add cheat codes
to the GBA core, as well as both cheat codes and save states to the Mega
Drive core. I no longer intend to emulate any new systems, so these
values will always be true. Further, the GUI doesn't respond to these
values to disable those features anymore ever since the hiro rewrite, so
they're double useless.
²: right now, the Z80 core is using a pointer for HL-\>(IX,IY)
overrides. But I can't reliably serialize pointers, so I need to convert
the Z80 core to use an integer here. The save states still appear to
work fine, but there's the potential for an instruction to execute
incorrectly if you're incredibly unlucky, so this needs to be fixed as
soon as possible. Further, I still need a way to serialize
array<T, Size> objects, and I should also add nall::Boolean
serialization support.
³: I don't have a system in place to share identical sound chips. But
this chip is so incredibly simple that it's not really much trouble to
duplicate it. Further, I can strip out the stereo sound support code
from the Game Gear portion, so it's even tinier.
Note that the Mega Drive only just barely uses the PSG. Not at all in
Altered Beast, and only for a tiny part of the BGM music on Sonic 1,
plus his jump sound effect.
2017-02-22 21:25:01 +00:00
|
|
|
#include <emulator/cheat.hpp>
|
2016-08-17 12:31:22 +00:00
|
|
|
|
|
|
|
#include <processor/z80/z80.hpp>
|
|
|
|
|
|
|
|
namespace MasterSystem {
|
2017-01-13 01:15:45 +00:00
|
|
|
#define platform Emulator::platform
|
2017-02-10 23:56:42 +00:00
|
|
|
namespace File = Emulator::File;
|
2016-08-17 12:31:22 +00:00
|
|
|
using Scheduler = Emulator::Scheduler;
|
Update to v102r10 release.
byuu says:
Changelog:
- removed Emulator::Interface::Capabilities¹
- MS: improved the PSG emulation a bit
- MS: added cheat code support
- MS: added save state support²
- MD: emulated the PSG³
¹: there's really no point to it anymore. I intend to add cheat codes
to the GBA core, as well as both cheat codes and save states to the Mega
Drive core. I no longer intend to emulate any new systems, so these
values will always be true. Further, the GUI doesn't respond to these
values to disable those features anymore ever since the hiro rewrite, so
they're double useless.
²: right now, the Z80 core is using a pointer for HL-\>(IX,IY)
overrides. But I can't reliably serialize pointers, so I need to convert
the Z80 core to use an integer here. The save states still appear to
work fine, but there's the potential for an instruction to execute
incorrectly if you're incredibly unlucky, so this needs to be fixed as
soon as possible. Further, I still need a way to serialize
array<T, Size> objects, and I should also add nall::Boolean
serialization support.
³: I don't have a system in place to share identical sound chips. But
this chip is so incredibly simple that it's not really much trouble to
duplicate it. Further, I can strip out the stereo sound support code
from the Game Gear portion, so it's even tinier.
Note that the Mega Drive only just barely uses the PSG. Not at all in
Altered Beast, and only for a tiny part of the BGM music on Sonic 1,
plus his jump sound effect.
2017-02-22 21:25:01 +00:00
|
|
|
using Cheat = Emulator::Cheat;
|
2016-08-17 12:31:22 +00:00
|
|
|
extern Scheduler scheduler;
|
Update to v102r10 release.
byuu says:
Changelog:
- removed Emulator::Interface::Capabilities¹
- MS: improved the PSG emulation a bit
- MS: added cheat code support
- MS: added save state support²
- MD: emulated the PSG³
¹: there's really no point to it anymore. I intend to add cheat codes
to the GBA core, as well as both cheat codes and save states to the Mega
Drive core. I no longer intend to emulate any new systems, so these
values will always be true. Further, the GUI doesn't respond to these
values to disable those features anymore ever since the hiro rewrite, so
they're double useless.
²: right now, the Z80 core is using a pointer for HL-\>(IX,IY)
overrides. But I can't reliably serialize pointers, so I need to convert
the Z80 core to use an integer here. The save states still appear to
work fine, but there's the potential for an instruction to execute
incorrectly if you're incredibly unlucky, so this needs to be fixed as
soon as possible. Further, I still need a way to serialize
array<T, Size> objects, and I should also add nall::Boolean
serialization support.
³: I don't have a system in place to share identical sound chips. But
this chip is so incredibly simple that it's not really much trouble to
duplicate it. Further, I can strip out the stereo sound support code
from the Game Gear portion, so it's even tinier.
Note that the Mega Drive only just barely uses the PSG. Not at all in
Altered Beast, and only for a tiny part of the BGM music on Sonic 1,
plus his jump sound effect.
2017-02-22 21:25:01 +00:00
|
|
|
extern Cheat cheat;
|
2016-08-17 12:31:22 +00:00
|
|
|
|
|
|
|
struct Thread : Emulator::Thread {
|
|
|
|
auto create(auto (*entrypoint)() -> void, double frequency) -> void {
|
|
|
|
Emulator::Thread::create(entrypoint, frequency);
|
|
|
|
scheduler.append(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto synchronize(Thread& thread) -> void {
|
|
|
|
if(clock() >= thread.clock()) scheduler.resume(thread);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-21 11:07:33 +00:00
|
|
|
struct Model {
|
|
|
|
inline static auto MasterSystem() -> bool;
|
|
|
|
inline static auto GameGear() -> bool;
|
|
|
|
};
|
|
|
|
|
Update to v101r28 release.
byuu says:
Changelog:
- SMS: emulated the remaining 240 instructions in the (0xfd, 0xdd)
0xcb (displacement) (opcode) set
- 1/8th of these were "legal" instructions, and apparently games
use them a lot
- SMS: emulated the standard gamepad controllers
- reset button not emulated yet
The reset button is tricky. In every other case, reset is a hardware
thing that instantly reboots the entire machine.
But on the SMS, it's more like a gamepad button that's attached to the
front of the device. When you press it, it fires off a reset vector
interrupt and the gamepad polling routine lets you query the status of
the button.
Just having a reset option in the "Master System" hardware menu is not
sufficient to fully emulate the behavior. Even more annoying is that the
Game Gear doesn't have such a button, yet the core information structs
aren't flexible enough for the Master System to have it, and the Game
Gear to not have it, in the main menu. But that doesn't matter anyway,
since it won't work having it in the menu for the Master System.
So as a result, I'm going to have to have a new "input device" called
"Hardware" that has the "Reset" button listed under there. And for the
sake of consistency, I'm not sure if we should treat the other systems
the same way or not :/
2017-01-08 20:55:02 +00:00
|
|
|
#include <ms/controller/controller.hpp>
|
|
|
|
|
2016-08-17 12:31:22 +00:00
|
|
|
#include <ms/cpu/cpu.hpp>
|
|
|
|
#include <ms/vdp/vdp.hpp>
|
|
|
|
#include <ms/psg/psg.hpp>
|
|
|
|
|
|
|
|
#include <ms/system/system.hpp>
|
|
|
|
#include <ms/cartridge/cartridge.hpp>
|
2016-08-27 04:48:21 +00:00
|
|
|
#include <ms/bus/bus.hpp>
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <ms/interface/interface.hpp>
|