Author Topic: ClassiCube porting thread  (Read 17144 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
ClassiCube porting thread
« on: April 18, 2024, 08:24:42 am »
I'm trying to use pure OS/2 for ClassiCube instead the much unsupported SDL2 window system (it even has a big #error Don't use it sign at the entry).
So I'm trying to use DIVE, but all I get is the frame window and the background in it. When I move the window around, the background stays in it, i.e. nothing gets drawn.
I looked at the SDL implementation and the Toolkit samples, but I can't understand, what's wrong with my code.

If somebody please can take a look at the attached code give me some hints. I think the ClassiCube code is well structured and understandable, but if you have questions about ask me.

Thanks
« Last Edit: April 25, 2024, 10:53:58 pm by Jochen Schäfer »

Flashback

  • Newbie
  • *
  • Posts: 11
  • Karma: +3/-1
    • View Profile
Re: Dive: Why does not this work
« Reply #1 on: April 18, 2024, 06:28:12 pm »
I seem to remember, that DIVE doesn't like 'BGR4'. Try to set up your source buffer as 'BGR3'. Also I don't see, where 'fccColorFormat' is initialized.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #2 on: April 19, 2024, 12:55:32 am »
Actually, BGR4 was what the driver was given me as screen color scheme. Also it's only the color scheme for the frame buffer, which gets blitted to the screen color scheme.
« Last Edit: April 19, 2024, 07:27:17 am by Jochen Schäfer »

Flashback

  • Newbie
  • *
  • Posts: 11
  • Karma: +3/-1
    • View Profile
Re: Dive: Why does not this work
« Reply #3 on: April 19, 2024, 08:03:56 pm »
Take a look here. It seems that DIVE doesn't support blitting from 32bit source buffers. No matter what colour depth the screen is using. You may also want to check the return values of DiveSetupBlitter and DiveBlitImage.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #4 on: April 19, 2024, 11:10:24 pm »
Ok, then I have to look how I get that to work.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #5 on: April 20, 2024, 09:52:13 am »
Well, using BGR3 or RGB3 as draw buffer doesn't change anything.
I still have only frame with the desktop background in it.

Lars

  • Hero Member
  • *****
  • Posts: 1349
  • Karma: +68/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #6 on: April 20, 2024, 12:39:55 pm »
Look at the OS/2 toolkit, in the "beehive" sample code (in that code you can ignore everything that centers around sprite creation. You can also ignore everything that centers around full screen DIVE unless you really want to do that, that includes loading GAMESVR [deprecated since Warp 4] or PMMERGE  Dive Fullscreen Init procedure).

I think you will need to support the WM_VRNDISABLED and WM_VRNENABLED window messages and use DiveAllocImageBuffer,DiveBlitImage,DivFreeImageBuffer. Note that the sample does the blitting from a secondary thread.

Also note that you cannot do "direct mode" when you are using Panorama with "Shadow Buffer Enabled". Since that is the setting that about 95% of all remaining OS/2 users will use, you should honour that.

« Last Edit: April 20, 2024, 01:10:05 pm by Lars »

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #7 on: April 20, 2024, 02:52:58 pm »
Look at the OS/2 toolkit, in the "beehive" sample code (in that code you can ignore everything that centers around sprite creation. You can also ignore everything that centers around full screen DIVE unless you really want to do that, that includes loading GAMESVR [deprecated since Warp 4] or PMMERGE  Dive Fullscreen Init procedure).

I think you will need to support the WM_VRNDISABLED and WM_VRNENABLED window messages and use DiveAllocImageBuffer,DiveBlitImage,DivFreeImageBuffer. Note that the sample does the blitting from a secondary thread.
Yes, I do use the Dive functions, but WM_VRNDISABLED AND WM_VRNENABLED are not much use for me, since Classicube gives me the rectangles it wants to paint to, anyway. Moreover, SDL2 works without using the window messages, so it seems optional.

Also note that you cannot do "direct mode" when you are using Panorama with "Shadow Buffer Enabled". Since that is the setting that about 95% of all remaining OS/2 users will use, you should honour that.
How can I get the option?

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4982
  • Karma: +109/-1
    • View Profile
Re: Dive: Why does not this work
« Reply #8 on: April 20, 2024, 04:35:29 pm »
Code from Mozilla (widget\os2\nswindow.cpp #405), for querying whether the shadow buffer is enabled
Code: [Select]
  // Don't use DIVE if the Panorama video driver is in use
  // unless its shadow buffer is turned off.
  HMODULE hmod;
  if (!DosQueryModuleHandle("PANOGREX", &hmod)) {
    char      str[8];
    if (PrfQueryProfileString(HINI_USERPROFILE, "PANORAMA", "VBEShadowBuffer",
                              0, str, sizeof(str)) && !strcmp(str, "0")) {
      sUseDive = TRUE;
      printf("Video driver is Panorama - shadow-buffer is disabled\n");
    }
    else
      printf("DIVE is disabled - Panorama's shadow-buffer is enabled\n");

    return;
  }

  sUseDive = TRUE;

Flashback

  • Newbie
  • *
  • Posts: 11
  • Karma: +3/-1
    • View Profile
Re: Dive: Why does not this work
« Reply #9 on: April 21, 2024, 12:15:55 am »
Yes, I do use the Dive functions, but WM_VRNDISABLED AND WM_VRNENABLED are not much use for me, since Classicube gives me the rectangles it wants to paint to, anyway. Moreover, SDL2 works without using the window messages, so it seems optional.
Really? Does it correctly handle the situation when the application window is partly obscured by another desktop window?

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #10 on: April 21, 2024, 03:22:49 am »
Code from Mozilla (widget\os2\nswindow.cpp #405), for querying whether the shadow buffer is enabled
Code: [Select]
  // Don't use DIVE if the Panorama video driver is in use
  // unless its shadow buffer is turned off.
  HMODULE hmod;
  if (!DosQueryModuleHandle("PANOGREX", &hmod)) {
    char      str[8];
    if (PrfQueryProfileString(HINI_USERPROFILE, "PANORAMA", "VBEShadowBuffer",
                              0, str, sizeof(str)) && !strcmp(str, "0")) {
      sUseDive = TRUE;
      printf("Video driver is Panorama - shadow-buffer is disabled\n");
    }
    else
      printf("DIVE is disabled - Panorama's shadow-buffer is enabled\n");

    return;
  }

  sUseDive = TRUE;
Thanks.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #11 on: April 21, 2024, 03:24:28 am »
Yes, I do use the Dive functions, but WM_VRNDISABLED AND WM_VRNENABLED are not much use for me, since Classicube gives me the rectangles it wants to paint to, anyway. Moreover, SDL2 works without using the window messages, so it seems optional.
Really? Does it correctly handle the situation when the application window is partly obscured by another desktop window?
No need to get snarky. I don’t get anything, so I‘m really not interested in obscured windows in the first place.

Lars

  • Hero Member
  • *****
  • Posts: 1349
  • Karma: +68/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #12 on: April 21, 2024, 11:45:27 am »
I don't think that checking for shadow buffer is worth the effort. Todays systems with the video memory addressable as write combined memory are more than fast enough for your purposes. Just always use DiveBlitImage, following the beehive sample. That sample works perfectly well with the shadow buffer enabled.

Lars

  • Hero Member
  • *****
  • Posts: 1349
  • Karma: +68/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #13 on: April 22, 2024, 11:23:35 am »
Look at the OS/2 toolkit, in the "beehive" sample code (in that code you can ignore everything that centers around sprite creation. You can also ignore everything that centers around full screen DIVE unless you really want to do that, that includes loading GAMESVR [deprecated since Warp 4] or PMMERGE  Dive Fullscreen Init procedure).

I think you will need to support the WM_VRNDISABLED and WM_VRNENABLED window messages and use DiveAllocImageBuffer,DiveBlitImage,DivFreeImageBuffer. Note that the sample does the blitting from a secondary thread.
Yes, I do use the Dive functions, but WM_VRNDISABLED AND WM_VRNENABLED are not much use for me, since Classicube gives me the rectangles it wants to paint to, anyway. Moreover, SDL2 works without using the window messages, so it seems optional.

Look at the help for the "DiveSetupBlitter" function. You need to support WM_VRNDISABLED and WM_VRNENABLED in order to notify the Dive Blitter via "DiveSetupBlitter" that changes to the visible regions will start or end to occur.
On a reception of WM_VRNDISABLED you need to disable the blitter, on a reception of WM_VRNENABLED you will need to set up again the blitter with the proper values.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Dive: Why does not this work
« Reply #14 on: April 22, 2024, 11:33:25 am »
I understand that, but Classicube calls the draw buffer function with a rectangle to paint, so I setup the blitter in the draw function. This should work I would think.