Jump to content
xisto Community
vizskywalker

VESA Programming Assembly

Recommended Posts

For months now I have been trying t o do assembly programming in SVGA. I am doing 16 bit assembly, not 32 bit , so I do not have an API to use. I have been to the VESA page and downloaded their standards. But when entering a lot of the video modes, The screen goes into power saving mode. Any help on resolving this issue would be helpful. And it is a problem with every computer I try it on, so it is not a hardware problem.

Share this post


Link to post
Share on other sites

No need to use their standards, just use interrupt 10h to do that, I show you how to program VESA 1.2 because VESA 2.0 is protected mode programing.

1. You need to gather information about requested graphics mode,
2. you must initialize that mode,

3. switch bank, if needed (in VESA you have access to memory across bank)
4. draw

I give you some code in Pascal/Assembler:

 TModeInfo = Record    ModeAttributes    :Word;    WinAAttributes    :Byte;    WinBAttributes    :Byte;    WinGranularity    :Word;    WinSize           :Word;    WinASegment       :Word;    WinBSegment       :Word;    BankSwitch        :Pointer;    BytesPerScanLine  :Word;    XResolution       :Word;    YResolution       :Word;    Reserved          :Array[0..233] of Byte;  End;Var  ActualBank :Word;  BankSwitch :Pointer;{/---------------------------------------------------------------------------  Name: GetModeInfo(Mode: Integer; ModeInfo: TModeInfo)  Desc:  Exp.: GetModeInfo($114,ModeInfo); $114 = 800x600 (64K Colors)/---------------------------------------------------------------------------}Procedure GetModeInfo(Mode: Integer; ModeInfo: TModeInfo); Assembler;Asm       push    es       push    di       push    cx       les     di, ModeInfo       mov     cx, Mode       mov     ax, 4F01h       int     10h       mov     ax, word ptr es:[di+0].(TModeInfo).BankSwitch       mov     word ptr [BankSwitch+0], ax       mov     ax, word ptr es:[di+2].(TModeInfo).BankSwitch       mov     word ptr [BankSwitch+2], ax       pop     cx       pop     di       pop     esEnd; { GetModeInfo }{/---------------------------------------------------------------------------  Name: SetVesaMode(Mode: Integer)  Desc:  Exp.: SetVesaMode($114);/---------------------------------------------------------------------------}Procedure SetVesaMode(Mode: Integer); Assembler;Asm       push    bx       mov     bx, Mode       mov     ax, 4F02h       int     10h       pop     bxEnd; { SetVesaMode }
This is pure assembler procedure, in Pascal you need write their prototype.
;/---------------------------------------------------------------------------;  Name:  Vesa_PutPixel_800x600x64;  Desc:;/---------------------------------------------------------------------------Vesa_PutPixel_800x600x64  PROC FAR USES ebx ecx edx esi edi es, \                               x :DWORD, y :DWORD, r :BYTE, g :BYTE,  b :BYTE       mov     eax, y       mov     ebx, eax       mov     edx, eax       shl     eax, 10       shl     ebx, 9       shl     edx, 6       add     eax, ebx       add     eax, edx       mov     ecx, x       shl     ecx, 1       add     eax, ecx       mov     esi, eax       shr     esi, 16       mov     cx, si       mov     ebx, esi       shl     ebx, 16       sub     eax, ebx       mov     di, ax       mov     ax, ActualBank       cmp     ax, cx       je      @@1       xor     bx, bx       mov     dx, cx       call    dword ptr [BankSwitch]@@1:   mov     ax, 0A000h       mov     es, ax       mov     si, di       mov     al, r       shl     ax, 6       add     al, g       shl     ax, 5       add     al, b       mov     word ptr es:[si], ax       mov     ActualBank, cxRETVesa_PutPixel_800x600x64  ENDP

Share this post


Link to post
Share on other sites
Difficulty?VESA ProgrammingReplying to zomoIs it possible to put this completely in assembly code without any PASCAL defines. (or at least a simple executable - ie a working example).Most people experience the same problem when using VESA modes. By changing the resolutionThe image squashes into the top area of the screen. What most people want to know is how to move a pixel about by changing the x y values only, and having the pixel respond accordingly on the screen, in the different resolution modes, with simplicity and control.-question by DENE

 

Share this post


Link to post
Share on other sites

VESA ProgrammingVESA Programming

The first step is to look into the modetable using VBE function 0 if there is a corresponding mode number aviable. To check the resolution of that numbers we have to use VBE function 1.

Here is a small aplication for to assemble with MASM 5:

.MODEL SMALL						  ; Programm möglichst klein halten.386  CODE SEGMENT use16 'CODE' assume cs:CODE,ds:DATEN,ss:STAPEL org 100hSTART:    mov	  ax, DATEN		   ; Segmentadresse vom Datenbereich	  mov	  ds, ax			  ;  in das DS-Segmentregister laden	  mov	  es, ax			  ;  in das ES-Segmentregister laden	  mov	  di, OFFSET VINF	 ; Zeiger auf ausgewählten Datenbereich (512 Bytes)	  mov	  ax, 4F00h		   ; Vesa Funktionsnummer 0	  int    10h				   ; Vesa-Bios-Analyse holt 512 Bytes nach es:di (Datensegment:VINF)	  cmp	  ax, 4Fh			 ; Wenn Rückgabewert "4F" dann war Funktion erfolgreich	  jnz NOVESA				   ;  sonst FEHLER: Kein Vesabios vorhanden	  mov	  dl, [di+5]		  ; Major version number of Vesa über ds:di+5 in das dl-Register holen	  cmp	  dl, 2			   ;  kleiner als Version 2 ?	  jb  VESA1				    ;  wenn ja FEHLER: Keine Modeliste vorhanden.;--------------------------------------	  lfs	  si, [di+0Eh]	    ; Pointer der Modeliste über ds:di+E ins fs-Segmentregister und si-Offsetregister ladenMODE:	 mov	  cx, fs:[si]		 ; Modenummern über fs:si ins cx-register holen	  lea	  si, [si+2]		  ; Qell-Adresszeiger(Offset) erhöhen	  cmp	  cx, 0FFFFh		  ;  Ende der Liste erreicht?	  jnz MEND		  xor	  eax, eax		  mov	  ax, cx		  call HEXOUT				  ; Vesamode ausgeben	  mov	  ax, 4F01h		   ; Modus spezifische Info holen		  mov	  di, OFFSET MINF	  int    10h				   ; es:di 256 byte	  cmp	  ax, 4Fh	  jnz NOVESA				   ; FEHLER: wird nicht unterstützt	  mov	  ax, [di+12h]	    ; MaxX		  call DEZOUT	  mov	  ax, [di+14h]	    ; MaxY		  call DEZOUT		  xor	  eax, eax	  mov	  al, [di+19h]	    ; Bit per pixel?		  call DEZOUT	  and	  BYTE PTR[di], 80h   ;  linear access enable ?		  jz  short NOLIN	  mov	  eax, [di+28h]	   ;  linearer Bild-Offset vorhanden ?		  call HEXOUTNOLIN:		  jmp MODE;------------------------------------- org START + ((($-START)/16)*16)+16   ; Code-Ausrichtung;-------------------------------------VESA1:		  mov	   cl, 1		  jmp ERREND;------------------------------------- org START + ((($-START)/16)*16)+16   ; Code-Ausrichtung;-------------------------------------NOVESA:		  mov	   cl, 0FFh		  jmp ERREND;------------------------------------- org START + ((($-START)/16)*16)+16   ; Code-Ausrichtung;-------------------------------------MEND:	 xor	  cl, clERREND:   mov	  al, cl			 ; ERRORLEVEL holen		  mov	  ah, 4Ch		    ; Rücksprung, Programm-Ende		  int    21h:----------------------------------------------------------------------------; EAX nach zehn dezimalen ASCII's wandeln und I'm Daten-Bereich ablegen:---------------------------------------------------------------------------- org START + ((($-START)/16)*16)+16   ; Code-Ausrichtung;-------------------------------------DEZOUT:   pusha		  mov	 di, OFFSET ASCII		  mov	 cl, 0Ah			 ; Zehn dezimale ASCII's		  mov	 ebx, 1000000000WANDEL:   xor	 edx, edx		  div	 ebx		  add	 al, 30h			 ; nach ASCII wandeln		  mov	 esi, edx		    ; Rest retten		  mov	 [di], al		    ; Ziffer retten		  inc	 di				  ; Zeiger erhöhen		  mov	 eax, ebx		  mov	 ebx, 0Ah		  xor	 edx, edx		  div	 ebx		  mov	 ebx, eax		  mov	 eax, esi		  dec	 cl		  jnz WANDEL;-------------------------------------GEBAUS:   mov	 si, OFFSET ASCII-1  ; erste(and) Null(en) überlesen		  mov	 dx, si		  inc	 dxNULL:	 inc	 si		  cmp    BYTE PTR[si], "0"		  jz  NULL		  sub	 si, 0Ah		  cmp	 si, dx		  jz  short AUSG			   ; keine null vorhanden !		  add	 si, 0Ah		  mov	 dx, siAUSG:	 mov	 ah, 9			    ; dezimale Zahl ausgeben		  int   21h		  popa		  ret:----------------------------------------------------------------------------; EAX nach acht hexadezimale ASCII's wandeln und I'm Daten-Bereich ablegen:---------------------------------------------------------------------------- org START + ((($-START)/16)*16)+16   ; Code-Ausrichtung;-------------------------------------HEXOUT:   pusha		  mov	 di, OFFSET ASCII    ; Doppel-Word nach Hex-Ziffern wandeln		  mov	 cl, 8			   ; 8 ZiffernA:	    rol	 eax, 4			  ; 1 Nibble weiter		  mov	 bl, al		  and	 bl, 0Fh			 ; nur low-Nibble		  add	 bl, 30h			 ; nach ASCII wandeln		  cmp	 bl, 39h			 ;  größer als Ziffer neun ?		  jna short B		  add	 bl, 7			   ; dann Buchstabe von "A" bis "F"B:	    mov	 [di], bl		    ; ASCII retten		  inc	 di				  ; Zeiger erhöhen		  dec	 cl				  ; Ziffer-Anzahl verringern		  jnz A		  jmp GEBAUS  CODE ends:----------------------------------------------------------------------------  DATEN SEGMENT use32 'DATA';-------------------------------------VINF	  DB 512 dup (0AAh)		    ; Vesa-Info(4F00)MINF	  DB 256 dup (44h)			 ; Mode-Info(4F01)ASCII	 DB "0000000000", "$"  DATEN ends:----------------------------------------------------------------------------  STAPEL SEGMENT use16 STACK 'STACK'	   DB 30h dup (88h)
STAPEL ends endFor more details have a look into the "vbe3.Pdf" which can be free download from "vesa.Org" (registration and login), or simple mail me to: freecrac at web.De

Dirk

-reply by Dirk Wolfgang Glomp

Share this post


Link to post
Share on other sites

VESA Programming

This pure 16 Bit DOS aplication below demonstrate how to use a vesamode with a resolution of 1024 x 768 x 32 with an own refreshrate of 100hz and additionaly it demonstrate how to use the linear framebuffer with hardware triple buffering.

To enable an access to the linear framebuffer i prefer the unrealmode/bigrealmode. For to use the unrealmode/bigrealmode we have to remove/REM any memmory manager like emm386.exe in our config.sys before. After rebooting without it we can start the aplication.

 

Goal of the aplication: If the application starts without any error message, then the application switch into the vesamode and begin to move some balls across the screen and if they reached a border of the screen, then they turn their direction.

For to terminate the application and to switch back to DOS in the textmode(3) please press any key on your keyboard.

 

Minimum system requirements:

Operating system: DOS 5, 6, or DOS 7 (a part of Windows98/ME) // Not working under Windows(DOSbox) and not working with a memmory manager like emm386.exe.

MMX-CPU (tested on AMD Palomino 1800+@1550mhz and on AMD Tbred 2700+@2100mhz; Socket A mainboard with AGP)

Fully working vesa 3 Bios (tested on MSI NVIDIA Geforce 4 TI 4200 64MB AGPx4 // failed with Powercolor ATI x800 pro(VBE3 256MB AGPx8))

CRT-Monitor with DDC and 96 khz (tested on 19" Samsung 940 and on 19" SAMTRON 96P)

 

Used public documents from vesa.org(register and/or login):

EEDIDguideV1.pdf

vbe3.pdf

 

...

 

Sorry, because i reached the limit for to post here i have to split the source-Code in two or tree parts looking forward to my next post.

But all lines of the source must be in one file for to assemble it. So you have to merge it together.

 

This is the first part of the source-code:

;--------------------------------------------------------------------------------------------------------------; I have written this sourcecode for MASM 5.; Example for to generate a 16 bit executable for a pure DOS-enviroment:; MASM /Z FILENAME.asm,FILENAME.obj,,; LINK /CP:1 FILENAME.obj,FILENAME.exe,,,;--------------------------------------------; Legal situation: No personalised spiritual ownership or liquidication rights for usement,; or for spreading out aviable, because all ideas are (at all hazards) only a small part of the; heritage of our common human culture and nobody can progress an idea without to make a use; of our all intergenerational relationships beginning from our roots thousands of years ago.;--------------------------------------------; Freeware and a wide-ranging transparency in the world helps a lot for to establish a social freedom and a gracefull living.; But additional We have to act very soon for to feed all humans and to stop the immiseration in the world.; Over one billion of humans are very hungry today, yesterday, the day before yesterday............; They all will die very painfully, if we can´t stop that with the highest ermergency now.;---------------------------------------------------------------------------------------------------------------.MODEL SMALL						  ; We want a small aplication.386P								 ; Enable protectmode instructions.387								  ; Enable FPU instructions;--------------------------------------	MaxX		 =	   1024		 ; Horizontal resolution of the requested vesamode	MaxY		 =		768		 ; Vertical resolution	MAXHZ		=		160		 ; CRT-Monitor: HZ	MAXKHZ	   =		 96		 ; KHZ	KreiFa	   =   00FFDD00h		; Circel Color	Vring		=   00030400h		; Color decrement	Groesse	  =		02Dh		; Radius of the ball (2Dh)	XPos		 =	 Groesse		; Position of the ball	YPos		 =	 Groesse	Anzahl	   =		 35h		; Number of Objects (max.255)	HFarb		=	0; 0100A03h	; Background Color	Max_X		=   (MaxX-(XPos*2))-9; Max and min	Max_Y		=	MaxY-(YPos*2)   ;  X/Y Position	Min_X		=		 9		  ;   of the movement area	Min_Y		=		 9	IRQs_Port	=		 21h		; Port-Adress: IRQ-Controller	Tast_Port	=		 60h		; Port-Adress: Keyboard-Controller	Stat_Port	=		 64h		; Port-Adress: Keyboard-Status	Cmos_Port	=		 70h		; Port-Adress: Bios-Cmos-Chip	Cr		   =		 0Dh		; Carriage Return	Lf		   =		 0Ah		; Line Feed	Ausri		=		 16		 ; Bytes for code alignment;----------------------------------------------------------------------------  CODE SEGMENT use16 'CODE' assume cs:CODE,ds:DATEN,ss:STAPEL org 100h;--------------------------------------START:	mov	  eax, 1			 ; Request for feature flags	   DB 0Fh, 0A2h				   ; CPUID instruction		  test	 edx, 00800000h	 ;  is MMX feature flag(bit 23) set?		  jz  NOMMX		  mov	  ax, DATEN		  ; Store relative Segmentadress of the Datasegment	  mov	  ds, ax			 ;  into DS-Segmentregister	  mov	  es, ax			 ;  into ES-Segmentregister	  mov	  di, OFFSET VINF	; Buffer(512 Bytes) for VESA-Info	  mov	  ax, 4F00h		  ; Function 0	  int	10h				  ; Get up to 512 Bytes es:di (Datasegment:VINF)	  cmp	  ax, 4Fh			;  succsesfull ?	  jnz NOVESA				  ;   else error: no Vesabios aviable	  cmp	 Byte PTR[di+5], 3   ; Compare major version number of Vesa	  jb  NOVESA3				 ;  lesser than Version 3 ?	  lfs	  si, [di+0Eh]	   ; Get pointer of Modelist in FS:SIMODE:	 mov	  cx, fs:[si]		; Get Modenumber	  lea	  si, [si+2]		 ; Instead of "add si,2" (increase Offset of modelist)	  cmp	  cx, 0FFFFh		 ; End of list ?	  jnz NOMODE		  add	  cx, 4000h + 800h   ; VESAnumber + linear + CRTC	  mov	  ax, 4F01h		  ; Get Mode Info		  mov	  di, OFFSET MINF	; Buffer(256 Bytes) for Mode Info	  int	10h	  cmp	  ax, 4Fh	  jnz NOVESA	  cmp	 Word PTR[di+12h], MaxX		  jnz MODE		  cmp	 Word PTR[di+14h], MaxY		  jnz MODE	  cmp	 BYTE PTR[di+19h],20h; 32 Bits per pixel?		  jnz MODE	  and	 BYTE PTR[di], 80h   ; Linear access enable ?		  jz  NOLIN	  mov	  eax,[di+28h]		  and	  eax, eax		   ; Check if the linear Offset to the framebuffer is aviable ?		  jz  NOLIN		  mov	  bp, cx			 ; Store the modenumber;--------------------------------------		  mov	  ax, 4F0Bh		  ; Get/set Pixel-Clock		  mov	  dx, cx		  xor	  bl, bl			 ; Get		  mov	  ecx, DWORD PTR[PIXCLOC]		  int	10h		  cmp	  ax, 4Fh		  jnz NOCLOC				  ; Error: No pixelcloc		  mov	  DWORD PTR[PIXCLOC], ecx;--------------------------		  xor	  eax, eax		   ; Calculate Refreshrate		  mov	  ax, [CRTC]		 ; Horizontal Total		  xor	  ebx, ebx		  mov	  bx, [VERTOTA]	  ; Vertikal Total		  mul	  ebx		  mov	  ebx, eax		  mov	  eax, ecx		   ; Pixelcloc		  mov	  esi, 10		  xor	  edx, edx		  div	  esi		  xor	  edx, edx		  div	  ebx		  mov	  [REFRATE], ax	  ; RefreshRate=Pixelcloc/(HTotal*Vtotal);--------------------------------------	  mov	  ax, 4F15h		  ; DDC - INSTALLATION CHECK	  mov	  bl, 0			  ;  for to get the monitor information	  int	10h	  cmp	  ax, 4Fh	  jnz NODDC	  mov	  ax, 4F15h		  ; DDC - READ EDID	  mov	  bl, 1	  xor	  cx, cx	  xor	  dx, dx	  mov	  di, OFFSET EDID	  int	10h	  mov	  eax, 0FD000000h	; Text-identifier V/H range	  mov	  bx, 36h	  cmp	  [di+bx], eax	   ; di+36h detailed timing #1	  jz  short H1	  add	  bx, 12h	  cmp	  [di+bx], eax	   ; di+48h detailed timing #2	  jz  short H1	  add	  bx, 12h	  cmp	  [di+bx], eax	   ; di+5Ah detailed timing #3	  jz  short H1	  add	  bx, 12h	  cmp	  [di+bx], eax	   ; di+6Ch detailed timing #4	  jnz NODDCH1:	   cmp	 BYTE PTR[di+bx+6], MAXHZ		  jb  NOHZ	  cmp	 BYTE PTR[di+bx+8], MAXKHZ		  jb  NOKHZ;--------------------------------------		  mov	  ax, 4F02h		  ; Switch to the requested vesamode		  mov	  bx, bp			 ;  with an access to the linear framebuffer		  mov	  di, OFFSET CRTC	;  and with an own Video-Timing(..refreshrate)		  int	10h		  cmp	  ax, 4Fh		  jnz NOMODE				  ; ERROR: No Vesamode;-----------------Switch to the unrealmode----------------------------------		  cli						 ; Dissable software-Interrupts		  mov	  al, 2			  ; Dissable IRQ 1		  out	  IRQs_Port, al		  in	   al, Cmos_Port	  ; Dissable Non-Mask-Interrupts(NMIs)		  or	   al, 80h		  out	  Cmos_Port, al		  call ESEG				   ; Switch to the Unrealmode(Enhance segment)		  mov	  ax, DATEN		  mov	  ds, ax		  in	   al, Cmos_Port	  ; Enable NMI's		  and	  al, 7Fh		  out	  Cmos_Port, al		  sti						 ; Enable Software-Interrupts;-----------------------------------------------------------------------------; Create an Offset table of startadresses of any line of the linear framebuffer;-----------------------------------------------------------------------------		  call PIXOFF				 ; ...placed in the beginning of the data segment;----------------------------------------------------------------------------		  finit					   ; Paint a ball		  mov	 DWORD PTR[XM], XPos		  mov	 DWORD PTR[YM], YPos		  mov	 DWORD PTR[COL], KreiFa		  mov	  ecx, 1			 ; RadiusRUND:	 call KREIS				  ;  Root-Circle		  lea	  ecx, [ecx+1]	   ; inc ecx		  sub	 DWORD PTR[COL], Vring; Color decreasing		  cmp	  ecx, Groesse		  jnz RUND;--------------------------------------		  call TABELLE				; Create a sprite-table of any colored pixel of the the screen;--------------------------------------		  mov	  si, OFFSET BALL	; Clear the screen from the ball		  xor	  eax, eax		   ; Color blackOBJLO:	mov	  ebx, [si]		  ; Get the Offset		  lea	  si, [si+8]		 ; add si, 8		  mov	  [ebx], eax		 ; To the screen		  cmp	  si, bp			 ;  End of table ?		  jb  OBJLO;-------------------------set all balls to the screen-----------------------		  mov	  si, OFFSET SX0	 ; Offset of Position-Table		  mov	  di, OFFSET STEP0X  ; Offset of Stepper-TableHIN:	  mov	  ebx, [si]		  ; Get X-Position		  mov	  eax, [di]		  ; Get X-Stepper		  mov	  ecx, [si+4]		; Get Y-Position		  mov	  edx, [di+4]		; Get Y-Stepper		  shl	  ebx, 2			 ; X * 4 Byte (true color)		  shl	  eax, 2			 ; X-Stepper * 4 Byte (true color)		  mov	  ecx, [ecx*4]	   ; Get line		  mov	  edx, [edx*4]	   ; Get Stepper-line		  sub	  ecx, DWORD PTR[PIXTAB]; Substract linear screen-Offset		  sub	  edx, DWORD PTR[PIXTAB]; Substract linear screen-Offset		  mov	  [si], ebx		  ; Write X back		  mov	  [si+4], ecx		; Write Y back as line		  lea	  si, [si+8]		 ; add si,8		  mov	  [di], eax		  ; Write back X-Stepper		  mov	  [di+4], edx		; Write back Y-Step as Step-line		  lea	  di, [di+8]		 ; add di,8		  cmp	  si, Anzahl*8+OFFSET SX0		  jb  HIN;--------------------------------------		  mov	  edx, DWORD PTR[PICAKT]; Get the actual adress of the framebuffer;--------------------------------------		  mov	  bx, OFFSET HINFAR  ; Background color	   DB 0Fh, 6Fh, 7				 ; MOVQ mm0, [bx];----------------------------------------------------------------------------	   DB  0EAh					   ; Clear Prefetch-buffer:	   DW  (OFFSET ACTION)			; The following lines create	   DW  (SEG ACTION)			   ;  the opcode of "JMP FAR CS:ACTION";----------------------------------------------------------------------------;						  M  A  i  N  -  R  O  U  T  I  N  E;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri; Code-Alignment;---------------------------------------------------------------------------ACTION:   mov	  ebx, edx			 ; Movement and checking if a ball		  mov	  ecx, DWORD PTR[PICLEN];  reached a border		  mov	  si, OFFSET SX0	   ; Offset of Position-Table		  mov	  di, OFFSET STEP0X	; Offset of Stepper-Table		  add	  ebx, DWORD PTR[PIXTAB]		  shr	  ecx, 3										; Beginning with to clear the screenCLEAN:  DB 67h, 0Fh, 7Fh, 3			 ; MOVQ [ebx], mm0		  lea	  ebx, [ebx+8]		 ; add bx,8		  dec	  ecx		  jnz CLEAN;----------------------------------------------------------------------------ALL:	  mov	  ebx, [si]			; Get X-Position		  cmp	 BYTE PTR[di+S_Len], 1 ; Compare Plus/Minus-XFlag		  jz  short FRAGX1			  ;  if minus, then jumpFRAGX0:   cmp	  ebx, Max_X * 4	   ; Compare X-Position with max.-X		  jb  short MAKEX0			  ;  if less, then jump		  mov	 BYTE PTR[di+S_Len], 1 ; Set Minus-XFlagMAKEX1:   sub	  ebx, [di]			; X - XStepper 		  jmp  short ALLX;-------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;--------------------------------------FRAGX1:   cmp	  ebx, Min_X * 4	   ; Compare X-Position with min.-X		  ja  short MAKEX1			  ;  if above, the jump		  mov	 BYTE PTR[di+S_Len], 0 ; Set Plus-XFlagMAKEX0:   add	  ebx, [di]			; X + XStepper ALLX:	 mov	  [si], ebx			; save X-Position;----------------------------------------------------------------------------		  mov	  ecx, [si+4]		  ; Get line		  cmp	 BYTE PTR[di+S_Len+1],1; Compare Plus/Minus-line-Flag		  jz  short FRAGY1			  ;  if minus, then jumpFRAGY0:   cmp	  ecx, Max_Y * (MaxX*4); Compare line with max.line		  jb  short MAKEY0			  ;  if lesser, then jump		  mov	 BYTE PTR[di+S_Len+1],1; Set Minus-lineflagMAKEY1:   sub	  ecx, [di+4]		  ; Line - linestepper 		  jmp  short ALLY;-------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;--------------------------------------FRAGY1:   cmp	  ecx, Min_Y * (MaxX*4); Compare line with min.line		  ja  short MAKEY1			  ;  if above, then jump		  mov	 BYTE PTR[di+S_Len+1],0; Plus-YFlag setzenMAKEY0:   add	  ecx, [di+4]		  ; Line + linestepper ALLY:	 mov	  [si+4], ecx		  ; Save new line		  lea	  si, [si+8]		   ; Increase Table-Offset (Position)		  add	  ecx, ebx			 ; Line plus X		  mov	  [RETTSI], si		  mov	  si, OFFSET BALL	  ; Table-Offset start		  add	  ecx, edxOBJECT:   mov	  ebx, [si]			; Get Sprite-Offset from Table		  mov	  eax, [si+4]		  ; Get color from Table		  lea	  si, [si+8]		   ; Increase Tablen-Offset		  mov	  [ebx+ecx], eax	   ; Color to the screen		  cmp	  si, bp			   ;  End of Table ?		  jb  OBJECT		  mov	  si, [RETTSI]		  lea	  di, [di+8]		   ; Increase Table-Offset (Stepper)		  cmp	  si, Anzahl*8+OFFSET SX0; Table-End ?		  jb  ALL;--------------switch the screen adress using triple buffering------------		  cmp	  BYTE PTR[FLAG], 0		  jz  short ASUKBSUK:	 mov	  ecx, edx			; Display-Start-Adress		  mov	  bx, 4			   ; Wait until Display shedule		  mov	  ax, 4F07h		  int 10h		  and	  cx, cx		  jnz BSUK;--------------------------------------ASUK:	 mov	  ecx, edx			; Display-Start-Adress		  add	  edx, DWORD PTR[PICLEN]; Get new Adress		  mov	  bx, 2			   ; Shedule new Display-Start-Adress		  mov	  ax, 4F07h		  int 10h		  mov	 BYTE PTR[FLAG], 1		  cmp	  edx, DWORD PTR[PICMAX]		  jna short NODO		  xor	  edx, edx;---------------------------------------------------------------------------NODO:	 in	   al, Stat_Port	  ; Get Keyboad-Status		  test	 al, 1			  ; Input buffer empty?		  jz  ACTION				  ;  else repeat movement	  test	 al, 20h	  jnz ACTION				  ; PS2-Mouse will be ignored;----------------------------------------------------------------------------;-----------------------End of main-routine----------------------------------;----------------------------------------------------------------------------		  in	   al, Tast_Port	  ; Get key		  cli		  xor	  al, al			 ; IRQ 1 freigeben		  out	  IRQs_Port, al		  sti		  mov	  ax, 3			  ; Text-Mode		  int	10h		  xor	  cl, cl			 ; No ERROR		  mov	  ah, 1			  ; Clear Keyboard buffer		  int	16h;-------------------------------------	   DB 0Fh, 0Eh					; 0Fh, 77h EMMS // 0Fh, 0Eh FEMMS;-------------------------------------HOME:	 mov	  al, cl			 ; Get the ERRORLEVEL		  mov	  ah, 4Ch			; Jump back to DOS		  int	21h;----------------------------------------------------------------------------;						 ERROR Messages;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOMODE:   mov	  cl, 1		  mov	  dx, OFFSET ERTEX1  ; NO VESA MODEERROUT:   mov	  ah, 9			  ; Text ausgeben		  int	21h		  jmp HOME;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOLIN:	mov	  cl, 2		  mov	  dx, OFFSET ERTEX2  ; No linear Offset		  jmp ERROUT;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOMMX:	mov	  cl, 3		  mov	  dx, OFFSET ERTEX3  ; No MMX-CPU		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOVESA:   mov	  cl, 4		  mov	  dx, OFFSET ERTEX4  ; No Vesa		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOVESA3:  mov	  cl, 5		  mov	  dx, OFFSET ERTEX5  ; No VESA 3		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NODDC:	mov	  cl, 6		  mov	  dx, OFFSET ERTEX6  ; No DDC		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOKHZ:	mov	  cl, 7		  mov	  dx, OFFSET ERTEX7  ; Less than 96 khz		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOHZ:	 mov	  cl, 8		  mov	  dx, OFFSET ERTEX8  ; Less than 160 hz		  jmp ERROUT;--------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;---------------------------------------------------------------------------NOCLOC:   mov	  cl, 9		  mov	  dx, OFFSET ERTEX9  ; No Pixelcloc		  jmp ERROUT;----------------------------------------------------------------------------;					 GDT for the Protected Mode;---------------------------------------------------------------------------- org START + ((($-START)/64)*64)+64;----------------------------------------------------------------------------GDTZEIGER DW ?	 ; Lenght of the GDT		  DW ?	 ; Adress low -Word:SEGMENTE		  DW ?	 ; Adress high-Word:SEGMENTE		  DW 0	 ; reservedSEGMENTE  DW 0	 ; Bits: 0-15 Seg.lenght(Bit0-15)		  DW 0	 ; Bits: 0-15 Basis-Adress Deskriptor-Table		  DB 0	 ; Bits:16-23 Basis-Adress Deskriptor-Table		  DB 0	 ; Bits: 0- 7 Access rights		  DB 0	 ; Bits: 0- 3 Seg.lenght(Bit16-19)/Bit7:1=4KByte/0=1Byte		  DB 0	 ; Bits:24-31 Basis-Adress Deskriptor-Table;-------------------------------------------- Selektor	Segmente	   DW 0FFFFh; Segmentlenght  Bits: 0-15  --------  -----------	   DW 0	 ; Adress low	 Bits: 0-15  ¦ 08h  ¦  ¦Code (CS)¦	   DB 0	 ; Adress high	Bits:16-23  +------+  +---------+	   DB 9Ah   ; Access rights	   DB 0	 ; Seg.Länge Bits:16-19 im Bit0-3 /Bit7:1=4KByte/0=1Byte	   DB 0	 ; Seg.Adress	 Bits:24-31;--------------------------------------------- Selektor	Segmente	   DW 0FFFFh; Segmentlenght  Bits: 0-15  --------  ------------	   DW 0	 ; Adress low	 Bits: 0-15  ¦ 10h  ¦  ¦Stack (SS)¦	   DB 0	 ; Adress high	Bits:16-23  +------+  +----------+	   DB 92h   ; Access rights	   DB 0	 ; Seg.Lenght Bits:16-19 im Bit0-3 /Bit7:1=4KByte/0=1Byte	   DB 0	 ; Seg.Adress	 Bits:24-31;--------------------------------------------- Selektor	Segmente	   DW 0FFFFh; Segmentlenght  Bits: 0-15  -------- ---------------	   DW 0	 ; Seg.Adress	 Bits: 0-15  ¦  18h ¦ ¦(DS,ES,FS,GS)¦	   DB 0	 ; Seg.Adress	 Bits:16-23  +------+ +-------------+	   DB 92h   ; Access rights	   DB 0FFh  ; Seg.Lenght Bits:16-19 im Bit0-3//Bit7:1=4KByte/0=1Byte	   DB 0FFh  ; Seg.Adress	 Bits:24-31;---------------------------------------------------		SEGMENTE_END label WORD		Gdt_Groesse equ (OFFSET SEGMENTE_END - SEGMENTE -1);----------------------------------------------------------------------------;----------------------------Subroutines-------------------------------------;----------------------------------------------------------------------------; Set for the DS(,ES,FS,GS)-Register a new segmentlenght of 00FFFFFFh.; For that we switch into the Protected Mode und back to the (Un)Realmode.;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;----------------------------------------------------------------------------ESEG:	 xor	  eax, eax		  mov	  ax, cs		  mov	  ds, ax		  shl	  eax, 4					   ; EAX is now physical		  mov	  ebx, eax					 ; Segmentstartadresse		  mov	 WORD PTR[SEGMENTE+0Ah], ax	;  into the Deskriptors		  mov	 WORD PTR[SEGMENTE+12h], ax	;  for CS		  ror	  eax, 10h					 ;  and SS store into		  mov	 BYTE PTR[SEGMENTE+0Ch], al	;  the GDT		  mov	 BYTE PTR[SEGMENTE+14h], al		  xor	  eax, eax					 ; EAX null		  mov	  ax, OFFSET SEGMENTE		  ; 16-Bit-Offset		  add	  ebx, eax					 ; GDT-Adress in		  mov	 WORD PTR[GDTZEIGER], Gdt_Groesse; GDT-Deskriptor		  mov	 DWORD PTR[GDTZEIGER+2], ebx		  pushf								 ; Save Flags		  lgdt	FWORD PTR[GDTZEIGER]		  ; Load GDT		  mov	  dx, ss					   ; Save SS		  mov	  eax, cr0					 ; Controlword 0 to EAX		  or	   al, 1						; Protected Mode on		  mov	  cr0, eax												; clear Prefetch-Buffer		  DB  0EAh							  ; The following lines		  DW  (OFFSET PMODE)					; create the opcode for:		  DW  8								 ; "JMP FAR CS:PMODE";------------------------------------------------ org START + ((($-START)/Ausri)*Ausri)+Ausri;------------------------------------------------PMODE:	mov	  ax, 10h					  ; Limit SS-Selektor to 64KB		  mov	  ss, ax		  mov	  ax, 18h		  mov	  ds, ax					   ; Enhance DS(,ES,FS,GS)-Segment;		  mov	  es, ax					  ;  to 4 GB;		  mov	  fs, ax;		  mov	  gs, ax		  mov	  eax, cr0					 ; Controlword 0 to EAX		  and	  eax, not 1				   ; Protected Mode off		  mov	  cr0, eax												; Clear Prefetch-Buffer		  DB  0EAh							  ; The following lines		  DW  (OFFSET RMODE)					; create the opcode for:AKTSEG	DW  (SEG RMODE)					   ; JMP FAR CS:RMODE;------------------------------------------------ org START + ((($-START)/Ausri)*Ausri)+Ausri;------------------------------------------------RMODE:	mov	  ss, dx					   ; restore SS		  popf								  ; get Flags;----------------------------------------------------------------------------;		   Swith  the  21. Adressbit on.;----------------------------------------------------------------------------BIT_FREI: call W_8042		   ;-->>----------+  Wait for 8042		  jnz BACK			  ;->--------+   ¦ 		  mov	  al, 0D1h	 ;		  ¦   ¦  Write command		  out	  Stat_Port, al;		  ¦   ¦		  call W_8042		   ;   -->>---Ï---¦  Ready to recieve ?		  jnz BACK			  ;->--------¦   ¦		  mov	  al, 0DFh	 ;		  ¦   ¦  Yes, set line 20 on		  out	  Tast_Port, al;		  ¦   ¦;-------------------------------------------¦---¦---------------;		   Wait til  the   8042 ¦   is	 ¦   ¦ ready.;-------------------------------------------¦---¦---------------W_8042:   xor	  cx, cx	   ;<<--------Ï---+STATUS:   in	   al, Stat_Port;<----+	¦	  Read Status		  and	  al, 2		;	 ¦	¦	   Buffer full ?		  loopnz STATUS		 ;->---+	¦	  til no or timeoutBACK:	 ret				   ;<---------+;----------------------------------------------------------------------------;			Spuare Root Circle (XM,YM,COL);---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;----------------------------------------------------------------------------KREIS:	mov	  eax, ecx		  mul	  eax				; Radius * Radius		  xor	  edi, edi		   ; Looping start		  mov	  esi, eax		  xor	  eax, eaxRUNDE:	mov	  ebp, esi		  mul	  eax				; X * X		  sub	  ebp, eax		   ; R * R - X * X		  mov	 DWORD PTR[Y], ebp		  fild	 [Y]				; Load Integer to ST(0)		  fsqrt					   ; Spuare root		  fistp	[Y]				; Integer save and pop		  mov	  ebp, DWORD PTR[Y]		  call HALB				   ; Set 4 Pixel		  mov	  eax, edi		   ; Switch X with Y		  mov	  edi, ebp		  mov	  ebp, eax		   ; Next Axes		  call HALB				   ; Set 4 Pixel		  lea	  ebp, [ebp+1]	   ; inc ebp / increase Loop-Counter		  mov	  edi, ebp		   ; Restore X		  cmp	  ecx, ebp		   ; Radiant reached ?		  jnz RUNDE		  ret;-------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;--------------------------------------HALB:	 mov	  edx, DWORD PTR[XM] ; Right below		  mov	  ebx, DWORD PTR[YM]		  add	  edx, edi		   ; X-Pos		  add	  ebx, ebp		   ; Y-Pos		  call PIXEL		  mov	  edx, DWORD PTR[XM] ; Left below		  mov	  ebx, DWORD PTR[YM]		  sub	  edx, edi		   ; X-Pos		  add	  ebx, ebp		   ; Y-Pos		  call PIXEL		  mov	  edx, DWORD PTR[XM] ; Right above		  mov	  ebx, DWORD PTR[YM]		  add	  edx, edi		   ; X-Pos		  sub	  ebx, ebp		   ; Y-Pos		  call PIXEL		  mov	  edx, DWORD PTR[XM] ; Left above		  mov	  ebx, DWORD PTR[YM]		  sub	  edx, edi		   ; X-Pos		  sub	  ebx, ebp		   ; Y-PosPIXEL:	shl	  edx, 2			 ; X *l 4 Byte (true color)		  add	  edx, [ebx*4]	   ; X plus line-Offset		  mov	  ebx, DWORD PTR[COL]		  mov	  [edx], ebx		 ; Color to the screen		  mov	  [edx+4], ebx	   ;  and the pixel beside too		  ret;----------------------------------------------------------------------------; Create a Sprite-TABLE (Offset, Color) of the content of the screen;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;----------------------------------------------------------------------------TABELLE:  mov	  eax, DWORD PTR[XMAX]		  xor	  esi, esi		  shr	  eax, 2			 ; X divide by 4 Byte (32Bit true color)		  mov	  di, OFFSET BALL	; Table-Offset		  mov	  esi, [esi]		 ; linear screen-Offset		  mul	 DWORD PTR[YMAX]		  mov	  ecx, eaxMAKETAB:  mov	  eax, [esi]		 ; Get the color of the pixel		  and	  eax, eax		   ;  empty/black ?		  jz  short LEER		  mov	  [di], esi		  ; Store Sprite-Offset in Table		  mov	  [di+4], eax		; Store Color in Table		  lea	  di, [di+8]		 ; Increase Table-Offset (add di,8)LEER:	 lea	  esi, [esi+4]	   ; Increase screen-Offset (add esi,4)		  dec	  ecx		  jnz MAKETAB		  mov	  bp, di			 ; End of table		  ret;----------------------------------------------------------------------------; Create an Offset table of startadresses of any horizontal line of the screen;---------------------------------------------------------------------------- org START + ((($-START)/Ausri)*Ausri)+Ausri;--------------------------------------PIXOFF:   mov	  si, OFFSET MINF	; Get the Offset of Mode info		  xor	  ebx, ebx		  mov	  bx, ds			 ; Get the actual adress of the data segment		  mov	  eax, [si+28h]	  ; Get the 32 Bit adress of the linear frambuffer		  shl	  ebx, 4			 ; Convert Data-Segment to a 32Bit-Offset		  xor	  di, di			 ; and substract it from the adress of the linear frambuffer		  sub	  eax, ebx		   ; = Adress of the first line is now "ds:Reg32"		  xor	  edx, edx		  mov	  dx, [si+32h]	   ; Get the lenght of a line (Xmax*BytejePixel)		  mov	  [XMAX], dx		  mov	  cx, [si+14h]	   ; Get Ymax		  mov	  [YMAX], cx		  shl	  cx, 2			  ; Max_Y * 4 Byte (32Bit true color)AGAIN:	mov	  [di], eax		  ; Store linear Offset of the framebuffer in the table		  lea	  di, [di+4]		 ; Increase Offset of table  (add di,4)		  add	  eax, edx		   ; Add Max_X to the address		  cmp	  di, cx			 ;  End of Table (Max_Y*4) ?		  jb  AGAIN		  ret  CODE ends
Edited by Dirk Wolfgang Glomp (see edit history)

Share this post


Link to post
Share on other sites

VESA Programming

This is the second part of the source-code(please merge it with the fist part) :

;----------------------------------------------------------------------------;						  D A T A - S e g m e n t;----------------------------------------------------------------------------  DATEN SEGMENT use32 'DATA' org 0;--------------------------------------PIXTAB DD MaxY+Ausri dup (0); Offset table of startadresses of any line of the screen(linear framebuffer);----------------------------------------------------------------------------;							Position - Table;----------------------------------------------------------------------------SX0	DD 122, 197					; X, Y	   DD 373, 347	   DD 493, 276	   DD 363, 143	   DD 323, 316	   DD 235, 192	   DD 273, 226	   DD 107, 226	   DD 422, 373	   DD 112, 347	   DD 133, 266	   DD 471, 343	   DD 423, 366	   DD 227, 230	   DD 143, 157	   DD 376, 322	   DD 212, 101	   DD 442, 226	   DD 293, 129	   DD 371, 123	   DD 323, 325	   DD 167, 292	   DD 223, 172	   DD 226, 145	   DD 113, 222	   DD 167, 166	   DD 133, 134	   DD 442, 292	   DD 252, 270	   DD 323, 350	   DD 262, 374	   DD 270, 151	   DD 166, 213	   DD 233, 154	   DD 123, 222	   DD 126, 274	   DD 060, 257	   DD 226, 313	   DD 418, 177	   DD 357, 153	   DD 458, 270	   DD 185, 035	   DD 248, 113	   DD 463, 366	   DD 370, 132	   DD 254, 267	   DD 239, 134	   DD 445, 262	   DD 454, 334	   DD 279, 257	   DD 146, 323	   DD 238, 267	   DD 143, 134	   DD 236, 377	   DD 139, 334	   DD 475, 258	   DD 454, 154	   DD 136, 337	   DD 484, 253	   DD 177, 266	   DD 224, 143	   DD 397, 127	   DD 448, 345	   DD 188, 123	   DD 442, 332	   DD 323, 176	   DD 472, 123	   DD 194, 379	   DD 046, 124	   DD 227, 111	   DD 144, 124	   DD 359, 165	   DD 177, 246	   DD 151, 342	   DD 178, 168	   DD 132, 149	   DD 427, 236	   DD 214, 013	   DD 361, 345	   DD 323, 176	   DD 249, 336	   DD 179, 144	   DD 439, 123	   DD 438, 347	   DD 288, 248	   DD 343, 158	   DD 228, 346	   DD 183, 253	   DD 347, 288	   DD 233, 235	   DD 198, 286	   DD 153, 147	   DD 297, 273	   DD 336, 231	   DD 479, 150	   DD 243, 287	   DD 257, 165	   DD 111, 122	   DD 389, 258	   DD 358, 285	   DD 224, 127	   DD 082, 122	   DD 266, 311	   DD 114, 351	   DD 321, 275	   DD 433, 159	   DD 240, 154	   DD 496, 160	   DD 148, 038	   DD 224, 369	   DD 312, 134	   DD 167, 126	   DD 278, 173	   DD 533, 436	   DD 356, 291	   DD 490, 352	   DD 369, 111	   DD 230, 134	   DD 477, 177	   DD 319, 443	   DD 553, 399	   DD 236, 266	   DD 474, 130	   DD 397, 127	   DD 238, 169	   DD 142, 186	   DD 171, 383	   DD 599, 138	   DD 368, 437	   DD 124, 424	   DD 597, 259	   DD 165, 197	   DD 143, 270	   DD 459, 349	   DD 159, 459	   DD 427, 427	   DD 215, 135	   DD 180, 180	   DD 377, 377	   DD 245, 145	   DD 473, 173	   DD 308, 408	   DD 483, 283	   DD 525, 125	   DD 412, 312	   DD 242, 142	   DD 293, 293	   DD 571, 371	   DD 423, 323	   DD 467, 267	   DD 183, 283	   DD 326, 126	   DD 313, 413	   DD 267, 267	   DD 533, 133	   DD 248, 188	   DD 358, 458	   DD 183, 383	   DD 162, 162	   DD 370, 170	   DD 434, 134	   DD 357, 157	   DD 123, 123	   DD 477, 167	   DD 534, 134	   DD 477, 177	   DD 264, 124	   DD 458, 138	   DD 154, 244	   DD 137, 237	   DD 193, 353	   DD 376, 276	   DD 543, 443	   DD 427, 227	   DD 145, 345	   DD 523, 123	   DD 338, 158	   DD 473, 425	   DD 196, 283	   DD 443, 394	   DD 558, 343	   DD 430, 134	   DD 414, 362	   DD 331, 185	   DD 561, 232	   DD 434, 321	   DD 376, 255	   DD 598, 388	   DD 114, 145	   DD 140, 243	   DD 537, 189	   DD 375, 434	   DD 225, 257	   DD 178, 283	   DD 157, 125	   DD 296, 158	   DD 372, 435	   DD 484, 192	   DD 543, 134	   DD 439, 212	   DD 338, 166	   DD 367, 288	   DD 133, 143	   DD 196, 313	   DD 429, 124	   DD 122, 448	   DD 585, 127	   DD 145, 173	   DD 534, 134	   DD 157, 157	   DD 323, 323	   DD 177, 167	   DD 134, 134	   DD 277, 177	   DD 164, 134	   DD 558, 358	   DD 254, 154	   DD 287, 137	   DD 493, 153	   DD 476, 376	   DD 243, 143	   DD 527, 127	   DD 445, 245	   DD 123, 223	   DD 138, 258	   DD 373, 225	   DD 396, 383	   DD 143, 194	   DD 258, 443	   DD 330, 134	   DD 414, 262	   DD 531, 185	   DD 361, 132	   DD 334, 121	   DD 476, 155	   DD 198, 288	   DD 114, 145	   DD 240, 343	   DD 137, 389	   DD 275, 134	   DD 525, 157	   DD 478, 183	   DD 557, 325	   DD 296, 258	   DD 572, 135	   DD 484, 192	   DD 343, 134	   DD 239, 212	   DD 138, 266	   DD 467, 388	   DD 233, 143	   DD 196, 313	   DD 529, 174	   DD 422, 148	   DD 385, 157	   DD 245, 173;---------------------------------------------------------------------------;							  Stepper - Table;---------------------------------------------------------------------------STEP0X DD 1, 1				 ; Number of Pixel for movement in horizontal	   DD 1, 2				 ;  and vertical direction (Step X,Y)	   DD 2, 1 	   DD 2, 4 	   DD 3, 1 	   DD 6, 6 	   DD 7, 5 	   DD 8, 4 	   DD 9, 3	   DD 2, 8	   DD 1, 6	   DD 5, 2	   DD 1, 3 	   DD 2, 4 	   DD 3, 5 	   DD 4, 6 	   DD 8, 1 	   DD 1, 2 	   DD 8, 3 	   DD 1, 9 	   DD 9, 1 	   DD 2, 2 	   DD 2, 3 	   DD 2, 7 	   DD 6, 1 	   DD 8, 8 	   DD 3, 3 	   DD 7, 7 	   DD 4, 1 	   DD 2, 7 	   DD 4, 3 	   DD 4, 2 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 2, 3 	   DD 2, 1 	   DD 2, 2 	   DD 2, 2 	   DD 2, 1 	   DD 3, 1 	   DD 6, 2 	   DD 3, 3 	   DD 3, 3 	   DD 4, 1 	   DD 2, 2 	   DD 4, 3 	   DD 4, 6 	   DD 1, 1 	   DD 1, 2 	   DD 1, 2 	   DD 1, 4 	   DD 2, 1 	   DD 2, 2 	   DD 3, 3 	   DD 2, 4 	   DD 3, 1 	   DD 3, 3 	   DD 3, 2 	   DD 3, 1 	   DD 4, 5 	   DD 2, 2 	   DD 4, 3 	   DD 1, 2 	   DD 3, 1 	   DD 1, 2 	   DD 1, 3 	   DD 2, 4 	   DD 2, 1 	   DD 2, 2 	   DD 2, 3 	   DD 2, 4 	   DD 3, 1 	   DD 3, 2 	   DD 3, 3 	   DD 3, 4 	   DD 4, 1 	   DD 3, 2 	   DD 4, 3 	   DD 2, 2 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 1, 2 	   DD 2, 1 	   DD 1, 2 	   DD 2, 3 	   DD 2, 2 	   DD 1, 1 	   DD 3, 2 	   DD 3, 3 	   DD 1, 1 	   DD 2, 1 	   DD 3, 2 	   DD 1, 3 	   DD 1, 2 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 1, 3 	   DD 3, 1 	   DD 2, 2 	   DD 2, 1 	   DD 2, 1 	   DD 5, 1 	   DD 3, 2 	   DD 3, 3 	   DD 3, 1 	   DD 3, 1 	   DD 3, 2 	   DD 2, 3 	   DD 4, 1 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 3, 4 	   DD 2, 1 	   DD 1, 5 	   DD 2, 3 	   DD 2, 4 	   DD 3, 1 	   DD 3, 2 	   DD 1, 3 	   DD 2, 3 	   DD 3, 1 	   DD 1, 2 	   DD 1, 3 	   DD 2, 1 	   DD 1, 1 	   DD 1, 1 	   DD 1, 3 	   DD 1, 2 	   DD 2, 1 	   DD 2, 2 	   DD 2, 3 	   DD 2, 3 	   DD 1, 1 	   DD 3, 2 	   DD 3, 3 	   DD 3, 3 	   DD 1, 1 	   DD 4, 1 	   DD 4, 3 	   DD 4, 2 	   DD 3, 1 	   DD 1, 2 	   DD 1, 3 	   DD 1, 3 	   DD 2, 1 	   DD 2, 2 	   DD 5, 3 	   DD 2, 1 	   DD 3, 1 	   DD 3, 2 	   DD 3, 3 	   DD 5, 3 	   DD 4, 1 	   DD 5, 2 	   DD 4, 1 	   DD 1, 2 	   DD 1, 1 	   DD 1, 5 	   DD 1, 3 	   DD 1, 3 	   DD 2, 1 	   DD 2, 2 	   DD 5, 1 	   DD 1, 4 	   DD 1, 1 	   DD 5, 2 	   DD 3, 5 	   DD 3, 4 	   DD 4, 1 	   DD 1, 2 	   DD 4, 3 	   DD 3, 5 	   DD 1, 1 	   DD 1, 1 	   DD 3, 3 	   DD 1, 4 	   DD 2, 3 	   DD 2, 1 	   DD 2, 3 	   DD 2, 4 	   DD 3, 1 	   DD 3, 2 	   DD 5, 3 	   DD 3, 1 	   DD 1, 3 	   DD 3, 5 	   DD 4, 3 	   DD 1, 2 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 1, 4 	   DD 2, 1 	   DD 5, 1 	   DD 2, 3 	   DD 3, 4 	   DD 3, 3 	   DD 1, 2 	   DD 3, 3 	   DD 3, 4 	   DD 4, 1 	   DD 3, 2 	   DD 1, 3 	   DD 2, 4 	   DD 1, 5 	   DD 1, 2 	   DD 5, 3 	   DD 1, 2 	   DD 2, 1 	   DD 2, 2 	   DD 2, 5 	   DD 2, 3 	   DD 3, 1 	   DD 3, 3 	   DD 3, 3 	   DD 3, 1 	   DD 2, 1 	   DD 3, 5 	   DD 2, 3 	   DD 4, 2 	   DD 1, 1 	   DD 3, 1 	   DD 1, 3 	   DD 1, 3 	   DD 2, 1 	   DD 5, 2 	   DD 2, 3 	   DD 2, 1 	   DD 3, 3 	   DD 3, 2 	   DD 3, 3 	   DD 3, 3 	   DD 5, 1 	   DD 1, 2 	   DD 2, 3 	   DD 4, 2 	   DD 1, 1 	   DD 1, 2 	   DD 1, 3 	   DD 1, 4 	   DD 2, 1 	   DD 5, 2 	   DD 2, 3 	   DD 2, 4 	   DD 3, 1 	   DD 3, 2 	   DD 3, 5 	   DD 2, 1 	   DD 3, 1 	   DD 2, 2 	   DD 1, 3 	   DD 2, 2 ;----------------------S_Len = ($-STEP0X);--------------------------------------; Table of direction-flags for movement;--------------------------------------W0	 DB (Anzahl+1)* 8 DUP(0)		; plus(0) / minus(1) für X,Y;--------------------------------------BALL   DB 0CC00h dup (22h)			; Sprite-Table: Offset32, Farbe32;--------------------------------------PICAKT DD MaxX*4*MaxY				 ; Actual adress of the framebufferPICLEN DD MaxX*4*MaxY				 ; Screen lenghtPICMAX DD MaxX*4*MaxY*2			   ; Max adress;--------------------------------------RETTSI DW 0, 0						; I don´t like to push the SI-register on the stack;--------------------------------------HINFAR DD HFarb, HFarb				; Background Color;--------------------------------------;			C i r c l e;--------------------------------------Y	  DD 0						   ; Double-Word for FPU: sqrXM	 DD 0						   ; X PositionYM	 DD 0						   ; Y PositionCOL	DD 0						   ; ColorXMAX   DW 0, 0YMAX   DW 0, 0;--------------------------------------EDID   DB 80h dup (55h)			   ; Buffer for DDC-Monitor-Info;--------------------------------------VINF   DB 512 dup (0AAh)			  ; Buffer for Vesa-Info(4F00h)MINF   DB 256 dup (044h)			  ; Buffer for Mode Info(4F01h);--------------------------------------CRTC	DW 1456					   ; Horizontal Total	   in PixelHORIANF DW 1122					   ; Horizontal  Sync-Start in PixelHORIEND DW 216						; Horizontal  Sync-End   in PixelVERTOTA DW 814						; Vertical   Total	   in LinesVERTANF DW 768						; Vertical	Sync-Start in LinesVERTEND DW 42						 ; Vertical	Sync-End   in LinesDOIFLAG DB 04h						; Flag (interlaced,doubleScan,polarity)PIXCLOC DD 118309000				  ; Pixel clock in hzREFRATE DW 10000					  ; Refresh-Rate in 0.01 hz;---------------------		DB 40 dup (0);--------------------------------------FLAG	DB 0						  ; Used for triple buffering adress switching;--------------------------------------ERTEX1 DB Cr, Lf, "No Video-Mode", Cr, Lf, "{:content:}quot;ERTEX2 DB Cr, Lf, "No lineare offset", Cr, Lf, "{:content:}quot;ERTEX3 DB Cr, Lf, "No MMX-CPU", Cr, Lf, "{:content:}quot;ERTEX4 DB Cr, Lf, "No Vesa-Bios", Cr, Lf, "{:content:}quot;ERTEX5 DB Cr, Lf, "No VESA 3 -Bios", Cr, Lf, "{:content:}quot;ERTEX6 DB Cr, Lf, "No DDC", Cr, Lf, "{:content:}quot;ERTEX7 DB Cr, Lf, "Less than 96 khz", Cr, Lf, "{:content:}quot;ERTEX8 DB Cr, Lf, "Less than 160 hz", Cr, Lf, "{:content:}quot;ERTEX9 DB Cr, Lf, "No pixelcloc", Cr, Lf, "{:content:}quot;;--------------------------------------  DATEN ends;---------------------------------------------------------------------------- STAPEL SEGMENT use16 STACK 'STACK'	   DB 10h dup (0) STAPEL ends;---------------------------------------------------------------------------- end
Dirk Edited by Dirk Wolfgang Glomp (see edit history)

Share this post


Link to post
Share on other sites

Difficulty?

VESA Programming

 

Replying to zomo Is it possible to put this completely in assembly code without any PASCAL defines. (or at least a simple executable - ie a working example). Most people experience the same problem when using VESA modes. By changing the resolution The image squashes into the top area of the screen. What most people want to know is how to move a pixel about by changing the x y values only, and having the pixel respond accordingly on the screen, in the different resolution modes, with simplicity and control. -question by DENE

Vesa function 0 fill our buffer with the vesa-info. Inside of this vesa-buffer we found a pointer to the vesa-modetable. The modetable contains all aviable vesa-modenumbers(of the used vesa-bios).

In the end of the modetable we found 0FFFFh.

INT 10 - VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION	 AX = 4F00h	 ES:DI -> buffer for SuperVGA information (see #00077) Return: AL = 4Fh if function supported	 AH = status		 00h successful		 ES:DI buffer filled		 01h failed		 ---VBE v2.0---		 02h function not supported by current hardware configuration		 03h function invalid in current video mode Desc:	determine whether VESA BIOS extensions are present and the capabilities	   supported by the display adapter SeeAlso: AX=4E00h,AX=4F01h,AX=7F00h"SOLLEX",AX=A00Ch Index:	installation check;VESA SuperVGA  Format of SuperVGA information: Offset	Size	Description	(Table 00077)  00h  4 BYTEs	(ret) signature ("VESA")		 (call) VESA 2.0 request signature ("VBE2"), required to receive		   version 2.0 info  04h	WORD	VESA version number (one-digit minor version -- 0102h = v1.2)  06h	DWORD	pointer to OEM name		 "761295520" for ATI  0Ah	DWORD	capabilities flags (see #00078)  0Eh	DWORD	pointer to list of supported VESA and OEM video modes		 (list of words terminated with FFFFh)  12h	WORD	total amount of video memory in 64K blocks ---VBE v1.x ---  14h 236 BYTEs	reserved ---VBE v2.0 ---  14h	WORD	OEM software version (BCD, high byte = major, low byte = minor)  16h	DWORD	pointer to vendor name  1Ah	DWORD	pointer to product name  1Eh	DWORD	pointer to product revision string  22h	WORD	(if capabilities bit 3 set) VBE/AF version (BCD)		 0100h for v1.0P  24h	DWORD	(if capabilities bit 3 set) pointer to list of supported		   accelerated video modes (list of words terminated with FFFFh)  28h 216 BYTEs	reserved for VBE implementation 100h 256 BYTEs	OEM scratchpad (for OEM strings, etc.) Notes:	the list of supported video modes is stored in the reserved portion of	   the SuperVGA information record by some implementations, and it may	   thus be necessary to either copy the mode list or use a different	   buffer for all subsequent VESA calls	 the 1.1 VESA document specifies 242 reserved bytes at the end, so the	   buffer should be 262 bytes to ensure that it is not overrun; for	   v2.0, the buffer should be 512 bytes	 the S3 specific video modes will most likely follow the FFFFh	   terminator at the end of the standard modes.	A search must then	   be made to find them, FFFFh will also terminate this second list	 in some cases, only a "stub" VBE may be present, supporting only	   AX=4F00h; this case may be assumed if the list of supported video	   modes is empty (consisting of a single word of FFFFh)  Bitfields for VESA capabilities: Bit(s)	Description	(Table 00078)  0	DAC can be switched into 8-bit mode  1	non-VGA controller  2	programmed DAC with blank bit (i.e. only during blanking interval)  3	controller supports VBE/AF v1.0P extensions  4	(VBE/AF) must call EnableDirectAccess to access framebuffer  5	(VBE/AF) controller supports hardware mouse cursor  6	(VBE/AF) controller supports hardware clipping  7	(VBE/AF) controller supports transparent BitBLT  8-31	reserved (0) SeeAlso: #00077,AX=4F09h
With the vesamodenumber and with the vesa function 1 we can get the modeinfo of the mode in a second buffer.

In this modeinfo-buffer we can find the resolution of the mode. Buffer+12h = X (horizontal) and Buffer+14h = Y (vertical).

Format of VESA SuperVGA mode information:   -----------------------------------------   Offset	Size	Description	(Table 0065)   --------------------------------------------	00h	WORD	mode attributes (see #0066)	02h	BYTE	window attributes, window A (see #0067)	03h	BYTE	window attributes, window B (see #0067)	04h	WORD	window granularity in KB	06h	WORD	window size in KB	08h	WORD	start segment of window A	0Ah	WORD	start segment of window B	0Ch	DWORD	-> FAR window positioning function (equivalent to AX=4F05h)	10h	WORD	bytes per scan line   ---remainder is optional for VESA modes in v1.0/1.1, needed for OEM modes---	12h	WORD	width in pixels (graphics) or characters (text)	14h	WORD	height in pixels (graphics) or characters (text)	16h	BYTE	width of character cell in pixels	17h	BYTE	height of character cell in pixels	18h	BYTE	number of memory planes	19h	BYTE	number of bits per pixel	1Ah	BYTE	number of banks	1Bh	BYTE	memory model type (see #0068)	1Ch	BYTE	size of bank in KB	1Dh	BYTE	number of image pages	1Eh	BYTE	reserved (0)   ---VBE v1.2+---	1Fh	BYTE	red mask size	20h	BYTE	red field position	21h	BYTE	green mask size	22h	BYTE	green field size	23h	BYTE	blue mask size	24h	BYTE	blue field size	25h	BYTE	reserved mask size	26h	BYTE	reserved mask position	27h	BYTE	direct color mode info		   bit 0: color ramp is programmable		   bit 1: bytes in reserved field may be used by application   ---VBE v2.0 ---	28h	DWORD	physical address of linear video buffer	2Ch	DWORD	pointer to start of offscreen memory	30h	WORD	KB of offscreen memory   ---VBE v3.0 ---	32h	WORD	bytes per scan line	34h	BYTE	35h	BYTE	36h	BYTE	37h	BYTE	38h	BYTE	39h	BYTE	3Ah	BYTE	3Bh	BYTE	3Ch	BYTE	3Dh	BYTE	3Eh	DWORD   max. Pixel clock   -----------------------------------	42h	BYTE	189 dup(0) reserved   ------------------------------------------------------------------------------   Bitfields for VESA SuperVGA mode attributes:   Bit(s)	Description	(Table 0066)	0	mode supported	1	optional information available	2	BIOS output supported	3	set if color, clear if monochrome	4	set if graphics mode, clear if text mode   ---VBE v2.0 ---	5	mode is not VGA-compatible	6	bank-switched mode not supported	7	linear framebuffer mode supported   ------------------------------------------------------------------------------   Bitfields for VESA SuperVGA window attributes:   Bit(s)	Description	(Table 0067)	0	exists	1	readable	2	writable	3-7	reserved   ------------------------------------------------------------------------------   (Table 0068)   Values for VESA SuperVGA memory model type:	00h	text	01h	CGA graphics	02h	HGC graphics	03h	16-color (EGA) graphics	04h	packed pixel graphics	05h	"sequ 256" (non-chain 4) graphics	06h	direct color (HiColor, 24-bit color)	07h	YUV (luminance-chrominance, also called YIQ)	08h-0Fh reserved for VESA	10h-FFh OEM memory models
Dirk

Share this post


Link to post
Share on other sites

No need to use their standards, just use interrupt 10h to do that, I show you how to program VESA 1.2 because VESA 2.0 is protected mode programing.

Only a few vesa function is for the protected mode(PM) only. So it is not possible to set a vesamode using the PM.But it is possible to use most VESA 3 function in the realmode(RM). VESA 3 provide vesamodi with own refreshrate that can be used also in banked mode.
Linear Vesamodi can also be used with EMS-memory-manager within the RM or the Unrealmode/Bigrealmode/Flatrealmode(without a memory-manager).

Dirk
Edited by Dirk Wolfgang Glomp (see edit history)

Share this post


Link to post
Share on other sites

THE LINE IN THE DATA CODE IS TOO LONGPIXTAB DD MaxY+Ausri dup (0); Offset table of startadresses of any line of the screen(linear framebuffer)LINE TO LONGDOES NOT COMPILE...SO SHORTEN THIS LINEPIXTAB DD MaxY+Ausri dup (0); Offset...THEN IT COMPILESOBJECT CODE is only 1kb though....looks like something went wrong?EOF file encounteredSO IT DOES NOT LINKwith link /cpERROR illegal parametersCAN YOU SUPPLY THE EXECUTABLE FILE?ALSO CODE IS use16 BIT and DATA use32 BIT ???I WILL TRY TO DEBUG THE WORKING EXAMPLE!THANK YOU

Share this post


Link to post
Share on other sites

THE LINE IN THE DATA CODE IS TOO LONG
PIXTAB DD MaxY+Ausri dup (0); Offset table of startadresses of any line of the screen(linear framebuffer)

LINE TO LONG

DOES NOT COMPILE...

SO SHORTEN THIS LINE

PIXTAB DD MaxY+Ausri dup (0); Offset...

THEN IT COMPILES


The text after a semicolon is a comment only for us and will be ignored from the assembler.

OBJECT CODE is only 1kb though....looks like something went wrong?
EOF file encountered

SO IT DOES NOT LINK

with link /cp

ERROR illegal parameters


This is a command line parameter of the 16 bit link.exe from masm 5.1.
(We can remove all parameter.)

16 bit linker:
Microsoft ® Segmented Executable Linker Version 5.60.339 Dec 5 1994
http://forums.xisto.com/no_longer_exists/

CAN YOU SUPPLY THE EXECUTABLE FILE?
ALSO CODE IS use16 BIT and DATA use32 BIT ???


I think this fit the start address of the data segment on an boundary of 4 byte instead of only 2 byte
for a data ailgment with an 32 bit access reading and writing within the data segment.

I WILL TRY TO DEBUG THE WORKING EXAMPLE!
THANK YOU


From my homepage:
Mode info: http://forums.xisto.com/no_longer_exists/ (2576 bytes)
Demo: http://forums.xisto.com/no_longer_exists/ (12739 bytes)

Dirk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.