Annotation of ntddk/src/video/displays/vga/i386/brushes.asm, revision 1.1

1.1     ! root        1:                 .386
        !             2: 
        !             3: ifndef  DOS_PLATFORM
        !             4:         .model  small,c
        !             5: else
        !             6: ifdef   STD_CALL
        !             7:         .model  small,c
        !             8: else
        !             9:         .model  small,pascal
        !            10: endif;  STD_CALL
        !            11: endif;  DOS_PLATFORM
        !            12: 
        !            13:         assume cs:FLAT,ds:FLAT,es:FLAT,ss:FLAT
        !            14:         assume fs:nothing,gs:nothing
        !            15: 
        !            16:         .xlist
        !            17:         include stdcall.inc             ;calling convention cmacros
        !            18:         include i386\egavga.inc
        !            19:         include i386\strucs.inc
        !            20:         include i386\ropdefs.inc
        !            21:         include i386\display.inc         ; Display specific structures
        !            22: 
        !            23:         .list
        !            24: 
        !            25: ;-----------------------------------------------------------------------;
        !            26: 
        !            27:         .data
        !            28: 
        !            29:         align        4
        !            30: ifdef LATER
        !            31:         public  CmpPlanes
        !            32: CmpPlanes  label dword
        !            33:         dd      check_plane_1
        !            34:         dd      check_plane_2
        !            35:         dd      check_plane_3
        !            36:         dd      0
        !            37: endif;LATER
        !            38: 
        !            39:         public  pCountTable
        !            40: pCountTable  label dword
        !            41:         dd      1h
        !            42:         dd      2h
        !            43:         dd      4h
        !            44:         dd      8h
        !            45:         dd      10h
        !            46:         dd      20h
        !            47:         dd      40h
        !            48:         dd      80h
        !            49:         dd      100h
        !            50:         dd      200h
        !            51:         dd      400h
        !            52:         dd      800h
        !            53:         dd      1000h
        !            54:         dd      2000h
        !            55:         dd      4000h
        !            56:         dd      8000h
        !            57: 
        !            58:         align        4
        !            59:         public  pPixelCount
        !            60: pPixelCount label dword
        !            61:         dd      0                ;//0
        !            62:         dd      1                ;//1
        !            63:         dd      1                ;//2
        !            64:         dd      2                ;//3
        !            65:         dd      1                ;//4
        !            66:         dd      2                ;//5
        !            67:         dd      2                ;//6
        !            68:         dd      3                ;//7
        !            69:         dd      1                ;//8
        !            70:         dd      2                ;//9
        !            71:         dd      2                ;//10
        !            72:         dd      3                ;//11
        !            73:         dd      2                ;//12
        !            74:         dd      3                ;//13
        !            75:         dd      3                ;//14
        !            76:         dd      3                ;//15
        !            77:         dd      4                ;//16
        !            78: 
        !            79:         align        4
        !            80: PackedToPlanar0  label dword
        !            81:         dd      0               ;//0
        !            82:         dd      00000001h       ;//1
        !            83:         dd      00000100h       ;//2
        !            84:         dd      00000101h       ;//3
        !            85:         dd      00010000h       ;//4
        !            86:         dd      00010001h       ;//5
        !            87:         dd      00010100h       ;//6
        !            88:         dd      00010101h       ;//7
        !            89:         dd      01000000h       ;//8
        !            90:         dd      01000001h       ;//9
        !            91:         dd      01000100h       ;//10
        !            92:         dd      01000101h       ;//11
        !            93:         dd      01010000h       ;//12
        !            94:         dd      01010001h       ;//13
        !            95:         dd      01010100h       ;//14
        !            96:         dd      01010101h       ;//15
        !            97: 
        !            98:         align    4
        !            99: PackedToPlanar1 label dword
        !           100:         dd      0                 ;//0
        !           101:         dd      (00000001h SHL 1) ;//1
        !           102:         dd      (00000100h SHL 1) ;//2
        !           103:         dd      (00000101h SHL 1) ;//3
        !           104:         dd      (00010000h SHL 1) ;//4
        !           105:         dd      (00010001h SHL 1) ;//5
        !           106:         dd      (00010100h SHL 1) ;//6
        !           107:         dd      (00010101h SHL 1) ;//7
        !           108:         dd      (01000000h SHL 1) ;//8
        !           109:         dd      (01000001h SHL 1) ;//9
        !           110:         dd      (01000100h SHL 1) ;//10
        !           111:         dd      (01000101h SHL 1) ;//11
        !           112:         dd      (01010000h SHL 1) ;//12
        !           113:         dd      (01010001h SHL 1) ;//13
        !           114:         dd      (01010100h SHL 1) ;//14
        !           115:         dd      (01010101h SHL 1) ;//15
        !           116: 
        !           117:         align   4
        !           118: PackedToPlanar2 label dword
        !           119:         dd      0                 ;//0
        !           120:         dd      (00000001h SHL 2) ;//1
        !           121:         dd      (00000100h SHL 2) ;//2
        !           122:         dd      (00000101h SHL 2) ;//3
        !           123:         dd      (00010000h SHL 2) ;//4
        !           124:         dd      (00010001h SHL 2) ;//5
        !           125:         dd      (00010100h SHL 2) ;//6
        !           126:         dd      (00010101h SHL 2) ;//7
        !           127:         dd      (01000000h SHL 2) ;//8
        !           128:         dd      (01000001h SHL 2) ;//9
        !           129:         dd      (01000100h SHL 2) ;//10
        !           130:         dd      (01000101h SHL 2) ;//11
        !           131:         dd      (01010000h SHL 2) ;//12
        !           132:         dd      (01010001h SHL 2) ;//13
        !           133:         dd      (01010100h SHL 2) ;//14
        !           134:         dd      (01010101h SHL 2) ;//15
        !           135: 
        !           136:         align        4
        !           137: PackedToPlanar3         label dword
        !           138:         dd      0                        ;//0
        !           139:         dd      (00000001h SHL 3) ;//1
        !           140:         dd      (00000100h SHL 3) ;//2
        !           141:         dd      (00000101h SHL 3) ;//3
        !           142:         dd      (00010000h SHL 3) ;//4
        !           143:         dd      (00010001h SHL 3) ;//5
        !           144:         dd      (00010100h SHL 3) ;//6
        !           145:         dd      (00010101h SHL 3) ;//7
        !           146:         dd      (01000000h SHL 3) ;//8
        !           147:         dd      (01000001h SHL 3) ;//9
        !           148:         dd      (01000100h SHL 3) ;//10
        !           149:         dd      (01000101h SHL 3) ;//11
        !           150:         dd      (01010000h SHL 3) ;//12
        !           151:         dd      (01010001h SHL 3) ;//13
        !           152:         dd      (01010100h SHL 3) ;//14
        !           153:         dd      (01010101h SHL 3) ;//15
        !           154: 
        !           155:         align        4
        !           156: PackedToPlanar4         label dword
        !           157:         dd      0                        ;//0
        !           158:         dd      (00000001h SHL 4) ;//1
        !           159:         dd      (00000100h SHL 4) ;//2
        !           160:         dd      (00000101h SHL 4) ;//3
        !           161:         dd      (00010000h SHL 4) ;//4
        !           162:         dd      (00010001h SHL 4) ;//5
        !           163:         dd      (00010100h SHL 4) ;//6
        !           164:         dd      (00010101h SHL 4) ;//7
        !           165:         dd      (01000000h SHL 4) ;//8
        !           166:         dd      (01000001h SHL 4) ;//9
        !           167:         dd      (01000100h SHL 4) ;//10
        !           168:         dd      (01000101h SHL 4) ;//11
        !           169:         dd      (01010000h SHL 4) ;//12
        !           170:         dd      (01010001h SHL 4) ;//13
        !           171:         dd      (01010100h SHL 4) ;//14
        !           172:         dd      (01010101h SHL 4) ;//15
        !           173: 
        !           174:         align        4
        !           175: PackedToPlanar5         label dword
        !           176:         dd      0                        ;//0
        !           177:         dd      (00000001h SHL 5) ;//1
        !           178:         dd      (00000100h SHL 5) ;//2
        !           179:         dd      (00000101h SHL 5) ;//3
        !           180:         dd      (00010000h SHL 5) ;//4
        !           181:         dd      (00010001h SHL 5) ;//5
        !           182:         dd      (00010100h SHL 5) ;//6
        !           183:         dd      (00010101h SHL 5) ;//7
        !           184:         dd      (01000000h SHL 5) ;//8
        !           185:         dd      (01000001h SHL 5) ;//9
        !           186:         dd      (01000100h SHL 5) ;//10
        !           187:         dd      (01000101h SHL 5) ;//11
        !           188:         dd      (01010000h SHL 5) ;//12
        !           189:         dd      (01010001h SHL 5) ;//13
        !           190:         dd      (01010100h SHL 5) ;//14
        !           191:         dd      (01010101h SHL 5) ;//15
        !           192: 
        !           193:         align        4
        !           194: PackedToPlanar6         label dword
        !           195:         dd      0                        ;//0
        !           196:         dd      (00000001h SHL 6) ;//1
        !           197:         dd      (00000100h SHL 6) ;//2
        !           198:         dd      (00000101h SHL 6) ;//3
        !           199:         dd      (00010000h SHL 6) ;//4
        !           200:         dd      (00010001h SHL 6) ;//5
        !           201:         dd      (00010100h SHL 6) ;//6
        !           202:         dd      (00010101h SHL 6) ;//7
        !           203:         dd      (01000000h SHL 6) ;//8
        !           204:         dd      (01000001h SHL 6) ;//9
        !           205:         dd      (01000100h SHL 6) ;//10
        !           206:         dd      (01000101h SHL 6) ;//11
        !           207:         dd      (01010000h SHL 6) ;//12
        !           208:         dd      (01010001h SHL 6) ;//13
        !           209:         dd      (01010100h SHL 6) ;//14
        !           210:         dd      (01010101h SHL 6) ;//15
        !           211: 
        !           212:         align  4
        !           213: PackedToPlanar7         label dword
        !           214:         dd      0                        ;//0
        !           215:         dd      (00000001h SHL 7) ;//1
        !           216:         dd      (00000100h SHL 7) ;//2
        !           217:         dd      (00000101h SHL 7) ;//3
        !           218:         dd      (00010000h SHL 7) ;//4
        !           219:         dd      (00010001h SHL 7) ;//5
        !           220:         dd      (00010100h SHL 7) ;//6
        !           221:         dd      (00010101h SHL 7) ;//7
        !           222:         dd      (01000000h SHL 7) ;//8
        !           223:         dd      (01000001h SHL 7) ;//9
        !           224:         dd      (01000100h SHL 7) ;//10
        !           225:         dd      (01000101h SHL 7) ;//11
        !           226:         dd      (01010000h SHL 7) ;//12
        !           227:         dd      (01010001h SHL 7) ;//13
        !           228:         dd      (01010100h SHL 7) ;//14
        !           229:         dd      (01010101h SHL 7) ;//15
        !           230: 
        !           231: 
        !           232: 
        !           233:         .code
        !           234: 
        !           235: ;==============================================================================
        !           236: ; CountColors(pBuffer, Count)
        !           237: ;
        !           238: ; This routine will count the number of unique colors in a packed pel 4bpp
        !           239: ; bitmap. The total number of colors is returned.
        !           240: ;
        !           241: ;==============================================================================
        !           242: 
        !           243: _TEXT$03   SEGMENT DWORD USE32 PUBLIC 'CODE'
        !           244:            ASSUME  CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
        !           245: 
        !           246: cProc   CountColors,16,<     \
        !           247:         uses esi edi ebx,   \
        !           248:         pBuffer: ptr dword, \
        !           249:         count:dword,        \
        !           250:         pColors: ptr dword, \
        !           251:         cbScan: dword       >
        !           252: 
        !           253:         ; This could be much faster. This routine really only needs to
        !           254:         ; find out if there are two colors and return those two colors.
        !           255:         ; If there are more, we can just return.
        !           256: 
        !           257:         mov     ecx,8
        !           258:         mov     esi,pBuffer
        !           259:         lea     edi,pCountTable
        !           260:         xor     edx,edx
        !           261: 
        !           262: 
        !           263: @@:     mov     ebx,[esi]               ; read in a dword of the bitmap
        !           264: 
        !           265:         rept    7
        !           266: 
        !           267:         mov     eax,ebx                 ;copy colors to eax
        !           268:         and     eax,0fh                 ;isolate nibble
        !           269:         shr     ebx,4                   ;remove current nibble from ebx
        !           270:         or      edx,[edi+eax*4]         ;or color count flags into edx
        !           271:         endm    ;-----------------------
        !           272: 
        !           273:         or      edx,[edi+ebx*4]         ;do last nibble
        !           274: 
        !           275:         cmp     count,16                ;if this is 16x8 we need to
        !           276:         jne     short continue_count    ; process the second dword on this
        !           277:                                         ; scan.
        !           278: 
        !           279:         rept    7
        !           280: 
        !           281:         mov     ebx,[esi+4]             ;read second dword
        !           282:         mov     eax,ebx                 ;copy colors to eax
        !           283:         and     eax,0fh                 ;isolate nibble
        !           284:         shr     ebx,4                   ;remove current nibble from ebx
        !           285:         or      edx,[edi+eax*4]         ;or color count flags into edx
        !           286:         endm    ;-----------------------
        !           287: 
        !           288:         or      edx,[edi+ebx*4]         ;do last nibble
        !           289: continue_count:
        !           290:         add     esi,cbScan
        !           291:         dec     ecx                     ;do next dword
        !           292:         jnz     @b
        !           293: 
        !           294:         ; Now count the number of bits on in each nibble
        !           295: 
        !           296:         mov     ecx,edx                    ;save bit mask
        !           297:         mov     ebx,edx
        !           298:         shr     edx,4
        !           299:         and     ebx,0fh
        !           300:         mov     eax,pPixelCount[ebx*4]
        !           301: 
        !           302:         mov     ebx,edx
        !           303:         shr     edx,4
        !           304:         and     ebx,0fh
        !           305:         add     eax,pPixelCount[ebx*4]
        !           306: 
        !           307:         mov     ebx,edx
        !           308:         shr     edx,4
        !           309:         and     ebx,0fh
        !           310:         add     eax,pPixelCount[ebx*4]
        !           311: 
        !           312:         add     eax,pPixelCount[edx*4]
        !           313: 
        !           314:         cmp     eax,2
        !           315:         jne     short cc_exit
        !           316: 
        !           317:         mov     al,16
        !           318: 
        !           319: @@:     dec     al
        !           320:         add     cx,cx
        !           321:         jnc     @b
        !           322:         mov     ah,al
        !           323: 
        !           324: @@:     dec     al
        !           325:         add     cx,cx
        !           326:         jnc     @b
        !           327: 
        !           328:         mov     edi,pColors
        !           329:         mov     [edi],ax
        !           330:         mov     ax,2
        !           331: cc_exit:
        !           332:         cRet    CountColors
        !           333: 
        !           334: endProc CountColors
        !           335: 
        !           336: ;==============================================================================
        !           337: ; bQuickPattern
        !           338: ;
        !           339: ; We special case patterns that are repeating two line patterns (like the
        !           340: ; grey/hatch brush). This allows us to do two passes instead of eight in the
        !           341: ; venetian blind patblt code.
        !           342: ;
        !           343: ;==============================================================================
        !           344: 
        !           345: cProc   bQuickPattern,8,<     \
        !           346:         uses edi,           \
        !           347:         pBuffer: ptr dword, \
        !           348:         count:dword         >
        !           349: 
        !           350:         ; Count must be 8 or 16;
        !           351: 
        !           352:         xor     eax,eax         ;Set ret value to false
        !           353:         mov     edi,pBuffer     ;get pointer to pattern
        !           354:         mov     edx,[edi]       ;Get first dword (first two lines of pattern)
        !           355:         mov     ecx,count       ;dword count
        !           356: 
        !           357: qp_loop:
        !           358: INDEX=4
        !           359:         rept    7
        !           360:         cmp     edx,[edi+INDEX]
        !           361:         jne     short qp_exit
        !           362: INDEX=INDEX+4
        !           363:         endm    ;----------------------
        !           364: 
        !           365:         sub     ecx,8
        !           366:         jz      exit_true
        !           367: 
        !           368:         add     edi,32
        !           369:         cmp     edx,[edi]
        !           370:         jne     short qp_exit
        !           371:         jmp     short qp_loop
        !           372: 
        !           373: exit_true:
        !           374:         inc     eax
        !           375: qp_exit:
        !           376:         cRet    bQuickPattern
        !           377: endProc bQuickPattern
        !           378: 
        !           379: _TEXT$03       ends
        !           380: 
        !           381:         .code
        !           382: 
        !           383: ;==============================================================================
        !           384: ; bShrinkPattern
        !           385: ;
        !           386: ; Test to see if we can shrink an 16x8 pattern to an 8x8 pattern.
        !           387: ;
        !           388: ;==============================================================================
        !           389: 
        !           390: cProc   bShrinkPattern,8,<     \
        !           391:         uses edi,           \
        !           392:         pBuffer: ptr dword, \
        !           393:         cbScan:dword         >
        !           394: 
        !           395:         xor     eax,eax
        !           396:         mov     ecx,cbScan
        !           397:         mov     edi,pBuffer        ;get pointer to pattern
        !           398: 
        !           399:         rept     8
        !           400:         mov     edx,[edi]
        !           401:         cmp     edx,[edi+4]
        !           402:         jne     @f
        !           403:         add     edi,ecx
        !           404:         endm     ;---------------
        !           405: 
        !           406:         inc     eax
        !           407: @@:
        !           408: 
        !           409:         cRet        bShrinkPattern
        !           410: endProc bShrinkPattern
        !           411: 
        !           412: ;==============================================================================
        !           413: ;vMono8Wide
        !           414: ;
        !           415: ; Copies an 8x8 pattern to a 16x16 buffer
        !           416: ;
        !           417: ;==============================================================================
        !           418: 
        !           419: _TEXT$04   SEGMENT DWORD USE32 PUBLIC 'CODE'
        !           420:            ASSUME  CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
        !           421: 
        !           422: cProc   vMono8Wide,12,<        \
        !           423:         uses ebx edi esi,      \
        !           424:         pDest: ptr dword,      \
        !           425:         pBuffer: ptr dword,    \
        !           426:         cbScan:ptr dword      >
        !           427: 
        !           428:         mov     edi,pDest                         ;Load up edi with our dest
        !           429:         mov     esi,pBuffer                        ;load esi with the source
        !           430:         mov     ebx,cbScan                        ;dest line delta
        !           431: 
        !           432:         rept     8
        !           433: 
        !           434:         mov     al,[esi]                        ;Read in first line of pattern
        !           435:         add     esi,ebx                                ;inc dest pointer
        !           436:         mov     ah,al                                ;make pattern 16 wide
        !           437:         mov     [edi],ax                        ;write first line of pattern
        !           438:         add     edi,2
        !           439:         endm     ;----------------------
        !           440: 
        !           441:         cRet vMono8Wide
        !           442: endProc vMono8Wide
        !           443: 
        !           444: _TEXT$04       ends
        !           445: 
        !           446:         .code
        !           447: 
        !           448: ;==============================================================================
        !           449: ;vMono16Wide
        !           450: ;
        !           451: ; Copies an 16x8 pattern to a 16x16 buffer
        !           452: ;
        !           453: ;==============================================================================
        !           454: 
        !           455: cProc   vMono16Wide,12,<       \
        !           456:         uses ebx edi esi,      \
        !           457:         pDest: ptr dword,      \
        !           458:         pBuffer: ptr dword,    \
        !           459:         cbScan:ptr dword       >
        !           460: 
        !           461:         mov     edi,pDest                         ;Load up edi with our dest
        !           462:         mov     esi,pBuffer                        ;load esi with the source
        !           463:         mov     ebx,cbScan                        ;dest line delta
        !           464: 
        !           465:         rept     8
        !           466: 
        !           467:         mov     ax,[esi]                        ;Read in first line of pattern
        !           468:         add     esi,ebx                                ;inc dest pointer
        !           469:         mov     [edi],ax                        ;write first line of pattern
        !           470:         add     edi,2
        !           471: 
        !           472:         endm        ;----------------------
        !           473: 
        !           474:         cRet vMono16Wide
        !           475: endProc vMono16Wide
        !           476: 
        !           477: cProc   vMono4Wide,12,<        \
        !           478:         uses ebx edi esi,      \
        !           479:         pDest: ptr dword,      \
        !           480:         pBuffer: ptr dword,    \
        !           481:         cbScan:ptr dword       >
        !           482: 
        !           483:         nop
        !           484: 
        !           485:         cRet vMono4Wide
        !           486: endProc vMono4Wide
        !           487: 
        !           488: cProc   vMono2Wide,12,<        \
        !           489:         uses ebx edi esi,      \
        !           490:         pDest: ptr dword,      \
        !           491:         pBuffer: ptr dword,    \
        !           492:         cbScan:ptr dword       >
        !           493: 
        !           494:         nop
        !           495: 
        !           496:         cRet vMono2Wide
        !           497: endProc vMono2Wide
        !           498: 
        !           499: ;==============================================================================
        !           500: ; Brush2ColorToMono
        !           501: ;
        !           502: ;
        !           503: ;==============================================================================
        !           504: 
        !           505: _TEXT$01   SEGMENT DWORD USE32 PUBLIC 'CODE'
        !           506:            ASSUME  CS:FLAT, DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
        !           507: 
        !           508: cProc   vBrush2ColorToMono,20,<  \
        !           509:         uses esi edi ebx,      \
        !           510:         pDest: ptr dword,      \
        !           511:         pSrc: ptr dword,       \
        !           512:         cbScan: dword,         \
        !           513:         ulWidth: dword,               \
        !           514:         jColor: dword          >
        !           515: 
        !           516:         local ulHeight : dword
        !           517: 
        !           518:         mov     ulHeight,8
        !           519: 
        !           520:         ;This routine relies on this: It only works on an 8x8
        !           521:         ;two color 4bpp packed pel pattern. It creates a 1bpp bitmap
        !           522:         ;with the foreground color being the smaller of the two numbers.
        !           523:         ;This is key because the way we set the bit in the monochrome bmp
        !           524:         ;is by comparing the background color (the larger of the two colors)
        !           525:         ;with the current nibble. If this nibble contains the foreground
        !           526:         ;color (the smaller color) then a carry will result from the compare.
        !           527:         ;We then use adc ebx,ebx to set the lsb to zero or one depending on
        !           528:         ;the result of the compare and also to shift ebx left by one.
        !           529: 
        !           530:         mov     ecx,jColor    ;jColor is the larger of the two colors
        !           531:         mov     ch,cl         ;Save jcolor in cl for comparisions with the low
        !           532:         shl     ch,4          ;nibble and ch for the high nibble
        !           533: 
        !           534:         mov     edi,pDest     ;Load Dest
        !           535:         mov     esi,pSrc      ;Load Src
        !           536:         mov     edx,cbScan
        !           537: 
        !           538:         cmp     ulWidth,8
        !           539:         jnz     do_16_wide
        !           540: 
        !           541: x8_wide_loop:
        !           542: SRCINDEX=0
        !           543:         xor     ebx,ebx         ;clear out place where we store the dest byte.
        !           544:         rept    4
        !           545:         mov     al,[esi+SRCINDEX] ;get src byte
        !           546:         cmp     al,ch             ;Is the top nibble fg or bk?
        !           547:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           548:         and     al,0fh            ;mask off high nibble
        !           549:         cmp     al,cl             ;Is the bottom nibble fg or bk?
        !           550:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           551: SRCINDEX=SRCINDEX+1
        !           552:         endm        ;------------------
        !           553:         add     esi,edx           ;increment src to next line
        !           554: 
        !           555:         mov     [edi],bl          ;Write out first byte (8 Pixels)
        !           556:         mov     [edi+1],bl        ;We expand this to 16 pixels
        !           557:         add     edi,2
        !           558: 
        !           559:         dec     ulHeight
        !           560:         jnz     x8_wide_loop
        !           561:         jmp     convert_exit
        !           562: 
        !           563: 
        !           564: do_16_wide:
        !           565: x16_wide_loop:
        !           566:         xor     ebx,ebx         ;clear out place where we store the dest byte.
        !           567: 
        !           568: SRCINDEX=0
        !           569:         rept    4
        !           570:         mov     al,[esi+SRCINDEX] ;get src byte
        !           571:         cmp     al,ch             ;Is the top nibble fg or bk?
        !           572:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           573:         and     al,0fh            ;mask off high nibble
        !           574:         cmp     al,cl             ;Is the bottom nibble fg or bk?
        !           575:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           576: SRCINDEX=SRCINDEX+1
        !           577:         endm        ;------------------
        !           578: 
        !           579:         mov     [edi],bl          ;Write out first byte (8 Pixels)
        !           580:         inc     edi
        !           581:         xor     ebx,ebx           ;clear out place where we store the dest byte.
        !           582: 
        !           583:         rept    4
        !           584:         mov     al,[esi+SRCINDEX] ;get src byte
        !           585:         cmp     al,ch             ;Is the top nibble fg or bk?
        !           586:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           587:         and     al,0fh            ;mask off high nibble
        !           588:         cmp     al,cl             ;Is the bottom nibble fg or bk?
        !           589:         adc     ebx,ebx           ;carry will be set if fg. Set bit in mask
        !           590: SRCINDEX=SRCINDEX+1
        !           591:         endm        ;------------------
        !           592: 
        !           593:         add     esi,edx           ;increment src to next line
        !           594:         mov     [edi],bl          ;Write out Second byte (8 Pixels)
        !           595:         inc     edi
        !           596:         dec     ulHeight
        !           597:         jnz     x16_wide_loop
        !           598: convert_exit:
        !           599:         cRet vBrush2ColorToMono
        !           600: endProc vBrush2ColorToMono
        !           601: 
        !           602: 
        !           603: ;==============================================================================
        !           604: ; vConvert4BppToPlanar
        !           605: ;
        !           606: ;
        !           607: ;==============================================================================
        !           608: 
        !           609: cProc   vConvert4BppToPlanar,16,<  \
        !           610:         uses esi edi ebx,      \
        !           611:         pDest: ptr dword,      \
        !           612:         pSrc: ptr dword,       \
        !           613:         cbScan: dword,         \
        !           614:         pulXlate: ptr dword          >
        !           615: 
        !           616:         local ulHeight : dword
        !           617: 
        !           618:         xor     eax,eax
        !           619:         mov     esi,pSrc
        !           620:         mov     edi,pDest
        !           621: 
        !           622:         mov     edx,pulXlate
        !           623:         or      edx,edx
        !           624:         jz      do_convert4toplanar
        !           625: 
        !           626:         mov     ulHeight,8
        !           627: convert4xlate:
        !           628:         mov     ebx,[esi]                  ;Get 8 4bpp pixels
        !           629:         and     ebx,0f0f0f0fh              ;Mask off the high nibbles
        !           630:         shl     ebx,2                      ;multiply by four (size of dword)
        !           631:         mov     al,bl                      ;move into eax to use an index
        !           632:         mov     eax,[edx][eax]             ;xlate color
        !           633:         mov     ecx,PackedToPlanar6[eax*4] ;build planar bytes
        !           634:         mov     al,bh                      ;move into eax to use an index
        !           635:         shr     ebx,16                     ;get access to high word
        !           636:         mov     eax,[edx][eax]             ;xlate color
        !           637:         or      ecx,PackedToPlanar4[eax*4] ;build planar bytes
        !           638:         mov     al,bl                      ;move into eax to use an index
        !           639:         mov     eax,[edx][eax]             ;xlate color
        !           640:         or      ecx,PackedToPlanar2[eax*4] ;build planar bytes
        !           641:         mov     al,bh                      ;move into eax to use an index
        !           642:         mov     eax,[edx][eax]             ;xlate color
        !           643:         or      ecx,PackedToPlanar0[eax*4] ;build planar bytes
        !           644: 
        !           645:         mov     ebx,[esi]                  ;Get same dword again so we
        !           646:         add     esi,cbScan                 ; can do the high nibbles
        !           647: 
        !           648:         and     ebx,0f0f0f0f0h             ;Mask off the low nibbles
        !           649:         shr     ebx,2                      ;shift into low nible and
        !           650:                                            ;multiply by four ((>> 4) << 2)
        !           651: 
        !           652:         mov     al,bl                      ;move into eax to use an index
        !           653:         mov     eax,[edx][eax]             ;xlate color
        !           654:         or      ecx,PackedToPlanar7[eax*4] ;build planar bytes
        !           655:         mov     al,bh                      ;move into eax to use an index
        !           656:         shr     ebx,16                     ;get access to high word
        !           657:         mov     eax,[edx][eax]             ;xlate color
        !           658:         or      ecx,PackedToPlanar5[eax*4] ;build planar bytes
        !           659:         mov     al,bl                      ;move into eax to use an index
        !           660:         mov     eax,[edx][eax]             ;xlate color
        !           661:         or      ecx,PackedToPlanar3[eax*4] ;build planar bytes
        !           662:         mov     al,bh                      ;move into eax to use an index
        !           663:         mov     eax,[edx][eax]             ;xlate color
        !           664:         or      ecx,PackedToPlanar1[eax*4] ;build planar bytes
        !           665: 
        !           666:         mov     [edi],cl                   ;Write the bytes out in planar
        !           667:         mov     [edi+8],ch                 ;format. We have to store them
        !           668:         shr     ecx,16                     ;this way because this is how
        !           669:         mov     [edi+16],cl                ;the blt compiler expects it.
        !           670:         mov     [edi+24],ch
        !           671:         add     edi,1                      ;increment dest pointer
        !           672: 
        !           673:         dec     ulHeight                   ;Check height
        !           674:         jnz     convert4xlate              ;do next line
        !           675:         jmp     short convert4exit         ;exit
        !           676: 
        !           677: do_convert4toplanar:
        !           678:         mov     edx,8
        !           679: 
        !           680: convert4toplanar:
        !           681:         mov     ebx,[esi]                       ;Get 8 4bpp pixels
        !           682:         and     ebx,0f0f0f0fh                   ;Mask off the high nibbles
        !           683:         shl     ebx,2                           ;multiply by four each nibble
        !           684:                                                 ; by four (size of dword)
        !           685:         mov     al,bl                           ;move into eax to use an index
        !           686:         mov     ecx,PackedToPlanar6[eax]        ;build planar bytes
        !           687:         mov     al,bh                           ;move into eax to use an index
        !           688:         shr     ebx,16                          ;get access to high word
        !           689:         or      ecx,PackedToPlanar4[eax]        ;build planar bytes
        !           690:         mov     al,bh                           ;move into eax to use an index
        !           691:         and     ebx,03ch                        ;mask off unneeded bits
        !           692:         or      ecx,PackedToPlanar2[ebx]        ;build planar bytes
        !           693:         or      ecx,PackedToPlanar0[eax]        ;build planar bytes
        !           694: 
        !           695:         mov     ebx,[esi]                       ;Get same dword again so we
        !           696:         add     esi,cbScan                      ; can do the high nibbles
        !           697: 
        !           698:         and     ebx,0f0f0f0f0h                  ;Mask off the low nibbles
        !           699:         shr     ebx,2                           ;shift into low nible and
        !           700:                                                 ;multiply by four ((>> 4) << 2)
        !           701: 
        !           702:         mov     al,bl                           ;move into eax to use an index
        !           703:         or      ecx,PackedToPlanar7[eax]        ;build planar bytes
        !           704:         mov     al,bh                           ;move into eax to use an index
        !           705:         shr     ebx,16                          ;get access to high word
        !           706:         or      ecx,PackedToPlanar5[eax]        ;build planar bytes
        !           707:         mov     al,bh                           ;move into eax to use an index
        !           708:         and     ebx,03ch                        ;mask off unneeded bits
        !           709:         or      ecx,PackedToPlanar3[ebx]        ;build planar bytes
        !           710:         or      ecx,PackedToPlanar1[eax]        ;build planar bytes
        !           711: 
        !           712:         mov     [edi],cl                        ;Write the bytes out in planar
        !           713:         mov     [edi+8],ch                      ;format. We have to store them
        !           714:         shr     ecx,16                          ;this way because this is how
        !           715:         mov     [edi+16],cl                     ;the blt compiler expects it.
        !           716:         mov     [edi+24],ch
        !           717:         add     edi,1                           ;increment dest pointer
        !           718: 
        !           719:         dec     edx                             ;check scan count
        !           720:         jnz     convert4toplanar                ;
        !           721: 
        !           722: convert4exit:
        !           723:         cRet vConvert4BpptoPlanar
        !           724: endProc vConvert4BppToPlanar
        !           725: 
        !           726: ;==============================================================================
        !           727: ; vConvert8BppToPlanar
        !           728: ;
        !           729: ;
        !           730: ;==============================================================================
        !           731: 
        !           732: cProc   vConvert8BppToPlanar,16,<  \
        !           733:         uses esi edi ebx,      \
        !           734:         pDest: ptr dword,      \
        !           735:         pSrc: ptr dword,       \
        !           736:         cbScan: dword,         \
        !           737:         pulXlate: ptr dword          >
        !           738: 
        !           739:         local ulHeight : dword
        !           740: 
        !           741:         xor     eax,eax
        !           742:         mov     esi,pSrc
        !           743:         mov     edi,pDest
        !           744: 
        !           745:         mov     edx,pulXlate
        !           746:         or      edx,edx
        !           747:         jz      do_convert8toplanar
        !           748: 
        !           749:         mov     ulHeight,8
        !           750: convert8xlate:
        !           751:         xor     ecx,ecx
        !           752:         mov     ebx,[esi]                  ;Get 4 8bpp pixels
        !           753:         mov     al,bl                      ;move into eax to use an index
        !           754:         mov     eax,[edx][eax*4]           ;xlate color
        !           755:         or      ecx,PackedToPlanar7[eax*4] ;build planar bytes
        !           756:         mov     al,bh                      ;move into eax to use an index
        !           757:         shr     ebx,16                     ;get access to high word
        !           758:         mov     eax,[edx][eax*4]           ;xlate color
        !           759:         or      ecx,PackedToPlanar6[eax*4] ;build planar bytes
        !           760:         mov     al,bl                      ;move into eax to use an index
        !           761:         mov     eax,[edx][eax*4]           ;xlate color
        !           762:         or      ecx,PackedToPlanar5[eax*4] ;build planar bytes
        !           763:         mov     al,bh                      ;move into eax to use an index
        !           764:         mov     eax,[edx][eax*4]             ;xlate color
        !           765:         or      ecx,PackedToPlanar4[eax*4] ;build planar bytes
        !           766: 
        !           767:         mov     ebx,[esi+4]                ;Get same dword again so we
        !           768:         add     esi,cbScan                 ; can do the high nibbles
        !           769: 
        !           770:         mov     al,bl                      ;move into eax to use an index
        !           771:         mov     eax,[edx][eax*4]           ;xlate color
        !           772:         or      ecx,PackedToPlanar3[eax*4] ;build planar bytes
        !           773:         mov     al,bh                      ;move into eax to use an index
        !           774:         shr     ebx,16                     ;get access to high word
        !           775:         mov     eax,[edx][eax*4]           ;xlate color
        !           776:         or      ecx,PackedToPlanar2[eax*4] ;build planar bytes
        !           777:         mov     al,bl                      ;move into eax to use an index
        !           778:         mov     eax,[edx][eax*4]           ;xlate color
        !           779:         or      ecx,PackedToPlanar1[eax*4] ;build planar bytes
        !           780:         mov     al,bh                      ;move into eax to use an index
        !           781:         mov     eax,[edx][eax*4]           ;xlate color
        !           782:         or      ecx,PackedToPlanar0[eax*4] ;build planar bytes
        !           783: 
        !           784:         mov     [edi],cl                   ;Write the bytes out in planar
        !           785:         mov     [edi+8],ch                 ;format. We have to store them
        !           786:         shr     ecx,16                     ;this way because this is how
        !           787:         mov     [edi+16],cl                ;the blt compiler expects it.
        !           788:         mov     [edi+24],ch
        !           789:         add     edi,1                      ;increment dest pointer
        !           790: 
        !           791:         dec     ulHeight                   ;Check height
        !           792:         jnz     convert8xlate              ;do next line
        !           793:         jmp     short convert8exit         ;exit
        !           794: 
        !           795: do_convert8toplanar:
        !           796:         mov     edx,8
        !           797: 
        !           798: convert8toplanar:
        !           799:         xor     ecx,ecx
        !           800:         mov     ebx,[esi]                       ;Get 8 4bpp pixels
        !           801:         mov     al,bl                           ;move into eax to use an index
        !           802:         or      ecx,PackedToPlanar7[eax*4]      ;build planar bytes
        !           803:         mov     al,bh                           ;move into eax to use an index
        !           804:         shr     ebx,16                          ;get access to high word
        !           805:         or      ecx,PackedToPlanar6[eax*4]      ;build planar bytes
        !           806:         mov     al,bl                           ;move into eax to use an index
        !           807:         or      ecx,PackedToPlanar5[eax*4]      ;build planar bytes
        !           808:         mov     al,bh                           ;move into eax to use an index
        !           809:         or      ecx,PackedToPlanar4[ebx*4]      ;build planar bytes
        !           810: 
        !           811:         mov     ebx,[esi+4]                     ;Get same dword again so we
        !           812:         add     esi,cbScan                      ; can do the high nibbles
        !           813: 
        !           814:         mov     al,bl                           ;move into eax to use an index
        !           815:         or      ecx,PackedToPlanar3[eax*4]      ;build planar bytes
        !           816:         mov     al,bh                           ;move into eax to use an index
        !           817:         shr     ebx,16                          ;get access to high word
        !           818:         or      ecx,PackedToPlanar2[eax*4]      ;build planar bytes
        !           819:         mov     al,bl                           ;move into eax to use an index
        !           820:         or      ecx,PackedToPlanar1[eax*4]      ;build planar bytes
        !           821:         mov     al,bh                           ;move into eax to use an index
        !           822:         or      ecx,PackedToPlanar0[ebx*4]      ;build planar bytes
        !           823: 
        !           824:         mov     [edi],cl                        ;Write the bytes out in planar
        !           825:         mov     [edi+8],ch                      ;format. We have to store them
        !           826:         shr     ecx,16                          ;this way because this is how
        !           827:         mov     [edi+16],cl                     ;the blt compiler expects it.
        !           828:         mov     [edi+24],ch
        !           829:         add     edi,1                           ;increment dest pointer
        !           830: 
        !           831:         dec     edx                             ;check scan count
        !           832:         jnz     convert8toplanar                ;
        !           833: 
        !           834: convert8exit:
        !           835:         cRet vConvert8BpptoPlanar
        !           836: endProc vConvert8BppToPlanar
        !           837: 
        !           838: ;==============================================================================
        !           839: ; vCreatePlaneMasks
        !           840: ;
        !           841: ;
        !           842: ;==============================================================================
        !           843: 
        !           844: cProc   vCreatePlaneMasks,8,<  \
        !           845:         uses esi edi ebx,      \
        !           846:         pDest: ptr dword,      \
        !           847:         pSrc: ptr dword        >
        !           848: 
        !           849:         mov     esi,pSrc
        !           850:         mov     edi,pDest
        !           851: 
        !           852:         mov     ebx,8                 ; do eight lines
        !           853: 
        !           854:         ;------------------------------------------------
        !           855:         ;  al = source byte for compare
        !           856:         ;  ah = plane 0 mask
        !           857:         ;  cl = plane 1 mask
        !           858:         ;  ch = plane 2 mask
        !           859:         ;  dl = plane 3 mask
        !           860:         ;
        !           861:         ;  ebx = scan count
        !           862:         ;  esi = pattern
        !           863:         ;  edi = plane masks
        !           864:         ;------------------------------------------------
        !           865: new_scan:
        !           866:         mov     ah,MM_C0                ;initialize plane masks
        !           867:         mov     cx,MM_C1 + (MM_C2 SHL 8)
        !           868:         mov     dl,MM_C3
        !           869: 
        !           870:         mov     al,[esi]                ;load plane 0
        !           871:         cmp     al,[esi+8]              ;compare planes 0 and 1
        !           872:         jne     plane0_ne_plane1
        !           873:         or      ah,cl
        !           874:         xor     cl,cl
        !           875: 
        !           876: plane0_ne_plane1:
        !           877:         cmp     al,[esi+16]             ;compare planes 0 and 2
        !           878:         jne     plane0_ne_plane2
        !           879:         or      ah,ch
        !           880:         xor     ch,ch
        !           881: 
        !           882: plane0_ne_plane2:
        !           883:         cmp     al,[esi+24]             ;compare planes 0 and 3
        !           884:         jne     plane0_ne_plane3
        !           885:         or      ah,dl
        !           886:         xor     dl,dl
        !           887: 
        !           888: plane0_ne_plane3:
        !           889:         or      cl,cl                   ;did this plane match plane 0
        !           890:         jz      compare_plane_2         ;if so, skip it
        !           891:         mov     al,[esi+8]              ;load plane 1
        !           892:         cmp     al,[esi+16]             ;compare planes 1 and 2
        !           893:         jne     plane1_ne_plane2
        !           894:         or      cl,ch
        !           895:         xor     ch,ch
        !           896: 
        !           897: plane1_ne_plane2:
        !           898:         cmp     al,[esi+24]             ;compare planes 1 and 3
        !           899:         jne     compare_plane_2
        !           900:         or      cl,dl
        !           901:         xor     dl,dl
        !           902:         jmp     short done_with_scan
        !           903: 
        !           904: compare_plane_2:
        !           905:         or      ch,ch
        !           906:         jz      done_with_scan
        !           907:         mov     al,[esi+16]             ;load plane 2
        !           908:         cmp     al,[esi+24]             ;compare planes 2 and 3
        !           909:         or      ch,dl
        !           910:         xor     dl,dl
        !           911: 
        !           912: 
        !           913: done_with_scan:                         ;save results
        !           914:         mov     [edi],ah                ;save plane 0 mask
        !           915:         mov     [edi+8],cl              ;save plane 1 mask
        !           916:         mov     [edi+16],ch             ;save plane 2 mask
        !           917:         mov     [edi+24],dl             ;save plane 3 mask
        !           918: 
        !           919:         inc     edi
        !           920:         inc     esi
        !           921:         dec     ebx
        !           922:         jnz     new_scan
        !           923: 
        !           924:         cRet vCreatePlaneMasks
        !           925: endProc vCreatePlaneMasks
        !           926: 
        !           927: _TEXT$01   ends
        !           928: 
        !           929: end
        !           930: 
        !           931: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.