aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2021-05-05 01:50:12 -0400
committerB. Watson <yalhcru@gmail.com>2021-05-05 01:50:12 -0400
commit1989c02b763a04d0f941114056f11bb96bdb2550 (patch)
tree459faeceae7280c2cd2c18e703e863b8ab9cc5e0
parent682bb2a6174a30578f1dd770ebd3d1f39938bf6c (diff)
downloadtaipan-1989c02b763a04d0f941114056f11bb96bdb2550.tar.gz
Finally fix damaged ship gfx
-rw-r--r--.gitignore2
-rw-r--r--DAMAGED.DATbin49 -> 49 bytes
-rw-r--r--LORCHA.DATbin49 -> 49 bytes
-rw-r--r--Makefile56
-rw-r--r--block2hex.pl13
-rw-r--r--convfont.c265
-rw-r--r--gzip2deflate.c78
-rw-r--r--hex2block.pl12
-rw-r--r--lorchatest.c1
-rw-r--r--shipshape.pl61
-rw-r--r--taifontbin1024 -> 1024 bytes
-rw-r--r--taipan.c14
12 files changed, 311 insertions, 191 deletions
diff --git a/.gitignore b/.gitignore
index fcf130b..52cd230 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,5 @@ ver.dat
.*
*~
convfont
+damaged.txt
+lorcha.txt
diff --git a/DAMAGED.DAT b/DAMAGED.DAT
index 175ea48..a968e8a 100644
--- a/DAMAGED.DAT
+++ b/DAMAGED.DAT
Binary files differ
diff --git a/LORCHA.DAT b/LORCHA.DAT
index e11c6fe..cc8ded1 100644
--- a/LORCHA.DAT
+++ b/LORCHA.DAT
Binary files differ
diff --git a/Makefile b/Makefile
index 801b6a1..16875d3 100644
--- a/Makefile
+++ b/Makefile
@@ -88,13 +88,6 @@ PERLFLAGS=-C0
PERLF=$(PERL) $(PERLFLAGS)
-# A few files have no make rules here. LORCHA.DAT is generated as a
-# side-effect of generating taifont.xex. It's a 49-byte (7x7) blob of
-# Atari "internal" screen codes.
-
-# LORCHA.DAT, and PORTSTAT.DAT aren't deleted by a
-# 'make clean'.
-
# romfont is the 1K font extracted from the Atari 800 OS, with a
# command like:
# dd if=atariosb.rom of=1 bs=256 skip=8 count=4
@@ -255,7 +248,7 @@ help.dat: help.txt text2screen.pl
# The main executable. All the C and asm code goes here, except the init
# segment in newtitle.s.
-taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) $(TAIMAIN_LIBS) messages.c
+taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS) $(BIGNUM_SRC) $(BIGNUM_HDRS) $(TAIMAIN_LIBS) messages.c LORCHA.DAT
$(CC) -m taipan.map $(CFLAGS) $(BIGNUM_CFLAGS) -o taimain.xex $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(BIGNUM_SRC) $(TAIMAIN_LIBS)
#cl65 --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c sounds.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s console.s
@@ -270,14 +263,13 @@ taipan.lst: taipan.c
sounds.lst: sounds.c sounds.h
$(CC) -m sounds.map $(CFLAGS) -c -o /dev/null -l sounds.lst -T sounds.c
+LORCHA.DAT: taifont.xex
+
# The font gets loaded into RAM, in the area reserved by the
# -D__RESERVED_MEMORY__ option to cl65. To actually use the font,
# taimain.xex contains code that sets CHBAS ($02f4).
-# Not mentioned in any make rule: convfont also creates LORCHA.DAT,
-# which draw_lorcha.s depends on (so we touch draw_lorcha.s here).
taifont.xex: convfont romfont font
cat romfont font | ./convfont -x > taifont.xex
- touch draw_lorcha.s
# Used by the cartridge build, but not the disk (xex) binary. This just
# builds the font without the Atari 6-byte binary load header. It ends
@@ -397,7 +389,7 @@ testcart: clean cart
# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont mkcart gzip2deflate *.xex AUTORUN.SYS taipan.atr dos2.atr mydos.atr fenders.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill256 blankbank romable_taimain.raw splitrom.raw.* comptitle.s comptitle.dat conio/*.o conio/*.lib messages.c textcomp titledata.dat cartbank2.cfg
+ rm -f *.o *.lst convfont mkcart gzip2deflate *.xex AUTORUN.SYS taipan.atr dos2.atr mydos.atr fenders.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill256 blankbank romable_taimain.raw splitrom.raw.* comptitle.s comptitle.dat conio/*.o conio/*.lib messages.c textcomp titledata.dat cartbank2.cfg LORCHA.DAT DAMAGED.DAT lorcha.txt damaged.txt
distclean: clean
rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz
@@ -412,42 +404,16 @@ procsizes: clean all taipan.lst
$(PERLF) procsizes.pl > procsizes
cat procsizes
-# Cruft. Was used for testing the enemy ship animation.
-lorchatest: lorchatest.c draw_lorcha.s taifont.xex
- $(CC) -t atari -O -T -o lorchatest1.xex lorchatest.c draw_lorcha.s
- cat taifont.xex lorchatest1.xex > lorchatest.xex
- atari800 -nobasic lorchatest.xex
-
-#### cruft, from when I was planning to use a 32K cart:
-# this was a blind alley: zlib is too slow to decompress, plus there's
-# no need to compress taimain.xex since I'm able to use a 64K cart.
+# These 2 are informational only, for when you're editing the ship
+# graphics in convfont.c.
+lorcha.txt: shipshape.pl LORCHA.DAT
+ $(PERLF) shipshape.pl LORCHA.DAT > lorcha.txt
-# gzip2deflate downloaded from https://github.com/pfusik/zlib6502
-# I could have used deflator.c that ships with cc65's source, but
-# it's deprecated by its own upstream (same author as gzip2deflate).
-gzip2deflate: gzip2deflate.c
- $(HOSTCC) $(HOSTCFLAGS) -o gzip2deflate gzip2deflate.c
-
-zlibtest.xex: gzip2deflate zlibtest.c zlibtestdata.s romable_taimain.raw
- gzip -9c < romable_taimain.raw | ./gzip2deflate > rom.dfl
- $(CC) -t atari -m zlibtest.map -l zlibtest.lst -Wl -D__SYSTEM_CHECK__=1 --start-addr 0x7000 -o zlibtest.xex zlibtest.c zlibtestdata.s
-romable_taimain.xex: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS)
- rm -f taimain.xex
- $(MAKE) TAIMAIN_ADDR=0x3ff EXTRACFLAGS="-DCART_TARGET=1 --asm-define CART_TARGET=1"
- mv taimain.xex romable_taimain.xex
-
-###
+damaged.txt: shipshape.pl LORCHA.DAT
+ $(PERLF) shipshape.pl DAMAGED.DAT > damaged.txt
+# This one build the sound code as a standalone xex.
soundtest: sounds.c
$(CC) -DTESTXEX -t atari -o sounds.xex sounds.c
atari800 -nobasic sounds.xex
-# former textmode title screen, was generated by TITLE.LST. Replaced
-# by graphical title screen.
-#title.xex: TITLE.DAT
-# $(PERL) title.pl TITLE.DAT > title.xex
-
-# old title
-#$(XEX): taimain.xex taifont.xex title.xex
-# cat taifont.xex title.xex taimain.xex > $(XEX)
-
diff --git a/block2hex.pl b/block2hex.pl
new file mode 100644
index 0000000..c1e44f0
--- /dev/null
+++ b/block2hex.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl -w
+
+while(<>) {
+ chomp;
+ #$was = $_;
+ s/$/ / while length($_) < 8;
+ s/X/1/g;
+ s/ /0/g;
+ #warn "was '$was', now '$_'\n";
+ push @out, sprintf("0x%02x", eval "0b$_");
+}
+
+print join(", ", @out) . "\n";
diff --git a/convfont.c b/convfont.c
index a0ae0f4..1882efd 100644
--- a/convfont.c
+++ b/convfont.c
@@ -5,99 +5,188 @@
#include <unistd.h>
#include <stdio.h>
-/* usage:
- # extract the 1K atari ROM font:
+/* convfont - convert and combine the Atari ROM font and the
+ Apple II Taipan font for use with Atari Taipan.
+
+ Usage:
+
+ # Extract the 1K Atari ROM font:
dd if=atariosb.rom of=romfont bs=256 skip=8 count=4
- # extract the Apple II Taipan font:
+ # Extract the Apple II Taipan font:
dd if=taipan.dsk of=font bs=256 skip=54 count=3
- # create the Atari 8-bit Taipan font:
+ # Create the Atari 8-bit Taipan font as raw data:
cat romfont font | ./convfont > taifont.raw
- # or, create the Atari 8-bit Taipan font as a binary load:
+ # Or, create the Atari 8-bit Taipan font as a binary load,
+ # with load address set to FONT_ADDR. This has to be defined
+ # on the gcc command line when convfont is built (see Makefile):
+
cat romfont font | ./convfont -x > taifont.xex
+
+ In addition to writing the font on stdout, this program
+ also creates LORCHA.DAT and DAMAGED.DAT. If they already
+ exist, they are overwritten.
+
+ There is NO error checking in this program! It expects exactly
+ 1792 bytes on its stdin (as in the commands above).
*/
-/*
- taipan font file order:
- 0-31: `a-z{|}" block
- 32-63: @A-Z[\]^_
- 64-95: space !"#$%&'()*+,-./0-9:;>=<?
+/* Long-winded explanation of shipdata[] and how to edit it:
- atari screen code order:
- 0-31: space !"#$%&'()*+,-./0-9:;>=<?
- 32-63: @A-Z[\]^_
- 64-95 graphics chars
- 96-127: `a-z and 4 graphics chars
-*/
+ Custom characters for ship graphics. 1st byte
+ is screencode, the other 8 are the pixel data. The
+ screencodes aren't in any particular order. They
+ match the screencodes in shipshape[] and damaged_shipshape[].
+
+ This stuff was originally done with a perl script that
+ sliced up a PNG image of the lorcha, from an Apple II
+ emulator screenshot. The script is long gone (it's from
+ before I started using git for this project). At this
+ point, nobody should ever have to edit the graphics again.
+ I document the process I used, below, in case that turns
+ out to be incorrect.
+
+ Editing the ship graphics is a cumbersome mostly-manual
+ process. Basically you copy the pixel data (8 hex pairs, do
+ NOT copy the screencode too), and paste
+ it into the stdin of hex2block.pl. If you wanted to edit
+ the small flag on top of the right-hand sail:
+
+ 1. Locate its character code by looking at shipshape[]. It's
+ the rightmost character on the 2nd row, 0x53.
+ 2. Find the shipdata[] line that begins with 0x53.
+ 3. Copy *just* the pixel data (don't copy the 0x53).
+ 4. Run this:
+
+$ perl hex2block.pl > x.txt
+
+ 5. Paste your line of hex data in the terminal and press Enter.
+ x.txt ends up looking like e.g.:
+
+$ cat -A x.txt
+ $
+ $
+ X $
+ XXX $
+ XXXXX $
+ X XXX$
+ X $
+ X $
+
+ The $ are EOL markers put there by 'cat -A', so you can see
+ the trailing spaces. You can see the flag shape made of X's.
+
+ 6. Edit x.txt with your favorite text editor, using X and space
+ for lit/unlit pixels. There should be exactly 8 lines of 8
+ characters (each of which is an X or a space).
+
+ 7. Run this:
+
+$ perl block2hex.pl x.txt
+
+ ...which gives you hex data to paste into this file, e.g.:
+
+0x00, 0x00, 0x40, 0x70, 0x7c, 0x47, 0x40, 0x40
+
+ 8. Copy the hex data, and paste it back into this file, replacing
+ the original data for character 0x53.
+
+ As you can see, I *really* should have written an easier to use
+ tool for this. However, it might have taken me longer to do that
+ than it did to just grind through all the damaged-ship graphics.
+
+ Notes:
+
+ Screen codes 0x41, 0x43, 0x44, 0x45, 0x51, 0x52, 0x5a are box
+ drawing chars, used to draw the port status, firm naming, and
+ retirement screens. So don't try to use them as ship pieces!
+
+ 0x54 is the ^T ball character, copied from the Atari ROM font.
+ It looks OK as a hole made by a cannonball so I used it as-is
+ (or actually, used 0xd4, the inverse video version).
+
+ All the other graphics characters are used, plus a few printable
+ ones (square brackets, backslash, underscore).
+
+ When you're editing the ship graphics, uncomment the
+ #define LORCHA_TEST line near the top of taipan.c to see you
+ work in progress (wail on the space bar to repeatedly damage
+ the ships).
+
+ If you want ASCII art versions of the healthy and fully-damaged
+ lorcha, use "make lorcha.txt" and/or "make damaged.txt".
+ */
-/* custom characters for ship graphics. 1st byte
- is screencode, the other 8 are the pixel data. */
char shipdata[][9] = {
/* healthy ship blocks */
- {0x02 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f},
- {0x03 , 0x18, 0x1f, 0x1f, 0x10, 0x10, 0x10, 0xff, 0xff},
- {0x04 , 0x00, 0xf0, 0xfc, 0x3e, 0x00, 0x00, 0xfc, 0xf0},
- {0x06 , 0x00, 0x00, 0x40, 0x70, 0x7c, 0x47, 0x40, 0x40},
- {0x1b , 0x1f, 0x3f, 0xff, 0x3f, 0x1f, 0x3f, 0xff, 0x7f},
- {0x1c , 0xc0, 0xf0, 0xfc, 0xf0, 0xc0, 0xf0, 0xfc, 0xf0},
- {0x1d , 0x07, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x07, 0x0f},
- {0x1e , 0xfe, 0xfc, 0xfe, 0xff, 0xfe, 0xf8, 0xfe, 0xff},
- {0x20 , 0xfe, 0xf8, 0xfe, 0xff, 0xfe, 0xfe, 0xfd, 0xf9},
- {0x3b , 0xc0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f},
- {0x3c , 0x00, 0x00, 0xc0, 0xff, 0x8f, 0x8e, 0x8e, 0xfe},
- {0x3d , 0x38, 0x38, 0x38, 0x38, 0xff, 0x38, 0x38, 0x38},
- {0x3e , 0x00, 0x00, 0x00, 0x01, 0xff, 0xe3, 0xe3, 0xe3},
- {0x3f , 0x00, 0x00, 0x00, 0xff, 0x8e, 0x8e, 0x8e, 0xff},
- {0x40 , 0xc3, 0xcf, 0xff, 0xff, 0x3f, 0x3e, 0x3c, 0xf8},
- {0x46 , 0x1f, 0x0f, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03},
- {0x47 , 0xf0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80},
-
- /*
-A, 50, 00 00 00 00 00 00 47 3e
-B, 5b, 18 1f 1d 10 10 10 fb fd
-E, 5e, 1f 0f 1f 3f 1f 3b ff 7f
-G, 5f, 00 01 03 07 03 03 07 06
-H, 60, f0 f8 fb fe fe f8 fe 7f
-I, 7b, fe f8 be 97 8e be fc f8
-J, 7d, 00 00 03 1d 1f 37 3b 1f
-K, 7e, 00 00 00 00 80 c1 e3 e3
-O, 7f, c0 c0 f0 e0 20 32 3c f1
-*/
+ {0x42 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f}, // ^B
+ {0x4e , 0x18, 0x1f, 0x1f, 0x10, 0x10, 0x10, 0xff, 0xff}, // ^N
+ {0x4f , 0x00, 0xf0, 0xfc, 0x3e, 0x00, 0x00, 0xfc, 0xf0}, // ^O
+ {0x53 , 0x00, 0x00, 0x40, 0x70, 0x7c, 0x47, 0x40, 0x40}, // ^S
+ {0x55 , 0x1f, 0x3f, 0xff, 0x3f, 0x1f, 0x3f, 0xff, 0x7f}, // ^U
+ {0x56 , 0xc0, 0xf0, 0xfc, 0xf0, 0xc0, 0xf0, 0xfc, 0xf0}, // ^V
+ {0x57 , 0x07, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x07, 0x0f}, // ^W
+ {0x58 , 0xfe, 0xfc, 0xfe, 0xff, 0xfe, 0xf8, 0xfe, 0xff}, // ^X
+ {0x5b , 0xfe, 0xf8, 0xfe, 0xff, 0xfe, 0xfe, 0xfd, 0xf9}, // Esc symbol
+ {0x3b , 0xc0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f}, // [
+ {0x3c , 0x00, 0x00, 0xc0, 0xff, 0x8f, 0x8e, 0x8e, 0xfe}, // backslash
+ {0x3d , 0x38, 0x38, 0x38, 0x38, 0xff, 0x38, 0x38, 0x38}, // ]
+ {0x5c , 0x00, 0x00, 0x00, 0x01, 0xff, 0xe3, 0xe3, 0xe3}, // up arrow
+ {0x3f , 0x00, 0x00, 0x00, 0xff, 0x8e, 0x8e, 0x8e, 0xff}, // _
+ {0x40 , 0xc3, 0xcf, 0xff, 0xff, 0x3f, 0x3e, 0x3c, 0xf8}, // heart (null)
+ {0x46 , 0x1f, 0x0f, 0x07, 0x07, 0x07, 0x03, 0x03, 0x03}, // ^F
+ {0x47 , 0xf0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80}, // ^G
+
/* damaged ship blocks */
- { 0x50 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x3e},
- { 0x5b , 0x18, 0x1f, 0x1d, 0x10, 0x10, 0x10, 0xfb, 0xfd},
- { 0x5e , 0x1f, 0x0f, 0x1f, 0x3f, 0x1f, 0x3b, 0xff, 0x7f},
- { 0x5f , 0x00, 0x01, 0x03, 0x07, 0x03, 0x03, 0x07, 0x06},
- { 0x60 , 0xf0, 0xf8, 0xfb, 0xfe, 0xfe, 0xf8, 0xfe, 0x7f},
- { 0x7b , 0xfe, 0xf8, 0xbe, 0x97, 0x8e, 0xbe, 0xfc, 0xf8},
- { 0x7d , 0x00, 0x00, 0x03, 0x1d, 0x1f, 0x37, 0x3b, 0x1f},
- { 0x7e , 0x00, 0x00, 0x00, 0x00, 0x80, 0xc1, 0xe3, 0xe3},
- { 0x7f , 0xc0, 0xc0, 0xf0, 0xe0, 0x20, 0x32, 0x3c, 0xf1},
+ { 0x50 , 0x00, 0x00, 0x00, 0x00, 0x83, 0xc3, 0xe3, 0xe3}, // ^P
+ { 0x5d , 0xff, 0x9f, 0x8f, 0x9f, 0xf9, 0xf8, 0xf9, 0xff}, // down arrow
+ { 0x48 , 0x1f, 0x3b, 0xfd, 0x39, 0x18, 0x31, 0xfb, 0x7f}, // ^H
+ { 0x49 , 0xff, 0xff, 0xfd, 0xe1, 0x83, 0x0f, 0xff, 0xff}, // ^G
+ { 0x4a , 0xd5, 0xa3, 0x41, 0x81, 0x40, 0xb0, 0xfc, 0xff}, // ^I
+ { 0x4b , 0xc0, 0xf0, 0xfc, 0xf0, 0xc0, 0x00, 0x80, 0xf0}, // ^J
+ { 0x5e , 0x1f, 0x39, 0xf1, 0x39, 0x1f, 0x3c, 0xf8, 0x7c}, // L arrow
+ { 0x5f , 0xfe, 0xf8, 0xee, 0xcf, 0x9e, 0xbe, 0xfd, 0xf9}, // R arrow
+ { 0x60 , 0xfe, 0xbc, 0xc6, 0xcf, 0x96, 0xd8, 0xfe, 0xff}, // diamond
+ { 0x4c , 0xff, 0xff, 0xff, 0xff, 0xe8, 0x81, 0xe1, 0xff}, // ^L (UL 1/4 blk)
+ { 0x4d , 0xff, 0x8f, 0x8f, 0xe7, 0xfe, 0xf8, 0xf0, 0xff}, // ^M
+ { 0x7b , 0xfe, 0xf8, 0xbe, 0x97, 0x8e, 0xbe, 0xfc, 0xf8}, // spades
+ { 0x7d , 0xc0, 0xfe, 0xeb, 0xc7, 0xc3, 0xe7, 0x7f, 0x1f}, // clrscr (bent arrow)
+ { 0x7e , 0x00, 0x00, 0x00, 0x00, 0x80, 0xc1, 0xe3, 0xe3}, // left triangle
+ { 0x7f , 0xc3, 0xce, 0xf8, 0xf0, 0x30, 0x30, 0x3c, 0xfe}, // right triangle
/* end of ship data marker */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-/* this ends up in LORCHA.DAT */
+/* This ends up in LORCHA.DAT, verbatim. See shipshape[] above
+ for the definitions of each screencode used here. If you can't
+ find a screencode in shipshape[], it's using the regular font
+ character (e.g. 0x00 is a space, 0x80 is an inverse space
+ aka solid 8x8 block). */
char shipshape[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x03, 0x04, 0x00, 0x06,
- 0x00, 0x00, 0x1b, 0x80, 0x1c, 0x1d, 0x1e,
- 0x00, 0x00, 0x1b, 0x80, 0x1c, 0x1d, 0x20,
- 0x00, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40,
+ 0x00, 0x00, 0x42, 0x4e, 0x4f, 0x00, 0x53,
+ 0x00, 0x00, 0x55, 0x80, 0x56, 0x57, 0x58,
+ 0x00, 0x00, 0x55, 0x80, 0x56, 0x57, 0x5b,
+ 0x00, 0x3b, 0x3c, 0x3d, 0x5c, 0x3f, 0x40,
0x00, 0x46, 0x80, 0x80, 0x80, 0x80, 0x47,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
+/* DAMAGED.DAT - each time a lorcha gets damaged, a random
+ character from here overwrites the original shipshape[]
+ character in screen RAM. See draw_lorcha.s for details.
+ If a part of the ship can't display damage, it'll have
+ the same screencode here as it does in shipshape[]. */
char damaged_shipshape[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x50, 0x5b, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x5e, 0xd4, 0x00, 0x5f, 0x1e,
- 0x00, 0x00, 0x5e, 0xd4, 0x00, 0x5f, 0x60,
- 0x00, 0x7d, 0x7e, 0x7c, 0x7e, 0x7e, 0x7f,
- 0x00, 0x46, 0xcc, 0x87, 0xcc, 0x8e, 0x47,
+ 0x00, 0x00, 0x42, 0x4e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x5e, 0x4a, 0x56, 0x57, 0x60,
+ 0x00, 0x00, 0x48, 0xd4, 0x4b, 0x57, 0x5f,
+ 0x00, 0x7d, 0x7e, 0x7c, 0x7e, 0x50, 0x7f,
+ 0x00, 0x46, 0x4c, 0x5d, 0x4d, 0x49, 0x47,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
@@ -125,19 +214,52 @@ void clear0bits(unsigned char *b, int lim) {
} while(--lim > 0);
}
+/*
+ taipan font file order:
+ 0-31: `a-z{|}" block
+ 32-63: @A-Z[\]^_
+ 64-95: space !"#$%&'()*+,-./0-9:;>=<?
+
+ atari screen code order:
+ 0-31: space !"#$%&'()*+,-./0-9:;>=<?
+ 32-63: @A-Z[\]^_
+ 64-95 graphics chars
+ 96-127: `a-z and 4 graphics chars
+*/
+
int main(int argc, char **argv) {
int i, j;
unsigned char font[1024], xex[6];
+ /* The first 1024 bytes of stdin are the Atari ROM font,
+ taken from an image of the ROM OS. */
read(0, font, 1024);
+
+ /* The remaining 768 bytes are the Taipan Apple II font,
+ extracted from the .dsk image. Its characters are in a
+ different order than the Atari expects them, so use 3 reads
+ with appropriate offsets/lengths. The Apple also packs the
+ pixels into each byte backwards from what the Atari expects,
+ so bitswap() fixes that. */
read(0, font + (96 * 8), 32 * 8);
bitswap(font + (96 * 8), 32 * 8);
+
read(0, font + (32 * 8), 32 * 8);
bitswap(font + (32 * 8), 32 * 8);
+
read(0, font + (0 * 8), 32 * 8);
bitswap(font + (0 * 8), 32 * 8);
- /* this stuff is from visual inspection via bitmapdump.pl */
+ /* This stuff is from visual inspection via bitmapdump.pl.
+ The Apple uses 7-bit-wide fonts. The high bit isn't displayed,
+ and the Apple font has it set on some of the characters. Not
+ sure if it has a meaning on the Apple, but it shows up as a
+ vertical bar at the right edge of the character here. Since we already
+ bit-swapped the font data, clear the 0 bit on the characters
+ where it's needed.
+ */
+ clear0bits(font + 0x018, 8);
+ clear0bits(font + 0x030, 8);
clear0bits(font + 0x1f8, 7);
clear0bits(font + 0x301, 7);
clear0bits(font + 0x308, 8);
@@ -148,7 +270,8 @@ int main(int argc, char **argv) {
clear0bits(font + 0x040, 16);
clear0bits(font + 0x1e8, 8);
- /* fix the vertical bar */
+ /* Fix the vertical bar (put it back to Atari ROM spec), since
+ we're using it as a box-drawing character. */
font[0x3e0] =
font[0x3e1] =
font[0x3e2] =
@@ -165,14 +288,20 @@ int main(int argc, char **argv) {
}
}
+ /* if we got an argument, assume it's -x, and write the .xex
+ header before the font data. */
if(argc > 1) {
xex[0] = xex[1] = 0xff;
xex[2] = FONT_ADDR % 256; xex[3] = FONT_ADDR / 256; /* load address $2000 */
xex[4] = 0xff; xex[5] = 0x23; /* end address $23ff */
write(1, xex, 6);
}
+
+ /* write the 1K font to stdout. */
write(1, font, 1024);
+ /* create LORCHA.DAT and DAMAGED.DAT, which get incbin'ed by
+ draw_lorcha.s. NO error checking here! */
i = open("LORCHA.DAT", O_WRONLY | O_CREAT, 0666);
write(i, shipshape, sizeof(shipshape));
close(i);
diff --git a/gzip2deflate.c b/gzip2deflate.c
deleted file mode 100644
index 7edf6ac..0000000
--- a/gzip2deflate.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// gzip2deflate by Piotr Fusik <fox@scene.pl>
-// http://xasm.atari.org
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef __WIN32
-#include <fcntl.h>
-#endif
-
-static int get_byte(void)
-{
- int b = getchar();
- if (b == EOF) {
- fputs("gzip2deflate: unexpected end of stream\n", stderr);
- exit(1);
- }
- return b;
-}
-
-static void skip_bytes(int n)
-{
- while (--n >= 0)
- get_byte();
-}
-
-static void skip_string(void)
-{
- while (get_byte() != 0);
-}
-
-int main (int argc, char *argv[])
-{
- int flg;
- char buf[8 + 4096];
- size_t len;
-#ifdef __WIN32
- _setmode(_fileno(stdin), _O_BINARY);
- _setmode(_fileno(stdout), _O_BINARY);
-#endif
- if (get_byte() != 0x1f || get_byte() != 0x8b || get_byte() != 8) {
- fputs("gzip2deflate: not a gzip file on stdin\n", stderr);
- return 1;
- }
- flg = get_byte();
- skip_bytes(6);
- if ((flg & 4) != 0) {
- int xlen = get_byte();
- xlen += get_byte() << 8;
- skip_bytes(xlen);
- }
- if ((flg & 8) != 0)
- skip_string();
- if ((flg & 16) != 0)
- skip_string();
- if ((flg & 2) != 0)
- skip_bytes(2);
- /* copy everything except the last 8 bytes */
- len = 0;
- for (;;) {
- len += fread(buf + len, 1, sizeof(buf) - len, stdin);
- if (len != sizeof(buf))
- break;
- fwrite(buf, 1, sizeof(buf) - 8, stdout);
- memcpy(buf, buf + sizeof(buf) - 8, 8);
- len = 8;
- }
- if (ferror(stdin)) {
- fputs("gzip2deflate: read error\n", stderr);
- return 1;
- }
- if (len < 8) {
- fputs("gzip2deflate: unexpected end of stream\n", stderr);
- return 1;
- }
- fwrite(buf, 1, len - 8, stdout);
- return 0;
-}
diff --git a/hex2block.pl b/hex2block.pl
new file mode 100644
index 0000000..2dd90ed
--- /dev/null
+++ b/hex2block.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl -w
+
+$_ = <>;
+chomp;
+for(split /, */, $_) {
+ s/, *//;
+ s/0x//;
+ my $out = sprintf("%08b", hex($_));
+ $out =~ s/1/X/g;
+ $out =~ s/0/ /g;
+ print "$out\n";
+}
diff --git a/lorchatest.c b/lorchatest.c
index 31d7f81..3d6cb45 100644
--- a/lorchatest.c
+++ b/lorchatest.c
@@ -1,6 +1,7 @@
#include <conio.h>
#include <peekpoke.h>
+char turbo;
extern void __fastcall__ damage_lorcha(int which);
extern void __fastcall__ draw_lorcha(int which);
extern void __fastcall__ flash_lorcha(int which);
diff --git a/shipshape.pl b/shipshape.pl
new file mode 100644
index 0000000..89cfacd
--- /dev/null
+++ b/shipshape.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl -w
+
+# draws an ASCII art representation of the lorcha.
+
+use bytes;
+
+if(!@ARGV) {
+ push @ARGV, "LORCHA.DAT";
+}
+
+undef $/;
+$_ = <>;
+@shape = unpack "C*", $_;
+
+open $in, "<taifont" or die $!;
+$f = <$in>;
+close $in;
+
+@out = ();
+
+for($row = 0; $row < 7; $row++) {
+ for($col = 0; $col < 7; $col++) {
+ draw_tile($row, $col);
+ }
+}
+
+for($row = 0; $row < @out; $row++) {
+ for($col = 0; $col < 7; $col++) {
+ print $out[$row][$col];
+ }
+ print "\n";
+}
+
+
+sub draw_tile {
+ my $row = shift;
+ my $col = shift;
+ my $tile = $shape[$row * 7 + $col];
+ my $reverse = 0;
+ my $i;
+ my $j;
+ my $y = $row * 8;
+ #$out[$row][$col] = sprintf(" %03x", $tile);
+
+ if($tile > 127) {
+ $tile -= 128;
+ $reverse = 1;
+ }
+ for($i = 0; $i < 8; $i++) {
+ my $data = sprintf "%08b", ord substr($f, $tile * 8 + $i, 1);
+ if($reverse) {
+ $data =~ s/0/X/g;
+ $data =~ s/1/ /g;
+ } else {
+ $data =~ s/1/X/g;
+ $data =~ s/0/ /g;
+ }
+
+ $out[$y + $i][$col] = $data;
+ }
+}
diff --git a/taifont b/taifont
index 8010d0b..f69d82d 100644
--- a/taifont
+++ b/taifont
Binary files differ
diff --git a/taipan.c b/taipan.c
index 1dba7e1..40fc94c 100644
--- a/taipan.c
+++ b/taipan.c
@@ -46,6 +46,9 @@
/* define this to show frames/scanlines timing for port_stats() */
// #define PORT_STAT_TIMER
+/* define this to test lorcha drawing/damage */
+// #define LORCHA_TEST
+
/**** atari-specific stuff */
/* values returned by cgetc() for backspace/enter/delete keys */
@@ -3392,6 +3395,17 @@ int main(void) {
POKE(731, 1); // disable keyclick on XL/XE (does nothing on 400/800)
POKE(559, 34); // turn on the screen (normal playfield)
+#ifdef LORCHA_TEST
+ for(choice = 0; choice < 10; choice++)
+ draw_lorcha(choice);
+ while(1) {
+ for(choice = 1; choice < 10; choice++) {
+ damage_lorcha(choice);
+ }
+ agetc();
+ }
+#endif
+
#ifdef MCHENRY_TEST
{
while(1) {