9 #include <exec/types.h> 10 #include <libraries/dos.h> 11 #include <exec/memory.h> 12 #include <proto/exec.h> 13 #include <proto/dos.h> 14 #include <intuition/intuition.h> 15 #include <hardware/custom.h> 16 #include <devices/trackdisk.h> 17 #include <hardware/cia.h> 20 extern struct IntuitionBase *IntuitionBase;
21 extern struct Custom far custom;
22 struct Window *mouse_window = NULL;
23 struct IntuiMessage *window_message = NULL;
24 static char str_diskname[256];
26 int file_get_size(
char *filename)
28 struct FileLock *lock;
29 struct FileInfoBlock *fib_ptr;
32 memset(str_diskname, 0, 255);
33 fib_ptr = (
struct FileInfoBlock *)AllocMem(
sizeof(
struct FileInfoBlock ), MEMF_PUBLIC | MEMF_CLEAR );
34 lock = (
struct FileLock *)Lock(filename, SHARED_LOCK);
38 if(Examine((BPTR)lock, fib_ptr) != NULL)
39 filesize = fib_ptr->fib_Size;
44 FreeMem(fib_ptr,
sizeof(
struct FileInfoBlock));
49 char *disk_get_logical_name(
char *device_physical_name)
53 struct MsgPort *TrackMP;
54 struct IOExtTD *TrackIO;
55 struct FileLock *lock;
56 struct FileInfoBlock *fib_ptr;
59 printf(
"disk_get_logical_name(%s), ", device_physical_name);
62 if (strncmp(device_physical_name,
"df0:", 4) == 0)
64 else if (strncmp(device_physical_name,
"df1:", 4) == 0)
66 else if (strncmp(device_physical_name,
"df2:", 4) == 0)
68 else if (strncmp(device_physical_name,
"df3:", 4) == 0)
73 printf(
"unknown disk physical name!\n");
79 if (TrackMP=CreatePort(0,0) )
80 if (TrackIO=(
struct IOExtTD *)CreateExtIO(TrackMP,
sizeof(
struct IOExtTD)))
82 if (!OpenDevice(TD_NAME, (
long)disk_idx,(
struct IORequest *)TrackIO, 0))
84 TrackIO->iotd_Req.io_Flags = IOF_QUICK;
85 TrackIO->iotd_Req.io_Command = TD_CHANGESTATE;
86 BeginIO((
struct IORequest *)TrackIO);
87 WaitIO((
struct IORequest *)TrackIO);
89 if (!(TrackIO->iotd_Req.io_Error))
91 if (!(TrackIO->iotd_Req.io_Actual))
92 disk_is_present =
TRUE;
97 printf(
"BeginIO() error!\n");
102 printf(
"%s did not open\n", TD_NAME);
109 memset(str_diskname, 0, 255);
110 fib_ptr = (
struct FileInfoBlock *)AllocMem(
sizeof(
struct FileInfoBlock ), MEMF_PUBLIC | MEMF_CLEAR );
111 lock = (
struct FileLock *)Lock(device_physical_name, SHARED_LOCK);
115 if(Examine((BPTR)lock, fib_ptr) != NULL)
116 strcpy(str_diskname, fib_ptr->fib_FileName);
121 FreeMem(fib_ptr,
sizeof(
struct FileInfoBlock));
123 strcat(str_diskname,
":");
125 printf(
"%s\n", str_diskname);
131 printf(
"no disk in drive!\n");
136 void input_window_init(
struct Window *window)
138 mouse_window = window;
141 void input_update(
short *button,
short *x,
short *y,
unsigned short *rawkey)
145 unsigned short qualifier;
146 unsigned short button_left = 0, button_right = 0;
148 if (mouse_window != NULL)
150 Wait(1 << mouse_window->UserPort->mp_SigBit);
152 while (window_message = (
struct IntuiMessage *)GetMsg(mouse_window->UserPort))
154 class = window_message->Class;
155 code = window_message->Code;
156 qualifier = window_message->Qualifier;
158 *x = window_message->MouseX;
159 *y = window_message->MouseY;
160 ReplyMsg((
struct Message *)window_message);
172 button_left = PLATFORM_MOUSE_LEFT_BUTTON;
180 button_right = PLATFORM_MOUSE_RIGHT_BUTTON;
211 *button = button_left | button_right;
215 printf(
"No window to get mouse from!\n");