tmp_file.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. XCC Utilities and Library
  3. Copyright (C) 2000 Olaf van der Spek <[email protected]>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #pragma once
  16. #include <cc_file_sh.h>
  17. #include <cc_structures.h>
  18. class Ctmp_file : public Ccc_file_sh<t_tmp_header>
  19. {
  20. public:
  21. bool is_valid() const
  22. {
  23. const t_tmp_header& h = header();
  24. int size = get_size();
  25. return !(sizeof(t_tmp_header) > size ||
  26. h.cx != 24 ||
  27. h.cy != 24 ||
  28. h.c_tiles > 128 ||
  29. h.zero1 ||
  30. h.size != size ||
  31. h.image_offset > size ||
  32. h.zero2 ||
  33. h.id != 0x0d1affff);
  34. }
  35. int get_c_tiles() const
  36. {
  37. return header().c_tiles;
  38. }
  39. const byte* get_image(int i) const
  40. {
  41. return data() + header().image_offset + 576 * get_index1()[i];
  42. }
  43. const byte* get_index1() const
  44. {
  45. return data() + header().index1;
  46. }
  47. };