home *** CD-ROM | disk | FTP | other *** search
/ modiromppu / modiromppu.iso / PROGRAMS / ORGPACKS / RADV1_0A.ZIP / RADTEST.ASM < prev    next >
Assembly Source File  |  1995-02-01  |  4KB  |  204 lines

  1. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2. ; Test-Code by Shayde/Reality Feb95.
  3. ;
  4. ; Assembled with TASM 4.0.
  5. ;
  6. ; This is a test code to demonstrate how to use the RAD-Player code in your
  7. ; own productions.  All it does is start the tune playing, waits for a key-
  8. ; press and stops.  Complex stuff, eh?! :-)
  9. ;
  10. ; This code assumes the tune is a 50Hz (normal-timer) tune and changes the PC
  11. ; hardware clock to interrupt 50 times a second (although it still calls the
  12. ; BIOS interrupt 18.2 times a second).  It is easy enough to modify it to
  13. ; stay at the default 18.2Hz for any slow-timer tunez.  If you want to
  14. ; create a new tune .INC file I have included the Reality Data-maker in this
  15. ; package.
  16. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  17.  
  18.         .286
  19.         jumps
  20.         locals
  21.  
  22.  
  23.  
  24. IPS        =    50
  25.  
  26.  
  27.  
  28. Code16        segment public use16
  29.         assume cs:Code16, ds:Code16
  30.  
  31.  
  32. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  33. ; Main.
  34. ;──────────────────────────────────────────────────────────────────────────────
  35. Start:        mov    ax,cs
  36.         mov    ds,ax
  37.  
  38.         mov    ax,Music
  39.         mov    es,ax
  40.         call    InitPlayer
  41.         call    SetInt
  42.  
  43.     ; wait for keypress
  44.         xor    ah,ah
  45.         int    16h
  46.  
  47.     ; stop tune
  48.         call    ResetInt
  49.         call    EndPlayer
  50.         mov    ax,4c00h
  51.         int    21h
  52.  
  53.  
  54.  
  55.  
  56.  
  57. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  58. ; Enables and starts the player interrupt.
  59. ;──────────────────────────────────────────────────────────────────────────────
  60. SetInt:        push    ax es
  61.  
  62.         cli
  63.         xor    ax,ax
  64.         mov    es,ax
  65.         mov    ax,es:[8*4]
  66.         mov    word ptr OldInt,ax
  67.         mov    ax,es:2[8*4]
  68.         mov    word ptr OldInt+2,ax
  69.         mov    word ptr es:[8*4], offset PlayerInt
  70.         mov    es:2[8*4],cs
  71.  
  72.         mov    ax,IPS
  73.         call    SetTimer
  74.  
  75.         sti
  76.         pop    es ax
  77.         ret
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  85. ; Disables the player interrupt.
  86. ;──────────────────────────────────────────────────────────────────────────────
  87. ResetInt:    push    ax es
  88.  
  89.         cli
  90.         xor    ax,ax
  91.         mov    es,ax
  92.         mov    ax,word ptr OldInt
  93.         mov    es:[8*4],ax
  94.         mov    ax,word ptr OldInt+2
  95.         mov    es:2[8*4],ax
  96.  
  97.         call    ResetTimer
  98.  
  99.         sti
  100.         pop    es ax
  101.         ret
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  109. ; The player interrupt.  Called 50 times a second.
  110. ;─────────────────────────────────────────────────────────────────────────────
  111. PlayerInt:    push    ax
  112.  
  113.         call    PlayMusic
  114.  
  115.     ; see if we have passed 18.2/s mark
  116.     @@lx:    mov    ax,TimerSteps        ; this no. of steps per int.
  117.         add    TimerCnt,ax
  118.         jnc    @@ly            ; don't call timer interrupt
  119.         pop    ax
  120.         jmp    cs:OldInt        ; call old interrupt handlers
  121.  
  122.     ; standard exit
  123.     @@ly:    mov    al,20h
  124.         out    20h,al
  125.         pop    ax
  126.         iret
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  134. ; Sets the interrupt timer duty cycle.
  135. ; IN:
  136. ;    AX    - number of times per second for INT08.
  137. ;──────────────────────────────────────────────────────────────────────────────
  138. SetTimer:    push    ax bx dx
  139.  
  140.         mov    bx,ax
  141.         mov    ax,13532    ; 1193180 mod 65536 (TASM craps out)
  142.         mov    dx,18        ; 1193180/65536 (TASM can't calculate this)
  143.         div    bx
  144.         mov    bx,ax
  145.  
  146.         mov    al,36h
  147.         out    43h,al
  148.         mov    al,bl
  149.         out    40h,al
  150.         mov    al,bh
  151.         out    40h,al
  152.  
  153.         mov    TimerSteps,bx    ; for keeping 18.2 timer correct
  154.         mov    TimerCnt,0    ; counter
  155.  
  156.         pop    dx bx ax
  157.         ret
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164. ;▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  165. ; Resets the interrupt timer back to 18.2/sec duty cycle.
  166. ;──────────────────────────────────────────────────────────────────────────────
  167. ResetTimer:    push    ax
  168.  
  169.         mov    al,36h
  170.         out    43h,al
  171.         xor    al,al
  172.         out    40h,al
  173.         out    40h,al
  174.  
  175.         pop    ax
  176.         ret
  177.  
  178.  
  179.  
  180.  
  181.         include        Player.Asm
  182.  
  183.  
  184.  
  185.  
  186. OldInt        dd    ?
  187. TimerCnt    dw    ?
  188. TimerSteps    dw    ?
  189.         ends
  190.  
  191.  
  192.  
  193. Music        segment para public use16
  194.         include    Hangover.Inc
  195.         ends
  196.  
  197.  
  198.  
  199. Stack16        segment para public use16 stack
  200.         dw    100h dup (?)
  201.         ends
  202.  
  203.         end    Start
  204.