// C Source File // Created 1/4/2003; 3:06:59 PM #define USE_TI89 // Compile for TI-89 #define USE_TI92PLUS // Compile for TI-92 Plus #define USE_V200 // Compile for V200 #define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization #define SAVE_SCREEN // Save/Restore LCD Contents #include // Include All Header Files #include "extgraph.h" //------------------------------------------------------------------ // returns pointer to start of external variable which name is given // by fname. // if variable cannot be found NULL is returned // // NOTE: this routine internally locks the variable. Due to the fact // that the variable has to be unlocked again if you don't // need it anymore, it uses the given pointer to a HANDLE // to store the handle of the locked variable in it. //------------------------------------------------------------------ unsigned char* GetPointerToFile(SYM_STR fname,HANDLE* h) { SYM_ENTRY* symptr; unsigned char* src; if ((symptr = DerefSym(SymFind(fname)))) { *h = symptr->handle; if (!(src = (unsigned char*)HLock(*h))) return NULL; src+=2; return src; } else { return NULL; } } BOOL isArchived (SYM_STR filestr) { SYM_ENTRY *symptr; symptr = SymFindPtr (filestr, 0); if (symptr->flags.bits.archived == 1) return 1; return 0; } void handleStdMemError(const char * const name, const char * const specific, short *error) { FontSetSys(F_4x6); printf_xy(0,50,"OUT OF MEMORY-Couldn't finish %s!",name); printf_xy(0,60,"Free more %s.",specific); DrawStr(0,70,"Press a key.",A_NORMAL); (*error)++; ngetchx(); } #define FILE_COUNT 2 const char * const ARCHIVE_STRING = "*Archive/Flash ROM*"; const char * const RAM_STRING = "*RAM*"; // Main Function void _main(void) { HANDLE h; unsigned char* src; short idx; char fullname[30]; char spaces[] = " "; short error=0; unsigned short t; const char * const n[FILE_COUNT] = {"oblvall1","oblvall2"}; SYM_STR s[FILE_COUNT] = {SYMSTR(n[0]),SYMSTR(n[1])}; clrscr(); FontSetSys(F_4x6); printf("OBLIVION Installer - Malcolm Smith\n"); printf("Press any key to begin installation.\n"); printf("Press Enter/OK to any boxes that pop up.\n"); ngetchx(); for(idx=0;idxname; unsigned short size_of_entry = ttarchive_desc(src,i)->length; unsigned char* decompressed; FontSetSys(F_4x6); printf_xy(0,85,"Extracting %s%s",name,spaces); //----------------------------------------------------------------------- // Now we have a pointer to the entry and we know how large this entry is // If the entry is compressed we could easily decompress it like this: //----------------------------------------------------------------------- if (ttunpack_valid(pointer_to_entry)) { // this entry is compressed ... size_of_entry = ttunpack_size(pointer_to_entry); if ((decompressed = malloc(size_of_entry))) { FontSetSys(F_4x6); printf_xy(100,85,"[%u bytes]%s",size_of_entry,spaces); if (ttunpack_decompress(pointer_to_entry,decompressed) == TTUNPACK_OKAY) { //--------------------------------- // entry successfully decompressed. //--------------------------------- sprintf(fullname,"oblivion\\%s",name); FILE *f = fopen(fullname,"wb"); if(f) { t = fwrite(decompressed,sizeof(BYTE),size_of_entry,f); if(t!=size_of_entry) handleStdMemError(name,RAM_STRING,&error); fclose(f); if(!EM_moveSymToExtMem(SYMSTR(fullname),HS_NULL)) { handleStdMemError(name,ARCHIVE_STRING,&error); } } } free(decompressed); // free allocated memory for decompressed entry again } else { handleStdMemError(name,RAM_STRING,&error); } } else { //File is not compressed } } } HeapUnlock(h); // unlock variable again .... } } FontSetSys(F_4x6); memset(LCD_MEM+30*30,0,70*30); if(!error) { DrawStr(0,40,"Installation Successful!",A_NORMAL); for(idx=0;idx