diff options
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | help.txt | 3 | ||||
-rw-r--r-- | mkver.pl | 2 | ||||
-rw-r--r-- | newtitle.s | 72 | ||||
-rw-r--r-- | taipan.c | 5 | ||||
-rw-r--r-- | text2screen.pl | 38 |
6 files changed, 122 insertions, 12 deletions
@@ -108,11 +108,17 @@ comptitle.xex: titledata.xex titlecomp.pl comptitle.s.in # 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 ver.dat +newtitle.xex: newtitle.s ver.dat help.dat cl65 -l newtitle.lst -m newtitle.map -o newtitle.xex -t none newtitle.s -ver.dat: mkver.pl - perl mkver.pl $(VERSION) > ver.dat +ver.dat: text2screen.pl + echo "$(VERSION)" | perl text2screen.pl > ver.dat + +help.dat: help.txt text2screen.pl + perl text2screen.pl < help.txt > help.dat + +#ver.dat: mkver.pl +# perl mkver.pl $(VERSION) > ver.dat # The main executable. All the C and asm code goes here, except the init # segment in newtitle.s. @@ -170,7 +176,7 @@ convfont: convfont.c # Obligatory clean and distclean rules. clean: - rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat + rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat help.dat distclean: clean rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz comptitle.s comptitle.dat diff --git a/help.txt b/help.txt new file mode 100644 index 0000000..583833e --- /dev/null +++ b/help.txt @@ -0,0 +1,3 @@ +\B:Change BG Color \E\s\c = more +\T:Change Text Color \E\s\c = more +\A\n\y other key: Start \E\s\c = more @@ -11,7 +11,7 @@ if(length($ver) > 32) { substr($ver, 32) = ""; } -$blanks = 40; +$blanks = 32; for(map { ord } split "", $ver) { my $byte = $_; if($_ < 32) { @@ -19,24 +19,50 @@ screendata = $9000 version: .incbin "ver.dat" +help: + .incbin "help.dat" + +helphitbl: + .byte >version + .byte >help + .byte >(help+32) + .byte >(help+64) + .byte 0 + +helplotbl: + .byte <version + .byte <help + .byte <(help+32) + .byte <(help+64) + .byte 0 + +helpshowing = FR1 + colorchoices: .byte $c0,$10,$00 colorcount = (*-colorchoices)-1 +textchoices: + .byte $0c,$0e,$0a + +textcount = (*-textchoices)-1 + ; executable code here start: ; setup color registers - lda #$c0 ; dark green + lda colorchoices sta COLOR2 ; text bg - lda #$0c ; white - sta COLOR1 + lda textchoices + sta COLOR1 ; text fg ; turn off screen, in case vblank happens while we work lda #0 + sta FR0 sta SDMCTL ; build our display list + ; TODO, for now it's hardcoded (see 'dlist' below) ; wait for the next frame, to avoid graphics glitching jsr wait1jiffy @@ -59,20 +85,53 @@ start: lda #$ff sta CH - ldx #0 ; X = index into color choices + ldx #0 ; X = index into bg color choices + ldy #0 ; Y = index into text color choices ; wait for user to press a key wait4key: lda colorchoices,x sta COLOR2 + lda textchoices,y + sta COLOR1 lda CH cmp #$ff beq wait4key - cmp #39 ; atari logo key - bne keyok + cmp #28 ; Escape key + bne not_esc + + ; show next line of help + stx FR1+1 + ldx helpshowing + inx +loadhelp: + lda helphitbl,x + bne helpok + ldx #0 + beq loadhelp +helpok: + sta help_lms+1 + lda helplotbl,x + sta help_lms + stx helpshowing + ldx FR1+1 + clc + bcc x_ok + +not_esc: + cmp #21 ; B key + bne not_b dex bpl x_ok ldx #colorcount + +not_b: + cmp #45 ; T key + bne keyok + dey + bpl x_ok + ldy #textcount + x_ok: lda #$ff sta CH @@ -111,6 +170,7 @@ dlist: .endrepeat ; .byte $30 ; blank 4 lines to match GR.8 (does it even matter?) .byte $02 | $40 ; LMS, 1 line of GR.0 for the version +help_lms: .word version .byte $41 ; JVB, jump & wait for vblank .word dlist @@ -9,7 +9,7 @@ /* define this for testing sea_battle(). it causes a pirate attack every time you leave port. Don't leave defined for a release!! */ -// #define COMBAT_TEST +#define COMBAT_TEST /* define this to show internals of damage calculation */ // #define DAMAGE_TEST @@ -909,10 +909,13 @@ int sea_battle(int id, int num_ships) { it on the title screen. */ for(i = 0; i < 3; i++) { unsigned char color = PEEK(710) & 0xf0; + unsigned char textcolor = PEEK(709); + POKE(709,0); POKE(710, color | 0x0c); jsleep(10); POKE(710, color & 0xf0); jsleep(10); + POKE(709,textcolor); } fight_stats(num_ships, orders); diff --git a/text2screen.pl b/text2screen.pl new file mode 100644 index 0000000..7fe4849 --- /dev/null +++ b/text2screen.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl -w + +# Turn each line of stdin into one 32-byte line of Atari screen codes, +# truncating or padding with nulls as needed. + +# Input format is plain text, except any character can be preceded +# by a \ to inverse it. No way to get a non-inverse \ in there, sorry. + +use bytes; + +$linelen = $1 || 32; # 32 for narrow playfield, would be 40 for normal. + +while(<>) { + chomp; + + s/\\(.)/chr(ord($1)|0x80)/ge; + + if(length > $linelen) { + warn "$0: line $. truncated to 32 characters!\n"; + substr($_, 32) = ""; + } + + my $blanks = $linelen; + for(map { ord } split "", $_) { + my $byte = $_ & 0x7f; + my $inv = $_ & 0x80; +#warn sprintf("\$_ %02x, \$byte %02x, \$inv %02x", $_, $byte, $inv); + if($byte < 32) { + $byte += 64; + } elsif($byte >= 32 && $byte <= 96) { + $byte -= 32; + } +#warn sprintf("result: %02x", ($byte | $inv)); + print chr($byte | $inv); + $blanks--; + } + print chr(0) x $blanks; +} |