/*============= OBLIVION ================= A single-player 3D action game Brought to TI 68ks by Malcolm Smith Powered by the FAT engine =========================================*/ //At least on TIGCC v0.95, enabling compressed ROM calls may //cause the pause routine to crash... for some unknown //reason. #define NO_EXIT_SUPPORT #define NO_CALC_DETECT //If editing in the IDE, undefine one AND ONLY ONE of these. //Or you can set one (only) in the Program Options in TIGCC .95+ //#define USE_TI89 //#define USE_TI92PLUS //#define USE_V200 #ifdef USE_TI92PLUS #define display_offsetx (48) #define display_offsety (14) #else #define display_offsetx (0) #define display_offsety (0) #endif //If you enable compressed textures, the game takes up even more RAM, //possibly more than you can free. //#define COMPRESSED_TEXTURES //Oblivion includes experimental in-game music: to enable it, //uncomment the following line... //#define USE_SOUND #include "includes.h" char *gamefolder; void _main(void) { char lcd[3840]; short result; short oldx,oldy; short choice; TEXCONFIG _sprites_s[TOTAL_TEXCONFIGS_IN_oblvgfx2]; TEXCONFIG _projectilemodels[TOTAL_TEXCONFIGS_IN_oblvgfx3]; TEXCONFIG _enemysprites[TOTAL_TEXCONFIGS_IN_oblvgfx4]; FATSPRITE _sprites[MAX_SPRITES+MAX_PROJECTILES]; ProjectileStruct _projectiles[MAX_PROJECTILES]; SpriteStruct _sprites_extra[MAX_SPRITES]; FATCONFIG lfc; if(!InitGlobals(lcd)) QuitBecauseOfMemory(); SetGlobalPointers(); #ifdef DEBUG alloc_mem = 0; #endif // Checks the calculator hardware version short *hwptr; hwptr = (short *) FL_getHardwareParmBlock(); gg->HW2 = (*hwptr)!=20 && !IsVTI(); FastCopyScreen(LCD_MEM,lcd); LoadFatEngineOrExit(); if(!AllocateMemory()) QuitBecauseOfMemory(); SetupFC(lfc); if(!LoadGraphicsFiles()) QuitBecauseOfGFX(); if(!LoadDataFiles()) QuitBecauseOfData(); randomize_long(); InstallDummyHandlerForINTs(); #ifdef USE_SOUND USE_GRAY_WITH_POLYSND; #endif if (!GrayOn()) QuitBecauseOfMemory(); gg->plane1 = GetPlane(0); gg->plane2 = GetPlane(1); SetUpCalculatorScreen(); LoadConfig(); TransparentAutoLoad(); ResetWeapons(); OSContrastDn(); if(gg->HW2) OSContrastDn(); Intro(); FAT_SetHUD(gg->HUDlight,gg->HUDdark,gg->HUDmask); FAT_SetPreHUDCallback (PreHUDCallback); //The following tasks will be repeated until the game is quit, // thru the menu or by pressing ESC. while(1) { PrepMenu(); choice = domenu(28+display_offsetx,25+display_offsety,NULL,MENUCHOICES,0,choices); //if(choice==0) /* Play Game! */; if(choice==1) { PromptToResetProgress(); continue; } if(choice == 2) { ProcessTextScrolling(story); continue; } if(choice == 3) //Options { char o[OPTIONS][27]; char *o2[OPTIONS]; //For a copy of Options short a; for(a=0;acfg.intro?"1":"0"); choice = domenu(28+display_offsetx,25+display_offsety,o2,OPTIONS,0,-1); if(choice==0) { gg->cfg.intro = !gg->cfg.intro; continue; } if(choice==1) { ConfigureGameKeys(); continue; } break; } continue; } if(choice == 4) { break; //Quitting } if(!gg->loadmid) //New Game { PrepMenu(); gg->difficulty = domenu(28+display_offsetx,25+display_offsety,NULL,DIFFICULTIES,0, difficulties); if(gg->difficulty==4) continue; else gg->difficulty++; } OSContrastUp(); if(gg->HW2) OSContrastUp(); //The following tasks will be repeated for each level. while(1) { InitPreLevel(); LoadExternalLevel(); if(gg->quitting==END_OF_GAME) { gg->quitting = FALSE; gg->current_level--; gg->loadbeginning = TRUE; break; } QuitIfNecessary(); #ifdef COMPRESSED_TEXTURES LoadLevelTextures(); QuitIfNecessary(); #else HandleLevelTextures(); #endif { lev = gg->current_level; do { lev--; } while(lev && #include "noprevlevels.txt" ); } ResetHUD(); SetupCrosshair(); SetUpCeilingAndFloor(); SetupSpawnPoint(); QuitIfNecessary(); InitForLevel(); InitWeapons(); FAT_SetPredrawCallback(Predraw_LightEffects); if(!gg->old_level && !gg->loadmid) RunPreLevelTasks(); if(!gg->loadmid) AdjustLevelSettings(); InitAnimatedWalls(); SpawnSprites(); InitButtons(); CreateDoors(); if(gg->loadbeginning) { TransparentAutoRefreshBeginning(); //Puts the oblvsave data back to gamedata gg->loadbeginning = FALSE; } if(gg->loadmid) { if(gg->current_level != gg->load_data->mid.current_level) { gg->current_level = gg->load_data->mid.current_level; continue; //Go back up, and re-init everything for the right level } TransparentAutoRefreshMid(); //Puts the oblvsave data back to gamedata gg->loadmid = FALSE; } else TransparentAutoSaveBeginning(); InitGUI(); SaveCoords(); gg->old_level = FALSE; gg->oldPlayer.life = !gg->player.life; gg->oldPlayer.armor = !gg->player.armor; gg->oldAmmo = !weapons[gg->cur_weapon].ammo; DisplayGUI(); //Dissolves back into the 3D world gg->marquee_time = 0; #ifdef USE_SOUND pSnd_EnableSound (); pSnd_InstallSound (); pSnd_PlayMode (MONO); pSnd_SetTempo(MUSIC_TEMPO); //pSnd_PlaySound_voice1 (channel1); pSnd_PlaySound_voice1 (channel2); pSnd_SetState (VOICE1); #endif //---------------------------------------------------------------- // the main rendering loop ... //---------------------------------------------------------------- do { contrast(); HandleEvents(); HandlePressedButtons(); HandleDoors(); HandleWeapons(); HandleProjectiles(); lfc.nr_sprites = gg->sprite_count + gg->projectile_count; AnimateStaticSprites(); SpritesExecute(); CheckForSpriteCollisions(); AnimateWalls(); FAT_Render(fc); UpdateCounters(); textDisplayAndCycle(); if(!HandlePlayerMovement()) break; if(CoordsChanged || gg->turning) CycleCeilFloor(); #ifdef USE_SOUND if(!pSnd_VoiceState()) { pSnd_PlayMode (MONO); pSnd_SetTempo(MUSIC_TEMPO); //pSnd_PlaySound_voice1 (channel1); pSnd_PlaySound_voice1 (channel2); pSnd_SetState (VOICE1); } #endif SaveCoords(); gg->marquee_time++; } while(!gg->quitting); #ifdef USE_SOUND pSnd_UninstallSound (); pSnd_DisableSound (); #endif ResetMarquee(); if(gg->quitting == NEW_LEVEL) { RunPostLevelTasks(); gg->current_level++; gg->quitting = FALSE; FAT_RemoveAllDoors(); #ifdef COMPRESSED_TEXTURES ResetTexSpace(); #endif //FreeLevel(); continue; } if(gg->quitting == OLD_LEVEL) { gg->current_level--; gg->old_level = TRUE; gg->quitting = FALSE; FAT_RemoveAllDoors(); #ifdef COMPRESSED_TEXTURES ResetTexSpace(); #endif //FreeLevel(); continue; } if(gg->quitting == LOAD_SAVE) { gg->quitting = FALSE; gg->loadmid = TRUE; FAT_RemoveAllDoors(); #ifdef COMPRESSED_TEXTURES ResetTexSpace(); #endif continue; } if(gg->quitting == PLAYER_DIED) { BlackGrayScreen2B(gg->BGlight,gg->BGdark); dissolveGSFromTo(gg->BGlight,gg->BGdark,gg->plane1,gg->plane2); DrawGrayStrExt(display_offsetx,40+display_offsety, stringIdx(gamestrings,eLoadWhenGameStarts),A_REVERSE,F_4x6); DrawGrayStrExt(display_offsetx,50+display_offsety, stringIdx(gamestrings,eToLoadMidSave),A_REVERSE,F_4x6); unsigned long count = int5_counter; while(int5_counter < count+20); gg->loadbeginning = TRUE; ResetMarquee(); gg->quitting = FALSE; gg->turning = FALSE; gg->chgbutton_flag = FALSE; gg->shoot_flag = FALSE; gg->speedup_flag = FALSE; FAT_RemoveAllDoors(); #ifdef COMPRESSED_TEXTURES ResetTexSpace(); #endif continue; } TransparentAutoSaveMid(); FAT_RemoveAllDoors(); #ifdef COMPRESSED_TEXTURES ResetTexSpace(); #endif gg->loadmid = TRUE; if(gg->quitting == FORCE_QUIT) break; break; }//END each level BREAK FAT_AllKeysReleased(); OSContrastDn(); if(gg->HW2) OSContrastDn(); if(gg->quitting == FORCE_QUIT) break; }//END menu BREAK OSContrastUp(); if(gg->HW2) OSContrastUp(); ending: FAT_AllKeysReleased(); CleanAndFree(); OSqclear(kbd_queue()); }