/* FINAL DRAGON LOAD GAME MODULE 4/25/05
JESSE HARRIS
SETS PLAYERS STATE TO LAST SAVED CONFIGURATION
*/
#include <mygba.h>
#include <hel.h>
#include "stuff.hpp"

extern player watashi;

//for quick reference
/*struct player {
  short x;
  short y;
  short map;
  short textnum;
  short musicnum;
  short dir;
  short hp;
  short maxhp;
  short mp;
  short maxmp;
  short exp;
  short level;
};*/

int myLoadGame()
{
    u32 success = 0;  //success Boolean
    int tempint;  //temp variable
    player anata;  //anata is the Japanese word for you
    //Try to load data
    success = success & ham_LoadIntFromRAM("X", &tempint);
    anata.x = (short)tempint;
    success = success & ham_LoadIntFromRAM("Y", &tempint);
    anata.y = (short)tempint;
    success = success & ham_LoadIntFromRAM("Map", &tempint);
    anata.map = (short)tempint;
    success = success & ham_LoadIntFromRAM("Textnum", &tempint);
    anata.textnum = (short)tempint;
    anata.musicnum = 0;
    success = success & ham_LoadIntFromRAM("Dir", &tempint);
    anata.dir = (short)tempint;
    success = success & ham_LoadIntFromRAM("Hp", &tempint);
    anata.hp = (short)tempint;
    success = success & ham_LoadIntFromRAM("Maxhp", &tempint);
    anata.maxhp = (short)tempint;
    success = success & ham_LoadIntFromRAM("Mp", &tempint);
    anata.mp = (short)tempint;
    success = success & ham_LoadIntFromRAM("Maxmp", &tempint);
    anata.maxmp = (short)tempint;
    success = success & ham_LoadIntFromRAM("Exp", &tempint);
    anata.exp = (u32)tempint;
    success = success & ham_LoadIntFromRAM("Level", &tempint);
    anata.level = (short)tempint;
    success = success & ham_LoadIntFromRAM("Playerstate", &tempint);
    anata.playerstate = (u32)tempint;
    //check for success
    if (success != 0xffffffff)
    {
        watashi = anata;
        return 1;
    }
    else
    {
        return 0;
    }
}


/* END OF FILE */
