2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Begining of AROS kernel
12 #include <aros/debug.h>
14 #include <intuition/intuition.h>
16 #include <exec/memory.h>
17 #include <exec/types.h>
19 #include <devices/trackdisk.h>
21 #include <proto/exec.h>
22 #include <graphics/gfx.h>
23 #include <utility/tagitem.h>
24 #include <proto/graphics.h>
25 #include <proto/intuition.h>
27 #include <hidd/hidd.h>
28 #include <hidd/serial.h>
33 #include <clib/arossupport_protos.h>
35 #define ioStd(x) ((struct IOStdReq *)x)
37 static void BlackPrint(struct RastPort
*RPort
, char *String
, UWORD height
, struct GfxBase
* GfxBase
);
38 static void WhitePrint(struct RastPort
*RPort
, char *String
, UWORD height
, struct GfxBase
* GfxBase
);
41 void hidd_demo(struct ExecBase
* SysBase
)
43 D(bug("graphics.hidd = %08.8lx\n",OpenLibrary("graphics.hidd",0)));
44 D(bug("display.hidd = %08.8lx\n",OpenLibrary("display.hidd",0)));
46 OpenLibrary("hidd.gfx.display",0);
48 struct GfxBase
*GfxBase
;
51 D(bug("init_gfx(hiddbase=%s)\n", "hidd.gfx.display"));
53 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 37);
57 /* Call private gfx.library call to init the HIDD.
58 Gfx library is responsable for closing the HIDD
59 library (although it will probably not be neccesary).
62 D(bug("calling private gfx LateGfxInit()\n"));
63 if (LateGfxInit("hidd.gfx.display"))
65 struct IntuitionBase
*IntuitionBase
;
67 D(bug("lategfxinit okay\n"));
69 /* Now that gfx. is guaranteed to be up & working, let intuition open WB screen */
70 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
71 D(bug("ibase = %lx\n", IntuitionBase
));
74 if (LateIntuiInit(NULL
))
78 CloseLibrary((struct Library
*)IntuitionBase
);
81 D(bug("Closing gfx\n"));
83 CloseLibrary((struct Library
*)GfxBase
);
87 D(bug("There is something wrong with hidd subsystem..."));
100 io
=CreateIORequest(mp
,sizeof(struct IOStdReq
));
101 D(bug("Result of opening device %d\n",
102 OpenDevice("gameport.device",0,io
,0)));
103 D(bug("Doing CMD_HIDDINIT...\n"));
106 data
= AllocMem(100, MEMF_PUBLIC
);
107 strcpy(data
, "hidd.bus.mouse");
108 ioStd(io
)->io_Command
=32000;
109 ioStd(io
)->io_Data
=data
;
110 ioStd(io
)->io_Length
=strlen(data
);
112 D(bug("Got io_ERROR=%d",io
->io_Error
));
117 struct IntuitionBase
*IntuitionBase
;
118 struct GfxBase
*GfxBase
;
119 struct Window
* win
= NULL
;
126 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 37);
127 GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 37);
131 struct TagItem tags
[] = {
140 {WA_Title
, (ULONG
)"AROS Dream :-)"},
142 {WA_SizeGadget
, TRUE
},
143 {WA_DepthGadget
, TRUE
},
145 win
= OpenWindowTagList(0, tags
);
148 DrawEllipse(win
->RPort
,160/2-35,120/2-4,80/2,80/2);
149 DrawEllipse(win
->RPort
,185/2-35,90/2-4,15/2,15/2);
150 DrawEllipse(win
->RPort
,135/2-35,90/2-4,15/2,15/2);
152 Move(win
->RPort
,125/2-35,140/2-4);
153 Draw(win
->RPort
,140/2-35,150/2-4);
154 Draw(win
->RPort
,180/2-35,150/2-4);
155 Draw(win
->RPort
,195/2-35,140/2-4);
172 MoveWindow(win
,-1,0);
177 MoveWindow(win
,0,-1);
185 struct Screen
*screen
;
187 struct IntuiMessage
*msg
;
190 if ((screen
= LockPubScreen(NULL
)))
192 struct TagItem tags
[] = {
201 {WA_Title
, (ULONG
)"AROS !ext" },
203 {WA_CloseGadget
, TRUE
},
204 {WA_SizeGadget
, TRUE
},
205 {WA_DepthGadget
, TRUE
},
206 {WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_MOUSEMOVE
| IDCMP_RAWKEY
},
207 {WA_ReportMouse
, TRUE
},
209 win2
= OpenWindowTagList(0, tags
);
211 sprintf(ScreenInfo
,"ScreenWidth: %d, ScreenHeight: %d", screen
->Width
, screen
->Height
);
215 BlackPrint(win2
->RPort
, ScreenInfo
, 40, GfxBase
);
221 WaitPort(win2
->UserPort
);
222 while((msg
= ((struct IntuiMessage
*)GetMsg(win2
->UserPort
))))
228 static char hex
[] = "0123456789ABCDEF";
235 s
[4] = hex
[(msg
->Code
>> 12) & 0xF];
236 s
[5] = hex
[(msg
->Code
>> 8) & 0xF];
237 s
[6] = hex
[(msg
->Code
>> 4) & 0xF];
238 s
[7] = hex
[(msg
->Code
>> 0) & 0xF];
241 BlackPrint(win2
->RPort
, s
, 60, GfxBase
);
243 if (msg
->Code
== 0x45) quitme
= TRUE
;
247 case IDCMP_MOUSEMOVE
:
249 WORD mx
= win2
->WScreen
->MouseX
;
250 WORD my
= win2
->WScreen
->MouseY
;
254 sprintf(s
, "Mouse: %4d, %4d", mx
, my
);
256 WhitePrint(win2
->RPort
, s
, 80, GfxBase
);
261 SetAPen(&win2
->WScreen
->RastPort
, 1);
262 SetDrMd(&win2
->WScreen
->RastPort
, JAM2
);
263 WritePixel(&win2
->WScreen
->RastPort
, mx
, my
);
268 case IDCMP_CLOSEWINDOW
:
275 ReplyMsg((struct Message
*)msg
);
282 UnlockPubScreen(NULL
,screen
);
289 static void BlackPrint(struct RastPort
*RPort
, char *String
, UWORD height
, struct GfxBase
* GfxBase
)
293 SetDrMd(RPort
, JAM2
);
294 Move(RPort
,20,height
);
295 Text(RPort
, String
, strlen(String
));
298 static void WhitePrint(struct RastPort
*RPort
, char *String
, UWORD height
, struct GfxBase
* GfxBase
)
302 SetDrMd(RPort
, JAM2
);
303 Move(RPort
,20,height
);
304 Text(RPort
, String
, strlen(String
));