int spriteNum = tptEntry.getSprite(); int spriteDrawY = spriteLocs[j][1]; int spriteDrawX = spriteLocs[j][0]; EbMap.loadSpriteImage(hm, spriteNum, tptEntry.getDirection()); SpriteEditor.SpriteInfoBlock sib = SpriteEditor.sib[spriteNum];  if (((tileY + k) % (MapEditor.sectorHeight * 2)) > 0)
if (tptEntry.getEventFlag() == 0)
        private void drawMap(Graphics g, Graphics2D g2d)        {        	if (tiles == null)        		tiles = getTilesImage();        	g.drawImage(tiles, 1, 1, tiles.getWidth(this), tiles.getHeight(this), this);                        for (int k = 0; k < getPreviewHeight(); k++)        	{        		if ((((tileY + k) % (MapEditor.sectorHeight * 2)) == 0)        				|| (k == 0))        		{        			for (int i = 0; i < getPreviewWidth(); i++)                	{                		if ((((tileX + i) % MapEditor.sectorWidth) == 0)                				|| (i == 0))                		{                			if (! EbMap.isSpriteDataLoaded(                					(tileX + i) / MapEditor.sectorWidth,									(tileY + k) / (MapEditor.sectorHeight * 2)))                			{                				EbMap.loadSpriteData(rom,                						(tileX + i) / MapEditor.sectorWidth,										(tileY + k) / (MapEditor.sectorHeight * 2));                			}                			int spritesNum = EbMap.getSpritesNum(                					(tileX + i) / MapEditor.sectorWidth,									(tileY + k) / (MapEditor.sectorHeight * 2));                        	short[][] spriteLocs = EbMap.getSpriteLocs(                        			(tileX + i) / MapEditor.sectorWidth,									(tileY + k) / (MapEditor.sectorHeight * 2));                        	short[] spriteTpts = EbMap.getSpriteTpts(                        			(tileX + i) / MapEditor.sectorWidth, (tileY + k) / (MapEditor.sectorHeight * 2));                        	// this.spriteLocs = new int[spriteData[0]][5];                            for (int j = 0; j < spritesNum; j++)                            {                            	TPTEditor.TPTEntry tptEntry =                             		TPTEditor.tptEntries[spriteTpts[j]];                            	int spriteNum = tptEntry.getSprite();                            	int spriteDrawY = spriteLocs[j][1];                            	int spriteDrawX = spriteLocs[j][0];                            	EbMap.loadSpriteImage(hm,                            			spriteNum, tptEntry.getDirection());                            	SpriteEditor.SpriteInfoBlock sib =                            		SpriteEditor.sib[spriteNum];                            	                            	if (((tileY + k) % (MapEditor.sectorHeight * 2)) > 0)                            	{                            		spriteDrawY -= ((tileY + k) % (MapEditor.sectorHeight * 2)) *											MapEditor.tileHeight;                            	}                            	                            	if (((tileX + i) % MapEditor.sectorWidth) > 0)                            	{                            		spriteDrawX -= ((tileX + i) % MapEditor.sectorWidth)											* MapEditor.tileWidth;                            	}                            	                            	g.drawImage(                            			EbMap.getSpriteImage(                            					spriteNum,tptEntry.getDirection()),            							spriteDrawX + (i * MapEditor.tileWidth),    									spriteDrawY + (k * MapEditor.tileHeight),										this);                            	/*if (spriteBoxes)                            	{                            		g2d.setPaint(Color.red);                            		g2d.draw(new Rectangle2D.Double(                                			spriteDrawX + (i * MapEditor.tileWidth) - 1,											spriteDrawY + (k * MapEditor.tileHeight) - 1,											EbMap.getSpriteImage(													spriteNum,tptEntry.getDirection())																	.getWidth(this) + 1,											EbMap.getSpriteImage(													spriteNum,tptEntry.getDirection())																	.getHeight(this) + 1));                            	}*/                            }                		}                	}        		}        	}                        g2d.setPaint(Color.yellow);            g2d.draw(new Line2D.Double(            		(centerX * 8) - (tileX * MapEditor.tileWidth) - 10,            		(centerY * 8) - (tileY * MapEditor.tileHeight),					(centerX * 8) - (tileX * MapEditor.tileWidth) + 10,            		(centerY * 8) - (tileY * MapEditor.tileHeight)));            g2d.draw(new Line2D.Double(            		(centerX * 8) - (tileX * MapEditor.tileWidth),            		(centerY * 8) - (tileY * MapEditor.tileHeight) - 10,					(centerX * 8) - (tileX * MapEditor.tileWidth),            		(centerY * 8) - (tileY * MapEditor.tileHeight) + 10));        	g2d.draw(new Rectangle2D.Double(        			(centerX * 8) - 96 - (tileX * MapEditor.tileWidth),					(centerY * 8) - 80 - (tileY * MapEditor.tileHeight),					192, 160));        	        	int firstX = -1, firstY = -1;        	for (int i = 0; i < party.length; i++)        	{        		if (((JCheckBox) party[i][0]).isSelected())        		{         		            		SpriteEditor.SpriteInfoBlock sib =                		SpriteEditor.sib[SpriteCharacterTableEditor.getPlayableSPT(i,0)];            		            		int x = (Integer.parseInt(((JTextField) party[i][1]).getText()) * 8)            				- (tileX * MapEditor.tileWidth) - (sib.width * 4);            		int y = (Integer.parseInt(((JTextField) party[i][2]).getText()) * 8)            				- (tileY * MapEditor.tileHeight) - (sib.height * 6);            		if (((JCheckBox) party[i][0]).isSelected()            				&& (x >= 0) && (x <= previewWidth * MapEditor.tileWidth)    						&& (y >= 0) && (y <= previewHeight * MapEditor.tileHeight))            		{            			if ((firstX < 0) && (firstY < 0))            			{            				firstX = x;            				firstY = y;            			}            			EbMap.loadSpriteImage(hm, SpriteCharacterTableEditor.getPlayableSPT(i,0),4);            			g.drawImage(                    			EbMap.getSpriteImage(SpriteCharacterTableEditor.getPlayableSPT(i,0),4),x,y,this);            			g2d.setPaint(Color.red);                		g2d.draw(new Rectangle2D.Double(                    			x - 1, y - 1,								sib.width * 8 + 1,								sib.height * 8 + 1));            		}        		}        	}        	    		// Draw the photoman    		if (showPhotoman)    		{    			SpriteEditor.SpriteInfoBlock sib =            		SpriteEditor.sib[0x8f];        		int manX = (Integer.parseInt((landX).getText()) * 8)    				- (tileX * MapEditor.tileWidth) - (sib.width * 4);        		int manY = (Integer.parseInt(landY.getText()) * 8)    				- (tileY * MapEditor.tileHeight) - (sib.height * 6);        		if ((manX >= 0) && (manX <= previewWidth * MapEditor.tileWidth)    					&& (manY >= 0) && (manY <= previewHeight * MapEditor.tileHeight))        		{        			int direction;        			if ((manY > firstY) && (manX > firstX))        				if (manY - firstY > manX - firstX)        					direction = 0; // face up        				else        					direction = 6; // face left        			else if (manY > firstY)        				if (manY - firstY > firstX - manX)        					direction = 0; // face up         				else        					direction = 2; // face right        			else if (manX > firstX)        				if (firstY - manY > manX - firstX)        					direction = 4; // face down        				else        					direction = 6; //face left        			else        				if (firstY - manY > firstX - manX)        					direction = 4; //face down        				else        					direction = 2; //face right        			EbMap.loadSpriteImage(hm, 0x8f,direction);        			g.drawImage(        					EbMap.getSpriteImage(0x8f,direction),manX,manY,this);        			g2d.setPaint(Color.blue);        			g2d.draw(new Rectangle2D.Double(                			manX - 1,							manY - 1,							sib.width * 8 + 1,							sib.height * 8 + 1));        		}    		}        	        	for (int i = 0; i < extra.length; i++)        	{        		if (((JCheckBox) extra[i][0]).isSelected())        		{            		int spriteNum = ((JComboBox) extra[i][1]).getSelectedIndex();            		SpriteEditor.SpriteInfoBlock sib = SpriteEditor.sib[spriteNum];            		            		int x = (Integer.parseInt(((JTextField) extra[i][2]).getText()) * 8)            				- (tileX * MapEditor.tileWidth) - (sib.width * 4);            		int y = (Integer.parseInt(((JTextField) extra[i][3]).getText()) * 8)            				- (tileY * MapEditor.tileHeight) - (sib.height * 6);            		if ((x >= 0) && (x <= previewWidth * MapEditor.tileWidth)    						&& (y >= 0) && (y <= previewHeight * MapEditor.tileHeight))            		{            			EbMap.loadSpriteImage(hm, spriteNum,4);            			g.drawImage(                    			EbMap.getSpriteImage(spriteNum,4),x,y,this);            			g2d.setPaint(Color.green);            			g2d.draw(new Rectangle2D.Double(                    			x - 1, y - 1,								sib.width * 8 + 1,								sib.height * 8 + 1));            		}        		}        	}        }