Skip to content

Commit

Permalink
Version 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 authored Mar 19, 2021
1 parent de0defb commit eaa06ad
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions UnkrawerterGBA.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* UnkrawerterGBA
* Version 3.1
* Version 4.0
*
* This program automatically extracts music files from Game Boy Advance games
* that use the Krawall sound engine. Audio files are extracted in the XM or S3M
Expand All @@ -9,7 +9,7 @@
* This file is intended for use as a library. Make sure to define AS_LIBRARY
* when compiling UnkrawerterGBA to avoid defining main.
*
* Copyright (c) 2020 JackMacWindows.
* Copyright (c) 2020-2021 JackMacWindows.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -59,6 +59,7 @@ extern void unkrawerter_readSampleToWAV(FILE* fp, uint32_t offset, const char *
// trimInstruments specifies whether to remove instruments that are not used by the module.
// name specifies the name of the module; if unset then the module is named "Krawall conversion".
// fixCompatibility specifies whether to make some changes to the pattern data in order to emulate some Krawall/S3M quirks. Set to true for accurate playback; set to false for accurate pattern data.
// instfp specifies a file handle to read instruments from - this is only necessary when using banks.
// Returns 0 on success, non-zero on error.
extern int unkrawerter_writeModuleToXM(
FILE* fp,
Expand All @@ -68,20 +69,61 @@ extern int unkrawerter_writeModuleToXM(
const char * filename,
bool trimInstruments = true,
const char * name = NULL,
bool fixCompatibility = true
bool fixCompatibility = true,
FILE* instfp = NULL
);

// Writes a module from a file pointer to a new S3M file.
// trimInstruments specifies whether to remove instruments that are not used by the module.
// name specifies the name of the module; if unset then the module is named "Krawall conversion".
// instfp specifies a file handle to read instruments from - this is only necessary when using banks.
// Returns 0 on success, non-zero on error.
extern int unkrawerter_writeModuleToS3M(
FILE* fp,
uint32_t moduleOffset,
const std::vector<uint32_t> &sampleOffsets,
const char * filename,
bool trimInstruments = true,
const char * name = NULL
const char * name = NULL,
FILE* instfp = NULL
);

/*
Unkrawerter 4.0 adds a new direct-rip format for dumping the exact pattern
and instrument data without any conversion. This makes it suitable for true
rips that have no data loss.
The format functions similar to miniGSF: there is one bank file that contains
all of the instruments, and multiple module files that share the same bank.
For further information on the format of the structures contained within the
files, see lib/mtypes.h in the Krawall source.
Krawall Bank (.krb) File Format:
* 4 bytes: Magic number "KRWB" (0x4257524b LE) for new version, "KRWC" (0x4357524b LE) for old version
* 2 bytes: Number of instruments
* 2 bytes: Number of samples
* 4*[x] bytes: Offsets to instruments relative to start
* 4*[y] bytes: Offsets to samples relative to start
* sizeof(Instrument)*[x] bytes: Instrument structures
* [z]*[y] bytes: Sample structures
Krawall Module (.krw) File Format:
* 4 bytes: Magic number "KRWM" (0x4d57524b LE)
* sizeof(Module)-sizeof(Pattern*) bytes: Module structure
* 4*[x] bytes: Offsets to patterns relative to start
* [y]*[x] bytes: Pattern structures
Note: To keep things sane, the row count size is always 2 bytes, even if the
module is from older versions where the row count is 1 byte.
*/

// Writes a Krawall Bank file to a path using the specified instrument and sample offsets.
// Returns true on success, false on error.
bool unkrawerter_writeBankFile(FILE* fp, const std::vector<uint32_t> &sampleOffsets, const std::vector<uint32_t> &instrumentOffsets, const char * filename);

// Writes a Krawall Module file to a path using the specified module offset.
// Returns true on success, false on error.
bool unkrawerter_writeModuleFile(FILE* fp, uint32_t moduleOffset, const char * filename);

#endif

0 comments on commit eaa06ad

Please sign in to comment.