IMPLEMENTATION MODULE GFXBits;

(*
  Author............Jürgen Weinelt
                    Zur Kanzel 1
                    W-8783 Hammelburg
                    Germany

  Creation date.....20-OCT-90
  Language used.....Modula-2
  Compiler used.....M2Amiga V4.0 by A+L AG, Switzerland

  Description.......convert image strings to longcards.
                    image strings contain pixel information for
                    image rendering (e.g. gadgets). each string
                    element describes one pixel.
                    examples:
                       2-color image string:
                          "11010001010110101011101000111001"
                      32-color image string:
                          "6324A987OSJDN9S8FRCGK38E7SJKPT56"

  Last changed......26-SEP-91
*)



IMPORT R;
IMPORT SYSTEM;



CONST
 xxxrev=0020;



PROCEDURE DecodeLine(str: DataStr; VAR line{R.A3}: MLine);
 BEGIN
  SYSTEM.ASSEMBLE(RELOCATION
        MOVEQ   #0,D0
char_conv_loop:
        MOVEQ   #0,D1
        MOVE.B  str(A5,D0.W),D1
        TST.B   D1
        BEQ     blank_str
        CMP.B   #"0",D1
        BLT     char_conv_fail
        CMP.B   #"9",D1
        BGT     not_numeric
        SUB.W   #"0",D1
        BRA     char_conv_chardone
not_numeric:
        CMP.B   #"A",D1
        BLT     char_conv_fail
        CMP.B   #"V",D1
        BGT     not_lochar
        SUB.W   #"A"-10,D1
        BRA     char_conv_chardone
not_lochar:
        CMP.B   #"a",D1
        BLT     char_conv_fail
        CMP.B   #"v",D1
        BGT     char_conv_fail
        SUB.W   #"a"-10,D1
        BRA     char_conv_chardone
char_conv_fail:
        MOVEQ   #0,D1
char_conv_chardone:
        MOVE.B  D1,str(A5,D0.W)
        ADDQ.W  #1,D0
        CMP.W   #160,D0
        BNE     char_conv_loop
        BRA     decode

blank_str:
        MOVEQ   #0,D1
blank_str_loop:
        MOVE.B  D1,str(A5,D0.W)
        ADDQ.W  #1,D0
        CMP.W   #160,D0
        BLE     blank_str_loop

decode:
        MOVE.W  #159,D3

charloop:
        MOVE.B  str(A5,D3.W),D0

        MOVE.L  A3,A0
        MOVEQ   #4,D1

bitloop:
        MOVEQ   #4,D2
        ROXR.W  #1,D0
shiftloop:
(* COMPILERFEHLER!!!
        ROXR.W  (A0)+
*)
        MOVE.L  (A0),D4
        ROXR.L  #1,D4
        MOVE.L  D4,(A0)+
        DBRA    D2,shiftloop
        DBRA    D1,bitloop
        DBRA    D3,charloop

  END);
 END DecodeLine;



END GFXBits.
