Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
716 lvd 1
#include "std.h"
2
 
3
#include "emul.h"
4
#include "vars.h"
5
#include "config.h"
6
#include "dx.h"
7
#include "draw.h"
8
#include "iehelp.h"
9
#include "gs.h"
10
#include "leds.h"
11
#include "tape.h"
12
#include "emulkeys.h"
13
#include "sshot_png.h"
14
#include "init.h"
15
#include "snapshot.h"
16
#include "savesnd.h"
17
#include "wd93dat.h"
18
#include "z80/tables.h"
19
#include "dbgbpx.h"
20
 
21
#include "util.h"
22
 
23
void cpu_info()
24
{
25
   char idstr[64];
26
   idstr[0] = 0;
27
 
28
   fillCpuString(idstr);
29
 
30
   trim(idstr);
31
 
32
   unsigned cpuver = cpuid(1,0);
33
   unsigned features = cpuid(1,1);
34
   temp.mmx = (features >> 23) & 1;
35
   temp.sse = (features >> 25) & 1;
36
   temp.sse2 = (features >> 26) & 1;
37
 
38
   unsigned features_apm = 0;
39
   bool features_apm_supported = false;
40
   unsigned max_ext_id = cpuid(0x80000000, 0);
41
   if(max_ext_id >= 0x80000007)
42
   {
43
       features_apm_supported = true;
44
       features_apm = cpuid(0x80000007,1);
45
   }
46
 
47
   temp.cpufq = GetCPUFrequency();
48
 
49
   color(CONSCLR_HARDITEM); printf("cpu: ");
50
 
51
   color(CONSCLR_HARDINFO);
52
   printf("%s ", idstr);
53
 
54
   color(CONSCLR_HARDITEM);
55
   printf("%d.%d.%d [MMX:%s,SSE:%s,SSE2:%s,TSCINV:%s] ",
56
      (cpuver>>8) & 0x0F, (cpuver>>4) & 0x0F, cpuver & 0x0F,
57
      temp.mmx ? "YES" : "NO",
58
      temp.sse ? "YES" : "NO",
59
      temp.sse2 ? "YES" : "NO",
60
      features_apm_supported ? ((features_apm & (1 << 8)) ? "YES" : "NO") : "UNK");
61
 
62
   color(CONSCLR_HARDINFO);
63
   printf("TSC at %u MHz\n", unsigned(temp.cpufq/1000000U));
64
 
65
#ifdef MOD_SSE2
66
   if (!temp.sse2) {
67
      color(CONSCLR_WARNING);
68
      printf("warning: this is an SSE2 build, recompile or download non-P4 version\n");
69
   }
70
#else //MOD_SSE2
71
   if (temp.sse2) {
72
      color(CONSCLR_WARNING);
73
      printf("warning: SSE2 disabled in compile-time, recompile or download P4 version\n");
74
   }
75
#endif
76
}
77
 
78
void restrict_version(char legacy)
79
{
80
//   color(CONSCLR_WARNING);
81
//   printf ("WARNING: Windows 95/98/Me is not fully supported.\n");
82
   temp.win9x=1; //Dexus
83
   color();
84
 
85
/*   static const char vererror[] = "unsupported OS version";
86
 
87
   if (!legacy) errexit(vererror);
88
 
89
   #ifdef MOD_9X
90
   static const char verwarning[] =
91
      "detected windows version is not supported\r\n"
92
      "by current version of UnrealSpeccy and untested.\r\n\r\n"
93
      "you may click 'YES' to continue on your own risk.\r\n"
94
      "in this case you will experience crashes under\r\n"
95
      "some conditions. it's an OS-specific problem, please\r\n"
96
      "don't report it and consider using NT-based system";
97
   if (MessageBox(0, verwarning, vererror, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON2) == IDNO) errexit(vererror);
98
   #endif
99
*/
100
}
101
 
102
void init_all(int argc, char **argv)
103
{
104
//   printf("%s\n", __FUNCTION__);
105
   cpu_info();
106
 
107
   char *config = 0, legacy = 0;
108
   for (int i = 0; i < argc; i++) {
109
      if (argv[i][0] != '/' && argv[i][0] != '-') continue;
110
      if (!stricmp(argv[i]+1, "i") && i+1 < argc)
111
         config = argv[i+1], i++;
112
      #ifdef MOD_9X
113
      if (argv[i][1] == '9') legacy = 1;
114
      #endif
115
   }
116
 
117
   temp.Minimized = false;
118
   temp.win9x=0; //Dexus
119
   if (GetVersion() >> 31) restrict_version(legacy);
120
 
121
   init_z80tables();
122
   video_permanent_tables();
123
   init_ie_help();
124
   load_config(config);
125
   //make_samples();
126
   #ifdef MOD_GS
127
   init_gs();
128
   #endif
129
   init_leds();
130
   init_tape();
131
   init_hdd_cd();
132
   start_dx();
133
   set_priority();
134
   applyconfig();
135
   main_reset();
136
   autoload();
137
   init_bpx();
138
   temp.PngSupport = PngInit();
139
   if(!temp.PngSupport)
140
   {
141
       color(CONSCLR_WARNING);
142
       printf("warning: libpng12.dll not found or wrong version -> png support disabled\n");
143
       if(conf.scrshot == 2) // Был выбран тип скриншотов .png
144
       {
145
           conf.scrshot = 1; // Замена на .bmp (т.к. отсутствует libpng)
146
       }
147
   }
148
   temp.ZlibSupport = ZlibInit();
149
   if(!temp.ZlibSupport)
150
   {
151
       color(CONSCLR_WARNING);
152
       printf("warning: zlib1.dll not found or wrong version -> csw 2.0 support disabled\n");
153
   }
154
   temp.LastSnapName[0] = 0;
155
   load_errors = 0;
156
   trd_toload = 0;
157
   *(DWORD*)trd_loaded = 0; // clear loaded flags, don't see autoload'ed images
158
 
159
   for (; argc; argc--, argv++)
160
   {
161
      if (**argv == '-' || **argv == '/')
162
      {
163
         if (argc > 1 && !stricmp(argv[0]+1, "i")) argc--, argv++;
164
         continue;
165
      }
166
 
167
      char fname[0x200], *temp;
168
      GetFullPathName(*argv, sizeof fname, fname, &temp);
169
 
170
      trd_toload = DefaultDrive; // auto-select
171
      if (!loadsnap(fname)) errmsg("error loading <%s>", *argv), load_errors = 1;
172
   }
173
 
174
   if (load_errors) {
175
      int code = MessageBox(wnd, "Some files, specified in\r\ncommand line, failed to load\r\n\r\nContinue emulation?", "File loading error", MB_YESNO | MB_ICONWARNING);
176
      if (code != IDYES) exit();
177
   }
178
 
179
   SetCurrentDirectory(conf.workdir);
180
   if(conf.HighResolutionTimer)
181
       timeBeginPeriod(1);
182
}
183
 
184
void __declspec(noreturn) exit()
185
{
186
//   EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_ENABLED);
187
#ifdef _DEBUG
188
   if(!normal_exit)
189
   {
190
       __debugbreak();
191
   }
192
#endif
193
   exitflag = 1;
194
   if (savesndtype)
195
       savesnddialog();  //stop saving sound
196
   if(videosaver_state)
197
       main_savevideo(); //stop saving video
198
 
199
   if(!normal_exit)
200
       done_fdd(false);
201
   done_tape();
202
   done_dx();
203
   done_gs();
204
   done_leds();
205
   save_nv();
206
   modem.close();
207
   done_ie_help();
208
   done_bpx();
209
   PngDone();
210
   ZlibDone();
211
 
212
   if(conf.HighResolutionTimer)
213
       timeEndPeriod(1);
214
   if (ay[1].Chip2203) YM2203Shutdown(ay[1].Chip2203); //Dexus
215
   if (ay[0].Chip2203) YM2203Shutdown(ay[0].Chip2203); //Dexus
216
   color();
217
   printf("\nsee you later!\n");
218
   if (!nowait)
219
   {
220
       SetConsoleTitle("press a key...");
221
       FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
222
       getch();
223
   }
224
   fflush(stdout);
225
   SetConsoleCtrlHandler(ConsoleHandler, FALSE);
226
   exit(0);
227
}