diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt index cc92cee1e2..9aff4e77a1 100644 --- a/common_syms/overworld.txt +++ b/common_syms/overworld.txt @@ -8,3 +8,4 @@ gLocalLinkPlayerId gFieldLinkPlayerCount gTimeOfDay currentTimeBlend +gTimeUpdateCounter diff --git a/data/maps/DewfordTown/map.json b/data/maps/DewfordTown/map.json index 8beb5add70..c59e668444 100644 --- a/data/maps/DewfordTown/map.json +++ b/data/maps/DewfordTown/map.json @@ -89,6 +89,19 @@ "trainer_sight_or_berry_tree_id": "0", "script": "DewfordTown_EventScript_TrendyPhraseBoy", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 4, + "y": 10, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/EverGrandeCity/map.json b/data/maps/EverGrandeCity/map.json index 9db9c8febb..311cf4c2c4 100644 --- a/data/maps/EverGrandeCity/map.json +++ b/data/maps/EverGrandeCity/map.json @@ -19,7 +19,21 @@ "map": "MAP_ROUTE128" } ], - "object_events": [], + "object_events": [ + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 29, + "y": 48, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + } + ], "warp_events": [ { "x": 18, diff --git a/data/maps/LilycoveCity/map.json b/data/maps/LilycoveCity/map.json index a13904ca9a..d4a2b6ee47 100644 --- a/data/maps/LilycoveCity/map.json +++ b/data/maps/LilycoveCity/map.json @@ -310,6 +310,19 @@ "trainer_sight_or_berry_tree_id": "0", "script": "LilycoveCity_EventScript_FatMan", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 26, + "y": 14, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/MauvilleCity/map.json b/data/maps/MauvilleCity/map.json index cf3d5f8a1c..bd7426404f 100644 --- a/data/maps/MauvilleCity/map.json +++ b/data/maps/MauvilleCity/map.json @@ -177,6 +177,32 @@ "trainer_sight_or_berry_tree_id": "0", "script": "0x0", "flag": "FLAG_HIDE_MAUVILLE_CITY_SCOTT" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 24, + "y": 5, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 25, + "y": 14, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/MossdeepCity/map.json b/data/maps/MossdeepCity/map.json index ff8ae1b616..309a22f424 100644 --- a/data/maps/MossdeepCity/map.json +++ b/data/maps/MossdeepCity/map.json @@ -250,6 +250,32 @@ "trainer_sight_or_berry_tree_id": "0", "script": "MossdeepCity_EventScript_BlackBelt", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 30, + "y": 16, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 39, + "y": 18, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/PacifidlogTown/map.json b/data/maps/PacifidlogTown/map.json index 51fc772a92..ec1bb1b226 100644 --- a/data/maps/PacifidlogTown/map.json +++ b/data/maps/PacifidlogTown/map.json @@ -63,6 +63,19 @@ "trainer_sight_or_berry_tree_id": "0", "script": "PacifidlogTown_EventScript_NinjaBoy", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 10, + "y": 15, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" } ], "warp_events": [ @@ -109,7 +122,9 @@ "dest_warp_id": 0 } ], - "coord_events": [], + "coord_events": [ + + ], "bg_events": [ { "type": "sign", diff --git a/data/maps/PetalburgCity/map.json b/data/maps/PetalburgCity/map.json index d9587cdbb9..c36d36fafb 100644 --- a/data/maps/PetalburgCity/map.json +++ b/data/maps/PetalburgCity/map.json @@ -141,6 +141,32 @@ "trainer_sight_or_berry_tree_id": "0", "script": "0x0", "flag": "FLAG_HIDE_PETALBURG_CITY_SCOTT" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 16, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 27, + "y": 12, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/RustboroCity/map.json b/data/maps/RustboroCity/map.json index 445bc51899..979d61e0b6 100644 --- a/data/maps/RustboroCity/map.json +++ b/data/maps/RustboroCity/map.json @@ -237,6 +237,227 @@ "trainer_sight_or_berry_tree_id": "0", "script": "RustboroCity_EventScript_Boy1", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 19, + "y": 37, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 37, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 19, + "y": 30, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 30, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 19, + "y": 23, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 23, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 44, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 19, + "y": 44, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 29, + "y": 48, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 14, + "y": 19, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 15, + "y": 17, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 9, + "y": 19, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 8, + "y": 17, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 19, + "y": 15, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 22, + "y": 15, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 14, + "y": 54, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 17, + "y": 54, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "0", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/SlateportCity/map.json b/data/maps/SlateportCity/map.json index 6ffed4b454..9141e5ab69 100644 --- a/data/maps/SlateportCity/map.json +++ b/data/maps/SlateportCity/map.json @@ -484,6 +484,32 @@ "trainer_sight_or_berry_tree_id": "0", "script": "0x0", "flag": "FLAG_HIDE_SLATEPORT_CITY_SCOTT" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 21, + "y": 19, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 15, + "y": 26, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/maps/VerdanturfTown/map.json b/data/maps/VerdanturfTown/map.json index 94d140c05e..df419ce905 100644 --- a/data/maps/VerdanturfTown/map.json +++ b/data/maps/VerdanturfTown/map.json @@ -76,6 +76,32 @@ "trainer_sight_or_berry_tree_id": "0", "script": "VerdanturfTown_EventScript_Camper", "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 18, + "y": 3, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "1", + "script": "NULL", + "flag": "0" + }, + { + "graphics_id": "OBJ_EVENT_GFX_LIGHT_SPRITE", + "x": 14, + "y": 3, + "elevation": 3, + "movement_type": "MOVEMENT_TYPE_NONE", + "movement_range_x": 0, + "movement_range_y": 0, + "trainer_type": "TRAINER_TYPE_NONE", + "trainer_sight_or_berry_tree_id": "2", + "script": "NULL", + "flag": "0" } ], "warp_events": [ diff --git a/data/tilesets/headers.inc b/data/tilesets/headers.inc index 3f1945af4b..8a1e8f444b 100644 --- a/data/tilesets/headers.inc +++ b/data/tilesets/headers.inc @@ -1,8 +1,8 @@ .align 2 gTileset_General:: - .byte TRUE @ is compressed + .byte 0x41 @ is compressed, swapPalettes 4 .byte FALSE @ is secondary tileset - .2byte 0 @ padding + .2byte 0x10 @ lightPalettes 4 .4byte gTilesetTiles_General .4byte gTilesetPalettes_General .4byte gMetatiles_General @@ -11,9 +11,9 @@ gTileset_General:: .align 2 gTileset_Petalburg:: - .byte TRUE @ is compressed + .byte 0x21 @ is compressed, swapPalettes 9 .byte TRUE @ is secondary tileset - .2byte 3 @ lightPalettes 6,7 + .2byte 0x00B @ lightPalettes 6,7,9, custom 9 .4byte gTilesetTiles_Petalburg .4byte gTilesetPalettes_Petalburg .4byte gMetatiles_Petalburg @@ -35,7 +35,7 @@ gTileset_Rustboro:: gTileset_Dewford:: .byte TRUE @ is compressed .byte TRUE @ is secondary tileset - .2byte 64 @ lightPalettes 12 + .2byte 0 @ padding .4byte gTilesetTiles_Dewford .4byte gTilesetPalettes_Dewford .4byte gMetatiles_Dewford @@ -44,9 +44,9 @@ gTileset_Dewford:: .align 2 gTileset_Slateport:: - .byte TRUE @ is compressed + .byte 5 @ is compressed, swapPalettes 6 .byte TRUE @ is secondary tileset - .2byte 0x41 @ lightPalettes 6,12 + .2byte 0x1 @ lightPalettes 6 .4byte gTilesetTiles_Slateport .4byte gTilesetPalettes_Slateport .4byte gMetatiles_Slateport @@ -68,7 +68,7 @@ gTileset_Mauville:: gTileset_Lavaridge:: .byte TRUE @ is compressed .byte TRUE @ is secondary tileset - .2byte 0 @ padding + .2byte 0x0101 @ lightPalettes 6, customLights 6 .4byte gTilesetTiles_Lavaridge .4byte gTilesetPalettes_Lavaridge .4byte gMetatiles_Lavaridge @@ -77,7 +77,7 @@ gTileset_Lavaridge:: .align 2 gTileset_Fallarbor:: - .byte TRUE @ is compressed + .byte 9 @ is compressed, swapPalettes 7 .byte TRUE @ is secondary tileset .2byte 2 @ lightPalettes 7 .4byte gTilesetTiles_Fallarbor @@ -99,7 +99,7 @@ gTileset_Fortree:: .align 2 gTileset_Lilycove:: - .byte TRUE @ is compressed + .byte 5 @ is compressed, swapPalettes 6 .byte TRUE @ is secondary tileset .2byte 0x01 @ lightPalettes 6 .4byte gTilesetTiles_Lilycove @@ -107,12 +107,13 @@ gTileset_Lilycove:: .4byte gMetatiles_Lilycove .4byte gMetatileAttributes_Lilycove .4byte InitTilesetAnim_Lilycove + .2byte 0 .align 2 gTileset_Mossdeep:: - .byte TRUE @ is compressed + .byte 0x11 @ is compressed, swapPalettes 8 .byte TRUE @ is secondary tileset - .2byte 0 @ lightPalettes 8,9 + .2byte 0x4 @ lightPalettes 8 .4byte gTilesetTiles_Mossdeep .4byte gTilesetPalettes_Mossdeep .4byte gMetatiles_Mossdeep @@ -129,10 +130,11 @@ gTileset_EverGrande:: .4byte gMetatiles_EverGrande .4byte gMetatileAttributes_EverGrande .4byte InitTilesetAnim_EverGrande + .2byte 0 .align 2 gTileset_Pacifidlog:: - .byte TRUE @ is compressed + .byte 0x21 @ is compressed, swapPalettes 9 .byte TRUE @ is secondary tileset .2byte 8 @ lightPalettes 9 .4byte gTilesetTiles_Pacifidlog @@ -143,7 +145,7 @@ gTileset_Pacifidlog:: .align 2 gTileset_Sootopolis:: - .byte TRUE @ is compressed + .byte 5 @ is compressed, swapPalettes 6 .byte TRUE @ is secondary tileset .2byte 0x101 @ lightPalettes 6, customLights 6 .4byte gTilesetTiles_Sootopolis diff --git a/data/tilesets/primary/general/metatile_attributes.bin b/data/tilesets/primary/general/metatile_attributes.bin index d9cd29016d..552dafb603 100644 Binary files a/data/tilesets/primary/general/metatile_attributes.bin and b/data/tilesets/primary/general/metatile_attributes.bin differ diff --git a/data/tilesets/primary/general/metatiles.bin b/data/tilesets/primary/general/metatiles.bin index af899bcc5e..813543f580 100644 Binary files a/data/tilesets/primary/general/metatiles.bin and b/data/tilesets/primary/general/metatiles.bin differ diff --git a/data/tilesets/primary/general/palettes/04.pal b/data/tilesets/primary/general/palettes/04.pal index 11ebd16a64..57d4faa34d 100644 --- a/data/tilesets/primary/general/palettes/04.pal +++ b/data/tilesets/primary/general/palettes/04.pal @@ -1,12 +1,12 @@ JASC-PAL 0100 16 -24 41 82 -248 0 248 +232 0 128 +216 224 232 222 230 238 -255 0 255 -255 0 255 -255 0 255 +184 200 224 +152 176 216 +112 184 240 156 164 189 80 104 208 65 90 189 @@ -16,4 +16,4 @@ JASC-PAL 139 164 222 106 131 213 82 106 213 -248 0 248 +96 168 232 diff --git a/data/tilesets/primary/general/palettes/13.pal b/data/tilesets/primary/general/palettes/13.pal index 4b0812f094..73fec5261a 100644 --- a/data/tilesets/primary/general/palettes/13.pal +++ b/data/tilesets/primary/general/palettes/13.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 -0 0 0 +232 0 128 +232 228 216 +222 230 238 +224 214 184 +216 200 152 +244 226 171 +156 164 189 +80 104 208 +65 90 189 +57 82 156 +41 65 139 +172 197 230 +139 164 222 +106 131 213 +82 106 213 +221 205 143 diff --git a/data/tilesets/primary/general/tiles.png b/data/tilesets/primary/general/tiles.png index 17426ab80e..b22b3f1fcb 100644 Binary files a/data/tilesets/primary/general/tiles.png and b/data/tilesets/primary/general/tiles.png differ diff --git a/data/tilesets/secondary/dewford/metatile_attributes.bin b/data/tilesets/secondary/dewford/metatile_attributes.bin index 67ee25d405..158238664f 100644 Binary files a/data/tilesets/secondary/dewford/metatile_attributes.bin and b/data/tilesets/secondary/dewford/metatile_attributes.bin differ diff --git a/data/tilesets/secondary/dewford/metatiles.bin b/data/tilesets/secondary/dewford/metatiles.bin index d99fd8a3a8..9e1f54e174 100644 Binary files a/data/tilesets/secondary/dewford/metatiles.bin and b/data/tilesets/secondary/dewford/metatiles.bin differ diff --git a/data/tilesets/secondary/dewford/palettes/12.pal b/data/tilesets/secondary/dewford/palettes/12.pal index cf04ad17c0..4b0812f094 100644 --- a/data/tilesets/secondary/dewford/palettes/12.pal +++ b/data/tilesets/secondary/dewford/palettes/12.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -0 224 0 -0 0 0 -222 230 238 -189 205 230 -156 180 222 -131 131 139 -98 98 123 -65 74 106 -152 176 216 -115 189 246 -98 172 238 0 0 0 0 0 0 -213 180 106 -205 156 82 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 0 0 0 diff --git a/data/tilesets/secondary/dewford/tiles.png b/data/tilesets/secondary/dewford/tiles.png index 522864a973..2af1303c27 100644 Binary files a/data/tilesets/secondary/dewford/tiles.png and b/data/tilesets/secondary/dewford/tiles.png differ diff --git a/data/tilesets/secondary/fallarbor/palettes/00.pal b/data/tilesets/secondary/fallarbor/palettes/00.pal index ede0c60a19..87f9999aef 100644 --- a/data/tilesets/secondary/fallarbor/palettes/00.pal +++ b/data/tilesets/secondary/fallarbor/palettes/00.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -115 197 164 -255 255 255 -222 230 238 -189 205 230 -156 180 222 +0 192 0 +222 230 164 +180 197 115 +148 156 82 +123 131 65 131 131 139 98 98 123 65 74 106 -189 189 131 -115 189 246 -98 172 238 -115 189 246 -98 164 222 -82 139 197 -74 115 172 -115 197 164 +88 168 168 +221 205 143 +244 226 171 +255 205 82 +230 156 49 +222 123 32 +156 98 41 +128 192 216 diff --git a/data/tilesets/secondary/lavaridge/metatiles.bin b/data/tilesets/secondary/lavaridge/metatiles.bin index fd0314ed78..c9bc71442a 100644 Binary files a/data/tilesets/secondary/lavaridge/metatiles.bin and b/data/tilesets/secondary/lavaridge/metatiles.bin differ diff --git a/data/tilesets/secondary/lavaridge/palettes/06.pal b/data/tilesets/secondary/lavaridge/palettes/06.pal index 00e1478a73..a858e623d1 100644 --- a/data/tilesets/secondary/lavaridge/palettes/06.pal +++ b/data/tilesets/secondary/lavaridge/palettes/06.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -0 0 0 -65 74 106 -197 205 0 -230 238 238 -255 255 255 -255 115 65 -230 115 65 -180 98 90 -164 82 82 -205 49 0 -148 49 0 -246 24 24 -246 148 0 -148 164 65 -106 123 139 -222 222 0 +0 192 24 +64 72 104 +192 200 0 +224 232 232 +248 248 248 +248 112 64 +224 112 64 +176 96 88 +160 80 80 +200 48 0 +144 48 0 +240 24 24 +240 144 0 +144 160 64 +104 120 136 +224 40 0 diff --git a/data/tilesets/secondary/lavaridge/tiles.png b/data/tilesets/secondary/lavaridge/tiles.png index 2f6898a0f7..03c832c37a 100644 Binary files a/data/tilesets/secondary/lavaridge/tiles.png and b/data/tilesets/secondary/lavaridge/tiles.png differ diff --git a/data/tilesets/secondary/lilycove/metatile_attributes.bin b/data/tilesets/secondary/lilycove/metatile_attributes.bin index 0f4e01b923..f31cc9a047 100644 Binary files a/data/tilesets/secondary/lilycove/metatile_attributes.bin and b/data/tilesets/secondary/lilycove/metatile_attributes.bin differ diff --git a/data/tilesets/secondary/lilycove/metatiles.bin b/data/tilesets/secondary/lilycove/metatiles.bin index 15b2229277..f82bdff5c6 100644 Binary files a/data/tilesets/secondary/lilycove/metatiles.bin and b/data/tilesets/secondary/lilycove/metatiles.bin differ diff --git a/data/tilesets/secondary/lilycove/palettes/15.pal b/data/tilesets/secondary/lilycove/palettes/15.pal index e7717d74ea..41c4142bb9 100644 --- a/data/tilesets/secondary/lilycove/palettes/15.pal +++ b/data/tilesets/secondary/lilycove/palettes/15.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -115 197 164 -255 213 180 -255 197 148 -222 148 115 -123 65 65 -57 74 123 -41 57 98 -24 41 82 -16 32 57 -222 230 238 -255 197 90 -189 156 90 -255 98 90 -197 65 65 -255 255 255 +24 200 0 +244 226 171 +221 205 143 +115 148 213 +90 115 189 +131 131 139 +232 228 216 +65 74 106 +222 213 222 +221 205 143 +244 226 171 +248 248 248 +0 0 0 +0 0 0 +0 0 0 0 0 0 diff --git a/data/tilesets/secondary/lilycove/tiles.png b/data/tilesets/secondary/lilycove/tiles.png index d778caef63..56be3ab4dc 100644 Binary files a/data/tilesets/secondary/lilycove/tiles.png and b/data/tilesets/secondary/lilycove/tiles.png differ diff --git a/data/tilesets/secondary/mauville/metatiles.bin b/data/tilesets/secondary/mauville/metatiles.bin index a71ead8e57..148991e52e 100644 Binary files a/data/tilesets/secondary/mauville/metatiles.bin and b/data/tilesets/secondary/mauville/metatiles.bin differ diff --git a/data/tilesets/secondary/mauville/tiles.png b/data/tilesets/secondary/mauville/tiles.png index 20da7198e8..09bab36577 100644 Binary files a/data/tilesets/secondary/mauville/tiles.png and b/data/tilesets/secondary/mauville/tiles.png differ diff --git a/data/tilesets/secondary/mossdeep/metatiles.bin b/data/tilesets/secondary/mossdeep/metatiles.bin index 5fc527d0ff..1fe4faf9c5 100644 Binary files a/data/tilesets/secondary/mossdeep/metatiles.bin and b/data/tilesets/secondary/mossdeep/metatiles.bin differ diff --git a/data/tilesets/secondary/mossdeep/palettes/01.pal b/data/tilesets/secondary/mossdeep/palettes/01.pal index 1d09f740d5..e845b832bc 100644 --- a/data/tilesets/secondary/mossdeep/palettes/01.pal +++ b/data/tilesets/secondary/mossdeep/palettes/01.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -131 197 98 +0 192 0 255 255 255 -222 230 238 -189 205 230 -156 180 222 -131 131 139 +205 205 197 +180 180 164 +180 189 222 +139 139 148 98 98 123 65 74 106 41 49 90 -115 189 246 -98 172 238 -255 189 131 -238 148 115 -222 106 98 -205 65 82 -115 197 164 +255 248 180 +224 217 159 +255 213 49 +238 148 16 +205 213 131 +148 148 74 +90 82 8 diff --git a/data/tilesets/secondary/mossdeep/palettes/02.pal b/data/tilesets/secondary/mossdeep/palettes/02.pal index 4c41030f66..14fb4a9897 100644 --- a/data/tilesets/secondary/mossdeep/palettes/02.pal +++ b/data/tilesets/secondary/mossdeep/palettes/02.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -24 41 82 -180 255 131 -131 197 98 -57 139 49 -57 82 0 -222 148 115 -106 90 90 -164 98 90 -65 57 49 -255 197 148 -222 106 98 -205 65 82 -164 213 197 -115 197 164 -65 180 131 -24 164 106 +0 32 0 +248 248 248 +248 0 248 +224 0 232 +64 128 96 +120 120 144 +96 96 120 +64 72 104 +255 227 148 +184 184 192 +160 160 152 +240 216 152 +208 144 112 +184 80 80 +128 56 64 +240 144 48 diff --git a/data/tilesets/secondary/mossdeep/palettes/09.pal b/data/tilesets/secondary/mossdeep/palettes/09.pal index 818ed6aa0e..0883321166 100644 --- a/data/tilesets/secondary/mossdeep/palettes/09.pal +++ b/data/tilesets/secondary/mossdeep/palettes/09.pal @@ -2,18 +2,18 @@ JASC-PAL 0100 16 0 32 0 -255 255 255 +248 248 248 248 0 248 -248 0 248 -65 131 98 -123 123 148 -98 98 123 -65 74 106 +224 0 232 +64 128 96 +120 120 144 +96 96 120 64 72 104 -189 189 197 -164 164 156 -246 222 156 -213 148 115 -189 82 82 -131 57 65 -246 148 49 +80 72 104 +184 184 192 +160 160 152 +240 216 152 +208 144 112 +184 80 80 +128 56 64 +240 144 48 diff --git a/data/tilesets/secondary/mossdeep/tiles.png b/data/tilesets/secondary/mossdeep/tiles.png index 3bd134f1a4..6c1bb1d396 100644 Binary files a/data/tilesets/secondary/mossdeep/tiles.png and b/data/tilesets/secondary/mossdeep/tiles.png differ diff --git a/data/tilesets/secondary/pacifidlog/palettes/02.pal b/data/tilesets/secondary/pacifidlog/palettes/02.pal index 4c41030f66..9ea109ce00 100644 --- a/data/tilesets/secondary/pacifidlog/palettes/02.pal +++ b/data/tilesets/secondary/pacifidlog/palettes/02.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -24 41 82 -180 255 131 -131 197 98 -57 139 49 -57 82 0 -222 148 115 -106 90 90 -164 98 90 -65 57 49 -255 197 148 -222 106 98 -205 65 82 -164 213 197 -115 197 164 -65 180 131 -24 164 106 +0 0 128 +222 230 164 +180 189 123 +156 164 98 +131 139 74 +90 98 41 +98 98 123 +65 74 106 +32 32 82 +238 230 164 +238 197 98 +205 156 57 +164 123 24 +131 82 49 +131 131 139 +244 226 171 diff --git a/data/tilesets/secondary/petalburg/palettes/02.pal b/data/tilesets/secondary/petalburg/palettes/02.pal index 4c41030f66..4897614451 100644 --- a/data/tilesets/secondary/petalburg/palettes/02.pal +++ b/data/tilesets/secondary/petalburg/palettes/02.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -24 41 82 -180 255 131 -131 197 98 -57 139 49 -57 82 0 -222 148 115 -106 90 90 -164 98 90 -65 57 49 -255 197 148 -222 106 98 -205 65 82 -164 213 197 -115 197 164 -65 180 131 -24 164 106 +0 192 0 +232 224 200 +208 200 144 +200 176 120 +168 136 120 +128 128 136 +96 96 120 +64 72 104 +40 48 88 +244 226 171 +221 205 143 +248 224 176 +248 184 168 +240 160 128 +200 136 104 +248 192 32 diff --git a/data/tilesets/secondary/petalburg/palettes/09.pal b/data/tilesets/secondary/petalburg/palettes/09.pal index c4a6e250af..1a6a5c7713 100644 --- a/data/tilesets/secondary/petalburg/palettes/09.pal +++ b/data/tilesets/secondary/petalburg/palettes/09.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -24 41 82 -238 230 205 -213 205 148 -205 180 123 -172 139 123 -131 131 139 -98 98 123 -65 74 106 -41 49 90 -156 205 246 -98 156 238 -255 230 180 -255 189 172 -246 164 131 -205 139 106 -115 197 164 +0 192 0 +232 224 200 +208 200 144 +200 176 120 +168 136 120 +128 128 136 +96 96 120 +64 72 104 +40 48 88 +152 200 240 +120 152 232 +248 224 176 +248 184 168 +240 160 128 +200 136 104 +248 192 32 diff --git a/data/tilesets/secondary/rustboro/metatiles.bin b/data/tilesets/secondary/rustboro/metatiles.bin index 63ecf0306e..649b09fac9 100644 Binary files a/data/tilesets/secondary/rustboro/metatiles.bin and b/data/tilesets/secondary/rustboro/metatiles.bin differ diff --git a/data/tilesets/secondary/rustboro/tiles.png b/data/tilesets/secondary/rustboro/tiles.png index 3c71f263bb..1cf8473a20 100644 Binary files a/data/tilesets/secondary/rustboro/tiles.png and b/data/tilesets/secondary/rustboro/tiles.png differ diff --git a/data/tilesets/secondary/slateport/metatile_attributes.bin b/data/tilesets/secondary/slateport/metatile_attributes.bin index d4894828bb..0f311a694f 100644 Binary files a/data/tilesets/secondary/slateport/metatile_attributes.bin and b/data/tilesets/secondary/slateport/metatile_attributes.bin differ diff --git a/data/tilesets/secondary/slateport/metatiles.bin b/data/tilesets/secondary/slateport/metatiles.bin index 0cb7f64aca..3ba541bfbd 100644 Binary files a/data/tilesets/secondary/slateport/metatiles.bin and b/data/tilesets/secondary/slateport/metatiles.bin differ diff --git a/data/tilesets/secondary/slateport/palettes/12.pal b/data/tilesets/secondary/slateport/palettes/12.pal index f003c0d9ed..589258c21f 100644 --- a/data/tilesets/secondary/slateport/palettes/12.pal +++ b/data/tilesets/secondary/slateport/palettes/12.pal @@ -1,18 +1,18 @@ JASC-PAL 0100 16 -0 128 64 +96 160 72 222 205 148 184 168 80 -0 0 0 -0 0 0 +168 224 200 +216 216 176 148 148 156 98 98 123 64 72 104 -0 0 0 +184 184 152 0 0 0 148 205 255 -0 0 0 +184 224 216 0 0 0 0 0 0 0 0 0 diff --git a/data/tilesets/secondary/slateport/palettes/15.pal b/data/tilesets/secondary/slateport/palettes/15.pal index e7717d74ea..25b623a269 100644 --- a/data/tilesets/secondary/slateport/palettes/15.pal +++ b/data/tilesets/secondary/slateport/palettes/15.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -115 197 164 -255 213 180 -255 197 148 -222 148 115 -123 65 65 -57 74 123 -41 57 98 -24 41 82 -16 32 57 -222 230 238 -255 197 90 -189 156 90 -255 98 90 -197 65 65 +0 32 0 255 255 255 -0 0 0 +230 230 238 +205 205 222 +197 180 222 +123 131 156 +98 98 123 +65 74 106 +255 231 138 +205 205 148 +172 148 90 +222 213 238 +197 180 189 +164 156 164 +131 106 172 +112 192 160 diff --git a/data/tilesets/secondary/slateport/tiles.png b/data/tilesets/secondary/slateport/tiles.png index beef335d53..c5f01eb1d0 100644 Binary files a/data/tilesets/secondary/slateport/tiles.png and b/data/tilesets/secondary/slateport/tiles.png differ diff --git a/data/tilesets/secondary/sootopolis/palettes/15.pal b/data/tilesets/secondary/sootopolis/palettes/15.pal index e7717d74ea..ee115befc9 100644 --- a/data/tilesets/secondary/sootopolis/palettes/15.pal +++ b/data/tilesets/secondary/sootopolis/palettes/15.pal @@ -1,19 +1,19 @@ JASC-PAL 0100 16 -115 197 164 -255 213 180 -255 197 148 -222 148 115 -123 65 65 -57 74 123 -41 57 98 -24 41 82 -16 32 57 -222 230 238 -255 197 90 -189 156 90 -255 98 90 -197 65 65 +0 192 0 255 255 255 -0 0 0 +238 238 213 +222 222 180 +180 180 148 +131 131 139 +98 98 123 +65 74 106 +41 49 90 +244 226 171 +221 205 143 +156 164 156 +123 131 123 +98 106 98 +82 90 82 +248 240 176 diff --git a/gflib/sprite.c b/gflib/sprite.c index 443a1708a2..7c2b759b23 100644 --- a/gflib/sprite.c +++ b/gflib/sprite.c @@ -1500,6 +1500,21 @@ u16 LoadSpriteSheet(const struct SpriteSheet *sheet) } } +// Like LoadSpriteSheet, but checks if already, and uses template image frames +u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u8 frame) { + u16 tileStart; + struct SpriteSheet tempSheet; + // error if template is null or tile tag or images not set + if (!template || template->tileTag == TAG_NONE || !template->images) + return 0xFFFF; + if ((tileStart = GetSpriteTileStartByTag(template->tileTag)) != 0xFFFF) // return if already loaded + return tileStart; + tempSheet.data = template->images[frame].data; + tempSheet.size = template->images[frame].size; + tempSheet.tag = template->tileTag; + return LoadSpriteSheet(&tempSheet); +} + void LoadSpriteSheets(const struct SpriteSheet *sheets) { u8 i; @@ -1621,6 +1636,13 @@ void LoadSpritePalettes(const struct SpritePalette *palettes) break; } +u8 LoadSpritePaletteInSlot(const struct SpritePalette *palette, u8 paletteNum) { + paletteNum = min(15, paletteNum); + sSpritePaletteTags[paletteNum] = palette->tag; + DoLoadSpritePalette(palette->data, paletteNum * 16); + return paletteNum; +} + void DoLoadSpritePalette(const u16 *src, u16 paletteOffset) { LoadPalette(src, paletteOffset + 0x100, 32); diff --git a/gflib/sprite.h b/gflib/sprite.h index e53737981b..6b952ab4ee 100644 --- a/gflib/sprite.h +++ b/gflib/sprite.h @@ -296,6 +296,7 @@ void FreeOamMatrix(u8 matrixNum); void InitSpriteAffineAnim(struct Sprite *sprite); void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotation); u16 LoadSpriteSheet(const struct SpriteSheet *sheet); +u16 LoadSpriteSheetByTemplate(const struct SpriteTemplate *template, u8 frame); void LoadSpriteSheets(const struct SpriteSheet *sheets); u16 AllocTilesForSpriteSheet(struct SpriteSheet *sheet); void AllocTilesForSpriteSheets(struct SpriteSheet *sheets); @@ -309,6 +310,7 @@ void RequestSpriteSheetCopy(const struct SpriteSheet *sheet); u16 LoadSpriteSheetDeferred(const struct SpriteSheet *sheet); void FreeAllSpritePalettes(void); u8 LoadSpritePalette(const struct SpritePalette *palette); +u8 LoadSpritePaletteInSlot(const struct SpritePalette *palette, u8 paletteNum); void LoadSpritePalettes(const struct SpritePalette *palettes); u8 AllocSpritePalette(u16 tag); u8 IndexOfSpritePaletteTag(u16 tag); diff --git a/graphics/object_events/palettes/light.pal b/graphics/object_events/palettes/light.pal index 3beca89bdf..92a4477f76 100644 --- a/graphics/object_events/palettes/light.pal +++ b/graphics/object_events/palettes/light.pal @@ -2,18 +2,18 @@ JASC-PAL 0100 16 110 198 165 -255 213 18 -255 214 38 -254 217 39 -254 218 53 -255 220 65 -255 221 76 -255 223 86 -254 225 95 -254 228 104 -254 229 112 -254 230 120 -255 232 132 -255 235 148 -255 237 162 -255 240 176 +64 61 42 +77 73 50 +85 81 58 +100 94 66 +111 105 75 +119 112 77 +140 131 92 +154 145 103 +171 159 111 +186 174 123 +197 183 128 +209 195 139 +224 209 146 +234 219 155 +249 232 161 diff --git a/graphics/object_events/palettes/light2.pal b/graphics/object_events/palettes/light2.pal new file mode 100644 index 0000000000..3d61a3020d --- /dev/null +++ b/graphics/object_events/palettes/light2.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +106 202 166 +58 54 31 +67 62 33 +96 89 53 +110 102 57 +121 111 67 +128 119 66 +156 143 82 +166 155 96 +185 169 100 +199 183 112 +211 192 113 +223 203 123 +237 218 129 +247 227 137 +255 237 147 diff --git a/graphics/object_events/palettes/neon_light.pal b/graphics/object_events/palettes/neon_light.pal new file mode 100644 index 0000000000..dd287fc645 --- /dev/null +++ b/graphics/object_events/palettes/neon_light.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +104 203 168 +19 48 64 +35 87 115 +58 132 140 +69 156 166 +77 193 254 +106 239 254 +27 68 89 +64 22 19 +115 39 34 +166 57 49 +191 66 57 +222 77 67 +0 0 0 +0 0 0 +0 0 0 diff --git a/graphics/object_events/pics/misc/light.png b/graphics/object_events/pics/misc/light.png index d1a0402d10..22687a7c00 100644 Binary files a/graphics/object_events/pics/misc/light.png and b/graphics/object_events/pics/misc/light.png differ diff --git a/graphics/object_events/pics/misc/mart_light.png b/graphics/object_events/pics/misc/mart_light.png new file mode 100644 index 0000000000..7ec1a434ea Binary files /dev/null and b/graphics/object_events/pics/misc/mart_light.png differ diff --git a/graphics/object_events/pics/misc/poke_center_light.png b/graphics/object_events/pics/misc/poke_center_light.png new file mode 100644 index 0000000000..42d19f51c6 Binary files /dev/null and b/graphics/object_events/pics/misc/poke_center_light.png differ diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 72933582fc..aed2b671fa 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -242,6 +242,7 @@ #define OBJ_EVENT_GFX_HOOH 238 #define OBJ_EVENT_GFX_ANIMATED_BALL OBJ_EVENT_GFX_ITEM_BALL // replaces ITEM_BALL #define OBJ_EVENT_GFX_OW_MON OBJ_EVENT_GFX_REGICE +#define OBJ_EVENT_GFX_LIGHT_SPRITE OBJ_EVENT_GFX_QUINTY_PLUMP #define NUM_OBJ_EVENT_GFX 239 diff --git a/include/field_weather.h b/include/field_weather.h index 12265e7b6f..091080f549 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -153,6 +153,7 @@ void FadeScreen(u8 mode, s8 delay); bool8 IsWeatherNotFadingIn(void); void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex, bool8 allowFog); void ApplyWeatherGammaShiftToPal(u8 paletteIndex); +void ApplyWeatherGammaShiftToPals(u8 startPalIndex, u8 numPalettes); void LoadCustomWeatherSpritePalette(const u16 *palette); void ResetDroughtWeatherPaletteLoading(void); bool8 LoadDroughtWeatherPalettes(void); diff --git a/include/fieldmap.h b/include/fieldmap.h index a7c92fcad1..28da8da2a3 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -20,7 +20,6 @@ #include "main.h" extern struct BackupMapLayout gBackupMapLayout; -extern struct Coords16 gLightMetatiles[32]; u32 MapGridGetMetatileIdAt(int, int); u32 MapGridGetMetatileBehaviorAt(int, int); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 24e9e9ea53..9882428ce1 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -32,7 +32,8 @@ typedef void (*TilesetCB)(void); struct Tileset { - /*0x00*/ bool8 isCompressed; + /*0x00*/ u8 isCompressed:2; + /*0x00*/ u8 swapPalettes:6; // bitmask determining whether palette has an alternate, night-time palette /*0x01*/ bool8 isSecondary; /*0x02*/ u8 lightPalettes; // Bitmask determining whether a palette should be time-blended as a light /*0x03*/ u8 customLightColor; // Bitmask determining which light palettes have custom light colors (color 15) diff --git a/include/overworld.h b/include/overworld.h index 5061bb304d..33fa7e9f13 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -48,6 +48,8 @@ struct __attribute__((packed)) TimeBlendSettings { u16 weight:9; u16 time1:3; u16 time0:3; + u16 unused:1; + u16 altWeight; }; // Exported RAM declarations @@ -63,6 +65,7 @@ extern bool8 (*gFieldCallback2)(void); extern u8 gLocalLinkPlayerId; extern u8 gFieldLinkPlayerCount; extern u8 gTimeOfDay; +extern u16 gTimeUpdateCounter; extern struct TimeBlendSettings currentTimeBlend; @@ -145,6 +148,7 @@ void CB1_Overworld(void); void CB2_OverworldBasic(void); u8 UpdateTimeOfDay(void); bool8 MapHasNaturalLight(u8 mapType); +void UpdateAltBgPalettes(u16 palettes); void UpdatePalettesWithTime(u32); void CB2_Overworld(void); void SetMainCallback1(void (*cb)(void)); diff --git a/include/palette.h b/include/palette.h index abb00be6ca..c1b7dff550 100644 --- a/include/palette.h +++ b/include/palette.h @@ -86,6 +86,7 @@ void BlendPalettesGradually(u32 selectedPalettes, s8 delay, u8 coeff, u8 coeffTa void TimeBlendPalette(u16 palOffset, u32 coeff, u32 blendColor); void TintPalette_RGB_Copy(u16 palOffset, u32 blendColor); void TimeMixPalettes(u32, u16 *, u16 *, struct BlendSettings *, struct BlendSettings *, u16); +void AvgPaletteWeighted(u16 *src0, u16 *src1, u16 *dst, u16 weight0); void TintPalette_GrayScale(u16 *palette, u16 count); void TintPalette_GrayScale2(u16 *palette, u16 count); void TintPalette_SepiaTone(u16 *palette, u16 count); diff --git a/src/data/field_effects/field_effect_objects.h b/src/data/field_effects/field_effect_objects.h index 3af4af323a..219700cdd8 100755 --- a/src/data/field_effects/field_effect_objects.h +++ b/src/data/field_effects/field_effect_objects.h @@ -32,7 +32,41 @@ const struct SpriteFrameImage gFieldEffectObjectPicTable_BallLight[] = { obj_frame_tiles(gFieldEffectObjectPic_BallLight), }; -const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight = {TAG_NONE, OBJ_EVENT_PAL_TAG_LIGHT, &gObjectEventBaseOam_32x32, sAnimTable_Inanimate, gFieldEffectObjectPicTable_BallLight, gDummySpriteAffineAnimTable, UpdateLightSprite}; +const struct SpriteFrameImage gFieldEffectObjectPicTable_PokeCenterLight[] = { + obj_frame_tiles(gFieldEffectObjectPic_PokeCenterLight), +}; + +const struct SpriteFrameImage gFieldEffectObjectPicTable_MartLight[] = { + obj_frame_tiles(gFieldEffectObjectPic_MartLight), +}; + +const struct SpriteTemplate gFieldEffectObjectTemplate_BallLight = {OBJ_EVENT_PAL_TAG_LIGHT, OBJ_EVENT_PAL_TAG_LIGHT, &gObjectEventBaseOam_32x32, sAnimTable_Inanimate, gFieldEffectObjectPicTable_BallLight, gDummySpriteAffineAnimTable, UpdateLightSprite}; + +const struct SpriteTemplate gFieldEffectObjectTemplate_PokeCenterLight = { + .tileTag = TAG_NONE, + .paletteTag = OBJ_EVENT_PAL_TAG_NEON_LIGHT, + .oam = &gObjectEventBaseOam_16x16, + .anims = sAnimTable_Inanimate, + .images = gFieldEffectObjectPicTable_PokeCenterLight, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = UpdateLightSprite, +}; + +const struct SpriteTemplate gFieldEffectObjectTemplate_MartLight = { + .tileTag = TAG_NONE, + .paletteTag = OBJ_EVENT_PAL_TAG_NEON_LIGHT, + .oam = &gObjectEventBaseOam_16x16, + .anims = sAnimTable_Inanimate, + .images = gFieldEffectObjectPicTable_MartLight, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = UpdateLightSprite, +}; + +const struct SpriteTemplate *const gFieldEffectLightTemplates[] = { + &gFieldEffectObjectTemplate_BallLight, + &gFieldEffectObjectTemplate_PokeCenterLight, + &gFieldEffectObjectTemplate_MartLight, +}; const struct SpriteTemplate gFieldEffectObjectTemplate_ShadowSmall = { .tileTag = TAG_NONE, diff --git a/src/data/object_events/object_event_graphics.h b/src/data/object_events/object_event_graphics.h index 4f15ad59ed..67cc1edb56 100755 --- a/src/data/object_events/object_event_graphics.h +++ b/src/data/object_events/object_event_graphics.h @@ -282,6 +282,8 @@ const u32 gFieldEffectObjectPic_ShadowMedium[] = INCBIN_U32("graphics/field_effe const u32 gFieldEffectObjectPic_ShadowLarge[] = INCBIN_U32("graphics/field_effects/pics/shadow_large.4bpp"); const u32 gFieldEffectObjectPic_ShadowExtraLarge[] = INCBIN_U32("graphics/field_effects/pics/shadow_extra_large.4bpp"); const u32 gFieldEffectObjectPic_BallLight[] = INCBIN_U32("graphics/object_events/pics/misc/light.4bpp"); +const u32 gFieldEffectObjectPic_PokeCenterLight[] = INCBIN_U32("graphics/object_events/pics/misc/poke_center_light.4bpp"); +const u32 gFieldEffectObjectPic_MartLight[] = INCBIN_U32("graphics/object_events/pics/misc/mart_light.4bpp"); static const u32 sFiller[0x48] = {}; const u8 gFieldEffectPic_CutGrass[] = INCBIN_U8("graphics/field_effects/pics/cut_grass.4bpp"); const u32 gFieldEffectPic_CutGrass_Copy[] = INCBIN_U32("graphics/field_effects/pics/cut_grass.4bpp"); @@ -783,4 +785,6 @@ const u16 gObjectEventPal_HoOh[] = INCBIN_U16("graphics/object_events/palettes/h const u16 gObjectEventPal_Lugia[] = INCBIN_U16("graphics/object_events/palettes/lugia.gbapal"); const u16 gObjectEventPaletteLight[] = INCBIN_U16("graphics/object_events/palettes/light.gbapal"); +const u16 gObjectEventPaletteLight2[] = INCBIN_U16("graphics/object_events/palettes/light2.gbapal"); const u16 gObjectEventPaletteEmotes[] = INCBIN_U16("graphics/misc/emotes.gbapal"); +const u16 gObjectEventPaletteNeonLight[] = INCBIN_U16("graphics/object_events/palettes/neon_light.gbapal"); diff --git a/src/data/object_events/object_event_graphics_info.h b/src/data/object_events/object_event_graphics_info.h index 789fc7e178..16677f9bba 100755 --- a/src/data/object_events/object_event_graphics_info.h +++ b/src/data/object_events/object_event_graphics_info.h @@ -245,3 +245,5 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Lugia = {TAG_NONE, const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh = {TAG_NONE, OBJ_EVENT_PAL_TAG_HO_OH, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 10, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, sOamTables_32x32, sAnimTable_HoOh, sPicTable_HoOhOld, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall = {TAG_NONE, OBJ_EVENT_PAL_TAG_NPC_3, OBJ_EVENT_PAL_TAG_NONE, 256, 16, 32, 2, SHADOW_SIZE_M, TRUE, FALSE, TRACKS_NONE, &gObjectEventBaseOam_16x32, sOamTables_16x32, sAnimTable_Following, sPicTable_AnimatedBall, gDummySpriteAffineAnimTable}; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower = {TAG_NONE, OBJ_EVENT_PAL_TAG_DYNAMIC, OBJ_EVENT_PAL_TAG_NONE, 512, 32, 32, 2, SHADOW_SIZE_M, FALSE, FALSE, TRACKS_FOOT, &gObjectEventBaseOam_32x32, sOamTables_32x32, sAnimTable_Following, sPicTable_Togetic, gDummySpriteAffineAnimTable}; + +const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_BallLight = {TAG_NONE, OBJ_EVENT_PAL_TAG_LIGHT, OBJ_EVENT_PAL_TAG_LIGHT_2, 512, 32, 32, 2, SHADOW_SIZE_NONE, TRUE, FALSE, TRACKS_NONE, &gObjectEventBaseOam_32x32, sOamTables_32x32, sAnimTable_Inanimate, gFieldEffectObjectPicTable_BallLight, gDummySpriteAffineAnimTable}; diff --git a/src/data/object_events/object_event_graphics_info_pointers.h b/src/data/object_events/object_event_graphics_info_pointers.h index 4db5967088..a69f11cede 100755 --- a/src/data/object_events/object_event_graphics_info_pointers.h +++ b/src/data/object_events/object_event_graphics_info_pointers.h @@ -240,6 +240,7 @@ const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_HoOh; // Begin pokemon event objects const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_AnimatedBall; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Follower; +const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_BallLight; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Bard; const struct ObjectEventGraphicsInfo gObjectEventGraphicsInfo_Hipster; @@ -255,7 +256,7 @@ const struct ObjectEventGraphicsInfo *const gObjectEventGraphicsInfoPointers[NUM [OBJ_EVENT_GFX_BRENDAN_MACH_BIKE] = &gObjectEventGraphicsInfo_BrendanMachBike, [OBJ_EVENT_GFX_BRENDAN_SURFING] = &gObjectEventGraphicsInfo_BrendanSurfing, [OBJ_EVENT_GFX_BRENDAN_FIELD_MOVE] = &gObjectEventGraphicsInfo_BrendanFieldMove, - [OBJ_EVENT_GFX_QUINTY_PLUMP] = &gObjectEventGraphicsInfo_QuintyPlump, + // [OBJ_EVENT_GFX_QUINTY_PLUMP] = &gObjectEventGraphicsInfo_QuintyPlump, [OBJ_EVENT_GFX_NINJA_BOY] = &gObjectEventGraphicsInfo_NinjaBoy, [OBJ_EVENT_GFX_TWIN] = &gObjectEventGraphicsInfo_Twin, [OBJ_EVENT_GFX_BOY_1] = &gObjectEventGraphicsInfo_Boy1, @@ -492,6 +493,7 @@ const struct ObjectEventGraphicsInfo *const gObjectEventGraphicsInfoPointers[NUM [OBJ_EVENT_GFX_HOOH] = &gObjectEventGraphicsInfo_HoOh, [OBJ_EVENT_GFX_ANIMATED_BALL] = &gObjectEventGraphicsInfo_AnimatedBall, [OBJ_EVENT_GFX_OW_MON] = &gObjectEventGraphicsInfo_Follower, + [OBJ_EVENT_GFX_LIGHT_SPRITE] = &gObjectEventGraphicsInfo_BallLight, }; const struct ObjectEventGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[] = { diff --git a/src/data/object_events/object_event_pic_tables.h b/src/data/object_events/object_event_pic_tables.h index 76da0b0c62..baed5cc479 100755 --- a/src/data/object_events/object_event_pic_tables.h +++ b/src/data/object_events/object_event_pic_tables.h @@ -1990,6 +1990,8 @@ static const struct SpriteFrameImage sPicTable_AnimatedBall[] = { overworld_frame(gObjectEventPic_AnimatedBall, 2, 4, 5), }; +extern const struct SpriteFrameImage gFieldEffectObjectPicTable_BallLight[]; + static const struct SpriteFrameImage sPicTable_Bulbasaur[] = { overworld_frame(gObjectEventPic_Bulbasaur, 4, 4, 0), overworld_frame(gObjectEventPic_Bulbasaur, 4, 4, 1), diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 517b114d13..c3eb81622a 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -455,7 +455,9 @@ const u8 gInitialMovementTypeFacingDirections[] = { #define OBJ_EVENT_PAL_TAG_RS_MAY 0x1123 #define OBJ_EVENT_PAL_TAG_DYNAMIC 0x1124 #define OBJ_EVENT_PAL_TAG_LIGHT 0x8001 -#define OBJ_EVENT_PAL_TAG_EMOTES 0x8002 +#define OBJ_EVENT_PAL_TAG_LIGHT_2 0x8002 +#define OBJ_EVENT_PAL_TAG_EMOTES 0x8003 +#define OBJ_EVENT_PAL_TAG_NEON_LIGHT 0x8004 #define OBJ_EVENT_PAL_TAG_NONE 0x11FF #include "data/object_events/object_event_graphics_info_pointers.h" @@ -505,7 +507,9 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = { {gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY}, {gObjectEventPal_Npc1, OBJ_EVENT_PAL_TAG_DYNAMIC}, {gObjectEventPaletteLight, OBJ_EVENT_PAL_TAG_LIGHT}, + {gObjectEventPaletteLight2, OBJ_EVENT_PAL_TAG_LIGHT_2}, {gObjectEventPaletteEmotes, OBJ_EVENT_PAL_TAG_EMOTES}, + {gObjectEventPaletteNeonLight, OBJ_EVENT_PAL_TAG_NEON_LIGHT}, {NULL, 0x0000}, }; @@ -1975,84 +1979,122 @@ bool8 ScrFunc_followerfly(struct ScriptContext *ctx) { // Sprite callback for light sprites void UpdateLightSprite(struct Sprite *sprite) { - s16 left = gSaveBlock1Ptr->pos.x - 2; - s16 right = gSaveBlock1Ptr->pos.x + 17; - s16 top = gSaveBlock1Ptr->pos.y; - s16 bottom = gSaveBlock1Ptr->pos.y + 15; - s16 x = sprite->data[6]; - s16 y = sprite->data[7]; - u16 sheetTileStart; - u32 paletteNum; - bool8 finished = TRUE; - // Ripped from RemoveObjectEventIfOutsideView - if (x >= left && x <= right - && y >= top && y <= bottom) - finished = FALSE; - finished = finished ? finished : gTimeOfDay != TIME_OF_DAY_NIGHT; - if (finished) { - sheetTileStart = sprite->sheetTileStart; - paletteNum = sprite->oam.paletteNum; - DestroySprite(sprite); - FieldEffectFreeTilesIfUnused(sheetTileStart); - FieldEffectFreePaletteIfUnused(paletteNum); - Weather_SetBlendCoeffs(7, 12); // TODO: Restore original blend coeffs at dawn - return; - } + s16 left = gSaveBlock1Ptr->pos.x - 2; + s16 right = gSaveBlock1Ptr->pos.x + 17; + s16 top = gSaveBlock1Ptr->pos.y; + s16 bottom = gSaveBlock1Ptr->pos.y + 15; + s16 x = sprite->data[6]; + s16 y = sprite->data[7]; + u16 sheetTileStart; + u32 paletteNum; + // Ripped from RemoveObjectEventIfOutsideView + if (!(x >= left && x <= right && y >= top && y <= bottom)) { + sheetTileStart = sprite->sheetTileStart; + paletteNum = sprite->oam.paletteNum; + DestroySprite(sprite); + FieldEffectFreeTilesIfUnused(sheetTileStart); + FieldEffectFreePaletteIfUnused(paletteNum); + Weather_SetBlendCoeffs(7, 12); // TODO: Restore original blend coeffs at dawn + return; + } - if (gPlayerAvatar.tileTransitionState) { // As long as the second coefficient stays 12, shadows will not change - Weather_SetBlendCoeffs(7, 12); - sprite->invisible = FALSE; - } else { - Weather_SetBlendCoeffs(12, 12); - sprite->invisible = gSaveBlock2Ptr->playTimeVBlanks & 1; - } + if (gTimeOfDay != TIME_OF_DAY_NIGHT) { + sprite->invisible = TRUE; + return; + } + + switch (sprite->data[5]) { // lightType + case 0: + if (gPaletteFade.active) { // if palette fade is active, don't flicker since the timer won't be updated + Weather_SetBlendCoeffs(7, 12); + sprite->invisible = FALSE; + } else if (gPlayerAvatar.tileTransitionState) { + Weather_SetBlendCoeffs(7, 12); // As long as the second coefficient stays 12, shadows will not change + sprite->invisible = FALSE; + if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT_2) + LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT)], sprite->oam.paletteNum); + } else if ((sprite->invisible = gTimeUpdateCounter & 1)) { + Weather_SetBlendCoeffs(12, 12); + if (GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum) == OBJ_EVENT_PAL_TAG_LIGHT) + LoadSpritePaletteInSlot(&sObjectEventSpritePalettes[FindObjectEventPaletteIndexByTag(OBJ_EVENT_PAL_TAG_LIGHT_2)], sprite->oam.paletteNum); + } + break; + case 1 ... 2: + Weather_SetBlendCoeffs(12, 12); + sprite->invisible = FALSE; + break; + } } -// Spawn a light at a map coordinate based on metatile behavior -static void SpawnLightSprite(s16 x, s16 y, s16 camX, s16 camY, u32 behavior) { - struct Sprite *sprite; - u8 i; - for (i = 0; i < MAX_SPRITES; i++) { - sprite = &gSprites[i]; - if (sprite->inUse && sprite->callback == UpdateLightSprite && sprite->data[6] == x && sprite->data[7] == y) - return; - } - sprite = &gSprites[CreateSprite(&gFieldEffectObjectTemplate_BallLight, 0, 0, 0)]; - UpdateSpritePaletteByTemplate(&gFieldEffectObjectTemplate_BallLight, sprite); - GetMapCoordsFromSpritePos(x + camX, y + camY, &sprite->x, &sprite->y); - sprite->data[6] = x; - sprite->data[7] = y; - sprite->affineAnims = gDummySpriteAffineAnimTable; - sprite->affineAnimBeginning = TRUE; - sprite->centerToCornerVecX = -(32 >> 1); - sprite->centerToCornerVecY = -(32 >> 1); - sprite->oam.priority = 1; - sprite->oam.objMode = 1; // BLEND - sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; - sprite->coordOffsetEnabled = TRUE; - sprite->x += 8; - sprite->y += 22 + sprite->centerToCornerVecY; +// Spawn a light at a map coordinate +static void SpawnLightSprite(s16 x, s16 y, s16 camX, s16 camY, u32 lightType) { + struct Sprite *sprite; + const struct SpriteTemplate *template; + u8 i; + for (i = 0; i < MAX_SPRITES; i++) { + sprite = &gSprites[i]; + if (sprite->inUse && sprite->callback == UpdateLightSprite && sprite->data[6] == x && sprite->data[7] == y) + return; + } + lightType = min(lightType, ARRAY_COUNT(gFieldEffectLightTemplates) - 1); // bounds checking + template = gFieldEffectLightTemplates[lightType]; + LoadSpriteSheetByTemplate(template, 0); + sprite = &gSprites[CreateSprite(template, 0, 0, 0)]; + if (lightType == 0 && (i = IndexOfSpritePaletteTag(template->paletteTag + 1)) < 16) + sprite->oam.paletteNum = i; + else + UpdateSpritePaletteByTemplate(template, sprite); + GetMapCoordsFromSpritePos(x + camX, y + camY, &sprite->x, &sprite->y); + sprite->data[5] = lightType; + sprite->data[6] = x; + sprite->data[7] = y; + sprite->affineAnims = gDummySpriteAffineAnimTable; + sprite->affineAnimBeginning = TRUE; + sprite->coordOffsetEnabled = TRUE; + switch (lightType) { + case 0: // Rustboro lanterns + sprite->centerToCornerVecX = -(32 >> 1); + sprite->centerToCornerVecY = -(32 >> 1); + sprite->oam.priority = 1; + sprite->oam.objMode = 1; // BLEND + sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; + sprite->x += 8; + sprite->y += 22 + sprite->centerToCornerVecY; + break; + case 1 ... 2: // Pokemon Center & mart + sprite->centerToCornerVecX = -(16 >> 1); + sprite->centerToCornerVecY = -(16 >> 1); + sprite->oam.priority = 2; + sprite->subpriority = 0xFF; + sprite->oam.objMode = 1; // BLEND + } } void TrySpawnLightSprites(s16 camX, s16 camY) { - s16 left = gSaveBlock1Ptr->pos.x - 2; - s16 right = gSaveBlock1Ptr->pos.x + 17; - s16 top = gSaveBlock1Ptr->pos.y; - s16 bottom = gSaveBlock1Ptr->pos.y + 16; - u8 i = 0; - s16 x, y; - u32 behavior; - if (gTimeOfDay != TIME_OF_DAY_NIGHT) - return; - for (i = 0; gLightMetatiles[i].x > 0; i++) { - x = gLightMetatiles[i].x; - y = gLightMetatiles[i].y; - if (x >= left && x <= right && y >= top && y <= bottom) { - behavior = MapGridGetMetatileBehaviorAt(x, y); - if (behavior == 0x04) // TODO: Use an actual constant for light metatiles - SpawnLightSprite(x, y, camX, camY, behavior); + u8 i; + u8 objectCount; + s16 left = gSaveBlock1Ptr->pos.x - 2; + s16 right = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2; + s16 top = gSaveBlock1Ptr->pos.y; + s16 bottom = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H + 2; + if (gMapHeader.events == NULL) + return; + + if (InBattlePyramid()) + objectCount = GetNumBattlePyramidObjectEvents(); + else if (InTrainerHill()) + objectCount = 2; + else + objectCount = gMapHeader.events->objectEventCount; + + for (i = 0; i < objectCount; i++) { + struct ObjectEventTemplate *template = &gSaveBlock1Ptr->objectEventTemplates[i]; + s16 npcX = template->x + MAP_OFFSET; + s16 npcY = template->y + MAP_OFFSET; + if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX && !FlagGet(template->flagId)) + if (template->graphicsId == OBJ_EVENT_GFX_LIGHT_SPRITE) // event is light sprite instead + SpawnLightSprite(npcX, npcY, camX, camY, template->trainerRange_berryTreeId); } - } } void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) @@ -2080,12 +2122,14 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) s16 npcX = template->x + MAP_OFFSET; s16 npcY = template->y + MAP_OFFSET; - if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX - && !FlagGet(template->flagId)) - TrySpawnObjectEventTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); + if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX && !FlagGet(template->flagId)) { + if (template->graphicsId == OBJ_EVENT_GFX_LIGHT_SPRITE) { // light sprite instead + SpawnLightSprite(npcX, npcY, cameraX, cameraY, template->trainerRange_berryTreeId); + } else + TrySpawnObjectEventTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY); + } } } - TrySpawnLightSprites(cameraX, cameraY); } void RemoveObjectEventsOutsideView(void) diff --git a/src/field_weather.c b/src/field_weather.c index 2c0fc5ca8c..fb07ec41f2 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -466,18 +466,21 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) if (gammaIndex > 0) { + // Create the palette mask + u32 palettes = PALETTES_ALL; + numPalettes += startPalIndex; + palettes = (palettes >> startPalIndex) << startPalIndex; + palettes = (palettes << (32-numPalettes)) >> (32-numPalettes); + numPalettes -= startPalIndex; gammaIndex--; palOffset = startPalIndex * 16; - CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 32 * numPalettes); - numPalettes += startPalIndex; + UpdateAltBgPalettes(palettes & PALETTES_BG); // Thunder gamma-shift looks bad on night-blended palettes, so ignore time blending in some situations - if (!(gammaIndex > 3 && gWeatherPtr->currWeather == WEATHER_RAIN_THUNDERSTORM)) { - // Create the palette mask - u32 palettes = PALETTES_ALL; - palettes = (palettes >> startPalIndex) << startPalIndex; - palettes = (palettes << (32-numPalettes)) >> (32-numPalettes); + if (!(gammaIndex > 3 && gWeatherPtr->currWeather == WEATHER_RAIN_THUNDERSTORM) && MapHasNaturalLight(gMapHeader.mapType)) UpdatePalettesWithTime(palettes); - } + else + CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 32 * numPalettes); + numPalettes += startPalIndex; curPalIndex = startPalIndex; // Loop through the speficied palette range and apply necessary gamma shifts to the colors. while (curPalIndex < numPalettes) @@ -546,6 +549,7 @@ static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) numPalettes += startPalIndex; palettes = (palettes >> startPalIndex) << startPalIndex; palettes = (palettes << (32-numPalettes)) >> (32-numPalettes); + UpdateAltBgPalettes(palettes & PALETTES_BG); UpdatePalettesWithTime(palettes); } else { // copy CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16)); @@ -570,6 +574,7 @@ static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaI while (curPalIndex < numPalettes) { + UpdateAltBgPalettes((1 << (palOffset >> 4)) & PALETTES_BG); CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16)); UpdatePalettesWithTime(1 << (palOffset >> 4)); // Apply TOD blend if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) @@ -670,6 +675,7 @@ static void ApplyFogBlend(u8 blendCoeff, u16 blendColor) // TODO: Optimize this u16 curPalIndex; // First blend all palettes with time + UpdateAltBgPalettes(PALETTES_BG); CpuFastCopy(gPlttBufferUnfaded, gPlttBufferFaded, 0x400); UpdatePalettesWithTime(PALETTES_ALL); // Then blend tile palettes [0, 12] faded->faded @@ -816,6 +822,7 @@ void FadeScreen(u8 mode, s8 delay) gWeatherPtr->fadeScreenCounter = 0; // Triggers gamma-shift-based fade-in else { if (MapHasNaturalLight(gMapHeader.mapType)) { + UpdateAltBgPalettes(PALETTES_BG); BeginTimeOfDayPaletteFade(PALETTES_ALL, delay, 16, 0, (struct BlendSettings *)&gTimeOfDayBlend[currentTimeBlend.time0], (struct BlendSettings *)&gTimeOfDayBlend[currentTimeBlend.time1], @@ -883,11 +890,15 @@ void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex, bool8 allowFog) } } -void ApplyWeatherGammaShiftToPal(u8 paletteIndex) +void ApplyWeatherGammaShiftToPal(u8 paletteIndex) // now unused / obselete { ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex); } +void ApplyWeatherGammaShiftToPals(u8 startPalIndex, u8 numPalettes) { + ApplyGammaShift(startPalIndex, numPalettes, gWeatherPtr->gammaIndex); +} + // Unused static bool8 IsFirstFrameOfWeatherFadeIn(void) { diff --git a/src/fieldmap.c b/src/fieldmap.c index 245562c93f..7fb479ae26 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -30,7 +30,6 @@ EWRAM_DATA struct MapHeader gMapHeader = {0}; EWRAM_DATA struct Camera gCamera = {0}; EWRAM_DATA static struct ConnectionFlags gMapConnectionFlags = {0}; EWRAM_DATA static u32 sFiller = 0; // without this, the next file won't align properly -EWRAM_DATA struct Coords16 gLightMetatiles[32] = {0}; struct BackupMapLayout gBackupMapLayout; @@ -63,7 +62,6 @@ static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, #define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height) #define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : MapGridGetBorderTileAt(x, y)) -static void CacheLightMetatiles(void); struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection) { @@ -75,7 +73,6 @@ void InitMap(void) InitMapLayoutData(&gMapHeader); SetOccupiedSecretBaseEntranceMetatiles(gMapHeader.events); RunOnLoadMapScript(); - CacheLightMetatiles(); } void InitMapFromSavedGame(void) @@ -85,7 +82,6 @@ void InitMapFromSavedGame(void) SetOccupiedSecretBaseEntranceMetatiles(gMapHeader.events); LoadSavedMapView(); RunOnLoadMapScript(); - CacheLightMetatiles(); UpdateTVScreensOnMap(gBackupMapLayout.width, gBackupMapLayout.height); } @@ -382,23 +378,6 @@ u32 MapGridGetMetatileBehaviorAt(int x, int y) return GetBehaviorByMetatileId(metatile) & METATILE_BEHAVIOR_MASK; } -// Caches light metatile coordinates -static void CacheLightMetatiles(void) { // TODO: Better way to dynamically generate lights - u8 i = 0; - s16 x, y; - for (x = 0; x < gBackupMapLayout.width; x++) { - for (y = 0; y < gBackupMapLayout.height; y++) { - if (MapGridGetMetatileBehaviorAt(x, y) == 0x04) { - gLightMetatiles[i].x = x; - gLightMetatiles[i].y = y; - i++; - } - } - } - gLightMetatiles[i].x = -1; - gLightMetatiles[i].y = -1; -} - u8 MapGridGetMetatileLayerTypeAt(int x, int y) { u16 metatile = MapGridGetMetatileIdAt(x, y); diff --git a/src/overworld.c b/src/overworld.c index b9b69acffd..332fa6d8c7 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -184,7 +184,6 @@ static u16 (*sPlayerKeyInterceptCallback)(u32); static bool8 sReceivingFromLink; static u8 sRfuKeepAliveTimer; -static u16 sTimeUpdateCounter; // playTimeVBlanks will eventually overflow, so this is used to update TOD // IWRAM common @@ -199,6 +198,7 @@ u8 gFieldLinkPlayerCount; u8 gTimeOfDay; struct TimeBlendSettings currentTimeBlend; +u16 gTimeUpdateCounter; // playTimeVBlanks will eventually overflow, so this is used to update TOD // EWRAM vars EWRAM_DATA static u8 sObjectEventLoadFlag = 0; @@ -822,8 +822,7 @@ void LoadMapFromCameraTransition(u8 mapGroup, u8 mapNum) CopySecondaryTilesetToVramUsingHeap(gMapHeader.mapLayout); LoadSecondaryTilesetPalette(gMapHeader.mapLayout); - for (paletteIndex = 6; paletteIndex < 13; paletteIndex++) // TODO: Optimize gamma shifts - ApplyWeatherGammaShiftToPal(paletteIndex); + ApplyWeatherGammaShiftToPals(6, 6); // palettes [6,12] InitSecondaryTilesetAnimation(); UpdateLocationHistoryForRoamer(); @@ -1481,29 +1480,34 @@ u8 UpdateTimeOfDay(void) { minutes = gLocalTime.minutes; if (hours >= 22 || hours < 4) { // night currentTimeBlend.weight = 256; + currentTimeBlend.altWeight = 0; return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_NIGHT; } else if (hours >= 4 && hours < 7) { // night->twilight currentTimeBlend.time0 = TIME_OF_DAY_NIGHT; currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT; currentTimeBlend.weight = 256 - 256 * ((hours - 4) * 60 + minutes) / ((7-4)*60); + currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2; return gTimeOfDay = TIME_OF_DAY_DAY; } else if (hours >= 7 && hours < 10) { // twilight->day currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT; currentTimeBlend.time1 = TIME_OF_DAY_DAY; currentTimeBlend.weight = 256 - 256 * ((hours - 7) * 60 + minutes) / ((10-7)*60); + currentTimeBlend.altWeight = (256 - currentTimeBlend.weight) / 2 + 128; return gTimeOfDay = TIME_OF_DAY_DAY; } else if (hours >= 10 && hours < 18) { // day - currentTimeBlend.weight = 256; + currentTimeBlend.weight = currentTimeBlend.altWeight = 256; return gTimeOfDay = currentTimeBlend.time0 = currentTimeBlend.time1 = TIME_OF_DAY_DAY; } else if (hours >= 18 && hours < 20) { // day->twilight currentTimeBlend.time0 = TIME_OF_DAY_DAY; currentTimeBlend.time1 = TIME_OF_DAY_TWILIGHT; currentTimeBlend.weight = 256 - 256 * ((hours - 18) * 60 + minutes) / ((20-18)*60); + currentTimeBlend.altWeight = currentTimeBlend.weight / 2 + 128; return gTimeOfDay = TIME_OF_DAY_TWILIGHT; } else if (hours >= 20 && hours < 22) { // twilight->night currentTimeBlend.time0 = TIME_OF_DAY_TWILIGHT; currentTimeBlend.time1 = TIME_OF_DAY_NIGHT; currentTimeBlend.weight = 256 - 256 * ((hours - 20) * 60 + minutes) / ((22-20)*60); + currentTimeBlend.altWeight = currentTimeBlend.weight / 2; return gTimeOfDay = TIME_OF_DAY_NIGHT; } else { // This should never occur currentTimeBlend.weight = 256; @@ -1516,16 +1520,41 @@ bool8 MapHasNaturalLight(u8 mapType) { // Whether a map type is naturally lit/ou || mapType == MAP_TYPE_OCEAN_ROUTE; } +// Update & mix day / night bg palettes (into unfaded) +void UpdateAltBgPalettes(u16 palettes) { + struct Tileset *primary = gMapHeader.mapLayout->primaryTileset; + struct Tileset *secondary = gMapHeader.mapLayout->secondaryTileset; + u32 i = 1; + if (!MapHasNaturalLight(gMapHeader.mapType)) + return; + palettes &= ~((1 << NUM_PALS_IN_PRIMARY) - 1) | primary->swapPalettes; + palettes &= ((1 << NUM_PALS_IN_PRIMARY) - 1) | (secondary->swapPalettes << NUM_PALS_IN_PRIMARY); + palettes &= 0x1FFE; // don't blend palette 0, [13,15] + palettes >>= 1; // start at palette 1 + if (!palettes) + return; + while (palettes) { + if (palettes & 1) { + if (i < NUM_PALS_IN_PRIMARY) + AvgPaletteWeighted(&((u16*)primary->palettes)[i*16], &((u16*)primary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, currentTimeBlend.altWeight); + else + AvgPaletteWeighted(&((u16*)secondary->palettes)[i*16], &((u16*)secondary->palettes)[((i+9)%16)*16], gPlttBufferUnfaded + i * 16, currentTimeBlend.altWeight); + } + i++; + palettes >>= 1; + } +} + void UpdatePalettesWithTime(u32 palettes) { if (MapHasNaturalLight(gMapHeader.mapType)) { - u16 i; - u16 tempPaletteBuffer[16]; + u32 i; u32 mask = 1 << 16; - for (i = 0; i < 16; i++, mask <<= 1) { - if (GetSpritePaletteTagByPaletteNum(i) >> 15) // Don't blend special sprite palette tags - palettes &= ~(mask); - } - palettes &= 0xFFFF1FFF; // Don't blend tile palettes [13,15] + if (palettes >= 0x10000) + for (i = 0; i < 16; i++, mask <<= 1) + if (GetSpritePaletteTagByPaletteNum(i) >> 15) // Don't blend special sprite palette tags + palettes &= ~(mask); + + palettes &= 0xFFFF1FFF; // Don't blend UI BG palettes [13,15] if (!palettes) return; TimeMixPalettes(palettes, @@ -1565,18 +1594,20 @@ static void OverworldBasic(void) UpdateTilesetAnimations(); DoScheduledBgTilemapCopiesToVram(); // Every minute if no palette fade is active, update TOD blending as needed - if (!(gPaletteFade.active || (++sTimeUpdateCounter % 3600))) { + if (!(gPaletteFade.active || (++gTimeUpdateCounter % 3600))) { struct TimeBlendSettings cachedBlend = { .time0 = currentTimeBlend.time0, .time1 = currentTimeBlend.time1, .weight = currentTimeBlend.weight, }; - sTimeUpdateCounter = 0; + gTimeUpdateCounter = 0; UpdateTimeOfDay(); if (cachedBlend.time0 != currentTimeBlend.time0 || cachedBlend.time1 != currentTimeBlend.time1 - || cachedBlend.weight != currentTimeBlend.weight) - UpdatePalettesWithTime(PALETTES_ALL); + || cachedBlend.weight != currentTimeBlend.weight) { + UpdateAltBgPalettes(PALETTES_BG); + UpdatePalettesWithTime(PALETTES_ALL); + } } } diff --git a/src/palette.c b/src/palette.c index 9ea27d0f25..2c9db82e25 100644 --- a/src/palette.c +++ b/src/palette.c @@ -1211,6 +1211,31 @@ void TimeMixPalettes(u32 palettes, u16 *src, u16 *dst, struct BlendSettings *ble } while (palettes); } +// Apply weighted average to palettes, preserving high bits of dst throughout +void AvgPaletteWeighted(u16 *src0, u16 *src1, u16 *dst, u16 weight0) { + u16 *srcEnd = src0 + 16; + u16 weight1 = 256 - weight0; + src0++; + src1++; + dst++; // leave dst transparency unchanged + while (src0 != srcEnd) { + u32 src0Color = *src0++; + s32 r0 = (src0Color << 27) >> 27; + s32 g0 = (src0Color << 22) >> 27; + s32 b0 = (src0Color << 17) >> 27; + u32 src1Color = *src1++; + s32 r1 = (src1Color << 27) >> 27; + s32 g1 = (src1Color << 22) >> 27; + s32 b1 = (src1Color << 17) >> 27; + + // Average and bitwise-OR + r0 = (weight0*r0 + weight1*r1) >> 8; + g0 = (weight0*g0 + weight1*g1) >> 8; + b0 = (weight0*b0 + weight1*b1) >> 8; + *dst++ = (*dst & 0x8000) | RGB2(r0, g0, b0); // preserve high bit of dst + } +} + void BlendPalettesUnfaded(u32 selectedPalettes, u8 coeff, u16 color) { void *src = gPlttBufferUnfaded; diff --git a/src/trainer_see.c b/src/trainer_see.c index 3bf4e0c2fd..0e478c9415 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -287,7 +287,7 @@ static const union AnimCmd *const sSpriteAnimTable_Emotes[] = { // TODO: Move these declarations into even_object_movement.h #define OBJ_EVENT_PAL_TAG_MAY 0x1110 -#define OBJ_EVENT_PAL_TAG_EMOTES 0x8002 +#define OBJ_EVENT_PAL_TAG_EMOTES 0x8003 static const struct SpriteTemplate sSpriteTemplate_ExclamationQuestionMark = {