Advertisement
BigETI

gc_mem.h

Jan 11th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.49 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <iostream>
  4. #include <stdint.h>
  5. #include <string>
  6. #include <vector>
  7.  
  8. #define GC_BANNER_WIDTH         (96)
  9. #define GC_BANNER_HEIGHT        (32)
  10. #define GC_BANNER_PIXEL_COUNT   (GC_BANNER_WIDTH * GC_BANNER_HEIGHT)
  11. #define GC_ICON_WIDTH           (32)
  12. #define GC_ICON_HEIGHT          (32)
  13. #define GC_ICON_PIXEL_COUNT     (GC_ICON_WIDTH * GC_ICON_HEIGHT)
  14.  
  15. class GCMem
  16. {
  17. public:
  18.     class DirEntry
  19.     {
  20.     private:
  21.         char game_code[0x4], maker_code[0x2];
  22.         uint8_t dummy1, graphics_format;
  23.         char game_title[0x20];
  24.         uint32_t save_time, image_offset;
  25.         uint16_t icon_format, animation_speed;
  26.         uint8_t file_permissions, counter;
  27.         uint16_t block_index, save_size, dummy2;
  28.         uint32_t comment_offset;
  29.     public:
  30.         enum REGION
  31.         {
  32.             REGION_JAPAN,
  33.             REGION_USA,
  34.             REGION_EUR,
  35.             REGION_UNKNOWN
  36.         };
  37.         enum COLOR_FORMAT
  38.         {
  39.             COLOR_FORMAT_RGB5A3,
  40.             COLOR_FORMAT_CI8
  41.         };
  42.         enum ICON_ANIMATION_TYPE
  43.         {
  44.             ICON_ANIMATION_FORWARD,
  45.             ICON_ANIMATION_PING_PONG
  46.         };
  47.         enum ICON_FORMAT
  48.         {
  49.             ICON_FORMAT_NONE,
  50.             ICON_FORMAT_CI8_REUSE_PALETTE,
  51.             ICON_FORMAT_RGB5A3,
  52.             ICON_FORMAT_CI8_UNIQUE_PALETTE
  53.         };
  54.         enum ANIMATION_SPEED
  55.         {
  56.             ANIMATION_SPEED_NONE,
  57.             ANIMATION_SPEED_4,
  58.             ANIMATION_SPEED_8,
  59.             ANIMATION_SPEED_12
  60.         };
  61.         __fastcall DirEntry(FILE *file);
  62.         __fastcall ~DirEntry();
  63.         void __fastcall Read(FILE *file);
  64.         bool __fastcall IsValid();
  65.         REGION __fastcall GetRegion();
  66.         std::string __fastcall GetRegionName();
  67.         std::string __fastcall GetGameCode();
  68.         std::string __fastcall GetMakerCode();
  69.         std::string __fastcall GetMakerName();
  70.         COLOR_FORMAT __fastcall GetColorFormat();
  71.         std::string __fastcall GetColorFormatName();
  72.         bool __fastcall IsBannerPresent();
  73.         ICON_ANIMATION_TYPE __fastcall GetIconAnimationType();
  74.         std::string __fastcall GetIconAnimationTypeName();
  75.         std::string __fastcall GetGameTitle();
  76.         uint32_t __fastcall GetSaveTimeStamp();
  77.         std::string __fastcall GetSaveTime();
  78.         uint32_t __fastcall GetBannerOffsetInSave();
  79.         uint32_t __fastcall GetBannerOffsetInFile();
  80.         ICON_FORMAT __fastcall GetIconFormat(uint8_t index);
  81.         std::string __fastcall GetIconFormatName(uint8_t index);
  82.         ANIMATION_SPEED __fastcall GetAnimationSpeed(uint8_t index);
  83.         std::string __fastcall GetAnimationSpeedName(uint8_t index);
  84.         bool __fastcall IsSavePublic();
  85.         bool __fastcall CopyDisabled();
  86.         bool __fastcall MovingDisabled();
  87.         uint8_t __fastcall GetCounter();
  88.         uint16_t __fastcall GetBlockIndex();
  89.         uint32_t __fastcall GetSaveDataOffsetInFile();
  90.         uint16_t __fastcall GetSaveSize();
  91.         uint32_t __fastcall GetComment1OffsetInSave();
  92.         uint32_t __fastcall GetComment1OffsetInFile();
  93.         uint32_t __fastcall GetComment2OffsetInSave();
  94.         uint32_t __fastcall GetComment2OffsetInFile();
  95.     };
  96.  
  97.     class GameData
  98.     {
  99.     private:
  100.         DirEntry *dir_entry;
  101.         struct Pixel
  102.         {
  103.             uint8_t blue, green, red, alpha;
  104.         } banner_pixel_data[GC_BANNER_PIXEL_COUNT], icon_pixel_data[8][GC_ICON_PIXEL_COUNT];
  105.         std::string comment1, comment2;
  106.  
  107.     public:
  108.         __fastcall GameData(FILE *file);
  109.         __fastcall ~GameData();
  110.         bool __fastcall IsValid();
  111.         DirEntry &__fastcall GetDirEntry();
  112.         std::string __fastcall GetComment1();
  113.         std::string __fastcall GetComment2();
  114.         void __fastcall StoreBannerAsTGA(std::string file_name);
  115.         void __fastcall StoreIconAsTGA(std::string file_name, uint8_t index);
  116.     };
  117.     __fastcall GCMem(std::string file_name);
  118.     __fastcall ~GCMem();
  119.     GameData &__fastcall Game(uint8_t index);
  120.     uint8_t __fastcall GameCount();
  121. private:
  122.     std::vector<GameData *> games;
  123. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement