ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/ROlib.h
Revision: 1.5
Committed: 2005-06-27T19:55:48Z (19 years, 3 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: VERSION_4_2, HEAD
Changes since 1.4: +1 -1 lines
Log Message:
updated copyright dates

File Contents

# Content
1 /*
2 * ROlib.h - Defines Classes, variables and OS interface calls for Acorn
3 * RISC OS computers
4 *
5 * (C) 1997 Andreas Dehmel
6 *
7 * Frodo (C) 1994-1997,2002-2005 Christian Bauer
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #ifndef RO_CUSTOM_LIB
25 #define RO_CUSTOM_LIB
26
27 #include <kernel.h>
28
29
30 #define TASKNAME "Frodo"
31 #define TASK_WORD 0x4b534154
32
33 /* Scrap-file for 1541fs directory function */
34 #define RO_TEMPFILE "<Wimp$ScrapDir>.FrodoDIR"
35
36
37
38 /* Icon Flags */
39 #define IFlg_Text 1
40 #define IFlg_Sprite 2
41 #define IFlg_Border 4
42 #define IFlg_HCenter 8
43 #define IFlg_VCenter 16
44 #define IFlg_Filled 32
45 #define IFlg_AntiA 64
46 #define IFlg_AutoRdrw 128
47 #define IFlg_Indir 256
48 #define IFlg_RAdjust 512
49 #define IFlg_Slct (1<<21)
50 #define IFlg_Grey (1<<22)
51
52 /* Menu Flags */
53 #define MFlg_Tick 1
54 #define MFlg_Dotted 2
55 #define MFlg_Writable 4
56 #define MFlg_Warning 8
57 #define MFlg_LastItem 128
58
59 /* Joystick stuff */
60 #define JoyDir_Thresh 32
61 #define JoyButton1 (1<<16)
62 #define JoyButton2 (1<<17)
63
64
65
66 /* Size of WIMP data types */
67 #define RO_WINDOW_WORDS 23
68 #define RO_WINDOW_BYTES 92
69 #define RO_ICON_WORDS 8
70 #define RO_ICON_BYTES 32
71 #define RO_MHEAD_WORDS 7
72 #define RO_MHEAD_BYTES 28
73 #define RO_MITEM_WORDS 6
74 #define RO_MITEM_BYTES 24
75
76
77
78
79 /* Structures for directory scanning (mainly 1541fs) */
80 /* May hold entire pathname, so DON'T REDUCE!!! */
81 #define FILENAME_MAX_CHARS 256 /* must be >= NAMEBUF_LENGTH (256) */
82
83 typedef struct {
84 unsigned int load, exec, length, attrib, otype;
85 char name[FILENAME_MAX_CHARS];
86 } dir_full_info;
87
88 typedef struct {
89 int readno, offset, buffsize;
90 char *match;
91 } dir_env;
92
93
94
95 /* WIMP structures: */
96 typedef struct {
97 int *tit, *val;
98 int len;
99 } WIdatI;
100
101 /* data type for window / icon data */
102 typedef union {
103 char strg[12];
104 WIdatI ind;
105 } WIdata;
106
107
108 /* Window descriptor - 23 words = 92 bytes */
109 typedef struct {
110 int Handle;
111 int vminx,vminy,vmaxx,vmaxy;
112 int scrollx,scrolly;
113 int stackpos;
114 unsigned int wflags;
115 char col_tfg, col_tbg, col_wfg, col_wbg; /* title/work_area fore/background colour */
116 char col_sbo, col_sbi, col_tsl, reserved;/* scroll bar inner/outer, title if input focus */
117 int wminx, wminy, wmaxx, wmaxy;
118 unsigned int tflags, waflags;
119 int SpriteAreaPtr;
120 short min_width, min_height;
121 WIdata dat;
122 int icon_no;
123 } RO_Window;
124
125
126 /* Icon descriptor */
127 typedef struct {
128 int minx, miny, maxx, maxy;
129 int iflags;
130 WIdata dat;
131 } RO_Icon;
132
133
134 typedef struct {
135 int WindowHandle;
136 int minx, miny, maxx, maxy;
137 int iflags;
138 WIdata dat;
139 } RO_IconDesc;
140
141
142 typedef struct {
143 char title[12];
144 char col_tfg, col_tbg, col_wfg, col_wbg;
145 int width, height, vgap;
146 } RO_MenuHead;
147
148
149 typedef struct {
150 unsigned int mflags;
151 RO_MenuHead *submenu;
152 unsigned int iflags;
153 WIdata dat;
154 } RO_MenuItem;
155
156
157 /* Caret descriptor */
158 typedef struct {
159 int WHandle;
160 int IHandle;
161 int offx, offy;
162 int height, index;
163 } RO_Caret;
164
165
166
167 /* Joystick key descriptor */
168 typedef struct {
169 unsigned char up, down, left, right, fire;
170 } Joy_Keys;
171
172
173
174
175 /* Declare classes that are needed in the following new classes */
176 class C64Display;
177 class C64;
178
179
180
181 /* Very simple class to read the resolution and eigen values */
182 class RORes
183 {
184 public:
185 RORes(void);
186 ~RORes(void);
187
188 int resx,resy,eigx,eigy;
189 };
190
191
192 /* Handle current screenmode */
193 class ROScreen
194 {
195 private:
196 _kernel_oserror ModeError;
197
198 public:
199 ROScreen(void);
200 ~ROScreen(void);
201 int ReadMode(void);
202
203 int resx, resy, ldbpp, eigx, eigy, ladd;
204 char *scrbase;
205 };
206
207
208 class Icon
209 {
210 private:
211 RO_IconDesc icon;
212
213 public:
214 Icon(int IconHandle, const RO_IconDesc *IDesc);
215 ~Icon(void);
216 void setstate(unsigned int eor, unsigned int clear);
217 void getstate(void);
218
219 int IHandle;
220 };
221
222
223 class Window
224 {
225 private:
226 RO_Window *wind;
227 bool isopen;
228
229 public:
230 Window(const int *WDesc, const char *Title);
231 ~Window(void);
232 int MyHandle(void);
233 void GetWorkArea(int *Dest);
234 void RedrawAWindow(int *Block, uint8 *Bitmap, C64Display *Disp);
235 RO_Window *Descriptor(void);
236 RO_Icon *GetIcon(unsigned int number);
237 void SetIconState(unsigned int number, unsigned int eor, unsigned int clear);
238 void GetIconState(unsigned int number, int *Block);
239 void WriteIconText(unsigned int number, const char *text);
240 void WriteIconTextU(unsigned int number, const char *text); // update instead of force redrw
241 void WriteIconNumber(unsigned int number, int value);
242 void WriteIconNumberU(unsigned int number, int value);
243 char *ReadIconText(unsigned int number);
244 int ReadIconNumber(unsigned int number);
245 void ForceIconRedraw(unsigned int number);
246 void UpdateIcon(unsigned int number);
247 void WriteTitle(const char *title);
248 char *ReadTitle(void);
249 void UpdateTitle(void);
250 bool HaveInput(void);
251 bool OpenStatus(void);
252 bool OpenStatus(int *Block);
253 void open(void);
254 void open(int *Block);
255 void close(void);
256 void forceredraw(int minx, int miny, int maxx, int maxy);
257 void update(uint8 *Bitmap, C64Display *Disp);
258 void update(int *Block, uint8 *Bitmap, C64Display *Disp);
259 void redraw(int *Block, uint8 *Bitmap, C64Display *Disp);
260 void extent(int minx, int miny, int maxx, int maxy);
261 void getstate(void);
262 void getstate(int *dest); // read window definition to external block
263 };
264
265
266 class WIMP
267 {
268 private:
269 _kernel_oserror WimpError;
270 int Block[64], AuxBlock[64]; // two WIMP blocks for convenience
271 int Mask;
272 int DragType, CMOS_DragType;
273 bool UseScrap; // Scrap file used (data transfer protocol!)
274 bool EmuPaused;
275 int UseNULL; // Number of clients that need NULL events
276 int RAMsize, RAMtransfered, RAMpartner; // for RAM transfer
277 int LastMenu, LastClick, LastDrag, MenuType, LastIcon, SaveType;
278 int *SpriteArea;
279 RO_Caret LastCaret;
280 int EmuZoom;
281 Joy_Keys NewJoyKeys[2];
282 C64 *the_c64;
283
284 public:
285 WIMP(C64 *my_c64);
286 ~WIMP(void);
287
288 // On startup
289 bool LoadATemplate(char *Name, Window **Which);
290
291 // To make window and pane work as a team
292 void OpenEmuWindow(void);
293 void OpenEmuWindow(int *Block); // open at pos
294 void CloseEmuWindow(void);
295 void UpdateEmuWindow(void); // update window and pane
296 void ThePrefsToWindow(void); // write ThePrefs into the window
297 void WindowToThePrefs(void); // update ThePrefs from window
298 void SysConfToWindow(void);
299 void WindowToSysConf(void);
300 void PollSysConfWindow(void); // low-level koyboard scan
301 void DragIconSprite(Window *host, unsigned int number);
302 int CalculateVolume(int *Block);
303 int CheckFilename(char *name);
304 void SnapshotSaved(bool OK);
305 void IssueSnapshotRequest(void);
306 void SetLEDIcons(bool FloppyEmulation);
307 void SetEmuWindowSize(void);
308 void ToggleEmuWindowSize(void);
309 int ReadEmuWindowSize(void);
310 void NewDriveImage(int DrNum, int *MsgBlock, bool SetNow);
311 void SetSpeedLimiter(bool LimitSpeed);
312
313 // Standard WIMP functions
314 void Poll(bool Paused);
315 void Redraw(void);
316 void OpenWindow(void);
317 void CloseWindow(void);
318 void MouseClick(void);
319 void UserDrag(void);
320 void KeyPressed(void);
321 void MenuSelection(void);
322 void UserMessage(void);
323 void UserMessageAck(void);
324
325 // WIMP's Windows and Icons
326 Icon *IBicon;
327 Window *EmuWindow, *EmuPane, *PrefsWindow, *ConfigWindow, *InfoWindow, *SoundWindow, *SaveBox;
328 char SnapFile[256], RAMFile[256];
329 };
330
331
332
333 /* system-specific Variables */
334
335 extern RO_IconDesc IBarIcon;
336 extern unsigned int TaskHandle;
337 extern int WimpMessages[];
338
339
340 /* Functions available via ROlib (not RISC OS Lib, mind you)
341 All SWIs are called in the X-Form! */
342
343 extern "C"
344 {
345
346 /* WIMP FUNCTIONS */
347
348 /* returns handle or 0 if error */
349 extern int Wimp_Initialise(int Version, int tw, const char *TaskName, const int *Messages);
350
351 extern _kernel_oserror *Wimp_CloseDown(int Handle, int tw);
352
353 /* returns handle or 0 if error */
354 extern int Wimp_CreateWindow(const int *Window);
355
356 extern int Wimp_CreateIcon(int Priority, const RO_IconDesc *Icon);
357
358 extern _kernel_oserror *Wimp_DeleteWindow(const int *Window);
359
360 extern _kernel_oserror *Wimp_DeleteIcon(int *Block);
361
362 extern _kernel_oserror *Wimp_OpenWindow(const int *Window);
363
364 extern _kernel_oserror *Wimp_CloseWindow(const int *Window);
365
366 extern int Wimp_Poll(unsigned int Mask, int *Block, int *PollWord);
367
368 /* returns 0 if no more to do or error */
369 extern int Wimp_RedrawWindow(int *Block);
370
371 extern int Wimp_UpdateWindow(int *Block);
372
373 extern int Wimp_GetRectangle(int *Block);
374
375 extern _kernel_oserror *Wimp_GetWindowState(int *Block);
376
377 extern _kernel_oserror *Wimp_GetWindowInfo(int *Block);
378
379 extern _kernel_oserror *Wimp_SetIconState(int *Block);
380
381 extern _kernel_oserror *Wimp_GetIconState(int *Block);
382
383 extern _kernel_oserror *Wimp_GetPointerInfo(int *Block);
384
385 extern _kernel_oserror *Wimp_DragBox(int *Block);
386
387 extern _kernel_oserror *Wimp_ForceRedraw(int Handle, int minx, int miny, int maxx, int maxy);
388
389 extern _kernel_oserror *Wimp_SetCaretPosition(int WHandle, int IHandle, int xoff, int yoff, int height, int index);
390
391 extern _kernel_oserror *Wimp_GetCaretPosition(RO_Caret *Caret);
392
393 extern _kernel_oserror *Wimp_CreateMenu(const int *Menu, int cx, int cy);
394
395 extern _kernel_oserror *Wimp_SetExtent(int Handle, int *Block);
396
397 extern _kernel_oserror *Wimp_OpenTemplate(char *Name);
398
399 extern _kernel_oserror *Wimp_CloseTemplate(void);
400
401 extern _kernel_oserror *Wimp_LoadTemplate(char **Template, char **Indirect, char *IndirLimit, char *Fonts, char *Name, int *Position);
402
403 extern _kernel_oserror *Wimp_ProcessKey(int Key);
404
405 extern int Wimp_StartTask(char *command);
406
407 extern _kernel_oserror *Wimp_ReportError(const _kernel_oserror *Error, unsigned int Flags, const char *AppName);
408
409 extern _kernel_oserror *Wimp_GetWindowOutline(int *Block);
410
411 extern int Wimp_PollIdle(unsigned int Mask, int *Block, int MinTime, int *PollWord);
412
413 extern _kernel_oserror *Wimp_PlotIcon(int *Block);
414
415 extern _kernel_oserror *Wimp_SendMessage(int Event, int *Block, int THandle, int IHandle);
416
417 extern _kernel_oserror *Wimp_CreateSubMenu(int *MenuBlock, int cx, int xy);
418
419 extern _kernel_oserror *Wimp_SpriteOp(int, int, int, int, int, int, int, int);
420
421 extern _kernel_oserror *Wimp_BaseOfSprites(int *ROM, int *RAM);
422
423 extern _kernel_oserror *Wimp_CommandWindow(int Action);
424
425 extern _kernel_oserror *Wimp_TransferBlock(int SHandle, char *SBuff, int DHandle, char *DBuff, int BuffSize);
426
427 extern _kernel_oserror *Wimp_SpriteInfo(char *name, int *width, int *height, int *mode);
428
429 extern _kernel_oserror *DragASprite_Start(unsigned int Flags, int SpriteArea, char *SpriteName, int *Box, int *BBox);
430
431 extern _kernel_oserror *DragASprite_Stop(void);
432
433 extern _kernel_oserror *ColourTrans_SelectTable(int SMode, int SPal, int DMode, int DPal, char **Buffer, unsigned int Flags, int *TransWork, int *TransFunc);
434
435 extern _kernel_oserror *ColourTrans_SetFontColours(int Handle, int BPal, int FPal, int Offset);
436
437 extern _kernel_oserror *ColourTrans_SetColour(int GCOL, unsigned int Flags, int Action);
438
439 extern _kernel_oserror *ColourTrans_SetGCOL(int Palette, unsigned int Flags, int Action);
440
441
442
443 /* OS FUNCTIONS */
444
445 extern int OS_ReadModeVariable(int mode, int var);
446
447 extern int OS_ReadDynamicArea(int area);
448
449 extern int ScanKeys(int keys);
450
451 extern int ReadKeyboardStatus(void);
452
453 extern int ReadDragType(void);
454
455 extern int SetMousePointer(int NewShape);
456
457
458 /* Generic sprite op call */
459 extern _kernel_oserror *OS_SpriteOp(int, int, int, int, int, int, int, int);
460
461 extern _kernel_oserror *OS_Plot(int Command, int x, int y);
462
463 extern _kernel_oserror *MouseBoundingBox(char Box[8]);
464
465 extern int OS_ReadMonotonicTime(void);
466
467 extern _kernel_oserror *OS_ReadC(char *Code);
468
469 /* returns length of characters read; if length negative ==> terminated by escape */
470 extern int OS_ReadLine(char *Buffer, int BuffSize, int minasc, int maxasc, int Echo);
471
472 /* true ==> escape */
473 extern bool OS_ReadEscapeState(void);
474
475 /* File related calls */
476
477 /* Returns object type */
478 extern int ReadCatalogueInfo(char *Name, int Result[4]);
479
480 /* Read the next name in the directory */
481 extern _kernel_oserror *ReadDirName(const char *dirname, char *buffer, dir_env *env);
482
483 /* Read the next entry (name, length, type,...) in the directory */
484 extern _kernel_oserror *ReadDirNameInfo(const char *dirname,dir_full_info *buffer,dir_env *env);
485
486 extern _kernel_oserror *DeleteFile(char *name);
487
488 extern _kernel_oserror *OS_FlushBuffer(int BuffNum);
489
490 /* These functions are more secure than using sprintf because they allow buffersize */
491 /* Return value is a pointer to the terminating null */
492 extern char *ConvertInteger1(int value, char *buffer, int buffsize);
493 extern char *ConvertInteger2(int value, char *buffer, int buffsize);
494 extern char *ConvertInteger3(int value, char *buffer, int buffsize);
495 extern char *ConvertInteger4(int value, char *buffer, int buffsize);
496
497
498 /* Misc */
499
500 extern unsigned int ModeColourNumber(unsigned int pal_entry);
501
502 /* Returns -1 if error in joystick module, -2 if SWI unknown, joystate otherwise */
503 extern int Joystick_Read(int joyno);
504
505
506 /* Sound stuff */
507
508 #define DRState_Active 1
509 #define DRState_NeedData 2
510 #define DRState_Overflow 4
511
512 /* Sound calls */
513
514 extern int Sound_Volume(int volume);
515
516 /* Digital Renderer SWI calls */
517 extern _kernel_oserror *DigitalRenderer_Activate(int Channels, int Length, int SamPeriod);
518
519 extern _kernel_oserror *DigitalRenderer_Deactivate(void);
520
521 extern _kernel_oserror *DigitalRenderer_Pause(void);
522
523 extern _kernel_oserror *DigitalRenderer_Resume(void);
524
525 extern _kernel_oserror *DigitalRenderer_GetTables(uint8 **LinToLog, uint8 **LogScale);
526
527 extern int DigitalRenderer_ReadState(void);
528
529 extern _kernel_oserror *DigitalRenderer_NewSample(uint8 *Sample);
530
531 }
532
533 #endif