2016-08-17 12:31:22 +00:00
|
|
|
#include <ms/ms.hpp>
|
|
|
|
|
|
|
|
namespace MasterSystem {
|
|
|
|
|
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 "peripherals.cpp"
|
2016-08-17 12:31:22 +00:00
|
|
|
System system;
|
|
|
|
Scheduler scheduler;
|
|
|
|
|
|
|
|
auto System::run() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
if(scheduler.enter() == Scheduler::Event::Frame) vdp.refresh();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 01:15:45 +00:00
|
|
|
auto System::load(Emulator::Interface* interface, Model model) -> bool {
|
2016-08-19 14:11:26 +00:00
|
|
|
information = {};
|
|
|
|
information.model = model;
|
|
|
|
|
2017-01-13 01:15:45 +00:00
|
|
|
if(auto fp = platform->open(ID::System, "manifest.bml", File::Read, File::Required)) {
|
2016-08-19 14:11:26 +00:00
|
|
|
information.manifest = fp->reads();
|
|
|
|
} else return false;
|
|
|
|
|
|
|
|
auto document = BML::unserialize(information.manifest);
|
|
|
|
if(!cartridge.load()) return false;
|
|
|
|
|
2017-01-13 01:15:45 +00:00
|
|
|
this->interface = interface;
|
2016-08-19 14:11:26 +00:00
|
|
|
information.colorburst = Emulator::Constants::Colorburst::NTSC;
|
|
|
|
return information.loaded = true;
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::save() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
cartridge.save();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::unload() -> void {
|
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
|
|
|
peripherals.unload();
|
2016-08-19 14:11:26 +00:00
|
|
|
cartridge.unload();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto System::power() -> void {
|
2016-08-19 14:11:26 +00:00
|
|
|
Emulator::video.reset();
|
|
|
|
Emulator::video.setInterface(interface);
|
|
|
|
Emulator::video.setPalette();
|
|
|
|
|
|
|
|
Emulator::audio.reset();
|
|
|
|
Emulator::audio.setInterface(interface);
|
|
|
|
|
|
|
|
scheduler.reset();
|
2017-01-13 01:15:45 +00:00
|
|
|
cartridge.power();
|
|
|
|
cpu.power();
|
|
|
|
vdp.power();
|
|
|
|
psg.power();
|
2016-08-19 14:11:26 +00:00
|
|
|
scheduler.primary(cpu);
|
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
|
|
|
|
|
|
|
peripherals.reset();
|
2016-08-17 12:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|