home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / FUNK108A.ZIP / DOS32V30.ZIP / EXAMPLES / VESA.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-06-08  |  4.4 KB  |  195 lines

  1. comment ~ 
  2. *****************************************************************************
  3.          Example program for DOS32 dos-extender.
  4.  
  5.  
  6.            Using the VESA BIOS Extention.
  7.  
  8.  
  9.  
  10.  
  11. *****************************************************************************
  12. ~
  13. .386
  14. .MODEL FLAT , PASCAL
  15. .STACK
  16.  
  17. ;
  18. ;  Macro to print some text on the screem
  19. ;
  20. Print MACRO string
  21. local @text,@skip
  22.     mov edx,offset @text
  23.     mov ah,9
  24.     int 21h
  25.     jmp @skip
  26. @text db string,13,10,36
  27. @skip:
  28. ENDM
  29.  
  30.  
  31. .DATA
  32. DOS_Ptr             DD ?
  33. VideoPtr            DD ?
  34. ProgramBaseAddress  DD ?
  35.  
  36. DOS_segs LABEL DWORD
  37. Real_ES     DW  ?
  38. Real_DS     DW  ?
  39.  
  40. CurrentBank         DB  ?
  41. .CODE
  42.  
  43.  
  44. Palette  Label Byte
  45. Include VESA.INC
  46.  
  47. ;---------------------------------------
  48. ; SET Video bank number to AL
  49. ;---------------------------------------
  50. SetBank PROC USES EDX EBX
  51.         movzx  edx,al
  52.         mov    bh,0
  53.         mov    bl,0
  54.         mov    ax,04F05h
  55.         push   10h
  56.         call   DOSinterrupt
  57.         Ret
  58. SetBank ENDP
  59.  
  60.  
  61. VBEstart PROC
  62.          mov    ax,0EE02h       ; GET REAL MODE SEGMENT OF FILE I/O BUFFER
  63.          int    31h
  64.          mov    ProgramBaseAddress,ebx
  65.          mov    Real_ES,ax
  66.          And    Eax,0FFFFh
  67.          shl    Eax,4
  68.          sub    eax,ebx
  69.          Mov    DOS_Ptr,eax
  70.  
  71.  
  72.          mov    ax,4F00h        ; GET VESA INFORMATION
  73.          mov    di,0             ; ES:DI -> 256 byte buffer
  74.          push   10h
  75.          call   DOSinterrupt
  76.          Cmp    AX,004Fh
  77.          jne   NoVESA
  78.  
  79.  
  80.  
  81.      ;
  82.      ; Search video mode list for 640x480x256 ( VESA mode 101h )
  83.      ;
  84.          mov   eax,DOS_Ptr
  85.          Movzx edx,Word Ptr [Eax+10h]       ; get DOS segment of mode list
  86.          shl   edx,4
  87.          sub   edx,ProgramBaseAddress
  88.          movzx ebx,Word Ptr [Eax+0Eh]       ; get offset of mode list
  89.          add   edx,ebx
  90.                                             ; EDX points to video mode list.
  91.  
  92. Loop01:  Mov   ax,[Edx]                     ; Read video mode list
  93.          Cmp   Ax,0FFFFh
  94.          je  @@ModeNotFound
  95.          add   Edx,2
  96.          cmp   Ax,101h
  97.          jne   Loop01
  98.  
  99.      ;
  100.      ; Calulate CPU video address
  101.      ;
  102.          mov    eax,0A0000h
  103.          sub    eax,ProgramBaseAddress
  104.          mov    VideoPtr,eax
  105.  
  106.      ;
  107.      ; Set VIDEO mode  640x480x256 ..........
  108.      ;
  109.          mov    ax,4F02h
  110.          mov    BX,101h
  111.          Int    10h
  112.          Cmp    AX,004Fh
  113.          jne    @@ModeNotFound
  114.  
  115.     ;
  116.     ; Set palette
  117.     ;
  118.          mov    al,0
  119.          mov    dx,3C8h
  120.          out    dx,al
  121.          mov    esi,Offset Palette
  122.          mov    dx,3C9h
  123.          mov    ecx,768
  124.          cld
  125.          rep    outsb
  126.  
  127.  
  128.     ;
  129.     ; Fill in screen with some patterns
  130.     ;
  131.          mov     CurrentBank,0
  132.          mov     bl,0
  133. loop02:  mov     edi,VideoPtr
  134.          mov     al,CurrentBank
  135.          call    SetBank
  136.          mov     bh,102
  137. Loop03:  mov     ecx,640/4
  138.          mov     al,bl
  139.          mov     ah,bl
  140.          push    ax
  141.          push    ax
  142.          pop     eax
  143.          rep     stosd
  144.          inc     bl
  145.          dec     bh
  146.          jnz Loop03
  147.  
  148.          inc     CurrentBank
  149.          cmp     CurrentBank,5
  150.          jb loop02
  151.  
  152.  
  153.         mov     ah,0        ; Wait for a key ( using BIOS service )
  154.         int     16h
  155.  
  156.         mov    ax,3          ; Return to TEXT mode
  157.         int    10h
  158.  
  159. Exit:
  160.          Mov    Ax,4C00h
  161.          Int    21h
  162.  
  163. @@ModeNotFound:
  164.          Print 'Video mode 640x480x256 not supported  ( VESA mode 101h )'
  165.          jmp Exit
  166.  
  167. NoVESA:
  168.          Print 'VESA BIOS not installed'
  169.          jmp Exit
  170.  
  171. VBEstart ENDP
  172.  
  173.  
  174. ;------------------------------------------------------------
  175. ; Procudure to call a DOS interrupt.
  176. ;------------------------------------------------------------
  177. DOSinterrupt PROC
  178.         push    dword ptr 0             ; ignore  SS, SP
  179.         lea     esp,[esp - 8]           ; ignore  CS, IP ,FS, GS
  180.         push    [DOS_segs]
  181.         pushfw
  182.         pushad
  183.         mov     edi,esp
  184.         mov     ax,0300h
  185.         xor     cx,cx
  186.         movzx   Ebx,Byte Ptr [esp+36h]  ; Get int number from stack param
  187.         int     31h                     ; Emulate Real Mode Interrupt
  188.         popad
  189.         popfw
  190.         lea     esp,[esp+16]            ; Ignore SS,SP,CS,IP,FS,GS,ES & DS
  191.         ret     4
  192. DOSinterrupt ENDP
  193.  
  194. End VBEstart
  195.