VOGONS


New command.. colors

Topic actions

First post, by Goalatio

User metadata
Rank Newbie
Rank
Newbie

Created a new command for DOSbox.. it's a variant of the command prompt's "Color" command.

Note: Does not support intense colors

Code:

[org 0100h]


[section .text]
mov bl,0x80
mov bx,0x82
mov si,bx

lodsb
cmp al,'"'
jne error

main:

lodsb
shl al,4
mov [digit_tens],al

lodsb
shl al,4
shr al,4
mov [digit_ones],al
xor al,al
mov al,[digit_tens]
add al,[digit_ones]
mov [colors],al

lodsb
cmp al,'"'
jne error


display_color:
mov ah,2
mov dh,0
mov dl,0
int 10h

mov ah,9
mov bl,[colors]
mov cx,16000
mov al,0
int 10h

jmp exit

error:
mov ah,9
mov dx,errmsg
int 21h

exit:
mov ah,4ch
mov al,0
int 21h

[section .data]

digit_tens db 0
digit_ones db 0
Show last 2 lines
colors db 0
errmsg db 'Invalid syntax. Use doscolor "##".', 13, 10, "$"

Screenshots:
col42.jpg

col64.jpg

I will release the program on request.

It's passion that drives me.

Reply 1 of 13, by eL_PuSHeR

User metadata
Rank l33t++
Rank
l33t++

That damned JPEG artifacts really hurt my eyes. Next time use PNG for screen captures.

Nice patch, btw.

Intel i7 5960X
Gigabye GA-X99-Gaming 5
8 GB DDR4 (2100)
8 GB GeForce GTX 1070 G1 Gaming (Gigabyte)

Reply 2 of 13, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Does this still work if you do a "dir" or something that causes the screen to scroll? It looks like it just clears the screen with the selected colour rather than changing the current colour.

Reply 3 of 13, by Goalatio

User metadata
Rank Newbie
Rank
Newbie

Yeah, i've actually added this to the 16-bit OS that i'm working on.. It keeps the color for 8 pages (Which, is the number that DOS contains in the normal video mode), so, yes, it will keep the color if you do a "Dir" command, or any other command that scrolls the screen.

I'm going to re-write this, because the current version can take anything as the two parameters.. ex;

color aa would output some odd hell-spawned color that I'd never have wanted to see.

Going to change it so it only accepts numbers 1-9. (Just need to port it from my OS.. Which is where I figured out this problem)

It's passion that drives me.

Reply 4 of 13, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

But if you're talking hex, colour aa is a valid value. Colour 10 for both text and background. Colour 10 is bright green, so you should have bright green text on a bright green background, or as bg-intensity is disabled by default, blinking bright green text on a dark green background. This is what you would get if you put 0xAA directly into the video memory attribute bytes.

Since there are 16 possible colours for foreground and background, making your program accept a two digit hex number would work quite well.

Perhaps you could make your program fancy by allowing the user to change the bg-intensity bit too, so you could choose between blinking text or bright background colours?

Reply 5 of 13, by Gatran

User metadata
Rank Newbie
Rank
Newbie

Would AA fit into AL? I wonder. I'll try it out.

After writing a few lines, it does indeed fit.

Assembly code-

[org 0x0100]

[section .text]
mov al,0xAA ;Does it fit?
jc error ;If not, we must tell the error gods!
jnc done

error:
mov al,0x01 ;Return '1' if there was an error
jmp exit

done:
xor al,al ;If there was no error, return '0'
jmp exit

exit:
mov ah,0x4C
int 0x21
C:\Users\#####>C:\Users\#####\Desktop\test.com

C:\Users\#####>%errorlevel%
'0' is not recognized as an internal or external command,
operable program or batch file.

Reply 6 of 13, by TeaRex

User metadata
Rank Member
Rank
Member
Gatran wrote:

mov al,0xAA ;Does it fit?
jc error ;If not, we must tell the error gods!
jnc done

Dude, how is "mov" supposed to set or clear the carry flag? If anything is going to complain about a value not "fitting", it's the assembler.

Also, any two-digit hex number will fit in an 8-bit register, since 4 bits make exactly one hex digit.

tearex

Reply 7 of 13, by Gatran

User metadata
Rank Newbie
Rank
Newbie

Wow, thanks for the 'constructive' comment. Really kind words there.
I suppose posting here was a mistake, great first impression sir.

The logic behind it was..
if it does not fit, it overflows?

</Forum>

Reply 8 of 13, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

Well you have to consider that you posted in a thread that was almost a year old, about something unrelated to the topic of the thread, and demonstrated something that wouldn't work because it was incorrect.

So really, it's a surprise you got as friendly a response as you did 😀

Reply 9 of 13, by Gatran

User metadata
Rank Newbie
Rank
Newbie

It is related to the thread.

"This is what you would get if you put 0xAA directly into the video memory attribute bytes."

It was a test to see if passing AA was 'allowed' into AL, out of curiosity as I have only been using assembler off and on for a few months.

But excuse me for trying.

Also, I believe I should be aloud to post a reply to my own thread, relating to a question that was asked many months ago. My account 'Goalatio' no longer exists. Don't believe me? Here you go.

img1.png
img2.png

Reply 10 of 13, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Odd 😀 According to the administrator panel it exists just fine.

(and according to the user page as well
Goalatio

Water flows down the stream
How to ask questions the smart way!

Reply 11 of 13, by TeaRex

User metadata
Rank Member
Rank
Member

@Gatran: I didn't mean to personally attack you; do you consider "dude" such a bad word?

tearex

Reply 12 of 13, by Gatran

User metadata
Rank Newbie
Rank
Newbie

Qbix- I can record it if you need me to.

TeaRex- No, I do not. It's just the way you worded your sentence. It gave me an impression of what you were hinting at.

Dude, how is "mov" supposed to set or clear the carry flag? If anything is going to complain about a value not "fitting", it's the assembler.

Try saying that aloud with an annoyed tone, that's what your sentence looked like to me.

Reply 13 of 13, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Maybe we can short-cut the discussion to

Would AA fit into AL? I wonder. I'll try it out.

which was answered by TeaRex's second sentence, namely AL is 8bit and
a two-digit hex number (0x00 to 0xff) fits into that. Keeping the rest of the
discussion down.

Qbix- I can record it if you need me to.

Maybe post the exact wording of the message if you try to log into the board.