static bool load_sif(const char *fname) { SIFLoader sif; uint8_t *sheetdata, *spritesdata; int sheetdatalength, spritesdatalength; if (sif.LoadHeader(fname)) return 1; if (!(sheetdata = sif.FindSection(SIF_SECTION_SHEETS, &sheetdatalength))) { NX_ERR("load_sif: file '%s' missing SIF_SECTION_SHEETS\n", fname); return 1; } if (!(spritesdata = sif.FindSection(SIF_SECTION_SPRITES, &spritesdatalength))) { NX_ERR("load_sif: file '%s' missing SIF_SECTION_SPRITES\n", fname); return 1; } // decode sheets sheetfiles.MakeEmpty(); if (SIFStringArraySect::Decode(sheetdata, sheetdatalength, &sheetfiles)) return 1; // decode sprites if (SIFSpritesSect::Decode(spritesdata, spritesdatalength, \ &sprites[0], &num_sprites, MAX_SPRITES)) { NX_ERR("load_sif: SIFSpritesSect decoder failed\n"); return 1; } sif.CloseFile(); create_slope_boxes(); offset_by_draw_points(); // for sprites which only have 1 dir (no separate frames for left & right), // create a 2nd identical dir as the rest of the engine doesn't bother // with this complication. for(int s=0;s<num_sprites;s++) { if (sprites[s].ndirs == 1) { sprites[s].ndirs = 2; for(int f=0;f<sprites[s].nframes;f++) sprites[s].frame[f].dir[1] = sprites[s].frame[f].dir[0]; } } return 0; }
static bool load_sif(const char *fname) { SIFLoader sif; uint8_t *sheetdata, *spritesdata; int sheetdatalength, spritesdatalength; if (sif.LoadHeader(fname)) return 1; if (!(sheetdata = sif.FindSection(SIF_SECTION_SHEETS, &sheetdatalength))) { staterr("load_sif: file '%s' missing SIF_SECTION_SHEETS", fname); return 1; } if (!(spritesdata = sif.FindSection(SIF_SECTION_SPRITES, &spritesdatalength))) { staterr("load_sif: file '%s' missing SIF_SECTION_SPRITES", fname); return 1; } // decode sheets sheetfiles.MakeEmpty(); if (SIFStringArraySect::Decode(sheetdata, sheetdatalength, &sheetfiles)) return 1; // decode sprites if (SIFSpritesSect::Decode(spritesdata, spritesdatalength, \ &sprites[0], &num_sprites, MAX_SPRITES)) { staterr("load_sif: SIFSpritesSect decoder failed"); return 1; } sif.CloseFile(); create_slope_boxes(); offset_by_draw_points(); expand_single_dir_sprites(); return 0; }