stefanhaustein / empire

The 90s are back and have uploaded their favorite BBS game!
2 stars 0 forks source link

Deal with Turbo Pascal 3.0 restrictions #7

Open pleumann opened 4 years ago

pleumann commented 4 years ago

For the fun of it I split the source into several parts tonight and added dummy definitions and procedures until it would compile with Turbo Pascal 3.0 under cp/m. There are some problems beyond the obvious terminal stuff. Some may actually be a dealbreaker.

1) All string mentions need a maximum length. This can easily be fixed by defining a type and using it everywhere.

type string255 = string[255];

2) Neither Word nor LongInt do exist. While the following does make the program compile it will probably kill the game logic:

type longint = integer;
     word = Integer;

I can try to isolate and work around the cases where LongInt is needed for date/time/milliseconds and even add cp/m BIOS calls to get this data. But it's also used in the game, for instance for coordinates in the galaxy. Would you mind thinking about a solution? Real, maybe?

3) The rest can be added or worked around, but it would make sense to change all occurrences of inc/dec with only a single parameter to inc/dec(x, 1) because Turbo Pascal cannot have two procedures with the same name.

const
     Black = 0;
     Blue = 1;
     Green = 2;
     Cyan = 3;
     Red = 4;
     Magenta = 5;
     Brown = 6;
     LightGray = 7;
     DarkGray = 8;
     LightBlue = 9;
     LightGreen = 10;
     LightCyan = 11;
     LightRed = 12;
     LightMagenta = 13;
     Yellow = 14;
     White = 15;
     Blink = 128;

(* --- Start of missing functions --- *)

procedure Halt(Result: Integer);
begin
end;

procedure Inc(var I: Integer; J: Integer);
begin
  I:=I+J;
end;

procedure Dec(var I: Integer; J: Integer);
begin
  I:=I-J;
end;

procedure TextColor(Color: Integer);
begin
end;

procedure MkDir(Dir: String255);
begin
end;

procedure RmDir(Dir: String255);
begin
end;

procedure GetTime(H, M, S, S100: Integer);
begin
end;

procedure GetDate(Y, M, D, Dow: Integer);
begin
end;

procedure Append(var F: Text);
begin
end;
stefanhaustein commented 4 years ago

Reals should work for the game logic... Do we need inc/dec at all?

pleumann commented 4 years ago

If you can change to real, please do it. Regarding Inc/Dec I was not sure if they have some special behavior on overflow/underflow that you rely on or if you just found them cooler than +/-. ;)

pleumann commented 4 years ago

Actually Integer might be fine in most cases. We only have 1000 Planets and the maximum coordinates are 1000/1000, too. The rest is IDs of players etc. Even with Integer there's still plenty of buffer for a really large game, if we wanted to.

pleumann commented 4 years ago

It will break the save files, though, so whatever you conquered so far will be lost. ;)

pleumann commented 4 years ago

All ship counts and travel times are Real now. Rest is Integer.