int WinX68k_Reset(void) { OPM_Reset(); #ifdef CYCLONE m68000_reset(); m68000_set_reg(M68K_A7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]); m68000_set_reg(M68K_PC, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]); #else C68k_Reset(&C68K); /* C68k_Set_Reg(&C68K, C68K_A7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]); C68k_Set_Reg(&C68K, C68K_PC, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]); */ C68k_Set_AReg(&C68K, 7, (IPL[0x30001]<<24)|(IPL[0x30000]<<16)|(IPL[0x30003]<<8)|IPL[0x30002]); C68k_Set_PC(&C68K, (IPL[0x30005]<<24)|(IPL[0x30004]<<16)|(IPL[0x30007]<<8)|IPL[0x30006]); #endif Memory_Init(); CRTC_Init(); DMA_Init(); MFP_Init(); FDC_Init(); FDD_Reset(); SASI_Init(); SCSI_Init(); IOC_Init(); SCC_Init(); PIA_Init(); RTC_Init(); TVRAM_Init(); GVRAM_Init(); BG_Init(); Pal_Init(); IRQH_Init(); MIDI_Init(); //WinDrv_Init(); //C68K.ICount = 0; m68000_ICountBk = 0; ICount = 0; DSound_Stop(); SRAM_VirusCheck(); //CDROM_Init(); DSound_Play(); return TRUE; }
void Ball_Sound(void) { // this functions hunts for an open handle to play a collision sound // start a hit sound for (int sound_index=0; sound_index < 8; sound_index++) { // test if this sound is playing if (DSound_Status_Sound(ball_ids[sound_index])==0) { DSound_Play(ball_ids[sound_index]); break; } // end if } // end for } // end Ball_Sound
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game int index; // looping var // start up DirectDraw (replace the parms as you desire) DDraw_Init2(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP,0); // initialize directinput DInput_Init(); // acquire the keyboard DInput_Init_Keyboard(); // add calls to acquire other directinput devices here... // initialize directsound and directmusic DSound_Init(); DMusic_Init(); // hide the mouse if (!WINDOWED_APP) ShowCursor(FALSE); // seed random number generator srand(Start_Clock()); Open_Error_File("MD2ERROR.TXT"); // initialize math engine Build_Sin_Cos_Tables(); // initialize the camera with 90 FOV, normalized coordinates Init_CAM4DV1(&cam, // the camera object CAM_MODEL_EULER, // the euler model &cam_pos, // initial camera position &cam_dir, // initial camera angles &cam_target, // no target 10.0, // near and far clipping planes 12000.0, 90.0, // field of view in degrees WINDOW_WIDTH, // size of final screen viewport WINDOW_HEIGHT); VECTOR4D terrain_pos = {0,0,0,0}; Generate_Terrain_OBJECT4DV2(&obj_terrain, // pointer to object TERRAIN_WIDTH, // width in world coords on x-axis TERRAIN_HEIGHT, // height (length) in world coords on z-axis TERRAIN_SCALE, // vertical scale of terrain "height_grass_40_40_01.bmp", // filename of height bitmap encoded in 256 colors "stone256_256_01.bmp", // "grass256_256_01.bmp", //"checker2562562.bmp", // filename of texture map RGB16Bit(255,255,255), // color of terrain if no texture &terrain_pos, // initial position NULL, // initial rotations POLY4DV2_ATTR_RGB16 //| POLY4DV2_ATTR_SHADE_MODE_FLAT | POLY4DV2_ATTR_SHADE_MODE_GOURAUD | POLY4DV2_ATTR_SHADE_MODE_TEXTURE); // set a scaling vector VECTOR4D_INITXYZ(&vscale, 20, 20, 20); // load all the light objects in for (int index_obj=0; index_obj < NUM_LIGHT_OBJECTS; index_obj++) { Load_OBJECT4DV2_COB2(&obj_light_array[index_obj], object_light_filenames[index_obj], &vscale, &vpos, &vrot, VERTEX_FLAGS_INVERT_WINDING_ORDER | VERTEX_FLAGS_TRANSFORM_LOCAL | VERTEX_FLAGS_TRANSFORM_LOCAL_WORLD ,0 ); } // end for index // set current object curr_light_object = 0; obj_light = &obj_light_array[curr_light_object]; // set up lights Reset_Lights_LIGHTV2(lights2, MAX_LIGHTS); // create some working colors white.rgba = _RGBA32BIT(255,255,255,0); gray.rgba = _RGBA32BIT(100,100,100,0); black.rgba = _RGBA32BIT(0,0,0,0); red.rgba = _RGBA32BIT(255,0,0,0); green.rgba = _RGBA32BIT(0,255,0,0); blue.rgba = _RGBA32BIT(0,0,255,0); orange.rgba = _RGBA32BIT(255,128,0,0); yellow.rgba = _RGBA32BIT(255,255,0,0); // ambient light Init_Light_LIGHTV2(lights2, AMBIENT_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_AMBIENT, // ambient light type gray, black, black, // color for ambient term only NULL, NULL, // no need for pos or dir 0,0,0, // no need for attenuation 0,0,0); // spotlight info NA VECTOR4D dlight_dir = {-1,1,-1,1}; // directional light Init_Light_LIGHTV2(lights2, INFINITE_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_INFINITE, // infinite light type black, gray, black, // color for diffuse term only NULL, &dlight_dir, // need direction only 0,0,0, // no need for attenuation 0,0,0); // spotlight info NA VECTOR4D plight_pos = {0,500,0,1}; // point light Init_Light_LIGHTV2(lights2, POINT_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_POINT, // pointlight type black, orange, black, // color for diffuse term only &plight_pos, NULL, // need pos only 0,.001,0, // linear attenuation only 0,0,1); // spotlight info NA // point light Init_Light_LIGHTV2(lights2, POINT_LIGHT2_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_POINT, // pointlight type black, yellow, black, // color for diffuse term only &plight_pos, NULL, // need pos only 0,.002,0, // linear attenuation only 0,0,1); // spotlight info NA VECTOR4D slight2_pos = {0,200,0,1}; VECTOR4D slight2_dir = {-1,1,-1,1}; // create lookup for lighting engine RGB_16_8_IndexedRGB_Table_Builder(DD_PIXEL_FORMAT565, // format we want to build table for palette, // source palette rgblookup); // lookup table // create the z buffer Create_Zbuffer(&zbuffer, WINDOW_WIDTH, WINDOW_HEIGHT, ZBUFFER_ATTR_32BIT); // build alpha lookup table RGB_Alpha_Table_Builder(NUM_ALPHA_LEVELS, rgb_alpha_table); // load background sounds wind_sound_id = DSound_Load_WAV("STATIONTHROB.WAV"); // start the sounds DSound_Play(wind_sound_id, DSBPLAY_LOOPING); DSound_Set_Volume(wind_sound_id, 100); #if 0 // load in the cockpit image Create_BOB(&cockpit, 0,0,800,600,2, BOB_ATTR_VISIBLE | BOB_ATTR_SINGLE_FRAME, DDSCAPS_SYSTEMMEMORY, 0, 16); Load_Bitmap_File(&bitmap16bit, "lego02.BMP"); Load_Frame_BOB16(&cockpit, &bitmap16bit,0,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); Load_Bitmap_File(&bitmap16bit, "lego02b.BMP"); Load_Frame_BOB16(&cockpit, &bitmap16bit,1,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); #endif // load background image that scrolls Load_Bitmap_File(&bitmap16bit, "sunset800_600_03.bmp"); Create_Bitmap(&background_bmp,0,0,800,600,16); Load_Image_Bitmap16(&background_bmp, &bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); static VECTOR4D vs = {4,4,4,1}; static VECTOR4D vp = {0,0,0,1}; // load the md2 object Load_Object_MD2(&obj_md2, // the loaded md2 file placed in container "./md2/q2mdl-tekkblade/tris.md2", // "D:/Games/quakeII/baseq2/players/male/tris.md2", // the filename of the .MD2 model &vs, &vp, NULL, "./md2/q2mdl-tekkblade/blade_black.bmp", //"D:/Games/quakeII/baseq2/players/male/claymore.bmp", // the texture filename for the model POLY4DV2_ATTR_RGB16 | POLY4DV2_ATTR_SHADE_MODE_FLAT | POLY4DV2_ATTR_SHADE_MODE_TEXTURE, RGB16Bit(255,255,255), VERTEX_FLAGS_SWAP_YZ); // control ordering etc. // prepare OBJECT4DV2 for md2 Prepare_OBJECT4DV2_For_MD2(&obj_model, // pointer to destination object &obj_md2); // md2 object to extract frame from // set the animation Set_Animation_MD2(&obj_md2,MD2_ANIM_STATE_STANDING_IDLE, MD2_ANIM_LOOP); #if 0 // play with these for more speed :) // set single precission _control87( _PC_24, _MCW_PC ); // set to flush mode _control87( _DN_FLUSH, _MCW_DN ); // set rounding mode _control87( _RC_NEAR, _MCW_RC ); #endif // return success return(1); } // end Game_Init
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game int index; // looping varsIable char filename[80]; // used to build up filenames // seed random number generate srand(Start_Clock()); // initialize directdraw, very important that in the call // to setcooperativelevel that the flag DDSCL_MULTITHREADED is used // which increases the response of directX graphics to // take the global critical section more frequently DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP); // load background image Load_Bitmap_File(&bitmap16bit, "LAVA24.BMP"); Create_Bitmap(&background_bmp,0,0,640,480,16); Load_Image_Bitmap16(&background_bmp, &bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); // load the bitmaps Load_Bitmap_File(&bitmap16bit, "LAVASHIP24.BMP"); // create ship Create_BOB(&ship,0,0,80,32,2,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16); // load the imagery in for (index=0; index < 2; index++) Load_Frame_BOB16(&ship, &bitmap16bit, index, index,0,BITMAP_EXTRACT_MODE_CELL); // unload bitmap image Unload_Bitmap_File(&bitmap16bit); // position the ship to left of screen // use element 0,1 to hold float accurate position ship.varsF[SHIP_X_POS] = 0; ship.varsF[SHIP_Y_POS] = screen_height/2; // use index 2 to hold x velocity ship.varsF[SHIP_X_VEL] = SHIP_INITIAL_VELOCITY; // hide the mouse if (!WINDOWED_APP) ShowCursor(FALSE); // initialize directinput DInput_Init(); // acquire the keyboard only DInput_Init_Keyboard(); // initilize DirectSound DSound_Init(); // load background sounds engine_id = DSound_Load_WAV("PULSAR.WAV"); // start the sounds DSound_Play(engine_id, DSBPLAY_LOOPING); // return success return(1); } // end Game_Init
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game int index; // looping var // start up DirectDraw (replace the parms as you desire) DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP); // initialize directinput DInput_Init(); // acquire the keyboard DInput_Init_Keyboard(); // add calls to acquire other directinput devices here... // initialize directsound and directmusic DSound_Init(); DMusic_Init(); // hide the mouse if (!WINDOWED_APP) ShowCursor(FALSE); // seed random number generator srand(Start_Clock()); Open_Error_File("ERROR.TXT"); // initialize math engine Build_Sin_Cos_Tables(); // initialize the camera with 90 FOV, normalized coordinates Init_CAM4DV1(&cam, // the camera object CAM_MODEL_EULER, // the euler model &cam_pos, // initial camera position &cam_dir, // initial camera angles &cam_target, // no target 40.0, // near and far clipping planes 12000.0, 90.0, // field of view in degrees WINDOW_WIDTH, // size of final screen viewport WINDOW_HEIGHT); VECTOR4D terrain_pos = {0,0,0,0}; Generate_Terrain_OBJECT4DV2(&obj_terrain, // pointer to object TERRAIN_WIDTH, // width in world coords on x-axis TERRAIN_HEIGHT, // height (length) in world coords on z-axis TERRAIN_SCALE, // vertical scale of terrain "checkerheight01.bmp", // filename of height bitmap encoded in 256 colors "checker256256.bmp", // filename of texture map RGB16Bit(255,255,255), // color of terrain if no texture &terrain_pos, // initial position NULL, // initial rotations POLY4DV2_ATTR_RGB16 | POLY4DV2_ATTR_SHADE_MODE_FLAT // | POLY4DV2_ATTR_SHADE_MODE_GOURAUD | POLY4DV2_ATTR_SHADE_MODE_TEXTURE); // the shading attributes we would like // set up lights Reset_Lights_LIGHTV2(lights2, MAX_LIGHTS); // create some working colors white.rgba = _RGBA32BIT(255,255,255,0); gray.rgba = _RGBA32BIT(100,100,100,0); black.rgba = _RGBA32BIT(0,0,0,0); red.rgba = _RGBA32BIT(255,0,0,0); green.rgba = _RGBA32BIT(0,255,0,0); blue.rgba = _RGBA32BIT(0,0,255,0); // ambient light Init_Light_LIGHTV2(lights2, AMBIENT_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_AMBIENT, // ambient light type gray, black, black, // color for ambient term only NULL, NULL, // no need for pos or dir 0,0,0, // no need for attenuation 0,0,0); // spotlight info NA VECTOR4D dlight_dir = {-1,1,-1,1}; // directional light Init_Light_LIGHTV2(lights2, INFINITE_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_INFINITE, // infinite light type black, gray, black, // color for diffuse term only NULL, &dlight_dir, // need direction only 0,0,0, // no need for attenuation 0,0,0); // spotlight info NA VECTOR4D plight_pos = {0,200,0,1}; // point light Init_Light_LIGHTV2(lights2, POINT_LIGHT_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_POINT, // pointlight type black, green, black, // color for diffuse term only &plight_pos, NULL, // need pos only 0,.001,0, // linear attenuation only 0,0,1); // spotlight info NA // point light Init_Light_LIGHTV2(lights2, POINT_LIGHT2_INDEX, LIGHTV2_STATE_ON, // turn the light on LIGHTV2_ATTR_POINT, // pointlight type black, blue, black, // color for diffuse term only &plight_pos, NULL, // need pos only 0,.002,0, // linear attenuation only 0,0,1); // spotlight info NA VECTOR4D slight2_pos = {0,200,0,1}; VECTOR4D slight2_dir = {-1,1,-1,1}; // create lookup for lighting engine RGB_16_8_IndexedRGB_Table_Builder(DD_PIXEL_FORMAT565, // format we want to build table for palette, // source palette rgblookup); // lookup table // create the z buffer Create_Zbuffer(&zbuffer, WINDOW_WIDTH, WINDOW_HEIGHT, ZBUFFER_ATTR_32BIT); // load background sounds wind_sound_id = DSound_Load_WAV("WIND.WAV"); // start the sounds DSound_Play(wind_sound_id, DSBPLAY_LOOPING); DSound_Set_Volume(wind_sound_id, 100); #if 0 // load in the cockpit image Load_Bitmap_File(&bitmap16bit, "lego01.BMP"); Create_BOB(&cockpit, 0,0,800,600,1, BOB_ATTR_VISIBLE | BOB_ATTR_SINGLE_FRAME, DDSCAPS_SYSTEMMEMORY, 0, 16); Load_Frame_BOB16(&cockpit, &bitmap16bit,0,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); #endif // set single precission //_control87( _PC_24, MCW_PC ); // return success return(1); } // end Game_Init
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game int index; // looping variable // initialize directdraw, very important that in the call // to setcooperativelevel that the flag DDSCL_MULTITHREADED is used // which increases the response of directX graphics to // take the global critical section more frequently DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP); // load background image Load_Bitmap_File(&bitmap16bit, "FLYBACK_24.BMP"); Create_Bitmap(&background_bmp,0,0,640,480,16); Load_Image_Bitmap16(&background_bmp, &bitmap16bit,0,0,BITMAP_EXTRACT_MODE_ABS); Unload_Bitmap_File(&bitmap16bit); // load the fly bitmaps Load_Bitmap_File(&bitmap16bit, "FLYS8_24.BMP"); // create master fly bob Create_BOB(&flys[0],320,200, 8,8, 4, BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY, 0, 16); Set_Anim_Speed_BOB(&flys[0], 1); // load the fly in for (index=0; index<4; index++) Load_Frame_BOB16(&flys[0], &bitmap16bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL); // unload flys Unload_Bitmap_File(&bitmap16bit); // now replicate flys for (index = 1; index < MAX_FLYS; index++) Clone_BOB(&flys[0], &flys[index]); // now set all of their values for (index=0; index<MAX_FLYS; index++) { // set positions Set_Pos_BOB(&flys[index], 320-32+rand()%64, 450-rand()%32); // set start frame randomly flys[index].curr_frame = 0; } // end for index // initilize DirectSound DSound_Init(); // load fly sound fly_sound_id = DSound_Load_WAV("FLYS.WAV"); // start the sound DSound_Play(fly_sound_id, DSBPLAY_LOOPING); // return success return(1); } // end Game_Init
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game int index; // looping varsIable char filename[80]; // used to build up filenames // seed random number generate srand(Start_Clock()); // start up DirectDraw (replace the parms as you desire) DDraw_Init(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); // load background image Load_Bitmap_File(&bitmap8bit, "GRAVSKY8.BMP"); Create_Bitmap(&background_bmp,0,0,640,480); Load_Image_Bitmap(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS); Set_Palette(bitmap8bit.palette); Unload_Bitmap_File(&bitmap8bit); // load the bitmaps for ship Load_Bitmap_File(&bitmap8bit, "BLAZE8.BMP"); // create bob Create_BOB(&ship,320,240,22,18,32,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY); // well use varsI[0] to hold the direction 0..15, 0-360 degrees, clockwise ship.varsI[0] = 0; // along +x axis to start // use varsF[0,1] for the x and y velocity ship.varsF[0] = 0; ship.varsF[1] = 0; // use varsF[2,3] for the x and y position, we need more accuracy than ints ship.varsF[2] = ship.x; ship.varsF[3] = ship.y; // load the frames in for (index=0; index < 32; index++) Load_Frame_BOB(&ship, &bitmap8bit, index, index%16,index/16,BITMAP_EXTRACT_MODE_CELL); // unload bitmap image Unload_Bitmap_File(&bitmap8bit); // load the bitmaps for blackhole Load_Bitmap_File(&bitmap8bit, "PHOTON8.BMP"); // create bob Create_BOB(&black_hole,32+rand()%(SCREEN_WIDTH-64),32+rand()%(SCREEN_HEIGHT-64), 44,44,7,BOB_ATTR_MULTI_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY); // set animation speed Set_Anim_Speed_BOB(&black_hole,3); // load the frames in for (index=0; index < 7; index++) Load_Frame_BOB(&black_hole, &bitmap8bit, index, index,0,BITMAP_EXTRACT_MODE_CELL); // unload bitmap image Unload_Bitmap_File(&bitmap8bit); // initialize directinput DInput_Init(); // acquire the keyboard only DInput_Init_Keyboard(); // initilize DirectSound DSound_Init(); // load background sounds sound_id = DSound_Load_WAV("BHOLE.WAV"); // start the sounds DSound_Play(sound_id, DSBPLAY_LOOPING); // set clipping rectangle to screen extents so objects dont // mess up at edges RECT screen_rect = {0,0,screen_width,screen_height}; lpddclipper = DDraw_Attach_Clipper(lpddsback,1,&screen_rect); // hide the mouse ShowCursor(FALSE); // return success return(1); } // end Game_Init