📄 scrmem.asm
字号:
;***
;* $Workfile: scrmem.asm $
;* $Revision: 1.3 $
;* $Author: Dave Sewell $
;* $Date: 11 Sep 1990 8:46:08 $
;***
% .MODEL memmodel, PASCAL
MOTOROLA_6845 EQU 3DAH
REVERSE_BIT EQU 1
UNDERLINE_BIT EQU 2
NORMAL_BIT EQU 4
BOLD_BIT EQU 8
BIOS_SEG SEGMENT AT 40H
ORG 49H
crt_mode DB ?
crt_cols DW ?
crt_len DW ?
crt_start DW ?
cursor_posn DW ?
BIOS_SEG ENDS
.DATA?
PUBLIC HerculesInColor ; Only referenced in initscr.asm
PUBLIC _desqview
PUBLIC __attrib
PUBLIC _cursor_column
PUBLIC _cursor_row
PUBLIC _cursor_location
PUBLIC _cursor_value
PUBLIC is_mono
HerculesInColor DB ? ; Non-zero if InColor card present
_desqview DB ?
is_mono DB ?
_cursor_location LABEL WORD
_cursor_column DB ?
_cursor_row DB ?
_cursor_value DW ?
__attrib DW ?
.DATA
EXTRN _display_segment:WORD
EXTRN _display_offset:WORD
EXTRN _retrace_wait:BYTE
EXTRN _force_mono:BYTE
EXTRN _on_cursor_value:WORD
EXTRN _off_cursor_value:WORD
old_video_mode DB 0FFH
IF @CodeSize
.CODE PARAGON_TEXT
ELSE
.CODE
ENDIF
topview DB ? ;Put this in code segment for easy ref.
PUBLIC fix_attribute
;*** The following macro generates code to wait for horizontal retrace
;*** intervals. This is necessary to prevent screen snow when using the
;*** IBM color adapter. Interrupts are disabled during the wait.
;*** DX must have the address of the Motorola 6845 status port.
;*** AL is clobbered.
RetraceWait MACRO
LOCAL WaitForLow, WaitForHigh
WaitForLow: IN AL, DX
RCR AL, 1
JC WaitForLow
CLI
WaitForHigh: IN AL, DX
RCR AL, 1
JNC WaitForHigh
ENDM
TopviewUpdate PROC NEAR
cmp cs:topview, 0
jz @F
push ax
push bp
push di
push si
mov ah, 0FFH
int 10H
pop si
pop di
pop bp
pop ax
@@: ret
TopviewUpdate ENDP
SetTopView PROC FAR
mov topview, al
ret
SetTopView ENDP
update_cursor PROC NEAR USES AX DX
;Enter with DX = cursor position, returns DI = offset
mov al, 160
mul dh
shl dl, 1
xor dh, dh
add ax, dx
mov di, ax
add di, _display_offset
ret
update_cursor ENDP
locate PROC USES BP DI SI, row_col:WORD
;***
;* locate -- locate cursor
;*
;* extern void pascal locate(int row_col);
;*
;* int row; desired screen row (0 - 24)
;* int column; screen column (0 - 79)
;***
mov dx, row_col
mov WORD PTR _cursor_column, dx
MOV AH, 2 ;locate cursor bios function
XOR BH, BH ;page zero
INT 10H
ret
locate ENDP
set_cursor PROC NEAR USES BP DI SI
mov _cursor_value, cx
mov ah, 1
int 10h
ret
set_cursor ENDP
cursor_on PROC
;***
;* cursor_on -- turn on cursor
;*
;* extern void pascal cursor_on(void);
;***
mov cx, _on_cursor_value
call set_cursor
ret
cursor_on ENDP
cursor_off PROC USES BP DI SI
;***
;* cursor_off -- turn off cursor
;*
;* extern void pascal cursor_off(void);
;***
mov cx, _off_cursor_value
call set_cursor
ret
cursor_off ENDP
restore_cursor PROC value:WORD
;***
;* restore_cursor -- restore cursor to specified value
;*
;* extern void pascal restore_cursor(unsigned value);
;***
mov cx, value
call set_cursor
ret
restore_cursor ENDP
set_attribute PROC attr:WORD
;
; extern void pascal set_attribute(int attr);
mov ax, attr
mov __attrib, ax
ret
set_attribute ENDP
dispmem PROC USES DI SI DS, pos:WORD, buff:FAR PTR, cnt:WORD
;
; extern void pascal dispmem(int pos, byte far *buff, int cnt);
mov ax, __attrib
call fix_attribute ;Fix attribute if force_mono set
mov dx, pos
call update_cursor ;Now DI has screen offset
mov bx, _display_segment
mov es, bx
mov cx, cnt
mov bl, _retrace_wait ;Save retrace wait flag
lds si, buff
mov dx, MOTOROLA_6845 ;Address of 6845 status register
jcxz dispmem_ret ;Insure we have something
or bl, bl ;Need to wait for retrace?
jnz slow_disp ;Yes -- Go Do it
fast_disp: lodsb ;Get a byte of text
stosw ;Save out text & attribute
loop fast_disp ;Go for next char.
jmp short dispmem_ret ;All done
slow_disp: lodsb ;Get a byte of text
mov bl, al ;Save character/attribute
RetraceWait
mov al, bl ;Recover the character
stosw ;Store character and attribute
sti ;Enable interrupts again
loop slow_disp
dispmem_ret: call TopviewUpdate
ret
dispmem ENDP
clear PROC USES DI SI, ulpos:WORD, lrpos:WORD
;extern void pascal clear(int ulpos, int lrpos);
mov ax, __attrib
call fix_attribute
mov bh, ah
mov dx, lrpos
mov cx, ulpos
xor al, al
mov ah, 6
INT 10H
ret
clear ENDP
scroll PROC USES DI SI, \
ulpos:WORD, lrpos:WORD, attr:WORD, count:BYTE, \
direction:WORD
;extern void pascal scroll(int ulpos, int lrpos, int attr, int count, int direction);
;
; int ulpos; Position of upper left corner
; int lrpos; Position of lower right corner
; int attrib; Attribute to use for filling
; int count; Number of lines to scroll
; int direction; 1 = down, 0 = up
mov cx, ulpos
mov dx, lrpos
mov ax, attr
call fix_attribute
mov bh, ah
mov al, count
mov ah, 6
shr BYTE PTR direction, 1
adc ah, 0 ;Make it a 7 if DOWN specified
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -