VOID trans_obj(LONG tree, WORD obj) { WORD type, wb, hl; LONG taddr, obspec; type = LLOBT(GET_TYPE(tree, obj)); if ( (obspec = GET_SPEC(tree, obj)) != -1L) { switch (type) { case G_IMAGE: trans_bitblk(obspec); break; case G_ICON: hl = LWGET(IB_HICON(obspec)); wb = (LWGET(IB_WICON(obspec)) + 7) >> 3; if ( (taddr = LLGET(IB_PDATA(obspec))) != -1L) gsx_trans(taddr, wb, taddr, wb, hl); if ( (taddr = LLGET(IB_PMASK(obspec))) != -1L) gsx_trans(taddr, wb, taddr, wb, hl); break; default: break; } } }
void app_tran(WORD bi_num) { BITBLK *pbi; BITBLK lb; rsrc_gaddr(R_BITBLK, bi_num, (void **)&pbi); memcpy(&lb, pbi, sizeof(BITBLK)); gsx_trans(lb.bi_pdata, lb.bi_wb, lb.bi_pdata, lb.bi_wb, lb.bi_hl); }
VOID trans_bitblk(LONG obspec) { LONG taddr; WORD wb, hl; if ( (taddr = LLGET(BI_PDATA(obspec))) != -1L) { wb = LWGET(BI_WB(obspec)); hl = LWGET(BI_HL(obspec)); gsx_trans(taddr, wb, taddr, wb, hl); } }
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(); }
/* Note: this file originally loaded the icon data from a file (deskhi.icn or desklo.icn). But due to endianness problems and for ROM-ing the desktop, I changed this behaviour so that the icons are included in the program file now. Hope there aren't too much faults in this new version of this function. See icons.c, too. - THH Note 2: this function was greatly rewritten in 2012 to use "real" ICONBLKs in icons.c, so that they can be generated by a resource editor - RFB */ static void app_rdicon(void) { WORD mask[NUM_IBLKS], data[NUM_IBLKS]; char copied[NUM_IBLKS]; char *p; WORD *addr; LONG temp; WORD i, j, n, iwb, ih; WORD num_mask, num_data, num_wds, num_bytes; /* * First, we copy the ICONBLKs to the g_iblist[] array: * g_iblist[] points to the transformed data/transformed mask * & is referenced by act_chkobj() in deskact.c, insa_icon() * in deskins.c, and win_bldview() in deskwin.c */ memcpy(G.g_iblist, icon_rs_iconblk, NUM_IBLKS*sizeof(ICONBLK)); /* * Then we initialise g_origmask[]: * g_origmask[i] points to the untransformed mask & is * referenced by act_chkobj() in deskact.c */ for (i = 0; i < NUM_IBLKS; i++) G.g_origmask[i] = (UWORD *)icon_rs_iconblk[i].ib_pmask; /* * Determine the number of mask and data icons actually used * (different ICONBLKs can point to the same mask and/or data) * and set mask[n] = mask# for iconblk n * data[n] = data# for iconblk n */ for (i = 0; i < NUM_IBLKS; i++) mask[i] = data[i] = -1; for (i = 0, num_mask = num_data = 0; i < NUM_IBLKS; i++) { if (mask[i] < 0) { mask[i] = num_mask; addr = icon_rs_iconblk[i].ib_pmask; for (j = i+1; j < NUM_IBLKS; j++) if (icon_rs_iconblk[j].ib_pmask == addr) mask[j] = num_mask; num_mask++; } if (data[i] < 0) { data[i] = num_data; addr = icon_rs_iconblk[i].ib_pdata; for (j = i+1; j < NUM_IBLKS; j++) if (icon_rs_iconblk[j].ib_pdata == addr) data[j] = num_data; num_data++; } } /* * Calculate the size of each icon in words & bytes. We * assume that all icons are the same w,h as the first */ num_wds = (icon_rs_iconblk[0].ib_wicon * icon_rs_iconblk[0].ib_hicon) / 16; num_bytes = num_wds * 2; /* * Allocate memory for the mask/data icons, and copy them * FIXME: we should check that memory is allocated successfully */ maskstart = dos_alloc(num_mask*num_bytes); memset(copied, 0x00, NUM_IBLKS); for (i = 0, p = maskstart; i < NUM_IBLKS; i++) { n = mask[i]; if (!copied[n]) /* only copy mask once */ { memcpy(p+n*num_bytes, (char *)icon_rs_iconblk[i].ib_pmask, num_bytes); copied[n] = 1; } } datastart = dos_alloc(num_data*num_bytes); memset(copied, 0x00, NUM_IBLKS); for (i = 0, p = datastart; i < NUM_IBLKS; i++) { n = data[i]; if (!copied[n]) /* only copy data once */ { memcpy(p+n*num_bytes, icon_rs_iconblk[i].ib_pdata, num_bytes); copied[n] = 1; } } /* * Fix up the ICONBLKs */ for (i = 0; i < NUM_IBLKS; i++) { temp = mask[i] * num_bytes; G.g_iblist[i].ib_pmask = (WORD *)(maskstart + temp); temp = data[i] * num_bytes; G.g_iblist[i].ib_pdata = (WORD *)(datastart + temp); G.g_iblist[i].ib_ytext = icon_rs_iconblk[0].ib_hicon; G.g_iblist[i].ib_wtext = 12 * gl_wschar; G.g_iblist[i].ib_htext = gl_hschar + 2; } /* * Finally we do the transforms */ iwb = icon_rs_iconblk[0].ib_wicon / 8; ih = icon_rs_iconblk[0].ib_hicon; for (i = 0, p = maskstart; i < num_mask; i++, p += num_bytes) gsx_trans((LONG)p, iwb, (LONG)p, iwb, ih); for (i = 0, p = datastart; i < num_data; i++, p += num_bytes) gsx_trans((LONG)p, iwb, (LONG)p, iwb, ih); }