• R/O
  • SSH
  • HTTPS

oswan: Commit


Commit MetaInfo

Revision88 (tree)
Time2010-05-12 15:14:01
Authorbird_may_nike

Log Message

(empty log message)

Change Summary

Incremental Difference

--- oswanj/trunk/src/WSMain.cpp (revision 87)
+++ oswanj/trunk/src/WSMain.cpp (revision 88)
@@ -37,13 +37,13 @@
3737 {
3838 return FALSE;
3939 }
40- hInst = hCurInst;
40+ hInst = hCurInst;
4141 accel = LoadAccelerators(hCurInst, MAKEINTRESOURCE(IDR_ACCELERATOR1));
4242 WsSetDir();
4343 WsLoadIEep();
4444 ConfigCreate();
4545 apuInit();
46- apuLoadSound();
46+ apuLoadSound();
4747 drawInitialize(FALSE);
4848 drawCreate();
4949 SetDrawSize(DS_2);
@@ -57,10 +57,10 @@
5757 {
5858 break;
5959 }
60- if (!TranslateAccelerator(hWnd, accel, &msg)) {
61- TranslateMessage(&msg);
62- DispatchMessage(&msg);
63- }
60+ if (!TranslateAccelerator(hWnd, accel, &msg)) {
61+ TranslateMessage(&msg);
62+ DispatchMessage(&msg);
63+ }
6464 }
6565 if (Run)
6666 {
@@ -141,17 +141,17 @@
141141 WsCreate(NULL);
142142 return 0L;
143143 case ID_STATE_SAVE_0:
144- WsSaveState(0);
145- return 0L;
144+ WsSaveState(0);
145+ return 0L;
146146 case ID_STATE_LOAD_0:
147- WsLoadState(0);
148- return 0L;
147+ WsLoadState(0);
148+ return 0L;
149149 case ID_PAUSE:
150- WsPause();
151- return 0L;
150+ WsPause();
151+ return 0L;
152152 case ID_RESET:
153- WsReset();
154- return 0L;
153+ WsReset();
154+ return 0L;
155155 case ID_SIZE_1:
156156 menu = GetMenu(hWnd);
157157 CheckMenuItem(menu, ID_SIZE_1, MF_CHECKED);
@@ -202,21 +202,21 @@
202202 return 0L;
203203 case ID_KERORIKAN:
204204 menu = GetMenu(hWnd);
205- if (Kerorikan)
206- {
207- Kerorikan = 0;
205+ if (Kerorikan)
206+ {
207+ Kerorikan = 0;
208208 CheckMenuItem(menu, LOWORD(wp), MF_UNCHECKED);
209- WsResize();
210- drawDraw();
211- }
212- else
213- {
214- Kerorikan = 1;
209+ WsResize();
210+ drawDraw();
211+ }
212+ else
213+ {
214+ Kerorikan = 1;
215215 CheckMenuItem(menu, LOWORD(wp), MF_CHECKED);
216- WsResize();
217- drawDraw();
218- }
219- return 0L;
216+ WsResize();
217+ drawDraw();
218+ }
219+ return 0L;
220220 case ID_SOUND_1:
221221 case ID_SOUND_2:
222222 case ID_SOUND_3:
@@ -250,13 +250,13 @@
250250 }
251251 return 0L;
252252 case ID_CONF_INPUT:
253- WsInputRelease();
254- DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_CONFIG), hWnd, (DLGPROC)ConfProc);
255- WsInputInit(hWnd);
256- return 0L;
257- case ID_ABOUT:
258- DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_ABOUT), hWnd, (DLGPROC)AboutProc);
259- break;
253+ WsInputRelease();
254+ DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_CONFIG), hWnd, (DLGPROC)ConfProc);
255+ WsInputInit(hWnd);
256+ return 0L;
257+ case ID_ABOUT:
258+ DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_ABOUT), hWnd, (DLGPROC)AboutProc);
259+ break;
260260 }
261261 break;
262262 case WM_PAINT:
@@ -274,54 +274,54 @@
274274 //Aboutダイアログプロシージャ
275275 LRESULT CALLBACK AboutProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
276276 {
277- HDC hDC;
278- HFONT hFont;
277+ HDC hDC;
278+ HFONT hFont;
279279
280- switch (msg)
281- {
280+ switch (msg)
281+ {
282282 case WM_INITDIALOG:
283- SetWindowText(GetDlgItem(hDlgWnd, IDC_TEXT_VERSION), TEXT("バージョン 0.1"));
283+ SetWindowText(GetDlgItem(hDlgWnd, IDC_TEXT_VERSION), TEXT("バージョン 0.1"));
284284 break;
285- case WM_CTLCOLORSTATIC:
286- if((HWND)lp == GetDlgItem(hDlgWnd, IDC_TEXT_VERSION))
287- {
288- hDC = (HDC)wp;
289- hFont = CreateFont(
290- 18, /* フォント高さ */
291- 0, /* 文字幅 */
292- 0, /* テキストの角度 */
293- 0, /* ベースラインとx軸との角度 */
294- FW_BOLD, /* フォントの重さ(太さ) */
295- FALSE, /* イタリック体 */
296- FALSE, /* アンダーライン */
297- FALSE, /* 打ち消し線 */
298- SHIFTJIS_CHARSET, /* 文字セット */
299- OUT_DEFAULT_PRECIS, /* 出力精度 */
300- CLIP_DEFAULT_PRECIS, /* クリッピング精度 */
301- PROOF_QUALITY, /* 出力品質 */
302- FIXED_PITCH | FF_MODERN, /* ピッチとファミリー */
303- (LPCTSTR)"MS Pゴシック" /* 書体名 */
304- );
305- SelectObject(hDC, hFont);
306- SetTextColor(hDC, RGB(0, 0, 255));
307- SetBkMode(hDC, TRANSPARENT);
308- return (BOOL)(HBRUSH)GetStockObject(NULL_BRUSH);
309- }
310- return DefWindowProc(hDlgWnd, msg, wp, lp);
311- case WM_COMMAND:
312- if(HIWORD(wp) == BN_CLICKED)
313- {
314- switch (LOWORD(wp))
315- {
316- case IDOK:
317- case IDCANCEL:
318- EndDialog(hDlgWnd, LOWORD(wp));
319- return 1;
320- }
321- }
322- break;
323- }
324- return 0;
285+ case WM_CTLCOLORSTATIC:
286+ if((HWND)lp == GetDlgItem(hDlgWnd, IDC_TEXT_VERSION))
287+ {
288+ hDC = (HDC)wp;
289+ hFont = CreateFont(
290+ 18, /* フォント高さ */
291+ 0, /* 文字幅 */
292+ 0, /* テキストの角度 */
293+ 0, /* ベースラインとx軸との角度 */
294+ FW_BOLD, /* フォントの重さ(太さ) */
295+ FALSE, /* イタリック体 */
296+ FALSE, /* アンダーライン */
297+ FALSE, /* 打ち消し線 */
298+ SHIFTJIS_CHARSET, /* 文字セット */
299+ OUT_DEFAULT_PRECIS, /* 出力精度 */
300+ CLIP_DEFAULT_PRECIS, /* クリッピング精度 */
301+ PROOF_QUALITY, /* 出力品質 */
302+ FIXED_PITCH | FF_MODERN, /* ピッチとファミリー */
303+ (LPCTSTR)"MS Pゴシック" /* 書体名 */
304+ );
305+ SelectObject(hDC, hFont);
306+ SetTextColor(hDC, RGB(0, 0, 255));
307+ SetBkMode(hDC, TRANSPARENT);
308+ return (BOOL)(HBRUSH)GetStockObject(NULL_BRUSH);
309+ }
310+ return DefWindowProc(hDlgWnd, msg, wp, lp);
311+ case WM_COMMAND:
312+ if(HIWORD(wp) == BN_CLICKED)
313+ {
314+ switch (LOWORD(wp))
315+ {
316+ case IDOK:
317+ case IDCANCEL:
318+ EndDialog(hDlgWnd, LOWORD(wp));
319+ return 1;
320+ }
321+ }
322+ break;
323+ }
324+ return 0;
325325 }
326326
327327 wchar_t* OpenWSFile(wchar_t* path, DWORD max)
@@ -349,20 +349,20 @@
349349
350350 void WsPause(void)
351351 {
352- static int pause = 0;
353- HMENU menu = GetMenu(hWnd);
352+ static int pause = 0;
353+ HMENU menu = GetMenu(hWnd);
354354
355- if (Run)
356- {
357- pause = 1;
358- Run = 0;
359- CheckMenuItem(menu, ID_PAUSE, MF_CHECKED);
360- apuWaveClear();
361- }
362- else if (pause)
363- {
364- Run = 1;
365- pause = 0;
366- CheckMenuItem(menu, ID_PAUSE, MF_UNCHECKED);
367- }
355+ if (Run)
356+ {
357+ pause = 1;
358+ Run = 0;
359+ CheckMenuItem(menu, ID_PAUSE, MF_CHECKED);
360+ apuWaveClear();
361+ }
362+ else if (pause)
363+ {
364+ Run = 1;
365+ pause = 0;
366+ CheckMenuItem(menu, ID_PAUSE, MF_UNCHECKED);
367+ }
368368 }
--- oswanj/trunk/src/WSApu.cpp (revision 87)
+++ oswanj/trunk/src/WSApu.cpp (revision 88)
@@ -47,7 +47,7 @@
4747 case WOM_DONE:
4848 rBuf++;
4949 if (rBuf >= BUFCOUNT)
50- {
50+ {
5151 rBuf = 0;
5252 }
5353 break;
@@ -75,12 +75,12 @@
7575 wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nBlockAlign;
7676 result = waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfe, (DWORD_PTR)apuWaveOutProc, NULL, CALLBACK_FUNCTION);
7777 if (result != MMSYSERR_NOERROR )
78- {
78+ {
7979 waveOutGetErrorText(result, msg, sizeof(msg));
8080 ErrorMsg(ERR_WAVEOUT_OPEN);
8181 }
8282 for (i = 0; i < BUFCOUNT; i++)
83- {
83+ {
8484 whdr[i] = (WAVEHDR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WAVEHDR));
8585 whdr[i]->lpData = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, BUFSIZEW * 4);
8686 whdr[i]->dwBufferLength = BUFSIZEW * 4;
@@ -88,7 +88,7 @@
8888 whdr[i]->dwLoops = 0;
8989 result = waveOutPrepareHeader(hWaveOut, whdr[i], sizeof(WAVEHDR));
9090 if (result != MMSYSERR_NOERROR )
91- {
91+ {
9292 waveOutGetErrorText(result, msg, sizeof(msg));
9393 ErrorMsg(ERR_WAVEOUT_PREPAREHEADER);
9494 }
@@ -98,13 +98,13 @@
9898
9999 void apuWaveRelease(void)
100100 {
101- int i;
101+ int i;
102102
103103 waveOutReset(hWaveOut);
104104 for(i = 0; i < BUFCOUNT; i++)
105- {
105+ {
106106 if (whdr[i])
107- {
107+ {
108108 waveOutUnprepareHeader(hWaveOut,whdr[i],sizeof(WAVEHDR));
109109 HeapFree(GetProcessHeap(),0,whdr[i]->lpData);
110110 HeapFree(GetProcessHeap(),0,whdr[i]);
@@ -121,7 +121,7 @@
121121
122122 waveOutReset(hWaveOut);
123123 for (i = 0; i < BUFCOUNT; i++)
124- {
124+ {
125125 ZeroMemory(whdr[i]->lpData, BUFSIZEW * 4);
126126 }
127127 rBuf = 0;
@@ -134,22 +134,22 @@
134134 int i, j;
135135
136136 for (i = 0; i < 4; i++)
137- {
137+ {
138138 for (j = 0; j < 32; j++)
139- {
139+ {
140140 PData[i][j] = 8;
141141 }
142142 }
143143 for (i = 0; i < 8; i++)
144- {
144+ {
145145 for (j = 0; j < BUFSIZEN; j++)
146- {
146+ {
147147 PDataN[i][j] = ((apuMrand(15 - i) & 1) ? 15 : 0);
148148 }
149149 }
150150
151151 for (i = 0; i < BUFSIZEN; i++)
152- {
152+ {
153153 RandData[i] = apuMrand(15);
154154 }
155155 apuWaveCreate();
@@ -159,7 +159,7 @@
159159 void apuEnd(void)
160160 {
161161 apuWaveRelease();
162- apuDestroySound();
162+ apuDestroySound();
163163 }
164164
165165 unsigned int apuMrand(unsigned int Degree)
@@ -166,7 +166,7 @@
166166 {
167167 #define BIT(n) (1<<n)
168168 typedef struct
169- {
169+ {
170170 unsigned int N;
171171 int InputBit;
172172 int Mask;
@@ -196,37 +196,37 @@
196196 int Masked;
197197
198198 if(pTbl->N != Degree)
199- {
199+ {
200200 pTbl = TblMask;
201201 while(pTbl->N) {
202202 if(pTbl->N == Degree)
203- {
203+ {
204204 break;
205205 }
206206 pTbl++;
207207 }
208208 if(!pTbl->N)
209- {
209+ {
210210 pTbl--;
211211 }
212212 ShiftReg &= pTbl->InputBit-1;
213213 if(!ShiftReg)
214- {
214+ {
215215 ShiftReg = pTbl->InputBit-1;
216216 }
217217 }
218218 Masked = ShiftReg & pTbl->Mask;
219219 while(Masked)
220- {
220+ {
221221 XorReg ^= Masked & 0x01;
222222 Masked >>= 1;
223223 }
224224 if(XorReg)
225- {
225+ {
226226 ShiftReg |= pTbl->InputBit;
227227 }
228228 else
229- {
229+ {
230230 ShiftReg &= ~pTbl->InputBit;
231231 }
232232 ShiftReg >>= 1;
@@ -255,15 +255,15 @@
255255 b++;
256256 }
257257 if (v < 0x80)
258- {
258+ {
259259 v += 0x80;
260260 }
261261 else
262- {
262+ {
263263 v -= 0x80;
264264 }
265265 if (SDMACNT <= index)
266- {
266+ {
267267 index = 0;
268268 b = 0;
269269 }
@@ -276,7 +276,7 @@
276276 b++;
277277 }
278278 if (SDMACNT <= index)
279- {
279+ {
280280 SDMACTL &= 0x7F; // DMA end
281281 SDMACNT = 0;
282282 index = 0;
@@ -289,9 +289,9 @@
289289 void apuSweep(void)
290290 {
291291 if ((Swp.step) && Swp.on) // sweep on
292- {
292+ {
293293 if (Swp.cnt < 0)
294- {
294+ {
295295 Swp.cnt = Swp.time;
296296 Ch[2].freq += Swp.step;
297297 Ch[2].freq &= 0x7ff;
@@ -305,7 +305,7 @@
305305 static int nPos = 0;
306306 // Noise counter
307307 if (++nPos >= BUFSIZEN)
308- {
308+ {
309309 nPos = 0;
310310 }
311311 return RandData[nPos];
@@ -321,47 +321,47 @@
321321 static int wait = 0;
322322 short *dataAdr;
323323
324- if (WsInputGetNowait())
325- {
326- wait = 1;
327- }
328- else if (wait)
329- {
330- wait = 0;
331- apuWaveClear();
332- }
324+ if (WsInputGetNowait())
325+ {
326+ wait = 1;
327+ }
328+ else if (wait)
329+ {
330+ wait = 0;
331+ apuWaveClear();
332+ }
333333 apuSweep();
334334 for (channel = 0; channel < 4; channel++)
335- {
335+ {
336336 lVol[channel] = 0;
337337 rVol[channel] = 0;
338338 if (Ch[channel].on)
339- {
339+ {
340340 if (channel == 1 && VoiceOn && Sound[4])
341- {
341+ {
342342 continue;
343343 }
344344 else if (channel == 2 && Swp.on && !Sound[5])
345- {
345+ {
346346 continue;
347347 }
348348 else if (channel == 3 && Noise.on && Sound[6])
349- {
349+ {
350350 index = (3072000 / BPSWAV) * point[3] / (2048 - Ch[3].freq);
351351 if ((index %= BUFSIZEN) == 0 && preindex[3])
352- {
352+ {
353353 point[3] = 0;
354354 }
355355 value = (short)PDataN[Noise.pattern][index] - 8;
356356 }
357357 else if (Sound[channel] == 0)
358- {
358+ {
359359 continue;
360360 }
361361 else {
362362 index = (3072000 / BPSWAV) * point[channel] / (2048 - Ch[channel].freq);
363363 if ((index %= 32) == 0 && preindex[channel])
364- {
364+ {
365365 point[channel] = 0;
366366 }
367367 value = (short)PData[channel][index] - 8;
@@ -380,20 +380,20 @@
380380 dataAdr[wPos * 2] = LL;
381381 dataAdr[wPos * 2 + 1] = RR;
382382 if (++wPos >= BUFSIZEW)
383- {
383+ {
384384 waveOutWrite(hWaveOut, whdr[wBuf], sizeof(WAVEHDR));
385385 wPos = 0;
386386 if (++wBuf >= BUFCOUNT)
387- {
387+ {
388388 wBuf = 0;
389389 }
390- if (wait == 0)
391- {
392- while (wBuf == rBuf) // 書き込みが再生に追いついた
393- {
394- Sleep(1); // WaveOutのコールバック関数でrBufが更新されるまで待つ
395- }
396- }
390+ if (wait == 0)
391+ {
392+ while (wBuf == rBuf) // 書き込みが再生に追いついた
393+ {
394+ Sleep(1); // WaveOutのコールバック関数でrBufが更新されるまで待つ
395+ }
396+ }
397397 }
398398 }
399399
@@ -403,86 +403,86 @@
403403
404404 void apuLoadSound(void)
405405 {
406- HINSTANCE hInst;
407- HRSRC hRsrc;
408- HGLOBAL hG;
409- BYTE* lock;
410- BYTE* wave;
411- DWORD wfesize;
412- size_t bufsize;
406+ HINSTANCE hInst;
407+ HRSRC hRsrc;
408+ HGLOBAL hG;
409+ BYTE* lock;
410+ BYTE* wave;
411+ DWORD wfesize;
412+ size_t bufsize;
413413
414- hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
415- hRsrc = FindResource(hInst, MAKEINTRESOURCE(IDR_WAVE1), TEXT("WAVE"));
416- bufsize = SizeofResource(hInst, hRsrc);
417- SSMasterBuf = malloc(bufsize);
418- SSPlayBuf = malloc(bufsize);
419- hG = LoadResource(hInst, hRsrc);
420- lock = (BYTE*)LockResource(hG); //RIFFヘッダの確認
421- memcpy(SSMasterBuf, lock, bufsize);
422- memcpy(SSPlayBuf, lock, bufsize);
423- if (*(LPDWORD)SSMasterBuf != *(LPDWORD)"RIFF")
424- {
425- ErrorMsg(ERR_WAVERESOURCE);
426- return;
427- }
428- wave = (BYTE*)SSMasterBuf;
429- wave += 4; //ポインタは次を指しておく
430- wave += 4; //ポインタは次を指しておく
431- //WAVEヘッダの確認
432- if (*(LPDWORD)wave != *(LPDWORD)"WAVE")
433- {
434- ErrorMsg(ERR_WAVERESOURCE);
435- return;
436- }
437- wave += 4; //ポインタは次を指しておく
438- //fmtチャンクの確認
439- if (*(LPDWORD)wave != *(LPDWORD)"fmt ")
440- {
441- ErrorMsg(ERR_WAVERESOURCE);
442- return;
443- }
444- wave += 4; //ポインタは次を指しておく
445- //fmtチャンクサイズの取得
446- wfesize = *(DWORD *)wave;
447- wave += 4; //ポインタは次を指しておく
448- wave += wfesize; //WAVEFORMATEX構造体分だけポインタを進めておく
449- //dataチャンクの確認
450- if (*(LPDWORD)wave != *(LPDWORD)"data")
451- {
452- ErrorMsg(ERR_WAVERESOURCE);
453- return;
454- }
455- wave += 4; //ポインタは次を指しておく
456- //波形データのバイト数の取得
457- SSDataLen = *(DWORD *)wave;
458- SSHeadLen = bufsize - SSDataLen;
459- FreeResource(hG);
414+ hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
415+ hRsrc = FindResource(hInst, MAKEINTRESOURCE(IDR_WAVE1), TEXT("WAVE"));
416+ bufsize = SizeofResource(hInst, hRsrc);
417+ SSMasterBuf = malloc(bufsize);
418+ SSPlayBuf = malloc(bufsize);
419+ hG = LoadResource(hInst, hRsrc);
420+ lock = (BYTE*)LockResource(hG); //RIFFヘッダの確認
421+ memcpy(SSMasterBuf, lock, bufsize);
422+ memcpy(SSPlayBuf, lock, bufsize);
423+ if (*(LPDWORD)SSMasterBuf != *(LPDWORD)"RIFF")
424+ {
425+ ErrorMsg(ERR_WAVERESOURCE);
426+ return;
427+ }
428+ wave = (BYTE*)SSMasterBuf;
429+ wave += 4; //ポインタは次を指しておく
430+ wave += 4; //ポインタは次を指しておく
431+ //WAVEヘッダの確認
432+ if (*(LPDWORD)wave != *(LPDWORD)"WAVE")
433+ {
434+ ErrorMsg(ERR_WAVERESOURCE);
435+ return;
436+ }
437+ wave += 4; //ポインタは次を指しておく
438+ //fmtチャンクの確認
439+ if (*(LPDWORD)wave != *(LPDWORD)"fmt ")
440+ {
441+ ErrorMsg(ERR_WAVERESOURCE);
442+ return;
443+ }
444+ wave += 4; //ポインタは次を指しておく
445+ //fmtチャンクサイズの取得
446+ wfesize = *(DWORD *)wave;
447+ wave += 4; //ポインタは次を指しておく
448+ wave += wfesize; //WAVEFORMATEX構造体分だけポインタを進めておく
449+ //dataチャンクの確認
450+ if (*(LPDWORD)wave != *(LPDWORD)"data")
451+ {
452+ ErrorMsg(ERR_WAVERESOURCE);
453+ return;
454+ }
455+ wave += 4; //ポインタは次を指しておく
456+ //波形データのバイト数の取得
457+ SSDataLen = *(DWORD *)wave;
458+ SSHeadLen = bufsize - SSDataLen;
459+ FreeResource(hG);
460460 }
461461
462462 void apuDestroySound(void)
463463 {
464- free(SSMasterBuf);
465- SSMasterBuf = NULL;
466- free(SSPlayBuf);
467- SSPlayBuf = NULL;
464+ free(SSMasterBuf);
465+ SSMasterBuf = NULL;
466+ free(SSPlayBuf);
467+ SSPlayBuf = NULL;
468468 }
469469
470470 void apuStartupSound(void)
471471 {
472- short *src, *dst;
473- int i;
474- int size = SSDataLen / sizeof(short);
472+ short *src, *dst;
473+ int i;
474+ int size = SSDataLen / sizeof(short);
475475
476- if (SSMasterBuf == NULL || SSPlayBuf == NULL)
477- {
478- return;
479- }
480- src = (short*)((BYTE*)SSMasterBuf + SSHeadLen);
481- dst = (short*)((BYTE*)SSPlayBuf + SSHeadLen);
482- // マスターの音量を変更してプレイバッファーにコピー
483- for (i = 0; i < size; i++)
484- {
485- *dst++ = (*src++) * WsWaveVol / 32;
486- }
487- PlaySound((LPCTSTR)SSPlayBuf, NULL, SND_MEMORY | SND_ASYNC);
476+ if (SSMasterBuf == NULL || SSPlayBuf == NULL)
477+ {
478+ return;
479+ }
480+ src = (short*)((BYTE*)SSMasterBuf + SSHeadLen);
481+ dst = (short*)((BYTE*)SSPlayBuf + SSHeadLen);
482+ // マスターの音量を変更してプレイバッファーにコピー
483+ for (i = 0; i < size; i++)
484+ {
485+ *dst++ = (*src++) * WsWaveVol / 32;
486+ }
487+ PlaySound((LPCTSTR)SSPlayBuf, NULL, SND_MEMORY | SND_ASYNC);
488488 }
--- oswanj/trunk/src/WSDraw.cpp (revision 87)
+++ oswanj/trunk/src/WSDraw.cpp (revision 88)
@@ -9,7 +9,7 @@
99 #include "WSRender.h"
1010
1111 extern HWND hWnd;
12-int Kerorikan = 0;
12+int Kerorikan = 0;
1313 static enum DRAWSIZE DrawSize = DS_1; // 描画サイズ フルスクリーン、x1 x2 x3
1414 static int DrawMode = 0; // 縦横フラグ 0:横
1515 static LPDIRECT3D9 pD3D; // IDirect3D9インターフェイスへのポインタ
@@ -79,7 +79,7 @@
7979 if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &D3DPP, &pD3DDevice)))
8080 {
8181 // 初期化失敗
82- MessageBox(hWnd, TEXT(" グラフィックチップが未対応です "), TEXT("Direct3D Error"), MB_OK);
82+ MessageBox(hWnd, TEXT(" グラフィックチップが未対応です "), TEXT("Direct3D Error"), MB_OK);
8383 return E_FAIL;
8484 }
8585 }
@@ -202,39 +202,39 @@
202202 //頂点バッファの中身を埋める
203203 MY_VERTEX* v;
204204 pMyVB->Lock( 0, 0, (void**)&v, 0 );
205- if (Kerorikan)
206- {
207- // 頂点座標の設定
208- v[0].p = D3DXVECTOR3(-112*KERO, 72*KERO, 0.0f);
209- v[1].p = D3DXVECTOR3( 112*KERO, 72*KERO, 0.0f);
210- v[2].p = D3DXVECTOR3(-112*KERO, -72*KERO, 0.0f);
211- v[3].p = D3DXVECTOR3( 112*KERO, -72*KERO, 0.0f);
212- v[4].p = D3DXVECTOR3( 114*KERO, 72*KERO, 0.0f);
213- v[5].p = D3DXVECTOR3( 122*KERO, 72*KERO, 0.0f);
214- v[6].p = D3DXVECTOR3( 114*KERO, -72*KERO, 0.0f);
215- v[7].p = D3DXVECTOR3( 122*KERO, -72*KERO, 0.0f);
216- }
217- else
218- {
219- // 頂点座標の設定
220- v[0].p = D3DXVECTOR3(-1.0f, 1.0f, 0.0f);
221- v[1].p = D3DXVECTOR3(MAIN_W, 1.0f, 0.0f);
222- v[2].p = D3DXVECTOR3(-1.0f, -1.0f, 0.0f);
223- v[3].p = D3DXVECTOR3(MAIN_W,-1.0f, 0.0f);
224- v[4].p = D3DXVECTOR3(SEG_W, 1.0f, 0.0f);
225- v[5].p = D3DXVECTOR3( 1.0f, 1.0f, 0.0f);
226- v[6].p = D3DXVECTOR3(SEG_W, -1.0f, 0.0f);
227- v[7].p = D3DXVECTOR3( 1.0f, -1.0f, 0.0f);
228- }
229- // テクスチャ座標の設定
230- v[0].t = D3DXVECTOR2(0.0f, 0.0f);
231- v[1].t = D3DXVECTOR2(MAIN_X, 0.0f);
232- v[2].t = D3DXVECTOR2(0.0f, MAIN_Y);
233- v[3].t = D3DXVECTOR2(MAIN_X, MAIN_Y);
234- v[4].t = D3DXVECTOR2(0.0f, 0.0f);
235- v[5].t = D3DXVECTOR2(SEG_X, 0.0f);
236- v[6].t = D3DXVECTOR2(0.0f, SEG_Y);
237- v[7].t = D3DXVECTOR2(SEG_X, SEG_Y);
205+ if (Kerorikan)
206+ {
207+ // 頂点座標の設定
208+ v[0].p = D3DXVECTOR3(-112*KERO, 72*KERO, 0.0f);
209+ v[1].p = D3DXVECTOR3( 112*KERO, 72*KERO, 0.0f);
210+ v[2].p = D3DXVECTOR3(-112*KERO, -72*KERO, 0.0f);
211+ v[3].p = D3DXVECTOR3( 112*KERO, -72*KERO, 0.0f);
212+ v[4].p = D3DXVECTOR3( 114*KERO, 72*KERO, 0.0f);
213+ v[5].p = D3DXVECTOR3( 122*KERO, 72*KERO, 0.0f);
214+ v[6].p = D3DXVECTOR3( 114*KERO, -72*KERO, 0.0f);
215+ v[7].p = D3DXVECTOR3( 122*KERO, -72*KERO, 0.0f);
216+ }
217+ else
218+ {
219+ // 頂点座標の設定
220+ v[0].p = D3DXVECTOR3(-1.0f, 1.0f, 0.0f);
221+ v[1].p = D3DXVECTOR3(MAIN_W, 1.0f, 0.0f);
222+ v[2].p = D3DXVECTOR3(-1.0f, -1.0f, 0.0f);
223+ v[3].p = D3DXVECTOR3(MAIN_W,-1.0f, 0.0f);
224+ v[4].p = D3DXVECTOR3(SEG_W, 1.0f, 0.0f);
225+ v[5].p = D3DXVECTOR3( 1.0f, 1.0f, 0.0f);
226+ v[6].p = D3DXVECTOR3(SEG_W, -1.0f, 0.0f);
227+ v[7].p = D3DXVECTOR3( 1.0f, -1.0f, 0.0f);
228+ }
229+ // テクスチャ座標の設定
230+ v[0].t = D3DXVECTOR2(0.0f, 0.0f);
231+ v[1].t = D3DXVECTOR2(MAIN_X, 0.0f);
232+ v[2].t = D3DXVECTOR2(0.0f, MAIN_Y);
233+ v[3].t = D3DXVECTOR2(MAIN_X, MAIN_Y);
234+ v[4].t = D3DXVECTOR2(0.0f, 0.0f);
235+ v[5].t = D3DXVECTOR2(SEG_X, 0.0f);
236+ v[6].t = D3DXVECTOR2(0.0f, SEG_Y);
237+ v[7].t = D3DXVECTOR2(SEG_X, SEG_Y);
238238 // 頂点カラーの設定
239239 v[0].color = v[1].color = v[2].color = v[3].color = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);
240240 v[4].color = v[5].color = v[6].color = v[7].color = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);
@@ -248,10 +248,10 @@
248248 D3DXMatrixRotationZ(&mat, 0.4636476f); // atanf(0.5f)だと最適化されないかもしれないので
249249 }
250250 // 縦(左90度回転)
251- else if (DrawMode & 0x01)
252- {
251+ else if (DrawMode & 0x01)
252+ {
253253 D3DXMatrixRotationZ(&mat, D3DXToRadian(90));
254- }
254+ }
255255 // 描画開始宣言
256256 if(SUCCEEDED(pD3DDevice->BeginScene()))
257257 {
--- oswanj/trunk/src/WSInput.cpp (revision 87)
+++ oswanj/trunk/src/WSInput.cpp (revision 88)
@@ -18,288 +18,288 @@
1818
1919 BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* lpddi, LPVOID lpContext)
2020 {
21- HRESULT hRet;
21+ HRESULT hRet;
2222
23- hRet = lpDInput->CreateDevice(lpddi->guidInstance, &lpJoyDevice, NULL);
24- if(FAILED(hRet)) return DIENUM_CONTINUE;
23+ hRet = lpDInput->CreateDevice(lpddi->guidInstance, &lpJoyDevice, NULL);
24+ if(FAILED(hRet)) return DIENUM_CONTINUE;
2525
26- return DIENUM_STOP;
26+ return DIENUM_STOP;
2727 }
2828
2929 int WsInputJoyInit(HWND hw)
3030 {
31- HRESULT hRet;
32- if (lpJoyDevice != NULL)
33- return TRUE;
31+ HRESULT hRet;
32+ if (lpJoyDevice != NULL)
33+ return TRUE;
3434
35- hRet = lpDInput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY);
36- if (hRet != DI_OK){
37- if (lpJoyDevice != NULL)
38- {
39- lpJoyDevice->Release();
40- lpJoyDevice = NULL;
41- }
42- return FALSE;
43- }
44- if (lpJoyDevice == NULL)
45- {
46- return FALSE;
47- }
48- hRet = lpJoyDevice->SetDataFormat(&c_dfDIJoystick2);
49- if (hRet != DI_OK){
50- if (lpJoyDevice != NULL)
51- {
52- lpJoyDevice->Release();
53- lpJoyDevice = NULL;
54- }
55- return FALSE;
56- }
57- hRet = lpJoyDevice->SetCooperativeLevel(hw, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
58- if (hRet != DI_OK){
59- if (lpJoyDevice != NULL)
60- {
61- lpJoyDevice->Release();
62- lpJoyDevice = NULL;
63- }
64- return FALSE;
65- }
66- lpJoyDevice->Acquire();
35+ hRet = lpDInput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY);
36+ if (hRet != DI_OK){
37+ if (lpJoyDevice != NULL)
38+ {
39+ lpJoyDevice->Release();
40+ lpJoyDevice = NULL;
41+ }
42+ return FALSE;
43+ }
44+ if (lpJoyDevice == NULL)
45+ {
46+ return FALSE;
47+ }
48+ hRet = lpJoyDevice->SetDataFormat(&c_dfDIJoystick2);
49+ if (hRet != DI_OK){
50+ if (lpJoyDevice != NULL)
51+ {
52+ lpJoyDevice->Release();
53+ lpJoyDevice = NULL;
54+ }
55+ return FALSE;
56+ }
57+ hRet = lpJoyDevice->SetCooperativeLevel(hw, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
58+ if (hRet != DI_OK){
59+ if (lpJoyDevice != NULL)
60+ {
61+ lpJoyDevice->Release();
62+ lpJoyDevice = NULL;
63+ }
64+ return FALSE;
65+ }
66+ lpJoyDevice->Acquire();
6767
68- return TRUE;
68+ return TRUE;
6969 }
7070
7171 int WsInputInit(HWND hw)
7272 {
73- DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&lpDInput, NULL);
74- lpDInput->CreateDevice(GUID_SysKeyboard, &lpKeyDevice, NULL);
75- lpKeyDevice->SetDataFormat(&c_dfDIKeyboard);
76- lpKeyDevice->SetCooperativeLevel(hw, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
77- return WsInputJoyInit(hw);
73+ DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&lpDInput, NULL);
74+ lpDInput->CreateDevice(GUID_SysKeyboard, &lpKeyDevice, NULL);
75+ lpKeyDevice->SetDataFormat(&c_dfDIKeyboard);
76+ lpKeyDevice->SetCooperativeLevel(hw, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
77+ return WsInputJoyInit(hw);
7878 }
7979
8080 void WsInputJoyRelease(void)
8181 {
82- if (lpJoyDevice != NULL)
83- {
84- lpJoyDevice->Unacquire();
85- lpJoyDevice->Release();
86- lpJoyDevice = NULL;
87- }
82+ if (lpJoyDevice != NULL)
83+ {
84+ lpJoyDevice->Unacquire();
85+ lpJoyDevice->Release();
86+ lpJoyDevice = NULL;
87+ }
8888 }
8989
9090 void WsInputRelease(void)
9191 {
92- if (lpKeyDevice != NULL)
93- {
94- lpKeyDevice->Unacquire();
95- lpKeyDevice->Release();
96- lpKeyDevice = NULL;
97- }
98- if (lpDInput != NULL)
99- {
100- lpDInput->Release();
101- lpDInput = NULL;
102- }
103- WsInputJoyRelease();
92+ if (lpKeyDevice != NULL)
93+ {
94+ lpKeyDevice->Unacquire();
95+ lpKeyDevice->Release();
96+ lpKeyDevice = NULL;
97+ }
98+ if (lpDInput != NULL)
99+ {
100+ lpDInput->Release();
101+ lpDInput = NULL;
102+ }
103+ WsInputJoyRelease();
104104 }
105105
106106 #define HALFRECT JOY_POVRIGHT / 2
107107 int WsInputCheckJoy(int value)
108108 {
109- int i;
109+ int i;
110110
111- if ((value >= 1) && (value <= 128))
112- {
113- return((js.rgbButtons[value - 1] & 0x80) ? 1 : 0);
114- }
115- if ((value & 0x1100) == 0x100)
116- {
117- i = (value & 0x30) >> 4;
118- switch (value & 0x0F)
119- {
120- case 1:
121- if (js.rgdwPOV[i] == JOY_POVLEFT + HALFRECT) return 1;
122- if (js.rgdwPOV[i] == JOY_POVFORWARD) return 1;
123- if (js.rgdwPOV[i] == JOY_POVFORWARD + HALFRECT) return 1;
124- break;
125- case 2:
126- if (js.rgdwPOV[i] == JOY_POVFORWARD + HALFRECT) return 1;
127- if (js.rgdwPOV[i] == JOY_POVRIGHT) return 1;
128- if (js.rgdwPOV[i] == JOY_POVRIGHT + HALFRECT) return 1;
129- break;
130- case 4:
131- if (js.rgdwPOV[i] == JOY_POVRIGHT + HALFRECT) return 1;
132- if (js.rgdwPOV[i] == JOY_POVBACKWARD) return 1;
133- if (js.rgdwPOV[i] == JOY_POVBACKWARD + HALFRECT) return 1;
134- break;
135- case 8:
136- if (js.rgdwPOV[i] == JOY_POVBACKWARD + HALFRECT) return 1;
137- if (js.rgdwPOV[i] == JOY_POVLEFT) return 1;
138- if (js.rgdwPOV[i] == JOY_POVLEFT + HALFRECT) return 1;
139- break;
140- }
141- return 0;
142- }
143- switch (value)
144- {
145- case WS_JOY_AXIS_X_P:
146- if (js.lX > 0xC000) return 1;
147- break;
148- case WS_JOY_AXIS_X_M:
149- if (js.lX < 0x4000) return 1;
150- break;
151- case WS_JOY_AXIS_Y_P:
152- if (js.lY > 0xC000) return 1;
153- break;
154- case WS_JOY_AXIS_Y_M:
155- if (js.lY < 0x4000) return 1;
156- break;
157- case WS_JOY_AXIS_Z_P:
158- if (js.lZ > 0xC000) return 1;
159- break;
160- case WS_JOY_AXIS_Z_M:
161- if (js.lZ < 0x4000) return 1;
162- break;
163- case WS_JOY_AXIS_RX_P:
164- if (js.lRx > 0xC000) return 1;
165- break;
166- case WS_JOY_AXIS_RX_M:
167- if (js.lRx < 0x4000) return 1;
168- break;
169- case WS_JOY_AXIS_RY_P:
170- if (js.lRy > 0xC000) return 1;
171- break;
172- case WS_JOY_AXIS_RY_M:
173- if (js.lRy < 0x4000) return 1;
174- break;
175- case WS_JOY_AXIS_RZ_P:
176- if (js.lRz > 0xC000) return 1;
177- break;
178- case WS_JOY_AXIS_RZ_M:
179- if (js.lRz < 0x4000) return 1;
180- break;
181- case WS_JOY_SLIDER1_P:
182- if (js.rglSlider[0] > 0xC000) return 1;
183- break;
184- case WS_JOY_SLIDER1_M:
185- if (js.rglSlider[0] < 0x4000) return 1;
186- break;
187- case WS_JOY_SLIDER2_P:
188- if (js.rglSlider[1] > 0xC000) return 1;
189- break;
190- case WS_JOY_SLIDER2_M:
191- if (js.rglSlider[1] < 0x4000) return 1;
192- break;
193- }
194- return 0;
111+ if ((value >= 1) && (value <= 128))
112+ {
113+ return((js.rgbButtons[value - 1] & 0x80) ? 1 : 0);
114+ }
115+ if ((value & 0x1100) == 0x100)
116+ {
117+ i = (value & 0x30) >> 4;
118+ switch (value & 0x0F)
119+ {
120+ case 1:
121+ if (js.rgdwPOV[i] == JOY_POVLEFT + HALFRECT) return 1;
122+ if (js.rgdwPOV[i] == JOY_POVFORWARD) return 1;
123+ if (js.rgdwPOV[i] == JOY_POVFORWARD + HALFRECT) return 1;
124+ break;
125+ case 2:
126+ if (js.rgdwPOV[i] == JOY_POVFORWARD + HALFRECT) return 1;
127+ if (js.rgdwPOV[i] == JOY_POVRIGHT) return 1;
128+ if (js.rgdwPOV[i] == JOY_POVRIGHT + HALFRECT) return 1;
129+ break;
130+ case 4:
131+ if (js.rgdwPOV[i] == JOY_POVRIGHT + HALFRECT) return 1;
132+ if (js.rgdwPOV[i] == JOY_POVBACKWARD) return 1;
133+ if (js.rgdwPOV[i] == JOY_POVBACKWARD + HALFRECT) return 1;
134+ break;
135+ case 8:
136+ if (js.rgdwPOV[i] == JOY_POVBACKWARD + HALFRECT) return 1;
137+ if (js.rgdwPOV[i] == JOY_POVLEFT) return 1;
138+ if (js.rgdwPOV[i] == JOY_POVLEFT + HALFRECT) return 1;
139+ break;
140+ }
141+ return 0;
142+ }
143+ switch (value)
144+ {
145+ case WS_JOY_AXIS_X_P:
146+ if (js.lX > 0xC000) return 1;
147+ break;
148+ case WS_JOY_AXIS_X_M:
149+ if (js.lX < 0x4000) return 1;
150+ break;
151+ case WS_JOY_AXIS_Y_P:
152+ if (js.lY > 0xC000) return 1;
153+ break;
154+ case WS_JOY_AXIS_Y_M:
155+ if (js.lY < 0x4000) return 1;
156+ break;
157+ case WS_JOY_AXIS_Z_P:
158+ if (js.lZ > 0xC000) return 1;
159+ break;
160+ case WS_JOY_AXIS_Z_M:
161+ if (js.lZ < 0x4000) return 1;
162+ break;
163+ case WS_JOY_AXIS_RX_P:
164+ if (js.lRx > 0xC000) return 1;
165+ break;
166+ case WS_JOY_AXIS_RX_M:
167+ if (js.lRx < 0x4000) return 1;
168+ break;
169+ case WS_JOY_AXIS_RY_P:
170+ if (js.lRy > 0xC000) return 1;
171+ break;
172+ case WS_JOY_AXIS_RY_M:
173+ if (js.lRy < 0x4000) return 1;
174+ break;
175+ case WS_JOY_AXIS_RZ_P:
176+ if (js.lRz > 0xC000) return 1;
177+ break;
178+ case WS_JOY_AXIS_RZ_M:
179+ if (js.lRz < 0x4000) return 1;
180+ break;
181+ case WS_JOY_SLIDER1_P:
182+ if (js.rglSlider[0] > 0xC000) return 1;
183+ break;
184+ case WS_JOY_SLIDER1_M:
185+ if (js.rglSlider[0] < 0x4000) return 1;
186+ break;
187+ case WS_JOY_SLIDER2_P:
188+ if (js.rglSlider[1] > 0xC000) return 1;
189+ break;
190+ case WS_JOY_SLIDER2_M:
191+ if (js.rglSlider[1] < 0x4000) return 1;
192+ break;
193+ }
194+ return 0;
195195 }
196196
197197 WORD WsInputGetState(void)
198198 {
199- int i;
200- HRESULT hRet;
201- BYTE diKeys[256];
202- WORD JoyState = 0;
203- WORD KeyState = 0;
199+ int i;
200+ HRESULT hRet;
201+ BYTE diKeys[256];
202+ WORD JoyState = 0;
203+ WORD KeyState = 0;
204204
205- ZeroMemory(&js, sizeof(DIJOYSTATE2));
206- ZeroMemory(diKeys, 256);
207- if (lpKeyDevice != NULL)
208- {
209- hRet = lpKeyDevice->Acquire();
210- if (hRet == DI_OK || hRet == S_FALSE)
211- {
212- hRet = lpKeyDevice->GetDeviceState(256, diKeys);
213- if (hRet == DI_OK)
214- {
215- for (i = 0; i < 12; i++)
216- {
217- KeyState <<= 1;
218- if (diKeys[WsKeyboard[i]] & 0x80)
219- {
220- KeyState |= 1;
221- }
222- }
223- }
224- }
225- }
226- if (lpJoyDevice != NULL)
227- {
228- hRet = lpJoyDevice->Poll();
229- if (FAILED(hRet))
230- {
231- hRet = lpJoyDevice->Acquire();
232- while (hRet == DIERR_INPUTLOST)
233- {
234- hRet = lpJoyDevice->Acquire();
235- }
236- return KeyState;
237- }
238- hRet = lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
239- if (hRet == DI_OK){
240- for (i = 0; i < 12; i++)
241- {
242- JoyState <<= 1;
243- JoyState |= WsInputCheckJoy(WsJoypad[i]);
244- }
245- }
246- }
247- return JoyState | KeyState;
205+ ZeroMemory(&js, sizeof(DIJOYSTATE2));
206+ ZeroMemory(diKeys, 256);
207+ if (lpKeyDevice != NULL)
208+ {
209+ hRet = lpKeyDevice->Acquire();
210+ if (hRet == DI_OK || hRet == S_FALSE)
211+ {
212+ hRet = lpKeyDevice->GetDeviceState(256, diKeys);
213+ if (hRet == DI_OK)
214+ {
215+ for (i = 0; i < 12; i++)
216+ {
217+ KeyState <<= 1;
218+ if (diKeys[WsKeyboard[i]] & 0x80)
219+ {
220+ KeyState |= 1;
221+ }
222+ }
223+ }
224+ }
225+ }
226+ if (lpJoyDevice != NULL)
227+ {
228+ hRet = lpJoyDevice->Poll();
229+ if (FAILED(hRet))
230+ {
231+ hRet = lpJoyDevice->Acquire();
232+ while (hRet == DIERR_INPUTLOST)
233+ {
234+ hRet = lpJoyDevice->Acquire();
235+ }
236+ return KeyState;
237+ }
238+ hRet = lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
239+ if (hRet == DI_OK){
240+ for (i = 0; i < 12; i++)
241+ {
242+ JoyState <<= 1;
243+ JoyState |= WsInputCheckJoy(WsJoypad[i]);
244+ }
245+ }
246+ }
247+ return JoyState | KeyState;
248248 }
249249
250250 void WsInputSetKeyMap(int mode)
251251 {
252- if (mode & 1)
253- {
254- WsJoypad = WsJoypadV;
255- WsKeyboard = WsKeyboardV;
256- }
257- else
258- {
259- WsJoypad = WsJoypadH;
260- WsKeyboard = WsKeyboardH;
261- }
252+ if (mode & 1)
253+ {
254+ WsJoypad = WsJoypadV;
255+ WsKeyboard = WsKeyboardV;
256+ }
257+ else
258+ {
259+ WsJoypad = WsJoypadH;
260+ WsKeyboard = WsKeyboardH;
261+ }
262262 }
263263
264264 int WsInputGetNowait(void)
265265 {
266- HRESULT hRet;
267- BYTE diKeys[256];
268- int flag = 0;
266+ HRESULT hRet;
267+ BYTE diKeys[256];
268+ int flag = 0;
269269
270- ZeroMemory(&js, sizeof(DIJOYSTATE2));
271- ZeroMemory(diKeys, 256);
272- if (lpKeyDevice != NULL)
273- {
274- hRet = lpKeyDevice->Acquire();
275- if (hRet == DI_OK || hRet == S_FALSE)
276- {
277- hRet = lpKeyDevice->GetDeviceState(256, diKeys);
278- if (hRet == DI_OK)
279- {
280- if (diKeys[WsKeyboard[12]] & 0x80)
281- {
282- flag = 1;
283- }
284- }
285- }
286- }
287- if (lpJoyDevice != NULL)
288- {
289- hRet = lpJoyDevice->Poll();
290- if (FAILED(hRet))
291- {
292- hRet = lpJoyDevice->Acquire();
293- while (hRet == DIERR_INPUTLOST)
294- {
295- hRet = lpJoyDevice->Acquire();
296- }
297- return flag;
298- }
299- hRet = lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
300- if (hRet == DI_OK){
301- flag |= WsInputCheckJoy(WsJoypad[12]);
302- }
303- }
304- return flag;
270+ ZeroMemory(&js, sizeof(DIJOYSTATE2));
271+ ZeroMemory(diKeys, 256);
272+ if (lpKeyDevice != NULL)
273+ {
274+ hRet = lpKeyDevice->Acquire();
275+ if (hRet == DI_OK || hRet == S_FALSE)
276+ {
277+ hRet = lpKeyDevice->GetDeviceState(256, diKeys);
278+ if (hRet == DI_OK)
279+ {
280+ if (diKeys[WsKeyboard[12]] & 0x80)
281+ {
282+ flag = 1;
283+ }
284+ }
285+ }
286+ }
287+ if (lpJoyDevice != NULL)
288+ {
289+ hRet = lpJoyDevice->Poll();
290+ if (FAILED(hRet))
291+ {
292+ hRet = lpJoyDevice->Acquire();
293+ while (hRet == DIERR_INPUTLOST)
294+ {
295+ hRet = lpJoyDevice->Acquire();
296+ }
297+ return flag;
298+ }
299+ hRet = lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
300+ if (hRet == DI_OK){
301+ flag |= WsInputCheckJoy(WsJoypad[12]);
302+ }
303+ }
304+ return flag;
305305 }
--- oswanj/trunk/src/WSDialog.cpp (revision 87)
+++ oswanj/trunk/src/WSDialog.cpp (revision 88)
@@ -20,595 +20,595 @@
2020
2121 void WsDlgConfInit(HWND hDlg)
2222 {
23- HINSTANCE hInst;
24- TC_ITEM tc;
25- RECT rt;
26- LPPOINT pt = (LPPOINT)&rt;
23+ HINSTANCE hInst;
24+ TC_ITEM tc;
25+ RECT rt;
26+ LPPOINT pt = (LPPOINT)&rt;
2727
28- memcpy(TmpKeyboardH, WsKeyboardH, sizeof(int) * 13);
29- memcpy(TmpKeyboardV, WsKeyboardV, sizeof(int) * 13);
30- memcpy(TmpJoypadH, WsJoypadH, sizeof(int) * 13);
31- memcpy(TmpJoypadV, WsJoypadV, sizeof(int) * 13);
32- hInst = (HINSTANCE)GetWindowLong(hDlg, GWLP_HINSTANCE);
33- hTabCtrl = GetDlgItem(hDlg, IDC_TAB1);
34- // タブコントロールにタブシートを挿入
35- tc.mask = TCIF_TEXT;
36- tc.pszText = TEXT("キー横");
37- TabCtrl_InsertItem(hTabCtrl , 0, &tc);
38- tc.mask = TCIF_TEXT;
39- tc.pszText = TEXT("キー縦");
40- TabCtrl_InsertItem(hTabCtrl , 1, &tc);
41- tc.mask = TCIF_TEXT;
42- tc.pszText = TEXT("コントローラー横");
43- TabCtrl_InsertItem(hTabCtrl , 2, &tc);
44- tc.mask = TCIF_TEXT;
45- tc.pszText = TEXT("コントローラー縦");
46- TabCtrl_InsertItem(hTabCtrl , 3, &tc);
47- // タブに貼り付けるダイアログを生成
48- hTab1 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB1, hDlg, (DLGPROC)TabProc1);
49- hTab2 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB2, hDlg, (DLGPROC)TabProc2);
50- hTab3 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB1, hDlg, (DLGPROC)TabProc3);
51- hTab4 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB2, hDlg, (DLGPROC)TabProc4);
52- // タブコントロールのクライアント領域の座標を取得
53- GetClientRect(hTabCtrl, &rt);
54- TabCtrl_AdjustRect(hTabCtrl, FALSE, &rt);
55- // 親ウィンドウがhDlgなのでタブのマップが必要
56- MapWindowPoints(hTabCtrl, hDlg, pt, 2);
57- // タブのウィンドウの位置とサイズを変更する
58- MoveWindow(hTab1, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
59- MoveWindow(hTab2, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
60- MoveWindow(hTab3, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
61- MoveWindow(hTab4, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
62- // デフォルトでタブ1を表示
63- ShowWindow(hTab1, SW_SHOW);
64- SetFocus(GetDlgItem(hTab1, IDC_EDIT_Y1));
65- SendMessage(GetDlgItem(hTab1, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
66- lpKeyDevice->Acquire();
28+ memcpy(TmpKeyboardH, WsKeyboardH, sizeof(int) * 13);
29+ memcpy(TmpKeyboardV, WsKeyboardV, sizeof(int) * 13);
30+ memcpy(TmpJoypadH, WsJoypadH, sizeof(int) * 13);
31+ memcpy(TmpJoypadV, WsJoypadV, sizeof(int) * 13);
32+ hInst = (HINSTANCE)GetWindowLong(hDlg, GWLP_HINSTANCE);
33+ hTabCtrl = GetDlgItem(hDlg, IDC_TAB1);
34+ // タブコントロールにタブシートを挿入
35+ tc.mask = TCIF_TEXT;
36+ tc.pszText = TEXT("キー横");
37+ TabCtrl_InsertItem(hTabCtrl , 0, &tc);
38+ tc.mask = TCIF_TEXT;
39+ tc.pszText = TEXT("キー縦");
40+ TabCtrl_InsertItem(hTabCtrl , 1, &tc);
41+ tc.mask = TCIF_TEXT;
42+ tc.pszText = TEXT("コントローラー横");
43+ TabCtrl_InsertItem(hTabCtrl , 2, &tc);
44+ tc.mask = TCIF_TEXT;
45+ tc.pszText = TEXT("コントローラー縦");
46+ TabCtrl_InsertItem(hTabCtrl , 3, &tc);
47+ // タブに貼り付けるダイアログを生成
48+ hTab1 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB1, hDlg, (DLGPROC)TabProc1);
49+ hTab2 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB2, hDlg, (DLGPROC)TabProc2);
50+ hTab3 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB1, hDlg, (DLGPROC)TabProc3);
51+ hTab4 = CreateDialog(hInst, (LPCTSTR)IDD_CONFIG_TAB2, hDlg, (DLGPROC)TabProc4);
52+ // タブコントロールのクライアント領域の座標を取得
53+ GetClientRect(hTabCtrl, &rt);
54+ TabCtrl_AdjustRect(hTabCtrl, FALSE, &rt);
55+ // 親ウィンドウがhDlgなのでタブのマップが必要
56+ MapWindowPoints(hTabCtrl, hDlg, pt, 2);
57+ // タブのウィンドウの位置とサイズを変更する
58+ MoveWindow(hTab1, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
59+ MoveWindow(hTab2, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
60+ MoveWindow(hTab3, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
61+ MoveWindow(hTab4, rt.left, rt.top, rt.right - rt.left, rt.bottom - rt.top, FALSE);
62+ // デフォルトでタブ1を表示
63+ ShowWindow(hTab1, SW_SHOW);
64+ SetFocus(GetDlgItem(hTab1, IDC_EDIT_Y1));
65+ SendMessage(GetDlgItem(hTab1, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
66+ lpKeyDevice->Acquire();
6767 }
6868
6969 LRESULT CALLBACK ConfProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
7070 {
71- NMHDR *nm = (NMHDR *)lParam;
71+ NMHDR *nm = (NMHDR *)lParam;
7272
73- switch (msg)
74- {
75- case WM_INITDIALOG:
76- WsInputInit(hDlg);
77- WsDlgConfInit(hDlg);
78- return TRUE;
79- case WM_NOTIFY:
80- // タブコントロールの選択されているタブが変更されたことを通知
81- switch (nm->code)
82- {
83- case TCN_SELCHANGE:
84- if (nm->hwndFrom == hTabCtrl)
85- {
86- SelectedTab = TabCtrl_GetCurSel(hTabCtrl);
87- switch (SelectedTab)
88- {
89- case 0:
90- ShowWindow(hTab1, SW_SHOW);
91- ShowWindow(hTab2, SW_HIDE);
92- ShowWindow(hTab3, SW_HIDE);
93- ShowWindow(hTab4, SW_HIDE);
94- SetFocus(GetDlgItem(hTab1, IDC_EDIT_Y1));
95- SendMessage(GetDlgItem(hTab1, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
96- lpKeyDevice->Acquire();
97- break;
98- case 1:
99- ShowWindow(hTab1, SW_HIDE);
100- ShowWindow(hTab2, SW_SHOW);
101- ShowWindow(hTab3, SW_HIDE);
102- ShowWindow(hTab4, SW_HIDE);
103- SetFocus(GetDlgItem(hTab2, IDC_EDIT_Y1));
104- SendMessage(GetDlgItem(hTab2, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
105- lpKeyDevice->Acquire();
106- break;
107- case 2:
108- ShowWindow(hTab1, SW_HIDE);
109- ShowWindow(hTab2, SW_HIDE);
110- ShowWindow(hTab3, SW_SHOW);
111- ShowWindow(hTab4, SW_HIDE);
112- SetFocus(GetDlgItem(hTab3, IDC_EDIT_Y1));
113- SendMessage(GetDlgItem(hTab3, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
114- break;
115- case 3:
116- ShowWindow(hTab1, SW_HIDE);
117- ShowWindow(hTab2, SW_HIDE);
118- ShowWindow(hTab3, SW_HIDE);
119- ShowWindow(hTab4, SW_SHOW);
120- SetFocus(GetDlgItem(hTab4, IDC_EDIT_Y1));
121- SendMessage(GetDlgItem(hTab4, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
122- break;
123- }
124- return TRUE;
125- }
126- break;
127- }
128- break;
129- case WM_COMMAND:
130- if(HIWORD(wParam) == BN_CLICKED)
131- {
132- switch (LOWORD(wParam))
133- {
134- case IDOK:
135- memcpy(WsKeyboardH, TmpKeyboardH, sizeof(int) * 13);
136- memcpy(WsKeyboardV, TmpKeyboardV, sizeof(int) * 13);
137- memcpy(WsJoypadH, TmpJoypadH, sizeof(int) * 13);
138- memcpy(WsJoypadV, TmpJoypadV, sizeof(int) * 13);
139- EndDialog(hDlg, LOWORD(wParam));
140- return TRUE;
141- case IDCANCEL:
142- EndDialog(hDlg, LOWORD(wParam));
143- return TRUE;
144- }
145- }
146- break;
147- case WM_DESTROY:
148- WsInputRelease();
149- break;
150- }
151- return FALSE;
73+ switch (msg)
74+ {
75+ case WM_INITDIALOG:
76+ WsInputInit(hDlg);
77+ WsDlgConfInit(hDlg);
78+ return TRUE;
79+ case WM_NOTIFY:
80+ // タブコントロールの選択されているタブが変更されたことを通知
81+ switch (nm->code)
82+ {
83+ case TCN_SELCHANGE:
84+ if (nm->hwndFrom == hTabCtrl)
85+ {
86+ SelectedTab = TabCtrl_GetCurSel(hTabCtrl);
87+ switch (SelectedTab)
88+ {
89+ case 0:
90+ ShowWindow(hTab1, SW_SHOW);
91+ ShowWindow(hTab2, SW_HIDE);
92+ ShowWindow(hTab3, SW_HIDE);
93+ ShowWindow(hTab4, SW_HIDE);
94+ SetFocus(GetDlgItem(hTab1, IDC_EDIT_Y1));
95+ SendMessage(GetDlgItem(hTab1, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
96+ lpKeyDevice->Acquire();
97+ break;
98+ case 1:
99+ ShowWindow(hTab1, SW_HIDE);
100+ ShowWindow(hTab2, SW_SHOW);
101+ ShowWindow(hTab3, SW_HIDE);
102+ ShowWindow(hTab4, SW_HIDE);
103+ SetFocus(GetDlgItem(hTab2, IDC_EDIT_Y1));
104+ SendMessage(GetDlgItem(hTab2, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
105+ lpKeyDevice->Acquire();
106+ break;
107+ case 2:
108+ ShowWindow(hTab1, SW_HIDE);
109+ ShowWindow(hTab2, SW_HIDE);
110+ ShowWindow(hTab3, SW_SHOW);
111+ ShowWindow(hTab4, SW_HIDE);
112+ SetFocus(GetDlgItem(hTab3, IDC_EDIT_Y1));
113+ SendMessage(GetDlgItem(hTab3, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
114+ break;
115+ case 3:
116+ ShowWindow(hTab1, SW_HIDE);
117+ ShowWindow(hTab2, SW_HIDE);
118+ ShowWindow(hTab3, SW_HIDE);
119+ ShowWindow(hTab4, SW_SHOW);
120+ SetFocus(GetDlgItem(hTab4, IDC_EDIT_Y1));
121+ SendMessage(GetDlgItem(hTab4, IDC_EDIT_Y1), EM_SETSEL, 0, -1);
122+ break;
123+ }
124+ return TRUE;
125+ }
126+ break;
127+ }
128+ break;
129+ case WM_COMMAND:
130+ if(HIWORD(wParam) == BN_CLICKED)
131+ {
132+ switch (LOWORD(wParam))
133+ {
134+ case IDOK:
135+ memcpy(WsKeyboardH, TmpKeyboardH, sizeof(int) * 13);
136+ memcpy(WsKeyboardV, TmpKeyboardV, sizeof(int) * 13);
137+ memcpy(WsJoypadH, TmpJoypadH, sizeof(int) * 13);
138+ memcpy(WsJoypadV, TmpJoypadV, sizeof(int) * 13);
139+ EndDialog(hDlg, LOWORD(wParam));
140+ return TRUE;
141+ case IDCANCEL:
142+ EndDialog(hDlg, LOWORD(wParam));
143+ return TRUE;
144+ }
145+ }
146+ break;
147+ case WM_DESTROY:
148+ WsInputRelease();
149+ break;
150+ }
151+ return FALSE;
152152 }
153153
154154 LRESULT CALLBACK EditProcKey(HWND hEditWnd, UINT msg, WPARAM wParam, LPARAM lParam)
155155 {
156- HRESULT hRet;
157- BYTE diKeys[256];
158- int key, i;
159- HWND next;
156+ HRESULT hRet;
157+ BYTE diKeys[256];
158+ int key, i;
159+ HWND next;
160160
161- switch (msg)
162- {
163- case WM_GETDLGCODE:
164- return DLGC_WANTALLKEYS;
165- case WM_CHAR:
166- return 0;
167- case WM_KEYDOWN:
168- key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
169- wParam = 0;
170- hRet = lpKeyDevice->Acquire();
171- if (hRet == DI_OK || hRet == S_FALSE)
172- {
173- hRet = lpKeyDevice->GetDeviceState(256, diKeys);
174- if (hRet == DI_OK)
175- {
176- for (i = 0; i < 256; i++)
177- {
178- if (diKeys[i] & 0x80)
179- {
180- SetWindowText(hEditWnd, keyName[i]);
181- if (SelectedTab == 0)
182- {
183- TmpKeyboardH[key] = i;
184- }
185- else
186- {
187- TmpKeyboardV[key] = i;
188- }
189- next = GetNextDlgTabItem(GetParent(hEditWnd), hEditWnd, FALSE);
190- SetFocus(next);
191- SendMessage(next, EM_SETSEL, 0, -1);
192- return 0;
193- }
194- }
195- }
196- }
197- break;
198- }
199- return CallWindowProc(OrgEditProc, hEditWnd, msg, wParam, lParam);
161+ switch (msg)
162+ {
163+ case WM_GETDLGCODE:
164+ return DLGC_WANTALLKEYS;
165+ case WM_CHAR:
166+ return 0;
167+ case WM_KEYDOWN:
168+ key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
169+ wParam = 0;
170+ hRet = lpKeyDevice->Acquire();
171+ if (hRet == DI_OK || hRet == S_FALSE)
172+ {
173+ hRet = lpKeyDevice->GetDeviceState(256, diKeys);
174+ if (hRet == DI_OK)
175+ {
176+ for (i = 0; i < 256; i++)
177+ {
178+ if (diKeys[i] & 0x80)
179+ {
180+ SetWindowText(hEditWnd, keyName[i]);
181+ if (SelectedTab == 0)
182+ {
183+ TmpKeyboardH[key] = i;
184+ }
185+ else
186+ {
187+ TmpKeyboardV[key] = i;
188+ }
189+ next = GetNextDlgTabItem(GetParent(hEditWnd), hEditWnd, FALSE);
190+ SetFocus(next);
191+ SendMessage(next, EM_SETSEL, 0, -1);
192+ return 0;
193+ }
194+ }
195+ }
196+ }
197+ break;
198+ }
199+ return CallWindowProc(OrgEditProc, hEditWnd, msg, wParam, lParam);
200200 }
201201
202202 LRESULT CALLBACK EditProcJoy(HWND hEditWnd, UINT msg, WPARAM wParam, LPARAM lParam)
203203 {
204- HWND next;
204+ HWND next;
205205
206- switch (msg)
207- {
208- case WM_GETDLGCODE:
209- return DLGC_WANTALLKEYS;
210- case WM_CHAR:
211- return 0;
212- case WM_KEYDOWN:
213- if (wParam == VK_TAB || wParam == VK_RETURN)
214- {
215- next = GetNextDlgTabItem(GetParent(hEditWnd), hEditWnd, FALSE);
216- SetFocus(next);
217- SendMessage(next, EM_SETSEL, 0, -1);
218- }
219- return 0;
220- }
221- return CallWindowProc(OrgEditProc, hEditWnd, msg, wParam, lParam);
206+ switch (msg)
207+ {
208+ case WM_GETDLGCODE:
209+ return DLGC_WANTALLKEYS;
210+ case WM_CHAR:
211+ return 0;
212+ case WM_KEYDOWN:
213+ if (wParam == VK_TAB || wParam == VK_RETURN)
214+ {
215+ next = GetNextDlgTabItem(GetParent(hEditWnd), hEditWnd, FALSE);
216+ SetFocus(next);
217+ SendMessage(next, EM_SETSEL, 0, -1);
218+ }
219+ return 0;
220+ }
221+ return CallWindowProc(OrgEditProc, hEditWnd, msg, wParam, lParam);
222222 }
223223
224224 LRESULT CALLBACK TabProc1(HWND hCtrl, UINT msg, WPARAM wParam, LPARAM lParam)
225225 {
226- switch (msg) {
227- case WM_INITDIALOG:
228- OrgEditProc = (WNDPROC)GetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC);
229- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
230- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
231- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
232- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
233- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
234- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
235- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
236- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
237- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
238- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
239- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
240- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
226+ switch (msg) {
227+ case WM_INITDIALOG:
228+ OrgEditProc = (WNDPROC)GetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC);
229+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
230+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
231+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
232+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
233+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
234+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
235+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
236+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
237+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
238+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
239+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
240+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
241241
242- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), keyName[TmpKeyboardH[12]]);
243- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), keyName[TmpKeyboardH[11]]);
244- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), keyName[TmpKeyboardH[10]]);
245- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), keyName[TmpKeyboardH[9]]);
246- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), keyName[TmpKeyboardH[8]]);
247- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), keyName[TmpKeyboardH[7]]);
248- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), keyName[TmpKeyboardH[6]]);
249- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), keyName[TmpKeyboardH[5]]);
250- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), keyName[TmpKeyboardH[4]]);
251- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), keyName[TmpKeyboardH[2]]);
252- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), keyName[TmpKeyboardH[1]]);
253- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), keyName[TmpKeyboardH[0]]);
254- return TRUE;
255- }
256- return FALSE;
242+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), keyName[TmpKeyboardH[12]]);
243+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), keyName[TmpKeyboardH[11]]);
244+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), keyName[TmpKeyboardH[10]]);
245+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), keyName[TmpKeyboardH[9]]);
246+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), keyName[TmpKeyboardH[8]]);
247+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), keyName[TmpKeyboardH[7]]);
248+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), keyName[TmpKeyboardH[6]]);
249+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), keyName[TmpKeyboardH[5]]);
250+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), keyName[TmpKeyboardH[4]]);
251+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), keyName[TmpKeyboardH[2]]);
252+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), keyName[TmpKeyboardH[1]]);
253+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), keyName[TmpKeyboardH[0]]);
254+ return TRUE;
255+ }
256+ return FALSE;
257257 }
258258
259259 LRESULT CALLBACK TabProc2(HWND hCtrl, UINT msg, WPARAM wParam, LPARAM lParam)
260260 {
261- switch (msg) {
262- case WM_INITDIALOG:
263- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
264- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
265- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
266- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
267- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
268- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
269- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
270- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
271- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
272- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
273- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
274- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
261+ switch (msg) {
262+ case WM_INITDIALOG:
263+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
264+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
265+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
266+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
267+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
268+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
269+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
270+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
271+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
272+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
273+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
274+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcKey);
275275
276- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), keyName[TmpKeyboardH[12]]);
277- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), keyName[TmpKeyboardV[11]]);
278- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), keyName[TmpKeyboardV[10]]);
279- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), keyName[TmpKeyboardV[9]]);
280- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), keyName[TmpKeyboardV[8]]);
281- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), keyName[TmpKeyboardV[7]]);
282- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), keyName[TmpKeyboardV[6]]);
283- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), keyName[TmpKeyboardV[5]]);
284- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), keyName[TmpKeyboardV[4]]);
285- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), keyName[TmpKeyboardV[2]]);
286- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), keyName[TmpKeyboardV[1]]);
287- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), keyName[TmpKeyboardV[0]]);
288- return TRUE;
289- }
290- return FALSE;
276+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), keyName[TmpKeyboardH[12]]);
277+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), keyName[TmpKeyboardV[11]]);
278+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), keyName[TmpKeyboardV[10]]);
279+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), keyName[TmpKeyboardV[9]]);
280+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), keyName[TmpKeyboardV[8]]);
281+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), keyName[TmpKeyboardV[7]]);
282+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), keyName[TmpKeyboardV[6]]);
283+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), keyName[TmpKeyboardV[5]]);
284+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), keyName[TmpKeyboardV[4]]);
285+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), keyName[TmpKeyboardV[2]]);
286+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), keyName[TmpKeyboardV[1]]);
287+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), keyName[TmpKeyboardV[0]]);
288+ return TRUE;
289+ }
290+ return FALSE;
291291 }
292292
293293 LRESULT CALLBACK TabProc3(HWND hCtrl, UINT msg, WPARAM wParam, LPARAM lParam)
294294 {
295- HWND hEditWnd;
296- int key, joy;
295+ HWND hEditWnd;
296+ int key, joy;
297297
298- switch (msg) {
299- case WM_INITDIALOG:
300- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
301- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
302- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
303- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
304- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
305- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
306- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
307- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
308- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
309- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
310- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
311- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
298+ switch (msg) {
299+ case WM_INITDIALOG:
300+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
301+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
302+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
303+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
304+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
305+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
306+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
307+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
308+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
309+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
310+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
311+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
312312
313- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GetJoyName(TmpJoypadH[12]));
314- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), GetJoyName(TmpJoypadH[11]));
315- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), GetJoyName(TmpJoypadH[10]));
316- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), GetJoyName(TmpJoypadH[9]));
317- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), GetJoyName(TmpJoypadH[8]));
318- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), GetJoyName(TmpJoypadH[7]));
319- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), GetJoyName(TmpJoypadH[6]));
320- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), GetJoyName(TmpJoypadH[5]));
321- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), GetJoyName(TmpJoypadH[4]));
322- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), GetJoyName(TmpJoypadH[2]));
323- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), GetJoyName(TmpJoypadH[1]));
324- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), GetJoyName(TmpJoypadH[0]));
313+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GetJoyName(TmpJoypadH[12]));
314+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), GetJoyName(TmpJoypadH[11]));
315+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), GetJoyName(TmpJoypadH[10]));
316+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), GetJoyName(TmpJoypadH[9]));
317+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), GetJoyName(TmpJoypadH[8]));
318+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), GetJoyName(TmpJoypadH[7]));
319+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), GetJoyName(TmpJoypadH[6]));
320+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), GetJoyName(TmpJoypadH[5]));
321+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), GetJoyName(TmpJoypadH[4]));
322+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), GetJoyName(TmpJoypadH[2]));
323+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), GetJoyName(TmpJoypadH[1]));
324+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), GetJoyName(TmpJoypadH[0]));
325325
326- SetTimer(hCtrl, 0, 30, NULL);
327- return TRUE;
328- case WM_TIMER:
329- if (SelectedTab != 2 || wParam != 0)
330- {
331- break;
332- }
333- hEditWnd = GetFocus();
334- key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
335- joy = GetJoyState();
336- if (joy < 0)
337- {
338- break;
339- }
340- SetWindowText(hEditWnd, GetJoyName(joy));
341- TmpJoypadH[key] = joy;
342- return TRUE;
343- }
344- return FALSE;
326+ SetTimer(hCtrl, 0, 30, NULL);
327+ return TRUE;
328+ case WM_TIMER:
329+ if (SelectedTab != 2 || wParam != 0)
330+ {
331+ break;
332+ }
333+ hEditWnd = GetFocus();
334+ key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
335+ joy = GetJoyState();
336+ if (joy < 0)
337+ {
338+ break;
339+ }
340+ SetWindowText(hEditWnd, GetJoyName(joy));
341+ TmpJoypadH[key] = joy;
342+ return TRUE;
343+ }
344+ return FALSE;
345345 }
346346
347347 LRESULT CALLBACK TabProc4(HWND hCtrl, UINT msg, WPARAM wParam, LPARAM lParam)
348348 {
349- HWND hEditWnd;
350- int key, joy;
349+ HWND hEditWnd;
350+ int key, joy;
351351
352- switch (msg) {
353- case WM_INITDIALOG:
354- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
355- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
356- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
357- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
358- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
359- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
360- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
361- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
362- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
363- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
364- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
365- SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
352+ switch (msg) {
353+ case WM_INITDIALOG:
354+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
355+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
356+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
357+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
358+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_Y4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
359+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X1), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
360+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X2), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
361+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X3), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
362+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_X4), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
363+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_START), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
364+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_A), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
365+ SetWindowLongPtr(GetDlgItem(hCtrl, IDC_EDIT_B), GWLP_WNDPROC, (LONG_PTR)EditProcJoy);
366366
367- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GetJoyName(TmpJoypadH[12]));
368- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), GetJoyName(TmpJoypadV[11]));
369- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), GetJoyName(TmpJoypadV[10]));
370- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), GetJoyName(TmpJoypadV[9]));
371- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), GetJoyName(TmpJoypadV[8]));
372- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), GetJoyName(TmpJoypadV[7]));
373- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), GetJoyName(TmpJoypadV[6]));
374- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), GetJoyName(TmpJoypadV[5]));
375- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), GetJoyName(TmpJoypadV[4]));
376- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), GetJoyName(TmpJoypadV[2]));
377- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), GetJoyName(TmpJoypadV[1]));
378- SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), GetJoyName(TmpJoypadV[0]));
367+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_NOWAIT), GetJoyName(TmpJoypadH[12]));
368+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y1), GetJoyName(TmpJoypadV[11]));
369+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y2), GetJoyName(TmpJoypadV[10]));
370+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y3), GetJoyName(TmpJoypadV[9]));
371+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_Y4), GetJoyName(TmpJoypadV[8]));
372+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X1), GetJoyName(TmpJoypadV[7]));
373+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X2), GetJoyName(TmpJoypadV[6]));
374+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X3), GetJoyName(TmpJoypadV[5]));
375+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_X4), GetJoyName(TmpJoypadV[4]));
376+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_START), GetJoyName(TmpJoypadV[2]));
377+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_A), GetJoyName(TmpJoypadV[1]));
378+ SetWindowText(GetDlgItem(hCtrl, IDC_EDIT_B), GetJoyName(TmpJoypadV[0]));
379379
380- SetTimer(hCtrl, 1, 30, NULL);
381- return TRUE;
382- case WM_TIMER:
383- if (SelectedTab != 3 || wParam != 1)
384- {
385- break;
386- }
387- hEditWnd = GetFocus();
388- key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
389- joy = GetJoyState();
390- if (joy < 0)
391- {
392- break;
393- }
394- SetWindowText(hEditWnd, GetJoyName(joy));
395- TmpJoypadV[key] = joy;
396- return TRUE;
397- }
398- return FALSE;
380+ SetTimer(hCtrl, 1, 30, NULL);
381+ return TRUE;
382+ case WM_TIMER:
383+ if (SelectedTab != 3 || wParam != 1)
384+ {
385+ break;
386+ }
387+ hEditWnd = GetFocus();
388+ key = GetDlgCtrlID(hEditWnd) - IDC_EDIT_B;
389+ joy = GetJoyState();
390+ if (joy < 0)
391+ {
392+ break;
393+ }
394+ SetWindowText(hEditWnd, GetJoyName(joy));
395+ TmpJoypadV[key] = joy;
396+ return TRUE;
397+ }
398+ return FALSE;
399399 }
400400
401401 LPCTSTR GetJoyName(int joy)
402402 {
403- static LPCTSTR JoyStr[] = {
404- TEXT("POV1 UP"), TEXT("POV1 RIGHT"), TEXT("POV1 DOWN"), TEXT("POV1 LEFT"),
405- TEXT("POV2 UP"), TEXT("POV2 RIGHT"), TEXT("POV2 DOWN"), TEXT("POV2 LEFT"),
406- TEXT("POV3 UP"), TEXT("POV3 RIGHT"), TEXT("POV3 DOWN"), TEXT("POV3 LEFT"),
407- TEXT("POV4 UP"), TEXT("POV4 RIGHT"), TEXT("POV4 DOWN"), TEXT("POV4 LEFT"),
408- TEXT("Y -"), TEXT("X +"), TEXT("Y +"), TEXT("X -"), TEXT("Z +"), TEXT("Z -"),
409- TEXT("RY -"), TEXT("RX +"), TEXT("RY +"), TEXT("RX -"), TEXT("RZ +"), TEXT("RZ -"),
410- TEXT("Slider1 +"), TEXT("Slider1 -"), TEXT("Slider2 +"), TEXT("Slider2 -")
411- };
412- static const int JoyInt[] = {
413- WS_JOY_POV1_UP, WS_JOY_POV1_RIGHT, WS_JOY_POV1_DOWN, WS_JOY_POV1_LEFT,
414- WS_JOY_POV2_UP, WS_JOY_POV2_RIGHT, WS_JOY_POV2_DOWN, WS_JOY_POV2_LEFT,
415- WS_JOY_POV3_UP, WS_JOY_POV3_RIGHT, WS_JOY_POV3_DOWN, WS_JOY_POV3_LEFT,
416- WS_JOY_POV4_UP, WS_JOY_POV4_RIGHT, WS_JOY_POV4_DOWN, WS_JOY_POV4_LEFT,
417- WS_JOY_AXIS_Y_M, WS_JOY_AXIS_X_P, WS_JOY_AXIS_Y_P, WS_JOY_AXIS_X_M, WS_JOY_AXIS_Z_P, WS_JOY_AXIS_Z_M,
418- WS_JOY_AXIS_RY_M, WS_JOY_AXIS_RX_P, WS_JOY_AXIS_RY_P, WS_JOY_AXIS_RX_M, WS_JOY_AXIS_RZ_P, WS_JOY_AXIS_RZ_M,
419- WS_JOY_SLIDER1_P, WS_JOY_SLIDER1_M, WS_JOY_SLIDER2_P, WS_JOY_SLIDER2_M
420- };
421- static TCHAR buf[8];
422- int i;
403+ static LPCTSTR JoyStr[] = {
404+ TEXT("POV1 UP"), TEXT("POV1 RIGHT"), TEXT("POV1 DOWN"), TEXT("POV1 LEFT"),
405+ TEXT("POV2 UP"), TEXT("POV2 RIGHT"), TEXT("POV2 DOWN"), TEXT("POV2 LEFT"),
406+ TEXT("POV3 UP"), TEXT("POV3 RIGHT"), TEXT("POV3 DOWN"), TEXT("POV3 LEFT"),
407+ TEXT("POV4 UP"), TEXT("POV4 RIGHT"), TEXT("POV4 DOWN"), TEXT("POV4 LEFT"),
408+ TEXT("Y -"), TEXT("X +"), TEXT("Y +"), TEXT("X -"), TEXT("Z +"), TEXT("Z -"),
409+ TEXT("RY -"), TEXT("RX +"), TEXT("RY +"), TEXT("RX -"), TEXT("RZ +"), TEXT("RZ -"),
410+ TEXT("Slider1 +"), TEXT("Slider1 -"), TEXT("Slider2 +"), TEXT("Slider2 -")
411+ };
412+ static const int JoyInt[] = {
413+ WS_JOY_POV1_UP, WS_JOY_POV1_RIGHT, WS_JOY_POV1_DOWN, WS_JOY_POV1_LEFT,
414+ WS_JOY_POV2_UP, WS_JOY_POV2_RIGHT, WS_JOY_POV2_DOWN, WS_JOY_POV2_LEFT,
415+ WS_JOY_POV3_UP, WS_JOY_POV3_RIGHT, WS_JOY_POV3_DOWN, WS_JOY_POV3_LEFT,
416+ WS_JOY_POV4_UP, WS_JOY_POV4_RIGHT, WS_JOY_POV4_DOWN, WS_JOY_POV4_LEFT,
417+ WS_JOY_AXIS_Y_M, WS_JOY_AXIS_X_P, WS_JOY_AXIS_Y_P, WS_JOY_AXIS_X_M, WS_JOY_AXIS_Z_P, WS_JOY_AXIS_Z_M,
418+ WS_JOY_AXIS_RY_M, WS_JOY_AXIS_RX_P, WS_JOY_AXIS_RY_P, WS_JOY_AXIS_RX_M, WS_JOY_AXIS_RZ_P, WS_JOY_AXIS_RZ_M,
419+ WS_JOY_SLIDER1_P, WS_JOY_SLIDER1_M, WS_JOY_SLIDER2_P, WS_JOY_SLIDER2_M
420+ };
421+ static TCHAR buf[8];
422+ int i;
423423
424- if (joy < 0x80)
425- {
426- _stprintf_s(buf, 8, TEXT("%d"), joy);
427- return buf;
428- }
429- for (i = 0; i < 32; i++)
430- {
431- if (joy == JoyInt[i])
432- {
433- return JoyStr[i];
434- }
435- }
436- buf[0] = 0;
437- return buf;
424+ if (joy < 0x80)
425+ {
426+ _stprintf_s(buf, 8, TEXT("%d"), joy);
427+ return buf;
428+ }
429+ for (i = 0; i < 32; i++)
430+ {
431+ if (joy == JoyInt[i])
432+ {
433+ return JoyStr[i];
434+ }
435+ }
436+ buf[0] = 0;
437+ return buf;
438438 }
439439
440440 int GetJoyState(void)
441441 {
442- const long joyCenter = 0x7fff;
443- static int xFlag = 0;
444- static int yFlag = 0;
445- static int zFlag = 0;
446- static int rxFlag = 0;
447- static int ryFlag = 0;
448- static int rzFlag = 0;
449- static int s1Flag = 0;
450- static int s2Flag = 0;
451- HRESULT hRet;
452- int joy;
453- unsigned int i;
454- DIJOYSTATE2 js;
455- DIDEVCAPS diDevCaps;
442+ const long joyCenter = 0x7fff;
443+ static int xFlag = 0;
444+ static int yFlag = 0;
445+ static int zFlag = 0;
446+ static int rxFlag = 0;
447+ static int ryFlag = 0;
448+ static int rzFlag = 0;
449+ static int s1Flag = 0;
450+ static int s2Flag = 0;
451+ HRESULT hRet;
452+ int joy;
453+ unsigned int i;
454+ DIJOYSTATE2 js;
455+ DIDEVCAPS diDevCaps;
456456
457- diDevCaps.dwSize = sizeof(DIDEVCAPS);
458- if (lpJoyDevice == NULL)
459- {
460- return -1;
461- }
462- hRet = lpJoyDevice->Poll();
463- if (FAILED(hRet))
464- {
465- hRet = lpJoyDevice->Acquire();
466- while (hRet == DIERR_INPUTLOST)
467- {
468- hRet = lpJoyDevice->Acquire();
469- }
470- return -1;
471- }
472- lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
473- lpJoyDevice->GetCapabilities(&diDevCaps);
474- for (i = 0; i < diDevCaps.dwButtons; i++)
475- {
476- if (js.rgbButtons[i] & 0x80)
477- {
478- return i + 1;
479- }
480- }
481- for (i = 0; i < diDevCaps.dwPOVs; i++)
482- {
483- joy = WS_JOY_POV1_UP + (i << 4);
484- if (js.rgdwPOV[i] == JOY_POVFORWARD)
485- {
486- return joy;
487- }
488- else if (js.rgdwPOV[i] == JOY_POVRIGHT)
489- {
490- return joy + 1;
491- }
492- else if (js.rgdwPOV[i] == JOY_POVBACKWARD)
493- {
494- return joy + 3;
495- }
496- else if (js.rgdwPOV[i] == JOY_POVLEFT)
497- {
498- return joy + 7;
499- }
500- }
501- if ((js.lX > joyCenter - 0x1000) && (js.lX < joyCenter + 0x1000))
502- {
503- xFlag = 1;
504- }
505- if ((js.lX > (joyCenter + 0x4000)) && xFlag)
506- {
507- xFlag = 0;
508- return WS_JOY_AXIS_X_P;
509- }
510- else if ((js.lX < (joyCenter - 0x4000)) && xFlag)
511- {
512- xFlag = 0;
513- return WS_JOY_AXIS_X_M;
514- }
515- if ((js.lY > joyCenter - 0x1000) && (js.lY < joyCenter + 0x1000))
516- {
517- yFlag = 1;
518- }
519- if ((js.lY > (joyCenter + 0x4000)) && yFlag)
520- {
521- yFlag = 0;
522- return WS_JOY_AXIS_Y_P;
523- }
524- else if ((js.lY < (joyCenter - 0x4000)) && yFlag)
525- {
526- yFlag = 0;
527- return WS_JOY_AXIS_Y_M;
528- }
529- if ((js.lZ > joyCenter - 0x1000) && (js.lZ < joyCenter + 0x1000))
530- {
531- zFlag = 1;
532- }
533- if ((js.lZ > (joyCenter + 0x4000)) && zFlag)
534- {
535- zFlag = 0;
536- return WS_JOY_AXIS_Z_P;
537- }
538- else if ((js.lZ < (joyCenter - 0x4000)) && zFlag)
539- {
540- zFlag = 0;
541- return WS_JOY_AXIS_Z_M;
542- }
543- if ((js.lRx > joyCenter - 0x1000) && (js.lRx < joyCenter + 0x1000))
544- {
545- rxFlag = 1;
546- }
547- if ((js.lRx > (joyCenter + 0x4000)) && rxFlag)
548- {
549- rxFlag = 0;
550- return WS_JOY_AXIS_RX_P;
551- }
552- else if ((js.lRx < (joyCenter - 0x4000)) && rxFlag)
553- {
554- rxFlag = 0;
555- return WS_JOY_AXIS_RX_M;
556- }
557- if ((js.lRy > joyCenter - 0x1000) && (js.lRy < joyCenter + 0x1000))
558- {
559- ryFlag = 1;
560- }
561- if ((js.lRy > (joyCenter + 0x4000)) && ryFlag)
562- {
563- ryFlag = 0;
564- return WS_JOY_AXIS_RY_P;
565- }
566- else if ((js.lRy < (joyCenter - 0x4000)) && ryFlag)
567- {
568- ryFlag = 0;
569- return WS_JOY_AXIS_RY_M;
570- }
571- if ((js.lRz > joyCenter - 0x1000) && (js.lRz < joyCenter + 0x1000))
572- {
573- rzFlag = 1;
574- }
575- if ((js.lRz > (joyCenter + 0x4000)) && rzFlag)
576- {
577- rzFlag = 0;
578- return WS_JOY_AXIS_RZ_P;
579- }
580- else if ((js.lRz < (joyCenter - 0x4000)) && rzFlag)
581- {
582- rzFlag = 0;
583- return WS_JOY_AXIS_RZ_M;
584- }
585- if ((js.rglSlider[0] > joyCenter - 0x1000) && (js.rglSlider[0] < joyCenter + 0x1000))
586- {
587- s1Flag = 1;
588- }
589- if ((js.rglSlider[0] > (joyCenter + 0x4000)) && s1Flag)
590- {
591- s1Flag = 0;
592- return WS_JOY_SLIDER1_P;
593- }
594- else if ((js.rglSlider[0] < (joyCenter - 0x4000)) && s1Flag)
595- {
596- s1Flag = 0;
597- return WS_JOY_SLIDER1_M;
598- }
599- if ((js.rglSlider[1] > joyCenter - 0x1000) && (js.rglSlider[0] < joyCenter + 0x1000))
600- {
601- s2Flag = 1;
602- }
603- if ((js.rglSlider[1] > (joyCenter + 0x4000)) && s2Flag)
604- {
605- s2Flag = 0;
606- return WS_JOY_SLIDER2_P;
607- }
608- else if ((js.rglSlider[1] < (joyCenter - 0x4000)) && s2Flag)
609- {
610- s2Flag = 0;
611- return WS_JOY_SLIDER2_M;
612- }
613- return -1;
457+ diDevCaps.dwSize = sizeof(DIDEVCAPS);
458+ if (lpJoyDevice == NULL)
459+ {
460+ return -1;
461+ }
462+ hRet = lpJoyDevice->Poll();
463+ if (FAILED(hRet))
464+ {
465+ hRet = lpJoyDevice->Acquire();
466+ while (hRet == DIERR_INPUTLOST)
467+ {
468+ hRet = lpJoyDevice->Acquire();
469+ }
470+ return -1;
471+ }
472+ lpJoyDevice->GetDeviceState(sizeof(DIJOYSTATE2), &js);
473+ lpJoyDevice->GetCapabilities(&diDevCaps);
474+ for (i = 0; i < diDevCaps.dwButtons; i++)
475+ {
476+ if (js.rgbButtons[i] & 0x80)
477+ {
478+ return i + 1;
479+ }
480+ }
481+ for (i = 0; i < diDevCaps.dwPOVs; i++)
482+ {
483+ joy = WS_JOY_POV1_UP + (i << 4);
484+ if (js.rgdwPOV[i] == JOY_POVFORWARD)
485+ {
486+ return joy;
487+ }
488+ else if (js.rgdwPOV[i] == JOY_POVRIGHT)
489+ {
490+ return joy + 1;
491+ }
492+ else if (js.rgdwPOV[i] == JOY_POVBACKWARD)
493+ {
494+ return joy + 3;
495+ }
496+ else if (js.rgdwPOV[i] == JOY_POVLEFT)
497+ {
498+ return joy + 7;
499+ }
500+ }
501+ if ((js.lX > joyCenter - 0x1000) && (js.lX < joyCenter + 0x1000))
502+ {
503+ xFlag = 1;
504+ }
505+ if ((js.lX > (joyCenter + 0x4000)) && xFlag)
506+ {
507+ xFlag = 0;
508+ return WS_JOY_AXIS_X_P;
509+ }
510+ else if ((js.lX < (joyCenter - 0x4000)) && xFlag)
511+ {
512+ xFlag = 0;
513+ return WS_JOY_AXIS_X_M;
514+ }
515+ if ((js.lY > joyCenter - 0x1000) && (js.lY < joyCenter + 0x1000))
516+ {
517+ yFlag = 1;
518+ }
519+ if ((js.lY > (joyCenter + 0x4000)) && yFlag)
520+ {
521+ yFlag = 0;
522+ return WS_JOY_AXIS_Y_P;
523+ }
524+ else if ((js.lY < (joyCenter - 0x4000)) && yFlag)
525+ {
526+ yFlag = 0;
527+ return WS_JOY_AXIS_Y_M;
528+ }
529+ if ((js.lZ > joyCenter - 0x1000) && (js.lZ < joyCenter + 0x1000))
530+ {
531+ zFlag = 1;
532+ }
533+ if ((js.lZ > (joyCenter + 0x4000)) && zFlag)
534+ {
535+ zFlag = 0;
536+ return WS_JOY_AXIS_Z_P;
537+ }
538+ else if ((js.lZ < (joyCenter - 0x4000)) && zFlag)
539+ {
540+ zFlag = 0;
541+ return WS_JOY_AXIS_Z_M;
542+ }
543+ if ((js.lRx > joyCenter - 0x1000) && (js.lRx < joyCenter + 0x1000))
544+ {
545+ rxFlag = 1;
546+ }
547+ if ((js.lRx > (joyCenter + 0x4000)) && rxFlag)
548+ {
549+ rxFlag = 0;
550+ return WS_JOY_AXIS_RX_P;
551+ }
552+ else if ((js.lRx < (joyCenter - 0x4000)) && rxFlag)
553+ {
554+ rxFlag = 0;
555+ return WS_JOY_AXIS_RX_M;
556+ }
557+ if ((js.lRy > joyCenter - 0x1000) && (js.lRy < joyCenter + 0x1000))
558+ {
559+ ryFlag = 1;
560+ }
561+ if ((js.lRy > (joyCenter + 0x4000)) && ryFlag)
562+ {
563+ ryFlag = 0;
564+ return WS_JOY_AXIS_RY_P;
565+ }
566+ else if ((js.lRy < (joyCenter - 0x4000)) && ryFlag)
567+ {
568+ ryFlag = 0;
569+ return WS_JOY_AXIS_RY_M;
570+ }
571+ if ((js.lRz > joyCenter - 0x1000) && (js.lRz < joyCenter + 0x1000))
572+ {
573+ rzFlag = 1;
574+ }
575+ if ((js.lRz > (joyCenter + 0x4000)) && rzFlag)
576+ {
577+ rzFlag = 0;
578+ return WS_JOY_AXIS_RZ_P;
579+ }
580+ else if ((js.lRz < (joyCenter - 0x4000)) && rzFlag)
581+ {
582+ rzFlag = 0;
583+ return WS_JOY_AXIS_RZ_M;
584+ }
585+ if ((js.rglSlider[0] > joyCenter - 0x1000) && (js.rglSlider[0] < joyCenter + 0x1000))
586+ {
587+ s1Flag = 1;
588+ }
589+ if ((js.rglSlider[0] > (joyCenter + 0x4000)) && s1Flag)
590+ {
591+ s1Flag = 0;
592+ return WS_JOY_SLIDER1_P;
593+ }
594+ else if ((js.rglSlider[0] < (joyCenter - 0x4000)) && s1Flag)
595+ {
596+ s1Flag = 0;
597+ return WS_JOY_SLIDER1_M;
598+ }
599+ if ((js.rglSlider[1] > joyCenter - 0x1000) && (js.rglSlider[0] < joyCenter + 0x1000))
600+ {
601+ s2Flag = 1;
602+ }
603+ if ((js.rglSlider[1] > (joyCenter + 0x4000)) && s2Flag)
604+ {
605+ s2Flag = 0;
606+ return WS_JOY_SLIDER2_P;
607+ }
608+ else if ((js.rglSlider[1] < (joyCenter - 0x4000)) && s2Flag)
609+ {
610+ s2Flag = 0;
611+ return WS_JOY_SLIDER2_M;
612+ }
613+ return -1;
614614 }
--- oswanj/trunk/src/WSConfig.cpp (revision 87)
+++ oswanj/trunk/src/WSConfig.cpp (revision 88)
@@ -10,116 +10,116 @@
1010 #include "WSFileio.h"
1111
1212 static LPCWSTR KeyName[] = {
13- L"B", L"A", L"START", L"OPTION",
14- L"X4", L"X3", L"X2", L"X1",
15- L"Y4", L"Y3", L"Y2", L"Y1",
16- L"NOWAIT"
13+ L"B", L"A", L"START", L"OPTION",
14+ L"X4", L"X3", L"X2", L"X1",
15+ L"Y4", L"Y3", L"Y2", L"Y1",
16+ L"NOWAIT"
1717 };
1818
1919 void ConfigCreate(void)
2020 {
21- int i;
21+ int i;
2222
23- WsKeyboardH[0] = DIK_Z; // B
24- WsKeyboardH[1] = DIK_X; // A
25- WsKeyboardH[2] = DIK_RETURN; // START
26- WsKeyboardH[3] = DIK_LCONTROL; // OPTION
27- WsKeyboardH[4] = DIK_LEFT; // X4
28- WsKeyboardH[5] = DIK_DOWN; // X3
29- WsKeyboardH[6] = DIK_RIGHT; // X2
30- WsKeyboardH[7] = DIK_UP; // X1
31- WsKeyboardH[8] = DIK_A; // Y4
32- WsKeyboardH[9] = DIK_S; // Y3
33- WsKeyboardH[10] = DIK_D; // Y2
34- WsKeyboardH[11] = DIK_W; // Y1
35- WsKeyboardH[12] = DIK_SPACE; // NO WAIT
23+ WsKeyboardH[0] = DIK_Z; // B
24+ WsKeyboardH[1] = DIK_X; // A
25+ WsKeyboardH[2] = DIK_RETURN; // START
26+ WsKeyboardH[3] = DIK_LCONTROL; // OPTION
27+ WsKeyboardH[4] = DIK_LEFT; // X4
28+ WsKeyboardH[5] = DIK_DOWN; // X3
29+ WsKeyboardH[6] = DIK_RIGHT; // X2
30+ WsKeyboardH[7] = DIK_UP; // X1
31+ WsKeyboardH[8] = DIK_A; // Y4
32+ WsKeyboardH[9] = DIK_S; // Y3
33+ WsKeyboardH[10] = DIK_D; // Y2
34+ WsKeyboardH[11] = DIK_W; // Y1
35+ WsKeyboardH[12] = DIK_SPACE; // NO WAIT
3636
37- WsKeyboardV[0] = DIK_Z; // B
38- WsKeyboardV[1] = DIK_X; // A
39- WsKeyboardV[2] = DIK_RETURN; // START
40- WsKeyboardV[3] = DIK_LCONTROL; // OPTION
41- WsKeyboardV[4] = DIK_S; // X4
42- WsKeyboardV[5] = DIK_D; // X3
43- WsKeyboardV[6] = DIK_W; // X2
44- WsKeyboardV[7] = DIK_A; // X1
45- WsKeyboardV[8] = DIK_DOWN; // Y4
46- WsKeyboardV[9] = DIK_RIGHT; // Y3
47- WsKeyboardV[10] = DIK_UP; // Y2
48- WsKeyboardV[11] = DIK_LEFT; // Y1
49- WsKeyboardV[12] = DIK_SPACE; // NO WAIT
50-
51- WsJoypadH[0] = 1; // B
52- WsJoypadH[1] = 2; // A
53- WsJoypadH[2] = 8; // START
54- WsJoypadH[3] = 0; // OPTION
55- WsJoypadH[4] = WS_JOY_AXIS_X_M; // X4
56- WsJoypadH[5] = WS_JOY_AXIS_Y_P; // X3
57- WsJoypadH[6] = WS_JOY_AXIS_X_P; // X2
58- WsJoypadH[7] = WS_JOY_AXIS_Y_M; // X1
59- WsJoypadH[8] = WS_JOY_POV1_LEFT; // Y4
60- WsJoypadH[9] = WS_JOY_POV1_DOWN; // Y3
61- WsJoypadH[10] = WS_JOY_POV1_RIGHT; // Y2
62- WsJoypadH[11] = WS_JOY_POV1_UP; // Y1
63- WsJoypadH[12] = 7; // NO WAIT
64-
65- WsJoypadV[0] = 5; // B
66- WsJoypadV[1] = 6; // A
67- WsJoypadV[2] = 8; // START
68- WsJoypadV[3] = 0; // OPTION
69- WsJoypadV[4] = 1; // X4
70- WsJoypadV[5] = 2; // X3
71- WsJoypadV[6] = 4; // X2
72- WsJoypadV[7] = 3; // X1
73- WsJoypadV[8] = WS_JOY_AXIS_Y_P; // Y4
74- WsJoypadV[9] = WS_JOY_AXIS_X_P; // Y3
75- WsJoypadV[10] = WS_JOY_AXIS_Y_M; // Y2
76- WsJoypadV[11] = WS_JOY_AXIS_X_M; // Y1
77- WsJoypadV[12] = 7; // NO WAIT
78-
79- for (i = 12; i >= 0; i--)
80- {
81- WsKeyboardH[i] = GetPrivateProfileIntW(L"KEY_H", KeyName[i] , WsKeyboardH[i] , IniPath);
82- }
83- for (i = 12; i >= 0; i--)
84- {
85- WsKeyboardV[i] = GetPrivateProfileIntW(L"KEY_V", KeyName[i] , WsKeyboardV[i] , IniPath);
86- }
87- for (i = 12; i >= 0; i--)
88- {
89- WsJoypadH[i] = GetPrivateProfileIntW(L"JOY_H", KeyName[i] , WsJoypadH[i] , IniPath);
90- }
91- for (i = 12; i >= 0; i--)
92- {
93- WsJoypadV[i] = GetPrivateProfileIntW(L"JOY_V", KeyName[i] , WsJoypadV[i] , IniPath);
94- }
37+ WsKeyboardV[0] = DIK_Z; // B
38+ WsKeyboardV[1] = DIK_X; // A
39+ WsKeyboardV[2] = DIK_RETURN; // START
40+ WsKeyboardV[3] = DIK_LCONTROL; // OPTION
41+ WsKeyboardV[4] = DIK_S; // X4
42+ WsKeyboardV[5] = DIK_D; // X3
43+ WsKeyboardV[6] = DIK_W; // X2
44+ WsKeyboardV[7] = DIK_A; // X1
45+ WsKeyboardV[8] = DIK_DOWN; // Y4
46+ WsKeyboardV[9] = DIK_RIGHT; // Y3
47+ WsKeyboardV[10] = DIK_UP; // Y2
48+ WsKeyboardV[11] = DIK_LEFT; // Y1
49+ WsKeyboardV[12] = DIK_SPACE; // NO WAIT
50+
51+ WsJoypadH[0] = 1; // B
52+ WsJoypadH[1] = 2; // A
53+ WsJoypadH[2] = 8; // START
54+ WsJoypadH[3] = 0; // OPTION
55+ WsJoypadH[4] = WS_JOY_AXIS_X_M; // X4
56+ WsJoypadH[5] = WS_JOY_AXIS_Y_P; // X3
57+ WsJoypadH[6] = WS_JOY_AXIS_X_P; // X2
58+ WsJoypadH[7] = WS_JOY_AXIS_Y_M; // X1
59+ WsJoypadH[8] = WS_JOY_POV1_LEFT; // Y4
60+ WsJoypadH[9] = WS_JOY_POV1_DOWN; // Y3
61+ WsJoypadH[10] = WS_JOY_POV1_RIGHT; // Y2
62+ WsJoypadH[11] = WS_JOY_POV1_UP; // Y1
63+ WsJoypadH[12] = 7; // NO WAIT
64+
65+ WsJoypadV[0] = 5; // B
66+ WsJoypadV[1] = 6; // A
67+ WsJoypadV[2] = 8; // START
68+ WsJoypadV[3] = 0; // OPTION
69+ WsJoypadV[4] = 1; // X4
70+ WsJoypadV[5] = 2; // X3
71+ WsJoypadV[6] = 4; // X2
72+ WsJoypadV[7] = 3; // X1
73+ WsJoypadV[8] = WS_JOY_AXIS_Y_P; // Y4
74+ WsJoypadV[9] = WS_JOY_AXIS_X_P; // Y3
75+ WsJoypadV[10] = WS_JOY_AXIS_Y_M; // Y2
76+ WsJoypadV[11] = WS_JOY_AXIS_X_M; // Y1
77+ WsJoypadV[12] = 7; // NO WAIT
78+
79+ for (i = 12; i >= 0; i--)
80+ {
81+ WsKeyboardH[i] = GetPrivateProfileIntW(L"KEY_H", KeyName[i] , WsKeyboardH[i] , IniPath);
82+ }
83+ for (i = 12; i >= 0; i--)
84+ {
85+ WsKeyboardV[i] = GetPrivateProfileIntW(L"KEY_V", KeyName[i] , WsKeyboardV[i] , IniPath);
86+ }
87+ for (i = 12; i >= 0; i--)
88+ {
89+ WsJoypadH[i] = GetPrivateProfileIntW(L"JOY_H", KeyName[i] , WsJoypadH[i] , IniPath);
90+ }
91+ for (i = 12; i >= 0; i--)
92+ {
93+ WsJoypadV[i] = GetPrivateProfileIntW(L"JOY_V", KeyName[i] , WsJoypadV[i] , IniPath);
94+ }
9595 }
9696
9797 static void WritePrivateProfileIntW(LPCWSTR lpAppName, LPCWSTR lpKeyName, int nInt, LPCWSTR lpFileName)
9898 {
99- wchar_t s[32];
99+ wchar_t s[32];
100100
101- swprintf_s(s, 32, L"%d", nInt);
102- WritePrivateProfileStringW(lpAppName, lpKeyName, s, lpFileName);
101+ swprintf_s(s, 32, L"%d", nInt);
102+ WritePrivateProfileStringW(lpAppName, lpKeyName, s, lpFileName);
103103 }
104104
105105 void ConfigRelease(void)
106106 {
107- int i;
107+ int i;
108108
109- for (i = 12; i >= 0; i--)
110- {
111- WritePrivateProfileIntW(L"KEY_H", KeyName[i] , WsKeyboardH[i] , IniPath);
112- }
113- for (i = 12; i >= 0; i--)
114- {
115- WritePrivateProfileIntW(L"KEY_V", KeyName[i] , WsKeyboardV[i] , IniPath);
116- }
117- for (i = 12; i >= 0; i--)
118- {
119- WritePrivateProfileIntW(L"JOY_H", KeyName[i] , WsJoypadH[i] , IniPath);
120- }
121- for (i = 12; i >= 0; i--)
122- {
123- WritePrivateProfileIntW(L"JOY_V", KeyName[i] , WsJoypadV[i] , IniPath);
124- }
109+ for (i = 12; i >= 0; i--)
110+ {
111+ WritePrivateProfileIntW(L"KEY_H", KeyName[i] , WsKeyboardH[i] , IniPath);
112+ }
113+ for (i = 12; i >= 0; i--)
114+ {
115+ WritePrivateProfileIntW(L"KEY_V", KeyName[i] , WsKeyboardV[i] , IniPath);
116+ }
117+ for (i = 12; i >= 0; i--)
118+ {
119+ WritePrivateProfileIntW(L"JOY_H", KeyName[i] , WsJoypadH[i] , IniPath);
120+ }
121+ for (i = 12; i >= 0; i--)
122+ {
123+ WritePrivateProfileIntW(L"JOY_V", KeyName[i] , WsJoypadV[i] , IniPath);
124+ }
125125 }
--- oswanj/trunk/src/WSFileio.cpp (revision 87)
+++ oswanj/trunk/src/WSFileio.cpp (revision 88)
@@ -34,8 +34,8 @@
3434 return;
3535 }
3636 *(++p) = 0;
37- wcscpy(IniPath, CurDir);
38- wcscat(IniPath, L"OswanJ.ini");
37+ wcscpy(IniPath, CurDir);
38+ wcscat(IniPath, L"OswanJ.ini");
3939 }
4040
4141 int WsSetPdata(void)
@@ -230,11 +230,11 @@
230230 CreateDirectoryW(SaveName, NULL);
231231 }
232232 wcscat(SaveName, p);
233- p = wcsrchr(SaveName, L'.');
234- if (p)
235- {
236- *p = 0;
237- }
233+ p = wcsrchr(SaveName, L'.');
234+ if (p)
235+ {
236+ *p = 0;
237+ }
238238 wcscat(SaveName, L".sav");
239239 }
240240 else
@@ -250,7 +250,7 @@
250250 if (fread(RAMMap[i], 1, RAMSize, fp) != (size_t)RAMSize)
251251 {
252252 ErrorMsg(ERR_FREAD_SAVE);
253- break;
253+ break;
254254 }
255255 }
256256 else
@@ -279,14 +279,14 @@
279279 CreateDirectoryW(StateName, NULL);
280280 }
281281 wcscat(StateName, p);
282- p = wcsrchr(StateName, L'.');
283- if (p)
284- {
285- *p = 0;
286- }
282+ p = wcsrchr(StateName, L'.');
283+ if (p)
284+ {
285+ *p = 0;
286+ }
287287 }
288288 WsReset();
289- SetDrawMode(buf[6] & 1); // 0:横 1:縦
289+ SetDrawMode(buf[6] & 1); // 0:横 1:縦
290290 return 0;
291291 }
292292
@@ -343,11 +343,11 @@
343343 fread(IEep, sizeof(WORD), 64, fp);
344344 fclose(fp);
345345 }
346- else
347- {
348- memset(IEep, 0xFF, 0x60);
349- memset(IEep + 0x60, 0, 0x20);
350- }
346+ else
347+ {
348+ memset(IEep, 0xFF, 0x60);
349+ memset(IEep + 0x60, 0, 0x20);
350+ }
351351 }
352352
353353 void WsSaveIEep(void)
@@ -365,38 +365,38 @@
365365 }
366366
367367 #define MacroLoadNecRegisterFromFile(F,R) \
368- fread(&value, sizeof(unsigned int), 1, fp); \
369- nec_set_reg(R,value);
368+ fread(&value, sizeof(unsigned int), 1, fp); \
369+ nec_set_reg(R,value);
370370 void WsLoadState(int num)
371371 {
372372 FILE* fp;
373373 wchar_t buf[512];
374- unsigned int value;
375- int i;
374+ unsigned int value;
375+ int i;
376376
377- wsprintf(buf, L"%s.%03d", StateName, num);
377+ wsprintf(buf, L"%s.%03d", StateName, num);
378378 if ((fp = _wfopen(buf, L"rb")) == NULL)
379379 {
380- return;
381- }
382- MacroLoadNecRegisterFromFile(fp,NEC_IP);
383- MacroLoadNecRegisterFromFile(fp,NEC_AW);
384- MacroLoadNecRegisterFromFile(fp,NEC_BW);
385- MacroLoadNecRegisterFromFile(fp,NEC_CW);
386- MacroLoadNecRegisterFromFile(fp,NEC_DW);
387- MacroLoadNecRegisterFromFile(fp,NEC_CS);
388- MacroLoadNecRegisterFromFile(fp,NEC_DS);
389- MacroLoadNecRegisterFromFile(fp,NEC_ES);
390- MacroLoadNecRegisterFromFile(fp,NEC_SS);
391- MacroLoadNecRegisterFromFile(fp,NEC_IX);
392- MacroLoadNecRegisterFromFile(fp,NEC_IY);
393- MacroLoadNecRegisterFromFile(fp,NEC_BP);
394- MacroLoadNecRegisterFromFile(fp,NEC_SP);
395- MacroLoadNecRegisterFromFile(fp,NEC_FLAGS);
396- MacroLoadNecRegisterFromFile(fp,NEC_VECTOR);
397- MacroLoadNecRegisterFromFile(fp,NEC_PENDING);
398- MacroLoadNecRegisterFromFile(fp,NEC_NMI_STATE);
399- MacroLoadNecRegisterFromFile(fp,NEC_IRQ_STATE);
380+ return;
381+ }
382+ MacroLoadNecRegisterFromFile(fp,NEC_IP);
383+ MacroLoadNecRegisterFromFile(fp,NEC_AW);
384+ MacroLoadNecRegisterFromFile(fp,NEC_BW);
385+ MacroLoadNecRegisterFromFile(fp,NEC_CW);
386+ MacroLoadNecRegisterFromFile(fp,NEC_DW);
387+ MacroLoadNecRegisterFromFile(fp,NEC_CS);
388+ MacroLoadNecRegisterFromFile(fp,NEC_DS);
389+ MacroLoadNecRegisterFromFile(fp,NEC_ES);
390+ MacroLoadNecRegisterFromFile(fp,NEC_SS);
391+ MacroLoadNecRegisterFromFile(fp,NEC_IX);
392+ MacroLoadNecRegisterFromFile(fp,NEC_IY);
393+ MacroLoadNecRegisterFromFile(fp,NEC_BP);
394+ MacroLoadNecRegisterFromFile(fp,NEC_SP);
395+ MacroLoadNecRegisterFromFile(fp,NEC_FLAGS);
396+ MacroLoadNecRegisterFromFile(fp,NEC_VECTOR);
397+ MacroLoadNecRegisterFromFile(fp,NEC_PENDING);
398+ MacroLoadNecRegisterFromFile(fp,NEC_NMI_STATE);
399+ MacroLoadNecRegisterFromFile(fp,NEC_IRQ_STATE);
400400 fread(IRAM, sizeof(BYTE), 0x10000, fp);
401401 fread(IO, sizeof(BYTE), 0x100, fp);
402402 for (i =0; i < RAMBanks; i++)
@@ -410,55 +410,55 @@
410410 fread(RAMMap[i], 1, 0x10000, fp);
411411 }
412412 }
413- fread(Palette, sizeof(WORD), 16 * 16, fp);
413+ fread(Palette, sizeof(WORD), 16 * 16, fp);
414414 fclose(fp);
415- WriteIO(0xC1, IO[0xC1]);
416- WriteIO(0xC2, IO[0xC2]);
417- WriteIO(0xC3, IO[0xC3]);
418- WriteIO(0xC0, IO[0xC0]);
419- for (i = 0x80; i <= 0x90; i++)
420- {
421- WriteIO(i, IO[i]);
422- }
415+ WriteIO(0xC1, IO[0xC1]);
416+ WriteIO(0xC2, IO[0xC2]);
417+ WriteIO(0xC3, IO[0xC3]);
418+ WriteIO(0xC0, IO[0xC0]);
419+ for (i = 0x80; i <= 0x90; i++)
420+ {
421+ WriteIO(i, IO[i]);
422+ }
423423 }
424424
425425 #define MacroStoreNecRegisterToFile(F,R) \
426- value = nec_get_reg(R); \
427- fwrite(&value, sizeof(unsigned int), 1, fp);
426+ value = nec_get_reg(R); \
427+ fwrite(&value, sizeof(unsigned int), 1, fp);
428428 void WsSaveState(int num)
429429 {
430430 FILE* fp;
431431 wchar_t buf[512];
432- unsigned int value;
433- int i;
432+ unsigned int value;
433+ int i;
434434
435- if (StateName[0] == 0)
436- {
437- return;
438- }
439- wsprintf(buf, L"%s.%03d", StateName, num);
435+ if (StateName[0] == 0)
436+ {
437+ return;
438+ }
439+ wsprintf(buf, L"%s.%03d", StateName, num);
440440 if ((fp = _wfopen(buf, L"wb")) == NULL)
441441 {
442- return;
443- }
444- MacroStoreNecRegisterToFile(fp,NEC_IP);
445- MacroStoreNecRegisterToFile(fp,NEC_AW);
446- MacroStoreNecRegisterToFile(fp,NEC_BW);
447- MacroStoreNecRegisterToFile(fp,NEC_CW);
448- MacroStoreNecRegisterToFile(fp,NEC_DW);
449- MacroStoreNecRegisterToFile(fp,NEC_CS);
450- MacroStoreNecRegisterToFile(fp,NEC_DS);
451- MacroStoreNecRegisterToFile(fp,NEC_ES);
452- MacroStoreNecRegisterToFile(fp,NEC_SS);
453- MacroStoreNecRegisterToFile(fp,NEC_IX);
454- MacroStoreNecRegisterToFile(fp,NEC_IY);
455- MacroStoreNecRegisterToFile(fp,NEC_BP);
456- MacroStoreNecRegisterToFile(fp,NEC_SP);
457- MacroStoreNecRegisterToFile(fp,NEC_FLAGS);
458- MacroStoreNecRegisterToFile(fp,NEC_VECTOR);
459- MacroStoreNecRegisterToFile(fp,NEC_PENDING);
460- MacroStoreNecRegisterToFile(fp,NEC_NMI_STATE);
461- MacroStoreNecRegisterToFile(fp,NEC_IRQ_STATE);
442+ return;
443+ }
444+ MacroStoreNecRegisterToFile(fp,NEC_IP);
445+ MacroStoreNecRegisterToFile(fp,NEC_AW);
446+ MacroStoreNecRegisterToFile(fp,NEC_BW);
447+ MacroStoreNecRegisterToFile(fp,NEC_CW);
448+ MacroStoreNecRegisterToFile(fp,NEC_DW);
449+ MacroStoreNecRegisterToFile(fp,NEC_CS);
450+ MacroStoreNecRegisterToFile(fp,NEC_DS);
451+ MacroStoreNecRegisterToFile(fp,NEC_ES);
452+ MacroStoreNecRegisterToFile(fp,NEC_SS);
453+ MacroStoreNecRegisterToFile(fp,NEC_IX);
454+ MacroStoreNecRegisterToFile(fp,NEC_IY);
455+ MacroStoreNecRegisterToFile(fp,NEC_BP);
456+ MacroStoreNecRegisterToFile(fp,NEC_SP);
457+ MacroStoreNecRegisterToFile(fp,NEC_FLAGS);
458+ MacroStoreNecRegisterToFile(fp,NEC_VECTOR);
459+ MacroStoreNecRegisterToFile(fp,NEC_PENDING);
460+ MacroStoreNecRegisterToFile(fp,NEC_NMI_STATE);
461+ MacroStoreNecRegisterToFile(fp,NEC_IRQ_STATE);
462462 fwrite(IRAM, sizeof(BYTE), 0x10000, fp);
463463 fwrite(IO, sizeof(BYTE), 0x100, fp);
464464 for (i =0; i < RAMBanks; i++)
@@ -472,7 +472,7 @@
472472 fwrite(RAMMap[i], 1, 0x10000, fp);
473473 }
474474 }
475- fwrite(Palette, sizeof(WORD), 16 * 16, fp);
475+ fwrite(Palette, sizeof(WORD), 16 * 16, fp);
476476 fclose(fp);
477477 }
478478
--- oswanj/trunk/src/WS.cpp (revision 87)
+++ oswanj/trunk/src/WS.cpp (revision 88)
@@ -156,7 +156,7 @@
156156
157157 static void WriteRom(DWORD A, BYTE V)
158158 {
159- //ErrorMsg(ERR_WRITE_ROM);
159+ //ErrorMsg(ERR_WRITE_ROM);
160160 }
161161
162162 static void WriteIRam(DWORD A, BYTE V)
@@ -172,109 +172,109 @@
172172 }
173173 }
174174
175-#define FLASH_CMD_ADDR1 0x0AAA
176-#define FLASH_CMD_ADDR2 0x0555
177-#define FLASH_CMD_DATA1 0xAA
178-#define FLASH_CMD_DATA2 0x55
179-#define FLASH_CMD_RESET 0xF0
180-#define FLASH_CMD_ERASE 0x80
181-#define FLASH_CMD_ERASE_CHIP 0x10
182-#define FLASH_CMD_ERASE_SECT 0x30
183-#define FLASH_CMD_CONTINUE_SET 0x20
184-#define FLASH_CMD_CONTINUE_RES1 0x90
185-#define FLASH_CMD_CONTINUE_RES2 0xF0
186-#define FLASH_CMD_CONTINUE_RES3 0x00
187-#define FLASH_CMD_WRITE 0xA0
175+#define FLASH_CMD_ADDR1 0x0AAA
176+#define FLASH_CMD_ADDR2 0x0555
177+#define FLASH_CMD_DATA1 0xAA
178+#define FLASH_CMD_DATA2 0x55
179+#define FLASH_CMD_RESET 0xF0
180+#define FLASH_CMD_ERASE 0x80
181+#define FLASH_CMD_ERASE_CHIP 0x10
182+#define FLASH_CMD_ERASE_SECT 0x30
183+#define FLASH_CMD_CONTINUE_SET 0x20
184+#define FLASH_CMD_CONTINUE_RES1 0x90
185+#define FLASH_CMD_CONTINUE_RES2 0xF0
186+#define FLASH_CMD_CONTINUE_RES3 0x00
187+#define FLASH_CMD_WRITE 0xA0
188188 static void WriteCRam(DWORD A, BYTE V)
189189 {
190- static int flashCommand1 = 0;
191- static int flashCommand2 = 0;
192- static int flashWriteSet = 0;
193- static int flashWriteOne = 0;
194- static int flashWriteReset = 0;
195- static int flashWriteEnable = 0;
196- int offset = A & 0xFFFF;
190+ static int flashCommand1 = 0;
191+ static int flashCommand2 = 0;
192+ static int flashWriteSet = 0;
193+ static int flashWriteOne = 0;
194+ static int flashWriteReset = 0;
195+ static int flashWriteEnable = 0;
196+ int offset = A & 0xFFFF;
197197
198198 if (offset >= RAMSize)
199199 {
200200 ErrorMsg(ERR_OVER_RAMSIZE);
201201 }
202- // WonderWitch
203- // FLASH ROM command sequence
204- if (flashCommand2)
205- {
206- if (offset == FLASH_CMD_ADDR1)
207- {
208- switch (V) {
209- case FLASH_CMD_CONTINUE_SET:
210- flashWriteSet = 1;
211- flashWriteReset = 0;
212- break;
213- case FLASH_CMD_WRITE:
214- flashWriteOne = 1;
215- break;
216- case FLASH_CMD_RESET:
217- break;
218- case FLASH_CMD_ERASE:
219- break;
220- case FLASH_CMD_ERASE_CHIP:
221- break;
222- case FLASH_CMD_ERASE_SECT:
223- break;
224- }
225- }
226- flashCommand2 = 0;
227- }
228- else if (flashCommand1)
229- {
230- if (offset == FLASH_CMD_ADDR2 && V == FLASH_CMD_DATA2)
231- {
232- flashCommand2 = 1;
233- }
234- flashCommand1 = 0;
235- }
236- else if (offset == FLASH_CMD_ADDR1 && V == FLASH_CMD_DATA1)
237- {
238- flashCommand1 = 1;
239- }
240- if (RAMSize != 0x40000 || BNK1SEL < 8)
241- {
242- // normal sram
243- Page[1][offset] = V;
244- }
245- else if (BNK1SEL >= 8 && BNK1SEL < 15)
246- {
247- // FLASH ROM use SRAM bank(port 0xC1:8-14)(0xC1:15 0xF0000-0xFFFFF are write protected)
248- if (flashWriteEnable || flashWriteOne)
249- {
250- Page[BNK1SEL][offset] = V;
251- flashWriteEnable = 0;
252- flashWriteOne = 0;
253- }
254- else if (flashWriteSet)
255- {
256- switch (V)
257- {
258- case FLASH_CMD_WRITE:
259- flashWriteEnable = 1;
260- flashWriteReset = 0;
261- break;
262- case FLASH_CMD_CONTINUE_RES1:
263- flashWriteReset = 1;
264- break;
265- case FLASH_CMD_CONTINUE_RES2:
266- case FLASH_CMD_CONTINUE_RES3:
267- if (flashWriteReset)
268- {
269- flashWriteSet = 0;
270- flashWriteReset = 0;
271- }
272- break;
273- default:
274- flashWriteReset = 0;
275- }
276- }
277- }
202+ // WonderWitch
203+ // FLASH ROM command sequence
204+ if (flashCommand2)
205+ {
206+ if (offset == FLASH_CMD_ADDR1)
207+ {
208+ switch (V) {
209+ case FLASH_CMD_CONTINUE_SET:
210+ flashWriteSet = 1;
211+ flashWriteReset = 0;
212+ break;
213+ case FLASH_CMD_WRITE:
214+ flashWriteOne = 1;
215+ break;
216+ case FLASH_CMD_RESET:
217+ break;
218+ case FLASH_CMD_ERASE:
219+ break;
220+ case FLASH_CMD_ERASE_CHIP:
221+ break;
222+ case FLASH_CMD_ERASE_SECT:
223+ break;
224+ }
225+ }
226+ flashCommand2 = 0;
227+ }
228+ else if (flashCommand1)
229+ {
230+ if (offset == FLASH_CMD_ADDR2 && V == FLASH_CMD_DATA2)
231+ {
232+ flashCommand2 = 1;
233+ }
234+ flashCommand1 = 0;
235+ }
236+ else if (offset == FLASH_CMD_ADDR1 && V == FLASH_CMD_DATA1)
237+ {
238+ flashCommand1 = 1;
239+ }
240+ if (RAMSize != 0x40000 || BNK1SEL < 8)
241+ {
242+ // normal sram
243+ Page[1][offset] = V;
244+ }
245+ else if (BNK1SEL >= 8 && BNK1SEL < 15)
246+ {
247+ // FLASH ROM use SRAM bank(port 0xC1:8-14)(0xC1:15 0xF0000-0xFFFFF are write protected)
248+ if (flashWriteEnable || flashWriteOne)
249+ {
250+ Page[BNK1SEL][offset] = V;
251+ flashWriteEnable = 0;
252+ flashWriteOne = 0;
253+ }
254+ else if (flashWriteSet)
255+ {
256+ switch (V)
257+ {
258+ case FLASH_CMD_WRITE:
259+ flashWriteEnable = 1;
260+ flashWriteReset = 0;
261+ break;
262+ case FLASH_CMD_CONTINUE_RES1:
263+ flashWriteReset = 1;
264+ break;
265+ case FLASH_CMD_CONTINUE_RES2:
266+ case FLASH_CMD_CONTINUE_RES3:
267+ if (flashWriteReset)
268+ {
269+ flashWriteSet = 0;
270+ flashWriteReset = 0;
271+ }
272+ break;
273+ default:
274+ flashWriteReset = 0;
275+ }
276+ }
277+ }
278278 }
279279
280280 void WriteIO(DWORD A, BYTE V)
@@ -295,12 +295,12 @@
295295 if (V & 0x01)
296296 {
297297 Segment[8] = 1;
298- RenderSleep();
298+ RenderSleep();
299299 }
300- else
301- {
300+ else
301+ {
302302 Segment[8] = 0;
303- }
303+ }
304304 if (V & 0x02)
305305 {
306306 SetDrawMode(1);
@@ -323,26 +323,26 @@
323323 {
324324 Segment[2] = 1;
325325 }
326- else
327- {
326+ else
327+ {
328328 Segment[2] = 0;
329- }
329+ }
330330 if (V & 0x10)
331331 {
332332 Segment[1] = 1;
333333 }
334- else
335- {
334+ else
335+ {
336336 Segment[1] = 0;
337- }
337+ }
338338 if (V & 0x20)
339339 {
340340 Segment[0] = 1;
341341 }
342- else
343- {
342+ else
343+ {
344344 Segment[0] = 0;
345- }
345+ }
346346 break;
347347 case 0x1C:
348348 case 0x1D:
@@ -502,12 +502,12 @@
502502 break;
503503 case 0xA4:
504504 case 0xA5:
505- IO[A] = V;
505+ IO[A] = V;
506506 HTimer = HPRE; // FF
507507 return;
508508 case 0xA6:
509509 case 0xA7:
510- IO[A] = V;
510+ IO[A] = V;
511511 IO[A + 4] = V; // Dark eyes
512512 if(TIMCTL & 0x04)
513513 {
@@ -554,18 +554,18 @@
554554 Page[0xF] = ROMMap[0xF | j];
555555 break;
556556 case 0xC1:
557- if (V >= 8) // WonderWitch
558- {
559- Page[1] = MemDummy;
560- }
557+ if (V >= 8) // WonderWitch
558+ {
559+ Page[1] = MemDummy;
560+ }
561561 else if (V >= RAMBanks)
562- {
563- RAMEnable = 0;
564- }
562+ {
563+ RAMEnable = 0;
564+ }
565565 else
566- {
567- Page[1] = RAMMap[V];
568- }
566+ {
567+ Page[1] = RAMMap[V];
568+ }
569569 break;
570570 case 0xC2:
571571 Page[2] = ROMMap[V];
@@ -783,10 +783,10 @@
783783 IRAM[0x75B3]=0x31;
784784 apuWaveClear();
785785 ButtonState = 0x0000;
786- for (i = 0; i < 11; i++)
787- {
788- Segment[i] = 0;
789- }
786+ for (i = 0; i < 11; i++)
787+ {
788+ Segment[i] = 0;
789+ }
790790 nec_reset(NULL);
791791 nec_set_reg(NEC_SP, 0x2000);
792792 }
@@ -847,8 +847,8 @@
847847 break;
848848 case 2:
849849 // Hblank毎に1サンプルセットすることで12KHzのwaveデータが出来る
850- apuWaveSet();
851- NCSR = apuShiftReg();
850+ apuWaveSet();
851+ NCSR = apuShiftReg();
852852 break;
853853 case 4:
854854 if(RSTRL == 140)
@@ -995,10 +995,10 @@
995995 Sleep(300);
996996 apuStartupSound();
997997 Sleep(150);
998- Segment[3] = 1;
999- Segment[5] = 1;
1000- Segment[9] = 1;
1001- Segment[10] = 1;
998+ Segment[3] = 1;
999+ Segment[5] = 1;
1000+ Segment[9] = 1;
1001+ Segment[10] = 1;
10021002 for (i = 0; i < 6; i++)
10031003 {
10041004 WORD color[6] = {0xFF00, 0xFF80, 0xFFF0, 0xF0F0, 0xF0FF, 0xF00F};
@@ -1110,9 +1110,9 @@
11101110 }
11111111 }
11121112 }
1113- Segment[3] = 0;
1114- Segment[5] = 0;
1115- Segment[9] = 0;
1113+ Segment[3] = 0;
1114+ Segment[5] = 0;
1115+ Segment[9] = 0;
11161116 drawDraw();
11171117 }
11181118
--- oswanj/trunk/src/WSRender.cpp (revision 87)
+++ oswanj/trunk/src/WSRender.cpp (revision 88)
@@ -763,39 +763,39 @@
763763 */
764764 void RenderSegment(void)
765765 {
766- int bit, x, y, i;
767- WORD* p = SegmentBuffer;
768- BYTE lcd[11] = {0x20, 0x10, 0x08, 0x04, 0x02, 0x40, 0, 0, 0x01, 0x80, 0}; // 大、中、小、横、縦、ヘッドホン、音量、電池、スリープ
766+ int bit, x, y, i;
767+ WORD* p = SegmentBuffer;
768+ BYTE lcd[11] = {0x20, 0x10, 0x08, 0x04, 0x02, 0x40, 0, 0, 0x01, 0x80, 0}; // 大、中、小、横、縦、ヘッドホン、音量、電池、スリープ
769769
770- for (i = 0; i < 11; i++)
771- {
772- for (y = 0; y < segLine[i]; y++)
773- {
774- for (x = 0; x < 4; x++)
775- {
776- BYTE ch = seg[i][y * 4 + x];
777- for (bit = 0; bit < 8; bit++)
778- {
779- if (ch & 0x80)
780- {
781- if (Segment[i])
782- {
783- *p++ = 0xFCCC;
784- }
785- else
786- {
787- *p++ = 0xF222;
788- }
789- }
790- else
791- {
792- *p++ = 0xF000;
793- }
794- ch <<= 1;
795- }
796- }
797- }
798- }
770+ for (i = 0; i < 11; i++)
771+ {
772+ for (y = 0; y < segLine[i]; y++)
773+ {
774+ for (x = 0; x < 4; x++)
775+ {
776+ BYTE ch = seg[i][y * 4 + x];
777+ for (bit = 0; bit < 8; bit++)
778+ {
779+ if (ch & 0x80)
780+ {
781+ if (Segment[i])
782+ {
783+ *p++ = 0xFCCC;
784+ }
785+ else
786+ {
787+ *p++ = 0xF222;
788+ }
789+ }
790+ else
791+ {
792+ *p++ = 0xF000;
793+ }
794+ ch <<= 1;
795+ }
796+ }
797+ }
798+ }
799799 }
800800
801801 void RenderSleep(void)
Show on old repository browser