flat assembler
Message board for the users of flat assembler.

Index > Windows > drawing

Thread Post new topic Reply to topic

Joined: 18 Jan 2012
Posts: 2

I am trying to draw some pixels by using some asm, though it doesn't seem to work.
From what I 've read there should be two ways to draw something, either every pixel on its own, or a editing a buffer and than drawing the buffer. Neither one works by me.

I try to run it from Command prompt, though it seems that graphics video mode fails.
My screen turns total black as if the screen is in sleeping modes, a few seconds later it becomes a little ligther, but no sign of a pixel witch has been changed or something like that.
Another thing is that the program doesn't seem to stop if I have it in video mode. By using the crtl-alt-del I can quit the program.
Do I need to set some extra conditions?? (btw I have Windows XP, my computer was build in 2006)

Making some simple text works fine, with mov ah,$0E\ int $10

If someone now's what's wrong, or know some other solutions.

Thank you

Some examples I tried

INT 10h / AH = 0Ch - change color for a single pixel.

AL = pixel color
CX = column.
DX = row.

format mz ;added for assembler
ORG $100

     mov al, 13h
 mov ah, 0
   int 10h     ; set graphics video mode. 
     mov al, 1100b
       mov cx, 10
  mov dx, 20
  mov ah, 0ch
 int 10h     ; set pixel. 
;//and added myself
  mov ah,10h
  int 16h           keypress I suppose
  mov al, 3h
  mov ah, 0
  int 0h     ; should be going back to normal mode
  mov  ah,$4C
  int  $21    ; Return to DOS

;Site I copied it from http://www.scribd.com/doc/61769669/asm

MOV AH,00h ;get into video mode. 00 = Set Video Mode
MOV AL,13h ;13h = 320x240x16
INT 10h
;SET_VSEGMENT: ;set up video segment
MOV AX,0A000h ;point ES to VGA segment
;VALUES: ;various values used for plotting later on
MOV AX,100 ;X location
MOV BX,100 ;Y location
MOV CX,120 ;Y location
;GET_OFFSET: ;get offset of pixel location using X,Y
MOV DI,AX ;put X location into DI
MOV DX,BX ;and Y into DX
SHL BX,8 ;Y * 2^8. same as saying Y * 256
SHL DX,6 ;Y * 2^8. same as saying Y * 64
ADD DX,BX ;add the two together
ADD DI,BX ;and add the X location
;this whole thing gives us the offset location of the pixel  
MOV AL,4 ;set color attributes
REP STOSB ;and store
XOR AX,AX ;wait for keypress
INT 16h
MOV AX,0003h ;switch to text mode
INT 10h
INT 20h ;and 
Post 19 Jan 2012, 18:56
View user's profile Send private message Reply with quote

Joined: 20 Feb 2006
Posts: 4273
Location: Now
here is windows section, you code is related to DOS (org 100h) section.
format MZ + org 100H???

to fill all the screen in red in mode 13h, ou can try that for example.
and compare with your code and you'll see where it don't work by experiments.
org 100h
mov ax,13h
int 10h
push es 0a000h
pop es
mov al,RED
mov di,0
mov cx,64000
rep stosb
pop es
;mov ax,3 ;comment it to see the result at exit in console
;int 10h  ;here, your first code have int 0h, maybe a typo error.

hope it helps.
Post 19 Jan 2012, 19:32
View user's profile Send private message Visit poster's website Reply with quote

Joined: 18 Jan 2012
Posts: 2
Thank you for your reply.

I copied your entire program, though I still have the same problem. When I execute it, it behaves for the user exactly the same as earlier tries I had.
When I execute it my screen first turns black, and later a different color of black, but no sign of any red pixels. I also have the problem that the only way I can exit the program (either with or without the mov ax,3 int 10h), is by pressing the windows-button and crtl-alt delete.

The problem doesn't solve itself if I run it from flat assembler (version 1.69.35)

Could it be that my computer is in some kind of mode, (or not), where drawing this way is disabled. Or that I might need something witch isn't in a every day computer?
Post 19 Jan 2012, 20:32
View user's profile Send private message Reply with quote

Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
It is probably problem of DOS compatibility. The programs above are not windows programs, they are DOS programs. Try booting FreeDOS and use FASM for DOS for ultimate test.
Post 20 Jan 2012, 07:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote

Joined: 28 Jan 2004
Posts: 1464
Location: Toronto, Canada
The DOS INT 10h should work fine in NTVDM.
It is emulated by Windows, but should be OK (before Win7, I think).
I tried it.
Post 20 Jan 2012, 15:25
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.