Browse Source

beta 12

master
asie 1 month 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) {
70 70
 #endif
71 71
 
72 72
 	zzt_init();
73
-	zzt_set_timer_ticks(time(NULL));
74 73
 
75 74
 #ifdef USE_GETOPT
76 75
 	if (argc > optind && posix_vfs_exists(argv[optind])) {
@@ -136,6 +135,8 @@ static int posix_zzt_init(int argc, char **argv) {
136 135
 		vfs_close(exeh);
137 136
 	}
138 137
 
138
+	zzt_set_timer_offset((time(NULL) % 86400) * 1000L);
139
+
139 140
 	if (skip_kc) {
140 141
 		zzt_key('k', 0x25);
141 142
 		zzt_key('c', 0x2E);

+ 10
- 12
src/zzt.c View File

@@ -68,6 +68,7 @@ static u32 def_palette[] = {
68 68
 typedef struct {
69 69
 	cpu_state cpu;
70 70
 	long real_time;
71
+	long timer_time_offset;
71 72
 	double timer_time;
72 73
 
73 74
 	// keyboard
@@ -96,7 +97,7 @@ typedef struct {
96 97
 	// DOS
97 98
 	u32 dos_dta;
98 99
 
99
-	u8 charset[256*14];
100
+	u8 charset[256*16];
100 101
 	u32 palette[16];
101 102
 } zzt_state;
102 103
 
@@ -111,7 +112,7 @@ void zzt_kmod_clear(int mod) {
111 112
 }
112 113
 
113 114
 static long zzt_internal_time(void) {
114
-	return zzt.timer_time;
115
+	return zzt.timer_time_offset + ((long) zzt.timer_time);
115 116
 //	return (long) (zzt.timer_time + (zeta_time_ms() - zzt.real_time));
116 117
 }
117 118
 
@@ -358,16 +359,8 @@ static void cpu_func_intr_0x33(cpu_state* cpu) {
358 359
 	}
359 360
 }
360 361
 
361
-u32 zzt_get_timer_ticks(void) {
362
-	return zzt.cpu.ram[0x46c] | (zzt.cpu.ram[0x46d] << 8)
363
-	    | (zzt.cpu.ram[0x46e] << 16) | (zzt.cpu.ram[0x46f] << 24);
364
-}
365
-
366
-void zzt_set_timer_ticks(u32 time) {
367
-	zzt.cpu.ram[0x46c] = time & 0xFF;
368
-	zzt.cpu.ram[0x46d] = (time>>8) & 0xFF;
369
-	zzt.cpu.ram[0x46e] = (time>>16) & 0xFF;
370
-	zzt.cpu.ram[0x46f] = (time>>24) & 0xFF;
362
+void zzt_set_timer_offset(long time) {
363
+	zzt.timer_time_offset = time;
371 364
 }
372 365
 
373 366
 static int cpu_func_interrupt_main(cpu_state* cpu, u8 intr) {
@@ -686,6 +679,11 @@ static int cpu_func_intr_0x21(cpu_state* cpu) {
686 679
 			cpu->dh = (ms / 1000) % 60;
687 680
 			cpu->dl = (ms / 10) % 100;
688 681
 		} return STATE_WAIT;
682
+		case 0x2D: { // systime set
683
+			long ms = cpu->dl * 10 + cpu->dh * 1000 + cpu->cl * 60000 + cpu->ch * 3600000;
684
+			zzt->timer_time_offset = ms - zzt->timer_time;
685
+			cpu->al = 0x00;
686
+		} return STATE_CONTINUE;
689 687
 		case 0x35: // get ivt
690 688
 			cpu->bl = cpu->ram[cpu->al * 4];
691 689
 			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);
67 67
 USER_FUNCTION
68 68
 void zzt_key_set_delay(int ms, int repeat_ms);
69 69
 USER_FUNCTION
70
-u32 zzt_get_timer_ticks(void);
71
-USER_FUNCTION
72
-void zzt_set_timer_ticks(u32 ticks);
70
+void zzt_set_timer_offset(long ms);
73 71
 
74 72
 IMPLEMENT_FUNCTION
75 73
 long zeta_time_ms(void);

+ 2
- 0
web/zeta.js View File

@@ -300,6 +300,8 @@ var vfs_done = function() {
300 300
 		emu._zzt_load_binary(handle, buffer);
301 301
 		vfsg_close(handle);
302 302
 
303
+		emu._zzt_set_timer_offset(Date.now() % 86400000)
304
+
303 305
 		last_timer_time = time_ms();
304 306
 		zzt_tick();
305 307
 	});

Loading…
Cancel
Save