Skip to content

Commit 0f8bb69

Browse files
committed
add predefined macros for kelf related constants
1 parent 2f94476 commit 0f8bb69

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/kelf.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,19 @@ int Kelf::LoadKelf(const std::string &filename)
136136
break;
137137
}
138138
switch (header.ApplicationType) {
139-
case 0:
139+
case KELFTYPE_DISC_WOOBLE:
140140
printf("header.ApplicationType = 0 (disc wobble \?)\n");
141141
break;
142-
case 1:
142+
case KELFTYPE_XOSDMAIN:
143143
printf("header.ApplicationType = 1 (xosdmain)\n");
144144
break;
145-
case 5:
145+
case KELFTYPE_DVDPLAYER_KIRX:
146146
printf("header.ApplicationType = 5 (dvdplayer kirx)\n");
147147
break;
148-
case 7:
148+
case KELFTYPE_DVDPLAYER_KELF:
149149
printf("header.ApplicationType = 7 (dvdplayer kelf)\n");
150150
break;
151-
case 11:
151+
case KELFTYPE_EARLY_MBR:
152152
printf("header.ApplicationType = 11 (early mbr \?)\n");
153153
break;
154154
default:
@@ -159,9 +159,9 @@ int Kelf::LoadKelf(const std::string &filename)
159159
break;
160160
}
161161
printf("header.Flags = %#X", header.Flags);
162-
if (header.Flags == 0x022c)
162+
if (header.Flags == HDR_PREDEF_KELF)
163163
printf(" - kelf:");
164-
else if (header.Flags == 0x021c)
164+
else if (header.Flags == HDR_PREDEF_KIRX)
165165
printf(" - kirx:");
166166
else
167167
printf(" - unknown:");
@@ -203,7 +203,7 @@ int Kelf::LoadKelf(const std::string &filename)
203203
printf("header.MGZones = %#X |", header.MGZones);
204204
if (header.MGZones == 0)
205205
printf("All regions blocked (useless)|");
206-
else if (header.MGZones == 0xFF)
206+
else if (header.MGZones == REGION_ALL_ALLOWED )
207207
printf("All regions allowed|");
208208
else {
209209
if (header.MGZones & REGION_JP)
@@ -389,7 +389,7 @@ int Kelf::SaveKelf(const std::string &filename, int headerid)
389389
header.SystemType = SYSTEM_TYPE_PS2; // same for COH (arcade)
390390
header.ApplicationType = 1; // 1 = xosdmain, 5 = dvdplayer kirx 7 = dvdplayer kelf 0xB - ?? 0x00 - ??
391391
// TODO: implement and check 3DES/1DES difference based on header.Flags. In both - encryption and decryption.
392-
header.Flags = 0x022C; // ?? 00000010 00101100 binary, 0x021C for kirx
392+
header.Flags = HDR_PREDEF_KELF; // ?? 00000010 00101100 binary, 0x021C for kirx
393393
header.MGZones = 0xFF; // region bit, 1 - allowed
394394
header.BitCount = 0;
395395
// ?? balika, wisi: strange value, represents number of blacklisted iLinkID, ConsoleID

src/kelf.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ struct KELFHeader
7676
#define HDR_FLAG13 0x2000 // Unset. ??
7777
#define HDR_FLAG14 0x4000 // Unset. ??
7878
#define HDR_FLAG15 0x8000 // Unset. ??
79+
#define HDR_PREDEF_KELF 0x022c
80+
#define HDR_PREDEF_KIRX 0x021c
7981

8082
// MGZones region flags. If unset - blocked in that region
8183
#define REGION_JP 0x1 // Japan
@@ -86,6 +88,13 @@ struct KELFHeader
8688
#define REGION_RU 0x20 // Russia
8789
#define REGION_CH 0x40 // China
8890
#define REGION_MX 0x80 // Mexico
91+
#define REGION_ALL_ALLOWED 0xFF
92+
93+
#define KELFTYPE_DISC_WOOBLE 0
94+
#define KELFTYPE_XOSDMAIN 1
95+
#define KELFTYPE_DVDPLAYER_KIRX 5
96+
#define KELFTYPE_DVDPLAYER_KELF 7
97+
#define KELFTYPE_EARLY_MBR 11
8998

9099
struct BitTable
91100
{

0 commit comments

Comments
 (0)