Hiya!
Working on adding the loading and saving into Gigas, finally figured out how to save and load which i was chuffed about, but now i notice that anything which was in array seems to be jumbled, as in it was written back to front.
for example, the map was stored like this
map[x][y] (x and y are both the same number, always)
but when i load it from the routine, i have to switch the x and y around as it seems to of loaded it backwards or something, this isnt a problem as both X and Y are always the same so i can just flip it around like so...
That all works, because like i said - both y and x go upto the same value.
However, im having problems loading arrays where the two values dont match, for example,
The problem here is, the array i wrote into the file was a short[100][16]. but because each [] doesn't store the same amount, i cannot just reverse it to put everything back in its correct place, any suggestions on how i can do this?
Working on adding the loading and saving into Gigas, finally figured out how to save and load which i was chuffed about, but now i notice that anything which was in array seems to be jumbled, as in it was written back to front.
for example, the map was stored like this
map[x][y] (x and y are both the same number, always)
but when i load it from the routine, i have to switch the x and y around as it seems to of loaded it backwards or something, this isnt a problem as both X and Y are always the same so i can just flip it around like so...
//Array to hold the current map layer in
unsigned short temp_map[map_settings.MAPW][map_settings.MAPH];
//i think maps have to be even shaped for this to work
//Load the map from the SMC
char filename[8];
int i;
for (i = 0; i < LAYERS; i++ ) {
sprintf((char*)filename, "M%dL%d.DAT", map_number, i);
GpFileOpen(filename, OPEN_R, &h_file );
GpFileRead(h_file, temp_map, sizeof(temp_map),NULL);
GpFileClose( h_file );
int x,y;
for(x = 0; x < map_settings.MAPW; x++)
{
for(y = 0; y < map_settings.MAPH; y++)
{
map[x][y] = temp_map[y][x];
}
}
}
That all works, because like i said - both y and x go upto the same value.
However, im having problems loading arrays where the two values dont match, for example,
//Now load the entitys
//Emulate the .DAT file for entitys
short temp_entitys[100][16]; //was 100 16
//Load the entity information from SMC into that dat file
sprintf((char*)filename, "M%E.DAT", map_number);
GpFileOpen(filename, OPEN_R, &h_file );
GpFileRead(h_file, temp_entitys, sizeof(temp_entitys),NULL);
GpFileClose( h_file );
//Apply the settings to the entitys
for(i = 0; i < (ENTITY_COUNT - 1); i++)
{
//Load the info
ENTITYS.x = temp_entitys[0];
ENTITYS.y = temp_entitys[1];
ENTITYS.enabled = temp_entitys[2];
ENTITYS.ai = temp_entitys[3];
ENTITYS.animation = temp_entitys[4];
ENTITYS.attack_animation = temp_entitys[5];
ENTITYS.state = temp_entitys[6];
ENTITYS.team = temp_entitys[7];
ENTITYS.STAT_BASE_HP = temp_entitys[8];
ENTITYS.STAT_BASE_MP = temp_entitys[9];
ENTITYS.STAT_BASE_ATK = temp_entitys[10];
ENTITYS.STAT_BASE_DEF = temp_entitys[11];
ENTITYS.STAT_EXP = temp_entitys[12];
ENTITYS.STAT_EXP_GRAPH = temp_entitys[13];
ENTITYS.speed = temp_entitys[14];
ENTITYS.STAT_BASE_ATTACK_RECHARGE = temp_entitys[15];
} //end of entity loop
The problem here is, the array i wrote into the file was a short[100][16]. but because each [] doesn't store the same amount, i cannot just reverse it to put everything back in its correct place, any suggestions on how i can do this?