Subversion Repositories Games.Carmageddon

Rev

Rev 18 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "drfile.h"
  2. #include "brender/brender.h"
  3. #include "harness/trace.h"
  4. #include "loading.h"
  5. #include <stdlib.h>
  6.  
  7. br_filesystem gFilesystem = {
  8.     "Carmageddon",
  9.     NULL,
  10.     &DRStdioOpenRead,
  11.     &DRStdioOpenWrite,
  12.     &DRStdioClose,
  13.     NULL,
  14.     NULL,
  15.     NULL,
  16.     &DRStdioRead,
  17.     &DRStdioWrite,
  18.     NULL,
  19.     NULL,
  20.     NULL
  21. };
  22. br_filesystem* gOld_file_system;
  23.  
  24. // IDA: void* __cdecl DRStdioOpenRead(char *name, br_size_t n_magics, br_mode_test_cbfn *identify, int *mode_result)
  25. void* DRStdioOpenRead(char* name, br_size_t n_magics, br_mode_test_cbfn* identify, int* mode_result) {
  26.     if (mode_result != NULL) {
  27.         *mode_result = 0;
  28.     }
  29.     return DRfopen(name, "rb");
  30. }
  31.  
  32. // IDA: void* __cdecl DRStdioOpenWrite(char *name, int mode)
  33. void* DRStdioOpenWrite(char* name, int mode) {
  34.     return gOld_file_system->open_write(name, mode);
  35. }
  36.  
  37. // IDA: void __cdecl DRStdioClose(void *f)
  38. void DRStdioClose(void* f) {
  39.     gOld_file_system->close(f);
  40. }
  41.  
  42. // IDA: br_size_t __cdecl DRStdioRead(void *buf, br_size_t size, unsigned int n, void *f)
  43. br_size_t DRStdioRead(void* buf, br_size_t size, unsigned int n, void* f) {
  44.     //br_size_t result; // Pierre-Marie Baty -- unused variable
  45.     return gOld_file_system->read(buf, size, n, f);
  46. }
  47.  
  48. // IDA: br_size_t __cdecl DRStdioWrite(void *buf, br_size_t size, unsigned int n, void *f)
  49. br_size_t DRStdioWrite(void* buf, br_size_t size, unsigned int n, void* f) {
  50.     //br_size_t result; // Pierre-Marie Baty -- unused variable
  51.     return gOld_file_system->write(buf, size, n, f);
  52. }
  53.  
  54. // IDA: void __cdecl InstallDRFileCalls()
  55. void InstallDRFileCalls(void) {
  56.     br_filesystem* temp_system;
  57.     LOG_TRACE("()");
  58.     temp_system = BrMemAllocate(sizeof(br_filesystem), kMem_temp_fs);
  59.     gOld_file_system = BrFilesystemSet(temp_system);
  60.     gFilesystem.attributes = gOld_file_system->attributes;
  61.     gFilesystem.eof = gOld_file_system->eof;
  62.     gFilesystem.getchr = gOld_file_system->getchr;
  63.     gFilesystem.putchr = gOld_file_system->putchr;
  64.     gFilesystem.getline = gOld_file_system->getline;
  65.     gFilesystem.putline = gOld_file_system->putline;
  66.     gFilesystem.advance = gOld_file_system->advance;
  67.     BrFilesystemSet(&gFilesystem);
  68.     BrMemFree(temp_system);
  69. }
  70.