void forker(void) { register FPD *f; register PD *oldrl; register LONG amt; FPD g; oldrl = rlr; rlr = (PD *) -1; while(fpcnt) { /* critical area */ cli(); fpcnt--; f = &D.g_fpdx[fph++]; /* copy FPD so an interrupt */ /* doesn't overwrite it. */ LBCOPY(ADDR(&g), ADDR(f), sizeof(FPD) ); if (fph == NFORKS) fph = 0; sti(); /* */ /* see if recording */ if (gl_recd) { /* check for stop key */ if ( ((void *)g.f_code == (void *)kchange) && ((g.f_data & 0x0000ffffL) == KEYSTOP) ) gl_recd = FALSE; /* if still recording */ /* then handle event */ if (gl_recd) { /* if its a time event &*/ /* previously recorded*/ /* was a time event */ /* then coalesce them */ /* else record the */ /* event */ if ( ((void *)g.f_code == (void *)tchange) && (LLGET(gl_rbuf - sizeof(FPD)) == (LONG)tchange) ) { amt = g.f_data + LLGET(gl_rbuf-sizeof(LONG)); LLSET(gl_rbuf - sizeof(LONG), amt); } else { LBCOPY(gl_rbuf, ADDR(f), sizeof(FPD)); gl_rbuf += sizeof(FPD); gl_rlen--; gl_recd = gl_rlen; } } } (*g.f_code)(g.f_data); } rlr = oldrl; }
/* * Routine to fix up the command tail and parse FCBs for a coming * exec. */ void sh_fixtail(WORD iscpm) { register WORD i; WORD len; BYTE *s_tail; BYTE *ptmp; BYTE s_fcbs[32]; /* reuse part of globals*/ s_tail = &D.g_dir[0]; i = 0; if (iscpm) { s_tail[i++] = NULL; ptmp = &D.s_cmd[0]; while ( (*ptmp) && (*ptmp != '.') ) s_tail[i++] = *ptmp++; } LBCOPY(ADDR(&s_tail[i]), ad_stail, 128 - i); if (iscpm) { /* pick up the length */ len = s_tail[i]; /* null over carriage ret*/ s_tail[i + len + 1] = NULL; /* copy down space,tail */ strcpy(&s_tail[i], &s_tail[i+1]); } else { /* zero the fcbs */ memset(s_fcbs, 0, 32); memset(&s_fcbs[1], ' ', 11); memset(&s_fcbs[17], ' ', 11); /* parse the fcbs */ if ( s_tail[0] ) { s_tail[ 1 + s_tail[0] ] = NULL; ptmp = sh_parse(&s_tail[1], &s_fcbs[0]); if (*ptmp != NULL) sh_parse(ptmp, &s_fcbs[16]); s_tail[ 1 + s_tail[0] ] = 0x0d; } } /* copy into true tail */ LBCOPY(ad_stail, s_tail, 128); }
VOID hndl_spmsg(WORD len, LONG lpath, WORD cnt, WORD delit,WORD prntr) { BYTE *pslot; WORD newprn; pslot = spol_alloc(); if (pslot) { switch (prntr & 0xFF) { case 0: case 1: case 2: newprn = prntr; break; default: newprn = 0; /* LPT1 */ } LBCOPY(ADDR(pslot), lpath, len + 1); gl_sppfn[gl_spnxt] = pslot; gl_spdel[gl_spnxt] = delit; gl_sptab[gl_spnxt] = ((prntr & 0x0100) == 0); gl_spcnt[gl_spnxt] = cnt; gl_spprn[gl_spnxt] = newprn; if (!gl_spnxt) spol_file( pslot, gl_sptab[gl_spnxt], gl_spprn[gl_spnxt] ); gl_spnxt++; } spol_bttn(); spol_draw(SPOLBOX); }
LOCAL LONG copy_bb(LONG source) { LONG dest; dest = get_mem((UWORD) sizeof(BITBLK)); LBCOPY(dest, source, sizeof(BITBLK) ); return (dest); }
LOCAL LONG copy_ti(LONG source) { LONG dest; dest = get_mem((UWORD) sizeof(TEDINFO)); LBCOPY(dest, source, sizeof(TEDINFO) ); return (dest); }
VOID icon_wh(LONG taddr, WORD *w, WORD *h) { ICONBLK here; GRECT p; LBCOPY(ADDR(&here), taddr, sizeof(ICONBLK)); rc_copy((GRECT *) &here.ib_xchar, &p); rc_union((GRECT *) &here.ib_xicon, &p); rc_union((GRECT *) &here.ib_xtext, &p); *w = p.g_x + p.g_w; *h = p.g_y + p.g_h; }
/* * Search for a particular string in the DOS environment and return * a long pointer to the character after the string if it is found. * Otherwise, return a NULLPTR */ void sh_envrn(BYTE **ppath, const BYTE *psrch) { BYTE *lp; WORD len, findend; BYTE last, tmp, loc1[10], loc2[10]; len = strlencpy(loc2, psrch); len--; loc1[len] = NULL; lp = ad_envrn; findend = FALSE; tmp = NULL; do { last = tmp; tmp = LBGET(lp); lp++; if ( (findend) && (tmp == NULL) ) { findend = FALSE; tmp = 0xFF; } else { if (((last == NULL) || (last == -1)) && (tmp == loc2[0])) { LBCOPY(ADDR(&loc1[0]), lp, len); if ( strcmp(&loc1[0], &loc2[1])==0 ) { lp += len; break; } } else findend = TRUE; } } while( tmp ); if (!tmp) lp = 0x0L; *ppath = lp; }
/* * 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 */ }
static void sh_init(void) { WORD cnt, need_ext; BYTE *psrc, *pdst, *pend; BYTE *s_tail; SHELL *psh; BYTE savch; psh = &sh[0]; sh_deskf(2, (LONG)&ad_pfile); /* add in internal */ /* search paths with */ /* right drive letter */ sh_addpath(); /* set defaults */ psh->sh_doexec = psh->sh_dodef = gl_shgem = psh->sh_isgem = TRUE; psh->sh_fullstep = FALSE; /* parse command tail */ /* that was stored in */ /* geminit */ psrc = s_tail = &D.g_dir[0]; /* reuse part of globals*/ memcpy(s_tail,ad_stail,128); cnt = *psrc++; if (cnt) { /* null-terminate it */ pend = psrc + cnt; *pend = NULL; /* scan off leading */ /* spaces */ while( (*psrc) && (*psrc == ' ') ) psrc++; /* if only white space */ /* get out don't */ /* bother parsing */ if (*psrc) { pdst = psrc; while ( (*pdst) && (*pdst != ' ') ) pdst++; /* find end of app name */ /* save command to do */ /* instead of desktop */ savch = *pdst; *pdst = '\0'; /* mark for sh_name() */ pend = sh_name(psrc); /* see if path also */ *pdst = savch; /* either blank or null */ pdst = &D.s_cmd[0]; if (pend != psrc) { if (*(psrc+1) != ':') /* need drive */ { *pdst++ = gl_logdrv; /* current drive */ *pdst++ = ':'; if (*psrc != '\\') *pdst++ = '\\'; } while (psrc < pend) /* copy rest of path */ *pdst++ = *psrc++; if (*(pdst-1) == '\\') /* back up one char */ pdst--; *pdst = '\0'; pend = &D.s_cmd[0]; while (*pend) /* upcase the path */ { *pend = toupper(*pend); pend++; } dos_sdrv(D.s_cmd[0] -'A'); dos_chdir(D.s_cmd); *pdst++ = '\\'; } need_ext = TRUE; while ( (*psrc) && (*psrc != ' ') ) { if (*psrc == '.') need_ext = FALSE; *pdst++ = *psrc++; } /* append .APP if no */ /* extension given */ if (need_ext) strcpy(pdst, ".APP"); else *pdst = NULL; pdst = &D.s_cmd[0]; while (*pdst) /* upcase the command */ { *pdst = toupper(*pdst); pdst++; } psh->sh_dodef = FALSE; /* save the remainder */ /* into command tail */ /* for the application*/ pdst = &s_tail[1]; /* if ( (*psrc) && * if tail then take * (*psrc != 0x0D) && * out first space * (*psrc == ' ') ) psrc++; */ if (*psrc == ' ') psrc++; /* the batch file allows */ /* three arguments */ /* one for a gem app */ /* and 2 for arguments */ /* to the gem app. */ /* if there are < three */ /* there will be a space */ /* at the end of the last*/ /* arg followed by a 0D */ while ( (*psrc) && (*psrc != 0x0D) && (*psrc != 0x09) && /* what is this?? */ !((*psrc == '/') && (toupper(*(psrc+1)) == 'D')) ) { if ( (*psrc == ' ') && ( (*(psrc+1) == 0x0D) || (*(psrc+1) == NULL)) ) psrc++; else *pdst++ = toupper(*psrc++); } *pdst = NULL; s_tail[0] = strlen(&s_tail[1]); /* don't do the desktop */ /* after this command */ /* unless a /d was */ /* encounterd */ psh->sh_doexec = (toupper(*(psrc+1)) == 'D'); } } LBCOPY(ad_stail, (LONG)(&s_tail[0]), 128); }
VOID view_trees(VOID) { WORD nobj, iobj; WORD kind, where, nh; LONG tree, iconad; tree = ad_pbx; rcs_work[0].ob_next = NIL; /* construct tree root */ rcs_work[0].ob_type = G_BOX; rcs_work[0].ob_flags = NONE; rcs_work[0].ob_state = NORMAL; #if TURBO_C rcs_work[0].ob_spec.index = 0x00000007L; #else rcs_work[0].ob_spec = 0x00000007L; #endif rcs_work[0].ob_x = view.g_x; rcs_work[0].ob_y = view.g_y; rcs_work[0].ob_width = view.g_w; rcs_work[0].ob_height = view.g_h; if (!LWGET(RSH_NTREE(head))) { rcs_work[0].ob_head = NIL; rcs_work[0].ob_tail = NIL; } else { nobj = min(VIEWSIZE, LWGET(RSH_NTREE(head)) - rcs_trpan); nobj = min(nobj, fit_vtrees() * (nh = fit_htrees())); rcs_work[0].ob_head = 1; /* root pointers */ rcs_work[0].ob_tail = nobj; for (iobj = 0; iobj++ < nobj; ) { if (iobj < nobj) rcs_work[iobj].ob_next = iobj + 1; else rcs_work[iobj].ob_next = ROOT; rcs_work[iobj].ob_head = NIL; rcs_work[iobj].ob_tail = NIL; rcs_work[iobj].ob_flags = NONE; rcs_work[iobj].ob_state = NORMAL; rcs_work[iobj].ob_type = G_ICON; #if TURBO_C rcs_work[iobj].ob_spec.iconblk = (ICONBLK *)ADDR(&rcs_icons[iobj]); #else rcs_work[iobj].ob_spec = ADDR(&rcs_icons[iobj]); #endif rcs_work[iobj].ob_width = ICON_W; rcs_work[iobj].ob_height = ICON_H + gl_hschar; rcs_work[iobj].ob_x = ((iobj - 1) % nh) * (ICON_W + MIN_WINT); rcs_work[iobj].ob_y = ((iobj - 1) / nh) * (ICON_H + MIN_HINT); where = find_tree(iobj + rcs_trpan - 1); kind = get_kind(where); iconad = GET_SPEC(tree, rcs_typ2icn[kind]); LBCOPY(ADDR(&rcs_icons[iobj]), iconad, sizeof(ICONBLK)); rcs_icons[iobj].ib_ptext = /* address of tree */ (char *)ADDR( get_name(where) ); rcs_icons[iobj].ib_wtext = ch_width(IBM) * (WORD)LSTRLEN(rcs_icons[iobj].ib_ptext); rcs_icons[iobj].ib_ytext = ICON_H; rcs_icons[iobj].ib_xtext = (rcs_icons[iobj].ib_wicon - rcs_icons[iobj].ib_wtext) / 2; } } }
void sh_read(BYTE *pcmd, BYTE *ptail) { strcpy(pcmd, D.s_cmd); LBCOPY(ptail, ad_stail, 128); }
/* * Used by the DESKTOP to save away 1024 bytes worth of desktop- * context information. */ void sh_put(const void *pdata, WORD len) { LBCOPY(ad_ssave, pdata, len); }
/* * Used by the DESKTOP to recall 1024 bytes worth of previously * 'put' desktop-context information. */ void sh_get(void *pbuffer, WORD len) { LBCOPY(pbuffer, ad_ssave, len); }