home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / graphics / utility / stadconv / fromstad.s next >
Encoding:
Text File  |  1992-07-11  |  7.3 KB  |  146 lines

  1. *****************************************************************************
  2. *                                                                           *
  3. * Ass-Subroutine to convert packed STAD-Pictures to 32k pictures (normal    *
  4. * screenformat).                                                            *
  5. *                                                                           *
  6. * params:   (sp) LONG  return-adress                                        *
  7. *          4(sp) LONG  adress of packed STAD-pictures                       *
  8. *          8(sp) LONG  adress of destination (32k buffer)                   *
  9. *                                                                           *
  10. * returns:   d0        0 = did correct convert                              *
  11. *                      1 = pictures is not in packed STAD-format :-(        *
  12. *                                                                           *
  13. * important: the two adresses are not removed from the stack (like trap)    *
  14. *                                                                           *
  15. * History:                                                                  *
  16. * Version 1.0   01.06.1991  Wolfgang Ley                                    *
  17. *                           - first version                                 *
  18. * Version 1.1   03.06.1991  Wolfgang Ley                                    *
  19. *                           - saving registers now                          *
  20. * Version 1.2   05.06.1991  Wolfgang Ley                                    *
  21. *                           - extra-counter in v_lese removed               *
  22. * Version 1.3   06.07.1992  Wolfgang Ley                                    *
  23. *                           - code cleaned up                               *
  24. *                                                                           *
  25. *****************************************************************************
  26.  
  27.                 TEXT
  28.  
  29.                 movem.l D1-D5/A0-A1,-(SP) ;save registers
  30.  
  31.                 movea.l 32(SP),A0       ;adress of packed STAD-picture
  32.                 movea.l 36(SP),A1       ;adress of destination (32k)
  33.  
  34. ; ---------------------------------------------------------------------------
  35. ; STAD-Header:
  36. ;   Byte 1-4  string 'pM85' (horizontal packed)
  37. ;                    'pM86' (vertical packed)
  38. ;   Byte 5    ID-Byte
  39. ;   Byte 6    PACK-Byte
  40. ;   Byte 7    SPECIAL-Byte
  41. ;   ....      picture datas
  42. ; ---------------------------------------------------------------------------
  43.  
  44.                 move.b  4(A0),D1        ;read ID-byte
  45.                 move.b  5(A0),D2        ;read PACK-byte
  46.                 move.b  6(A0),D3        ;read SPEC-byte
  47.                 clr.w   D4              ;clear dest.offset
  48.  
  49.                 cmpi.b  #'p',(A0)+      ;first  byte = "p"
  50.                 bne.s   error
  51.                 cmpi.b  #'M',(A0)+      ;second byte = "M"
  52.                 bne.s   error
  53.                 cmpi.b  #'8',(A0)+      ;third  byte = "8"
  54.                 bne.s   error
  55.                 cmpi.b  #'5',(A0)       ;fourth byte = "5"
  56.                 beq.s   h_start         ;-> horizontal packed
  57.                 cmpi.b  #'6',(A0)       ;fourth byte = "6"
  58.                 beq.s   v_start         ;-> vertical packed
  59.  
  60. error:          move.l  #1,D0           ;error 1 = no packed STAD-picture
  61. exit:           movem.l (SP)+,D1-D5/A0-A1 ;restore registers
  62.                 rts
  63.  
  64. ; ---------------------------------------------------------------------------
  65. ; horizontal decompress routine
  66. ; ---------------------------------------------------------------------------
  67.  
  68. h_start:        addq.l  #4,A0           ;length of header
  69. h_read:         move.b  (A0)+,D0        ;read next byte
  70.                 cmp.b   D1,D0           ;ID-Byte?
  71.                 beq.s   h_use_pack      ;yes -> use PACK-byte
  72.                 cmp.b   D3,D0           ;SPEC-Byte?
  73.                 beq.s   h_use_spec      ;yes -> use SPEC-byte
  74.                 move.b  D0,0(A1,D4.w)   ;use Byte "as is"
  75.                 addq.w  #1,D4           ;increment offset
  76. h_cont:         cmpi.w  #32000,D4       ;everything read in?
  77.                 bne.s   h_read          ;no -> read next
  78.  
  79. ready:          clr.l   D0              ;return 0 = everything ok
  80.                 bra.s   exit            ;that's it...
  81.  
  82. ; ---------------------------------------------------------------------------
  83. ; if you got an ID-byte: read next byte (n) and use PACK-Byte n+1 times
  84. ; ---------------------------------------------------------------------------
  85.  
  86. h_use_pack:     move.b  D2,D5           ;PACK-byte to write-byte
  87.                 bra.s   h_unpack        ;...and unpack
  88.  
  89. ; ---------------------------------------------------------------------------
  90. ; if you got a SPEC-byte: read two more byte (d and n) and use the byte d
  91. ; n+1 times
  92. ; ---------------------------------------------------------------------------
  93.  
  94. h_use_spec:     move.b  (A0)+,D5        ;read next byte d
  95.  
  96. h_unpack:       clr.w   D0              ;clear...
  97.                 move.b  (A0)+,D0        ;read quantity
  98.  
  99. h_unpack_1:     move.b  D5,0(A1,D4.w)   ;write byte
  100.                 addq.w  #1,D4
  101.                 cmpi.w  #32000,D4       ;ready?
  102.                 dbeq    D0,h_unpack_1   ;next turn...
  103.                 bra.s   h_cont          ;read next byte from source
  104.  
  105. ; ---------------------------------------------------------------------------
  106. ; verticale decompress routine
  107. ; ---------------------------------------------------------------------------
  108.  
  109. v_start:        addq.l  #4,A0           ;don't read header
  110. v_read:         move.b  (A0)+,D0        ;read byte
  111.                 cmp.b   D1,D0           ;ID-Byte?
  112.                 beq.s   v_use_pack      ;yes -> use PACK-byte
  113.                 cmp.b   D3,D0           ;SPEC-Byte?
  114.                 beq.s   v_use_spec      ;yes -> use SPEC-byte
  115.                 move.b  D0,0(A1,D4.w)   ;use byte "as is"
  116.                 addi.l  #80,D4          ;increment offset
  117.                 cmpi.w  #32000,D4       ;column ready?
  118.                 blo.s   v_read          ;no, continue read
  119.                 subi.w  #31999,D4       ;correct offset to next column
  120.                 cmpi.w  #80,D4          ;everything read in?
  121.                 bne.s   v_read          ;no, continue read
  122.                 bra.s   ready           ;yes -> ready
  123.  
  124. ; ---------------------------------------------------------------------------
  125. ; ...see h_use_pack
  126. ; ---------------------------------------------------------------------------
  127.  
  128. v_use_pack:     move.b  D2,D5           ;PACK-byte to write-byte
  129.                 bra.s   v_unpack        ;...and unpack
  130.  
  131. v_use_spec:     move.b  (A0)+,D5        ;read next byte d
  132. v_unpack:       clr.w   D0              ;clear...
  133.                 move.b  (A0)+,D0        ;read quantity
  134. v_unpack_1:     move.b  D5,0(A1,D4.w)   ;write byte
  135.                 addi.l  #80,D4          ;increment offset
  136.                 cmpi.w  #32000,D4       ;column complete?
  137.                 blo.s   v_unpack_2      ;no, continue read
  138.                 subi.w  #31999,D4       ;yes, correct offset to next column
  139.                 cmpi.w  #80,D4          ;everything read in?
  140.                 beq.s   ready           ;yes, ready
  141. v_unpack_2:     dbra    D0,v_unpack_1   ;...next turn
  142.                 bra.s   v_read          ;read next byte from source
  143.  
  144.  
  145.                 END
  146.