Skip to content

Commit

Permalink
Added activity indicator for RIFS
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-jonsson committed Jan 20, 2024
1 parent fb6b7d2 commit 8d6b963
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions front/sdl/docopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ int elems_to_args(struct Elements *elements, struct DocoptArgs *args,
struct DocoptArgs docopt(int argc, char *argv[], const bool help, const char *version) {
struct DocoptArgs args = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, (char *) "8088", NULL, (char *)
"12.0", NULL, NULL, NULL,
"10.0", NULL, NULL, NULL,
usage_pattern,
{ "Usage: virtualxt [options]",
"",
Expand All @@ -323,7 +323,7 @@ struct DocoptArgs docopt(int argc, char *argv[], const bool help, const char *ve
" --config=PATH Set config directory.",
" --trace=FILE Write CPU trace to file.",
" --cpu=TYPE Types are 8088, v20 and 286. [default: 8088]",
" --frequency=MHZ CPU frequency. [default: 12.0]",
" --frequency=MHZ CPU frequency. [default: 10.0]",
" -a --floppy=FILE Mount floppy image as drive A.",
" -c --harddrive=FILE Mount harddrive image as drive C."}
};
Expand Down
6 changes: 5 additions & 1 deletion front/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static int emu_loop(void *ptr) {
vxt_system *vxt = (vxt_system*)ptr;
Sint64 penalty = 0;
double frequency = cpu_frequency;
int frequency_hz = (int)(cpu_frequency * 1000000.0);
Uint64 start = SDL_GetPerformanceCounter();

while (SDL_AtomicGet(&running)) {
Expand All @@ -198,11 +199,14 @@ static int emu_loop(void *ptr) {
}
num_cycles += res.cycles;
}

frequency = vxtu_ppi_turbo_enabled(ppi_device) ? cpu_frequency : ((double)VXT_DEFAULT_FREQUENCY / 1000000.0);
frequency_hz = (int)(frequency * 1000000.0);
vxt_system_set_frequency(vxt, frequency_hz);
);

for (;;) {
const Uint64 f = SDL_GetPerformanceFrequency() / (Uint64)(frequency * 1000000.0);
const Uint64 f = SDL_GetPerformanceFrequency() / (Uint64)frequency_hz;
if (!f) {
penalty = 0;
break;
Expand Down
2 changes: 1 addition & 1 deletion front/sdl/virtualxt.docopt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Options:
--config=PATH Set config directory.
--trace=FILE Write CPU trace to file.
--cpu=TYPE Types are 8088, v20 and 286. [default: 8088]
--frequency=MHZ CPU frequency. [default: 12.0]
--frequency=MHZ CPU frequency. [default: 10.0]
-a --floppy=FILE Mount floppy image as drive A.
-c --harddrive=FILE Mount harddrive image as drive C.
15 changes: 13 additions & 2 deletions modules/rifs/rifs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// 3. This notice may not be removed or altered from any source distribution.

#include <vxt/vxtu.h>
#include <frontend.h>
#include "crc32.h"

#include <assert.h>
Expand Down Expand Up @@ -113,6 +114,9 @@ struct rifs {
bool dlab;
bool readonly;

void (*activity_callback)(int num, void *userdata);
void *activity_callback_userdata;

vxt_byte buffer_input[BUFFER_SIZE];
int buffer_input_len;

Expand Down Expand Up @@ -206,6 +210,9 @@ static void process_request(struct rifs *fs, struct rifs_packet *pk) {
return;
}

if (fs->activity_callback)
fs->activity_callback(0xFF, fs->activity_callback_userdata);

#define BREAK_RO(size) { \
if (fs->readonly) { \
pk->cmd = 5; \
Expand All @@ -214,8 +221,6 @@ static void process_request(struct rifs *fs, struct rifs_packet *pk) {
} \
} \

//VXT_LOG("CMD: 0x%X", pk->cmd);

switch (pk->cmd) {
case IFS_RMDIR: BREAK_RO(0)
pk->cmd = rifs_rmdir(host_path(fs, (char*)pk->data));
Expand Down Expand Up @@ -533,6 +538,12 @@ VXTU_MODULE_CREATE(rifs, {
rifs_copy_root(DEVICE->root_path, ".");
else
rifs_copy_root(DEVICE->root_path, home);

struct frontend_interface *fi = (struct frontend_interface*)FRONTEND;
if (fi) {
DEVICE->activity_callback = fi->disk.activity_callback;
DEVICE->activity_callback_userdata = fi->disk.userdata;
}

PIREPHERAL->install = &install;
PIREPHERAL->name = &name;
Expand Down

0 comments on commit 8d6b963

Please sign in to comment.