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 "sysconfig.h"
10 #include "sysdeps.h"
11
12 #include "options.h"
13 #include "gui.h"
14 #include "retroglue.h"
15
gui_disk_image_change(int unitnum,const TCHAR * name,bool writeprotected)16 void gui_disk_image_change (int unitnum, const TCHAR *name, bool writeprotected) {}
17
gui_open(void)18 int gui_open (void)
19 {
20 return 1;
21 }
22
gui_notify_state(int state)23 void gui_notify_state (int state)
24 {
25 }
26
gui_update(void)27 int gui_update (void)
28 {
29 return 0;
30 }
31
gui_exit(void)32 void gui_exit (void)
33 {
34 }
gui_fps(int fps,int idle,int color)35 void gui_fps (int fps, int idle, int color)
36 {
37 gui_data.fps = fps;
38 gui_data.idle = idle;
39 gui_data.fps_color = color;
40 }
41
gui_led(int led,int on)42 void gui_led (int led, int on)
43 {
44 }
45
gui_hd_led(int led)46 void gui_hd_led (int led)
47 {
48 /*
49 static int resetcounter;
50
51 int old = gui_data.hd;
52
53 if (led == 0) {
54 resetcounter--;
55 if (resetcounter > 0)
56 return;
57 }
58
59 gui_data.hd = led;
60 resetcounter = 6;
61 if (old != gui_data.hd)
62 gui_led (5, gui_data.hd);
63 */
64 }
65
gui_cd_led(int led)66 void gui_cd_led (int led)
67 {
68 /*
69 static int resetcounter;
70
71 int old = gui_data.cd;
72 if (led == 0) {
73 resetcounter--;
74 if (resetcounter > 0)
75 return;
76 }
77
78 gui_data.cd = led;
79 resetcounter = 6;
80 if (old != gui_data.cd)
81 gui_led (6, gui_data.cd);
82 */
83 }
84
gui_flicker_led2(int led,int unitnum,int status)85 static void gui_flicker_led2 (int led, int unitnum, int status)
86 {
87 static int resetcounter[LED_MAX];
88 uae_s8 old;
89 uae_s8 *p;
90
91 if (led == LED_HD)
92 p = &gui_data.hd;
93 else if (led == LED_CD)
94 p = &gui_data.cd;
95 else if (led == LED_MD)
96 p = &gui_data.md;
97 else if (led == LED_NET)
98 p = &gui_data.net;
99 else
100 return;
101 old = *p;
102 if (status < 0) {
103 if (old < 0) {
104 gui_led (led, -1);
105 } else {
106 gui_led (led, 0);
107 }
108 return;
109 }
110 if (status == 0 && old < 0) {
111 *p = 0;
112 resetcounter[led] = 0;
113 gui_led (led, 0);
114 return;
115 }
116 if (status == 0) {
117 resetcounter[led]--;
118 if (resetcounter[led] > 0)
119 return;
120 }
121 #ifdef RETROPLATFORM
122 if (unitnum >= 0) {
123 if (led == LED_HD) {
124 rp_hd_activity(unitnum, status ? 1 : 0, status == 2 ? 1 : 0);
125 } else if (led == LED_CD) {
126 rp_cd_activity(unitnum, status);
127 }
128 }
129 #endif
130 *p = status;
131 resetcounter[led] = 4;
132 if (old != *p)
133 gui_led (led, *p);
134 }
135
gui_flicker_led(int led,int unitnum,int status)136 void gui_flicker_led (int led, int unitnum, int status)
137 {
138 if (led < 0) {
139 if (gui_data.hd >= 0)
140 gui_flicker_led2(LED_HD, 0, 0);
141 if (gui_data.cd >= 0)
142 gui_flicker_led2(LED_CD, 0, 0);
143 if (gui_data.net >= 0)
144 gui_flicker_led2(LED_NET, 0, 0);
145 if (gui_data.md >= 0)
146 gui_flicker_led2(LED_MD, 0, 0);
147 } else {
148 gui_flicker_led2(led, unitnum, status);
149 }
150 }
151
gui_filename(int num,const char * name)152 void gui_filename (int num, const char *name)
153 {
154 }
155
gui_handle_events(void)156 void gui_handle_events (void)
157 {
158 }
159
gui_display(int shortcut)160 void gui_display(int shortcut)
161 {
162 }
163
gui_message(const char * format,...)164 void gui_message (const char *format,...)
165 {
166 static char msg[2048];
167 va_list parms;
168
169 va_start (parms,format);
170 vsprintf ( msg, format, parms);
171 va_end (parms);
172 }
173
174
175 static int guijoybutton[MAX_JPORTS];
176 static int guijoyaxis[MAX_JPORTS][4];
177 static bool guijoychange;
178
gui_gameport_button_change(int port,int button,int onoff)179 void gui_gameport_button_change (int port, int button, int onoff)
180 {
181 //write_log ("%d %d %d\n", port, button, onoff);
182 #ifdef RETROPLATFORM
183 int mask = 0;
184 if (button == JOYBUTTON_CD32_PLAY)
185 mask = RP_JOYSTICK_BUTTON5;
186 if (button == JOYBUTTON_CD32_RWD)
187 mask = RP_JOYSTICK_BUTTON6;
188 if (button == JOYBUTTON_CD32_FFW)
189 mask = RP_JOYSTICK_BUTTON7;
190 if (button == JOYBUTTON_CD32_GREEN)
191 mask = RP_JOYSTICK_BUTTON4;
192 if (button == JOYBUTTON_3 || button == JOYBUTTON_CD32_YELLOW)
193 mask = RP_JOYSTICK_BUTTON3;
194 if (button == JOYBUTTON_1 || button == JOYBUTTON_CD32_RED)
195 mask = RP_JOYSTICK_BUTTON1;
196 if (button == JOYBUTTON_2 || button == JOYBUTTON_CD32_BLUE)
197 mask = RP_JOYSTICK_BUTTON2;
198 rp_update_gameport (port, mask, onoff);
199 #endif
200 if (onoff)
201 guijoybutton[port] |= 1 << button;
202 else
203 guijoybutton[port] &= ~(1 << button);
204 guijoychange = true;
205 }
206
gui_gameport_axis_change(int port,int axis,int state,int max)207 void gui_gameport_axis_change (int port, int axis, int state, int max)
208 {
209 int onoff = state ? 100 : 0;
210 if (axis < 0 || axis > 3)
211 return;
212 if (max < 0) {
213 if (guijoyaxis[port][axis] == 0)
214 return;
215 if (guijoyaxis[port][axis] > 0)
216 guijoyaxis[port][axis]--;
217 } else {
218 if (state > max)
219 state = max;
220 if (state < 0)
221 state = 0;
222 guijoyaxis[port][axis] = max ? state * 127 / max : onoff;
223 #ifdef RETROPLATFORM
224 if (axis == DIR_LEFT_BIT)
225 rp_update_gameport (port, RP_JOYSTICK_LEFT, onoff);
226 if (axis == DIR_RIGHT_BIT)
227 rp_update_gameport (port, DIR_RIGHT_BIT, onoff);
228 if (axis == DIR_UP_BIT)
229 rp_update_gameport (port, DIR_UP_BIT, onoff);
230 if (axis == DIR_DOWN_BIT)
231 rp_update_gameport (port, DIR_DOWN_BIT, onoff);
232 #endif
233 }
234 guijoychange = true;
235 }
236
237
238