[Vm-dev] [commit][2674] changes to support sound output, modernise some parts and update the license

commits at squeakvm.org commits at squeakvm.org
Thu Jan 24 20:08:42 UTC 2013


Revision: 2674
Author:   rowledge
Date:     2013-01-24 12:08:41 -0800 (Thu, 24 Jan 2013)
Log Message:
-----------
changes to support sound output, modernise some parts and update the license

Modified Paths:
--------------
    trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!Help
    trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!run
    trunk/platforms/RiscOS/misc/ToCopy/READMERIGHTNOW
    trunk/platforms/RiscOS/plugins/FileCopyPlugin/sqRPCFileCopy.c
    trunk/platforms/RiscOS/plugins/FilePlugin/sqFilePluginBasicPrims.c
    trunk/platforms/RiscOS/plugins/FilePlugin/sqRPCDirectory.c
    trunk/platforms/RiscOS/plugins/LocalePlugin/sqRPCLocale.c
    trunk/platforms/RiscOS/plugins/SecurityPlugin/sqRPCSecurity.c
    trunk/platforms/RiscOS/plugins/SocketPlugin/sqRPCNetPlugin.c
    trunk/platforms/RiscOS/plugins/SoundPlugin/sqRPCSound.c
    trunk/platforms/RiscOS/vm/config.h
    trunk/platforms/RiscOS/vm/fperrors.s
    trunk/platforms/RiscOS/vm/osExports.c
    trunk/platforms/RiscOS/vm/sqArgument.c
    trunk/platforms/RiscOS/vm/sqArguments.h
    trunk/platforms/RiscOS/vm/sqConfig.h
    trunk/platforms/RiscOS/vm/sqPlatformSpecific.h
    trunk/platforms/RiscOS/vm/sqRPCClipboard.c
    trunk/platforms/RiscOS/vm/sqRPCEvents.c
    trunk/platforms/RiscOS/vm/sqRPCExternalPrims.c
    trunk/platforms/RiscOS/vm/sqRPCFormPrint.c
    trunk/platforms/RiscOS/vm/sqRPCMain.c
    trunk/platforms/RiscOS/vm/sqRPCSyscall.c
    trunk/platforms/RiscOS/vm/sqRPCVersion.c
    trunk/platforms/RiscOS/vm/sqRPCWindows.c

Removed Paths:
-------------
    trunk/platforms/RiscOS/misc/ToCopy/!Squeak/modules/TimerMod/

Modified: trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!Help
===================================================================
--- trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!Help	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!Help	2013-01-24 20:08:41 UTC (rev 2674)
@@ -87,7 +87,7 @@
 
 The legal bit
 =============
-The license under which Squeak is provided - the MIT License, with some portions covered by the Apache License version 2.0-   can be found in full on http://www.squeak.org
+The license under which Squeak is provided - the MIT License, with some portions covered by the Apache License version 2.0 - can be found in full on http://www.squeak.org
 
 Finally
 -------

Modified: trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!run
===================================================================
--- trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!run	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/misc/ToCopy/!Squeak/!run	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,15 +1,17 @@
 Wimpslot -min 400K  -max 700k
 Set Squeak$Dir <Obey$Dir>
 
-| Timers: we're either using the druck TimerMod or the Rik Griffin HALTimer
-
-| Make sure the MillisecondTimer & HALTimer module are loaded
-RMEnsure HALTimer 0.03 RMLoad <Squeak$Dir>.modules.HALTimer
+|  Make sure the MillisecondTimer & HALTimer module are loaded
+RMEnsure HALTimer 0.05 RMLoad <Squeak$Dir>.modules.HALTimer
+RMEnsure HALTimer 0.05 Error You need HALTimer 0.05 or later
 RMEnsure MillisecondTimer 1.00 RMLoad <Squeak$Dir>.modules.MillisecondTimer
-|
-|RMEnsure TimerMod 4.12 RMLoad <Squeak$Dir>.modules.TimerMod.TimerMod
+RMEnsure MillisecondTimer 1.00 Error You need MillisecondTimer 1.00 or later
+|  Sound support modules
+RMEnsure StreamManager 0.03 RMLoad System:Modules.StreamMan
+RMEnsure StreamManager 0.03 Error You need StreamManager 0.03 or later
+RMEnsure SharedSoundBuffer 0.07 RMLoad System:Modules.SSBuffer
+RMEnsure SharedSoundBuffer 0.07 You need SharedSoundBuffer 0.07 or later
 
-
 | syntax:
 | {appname} [-vmoption [-vmoption]] imagefilepath [startupfile/URL] [imageoption [imageoption]]
 | vmoptions -

Modified: trunk/platforms/RiscOS/misc/ToCopy/READMERIGHTNOW
===================================================================
--- trunk/platforms/RiscOS/misc/ToCopy/READMERIGHTNOW	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/misc/ToCopy/READMERIGHTNOW	2013-01-24 20:08:41 UTC (rev 2674)
@@ -6,11 +6,11 @@
 a) the image and changelog files.
   The image file is the recorded state of a Squeak system and the changelog is a matching audit trail of what code changes have been made since a certain point in time.  You can obtain those two files from the www.squeak.org site and visiting the downloads page and then going to the FTP archive - specifially ftp.squeak.org/4.0/Squeak4.0-basic.zip
 b) the sources file.
-  This is not the sources for the !Squeak application but for the Smalltalk system code. This file is large and has all the Smalltalk code, all the class definitions and comments, for the system. It does not change very often and is not written to by the running system. It too can be obtained from the Squeak site, specifically ftp.squeak.org/4.0/SqueakV40.sources.gz
+  This is not the C/asm sources for the !Squeak application but the Smalltalk system code. This file is large and has all the Smalltalk code, all the class definitions and comments, for the system. It does not change very often and is not written to by the running system. It too can be obtained from the Squeak site, specifically ftp.squeak.org/4.0/SqueakV40.sources.gz
 2) unzip the Squeak4.0-basic.zip file.
   You should end up with a file Squeak4/0-basic/image of size 13478196 bytes, and another file Squeak4/0-basic/changes of size 694 bytes. Change the filetype of the Squeak4/0-basic/image file to faa (STimage). If you don't know how to do this you will need to read that fine manual for RISC OS.
 3) unzip the SqueakV40/sources/gz file - depending on exctly how you downloaded it you may find that it has already been decompressed. I don't know why that seems to happen. You should end up with SqueakV40/sources file of size 16748347 bytes.
 4) move the SqueakV40/sources file *into the !Squeak application*. If you don't know how to do this you will need to read that fine manual for RISC OS.
 5) While you have the aplication directory open, take a moment to *read the frickin !Help file*
 
-Now, you have an installation that can run. Double-click on the Squeak4/0-basic/image file and wait a moment for it to be read in and started up. You should see a medium sized window labelled with the path of the image file and containing a number of slightly odd looking windows. For further help, read the contents of the www.squeak.org site, join the mailing list(s) and ask questions.
\ No newline at end of file
+Now, you have an installation that can run. Double-click on the 'Squeak4/0-basic/image' file and wait a moment (it might take ten seconds or depending your disc speed etc) for it to be read in and started up. You should see a medium sized window labelled with the path of the image file and containing a number of slightly odd looking windows. For further help, read the contents of the www.squeak.org site, join the mailing list(s) and ask questions.
\ No newline at end of file

Modified: trunk/platforms/RiscOS/plugins/FileCopyPlugin/sqRPCFileCopy.c
===================================================================
--- trunk/platforms/RiscOS/plugins/FileCopyPlugin/sqRPCFileCopy.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/FileCopyPlugin/sqRPCFileCopy.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,17 +1,34 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                       sqRPCFileCopy.c                                  */
-/*  hook up to RiscOS file copy to preserve filetypes etc                 */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqRPCFileCopy.c
+// It implements a nasty little primitive that copies a file using the OS call
+// that will keep the filetypes etc as-is.
+// It wouldn't be needed if Squeak had a decent filesystem interface
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
-/* debugging stuff; can probably be deleted */
 //#define DEBUG
 #include "oslib/os.h"
 #include "oslib/osfile.h"
@@ -27,7 +44,7 @@
 
 
 	osfscontrol_copy_flags flag = osfscontrol_COPY_FORCE;
-		PRINTF(("\\t platcopy called\n"));
+		PRINTF(("\\t sqCopyFilesizetosize called\n"));
 
 	if (!canonicalizeFilenameToString(srcName, srcNameSize, fromname))
 		return false;
@@ -35,7 +52,7 @@
 	if (!canonicalizeFilenameToString(dstName, dstNameSize, toname))
 		return false;
 
-		PRINTF(("\\t platcopy names ok\n"));
+		PRINTF(("\\t sqCopyFilesizetosize file names ok\n"));
 
 	e = xosfscontrol_copy(
 		(char const *)fromname,
@@ -44,7 +61,7 @@
 		(bits)0,(bits)0,(bits)0,(bits)0,(osfscontrol_descriptor *)0 );
 
 	if (e != NULL) return false;
-	PRINTF(("\\t platcopy ok\n"));
+	PRINTF(("\\t sqCopyFilesizetosize ok\n"));
 
 	return true;
 }

Modified: trunk/platforms/RiscOS/plugins/FilePlugin/sqFilePluginBasicPrims.c
===================================================================
--- trunk/platforms/RiscOS/plugins/FilePlugin/sqFilePluginBasicPrims.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/FilePlugin/sqFilePluginBasicPrims.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,19 +1,36 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*           sqFilePluginBasicPrims.c                                     */
-/* Replacement for the Cross/plugins/filePlugin/sqFilePluginBasicPrims.c  */
-/* to attempt to provide multiple opening of writable files, thus         */
-/* coping with the idiocy of the FileStream>readOnlyCopy method           */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqFilePluginBasicPrims.c
+// It provides the low level File calls for Squeak, with some twists to
+// handle a few other-platform quirks, such as being able to open the ssame file
+// for read amd read/write multiple times.
+// and to keep life a little simpler within Squeak, RISC OS filenames
+// are converted to a URL-lite format, mainly swapping the '/' for '.'
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
-
 /* define this to get lots of debug reports  */
 //#define DEBUG
 
@@ -26,7 +43,7 @@
 #include "oslib/osfscontrol.h"
 #include "oslib/osargs.h"
 #include "oslib/osgbpb.h"
-#include "oslib/osfile.h"                                                   
+#include "oslib/osfile.h"
 #include "sq.h"
 #include "FilePlugin.h"
 
@@ -54,12 +71,17 @@
 		int		sessionID;
 		File	*file;
 		int		writable;
-		squeakFileOffsetType		fileSize; 
+		squeakFileOffsetType		fileSize;
 		int		lastOp;  // 0 = uncommitted, 1 = read, 2 = write -
 		(used for RISCOS specific code to hold file postion pointer)
 	} SQFile;
 
-For this perversion of the filesystem we need to do some trickery to attempt to persuade RISC OS to pretend to allow multiple openings of one file. The approach is to open files with SWIs and keep a list of canoncalized filenames. When opening a file we search for a matching filename and if found we use the same fileid number. Since Squeak uses a really annoying position/read/write api (to match posix I guess) we have to cache the position and use it in later read/writes.
+For this perversion of the filesystem we need to do some trickery to attempt to
+persuade RISC OS to pretend to allow multiple openings of one file. The approach
+ is to open files with SWIs and keep a list of canoncalized filenames. When open
+ing a file we search for a matching filename and if found we use the same fileid
+ number. Since Squeak uses a really annoying position/read/write api (to match p
+osix I guess) we have to cache the position and use it in later read/writes.
 
 w/r
 file not open (name not in list)
@@ -73,7 +95,7 @@
 
 w/r
 file open (name in list)
-h = list entry->handle 
+h = list entry->handle
 sqFile->file = h
 sqFile->writable = true
 return
@@ -155,7 +177,8 @@
  * copy the fName into the new entry so the fName string can be freed later
  */
 OpenFileListEntry *entry;
-	entry = (OpenFileListEntry*) calloc(1, sizeof(OpenFileListEntry) + strlen(fName));
+	entry = (OpenFileListEntry*) calloc(1, sizeof(OpenFileListEntry) + strlen(fN
+ame));
 	if ( entry == NULL) {
 		return NULL;
 	}
@@ -210,7 +233,8 @@
 			 */
 			entry->refCt = -1;
 		}
-		PRINTF(("\\t file entry %s (%0x):%d\n",entry->name, entry->handle, entry->refCt));
+		PRINTF(("\\t file entry %s (%0x):%d\n",entry->name, entry->handle, entry
+->refCt));
 		return entry;
 	}
 	/* the file is not open so open it */
@@ -246,7 +270,8 @@
 
 /* primitive support */
 
-sqInt sqFileOpen(SQFile *f, char* sqFileName, sqInt sqFileNameSize, sqInt writeFlag) {
+sqInt sqFileOpen(SQFile *f, char* sqFileName, sqInt sqFileNameSize, sqInt writeF
+lag) {
 /* Opens the given file using the supplied sqFile structure
  * to record its state. Fails with no side effects if f is
  * already open. Files are always opened in binary mode;
@@ -261,7 +286,8 @@
 		FAIL();
 	}
 
-	if (!canonicalizeFilenameToString(sqFileName, sqFileNameSize, cFilename)) FAIL();
+	if (!canonicalizeFilenameToString(sqFileName, sqFileNameSize, cFilename)) FA
+IL();
 
 	PRINTF(("\\t sqFileOpen: canonicalized filename: %s\n", cFilename));
 
@@ -275,7 +301,7 @@
 		f->writable = true;
 		FAIL();
 	}
- 
+
 	if (writeFlag) {
 		f->writable = true;
 	} else {
@@ -306,7 +332,8 @@
 	PRINTF(("\\t sqFileClose: failed\n"));
 		FAIL();
 	}
-	PRINTF(("\\t close file entry %s (%0x):%d\n",entry->name, entry->handle, entry->refCt));
+	PRINTF(("\\t close file entry %s (%0x):%d\n",entry->name, entry->handle, ent
+ry->refCt));
 	entry->refCt -= 2;
 	if (entry->refCt == 0) {
 		/* all uses closed, so close file and remove entry */
@@ -341,7 +368,8 @@
 		PRINTF(("\\t sqFileGetPosition: attempt to query invalid file\n"));
 		FAIL();
 	}
-	PRINTF(("\\t sqFileGetPosition: file %x at %d\n", FILE_HANDLE(f), FILE_POSITION(f)));
+	PRINTF(("\\t sqFileGetPosition: file %x at %d\n", FILE_HANDLE(f), FILE_POSIT
+ION(f)));
 	return FILE_POSITION(f);
 }
 
@@ -351,7 +379,8 @@
 		PRINTF(("\\t sqFileSetPosition: attempt to set invalid file\n"));
 		FAIL();
 	}
-	PRINTF(("\\t sqFileSetPosition: file %x to %d\n", FILE_HANDLE(f), position));
+	PRINTF(("\\t sqFileSetPosition: file %x to %d\n", FILE_HANDLE(f), position))
+;
 	FILE_POSITION(f) = position;
 	return true;
 }
@@ -360,7 +389,7 @@
 /* Return the length of the given file. */
 int extent;
 	if (!sqFileValid(f)) {
-		PRINTF(("\\t sqFileSize: attempt to query invalid file\n")); 
+		PRINTF(("\\t sqFileSize: attempt to query invalid file\n"));
 		FAIL();
 	}
 	return f->fileSize;
@@ -379,13 +408,14 @@
 	if (!sqFileValid(f)) FAIL();
 	if (xosargs_set_extw(FILE_HANDLE(f), offset) != NULL) {
 		FAIL();
-	} 
+	}
 	xosargs_read_extw(FILE_HANDLE(f), &extent);
 	f->fileSize = extent;
 	return true;
 }
 
-size_t sqFileReadIntoAt(SQFile *f, size_t count, char* byteArrayIndex, size_t startIndex) {
+size_t sqFileReadIntoAt(SQFile *f, size_t count, char* byteArrayIndex, size_t st
+artIndex) {
 /* Read count bytes from the given file into byteArray starting at
  * startIndex. byteArray is the address of the first byte of a
  * Squeak bytes object (e.g. String or ByteArray). startIndex
@@ -400,13 +430,16 @@
 	}
 	dst = (byte *) (byteArrayIndex + startIndex);
 
-	xosgbpb_read_atw(FILE_HANDLE(f), dst, count, FILE_POSITION(f), &bytesUnread);
+	xosgbpb_read_atw(FILE_HANDLE(f), dst, count, FILE_POSITION(f), &bytesUnread)
+;
 	FILE_POSITION(f) += (count - bytesUnread);
-	PRINTF(("\\t sqFileReadIntoAt: read %d bytes of %d from file %x to %0x\n",count - bytesUnread, count, (int)FILE_HANDLE(f), (int)dst));
+	PRINTF(("\\t sqFileReadIntoAt: read %d bytes of %d from file %x to %0x\n",co
+unt - bytesUnread, count, (int)FILE_HANDLE(f), (int)dst));
 	return count - bytesUnread;
 }
 
-size_t sqFileWriteFromAt(SQFile *f, size_t count, char* byteArrayIndex, size_t startIndex) {
+size_t sqFileWriteFromAt(SQFile *f, size_t count, char* byteArrayIndex, size_t s
+tartIndex) {
 /* Write count bytes to the given writable file starting at startIndex
  * in the given byteArray. (See comment in sqFileReadIntoAt for interpretation
  * of byteArray and startIndex).
@@ -420,9 +453,11 @@
 		FAIL();
 	}
 	src = (byte *) (byteArrayIndex + startIndex);
-	xosgbpb_write_atw(FILE_HANDLE(f), src, count, FILE_POSITION(f), &bytesUnwritten);
+	xosgbpb_write_atw(FILE_HANDLE(f), src, count, FILE_POSITION(f), &bytesUnwrit
+ten);
 	FILE_POSITION(f) += (count - bytesUnwritten);
-	PRINTF(("\\t sqFileWriteFromAt: wrote %d bytes of %d from %0x to file %x\n",count - bytesUnwritten, count, (int)src, (int)f->file));
+	PRINTF(("\\t sqFileWriteFromAt: wrote %d bytes of %d from %0x to file %x\n",
+count - bytesUnwritten, count, (int)src, (int)f->file));
 
 	xosargs_read_extw(FILE_HANDLE(f), &extent);
 	f->fileSize = extent;
@@ -434,11 +469,14 @@
 	return count;
 }
 
-sqInt sqFileRenameOldSizeNewSize(char* oldNameIndex, sqInt oldNameSize, char* newNameIndex, sqInt newNameSize) {
+sqInt sqFileRenameOldSizeNewSize(char* oldNameIndex, sqInt oldNameSize, char* ne
+wNameIndex, sqInt newNameSize) {
 char cNewName[MAXDIRNAMELENGTH];
 
-	if (!canonicalizeFilenameToString(oldNameIndex, oldNameSize, cFilename)) FAIL();
-	if (!canonicalizeFilenameToString(newNameIndex, newNameSize, cNewName)) FAIL();
+	if (!canonicalizeFilenameToString(oldNameIndex, oldNameSize, cFilename)) FAI
+L();
+	if (!canonicalizeFilenameToString(newNameIndex, newNameSize, cNewName)) FAIL
+();
 
 	if (xosfscontrol_rename(cFilename, cNewName) != NULL) {
 		FAIL();
@@ -453,7 +491,8 @@
 int size;
 fileswitch_attr attr;
 
-	if (!canonicalizeFilenameToString(sqFileName, sqFileNameSize, cFilename)) FAIL();;
+	if (!canonicalizeFilenameToString(sqFileName, sqFileNameSize, cFilename)) FA
+IL();;
 
 	PRINTF(("\\t sqFileDeleteNameSize: canonicalized name %s\n",cFilename));
 

Modified: trunk/platforms/RiscOS/plugins/FilePlugin/sqRPCDirectory.c
===================================================================
--- trunk/platforms/RiscOS/plugins/FilePlugin/sqRPCDirectory.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/FilePlugin/sqRPCDirectory.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,16 +1,32 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                       sqRPCDirectory.c                                 */
-/*  hook up to RiscOS directory listing etc                               */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqRPCFileDirectory.c
+// It provides the Squeak directory related low-level calls
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
 /* debugging stuff; uncommnet for debugging trace */
 //#define DEBUG
 #include "oslib/os.h"
@@ -64,7 +80,7 @@
 
 	/* Remove the centiseconds from the time.
 	 * 0x1000000000 / 100 = 42949672.96 */
-	low = (low / 100) + (high * 42949673U); 
+	low = (low / 100) + (high * 42949673U);
 	low -= (high / 25); /* compensate for that 0.04 error.  */
 
 	return (int)low + (tzoffset/100);
@@ -135,13 +151,13 @@
 		goto decode_disc_id;
 	}
 	run_total += scsifs_flop;
-	    
+
 	if (  context < (run_total + scsifs_hard) ) {
 		// it's a scsifs hard disc
 		sprintf( discid, "SCSI::%d", context - run_total + F2HJump);
 		goto decode_disc_id;
 	}
-	run_total += scsifs_hard;    
+	run_total += scsifs_hard;
 
 	xramfs_drives (&junk, &ramfs_flop,  &ramfs_hard);
 	if (  context < ( run_total + ramfs_flop) ) {
@@ -149,13 +165,13 @@
 		sprintf( discid, "RAM::%d", context - run_total);
 		goto decode_disc_id;
 	}
-	run_total += ramfs_flop;    
+	run_total += ramfs_flop;
 	if (  context < (run_total + ramfs_hard) ) {
 		// it's a ramfs hard disc
 		sprintf( discid, "RAM::%d", context - run_total + F2HJump);
 		goto decode_disc_id;
 	}
-	run_total += ramfs_hard;    
+	run_total += ramfs_hard;
 
 	xcdfs_get_number_of_drives( &cdfs_hard);
 	if (  context < (run_total + cdfs_hard) ) {
@@ -263,7 +279,7 @@
 		 */
 		strncpy(name, filename, filenamesize);
 		name[filenamesize] = null;
-		PRINTF(("\\tsettype of %s \n", name)); 
+		PRINTF(("\\tsettype of %s \n", name));
 		if (strstr(name, ".$.") ) {
 			/* .$. is a strong hint that the name is already in RISC OS form */
 			xosfile_set_type(name, (bits)0xFAA);

Modified: trunk/platforms/RiscOS/plugins/LocalePlugin/sqRPCLocale.c
===================================================================
--- trunk/platforms/RiscOS/plugins/LocalePlugin/sqRPCLocale.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/LocalePlugin/sqRPCLocale.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,16 +1,32 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*           sqRPCLocale.c                                                */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqRPCLocale.c
+// It provides locale/territory calls for Squeak
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
-
 /* define this to get lots of debug reports  */
 //#define DEBUG
 

Modified: trunk/platforms/RiscOS/plugins/SecurityPlugin/sqRPCSecurity.c
===================================================================
--- trunk/platforms/RiscOS/plugins/SecurityPlugin/sqRPCSecurity.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/SecurityPlugin/sqRPCSecurity.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,16 +1,33 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                       sqRPCSecurity.c                                  */
-/*  Connect to Squeak's security stuff                                    */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqRPCSecurity.c
+// It provides some filesysem security apis - you can set up a directory as
+// a 'trusted' place for users data, or restrict saving of the image file etc
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
 /* debugging stuff; uncomment for debugging trace */
 //#define DEBUG
 

Modified: trunk/platforms/RiscOS/plugins/SocketPlugin/sqRPCNetPlugin.c
===================================================================
--- trunk/platforms/RiscOS/plugins/SocketPlugin/sqRPCNetPlugin.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/SocketPlugin/sqRPCNetPlugin.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,16 +1,33 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                       sqRPCNetPlugin.c                                 */
-/*  hook up to RiscOS socket stuff                                        */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
 
-/* To recompile this reliably you will need    */           
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
+// This is sqRPCNetPlugin.c
+// It provides unix like sockets for Squeak.
+// If you understand sockets and RISC OS, feel free to offer to improve it.
 
 /* Shamelessly copied from Unix socket support.
  *
@@ -19,52 +36,52 @@
  */
 
 /* sqUnixSocket.c -- Unix socket support
- * 
+ *
  *   Copyright (C) 1996-2003 Ian Piumarta and other authors/contributors
  *     as listed elsewhere in this file.
  *   All rights reserved.
- *   
+ *
  *     You are NOT ALLOWED to distribute modified versions of this file
  *     under its original name.  If you want to modify it and then make
  *     your modifications available publicly, rename the file first.
- * 
+ *
  *   This file is part of Unix Squeak.
- * 
+ *
  *   This file is distributed in the hope that it will be useful, but WITHOUT
  *   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  *   FITNESS FOR A PARTICULAR PURPOSE.
- *   
+ *
  *   You may use and/or distribute this file ONLY as part of Squeak, under
  *   the terms of the Squeak License as described in `LICENSE' in the base of
  *   this distribution, subject to the following additional restrictions:
- * 
+ *
  *   1. The origin of this software must not be misrepresented; you must not
  *      claim that you wrote the original software.  If you use this software
  *      in a product, an acknowledgment to the original author(s) (and any
  *      other contributors mentioned herein) in the product documentation
  *      would be appreciated but is not required.
- * 
+ *
  *   2. You must not distribute (or make publicly available by any
  *      means) a modified copy of this file unless you first rename it.
- * 
+ *
  *   3. This notice must not be removed or altered in any source distribution.
- * 
+ *
  *   Using (or modifying this file for use) in any context other than Squeak
  *   changes these copyright conditions.  Read the file `COPYING' in the
  *   directory `platforms/unix/doc' before proceeding with any such use.
  */
 
 /* Author: Ian.Piumarta at inria.fr
- * 
+ *
  * Last edited: 2004-04-02 14:21:17 by piumarta on emilia.local
- * 
+ *
  * Support for BSD-style "accept" primitives contributed by:
  *	Lex Spoon <lex at cc.gatech.edu>
- * 
+ *
  * Notes:
  * 	Sockets are completely asynchronous, but the resolver is still
  *	synchronous.
- * 
+ *
  * BUGS:
  *	Now that the image has real UDP primitives, the TCP/UDP duality in
  *	many of the connection-oriented functions should be removed and
@@ -113,7 +130,7 @@
 # include <netdb.h>
 # include <errno.h>
 # include <unistd.h>
-  
+
 #endif /* !ACORN */
 
 /* Solaris sometimes fails to define this in netdb.h */
@@ -286,7 +303,7 @@
   FD_ZERO(&exMask);
   FD_ZERO(&xdMask);
   maxFd= 0;
-#ifndef ACORN  
+#ifndef ACORN
   signal(SIGPIPE, SIG_IGN);
 #endif
 }
@@ -309,7 +326,7 @@
       }
   while (maxFd && !FD_ISSET(maxFd - 1, &fdMask))
     --maxFd;
-#ifndef ACORN    
+#ifndef ACORN
   signal(SIGPIPE, SIG_DFL);
 #endif
 }
@@ -568,7 +585,7 @@
 {
   struct timeval tv= { 0, 0 };
   fd_set fds;
-  
+
   FD_ZERO(&fds);
   FD_SET(s, &fds);
   return select(s+1, 0, &fds, 0, &tv) > 0;
@@ -987,7 +1004,7 @@
 
 void sqSocketAcceptFromRecvBytesSendBytesSemaID(SocketPtr s, SocketPtr serverSocket, sqInt recvBufSize, sqInt sendBufSize, sqInt semaIndex){
   sqSocketAcceptFromRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID
-    (s, serverSocket, recvBufSize, sendBufSize, 
+    (s, serverSocket, recvBufSize, sendBufSize,
      semaIndex, semaIndex, semaIndex);
 }
 
@@ -1098,7 +1115,7 @@
 }
 
 
-/* Release the resources associated with this socket. 
+/* Release the resources associated with this socket.
    If a connection is open, abort it. */
 
 void sqSocketDestroy(SocketPtr s)
@@ -1308,7 +1325,7 @@
 
 /* write data to the socket s from buf for at most bufSize bytes.
    answer the number of bytes actually written.
-*/ 
+*/
 sqInt sqSocketSendDataBufCount(SocketPtr s, char * buf, sqInt bufSize)
 {
   int nsent= 0;
@@ -1361,7 +1378,7 @@
 
 /* read data from the UDP socket s into buf for at most bufSize bytes.
    answer the number of bytes actually read.
-*/ 
+*/
 sqInt sqSocketReceiveUDPDataBufCountaddressportmoreFlag
     (SocketPtr s, char * buf, sqInt bufSize,  sqInt *address,  sqInt *port, sqInt *moreFlag)
 {
@@ -1372,7 +1389,7 @@
 
       FPRINTF((stderr, "recvFrom(%d)\n", SOCKET(s)));
       memset(&saddr, 0, sizeof(saddr));
-      { 
+      {
 	int nread= recvfrom(SOCKET(s), (void *)buf, bufSize, 0,
 			    (struct sockaddr *)&saddr,
 			    &addrSize);
@@ -1395,7 +1412,7 @@
 
 /* write data to the UDP socket s from buf for at most bufSize bytes.
  * answer the number of bytes actually written.
- */ 
+ */
 sqInt sqSockettoHostportSendDataBufCount(SocketPtr s, sqInt address, sqInt port,
 				       char * buf, sqInt bufSize)
 {
@@ -1414,7 +1431,7 @@
 			  sizeof(saddr));
 	if (nsent >= 0)
 	  return nsent;
-	
+
 	if (errno == EWOULDBLOCK)	/* asynchronous write in progress */
 	  return 0;
 	FPRINTF((stderr, "UDP send failed\n"));
@@ -1605,7 +1622,7 @@
   interpreterProxy->success(false);
   return errno;
 }
-   
+
 void sqSocketBindToPort(SocketPtr s, int addr, int port)
 {
   int result;

Modified: trunk/platforms/RiscOS/plugins/SoundPlugin/sqRPCSound.c
===================================================================
--- trunk/platforms/RiscOS/plugins/SoundPlugin/sqRPCSound.c	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/plugins/SoundPlugin/sqRPCSound.c	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,31 +1,234 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                       sqRPCSound.c                                     */
-/*  hook up to RiscOS sound stuff - eventually                            */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+// This is sqRPCSound.c
+// It provides Squeak with access to the RISC OS sound system as
+// implemented by John Duffell's very neat SharedSoundBuffer/StreamManager
+// modules. Furthermore, my understanding of how to make use of John's modules
+// relied on reading Andrew Sellors excellent code for !RDPClient.
+// Thank you both.
 
-/* To recompile this reliably you will need    */
-/* OSLib -  http://ro-oslib.sourceforge.net/   */
-/* Castle/AcornC/C++, the Acorn TCPIPLib       */
-/* and a little luck                           */
+#define DEBUG
 
 #include "sq.h"
 #include "SoundPlugin.h"
+#include "kernel.h"
+#include "sqRPCSound.h"
 
 
+
 extern struct VirtualMachine * interpreterProxy;
+static unsigned sound_initialised = false;
+static int sound_handle = 0;
+static int sound_stream = 0;
+static unsigned sound_volume = 0; // this ought to be queriable from system
+static unsigned char *sound_global_buffer_data = NULL;
+static int sound_global_buffer_length = 0;
+static int sound_buffersize = 0;
+static unsigned sound_delayed_start = false;
+static unsigned int sound_delayed_start_time = 0;
 
+
+/*********************/
+/* internal routines */
+/*********************/
+
+
+static void ssb_closestream(int handle) {
+	_kernel_swi_regs r;
+	PRINTF(("ssb close %d\n", handle));
+
+	r.r[0] = (int)handle;
+
+	_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_CloseStream, &r, &r);
+}
+
+static unsigned ssb_openstream(char *name, unsigned set_expected_size, int expected_size, int *handle) {
+	_kernel_swi_regs r;
+	unsigned success = false;
+	int flags = 0;
+
+	PRINTF(("ssb open %s expected size: %d", name, expected_size));
+
+	if(set_expected_size)
+		flags = flags | 0x2;
+
+	r.r[0] = (int)flags;
+	r.r[1] = (int)name;
+	r.r[2] = expected_size; // might be 0, see flag setting above
+
+	if(_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_OpenStream, &r, &r) == NULL)
+		success = true;
+
+	*handle = (unsigned int)r.r[0];
+
+	if (success) {
+		PRINTF((" - suceeded with handle: %d\n", handle));
+	} else {
+		PRINTF((" failed\n"));
+	};
+	return(success);
+}
+
+static void ssb_pause(int handle, unsigned pause) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)handle;
+	r.r[1] = (int)(pause ? 0 : 1);
+
+	if (pause) {PRINTF(("ssb pause\n"));} else {PRINTF(("ssb un-pause\n"));}
+
+	_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_Pause, &r, &r);
+}
+
+static unsigned ssb_returnstreamhandle(int handle, int *stream) {
+	_kernel_swi_regs r;
+
+	*stream = 0;
+	r.r[0] = (int)handle;
+	if(_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_ReturnStreamHandle, &r, &r) == 0) {
+		*stream = r.r[0];
+		PRINTF(("ssb returnstreamhandle: %d\n", *stream));
+		return true;
+	}
+	PRINTF(("ssb returnstreamhandle: failed\n"));
+
+	return false;
+}
+
+static void ssb_samplerate(int handle, int samplerate) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)handle;
+	r.r[1] = (int)samplerate;
+
+	PRINTF(("ssb setsamplerate: %d\n", samplerate>>10));
+	_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_SampleRate, &r, &r);
+}
+
+static void ssb_volume(int handle, unsigned int volume) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)handle;
+	r.r[1] = (int)volume;
+	sound_volume = volume;
+
+	PRINTF(("ssb setsvolume\n"));
+	_kernel_swi(SWI_XOS_Bit | SWI_SharedSoundBuffer_Volume, &r, &r);
+}
+
+static unsigned ssb_getvolume(int handle) {
+// this really needs to be done with a query SWI
+	PRINTF(("ssb getvolume\n"));
+	return sound_volume;
+}
+
+static unsigned sm_addblock(int stream, unsigned char *block, int length) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)stream;
+	r.r[1] = (int)block;
+	r.r[2] = (int)length;
+
+	if(_kernel_swi(SWI_XOS_Bit | SWI_StreamManager_AddBlock, &r, &r) == NULL) {
+		PRINTF(("sm addblock on stream: %d length: %d\n", stream, length));
+		return true;
+	}
+	PRINTF(("sm addblock: failed\n"));
+
+	return false;
+}
+
+static int sm_bufferstats(int stream) {
+	_kernel_swi_regs r;
+	int bytes_left = 0;
+
+	r.r[0] = (int)stream;
+
+	if(_kernel_swi(SWI_XOS_Bit | SWI_StreamManager_BufferStats, &r, &r) == 0)
+		bytes_left = r.r[0] - r.r[1];
+	PRINTF(("sm bufferstats: %d\n", bytes_left));
+
+	/* This doesn't match the supposed doc
+	* r0 = added
+	* r1 = played
+	* r2 = freed
+	*/
+
+	return(bytes_left);
+}
+
+static void sm_setbuffer(int stream, int max_bytes) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)stream;
+	r.r[1] = (int)max_bytes;
+	PRINTF(("sm setbuffer\n"));
+
+	_kernel_swi(SWI_XOS_Bit | SWI_StreamManager_SetBuffer, &r, &r);
+}
+
+static void sm_setdalimits(int da_max_bytes, int heap_max_bytes) {
+	_kernel_swi_regs r;
+
+	r.r[0] = (int)da_max_bytes;
+	r.r[1] = (int)heap_max_bytes;
+	PRINTF(("sm setdalimits da: %d heap: %d\n", da_max_bytes, heap_max_bytes));
+
+	_kernel_swi(SWI_XOS_Bit | SWI_StreamManager_SetDALimits, &r, &r);
+}
+
+/**********************************/
 /* module initialization/shutdown */
+/**********************************/
+
 int soundInit(void) {
-// anything to do ?
+// make sure all state variables are setup ok
+	sound_initialised = false;
+	sound_handle = 0;
+	sound_stream = 0;
+	sound_global_buffer_data = NULL;
+	sound_global_buffer_length = 0;
+	sound_buffersize = 0;
+
+	sound_delayed_start = false;
+	sound_delayed_start_time = 0;
+	PRINTF(("soundInit\n"));
+	return true;
 }
 
 int soundShutdown(void) {
-// anything to do?
-	return 0;
+// close down the streams etc
+	PRINTF(("soundShutdown\n"));
+
+	if(sound_initialised){
+		ssb_closestream(sound_handle);
+		sound_initialised = false;
+	}
+	return true;
 }
 
 /****************/
@@ -34,8 +237,16 @@
 
 int snd_AvailableSpace(void) {
 
-/*	Returns the number of bytes of available sound output buffer space.  This should be (frames*4) if the device is in stereo mode, or (frames*2) otherwise */
-	return 0;
+// Returns the number of bytes of available sound output buffer space.
+// This should be (frames*4) if the device is in stereo mode,
+// or (frames*2) otherwise
+// Note that we are not supporting non-stereo anyway
+	if (!sound_initialised) {
+		PRINTF(("snd_availableSpace failed - sound not initialised\n"));
+		return -1;
+	}
+	PRINTF(("snd_availableSpace: \n")); // sm_bufferstats prints the number
+	return (sound_buffersize - sm_bufferstats(sound_stream));
 }
 
 int snd_InsertSamplesFromLeadTime(int frameCount, int srcBufPtr, int samplesOfLeadTime) {
@@ -48,39 +259,115 @@
 	specifies the number of samples past the estimated sound output buffer
 	position the inserted sound should start. If successful, it returns the
 	number of samples inserted. */
+	PRINTF(("snd_InsertSamplesFromLeadTime - not supported\n"));
 	return 0;
 }
 
 int snd_PlaySamplesFromAtLength(int frameCount, int arrayIndex, int startIndex) {
-/*	Output a buffer's worth of sound samples. */
-	return 0;
+// Output a frameCount sound samplesfrom the passed in array, starting from startIndex.
+// return the number actually 'played'; though no one uses it
+	if (!sound_initialised) {
+		interpreterProxy->success(false);
+		PRINTF(("snd_PlatSamplesFrom failed - sound not initialised\n"));
+		return false;
+	}
+	PRINTF(("snd_PlaySamplesFrom: %d At: %d Length: %d", arrayIndex, startIndex, frameCount));
+	sm_addblock(sound_stream, (unsigned char *)(arrayIndex + startIndex), BYTESFROMSAMPLES(frameCount));
+	ssb_pause(sound_handle, false);
+	return frameCount;
 }
 
 int snd_PlaySilence(void) {
-
-
 /*	Output a buffer's worth of silence. Returns the number of sample frames played. */
-	return 0;
+// What? Doesn't appear to be used, has no readily apparent purpose
+	PRINTF(("snd_PlaySilence\n"));
+	interpreterProxy->success(false);
+	return 42;
 }
 
 int snd_Start(int frameCount, int samplesPerSec, int stereo, int semaIndex) {
+// Start the buffered sound output with the given buffer size, sample rate, stereo flag and semaphore index.
+	extern char sqTaskName[];
+	PRINTF(("snd_Start"));
 
-/*	Start the double-buffered sound output with the given buffer size, sample rate, stereo flag and semaphore index. */
-	interpreterProxy->primitiveFail();
-	return null;
+// just for now we won't mess with semaphores
+	if ( semaIndex ) {
+		PRINTF((" fails due to semaphore use\n"));
+		 return false;
+	}
+	if(!sound_initialised) {
+		PRINTF((" initialising sound setup\n"));
+		sm_setdalimits(SOUND_DA_MAX_SIZE, SOUND_HEAP_MAX_SIZE);
+		if(ssb_openstream(sqTaskName, true,BYTESFROMSAMPLES(frameCount), &sound_handle)) {
+			if(ssb_returnstreamhandle(sound_handle, &sound_stream)) {
+				sound_buffersize =  SOUND_BUFFER_SIZE(frameCount);
+				sm_setbuffer(sound_stream, sound_buffersize);
+				ssb_volume(sound_handle, 0xFFFFFFFF);
+				ssb_samplerate(sound_handle, samplesPerSec << 10);
+					// uses 1/1024Hz, so multiply given rate by 1024
+				ssb_pause(sound_handle, true);
+				sound_initialised = true;
+			}
+			else {
+				ssb_closestream(sound_handle);
+			}
+		}
+		if(!sound_initialised){
+			sound_handle = 0;
+			sound_stream = 0;
+			PRINTF(("snd_Start failed to init\n"));
+			return false;
+		}
+	}
+	PRINTF(("snd_Start initialised OK\n"));
+	return true;
 }
 
 int snd_Stop(void) {
+	PRINTF(("snd_Stop\n"));
+	// soundShutdown();
+	ssb_pause(sound_handle, true);
+	return null;
+}
 
-/*	Stop double-buffered sound output. */
+
+void snd_Volume(double *left, double *right) {
+// used to GET the volume settings
+unsigned int leftVol, rightVol;
+	if (!sound_initialised) {
+		interpreterProxy->success(false);
+		PRINTF(("snd_Volume failed - sound not initialised\n"));
+		return;
+	}
+// get the volume and make doubles out if it
+	leftVol = sound_volume >> 16;
+	rightVol = sound_volume & 0xFFFF;
+	*left = leftVol  / 65535.0;
+	*right = rightVol / 65535.0;
+	PRINTF(("snd_Volume %f:%f\n", *left, *right));
 }
 
+void snd_SetVolume(double left, double right) {
+// used to SET the volume settings
+unsigned int leftVol, rightVol;
+	if (!sound_initialised) {
+		interpreterProxy->success(false);
+		PRINTF(("snd_SetVolume failed - sound not initialised\n"));
+		return;
+	}
+
+	leftVol = (unsigned int)((left > 1.0 ? 1.0 : left) * 0xFFFF) & 0xFFFF;
+	rightVol = (unsigned int)((right > 1.0 ? 1.0 : right) * 0xFFFF) & 0xFFFF;
+	PRINTF(("snd_SetVolume %f:%f\n", left, right));
+	ssb_volume(sound_handle, (leftVol << 16) | rightVol);
+}
+
 /***************/
 /* sound input */
 /***************/
 
 
-int snd_SetRecordLevel(int level) {;
+int snd_SetRecordLevel(int level) {
 	return null;
 }
 
@@ -99,12 +386,3 @@
 int snd_RecordSamplesIntoAtLength(int buf, int startSliceIndex, int bufferSizeInBytes) {
 	return null;
 }
-
-void snd_Volume(double *left, double *right) {
-// used to GET the volume settings
-}
-
-void snd_SetVolume(double left, double right) {
-// used to SET the volume settings
-	interpreterProxy->primitiveFail();
-}

Modified: trunk/platforms/RiscOS/vm/config.h
===================================================================
--- trunk/platforms/RiscOS/vm/config.h	2013-01-18 19:25:43 UTC (rev 2673)
+++ trunk/platforms/RiscOS/vm/config.h	2013-01-24 20:08:41 UTC (rev 2674)
@@ -1,13 +1,31 @@
-/**************************************************************************/
-/*  A Squeak VM for Acorn RiscOS machines by Tim Rowledge                 */
-/*  tim at rowledge.org & http://www.rowledge.org/tim                        */
-/*  Known to work on RiscOS >3.7 for StrongARM RPCs and Iyonix,           */
-/*  other machines not yet tested.                                        */
-/*                  config.h --                                           */
-/*  configuration stuff analogous to that produced on *nix machines when  */
-/*  you run the spawn-of-satan-autoconf stuff.                            */
-/**************************************************************************/
+//  A Squeak VM for RiscOS machines
+//  Suited to RISC OS > 4, preferably > 5
+// See www.squeak.org for much more information
+//
+// tim Rowledge tim at rowledge.org
+//
+// License: MIT License -
+// Copyright (C) <2013> <tim rowledge>
+//

@@ Diff output truncated at 50000 characters. @@


More information about the Vm-dev mailing list