Browse Source

beta 12

kvm
asie 6 months ago
parent
commit
78255fab05
4 changed files with 15 additions and 16 deletions
  1. 2
    1
      src/frontend_posix.c
  2. 10
    12
      src/zzt.c
  3. 1
    3
      src/zzt.h
  4. 2
    0
      web/zeta.js

+ 2
- 1
src/frontend_posix.c View File

@@ -70,7 +70,6 @@ static int posix_zzt_init(int argc, char **argv) {
#endif

zzt_init();
zzt_set_timer_ticks(time(NULL));

#ifdef USE_GETOPT
if (argc > optind && posix_vfs_exists(argv[optind])) {
@@ -136,6 +135,8 @@ static int posix_zzt_init(int argc, char **argv) {
vfs_close(exeh);
}

zzt_set_timer_offset((time(NULL) % 86400) * 1000L);

if (skip_kc) {
zzt_key('k', 0x25);
zzt_key('c', 0x2E);

+ 10
- 12
src/zzt.c View File

@@ -68,6 +68,7 @@ static u32 def_palette[] = {
typedef struct {
cpu_state cpu;
long real_time;
long timer_time_offset;
double timer_time;

// keyboard
@@ -96,7 +97,7 @@ typedef struct {
// DOS
u32 dos_dta;

u8 charset[256*14];
u8 charset[256*16];
u32 palette[16];
} zzt_state;

@@ -111,7 +112,7 @@ void zzt_kmod_clear(int mod) {
}

static long zzt_internal_time(void) {
return zzt.timer_time;
return zzt.timer_time_offset + ((long) zzt.timer_time);
// return (long) (zzt.timer_time + (zeta_time_ms() - zzt.real_time));
}

@@ -358,16 +359,8 @@ static void cpu_func_intr_0x33(cpu_state* cpu) {
}
}

u32 zzt_get_timer_ticks(void) {
return zzt.cpu.ram[0x46c] | (zzt.cpu.ram[0x46d] << 8)
| (zzt.cpu.ram[0x46e] << 16) | (zzt.cpu.ram[0x46f] << 24);
}

void zzt_set_timer_ticks(u32 time) {
zzt.cpu.ram[0x46c] = time & 0xFF;
zzt.cpu.ram[0x46d] = (time>>8) & 0xFF;
zzt.cpu.ram[0x46e] = (time>>16) & 0xFF;
zzt.cpu.ram[0x46f] = (time>>24) & 0xFF;
void zzt_set_timer_offset(long time) {
zzt.timer_time_offset = time;
}

static int cpu_func_interrupt_main(cpu_state* cpu, u8 intr) {
@@ -686,6 +679,11 @@ static int cpu_func_intr_0x21(cpu_state* cpu) {
cpu->dh = (ms / 1000) % 60;
cpu->dl = (ms / 10) % 100;
} return STATE_WAIT;
case 0x2D: { // systime set
long ms = cpu->dl * 10 + cpu->dh * 1000 + cpu->cl * 60000 + cpu->ch * 3600000;
zzt->timer_time_offset = ms - zzt->timer_time;
cpu->al = 0x00;
} return STATE_CONTINUE;
case 0x35: // get ivt
cpu->bl = cpu->ram[cpu->al * 4];
cpu->bh = cpu->ram[cpu->al * 4 + 1];

+ 1
- 3
src/zzt.h View File

@@ -67,9 +67,7 @@ int zzt_key_get_repeat_delay(void);
USER_FUNCTION
void zzt_key_set_delay(int ms, int repeat_ms);
USER_FUNCTION
u32 zzt_get_timer_ticks(void);
USER_FUNCTION
void zzt_set_timer_ticks(u32 ticks);
void zzt_set_timer_offset(long ms);

IMPLEMENT_FUNCTION
long zeta_time_ms(void);

+ 2
- 0
web/zeta.js View File

@@ -300,6 +300,8 @@ var vfs_done = function() {
emu._zzt_load_binary(handle, buffer);
vfsg_close(handle);

emu._zzt_set_timer_offset(Date.now() % 86400000)

last_timer_time = time_ms();
zzt_tick();
});

Loading…
Cancel
Save