mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-27 00:29:35 +00:00
aiibot: a2_4ever
80 column mode as always turns up bugs in my tokenizer
This commit is contained in:
parent
20b33ae880
commit
bf7202c441
@ -9,7 +9,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS \
|
||||
CIRCLES.BAS AUTUMN.BAS QKUMBA.BAS ASTEROID.BAS PERSON.BAS SHIP.BAS \
|
||||
CONCERT.BAS NYAN.BAS RASTER.BAS RASTER2.BAS RASTER3.BAS LOTS.BAS LOAD \
|
||||
RASTER4.BAS RASTER5.BAS PUMPKIN.BAS PUMPKIN_SMALL.BAS LADY.BAS \
|
||||
A2.BAS FOURAM.BAS FLOPPY.BAS QR.BAS
|
||||
A2.BAS FOURAM.BAS FLOPPY.BAS QR.BAS A2_4EVER.BAS
|
||||
cp empty.dsk appleiibot.dsk
|
||||
$(DOS33) -y appleiibot.dsk BSAVE -a 0x0300 LOAD
|
||||
$(DOS33) -y appleiibot.dsk SAVE A E2.BAS
|
||||
@ -36,6 +36,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS \
|
||||
$(DOS33) -y appleiibot.dsk SAVE A FOURAM.BAS
|
||||
$(DOS33) -y appleiibot.dsk SAVE A FLOPPY.BAS
|
||||
$(DOS33) -y appleiibot.dsk SAVE A QR.BAS
|
||||
$(DOS33) -y appleiibot.dsk SAVE A A2_4EVER.BAS
|
||||
|
||||
###
|
||||
|
||||
@ -194,6 +195,12 @@ A2.BAS: a2.bas
|
||||
|
||||
####
|
||||
|
||||
A2_4EVER.BAS: a2_4ever.bas
|
||||
$(TOKENIZE) < a2_4ever.bas > A2_4EVER.BAS
|
||||
|
||||
|
||||
####
|
||||
|
||||
FOURAM.BAS: fouram.bas
|
||||
$(TOKENIZE) < fouram.bas > FOURAM.BAS
|
||||
|
||||
|
4
appleiibot/a2_4ever.bas
Normal file
4
appleiibot/a2_4ever.bas
Normal file
@ -0,0 +1,4 @@
|
||||
1REM______/X__ X_______N__[WO_/ # [& .<'^?^O_C_CC_[W=__.X.X.XN#W?W]_[N[N[N[NM_=W_O'N#G#GS!XP=X_Y[NGNGN\O[WO_? X@[@#. . ^__O[O[__________@_@__
|
||||
2PR#3:FORY=0TO140:Z=PEEK(2054+Y)-32:FORI=0TO5:NORMAL:Q%=Z/2:IFQ%*2-ZTHENINVERSE
|
||||
3Z=Q%:?" ";:NEXTI,Y
|
||||
4?"F O R E V E R";
|
@ -28,8 +28,10 @@ static int debug=0;
|
||||
/* Starting at 0x80 */
|
||||
char applesoft_tokens[][8]={
|
||||
|
||||
/* note applesoft ignores all spaces when parsing */
|
||||
/* so OK that we have PR# instead of PR # here */
|
||||
/* 80 */ "END","FOR","NEXT","DATA","INPUT","DEL","DIM","READ",
|
||||
/* 88 */ "GR","TEXT","PR #","IN #","CALL","PLOT","HLIN","VLIN",
|
||||
/* 88 */ "GR","TEXT","PR#","IN#","CALL","PLOT","HLIN","VLIN",
|
||||
/* 90 */ "HGR2","HGR","HCOLOR=","HPLOT","DRAW","XDRAW","HTAB","HOME",
|
||||
/* 98 */ "ROT=","SCALE=","SHLOAD","TRACE","NOTRACE","NORMAL","INVERSE","FLASH",
|
||||
/* A0 */ "COLOR=","POP","VTAB ","HIMEM:","LOMEM:","ONERR","RESUME","RECALL",
|
||||
|
@ -3,7 +3,7 @@ include ../Makefile.inc
|
||||
CFLAGS = -g -Wall -O2
|
||||
|
||||
all: text2gr png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 \
|
||||
png2sixbitmap
|
||||
png2sixbitmap png2six80
|
||||
|
||||
|
||||
###
|
||||
@ -45,6 +45,14 @@ png2sixbitmap: png2sixbitmap.o loadpng.o
|
||||
png2sixbitmap.o: png2sixbitmap.c loadpng.h
|
||||
$(CC) $(CFLAGS) -c png2sixbitmap.c
|
||||
|
||||
###
|
||||
|
||||
png2six80: png2six80.o loadpng.o
|
||||
$(CC) $(LFLAGS) -o png2six80 png2six80.o loadpng.o -lpng
|
||||
|
||||
png2six80.o: png2six80.c loadpng.h
|
||||
$(CC) $(CFLAGS) -c png2six80.c
|
||||
|
||||
|
||||
###
|
||||
|
||||
@ -85,8 +93,8 @@ png_to_40x96.o: png_to_40x96.c loadpng.h rle_common.h
|
||||
###
|
||||
|
||||
install:
|
||||
cp png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 png2sixbitmap $(INSTALL_LOC)
|
||||
cp png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 png2sixbitmap png2six80 $(INSTALL_LOC)
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 png2sixbitmap
|
||||
rm -f *~ *.o png2gr png2gr_text png2rle png2lz4 png_to_40x48d png_to_40x96 png2sixbitmap png2six80
|
||||
|
||||
|
@ -275,3 +275,224 @@ int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* for 80 column mode or double-lores */
|
||||
int loadpng80(char *filename, unsigned char **image_ptr, int *xsize, int *ysize,
|
||||
int png_type) {
|
||||
|
||||
int x,y,ystart,yadd,xadd;
|
||||
int color;
|
||||
FILE *infile;
|
||||
int debug=0;
|
||||
unsigned char *image,*out_ptr;
|
||||
int width, height;
|
||||
int a2_color;
|
||||
|
||||
png_byte bit_depth;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_bytep *row_pointers;
|
||||
png_byte color_type;
|
||||
|
||||
unsigned char header[8];
|
||||
|
||||
/* open file and test for it being a png */
|
||||
infile = fopen(filename, "rb");
|
||||
if (infile==NULL) {
|
||||
fprintf(stderr,"Error! Could not open %s\n",filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check the header */
|
||||
fread(header, 1, 8, infile);
|
||||
if (png_sig_cmp(header, 0, 8)) {
|
||||
fprintf(stderr,"Error! %s is not a PNG file\n",filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* initialize stuff */
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr) {
|
||||
fprintf(stderr,"Error create_read_struct\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
fprintf(stderr,"Error png_create_info_struct\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, infile);
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
width = png_get_image_width(png_ptr, info_ptr);
|
||||
height = png_get_image_height(png_ptr, info_ptr);
|
||||
|
||||
if (width==80) {
|
||||
*xsize=80;
|
||||
xadd=1;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"Unsupported width %d\n",width);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (png_type==PNG_WHOLETHING) {
|
||||
*ysize=height;
|
||||
ystart=0;
|
||||
yadd=2;
|
||||
}
|
||||
else if (png_type==PNG_ODDLINES) {
|
||||
*ysize=height/2;
|
||||
ystart=1;
|
||||
yadd=4;
|
||||
}
|
||||
else if (png_type==PNG_EVENLINES) {
|
||||
*ysize=height/2;
|
||||
ystart=0;
|
||||
yadd=4;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"Unknown PNG type\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
color_type = png_get_color_type(png_ptr, info_ptr);
|
||||
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
if (debug) {
|
||||
printf("PNG: width=%d height=%d depth=%d\n",width,height,bit_depth);
|
||||
if (color_type==PNG_COLOR_TYPE_RGB) printf("Type RGB\n");
|
||||
else if (color_type==PNG_COLOR_TYPE_RGB_ALPHA) printf("Type RGBA\n");
|
||||
else if (color_type==PNG_COLOR_TYPE_PALETTE) printf("Type palette\n");
|
||||
printf("Generating output size %d x %d\n",*xsize,*ysize);
|
||||
}
|
||||
|
||||
// number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
|
||||
for (y=0; y<height; y++) {
|
||||
/* FIXME: do we ever free these? */
|
||||
row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
||||
fclose(infile);
|
||||
|
||||
/* FIXME: this should be 40x24 max??? */
|
||||
image=calloc(width*height,sizeof(unsigned char));
|
||||
if (image==NULL) {
|
||||
fprintf(stderr,"Memory error!\n");
|
||||
return -1;
|
||||
}
|
||||
out_ptr=image;
|
||||
|
||||
if (color_type==PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||
for(y=ystart;y<height;y+=yadd) {
|
||||
for(x=0;x<width;x+=xadd) {
|
||||
|
||||
/* top color */
|
||||
color= (row_pointers[y][x*xadd*4]<<16)+
|
||||
(row_pointers[y][x*xadd*4+1]<<8)+
|
||||
(row_pointers[y][x*xadd*4+2]);
|
||||
if (debug) {
|
||||
printf("%x ",color);
|
||||
}
|
||||
|
||||
a2_color=convert_color(color,filename);
|
||||
|
||||
/* bottom color */
|
||||
color= (row_pointers[y+1][x*xadd*4]<<16)+
|
||||
(row_pointers[y+1][x*xadd*4+1]<<8)+
|
||||
(row_pointers[y+1][x*xadd*4+2]);
|
||||
if (debug) {
|
||||
printf("%x ",color);
|
||||
}
|
||||
|
||||
a2_color|=(convert_color(color,filename)<<4);
|
||||
|
||||
*out_ptr=a2_color;
|
||||
out_ptr++;
|
||||
}
|
||||
if (debug) printf("\n");
|
||||
}
|
||||
}
|
||||
else if (color_type==PNG_COLOR_TYPE_PALETTE) {
|
||||
for(y=ystart;y<height;y+=yadd) {
|
||||
for(x=0;x<width;x+=xadd) {
|
||||
|
||||
if (bit_depth==8) {
|
||||
/* top color */
|
||||
a2_color=row_pointers[y][x];
|
||||
|
||||
/* bottom color */
|
||||
color=row_pointers[y+(yadd/2)][x];
|
||||
|
||||
a2_color|=(color<<4);
|
||||
|
||||
if (debug) {
|
||||
printf("%x ",a2_color);
|
||||
}
|
||||
|
||||
*out_ptr=a2_color;
|
||||
out_ptr++;
|
||||
}
|
||||
else if (bit_depth==4) {
|
||||
/* top color */
|
||||
a2_color=row_pointers[y][x/2];
|
||||
if (x%2==0) {
|
||||
a2_color=(a2_color>>4);
|
||||
}
|
||||
a2_color&=0xf;
|
||||
|
||||
/* bottom color */
|
||||
color=row_pointers[y+(yadd/2)][x/2];
|
||||
if (x%2==0) {
|
||||
color=(color>>4);
|
||||
}
|
||||
color&=0xf;
|
||||
|
||||
a2_color|=(color<<4);
|
||||
|
||||
if (debug) {
|
||||
printf("%x ",a2_color);
|
||||
}
|
||||
|
||||
*out_ptr=a2_color;
|
||||
out_ptr++;
|
||||
|
||||
}
|
||||
}
|
||||
if (debug) printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Unknown color type\n");
|
||||
}
|
||||
|
||||
/* Stripe test image */
|
||||
// for(x=0;x<40;x++) for(y=0;y<40;y++) image[(y*width)+x]=y%16;
|
||||
|
||||
/*
|
||||
Addr Row /80 %40
|
||||
$400 0 0 0 0
|
||||
$428 28 16 0
|
||||
$450 50 32 0
|
||||
$480 80 2 1
|
||||
$4A8 a8 18 1
|
||||
$4D0 d0 34 1
|
||||
$500 100 3 2
|
||||
0,0 0,1 0,2....0,39 16,0 16,1 ....16,39 32,0..32,39, X X X X X X X X
|
||||
*/
|
||||
|
||||
*image_ptr=image;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,4 +4,6 @@
|
||||
|
||||
int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize,
|
||||
int png_type);
|
||||
int loadpng80(char *filename, unsigned char **image_ptr, int *xsize, int *ysize,
|
||||
int png_type);
|
||||
|
||||
|
56
gr-utils/png2six80.c
Normal file
56
gr-utils/png2six80.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "loadpng.h"
|
||||
|
||||
/* Converts a PNG to a shifted 6 bitmap */
|
||||
/* for 80 column mode */
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int row=0;
|
||||
int col=0;
|
||||
|
||||
unsigned char ch;
|
||||
|
||||
unsigned char *image;
|
||||
int xsize,ysize;
|
||||
|
||||
if (argc<2) {
|
||||
fprintf(stderr,"Usage:\t%s INFILE\n\n",argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (loadpng80(argv[1],&image,&xsize,&ysize,PNG_WHOLETHING)<0) {
|
||||
fprintf(stderr,"Error loading png!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stderr,"Loaded image %d by %d\n",xsize,ysize);
|
||||
|
||||
ch=0;
|
||||
for(row=0;row<12;row++) {
|
||||
for(col=0;col<80;col++) {
|
||||
if (image[row*xsize+col]) {
|
||||
ch|=1<<5;
|
||||
}
|
||||
if ((row*xsize+col)%6==5) {
|
||||
printf("%c",ch+32);
|
||||
ch=0;
|
||||
}
|
||||
else {
|
||||
ch>>=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user