mirror of https://github.com/deater/tb1.git
Import tb_6502 vesion 1.1
This commit is contained in:
parent
89efbb96c3
commit
1c5f7cf293
|
@ -0,0 +1,134 @@
|
|||
8 April 2003
|
||||
+ Got simple hello world to compile and run when entered in hex
|
||||
by hand [ od -t x1 hello ] into apple emulator.
|
||||
+ start work on add-file-to-disk-image program
|
||||
|
||||
10 April 2003
|
||||
+ Add to disk program now lets you add arbitrary files to a disk image.
|
||||
+ Hello World program now works from "BRUN TB_6502"
|
||||
|
||||
11 April 2003
|
||||
+ Move from default Apple start addy of $800 to $c00 so we can
|
||||
use low-res page flipping (page1 is from $800-$bff)
|
||||
+ Got print_text_xy routine working
|
||||
+ Got blit working! VMW opening screen now comes up!
|
||||
|
||||
14 April 2003
|
||||
+ RLE compress the sprites
|
||||
+ get title screen displaying after figuring out minor problem
|
||||
[was > 256 bytes]
|
||||
|
||||
15 April 2003
|
||||
+ Add support for in-line x and y on put_text_xy
|
||||
|
||||
16 April 2003
|
||||
+ Worked on dos3.3 utils rather than any useful menu stuff
|
||||
|
||||
9 May 2003
|
||||
+ Have menu partially working, plus the about and phobos sprites loading
|
||||
|
||||
15 May 2003
|
||||
+ Have "ABOUT" running the way I like, and not as cluttered as it was.
|
||||
|
||||
28 May 2003
|
||||
+ Fix up printxy to correctly wrap at 8-byte boundary
|
||||
+ have the story output text set up correctly.
|
||||
+ add a "clear_bottom_ function.
|
||||
|
||||
1 June 2003
|
||||
+ Story works
|
||||
+ Spent 3 hours figuring out why put_text_xy have sporadic problem.
|
||||
Stupid 6502 and no-16-bit addition. So very tired...
|
||||
|
||||
12 June 2003
|
||||
+ Add arrow key support
|
||||
+ Faster clear-screen
|
||||
|
||||
13 June 2003
|
||||
+ Fix arrow keys being backwards, add escape key support
|
||||
|
||||
21 June 2003
|
||||
+ Get normal TB left/right support, and clipping.
|
||||
+ Add missile support
|
||||
+ Fix various minor bugs.
|
||||
+ Set up page flipping. Make clear_screen, clear_bottom, and blit
|
||||
handle this properly
|
||||
+ Get preliminary shields/level/score indicator working
|
||||
+ (yes my gf was out of town, how can you guess)
|
||||
|
||||
|
||||
11 July 2003
|
||||
+ Got an enemy to appear in upper left
|
||||
|
||||
14 July 2003
|
||||
+ Enemy moving back and forth, but major heisenbug. Why, why, why?
|
||||
|
||||
15 July 2003
|
||||
+ Not heisenbug at all. Was running the move-enemy routine when
|
||||
no enemy.out. Glad I didn't post on usenet asking why my code
|
||||
was broken!
|
||||
|
||||
16 July 2003
|
||||
+ Minimal y movement implemented
|
||||
|
||||
17 July 2003
|
||||
+ Added random number generator
|
||||
|
||||
18 July 2003
|
||||
+ Re structure enemy handling code to do a copy to zero page first,
|
||||
thus streamlining things
|
||||
+ Have missile <-> enemy collision detection working
|
||||
+ Have minimal score keeping working
|
||||
+ Have minimal enemy spawning working
|
||||
+ (Yes gf was out on work related business, how did you guess)
|
||||
|
||||
29 August 2003
|
||||
+ Long delay due to move to Ithaca
|
||||
+ Annoying work getting 16-bit BCD printing to work. Harder than
|
||||
it looks!
|
||||
|
||||
30 August 2003
|
||||
+ Implement Proper Collision detection
|
||||
+ Enemies can actually damage you
|
||||
+ Explosions no longer move
|
||||
+ Have "GAME OVER" print when you die
|
||||
|
||||
7 September 2003
|
||||
+ Have it print "Level 1" at start of level
|
||||
|
||||
27 September 2003
|
||||
+ HUGELY busy with grad school. Trying to get this
|
||||
done for minigames competition
|
||||
|
||||
28 September 2003
|
||||
+ Actual varied levels working. Trying to adjust speed for playability.
|
||||
+ Added two more enemies, as having 8 is easier to do with mask instructions
|
||||
;)
|
||||
+ Attempting to add Boss.
|
||||
+ Added shield increment every 100 points
|
||||
+ S now toggles sound
|
||||
+ P now pauses
|
||||
+ While waiting for keypress, random number gen seeded
|
||||
+ Updated timinings. yae is too slow :( am trusting
|
||||
xapple2 as it seems to play most other games properly.
|
||||
Should fire up my _real_ IIe.
|
||||
|
||||
11 July 2004
|
||||
+ Finally got around to uploading on my real IIe.
|
||||
Subjective delay timing, seems to work.
|
||||
+ Boss seems to act irregularly?
|
||||
|
||||
13 July 2004
|
||||
+ Scrolling stars implemented.
|
||||
|
||||
18 July 2004
|
||||
+ "Ending" for end of level 1 ported over.
|
||||
+ Bonuses added
|
||||
+ Hi-score (though not to disk) implemented
|
||||
+ Final balancing on my Apple IIe Platinum
|
||||
+ Fix some minor bugs
|
||||
+ Fixed bug where unitialized memory was causing star scrolling to mess up
|
||||
+ Bumped version number to 1.0
|
||||
|
||||
24 July 2004
|
||||
+ Added sort-of-working paddle/joystick code.
|
|
@ -0,0 +1,233 @@
|
|||
FAQ. Some questions shamelessly stolen from the tb_asm FAQ
|
||||
|
||||
|
||||
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 somehow got side-tracked into an 8k Linux x86 text-mode version first,
|
||||
and then it seemed obvious to port it to the 6502. Finally the disks
|
||||
full of poorly written way-to-slow BASIC space games I wrote when
|
||||
I was in elementary school have been vindicated!
|
||||
|
||||
|
||||
Q. The game runs too fast/too slow! It is unplayable!
|
||||
|
||||
A. The game has been balanced and tested on an actual Apple IIe platinum.
|
||||
If you are running on an emulator, your emulator probably isn't
|
||||
emulating 100% accurately.
|
||||
If you are on a real Apple IIe... well it's probably my fault.
|
||||
If you're clever you can find the timing code in the source
|
||||
and fix it yourself.
|
||||
|
||||
|
||||
|
||||
Q. Why did it take you so long to finish?
|
||||
|
||||
A. I originally rushed to get this game entered in the 2003 Minigames
|
||||
Competition in the 4k game section. I had to cut down on the
|
||||
features a lot to get it to fit in 4k.
|
||||
|
||||
Despite all this work, I finished 53rd or so. Most of the
|
||||
complaints were negative because there aren't that many good Apple ][
|
||||
emulators out there, but a highlight was the infamous "blocky graphics"
|
||||
comment by the Atari 2600 programmer.
|
||||
|
||||
Anyway this experience burned me out on the whole concept for a bit,
|
||||
plus I started grad school which sucked up most of my time.
|
||||
|
||||
But anyway I got a chance to finish it this summer.
|
||||
|
||||
|
||||
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 LOW-RES graphics mode?
|
||||
|
||||
A. Because I like 16 colors. High-res on the Apple ][ really isn't all
|
||||
that great and can only do 4 colors or so with weird placement rules.
|
||||
|
||||
And all of you people with Atari 800s and Commodore's feel free to laugh.
|
||||
But my code here will run in full 16 color mode even on the Original
|
||||
Apple ][ released in 1977.
|
||||
|
||||
In any case I like blocky graphics, probably dating to my time doing
|
||||
ANSI graphics for BBS's in the early 90s.
|
||||
|
||||
And don't think low-res mode was a cheating way out. The Apple ][
|
||||
framebuffer is _horribly_ convoluted and non-linear. Apparently
|
||||
this saved some chips on the memory refresh... but man is it a pain
|
||||
to program.
|
||||
|
||||
|
||||
Q. Why is all the text in this game SHOUTING AT ME?
|
||||
|
||||
A. For extra perversity, I want the game to work on all machines
|
||||
back to the original 1977 Apple ][. Lower-case letters were an
|
||||
optional add-on until the Apple //e came out much later.
|
||||
|
||||
|
||||
|
||||
Q. What is the high score?
|
||||
|
||||
A. A bit of a silly question as its impossible to prove.
|
||||
|
||||
The highest _possible_ score is 9999 I am pretty sure, due
|
||||
to the limitations of a 16 bit BCD number (which is how the
|
||||
score is stored).
|
||||
|
||||
|
||||
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 Bruce Jacob always said...
|
||||
A computer is just a state machine.
|
||||
|
||||
|
||||
|
||||
Q. Why are there only 6 enemies / 2 missiles / shields go up at 100/ 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_6502.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.
|
||||
The apple II version has in addition a green toothbrush and a
|
||||
purple toupe. Those wacky marketers!
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Q. Why does vince use the stack so often, when it would make much more
|
||||
sense to backup the Y register to the zero page?
|
||||
|
||||
A. Too much intel x86 programming has warped my mind into thinking
|
||||
stack usage is a good way of mitigating limited register count.
|
||||
|
||||
Must remind myself the zero page is like a 256-byte register file.
|
||||
|
||||
|
||||
|
||||
Q. Why is the 6502 instruction set so obtuse?
|
||||
|
||||
A. I HAVE NO IDEA. In coding I keep stumbling across instructions
|
||||
that I think would be _so_ useful. But they don't exist. But
|
||||
apparently the instructions I pine for are fairly obvious...
|
||||
an enhanced 65C02 was released with "bonus" opcodes. Sadly
|
||||
I cannot use them because of the aforementioned want of Apple ][
|
||||
compatibility [the 65C02 wasn't around until the //e.
|
||||
|
||||
ABS (IND), X indexing : would be great working with structs.
|
||||
BRA -- Branch Always : a great opcode name, but also remove
|
||||
the need for 16-bit absolute JMP's when
|
||||
a short branch would do
|
||||
DEA -- Decrement Accumulator :
|
||||
That's right, there's no way to decrement
|
||||
the accumulator. You have to CLC clear
|
||||
carry then ADC $FF. Yet you can dec
|
||||
X or Y with one-byte. Weird.
|
||||
INA -- Incrememnt Accumlator:
|
||||
See DEA. Yes, even more perverse. Taking
|
||||
3 bytes to do what should be a common task.
|
||||
PHX/PLX
|
||||
PHY/PLY -- Push/Pop X/Y :
|
||||
These would be so useful. Otherwise
|
||||
you can only push/pop the accumulator.
|
||||
STZ -- Store Zero to Memory :
|
||||
Would save a lot of LDA #$0 / STA pairs.
|
||||
TRB/TSB -- Test and Set/Reset bit:
|
||||
Wow, getting even more CISC here. Atomic
|
||||
test/set bit instructions. We're ready
|
||||
for SMP now.
|
|
@ -0,0 +1,18 @@
|
|||
all: TB_6502
|
||||
|
||||
|
||||
TB_6502: tb_6502
|
||||
make_b ./tb_6502 ./TB_6502 0xC00
|
||||
|
||||
tb_6502: tb_6502.o
|
||||
ld65 -C ./apple2_c00.inc -o tb_6502 tb_6502.o
|
||||
|
||||
tb_6502.o: tb_6502.s
|
||||
ca65 -o tb_6502.o -l tb_6502.s
|
||||
|
||||
disk:
|
||||
dos33 tb_6502.dsk SAVE B TB_6502
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.lst *.o tb_6502 *~ add_to_disk TB_6502 make_b a.out
|
|
@ -0,0 +1,130 @@
|
|||
TOM BOMBEM: Merciless Marauding Malicious Marketers
|
||||
6502 Apple IIe Edition
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
http://www.deater.net/weave/vmwprod/tb1/tb_6502.html
|
||||
|
||||
by Vince Weaver <vince@deater.net>
|
||||
|
||||
version 1.1 -- 24 July 2004
|
||||
|
||||
|
||||
Quotes about tb_6502:
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
"The graphics are crude and blocky."
|
||||
-- random Atari 2600 developer
|
||||
|
||||
|
||||
System Requirements:
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
Apple ][ Computer
|
||||
At least 32kB of RAM
|
||||
Disk drive, or Super Serial Card to load game
|
||||
|
||||
|
||||
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_6502 comes before "tb1: Invasion of the Inanimate Objects"
|
||||
chronologically, for those who might care.
|
||||
|
||||
|
||||
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:
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
not implemented yet
|
||||
|
||||
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 100 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!
|
||||
|
||||
|
||||
Compiling / Running:
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
RUNNING:
|
||||
Just obtain an apple emulator. Point it to the tb_6502.dsk image.
|
||||
Upon booting it should run!
|
||||
|
||||
Also, you can get a real Apple II computer and download the disk
|
||||
image to a real floppy. That is a bit more complicated.
|
||||
|
||||
COMPILING:
|
||||
|
||||
The following compile instructions assume you are using Linux.
|
||||
|
||||
* first you need the c65 package from:
|
||||
http://www.cc65.org/
|
||||
|
||||
To install cc65 you need to unpack, and do a
|
||||
"make -f make/gcc.mak" from the cc65/src directory.
|
||||
|
||||
The utils we need are ca65 and ld65. Copy them somewhere in your
|
||||
path (ie /usr/local/bin).
|
||||
|
||||
* To make the disk image you will need the dos33fsprogs package
|
||||
of mine, available from:
|
||||
http://www.deater.net/weave/vmwprod/apple/dos33fs.html
|
||||
Unpack and instal. "make; make install"
|
||||
|
||||
* Now hopefully just type "make" in the tb_6502 directory and
|
||||
the program should be assembled. "make disk" should copy
|
||||
the new version to the disk image, assuming all the tools
|
||||
are installed properly.
|
||||
|
||||
|
||||
|
||||
About:
|
||||
~~~~~~
|
||||
|
||||
When I was much younger, I would type in BASIC games on the Apple II.
|
||||
I always wanted to write games myself, but the ones I wrote in BASIC
|
||||
were too slow. I was just starting to learn assembly when we got
|
||||
a 386 and I moved on to other things.
|
||||
|
||||
But now, only 25 years too late, I finally wrote a playable game!
|
||||
|
||||
The hope is maybe eventually using this as a stepping-board to
|
||||
creating a Game Boy Advance TomBombem game.
|
||||
|
||||
This game was originally written for the 4k mini-game competition.
|
||||
It finished embarassingly low in the standings. I've added some
|
||||
more features now so it is well over the 4k mark.
|
||||
|
||||
Author:
|
||||
~~~~~~~
|
||||
Vince Weaver <vince@deater.net>
|
||||
http://www.deater.net/weave/
|
||||
Special Thanks to KRG
|
||||
24 July 2004
|
||||
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
Save high score to disk.
|
||||
|
||||
OPTIMIZE!
|
|
@ -0,0 +1,12 @@
|
|||
MEMORY {
|
||||
ZP: start = $00, size = $1A, type = rw;
|
||||
RAM: start = $C00, size = $8E00, file = %O;
|
||||
}
|
||||
|
||||
SEGMENTS {
|
||||
CODE: load = RAM, type = ro;
|
||||
RODATA: load = RAM, type = ro;
|
||||
DATA: load = RAM, type = rw;
|
||||
BSS: load = RAM, type = bss, define = yes;
|
||||
ZEROPAGE: load = ZP, type = zp;
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,173 @@
|
|||
/* 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() */
|
||||
|
||||
char dos_color_to_apple[16]=
|
||||
{0, /* 0 black */
|
||||
2, /* 1 blue */
|
||||
4, /* 2 green */
|
||||
7, /* 3 cyan */
|
||||
1, /* 4 red */
|
||||
3, /* 5 purple */
|
||||
8, /* 6 brown */
|
||||
10,/* 7 l grey */
|
||||
5, /* 8 d grey */
|
||||
6, /* 9 l blue */
|
||||
12, /*10 l green */
|
||||
14, /*11 l cyan */
|
||||
9, /*12 l red */
|
||||
11, /*13 pink */
|
||||
13, /*14 yellow */
|
||||
15, /* 15 white */
|
||||
}
|
||||
;
|
||||
|
||||
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 main(int argc, char **argv) {
|
||||
|
||||
FILE *input,*output;
|
||||
|
||||
char input_filename[]="sprites";
|
||||
int pointer,temp_pointer;
|
||||
char input_line[BUFSIZ];
|
||||
char temp_string[BUFSIZ];
|
||||
int color=0,oldcolor,run;
|
||||
|
||||
input=fopen(input_filename,"r");
|
||||
if (input==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)) {
|
||||
pointer=5;
|
||||
|
||||
printf("\t.byte ");
|
||||
while(!isdigit(input_line[pointer])) pointer++;
|
||||
color=get_number(input_line,&pointer);
|
||||
while(!isdigit(input_line[pointer])) pointer++;
|
||||
oldcolor=color;
|
||||
run=1;
|
||||
while(pointer<strlen(input_line)) {
|
||||
color=get_number(input_line,&pointer);
|
||||
if ((color!=oldcolor) || (run>14)) {
|
||||
printf("$%X,",(run<<4)+dos_color_to_apple[oldcolor]);
|
||||
run=0;
|
||||
}
|
||||
run++;
|
||||
oldcolor=color;
|
||||
|
||||
while(!isdigit(input_line[pointer])) pointer++;
|
||||
}
|
||||
if (color!=0) {
|
||||
printf("$%X,",(run<<4)+dos_color_to_apple[color]);
|
||||
}
|
||||
|
||||
|
||||
printf("$00\n");
|
||||
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--;
|
||||
|
||||
strncpy(temp_string,input_line+temp_pointer,pointer-temp_pointer);
|
||||
temp_string[pointer]='\0';
|
||||
printf("\t.byte $00\n");
|
||||
printf("%s:\n",temp_string);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
pointer++;
|
||||
}
|
||||
done_with_string: ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
close_file:
|
||||
if (input!=NULL) fclose(input);
|
||||
|
||||
file_error:
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
char string[BUFSIZ];
|
||||
int i;
|
||||
|
||||
while(1) {
|
||||
fgets(string,BUFSIZ,stdin);
|
||||
if (feof(stdin)) goto done;
|
||||
|
||||
printf(";# %s\n",string);
|
||||
printf(".byte\t");
|
||||
|
||||
printf("$%X",string[0]+128);
|
||||
|
||||
for (i=1;i<strlen(string);i++) {
|
||||
printf(",$%X",string[i]+128);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
done:
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int random_num(int seed)
|
||||
{
|
||||
|
||||
static int our_seed;
|
||||
|
||||
if (seed!=-1) our_seed=seed;
|
||||
|
||||
if (our_seed==0) our_seed=13;
|
||||
|
||||
our_seed<<=1;
|
||||
if (our_seed & 0x100) our_seed^=0x87;
|
||||
|
||||
our_seed&=0xff;
|
||||
|
||||
return our_seed;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int frequency[256];
|
||||
for(i=0;i<256;i++) frequency[i]=0;
|
||||
|
||||
for(i=0;i<4096;i++)
|
||||
frequency[random_num(-1)]++;
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
printf("%i : %i\n",i,frequency[i]);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i;
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
printf("%i = %x = %i\n",i,i,(26+27*i+5*i*i)/2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue