PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
rom0_info.c
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
17#include <rom0_info.h>
18
19// We don't want kernel to depend newlib
20#define NEWLIB_PORT_AWARE
21#include "fileio.h"
22
23#define defaultIODriver { (void *)fioOpen, fioClose, fioRead, FIO_O_RDONLY }
24
25extern char g_RomName[];
26
27#ifdef F__info_internals
29char g_RomName[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
30#endif
31
32#ifdef F_GetRomNameWithIODriver
33char *GetRomNameWithIODriver(char *romname, _io_driver *driver)
34{
35 int fd;
36
37 fd = driver->open("rom0:ROMVER", driver->openFlags);
38 driver->read(fd, romname, 14);
39 driver->close(fd);
40 return romname;
41}
42#endif
43
44#ifdef F_GetRomName
45char *GetRomName(char *romname)
46{
47 _io_driver driver = defaultIODriver;
48 return GetRomNameWithIODriver(romname, &driver);
49}
50#endif
51
52#ifdef F_IsDESRMachineWithIODriver
53int IsDESRMachineWithIODriver(_io_driver *driver)
54{
55 int fd;
56
57 fd = driver->open("rom0:PSXVER", driver->openFlags);
58 if (fd > 0) {
59 driver->close(fd);
60 return 1;
61 }
62
63 return 0;
64}
65#endif
66
67#ifdef F_IsDESRMachine
68int IsDESRMachine(void)
69{
70 _io_driver driver = defaultIODriver;
71 return IsDESRMachineWithIODriver(&driver);
72}
73#endif
74
75#ifdef F_IsT10KWithIODriver
76int IsT10KWithIODriver(_io_driver *driver)
77{
78 // only read in the romname the first time
79 if (g_RomName[0] == 0)
80 GetRomNameWithIODriver(g_RomName, driver);
81 return (g_RomName[4] == 'T' && g_RomName[5] != 'Z') ? 1 : 0;
82}
83#endif
84
85#ifdef F_IsT10K
86int IsT10K(void)
87{
88 _io_driver driver = defaultIODriver;
89 return IsT10KWithIODriver(&driver);
90}
91#endif
char * GetRomName(char *romname)
int IsDESRMachine(void)
int IsT10K(void)