mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-21 21:33:54 +00:00
Catch SSM events.
This commit is contained in:
parent
0e30e2d865
commit
dbc0ecde31
@ -946,14 +946,29 @@ class ConcreteMachine:
|
||||
|
||||
if constexpr (catches_ssm) {
|
||||
ssm_code_ = (ssm_code_ << 8) | read_pointers_[address >> 14][address & 16383];
|
||||
if((ssm_code_ & 0xff00ff00) == 0xed00ed00) {
|
||||
if(ssm_delegate_) {
|
||||
ssm_delegate_->perform(
|
||||
uint16_t(
|
||||
(ssm_code_ & 0xff) | ((ssm_code_ >> 8) & 0xff00)
|
||||
));
|
||||
if(ssm_delegate_) {
|
||||
if((ssm_code_ & 0xff00ff00) == 0xed00ed00) {
|
||||
const auto code = uint16_t(
|
||||
(ssm_code_ & 0xff) | ((ssm_code_ >> 8) & 0xff00)
|
||||
);
|
||||
ssm_code_ = 0;
|
||||
|
||||
if(
|
||||
(code <= 0x3f3f) ||
|
||||
(code >= 0x7f7f && code <= 0x9f9f) ||
|
||||
(code >= 0xa4a4 && code <= 0xa7a7) ||
|
||||
(code >= 0xacac && code <= 0xafaf) ||
|
||||
(code >= 0xb4b4 && code <= 0xb7b7) ||
|
||||
(code >= 0xbcbc && code <= 0xbfbf) ||
|
||||
(code >= 0xc0c0 && code <= 0xfdfd)
|
||||
) {
|
||||
ssm_delegate_->perform(code);
|
||||
}
|
||||
}
|
||||
ssm_code_ = 0;
|
||||
} else if((ssm_code_ & 0xffff) == 0xedfe) {
|
||||
ssm_delegate_->perform(0xfffe);
|
||||
} else if((ssm_code_ & 0xffff) == 0xedff) {
|
||||
ssm_delegate_->perform(0xffff);
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
@ -21,8 +21,10 @@
|
||||
#include "KeyboardMachine.hpp"
|
||||
#include "MachineForTarget.hpp"
|
||||
|
||||
struct CSLPerformer {
|
||||
|
||||
struct SSMDelegate: public AmstradCPC::Machine::SSMDelegate {
|
||||
void perform(uint16_t code) {
|
||||
NSLog(@"SSM %04x", code);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@ -31,23 +33,27 @@ struct CSLPerformer {
|
||||
@interface CPCShakerTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation CPCShakerTests {
|
||||
}
|
||||
@implementation CPCShakerTests {}
|
||||
|
||||
- (void)testCSLPath:(NSString *)path name:(NSString *)name {
|
||||
using namespace Storage::Automation;
|
||||
const auto steps = CSL::parse([[path stringByAppendingPathComponent:name] UTF8String]);
|
||||
|
||||
SSMDelegate ssm_delegate;
|
||||
|
||||
std::unique_ptr<Machine::DynamicMachine> lazy_machine;
|
||||
CSL::KeyDelay key_delay;
|
||||
using Target = Analyser::Static::AmstradCPC::Target;
|
||||
Target target;
|
||||
target.catch_ssm_codes = true;
|
||||
target.model = Target::Model::CPC6128;
|
||||
|
||||
const auto machine = [&]() -> Machine::DynamicMachine& {
|
||||
if(!lazy_machine) {
|
||||
Machine::Error error;
|
||||
lazy_machine = Machine::MachineForTarget(&target, CSROMFetcher(), error);
|
||||
reinterpret_cast<AmstradCPC::Machine *>(lazy_machine->raw_pointer())
|
||||
->set_ssm_delegate(&ssm_delegate);
|
||||
}
|
||||
return *lazy_machine;
|
||||
};
|
||||
@ -56,7 +62,6 @@ struct CSLPerformer {
|
||||
};
|
||||
|
||||
using Type = CSL::Instruction::Type;
|
||||
int c = 0;
|
||||
for(const auto &step: steps) {
|
||||
switch(step.type) {
|
||||
case Type::Version:
|
||||
|
Loading…
Reference in New Issue
Block a user