home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / digmid / real / video.asm < prev    next >
Assembly Source File  |  1992-11-19  |  1KB  |  83 lines

  1.  
  2.  
  3.     LOCALS            ;; Enable local labels
  4.  
  5.         IDEAL                   ;; Use Turbo Assembler's IDEAL mode
  6.     JUMPS
  7.  
  8.     ; Driver load and unload calls.  Requires that the application provide
  9.     ; memory allocation functions and access to DOSCALLS.OBJ.
  10.  
  11. SMALL_MODEL    equ    0   ;: True if declaring C procedures as near.
  12.             ; It is false here because all procedures are
  13.             ; far, so that you can link any memory model
  14.             ; to theme. (They are prototyped as well.)
  15.  
  16.  
  17.         INCLUDE "PROLOGUE.MAC"          ;; common prologue
  18.  
  19.  
  20. SEGMENT  _TEXT BYTE PUBLIC 'CODE'               ;; Set up _TEXT segment
  21.         ENDS
  22.  
  23.     ASSUME    CS: _TEXT, DS: _TEXT, SS: NOTHING, ES: NOTHING
  24.  
  25.  
  26. SEGMENT _TEXT
  27.  
  28. Macro    CPROC    name        ; Macro to establish a C callable procedure.
  29.     public    _&name
  30. IF    SMALL_MODEL
  31. Proc    _&name    near
  32. ELSE
  33. Proc    _&name    far
  34. ENDIF
  35.     endm
  36.  
  37.  
  38. CPROC    VidOn
  39.     mov    ax,13h
  40.     int    10h
  41.     ret
  42.     endp
  43.  
  44. CPROC    VidOff
  45.     mov    ax,03
  46.     int    10h
  47.     ret
  48.     endp
  49.  
  50. CPROC    DrawSound
  51.     ARG    SOUND:DWORD,SWID:WORD,COLOR:WORD
  52.     PENTER    0
  53.     PushCREGS
  54.  
  55.     mov    ax,0A000h
  56.     mov    es,ax        ; VGA screen ram segment.
  57.     lds    si,[SOUND]
  58.     mov    bx,320
  59.     xor    cx,cx        ; Xlocation.
  60.  
  61. @@GO:   mov     al,[ds:si]      ; Get sound value.
  62.     xor    ah,ah        ; Zero high byte.
  63.     shr    ax,1
  64.     add    ax,36        ; Adjust.
  65.     mul    bx
  66.     add    ax,cx        ; Plus current xlocation.
  67.     mov    di,ax
  68.     mov    ax,[COLOR]
  69.     mov    [byte es:di],al
  70.     inc    cx
  71.     inc    si
  72.     cmp    cx,[SWID]
  73.     jne    @@GO
  74.  
  75.     PopCREGS
  76.     PLEAVE
  77.     ret
  78.     endp
  79.  
  80.  
  81.     ends
  82.     end
  83.