1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 16:31:31 +00:00

Merge pull request #792 from TomHarte/BIOSFreeMasterSystem

Ensures the Master System makes a genuine attempt to boot sans BIOS
This commit is contained in:
Thomas Harte 2020-05-12 22:35:17 -04:00 committed by GitHub
commit e4335577ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 45 additions and 45 deletions

View File

@ -25,7 +25,7 @@ class MultiJoystick: public Inputs::Joystick {
}
}
std::vector<Input> &get_inputs() final {
const std::vector<Input> &get_inputs() final {
if(inputs.empty()) {
for(const auto &joystick: joysticks_) {
std::vector<Input> joystick_inputs = joystick->get_inputs();

View File

@ -51,7 +51,7 @@ class Base {
}
protected:
const static int output_lag = 11; // i.e. pixel output will occur 11 cycles after corresponding data read.
static constexpr int output_lag = 11; // i.e. pixel output will occur 11 cycles after corresponding data read.
// The default TMS palette.
const uint32_t palette[16] = {

View File

@ -98,7 +98,7 @@ class Joystick {
};
/// @returns The list of all inputs defined on this joystick.
virtual std::vector<Input> &get_inputs() = 0;
virtual const std::vector<Input> &get_inputs() = 0;
/*!
Sets the digital value of @c input. This may have direct effect or
@ -170,7 +170,7 @@ class ConcreteJoystick: public Joystick {
}
}
std::vector<Input> &get_inputs() final {
const std::vector<Input> &get_inputs() final {
return inputs_;
}
@ -223,7 +223,7 @@ class ConcreteJoystick: public Joystick {
}
private:
std::vector<Input> inputs_;
const std::vector<Input> inputs_;
enum class StickType {
Digital,

View File

@ -80,10 +80,11 @@ class Keyboard {
private:
std::set<Key> observed_keys_;
std::set<Key> essential_modifiers_;
const std::set<Key> essential_modifiers_;
const bool is_exclusive_ = true;
std::vector<bool> key_states_;
Delegate *delegate_ = nullptr;
bool is_exclusive_ = true;
};
}

View File

@ -29,8 +29,8 @@
#include "Cartridges/Unpaged.hpp"
namespace {
static const double NTSC_clock_rate = 1194720;
static const double PAL_clock_rate = 1182298;
static constexpr double NTSC_clock_rate = 1194720;
static constexpr double PAL_clock_rate = 1182298;
}
namespace Atari2600 {

View File

@ -121,13 +121,13 @@ class MappedKeyboardMachine: public Inputs::Keyboard::Delegate, public KeyboardM
};
/// Terminates a key sequence from the character mapper.
static const uint16_t KeyEndSequence = 0xffff;
static constexpr uint16_t KeyEndSequence = 0xffff;
/*!
Indicates that a key is not mapped (for the keyboard mapper) or that a
character cannot be typed (for the character mapper).
*/
static const uint16_t KeyNotMapped = 0xfffe;
static constexpr uint16_t KeyNotMapped = 0xfffe;
/*!
Allows individual machines to provide the mapping between host keys

View File

@ -133,30 +133,31 @@ class ConcreteMachine:
paging_registers_[2] = 0;
}
// Load the BIOS if relevant.
if(has_bios()) {
// TODO: there's probably a million other versions of the Master System BIOS; try to build a
// CRC32 catalogue of those. So far:
//
// 0072ed54 = US/European BIOS 1.3
// 48d44a13 = Japanese BIOS 2.1
const bool is_japanese = target.region == Target::Region::Japan;
const auto roms = rom_fetcher(
{ {"MasterSystem",
is_japanese ? "the Japanese Master System BIOS" : "the European/US Master System BIOS",
is_japanese ? "japanese-bios.sms" : "bios.sms",
8*1024,
{ is_japanese ? 0x48d44a13u : 0x0072ed54u }
} }
);
if(!roms[0]) {
// No BIOS found; attempt to boot as though it has already disabled itself.
memory_control_ |= 0x08;
std::cerr << "No BIOS found; attempting to start cartridge directly" << std::endl;
} else {
roms[0]->resize(8*1024);
memcpy(&bios_, roms[0]->data(), roms[0]->size());
}
// Load the BIOS if available.
//
// TODO: there's probably a million other versions of the Master System BIOS; try to build a
// CRC32 catalogue of those. So far:
//
// 0072ed54 = US/European BIOS 1.3
// 48d44a13 = Japanese BIOS 2.1
const bool is_japanese = target.region == Target::Region::Japan;
const auto roms = rom_fetcher(
{ {"MasterSystem",
is_japanese ? "the Japanese Master System BIOS" : "the European/US Master System BIOS",
is_japanese ? "japanese-bios.sms" : "bios.sms",
8*1024,
{ is_japanese ? 0x48d44a13u : 0x0072ed54u }
} }
);
if(!roms[0]) {
// No BIOS found; attempt to boot as though it has already disabled itself.
has_bios_ = false;
memory_control_ |= 0x08;
std::cerr << "No BIOS found; attempting to start cartridge directly" << std::endl;
} else {
has_bios_ = true;
roms[0]->resize(8*1024);
memcpy(&bios_, roms[0]->data(), roms[0]->size());
}
page_cartridge();
@ -486,9 +487,9 @@ class ConcreteMachine:
}
using Target = Analyser::Static::Sega::Target;
Target::Model model_;
Target::Region region_;
Target::PagingScheme paging_scheme_;
const Target::Model model_;
const Target::Region region_;
const Target::PagingScheme paging_scheme_;
CPU::Z80::Processor<ConcreteMachine, false, false> z80_;
JustInTimeActor<TI::TMS::TMS9918> vdp_;
@ -550,13 +551,11 @@ class ConcreteMachine:
}
// Throw the BIOS on top if this machine has one and it isn't disabled.
if(has_bios() && !(memory_control_ & 0x08)) {
if(has_bios_ && !(memory_control_ & 0x08)) {
map(read_pointers_, bios_, 8*1024, 0);
}
}
bool has_bios() {
return is_master_system(model_) && region_ != Target::Region::Japan;
}
bool has_bios_ = true;
};
}

View File

@ -83,7 +83,7 @@ class CRT {
Outputs::Display::ScanTarget *scan_target_ = &Outputs::Display::NullScanTarget::singleton;
Outputs::Display::ScanTarget::Modals scan_target_modals_;
static const uint8_t DefaultAmplitude = 80;
static constexpr uint8_t DefaultAmplitude = 80;
#ifndef NDEBUG
size_t allocated_data_length_ = std::numeric_limits<size_t>::min();

View File

@ -91,7 +91,7 @@ struct Microcycle {
/// Provides the 68000's bus grant line — indicating whether a bus request has been acknowledged.
static constexpr int BusGrant = 1 << 10;
/// Contains a valid combination of the various static const int flags, describing the operation
/// Contains a valid combination of the various static constexpr int flags, describing the operation
/// performed by this Microcycle.
int operation = 0;

View File

@ -323,7 +323,7 @@ class ProcessorStorage {
static constexpr int DestinationMask = 1 << 6;
uint8_t action = uint8_t(Action::None);
static const uint16_t NoBusProgram = std::numeric_limits<uint16_t>::max();
static constexpr uint16_t NoBusProgram = std::numeric_limits<uint16_t>::max();
uint16_t bus_program = NoBusProgram;
MicroOp() {}