swap_screens() /* Commuter ‚crans 1/2 */ { if (Logbase () == screen1) Setscreen (screen2, screen1, -1); else Setscreen (screen1, screen2, -1); }
uninit_sys() { WORD dummy; WORD i; Vector ourmbvec; jimints_off(); wait_penup(); for (i=0; i<22000; i++) ; /* just stall - hey I'm experimenting */ free_cfont(); set_for_gem(); /*magic poke to set mouse wrap-around*/ *((WORD *)(aline-692)) = mouse_bx; *((WORD *)(aline-690)) = mouse_by; *((WORD *)(aline-666)) = gem_colr; Setscreen( -1L, -1L, irez); /*restore palette...*/ if (initted_color) Setpallete(color_env); remove_critical(); if (handle != 0) v_clsvwk(handle); if (gl_apid != -1) appl_exit(0); }
jim_rez() { Setscreen( -1L, -1L, 0); *((WORD *)(aline-692)) = 319; *((WORD *)(aline-690)) = 199; *((WORD *)(aline-666)) = 16; }
int init_display() { unsigned short loop,yr; unsigned short k,i; screen_buffer_backup_aligned=(unsigned char*)malloc(16*1024); SCREEN_YRESOL=200; NUMBER_OF_FILE_ON_DISPLAY=19-5;// 19-5 //19 -240 old_physical_adr=(unsigned long)Physbase(); screen_buffer=(unsigned char*)malloc((32*1024) + 256); memset(screen_buffer,0,(32*1024) + 256); screen_buffer_aligned = (unsigned char*)(((unsigned long)screen_buffer| 0xff)+1); screen_buffer_backup=(unsigned char*)malloc((8*1000) + 256); memset(screen_buffer_backup,0,(8*1000) + 256); screen_buffer_backup_aligned = (unsigned char*)(((unsigned long)screen_buffer_backup| 0xff)+1); Blitmode(1); Setscreen( -1, screen_buffer_aligned, 1 ); color=0; Supexec(initpal); init_buffer(); }
/* * Cleanup -- restore palette and sane VT52 state. */ vt_cleanup() { /* * Restore desktop resolution (if we switched). */ if (drez != Getrez()) Setscreen(-1L, -1L, drez); if (drez != 2) { /* * Restore desktop palette. */ Setpalette(dpalette); Cconws("\033b"); Cconout(3 + VTC); Cconws("\033c"); Cconout(0 + VTC); } /* * Bring the mouse back */ graf_mouse(M_ON, NULL); /* * Make the cursor visible */ curs_show(); }
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(); }
static void restoreMode(_THIS) { /* SB3 do not allow changing video mode */ Setscreen(-1, XBIOS_oldvbase, -1); if (XBIOS_oldnumcol) { VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette); } }
gem_rez() { if (gem_mrez) { Setscreen( -1L, -1L, 1); *((WORD *)(aline-692)) = 639; *((WORD *)(aline-690)) = 199; *((WORD *)(aline-666)) = 4; } }
static void setMode(_THIS, xbiosmode_t *new_video_mode) { /* SB3 do not allow changing video mode */ Setscreen(-1,XBIOS_screens[0],-1); /* Set hardware palette to black in True Colour */ if (new_video_mode->depth > 8) { SDL_memset(F30_palette, 0, sizeof(F30_palette)); VsetRGB(0,256,F30_palette); } }
int InitTank() { int ii; /* initialiser cookie */ InitCookie(); /* sauvegarder palette des couleurs */ for ( ii = 0; ii < 16; ii++ ) SavPalette[ii] = Setcolor(ii,-1); /* aller en basse resolution */ SavRez = Getrez(); if ( SavRez > 1 ) return (1); /* mise en place des ecrans de travail */ _SavLogScreen = (char *)Logbase(); _SavPhyScreen = (char *)Physbase(); _Screens[0] = (char *)malloc(32256L); _Screens[1] = (char *)malloc(32256L); if ( _Screens[0] == 0 || _Screens[1] == 0L ) return (2); _Screens[0] = _ShowScreen = (char *)((long)(_Screens[0] + 255) & 0xFFFFFF00L); _Screens[1] = _HideScreen = (char *)((long)(_Screens[1] + 255) & 0xFFFFFF00L); MemClear(_Screens[0],32000L); MemClear(_Screens[1],32000L); Setpalette(BlackPalette); if ( ShipSetUp(0) == 0 ) return (2); if ( MiscSetUp() == 0 ) return (2); if ( StarSetUp() == 0 ) return (2); if ( AstSetUp() == 0 ) return (2); if ( ExplSetUp() == 0 ) return (2); Setscreen(_Screens[0],_Screens[0],0); TTSpl = ((Cookies.snd & 2) != 0); SplOn._proc = _SplOnProc[ TTSpl ]; SplOff._proc = _SplOffProc[ TTSpl ]; NStars = (Cookies.cpu > 10) ? 32 : 16; return (0); }
/* set_for_gem and set_for_jim - functions that let me run at low rez while doing file requestor and file io at whatever rez GEM thinks it is - necessary for file requestor to appear ok, and for system io error dialogs to be centered etc. Thanks to Dave Staugas (of Neochrome) for the necessary magic aline peeks and pokes! */ set_for_gem() { WORD i; wait_penup(); for (i=0; i<22000; i++) ; /* just stall - hey I'm experimenting */ remove_critical(); Setpallete(color_env); /* restore start-up colors */ hide_mouse(); /* go reset mouse and */ vs_clip(handle, 0, screen_bounds); gem_rez(); /* screen rez */ gshow_mouse(); /* to what GEM wants */ Setscreen(pscreen, pscreen, -1); }
void driver( enum sort atype, int *array, int elements, int random, int delay_factor ) { switch( atype ) { /* 所有排序算法 */ case all : /* 冒泡排序 */ case bubble : Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + bubble) ); Bubble( array, elements, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* 延迟交换排序 */ case delayed: Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + delayed) ); Delayed( array, elements, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* 希尔排序 */ case shell : Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + shell )); Shell( array, elements, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* Metzner希尔排序 */ case shell_metzner: Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + shell_metzner) ); Shell_Metzner( array, elements, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* 快速排序 */ case quick : Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + quick) ); Quicksort( array, 0, elements - 1, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* 插入排序 */ case insertion: Setscreen( array, elements, random ); gprintf( &xaxis, &yaxis, *(sorts + insertion) ); Insertion( array, elements, delay_factor ); if ( atype != all ) break; else delay( 1350 ); /* 停止 */ case stop: default:; } }
void gem_main(void) { WORD i; const BITBLK *tmpadbi; sh_rdinf(); /* get start of emudesk.inf */ if (!gl_changerez) /* can't be here because of rez change, */ process_inf1(); /* so see if .inf says we need to change rez */ if (gl_changerez) { switch(gl_changerez) { #if CONF_WITH_SHIFTER case 1: /* ST(e) or TT display */ Setscreen(-1L,-1L,gl_nextrez-2,0); initialise_palette_registers(gl_nextrez-2,0); break; #endif #if CONF_WITH_VIDEL case 2: /* Falcon display */ Setscreen(-1L, -1L, FALCON_REZ, gl_nextrez); initialise_palette_registers(FALCON_REZ,gl_nextrez); break; #endif } gsx_wsclear(); /* avoid artefacts that may show briefly */ } totpds = NUM_PDS; ml_ocnt = 0; gl_changerez = FALSE; ini_dlongs(); /* init longs */ cli(); takecpm(); /* take the 0efh int. */ /* init event recorder */ gl_recd = FALSE; gl_rlen = 0; gl_rbuf = 0x0L; /* initialize pointers to heads of event list and thread list */ elinkoff = (BYTE *) &(D.g_intevb[0].e_link) - (BYTE *) &(D.g_intevb[0]); /* link up all the evb's to the event unused list */ eul = NULLPTR; ev_init(&D.g_intevb[0], NUM_IEVBS); if (totpds > 2) ev_init(&D.g_extevb[0], NUM_EEVBS); /* initialize sync blocks */ wind_spb.sy_tas = 0; wind_spb.sy_owner = NULLPTR; wind_spb.sy_wait = 0; /* * init processes - TODO: should go in gempd or gemdisp. */ /* initialize list and unused lists */ nrl = drl = NULLPTR; dlr = zlr = NULLPTR; fph = fpt = fpcnt = 0; /* init initial process */ for(i=totpds-1; i>=0; i--) { rlr = pd_index(i); if (i < 2) { rlr->p_uda = &D.g_intuda[i]; rlr->p_cda = &D.g_intcda[i]; } else { rlr->p_uda = &D.g_extuda[i-2]; rlr->p_cda = &D.g_extcda[i-2]; } rlr->p_qaddr = (LONG)(&rlr->p_queue[0]); rlr->p_qindex = 0; memset(rlr->p_name, ' ', 8); rlr->p_appdir[0] = '\0'; /* by default, no application directory */ /* if not rlr then initialize his stack pointer */ if (i != 0) rlr->p_uda->u_spsuper = &rlr->p_uda->u_supstk; rlr->p_pid = i; rlr->p_stat = 0; } curpid = 0; rlr->p_pid = curpid++; rlr->p_link = NULLPTR; /* end of process init */ /* restart the tick */ sti(); /* * screen manager process init. this process starts out owning the mouse * and the keyboard. it has a pid == 1 */ gl_dacnt = 0; gl_mowner = ctl_pd = iprocess("SCRENMGR", ctlmgr); /* load gem resource and fix it up before we go */ gem_rsc_init(); { /* get mice forms */ ad_armice = *(LONG *)&rs_bitblk[MICE00]; ad_hgmice = *(LONG *)&rs_bitblk[MICE02]; /* init button stuff */ gl_btrue = 0x0; gl_bdesired = 0x0; gl_bdely = 0x0; gl_bclick = 0x0; gl_logdrv = dos_gdrv() + 'A'; /* boot directory */ gsx_init(); /* do gsx open work station */ /* load all desk acc's */ if (totpds > 2) ldaccs(); /* fix up icons */ for(i=0; i<3; i++) { tmpadbi = &rs_bitblk[NOTEBB+i]; memcpy((char *)&bi, tmpadbi, sizeof(BITBLK)); gsx_trans(bi.bi_pdata, bi.bi_wb, bi.bi_pdata, bi.bi_wb, bi.bi_hl); } /* take the critical err handler int. */ cli(); takeerr(); sti(); /* go into graphic mode */ sh_tographic(); /* take the tick int. */ cli(); gl_ticktime = gsx_tick(tikaddr, &tiksav); sti(); /* set init. click rate: must do this after setting gl_ticktime */ ev_dclick(3, TRUE); /* fix up the GEM rsc. file now that we have an open WS */ gem_rsc_fixit(); /* get st_desk ptr */ ad_stdesk = (LONG) rs_trees[DESKTOP]; /* init. window vars. */ wm_start(); /* startup gem libs */ fs_start(); /* remember current desktop directory */ sh_curdir(D.s_cdir); /* process emudesk.inf part 2 */ process_inf2(); /* off we go !!! */ dsptch(); /* let them run */ all_run(); /* * init for shell loop up thru here it is okay for system to * overlay this initialization code */ sh_init(); /* * main shell loop. From here on down data should not overlay * this code */ sh_main(); /* give back the tick */ cli(); gl_ticktime = gsx_tick(tiksav, &tiksav); sti(); /* close workstation */ gsx_wsclose(); } /* return GEM's 0xEF int*/ cli(); givecpm(); sti(); }
void gem_main(void) { WORD i; sh_rdinf(); /* get start of emudesk.inf */ if (!gl_changerez) /* can't be here because of rez change, */ process_inf1(); /* so see if .inf says we need to change rez */ if (gl_changerez) { switch(gl_changerez) { #if CONF_WITH_ATARI_VIDEO case 1: /* ST(e) or TT display */ Setscreen(-1L,-1L,gl_nextrez-2,0); initialise_palette_registers(gl_nextrez-2,0); break; #endif #if CONF_WITH_VIDEL case 2: /* Falcon display */ Setscreen(-1L, -1L, FALCON_REZ, gl_nextrez); initialise_palette_registers(FALCON_REZ,gl_nextrez); break; #endif } gsx_wsclear(); /* avoid artefacts that may show briefly */ /* * resolution change always resets the default drive to the * boot device. TOS3 issues a Dsetdrv() when this happens, * which Hatari's GEMDOS drive emulation uses to keep track * of the current drive. we do the same. */ dos_sdrv(bootdev); } ml_ocnt = 0; gl_changerez = FALSE; mn_init(); /* initialise variables for menu_register() */ num_accs = count_accs(); /* puts ACC names in acc_name[] */ D.g_acc = NULL; if (num_accs) D.g_acc = dos_alloc(num_accs*sizeof(AESPROCESS)); if (D.g_acc) memset(D.g_acc,0x00,num_accs*sizeof(AESPROCESS)); else num_accs = 0; totpds = num_accs + 2; disable_interrupts(); set_aestrap(); /* set trap#2 -> aestrap */ /* init event recorder */ gl_recd = FALSE; gl_rlen = 0; gl_rbuf = NULL; /* link up all the evb's to the event unused list */ eul = NULL; for (i = 0; i < 2; i++) ev_init(D.g_int[i].a_evb,EVBS_PER_PD); for (i = 0; i < num_accs; i++) ev_init(D.g_acc[i].a_evb,EVBS_PER_PD); /* initialize sync blocks */ wind_spb.sy_tas = 0; wind_spb.sy_owner = NULL; wind_spb.sy_wait = 0; /* * init processes - TODO: should go in gempd or gemdisp. */ /* initialize list and unused lists */ nrl = drl = NULL; dlr = zlr = NULL; fph = fpt = fpcnt = 0; /* init initial process */ for(i=totpds-1; i>=0; i--) { rlr = pd_index(i); if (i < 2) { rlr->p_uda = &D.g_int[i].a_uda; rlr->p_cda = &D.g_int[i].a_cda; } else { rlr->p_uda = &D.g_acc[i-2].a_uda; rlr->p_cda = &D.g_acc[i-2].a_cda; } rlr->p_qaddr = rlr->p_queue; rlr->p_qindex = 0; memset(rlr->p_name, ' ', AP_NAMELEN); rlr->p_appdir[0] = '\0'; /* by default, no application directory */ /* if not rlr then initialize his stack pointer */ if (i != 0) rlr->p_uda->u_spsuper = &rlr->p_uda->u_supstk; rlr->p_pid = i; rlr->p_stat = 0; } curpid = 0; rlr->p_pid = curpid++; rlr->p_link = NULL; /* end of process init */ /* restart the tick */ enable_interrupts(); /* * screen manager process init. this process starts out owning the mouse * and the keyboard. it has a pid == 1 */ gl_mowner = ctl_pd = iprocess("SCRENMGR", ctlmgr); /* * run the accessories and the desktop until termination * (for shutdown or resolution change) */ aes_run_rom_program(accdesk_start); /* restore previous trap#2 address */ disable_interrupts(); unset_aestrap(); enable_interrupts(); if (D.g_acc) dos_free((LONG)D.g_acc); }
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; }
/* * Set up screen for VT52. * This is called by os_askfile to restore the screen to the normal * state, so it shouldn't allocate data structures. */ vt_setup() { int i; /* * Get rid of the mouse */ graf_mouse(M_OFF, NULL); /* * Get desktop resolution. If monochrome, note the fact so that * we can make sure our color choices get set correctly later on. * If low resolution, change to medium resolution automagically. * * If any other resolution, don't do anything different, and hope * things work out OK. */ drez = Getrez(); if (drez == 0) Setscreen(-1L, -1L, 1); if (drez != 2) { /* * Get desktop palette. */ for (i = 0; i < 16; i++) dpalette[i] = Setcolor(i, -1); /* * Set our palette. */ Setpalette(palette); /* * Tell the rest of the system what good colors * are for various things. */ sdesc_color = colbyte(osWHITE, osBLUE); ldesc_color = colbyte(osBLACK, osWHITE); debug_color = colbyte(osBRIGHTWHITE, osBLACK); text_color = colbyte(osWHITE, osBLACK); text_bold_color = colbyte(osBRIGHTWHITE, osBLACK); text_normal_color = text_color; } else { /* * Monochrome -- note different color name constants */ sdesc_color = colbyte(osmREVERSE, osmREVERSE); ldesc_color = colbyte(osmREVERSE, osmREVERSE); debug_color = colbyte(osmNORMAL, osmNORMAL); text_color = colbyte(osmNORMAL, osmNORMAL); text_bold_color = colbyte(osmREVERSE, osmREVERSE); text_normal_color = text_color; } /* * Set default text color */ vt_color(text_color); /* * Clear the screen, set to no-wrap mode, and enable cursor. * Also, set drawing colors to normal. */ Cconws("\033E\033w\033e"); X = 0; Y = 0; /* * Make the cursor not blink. */ Cursconf(2, 0); }