Skip to content

Commit f139b84

Browse files
authored
Merge pull request #53 from halotroop2288/patch-1
Fix code at top of XEX article
2 parents 4b23c09 + 911c0f4 commit f139b84

1 file changed

Lines changed: 54 additions & 54 deletions

File tree

  • docs/System-Software/Formats

docs/System-Software/Formats/XEX.md

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,60 +17,60 @@ Actually it has been reported to work with the first official "Backward
1717
Compatibility" .XEX File from Microsoft. It takes the XEX file as
1818
argument.
1919

20-
`// default.xex table dumper`
21-
` // only works with the default.xex from the xbox360 emulator update package.`
22-
` // - th0mas, th0mas.sixbit.org [at] gmail.com`
23-
` `
24-
` #include <stdio.h>`
25-
` #include <string.h>`
26-
` `
27-
` #define TABLE_START 0x288`
28-
` `
29-
` struct table {`
30-
`    unsigned int unknown[6];`
31-
` };`
32-
` `
33-
` unsigned int ByteSwap (unsigned int nInt)`
34-
` {`
35-
`    union u {unsigned int vi; unsigned char c[sizeof(unsigned int)];};`
36-
`    union v {unsigned int ni; unsigned char d[sizeof(unsigned int)];};`
37-
`    union u un;`
38-
`    union v vn;`
39-
`    un.vi = nInt;`
40-
`    vn.d[0]=un.c[3];`
41-
`    vn.d[1]=un.c[2];`
42-
`    vn.d[2]=un.c[1];`
43-
`    vn.d[3]=un.c[0];`
44-
`    return (vn.ni);`
45-
` }`
46-
` `
47-
` void printTable(struct table *t)`
48-
` {`
49-
`    int i;`
50-
`    for (i = 0; i < 6; i  ) {`
51-
`       int j = ByteSwap(t->unknown[i]);`
52-
`       printf("0x%08x ", j);`
53-
`    }`
54-
`    printf("\n");`
55-
` }`
56-
` `
57-
` int main(int argc, char **argv)`
58-
` {`
59-
`    FILE *fp = fopen(argv[1], "rb");`
60-
`    struct table tmp;`
61-
`    int numEntries = 0;`
62-
`    int i;`
63-
` `
64-
`    fseek(fp, TABLE_START, SEEK_SET);`
65-
`    fread(&numEntries, sizeof(unsigned int), 1, fp);`
66-
`    numEntries = ByteSwap(numEntries);`
67-
`    for (i = 0; i < numEntries; i  ) {`
68-
`         fread(&tmp, sizeof(struct table), 1, fp);`
69-
`         printTable(&tmp);`
70-
`    }`
71-
` }`
72-
` `
73-
` `
20+
```c
21+
// default.xex table dumper
22+
// only works with the default.xex from the xbox360 emulator update package.
23+
// - th0mas, th0mas.sixbit.org@gmail.com
24+
25+
#include <stdio.h>
26+
#include <string.h>
27+
28+
#define TABLE_START 0x288
29+
30+
struct table {
31+
   unsigned int unknown[6];
32+
};
33+
34+
unsigned int ByteSwap (unsigned int nInt)
35+
{
36+
   union u { unsigned int vi; unsigned char c[sizeof(unsigned int)]; };
37+
   union v { unsigned int ni; unsigned char d[sizeof(unsigned int)]; };
38+
   union u un;
39+
   union v vn;
40+
   un.vi = nInt;
41+
   vn.d[0]=un.c[3];
42+
   vn.d[1]=un.c[2];
43+
   vn.d[2]=un.c[1];
44+
   vn.d[3]=un.c[0];
45+
   return (vn.ni);`
46+
}
47+
48+
void printTable(struct table *t)
49+
{
50+
   int i;
51+
   for (i = 0; i < 6; i++) {
52+
      int j = ByteSwap(t->unknown[i]);
53+
      printf("0x%08x ", j);
54+
   }
55+
   printf("\n");
56+
}
57+
58+
int main(int argc, char **argv)
59+
{
60+
   FILE *fp = fopen(argv[1], "rb");
61+
   struct table tmp;
62+
   int numEntries = 0;
63+
   int i;
64+
65+
   fseek(fp, TABLE_START, SEEK_SET);
66+
   fread(&numEntries, sizeof(unsigned int), 1, fp);
67+
   numEntries = ByteSwap(numEntries);
68+
   for (i = 0; i < numEntries; i++) {
69+
        fread(&tmp, sizeof(struct table), 1, fp);
70+
        printTable(&tmp);
71+
   }
72+
}
73+
```
7474

7575
# Structure of the XEX File
7676

0 commit comments

Comments
 (0)