News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Changing the starting date on SNES rom and troops  (Read 2471 times)

LorD-16

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Changing the starting date on SNES rom and troops
« on: June 10, 2014, 04:13:49 am »
The SNES game is the Koei classic Liberty or Death. The game starts in the summer on the date July 1, 1775. The game has 2 turns per month (1st and 16th of each month). I have found nearly everything except the starting date. The game will automatically end on January 1, 1820 (45 years to try and win the game). It seems to be hidden well and I'm not a programmer, just a fan of the game.

I want to make the game into a Civil War game, but I need to be able to change the starting date for a more authentic feel. 1861-1865 was the American Civil War so I would probably start in 1860 or 1861 and have the game automatically end in 20 years( about 1860-1880). I also want to be able to change the total number of troops per unit. I found maximum men and can change that to 1000+ per regiment but once the men reach 511 then they go to 0 instead of 512. I would like to be able to prevent the loop back to 0 if possible.

Does anybody have any experience or tips for finding the starting dates, or calendar info, or specific years within a SNES rom? I tried the hex value of 1775, and even tried searching the ram using the emulator, but I can't find it. Any info on why the total troops go back to 0 when the total reaches 512? Any help or guidance to help me finish my Civil War version of Liberty or Death is greatly appreciated.

EDIT**** Update: I have found the ability to switch sides using a save state file. Offset 2FEF has 00 (American) 01 (British) so I can now switch sides if I want a real challenge to comeback and defeat the other side from the brink of defeat. Not something many will care about but yet another thing I can cross of my list.
« Last Edit: June 14, 2014, 04:07:11 am by LorD-16 »

FAST6191

  • Hero Member
  • *****
  • Posts: 3091
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #1 on: June 10, 2014, 07:43:55 am »
I would be half surprised if it was a full number. What tends to happen in short but offset time frames if you start from 0 and then generate whatever number for display you need-- think rather than trying to make a hours and seconds clock and all the logic that would need then just make a "seconds since day has started" count and converting when necessary and doing maths upon that. Even if it does have "full" values then I would not be surprised to see it maintain a simple working number starting at 0 and a full count (probably 90 as it is 90 turns rather than 45 years) as a kind of mirror -- people often encounter things like this when making cheats. Speaking of cheats that is probably how I would set about doing something. Rather than search for specific numbers do a search for an increasing value. This should net you the turn count in memory. Once you have that you need to patch a watch/break on anything reading or writing to it. That should then break on the routine that does anything and you can follow it back through to figure out what is going on.

On 512... it could go either way. Numbers would be stored as hex and much like 99 is as big as you get in two digit natural numbers you have the likes of 512, kind of. What might be more troubling though is if the game performs a calculation like units * attack strength (which by the way would probably be limited to 1023/1024) makes a number higher than it would with just 511. Do the troops act as a megapowerful unit or do they actually vanish/get weak? If they vanish then you have an overflow condition which are a pig to sort a lot of the time and if they get powerful you hopefully just have a display numbers issue.
On a PC if you have the source code this is basic programming to sort, if your programming language of choice even observes the distinction which a lot of modern ones do no. When hacking a game built for a somewhat limited power device and pre a lot of this it is a far more troublesome proposition, starting with the fact the SNES is a 16 bit console and that makes doing maths on larger numbers more troublesome.

Would you accept a fake? You could say something like if a unit size drops below ? then they get routed, this being somewhat historically accurate as well (the US civil war being one of the earlier examples of more modern warfare and all).

LorD-16

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #2 on: June 10, 2014, 04:56:34 pm »
Thank you very much for your help. I am still learning as I go (slowly) what probably is going on within the rom.

There are 2 turns per month and that is 24 per year. 24 * 44.5 = 1068 turns before the game auto ends on Jan.1, 1820.
When you say generate the starting point you mean adding 2 values together that equal 1775? I tried searching for 75, 775 and changing them but it had no impact, thinking maybe the values were 1000+775 or 1700+75.

There are 90 turns maximum in a battle (6 turns per day and 15 days of fighting) but that is separate from the starting date data.

As far as doing a comparative search should I be looking for a constant increasing value say over the course of 1 year (24 turns)? Or should I do a bunch of comparative searches each new turn, like when the game switches from July 1, 1775 to July 16, 1775)?

Regarding the men I can get the game to show 511/1000 but when I draft 1 more man for the regiment it switches back to 0. The problem might be that the game reads from 2 different sections for the available men and total men. The available men resets at 512 is that because in the available men section it only has 7d(125*2) for 250 men available and FA(250*2) for 500 men available.

The game does take into account the size of the regiment attacking(more men do more damage). However it does also have an overflow problem as well. I changed the artillery unit to 500 men and the result was a weak unit on the battlefield, but if I give them 400(usual is 250 men) then the unit becomes extremely powerful during battle(killing half of a defending regiment with 1 barrage). The game has a value (% probably of available men to total men) where it will try and retreat the unit if it falls to low during a battle (usually 50 to 150 men left range).

I am unable to find the maximum amount for fleets (100) figured it would be as simple as searching for (LDA 100) A9 64 but that's not the case. I know the values for max fleet, fleet attack strength(close) and (far), but I'm unable to find them within the hex data.

Sorry about the length, but there is 1 more thing I find confusing. I found the starting location (specific districts) for a regiment but when I try and change there starting location (say move George Washington out of Massachusetts to Philadelphia to start the game) he remains in Mass. Any idea why?

FAST6191

  • Hero Member
  • *****
  • Posts: 3091
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #3 on: June 11, 2014, 07:32:27 am »
Yeah I fluffed the maths, hopefully the underlying thinking was evident.

I was thinking more start a cheat search, pass a turn, search for something that increased, do nothing and pass another turn, search for something that increased... this should narrow down a turn counter fairly quickly. Said counter probably started at 0 and counts up to the 1068 value. When they want to display the year I imagine it probably takes that number and does whatever maths it needs (probably is odd or even to get the date in the month, something to figure out the months and then the year). It might not start at 0 but it probably does count up, it may count down instead (there are technical reasons why that could be a good thing) but that only means you want to change the cheat search to changes rather than greater than/increases.

There is an alternative I forgot last time which has been seen in SNES games and games of a similar vintage, it is called Binary Coded Decimal aka BCD. It is not especially hard to work with but I do hope it is not the case here, it can make date/time displays a bit easier to manage though and such things are the most common uses of it in games. There are further variations on the theme (see something like DOS date/timestamps) but it is all much the same idea.
An example might be if I wanted to represent 15:31 (the time) I could do something to have a clock with a seconds count or instead I could put 0F:1F (or more likely 0F1F which has a decimal equivalent of 3871).

On the units thing. Interesting that it does that (I assume it is not trying to represent many people trying to go through a small gap) before you hit the display limit, I guess the original devs made it so the game never overflowed. If it already has a casualty rate desertion type mechanic then I guess you can not even fake it like that. Overflow issues like this really are horrible to deal with, the best method that does involve chasing through hundreds of lines of code is to drop the numbers to avoid it -- if attack and defence numbers are in the 40 or so range then drop everything to between 1 and 8 or something and do the same for other things and you have just shaved off an order of magnitude. The main problem there is if the AI is hardcoded to look at those numbers rather than look at its own and compare. Frankly though I am half impressed it does not crash or get very strange.

No specific idea why a unit remains in the same location. It could be that you have missed something, I have also seen plenty of games theoretically be able to move a unit but because the dev wanted to knock off for launch/not debug something they forced it to be a given thing and though I doubt it would be in this case it could also be a kind of anti cheat.

LorD-16

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #4 on: June 11, 2014, 11:39:01 pm »
FAST6191 Thank You so much!

I found the turn counter it didn't start from 0 but 42612 instead. I found that value within the SNES save state (74 A6) as well and can change it without having to use a cheat.

Now the next step, finding a way to get the game to show 1860 graphically on the screen. It shows 18 (1st 2 values) because the game normally can go to 1820, but the last 2 values I'm guessing nothing but 75-20 so that would mean no 60. Actually after messing around with it a bit, the game will show the years 1775 to 1820 but nothing more or less. Only the 1st or 16th and the month shows up during gameplay while the year is pretty much blank if you go below 1775 and the whole screen messes up if you put in 1860.  Is the table that contains this data to generate the year restricted? I mean all the numbers 0-9 can all show up but not outside of a limited few within the year. Am I looking at this all wrong? The way I see it is the 1st number can only be a 1, and the 2nd number can be a 7 or an 8, the 3rd a 7,8,9,0,1, or 2, while the last number can be all the numbers. Probably not the right track since I know nothing how the data is being pulled or put together to display the year.

Regarding the attack strength I do not know what the attack strength is per unit but it does vary. Infantry for instance can attack with muskets (strong) or bayonets (weak). Cavalry can charge (strong), pistols (weak), or ambush (very strong). Artillery can barrage (strong) or muskets (weak) or hand to hand (very weak). Rangers are special in that they fight like 2x as strong during nighttime as they do during the day, and they can ambush (very strong) and rifles (strong). Plus there are terrain modifiers and entrenching which adds strength to unit as well. Many variables that I simply don't know the specific values for like Fleet barrage close(30) and far (26) and fireboats (26). Like I mentioned before I know these values (from the game's manual) but unable to find them lumped together like the terrain data is all in 1 place in the hex. I should mention in the original unmodified data nothing is as strong as the Fleet close barrage (30) or as weak as the Artillery unit without a cannon(hand to hand).

Any ideas? You have given me great advice and steered me in the right direction and I'm finally making progress for that I am very grateful. Thanks Again!

June 13, 2014, 04:48:32 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Just quick update FAST6191. I found out how to move regiments into districts now and have them show up in the game where I want. I just needed to include my changes in the corresponding districts not just at the regiment level.

I still need help on a few things:
1. Need the game to show the years 1860-1881 and then auto quit at Jan. 1, 1881 rather than only 1775 to 1820.

2. Help finding a way to change sides for the Human. (Starting a game as the North then halfway through switching the North to the CPU while simultaneously switching Human control to the South to see if I can win with the odds stacked against me.) Found it.

3. Help finding or figuring out the Attack/Defensive strength of each unit(Infantry, Cavalry, Rangers, and Artillery) to offset the fact I can't stop the overflow problems or the Loop of only 511 max men before resetting to 0 instead of 512.

4. Tile editing to change the Title screen from Liberty or Death(L or D) to maybe Civil War, North vs South, or Union and Confederacy (IDK something besides L or D). I have never attempted tile editing graphics editing of any kind, but feel if I get the year accurate then this has to be attempted.

5. Understanding terrain graphics for each of the districts for more authentic terrains (Gettysburg is accurate not just a name of a district).

Any help I can get from anybody with experience in those areas would be very much appreciated. I have no time table for this hack but would like to enjoy playing it someday.
« Last Edit: June 14, 2014, 04:08:28 am by LorD-16 »

Woden

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #5 on: June 14, 2014, 08:21:46 pm »
I found the turn counter it didn't start from 0 but 42612 instead.
Let me guess: The game's start date is August 1st, 1775?

It sounds like it just directly stores the dates in turn format (i.e., +24 = +1 year).

That means, assuming that the game normally ends on January 1st, 1820, you'd be looking for a value of 43,680 (0xAAA0) for the end date.

LorD-16

  • Jr. Member
  • **
  • Posts: 4
    • View Profile
Re: Changing the starting date on SNES rom and troops
« Reply #6 on: June 14, 2014, 10:25:12 pm »
The Start date is July 1st, 1775. Yes, the game does an auto-ending for an American victory after the final turn of Dec.16, 1819. If I put the start date into the hex as Jan. 1st, 1820 (A0AA), then I can play until the final turn of Dec.16, 1820 until the auto-ending plays out for the American side again.

Any ideas to get around this? I still can't figure out how to get anything besides 1775-1820 to display correctly in the game box. I did get the larger number font to show 1861 during the allocation phase which is just text and numbers, but once the game starts it gets messed up graphically where the year normally displays.

I thought of a workaround but have no idea how to implement. 1801-1809 could be changed to read 1861-1869 if I can get the game to load the 6 instead of the 0. I know it isn't what I want but it would be good enough. Any help on how to make that work?

EDIT**** Something else I thought of regarding the dates 1775 to 1820. Is the game loading up a specific date each year? It's pretty unlikely there's a section of the rom where say 90 bytes in a row go from 1775,1776,1777,1778, etc... until 1820 then anything before 1775 or after 1820 is getting read on a section that doesn't have a year but is instead blank data or other graphics? Just don't know why when I make the year 1760 it was blank for the year in the game box, where 1860 was a blotch of weird graphics. Maybe 2 numbers get added together to make 1775, I don't know. If it was a specific section I could simply change the number value to start with say 1825 to 1870 and just put  the start date as 1860 giving 10 years of possible war.

2nd EDIT***** I have a question about how the game decides to play out a specific scenario. If the British take over District 27: Philadelphia the game plays out a scene where the rebel American Congress are removed from Philadelphia and the government is in exile. There is some special graphics flashing on the screen showing the British now occupy the Capital. Would it be possible to change this scenario to play out in a different district? I would change it to District 36: Richmond so when the Union occupied it the Confederate government would be in exile. The game is programmed to take back their Capital as soon as possible (it becomes top priority).
« Last Edit: June 16, 2014, 05:50:54 am by LorD-16 »