-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/rom3M
- Loading branch information
Showing
54 changed files
with
1,689 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
#include "fat/ff.h" | ||
|
||
typedef void (*inir_callback_t)(void* arg, const char* section, const char* key, const char* value); | ||
|
||
class INIReader | ||
{ | ||
public: | ||
static bool Parse(FIL* file, inir_callback_t callback, void* arg); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "vram.h" | ||
#include "vramheap.h" | ||
#include "string.h" | ||
#include "fat/ff.h" | ||
#include "INIReader.h" | ||
|
||
bool INIReader::Parse(FIL* file, inir_callback_t callback, void* arg) | ||
{ | ||
char line[128]; | ||
char section[128]; | ||
while (f_gets(line, sizeof(line), file)) | ||
{ | ||
if(line[0] == ';') | ||
continue; | ||
char* newLine = strchr(line, '\n'); | ||
*newLine = 0; | ||
if(line[0] == '[') | ||
{ | ||
int len = strlen(line) - 2; | ||
for(int i = 0; i < len; i++) | ||
section[i] = line[i + 1]; | ||
section[len] = 0; | ||
continue; | ||
} | ||
char* equals = strchr(line, '='); | ||
if(!equals) | ||
continue; | ||
*equals = 0; | ||
callback(arg, section, line, equals + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include "fat/ff.h" | ||
|
||
class INIWriter | ||
{ | ||
FIL* _file; | ||
public: | ||
explicit INIWriter(FIL* file); | ||
|
||
void WriteSection(const char* name); | ||
void WriteProperty(const char* key, const char* value); | ||
void WriteBooleanProperty(const char* key, bool value); | ||
void WriteIntegerProperty(const char* key, int value); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "vram.h" | ||
#include "vramheap.h" | ||
#include "fat/ff.h" | ||
#include "INIWriter.h" | ||
|
||
INIWriter::INIWriter(FIL* file) | ||
: _file(file) | ||
{ | ||
|
||
} | ||
|
||
void INIWriter::WriteSection(const char* name) | ||
{ | ||
f_printf(_file, "[%s]\n", name); | ||
} | ||
|
||
void INIWriter::WriteProperty(const char* key, const char* value) | ||
{ | ||
f_printf(_file, "%s=%s\n", key, value); | ||
} | ||
|
||
void INIWriter::WriteBooleanProperty(const char* key, bool value) | ||
{ | ||
WriteProperty(key, value ? "true" : "false"); | ||
} | ||
|
||
void INIWriter::WriteIntegerProperty(const char* key, int value) | ||
{ | ||
f_printf(_file, "%s=%d\n", key, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
typedef u16 RomGpioHwMask; | ||
|
||
#define RIO_NONE 0 | ||
#define RIO_RTC (1 << 0) | ||
#define RIO_LIGHT (1 << 1) | ||
|
||
extern u16 gRioGpioData; | ||
extern u16 gRioGpioDirection; | ||
extern u16 gRioGpioControl; | ||
|
||
void rio_init(RomGpioHwMask forceHwMask); | ||
extern "C" void rio_write(u32 addr, u16 val); | ||
void rio_invalidate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include "vram.h" | ||
#include "consts.s" | ||
#include "romGpioRtc.h" | ||
#include "romGpio.h" | ||
|
||
struct game_hw_info_t | ||
{ | ||
u32 gameCode; | ||
RomGpioHwMask hardware; | ||
}; | ||
|
||
#define GAMECODE(x) ((((x) & 0xFF) << 24) | ((((x) >> 8) & 0xFF) << 16) | ((((x) >> 16) & 0xFF) << 8) | ((x) >> 24)) | ||
|
||
static game_hw_info_t sGameHardwareTable[] = | ||
{ | ||
// Boktai: The Sun is in Your Hand | ||
{ GAMECODE('U3IJ'), RIO_RTC | RIO_LIGHT }, | ||
{ GAMECODE('U3IE'), RIO_RTC | RIO_LIGHT }, | ||
{ GAMECODE('U3IP'), RIO_RTC | RIO_LIGHT }, | ||
|
||
// Boktai 2: Solar Boy Django | ||
{ GAMECODE('U32J'), RIO_RTC | RIO_LIGHT }, | ||
{ GAMECODE('U32E'), RIO_RTC | RIO_LIGHT }, | ||
{ GAMECODE('U32P'), RIO_RTC | RIO_LIGHT }, | ||
|
||
// Pokemon Ruby | ||
{ GAMECODE('AXVJ'), RIO_RTC }, | ||
{ GAMECODE('AXVE'), RIO_RTC }, | ||
{ GAMECODE('AXVP'), RIO_RTC }, | ||
{ GAMECODE('AXVI'), RIO_RTC }, | ||
{ GAMECODE('AXVS'), RIO_RTC }, | ||
{ GAMECODE('AXVD'), RIO_RTC }, | ||
{ GAMECODE('AXVF'), RIO_RTC }, | ||
|
||
// Pokemon Sapphire | ||
{ GAMECODE('AXPJ'), RIO_RTC }, | ||
{ GAMECODE('AXPE'), RIO_RTC }, | ||
{ GAMECODE('AXPP'), RIO_RTC }, | ||
{ GAMECODE('AXPI'), RIO_RTC }, | ||
{ GAMECODE('AXPS'), RIO_RTC }, | ||
{ GAMECODE('AXPD'), RIO_RTC }, | ||
{ GAMECODE('AXPF'), RIO_RTC }, | ||
|
||
// Pokemon Emerald | ||
{ GAMECODE('BPEJ'), RIO_RTC }, | ||
{ GAMECODE('BPEE'), RIO_RTC }, | ||
{ GAMECODE('BPEP'), RIO_RTC }, | ||
{ GAMECODE('BPEI'), RIO_RTC }, | ||
{ GAMECODE('BPES'), RIO_RTC }, | ||
{ GAMECODE('BPED'), RIO_RTC }, | ||
{ GAMECODE('BPEF'), RIO_RTC }, | ||
|
||
// RockMan EXE 4.5 - Real Operation | ||
{ GAMECODE('BR4J'), RIO_RTC }, | ||
|
||
// Sennen Kazoku | ||
{ GAMECODE('BKAJ'), RIO_RTC }, | ||
|
||
// Shin Bokura no Taiyou: Gyakushuu no Sabata | ||
{ GAMECODE('U33J'), RIO_RTC | RIO_LIGHT }, | ||
}; | ||
|
||
#define RIO_REG_DATA 0xC4 | ||
#define RIO_REG_DIRECTION 0xC6 | ||
#define RIO_REG_CONTROL 0xC8 | ||
|
||
static RomGpioHwMask sGpioHwMask; | ||
|
||
u16 gRioGpioData; | ||
u16 gRioGpioDirection; | ||
u16 gRioGpioControl; | ||
|
||
void rio_init(RomGpioHwMask forceHwMask) | ||
{ | ||
sGpioHwMask = forceHwMask; | ||
u32 gameCode = *(u32*)(MAIN_MEMORY_ADDRESS_ROM_DATA + 0xAC); | ||
for(int i = 0; i < sizeof(sGameHardwareTable) / sizeof(sGameHardwareTable[0]); i++) | ||
{ | ||
if(sGameHardwareTable[i].gameCode == gameCode) | ||
{ | ||
sGpioHwMask = sGameHardwareTable[i].hardware | forceHwMask; | ||
break; | ||
} | ||
} | ||
gRioGpioData = 0; | ||
gRioGpioDirection = 0; | ||
gRioGpioControl = 0; | ||
if(sGpioHwMask & RIO_RTC) | ||
rio_rtcInit(); | ||
} | ||
|
||
static void updateHardware() | ||
{ | ||
if(sGpioHwMask & RIO_RTC) | ||
rio_rtcUpdate(); | ||
} | ||
|
||
extern "C" void rio_write(u32 addr, u16 val) | ||
{ | ||
switch(addr - 0x08000000) | ||
{ | ||
case RIO_REG_DATA: | ||
gRioGpioData = (gRioGpioData & ~gRioGpioDirection) | (val & gRioGpioDirection); | ||
updateHardware(); | ||
break; | ||
case RIO_REG_DIRECTION: | ||
gRioGpioDirection = val & 0xF; | ||
break; | ||
case RIO_REG_CONTROL: | ||
gRioGpioControl = val & 1; | ||
break; | ||
} | ||
rio_invalidate(); | ||
} | ||
|
||
void rio_invalidate() | ||
{ | ||
if(gRioGpioControl) | ||
{ | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_DATA) = gRioGpioData; | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_DIRECTION) = gRioGpioDirection; | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_CONTROL) = gRioGpioControl; | ||
} | ||
else | ||
{ | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_DATA) = 0; | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_DIRECTION) = 0; | ||
*(u16*)(MAIN_MEMORY_ADDRESS_ROM_DATA + RIO_REG_CONTROL) = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
|
||
void rio_rtcInit(); | ||
void rio_rtcUpdate(); |
Oops, something went wrong.