Wednesday, December 6, 2017

Dispatch Loop

Using a liberal amount of dummy functions, I was able to get to the man input loop of the game. The road to get it this far required me to get the filesystem code (rules1.c) operational. For the most part that was a drop-in, but there were two things that I found worrisome.

First I had to replace some of the legacy dos library functions with the POSIX counterpart. In this case _dos_findfirst() and _dos_findnext() had to be replaced. The POSIX _findfirst() and _findnext() returns a file object, and not an int like it's dos counterparts. (The return is not needed, the game just checks if the file exists and then makes some bold assumptions about it after that point). Basically if I see any function that starts with an underscore, it raises a red flag. Functions and variables that start with an underscore are a little too chummy to the compiler/library and when switching platforms may be a headache. After fixing that, the filesystem code didn't seem to rise any intellisense errors, but we will see what happens when they start being used.

The Second worrisome thing is that the legacy ATARI and AMIGA #ifdefs have a lot of byte swap code associated with them. I'm assuming because these endianness of their CPUs. This may be an issue when I switch platforms so I'm going to leave that in and dummied out. There is a larger problem than that though. ROE makes the assumption that an int are two bytes. This breaks one of the cardinal rules of C.

Never assume the size of an int!

In my system int is 4 bytes, and I use other compilers (for 8 bit machines), where it's only one. I've already have run into this snag where I tried to read the config file and it was reading in way too many bytes. That was strange as the data I was trying to retrieve was only used three bits max, the var should of been typed as an unsigned char. I typed the misbehaving variable as __int16 (Ohh! two underscores! That's even more sticky to my platform!) I could of used int16_t, but I'm keeping the double-underscore so I can get that on my second pass.

Got the mouse going, though it doesn't pass anything to Nermal's pointer struct yet, but is has the goofy hand pointer though.



No comments:

Post a Comment