Browse Source

improve SYS_TIMER_TIME, blinking timing accuracy; fix blinking not updating the screen in OpenGL mode

kvm
asie 5 months ago
parent
commit
01d542a25b
5 changed files with 19 additions and 8 deletions
  1. 2
    1
      src/config.h
  2. 6
    3
      src/frontend_sdl.c
  3. 2
    2
      src/zzt.c
  4. 8
    1
      src/zzt.h
  5. 1
    1
      web/src/render.js

+ 2
- 1
src/config.h View File

@@ -27,7 +27,8 @@

// SDL port configuration

#define BLINK_TOGGLE_DURATION_MS 233
// 60/16 Hz (blink every 16 frames at 60 Hz)
#define BLINK_TOGGLE_DURATION_MS 267
#define ENABLE_SCREENSHOTS
#define USE_GETOPT
#define USE_OPENGL

+ 6
- 3
src/frontend_sdl.c View File

@@ -460,8 +460,7 @@ static void deinit_opengl(void) {
free(ogl_buf_pos);
}

static void render_opengl(long curr_time, int regen_visuals) {
u8 blink_local = video_blink && sdl_is_blink_phase(curr_time);
static void render_opengl(long curr_time, int regen_visuals, u8 blink_local) {
float texw, texh;
int width = (zzt_video_mode() & 2) ? 80 : 40;

@@ -712,6 +711,7 @@ int main(int argc, char **argv) {

#ifdef USE_OPENGL
int should_render = 1;
u8 last_blink_local = 0xFF;
#endif

while (cont_loop) {
@@ -882,7 +882,10 @@ int main(int argc, char **argv) {
curr_time = zeta_time_ms();
if (use_opengl) {
#ifdef USE_OPENGL
render_opengl(curr_time, should_render);
u8 blink_local = video_blink && sdl_is_blink_phase(curr_time);
should_render |= (blink_local != last_blink_local);
render_opengl(curr_time, should_render, blink_local);
last_blink_local = blink_local;
SDL_GL_SwapWindow(window);
#endif
} else {

+ 2
- 2
src/zzt.c View File

@@ -894,7 +894,7 @@ static void zzt_load_exe(int handle, const char *arg) {
// int size_pars = 40400;
// int offset_pars = mem_alloc(size_pars, 0);
int offset_pars = 0x100;
int size_pars = 0xA000 - 0x100;
int size_pars = 0xB800 - 0x100;

// location
zzt.cpu.seg[SEG_CS] = vfs_read16(handle, 0x16) + offset_pars + 0x10;
@@ -940,7 +940,7 @@ void zzt_load_binary(int handle, const char *arg) {

// assume com file
int offset_pars = 0x100;
int size_pars = 0xA000 - 0x100;
int size_pars = 0xB800 - 0x100;
zzt_load_build_psp(offset_pars, offset_pars + size_pars, arg);

zzt.cpu.seg[SEG_CS] = offset_pars;

+ 8
- 1
src/zzt.h View File

@@ -24,7 +24,14 @@

#define MAX_FILES 16
#define TEXT_ADDR(x,y) (0xB8000 + ((y)*160) + ((x)*2))
#define SYS_TIMER_TIME 54.9451

// the long story:
// 3.579545 MHz - NTSC dotclock
// dotclock * 4 = 14.31818
// 14.31818 / 12 ~= 1.19318166 - PIT frequency
// 65535 - maximum PIT cycle count before reload
// (65535 / 1193181.66) = SYS_TIMER_TIME (seconds)
#define SYS_TIMER_TIME 54.92457871

USER_FUNCTION
int zzt_video_mode(void);

+ 1
- 1
web/src/render.js View File

@@ -23,7 +23,7 @@ export class CanvasBasedRenderer {
this.ctx = canvas.getContext('2d', {alpha: false});
this.ctx.imageSmoothingEnabled = false;

this.blink_duration = Math.round(((options && options.blink_cycle_duration) || 0.466) * 1000);
this.blink_duration = Math.round(((options && options.blink_cycle_duration) || 0.534) * 1000);
this.video_blink = this.blink_duration > 0;

this.video_mode = -1;

Loading…
Cancel
Save