Skip to content

Commit e98b9e6

Browse files
committed
Style: Rename public pack functions
I prefer a namespace-like prefix on global functions, so all pack functions now start with PACK_.
1 parent 8a6c1e8 commit e98b9e6

File tree

15 files changed

+107
-100
lines changed

15 files changed

+107
-100
lines changed

src/gameinitexit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ int gGameOn;
9999
// gLevelID = 0;
100100
// }
101101

102-
// LoadPack(PACK_LEVEL_01 + gLevelID);
103-
// gLevelData = GetSortedPackEntry(PACK_LEVEL_01 + gLevelID, 1, NULL);
104-
// gMarks = GetSortedPackEntry(PACK_LEVEL_01 + gLevelID, 2, &gMarkSize);
102+
// PACK_load(PACK_LEVEL_01 + gLevelID);
103+
// gLevelData = PACK_get_sorted_entry(PACK_LEVEL_01 + gLevelID, 1, NULL);
104+
// gMarks = PACK_get_sorted_entry(PACK_LEVEL_01 + gLevelID, 2, &gMarkSize);
105105
// gMarkSize /= sizeof(tMarkSeg);
106-
// gRoadInfo = GetSortedPackEntry(kPackRoad, gLevelData->roadInfo, NULL);
106+
// gRoadInfo = PACK_get_sorted_entry(kPackRoad, gLevelData->roadInfo, NULL);
107107
// gTrackUp = (Ptr)gLevelData + sizeof(tLevelData);
108108
// gTrackDown =
109109
// (Ptr)gTrackUp + sizeof(uint32_t) + gTrackUp->num *
@@ -151,7 +151,7 @@ int gGameOn;
151151
// }
152152

153153
// void DisposeLevel() {
154-
// UnloadPack(PACK_LEVEL_01 + gLevelID);
154+
// PACK_unload(PACK_LEVEL_01 + gLevelID);
155155
// gPlayerObj = NULL;
156156
// while ((tObject *)gFirstObj->next != gFirstObj) {
157157
// SpriteUnused((*(tObject *)gFirstObj->next).frame);

src/include/packs.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ typedef enum {
3535

3636
#define PACK_ENCRYPTED PACK_LEVEL_04
3737

38-
uint32_t LoadPack(int);
39-
bool CheckPack(int num, uint32_t check);
40-
void UnloadPack(int);
41-
Ptr GetSortedPackEntry(int, int, int *);
42-
Ptr GetUnsortedPackEntry(int, int, int *);
43-
int NumPackEntries(int);
38+
uint32_t PACK_load(int);
39+
bool PACK_check(int num, uint32_t check);
40+
void PACK_unload(int);
41+
Ptr PACK_get_sorted_entry(int, int, int *);
42+
Ptr PACK_get_unsorted_entry(int, int, int *);
43+
int PACK_num_entries(int);
4444

4545
#endif // __PACKS_H

src/initexit.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ bool Init() {
3434
}
3535
// InitScreen(0);
3636
ShowPicScreen(1003);
37-
LoadPack(PACK_SOUNDS);
38-
LoadPack(PACK_OBJECT_TYPE);
39-
LoadPack(PACK_OBJECT_GROUPS);
40-
LoadPack(PACK_ROAD);
37+
PACK_load(PACK_SOUNDS);
38+
PACK_load(PACK_OBJECT_TYPE);
39+
PACK_load(PACK_OBJECT_GROUPS);
40+
PACK_load(PACK_ROAD);
4141
if (gPrefs.full_color) {
42-
LoadPack(PACK_RLE_16);
43-
LoadPack(PACK_cRLE_16);
44-
LoadPack(PACK_TEXTURES_16);
42+
PACK_load(PACK_RLE_16);
43+
PACK_load(PACK_cRLE_16);
44+
PACK_load(PACK_TEXTURES_16);
4545
}
4646
else {
47-
LoadPack(PACK_RLE);
48-
LoadPack(PACK_cRLE);
49-
LoadPack(PACK_TEXTURES);
47+
PACK_load(PACK_RLE);
48+
PACK_load(PACK_cRLE);
49+
PACK_load(PACK_TEXTURES);
5050
}
5151
LoadSprites();
5252
// InitInput();
@@ -59,16 +59,16 @@ bool Init() {
5959
}
6060

6161
static void free_packs() {
62-
UnloadPack(PACK_SOUNDS);
63-
UnloadPack(PACK_OBJECT_TYPE);
64-
UnloadPack(PACK_OBJECT_GROUPS);
65-
UnloadPack(PACK_ROAD);
66-
UnloadPack(PACK_RLE_16);
67-
UnloadPack(PACK_cRLE_16);
68-
UnloadPack(PACK_TEXTURES_16);
69-
UnloadPack(PACK_RLE);
70-
UnloadPack(PACK_cRLE);
71-
UnloadPack(PACK_TEXTURES);
62+
PACK_unload(PACK_SOUNDS);
63+
PACK_unload(PACK_OBJECT_TYPE);
64+
PACK_unload(PACK_OBJECT_GROUPS);
65+
PACK_unload(PACK_ROAD);
66+
PACK_unload(PACK_RLE_16);
67+
PACK_unload(PACK_cRLE_16);
68+
PACK_unload(PACK_TEXTURES_16);
69+
PACK_unload(PACK_RLE);
70+
PACK_unload(PACK_cRLE);
71+
PACK_unload(PACK_TEXTURES);
7272

7373
UnloadSprites();
7474
}

src/objects.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ t2DPoint GetUniquePos(int16_t minOffs, int16_t maxOffs, float *objDir,
180180
void InsertObjectGroup(tObjectGroupReference groupRef) {
181181
int probilities[100];
182182
int entryCnt, indexCount = 0, probCount;
183-
tObjectGroup *group = (tObjectGroup *)GetSortedPackEntry(
183+
tObjectGroup *group = (tObjectGroup *)PACK_get_sorted_entry(
184184
PACK_OBJECT_GROUPS, groupRef.resID, NULL);
185185
for (entryCnt = 0; entryCnt < (*group).numEntries; entryCnt++)
186186
for (probCount = 0; probCount < (*group).data[entryCnt].probility;
@@ -218,7 +218,7 @@ tObject *NewObject(tObject *prev, int16_t typeRes) {
218218
((tObject *)(prev->next))->prev = theObj;
219219
prev->next = theObj;
220220
theObj->type =
221-
(tObjectTypePtr)GetUnsortedPackEntry(PACK_OBJECT_TYPE, typeRes, 0);
221+
(tObjectTypePtr)PACK_get_unsorted_entry(PACK_OBJECT_TYPE, typeRes, 0);
222222
if ((*theObj->type).flags & kObjectRandomFrameFlag)
223223
theObj->frame =
224224
(*theObj->type).frame + RanInt(0, (*theObj->type).numFrames);
@@ -241,7 +241,7 @@ void RemoveObject(tObject *theObj) {
241241
if (theObj == gPlayerObj) {
242242
theObj->frame = 0;
243243
theObj->type =
244-
(tObjectTypePtr)GetUnsortedPackEntry(PACK_OBJECT_TYPE, 2000, 0);
244+
(tObjectTypePtr)PACK_get_unsorted_entry(PACK_OBJECT_TYPE, 2000, 0);
245245
}
246246
else {
247247
if (theObj == gFirstVisObj)
@@ -314,7 +314,7 @@ void KillObject(tObject *theObj) {
314314
RemoveObject(theObj);
315315
return;
316316
}
317-
theObj->type = (tObjectTypePtr)GetUnsortedPackEntry(
317+
theObj->type = (tObjectTypePtr)PACK_get_unsorted_entry(
318318
PACK_OBJECT_TYPE,
319319
(*objType).deathObj + (sinkEnable ? gRoadInfo->deathOffs : 0), 0);
320320
theObj->layer = (*theObj->type).flags2 >> 5 & 3;

src/packs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static uint32_t CryptData(uint32_t *data, uint32_t len) {
4646
return check;
4747
}
4848

49-
uint32_t LoadPack(int num) {
49+
uint32_t PACK_load(int num) {
5050
uint32_t check = 0;
5151
if (!packs[num]) {
5252
packs[num] = GetResource("Pack", num + 128);
@@ -63,7 +63,7 @@ uint32_t LoadPack(int num) {
6363
}
6464

6565
// Only used to check if registration is valid.
66-
bool CheckPack(int num, uint32_t check) {
66+
bool PACK_check(int num, uint32_t check) {
6767
bool ok = false;
6868
if (!packs[num]) {
6969
packs[num] = GetResource("Pack", num + 128);
@@ -82,7 +82,7 @@ bool CheckPack(int num, uint32_t check) {
8282
return ok;
8383
}
8484

85-
void UnloadPack(int num) {
85+
void PACK_unload(int num) {
8686
if (packs[num]) {
8787
// Any valid pack has been decompressed, which means it is no longer a
8888
// resource handle, but a memory handle, so we must use DisposeHandle to
@@ -92,7 +92,7 @@ void UnloadPack(int num) {
9292
}
9393
}
9494

95-
Ptr GetSortedPackEntry(int packNum, int entryID, int *size) {
95+
Ptr PACK_get_sorted_entry(int packNum, int entryID, int *size) {
9696
PackHeader *pack = (PackHeader *)*packs[packNum];
9797
int startId = pack[1].id;
9898
uint32_t offset = pack[entryID - startId + 1].offset;
@@ -117,7 +117,7 @@ static int ComparePackHeaders(const void *p1, const void *p2) {
117117
// HACK: This was changed a great deal from the original code.
118118
// It seems to work okay, but it would be good to revisit the logic
119119
// at some point.
120-
Ptr GetUnsortedPackEntry(int packNum, int entryID, int *size) {
120+
Ptr PACK_get_unsorted_entry(int packNum, int entryID, int *size) {
121121
PackHeader pack = *(PackHeader *)*packs[packNum];
122122
FLIP_SHORT(pack.id);
123123
FLIP_LONG(pack.offset);
@@ -146,6 +146,6 @@ Ptr GetUnsortedPackEntry(int packNum, int entryID, int *size) {
146146
return (char *)*packs[packNum] + offset;
147147
}
148148

149-
int NumPackEntries(int num) {
149+
int PACK_num_entries(int num) {
150150
return packs[num] ? TO_LITTLE_S((**(PackHandle)packs[num]).id) : 0;
151151
}

src/preferences.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,22 @@ void PREFS_load_preferences() {
301301
// ScreenMode(kScreenStopped);
302302
// InitScreen(0);
303303
// ShowPicScreen(1003);
304-
// UnloadPack(PACK_RLE_16);
305-
// UnloadPack(PACK_cRLE_16);
306-
// UnloadPack(PACK_TEXTURES_16);
307-
// UnloadPack(PACK_RLE);
308-
// UnloadPack(PACK_cRLE);
309-
// UnloadPack(PACK_TEXTURES);
304+
// PACK_unload(PACK_RLE_16);
305+
// PACK_unload(PACK_cRLE_16);
306+
// PACK_unload(PACK_TEXTURES_16);
307+
// PACK_unload(PACK_RLE);
308+
// PACK_unload(PACK_cRLE);
309+
// PACK_unload(PACK_TEXTURES);
310310
// UnloadSprites();
311311
// if (gPrefs.full_color) {
312-
// LoadPack(PACK_RLE_16);
313-
// LoadPack(PACK_cRLE_16);
314-
// LoadPack(PACK_TEXTURES_16);
312+
// PACK_load(PACK_RLE_16);
313+
// PACK_load(PACK_cRLE_16);
314+
// PACK_load(PACK_TEXTURES_16);
315315
// }
316316
// else {
317-
// LoadPack(PACK_RLE);
318-
// LoadPack(PACK_cRLE);
319-
// LoadPack(PACK_TEXTURES);
317+
// PACK_load(PACK_RLE);
318+
// PACK_load(PACK_cRLE);
319+
// PACK_load(PACK_TEXTURES);
320320
// }
321321
// LoadSprites();
322322
// InitInterface();

src/register.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool REG_check_registration() {
9292
uint32_t check_num = FLIP_LONG(**(uint32_t **)check);
9393
ReleaseResource(check);
9494

95-
gRegistered = CheckPack(PACK_ENCRYPTED, check_num);
95+
gRegistered = PACK_check(PACK_ENCRYPTED, check_num);
9696
return gRegistered;
9797
}
9898

src/renderframe.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void DrawTracksZoomed(float xDrawStart, float yDrawStart, float zoom) {
281281
int i;
282282
int y1Clip = yDrawStart - (gYSize - (gFinishDelay ? 0 : kInvLines)) * zoom;
283283
uint8_t *textures =
284-
GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).tracks, 0);
284+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).tracks, 0);
285285
for (i = 0; i < gTrackCount; i++) {
286286
if (gTracks[i].p2.y <= yDrawStart + size && gTracks[i].p1.y > y1Clip &&
287287
gTracks[i].time + kTrackLifeTime + kTrackDeathDuration > gFrameCount) {
@@ -370,7 +370,8 @@ void DrawMarksZoomed(float xDrawStart, float yDrawStart, float zoom) {
370370
uint32_t shiftClip = gXSize - size << 16;
371371
int i;
372372
int y1Clip = yDrawStart - (gYSize - (gFinishDelay ? 0 : kInvLines)) * zoom;
373-
uint8_t *texture = GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).marks, 0);
373+
uint8_t *texture =
374+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).marks, 0);
374375
int l = 0, r = gMarkSize;
375376
while (r - 1 > l)
376377
if (gMarks[(l + r) / 2].p1.y + gMarks[(l + r) / 2].p2.y >
@@ -511,7 +512,7 @@ void DrawTracksZoomed16(float xDrawStart, float yDrawStart, float zoom) {
511512
int i;
512513
int y1Clip = yDrawStart - (gYSize - (gFinishDelay ? 0 : kInvLines)) * zoom;
513514
uint16_t *textures =
514-
GetUnsortedPackEntry(PACK_TEXTURES_16, (*gRoadInfo).tracks, 0);
515+
PACK_get_unsorted_entry(PACK_TEXTURES_16, (*gRoadInfo).tracks, 0);
515516
for (i = 0; i < gTrackCount; i++) {
516517
if (gTracks[i].p2.y <= yDrawStart + size && gTracks[i].p1.y > y1Clip &&
517518
gTracks[i].time + kTrackLifeTime + kTrackDeathDuration > gFrameCount) {
@@ -602,7 +603,7 @@ void DrawMarksZoomed16(float xDrawStart, float yDrawStart, float zoom) {
602603
int i;
603604
int y1Clip = yDrawStart - (gYSize - (gFinishDelay ? 0 : kInvLines)) * zoom;
604605
uint16_t *texture =
605-
GetUnsortedPackEntry(PACK_TEXTURES_16, (*gRoadInfo).marks, 0);
606+
PACK_get_unsorted_entry(PACK_TEXTURES_16, (*gRoadInfo).marks, 0);
606607
int l = 0, r = gMarkSize;
607608
while (r - 1 > l)
608609
if (gMarks[(l + r) / 2].p1.y + gMarks[(l + r) / 2].p2.y >

src/renderframezoom.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ void DrawRoadZoomed(float xDrawStart, float yDrawStart, float zoom) {
125125
int rowBytesSkip = gRowBytes - gXSize;
126126
Ptr drawPos = gBaseAddr;
127127
Ptr backgrTex =
128-
GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).backgroundTex);
129-
Ptr roadTex = GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).foregroundTex);
128+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).backgroundTex);
129+
Ptr roadTex =
130+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).foregroundTex);
130131
Ptr leftBorder =
131-
GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).roadLeftBorder);
132+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).roadLeftBorder);
132133
Ptr rightBorder =
133-
GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).roadRightBorder);
134+
PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).roadRightBorder);
134135
if (gPrefs.lineSkip)
135136
rowBytesSkip += gRowBytes;
136137
for (screenY = 0; screenY < gYSize; screenY += (gPrefs.lineSkip ? 2 : 1)) {
@@ -181,7 +182,7 @@ void DrawMarksZoomed(float xDrawStart, float yDrawStart, float zoom) {
181182
int l = 0, r = gMarkSize, i;
182183
int yClipWorld = (gYSize - (gFinishDelay ? 0 : kInvLines)) * zoom;
183184
int yClip = (gYSize - (gFinishDelay ? 0 : kInvLines));
184-
Ptr trackTex = GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).marks);
185+
Ptr trackTex = PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).marks);
185186
while (r - 1 > l)
186187
if (gMarks[(l + r) / 2].y > yDrawStart)
187188
l = (l + r) / 2;
@@ -202,7 +203,7 @@ void DrawTracksZoomed(float xDrawStart, float yDrawStart, float zoom) {
202203
float invZoom = 1 / zoom;
203204
int i;
204205
int yClip = gYSize - (gFinishDelay ? 0 : kInvLines);
205-
Ptr trackTex = GetUnsortedPackEntry(PACK_TEXTURES, (*gRoadInfo).tracks);
206+
Ptr trackTex = PACK_get_unsorted_entry(PACK_TEXTURES, (*gRoadInfo).tracks);
206207
for (i = 0; i < gTrackCount; i++) {
207208
int x = (gTracks[i].x - xDrawStart) * invZoom - 2;
208209
int y = (yDrawStart - gTracks[i].y) * invZoom;

src/rle.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
void DrawRLE8(int h, int v, int id) {
1515
int rowBytes = gRowBytes;
16-
uint8_t *spritePos = GetSortedPackEntry(PACK_RLE, id, NULL) + sizeof(Rect);
16+
uint8_t *spritePos = PACK_get_sorted_entry(PACK_RLE, id, NULL) + sizeof(Rect);
1717
uint8_t *lineStart = gBaseAddr + h + v * rowBytes;
1818
uint8_t *dst = lineStart;
1919
int stop = 0;
@@ -56,7 +56,8 @@ void DrawRLE8(int h, int v, int id) {
5656

5757
void DrawRLE16(int h, int v, int id) {
5858
int rowBytes = gRowBytes;
59-
uint8_t *spritePos = GetSortedPackEntry(PACK_RLE_16, id, NULL) + sizeof(Rect);
59+
uint8_t *spritePos =
60+
PACK_get_sorted_entry(PACK_RLE_16, id, NULL) + sizeof(Rect);
6061
uint8_t *lineStart = gBaseAddr + h * 2 + v * rowBytes;
6162
uint16_t *dst = lineStart;
6263
int stop = 0;
@@ -96,7 +97,7 @@ void DrawRLE16(int h, int v, int id) {
9697

9798
void DrawRLEYClip8(int h, int v, int id) {
9899
int rowBytes = gRowBytes;
99-
uint8_t *spritePos = GetSortedPackEntry(PACK_RLE, id, NULL) + sizeof(Rect);
100+
uint8_t *spritePos = PACK_get_sorted_entry(PACK_RLE, id, NULL) + sizeof(Rect);
100101
uint8_t *lineStart = gBaseAddr + h + v * rowBytes;
101102
uint8_t *dst = lineStart;
102103
int stop = 0;
@@ -144,7 +145,8 @@ void DrawRLEYClip8(int h, int v, int id) {
144145

145146
void DrawRLEYClip16(int h, int v, int id) {
146147
int rowBytes = gRowBytes;
147-
uint8_t *spritePos = GetSortedPackEntry(PACK_RLE_16, id, NULL) + sizeof(Rect);
148+
uint8_t *spritePos =
149+
PACK_get_sorted_entry(PACK_RLE_16, id, NULL) + sizeof(Rect);
148150
uint8_t *lineStart = gBaseAddr + h * 2 + v * rowBytes;
149151
uint16_t *dst = lineStart;
150152
int stop = 0;

0 commit comments

Comments
 (0)