Wednesday, January 31, 2018

So Much Progress!

Checking out Earth in the solar system builder
Manually loading member data
It may not seem like much, but the filesystem replacement functions are going really well. I can now load, edit,  and save the solar system files in their native format and without regard of endianness (In the original code, Apple and Atari had special functions to byte swap integers before they were written to disk.). I decided to to write the code so that each struct member is loaded individually. This means that I don't need to rely on how big an integer is anymore. The real success was when I loaded and saved the solar system file and did a binary compare and they both came out the same. Then I added a system, deleted it and saved it and it was still the same... 100% compatibility!

Captain list
I just completed work on the code to load the captains. I'll have to work on the code to save them tomorrow. After that I'm going to do the ships and the enemy races. The underpinnings are working well with the HD graphics library. Even though these graphics look pixelated, that's because I'm using the original assets zoomed 400%. When the updated graphics come along, you will start to see things begin to shine.






Another thing I came across was an interesting piece of code that will not compile anymore. You can tell it was written in a time when you could overwrite memory with no protection. It was the code that replaced a tilde (~) with a string you passed it. The original code looked like this...

cs = strchr(ts,'~');
if(cs != NULL) {
  *cs = 0;
  strcpy(bs,ts);
  *cs = '~';
  cs++;
  strcat(bs,s);
  strcat(bs,cs);

  }
else strcpy(bs,ts); 

You just can't arbitrarily change data at a pointer that's pointing to... something anymore. [*cs = 0;] - Windows gets super upset when you try. It was fixed with a little pointer math like such.

cs = strchr(ts, '~');
if (cs != NULL) {
   n = cs - ts;        //n = characters from ts to cs
   memcpy(bs, ts, n);  //copy up to cs into bs
   bs[n] = '\0';       //terminate the string
   cs++;               //push the pointer up one to skip the tilde
   strcat(bs, s);      //cat "file" to bs
   strcat(bs, cs);     //cat the rest of the string to bs.

}
else strcpy(bs, ts);

You have to be polite as ask to do things with memory as opposed to plopping a pointer anywhere you want.

Anywho, Here's a few final screenshots of progress.

Sol System - HD circle on radar screen
Captain Dossier





No comments:

Post a Comment