From 6fd6c7af4675e97f9bcf677edf426b37998f9c13 Mon Sep 17 00:00:00 2001 From: KuroiIeWa5Da Date: Sat, 28 Jan 2012 00:38:49 -0600 Subject: big update after strip hg-commit-id: dcfb20faef4d --- music/pokeredmusicdisasm/Console.cpp | 2 +- music/pokeredmusicdisasm/Duty.h | 2 +- music/pokeredmusicdisasm/Makefile | 65 +++++++++++++++ music/pokeredmusicdisasm/Note.h | 70 ++++++++-------- music/pokeredmusicdisasm/Octave.h | 22 ++--- music/pokeredmusicdisasm/Parser.h | 32 +++---- music/pokeredmusicdisasm/README.txt | 22 +++++ music/pokeredmusicdisasm/Stop.cpp | 2 +- music/pokeredmusicdisasm/Tempo.cpp | 2 +- music/pokeredmusicdisasm/UnkCode.cpp | 12 --- music/pokeredmusicdisasm/UnkEB.cpp | 12 --- music/pokeredmusicdisasm/Volume.cpp | 2 +- music/pokeredwavptnvis/Console.cpp | 54 ++++++++++++ music/pokeredwavptnvis/Console.h | 29 +++++++ music/pokeredwavptnvis/Makefile | 18 ++++ music/pokeredwavptnvis/README.txt | 17 ++++ music/pokeredwavptnvis/main.cpp | 156 +++++++++++++++++++++++++++++++++++ 17 files changed, 428 insertions(+), 91 deletions(-) create mode 100644 music/pokeredmusicdisasm/Makefile create mode 100644 music/pokeredmusicdisasm/README.txt create mode 100644 music/pokeredwavptnvis/Console.cpp create mode 100644 music/pokeredwavptnvis/Console.h create mode 100644 music/pokeredwavptnvis/Makefile create mode 100644 music/pokeredwavptnvis/README.txt create mode 100644 music/pokeredwavptnvis/main.cpp diff --git a/music/pokeredmusicdisasm/Console.cpp b/music/pokeredmusicdisasm/Console.cpp index 85623210..84d5fab1 100644 --- a/music/pokeredmusicdisasm/Console.cpp +++ b/music/pokeredmusicdisasm/Console.cpp @@ -1,4 +1,4 @@ -#include "console.h" +#include "Console.h" using namespace std; diff --git a/music/pokeredmusicdisasm/Duty.h b/music/pokeredmusicdisasm/Duty.h index 42c58dd7..aa3f0d0d 100644 --- a/music/pokeredmusicdisasm/Duty.h +++ b/music/pokeredmusicdisasm/Duty.h @@ -25,7 +25,7 @@ public: // Custom Functions std::string LookupDutyString(); - const enum dutyList : unsigned char + enum dutyList : unsigned char { duty12_5 = 0x0, duty25 = 0x1, diff --git a/music/pokeredmusicdisasm/Makefile b/music/pokeredmusicdisasm/Makefile new file mode 100644 index 00000000..85c74288 --- /dev/null +++ b/music/pokeredmusicdisasm/Makefile @@ -0,0 +1,65 @@ + +OBJECTS = main.o Jump.o Modulation.o Note.o Octave.o Parser.o Stop.o \ +Tempo.o UnkCode.o UnkEB.o Velocity.o Volume.o Console.o AbstractData.o Call.o \ +Duty.o + +CC = g++ +CFLAGS = -std=c++0x + +pokeredmusicdisasm: $(OBJECTS) + $(CC) $(CFLAGS) $(OBJECTS) -o "../../extras/pokeredmusicdisasm.exe" + +Parser.o: Jump.h Modulation.h Note.h Octave.h Parser.h Stop.h \ +Tempo.h UnkCode.h UnkEB.h Velocity.h Volume.h + $(CC) $(CFLAGS) -c main.cpp Jump.cpp Modulation.cpp \ +Note.cpp Octave.cpp Parser.cpp Stop.cpp Tempo.cpp UnkCode.cpp UnkEB.cpp \ +Velocity.cpp Volume.cpp + +Duty.o: Duty.h AbstractData.h + $(CC) $(CFLAGS) -c Duty.cpp AbstractData.cpp + +Console.o: Console.h + $(CC) $(CFLAGS) -c Console.cpp + +AbstractData.o: AbstractData.h + $(CC) $(CFLAGS) -c AbstractData.cpp + +Call.o: Call.h Call.cpp AbstractData.h + $(CC) $(CFLAGS) -c Call.cpp AbstractData.cpp + +main.o: main.cpp Console.h Parser.h + $(CC) $(CFLAGS) -c main.cpp Console.cpp Parser.cpp + +Jump.o: Jump.h AbstractData.h + $(CC) $(CFLAGS) -c Jump.cpp AbstractData.cpp + +Modulation.o: Modulation.h AbstractData.h + $(CC) $(CFLAGS) -c Modulation.cpp AbstractData.cpp + +Note.o: Note.h AbstractData.h + $(CC) $(CFLAGS) -c Note.cpp AbstractData.cpp + +Octave.o: Octave.h AbstractData.h + $(CC) $(CFLAGS) -c Octave.cpp AbstractData.cpp + +Stop.o: Stop.h AbstractData.h + $(CC) $(CFLAGS) -c Stop.cpp AbstractData.cpp + +Tempo.o: Tempo.h AbstractData.h + $(CC) $(CFLAGS) -c Tempo.cpp AbstractData.cpp + +UnkCode.o: UnkCode.h AbstractData.h + $(CC) $(CFLAGS) -c UnkCode.cpp AbstractData.cpp + +UnkEB.o: UnkEB.h AbstractData.h + $(CC) $(CFLAGS) -c UnkEB.cpp AbstractData.cpp + +Velocity.o: Velocity.h AbstractData.h + $(CC) $(CFLAGS) -c Velocity.cpp AbstractData.cpp + +Volume.o: Volume.h AbstractData.h + $(CC) $(CFLAGS) -c Volume.cpp AbstractData.cpp + +clean: + rm *.o + rm ../../extras/pokeredmusicdisasm.exe diff --git a/music/pokeredmusicdisasm/Note.h b/music/pokeredmusicdisasm/Note.h index 73502683..599d66f7 100644 --- a/music/pokeredmusicdisasm/Note.h +++ b/music/pokeredmusicdisasm/Note.h @@ -29,42 +29,42 @@ public: std::string LookupPitchStr(); std::string LookupDelayStr(); - const enum pitch_code : unsigned char - { - noteC = 0x0, - noteCS = 0x1, - noteD = 0x2, - noteDS = 0x3, - noteE = 0x4, - noteF = 0x5, - noteFS = 0x6, - noteG = 0x7, - noteGS = 0x8, - noteA = 0x9, - noteAS = 0xA, - noteB = 0xB, - noteRst = 0xC - }; + enum pitch_code : unsigned char + { + noteC = 0x0, + noteCS = 0x1, + noteD = 0x2, + noteDS = 0x3, + noteE = 0x4, + noteF = 0x5, + noteFS = 0x6, + noteG = 0x7, + noteGS = 0x8, + noteA = 0x9, + noteAS = 0xA, + noteB = 0xB, + noteRst = 0xC + }; - const enum delay_code : unsigned char - { - note16 = 0x0, - note8 = 0x1, - note8_16 = 0x2, - note4 = 0x3, - note4_16 = 0x4, - note4_8 = 0x5, - note4_8_16 = 0x6, - note2 = 0x7, - note2_16 = 0x8, - note2_8 = 0x9, - note2_8_16 = 0xA, - note2_4 = 0xB, - note2_4_16 = 0xC, - note2_4_8 = 0xD, - note2_4_8_16 = 0xE, - note1 = 0xF - }; + enum delay_code : unsigned char + { + note16 = 0x0, + note8 = 0x1, + note8_16 = 0x2, + note4 = 0x3, + note4_16 = 0x4, + note4_8 = 0x5, + note4_8_16 = 0x6, + note2 = 0x7, + note2_16 = 0x8, + note2_8 = 0x9, + note2_8_16 = 0xA, + note2_4 = 0xB, + note2_4_16 = 0xC, + note2_4_8 = 0xD, + note2_4_8_16 = 0xE, + note1 = 0xF + }; private: unsigned char pitch; unsigned char delay; diff --git a/music/pokeredmusicdisasm/Octave.h b/music/pokeredmusicdisasm/Octave.h index b0e5764e..c51ea7b1 100644 --- a/music/pokeredmusicdisasm/Octave.h +++ b/music/pokeredmusicdisasm/Octave.h @@ -24,17 +24,17 @@ public: std::string LookupOctString(); - const enum OctaveCode : unsigned char - { - oct0 = 0xE7, - oct1 = 0xE6, - oct2 = 0xE5, - oct3 = 0xE4, - oct4 = 0xE3, - oct5 = 0xE2, - oct6 = 0xE1, - oct7 = 0xE0, - }; + enum OctaveCode : unsigned char + { + oct0 = 0xE7, + oct1 = 0xE6, + oct2 = 0xE5, + oct3 = 0xE4, + oct4 = 0xE3, + oct5 = 0xE2, + oct6 = 0xE1, + oct7 = 0xE0 + }; private: unsigned char octave; diff --git a/music/pokeredmusicdisasm/Parser.h b/music/pokeredmusicdisasm/Parser.h index 20af39a7..9630a519 100644 --- a/music/pokeredmusicdisasm/Parser.h +++ b/music/pokeredmusicdisasm/Parser.h @@ -54,22 +54,22 @@ public: template bool ParseData(unsigned int& pos, bool reado = false); - const enum dataType : unsigned char - { - DATA_NA, - DATA_CALL, - DATA_DUTY, - DATA_JUMP, - DATA_MODULATION, - DATA_NOTE, - DATA_OCTAVE, - DATA_STOP, - DATA_TEMPO, - DATA_UNKCODE, - DATA_UNKEB, - DATA_VELOCITY, - DATA_VOLUME - }; + enum dataType : unsigned char + { + DATA_NA, + DATA_CALL, + DATA_DUTY, + DATA_JUMP, + DATA_MODULATION, + DATA_NOTE, + DATA_OCTAVE, + DATA_STOP, + DATA_TEMPO, + DATA_UNKCODE, + DATA_UNKEB, + DATA_VELOCITY, + DATA_VOLUME + }; private: std::string filename; diff --git a/music/pokeredmusicdisasm/README.txt b/music/pokeredmusicdisasm/README.txt new file mode 100644 index 00000000..995f0e5f --- /dev/null +++ b/music/pokeredmusicdisasm/README.txt @@ -0,0 +1,22 @@ +to compile you must have g++ installed +type: make +and it will install to the extras folder + +if you want to unmake +type: make clean +and it will remove make objects and the executable + +the program usage is: pokeredmusicdisasm [ [ | --] [--stop] +offset is the rom offset in hexidecimal (FFFF or 0xFFFF) +file is the rom file, you can use -- for "../baserom.gbc" +--stop is the hexidecimal stop number + +to make things quick and easy you can just enter the hexidecimal offset +pokeredmusicdisasm + +to use the stop parameter you must use it as the 3rd argument as below +pokeredmusicdisasm -- --stop=FFFF +pokeredmusicdisasm --stop=FFFF + +you may enter limited interactive mode by not supplying any arguments +pokeredmusicdisasm \ No newline at end of file diff --git a/music/pokeredmusicdisasm/Stop.cpp b/music/pokeredmusicdisasm/Stop.cpp index c0a0a2ff..de6aa062 100644 --- a/music/pokeredmusicdisasm/Stop.cpp +++ b/music/pokeredmusicdisasm/Stop.cpp @@ -27,7 +27,7 @@ bool Stop::IsValid(unsigned char* byte) string Stop::GenAsm() { string tmpRet = AbstractData::GenAsm(); - if(tmpRet != "") return false; + if(tmpRet != "") return tmpRet; stringstream tmpAsmOut; tmpAsmOut << "mus_end"; diff --git a/music/pokeredmusicdisasm/Tempo.cpp b/music/pokeredmusicdisasm/Tempo.cpp index b981579f..a41de4a8 100644 --- a/music/pokeredmusicdisasm/Tempo.cpp +++ b/music/pokeredmusicdisasm/Tempo.cpp @@ -56,7 +56,7 @@ bool Tempo::IsValid(unsigned char* byte) string Tempo::GenAsm() { string tmpRet = AbstractData::GenAsm(); - if(tmpRet != "") return false; + if(tmpRet != "") return tmpRet; stringstream tmpAsmOut; tmpAsmOut << "mus_tempo" << " " << (short)divider << ", " << (short)modifier; diff --git a/music/pokeredmusicdisasm/UnkCode.cpp b/music/pokeredmusicdisasm/UnkCode.cpp index 93c74f66..da3cd02f 100644 --- a/music/pokeredmusicdisasm/UnkCode.cpp +++ b/music/pokeredmusicdisasm/UnkCode.cpp @@ -1,16 +1,4 @@ #include - -#include "Call.h" -#include "Duty.h" -#include "Jump.h" -#include "Modulation.h" -#include "Note.h" -#include "Octave.h" -#include "Stop.h" -#include "Tempo.h" -#include "Velocity.h" -#include "Volume.h" - #include "UnkCode.h" using namespace std; diff --git a/music/pokeredmusicdisasm/UnkEB.cpp b/music/pokeredmusicdisasm/UnkEB.cpp index c8db595f..39007f30 100644 --- a/music/pokeredmusicdisasm/UnkEB.cpp +++ b/music/pokeredmusicdisasm/UnkEB.cpp @@ -1,16 +1,4 @@ #include - -#include "Call.h" -#include "Duty.h" -#include "Jump.h" -#include "Modulation.h" -#include "Note.h" -#include "Octave.h" -#include "Stop.h" -#include "Tempo.h" -#include "Velocity.h" -#include "Volume.h" - #include "UnkEB.h" using namespace std; diff --git a/music/pokeredmusicdisasm/Volume.cpp b/music/pokeredmusicdisasm/Volume.cpp index 3c717f0e..a0c2d192 100644 --- a/music/pokeredmusicdisasm/Volume.cpp +++ b/music/pokeredmusicdisasm/Volume.cpp @@ -44,7 +44,7 @@ bool Volume::IsValid(unsigned char* byte) string Volume::GenAsm() { string tmpRet = AbstractData::GenAsm(); - if(tmpRet != "") return false; + if(tmpRet != "") return tmpRet; stringstream tmpAsmOut; tmpAsmOut << "mus_volume" << " " << (short)volume; diff --git a/music/pokeredwavptnvis/Console.cpp b/music/pokeredwavptnvis/Console.cpp new file mode 100644 index 00000000..84d5fab1 --- /dev/null +++ b/music/pokeredwavptnvis/Console.cpp @@ -0,0 +1,54 @@ +#include "Console.h" + +using namespace std; + +// Basic +void Console::Get(char* value) +{ + cin >> value; +} +void Console::Get(string& value) +{ + cin >> value; +} +void Console::Print(const char* value) +{ + cout << value; +} +void Console::Error(const char* value) +{ + cerr << value; +} + +// Upper-Basic +void Console::PrintLn(const char* value) +{ + Print(value); + cout << endl; +} +void Console::ErrorLn(const char* value) +{ + Error(value); + cerr << endl; +} + +// Higher +void Console::Ask(const char* question, char* answer) +{ + Print(question); + Get(answer); +} +void Console::Ask(const char* question, string& answer) +{ + Print(question); + Get(answer); +} + +// Better Error Handling +int Console::atoi_ex(const char* input, bool supress) +{ + int convInp = atoi(input); + if((supress == false) && (convInp == 0)) + PrintLn("Warning: the converted integer input is 0, this may not be what you intended"); + return convInp; +} diff --git a/music/pokeredwavptnvis/Console.h b/music/pokeredwavptnvis/Console.h new file mode 100644 index 00000000..c6fe1833 --- /dev/null +++ b/music/pokeredwavptnvis/Console.h @@ -0,0 +1,29 @@ +#ifndef CONSOLE_H +#define CONSOLE_H + +#include +#include + +// Just a Console Utility Library +class Console +{ +public: + // Basic + static void Get(char* value); + static void Get(std::string& value); + static void Print(const char* value); + static void Error(const char* value); + + // Upper-Basic + static void PrintLn(const char* value); + static void ErrorLn(const char* value); + + // Higher + static void Ask(const char* question, char* answer); + static void Ask(const char* question, std::string& answer); + + // Better Error Handling + static int atoi_ex(const char* input, bool supress = false); +}; + +#endif // CONSOLE_H diff --git a/music/pokeredwavptnvis/Makefile b/music/pokeredwavptnvis/Makefile new file mode 100644 index 00000000..2b211675 --- /dev/null +++ b/music/pokeredwavptnvis/Makefile @@ -0,0 +1,18 @@ + +OBJECTS = Console.o main.o + +CC = g++ +CFLAGS = -std=c++0x + +pokeredwavptnvis: $(OBJECTS) + $(CC) $(CFLAGS) $(OBJECTS) -o "../../extras/pokeredwavptnvis.exe" + +Console.o: Console.h + $(CC) $(CFLAGS) -c Console.cpp + +main.o: main.cpp Console.h + $(CC) $(CFLAGS) -c main.cpp Console.cpp + +clean: + rm *.o + rm ../../extras/pokeredwavptnvis.exe diff --git a/music/pokeredwavptnvis/README.txt b/music/pokeredwavptnvis/README.txt new file mode 100644 index 00000000..dff29542 --- /dev/null +++ b/music/pokeredwavptnvis/README.txt @@ -0,0 +1,17 @@ +to compile you must have g++ installed +type: make +and it will install to the extras folder + +if you want to unmake +type: make clean +and it will remove make objects and the executable + +the program usage is: pokeredwavptnvis [ [ | --] +offset is the rom offset in hexidecimal (FFFF or 0xFFFF) +file is the rom file, you can use -- for "../baserom.gbc" + +to make things quick and easy you can just enter the hexidecimal offset +pokeredwavptnvis + +you may enter limited interactive mode by not supplying any arguments +pokeredwavptnvis \ No newline at end of file diff --git a/music/pokeredwavptnvis/main.cpp b/music/pokeredwavptnvis/main.cpp new file mode 100644 index 00000000..035daef5 --- /dev/null +++ b/music/pokeredwavptnvis/main.cpp @@ -0,0 +1,156 @@ +#include +#include +#include +#include + +#include "Console.h" + +using namespace std; + +char* rawBytes = 0; +unsigned int fileLength = 0; + +void Read(const char* filename) +{ + // open File + fstream tmpFile(filename, ios_base::in | ios_base::binary); + + // Get Length + tmpFile.seekg(0, ios::end); + fileLength = tmpFile.tellg(); + tmpFile.seekg(0, ios::beg); + + // Allocate proper memory + rawBytes = new char[fileLength]; + + // Read filedata + tmpFile.read(rawBytes, fileLength); + tmpFile.close(); +} + +unsigned char GetNibble(unsigned char byte, bool high) +{ + if(high) + { + unsigned char tmp = byte & 0xF0; + tmp >>= 4; + return tmp; + } + else + { + unsigned char tmp = byte & 0x0F; + return tmp; + } +} + +// Usage: pokeredwavptnvis [ [ | --]] +// If no parameters or a parameter is missing the program enters limited interactive mode +int main(int argc, char** argv) +{ + const unsigned char parameters = 2; + const unsigned char self = 1; + const unsigned char _max_argc = parameters + self; + const string defFileLoc = "../baserom.gbc"; + + string arg1; // Offset + string arg2; // File or "--" (if "--" then the file is assumed) + + string paramStopAddr; + + if(argc >= _max_argc) + { + arg1 = argv[1]; + arg2 = argv[2]; + } + else if(argc == (_max_argc - 1)) + { + arg1 = argv[1]; + arg2 = defFileLoc; + } + + if(arg1 == "") Console::Ask("What offset in the file in hex: ", arg1); + if(arg2 == "") Console::Ask("What file: ", arg2); + if(arg2 == "--") arg2 = defFileLoc; // You can also put "--" for the default file location + + stringstream arg1Conv; + unsigned int arg1ConvNum; + arg1Conv << arg1; + arg1Conv << hex; + arg1Conv >> arg1ConvNum; + + Read(arg2.c_str()); + unsigned char* rawBytesFixed = (unsigned char*)rawBytes; + + // All the loading is done, create a 32x16 vector + vector> image; + vector lines; // This is the array of output lines + + // Initialize the vector image[x][y] and lines + for(unsigned char i = 0; i < 32; i++) + { + image.push_back(vector()); + + for(unsigned char j = 0; j < 16; j++) + { + image[i].push_back(false); + lines.push_back(""); + } + } + + unsigned char n1 = 0; + unsigned char n2 = 0; + + vector expBytes; + for(unsigned char i = 0; i < 16; i++) + { + n1 = GetNibble(rawBytesFixed[arg1ConvNum + i], true); + n2 = GetNibble(rawBytesFixed[arg1ConvNum + i], false); + + expBytes.push_back(n1); + expBytes.push_back(n2); + } + + // Go through each column in the vector and add a 1 on the appropiate line + for(unsigned char i = 0; i < 32; i++) + { + unsigned char _tmpVal = expBytes[i]; // Here for debugging reasons + image[i][_tmpVal] = true; + } + + // Now draw the image + for(unsigned char i = 0; i < 32; i++) + { + for(unsigned char j = 0; j < 16; j++) + { + if(i == 0) + { + if(image[i][j]) lines[j].append("|*"); + else lines[j].append("| "); + } + else if((i > 0) && (i < 31)) + { + if(image[i][j]) lines[j].append(".*"); + else lines[j].append(". "); + } + else + { + if(image[i][j]) lines[j].append(".*|"); + else lines[j].append(". |"); + } + } + } + + // Now output the drawn lines (mirrored) + stringstream tmpCtr; + Console::PrintLn(" 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F"); + Console::PrintLn(" ---------------------------------------------------------------"); + for(unsigned char i = 0xF; (i >= 0x0) && (i < 0x10); i--) + { + tmpCtr << hex << uppercase << (short)i; + Console::Print(tmpCtr.str().c_str()); + Console::PrintLn(lines[i].c_str()); + tmpCtr.str(""); + } + + return 0; +} \ No newline at end of file -- cgit v1.2.3