flat assembler
Message board for the users of flat assembler.

Index > DOS > 0x12 graphics

Author
Thread Post new topic Reply to topic
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 17 Aug 2004, 10:37
I go to 0x12 graphics mode (640x480x16), then use Privalov's go32 and then trying to draw something but graphics address 0xA0000 seems not to be valid - if I'm drawing a pixel at (0,0) it appears somewhere else (bottom half of the screen, to the left). To draw normally, i need to use address 0xA0000-0x5F50 or some other value. How can I determine real graphics address?


Last edited by mike.dld on 17 Aug 2004, 11:20; edited 2 times in total
Post 17 Aug 2004, 10:37
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 17 Aug 2004, 11:00
Y not use vesa ?. Then you can program 640x480 16m, just as easy.
Let me know if you want some demo code, and what pc you have.

\\\\|////
(@@)
ASHLEY4.
Post 17 Aug 2004, 11:00
View user's profile Send private message Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 17 Aug 2004, 11:19
I meant 16 colors, not 16m colors
I have P-IV 1800@2400 & ATI Radeon 9000 64M
Post 17 Aug 2004, 11:19
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 17 Aug 2004, 11:36
Yes, i know what you meant, but 16m is alot better than 16 color' Wink.

\\\\|////
(@@)
ASHLEY4.
Post 17 Aug 2004, 11:36
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 17 Aug 2004, 11:39
doing graphics with 16 color mode isn't as easy, as it is not linear mode, so you have to learn some basics of using vga regs. Just now I can't find any article about it, but try this: http://brand107.home.comcast.net/pc-gpe/

take a look at "VGA" section, especially "Registers and Palette" and "ModeX".
Post 17 Aug 2004, 11:39
View user's profile Send private message Visit poster's website Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld 17 Aug 2004, 12:30
Thanks, decard, but i know this well. Look at this proc:
Code:
use32
; eax = x
; ebx = y
; ecx = color
put_pixel:
        push    ecx
        mov     ecx,eax
        pop     eax
        imul    ebx, 640*4
        lea     edx, [ebx+ecx*4]
        shr     edx,5
        mov     edi,edx
        add     edi,0x0a0000
        and     ecx,0x07
        mov     bl,al
        inc     cl
        mov     ax,0x100
        shr     ax,cl
        mov     dx,0x03cf
        out     dx,al
        mov     al,[edi]
        mov     [edi],bl
        ret    

I just can't understand why it's not working properly e.g. eax=0, ebx=0, ecx=15 must put pixel on the top left corner of the screen but it's not Sad
Post 17 Aug 2004, 12:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 20 Aug 2004, 20:21
in 16 colors CGA, there are 4 planes, each describing one part of color (red, green, blue and brightness). You can see how 16 colors are created in text mode, where 8 bit color describes two colors (foreground and background). Each plane is a bit-buffer, so you have to divide color number into bits, get byte index in plane, get bit index in byte, shift bit value, set bit in plane, and do that with 3 other planes.

In EGA, you have palette of 64 colors, from that only 6 can be chosen and used at the same time.

But this is only theory, i have never done something with CGA/EGA, i was just using EGA registers for pixel-scrolling in text mode. I think I had some TASM examples, but only with czech comments. I can look for them if you really need it.
Post 20 Aug 2004, 20:21
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
neonz



Joined: 02 Aug 2003
Posts: 62
Location: Latvia
neonz 23 Aug 2004, 20:51
ASHLEY4 wrote:
Yes, i know what you meant, but 16m is alot better than 16 color' Wink.


And requires newer video board with more video memory.
Post 23 Aug 2004, 20:51
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 24 Aug 2004, 01:43
This code will run on older machines, use's vesa 1, and can be run in realmode (5. 64k chunks)
Code:
 mov ax,4f02h  ;set vesa 1.0 screen mode mov bx,101h  ;640*480*256 int 10h  mov dx,0xa000 mov ds,dx              ;sets up registers call window rain: xor dx,dx      ;(pages-1)  mouse: push dx call window xor bx,bx mov al, 0cch call dog pop dx cmp dx,4 je rain inc dx mov ah,01h int 16h                   ; have we pressed a key,if no then loop jz mouse  mov ax,0003h       ;back to text mode. int 10h  mov ax,4c00h      ; This is just  int 21h                ; for test ,take it out in your OS   window: mov ax,4f05h    ;vesa 1 window select mov bx,0 int 10h        ;dx is  the reqired window xor bx,bx ret  dog:        ;(4*2^16)+45056 pixels mov [bx],al inc bx cmp bx,$00000 jne dog ret      

And give's 640x480x256, better than 16.

\\\\||////
(@@)
ASHLEY4.
Post 24 Aug 2004, 01:43
View user's profile Send private message Reply with quote
neonz



Joined: 02 Aug 2003
Posts: 62
Location: Latvia
neonz 24 Aug 2004, 22:05
ASHLEY4 wrote:

And give's 640x480x256, better than 16.


And will not work on 1) non-VESA adapters, 2) 256 KiB VESA adapters (where even 800x600x16 VESA would work).
Post 24 Aug 2004, 22:05
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 16 Sep 2004, 11:38
Ashley,
i have made your code a little better:

Code:

_640x480x256=$101

org $100
push es

mov bx,_640x480x256
call bsetvesamode

; mov dx,0xa000
; mov ds,dx              ;sets up registers

 xor dx,dx      ;(pages-1)
 call bselectwindow
 mov al,100
 pages:
 xor dx,dx      ;(pages-1)
 inc al
 top:
 push dx
 push ax
 call bselectwindow
 pop ax
 xor bx,bx
; mov al,0cch
 call dowhat
 pop dx
 cmp dx,4
 je pages
 inc dx
 push ax
 mov ah,11h
 int 16h                   ; have we pressed a key,if no then loop
 pop ax
 jz top

 pop es
 mov ax,0003h       ;back to text mode.
 int 10h

 mov ax,4c00h      ; This is just
 int 21h                ; for test ,take it out in your OS

 dowhat:        ;(4*2^16)+45056 pixels
 push $a000
 pop es
 mov ah,al
 push ax
 shl eax,16
 pop ax
 mov [es:bx],eax
 add bx,4
 or bx,bx
 jnz dowhat
 ret


bsetvesamode: ; bx=mode number
mov ax,4f02h  ;set vesa 1.0 screen mode
 int 10h
ret

bselectwindow:
 mov ax,4f05h    ;vesa 1 window select
 xor bx,bx
 int 10h        ;dx is  the reqired window
 xor bx,bx
 ret

    


MATRIX


Last edited by Matrix on 17 Sep 2004, 20:52; edited 1 time in total
Post 16 Sep 2004, 11:38
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 16 Sep 2004, 11:57
Here it is with no flicker

Code:

_640x480x256=$101

org $100
push es
 push $a000
 pop es

mov bx,_640x480x256
call bsetvesamode

; mov dx,0xa000
; mov ds,dx              ;sets up registers

 xor dx,dx      ;(pages-1)
 call bselectwindow
 mov al,100
 pages:
 xor dx,dx      ;(pages-1)
 inc al

push dx
push ax
 call waitvretrace
pop ax
pop dx

 top:
 push dx
 push ax
 call bselectwindow
 pop ax
 xor bx,bx
; mov al,0cch
 call dowhat
 pop dx
 cmp dx,4
 je pages
 inc dx
 push ax
 mov ah,11h
 int 16h                   ; have we pressed a key,if no then loop
 pop ax
 jz top

 pop es
 mov ax,0003h       ;back to text mode.
 int 10h

 mov ax,4c00h      ; This is just
 int 21h                ; for test ,take it out in your OS

; dowhat:        ;(4*2^16)+45056 pixels
; push $a000
; pop es
; mov ah,al
; push ax
; shl eax,16
; pop ax
; mov [es:bx],eax
; add bx,4
; or bx,bx
; jnz dowhat
; ret

 dowhat:        ;(4*2^16)+45056 pixels
 mov ah,al
 push ax
 shl eax,16
 pop ax
 mov ecx,16384
 xor di,di
 rep stosd
 ret


bsetvesamode: ; bx=mode number
mov ax,4f02h  ;set vesa 1.0 screen mode
 int 10h
ret

bselectwindow:
 mov ax,4f05h    ;vesa 1 window select
 xor bx,bx
 int 10h        ;dx is  the reqired window
 xor bx,bx
 ret

waitvretrace:
     mov dx,3dah
.v1: in al,dx
     and al,08h
     jnz .v1
.v2: in al,dx
     and al,08h
     jz .v2
ret 

    


MATRIX
Post 16 Sep 2004, 11:57
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 23 Oct 2004, 15:41
Sorry ASHLEY4, i'm moderating myself too
Post 23 Oct 2004, 15:41
View user's profile Send private message Visit poster's website Reply with quote
ASHLEY4



Joined: 28 Apr 2004
Posts: 376
Location: UK
ASHLEY4 24 Oct 2004, 02:08
It's the way i code, i start by writing the code all neat and tidy, with full comments, if it works like i think it should, thats ok.
But if it does not work, i start chopping and deselecting bits, to try and find the problem,
and this it when bits get left behind Rolling Eyes.

\\\\||////
(@@)
ASHLEY4.
Post 24 Oct 2004, 02:08
View user's profile Send private message Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Japheth 26 Oct 2004, 10:52
The reason for this error seems to be that DS hasn't a base address of 0. I don't know Go32, so it is just a guess.
Post 26 Oct 2004, 10:52
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.