home *** CD-ROM | disk | FTP | other *** search
- =ReadPaint
- PRG formatted GEOS file V1.0
- PSLowGC
- BLASTER'S CONVERTER V2.5
- Write Image V2.1
- geoWrite V2.1
- ;************************************************************
- ; ReadPaint
- ; Routines for reading and decoding
- ; a GeoPaint file.
- ;************************************************************
- .if Pass1
- .noglbl
- .noeqin
- .include geosSym
- .include geosMac
- .eqin
- .glbl
- .endif
- .psect
- ;A GeoPaint file is made up of 45 records in VLIR format. Each record
- ;represents 16 raster lines (actually 2 card rows) of the GeoPaint page.
- ;If a record i
- ;A GeoPaint file is made up of 45 records in VLIR format. Each record
- ;represents 16 raster lines (actually 2 card rows) of the GeoPaint page.
- ;If a record is empty, then those 2 card rows are blank.
- ;To use these routines, first get a pointer to a filename
- ;into r6. Then call GetIndex.
- ;Provide a 1448 byte buffer (see below) and point r2 to the buffer.
- ;Load x with the record number to load into the buffer.
- ;Call LdBuf and the record will be decoded and stored
- ;in the buffer. This buffer will hold the data for 2 card rows.
- ;The breakdown of the 1448 byte buffer will be as follows:
- line1Buffer:
- .block 640 ;data for the first card row of the record.
- line2Buffer:
- .block 640 ;data for the second card row of the record.
- extraBytes:
- .block 8 ;these are not used.
- line1Color:
- .block 80 ;color data for the first card row.
- line2Color:
- .block 80 ;color data for the second card row.
- ;Each 640 byte card row is stored just like the 64's screen data
- ;is stored. The first 8 bytes make up the first card, the 2nd 8 bytes
- ;make up the second card and so on.
- ;The first byte of the color data is for the first card. The upper
- ;nybble is the foreground color and the lower nybble is the background
- ;color.
- ;Once you have a record loaded, you can then use it as needed, whether it
- ;be for printing, converting to other formats, or displaying on the screen.
- ;If you have room, you can load in more than one record at a time.
- ;call this routine with r6 poin
- ;call this routine with r6 pointing to a buffer holding
- ;the filename of a GeoPaint file.
- ;Any non-zero value in x upon exit indicates either an error
- ;or the file is not a GeoPaint.
- ;This will also load track and sector pointers to the
- ;records in two buffers at trackIndex and sectorIndex.
- ;This frees up fileHeader for other uses while you are
- ;working with the GeoPaint image.
- GetIndex:
- jsr FindFile ;is there a next page?
- bne 90$ ;branch if not.
- LoadW r9,#dirEntryBuf
- jsr GetFHdrInfo ;get some stuff on this file.
- bne 90$ ;branch if any problems.
- jsr CmpIfPaint ;is this file a GeoPaint file?
- bne 90$
- MoveW dirEntryBuf+1,r1
- LoadW r4,#fileHeader
- jsr GetBlock
- bne 90$
- ldx #0
- ldy #0
- lda fileHeader+2,x
- sta trackIndex,y
- lda fileHeader+3,x
- sta sectorIndex,y
- cpy #45
- bne 20$
- ldx #0
- ;load the header block for the desired file into
- ;fileHeader and then use this routine to verify
- ;that
- ;load the header block for the desired file into
- ;fileHeader and then use this routine to verify
- ;that the file is a GeoPaint data file.
- ;Equals flag or the x register may be checked
- ;upon exit. x=0 if GeoPaint.
- CmpIfPaint:
- LoadW r0,#gpName
- LoadW r1,#(fileHeader+77)
- ldx #r0
- ldy #r1
- lda #11
- jsr CmpFString
- bne 90$
- ldx #0
- ldx #128
- gpName:
- .byte "Paint Image",0
- ;Before calling this routine, point r2 to a 1448 byte bu
- ;Before calling this routine, point r2 to a 1448 byte buffer.
- ;This will load the buffer with the data from the geoPaint record
- ;that x points at. Therefore x should have a value between 0 and 44
- ;upon entry. If any data was loaded, then dataLoaded will have
- ;bit 7 set, otherwise cleared.
- ;The calling routine might want to clear the buffer prior
- ;to calling this routine to erase any data from the previously
- ;loaded record.
- ;Destroys r1 - r5.
- ;Assume no errors, value of x is not valid upon exit.
- LdBuf:
- LoadB dataLoaded,#0
- lda r2L
- adc #[1448
- sta bufLength+0
- lda r2H
- adc #]1448
- sta bufLength+1
- lda trackIndex,x
- beq 15$
- sta r1L
- lda sectorIndex,x
- sta r1H
- LoadW r4,#diskBlkBuf
- LoadB r5H,#0
- sta r5L
- jsr ReadByte ;fetch a command byte.
- cpx #0
- bne 15$
- cmp #0
- bne 20$
- sta cmdByte
- LoadB dataLoaded,#128
- lda cmdByte
- cmp #$80 ;is this a $80?
- beq 15$ ;branch if so. (invalid)
- bcc 40$ ;branch if less than $80.
- jsr RepeatByte
- beq 10$
- cmp #$40 ;is this a $40?
- beq 15$ ;branch if so. (invalid)
- bcc 50$ ;branch if less than $40.
- jsr Repeat8Bytes
- beq 10$
- jsr DoUniqBytes
- beq 10$
- ;this is called by LdBuf.
- DoUniqBytes:
- ;this is called by LdBuf.
- DoUniqBytes:
- jsr ReadByte
- cpx #0
- bne 90$
- ldy #0
- sta (r2),y
- inc r2L
- bne 60$
- inc r2H
- CmpW r2,bufLength
- bcs 90$
- dec cmdByte
- bne 10$
- ldx #0
- ldx #128
- ;this is called by LdBuf.
- RepeatByte:
- and #%01111111
- sta cmdByte
- jsr ReadByte
- sta uniqByte
- cpx #0
- bne 90$
- ldy #0
- lda uniqByte
- sta (r2),y
- inc r2L
- bne 60$
- inc r2H
- CmpW r2,bufLength
- bcs 90$
- dec cmdByte
- bne 10$
- ldx #0
- ldx #128
- uniqByte:
- .block 1
- ;this is called by LdBuf.
- ;Destroys r3.
- Repeat8Bytes:
- and #%00111111
- sta cmdByte
- LoadB
- ;this is called by LdBuf.
- ;Destroys r3.
- Repeat8Bytes:
- and #%00111111
- sta cmdByte
- LoadB repeatCount,#8
- MoveW r2,r3
- jsr ReadByte
- cpx #0
- bne 90$
- ldy #0
- sta (r2),y
- inc r2L
- bne 15$
- inc r2H
- dec repeatCount
- bne 10$
- beq 25$
- AddVW #8,r2
- CmpW r2,bufLength
- bcs 90$
- dec cmdByte
- beq 80$
- ldy #0
- lda (r3),y
- sta (r2),y
- cpy #8
- bne 30$
- beq 20$
- ldx #0
- ldx #128
- cmdByte:
- .block 1
- dataLoaded:
- .block 1
- bufLength:
- .block 2
- trackIndex:
- .block 45
- sectorIndex:
- .block 45
-