]> 4ch.mooo.com Git - 16.git/blobdiff - 16/x_/mxhl.asm
refresh wwww
[16.git] / 16 / x_ / mxhl.asm
diff --git a/16/x_/mxhl.asm b/16/x_/mxhl.asm
new file mode 100755 (executable)
index 0000000..049a056
--- /dev/null
@@ -0,0 +1,76 @@
+;-----------------------------------------------------------\r
+;\r
+; MXHL.ASM - Horizontal line mask utility\r
+; Copyright (c) 1993,1994 by Alessandro Scotti\r
+;\r
+;-----------------------------------------------------------\r
+WARN    PRO\r
+INCLUDE MODEX.DEF\r
+\r
+PUBLIC  subHorizontalLineInfo\r
+\r
+MX_TEXT         SEGMENT USE16 PARA PUBLIC 'CODE'\r
+                ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING\r
+\r
+EXTRN   mx_BytesPerLine : WORD\r
+\r
+tblLeftSize     DW      00h, 03h, 02h, 01h\r
+tblLeftMask     DB      00h, 0Eh, 0Ch, 08h\r
+tblRightMask    DB      00h, 01h, 03h, 07h\r
+tblPatchMask    DB      02h, 06h\r
+\r
+;-----------------------------------------------------------\r
+;\r
+; Prepares register for fast horizontal line drawing.\r
+;\r
+; Input:\r
+;       BX, AX  = X, Y address of left pixel\r
+;       CX      = line width\r
+; Output:\r
+;       DI      = left pixel offset in video memory\r
+;       AL      = left block write plane mask (0 = none)\r
+;       AH      = right block write plane mask (0 = none)\r
+;       CX      = center block width in 4-pixel blocks\r
+;\r
+subHorizontalLineInfo   PROC NEAR\r
+        ASSUME  ds:NOTHING\r
+\r
+        mul     [mx_BytesPerLine]\r
+        mov     di, bx\r
+        shr     di, 1\r
+        shr     di, 1\r
+        add     di, ax                  ; Offset of left pixel\r
+\r
+        and     bx, 03h\r
+        mov     al, tblLeftMask[bx]\r
+        shl     bx, 1\r
+        sub     cx, tblLeftSize[bx]\r
+        jge     @@1                     ; Ok to continue\r
+\r
+; Special case: start and end in the middle of a 4-pixel block.\r
+; There are only three cases:\r
+;    Pixels     Left mask       CX      CX+2    Patch mask      Result\r
+; 1)  ..o.        ..xx          -1      1       .xx.            ..x.\r
+; 2)  .oo.        .xxx          -1      1       .xx.            .xx.\r
+; 3)  .o..        .xxx          -2      0       .x..            .x..\r
+; All other cases are automatically handled with the standard masks.\r
+        mov     bx, cx\r
+        inc     bx\r
+        inc     bx\r
+        and     al, tblPatchMask[bx]    ; Combine masks\r
+        xor     ah, ah                  ; No right block\r
+        xor     cx, cx                  ; No center block\r
+        jmp     @@Exit\r
+\r
+@@1:\r
+        mov     bx, cx\r
+        and     bx, 03h\r
+        mov     ah, tblRightMask[bx]\r
+        shr     cx, 2\r
+\r
+@@Exit:\r
+        ret\r
+subHorizontalLineInfo   ENDP\r
+\r
+MX_TEXT         ENDS\r
+END\r