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:
parent
5280f5aba2
commit
778ac6e6d1
@ -199,19 +199,36 @@ class ConcreteMachine:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x400d4: {
|
case 0x400d4: {
|
||||||
uint32_t address = executor_.registers()[1] + 28;
|
if(autoload_phase_ == AutoloadPhase::TestingMenu) {
|
||||||
|
autoload_phase_ = AutoloadPhase::Ended;
|
||||||
|
|
||||||
|
uint32_t address = executor_.registers()[1] + 28;
|
||||||
|
bool should_left_click = true;
|
||||||
|
|
||||||
printf("Menu:\n");
|
|
||||||
while(true) {
|
while(true) {
|
||||||
uint32_t icon_flags;
|
uint32_t icon_flags;
|
||||||
uint32_t item_flags;
|
uint32_t item_flags;
|
||||||
executor_.bus.read(address, item_flags, false);
|
executor_.bus.read(address, item_flags, false);
|
||||||
executor_.bus.read(address + 8, icon_flags, false);
|
executor_.bus.read(address + 8, icon_flags, false);
|
||||||
auto desc = get_string(address + 12, icon_flags & (1 << 8));
|
auto desc = get_string(address + 12, icon_flags & (1 << 8));
|
||||||
printf("%s\n", desc.c_str());
|
|
||||||
|
should_left_click &=
|
||||||
|
(desc == "Info") ||
|
||||||
|
(desc == "Quit");
|
||||||
|
|
||||||
address += 24;
|
address += 24;
|
||||||
if(item_flags & (1 << 7)) break;
|
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;
|
||||||
|
|
||||||
// Wimp_OpenWindow.
|
// Wimp_OpenWindow.
|
||||||
@ -236,10 +253,10 @@ class ConcreteMachine:
|
|||||||
|
|
||||||
// Wimp_CreateIcon, which also adds to the icon bar.
|
// Wimp_CreateIcon, which also adds to the icon bar.
|
||||||
case 0x400c2:
|
case 0x400c2:
|
||||||
|
switch(autoload_phase_) {
|
||||||
|
case AutoloadPhase::WaitingForStartup:
|
||||||
// Creation of any icon is used to spot that RISC OS has started up.
|
// Creation of any icon is used to spot that RISC OS has started up.
|
||||||
if(autoload_phase_ == AutoloadPhase::WaitingForStartup) {
|
//
|
||||||
autoload_phase_ = AutoloadPhase::OpeningDisk;
|
|
||||||
|
|
||||||
// Wait a further second, mouse down to (32, 240), left click.
|
// Wait a further second, mouse down to (32, 240), left click.
|
||||||
// That'll trigger disk access. Then move up to the top left,
|
// That'll trigger disk access. Then move up to the top left,
|
||||||
// in anticipation of the appearance of a window.
|
// in anticipation of the appearance of a window.
|
||||||
@ -252,9 +269,29 @@ class ConcreteMachine:
|
|||||||
target_program_.empty() ? AutoloadPhase::Ended : AutoloadPhase::WaitingForDiskContents)
|
target_program_.empty() ? AutoloadPhase::Ended : AutoloadPhase::WaitingForDiskContents)
|
||||||
);
|
);
|
||||||
cursor_actions_.push_back(CursorAction::move_to(64, 36));
|
cursor_actions_.push_back(CursorAction::move_to(64, 36));
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: spot potential addition of extra program icon.
|
autoload_phase_ = AutoloadPhase::OpeningDisk;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AutoloadPhase::OpeningProgram: {
|
||||||
|
const uint32_t address = executor_.registers()[1];
|
||||||
|
uint32_t handle;
|
||||||
|
executor_.bus.read(address, handle, false);
|
||||||
|
|
||||||
|
// Test whether the program has added an icon on the right.
|
||||||
|
if(static_cast<int32_t>(handle) == -1) {
|
||||||
|
cursor_actions_.clear();
|
||||||
|
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;
|
||||||
|
}
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user