home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / MRFiles / RDPAINT.CVT (.txt) < prev    next >
Encoding:
GEOS ConVerT  |  2019-04-13  |  7.0 KB  |  237 lines

  1. =ReadPaint
  2. PRG formatted GEOS file V1.0
  3. PSLowGC
  4. BLASTER'S CONVERTER V2.5
  5. Write Image V2.1
  6. geoWrite    V2.1
  7. ;************************************************************
  8. ;        ReadPaint
  9. ;    Routines for reading and decoding
  10. ;    a GeoPaint file.
  11. ;************************************************************
  12. .if    Pass1
  13. .noglbl
  14. .noeqin
  15. .include    geosSym
  16. .include    geosMac
  17. .eqin
  18. .glbl
  19. .endif
  20.     .psect
  21. ;A GeoPaint file is made up of 45 records in VLIR format. Each record
  22. ;represents 16 raster lines (actually 2 card rows) of the GeoPaint page.
  23. ;If a record i
  24. ;A GeoPaint file is made up of 45 records in VLIR format. Each record
  25. ;represents 16 raster lines (actually 2 card rows) of the GeoPaint page.
  26. ;If a record is empty, then those 2 card rows are blank.
  27. ;To use these routines, first get a pointer to a filename
  28. ;into r6. Then call GetIndex.
  29. ;Provide a 1448 byte buffer (see below) and point r2 to the buffer.
  30. ;Load x with the record number to load into the buffer.
  31. ;Call LdBuf and the record will be decoded and stored
  32. ;in the buffer. This buffer will hold the data for 2 card rows.
  33. ;The breakdown of the 1448 byte buffer will be as follows:
  34. line1Buffer:
  35.     .block    640    ;data for the first card row of the record.
  36. line2Buffer:
  37.     .block    640    ;data for the second card row of the record.
  38. extraBytes:
  39.     .block    8    ;these are not used.
  40. line1Color:
  41.     .block    80    ;color data for the first card row.
  42. line2Color:
  43.     .block    80    ;color data for the second card row.
  44. ;Each 640 byte card row is stored just like the 64's screen data
  45. ;is stored. The first 8 bytes make up the first card, the 2nd 8 bytes
  46. ;make up the second card and so on.
  47. ;The first byte of the color data is for the first card. The upper
  48. ;nybble is the foreground color and the lower nybble is the background
  49. ;color.
  50. ;Once you have a record loaded, you can then use it as needed, whether it
  51. ;be for printing, converting to other formats, or displaying on the screen.
  52. ;If you have room, you can load in more than one record at a time.
  53. ;call this routine with r6 poin
  54. ;call this routine with r6 pointing to a buffer holding
  55. ;the filename of a GeoPaint file.
  56. ;Any non-zero value in x upon exit indicates either an error
  57. ;or the file is not a GeoPaint.
  58. ;This will also load track and sector pointers to the
  59. ;records in two buffers at trackIndex and sectorIndex.
  60. ;This frees up fileHeader for other uses while you are
  61. ;working with the GeoPaint image.
  62. GetIndex:
  63.     jsr    FindFile    ;is there a next page?
  64.     bne    90$    ;branch if not.
  65.     LoadW    r9,#dirEntryBuf
  66.     jsr    GetFHdrInfo    ;get some stuff on this file.
  67.     bne    90$    ;branch if any problems.
  68.     jsr    CmpIfPaint    ;is this file a GeoPaint file?
  69.     bne    90$
  70.     MoveW    dirEntryBuf+1,r1
  71.     LoadW    r4,#fileHeader
  72.     jsr    GetBlock
  73.     bne    90$
  74.     ldx    #0
  75.     ldy    #0
  76.     lda    fileHeader+2,x
  77.     sta    trackIndex,y
  78.     lda    fileHeader+3,x
  79.     sta    sectorIndex,y
  80.     cpy    #45
  81.     bne    20$
  82.     ldx    #0
  83. ;load the header block for the desired file into
  84. ;fileHeader and then use this routine to verify
  85. ;that 
  86. ;load the header block for the desired file into
  87. ;fileHeader and then use this routine to verify
  88. ;that the file is a GeoPaint data file.
  89. ;Equals flag or the x register may be checked
  90. ;upon exit. x=0 if GeoPaint.
  91. CmpIfPaint:
  92.     LoadW    r0,#gpName
  93.     LoadW    r1,#(fileHeader+77)
  94.     ldx    #r0
  95.     ldy    #r1
  96.     lda    #11
  97.     jsr    CmpFString
  98.     bne    90$
  99.     ldx    #0
  100.     ldx    #128
  101. gpName:
  102.     .byte    "Paint Image",0
  103. ;Before calling this routine, point r2 to a 1448 byte bu
  104. ;Before calling this routine, point r2 to a 1448 byte buffer.
  105. ;This will load the buffer with the data from the geoPaint record
  106. ;that x points at. Therefore x should have a value between 0 and 44
  107. ;upon entry. If any data was loaded, then dataLoaded will have
  108. ;bit 7 set, otherwise cleared.
  109. ;The calling routine might want to clear the buffer prior
  110. ;to calling this routine to erase any data from the previously
  111. ;loaded record.
  112. ;Destroys r1 - r5.
  113. ;Assume no errors, value of x is not valid upon exit.
  114. LdBuf:
  115.     LoadB    dataLoaded,#0
  116.     lda    r2L
  117.     adc    #[1448
  118.     sta    bufLength+0
  119.     lda    r2H
  120.     adc    #]1448
  121.     sta    bufLength+1
  122.     lda    trackIndex,x
  123.     beq    15$
  124.     sta    r1L
  125.     lda    sectorIndex,x
  126.     sta    r1H
  127.     LoadW    r4,#diskBlkBuf
  128.     LoadB    r5H,#0
  129.     sta    r5L
  130.     jsr    ReadByte    ;fetch a command byte.
  131.     cpx    #0
  132.     bne    15$
  133.     cmp    #0
  134.     bne    20$
  135.     sta    cmdByte
  136.     LoadB    dataLoaded,#128
  137.     lda    cmdByte
  138.     cmp    #$80    ;is this a $80?
  139.     beq    15$    ;branch if so. (invalid)
  140.     bcc    40$    ;branch if less than $80.
  141.     jsr    RepeatByte
  142.     beq    10$
  143.     cmp    #$40    ;is this a $40?
  144.     beq    15$    ;branch if so. (invalid)
  145.     bcc    50$    ;branch if less than $40.
  146.     jsr    Repeat8Bytes
  147.     beq    10$
  148.     jsr    DoUniqBytes
  149.     beq    10$
  150. ;this is called by LdBuf.
  151. DoUniqBytes:
  152. ;this is called by LdBuf.
  153. DoUniqBytes:
  154.     jsr    ReadByte
  155.     cpx    #0
  156.     bne    90$
  157.     ldy    #0
  158.     sta    (r2),y
  159.     inc    r2L
  160.     bne    60$
  161.     inc    r2H
  162.     CmpW    r2,bufLength
  163.     bcs    90$
  164.     dec    cmdByte
  165.     bne    10$
  166.     ldx    #0
  167.     ldx    #128
  168. ;this is called by LdBuf.
  169. RepeatByte:
  170.     and    #%01111111
  171.     sta    cmdByte
  172.     jsr    ReadByte
  173.     sta    uniqByte
  174.     cpx    #0
  175.     bne    90$
  176.     ldy    #0
  177.     lda    uniqByte
  178.     sta    (r2),y
  179.     inc    r2L
  180.     bne    60$
  181.     inc    r2H
  182.     CmpW    r2,bufLength
  183.     bcs    90$
  184.     dec    cmdByte
  185.     bne    10$
  186.     ldx    #0
  187.     ldx    #128
  188. uniqByte:
  189.     .block    1
  190. ;this is called by LdBuf.
  191. ;Destroys r3.
  192. Repeat8Bytes:
  193.     and    #%00111111
  194.     sta    cmdByte
  195.     LoadB    
  196. ;this is called by LdBuf.
  197. ;Destroys r3.
  198. Repeat8Bytes:
  199.     and    #%00111111
  200.     sta    cmdByte
  201.     LoadB    repeatCount,#8
  202.     MoveW    r2,r3
  203.     jsr    ReadByte
  204.     cpx    #0
  205.     bne    90$
  206.     ldy    #0
  207.     sta    (r2),y
  208.     inc    r2L
  209.     bne    15$
  210.     inc    r2H
  211.     dec    repeatCount
  212.     bne    10$
  213.     beq    25$
  214.     AddVW    #8,r2
  215.     CmpW    r2,bufLength
  216.     bcs    90$
  217.     dec    cmdByte
  218.     beq    80$
  219.     ldy    #0
  220.     lda    (r3),y
  221.     sta    (r2),y
  222.     cpy    #8
  223.     bne    30$
  224.     beq    20$
  225.     ldx    #0
  226.     ldx    #128
  227. cmdByte:
  228.     .block    1
  229. dataLoaded:
  230.     .block    1
  231. bufLength:
  232.     .block    2
  233. trackIndex:
  234.     .block    45
  235. sectorIndex:
  236.     .block    45
  237.