mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-24 11:29:18 +00:00
peasant: work on common word lookup
not quite there yet
This commit is contained in:
parent
d7a14b3dad
commit
ab1bdb4844
@ -1 +1,3 @@
|
||||
.include "text/peasant2.inc"
|
||||
;.include "text/peasant2.inc"
|
||||
.include "text/lookup.inc"
|
||||
.include "text/peasant2.inc.lookup"
|
||||
|
@ -1,7 +1,13 @@
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -Wall -g
|
||||
|
||||
all: dump_text
|
||||
all: dump_text shrink_text peasant2.inc.lookup
|
||||
|
||||
###
|
||||
|
||||
peasant2.inc.lookup: peasant2.inc shrink_text
|
||||
./shrink_text < peasant2.inc > peasant2.inc.lookup
|
||||
|
||||
|
||||
###
|
||||
|
||||
@ -13,8 +19,16 @@ dump_text.o: dump_text.c
|
||||
|
||||
###
|
||||
|
||||
shrink_text: shrink_text.o
|
||||
$(CC) -o shrink_text shrink_text.o $(LFLAGS)
|
||||
|
||||
shrink_text.o: shrink_text.c
|
||||
$(CC) $(CFLAGS) -c shrink_text.c
|
||||
|
||||
###
|
||||
|
||||
clean:
|
||||
rm -f *.o dump_text
|
||||
rm -f *.o dump_text shrink_text *.lookup
|
||||
|
||||
|
||||
|
||||
|
13
games/peasant/text/NOTES
Normal file
13
games/peasant/text/NOTES
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
orig lzsa word wordlzsa
|
||||
==== ==== ==== ====
|
||||
cliff 2836 1801
|
||||
inn 3815 2251
|
||||
inside 7213 4111
|
||||
peasant1 7465 4234
|
||||
peasant2 7439 4269 5807 4055
|
||||
peasant3 6229 3599
|
||||
peasant4 6819 3947
|
||||
|
||||
not peasant1/peasant4 has some of the kerrek text commented out
|
||||
so it would fit
|
85
games/peasant/text/lookup.inc
Normal file
85
games/peasant/text/lookup.inc
Normal file
@ -0,0 +1,85 @@
|
||||
DIALOG_ALREADY = $80
|
||||
DIALOG_COTTAGE = $81
|
||||
DIALOG_PEASANT = $82
|
||||
DIALOG_CAPITAL_THERES = $83
|
||||
DIALOG_CAPITAL_TROGDOR = $84
|
||||
|
||||
DIALOG_LITTLE = $85
|
||||
DIALOG_YOURE = $86
|
||||
DIALOG_CAPITAL_YOURE = $87
|
||||
|
||||
DIALOG_ABOUT = $88
|
||||
DIALOG_CANT = $89
|
||||
DIALOG_DONT = $8A
|
||||
DIALOG_THERE = $8B
|
||||
DIALOG_CAPITAL_THERE = $8C
|
||||
|
||||
DIALOG_BABY = $8D
|
||||
DIALOG_DEAD = $8E
|
||||
DIALOG_FROM = $8F
|
||||
DIALOG_HAVE = $90
|
||||
DIALOG_HERE = $91
|
||||
DIALOG_INTO = $92
|
||||
DIALOG_ITS = $93
|
||||
DIALOG_CAPITAL_ITS = $94
|
||||
DIALOG_JUST = $95
|
||||
DIALOG_LIKE = $96
|
||||
DIALOG_SAYS = $97
|
||||
DIALOG_SOME = $98
|
||||
DIALOG_THAT = $99
|
||||
DIALOG_CAPITAL_THAT = $9A
|
||||
DIALOG_THIS = $9B
|
||||
DIALOG_WITH = $9C
|
||||
DIALOG_YOUR = $9D
|
||||
|
||||
DIALOG_ALL = $9E
|
||||
DIALOG_AND = $9F
|
||||
DIALOG_ARE = $A0
|
||||
DIALOG_BUT = $A1
|
||||
DIALOG_FOR = $A2
|
||||
DIALOG_GET = $A3
|
||||
DIALOG_GOT = $A4
|
||||
DIALOG_HIM = $A5
|
||||
DIALOG_HIS = $A6
|
||||
DIALOG_NOT = $A7
|
||||
DIALOG_NOW = $A8
|
||||
DIALOG_OLD = $A9
|
||||
DIALOG_ONE = $AA
|
||||
DIALOG_OUT = $AB
|
||||
DIALOG_SEE = $AC
|
||||
DIALOG_THE = $AD
|
||||
DIALOG_CAPITAL_THE = $AE
|
||||
DIALOG_WAS = $AF
|
||||
DIALOG_YOU = $B0
|
||||
DIALOG_CAPITAL_YOU = $B1
|
||||
|
||||
DIALOG_AN = $B2
|
||||
DIALOG_AT = $B3
|
||||
DIALOG_BE = $B4
|
||||
DIALOG_DO = $B5
|
||||
DIALOG_GO = $B6
|
||||
DIALOG_HE = $B7
|
||||
DIALOG_CAPITAL_HE = $B8
|
||||
DIALOG_IN = $B9
|
||||
DIALOG_IS = $BA
|
||||
DIALOG_IT = $BB
|
||||
DIALOG_CAPITAL_IT = $BC
|
||||
DIALOG_MY = $BD
|
||||
DIALOG_NO = $BE
|
||||
DIALOG_CAPITAL_NO = $BF
|
||||
DIALOG_OF = $C0
|
||||
DIALOG_ON = $C1
|
||||
DIALOG_OR = $C2
|
||||
DIALOG_SO = $C3
|
||||
DIALOG_TO = $C4
|
||||
DIALOG_UP = $C5
|
||||
|
||||
;.byte "already","cottage","peasant","There's","Trogdor"
|
||||
;.byte "little","you're","You're"
|
||||
;.byte "about","can't","don't","there","There"
|
||||
;.byte "baby","dead","from","have","here","into","it's","It's"
|
||||
;.byte "just","like","says","some","that","That","this","with","your",
|
||||
;.byte "all","and","are","but","for","get","got","him","his","not"
|
||||
;.byte "now","old","one","out","see","the","The","was","you","You"
|
||||
;.byte "an","at","be","do","go","he","He","in","is","it","It"
|
||||
;.byte "my","no","No","of","on","or","so","to","up"
|
187
games/peasant/text/shrink_text.c
Normal file
187
games/peasant/text/shrink_text.c
Normal file
@ -0,0 +1,187 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NUM_WORDS 70
|
||||
|
||||
static char word_list[NUM_WORDS][20]={
|
||||
"already","cottage","peasant","There's","Trogdor",
|
||||
"little","you're","You're",
|
||||
"about","can't","don't","there","There",
|
||||
"baby","dead","from","have","here","into","it's","It's","just","like","says","some","that","That","this","with","your",
|
||||
"all","and","are","but","for","get","got","him","his","not","now","old","one","out","see","the","The","was","you","You",
|
||||
"an","at","be","do","go","he","He","in","is","it","It","my","no","No","of","on","or","so","to","up",
|
||||
};
|
||||
|
||||
static char replacement_list[NUM_WORDS][32]={
|
||||
"DIALOG_ALREADY",
|
||||
"DIALOG_COTTAGE",
|
||||
"DIALOG_PEASANT",
|
||||
"DIALOG_CAPITAL_THERES",
|
||||
"DIALOG_CAPITAL_TROGDOR",
|
||||
|
||||
"DIALOG_LITTLE",
|
||||
"DIALOG_YOURE",
|
||||
"DIALOG_CAPITAL_YOURE",
|
||||
|
||||
"DIALOG_ABOUT",
|
||||
"DIALOG_CANT",
|
||||
"DIALOG_DONT",
|
||||
"DIALOG_THERE",
|
||||
"DIALOG_CAPITAL_THERE",
|
||||
|
||||
"DIALOG_BABY",
|
||||
"DIALOG_DEAD",
|
||||
"DIALOG_FROM",
|
||||
"DIALOG_HAVE",
|
||||
"DIALOG_HERE",
|
||||
"DIALOG_INTO",
|
||||
"DIALOG_ITS",
|
||||
"DIALOG_CAPITAL_ITS",
|
||||
"DIALOG_JUST",
|
||||
"DIALOG_LIKE",
|
||||
"DIALOG_SAYS",
|
||||
"DIALOG_SOME",
|
||||
"DIALOG_THAT",
|
||||
"DIALOG_CAPITAL_THAT",
|
||||
"DIALOG_THIS",
|
||||
"DIALOG_WITH",
|
||||
"DIALOG_YOUR",
|
||||
|
||||
"DIALOG_ALL",
|
||||
"DIALOG_AND",
|
||||
"DIALOG_ARE",
|
||||
"DIALOG_BUT",
|
||||
"DIALOG_FOR",
|
||||
"DIALOG_GET",
|
||||
"DIALOG_GOT",
|
||||
"DIALOG_HIM",
|
||||
"DIALOG_HIS",
|
||||
"DIALOG_NOT",
|
||||
"DIALOG_NOW",
|
||||
"DIALOG_OLD",
|
||||
"DIALOG_ONE",
|
||||
"DIALOG_OUT",
|
||||
"DIALOG_SEE",
|
||||
"DIALOG_THE",
|
||||
"DIALOG_CAPITAL_THE",
|
||||
"DIALOG_WAS",
|
||||
"DIALOG_YOU",
|
||||
"DIALOG_CAPITAL_YOU",
|
||||
|
||||
"DIALOG_AN",
|
||||
"DIALOG_AT",
|
||||
"DIALOG_BE",
|
||||
"DIALOG_DO",
|
||||
"DIALOG_GO",
|
||||
"DIALOG_HE",
|
||||
"DIALOG_CAPITAL_HE",
|
||||
"DIALOG_IN",
|
||||
"DIALOG_IS",
|
||||
"DIALOG_IT",
|
||||
"DIALOG_CAPITAL_IT",
|
||||
"DIALOG_MY",
|
||||
"DIALOG_NO",
|
||||
"DIALOG_CAPITAL_NO",
|
||||
"DIALOG_OF",
|
||||
"DIALOG_ON",
|
||||
"DIALOG_OR",
|
||||
"DIALOG_SO",
|
||||
"DIALOG_TO",
|
||||
"DIALOG_UP",
|
||||
|
||||
};
|
||||
|
||||
|
||||
static int char_count=0,orig_count=0;
|
||||
|
||||
void parse_line(char *string) {
|
||||
int len;
|
||||
int i,j;
|
||||
int in_string=0;
|
||||
int in_quote=0;
|
||||
int dotfound=0,bfound=0,yfound=0,tfound=0,efound=0;
|
||||
|
||||
len=strlen(string);
|
||||
|
||||
for(i=0;i<len;i++) {
|
||||
|
||||
if ((!in_string) && (!in_quote)) {
|
||||
if (string[i]=='.') dotfound=1;
|
||||
else if ((dotfound)&&(string[i]=='b')) bfound=1;
|
||||
else if ((bfound)&&(string[i]=='y')) yfound=1;
|
||||
else if ((yfound)&&(string[i]=='t')) tfound=1;
|
||||
else if ((tfound)&&(string[i]=='e')) efound=1;
|
||||
else {
|
||||
dotfound=0;
|
||||
bfound=0;
|
||||
yfound=0;
|
||||
tfound=0;
|
||||
efound=0;
|
||||
}
|
||||
|
||||
if (efound) {
|
||||
in_string=1;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_string) {
|
||||
if (!in_quote) {
|
||||
if (string[i]=='\"') {
|
||||
in_quote=1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* in quote */
|
||||
if (string[i]=='\"') {
|
||||
in_quote=0;
|
||||
}
|
||||
else {
|
||||
orig_count++;
|
||||
char_count++;
|
||||
}
|
||||
}
|
||||
|
||||
for(j=0;j<NUM_WORDS;j++) {
|
||||
if (!strncmp(&string[i],word_list[j],
|
||||
strlen(word_list[j]))) {
|
||||
|
||||
// printf("MATCH %s%d %s%d\n",
|
||||
// &string[i],i,word_list[j],j);
|
||||
|
||||
printf("\",%s,\"",replacement_list[j]);
|
||||
orig_count+=strlen(word_list[j]);
|
||||
i+=strlen(word_list[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("%c",string[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char string[BUFSIZ];
|
||||
char *result;
|
||||
int length_of_table=0;
|
||||
int i;
|
||||
|
||||
for(i=0;i<NUM_WORDS;i++) {
|
||||
length_of_table+=strlen(word_list[i]);
|
||||
}
|
||||
|
||||
while(1) {
|
||||
|
||||
result=fgets(string,BUFSIZ,stdin);
|
||||
if (result==NULL) break;
|
||||
|
||||
parse_line(string);
|
||||
|
||||
}
|
||||
|
||||
printf("; Done! rough char count = %d, rough orig count = %d length_of_table = %d\n",
|
||||
char_count, orig_count, length_of_table);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user