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

Complete autoload loop.

This commit is contained in:
Thomas Harte 2024-05-23 22:16:40 -04:00
parent 5280f5aba2
commit 778ac6e6d1

View File

@ -199,18 +199,35 @@ class ConcreteMachine:
break; break;
case 0x400d4: { case 0x400d4: {
uint32_t address = executor_.registers()[1] + 28; if(autoload_phase_ == AutoloadPhase::TestingMenu) {
autoload_phase_ = AutoloadPhase::Ended;
printf("Menu:\n"); uint32_t address = executor_.registers()[1] + 28;
while(true) { bool should_left_click = true;
uint32_t icon_flags;
uint32_t item_flags; while(true) {
executor_.bus.read(address, item_flags, false); uint32_t icon_flags;
executor_.bus.read(address + 8, icon_flags, false); uint32_t item_flags;
auto desc = get_string(address + 12, icon_flags & (1 << 8)); executor_.bus.read(address, item_flags, false);
printf("%s\n", desc.c_str()); executor_.bus.read(address + 8, icon_flags, false);
address += 24; auto desc = get_string(address + 12, icon_flags & (1 << 8));
if(item_flags & (1 << 7)) break;
should_left_click &=
(desc == "Info") ||
(desc == "Quit");
address += 24;
if(item_flags & (1 << 7)) break;
}
if(should_left_click) {
cursor_actions_.push_back(CursorAction::button(1, true));
cursor_actions_.push_back(CursorAction::wait(12'000'000));
cursor_actions_.push_back(CursorAction::button(1, false));
cursor_actions_.push_back(CursorAction::button(0, true));
cursor_actions_.push_back(CursorAction::wait(12'000'000));
cursor_actions_.push_back(CursorAction::button(0, false));
}
} }
} break; } break;
@ -236,25 +253,45 @@ class ConcreteMachine:
// Wimp_CreateIcon, which also adds to the icon bar. // Wimp_CreateIcon, which also adds to the icon bar.
case 0x400c2: case 0x400c2:
// Creation of any icon is used to spot that RISC OS has started up. switch(autoload_phase_) {
if(autoload_phase_ == AutoloadPhase::WaitingForStartup) { case AutoloadPhase::WaitingForStartup:
autoload_phase_ = AutoloadPhase::OpeningDisk; // Creation of any icon is used to spot that RISC OS has started up.
//
// Wait a further second, mouse down to (32, 240), left click.
// That'll trigger disk access. Then move up to the top left,
// in anticipation of the appearance of a window.
cursor_actions_.push_back(CursorAction::wait(24'000'000));
cursor_actions_.push_back(CursorAction::move_to(32, 240));
cursor_actions_.push_back(CursorAction::button(0, true));
cursor_actions_.push_back(CursorAction::wait(12'000'000));
cursor_actions_.push_back(CursorAction::button(0, false));
cursor_actions_.push_back(CursorAction::set_phase(
target_program_.empty() ? AutoloadPhase::Ended : AutoloadPhase::WaitingForDiskContents)
);
cursor_actions_.push_back(CursorAction::move_to(64, 36));
// Wait a further second, mouse down to (32, 240), left click. autoload_phase_ = AutoloadPhase::OpeningDisk;
// That'll trigger disk access. Then move up to the top left, break;
// in anticipation of the appearance of a window.
cursor_actions_.push_back(CursorAction::wait(24'000'000)); case AutoloadPhase::OpeningProgram: {
cursor_actions_.push_back(CursorAction::move_to(32, 240)); const uint32_t address = executor_.registers()[1];
cursor_actions_.push_back(CursorAction::button(0, true)); uint32_t handle;
cursor_actions_.push_back(CursorAction::wait(12'000'000)); executor_.bus.read(address, handle, false);
cursor_actions_.push_back(CursorAction::button(0, false));
cursor_actions_.push_back(CursorAction::set_phase( // Test whether the program has added an icon on the right.
target_program_.empty() ? AutoloadPhase::Ended : AutoloadPhase::WaitingForDiskContents) if(static_cast<int32_t>(handle) == -1) {
); cursor_actions_.clear();
cursor_actions_.push_back(CursorAction::move_to(64, 36)); cursor_actions_.push_back(CursorAction::move_to(536, 240));
cursor_actions_.push_back(CursorAction::button(1, true));
cursor_actions_.push_back(CursorAction::wait(12'000'000));
cursor_actions_.push_back(CursorAction::button(1, false));
autoload_phase_ = AutoloadPhase::TestingMenu;
}
} break;
default: break;
} }
// TODO: spot potential addition of extra program icon.
break; break;
// Wimp_PlotIcon. // Wimp_PlotIcon.
@ -269,7 +306,6 @@ class ConcreteMachine:
desc = get_string(address + 20, flags & (1 << 8)); desc = get_string(address + 20, flags & (1 << 8));
} }
printf("%s == %s?\n", desc.c_str(), target_program_.c_str());
if(desc == target_program_) { if(desc == target_program_) {
uint32_t x1, y1, x2, y2; uint32_t x1, y1, x2, y2;
executor_.bus.read(address + 0, x1, false); executor_.bus.read(address + 0, x1, false);
@ -553,6 +589,7 @@ class ConcreteMachine:
WaitingForDiskContents, WaitingForDiskContents,
WaitingForTargetIcon, WaitingForTargetIcon,
OpeningProgram, OpeningProgram,
TestingMenu,
Ended, Ended,
}; };
AutoloadPhase autoload_phase_ = AutoloadPhase::Ended; AutoloadPhase autoload_phase_ = AutoloadPhase::Ended;