Annotation of hatari/src/main.c, revision 1.1.1.9

1.1       root        1: /*
1.1.1.6   root        2:   Hatari - main.c
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      6: 
                      7:   Main initialization and event handling routines.
1.1       root        8: */
1.1.1.9 ! root        9: char Main_rcsid[] = "Hatari $Id: main.c,v 1.66 2004/12/09 21:06:37 thothy Exp $";
1.1       root       10: 
                     11: #include <time.h>
1.1.1.5   root       12: #include <unistd.h>
1.1       root       13: 
                     14: #include <SDL.h>
                     15: 
                     16: #include "main.h"
                     17: #include "configuration.h"
                     18: #include "dialog.h"
                     19: #include "audio.h"
                     20: #include "debug.h"
                     21: #include "joy.h"
                     22: #include "errlog.h"
                     23: #include "file.h"
                     24: #include "floppy.h"
                     25: #include "gemdos.h"
1.1.1.4   root       26: #include "hdc.h"
1.1       root       27: #include "ikbd.h"
                     28: #include "intercept.h"
1.1.1.5   root       29: #include "keymap.h"
1.1       root       30: #include "m68000.h"
                     31: #include "memorySnapShot.h"
                     32: #include "misc.h"
1.1.1.8   root       33: #include "midi.h"
1.1       root       34: #include "printer.h"
1.1.1.8   root       35: #include "reset.h"
1.1       root       36: #include "rs232.h"
                     37: #include "screen.h"
1.1.1.5   root       38: #include "sdlgui.h"
1.1       root       39: #include "shortcut.h"
                     40: #include "sound.h"
1.1.1.8   root       41: #include "stMemory.h"
1.1       root       42: #include "tos.h"
1.1.1.5   root       43: #include "vdi.h"
1.1       root       44: #include "video.h"
                     45: #include "ymFormat.h"
1.1.1.2   root       46: #include "debugui.h"
1.1       root       47: 
                     48: #include "uae-cpu/hatari-glue.h"
                     49: 
                     50: 
                     51: BOOL bQuitProgram=FALSE;                  /* Flag to quit program cleanly */
1.1.1.4   root       52: BOOL bEmulationActive=TRUE;               /* Run emulation when started */
1.1.1.2   root       53: BOOL bEnableDebug=FALSE;                  /* Enable debug UI? */
1.1.1.8   root       54: char szBootDiscImage[FILENAME_MAX];
                     55: char szWorkingDir[FILENAME_MAX];          /* Working directory */
1.1.1.9 ! root       56: BOOL bIgnoreNextMouseMotion = FALSE;      /* Next mouse motion will be ignored (needed after SDL_WarpMouse) */
1.1       root       57: 
                     58: 
                     59: /*-----------------------------------------------------------------------*/
                     60: /*
                     61:   Save/Restore snapshot of local variables('MemorySnapShot_Store' handles type)
                     62: */
                     63: void Main_MemorySnapShot_Capture(BOOL bSave)
                     64: {
                     65:   int nBytes;
                     66: 
                     67:   /* Save/Restore details */
                     68:   /* Only save/restore area of memory machine ie set to, eg 1Mb */
                     69:   if (bSave) {
1.1.1.7   root       70:     nBytes = STRamEnd;  /* was: STRamEnd_BusErr */
1.1       root       71:     MemorySnapShot_Store(&nBytes,sizeof(nBytes));
                     72:     MemorySnapShot_Store(STRam,nBytes);
                     73:   }
                     74:   else {
                     75:     MemorySnapShot_Store(&nBytes,sizeof(nBytes));
                     76:     MemorySnapShot_Store(STRam,nBytes);
                     77:   }
                     78:   /* And Cart/TOS/Hardware area */
                     79:   MemorySnapShot_Store(&STRam[0xE00000],0x200000);
                     80:   MemorySnapShot_Store(szBootDiscImage,sizeof(szBootDiscImage));
                     81:   MemorySnapShot_Store(szWorkingDir,sizeof(szWorkingDir));
                     82: }
                     83: 
                     84: 
                     85: /*-----------------------------------------------------------------------*/
                     86: /*
                     87:   Error handler
                     88: */
                     89: void Main_SysError(char *Error,char *Title)
                     90: {
1.1.1.2   root       91:   fprintf(stderr,"%s : %s\n",Title,Error);
1.1       root       92: }
                     93: 
1.1.1.2   root       94: 
1.1       root       95: /*-----------------------------------------------------------------------*/
                     96: /*
1.1.1.9 ! root       97:   Bring up a message dialog.
1.1       root       98: */
1.1.1.9 ! root       99: int Main_Message(char *pText, char *pCaption)
1.1       root      100: {
1.1.1.9 ! root      101:   /* Show message: */
        !           102:   fprintf(stderr,"%s: %s\n", pCaption, pText);
1.1       root      103: 
1.1.1.9 ! root      104:   return DlgAlert_Notice(pText);
1.1       root      105: }
                    106: 
1.1.1.7   root      107: 
1.1       root      108: /*-----------------------------------------------------------------------*/
                    109: /*
                    110:   Pause emulation, stop sound
                    111: */
                    112: void Main_PauseEmulation(void)
                    113: {
1.1.1.4   root      114:   if( bEmulationActive )
                    115:   {
1.1.1.6   root      116:     Audio_EnableAudio(FALSE);
1.1.1.4   root      117:     bEmulationActive = FALSE;
                    118:   }
1.1       root      119: }
                    120: 
1.1.1.2   root      121: /*-----------------------------------------------------------------------*/
1.1       root      122: /*
                    123:   Start emulation
                    124: */
                    125: void Main_UnPauseEmulation(void)
                    126: {
1.1.1.4   root      127:   if( !bEmulationActive )
                    128:   {
1.1.1.6   root      129:     Audio_EnableAudio(ConfigureParams.Sound.bEnableSound);
1.1.1.4   root      130:     Screen_SetFullUpdate();       /* Cause full screen update(to clear all) */
1.1       root      131: 
1.1.1.4   root      132:     bEmulationActive = TRUE;
                    133:   }
1.1       root      134: }
                    135: 
1.1.1.7   root      136: 
1.1       root      137: /* ----------------------------------------------------------------------- */
                    138: /*
1.1.1.9 ! root      139:   Set mouse pointer to new coordinates and set flag to ignore the mouse event
        !           140:   that is generated by SDL_WarpMouse().
        !           141: */
        !           142: void Main_WarpMouse(int x, int y)
        !           143: {
        !           144:   SDL_WarpMouse(x, y);                  /* Set mouse pointer to new position */
        !           145:   bIgnoreNextMouseMotion = TRUE;        /* Ignore mouse motion event from SDL_WarpMouse */
        !           146: }
        !           147: 
        !           148: 
        !           149: /* ----------------------------------------------------------------------- */
        !           150: /*
1.1.1.7   root      151:   Message handler
1.1       root      152:   Here we process the SDL events (keyboard, mouse, ...) and map it to
                    153:   Atari IKBD events.
                    154: */
1.1.1.8   root      155: void Main_EventHandler(void)
1.1       root      156: {
1.1.1.4   root      157:   SDL_Event event;
1.1       root      158: 
1.1.1.4   root      159:   if( SDL_PollEvent(&event) )
                    160:    switch( event.type )
1.1       root      161:    {
1.1.1.9 ! root      162: 
1.1       root      163:     case SDL_QUIT:
1.1.1.4   root      164:        bQuitProgram = TRUE;
1.1.1.8   root      165:        set_special(SPCFLAG_BRK);        /* Assure that CPU core shuts down */
1.1       root      166:        break;
1.1.1.9 ! root      167: 
1.1.1.4   root      168:     case SDL_MOUSEMOTION:               /* Read/Update internal mouse position */
1.1.1.9 ! root      169:        if (bIgnoreNextMouseMotion)
        !           170:        {
        !           171:          bIgnoreNextMouseMotion = FALSE;
        !           172:        }
        !           173:        else
        !           174:        {
        !           175:          KeyboardProcessor.Mouse.dx += event.motion.xrel;
        !           176:          KeyboardProcessor.Mouse.dy += event.motion.yrel;
        !           177:        }
1.1       root      178:        break;
1.1.1.9 ! root      179: 
1.1       root      180:     case SDL_MOUSEBUTTONDOWN:
                    181:        if( event.button.button==SDL_BUTTON_LEFT )
1.1.1.4   root      182:        {
                    183:          if(Keyboard.LButtonDblClk==0)
                    184:            Keyboard.bLButtonDown |= BUTTON_MOUSE;  /* Set button down flag */
                    185:        }
1.1       root      186:        else if( event.button.button==SDL_BUTTON_RIGHT )
1.1.1.4   root      187:          Keyboard.bRButtonDown |= BUTTON_MOUSE;
1.1       root      188:        else if( event.button.button==SDL_BUTTON_MIDDLE )
                    189:          Keyboard.LButtonDblClk = 1;    /* Start double-click sequence in emulation time */
                    190:        break;
1.1.1.9 ! root      191: 
1.1       root      192:     case SDL_MOUSEBUTTONUP:
                    193:        if( event.button.button==SDL_BUTTON_LEFT )
1.1.1.4   root      194:          Keyboard.bLButtonDown &= ~BUTTON_MOUSE;
1.1       root      195:        else if( event.button.button==SDL_BUTTON_RIGHT )
1.1.1.4   root      196:          Keyboard.bRButtonDown &= ~BUTTON_MOUSE;;
1.1       root      197:        break;
1.1.1.9 ! root      198: 
1.1.1.7   root      199:     case SDL_KEYDOWN:
                    200:        Keymap_KeyDown(&event.key.keysym);
1.1       root      201:        break;
1.1.1.9 ! root      202: 
1.1.1.7   root      203:     case SDL_KEYUP:
                    204:        Keymap_KeyUp(&event.key.keysym);
1.1       root      205:        break;
                    206:    }
                    207: }
                    208: 
                    209: 
1.1.1.2   root      210: /*-----------------------------------------------------------------------*/
1.1       root      211: /*
1.1.1.8   root      212:   Show supported options.
                    213: */
                    214: static void Main_ShowOptions(void)
                    215: {
                    216:   printf("Usage:\n hatari [options] [disk image name]\n"
                    217:          "Where options are:\n"
                    218:          "  --help or -h          Print this help text and exit.\n"
                    219:          "  --version or -v       Print version number and exit.\n"
                    220:          "  --mono or -m          Start in monochrome mode instead of color.\n"
1.1.1.9 ! root      221:          "  --fullscreen or -f    Start emulator in fullscreen mode.\n"
        !           222:          "  --window or -w        Start emulator in window mode.\n"
1.1.1.8   root      223:          "  --joystick or -j      Emulate a ST joystick with the cursor keys.\n"
                    224:          "  --nosound             Disable sound (faster!).\n"
                    225:          "  --printer             Enable printer support (experimental).\n"
                    226:          "  --midi <filename>     Enable midi support and write midi data to <filename>.\n"
                    227:          "  --rs232 <filename>    Use <filename> as the serial port device.\n"
                    228:          "  --frameskip           Skip every second frame (speeds up emulation!).\n"
                    229:          "  --debug or -D         Allow debug interface.\n"
                    230:          "  --harddrive <dir>     Emulate an ST harddrive\n"
                    231:          "     or -d <dir>         (<dir> = root directory).\n"
                    232:          "  --hdimage <imagename> Emulate an ST harddrive with an image.\n"
                    233:          "  --tos <file>          Use TOS image <file>.\n"
1.1.1.9 ! root      234:          "  --cartridge <file>    Use ROM cartridge image <file>.\n"
1.1.1.8   root      235:          "  --cpulevel <x>        Set the CPU type (x => 680x0) (TOS 2.06 only!).\n"
                    236:          "  --compatible          Use a more compatible (but slower) 68000 CPU mode.\n"
                    237:          "  --blitter             Enable blitter emulation (unstable!)\n"
                    238:          "  --vdi                 Use extended VDI resolution\n"
                    239:          "  --memsize <x>         Memory size in MB (x = 0, 1, 2 or 4; 0 for 512kB)\n"
                    240:          "  --configfile <file>   Use <file> instead of ~/.hatari.cfg as configuration\n"
                    241:          "     or -c <file>        file.\n"
                    242:          "  --slowfdc             Slow down FDC emulation (very experimental!).\n"
                    243:         );
                    244: }
                    245: 
                    246: 
                    247: /*-----------------------------------------------------------------------*/
                    248: /*
1.1       root      249:   Check for any passed parameters
                    250: */
1.1.1.8   root      251: static void Main_ReadParameters(int argc, char *argv[])
1.1       root      252: {
1.1.1.4   root      253:   int i;
1.1       root      254: 
1.1.1.4   root      255:   /* Scan for any which we can use */
                    256:   for(i=1; i<argc; i++)
1.1       root      257:   {
1.1.1.4   root      258:     if (strlen(argv[i])>0)
1.1       root      259:     {
1.1.1.4   root      260:       if (!strcmp(argv[i],"--help") || !strcmp(argv[i],"-h"))
1.1       root      261:       {
1.1.1.8   root      262:         Main_ShowOptions();
1.1.1.4   root      263:         exit(0);
1.1       root      264:       }
                    265:       else if (!strcmp(argv[i],"--version") || !strcmp(argv[i],"-v"))
                    266:       {
1.1.1.4   root      267:         printf("This is %s.\n", PROG_NAME);
                    268:         printf("This program is free software licensed under the GNU GPL.\n");
                    269:         exit(0);
1.1       root      270:       }
1.1.1.2   root      271:       else if (!strcmp(argv[i],"--mono") || !strcmp(argv[i],"-m"))
1.1       root      272:       {
1.1.1.4   root      273:         bUseHighRes=TRUE;
                    274:         ConfigureParams.Screen.bUseHighRes=TRUE;
                    275:         STRes=PrevSTRes=ST_HIGH_RES;
1.1       root      276:       }
                    277:       else if (!strcmp(argv[i],"--fullscreen") || !strcmp(argv[i],"-f"))
                    278:       {
1.1.1.9 ! root      279:         ConfigureParams.Screen.bFullScreen = TRUE;
        !           280:       }
        !           281:       else if (!strcmp(argv[i],"--window") || !strcmp(argv[i],"-w"))
        !           282:       {
        !           283:         ConfigureParams.Screen.bFullScreen = FALSE;
1.1       root      284:       }
                    285:       else if (!strcmp(argv[i],"--joystick") || !strcmp(argv[i],"-j"))
                    286:       {
1.1.1.4   root      287:         ConfigureParams.Joysticks.Joy[1].bCursorEmulation=TRUE;
1.1       root      288:       }
1.1.1.4   root      289:       else if ( !strcmp(argv[i],"--nosound") )
1.1.1.2   root      290:       {
1.1.1.4   root      291:         ConfigureParams.Sound.bEnableSound = FALSE;
1.1.1.2   root      292:       }
                    293:       else if ( !strcmp(argv[i],"--frameskip") )
                    294:       {
1.1.1.7   root      295:         ConfigureParams.Screen.bFrameSkip = TRUE;
1.1.1.2   root      296:       }
1.1.1.8   root      297:       else if ( !strcmp(argv[i],"--printer") )
                    298:       {
                    299:         /* FIXME: add more commandline configuration for printing */
                    300:         ConfigureParams.Printer.bEnablePrinting = TRUE;
                    301:       }
                    302:       else if (!strcmp(argv[i], "--midi"))
                    303:       {
                    304:         if(i+1 >= argc)
                    305:           fprintf(stderr, "Missing argument for --midi\n");
                    306:         else
                    307:         {
                    308:           if (strlen(argv[i+1]) <= sizeof(ConfigureParams.Midi.szMidiOutFileName))
                    309:           {
                    310:             ConfigureParams.Midi.bEnableMidi = TRUE;
                    311:             strcpy(ConfigureParams.Midi.szMidiOutFileName, argv[i+1]);
                    312:           }
                    313:           else fprintf(stderr, "Midi file name too long!\n");
                    314:           i += 1;
                    315:         }
                    316:       }
                    317:       else if (!strcmp(argv[i], "--rs232"))
                    318:       {
                    319:         if(i+1 >= argc)
                    320:           fprintf(stderr, "Missing argument for --rs232\n");
                    321:         else
                    322:         {
                    323:           if (strlen(argv[i+1]) <= sizeof(ConfigureParams.RS232.szOutFileName))
                    324:           {
                    325:             ConfigureParams.RS232.bEnableRS232 = TRUE;
                    326:             strcpy(ConfigureParams.RS232.szOutFileName, argv[i+1]);
                    327:             strcpy(ConfigureParams.RS232.szInFileName, argv[i+1]);
                    328:           }
                    329:           else fprintf(stderr, "RS232 file name too long!\n");
                    330:           i += 1;
                    331:         }
                    332:       }
1.1.1.4   root      333:       else if (!strcmp(argv[i],"--debug") || !strcmp(argv[i],"-D"))
1.1.1.2   root      334:       {
1.1.1.4   root      335:         bEnableDebug=TRUE;
1.1.1.2   root      336:       }
1.1.1.4   root      337:       else if (!strcmp(argv[i],"--hdimage"))
1.1.1.3   root      338:       {
1.1.1.8   root      339:         if(i+1 >= argc)
1.1.1.7   root      340:           fprintf(stderr, "Missing argument for --hdimage\n");
                    341:         else
1.1.1.4   root      342:         {
1.1.1.8   root      343:           if (strlen(argv[i+1]) <= sizeof(ConfigureParams.HardDisc.szHardDiscImage))
1.1.1.4   root      344:           {
1.1.1.7   root      345:             ConfigureParams.HardDisc.bUseHardDiscImage = TRUE;
1.1.1.4   root      346:             strcpy(ConfigureParams.HardDisc.szHardDiscImage, argv[i+1]);
                    347:           }
1.1.1.7   root      348:           else fprintf(stderr, "HD image file name too long!\n");
                    349:           i += 1;
1.1.1.4   root      350:         }
                    351:       }
                    352:       else if (!strcmp(argv[i],"--harddrive") || !strcmp(argv[i],"-d"))
                    353:       {
1.1.1.8   root      354:         if(i+1 >= argc)
1.1.1.7   root      355:           fprintf(stderr, "Missing argument for --harddrive\n");
                    356:         else
1.1.1.4   root      357:         {
1.1.1.7   root      358:           if(strlen(argv[i+1]) <= MAX_PATH )
                    359:           {
                    360:             ConfigureParams.HardDisc.bUseHardDiscDirectories = TRUE;
                    361:             ConfigureParams.HardDisc.bBootFromHardDisc = TRUE;
                    362:             strcpy(ConfigureParams.HardDisc.szHardDiscDirectories[0], argv[i+1]);
                    363:           }
                    364:           else fprintf(stderr, "HD directory name too long!\n");
1.1.1.4   root      365:           i += 1;
                    366:         }
1.1.1.3   root      367:       }
                    368:       else if (!strcmp(argv[i],"--tos"))
                    369:       {
1.1.1.4   root      370:         if(i+1>=argc)
                    371:           fprintf(stderr,"Missing argument for --tos.\n");
1.1.1.3   root      372:         else
1.1.1.9 ! root      373:           strncpy(ConfigureParams.Rom.szTosImageFileName, argv[++i], sizeof(ConfigureParams.Rom.szTosImageFileName));
        !           374:       }
        !           375:       else if (!strcmp(argv[i],"--cartridge"))
        !           376:       {
        !           377:         if(i+1>=argc)
        !           378:           fprintf(stderr,"Missing argument for --cartridge.\n");
        !           379:         else
        !           380:           strncpy(ConfigureParams.Rom.szCartridgeImageFileName, argv[++i], sizeof(ConfigureParams.Rom.szCartridgeImageFileName));
1.1.1.3   root      381:       }
                    382:       else if (!strcmp(argv[i],"--cpulevel"))
                    383:       {
1.1.1.4   root      384:         if(i+1>=argc)
                    385:           fprintf(stderr,"Missing argument for --cpulevel.\n");
                    386:          else
                    387:           cpu_level = atoi(argv[++i]);
                    388:         if(cpu_level<0 || cpu_level>4)
                    389:           cpu_level = 0;
1.1.1.5   root      390:         ConfigureParams.System.nCpuLevel = cpu_level;
1.1.1.3   root      391:       }
                    392:       else if (!strcmp(argv[i],"--compatible") || !strcmp(argv[i],"-d"))
                    393:       {
1.1.1.4   root      394:         cpu_compatible = TRUE;
1.1.1.5   root      395:         ConfigureParams.System.bCompatibleCpu = TRUE;
                    396:       }
                    397:       else if (!strcmp(argv[i],"--blitter"))
                    398:       {
                    399:         bEnableBlitter = TRUE;
                    400:         ConfigureParams.System.bBlitter = TRUE;
                    401:       }
1.1.1.7   root      402:       else if (!strcmp(argv[i], "--vdi"))
1.1.1.5   root      403:       {
1.1.1.9 ! root      404:         bUseVDIRes = ConfigureParams.Screen.bUseExtVdiResolutions = TRUE;
1.1.1.3   root      405:       }
1.1.1.7   root      406:       else if (!strcmp(argv[i], "--memsize"))
                    407:       {
                    408:         int memorysize = MEMORY_SIZE_1Mb;
                    409:         if(i+1 >= argc)
                    410:           fprintf(stderr,"Missing argument for --memsize.\n");
                    411:         else
                    412:           memorysize = atoi(argv[++i]);
                    413:         if(memorysize == 0)
                    414:           ConfigureParams.Memory.nMemorySize = MEMORY_SIZE_512Kb;
                    415:         else if(memorysize == 2)
                    416:           ConfigureParams.Memory.nMemorySize = MEMORY_SIZE_2Mb;
                    417:         else if(memorysize == 4)
                    418:           ConfigureParams.Memory.nMemorySize = MEMORY_SIZE_4Mb;
                    419:         else  /* Use 1MB as default */
                    420:           ConfigureParams.Memory.nMemorySize = MEMORY_SIZE_1Mb;
                    421:       }
1.1.1.8   root      422:       else if (!strcmp(argv[i],"--configfile") || !strcmp(argv[i],"-c"))
                    423:       {
                    424:         if (i+1 >= argc)
                    425:           fprintf(stderr, "Missing argument for --configfile\n");
                    426:         else
                    427:         {
                    428:           if (strlen(argv[i+1]) <= sizeof(sConfigFileName))
                    429:           {
                    430:             strcpy(sConfigFileName, argv[i+1]);
                    431:             Configuration_Load();
                    432:           }
                    433:           else
                    434:             fprintf(stderr, "Config file name too long!\n");
                    435:           i += 1;
                    436:         }
                    437:       }
                    438:       else if (!strcmp(argv[i], "--slowfdc"))
                    439:       {
                    440:         ConfigureParams.System.bSlowFDC = TRUE;
                    441:       }
1.1       root      442:       else
                    443:       {
1.1.1.4   root      444:         /* Possible passed disc image filename, ie starts with character other than '-' */
1.1.1.8   root      445:         if (argv[i][0] != '-' && strlen(argv[i]) < sizeof(szBootDiscImage)
                    446:             && File_Exists(argv[i]))
                    447:         {
                    448:           strcpy(szBootDiscImage, argv[i]);
                    449:           File_MakeAbsoluteName(szBootDiscImage);
                    450:         }
1.1.1.3   root      451:         else
1.1.1.8   root      452:           fprintf(stderr,"Illegal parameter: %s\n", argv[i]);
1.1       root      453:       }
                    454:     }
                    455:   }
                    456: }
                    457: 
1.1.1.2   root      458: 
                    459: /*-----------------------------------------------------------------------*/
1.1       root      460: /*
                    461:   Initialise emulation
                    462: */
1.1.1.8   root      463: static void Main_Init(void)
1.1       root      464: {
1.1.1.7   root      465:   /* Init SDL's video subsystem. Note: Audio and joystick subsystems
1.1.1.5   root      466:      will be initialized later (failures there are not fatal). */
1.1.1.7   root      467:   if(SDL_Init(SDL_INIT_VIDEO) < 0)
1.1.1.4   root      468:   {
1.1.1.2   root      469:     fprintf(stderr, "Could not initialize the SDL library:\n %s\n", SDL_GetError() );
                    470:     exit(-1);
1.1.1.4   root      471:   }
1.1.1.2   root      472: 
1.1       root      473:   Misc_SeedRandom(1043618);
1.1.1.4   root      474:   SDLGui_Init();
1.1       root      475:   Printer_Init();
                    476:   RS232_Init();
1.1.1.8   root      477:   Midi_Init();
1.1       root      478:   Screen_Init();
                    479:   Floppy_Init();
1.1.1.6   root      480:   Init680x0();                  /* Init CPU emulation */
                    481:   Audio_Init();
1.1.1.7   root      482:   Keymap_Init();
                    483: 
                    484:   /* Init HD emulation */
                    485:   if(ConfigureParams.HardDisc.bUseHardDiscImage)
                    486:   {
                    487:     char *szHardDiscImage = ConfigureParams.HardDisc.szHardDiscImage;
                    488:     if( HDC_Init(szHardDiscImage) )
                    489:       printf("Hard drive image %s mounted.\n", szHardDiscImage);
                    490:     else
                    491:       printf("Couldn't open HD file: %s, or no partitions\n", szHardDiscImage);
                    492:   }
                    493:   GemDOS_Init();
                    494:   if(ConfigureParams.HardDisc.bUseHardDiscDirectories)
                    495:   {
                    496:     GemDOS_InitDrives();
                    497:   }
1.1.1.6   root      498: 
                    499:   if(Reset_Cold())              /* Reset all systems, load TOS image */
                    500:   {
                    501:     /* If loading of the TOS failed, we bring up the GUI to let the
                    502:      * user choose another TOS ROM file. */
                    503:     Dialog_DoProperty();
                    504:   }
                    505:   if(!bTosImageLoaded || bQuitProgram)
                    506:   {
                    507:     fprintf(stderr, "Failed to load TOS image!\n");
                    508:     SDL_Quit();
                    509:     exit(-2);
                    510:   }
                    511: 
1.1       root      512:   Intercept_Init();
                    513:   Joy_Init();
                    514:   Sound_Init();
                    515: 
1.1.1.2   root      516:   /* Check passed disc image parameter, boot directly into emulator */
1.1.1.6   root      517:   if(strlen(szBootDiscImage) > 0)
                    518:   {
1.1       root      519:     Floppy_InsertDiscIntoDrive(0,szBootDiscImage);
                    520:   }
                    521: }
                    522: 
1.1.1.6   root      523: 
1.1.1.2   root      524: /*-----------------------------------------------------------------------*/
1.1       root      525: /*
                    526:   Un-Initialise emulation
                    527: */
1.1.1.8   root      528: static void Main_UnInit(void)
1.1       root      529: {
                    530:   Screen_ReturnFromFullScreen();
                    531:   Floppy_UnInit();
1.1.1.4   root      532:   HDC_UnInit();
1.1.1.8   root      533:   Midi_UnInit();
1.1       root      534:   RS232_UnInit();
                    535:   Printer_UnInit();
                    536:   Intercept_UnInit();
1.1.1.4   root      537:   GemDOS_UnInitDrives();
1.1.1.5   root      538:   if(Sound_AreWeRecording())
                    539:     Sound_EndRecording();
1.1.1.2   root      540:   Audio_UnInit();
1.1       root      541:   YMFormat_FreeRecording();
1.1.1.4   root      542:   SDLGui_UnInit();
1.1       root      543:   Screen_UnInit();
1.1.1.8   root      544:   Exit680x0();
1.1       root      545: 
1.1.1.2   root      546:   /* SDL uninit: */
                    547:   SDL_Quit();
1.1       root      548: }
                    549: 
1.1.1.6   root      550: 
1.1.1.2   root      551: /*-----------------------------------------------------------------------*/
1.1       root      552: /*
                    553:   Main
                    554: */
                    555: int main(int argc, char *argv[])
                    556: {
                    557: 
                    558:   /* Generate random seed */
                    559:   srand( time(NULL) );
                    560: 
1.1.1.8   root      561:   /* Get working directory */
                    562:   getcwd(szWorkingDir, FILENAME_MAX);
                    563: 
                    564:   szBootDiscImage[0] = 0;
1.1       root      565: 
                    566:   /* Create debug files */
                    567:   Debug_OpenFiles();
                    568:   ErrLog_OpenFile();
                    569: 
1.1.1.2   root      570:   /* Set default configuration values: */
                    571:   Configuration_SetDefault();
                    572: 
1.1.1.7   root      573:   /* Now load the values from the configuration file */
                    574:   Configuration_Load();
                    575: 
1.1       root      576:   /* Check for any passed parameters */
1.1.1.2   root      577:   Main_ReadParameters(argc, argv);
1.1       root      578: 
                    579:   /* Init emulator system */
                    580:   Main_Init();
                    581: 
1.1.1.2   root      582:   /* Switch immediately to fullscreen if user wants to */
1.1.1.9 ! root      583:   if (ConfigureParams.Screen.bFullScreen)
1.1.1.2   root      584:     Screen_EnterFullScreen();
                    585: 
1.1.1.4   root      586:   /* Run emulation */
1.1       root      587:   Main_UnPauseEmulation();
1.1.1.4   root      588:   Start680x0();                 /* Start emulation */
1.1       root      589: 
                    590:   /* Un-init emulation system */
1.1.1.7   root      591:   Main_UnInit();
1.1       root      592: 
                    593:   /* Close debug files */
                    594:   ErrLog_CloseFile();
                    595:   Debug_CloseFiles();
                    596: 
                    597:   return(0);
                    598: }
1.1.1.3   root      599: 
                    600: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.