1 /*
2 TiMidity++ -- MIDI to WAVE converter and player
3 Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4 Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 w32g_subwin2.c: Written by Daisuke Aoki <dai@y7.net>
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif /* HAVE_CONFIG_H */
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <process.h>
29 #include <stddef.h>
30 #ifndef NO_STRING_H
31 #include <string.h>
32 #else
33 #include <strings.h>
34 #endif
35
36 #include "timidity.h"
37 #include "common.h"
38 #include "instrum.h"
39 #include "playmidi.h"
40 #include "readmidi.h"
41 #include "output.h"
42 #include "controls.h"
43 #include "tables.h"
44 #include "miditrace.h"
45 #include "reverb.h"
46 #ifdef SUPPORT_SOUNDSPEC
47 #include "soundspec.h"
48 #endif /* SUPPORT_SOUNDSPEC */
49 #include "recache.h"
50 #include "arc.h"
51 #include "strtab.h"
52 #include "wrd.h"
53 #include "mid.defs"
54
55 #include "w32g.h"
56 #include <shlobj.h>
57 #include <commctrl.h>
58 #include <windowsx.h>
59 #include "w32g_res.h"
60 #include "w32g_utl.h"
61 #include "w32g_pref.h"
62 #include "w32g_subwin.h"
63 #include "w32g_ut2.h"
64
65 #include "w32g_dib.h"
66 #include "w32g_wrd.h"
67 #include "w32g_mag.h"
68
69 extern int gdi_lock_ex ( DWORD timeout );
70 #if 0
71 static int gdi_lock_result;
72 #define GDI_LOCK_EX(timeout) ( \
73 ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "GDI_LOCK_EX(%s: %d)", __FILE__, __LINE__ ), \
74 gdi_lock_result = gdi_lock_ex(timeout), \
75 ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "GDI_LOCK_EX_RESULT(%d)", gdi_lock_result ), \
76 gdi_lock_result \
77 )
78 #define GDI_LOCK() { \
79 ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "GDI_LOCK(%s: %d)", __FILE__, __LINE__ ); \
80 gdi_lock(); \
81 }
82 #define GDI_UNLOCK() { \
83 ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "GDI_UNLOCK(%s: %d)", __FILE__, __LINE__ ); \
84 gdi_unlock(); \
85 }
86 #else
87 #define GDI_LOCK() { gdi_lock(); }
88 #define GDI_LOCK_EX(timeout) gdi_lock_ex(timeout)
89 #define GDI_UNLOCK() { gdi_unlock(); }
90 #endif
91
92 #if defined(__CYGWIN32__) || defined(__MINGW32__)
93 #ifndef TPM_TOPALIGN
94 #define TPM_TOPALIGN 0x0000L
95 #endif
96 #endif
97
98 extern void VprintfEditCtlWnd(HWND hwnd, char *fmt, va_list argList);
99 extern void PrintfEditCtlWnd(HWND hwnd, char *fmt, ...);
100 extern void PutsEditCtlWnd(HWND hwnd, char *str);
101 extern void ClearEditCtlWnd(HWND hwnd);
102
103 #ifndef _mbbtype
104 #ifndef _MBC_SINGLE
105 #define _MBC_SINGLE (0)
106 #endif
107 #ifndef _MBC_LEAD
108 #define _MBC_LEAD (1)
109 #endif
110 #ifndef _MBC_TRAIL
111 #define _MBC_TRAIL (2)
112 #endif
113 #ifndef _MBC_ILLEGAL
114 #define _MBC_ILLEGAL (-1)
115 #endif
116 #define is_sjis_kanji1(x) ((((unsigned char)(x))>=0x81 && ((unsigned char)(x))<=0x9f) || (((unsigned char)(x))>=0xe0 && ((unsigned char)(x))<=0xfc))
117 #define is_sjis_kanji2(x) ((((unsigned char)(x))>=0x40 && ((unsigned char)(x))<=0x7e) || (((unsigned char)(x))>=0x80 && ((unsigned char)(x))<=0xfc))
___sjis_mbbtype(unsigned char c,int mbtype)118 static int ___sjis_mbbtype(unsigned char c, int mbtype)
119 {
120 if(mbtype==_MBC_LEAD){
121 if(is_sjis_kanji2(c)) return _MBC_TRAIL; else return _MBC_ILLEGAL;
122 } else { if(is_sjis_kanji1(c)) return _MBC_LEAD; else return _MBC_SINGLE; }
123 }
_mbbtype(unsigned char c,int mbtype)124 static int _mbbtype(unsigned char c, int mbtype)
125 {
126 return ___sjis_mbbtype(c,mbtype);
127 }
128 #endif
129
130
131 static RGBQUAD RGBtoRGBQUAD ( COLORREF color );
132 static COLORREF RGBQUADtoRGB ( RGBQUAD rq );
133
134 // ****************************************************************************
135 // Wrd Window
136
137 #define MAG_WORK_WIDTH 800
138 #define MAG_WORK_HEIGHT 640
139
140 #define COLOR_MASK_WHITE RGB(0xFF,0xFF,0xFF)
141 #define COLOR_MASK_BLACK RGB(0x00,0x00,0x00)
142
143 WRDWNDINFO WrdWndInfo;
144
145 static int WrdWndInfoReset(HWND hwnd);
146 static int WrdWndInfoApply(void);
147
148 w32g_wrd_wnd_t w32g_wrd_wnd;
149
SetWrdWndActive(void)150 BOOL SetWrdWndActive(void)
151 {
152 if ( IsWindowVisible(hWrdWnd) ) {
153 w32g_wrd_wnd.active = TRUE;
154 } else {
155 w32g_wrd_wnd.active = FALSE;
156 }
157 return w32g_wrd_wnd.active;
158 }
159
160 static void wrd_graphic_terminate ( void );
161 static void wrd_graphic_init ( HDC hdc );
162 static void wrd_graphic_tone_change ( int index, int tone );
163 static void wrd_graphic_set_pal ( int index, int pal_index, COLORREF color );
164 static void wrd_graphic_plane_change ( int active, int display );
165 static void wrd_graphic_reset ( int index );
166 static void wrd_graphic_reset_all ( void );
167 static void wrd_graphic_apply ( RECT *lprc, int index, int lockflag );
168 static void wrd_graphic_update ( RECT *lprc, int lockflag );
169 static void wrd_text_update ( int x_from, int y_from, int x_to, int y_to, int lockflag );
170
171 static int volatile wrd_graphic_pal_init_flag = 0;
172
173 static HANDLE volatile hMutexWrd = NULL;
wrd_wnd_lock_ex(DWORD timeout)174 static BOOL wrd_wnd_lock_ex ( DWORD timeout )
175 {
176 if ( hMutexWrd == NULL ) {
177 hMutexWrd = CreateMutex ( NULL, FALSE, NULL );
178 if ( hMutexWrd == NULL )
179 return FALSE;
180 }
181 if ( WaitForSingleObject ( hMutexWrd, timeout )== WAIT_FAILED ) {
182 return FALSE;
183 }
184 return TRUE;
185 }
wrd_wnd_lock(void)186 static BOOL wrd_wnd_lock (void)
187 {
188 return wrd_wnd_lock_ex ( INFINITE );
189 }
wrd_wnd_unlock(void)190 static void wrd_wnd_unlock (void)
191 {
192 ReleaseMutex ( hMutexWrd );
193 }
194
195
196 BOOL CALLBACK WrdWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
197 BOOL CALLBACK WrdCanvasWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam);
198 static int volatile wrd_wnd_initflag = 1;
TerminateWrdWnd(void)199 void TerminateWrdWnd ( void )
200 {
201 wrd_wnd_lock();
202 w32g_wrd_wnd.active = FALSE;
203 if ( !wrd_wnd_initflag ) {
204 DeleteDC ( w32g_wrd_wnd.hmdc );
205 DeleteObject ( (HGDIOBJ) w32g_wrd_wnd.hbitmap );
206 DeleteObject ( (HGDIOBJ) w32g_wrd_wnd.hbmp_tmask );
207 DeleteObject ( (HGDIOBJ) w32g_wrd_wnd.hbmp_work );
208 DeleteObject ( (HGDIOBJ) w32g_wrd_wnd.hNullBrush );
209 DeleteObject ( (HGDIOBJ) w32g_wrd_wnd.hNullPen );
210 }
211 wrd_graphic_terminate ();
212 memset ( &w32g_wrd_wnd, 0, sizeof (w32g_wrd_wnd_t) );
213 wrd_wnd_unlock();
214 }
InitWrdWnd(HWND hParentWnd)215 void InitWrdWnd(HWND hParentWnd)
216 {
217 WNDCLASS wndclass ;
218 HICON hIcon;
219
220 wrd_wnd_lock();
221 if ( wrd_wnd_initflag ) {
222 memset ( &w32g_wrd_wnd, 0, sizeof (w32g_wrd_wnd_t) );
223 wrd_wnd_initflag = 0;
224 }
225 if (hWrdWnd != NULL) {
226 DestroyWindow(hWrdWnd);
227 hWrdWnd = NULL;
228 }
229 TerminateWrdWnd ();
230
231 INILoadWrdWnd();
232
233 w32g_wrd_wnd.hNullBrush = GetStockObject ( NULL_BRUSH );
234 w32g_wrd_wnd.hNullPen = GetStockObject ( NULL_PEN );
235
236 hWrdWnd = CreateDialog
237 (hInst,MAKEINTRESOURCE(IDD_DIALOG_WRD),hParentWnd,WrdWndProc);
238 WrdWndInfoReset(hWrdWnd);
239 INILoadWrdWnd();
240 ShowWindow(hWrdWnd,SW_HIDE);
241 w32g_wrd_wnd.draw_skip = 0;
242 w32g_wrd_wnd.font_height = 16;
243 w32g_wrd_wnd.font_width = 8;
244 w32g_wrd_wnd.row = 80;
245 w32g_wrd_wnd.col = 25;
246 w32g_wrd_wnd.width = w32g_wrd_wnd.font_width * w32g_wrd_wnd.row;
247 w32g_wrd_wnd.height = w32g_wrd_wnd.font_height * w32g_wrd_wnd.col;
248 w32g_wrd_wnd.pals[W32G_WRDWND_BLACK] = RGB ( 0x00, 0x00, 0x00 );
249 w32g_wrd_wnd.pals[W32G_WRDWND_RED] = RGB ( 0xFF, 0x00, 0x00 );
250 w32g_wrd_wnd.pals[W32G_WRDWND_BLUE] = RGB ( 0x00, 0x00, 0xFF );
251 w32g_wrd_wnd.pals[W32G_WRDWND_PURPLE] = RGB ( 0xFF, 0x00, 0xFF );
252 w32g_wrd_wnd.pals[W32G_WRDWND_GREEN] = RGB ( 0x00, 0xFF, 0x00 );
253 w32g_wrd_wnd.pals[W32G_WRDWND_LIGHTBLUE] = RGB ( 0x00, 0xFF, 0xFF );
254 w32g_wrd_wnd.pals[W32G_WRDWND_YELLOW] = RGB ( 0xFF, 0xFF, 0xFF );
255 w32g_wrd_wnd.pals[W32G_WRDWND_WHITE] = RGB ( 0xFF, 0xFF, 0xFF );
256 w32g_wrd_wnd.flag = WRD_FLAG_DEFAULT;
257
258 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_CLASSDC;
259 wndclass.lpfnWndProc = WrdCanvasWndProc ;
260 wndclass.cbClsExtra = 0 ;
261 wndclass.cbWndExtra = 0 ;
262 wndclass.hInstance = hInst ;
263 wndclass.hIcon = NULL;
264 wndclass.hCursor = LoadCursor(0,IDC_ARROW) ;
265 // wndclass.hbrBackground = (HBRUSH)(COLOR_SCROLLBAR + 1);
266 wndclass.hbrBackground = w32g_wrd_wnd.hNullBrush;
267 wndclass.lpszMenuName = NULL;
268 wndclass.lpszClassName = "wrd canvas wnd";
269 RegisterClass(&wndclass);
270 w32g_wrd_wnd.hwnd = CreateWindowEx(0,"wrd canvas wnd",0,WS_CHILD,
271 CW_USEDEFAULT,0,w32g_wrd_wnd.width,w32g_wrd_wnd.height,
272 hWrdWnd,0,hInst,0);
273 w32g_wrd_wnd.hdc = GetDC(w32g_wrd_wnd.hwnd);
274
275 // �匳
276 w32g_wrd_wnd.hbitmap = CreateCompatibleBitmap(w32g_wrd_wnd.hdc,w32g_wrd_wnd.width,w32g_wrd_wnd.height);
277 w32g_wrd_wnd.hmdc = CreateCompatibleDC(w32g_wrd_wnd.hdc);
278 w32g_wrd_wnd.hgdiobj_hmdcprev = SelectObject(w32g_wrd_wnd.hmdc,w32g_wrd_wnd.hbitmap);
279 SelectObject ( w32g_wrd_wnd.hmdc, w32g_wrd_wnd.hNullBrush );
280 SelectObject ( w32g_wrd_wnd.hmdc, w32g_wrd_wnd.hNullPen );
281
282 // ���[�N
283 w32g_wrd_wnd.hbmp_work = CreateCompatibleBitmap(w32g_wrd_wnd.hdc,w32g_wrd_wnd.width,w32g_wrd_wnd.height);
284
285 // �e�L�X�g�}�X�N
286 // w32g_wrd_wnd.hbmp_tmask = CreateBitmap ( w32g_wrd_wnd.width, w32g_wrd_wnd.height, 1, 1, NULL);
287 w32g_wrd_wnd.hbmp_tmask = CreateCompatibleBitmap(w32g_wrd_wnd.hdc,w32g_wrd_wnd.width,w32g_wrd_wnd.height);
288 {
289 HDC hmdc;
290 RECT rc;
291 HBRUSH hbrush = CreateSolidBrush ( COLOR_MASK_BLACK );
292 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
293 hmdc = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
294 SelectObject ( hmdc, w32g_wrd_wnd.hbmp_tmask );
295 FillRect ( hmdc, &rc, hbrush );
296 SelectObject ( hmdc, w32g_wrd_wnd.hbmp_work );
297 FillRect ( hmdc, &rc, hbrush );
298 DeleteDC ( hmdc );
299 DeleteObject ( hbrush );
300 }
301
302 // �O���t�B�b�N
303 wrd_graphic_init ( w32g_wrd_wnd.hdc );
304
305 ReleaseDC(w32g_wrd_wnd.hwnd,w32g_wrd_wnd.hdc);
306
307 {
308 char fontname[1024];
309 if ( PlayerLanguage == LANGUAGE_JAPANESE )
310 strcpy(fontname,"�l�r ����");
311 else
312 strcpy(fontname,"Times New Roman");
313 w32g_wrd_wnd.hFont = CreateFont(w32g_wrd_wnd.font_height,w32g_wrd_wnd.font_width,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,
314 DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
315 FIXED_PITCH | FF_MODERN ,fontname);
316 }
317 hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_TIMIDITY), IMAGE_ICON, 16, 16, 0);
318 if (hIcon!=NULL) SendMessage(hWrdWnd,WM_SETICON,FALSE,(LPARAM)hIcon);
319 wrd_wnd_unlock();
320
321 WrdWndReset();
322 w32g_wrd_wnd.active = FALSE;
323 MoveWindow(w32g_wrd_wnd.hwnd,0,0,w32g_wrd_wnd.width,w32g_wrd_wnd.height,TRUE);
324 WrdWndClear ( TRUE );
325 ShowWindow(w32g_wrd_wnd.hwnd,SW_SHOW);
326 UpdateWindow(w32g_wrd_wnd.hwnd);
327 UpdateWindow(hWrdWnd);
328 WrdWndInfoApply();
329 }
330
wrd_graphic_terminate(void)331 static void wrd_graphic_terminate ( void )
332 {
333 int index;
334 wrd_wnd_lock();
335 GdiFlush ();
336 for ( index = 0; index < W32G_WRDWND_GRAPHIC_PLANE_MAX; index++ ) {
337 if ( w32g_wrd_wnd.graphic_dib[index] != NULL ) {
338 dib_free ( w32g_wrd_wnd.graphic_dib[index] );
339 w32g_wrd_wnd.graphic_dib[index] = NULL;
340 }
341 }
342 if ( w32g_wrd_wnd.bits_mag_work != NULL )
343 free ( w32g_wrd_wnd.bits_mag_work );
344 wrd_wnd_unlock();
345 }
346
347 // �v���[�� index �̃O���t�B�b�N�̏�����
wrd_graphic_init(HDC hdc)348 static void wrd_graphic_init ( HDC hdc )
349 {
350 int index;
351
352 wrd_wnd_lock();
353 wrd_graphic_terminate ();
354 for ( index = 0; index < W32G_WRDWND_GRAPHIC_PLANE_MAX; index++ ) {
355 w32g_wrd_wnd.graphic_dib[index] = dib_create ( w32g_wrd_wnd.width, w32g_wrd_wnd.height );
356 w32g_wrd_wnd.modified_graphic[index] = TRUE;
357 }
358
359 w32g_wrd_wnd.bits_mag_work = (char *) safe_malloc ( MAG_WORK_WIDTH * MAG_WORK_HEIGHT );
360
361 w32g_wrd_wnd.index_active = 0;
362 w32g_wrd_wnd.index_display = 0;
363 wrd_wnd_unlock();
364 wrd_graphic_reset_all ();
365 }
366
wrd_graphic_plane_change(int active,int display)367 static void wrd_graphic_plane_change ( int active, int display )
368 {
369 wrd_wnd_lock();
370 w32g_wrd_wnd.index_active = active;
371 w32g_wrd_wnd.index_display = display;
372 wrd_wnd_unlock();
373 }
374
wrd_graphic_reset(int index)375 static void wrd_graphic_reset ( int index )
376 {
377 RECT rc;
378
379 wrd_wnd_lock();
380 memset ( w32g_wrd_wnd.graphic_dib[index]->bits, 0, w32g_wrd_wnd.graphic_dib[index]->width * w32g_wrd_wnd.graphic_dib[index]->height );
381 dib_set_pals ( w32g_wrd_wnd.graphic_dib[index], w32g_wrd_wnd.default_gpal, W32G_WRDWND_GRAPHIC_PALLETE_MAX );
382 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
383 w32g_wrd_wnd.modified_graphic[index] = TRUE;
384 wrd_wnd_unlock();
385 wrd_graphic_apply ( &rc, index, TRUE );
386 }
387
wrd_graphic_reset_all(void)388 static void wrd_graphic_reset_all ( void )
389 {
390 int i;
391
392 wrd_wnd_lock();
393 w32g_wrd_wnd.default_gpal[0] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));
394 w32g_wrd_wnd.default_gpal[1] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x7F ) );
395 w32g_wrd_wnd.default_gpal[2] = RGBtoRGBQUAD (RGB ( 0x7F, 0x00, 0x00 ));
396 w32g_wrd_wnd.default_gpal[3] = RGBtoRGBQUAD (RGB ( 0x7F, 0x00, 0x7F ));
397 w32g_wrd_wnd.default_gpal[4] = RGBtoRGBQUAD (RGB ( 0x00, 0x7F, 0x00 ));
398 w32g_wrd_wnd.default_gpal[5] = RGBtoRGBQUAD (RGB ( 0x00, 0x7F, 0x7F ));
399 w32g_wrd_wnd.default_gpal[6] = RGBtoRGBQUAD (RGB ( 0x7F, 0x7F, 0x00 ));
400 w32g_wrd_wnd.default_gpal[7] = RGBtoRGBQUAD (RGB ( 0x7F, 0x7F, 0x7F ));
401 w32g_wrd_wnd.default_gpal[8] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));
402 w32g_wrd_wnd.default_gpal[9] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0xFF ));
403 w32g_wrd_wnd.default_gpal[10] = RGBtoRGBQUAD (RGB ( 0xFF, 0x00, 0x00 ));
404 w32g_wrd_wnd.default_gpal[11] = RGBtoRGBQUAD (RGB ( 0xFF, 0x00, 0xFF ));
405 w32g_wrd_wnd.default_gpal[12] = RGBtoRGBQUAD (RGB ( 0x00, 0xFF, 0x00 ));
406 w32g_wrd_wnd.default_gpal[13] = RGBtoRGBQUAD (RGB ( 0x00, 0xFF, 0xFF ));
407 w32g_wrd_wnd.default_gpal[14] = RGBtoRGBQUAD (RGB ( 0xFF, 0xFF, 0x00 ));
408 w32g_wrd_wnd.default_gpal[15] = RGBtoRGBQUAD (RGB ( 0xFF, 0xFF, 0xFF ));
409 for ( i = 16; i < W32G_WRDWND_GRAPHIC_PALLETE_MAX; i++ )
410 w32g_wrd_wnd.default_gpal[i] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));
411 wrd_wnd_unlock();
412
413 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i ++ ) {
414 wrd_graphic_reset ( i );
415 }
416 wrd_wnd_lock();
417 w32g_wrd_wnd.gmode = 0xFFFF;
418 w32g_wrd_wnd.fade_from = -1;
419 w32g_wrd_wnd.fade_to = -1;
420 wrd_wnd_unlock();
421 }
422
423 // �v���[�� index �̃O���t�B�b�N�� lprc �̈�� hmdc_graphic �֍X�V
wrd_graphic_apply(RECT * lprc,int index,int lockflag)424 static void wrd_graphic_apply ( RECT *lprc, int index, int lockflag )
425 {
426 #if 0
427 if ( WrdWndInfo.GraphicStop ) return;
428 // if ( !w32g_wrd_wnd.modified_graphic[index] ) return;
429
430 if ( lockflag ) wrd_wnd_lock();
431 w32g_wrd_wnd.modified_graphic[index] = FALSE;
432 if ( lockflag ) wrd_wnd_unlock();
433 #endif
434 }
435
436 // lprc �̈�̃O���t�B�b�N���X�V
wrd_graphic_update(RECT * lprc,int lockflag)437 static void wrd_graphic_update ( RECT *lprc, int lockflag )
438 {
439 if ( WrdWndInfo.GraphicStop ) return;
440 if ( w32g_wrd_wnd.draw_skip ) return;
441 wrd_wnd_lock();
442 if ( lockflag ) GDI_LOCK();
443 // �摜�����������ōs���B
444 if ( w32g_wrd_wnd.flag & WRD_FLAG_GRAPHIC ) {
445 if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT ) {
446 HDC hmdc_work, hmdc_tmask, hmdc_graphic;
447 GdiFlush ();
448 hmdc_work = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
449 hmdc_tmask = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
450 hmdc_graphic = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
451 SelectObject ( hmdc_work, w32g_wrd_wnd.hbmp_work );
452 SelectObject ( hmdc_tmask, w32g_wrd_wnd.hbmp_tmask );
453 SelectObject ( hmdc_graphic, w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display]->hbmp );
454 BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,
455 hmdc_tmask, lprc->left, lprc->top, SRCAND );
456 BitBlt ( hmdc_work, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,
457 hmdc_tmask, lprc->left, lprc->top, NOTSRCCOPY );
458 BitBlt ( hmdc_work, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,
459 hmdc_graphic, lprc->left, lprc->top, SRCAND );
460 BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,
461 hmdc_work, lprc->left, lprc->top, SRCPAINT );
462 DeleteDC ( hmdc_work );
463 DeleteDC ( hmdc_tmask );
464 DeleteDC ( hmdc_graphic );
465 } else {
466 HDC hmdc_graphic;
467 hmdc_graphic = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
468 SelectObject ( hmdc_graphic, w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display]->hbmp );
469 BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,
470 hmdc_graphic, lprc->left, lprc->top, SRCCOPY );
471 DeleteDC ( hmdc_graphic );
472 }
473 }
474 if ( lockflag ) GDI_UNLOCK();
475 wrd_wnd_unlock();
476 }
477
478 // �̈�̃e�L�X�g���X�V
wrd_text_update(int x_from,int y_from,int x_to,int y_to,int lockflag)479 static void wrd_text_update ( int x_from, int y_from, int x_to, int y_to, int lockflag )
480 {
481 RECT rc;
482
483 if ( w32g_wrd_wnd.draw_skip ) return;
484
485 if ( x_from < 0 ) x_from = 0;
486 if ( x_from >= w32g_wrd_wnd.row ) x_from = w32g_wrd_wnd.row - 1;
487 if ( x_to < 0 ) x_to = 0;
488 if ( x_to >= w32g_wrd_wnd.row ) x_to = w32g_wrd_wnd.row - 1;
489 if ( y_from < 0 ) y_from = 0;
490 if ( y_from >= w32g_wrd_wnd.row ) y_from = w32g_wrd_wnd.col - 1;
491 if ( y_to < 0 ) y_to = 0;
492 if ( y_to >= w32g_wrd_wnd.row ) y_to = w32g_wrd_wnd.col - 1;
493
494 SetRect ( &rc, x_from * w32g_wrd_wnd.font_width, y_from * w32g_wrd_wnd.font_height,
495 (x_to+1) * w32g_wrd_wnd.font_width, (y_to+1) * w32g_wrd_wnd.font_height);
496
497 wrd_wnd_lock();
498 if ( lockflag ) GDI_LOCK();
499 if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT ) {
500 HDC hmdc_tmask;
501 COLORREF forecolor, backcolor, prevforecolor, prevbackcolor;
502 char attr;
503 HGDIOBJ hgdiobj;
504 int x, y;
505 forecolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.curforecolor];
506 backcolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.curbackcolor];
507 prevforecolor = SetTextColor( w32g_wrd_wnd.hmdc, forecolor );
508 prevbackcolor = SetBkColor( w32g_wrd_wnd.hmdc, backcolor );
509 hgdiobj = SelectObject( w32g_wrd_wnd.hmdc, w32g_wrd_wnd.hFont );
510 hmdc_tmask = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );
511 SelectObject( hmdc_tmask, w32g_wrd_wnd.hbmp_tmask );
512 SelectObject( hmdc_tmask, w32g_wrd_wnd.hFont );
513 SelectObject( hmdc_tmask, w32g_wrd_wnd.hNullBrush );
514 SelectObject( hmdc_tmask, w32g_wrd_wnd.hNullPen );
515 attr = 0;
516 SetTextColor( hmdc_tmask, COLOR_MASK_WHITE );
517 SetBkColor( hmdc_tmask, COLOR_MASK_BLACK );
518 for( y = y_from; y <= y_to; y++ ) {
519 for( x = x_from; x <= x_to; x++ ) {
520 char mbt = _MBC_SINGLE;
521 RECT rc_part;
522 if ( forecolor != w32g_wrd_wnd.pals[w32g_wrd_wnd.forecolorbuf[y][x]] ) {
523 forecolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.forecolorbuf[y][x]];
524 SetTextColor( w32g_wrd_wnd.hmdc, forecolor );
525 }
526 if ( backcolor != w32g_wrd_wnd.pals[w32g_wrd_wnd.backcolorbuf[y][x]] ) {
527 backcolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.backcolorbuf[y][x]];
528 SetBkColor( w32g_wrd_wnd.hmdc, backcolor );
529 }
530 if ( attr != w32g_wrd_wnd.attrbuf[y][x] ) {
531 if ( ( attr & W32G_WRDWND_ATTR_REVERSE ) != ( w32g_wrd_wnd.attrbuf[y][x] & W32G_WRDWND_ATTR_REVERSE ) ) {
532 if ( w32g_wrd_wnd.attrbuf[y][x] & W32G_WRDWND_ATTR_REVERSE ) {
533 SetTextColor( hmdc_tmask, COLOR_MASK_BLACK );
534 SetBkColor( hmdc_tmask, COLOR_MASK_WHITE );
535 } else {
536 SetTextColor( hmdc_tmask, COLOR_MASK_WHITE );
537 SetBkColor( hmdc_tmask, COLOR_MASK_BLACK );
538 }
539 }
540 attr = w32g_wrd_wnd.attrbuf[y][x];
541 }
542 if ( PlayerLanguage == LANGUAGE_JAPANESE && _mbbtype( w32g_wrd_wnd.textbuf[y][x], _MBC_SINGLE ) == _MBC_LEAD ) {
543 SetRect ( &rc_part, x * w32g_wrd_wnd.font_width, y * w32g_wrd_wnd.font_height,
544 (x + 2) * w32g_wrd_wnd.font_width, (y + 1) * w32g_wrd_wnd.font_height );
545 if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT )
546 ExtTextOut( w32g_wrd_wnd.hmdc, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 2, NULL);
547 ExtTextOut( hmdc_tmask, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 2, NULL);
548 x++;
549 } else {
550 SetRect ( &rc_part, x * w32g_wrd_wnd.font_width, y * w32g_wrd_wnd.font_height,
551 (x + 1) * w32g_wrd_wnd.font_width, (y + 1) * w32g_wrd_wnd.font_height );
552 if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT )
553 ExtTextOut( w32g_wrd_wnd.hmdc, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 1, NULL);
554 ExtTextOut( hmdc_tmask, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 1, NULL);
555 }
556 }
557 }
558 SetTextColor( w32g_wrd_wnd.hmdc, prevforecolor);
559 SetBkColor( w32g_wrd_wnd.hmdc, prevbackcolor);
560 SelectObject( w32g_wrd_wnd.hmdc, hgdiobj );
561 DeleteDC ( hmdc_tmask );
562 }
563 if ( lockflag ) GDI_UNLOCK();
564 wrd_wnd_unlock();
565 if ( ! WrdWndInfo.GraphicStop ) {
566 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
567 wrd_graphic_update ( &rc, 0 );
568 }
569 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE);
570 }
571
572 extern void wrd_graphic_ginit ( void );
573 extern void wrd_graphic_gcls ( int sw );
574 extern void wrd_graphic_gscreen ( int active, int display );
575 extern void wrd_graphic_gon ( int sw );
576 extern void wrd_graphic_gline ( int x1, int y1, int x2, int y2, int p1, int sw, int p2 );
577 extern void wrd_graphic_gcircle ( int x, int y, int r, int p1, int sw, int p2 );
578 extern void wrd_graphic_pload ( char *path );
579 extern void wrd_graphic_pal_g4r4b4 ( int p, int *g4r4b4, int max );
580 extern void wrd_graphic_palrev ( int p );
581 extern void wrd_graphic_apply_pal ( int p );
582 extern void wrd_graphic_fade ( int p1, int p2, int speed );
583 extern void wrd_graphic_fadestep ( int v );
584 extern void wrd_graphic_gmode ( int sw );
585 extern void wrd_graphic_gmove ( int x1, int y1, int x2, int y2, int xd, int yd, int vs, int vd, int sw );
586 extern void wrd_graphic_mag ( char *path, int x, int y, int s, int p );
587 extern void wrd_text_scroll ( int x1, int y1, int x2, int y2, int mode, int color, int c );
588 extern void wrd_start_skip ( void );
589 extern void wrd_end_skip ( void );
590 extern void wrd_graphic_xcopy ( int sx1, int sy1, int sx2, int sy2, int tx, int ty, int ss, int ts, int method,
591 int opt1, int opt2, int opt3, int opt4, int opt5 );
592
wrd_graphic_ginit(void)593 void wrd_graphic_ginit ( void )
594 {
595 RECT rc;
596 int index_display_old = w32g_wrd_wnd.index_display;
597 if ( WrdWndInfo.GraphicStop ) return;
598 if ( !w32g_wrd_wnd.active ) return;
599 wrd_graphic_plane_change ( 0, 0 );
600 wrd_graphic_reset_all ();
601 wrd_wnd_lock();
602 mag_deletetab();
603 wrd_wnd_unlock();
604 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
605 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
606 }
607
wrd_graphic_gcls(int sw)608 void wrd_graphic_gcls ( int sw )
609 {
610 RECT rc;
611 int i, size;
612
613 if ( WrdWndInfo.GraphicStop ) return;
614 if ( !w32g_wrd_wnd.active ) return;
615 wrd_wnd_lock();
616 GdiFlush ();
617 size = w32g_wrd_wnd.width * w32g_wrd_wnd.height;
618 if ( sw == 0 )
619 sw = 0xFF;
620 for ( i = 0; i < size; i ++ ) {
621 w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits[i] &= ~sw;
622 }
623 w32g_wrd_wnd.modified_graphic[w32g_wrd_wnd.index_active] = TRUE;
624 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
625 wrd_wnd_unlock();
626 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
627 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
628 wrd_graphic_update ( &rc, TRUE );
629 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
630 }
631 }
632
wrd_graphic_gscreen(int active,int display)633 void wrd_graphic_gscreen ( int active, int display )
634 {
635 int display_old = w32g_wrd_wnd.index_display;
636
637 if ( WrdWndInfo.GraphicStop ) return;
638 if ( !w32g_wrd_wnd.active ) return;
639 if ( active < 0 || active >= 2 || display < 0 || display >= 2 )
640 return;
641 wrd_wnd_lock();
642 wrd_graphic_plane_change ( active, display );
643 wrd_wnd_unlock();
644 if ( display_old != w32g_wrd_wnd.index_display ) {
645 RECT rc;
646 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
647 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
648 wrd_graphic_update ( &rc, TRUE );
649 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
650 }
651 }
652
wrd_graphic_gon(int sw)653 void wrd_graphic_gon ( int sw )
654 {
655 int sw_old = w32g_wrd_wnd.flag & WRD_FLAG_GRAPHIC;
656
657 if ( WrdWndInfo.GraphicStop ) return;
658 if ( !w32g_wrd_wnd.active ) return;
659 if ( sw && !sw_old ) {
660 w32g_wrd_wnd.flag |= WRD_FLAG_GRAPHIC; // ��ɐݒ�
661 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
662 RECT rc;
663 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
664 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
665 wrd_graphic_update ( &rc, TRUE );
666 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
667 }
668 } else if ( !sw && sw_old ) {
669 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
670 RECT rc;
671 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
672 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
673 wrd_graphic_update ( &rc, TRUE );
674 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
675 }
676 }
677 if ( sw )
678 w32g_wrd_wnd.flag |= WRD_FLAG_GRAPHIC;
679 else
680 w32g_wrd_wnd.flag &= ~WRD_FLAG_GRAPHIC;
681 }
682
wrd_graphic_gline(int x1,int y1,int x2,int y2,int p1,int sw,int p2)683 void wrd_graphic_gline ( int x1, int y1, int x2, int y2, int p1, int sw, int p2 )
684 {
685 int x, y, i;
686 RECT rc[10];
687 int rc_max = 0;
688 char *bits = w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits;
689
690 if ( WrdWndInfo.GraphicStop ) return;
691 if ( !w32g_wrd_wnd.active ) return;
692 if ( x1 > x2 || y1 > y2 || x1 < 0 || y1 < 0 || x2 >= w32g_wrd_wnd.width || y2 >= w32g_wrd_wnd.height )
693 return;
694 wrd_wnd_lock();
695 GdiFlush ();
696 // w32g_wrd_wnd.gmode
697 if ( sw >= 1 ) {
698 for ( x = x1; x <= x2; x ++ )
699 bits[ y1 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;
700 SetRect ( &rc[rc_max++], x1, y1, x2+1, y1+1 );
701 for ( y = y1 + 1; y <= y2 - 1; y ++ ) {
702 bits[ y * w32g_wrd_wnd.width + x1] = w32g_wrd_wnd.gmode & p1;
703 bits[ y * w32g_wrd_wnd.width + x2] = w32g_wrd_wnd.gmode & p1;
704 }
705 SetRect ( &rc[rc_max++], x1, y1, x1+1, y2+1 );
706 SetRect ( &rc[rc_max++], x2, y1, x2+1, y2+1 );
707 for ( x = x1; x <= x2; x ++ )
708 bits[ y2 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;
709 SetRect ( &rc[rc_max++], x1, y2, x2+1, y2+1 );
710 if ( sw == 2 ) {
711 for ( y = y1 + 1; y <= y2 - 1; y ++ )
712 for ( x = x1 + 1; x <= x2 - 1; x ++ )
713 bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p2;
714 rc_max = 0;
715 SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );
716 }
717 } else if ( sw == 0 ) {
718 if ( x1 == x2 ) {
719 for ( y = y1 ; y <= y2 ; y ++ )
720 bits[ y * w32g_wrd_wnd.width + x1] = w32g_wrd_wnd.gmode & p1;
721 SetRect ( &rc[rc_max++], x1, y1, x1+1, y2+1 );
722 } else if ( y1 == y2 ) {
723 for ( x = x1; x <= x2; x ++ )
724 bits[ y1 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p2;
725 SetRect ( &rc[rc_max++], x1, y1, x2+1, y1+1 );
726 } else if ( x2 - x1 == y2 - y1 ) {
727 for ( y = y1; y <= y2; y ++ )
728 bits[ y1 * w32g_wrd_wnd.width + (y - y1) + x1] = w32g_wrd_wnd.gmode & p2;
729 SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );
730 } else if ( x2 - x1 > y2 - y1 ) {
731 double r = (y2 - y1) / (x2 -x1), r2;
732 int x_min = x1;
733 for ( y = y1; y <= y2 - 1; y ++ ) {
734 for ( x = x_min; x <= x2; x ++ ) {
735 r2 = r * (x - x1) - (y - y1);
736 if ( r2 < 0.0 || r2 >= 1.0 ) {
737 break;
738 } else if ( r2 <= 0.5 ) {
739 bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;
740 x_min = x + 1;
741 } else {
742 bits[ (y + 1) * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;
743 x_min = x + 1;
744 }
745 }
746 }
747 SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );
748 } else if ( x2 - x1 < y2 - y1 ) {
749 double r = (x2 - x1) / (y2 -y1), r2;
750 int y_min = y1;
751 for ( x = x1; x <= x2 - 1; x ++ ) {
752 for ( y = y_min; y <= y2; y ++ ) {
753 r2 = r * (y - y1) - (x - x1);
754 if ( r2 < 0.0 || r2 >= 1.0 ) {
755 break;
756 } else if ( r2 <= 0.5 ) {
757 bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;
758 y_min = y + 1;
759 } else {
760 bits[ y * w32g_wrd_wnd.width + x + 1] = w32g_wrd_wnd.gmode & p1;
761 y_min = y + 1;
762 }
763 }
764 }
765 SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );
766 }
767 }
768 wrd_wnd_unlock();
769 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
770 for ( i = 0; i < rc_max; i ++ ) {
771 wrd_graphic_apply ( &rc[i], w32g_wrd_wnd.index_display, TRUE );
772 wrd_graphic_update ( &rc[i], TRUE );
773 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc[i], FALSE );
774 }
775 }
776 }
777
wrd_graphic_gcircle(int x,int y,int r,int p1,int sw,int p2)778 void wrd_graphic_gcircle ( int x, int y, int r, int p1, int sw, int p2 )
779 {
780 if ( WrdWndInfo.GraphicStop ) return;
781 if ( !w32g_wrd_wnd.active ) return;
782 wrd_wnd_lock();
783 wrd_wnd_unlock();
784 // w32g_wrd_wnd.gmode
785 }
786
wrd_graphic_pload(char * path)787 void wrd_graphic_pload ( char *path )
788 {
789 int res;
790
791 if ( WrdWndInfo.GraphicStop ) return;
792 if ( !w32g_wrd_wnd.active ) return;
793 wrd_wnd_lock();
794 GdiFlush ();
795 res = pho_load_pixel ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits, w32g_wrd_wnd.width, w32g_wrd_wnd.height, path );
796 wrd_wnd_unlock();
797 if ( res && w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
798 RECT rc;
799 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
800 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
801 wrd_graphic_update ( &rc, TRUE );
802 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
803 }
804 }
805
g4r4b4_to_rgb(int g4r4b4)806 static COLORREF g4r4b4_to_rgb ( int g4r4b4 )
807 {
808 return RGB ( ((g4r4b4 & 0x00F0) >> 4 ) << 4,
809 ((g4r4b4 & 0x0F00) >> 8 ) << 4,
810 ((g4r4b4 & 0x000F) >> 0 ) << 4 );
811 }
812
wrd_graphic_pal_g4r4b4(int p,int * g4r4b4,int max)813 void wrd_graphic_pal_g4r4b4 ( int p, int *g4r4b4, int max )
814 {
815 int i;
816
817 if ( WrdWndInfo.GraphicStop ) return;
818 if ( !w32g_wrd_wnd.active ) return;
819 if ( p < 0 ) return;
820 if ( p >= W32G_WRDWND_GRAPHIC_PALLETE_BUF_MAX )
821 return;
822 wrd_wnd_lock();
823 if ( max > W32G_WRDWND_GRAPHIC_PALLETE_MAX ) {
824 max = W32G_WRDWND_GRAPHIC_PALLETE_MAX;
825 }
826 for ( i = 0; i < max; i++ ) {
827 w32g_wrd_wnd.gpal_buff[p][i] = RGBtoRGBQUAD ( g4r4b4_to_rgb( g4r4b4[i] ) );
828 }
829 wrd_wnd_unlock();
830 if ( p == 0 ) {
831 RECT rc;
832 #if 1
833 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i++ ) {
834 dib_set_pals ( w32g_wrd_wnd.graphic_dib[i], w32g_wrd_wnd.gpal_buff[p], max );
835 }
836 #else
837 dib_set_pals ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display], w32g_wrd_wnd.gpal_buff[p], max );
838 #endif
839 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
840 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
841 wrd_graphic_update ( &rc, TRUE );
842 InvalidateRect(w32g_wrd_wnd.hwnd, &rc, FALSE);
843 }
844 }
845
846 extern DWORD volatile dwMainThreadId;
wrd_graphic_palrev(int p)847 void wrd_graphic_palrev ( int p )
848 {
849 int i;
850
851 if ( WrdWndInfo.GraphicStop ) return;
852 if ( !w32g_wrd_wnd.active ) return;
853 if ( p < 0 ) return;
854 if ( p >= W32G_WRDWND_GRAPHIC_PALLETE_BUF_MAX )
855 return;
856 wrd_wnd_lock();
857 for ( i = 0; i <W32G_WRDWND_GRAPHIC_PALLETE_MAX; i++ ) {
858 w32g_wrd_wnd.gpal_buff[p][i].rgbBlue = 0xFF - w32g_wrd_wnd.gpal_buff[p][i].rgbBlue;
859 w32g_wrd_wnd.gpal_buff[p][i].rgbGreen = 0xFF - w32g_wrd_wnd.gpal_buff[p][i].rgbGreen;
860 w32g_wrd_wnd.gpal_buff[p][i].rgbRed = 0xFF - w32g_wrd_wnd.gpal_buff[p][i].rgbRed;
861 }
862 wrd_wnd_unlock();
863 if ( p == 0 ) {
864 RECT rc;
865 #if 1
866 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i++ ) {
867 dib_set_pals ( w32g_wrd_wnd.graphic_dib[i], w32g_wrd_wnd.gpal_buff[p], W32G_WRDWND_GRAPHIC_PALLETE_MAX );
868 }
869 #else
870 dib_set_pals ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display], w32g_wrd_wnd.gpal_buff[p], W32G_WRDWND_GRAPHIC_PALLETE_MAX );
871 #endif
872 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
873 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
874 wrd_graphic_update ( &rc, TRUE );
875 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
876 }
877 }
878
wrd_graphic_apply_pal(int p)879 void wrd_graphic_apply_pal ( int p )
880 {
881 int i;
882 RECT rc;
883
884 if ( WrdWndInfo.GraphicStop ) return;
885 if ( !w32g_wrd_wnd.active ) return;
886 if ( p < 0 ) return;
887 if ( p >= W32G_WRDWND_GRAPHIC_PALLETE_BUF_MAX )
888 return;
889 wrd_wnd_lock();
890 #if 1
891 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i++ ) {
892 dib_set_pals ( w32g_wrd_wnd.graphic_dib[i], w32g_wrd_wnd.gpal_buff[p], W32G_WRDWND_GRAPHIC_PALLETE_MAX );
893 }
894 #else
895 dib_set_pals ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display], w32g_wrd_wnd.gpal_buff[p], W32G_WRDWND_GRAPHIC_PALLETE_MAX );
896 #endif
897 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
898 wrd_wnd_unlock();
899 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
900 wrd_graphic_update ( &rc, TRUE );
901 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
902 }
903
wrd_graphic_fade(int p1,int p2,int speed)904 void wrd_graphic_fade ( int p1, int p2, int speed )
905 {
906
907 if ( WrdWndInfo.GraphicStop ) return;
908 if ( !w32g_wrd_wnd.active ) return;
909 if ( p1 < 0 ) return;
910 if ( p1 >= W32G_WRDWND_GRAPHIC_PALLETE_BUF_MAX ) return;
911 if ( p2 < 0 ) return;
912 if ( p2 >= W32G_WRDWND_GRAPHIC_PALLETE_BUF_MAX ) return;
913 wrd_wnd_lock();
914 w32g_wrd_wnd.fade_from = p1;
915 w32g_wrd_wnd.fade_to = p2;
916 wrd_wnd_unlock();
917 if ( speed == 0 ) {
918 wrd_graphic_apply_pal ( p2 );
919 } else{
920 // wrd_graphic_apply_pal ( p1 );
921 }
922 }
923
wrd_graphic_fadestep(int v)924 void wrd_graphic_fadestep ( int v )
925 {
926 int i;
927 RECT rc;
928 RGBQUAD gpal[W32G_WRDWND_GRAPHIC_PALLETE_MAX];
929 double v1, v2;
930
931 if ( WrdWndInfo.GraphicStop ) return;
932 if ( !w32g_wrd_wnd.active ) return;
933 if ( w32g_wrd_wnd.fade_from < 0 || w32g_wrd_wnd.fade_to < 0 )
934 return;
935 wrd_wnd_lock();
936 v2 = (double) v / WRD_MAXFADESTEP;
937 v1 = 1.0 - v2;
938 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PALLETE_MAX; i++ ) {
939 RGBQUAD *rq1 = &w32g_wrd_wnd.gpal_buff[w32g_wrd_wnd.fade_from][i];
940 RGBQUAD *rq2 = &w32g_wrd_wnd.gpal_buff[w32g_wrd_wnd.fade_to][i];
941 gpal[i].rgbBlue = (char) ( v1 * rq1->rgbBlue + v2 * rq2->rgbBlue );
942 gpal[i].rgbGreen = (char) ( v1 * rq1->rgbGreen + v2 * rq2->rgbGreen );
943 gpal[i].rgbRed = (char) ( v1 * rq1->rgbRed + v2 * rq2->rgbRed );
944 gpal[i].rgbReserved = 0;
945 }
946 #if 1
947 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i++ ) {
948 dib_set_pals ( w32g_wrd_wnd.graphic_dib[i], gpal, W32G_WRDWND_GRAPHIC_PALLETE_MAX );
949 }
950 #else
951 dib_set_pals ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display], gpal, W32G_WRDWND_GRAPHIC_PALLETE_MAX );
952 #endif
953 SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );
954 wrd_wnd_unlock();
955 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
956 wrd_graphic_update ( &rc, TRUE );
957 #if 1
958 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
959 #else
960 { // �p���b�g�̕ω��őS��ʂ��X�V���Ȃ��ōςނ悤�Ƀ`�F�b�N���Ă݂�B���ǁA�d���̂ŕs�̗p�B
961 #define BITS_DIV 10
962 int j;
963 char *bits;
964 int mod_pal[W32G_WRDWND_GRAPHIC_PALLETE_MAX];
965 char bits_use_pal[BITS_DIV][BITS_DIV];
966 for ( i = 0; i < W32G_WRDWND_GRAPHIC_PALLETE_MAX; i++ ) {
967 if ( memcmp ( &w32g_wrd_wnd.gpal_buff[w32g_wrd_wnd.fade_from][i],
968 &w32g_wrd_wnd.gpal_buff[w32g_wrd_wnd.fade_to][i], sizeof (RGBQUAD) ) != 0 )
969 mod_pal[i] = 1;
970 else
971 mod_pal[i] = 0;
972 }
973 bits = w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display]->bits;
974 for ( i = 0; i < BITS_DIV; i ++ ) {
975 for ( j = 0; j < BITS_DIV; j ++ ) {
976 bits_use_pal[i][j] = 0;
977 }
978 }
979 for ( i = 0; i < 640; i ++ ) {
980 for ( j = 0; j < 400; j ++ ) {
981 char c = bits [ j * w32g_wrd_wnd.width + i ];
982 if ( c >= 0 && c <= 0x0F && mod_pal[ c ] )
983 bits_use_pal[BITS_DIV*i/640][BITS_DIV*j/400] = 1;
984 }
985 }
986 for ( i = 0; i < BITS_DIV; i ++ ) {
987 for ( j = 0; j < BITS_DIV; j ++ ) {
988 if ( bits_use_pal[i][j] )
989 SetRect ( &rc, i * 640/BITS_DIV, j * 400/BITS_DIV, ( i + 1) * 640/BITS_DIV, ( j + 1) * 400/BITS_DIV );
990 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
991 }
992 }
993 }
994 #endif
995 }
996
wrd_graphic_gmode(int sw)997 void wrd_graphic_gmode ( int sw )
998 {
999 w32g_wrd_wnd.gmode = sw;
1000 }
1001
wrd_graphic_gmove(int x1,int y1,int x2,int y2,int xd,int yd,int vs,int vd,int sw)1002 void wrd_graphic_gmove ( int x1, int y1, int x2, int y2, int xd, int yd, int vs, int vd, int sw )
1003 {
1004 int x, y;
1005
1006 if ( WrdWndInfo.GraphicStop ) return;
1007 if ( !w32g_wrd_wnd.active ) return;
1008 if ( vs < 0 || vs >= 2 || vd < 0 || vd >= 2 ) return;
1009 if ( x1 < 0 || x1 >= w32g_wrd_wnd.width ) return;
1010 if ( y1 < 0 || y1 >= w32g_wrd_wnd.height ) return;
1011 if ( xd < 0 || xd >= w32g_wrd_wnd.width ) return;
1012 if ( yd < 0 || yd >= w32g_wrd_wnd.height ) return;
1013 wrd_wnd_lock();
1014 GdiFlush ();
1015 x1 = ( ( x1 + 7 ) / 8 ) * 8;
1016 x2 = ( ( x2 + 7 ) / 8 ) * 8;
1017 xd = ( ( xd + 7 ) / 8 ) * 8;
1018 if ( xd + x2 - x1 >= w32g_wrd_wnd.width ) {
1019 int d = w32g_wrd_wnd.width - 1 - xd;
1020 x2 = x1 + d;
1021 }
1022 if ( yd + y2 - y1 >= w32g_wrd_wnd.height ) {
1023 int d = w32g_wrd_wnd.height - 1 - yd;
1024 y2 = y1 + d;
1025 }
1026 switch ( sw ) {
1027 default:
1028 case 0: // COPY
1029 for ( y = y1; y <= y2; y ++ ) {
1030 int i_src = y * w32g_wrd_wnd.width;
1031 int i_dest = (yd + y - y1) * w32g_wrd_wnd.width;
1032 if ( w32g_wrd_wnd.gmode >= 0x0F ) {
1033 memcpy ( &w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest + xd],
1034 &w32g_wrd_wnd.graphic_dib[vs]->bits[i_src + x1], x2 - x1 + 1 );
1035 } else {
1036 for ( x = x1; x <= x2; x ++ ) {
1037 int i_dest_tmp = i_dest + xd + x - x1;
1038 int i_src_tmp = i_src + x;
1039 w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest_tmp]
1040 = w32g_wrd_wnd.graphic_dib[vs]->bits[i_src_tmp] & w32g_wrd_wnd.gmode;
1041 }
1042 }
1043 }
1044 break;
1045 case 1: // SWAP
1046 for ( y = y1; y <= y2; y ++ ) {
1047 int i_src = y * w32g_wrd_wnd.width;
1048 int i_dest = (yd + y - y1) * w32g_wrd_wnd.width;
1049 if ( w32g_wrd_wnd.gmode >= 0x0F ) {
1050 char buff[640+1];
1051 int d = x2 - x1 + 1;
1052 memcpy ( buff, &w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest + xd], d );
1053 memcpy ( &w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest + xd],
1054 &w32g_wrd_wnd.graphic_dib[vs]->bits[i_src + x1], d );
1055 memcpy ( &w32g_wrd_wnd.graphic_dib[vs]->bits[i_src + x1], buff, d );
1056 } else {
1057 for ( x = x1; x <= x2; x ++ ) {
1058 int i_dest_tmp = i_dest + xd + x - x1;
1059 int i_src_tmp = i_src + x;
1060 char t = w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest_tmp];
1061 w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest_tmp]
1062 = ( w32g_wrd_wnd.graphic_dib[vd]->bits[i_dest_tmp] & ~w32g_wrd_wnd.gmode )
1063 | ( w32g_wrd_wnd.graphic_dib[vs]->bits[i_src_tmp] & w32g_wrd_wnd.gmode );
1064 w32g_wrd_wnd.graphic_dib[vs]->bits[i_src_tmp]
1065 = ( w32g_wrd_wnd.graphic_dib[vs]->bits[i_src_tmp] & ~w32g_wrd_wnd.gmode )
1066 | t & w32g_wrd_wnd.gmode;
1067 }
1068 }
1069 }
1070 break;
1071 }
1072 wrd_wnd_unlock();
1073 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
1074 RECT rc;
1075 SetRect ( &rc, xd, yd, xd + x2 - x1, yd + y2 - y1 );
1076 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
1077 wrd_graphic_update ( &rc, TRUE );
1078 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
1079 }
1080 }
1081
wrd_graphic_mag(char * path,int x,int y,int s,int p)1082 void wrd_graphic_mag ( char *path, int x, int y, int s, int p )
1083 {
1084 int x_orig = x, y_orig = y;
1085 int size = w32g_wrd_wnd.width * w32g_wrd_wnd.height;
1086 magdata *mh;
1087 int width, height;
1088
1089 if ( WrdWndInfo.GraphicStop ) return;
1090 if ( !w32g_wrd_wnd.active ) return;
1091 mh = mag_create ( path );
1092 if ( x_orig == WRD_NOARG )
1093 x_orig = 0;
1094 if ( y_orig == WRD_NOARG )
1095 y_orig = 0;
1096 if ( mh == NULL )
1097 return;
1098 width = mh->xend - mh->xorig + 1;
1099 height = mh->yend - mh->yorig + 1;
1100 if (MAG_WORK_WIDTH < width )
1101 return;
1102 if ( MAG_WORK_HEIGHT < height )
1103 return;
1104 if ( s <= 0 )
1105 return;
1106 wrd_wnd_lock();
1107 GdiFlush ();
1108 if ( wrd_graphic_pal_init_flag == 0 ) { /* MIMPI BUG ? */
1109 if ( p == 1 ) p = 0;
1110 wrd_graphic_pal_init_flag = 1;
1111 }
1112 if ( p == 0 || p == 1 ) {
1113 if ( s == 1 && x_orig == 0 && y_orig == 0 && width <= w32g_wrd_wnd.width && height <= w32g_wrd_wnd.height ) {
1114 mag_load_pixel ( w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits,
1115 w32g_wrd_wnd.width, w32g_wrd_wnd.height, mh );
1116 } else {
1117 #if 1
1118 mag_load_pixel ( w32g_wrd_wnd.bits_mag_work,
1119 MAG_WORK_WIDTH, MAG_WORK_HEIGHT, mh );
1120 for ( y = 0; y < height; y ++ ) {
1121 int dest_index = (y_orig + y/s) * w32g_wrd_wnd.width;
1122 int src_index = y * MAG_WORK_WIDTH;
1123 long v[MAG_WORK_WIDTH];
1124 for ( x = 0; x < width; x ++ )
1125 v[x] = 0;
1126 for ( x = 0; x < width; x ++ ) {
1127 v[x/s] += w32g_wrd_wnd.bits_mag_work[ src_index + x ];
1128 }
1129 for ( x = 0; x < width; x ++ ) {
1130 if ( v[x/s] >= 0 ) {
1131 int i_tmp = dest_index + x_orig + x/s;
1132 if ( i_tmp < MAG_WORK_WIDTH * MAG_WORK_HEIGHT )
1133 w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits[i_tmp] = ( v[x/s] / s / s ) & 0x0F;
1134 v[x/s] = -1;
1135 }
1136 }
1137 }
1138 width /= s;
1139 height /= s;
1140 #else
1141 mag_load_pixel ( w32g_wrd_wnd.bits_mag_work,
1142 MAG_WORK_WIDTH, MAG_WORK_HEIGHT, mh );
1143 for ( y = 0; y < height; y ++ ) {
1144 for ( x = 0; x < width; x ++ ) {
1145 w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits[(y_orig + y) * w32g_wrd_wnd.width + x_orig + x]
1146 = w32g_wrd_wnd.bits_mag_work[ y * MAG_WORK_WIDTH + x];
1147 }
1148 }
1149 #endif
1150 }
1151 }
1152 wrd_wnd_unlock();
1153 wrd_graphic_pal_g4r4b4 ( 17, mh->pal, 16 );
1154 if ( w32g_wrd_wnd.index_active == 0 )
1155 wrd_graphic_pal_g4r4b4 ( 18, mh->pal, 16 );
1156 if ( w32g_wrd_wnd.index_active == 1 )
1157 wrd_graphic_pal_g4r4b4 ( 19, mh->pal, 16 );
1158 if ( p == 0 || p == 2 ) {
1159 wrd_graphic_pal_g4r4b4 ( 0, mh->pal, 16 );
1160 } else {
1161 // wrd_graphic_pal_g4r4b4() �����s���Ȃ��Ɨ̈悪�X�V����Ȃ��B
1162 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
1163 RECT rc;
1164 SetRect ( &rc, x_orig, y_orig, width, height );
1165 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
1166 wrd_graphic_update ( &rc, TRUE );
1167 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
1168 }
1169 }
1170 }
1171
wrd_text_ton(int sw)1172 void wrd_text_ton ( int sw )
1173 {
1174 int sw_old = w32g_wrd_wnd.flag & WRD_FLAG_TEXT;
1175
1176 if ( !w32g_wrd_wnd.active ) return;
1177 if ( sw && !sw_old ) {
1178 w32g_wrd_wnd.flag |= WRD_FLAG_TEXT; // ��ɐݒ�
1179 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
1180 wrd_text_update ( 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height, TRUE );
1181 }
1182 } else if ( !sw && sw_old ) {
1183 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
1184 wrd_text_update ( 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height, TRUE );
1185 }
1186 }
1187 if ( sw )
1188 w32g_wrd_wnd.flag |= WRD_FLAG_TEXT;
1189 else
1190 w32g_wrd_wnd.flag &= ~WRD_FLAG_TEXT;
1191 }
1192
wrd_text_scroll(int x1,int y1,int x2,int y2,int mode,int color,int c)1193 void wrd_text_scroll ( int x1, int y1, int x2, int y2, int mode, int color, int c )
1194 {
1195 int x, y;
1196 x1--; x2--; y1--; y2--;
1197 if ( !w32g_wrd_wnd.active ) return;
1198 if ( x1 > x2 ) return;
1199 if ( y1 > y2 ) return;
1200 if ( x1 < 0 ) x1 = 0; if ( x2 < 0 ) x2 = 0;
1201 if ( x1 >= w32g_wrd_wnd.row ) x1 = w32g_wrd_wnd.row - 1;
1202 if ( x2 >= w32g_wrd_wnd.row ) x2 = w32g_wrd_wnd.row - 1;
1203 if ( y1 < 0 ) y1 = 0; if ( y2 < 0 ) y2 = 0;
1204 if ( y1 >= w32g_wrd_wnd.row ) y1 = w32g_wrd_wnd.col - 1;
1205 if ( y2 >= w32g_wrd_wnd.row ) y2 = w32g_wrd_wnd.col - 1;
1206 wrd_wnd_lock();
1207 if ( mode == 0 ) {
1208 int dx = x2 - x1 + 1;
1209 for ( y = y1+1; y <= y2; y ++ ) {
1210 memcpy ( &w32g_wrd_wnd.textbuf [ y - 1 ][x1],
1211 &w32g_wrd_wnd.textbuf [ y ][x1], dx );
1212 memcpy ( &w32g_wrd_wnd.forecolorbuf [ y - 1 ][x1],
1213 &w32g_wrd_wnd.forecolorbuf [ y ][x1], dx );
1214 memcpy ( &w32g_wrd_wnd.backcolorbuf [ y - 1 ][x1],
1215 &w32g_wrd_wnd.backcolorbuf [ y ][x1], dx );
1216 memcpy ( &w32g_wrd_wnd.attrbuf [ y - 1 ][x1],
1217 &w32g_wrd_wnd.attrbuf [ y ][x1], dx );
1218 }
1219 WrdWndCurStateSaveAndRestore ( 1 );
1220 WrdWndSetAttr98 ( color );
1221 for ( x = x1; x <= x2; x ++ ) {
1222 w32g_wrd_wnd.textbuf [ y2][x] = c;
1223 w32g_wrd_wnd.forecolorbuf [ y2][x] = w32g_wrd_wnd.curforecolor;
1224 w32g_wrd_wnd.backcolorbuf [ y2][x] = w32g_wrd_wnd.curbackcolor;
1225 w32g_wrd_wnd.attrbuf [ y2][x] = w32g_wrd_wnd.curattr;
1226 }
1227 WrdWndCurStateSaveAndRestore ( 0 );
1228 } else if ( mode == 1 ) {
1229 int dx = x2 - x1 + 1;
1230 for ( y = y2 - 1; y >= y1; y -- ) {
1231 memcpy ( &w32g_wrd_wnd.textbuf [ y + 1 ][x1],
1232 &w32g_wrd_wnd.textbuf [ y ][x1], dx );
1233 memcpy ( &w32g_wrd_wnd.forecolorbuf [ y + 1 ][x1],
1234 &w32g_wrd_wnd.forecolorbuf [ y ], dx );
1235 memcpy ( &w32g_wrd_wnd.backcolorbuf [ y + 1 ][x1],
1236 &w32g_wrd_wnd.backcolorbuf [ y ][x1], dx );
1237 memcpy ( &w32g_wrd_wnd.attrbuf [ y + 1 ][x1],
1238 &w32g_wrd_wnd.attrbuf [ y ][x1], dx );
1239 }
1240 WrdWndCurStateSaveAndRestore ( 1 );
1241 WrdWndSetAttr98 ( color );
1242 for ( x = x1; x <= x2; x ++ ) {
1243 w32g_wrd_wnd.textbuf [ y1][x] = c;
1244 w32g_wrd_wnd.forecolorbuf [ y1][x] = w32g_wrd_wnd.curforecolor;
1245 w32g_wrd_wnd.backcolorbuf [ y1][x] = w32g_wrd_wnd.curbackcolor;
1246 w32g_wrd_wnd.attrbuf [ y1][x] = w32g_wrd_wnd.curattr;
1247 }
1248 WrdWndCurStateSaveAndRestore ( 0 );
1249 } else if ( mode == 2 ) {
1250 for ( y = y1; y <= y2; y ++ ) {
1251 for ( x = x1+1; x <= x2; x ++ ) {
1252 w32g_wrd_wnd.textbuf [ y ][ x ]
1253 = w32g_wrd_wnd.textbuf [ y ][ x - 1];
1254 w32g_wrd_wnd.forecolorbuf[ y ][ x ]
1255 = w32g_wrd_wnd.forecolorbuf [ y ][ x - 1];
1256 w32g_wrd_wnd.backcolorbuf [ y ][ x ]
1257 = w32g_wrd_wnd.backcolorbuf [ y ][ x - 1];
1258 w32g_wrd_wnd.attrbuf [ y ][ x ]
1259 = w32g_wrd_wnd.attrbuf [ y ][ x - 1];
1260 }
1261 }
1262 WrdWndCurStateSaveAndRestore ( 1 );
1263 WrdWndSetAttr98 ( color );
1264 for ( y = y1; y <= y2; y ++ ) {
1265 w32g_wrd_wnd.textbuf [ y ][ x1] = c;
1266 w32g_wrd_wnd.forecolorbuf [ y ][ x1] = w32g_wrd_wnd.curforecolor;
1267 w32g_wrd_wnd.backcolorbuf [ y ][ x1] = w32g_wrd_wnd.curbackcolor;
1268 w32g_wrd_wnd.attrbuf [ y ][ x1] = w32g_wrd_wnd.curattr;
1269 }
1270 WrdWndCurStateSaveAndRestore ( 0 );
1271 } else if ( mode == 3 ) {
1272 for ( y = y1; y <= y2; y ++ ) {
1273 for ( x = x2 - 1; x >= x1; x -- ) {
1274 w32g_wrd_wnd.textbuf [ y ][ x ]
1275 = w32g_wrd_wnd.textbuf [ y ][ x + 1];
1276 w32g_wrd_wnd.forecolorbuf[ y ][ x ]
1277 = w32g_wrd_wnd.forecolorbuf [ y ][ x + 1];
1278 w32g_wrd_wnd.backcolorbuf [ y ][ x ]
1279 = w32g_wrd_wnd.backcolorbuf [ y ][ x + 1];
1280 w32g_wrd_wnd.attrbuf [ y ][ x ]
1281 = w32g_wrd_wnd.attrbuf [ y ][ x + 1];
1282 }
1283 }
1284 WrdWndCurStateSaveAndRestore ( 1 );
1285 WrdWndSetAttr98 ( color );
1286 for ( y = y1; y <= y2; y ++ ) {
1287 w32g_wrd_wnd.textbuf [ y ][ x2] = c;
1288 w32g_wrd_wnd.forecolorbuf [ y ][ x2] = w32g_wrd_wnd.curforecolor;
1289 w32g_wrd_wnd.backcolorbuf [ y ][ x2] = w32g_wrd_wnd.curbackcolor;
1290 w32g_wrd_wnd.attrbuf [ y ][ x2] = w32g_wrd_wnd.curattr;
1291 }
1292 WrdWndCurStateSaveAndRestore ( 0 );
1293 }
1294 wrd_wnd_unlock();
1295 wrd_text_update ( x1, y1, x2, y2, TRUE );
1296 }
1297
wrd_start_skip(void)1298 void wrd_start_skip ( void )
1299 {
1300 wrd_wnd_lock();
1301 w32g_wrd_wnd.draw_skip = 1;
1302 wrd_wnd_unlock();
1303 }
1304
wrd_end_skip(void)1305 void wrd_end_skip ( void )
1306 {
1307 w32g_wrd_wnd.draw_skip = 0;
1308 wrd_text_update ( 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height, TRUE );
1309 }
1310
wrd_graphic_xcopy(int sx1,int sy1,int sx2,int sy2,int tx,int ty,int ss,int ts,int method,int opt1,int opt2,int opt3,int opt4,int opt5)1311 void wrd_graphic_xcopy ( int sx1, int sy1, int sx2, int sy2, int tx, int ty, int ss, int ts, int method,
1312 int opt1, int opt2, int opt3, int opt4, int opt5 )
1313 {
1314 #if 0
1315 int x, y, d, size = w32g_wrd_wnd.width * w32g_wrd_wnd.height;
1316
1317 if ( WrdWndInfo.GraphicStop ) return;
1318 if ( !w32g_wrd_wnd.active ) return;
1319
1320 if ( ss < 0 || ss >= 2 || ts < 0 || ts >= 2 ) return;
1321 if ( sx1 < 0 || sx1 >= w32g_wrd_wnd.width ) return;
1322 if ( sy1 < 0 || sy1 >= w32g_wrd_wnd.height ) return;
1323 if ( tx < 0 || tx >= w32g_wrd_wnd.width ) return;
1324 if ( ty < 0 || ty >= w32g_wrd_wnd.height ) return;
1325 wrd_wnd_lock();
1326 GdiFlush ();
1327 if ( tx + sx2 - sx1 >= w32g_wrd_wnd.width ) {
1328 d = w32g_wrd_wnd.width - 1 - tx;
1329 sx2 = sx1 + d;
1330 }
1331 if ( ty + sy2 - sy1 >= w32g_wrd_wnd.height ) {
1332 d = w32g_wrd_wnd.height - 1 - ty;
1333 sy2 = sy1 + d;
1334 }
1335 switch ( method ) {
1336 case 0: // COPY
1337 d = sx2 - sx1 + 1;
1338 for ( y = sy1; y <= sy2; y ++ ) {
1339 int i_src = y * w32g_wrd_wnd.width;
1340 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1341 memcpy ( &w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest + tx],
1342 &w32g_wrd_wnd.graphic_dib[ss]->bits[i_src + sx1], d );
1343 }
1344 break;
1345 case 1: // COPY EXCEPT 0
1346 for ( y = sy1; y <= sy2; y ++ ) {
1347 int i_src = y * w32g_wrd_wnd.width;
1348 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1349 for ( x = sx1; x <= sx2; x ++ ) {
1350 int i_src_tmp = i_src + x;
1351 int i_dest_tmp = i_dest + tx + x - sx1;
1352 char c = w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1353 if ( c != 0 )
1354 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] = c;
1355 }
1356 }
1357 break;
1358 case 2: // XOR
1359 for ( y = sy1; y <= sy2; y ++ ) {
1360 int i_src = y * w32g_wrd_wnd.width;
1361 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1362 for ( x = sx1; x <= sx2; x ++ ) {
1363 int i_src_tmp = i_src + x;
1364 int i_dest_tmp = i_dest + tx + x - sx1;
1365 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] ^= w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1366 }
1367 }
1368 break;
1369 case 3: // AND
1370 for ( y = sy1; y <= sy2; y ++ ) {
1371 int i_src = y * w32g_wrd_wnd.width;
1372 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1373 for ( x = sx1; x <= sx2; x ++ ) {
1374 int i_src_tmp = i_src + x;
1375 int i_dest_tmp = i_dest + tx + x - sx1;
1376 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] &= w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1377 }
1378 }
1379 break;
1380 case 4: // OR
1381 for ( y = sy1; y <= sy2; y ++ ) {
1382 int i_src = y * w32g_wrd_wnd.width;
1383 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1384 for ( x = sx1; x <= sx2; x ++ ) {
1385 int i_src_tmp = i_src + x;
1386 int i_dest_tmp = i_dest + tx + x - sx1;
1387 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] |= w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1388 }
1389 }
1390 break;
1391 case 5: // X REVERSE
1392 for ( y = sy1; y <= sy2; y ++ ) {
1393 int i_src = y * w32g_wrd_wnd.width;
1394 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1395 for ( x = sx1; x <= sx2; x ++ ) {
1396 int i_src_tmp = i_src + x;
1397 int i_dest_tmp = i_dest + tx + sx2 - x;
1398 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] |= w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1399 }
1400 }
1401 break;
1402 case 6: // Y REVERSE
1403 d = sx2 - sx1 + 1;
1404 for ( y = sy1; y <= sy2; y ++ ) {
1405 int i_src = ( sy1 + sy2 - y ) * w32g_wrd_wnd.width;
1406 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1407 memcpy ( &w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest + tx],
1408 &w32g_wrd_wnd.graphic_dib[ss]->bits[i_src + sx1], d );
1409 }
1410 break;
1411 case 7: // X Y REVERSE
1412 for ( y = sy1; y <= sy2; y ++ ) {
1413 int i_src = ( sy1 + sy2 - y ) * w32g_wrd_wnd.width;
1414 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1415 for ( x = sx1; x <= sx2; x ++ ) {
1416 int i_src_tmp = i_src + x;
1417 int i_dest_tmp = i_dest + tx + sx2 - x;
1418 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] |= w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1419 }
1420 }
1421 break;
1422 case 8: // COPY2
1423 for ( y = sy1; y <= sy2; y ++ ) {
1424 int i_src = y * w32g_wrd_wnd.width;
1425 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1426 for ( x = sx1; x <= sx2; x ++ ) {
1427 int i_src_tmp = i_src + x;
1428 int i_dest_tmp = i_dest + tx + x - sx1;
1429 char c = w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1430 if ( c != 0 )
1431 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] = c;
1432 else {
1433 i_src_tmp = ( opt2 + y - sy1) * w32g_wrd_wnd.width + opt1 + x - sx1;
1434 if ( 0 <= i_src_tmp && i_src_tmp < size )
1435 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] = w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1436 }
1437 }
1438 }
1439 break;
1440 case 9: // ������Ƃ킩��Ȃ������B
1441 break;
1442 case 10: // COPY opt1, opt2
1443 if ( opt1 < 0 || opt2 < 0 )
1444 break;
1445 d = sx2 - sx1 + 1;
1446 for ( y = sy1; y <= sy2; y ++ ) {
1447 int i_src, i_dest;
1448 if ( (y - sy1) % ( opt1 + opt2 ) >= opt2 )
1449 continue;
1450 i_src = y * w32g_wrd_wnd.width;
1451 i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1452 memcpy ( &w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest + tx],
1453 &w32g_wrd_wnd.graphic_dib[ss]->bits[i_src + sx1], d );
1454 }
1455 break;
1456 case 11: // Clipping Copy �ӂ��̃R�s�[�ő�p�B
1457 d = sx2 - sx1 + 1;
1458 for ( y = sy1; y <= sy2; y ++ ) {
1459 int i_src = y * w32g_wrd_wnd.width;
1460 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1461 memcpy ( &w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest + tx],
1462 &w32g_wrd_wnd.graphic_dib[ss]->bits[i_src + sx1], d );
1463 }
1464 break;
1465 case 12: // PLANE COPY
1466 if ( opt1 < 0 || opt1 >= 4 || opt2 < 0 || opt2 >= 4 )
1467 break;
1468 for ( y = sy1; y <= sy2; y ++ ) {
1469 int i_src = y * w32g_wrd_wnd.width;
1470 int i_dest = ( ty + y - sy1) * w32g_wrd_wnd.width;
1471 for ( x = sx1; x <= sx2; x ++ ) {
1472 int i_src_tmp = i_src + x;
1473 int i_dest_tmp = i_dest + tx + x - sx1;
1474 char c = w32g_wrd_wnd.graphic_dib[ss]->bits[i_src_tmp];
1475 c = ( ( c & ( 1 << opt1) ) >> opt1 ) << opt2;
1476 w32g_wrd_wnd.graphic_dib[ts]->bits[i_dest_tmp] = c;
1477 }
1478 }
1479 break;
1480 default:
1481 break;
1482 }
1483 wrd_wnd_unlock();
1484 if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {
1485 RECT rc;
1486 SetRect ( &rc, tx, ty, tx + sx2 - sx1, ty + sy2 - sy1 );
1487 wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );
1488 wrd_graphic_update ( &rc, TRUE );
1489 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
1490 }
1491 #endif
1492 }
1493
WrdWndReset(void)1494 void WrdWndReset(void)
1495 {
1496 int i;
1497 wrd_wnd_lock();
1498 w32g_wrd_wnd.curposx = 0;
1499 w32g_wrd_wnd.curposy = 0;
1500 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1501 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1502 w32g_wrd_wnd.curattr = 0;
1503 for ( i = 0; i < w32g_wrd_wnd.col; i++ ) {
1504 memset ( w32g_wrd_wnd.textbuf[i], 0x20, w32g_wrd_wnd.row );
1505 memset ( w32g_wrd_wnd.forecolorbuf[i], w32g_wrd_wnd.curforecolor, w32g_wrd_wnd.row );
1506 memset ( w32g_wrd_wnd.backcolorbuf[i], w32g_wrd_wnd.curbackcolor, w32g_wrd_wnd.row );
1507 memset ( w32g_wrd_wnd.attrbuf[i], w32g_wrd_wnd.curattr, w32g_wrd_wnd.row);
1508 }
1509 wrd_graphic_pal_init_flag = 0;
1510 wrd_wnd_unlock();
1511 wrd_text_update ( 0, 0, w32g_wrd_wnd.row - 1, w32g_wrd_wnd.col - 1, TRUE );
1512 wrd_graphic_ginit ();
1513 }
1514
WrdWndCurStateSaveAndRestore(int saveflag)1515 void WrdWndCurStateSaveAndRestore(int saveflag)
1516 {
1517 static int saved_curposx = 0;
1518 static int saved_curposy = 0;
1519 static int saved_curforecolor = W32G_WRDWND_WHITE;
1520 static int saved_curbackcolor = W32G_WRDWND_BLACK;
1521 static int saved_curattr = 0;
1522 if ( saveflag ) {
1523 saved_curforecolor = w32g_wrd_wnd.curforecolor;
1524 saved_curbackcolor = w32g_wrd_wnd.curbackcolor;
1525 saved_curattr = w32g_wrd_wnd.curattr;
1526 saved_curposx = w32g_wrd_wnd.curposx;
1527 saved_curposy = w32g_wrd_wnd.curposy;
1528 } else {
1529 w32g_wrd_wnd.curforecolor = saved_curforecolor;
1530 w32g_wrd_wnd.curbackcolor = saved_curbackcolor;
1531 w32g_wrd_wnd.curattr = saved_curattr;
1532 WrdWndGoto( saved_curposx, saved_curposy );
1533 }
1534 }
1535
1536 // from_from �s���� from_to �s�܂ł� to_from �s��擪�ɃR�s�[�B
WrdWndCopyLineS(int from_from,int from_to,int to_from,int lockflag)1537 void WrdWndCopyLineS ( int from_from, int from_to, int to_from, int lockflag )
1538 {
1539 int y, to_to;
1540 if ( !w32g_wrd_wnd.active ) return;
1541 if ( to_from >= w32g_wrd_wnd.col ) return;
1542 if ( to_from == from_from ) return;
1543 if ( from_to < from_from ) return;
1544 if ( to_from < 0 ) {
1545 from_from -= to_from;
1546 from_to -= to_from;
1547 to_from = 0;
1548 }
1549 to_to = to_from + from_to - from_from;
1550 if ( to_to >= w32g_wrd_wnd.col )
1551 to_to = w32g_wrd_wnd.col - 1;
1552 if ( lockflag ) wrd_wnd_lock();
1553 if ( to_from < from_from ) {
1554 for ( y = to_from; y <= to_to; y++ ) {
1555 int y_from = from_from + y - to_from;
1556 if ( y_from < 0 || y_from >= w32g_wrd_wnd.col ) {
1557 memset ( w32g_wrd_wnd.textbuf[y], 0x20, w32g_wrd_wnd.row );
1558 memset ( w32g_wrd_wnd.forecolorbuf[y], W32G_WRDWND_BLACK, w32g_wrd_wnd.row );
1559 memset ( w32g_wrd_wnd.backcolorbuf[y], W32G_WRDWND_BLACK, w32g_wrd_wnd.row );
1560 memset ( w32g_wrd_wnd.attrbuf[y], 0, w32g_wrd_wnd.row);
1561 } else {
1562 memcpy ( w32g_wrd_wnd.textbuf[y], w32g_wrd_wnd.textbuf[y_from], w32g_wrd_wnd.row );
1563 memcpy ( w32g_wrd_wnd.forecolorbuf[y], w32g_wrd_wnd.forecolorbuf[y_from], w32g_wrd_wnd.row );
1564 memcpy ( w32g_wrd_wnd.backcolorbuf[y], w32g_wrd_wnd.backcolorbuf[y_from], w32g_wrd_wnd.row );
1565 memcpy ( w32g_wrd_wnd.attrbuf[y], w32g_wrd_wnd.attrbuf[y_from], w32g_wrd_wnd.row );
1566 }
1567 }
1568 } else {
1569 for ( y = to_to; y >= to_from; y-- ) {
1570 int y_from = from_from + y - to_from;
1571 if ( y_from < 0 || y_from >= w32g_wrd_wnd.col ) {
1572 memset ( w32g_wrd_wnd.textbuf[y], 0x20, w32g_wrd_wnd.row );
1573 memset ( w32g_wrd_wnd.forecolorbuf[y], W32G_WRDWND_BLACK, w32g_wrd_wnd.row );
1574 memset ( w32g_wrd_wnd.backcolorbuf[y], W32G_WRDWND_BLACK, w32g_wrd_wnd.row );
1575 memset ( w32g_wrd_wnd.attrbuf[y], 0, w32g_wrd_wnd.row);
1576 } else {
1577 memcpy ( w32g_wrd_wnd.textbuf[y], w32g_wrd_wnd.textbuf[y_from], w32g_wrd_wnd.row );
1578 memcpy ( w32g_wrd_wnd.forecolorbuf[y], w32g_wrd_wnd.forecolorbuf[y_from], w32g_wrd_wnd.row );
1579 memcpy ( w32g_wrd_wnd.backcolorbuf[y], w32g_wrd_wnd.backcolorbuf[y_from], w32g_wrd_wnd.row );
1580 memcpy ( w32g_wrd_wnd.attrbuf[y], w32g_wrd_wnd.attrbuf[y_from], w32g_wrd_wnd.row );
1581 }
1582 }
1583 }
1584 if ( lockflag ) wrd_wnd_unlock();
1585 wrd_text_update ( 0, to_from, w32g_wrd_wnd.row - 1, to_to, lockflag );
1586 }
1587
1588 // from �s�� to �s�ɃR�s�[�B
WrdWndCopyLine(int from,int to,int lockflag)1589 void WrdWndCopyLine ( int from, int to, int lockflag )
1590 {
1591 if ( !w32g_wrd_wnd.active ) return;
1592 WrdWndCopyLineS ( from, from, to, lockflag );
1593 }
1594
1595 // from�s���� to �s�܂ŃN���A
WrdWndClearLineFromTo(int from,int to,int lockflag)1596 void WrdWndClearLineFromTo(int from, int to, int lockflag)
1597 {
1598 int i;
1599 if ( !w32g_wrd_wnd.active ) return;
1600 if ( from < 0 ) from = 0;
1601 if ( from >= w32g_wrd_wnd.col ) from = w32g_wrd_wnd.col - 1;
1602 if ( to < 0 ) to = 0;
1603 if ( to >= w32g_wrd_wnd.col ) to = w32g_wrd_wnd.col - 1;
1604 if ( to < from ) return;
1605 if ( lockflag ) wrd_wnd_lock();
1606 for ( i = from; i <= to; i++ ) {
1607 memset(w32g_wrd_wnd.textbuf[i], 0x20, w32g_wrd_wnd.row);
1608 memset(w32g_wrd_wnd.forecolorbuf[i], W32G_WRDWND_BLACK, w32g_wrd_wnd.row);
1609 memset(w32g_wrd_wnd.backcolorbuf[i], W32G_WRDWND_BLACK, w32g_wrd_wnd.row);
1610 memset(w32g_wrd_wnd.attrbuf[i], 0, w32g_wrd_wnd.row);
1611 }
1612 if ( lockflag ) wrd_wnd_unlock();
1613 wrd_text_update ( 0, from, w32g_wrd_wnd.row - 1, to, lockflag );
1614 }
1615
1616 // from �s�� to �s�Ɉړ��B
WrdWndMoveLine(int from,int to,int lockflag)1617 void WrdWndMoveLine(int from, int to, int lockflag)
1618 {
1619 if ( !w32g_wrd_wnd.active ) return;
1620 if ( from == to ) return;
1621 if ( from < 0 || from >= w32g_wrd_wnd.col ) return;
1622 if ( to < 0 || to >= w32g_wrd_wnd.col ) return;
1623 WrdWndCopyLine ( from, to, lockflag );
1624 WrdWndClearLineFromTo ( from,from, lockflag );
1625 }
1626
1627 // �X�N���[���_�E������B
WrdWndScrollDown(int lockflag)1628 void WrdWndScrollDown(int lockflag)
1629 {
1630 if ( !w32g_wrd_wnd.active ) return;
1631 WrdWndCopyLineS ( 0, w32g_wrd_wnd.col - 1, 1, lockflag );
1632 WrdWndClearLineFromTo ( 0, 0, lockflag );
1633 }
1634
1635 // �X�N���[���A�b�v����B
WrdWndScrollUp(int lockflag)1636 void WrdWndScrollUp(int lockflag)
1637 {
1638 if ( !w32g_wrd_wnd.active ) return;
1639 WrdWndCopyLineS ( 1, w32g_wrd_wnd.col - 1, 0, lockflag );
1640 WrdWndClearLineFromTo ( w32g_wrd_wnd.col - 1, w32g_wrd_wnd.col - 1, lockflag );
1641 }
1642
1643 // ��ʏ���
WrdWndClear(int lockflag)1644 void WrdWndClear(int lockflag)
1645 {
1646 if ( !w32g_wrd_wnd.active ) return;
1647 WrdWndClearLineFromTo ( 0, w32g_wrd_wnd.col - 1, lockflag );
1648 }
1649
1650 // �����o��
WrdWndPutString(char * str,int lockflag)1651 void WrdWndPutString(char *str, int lockflag)
1652 {
1653 if ( !w32g_wrd_wnd.active ) return;
1654 WrdWndPutStringN(str, strlen(str),lockflag);
1655 }
1656
1657 // �����o��(n����)
WrdWndPutStringN(char * str,int n,int lockflag)1658 void WrdWndPutStringN(char *str, int n, int lockflag)
1659 {
1660 int i;
1661
1662 if ( !w32g_wrd_wnd.active ) return;
1663 if ( lockflag ) wrd_wnd_lock();
1664 for(;;){
1665 if ( w32g_wrd_wnd.curposx + n <= w32g_wrd_wnd.row ) {
1666 memcpy( &w32g_wrd_wnd.textbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx], str, n );
1667 memset( &w32g_wrd_wnd.forecolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1668 w32g_wrd_wnd.curforecolor, n );
1669 memset( &w32g_wrd_wnd.backcolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1670 w32g_wrd_wnd.curbackcolor, n );
1671 memset( &w32g_wrd_wnd.attrbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1672 w32g_wrd_wnd.curattr, n );
1673 if ( lockflag ) wrd_wnd_unlock();
1674 wrd_text_update ( w32g_wrd_wnd.curposx, w32g_wrd_wnd.curposy,
1675 w32g_wrd_wnd.curposx + n - 1, w32g_wrd_wnd.curposy, lockflag );
1676 if ( lockflag ) wrd_wnd_lock();
1677 w32g_wrd_wnd.curposx += n;
1678 if ( w32g_wrd_wnd.curposx >= w32g_wrd_wnd.row ) {
1679 w32g_wrd_wnd.curposx = 0;
1680 w32g_wrd_wnd.curposy++;
1681 if ( w32g_wrd_wnd.curposy >= w32g_wrd_wnd.col ) {
1682 if ( lockflag ) wrd_wnd_unlock();
1683 WrdWndScrollUp ( lockflag );
1684 if ( lockflag ) wrd_wnd_lock();
1685 w32g_wrd_wnd.curposy = w32g_wrd_wnd.col - 1;
1686 }
1687 }
1688 break;
1689 } else {
1690 int len = w32g_wrd_wnd.row - w32g_wrd_wnd.curposx;
1691 char mbt = _MBC_SINGLE;
1692 if ( PlayerLanguage == LANGUAGE_JAPANESE ) {
1693 for ( i=0; i < len; i++ ) {
1694 mbt = _mbbtype ( str[i], mbt );
1695 }
1696 if ( mbt == _MBC_LEAD )
1697 len -= 1;
1698 }
1699 memcpy( &w32g_wrd_wnd.textbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx], str, len );
1700 memset( &w32g_wrd_wnd.forecolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1701 w32g_wrd_wnd.curforecolor, len );
1702 memset( &w32g_wrd_wnd.backcolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1703 w32g_wrd_wnd.curbackcolor, len );
1704 memset( &w32g_wrd_wnd.attrbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1705 w32g_wrd_wnd.curattr, len );
1706 if ( mbt == _MBC_LEAD ) {
1707 w32g_wrd_wnd.textbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.row-1] = 0x20;
1708 w32g_wrd_wnd.forecolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.row-1] = w32g_wrd_wnd.curforecolor;
1709 w32g_wrd_wnd.backcolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.row-1] = w32g_wrd_wnd.curbackcolor;
1710 w32g_wrd_wnd.attrbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.row-1] = 0;
1711 }
1712 if ( lockflag ) wrd_wnd_unlock();
1713 wrd_text_update ( w32g_wrd_wnd.curposx, w32g_wrd_wnd.curposy,
1714 w32g_wrd_wnd.curposx + len - 1, w32g_wrd_wnd.curposy, lockflag );
1715 if ( lockflag ) wrd_wnd_lock();
1716 n -= len;
1717 str += len;
1718 w32g_wrd_wnd.curposx = 0;
1719 w32g_wrd_wnd.curposy++;
1720 if ( w32g_wrd_wnd.curposy >= w32g_wrd_wnd.col ) {
1721 if ( lockflag ) wrd_wnd_unlock();
1722 WrdWndScrollUp(lockflag);
1723 if ( lockflag ) wrd_wnd_lock();
1724 w32g_wrd_wnd.curposy = w32g_wrd_wnd.col - 1;
1725 }
1726 }
1727 }
1728 if ( lockflag ) wrd_wnd_unlock();
1729 }
1730
1731 // left == TRUE : �s�̍�����
1732 // left != TRUE : �s�̉E����
WrdWndLineClearFrom(int left,int lockflag)1733 void WrdWndLineClearFrom(int left, int lockflag)
1734 {
1735 if ( !w32g_wrd_wnd.active ) return;
1736 if ( lockflag ) wrd_wnd_lock();
1737 if ( left ) {
1738 memset( w32g_wrd_wnd.textbuf[w32g_wrd_wnd.curposy] , 0x20 , w32g_wrd_wnd.curposx + 1 );
1739 memset( w32g_wrd_wnd.forecolorbuf[w32g_wrd_wnd.curposy], W32G_WRDWND_BLACK, w32g_wrd_wnd.curposx + 1 );
1740 memset( w32g_wrd_wnd.backcolorbuf[w32g_wrd_wnd.curposy], W32G_WRDWND_BLACK, w32g_wrd_wnd.curposx + 1 );
1741 memset( w32g_wrd_wnd.attrbuf[w32g_wrd_wnd.curposy], 0, w32g_wrd_wnd.curposx + 1 );
1742 if ( lockflag ) wrd_wnd_unlock();
1743 wrd_text_update ( 0, w32g_wrd_wnd.curposy,
1744 w32g_wrd_wnd.curposx - 1, w32g_wrd_wnd.curposy, lockflag );
1745 } else {
1746 memset( &w32g_wrd_wnd.textbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1747 0x20 , w32g_wrd_wnd.row - w32g_wrd_wnd.curposx );
1748 memset( &w32g_wrd_wnd.forecolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1749 W32G_WRDWND_BLACK, w32g_wrd_wnd.row - w32g_wrd_wnd.curposx );
1750 memset( &w32g_wrd_wnd.backcolorbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1751 W32G_WRDWND_BLACK, w32g_wrd_wnd.row - w32g_wrd_wnd.curposx );
1752 memset( &w32g_wrd_wnd.attrbuf[w32g_wrd_wnd.curposy][w32g_wrd_wnd.curposx],
1753 0, w32g_wrd_wnd.row - w32g_wrd_wnd.curposx );
1754 if ( lockflag ) wrd_wnd_unlock();
1755 wrd_text_update ( w32g_wrd_wnd.curposx, w32g_wrd_wnd.curposy,
1756 w32g_wrd_wnd.row - 1, w32g_wrd_wnd.curposy, lockflag );
1757 }
1758 }
1759
1760 // PC98 �̃A�g���r���[�g�Őݒ�
WrdWndSetAttr98(int attr)1761 void WrdWndSetAttr98(int attr)
1762 {
1763 if ( !w32g_wrd_wnd.active ) return;
1764 switch ( attr ) {
1765 case 0: // �K��l
1766 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1767 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1768 w32g_wrd_wnd.curattr = 0;
1769 break;
1770 case 1: // �n�C���C�g
1771 w32g_wrd_wnd.curattr = 0;
1772 break;
1773 case 2: // �o�[�e�B�J�����C��
1774 w32g_wrd_wnd.curattr = 0;
1775 break;
1776 case 4: // �A���_�[���C��
1777 w32g_wrd_wnd.curattr = 0;
1778 break;
1779 case 5: // �u�����N
1780 w32g_wrd_wnd.curattr = 0;
1781 break;
1782 case 7: // ���o�[�X
1783 {
1784 char tmp = w32g_wrd_wnd.curbackcolor;
1785 w32g_wrd_wnd.curbackcolor = w32g_wrd_wnd.curforecolor;
1786 w32g_wrd_wnd.curforecolor = tmp;
1787 w32g_wrd_wnd.curattr = 0;
1788 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1789 }
1790 break;
1791 case 8: // �V�[�N���b�g
1792 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1793 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1794 w32g_wrd_wnd.curattr = 0;
1795 break;
1796 case 16: // ��
1797 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1798 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1799 w32g_wrd_wnd.curattr = 0;
1800 break;
1801 case 17: // ��
1802 w32g_wrd_wnd.curforecolor = W32G_WRDWND_RED;
1803 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1804 w32g_wrd_wnd.curattr = 0;
1805 break;
1806 case 18: // ��
1807 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLUE;
1808 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1809 w32g_wrd_wnd.curattr = 0;
1810 break;
1811 case 19: // ��
1812 w32g_wrd_wnd.curforecolor = W32G_WRDWND_PURPLE;
1813 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1814 w32g_wrd_wnd.curattr = 0;
1815 break;
1816 case 20: // ��
1817 w32g_wrd_wnd.curforecolor = W32G_WRDWND_GREEN;
1818 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1819 w32g_wrd_wnd.curattr = 0;
1820 break;
1821 case 21: // ���F
1822 w32g_wrd_wnd.curforecolor = W32G_WRDWND_YELLOW;
1823 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1824 w32g_wrd_wnd.curattr = 0;
1825 break;
1826 case 22: // ���F
1827 w32g_wrd_wnd.curforecolor = W32G_WRDWND_LIGHTBLUE;
1828 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1829 w32g_wrd_wnd.curattr = 0;
1830 break;
1831 case 23: // ��
1832 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1833 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1834 w32g_wrd_wnd.curattr = 0;
1835 break;
1836 case 30: // ��
1837 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1838 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1839 w32g_wrd_wnd.curattr = 0;
1840 break;
1841 case 31: // ��
1842 w32g_wrd_wnd.curforecolor = W32G_WRDWND_RED;
1843 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1844 w32g_wrd_wnd.curattr = 0;
1845 break;
1846 case 32: // ��
1847 w32g_wrd_wnd.curforecolor = W32G_WRDWND_GREEN;
1848 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1849 w32g_wrd_wnd.curattr = 0;
1850 break;
1851 case 33: // ���F
1852 w32g_wrd_wnd.curforecolor = W32G_WRDWND_YELLOW;
1853 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1854 w32g_wrd_wnd.curattr = 0;
1855 break;
1856 case 34: // ��
1857 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLUE;
1858 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1859 w32g_wrd_wnd.curattr = 0;
1860 break;
1861 case 35: // ��
1862 w32g_wrd_wnd.curforecolor = W32G_WRDWND_PURPLE;
1863 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1864 w32g_wrd_wnd.curattr = 0;
1865 break;
1866 case 36: // ���F
1867 w32g_wrd_wnd.curforecolor = W32G_WRDWND_LIGHTBLUE;
1868 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1869 w32g_wrd_wnd.curattr = 0;
1870 break;
1871 case 37: // ��
1872 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1873 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1874 w32g_wrd_wnd.curattr = 0;
1875 break;
1876 case 40: // �����]
1877 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1878 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1879 w32g_wrd_wnd.curattr = 0;
1880 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1881 break;
1882 case 41: // �Ԕ��]
1883 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1884 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_RED;
1885 w32g_wrd_wnd.curattr = 0;
1886 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1887 break;
1888 case 42: // ���]
1889 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1890 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_GREEN;
1891 w32g_wrd_wnd.curattr = 0;
1892 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1893 break;
1894 case 43: // ���F���]
1895 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1896 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_YELLOW;
1897 w32g_wrd_wnd.curattr = 0;
1898 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1899 break;
1900 case 44: // ���]
1901 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1902 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLUE;
1903 w32g_wrd_wnd.curattr = 0;
1904 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1905 break;
1906 case 45: // �����]
1907 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1908 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_PURPLE;
1909 w32g_wrd_wnd.curattr = 0;
1910 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1911 break;
1912 case 46: // ���F���]
1913 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1914 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_LIGHTBLUE;
1915 w32g_wrd_wnd.curattr = 0;
1916 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1917 break;
1918 case 47: // �����]
1919 w32g_wrd_wnd.curforecolor = W32G_WRDWND_BLACK;
1920 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_WHITE;
1921 w32g_wrd_wnd.curattr = 0;
1922 w32g_wrd_wnd.curattr |= W32G_WRDWND_ATTR_REVERSE;
1923 break;
1924 default:
1925 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1926 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1927 w32g_wrd_wnd.curattr = 0;
1928 break;
1929 }
1930 }
1931
1932 // �A�g���r���[�g�̃��Z�b�g
WrdWndSetAttrReset(void)1933 void WrdWndSetAttrReset(void)
1934 {
1935 if ( !w32g_wrd_wnd.active ) return;
1936 w32g_wrd_wnd.curforecolor = W32G_WRDWND_WHITE;
1937 w32g_wrd_wnd.curbackcolor = W32G_WRDWND_BLACK;
1938 w32g_wrd_wnd.curattr = 0;
1939 }
1940
1941 // �J�[�\���|�W�V�����̈ړ�
WrdWndGoto(int x,int y)1942 void WrdWndGoto(int x, int y)
1943 {
1944 if ( !w32g_wrd_wnd.active ) return;
1945 if ( x < 0 ) x = 0;
1946 if ( x >= w32g_wrd_wnd.row ) x = w32g_wrd_wnd.row - 1;
1947 if ( y < 0 ) y = 0;
1948 if ( y >= w32g_wrd_wnd.col ) y = w32g_wrd_wnd.col - 1;
1949 w32g_wrd_wnd.curposx = x;
1950 w32g_wrd_wnd.curposy = y;
1951 }
1952
WrdWndPaintAll(int lockflag)1953 void WrdWndPaintAll(int lockflag)
1954 {
1955 if ( !w32g_wrd_wnd.active ) return;
1956 wrd_text_update ( 0, 0, w32g_wrd_wnd.row - 1, w32g_wrd_wnd.col - 1, TRUE );
1957 }
1958
1959 // SetInvalidateRect() �� WM_PAINT ���Ăԉ\��������B
WrdWndPaintDo(int flag)1960 void WrdWndPaintDo(int flag)
1961 {
1962 RECT rc;
1963 if ( flag ) InvalidateRect( w32g_wrd_wnd.hwnd,NULL, FALSE );
1964 if ( GetUpdateRect(w32g_wrd_wnd.hwnd, &rc, FALSE) ) {
1965 PAINTSTRUCT ps;
1966 if ( wrd_wnd_lock_ex ( 0 ) == TRUE ) {
1967 if ( GDI_LOCK_EX(0) == 0 ) {
1968 w32g_wrd_wnd.hdc = BeginPaint(w32g_wrd_wnd.hwnd, &ps);
1969 BitBlt(w32g_wrd_wnd.hdc,rc.left,rc.top,rc.right,rc.bottom,w32g_wrd_wnd.hmdc,rc.left,rc.top,SRCCOPY);
1970 EndPaint(w32g_wrd_wnd.hwnd, &ps);
1971 GDI_UNLOCK(); // gdi_lock
1972 } else {
1973 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
1974 }
1975 } else {
1976 InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );
1977 }
1978 wrd_wnd_unlock();
1979 }
1980 }
1981
1982 #define IDM_GRAPHIC_STOP 3531
1983 #define IDM_GRAPHIC_START 3532
1984
1985 BOOL CALLBACK
WrdCanvasWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)1986 WrdCanvasWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
1987 {
1988 static HMENU hPopupMenu = NULL;
1989 switch (uMess)
1990 {
1991 case WM_CREATE:
1992 break;
1993 case WM_PAINT:
1994 WrdWndPaintDo(FALSE);
1995 return 0;
1996 case WM_DROPFILES:
1997 SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam);
1998 return 0;
1999 case WM_DESTROY:
2000 if ( hPopupMenu != NULL )
2001 DestroyMenu ( hPopupMenu );
2002 hPopupMenu = NULL;
2003 break;
2004 case WM_COMMAND:
2005 switch (LOWORD(wParam)) {
2006 case IDM_GRAPHIC_STOP:
2007 WrdWndInfo.GraphicStop = 1;
2008 break;
2009 case IDM_GRAPHIC_START:
2010 WrdWndInfo.GraphicStop = 0;
2011 break;
2012 default:
2013 break;
2014 }
2015 break;
2016 case WM_RBUTTONDOWN:
2017 {
2018 if ( LOWORD(lParam ) != HTCAPTION ){
2019 POINT point;
2020 int res;
2021 if ( hPopupMenu != NULL )
2022 DestroyMenu ( hPopupMenu );
2023 hPopupMenu = CreatePopupMenu();
2024 if ( WrdWndInfo.GraphicStop ) {
2025 AppendMenu(hPopupMenu,MF_STRING,IDM_GRAPHIC_START,"Graphic Start");
2026 } else {
2027 AppendMenu(hPopupMenu,MF_STRING,IDM_GRAPHIC_STOP,"Graphic Stop");
2028 }
2029 GetCursorPos(&point);
2030 SetForegroundWindow ( hwnd );
2031 res = TrackPopupMenu ( hPopupMenu, TPM_TOPALIGN|TPM_LEFTALIGN,
2032 point.x, point.y, 0, hwnd, NULL );
2033 PostMessage ( hwnd, WM_NULL, 0, 0 );
2034 DestroyMenu ( hPopupMenu );
2035 hPopupMenu = NULL;
2036 }
2037 }
2038 break;
2039 default:
2040 return DefWindowProc(hwnd,uMess,wParam,lParam) ;
2041 }
2042 return 0L;
2043 }
2044
2045 extern void MainWndUpdateWrdButton(void);
2046
2047 BOOL CALLBACK
WrdWndProc(HWND hwnd,UINT uMess,WPARAM wParam,LPARAM lParam)2048 WrdWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
2049 {
2050 switch (uMess){
2051 case WM_INITDIALOG:
2052 SetWindowPosSize(GetDesktopWindow(),hwnd,WrdWndInfo.PosX, WrdWndInfo.PosY );
2053 return FALSE;
2054 case WM_DESTROY:
2055 TerminateWrdWnd ();
2056 INISaveWrdWnd();
2057 break;
2058 case WM_COMMAND:
2059 switch (LOWORD(wParam)) {
2060 case IDCLOSE:
2061 ShowWindow(hwnd, SW_HIDE);
2062 MainWndUpdateWrdButton();
2063 break;
2064 default:
2065 return FALSE;
2066 }
2067 case WM_MOVE:
2068 // WrdWndInfo.PosX = (int) LOWORD(lParam);
2069 // WrdWndInfo.PosY = (int) HIWORD(lParam);
2070 {
2071 RECT rc;
2072 GetWindowRect(hwnd,&rc);
2073 WrdWndInfo.PosX = rc.left;
2074 WrdWndInfo.PosY = rc.top;
2075 }
2076 break;
2077 case WM_CLOSE:
2078 ShowWindow(hWrdWnd, SW_HIDE);
2079 MainWndUpdateWrdButton();
2080 break;
2081 case WM_DROPFILES:
2082 SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam);
2083 return 0;
2084 default:
2085 return FALSE;
2086 }
2087 return FALSE;
2088 }
2089
WrdWndInfoReset(HWND hwnd)2090 static int WrdWndInfoReset(HWND hwnd)
2091 {
2092 memset(&WrdWndInfo,0,sizeof(WRDWNDINFO));
2093 WrdWndInfo.PosX = - 1;
2094 WrdWndInfo.PosY = - 1;
2095 WrdWndInfo.GraphicStop = 1;
2096 return 0;
2097 }
2098
WrdWndInfoApply(void)2099 static int WrdWndInfoApply(void)
2100 {
2101 return 0;
2102 }
2103
RGBtoRGBQUAD(COLORREF color)2104 static RGBQUAD RGBtoRGBQUAD ( COLORREF color )
2105 {
2106 RGBQUAD rq;
2107 rq.rgbRed = (unsigned char) ( ( color & 0x000000FFL ) >> 0 );
2108 rq.rgbGreen = (unsigned char) ( ( color & 0x0000FF00L ) >> 8 );
2109 rq.rgbBlue = (unsigned char) ( ( color & 0x00FF0000L ) >> 16 );
2110 rq.rgbReserved = 0;
2111 return rq;
2112 }
2113
RGBQUADtoRGB(RGBQUAD rq)2114 static COLORREF RGBQUADtoRGB ( RGBQUAD rq )
2115 {
2116 return RGB ( rq.rgbRed, rq.rgbGreen, rq.rgbBlue );
2117 }
2118
2119 extern int PosSizeSave;
2120
2121 #define SEC_WRDWND "WrdWnd"
INISaveWrdWnd(void)2122 int INISaveWrdWnd(void)
2123 {
2124 char *section = SEC_WRDWND;
2125 char *inifile = TIMIDITY_WINDOW_INI_FILE;
2126 char buffer[256];
2127 if ( PosSizeSave ) {
2128 if ( WrdWndInfo.PosX >= 0 || WrdWndInfo.PosY >= 0 ) {
2129 if ( WrdWndInfo.PosX < 0 )
2130 WrdWndInfo.PosX = 0;
2131 if ( WrdWndInfo.PosY < 0 )
2132 WrdWndInfo.PosY = 0;
2133 }
2134 sprintf(buffer,"%d",WrdWndInfo.PosX);
2135 if ( WrdWndInfo.PosX >= 0 )
2136 WritePrivateProfileString(section,"PosX",buffer,inifile);
2137 sprintf(buffer,"%d",WrdWndInfo.PosY);
2138 if ( WrdWndInfo.PosY >= 0 )
2139 WritePrivateProfileString(section,"PosY",buffer,inifile);
2140 }
2141 sprintf(buffer,"%d",WrdWndInfo.GraphicStop);
2142 WritePrivateProfileString(section,"GraphicStop",buffer,inifile);
2143 WritePrivateProfileString(NULL,NULL,NULL,inifile); // Write Flush
2144 return 0;
2145 }
2146
INILoadWrdWnd(void)2147 int INILoadWrdWnd(void)
2148 {
2149 char *section = SEC_WRDWND;
2150 char *inifile = TIMIDITY_WINDOW_INI_FILE;
2151 int num;
2152 num = GetPrivateProfileInt(section,"PosX",-1,inifile);
2153 WrdWndInfo.PosX = num;
2154 num = GetPrivateProfileInt(section,"PosY",-1,inifile);
2155 WrdWndInfo.PosY = num;
2156 num = GetPrivateProfileInt(section,"GraphicStop",1,inifile);
2157 WrdWndInfo.GraphicStop = num;
2158 return 0;
2159 }
2160
w32_wrd_ctl_event(CtlEvent * e)2161 void w32_wrd_ctl_event(CtlEvent *e)
2162 {
2163 }
2164
2165
2166