Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.21 KB | None | 0 0
  1. #include "plugin.h"
  2. #include "gob.h"
  3.  
  4.  
  5. void *util_alloc(size_t sz);
  6.  
  7. enum plugin_status plugin_start(const void* parameter)
  8. {
  9.     /*TODO this is a temporary warning suppressor for parameter, which is not yet used*/
  10.     (void)parameter;
  11.     #ifdef HAVE_ADJUSTABLE_CPU_FREQ
  12.     rb->cpu_boost(true);
  13.     #endif
  14.  
  15.     /*read in the gob files indexes to one big index*/
  16.     int dark_file = rb->open("/.rockbox/dark/DARK.GOB", O_RDONLY);
  17.     int sprites_file = rb->open("/.rockbox/dark/SPRITES.GOB", O_RDONLY);
  18.     int tex_file = rb->open("/.rockbox/dark/TEXTURES.GOB", O_RDONLY);
  19.     int sound_file = rb->open("/.rockbox/dark/SOUNDS.GOB", O_RDONLY);
  20.  
  21.     struct gob_header current_header;
  22.     uint32_t current_mastern, total_mastern = 0, ofs_mastern;
  23.  
  24.     /*get the total number of ix entries*/
  25.     rb->read(dark_file, &current_header, sizeof(struct gob_header));
  26.     rb->lseek(dark_file, current_header.MASTERX, SEEK_SET);
  27.     rb->read(dark_file, &current_mastern, sizeof(uint32_t));
  28.     total_mastern += current_mastern;
  29.     rb->read(sprites_file, &current_header, sizeof(struct gob_header));
  30.     rb->lseek(sprites_file, current_header.MASTERX, SEEK_SET);
  31.     rb->read(sprites_file, &current_mastern, sizeof(uint32_t));
  32.     total_mastern += current_mastern;
  33.     rb->read(tex_file, &current_header, sizeof(struct gob_header));
  34.     rb->lseek(tex_file, current_header.MASTERX, SEEK_SET);
  35.     rb->read(tex_file, &current_mastern, sizeof(uint32_t));
  36.     total_mastern += current_mastern;
  37.     rb->read(sound_file, &current_header, sizeof(struct gob_header));
  38.     rb->lseek(sound_file, current_header.MASTERX, SEEK_SET);
  39.     rb->read(sound_file, &current_mastern, sizeof(uint32_t));
  40.     total_mastern += current_mastern;
  41.  
  42.     /*allocate the idx struct array*/
  43.     struct gob_idx_entry* idx = util_alloc(sizeof(struct gob_idx_entry) * total_mastern);
  44.  
  45.     /*and then read the idx portion of the files into the idx struct array*/
  46.     rb->read(dark_file, &current_header, sizeof(struct gob_header));
  47.     rb->lseek(dark_file, current_header.MASTERX, SEEK_SET);
  48.     rb->read(dark_file, &current_mastern, sizeof(uint32_t));
  49.     rb->read(dark_file, &idx[0], sizeof(struct gob_idx_entry) * current_mastern);
  50.     ofs_mastern = current_mastern;
  51.     rb->read(sprites_file, &current_header, sizeof(struct gob_header));
  52.     rb->lseek(sprites_file, current_header.MASTERX, SEEK_SET);
  53.     rb->read(sprites_file, &current_mastern, sizeof(uint32_t));
  54.     rb->read(dark_file, &idx[ofs_mastern], sizeof(struct gob_idx_entry) * current_mastern);
  55.     ofs_mastern = current_mastern;
  56.     rb->read(sprites_file, &current_header, sizeof(struct gob_header));
  57.     rb->lseek(sprites_file, current_header.MASTERX, SEEK_SET);
  58.     rb->read(sprites_file, &current_mastern, sizeof(uint32_t));
  59.     rb->read(dark_file, &idx[ofs_mastern], sizeof(struct gob_idx_entry) * current_mastern);
  60.     ofs_mastern = current_mastern;
  61.     rb->read(sprites_file, &current_header, sizeof(struct gob_header));
  62.     rb->lseek(sprites_file, current_header.MASTERX, SEEK_SET);
  63.     rb->read(sprites_file, &current_mastern, sizeof(uint32_t));
  64.     rb->read(dark_file, &idx[ofs_mastern], sizeof(struct gob_idx_entry) * current_mastern);
  65.  
  66.  
  67.     rb->close(dark_file);
  68.     return PLUGIN_OK;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement