-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build AppleWin & LinApple from the same source? #274
Comments
Great. Thanks! I have fixed a problem in LinApple with the Alt key failing to emulate the Open Apple key. But, what I changed actually seems to work in AppleWin (unchanged). I'm wondering if anyone can explain how this works: Joystick.cpp: 279: keydown[JK_OPENAPPLE+(extended != 0)] = down; The '+(extended != 0)' part causes the failure in LinApple. When this is removed the Alt key works fine in LinApple. What is the 'extended' variable supposed to represent, and how does this not break AppleWin as the wrong element of the array is set when extended==1? |
My project is here: https://github.com/gungwald/applelin I also have applied a patch posted on SourceForge that fixes LinApple under Linux on the PowerPC (Big Endian) architecture. I'm developing on Debian PowerPC 7.8 with a PowerBook G4 which I bought on e-bay for $50 just for fun. |
Yeah, we definitely to coordinate and get AppleWin in better cross-platform / porting shape. This is still a long term "wish list" to have official support so all efforts are appreciated even if it seems there is no traction. |
I can confirm that 1.25.0.3 maxes out 1 CPU when running in wine. What (and where in the code) does AppleWin do in its idle loop. Maybe is uses Windows calls that do not work well in wine. |
I assume that AppleWin under Wine runs at the correct speed?
Maybe Wine's implementation of this DirectSound clock is via some sort of busy-wait loop? |
re. I can confirm that 1.25.0.3 maxes out 1 CPU when running in wine. |
Thanks for the info. I had a look and I can confirm that ~ 97% of running time is inside the WaitForSingleObject(). Tried to replace the DirectSound IReferenceClock with a direct call to CreateWaitableTimer and the CPU usage drops by 50% (in wine). Even in a "do nothing" app waiting on a timer every 1ms the same pattern is visible (DirectSound vs CreateWaitableTimer), will have to ask the wine guys about it. Still it use a lot more CPU then it should. Now, before even mentioning a patch (there is actually no bug to fix in AppleWin), CreateWaitableTimer has a resolution of 1 ms, while the code seems to allow for micro seconds periods (even though it is 1000 microseconds = 1 millisecond always). I could not find an other Windows normal (i.e. non DirectSound) call with a resolution < 1ms. Were there any particular reason for the choice of DirectSound for the timer event generation? |
Hi,
When we switched to DirectSound for the timer, AppleWin was still supporting Win98(*). But CreateWaitableTimer has a minimum supported OS of WinXP: (*) In fact, it will only be the next 1.26 release that we will drop support for Win98 by building with VS2008 (instead of VS2005). With VS2008 the minimum OS becomes Win2000. (Ref #124) |
I will report some more details of my findings, but so far I've found 4 timer functions in Windows
In wine the first one seems to be implemented as a spin lock, the others as proper wait. Moreover using the last 3, the CPU usage in wine decreases when "nExecutionPeriodUsec" in Applewin.cpp:168 increases (as they are called less often). So anybody willing to recompile Applewin to run it in wine, they could change timer function and optionally increase the execution period (with AdvisePeriodic it is useless as it behaves similarly to a spinlock). |
I've timed the 4 implementations above in a test app (http://pastebin.com/wt4iTL78) With periods of 1 ms and out of a total wait of 10 sec, I get the following times spent in "sys" using the "time" app
The feeling is a spin lock for the first. As soon as I get a VS install running somewhere (wine / VB) I will post a modified AppleWin for other Linux users interested to try. |
Good news, wine developers seems to have found an issue in IReferenceClock->AdvisePeriodic see here http://article.gmane.org/gmane.comp.emulators.wine.devel/102107 once I get (or compile) such a wine I will let you know |
Very interesting. Thanks for sharing this (and pursuing this with the Wine dev team). |
Thanks from me too. I can't wait to see it work.
Very interesting. Thanks for sharing this (and pursuing this with the Wine dev team).— |
I've pushed a code change to use CreateWaitableTimer, which behaves better for the time being and according to wine-devel is anyway better implemented then all the others. https://github.com/audetto/AppleWin branch wine, if you want to compile it. I still have an other issue with sound, but I will open an other ticket for it. |
The timer patch should land in wine 1.7.45 http://source.winehq.org/git/wine.git/commit/b513e07c55504f623baf8d838d00ac628eac7614 |
Very cool. Thanks!
The timer patch should land in wine 1.7.45http://source.winehq.org/git/wine.git/commit/b513e07c55504f623baf8d838d00ac628eac7614— |
That's great news -- Thanks for taking the time to investigate and patch Sent from my iPhone On Jun 25, 2015, at 1:27 PM, Andrea notifications@github.com wrote:
|
wine 1.7.45 is out but I don't think I works as it should. I compare the requested period with the actual period, and for 1ms wait things can get really bad. It used to be 1ms in both cases. I reported the fact, let's see if they can improve the patch. |
Thanks for including the source for the test case! Since pastebin is not permanent .... including it here as a reference. |
|
With the latest versions of AppleWin and Wine on Fedora 21, I no longer see the processes taking up 100% of the CPU. I'm not sure if Wine is doing exactly the right wait time, but it is not causing a problem anymore. Thanks for the fixes on this. This solves the problem for Linux on Intel-based hardware because Wine can successfully be used to run AppleWin. However, a good Apple II emulator for Linux non-Intel hardware, such as ARM and PowerPC, is still lacking. I'm not up to working on that right now so I'll close this issue since my main problem was solved. I may come back to it later and will re-open something at that time. Thanks again. |
Hi,
For future reference can you just confirm which versions of AppleWin and Wine you used? Thanks. |
AppleWin 1.25.0.3 Note that I misstated the Fedora version before as 21. It is actually 22. |
I have a stupid question now. Why it is called as no AppleLin but it is I am sorry for putting totally different story from the discussion although James On Tue, Aug 25, 2015 at 5:46 PM, Bill Chatfield notifications@github.com
Best regards,
|
The original person who ported AppleWin to Linux just liked the sound of LinApple better, so he used that name. My fork of LinApple, I did call AppleLin. Now I'm so confused I can't ever remember what the correct names are. |
That's so much understandable. LinApple sounds better for me as well, like James S Kim On Wed, Aug 26, 2015 at 12:25 AM, Bill Chatfield notifications@github.com
Best regards,
|
On Linux we have LinApple, but it is based on a very old version of AppleWin. So, all the improvements that have been made in AppleWin are not available in LinApple. It would be nice if it would be possible to support a Linux build directly from the AppleWin sources, if there were a way to do this without making a mess of the source code. I'm currently looking at LinApple to see how it was done. I hope to come up with some ideas on how it would be possible to build a Linux version directly from AppleWin, so that improvements could be shared across the platforms.
AppleWin runs nicely in Wine on Linux, except that it continually takes up 100% of the CPU. I'm sure it's a problem with Wine and not AppleWin. But a native Linux version would be preferable.
Thanks. Let me know what your thoughts on this are.
The text was updated successfully, but these errors were encountered: