From 7604df70d7ca9de06c5181b48ab7fc95d08a46a8 Mon Sep 17 00:00:00 2001
From: "B. Watson" <yalhcru@gmail.com>
Date: Sun, 11 Apr 2021 14:24:50 -0400
Subject: Save 33 bytes

---
 PORTSTAT.DAT  | Bin 600 -> 560 bytes
 mkportstats.c |  30 ++++++++++++++++++++++++++----
 taipan.c      |   4 +++-
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/PORTSTAT.DAT b/PORTSTAT.DAT
index 10c9f4a..ee4e3c1 100644
Binary files a/PORTSTAT.DAT and b/PORTSTAT.DAT differ
diff --git a/mkportstats.c b/mkportstats.c
index d4358cc..1287c6c 100644
--- a/mkportstats.c
+++ b/mkportstats.c
@@ -2,6 +2,15 @@
 #include <stdio.h>
 #include <peekpoke.h>
 
+#define FILENAME "H:PORTSTAT.DAT"
+
+/* 0-based. Set to 1 because we don't include the top
+   row (all spaces anyway) */
+#define TOPLINE 1
+
+/* Used to be 15, taipan.c now draws the horizontal line itself */
+#define LINES 14
+
 void port_stats() {
 	cursor(0);
 	clrscr();
@@ -42,14 +51,27 @@ void port_stats() {
 	cputsxy(29, 11, "Ship Status");
 	cputsxy(0, 14, "Cash: ");
 	cputsxy(20, 14, "Bank: ");
+	gotoxy(0, 17);
+}
+
+void finish(void) {
+	printf("You can exit the emulator now.\n");
+	while(1)
+		;
 }
 
 int main(void) {
-	char *screenmem = PEEK(88)+256*PEEK(89);
-	FILE *f = fopen("H:PORTSTAT.DAT", "wb");
+	char *screenmem = (char *) (PEEK(88)+256*PEEK(89));
+	FILE *f = fopen(FILENAME, "wb");
+	if(!f) {
+		printf("\nCan't create " FILENAME "\n");
+		printf("Is the H: device configured?\n");
+		finish();
+	}
 	port_stats();
-	fwrite(screenmem + 40, 40, 15, f);
+	fwrite(screenmem + (40 * TOPLINE), 40, LINES, f);
 	fclose(f);
-	cgetc();
+	printf("\n" FILENAME " written\n");
+	finish();
 	return 0;
 }
diff --git a/taipan.c b/taipan.c
index ee525dd..2350615 100644
--- a/taipan.c
+++ b/taipan.c
@@ -1694,8 +1694,10 @@ void port_stats(void) {
 			cc65 won't use. When it's time to print it, it'll get copied
 			into *SAVMSC. */
 		redraw_port_stat();
+		gotox0y(15);
+		chline(40);
 
-		gotoxy(0, 0);
+		gotox0y(0);
 		cspaces(firmpos);
 		// cputs("Firm: ");
 		cprint_firm_colon();
-- 
cgit v1.2.3