00001
00002
00003
00004 #define DEBUG_LOG_LOCAL 1
00005
00006 #include <windowsx.h>
00007
00008 #include <ALL.H>
00009 #include <IMGFUN.H>
00010 #include <COLCODE.H>
00011 #include <OMOUSE.H>
00012 #include <OMOUSECR.H>
00013 #include <OCOLTBL.H>
00014 #include <OFILE.H>
00015 #include <OSYS.H>
00016 #include <OVGA.H>
00017 #include <OLOG.H>
00018 #include <OVGALOCK.H>
00019 #include <OSYS.H>
00020
00021
00022 #define UP_OPAQUE_COLOR (VGA_GRAY+10)
00023 #define DOWN_OPAQUE_COLOR (VGA_GRAY+13)
00024
00025
00026
00027 char Vga::use_back_buf = 0;
00028 char Vga::opaque_flag = 0;
00029 VgaBuf* Vga::active_buf = &vga_front;
00030
00031
00032
00033
00034 char low_video_memory_flag = 0;
00035 extern "C" {
00036 short transparent_code_w;
00037 }
00038
00039
00040
00041 Vga::Vga() {
00042 memset( this, 0, sizeof(Vga) );
00043
00044
00045
00046 vga_color_table = new ColorTable;
00047 dont_blt =0;
00048 }
00049
00050
00051
00052
00053
00054 Vga::~Vga() {
00055 deinit();
00056
00057 delete vga_color_table;
00058
00059 err_when( back_up_pal );
00060 }
00061
00062
00063
00064
00065
00066 BOOL Vga::init() {
00067 char* warnStr = "Warning: Due to the low memory of your display card, "
00068 "you may experience problems when you quit the game or "
00069 "switch tasks during the game. "
00070 "To avoid this problem, set your Windows display "
00071 "to 800x600 16-bit color mode before running the game.";
00072
00073
00074
00075 if( !init_dd() )
00076 return FALSE;
00077
00078
00079 DDSURFACEDESC2 ddsd;
00080 DDSCAPS2 ddsCaps;
00081 DWORD dwTotal;
00082 DWORD dwFree;
00083
00084 memset(&ddsd, 0, sizeof(ddsd) );
00085 ddsd.dwSize = sizeof(ddsd);
00086 ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
00087
00088 if( dd_obj->GetDisplayMode(&ddsd) == DD_OK &&
00089 dd_obj->GetAvailableVidMem(&ddsCaps, &dwTotal, &dwFree) == DD_OK ) {
00090 if( dwFree < (DWORD) VGA_WIDTH*VGA_HEIGHT*VGA_BPP/8 &&
00091 !(ddsd.dwWidth==(DWORD)VGA_WIDTH && ddsd.dwHeight==(DWORD)VGA_HEIGHT && (ddsd.ddpfPixelFormat.dwRGBBitCount == (DWORD)VGA_BPP)) ) {
00092
00093
00094 ShowCursor(TRUE);
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 low_video_memory_flag = 1;
00107
00108 ShowCursor(FALSE);
00109 }
00110 }
00111
00112 if( !set_mode(VGA_WIDTH, VGA_HEIGHT) )
00113 return FALSE;
00114
00115 return TRUE;
00116 }
00117
00118
00119
00120
00121
00122 BOOL Vga::init_dd() {
00123 if(dd_obj)
00124 return TRUE;
00125
00126
00127
00128 DEBUG_LOG("Attempt DirectDrawCreate");
00129 LPDIRECTDRAW dd1Obj;
00130 int rc = DirectDrawCreate( NULL, &dd1Obj, NULL );
00131 DEBUG_LOG("DirectDrawCreate finish");
00132
00133 if( rc != DD_OK ) {
00134 #ifdef DEBUG
00135 debug_msg("DirectDrawCreate failed err=%d", rc);
00136 #endif
00137 return FALSE;
00138 }
00139
00140
00141
00142 DEBUG_LOG("Attempt Query DirectDraw4");
00143 rc = dd1Obj->QueryInterface(IID_IDirectDraw4, (void **)&dd_obj);
00144 DEBUG_LOG("Query DirectDraw4 finish");
00145 if( rc != DD_OK ) {
00146 #ifdef DEBUG
00147 debug_msg("Query DirectDraw4 failed err=%d", rc);
00148 #endif
00149 dd1Obj->Release();
00150 return FALSE;
00151 }
00152
00153 dd1Obj->Release();
00154
00155
00156
00157
00158
00159 DWORD dwStyle;
00160 dwStyle = GetWindowStyle(sys.main_hwnd);
00161 dwStyle |= WS_POPUP;
00162 dwStyle &= ~(WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX);
00163 SetWindowLong(sys.main_hwnd, GWL_STYLE, dwStyle);
00164
00165
00166
00167
00168
00169
00170 DEBUG_LOG("Attempt DirectDraw SetCooperativeLevel");
00171
00172 if( sys.use_true_front == 2 ) {
00173 rc = dd_obj->SetCooperativeLevel( sys.main_hwnd,
00174 DDSCL_NORMAL );
00175 }
00176 else {
00177 rc = dd_obj->SetCooperativeLevel( sys.main_hwnd,
00178 DDSCL_EXCLUSIVE |
00179 DDSCL_FULLSCREEN );
00180 }
00181
00182 DEBUG_LOG("DirectDraw SetCooperativeLevel finish");
00183
00184 if( rc != DD_OK ) {
00185 #ifdef DEBUG
00186 debug_msg("SetCooperativeLevel failed err=%d", rc);
00187 #endif
00188 return FALSE;
00189 }
00190
00191 return TRUE;
00192 }
00193
00194
00195
00196
00197
00198 BOOL Vga::set_mode(int w, int h) {
00199 HRESULT rc;
00200
00201 if( sys.use_true_front == 2 ) {
00202 }
00203 else {
00204
00205
00206
00207 DEBUG_LOG("Attempt DirectDraw SetDisplayMode");
00208
00209 rc = dd_obj->SetDisplayMode( w, h, VGA_BPP, 0, 0);
00210 DEBUG_LOG("DirectDraw SetDisplayMode finish");
00211
00212 if( rc != DD_OK ) {
00213 #ifdef DEBUG
00214 debug_msg("SetMode failed err=%d", rc);
00215 #endif
00216 return FALSE;
00217 }
00218 }
00219
00220
00221
00222 DDSURFACEDESC2 ddsd;
00223 memset(&ddsd, 0, sizeof(ddsd) );
00224 ddsd.dwSize = sizeof(ddsd);
00225
00226 pixel_format_flag = -1;
00227
00228 if( dd_obj->GetDisplayMode(&ddsd) == DD_OK && ddsd.dwFlags & DDSD_PIXELFORMAT ) {
00229 if( ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB
00230 && ddsd.ddpfPixelFormat.dwRGBBitCount == (DWORD)VGA_BPP ) {
00231 if( ddsd.ddpfPixelFormat.dwRBitMask == 0x001fL
00232 && ddsd.ddpfPixelFormat.dwGBitMask == 0x001fL << 5
00233 && ddsd.ddpfPixelFormat.dwBBitMask == 0x001fL << 10 ) {
00234 pixel_format_flag = PIXFORM_RGB_555;
00235 }
00236 else if( ddsd.ddpfPixelFormat.dwRBitMask == 0x001fL
00237 && ddsd.ddpfPixelFormat.dwGBitMask == 0x003fL << 5
00238 && ddsd.ddpfPixelFormat.dwBBitMask == 0x001fL << 11 ) {
00239 pixel_format_flag = PIXFORM_RGB_565;
00240 }
00241 else if( ddsd.ddpfPixelFormat.dwBBitMask == 0x001fL
00242 && ddsd.ddpfPixelFormat.dwGBitMask == 0x001fL << 5
00243 && ddsd.ddpfPixelFormat.dwRBitMask == 0x001fL << 10 ) {
00244 pixel_format_flag = PIXFORM_BGR_555;
00245 }
00246 else if( ddsd.ddpfPixelFormat.dwBBitMask == 0x001fL
00247 && ddsd.ddpfPixelFormat.dwGBitMask == 0x003fL << 5
00248 && ddsd.ddpfPixelFormat.dwRBitMask == 0x001fL << 11 ) {
00249 pixel_format_flag = PIXFORM_BGR_565;
00250 }
00251 }
00252
00253 if( sys.use_true_front == 2 ) {
00254 if( ddsd.dwWidth < VGA_WIDTH || ddsd.dwHeight < VGA_HEIGHT ) {
00255 MessageBox( sys.main_hwnd, "Desktop resolution too small",
00256 WIN_TITLE, MB_OK | MB_ICONWARNING | MB_SETFOREGROUND );
00257 return FALSE;
00258 }
00259 }
00260 }
00261
00262 if( pixel_format_flag == -1 ) {
00263 MessageBox(sys.main_hwnd, "Cannot determine the pixel format of this display mode.",
00264 WIN_TITLE, MB_OK | MB_ICONWARNING | MB_SETFOREGROUND );
00265
00266 if( sys.use_true_front == 2 ) {
00267 return FALSE;
00268 }
00269
00270 pixel_format_flag = PIXFORM_BGR_565;
00271 }
00272
00273
00274
00275 INITeffect(pixel_format_flag);
00276 INITbright(pixel_format_flag);
00277
00278
00279
00280 SetCursor(NULL);
00281
00282 return TRUE;
00283 }
00284
00285
00286
00287
00288
00289 void Vga::deinit() {
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 release_pal();
00300
00301 if( dd_obj ) {
00302
00303
00304
00305
00306 DEBUG_LOG("Attempt vga.dd_obj->Release()");
00307 dd_obj->Release();
00308 DEBUG_LOG("vga.dd_obj->Release() finish");
00309 dd_obj = NULL;
00310 }
00311
00312 }
00313
00314
00315
00316
00317
00318
00319
00320 BOOL Vga::load_pal(char* fileName) {
00321 char palBuf[256][3];
00322 File palFile;
00323
00324 palFile.file_open(fileName);
00325 palFile.file_seek(8);
00326 palFile.file_read(palBuf, 256*3);
00327 palFile.file_close();
00328
00329
00330
00331 if( dd_pal == NULL ) {
00332 for(int i=0; i<256; i++) {
00333 pal_entry_buf[i].peRed = palBuf[i][0];
00334 pal_entry_buf[i].peGreen = palBuf[i][1];
00335 pal_entry_buf[i].peBlue = palBuf[i][2];
00336 }
00337
00338 HRESULT rc = dd_obj->CreatePalette( DDPCAPS_8BIT, pal_entry_buf, &dd_pal, NULL );
00339
00340 if( rc != DD_OK )
00341 return FALSE;
00342 }
00343
00344 init_color_table();
00345 init_gray_remap_table();
00346
00347
00348 transparent_code_w = translate_color(TRANSPARENT_CODE);
00349
00350 return TRUE;
00351 }
00352
00353
00354
00355
00356
00357 void Vga::init_color_table() {
00358
00359
00360 PalDesc palDesc( (unsigned char*) pal_entry_buf, sizeof(PALETTEENTRY), 256, 8);
00361 vga_color_table->generate_table_fast( MAX_BRIGHTNESS_ADJUST_DEGREE, palDesc, ColorTable::bright_func );
00362
00363 default_remap_table = (short *)vga_color_table->get_table(0);
00364 }
00365
00366
00367
00368
00369
00370 void Vga::release_pal() {
00371
00372 if( dd_pal ) {
00373 while( dd_pal->Release() );
00374 dd_pal = NULL;
00375 }
00376
00377 }
00378
00379
00380
00381
00385
00386 vgaBufPtr->activate_pal(dd_pal);
00387 }
00388
00389
00390
00391
00399
00400
00401
00402 int i;
00403 int newRed, newGreen, newBlue;
00404 PALETTEENTRY palBuf[256];
00405
00406
00407
00408 for( i=0 ; i<256 ; i++ ) {
00409 newRed = (int)pal_entry_buf[i].peRed + changeValue;
00410 newGreen = (int)pal_entry_buf[i].peGreen + changeValue;
00411 newBlue = (int)pal_entry_buf[i].peBlue + changeValue;
00412
00413 palBuf[i].peRed = min(255, max(newRed,0) );
00414 palBuf[i].peGreen = min(255, max(newGreen,0) );
00415 palBuf[i].peBlue = min(255, max(newBlue,0) );
00416 }
00417
00418
00419
00420 vga_front.temp_unlock();
00421
00422 dd_pal->SetEntries( 0, 0, 256, palBuf );
00423
00424 vga_front.temp_restore_lock();
00425 }
00426
00427
00428
00429
00438
00439 BOOL Vga::blt_buf(int x1, int y1, int x2, int y2, int putBackCursor) {
00440
00441 if (dont_blt) return FALSE;
00442 if (sys.no_true_output_flag) return FALSE;
00443
00444
00445 int restoreCursor = 0;
00446 short mouseBackBufferStorageBitmap[2+64*64];
00447
00448 if( putBackCursor ) {
00449
00450
00451 if( !mouse_cursor.hide_all_flag && mouse_cursor.cur_icon
00452 && m.is_touch(x1,y1,x2,y2, mouse_cursor.cur_x1,mouse_cursor.cur_y1,mouse_cursor.cur_x2,mouse_cursor.cur_y2) ) {
00453 mouse_cursor.hide_area_flag = 0;
00454
00455 mouse_cursor.hide_x1 = x1;
00456 mouse_cursor.hide_y1 = y1;
00457 mouse_cursor.hide_x2 = x2;
00458 mouse_cursor.hide_y2 = y2;
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 err_when( BitmapW::size(min(x2,mouse_cursor.cur_x2)-max(x1,mouse_cursor.cur_x1)+1,min(y2,mouse_cursor.cur_y2)-max(y1,mouse_cursor.cur_y1)) > sizeof(mouseBackBufferStorageBitmap) );
00469 vga_back.read_bitmapW( max(x1,mouse_cursor.cur_x1), max(y1,mouse_cursor.cur_y1),
00470 min(x2,mouse_cursor.cur_x2), min(y2,mouse_cursor.cur_y2), mouseBackBufferStorageBitmap );
00471
00472 mouse_cursor.disp_back_buf(x1, y1, x2, y2);
00473 restoreCursor = 1;
00474 }
00475
00476 }
00477 else {
00478 mouse.hide_area(x1, y1, x2, y2);
00479 }
00480
00481
00482
00483
00484
00485 vga_front.temp_unlock();
00486 vga_back.temp_unlock();
00487 RECT rect = { x1, y1, x2+1, y2+1 };
00488 vga_front.dd_buf->BltFast( x1, y1, vga_back.dd_buf, &rect, DDBLTFAST_NOCOLORKEY );
00489 vga_back.temp_restore_lock();
00490 vga_front.temp_restore_lock();
00491
00492
00493
00494 if( putBackCursor ) {
00495
00496 if( restoreCursor ) {
00497
00498
00499
00500 vga_back.put_bitmapW( max(x1,mouse_cursor.cur_x1), max(y1,mouse_cursor.cur_y1),
00501 mouseBackBufferStorageBitmap );
00502 mouse_cursor.hide_area_flag = 0;
00503 }
00504
00505 }
00506 else {
00507 mouse.show_area();
00508 }
00509 return TRUE;
00510 }
00511
00512
00513
00514
00522
00523 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00524
00525 VgaBuf* vgaBuf;
00526
00527 if( vgaFrontOnly )
00528 vgaBuf = &vga_front;
00529 else
00530 vgaBuf = &vga_back;
00531
00532 if(sys.no_true_output_flag)
00533 vgaBuf = &vga_back;
00534
00535 if( !drawBorderOnly ) {
00536 if( Vga::opaque_flag )
00537 vgaBuf->bar(x1+1, y1+1, x2-1, y2-1, UP_OPAQUE_COLOR);
00538 else
00539 vgaBuf->adjust_brightness(x1+1, y1+1, x2-1, y2-1, IF_UP_BRIGHTNESS_ADJUST);
00540 }
00541
00542 mouse.hide_area( x1,y1,x2,y2 );
00543
00544
00545
00546
00547 vgaBuf->bar_fast( x1+1,y1,x2,y1, IF_LIGHT_BORDER_COLOR );
00548
00549 vgaBuf->bar_fast( x1,y1,x1,y2 , IF_LIGHT_BORDER_COLOR );
00550
00551
00552
00553
00554 vgaBuf->bar_fast( x1+1,y2,x2,y2, IF_DARK_BORDER_COLOR );
00555
00556 vgaBuf->bar_fast( x2,y1+1,x2,y2, IF_DARK_BORDER_COLOR );
00557
00558
00559
00560 mouse.show_area();
00561
00562
00563
00564 if( !vgaFrontOnly && !use_back_buf )
00565 vga.blt_buf(x1, y1, x2, y2, 0);
00566 }
00567
00568
00569
00570
00578
00579 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00580
00581 VgaBuf* vgaBuf;
00582
00583 if( vgaFrontOnly )
00584 vgaBuf = &vga_front;
00585 else
00586 vgaBuf = &vga_back;
00587
00588 if(sys.no_true_output_flag)
00589 vgaBuf = &vga_back;
00590
00591 if( !drawBorderOnly ) {
00592 if( Vga::opaque_flag )
00593 vgaBuf->bar(x1+1, y1+1, x2-1, y2-1, DOWN_OPAQUE_COLOR);
00594 else
00595 vgaBuf->adjust_brightness(x1+1, y1+1, x2-1, y2-1, IF_DOWN_BRIGHTNESS_ADJUST);
00596 }
00597
00598 mouse.hide_area( x1,y1,x2,y2 );
00599
00600
00601
00602
00603 vgaBuf->bar_fast( x1+1,y1,x2,y1, IF_DARK_BORDER_COLOR );
00604
00605 vgaBuf->bar_fast( x1,y1,x1,y2 , IF_DARK_BORDER_COLOR );
00606
00607
00608
00609
00610 vgaBuf->bar_fast( x1+1,y2,x2,y2, IF_LIGHT_BORDER_COLOR );
00611
00612 vgaBuf->bar_fast( x2,y1+1,x2,y2, IF_LIGHT_BORDER_COLOR );
00613
00614
00615
00616 mouse.show_area();
00617
00618
00619
00620 if( !vgaFrontOnly && !use_back_buf )
00621 vga.blt_buf(x1, y1, x2, y2, 0);
00622 }
00623
00624
00625
00626
00634
00635 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00636
00637 VgaBuf* vgaBuf;
00638
00639 if( vgaFrontOnly )
00640 vgaBuf = &vga_front;
00641 else
00642 vgaBuf = &vga_back;
00643
00644 if(sys.no_true_output_flag)
00645 vgaBuf = &vga_back;
00646
00647 if( !drawBorderOnly )
00648 vgaBuf->adjust_brightness(x1+2, y1+2, x2-3, y2-3, IF_UP_BRIGHTNESS_ADJUST);
00649
00650 mouse.hide_area( x1,y1,x2,y2 );
00651
00652
00653
00654 vgaBuf->bar_fast( x1,y1,x2-3,y1+1,0x9a );
00655 vgaBuf->draw_pixel(x2-2, y1, 0x9a);
00656 vgaBuf->bar_fast( x1,y1+2,x1+1,y2-3, 0x9a );
00657 vgaBuf->draw_pixel(x1, y2-2, 0x9a);
00658
00659
00660
00661 vgaBuf->bar_fast( x2-2,y1+2,x2-1,y2-1, 0x90 );
00662 vgaBuf->draw_pixel(x2-1, y1+1, 0x90);
00663 vgaBuf->bar_fast( x1+2,y2-2,x2-3,y2-1, 0x90 );
00664 vgaBuf->draw_pixel(x1+1, y2-1, 0x90);
00665
00666
00667 vgaBuf->draw_pixel(x2-1, y1, 0x97);
00668 vgaBuf->draw_pixel(x2-2, y1+1, 0x97);
00669 vgaBuf->draw_pixel(x1, y2-1, 0x97);
00670 vgaBuf->draw_pixel(x1+1, y2-2, 0x97);
00671
00672
00673 vgaBuf->bar_fast( x2, y1+1, x2, y2, 0x97);
00674 vgaBuf->bar_fast( x1+1, y2, x2-1, y2, 0x97);
00675
00676
00677
00678 mouse.show_area();
00679
00680
00681
00682 if( !vgaFrontOnly && !use_back_buf )
00683 vga.blt_buf(x1, y1, x2, y2, 0);
00684 }
00685
00686
00687
00688
00696
00697 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00698
00699 VgaBuf* vgaBuf;
00700
00701 if( vgaFrontOnly )
00702 vgaBuf = &vga_front;
00703 else
00704 vgaBuf = &vga_back;
00705
00706 if(sys.no_true_output_flag)
00707 vgaBuf = &vga_back;
00708
00709 if( !drawBorderOnly )
00710 vgaBuf->adjust_brightness(x1+2, y1+2, x2-3, y2-3, IF_DOWN_BRIGHTNESS_ADJUST);
00711
00712 mouse.hide_area( x1,y1,x2,y2 );
00713
00714
00715
00716 vgaBuf->bar_fast( x1,y1,x2-3,y1+1,0x90 );
00717 vgaBuf->draw_pixel(x2-2, y1, 0x90);
00718 vgaBuf->bar_fast( x1,y1+2,x1+1,y2-3, 0x90 );
00719 vgaBuf->draw_pixel(x1, y2-2, 0x90);
00720
00721
00722
00723 vgaBuf->bar_fast( x2-2,y1+2,x2-1,y2-1, 0x9a );
00724 vgaBuf->draw_pixel(x2-1, y1+1, 0x9a);
00725 vgaBuf->bar_fast( x1+2,y2-2,x2-3,y2-1, 0x9a );
00726 vgaBuf->draw_pixel(x1+1, y2-1, 0x9a);
00727
00728
00729 vgaBuf->draw_pixel(x2-1, y1, 0x97);
00730 vgaBuf->draw_pixel(x2-2, y1+1, 0x97);
00731 vgaBuf->draw_pixel(x1, y2-1, 0x97);
00732 vgaBuf->draw_pixel(x1+1, y2-2, 0x97);
00733
00734
00735 vgaBuf->bar_fast( x2, y1+1, x2, y2, 0x9c);
00736 vgaBuf->bar_fast( x1+1, y2, x2-1, y2, 0x9c);
00737
00738 mouse.show_area();
00739
00740
00741
00742 if( !vgaFrontOnly && !use_back_buf )
00743 vga.blt_buf(x1, y1, x2, y2, 0);
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757 void Vga::separator(int x1, int y1, int x2, int y2) {
00758 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00759
00760 if( y1+1==y2 ) {
00761 vga_front.adjust_brightness(x1, y1, x2, y1, IF_UP_BRIGHTNESS_ADJUST);
00762 vga_front.adjust_brightness(x1, y2, x2, y2, IF_DOWN_BRIGHTNESS_ADJUST);
00763 }
00764 else {
00765 vga_front.adjust_brightness(x1, y1, x1, y2, IF_UP_BRIGHTNESS_ADJUST);
00766 vga_front.adjust_brightness(x2, y1, x2, y2, IF_DOWN_BRIGHTNESS_ADJUST);
00767 }
00768 }
00769
00770
00771
00772
00776
00777
00778
00779 #define FIRST_GRAY_COLOR 0x90
00780 #define GRAY_SCALE_COUNT 16 // no. of gray colors
00781
00782
00783
00784
00785 PALETTEENTRY* palEntry = vga.pal_entry_buf;
00786 int i, grayIndex;
00787
00788 for( i=0 ; i<256 ; i++, palEntry++ ) {
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 grayIndex = ((int)palEntry->peRed * 30 + (int)palEntry->peGreen * 59 +
00800 (int)palEntry->peBlue * 11) / 100 / (256/GRAY_SCALE_COUNT);
00801
00802 gray_remap_table[i] = FIRST_GRAY_COLOR + grayIndex;
00803 }
00804 }
00805
00806
00807
00808 int Vga::make_pixel(BYTE red, BYTE green, BYTE blue) {
00809 return IMGmakePixel((blue << 16) + (green << 8) + red);
00810 }
00811
00812 int Vga::make_pixel(RGBColor *rgb) {
00813 int u;
00814 memcpy(&u, rgb, sizeof(RGBColor));
00815 return IMGmakePixel(u);
00816 }
00817
00818 void Vga::decode_pixel(int p, RGBColor *rgb) {
00819 int u = IMGdecodePixel(p);
00820 memcpy(rgb, &u, sizeof(RGBColor));
00821 }