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