1 /*
2 * UAE - The Un*x Amiga Emulator
3 *
4 * Interface to the Tcl/Tk GUI
5 *
6 * Copyright 1996 Bernd Schmidt
7 */
8
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #ifdef __unix
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #include <sys/time.h>
16 #endif
17 #include <fcntl.h>
18 #include <unistd.h>
19 #include <signal.h>
20 #include <SIOUX.h>
21
22 #include "amiga.h"
23 #include "options.h"
24 #include "memory.h"
25 #include "custom.h"
26 #include "newcpu.h"
27 #include "disk.h"
28 #include "gui.h"
29
30 #define kAppleMenuID 128
31 #define kFileMenuID 129
32 #define kEditMenuID 130
33 #define kDrivesMenuID 131
34 #define kMemoryMenuID 132
35 #define kResMenuID 135
36 #define kRateMenuID 134
37 #define kVideoMenuID 133
38
39 MenuHandle resMenu,rateMenu;
40 static int macLedState[5];
41 extern int use_quickdraw;
42 static Rect powerRect, driveDf0Rect, driveDf1Rect, driveDf2Rect, driveDf3Rect;
43
sigchldhandler(int foo)44 static void sigchldhandler(int foo)
45 {
46 }
47
InitToolbox(void)48 static void InitToolbox(void)
49 {
50 InitGraf (&qd.thePort);
51 InitFonts ();
52 FlushEvents (everyEvent,0);
53 InitWindows ();
54 InitMenus ();
55 TEInit ();
56 InitDialogs (nil);
57 InitCursor ();
58 }
59
60 #define kPrefStrRsrc 130
61
gui_init(void)62 int gui_init(void)
63 { char pathString[1024];
64 Handle menuBar;
65
66 InitToolbox();
67
68 SIOUXSettings.initializeTB=false;
69 SIOUXSettings.standalone=false;
70 SIOUXSettings.setupmenus=false;
71 SIOUXSettings.autocloseonquit=true;
72 SIOUXSettings.asktosaveonclose=false;
73 SIOUXSettings.showstatusline=false;
74 SIOUXSettings.rows=11;
75 SIOUXSettings.toppixel=350;
76 SIOUXSettings.leftpixel=0;
77 fprintf(stderr,"Starting up the GUI�\n");
78 SIOUXSetTitle("\pInfo Window");
79
80 if (ReadPrefs(pathString))
81 { if (*pathString != 0) add_filesys_unit("HD0", (char *)pathString, false);
82 }
83 else
84 { if (*pathString == 0)
85 { CreatePrefs();
86 WritePrefs(0);
87 }
88 }
89
90 menuBar=GetNewMBar(128);
91 SetMenuBar(menuBar);
92 DisposeHandle(menuBar);
93
94 AddResMenu(GetMenuHandle(kAppleMenuID), 'DRVR');
95
96 if (screen_res != 4) DisableItem (GetMenuHandle(kFileMenuID), 3);
97 if (use_quickdraw) CheckItem(GetMenuHandle(kVideoMenuID),5,true);
98 if (use_gfxlib) CheckItem(GetMenuHandle(kVideoMenuID),7,true);
99 if (use_slow_mem) SetMenuItemText(GetMenuHandle(kMemoryMenuID), 1, "\pDisable 1 Mb (SlowMem)" );
100 if (!automount_uaedev) CheckItem(GetMenuHandle(kDrivesMenuID),7,true);
101 if (produce_sound) SetMenuItemText(GetMenuHandle(kFileMenuID), 9, "\pTurn Sound Off");
102 else SetMenuItemText(GetMenuHandle(kFileMenuID), 9, "\pTurn Sound On");
103 if (fake_joystick) SetMenuItemText(GetMenuHandle(kFileMenuID), 11, "\pTurn Joystick Off");
104 else SetMenuItemText(GetMenuHandle(kFileMenuID), 11, "\pTurn Joystick On");
105
106 rateMenu=GetMenu(kRateMenuID);
107 InsertMenu(rateMenu, -1);
108 if (framerate == 1) CheckItem(rateMenu,1,true);
109 if (framerate == 3) CheckItem(rateMenu,2,true);
110 if (framerate == 5) CheckItem(rateMenu,3,true);
111 if (framerate == 7) CheckItem(rateMenu,4,true);
112
113 resMenu=GetMenu(kResMenuID);
114 InsertMenu(resMenu, -1);
115 CheckItem(resMenu,(unsigned char)screen_res+1,true);
116
117 DrawMenuBar();
118
119 macLedState[0]=false;
120 macLedState[1]=false;
121 macLedState[2]=false;
122 macLedState[3]=false;
123 macLedState[4]=false;
124
125 quit_program = 0;
126 }
127
gui_update(void)128 int gui_update(void)
129 {
130 return 0;
131 }
132
gui_exit(void)133 void gui_exit(void)
134 {
135 DeleteMenu(kAppleMenuID);
136 DeleteMenu(kFileMenuID);
137 DeleteMenu(kEditMenuID);
138 DeleteMenu(kDrivesMenuID);
139 DeleteMenu(kMemoryMenuID);
140 DeleteMenu(kResMenuID);
141 DeleteMenu(kRateMenuID);
142 DeleteMenu(kVideoMenuID);
143 }
144
gui_prepare_leds(long screenV)145 void gui_prepare_leds(long screenV)
146 {
147 if (screen_res >= 3)
148 { SetRect(&powerRect,70,(short)screenV+1,110,(short)screenV+11);
149 SetRect(&driveDf0Rect,220,(short)screenV+1,260,(short)screenV+11);
150 SetRect(&driveDf1Rect,292,(short)screenV+1,332,(short)screenV+11);
151 SetRect(&driveDf2Rect,365,(short)screenV+1,405,(short)screenV+11);
152 SetRect(&driveDf3Rect,436,(short)screenV+1,476,(short)screenV+11);
153 }
154 else
155 { SetRect(&powerRect,46,(short)screenV+1,76,(short)screenV+11);
156 SetRect(&driveDf0Rect,106,(short)screenV+1,136,(short)screenV+11);
157 SetRect(&driveDf1Rect,166,(short)screenV+1,196,(short)screenV+11);
158 SetRect(&driveDf2Rect,226,(short)screenV+1,256,(short)screenV+11);
159 SetRect(&driveDf3Rect,286,(short)screenV+1,316,(short)screenV+11);
160 }
161 }
162
gui_update_leds(void)163 void gui_update_leds(void)
164 { int i;
165
166 for(i=0;i<=4;i++) gui_led(i,macLedState[i]);
167 }
168
gui_led(int led,int on)169 void gui_led(int led, int on)
170 {
171 macLedState[led]=on;
172 if (dont_want_aspect || screen_res == 2)
173 { if (led == 0)
174 { if (on)
175 { ForeColor(redColor);
176 PaintRect(&powerRect);
177 }
178 else
179 { ForeColor(whiteColor);
180 PaintRect(&powerRect);
181 }
182 }
183 else
184 { switch (led)
185 { case 1:
186 if (on)
187 { ForeColor(greenColor);
188 PaintRect(&driveDf0Rect);
189 }
190 else
191 { ForeColor(whiteColor);
192 PaintRect(&driveDf0Rect);
193 }
194 break;
195
196 case 2:
197 if (on)
198 { ForeColor(greenColor);
199 PaintRect(&driveDf1Rect);
200 }
201 else
202 { ForeColor(whiteColor);
203 PaintRect(&driveDf1Rect);
204 }
205 break;
206
207 case 3:
208 if (on)
209 { ForeColor(greenColor);
210 PaintRect(&driveDf2Rect);
211 }
212 else
213 { ForeColor(whiteColor);
214 PaintRect(&driveDf2Rect);
215 }
216 break;
217
218 case 4:
219 if (on)
220 { ForeColor(greenColor);
221 PaintRect(&driveDf3Rect);
222 }
223 else
224 { ForeColor(whiteColor);
225 PaintRect(&driveDf3Rect);
226 }
227 break;
228 }
229 }
230 ForeColor(blackColor);
231 }
232 }
233
gui_filename(int num,char * name)234 void gui_filename(int num, char *name)
235 {
236 }
237
getline(char * p)238 static void getline(char *p)
239 {
240 }
241
gui_handle_events(void)242 void gui_handle_events(void)
243 {
244 }
245