diff --git a/emu/dis340.c b/emu/dis340.c index 0ab814d..bc134ca 100644 --- a/emu/dis340.c +++ b/emu/dis340.c @@ -845,6 +845,10 @@ renderthread(void *arg) SDL_TEXTUREACCESS_STREAMING, 1024, 1024); SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND); + lock(&initlock); + awaitinit--; + unlock(&initlock); + for(;;){ #ifdef JUSTTESTING while(SDL_PollEvent(&ev)) @@ -1017,6 +1021,10 @@ makedis(int argc, char *argv[]) t = (Task){ nil, discycle, dis, 20, 0 }; addtask(t); + lock(&initlock); + awaitinit++; + unlock(&initlock); + /* There's a race somewhere here */ threadcreate(renderthread, dis); diff --git a/emu/main_panel.c b/emu/main_panel.c index 39d1279..b843f19 100644 --- a/emu/main_panel.c +++ b/emu/main_panel.c @@ -55,6 +55,8 @@ struct SwDigit static SDL_Window *window; static SDL_Renderer *renderer; +Lock initlock; +volatile int awaitinit; Image* mustloadimg(const char *path) @@ -903,6 +905,8 @@ void main340(void); if(apr == nil || tty == nil || ptr == nil || ptp == nil) err("need APR, TTY, PTR and PTP"); + while(awaitinit); + cmdchans[0] = chancreate(sizeof(char*), 1); cmdchans[1] = chancreate(sizeof(void*), 1); t = (Task){ nil, readcmdchan, cmdchans, 10, 0 }; diff --git a/emu/pdp6.h b/emu/pdp6.h index d44a51c..9ed0be8 100644 --- a/emu/pdp6.h +++ b/emu/pdp6.h @@ -42,6 +42,9 @@ void *rtcthread(void *p); int dofile(const char *path); void defaultconfig(void); +extern Lock initlock; +extern volatile int awaitinit; + enum { MAXPULSE = 20 };