/* * Routine to set the next application to run * * isgem = 0 then run in character mode * isgem = 1 them run in graphic mode * * isover = 0 then run above DESKTOP * isover = 1 then run over DESKTOP */ WORD sh_write(WORD doex, WORD isgem, WORD isover, const BYTE *pcmd, const BYTE *ptail) { SHELL *psh; if (doex == 5) /* Change resolution */ { gl_changerez = 1 + isover; gl_nextrez = isgem; strcpy(D.s_cmd, ""); strcpy(ad_stail, ""); return TRUE; } strcpy(D.s_cmd, pcmd); LBCOPY(ad_stail, ptail, 128); if (isover > 0) { /* stepaside to run */ psh = &sh[rlr->p_pid]; psh->sh_isgem = (isgem != FALSE); psh->sh_doexec = doex; psh->sh_dodef = FALSE; psh->sh_fullstep = isover - 1; sh_curdir(sh_apdir); /* save apps. current */ /* directory */ } else { sh_fixtail(FALSE); /* run it above us */ if ( sh_find(D.s_cmd) ) { /* Normal Atari-GEM's shel_write does not support running PRGs directly! */ /*dos_exec(0, D.s_cmd, ad_stail, ad_envrn);*/ } else return(FALSE); } return(TRUE); /* for the future */ }
void gem_main(void) { WORD i; const BITBLK *tmpadbi; sh_rdinf(); /* get start of emudesk.inf */ if (!gl_changerez) /* can't be here because of rez change, */ process_inf1(); /* so see if .inf says we need to change rez */ if (gl_changerez) { switch(gl_changerez) { #if CONF_WITH_SHIFTER case 1: /* ST(e) or TT display */ Setscreen(-1L,-1L,gl_nextrez-2,0); initialise_palette_registers(gl_nextrez-2,0); break; #endif #if CONF_WITH_VIDEL case 2: /* Falcon display */ Setscreen(-1L, -1L, FALCON_REZ, gl_nextrez); initialise_palette_registers(FALCON_REZ,gl_nextrez); break; #endif } gsx_wsclear(); /* avoid artefacts that may show briefly */ } totpds = NUM_PDS; ml_ocnt = 0; gl_changerez = FALSE; ini_dlongs(); /* init longs */ cli(); takecpm(); /* take the 0efh int. */ /* init event recorder */ gl_recd = FALSE; gl_rlen = 0; gl_rbuf = 0x0L; /* initialize pointers to heads of event list and thread list */ elinkoff = (BYTE *) &(D.g_intevb[0].e_link) - (BYTE *) &(D.g_intevb[0]); /* link up all the evb's to the event unused list */ eul = NULLPTR; ev_init(&D.g_intevb[0], NUM_IEVBS); if (totpds > 2) ev_init(&D.g_extevb[0], NUM_EEVBS); /* initialize sync blocks */ wind_spb.sy_tas = 0; wind_spb.sy_owner = NULLPTR; wind_spb.sy_wait = 0; /* * init processes - TODO: should go in gempd or gemdisp. */ /* initialize list and unused lists */ nrl = drl = NULLPTR; dlr = zlr = NULLPTR; fph = fpt = fpcnt = 0; /* init initial process */ for(i=totpds-1; i>=0; i--) { rlr = pd_index(i); if (i < 2) { rlr->p_uda = &D.g_intuda[i]; rlr->p_cda = &D.g_intcda[i]; } else { rlr->p_uda = &D.g_extuda[i-2]; rlr->p_cda = &D.g_extcda[i-2]; } rlr->p_qaddr = (LONG)(&rlr->p_queue[0]); rlr->p_qindex = 0; memset(rlr->p_name, ' ', 8); rlr->p_appdir[0] = '\0'; /* by default, no application directory */ /* if not rlr then initialize his stack pointer */ if (i != 0) rlr->p_uda->u_spsuper = &rlr->p_uda->u_supstk; rlr->p_pid = i; rlr->p_stat = 0; } curpid = 0; rlr->p_pid = curpid++; rlr->p_link = NULLPTR; /* end of process init */ /* restart the tick */ sti(); /* * screen manager process init. this process starts out owning the mouse * and the keyboard. it has a pid == 1 */ gl_dacnt = 0; gl_mowner = ctl_pd = iprocess("SCRENMGR", ctlmgr); /* load gem resource and fix it up before we go */ gem_rsc_init(); { /* get mice forms */ ad_armice = *(LONG *)&rs_bitblk[MICE00]; ad_hgmice = *(LONG *)&rs_bitblk[MICE02]; /* init button stuff */ gl_btrue = 0x0; gl_bdesired = 0x0; gl_bdely = 0x0; gl_bclick = 0x0; gl_logdrv = dos_gdrv() + 'A'; /* boot directory */ gsx_init(); /* do gsx open work station */ /* load all desk acc's */ if (totpds > 2) ldaccs(); /* fix up icons */ for(i=0; i<3; i++) { tmpadbi = &rs_bitblk[NOTEBB+i]; memcpy((char *)&bi, tmpadbi, sizeof(BITBLK)); gsx_trans(bi.bi_pdata, bi.bi_wb, bi.bi_pdata, bi.bi_wb, bi.bi_hl); } /* take the critical err handler int. */ cli(); takeerr(); sti(); /* go into graphic mode */ sh_tographic(); /* take the tick int. */ cli(); gl_ticktime = gsx_tick(tikaddr, &tiksav); sti(); /* set init. click rate: must do this after setting gl_ticktime */ ev_dclick(3, TRUE); /* fix up the GEM rsc. file now that we have an open WS */ gem_rsc_fixit(); /* get st_desk ptr */ ad_stdesk = (LONG) rs_trees[DESKTOP]; /* init. window vars. */ wm_start(); /* startup gem libs */ fs_start(); /* remember current desktop directory */ sh_curdir(D.s_cdir); /* process emudesk.inf part 2 */ process_inf2(); /* off we go !!! */ dsptch(); /* let them run */ all_run(); /* * init for shell loop up thru here it is okay for system to * overlay this initialization code */ sh_init(); /* * main shell loop. From here on down data should not overlay * this code */ sh_main(); /* give back the tick */ cli(); gl_ticktime = gsx_tick(tiksav, &tiksav); sti(); /* close workstation */ gsx_wsclose(); } /* return GEM's 0xEF int*/ cli(); givecpm(); sti(); }
/* * This function is called from accdesk_start (in gemstart.S) which * is itself called from gem_main() below. * * It runs under a separate process which terminates on shutdown or * resolution change (see accdesk_start). This ensures that all * memory allocated to or by desk accessories is automatically freed * on resolution change. */ void run_accs_and_desktop(void) { WORD i; BOOL isgem; /* load gem resource and fix it up before we go */ gem_rsc_init(); /* get mice forms */ ad_armice = (MFORM *)rs_bitblk[MICE00].bi_pdata; ad_hgmice = (MFORM *)rs_bitblk[MICE02].bi_pdata; /* init button stuff */ gl_btrue = 0x0; gl_bdesired = 0x0; gl_bdely = 0x0; gl_bclick = 0x0; gl_logdrv = dos_gdrv() + 'A'; /* boot directory */ gsx_init(); /* do gsx open work station */ load_accs(num_accs); /* load up to 'num_accs' desk accessories */ /* fix up icons */ for (i = 0; i < 3; i++) { memcpy(&bi, &rs_bitblk[NOTEBB+i], sizeof(BITBLK)); gsx_trans(bi.bi_pdata, bi.bi_wb, bi.bi_pdata, bi.bi_wb, bi.bi_hl); } /* take the critical err handler int. */ disable_interrupts(); takeerr(); enable_interrupts(); sh_tographic(); /* go into graphic mode */ /* take the tick interrupt */ disable_interrupts(); gl_ticktime = gsx_tick(tikaddr, &tiksav); enable_interrupts(); /* set initial click rate: must do this after setting gl_ticktime */ ev_dclick(3, TRUE); /* fix up the GEM rsc file now that we have an open WS */ gem_rsc_fixit(); wm_start(); /* initialise window vars */ fs_start(); /* startup gem libs */ sh_curdir(D.s_cdir); /* remember current desktop directory */ isgem = process_inf2(); /* process emudesk.inf part 2 */ dsptch(); /* off we go !!! */ all_run(); /* let them run */ sh_init(); /* init for shell loop */ sh_main(isgem); /* main shell loop */ /* give back the tick */ disable_interrupts(); gl_ticktime = gsx_tick(tiksav, &tiksav); enable_interrupts(); /* close workstation */ gsx_wsclose(); }
WORD sh_find(BYTE *pspec) { WORD path; BYTE gotdir, *pname; pname = sh_name(pspec); /* get ptr to name */ gotdir = (pname != pspec); dos_sdta((LONG)D.g_dta); /* first, search in the application directory */ if (!gotdir && rlr->p_appdir[0] != '\0') { strcpy(D.g_dir, rlr->p_appdir); strcat(D.g_dir, pname); dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); if (!DOS_ERR) { strcpy(pspec, D.g_dir); return 1; } } /* second, search in the current directory */ strcpy(D.g_dir, pspec); /* copy to local buffer */ if (!gotdir) { sh_curdir(D.g_dir); /* get current drive/dir*/ if (D.g_dir[3] != NULL) /* if not at root */ strcat(&D.g_dir[0], "\\"); /* add foreslash */ strcat(&D.g_dir[0], pname); /* append name to drive */ /* and directory. */ /* the actual search will be performed in the loop below */ } /* third, search in the AES path */ path = 0; do { dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); if ( (DOS_AX == E_PATHNOTFND) || ((DOS_ERR) && ((DOS_AX == E_NOFILES) || (DOS_AX == E_PATHNOTFND) || (DOS_AX == E_FILENOTFND))) ) { path = sh_path(path, (LONG)D.g_dir, pname); DOS_ERR = TRUE; } else path = 0; } while ( !gotdir && DOS_ERR && path ); /* fourth, search in the current drive root directory */ if (DOS_ERR && !gotdir) { strcpy(D.g_dir, "\\"); strcat(D.g_dir, pname); dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); } if (!DOS_ERR) strcpy(pspec, D.g_dir); return(!DOS_ERR); }