HotspotEditor.Hotspot spot = HotspotEditor.getHotspot(i); int x1Tile = spot.getX1() * 8 / MapEditor.tileWidth, y1Tile = spot .getY1() * 8 / MapEditor.tileHeight, x2Tile = spot.getX2() * 8 / MapEditor.tileWidth, y2Tile = spot.getY2() * 8 / MapEditor.tileHeight; if ((i != movingHotspot) && (x1Tile <= tileX + screenWidth)
spot = HotspotEditor.getHotspot(i); int x1Tile = spot.getX1() * 8 / MapEditor.tileWidth, y1Tile = spot.getY1() * 8 / MapEditor.tileHeight, x2Tile = spot.getX2() * 8 / MapEditor.tileWidth, y2Tile = spot.getY2() * 8 / MapEditor.tileHeight; if ((x1Tile <= tileX + screenWidth)
		private void drawMap(Graphics g, Graphics2D g2d) {			visibleHotspots = new ArrayList();			int tileX = getMapTileX(), tileY = getMapTileY();			if (getModeProps()[1] == 1) {				g2d.setPaint(Color.black);				g2d.setFont(new Font("Arial", Font.PLAIN, 12));				for (int i = 0; i < maparray.length; i++) {					int[] row2draw = maparray[i];					for (int j = 0; j < row2draw.length; j++) {						g2d.drawString(addZeros(Integer								.toHexString(row2draw[j]), 2),								(j * MapEditor.tileWidth)										+ (MapEditor.tileWidth / 2),								(i * MapEditor.tileHeight)										+ (MapEditor.tileHeight / 2));						if (grid && (i % getModeProps()[10] == 0)								&& (j % getModeProps()[10] == 0))							g2d.draw(new Rectangle2D.Double(j									* MapEditor.tileWidth, i									* MapEditor.tileHeight,									MapEditor.tileWidth, MapEditor.tileHeight));					}				}			} else if (getModeProps()[1] == 2) {				int tile_set, tile, tile_pal, sectorY, sectorX;				for (int i = 0; i < maparray.length; i++) {					int[] row2draw = maparray[i];					sectorY = (i + tileY) / MapEditor.sectorHeight;					for (int j = 0; j < row2draw.length; j++) {						sectorX = (j + tileX) / MapEditor.sectorWidth;						if (!EbMap.isSectorDataLoaded(sectorX, sectorY))							EbMap.loadSectorData(hm.rom, sectorX, sectorY);						EbMap.Sector sector = EbMap.getSectorData(sectorX,								sectorY);						tile_set = EbMap.getDrawTileset(sector.getTileset());						tile = row2draw[j];						boolean changed = false;						if (mapChanges)							for (int k = 0; k < MapEventEditor									.countGroups(tile_set); k++) {								for (int l = 0; l < MapEventEditor										.countTileChanges(tile_set, k); l++)									if (tile == MapEventEditor.getTileChange(											tile_set, k, l).getTile1()) {										tile = MapEventEditor.getTileChange(												tile_set, k, l).getTile2();										changed = true;										break;									}								if (changed)									break;							}						tile_pal = TileEditor.tilesets[tile_set].getPaletteNum(								sector.getTileset(), sector.getPalette());						EbMap.loadTileImage(tile_set, tile, tile_pal);						if (!eventPalette)							g.drawImage(EbMap.getTileImage(tile_set, tile,									tile_pal), j * MapEditor.tileWidth, i									* MapEditor.tileHeight,									MapEditor.tileWidth, MapEditor.tileHeight,									this);						/*						 * else g.drawImage(TileEditor						 * .tilesets[tile_set].getArrangementImage(tile,						 * PaletteEventEditor.getPalette(tile_set)), j *						 * MapEditor.tileWidth, i * MapEditor.tileHeight,						 * MapEditor.tileWidth, MapEditor.tileHeight, this);						 */						if (changed) {							Rectangle2D.Double rect = new Rectangle2D.Double(									(j * MapEditor.tileWidth),									(i * MapEditor.tileHeight),									MapEditor.tileWidth, MapEditor.tileHeight);							g2d.setPaint(Color.red);							g2d.setComposite(AlphaComposite.getInstance(									AlphaComposite.SRC_OVER, 0.5F));							g2d.fill(rect);							g2d.setComposite(AlphaComposite.getInstance(									AlphaComposite.SRC_OVER, 1.0F));						}					}				}			}			if (getModeProps()[3] >= 1) {				// this.spriteLocs = new int[spriteData[0]][5];				for (int k = 0; k < screenHeight; k++) {					if ((((tileY + k) % (MapEditor.sectorHeight * 2)) == 0)							|| (k == 0)) {						for (int i = 0; i < screenWidth; i++) {							if ((((tileX + i) % MapEditor.sectorWidth) == 0)									|| (i == 0)) {								/*								 * if (! EbMap.isSpriteDataLoaded( (tileX + i) /								 * MapEditor.sectorWidth, (tileY + k) /								 * (MapEditor.sectorHeight * 2)))								 * EbMap.loadSpriteData(hm.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;									if (spriteDrawX + (i * MapEditor.tileWidth) <= screenWidth											* MapEditor.tileWidth											&& spriteDrawY													+ (k * MapEditor.tileHeight) <= screenHeight													* MapEditor.tileHeight) {										g												.drawImage(														EbMap																.getSpriteImage(																		spriteNum,																		tptEntry																				.getDirection()),														// new														// SpriteEditor.Sprite(sib.getSpriteInfo(tptEntry.getDirection()),														// hm).getImage(true),														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,															sib.width * 8 + 1,															sib.height * 8 + 1));										}									}								}							}						}					}				}			}			if (getModeProps()[4] >= 1) {				for (int k = 0; k < screenHeight; k++) {					if ((((tileY + k) % MapEditor.sectorHeight) == 0)							|| (k == 0)) {						for (int i = 0; i < screenWidth; i++) {							if ((((tileX + i) % MapEditor.sectorWidth) == 0)									|| (i == 0)) {								/*								 * if (! EbMap.isDoorDataLoaded( (tileX + i) /								 * MapEditor.sectorWidth, (tileY + k) /								 * (MapEditor.sectorHeight * 2)))								 * EbMap.loadDoorData(hm.rom, (tileX + i) /								 * MapEditor.sectorWidth, (tileY + k) /								 * (MapEditor.sectorHeight * 2));								 */								int doorsNum = EbMap.getDoorsNum((tileX + i)										/ MapEditor.sectorWidth, (tileY + k)										/ (MapEditor.sectorHeight * 2));								for (int j = 0; j < doorsNum; j++) {									short[] doorXY = EbMap											.getDoorXY(													(tileX + i)															/ MapEditor.sectorWidth,													(tileY + k)															/ (MapEditor.sectorHeight * 2),													j);									int doorDrawX = ((int) doorXY[0]) * 8;									int doorDrawY = ((int) doorXY[1]) * 8;									if (((tileY + k) % (MapEditor.sectorHeight * 2)) > 0)										doorDrawY -= ((tileY + k) % (MapEditor.sectorHeight * 2))												* MapEditor.tileHeight;									if (((tileX + i) % MapEditor.sectorWidth) > 0)										doorDrawX -= ((tileX + i) % MapEditor.sectorWidth)												* MapEditor.tileWidth;									g2d.setPaint(Color.blue);									g2d											.draw(new Rectangle2D.Double(													doorDrawX															+ (i * MapEditor.tileWidth),													doorDrawY															+ (k * MapEditor.tileHeight),													8, 8));								}							}						}					}				}			}			if (getModeProps()[8] >= 1) {				for (int i = 0; i < HotspotEditor.NUM_HOTSPOTS; i++) {					HotspotEditor.Hotspot spot = HotspotEditor.getHotspot(i);					int x1Tile = spot.getX1() * 8 / MapEditor.tileWidth, y1Tile = spot							.getY1()							* 8 / MapEditor.tileHeight, x2Tile = spot.getX2()							* 8 / MapEditor.tileWidth, y2Tile = spot.getY2()							* 8 / MapEditor.tileHeight;					if ((i != movingHotspot) && (x1Tile <= tileX + screenWidth)							&& (x2Tile >= tileX)							&& (y1Tile <= tileY + screenHeight)							&& (y2Tile >= tileY)) {						visibleHotspots.add(new Integer(i));						g2d.setPaint(Color.orange);						g2d.setComposite(AlphaComposite.getInstance(								AlphaComposite.SRC_OVER, 0.5F));						Rectangle2D.Double rect = new Rectangle2D.Double(spot								.getX1()								* 8 - tileX * MapEditor.tileWidth, spot.getY1()								* 8 - tileY * MapEditor.tileHeight, (spot								.getX2() - spot.getX1()) * 8,								(spot.getY2() - spot.getY1()) * 8);						g2d.fill(rect);					}				}			}			if (getModeProps()[5] == 1) {				g2d.setPaint(Color.blue);				g2d.draw(new Line2D.Double(0, crossY, this.getWidth(), crossY));				g2d						.draw(new Line2D.Double(crossX, 0, crossX, this								.getHeight()));			}			if ((getModeProps()[7] & 1) == 1 && previewBoxX >= 0					&& previewBoxY >= 0) {				g2d.setPaint(Color.magenta);				g2d						.draw(new Rectangle2D.Double(previewBoxX, previewBoxY,								8, 8));			}			if (getModeProps()[9] >= 1) {				int group, incX = 2, incY = 2;				Rectangle2D rect;				g2d.setFont(new Font("Arial", Font.PLAIN, 12));				String message;				for (int i = 0; i < screenHeight; i += incY)					for (int j = 0; j < screenWidth; j += incX) {						group = EbMap.getEnemyLoc(hm.rom, (tileX + j) / 2,								(tileY + i) / 2);						incX = 2 - (tileX + j) % 2;						incY = 2 - (tileY + i) % 2;						if (enemyColors) {							g2d.setComposite(AlphaComposite.getInstance(									AlphaComposite.SRC_OVER, 0.5F));							if (group > 0)								g2d										.setPaint(new Color(												((int) (Math.E * 0x100000 * group)) & 0xffffff));							else								g2d.setPaint(noEnemyColor);							g2d.fill(new Rectangle2D.Double(j									* MapEditor.tileWidth, i									* MapEditor.tileHeight, MapEditor.tileWidth									* incX, MapEditor.tileHeight * incY));						}						if (group > 0) {							g2d.setComposite(AlphaComposite.getInstance(									AlphaComposite.SRC_OVER, 1.0F));							g2d.setPaint(Color.black);							message = addZeros(Integer.toHexString(group), 2);							rect = g2d.getFontMetrics().getStringBounds(									message, g2d);							rect.setRect((j + 2) * MapEditor.tileWidth									- rect.getWidth(), (i + 2)									* MapEditor.tileHeight - rect.getHeight(),									rect.getWidth(), rect.getHeight());							g2d.fill(rect);							g2d.setPaint(Color.white);							g2d.drawString(message, (float) ((j + 2)									* MapEditor.tileWidth - rect.getWidth()),									(float) ((i + 2) * MapEditor.tileHeight));							if (enemySprites)								g2d.drawImage(getEnemyImage(group,										MapEditor.tileWidth * 2,										MapEditor.tileHeight * 2), j										* MapEditor.tileWidth, i										* MapEditor.tileHeight, this);						}					}			}			if (grid) {				g2d.setPaint(Color.black);				for (int i = 0; i < screenHeight; i++)					for (int j = 0; j < screenWidth; j++) {						if ((tileY + i) % getModeProps()[10] == 0)							g2d.draw(new Line2D.Double(j * MapEditor.tileWidth,									i * MapEditor.tileHeight,									(getModeProps()[10] + j)											* MapEditor.tileWidth, i											* MapEditor.tileHeight));						if ((tileX + j) % getModeProps()[10] == 0)							g2d.draw(new Line2D.Double(j * MapEditor.tileWidth,									i * MapEditor.tileHeight, j											* MapEditor.tileWidth,									(getModeProps()[10] + i)											* MapEditor.tileHeight));					}			}			if ((getModeProps()[0] >= 1) && this.knowssector) {				g2d.setPaint(Color.yellow);				int drawSectorX = (sectorx * MapEditor.sectorWidth * MapEditor.tileWidth)						- (MapEditor.tileWidth * tileX);				int drawSectorY = (sectory * MapEditor.sectorHeight * MapEditor.tileHeight)						- (MapEditor.tileWidth * tileY);				int drawSectorW = MapEditor.sectorWidth * MapEditor.tileWidth;				int drawSectorH = MapEditor.sectorHeight * MapEditor.tileHeight;				g2d.draw(new Rectangle2D.Double(drawSectorX, drawSectorY,						drawSectorW, drawSectorH));			}		}