home *** CD-ROM | disk | FTP | other *** search
/ M.u.C.S. Disc 2000 / MUCS2000.iso / falcon / whip_ / vlmdocu / example / example.s next >
Text File  |  1985-06-06  |  9KB  |  294 lines

  1. ;
  2. ; VLM EXAMPLE MODULE                                             NO/Escape'98
  3. ;
  4.  
  5.                 OUTPUT 'E:\VOODOO\VLM\EXAMPLE.VLM'
  6.                 TEXT
  7.  
  8.                 >PART 'vlm module structure'
  9. *** VLM STRUCTURE **************************************************************
  10.  
  11.                 DC.B "VLM2"     ;vlm module type
  12.                 DC.L infotext   ;pointer to infotext
  13.                 DC.L settings   ;pointer to settings-structure
  14.                 DC.L init       ;pointer to init routine
  15.                 DC.L deinit     ;pointer to deinit routine
  16.                 DC.L main       ;pointer to mainloop routine
  17.  
  18. ;SERVICE ROUTINES PROVIDED BY THE CALLING PROGRAM
  19.  
  20. set_vblrout:
  21. ;a0: new vbl subroutine
  22.                 movea.l service_struct,A1
  23.                 movea.l (A1),A1
  24.                 jsr     (A1)
  25.                 rts
  26.  
  27. wait_vbl:
  28.                 movea.l service_struct,A1
  29.                 movea.l 4(A1),A1
  30.                 jsr     (A1)
  31.                 rts
  32.  
  33. set_scradr:
  34. ;a0: new screen adress
  35.                 movea.l service_struct,A1
  36.                 movea.l 8(A1),A1
  37.                 jsr     (A1)
  38.                 rts
  39.  
  40. set_resolution:
  41. ;d0: number of the wanted resolution
  42.                 movea.l service_struct,A1
  43.                 movea.l 12(A1),A1
  44.                 jsr     (A1)
  45.                 rts
  46.  
  47. get_left_spec:
  48.                 movea.l service_struct,A1
  49.                 movea.l 16(A1),A1
  50.                 jsr     (A1)            ;returns in a0 the adress of left spec
  51.                 rts
  52.  
  53. get_right_spec:
  54.                 movea.l service_struct,A1
  55.                 movea.l 20(A1),A1
  56.                 jsr     (A1)            ;returns in a0 the adress of right spec
  57.                 rts
  58.  
  59. get_left_volume:
  60.                 movea.l service_struct,A1
  61.                 movea.l 24(A1),A1
  62.                 jsr     (A1)            ;returns in d0 the left volume value
  63.                 rts
  64.  
  65. get_right_volume:
  66.                 movea.l service_struct,A1
  67.                 movea.l 28(A1),A1
  68.                 jsr     (A1)            ;returns in d0 the right volume value
  69.                 rts
  70.  
  71. get_left_osci:
  72.                 movea.l service_struct,A1
  73.                 movea.l 32(A1),A1
  74.                 jsr     (A1)            ;returns in a0 the adress of osci data
  75.                 rts
  76.  
  77. get_right_osci:
  78.                 movea.l service_struct,A1
  79.                 movea.l 36(A1),A1
  80.                 jsr     (A1)            ;returns in a0 the adress of osci data
  81.                 rts
  82.  
  83. service_struct: DC.L 0          ;must be set in 'init'
  84.  
  85. ********************************************************************************
  86.                 ENDPART
  87. infotext:       >PART
  88.                 DC.B 'PROGRAMMING EXAMPLE',0
  89.                 DC.B 'author:  NO/Escape',0
  90.                 DC.B 'version: 1.0',0
  91.                 DC.B 'date:    02.06.99',0
  92.                 DC.B 0
  93.                 EVEN
  94.                 ENDPART
  95. settings:       >PART
  96.                 DC.L 3
  97.  
  98.                 DC.L parname1
  99.                 DC.L 1          ;parameter type = activator
  100. show_osci:      DC.L 1          ;parametervalue (1...activated)
  101.                 DC.L 0
  102.  
  103.                 DC.L parname2
  104.                 DC.L 1
  105. show_volumes:   DC.L 1
  106.                 DC.L 0
  107.  
  108.                 DC.L parname3
  109.                 DC.L 1
  110. show_spec:      DC.L 1
  111.                 DC.L 0
  112.  
  113. parname1:       DC.B "SHOW OSCILLOSCOPE",0
  114. parname2:       DC.B "SHOW MAINVOLUMES",0
  115. parname3:       DC.B "SHOW SPECTRE",0
  116.                 EVEN
  117.                 ENDPART
  118. init:           >PART
  119. ;a0: service structure
  120.                 move.l  A0,service_struct
  121.  
  122.                 movea.l scradr2,A0      ;set new screen adress
  123.                 bsr     set_scradr
  124.  
  125.                 move.l  #2,D0           ;set resolution to 320x100
  126.                 bsr     set_resolution
  127.                 rts
  128.                 ENDPART
  129. deinit:         >PART
  130.                 rts
  131.                 ENDPART
  132. main:           PART
  133.  
  134.                 bsr     wait_vbl
  135.                 bsr     switch_screens
  136.                 bsr     clrscr
  137.  
  138. ;DRAW SPECTRES
  139.                 tst.l   show_spec       ;test spec activator
  140.                 beq     draw_no_spectres
  141.                 bsr     get_left_spec
  142.                 movea.l A0,A6
  143.                 movea.l scradr1,A0
  144.                 lea     (60+99*2*320.l,ZA0,A0.l),A0
  145.                 bsr     draw_spectre
  146.  
  147.                 bsr     get_right_spec
  148.                 movea.l A0,A6
  149.                 movea.l scradr1,A0
  150.                 lea     (60+99*2*320+2*128.l,ZA0,A0.l),A0
  151.                 bsr     draw_spectre
  152. draw_no_spectres:
  153.  
  154.  
  155. ;DRAW OSCILLOSCOPES (ONLY WHEN PARAMETER SET)
  156.                 tst.l   show_osci       ;test osci activator
  157.                 beq     draw_no_osci
  158.                 bsr     get_left_osci
  159.                 movea.l A0,A6           ;osci data
  160.                 movea.l scradr1,A0
  161.                 adda.l  #640*32+60,A0   ;screenposition
  162.                 move.w  #%1111,D6       ;color
  163.                 bsr     draw_oscilloscope
  164.  
  165.                 bsr     get_right_osci
  166.                 movea.l A0,A6           ;osci data
  167.                 movea.l scradr1,A0
  168.                 adda.l  #640*32+60,A0   ;screenposition
  169.                 move.w  #%111100000000000,D6 ;color
  170.                 bsr     draw_oscilloscope
  171. draw_no_osci:
  172.  
  173. ;DRAW VOLUMES (ONLY WHEN PARAMETER SET)
  174.                 tst.l   show_volumes    ;test volume activator
  175.                 beq     draw_no_volumes
  176.                 bsr     get_left_volume ;returns left volume in d0
  177.                 lsr.l   #8,D0
  178.                 andi.w  #255,D0
  179.                 movea.l scradr1,A0
  180.                 adda.l  #640*50+60,A0
  181. draw_left_volume_loop:
  182.                 move.w  #-1,(A0)+
  183.                 dbra    D0,draw_left_volume_loop
  184.  
  185.                 bsr     get_right_volume ;returns right volume in d0
  186.                 lsr.l   #8,D0
  187.                 andi.w  #255,D0
  188.                 movea.l scradr1,A0
  189.                 adda.l  #640*60+60,A0
  190. draw_right_volume_loop:
  191.                 move.w  #-1,(A0)+
  192.                 dbra    D0,draw_right_volume_loop
  193. draw_no_volumes:
  194.  
  195.                 rts                     ;end of the mainroutine
  196.  
  197.  
  198.  
  199. ;FUNCTION DRAWS A SPECTRE ON THE SPECIFIED SCREENPOSITION
  200. draw_spectre:
  201. ;a6: buffer with spec values
  202. ;a0: first screenadress
  203.                 lea     zshade_epp,A3
  204.                 move.w  #128-1,D2
  205. receive_spectrum:
  206.                 moveq   #0,D0           ;get spec value from buffer
  207.                 move.w  (A6)+,D0        ;and scale it a bit
  208.                 lsl.l   #7,D0
  209.                 swap    D0
  210.                 andi.l  #$7F,D0
  211.  
  212.                 cmpi.l  #99,D0          ;clip to high values
  213.                 blt     spec_value_ok
  214.                 move.l  #100,D0
  215. spec_value_ok:
  216.                 movea.l A0,A1
  217.  
  218.                 move.l  #100,D1         ;choose color (depends on spec value)
  219.                 sub.l   D0,D1
  220.                 lsr.l   #1,D1
  221.                 move.w  10(A3,D1.w*2),D1
  222. draw_yloop:
  223.                 move.w  D1,(A1)
  224.                 lea     -640(A1),A1
  225.                 dbra    D0,draw_yloop
  226.                 addq.l  #2,A0           ;go on with next vertical line
  227.                 dbra    D2,receive_spectrum
  228.                 rts
  229.  
  230.  
  231. ;DRAWS AN OSCILLOSCOPE
  232. draw_oscilloscope:
  233. ;a0: scradr
  234. ;d6: color
  235. ;a6: buffer with osci values
  236.                 lea     zshade_epp+32,A1
  237.                 move.w  #256-1,D7
  238. get_left_osci_loop:
  239.                 move.w  (A6)+,D0        ;get value from left osci buffer
  240.                 ext.l   D0
  241.                 asl.l   #5,D0           ;scale value to range (-32..32)
  242.                 swap    D0
  243.                 move.w  D0,D1
  244.                 muls    #640,D0
  245.                 add.w   D6,0(A0,D0.w)
  246.                 addq.l  #2,A0
  247.                 dbra    D7,get_left_osci_loop
  248.                 rts
  249.  
  250.  
  251. clrscr:
  252. ;clear screen
  253.                 movea.l scradr1,A0
  254.                 adda.l  #60+640*0,A0
  255.                 move.l  #%11110111110111101111011111011110,D5
  256.                 move.w  #100,D7
  257. clrscr_yloop:
  258.                 move.w  #128-1,D6
  259. clrscr_xloop:
  260.                 move.l  (A0),D0
  261.                 and.l   D5,D0
  262.                 lsr.l   #1,D0
  263.                 move.l  D0,(A0)+
  264.                 dbra    D6,clrscr_xloop
  265.                 adda.l  #128,A0
  266.                 dbra    D7,clrscr_yloop
  267.                 rts
  268.  
  269.  
  270. ;ROUTINE SWITCHES VISIBLE SCREEN AND CYCLES THE SCREENADRESSES
  271. switch_screens:
  272.                 move.l  scradr3,D0
  273.                 move.l  scradr2,scradr3
  274.                 move.l  scradr1,scradr2
  275.                 move.l  D0,scradr1
  276.                 movea.l scradr2,A0
  277.                 bsr     set_scradr
  278.                 rts
  279.  
  280.                 ENDPART
  281.  
  282. scradr1:        DC.L scr1+256
  283. scradr2:        DC.L scr2+256
  284. scradr3:        DC.L scr3+256
  285. zshade_epp:     IBYTES 'ZSHADE.EPP'
  286.  
  287.                 BSS
  288.  
  289. scr1:           DS.W 320*100
  290. scr2:           DS.W 320*100
  291. scr3:           DS.W 320*100
  292.  
  293.                 END
  294.