Subversion Repositories pentevo

Rev

Rev 798 | Details | Compare with Previous | 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"
800 DimkaM 17
#include "fdd.h"
716 lvd 18
#include "z80/tables.h"
19
#include "dbgbpx.h"
20
 
21
#include "util.h"
22
 
796 DimkaM 23
static void cpu_info()
716 lvd 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);
796 DimkaM 55
   printf("%u.%u.%u [MMX:%s,SSE:%s,SSE2:%s,TSCINV:%s] ",
716 lvd 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
 
796 DimkaM 78
static void restrict_version(char legacy)
716 lvd 79
{
796 DimkaM 80
    (void)legacy;
716 lvd 81
//   color(CONSCLR_WARNING);
82
//   printf ("WARNING: Windows 95/98/Me is not fully supported.\n");
83
   temp.win9x=1; //Dexus
84
   color();
85
 
86
/*   static const char vererror[] = "unsupported OS version";
87
 
88
   if (!legacy) errexit(vererror);
89
 
90
   #ifdef MOD_9X
91
   static const char verwarning[] =
92
      "detected windows version is not supported\r\n"
93
      "by current version of UnrealSpeccy and untested.\r\n\r\n"
94
      "you may click 'YES' to continue on your own risk.\r\n"
95
      "in this case you will experience crashes under\r\n"
96
      "some conditions. it's an OS-specific problem, please\r\n"
97
      "don't report it and consider using NT-based system";
98
   if (MessageBox(0, verwarning, vererror, MB_ICONERROR | MB_YESNO | MB_DEFBUTTON2) == IDNO) errexit(vererror);
99
   #endif
100
*/
101
}
102
 
103
void init_all(int argc, char **argv)
104
{
105
//   printf("%s\n", __FUNCTION__);
106
   cpu_info();
107
 
796 DimkaM 108
   char *config = nullptr, legacy = 0;
716 lvd 109
   for (int i = 0; i < argc; i++) {
110
      if (argv[i][0] != '/' && argv[i][0] != '-') continue;
796 DimkaM 111
      if(!stricmp(argv[i] + 1, "i") && i + 1 < argc)
112
      {
113
          config = argv[i + 1];
114
          i++;
115
      }
716 lvd 116
      #ifdef MOD_9X
117
      if (argv[i][1] == '9') legacy = 1;
118
      #endif
119
   }
120
 
121
   temp.Minimized = false;
122
   temp.win9x=0; //Dexus
123
   if (GetVersion() >> 31) restrict_version(legacy);
124
 
125
   init_z80tables();
126
   video_permanent_tables();
127
   init_ie_help();
128
   load_config(config);
129
   //make_samples();
130
   init_leds();
131
   init_tape();
132
   init_hdd_cd();
133
   start_dx();
134
   set_priority();
135
   applyconfig();
136
   main_reset();
137
   autoload();
138
   init_bpx();
139
   temp.PngSupport = PngInit();
140
   if(!temp.PngSupport)
141
   {
142
       color(CONSCLR_WARNING);
143
       printf("warning: libpng12.dll not found or wrong version -> png support disabled\n");
144
       if(conf.scrshot == 2) // ��� ������ ��� ���������� .png
145
       {
146
           conf.scrshot = 1; // ������ �� .bmp (�.�. ����������� libpng)
147
       }
148
   }
149
   temp.ZlibSupport = ZlibInit();
150
   if(!temp.ZlibSupport)
151
   {
152
       color(CONSCLR_WARNING);
153
       printf("warning: zlib1.dll not found or wrong version -> csw 2.0 support disabled\n");
154
   }
155
   temp.LastSnapName[0] = 0;
156
   load_errors = 0;
157
   trd_toload = 0;
158
   *(DWORD*)trd_loaded = 0; // clear loaded flags, don't see autoload'ed images
159
 
160
   for (; argc; argc--, argv++)
161
   {
162
      if (**argv == '-' || **argv == '/')
163
      {
796 DimkaM 164
          if(argc > 1 && !stricmp(argv[0] + 1, "i"))
165
          {
166
              argc--;
167
              argv++;
168
          }
716 lvd 169
         continue;
170
      }
171
 
172
      char fname[0x200], *temp;
173
      GetFullPathName(*argv, sizeof fname, fname, &temp);
174
 
175
      trd_toload = DefaultDrive; // auto-select
796 DimkaM 176
      if(!loadsnap(fname))
177
      {
178
          errmsg("error loading <%s>", *argv);
179
          load_errors = 1;
180
      }
716 lvd 181
   }
182
 
183
   if (load_errors) {
184
      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);
185
      if (code != IDYES) exit();
186
   }
187
 
188
   SetCurrentDirectory(conf.workdir);
189
   if(conf.HighResolutionTimer)
190
       timeBeginPeriod(1);
191
}
192
 
193
void __declspec(noreturn) exit()
194
{
195
//   EnableMenuItem(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_ENABLED);
196
#ifdef _DEBUG
197
   if(!normal_exit)
198
   {
199
       __debugbreak();
200
   }
201
#endif
202
   exitflag = 1;
203
   if (savesndtype)
204
       savesnddialog();  //stop saving sound
205
   if(videosaver_state)
206
       main_savevideo(); //stop saving video
207
 
208
   if(!normal_exit)
209
       done_fdd(false);
210
   done_tape();
211
   done_dx();
212
   done_gs();
213
   done_leds();
214
   save_nv();
215
   modem.close();
216
   done_ie_help();
217
   done_bpx();
218
   PngDone();
219
   ZlibDone();
220
 
221
   if(conf.HighResolutionTimer)
222
       timeEndPeriod(1);
223
   if (ay[1].Chip2203) YM2203Shutdown(ay[1].Chip2203); //Dexus
224
   if (ay[0].Chip2203) YM2203Shutdown(ay[0].Chip2203); //Dexus
225
   color();
226
   printf("\nsee you later!\n");
227
   if (!nowait)
228
   {
229
       SetConsoleTitle("press a key...");
230
       FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
231
       getch();
232
   }
233
   fflush(stdout);
234
   SetConsoleCtrlHandler(ConsoleHandler, FALSE);
235
   exit(0);
236
}