v0.55 (20 July 2002)
(C) 2002 Niall Douglas
CallWin32 is a podule emulator for Red Squirrel v0.58 or later (or VirtualAcorn). It permits any RISC-OS code to execute arbitrary Win32 calls via a SWI interface and is compatible with the Wimp2 preemptive multitasker for RISC-OS.
All files or additions created by myself (ie; under my copyright) are hereby placed under the GNU General Public Licence. You can find it in a gpl.txt file within the archive.
From hereafter, when we refer to Red Squirrel, we also mean VirtualAcorn.
This tiny application called "RSTools" in the archive currently returns spare RISC-OS time to Windows ie; instead of it using 100% of your processor, it will now only use what it needs. Place it in your boot sequence to automatically have it present. You can quit it from the Task Manager if you ever need to (unlikely).
It is intended to greatly extend the "Red Squirrel Tools" application which comes with CallWin32. It is hoped the following features can be added:
One very useful thing which I won't be doing is exposing the Win32 clipboard to RISC-OS. It's not difficult for basic things like text (graphics are a bit harder), but someone else can do it. I suggest a little window with an icon you can drag out (import clipboard) and drag into (export clipboard).
To install, copy the CallWin32 directory from this archive into the Plugins directory within the Red Squirrel. Modify your model config file which resides in the Models directory to include the following lines:
[CallWin32Podule] podule = <n>
... where <n> is a free podule slot.
When you now boot using your modified model, a new module called CallWin32 will be present. It provides the following SWI's:
See each SWI individual documentation page for more information. The following error codes can also be returned:
You will probably want some examples to show you how it works:
PRINT TIME SYS "CallWin32_Immediate","stdcall:kernel32::Sleep",1,3000 PRINT TIME PRINT "Note the entire VM stops"
A more complicated example is as follows:
REM > TestCWR3 SYS "CallWin32_Info" TO ,size% DIM q% size% SYS "CallWin32_ParsInit",q% : REM To fetch an OSVERSIONINFO struct DIM osv% 256 !osv%=148:REM sizeof(OSVERSIONINFO) SYS "CallWin32_ParsAddMemBlk",q%,1,osv%,256 SYS "CallWin32_WithPars",q%,"stdcall:kernel32::GetVersionExA" TO success%,errcode% IF success% THEN major%=osv%!4 minor%=osv%!8 build%=osv%!12 PRINT "Your version of Windows is ";major%;".";minor%;" (build ";build%;": ";FNgetz(osv%+20);")" ELSE PRINT "Call failed with error code ",errcode% ENDIF END : DEF FNgetz(a%) a$="" WHILE ?a% a$+=CHR$(?a%) a%+=1 ENDWHILE =a$
You can find these programs in the archive. You may need to set their filetype before they will run.
Y'know, four years ago I never ever envisaged myself ever programming for the Acorn again. And then in 1999 I released Wimp2, my preemptive multitasker for RISC-OS, to an Acorn scene which was clearly near-dead as indeed I had predicted many years before during the ill-fated Tornado project. The huge backward compatibility in RISC-OS was a bad thing, not a good thing - without advance, things wither. Still, after 1999 I really really never thought I'd use another Acorn again.
And well, here I am July 2002 writing relocatable modules once again. Strange how fate can be so strange. The rest of the world has caught up with RISC-OS but still, even in 2002, there are quite a number of things RISC-OS does better than anyone else - KDE, Linux, Win32 or MacOS. It's been strange to be back in that environment again - nowadays little things about RISC-OS annoy me, but still even now it is a superior environment. Even after the countless systems I have programmed for professionally in the last five years, I still find good things in RISC-OS I wish I could use every day.
Furthermore, ex-RISC-OS programmers have proven to be some of the best on the planet. They are extremely flexible programmers, happy to tackle all sorts of weird systems and produce code of second-to-none quality. I find it strange when I talk with managers from around the world that they know of Acorn not because its technical superiority in the 80's, but because consistently their best remembered employees had an Acorn background. If nothing else, RISC-OS is an excellent teacher of good programming, and it is an excellent testament to the seven or so original programmers some of whom it has been my good fortune to work with.
But what of the future? Well, so long as some things remain easier to do in RISC-OS, I shall be using the Acorn emulator by Graeme Barnes to work in conjunction with Windows and Linux. Believe it or not, I have worked some projects with Linux running in VMWare and VirtualAcorn on files mapped using HostFS off a samba share in VMWare. Now if only I could drag enough money together for three monitors, I could have all three systems on a monitor each ...
Obviously, the success of any emulated system is its integration with the host OS. VMWare does a minimum of this, and it is my intention to get Red Squirrel up to at least that point. To that end, the first step is clearly a method of RISC-OS being able to call Win32 and it is my hope that that has been done with CallWin32.
20th July 2002 v0.55: Added memory block support and fixed quite a few bugs. Upped to v0.55. Made a little app to return idle RISC-OS time. Released publicly for the first time
19th July 2002 v0.50: Released as beta to Red Squirrel mailing list
My thanks to Graeme Barnes for his invaluable help in developing CallWin32.
Niall Douglas
20th July 2002
http://www.nedprod.com/programs/RISC-OS/CallWin32/
CallWin32Support@nedprod.com