-
Notifications
You must be signed in to change notification settings - Fork 9
/
modelname.c
79 lines (67 loc) · 2.53 KB
/
modelname.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <kernel.h>
#include <sifcmd.h>
#include <libcdvd.h>
#include "libcdvd_add.h"
#include "main.h"
#include "modelname.h"
#define MODEL_NAME_MAX_LEN 17
static char ModelName[MODEL_NAME_MAX_LEN];
extern char ConsoleROMVER[];
static int ReadModelName(char *name)
{
int stat, result, fd;
/* This function is a hybrid between the late ROM browser program and the HDD Browser.
In v2.20, there was only a simple null-terminate before calling sceCdRM(), as below.
However, this does not support the early PlayStation 2 models.
In the HDD Browser, the model name buffer was a global instead of an argument. */
memset(name, 0, MODEL_NAME_MAX_LEN);
/* Invoking the "Read model" command on the first SCPH-10000 seems to return an error code,
but it seems to function on my SCPH-15000...although no valid name is returned!
In the HDD OSD, "SCPH-10000" is returned when the ROM v1.00 is detected (It checks rom0:ROMVER).
It attempts to read the model name from the ROM OSDSYS program, when ROM v1.01 (late SCPH-10000 and all SCPH-15000 models) is detected.
The model name was originally hardcoded into the OSDSYS. The MECHACON EEPROM did not have the model name recorded in it.
Oddly, the console models that come with v1.01, like the SCPH-15000 and DTL-H10000,
will always be identified as "SCPH-10000" by their ROM OSDSYS programs.
*/
if (ConsoleROMVER[0] == '0' && ConsoleROMVER[1] == '1' && ConsoleROMVER[2] == '0')
{
if (ConsoleROMVER[3] == '0') // For ROM v1.00 (Early SCPH-10000 units).
strcpy(name, "SCPH-10000");
else
{ //For ROM v1.01 (Late SCPH-10000, and all SCPH-15000 units).
if ((fd = _ps2sdk_open("rom0:OSDSYS", O_RDONLY)) >= 0)
{ //The model name is located at this address.
_ps2sdk_lseek(fd, 0x8C808, SEEK_SET);
_ps2sdk_read(fd, name, MODEL_NAME_MAX_LEN);
_ps2sdk_close(fd);
}
else
strcpy(name, "Unknown");
}
return 0; //Original returned -1
}
else
{
if ((result = sceCdAltRM(name, &stat)) == 1)
{
if (stat & 0x80)
return -2;
if ((stat & 0x40) || name[0] == '\0')
strcpy(name, "unknown");
return 0; //Original returned -1
}
else
return -2;
}
}
int ModelNameInit(void)
{
return ReadModelName(ModelName);
}
const char *ModelNameGet(void)
{
return ModelName;
}