TASM 1.4 - 改变背景颜色,但不清除屏幕? [英] TASM 1.4 - Changing background color without clearing the screen?

查看:243
本文介绍了TASM 1.4 - 改变背景颜色,但不清除屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TASM 1.4。
我试图改变的背景和文本的颜色不清除previous文本,但它总是尽管颜色变清previous文本结束。

I'm using Tasm 1.4. I'm trying to change the color of the background and text without clearing the previous text, but it always ends up on clearing the previous text although the colors are changed.

例如:

mov ah,09h
lea dx,text1
int 21h             ;displays text1
mov ah,01h
int 21h             ;I input a character
mov ah,06h
mov bh,42h
mov cx,0000h
mov dx,184fh
int 10h             ;I use this to change the text and background color
mov ah,02h
mov bh,00h
mov dh,0ch
mov dl,20h
int 10h             ;along with this
mov ah,09h
lea dx,text2
int 21h             ;displays text2
mov ah,02h
mov dl,al
int 21h             ;displays the inputted character

现在发生的事情有...

Now what happens there is...


  • 它显示文本1

  • ,它要求输入

  • 我输入的输入

  • 将显示文本2其次是输入的文字,与背景颜色变为红色,文本颜色变为绿色。但是,文本1是从屏幕上消失。

我还应该说,文本1和文本绝对可以适应在同一屏幕。

I should also say that text1 and text2 can definitely fit in the same screen.

那么,如何得到的结果相同,但与文本1没有被从屏幕上消失?

So how do I get the same output but with text1 not being cleared from the screen?

推荐答案

刚写入显存直接与它做。如果在模式03H是,那么你已经有了在屏幕上字符80x25个。每个字符都有与之相关联的16位。显示文本/背景色8位,另外8字符。

Just write to the video memory directly and be done with it. If you're in mode 03h, then you've got 80x25 chars on screen. Each char has 16bits associated with it. 8 bits for text/background colour and another 8 for the character displayed.

要显示的字符是第一个字节和属性的第二个字节。
您可以在内存组织的简要描述,并在此属性位: http://www.shikadi.net/ moddingwiki / B800_Text

The character to display is the first byte and the attributes are the second byte. You can find a brief description of the memory organization and attribute bits here: http://www.shikadi.net/moddingwiki/B800_Text

下面是一些code,这将会使文本内容不变,只是设置属性字节为80x25个屏幕上的所有文本。我使用NASM这些天来,它一直以来我最后一次使用TASM15年 - 我不知道是否有任何语法都需要改变。

Here's some code that will leave the text content unchanged and will just set the attribute byte for all text on an 80x25 screen. I use nasm these days, it's been 15 years since I last used tasm - I'm not sure if any of the syntax will need changing.

;********************************************************
; Sets the text-mode attributes for the whole 80x25 screen
; call  with AL = attribute (hi nibble = background, lo-nibble = foreground)
;********************************************************
setTextAttributes:
    push    es              ; save the seg register
    mov     cx, 80*25       ; # of chars to do
    mov     bx, 0xB800      ; segment of the screen memory for this video mode
    mov     es, bx
    xor     di, di          ; point to char data of screen-pos 0,0
.setTextAttributesLoop:
    inc     di              ; advance by 1 to point to the attribute, rather than the char
    stosb                   ; store our attribute byte to [es:di] and increment di. di now points to a character
    loop    .setTextAttributesLoop
    pop     es
    ret

这篇关于TASM 1.4 - 改变背景颜色,但不清除屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆