Recent

Author Topic: Porting a strategy game from Turbo Pascal  (Read 12953 times)

ZsurzsaLaszlo

  • New Member
  • *
  • Posts: 17
Porting a strategy game from Turbo Pascal
« on: May 01, 2018, 11:18:25 pm »
Hey everyone,

I have the old source code of my strategy game I wrote when I was 18. (Video: https://www.youtube.com/watch?v=Jd5ajcdmlHk). As you can see see in the description of the video, the whole 'engine' had every program that you would need to create a game:
    1. Sprite editor
    2. Terrain editor
    3. Game engine (Never finished fully)

I tried to retrieve the color codes from Turbo Pascal but was not successful. Years passed, I still have the whole source code but can't do a lot whit it. I started to remove the 'bottom layer', the draw logic and replace it with OpenGL but it would be hard without the color codes of TP (would like to save the assets that I hand draw :D).

Does somebody have experience with porting a game from TP to FreePascal? I would love to finish this game one day! Maybe making it open-source would be the best choice (would need to clean up the code before :P)

Every answer is highly appreciated!
   

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Porting a strategy game from Turbo Pascal
« Reply #1 on: May 01, 2018, 11:36:44 pm »
What do you mean by "color codes of TP"?

Video looked nice.
What was it, 320 x ??? resolution?
Using assemble to generate video output?
Maybe even using the famous gfxfx unit?

Bart

ZsurzsaLaszlo

  • New Member
  • *
  • Posts: 17
Re: Porting a strategy game from Turbo Pascal
« Reply #2 on: May 01, 2018, 11:42:36 pm »
Resolution of the game was 320x200. Low level pixel drawing was done with assembly yes. The colors where used from the standard 256 color palette from this graph mode. Sorry for the sloppy words, with color codes I wanted to mean RBG values.

Besides some assembly and writing to de video memory I didn't use any graphics library.

soerensen3

  • Full Member
  • ***
  • Posts: 213
Re: Porting a strategy game from Turbo Pascal
« Reply #3 on: May 02, 2018, 12:22:46 am »
I have no experience with turbo pascal but maybe you mean this: https://en.wikipedia.org/wiki/Enhanced_Graphics_Adapter#Color_palette
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Porting a strategy game from Turbo Pascal
« Reply #4 on: May 02, 2018, 04:06:37 am »
Resolution of the game was 320x200. Low level pixel drawing was done with assembly yes. The colors where used from the standard 256 color palette from this graph mode.

Then it should be Mode 13h:
https://en.wikipedia.org/wiki/Mode_13h

The conversion table for Mode 13h to RGB value should be:
000000 0000AA 00AA00 00AAAA AA0000 AA00AA AA5500 AAAAAA 555555 5555FF
55FF55 55FFFF FF5555 FF55FF FFFF55 FFFFFF 000000 101010 202020 353535
454545 555555 656565 757575 8A8A8A 9A9A9A AAAAAA BABABA CACACA DFDFDF
EFEFEF FFFFFF 0000FF 4100FF 8200FF BE00FF FF00FF FF00BE FF0082 FF0041
FF0000 FF4100 FF8200 FFBE00 FFFF00 BEFF00 82FF00 41FF00 00FF00 00FF41
00FF82 00FFBE 00FFFF 00BEFF 0082FF 0041FF 8282FF 9E82FF BE82FF DF82FF
FF82FF FF82DF FF82BE FF829E FF8282 FF9E82 FFBE82 FFDF82 FFFF82 DFFF82
BEFF82 9EFF82 82FF82 82FF9E 82FFBE 82FFDF 82FFFF 82DFFF 82BEFF 829EFF
BABAFF CABAFF DFBAFF EFBAFF FFBAFF FFBAEF FFBADF FFBACA FFBABA FFCABA
FFDFBA FFEFBA FFFFBA EFFFBA DFFFBA CAFFBA BAFFBA BAFFCA BAFFDF BAFFEF
BAFFFF BAEFFF BADFFF BACAFF 000071 1C0071 390071 550071 710071 710055
710039 71001C 710000 711C00 713900 715500 717100 557100 397100 1C7100
007100 00711C 007139 007155 007171 005571 003971 001C71 393971 453971
553971 613971 713971 713961 713955 713945 713939 714539 715539 716139
717139 617139 557139 457139 397139 397145 397155 397161 397171 396171
395571 394571 515171 595171 615171 695171 715171 715169 715161 715159
715151 715951 716151 716951 717151 697151 617151 597151 517151 517159
517161 517169 517171 516971 516171 515971 000041 100041 200041 310041
410041 410031 410020 410010 410000 411000 412000 413100 414100 314100
204100 104100 004100 004110 004120 004131 004141 003141 002041 001041
202041 282041 312041 392041 412041 412039 412031 412028 412020 412820
413120 413920 414120 394120 314120 284120 204120 204128 204131 204139
204141 203941 203141 202841 2D2D41 312D41 352D41 3D2D41 412D41 412D3D
412D35 412D31 412D2D 41312D 41352D 413D2D 41412D 3D412D 35412D 31412D
2D412D 2D4131 2D4135 2D413D 2D4141 2D3D41 2D3541 2D3141 000000 000000
000000 000000 000000 000000 000000 000000


Source (public domain):
https://commons.wikimedia.org/w/index.php?title=User:Psychonaut/ipalette.sh&oldid=8607095

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Porting a strategy game from Turbo Pascal
« Reply #5 on: May 02, 2018, 01:47:34 pm »
If you'll port it to Free Pascal, I recommend you to use a game framework.  It will help you a lot.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

ZsurzsaLaszlo

  • New Member
  • *
  • Posts: 17
Re: Porting a strategy game from Turbo Pascal
« Reply #6 on: May 02, 2018, 04:04:12 pm »
Wohoooo thanks guys, the colors are awesome!

'If you'll port it to Free Pascal, I recommend you to use a game framework.  It will help you a lot.' - good point, but have to see. Actually I have my own engine written, with everything I need. The question is if it's portable or not. If not, then I have a few options. With the color table posted before, at least I can save my assets and maybe rework it.



Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Porting a strategy game from Turbo Pascal
« Reply #7 on: May 02, 2018, 04:21:26 pm »
On your 18 you've already wrote strategy game including the sprite editor, terrain editor, game engine, and some parts of them are optimized using assembly. I salute you!

Please port it and enhance it with higher resolution graphics. I rarely know strategy games built using Pascal, except xTactics.

ZsurzsaLaszlo

  • New Member
  • *
  • Posts: 17
Re: Porting a strategy game from Turbo Pascal
« Reply #8 on: May 02, 2018, 04:31:06 pm »
Thanks for the kodos. I love pascal, was the best thing what happened to me. I will try to open-source it, but would need to clean the code. I hope I manage this in the upcoming few months. Would be a great boost for boot Turbo Pascal and FreePascal.

To be 100% fair. The game only runned on XP, although the game can be compiled with turbo pascal 7.0. The optimization was done yes in assembly :D
« Last Edit: May 02, 2018, 04:33:50 pm by ZsurzsaLaszlo »

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Porting a strategy game from Turbo Pascal
« Reply #9 on: May 02, 2018, 04:49:41 pm »
I started to learn programming when I was 13, when good programming books were hard to find and there was no internet that time. My progress was slow, I abandoned programming for about 10 years. But I love programming and Pascal, now on my free time I learn and do some programming.

The first language I learned was BASIC. Very slow, it forced me to learn some Assembly to write obj files for called from BASIC. I stopped learning Assembly after I found Pascal, it's much faster, it allows me to map graphics data directly to the memory and even write ASM code, which I never used.

If you finish reworking the game, please lets us know.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Porting a strategy game from Turbo Pascal
« Reply #10 on: May 02, 2018, 05:55:50 pm »
If you finish reworking the game, please lets us know.
Yes please!
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Paul_

  • Full Member
  • ***
  • Posts: 143
Re: Porting a strategy game from Turbo Pascal
« Reply #11 on: May 02, 2018, 08:31:35 pm »
I rarely know strategy games built using Pascal, except xTactics.

There are some:
Knights & Merchants remake - http://www.kamremake.com/ (freeware)
C-Evo - http://www.c-evo.org/text.html (Civilization like game, freeware)
Cossacks 3 (2016, commercial)




Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Porting a strategy game from Turbo Pascal
« Reply #12 on: May 02, 2018, 09:00:00 pm »
Cool, they look good. I'm a bit busy currently, will test those games for sure.
Thank you for mentioning them.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Porting a strategy game from Turbo Pascal
« Reply #13 on: May 03, 2018, 06:50:34 pm »
You can make an array of color codes and use it with OpenGL. Something like:
Code: Pascal  [Select][+][-]
  1. type
  2.   RGBByte = packed record
  3.     r,g,b: byte
  4.   end;
  5. ...
  6. var colors: array[0..255] of RGBByte;
  7. ...
  8. glColor3bv(@colors[16]); // Would use index color 16 for all next drawings

ZsurzsaLaszlo

  • New Member
  • *
  • Posts: 17
Re: Porting a strategy game from Turbo Pascal
« Reply #14 on: May 04, 2018, 10:21:26 pm »
Wow this is indeed a good idea! I will keep this thread alive (although no time yet to do anything :( ), first I will port my assets.

 

TinyPortal © 2005-2018