Skip to content

Commit 97e42e0

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 002f310 + c301d2a commit 97e42e0

37 files changed

+6384
-335
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ env:
88
- CABALVER=1.22 GHCVER=7.10.1
99
- CABALVER=head GHCVER=head # see section about GHC HEAD snapshots
1010

11+
matrix:
12+
allow_failures:
13+
- env: CABALVER=head GHCVER=head
14+
1115
# Note: the distinction between `before_install` and `install` is not important.
1216
before_install:
1317
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc

Changelog.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Changelog for tttool
2+
3+
## 1.4 (2015-04-29)
4+
5+
* The `tttool play` command is greatly enhanced:
6+
+ Audio samples are actually played (On linux, install `sox`).
7+
+ You can use the name of your scripts instead of the OID codes.
8+
+ The prompt supports a persistent history (press ↑).
9+
+ You can tab-complete your input.
10+
* `tttool` knows its own version.
11+
* `tttool assemble` warns if the comment field is too long for the GME file.
12+
13+
## 1.3 (2015-03-18)
14+
15+
* The `tttool play` command now supports jump commands.
16+
17+
## 1.2 (2015-03-08)
18+
19+
* The `language` fields takes arbitrary strings, which will hopefully be
20+
understood by the text-to-speak engine.
21+
22+
## 1.1 (2015-02-15)
23+
24+
* The yaml files support a `language` field, specifying the default language
25+
for the text-to-speech feature.
26+
* The `speak` section of the yaml file can have subsections with differing
27+
languge settings, to allow multi-language files.
28+
* The text-to-speech feature will use either pico2wave or espeak, depending on
29+
what is available.
30+
* The windows release zipfile now comes with espeak and oggenc, so Windows users
31+
can use text-to-speech out of the box.
32+
33+
## 1.0 (2015-01-29)
34+
35+
* Last release without a changelog

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
tttool: tttool.hs
2-
ghc -O -with-rtsopts=-K100M tttool.hs
1+
tttool: src/*.hs
2+
# cabal update
3+
cabal install --only-dependencies
4+
cabal install --bindir=.
35

46
all: tttool libtiptoi gameanalyse makegraphic
57

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ you to dissect these files.
1515
The tool can also be used to generate completely new files from scratch; see
1616
below for details.
1717

18-
If you want to learn more, here are some relevant links:
19-
* Discussion about Tip-Toi: http://www.quadrierer.de/geekythinking/blog/?itemid=368 (German)
20-
* Discussion about Tip-Toi and the related TING pen, including discussion on how to print your own books: http://www.mikrocontroller.net/topic/214479 (German)
18+
If you want to learn more please have a look into our wiki (https://github.com/entropia/tip-toi-reveng/wiki).
2119

2220
The tttool tool
2321
---------------
@@ -58,7 +56,7 @@ supports various subcommands:
5856
lists all unknown parts of the file.
5957
explain <file.gme>...
6058
lists all parts of the file, with description and hexdump.
61-
play <file.gme>
59+
play <file.gme or file.yaml>
6260
interactively play: Enter OIDs, and see what happens.
6361
rewrite <infile.gme> <outfile.gme>
6462
parses the file and serializes it again (for debugging).
@@ -102,7 +100,7 @@ Otherwise, installation from source is not difficult either:
102100
`cabal`, and you should run the two commands
103101

104102
cabal update
105-
cabal install --dependencies-only
103+
cabal install --only-dependencies
106104

107105
3. Now you can build the program using
108106

@@ -153,7 +151,7 @@ things you did if you succeded.
153151
Text to speech
154152
--------------
155153

156-
If you have libttspico-utils and vorbis-tools installed, you can have tttool
154+
If you have `libttspico-utils` and `vorbis-tools installed`, you can have tttool
157155
generate audio files from text for you, which makes developing your yaml file
158156
much easier. See [text2speech.yaml](text2speech.yaml) for more information.
159157

@@ -194,5 +192,5 @@ Other resources in this repository
194192
* `matlab/` contains scripts to analyse gme files in Matlab
195193
* `wip/` (work in progess) contains notes about the parts of the gme files that are not
196194
fully understood yet.
197-
195+
* `perl-tools` contains a perl based script, to generate a PDF with all OID codes from a yaml-file as well some functions to generate PNG-files, inject pHYs-chunks with resolution hints into GD generated PNG files as result from some testing
198196

example.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# ./tttool assemble example.yaml example.gme
66

77
# The product ID must match that of the book you want to use this with
8-
# If you generate your own codes, then this corresponds to "tttool oid-code 272".
98
product-id: 42
109

1110
# The media path is optional
@@ -32,7 +31,6 @@ welcome: bing, hello
3231
scripts:
3332
# We begin to specify what to do when the area in the book with the OID code
3433
# 8066 is touched.
35-
# This corresponds to "tttool oid-code 3701", and so on for the next few codes.
3634
8066:
3735
# The following line means: If register $mode is set to 1, then set it to 2, and
3836
# increment register $1 by one, and play the sound example/hello.ogg.

gen-windows-release.sh

+40-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,58 @@
11
#!/bin/bash
22

33
set -e
4-
wine cabal install --bindir=.
4+
wine cabal install --distdir=dist-win --bindir=.
55
(cd Audio/digits/; ./build.sh)
66

7-
rev=$(git describe --always)
8-
zipfile=tttool-win32-$rev.zip
7+
rev=$(git describe --tags)
8+
zipfile=tttool-win32-$rev.zip
99
rm -f $zipfile
1010

11-
zip $zipfile \
11+
# Oggenc
12+
OGGENC=oggenc2.87-1.3.5-generic.zip
13+
14+
mkdir -p contrib
15+
test -e contrib/$OGGENC ||
16+
wget http://www.rarewares.org/files/ogg/$OGGENC -O contrib/$OGGENC
17+
unzip -d contrib contrib/$OGGENC oggenc2.exe
18+
mv contrib/oggenc2.exe contrib/oggenc.exe
19+
20+
#SDL
21+
SDL=SDL-1.2.15-win32.zip
22+
SDLMIXER=SDL_mixer-1.2.12-win32.zip
23+
24+
test -e contrib/$SDL ||
25+
wget http://libsdl.org/release/$SDL -O contrib/$SDL
26+
unzip -o -d contrib contrib/$SDL
27+
test -e contrib/$SDLMIXER ||
28+
wget https://www.libsdl.org/projects/SDL_mixer/release/$SDLMIXER -O contrib/$SDLMIXER
29+
unzip -o -d contrib contrib/$SDLMIXER
30+
31+
cp -v playmus/playmus.exe contrib/playmus.exe
32+
33+
# install espeak first in wine
34+
cp ~/.wine/drive_c/Programme/eSpeak/command_line/espeak.exe contrib/
35+
cp -r ~/.wine/drive_c/Programme/eSpeak/espeak-data/ contrib/
36+
37+
zip --recurse-paths $zipfile \
1238
tttool.exe \
1339
README.md \
40+
Changelog.md \
1441
oid-decoder.html \
1542
example \
1643
example.yaml \
17-
debug.yaml \
44+
Debug.yaml \
1845
oid-table.png \
1946
templates/README.md \
2047
templates/*.yaml \
2148
transcript/*.csv \
2249
wip/* \
23-
Audio/digits/*.ogg
50+
Audio/digits/*.ogg \
51+
contrib/oggenc.exe \
52+
contrib/espeak.exe \
53+
contrib/espeak-data \
54+
contrib/LICENSE* \
55+
contrib/README-SDL.txt \
56+
contrib/*.dll \
57+
contrib/playmus.exe
2458
echo Created $zipfile

libtiptoi.c

+22-4
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ GME_AUDIO_FILE_TABLE *createAudioTable(GME_FILE *gme, char *filepath,int useNumb
186186
if (useNumbers){
187187
sprintf(audioFileName,"%s/%04d.ogg", filepath, i);
188188
}else{
189+
if (fplist == NULL) {
190+
fprintf(stderr,"Could not open file %s\n", filepath);
191+
exit(1);
192+
}
189193
fscanf(fplist, "%s", audioFileName);
190194
}
191195
aft[i].offset = nextOffset;
@@ -209,10 +213,18 @@ void addAudioFiles(GME_FILE *gme, GME_AUDIO_FILE_TABLE *aft, uint8_t *data, char
209213
if (useNumbers){
210214
sprintf(audioFileName,"%s/%04d.ogg", filepath, i);
211215
}else{
216+
if (fplist == NULL) {
217+
fprintf(stderr,"Could not open file %s\n", filepath);
218+
exit(1);
219+
}
212220
fscanf(fplist, "%s", audioFileName);
213221
}
214222

215223
fp = fopen(audioFileName, "rb");
224+
if (fp == NULL) {
225+
fprintf(stderr,"Could not open file %s\n", audioFileName);
226+
return;
227+
}
216228
fread(cpos, 1, aft[i].lenght, fp);
217229
fclose(fp);
218230
for (j = 0; j < aft[i].lenght; j++){
@@ -259,7 +271,7 @@ GME_AUDIO_SCRIPT *readFilelist(char *filelist, uint32_t firstOffset){
259271
fseek(fp, 0, SEEK_SET);
260272

261273
if ((gas = malloc(sizeof(GME_AUDIO_SCRIPT))) == NULL || (gas->data = malloc(filesize+1)) == NULL){
262-
fprintf(stderr, "Could not allocate memory\n", filelist);
274+
fprintf(stderr, "Could not allocate memory: %d\n", filesize+1);
263275
exit(1);
264276
}
265277
gas->fileCount = 0;
@@ -316,6 +328,8 @@ GME_AUDIO_SCRIPT *readFilelist(char *filelist, uint32_t firstOffset){
316328
}
317329
}
318330
}
331+
332+
return gas;
319333
}
320334

321335
//Replace audio files with files from given list
@@ -348,13 +362,17 @@ void replaceAudio(char *inputfile, char *outputfile, char *filepath, int useNumb
348362
*((uint32_t*)dataPos) = calculateChecksum(data, dataPos-data);
349363

350364
fp = fopen(outputfile, "wb");
365+
if (fp == NULL) {
366+
fprintf(stderr,"Could not open file %s for writing\n", outputfile);
367+
exit(1);
368+
}
351369
fwrite(data, 1, dataLength, fp);
352370
fclose(fp);
353371
}
354372

355373
//Exports all audio files and creates a filelist.txt with every filename
356374
//for use by replace functionality
357-
int exportAudioFiles(char *inputfile, char *path, int filelistOnly){
375+
void exportAudioFiles(char *inputfile, char *path, int filelistOnly){
358376
GME_FILE *gme = readFile(inputfile);
359377
char filename[1024];
360378
uint8_t *file;
@@ -368,7 +386,7 @@ int exportAudioFiles(char *inputfile, char *path, int filelistOnly){
368386
sprintf(filename, "%sfilelist.txt", path);
369387
if ((fplist = fopen(filename, "wb")) == NULL){
370388
fprintf(stderr, "Could not open outputfile '%s'", filename);
371-
exit(0);
389+
exit(1);
372390
}
373391
for (i = 0; i < gme->audioFileTableEntries; i++){
374392
duplicate = 0;
@@ -452,7 +470,7 @@ void printInformation(char *inputfile, FILE *out){
452470
uint32_t jumpTableOffset;
453471
uint32_t *gjt;
454472
uint16_t elements;
455-
fprintf(out,"Filesize: %d\n", gme->filesize);
473+
fprintf(out,"Filesize: %ld\n", gme->filesize);
456474
fprintf(out,"File checksum: 0x%0X\n", gme->checksum);
457475
fprintf(out,"Calc checksum: 0x%0X\n", calculateChecksum(gme->data, gme->filesize - 4));
458476
fprintf(out,"XOR value: 0x%0X\n", gme->xor);

matlab/decode.m

-24
This file was deleted.

matlab/decodejumptableline.m

-21
This file was deleted.

matlab/decryptaudiofile.m

-14
This file was deleted.

matlab/getandsaveaudiofiles.m

-13
This file was deleted.

matlab/getaudiofile.m

-6
This file was deleted.

matlab/getaudiotable.m

-21
This file was deleted.

matlab/getjumptable.m

-12
This file was deleted.

0 commit comments

Comments
 (0)