stefanhaustein/empire

Organize code

pleumann opened this issue · 3 comments

The current source code is too large for Turbo Pascal 3.0 on cp/m. The limit there is about 30K. So we need to split up the current code. Would also make it easier to maintain.

How about this:

  • crt.pas similar to Turbo Pascal 4 and up
  • world.pas for data structures and procedures representing players, planets and ships
  • rules.pas for procedures dealing with rules of play (ships attacking planets etc.)
  • empire.pas for main program

Just found out that Turbo Pascal 3.0 did not yet support conditional compilation - which does suck a tiny bit. Do we

  1. want to look for a way of structuring the code based on top-level "project" files that contain the needed includes or
  2. do we prefer something with proper units that compiles fine with Turbo Pascal 4+ and Free Pascal plus a Python script that generates a version for Turbo Pascal 3.0 (based on some special markers)?

I don't see anything that can be conditional, so why not go ahead with includes and add more complexity later as needed?

I don't see how to manage KeyPressed and ReadKey on FPC without conditionally using CRT. And without these we only have Read() for Input, which means a) every input has to be confirmed with and b) the user can type any kind of garbage that would potentially garble the user interface. Alternative is that we split up the code and have top-level files empire.pas for FPC and empire3.pas for Turbo 3, and these include everything as needed.