/* BWOverWorld */

#import <Cocoa/Cocoa.h>

struct sArea
{
	unsigned char x;
	unsigned char y;
	unsigned char z;
	unsigned char w;
};

@interface BWOverWorld : NSMatrix
{
    IBOutlet id matrixTools;
	IBOutlet id scrollView;
	
	IBOutlet id fieldPosition;
	IBOutlet id fieldGroups;
	
	IBOutlet id menuRegion;
	IBOutlet id menuArea;
	
	IBOutlet id fieldMap;
	IBOutlet id fieldWorld;
	IBOutlet id fieldEnter;
	IBOutlet id matrixFlags;
	
	NSMutableData *rom;
	NSMutableArray *tiles;
	
	unsigned char currentTool;
	unsigned char mapScale;
	unsigned char cr;			// Current Region (WH, DM, EH, MI)
	
	int sel;		// Current selected area (-1 for Show All)
	
	struct sArea keyAreas[0x3F][4];
	
	unsigned short offSet;
	unsigned short offSetPalaces;
	unsigned short maxGroups;
	
	unsigned short g[4];		// Current number of groups for each region
	unsigned char b[4][1024];   // Current map data for each region
}

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

- (void)loadTiles;
- (NSImage *)tileWithOffset:(int)os palette:(struct sCol[4])pal;

- (void)loadRegions;
- (IBAction)changeRegion:(id)sender;
- (void)loadAreas;
- (IBAction)changeArea:(id)sender;

- (IBAction)changeTool:(id)sender;
- (IBAction)actionFields:(id)sender;
- (IBAction)actionFlags:(id)sender;

- (void)calc;
- (void)palacePointers;

- (IBAction)exportRegion:(id)sender;

@end
