Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ROlib.h

Go to the documentation of this file.
00001 /*
00002  * ROlib.h
00003  *
00004  * Defines Classes, variables and OS interface calls for Acorn RISC OS computers.
00005  * (C) 1997 Andreas Dehmel
00006  *
00007  */
00008 
00009 
00010 
00011 #ifndef RO_CUSTOM_LIB
00012 #define RO_CUSTOM_LIB
00013 
00014 #include <kernel.h>
00015 
00016 
00017 #define TASKNAME   "Frodo"
00018 #define TASK_WORD  0x4b534154
00019 
00020 /* Scrap-file for 1541fs directory function */
00021 #define RO_TEMPFILE     "<Wimp$ScrapDir>.FrodoDIR"
00022 
00023 
00024 
00025 /* Icon Flags */
00026 #define IFlg_Text       1
00027 #define IFlg_Sprite     2
00028 #define IFlg_Border     4
00029 #define IFlg_HCenter    8
00030 #define IFlg_VCenter    16
00031 #define IFlg_Filled     32
00032 #define IFlg_AntiA      64
00033 #define IFlg_AutoRdrw   128
00034 #define IFlg_Indir      256
00035 #define IFlg_RAdjust    512
00036 #define IFlg_Slct       (1<<21)
00037 #define IFlg_Grey       (1<<22)
00038 
00039 /* Menu Flags */
00040 #define MFlg_Tick       1
00041 #define MFlg_Dotted     2
00042 #define MFlg_Writable   4
00043 #define MFlg_Warning    8
00044 #define MFlg_LastItem   128
00045 
00046 /* Joystick stuff */
00047 #define JoyDir_Thresh   32
00048 #define JoyButton1      (1<<16)
00049 #define JoyButton2      (1<<17)
00050 
00051 
00052 
00053 /* Size of WIMP data types */
00054 #define RO_WINDOW_WORDS 23
00055 #define RO_WINDOW_BYTES 92
00056 #define RO_ICON_WORDS   8
00057 #define RO_ICON_BYTES   32
00058 #define RO_MHEAD_WORDS  7
00059 #define RO_MHEAD_BYTES  28
00060 #define RO_MITEM_WORDS  6
00061 #define RO_MITEM_BYTES  24
00062 
00063 
00064 
00065 
00066 /* Structures for directory scanning (mainly 1541fs) */
00067 /* May hold entire pathname, so DON'T REDUCE!!! */
00068 #define FILENAME_MAX_CHARS      256     /* must be >= NAMEBUF_LENGTH (256) */
00069 
00070 typedef struct {
00071   unsigned int load, exec, length, attrib, otype;
00072   char name[FILENAME_MAX_CHARS];
00073 } dir_full_info;
00074 
00075 typedef struct {
00076   int readno, offset, buffsize;
00077   char *match;
00078 } dir_env;
00079 
00080 
00081 
00082 /* WIMP structures: */
00083 typedef struct {
00084   int *tit, *val;
00085   int len;
00086 } WIdatI;
00087 
00088 /* data type for window / icon data */
00089 typedef union {
00090   char strg[12];
00091   WIdatI ind;
00092 } WIdata;
00093 
00094 
00095 /* Window descriptor - 23 words = 92 bytes */
00096 typedef struct {
00097   int Handle;
00098   int vminx,vminy,vmaxx,vmaxy;
00099   int scrollx,scrolly;
00100   int stackpos;
00101   unsigned int wflags;
00102   char col_tfg, col_tbg, col_wfg, col_wbg; /* title/work_area fore/background colour */
00103   char col_sbo, col_sbi, col_tsl, reserved;/* scroll bar inner/outer, title if input focus */
00104   int wminx, wminy, wmaxx, wmaxy;
00105   unsigned int tflags, waflags;
00106   int SpriteAreaPtr;
00107   short min_width, min_height;
00108   WIdata dat;
00109   int icon_no;
00110 } RO_Window;
00111 
00112 
00113 /* Icon descriptor */
00114 typedef struct {
00115   int minx, miny, maxx, maxy;
00116   int iflags;
00117   WIdata dat;
00118 } RO_Icon;
00119 
00120 
00121 typedef struct {
00122   int WindowHandle;
00123   int minx, miny, maxx, maxy;
00124   int iflags;
00125   WIdata dat;
00126 } RO_IconDesc;
00127 
00128 
00129 typedef struct {
00130   char title[12];
00131   char col_tfg, col_tbg, col_wfg, col_wbg;
00132   int width, height, vgap;
00133 } RO_MenuHead;
00134 
00135 
00136 typedef struct {
00137   unsigned int mflags;
00138   RO_MenuHead *submenu;
00139   unsigned int iflags;
00140   WIdata dat;
00141 } RO_MenuItem;
00142 
00143 
00144 /* Caret descriptor */
00145 typedef struct {
00146   int WHandle;
00147   int IHandle;
00148   int offx, offy;
00149   int height, index;
00150 } RO_Caret;
00151 
00152 
00153 
00154 /* Joystick key descriptor */
00155 typedef struct {
00156   unsigned char up, down, left, right, fire;
00157 } Joy_Keys;
00158 
00159 
00160 
00161 
00162 /* Declare classes that are needed in the following new classes */
00163 class C64Display;
00164 class C64;
00165 
00166 
00167 
00168 /* Very simple class to read the resolution and eigen values */
00169 class RORes
00170 {
00171   public:
00172   RORes(void);
00173   ~RORes(void);
00174 
00175   int resx,resy,eigx,eigy;
00176 };
00177 
00178 
00179 /* Handle current screenmode */
00180 class ROScreen
00181 {
00182   private:
00183   _kernel_oserror ModeError;
00184 
00185   public:
00186   ROScreen(void);
00187   ~ROScreen(void);
00188   int ReadMode(void);
00189 
00190   int resx, resy, ldbpp, eigx, eigy, ladd;
00191   char *scrbase;
00192 };
00193 
00194 
00195 class Icon
00196 {
00197   private:
00198   RO_IconDesc icon;
00199 
00200   public:
00201   Icon(int IconHandle, const RO_IconDesc *IDesc);
00202   ~Icon(void);
00203   void setstate(unsigned int eor, unsigned int clear);
00204   void getstate(void);
00205 
00206   int IHandle;
00207 };
00208 
00209 
00210 class Window
00211 {
00212   private:
00213   RO_Window *wind;
00214   bool isopen;
00215 
00216   public:
00217   Window(const int *WDesc, const char *Title);
00218   ~Window(void);
00219   int  MyHandle(void);
00220   void GetWorkArea(int *Dest);
00221   void RedrawAWindow(int *Block, uint8 *Bitmap, C64Display *Disp);
00222   RO_Window *Descriptor(void);
00223   RO_Icon *GetIcon(unsigned int number);
00224   void SetIconState(unsigned int number, unsigned int eor, unsigned int clear);
00225   void GetIconState(unsigned int number, int *Block);
00226   void WriteIconText(unsigned int number, const char *text);
00227   void WriteIconTextU(unsigned int number, const char *text);   // update instead of force redrw
00228   void WriteIconNumber(unsigned int number, int value);
00229   void WriteIconNumberU(unsigned int number, int value);
00230   char *ReadIconText(unsigned int number);
00231   int  ReadIconNumber(unsigned int number);
00232   void ForceIconRedraw(unsigned int number);
00233   void UpdateIcon(unsigned int number);
00234   void WriteTitle(const char *title);
00235   char *ReadTitle(void);
00236   void UpdateTitle(void);
00237   bool HaveInput(void);
00238   bool OpenStatus(void);
00239   bool OpenStatus(int *Block);
00240   void open(void);
00241   void open(int *Block);
00242   void close(void);
00243   void forceredraw(int minx, int miny, int maxx, int maxy);
00244   void update(uint8 *Bitmap, C64Display *Disp);
00245   void update(int *Block, uint8 *Bitmap, C64Display *Disp);
00246   void redraw(int *Block, uint8 *Bitmap, C64Display *Disp);
00247   void extent(int minx, int miny, int maxx, int maxy);
00248   void getstate(void);
00249   void getstate(int *dest); // read window definition to external block
00250 };
00251 
00252 
00253 class WIMP
00254 {
00255   private:
00256   _kernel_oserror WimpError;
00257   int Block[64], AuxBlock[64];          // two WIMP blocks for convenience
00258   int Mask;
00259   int DragType, CMOS_DragType;
00260   bool UseScrap;        // Scrap file used (data transfer protocol!)
00261   bool EmuPaused;
00262   int UseNULL;          // Number of clients that need NULL events
00263   int RAMsize, RAMtransfered, RAMpartner;       // for RAM transfer
00264   int LastMenu, LastClick, LastDrag, MenuType, LastIcon, SaveType;
00265   int *SpriteArea;
00266   RO_Caret LastCaret;
00267   int EmuZoom;
00268   Joy_Keys NewJoyKeys[2];
00269   C64 *the_c64;
00270 
00271   public:
00272   WIMP(C64 *my_c64);
00273   ~WIMP(void);
00274 
00275   // On startup
00276   bool LoadATemplate(char *Name, Window **Which);
00277 
00278   // To make window and pane work as a team
00279   void OpenEmuWindow(void);
00280   void OpenEmuWindow(int *Block);       // open at pos
00281   void CloseEmuWindow(void);
00282   void UpdateEmuWindow(void);           // update window and pane
00283   void ThePrefsToWindow(void);          // write ThePrefs into the window
00284   void WindowToThePrefs(void);          // update ThePrefs from window
00285   void SysConfToWindow(void);
00286   void WindowToSysConf(void);
00287   void PollSysConfWindow(void);         // low-level koyboard scan
00288   void DragIconSprite(Window *host, unsigned int number);
00289   int  CalculateVolume(int *Block);
00290   int  CheckFilename(char *name);
00291   void SnapshotSaved(bool OK);
00292   void IssueSnapshotRequest(void);
00293   void SetLEDIcons(bool FloppyEmulation);
00294   void SetEmuWindowSize(void);
00295   void ToggleEmuWindowSize(void);
00296   int  ReadEmuWindowSize(void);
00297   void NewDriveImage(int DrNum, int *MsgBlock, bool SetNow);
00298   void SetSpeedLimiter(bool LimitSpeed);
00299 
00300   // Standard WIMP functions
00301   void Poll(bool Paused);
00302   void Redraw(void);
00303   void OpenWindow(void);
00304   void CloseWindow(void);
00305   void MouseClick(void);
00306   void UserDrag(void);
00307   void KeyPressed(void);
00308   void MenuSelection(void);
00309   void UserMessage(void);
00310   void UserMessageAck(void);
00311 
00312   // WIMP's Windows and Icons
00313   Icon *IBicon;
00314   Window *EmuWindow, *EmuPane, *PrefsWindow, *ConfigWindow, *InfoWindow, *SoundWindow, *SaveBox;
00315   char SnapFile[256], RAMFile[256];
00316 };
00317 
00318 
00319 
00320 /* system-specific Variables */
00321 
00322 extern RO_IconDesc IBarIcon;
00323 extern unsigned int TaskHandle;
00324 extern int WimpMessages[];
00325 
00326 
00327 /* Functions available via ROlib (not RISC OS Lib, mind you)
00328    All SWIs are called in the X-Form! */
00329 
00330 extern "C"
00331 {
00332 
00333 /* WIMP FUNCTIONS */
00334 
00335 /* returns handle or 0 if error */
00336 extern int Wimp_Initialise(int Version, int tw, const char *TaskName, const int *Messages);
00337 
00338 extern _kernel_oserror *Wimp_CloseDown(int Handle, int tw);
00339 
00340 /* returns handle or 0 if error */
00341 extern int Wimp_CreateWindow(const int *Window);
00342 
00343 extern int Wimp_CreateIcon(int Priority, const RO_IconDesc *Icon);
00344 
00345 extern _kernel_oserror *Wimp_DeleteWindow(const int *Window);
00346 
00347 extern _kernel_oserror *Wimp_DeleteIcon(int *Block);
00348 
00349 extern _kernel_oserror *Wimp_OpenWindow(const int *Window);
00350 
00351 extern _kernel_oserror *Wimp_CloseWindow(const int *Window);
00352 
00353 extern int Wimp_Poll(unsigned int Mask, int *Block, int *PollWord);
00354 
00355 /* returns 0 if no more to do or error */
00356 extern int Wimp_RedrawWindow(int *Block);
00357 
00358 extern int Wimp_UpdateWindow(int *Block);
00359 
00360 extern int Wimp_GetRectangle(int *Block);
00361 
00362 extern _kernel_oserror *Wimp_GetWindowState(int *Block);
00363 
00364 extern _kernel_oserror *Wimp_GetWindowInfo(int *Block);
00365 
00366 extern _kernel_oserror *Wimp_SetIconState(int *Block);
00367 
00368 extern _kernel_oserror *Wimp_GetIconState(int *Block);
00369 
00370 extern _kernel_oserror *Wimp_GetPointerInfo(int *Block);
00371 
00372 extern _kernel_oserror *Wimp_DragBox(int *Block);
00373 
00374 extern _kernel_oserror *Wimp_ForceRedraw(int Handle, int minx, int miny, int maxx, int maxy);
00375 
00376 extern _kernel_oserror *Wimp_SetCaretPosition(int WHandle, int IHandle, int xoff, int yoff, int height, int index);
00377 
00378 extern _kernel_oserror *Wimp_GetCaretPosition(RO_Caret *Caret);
00379 
00380 extern _kernel_oserror *Wimp_CreateMenu(const int *Menu, int cx, int cy);
00381 
00382 extern _kernel_oserror *Wimp_SetExtent(int Handle, int *Block);
00383 
00384 extern _kernel_oserror *Wimp_OpenTemplate(char *Name);
00385 
00386 extern _kernel_oserror *Wimp_CloseTemplate(void);
00387 
00388 extern _kernel_oserror *Wimp_LoadTemplate(char **Template, char **Indirect, char *IndirLimit, char *Fonts, char *Name, int *Position);
00389 
00390 extern _kernel_oserror *Wimp_ProcessKey(int Key);
00391 
00392 extern int Wimp_StartTask(char *command);
00393 
00394 extern _kernel_oserror *Wimp_ReportError(const _kernel_oserror *Error, unsigned int Flags, const char *AppName);
00395 
00396 extern _kernel_oserror *Wimp_GetWindowOutline(int *Block);
00397 
00398 extern int Wimp_PollIdle(unsigned int Mask, int *Block, int MinTime, int *PollWord);
00399 
00400 extern _kernel_oserror *Wimp_PlotIcon(int *Block);
00401 
00402 extern _kernel_oserror *Wimp_SendMessage(int Event, int *Block, int THandle, int IHandle);
00403 
00404 extern _kernel_oserror *Wimp_CreateSubMenu(int *MenuBlock, int cx, int xy);
00405 
00406 extern _kernel_oserror *Wimp_SpriteOp(int, int, int, int, int, int, int, int);
00407 
00408 extern _kernel_oserror *Wimp_BaseOfSprites(int *ROM, int *RAM);
00409 
00410 extern _kernel_oserror *Wimp_CommandWindow(int Action);
00411 
00412 extern _kernel_oserror *Wimp_TransferBlock(int SHandle, char *SBuff, int DHandle, char *DBuff, int BuffSize);
00413 
00414 extern _kernel_oserror *Wimp_SpriteInfo(char *name, int *width, int *height, int *mode);
00415 
00416 extern _kernel_oserror *DragASprite_Start(unsigned int Flags, int SpriteArea, char *SpriteName, int *Box, int *BBox);
00417 
00418 extern _kernel_oserror *DragASprite_Stop(void);
00419 
00420 extern _kernel_oserror *ColourTrans_SelectTable(int SMode, int SPal, int DMode, int DPal, char **Buffer, unsigned int Flags, int *TransWork, int *TransFunc);
00421 
00422 extern _kernel_oserror *ColourTrans_SetFontColours(int Handle, int BPal, int FPal, int Offset);
00423 
00424 extern _kernel_oserror *ColourTrans_SetColour(int GCOL, unsigned int Flags, int Action);
00425 
00426 extern _kernel_oserror *ColourTrans_SetGCOL(int Palette, unsigned int Flags, int Action);
00427 
00428 
00429 
00430 /* OS FUNCTIONS */
00431 
00432 extern int OS_ReadModeVariable(int mode, int var);
00433 
00434 extern int OS_ReadDynamicArea(int area);
00435 
00436 extern int ScanKeys(int keys);
00437 
00438 extern int ReadKeyboardStatus(void);
00439 
00440 extern int ReadDragType(void);
00441 
00442 extern int SetMousePointer(int NewShape);
00443 
00444 
00445 /* Generic sprite op call */
00446 extern _kernel_oserror *OS_SpriteOp(int, int, int, int, int, int, int, int);
00447 
00448 extern _kernel_oserror *OS_Plot(int Command, int x, int y);
00449 
00450 extern _kernel_oserror *MouseBoundingBox(char Box[8]);
00451 
00452 extern int OS_ReadMonotonicTime(void);
00453 
00454 extern _kernel_oserror *OS_ReadC(char *Code);
00455 
00456 /* returns length of characters read; if length negative ==> terminated by escape */
00457 extern int OS_ReadLine(char *Buffer, int BuffSize, int minasc, int maxasc, int Echo);
00458 
00459 /* TRUE ==> escape */
00460 extern bool OS_ReadEscapeState(void);
00461 
00462 /* File related calls */
00463 
00464 /* Returns object type */
00465 extern int ReadCatalogueInfo(char *Name, int Result[4]);
00466 
00467 /* Read the next name in the directory */
00468 extern _kernel_oserror *ReadDirName(const char *dirname, char *buffer, dir_env *env);
00469 
00470 /* Read the next entry (name, length, type,...) in the directory */
00471 extern _kernel_oserror *ReadDirNameInfo(const char *dirname,dir_full_info *buffer,dir_env *env);
00472 
00473 extern _kernel_oserror *DeleteFile(char *name);
00474 
00475 extern _kernel_oserror *OS_FlushBuffer(int BuffNum);
00476 
00477 /* These functions are more secure than using sprintf because they allow buffersize */
00478 /* Return value is a pointer to the terminating null */
00479 extern char *ConvertInteger1(int value, char *buffer, int buffsize);
00480 extern char *ConvertInteger2(int value, char *buffer, int buffsize);
00481 extern char *ConvertInteger3(int value, char *buffer, int buffsize);
00482 extern char *ConvertInteger4(int value, char *buffer, int buffsize);
00483 
00484 
00485 /* Misc */
00486 
00487 extern unsigned int ModeColourNumber(unsigned int pal_entry);
00488 
00489 /* Returns -1 if error in joystick module, -2 if SWI unknown, joystate otherwise */
00490 extern int Joystick_Read(int joyno);
00491 
00492 
00493 /* Sound stuff */
00494 
00495 #define DRState_Active          1
00496 #define DRState_NeedData        2
00497 #define DRState_Overflow        4
00498 
00499 /* Sound calls */
00500 
00501 extern int Sound_Volume(int volume);
00502 
00503 /* Digital Renderer SWI calls */
00504 extern _kernel_oserror *DigitalRenderer_Activate(int Channels, int Length, int SamPeriod);
00505 
00506 extern _kernel_oserror *DigitalRenderer_Deactivate(void);
00507 
00508 extern _kernel_oserror *DigitalRenderer_Pause(void);
00509 
00510 extern _kernel_oserror *DigitalRenderer_Resume(void);
00511 
00512 extern _kernel_oserror *DigitalRenderer_GetTables(uint8 **LinToLog, uint8 **LogScale);
00513 
00514 extern int DigitalRenderer_ReadState(void);
00515 
00516 extern _kernel_oserror *DigitalRenderer_NewSample(uint8 *Sample);
00517 
00518 }
00519 
00520 #endif

Generated on Tue Feb 8 04:08:07 2005 for E32frodo by doxygen 1.3.3