mirror of https://github.com/zeldaret/tmc.git
Fix clang warnings and remove remaining baserom references
This commit is contained in:
parent
74e416b578
commit
db763950bb
46
Makefile
46
Makefile
|
@ -272,49 +272,3 @@ demo_usa: ; @$(MAKE) GAME_VERSION=DEMO_USA
|
|||
jp: ; @$(MAKE) GAME_VERSION=JP
|
||||
demo_jp: ; @$(MAKE) GAME_VERSION=DEMO_JP
|
||||
eu: ; @$(MAKE) GAME_VERSION=EU
|
||||
|
||||
ifeq ($(GAME_VERSION), USA)
|
||||
baserom.gba:
|
||||
$(error "You need to provide a USA ROM as baserom.gba")
|
||||
.PHONY: baserom_demo.gba baserom_jp.gba baserom_eu.gba baserom_demo_jp.gba
|
||||
baserom_demo.gba:
|
||||
baserom_jp.gba:
|
||||
baserom_eu.gba:
|
||||
baserom_demo_jp.gba:
|
||||
endif
|
||||
ifeq ($(GAME_VERSION), DEMO_USA)
|
||||
baserom_demo.gba:
|
||||
$(error "You need to provide a DEMO ROM as baserom_demo.gba")
|
||||
.PHONY: baserom_jp.gba baserom_eu.gba baserom.gba baserom_demo_jp.gba
|
||||
baserom.gba:
|
||||
baserom_jp.gba:
|
||||
baserom_eu.gba:
|
||||
baserom_demo_jp.gba:
|
||||
endif
|
||||
ifeq ($(GAME_VERSION), JP)
|
||||
baserom_jp.gba:
|
||||
$(error "You need to provide a JP ROM as baserom_jp.gba")
|
||||
.PHONY: baserom_demo.gba baserom_eu.gba baserom.gba baserom_demo_jp.gba
|
||||
baserom.gba:
|
||||
baserom_demo.gba:
|
||||
baserom_eu.gba:
|
||||
baserom_demo_jp.gba:
|
||||
endif
|
||||
ifeq ($(GAME_VERSION), DEMO_JP)
|
||||
baserom_demo_jp.gba:
|
||||
$(error "You need to provide a DEMO JP ROM as baserom_demo_jp.gba")
|
||||
.PHONY: baserom_jp.gba baserom_eu.gba baserom.gba baserom_demo.gba
|
||||
baserom.gba:
|
||||
baserom_jp.gba:
|
||||
baserom_eu.gba:
|
||||
baserom_demo.gba:
|
||||
endif
|
||||
ifeq ($(GAME_VERSION), EU)
|
||||
baserom_eu.gba:
|
||||
$(error "You need to provide a EU ROM as baserom_eu.gba")
|
||||
.PHONY: baserom_demo.gba baserom.gba baserom_jp.gba baserom_demo_jp.gba
|
||||
baserom.gba:
|
||||
baserom_jp.gba:
|
||||
baserom_demo.gba:
|
||||
baserom_demo_jp.gba:
|
||||
endif
|
||||
|
|
|
@ -21023,6 +21023,21 @@
|
|||
"start": 752492,
|
||||
"size": 8
|
||||
},
|
||||
{
|
||||
"path": "data_080B7B74/gCollisionMtx.bin",
|
||||
"start": 752500,
|
||||
"size": 1210
|
||||
},
|
||||
{
|
||||
"path": "data_080B7B74/gUnk_080B802E.bin",
|
||||
"start": 753710,
|
||||
"size": 8850
|
||||
},
|
||||
{
|
||||
"path": "data_080B7B74/gUnk_080BA2C0.bin",
|
||||
"start": 762560,
|
||||
"size": 4064
|
||||
},
|
||||
{
|
||||
"path": "data_080B7B74/gUnk_080B7B74_1_EU.bin",
|
||||
"variants": [
|
||||
|
@ -42724,6 +42739,36 @@
|
|||
"start": 1164390,
|
||||
"size": 34
|
||||
},
|
||||
{
|
||||
"path": "demo/save1.bin",
|
||||
"starts": {
|
||||
"DEMO_USA": 1171472
|
||||
},
|
||||
"size": 1280,
|
||||
"variants": [
|
||||
"DEMO_USA"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "demo/save2.bin",
|
||||
"starts": {
|
||||
"DEMO_USA": 1172752
|
||||
},
|
||||
"size": 1280,
|
||||
"variants": [
|
||||
"DEMO_USA"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "demo/save3.bin",
|
||||
"starts": {
|
||||
"DEMO_USA": 1174032
|
||||
},
|
||||
"size": 1280,
|
||||
"variants": [
|
||||
"DEMO_USA"
|
||||
]
|
||||
},
|
||||
{
|
||||
"offsets": {
|
||||
"DEMO_USA": 2572,
|
||||
|
@ -48401,6 +48446,12 @@
|
|||
"size": 60,
|
||||
"type": "animation"
|
||||
},
|
||||
{
|
||||
"path": "animations/gSpriteAnimations_TorchTrapProjectile_0_0.bin",
|
||||
"start": 1221600,
|
||||
"size": 20,
|
||||
"type": "animation"
|
||||
},
|
||||
{
|
||||
"path": "animations/gSpriteAnimations_TorchTrapProjectile_1_0.bin",
|
||||
"start": 1221628,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.align 2
|
||||
|
||||
gSpriteAnimations_TorchTrapProjectile_0_0:: @ 0812A3E0
|
||||
.incbin "baserom.gba", 0x12A3E0, 0x0000014
|
||||
.include "animations/gSpriteAnimations_TorchTrapProjectile_0_0.s"
|
||||
|
||||
gSpriteAnimations_TorchTrapProjectile_0:: @ 0812A3F4
|
||||
.4byte gSpriteAnimations_TorchTrapProjectile_0_0
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
.align 2
|
||||
|
||||
gCollisionMtx:: @ 080B7B74
|
||||
.incbin "baserom.gba", 0x0B7B74, 0x00004BA
|
||||
.incbin "data_080B7B74/gCollisionMtx.bin"
|
||||
|
||||
gUnk_080B802E:: @ 080B802E
|
||||
.incbin "baserom.gba", 0x0B802E, 0x0002292
|
||||
.incbin "data_080B7B74/gUnk_080B802E.bin"
|
||||
|
||||
gUnk_080BA2C0:: @ 080BA2C0
|
||||
.incbin "baserom.gba", 0x0BA2C0, 0x0000FE0
|
||||
.incbin "data_080B7B74/gUnk_080BA2C0.bin"
|
||||
|
||||
gUnk_080BB2A0:: @ 080BB2A0
|
||||
.ifdef EU
|
||||
|
|
|
@ -59,9 +59,9 @@ static SaveResult (*const sSaveHandlers[])(u32) = { HandleSaveInit, HandleSaveIn
|
|||
#if defined(DEMO_USA) || defined(DEMO_JP)
|
||||
|
||||
#ifdef DEMO_USA
|
||||
asm("demoPointer1: .incbin \"baserom_demo.gba\", 0x11e010, 0x500");
|
||||
asm("demoPointer2: .incbin \"baserom_demo.gba\", 0x11e510, 0x500");
|
||||
asm("demoPointer3: .incbin \"baserom_demo.gba\", 0x11ea10, 0x500");
|
||||
asm("demoPointer1: .incbin \"demo/save1.bin\"");
|
||||
asm("demoPointer2: .incbin \"demo/save2.bin\"");
|
||||
asm("demoPointer3: .incbin \"demo/save3.bin\"");
|
||||
|
||||
extern const u8 demoPointer1[];
|
||||
extern const u8 demoPointer2[];
|
||||
|
|
|
@ -44,20 +44,12 @@ void Seek(long offset);
|
|||
|
||||
std::vector<std::uint32_t> trackPointers;
|
||||
|
||||
/*const int FILE_OFFSET = 0x10000;
|
||||
// const int START_OFFSET = 0x1c;
|
||||
const int START_OFFSET = 0x2DE4;
|
||||
const int REDUCE_POINTERS = 0;*/
|
||||
|
||||
const int FILE_OFFSET = 0;
|
||||
const int START_OFFSET = 0xDE38F0;
|
||||
const unsigned int REDUCE_POINTERS = 0x8000000;
|
||||
|
||||
extern int g_fileStartOffset; // TODO move to header
|
||||
|
||||
void ReadAgbSong() {
|
||||
|
||||
Seek(FILE_OFFSET + g_fileStartOffset);
|
||||
Seek(g_fileStartOffset);
|
||||
|
||||
int numTracks = ReadInt8();
|
||||
int numBlocks = ReadInt8();
|
||||
|
@ -101,7 +93,6 @@ std::vector<std::vector<Event>> trackEvents;
|
|||
std::vector<Event> metaEvents;
|
||||
|
||||
int convertTime(int time) {
|
||||
// event.time = (24 * g_clocksPerBeat * event.time) / g_midiTimeDiv;
|
||||
return ((float)time * g_midiTimeDiv) / (24 * g_clocksPerBeat);
|
||||
}
|
||||
|
||||
|
@ -112,19 +103,13 @@ std::uint32_t GetCurrentPtr() {
|
|||
}
|
||||
|
||||
std::uint32_t PtrToFileAddr(std::uint32_t ptr) {
|
||||
return ptr + FILE_OFFSET - REDUCE_POINTERS;
|
||||
return ptr - REDUCE_POINTERS;
|
||||
}
|
||||
|
||||
void insertAtCorrectTimeFromEnd(std::vector<Event>& events, const Event& event) {
|
||||
// std::printf("time: %d\n", event.time);
|
||||
for (auto it = events.rbegin(); it != events.rend(); it++) {
|
||||
if ((*it).time <= event.time) {
|
||||
events.insert(it.base(), event);
|
||||
|
||||
/* for (const auto& event : events) {
|
||||
std::printf("e: %X t: %d\n", (int)event.type, event.time);
|
||||
}
|
||||
std::cin.ignore();*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -132,15 +117,9 @@ void insertAtCorrectTimeFromEnd(std::vector<Event>& events, const Event& event)
|
|||
}
|
||||
|
||||
void insertAtCorrectTimeFromStart(std::vector<Event>& events, const Event& event) {
|
||||
// std::printf("time: %d\n", event.time);
|
||||
for (auto it = events.begin(); it != events.end(); it++) {
|
||||
if ((*it).time >= event.time) {
|
||||
events.insert(it, event);
|
||||
|
||||
/* for (const auto& event : events) {
|
||||
std::printf("e: %X t: %d\n", (int)event.type, event.time);
|
||||
}
|
||||
std::cin.ignore();*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +128,6 @@ void insertAtCorrectTimeFromStart(std::vector<Event>& events, const Event& event
|
|||
|
||||
void ReadAgbTracks() {
|
||||
size_t count = 0;
|
||||
|
||||
|
||||
|
||||
int addedPadding = 8;
|
||||
|
||||
// TODO configurable???
|
||||
|
@ -168,11 +144,10 @@ void ReadAgbTracks() {
|
|||
for (uint32_t trackPointer : trackPointers) {
|
||||
|
||||
std::vector<Event> events;
|
||||
count ++;
|
||||
count++;
|
||||
if (g_verbose)
|
||||
std::printf("\n\ntrackPointer: %X -> %X %ld\n", trackPointer, trackPointer - REDUCE_POINTERS, count);
|
||||
|
||||
|
||||
// Search for loop in this trac
|
||||
bool hasLoop = false;
|
||||
std::uint32_t loopAddress = 0;
|
||||
|
@ -180,10 +155,12 @@ void ReadAgbTracks() {
|
|||
int loopStartTime = 0;
|
||||
|
||||
unsigned int trackEnd =
|
||||
(trackPointers.size() > count ? trackPointers[count] : (g_fileStartOffset + REDUCE_POINTERS)) ; // Use offset to header as end for last track
|
||||
(trackPointers.size() > count
|
||||
? trackPointers[count]
|
||||
: (g_fileStartOffset + REDUCE_POINTERS)); // Use offset to header as end for last track
|
||||
if (g_verbose)
|
||||
std::printf("End of track: %X\n", trackEnd);
|
||||
Seek(FILE_OFFSET + trackEnd - REDUCE_POINTERS);
|
||||
Seek(trackEnd - REDUCE_POINTERS);
|
||||
|
||||
// search for a few bytes whether there is a loop end
|
||||
for (int i = 5; i < 10 + addedPadding; i++) {
|
||||
|
@ -191,11 +168,11 @@ void ReadAgbTracks() {
|
|||
// Ignore GOTOs from the previous track.
|
||||
continue;
|
||||
}
|
||||
Seek(FILE_OFFSET + trackEnd - REDUCE_POINTERS -i);
|
||||
Seek(trackEnd - REDUCE_POINTERS - i);
|
||||
if (ReadInt8() == GOTO) {
|
||||
if (g_verbose)
|
||||
std::printf("Has loop: %d\n", i);
|
||||
loopAddress = lReadInt32() + FILE_OFFSET - REDUCE_POINTERS;
|
||||
loopAddress = lReadInt32() - REDUCE_POINTERS;
|
||||
if (loopAddress > 0x1000000) {
|
||||
// The 0xB1 was probably part of the pointer or something.
|
||||
continue;
|
||||
|
@ -211,32 +188,17 @@ void ReadAgbTracks() {
|
|||
if (g_verbose)
|
||||
std::printf("Has loop: %d, %X\n", hasLoop, loopAddress);
|
||||
|
||||
|
||||
|
||||
|
||||
// Read all track events
|
||||
|
||||
Seek(FILE_OFFSET + trackPointer - REDUCE_POINTERS);
|
||||
Seek(trackPointer - REDUCE_POINTERS);
|
||||
|
||||
int type = ReadInt8();
|
||||
// std::printf("type: %X\n", type);
|
||||
|
||||
// VOL?
|
||||
if (type == VOL) {
|
||||
// TODO extract to function and reuse below
|
||||
|
||||
int val = ReadInt8();
|
||||
|
||||
if (g_verbose)
|
||||
std::printf("ignore vol: %X\n", val);
|
||||
|
||||
// TODO if this is a change to 127*mvl/mxv, there was no event in midi
|
||||
/*std::printf("VOL: %X\n", val);
|
||||
Event event;
|
||||
event.type = EventType::Controller;
|
||||
event.param1 = 0x7;
|
||||
event.param2 = std::round((float)val * MXV / MVL); // TODO inverse "%u*%s_mvl/mxv", event.param2,
|
||||
g_asmLabel.c_str()); events.push_back(event);*/
|
||||
type = ReadInt8();
|
||||
}
|
||||
|
||||
|
@ -249,7 +211,6 @@ void ReadAgbTracks() {
|
|||
if (g_verbose)
|
||||
std::printf("KEYSH: %d\n", keyShift);
|
||||
// TODO initial shift is always 0? Or is this set as the whole key shift?
|
||||
|
||||
} else {
|
||||
std::printf("Error: initial type %X not implemented\n", type);
|
||||
return;
|
||||
|
@ -273,11 +234,10 @@ void ReadAgbTracks() {
|
|||
int returnPtr = 0;
|
||||
|
||||
while (!endOfTrack) {
|
||||
// std::printf("type: %X\n", type);
|
||||
if (hasLoop && !foundLoop && GetCurrentPtr()-1 == loopAddress) {
|
||||
if (hasLoop && !foundLoop && GetCurrentPtr() - 1 == loopAddress) {
|
||||
if (g_verbose)
|
||||
std::printf("<<<< inserted loop start\n");
|
||||
//foundLoop = true;
|
||||
// foundLoop = true;
|
||||
loopStartTime = currentTime;
|
||||
Event event;
|
||||
event.time = loopStartTime;
|
||||
|
@ -291,8 +251,6 @@ void ReadAgbTracks() {
|
|||
// Repeat last command
|
||||
Skip(-1);
|
||||
type = lastCommand;
|
||||
// std::printf("%X ", type);
|
||||
// std::printf("Repeat last command: %X\n", lastCommand);
|
||||
if (g_verbose)
|
||||
std::printf("(repeat cmd) ");
|
||||
} else {
|
||||
|
@ -310,7 +268,6 @@ void ReadAgbTracks() {
|
|||
Event event;
|
||||
event.time = currentTime;
|
||||
event.type = EventType::Tempo;
|
||||
// 60000000 / event.param2
|
||||
event.param2 = 60000000 / (val * 2);
|
||||
metaEvents.push_back(event);
|
||||
|
||||
|
@ -328,9 +285,7 @@ void ReadAgbTracks() {
|
|||
break;
|
||||
}
|
||||
case VOL: {
|
||||
// const int MVL = 90; // TODO configurable per song?
|
||||
const int MVL = 128;
|
||||
|
||||
const int MXV = 0x7F;
|
||||
|
||||
int val = ReadInt8();
|
||||
|
@ -340,8 +295,7 @@ void ReadAgbTracks() {
|
|||
event.time = currentTime;
|
||||
event.type = EventType::Controller;
|
||||
event.param1 = 0x7;
|
||||
event.param2 = std::ceil((float)val * MXV /
|
||||
MVL); // TODO inverse "%u*%s_mvl/mxv", event.param2, g_asmLabel.c_str());
|
||||
event.param2 = std::ceil((float)val * MXV / MVL);
|
||||
events.push_back(event);
|
||||
break;
|
||||
}
|
||||
|
@ -414,7 +368,6 @@ void ReadAgbTracks() {
|
|||
|
||||
// Already handled
|
||||
loopEndTime = currentTime;
|
||||
|
||||
break;
|
||||
}
|
||||
case EOT: {
|
||||
|
@ -601,7 +554,6 @@ void ReadAgbTracks() {
|
|||
}
|
||||
default:
|
||||
if (type >= 0x80 && type <= 0x80 + 48) {
|
||||
|
||||
const int lenTbl[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 28, 30, 32, 36, 40, 42, 44, 48, 52,
|
||||
54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92, 96 };
|
||||
|
@ -613,65 +565,31 @@ void ReadAgbTracks() {
|
|||
patternDuration += wait;
|
||||
|
||||
if (!currentlyPlayingNotes.empty()) {
|
||||
|
||||
// std::printf("Testing... %d\n", (int)currentlyPlayingNotes.size());
|
||||
for (auto it = currentlyPlayingNotes.begin(); it != currentlyPlayingNotes.end();) {
|
||||
Event& note = *it; // Modify the note in the list if we don't remove it now.
|
||||
note.time -= wait;
|
||||
if (note.time <= 0) {
|
||||
|
||||
/*if (note.time < 0) {
|
||||
std::printf("<0: %d\n", note.time);
|
||||
std::cin.ignore();
|
||||
}*/
|
||||
// note.time += currentTime; // Set to the global time the note was finished.
|
||||
// TODO negative=
|
||||
note.time += currentTime + wait;
|
||||
|
||||
// std::printf("Note off at %d\n", note.time);
|
||||
insertAtCorrectTimeFromEnd(events, note);
|
||||
|
||||
it = currentlyPlayingNotes.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
// // TODO handle multiple notes playing at the same time on the same track?
|
||||
// if (wait >= currentlyPlayingNotes[0].time) {
|
||||
// Event event = currentlyPlayingNotes[0];
|
||||
// std::printf("Finished playing note\n");
|
||||
// event.time = currentTime;
|
||||
// events.push_back(event);
|
||||
// currentlyPlayingNotes.pop_back();
|
||||
// } else {
|
||||
// currentlyPlayingNotes[0].time -= wait;
|
||||
// }
|
||||
}
|
||||
// std::printf("Done... %d\n", (int)currentlyPlayingNotes.size());
|
||||
}
|
||||
currentTime += wait;
|
||||
|
||||
/* if (wait > 0) {
|
||||
Event event;
|
||||
event.type = EventType::Wait;
|
||||
event.time = currentTime+convertTime(wait);
|
||||
events.push_back(event);
|
||||
}*/
|
||||
|
||||
} else if (type >= 0xD0 && type <= 0xD0 + 47) {
|
||||
|
||||
// Handle note with a fixed length
|
||||
int noteType = type;
|
||||
int note = ReadInt8();
|
||||
int velocity = 0;
|
||||
int length = 0;
|
||||
|
||||
bool usedLastNote = false;
|
||||
bool usedLastVelocity = false;
|
||||
if (note < 0x80) { // a valid note
|
||||
lastNote = note;
|
||||
velocity = ReadInt8();
|
||||
if (velocity < 0x80) { // a valid velocity
|
||||
// std::printf("Explicit velocity%d\n", velocity);
|
||||
lastVelocity = velocity;
|
||||
length = ReadInt8();
|
||||
if (length < 0x80) { // a valid length
|
||||
|
@ -681,7 +599,6 @@ void ReadAgbTracks() {
|
|||
length = 0;
|
||||
}
|
||||
} else {
|
||||
// std::printf("Reusing last vel %d\n", lastVelocity);
|
||||
type = velocity;
|
||||
velocity = lastVelocity;
|
||||
usedLastVelocity = true;
|
||||
|
@ -732,56 +649,12 @@ void ReadAgbTracks() {
|
|||
}
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
// std::printf("Wait before convert: %d\n", wait);
|
||||
// std::printf("Wait after convert: %d\n", event.param2);
|
||||
events.push_back(event);
|
||||
|
||||
event.type = EventType::NoteOff;
|
||||
event.time = wait;
|
||||
// std::printf("Should be off at %d...\n", currentTime+wait);
|
||||
// std::printf("Note length: %d\n", wait);
|
||||
// std::cin.ignore();
|
||||
currentlyPlayingNotes.push_back(event);
|
||||
// event.param2 = wait;
|
||||
|
||||
/* int duration = wait; // event.param2;
|
||||
|
||||
if (!g_exactGateTime) { // && duration < 96)
|
||||
// TODO inverse lut
|
||||
std::printf("asdf\n");
|
||||
for (size_t i = 0; i < 97; i++) {
|
||||
if (g_noteDurationLUT[i] == duration) {
|
||||
duration = i;
|
||||
std::printf("test%d\n", (int)i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (duration == 1)
|
||||
duration = 0;
|
||||
|
||||
// event.param2 = (duration * g_midiTimeDiv) /(24 * g_clocksPerBeat);
|
||||
event.param2 = g_noteDurationInverseLUT[duration];
|
||||
std::printf("Wait after convert: %d\n", event.param2);*/
|
||||
|
||||
/*
|
||||
event.param1 = g_noteVelocityLUT[event.param1];
|
||||
|
||||
std::uint32_t duration = (24 * g_clocksPerBeat * event.param2) / g_midiTimeDiv;
|
||||
|
||||
if (duration == 0)
|
||||
duration = 1;
|
||||
|
||||
if (!g_exactGateTime && duration < 96)
|
||||
duration = g_noteDurationLUT[duration];
|
||||
|
||||
event.param2 = duration;
|
||||
*/
|
||||
|
||||
continue; // Next type was already read
|
||||
|
||||
} else {
|
||||
std::printf("ERROR: Unhandled type %X\n", type);
|
||||
return;
|
||||
|
@ -789,8 +662,6 @@ void ReadAgbTracks() {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO notes, waits,
|
||||
type = ReadInt8();
|
||||
}
|
||||
|
@ -816,30 +687,10 @@ void ReadAgbTracks() {
|
|||
std::cin.ignore();
|
||||
}
|
||||
|
||||
/*if (foundLoop) {
|
||||
// Place the loop begin event as the last event for that time on the meta events track.
|
||||
// TODO this does not help as TEMPO events are not placed on the meta track?
|
||||
|
||||
Event event;
|
||||
event.time = loopStartTime;
|
||||
event.type = EventType::LoopBegin;
|
||||
insertAtCorrectTimeFromEnd(events, event);
|
||||
std::printf("--- Inserting loop at %d\n", loopStartTime);
|
||||
}*/
|
||||
|
||||
if (hasLoop) {
|
||||
Event event;
|
||||
event.type = EventType::LoopEnd;
|
||||
event.time = loopEndTime;
|
||||
// Place loop end at the end of the track that has the latest end.
|
||||
/*for (const auto& events : trackEvents) {
|
||||
int trackEnd = events.back().time;
|
||||
if (trackEnd > event.time) {
|
||||
event.time = trackEnd;
|
||||
}
|
||||
}*/
|
||||
// std::printf("####### loop End %d\n", event.time);
|
||||
//events.push_back(event);
|
||||
insertAtCorrectTimeFromEnd(events, event);
|
||||
}
|
||||
|
||||
|
@ -853,8 +704,6 @@ void ReadAgbTracks() {
|
|||
trackEvents.push_back(events);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Insert manual time signature change event
|
||||
for (const auto& change : timeSignatureChanges) {
|
||||
bool inserted = false;
|
||||
|
@ -866,15 +715,12 @@ void ReadAgbTracks() {
|
|||
for (size_t i = 0; i < metaEvents.size() - 1; i++) {
|
||||
int prevTime = metaEvents[i].time;
|
||||
int nextTime = metaEvents[i + 1].time;
|
||||
//std::printf("%d < %d <= %d?\n", prevTime, event.time, nextTime);
|
||||
if (event.time > prevTime && event.time <= nextTime) {
|
||||
//std::printf("axd%d\n", (int)metaEvents.size());
|
||||
metaEvents.insert(metaEvents.begin() + i + 1, event);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//std::printf("asd %d\n", (int)metaEvents.size());
|
||||
if (!inserted) {
|
||||
metaEvents.push_back(event);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include <cstdarg>
|
||||
|
||||
// Reports an error diagnostic and terminates the program.
|
||||
[[noreturn]] void RaiseError(const char* format, ...)
|
||||
{
|
||||
[[noreturn]] void RaiseError(const char* format, ...) {
|
||||
const int bufferSize = 1024;
|
||||
char buffer[bufferSize];
|
||||
std::va_list args;
|
||||
|
|
|
@ -49,12 +49,8 @@ int g_denominatorExp = 2;
|
|||
bool g_verbose = false;
|
||||
std::vector<TimeSignatureChange> timeSignatureChanges;
|
||||
|
||||
|
||||
|
||||
[[noreturn]] static void PrintUsage()
|
||||
{
|
||||
std::printf(
|
||||
"Usage: AGB2MID baserom start_offset input_file output_file [options]\n"
|
||||
[[noreturn]] static void PrintUsage() {
|
||||
std::printf("Usage: AGB2MID baserom start_offset input_file output_file [options]\n"
|
||||
"\n"
|
||||
" baserom path to the baserom\n"
|
||||
" start_offset offset to the sound header\n"
|
||||
|
@ -72,37 +68,30 @@ std::vector<TimeSignatureChange> timeSignatureChanges;
|
|||
" -n??? midi time nominator\n"
|
||||
" -d??? midi time denominator\n"
|
||||
" -t ? ? ? time signature change\n"
|
||||
" -v verbose\n"
|
||||
);
|
||||
" -v verbose\n");
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
static std::string StripExtension(std::string s)
|
||||
{
|
||||
static std::string StripExtension(std::string s) {
|
||||
std::size_t pos = s.find_last_of('.');
|
||||
|
||||
if (pos > 0 && pos != std::string::npos)
|
||||
{
|
||||
if (pos > 0 && pos != std::string::npos) {
|
||||
s = s.substr(0, pos);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::string GetExtension(std::string s)
|
||||
{
|
||||
static std::string GetExtension(std::string s) {
|
||||
std::size_t pos = s.find_last_of('.');
|
||||
|
||||
if (pos > 0 && pos != std::string::npos)
|
||||
{
|
||||
if (pos > 0 && pos != std::string::npos) {
|
||||
return s.substr(pos + 1);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
static std::string BaseName(std::string s)
|
||||
{
|
||||
static std::string BaseName(std::string s) {
|
||||
std::size_t posAfterSlash = s.find_last_of("/\\");
|
||||
|
||||
if (posAfterSlash == std::string::npos)
|
||||
|
@ -117,11 +106,10 @@ static std::string BaseName(std::string s)
|
|||
return s;
|
||||
}
|
||||
|
||||
static const char *GetArgument(int argc, char **argv, int& index)
|
||||
{
|
||||
static const char* GetArgument(int argc, char** argv, int& index) {
|
||||
assert(index >= 0 && index < argc);
|
||||
|
||||
const char *option = argv[index];
|
||||
const char* option = argv[index];
|
||||
|
||||
assert(option != nullptr);
|
||||
assert(option[0] == '-');
|
||||
|
@ -131,34 +119,27 @@ static const char *GetArgument(int argc, char **argv, int& index)
|
|||
return option + 2;
|
||||
|
||||
// Otherwise, try to get the next arg.
|
||||
if (index + 1 < argc)
|
||||
{
|
||||
if (index + 1 < argc) {
|
||||
index++;
|
||||
return argv[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int main(int argc, char** argv) {
|
||||
std::string baseromPath;
|
||||
std::string startOffset;
|
||||
std::string inputFilename;
|
||||
std::string outputFilename;
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
const char *option = argv[i];
|
||||
for (int i = 1; i < argc; i++) {
|
||||
const char* option = argv[i];
|
||||
|
||||
if (option[0] == '-' && option[1] != '\0')
|
||||
{
|
||||
const char *arg;
|
||||
if (option[0] == '-' && option[1] != '\0') {
|
||||
const char* arg;
|
||||
|
||||
switch (option[1])
|
||||
{
|
||||
switch (option[1]) {
|
||||
case 'E':
|
||||
g_exactGateTime = true;
|
||||
break;
|
||||
|
@ -204,8 +185,7 @@ int main(int argc, char** argv)
|
|||
PrintUsage();
|
||||
g_nominator = std::stoi(arg);
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
case 'd': {
|
||||
arg = GetArgument(argc, argv, i);
|
||||
if (arg == nullptr)
|
||||
PrintUsage();
|
||||
|
@ -228,10 +208,9 @@ int main(int argc, char** argv)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
int nominator = std::stoi(argv[i+1]);
|
||||
int denominator = std::stoi(argv[i+2]);
|
||||
case 't': {
|
||||
int nominator = std::stoi(argv[i + 1]);
|
||||
int denominator = std::stoi(argv[i + 2]);
|
||||
if (denominator == 1) {
|
||||
denominator = 0;
|
||||
} else if (denominator == 2) {
|
||||
|
@ -248,7 +227,7 @@ int main(int argc, char** argv)
|
|||
std::printf("ERROR: denominator %d\n", denominator);
|
||||
exit(1);
|
||||
}
|
||||
int time = std::stoi(argv[i+3]);
|
||||
int time = std::stoi(argv[i + 3]);
|
||||
i += 3;
|
||||
TimeSignatureChange change;
|
||||
change.nominator = nominator;
|
||||
|
@ -266,9 +245,7 @@ int main(int argc, char** argv)
|
|||
default:
|
||||
PrintUsage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (baseromPath.empty())
|
||||
baseromPath = argv[i];
|
||||
else if (startOffset.empty())
|
||||
|
@ -285,16 +262,12 @@ int main(int argc, char** argv)
|
|||
if (inputFilename.empty())
|
||||
PrintUsage();
|
||||
|
||||
/*if (GetExtension(inputFilename) != "out") // TODO unify with baserom parameter?
|
||||
RaiseError("input filename extension is not \"out\"");
|
||||
*/
|
||||
if (outputFilename.empty())
|
||||
outputFilename = StripExtension(inputFilename) + ".mid";
|
||||
|
||||
if (GetExtension(outputFilename) != "mid")
|
||||
RaiseError("output filename extension is not \"mid\"");
|
||||
|
||||
|
||||
if (g_asmLabel.empty())
|
||||
g_asmLabel = BaseName(outputFilename);
|
||||
|
||||
|
@ -310,16 +283,10 @@ int main(int argc, char** argv)
|
|||
|
||||
g_fileStartOffset = std::stoul(startOffset, nullptr, 16);
|
||||
|
||||
|
||||
ReadAgbSong();
|
||||
ReadAgbTracks();
|
||||
WriteMidiFile();
|
||||
|
||||
/*ReadMidiFileHeader();
|
||||
PrintAgbHeader();
|
||||
ReadMidiTracks();
|
||||
PrintAgbFooter();*/
|
||||
|
||||
std::fclose(g_inputFile);
|
||||
std::fclose(g_outputFile);
|
||||
|
||||
|
|
|
@ -222,57 +222,48 @@ void WriteTrack(int channelId, const std::vector<Event>& events) {
|
|||
bool DEBUG = g_verbose && false;
|
||||
|
||||
for (const auto& event : events) {
|
||||
|
||||
if (DEBUG) { std::printf("TIME: %d\n", event.time); }
|
||||
|
||||
|
||||
/* if (event.type == EventType::Wait) { // Handle special wait event
|
||||
waiting += event.time;
|
||||
continue;
|
||||
}*/
|
||||
|
||||
|
||||
// TODO can remove type parameter if it is the same type as before?
|
||||
|
||||
// Delta time to previous event
|
||||
// std::printf("delta Time: %d\n", event.time);
|
||||
// TODO make sure currentTime <= event.time!!
|
||||
writeDeltaTime(data, event.time - currentTime); // - previousTime);
|
||||
if (DEBUG) {
|
||||
std::printf("TIME: %d\n", event.time);
|
||||
}
|
||||
writeDeltaTime(data, event.time - currentTime);
|
||||
currentTime = event.time;
|
||||
// previousTime = event.time;
|
||||
|
||||
switch (event.type) {
|
||||
case EventType::InstrumentChange:
|
||||
if (DEBUG) { std::printf("InstrumentChange\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("InstrumentChange\n");
|
||||
}
|
||||
data.push_back(0xC0 + channelId); // type
|
||||
data.push_back(event.param1); // instrument
|
||||
break;
|
||||
case EventType::Controller:
|
||||
if (DEBUG) { std::printf("Controller\n");}
|
||||
/*if (event.param1 == 7 && !firstVol) {
|
||||
firstVol = true; // hack TODO
|
||||
} else {*/
|
||||
if (DEBUG) {
|
||||
std::printf("Controller\n");
|
||||
}
|
||||
data.push_back(0xB0 + channelId); // type
|
||||
//}
|
||||
data.push_back(event.param1); // controller index
|
||||
data.push_back(event.param2); // value
|
||||
break;
|
||||
case EventType::Note:
|
||||
if (DEBUG) { std::printf("Note\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("Note\n");
|
||||
}
|
||||
data.push_back(0x90 + channelId); // type
|
||||
data.push_back(event.note); // note
|
||||
data.push_back(event.param1); // velocity
|
||||
break;
|
||||
case EventType::NoteOff:
|
||||
if (DEBUG) { std::printf("NoteOff\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("NoteOff\n");
|
||||
}
|
||||
// Wait and note_end
|
||||
data.push_back(0x80 + channelId); // type
|
||||
data.push_back(event.note); // note
|
||||
data.push_back(0); // Ignored velocity
|
||||
break;
|
||||
case EventType::TimeSignature:
|
||||
{
|
||||
if (DEBUG) { std::printf("TimeSignature\n");}
|
||||
case EventType::TimeSignature: {
|
||||
if (DEBUG) {
|
||||
std::printf("TimeSignature\n");
|
||||
}
|
||||
// One time meta event at the beginning of the meta track.
|
||||
data.push_back(0xff); // meta
|
||||
data.push_back(88); // TIME_SIGNATURE
|
||||
|
@ -284,14 +275,18 @@ void WriteTrack(int channelId, const std::vector<Event>& events) {
|
|||
break;
|
||||
}
|
||||
case EventType::Tempo:
|
||||
if (DEBUG) { std::printf("Tempo\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("Tempo\n");
|
||||
}
|
||||
data.push_back(0xff); // meta
|
||||
data.push_back(81); // META_TEMPO
|
||||
writeDeltaTime(data, 3); // only valid tempo size is 3
|
||||
writeInt24(data, event.param2); // usecPerQuarterNote
|
||||
break;
|
||||
case EventType::Extended:
|
||||
if (DEBUG) { std::printf("Extended\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("Extended\n");
|
||||
}
|
||||
if (event.note == 0x1d) {
|
||||
// for some reason the first one is in a meta change?
|
||||
data.push_back(0xb0);
|
||||
|
@ -304,37 +299,43 @@ void WriteTrack(int channelId, const std::vector<Event>& events) {
|
|||
data.push_back(event.param2);
|
||||
break;
|
||||
case EventType::PitchBend:
|
||||
if (DEBUG) { std::printf("PitchBend\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("PitchBend\n");
|
||||
}
|
||||
data.push_back(0xe0 + channelId); // petch bend
|
||||
data.push_back(0); // lsb
|
||||
data.push_back(event.param2);
|
||||
break;
|
||||
case EventType::EndOfTrack:
|
||||
if (DEBUG) { std::printf("EndOfTrack\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("EndOfTrack\n");
|
||||
}
|
||||
// End of track
|
||||
data.push_back(0xff); // meta
|
||||
data.push_back(47); // META_END_OF_TRACK
|
||||
writeDeltaTime(data, 0); // length
|
||||
break;
|
||||
case EventType::LoopBegin:
|
||||
if (DEBUG) { std::printf("LoopBegin\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("LoopBegin\n");
|
||||
}
|
||||
data.push_back(0xff); // meta
|
||||
data.push_back(0x6); // META_MARKER
|
||||
data.push_back(0x1); // length
|
||||
data.push_back(0x5B); // [
|
||||
break;
|
||||
case EventType::LoopEnd:
|
||||
if (DEBUG) { std::printf("LoopEnd\n");}
|
||||
if (DEBUG) {
|
||||
std::printf("LoopEnd\n");
|
||||
}
|
||||
data.push_back(0xff); // meta
|
||||
data.push_back(0x6); // META_MARKER
|
||||
data.push_back(0x1); // length
|
||||
data.push_back(0x5D); // ]
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MidiTrack header
|
||||
std::fprintf(g_outputFile, "MTrk");
|
||||
// length of track data
|
||||
|
@ -355,19 +356,11 @@ void WriteMidiFile() {
|
|||
// u16 midiTimeDiv (24 in example)
|
||||
WriteInt16(g_midiTimeDiv);
|
||||
|
||||
|
||||
// Add end of track to meta events
|
||||
Event event;
|
||||
event.type = EventType::EndOfTrack;
|
||||
/*event.time = 0;
|
||||
// Place loop end at the end of the track that has the latest end.
|
||||
for (const auto& events:trackEvents) {
|
||||
int trackEnd = events.back().time;
|
||||
if (trackEnd > event.time) {
|
||||
event.time = trackEnd;
|
||||
}
|
||||
}*/
|
||||
// EndOfTrack event needs to be at the last meta event (can be earlier than the end of other tracks) for bgmVaatiMotif to work
|
||||
// EndOfTrack event needs to be at the last meta event (can be earlier than the end of other tracks) for
|
||||
// bgmVaatiMotif to work
|
||||
event.time = metaEvents.back().time;
|
||||
metaEvents.push_back(event);
|
||||
|
||||
|
|
|
@ -23,14 +23,9 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
enum class MidiFormat
|
||||
{
|
||||
SingleTrack,
|
||||
MultiTrack
|
||||
};
|
||||
enum class MidiFormat { SingleTrack, MultiTrack };
|
||||
|
||||
enum class EventType
|
||||
{
|
||||
enum class EventType {
|
||||
EndOfTie = 0x01,
|
||||
Label = 0x11,
|
||||
LoopEnd = 0x12,
|
||||
|
@ -53,25 +48,19 @@ enum class EventType
|
|||
NoteOff,
|
||||
};
|
||||
|
||||
struct Event
|
||||
{
|
||||
struct Event {
|
||||
std::int32_t time = 0;
|
||||
EventType type;
|
||||
std::uint8_t note = 0;
|
||||
std::uint8_t param1 = 0;
|
||||
std::int32_t param2 = 0;
|
||||
|
||||
bool operator==(const Event& other)
|
||||
{
|
||||
return (time == other.time
|
||||
&& type == other.type
|
||||
&& note == other.note
|
||||
&& param1 == other.param1
|
||||
&& param2 == other.param2);
|
||||
bool operator==(const Event& other) {
|
||||
return (time == other.time && type == other.type && note == other.note && param1 == other.param1 &&
|
||||
param2 == other.param2);
|
||||
}
|
||||
|
||||
bool operator!=(const Event& other)
|
||||
{
|
||||
bool operator!=(const Event& other) {
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
@ -81,8 +70,7 @@ void WriteMidiFile();
|
|||
extern int g_midiChan;
|
||||
extern std::int32_t g_initialWait;
|
||||
|
||||
inline bool IsPatternBoundary(EventType type)
|
||||
{
|
||||
inline bool IsPatternBoundary(EventType type) {
|
||||
return type == EventType::EndOfTrack || (int)type <= 0x17;
|
||||
}
|
||||
extern std::int16_t g_midiTimeDiv;
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "tables.h"
|
||||
|
||||
const int g_noteDurationLUT[] =
|
||||
{
|
||||
const int g_noteDurationLUT[] = {
|
||||
0, // 0
|
||||
1, // 1
|
||||
2, // 2
|
||||
|
@ -121,8 +120,7 @@ const int g_noteDurationLUT[] =
|
|||
96, // 96
|
||||
};
|
||||
|
||||
const int g_noteVelocityLUT[] =
|
||||
{
|
||||
const int g_noteVelocityLUT[] = {
|
||||
0, // 0
|
||||
4, // 1
|
||||
4, // 2
|
||||
|
@ -253,90 +251,17 @@ const int g_noteVelocityLUT[] =
|
|||
127, // 127
|
||||
};
|
||||
|
||||
const char* g_noteTable[] =
|
||||
{
|
||||
"Cn%01u ",
|
||||
"Cs%01u ",
|
||||
"Dn%01u ",
|
||||
"Ds%01u ",
|
||||
"En%01u ",
|
||||
"Fn%01u ",
|
||||
"Fs%01u ",
|
||||
"Gn%01u ",
|
||||
"Gs%01u ",
|
||||
"An%01u ",
|
||||
"As%01u ",
|
||||
"Bn%01u ",
|
||||
const char* g_noteTable[] = {
|
||||
"Cn%01u ", "Cs%01u ", "Dn%01u ", "Ds%01u ", "En%01u ", "Fn%01u ",
|
||||
"Fs%01u ", "Gn%01u ", "Gs%01u ", "An%01u ", "As%01u ", "Bn%01u ",
|
||||
};
|
||||
|
||||
const char* g_minusNoteTable[] =
|
||||
{
|
||||
"CnM%01u",
|
||||
"CsM%01u",
|
||||
"DnM%01u",
|
||||
"DsM%01u",
|
||||
"EnM%01u",
|
||||
"FnM%01u",
|
||||
"FsM%01u",
|
||||
"GnM%01u",
|
||||
"GsM%01u",
|
||||
"AnM%01u",
|
||||
"AsM%01u",
|
||||
"BnM%01u",
|
||||
};
|
||||
|
||||
const int g_noteIdLUT[] = {
|
||||
0, //
|
||||
const char* g_minusNoteTable[] = {
|
||||
"CnM%01u", "CsM%01u", "DnM%01u", "DsM%01u", "EnM%01u", "FnM%01u",
|
||||
"FsM%01u", "GnM%01u", "GsM%01u", "AnM%01u", "AsM%01u", "BnM%01u",
|
||||
};
|
||||
|
||||
const int g_noteDurationInverseLUT[] = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
28,
|
||||
30,
|
||||
32,
|
||||
36,
|
||||
40,
|
||||
42,
|
||||
44,
|
||||
48,
|
||||
52,
|
||||
54,
|
||||
56,
|
||||
60,
|
||||
64,
|
||||
66,
|
||||
68,
|
||||
72,
|
||||
76,
|
||||
78,
|
||||
80,
|
||||
84,
|
||||
88,
|
||||
90,
|
||||
92,
|
||||
96,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
28, 30, 32, 36, 40, 42, 44, 48, 52, 54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92, 96,
|
||||
};
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3 -Wall -Wextra -std=c++17
|
||||
CXXFLAGS = -O3 -Wall -Wextra -Werror -std=c++17
|
||||
#CXXFLAGS += -g # debug
|
||||
|
||||
BUILD_FOLDER=build
|
||||
BUILD_FOLDER = build
|
||||
|
||||
SRCS = $(wildcard *.cpp)
|
||||
SRCS += $(wildcard assets/*.cpp)
|
||||
|
|
|
@ -13,6 +13,8 @@ class BaseAsset {
|
|||
: path(path), start(start), size(size), asset(asset) {
|
||||
}
|
||||
|
||||
virtual ~BaseAsset() = default;
|
||||
|
||||
void setup() {
|
||||
// Cannot call virtual functions in constructor, so another function call is necessary
|
||||
assetPath = this->generateAssetPath();
|
||||
|
|
|
@ -71,13 +71,13 @@ int main(int argc, char** argv) {
|
|||
argCount--;
|
||||
args++;
|
||||
} else {
|
||||
std::cerr << "Unrecognized argument `" << args[0] << "`" << std::endl;
|
||||
std::cerr << "Error: Unrecognized argument `" << args[0] << "`" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argCount != 3) {
|
||||
std::cerr << "Not enough arguments. expected: 3, actual: " << argCount << std::endl;
|
||||
std::cerr << "Error: Not enough arguments. expected: 3, actual: " << argCount << std::endl;
|
||||
usage();
|
||||
}
|
||||
|
||||
|
@ -88,18 +88,23 @@ int main(int argc, char** argv) {
|
|||
} else if (strcmp(args[0], "build") == 0) {
|
||||
gMode = BUILD;
|
||||
} else {
|
||||
std::cerr << "Unsupported mode `" << args[0] << "`" << std::endl;
|
||||
std::cerr << "Error: Unsupported mode `" << args[0] << "`" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
gVariant = args[1];
|
||||
if (gVariant != "USA" && gVariant != "EU" && gVariant != "JP" && gVariant != "DEMO_USA" && gVariant != "DEMO_JP") {
|
||||
std::cerr << "Unsupported variant `" << gVariant << "`" << std::endl;
|
||||
std::cerr << "Error: Unsupported variant `" << gVariant << "`" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
gAssetsFolder = args[2];
|
||||
gBaseromPath = baseroms[gVariant];
|
||||
|
||||
if (!std::filesystem::exists(gBaseromPath)) {
|
||||
std::cerr << "Error: You need to provide a " << gVariant << " ROM as " << gBaseromPath << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
// Read baserom.
|
||||
std::ifstream file(gBaseromPath, std::ios::binary | std::ios::ate);
|
||||
std::streamsize size = file.tellg();
|
||||
|
@ -255,7 +260,7 @@ std::unique_ptr<BaseAsset> getAssetHandlerByType(const std::filesystem::path& pa
|
|||
// Unknown binary asset
|
||||
assetHandler = std::make_unique<BaseAsset>(path, start, size, asset);
|
||||
} else {
|
||||
std::cerr << "Unimplemented asset type `" << type << "`" << std::endl;
|
||||
std::cerr << "Error: Unimplemented asset type `" << type << "`" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
assetHandler->setup();
|
||||
|
|
|
@ -99,7 +99,7 @@ int main(int argc, char **argv)
|
|||
std::string path(includeDir + incbin);
|
||||
if (CanOpenFile(path))
|
||||
{
|
||||
dependencies.insert(path).second;
|
||||
dependencies.insert(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ namespace {
|
|||
};
|
||||
|
||||
constexpr const char *const ColorStrings[] = {
|
||||
[Color_White] = "White",
|
||||
[Color_Red] = "Red",
|
||||
[Color_Green] = "Green",
|
||||
[Color_Blue] = "Blue",
|
||||
[Color_Yellow] = "Yellow",
|
||||
"White",
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue",
|
||||
"Yellow",
|
||||
};
|
||||
|
||||
enum Input {
|
||||
|
@ -52,17 +52,17 @@ namespace {
|
|||
};
|
||||
|
||||
constexpr const char *const InputStrings[] = {
|
||||
[Input_A] = "A",
|
||||
[Input_B] = "B",
|
||||
[Input_Left] = "Left",
|
||||
[Input_Right] = "Right",
|
||||
[Input_DUp] = "DUp",
|
||||
[Input_DDown] = "DDown",
|
||||
[Input_DLeft] = "DLeft",
|
||||
[Input_DRight] = "DRight",
|
||||
[Input_Dpad] = "Dpad",
|
||||
[Input_Select] = "Select",
|
||||
[Input_Start] = "Start",
|
||||
"A",
|
||||
"B",
|
||||
"Left",
|
||||
"Right",
|
||||
"DUp",
|
||||
"DDown",
|
||||
"DLeft",
|
||||
"DRight",
|
||||
"Dpad",
|
||||
"Select",
|
||||
"Start",
|
||||
};
|
||||
|
||||
const std::map<u8, std::string> CharConvertArray = {
|
||||
|
|
Loading…
Reference in New Issue