home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / hsc14ecr.zip / TESTHSC.ASM < prev    next >
Assembly Source File  |  1994-01-30  |  10KB  |  202 lines

  1. MASM
  2. COMMENT *
  3. ───────────────────────────────────────────────────────────────────────────────
  4.  This is just a short assembler file that shows the usage of the HSCTracker
  5.  FM routines, What IS strange about this file is that the jnc instruction
  6.  used at line 37 (or so) assembles to jnb using tasm, which is strange to say
  7.  the least......  I dont want it to change my shitty code! :))
  8.  
  9.  Anyways, this should give everyone an idea how to use the FM routines in thier
  10.  own asm programs, and for my part, I think these routines are real cool, a
  11.  big thanks to chicken!!
  12.  
  13.  Phil Carlisle  -  pc@espr.demon.co.uk
  14.  
  15.  Umm, dig the modular style!, where's the bloody incbin, thanks for the patch
  16.  program chicken!
  17. ───────────────────────────────────────────────────────────────────────────────
  18. *
  19.  
  20. ;───────────────────────────────────────────────────────────────────────────────
  21. ; Dont forget to change the directories of the include files!! :)
  22. ;───────────────────────────────────────────────────────────────────────────────
  23.  
  24. include c:\assemble\fmhsc.inc                 ;fm routines include file
  25. include c:\assemble\dosstdhd.inc              ;dos header include file
  26. dataseg                                       ;start the data segment
  27. include "bomb.bin"                            ;the HSC music file data
  28. include "done.dat"                            ;the screen file 4000 bytes
  29. ends                                          ;end data segment
  30. codeseg                                       ;start code segment
  31. adlibthere      db      0                     ;byte to store adlib flag
  32. include "c:\assemble\macros.inc"              ;include my macro's
  33. include "c:\assemble\retrace.inc"             ;and my retrace code
  34. include "c:\assemble\adlibtst.inc"            ;and the adlibdetect proc
  35.  
  36.  
  37. Equalizers      db      9 dup (0)             ;where to put the equ data!
  38.                                               ;not really needed but I use it
  39.                                               ;because I wasnt sure what I was
  40.                                               ;doing with hsc at first...
  41.  
  42. ;───────────────────────────────────────────────────────────────────────────────
  43. ; Proc Startmusic, funnily enough starts the HSC music playing, in timer
  44. ; mode... detectadlib returns carry set if no adlib...
  45. ; everything else SHOULD be preserved.
  46. ;───────────────────────────────────────────────────────────────────────────────
  47.  
  48. PROC Startmusic                               ;called to start FM music
  49.  
  50.      call      Detectadlib                    ;detect CF=Set on not there...
  51.      jc        @@notmusic                     ;carry flag set, no music
  52. @@noprob:                                     ;
  53.      mov       [cs:adlibthere],1              ;store a flag about music
  54.      mov       ax,seg bomb                    ;adlibthere=1 = music ok...
  55.      mov       es,ax                          ;point es to segment of music-
  56.      mov       ax,offset bomb                 ;data, si=offset
  57.      mov       si,ax                          ;
  58.      mov       ah,0                           ;zero ah (Use XOR next time! )
  59.      mov       bx,0                           ;and bx
  60.      call      hscplayer                      ;call music routine
  61. @@notmusic:                                   ;jmp here if no music allowed
  62.      ret                                      ;return from proc
  63. ENDP                                          ;end of proc
  64.  
  65. ;───────────────────────────────────────────────────────────────────────────────
  66. ; Proc DoGreetz, just blasts a 4000byte file in the form of an SBD file (mine)
  67. ; char:1byte Attrib:1byte format, uses rep movsw to write it...
  68. ; All regs preserved...
  69. ;───────────────────────────────────────────────────────────────────────────────
  70.  
  71. PROC DoGreetz                                 ;routine to show screen
  72.      pusha                                    ;save regs
  73.      mov        ax,seg Screenfile             ;point ds:si to screenfile
  74.      mov        ds,ax                         ;address
  75.      mov        ax,offset screenfile          ;
  76.      mov        si,ax                         ;
  77.      mov        ax,0b800h                     ;es to text screen segment b800h
  78.      mov        es,ax                         ;
  79.      mov        di,0                          ;di to start of that seg
  80.      mov        cx,2000                       ;4000 bytes = 1 screen
  81.      rep        movsw                         ;moved in words
  82.                                               ;hide cursor
  83.      mov        dh,24                         ;use an int to set cursor pos'n
  84.      mov        dl,0
  85.      mov        ah,02
  86.      int        10h                           ;so we cant see it flashing
  87.      popa
  88.      ret                                      ;end of proc
  89. ENDP
  90.  
  91. ;───────────────────────────────────────────────────────────────────────────────
  92. ; Proc Dobars just sets up equalizer bars horizontally, as its easier!
  93. ; All regs preserved     NOTE: It checks keyboard as well.... only an example!
  94. ;───────────────────────────────────────────────────────────────────────────────
  95.  
  96. PROC Dobars                                   ;equalizer bars for hscplayer
  97.      pusha                                    ;save regs
  98.      mov        bp,0
  99. @@equloop:
  100.      mov        ax,seg hscplayer              ;move segment of hscplayer
  101.      mov        ds,ax                         ;into ds
  102.      mov        si,0a48h
  103.      mov        ax,cs
  104.      mov        es,ax
  105.      mov        di,offset cs:equalizers
  106.      mov        cx,9
  107.      rep        movsb                         ;data for EQU's copied
  108.  
  109.      mov        ax,0b800h                     ;es=>screen mem (text)
  110.      mov        es,ax                         ;
  111.      mov        di,0                          ;di points to start
  112. @@eqloop:
  113.      xor        cx,cx                         ;clear cx
  114.      mov        cl,[cs:equalizers+bp]         ;ch = value in equ (n) see address
  115.      mov        ch,0h                         ;given in hscdoc
  116.      inc        cx
  117.      and        cx,1fh                        ;take ch value from ff
  118.      shl        cx,2                          ;divide cl by for to keep in
  119.  
  120.      mov        al,220                        ;al = bar character
  121.      mov        ah,12                         ;ah= colour attrib byte
  122.      rep        stosw                         ;write the data
  123.      add        bp,1
  124.      xor        ax,ax
  125.      mov        ax,bp
  126.      mov        dx,160
  127.      mul        dx
  128.      mov        di,ax
  129.      cmp        bp,8
  130.      jle        @@eqloop
  131.      Call       WaitVsyncStart                ;wait again, at least a frame
  132.                                               ;(Might be better to wait_de!!)
  133.      mov        di,0
  134.      mov        ax,0
  135.      mov        cx,2000
  136.      Call       WaitVsyncStart
  137.      rep        stosw
  138.      mov        bp,0
  139.      mov        di,0                          ;so that we see the bar
  140.      in         al,60h                        ;check keyboard
  141.      cmp        al,01                         ;is esc pressed?
  142.      jne        @@equloop                     ;no, so loop...
  143.      popa                                     ;restore regs
  144.      ret                                      ;end it all.. :)
  145. ENDP                                          ;end of proc..
  146.  
  147. ;───────────────────────────────────────────────────────────────────────────────
  148. ; Proc Deinitmusic (amazingly stops the music playing), it first
  149. ; checks a flag we set in the adlib detect part to know wether to bother.
  150. ;───────────────────────────────────────────────────────────────────────────────
  151.  
  152. PROC Deinitmusic                              ;de initialise FM and free timers
  153.      cmp        [adlibthere],1                ;if no adlib there dont bother
  154.      jne        @@dontbother                  ;otherwise
  155.      mov        ah,2                          ;use function 2
  156.      call       hscplayer                     ;of FM routines to free timers
  157. @@dontbother:                                 ;etc....
  158.      ret                                      ;end
  159.  
  160. ENDP
  161.  
  162. ;───────────────────────────────────────────────────────────────────────────────
  163. ; Proc Gotoit (Our main program), calls all the other procs,
  164. ; then loops around in dobars until esc is pressed...
  165. ;───────────────────────────────────────────────────────────────────────────────
  166.  
  167. PROC Gotoit                                   ;Main program starts
  168.      Call    Startmusic                       ;
  169.      Call    Dobars                           ;dobars checks escape...
  170.      Call    Deinitmusic                      ;restore machine state
  171.      textmode                                 ;reset the mode (cls)
  172.      Call    DoGreetz                         ;Display the greetings (huh! :)
  173. ;     Waitferescape                            ;Wait for the world to end...
  174. ;     textmode                                 ;set 24bit colour cga mode
  175.      quittodos                                ;exit to dos macro....
  176. ENDP                                          ;end procedure
  177. ENDS                                          ;end code segment
  178. END Gotoit                                    ;end program
  179.  
  180. MASM
  181. COMMENT *
  182. ───────────────────────────────────────────────────────────────────────────────
  183. Note to User:
  184. =============
  185. I only use this as an example, dont take it as gospel, but the value
  186. does change, I'm not sure what range it is supposed to be in though,
  187. I use shr 2 to divide it by 4, so that its always in my range....
  188.  
  189. Obviously the code for the tracker is copyright chicken, so dont bring youre
  190. problems to me! :)), errrm, use this at youre own rick, errm, dont drink n drive
  191. dont cheek your elders etc.... um, this code is public domain, if you make ANY
  192. money off of it, youre a better man than I... :))
  193. ───────────────────────────────────────────────────────────────────────────────
  194. *
  195. IDEAL    ; dont we all wish life was more ideal?? :)
  196.                                               
  197.  
  198.  
  199.  
  200.  
  201.  
  202.