Recent

Author Topic: Does "sdlgraph" unit work?  (Read 2923 times)

kveroneau

  • Full Member
  • ***
  • Posts: 119
Does "sdlgraph" unit work?
« on: April 11, 2019, 06:19:59 am »
I was browsing through the FPC-3.0.4 source tree I have locally browsing for Retro TP units to see how they were implemented for use in MS-DOS/Go32 and how those units were ported over to run on modern systems.  While I am not planning on making a new program using the old Turbo Pascal legacy "graph" unit, it is still a curiosity.  Anyways, I noticed for modern systems that there is currently a working "ggigraph" unit, which is able to compile an old Turbo Pascal program, however when it comes to linking, the latest Debian does not include a libggi.  I then noticed that someone ported "graph" to SDL in the form of sdlgraph.  Sadly, this unit isn't available in the binary FPC 3.0.4 distribution for whatever reason.  So, I did what everyone else would try, I attempted to compile the sdlgraph.pp file.  For those curious, here is where you can find it in the FPC source: fpc-3.0.4/packages/graph/src/sdlgraph

Anyways, it almost compiled, but it is now missing a unit called "sdlutils".  Which is odd, as this unit source is also in the source tree, but for whatever reason isn't in the binary distribution of FPC-3.0.4.  I feel like some Makefiles are missing these units during the current build process.  Unfortunately trying to compile the sdlutils unit is giving me 50 errors.  I have a feeling that sdlutils is something legacy, and that now all that functionality has been moved to the other SDL units.  The only procedure and functions used from sdlutils is SDL_GetPixel and SDL_PutPixel, and neither of these seem to be available in the other SDL units.  So...  I copied and pasted over the procedure and function into sdlgraph.pas, and removed the sdlutils from the uses clause.  Upon running the compile again, I ran into some errors.  These errors don't make much sense if sdlutils ever worked...  So, it first complained about this: bpp := SrcSurface.format.BytesPerPixel;

This line is completely broken if you know the structure of the TSDL_Surface and TSDL_PixelFormat...  So, srcSurface is actually a pointer, and format is also a pointer.  So I needed to add the carets to signify that, and then the compile got passed this line.  However, more errors are found in SDL_GetPixel.  One of the easy ones was that it uses "Result:=" in the function call, but neither sdlutils.pas or sdlgraph.pas even has a {$MODE objfpc}, so this isn't supported...  So I added the mode compiler directive, and I have yet more errors to go through...  Thankfully all these errors are currently isolated to SDL_GetPixel and SDL_SetPixel.  Aren't these methods provided by the SDL library?  These are such primitive functions that'd I'd expect SDL to have them in it's own library.  I may just look into that next to get sdlgraph.pas working.

Perhaps in the future, I will create a "toy project" which will be an LCL control that works like a graphics driver for the old school "graph" unit, so some retro TP graph unit programs can be drawn with minimal modifications onto a LCL control.  I must admit that I do love all things retro, which is why I am fascinated at getting "sdlgraph" to work.

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #1 on: April 11, 2019, 10:15:21 am »
hi hello kveroneau,

sdlutils is package sdl. If binary freepascal then not have. can find source packages/sdl/src/sdlutils.pas (https://github.com/graemeg/freepascal/blob/master/packages/sdl/src/sdlutils.pas)

I try polytest.pas then i error link sdl.
Code: [Select]
Free Pascal Compiler version 3.0.4-r37149 [2019/03/13] for arm
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling polytest.pas
Assembling polytest
Linking polytest
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: cannot find -lSDL
polytest.pas(79,39) Error: Error while linking
polytest.pas(79,39) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: $HOME/bin/fpc/3.0.4/bin/arm-linux/ppcarm returned an error exitcode
Compilation failed.

I sudo apt-get install libsdl1.2debian, same error  :'( I think have look configuration directory. I think i tell first you that can work then try find error  :)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Does "sdlgraph" unit work?
« Reply #2 on: April 11, 2019, 10:16:15 am »
Install sdl devel or dev package.

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #3 on: April 11, 2019, 10:33:53 am »
Install sdl devel or dev package.
hi hello marcov,

i write
Code: [Select]
sudo apt-get install libsdl1.2-dev
now can work. Not more link error  :)

Code: [Select]
Free Pascal Compiler version 3.0.4-r37149 [2019/03/13] for arm
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling polytest.pas
Assembling polytest
Linking polytest
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
83 lines compiled, 4.6 sec
2 hint(s) issued
Compilation finished successfully.

Thanksy marcov  8)

Have program error polytest. I think not error sdl maybe
Code: [Select]
./polytest
An unhandled exception occurred at $00051320:
EAccessViolation: Access violation
  $00051320
  $00047E44
  $00048070
  $0003CC24
  $0003EF8C
  $0003F2E4
  $000111BC
  $00011308

I try example other or find error polytest  :)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Does "sdlgraph" unit work?
« Reply #4 on: April 11, 2019, 10:37:49 am »
For libggi in stretch:
Code: Bash  [Select][+][-]
  1. sudo apt install libggi2 libggi2-dev
Also contains ggi1.
Specialize a type, not a var.

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #5 on: April 11, 2019, 10:59:29 am »
Also contains ggi1.
Many thanksy user Thaddy  8)

I not see ggi1. Alone ggi2. I not know ggi2 have ggi1. Is problem solve  :)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Does "sdlgraph" unit work?
« Reply #6 on: April 11, 2019, 11:31:03 am »
Note the sdlgraph units seem to rely on https://github.com/ev1313/Pascal-SDL-2-Headers which differ from the headers in the official fpc distribution,. (sdl_events and so on...)
Specialize a type, not a var.

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #7 on: April 11, 2019, 12:17:34 pm »
OK thanksy Thaddy.

Maybe that why not work sdlgraph. I SDL1. I try SDL2.

I problem ggigraph.

I try polytest make error fix good ?
Code: Pascal  [Select][+][-]
  1. program PolyTest;
  2. uses
  3.   ggigraph;  // graph;
  4.  
and
Code: Pascal  [Select][+][-]
  1. var
  2.   GraphDriver, GraphMode: Integer;
  3. begin
  4.   GraphDriver := Detect; //  GraphDriver := VGA;
  5.   GraphMode := 0; //  GraphMode := VGAHi;
  6.   InitGraph(GraphDriver, GraphMode, '');
  7.   if GraphResult <> grok then
  8.   begin
  9.     WriteLn('GraphResult give error');
  10.     halt;
  11.   end;
  12.   SetFillStyle(SolidFill, 9);
  13.   Tralala;
  14.   CloseGraph;
  15. end.
  16.  

./polytest > polytest.001 2>&1

Then have polytest.out
Code: [Select]
K for mode 33 : S320x200[GT_32BIT]
OK for mode 34 : S640x480[GT_32BIT]
OK for mode 35 : S800x600[GT_32BIT]
OK for mode 36 : S1024x768[GT_32BIT]
OK for mode 43 : S1152x864[GT_32BIT]

then polytest.001
Code: [Select]
LibGGI: No explicit target specified.
LibGGI: Try to use display-x...
OK for mode 33 : S320x200[GT_32BIT]
OK for mode 34 : S640x480[GT_32BIT]
OK for mode 35 : S800x600[GT_32BIT]
OK for mode 36 : S1024x768[GT_32BIT]
OK for mode 43 : S1152x864[GT_32BIT]
GraphResult give error
Failed to kill(6927,27) (error 3).
Failed to kill(6927,27) (error 3).
Failed to kill(6927,27) (error 3).
Failed to kill(6927,27) (error 3).
Have many "Failed to kill(6927,27) (error 3)" . No can close terminal  and polytst.001 big and more big :o

I not sure how work unit graph. I need fix "No explicit target specified." ? then how can fix ?

Other (no same) error my confuse when compile -glh polytest
Code: [Select]
ggigraph.pp(176,18) Hint: Local type "TGGIResource" is not used
ggigraph.pp(185,14) Hint: Local type "PGGIClut" is not used
ggigraph.pp(191,14) Hint: Local type "TGGIAttr" is not used
ggigraph.pp(335,13) Hint: Local type "PBitmap" is not used
Assembling ggigraph
Assembling polytest
Linking polytest
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/bin/ld: $HOME/bin/fpc/3.0.4/units/arm-linux/rtl/heaptrc.o: undefined reference to symbol '_end'
//usr/lib/arm-linux-gnueabihf/libXxf86dga.so.1: error adding symbols: DSO missing from command line
polytest.pas(87,37) Error: Error while linking
polytest.pas(87,37) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: $HOME/bin/fpc/3.0.4/bin/arm-linux/ppcarm returned an error exitcode
Compilation failed.
I not know why no compile good -glh. Maybe some know ?

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #8 on: April 11, 2019, 02:37:48 pm »
Ok,

can make work ptcpas. Not example polytest.pas use polytest.txt but polytst2.txt. ptcpas is error not compatible 100% graph unit fillpoly.

If use polytst2.txt sdlgraph better work. Then also access violation. I think more compatible problem sdlgraph not alone fillpoly().

kveroneau

  • Full Member
  • ***
  • Posts: 119
Re: Does "sdlgraph" unit work?
« Reply #9 on: April 11, 2019, 04:43:30 pm »
For libggi in stretch:
Code: Bash  [Select][+][-]
  1. sudo apt install libggi2 libggi2-dev
Also contains ggi1.

My Debian Stretch doesn't appear to have that package. :(  Today after work, I'll take a look at that SDL git repository and maybe get sdlgraph to compile.  Here's my output when trying to install:

Code: Text  [Select][+][-]
  1. root@sys3:~# apt-get install libggi2 libggi2-dev
  2. Reading package lists... Done
  3. Building dependency tree      
  4. Reading state information... Done
  5. Package libggi2-dev is not available, but is referred to by another package.
  6. This may mean that the package is missing, has been obsoleted, or
  7. is only available from another source
  8.  
  9. E: Unable to locate package libggi2
  10. E: Package 'libggi2-dev' has no installation candidate
  11. root@sys3:~# cat /etc/debian_version
  12. 9.8
  13.  

Yes, I am one of those people who don't believe in sudo, not using sudo and forcing separate root password enforces privilege separation and also adds another layer for a potential hacker to get through. ;)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Does "sdlgraph" unit work?
« Reply #10 on: April 11, 2019, 06:34:53 pm »
That's strange because I only installed it because of the question. My platform is Debian-stretch -armhf. ( Raspbian.)
Stretch has these libraries in APT I double checked that it is in the repositories. Also for other platforms.
« Last Edit: April 11, 2019, 06:36:44 pm by Thaddy »
Specialize a type, not a var.

kveroneau

  • Full Member
  • ***
  • Posts: 119
Re: Does "sdlgraph" unit work?
« Reply #11 on: April 11, 2019, 10:34:25 pm »
Do you have any additional repositories enabled perhaps?  I searched in the official Debian packages and I don't see it available in any suite or for any architecture:

https://packages.debian.org/search?suite=all&section=all&arch=any&searchon=names&keywords=libggi

Thausand

  • Sr. Member
  • ****
  • Posts: 292
Re: Does "sdlgraph" unit work?
« Reply #12 on: April 11, 2019, 10:58:35 pm »
hi hello kveroneau

package old. i raspbian virgin repository.
Code: [Select]
$ apt search libggi2
Sorting... Done
Full Text Search... Done
libggi2/stable,now 1:2.2.2-5.1 armhf [installed]
  General Graphics Interface runtime libraries

libggi2-dev/stable,now 1:2.2.2-5.1 armhf [installed]
  General Graphics Interface development package

$ cat /etc/debian_version
9.8

package find here https://tracker.debian.org/pkg/libggi (sorry i no can link direct libggi2 (!?). See left)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Does "sdlgraph" unit work?
« Reply #13 on: April 12, 2019, 07:23:50 am »
Indeed it must be libggi2 (which also contains ggi1) and is most definitely in the default Debian packages. I believe I already wrote that.
Specialize a type, not a var.

 

TinyPortal © 2005-2018