flat assembler
Message board for the users of flat assembler.
Index
> DOS > 0x12 graphics |
Author |
|
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. |
|||
17 Aug 2004, 11:00 |
|
mike.dld 17 Aug 2004, 11:19
I meant 16 colors, not 16m colors
I have P-IV 1800@2400 & ATI Radeon 9000 64M |
|||
17 Aug 2004, 11:19 |
|
ASHLEY4 17 Aug 2004, 11:36
Yes, i know what you meant, but 16m is alot better than 16 color' .
\\\\|//// (@@) ASHLEY4. |
|||
17 Aug 2004, 11:36 |
|
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". |
|||
17 Aug 2004, 11:39 |
|
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 |
|||
17 Aug 2004, 12:30 |
|
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. |
|||
20 Aug 2004, 20:21 |
|
neonz 23 Aug 2004, 20:51
ASHLEY4 wrote: Yes, i know what you meant, but 16m is alot better than 16 color' . And requires newer video board with more video memory. |
|||
23 Aug 2004, 20:51 |
|
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. |
|||
24 Aug 2004, 01:43 |
|
neonz 24 Aug 2004, 22:05
ASHLEY4 wrote:
And will not work on 1) non-VESA adapters, 2) 256 KiB VESA adapters (where even 800x600x16 VESA would work). |
|||
24 Aug 2004, 22:05 |
|
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 |
|||
16 Sep 2004, 11:38 |
|
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 |
|||
16 Sep 2004, 11:57 |
|
Matrix 23 Oct 2004, 15:41
Sorry ASHLEY4, i'm moderating myself too
|
|||
23 Oct 2004, 15:41 |
|
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 . \\\\||//// (@@) ASHLEY4. |
|||
24 Oct 2004, 02:08 |
|
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.
|
|||
26 Oct 2004, 10:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.