Taseditor: changed fm3 format to version 3
This commit is contained in:
parent
80bd1aaf02
commit
5f8013e45e
|
@ -484,9 +484,12 @@ void BOOKMARKS::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool BOOKMARKS::load(EMUFILE *is, bool really_load)
|
||||
bool BOOKMARKS::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
if (!really_load)
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
branches.reset();
|
||||
|
@ -514,7 +517,7 @@ bool BOOKMARKS::load(EMUFILE *is, bool really_load)
|
|||
RedrawBookmarksCaption();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading bookmarks\n");
|
||||
FCEU_printf("Error loading Bookmarks\n");
|
||||
reset();
|
||||
branches.reset();
|
||||
return true;
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
void update();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void command(int command_id, int slot = -1);
|
||||
|
||||
|
|
|
@ -255,10 +255,13 @@ void GREENZONE::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool GREENZONE::load(EMUFILE *is, bool really_load)
|
||||
bool GREENZONE::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
free();
|
||||
if (!really_load)
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
playback.StartFromZero(); // reset Playback cursor to frame 0
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
void update();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void AdjustUp();
|
||||
void AdjustDown();
|
||||
|
|
|
@ -1013,23 +1013,27 @@ void HISTORY::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool HISTORY::load(EMUFILE *is, bool really_load)
|
||||
bool HISTORY::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
if (!really_load)
|
||||
int i = -1;
|
||||
SNAPSHOT snap;
|
||||
BOOKMARK bookm;
|
||||
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
int i = -1;
|
||||
SNAPSHOT snap;
|
||||
BOOKMARK bookm;
|
||||
// read "HISTORY" string
|
||||
char save_id[HISTORY_ID_LEN];
|
||||
if ((int)is->fread(save_id, HISTORY_ID_LEN) < HISTORY_ID_LEN) goto error;
|
||||
if (!strcmp(history_skipsave_id, save_id))
|
||||
{
|
||||
// string says to skip loading History
|
||||
FCEU_printf("No history in the file\n");
|
||||
FCEU_printf("No History in the file\n");
|
||||
reset();
|
||||
return false;
|
||||
}
|
||||
|
@ -1092,7 +1096,7 @@ bool HISTORY::load(EMUFILE *is, bool really_load)
|
|||
RedrawHistoryList();
|
||||
return false;
|
||||
error:
|
||||
FCEU_printf("Error loading history\n");
|
||||
FCEU_printf("Error loading History\n");
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
void HistorySizeChanged();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
|
|
@ -82,9 +82,12 @@ void MARKERS_MANAGER::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool MARKERS_MANAGER::load(EMUFILE *is, bool really_load)
|
||||
bool MARKERS_MANAGER::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
if (!really_load)
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
return false;
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
void update();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
int GetMarkersSize();
|
||||
bool SetMarkersSize(int new_size);
|
||||
|
|
|
@ -841,7 +841,7 @@ void PIANO_ROLL::save(EMUFILE *os, bool really_save)
|
|||
{
|
||||
if (really_save)
|
||||
{
|
||||
update();
|
||||
UpdateItemCount();
|
||||
// write "PIANO_ROLL" string
|
||||
os->fwrite(piano_roll_save_id, PIANO_ROLL_ID_LEN);
|
||||
// write current top item
|
||||
|
@ -854,11 +854,14 @@ void PIANO_ROLL::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool PIANO_ROLL::load(EMUFILE *is, bool really_load)
|
||||
bool PIANO_ROLL::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
reset();
|
||||
update();
|
||||
if (!really_load)
|
||||
UpdateItemCount();
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
// scroll to the beginning
|
||||
ListView_EnsureVisible(hwndList, 0, FALSE);
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
void update();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
|
||||
void RedrawList();
|
||||
void RedrawRow(int index);
|
||||
|
|
|
@ -267,9 +267,12 @@ void SELECTION::save(EMUFILE *os, bool really_save)
|
|||
}
|
||||
}
|
||||
// returns true if couldn't load
|
||||
bool SELECTION::load(EMUFILE *is, bool really_load)
|
||||
bool SELECTION::load(EMUFILE *is, unsigned int offset)
|
||||
{
|
||||
if (!really_load)
|
||||
if (offset)
|
||||
{
|
||||
if (is->fseek(offset, SEEK_SET)) goto error;
|
||||
} else
|
||||
{
|
||||
reset();
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void RedrawMarker();
|
||||
|
||||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
bool load(EMUFILE *is, unsigned int offset);
|
||||
void saveSelection(SelectionFrames& selection, EMUFILE *os);
|
||||
bool loadSelection(SelectionFrames& selection, EMUFILE *is);
|
||||
bool skiploadSelection(EMUFILE *is);
|
||||
|
|
|
@ -13,7 +13,7 @@ Project - Manager of working project
|
|||
* stores the info about current project filename and about having unsaved changes
|
||||
* implements saving and loading project files from filesystem
|
||||
* implements autosave function
|
||||
* stores resources: autosave period scale, default filename
|
||||
* stores resources: autosave period scale, default filename, fm3 format offsets
|
||||
------------------------------------------------------------------------------------ */
|
||||
|
||||
#include "taseditor_project.h"
|
||||
|
@ -128,23 +128,44 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
|
|||
currMovieData.loadFrameCount = currMovieData.records.size();
|
||||
currMovieData.emuVersion = FCEU_VERSION_NUMERIC;
|
||||
currMovieData.dump(ofs, save_binary);
|
||||
unsigned int taseditor_data_offset = ofs->ftell();
|
||||
// save header: fm3 version + saved_stuff
|
||||
write32le(PROJECT_FILE_CURRENT_VERSION, ofs);
|
||||
unsigned int saved_stuff = 0;
|
||||
if (save_markers) saved_stuff |= MARKERS_SAVED;
|
||||
if (save_bookmarks) saved_stuff |= BOOKMARKS_SAVED;
|
||||
if (save_greenzone) saved_stuff |= GREENZONE_SAVED;
|
||||
if (save_history) saved_stuff |= HISTORY_SAVED;
|
||||
if (save_piano_roll) saved_stuff |= PIANO_ROLL_SAVED;
|
||||
if (save_selection) saved_stuff |= SELECTION_SAVED;
|
||||
write32le(saved_stuff, ofs);
|
||||
unsigned int saved_stuff_map = 0;
|
||||
if (save_markers) saved_stuff_map |= MARKERS_SAVED;
|
||||
if (save_bookmarks) saved_stuff_map |= BOOKMARKS_SAVED;
|
||||
if (save_greenzone) saved_stuff_map |= GREENZONE_SAVED;
|
||||
if (save_history) saved_stuff_map |= HISTORY_SAVED;
|
||||
if (save_piano_roll) saved_stuff_map |= PIANO_ROLL_SAVED;
|
||||
if (save_selection) saved_stuff_map |= SELECTION_SAVED;
|
||||
write32le(saved_stuff_map, ofs);
|
||||
unsigned int number_of_pointers = DEFAULT_NUMBER_OF_POINTERS;
|
||||
write32le(saved_stuff_map, ofs);
|
||||
// write dummy zeros to the file, where the offsets will be
|
||||
for (unsigned int i = 0; i < number_of_pointers; ++i)
|
||||
write32le(0, ofs);
|
||||
// save specified modules
|
||||
unsigned int markers_offset = ofs->ftell();
|
||||
markers_manager.save(ofs, save_markers);
|
||||
unsigned int bookmarks_offset = ofs->ftell();
|
||||
bookmarks.save(ofs, save_bookmarks);
|
||||
unsigned int greenzone_offset = ofs->ftell();
|
||||
greenzone.save(ofs, save_greenzone);
|
||||
unsigned int history_offset = ofs->ftell();
|
||||
history.save(ofs, save_history);
|
||||
unsigned int piano_roll_offset = ofs->ftell();
|
||||
piano_roll.save(ofs, save_piano_roll);
|
||||
unsigned int selection_offset = ofs->ftell();
|
||||
selection.save(ofs, save_selection);
|
||||
// now write offsets (pointers)
|
||||
ofs->fseek(taseditor_data_offset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA, SEEK_SET);
|
||||
write32le(markers_offset, ofs);
|
||||
write32le(bookmarks_offset, ofs);
|
||||
write32le(greenzone_offset, ofs);
|
||||
write32le(history_offset, ofs);
|
||||
write32le(piano_roll_offset, ofs);
|
||||
write32le(selection_offset, ofs);
|
||||
// finish
|
||||
delete ofs;
|
||||
playback.updateProgressbar();
|
||||
// also set project.changed to false, unless it was SaveCompact
|
||||
|
@ -161,6 +182,7 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool
|
|||
bool TASEDITOR_PROJECT::load(const char* fullname)
|
||||
{
|
||||
bool load_all = true;
|
||||
unsigned int taseditor_data_offset = 0;
|
||||
EMUFILE_FILE ifs(fullname, "rb");
|
||||
|
||||
if (ifs.fail())
|
||||
|
@ -206,6 +228,7 @@ bool TASEDITOR_PROJECT::load(const char* fullname)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
taseditor_data_offset = ifs.ftell();
|
||||
// load fm3 version from header and check it
|
||||
unsigned int file_version;
|
||||
if (read32le(&file_version, &ifs))
|
||||
|
@ -253,16 +276,60 @@ bool TASEDITOR_PROJECT::load(const char* fullname)
|
|||
return false;
|
||||
}
|
||||
|
||||
unsigned int saved_stuff;
|
||||
unsigned int saved_stuff = 0;
|
||||
unsigned int number_of_pointers = 0;
|
||||
unsigned int data_offset = 0;
|
||||
unsigned int pointer_offset = taseditor_data_offset + PROJECT_FILE_OFFSET_OF_POINTERS_DATA;
|
||||
if (load_all)
|
||||
{
|
||||
read32le(&saved_stuff, &ifs);
|
||||
// load modules
|
||||
markers_manager.load(&ifs, load_all);
|
||||
bookmarks.load(&ifs, load_all);
|
||||
greenzone.load(&ifs, load_all);
|
||||
history.load(&ifs, load_all);
|
||||
piano_roll.load(&ifs, load_all);
|
||||
selection.load(&ifs, load_all);
|
||||
read32le(&number_of_pointers, &ifs);
|
||||
// load modules
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
markers_manager.load(&ifs, data_offset);
|
||||
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
bookmarks.load(&ifs, data_offset);
|
||||
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
greenzone.load(&ifs, data_offset);
|
||||
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
history.load(&ifs, data_offset);
|
||||
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
piano_roll.load(&ifs, data_offset);
|
||||
|
||||
if (number_of_pointers-- && !(ifs.fseek(pointer_offset, SEEK_SET)) && read32le(&data_offset, &ifs))
|
||||
pointer_offset += sizeof(unsigned int);
|
||||
else
|
||||
data_offset = 0;
|
||||
selection.load(&ifs, data_offset);
|
||||
} else
|
||||
{
|
||||
// reset modules
|
||||
markers_manager.load(&ifs, 0);
|
||||
bookmarks.load(&ifs, 0);
|
||||
greenzone.load(&ifs, 0);
|
||||
history.load(&ifs, 0);
|
||||
piano_roll.load(&ifs, 0);
|
||||
selection.load(&ifs, 0);
|
||||
}
|
||||
// reset other modules
|
||||
playback.reset();
|
||||
recorder.reset();
|
||||
|
|
|
@ -29,7 +29,13 @@
|
|||
#define PIANO_ROLL_SAVED 16
|
||||
#define SELECTION_SAVED 32
|
||||
|
||||
#define PROJECT_FILE_CURRENT_VERSION 2
|
||||
#define PROJECT_FILE_CURRENT_VERSION 3
|
||||
|
||||
#define PROJECT_FILE_OFFSET_OF_VERSION_NUMBER 0
|
||||
#define PROJECT_FILE_OFFSET_OF_SAVED_MODULES_MAP (PROJECT_FILE_OFFSET_OF_VERSION_NUMBER + 4)
|
||||
#define PROJECT_FILE_OFFSET_OF_NUMBER_OF_POINTERS (PROJECT_FILE_OFFSET_OF_SAVED_MODULES_MAP + 4)
|
||||
#define DEFAULT_NUMBER_OF_POINTERS 6
|
||||
#define PROJECT_FILE_OFFSET_OF_POINTERS_DATA (PROJECT_FILE_OFFSET_OF_NUMBER_OF_POINTERS + 4)
|
||||
|
||||
class TASEDITOR_PROJECT
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue