Beispiel #1
0
void sh_chdef(SHELL *psh)
{
                                                /* if we should exec    */
                                                /*   the default command*/
                                                /*   then let it be     */
                                                /*   known that it is   */
                                                /*   a gem appl.        */
        psh->sh_isdef = FALSE;
        if ( psh->sh_dodef )
        {
          psh->sh_isdef = psh->sh_isgem = TRUE;
          psh->sh_fullstep = 0;
          if(psh->sh_cdir[1] == ':')
            dos_sdrv(psh->sh_cdir[0] - 'A');
          dos_chdir((BYTE *)ADDR(&psh->sh_cdir[0]));
          strcpy(&D.s_cmd[0], &psh->sh_desk[0]);
        }
        else
        {                       
          if(sh_apdir[1] == ':')
            dos_sdrv(sh_apdir[0] - 'A');        /* desktop's def. dir   */
          dos_chdir(sh_apdir);
        }
}
Beispiel #2
0
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);
}
Beispiel #3
0
void gem_main(void)
{
    WORD    i;

    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_ATARI_VIDEO
        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 */
        /*
         * resolution change always resets the default drive to the
         * boot device.  TOS3 issues a Dsetdrv() when this happens,
         * which Hatari's GEMDOS drive emulation uses to keep track
         * of the current drive.  we do the same.
         */
        dos_sdrv(bootdev);
    }

    ml_ocnt = 0;

    gl_changerez = FALSE;

    mn_init();                      /* initialise variables for menu_register() */

    num_accs = count_accs();        /* puts ACC names in acc_name[] */

    D.g_acc = NULL;
    if (num_accs)
        D.g_acc = dos_alloc(num_accs*sizeof(AESPROCESS));
    if (D.g_acc)
        memset(D.g_acc,0x00,num_accs*sizeof(AESPROCESS));
    else num_accs = 0;

    totpds = num_accs + 2;

    disable_interrupts();
    set_aestrap();                  /* set trap#2 -> aestrap */

    /* init event recorder  */
    gl_recd = FALSE;
    gl_rlen = 0;
    gl_rbuf = NULL;

    /* link up all the evb's to the event unused list */
    eul = NULL;
    for (i = 0; i < 2; i++)
        ev_init(D.g_int[i].a_evb,EVBS_PER_PD);
    for (i = 0; i < num_accs; i++)
        ev_init(D.g_acc[i].a_evb,EVBS_PER_PD);

    /* initialize sync blocks */
    wind_spb.sy_tas = 0;
    wind_spb.sy_owner = NULL;
    wind_spb.sy_wait = 0;

    /*
     * init processes - TODO: should go in gempd or gemdisp.
     */

    /* initialize list and unused lists   */
    nrl = drl = NULL;
    dlr = zlr = NULL;
    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_int[i].a_uda;
            rlr->p_cda = &D.g_int[i].a_cda;
        }
        else
        {
            rlr->p_uda = &D.g_acc[i-2].a_uda;
            rlr->p_cda = &D.g_acc[i-2].a_cda;
        }
        rlr->p_qaddr = rlr->p_queue;
        rlr->p_qindex = 0;
        memset(rlr->p_name, ' ', AP_NAMELEN);
        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 = NULL;

    /* end of process init */

    /* restart the tick     */
    enable_interrupts();

    /*
     * screen manager process init. this process starts out owning the mouse
     * and the keyboard. it has a pid == 1
     */
    gl_mowner = ctl_pd = iprocess("SCRENMGR", ctlmgr);

    /*
     * run the accessories and the desktop until termination
     * (for shutdown or resolution change)
     */
    aes_run_rom_program(accdesk_start);

    /* restore previous trap#2 address */
    disable_interrupts();
    unset_aestrap();
    enable_interrupts();

    if (D.g_acc)
        dos_free((LONG)D.g_acc);
}
Beispiel #4
0
/*
 *  Initialize the application list by reading in the EMUDESK.INF
 *  file, either from memory or from the disk if the shel_get
 *  indicates no message is there.
 */
void app_start(void)
{
    WORD i, x, y;
    ANODE *pa;
    WSAVE *pws;
    BYTE *pcurr, *ptmp, *pauto = NULL;
    WORD envr, xcnt, ycnt, xcent, wincnt, dummy;

    /* remember start drive */
    gl_stdrv = dos_gdrv();

    G.g_pbuff = gl_buffer;

    for (i = NUM_ANODES - 2; i >= 0; i--)
        G.g_alist[i].a_next = &G.g_alist[i + 1];
    G.g_ahead = (ANODE *) NULL;
    G.g_aavail = G.g_alist;
    G.g_alist[NUM_ANODES - 1].a_next = (ANODE *) NULL;

    app_rdicon();

    G.g_wicon = (12 * gl_wschar) + (2 * G.g_iblist[0].ib_xtext);
    G.g_hicon = G.g_iblist[0].ib_hicon + gl_hschar + 2;

    xcnt = G.g_wdesk / (G.g_wicon+MIN_WINT);/* icon count */
    G.g_icw = G.g_wdesk / xcnt;             /* width */

    ycnt = G.g_hdesk / (G.g_hicon+MIN_HINT);/* icon count */
    G.g_ich = G.g_hdesk / ycnt;             /* height */

    shel_get(gl_afile, SIZE_AFILE);
    if (gl_afile[0] != '#')                 /* invalid signature    */
    {                                       /*   so read from disk  */
        LONG ret;
        WORD fh;
        char inf_file_name[16];
        strcpy(inf_file_name, INF_FILE_NAME);
        inf_file_name[0] += gl_stdrv;         /* Adjust drive letter  */
        ret = dos_open(inf_file_name, 0x0);
        if (ret >= 0L)
        {
            fh = (WORD) ret;
            ret = dos_read(fh, SIZE_AFILE, gl_afile);
            G.g_afsize = (ret < 0L) ? 0L : ret;
            dos_close(fh);
            gl_afile[G.g_afsize] = '\0';
        }
    }

    /* If there's still no desktop.inf data, use built-in now: */
    if (gl_afile[0] != '#')
    {
        LONG drivemask;
        char *text;
        int icon_index = 0;
        int drive_x = 0, drive_y = 0;
        int trash_x, trash_y;
        int icon_type;
        char drive_letter;

        /* Environment and Windows */
        strcat(gl_afile, desk_inf_data1);

        /* Scan for valid drives: */
        drivemask = dos_sdrv(dos_gdrv());
        for (i = 0; i < BLKDEVNUM; i++)
        {
            if (drivemask&(1L<<i))
            {
                x = strlen(gl_afile);
                drive_x = icon_index % xcnt; /* x position */
                drive_y = icon_index / xcnt; /* y position */
                icon_type = (i > 1) ? 0 /* Hard disk */ : 1 /* Floppy */;
                drive_letter = 'A' + i;
                rsrc_gaddr(R_STRING, STDISK, (void **)&text);
                sprintf(gl_afile + x, "#M %02X %02X %02X FF %c %s %c@ @\r\n",
                        drive_x, drive_y, icon_type, drive_letter, text, drive_letter);
                icon_index++;
            }
        }

        /* Copy core data part 2 */
        strcat(gl_afile, desk_inf_data2);

        /* add Trash icon to end */
        x = strlen(gl_afile);
        trash_x = 0;            /* Left */
        trash_y = ycnt-1;       /* Bottom */
        if (drive_y >= trash_y) /* if the last drive icon overflows over */
            trash_x = xcnt-1;   /*  the trash row, force trash to right  */
        rsrc_gaddr(R_STRING, STTRASH, (void **)&text);
        sprintf(gl_afile + x, "#T %02X %02X 03 FF   %s@ @\r\n",
                trash_x, trash_y, text);
        G.g_afsize = strlen(gl_afile);
    }

    wincnt = 0;
    inf_rev_level = 0;
    pcurr = gl_afile;

    while(*pcurr)
    {
        if (*pcurr++ != '#')            /* look for start of line */
            continue;

        switch(*pcurr)
        {
        case 'R':                       /* revision level */
            pcurr++;
            pcurr = scan_2(pcurr,&inf_rev_level);
            break;
        case 'Z':                       /* autorun: Z nn pathname@ */
            pcurr = scan_str(pcurr+5,&pauto);   /* save pathname in buffer */
            break;                              /* (a bit wasteful)        */
        case 'T':                       /* Trash */
        case 'M':                       /* Media (Hard/Floppy)  */
        case 'G':                       /* GEM Application      */
        case 'Y':                       /* GEM App. with parms  */
        case 'F':                       /* File (DOS w/o parms) */
        case 'P':                       /* Parm (DOS w/ parms)  */
        case 'D':                       /* Directory            */
        case 'I':                       /* Executable file icon     */
        case 'N':                       /* Non-executable file icon */
            pa = app_alloc(TRUE);
            if (!pa)                    /* paranoia */
                return;
            pcurr = app_parse(pcurr, pa);
            if ((pa->a_type == AT_ISFILE) && pauto)
            {                           /* autorun exists & not yet merged */
                if (strcmp(pauto,pa->a_pappl) == 0)
                {
                    pa->a_flags |= AF_AUTORUN;  /* it's this program */
                    pauto = NULL;               /*  (and no other)   */
                }
            }
            break;
        case 'W':                       /* Window               */
            pcurr++;
            if (wincnt < NUM_WNODES)
            {
                pws = &G.g_cnxsave.cs_wnode[wincnt];
                pcurr = scan_2(pcurr, &dummy);
                pcurr = scan_2(pcurr, &pws->vsl_save);
/* BugFix       */
                pcurr = scan_2(pcurr, &pws->x_save);
                pws->x_save *= gl_wchar;
                pcurr = scan_2(pcurr, &pws->y_save);
                pws->y_save *= gl_hchar;
                pcurr = scan_2(pcurr, &pws->w_save);
                pws->w_save *= gl_wchar;
                pcurr = scan_2(pcurr, &pws->h_save);
                pws->h_save *= gl_hchar;
/* */
                pcurr = scan_2(pcurr, &pws->obid_save);
                ptmp = pws->pth_save;
                pcurr++;
                while(*pcurr != '@')
                    *ptmp++ = *pcurr++;
                *ptmp = '\0';
                wincnt += 1;
            }
            break;
        case 'E':                       /* Environment */
            pcurr++;
            pcurr = scan_2(pcurr, &envr);
            G.g_cnxsave.cs_view = ( (envr & INF_E1_VIEWTEXT) != 0);
            G.g_cnxsave.cs_sort = ( (envr & INF_E1_SORTMASK) >> 5);
            G.g_cnxsave.cs_confdel = ( (envr & INF_E1_CONFDEL) != 0);
            G.g_cnxsave.cs_confcpy = ( (envr & INF_E1_CONFCPY) != 0);
            G.g_cnxsave.cs_dblclick = envr & INF_E1_DCMASK;

            pcurr = scan_2(pcurr, &envr);
            G.g_cnxsave.cs_confovwr = ( (envr & INF_E2_ALLOWOVW) == 0);
            G.g_cnxsave.cs_mnuclick = ( (envr & INF_E2_MNUCLICK) != 0);
            menu_click(G.g_cnxsave.cs_mnuclick, 1); /* tell system */
            if (envr & INF_E2_IDTDATE)
                G.g_cnxsave.cs_datefmt = DATEFORM_IDT;
            else
                G.g_cnxsave.cs_datefmt = (envr & INF_E2_DAYMONTH) ? DATEFORM_DMY : DATEFORM_MDY;
            if (envr & INF_E2_IDTTIME)
                G.g_cnxsave.cs_timefmt = TIMEFORM_IDT;
            else
                G.g_cnxsave.cs_timefmt = (envr & INF_E2_24HCLOCK) ? TIMEFORM_24H : TIMEFORM_12H;
            sound(FALSE, !(envr & INF_E2_SOUND), 0);

            pcurr = scan_2(pcurr, &dummy);  /* skip video stuff */
            pcurr = scan_2(pcurr, &dummy);

            pcurr = scan_2(pcurr, &envr);
            if (envr & INF_E5_NOSORT)
                G.g_cnxsave.cs_sort = CS_NOSORT;
            break;
        }
    }

    for (pa = G.g_ahead; pa; pa = pa->a_next)
    {
        if (pa->a_flags & AF_ISDESK)
        {
            x = pa->a_xspot * G.g_icw;
            y = pa->a_yspot * G.g_ich + G.g_ydesk;
            snap_disk(x, y, &pa->a_xspot, &pa->a_yspot, 0, 0);
        }
    }

    /* set up outlines for dragging files displayed as icons */
    G.g_nmicon = 9;     /* number of points */
    memset(G.g_xyicon, 0, sizeof(G.g_xyicon));
    xcent = (G.g_wicon - G.g_iblist[0].ib_wicon) / 2;
    G.g_xyicon[0] = xcent;
    G.g_xyicon[2] = xcent;
    G.g_xyicon[3] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[5] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[7] = G.g_hicon;
    G.g_xyicon[8] = G.g_wicon;
    G.g_xyicon[9] = G.g_hicon;
    G.g_xyicon[10] = G.g_wicon;
    G.g_xyicon[11] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[12] = G.g_wicon-xcent;
    G.g_xyicon[13] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[14] = G.g_wicon-xcent;
    G.g_xyicon[16] = xcent;

    /* set up outlines for dragging files displayed as text */
    G.g_nmtext = 5;     /* number of points */
    memset(G.g_xytext, 0, sizeof(G.g_xytext));
    G.g_xytext[2] = gl_wchar * DRAG_BOX_WIDTH;
    G.g_xytext[4] = gl_wchar * DRAG_BOX_WIDTH;
    G.g_xytext[5] = gl_hchar;
    G.g_xytext[7] = gl_hchar;
}