diff --git a/bot_demo/Makefile b/bot_demo/Makefile new file mode 100644 index 00000000..3d6c38de --- /dev/null +++ b/bot_demo/Makefile @@ -0,0 +1,24 @@ +include ../Makefile.inc + +DOS33 = ../dos33fs-utils/dos33 +TOKENIZE = ../asoft_basic-utils/tokenize_asoft + +all: bot_demo.dsk + +bot_demo.dsk: RLE + cp empty.dsk bot_demo.dsk + $(DOS33) -y bot_demo.dsk BSAVE -a 0x036c RLE + + +### + +RLE: rle.o + ld65 -o RLE rle.o -C ./apple2_custom.inc + +rle.o: rle.s + ca65 -o rle.o rle.s -l rle.lst + +#### + +clean: + rm -f *~ *.o *.lst RLE diff --git a/bot_demo/apple2_custom.inc b/bot_demo/apple2_custom.inc new file mode 100644 index 00000000..dddae43f --- /dev/null +++ b/bot_demo/apple2_custom.inc @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $00, size = $1A, type = rw; + RAM: start = $36c, size = $8E00, file = %O; +} + +SEGMENTS { +CODE: load = RAM, type = ro, align = $1; +RODATA: load = RAM, type = ro; +DATA: load = RAM, type = rw; +BSS: load = RAM, type = bss, define = yes; +ZEROPAGE: load = ZP, type = zp; +} diff --git a/bot_demo/empty.dsk b/bot_demo/empty.dsk new file mode 100644 index 00000000..b34eb519 Binary files /dev/null and b/bot_demo/empty.dsk differ diff --git a/bot_demo/rle.s b/bot_demo/rle.s new file mode 100644 index 00000000..3a19914d --- /dev/null +++ b/bot_demo/rle.s @@ -0,0 +1,62 @@ +PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved) +SETCOL = $F864 +TEXT = $FB36 ;; Set text mode +TABV = $FB5B +BASCALC = $FBC1 +SETGR = $FB40 +STORADV = $FBF0 +HOME = $FC58 ;; Clear the text screen +WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us +HLINE = $F819 +CH = $24 +CV = $25 +COLOR = $30 +TEMPY = $FF + +graphic: +.byte $F0,$25,$1C,$F0,$26,$1C,$F0,$24,$6C,$A0,$1F,$F0,$16,$6D,$B0,$2F +.byte $F0,$15,$69,$B0,$3F,$F0,$14,$71,$A0,$4F,$F0,$13,$72,$A0,$5F,$F0 +.byte $13,$56,$B0,$67,$F0,$20,$12,$10,$BF,$52,$F0,$12,$4D,$22,$1F,$31 +.byte $42,$3F,$62,$F0,$0F,$6D,$22,$2F,$11,$34,$12,$4F,$72,$D0,$4D,$39 +.byte $22,$BF,$82,$E0,$5D,$22,$BF,$92,$F0,$0F,$3D,$22,$A7,$BF,$F0,$11 +.byte $12,$10,$9F,$17,$CF,$00 + +rle: + jsr SETGR +rerun: + lda #1 + sta CH + jsr TABV + + ldy #0 +decode_loop: + lda graphic,Y + pha + jsr SETCOL ; puts (color&0xf)*17 in $30 + pla + lsr + lsr + lsr + lsr + beq rerun ; if stride=0 then done + cmp #$f + bne ready + iny + lda graphic,Y +ready: + tax + sty TEMPY +final_loop: + lda COLOR + jsr STORADV ; destroys A and Y + dex + bne final_loop + ldy TEMPY + iny + jmp decode_loop +start: + jmp rle ; ampersand jumps to $3f5 + ; 140 is 8c in hex + ; so want to load at $3f5-$8c+3 = $36C + + diff --git a/gr-utils/png2sixrle2.c b/gr-utils/png2sixrle2.c new file mode 100644 index 00000000..b4f3f274 --- /dev/null +++ b/gr-utils/png2sixrle2.c @@ -0,0 +1,84 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include "loadpng.h" + +static int print_rle(int color, int run) { + + int ret=0; + + if ((color&0xf)!=((color>>4)&0xf)) { + fprintf(stderr,"color not match! %x\n",color); + ret=1; + } + if (run>63) { + fprintf(stderr,"Run too big %x\n",run); + ret=1; + } + if (run==1) { + printf("%c",(color&0xf)+16); + } + else { + printf("%c%c",(color&0xf)+' ',run+' '); +// fprintf(stderr,"c=%x run=%x\n",color,run); + } + return ret; +} + +/* Converts a PNG to a 6-bit RLE encoding */ + +int main(int argc, char **argv) { + + int row=0; + int col=0; + int color=0,oldcolor=0; + int run=0; + + unsigned char *image; + int xsize,ysize; + + if (argc<2) { + fprintf(stderr,"Usage:\t%s INFILE\n\n",argv[0]); + exit(-1); + } + + if (loadpng(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); + + oldcolor=image[0]; + for(row=0;row<24;row++) { + for(col=0;col<40;col++) { + color=image[row*xsize+col]; + if (color!=oldcolor) { + if (print_rle(oldcolor,run)) { + fprintf(stderr,"at %d, %d\n",col,row); + } + oldcolor=color; + run=0; + } + if (run>62) { + if (print_rle(oldcolor,run)) { + fprintf(stderr,"at %d, %d\n",col,row); + } + oldcolor=color; + run=0; + } + + run++; + } + } + print_rle(oldcolor,run); + printf("\n"); + + return 0; +}