Hacker News new | ask | show | jobs
by loadzero 2162 days ago
I'm glad to see that others remember this fondly as well.

The Pascal to C translation was a bit gruelling. I'd like to say that I'd written a fancy transpiler for it, but it came down to a 20 line ruby script, some vim macros and a ton of elbow grease.

I added the functions to emulate the Turbo Pascal library as I went. This was a bit more fun, because I got to play around with implementing line drawing, circle drawing and flood filling, and really low level stuff like that.

The final stages, adding in threading to handle emulating the keyboard buffer, framebuffer and PC speaker was also a lot of fun.

I plan to cover at least some of these things in part two.

1 comments

Why not use something like freepascal with SDL bindings?
With these restoration projects, I am usually looking to maximise code portability and minimise dependencies, which for me means C.

Sticking with Pascal would have been more authentic to the original source code, but I think that would have been more painful for me to deal with, and come with a lot of unknown unknowns.

I would likely also have been sacrificing my ability to port it onto the web and other interesting targets.

FreePascal WebAssembly is almost fully there and FPC already has plenty of supported targets, basically almost any CPU that matters.

However it is your project, your decisions.

Yeah, that makes sense, I mentioned freepascal specifically because it has pretty broad platform support (and can generate LLVM bitcode). But, maybe the cost of translating to C is worth it.