• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Not quite a day night cycle (Fire Red)

  • 6
    Posts
    3
    Years
    • Seen Oct 10, 2021
    Hey so when I started reading into rom hacking I made the mistake of learning up on binary hacking when I really should have started reading up on this! Anyway I just wanted to feel out what is and what isn't currently considered possible with hacking currently. Honestly the game I have in mind isn't crazy ambitious mechanics wise, but there is one thing I have my heart set on doing and I just wanted to hear what you guys thought.
    So I do want day and night to be in my game, but I don't want a real clock or in game clock day night cycle. What I really want is some flag or variable I can set in a script that will cause the game to access an entirely separate set of the 12 map pallets. That way if an event happens I can jump to night, or have the players bed or beds at the pokemon center give the option to sleep until day or night. I figure if it's a variable or something I could jerry rig Embreon and Umbreon just fine too. Back when I was looking at binary hacking I saw that the DNS had options for different seasons tilesets and maybe I could use something to that effect.
    The thing is beyond advanced map I don't know how how how the game reads and writes tilesets, so I have no idea how achievable/unachievable this is. If the base rom goes to a certain stretch of values for the maps 12 pallets, how impossible can it be to create another set of 12 pallets and have the game use those when some variable is set to night? (I think this is preferable to using a blue filter like the DNS tool in binary hacking because a) I just don't like the look b) this way I could fix the palettes to have the lights on in houses and on lamps. Still, completely talking rubbish. What do you guys think?

    Thanks!
     
    sure, it sounds possible!

    the 12 palettes you're referring to are actually discrete palette files - like, you can go into a folder in your decomp project and see "palette1.pal, palette2.pal" (or whatever they're actually called) and so on - so it will be very easy to define your own palettes. then it's a matter of finding the code that loads these palettes, and figuring out how to convince it to load different palette files instead, after checking the value stored in a global variable. on first glance, that doesn't sound like a very difficult problem to me. what's your coding experience atm? do you need any help finding the relevant code?

    also, have you considered NPC palettes? they might look odd if they're still just as bright at nighttime, but changing them would likely require a whole system as well.
     
    Oh you're a god send. It's really reassuring that you think it's an easy fix. Experience wise I've mostly only used coding in my university assignments, so python and c++. Not completely uninitiated, and probably a quick enough learner, but far from an expert. If you have the time to point me to the right part of the code I'd greatly appreciate it. You raise a very good point about the npc pallets. It shouldn't be much harder than setting the map pallets (well, save for the fact that npcs will have waaay more pallets than the overworld, but hey).

    Thanks again!!
     
    so, there's a few relevant sections of code for this problem. i'm not really sure what the best way of editing them is, it will depend on your approach.

    src/graphics.c is where the palettes for other tilesets are included in the code. you can find sections like "const u16 gTilesetPalettes_General[][16] =" with a bunch of lines showing file paths to the palette files. so you'll definitely need to copy this style to include your own palette files.

    include/global.fieldmap.h has the definition for the Tileset struct. if you scroll down to "struct Tileset" you can see all the properties that are associated with a tileset. depending on your approach, you might want to edit this. for example, you can consider adding "bool8 doDayNightCycle" and "void *nightPalettes" and "void *mornPalettes". there are advantages and disadvantages to this, but i think it would make the palette loading code easy to write.

    data/tilesets/headers.inc is the data file for which tilesets have which properties. so if you edit the tileset struct, you'll also want to edit this. you can add ".byte TRUE" for the "doDayNightCycle" property, and ".4byte yourPaletteName" with the name of the palette as you wrote it in graphics.c. ofc, you will have to add these properties to every single tileset, so that's the downside of editing the tileset struct. if you have a property for "nightPalettes" but you have, e.g., an indoor tileset that doesn't change at night, i think you can write ".4byte 0x0" to leave that field empty.

    if you DON'T edit the tileset struct, you will also want to look at include/graphics.h. just add a line like the other "extern const" lines with the name of your palette array as you added it in graphics.c. the base tileset palettes aren't included in this file, because their names are never referred to by other C code, but you may want to take an approach that does refer to their names in C code.

    src/fieldmap.c is where all the palette loading code is. it contains a function "void apply_map_tileset1_tileset2_palette(struct MapLayout const *mapLayout)" which gets called a number of times in src/overworld.c. so basically, whenever the game needs to load map palettes, it calls this apply_map_tileset1_tileset2_palette function. the function itself just calls other separate functions for the primary and secondary tilesets, and both of those functions call the same function: "static void apply_map_tileset_palette(struct Tileset const *tileset, u16 destOffset, u16 size)". inside THAT function, you'll see some calls to a function called "LoadPalette". in the base game, these LoadPalette calls are set up to load from the tileset struct's palettes pointer property. so you're going to have to write some logic to get them to load from somewhere else under specific conditions.

    i hope this provides you some guidance, let me know if you get stuck!
     
    Hey this was incredibly helpful, I feel like I have a way better grasp of what I need to do and learn now, thank you so much! so I've only just realized I cannot even edit those pallet files with what I currently have, I went around looking for some decomp tools but really haven't seen anything other than porymap. Did you have any recommendations on how to edit pal files? Figure I'll need to make the night pallets if I'm going to jam them into the game. Btw I think I'm going with the first method you suggested.

    Thanks again!
     
    palette files are really simple files, you can open them in a text editor and see it's basically just a header followed by a bunch of RGB colour values. however if you want something more visual, i recommend graphics gale. it can export .pal files. so you can open up the tileset, make your modifications, and instead of saving the image, just export the .pal files.
     
    Phenomenal. I also started using a bunch of different layers in photoshop to dye any tileset to a night time pallet, I'm setting it up so that I'll take the rgb codes, throw them in photoshop, take the rgb codes from the night time version, and throw them into duplicate primary and secondary folders, (named nprimary and nsecondary). That way when I am coding the redirection to the night time pallets I have to make minimal changes. I've struggled to find any of the overworld sprites in the decomp files for some reason. I was wondering if you knew what the address for those were.

    I realised there was going to be a knack when colouring the overworld sprites properly too, since indoors will never be dark I can simply just avoid altering the pallets of the indoors in the night time folders, but with the npcs their colouring will also depend on if they are in a building or not. Do you think that will complicate things very much?

    Thanks again for all the advice so far
     
    glad to hear you're making progress! if you get this working i'd love to see the results, it sounds like a fun project.

    overworld NPC sprites and palettes can be found in graphics/object_events. you're in luck - it looks like there are only a handful of NPC palettes which get reused for many NPC sprites, so it shouldn't take too long to make night mode versions of them.

    i don't have time to take a proper look so far, but i think checking for whether you're indoors should be doable. i would take a look at other parts of the game that check for being indoors - like running shoes or fly - and see if you can call those same checks when you load the NPC palettes.
     
    That's a fantastic idea. Seriously don't know what I would have done without you. I'll admit I am slightly worried about npc sprites still, after all there are custom sprites I'll need to insert with their own pallets. In binary hacking you just installed the dynamic pallets patch and then added whatever you liked. Still I'll cross that bridge when I get to it. If I get this all working you'll be the first to know. Obviously it's only small steps between university and life, but you do what you can.

    Seriously I can't thank you enough
     
    Back
    Top