Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. #ifndef __ID_PM__
  2. #define __ID_PM__
  3.  
  4. #ifdef USE_HIRES
  5. #define PMPageSize 16384
  6. #else
  7. #define PMPageSize 4096
  8. #endif
  9.  
  10. extern int ChunksInFile;
  11. extern int PMSpriteStart;
  12. extern int PMSoundStart;
  13.  
  14. extern bool PMSoundInfoPagePadded;
  15.  
  16. // ChunksInFile+1 pointers to page starts.
  17. // The last pointer points one byte after the last page.
  18. extern uint8_t **PMPages;
  19.  
  20. void PM_Startup();
  21. void PM_Shutdown();
  22.  
  23. static inline uint32_t PM_GetPageSize(int page)
  24. {
  25.     if(page < 0 || page >= ChunksInFile)
  26.         Quit("PM_GetPageSize: Tried to access illegal page: %i", page);
  27.     return (uint32_t) (PMPages[page + 1] - PMPages[page]);
  28. }
  29.  
  30. static inline uint8_t *PM_GetPage(int page)
  31. {
  32.     if(page < 0 || page >= ChunksInFile)
  33.         Quit("PM_GetPage: Tried to access illegal page: %i", page);
  34.     return PMPages[page];
  35. }
  36.  
  37. static inline uint8_t *PM_GetEnd()
  38. {
  39.     return PMPages[ChunksInFile];
  40. }
  41.  
  42. static inline byte *PM_GetTexture(int wallpic)
  43. {
  44.     return PM_GetPage(wallpic);
  45. }
  46.  
  47. static inline uint16_t *PM_GetSprite(int shapenum)
  48. {
  49.     // correct alignment is enforced by PM_Startup()
  50.     return (uint16_t *) (void *) PM_GetPage(PMSpriteStart + shapenum);
  51. }
  52.  
  53. static inline byte *PM_GetSound(int soundpagenum)
  54. {
  55.     return PM_GetPage(PMSoundStart + soundpagenum);
  56. }
  57.  
  58. #endif
  59.