I was browsing through the FPC-3.0.4 source tree I have locally browsing for Retro TP units to see how they were implemented for use in MS-DOS/Go32 and how those units were ported over to run on modern systems. While I am not planning on making a new program using the old Turbo Pascal legacy "graph" unit, it is still a curiosity. Anyways, I noticed for modern systems that there is currently a working "ggigraph" unit, which is able to compile an old Turbo Pascal program, however when it comes to linking, the latest Debian does not include a libggi. I then noticed that someone ported "graph" to SDL in the form of sdlgraph. Sadly, this unit isn't available in the binary FPC 3.0.4 distribution for whatever reason. So, I did what everyone else would try, I attempted to compile the sdlgraph.pp file. For those curious, here is where you can find it in the FPC source: fpc-3.0.4/packages/graph/src/sdlgraph
Anyways, it almost compiled, but it is now missing a unit called "sdlutils". Which is odd, as this unit source is also in the source tree, but for whatever reason isn't in the binary distribution of FPC-3.0.4. I feel like some Makefiles are missing these units during the current build process. Unfortunately trying to compile the sdlutils unit is giving me 50 errors. I have a feeling that sdlutils is something legacy, and that now all that functionality has been moved to the other SDL units. The only procedure and functions used from sdlutils is SDL_GetPixel and SDL_PutPixel, and neither of these seem to be available in the other SDL units. So... I copied and pasted over the procedure and function into sdlgraph.pas, and removed the sdlutils from the uses clause. Upon running the compile again, I ran into some errors. These errors don't make much sense if sdlutils ever worked... So, it first complained about this: bpp := SrcSurface.format.BytesPerPixel;
This line is completely broken if you know the structure of the TSDL_Surface and TSDL_PixelFormat... So, srcSurface is actually a pointer, and format is also a pointer. So I needed to add the carets to signify that, and then the compile got passed this line. However, more errors are found in SDL_GetPixel. One of the easy ones was that it uses "Result:=" in the function call, but neither sdlutils.pas or sdlgraph.pas even has a {$MODE objfpc}, so this isn't supported... So I added the mode compiler directive, and I have yet more errors to go through... Thankfully all these errors are currently isolated to SDL_GetPixel and SDL_SetPixel. Aren't these methods provided by the SDL library? These are such primitive functions that'd I'd expect SDL to have them in it's own library. I may just look into that next to get sdlgraph.pas working.
Perhaps in the future, I will create a "toy project" which will be an LCL control that works like a graphics driver for the old school "graph" unit, so some retro TP graph unit programs can be drawn with minimal modifications onto a LCL control. I must admit that I do love all things retro, which is why I am fascinated at getting "sdlgraph" to work.