Skip to content

Commit

Permalink
0.20180825
Browse files Browse the repository at this point in the history
convert to v2m newest version
  • Loading branch information
zvezdochiot committed Aug 25, 2018
1 parent 4dbe9ae commit 57012ec
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG -DRONAN -Os -flto -Wall -fno-as

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
set(MAJOR_VERSION 0)
set(DATE_VERSION 20180821)
set(DATE_VERSION 20180825)
set(V2M_VERSION ${MAJOR_VERSION}.${DATE_VERSION})
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ sudo make install
```
./v2mplayer v2m/0test.v2m
zcat v2m/Dafunk--breeze.v2mz | ./v2mplayer
gzip -cdf v2m/Dafunk--breeze.v2mz | ./v2mplayer -o Dafunk--breeze.newest.v2m
```

## See also

```
http://ftp.modland.com/
```

---
Expand Down
4 changes: 4 additions & 0 deletions doc/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Farbrausch V2M player
SDL Port by github.com/jgilje

0.20180825

convert to v2m newest version

0.20180821

fix error memory allocator
Expand Down
2 changes: 1 addition & 1 deletion doc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20180821
0.20180825
5 changes: 4 additions & 1 deletion man/man1/v2mplayer.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "V2mPlayer User Manual" 1 "0.20180819" "V2m documentation"
.TH "V2mPlayer User Manual" 1 "0.20180825" "V2m documentation"

.SH NAME
v2mplayer
Expand All @@ -19,6 +19,9 @@ force power size stdin buffer (int, optional, [0..10])
\fB-k\fP
key/auto stop (bool, optional, default = false)
.TP
\fB-o\fP str
output v2m newest version (string, optional, default = none)
.TP
\fB-h\fP
help

Expand Down
59 changes: 48 additions & 11 deletions src/tinyplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static void V2mPlayerUsage()
printf("options:\n");
printf(" -b force power size stdin buffer (int, optional, [0..10])\n");
printf(" -k key/auto stop (bool, optional, default = false)\n");
printf(" -o str output v2m newest version (string, optional, default = none)\n");
printf(" -h this help\n");
}
static void sdl_callback(void *userdata, Uint8 * stream, int len) {
Expand Down Expand Up @@ -69,11 +70,16 @@ static bool init_sdl()
return true;
}

static unsigned char* check_and_convert(unsigned char* tune, int length)
static unsigned char* check_and_convert(unsigned char* tune, unsigned int* length)
{
sdInit();

int version = CheckV2MVersion(tune, length);
if (tune[2] != 0 || tune[3] != 0)
{
SDL_LogCritical(SDL_LOG_CATEGORY_INPUT, "No valid input file");
return NULL;
}
int version = CheckV2MVersion(tune, *length);
if (version < 0)
{
SDL_LogCritical(SDL_LOG_CATEGORY_INPUT, "Failed to Check Version on input file");
Expand All @@ -82,7 +88,8 @@ static unsigned char* check_and_convert(unsigned char* tune, int length)

uint8_t* converted;
int converted_length;
ConvertV2M(tune, length, &converted, &converted_length);
ConvertV2M(tune, *length, &converted, &converted_length);
*length = converted_length;
free(tune);

return converted;
Expand All @@ -93,9 +100,11 @@ int main(int argc, char** argv)
V2mPlayerTitle();
int opt;
int fbuf = -1;
int fouts = 0;
int fkey = 0;
int fhelp = 0;
while ((opt = getopt(argc, argv, ":b:kh")) != -1)
char *foutput;
while ((opt = getopt(argc, argv, ":b:ko:h")) != -1)
{
switch(opt)
{
Expand All @@ -105,6 +114,10 @@ int main(int argc, char** argv)
case 'k':
fkey = 1;
break;
case 'o':
foutput = optarg;
fouts = 1;
break;
case 'h':
fhelp = 1;
break;
Expand All @@ -125,28 +138,28 @@ int main(int argc, char** argv)
unsigned char* theTune;
FILE* file;
uint64_t size;
size_t read = 0;
unsigned int blksz = 4096, read = 0, eofcnt = 0;
char ch;
if(optind + 1 > argc)
{
file = stdin;
if (fbuf < 0)
{
char ch;
int eofcnt = 0;
size = 1024;
eofcnt = 0;
size = blksz;
theTune = (unsigned char*) calloc(1, size);
if (theTune == NULL)
{
fprintf(stderr, "Error memory allocator: %Ld b\n", size);
exit(1);
}
ch = getc(stdin);
while (ch != EOF || eofcnt < 1024)
while (ch != EOF || eofcnt < blksz)
{
if (ch != EOF) {eofcnt = 0;} else {eofcnt++;}
if (read == size)
{
size += 1024;
size += blksz;
theTune = (unsigned char*)realloc(theTune, size * sizeof(unsigned char));
if (theTune == NULL)
{
Expand Down Expand Up @@ -200,7 +213,31 @@ int main(int argc, char** argv)
fprintf(stderr, "Invalid read size\n");
return 1;
}
theTune = check_and_convert(theTune, read);
fclose(file);
theTune = check_and_convert(theTune, &read);
if (theTune == NULL)
{
fprintf(stderr, "Error convert to newest\n");
exit(1);
}
printf("Convert: %d b\n", read);
while (theTune[read--] == 0){}
read++;
read++;
printf("Strip: %d b\n", read);

if (fouts)
{
FILE* fout;
fout = fopen(foutput, "a");
if (fout == NULL)
{
fprintf(stderr, "Failed to open %s\n", foutput);
return 1;
}
fwrite(theTune, 1, read, fout);
fclose(fout);
}

player.Init();
player.Open(theTune);
Expand Down
2 changes: 1 addition & 1 deletion src/v2mplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define V2MPLAYER_H_

#define PROJECTNAME "V2MPlayer"
#define PROJECTVERSION "0.20180821"
#define PROJECTVERSION "0.20180825"
#define PROJECTURL "github.com/jgilje"


Expand Down
Binary file modified v2m/Wayfinder--fr-041_debris-sfx.v2mz
Binary file not shown.
Binary file modified v2m/Wayfinder--kkrieger-chapter_i.v2mz
Binary file not shown.

0 comments on commit 57012ec

Please sign in to comment.