home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Equalizer BBS
/
equalizer-bbs-collection_2004.zip
/
equalizer-bbs-collection
/
DEMOSCENE-STUFF
/
RVLVBE10.ZIP
/
VESA.INC
< prev
Wrap
Text File
|
1997-05-17
|
37KB
|
997 lines
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒ ▒▒ ▒ ▒▒▒ ▒ ▒ ▒▒ ▒▒▒▒ ▒ ▒ ▒▒▒ ▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒ ▒ ▒▒▒ ▒▒▒ ▒ ▒ ▒ ▒ ▒▒▒▒▒ ▒▒▒ ▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒ ▒ ▒▒▒ ▒▒▒ ▒ ▒ ▒ ▒ ▒▒▒▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒ ▒ ▒ ▒ ▒ ▒ ▒▒ ▒▒▒▒ ▒▒▒ ▒ ▒ ▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;-----------------------------------------------------------------------------
; (c)opyright 1997, babyloon/revelation
; use it where you want, for what you want, it is at you own risk !
;-----------------------------------------------------------------------------
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
.Code
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ CheckVESA: Check if VBE is present and set primary VBE_????? variables..
;░ In:
;░ Nothing
;░ Out:
;░ DL - Error code
;░ =0 VESA Found.
;░ =1 DOS Memory allocation failed.
;░ =2 DOS interrupt failed.
;░ =3 VESA Not supported.
;░ =4 DOS Memory DeAllocation failed.
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
CheckVESA Proc
; *** Alloc DOS memory block for GET VESA INFO(4F00), GET MODE INFO(4F01)..
mov ax,100h ; Allocate DOS memory block
mov bx,32 ; 32*16=512 bytes
int 31h ;
jnc @@DOSAllocOk
Mov Dl,1 ; DOS Alloc error
ret
@@DOSAllocOK:
mov [VBE_RealSegment],ax ; Save segment and selector registers.
mov [VBE_MemSelector],dx ;
; *** VBE Controller Informations - DOS interrupt ***
mov eax,04F00h
mov [Real_Mode_Block.R_EAX],eax
mov ax,[VBE_RealSegment]
mov [Real_Mode_Block.R_ES],ax ;\ Infos block at ES:DI
xor eax,eax ; | ES - Reserved Segment
mov [Real_Mode_Block.R_EDI],eax ;/ DI - Offset 0..
; clear unused parameters..
mov [Real_Mode_Block.R_ESI],eax
mov [Real_Mode_Block.R_EBP],eax
mov [Real_Mode_Block.R_EBP+4],eax
mov [Real_Mode_Block.R_EDX],eax
mov [Real_Mode_Block.R_EBX],eax
mov word ptr [Real_Mode_Block.R_EAX+4],ax
mov [Real_Mode_Block.R_DS],ax
mov [Real_Mode_Block.R_FS],ax
mov [Real_Mode_Block.R_GS],ax
mov [Real_Mode_Block.R_CS],ax
mov [Real_Mode_Block.R_IP],ax
mov [Real_Mode_Block.R_SS],ax
mov [Real_Mode_Block.R_SP],ax
mov ax,0300h ;\
mov bl,10h ; |
xor bh,bh ; |
xor cx,cx ; | DOS interrupt simulation.
push ds ; |
pop es ; |
mov edi,offset Real_Mode_Block ; |
int 31h ;/
jnc @@VBE_PMInterrupt_ok1
Mov Dl,2 ; DOS int failure
jmp @@EndCheck
@@VBE_PMInterrupt_ok1:
mov eax,[Real_Mode_Block.R_EAX] ; Test if VESA driver found.
cmp ax,004Fh
je @@VBE_VESADriver_found
Mov Dl,3 ; VESA not supported
jmp @@EndCheck
@@VBE_VESADriver_found:
;//---Set all primary VBE_?????? variables...
mov fs,[VBE_MemSelector]
xor edi,edi
mov eax,Dword ptr fs:[edi.VBESignature]
mov [VBE_Signature+0],al
mov [VBE_Signature+1],ah
shr eax,16
mov [VBE_Signature+2],al
mov [VBE_Signature+3],ah
mov ax,Word Ptr fs:[edi.VBEVersion]
mov [VBE_VBEVersion],ax
mov ax,Word Ptr fs:[edi.TotalMemory]
shl ax,6 ; 64Ko blocks
mov [VBE_TotalMemory],ax
mov ax,Word Ptr fs:[edi.OEMSoftwareRev]
mov [VBE_SoftwareRev],ax
mov eax,DWord Ptr fs:[edi.OEMStringPtr] ; eax=Segment*65536+Offset
mov edx,eax
movzx ebx,ax
xor dx,dx
shr edx,12
add edx,ebx
mov [VBE_OEMStringPtr],edx ; LinearAddress=Segment*4+Offset
mov eax,DWord Ptr fs:[edi.OEMVendorNamePtr]
mov edx,eax
movzx ebx,ax
xor dx,dx
shr edx,12
add edx,ebx
mov [VBE_OEMVendorNamePtr],edx
mov eax,DWord Ptr fs:[edi.OEMProductNamePtr]
mov edx,eax
movzx ebx,ax
xor dx,dx
shr edx,12
add edx,ebx
mov [VBE_OEMProductNamePtr],edx
mov eax,DWord Ptr fs:[edi.OEMProductRevPtr]
mov edx,eax
movzx ebx,ax
xor dx,dx
shr edx,12
add edx,ebx
mov [VBE_OEMProductRevPtr],edx
; *** Initialise VBE Mode List ***
mov [VBE_NumberOfMode],0
mov esi,Offset VBE_ModeList
mov ebp,100h ; first VESA mode
@@SetModeListLoop:
mov eax,04F01h
mov [Real_Mode_Block.R_EAX],eax ; Infos Mode VESA function
mov [Real_Mode_Block.R_ECX],ebp ; which VESA mode ? EBP=Mode
mov ax,[VBE_RealSegment]
mov [Real_Mode_Block.R_ES],ax ;\ Infos block at ES:DI
xor eax,eax ; | ES - Reserved Segment
mov [Real_Mode_Block.R_EDI],eax ;/ DI - Offset 0..
; clear unused parameters..
mov [Real_Mode_Block.R_ESI],eax
mov [Real_Mode_Block.R_EBP],eax
mov [Real_Mode_Block.R_EDX],eax
mov [Real_Mode_Block.R_EBX],eax
mov [Real_Mode_Block.R_EBP+4],eax
mov word ptr [Real_Mode_Block.R_EAX+4],ax
mov [Real_Mode_Block.R_DS],ax
mov [Real_Mode_Block.R_FS],ax
mov [Real_Mode_Block.R_GS],ax
mov [Real_Mode_Block.R_CS],ax
mov [Real_Mode_Block.R_IP],ax
mov [Real_Mode_Block.R_SS],ax
mov [Real_Mode_Block.R_SP],ax
push ebp esi
mov ax,300h ;\
mov bl,10h ; |
xor bh,bh ; |
xor cx,cx ; | DOS interrupt simulation.
push ds ; |
pop es ; |
mov edi,offset Real_Mode_Block ; |
int 31h ;/
jnc @@VBE_PMInterrupt_ok2
pop esi ebp
Mov dl,2 ; DOS int failure
jmp @@EndCheck
@@VBE_PMInterrupt_ok2:
pop esi ebp
mov eax,[Real_Mode_Block.R_EAX] ; Test if mode available.
cmp ax,004Fh
jne @@BadVideoMode
inc [VBE_NumberOfMode]
mov fs,[VBE_MemSelector]
mov ax,fs:[XResolution]
mov [esi],ax
mov ax,fs:[YResolution]
mov [esi+2],ax
xor eax,eax
mov al,fs:[BitsPerPixel]
mov [esi+4],ax
mov [esi+6],bp
add esi,8
@@BadVideoMode:
inc ebp
cmp ebp,0201h
jne @@SetModeListLoop
; *** Free allocated DOS memory block ***
mov ax,0101h
mov dx,[VBE_MemSelector]
int 31h
jnc @@VBE_FreeMem_Ok
mov dl,4
ret
@@VBE_FreeMem_Ok:
xor dl,dl
ret
@@EndCheck:
push edx
mov ax,0101h
mov dx,[VBE_MemSelector]
int 31h
pop edx
ret
CheckVESA EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ InitVESAMode: Verify if requested mode is available and initializes it..
;░ In:
;░ AX - Video mode WIDTH
;░ BX - Video mode HEIGHT
;░ CX - Bits per pixel
;░ Out:
;░ DL - Error code
;░ =0 Initialisation ok.
;░ =1 DOS Memory allocation failed.
;░ =2 DOS interrupt failed.
;░ =4 DOS Memory DeAllocation failed.
;░ =5 Requested video mode not found.
;░ =6 Wrong VESA mode.
;░ =7 Can't map memory.
;░ =8 Bank Switching not really available (!).
;░ =9 Bad Window A attributes.
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
InitVESAMode Proc
mov esi,Offset VBE_ModeList
mov ebp,[VBE_NumberOfMode]
or ebp,ebp
jnz @@FindModeLoop
mov dl,5
ret
@@FindModeLoop:
cmp ax,[esi]
jne @@SkipThisMode
cmp bx,[esi+2]
jne @@SkipThisMode
cmp cx,[esi+4]
jne @@SkipThisMode
mov dx,[esi+6]
mov [VBE_Gfx_Mode],dx ; Set Graphic Mode
jmp @@VideoModeFound
@@SkipThisMode:
add esi,8
dec ebp
jnz @@FindModeLoop
mov dl,5
ret
@@VideoModeFound:
push ax
xor eax,eax
pop ax
push bx
xor ebx,ebx
pop bx
push cx
xor ecx,ecx
pop cx
imul eax,ebx
shr ecx,3
imul eax,ecx
mov [VBE_Mapping_Size],eax ; Set Mapping Size (if LFB available)
; *** Alloc DOS memory block for Mode Info Buffer ***
mov ax,100h ; Allocate DOS memory block
mov bx,32 ; 32*16=512 bytes
int 31h ;
jnc @@VBE_DOSAlloc_ok
Mov Dl,1 ; can't alloc DOS memory
ret
@@VBE_DOSAlloc_Ok:
mov [VBE_RealSegment],ax ; Save segment and selector registers.
mov [VBE_MemSelector],dx ;
; *** VBE Mode Informations - DOS interrupt *** INITIALIZE VIDEO MODE !!!!
mov eax,04F01h
mov [Real_Mode_Block.R_EAX],eax ; Infos Mode VESA function
mov cx,[VBE_Gfx_Mode]
mov [Real_Mode_Block.R_ECX],ecx ; which VESA mode ?
mov ax,[VBE_RealSegment]
mov [Real_Mode_Block.R_ES],ax ;\ Infos block at ES:DI
xor eax,eax ; | ES - Reserved Segment
mov [Real_Mode_Block.R_EDI],eax ;/ DI - Offset 0..
; clear unused parameters..
mov [Real_Mode_Block.R_ESI],eax
mov [Real_Mode_Block.R_EBP],eax
mov [Real_Mode_Block.R_EDX],eax
mov [Real_Mode_Block.R_EBX],eax
mov [Real_Mode_Block.R_EBP+4],eax
mov word ptr [Real_Mode_Block.R_EAX+4],ax
mov [Real_Mode_Block.R_DS],ax
mov [Real_Mode_Block.R_FS],ax
mov [Real_Mode_Block.R_GS],ax
mov [Real_Mode_Block.R_CS],ax
mov [Real_Mode_Block.R_IP],ax
mov [Real_Mode_Block.R_SS],ax
mov [Real_Mode_Block.R_SP],ax
mov ax,300h ;\
mov bl,10h ; |
xor bh,bh ; |
xor cx,cx ; | DOS interrupt simulation.
push ds ; |
pop es ; |
mov edi,offset Real_Mode_Block ; |
int 31h ;/
jnc @@VBE_PMInterrupt_ok
Mov dl,2 ; DOS int failure
jmp @@EndInit
@@VBE_PMInterrupt_ok:
mov eax,[Real_Mode_Block.R_EAX] ; Test if mode available.
cmp ax,004Fh
je @@VBE_VideoMode_Ok
Mov Dl,6 ; Wrong VESA mode
jmp @@EndInit
@@VBE_VideoMode_Ok:
mov fs,[VBE_MemSelector]
movzx eax,word ptr fs:[BytesPerScanLine]
mov [VBE_BytesPerScanLine],eax
mov [VBE_PMODESetStartFactor],0
cmp byte ptr fs:[BitsPerPixel],4
je @@NoFactorNeeded
mov [VBE_PMODESetStartFactor],2
@@NoFactorNeeded:
mov ax,fs:[ModeAttributes] ; Test if LFB available
test ax,010000000b
jz @@VBE_BankSwitchMethod
; *************************************************************
; *** LINEAR FRAME BUFFERING AVAILABLE ***
; *************************************************************
mov [VBE_LFBAvailable],1
mov eax,fs:[PhysBasePtr]
; mov [VBE_VRAM_Address],eax ; Physical address of LFB
; LFB Physical address converted into linear address..
mov ecx,eax
mov ebx,eax
shr ebx,16 ; BX:CX = Physical address of LFB
mov eax,[VBE_Mapping_Size]
mov edi,eax
mov esi,eax
shr esi,16 ; SI:DI=size of zone to map in bytes
mov ax,0800h ; DPMI Physical address mapping..
int 31h
jnc @@VBE_MemMapping_ok
Mov Dl,7 ; Can't map memory..
jmp @@EndInit
@@VBE_MemMapping_ok:
shl ebx,16
mov bx,cx
mov [VBE_VRAM_Address],ebx
Add [VBE_Gfx_Mode],4000h ; Prepare for Linear Addressing.
jmp @@Check32BitInterface ; Now set all Accelerated Functions.
; *************************************************************
; *** BANK SWITCHING METHOD ***
; *************************************************************
@@VBE_BankSwitchMethod:
Mov [VBE_LFBAvailable],0
mov fs,[VBE_MemSelector]
mov ax,fs:[ModeAttributes] ; Test if bank switching
test ax,01000000b ; is really available.
jz @@VBE_windowing_supported
Mov Dl,8 ; BankSwitch not really available..
jmp @@EndInit
@@VBE_windowing_supported:
mov al,fs:[WinAAttributes] ; Test if Windows Attributes
and al,0101b ; are OK.
cmp al,0101b
je @@VBE_WinAttributes_ok
Mov Dl,9 ; Bad Window A attributes
jmp @@EndInit
@@VBE_WinAttributes_ok:
movzx eax,word ptr fs:[WinSize] ;\
shl eax,10 ; | Get window size.
mov [VBE_WindowSize],eax ;/
mov eax,[VBE_Mapping_Size]
xor edx,edx
mov ebx,[VBE_WindowSize]
idiv ebx
or edx,edx
je @@VBE_EndCalcBanks
inc eax
@@VBE_EndCalcBanks:
mov [VBE_NumberOfBanks],AL
; Setup bank numering table..
Movzx eax,word ptr fs:[WinSize]
Movzx ebx,word ptr fs:[WinGranularity]
xor edx,edx
div ebx
xor edx,edx
xor ecx,ecx
@@LoopSetUpBank:
mov VBE_BANKSetTable[ECX*4],edx
add edx,eax
inc ecx
cmp ecx,LENGTH VBE_BANKSetTable
jb @@LoopSetUpBank
; Window A physical Address converted into 32bits pointer. 0A000h -> 0A0000h
xor eax,eax
mov ax,fs:[WinASegment]
shl eax,4
mov [VBE_VRAM_Address],eax
mov eax,Offset RealModeSetBank ; Pointer to the standard
mov [VBE_SetVBEBankPtr],eax ; bankswitch function. (real mode).
mov [VBE_CurrentBank],1 ;\
xor dl,dl ; |-- Initialize to first bank..->0
call SetVBEBank ;/
;******************************************************
;*** Now Check for a 32bit bank switch interface !! ***
;******************************************************
@@Check32BitInterface:
mov [VBE_PMODEInterface],0 ; firstly suppose there is none.
mov [VBE_PMODEBankSwitch],0
; *** Return VBE Protected Mode Interface - DOS interrupt *** check it !!
mov eax,04F0Ah
mov [Real_Mode_Block.R_EAX],eax
xor eax,eax
mov [Real_Mode_Block.R_EBX],eax
; clear unused parameters..
mov [Real_Mode_Block.R_ECX],eax
mov [Real_Mode_Block.R_EDI],eax
mov [Real_Mode_Block.R_ESI],eax
mov [Real_Mode_Block.R_EBP],eax
mov [Real_Mode_Block.R_EDX],eax
mov [Real_Mode_Block.R_EBP+4],eax
mov word ptr [Real_Mode_Block.R_EAX+4],ax
mov [Real_Mode_Block.R_ES],ax
mov [Real_Mode_Block.R_DS],ax
mov [Real_Mode_Block.R_FS],ax
mov [Real_Mode_Block.R_GS],ax
mov [Real_Mode_Block.R_CS],ax
mov [Real_Mode_Block.R_IP],ax
mov [Real_Mode_Block.R_SS],ax
mov [Real_Mode_Block.R_SP],ax
mov ax,300h ;\
mov bl,10h ; |
xor bh,bh ; |
xor cx,cx ; | DOS interrupt simulation.
push ds ; |
pop es ; |
mov edi,offset Real_Mode_Block ; |
int 31h ;/
jnc @@VBE_PMInterrupt_ok2
Mov dl,2 ; DOS int failure
jmp @@EndInit
@@VBE_PMInterrupt_ok2:
mov eax,[Real_Mode_Block.R_EAX]
cmp ax,004Fh
jne @@No32BitInterface
movzx esi,[Real_Mode_Block.R_ES] ; RM pointer->Linear Pointer
shl esi,4
mov edi,[Real_Mode_Block.R_EDI]
and edi,0FFFFh
add esi,edi ; ESI=Segment*16+Offset
; Check if there's a zero length memory list, it should be that for most video
; card. If memory list have a non-zero length, you are not lucky, because its
; too boring to code that case .. (it runs on 99% of video cards..)
movzx edi,Word Ptr [ESI+06] ; get port/memory table list
or edi,edi
jz @@UsePmodeInterface ; No port list.. coool..
mov ax,Word Ptr [esi+edi]
cmp ax,0FFFFh
je @@CheckMemoryList
@@CheckPortList:
add edi,2
mov ax,Word Ptr [Esi+Edi] ; CMP WORD PTR [ESI+EDI],0FFFFh
cmp ax,0FFFFh ; search port list ; causes problems under my W95!
jne @@CheckPortList
@@CheckMemoryList:
add edi,2
mov ax,Word Ptr [Esi+Edi]
cmp ax,0FFFFh ; see if mem list is zero
jne @@NoPMODEBankSwitch
@@UsePmodeInterface:
movzx eax,Word Ptr [ESI+00]
add eax,esi
mov [VBE_SetVBEBankPtr],eax ; save SetBank code address
mov [VBE_PMODEBankSwitch],1
@@NoPMODEBankSwitch:
movzx eax,Word Ptr [ESI+02]
add eax,esi
mov [VBE_PMODESetStartPtr],eax ; save SetStart code address
;
; Here I should set all others available
; 32bit functions..
;
mov [VBE_PMODEInterface],1
@@No32BitInterface:
mov ax,0101h
mov dx,[VBE_MemSelector]
int 31h
jnc @@VBE_FreeMem_Ok
mov dl,4
ret
@@VBE_FreeMem_Ok:
xor dl,dl ; All is ok !!
RET
@@EndInit:
push edx
mov ax,0101h
mov dx,[VBE_MemSelector]
int 31h
pop edx
ret
InitVESAMode EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ SetVBEMode: Set VESA mode
;░ In:
;░ Nothing
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
SetVBEMode Proc
pushad
mov ax,4F02h
mov bx,[VBE_Gfx_Mode]
Int 10h
popad
Ret
SetVBEMode EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ CloseVBEMode: Close VESA mode and unmap VIDEO memory
;░ In:
;░ Nothing
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
CloseVBEMode Proc
cmp [VBE_LFBAvailable],1
jne @@NoNeed
mov ax,0801h
mov ebx,[VBE_VRAM_Address]
mov cx,bx
shr ebx,16
int 31h
@@NoNeed:
Ret
CloseVBEMode Endp
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ SetVBEBank: Setup writable bank
;░ In:
;░ DL - Bank number
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
SetVBEBank Proc
cmp [VBE_CurrentBank],dl
je @@BankAlreadySet
and edx,01fh
mov VBE_CurrentBank,dl
mov edx,VBE_BANKSetTable[edx*4]
push ebx
call [VBE_SetVBEBankPtr]
pop ebx
@@BankAlreadySet:
RET
SetVBEBank EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ RealModeSetBank: Set the position of Window A in the frame buffer memory
;░ In:
;░ DX - Window number in video memory in window granularity units
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
RealModeSetBank Proc
xor ebx,ebx
mov ax,4F05h ; Use Real Mode interrupt
int 10h
ret
RealModeSetBank EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ SetVBEStart: Setup start address
;░ In:
;░ ECX - Pixel in scanline
;░ EDX - scanline number
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
SetVBEStart Proc
cmp [VBE_PMODEInterface],1
je @@PMODESetStart
mov eax,4F07h
xor ebx,ebx
int 10h
RET
@@PMODESetStart:
imul edx,[VBE_BytesPerScanLine]
add edx,ecx
mov cl,[VBE_PMODESetStartFactor]
shr edx,cl
mov cx,dx
shr edx,16
xor ebx,ebx
call [VBE_PMODESetStartPtr]
ret
SetVBEStart EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ ShowVBEInfos: Write all necessary infos. Must be called after InitVESAMode.
;░ In:
;░ Nothing
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
ShowVBEInfos Proc
mov ah,9
mov edx,Offset VSTR_TitleString
int 21h
mov ah,9
mov edx,Offset VSTR_Signature
int 21h
mov ah,9
mov edx,Offset VBE_Signature
int 21h
mov ah,9
mov edx,Offset VSTR_VBEVersion
int 21h
mov ax,[VBE_VBEVersion]
Call WriteBCD
Call CRLF
mov ah,9
mov edx,Offset VSTR_OEMString
int 21h
mov edx,[VBE_OEMStringPtr]
call WriteASCIIZ
mov ah,9
mov edx,Offset VSTR_TotalMemory
int 21h
mov ax,[VBE_TotalMemory]
Call WriteWord
mov al,'K'
call WriteChar
mov al,'b'
call WriteChar
Call CRLF
Cmp [VBE_VBEVersion],0200h
jb @@SkipVBE2Implementations
mov ah,9
mov edx,Offset VSTR_SoftwareRev
int 21h
mov ax,[VBE_SoftwareRev]
Call WriteBCD
Call CRLF
mov ah,9
mov edx,Offset VSTR_OEMVendorName
int 21h
mov edx,[VBE_OEMVendorNamePtr]
call WriteASCIIZ
mov ah,9
mov edx,Offset VSTR_OEMProductName
int 21h
mov edx,[VBE_OEMProductNamePtr]
call WriteASCIIZ
mov ah,9
mov edx,Offset VSTR_OEMProductRev
int 21h
mov edx,[VBE_OEMProductRevPtr]
call WriteASCIIZ
@@SkipVBE2Implementations:
mov ah,9
mov edx,Offset VSTR_DrawMode
int 21h
cmp [VBE_LFBAvailable],1
jne @@NoLFBFound
mov edx,Offset VSTR_LFB
jmp @@DrawInfoEnd
@@NoLFBFound:
cmp [VBE_PMODEBankSwitch],1
jne @@NoPMODEBankSwitch
mov edx,Offset VSTR_PMBS
jmp @@DrawInfoEnd
@@NoPMODEBankSwitch:
mov edx,Offset VSTR_RMBS
@@DrawInfoEnd:
mov ah,9
int 21h
cmp [VBE_PMODEInterface],1
jne @@No32BitInterface
mov ah,9
mov edx,Offset VSTR_PMODEInterface
int 21h
@@No32BitInterface:
mov ah,9
mov edx,Offset VSTR_NumberOfMode
int 21h
mov eax,[VBE_NumberOfMode]
call WriteWord
ret
ShowVBEInfos EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ WriteASCIIZ: Write a "/0" terminated string
;░ In:
;░ EDX - Pointer to the ASCIIZ string
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
WriteASCIIZ Proc
@@AsciiLoop:
mov al,[edx]
or al,al
jz @@ZeroCharFound
call WriteChar
inc edx
jmp @@AsciiLoop
@@ZeroCharFound:
mov al,13
call WriteChar
mov al,10
call WriteChar
ret
WriteASCIIZ EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ WriteChar: Write a char at the current cursor position and move it.
;░ In:
;░ AL - ASCII number
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
WriteChar Proc
push ax
push dx
mov dl,al
mov ah,2
int 21h
pop dx
pop ax
ret
WriteChar EndP
CRLF Proc
mov al,13
call WriteChar
mov al,10
Call writechar
ret
CRLF EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ WriteWord: Write a WORD as a decimal number
;░ In:
;░ AX - Number
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
WriteWord Proc
pushad
mov bx,10
xor cx,cx
affdecimal_decompose:
xor dx,dx
div bx
push dx
inc cx
or ax,ax
jnz affdecimal_decompose
affdecimal_affiche:
pop ax
add al,48 ; yek !!!
call WriteChar
dec cx
jnz affdecimal_affiche
popad
ret
WriteWord EndP
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
;░ WriteBCD: Write 2 bytes BCD number
;░ In:
;░ AX - Number
;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
WriteBCD Proc
mov edx,eax
mov al,dh
add al,48
call WriteChar
mov al,'.'
call WriteChar
mov al,dl
add al,48
call WriteChar
ret
WriteBCD EndP
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
.Data
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
RealMode_Registers STRUC ; DOS int structure as explain in PMODEW.DOC !
R_EDI dd 0
R_ESI dd 0
R_EBP dd 0
dd 0 ; reserved
R_EBX dd 0
R_EDX dd 0
R_ECX dd 0
R_EAX dd 0
dw 0 ; reserved (cpu status flag)
R_ES dw 0 ; \
R_DS dw 0 ; | --- Real mode segments
R_FS dw 0 ; |
R_GS dw 0 ; /
R_IP dw 0 ; ignored
R_CS dw 0 ; ignored
R_SP dw 0
R_SS dw 0
RealMode_Registers ENDS
;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ VBEInfoBlock ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
VBEInfoBlock STRUC
VBESignature dd 0 ; VBE Signature
VBEVersion dw 0 ; VBE Version
OEMStringPtr dd 0 ; Pointer to OEM string
Capabilities dd 4 ; Graphics capabilities of card
VideoModePtr dd 0 ; Pointer to Video Mode List
TotalMemory dw 0 ; Number of 64kb memory blocks (add for 2.0)
OemSoftwareRev dw 0 ; VBE implementation Software revision (2.0)
OemVendorNamePtr dd 0 ; Pointer to Vendor Name String (2.0)
OemProductNamePtr dd 0 ; Pointer to Product Name String (2.0)
OemProductRevPtr dd 0 ; Pointer to Product Revision String (2.0)
Reserved db 222 dup (?) ; Reserved for VBE implementation..
OemData db 256 dup (?) ; Data Area for OEM Strings (2.0)
VBEInfoBlock ENDS
;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ModeInfoBlock ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
; Mandatory information for all VBE revisions
ModeAttributes EQU 0 ; DW mode attributes
WinAAttributes EQU 2 ; DB window A attributes
WinBAttributes EQU 3 ; DB window B attributes
WinGranularity EQU 4 ; DW window granularity
WinSize EQU 6 ; DW window size
WinASegment EQU 8 ; DW window A start segment
WinBSegment EQU 10 ; DW window B start segment
WinFuncPtr EQU 12 ; DD pointer to window function
BytesPerScanLine EQU 16 ; DW bytes per scan line
; Mandatory information for VBE 1.2 and above
XResolution EQU 18 ; DW horizontal resolution in pixels or chars
YResolution EQU 20 ; DW vertical resolution in pixels or chars
XCharSize EQU 22 ; DB character cell width in pixels
YCharSize EQU 23 ; DB character cell height in pixels
NumberOfPlanes EQU 24 ; DB number of memory planes
BitsPerPixel EQU 25 ; DB bits per pixel
NumberOfBanks EQU 26 ; DB number of banks
MemoryModel EQU 27 ; DB memory model type
BankSize EQU 28 ; DB bank size in KB
NumberOfImagePages EQU 29 ; DB number of images
Reserved_ EQU 30 ; DB reserved for page function
; Direct Color fields (required for direct/6 and YUV/7 memory models)
RedMaskSize EQU 31 ; DB size of direct color red mask in bits
RedFieldPosition EQU 32 ; DB bit position of lsb of red mask
GreenMaskSize EQU 33 ; DB size of direct color green mask in bits
GreenFieldPosition EQU 34 ; DB bit position of lsb of green mask
BlueMaskSize EQU 35 ; DB size of direct color blue mask in bits
BlueFieldPosition EQU 36 ; DB bit position of lsb of blue mask
RsvdMaskSize EQU 37 ; DB size of direct color reserved mask in bits
RsvdFieldPosition EQU 38 ; DB bit position of lsb of reserved mask
DirectColorModeInfo EQU 39 ; DB direct color mode attributes
; Mandatory information for VBE 2.0 and above
PhysBasePtr EQU 40 ; DD physical address for flat frame buffer
OffScreenMemOffset EQU 44 ; DD pointer to start of off screen memory
OffScreenMemSize EQU 48 ; DW amount of off screen memory in 1k units
Real_Mode_Block RealMode_Registers ?
VBE_RealSegment dw 0
VBE_MemSelector dw 0
VBE_Signature db 0,0 ; Signature
db 0,0
db 13,10,'$'
VBE_TotalMemory dw 0 ; Video Ram (in kb)
VBE_VBEVersion dw 0 ; BCD Version
VBE_OEMStringPtr dd 0 ; Pointer to OEM string
VBE_SoftwareRev dw 0 ; BCD Software rev.
VBE_OEMVendorNamePtr dd 0 ; Pointer to Vendor Name String
VBE_OEMProductNamePtr dd 0 ; Pointer to Product Name String
VBE_OEMProductRevPtr dd 0 ; Pointer to Product Revision String
VBE_NumberOfMode dd 0
VBE_ModeList dw 4*256 dup (0) ; Video Mode List with :
; Width, Height, bpp & mode number
VBE_Gfx_Mode dw 0 ; Hexadecimal graphic mode found
VBE_Mapping_Size dd 0 ; Size of VRAM mapping needed
VBE_VRAM_Address dd 0 ; Pointer to VIDEO RAM
VBE_BytesPerScanLine dd 0 ; Bytes per scan line
VBE_BANKSetTable dd 128 DUP (0)
VBE_WindowSize dd 0
VBE_NumberOfBanks db 0
VBE_CurrentBank db 0 ; Current used bank
VBE_LFBAvailable db 0 ; =1 if LFB available
VBE_PMODEInterface db 0 ; =1 if Protected Mode interface found
VBE_PMODEBankSwitch db 0 ; =1 if use P-Mode bank switch
VBE_PMODESetStartPtr dd 0 ; Pointer to P-Mode set start function
VBE_PMODESetStartFactor db 0 ; Factor need for Start Address
VBE_SetVBEBankPtr dd 0 ; Pointer to BankSwitch function rm&pm
VBE_Counter db 0
VSTR_TitleString db 13,10,'Revelation''s VESA driver, (c) 1997 babyloon/revelation',13,10,'$'
VSTR_Signature db ' ∙ Signature : $'
VSTR_VBEVersion db ' ∙ VBE version : $'
VSTR_OEMString db ' ∙ OEM string : $'
VSTR_TotalMemory db ' ∙ Video RAM found : $'
VSTR_SoftwareRev db ' ∙ OEM Software revision : $'
VSTR_OEMVendorName db ' ∙ OEM vendor name : $'
VSTR_OEMProductName db ' . OEM product name : $'
VSTR_OEMProductRev db ' ∙ OEM product revision : $'
VSTR_DrawMode db ' ∙ Drawing mode : $'
VSTR_LFB db 'Linear Frame Buffering',13,10,'$'
VSTR_RMBS db 'Real Mode BankSwitching',13,10,'$'
VSTR_PMBS db 'Protected Mode BankSwitching',13,10,'$'
VSTR_PMODEInterface db ' ∙ Protected Mode interface found !',13,10,'$'
VSTR_NumberOfMode db ' ∙ Number of VBE Mode : $'
VBE_Msg_Table dd offset VBE_Err0,offset VBE_Err1,offset VBE_Err2
dd offset VBE_Err3,offset VBE_Err4,offset VBE_Err5
dd offset VBE_Err6,offset VBE_Err7,Offset VBE_Err8,Offset VBE_Err9
VBE_Err0 db '>VESA assembler functions (c) 1997 babyloon/revelation$'
VBE_Err1 db '>DOS memory allocation failed$'
VBE_Err2 db '>DOS interrupt failed$'
VBE_Err3 db '>VESA not supported$'
VBE_Err4 db '>DOS memory DeAllocation failed$'
VBE_Err5 db '>Requested video mode not found$'
VBE_Err6 db '>Wrong VESA mode$'
VBE_Err7 db '>Cannot map memory$'
VBE_Err8 db '>Bank Switching not really available$'
VBE_Err9 db '>Bad Window A attributes$'