Function Names correspond to those used in docs/SystemCalls.txt

Colours
~~~~~~~

	#include <menuet/msys.h>

	/* Form colour with components r, g and b (0 - 255). */
	int _msys_RGB(int r, int g, int b);

	#include <menuet/colour.h>

	/* Pre-defined colours. */
	C_WHITE, C_RED, C_GREEN, C_BLUE, C_BLACK, C_ORANGE, C_YELLOW,
	C_MAGENTA, C_CYAN, C_GREY


Drawing
~~~~~~~

	#include <menuet/msys.h>
	#include <menuet/colour.h>

	/* Define a window, standard and new styles (currently equivalent).
	   The gbarcolour can be OR'ed with GLIDE??. */
	void _msys_DefineWindow(int x, int y, int width, int height,
	   int bodycolour, int gbarcolour, int framecolour);
	void _msys_DefineNewWindow(int x, int y, int width, int height,
	   int bodycolour, int gbarcolour, int framecolour);

	/* Define a button. */
	void _msys_DefineButton(int x, int y, int width, int height,
	   int colour, int id);

	/* Attempt to read a string off the screen. */
	int _msys_ReadString(int x, int y, void *buffer,
	   int textcolour, int bgcolour, int n);

	/* Write a message to the screen. */
	void _msys_WriteText(int x, int y, int colour, const char *msg,
	   int len);

	/* Place an image on the screen. */
	int _msys_PutImage(int x, int y, int width, int height, void *img);

	/* Change the shape of a window. */
	void _msys_SetRandomShapedWindow(void *data);

	/* Change the scale of a randomly-shaped window (default 1). */
	void _msys_SetRandomShapedWindowScale(int scale);

	/* Obtain the extent of the screen. */
	void _msys_GetScreenSize(int *width, int *height);

	/* Returns colour of a particular pixel. */
	int _msys_GetPixel(int x, int y);

	/* Call prior to redrawing. */
	void _msys_BeginDraw(void);

	/* Call at end of redraw. */
	void _msys_EndDraw(void);

	/* Draw a line from (x1, y1) to (x2, y2) in ?? colour. */
	void _msys_DrawLine(int x1, int y1, int x2, int y2);

	/* Draw a rectangle. */
	void _msys_DrawRect(int x, int y, int width, int height, int colour);

	#include <menuet/button.h>

	/* Change buttons to given type BUTTON_3D or BUTTON_FLAT. */
	void _msys_SetButtonType(int type);

	#include <menuet/wnum.h>

	/* Write a number to the screen. Base can be BASE_HEX, BASE_BIN
	   or BASE_DEC. Type can be VAL_NUM or VAL_PTR. */
	void _msys_WriteNum(int x, int y, int colour, int val, int base,
	   int type, int ndigits);

	#include <menuet/pxset.h>

	/* Changes colour of a particular pixel. Colour should be OR'ed 
	   with PX_NEG to invert. */
	void _msys_SetPixel(int x, int y, int colour);

	#include <menuet/redraw.h>

	/* Choose redraw type??. */
	void _msys_SetRedrawType(int type);

Background
~~~~~~~~~~

	#include <menuet/msys.h>

	/* Redraw the desktop background. */
	void _msys_DrawBackground(void);

	/* Read data from the desktop background image. */
	int _msys_ReadBackgroundData(int pos);

	/* Change data in the background image. */
	void _msys_WriteBackgroundData (int pos, int colour);

	/* Obtain the size of the background image. */
	void _msys_GetBackgroundSize(int *width, int *height);

	/* Set the size of the background image. */
	void _msys_SetBackgroundSize(int width, int height);

	/* Unknown Background function. */
	void _msys_UnknownBackgroundFunction(void);

	#include <menuet/bkground.h>

	/* Choose the method by which the background image is drawn. Method can
	   be BACKGROUND_TILE or BACKGROUND_STRETCH. */
	int _msys_GetBackgroundType(void);

	/* Choose the method by which the background image is drawn. */
	void _msys_SetBackgroundType(int type);



Process Management
~~~~~~~~~~~~~~~~~~

	#include <menuet/msys.h>

	/* Start application from ramdisk image. */
	int _msys_StartApp(const char *name, const char *params);

	/* Start application from hard-disk. */
	void _msys_StartHdApp(void *file, int filelen, void *workarea);

	/* Returns the CPU Idle time. */
	int _msys_GetIdle(void);

	/* Kill a specified process. */
	void _msys_KillApp(int pid);

	/* Initiate system shutdown. */
	void _msys_Shutdown(void);

	/* Suspend current process for a given delay in hundredths of
	   a second. */
	void _msys_DelayHs(int hs);

	/* Close current process. */
	void _msys_EndApp(void);

	/* ??? */
	void _msys_AppInts(void);

	/* Return the CPU task-switch count??. */
	int _msys_GetTsc(void);

	/* ?. */
	int _msys_WindowActivate(void);

	#include <menuet/apphdr.h>

	/* Access the header of the application. */
	struct menuet_apphdr * _msys_GetAppHeader(void);

	#include <menuet/process.h>

	/* Obtain information about a specified process. Returns number of
	   processes in system. */
	int _msys_GetProcessInfo(struct menuet_process_info *buf, int pid);


Event Management
~~~~~~~~~~~~~~~~

	#include <menuet/msys.h>

	/* Returns the value?? of a pressed key. Use when a EV_KEY event
	   arrives. */
	int _msys_GetKey(int *k);

	/* Returns the id of a pressed button. Use when a EV_BUTTON event
	   arrives. */
	int _msys_GetButton(void);

	#include <menuet/events.h>

	/* Suspend process until an event arrives. Returns type of event
	   (not EV_NULL). */
	int _msys_WaitForEvent(void);

	/* Suspend process until an event arrives or a given delay
	   (in hundredths of a success) expires. Returns type of event
	   (EV_NULL for timeout). */
	int _msys_TimeoutWaitForEvent(int hs);

	/* See if any events are pending. Returns event type
	   (EV_NULL if none). */
	int _msys_CheckForEvent(void);

	#include <menuet/wevents.h>

	/* Specify mask of event types the process wishes to be alerted
	   about. Possible values to be bitwise OR'ed are:

		WEV_REDRAW_REQ		request for window to be redrawn
		WEV_KEY			key pressed
		WEV_BUTTON		button pressed
		WEV_END_REQUEST		??
		WEV_BACKGROUND_DRAW	background redrawn
		WEV_MOUSE_CHANGE	mouse status changed
		WEV_IRQ0 ... WEV_IRQ15	irq status changed

	   Default mask is (WEV_REDRAW_REQ | WEV_KEY | WEV_BUTTON). */
	void _msys_WantEvents(int evmask);


Time
~~~~

	#include <menuet/msys.h>
	#include <menuet/time.h>

	/* Read system clock. */
	void _msys_GetClock(struct menuet_clock *c);

	/* Obtain the current date. */
	void _msys_GetDate(struct menuet_date *d);


File I/O
~~~~~~~~

	#include <menuet/msys.h>

	/* Write a file to the Fat32 partition. */
	void _msys_WriteFat32File(void);

	/* Read a file to the Fat32 partition. */
	void _msys_ReadFat32File(void);

	/* Remove a file from the ramdisk image. */
	void _msys_DelRamdiskFile(const char *name);

	/* Flush the floppy cache??. */
	void _msys_FlushFloppyCache(void);

	/* Read a file from the hard-drive. Blocks are 512 bytes. */
	void _msys_ReadHd(void *file, int filelen, int startblock,
	   int nblocks, void *workarea);

	/* Set the Fat32 data. */
	void _msys_SetFat32Data(void);

	/* Read the floppy drive. */
	int _msys_ReadFloppyDrive(void *file, int filelen, int startblock,
	   int nblocks, void *workarea);

	#include <menuet/fmode.h>

	/* Save a file to the ramdisk image. Blocks are 512 bytes.
	   Mode should be MODE_CREATE or MODE_APPEND. */
	void _msys_WriteRamdiskFile(const char *name, void *buf,
	   int nblocks, int mode);


Drives
~~~~~~

	#include <menuet/msys.h>

	/* Returns the number of the Fat32 partition on the hard-drive. */
	int _msys_GetFat32Partition(void);

	/* Set the number of the Fat32 partition on the hard-drive. */
	void _msys_SetFat32Partition(int p);

	#include <menuet/ide.h>

	/* Returns the drive number of the CD drive. Possible values are
	   PRI_MASTER, PRI_SLAVE, SEC_MASTER and SEC_SLAVE. */
	int _msys_GetCdBase(void);

	/* Set the drive number of the CD drive. */
	void _msys_SetCdBase(int dev);

	/* Returns the drive number of the hard-drive. */
	int _msys_GetHdBase(void);

	/* Set the drive number of the hard-drive. */
	void _msys_SetHdBase(int dev);



Language
~~~~~~~~

	#include <menuet/msys.h>
	#include <menuet/language.h>

	/* Obtain the current system language.
	   Possible values are LANG_ENGLISH, LANG_FINNISH, LANG_GERMAN and
	   LANG_RUSSIAN. */
	int _msys_GetSysLanguage(void);

	/* Change the current system language. Default LANG_ENGLISH. */
	void _msys_SetSysLanguage(int lang);


Mouse
~~~~~

	#include <menuet/msys.h>
	#include <menuet/mouse.h>

	/* Get mouse pointer position relative to the screen. */
	void _msys_GetMousePosition_ScreenRelative(int *x, int *y);

	/* Get mouse pointer position relative to the window. */
	void _msys_GetMousePosition_WinRelative(int *x, int *y);

	/* Obtain the current status (buttons pressed) of the mouse.
	  Returns bitwise OR of some of these values ?? */
	int _msys_GetMouseStatus(void);


Sound
~~~~~

	#include <menuet/msys.h>

	/* Get the I/O address of the Roland MPU-401 midi chip. */
	int _msys_GetMidiBase(void);

	/* Set the I/O address of the Roland MPU-401 midi chip. */
	void _msys_SetMidiBase(int iobase);

	/* Reset the Roland MPU-401 midi chip. */
	void _msys_ResetMidi(void);

	/* Output data to the Roland MPU-401 midi chip. */
	void _msys_OutputMidi(int data);

	/* Get the I/O address of the SoundBlaster-16 chip. */
	int _msys_GetSb16Base(void);

	/* Set the I/O address of the SoundBlaster-16 chip. */
	void _msys_SetSb16Base(int iobase);

	/* Get the I/O address of the Windows Sound System chip. */
	int _msys_GetWssBase(void);

	/* Set the I/O address of the Windows Sound System chip. */
	void _msys_SetWssBase(int iobase);

	/* Set the main volume for the SoundBlaster-16 Mixer I. */
	void _msys_SetSb16MixerIMainVol(int left, int right);

	/* Set the CD volume for the SoundBlaster-16 Mixer I. */
	void _msys_SetSb16MixerICdVol(int left, int right);

	/* Set the main volume for the SoundBlaster-16 Mixer II. */
	void _msys_SetSb16MixerIIMainVol(int vol);

	/* Set the CD volume for the SoundBlaster-16 Mixer II. */
	void _msys_SetSb16MixerIICdVol(int vol);

	/* Set the main volume for the Windows Sound System chip. */
	void _msys_SetWssMainVol(int vol);

	/* Set the CD volume for the Windows Sound System chip. */
	void _msys_SetWssCdVol(int vol);

	/* Load music for the SoundBlaster-16 from a 64k buffer. */
	void _msys_LoadSb16Music(void *data);

	/* Play music previously loaded into the SoundBlaster-16. */
	void _msys_PlaySb16Music(void);



CD
~~

	#include <menuet/msys.h>

	/* Obtain list of songs on a CD???. */
	int _msys_GetCdPlaylist(int size, void *buf);

	/* Stop CD playing. */
	int _msys_StopCd(void);

	/* Play CD track from given start time. */
	int _msys_PlayCdTrack(int track, int minute, int sec);


Keyboard Setup
~~~~~~~~~~~~~~

	#include <menuet/msys.h>

	/* Returns a pointer to the current base keymap. */
	void * _msys_GetKeymap(void);

	/* Change the base keymap. */
	void _msys_SetKeymap(void *map);

	/* Returns a pointer to the shifted keymap. */
	void * _msys_GetShiftKeymap(void);

	/* Change the shifted keymap. */
	void _msys_SetShiftKeymap(void *map);

	#include <menuet/klayout.h>

	/* Obtain the current keyboard layout setting.
	   Possible values are KLAYOUT_ENGLISH, KLAYOUT_FINNISH,
	   KLAYOUT_GERMAN and KLAYOUT_RUSSIAN. */
	int _msys_GetKeyLayout(void);

	/* Change the current keyboard layout setting. */
	void _msys_SetKeyLayout(int country);



IRQs and Devices
~~~~~~~~~~~~~~~~

	#include <menuet/msys.h>


	/* Reserve a port area. */
	int _msys_ReservePortArea(int first, int last);

	/* Free a reserved port area. */
	int _msys_FreePortArea(int first, int last);

	/* Reserve an IRQ. */
	int _msys_ReserveIrq(void);

	/* Free a reserved IRQ. */
	int _msys_FreeIrq(int irq);

	/* Read data from a given IRQ. */
	void _msys_ReadIrqData(int irq);

	/* Query owner of an IRQ. */
	void _msys_GetIrqOwner(void);

	/* Program IRQs. */
	void _msys_ProgramIrqs(int irq, void *table);

	/* Write to a device. */
	int _msys_SendDeviceData(int port, int data);

