Commit 81150889 authored by Derrick Sobodash's avatar Derrick Sobodash

Initial commit.

parent 40ed8486
<?php
include ("src/subs.php");
include ("src/maketables.php");
$fd = fopen("langriss.bin", "rb");
$filename = array("items.txt", "system.txt", "magic.txt", "units.txt", "names.txt", "credits.txt");
$offset = array(0x1066, 0x82a92, 0x82ba2, 0x82d1e, 0x9722c, 0xa332a);
for($i=0; $i<count($offset); $i++) {
$pointers = array();
fseek($fd, $offset[$i], SEEK_SET);
$m=0;
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
while(ftell($fd) < $pointers[0]) {
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
}
$fo = fopen("text/".$filename[$i], "w");
for($k=0; $k<count($pointers); $k++) {
fseek($fd, $pointers[$k], SEEK_SET);
$next_block = 0;
while($next_block == 0) {
$switch = hexdec(bin2hex(fread($fd, 1)));
if($switch == 0x0 ) fputs($fo, $font0[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x1) fputs($fo, $font1[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x2) fputs($fo, $font2[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x3) fputs($fo, $font3[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch ==0xff) {
$code = hexdec(bin2hex(fread($fd, 1)));
if($code == 0xf4 ) fputs($fo, "{reboot}");
elseif($code == 0xf7) {
$tmp = hexdec(bin2hex(fread($fd, 1)));
$tmp = hexdec(bin2hex(fread($fd, 1)));
fputs($fo, $char_names[$tmp]);
unset($tmp);
}
elseif($code == 0xf9) {
$tmp = hexdec(bin2hex(fread($fd, 1)));
$tmp = hexdec(bin2hex(fread($fd, 1)));
fputs($fo, "{portrait:$tmp}");
unset($tmp);
}
elseif($code == 0xfb) fputs($fo, "{fast_clear}\r\n");
elseif($code == 0xfc) {
fputs($fo, "{fast_end}\r\n\r\n");
$next_block++;
}
elseif($code == 0xfd) fputs($fo, "{clear}\r\n");
elseif($code == 0xfe) fputs($fo, "\r\n");
elseif($code == 0xff) {
fputs($fo, "{end}\r\n\r\n");
$next_block++;
}
}
}
unset($temp, $line_ptr, $next_block);
}
fclose($fo);
}
?>
\ No newline at end of file
<?php
include ("src/subs.php");
include ("src/maketables.php");
$fd = fopen("langriss.bin", "rb");
$filename = array("v_prologues.txt", "v_conditions.txt");
$offset = array(0x9cf7c, 0x98d7a);
$rawdata = array(0x9b2fc, 0x986c6);
$wrapwidth= array(0, 16);
for($i=0; $i<count($offset); $i++) {
$pointers = array();
$tables = array();
fseek($fd, $offset[$i], SEEK_SET);
$m=0;
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
while(ftell($fd) < $pointers[0]) {
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
}
fseek($fd, $rawdata[$i], SEEK_SET);
$m=0;
$tables[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
while(ftell($fd) < $tables[0]) {
$tables[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
}
$output = array();
$fo = fopen("text/".$filename[$i], "w");
for($k=0; $k<count($pointers); $k++) {
fseek($fd, $tables[$k], SEEK_SET);
$bank_font = array();
for($h=0; $h<256; $h++) {
$bank_font[$h] = fread($fd, 2);
}
//die(print bin2hex($bank_font[0]));
fseek($fd, $pointers[$k], SEEK_SET);
$next_block = 0;
while($next_block == 0) {
$switch = fread($fd, 1);
if(hexdec(bin2hex($switch)) != 0xff ) $output[$k] .= $bank_font[hexdec(bin2hex(fread($fd, 1)))];
else {
$code = fread($fd, 1);
if(hexdec(bin2hex($code)) == 0xff ) {
$output[$k] .= $switch . $code;
$next_block++;
}
elseif(hexdec(bin2hex($code)) == 0xf7 || hexdec(bin2hex($code)) == 0xf9) {
$output[$k] .= $switch . $code . fread($fd, 2);
}
else $output[$k] .= $switch . $code;
}
}
unset($temp, $line_ptr, $next_block);
}
for($k=0; $k<count($output); $k++) {
$temp = $output[$k];
$charchar=0;
for($z=0; $z<strlen($temp); $z++) {
$switch = hexdec(bin2hex($temp[$z]));
$code = hexdec(bin2hex($temp[$z+1]));
if($switch == 0x0 ) fputs($fo, $font0[$code]);
elseif($switch == 0x1) fputs($fo, $font1[$code]);
elseif($switch == 0x2) fputs($fo, $font2[$code]);
elseif($switch == 0x3) fputs($fo, $font3[$code]);
elseif($switch ==0xff) {
if($code == 0xf4 ) fputs($fo, "{reboot}");
elseif($code == 0xf7) {
$tmp = hexdec(bin2hex($temp[$z+3]));
fputs($fo, $char_names[$tmp]);
$charchar += (strlen($char_names[$tmp])/2)-1;
$z+=2;
unset($tmp);
}
elseif($code == 0xf9) {
$tmp = hexdec(bin2hex($temp[$z+3]));
fputs($fo, "{portrait:$tmp}");
$z+=2;
unset($tmp);
}
elseif($code == 0xfb) fputs($fo, "{fast_clear}\r\n");
elseif($code == 0xfc) {
fputs($fo, "{fast_end}\r\n\r\n");
$next_block++;
}
elseif($code == 0xfd) fputs($fo, "{clear}\r\n");
elseif($code == 0xfe) { fputs($fo, "\r\n"); $charchar = -1; }
elseif($code == 0xff) {
fputs($fo, "{end}\r\n\r\n");
$next_block++;
}
}
$z++;
$charchar++;
if($charchar>0 && $wrapwidth[$i]>0) if($charchar % $wrapwidth[$i] == 0) fputs($fo, "\r\n");
}
}
fclose($fo);
}
?>
\ No newline at end of file
<?php
include ("src/subs.php");
include ("src/maketables.php");
$fd = fopen("langriss.bin", "rb");
$filename = array("w_items.txt", "w_descriptions.txt");
$offset = array(0xa18f2, 0xa1d6c);
$rawdata = array(0xa149c, 0xa151e);
$wrapwidth= array(0, 9);
for($i=0; $i<count($offset); $i++) {
$pointers = array();
fseek($fd, $offset[$i], SEEK_SET);
$m=0;
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
while(ftell($fd) < $pointers[0]) {
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
}
fseek($fd, $rawdata[$i], SEEK_SET);
$bank_font = array();
for($k=0; $k<256; $k++) {
$bank_font[$k] = fread($fd, 2);
}
//die(print bin2hex($bank_font[0]));
$output = array();
$fo = fopen("text/".$filename[$i], "w");
for($k=0; $k<count($pointers); $k++) {
fseek($fd, $pointers[$k], SEEK_SET);
$next_block = 0;
while($next_block == 0) {
$switch = fread($fd, 1);
if(hexdec(bin2hex($switch)) != 0xff ) $output[$k] .= $bank_font[hexdec(bin2hex(fread($fd, 1)))];
else {
$code = fread($fd, 1);
if(hexdec(bin2hex($code)) == 0xff ) {
$output[$k] .= $switch . $code;
$next_block++;
}
elseif(hexdec(bin2hex($code)) == 0xf7 || hexdec(bin2hex($code)) == 0xf9) {
$output[$k] .= $switch . $code . fread($fd, 2);
}
else $output[$k] .= $switch . $code;
}
}
unset($temp, $line_ptr, $next_block);
}
for($k=0; $k<count($output); $k++) {
$temp = $output[$k];
$charchar=0;
for($z=0; $z<strlen($temp); $z++) {
$switch = hexdec(bin2hex($temp[$z]));
$code = hexdec(bin2hex($temp[$z+1]));
if($switch == 0x0 ) fputs($fo, $font0[$code]);
elseif($switch == 0x1) fputs($fo, $font1[$code]);
elseif($switch == 0x2) fputs($fo, $font2[$code]);
elseif($switch == 0x3) fputs($fo, $font3[$code]);
elseif($switch ==0xff) {
if($code == 0xf4 ) fputs($fo, "{reboot}");
elseif($code == 0xf7) {
$tmp = hexdec(bin2hex($temp[$z+3]));
fputs($fo, $char_names[$tmp]);
$charchar += (strlen($char_names[$tmp])/2)-1;
unset($tmp);
}
elseif($code == 0xf9) {
$tmp = hexdec(bin2hex($temp[$z+3]));
fputs($fo, "{portrait:$tmp}");
unset($tmp);
}
elseif($code == 0xfb) fputs($fo, "{fast_clear}\r\n");
elseif($code == 0xfc) {
fputs($fo, "{fast_end}\r\n\r\n");
$next_block++;
}
elseif($code == 0xfd) fputs($fo, "{clear}\r\n");
elseif($code == 0xfe) { fputs($fo, "\r\n"); $charchar = -1; }
elseif($code == 0xff) {
fputs($fo, "{end}\r\n\r\n");
$next_block++;
}
}
$z++;
$charchar++;
if($charchar>0 && $wrapwidth[$i]>0) if($charchar % $wrapwidth[$i] == 0) fputs($fo, "\r\n");
}
}
fclose($fo);
}
?>
\ No newline at end of file
<?php
include ("src/subs.php");
include ("src/maketables.php");
$fd = fopen("langriss.bin", "rb");
$filename = array("classes8n.txt", "items8n.txt", "names8n.txt");
$offset = array(0x5e6d6, 0x60364, 0x618e8);
$offend = array(0x5e94a, 0x603fc, 0x61abc);
for($i=0; $i<count($offset); $i++) {
$pointers = array();
fseek($fd, $offset[$i], SEEK_SET);
$m=0;
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
while(ftell($fd) < $offend[$i]) {
$pointers[$m] = hexdec(bin2hex(fread($fd, 4)));
$m++;
}
$fo = fopen("text/".$filename[$i], "w");
for($k=0; $k<count($pointers); $k++) {
fseek($fd, $pointers[$k], SEEK_SET);
$next_block = 0;
while($next_block == 0) {
$switch = fread($fd, 1);
if(hexdec(bin2hex($switch)) == 0xff) {
fputs($fo, "{end}\r\n");
$next_block++;
}
else fputs($fo, $switch);
}
unset($temp, $line_ptr, $next_block);
}
fclose($fo);
}
?>
\ No newline at end of file
Copyright (c) 2012, Derrick Sobodash
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
php scendump.php
php epdump.php
php 16ndump.php
php 16wdump.php
php 16vdump.php
php 8ndump.php
php rip.php langriss.bin 0xa6b98 898 text/ending.txt
php rip.php langriss.bin 0xa6b10 136 text/bernhardt.txt
php rip.php langriss.bin 0xa3afc 18 text/erwin_default.txt
<?php
include ("src/subs.php");
include ("src/maketables.php");
$fd = fopen("langriss.bin", "rb");
$pointers = getpointers("pnt/epilogue.pnt");
$fo = fopen("text/epilogue.txt", "w");
for($k=0; $k<count($pointers); $k++) {
fseek($fd, $pointers[$k], SEEK_SET);
$line_ptr = hexdec(bin2hex(fread($fd, 4)));
fseek($fd, $line_ptr, SEEK_SET);
$next_block = 0;
while($next_block == 0) {
$switch = hexdec(bin2hex(fread($fd, 1)));
if($switch == 0x0 ) fputs($fo, $font0[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x1) fputs($fo, $font1[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x2) fputs($fo, $font2[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch == 0x3) fputs($fo, $font3[hexdec(bin2hex(fread($fd, 1)))]);
elseif($switch ==0xff) {
$code = hexdec(bin2hex(fread($fd, 1)));
if($code == 0xf4 ) fputs($fo, "{reboot}");
elseif($code == 0xf7) {
$tmp = hexdec(bin2hex(fread($fd, 1)));
$tmp = hexdec(bin2hex(fread($fd, 1)));
fputs($fo, $char_names[$tmp]);
unset($tmp);
}
elseif($code == 0xf9) {
$tmp = hexdec(bin2hex(fread($fd, 1)));
$tmp = hexdec(bin2hex(fread($fd, 1)));
fputs($fo, "{portrait:$tmp}");
unset($tmp);
}
elseif($code == 0xfb) fputs($fo, "{fast_clear}\r\n");
elseif($code == 0xfc) {
fputs($fo, "{fast_end}\r\n\r\n");
$next_block++;
}
elseif($code == 0xfd) fputs($fo, "{clear}\r\n");
elseif($code == 0xfe) fputs($fo, "\r\n");
elseif($code == 0xff) {
fputs($fo, "{end}\r\n\r\n");
$next_block++;
}
}
}
unset($temp, $line_ptr, $next_block);
}
fclose($fo);
?>
\ No newline at end of file
561590
561602
561614
561626
561638
561650
561662
561674
561686
561700
561712
561724
561736
561748
561760
561772
561784
561796
561810
561822
561834
561846
561858
561870
561882
561894
561906
561920
561932
561944
561956
561968
561980
561992
562004
562016
562030
562042
562054
562066
562078
562090
562102
562114
562126
562140
562152
562164
562176
562188
562200
562212
562224
562236
562250
562262
562274
562286
562298
562310
562322
562334
562346
562360
562372
562384
562396
562408
562420
562432
562444
562456
562470
562484
562498
562512
562526
562540
562554
562566
562578
1590030
1590038
1590046
1590054
1590062
1590070
1590088
1590096
1590104
1590114
1590122
1590154
1590168
1590178
1590192
1590206
1590214
1590224
1590234
1590244
1590252
1590268
1590278
1590296
1590304
1590312
1590320
1590328
1590342
1590350
1590364
1590374
1590384
1590394
1590404
1590422
1590436
1590446
1590454
1590464
1590478
1590488
1590496
1590504
1590518
1590532
1590548
1590558
1590566
1590574
1590582
1590592
1590606
1590616
1590624
1590642
1590650
1590658
1590666
1590674
1590682
1590690
1590698
1590706
1590716
1590724
1590732
1590742
1590752
1590760
1590780
1590788
1590796
1590804
1590812
1590822
1590830
1590838
1590894
1590902
1590922
1590940
1590950
1590958
1590966
1590974
1590988
1591004
1591050
1591058
1591066
1591080
1591088
1591102
1591116
1591130
1591144
1591158
1591166
1591174
1591182
1591190
1591198
1591206
1591214
1591228
1591236
1591244
1591252
1591264
1591274
1591282
1591290
1591298
1591330
1591340
1591354
1591368
1591378
1598112
1598130
1598138
1598146
1598154
1598162
1598170
1598178
1598186
1598194
1598202
1598210
1598218
1598228
1598274
1598282
1598290
1598298
1598306
1598314
1598322
1598330
1598338
1598346
1598354
1598362
1598370
1598390
1598398
1598422
1598430
1598438
1598446
1598456
1598464
1598492
1598526
1598560
1598594
1598628
1598656
1598664
1598678
1598686
1598712
1598728
1598738
1598752
1598766
1598782
1598806
1598814
1598828
1598836
1598848
1598858
1598868
1598878
1598888
1598898
1598912
1598920
1598932
1598942
1598982
1598992
1599032
1599048
1599064
1599078
1599086
1599094
1599102
1599118
1599134
1599144
1599154
1599164
1599174
1599184
1599194
1599204
1599214
1599224
1599234
1599252
1599260
1599274
1599294
1599308
1599316
1599334
1599342
1599376