dev9null reformat

This commit is contained in:
Clang Format 2016-08-24 23:16:38 +02:00 committed by Gregory Hainaut
parent e3a2ad03bc
commit e61d14168a
4 changed files with 207 additions and 187 deletions

View File

@ -28,24 +28,23 @@ PluginConf Ini;
void setLoggingState() void setLoggingState()
{ {
if (conf.Log) if (conf.Log) {
{
Dev9Log.WriteToConsole = true; Dev9Log.WriteToConsole = true;
Dev9Log.WriteToFile = true; Dev9Log.WriteToFile = true;
} } else {
else
{
Dev9Log.WriteToConsole = false; Dev9Log.WriteToConsole = false;
Dev9Log.WriteToFile = false; Dev9Log.WriteToFile = false;
} }
} }
EXPORT_C_(void) DEV9about() EXPORT_C_(void)
DEV9about()
{ {
SysMessage("Dev9null: A simple null plugin."); SysMessage("Dev9null: A simple null plugin.");
} }
EXPORT_C_(void) DEV9configure() EXPORT_C_(void)
DEV9configure()
{ {
LoadConfig(); LoadConfig();
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
@ -55,22 +54,20 @@ EXPORT_C_(void) DEV9configure()
void LoadConfig() void LoadConfig()
{ {
string IniPath = s_strIniPath + "/Dev9null.ini"; string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, READ_FILE)) if (!Ini.Open(IniPath, READ_FILE)) {
{
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
SaveConfig(); SaveConfig();
return; return;
} }
conf.Log = Ini.ReadInt("logging",0); conf.Log = Ini.ReadInt("logging", 0);
Ini.Close(); Ini.Close();
} }
void SaveConfig() void SaveConfig()
{ {
string IniPath = s_strIniPath + "/Dev9null.ini"; string IniPath = s_strIniPath + "/Dev9null.ini";
if (!Ini.Open(IniPath, WRITE_FILE)) if (!Ini.Open(IniPath, WRITE_FILE)) {
{
Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); Dev9Log.WriteLn("Failed to open %s", IniPath.c_str());
return; return;
} }
@ -78,4 +75,3 @@ void SaveConfig()
Ini.WriteInt("logging", conf.Log); Ini.WriteInt("logging", conf.Log);
Ini.Close(); Ini.Close();
} }

View File

@ -18,7 +18,7 @@
void SaveConfig(); void SaveConfig();
void LoadConfig(); void LoadConfig();
void SysMessage(char *fmt, ...); void SysMessage(char* fmt, ...);
//#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)))) //#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
//#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) //#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)

View File

@ -48,7 +48,7 @@ void (*DEV9irq)(int);
__aligned16 s8 dev9regs[0x10000]; __aligned16 s8 dev9regs[0x10000];
string s_strIniPath = "inis"; string s_strIniPath = "inis";
string s_strLogPath="logs"; string s_strLogPath = "logs";
PluginLog Dev9Log; PluginLog Dev9Log;
Config conf; Config conf;
@ -60,33 +60,38 @@ void LogInit()
Dev9Log.Open(LogFile); Dev9Log.Open(LogFile);
} }
EXPORT_C_(void) DEV9setLogDir(const char* dir) EXPORT_C_(void)
DEV9setLogDir(const char* dir)
{ {
// Get the path to the log directory. // Get the path to the log directory.
s_strLogPath = (dir==NULL) ? "logs" : dir; s_strLogPath = (dir == NULL) ? "logs" : dir;
// Reload the log file after updated the path // Reload the log file after updated the path
Dev9Log.Close(); Dev9Log.Close();
LogInit(); LogInit();
} }
EXPORT_C_(u32) PS2EgetLibType() EXPORT_C_(u32)
PS2EgetLibType()
{ {
return PS2E_LT_DEV9; return PS2E_LT_DEV9;
} }
EXPORT_C_(char*) PS2EgetLibName() EXPORT_C_(char*)
PS2EgetLibName()
{ {
snprintf( libraryName, 255, "DEV9null Driver %lld%s",SVN_REV, SVN_MODS ? "m" : ""); snprintf(libraryName, 255, "DEV9null Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
return libraryName; return libraryName;
} }
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type) EXPORT_C_(u32)
PS2EgetLibVersion2(u32 type)
{ {
return (version<<16) | (revision<<8) | build; return (version << 16) | (revision << 8) | build;
} }
EXPORT_C_(s32) DEV9init() EXPORT_C_(s32)
DEV9init()
{ {
LoadConfig(); LoadConfig();
setLoggingState(); setLoggingState();
@ -98,13 +103,15 @@ EXPORT_C_(s32) DEV9init()
return 0; return 0;
} }
EXPORT_C_(void) DEV9shutdown() EXPORT_C_(void)
DEV9shutdown()
{ {
Dev9Log.WriteLn("Shutting down Dev9null."); Dev9Log.WriteLn("Shutting down Dev9null.");
Dev9Log.Close(); Dev9Log.Close();
} }
EXPORT_C_(s32) DEV9open(void *pDsp) EXPORT_C_(s32)
DEV9open(void* pDsp)
{ {
Dev9Log.WriteLn("Opening Dev9null."); Dev9Log.WriteLn("Opening Dev9null.");
// Get anything ready we need to. Opening and creating hard // Get anything ready we need to. Opening and creating hard
@ -112,20 +119,22 @@ EXPORT_C_(s32) DEV9open(void *pDsp)
return 0; return 0;
} }
EXPORT_C_(void) DEV9close() EXPORT_C_(void)
DEV9close()
{ {
Dev9Log.WriteLn("Closing Dev9null."); Dev9Log.WriteLn("Closing Dev9null.");
// Close files opened. // Close files opened.
} }
EXPORT_C_(u8) DEV9read8(u32 addr) EXPORT_C_(u8)
DEV9read8(u32 addr)
{ {
u8 value = 0; u8 value = 0;
switch(addr) switch (addr) {
{ // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) case 0x10000038: /*value = dev9Ru8(addr);*/
case 0x10000038: /*value = dev9Ru8(addr);*/ break; // We need to have at least one case to avoid warnings. break; // We need to have at least one case to avoid warnings.
default: default:
//value = dev9Ru8(addr); //value = dev9Ru8(addr);
Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr); Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr);
@ -134,30 +143,31 @@ EXPORT_C_(u8) DEV9read8(u32 addr)
return value; return value;
} }
EXPORT_C_(u16) DEV9read16(u32 addr) EXPORT_C_(u16)
DEV9read16(u32 addr)
{ {
u16 value = 0; u16 value = 0;
switch(addr) switch (addr) {
{
// Addresses you may want to catch here include: // Addresses you may want to catch here include:
// case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay) // case 0x1F80146E: // DEV9 hardware type (0x32 for an expansion bay)
// case 0x10000002: // The Smart Chip revision. Should be 0x11 // case 0x10000002: // The Smart Chip revision. Should be 0x11
// case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash // case 0x10000004: // More type info: bit 0 - smap; bit 1 - hd; bit 5 - flash
// case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up. // case 0x1000000E: // Similar to the last; bit 1 should be set if a hd is hooked up.
// case 0x10000028: // intr_stat // case 0x10000028: // intr_stat
// case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here. // case 0x10000038: // hard drives seem to like reading and writing the max dma size per transfer here.
// case 0x1000002A: // intr_mask // case 0x1000002A: // intr_mask
// case 0x10000040: // pio_data // case 0x10000040: // pio_data
// case 0x10000044: // nsector // case 0x10000044: // nsector
// case 0x10000046: // sector // case 0x10000046: // sector
// case 0x10000048: // lcyl // case 0x10000048: // lcyl
// case 0x1000004A: // hcyl // case 0x1000004A: // hcyl
// case 0x1000004C: // select // case 0x1000004C: // select
// case 0x1000004E: // status // case 0x1000004E: // status
// case 0x1000005C: // status // case 0x1000005C: // status
// case 0x10000064: // if_ctrl // case 0x10000064: // if_ctrl
case 0x10000038: /*value = dev9Ru16(addr);*/ break; case 0x10000038: /*value = dev9Ru16(addr);*/
break;
default: default:
//value = dev9Ru16(addr); //value = dev9Ru16(addr);
Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr); Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr);
@ -167,13 +177,14 @@ EXPORT_C_(u16) DEV9read16(u32 addr)
return value; return value;
} }
EXPORT_C_(u32 ) DEV9read32(u32 addr) EXPORT_C_(u32)
DEV9read32(u32 addr)
{ {
u32 value = 0; u32 value = 0;
switch(addr) switch (addr) {
{ case 0x10000038: /*value = dev9Ru32(addr);*/
case 0x10000038: /*value = dev9Ru32(addr);*/ break; break;
default: default:
//value = dev9Ru32(addr); //value = dev9Ru32(addr);
Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr); Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr);
@ -183,11 +194,12 @@ EXPORT_C_(u32 ) DEV9read32(u32 addr)
return value; return value;
} }
EXPORT_C_(void) DEV9write8(u32 addr, u8 value) EXPORT_C_(void)
DEV9write8(u32 addr, u8 value)
{ {
switch(addr) switch (addr) {
{ case 0x10000038: /*dev9Ru8(addr) = value;*/
case 0x10000038: /*dev9Ru8(addr) = value;*/ break; break;
default: default:
Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value);
//dev9Ru8(addr) = value; //dev9Ru8(addr) = value;
@ -195,13 +207,14 @@ EXPORT_C_(void) DEV9write8(u32 addr, u8 value)
} }
} }
EXPORT_C_(void) DEV9write16(u32 addr, u16 value) EXPORT_C_(void)
DEV9write16(u32 addr, u16 value)
{ {
switch(addr) switch (addr) {
{
// Remember that list on DEV9read16? You'll want to write to a // Remember that list on DEV9read16? You'll want to write to a
// lot of them, too. // lot of them, too.
case 0x10000038: /*dev9Ru16(addr) = value;*/ break; case 0x10000038: /*dev9Ru16(addr) = value;*/
break;
default: default:
Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value);
//dev9Ru16(addr) = value; //dev9Ru16(addr) = value;
@ -209,11 +222,12 @@ EXPORT_C_(void) DEV9write16(u32 addr, u16 value)
} }
} }
EXPORT_C_(void) DEV9write32(u32 addr, u32 value) EXPORT_C_(void)
DEV9write32(u32 addr, u32 value)
{ {
switch(addr) switch (addr) {
{ case 0x10000038: /*dev9Ru32(addr) = value;*/
case 0x10000038: /*dev9Ru32(addr) = value;*/ break; break;
default: default:
Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value);
//dev9Ru32(addr) = value; //dev9Ru32(addr) = value;
@ -222,7 +236,8 @@ EXPORT_C_(void) DEV9write32(u32 addr, u32 value)
} }
//#ifdef ENABLE_NEW_IOPDMA_DEV9 //#ifdef ENABLE_NEW_IOPDMA_DEV9
EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) EXPORT_C_(s32)
DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
{ {
// You'll want to put your own DMA8 reading code here. // You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware. // Time to interact with your fake (or real) hardware.
@ -231,7 +246,8 @@ EXPORT_C_(s32) DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProc
return 0; return 0;
} }
EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed) EXPORT_C_(s32)
DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
{ {
// See above. // See above.
Dev9Log.WriteLn("Writing DMA8 Mem."); Dev9Log.WriteLn("Writing DMA8 Mem.");
@ -239,26 +255,30 @@ EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesPro
return 0; return 0;
} }
EXPORT_C_(void) DEV9dmaInterrupt(s32 channel) EXPORT_C_(void)
DEV9dmaInterrupt(s32 channel)
{ {
// See above. // See above.
} }
//#else //#else
EXPORT_C_(void) DEV9readDMA8Mem(u32 *pMem, int size) EXPORT_C_(void)
DEV9readDMA8Mem(u32* pMem, int size)
{ {
// You'll want to put your own DMA8 reading code here. // You'll want to put your own DMA8 reading code here.
// Time to interact with your fake (or real) hardware. // Time to interact with your fake (or real) hardware.
Dev9Log.WriteLn("Reading DMA8 Mem."); Dev9Log.WriteLn("Reading DMA8 Mem.");
} }
EXPORT_C_(void) DEV9writeDMA8Mem(u32* pMem, int size) EXPORT_C_(void)
DEV9writeDMA8Mem(u32* pMem, int size)
{ {
// See above. // See above.
Dev9Log.WriteLn("Writing DMA8 Mem."); Dev9Log.WriteLn("Writing DMA8 Mem.");
} }
//#endif //#endif
EXPORT_C_(void) DEV9irqCallback(DEV9callback callback) EXPORT_C_(void)
DEV9irqCallback(DEV9callback callback)
{ {
// Setting our callback. You will call it with DEV9irq(cycles), // Setting our callback. You will call it with DEV9irq(cycles),
// Where cycles is the number of cycles till the irq is triggered. // Where cycles is the number of cycles till the irq is triggered.
@ -271,13 +291,15 @@ int _DEV9irqHandler(void)
return 0; return 0;
} }
EXPORT_C_(DEV9handler) DEV9irqHandler(void) EXPORT_C_(DEV9handler)
DEV9irqHandler(void)
{ {
// Pass it to pcsx2. // Pass it to pcsx2.
return (DEV9handler)_DEV9irqHandler; return (DEV9handler)_DEV9irqHandler;
} }
EXPORT_C_(void) DEV9setSettingsDir(const char* dir) EXPORT_C_(void)
DEV9setSettingsDir(const char* dir)
{ {
// Grab the ini directory. // Grab the ini directory.
s_strIniPath = (dir == NULL) ? "inis" : dir; s_strIniPath = (dir == NULL) ? "inis" : dir;
@ -285,17 +307,18 @@ EXPORT_C_(void) DEV9setSettingsDir(const char* dir)
// extended funcs // extended funcs
EXPORT_C_(s32) DEV9test() EXPORT_C_(s32)
DEV9test()
{ {
return 0; return 0;
} }
EXPORT_C_(s32) DEV9freeze(int mode, freezeData *data) EXPORT_C_(s32)
DEV9freeze(int mode, freezeData* data)
{ {
// This should store or retrieve any information, for if emulation // This should store or retrieve any information, for if emulation
// gets suspended, or for savestates. // gets suspended, or for savestates.
switch(mode) switch (mode) {
{
case FREEZE_LOAD: case FREEZE_LOAD:
// Load previously saved data. // Load previously saved data.
break; break;

View File

@ -25,7 +25,8 @@
#include "PS2Edefs.h" #include "PS2Edefs.h"
#include "PS2Eext.h" #include "PS2Eext.h"
typedef struct { typedef struct
{
s32 Log; s32 Log;
} Config; } Config;
@ -42,12 +43,12 @@ void LoadConfig();
extern void (*DEV9irq)(int); extern void (*DEV9irq)(int);
extern __aligned16 s8 dev9regs[0x10000]; extern __aligned16 s8 dev9regs[0x10000];
#define dev9Rs8(mem) dev9regs[(mem) & 0xffff] #define dev9Rs8(mem) dev9regs[(mem)&0xffff]
#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem) & 0xffff]) #define dev9Rs16(mem) (*(s16*)&dev9regs[(mem)&0xffff])
#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem) & 0xffff]) #define dev9Rs32(mem) (*(s32*)&dev9regs[(mem)&0xffff])
#define dev9Ru8(mem) (*(u8*) &dev9regs[(mem) & 0xffff]) #define dev9Ru8(mem) (*(u8*)&dev9regs[(mem)&0xffff])
#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem) & 0xffff]) #define dev9Ru16(mem) (*(u16*)&dev9regs[(mem)&0xffff])
#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem) & 0xffff]) #define dev9Ru32(mem) (*(u32*)&dev9regs[(mem)&0xffff])
extern void setLoggingState(); extern void setLoggingState();