1 #include "sysconfig.h"
2 #include "sysdeps.h"
3 
4 #include "autoconf.h"
5 #include "fsdb.h"
6 #include "options.h"
7 #include "serial.h"
8 #include "sleep.h"
9 #include "uae.h"
10 #include "xwin.h"
11 #include "uae/fs.h"
12 #include "../od-win32/debug_win32.h"
13 
14 #ifndef PICASSO96
15 // just to make ncr_scsi compile. it will not work, of course,
16 // so do not try to use functions in ncr_scsi
17 uaecptr p96ram_start;
18 #endif
19 
20 #ifdef WINDOWS
21 #else
22 // need to fake _timezone because some code from WinUAE depend on it (a
23 // Windows global variable)
24 int _timezone;
25 int _daylight;
26 #endif
27 
28 int pause_emulation = 0;
29 int uaelib_debug = 0;
30 
31 int sleep_resolution = 1000 / 1;
32 int pissoff_value = 15000 * CYCLE_UNIT;
33 
34 //int uaeser_getdatalenght (void) {
35 //    return uaeser_getdatalength();
36 //}
37 
target_default_options(struct uae_prefs * p,int type)38 void target_default_options (struct uae_prefs *p, int type) {
39     //write_log("STUB: target_default_options p=%p type=%d\n", p, type);
40     write_log("target_default_options p=%p type=%d\n", p, type);
41     // FIXME: move out of here - into a (lib)amiga_ function
42     write_log("target_default_options: enabling floppy sounds\n");
43 
44     for (int i = 0; i < 4; i++) {
45         p->floppyslots[i].dfxclick = 1;
46     }
47 
48     if (type == 2 || type == 0) {
49         // if this isn't set to -1, will caused problems for parallel
50         // port joysticks
51         p->win32_samplersoundcard = -1;
52     }
53 
54     p->win32_rtgvblankrate = 0;
55 
56 #ifdef WORDS_BIGENDIAN
57     p->picasso96_modeflags = 0x442;
58 #else
59     p->picasso96_modeflags = 0x212;
60 #endif
61 
62     return;
63 }
64 
65 /**
66  * sleep_millis_main was introduced to custom.cpp in WinUAE 2.4.0b5.
67  * FIXME: what does _main signify here?
68  */
sleep_millis_main(int ms)69 void sleep_millis_main (int ms) {
70     // FIXME: HOW EXACT MUST THE SLEEP BE?
71     //printf("sleep_millis_main %d\n", ms);
72     usleep(ms * 1000);
73     //uae_msleep(ms);
74 }
75 
sleep_millis(int ms)76 void sleep_millis (int ms) {
77     // FIXME: HOW EXACT MUST THE SLEEP BE?
78     //printf("sleep_millis %d\n", ms);
79     // FIXME: check usage of this for CD32
80     usleep(ms * 1000);
81     //uae_msleep(ms);
82 }
83 
console_out_f(const TCHAR * fmt,...)84 void console_out_f(const TCHAR *fmt, ...) {
85     va_list arg_ptr;
86     va_start(arg_ptr, fmt);
87     vprintf(fmt, arg_ptr);
88     va_end(arg_ptr);
89 }
90 
91 /* FIXME: change void *f to FILE* f */
f_out(void * f,const TCHAR * format,...)92 void f_out(void *f, const TCHAR *format, ...)
93 {
94     if (f == NULL) {
95         return;
96     }
97     va_list arg_ptr;
98     va_start(arg_ptr, format);
99     vfprintf((FILE*) f, format, arg_ptr);
100     va_end(arg_ptr);
101 }
102 
console_out(const TCHAR * msg)103 void console_out (const TCHAR *msg) {
104     printf("%s", msg);
105 }
106 
console_get_gui(TCHAR * out,int maxlen)107 int console_get_gui (TCHAR *out, int maxlen) {
108     STUB("");
109     return 0;
110 }
111 
console_get(TCHAR * in,int maxlen)112 int console_get(TCHAR *in, int maxlen) {
113     TCHAR *res = fgets(in, maxlen, stdin);
114     if (res == NULL) {
115         return -1;
116     }
117     int len = strlen(in);
118     return len - 1;
119 }
120 
console_flush(void)121 void console_flush(void) {
122     fflush(stdout);
123 }
124 
console_getch(void)125 TCHAR console_getch (void) {
126     STUB("");
127     return 0;
128 }
129 
close_console(void)130 void close_console (void) {
131     STUB("");
132 }
133 
activate_console(void)134 extern void activate_console (void) {
135     STUB("");
136 }
137 
console_isch(void)138 bool console_isch (void)
139 {
140     STUB("");
141     return false;
142 }
143 
144 /*
145 struct uae_filter usedfilter_storage
146 struct uae_filter *usedfilter = &usedfilter_storage;
147 */
148 
149 //struct uae_prefs currprefs;
150 /*
151 uae_u8 *mapped_malloc (size_t s, TCHAR *file)
152 {
153     return xmalloc (uae_u8, s);
154 }
155 
156 void mapped_free (uae_u8 *p)
157 {
158     xfree (p);
159 }
160 */
161 
162 //#include "fsdb.h"
163 // FIXME: to fsdb_unix.cpp
164 
my_setcurrentdir(const TCHAR * curdir,TCHAR * oldcur)165 int my_setcurrentdir (const TCHAR *curdir, TCHAR *oldcur) {
166     STUB("curdir=\"%s\" oldcur=\"%s\"", curdir, oldcur);
167     return 0;
168 }
169 
my_isfilehidden(const TCHAR * path)170 bool my_isfilehidden (const TCHAR *path) {
171     STUB("path=\"%s\"", path);
172     return 0;
173 }
174 
my_setfilehidden(const TCHAR * path,bool hidden)175 void my_setfilehidden (const TCHAR *path, bool hidden) {
176     STUB("path=\"%s\" hidden=%d", path, hidden);
177 }
178 
target_get_volume_name(struct uaedev_mount_info * mtinf,const TCHAR * volumepath,TCHAR * volumename,int size,bool inserted,bool fullcheck)179 int target_get_volume_name (struct uaedev_mount_info *mtinf,
180         const TCHAR *volumepath, TCHAR *volumename, int size, bool inserted,
181         bool fullcheck) {
182     STUB("");
183     return 0;
184 }
185 
186 static char *console_buffer;
187 static int console_buffer_size;
188 
setconsolemode(char * buffer,int maxlen)189 char *setconsolemode (char *buffer, int maxlen) {
190     char *ret = NULL;
191     if (buffer) {
192         console_buffer = buffer;
193         console_buffer_size = maxlen;
194     }
195     else {
196         ret = console_buffer;
197         console_buffer = NULL;
198     }
199     return ret;
200 }
201 
202 // writelog
buf_out(TCHAR * buffer,int * bufsize,const TCHAR * format,...)203 TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...) {
204     if (buffer == NULL) {
205         return 0;
206     }
207     va_list parms;
208     va_start (parms, format);
209     vsnprintf (buffer, (*bufsize) - 1, format, parms);
210     va_end (parms);
211     *bufsize -= _tcslen (buffer);
212     return buffer + _tcslen (buffer);
213 }
214 
to_lower(TCHAR * s,int len)215 void to_lower (TCHAR *s, int len) {
216     for (int i = 0; i < len; i++) {
217         s[i] = tolower(s[i]);
218     }
219 }
220 
to_upper(TCHAR * s,int len)221 void to_upper (TCHAR *s, int len) {
222     for (int i = 0; i < len; i++) {
223         s[i] = toupper(s[i]);
224     }
225 }
226 
target_expand_environment(const TCHAR * path)227 TCHAR *target_expand_environment (const TCHAR *path) {
228     // FIXME:
229     return strdup(path);
230 }
231 
232 #if 0
233 #include <signal.h>
234 #include "debug.h"
235 #ifdef __cplusplus_disabled
236 static RETSIGTYPE sigbrkhandler(...)
237 #else
238 static RETSIGTYPE sigbrkhandler (int foo)
239 #endif
240 {
241 #ifdef DEBUGGER
242     activate_debugger ();
243 #endif
244 
245 #if !defined(__unix) || defined(__NeXT__)
246     signal (SIGINT, sigbrkhandler);
247 #endif
248 }
249 #endif
250 
setup_brkhandler(void)251 void setup_brkhandler (void)
252 {
253     /*
254 #if defined(__unix) && !defined(__NeXT__)
255     struct sigaction sa;
256     sa.sa_handler = sigbrkhandler;
257     sa.sa_flags = 0;
258 #ifdef SA_RESTART
259     sa.sa_flags = SA_RESTART;
260 #endif
261     sigemptyset (&sa.sa_mask);
262     sigaction (SIGINT, &sa, NULL);
263 #else
264     signal (SIGINT, sigbrkhandler);
265 #endif
266     */
267 }
268 
sleep_cpu_wakeup(void)269 void sleep_cpu_wakeup(void)
270 {
271     UAE_LOG_STUB_MAX(10, "");
272 }
273