home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / modex32.zip / MKALIGN.ASM < prev    next >
Assembly Source File  |  1994-09-12  |  7KB  |  328 lines

  1.     .386p
  2.     ifndef    ??version
  3. ?debug    macro
  4.     endm
  5.     endif
  6.     ?debug    S "MKALIGN.C"
  7.     ?debug    T "MKALIGN.C"
  8. _TEXT    segment byte public use32 'CODE'
  9. _TEXT    ends
  10. _DATA    segment dword public use32 'DATA'
  11. _DATA    ends
  12. _BSS    segment dword public use32 'BSS'
  13. _BSS    ends
  14. DGROUP    group    _DATA,_BSS
  15.     assume    cs:_TEXT,ds:DGROUP
  16. _TEXT    segment byte public use32 'CODE'
  17. c@    label    byte
  18.     assume    cs:_TEXT
  19. _CreateAlignedMaskedImage       proc    near
  20.    ;    
  21.    ;    unsigned int CreateAlignedMaskedImage(MaskedImage * ImageToSet,
  22.    ;    
  23.     ?debug    L 18
  24. @11@55:
  25.     enter    48,0
  26.     push    edi
  27.     push    esi
  28.    ;    
  29.    ;       unsigned int DispMemStart, char * Image, int ImageWidth,
  30.    ;       int ImageHeight, char * Mask)
  31.    ;    {
  32.    ;       int Align, ScanLine, BitNum, Size, TempImageWidth;
  33.    ;       unsigned char MaskTemp;
  34.    ;       unsigned int DispMemOffset = DispMemStart;
  35.    ;    
  36.     ?debug    L 24
  37. @12@0:
  38.     mov    dword ptr [ebp-4],edx
  39.    ;    
  40.    ;       AlignedMaskedImage *WorkingAMImage;
  41.    ;       char *NewMaskPtr, *OldMaskPtr;
  42.    ;    
  43.    ;       /* Generate each of the four alignments in turn */
  44.    ;       for (Align = 0; Align < 4; Align++) {
  45.    ;    
  46.     ?debug    L 29
  47. @12@28:
  48.     xor    edi,edi
  49.     mov    dword ptr [ebp-8],eax
  50. @12@70:
  51.     mov    dword ptr [ebp-12],edx
  52. @12@99:
  53.     mov    dword ptr [ebp-16],ebx
  54. @12@128:
  55.     jmp    near ptr @28
  56. @13:
  57.    ;    
  58.    ;    
  59.    ;          /* Allocate space for the AlignedMaskedImage struct for this
  60.    ;             alignment */
  61.    ;          if ((WorkingAMImage = ImageToSet->Alignments[Align] =
  62.    ;    
  63.     ?debug    L 33
  64.     push    12
  65.     call    near ptr MALLOC
  66.     lea    edx,dword ptr [edi*4]
  67.     mov    ecx,dword ptr [ebp-8]
  68. @13@89:
  69.     mov    dword ptr [ecx+edx],eax
  70.     mov    esi,eax
  71.     test    esi,esi
  72.     jne    short @15
  73.    ;    
  74.    ;                malloc(sizeof(AlignedMaskedImage))) == NULL)
  75.    ;             return 0;
  76.    ;    
  77.     ?debug    L 35
  78.     xor    eax,eax
  79.     ?debug    L 76
  80.     jmp    near ptr @31
  81. @15:
  82.    ;    
  83.    ;    
  84.    ;          WorkingAMImage->ImageWidth =
  85.    ;    
  86.     ?debug    L 37
  87.     mov    eax,dword ptr [ebp+16]
  88.     lea    edx,dword ptr [eax+edi]
  89.     add    edx,3
  90.     mov    eax,edx
  91.     mov    ecx,4
  92.     cdq
  93.     idiv    ecx
  94.     mov    dword ptr [esi],eax
  95.    ;    
  96.    ;                (ImageWidth + Align + 3) / 4; /* width in 4-pixel sets */
  97.    ;    
  98.    ;          WorkingAMImage->ImagePtr = DispMemOffset; /* image dest */
  99.    ;    
  100.     ?debug    L 40
  101.     mov    eax,dword ptr [ebp-4]
  102.     mov    dword ptr [esi+4],eax
  103.    ;    
  104.    ;    
  105.    ;          /* Download this alignment of the image */
  106.    ;          CopySystemToScreenX(0, 0, ImageWidth, ImageHeight, Align, 0,
  107.    ;    
  108.     ?debug    L 43
  109.     mov    edx,dword ptr [esi]
  110.     shl    edx,2
  111.     push    dword ptr [ebp+12]
  112.     push    edi
  113.     push    0
  114.     push    dword ptr [ebp-16]
  115.     push    eax
  116.     mov    eax,dword ptr [ebp+16]
  117.     push    eax
  118.     push    edx
  119.     xor    eax,eax
  120.     xor    edx,edx
  121.     mov    dword ptr [ebp-20],ebx
  122.     mov    ebx,dword ptr [ebp+16]
  123.         call    near ptr _CopySystemToScreenX
  124.    ;    
  125.    ;                Image, DispMemOffset, ImageWidth,
  126.    ;                WorkingAMImage->ImageWidth * 4);
  127.    ;    
  128.    ;          /* Calculate the number of bytes needed to store the mask in
  129.    ;             nibble (Map Mask-ready) form, then allocate that space */
  130.    ;          Size = WorkingAMImage->ImageWidth * ImageHeight;
  131.    ;    
  132.     ?debug    L 49
  133.     mov    eax,dword ptr [esi]
  134.     imul    eax,dword ptr [ebp+12]
  135.    ;    
  136.    ;    
  137.    ;          if ((WorkingAMImage->MaskPtr = malloc(Size)) == NULL)
  138.    ;    
  139.     ?debug    L 51
  140. @16@35:
  141.     mov    edx,eax
  142.     push    edx
  143.     mov    dword ptr [ebp-24],eax
  144. @16@89:
  145.     call    near ptr MALLOC
  146.     mov    dword ptr [esi+8],eax
  147.     test    eax,eax
  148.     jne    short @18
  149.    ;    
  150.    ;             return 0;
  151.    ;    
  152.     ?debug    L 52
  153.     xor    eax,eax
  154.     ?debug    L 76
  155.     jmp    near ptr @31
  156. @18:
  157.    ;    
  158.    ;    
  159.    ;          /* Generate this nibble oriented (Map Mask-ready) alignment of
  160.    ;             the mask, one scan line at a time */
  161.    ;          OldMaskPtr = Mask;
  162.    ;    
  163.     ?debug    L 56
  164.     mov    eax,dword ptr [ebp+8]
  165.    ;    
  166.    ;          NewMaskPtr = WorkingAMImage->MaskPtr;
  167.    ;    
  168.     ?debug    L 57
  169. @18@28:
  170.     mov    edx,dword ptr [esi+8]
  171.    ;    
  172.    ;          for (ScanLine = 0; ScanLine < ImageHeight; ScanLine++) {
  173.    ;    
  174.     ?debug    L 58
  175. @18@56:
  176.     mov    dword ptr [ebp-28],0
  177. @18@83:
  178.     mov    dword ptr [ebp-32],eax
  179. @18@112:
  180.     mov    dword ptr [ebp-36],edx
  181. @18@141:
  182.     jmp    short @26
  183. @19:
  184.    ;    
  185.    ;             BitNum = Align;
  186.    ;    
  187.     ?debug    L 59
  188.     mov    ebx,edi
  189.    ;    
  190.    ;             MaskTemp = 0;
  191.    ;    
  192.     ?debug    L 60
  193.     mov    byte ptr [ebp-40],0
  194.    ;    
  195.    ;             TempImageWidth = ImageWidth;
  196.    ;    
  197.     ?debug    L 61
  198. @19@40:
  199.     mov    eax,dword ptr [ebp+16]
  200. @19@69:
  201.     mov    dword ptr [ebp-44],eax
  202. @19@98:
  203. @20:
  204.    ;    
  205.    ;             do {
  206.    ;                /* Set the mask bit for next pixel according to its alignment */
  207.    ;                MaskTemp |= (*OldMaskPtr++ != 0) << BitNum;
  208.    ;    
  209.     ?debug    L 64
  210.     mov    eax,dword ptr [ebp-32]
  211. @20@29:
  212.     cmp    byte ptr [eax],0
  213.     setne    dl
  214.     movzx    edx,dl
  215.     mov    ecx,ebx
  216.     mov    dword ptr [ebp-48],ecx
  217.     mov    ecx,dword ptr [ebp-48]
  218.     shl    dl,cl
  219.     or    byte ptr [ebp-40],dl
  220. @20@188:
  221.     inc    eax
  222.    ;    
  223.    ;                if (++BitNum > 3) {
  224.    ;    
  225.     ?debug    L 65
  226. @20@198:
  227.     inc    ebx
  228.     cmp    ebx,3
  229.     mov    dword ptr [ebp-32],eax
  230. @20@249:
  231.     jle    short @22
  232.    ;    
  233.    ;                   *NewMaskPtr++ = MaskTemp;
  234.    ;    
  235.     ?debug    L 66
  236.     mov    al,byte ptr [ebp-40]
  237.     mov    edx,dword ptr [ebp-36]
  238. @21@56:
  239.     mov    byte ptr [edx],al
  240.     inc    edx
  241.    ;    
  242.    ;                   MaskTemp = BitNum = 0;
  243.    ;    
  244.     ?debug    L 67
  245. @21@90:
  246.     xor    ebx,ebx
  247.     mov    byte ptr [ebp-40],bl
  248. @21@131:
  249.     mov    dword ptr [ebp-36],edx
  250. @21@160:
  251. @22:
  252.    ;    
  253.    ;                }
  254.    ;             } while (--TempImageWidth);
  255.    ;    
  256.     ?debug    L 69
  257.     dec    dword ptr [ebp-44]
  258. @22@25:
  259.     cmp    dword ptr [ebp-44],0
  260.     jne    short @20
  261.    ;    
  262.    ;             /* Set any partial final mask on this scan line */
  263.    ;             if (BitNum != 0) *NewMaskPtr++ = MaskTemp;
  264.    ;    
  265.     ?debug    L 71
  266.     test    ebx,ebx
  267.     je    short @25
  268.     mov    al,byte ptr [ebp-40]
  269.     mov    edx,dword ptr [ebp-36]
  270. @24@56:
  271.     mov    byte ptr [edx],al
  272.     inc    edx
  273. @24@90:
  274.     mov    dword ptr [ebp-36],edx
  275. @24@119:
  276. @25:
  277.     ?debug    L 58
  278.     inc    dword ptr [ebp-28]
  279. @25@25:
  280. @26:
  281.     mov    eax,dword ptr [ebp+12]
  282.     cmp    dword ptr [ebp-28],eax
  283.     jl    short @19
  284.    ;    
  285.    ;          }
  286.    ;          DispMemOffset += Size; /* mark off the space we just used */
  287.    ;    
  288.     ?debug    L 73
  289.     mov    eax,dword ptr [ebp-24]
  290.     add    dword ptr [ebp-4],eax
  291.     ?debug    L 29
  292. @27@57:
  293.     inc    edi
  294. @28:
  295.     cmp    edi,4
  296.     jl    near ptr @13
  297.    ;    
  298.    ;       }
  299.    ;       return DispMemOffset - DispMemStart;
  300.    ;    
  301.     ?debug    L 75
  302.     mov    eax,dword ptr [ebp-4]
  303.     sub    eax,dword ptr [ebp-12]
  304.     ?debug    L 76
  305. @31:
  306. @31@0:
  307.     pop    esi
  308.     pop    edi
  309.     leave
  310.     ret    12
  311. _CreateAlignedMaskedImage       endp
  312. _TEXT    ends
  313.     extrn    MALLOC:near
  314.         extrn   _CopySystemToScreenX:near
  315.         public  _CreateAlignedMaskedImage
  316. _DATA    segment dword public use32 'DATA'
  317. d@    label    byte
  318. d@w    label    word
  319. d@d    label    dword
  320. s@    label    byte
  321. _DATA    ends
  322. _BSS    segment dword public use32 'BSS'
  323. b@    label    byte
  324. b@w    label    word
  325. b@d    label    dword
  326. _BSS    ends
  327.     end
  328.