diff --git a/data/icons2.png b/data/icons2.png index fb1eff6..d103678 100644 Binary files a/data/icons2.png and b/data/icons2.png differ diff --git a/source/Globals.c b/source/Globals.c index 8c003ff..abfa1c5 100644 --- a/source/Globals.c +++ b/source/Globals.c @@ -1403,3 +1403,27 @@ bool isSwimming(){ return getTile(player.x>>4,player.y>>4)==TILE_WATER; } +void reloadColors() { + dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); + dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); + dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); + dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); + dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); + + grassColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 17, 0)); + grassColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 17, 1)); + + sandColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 18, 0)); + sandColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 18, 1)); + + waterColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 19, 0)); + waterColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 19, 1)); + + lavaColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 20, 0)); + lavaColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 20, 1)); + + rockColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 21, 0)); + rockColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 21, 1)); + rockColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 21, 2)); + rockColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 21, 3)); +} \ No newline at end of file diff --git a/source/Globals.h b/source/Globals.h index e2d83ab..9b6fe51 100644 --- a/source/Globals.h +++ b/source/Globals.h @@ -76,7 +76,14 @@ u8 data[5][128*128]; u8 treeTable[256]; u16 rockTable[256]; u16 grassTable[16]; + u32 dirtColor[5]; +u32 grassColor[2]; +u32 sandColor[2]; +u32 waterColor[2]; +u32 lavaColor[2]; +u32 rockColor[4]; + char currentFileName[256]; extern u8 currentMenu; extern char fpsstr[]; @@ -122,3 +129,5 @@ bool playerUseEnergy(int amount); void playerHurtTile(int tile, int xt, int yt, int damage, int dir); bool playerIntersectsEntity(Entity* e); void playerEntityInteract(Entity* e); + +void reloadColors(); \ No newline at end of file diff --git a/source/Menu.c b/source/Menu.c index 2b7ed08..df0166e 100644 --- a/source/Menu.c +++ b/source/Menu.c @@ -564,11 +564,7 @@ void tickMenu(int menu){ isLoadingTP = 4; } else { icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM); - dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); - dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); - dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); - dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); - dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); + reloadColors(); font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM); bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM); currentMenu = MENU_SETTINGS; @@ -1233,10 +1229,10 @@ void renderMenu(int menu,int xscr,int yscr){ render16(startX,startY+12,0,128,0);//Player(Carrying) render16(startX,startY,128,128,0);//Workbench startX = 120;startY = 20; - render16b(startX,startY,16,96,0,0xFFC11D00);// water pit - render16b(startX+16,startY,32,96,0,0xFFC11D00); - render16b(startX,startY+16,48,96,0,0xFFC11D00); - render16b(startX+16,startY+16,64,96,0,0xFFC11D00); + render16b(startX,startY,16,96,0,waterColor[0]);// water pit + render16b(startX+16,startY,32,96,0,waterColor[0]); + render16b(startX,startY+16,48,96,0,waterColor[0]); + render16b(startX+16,startY+16,64,96,0,waterColor[0]); renderc (startX+8,startY+12,48,160,16,8,0);//Waves renderc (startX+8,startY+8,0,112,16,8,0);//Player (Top-Half) startX = 110;startY = 76; @@ -1250,10 +1246,10 @@ void renderMenu(int menu,int xscr,int yscr){ renderc (startX+14,startY,32,160,8,16,0);//Slash render (startX+12,startY+4,104,144,1);//Sword startX = 64;startY = 40; - render16b(startX,startY,16,80,0,0xFF69B569);// grass pit - render16b(startX+16,startY,32,80,0,0xFF69B569); - render16b(startX,startY+16,48,80,0,0xFF69B569); - render16b(startX+16,startY+16,64,80,0,0xFF69B569); + render16b(startX,startY,16,80,0,grassColor[0]);// grass pit + render16b(startX+16,startY,32,80,0,grassColor[0]); + render16b(startX,startY+16,48,80,0,grassColor[0]); + render16b(startX+16,startY+16,64,80,0,grassColor[0]); render16 (startX+8,startY+4,0,16,0);//Tree render (startX+1,startY+14,80,152,0);// Apple render16 (startX+9,startY+18,16,112,0);//Player diff --git a/source/MenuTutorial.c b/source/MenuTutorial.c index f3a4c98..34681e5 100644 --- a/source/MenuTutorial.c +++ b/source/MenuTutorial.c @@ -114,19 +114,19 @@ void renderTutorialPage(bool topScreen){ renderButtonIcon(k_attack.input & -k_attack.input, 80, 56, 2); renderc(60,68,16,160,16,8,2);//Slash - render16b(12,20,16,80,0,0xFF69B569);// grass pit - render16b(12+16,20,32,80,0,0xFF69B569); - render16b(12,20+16,48,80,0,0xFF69B569); - render16b(12+16,20+16,64,80,0,0xFF69B569); + render16b(12,20,16,80,0,grassColor[0]);// grass pit + render16b(12+16,20,32,80,0,grassColor[0]); + render16b(12,20+16,48,80,0,grassColor[0]); + render16b(12+16,20+16,64,80,0,grassColor[0]); render16(12+8,20+4,0,16,0);//Tree renderc(12+9,20+14,16,160,16,8,0);//Slash render(12+9+4,20+14,192,144,0);//Axe render16(12+9,20+18,16,112,0);//Player-up - render16b(122,62,16,80,0,0xFF7BF7F7);// sand pit - render16b(122+16,62,32,80,0,0xFF7BF7F7); - render16b(122,62+16,48,80,0,0xFF7BF7F7); - render16b(122+16,62+16,64,80,0,0xFF7BF7F7); + render16b(122,62,16,80,0,sandColor[0]);// sand pit + render16b(122+16,62,32,80,0,sandColor[0]); + render16b(122,62+16,48,80,0,sandColor[0]); + render16b(122+16,62+16,64,80,0,sandColor[0]); render16b(130,70,0,96,0,0xFF383838);// hole render16(116,70,48,112,0);//Player-right renderb(136,76,16,152,0,0xFF8197AF);// Dirt item @@ -147,7 +147,7 @@ void renderTutorialPage(bool topScreen){ renderButtonIcon(biasedCirclePad(k_down.input), 44, 125, 1); break; case 3: // Furniture - sf2d_draw_rectangle(64, 48, 192, 32, 0xFF69B569); + sf2d_draw_rectangle(64, 48, 192, 32, grassColor[0]); renderc(32,24,64,128,96,16,0);//Furniture entities renderFurniture(ITEM_WORKBENCH, 50,60); @@ -186,14 +186,14 @@ void renderTutorialPage(bool topScreen){ render(76,48,40,152,0); // Seeds sf2d_draw_rectangle(216, 80, 32, 32, dirtColor[1]); // Dirt color for grass - render16b(108, 40, 0, 80, 0, 0xFF69B569); // Grass + render16b(108, 40, 0, 80, 0, grassColor[0]); // Grass render16(124, 40,144,0,0); // Farm Tile render16(108,54,16,112,0); // Player (Up) renderc(108,50,16,160,16,8,0); // Slash (Up) render(112,48,72,144,0); // Gem Hoe sf2d_draw_rectangle(112, 156, 32, 32, dirtColor[1]); // Dirt color for grass - render16b(56, 78, 0, 80, 0, 0xFF69B569); // Grass + render16b(56, 78, 0, 80, 0, grassColor[0]); // Grass sf2d_draw_rectangle(80, 156, 32, 32, dirtColor[1]); // Dirt color render16b(40, 78, 0, 0, 0, 0xFF8F8FA8); // Dirt Dots render(44, 82, 40,152,0); // Seeds diff --git a/source/Render.c b/source/Render.c index 5d4bc9d..f8cf80b 100644 --- a/source/Render.c +++ b/source/Render.c @@ -538,8 +538,8 @@ void renderTile(int i, int x, int y) { | checkSurrTiles4(x >> 4, y >> 4, TILE_TREE) | checkSurrTiles4(x >> 4, y >> 4, TILE_FLOWER) | checkSurrTiles4(x >> 4, y >> 4, TILE_SAPLING_TREE); - render16b(x, y, grassTable[v], 80, 0, 0xFF69B569); - renderDotsWithColor(v, x, y, 0, 0xFF8ED38E); + render16b(x, y, grassTable[v], 80, 0, grassColor[0]); + renderDotsWithColor(v, x, y, 0, grassColor[1]); break; case TILE_TREE: renderTile(TILE_GRASS, x, y); @@ -548,13 +548,13 @@ void renderTile(int i, int x, int y) { break; case TILE_ROCK: v = checkSurrTiles8(x >> 4, y >> 4, TILE_ROCK); - render16s(x, y, rockTable[v] + 8192, 0, 0xFFFFFFFF); - renderRockDotsWithColor(rockTable[v], x, y, 0xFF949494); + render16s(x, y, rockTable[v] + 8192, 0, rockColor[0]); + renderRockDotsWithColor(rockTable[v], x, y, rockColor[1]); break; case TILE_HARDROCK: v = checkSurrTiles8(x >> 4, y >> 4, TILE_HARDROCK); - render16s(x, y, rockTable[v] + 8192, 0, 0xFFFFCFCF); - renderRockDotsWithColor(rockTable[v], x, y, 0xFFFF9494); + render16s(x, y, rockTable[v] + 8192, 0, rockColor[2]); + renderRockDotsWithColor(rockTable[v], x, y, rockColor[3]); break; case TILE_DIRT: // render dots. if (currentLevel > 1) @@ -566,22 +566,22 @@ void renderTile(int i, int x, int y) { v = checkSurrTiles4(x >> 4, y >> 4, TILE_SAND) | checkSurrTiles4(x >> 4, y >> 4, TILE_CACTUS) | checkSurrTiles4(x >> 4, y >> 4, TILE_SAPLING_CACTUS); - render16b(x, y, grassTable[v], 80, 0, 0xFF7BF7F7); - renderDotsWithColor(v, x, y, 0, 0xFF5BB7B7); + render16b(x, y, grassTable[v], 80, 0, sandColor[0]); + renderDotsWithColor(v, x, y, 0, sandColor[1]); break; case TILE_WATER: v = checkSurrTiles4(x >> 4, y >> 4, TILE_WATER) | checkSurrTiles4(x >> 4, y >> 4, TILE_HOLE); - render16b(x, y, grassTable[v], 96, 0, 0xFFC11D00); + render16b(x, y, grassTable[v], 96, 0, waterColor[0]); srand((tickCount + (x / 2 - y) * 4311) / 10); - renderDotsWithColor(v, x, y, rand() & 3, 0xFFFF6B6B); + renderDotsWithColor(v, x, y, rand() & 3, waterColor[1]); break; case TILE_LAVA: v = checkSurrTiles4(x >> 4, y >> 4, TILE_LAVA) | checkSurrTiles4(x >> 4, y >> 4, TILE_HOLE); - render16b(x, y, grassTable[v], 96, 0, 0xFF001DC1); + render16b(x, y, grassTable[v], 96, 0, lavaColor[0]); srand((tickCount + (x / 2 - y) * 4311) / 10); - renderDotsWithColor(v, x, y, rand() & 3, 0xFF6B6BFF); + renderDotsWithColor(v, x, y, rand() & 3, lavaColor[1]); break; case TILE_HOLE: render16b(x, y, @@ -1258,10 +1258,10 @@ void renderItemIcon(int itemID, int countLevel, int x, int y) { render(x, y, 8, 152, 0); break; case ITEM_STONE: - renderb(x, y, 16, 152, 0, 0xFFCFCFCF); + renderb(x, y, 16, 152, 0, rockColor[1]); break; case ITEM_SAND: - renderb(x, y, 16, 152, 0, 0xFF7BF7F7); + renderb(x, y, 16, 152, 0, sandColor[0]); break; case ITEM_DIRT: renderb(x, y, 16, 152, 0, 0xFF8197AF); diff --git a/source/main.c b/source/main.c index 2d22cbd..114dd7d 100644 --- a/source/main.c +++ b/source/main.c @@ -187,13 +187,8 @@ int main() { sf2d_texture_tile32(minimap[i]); } - dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); - dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); - dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); - dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); - dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); - - + reloadColors(); + sf2d_set_vblank_wait(true); sf2d_set_clear_color(0xFF); diff --git a/source/texturepack.c b/source/texturepack.c index 4493faf..a79f47b 100644 --- a/source/texturepack.c +++ b/source/texturepack.c @@ -114,11 +114,8 @@ int loadTexturePack(char * filename){ return 7; } icons = sfil_load_PNG_file(filename, SF2D_PLACE_RAM); - dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); - dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); - dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); - dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); - dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); + + reloadColors(); useDefaultIcons = false; @@ -158,11 +155,7 @@ int loadTexturePack(char * filename){ if(useDefaultIcons){ icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM); - dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); - dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); - dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); - dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); - dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); + reloadColors(); } if(useDefaultFont) font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM); if(useDefaultBottom) bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM);