⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scrmem.asm

📁 dos 6.0 源代码 .对大家提高有一定的帮助。
💻 ASM
📖 第 1 页 / 共 2 页
字号:
                INT     10H
                ret

scroll          ENDP

fill            PROC    USES DI SI, ulpos:WORD, height_width:WORD, fill_ch:BYTE

;extern void pascal fill(int ulpos, int height_width, int c);

                mov     ax, _display_segment
                mov     es, ax
                mov     dx, ulpos
                call    update_cursor
                mov     si, di              ;Keep destination ptr in SI
                mov     dx, height_width    ;Get height/width pair
                or      dh, dh
                jz      fill_done

                or      dl, dl
                jz      fill_done

                mov     ax, __attrib         ;Get attribute
                call    fix_attribute
                mov     al, fill_ch         ;Get character
                mov     bx, 2 * 80          ;Length of a screen row in bytes
                xor     ch, ch

fill_loop:      mov     di, si              ;Set destination pointer
                mov     cl, dl              ;Set up count
                push    di
                push    cx
                cmp     _retrace_wait, 0
                je      fast_fill

                push    bx
                push    dx
                mov     dx, MOTOROLA_6845   ;Address of 6845 status register
                mov     bl, al

slow_fill:      RetraceWait
                mov     al, bl
                stosw
                sti
                loop    slow_fill

                pop     dx
                pop     bx
                jmp     short end_row

fast_fill:      rep     stosw               ;Fill the line

end_row:        pop     cx
                pop     di
                dec     dh                  ;Decrement # of lines left
                jz      fill_done           ;All done!

                add     si, bx              ;Point to start of next line
                jmp     fill_loop           ;Go back & fill next line

fill_done:      call    TopviewUpdate
                ret

fill            ENDP

shade           PROC    USES DI SI, ulpos:WORD, height_width:WORD

; extern void pascal shade(int ulpos, int height_width);
;
; Change the attribute of a display zone
;

                mov     ax, _display_segment
                mov     es, ax
                mov     dx, ulpos
                call    update_cursor
                mov     si, di              ;Keep destination ptr in SI
                mov     dx, height_width    ;Get height/width pair
                mov     ax, __attrib         ;Get attribute
                call    fix_attribute
                mov     al, ah
                mov     bx, 2 * 80          ;Length of a screen row in bytes
                xor     ch, ch

shade_loop:     mov     di, si                  ;Set destination pointer
                mov     cl, dl                  ;Set up count
                push    di
                push    cx
                cmp     _retrace_wait, 0
                je      shade_each

                push    bx
                push    dx
                mov     dx, MOTOROLA_6845   ;Address of 6845 status register
                mov     bl, al

slow_shade:     inc     di                      ;Skip past char
                RetraceWait                     ;Wait for retrace
                mov     al, bl
                stosb
                sti
                loop    slow_shade

                pop     dx
                pop     bx
                jmp     short shade_next

shade_each:     inc     di                      ;Skip past char
                stosb                           ;Store attribute
                loop    shade_each              ;Do until end of line

shade_next:     pop     cx
                pop     di
                dec     dh                      ;Decrement # of lines left
                jz      shade_done              ;All done!

                add     si, bx                  ;Point to start of next line
                jmp     short shade_loop        ;Go back & fill next line

shade_done:     call    TopviewUpdate
                ret

shade           ENDP

save_zone       PROC    USES DI SI DS, \
                ulpos:WORD, height_width:WORD, buff:FAR PTR

;extern void pascal save_zone(int ulpos, int height_width, byte far *buff);

; Copy the display info in a zone into a far buffer
;
                mov     dx, ulpos
                call    update_cursor
                mov     cx, di
                mov     dx, height_width        ;Height, width to DX
                les     di, buff                ;Buffer pointer to ES:[DI]
                mov     bp, cx                  ;Screen offset goes in BP
                mov     ah, _retrace_wait       ;Get retrace flag to AH
                mov     ds, _display_segment    ;Point to screen memory
                mov     bx, 80 * 2              ;Length of 1 line in bytes
                xor     ch, ch

save_loop:      mov     si, bp                  ;Set destination pointer
                mov     cl, dl                  ;Set up count
                or      ah, ah
                jz      fast_save

                push    dx
                mov     dx, MOTOROLA_6845

slow_save:      RetraceWait
                movsw
                sti
                loop    slow_save

                pop     dx
                jmp     short save_next

fast_save:
            rep movsw                           ;Copy the line

save_next:      dec     dh                      ;Decrement # of lines left
                jz      save_done               ;All done!

                add     bp, bx                  ;Point to start of next line
                jmp     short save_loop         ;Go back & fill next line

save_done:      ret

save_zone       ENDP

restore_zone    PROC    USES DI SI DS, \
                ulpos:WORD, height_width:WORD, buff:FAR PTR

;extern void pascal restore_zone(int ulpos, int height_width, byte far *buff);

;
; Restore a display zone from a buffer
;

                mov     dx, ulpos
                call    update_cursor
                mov     cx, di                  ;Temporarily put offset in CX
                mov     dx, height_width        ;Height, width to DX
                mov     es, _display_segment    ;Point to screen memory
                mov     ah, _retrace_wait       ;Get retrace flag to AH
                lds     si, buff                ;Buffer pointer to DS:[SI]
                mov     bp, cx                  ;Screen offset goes in BP
                mov     bx, 80 * 2              ;Length of 1 line in bytes
                xor     ch, ch

rest_loop:      mov     di, bp                  ;Set destination pointer
                mov     cl, dl                  ;Set up count
                push    di
                push    cx
                or      ah, ah
                jz      fast_rest

                push    bx
                push    dx
                mov     dx, MOTOROLA_6845

slow_rest:      lodsw
                mov     bx, ax
                RetraceWait
                mov     ax, bx
                stosw
                sti
                loop    slow_rest

                pop     dx
                pop     bx
                jmp     short rest_next

fast_rest:
            rep movsw                           ;Copy the line

rest_next:      pop     cx
                pop     di
                dec     dh                      ;Decrement # of lines left
                jz      rest_done               ;All done!

                add     bp, bx                  ;Point to start of next line
                jmp     short rest_loop         ;Go back & fill next line

rest_done:      call    TopviewUpdate
                ret

restore_zone    ENDP


fix_attribute   PROC    NEAR

;Entry:
;   AL = desired attribute for color screen
;   AH may have bits set indicating monochrome adapter attributes as follows:
;       01 - reverse video
;       02 - underline
;Return:
;   AL and AH = physical screen attribute
;
                mov     __attrib, ax
                cmp     is_mono, 0
                jz      color_adapter

;--- Using B000 segment.  Is this a Hercules InColor Card?

                cmp     HerculesInColor, 0
                jne     color_adapter           ;Then leave attributes alone

                test    ah, UNDERLINE_BIT
                jnz     underline

                jmp short   other_tests

;--- Set for underline

underline:      and     al, 88H
                or      al, 1
                jmp     short fix_ret

color_adapter:  cmp     _force_mono, 0
                je      fix_ret

other_tests:    test    ah, REVERSE_BIT
                jnz     mono_reverse

                test    ah, NORMAL_BIT
                jnz     mono_normal

                test    ah, BOLD_BIT
                jnz     mono_bold

                or      al, 07H
                and     al, 8FH
                jmp     short fix_ret

mono_normal:    mov     al, 07H
                jmp short   fix_ret

mono_bold:      mov     al, 0FH
                jmp short   fix_ret

mono_reverse:   or      al, 70H
                and     al, 0F0H

fix_ret:        mov     ah, al
                ret

fix_attribute   ENDP

                END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -