00001
00002
00003
00004 #include <ALL.H>
00005 #include <IMGFUN.H>
00006 #include <OMOUSE.H>
00007 #include <OPOWER.H>
00008 #include <OCOLTBL.H>
00009 #include <OVGA.H>
00010 #include <OVGABUF.H>
00011 #include <OIMGRES.H>
00012 #include <OSYS.H>
00013 #include <OFONT.H>
00014 #include <OBITMAP.H>
00015 #include <OBITMAPW.H>
00016
00017
00018
00019 short VgaBuf::color_scheme;
00020 char VgaBuf::color_light;
00021 char VgaBuf::color_dark;
00022 char VgaBuf::color_up;
00023 char VgaBuf::color_down;
00024 char VgaBuf::color_push;
00025 char VgaBuf::color_border;
00026
00027
00033
00034 color_scheme = colorScheme;
00035
00036 color_light = colorScheme;
00037 color_dark = colorScheme+8;
00038 color_up = colorScheme+4;
00039 color_down = colorScheme+2;
00040 color_push = colorScheme+6;
00041 color_border = colorScheme+10;
00042 }
00043
00044
00045
00046
00056
00057 err_when( !buf_locked );
00058
00059 if(sys.no_true_output_flag)
00060 if( is_front )
00061 return;
00062
00063 if( is_front )
00064 mouse.hide_area(x1,y1,x2,y2);
00065
00066
00067
00068 for(int j=y1;j<=y2;j++)
00069 for(int i=x1;i<=x2;i++) {
00070 short readpixel=(*(buf_ptr()+buf_pitch()*j+i));
00071
00072 if(((colorCode!=5)&&(colorCode!=Vga::active_buf->color_dark))
00073 ||(readpixel!=translate_color(193)))
00074 draw_pixel(i,j,colorCode);
00075 }
00076
00077 if( is_front )
00078 mouse.show_area();
00079 }
00080
00081
00082
00083
00084
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00144
00145 lt--;
00146
00147 bar(x1,y1,x2,y1+lt,color);
00148 bar(x1,y1,x1+lt,y2,color);
00149 bar(x1,y2-lt,x2,y2,color);
00150 bar(x2-lt,y1,x2,y2,color);
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 void VgaBuf::d3_rect(int x1,int y1,int x2,int y2) {
00165 rect( x1+1, y1+1, x2, y2, 1, V_WHITE );
00166 rect( x1, y1, x2-1, y2-1, 1, VGA_GRAY+8 );
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 void VgaBuf::tile(int x1,int y1,int x2,int y2,char* tileName) {
00180 err_if( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT )
00181 err_now( "VgaBuf::tile" );
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 }
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207 void VgaBuf::separator(int x1, int y1, int x2, int y2) {
00208 if( y1+1==y2 ) {
00209 bar( x1, y1, x2, y1, V_WHITE );
00210 bar( x1, y2, x2, y2, color_dark );
00211 }
00212 else {
00213 bar( x1, y1, x1, y2, V_WHITE );
00214 bar( x2, y1, x2, y2, color_dark );
00215 }
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 void VgaBuf::indicator(int x1, int y1, int x2, int y2, float curValue,
00231 float maxValue, int indiColor, int backColor) {
00232 if(sys.no_true_output_flag)
00233 if( is_front )
00234 return;
00235
00236 if( backColor == -1 )
00237 backColor = color_down;
00238
00239 if( curValue > maxValue )
00240 curValue = maxValue;
00241
00242 if( curValue > 0 ) {
00243 int barWidth = (int) ((float)(x2-x1) * curValue / maxValue);
00244
00245 int halfHeight = (y2-y1+1)/2-1;
00246 int tx2 = x1+barWidth;
00247 int y;
00248 double ic=indiColor;
00249
00250 ic+=halfHeight;
00251
00252 bar( x1-1, y1-1, x1+barWidth+1, y2+1, V_BLACK );
00253
00254 for( y=y1 ; y<y1+(halfHeight/2) ; y++, ic-=2.0 )
00255 bar( x1, y, tx2, y, (int)ic);
00256
00257 for( ; y<=y2 ; y++, ic+=0.75 )
00258 bar( x1, y, tx2, y, (int)ic );
00259
00260 if( backColor != -2 ) {
00261 if( x1+barWidth < x2 )
00262 bar( x1+barWidth+1, y1, x2, y2, backColor );
00263 }
00264 }
00265 else {
00266 if( backColor != -2 )
00267 bar( x1, y1, x2, y2, backColor );
00268 }
00269
00270 }
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 void VgaBuf::v_indicator(int x1, int y1, int x2, int y2, float curValue,
00285 float maxValue, int indiColor, int backColor) {
00286 if(sys.no_true_output_flag)
00287 if( is_front )
00288 return;
00289
00290 if( backColor == -1 )
00291 backColor = color_down;
00292
00293 if( curValue > maxValue )
00294 curValue = maxValue;
00295
00296 if( curValue > 0 ) {
00297 int barHeight = (int) ((float)(y2-y1) * curValue / maxValue);
00298
00299 int halfWidth = (x2-x1+1)/2-1;
00300 int ty2 = y1+barHeight;
00301 int x;
00302
00303 indiColor+=halfWidth;
00304
00305 for( x=x1 ; x<x1+halfWidth; x++, indiColor-- )
00306 bar( x, y1, x, ty2, indiColor );
00307
00308 for( ; x<=x2 ; x++, indiColor++ )
00309 bar( x, y1, x, ty2, indiColor );
00310
00311 if( backColor != -2 ) {
00312 if( y1+barHeight < y2 )
00313 bar( x1, y1+barHeight+1, x2, y2, backColor );
00314 }
00315 }
00316 else {
00317 if( backColor != -2 )
00318 bar( x1, y1, x2, y2, backColor );
00319 }
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00511
00512 if( is_front )
00513 mouse.hide_area( x1,y1,x2,y2 );
00514
00515 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1, y1, x2, y2, lineColor);
00516
00517 if( is_front )
00518 mouse.show_area();
00519 }
00520
00521
00522
00523
00530
00531 err_when( x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00532
00533 if( is_front )
00534 mouse.hide_area( x1,y1,x2,y2 );
00535
00536 if( y1-y2 > abs(x2-x1) ) {
00537 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1-1, x2 , y2-1, lineColor );
00538 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1 , x2 , y2 , lineColor );
00539 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1+1, x2 , y2+1, lineColor );
00540 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1+1, y1+1, x2+1, y2+1, lineColor );
00541 }
00542
00543 else if( y2-y1 > abs(x2-x1) ) {
00544 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1+1, y1-1, x2+1, y2-1, lineColor );
00545 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1-1, x2 , y2-1, lineColor );
00546 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1 , x2 , y2 , lineColor );
00547 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1 , y1+1, x2 , y2+1, lineColor );
00548 }
00549
00550 else {
00551 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1, y1-1, x2, y2-1, lineColor );
00552 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1, y1 , x2, y2 , lineColor );
00553 IMGline(buf_ptr(), buf_true_pitch(), buf_width(), buf_height(), x1, y1+1, x2, y2+1, lineColor );
00554 }
00555
00556 if( is_front )
00557 mouse.show_area();
00558 }
00559
00560
00561
00562
00577
00578 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00579
00580 if(sys.no_true_output_flag)
00581 if( is_front )
00582 return;
00583 if( is_front )
00584 mouse.hide_area( x1,y1,x2,y2 );
00585
00586
00587
00588 if( paintCentre )
00589 {
00590 if( tileName )
00591 tile( x1+t, y1+t, x2-t, y2-t, tileName);
00592 else
00593 bar_fast(x1+t, y1+t, x2-t, y2-t, 193 );
00594 }
00595
00596 int i, x, y;
00597
00598 for( i=t-1, y=y1+t-1 ; y>=y1 ; y--,i-- )
00599 bar_fast( x1+i,y,x2-i,y, i==0?V_WHITE:193
00600 );
00601
00602 for( i=t-1, x=x1+t-1 ; x>=x1 ; x--,i-- )
00603 bar_fast( x,y1+i,x,y2-i, i==0?V_WHITE:193 );
00604
00605 for( i=t-1, y=y2-t+1 ; y<=y2 ; y++,i-- )
00606 bar_fast( x1+i,y,x2-i,y, i==0?color_dark+2:color_dark-2 );
00607
00608 for( i=t-1, x=x2-t+1 ; x<=x2 ; x++,i-- )
00609 bar_fast( x,y1+i,x,y2-i, i==0?color_dark+2:color_dark-2 );
00610
00611
00612
00613 if( is_front )
00614 mouse.show_area();
00615 }
00616
00617
00618
00619
00632
00633 {
00634 err_when( x1>x2 || y1>y2 || x1<0 || y1<0 || x2>=VGA_WIDTH || y2>=VGA_HEIGHT );
00635
00636 if(sys.no_true_output_flag)
00637 if( is_front )
00638 return;
00639
00640 if( is_front )
00641 mouse.hide_area( x1,y1,x2,y2 );
00642
00643
00644
00645
00646 if( paintCentre )
00647 {
00648 if( tileName )
00649 tile( x1+t, y1+t, x2-t, y2-t, tileName );
00650 else
00651 bar_fast(x1+t, y1+t, x2-t, y2-t, color_down );
00652 }
00653
00654 if( t == 2 )
00655 {
00656
00657
00658 bar_fast( x1,y1,x2-1,y1,color_scheme+8 );
00659 bar_fast( x1+1,y2,x2,y2,V_WHITE );
00660 bar_fast( x1,y1,x1,y2-1,color_scheme+8 );
00661 bar_fast( x2,y1+1,x2,y2,V_WHITE );
00662
00663
00664
00665 bar_fast( x1+1,y1+1,x2-1,y1+1,color_scheme+15 );
00666 bar_fast( x1+1,y2-1,x2-1,y2-1,color_scheme+1 );
00667 bar_fast( x1+1,y1+1,x1+1,y2-1,color_scheme+15 );
00668 bar_fast( x2-1,y1+1,x2-1,y2-1,color_scheme+1 );
00669 }
00670 else
00671 {
00672 int i, x, y;
00673
00674 for( i=t-1, y=y2-t+1 ; y<=y2 ; y++,i-- )
00675 bar_fast( x1+i,y,x2-i,y,i==0?V_WHITE:color_light );
00676
00677 for( i=t-1, x=x2-t+1 ; x<=x2 ; x++,i-- )
00678 bar_fast( x,y1+i,x2,y2-i,i==0?V_WHITE:color_light );
00679
00680 for( i=t-1, y=y1+t-1 ; y>=y1 ; y--,i-- )
00681 bar_fast( x1+i,y,x2-i,y,i==0?color_dark+2:color_dark-2 );
00682
00683 for( i=t-1, x=x1+t-1 ; x>=x1 ; x--,i-- )
00684 bar_fast( x,y1+i,x,y2-i,i==0?color_dark+2:color_dark-2 );
00685 }
00686
00687
00688
00689 if( is_front )
00690 mouse.show_area();
00691 }
00692
00693
00694
00695
00705
00706 {
00707 if(sys.no_true_output_flag)
00708 if( is_front )
00709 return;
00710
00711 if( tileName )
00712 tile( x1+t, y1+t, x2-t, y2-t, tileName );
00713 else
00714 bar(x1+t, y1+t, x2-t, y2-t, color_up );
00715 }
00716
00717
00718
00719
00729
00730 {
00731 if(sys.no_true_output_flag)
00732 if( is_front )
00733 return;
00734 if( tileName )
00735 tile( x1+t, y1+t, x2-t, y2-t, tileName );
00736 else
00737 bar(x1+t, y1+t, x2-t, y2-t, color_down );
00738 }
00739
00740
00741
00742
00750
00751 {
00752 if( is_front )
00753 mouse.hide_area( x1,y1,x2,y2 );
00754
00755 #if( MAX_BRIGHTNESS_ADJUST_DEGREE > 10 )
00756 adjustDegree *= MAX_BRIGHTNESS_ADJUST_DEGREE / 10;
00757 #endif
00758
00759 err_when( adjustDegree < -MAX_BRIGHTNESS_ADJUST_DEGREE ||
00760 adjustDegree > MAX_BRIGHTNESS_ADJUST_DEGREE );
00761
00762
00763
00764 IMGbrightBar( buf_ptr(), buf_true_pitch(), x1, y1, x2, y2, adjustDegree);
00765
00766 if( is_front )
00767 mouse.show_area();
00768 }
00769
00770
00771
00772
00776
00777 {
00778 #if( MAX_BRIGHTNESS_ADJUST_DEGREE > 10 )
00779 adjustDegree *= MAX_BRIGHTNESS_ADJUST_DEGREE / 10;
00780 #endif
00781
00782 err_when( adjustDegree < -MAX_BRIGHTNESS_ADJUST_DEGREE ||
00783 adjustDegree > MAX_BRIGHTNESS_ADJUST_DEGREE );
00784
00785 IMGcopyWbright( buf_ptr(), buf_true_pitch(), srcBuf->buf_ptr(), srcBuf->buf_true_pitch(), srcX1, srcY1, srcX2, srcY2, adjustDegree);
00786 }
00787
00788
00789
00790
00792
00793 {
00794 short *srcPtr = srcBuf->buf_ptr();
00795 int srcWidth = srcBuf->buf_width();
00796 int srcPitch = srcBuf->buf_true_pitch();
00797 int srcHeight = srcBuf->buf_height();
00798 short *destPtr = buf_ptr();
00799 int destPitch = buf_true_pitch();
00800
00801 _asm
00802 {
00803 mov eax, y1
00804 imul destPitch
00805 add eax, x1
00806 add eax, x1
00807 mov edi, eax
00808 add edi, destPtr
00809
00810 mov esi, srcPtr
00811
00812 mov ecx, srcHeight
00813 blt_buf_1:
00814 push ecx
00815 push esi
00816 push edi
00817 mov ecx, srcWidth
00818 rep movsw
00819 pop edi
00820 pop esi
00821 pop ecx
00822 add edi, destPitch
00823 add esi, srcPitch
00824 loop blt_buf_1
00825 }
00826 }
00827