/* BWGameData */

#import "Variables.h"
#import "BWSideView.h"

@interface BWGameData : NSObject
{
	IBOutlet id objMain;
	IBOutlet id objSideView;
	
	IBOutlet id matrixAttack;
	
    IBOutlet id matrixMagic;
    IBOutlet id matrixMagicNames;
	IBOutlet id matrixMagicEffects;
	
	IBOutlet id matrixLevels;
    IBOutlet id matrixLevelsNames;
	
	IBOutlet id fieldText;
	IBOutlet id browserText;
	IBOutlet id matrixText;
	
	IBOutlet id menuWorld;
	IBOutlet id menuEnemy;
	IBOutlet id fieldHP;
	IBOutlet id menuExpCode;
	IBOutlet id textExperience;
	IBOutlet id menuDamageCode;
	IBOutlet id menuItemType;
	IBOutlet id matrixEnemyPalette;
	IBOutlet id boxPalette;
	
	IBOutlet id checkSteals;
	IBOutlet id checkNeedsFire;
	IBOutlet id checkFlyingBlade;
	IBOutlet id checkImmuneThunder;
	IBOutlet id checkRegenerates;
	
	IBOutlet id imageEnemy;
	
	IBOutlet id tableExperience;
	IBOutlet id tableDamage;
	IBOutlet id tableHits;
	
	IBOutlet id matrixBeginMagic;
	IBOutlet id matrixBeginItems;
	IBOutlet id matrixBeginTechs;
	IBOutlet id fieldBeginLives;
	IBOutlet id sliderBeginCrystals;
	IBOutlet id sliderBeginHC;
	IBOutlet id sliderBeginMC;
	IBOutlet id textBeginHC;
	IBOutlet id textBeginMC;
	
	IBOutlet id fieldMiscLife;
	IBOutlet id fieldMiscItem;
	IBOutlet id checkMiscBeep;
	IBOutlet id textMiscBeep;
	IBOutlet id fieldMiscBeep;
	
	unsigned char attack[9];
	unsigned char magic[64];
	unsigned char magicNames[8][8];
	unsigned char magicEffects[8];
	
	NSMutableArray *textStrings;
	NSMutableArray *tiles;
	
	unsigned char enemyHP[6][0x24];
	
	unsigned char enemyAttributes1[6][0x24];
	// xx.. ....	Palette Code (0-3)
	// ..x. ....	No Damage from Sword (needs Fire)
	// ...x ....	Steals Experience Points
	// .... xxxx	Experience Code (0-F)
	
	unsigned char enemyAttributes2[6][0x24];
	// xx.. ....	Item Type (0 = gives no items, 1 = minor item, 2 = major item)
	// ..x. ....	Immune to Flying Blade and Fire
	// ...x ....	?
	// .... xxxx	Damage Code
	
	unsigned char enemyAttributes3[6][0x24];
	// x... ....	Immune to Thunder Spell
	// .x.. ....	Regenerates
	// ..x. ....	?
	// ...x ....	Not hittable with sword
	// .... xxxx	?
	
	unsigned char hit[9];
	unsigned short exp[16];
	unsigned char damage[8][8];
	
	//unsigned char enemyAttributes[8][4][0x24];
	
	BOOL displayHex;
	
	NSMutableArray *tilesEnemies;
	NSMutableArray *tilesBosses;
	
	NSMutableData *rom;
	unsigned const char *ptr;
	
	//NSFormatter *numberFormat;
	NSRect boxPaletteBasePosition;
}

- (void)open:(NSMutableData *)theRom;
- (void)save;

- (void)loadAttack;
- (IBAction)changeAttack:(id)sender;
- (void)saveAttack;

- (void)loadMagic;
- (IBAction)changeMagic:(id)sender;
- (IBAction)changeMagicName:(id)sender;
- (IBAction)changeMagicEffect:(id)sender;
- (void)saveMagic;

- (void)setLevels;
- (void)setLevelsNames;
- (void)saveLevels;

- (void)loadTiles;
- (void)loadTilesEnemies;

- (void)setTextStrings;
- (IBAction)showText:(id)sender;
- (IBAction)confirmText:(id)sender;
- (void)saveText;

- (void)loadExperience;
- (void)loadDamage;
- (void)loadEnemyAttributes;

- (IBAction)changeWorld:(id)sender;
- (IBAction)changeEnemy:(id)sender;
- (void)changeHitTable;
- (IBAction)changeHP:(id)sender;
- (IBAction)changeExpCode:(id)sender;
- (IBAction)changeDamageCode:(id)sender;
- (IBAction)changeItemType:(id)sender;
- (IBAction)changeEnemyPalette:(id)sender;
- (IBAction)changeSteals:(id)sender;
- (IBAction)changeNeedsFire:(id)sender;
- (IBAction)changeFlyingBlade:(id)sender;
- (IBAction)changeImmuneThunder:(id)sender;
- (IBAction)changeRegenerates:(id)sender;
- (void)saveEnemies;

- (void)setBeginning;
- (void)saveBeginning;

- (void)setMisc;
- (IBAction)actionBeeping:(id)sender;
- (void)saveMisc;

- (unsigned char)toASCII:(unsigned char)ctc;
- (unsigned char)fromASCII:(unsigned char)ctc;

@end
