diff --git a/gr-utils/Makefile b/gr-utils/Makefile index 16fe6607..74af67be 100644 --- a/gr-utils/Makefile +++ b/gr-utils/Makefile @@ -2,7 +2,7 @@ include ../Makefile.inc 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 $(CC) $(CFLAGS) -c rle_common.c +### + +text2gr: text2gr.o + $(CC) $(LFLAGS) -o text2gr text2gr.o + +text2gr.o: text2gr.c + $(CC) $(CFLAGS) -c text2gr.c ### diff --git a/gr-utils/text2gr.c b/gr-utils/text2gr.c new file mode 100644 index 00000000..a18fec0a --- /dev/null +++ b/gr-utils/text2gr.c @@ -0,0 +1,150 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include + +/* 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=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; +} diff --git a/mist/Makefile b/mist/Makefile index 3b4de741..2366a640 100644 --- a/mist/Makefile +++ b/mist/Makefile @@ -80,6 +80,7 @@ OCTAGON: octagon.o octagon.o: octagon.s zp.inc hardware.inc common_defines.inc \ graphics_octagon/octagon_graphics.inc \ + books/octagon_books.inc \ common_sprites.inc \ leveldata_octagon.inc \ letter_cat.s \ diff --git a/mist/books/Makefile b/mist/books/Makefile new file mode 100644 index 00000000..2dc60362 --- /dev/null +++ b/mist/books/Makefile @@ -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 diff --git a/mist/books/channelwood.book b/mist/books/channelwood.book new file mode 100644 index 00000000..894ac334 --- /dev/null +++ b/mist/books/channelwood.book @@ -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? : + : diff --git a/mist/books/mechanical.book b/mist/books/mechanical.book new file mode 100644 index 00000000..00800dc8 --- /dev/null +++ b/mist/books/mechanical.book @@ -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. : diff --git a/mist/books/selenitic.book b/mist/books/selenitic.book new file mode 100644 index 00000000..0579a7ba --- /dev/null +++ b/mist/books/selenitic.book @@ -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 + : diff --git a/mist/books/stoneship.book b/mist/books/stoneship.book new file mode 100644 index 00000000..6805b38b --- /dev/null +++ b/mist/books/stoneship.book @@ -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. : * * _/\_ + : .. * \__/ diff --git a/mist/hello.bas b/mist/hello.bas index 7ec38ffe..61ae42c7 100644 --- a/mist/hello.bas +++ b/mist/hello.bas @@ -1,7 +1,6 @@ 5 HOME -10 PRINT " LOADING MIST V0.81" -20 PRINT -30 PRINT:PRINT:PRINT:PRINT +10 PRINT "LOADING MIST V0.82" +20 PRINT:PRINT 40 PRINT "CONTROLS: ARROWS OR WASD" 50 PRINT " ENTER MOVES/ACTION" 60 PRINT:PRINT diff --git a/mist/leveldata_octagon.inc b/mist/leveldata_octagon.inc index 2d5405b2..2ff50e37 100644 --- a/mist/leveldata_octagon.inc +++ b/mist/leveldata_octagon.inc @@ -253,7 +253,10 @@ location12: .word $0000 ; east bg .word $0000 ; west bg .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 location13: diff --git a/mist/octagon.s b/mist/octagon.s index ccc944fa..7edb68d6 100644 --- a/mist/octagon.s +++ b/mist/octagon.s @@ -279,7 +279,9 @@ done_goto: ; linking books - ; letters + ; books + + .include "books/octagon_books.inc" .include "common_sprites.inc" diff --git a/mist/octagon_bookshelf.s b/mist/octagon_bookshelf.s index 86d41eb5..93d39082 100644 --- a/mist/octagon_bookshelf.s +++ b/mist/octagon_bookshelf.s @@ -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 + jmp load_the_book + +read_stoneship: + lda #stoneship_book_lzsa + jmp load_the_book + +read_mechanical: + lda #mechanical_book_lzsa + jmp load_the_book + +read_channelwood: + 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 ;=========================