static void CLISeek( dw_sectnum sect, long offs, uint type ) { /******************************************************/ section_data *cur_sec; long temp; // int typ; long new_off; new_off = 0; cur_sec = &Sections[sect]; switch( type ) { case DW_SEEK_CUR: new_off = cur_sec->cur_offset + offs; // typ = SEEK_CUR; break; case DW_SEEK_SET: new_off = offs; // typ = SEEK_SET; break; case DW_SEEK_END: new_off = Sections[ sect ].max_offset - offs; // typ = SEEK_END; break; } if ( cur_sec->sec_type == MEM_SECTION ) { if ( cur_sec->max_offset < new_off ) { temp = new_off - cur_sec->max_offset; cur_sec->cur_offset = cur_sec->max_offset; CLIZeroWrite( sect, temp ); } } else if ( cur_sec->sec_type == FILE_SECTION ) { if ( !( cur_sec->u1.fp ) ) { CLIZeroWrite( sect, offs ); } else { if ( cur_sec->max_offset < new_off ) { SDSeek( cur_sec->u1.fp, cur_sec->max_offset, 1 ); chkIOErr( cur_sec->u1.fp, SM_IO_READ_ERR, "temporary file" ); cur_sec->cur_offset = cur_sec->max_offset; temp = new_off - cur_sec->max_offset; CLIZeroWrite( sect, temp ); } else { SDSeek( cur_sec->u1.fp, new_off, 1 ); chkIOErr( cur_sec->u1.fp, SM_IO_READ_ERR, "temporary file" ); } } } else { CLIZeroWrite( sect, offs ); } cur_sec->cur_offset = new_off; }
static void DumpCurrPage( void ) { //==================================== // Dump current page to disk. if( PageFlags & PF_DIRTY ) { if( CurrPage > MaxPage ) { MaxPage = CurrPage; } SDSeek( PageFile, CurrPage, PAGE_SIZE ); ChkIOErr( PageFile, SM_IO_WRITE_ERR ); SDWrite( PageFile, ObjCode, PAGE_SIZE ); ChkIOErr( PageFile, SM_IO_WRITE_ERR ); PageFlags &= ~PF_DIRTY; } }
static void LoadPage( unsigned_16 page ) { //============================================ // Load a page into memory. if( page != CurrPage ) { DumpCurrPage(); SDSeek( PageFile, page, PAGE_SIZE ); ChkIOErr( PageFile, SM_IO_READ_ERR ); SDRead( PageFile, ObjCode, PAGE_SIZE ); // If we seek to the end of the last page in the disk // file (which is the start of a non-existent page file), // we will get end-of-file when we do the read. if( !SDEof( PageFile ) ) { ChkIOErr( PageFile, SM_IO_READ_ERR ); } CurrPage = page; PageFlags = PF_INIT; } }