mist: add books on bookshelf

This commit is contained in:
Vince Weaver 2020-04-08 12:02:03 -04:00
parent 4a446c36aa
commit 4d4ece23f4
12 changed files with 402 additions and 6 deletions

View File

@ -2,7 +2,7 @@ include ../Makefile.inc
CFLAGS = -g -Wall -O2 CFLAGS = -g -Wall -O2
all: png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 all: text2gr png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96
### ###
@ -12,6 +12,13 @@ loadpng.o: loadpng.c loadpng.h
rle_common.o: rle_common.c rle_common.h rle_common.o: rle_common.c rle_common.h
$(CC) $(CFLAGS) -c rle_common.c $(CC) $(CFLAGS) -c rle_common.c
###
text2gr: text2gr.o
$(CC) $(LFLAGS) -o text2gr text2gr.o
text2gr.o: text2gr.c
$(CC) $(CFLAGS) -c text2gr.c
### ###

150
gr-utils/text2gr.c Normal file
View File

@ -0,0 +1,150 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <getopt.h>
/* Converts text to a GR image */
/* Why? On Apple II GR is just a form of text */
/* Maybe it will compress better */
static int loadtext(char *filename, unsigned char **image_ptr,
int *xsize, int *ysize, int inverse) {
FILE *infile;
char string[BUFSIZ];
char *result;
unsigned char *image;
int width,height,x,y;
x=0; y=0;
width=40;
height=24;
*xsize=40;
*ysize=24;
image=calloc(width*height,sizeof(unsigned char));
/* set to plain spaces */
if (inverse) {
memset(image,' '&0x3f,width*height);
}
else {
memset(image,' '|0x80,width*height);
}
infile=fopen(filename,"rb");
if (infile==NULL) {
fprintf(stderr,"Error, could not open %s!\n",filename);
return -1;
}
while(1) {
result=fgets(string,BUFSIZ,infile);
if (result==NULL) break;
if (string[0]=='#') continue;
// printf("%s",string);
for(x=0;x<width;x++) {
if ((string[x]=='\n') || (string[x]==0)) break;
if (inverse) {
if (string[x]=='~') {
image[(y*width)+x]=' '|0x80;
}
else {
image[(y*width)+x]=string[x]&0x3f;
}
}
else {
image[(y*width)+x]=string[x]|0x80;
}
}
y++;
if (y>=height) break;
}
fclose(infile);
*image_ptr=image;
return 0;
}
static int usage(char *name) {
fprintf(stderr,"Usage:\t%s INFILE OUTFILE\n\n",name);
exit(-1);
}
int main(int argc, char **argv) {
int row=0;
int col=0;
int x,c;
unsigned char out_buffer[1024];
unsigned char *image;
int xsize,ysize;
FILE *outfile;
int inverse=0;
opterr=0;
while ((c=getopt(argc,argv,"i"))!=-1) {
switch(c) {
case 'i':
inverse=1;
break;
default:
usage(argv[0]);
break;
}
}
if (argc-optind < 2) {
usage(argv[0]);
}
outfile=fopen(argv[optind+1],"w");
if (outfile==NULL) {
fprintf(stderr,"Error! Could not open %s\n",argv[2]);
exit(-1);
}
if (loadtext(argv[optind],&image,&xsize,&ysize,inverse)<0) {
fprintf(stderr,"Error loading text!\n");
exit(-1);
}
fprintf(stderr,"Loaded text %d by %d\n",xsize,ysize);
short gr_offsets[]={
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
};
memset(out_buffer,0,1024);
for(row=0;row<24;row++) {
for(col=0;col<40;col++) {
out_buffer[(gr_offsets[row]-0x400)+col]=image[row*xsize+col];
}
}
for(x=0;x<1024;x++) fputc( out_buffer[x],outfile);
fclose(outfile);
return 0;
}

View File

@ -80,6 +80,7 @@ OCTAGON: octagon.o
octagon.o: octagon.s zp.inc hardware.inc common_defines.inc \ octagon.o: octagon.s zp.inc hardware.inc common_defines.inc \
graphics_octagon/octagon_graphics.inc \ graphics_octagon/octagon_graphics.inc \
books/octagon_books.inc \
common_sprites.inc \ common_sprites.inc \
leveldata_octagon.inc \ leveldata_octagon.inc \
letter_cat.s \ letter_cat.s \

30
mist/books/Makefile Normal file
View File

@ -0,0 +1,30 @@
#include ../Makefile.inc
PNG2RLE = ../../gr-utils/png2rle
PNG2GR = ../../gr-utils/png2gr
TEXT2GR = ../../gr-utils/text2gr
LZSA = ~/research/lzsa/lzsa/lzsa
all: octagon_books.inc
####
octagon_books.inc: \
channelwood.lzsa stoneship.lzsa mechanical.lzsa selenitic.lzsa
echo "channelwood_book_lzsa: .incbin \"channelwood.lzsa\"" > octagon_books.inc
echo "stoneship_book_lzsa: .incbin \"stoneship.lzsa\"" >> octagon_books.inc
echo "mechanical_book_lzsa: .incbin \"mechanical.lzsa\"" >> octagon_books.inc
echo "selenitic_book_lzsa: .incbin \"selenitic.lzsa\"" >> octagon_books.inc
%.gr: %.book
$(TEXT2GR) -i $< $@
%.lzsa: %.gr
$(LZSA) -r -f2 $< $@
####
clean:
rm -f *~ *.o *.lst *.gr *.lzsa octagon_books.inc

View File

@ -0,0 +1,25 @@
#0 1 2 3
#12345678901234567890123457890123456789
:
-- I HAVE CALLED :
THIS AGE CHANNELWOOD: \
WATER COVERS THE AGE: []=====[]/ ()
THERE ARE MONKEYS : :: / []/
LIVING IN TREE FORTS: []---()\\ ()
THEY WORSHIP ME FOR : // \\ () ::
SOME REASON. AN OLD : () \\ :: ::
HUMAN IS THERE TOO. : :: ()==[]==[]
HE TELLS ME ONCE : () //
THERE WERE MORE BUT : \\ //
A BIG EARTHQUAKE : []
FLOODED THINGS. : ::
THEN HE DIED. : ()
:
I STAYED 3 MONTHS. :
I COULDN'T GET :
CATHERINE TO VISIT. :
MY SONS LIKE IT HERE:
WILL IT BE OK TO :
LET THEM REMAIN :
UNSUPERVISED? :
:

View File

@ -0,0 +1,25 @@
#0 1 2 3
#12345678901234567890123457890123456789
:
-- THE SKY IS DARK : /=/
GRAY WITH INCESSANT : ::
DISTANT LIGHTNING. : /----\
AN OLD MAN TOLD OF : / \
AN ANCIENT CITY : / \:/ \ *
DESTROYED BY EASTERN: ==: -*-) :==*
INVADERS IN SHIPS. : \ /:\ / *
THE INVADERS WILL : \ /
RETURN. : \----/
:
I BROUGHT MY SONS :
AND WE WILL BUILD : \============
A FORTRESS. : : : )) /
: : -*- )) \
-- THE FORTRESS HELD: : : )) /
OFF THE INVADERS OF : : )) \
THIS MECHANICAL AGE : :============
BUT THE SKY REMAINS : /
GRAY AS THE ENEMY : INSIGNIA OF
REMAINS. MY SONS : BLACK SHIP
LONG FOR THE BLUE :
SKY OF MYST. :

25
mist/books/selenitic.book Normal file
View File

@ -0,0 +1,25 @@
#0 1 2 3
#12345678901234567890123457890123456789
:
-- I DO NOT FEEL : _______/===\
ALTOGETHER WELCOME : < : [] >
ON THIS EMPTY SILENT: -:-----\===/
NEW WORLD. SUNSET :
IS BEAUTIFUL AND RED: ********** E
: ~~~~****** D# 3
I HAD TO LEAVE DUE : ********** D
TO HORRIBLE BALLS OF: ~~~~****** C#
FLAME FALLING FROM : ********** C 2
THE SKY. : ********** B
: ~~~~****** A#
THE LANDSCAPE WAS : ********** A
ALTERED BY THE : ~~~~****** G#
METEOR SHOWER. : ********** G
I HAVE FOUND A GIANT: ~~~~****** F#
CHASM. : ********** F 4
: ********** E
FOR SOME REASON MANY: ~~~~****** D#
OF MY NOTES HAVE : ********** D
FADED AWAY. : ~~~~****** C#
: ********** C 1
:

25
mist/books/stoneship.book Normal file
View File

@ -0,0 +1,25 @@
#0 1 2 3
#12345678901234567890123457890123456789
:
-- EMMIT, BRANCH, : CONSTELLATIONS
AND WILL LIVE ON : O
THIS NEW WORLD. I : * -:-
TOLD THEM I WOULD : * . * \:/
MAKE A SURPRISING :
CHANGE BEFORE I : . ** . <(O)>
RETURN. :
: . . M
-- I DO NOT KNOW : * : :/\
WHAT HAPPENED. I WAS:
EXPERIMENTING WITH : .: \O/
THE ART, ATTEMPTING : :: >O<
TO WRITE A SHIP INTO:
THE AGE BUT IT WAS : .:. +
GRIPPED BY THE ROCK : ^
AND SPLIT IN TWO. : .:^ >>--->
:
I HAVE MAPPED THE : * * -\
CONSTELLATIONS AND : : * ()
PLAN TO BUILD A :
LIGHTHOUSE. : * * _/\_
: .. * \__/

View File

@ -1,7 +1,6 @@
5 HOME 5 HOME
10 PRINT " LOADING MIST V0.81" 10 PRINT "LOADING MIST V0.82"
20 PRINT 20 PRINT:PRINT
30 PRINT:PRINT:PRINT:PRINT
40 PRINT "CONTROLS: ARROWS OR WASD" 40 PRINT "CONTROLS: ARROWS OR WASD"
50 PRINT " ENTER MOVES/ACTION" 50 PRINT " ENTER MOVES/ACTION"
60 PRINT:PRINT 60 PRINT:PRINT

View File

@ -253,7 +253,10 @@ location12:
.word $0000 ; east bg .word $0000 ; east bg
.word $0000 ; west bg .word $0000 ; west bg
.byte BG_NORTH .byte BG_NORTH
.byte $ff .byte DIRECTION_N ; special exit
.byte 6,34 ; special x
.byte 2,46 ; special y
.word read_book-1 ; special function
; OCTAGON_TOWER_HALL1 -- hallway to tower ; OCTAGON_TOWER_HALL1 -- hallway to tower
location13: location13:

View File

@ -279,7 +279,9 @@ done_goto:
; linking books ; linking books
; letters ; books
.include "books/octagon_books.inc"
.include "common_sprites.inc" .include "common_sprites.inc"

View File

@ -1,3 +1,107 @@
;================================
; read a book on the shelf
;================================
read_book:
bit KEYRESET
bit SET_TEXT
ldx XPOS
ldy YPOS
cpy #18
bcc top_shelf
cpy #32
bcc middle_shelf
bcs bottom_shelf
top_shelf:
cpx #12
bcc read_burnt_book
cpx #20
bcc read_channelwood
cpx #28
bcc read_burnt_book
bcs read_stoneship
middle_shelf:
cpx #13
bcc read_burnt_book
cpx #18
bcc read_selenitic
cpx #30
bcc read_burnt_book
bcs read_fireplace
bottom_shelf:
cpx #8
bcc read_burnt_book
cpx #15
bcc read_mechanical
bcs read_burnt_book
read_burnt_book:
jmp all_done_book
read_fireplace:
; FIXME
jmp all_done_book
read_selenitic:
lda #<selenitic_book_lzsa
sta LZSA_SRC_LO
iny
lda #>selenitic_book_lzsa
jmp load_the_book
read_stoneship:
lda #<stoneship_book_lzsa
sta LZSA_SRC_LO
iny
lda #>stoneship_book_lzsa
jmp load_the_book
read_mechanical:
lda #<mechanical_book_lzsa
sta LZSA_SRC_LO
iny
lda #>mechanical_book_lzsa
jmp load_the_book
read_channelwood:
lda #<channelwood_book_lzsa
sta LZSA_SRC_LO
iny
lda #>channelwood_book_lzsa
load_the_book:
sta LZSA_SRC_HI
lda #$c ; load to page $c00
jsr decompress_lzsa2_fast
jsr gr_copy_to_current
jsr page_flip
wait_done_book:
lda KEYPRESS
bpl wait_done_book
bit KEYRESET
all_done_book:
bit SET_GR
jsr change_location
rts
;========================= ;=========================
; change rotation ; change rotation
;========================= ;=========================