Ejemplo n.º 1
0
// Initialize Sound Card ------------------------------------------------------
static  int     Sound_Init_SoundCard (void)
{
  int            i;
  AUDIOINFO      Audio_Infos;

  ConsolePrintf (Msg_Get (MSG_Sound_Init_Soundcard), Sound.SampleRate);
  ConsolePrint ("\n");

  Audio_Infos.nDeviceId = Sound.SoundCard;
  Audio_Infos.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; // FIXME: Stereo ?
  Audio_Infos.nSampleRate = audio_sample_rate = Sound.SampleRate;

  if (AOpenAudio(&Audio_Infos) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Audio));
     return (MEKA_ERR_FAIL);
     }
  // FIXME: original sound engine was trying different sample rate on failure

  // Unused
  // Maybe it was intended to check out number of channels there ?
  // AGetAudioCaps (Audio_Infos.nDeviceId, &Audio_Caps);

  // Open voices
  if (AOpenVoices(Sound.Voices_Max) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Voices));
     return (MEKA_ERR_FAIL);
     }

  ASetAudioMixerValue (AUDIO_MIXER_MASTER_VOLUME, 256);

  // Allocate voices and waveforms
  Sound.Voices = Memory_Alloc (sizeof (t_voice) * Sound.Voices_Max);
  for (i = 0; i < Sound.Voices_Max; i++)
     {
     if (ACreateAudioVoice(&Sound.Voices[i].hVoice) != AUDIO_ERROR_NONE)
        {
        Quit_Msg (Msg_Get (MSG_Sound_Init_Error_Voice_N), i);
        return (MEKA_ERR_FAIL);
        }
     ASetVoicePanning(Sound.Voices[i].hVoice, 128); // Center voice
     Sound.Voices[i].lpWave  = NULL;
     Sound.Voices[i].playing = FALSE;
     }

  // FIXME: is this needed ?
  AUpdateAudio ();

  // FIXME: is this needed ?
  // Check frame sample rate
  audio_sample_rate = nominal_sample_rate = Audio_Infos.nSampleRate;

  return (MEKA_ERR_OK);
}
Ejemplo n.º 2
0
void	Blitters_Init()
{
    ConsolePrint(Msg_Get(MSG_Blitters_Loading));

    Blitters.list = NULL;
    Blitters.current = NULL;

    // Open and read file
    t_tfile * tf;
    if ((tf = tfile_read (Blitters.filename)) == NULL)
        Quit_Msg("%s", meka_strerror());
    ConsolePrint("\n");

    // Parse each line
    int line_cnt = 0;
    for (t_list* lines = tf->data_lines; lines; lines = lines->next)
    {
        const char* line = (char*)lines->elem;
        line_cnt += 1;

		int i, j;
        char s1 [256], s2 [256];
        for (i = 0, j = 0; line [i] != 0 && line [i] != ';'; i ++)
            if ((line [0] == '[') || (line [i] != ' ' && line [i] != '\t'))
                s2 [j ++] = line [i];
        s2 [j] = 0;
        if (StrIsNull (s2))
            continue;

        strcpy(s1, s2);
        StrLower(s1);

        switch (Blitters_Parse_Line (s1, s2))
        {
        case MEKA_ERR_UNKNOWN:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Unrecognized), line_cnt);
        case MEKA_ERR_MISSING:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Missing), line_cnt);
        case MEKA_ERR_VALUE_INCORRECT:  tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Incorrect_Value), line_cnt);
        }
    }

    // Free file data
    tfile_free(tf);

    // Requires at least 1 blitter
    if (Blitters.count == 0)
        Quit_Msg("%s", Msg_Get(MSG_Blitters_Error_Not_Enough));

    // Current blitter
    if (Blitters.blitter_configuration_name != NULL)
        Blitters.current = Blitters_FindBlitterByName(Blitters.blitter_configuration_name);
    if (Blitters.current == NULL)
        Blitters.current = (t_blitter*)Blitters.list->elem; // first
}
Ejemplo n.º 3
0
// Initialize SEAL library ----------------------------------------------------
int     Sound_Init_SEAL (void)
{
    if (AInitialize() != AUDIO_ERROR_NONE)
    {
        Quit_Msg (Msg_Get (MSG_Sound_Init_Error_SEAL));
        return (MEKA_ERR_FAIL);
    }
    return (MEKA_ERR_OK);
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Memory_Alloc (int size)
// Allocate memory using malloc(), abort if unavailable
//-----------------------------------------------------------------------------
void    *Memory_Alloc (int size)
{
 byte   *p;

 if ((p = malloc (size)) == NULL)
    {
    meka_errno = MEKA_ERR_MEMORY;
    Quit_Msg (meka_strerror());
    }
 return (p);
}
Ejemplo n.º 5
0
// Send a message to the user and/or debugging message
void            Msg(int attr, const char *format, ...)
{
    va_list     params;
    char *      src;
    char *      p;

    va_start (params, format);
    vsprintf (Msg_Buf, format, params);
    va_end   (params);

    #ifdef MSG_USER
        if (attr == MSG_USER) // Allegro constant!!
            Quit_Msg("Fatal: avoid using MSG_USER, it is an Allegro constant!");
    #endif

    // Handle Bock-is-lazy-to-type-a-full-constant mode
    if (attr == 0)
        attr = MSGT_USER;

    // Split message by line (\n) and send it to the various places
    p = NULL;
    do
    {
        src = p ? p : Msg_Buf;
        p = strpbrk (src, "\n\r");
        if (p)
        {
            *p = EOSTR;
            p += 1;
        }

        // Set status line
        if (attr & MSGT_STATUS_BAR)
        {
            strcpy(g_gui_status.message, src);
            g_gui_status.timeleft = 120;
        }

        // Add to user text box
        if (attr & MSGT_USER_BOX)
            TB_Message_Print(src);

#ifdef WIN32
		if (attr & MSGT_ATTR_DEBUG)
		{
			OutputDebugString(src);
			OutputDebugString("\n");
		}
#endif
    }
    while (p != NULL);
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------
// DB_Load (const char *filename)
// Initialize and load given Meka DB file
//-----------------------------------------------------------------------------
void            DB_Load (const char *filename)
{
    t_tfile *   tf;
    t_list *    lines;
    char *      line;
    int         line_cnt;

    ConsolePrint (Msg_Get (MSG_DB_Loading));

    // Open and read file
    tf = tfile_read (filename);
    if (tf == NULL)
    {
        ConsolePrintf ("%s\n", meka_strerror());
        return;
    }

    // Ok
    ConsolePrint ("\n");

    // Parse each line
    line_cnt = 0;
    for (lines = tf->data_lines; lines; lines = lines->next)
    {
        line_cnt += 1;
        line = lines->elem;

        // Strip comments
        // FIXME
        // Trim spaces?
        // FIXME
        // Skip empty lines
        //if (line[0] == EOSTR)
        //    continue;

        if (DB_Load_Line (line) == 0)
        {
            tfile_free (tf); 
            Quit_Msg (Msg_Get (MSG_DB_SyntaxError), line_cnt);
        }
    }

    // Free file data
    tfile_free(tf);

    // FIXME - Uncomment for counting progress of DB transition
    //ConsolePrintf ("ENTRIES NEW = %d, OLD = %d\n", DB.entries_counter_format_new, DB.entries_counter_format_old);
    //Quit();
}
Ejemplo n.º 7
0
void        OSD_Timer_Initialize (void)
{
    // Select timer to use
    if (OSD_X86CPU_Has_RDTSC ())
    {
        DWORD   a, b;
        s64     time_start, time_end;

        timer_func_get_cycles_current = OSD_Timer_GetCyclesCurrent_RDTSC;

        a = uclock();
        // Wait some time to let everything stabilize
        do
        {
            b = uclock();
            // get the starting cycle count
            time_start = OSD_Timer_GetCyclesCurrent_RDTSC();
        } while (b - a < UCLOCKS_PER_SEC/2);

        // Now wait for 1/2 second
        do
        {
            a = uclock();
            // get the ending cycle count
            time_end = OSD_Timer_GetCyclesCurrent_RDTSC();
        } while (a - b < UCLOCKS_PER_SEC/2);

        // Compute timer_cycles_per_second
        timer_cycles_per_second = (time_end - time_start) * 2;
    }
    else
    {
        Quit_Msg ("Error initializating timer!");
    }
    /*
    else
    {
        timer_func_get_cycles_current = OSD_Timer_GetCyclesCurrent_DOS_uclock;
        timer_cycles_per_second = UCLOCKS_PER_SEC;
    }
    */
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Data_Init (void)
// Load graphics, font & BIOS data from datafile
// Some data processing is done here
//-----------------------------------------------------------------------------
void            Data_Init(void)
{
    DATAFILE *  df;

    // Print loading message to console
    ConsolePrint (Msg_Get (MSG_Datafile_Loading));

    // Open and load datafile
    assert(g_Datafile == NULL);
    df = g_Datafile = load_datafile (g_Env.Paths.DataFile);
    if (g_Datafile == NULL)
        Quit_Msg (Msg_Get (MSG_Failed));
    ConsolePrint ("\n");

    // Make a copy of ALL bitmaps in their original RGBA 32-bits version
    // This is required to handle successives calls to fixup_datafile()
    g_DatafileBitmapCopy32 = NULL;

    // Assign pointers to data
	Data_UpdateNamedPointers();

    // BIOS
    // Note: BIOSes are unpacked in a bigger memory area, so they can be mapped
    // without having to handle memory accesses outside their allocated range.
    // The same trick is done on loading < 48 KB Sega 8-bits ROM images.
    BIOS_ROM            = Data_CopyInBiggerArea (df [DATA_ROM_SMS].dat,     0x2000, 0xC000);
    BIOS_ROM_Jap        = Data_CopyInBiggerArea (df [DATA_ROM_SMS_J].dat,   0x2000, 0xC000);
    BIOS_ROM_Coleco     = Data_CopyInBiggerArea (df [DATA_ROM_COLECO].dat,  0x2000, 0x2000);
    BIOS_ROM_SF7000     = Data_CopyInBiggerArea (df [DATA_ROM_SF7000].dat,  0x2000, 0x4000);

    // Patch SF-7000 BIOS (FIXME: move to sf7000.c)
    // Bios_ROM_SF7000[0x112] = Bios_ROM_SF7000[0x113] = Bios_ROM_SF7000[0x114] = 0x00;
    // Bios_ROM_SF7000[0x183] = Bios_ROM_SF7000[0x184] = Bios_ROM_SF7000[0x185] = 0x00;
    BIOS_ROM_SF7000[0x1D8] = BIOS_ROM_SF7000[0x1D9] = BIOS_ROM_SF7000[0x1DA] = 0x00;

    // Fonts
    Fonts_AddFont(F_LARGE,     df[DATA_FONT_0].dat);  // Font Large Sized
    Fonts_AddFont(F_MIDDLE,    df[DATA_FONT_1].dat);  // Font Middle Sized
    Fonts_AddFont(F_SMALL,     df[DATA_FONT_2].dat);  // Font Small Sized
}
Ejemplo n.º 9
0
void    drv_set (int num)
{
    if (num < 0 || num >= DRV_MAX)
    {
        Quit_Msg("%s", Msg_Get(MSG_Driver_Unknown));
    }
    else
    {
        g_driver = &drivers[num];
        if (opt.GUI_Inited == TRUE)
        {
            int palette_max = 2;
            switch (g_driver->vdp)
            {
                case VDP_SMSGG:     palette_max = 2;  break;
                case VDP_TMS9918:   palette_max = 15; break;
            }
            TileViewer_Configure_PaletteMax(palette_max);
            PaletteViewer_SetPaletteSize(&PaletteViewer, g_driver->colors);
        }
    }
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
// Inputs_Check_GUI ()
// Check for GUI related inputs
//-----------------------------------------------------------------------------
// Note: 'sk1100_pressed' tells if SK-1100 emulation has taken a key yet.
// Specific checks are being done here to avoid collision.
//-----------------------------------------------------------------------------
void        Inputs_Check_GUI (bool sk1100_pressed)
{
    // Update INPUTS configuration in priority, since it eat some keys
    Inputs_CFG_Update(&Inputs_CFG);
    //Inputs_CFG_Map_Change_Update();
    //if (Inputs_CFG.active)
    //    Inputs_CFG.Box->update ();

    switch (key_shifts & (KB_CTRL_FLAG | KB_ALT_FLAG | KB_SHIFT_FLAG))
    {
    case 0: // No modifiers
        {
            // State save/load
            if (Inputs_KeyPressed (KEY_F5, FALSE))
                Save_Game ();
            if (Inputs_KeyPressed (KEY_F7, FALSE))
                Load_Game ();

            // State change slot
            /*
            if (cur_drv->id != DRV_COLECO)
                if (!gui.box_z_ordered[0]->focus_inputs_exclusive) // check note in inputs_u.c::Inputs_Emulation_Update()
                {
                    if (Inputs_KeyPressed (KEY_0, FALSE))  Save_Set_Slot (0);
                    if (Inputs_KeyPressed (KEY_1, FALSE))  Save_Set_Slot (1);
                    if (Inputs_KeyPressed (KEY_2, FALSE))  Save_Set_Slot (2);
                    if (Inputs_KeyPressed (KEY_3, FALSE))  Save_Set_Slot (3);
                    if (Inputs_KeyPressed (KEY_4, FALSE))  Save_Set_Slot (4);
                    if (Inputs_KeyPressed (KEY_5, FALSE))  Save_Set_Slot (5);
                    if (Inputs_KeyPressed (KEY_6, FALSE))  Save_Set_Slot (6);
                    if (Inputs_KeyPressed (KEY_7, FALSE))  Save_Set_Slot (7);
                    if (Inputs_KeyPressed (KEY_8, FALSE))  Save_Set_Slot (8);
                    if (Inputs_KeyPressed (KEY_9, FALSE))  Save_Set_Slot (9);
                }
            */
            if (Inputs_KeyPressed_Repeat (KEY_F6, FALSE, 30, 3)) 
                Save_Set_Slot (opt.State_Current - 1);
            if (Inputs_KeyPressed_Repeat (KEY_F8, FALSE, 30, 3)) 
                Save_Set_Slot (opt.State_Current + 1);

            // Blitters switch
            if (Inputs_KeyPressed (KEY_F1, FALSE))    
                Blitters_SwitchNext();

            // Speed & Frame skip 
            if (Inputs_KeyPressed (KEY_F2, FALSE))
                Frame_Skipper_Switch ();
            if (Inputs_KeyPressed (KEY_F3, FALSE))
                Frame_Skipper_Configure (-1);
            if (Inputs_KeyPressed (KEY_F4, FALSE))
                Frame_Skipper_Configure (1);

            // Input peripheral
            if (Inputs_KeyPressed (KEY_F9, FALSE))
                Inputs_Peripheral_Next (PLAYER_1);

            // Switch mode (Fullscreen <-> GUI)
            if (Inputs_KeyPressed (Inputs.Cabinet_Mode ? KEY_F10 : KEY_ESC, FALSE))
                Action_Switch_Mode ();

            // Sprites Refresh switch
            if (Inputs_KeyPressed (KEY_F11, FALSE))
                Action_Switch_Layer_Sprites ();

            // Hard Pause
            if (Inputs_KeyPressed (KEY_F12, FALSE))
                Machine_Pause_Need_To = TRUE;
        }
        break;
    case KB_CTRL_FLAG:
        {
            // Easter egg: Tetris
            if (!sk1100_pressed && Inputs_KeyPressed (KEY_T, FALSE))
                Tetris_Start ();
            // Nintendon't - now removed because it is too violent
            #ifdef ARCH_DOS
                if (!sk1100_pressed && Inputs_KeyPressed (KEY_N, FALSE))     
                    Quit_Msg ("Nintendont.");
            #endif

            // Hard Pause
            if (Inputs_KeyPressed (KEY_F12, FALSE) || (!sk1100_pressed && Inputs_KeyPressed (KEY_P, FALSE)))
                Machine_Pause_Need_To = TRUE;
            // Hard Reset
            if (!sk1100_pressed && Inputs_KeyPressed (KEY_BACKSPACE, TRUE)) // Note: eat backspace to avoid triggering software reset as well
                Machine_Reset ();

            // CTRL-TAB cycle thru boxes with TAB_STOP flag
            if (Inputs_KeyPressed(KEY_TAB, FALSE))
            {
                int n;

                // Remove keypress
                // FIXME-KEYPRESS
                t_list *keypresses;
                for (keypresses = Inputs.KeyPressedQueue; keypresses != NULL; )
                {
                    t_key_press *keypress = keypresses->elem;
                    keypresses = keypresses->next;
                    if (keypress->scancode == KEY_TAB)
                        list_remove(&Inputs.KeyPressedQueue, keypress);
                }

                // Cycle focus
                for (n = gui.boxes_count - 1; n >= 0; n--)
                {
                    t_gui_box *b = gui.boxes_z_ordered[n];
                    if ((b->flags & GUI_BOX_FLAGS_TAB_STOP) && (b->flags & GUI_BOX_FLAGS_ACTIVE))
                    {
                        gui_box_set_focus(b);
                        break;
                    }
                }
            }

        }
        break;
   case KB_ALT_FLAG:
       {
           // SK-1100 Keyboard switch
           if (Inputs_KeyPressed (KEY_F9, FALSE))        
               Keyboard_Switch ();
           // Background Refresh switch
           if (Inputs_KeyPressed (KEY_F11, FALSE)) 
               Action_Switch_Layer_Background ();
           // Next frame (pause hack)
           if (Inputs_KeyPressed (KEY_F12, FALSE))
               Machine_Pause_Need_To = (machine & MACHINE_PAUSED) ? 2 : 1;

           if (!sk1100_pressed)
           {
               // FPS Counter switch
               if (Inputs_KeyPressed (KEY_F, FALSE))         
                   Frame_Skipper_Switch_FPS_Counter ();
               // Applets hotkeys
               if (Inputs_KeyPressed (KEY_L, FALSE))         FB_Switch ();
               if (Inputs_KeyPressed (KEY_O, FALSE))         Options_Switch ();
               if (Inputs_KeyPressed (KEY_M, FALSE))         TB_Message_Switch ();
               if (Inputs_KeyPressed (KEY_P, FALSE))         PaletteViewer_Switch();
               if (Inputs_KeyPressed (KEY_T, FALSE))         TileViewer_Switch ();
               if (Inputs_KeyPressed (KEY_I, FALSE))         TechInfo_Switch ();
               // Quit emulator
               if (Inputs_KeyPressed (KEY_X, FALSE))         
                   opt.Force_Quit = TRUE;
               // Hard Reset
               if (Inputs_KeyPressed (KEY_BACKSPACE, TRUE))  // Note: eat backspace to avoid triggering software reset as well
                   Machine_Reset ();

               // GUI fullscreen/windowed
                if (Inputs_KeyPressed (KEY_ENTER, FALSE))
                {
                    if (Meka_State == MEKA_STATE_FULLSCREEN)
                    {
                        t_video_driver *driver = VideoDriver_FindByDriverId(Blitters.current->driver);
                        if (driver && driver->drv_id_switch_fs_win)
                        {
                            // FIXME: Put that properly in blitter interface
                            // FIXME: Not saved anywhere... better than nothing anyway.
                            Blitters.current->driver = driver->drv_id_switch_fs_win;
                            Video_Setup_State();
                        }
                    }
                    else if (Meka_State == MEKA_STATE_GUI)
                    {
                        t_video_driver *driver = VideoDriver_FindByDriverId(g_Configuration.video_mode_gui_driver);
                        if (driver && driver->drv_id_switch_fs_win)
                        {
                            g_Configuration.video_mode_gui_driver = driver->drv_id_switch_fs_win;
                            Video_GUI_ChangeVideoMode(g_Configuration.video_mode_gui_res_x, g_Configuration.video_mode_gui_res_y, g_Configuration.video_mode_gui_depth);
                        }
                    }
                    return;
                }

           }
       }
       break;
    }

    // Quit emulator
    if (key [Inputs.Cabinet_Mode ? KEY_ESC : KEY_F10]) 
        opt.Force_Quit = TRUE;

    // Debugger switch
    #ifdef MEKA_Z80_DEBUGGER
        // Disabled when SK-1100 is emulated because of collision in usage of ScrollLock key
        // Actually on SC-3000 it is hardwired to NMI
        if (!Inputs.Keyboard_Enabled && Inputs_KeyPressed (KEY_SCRLOCK, TRUE))
        //if (!sk1100_pressed && Inputs_KeyPressed (KEY_SCRLOCK, TRUE))
            Debugger_Switch ();
    #endif

    // Screen capture
    if (Inputs_KeyPressed (KEY_PRTSCR, FALSE))
        Capture_Request();

    // SF-7000 Disk 21 Bomber Raid
    // if (Test_Key(KEY_W))
    //     PSG.Registers[6] = PSG.Registers[6] ^ 0x04;

    // Wonder Boy III, Current Song
    //if (key[KEY_J])
    //   Msg (0, "RAM[0xFF9] = %02X", RAM[0xFF9]);

    // Old video modes debugging
    // if (Test_Key(KEY_J)) BACK_AREA -= 0x100;
    // if (Test_Key(KEY_K)) BACK_AREA += 0x100;
    // if (Test_Key(KEY_U)) BACK_AREA -= 0x1;
    // if (Test_Key(KEY_I)) BACK_AREA += 0x1;
    // SG-1000 stuff
    // if (Test_Key(KEY_U)) SG_BACK_TILE -= 0x100;
    // if (Test_Key(KEY_I)) SG_BACK_TILE += 0x100;
    // if (Test_Key(KEY_O)) SG_BACK_TILE -= 0x2000;
}
Ejemplo n.º 11
0
void            Load_Inputs_Src_List (void)
{
    int             i;
    char            w[256];
    t_input_src *   input_src = NULL;

    t_tfile *       tf;
    t_list *        lines;
    int             line_cnt;

    // Open and read file
    ConsolePrint (Msg_Get (MSG_Inputs_Src_Loading));
    tf = tfile_read (Inputs.FileName);
    if (tf == NULL)
        Quit_Msg (meka_strerror());
    ConsolePrint ("\n");

    // Parse each line
    line_cnt = 0;
    for (lines = tf->data_lines; lines; lines = lines->next)
    {
        char *line;

        line_cnt += 1;
        line = lines->elem;

        if (StrNull(line))
            continue;

        if (line[0] == '[' && line[strlen(line) - 1] == ']')
        {
            input_src = Inputs_Sources_Add (StrNDup (line + 1, strlen(line) - 2));
            // ConsolePrintf ("new source --> %s <--\n", CurSrc->Name);
            continue;
        }

        strlwr(line);
        if (!parse_getword(w, sizeof(w), &line, "=", ';', PARSE_FLAGS_NONE))
            continue;

        for (i = 0; Inputs_Src_List_KeyWords[i]; i++)
            if (strcmp(w, Inputs_Src_List_KeyWords[i]) == 0)
            {
                // FIXME: this is ugly
                if (input_src == NULL && strcmp (w, "joy_driver") != 0
                    && strcmp (w, "mouse_speed_x") != 0
                    && strcmp (w, "mouse_speed_y") != 0
                    && strcmp (w, "cabinet_mode")  != 0)
                {
                    tfile_free(tf);
                    Quit_Msg (Msg_Get (MSG_Inputs_Src_Missing), line_cnt);
                }

                parse_skip_spaces(&line);
                if (!parse_getword(w, sizeof(w), &line, "", ';', PARSE_FLAGS_NONE))
                {
                    tfile_free(tf);
                    Quit_Msg (Msg_Get (MSG_Inputs_Src_Equal), line_cnt);
                }

                switch (Load_Inputs_Src_Parse_Var(i, w, input_src))
                {
                case MEKA_ERR_SYNTAX:
                    tfile_free(tf);
                    Quit_Msg (Msg_Get (MSG_Inputs_Src_Syntax_Param), line_cnt);
                case MEKA_ERR_INCOHERENT :
                    tfile_free(tf);
                    Quit_Msg (Msg_Get (MSG_Inputs_Src_Inconsistency), line_cnt);
                    break;
                    // FIXME: EMPTY is not handled there
                }
                break;
            }
            if (!Inputs_Src_List_KeyWords [i])
            {
                tfile_free(tf);
                Quit_Msg (Msg_Get (MSG_Inputs_Src_Unrecognized), line_cnt, w);
            }
    }

    // Free file data
    tfile_free(tf);

    // Verify that we have enough inputs sources
    if (Inputs.Sources_Max == 0)
        Quit_Msg (Msg_Get (MSG_Inputs_Src_Not_Enough));
}
Ejemplo n.º 12
0
// Load messages from MEKA.MSG file (path given in structure)
// Return a MEKA_ERR_xxx code
int             Messages_Init (void)
{
    t_tfile *   tf;
    t_list *    lines;
    int         line_cnt;
    char *      p;

    Messages.Lang_Cur = Messages.Lang_Default = NULL;
    Messages.Langs = NULL;

    // Note: this is one of the few cases were the string has to be hardcoded.
    // That is of course because the messages/localization system is not
    // initialized as of yet..
    ConsolePrint("Loading MEKA.MSG (messages).. ");

    // Open and read file --------------------------------------------------------
    tf = tfile_read (Messages.FileName);
    if (tf == NULL)
        Quit_Msg("MISSING!\nTry re-installing your version of Meka.");
    ConsolePrint("\n");

    // Parse each line -----------------------------------------------------------
    line_cnt = 0;
    for (lines = tf->data_lines; lines; lines = lines->next)
    {
        char *line = (char*)lines->elem;
        line_cnt += 1;

        // Cut Comments
        p = strchr (line, ';');
        if (p != NULL)
            *p = EOSTR;

        StrTrim (line);
        if (StrIsNull (line))
            continue;

        // Parse Line and handle errors
        // ConsolePrintf ("%d: %s--\n", line_cnt, line);
        switch (Messages_Init_Parse_Line(line))
        {
        case MEKA_ERR_MISSING:    
            ConsolePrintf ("On line %d: No language defined for storing message !", line_cnt);
            tfile_free(tf);
            Quit();
            break;
        case MEKA_ERR_UNKNOWN:    
            ConsolePrintf ("On line %d: Unknown message \"%s\", skipping it.\n", line_cnt, line);
            // tfile_free(tf);
            // Quit();
            break;
        case MEKA_ERR_SYNTAX:     
            ConsolePrintf ("On line %d: Syntax error.\n%s\n", line_cnt, line);
            tfile_free(tf);
            Quit();
            break;
        }
    }

    // Free file data
    tfile_free(tf);

    // Verify language completion
    {
        if (Messages.Lang_Cur == NULL)
            Quit_Msg("No language defined. Try re-installing your version of Meka.");
        Messages.Lang_Cur = Messages.Lang_Default;
        for (t_list* langs = Messages.Langs; langs; langs = langs->next)
        {
            t_lang* lang = (t_lang*)langs->elem;
            if (Lang_Post_Check (lang) != MEKA_ERR_OK)
                if (lang == Messages.Lang_Default)
                    Quit_Msg("This is the default language, so we need to abort.");
        }
    }

    // Ok
    return (MEKA_ERR_OK);
}
Ejemplo n.º 13
0
// Load media/ROM from given filename.
// If user_verbose if false, avoid printing stuff to the message box
// Note: path to ROM filename must be set in 'g_env.Paths.MediaImageFile' before calling this
bool    Load_ROM(t_load_mode load_mode, bool user_verbose)
{
    // Set file global flag
    Loading_UserVerbose = user_verbose;

    switch (load_mode)
    {
    case LOAD_MODE_COMMANDLINE:
        if (user_verbose)
            ConsolePrint(Msg_Get(MSG_LoadROM_Loading));
        break;
    case LOAD_MODE_GUI:
        // FIXME: do not save Backed Memory in non-verbose mode
        // This mode is only used by the file browser. This way we avoid loading
        // and saving all battery backed memory when doing a "Load All".
        // Of course, this is a little hack but it's better this way.
        if (user_verbose)
            BMemory_Save();
        break;
    }

    if (Load_ROM_Main() != MEKA_ERR_OK)
    {
        switch (load_mode)
        {
        case LOAD_MODE_COMMANDLINE:
            Quit_Msg("%s\n\"%s\"\n", meka_strerror(), g_env.Paths.MediaImageFile);
            return false;
        case LOAD_MODE_GUI:
            Msg(MSGT_USER, Msg_Get(MSG_Error_Base), meka_strerror());
            return false;
        }
    }

    // If we are already in SF-7000 mode, do not reset (allows hot switching disks)
    const bool reset = (g_driver->id != DRV_SF7000);

    // Miscellaneous stuff (including reset)
    Load_ROM_Misc(reset);

    if (load_mode == LOAD_MODE_COMMANDLINE)
    {
        if (user_verbose)
            ConsolePrint("\n");
        if (opt.State_Load != -1)
        {
            opt.State_Current = opt.State_Load; // Note: we're not calling the function to avoid displaying the 'slot change' message
            opt.State_Load = -1;
            SaveState_Load();
        }
    }

    // Verbose
    if (user_verbose)
    {
        // Display success message
        char filename[FILENAME_LEN];
        StrPath_RemoveDirectory(filename, g_env.Paths.MediaImageFile);
        if (g_driver->id != DRV_SF7000)
            Msg(MSGT_USER, Msg_Get(MSG_LoadROM_Success), filename);
        else
            Msg(MSGT_USER, Msg_Get(MSG_LoadDisk_Success), filename);

        // Display data from DB
        if (DB.current_entry)
        {
            // Name
            Msg(MSGT_USER, "\"%s\"", DB_Entry_GetCurrentName (DB.current_entry));

            // Comment
            if (DB.current_entry->comments)
                Msg(MSGT_USER_LOG, Msg_Get(MSG_LoadROM_Comment), DB.current_entry->comments);

            // Show SMS-GG mode info
            if (DB.current_entry->flags & DB_FLAG_SMSGG_MODE)
            {
                if (DB.current_entry->comments)
                    // Append to comment message
                    Msg(MSGT_USER_LOG, "%s", Msg_Get(MSG_LoadROM_SMSGG_Mode_Comment));
                else // Print the comment marker before
                    Msg(MSGT_USER_LOG, Msg_Get(MSG_LoadROM_Comment), Msg_Get(MSG_LoadROM_SMSGG_Mode_Comment));
            }

            // Show BAD ROM warning
            if (DB.current_entry->flags & DB_FLAG_BAD)
            {
                Msg(MSGT_USER_LOG, "%s", Msg_Get(MSG_LoadROM_Warning));
                Msg(MSGT_USER_LOG, "%s", Msg_Get(MSG_LoadROM_Bad_Dump_Long));
                Msg(MSGT_STATUS_BAR, "%s", Msg_Get(MSG_LoadROM_Bad_Dump_Short));
            }

            // Show Product Number
            if (DB.current_entry->product_no && g_config.show_product_number)
                Msg(MSGT_USER_LOG, Msg_Get(MSG_LoadROM_Product_Num), DB.current_entry->product_no);
        }

        // Show SDSC Header
        if (user_verbose)
            SDSC_Read_and_Display();
    }

    // Automatically change input peripheral depending on MEKA.NAM entry
    // FIXME: we don't do it at all if !user_verbose, to save us from passing
    // the verbose flag all down to inputs peripherals changing functions.
    // Since the verbose flag is only cleared by the file browser "Load All"
    // functionality, it is ok to avoid changing inputs.
    if (user_verbose)
        Input_ROM_Change();

    return true;
}