Author Topic: Compiling a PM sample with GCC (2023)  (Read 76428 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
« Last Edit: June 17, 2023, 06:41:01 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #181 on: June 17, 2023, 01:54:00 pm »
Hi Again

Now I'm trying COLORS from:
https://github.com/OS2World/DEV-SAMPLES-The-IBM-Developer-Connection-Release-12/tree/893ec58ff58237281e533bff8f8bb26bc882674e/PMSAMPLE/COLORS

It didn't compiled because of a UNDEF of "WinWriteProfileData", and there was no documentation about it, I change it to "PrfWriteProfileData"  (COLORS.C Line 151) and it compiled, but the application crash with...

Quote
06-17-2023  06:51:46  SYS3171  PID 0114  TID 0001  Slot 00a4
C:\DEV\DEV-SAMPLES-THE-IBM-DEVELOPER-CONNECTION-RELEASE-12\PMSAMPLE\COLORS\COLORS.EXE
c0000005
1fe0d1c8
P1=00000002  P2=0002fffc  P3=XXXXXXXX  P4=XXXXXXXX 
EAX=00030e98  EBX=00000005  ECX=00030f4c  EDX=00000000
ESI=00000002  EDI=00000000 
DS=0053  DSACC=d0f3  DSLIM=9fffffff 
ES=0053  ESACC=d0f3  ESLIM=9fffffff 
FS=150b  FSACC=00f3  FSLIM=00000030
GS=0000  GSACC=****  GSLIM=********
CS:EIP=005b:1fe0d1c8  CSACC=d0df  CSLIM=9fffffff
SS:ESP=0053:00030000  SSACC=d0f3  SSLIM=9fffffff
EBP=00030ea8  FLG=00010246

LIBCN0.DLL 0001:0007d1c8

Any help is welcome.

Regards

Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #182 on: June 17, 2023, 03:37:02 pm »
Try the attached. I used VAC so you will need to replace with your own makefile.

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #183 on: June 17, 2023, 04:18:37 pm »
Hi Dave
Edit: looking further, it does seem to load DIVE, though the code actually uses DosLoadModule to load GAMESRVR, which isn't on my system, yet the map file shows DIVE being used
The only thing that I found is that GAMESRVR is not longer available, seems that was embedded to DIVE since Warp 4.

DosLoadModule has two version the old 1.x and the newer one, but it seems to be called like the newer one. 

Regards

Try the attached:
1) I compiled with VAC, you will need to use your makefile and maybe revert some stuff that VAC did not like but maybe gcc expects
2) the code tests for your OS version. If the version is WARP3, it uses GAMESRVR, if it is newer (true for us), it uses PMMERGE to find the same functionality that GAMESRVR offered. This is because Warp3 did not contain DIVE whereas >= Warp 4 did
3) the code computed time diff from one screen refresh to the next. It was so fast that the time diff was computed as 0 and then fps computation led to a trap because it tried to divide by time diff (being zero). I fixed that error and changed DosSleep(0) to DosSleep(1) and now it works ok

Lars

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #184 on: June 17, 2023, 11:04:54 pm »
Hi Dave
Edit: looking further, it does seem to load DIVE, though the code actually uses DosLoadModule to load GAMESRVR, which isn't on my system, yet the map file shows DIVE being used
The only thing that I found is that GAMESRVR is not longer available, seems that was embedded to DIVE since Warp 4.

DosLoadModule has two version the old 1.x and the newer one, but it seems to be called like the newer one. 

Regards

Try the attached:
1) I compiled with VAC, you will need to use your makefile and maybe revert some stuff that VAC did not like but maybe gcc expects
2) the code tests for your OS version. If the version is WARP3, it uses GAMESRVR, if it is newer (true for us), it uses PMMERGE to find the same functionality that GAMESRVR offered. This is because Warp3 did not contain DIVE whereas >= Warp 4 did
3) the code computed time diff from one screen refresh to the next. It was so fast that the time diff was computed as 0 and then fps computation led to a trap because it tried to divide by time diff (being zero). I fixed that error and changed DosSleep(0) to DosSleep(1) and now it works ok

Lars

Another fix.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #185 on: June 17, 2023, 11:39:30 pm »
Hi Lars.

Thanks for taking a look at it.  I have compiled beehiveb3 with gcc, it compiles with warnings, but the .exe just keep crashing on execution.
Just in case here it is attached is your same code with my makefile.  Even if I fix some of the warning, it still does not load.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #186 on: June 17, 2023, 11:43:19 pm »
Hi Lars.

About COLORS, your version worked with gcc, It was just missing on the DEF:
Quote
NAME    COLORS   WINDOWAPI

Seems to be working. I will check on the gcc warnings and upload it on the github.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4756
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #187 on: June 18, 2023, 01:36:02 am »
Beehive doesn't actually crash here, trying to use a debugger, it sets up dive, reads the pcx files and then cleanly exits.
Code: [Select]
ULONG Initialize( VOID )
{
   // Create a dive instance
   //
   ulrc = SetupDive();
   if( ulrc )
      return ulrc;

   ulrc = ReadFile( (PSZ) "bee1.pcx", &bmpImage1 );     // bee moving right
   ulrc += ReadFile( (PSZ) "bee1b.pcx", &bmpImage1b );   // bee moving right wit
   ulrc += ReadFile( (PSZ) "bee2.pcx", &bmpImage2 );     // bee moving left
   ulrc += ReadFile( (PSZ) "bee2b.pcx", &bmpImage2b );   // bee moving left with
   ulrc += ReadFile( (PSZ) "honey.pcx", &bmpBackGround );
   if( ulrc )
      return ulrc;

Seems after the return ulrc it closes the dive instance, windows and cleanly exits.
Trying to trace into ReadFile() leads to CCLYDNOS2.5.S and idbug doesn't seem to want to step through the assembly.
Here's the debug build in case someone who knows debuggers wants to try figuring it out. Any native debugger should work

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #188 on: June 20, 2023, 03:52:18 am »
FYI

The gcc working version of COLORS is now on Github: https://github.com/OS2World/DEV-SAMPLES-C-PM-Colors
Thanks Lars.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #189 on: June 20, 2023, 08:05:00 am »
Beehive doesn't actually crash here, trying to use a debugger, it sets up dive, reads the pcx files and then cleanly exits.
Code: [Select]
ULONG Initialize( VOID )
{
   // Create a dive instance
   //
   ulrc = SetupDive();
   if( ulrc )
      return ulrc;

   ulrc = ReadFile( (PSZ) "bee1.pcx", &bmpImage1 );     // bee moving right
   ulrc += ReadFile( (PSZ) "bee1b.pcx", &bmpImage1b );   // bee moving right wit
   ulrc += ReadFile( (PSZ) "bee2.pcx", &bmpImage2 );     // bee moving left
   ulrc += ReadFile( (PSZ) "bee2b.pcx", &bmpImage2b );   // bee moving left with
   ulrc += ReadFile( (PSZ) "honey.pcx", &bmpBackGround );
   if( ulrc )
      return ulrc;

Seems after the return ulrc it closes the dive instance, windows and cleanly exits.
Trying to trace into ReadFile() leads to CCLYDNOS2.5.S and idbug doesn't seem to want to step through the assembly.
Here's the debug build in case someone who knows debuggers wants to try figuring it out. Any native debugger should work

If you cannot debug into ReadFile, then something is going awfully wrong as it is part of the code.
WRC might be a problem: I ran into the problem that the VAC installation contained a very outdated version of RC that would create an invalid binary when binding the compiled resources to the executable. You can just use the toolkit supplied exehdr.exe to check the exe for the memory objects it contains.
Might be a prob with WRC also.

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #190 on: June 20, 2023, 07:34:36 pm »
Hi Lars.

Thanks for taking a look at it.  I have compiled beehiveb3 with gcc, it compiles with warnings, but the .exe just keep crashing on execution.
Just in case here it is attached is your same code with my makefile.  Even if I fix some of the warning, it still does not load.

Regards

Try the exe that I built. If it works, you have a problem with compiling. If it does not work, then let me know how many colors your desktop uses. Mine uses 32-bit color resolution. Maybe you are using 256 colors (color palette) and that might be a problem with DIVE.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #191 on: June 20, 2023, 09:42:03 pm »
Hi Lars

I tried the compiled beehive.exe with different colors settings on my VM:
- with 16M does not run
- with 65K does not run
- with 256 does not run

What "does not run" means? it loads and exists quickly without showing anything on the screen. It does not produces any POPUPLOG. I don't know if I can take any other log.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4756
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #192 on: June 21, 2023, 01:56:34 am »
Beehive doesn't actually crash here, trying to use a debugger, it sets up dive, reads the pcx files and then cleanly exits.
Code: [Select]
ULONG Initialize( VOID )
{
   // Create a dive instance
   //
   ulrc = SetupDive();
   if( ulrc )
      return ulrc;

   ulrc = ReadFile( (PSZ) "bee1.pcx", &bmpImage1 );     // bee moving right
   ulrc += ReadFile( (PSZ) "bee1b.pcx", &bmpImage1b );   // bee moving right wit
   ulrc += ReadFile( (PSZ) "bee2.pcx", &bmpImage2 );     // bee moving left
   ulrc += ReadFile( (PSZ) "bee2b.pcx", &bmpImage2b );   // bee moving left with
   ulrc += ReadFile( (PSZ) "honey.pcx", &bmpBackGround );
   if( ulrc )
      return ulrc;

Seems after the return ulrc it closes the dive instance, windows and cleanly exits.
Trying to trace into ReadFile() leads to CCLYDNOS2.5.S and idbug doesn't seem to want to step through the assembly.
Here's the debug build in case someone who knows debuggers wants to try figuring it out. Any native debugger should work

If you cannot debug into ReadFile, then something is going awfully wrong as it is part of the code.
WRC might be a problem: I ran into the problem that the VAC installation contained a very outdated version of RC that would create an invalid binary when binding the compiled resources to the executable. You can just use the toolkit supplied exehdr.exe to check the exe for the memory objects it contains.
Might be a prob with WRC also.

Using rc didn't help.
CCLYDNOS2.5.S is actually crt0.obj and things seem to hang with the debugger only responding to r (run) and the desktop frozen with only the one window of the debugger (idbug.exe) responsive.
It's possible it is a problem with the stack setup, GCC is not 100% compatible for debugging code. IIRC occasionally it uses the stack in a way the debugger doesn't expect.
Of course I am far from being knowledgeable about debugging.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4756
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #193 on: June 21, 2023, 02:00:14 am »
Hi Lars

I tried the compiled beehive.exe with different colors settings on my VM:
- with 16M does not run
- with 65K does not run
- with 256 does not run

What "does not run" means? it loads and exists quickly without showing anything on the screen. It does not produces any POPUPLOG. I don't know if I can take any other log.

Regards

No popup complaining about not enough colours with 256 colours? Should be a WinMessageBox "usage: The sample program can not run on this system environment."

Lars

  • Hero Member
  • *****
  • Posts: 1262
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #194 on: June 21, 2023, 09:23:28 am »
Hi Lars

I tried the compiled beehive.exe with different colors settings on my VM:
- with 16M does not run
- with 65K does not run
- with 256 does not run

What "does not run" means? it loads and exists quickly without showing anything on the screen. It does not produces any POPUPLOG. I don't know if I can take any other log.

Regards

Long story short: the executable that I attached works perfectly on my system. I am using eCS under Virtualbox. Even full screen support works but under Virtualbox, it does not make much sense (as it does not stretch across the full screen, of course).
I am using plain GENGRADD in the eCS guest (anything else will not improve performance anyways).
If you use Panorama: the problem is that Panorama and DIVE do not go together well. I think you will need to disable "shadow buffer". But of course, Panorama will then become totally unresponsive.

« Last Edit: June 21, 2023, 09:55:12 am by Lars »