In my compilation I have two stages: Precompilation and Compilation. In precompilation, everything is done in a non-write test mode and the script's length is retrieved. Then I search for X amount of successing FF's (or 00's for Emerald, not sure if I implemented that). The program goes as follows:
* Scan with while loop from start address for 0xFF
* Once FF is found, loop for X amount of bytes
* If number of bytes is free, enable boolean to true to end upper while loop and then break, retrieving freespace location.
* If not, break and continue while loop. Rinse and repeat.
It's fairly simple, but may or may not be prone to bugs. If you want a good example of freespace finding you could also take a look at the FSF source, since it's available on Google Code.
ah ok, what I was doing was reading in each byte, then converting it to a hex string(ex 255 became FF) then I string concatenated it three more times, for the next 3 bytes(In reverse order) then I did a Integer.ParseInt(variable, 16)
Also I was wondering how you did preform free space searches, I looked at your source code and I am having problems trying to apply the logic to my own program
Basically since Java doesn't support unsigned values I had to store the 32 bit values in a long. To get the values I pretty much just read the byte, bitshifted left 24, read the next, bitshifted 16, and so on to eventually reach the original value.
SEA's Github repo should still be up if you want to take a look at how I did it. To be honest I can't remember exactly what code I used but I could probably go back in and check. I'll go fix the link though, I'm not sure why it would be down...