Add tb_asm to the repository

This commit is contained in:
Vince Weaver 2012-12-18 21:43:40 -05:00
parent 67b1d05118
commit a3f4fd0683
69 changed files with 8003 additions and 0 deletions

86
tb_asm/Changelog.tb_asm Normal file
View File

@ -0,0 +1,86 @@
25 December 2002
+ Get idea from friend
+ Start implementing in C
?? January 2003
+ Finish title, about, story options
?? January 2003
+ Add "quit, are you sure" display
?? February 2003
+ Port all of C version at time to assembler
?? February 2003
+ Add help screen to C version
+ Add help screen to asm version
?? February 2003
+ Add ansi-code sound effects to C version
?? February 2003
+ Finish varied enemies and boss on C version
?? February 2003
+ Add save game support to C version
4 March 2003
+ Started adding actual game support to assembler
+ Frame limiter and pause/sound/help work
6 March 2003
+ Added pseudo-random number generator
+ Added scrolling star background
+ Added missiles
10 March 2003
+ Added int->ascii routine
+ Added bottom status bar
11 March 2003
+ Simple enemy movement.
12 March 2003
+ Added collision detection.
17 March 2003
+ Added enemy behavior
18 March 2003
+ Added sound
+ Added hi-score support
+ Added level announce
19 March 2003
+ Added boss
+ Polished a bit
+ Put rep / stosb on separate lines so works with as 2.9.1
20 March 2003
+ Added "restore colors" at exit time
+ Removed extra spaces from strings... saves 100 bytes
+ Lots of infrastructute to compress data segment... saves 2k
+ Change all the cool "bt/btr/bts/btc" op-codes to equivelant
or/and/xor. The former was cool, but slightly longer. Sad, sad.
+ Found if I remove ".data" the text+data segments are merged saving
3k. Cool, especially as I don't write to the data segment at all anymore.
+ Use sstrip. There are random file lengths that either "strip" or
"sstrip" don't handle well. May have to pad things out in the end
21 March 2003
+ convert "get_char" and "get_a_char" to return status in the carry flag.
+ Much optimization. See "optimization" file.
+ Now under 8k ;)
23 March 2003
+ Extensive play-testing to make sure optimization didn't break game.
+ Fix "sstrip" program so it puts the bss on the proper boundry.
Hope this isn't "as" version specific.
+ Game balancing. Moved up to 6 enemies. Slight shifts in
game engine constants.
+ Fix problem where enemies get stuck at level 4. As a result
level 7 never ends, as we do tricks where we use level*16 and
over 7 that overflows to negative.
+ Play tested. Seems ok. Release 0.32!

168
tb_asm/FAQ.tb_asm Normal file
View File

@ -0,0 +1,168 @@
Q. Why?
A. My friend <A href="http://www.deater.net/john">John</A> got a Gameboy
Advance for Christmas. He suggested I port my game
<A href="http://www.deater.net/weave/vmwprod/tb1">Tom Bombem</A> to it.
In actuality the specs of the GBA are similar to the machine I
originally wrote TB1 on. It was on a 386-33 with 320x200x256 graphics
and constrained to 640kB of RAM. The game was written in 16-bit
PASCAL with some 32-bit assembly.
I thought I should attempt a x86 assembly version before I go and learn
ARM assembly.
Q. How did you do the graphics.
A. With <A href="http://www.thegimp.org">The Gimp</A>. Used 16 color indexed
palette. Saved as xpm. Edited with text editor.
Q. Why text mode?
A. Because doing graphics in Linux is a pain. And I didn't feel like
messing with the framebuffer. This was a proof-of-concept, not a
designed-for-release game.
Q. Why 40x20 resolution?
A. Because I'd like to port it to Apple IIe low-res graphics mode.
Q. Why not a DOS version?
A. Should be technically possible, although it's been a while and gas
isn't the best assembler for it. Also doing things like reading
the keyboard/getting timestamps/speaker noise are more complicated.
More interesting would be a version using Windows console syscalls.
Q. What is the high score?
A. A bit of a silly question as anyone can edit a text file and lie. The
highest score I've gotten is 14170 on level 4.
But this isn't saying much, I tend to be debugging more than playing.
The highest _possible_ score is 2^31 or about 2 billion. Actually
it might be 4 billion, I am not sure how my int->ascii code handles
signed numbers.
Q. Why does the ship have its engines constantly on, even though
it is moving at a constant velocity?
A. Ummmm... friction. Yeah... space friction.
Q. Why are the stars moving so quickly? Are you going faster than light?
A. If you look closely you'll notice the stars repeat. Hence you
are really flying very fast in a big circle. Hey, maybe that's
why the engine is constantly firing!
Q. Where in that tiny ship are all of those missiles stored?
A. In the seventh dimension.
Q. Why the seventh dimension?
A. The others were all full.
Q. Why is there a guinea pig in the game?
A. A local guinea pig threatened me with violence if I did not include
a picture of her.
Q. What have you learned from all this assembly programming?
A. I'm just reminded what Professor Jacob always said...
A computer is just a state machine.
Q. What do you hate most about the GNU Assembler "gas"?
A. It doesn't warn you when a "loop" instruction overflows
128 thus causing your program to go off into la-la land.
It also doesn't do type checking causing you headaches if
you forget the "b" on cmpb.
But you can't really blame it, it's used to dealing with
gcc which is a very good and proper assembler-producer,
unlike the author.
Q. Why are there only 6 enemies / 2 missiles / shields go up at 320/ etc?
A. Game balance. Just trying to keep it challenging yet not overwhlmingly
so. [For the original tb1 it was "because my 386 can't keep up" but
that should be less of a problem these days].
If you _must_ have it some other way, feel free to mess with the constants
on the first page of the tb_asm.s file, but I cannot guarantee what
the consequences might be!
Q. Will there be a sequel?
A. Yes, it will be released shortly before either the release of
"Duke Nukem Forever (tm)" or the heat death of the universe,
which ever happens first.
Q. Why can't Vince stay consitent between "HISCORE" and "HIGH SCORE"
including all possibly variations of "HI-SCORE" "HIGH_SCORE" usw?
A. The world may never know.
Q. What does "usw" mean?
A. Und So Weiter.
Q. That wasn't helpful.
A. This isn't a question.
Q. What's the highest level you can get to?
A. No matter how you try, once you get to level 7 it will
keep repeating. This is because I multiply the level
by 16 in various places for enemy movement, and it it goes
above 7 then the byte will be negative causing
Bad Things(tm) to happen.
Q. Well why don't you modify the code so it doesn't go haywire
after level 7?
A. I am lazy. Also it should be too hard to get to level 7 anyway
Q. What are the enemies supposed to be?
A. An envelope, a clip-board, a cigarette, a telephone, a dollar-bill,
and an un-identified yellow thing, possibly a banana. All things
malicious marketers might have in excess.
Q. How come the stars appear in straight bands insteas of scattered in the
sky?
A. Because my pseudo-random number algorithm is at times more pseudo
than random.

47
tb_asm/Makefile Normal file
View File

@ -0,0 +1,47 @@
CC=gcc
CFLAGS = -Wall -O2
LFLAGS =
all: tb_asm configure compress_data
./sstrip/sstrip:
cd sstrip && make
compress_data: compress_data.o lzss.o
$(CC) $(LFLAGS) -o compress_data compress_data.o lzss.o
compress_data.o: compress_data.c
$(CC) $(CFLAGS) -c compress_data.c
lzss.o: lzss.c
gcc -O2 -Wall -c lzss.c
lzss_new.o: lzss_new.c
gcc -O2 -Wall -c lzss_new.c
tb_asm: tb_asm.o ./sstrip/sstrip
ld -o tb_asm tb_asm.o
./sstrip/sstrip tb_asm
tb_asm.o: tb_asm.s data.lzss data.labels
as -o tb_asm.o tb_asm.s
tb_asm.s: configure
./configure
data.labels: compress_data
./compress_data
data.lzss: compress_data data.inc
./compress_data
configure: configure.c
gcc -O2 -Wall -o configure configure.c
clean:
rm -f *~ *.o tb_asm tb_asm.s core configure compress_data data.lzss data.header data.raw data.labels
cd sstrip && $(MAKE) clean

99
tb_asm/README.tb_asm Normal file
View File

@ -0,0 +1,99 @@
TOM BOMBEM: Merciless Marauding Malicious Marketers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.deater.net/weave/vmwprod/tb1/tb_asm.html
by Vince Weaver <vince@deater.net>
version 0.24 -- 19 March 2003
Background:
~~~~~~~~~~~
You are Tom Bombem, a shy new intern on Moonbase Alpha.
Somewhat against your will it has become your job to
defend Earth! See the "Story" option in the game
for the rest of the story.
tb_asm comes before "tb1: Invasion of the Inanimate Objects"
chronologically, for those who might care.
Compiling / Running:
~~~~~~~~~~~~~~~~~~~~
Just run "make". If you have a supported architecture "tb_asm"
will be created.
If you don't have an ix86 or ppc computer, you can try in the
"c" subdirectory and do "make" there to run a "C" version of the game
that should run on and architecture. The "C" version is not
as feature-complete.
After compiling just run "./tb_asm"
tb_asm will run _ONLY_ on Linux. A DOS/w32 port could be possible
but I really don't have the time or desire to mess with it.
tb_asm should be run at the text_console [if in X press CTRL-ALT-F1].
It will run to some extent in an x-term, but w/o sound.
Keybindings:
~~~~~~~~~~~
Use arrow keys, or i,j,k,m to manuever and navigate menus.
' ' shoots and selects.
'h' displays help. 's' toggles sound 'p' pauses
Options/Hiscore File:
~~~~~~~~~~~~~~~~~~~~~
tb_asm will create the file "/tmp/tb_asm.hsc" to store the hiscore.
tb_asm will only write the file if it's not there, or if there
is a file there that is at least 12 bytes long and starts
with "tb".
Besides the hiscore tb_asm also stores the "sound on/sound off"
state in this file.
Game Play:
~~~~~~~~~~
Manuever your ship avoiding the falling objects. Shoot them.
Only 2 missiles can be in the air at the time [this is _not_ a bug.
it's a limit of your ship's missile guidance system].
Every 320 points your shields will increase.
There are special bonuses you can earn at the end of each level.
+ No Shields Hit : going through an entire level without
having an enemy hit your ship
+ All Enemies Destroyed : all enemies were destroyed before
scrolling off the screen. [Note,
ramming an enemy with your ship
_DOES_ count as destroying it. Just
don't let them get by you]
+ Perfect Shot: Every missile fired hits an enemy.
At the end each level you fight the boss. Then the game starts over
with the enemies moving faster!
About:
~~~~~~
(see also the FAQ.asm file)
This was done as an exercise to see if I could make a Tom-Bombem
class game entirely in assembly language. I've optimized for
size rather than speed. And most likely it's not _completely_
optimized for size yet.
The hope is maybe eventually using this as a stepping-board to
creating a Game Boy Advance TomBombem game.
Author:
~~~~~~~
Vince Weaver <vince@deater.net>
http://www.deater.net/weave/
Special Thanks to KRG
19 March 2003

2
tb_asm/TODO Normal file
View File

@ -0,0 +1,2 @@
have the boss go away before final explosion
"demo" mode of self playing

32
tb_asm/arch.h Normal file
View File

@ -0,0 +1,32 @@
#define ARCH_UNKNOWN 0
#define ARCH_ALPHA 1
#define ARCH_ARM 2
#define ARCH_CRIS 3
#define ARCH_IA64 4
#define ARCH_IX86 5
#define ARCH_M68K 6
#define ARCH_MIPS 7
#define ARCH_PARISC 8
#define ARCH_PPC 9
#define ARCH_S390 10
#define ARCH_SH3 11
#define ARCH_SPARC 12
#define ARCH_VAX 13
char *arch_names[]={
"Unknown",
"alpha",
"arm",
"cris",
"ia64",
"ix86",
"m68k",
"mips",
"parisc",
"ppc",
"s390",
"sh3",
"sparc",
"vax"
};

12
tb_asm/c/Makefile Normal file
View File

@ -0,0 +1,12 @@
C_FLAGS=-Wall -O2 -g
all: tb_asm
tb_asm: tb_asm.o
gcc $(L_FLAGS) -o tb_asm tb_asm.o
tb_asm.o: tb_asm.c game_sprites.h
gcc $(C_FLAGS) -c tb_asm.c
clean:
rm -f *~ *.o tb_asm core

34
tb_asm/c/boss.h Normal file
View File

@ -0,0 +1,34 @@
/* XPM */
/* Boss */
/* 3x2 */
char smoke_sprites[3][6]={
{0x0,0x8,0x0,
0x0,0x0,0x0,
},
{0x8,0x7,0x8,
0x8,0x8,0x8,
},
{0x7,0x4,0x7,
0x7,0x7,0x7,
},
};
/* 13x3 */
char boss_sprite[]={
0xf,0x7,0x4,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x4,0x7,0xf,
0xf,0x8,0x7,0x4,0x4,0x3,0xb,0x3,0x4,0x4,0x7,0x8,0xf,
0xf,0x0,0x8,0x7,0x3,0xb,0xe,0xb,0x3,0x7,0x8,0x0,0xf,
};
/* 1x2 */
char laser_sprite[2][2]={
{0xd,
0x5,
},
{0x5,
0xd,
}
};

33
tb_asm/c/dump_to_ansi.c Normal file
View File

@ -0,0 +1,33 @@
#include <stdio.h>
int main(int argc, char **argv) {
int ch,vt102mode=0,inAnsi=0;
while(!feof(stdin)) {
ch=getchar();
if (ch<0) break;
if (ch==27) inAnsi=1;
if ((inAnsi) && (ch=='m')) inAnsi=0;
if ((inAnsi) && (ch=='H')) inAnsi=0;
if (ch==14) {
vt102mode=1;
goto skip_print;
}
if (ch==15) {
vt102mode=0;
goto skip_print;
}
if ((vt102mode)&&(ch=='0')&&(!inAnsi)) putchar('\333');
else putchar(ch);
skip_print:
}
}

34
tb_asm/c/ending.h Normal file
View File

@ -0,0 +1,34 @@
/* Ending */
/* 7x7*/
char tom_head_sprite[]={
0x0,0x1,0x1,0x1,0x9,0x9,0x0,
0x0,0x1,0x0,0x0,0x8,0x9,0x0,
0x0,0x1,0x0,0x0,0x8,0x9,0x0,
0x0,0x1,0x0,0x0,0x8,0x9,0x0,
0x0,0x1,0x0,0x0,0x8,0x9,0x0,
0x0,0x0,0x1,0x1,0x9,0x0,0x0,
0x1,0x1,0x1,0x1,0x9,0x9,0x9,
};
/* 5x6 */
char earth_sprite[]={
0x0,0x7,0xf,0xf,0x0,
0x2,0xA,0xA,0x9,0x9,
0x1,0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0x0,0x9,0x0,
}
,
{0x2,0xa,0x2,
0x2,0xa,0x2,
}
,
{0x3,0x6,0x6,
0x3,0x6,0x6,
}
,
{0x0,0xe,0x0,
0xe,0x0,0xe,
}
,
{0xc,0xf,0xf,
0xc,0x7,0x7
}
,
};
char explosion_sprites[3][6]={
{ 0xe,0xe,0xc,
0xc,0xe,0x8,
},
{ 0x7,0x7,0x4,
0x4,0x7,0x0,
},
{ 0x8,0x8,0x0,
0x0,0x8,0x8,
},
};

41
tb_asm/c/guess.c Normal file
View File

@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char **argv) {
int result,guess,secret,tries;
srand(time(NULL));
new_game:
secret=rand()%65536;
tries=0;
printf("Guess a number between 0 and 65536!\n");
printf(" Or -1 to quit\n");
guess_again:
result=scanf("%d",&guess);
if (result<1) {
scanf("%*s");
goto guess_again;
}
if (guess==-1) goto end;
tries++;
if (guess<secret) {
printf("%i is too low! Try again!\n",guess);
goto guess_again;
}
if (guess>secret) {
printf("%i is too high! Try again!\n",guess);
goto guess_again;
}
if (guess==secret) {
printf("Correct! It took you %i tries!\n",tries);
goto new_game;
}
end:
printf("Thanks for playing!\n\n");
return 0;
}

56
tb_asm/c/int_random.c Normal file
View File

@ -0,0 +1,56 @@
#include <stdio.h>
#include <time.h>
/* default beep is 750Hz/125ms */
/* The following algorithm from the Hewlett Packard HP-20S */
/* Scientific Calculator manual, September 1998, p75-76 */
/* The algorithm r = FractionalPart (997r ) */
/* i+1 i */
/* */
/* Where r0 is a starting value between 0 and 1. */
/* The generator passes the chi-square frequency test for */
/* uniformity, and serial and run tests for randomness. */
/* The more significant digits are more random than the */
/* less significant. If r0 * 10e7 is not divisible */
/* by 2 or 5 you get 500,000 numbers w/o repeating. */
/* modified to be fixed-point integer only by Vince Weaver */
int int_random(int seed) {
static int ri;
/* Be sure doesn't end in multiple of 2, 5 and is ~<=7 digits */
if (seed!=0) {
ri=seed;
while ((ri%2==0) || (ri%5==0)) ri++;
ri=ri&0xffffff;
return ri;
}
ri*=997;
ri&=0xffffff;
return ri;
}
int random_word() {
int i;
i=(int_random(0)>>8)&0xffff;
return i;
}
int main(int argc,char **argv) {
int i;
int_random(time(NULL));
for(i=0;i<1000;i++) printf("%i\n",random_word()%1000);
return 0;
}

12
tb_asm/c/open_test.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main(int argc, char **argv) {
FILE *fff;
fff=fopen("bob","w");
if (fff!=NULL) {
fprintf(fff,"HELLO\n");
fclose(fff);
}
return 0;
}

28
tb_asm/c/opener.h Normal file
View File

@ -0,0 +1,28 @@
/* opener.h */
/* 40x20 */
/* 0,5 Merciless Marauding Malicious Marketers */
char opener_sprite[]=
{
0x9,0x9,0x9,0x0,0x9,0x9,0x9,0x0,0x9,0x0,0x0,0x0,0x9,0x0,0xC,0xC,0x0,0x0,0xC,0xC,0xC,0x0,0xC,0x0,0x0,0x0,0xC,0x0,0xC,0xC,0x0,0x0,0xC,0xC,0x0,0xC,0x0,0x0,0x0,0xC,
0x0,0x9,0x0,0x0,0x9,0x0,0x9,0x0,0x9,0x9,0x0,0x9,0x9,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0xC,0x0,0xC,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0x0,0xC,0xC,0x0,0xC,0xC,
0x0,0x9,0x0,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0xC,0xC,0x0,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0xC,0x0,0x0,0xC,0xC,0x0,0xC,0x0,0xC,0x0,0xC,
0x0,0x9,0x0,0x0,0x9,0x0,0x9,0x0,0x9,0x0,0x0,0x0,0x9,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0x0,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0xC,0x0,0x0,0xC,0x0,0x0,0x0,0xC,
0x0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,0x0,0x0,0x0,0xF,0x0,0x0,0x0,0x0,0x4,0x4,
0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0xF,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xF,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,
};

71
tb_asm/c/organ.c Normal file
View File

@ -0,0 +1,71 @@
#include <stdio.h>
#include <math.h> /* pow */
#include <fcntl.h> /* fcntl */
#include <termios.h>
int main(int argc, char **argv) {
int frequency[127],i,ch,note=60;
static struct termios new_tty,old_tty;
/* setup non-blocking non-echo mode */
tcgetattr(0,&old_tty);
new_tty=old_tty;
new_tty.c_lflag&=~ICANON;
new_tty.c_cc[VMIN]=1;
new_tty.c_lflag&=~ECHO;
tcsetattr(0,TCSANOW,&new_tty);
fcntl(0,F_SETFL,fcntl(0,F_GETFL) | O_NONBLOCK);
for (i=0;i<127;i++) frequency[i]=(440.0/32.0)*(pow(2.0,(i-9.0)/12.0));
for(i=0;i<127;i++) printf("%i\n",frequency[i]);
while ((ch=getchar())!='q') {
if (ch==-1) goto loop;
switch(ch)
{
case 'a': note=60; break;
case 'w': note=61; break;
case 's': note=62; break;
case 'e': note=63; break;
case 'd': note=64; break;
case 'f': note=65; break;
case 't': note=66; break;
case 'g': note=67; break;
case 'y': note=68; break;
case 'h': note=69; break;
case 'u': note=70; break;
case 'j': note=71; break;
case 'k': note=72; break;
}
printf("%c[10;%i]\n",27,frequency[note]);
// write(1, "\33[11;200]", 9) length = 200
printf("%c",ch);
printf("\a");
usleep(150000);
loop:
}
tcsetattr(0,TCSANOW,&old_tty);
}

26
tb_asm/c/phobos.h Normal file
View File

@ -0,0 +1,26 @@
/* 40x16 */
char phobos_sprite[]={
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x7,0xf,0xf,0xf,0xf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0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0,0x4,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x0,0x0,0x0,
0x0,0x0,0x0,0x4,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x0,0x0,0x0,
};

274
tb_asm/compress_data.c Normal file
View File

@ -0,0 +1,274 @@
/* The following code is UGLY. Read at your own risk. --vmw */
#include <stdio.h>
#include <string.h> /* strncpy() */
#include <ctype.h> /* isdigit() */
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
#include "lzss.h"
int write_ascii(char *string,int output_fd) {
int pointer=0,count=0,octal=0;
unsigned char byte;
while(string[pointer]!='\"') pointer++;
pointer++;
while(string[pointer]!='\"') {
if (string[pointer]=='\\') {
pointer++;
if (isdigit(string[pointer])) {
octal=0;
while(isdigit(string[pointer])) {
octal=8*octal+(string[pointer]-'0');
pointer++;
}
if (octal>255) {
fprintf(stderr,"BYTE OUT OF RANGE\n");
}
else {
byte=octal;
}
pointer--;
}
else {
switch(string[pointer]) {
case 'n': byte='\n'; break;
case 't': byte='\t'; break;
case '\\': byte='\\'; break;
case '\"': byte='\"'; break;
}
}
}
else byte=string[pointer];
write(output_fd,&byte,1);
pointer++;
count++;
}
return count;
}
int get_number(char *string, int *pointer) {
int temp_number;
if (string[*pointer]=='0') {
/* Hexadecimal */
if (string[*pointer+1]=='x') {
(*pointer)++;
(*pointer)++;
temp_number=0;
while(isxdigit(string[*pointer])) {
if ((string[*pointer]>='a') && (string[*pointer]<='f'))
temp_number=16*temp_number+(10+(string[*pointer]-'a'));
if ((string[*pointer]>='A') && (string[*pointer]<='F'))
temp_number=16*temp_number+(10+(string[*pointer]-'A'));
if ((string[*pointer]>='0') && (string[*pointer]<='9'))
temp_number=16*temp_number+(string[*pointer]-'0');
(*pointer)++;
}
}
else {
/* Octal */
temp_number=0;
while(isdigit(string[*pointer])) {
temp_number=8*temp_number+(string[*pointer]-'0');
(*pointer)++;
}
}
}
else {
/* Decimal */
temp_number=0;
while(isdigit(string[*pointer])) {
temp_number=10*temp_number+(string[*pointer]-'0');
(*pointer)++;
}
}
return temp_number;
}
int write_bytes(char *string, int output_fd) {
int pointer=0,count=0,number=0;
unsigned char temp_byte;
while(1) {
while(!isdigit(string[pointer])) {
if (string[pointer]=='\n') goto done_byte;
pointer++;
}
number=get_number(string,&pointer);
if (number>255) {
fprintf(stderr,"Byte too big!\n");
}
else {
temp_byte=number;
write(output_fd,&temp_byte,1);
count++;
}
}
done_byte:
return count;
}
int write_32bits(char *string, int output_fd) {
int pointer=0,count=0,number=0;
// unsigned char temp_int[4];
while(1) {
while(!isdigit(string[pointer])) {
if (string[pointer]=='\n') goto done_32;
pointer++;
}
number=get_number(string,&pointer);
write(output_fd,&number,4);
count+=4;
}
done_32:
return count;
}
int main(int argc, char **argv) {
FILE *input,*header,*labels,*output;
int output_fd,byte_count;
char input_filename[]="data.inc";
char output_raw_filename[]="data.raw";
char output_lzss_filename[]="data.lzss";
char output_header_filename[]="data.header";
char output_labels_filename[]="data.labels";
int offset=0,pointer,temp_pointer;
char input_line[BUFSIZ];
char temp_label_string[BUFSIZ];
input=fopen(input_filename,"r");
if (input==NULL) goto file_error;
output_fd=open(output_raw_filename,O_WRONLY|O_CREAT|O_TRUNC,0666);
if (output_fd<0) goto file_error;
labels=fopen(output_labels_filename,"w");
if (labels==NULL) goto file_error;
while(1) {
if ( fgets(input_line,BUFSIZ,input) ==NULL) goto close_file;
pointer=0;
while(pointer<strlen(input_line)) {
/* Comment, we are done */
if (input_line[pointer]=='#') goto done_with_string;
/* end of line, we are done */
if (input_line[pointer]=='\n') goto done_with_string;
/* directive */
if (input_line[pointer]=='.') {
if (!strncmp("byte",input_line+pointer+1,4)) {
offset+=write_bytes(input_line+pointer+1,output_fd);
goto done_with_string;
}
else if (!strncmp("ascii",input_line+pointer+1,5)) {
offset+=write_ascii(input_line+pointer+1,output_fd);
goto done_with_string;
}
else if (!strncmp("long",input_line+pointer+1,4)) {
offset+=write_32bits(input_line+pointer+1,output_fd);
goto done_with_string;
}
else if (!strncmp("int",input_line+pointer+1,3)) {
offset+=write_32bits(input_line+pointer+1,output_fd);
offset++;
goto done_with_string;
}
else {
printf("Unknown directive!\n");
goto close_file;
}
}
/* end of label */
if (input_line[pointer]==':') {
temp_pointer=pointer;
while( (temp_pointer>0) &&
(input_line[temp_pointer]!='\t') &&
(input_line[temp_pointer]!=' ')) temp_pointer--;
memcpy(temp_label_string,input_line+temp_pointer,
pointer-temp_pointer);
temp_label_string[pointer-temp_pointer]='\0';
fprintf(labels,".equ %s,%i+DATA_OFFSET\n",temp_label_string,offset);
}
pointer++;
}
done_with_string: ;
}
close_file:
fclose(labels);
close(output_fd);
fclose(input);
printf("Original size of data segment = %i bytes\n",offset);
input=fopen(output_raw_filename,"r");
if (input==NULL) goto file_error;
output=fopen(output_lzss_filename,"w");
if (output==NULL) goto file_error;
header=fopen(output_header_filename,"w");
if (header==NULL) goto file_error;
byte_count=lzss_encode_better(input,header,output,'\0',1024,2);
printf("Compressed data segment = %i bytes\n",byte_count);
fprintf(header,".equ TB_DATA_SIZE,%i\n",offset);
fclose(header);
fclose(input);
fclose(output);
file_error:
return 0;
}

71
tb_asm/configure.c Normal file
View File

@ -0,0 +1,71 @@
#include <stdio.h>
#include <string.h> /* strncpy */
#include <sys/utsname.h> /* uname */
#include <stdlib.h> /* system */
#include "arch.h"
int linux_detect_arch(void) {
/* Yes this is a bit messy, but it cleans up the makefile a bit *\
\* The C-Preproccessor can be out friend ;) */
/* return ARCH_SPARC; */
#if defined(__alpha__)
return ARCH_ALPHA;
#elif defined(__arm__)
return ARCH_ARM;
#elif defined(__cris__)
return ARCH_CRIS;
#elif defined(__ia64__)
return ARCH_IA64;
#elif defined(i386)
return ARCH_IX86;
#elif (defined(mc68000) || #cpu(m68k))
return ARCH_M68K;
#elif defined(__mips__)
return ARCH_MIPS;
#elif defined(__parisc__)
return ARCH_PARISC;
#elif defined(__PPC__)
return ARCH_PPC;
#elif defined(__s390__)
return ARCH_S390;
#elif defined(__sh3__) || defined(__sh2__) || defined(__sh4)
return ARCH_SH3
#elif defined(__sparc__)
return ARCH_SPARC;
#elif defined(__vax__)
return ARCH_VAX;
#else
return ARCH_UNKNOWN;
#endif
}
int main(int argc, char **argv) {
struct utsname buf;
char temp_string[256],arch[65];
int command_override=0;
if (argc>1) {
command_override=1;
}
uname(&buf);
sprintf(temp_string,"rm -f tb_asm.s");
system(temp_string);
strncpy(arch,arch_names[linux_detect_arch()],63);
printf("+ compiling for %s architecture\n",arch);
sprintf(temp_string,"ln -n -s tb_asm.%s.s tb_asm.s",arch);
system(temp_string);
return 0;
}

488
tb_asm/data.inc Normal file
View File

@ -0,0 +1,488 @@
clear_screen: .ascii "\033[2J\n\0"
default_colors: .ascii "\017\033[0m\n\0"
score_file: .ascii "/tmp/tb_asm.hsc\0"
menu_arrow: .ascii " --> \0"
menu_blank: .ascii " \0"
menu_pointer: .ascii "^\0"
title_string: .byte 14,5,0
.ascii "Merciless Marauding Malicious Marketers\0"
vmw_string: .byte 15,15,7
.ascii "A VMW Software Production\0"
menu_new_string: .ascii "New Game\0"
menu_about_string: .ascii "About\0\0\0\0"
menu_story_string: .ascii "Story\0\0\0\0"
menu_hi_string: .ascii "Hi Score\0"
menu_quit_string: .ascii "Quit\0\0\0\0\0"
menu_no_string: .ascii "NO! \0\0\0"
menu_yes_string: .ascii "YES! \0\0\0"
menu_help_string: .byte 7,20,0
.ascii "F1 or 'h' for HELP\0"
bonus_points_line: .byte 15,5,14
.ascii "BONUS POINTS\0"
no_bonus_line: .byte 14,7,5
.ascii "NO BONUSES THIS LEVEL\0"
no_shield_line: .byte 14,7,5
.ascii "NO SHIELD HITS = +1000\0"
shot_every_line: .byte 14,8,5
.ascii "DESTROYED EVERY ENEMY = +5000\0"
perfect_shot_line: .byte 14,9,5
.ascii "PERFECT SHOT = +5000\0"
about_line_0: .byte 13,0,7
.ascii "TOM BOMBEM\0"
.byte 14,1,11
.ascii "by\0"
.byte 9,2,6
.ascii "Vince Weaver\0"
.byte 12,3,0
.ascii "author if you squint ->\0"
.byte 11,5,0
.ascii "* Testing my asm skills\0"
.byte 10,7,0
.ascii "* Based on Tom Bombem:\0"
.byte 10,8,2
.ascii "Invasion of Inanimate\0"
.byte 10,9,2
.ascii "Objects, a game I\0"
.byte 10,10,2
.ascii "started 10 years ago\0"
.byte 10,11,2
.ascii "in Pascal/asm and is\0"
.byte 10,12,2
.ascii "still languishing\0"
.byte 10,13,2
.ascii "uncompleted in C/SDL.\0"
.byte 5,17,0
.ascii "Contact Vince:\0"
.byte 9,18,0
.ascii "vince@deater.net\0"
.byte 9,19,0
.ascii "http://www.deater.net/weave/\0"
story_line_0: .byte 15,17,0
.ascii "It is the year 2025. All telemarketers\0"
.byte 15,18,0
.ascii "and unsolicited bulk e-mailers have\0"
.byte 15,19,0
.ascii "been exiled to Phobos.\0"
story_line_1: .byte 10,17,0
.ascii "Right before being trapped forever they\0"
.byte 10,18,0
.ascii "manage to launch one last marketing\0"
.byte 10,19,0
.ascii "droid. \0"
# note spaces needed to overwrite old text?
story_line_2:
.byte 9,0,0
.ascii "You are Tom Bombem.\0"
.byte 9,2,0
.ascii "You drew the short straw.\0"
.byte 9,4,0
.ascii "So it is up to you to\0"
.byte 9,5,2
.ascii "fight through the ads\0"
.byte 9,6,2
.ascii "and destroy the evil\0"
.byte 9,7,2
.ascii "marketing robot, thus\0"
.byte 9,8,2
.ascii "restoring harmony to\0"
.byte 9,9,2
.ascii "the space lanes.\0"
.byte 11,12,7
.ascii "GOOD LUCK!\0"
ending_line:
.byte 15,0,0
.ascii "INCOMING MESSAGE FROM\0"
.byte 15,1,5
.ascii "** EARTH **\0"
.byte 14,3,0
.ascii "Congratulations Tom!\0"
.byte 14,4,0
.ascii "You've destroyed the\0"
.byte 14,5,2
.ascii "Marketing Menace!!\0"
.byte 14,7,0
.ascii "But wait...\0"
.byte 14,8,0
.ascii "Our sensors detect another batch of\0"
.byte 14,9,2
.ascii "enemies, moving even faster!\0"
.byte 14,11,0
.ascii "Feel free to quit at any time, but\0"
.byte 14,12,2
.ascii "remember no paycheck bonus unless\0"
.byte 14,13,2
.ascii "all are destroyed.\0"
.byte 14,15,0
.ascii "PS Your pet guinea\0"
.byte 14,16,3
.ascii "pig is doing\0"
.byte 14,17,3
.ascii "well.\0"
.byte 14,17,16
.ascii "-->\0"
.byte 15,22,0
.ascii "** END TRANSMISSION **\0"
ending_line_2:
.byte 9,0,10
.ascii "Tom: *Sigh*\0"
.byte 15,10,0
.ascii "Press Any Key to Resume Fighting\0"
help_line_0: .byte 15,0,10
.ascii "TOM BOMBEM\0"
.byte 7,1,14
.ascii "by\0"
.byte 15,2,9
.ascii "Vince Weaver\0"
.byte 15,4,0
.ascii "Key Bindings:\0"
.byte 7,6,2
.ascii "UP or 'i' : Move menu up\0"
.byte 7,7,2
.ascii "DOWN or 'm' : Move menu down\0"
.byte 7,8,2
.ascii "ENTER\0"
.byte 7,8,15
.ascii ": Selects current option\0"
.byte 7,10,2
.ascii "RIGHT or 'k' : Move ship right\0"
.byte 7,11,2
.ascii "LEFT of 'j' : Move ship left\0"
.byte 7,12,2
.ascii "SPACEBAR\0"
.byte 7,12,15
.ascii ": Shoots\0"
.byte 7,14,2
.ascii "F1 or 'h' : Displays help\0"
.byte 7,15,2
.ascii "ESC or 'q' : Quits\0"
.byte 7,16,2
.ascii "'p'\0"
.byte 7,16,15
.ascii ": Pauses\0"
.byte 7,17,2
.ascii "'s'\0"
.byte 7,17,15
.ascii ": Toggles sound\0"
game_over_line: .byte 12,8,14
.ascii " GAME OVER! \0"
game_paused_line: .byte 12,8,13
.ascii " GAME PAUSED! \0"
quit_line: .byte 12,7,9
.ascii " QUIT? Are you sure? \0"
block: .byte 219,0
underscore: .ascii "_\0"
shields_line: .byte 0,21,0
.ascii "SHIELDS:\0"
score_line: .byte 15,22,0
.ascii "SCORE:\0"
hiscore_line: .byte 15,22,20
.ascii "HISCORE:\0"
level_line: .byte 15,23,0
.ascii "LEVEL:\0"
high_score_line: .byte 14,7,15
.ascii "HIGH SCORE\0"
new_high_line: .byte 13,5,13
.ascii "NEW HIGH SCORE\0"
.byte 14,7,2
.ascii "Use the arrows to pick your initials\0"
.byte 14,8,5
.ascii "Press ENTER when you are done\0"
hiscore: .long 500
hi_player: .ascii "KRG\0"
game_flags: .byte 2 # bit 0 = Previously Paused
# bit 1 = Sound On/Off
# bit 2 = Shield/Score change?
# timespec for nanosleep
milisecond: .long 0
.long 1000000
hundred_microsecond: .long 0
.long 100000
#
# vmw_soft.h
# vmw @ 8,6
# A VMW Software Production" @ 7,15
vmw_sprite:
.byte 23,8
.byte 0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x1
.byte 0x4,0x4,0x4,0x4,0x4,0x4,0x4,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x2,0x1,0x1,0x1,0x1,0x1,0x1,0x1
.byte 0x0,0x4,0x4,0x4,0x4,0x4,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x0
.byte 0x0,0x4,0x4,0x4,0x4,0x4,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x1,0x1,0x1,0x1,0x1,0x0
.byte 0x0,0x0,0x4,0x4,0x4,0x2,0x2,0x2,0x2,0x2,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2,0x1,0x1,0x1,0x0,0x0
.byte 0x0,0x0,0x4,0x4,0x4,0x2,0x2,0x2,0x2,0x2,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2,0x1,0x1,0x1,0x0,0x0
.byte 0x0,0x0,0x0,0x4,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x1,0x0,0x0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x9
.byte 0x3,0x3,0xb,0xb,0x1,0x1,0x9,0x9,0x1,0x1,0x9,0x9,0x3,0x3,0xb,0xb
.byte 0x0,0x0,0x0,0x0,0x1,0x1,0x9,0x9,0x1,0x1,0x9,0x9,0x0,0x0,0x0,0x0
.byte 0x0,0x0,0x0,0x0,0x1,0x1,0x9,0x9,0x1,0x1,0x9,0x9,0x0,0x0,0x0,0x0
.byte 0x0,0x0,0x0,0x0,0x1,0x1,0x9,0x9,0x1,0x1,0x9,0x9,0x0,0x0,0x0,0x0
.byte 0x0,0x0,0x0,0x0,0x3,0x3,0xb,0xb,0x3,0x3,0xb,0xb,0x0,0x0,0x0,0x0
.byte 0x0,0x0,0x0,0x0,0x8,0x8,0x7,0x7,0x8,0x8,0x7,0x7,0x0,0x0,0x0,0x0
# game_sprites.h
# 8x4
ship_sprite:
.byte 0x8,0x4
.byte 0x0,0x0,0x9,0x9,0x9,0x0,0x0,0x0
.byte 0x0,0x7,0xf,0xf,0xf,0x7,0x0,0x0
.byte 0x7,0x7,0xf,0x7,0xf,0x7,0x7,0x0
.byte 0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0
# 1x3
missile_sprite:
.byte 0x1,0x3
.byte 0x7
.byte 0x7
.byte 0xe
# 3x2
enemy_sprites:
enemy_sprite0:
.byte 0x3,0x2
.byte 0xf,0xf,0x4
.byte 0xf,0xf,0xf
enemy_sprite1:
.byte 0x3,0x2
.byte 0x9,0x0,0x9
.byte 0x0,0x9,0x0
enemy_sprite2:
.byte 0x3,0x2
.byte 0x2,0xa,0x2
.byte 0x2,0xa,0x2
enemy_sprite3:
.byte 0x3,0x2
.byte 0x3,0x6,0x6
.byte 0x3,0x6,0x6
enemy_sprite4:
.byte 0x3,0x2
.byte 0x0,0xe,0x0
.byte 0xe,0x0,0xe
enemy_sprite5:
.byte 0x3,0x2
.byte 0xc,0xf,0xf
.byte 0xc,0x7,0x7
explosion_sprites:
explosion_sprite0:
.byte 0x3,0x2
.byte 0xe,0xe,0xc
.byte 0xc,0xe,0x8
explosion_sprite1:
.byte 0x3,0x2
.byte 0x7,0x7,0x4
.byte 0x4,0x7,0x0
explosion_sprite2:
.byte 0x3,0x2
.byte 0x8,0x8,0x0
.byte 0x0,0x8,0x8
# boss.h
# 3x2
smoke_sprites:
smoke_sprite0:
.byte 0x3,0x1
.byte 0x0,0x8,0x0
smoke_sprite1:
.byte 0x3,0x1
.byte 0x8,0x7,0x8
smoke_sprite2:
.byte 0x3,0x1
.byte 0x7,0x4,0x7
# 13x3
boss_sprite:
.byte 0xd,0x3
.byte 0xf,0x7,0x4,0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x4,0x7,0xf
.byte 0xf,0x8,0x7,0x4,0x4,0x3,0xb,0x3,0x4,0x4,0x7,0x8,0xf
.byte 0xf,0x0,0x8,0x7,0x3,0xb,0xe,0xb,0x3,0x7,0x8,0x0,0xf
# 1x2
laser_sprites:
laser_sprite0:
.byte 0x1,0x2
.byte 0xd
.byte 0x5
laser_sprite1:
.byte 0x1,0x2
.byte 0x5
.byte 0xd
# ending.h
# 7x7
tom_head_sprite:
.byte 0x7,0x7
.byte 0x0,0x1,0x1,0x1,0x9,0x9,0x0
.byte 0x0,0x1,0x0,0x0,0x8,0x9,0x0
.byte 0x0,0x1,0x0,0x0,0x8,0x9,0x0
.byte 0x0,0x1,0x0,0x0,0x8,0x9,0x0
.byte 0x0,0x1,0x0,0x0,0x8,0x9,0x0
.byte 0x0,0x0,0x1,0x1,0x9,0x0,0x0
.byte 0x1,0x1,0x1,0x1,0x9,0x9,0x9
# 5x6
earth_sprite:
.byte 0x5,0x6
.byte 0x0,0x7,0xf,0xf,0x0
.byte 0x2,0xA,0xA,0x9,0x9
.byte 0x1,0xA,0x9,0x9,0x9
.byte 0x1,0x9,0xA,0xA,0x9
.byte 0x1,0x9,0xA,0x9,0x9
.byte 0x0,0x7,0xf,0xf,0x0
# 19x7
susie_sprite:
.byte 0x13,0x7
.byte 0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x7,0x8,0x0,0xf,0xf,0x0,0x7,0x7,0x7
.byte 0x7,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0x0,0x0,0x8,0x0,0x0,0x7,0x7
.byte 0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7
.byte 0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7
.byte 0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x7,0x7
.byte 0x7,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x7,0x7,0x7,0x7
.byte 0x7,0x7,0x7,0x7,0x8,0x8,0x8,0x7,0x7,0x7,0x7,0x7,0x8,0x8,0x8,0x7,0x7,0x7,0x7

320
tb_asm/lzss.c Normal file
View File

@ -0,0 +1,320 @@
/**************************************************************
LZSS.C -- A Data Compression Program
(tab = 4 spaces)
***************************************************************
4/6/1989 Haruhiko Okumura
Use, distribute, and modify this program freely.
Please send me your improved versions.
PC-VAN SCIENCE
NIFTY-Serve PAF01022
CompuServe 74050,1022
**************************************************************
WARNING: order of match_position and match_lenght changed!
see lines 178 to 182
Mofication by <stephan.walter@gmx.ch>
Also modified to have N,F,etc, etc to be parameters, not
hard-coded -- vmw
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define num_trees 256
/* initialize trees */
void newInitTree(int ring_buffer_size,int binary_search_index,
int *rson, int *dad) {
int i;
/* For i = 0 to N - 1, rson[i] and lson[i] will be the right and
left children of node i. These nodes need not be initialized.
Also, dad[i] is the parent of node i. These are initialized to
NIL (= N), which stands for 'not used.'
For i = 0 to 255, rson[N + i + 1] is the root of the tree
for strings that begin with character i. These are initialized
to NIL. Note there are 256 trees. */
for (i=ring_buffer_size+1; i<=ring_buffer_size+num_trees; i++)
rson[i] = binary_search_index;
for (i=0; i<ring_buffer_size; i++) dad[i] = binary_search_index;
}
void newInsertNode(int r, int ring_buffer_size, int binary_search_index,
int match_length_limit,
unsigned char *text_buf, int *rson,int *lson, int *dad,
int *match_length, int *match_position) {
/* Inserts string of length F, text_buf[r..r+F-1], into one of the
trees (text_buf[r]'th tree) and returns the longest-match position
and length via the global variables match_position and match_length.
If match_length = F, then removes the old node in favor of the new
one, because the old one will be deleted sooner.
Note r plays double role, as tree node and position in buffer. */
int i, p, cmp;
unsigned char *key;
cmp = 1;
key = text_buf+r;
p = ring_buffer_size + 1 + key[0];
rson[r] = lson[r] = binary_search_index;
*match_length = 0;
for( ; ; ) {
if (cmp >= 0) {
if (rson[p] != binary_search_index) p = rson[p];
else {
rson[p] = r;
dad[r] = p;
return;
}
}
else {
if (lson[p] != binary_search_index) p = lson[p];
else {
lson[p] = r;
dad[r] = p;
return;
}
}
for(i = 1; i < match_length_limit; i++)
if ((cmp = key[i] - text_buf[p + i]) != 0) break;
if (i > *match_length) {
*match_position = p;
if ((*match_length = i) >= match_length_limit) break;
}
}
dad[r] = dad[p];
lson[r] = lson[p];
rson[r] = rson[p];
dad[lson[p]] = r;
dad[rson[p]] = r;
if (rson[dad[p]] == p) rson[dad[p]] = r;
else lson[dad[p]] = r;
dad[p] = binary_search_index; /* remove p */
}
/* deletes node p from tree */
void newDeleteNode(int p, int binary_search_index,
int *dad, int *rson, int *lson) {
int q;
if (dad[p] == binary_search_index) return; /* not in tree */
if (rson[p] == binary_search_index) q = lson[p];
else if (lson[p] == binary_search_index) q = rson[p];
else {
q = lson[p];
if (rson[q] != binary_search_index) {
do { q = rson[q]; } while (rson[q] != binary_search_index);
rson[dad[q]] = lson[q];
dad[lson[q]] = dad[q];
lson[q] = lson[p];
dad[lson[p]] = q;
}
rson[q] = rson[p]; dad[rson[p]] = q;
}
dad[q] = dad[p];
if (rson[dad[p]] == p) rson[dad[p]] = q;
else lson[dad[p]] = q;
dad[p] = binary_search_index;
}
int lzss_encode_better(FILE *infile,FILE *header,FILE *outfile,
unsigned char frequent_char,
int ring_buffer_size, int position_length_threshold) {
// unsigned char frequent_char='#';
// int ring_buffer_size=1024; /* N */
int match_length_limit; //=64; /* F */
/*int position_length_threshold=2; THRESHOLD */
int binary_search_index=ring_buffer_size; /* NIL */
int position_bits; //=10;
// int length_bits=16-position_bits;
unsigned long int codesize = 0; /* code size counter */
int i, c, len, r, s, last_match_length, code_buf_ptr;
unsigned char code_buf[8*2+1], mask;
unsigned char *text_buf;
int match_position, match_length; /* of longest match. These are
set by the InsertNode() procedure. */
int *lson, *rson, *dad; /* left & right children &
parents -- These constitute
binary search trees. */
/* determine stuff from ring_buffer_size */
/* fake log2 algorithm */
i=1;
while (((ring_buffer_size-1)>>i) >=1) {
i++;
};
position_bits=i;
match_length_limit=1<<(16-position_bits);
// printf("%i, %i %i %i '%c'\n",ring_buffer_size,position_bits,match_length_limit
// ,position_length_threshold,frequent_char);
/* ring buffer of size N, with extra F-1
bytes to facilitate string comparison */
text_buf=calloc(ring_buffer_size+match_length_limit-1,sizeof(unsigned char));
lson=calloc(ring_buffer_size+1,sizeof(int));
rson=calloc(ring_buffer_size+num_trees+1,sizeof(int));
dad=calloc(ring_buffer_size+1,sizeof(int));
newInitTree(ring_buffer_size,binary_search_index,rson,dad); /* initialize trees */
code_buf[0] = 0; /* code_buf[1..16] saves eight units of code, and
code_buf[0] works as eight flags, "1" representing
that the unit is an unencoded letter (1 byte),
"0" a position-and-length pair (2 bytes).
Thus, eight units require at most 16 bytes of code. */
code_buf_ptr = mask = 1;
s = 0;
r = ring_buffer_size - match_length_limit;
if (header!=NULL) {
fprintf(header,".equ FREQUENT_CHAR,'%c'\n",frequent_char);
fprintf(header,".equ N,%i\n",ring_buffer_size);
fprintf(header,".equ F,%i\n",match_length_limit);
fprintf(header,".equ THRESHOLD,%i\n",position_length_threshold);
fprintf(header,".equ P_BITS,%i\n",position_bits);
fprintf(header,".equ POSITION_MASK,%i\n",(0xff>>(8-(position_bits-8))));
}
if (outfile!=NULL) {
fprintf(outfile,"tb_data_begin:\n");
}
/* Clear the buffer with any character that will appear often. */
for(i=0; i<(ring_buffer_size-match_length_limit); i++)
text_buf[i]=frequent_char;
// printf("%i to %i = %i\n",0,ring_buffer_size-match_length_limit,frequent_char);
// printf("%i to %i = ",r,r+match_length_limit);
for(len=0; len<match_length_limit && (c=getc(infile))!=EOF; len++) {
text_buf[r+len]=c; /* Read F bytes into the last F bytes of
the buffer */
// printf("%i ",text_buf[r+len]);
}
// printf("\n");
if (len== 0) return 0; /* trying to compress empty file */
for(i = 1; i <= match_length_limit; i++)
newInsertNode(r-i,ring_buffer_size,binary_search_index,
match_length_limit,text_buf,rson,lson,dad,
&match_length,&match_position);
/* Insert the F strings,
each of which begins with one or more 'space' characters. Note
the order in which these strings are inserted. This way,
degenerate trees will be less likely to occur. */
newInsertNode(r,ring_buffer_size,binary_search_index,
match_length_limit,text_buf,rson,lson,dad,
&match_length,&match_position);
/* Finally, insert the whole string just read. The
global variables match_length and match_position are set. */
do {
if (match_length > len) match_length = len; /* match_length
may be spuriously long near the end of text. */
if (match_length <= position_length_threshold) {
match_length=1; /* Not long enough match. Send one byte. */
code_buf[0] |= mask; /* 'send one byte' flag */
code_buf[code_buf_ptr++] = text_buf[r]; /* Send uncoded. */
// printf("single: %i @ %i\n",text_buf[r],r);
} else {
// printf("pos : %i\tlen : %i\n",match_position,match_length);
code_buf[code_buf_ptr++] = (unsigned char) match_position;
code_buf[code_buf_ptr++] = (unsigned char)
( ((match_position>>8) & (0xff >> (8-(position_bits-8)))) |
((match_length-(position_length_threshold+1))<<(position_bits-8)) );
// code_buf[code_buf_ptr++] = (unsigned char)
// (((match_position >> 8) & 7) |
// (match_length - (position_length_threshold+1))<<3);
}
if ((mask <<= 1) == 0) { /* Shift mask left one bit. */
if (outfile!=NULL) {
fprintf(outfile,"\t.byte\t");
for(i = 0; i < code_buf_ptr; i++) { /* Send at most 8 units of */
fprintf(outfile,"%d%c",code_buf[i],(i==code_buf_ptr-1)?'\n':',');
}
}
codesize += code_buf_ptr;
code_buf[0] = 0; code_buf_ptr = mask = 1;
}
last_match_length = match_length;
for (i = 0; i < last_match_length && (c = getc(infile)) != EOF; i++) {
newDeleteNode(s,binary_search_index,
dad,rson,lson); /* Delete old strings and */
text_buf[s] = c; /* read new bytes */
if (s < match_length_limit - 1) text_buf[s + ring_buffer_size] = c; /* If the position is
near the end of buffer, extend the buffer to make
string comparison easier. */
s = (s + 1) & (ring_buffer_size - 1);
r = (r + 1) & (ring_buffer_size - 1);
/* Since this is a ring buffer, increment the position
modulo N. */
newInsertNode(r,ring_buffer_size,binary_search_index,
match_length_limit,text_buf,rson,lson,dad,
&match_length,&match_position);
/* Register the string in text_buf[r..r+F-1] */
}
while (i++ < last_match_length) { /* After the end of text, */
newDeleteNode(s,binary_search_index,
dad,rson,lson); /* no need to read, but */
s = (s + 1) & (ring_buffer_size - 1);
r = (r + 1) & (ring_buffer_size - 1);
if (--len) newInsertNode(r,ring_buffer_size,binary_search_index,
match_length_limit,text_buf,rson,lson,dad,
&match_length,&match_position);
/* buffer may not be empty. */
}
} while (len > 0); /* until length of string to be processed is zero */
if (code_buf_ptr > 1) { /* Send remaining code. */
if (outfile!=NULL) {
fprintf(outfile,"\t.byte\t");
for(i = 0; i < code_buf_ptr; i++) {
fprintf(outfile,"%d%c",code_buf[i],(i==code_buf_ptr-1)?'\n':',');
}
}
codesize += code_buf_ptr;
}
if (outfile!=NULL) fprintf(outfile,"tb_data_end:\n");
free(text_buf);
free(lson);
free(rson);
free(dad);
return codesize;
}

4
tb_asm/lzss.h Normal file
View File

@ -0,0 +1,4 @@
int lzss_encode(FILE *infile,FILE *outfile);
int lzss_encode_better(FILE *infile,FILE *header,FILE *outfile,
unsigned char frequent_char,
int ring_buffer_size, int position_length_threshold);

57
tb_asm/optimization Normal file
View File

@ -0,0 +1,57 @@
Chart of size optimization
Using gas 2.11.93.0.2
goal = 8192 bytes
Version Size (bytes) Notes
~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~
0.26 25422 First working version
0.26 13260 Stripped
0.27 13172 Removing extraneous spaces from strings
0.27 11076 Compressed Data Segment
0.28 8940 Removed ".data" line to force data+text in same segment
0.28 8668 Using sstrip "super-strip"
0.29 8656 move get_char to return status in carry flag
1 byte immediate moves -> push/pop
0.29 8620 make "blit_219"
0.29 8592 Optimizing "do_story" routine to remove %bp use
0.29 8556 Optimize "do_menu" to use lea
0.29 8544 convert verify_quit to use zero flag result
0.29 8528 convert check_inside to use carry flag for status
0.29 8452 move sound_freq to one 32bit value rather than 16 f/d pair
0.29 8448 optimize high score routines
0.29 8440 change cmp $0/jl to just js
0.30 8312 messing with new_game
0.30 8283 more removal of bx->bp in new_game
0.30 8231 cheat, have functions called at end of other functions instead have them follow and thus shave the end saving a call
0.30 8228 remove extraneous phobos_sprite line
0.30 8193 Messing with jmping midway into functions for code re-use
0.30 8187 merging the ioctl commands ;)
0.31 8151 fixing the game to work again, culling unneeded code
0.32 8174 Added some game balancing stuff bloating it back up a bit
I am guessing with further code manipulation could get another 100-200
bytes off. But have become lazy.
Why optimize for size? It makes you realize how wasteful high level
code is even with optimizing compilers. Also on x86 optimizing for size is
the same from 386 on up. Optimizing for speed is so convoluted you have to
pick a particular generation of processor and even then it takes lots
of tuning because speed can depent on other things such as cache hits.
One nice thing about programs under 8k, they most likely fit in
the icache entirely ;)
Big lessons here. Function calls are killer! They take up 6 bytes!
Avoid them whenever possible.
Also, loading 32bit constants is also a pain. Also take 6 bytes!
Not as bad as on RISC where can take up to 8 bytes. Luckily x86
allows push imm/pop reg to load 8bit constant into 32 bit register
in 3 bytes.
Doing anything in memory rather than register is at least 6+ bytes!
Not as bad as RISC where you must often load/modify/store (12bytes)
but still a pain. Would possibly be mitigated if more registers
available, but that would probably make code-size bigger to accomodate
extra opcodes [waiting for x86-64 to see].

11
tb_asm/sstrip/Makefile Normal file
View File

@ -0,0 +1,11 @@
# Makefile for sstrip
ifeq ($(ARCH),)
ARCH = $(shell uname -m)
endif
sstrip: sstrip.c
gcc -ggdb -Wall -W -DARCHITECTURE=\"asm_elf_$(ARCH).h\" -o sstrip sstrip.c
clean:
rm -f sstrip *~ *.o

40
tb_asm/sstrip/README Normal file
View File

@ -0,0 +1,40 @@
sstrip is a small utility that removes the contents at the end of an
ELF file that are not part of the program's memory image.
Most ELF executables are built with both a program header table and a
section header table. However, only the former is required in order
for the OS to load, link and execute a program. sstrip attempts to
extract the ELF header, the program header table, and its contents,
leaving everything else in the bit bucket. It can only remove parts of
the file that occur at the end, after the parts to be saved. However,
this almost always includes the section header table, and occasionally
a few random sections that are not used when running a program.
It should be noted that the GNU bfd library is (understandably)
dependent on the section header table as an index to the file's
contents. Thus, an executable file that has no section header table
cannot be used with gdb, objdump, or any other program based upon the
bfd library, at all. In fact, the program will not even recognize the
file as a valid executable. (This limitation is noted in the source
code comments for bfd, and is marked "FIXME", so this may change at
some future date. However, I would imagine that it is a pretty
low-priority item, as executables without a section header table are
rare in the extreme.) This probably also explains why strip doesn't
offer the option to do this.
Shared library files may also have their section header table removed.
Such a library will still function; however, it will no longer be
possible for a compiler to link a new program against it.
As an added bonus, sstrip also tries to removes trailing zero bytes
from the end of the file. (This normally cannot be done with an
executable that has a section header table.)
sstrip is a very simplistic program. It depends upon the common
practice of putting the parts of the file that contribute to the
memory image at the front, and the remaining material at the end. This
permits it to discard the latter material without affecting file
offsets and memory addresses in what remains. Of course, the ELF
standard permits files to be organized in almost any order, so if a
pathological linker decided to put its section headers at the top,
sstrip would be useless on such executables.

View File

@ -0,0 +1,5 @@
This utility by Brian Raiter
Available at his web-site
http://www.muppetlabs.com/~breadbox/software/elfkickers.html
Included here as per the GPL.

View File

@ -0,0 +1,3 @@
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH 0xffff

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_ALPHA

View File

@ -0,0 +1,10 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#ifdef __ARMEB__
//#define ELF_DATA ELFDATA2MSB
//#else
#define ELF_DATA ELFDATA2LSB
//#endif
#define ELF_ARCH EM_ARM

View File

@ -0,0 +1,10 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#ifdef __ARMEB__
//#define ELF_DATA ELFDATA2MSB
//#else
#define ELF_DATA ELFDATA2LSB
//#endif
#define ELF_ARCH EM_ARM

View File

@ -0,0 +1,10 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#ifdef __ARMEB__
//#define ELF_DATA ELFDATA2MSB
//#else
#define ELF_DATA ELFDATA2LSB
//#endif
#define ELF_ARCH EM_ARM

View File

@ -0,0 +1,7 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
//#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_AVR32

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_BLACKFIN

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_CRIS

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_FRV

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_H8_300

View File

@ -0,0 +1,5 @@
/* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_386

View File

@ -0,0 +1,6 @@
/* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_IA_64

View File

@ -0,0 +1,7 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
//#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_M32R

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_68K

View File

@ -0,0 +1,8 @@
/*
* These are used to set parameters in the core dumps.
*/
#define EM_XILINX_MICROBLAZE 0xbaab
#define ELF_ARCH EM_XILINX_MICROBLAZE
#define ELF_CLASS ELFCLASS32
//#define ELF_DATA ELFDATA2LSB
#define ELF_DATA ELFDATA2MSB

View File

@ -0,0 +1,8 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2MSB
//#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_MIPS

View File

@ -0,0 +1,8 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2MSB
//#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_MIPS

View File

@ -0,0 +1,7 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_MIPS

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_MN10300

View File

@ -0,0 +1,8 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_PARISC
//#define ELF_CLASS ELFCLASS64
#define ELF_CLASS ELFCLASS32

View File

@ -0,0 +1,7 @@
# define ELF_ARCH EM_PPC
# define ELF_CLASS ELFCLASS32
# define ELF_DATA ELFDATA2MSB
//# define ELF_ARCH EM_PPC64
//# define ELF_CLASS ELFCLASS64
//# define ELF_DATA ELFDATA2MSB

View File

@ -0,0 +1,7 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
//#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_S390

View File

@ -0,0 +1,7 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
//#define ELF_DATA ELFDATA2MSB
#define ELF_ARCH EM_SH

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_ARCH EM_SPARC
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_ARCH EM_SPARC
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2MSB

View File

@ -0,0 +1,6 @@
/* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS32
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_VAX

View File

@ -0,0 +1,6 @@
/*
* These are used to set parameters in the core dumps.
*/
#define ELF_CLASS ELFCLASS64
#define ELF_DATA ELFDATA2LSB
#define ELF_ARCH EM_X86_64

View File

@ -0,0 +1,8 @@
/*
* These are used to set parameters in the core dumps.
*/
# define ELF_DATA ELFDATA2LSB
//# define ELF_DATA ELFDATA2MSB
#define ELF_CLASS ELFCLASS32
#define ELF_ARCH EM_XTENSA

498
tb_asm/sstrip/sstrip.c Normal file
View File

@ -0,0 +1,498 @@
/* sstrip: Copyright (C) 1999-2001 by Brian Raiter, under the GNU
* General Public License. No warranty. See COPYING for details.
* Various changes by Vince Weaver
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <elf.h>
#include <endian.h>
#include <byteswap.h>
#include ARCHITECTURE /* made local as new distros don't have it */
#if ELF_CLASS == ELFCLASS32
#define Elf_Ehdr Elf32_Ehdr
#define Elf_Phdr Elf32_Phdr
#else
#define Elf_Ehdr Elf64_Ehdr
#define Elf_Phdr Elf64_Phdr
#endif
/* Endianess of the host */
#if __BYTE_ORDER == __LITTLE_ENDIAN
static int little_endian=1;
#else
static int little_endian=0;
#endif
static int swap_bytes=0;
/* The name of the program.
*/
static char const *progname;
/* The name of the current file.
*/
static char const *filename;
/* A simple error-handling function. 0 is always returned for the
* convenience of the caller.
*/
static int err(char const *errmsg)
{
fprintf(stderr, "%s: %s: %s\n", progname, filename, errmsg);
return 0;
}
/* A macro for I/O errors: The given error message is used only when
* errno is not set.
*/
#define ferr(msg) (err(errno ? strerror(errno) : (msg)))
/* readelfheader() reads the ELF header into our global variable, and
* checks to make sure that this is in fact a file that we should be
* munging.
*/
static int readelfheader(int fd, Elf_Ehdr *ehdr) {
errno = 0;
if (read(fd, ehdr, sizeof *ehdr) != sizeof *ehdr) {
return ferr("missing or incomplete ELF header.");
}
/* Check the ELF signature.
*/
if (!(ehdr->e_ident[EI_MAG0] == ELFMAG0 &&
ehdr->e_ident[EI_MAG1] == ELFMAG1 &&
ehdr->e_ident[EI_MAG2] == ELFMAG2 &&
ehdr->e_ident[EI_MAG3] == ELFMAG3)) {
printf("missing ELF signature.");
exit(0);
}
/* Compare the file's class and endianness with the program's.
*/
if (ELF_DATA == ELFDATA2LSB) { /* 2's complement, little endian */
if (!little_endian) {
fprintf(stderr,"Warning! Host and target endianess don't match!\n");
swap_bytes=1;
}
}
else if (ELF_DATA == ELFDATA2MSB) { /* 2's complement, big endian */
if (little_endian) {
fprintf(stderr,"Warning! Host and target endianess don't match!\n");
swap_bytes=1;
}
}
else {
err("Unknown endianess type.");
}
if (ELF_CLASS == ELFCLASS64) {
if (sizeof(void *)!=8) err("host!=elf word size not supported");
}
else if (ELF_CLASS == ELFCLASS32) {
if (sizeof(void *)!=4) err("host!=elf word size not supported");
}
else {
err("Unknown word size");
}
if (ehdr->e_ident[EI_DATA] != ELF_DATA) {
err("ELF file has different endianness.");
}
if (ehdr->e_ident[EI_CLASS] != ELF_CLASS) {
err("ELF file has different word size.");
}
/* Check the target architecture.
*/
{ unsigned short machine;
machine=ehdr->e_machine;
if (swap_bytes) machine=bswap_16(machine);
if (machine != ELF_ARCH) {
fprintf(stderr, "Warning! "
"ELF file created for different architecture: %d\n",
ehdr->e_machine);
}
}
/* Verify the sizes of the ELF header and the program segment
* header table entries.
*/
{ short ehsize;
ehsize=ehdr->e_ehsize;
if (swap_bytes) ehsize=bswap_16(ehsize);
if (ehsize != sizeof(Elf_Ehdr)) {
fprintf(stderr,"Warning! "
"unrecognized ELF header size: %d != %ld\n",
ehdr->e_ehsize,(long)sizeof(Elf_Ehdr));
}
}
{
short phentsize;
phentsize=ehdr->e_phentsize;
if (swap_bytes) phentsize=bswap_16(phentsize);
if (phentsize != sizeof(Elf_Phdr)) {
fprintf(stderr,"Warning! "
"unrecognized program segment header size: %d != %ld\n",
ehdr->e_phentsize,(long)sizeof(Elf_Phdr));
}
}
/* Finally, check the file type.
*/
{short e_type;
e_type=ehdr->e_type;
if (swap_bytes) e_type=bswap_16(e_type);
if (e_type != ET_EXEC && e_type != ET_DYN) {
return err("not an executable or shared-object library.");
}
}
return 1;
}
/* readphdrtable() loads the program segment header table into memory.
*/
static int readphdrtable(int fd, Elf_Ehdr const *ehdr, Elf_Phdr **phdrs) {
size_t size;
short e_phnum;
/* should be endian safe, as zero is the same in all endianesses */
if (!ehdr->e_phoff || !ehdr->e_phnum) {
return err("ELF file has no program header table.");
}
e_phnum=ehdr->e_phnum;
if (swap_bytes) e_phnum=bswap_16(e_phnum);
size = e_phnum * sizeof **phdrs;
if (!(*phdrs = malloc(size))) {
return err("Out of memory!");
}
errno = 0;
if (read(fd, *phdrs, size) != (ssize_t)size) {
return ferr("missing or incomplete program segment header table.");
}
return 1;
}
/* getmemorysize() determines the offset of the last byte of the file
* that is referenced by an entry in the program segment header table.
* (Anything in the file after that point is not used when the program
* is executing, and thus can be safely discarded.)
*/
static int getmemorysize(Elf_Ehdr const *ehdr, Elf_Phdr *phdrs,
unsigned long *newsize)
{
Elf_Phdr *phdr;
unsigned long size, n ,end=0;
int i;
unsigned long e_phoff;
short e_phnum;
unsigned long p_offset,p_filesz;
e_phoff=ehdr->e_phoff;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) e_phoff=bswap_64(e_phoff);
#else
if (swap_bytes) e_phoff=bswap_32(e_phoff);
#endif
e_phnum=ehdr->e_phnum;
if (swap_bytes) e_phnum=bswap_16(e_phnum);
/* Start by setting the size to include the ELF header and the
* complete program segment header table.
*/
size = e_phoff + e_phnum * sizeof *phdrs;
if (size < sizeof *ehdr) {
size = sizeof *ehdr;
printf("-> Adjusting that to %ld\n",size);
}
/* Then keep extending the size to include whatever data the
* program segment header table references.
*/
for (i = 0, phdr = phdrs ; i < e_phnum ; ++i, ++phdr) {
/* endian safe as PT_NULL is zero */
if (phdr->p_type != PT_NULL) {
p_offset=phdr->p_offset;
p_filesz=phdr->p_filesz;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
p_offset=bswap_64(p_offset);
p_filesz=bswap_64(p_filesz);
}
#else
if (swap_bytes) {
p_offset=bswap_32(p_offset);
p_filesz=bswap_32(p_filesz);
}
#endif
n = p_offset + p_filesz;
if (n > size)
size = n;
end=size;
}
}
*newsize = size;
return 1;
}
/* truncatezeros() examines the bytes at the end of the file's
* size-to-be, and reduces the size to exclude any trailing zero
* bytes.
*/
static int truncatezeros(int fd, unsigned long *newsize)
{
unsigned char contents[1024];
unsigned long size, n;
size = *newsize;
do {
n = sizeof contents;
if (n > size)
n = size;
if (lseek(fd, size - n, SEEK_SET) == (off_t)-1)
return ferr("cannot seek in file.");
if (read(fd, contents, n) != (ssize_t)n)
return ferr("cannot read file contents");
while (n && !contents[--n])
--size;
} while (size && !n);
/* Sanity check.
*/
if (!size)
return err("ELF file is completely blank!");
*newsize = size;
return 1;
}
/* modifyheaders() removes references to the section header table if
* it was stripped, and reduces program header table entries that
* included truncated bytes at the end of the file.
*/
static int modifyheaders(Elf_Ehdr *ehdr, Elf_Phdr *phdrs,
unsigned long newsize)
{
Elf_Phdr *phdr;
int i;
unsigned long e_shoff;
short e_phnum;
unsigned long p_offset,p_filesz;
e_shoff=ehdr->e_shoff;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
e_shoff=bswap_64(e_shoff);
}
#else
if (swap_bytes) {
e_shoff=bswap_32(e_shoff);
}
#endif
e_phnum=ehdr->e_phnum;
if (swap_bytes) e_phnum=bswap_16(e_phnum);
/* If the section header table is gone, then remove all references
* to it in the ELF header.
*/
if (e_shoff >= newsize) {
ehdr->e_shoff = 0; /* all OK because 0 is endian neutral */
ehdr->e_shnum = 0;
ehdr->e_shentsize = 0;
ehdr->e_shstrndx = 0;
}
/* The program adjusts the file size of any segment that was
* truncated. The case of a segment being completely stripped out
* is handled separately.
*/
for (i = 0, phdr = phdrs ; i < e_phnum ; ++i, ++phdr) {
p_offset=phdr->p_offset;
p_filesz=phdr->p_filesz;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
p_offset=bswap_64(p_offset);
p_filesz=bswap_64(p_filesz);
}
#else
if (swap_bytes) {
p_offset=bswap_32(p_offset);
p_filesz=bswap_32(p_filesz);
}
#endif
if (p_offset >= newsize) {
p_offset = newsize;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
phdr->p_offset=bswap_64(p_offset);
}
#else
if (swap_bytes) {
phdr->p_offset=bswap_32(p_offset);
}
#endif
phdr->p_filesz = 0;
} else if (p_offset + p_filesz > newsize) {
p_filesz = newsize - p_offset;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
phdr->p_filesz=bswap_64(p_filesz);
}
#else
if (swap_bytes) {
phdr->p_filesz=bswap_32(p_filesz);
}
#endif
}
}
return 1;
}
/* commitchanges() writes the new headers back to the original file
* and sets the file to its new size.
*/
static int commitchanges(int fd, Elf_Ehdr const *ehdr, Elf_Phdr *phdrs,
unsigned long newsize)
{
size_t n;
unsigned long e_phoff;
short e_phnum;
e_phnum=ehdr->e_phnum;
if (swap_bytes) e_phnum=bswap_16(e_phnum);
e_phoff=ehdr->e_phoff;
#if (ELF_CLASS==ELFCLASS64)
if (swap_bytes) {
e_phoff=bswap_64(e_phoff);
}
#else
if (swap_bytes) {
e_phoff=bswap_32(e_phoff);
}
#endif
/* Save the changes to the ELF header, if any.
*/
if (lseek(fd, 0, SEEK_SET))
return ferr("could not rewind file");
errno = 0;
if (write(fd, ehdr, sizeof *ehdr) != sizeof *ehdr)
return err("could not modify file");
/* Save the changes to the program segment header table, if any.
*/
if (lseek(fd, e_phoff, SEEK_SET) == (off_t)-1) {
err("could not seek in file.");
goto warning;
}
n = e_phnum * sizeof *phdrs;
if (write(fd, phdrs, n) != (ssize_t)n) {
err("could not write to file");
goto warning;
}
/* Eleventh-hour sanity check: don't truncate before the end of
* the program segment header table.
*/
if (newsize < e_phoff + n)
newsize = e_phoff + n;
/* Chop off the end of the file.
*/
if (ftruncate(fd, newsize)) {
err("could not resize file");
goto warning;
}
return 1;
warning:
return err("ELF file may have been corrupted!");
}
/* main() loops over the cmdline arguments, leaving all the real work
* to the other functions.
*/
int main(int argc, char *argv[]) {
int fd;
Elf_Ehdr ehdr;
Elf_Phdr *phdrs;
unsigned long newsize;
char **arg;
int failures = 0;
if (argc < 2 || argv[1][0] == '-') {
printf("Usage: sstrip FILE...\n"
"sstrip discards all nonessential bytes from an executable.\n\n"
"Version 2.0 Copyright (C) 2000,2001 Brian Raiter.\n"
"This program is free software, licensed under the GNU\n"
"General Public License. There is absolutely no warranty.\n");
return EXIT_SUCCESS;
}
progname = argv[0];
for (arg = argv + 1 ; *arg != NULL ; ++arg) {
filename = *arg;
fd = open(*arg, O_RDWR);
if (fd < 0) {
ferr("can't open");
++failures;
continue;
}
if (!(readelfheader(fd, &ehdr) &&
readphdrtable(fd, &ehdr, &phdrs) &&
getmemorysize(&ehdr, phdrs, &newsize) &&
truncatezeros(fd, &newsize) &&
modifyheaders(&ehdr, phdrs, newsize) &&
commitchanges(fd, &ehdr, phdrs, newsize)))
++failures;
close(fd);
}
return failures ? EXIT_FAILURE : EXIT_SUCCESS;
}

3543
tb_asm/tb_asm.ix86.s Normal file

File diff suppressed because it is too large Load Diff

35
tb_asm/xpm/boss.xpm Normal file
View File

@ -0,0 +1,35 @@
/* XPM */
static char * boss_xpm[] = {
"40 20 12 1",
" c None",
". c #000000",
"+ c #FC54FC",
"@ c #A800A8",
"# c #A8A8A8",
"$ c #545454",
"% c #FC5454",
"& c #A80000",
"* c #FCFCFC",
"= c #00A8A8",
"- c #54FCFC",
"; c #FCFC54",
"....$#$.......*#&%%%%%%%&#*.............",
"....#$#.......*$#&&=-=&&#$*.............",
"..............*.$#=-;-=#$.*.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+.............",
"..............@...........@.............",
"..............+...........+............."};

40
tb_asm/xpm/default.xpm Normal file
View File

@ -0,0 +1,40 @@
/* XPM */
static char * default_xpm[] = {
"40 20 17 1",
" c None",
"0 c #000000",
"1 c #0000A8",
"2 c #00A800",
"3 c #00A8A8",
"4 c #A80000",
"5 c #A800A8",
"6 c #A85400",
"7 c #A8A8A8",
"8 c #545454",
"9 c #5454FC",
"A c #54FC54",
"B c #54FCFC",
"C c #FC5454",
"D c #FC54FC",
"E c #FCFC54",
"F c #FCFCFC",
"0123456789ABCDEF000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000"};

35
tb_asm/xpm/ending.xpm Normal file
View File

@ -0,0 +1,35 @@
/* XPM */
static char * ending_xpm[] = {
"40 20 12 1",
" c None",
". c #000000",
"+ c #A8A8A8",
"@ c #5454FC",
"# c #0000A8",
"$ c #545454",
"% c #54FC54",
"& c #FCFCFC",
"* c #00A8A8",
"= c #54FCFC",
"- c #00A800",
"; c #A80000",
"...###@@............+&&.................",
"...#..$@...........-%%@@................",
"...#..$@...........#%@@@................",
"...#..$@...........#@%%@................",
"...#..$@...........#@%@@................",
"....##@.............+&&.................",
"..####@@@@..............................",
"..#@##@;#@..............................",
"..#@##@@#@...+++++++++++++++++++........",
"..#@##@@#@...+++++++++++$.&&.+++........",
"..#@##@@#@...++.........$..$..++........",
"..#@##@@#@...+.................+........",
"..*=#@#@*=...+.................+........",
"....#@#@.....+...............+++........",
"....#@#@.....++............+++++........",
"....#@#@.....++++$$$+++++$$$++++........",
"....*=*=................................",
"....$+$+................................",
"........................................",
"........................................"};

40
tb_asm/xpm/missile.xpm Normal file
View File

@ -0,0 +1,40 @@
/* XPM */
static char * missile_xpm[] = {
"40 20 17 1",
" c None",
". c #000000",
"+ c #A8A8A8",
"@ c #FCFCFC",
"# c #FCFC54",
"$ c #5454FC",
"% c #A80000",
"& c #545454",
"* c #00A800",
"= c #A85400",
"- c #FC5454",
"; c #00A8A8",
"> c #54FC54",
", c #0000A8",
"' c #A800A8",
") c #54FCFC",
"! c #FC54FC",
".,*;#'=+&$>)-!#@........................",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................",
"....+..........@@%...$.$...##-..........",
"....+..........@@@....$....-#&..........",
"....+...................................",
"...%%%.........*>*...;==...++%..........",
"....#..........*>*...;==...%+...........",
"........................................",
".........+......#....-@@...&&...........",
".........+.....#.#...-++....&&..........",
".........#..............................",
"..............$$$.......................",
".............+@@@+......................",
"............++@+@++.....................",
"...............#........................"};

38
tb_asm/xpm/opener.xpm Normal file
View File

@ -0,0 +1,38 @@
/* XPM */
static char * opener_xpm[] = {
"40 20 15 1",
" c None",
". c #0000A8",
"+ c #54FCFC",
"@ c #00A8A8",
"# c #FC5454",
"$ c #000000",
"% c #A8A8A8",
"& c #FCFCFC",
"* c #545454",
"= c #00FCFC",
"- c #FCFC00",
"; c #A80000",
"> c #0000FC",
", c #FC0000",
"' c #00A800",
"...+...+.+++.@##@@###@#@@@#@##@@##@#@@@#",
"+.++.+.+..+..@#@#@#@#@##@##@#@#@#@@##@##",
"+.++.+.+.+.+.@##@@#@#@#@#@#@##@@##@#@#@#",
"+.++.+.+.+++.@#@#@#@#@#@@@#@#@#@#@@#@@@#",
"+.++...+.+++.@##@@###@#@@@#@##@@##@#@@@#",
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
"$$$$$$$$$$$$$$$$$$$$$$$$$%$$$$$$$$$$%$$$",
"$$$%$$$$$$$&$$$$$$$$$$$$$$$$$$$*$$$$$$$$",
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
"$$$$$%$$$$$$$$$$*$$$$$$$$$$$$&$$$$$$$$$$",
"$$$$$%%$$$$$$$$$$$$$$$%$$$$$$$$$$$$$=$$$",
"$-$$$%%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$=;;",
"$--->&&&&&&&&>>>$$$$$$$$$$$$$$$$$$$$$=,,",
"--;,.&;'.'.&&>>>>$$$$$$$$$$$$$$$$$$$=$,,",
"$--,>&;'.'.&&>>>>>$$$$$$;$$$$$$$$$$$$$,,",
"$$$-.%%%%%%%%&&&&&&$$$$-%%%%$$$$$$$$$$,,",
"$$$$$$$$$$$$$$$$$$$$$$$$;$$$$$$$$&$$$$;;",
"$$$$*$$$$$%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
"$&$$$$$$$$$$$$$$$&$$$$$$$$$*$$$$$$$$$$$$",
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%$"};

33
tb_asm/xpm/phobos.xpm Normal file
View File

@ -0,0 +1,33 @@
/* XPM */
static char * phobos_xpm[] = {
"40 20 10 1",
" c None",
". c #000000",
"+ c #FC0000",
"@ c #FCFCFC",
"# c #A80000",
"$ c #A8A8A8",
"% c #00A8A8",
"& c #A85400",
"* c #545454",
"= c #00FCFC",
"........................................",
"..................$.....................",
"....................................@...",
"........................................",
".....$@@@@..............................",
"....#++++++..............@..............",
"...#+++++#++............................",
"...#++++++++............................",
"...#+++#++++.....*&.....................",
"...#++++++++.....&......................",
"...#+++++#++...................@........",
"....#++++++...............$.............",
".....$@@@@..............................",
"........................................",
"........................................",
"...@.............$............$.........",
"........................................",
".%=%....................................",
"........................................",
"........................................"};

32
tb_asm/xpm/tom.xpm Normal file
View File

@ -0,0 +1,32 @@
/* XPM */
static char * tom_xpm[] = {
"40 20 9 1",
" c None",
". c #000000",
"+ c #0000A8",
"@ c #0000FC",
"# c #545454",
"$ c #00A8A8",
"% c #00FCFC",
"& c #A8A8A8",
"* c #FC0000",
"...+++@@................................",
"...+..#@................................",
"...+..#@................................",
"...+..#@................................",
"...+..#@................................",
"....++@.................................",
"..++++@@@@..............................",
"..+@++@*+@..............................",
"..+@++@@+@..............................",
"..+@++@@+@..............................",
"..+@++@@+@..............................",
"..+@++@@+@..............................",
"..$%+@+@$%..............................",
"....+@+@................................",
"....+@+@................................",
"....+@+@................................",
"....$%$%................................",
"....#&#&................................",
"........................................",
"........................................"};

View File

@ -0,0 +1,28 @@
/* XPM */
static char * vince_minimal_xpm[] = {
"16 20 5 1",
" c None",
". c #000000",
"+ c #A8A8A8",
"@ c #545454",
"# c #FCFCFC",
"..@########@....",
".@+####+####++..",
"@+++++@+#++###+.",
"+@.@+++########@",
"+.@############+",
"@.+#######+#++@@",
"@@#########@@.@+",
"@+####+###+.@.@+",
"+@@+#@.@+#+....@",
".+.@#..@.@#@...@",
".+@+#@..+##+...+",
".#@###++####...+",
".#+@@+#####@@@++",
".##@.+####+.+++.",
".##+@++###+.++@.",
".++.@..++..#@+..",
".@##@##+..@++@..",
"..#+++#++@@#+...",
"..+####@@.@#@...",
"...@@.....+#@..."};

View File

@ -0,0 +1,40 @@
/* XPM */
static char * vmwsoft_xpm[] = {
"40 20 17 1",
" c None",
". c #000000",
"+ c #0000A8",
"@ c #00A800",
"# c #00A8A8",
"$ c #A80000",
"% c #A800A8",
"& c #A85400",
"* c #A8A8A8",
"= c #545454",
"- c #5454FC",
"; c #54FC54",
"> c #54FCFC",
", c #FC5454",
"' c #FC54FC",
") c #FCFC54",
"! c #FCFCFC",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................",
"........$$$$$$$@+++++++@+++++++.........",
"........$$$$$$$@+++++++@+++++++.........",
".........$$$$$@@@+++++@@@+++++..........",
".........$$$$$@@@+++++@@@+++++..........",
"..........$$$@@@@@+++@@@@@+++...........",
"..........$$$@@@@@+++@@@@@+++...........",
"...........$@@@@@@@+@@@@@@@+............",
"...........$@@@@@@@+@@@@@@@+............",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................",
"........................................"};