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

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

unix.superglobalmegacorp.com

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