void ScrollButtons(struct ScrollBar *scroll) { if(user_interface.scrollbarstyle == 'C') //C = Clarence ;) return; if(!scroll->scrollbarstyle || !scroll->yvisible) return; else { //arrow up Box3Dv(scroll->xtop+scroll->xsize+1,scroll->y_decrease_gap, scroll->xtop+scroll->xsize+user_interface.scrollbarsize,scroll->y_decrease_gap+18); x_setcolor(8); x_line(scroll->xtop+scroll->xsize+user_interface.scrollbarsize/2,4+scroll->y_decrease_gap, scroll->xtop+scroll->xsize+3,14+scroll->y_decrease_gap); x_setcolor(15); x_line(scroll->xtop+scroll->xsize+3,14+scroll->y_decrease_gap, scroll->xtop+scroll->xsize+user_interface.scrollbarsize-3,14+scroll->y_decrease_gap); //arrow down Box3Dv(scroll->xtop+scroll->xsize+1,scroll->y_increase_gap, scroll->xtop+scroll->xsize+user_interface.scrollbarsize,scroll->y_increase_gap+17); x_setcolor(15); x_line(scroll->xtop+scroll->xsize+user_interface.scrollbarsize/2,scroll->y_increase_gap+13, scroll->xtop+scroll->xsize+user_interface.scrollbarsize-3,scroll->y_increase_gap+4); x_setcolor(8); x_line(scroll->xtop+scroll->xsize+3,scroll->y_increase_gap+4, scroll->xtop+scroll->xsize+user_interface.scrollbarsize-3,scroll->y_increase_gap+4); if(!scroll->xvisible) return; //arrow left Box3Dh(scroll->x_decrease_gap,scroll->ytop+scroll->ysize+1, scroll->x_decrease_gap+18,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); x_setcolor(8); x_line(scroll->x_decrease_gap+4,scroll->ytop+scroll->ysize+user_interface.scrollbarsize/2, scroll->x_decrease_gap+14,scroll->ytop+scroll->ysize+3); x_setcolor(15); x_line(scroll->x_decrease_gap+14,scroll->ytop+scroll->ysize+3, scroll->x_decrease_gap+14,scroll->ytop+scroll->ysize+user_interface.scrollbarsize-3); if(scroll->scrollbarstyle!='W') { x_setcolor(0); x_line(scroll->x_increase_gap-1,scroll->ytop+scroll->ysize+1,scroll->x_increase_gap-1,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); } //arrow right Box3Dh(scroll->x_increase_gap,scroll->ytop+scroll->ysize+1, scroll->x_increase_gap+18,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); x_setcolor(15); x_line(scroll->x_increase_gap+14,scroll->ytop+scroll->ysize+user_interface.scrollbarsize/2, scroll->x_increase_gap+4,scroll->ytop+scroll->ysize+user_interface.scrollbarsize-3); x_setcolor(8); x_line(scroll->x_increase_gap+4,scroll->ytop+scroll->ysize+3 , scroll->x_increase_gap+4,scroll->ytop+scroll->ysize+user_interface.scrollbarsize-3); } }
void x_poly(int nump, int *pole ) { int i; for ( i = 2; i < nump*2; i += 2 ) x_line(pole[i-2], pole[i-1], pole[i], pole[i+1] ); }
void textwindow(int Margin){ int x0=0+Margin; int y0=0+Margin; int x1=ScrnPhysicalPixelWidth-Margin; int y1=ScrnPhysicalHeight-Margin; x_rect_fill(x0, y0, x1,y1,VisiblePageOffs,1); x_line(x0,y0,x1,y0,2,VisiblePageOffs); x_line(x0,y1,x1,y1,2,VisiblePageOffs); x_line(x0,y0,x0,y1,2,VisiblePageOffs); x_line(x1,y0,x1,y1,2,VisiblePageOffs); x_line(x0+2,y0+2,x1-2,y0+2,2,VisiblePageOffs); x_line(x0+2,y1-2,x1-2,y1-2,2,VisiblePageOffs); x_line(x0+2,y0+2,x0+2,y1-2,2,VisiblePageOffs); x_line(x1-2,y0+2,x1-2,y1-2,2,VisiblePageOffs); textwindow_x=x0; textwindow_y=y0; }
static void render_heat_border (cairo_surface_t * surface, double magfloor, const RECT *r) { const char *decibels = "dB" ; char text [512] ; cairo_t * cr ; cairo_text_extents_t extents ; TICKS ticks ; int k, tick_count ; cr = cairo_create (surface) ; cairo_set_source_rgb (cr, 1.0, 1.0, 1.0) ; cairo_set_line_width (cr, BORDER_LINE_WIDTH) ; /* Border around actual spectrogram. */ cairo_rectangle (cr, r->left, r->top, r->width, r->height) ; cairo_stroke (cr) ; cairo_select_font_face (cr, font_family, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) ; cairo_set_font_size (cr, 1.0 * NORMAL_FONT_SIZE) ; cairo_text_extents (cr, decibels, &extents) ; cairo_move_to (cr, r->left + (r->width - extents.width) / 2, r->top - 5) ; cairo_show_text (cr, decibels) ; tick_count = calculate_ticks (0.0, fabs (magfloor), r->height, false, &ticks) ; for (k = 0 ; k < tick_count ; k++) { x_line (cr, r->left + r->width, r->top + ticks.distance [k], TICK_LEN) ; if (JUST_A_TICK (ticks, k)) continue ; str_print_value (text, sizeof (text), -1.0 * ticks.value [k], ticks.decimal_places_to_print) ; cairo_text_extents (cr, text, &extents) ; cairo_move_to (cr, r->left + r->width + 2 * TICK_LEN, r->top + ticks.distance [k] + extents.height / 4.5) ; cairo_show_text (cr, text) ; } ; cairo_destroy (cr) ; } /* render_heat_border */
//划线函数(有符号) void Line( unsigned int y1, unsigned char x1, unsigned int y2, unsigned char x2, uint8 Mode) { unsigned char x,y,z; float k,b; if(x1==x2) y_line(y1,x1, y2, Mode); else if(y1==y2) x_line(y1,x1, x2, Mode); else { z=0; { signed int y_f,x_f; y_f=(signed int)y2-(signed int)y1; x_f=(signed int)x2-(signed int)x1; if( abs(y_f)< abs(x_f) ) // |k|<=1 z=1; } if( z==1 ) // |k|<=1 { { signed int y_f,x_f; y_f=(signed int)y2-(signed int)y1; x_f=(signed int)x2-(signed int)x1; k=(float)(y_f) / (float)(x_f) ; b=(float)y1-k*(float)x1; } if( x1 < x2 ) { z=y1; for(x=x1+1;x<x2;x++) { y=(unsigned char)(k*(float)x+b); Pixel(y, x, Mode); y_line(y, x, z, Mode); z=y; } } else { z=y2; for(x=x2+1;x<x1;x++) { y=(unsigned char)(k*(float)x+b); Pixel(y, x, Mode); y_line(y, x, z, Mode); z=y; } } } else // abs(y1-y2) < abs(x1-x2) |K|>1 { { signed int y_f,x_f; y_f=(signed int)y2-(signed int)y1; x_f=(signed int)x2-(signed int)x1; k=(float)x_f / (float)y_f ; b=(float)x1-k*(float)y1; } if( y1 <= y2 ) { z=x1; for(y=y1+1;y<y2;y++) { x=(unsigned char)(k*(float)y+b); Pixel( y , x,Mode ); x_line(y, x, z, Mode); z=x; } } else { z=x2; for(y=y2+1;y<y1;y++) { x=(unsigned char)(k*(float)y+b); Pixel( y, x,Mode ); x_line(y, x, z,Mode); z=x; } } } } }
void outs( char far *s) /* print a ASCIIZ string to stdio */ { #ifdef CAV if (GLOBAL.clipdel == CLIPBOARD_DEFER_ADD || GLOBAL.clipdel == CLIPBOARD_ADDHOT) return; #endif if(fullscreen) return; #ifndef TEXTONLY { char str[105], *ptr; int l; //!!glennmcc: Aug 22, 2005 -- maintain size independant of fontshift htmlfont(1-user_interface.fontshift,0); // htmlfont(1,0); l=x_charmax((unsigned char *)s,x_maxx()-200); if(l>100) l=100; x_setfill(0,7); #ifndef AGB #ifdef CUSTOMER x_setcolor(15); x_line(2,x_maxy()-14,x_maxx()-2,x_maxy()-14); x_setcolor(8); x_line(2,x_maxy()-1,x_maxx()-2,x_maxy()-1); x_bar(2,x_maxy()-13,x_maxx()-2,x_maxy()-2); #else x_setcolor(15); x_line(2,x_maxy()-14,x_maxx()-154,x_maxy()-14); x_setcolor(8); x_line(2,x_maxy()-1,x_maxx()-154,x_maxy()-1); x_bar(2,x_maxy()-13,x_maxx()-154,x_maxy()-2); #endif // CUSTOMER #else x_setcolor(15); x_line(2,x_maxy()-14,x_maxx()-2,x_maxy()-14); x_setcolor(8); x_line(2,x_maxy()-1,x_maxx()-2,x_maxy()-1); x_bar(2,x_maxy()-13,x_maxx()-2,x_maxy()-2); #endif // AGB if(strlen(s)>l && l>3) { l-=3; makestr(str,s,l); strcat(str,"..."); ptr=str; } else ptr=s; x_setcolor(0); x_text_ib(4,x_maxy()-15,(unsigned char *)ptr); //redraw time! lasttime[0]='\0'; } #else puts(s); #endif }
static void render_spect_border (cairo_surface_t * surface, const char * filename, double left, double width, double seconds, double top, double height, double min_freq, double max_freq, bool log_freq) { char text [512] ; cairo_t * cr ; cairo_text_extents_t extents ; cairo_matrix_t matrix ; TICKS ticks ; int k, tick_count ; cr = cairo_create (surface) ; cairo_set_source_rgb (cr, 1.0, 1.0, 1.0) ; cairo_set_line_width (cr, BORDER_LINE_WIDTH) ; /* Print title. */ cairo_select_font_face (cr, font_family, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) ; cairo_set_font_size (cr, 1.0 * TITLE_FONT_SIZE) ; snprintf (text, sizeof (text), "Spectrogram: %s", filename) ; cairo_text_extents (cr, text, &extents) ; cairo_move_to (cr, left + 2, top - extents.height / 2) ; cairo_show_text (cr, text) ; /* Print labels. */ cairo_select_font_face (cr, font_family, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) ; cairo_set_font_size (cr, 1.0 * NORMAL_FONT_SIZE) ; /* Border around actual spectrogram. */ cairo_rectangle (cr, left, top, width, height) ; /* Put ticks on Time axis */ tick_count = calculate_ticks (0.0, seconds, width, false, &ticks) ; for (k = 0 ; k < tick_count ; k++) { y_line (cr, left + ticks.distance [k], top + height, TICK_LEN) ; if (JUST_A_TICK (ticks, k)) continue ; str_print_value (text, sizeof (text), ticks.value [k], ticks.decimal_places_to_print) ; cairo_text_extents (cr, text, &extents) ; cairo_move_to (cr, left + ticks.distance [k] - extents.width / 2, top + height + 8 + extents.height) ; cairo_show_text (cr, text) ; } ; /* Put ticks on Frequency axis */ tick_count = calculate_ticks (min_freq, max_freq, height, log_freq, &ticks) ; for (k = 0 ; k < tick_count ; k++) { x_line (cr, left + width, top + height - ticks.distance [k], TICK_LEN) ; if (JUST_A_TICK (ticks, k)) continue ; str_print_value (text, sizeof (text), ticks.value [k], ticks.decimal_places_to_print) ; cairo_text_extents (cr, text, &extents) ; cairo_move_to (cr, left + width + 12, top + height - ticks.distance [k] + extents.height / 4.5) ; cairo_show_text (cr, text) ; } ; cairo_set_font_size (cr, 1.0 * NORMAL_FONT_SIZE) ; /* Label X axis. */ snprintf (text, sizeof (text), "Time (secs)") ; cairo_text_extents (cr, text, &extents) ; cairo_move_to (cr, left + (width - extents.width) / 2, cairo_image_surface_get_height (surface) - 8) ; cairo_show_text (cr, text) ; /* Label Y axis (rotated). */ snprintf (text, sizeof (text), "Frequency (Hz)") ; cairo_text_extents (cr, text, &extents) ; cairo_get_font_matrix (cr, &matrix) ; cairo_matrix_rotate (&matrix, -0.5 * M_PI) ; cairo_set_font_matrix (cr, &matrix) ; cairo_move_to (cr, cairo_image_surface_get_width (surface) - 12, top + (height + extents.width) / 2) ; cairo_show_text (cr, text) ; cairo_destroy (cr) ; } /* render_spect_border */
//Draw time void clock_and_timer(char *wait) //kresleni casu a screensaver { #ifndef POSIX struct time t; #endif char cas2[32]; timestr(cas2); if (strcmp(lasttime,cas2) == 0 ) return; #ifndef CLEMTEST #ifndef AGB if((ScreenSaver>0l||lasttime[0]=='*') && SecondsSleeping>(long)ScreenSaver*60l) { /* if(1) { mouseoff(); // strcpy(buf,"system\\scrnsvrs\\stin.exe"); // closebat(buf,RESTART_REDRAW); // GLOBAL.willexecute=willexecute(buf); // GLOBAL.gotolocation=1; execl("system\\scrnsvrs\\stin.exe","system\\scrnsvrs\\stin.exe",NULL); graphicsinit(arachne.graphics); // XLOPIF SVGA GRAPHICS } else */ { int j; int fullscr[4]={0,0,0,0}; int x,y,px,py,done=0; fullscr[2]=x_maxx(); fullscr[3]=x_maxy(); { #define MAX_CERFS 20 #define MAX_TRACK 100 int xx[MAX_CERFS],yy[MAX_CERFS],xs[MAX_CERFS],ys[MAX_CERFS],col[MAX_CERFS]; int x2[MAX_CERFS],y2[MAX_CERFS],xs2[MAX_CERFS],ys2[MAX_CERFS]; int tracklen[MAX_CERFS]; int trackcnt[MAX_CERFS]; int trackbuf[MAX_CERFS]; int xtr[MAX_CERFS][MAX_TRACK],ytr[MAX_CERFS][MAX_TRACK]; int xt2[MAX_CERFS][MAX_TRACK],yt2[MAX_CERFS][MAX_TRACK]; int pom; int cerfs=MAX_CERFS/2; char barva0[6]={1,3,9,11,7,8}; char barva1[6]={1,2,3,6,10,14}; char *barva; char *value; #ifdef HICOLOR int dc=1,p=0; #endif //----------------------------screensaver mouseoff(); x_cleardev(); #ifdef LINUX #define RND(X) (random()*X) srandom(time(NULL)); #else #define RND(X) random(X) randomize(); #endif value=configvariable(&ARACHNEcfg,"ScreenSaverColors",NULL); if(value && *value=='1') barva=barva1; else barva=barva0; value=configvariable(&ARACHNEcfg,"ScreenSaverMess",NULL); if(value) { cerfs=atoi(value); if(cerfs<1) cerfs=1; if(cerfs>MAX_CERFS) cerfs=MAX_CERFS; } value=configvariable(&ARACHNEcfg,"ScreenSaverStyle",NULL); j=0; while(j<cerfs) //deklarace car { xx[j]=100+RND(fullscr[2]-200); yy[j]=100+RND(fullscr[3]-200); if(*value=='C') x2[j]=10+RND(fullscr[3]/3); else { x2[j]=120+RND(fullscr[2]-240); y2[j]=120+RND(fullscr[3]-240); } if(*value=='R') {xs[j]=RND(2);if(xs[j]==0)xs[j]=-1;} else {xs[j]=RND(3);if(xs[j]==2)xs[j]=-1;} ys[j]=RND(2);if(ys[j]==0)ys[j]=-1; xs2[j]=RND(2);if(xs2[j]==0)xs2[j]=-1; if(*value=='R') {ys2[j]=RND(2);if(ys2[j]==0)ys2[j]=-1;} else {ys2[j]=RND(3);if(ys2[j]==2)ys2[j]=-1;} col[j]=barva[RND(6)]; pom=RND(MAX_TRACK-10)+10; tracklen[j]=pom; trackcnt[j]=1; //odsud se bude cist trackbuf[j]=0; //sem se bude zapisovat while(pom>=0) { xtr[j][pom]=0; ytr[j][pom]=0; xt2[j][pom]=0; yt2[j][pom]=0; pom--; } j+=1; }//loop j=0; ImouseRead( &x, &y ); ImouseWait(); px=x;py=y; while(!done) //animace { if(wait!=NULL) { #ifdef POSIX time_t t=time(NULL); struct tm *gt=gmtime(&t); sprintf(cas2,"%2d:%02d:%02d", gt->tm_hour, gt->tm_min, gt->tm_sec ); #else gettime(&t); sprintf(cas2,"%2d:%02d:%02d", t.ti_hour, t.ti_min, t.ti_sec ); #endif if(strstr(wait,cas2)!=NULL)break; }//endif #ifndef LINUX if(g_PrtScr) { g_PrtScr = 0; PrintScreen2BMP(0); goto out; } #endif //mazani stopy x_setcolor(0); #ifndef LINUX if(*value=='C') x_circle(xtr[j][trackcnt[j]],ytr[j][trackcnt[j]],xt2[j][trackcnt[j]]); else #endif if(*value=='R') x_rect(xtr[j][trackcnt[j]],ytr[j][trackcnt[j]],xt2[j][trackcnt[j]],yt2[j][trackcnt[j]]); else x_line(xtr[j][trackcnt[j]],ytr[j][trackcnt[j]],xt2[j][trackcnt[j]],yt2[j][trackcnt[j]]); if(++trackcnt[j]>tracklen[j])trackcnt[j]=0; xtr[j][trackbuf[j]]=xx[j]; ytr[j][trackbuf[j]]=yy[j]; xt2[j][trackbuf[j]]=x2[j]; yt2[j][trackbuf[j]]=y2[j]; if(++trackbuf[j]>tracklen[j])trackbuf[j]=0; //kresleni nove cary x_setcolor(col[j]); #ifndef LINUX if(*value=='C') x_circle(xx[j],yy[j],x2[j]); else #endif if(*value=='R') x_rect(xx[j],yy[j],x2[j],y2[j]); else x_line(xx[j],yy[j],x2[j],y2[j]); xx[j]+=xs[j]; yy[j]+=ys[j]; x2[j]+=xs2[j]; y2[j]+=ys2[j]; if(xx[j]>=fullscr[2]||xx[j]<=0)xs[j]=-xs[j]; if(yy[j]>=fullscr[3]||yy[j]<=0)ys[j]=-ys[j]; if(x2[j]>=fullscr[2]||x2[j]<=0)xs2[j]=-xs2[j]; if(y2[j]>=fullscr[3]||y2[j]<=0)ys2[j]=-ys2[j]; j++; if(j==cerfs) j=0; if(*value=='C' || j%10==0) { //!!RAY: Sep 30, 2006 -- CTRL key will now deactivate the screensaver if((bioskey(1) || bioskey(2) &4) || ImouseRead( &x, &y ) || x!=px || y!=py) // if(bioskey(1) || ImouseRead( &x, &y ) || x!=px || y!=py) done=1; } px=x;py=y; #ifdef HICOLOR if(xg_256 == MM_Hic) { if(p>20*cerfs) { dc=-dc; p=0; } p++; if(p%cerfs==0) { int c=1; while(c<16) { if(c%2) dc=-dc; Iipal[c*3]+=dc; if(Iipal[c*3]>63) Iipal[c*3]=63; if(Iipal[c*3]<0) Iipal[c*3]=0; Iipal[c*3+1]+=dc; if(Iipal[c*3+1]>63) Iipal[c*3+1]=63; if(Iipal[c*3+1]<0) Iipal[c*3+1]=0; Iipal[c*3+2]+=dc; if(Iipal[c*3+2]>63) Iipal[c*3+2]=63; if(Iipal[c*3+2]<0) Iipal[c*3+2]=0; c++; }//loop } x_palett( 16, Iipal); } #endif }//loop if(bioskey(1))bioskey(0); ImouseWait(); out: #ifdef HICOLOR if(xg_256 == MM_Hic) initpalette(); #endif x_cleardev(); RedrawALL(); DrawTitle(1); if(lasttime[1]=='*') redraw=4; else redraw=3; } } SecondsSleeping=0l; }//endif screensaver #endif// AGB #endif// CLEMTEST #ifndef GGI //it doesn't make sense to show time in X11 app.. if(!fullscreen) { x_setfill(0,7); //sediva if(mousey>x_maxy()-30 && mousex>x_maxx()-230) mouseoff(); #ifdef CUSTOMER x_bar(x_maxx()-56,x_maxy()-13,x_maxx()-2,x_maxy()-2); x_setcolor(0); //cerna htmlfont(1,0); x_text_ib( x_maxx()-56,x_maxy()-15,(unsigned char *)cas2); #elif AGB x_bar(x_maxx()-56,x_maxy()-13,x_maxx()-2,x_maxy()-2); x_setcolor(0); //cerna htmlfont(1,0); x_text_ib( x_maxx()-56,x_maxy()-15,(unsigned char *)cas2); #else x_bar(x_maxx()-206,x_maxy()-13,x_maxx()-156,x_maxy()-2); x_setcolor(0); //cerna //!!glennmcc: Aug 22, 2005 //prevent fontshift >0 from causing the clock to go 'off the right' htmlfont(0-user_interface.fontshift,0); // htmlfont(1,0); x_text_ib( x_maxx()-206,x_maxy()-15,(unsigned char *)cas2); #endif if(mousey>x_maxy()-30 && mousex>x_maxx()-230) mouseon(); } #endif if(lasttime[0]) //not if time redraw was forced! { SecondsSleeping++; if(GLOBAL.timeout) GLOBAL.secondsleft--; if(ppplogtime && tcpip) draw_time_online(); } strcpy(lasttime,cas2); }//end sub
void main(){ int i, j, xinc, yinc, Margin; char ch; WORD curr_x=0, curr_y=0; pal = (char far *) farmalloc(256*3); pal2 = (char far *) farmalloc(256*3); userfnt1 = (char far *) farmalloc(256*16+4); /* INITIALIZE XLIB */ /* we set up Mode X 360x200x256 with a logical width of ~ 500 */ /* pixels; we actually get 496 due to the fact that the width */ /* must be divisible by 8 */ x_text_mode(); /* make sure VGA is in color mode, if possible */ x_set_mode(X_MODE_360x200,500); /* actually is set to 496 */ x_install_vsync_handler(2); x_set_splitscreen(ScrnPhysicalHeight-60); /* split screen 60 pixels high */ x_set_doublebuffer(220); x_text_init(); x_hide_splitscreen(); x_mouse_init(); MouseColor=2; atexit(exitfunc); /* DRAW BACKGROUND LINES */ for(j=0;j<ScrnPhysicalHeight;j++){ x_line(0,j,ScrnLogicalPixelWidth,j,16+(j%239),VisiblePageOffs); } ctrlbrk(terminate); x_get_pal_struc(pal, 240,16); load_user_fonts(); intro_1(); x_set_font(2); x_hide_mouse(); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Hi, folks. This is yet another FREEWARE Mode X"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " graphics library. It is by no means complete,"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " but I believe it contains a rich enough set of"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " functions to achieve its design goal - to be"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " a game development oriented library for"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Borland TC/BC/BC++ and TASM programmers."); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " This library comes with TASM and C sources."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " It was inspired by the DDJ Graphics column and"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " many INTERNET and USENET authors who, unlike the"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " majority of programmers (you know who you are!),"); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " willingly share their code and ideas with others."); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " I can't afford, nor do I want, to copyright"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " this code - but if you use it, some credit would "); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9," be appreciated. "); wait_for_keypress(); subsequent_page(); x_set_font(0); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"Supported 256 colour resolutions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"Supported 256 colour resolutions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " 320x200 Standard for games ~ 4 pages"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " 320x240 DDJ Mode X square pixels ~ 3.5 pages"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " 360x200 My favourite for games ~ 3 pages "); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " 360x240 ~ 2.8 pages"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " 320x400 ~ 2 pages "); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " 320x480 All subsequent modes support"); x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " 360x400 less than two pages."); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " 360x480"); x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " 376x282,360x360,376x308,376x564,256x200,256x240"); x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " Phew! and they'll run on all VGA cards and "); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " monitors (some of the weird ones are best suited"); x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " to monitors with both vert & horiz adjustments)"); x_printf(textwindow_x+5,50+98,VisiblePageOffs,2, " "); x_printf(textwindow_x+5,50+106,VisiblePageOffs,2," Overkill? Maybe!! "); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Text display functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Text display functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Several text printing functions are provided."); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " They support the VGA ROM 8x14 and 8x8 fonts as"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " well as user-defined fonts (like this 6x8 font)."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " Furthermore, a function similar to printf is"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " included which provides formatted text output."); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " User defined fonts may be proportionally spaced"); x_printf(textwindow_x+5,50+58,VisiblePageOffs,9, " but have a maximum width of 8 pixels."); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Advanced screen functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Advanced screen functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " The library supports virtual screens larger"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " than the physical screen, panning of such"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " screens, and a split screen option."); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " These functions can be used together or"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " in isolation, and in the lower resolutions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " double buffering can also be accomplished."); x_rect_fill(0, 0, ScrnPhysicalPixelWidth,60,SplitScrnOffs,5); x_line(0,0,ScrnPhysicalPixelWidth,0,2,SplitScrnOffs); x_set_font(1); x_printf(10,10,SplitScrnOffs,2, " This is a split screen, tops for scores."); x_set_font(0); for (i=ScrnPhysicalHeight;i>ScrnPhysicalHeight-60;i--){ x_adjust_splitscreen(i); } x_printf(10,25,SplitScrnOffs,2, " Even better for scrolling games etc."); x_cp_vid_rect(0,0,ScrnLogicalPixelWidth,ScrnLogicalHeight,0,0, VisiblePageOffs,HiddenPageOffs, ScrnLogicalPixelWidth,ScrnLogicalPixelWidth); x_show_mouse(); wait_for_keypress(); curr_x=curr_y=0; init_object(60,90,4, 12, -1, 1, MK_FP(FP_SEG(bm2),FP_OFF(bm2))); init_object(30,30,4, 12, 1, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(80,120,4, 12, 2, 1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(300,200,4, 12, 1, -2, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,30,4, 12, -1, -1, MK_FP(FP_SEG(bm),FP_OFF(bm))); init_object(360,10,4, 12, -2, 2, MK_FP(FP_SEG(bm),FP_OFF(bm))); x_hide_mouse(); while (!kbhit()&& !(MouseButtonStatus==LEFT_PRESSED)){ animate(); if (objects[0].X>=curr_x+ScrnPhysicalPixelWidth-32 && curr_x < MaxScrollX) curr_x++; else if (objects[0].X < curr_x+16 && curr_x > 0) curr_x--; if (objects[0].Y>=curr_y+ScrnPhysicalHeight-92 && curr_y < MaxScrollY) curr_y++; else if (objects[0].Y < curr_y+16 && curr_y > 0) curr_y--; x_page_flip(curr_x,curr_y); while(StartAddressFlag); } while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); clear_objects(); x_page_flip(curr_x,curr_y); while(StartAddressFlag); x_set_start_addr(0,0); for (j=0;j<4;j++){ x_hide_splitscreen(); delay(100); x_show_splitscreen(); delay(100); } for (i=ScrnPhysicalHeight-60;i<=ScrnPhysicalHeight;i++){ x_adjust_splitscreen(i); } x_hide_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," Palette functions."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," Palette functions."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " A number of palette manipulation functions"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " are provided. You have already seen some of"); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " them in action. Another common operation is"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " palette fading. "); i=0; ch=255; while (x_cpcontrast_pal_struc(pal, pal2,ch-=2)){ x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); i++; }; for (j=0;j<i;j++){ x_cpcontrast_pal_struc(pal, pal2,ch+=2); x_put_pal_struc(pal2); x_rot_pal_struc(pal,palscrolldir); }; wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 3.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 3.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - RLE data compression"); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - FAST compiled masked bitmaps"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Hardware detection"); x_show_mouse(); wait_for_keypress(); x_hide_mouse(); for (i = 0; i < 150; i++) { x_circle(0, 0, i, 181 - i, VisiblePageOffs); x_circle(360 - i, 0, i, i + 30, VisiblePageOffs); x_circle(0, 200 - i, i, i + 30, VisiblePageOffs); x_circle(360 - i, 200 - i, i, 181 - i, VisiblePageOffs); } for (i = 0; i < 100; i++) x_filled_circle(80 + i, i, 201 - (i << 1), 30+i, VisiblePageOffs); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 4.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 4.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " NEW functions not demonstrated here include:"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - FAST VRAM-based masked bitmaps, including"); x_printf(textwindow_x+5,50+18,VisiblePageOffs,9, " support for clipping regions"); x_printf(textwindow_x+5,50+28,VisiblePageOffs,9, " - Faster, smaller compiled bitmaps"); x_printf(textwindow_x+5,50+38,VisiblePageOffs,9, " - Improved planar bitmap performance and"); x_printf(textwindow_x+5,50+46,VisiblePageOffs,9, " additional support for clipping"); x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " - mouse module"); x_printf(textwindow_x+5,50+66,VisiblePageOffs,9, " - Detection of math co-processor and mouse"); x_printf(textwindow_x+5,50+76,VisiblePageOffs,9, " - Bezier curve module"); x_printf(textwindow_x+5,50+86,VisiblePageOffs,9, " - Four new resolutions, including one with"); x_printf(textwindow_x+5,50+94,VisiblePageOffs,9, " square pixels (376x282)"); x_printf(textwindow_x+5,50+104,VisiblePageOffs,9, " - More bug fixes"); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 5.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 5.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - *FAST* filled and clipped triangles ideal for"); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " 3D work. Thanks to S. Dollins for the code."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Filled and clipped polygons, C++ Compatible"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - header files, and of course bug fixes!"); x_show_mouse(); wait_for_keypress(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," NEW Version 6.0 Functions!"); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," NEW Version 6.0 Functions!"); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " - Fast flood filling functions "); x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - New pbm flipping put functions."); x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Timer synchronized vertical retrace"); x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Tripple buffering extensions"); x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Checkout demo 9 and 10 for previews"); x_show_mouse(); wait_for_keypress(); randomize(); x_hide_mouse(); while(kbhit()) getch(); palscrolldir^=1; do { int x0,x1,x2,y0,y1,y2,i; i=random(256); x0=random(ScrnLogicalPixelWidth); x1=random(ScrnLogicalPixelWidth); x2=random(ScrnLogicalPixelWidth); y0=random(ScrnPhysicalHeight); y1=random(ScrnPhysicalHeight); y2=random(ScrnPhysicalHeight); x_triangle(x0,y0,x1,y1,x2,y2,i,VisiblePageOffs); } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED)); while(MouseButtonStatus==LEFT_PRESSED); while(kbhit()) getch(); x_show_mouse(); subsequent_page(); x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6," PLEASE..."); x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3," PLEASE..."); x_set_font(2); x_printf(textwindow_x+5,50 ,VisiblePageOffs,9, " Please mention my name in programs that use XLIB"); x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " just to make me feel it was worth the effort."); x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " If you have any bug to report please feel free to"); x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " mail me a message. Any hints, suggestions and"); x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " contributions are welcome and encouraged."); x_printf(textwindow_x+5,50+52,VisiblePageOffs,9, " I have contributed this code to the public domain."); x_printf(textwindow_x+5,50+60,VisiblePageOffs,9, " Please respect my wishes and leave it there."); x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " Finally, I hope you all find this stuff useful,"); x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " Themie Gouthas - [email protected]"); wait_for_keypress(); x_hide_mouse(); x_shift_rect (27, 27, 360-27, 177, 27, 23, VisiblePageOffs); x_rect_fill(25, 173, 335, 176, VisiblePageOffs, 1); for (i = 0; i < 50; i++) { x_shift_rect (27, 26, 360-27, 177 - (i * 3), 27, 23, VisiblePageOffs); } }
//REDRAW SCROLL BARS void ScrollDraw(struct ScrollBar *scroll,int fromx,long fromy) { long pom; int zblo=0; if(user_interface.scrollbarstyle == 'C') //C = Clarence ;) return; if(!scroll->onscrollx) { if(scroll->total_y<=scroll->ysize || scroll->total_y==0) { scroll->yscrsz=scroll->max_yscrsz; scroll->yscr=0; } else { pom=(long)scroll->ysize*(long)scroll->max_yscrsz; scroll->yscrsz=(int)(pom/scroll->total_y)+1; if(scroll->yscrsz<8) { scroll->yscrsz=8; if(scroll->yscrsz>scroll->max_yscrsz)scroll->yscrsz=scroll->max_yscrsz; } pom=fromy*(long)scroll->max_yscrsz; scroll->yscr=(int)(pom/scroll->total_y); //!!Ray: Dec 17, 2007 -- fix BSOD // Return if overflow: if(scroll->yscr < 0) return; //!!Ray: end if(scroll->yscr+scroll->yscrsz>scroll->max_yscrsz)scroll->yscr=scroll->max_yscrsz-scroll->yscrsz; } if(!scroll->yvisible) return; x_setfill(0,0); if(scroll->scrollbarstyle) zblo=1; scroll->yscr+=scroll->gap; if(scroll->yscr>0) x_bar(scroll->xtop+scroll->xsize+1,scroll->ytop+scroll->gap, scroll->xtop+scroll->xsize+user_interface.scrollbarsize,scroll->ytop+scroll->yscr-1); if(scroll->yscr+scroll->yscrsz<scroll->max_yscrsz+scroll->gap) x_bar(scroll->xtop+scroll->xsize+1,scroll->ytop+scroll->yscr+scroll->yscrsz+1, scroll->xtop+scroll->xsize+user_interface.scrollbarsize,scroll->ytop+scroll->max_yscrsz+scroll->gap+zblo); Box3Dv(scroll->xtop+scroll->xsize+1,scroll->ytop+scroll->yscr, scroll->xtop+scroll->xsize+user_interface.scrollbarsize,scroll->ytop+scroll->yscr+scroll->yscrsz+zblo); //ozdobicky (tr.: ornaments) if(scroll->yscrsz>24) { int ymid=scroll->yscrsz/2; int xleft=scroll->xtop+scroll->xsize+3; int xright=scroll->xtop+scroll->xsize+user_interface.scrollbarsize-3; int yyy=scroll->ytop+scroll->yscr+ymid; x_setcolor(15); x_line(xleft,yyy, xright,yyy); x_line(xleft,yyy-4, xright,yyy-4); x_line(xleft,yyy+4, xright,yyy+4); x_line(xleft,yyy-8, xright,yyy-8); x_line(xleft,yyy+8, xright,yyy+8); x_setcolor(8); x_line(xleft,yyy-1, xright,yyy-1); x_line(xleft,yyy-5, xright,yyy-5); x_line(xleft,yyy+3, xright,yyy+3); x_line(xleft,yyy-9, xright,yyy-9); x_line(xleft,yyy+7, xright,yyy+7); } } if(scroll->onscrolly) { #ifdef GGI Smart_ggiFlush(); #endif return; } if(!scroll->xvisible || scroll->total_x<=scroll->xsize || scroll->total_x==0) { scroll->xscrsz=scroll->max_xscrsz; scroll->xscr=0; if(!scroll->xvisible) return; } else { pom=(long)scroll->xsize*(long)scroll->max_xscrsz; scroll->xscrsz=(int)(pom/scroll->total_x)+1; if(scroll->xscrsz<8) { scroll->xscrsz=8; if(scroll->xscrsz>scroll->max_xscrsz)scroll->xscrsz=scroll->max_xscrsz; } pom=fromx*(long)scroll->max_xscrsz; scroll->xscr=(int)(pom/scroll->total_x); if(scroll->xscr+scroll->xscrsz>scroll->max_xscrsz)scroll->xscr=scroll->max_xscrsz-scroll->xscrsz; } x_setfill(0,0); if(scroll->scrollbarstyle!='N') zblo=0; scroll->xscr+=scroll->gap+zblo; if(scroll->xscr>0) x_bar(scroll->xtop+scroll->gap+zblo,scroll->ytop+scroll->ysize+1, scroll->xtop+scroll->xscr-1,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); if(scroll->xscr+scroll->xscrsz<scroll->max_xscrsz+scroll->gap+zblo) x_bar(scroll->xtop+scroll->xscr+scroll->xscrsz+1,scroll->ytop+scroll->ysize+1, scroll->xtop+scroll->max_xscrsz+scroll->gap+zblo,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); Box3Dh(scroll->xtop+scroll->xscr,scroll->ytop+scroll->ysize+1, scroll->xtop+scroll->xscr+scroll->xscrsz,scroll->ytop+scroll->ysize+user_interface.scrollbarsize); if(scroll->xscrsz>24)//ozdobicky... (tr.: ornaments...) { int xmid=scroll->xscrsz/2; int yend=scroll->ytop+scroll->ysize+3; int ystart=scroll->ytop+scroll->ysize+user_interface.scrollbarsize-3; int xxx=scroll->xtop+scroll->xscr+xmid; x_setcolor(15); x_line(xxx,yend, xxx,ystart); x_line(xxx-4,yend, xxx-4,ystart); x_line(xxx+4,yend, xxx+4,ystart); x_line(xxx-8,yend, xxx-8,ystart); x_line(xxx+8,yend, xxx+8,ystart); x_setcolor(8); x_line(xxx-1,yend, xxx-1,ystart); x_line(xxx-5,yend, xxx-5,ystart); x_line(xxx+3,yend, xxx+3,ystart); x_line(xxx-9,yend, xxx-9,ystart); x_line(xxx+7,yend, xxx+7,ystart); } #ifdef GGI Smart_ggiFlush(); #endif }