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

📄 direct.asm

📁 汇编语言编的关于ov143b.asm的小程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        PAGE   60,132
        TITLE  Routines to do direct screen I/O

;  012  18-Apr-87  direct.asm

;       Copyright (c) 1986,1987 by Blue Sky Software.  All rights reserved.

;****************************************************************************
;****** Make sure the following symbol matches calling program usage ********
;****************************************************************************

ALTCALL EQU    'pascal'        ; Uses alternate calling sequence when defined

;****************************************************************************

B_proc  MACRO  lname,uname             ; simple Begin proc macro
IFDEF   ALTCALL
        PUBLIC uname
uname   PROC   NEAR
ELSE
        PUBLIC lname
lname   PROC   NEAR
ENDIF
        ENDM

E_proc  MACRO  lname,uname,n           ; simple End proc macro
IFDEF   ALTCALL
        ret    n
uname   ENDP
ELSE
        ret
lname   ENDP
ENDIF
        ENDM

Param   MACRO  sym,cway,pway           ; simple parameter defination macro
IFDEF   ALTCALL
sym     EQU    [bp+pway]
ELSE
sym     EQU    [bp+cway]
ENDIF
        ENDM

_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS

DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP

_DATA   SEGMENT
        EXTRN   _screen:DWORD
        EXTRN   _cursor:DWORD
        EXTRN   _vid_attrib:BYTE
        EXTRN   _vid_snow:BYTE
        boxloc  dw    0           ; stores the starting offset to the dialog box
_DATA   ENDS

_TEXT      SEGMENT

;******************************************************************************
;
;  gotorc(row,col)    move 'cursor' to specified row, col
;
;******************************************************************************

        B_proc _gotorc,GOTORC

        Param  Row,4,6
        Param  Col,6,4

        push    bp
        mov     bp,sp

        mov     ax,Row                         ; row to ax
        mov     cl,5
        shl     ax,cl                          ; row * 32
        mov     bx,ax
        shl     ax,1
        shl     ax,1                           ; row * 128
        add     ax,bx                          ; row * 160

        mov     bx,Col                         ; col to bx
        shl     bx,1                           ; col * 2

        add     ax,bx                          ; row * 160 + col * 2 = cursor
        mov     WORD PTR _cursor,ax

        mov     sp,bp
        pop     bp

        E_proc  _gotorc,GOTORC,4

;******************************************************************************
;
;  disp_str(s)    display a string at current location
;
;******************************************************************************

        B_proc _disp_str,DISP_STR

        push    bp
        mov     bp,sp
        push    di
        push    si
        mov     si,[bp+4]

        mov     ah,_vid_attrib         ; attribute byte to ah
        les     di,DWORD PTR _cursor   ; cursor ptr to es:di

        jmp     SHORT tst_ch           ; skip to load/test code

chloop:

        IFDEF  nosnow                  ; if adapter doesn't snow, its quick
           stosw                       ; store char and attrib to es:[di++]
        ELSE                           ; well, its not so quick or easy....
           mov    cx,1
           call   stvideo
        ENDIF

tst_ch: lodsb                          ; string char to al
        or      al,al                  ; done when char = 0
        jne     chloop

        mov     WORD PTR _cursor,di    ; update cursor offset

        pop     si
        pop     di
        mov     sp,bp
        pop     bp

        E_proc _disp_str,DISP_STR,2

;******************************************************************************
;
;   disp_char(ch)   display a single char at current location
;
;******************************************************************************

        B_proc _disp_char,DISP_CHAR

        push    bp
        mov     bp,sp
        push    di

        les     di,DWORD PTR _cursor   ; cursor loc to es:di

        mov     al,[bp+4]              ; get char to store in video memory
        mov     ah,_vid_attrib         ; get video attribute

        IFDEF nosnow
           stosw                       ; store 'em and update di
        ELSE
           mov  cx,1
           call stvideo
        ENDIF

        mov     WORD PTR _cursor,di    ; update cursor offset

        pop     di
        mov     sp,bp
        pop     bp

        E_proc _disp_char,DISP_CHAR,2


;******************************************************************************
;
;   disp_rep(ch,cnt)   display a single char cnt times at current location
;
;******************************************************************************

        B_proc _disp_rep,DISP_REP

        Param   Ch_d,4,6
        Param   Cnt,6,4

        push    bp
        mov     bp,sp
        push    di

        les     di,DWORD PTR _cursor   ; cursor loc to es:di

        mov     al,Ch_d                ; get char to store in video memory
        mov     ah,_vid_attrib         ; get video attribute
        mov     cx,Cnt                 ; rep count to cx

        IFDEF  nosnow
           rep stosw                   ; store 'em and update di
        ELSE
           call stvideo
        ENDIF

        mov     WORD PTR _cursor,di    ; update cursor offset

        pop     di
        mov     sp,bp
        pop     bp

        E_proc _disp_rep,DISP_REP,4


;******************************************************************************
;
;       insert_line(row,n)   insert a line at row, effects n lines
;
;******************************************************************************

        Param   Row_l,4,6      ; Parameters for insert_line, delete_line,
        Param   Num_l,6,4      ;    scroll_video

        B_proc _insert_line,INSERT_LINE

        push    bp
        mov     bp,sp
        push    di
        push    si

        mov     bx,Row_l               ; ( r + n - 1) * 160 - 2 =
        add     bx,Num_l               ;   end of new last row
        dec     bx
        mov     ax,160
        imul    bx
        dec     ax
        dec     ax
        mov     si,ax                  ;   (but its the source for the move)

        add     ax,160                 ; call addr of dest (where new last
        mov     di,ax                  ;   line will go)

        std                            ; to insert a row, need to go backwards

        call    scroll_video           ; scroll the video buffer

        mov     al,20h                 ; fill the inserted line with blanks
        mov     ah,_vid_attrib
        mov     cx,80
        IFDEF  nosnow
           rep stosw
        ELSE
           call stvideo
        ENDIF

        cld                            ; C expects it this way

        pop     si
        pop     di
        mov     sp,bp
        pop     bp

        E_proc  _insert_line,INSERT_LINE,4


;******************************************************************************
;
;       delete_line(r,n)   delete a line at row, effects n lines
;
;******************************************************************************

        B_proc _delete_line,DELETE_LINE

        push    bp
        mov     bp,sp
        push    di
        push    si

        mov     ax,160                 ; get row
        imul    WORD PTR Row_l         ;   turn into offset in video ram
        mov     di,ax

        add     ax,160                 ; calc offset of next row
        mov     si,ax

        call    scroll_video           ; scroll the video buffer

        mov     al,20h                 ; fill the last line with blanks
        mov     ah,_vid_attrib
        mov     cx,80
        IFDEF  nosnow
           rep stosw
        ELSE
           call stvideo
        ENDIF

        pop     si
        pop     di
        mov     sp,bp
        pop     bp

        E_proc _delete_line,DELETE_LINE,4


;*****************************************************************************
;
;   scroll_video   support routine for insert/delete line
;
;*****************************************************************************

scroll_video PROC NEAR

        mov     ax,80                  ; get # rows to move and
        imul    WORD PTR Num_l         ;   turn into # words to move
        mov     cx,ax

        IFNDEF  nosnow
           mov  al,_vid_snow           ; movideo needs vid_snow - get it
        ENDIF                          ;   before ds gets changed

        push    ds                     ; save current ds
        mov     bx,WORD PTR _screen+2  ; segment address of video ram
        mov     ds,bx                  ; moving to/from video ram
        mov     es,bx

        IFDEF   nosnow
           rep movsw                   ; scroll the data in the video buffer
        ELSE
           call movideo
        ENDIF

        pop    ds                      ; restore ds

        ret

scroll_video ENDP


;******************************************************************************
;
;       scrcpy(to,from)
;       char far *to, far *from;
;
;       copy screen image from to
;
;******************************************************************************

        B_proc _scrcpy,SCRCPY

        Param  To,4,8
        Param  From,8,4

        push    bp
        mov     bp,sp
        push    di
        push    si
        push    ds

        IFNDEF  nosnow
        mov     al,_vid_snow           ; flag for movideo
        ENDIF

⌨️ 快捷键说明

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