Forum > Graphics

Convert pictures of a Turbo Pascal program ported to ptcGraph

<< < (3/6) > >>

Roland57:

--- Quote from: dseligo on May 17, 2021, 06:26:21 pm ---Very nice :)

--- End quote ---
Indeed.  :)

I really do not regret my efforts. It's a very nice little game. The source code is surprisingly short. Congratulations to the author.


--- Quote from: retronick on May 17, 2021, 03:58:17 pm ---Wow! I didn't think you would be so quick.

--- End quote ---
It was easy. The solution was to use the original BLoad procedure for loading the maze data.

Thank you for the hints about compilation mode. It seems that the game crashes when the range checking is on. With patience I should be able to find the errors.

retronick:
The issue probably also exists in the original code except no errors are thrown. probably just accessing the contents of one of the arrays limit. you can try increasing the array sizes and see if the error goes away.

Roland57:
I found the error. It's here:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---// mspacman.pas line 604  Inc(cwf); LogLn(Format({$I %LINE%} + ' cwf = %d', [cwf]));
The error happens when cwf = 255. I still have to figure how to fix it.

To compile and run the game, you can do this:
make
make run

If you wish to run the game without error:
make release
make run

retronick:
that variable is declared as a byte.

in turbo pascal if

var
  c  : byte;
...
c:=255;
inc(255);
writeln(c);    <-- will display 0

the variable will be set to 0

in freepascal it will not - it will generate an error

so if you want to make your code compatible with turbo pascal you should check if it is 255 and set to 0 - if not inc(cwf)

or turn off range checking before you inc
{$R-}
inc(cwf);
{$R+}

I think your release compiler options turn off range checking so that's why it works.

make sense?








Roland57:
@retronick

Yes, all what you say makes sense. Thank you for your help.

So I made this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if cwf < High(byte) then    Inc(cwf)  else    cwf := 0;
but it seems that there still are other errors. But it isn't really an issue, since (as you said) we can simply turn the range checking off.

If I have time, I will add some sound effects.


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version