00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __WITHSOUND //enable or disable sound easily
00027 #define __WITHSOUND
00028
00029
00030
00031 #endif
00032
00033 #ifndef __WITHSAVING //enable or disable SRAM support
00034 #define __WITHSAVING
00035 #endif
00036
00038 #define OFFX -50
00040 #define OFFY -256
00041
00042 #ifdef __MDDEBUG
00044 #define LOGPOS 1
00046 #define ERRORPOS 4
00048 #define ERRTEXT "ERR"
00049 #endif
00050
00051 #ifndef _MDUELMACROS_
00052 #define _MDUELMACROS_
00053
00054 #include <PA9.h>
00055 #include <string>
00056 using namespace std;
00057
00058 #ifdef __MDDEBUG
00059 #include <fstream>
00060 #include <fat.h>
00061 #define LOGFILE "mduelLog.txt"
00062 #endif
00063
00071 namespace macros
00072 {
00073 #ifdef __MDDEBUG
00074
00084 inline string debugMessage(string className, string outText, u8 yPos = LOGPOS)
00085 {
00086 string ret = className+string(": ")+outText+string(" \n");
00087
00088 if (yPos == LOGPOS)
00089 {
00090 FILE* logFile = fopen(LOGFILE, "a+");
00091 if (logFile)
00092 fprintf(logFile, ret.c_str());
00093 else
00094 PA_OutputText(0, 0, 0, const_cast<char *>(ret.c_str()));
00095 fclose(logFile);
00096 } else {
00097 PA_OutputText(0, 0, yPos, const_cast<char *>(ret.c_str()));
00098
00099 if (className == ERRTEXT && yPos == ERRORPOS)
00100 PA_WaitFor(Stylus.Newpress);
00101 }
00102
00103 return ret;
00104 }
00105 #endif
00106
00114 inline string getPlayerName(u8 playerNum, string playerNames, bool leftPadding = true)
00115 {
00116 playerNum -= 1;
00117 string ret;
00118 for (u8 i=playerNum*8; i < (playerNum+1)*8; ++i)
00119 ret += playerNames[i];
00120
00121 if (leftPadding)
00122 {
00123 if (playerNum >= 4)
00124 {
00125 while (ret.at(ret.length()-1) == ' ')
00126 {
00127 for (s8 i=ret.length()-2; i>=0; i--)
00128 ret.at(i+1) = ret.at(i);
00129 ret.at(0) = ' ';
00130 }
00131 }
00132 }
00133 return ret;
00134 }
00135 };
00136
00137 #endif