TITLE'READPIC -- Reads ATARIARTIST Picture Files' SUBTTL'Definitions' ; ;**** READPI.MAC -- Reads ATARIARTIST Picture Files *** ; ; By Robert Elden Wilson ; REW Consulting ; December, 1984 ; ; *** Definitions *** ; BYTE:EQU$CB;Will hold input byte MODE:EQU$CC;Unique data or Same data mode TYPE:EQU$CD;Compression type PNT:EQU$CE;Buffer pointer CNT96:EQU$D0;Counter (96-0) CNT2:EQU$D1;Counter (2-0) LEN:EQU$D4;Length of compression block ; ICCMD:EQU$0352;IOCB1 command byte ICBA:EQU$0354;IOCB1 buffer address ICBL:EQU$0358;IOCB1 buffer length ; SCRMEM:EQU$58;Address to Pointer to Screen memory COLOR0:EQU$02C4;Playfield color 0 shadow ; CIOV:EQU$E456;Address of CIO routine ; ; EJECT SUBTTL'Page Six' ; ; *** Page Six *** ; ; ; This block must be loaded into page 6. ; ORG$0600 ; ; ;>>>GETBYT --Inputs a byte from the file ;open on IOCB1. When number ;of bytes input equals ;value stored at LENGTH, ;return address is popped ;from stack and routine ;returns to previous caller. ; GETBYT:LDACOUNT+1;See if done yet CMPLENGTH+1 BNECONTIN;No, continue LDACOUNT CMPLENGTH BEQERROR;Yes, exit CONTIN:LDX#$10;Use IOCB1 LDA#$00;Set buffer len to 0 STAICBL;This causes byte STAICBL+1;to be returned in A JSRCIOV;Get byte BMIERROR;Error INCCOUNT;Increment # bytes read BNEDONE INCCOUNT+1 DONE:RTS;That's all ; ERROR:PLA;Pop off return address PLA RTS;Return to previous caller ; COUNT:DW0;# bytes input LENGTH:DW0;Length of file BASE:DW0;Base screen address ; ; ;>>>NXTPNT --Loads PNT with the screen ;address for the next byte ;of picture data. ; NXTPNT:BITTYPE;Check compression type BVCNOCOMP;No compression DECCNT96;Have we done 96 rows? BEQSTEP5;Yes LDA#80;Add 80 to PNT CLC ADCPNT STAPNT LDA#$00 ADCPNT+1 STAPNT+1 RTS;Done STEP5:LDA#96;Reset counter STACNT96 DECCNT2;Both odd/even rows done? BEQSTEP7;Yes LDA#40;Add 40 to BASE CLC ADCBASE STAPNT;and store in PNT LDA#$00 ADCBASE+1 STAPNT+1 RTS;Done STEP7:LDA#$02;Reset counter STACNT2 NOCOMP:LDA#$01;Add 1 to BASE & PNT CLC ADCBASE STABASE STAPNT LDA#$00 ADCBASE+1 STABASE+1 STAPNT+1 RTS;Done ; EJECT SUBTTL'Main Routine' ; ; *** Main Routine *** ; ; ; This block can be loaded anywhere. ; ORG$0000 ; READIT:PLA;Remove arg cnt LDASCRMEM;Get screen memory address STABASE STAPNT LDASCRMEM+1 STABASE+1 STAPNT+1 LDA#96;Set up counters STACNT96 LDA#$02 STACNT2 LDA#$07;I/O will be read STAICCMD LDA#BYTE;Store buffer address STAICBA LDA#$00 STAICBA+1 STALEN;Init remaining variables STALENGTH+1 LDA#$FF STALENGTH STACOUNT STACOUNT+1 READHD:JSRGETBYT;Get a header byte STABYTE LDACOUNT;Load # bytes read CMP#$07 BEQCTYPE;Up to compression CMP#$0C BEQCOLORS;Up to colors CMP#$1A BEQREADAT;Done with header BNEREADHD;Keep reading header CTYPE:LDABYTE;Get data LSRA;Move bits 0,1 to 6,7 RORA RORA STATYPE;Save compression type CLC BCCREADHD;Read more header COLORS:LDA#$05;Load counter to read colors STAMODE NXTCOL:JSRGETBYT;Get a color LDXLEN STACOLOR0,X ;Store it INCLEN DECMODE BNENXTCOL;Get next one JSRGETBYT;Get file size STALENGTH;Store it JSRGETBYT STALENGTH+1 CLC BCCREADHD;Read more header READAT:LDATYPE;Get compression type BEQINPBYT;No compression COMPR:JSRGETBYT;Get a mode byte STAMODE AND#$7F;Get count BNESHORT;Count < 128 JSRGETBYT;Get long count STALEN+1 INCLEN+1 JSRGETBYT STALEN CLC BCCGETDAT SHORT:STALEN LDA#$01 STALEN+1 GETDAT:LDAMODE;Reload mode AND#$80;Strip off count STAMODE INPBYT:JSRGETBYT;Get data byte STABYTE LDY#$00 STORE:LDABYTE STA(PNT),Y;Store it JSRNXTPNT;Go calculate next address LDATYPE;Check compression BEQINPBYT;No compression DECLEN;More in the block? BNENEXT;Yes DECLEN+1 BEQCOMPR;No, get next mode byte NEXT:LDAMODE;Check mode BEQSTORE;Repeated data mode BNEINPBYT;Unique data mode ; END