Author Topic: 8er MagicSquare  (Read 10539 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
8er MagicSquare
« on: January 30, 2011, 04:57:12 AM »
deleted

[attachment deleted by admin]

.
« Last Edit: April 11, 2015, 09:01:42 AM by Peter »

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #1 on: January 30, 2011, 09:20:14 AM »
Thanks Peter,

I think I've got an algorithm. ;D

Hint: clockwise 1236874

Charles

PS: GPF on termination - something left on the stack?


.

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #2 on: January 30, 2011, 08:53:17 PM »

Peter,

I found there was something that prevented your 5x5 Magic square from working when compiled as a standalone (with RTL32).

I traced this to an error in Win_G.inc.

Code: [Select]
Bind user32
(
  LoadIcon         LoadIconA       
  LoadCursor       LoadCursorA       
  RegisterClass    RegisterClassA   
  MessageBox       MessageBoxA       
  SendMessage      SendMessageA  '<---- was SendMessage
  GetMessage       GetMessageA

I also removed "ExitProcess" from WinEnd allowing the O2 epilog procedures to perform their normal duties.

Code: [Select]
Function WinEnd()             
FreeGraphics
DestroyWindow sys_hwnd 
'ExitProcess 0  '<-----Now removed
End Function

Would it be okay to adopt these changes in your standard Win_G.inc? (zipped below)


Charles

.

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #3 on: January 31, 2011, 05:26:05 AM »
Thanks Peter,

Here is the amended Func.inc (SendMessage --> SendMessageA)
WinEnd was okay.

Charles


.

JRS

  • Guest
Re: 8er MagicSquare
« Reply #4 on: January 31, 2011, 09:59:49 AM »
Quote
I also removed "ExitProcess" from WinEnd allowing the O2 epilog procedures to perform their normal duties.

I wonder if this is the reason I see the client area of peter's programs overwriting the upper left corner of my Linux desktop when his program examples end.


Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #5 on: January 31, 2011, 02:11:56 PM »

Yes Wine could well be more sensitive to libraries closing prematurely - X-Windows is likely to behave differently from MS Windows in unexpected circumstances.

Charles

JRS

  • Guest
Re: 8er MagicSquare
« Reply #6 on: January 31, 2011, 07:00:03 PM »
Charles,

I updated the win_g.inc with yours and did a recompile of peter's magic squares game. It still leaves a mess. I have stopped trying peter's demos due to this problem.


John

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #7 on: February 01, 2011, 01:07:32 AM »

Hi John,

I've just installed Wine and am slowly getting familiar with this environment where everything is slightly different from MS. I've run some of the Oxygen standard examples so far. One interesting result is that I was able to run OpenGL Child windows and resize it without getting the problem that you encountered. (We may have a driver/Graphics card issue here, not directly related to Wine.)

Anyway I hope to look at some of Peter's code running under Wine and see if we can find a solution.

One thing I need to know is how to get a DOS console running under Wine?

Charles

JRS

  • Guest
Re: 8er MagicSquare
« Reply #8 on: February 01, 2011, 02:11:23 AM »
Quote
One thing I need to know is how to get a DOS console running under Wine?

In a Linux console type the following.

wineconsole cmd

Z:\ is your Linux home root.

C:\  is /home/you/.wine/drive_c  

FYI: you may need to right click (if in Nautilus) and make the .exe have executable permission if the file wasn't created as part of a Windows install.

Quote
may have a driver/Graphics card issue here, not directly related to Wine

Glad to hear it's working there. It's more than likely is my old POS laptop that is the problem. I have to run in no theme goodies mode as I have problems even using minimal effects.  >:(

On the other hand, the Gambas OpenGL demos run smooth as glass. (native)
« Last Edit: February 01, 2011, 02:36:32 AM by JRS »

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #9 on: February 01, 2011, 09:56:31 AM »

The problem appears to be FlipBuffer(). Perhaps this should only be done in response to a WM_Paint message. I will investigate further

Charles

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #10 on: February 01, 2011, 10:23:15 AM »
I think Wine has expectations as to when an image can be rendered. I will try invalidateRect.. paintstruct etc.

Charles

JRS

  • Guest
Re: 8er MagicSquare
« Reply #11 on: February 01, 2011, 10:56:28 PM »
That brings up the question is Windows smart enough to realize what the programmer meant to do and recover or did Windows miss the boat altogether and the problem ending up getting redirected to Winull? (NOP with a few layers)




« Last Edit: February 01, 2011, 11:01:19 PM by JRS »

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #12 on: February 02, 2011, 02:39:13 AM »

With a few modifications I've got Peter's Magic square and 3D demo working quite well with Wine/Linux.

The two most important things are:

1: Only update the screen buffer when a WM_PAINT message is given - otherwise it may paint in the wrong place and make a mess on the desktop.

2: mask out the upper 16 bits of the value returned from GetAsyncKeyState() otherwise you will get false positives when testing individual keyboard keys.


Other mods are directed towards reducing CPU workload and ensuring that the window can be moved around the screen without disrupting its image refresh.

I have a few more issues to deal with concerning fonts, and will need to investigate another source of memory leaks which is an Oxygen garbage collection problem and quite easy to work around.

Charles


JRS

  • Guest
Re: 8er MagicSquare
« Reply #13 on: February 02, 2011, 11:11:59 AM »
Quote
I have a few more issues to deal with concerning fonts

Make sure you install the Windows/Wine font pack. Using Winetricks should do the ...

http://wiki.winehq.org/winetricks

You can use Ubuntu Synaptics (default installer) to get Winetricks.

Quote
Wine is a compatibility layer for running Windows applications on Linux.
Applications are run at full speed without the need of cpu emulation. Wine
does not require Microsoft Windows, however it can use native system dll
files in place of its own if they are available.

Note: Check the Wine site for the few Wine specific DLLs that can't be replaced with the Windows equivalents.
« Last Edit: February 02, 2011, 11:41:13 AM by JRS »

Charles Pegge

  • Guest
Re: 8er MagicSquare
« Reply #14 on: February 02, 2011, 12:14:43 PM »
I'll get those fonts John, thanks. I was able to fix the font problem by avoiding "courier" and specifying "roman" instead. It probably did not know what Roman was but came up with a good looking monospaced font instead a scrambled Courier.

Peter,
Your test code above did not work correctly in Linux, partly due to the Courier font, and dumped all its pixels onto the desktop at the end. But here are compatible versions of the magic square and the 3d demo.

I made a number of changes to Func.inc.

1 Replace peekMessage with GetMessage. This eliminates frenetic looping.
2 Call a render() procedure from wndproc on the WM_PAINT message.
3 Respond to the WM_ERASEBKGND message returning 1. This maintains a clean window when moving.

On the App side.

1 provide render() procedure that can be called from WndProc (on WM_PAINT message).
2 bypass rendering when there is no user activity (the act flag)
3 sleep for 10ms instead :)

I am sure the logic controlling the keydown, buttondown and act flags can be improved. They reduce CPU activity to almost nil when the user is not interacting.

Charles

PS: the Magic square needs the media folder (not included)

.
« Last Edit: February 02, 2011, 12:18:02 PM by Charles Pegge »