void show_picture(u8 image,u8 dir,u8 fade) { static u8 i,j; if(fade) { for(i=0;i<4;++i) { pal_bright(dir?BRIGHT_MID+i:BRIGHT_MID-i); for(j=0;j<4;++j) vsync(); } } draw_image(0,0,image); pal_select(image); swap_screen(); if(fade) { for(i=0;i<4;++i) { pal_bright(dir?BRIGHT_MAX-i:BRIGHT_MIN+i); for(j=0;j<4;++j) vsync(); } } }
void DrawIntro() { unsigned char frame; ResetVideo(); setupFont(); vsync(); set_color(1, 0); SetFontColors(14, 0, 0, 0); put_string("KORDAMP PRESENTS", 12, 14); for(frame = 0; frame < 7; frame ++) { SetFontColors(14, 0, RGB(frame, frame, frame), 0); vsync(3); } frame = 5; while(frame) frame --; for(frame = 7; frame > 0; frame --) { SetFontColors(14, 0, RGB(frame, frame, frame), 0); vsync(3); } }
void WGLWindow::multiSampling(MultiSampling::Type samplingType) { // No change if (samplingType == pMultiSampling) return; // Not supported (also means it could not have been activated before) if (not ::glewIsSupported("GL_ARB_multisample") or not ::wglewIsSupported("WGL_ARB_multisample")) return; // Store the old vsync because we will lose it otherwise bool hasVsync = vsync(); // Try to change the FSAA by klling the window and creating it again with the new values closeWindowForReinit(); pMultiSampling = samplingType; if (!initWindow()) // Init window will generate errors by itself if it fails // It will automatically go back to a default non-fsaa state on error return; // Reapply vsync vsync(hasVsync); if (MultiSampling::msNone != pMultiSampling) ::glEnable(GL_MULTISAMPLE); else ::glDisable(GL_MULTISAMPLE); }
neosplash(){ disp_off(); cls(); load_palette(16,neosprpal,1); load_vram(0x5000,neospr,0x400); load_palette(0,badge1pal,1); set_tile_data(neotiles); load_tile(0x1000); for(j=0;j<14;j++){ for(i=0;i<14;i++){ put_tile(j*14+i,i+1,j); } } for(i=0;i<8;i++){ spr_set(i); spr_pal(0); spr_pri(1); spr_ctrl(SIZE_MAS,SZ_32x16); spr_pattern(0x5000+0x80*i); spr_y(224-24); spr_x(i*32); } disp_on(); t=0; for(;;){ t++; vsync(); joy0=joy(0); satb_update(); if(joy0&JOY_STRT){ break; } if(t>144)break; } psgPlay(0); disp_off(); for(i=0;i<8;i++){ spr_set(i); spr_hide(); } satb_update(); cls(); set_color(0,0); set_color(256,0); disp_on(); while(joy0&JOY_STRT){ vsync(); joy0=joy(0); } }
void blend_in_rle(int x, int y, RLE_SPRITE* pict,unsigned char frames) { for (int i=255; i>0; i--) { draw_lit_rle_sprite(buffer,pict,x,y,i); for(int j=frames; j>0; j--) vsync(); showbuffer(); } }
void vnpins(int dosync) { register int d = DEPTH(vcline); register int e; e = LINE(vcline) + DEPTH(vcline); if (e < LINE(vcline + 1)) { vigoto(e, 0); vclreol(); return; } DEPTH(vcline)++; if (e < WECHO) { e = vglitchup(vcline, d); vigoto(e, 0); vclreol(); if (dosync) { int (*Ooutchar)() = Outchar; Outchar = vputchar; vsync(e + 1); Outchar = Ooutchar; } } else { vup1(); vigoto(WBOT, 0); vclreol(); } vprepins(); }
/** * The main loop of the jukebox. Waits for the end of the song (while updating * the timer) and then returns an indicator that we need the next song. * Also waits for keypresses; the user can press ESC, left arrow or right arrow * to trigger appropriate return codes. */ int jukebox_loop() { int key_p; while (TRUE) { while (keypressed()) { key_p = readkey() >> 8; if (key_p == KEY_ESC) { return JUKEBOX_EXIT; } if (key_p == KEY_LEFT) { return JUKEBOX_PREV_SONG; } if (key_p == KEY_RIGHT) { return JUKEBOX_NEXT_SONG; } } clear_bitmap(buffer); update_starfield(buffer); update_track_data(); update_song_data(); draw_help(); vsync(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); // When we're at the end of the file, midi_pos will be set to // the negative number of beats in the song. if (midi_pos < 0) { rest(TRACK_CHANGE_WAIT); return JUKEBOX_NEXT_SONG; } } }
void blend_out_rle(int x, int y, RLE_SPRITE* pict,unsigned short frames) { for (int i=0; i<256; i++) { draw_lit_rle_sprite(buffer,pict,x,y,i); for(int j=frames; j>0; j--) vsync(); showbuffer(); } }
void Update_video() { /* Sync code by Allegro team, thank you guys ! https://wiki.allegro.cc/index.php?title=Using_Timers_in_Allegro_4 */ vsync(); while(ticks == 0) { rest(1); } while(ticks > 0) { int old_ticks = ticks; ticks--; if(old_ticks <= ticks) break; } }
void highcolor_fade_out(int speed) { BITMAP *bmp_orig, *bmp_buff; if ((bmp_orig = create_bitmap(SCREEN_W, SCREEN_H))) { if ((bmp_buff = create_bitmap(SCREEN_W, SCREEN_H))) { int a; blit(screen, bmp_orig, 0,0, 0,0, SCREEN_W, SCREEN_H); if (speed <= 0) speed = 16; for (a = 255-speed; a > 0; a-=speed) { clear(bmp_buff); set_trans_blender(0,0,0,a); draw_trans_sprite(bmp_buff, bmp_orig, 0, 0); vsync(); blit(bmp_buff, screen, 0,0, 0,0, SCREEN_W, SCREEN_H); } destroy_bitmap(bmp_buff); } destroy_bitmap(bmp_orig); } rectfill(screen, 0,0, SCREEN_W,SCREEN_H, makecol(0,0,0)); }
int main(void) { allegro_init(); install_timer(); install_keyboard(); rgb_map = malloc(sizeof(RGB_MAP)); create_rgb_table(rgb_map, desktop_palette, NULL); set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0); buffer = create_bitmap(SCREEN_W, SCREEN_H); set_projection_viewport(0, 0, SCREEN_W, SCREEN_H); init_shape(); while (!key[KEY_ESC]) { move_shape(); translate_shape(); vsync(); draw(); } destroy_bitmap(buffer); free(rgb_map); allegro_exit(); return 0; }
void reset_menu_palette(void) { vsync(); // clear_bitmap(screen); clear_bitmap(display); // arena.target_palette = 0; // set_base_palette(); // set_base_palette(); // int newpal = build_new_palette(arena.change_palette, 0, 0, 0); vsync(); // clear_bitmap(screen); // set_palette(palet [newpal]); }
void Vga::thread() { while(true) { wait(period); if(address != 0) { vsync(); } } }
void change_color(int r, int g, int b) { RGB col; col.r = r; col.g = g; col.b = b; vsync(); set_color(254, &col); }
void _kgfx_draw_screen(int pid) { //skip processes that are inactive if (pid == context_pid[active_context]) { vsync(); _kgfx_load_palette(contexts[active_context].palette); blit(&screen, contexts[active_context].backbuffer, 0, 0); } }
uint16 DreamGenContext::waitframes() { readmouse(); showpointer(); vsync(); dumppointer(); delpointer(); return data.word(kMousebutton); }
void goodbye_menu_circles(void) { int i, j; int finished = 1, thing, speed = 0, timeout = 0; do { clear_to_color(display, COL_BACK1); finished = 1; speed ++; timeout ++; if (timeout > 100) return; for (i = 0; i < MENU_CIRCLES; i ++) { if (menu_circle_size [i] <= 0) break; finished = 0; if (menu_circle_size [i] > 0) menu_circle_size [i] -= 100; if (minicircle_size [i] > 0) minicircle_size [i] -= 100; menu_circle_angle [i] += menu_circle_rot [i]; if (menu_circle_rot [i] < 0) menu_circle_angle [i] += speed; else menu_circle_angle [i] -= speed; menu_circle_angle [i] &= 1023; for (j = 0; j < menu_circle_number [i]; j ++) { draw_menu_circle(i, j); } } do { thing ++; } while (ticked == 0); ticked = 0; vsync(); blit(display, screen, 0, 0, 100, 0, 600, 600); } while (finished == 0); }
/* PLEASE, do not use this. It's not necessary. It wasts processor time. It's stupid. I left it here for the sake of compatability. */ void bill_slowfade_bmp(BITMAP *bmp, int clr) { int yoff; int ysub; int xoff; int xadd; for(yoff=0; yoff<=SCREEN_H; yoff +=2) { vsync(); for(ysub=0; ((yoff-ysub)>=0);ysub++) putpixel(bmp, ysub, yoff-ysub, clr); } for(xoff=0; xoff<=SCREEN_W; xoff +=2) { vsync(); for(xadd=0; ((xoff+xadd)<=SCREEN_W); xadd++) putpixel(bmp, xoff+xadd, SCREEN_H-xadd, clr); } }
static void Save(int asCode) { char filename[128]; // char drive[_MAX_DRIVE]; char dir[96]; char name[32]; // char ext[_MAX_EXT]; char c; int i; strcpy(filename, lastFile); while (1) { memset(GetDstScreen(), 58, 64000); TextStringAt(125, 50, "Save as:"); TextGoto(125, 50 + TextHeight()); TextChar('\020'); TextString(filename); TextChar('\021'); vsync(); CopyToScreen(); c = GetKey(); switch (c) { case ENTER: if (!filename[0]) break; if (asCode) { SaveCampaignAsC(filename, name, &campaign); } else { SaveCampaign(filename, &campaign); } fileChanged = 0; return; case ESCAPE: return; case BACKSPACE: if (filename[0]) filename[strlen(filename) - 1] = 0; break; default: if (strlen(filename) == sizeof(filename) - 1) break; c = toupper(c); if ((c >= 'A' && c <= 'Z') || c == '-' || c == '_' || c == '\\') { i = strlen(filename); filename[i + 1] = 0; filename[i] = c; } } } }
static void hsync(const char *message) { if(counter == counter_end) { CLOCK(message); screen_hsync(); counter = 0; line++; if(line == line_end) vsync(); } }
static int ConfirmQuit(void) { int c; memset(GetDstScreen(), 58, 64000); TextStringAt(80, 50, "Campaign has been modified, but not saved"); TextStringAt(110, 50 + TH, "Quit anyway? (Y/N)"); vsync(); CopyToScreen(); c = GetKey(); return (c == 'Y' || c == 'y'); }
void show_gripdesign(void) { BITMAP *bmp; BITMAP *bmp2; int end=0; int time=0; int alpha=255; bmp2 = load_bitmap("graphic/menu/logo.pcx",NULL); bmp = create_bitmap(480,480); stretch_sprite(bmp,bmp2,0,0,480,480); speed_counter = 0; while(!key[KEY_ESC] && !end) { while(speed_counter>0) { time++; if(time<350 && alpha>0) alpha-=2; if(alpha<0)alpha=0; if(time>350) alpha+=4; if(alpha>255)alpha=255; if(time>450)end=1; speed_counter--; } set_trans_blender(0,0,0,0); draw_lit_sprite(virt,bmp,0,0,alpha); vsync(); blit(virt,screen,0,0,80,0,480,480); } destroy_bitmap(bmp); destroy_bitmap(bmp2); }
squirrelsplash(){ disp_off(); cls(); foo=6; put_string(" PC Engine ",0,foo); put_string(" MML Sound Library ",0,2+foo); put_string(" 'SQUIRREL' ",0,4+foo); put_string(" By: Aetherbyte ",0,6+foo); put_string(" http://www.aetherbyte.com/ ",0,8+foo); foo++; put_string(" Game concept and graphics by ",0,12+foo); put_string(" http://lazybraingames.com/ ",0,14+foo); disp_on(); bar=0; while(1){ lastjoy0=joy0; vsync(); bar++; joy0=joy(0); if(joy0&JOY_STRT)break; if(bar>90)break; } cls(); while(joy0&JOY_STRT){ vsync(); joy0=joy(0); } }
// Fade in void highcolor_fade_in(BITMAP* bmp_orig, int speed){ BITMAP* bmp_buff = create_bitmap(SCREEN_W,SCREEN_H); BITMAP* str_orig = create_bitmap( SCREEN_W, SCREEN_H); stretch_sprite( str_orig, bmp_orig, 0, 0, SCREEN_W, SCREEN_H); if ( speed<=0) speed=16; for(int a=0; a<256; a+=speed){ clear( bmp_buff); set_trans_blender( 0, 0, 0, a); draw_trans_sprite( bmp_buff, str_orig, 0, 0); vsync(); stretch_sprite( screen, bmp_buff, 0, 0, SCREEN_W, SCREEN_H); } stretch_sprite( screen, str_orig, 0, 0, SCREEN_W, SCREEN_H); }
/* helper for changing one of the color values */ int update_color(void *dp3, int val) { int type = ((unsigned long)dp3 - (unsigned long)colors) / sizeof(colors[0]); int r, g, b; float h, s, v; RGB rgb; if (colors[type] != val) { colors[type] = val; if ((type == S_R) || (type == S_G) || (type == S_B)) { /* convert RGB color to HSV */ r = colors[S_R]; g = colors[S_G]; b = colors[S_B]; rgb_to_hsv(r, g, b, &h, &s, &v); colors[S_H] = h * 255.0 / 360.0; colors[S_S] = s * 255.0; colors[S_V] = v * 255.0; } else { /* convert HSV color to RGB */ h = colors[S_H] * 360.0 / 255.0; s = colors[S_S] / 255.0; v = colors[S_V] / 255.0; hsv_to_rgb(h, s, v, &r, &g, &b); colors[S_R] = r; colors[S_G] = g; colors[S_B] = b; } /* set the screen background to the new color */ rgb.r = colors[S_R]/4; rgb.g = colors[S_G]/4; rgb.b = colors[S_B]/4; vsync(); set_color(0, &rgb); } return D_O_K; }
void cmd_viewpic(){ // Views the contents of a WAD file picture. // WARNING: Needs an error check, to make sure lump is actually a picture. WAD_PIC *temp_pic; temp_pic=wad_loadpic(INTERNAL_WAD,parse_words[1]); if(temp_pic!=NULL){ clear_to_color(vgabuf,0); draw_scaled_wad_pic(temp_pic,temp_pic->w,temp_pic->h,256,0,0,screen_height); vsync(); blit(vgabuf,screen,0,0,0,0,screen_width,screen_height); readkey(); wad_killpic(temp_pic); } else{ con_printf("viewpic failed"); } }
int main(void) { const int8_t *sin = (const int8_t *) &sin256x63[0]; const uint8_t VORIGIN = (LINE_LAST + LINE_FIRST) / 2; uint8_t r = 0; uint8_t va = VORIGIN; uint8_t vb = VORIGIN; int8_t radd = 1; volatile uint8_t *vp0 = (uint8_t *) &clist[7].w0; volatile uint8_t *vp1 = (uint8_t *) &clist[9].w0; custom->dmacon = DMAF_MASTER | DMAF_ALL; /* Install the copper list */ copper_install(1, clist); copper_start(); while (1) { /* Wait for maximum vertical beam position. */ vsync(VPOS_MAX); /* Frame loop start */ va = VORIGIN + sin[(uint8_t) r]; vb = VORIGIN + sin[(uint8_t) (r+0x20)]; r += radd; /* * Install new bar horizontal position in copper list. It is * important that those writes happen before the copper * encounters the corresponding wait instructions. */ if (va <= vb) { *vp0 = va; *vp1 = vb; } else { *vp0 = vb; *vp1 = va; } /* Frame loop end */ } return 0; }
int main() { BITMAP *buffer; PALETTE pal; int c; allegro_init(); install_keyboard(); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { allegro_exit(); printf("Error setting graphics mode\n%s\n\n", allegro_error); return 1; } /* tile 1 colour */ for (c = 1; c != 128; c++) { pal[c].r = c * 49/127; pal[c].g = 0; pal[c].b = c * 63/127; } /* tile 2 colour */ for (c = 0; c != 127; c++) { pal[c + 128].r = 0; pal[c + 128].g = 0; pal[c + 128].b = c * 63/127; } pal[0].r = pal[0].g = pal[0].b = 0; pal[255].r = pal[255].g = pal[255].b = 63; set_pallete(pal); buffer = create_bitmap(SCREEN_W, SCREEN_H); while (!key[KEY_ESC]) { render(buffer); vsync(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); process_input(); } destroy_bitmap(buffer); return 0; }
// Duplo buffer void bufferDuplo ( BITMAP * buffer ) { // sincronizar // como em jogos 3D modernos vsync(); // imprime o buffer na tela (use sempre masked_blit - eh mais rapido) // do buffer-> para as creen // pega da posicao 0,0 do buffer e poe na // 0,0 da screen, de tamanho RES_W e RES_H masked_blit(buffer, screen, 0,0,0,0, RES_W, RES_H); // o BITMAP * buffer eh como se fosse uma caixa, quando um frame comeca // ( um novo loop do while(!key[KEY_ESC]) nos jogamos tudo fora // e comecamos a colocar coisas novas // depois nos jogamos o conteudo desta caixa na tela // quando estiver tudo pronto rest(180); }
void highcolor_fade_in(BITMAP *bmp_orig, int speed) { BITMAP *bmp_buff; if ((bmp_buff = create_bitmap(SCREEN_W, SCREEN_H))) { int a; if (speed <= 0) speed = 16; for (a = 0; a < 256; a+=speed) { clear(bmp_buff); set_trans_blender(0,0,0,a); draw_trans_sprite(bmp_buff, bmp_orig, 0, 0); vsync(); blit(bmp_buff, screen, 0,0, 0,0, SCREEN_W, SCREEN_H); } destroy_bitmap(bmp_buff); } blit(bmp_orig, screen, 0,0, 0,0, SCREEN_W, SCREEN_H); }