decomp.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class SPC7110Decomp {
  2. public:
  3. uint8 read();
  4. void init(unsigned mode, unsigned offset, unsigned index);
  5. void reset();
  6. SPC7110Decomp();
  7. ~SPC7110Decomp();
  8. private:
  9. unsigned decomp_mode;
  10. unsigned decomp_offset;
  11. //read() will spool chunks half the size of decomp_buffer_size
  12. enum { decomp_buffer_size = 64 }; //must be >= 64, and must be a power of two
  13. uint8 *decomp_buffer;
  14. unsigned decomp_buffer_rdoffset;
  15. unsigned decomp_buffer_wroffset;
  16. unsigned decomp_buffer_length;
  17. void write(uint8 data);
  18. uint8 dataread();
  19. void mode0(bool init);
  20. void mode1(bool init);
  21. void mode2(bool init);
  22. static const uint8 evolution_table[53][4];
  23. static const uint8 mode2_context_table[32][2];
  24. struct ContextState {
  25. uint8 index;
  26. uint8 invert;
  27. } context[32];
  28. uint8 probability(unsigned n);
  29. uint8 next_lps(unsigned n);
  30. uint8 next_mps(unsigned n);
  31. bool toggle_invert(unsigned n);
  32. unsigned morton16[2][256];
  33. unsigned morton32[4][256];
  34. unsigned morton_2x8(unsigned data);
  35. unsigned morton_4x8(unsigned data);
  36. };