//--------------------------------------------------------------------------- void Table::Sync(void) { #ifndef NO_TABLE_WIN32_LOCKING if (!Handle) return; char lockbuf[4096]; wsprintf(lockbuf,"%s.lock",Handle->filename); int retry_cnt=0; HANDLE hFile; do { hFile = CreateFile(lockbuf,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); if (hFile == INVALID_HANDLE_VALUE) Sleep(100); } while (hFile == INVALID_HANDLE_VALUE && retry_cnt++ < 100); // try for 10 seconds if (hFile == INVALID_HANDLE_VALUE) return; // db already locked, fail gracefully #endif if (IndexList) { IndexField *field = (IndexField *)IndexList->Fields.GetHead(); while (field) { field->index->WriteIndex(); field = (IndexField *)field->GetNext(); } } int err=0; if (!err && Handle) err|=Vsync(Handle); if (!err && IdxHandle) err|=Vsync(IdxHandle); if (!err && FieldsRecord) { ColumnField *field = (ColumnField *)FieldsRecord->Fields.GetHead(); while (field) { if (field->indexUnique && field->uniqueTable) field->uniqueTable->Sync(); field = (ColumnField *)field->GetNext(); } } #ifndef NO_TABLE_WIN32_LOCKING CloseHandle(hFile); DeleteFile(lockbuf); #endif }
/* * Cancel changes made to any color */ void cnclchgs(void) { /* if in ST high rez and invert state has been changed */ if (currez == STHI && oldinv != curinv) flip(1, &oldinv); /* reset to original invert state */ if (bpg > 0) { /* if it's a color system */ /* restore modified colors with old values for all banks */ for (curbnk = BNK_MIN; curbnk < numbnk; curbnk++) { if (touch_bnk[curbnk] == DIRTY) { visit_bnk(1); cnclbnk(); } } /* if hypermono mode supported, reset to original mode */ if (curmode == TTVDO && currez != TTHI && oldgray != curgray) { Vsync(); EsetGray(oldgray); reinitcol(); } } if (numbnk > 1) { /* if there's bank switching */ EsetBank(oldbnk); /* reset to original bank */ reinitcol(); } }
main() { int i; init_screens (); /* Initialisiation du 2Šme ‚cran */ gem_init(); /* Se trouve dans fichier Include GEM_INEX.C */ v_hide_c (handle); /* D‚sactiver pointeur souris */ for (i=20; i<=300; i++) { Cconws ("\33E"); /* Effacer ‚cran */ v_gtext (handle, i, i, "Salut!"); /* Affichage texte sous GEM */ swap_screens (); /* Commuter ‚crans log./phys. */ Vsync(); /* Attente retour image */ } Crawcin(); /* Attente appui touche */ Setscreen (screen1, screen1, -1); /* Retour … l'‚cran normal */ v_show_c (handle, 1); /* Pointeur souris actif */ gem_exit(); }
jimints_off() { if (jimint_status) { Supexec(pfcleanup); Vsync(); jimint_status = 0; } }
/* * Update to next bank of available colors */ void nxtbnk(void) { curslid = BNKSLID; slidtext(); /* update bank # */ Vsync(); /* wait for next vblank to occur */ visit_bnk(1); /* visit the desired Bank */ reinitcol(); /* re-initialize color */ update_rgb(1); /* update and draw the RGB indices */ }
/* do_redraw() *========================================================================== * Standard object tree redraw routine for handling object trees * * IN: OBJECT *tree: object tree * int object: object to redraw * GRECT *prect: GRECT of dirtied area * * OUT: void * * GLOBAL: WINFO w: window structure */ void do_redraw( OBJECT *tree, GRECT *prect ) { GRECT rect; Wind_get( w.id, WF_FIRSTXYWH, ( WARGS *)&rect ); while( !rc_empty( &rect ) ) { if( rc_intersect( prect, &rect )) { Vsync(); Objc_draw( tree, ROOT, MAX_DEPTH, &rect ); } Wind_get( w.id, WF_NEXTXYWH, ( WARGS *)&rect ); } }
/* * Initialize system with given information. */ void init(DEFAULTS *info) { int i; /* counter */ open_vwork(); /* if not boot time, on a color system and has more than 1 bank */ if (!xcpb->booting && bpg && numbnk > 1) { for (curbnk = BNK_MIN; curbnk < NUM_BNK; curbnk++) { if (setup_bnk[curbnk] == CLEAN) { setup_bnk[curbnk] = DIRTY; visit_bnk(1); for (i = 0; i < numcol; i++) { vq_color(vhandle, i, 0, (int *)(curold+i)); } } } } switch((int)curmode) { case TTVDO: /* if TT video */ if (info->gray != -1) { /* set to color or gray scales */ Vsync(); EsetGray(info->gray); } switch(currez) { default: /* in ST Low/Med, TT Med rez */ if (info->bnk != -1) { EsetBank(0); slamcol(info->ubnk0.orez); /* set up colors in every bank */ for (i = BNK_MIN+1; i < NUM_BNK; i++) { EsetBank(i); slamcol(info->obnk[i-1]); } /* set to desired bank */ EsetBank(info->bnk); } break; case STHI: /* if in ST high rez */ /* if invert state is saved, set it */ if (info->inv != -1) { flip(1, &info->inv); if (!(info->inv & NOT_FLIPPED)) { swaprgb(&info->ubnk0.orez[0], &info->ubnk0.orez[1]); slamcol(info->ubnk0.orez); swaprgb(&info->ubnk0.orez[0], &info->ubnk0.orez[1]); } else { slamcol(info->ubnk0.orez); } } else { slamcol(info->ubnk0.orez); } break; case TTLOW: /* if in TT low rez */ slamcol(info->ubnk0.ttlow); break; case TTHI: /* if in TT high rez */ /* do nothing */ break; } break; case STVDO: /* if ST or STE video */ case STEVDO: if (currez == STHI) { /* if in ST high rez */ if (info->inv != -1) /* if invert state saved */ flip(1, &info->inv); /* set to it */ } else { slamcol(info->ubnk0.orez); } break; } if (!xcpb->booting) { /* if not boot time */ if (currez == STHI) { if (curinv != info->inv) { if (!(info->inv & NOT_FLIPPED)) Select(INVRSVDO); draw_button(INVRSVDO); Deselect(INVRSVDO); curinv = info->inv; } } if ((int)curmode == TTVDO && currez != TTHI) { if (curgray != info->gray) { if (info->gray) { HideObj(SETGRAY); i = SETCOL; } else { HideObj(SETCOL); i = SETGRAY; } ShowObj(i); draw_button(i); curgray = info->gray; } } if (bpg) { if (numbnk == 1) { touch_bnk[0] = DIRTY; for (i = 0; i < numcol; i++) { vq_color(vhandle, i, 0, (int *)(curnew+i)); *(curdirt+i) = DIRTY; } } else { for (curbnk = BNK_MIN; curbnk < numbnk; curbnk++) { touch_bnk[curbnk] = setup_bnk[curbnk] = DIRTY; visit_bnk(1); for (i = 0; i < numcol; i++) { vq_color(vhandle, i, 0, (int *)(curnew+i)); *(curdirt+i) = DIRTY; } } curbnk = info->bnk; visit_bnk(1); update_slid(HORIZONTAL, BNKBASE, BNKSLID, curbnk, BNK_MIN, BNK_MAX, 1); } update_rgb(1); } } close_vwork(); }
/* * Show color panel * Passed: GRECT *rect = pointer to rectangle CPX resides in * Returns: BOOLEAN FALSE = to exit CPX */ BOOLEAN cdecl colpnl(GRECT *rect) { MRETS mk; int quit=0; int obj, ox, oy; WORD msg[8], clip[4]; GRECT obrect; /* object rectangle */ Wind_get(0, WF_WORKXYWH, (WARGS *)&obrect); /* set clipping to */ rc_2xy(&obrect, clip); /* Desktop space */ open_vwork(); vs_clip(vhandle, 1, (int *)clip); ObX(COLPNL) = rect->g_x; /* position panel */ ObY(COLPNL) = rect->g_y; Objc_draw(tree, COLPNL, MAX_DEPTH, NULL); /* draw panel */ draw_boxes(); /* draw the color boxes */ outline(curbox, HILITE); /* show selected box */ close_vwork(); if (IsSelected(INVRSVDO)) /* if Invert button is selected */ Deselect(INVRSVDO); /* deselect it */ do { if ((obj = (*xcpb->Xform_do)(tree, COLPNL, msg)) != -1) { obj &= 0x7fff; /* mask out double clicks */ switch(obj) { case RUP: curslid = RSLID; (*xcpb->Sl_arrow)(tree, RBASE, RSLID, RUP, 1, val_min, val_max, &curscrn[R], VERTICAL, adjcol); break; case RDOWN: curslid = RSLID; (*xcpb->Sl_arrow)(tree, RBASE, RSLID, RDOWN, -1, val_min, val_max, &curscrn[R], VERTICAL, adjcol); break; case RSLID: (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) DRAG_MOUSE; curslid = RSLID; (*xcpb->Sl_dragy)(tree, RBASE, RSLID, val_min, val_max, &curscrn[R], adjcol); (*xcpb->MFsave)(MFRESTORE, &orig_mf); break; case RBASE: Graf_mkstate(&mk); objc_offset(tree, RSLID, &ox, &oy); if(mk.y < oy) oy = VAL_PAGE; else oy = -VAL_PAGE; curslid = RSLID; (*xcpb->Sl_arrow)(tree, RBASE, RSLID, -1, oy, val_min, val_max, &curscrn[R], VERTICAL, adjcol); break; case GUP: curslid = GSLID; (*xcpb->Sl_arrow)(tree, GBASE, GSLID, GUP, 1, val_min, val_max, &curscrn[G], VERTICAL, adjcol); break; case GDOWN: curslid = GSLID; (*xcpb->Sl_arrow)(tree, GBASE, GSLID, GDOWN, -1, val_min, val_max, &curscrn[G], VERTICAL, adjcol); break; case GSLID: (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) DRAG_MOUSE; curslid = GSLID; (*xcpb->Sl_dragy)(tree, GBASE, GSLID, val_min, val_max, &curscrn[G], adjcol); (*xcpb->MFsave)(MFRESTORE, &orig_mf); break; case GBASE: Graf_mkstate(&mk); objc_offset(tree, GSLID, &ox, &oy); if(mk.y < oy) oy = VAL_PAGE; else oy = -VAL_PAGE; curslid = GSLID; (*xcpb->Sl_arrow)(tree, GBASE, GSLID, -1, oy, val_min, val_max, &curscrn[G], VERTICAL, adjcol); break; case BUP: curslid = BSLID; (*xcpb->Sl_arrow)(tree, BBASE, BSLID, BUP, 1, val_min, val_max, &curscrn[B], VERTICAL, adjcol); break; case BDOWN: curslid = BSLID; (*xcpb->Sl_arrow)(tree, BBASE, BSLID, BDOWN, -1, val_min, val_max, &curscrn[B], VERTICAL, adjcol); break; case BSLID: (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) DRAG_MOUSE; curslid = BSLID; (*xcpb->Sl_dragy)(tree, BBASE, BSLID, val_min, val_max, &curscrn[B], adjcol); (*xcpb->MFsave)(MFRESTORE, &orig_mf); break; case BBASE: Graf_mkstate(&mk); objc_offset(tree, BSLID, &ox, &oy); if(mk.y < oy) oy = VAL_PAGE; else oy = -VAL_PAGE; curslid = BSLID; (*xcpb->Sl_arrow)(tree, BBASE, BSLID, -1, oy, val_min, val_max, &curscrn[B], VERTICAL, adjcol); break; case COLUP: (*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, COLUP, -1, col_max, col_min, &curcol, VERTICAL, nxtrow); break; case COLDOWN: (*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, COLDOWN, 1, col_max, col_min, &curcol, VERTICAL, nxtrow); break; case COLSLID: (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) DRAG_MOUSE; (*xcpb->Sl_dragy)(tree, COLBASE, COLSLID, col_max, col_min, &curcol, nxtgrp); (*xcpb->MFsave)(MFRESTORE, &orig_mf); break; case COLBASE: Graf_mkstate(&mk); objc_offset(tree, COLSLID, &ox, &oy); if(mk.y < oy) oy = -col_page; else oy = col_page; curslid = COLSLID; (*xcpb->Sl_arrow)(tree, COLBASE, COLSLID, -1, oy, col_max, col_min, &curcol, VERTICAL, nxtpage); break; case BNKRIGHT: (*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, BNKRIGHT, 1, BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk); break; case BNKLEFT: (*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, BNKLEFT, -1, BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk); break; case BNKSLID: (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) DRAG_MOUSE; (*xcpb->Sl_dragx)(tree, BNKBASE, BNKSLID, BNK_MIN, BNK_MAX, &curbnk, nxtbnk); (*xcpb->MFsave)(MFRESTORE, &orig_mf); break; case BNKBASE: Graf_mkstate(&mk); objc_offset(tree, BNKSLID, &ox, &oy); if(mk.x < ox) oy = -BNK_PAGE; else oy = BNK_PAGE; (*xcpb->Sl_arrow)(tree, BNKBASE, BNKSLID, -1, oy, BNK_MIN, BNK_MAX, &curbnk, HORIZONTAL, nxtbnk); break; case DUO0: /* for ST High rez */ case DUO1: case QUARTRO0: /* for ST Medium rez */ case QUARTRO1: case QUARTRO2: case QUARTRO3: case BOX0: /* for all other rez */ case BOX1: case BOX2: case BOX3: case BOX4: case BOX5: case BOX6: case BOX7: case BOX8: case BOX9: case BOX10: case BOX11: case BOX12: case BOX13: case BOX14: case BOX15: if (obj != curbox) { /* select requested color */ curcol = obj - headbox + headcol; nxt_to_show(0); update_slid(VERTICAL, COLBASE, COLSLID, curcol, col_max, col_min, 1); } break; case INVRSVDO: Deselect(obj); /* deselect button */ flip(0, &curinv); /* read invert state */ if (curinv & NOT_FLIPPED) { /* inverted? */ curinv &= 0xfffe; /* if not, invert it */ } else { /* else */ curinv |= NOT_FLIPPED; /* restore it */ draw_button(obj); /* redraw button */ } flip(1, &curinv); /* set new invert state */ if (bpg) { /* if color */ swaprgb(curnew, curnew+1); /* swap pen 0 and 1 */ open_vwork(); vs_color(vhandle, 0, (int *)curnew); vs_color(vhandle, 1, (int *)(curnew+1)); close_vwork(); *curdirt = *(curdirt+1) = *touch_bnk = DIRTY; update_rgb(1); /* update RGB sliders */ } break; case SETGRAY: case SETCOL: Deselect(obj); /* deselect selected button */ HideObj(obj); /* hide selected button */ if (obj == SETGRAY) { obj = SETCOL; /* change to Color button */ curgray = TRUE; /* turn on hypermono */ } else { obj = SETGRAY; /* change to Gray button */ curgray = FALSE; /* turn off hypermono */ } ShowObj(obj); /* show new button */ draw_button(obj); /* draw it */ Vsync(); EsetGray(curgray); /* set to selected mode */ reinitcol(); /* reinit color regs */ break; case COLSAVE: /* save current values */ if ((*xcpb->XGen_Alert)(SAVE_DEFAULTS) == TRUE) { (*xcpb->MFsave)(MFSAVE, &orig_mf); if( AES_Version >= 0x0320 ) BEE_MOUSE; if (bpg) { /* if color */ usr_vals.bnk = curbnk; /* save bank # */ savergb(); /* save color info */ /* update RGBs */ cpyrgb((RGB *)&oldrgb, (RGB *)&newrgb, totcol); } if (currez == STHI) /* if in ST high rez */ usr_vals.inv = curinv; /* save invert state */ /* if hypermono supported, save state */ if (curmode == TTVDO && currez != TTHI) usr_vals.gray = curgray; /* save current data to file */ saved = 1; (*xcpb->CPX_Save)((void *)&saved, sizeof(DEFAULTS)+2); (*xcpb->MFsave)(MFRESTORE, &orig_mf); } Deselect(obj); draw_button(obj); break; case COLCNCEL: cnclchgs(); /* cancel all changes made */ case COLOK: /* accept all changes made */ Deselect(obj); /* deselect button */ quit = TRUE; /* ready to quit */ break; case COLRLOAD: /* reload saved user-preference */ if (saved) init(&usr_vals); else init(&def_vals); Deselect(obj); draw_button(obj); break; } } else { switch(msg[0]) { case WM_REDRAW: /* redraw cpx */ do_redraw((GRECT *)&msg[4], (int *)clip); break; case KEY_CODE: switch(msg[3]) { /* check which key is returned */ case UNDO: /* if Undo key */ /* reset to original invert state */ if (currez == STHI && oldinv != curinv) { flip(1, &oldinv); if (!(oldinv & NOT_FLIPPED)) Select(INVRSVDO); draw_button(INVRSVDO); Deselect(INVRSVDO); curinv = oldinv; } if (bpg) { /* if there is color */ if ((int)curmode == TTVDO && currez != TTHI && curgray != oldgray) { Vsync(); EsetGray(oldgray); reinitcol(); if (oldgray) { HideObj(SETGRAY); obj = SETCOL; } else { HideObj(SETCOL); obj = SETGRAY; } ShowObj(obj); draw_button(obj); curgray = oldgray; } cnclbnk(); /* cancel color changes */ update_rgb(1); /* update RGB on screen */ } break; case HOME: /* if Clr Home key */ if (currez != TTHI) /* if not in TT High rez */ init(&def_vals); /* init to system defs */ break; } break; case AC_CLOSE: cnclchgs(); /* cancel changes made */ case WM_CLOSED: quit = TRUE; /* ready to quit */ break; } } } while (!quit); return (FALSE); }
/* blit_slots() *========================================================================== * Handle the scrolling of the slots. Worst case is to redraw all four * slots. Otherwise, we blit three, two or one slots, and redraw the * remaining. * * IN: int oldnum: Old node number * int newnum: new node number * Note: the node nunber is the node * that is in the first slot. * OUT: void */ void blit_slots( int oldnum, int newnum ) { OBJECT *tree = ( OBJECT *)rs_trindex[ XCONTROL ]; GRECT srcbase; GRECT dstbase; GRECT clip; GRECT rect; int pxy[16]; GRECT clip2; int offset; long location = 0L; int dummy; int ypos1; int ypos2; clip = ObRect( SLOT0 ); objc_offset( tree, SLOT0, &clip.g_x, &clip.g_y ); clip.g_h = ( clip.g_h * MAX_SLOTS ) + MAX_SLOTS; clip2 = srcbase = dstbase = rect = clip; offset = newnum - oldnum; /* Serious Kludge - This will do a blit, when we shouldn't. * The code following kludges the height comparisons to * force a total redraw instead of a blit when we are * 8 pixels too close to the edge */ ypos1 = desk.g_y + desk.g_h - 1; objc_offset( tree, SLOTBASE, &dummy, &ypos2 ); ypos2 = ypos2 + ObH( SLOTBASE ) + 8; if( !offset ) /* went nowhere fast...*/ return; if( !open_vwork() ) return; rc_intersect( &desk, &clip2 ); if( ( abs( offset ) < MAX_SLOTS ) && rc_equal( &clip2, &clip ) && ( ypos2 < ypos1 ) ) { rect.g_h = ( abs( offset ) * ObH( SLOT0 ) ); dstbase.g_h = srcbase.g_h = (MAX_SLOTS - abs(offset )) * ObH( SLOT0 ) + ( MAX_SLOTS - abs( offset) ); if( offset > 0 ) { objc_offset( tree, slots[ abs( MAX_SLOTS - offset ) ].obj, &dummy, &rect.g_y ); objc_offset( tree, slots[ abs( offset ) ].obj, &dummy, &srcbase.g_y ); } else objc_offset( tree, slots[ abs( offset ) ].obj, &dummy, &dstbase.g_y ); rc_intersect( &desk, &srcbase ); rc_intersect( &desk, &dstbase ); rc_2xy( &srcbase, ( WORD *) &pxy[0] ); rc_2xy( &dstbase, ( WORD *)&pxy[4] ); rc_2xy( &clip, ( WORD *)&pxy[8] ); vs_clip( vhandle, 1, &pxy[8] ); graf_mouse( M_OFF, 0L ); Vsync(); vro_cpyfm( vhandle, 3, pxy, ( MFDB *)&location, ( MFDB *)&location ); graf_mouse( M_ON, 0L ); } else { rc_2xy( &clip, ( WORD *)&pxy[0] ); vs_clip( vhandle, 1, &pxy[0] ); } Vsync(); Objc_draw( tree, SLOTBASE, MAX_DEPTH, &rect ); close_vwork(); }
/* blit_slits() *========================================================================== * Perform the blitting when the slits are scrolling. * IN: BOOLEAN flag: either Active or Inactive * int old_slit: The previous slit * int new_slit: The current slit to work on. */ void Blit_Slits( int old_slit, int new_slit ) { GRECT srcbase; GRECT dstbase; GRECT clip; GRECT rect; int pxy[16]; GRECT clip2; int offset; long location = 0L; int dummy; int obj; int base; obj = First_Obj; base = Base_Obj; clip = ObRect( base ); objc_offset( tree, obj, &clip.g_x, &clip.g_y ); clip2 = srcbase = dstbase = rect = clip; offset = new_slit - old_slit; if( !offset ) /* went nowhere fast...*/ return; if( !open_vwork()) { return; } rc_intersect( &desk, &clip2 ); if( ( abs( offset ) < MAX_SLITS ) && rc_equal( &clip2, &clip ) ) { rect.g_h = ( abs( offset ) * ObH( obj ) ); dstbase.g_h = srcbase.g_h = ( MAX_SLITS - abs( offset ) ) * ObH( obj ); if( offset > 0 ) { objc_offset( tree, obj + abs( MAX_SLITS - offset ), &dummy, &rect.g_y ); objc_offset( tree, obj + abs( offset ), &dummy, &srcbase.g_y ); } else objc_offset( tree, obj + abs( offset ), &dummy, &dstbase.g_y ); rc_intersect( &desk, &srcbase ); rc_intersect( &desk, &dstbase ); rc_2xy( &srcbase, ( WORD *) &pxy[0] ); rc_2xy( &dstbase, ( WORD *)&pxy[4] ); rc_2xy( &clip, ( WORD *)&pxy[8] ); vs_clip( vhandle, 1, &pxy[8] ); graf_mouse( M_OFF, 0L ); Vsync(); vro_cpyfm( vhandle, 3, pxy, ( MFDB *)&location, ( MFDB *)&location ); graf_mouse( M_ON, 0L ); } else { rc_2xy( &clip, ( WORD *)&pxy[0] ); vs_clip( vhandle, 1, &pxy[0] ); } Vsync(); Objc_draw( tree, base, MAX_DEPTH, &rect ); close_vwork(); }
int main() { int i = 0; int j = 1; int musicCounter = 0; UINT8 *base = Physbase(); UINT8 *base2 = buffer; UINT8 ch; UINT8 has_moved = 1; UINT8 switchBase = 0; UINT32 timeNow, timeThen, prevCall; struct Model game; struct Model *gamePtr = &game; base2 += 256 - ((long)base2 & (long)0xFF); init_model(gamePtr); disable_cursor(); Setscreen(-1, base2, -1); disable_cursor(); Setscreen(-1, base, -1); timeNow = get_time(); timeThen = timeNow + DELAY; start_sound(); prevCall = timeNow; srand(time(0)); while(!game_over(gamePtr)) { if(update_music(get_time() - prevCall)){ prevCall = get_time(); } /* Check if there is kbd input */ if(kbd_is_waiting()) { ch = kbd_read_char(); request_player_move(gamePtr, 0, ch); } /* If clock ticked */ if(timeNow != get_time()) { /* Check if a second has passed */ if(timeNow >= timeThen) { update_score(gamePtr, 1); timeThen = timeNow + DELAY; } /* Move player ship */ has_moved = move_player_ship(gamePtr, 0); if(has_moved){ thruster(); } /* Move enemy ships and check collisions with player ship */ for(i = 0; i < NUM_ENEMIES; i++) { move_enemy_ship(gamePtr, i); collision(gamePtr,i,0); } /* Render the model with double buffering */ if(switchBase) { render_model(gamePtr, base, has_moved); Setscreen(-1, base, -1); } else { render_model(gamePtr, base2, has_moved); Setscreen(-1, base2, -1); } Vsync(); switchBase = !switchBase; } stop_thruster(); timeNow = get_time(); } stop_sound(); explosion(); render_model(gamePtr, base, has_moved); Setscreen(-1, base, -1); Vsync(); return 0; }
init_sys() { WORD work_in[11]; WORD work_out[57]; WORD i; save_critical(); got_blitter = ( (_xbios(64, -1) & 3 ) == 3); if ( (gl_apid = appl_init()) == -1) { exit(-1); } aline = ainit(); if (!init_mem()) exit(-2); /* save initial rez ... we'll see if GEM agrees with this later */ if ( (irez = Getrez()) != 0) { if (irez != 1) { puts("Cyber Paint can't run on black and white systems, sorry"); for (i=0; i<60; i++) { Vsync(); } exit(-3); } } get_cmap(color_env); copy_words(init_cmap, sys_cmap, COLORS); put_cmap(sys_cmap); initted_color = 1; if (!init_pulls()) return(-4); /* save mouse wrap-around */ mouse_bx = *((WORD *)(aline-692)); mouse_by = *((WORD *)(aline-690)); /* save # of colors gem thinks exist */ gem_colr = *((WORD *)(aline-666)); gr_handle = graf_handle(&gr_hwchar, &gr_hhchar, &gr_hwbox, &gr_hhbox); handle = gr_handle; stuff_words(work_in, 1, 10); work_in[10] = 2; v_opnvwk(work_in, &handle, work_out); if (handle == 0) return(-5); if (work_out[0] == 639) { gem_mrez = 1; /* see what GEM thinks rez is in so file-requestor can work */ /* poke in initial mouse location (in case off-screen for lo-rez */ *((WORD *)(aline-602)) = 160; *((WORD *)(aline-600)) = 100; } jim_rez(); pscreen = cscreen = (WORD *)Physbase(); if ((uscreen = askmem(32000)) == NULL) return(-6); if ((start_screen = askmem(32000)) == NULL) return(-7); if ((end_screen = askmem(32000)) == NULL) return(-8); if ((prev_screen = laskmem(2L*32000L)) == NULL) /* prev/next form 64K buffer */ return(-9); next_screen = prev_screen+16000; if ((bscreen = askmem(32000)) == NULL) return(-11); empty_ram_dlt(); zero_screens(); if (!init_input()) return(-13); init_fname(); init_menu_colors(); install_critical(); jimints_on(); cel_mem_alloc = mem_free; /* "user" memory starts here */ return(1); }