aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile141
-rw-r--r--README.txt113
-rw-r--r--clrtobot.s66
-rw-r--r--draw_lorcha.s4
-rw-r--r--newtitle.pl71
-rw-r--r--newtitle.pngbin0 -> 5666 bytes
-rw-r--r--newtitle.s98
-rw-r--r--oldcurses.c23
-rw-r--r--taipan.c80
9 files changed, 459 insertions, 137 deletions
diff --git a/Makefile b/Makefile
index d5faa1e..92b1611 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,21 @@
+# Makefile for Atari 800 Taipan, by B. Watson
+# Written for GNU make, but seems to work with BSD make (though
+# I don't test BSD make every time I change anything).
+# cl65 binary:
CC=cl65
+
+# System cl65 will compile for. Don't expect this to work if you change it
+# (though possibly atarixl might work, with newer cc65s)
SYS=atari
-# the meaning of the -l flag is different between cc65-2.13.3
-# and the later github cc65, so it's commented out here.
-#COPT=-O -l -T
-COPT=-O -T
+# Optimization flags for cc65.
+#COPT=-Oirs
+COPT=-O
+
+# This is used for embedding the date and git hash in the game binary.
+# It'll appear on the "name your firm" screen.
+VERSION="v0.99alpha-`date +%Y%m%d`-`git rev-parse --short HEAD 2>/dev/null || echo UNKNOWN`"
# for older cc65, we need a custom linker file.
#CFLAGS=-t $(SYS) -C custom.cfg -I. -L. $(COPT)
@@ -13,29 +23,27 @@ COPT=-O -T
# for recent git cc65, we can reserve memory on the command line.
# -D__RESERVED_MEMORY__=1056 because cc65's default end of memory
# is $BC20, and we want it to end just below our font, which starts
-# at $B800.
+# at $B800. cc65's runtime stack starts just below this, and is
+# 2K in size (bottom is at 0xb000).
# -D__SYSTEM_CHECK__=1 stops cl65 from prepending a bit of code that
# checks to make sure there's enough memory. Older cc65 didn't do this,
# and I never missed it.
-CFLAGS=-t $(SYS) -I. -L. -Wl -D__SYSTEM_CHECK__=1 -Wl -D__RESERVED_MEMORY__=1056 $(COPT)
+# The meaning of the -l flag is different between cc65-2.13.3
+# and the later github cc65, so it's been removed here.
+CFLAGS=-t $(SYS) -T -I. -L. -DVERSION=\"$(VERSION)\" -Wl -D__SYSTEM_CHECK__=1 -Wl -D__RESERVED_MEMORY__=1056 $(COPT)
AS=ca65
ASFLAGS=
AR=ar65
-VERSION="v0.99alpha-$(shell date +%Y%m%d)-$(shell git rev-parse --short HEAD 2>/dev/null || echo UNKNOWN)"
+# C compiler for host system. Currently only used for building convfont.
+HOSTCC=gcc
+HOSTCFLAGS=-Wall
# 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.
-# TITLE.DAT is generated by Atari BASIC code in TITLE.LST,
-# except last time I modified it, I exited the emulator without
-# saving the damn BASIC source, so TITLE.LST is outdated. TITLE.DAT
-# is a complete 960-byte dump of GR.0 screen memory, which gets
-# turned into title.xex and prepended to the main .xex. When
-# it loads, it goes straight to screen memory.
-
-# TITLE.DAT, LORCHA.DAT, and PORTSTAT.DAT aren't deleted by a
+# 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
@@ -43,54 +51,113 @@ VERSION="v0.99alpha-$(shell date +%Y%m%d)-$(shell git rev-parse --short HEAD 2>/
# dd if=atariosb.rom of=1 bs=256 skip=8 count=4
# ...where atariosb.rom comes from e.g. the PC-Xformer 2.5 zip file.
+# The game binary:
XEX=taipan.xex
+# Default rule for plain 'make' command is to build the binary.
all: $(XEX)
-ver:
- @echo $(VERSION)
-
-$(XEX): taimain.xex taifont.xex title.xex
- cat taifont.xex title.xex taimain.xex > $(XEX)
-
-title.xex: TITLE.DAT
- perl title.pl TITLE.DAT > title.xex
-
-taimain.xex: taipan.c rand.s draw_lorcha.s taifont.xex
- cl65 -DVERSION=\"$(VERSION)\" --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s
+# I have F10 in my editor bound to 'make test', so:
+test: all
+ atari800 -nobasic $(XEX)
+# old title
+#$(XEX): taimain.xex taifont.xex title.xex
+# cat taifont.xex title.xex taimain.xex > $(XEX)
+
+# The game binary is a multi-part binary load file. This rule
+# depends on all the pieces, and just concatenates them.
+$(XEX): taimain.xex taifont.xex newtitle.xex titledata.xex
+ cat titledata.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
+
+# Bitmap data for the title screen, 256x184 = 47104 pixels, 8 bits
+# per pixel, or 5888 bytes. Displayed in ANTIC mode F (aka GR.8),
+# using GTIA narrow playfield. The original title screen for the Apple
+# is a 280x192 bitmap with a few blank lines at the top & bottom. I
+# squished it horizontally to 256 pixels and got rid of the blank lines,
+# to save load time.
+titledata.xex: newtitle.pl newtitle.png
+ perl newtitle.pl > titledata.xex
+
+# Init segment that loads after the title screen data. It sets up
+# a custom display list and sets the GTIA for narrow playfield,
+# then waits for a keypress. Afterwards, it restores the OS's
+# display list and sets the GTIA back to normal, then exits.
+# Notice this is built with "-t none" instead of "-t atari",
+# since it's a lot easier to homebrew an init segment than it is
+# to get cc65 to build an init segment (would need a custom linker
+# script at least).
+newtitle.xex: newtitle.s
+ cl65 -o newtitle.xex -t none newtitle.s
+
+# 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
+
+# The main executable. All the C and asm code goes here, except the init
+# segment in newtitle.s.
+taimain.xex: taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s clrtobot.s
+ cl65 --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s clrtobot.s
+
+# With newer cc65s, I have to do this to get an assembly listing of just
+# taipan.c. This rule not used as part of the main build, it's only for
+# debugging.
+taipan.lst: taipan.c
+ cl65 --mapfile taipan.map $(CFLAGS) -c -o /dev/null -l taipan.lst -T taipan.c
+
+# 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
+# Not part of the game binary. This just builds the font without the
+# Atari 6-byte binary load header, for eyeballing it in bitmapdump.pl
+# or converting to other formats.
taifont: convfont romfont font
cat romfont font | ./convfont > taifont
-convfont: convfont.c
- gcc -Wall -o convfont convfont.c
+# PORTSTAT.DAT gets incbin'ed directly in portstat.s. It's screen-code
+# data for the static part of the port status screen, which ends up in
+# an array that the C code can memcpy() into screen RAM as needed.
+# This make rule actually runs atari800. For it to work, you'll need
+# the H: device enabled, pointed at the current directory, and set
+# to writable.
+PORTSTAT.DAT: mkportstats.xex
+ atari800 -nobasic mkportstats.xex
+ touch portstat.s
-test: all
- atari800 -nobasic $(XEX)
+# Host tool that builds our custom font from the data ripped out of
+# the Apple version, plus the Atari OS ROM. Also, all the custom
+# characters for the enemy ships are defined here (as hex data. Yes,
+# I converted them manually from eyeballing a screenshot of the Apple
+# combat screen).
+convfont: convfont.c
+ $(HOSTCC) $(HOSTCFLAGS) -o convfont convfont.c
+# Rules for building various file types with the cc65 toolchain.
.s.o:
$(AS) $(ASFLAGS) -o $@ $<
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
+%.xex: %.c
+ $(CC) --mapfile map $(CFLAGS) -o $@ $<
+
+# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont *.xex
+ rm -f *.o *.lst convfont *.xex AUTORUN.SYS
distclean: clean
rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz
-%.xex: %.c
- $(CC) --mapfile map $(CFLAGS) -o $@ $<
-
+# Cruft. Was used for testing the enemy ship animation.
lorchatest: lorchatest.c draw_lorcha.s taifont.xex
cl65 -t atari -O -T -o lorchatest1.xex lorchatest.c draw_lorcha.s
cat taifont.xex lorchatest1.xex > lorchatest.xex
atari800 -nobasic lorchatest.xex
-
-PORTSTAT.DAT: mkportstats.xex
- atari800 -nobasic mkportstats.xex
diff --git a/README.txt b/README.txt
index b65a535..f793dfa 100644
--- a/README.txt
+++ b/README.txt
@@ -1,10 +1,9 @@
Taipan for Atari 800
-This is a work in progress. It's a port of the C version for Linux
-and curses, with the font and screen layout from the original Apple
-II version.
+This is a work in progress. It's a port of the C version for Linux and
+curses, modified to look and play more like the original Apple II version.
-Currently the game is playable but incomplete, and has a few known bugs
+Currently the game is playable and complete, but has a few known bugs
(see "Bugs" section below) and probably a few unknown ones too.
The latest version of the source can be found here:
@@ -35,31 +34,38 @@ What's missing:
in this game). As a side effect of this, the "negative interest"
bug/feature is missing.
-- The title screen isn't as nice as the Apple version.
-
-Building:
-
-Prerequisites are GNU make, cc65 (I use version 2.13.0, any recent one
-should do), perl (any recent-ish version), and a *nix-like environment (I
-use Slackware Linux, if you're on Windows you might try Cygwin or Msys).
-
Build Requirements:
- GNU make. I use version 3.82, but I don't use any of its special
- features, so any version should do. In fact, BSD make might work.
+ features, so any version should do.
- cc65. Originally I used version 2.13.3, and part way through I
- upgraded to a git snapshot dated December 29, 2015.
+ upgraded to a git snapshot dated December 29, 2015. cc65-2.3.13
+ is probably broken right now, but it will be supported again.
+
+- gcc. I use version 4.8.2. Probably any version will do. It's only
+ needed for convfont.c (and there's nothing gcc-specific about it,
+ so really you just need any C compiler).
- perl. I use version 5.18.1, probably any 5.x version will work.
- A UNIX/POSIX environment. At least, you need a 'cat' command and
- a shell that does I/O redirection.
+ a shell that does I/O redirection. Linux, BSD, and Mac OS X should
+ be fine. If you're on Windows, try Cygwin.
-If you plan to edit the title screen or ship graphics, you'll need
+If you plan to edit the port status scrren or ship graphics, you'll need
the Atari800 emulator. It's also handy for actually playing the game,
whether you build it or use the provided binary.
+If you plan to edit the title screen, you'll need the ImageMagick library
+and its perl module (Image::Magick). Also you'll need something that
+can edit PNG images (I use the gimp, anything will do).
+
+Building:
+
+Hopefully you can just type "make" to create the binary. If it doesn't
+work, you're likely missing one or more of the requirements listed above.
+
Running:
The game binary is called "taipan.xex". It's a standard Atari DOS
@@ -74,7 +80,12 @@ floppy disk, you probably want a bootable DOS disk with Taipan renamed
to AUTORUN.SYS.
It's also possible to run Taipan in an emulator, such as Atari800,
-Atari++, or Altirra.
+Atari++, or Altirra. For Atari800, you should be able to do this:
+
+atari800 -nobasic taipan.xex
+
+Even though the title screen says to press Escape to start, you can
+really press any key to start the game.
License:
@@ -82,13 +93,13 @@ The legal status of this is quite murky. The original game is still
copyrighted, though quite a few clones of it have been made for various
platforms over the years with no complaints from the copyright holder.
-This Atari build includes font data ripped straight from the original
-Apple game, plus more font data ripped from the Atari 800's OS ROM.
+This Atari port includes font and graphics data ripped straight from
+the original Apple game, plus more font data ripped from the Atari 800's
+OS ROM.
-The Linux port of taipan, according to its .lsm file, is GPL. My C code
-is definitely a derivative work, so it's GPL also. The assembly code and
-title/ship graphics are my own work, and I release them under the GPL
-(version 2).
+The Linux port of taipan, according to its .lsm file, is GPL. My C code is
+definitely a derivative work, so it's GPL also. The assembly code and ship
+graphics are my own work, and I release them under the GPL (version 2).
Notes:
@@ -112,30 +123,11 @@ is a real issue (it's not like Taipan is a fast-paced arcade game).
Bugs! At least these:
-- Can't change orders in mid-battle. Whatever you pick for your first
- turn, you're stuck with. Not sure why yet.
-
-- The damage calculation is messed up. You can get killed in your first
- battle, one shot can occasionally destroy a 100% healthy ship.
-
-- When the lower-left ship get sunk, a little graphical "turd" gets
- left behind.
-
-- This may or may not be fixed: Occasionally the font gets partly
- corrupted in memory, by some rogue pointer or cc65 bug. The usual
- symptom is that the vertical bars of the "box" in the port status
- display get messed up. Still investigating this one. It ain't like
- the Atari has valgrind :)
-
- The "negative interest" bug is currently missing, due to using
unsigned values for debt. Plus, it's cheating. It'll get added back when
I either start using big numbers (floats or 64-bit ints or whatever),
or just decide to live with the limits of 32-bit ints.
-- The retirement display still uses ASCII | and - to draw a box. They
- should be using ATASCII line-drawing characters instead (like the port
- status does).
-
- Retirement score calculations are a bit off, due to using integer math.
- Not really a bug, but, the interest calculations for debt and the bank
@@ -148,10 +140,25 @@ Bugs! At least these:
- A few things in the screen layout are slightly off comapred to
the Apple version. Would really like to get it exact.
-- The cursor isn't getting disabled in a few places, and at some
- prompts it's not visible until you actually type something.
+- Control and graphics characters should be ignored at all input
+ prompts. Inverse video input should either be converted to
+ normal, or completely ignored.
+
+- Pressing either the inverse or caps-lock key at a timed prompt stops
+ the timer from ever expiring (until you press a regular key). This
+ can be fixed in timed_getch().
-- Escape key should actually work, when typing at prompts.
+- The 'Please limit your firm name to 22 characters' prompt is missing.
+ The Apple version actually allows you to type all you want until you
+ press Enter. This port works like the Linux version: as soon as you type
+ the 22nd character, it acts like you pressed Enter after it. A good
+ compromise might be to allow up to 22 characters, then any keypress
+ other than backspace or enter will show the "please limit" prompt.
+
+- Damaged ship graphics need work. I don't have enough unused font
+ characters to duplicate the Apple bitmapped graphics exactly, plus
+ each damage location must fit entirely within a character cell... but
+ a couple of my damaged sections are pretty hokey-looking.
- fancy_numbers() maybe should round when it's showing a decimal point.
If you have e.g. 1,190,000, that should show as 1.2 million, not 1.1...
@@ -182,17 +189,17 @@ and it complicates the code more than I want to deal with. Also #10
will probably not happen (to me, the slow ship-sinking of the Apple
version is annoying anyway).
-Right now, items 1, 2, 5, 7, and 9 are implemented Apple-style; and 3,
-6, 8, 10 are Linux-style. 4 is kinda halfway between (the graphics are
-6 of the enemy ships rather than a hi-res single ship).
+Right now, items 1, 2, 4, 5, 7, 8, and 9 are implemented Apple-style;
+and 3, 6, 10 are Linux-style.
Other things that need doing to the code:
-- Size optimization. Right now, the executable is almost 32K of code. I'd
+- Size optimization. Right now, the executable is almost 29K of code. I'd
like it to at least fit on a 16K cartridge. A lot of the C code is
redundant, and some things can be rewritten in asm if need be. I've
already eliminated all uses of printf() and its ilk, which removed 2K
- of library code from the executable.
+ of library code from the executable. Removing all other stdio.h functions
+ saved another 1/2K or so.
- In aid of the above: split splash_intro(), cash_or_guns(), name_firm() into
separate .xex segments. Have to write a linker script to generate an
@@ -216,12 +223,6 @@ Other things that need doing to the code:
- Temporarily add a "god mode" to allow me to test situations that would take
a lot of regular gameplay to reach.
-- The title screen could be rearranged a bit and use a custom display list
- to put all the text on top and bottom, with a GR.8 ship in the
- middle. The Apple version's ship is a 176x145 bitmap, 22 bytes wide,
- or 3190 bytes total on disk. Might use a narrow playfield to display
- it? Or use GR.15 for a greyscale (greenscale) image?
-
Future Ideas:
I may do a "Taipan Plus" at some point. The regular Taipan game will be
diff --git a/clrtobot.s b/clrtobot.s
new file mode 100644
index 0000000..72f97e5
--- /dev/null
+++ b/clrtobot.s
@@ -0,0 +1,66 @@
+
+
+ .include "atari.inc"
+ .export _clrtobot, _clrtoeol, _clrtoline
+
+ .import mul40 ; from cc65's runtime
+ .importzp tmp3 ; ditto
+ .import bump_destptr ; these two are
+ .importzp destptr ; from draw_lorcha.s
+
+; void clrtobot(void);
+; void clrtoeol(void);
+; void clrtoline(unsigned char line);
+
+; this stuff doesn't disturb conio's (and the OS's) idea of the
+; current cursor position. It's *way* faster than writing them in
+; C in terms of cclear() (which uses one cputc() call per blank).
+
+_clrtobot: ; same as clrtoline(24);
+ lda #24
+ bne _clrtoline
+
+_clrtoeol:
+ lda ROWCRS
+ ; fall through to _clrtoline
+
+_clrtoline:
+ sta tmp3 ; stash our arg
+ lda #0
+ sta OLDCHR ; stop conio from redrawing stuff after we clear it
+
+ ; setup destptr to start of current line, NOT
+ ; current cursor position.
+ lda ROWCRS
+ jsr mul40 ; AX = A*40 (addr of start-of-row)
+ clc
+ adc SAVMSC ; add to screen pointer
+ sta destptr
+ txa
+ adc SAVMSC+1
+ sta destptr+1
+
+ ; X = current row, Y = current column. Stop clearing a line when Y == 40,
+ ; we're done when X == 24. Apologies, the names X and Y are backwards
+ ; compared to proper Cartesian coordinates.
+ ldx ROWCRS
+ ldy COLCRS
+ lda #0
+
+clrloop:
+ sta (destptr),y ; blank a character (A == 0, screen code for a space)
+ iny
+ cpy #40
+ bne clrloop
+ ldy #0
+ inx
+ cpx tmp3
+ bcs done
+
+ jsr bump_destptr
+ lda #0
+ tay
+ beq clrloop
+
+done:
+ rts
diff --git a/draw_lorcha.s b/draw_lorcha.s
index 2abd196..ae82bd2 100644
--- a/draw_lorcha.s
+++ b/draw_lorcha.s
@@ -28,6 +28,10 @@ lorcha_pos_hi:
lcount = $d8
which = $d9
+; clrtobot.s needs these:
+ .exportzp destptr
+ .export bump_destptr
+
; Our lorcha is a 7x7 block of ATASCII characters. We're storing
; directly to screen RAM, so we use 'internal' codes.
; To edit the graphics, see shipshape[] in convfont.c.
diff --git a/newtitle.pl b/newtitle.pl
new file mode 100644
index 0000000..8daae62
--- /dev/null
+++ b/newtitle.pl
@@ -0,0 +1,71 @@
+#!/usr/bin/perl -w
+
+use bytes;
+use Image::Magick;
+use Data::Dumper;
+my $img = new Image::Magick;
+$img->read("newtitle.png");
+@pixels = $img->GetPixels(
+ width => 256,
+ height => 184,
+ x => 0,
+ y => 0,
+ map => 'G',
+);
+#print Dumper \@pixels;
+#print "got " . @pixels . " pixels\n";
+
+for $y (0..183) {
+ for $b (0..31) {
+ my $byte = 0;
+ for($x = 0; $x < 8; $x++) {
+ $byte <<= 1;
+ $byte |= ($pixels[$y * 256 + $b * 8 + $x] > 0);
+ }
+ push @bytes, $byte;
+ }
+}
+
+# we got over 4K of data, so the display list will have to
+# have an LMS for the 2nd half. Since we're using narrow
+# playfield mode, we don't have to leave a hole in the data,
+# just make sure it gets loaded to an address aligned to a
+# 32-byte boundary. I choose $3000 for now.
+$load = 0x3000;
+$len = scalar @bytes;
+$end = $load + $len - 1;
+print chr(0xff), chr(0xff);
+print chr($load % 256);
+print chr(int($load / 256));
+print chr($end % 256);
+print chr(int($end / 256));
+print chr($_) for @bytes;
+
+
+#print scalar @bytes;
+
+#for $y (0..183) {
+# for $b (0..31) {
+# my $data = sprintf "%08b", $bytes[$y * 32 + $b];
+# $data =~ s,0, ,g;
+# $data =~ s,1,X,g;
+# print $data;
+# }
+# print "\n";
+#}
+
+# we might try a crude form of RLE, but not right now
+#$run = 0;
+#for(@bytes) {
+# if($_ == 0) {
+# $run++;
+# } else {
+# if($run > 1) {
+# print "run of $run 0 bytes\n";
+# $total += $run;
+# }
+# $run = 0;
+# }
+#}
+#
+#print "total $total\n";
diff --git a/newtitle.png b/newtitle.png
new file mode 100644
index 0000000..0ee6621
--- /dev/null
+++ b/newtitle.png
Binary files differ
diff --git a/newtitle.s b/newtitle.s
new file mode 100644
index 0000000..d62a40a
--- /dev/null
+++ b/newtitle.s
@@ -0,0 +1,98 @@
+; this file needs to be assembled with:
+; cl65 -o newtitle.xex -t none newtitle.s
+; It contains only an init routine, no run address.
+
+ .include "atari.inc"
+
+ ; where our screen was loaded (see newtitle.pl)
+screendata = $3000
+
+ ; homebrew atari xex header
+ .word $ffff
+ .word start
+ .word end-1
+
+ .org $5000 ; anywhere that doesn't step on the title data at
+ ; $3000, and doesn't cross a 1K boundary (since there's
+ ; a display list included here)
+
+ ; executable code here
+start:
+ ; setup color registers
+ lda #$c0 ; dark green
+ sta COLOR2 ; text bg
+ lda #$0c ; white
+ sta COLOR1
+
+ ; turn off screen, in case vblank happens while we work
+ lda #0
+ sta SDMCTL
+
+ ; setup our display list
+ lda SDLSTL
+ sta FR0
+ lda SDLSTH
+ sta FR0+1
+ lda #<dlist
+ sta SDLSTL
+ lda #>dlist
+ sta SDLSTH
+
+ ; switch to narrow playfield, enable screen
+ lda #$21
+ sta SDMCTL
+
+ ; clear any keypress that happened during loading
+ lda #$ff
+ sta CH
+
+ ; wait for user to press a key
+wait4key:
+ lda CH
+ cmp #$ff
+ beq wait4key
+
+ ; eat the keypress
+ lda #$ff
+ sta CH
+
+ ; restore OS's display list
+ lda #0
+ sta SDMCTL ; disable screen again
+ lda FR0
+ sta SDLSTL
+ lda FR0+1
+ sta SDLSTH
+
+ ; switch to normal playfield, enable screen
+ lda #$22
+ sta SDMCTL
+
+ rts ; return to DOS
+
+ ; display list here
+dlist:
+ .byte $70 ; 24 scanlines of blanks
+ .byte $70
+ .byte $70
+ .byte $30 ; 4 more since image is only 184 lines tall
+
+ .byte $0f | $40 ; LMS, BASIC mode 8
+ .word screendata
+ .repeat 127
+ .byte $0f ; 127 more scanlines of mode 8
+ .endrepeat
+
+ .byte $0f | $40 ; Hit 4K boundary, LMS again
+ .word screendata+$1000
+ .repeat 55
+ .byte $0f ; 55 more scanlines of mode 8
+ .endrepeat
+ .byte $30 ; blank 4 lines to match GR.8 (does it even matter?)
+ .byte $41 ; JVB, jump & wait for vblank
+ .word dlist
+
+end:
+ .word INITAD
+ .word INITAD+1
+ .word start
diff --git a/oldcurses.c b/oldcurses.c
index 44ff6b3..c8702d5 100644
--- a/oldcurses.c
+++ b/oldcurses.c
@@ -75,6 +75,29 @@ void clrtobot() {
gotoxy(oldx, oldy);
}
+/* TODO: rewrite in asm */
+void clrtobot() {
+ unsigned char rows, cols, y, oldx, oldy;
+ oldx = wherex();
+ oldy = wherey();
+ screensize(&cols, &rows);
+ cclear(cols - wherex()); /* leaves cursor at start of next line */
+ for(y = wherey(); y < rows; y++)
+ cclearxy(0, y, cols);
+ gotoxy(oldx, oldy);
+}
+
+/* TODO: rewrite in asm */
+void clrtoeol() {
+ unsigned char cols, rows, oldx, oldy;
+ oldx = wherex();
+ oldy = wherey();
+ screensize(&cols, &rows);
+ cclear(cols - wherex());
+ gotoxy(oldx, oldy);
+}
+
+
/* one-to-one mapping between some of the conio API and the curses one */
#define clear() clrscr()
#define printw cprintf
diff --git a/taipan.c b/taipan.c
index 2e57671..27f2adb 100644
--- a/taipan.c
+++ b/taipan.c
@@ -2,6 +2,7 @@
#include <time.h>
#include <stdlib.h>
// #include <stdio.h> // finally got rid of it!
+#include <ctype.h>
#include <string.h>
#include <peekpoke.h>
@@ -55,53 +56,38 @@ extern void __fastcall__ jsleep(unsigned int j);
extern unsigned int __fastcall__ randi(void);
extern unsigned long __fastcall__ randl(void);
-char port_stat_dirty = 1;
+/* defined in portstat.s, this is the contents of PORTSTAT.DAT.
+ used to quickly redraw the port stats screen.
+ If ever PORTSTAT.DAT needs to be regenerated, use mkportstats.c */
extern const char *port_stat_screen;
-/**** End of atari-specific stuff */
+/* boolean, whether or not port_stats() needs to redraw the
+ static parts of the port stats screen (by copying
+ port_stat_screen into screen RAM) */
+char port_stat_dirty = 1;
-unsigned long randclamp(unsigned long clamp) {
- return randl() % clamp;
-}
+/* asm curses/conio funcs from clrtobot.s. Old C versions moved to
+ oldcurses.c for reference. */
+extern void clrtobot();
+extern void clrtoeol();
-/* TODO: rewrite in asm */
-void clrtobot() {
- unsigned char rows, cols, y, oldx, oldy;
- oldx = wherex();
- oldy = wherey();
- screensize(&cols, &rows);
- cclear(cols - wherex()); /* leaves cursor at start of next line */
- for(y = wherey(); y < rows; y++)
- cclearxy(0, y, cols);
- gotoxy(oldx, oldy);
-}
-/* TODO: rewrite in asm */
-void clrtoeol() {
- unsigned char cols, rows, oldx, oldy;
- oldx = wherex();
- oldy = wherey();
- screensize(&cols, &rows);
- cclear(cols - wherex());
- gotoxy(oldx, oldy);
-}
+/**** End of atari-specific stuff */
-/* TODO: rewrite in asm */
-int lc(int a) {
- if(a >= 'A' && a <= 'Z') a ^= 0x20;
- return a;
+unsigned long randclamp(unsigned long clamp) {
+ return randl() % clamp;
}
-/* TODO: rewrite in asm */
/* wrapper for cgetc() that returns letters as lowercase only
(and everything else normally). Avoids a bunch of reduntant
if(foo == 'A' || foo == 'a') tests. */
-int lcgetch() {
- return lc(cgetc());
+int lcgetc() {
+ return tolower(cgetc());
}
/* print 'count' spaces, but leave the cursor where it was.
doesn't work if the cursor wraps to the next line!
+ TODO: rewrite in asm.
*/
void cblank(unsigned char count) {
char oldx = wherex();
@@ -121,7 +107,7 @@ void backspace() {
#define GENERIC 1
#define LI_YUEN 2
-void splash_intro(void);
+// void splash_intro(void);
int get_one(void);
unsigned long get_num(int maxlen);
void name_firm(void);
@@ -312,8 +298,7 @@ void new_gun(void)
time = ((year - 1860) * 12) + month;
amount = randi()%(1000 * (time + 5) / 6) + 500;
- if ((cash < amount) || (hold < 10))
- {
+ if((cash < amount) || (hold < 10)) {
return;
}
@@ -523,7 +508,7 @@ int sea_battle(int id, int num_ships) {
(input != 'r') &&
(input != 't'))
{
- input = lcgetch();
+ input = lcgetc();
}
gotoxy(0, 3);
clrtoeol();
@@ -716,7 +701,7 @@ int sea_battle(int id, int num_ships) {
(choice != 'g') &&
(choice != '*'))
{
- choice = lc(get_one());
+ choice = tolower(get_one());
}
if(choice == 'o') {
@@ -962,7 +947,7 @@ int get_one(void)
// is printed... can't use cputc() here as it escapes the
// character (prints graphics char instead of actually backspacing)
- /* new: */
+ /* these 2 lines make the cursor visible */
cursor(1);
cblank(1);
@@ -971,7 +956,6 @@ int get_one(void)
if (((input == BKSP) || (input == 127)) && (character == 0))
{
} else if ((input == BKSP) || (input == 127)) {
- // putchar(BKSP);
backspace();
character--;
} else if (character >= 1) {
@@ -1008,7 +992,6 @@ unsigned long get_num(int maxlen)
if (((input == BKSP) || (input == 127)) && (character == 0))
{
} else if ((input == BKSP) || (input == 127)) {
- // putchar(BKSP);
backspace();
number[character] = '\0';
character--;
@@ -1235,13 +1218,13 @@ void port_stats(void)
revers(0);
gotoxy(29, 12);
+ clrtoeol();
i = status / 20;
if (i < 2) {
revers(1);
}
cputs(st[i]);
cputc(':');
- cblank(3);
cprintulong(status);
revers(0);
@@ -1265,6 +1248,7 @@ void port_stats(void)
that I can draw a nice ATASCII trading ship. But for
now I'll just draw 6 of the lorchas.
*/
+#if 0
void splash_intro(void)
{
int i;
@@ -1290,6 +1274,7 @@ void splash_intro(void)
flushinp();
return;
}
+#endif
void mchenry(void)
{
@@ -2205,7 +2190,14 @@ void name_firm(void)
int input,
character = 0;
+ cursor(0);
clrscr();
+ gotoxy(0,23);
+#ifdef VERSION
+ cputs(VERSION);
+#else
+ cputs("(no version info)");
+#endif
chlinexy(1, 7, 38);
chlinexy(1, 16, 38);
@@ -2271,7 +2263,7 @@ void buy(void)
cputs("What do you wish me to buy, Taipan? ");
/* TODO: buy() sell() and throwing cargo, common code in get_item() */
- choice = lc(get_one());
+ choice = tolower(get_one());
if(choice == 'o') {
choice = 0;
break;
@@ -2364,7 +2356,7 @@ void sell(void) {
cputs("What do you wish me to sell, Taipan? ");
/* TODO: buy() sell() and throwing cargo, common code in get_item() */
- choice = lc(get_one());
+ choice = tolower(get_one());
if(choice == 'o') {
choice = 0;
break;
@@ -2491,7 +2483,7 @@ int main(void) {
atari_text_setup();
initrand();
- splash_intro();
+ // splash_intro();
name_firm();
cash_or_guns();
set_prices();