void update_room0_cache (enum em em, enum vm vm) { room_view = 0; struct pos mouse_pos_bkp = mouse_pos; invalid_pos (&mouse_pos); con_caching = true; if (! room0) room0 = create_bitmap (ORIGINAL_WIDTH, ORIGINAL_HEIGHT); clear_bitmap (room0, TRANSPARENT_COLOR); mr.dx = 0; mr.dy = 0; draw_room (room0, 0, em, vm); con_caching = false; mouse_pos = mouse_pos_bkp; }
int startGame(){ configAll(); BITMAP * nave = load_bitmap("img/35x45/nave.bmp",NULL); BITMAP * alien = load_bitmap("img/35x45/alien.bmp", NULL); BITMAP * gun = load_bitmap("img/35x45/gun.bmp", NULL); BITMAP * init = load_bitmap("img/start.bmp", NULL); BITMAP * bg = load_bitmap("img/bartop.bmp", NULL); BITMAP * buffer = create_bitmap(SCREEN_W,SCREEN_H); SAMPLE * sound = load_wav("wav/tiro.wav"); SAMPLE * music = load_sample("wav/laserHit.wav"); initStart(buffer,init); install_int_ex(countXa,SECS_TO_TIMER(1)); install_int_ex(countGun,MSEC_TO_TIMER(1)); gameControll(nave,buffer,alien,gun,bg,sound,music); destroyAll(nave,buffer,alien,gun,init,bg,sound,music); return 0; }
void Animation::load(PACKFILE* f) throw (std::bad_alloc, ReadError) { int nameLen = igetl(f); name = (char*)malloc(nameLen+1); for (int i = 0; i < nameLen; i++) name[i] = my_pack_getc(f); name[nameLen] = 0; numFrames = igetl(f); int width = igetl(f); int height = igetl(f); try { frames = new BITMAP*[numFrames]; for (int i = 0; i < numFrames; i++) frames[i] = 0; for (int i = 0; i < numFrames; i++) { frames[i] = create_bitmap(width, height); if (!frames[i]) throw new std::bad_alloc(); } delays = new int[numFrames]; for (int i = 0; i < numFrames; i++) { loadFrame(width, height, frames[i], &delays[i], f); } } catch (...) { free(name); for (int i = 0; i < numFrames; i++) if (frames[i]) destroy_bitmap(frames[i]); if (delays) delete[] delays; throw new std::bad_alloc(); } }
int main(void) { BITMAP *memory_bitmap; int x, y; if (allegro_init() != 0) return 1; install_keyboard(); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return 1; } } set_palette(desktop_palette); /* make a memory bitmap sized 20x20 */ memory_bitmap = create_bitmap(20, 20); /* draw some circles onto it */ clear_bitmap(memory_bitmap); for (x=0; x<16; x++) circle(memory_bitmap, 10, 10, x, palette_color[x]); /* blit lots of copies of it onto the screen */ acquire_screen(); for (y=0; y<SCREEN_H; y+=20) for (x=0; x<SCREEN_W; x+=20) blit(memory_bitmap, screen, 0, 0, x, y, 20, 20); release_screen(); /* free the memory bitmap */ destroy_bitmap(memory_bitmap); readkey(); return 0; }
/* * mark_levelv3 * * Traverse the backup hierarchy and mark the bits for the * modified objects of directories leading to a modified * object for the level-type backup. * * Parameters: * session (input) - pointer to the session * nlp (input) - pointer to the nlp structure * path (input) - the physical path to traverse * * Returns: * 0: on success * != 0: otherwise */ int mark_levelv3(ndmpd_session_t *session, ndmp_lbr_params_t *nlp, char *path) { fs_traverse_t ft; mark_param_t mp; tlm_acls_t traverse_acl; if (!session || !nlp || !path || !*path) { syslog(LOG_ERR, "Invalid argument in mark_levelv3"); return (-1); } if (nlp->nlp_ldate == (time_t)0) return (create_allset_bitmap(nlp)); nlp->nlp_bkmap = create_bitmap(nlp->nlp_backup_path, 0); if (nlp->nlp_bkmap < 0) { syslog(LOG_ERR, "Failed to allocate bitmap in mark_levelv3"); return (-1); } syslog(LOG_DEBUG, "nlp_bkmap %d", nlp->nlp_bkmap); /* * We do not want to allocate memory for acl every time we * process a file. */ (void) memset(&traverse_acl, 0, sizeof (traverse_acl)); mp.mp_tacl = &traverse_acl; mp.mp_bmd = nlp->nlp_bkmap; mp.mp_ddate = nlp->nlp_ldate; mp.mp_session = session; mp.mp_nlp = nlp; ft.ft_path = path; ft.ft_lpath = nlp->nlp_backup_path; ft.ft_callbk = mark_cb; ft.ft_arg = ∓ ft.ft_logfp = (ft_log_t)syslog; ft.ft_flags = ndmpd_mark_flags; return (traverse(session, nlp, &ft)); }
//draw with rotation void sprite::drawframe(BITMAP *dest, int angle) { if (!this->image) return; //create scratch frame if necessary if (!this->frame) { this->frame = create_bitmap(this->width, this->height); } //first, draw frame normally but send it to the scratch frame image int fx = this->animstartx + (this->curframe % this->animcolumns) * this->width; int fy = this->animstarty + (this->curframe / this->animcolumns) * this->height; blit(this->image, this->frame, fx, fy, 0, 0, this->width, this->height); //draw rotated image in scratch frame onto dest //adjust for Allegro's 16.16 fixed trig (256 / 360 = 0.7) then divide by 2 radians rotate_sprite(dest, this->frame, (int)this->x, (int)this->y, itofix((int)(angle / 0.7f / 2.0f))); }
void IniciaGrafica(){ if (allegro_init() != 0) return; install_keyboard(); install_timer(); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, VentanaX, VentanaY, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, VentanaX, VentanaY, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set any graphic mode\n%s\n", allegro_error); return; } } set_palette(desktop_palette); /* allocate the memory buffer */ buffer = create_bitmap(SCREEN_W, SCREEN_H); clear_keybuf(); divisionY = VentanaY/nCeldas_i; divisionX = VentanaX/nCeldas_j; }
/* ============================== = Stuff that didn't fit in = ============================== */ int init_moveable(DIALOG *dialog) { BITMAP *backbuffer = create_bitmap(dialog->w+1, dialog->h+1); BILLWIN_INFO_STRUCTURE *infostruct = malloc(sizeof(BILLWIN_INFO_STRUCTURE)); /* We do NOT need to memverify the above, if they aren't there, the window will notice, and disable the moving routine */ if (backbuffer) { scare_mouse(); blit(screen, backbuffer, dialog->x, dialog->y, 0, 0, dialog->w+1, dialog->h+1); unscare_mouse(); } if(infostruct) infostruct->backbuffer = backbuffer; dialog->dp3 = infostruct; return 0; }
void rfs_fmat(device_t * devp) { printfk("rfs_fmat begin\n\r"); if(create_superblk(devp) == FALSE) { hal_sysdie("create superblk failed"); } if(create_bitmap(devp) == FALSE) { hal_sysdie("create bitmap failed"); } if(create_rootdir(devp) == FALSE) { hal_sysdie("create rootdir failed"); } return; }
void draw_block(BITMAP *bmp, int x, int y, BLOCK block, int dark) { if (!block_bmp) block_bmp = create_bitmap(BLOCK_SIZE, BLOCK_SIZE); if (block) { if (!(block & 0xf0) || ((block & 0xf0) == BLOCK_GRAY)) blit(datafile[BLOCK_BMP].dat, block_bmp, 0, 0, 0, 0, BLOCK_SIZE, BLOCK_SIZE); else { blit(datafile[BLOCK_BMP].dat, block_bmp, ((block & 0xf0) >> 4) * BLOCK_SIZE, 0, 0, 0, BLOCK_SIZE, BLOCK_SIZE); block = PAL_GRAY; dark = FALSE; } color_map = (dark)? tint_dark_map: tint_map; draw_lit_sprite(bmp, block_bmp, x, y, (block & 0x0f)); } }
/** * Switches to graphics mode, installs Allegro drivers and initializes * variables used by the jukebox. */ void initialize_jukebox() { // Switch to graphics mode. initialize_allegro(); screen_gfx_mode(); initialize_sound(); load_flim_dat(); // Prepare for the jukebox loop. buffer = create_bitmap(SCREEN_W, SCREEN_H); RGB *pal = get_starfield_palette(); add_flim_palette_colors(pal); set_palette(pal); free(pal); font_height = FLIM_HEIGHT; help_text_x = SCREEN_W / 2; help_text_y1 = SCREEN_H - (font_height * 5) - (font_height / 2); help_text_y2 = SCREEN_H - (font_height * 4) - (font_height / 2); help_text_y3 = SCREEN_H - (font_height * 3); help_text_y4 = SCREEN_H - (font_height * 2); }
Opponent::Opponent(Character character): mCharacter(character) { mPositionX = 900; mPositionY = 520; mBitmap = create_bitmap(32, 32); switch (mCharacter) { case Luigi: mSprite = load_bitmap("Data/Luigi.bmp", NULL); break; case Peach: mSprite = load_bitmap("Data/Peach.bmp", NULL); } floodfill(mBitmap, 0, 0, makecol(0, 0, 0)); blit(mSprite, mBitmap, 0, 0, 0, 0, 32, 32); }
int get_tiles() { int x,y,z; for(x=0 ; x<=(tilebuffer_height_in_tiles * tilebuffer_width_in_tiles) ; x++) { tile[x] = create_bitmap(tile_width , tile_width); } z=0; for (y=0 ; y < tilebuffer_height_in_tiles * tile_width ; y+=32) { for (x=0 ; x < tilebuffer_width_in_tiles * tile_width ; x+=32) { blit ( tile_buffer, tile[z], x,y, 0,0, tile_width,tile_width); z++; } } return 0; }
/*! \brief Initialise enemy & sprites for combat * * If required, load the all the enemies, then * init the ones that are going into battle, by calling make_enemy() and * copying the graphics sprites into cframes[] and tcframes[]. * Looks at the cf[] array to see which enemies to do. * * \author PH * \date 2003???? */ void enemy_init (void) { int i, p; s_fighter *f; if (enemies == NULL) load_enemies (); for (i = 0; i < numens; ++i) { f = make_enemy (cf[i], &fighter[i + PSIZE]); for (p = 0; p < MAXCFRAMES; ++p) { /* If, in a previous combat, we made a bitmap, destroy it now */ if (cframes[i + PSIZE][p]) destroy_bitmap (cframes[i + PSIZE][p]); /* and create a new one */ cframes[i + PSIZE][p] = create_bitmap (f->img->w, f->img->h); blit (f->img, cframes[i + PSIZE][p], 0, 0, 0, 0, f->img->w, f->img->h); tcframes[i + PSIZE][p] = copy_bitmap (tcframes[i + PSIZE][p], f->img); } } }
void Screen::init() { allegro_init(); // Starts allegro set_color_depth(COLOR_DEPTH); // Sets the pixel color depth format set_gfx_mode(GFX_AUTODETECT_WINDOWED, LENGTH_X, LENGTH_Y, 0, 0); // Creates a windowed screen install_keyboard(); // Prepares the keyboard for input BUFFER = create_bitmap(LENGTH_X, LENGTH_Y); // Creates the buffer bitmap // Correctly assigns the colors BLACK = makecol(0, 0, 0); WHITE = makecol(255, 255, 255); GRAY = makecol(100, 100, 100); RED = makecol(255, 0, 0); GREEN = makecol(0, 255, 0); BLUE = makecol(0, 0, 255); YELLOW = makecol(255, 255, 0); ORANGE = makecol(255, 150, 0); BROWN = makecol(150, 75, 0); PURPLE = makecol(150, 0, 150); }
int main(){ allegro_init(); install_keyboard(); /* install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL); MIDI *music; music = load_midi("./99.midd"); if (!music) {std::cerr<<"Couldn't load background music!"<<std::endl;exit(1);} else play_midi(music,1); */ set_gfx_mode( GFX_AUTODETECT, 1920, 1200, 0, 0); buffer = create_bitmap( 1920, 1200); while ( !key[KEY_ESC] ){ clear_keybuf(); if (key[KEY_UP]) rotateY(-2); else if (key[KEY_DOWN]) rotateY(2); else if (key[KEY_RIGHT]) rotateX(2); else if (key[KEY_LEFT]) rotateX(-2); else if (key[KEY_PGUP]) rotateZ(-2); else if (key[KEY_PGDN]) rotateZ(2); draw(); } /* if(music) { stop_midi(); destroy_midi(music); } */ return 0; }
// Convert truecolor graphics stored in datafile in current native format void Data_UpdateVideoMode() { int i; t_list *bmp_copies; assert(g_Datafile != NULL); bmp_copies = g_DatafileBitmapCopy32; if (bmp_copies == NULL) { // First time, copy everything into 32-bits buffers. fixup_datafile(g_Datafile); for (i = 0; g_Datafile[i].type != DAT_END; i++) { if (g_Datafile[i].type == DAT_BITMAP) { BITMAP * dat_bmp = g_Datafile[i].dat; BITMAP * copy_bmp = create_bitmap_ex(32, dat_bmp->w, dat_bmp->h); blit(dat_bmp, copy_bmp, 0, 0, 0, 0, dat_bmp->w, dat_bmp->h); list_add_to_end(&g_DatafileBitmapCopy32, copy_bmp); } } bmp_copies = g_DatafileBitmapCopy32; } for (i = 0; g_Datafile[i].type != DAT_END; i++) { if (g_Datafile[i].type == DAT_BITMAP) { // Recreate it all BITMAP * src_bmp = bmp_copies->elem; BITMAP * dst_bmp = create_bitmap( src_bmp->w, src_bmp->h ); destroy_bitmap( g_Datafile[i].dat ); g_Datafile[i].dat = dst_bmp; blit(src_bmp, dst_bmp, 0, 0, 0, 0, src_bmp->w, src_bmp->h); bmp_copies = bmp_copies->next; } } //fixup_datafile(g_Datafile); Data_UpdateNamedPointers(); }
int gui_create_window(int x, int y, int w, int h, char *title, int draggable) { /* Note there's a new window, and create it */ gui_num_windows++; gui_window = realloc(gui_window,sizeof(GUI_WINDOW)*gui_num_windows); /* Setup its parameters */ gui_window[gui_num_windows-1].x = x; gui_window[gui_num_windows-1].y = y; gui_window[gui_num_windows-1].width = w; gui_window[gui_num_windows-1].height = h; gui_window[gui_num_windows-1].content_changed = TRUE; gui_window[gui_num_windows-1].visible = TRUE; sprintf(gui_window[gui_num_windows-1].title,"%s",title); /* create its rendering bitmap */ gui_window[gui_num_windows-1].bmp = create_bitmap(w+(gui_border_size*2),h+(gui_border_size*2)+gui_titlebar_height); /* Init the rest of its properties */ gui_window[gui_num_windows-1].draggable = draggable; gui_window[gui_num_windows-1].picture = NULL; gui_window[gui_num_windows-1].num_labels = 0; gui_window[gui_num_windows-1].label = NULL; gui_window[gui_num_windows-1].num_buttons = 0; gui_window[gui_num_windows-1].button = NULL; gui_window[gui_num_windows-1].num_lists = 0; gui_window[gui_num_windows-1].list = NULL; /* Make this window topmost */ gui_window_topmost = gui_num_windows-1; /* Return this window's ID */ return gui_num_windows-1; }
void AnimFrame::Draw(BITMAP* bmp, Vector pos, float scale, bool vertical_flip, float rotation, int alpha) { BITMAP* graphic = (BITMAP*)global_datafile[graphic_id].dat; if (graphic == NULL) { erlog("Graphic ID out of bounds in frame draw", 3); return; } if (bmp == NULL) { erlog("Buffer out of bounds in frame draw", 3); return; } if (scale == 0.0 && vertical_flip == false && rotation == 0.0 && (alpha >= 256 || alpha < 0)) { draw_sprite(bmp, graphic, pos.XInt(), pos.YInt()); return; } if (alpha >= 256 || alpha < 0) { if (vertical_flip == false) { rotate_scaled_sprite(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); return; } rotate_scaled_sprite_v_flip(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); return; } float fdiagonal = sqrt(static_cast<float>(graphic->w*graphic->w + graphic->h*graphic->h)); int diagonal = static_cast<int>(fdiagonal + 1); BITMAP* temp_bmp = create_bitmap(diagonal, diagonal); if (vertical_flip == false) { rotate_scaled_sprite(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); } else { rotate_scaled_sprite_v_flip(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); } set_trans_blender(0, 0, 0, alpha); drawing_mode(DRAW_MODE_TRANS, 0, 0, 0); draw_trans_sprite(temp_bmp, bmp, pos.XInt(), pos.YInt()); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); }
void Abertura (void) { BITMAP *buffer; SAMPLE *som, *grito, *som2, *som3; buffer = create_bitmap(LARGURA, ALTURA); carregaSom_Abertura(&som3, "../audio/thunder.wav"); play_sample(som3, 255, 128, 1000, FALSE); rest (1000); carregaImg_Abertura(&buffer, "../grafics/img01.tga"); highcolor_fade_in_Abertura(buffer, 3); carregaSom_Abertura(&som, "../audio/00.wav"); play_sample(som, 255, 128, 1000, FALSE); carregaSom_Abertura(&som2, "../audio/a_thunder.wav"); play_sample(som2, 255, 128, 1000, FALSE); rest (2500); carregaImg_Abertura(&buffer, "../grafics/img02.tga"); play_sample(som, 255, 128, 1000, FALSE); carregaSom_Abertura(&som, "../audio/01.wav"); play_sample(som, 1000, 128, 1000, FALSE); carregaSom_Abertura(&grito, "../audio/scream05.wav"); play_sample(grito, 255, 128, 1000, FALSE); blit(buffer,screen,0,0,0,0,LARGURA,ALTURA); highcolor_fade_out_Abertura (5); rest(1000); destroy_sample(som); destroy_sample(som2); destroy_sample(som3); destroy_sample(grito); destroy_bitmap(buffer); }
int main() { allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 900, 600, 0, 0); buffer = create_bitmap(900, 600); roca = load_bitmap("Images/roca.bmp", NULL); while(!key[KEY_ESC]) { dibujar_mapa(); pantalla(); } return 0; }
void lancerAllegro(int largeur, int hauteur) { // BUFFER d'affichage BITMAP *page; allegro_init(); install_keyboard(); /// OUVERTURE DU MODE GRAPHIQUE set_color_depth(desktop_color_depth()); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,largeur,hauteur,0,0)!=0) { allegro_message("Erreur graphique : %s", allegro_error); allegro_exit(); exit(EXIT_FAILURE); } /// CREATION DU BUFFER D'AFFICHAGE à la taille de l'écran page=create_bitmap(SCREEN_W,SCREEN_H); clear_bitmap(page); }
int advanceCredits(int position, float creditPosition) { BITMAP *credits1 = NULL; credits1 = load_bitmap("Intro Credits 1.bmp", NULL); // Load our picture BITMAP *newBuffer = NULL; newBuffer = create_bitmap(1024,768); //Create an empty bitmap. BITMAP *newBackground = NULL; newBackground = load_bitmap("Intro Background 1.bmp", NULL); // Load our picture while(!key[KEY_ESC] && creditPosition >= -position) { draw_sprite(newBuffer, newBackground, 0, 0); draw_sprite(newBuffer, credits1, 0, creditPosition); blit(newBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen creditPosition -= 0.01*(creditPosition + position + 30); } readkey(); clear_keybuf(); return(creditPosition); }
player_bullet player_bullet_init(player p) { player_bullet b; b.a = p.a; b.rot = 2 * pi * rand() / RAND_MAX; b.h = p.h + rskala() * 10 * 2.0; b.obraz = load_bitmap("media/pocisk.bmp", NULL); if (!b.obraz) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Nie moge zaladowac grafiki ( pocisk )"); allegro_exit(); } int d = diagonal(b.obraz->w, b.obraz->h); b.obraz_rot = create_bitmap(d, d); return b; }
grid_vertex_adapter(PathType & path, T dx, T dy, box2d<T> box) : dx_(dx), dy_(dy), img_(create_bitmap(box)), vt_(img_.width(), img_.height(), box), si_(box.width() / dx, box.height() / dy) { transform_path<PathType, coord_type, view_transform> tp(path, vt_); tp.rewind(0); agg::rasterizer_scanline_aa<> ras; ras.add_path(tp); agg::rendering_buffer buf(img_.data(), img_.width(), img_.height(), img_.row_size()); agg::pixfmt_gray8 pixfmt(buf); using renderer_base = agg::renderer_base<agg::pixfmt_gray8>; using renderer_bin = agg::renderer_scanline_bin_solid<renderer_base>; renderer_base rb(pixfmt); renderer_bin ren_bin(rb); ren_bin.color(agg::gray8(1)); agg::scanline_bin sl_bin; agg::render_scanlines(ras, sl_bin, ren_bin); }
/* create_mouse_pointer: * Creates the default arrow mouse sprite using the current color depth * and palette. */ static BITMAP *create_mouse_pointer(char *data) { BITMAP *bmp; int x, y; int col; bmp = create_bitmap(DEFAULT_SPRITE_W, DEFAULT_SPRITE_H); for (y=0; y<DEFAULT_SPRITE_H; y++) { for (x=0; x<DEFAULT_SPRITE_W; x++) { switch (data[x+y*DEFAULT_SPRITE_W]) { case 1: col = makecol(255, 255, 255); break; case 2: col = makecol(0, 0, 0); break; default: col = bmp->vtable->mask_color; break; } putpixel(bmp, x, y, col); } } return bmp; }
static BITMAP *generate_bitmap(AL_CONST unsigned char templat[], int w, int h) { BITMAP *bmp; AL_CONST unsigned char *p; int x, y; bmp = create_bitmap(w, h); p = templat; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { if (*p == 0) putpixel(bmp, x, y, bitmap_mask_color(bmp)); else putpixel(bmp, x, y, makecol(*p, *p, *p)); p++; } } return bmp; }
void draw_text(BITMAP *bmp, int x, int y, int w, int h, int color, const char *format, ...) { if (w > 0 && h > 0) { char buf[512]; va_list ap; va_start(ap, format); uvszprintf(buf, sizeof(buf), format, ap); va_end(ap); BITMAP *tmp = create_bitmap(text_length(gamefont, buf), text_height(gamefont)+1); clear_to_color(tmp, bitmap_mask_color(tmp)); textout_ex(tmp, gamefont, buf, 0, 1, blend_color(color, makecol(0, 0, 0), 0.5), -1); textout_ex(tmp, gamefont, buf, 0, 0, color, -1); masked_stretch_blit(tmp, bmp, 0, 0, tmp->w, tmp->h, x, y, w, h); destroy_bitmap(tmp); } }
void crosshair_init(running_machine &machine) { /* request a callback upon exiting */ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_exit), &machine)); /* clear all the globals */ memset(&global, 0, sizeof(global)); /* setup the default auto visibility time */ global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ for (ioport_port *port = machine.ioport().first_port(); port != NULL; port = port->next()) for (ioport_field *field = port->first_field(); field != NULL; field = field->next()) if (field->crosshair_axis() != CROSSHAIR_AXIS_NONE) { int player = field->player(); assert(player < MAX_PLAYERS); /* mark as used and set the default visibility and mode */ global.usage = TRUE; global.used[player] = TRUE; global.mode[player] = CROSSHAIR_VISIBILITY_DEFAULT; global.visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE; /* for now, use the main screen */ global.screen[player] = machine.primary_screen; create_bitmap(machine, player); } /* register callbacks for when we load/save configurations */ if (global.usage) config_register(machine, "crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine)); /* register the animation callback */ if (machine.primary_screen != NULL) machine.primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(animate), &machine)); }
int pingpong() { buffer = create_bitmap( 640, 480); BITMAP *BGpong = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\BGpong.bmp", NULL); samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\pingpong.wav"); play_sample(samSong, 128, 128, 1000, 1); setupGame(); while( !key[KEY_ESC]) { draw_sprite(buffer, BGpong, 0,0); textprintf(buffer,font,60,2,makecol(255,255,255), "P1=%d", count1); textprintf(buffer,font,540,2,makecol(255,255,255), "P2=%d", count2); p1Move(); p2Move(); moveBall(); checkWin(); if(scored==1) pingpong_score(); if(key[KEY_BACKSPACE]) { count1=0; count2=0; ball_x=320; ball_y=240; p1_x = 20; p1_y = 210; p2_x = 620; p2_y = 210; stop_sample(samSong); openscreen(); } } return 0; }