home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 067.lha / Drw / drw.4th < prev    next >
Text File  |  1986-11-20  |  25KB  |  1,165 lines

  1. \ Draw yer freqencies and synthesize em
  2. \
  3. \ get the binary speedy sin,cosine
  4. Find Qsin.Spot Not IFTrue Include Qsin IfEnd
  5. \ get 8SVX maker?
  6. find 8svxmake.spot not IFTrue Include 8SVXMAke IFEnd
  7. \ console support pack
  8. find Consupp.spot not IFTrue Include Consupp IFEnd
  9. \
  10. \
  11. Decimal
  12. \
  13. 15000 Minimum.Object
  14. 512 tokens
  15. anew Drw.spot
  16. \
  17. 512 4 1array Accum
  18. 256 4 1array Phase
  19. \
  20. Variable N'p   \ number of points in the record
  21. Variable WN'p   \ working number of points in the record
  22. Variable WN'x   \ working number of points in the record multiple
  23. Variable K     \ Bitwise resolution 
  24. \ Drw Loop Parms...
  25. Variable B'Zd \ sample Delta
  26. Variable B'Ze \ sample end
  27. Variable B'Fs \ Low Freq  ( as phase shift )
  28. Variable B'Fe \ HighFreq  ( ditto )
  29. Variable B'Fd \ Freq delta ( = H-l/128 ) 
  30. Variable F'Sz \ Size of the in-core block (64K)
  31. Variable B'Zs \ BPF start
  32. Variable B'Fk \ skip number for BPF
  33. variable f'oct \ OCtaves for the file
  34. \
  35. Variable Shutup
  36. Variable Played?
  37. Variable Button
  38. Variable Period
  39. variable ccolor
  40. Variable CDrmode
  41. Variable HowLoud
  42. \
  43. hex 68 wconstant MDOWN        \ these are returned in event message
  44.     E8 wconstant MUP decimal
  45. \
  46. Variable Dl'x
  47. Variable Dl'y
  48. Variable T'f \ working frequency
  49. Variable T's \ sum register
  50. Variable T'c \ sum register
  51. Variable I'  \ other index
  52. variable LoopIx \ drawing loop indicies
  53. Variable Flock \ frequency lock
  54. \
  55. Variable Fl'S \ floating scale...
  56. Variable Fid \ file id for BPF
  57. Variable BackX \ backup feature...
  58. Variable Backy \ backup feature...
  59. Variable CbaseXA \ Copy base
  60. Variable CbaseXB \ Copy base
  61. Variable CbaseYA \ Copy base
  62. Variable CbaseYB \ Copy base
  63. 256 Constant Bwid 
  64. 128 Constant BHei 
  65. 30 Constant Bdown 
  66. Bdown 129 + Constant Bdown' 
  67. Bdown 128 + Constant Bdown'' 
  68. 5  Constant BLeft 
  69. Bleft 1+  Constant BLeft' 
  70. Bleft Bwid + Constant Bright
  71. \ loopix box
  72. bright 5+ Constant L'Left
  73. l'left 10 + constant l'right
  74. bdown constant L'top
  75. bdown  40 + constant l'bot
  76.  
  77.  
  78. \ define a custom screen, use defaults
  79. \
  80. Create DrwSTitle
  81. 0," Hey! I'm Dressing!"
  82. Create DrwWTitle
  83. 0," Drw Window"
  84. struct NewScreen DrwNs
  85.     DrwNs InitScreen     \ copy default values to new screen
  86. 5   DrwNs +nsDepth W!
  87. 320 DrwNs +nsWidth W!
  88. 0   DrwNs +NsViewModes W!
  89. struct NewWindow DrwNw \ define a window
  90.          Drwnw InitWindow      \ copy default values to new window
  91.       0  Drwnw +nwLeftEdge w!
  92.       0  Drwnw +nwTopEdge  w!
  93.      320 Drwnw +nwWidth    w!
  94.      200 Drwnw +nwHeight   w!
  95.  WINDOWSIZING WINDOWDRAG  | WINDOWCLOSE | ACTIVATE | 
  96.                       Drwnw +nwFlags !
  97.      fCLOSEWINDOW MouseButtons |  
  98.      RawKey |         Drwnw +nwIDCMPFlags  !
  99.      CUSTOMSCREEN     Drwnw +nwType w!  \  open on a custom screen
  100. structend
  101. \
  102. Variable MODE
  103. \
  104. create TopMode$
  105. 0," D R W -  D S P  R B  W  I O  Q "
  106. create DoodleMode$
  107. 0," Doodle Mode "
  108. create SynthMode$
  109. 0," Synth Mode "
  110. create PlayMode$
  111. 0," Play Mode " 
  112. create WriteMode$
  113. 0," Write Mode " 
  114. create BPFMode$
  115. 0," Band Pass Mode " 
  116. create InputMode$
  117. 0," Input Mode " 
  118. create OutputMode$
  119. 0," Output Mode " 
  120. \
  121. : Curx Currentwindow @ +wMouseX W@
  122. ;
  123. : CurY Currentwindow @ +wMouseY W@
  124. ;
  125. : ClipX
  126. Dup BLeft < if drop bleft then
  127. Dup Bright > if drop Bright then
  128. ;
  129. : ClipY
  130. dup bdown < if drop bdown then
  131. dup bdown' > if drop bdown' then 
  132. ;
  133. : CurX'
  134. CurX clipx
  135. ;
  136. : CurY'
  137. cury clipy
  138. ;
  139. Variable CX'
  140. Variable CY'
  141. variable Vx
  142. variable vy
  143. \
  144. Create T'Tx 8 allot
  145. T'Tx 8 erase
  146. : N'Text ( I X Y )
  147. Locals| YY XX II |
  148. II <# # # # # # # # # #> T'Tx swap Cmove
  149. Rport 2 SetAPen
  150. Rport XX yY Move
  151.  Rport T'Tx  8 Text drop
  152. ;
  153. : N'Text2 ( I X Y )
  154. Locals| YY XX II |
  155. II <# # # # #> T'Tx swap Cmove
  156. Rport 2 SetAPen
  157. Rport XX yY Move
  158.  Rport T'Tx  3 Text drop
  159. ;
  160. \
  161. : Asc, [compile] Ascii , ;
  162. ?align4
  163. create Xplan
  164. Asc, Dot_  Asc, Line  asc, Ramp  asc, Thin  asc, Blob
  165. asc, Harm  Asc, Avg_  asc, R-Up  asc, R-Dn  asc, Fill
  166. asc, Fil2  asc, Dec_  asc, Inc_  asc, Xcld  asc, -Cut
  167. Asc, Dec0  asc, Inc0  asc, From  asc, To__  asc, Copy
  168. asc, .21.  asc, AMmd  asc, CpFr  asc, CpTm  asc, Lck1
  169. asc, Lck2  asc, Lck4  asc, Lck8  asc, Vl02  asc, Vl01
  170. asc, Vl00  asc, .32. 
  171. : getCmode 
  172. Cury 25 < If
  173. Curx Bleft - 4 / 32 min  1 Max cdrmode ! 
  174.  cdrmode @ 280 20 N'text2
  175. rport 240 20 Move
  176. Rport 2 setapen
  177. Rport CdrMode @ 1- 4* Xplan + 4 Text drop 
  178. Rport CColor @ Setapen \ goldarn ntext busted it
  179. Mup Button !
  180. then
  181. ;
  182. : compcm
  183. CdrMode @  4* bleft + Locals| XX |
  184. Rport 2 SetDrMd
  185. Rport xx 18 xx 3+ 23 RectFill
  186. Rport 1 setdrmd
  187. ;
  188. \ Trace on
  189. : LoopixShow
  190. Loopix @ l'bot + 5- 
  191. Locals| Me  |
  192. Rport 2 setDrMd
  193. rport l'left me move
  194. rport l'right me draw
  195. rport 1 setdrmd
  196. Loopix @ negate 280 40 N'Text2
  197. ;
  198. : GetLoopix
  199. curx l'left l'right range swap drop  if
  200. \ oh boy: in range!
  201. LoopixShow
  202. cury 5+ l'bot -  -31 max -1 min loopix !
  203. loopixshow
  204. then
  205. ;
  206. : getccolor?
  207. Cury 17 < If
  208. curx bleft - 4 / 31 min 1 max  ccolor !
  209. Rport CColor @ SetAPen
  210. Rport 140 12  160 23 RectFill
  211. Mup Button !
  212. Else
  213. CompCM
  214. GetCmode
  215. CompCm
  216. then
  217. \ how bout somothose funny parms?
  218. Cury bleft 30 - > If
  219. GetLoopix
  220. then
  221. ;
  222. \
  223. : EventPoll ( -- t/f ) \ true if any button hit
  224.    GetEvent
  225.    Case
  226. MouseButtons Of ThisEvent  +eCode W@ Button ! false
  227. Mode @ 1 = if
  228. Button @ Mdown = If getccolor?  else BackX Off Backy off then 
  229. then
  230.  Endof
  231. RawKey OF
  232.    ThisEvent +ecode W@ 
  233.     Case
  234. [ hex ]
  235.  22 of 1 Mode ! true endof \ D fer doodle
  236.  21 of 2 Mode ! true endof \ s fer Synth
  237.  19 of 3 Mode ! true endof \ p fer Play
  238.  14 of 4 Mode ! true endof \ t fer Top
  239.  10 of 5 Mode ! true endof \ Q fer Quit
  240.  11 of 6 Mode ! true endof \ W for Write
  241.  35 of 7 Mode ! true endof \ B for BPF
  242.  13 of 8 Mode ! true endof \ R for Reset
  243.  17 of 9 Mode ! true endof \ I for input screen
  244.  18 of 0A Mode ! true endof \ O for output screen
  245. [ decimal ] false
  246.     endcase
  247.     EndOf
  248. fCLOSEWINDOW Of
  249. \ ." CW "
  250.   5 mode ! true Endof
  251. \ elsssee....
  252.  false 
  253.    Endcase
  254. ;
  255. Create FileName$ 41 allot 
  256. Variable F'
  257. \
  258.  
  259. : GNum ( -- # ) \ read a # from keyboard
  260. Begin 10 ask.Number until
  261. ;
  262. : GetFileName 
  263. cr ." Filename?"
  264. FileName$ 40 expect 
  265. 0 FileName$ Cnt @ 1- + C!
  266. cr
  267. ;
  268. Create DrwConname
  269. 0," CON:10/10/300/150/D R W Input screen"
  270. variable rf'sz
  271. : GetBpfFileName 
  272. CurrentScreen @ ScreentoBack
  273. DRWCOnName ZapDosCon
  274. begin
  275. cr ." Filename of a sound file?"
  276. FileName$ 40 expect 
  277. 0 FileName$ Cnt @ 1- + C!
  278. FileName$ Open ?Dup 
  279. 0= if ." Can't find that file??" cr false
  280. else fid ! true then
  281. until
  282. \ other bpf stuff
  283. ." Sample start:" GNum B'Zs !
  284. B'Zs @ B'Zd @ 8 scale +  F'sz @ Min  B'Ze !
  285. ." K           :" Gnum K !
  286. 1 k @ Scale  N'p !
  287. fid @ filesize?  65536 Min RF'sz !
  288. \ Read the sucker into the sound array...
  289. F' @@ RF'Sz @ 0 Fid @ Read.Virtual
  290. Fid @ Close
  291. UnzapDosCon
  292. CurrentScreen @ ScreenToFront
  293. ;
  294.  
  295. \
  296. Decimal
  297. : BigBegin
  298. Shutup off
  299. Mode Off
  300. 2 ccolor !
  301. 3  CdrMode !
  302. -1 loopIx !
  303. -10 HowLoud !
  304. 1 flock !
  305. \ defaults for sampling
  306. 128 B'Zd ! 
  307. B'Zd @ 8 scale B'ze !
  308. 512 B'FD !
  309. 4096 B'Fs !
  310. BackX Off
  311. BackY Off
  312. B'Fs @ B'Fd @ 7 scale + B'Fe !
  313. \ Size up the video pieces  256(x) by 128 (y)
  314. 65 1024 * F'SZ !
  315.  
  316. F'Sz @ Chip Get.Memory F' !
  317. F' @ 0= IF False else True Then
  318. ;
  319. decimal
  320. : GetDrwParms
  321. \ flip back the screen a spell...
  322. currentscreen @ Screentoback
  323. DRWConName  ZapDosCOn
  324. ."    Reset sample parms Mode... " cr
  325. ." Sample Delta(" B'Zd ? ." ):"   GNum 256 min 1 max B'Zd ! 
  326. B'Zd @ 8 scale   65536 Min  B'Ze !
  327. ."      Sample end is:" B'Ze ? cr
  328. ." Freq   Delta(" B'Fd ? ." ):"   Gnum b'Fd !
  329. ."        Delta in Hz:" b'fd @ 3523 * -15 scale . cr
  330. ." Freq   Start(" B'Fs ? ." ):" Gnum  B'Fs !
  331. ."        Start in Hz:"  B'Fs @ 3523 * -15 scale . cr
  332. B'Fs @ B'Fd @ 7 scale + B'Fe !
  333. ."    Freq End in Hz:" B'Fe @ 3523 * -15 scale . cr
  334. 50 delay 
  335. 3 mode !
  336. UnzapDosCon
  337. currentscreen @ screentofront
  338. \ tell 'e the current freq etc.
  339. B'Zd @ 20 190  n'text
  340. B'Fs @ 120 190 n'text
  341. B'FE @ 220 190 N'Text 
  342. ;
  343.  
  344. \
  345. create b> -4 allot  \ Code B>
  346. Hex
  347. 2017 w, \ d0 get,
  348. 4880 w, \ d0 byte ext,
  349. 48c0 w, \ d0 word ext,
  350. 2E80 w, \ d0 put,
  351. 361A W, 4eF6 W, 3018 W, \ next
  352. Decimal
  353. \ End-Code
  354. \
  355. { a forth version...
  356. Hex
  357. : B> ( byte extend )
  358.  FF and dup 7F > if FFFFFF00 + then
  359. ;
  360. Decimal
  361. }
  362. \
  363. \
  364. : okwindow?  ( -- )  currentwindow @ 0= if
  365.     currentscreen @ CloseScreen
  366.     cr ." unable to open window! " abort then ;
  367. \
  368.  : rgb \ r g b --n |     packs color values
  369.      swap 16* or swap 8 scale or ;  \ 16* is quick *, scale shifts bits
  370.  
  371. ?align
  372.  create ctable  \   table to store new colors
  373.  15 15 15 rgb w,  08 08 08 rgb w,  00 08 08 rgb w,  01 07 08 rgb w,
  374.  02 06 08 rgb w,  03 05 08 rgb w,  04 04 07 rgb w,  05 03 06 rgb w,
  375.  06 02 05 rgb w,  07 01 04 rgb w,  08 00 04 rgb w,  09 00 04 rgb w,
  376.  10 00 04 rgb w,  11 00 04 rgb w,  12 00 04 rgb w,  13 00 04 rgb w,
  377.  14 00 04 rgb w,  15 00 04 rgb w,  15 01 04 rgb w,  15 02 04 rgb w,
  378.  15 03 04 rgb w,  15 04 04 rgb w,  15 05 04 rgb w,  15 06 04 rgb w,
  379.  15 07 04 rgb w,  15 08 04 rgb w,  15 09 04 rgb w,  15 10 04 rgb w,
  380.  15 11 04 rgb w,  15 12 04 rgb w,  15 13 04 rgb w,  15 14 04 rgb w,
  381.  15 15 04 rgb w,
  382.  
  383.  : loadcolors  \  --   load new colors
  384.     currentwindow @ ViewPortAddress   \  get ViewPort address
  385.     ctable                            \   color table address
  386.     32                                \  number of colors to load
  387.     LoadRGB4 ;                        \ call to load color values
  388.  
  389. : PutUpScreen
  390. DrwSTitle DrwNs +nsDefaultTitle !
  391. DrwWTitle DrwNw +nwTitle !
  392.    DrwNs
  393.  OpenScreen
  394.  verifyscreen    \ open a 4 bit plane screen
  395.    CurrentScreen @ DrwNw  +nwScreen  ! \ store screen ptr in window
  396.    DrwNw OpenWindow okwindow?     \ open demo window
  397. \ set the colors
  398.  loadcolors
  399. ;
  400. \
  401. : ShutUpScreen
  402. Currentscreen @ ScreenTOBack
  403. CurrentWindow @ CloseWindow
  404. CurrentScreen @ CloseScreen
  405. \ Release GM space
  406. f' @ ?DUP IF  To.Heap then
  407. ;
  408. \
  409. Variable lennn
  410.  
  411. Decimal
  412. : N'Show ( Addr -- )
  413. Locals| Add |
  414. \ another display of the waveform
  415. \  Rport 1 setapen
  416. \  Rport bleft 180 17 -  Bright  180 17 + Rectfill
  417.  256 0 DO
  418. rport 1 setapen
  419.  rport bleft I+ 163 move
  420.  rport bleft I+ 197 draw
  421.  Rport 31 SetAPen
  422. Rport  Bleft I+ 
  423. Add I+ C@ B>  -3 scale 180 +   WritePixel \ draw
  424. Loop
  425. ;
  426. Hex
  427. : EndGame \ now quasi stereo
  428. 0 Locals| U- | 
  429. Button @ Mdown = IF
  430. Played? On
  431. F' @@  dup DFF0A0 ! DFF0B0 !
  432. B'Ze @ 2/ dup DFF0A4 W! DFF0B4 W!
  433.  CurrentWindow @ +wMouseY W@ 2* 7c + 7c Max  dup DFF0A6 W!  DFF0B6 W! \ period
  434. \ CurrentWindow @ +wMousex W@  7c + 7c Max   DFF0B6 W!  \ period
  435. 3f Dff0A8 W! \ loudness
  436. 3f Dff0B8 W! \ loudness
  437. \ fire away..
  438. 8203 Dff096 W! \ start DMA
  439. else
  440. \
  441. Played? @ If
  442.    3 Dff096 W! \ Stop DMA
  443. Then
  444. Played? Off
  445. then
  446.  \
  447. ;
  448. Decimal
  449. : PlayMode
  450. CurrentWindow @ PlayMode$ -1 SetWindowTitles
  451. Shutup off
  452. Begin
  453. \ display "mouse std freq in Hz (freq of a b'fd sized record)"
  454.  CurrentWindow @ +wMouseY W@ 2* 124 + 124 Max  170 20 n'text
  455. Endgame
  456. eventPoll Mode @ 3 = not and
  457. until
  458. ;
  459. : TopMode
  460. 0 0 locals| Z  aa |
  461. CurrentWindow @ TopMode$ -1 SetWindowTitles
  462. 32 1 do
  463. Rport I SetAPen
  464. Rport BLeft I 4* +  12  BLeft I 1+ 4* + 1- 16 RectFill
  465. loop
  466. \ move the comb over
  467.  33 1 do
  468. rport 1 setapen
  469. Rport Bleft I  4* +   17  bleft I 1+ 4* + 1- 23 Rectfill
  470. rport 12 setapen
  471. Rport Bleft I  4* + 1+  17  bleft I 1+ 4* + 2- 23 Rectfill
  472. loop
  473. CompCm
  474. \ draw the box
  475. Rport 1 setApen
  476. Rport BLeft Bdown  Bright    Bdown Bhei + 1+   RectFill
  477. \ tell 'e the current freq etc.
  478. B'Zd @ 20 190  n'text
  479. B'Fs @ 120 190 n'text
  480. B'FE @ 220 190 N'Text 
  481. \ draw the loopix box
  482. rport l'left l'top l'right l'bot Rectfill
  483. rport 16 setapen
  484. rport l'left l'top move
  485. rport l'left l'bot draw
  486. rport l'right l'bot draw
  487. rport l'right l'top draw
  488. rport l'left  l'top draw
  489. rport 1 setapen
  490. LoopixShow
  491. Loopix @ negate 280 40 N'Text2
  492. rport ccolor @ setapen
  493. 1 mode !
  494. ;
  495. Decimal
  496.  
  497. : writeMode \ actually attempts to write 8SVX IFF file
  498. CurrentWindow @ WriteMode$ -1 SetWindowTitles
  499. CurrentScreen @ ScreentoBack
  500.  drwconname ZApdoscon
  501. Getfilename
  502. ." Number Of Octaves??"  Gnum 1 max 7 min f'Oct !
  503. ." Favorite Period (124-999)?"  Gnum 124 max 999 min 3579546 swap / 8Hertz !
  504.  
  505.  f' @@ B'Ze @ F'Oct @ Filename$  8svxMake 
  506. if cr ." Successfully created!"  else
  507.    cr ." Sorry, couldn't write it!" then 30 delay
  508.  unzapdoscon
  509. CurrentScreen @ ScreenToFront
  510. 3 mode !
  511. ;
  512.  
  513. \
  514. Variable zpot
  515. Variable Pimp
  516. Variable BLIP ascii Blip blip !
  517. \
  518. : full@
  519. pimp  4  zpot @ Fid @ read.virtual
  520. 4 Zpot +! pimp @
  521. ;
  522. : full!
  523.  4  zpot @ Fid @ write.virtual
  524. 4 zpot +!
  525. ;
  526. \ structure for file: ID, time width,
  527. \ frq lo, frq width, (samples)
  528. \
  529. : InputMode \ read screen file..
  530. CurrentWindow @ InputMode$ -1 SetWindowTitles
  531. CurrentScreen @ ScreentoBack
  532. drwconname ZapDosCon
  533. ." Input a Screen File " cr
  534. begin
  535. Getfilename
  536. Filename$ open dup fid !
  537. 0= if ." Can't find it! " cr then
  538. fid @ 0= not until
  539. UnzapDosCOn
  540. CurrentScreen @ ScreenToFront
  541. zpot off
  542. \ get ye parms
  543.  full@ blip @ = if
  544. full@  B'zd !
  545. B'Zd @ 8 scale   65536 Min  B'Ze !
  546. full@  b'fs !
  547. full@  b'fd !
  548. B'Fs @ B'Fd @ 7 scale + B'Fe !
  549. \ now read em
  550. f' @@ f'sz @ zpot @ fid @ read.virtual
  551. fid @ close
  552. \ now show it
  553. 256 0 do
  554. I 170 20 n'text
  555.  128  0 do
  556. rport  j 7 scale i+ f' @@ + C@ setapen
  557. rport bleft j + bdown i+ writepixel
  558. loop
  559. loop 
  560. else
  561. ." That wasn't a good screen file " cr
  562. fid @ close
  563. then
  564. 3 mode !
  565. \ tell me the current freq etc.
  566. B'Zd @ 20 190  n'text
  567. B'Fs @ 120 190 n'text
  568. B'FE @ 220 190 N'Text 
  569. ;
  570. : OutputMode \ write screenfile
  571. CurrentWindow @ OutputMode$ -1 SetWindowTitles
  572. CurrentScreen @ ScreentoBack
  573. drwconname ZapDosCon
  574. ." Output screen file name:" Cr
  575. Getfilename
  576. UnzapDoscon
  577. CurrentScreen @ ScreenToFront
  578. \ open it for write..
  579. filename$ new.file fid !
  580. fid @ 0= not if
  581. zpot off
  582. blip full!
  583. b'zd Full!
  584. b'fs full!
  585. b'fd full! 
  586. \ now read off those pixels into f'
  587. 256 0 do
  588. I 170 20 n'text
  589.  128 0 do 
  590. rport Bleft j + bdown i+ readpixel
  591. j 7 scale i+ f' @@ + C!
  592. loop
  593. loop 
  594. \ now write f'
  595. f' @@ f'sz @ zpot @ fid @ write.virtual
  596. fid @ close
  597. else
  598. ioerror? @
  599. ." couldn't open it: code:" . cr
  600. then
  601. 3 mode !
  602. ;
  603. \
  604. VAriable Tharm
  605. Variable Ty
  606. Variable Lx
  607. Variable Px'
  608. Variable Py'
  609. Variable Rx
  610. Variable Lcol
  611. Variable Rcol
  612. \
  613. : doodleMode
  614. 0 Locals| Temp  |
  615. CurrentWindow @ DoodleMode$ -1 SetWindowTitles
  616. begin
  617. Curx Cx' !
  618. CurY' FLock @ w/ FLock @ W* CY' !
  619. CY' @ Bdown  bdown' range  swap drop 
  620. Cx' @ Bleft bright Range swap drop and IF
  621. bdown' Cy' @ - B'fd @ * b'Fs @ + 3523 * -15 scale 170 20 n'text 
  622. cx' @ clipx Cx' !
  623. Button @ MDown = If
  624. rport ccolor @ setapen
  625. Cdrmode @
  626. Case
  627. 1 of \ mode 1 = just draw, fella
  628. Rport CX' @ clipx CY' @ writePixel
  629. endof
  630. 2 of \ draw via line, bub
  631. Cx' @ BAckX @ > IF
  632. cx' @ 1+ BackX !
  633. rport vx @  Clipx vy @ move
  634. Rport CX' @ clipx   CY' @  clipy DRaw
  635. cx' @ vx !
  636. cy' @ vy !
  637. then
  638. endof
  639. 3 of \ ramp draw- add
  640. CX' @ BackX @ > If
  641. cx' @ 1+ BackX !
  642. CColor @ to Temp
  643. 0 I' !
  644. 2 Temp  do
  645. Cx' @ I' @ -  Clipx Lx !
  646. Rport Lx @ Cy' @ readPixel i+ 31 min
  647. Rport swap SetApen
  648. Rport Lx @ Cy' @ WritePixel
  649. Cx' @ I' @ +  Clipx dup lx @ = if drop else
  650. Lx !
  651. Rport Lx @ Cy' @ readPixel i+ 31 min
  652. Rport swap SetApen
  653. Rport Lx @ Cy' @ WritePixel
  654. then
  655. 1 i' +!
  656.  LoopIx @  +loop
  657. then
  658. endof
  659. 4 of 
  660. Rport CX' @ clipx  CY' @ clipy  CX' @ 1+  clipx CY' @ 5+ clipy  RectFill
  661. endof
  662. 5 of 
  663. Rport CX' @ 3- clipx  CY' @ 3- clipy CX' @ 3+ clipx CY' @ 3+ clipy  RectFill
  664. endof
  665. 6 of \ HArmonix mode
  666. Cx' @ Backx @ > IF
  667. Backx @ 0= if cx' @ 1- backx ! cy' @ backy ! then 
  668. CX' @  BackX @ DO
  669. I PX' !
  670. \ interpolate Py from px
  671. I BackX @ - Cy' @ Backy @ - * Cx' @ BAckx @ - / Backy @ + Py' !
  672. \
  673. Bdown'  Py' @ -  B'fd @ *  B'fs @ + 8/ to temp \ CUrrent phase to temp
  674. Temp Tharm !
  675. BDown' Tharm @ B'Fs @ - B'Fd @ / - TY !
  676. \ cr ." harm: " temp . ." :"
  677. begin
  678. ty @ bdown' < If
  679.  0 i' !
  680.  2 ccolor @ do
  681.   Px' @ i' @ - clipx Lx !
  682.   Rport Lx @  Ty @ readPixel i+ 31 min 
  683.   rport swap setapen
  684.   Rport Lx @  Ty @ WritePixel \ write this one..
  685.   Px' @ i' @ + clipx dup lx @ = if drop else  Lx !
  686.    Rport Lx @ Ty @ ReadPixel  i+ 31 min
  687.   rport swap SetAPen
  688.   Rport Lx @ Ty @ WritePixel \ write this one..
  689.   then 
  690.   1 i' +!
  691.  Loopix @ +loop
  692. then
  693. Temp Tharm +!
  694. \ convert tharm to Ty
  695. BDown' Tharm @ B'Fs @ - B'Fd @ / - TY !
  696. \ ." (" Tharm @ . Ty @ . ." )"
  697. Ty @ Bdown <
  698. until
  699. loop
  700.  
  701. Cx' @  BackX !
  702. Cy' @  BackY !
  703.  
  704. then
  705. endof
  706. 7 of \ average mode
  707. 0 to Temp
  708.  3 -2 do
  709.  Rport Cx' @ I + clipx  Cy' @  ReadPixel temp + to Temp  
  710. loop
  711. rport temp 5 /  1 max setapen
  712. Rport Cx' @ 2- clipx  Cy' @  Cx' @ 2+ clipx  cy' @  RectFill
  713. endof
  714. 8 of \ smear forward
  715.  Rport Cx' @ Cy' @ ReadPixel to Temp
  716. 0 I' !
  717. 2 Temp  do
  718. Rport I SetApen
  719. Rport Cx' @ I' @ - dup bleft < if drop bleft then  Cy' @ WritePixel
  720. 1 i' +!
  721. LoopIx @ +loop
  722. rport ccolor @ Setapen 
  723. endof
  724. 9 of \ smear backward
  725.  Rport Cx' @ Cy' @ ReadPixel to Temp
  726. 0 I' !
  727. 2 Temp  do
  728. Rport I SetApen
  729. Rport Cx' @ I' @ + dup bright > if drop bright then  Cy' @ WritePixel
  730. 1 i' +!
  731. LoopIx @ +loop
  732. rport ccolor @ Setapen 
  733. endof
  734. 10 of \ FLOOD ( all with the same as x-y become Apen )
  735. rport cx' @ cy' @ readpixel to Temp
  736. \ search left..
  737. Cx' @ Dup Lx ! Rx !
  738. begin
  739. -1 Lx +!
  740. Rport Lx @ Cy' @ ReadPixel Temp = not 
  741. LX @ Bleft <  or
  742. until
  743. 1 Lx +!
  744. \ search right ..
  745. begin
  746. 1 rx +!
  747. Rport rx @ Cy' @ ReadPixel  Temp = not
  748. rX @ Bright >  or
  749. until
  750. -1 Rx +!
  751. \ redraw it
  752. Rport Lx @  cy' @ move
  753. Rport Rx @  Cy' @ Draw
  754. endof
  755. 11 of \ ramp this line up
  756. rport cx' @ cy' @ readpixel to Temp
  757. \ search left..
  758. Cx' @ Dup Lx ! Rx !
  759. begin
  760. -1 Lx +!
  761. Rport Lx @ Cy' @ ReadPixel dup Lcol ! Temp = not 
  762. LX @ Bleft < dup if 2 lcol ! then or
  763. Lcol @ 2 < or
  764. until
  765.  
  766. \ search right ..
  767. begin
  768. 1 rx +!
  769. Rport rx @ Cy' @ ReadPixel Dup Rcol ! Temp = not
  770. rX @ Bright > dup if 2 Rcol ! then or
  771. rcol @ 2 < or
  772. until
  773. \ ." Lx:" Lx ? ." Rx:" Rx ? ." Lcol:" Lcol ? ." Rcol:" rcol ? cr
  774.  
  775. \ redraw .left.
  776. cx' @ 1+ Lx @ do
  777.  rport Lcol @ 4* temp + 5 w/ dup Lcol ! Setapen
  778. Rport I Cy' @ WritePixel
  779. 1 +loop
  780. \ redraw right
  781. cx' @  rx @ 1+ do
  782.  rport rcol @ 4* temp + 5 / dup rcol ! Setapen
  783. Rport I Cy' @ WritePixel
  784. -1 +loop
  785.  
  786. Rport ccolor @ Setapen \ whew
  787.  endof
  788. 12 of \ decrement
  789. 4 -3 do
  790.  Rport Cx' @ I+ clipx Cy' @  ReadPixel 
  791. Loopix @ + 1 max rport swap setapen
  792.  Rport Cx' @ I+ clipx Cy' @  writePixel 
  793. loop
  794. rport CColor @ setapen
  795. endof
  796. 13 of \ increment
  797. 4 -3 do
  798.  Rport Cx' @ I+ clipx Cy' @  ReadPixel 
  799. Loopix @ - 31 Min rport swap setapen
  800.  Rport Cx' @ I+ clipx Cy' @  writePixel 
  801. loop
  802. rport CColor @ setapen
  803. endof
  804. 14 of  \ edible harmonie
  805.  
  806. cx' @ BackX @ >
  807. cx' @ BackX @ 2+ < and Backx @ 0= or
  808.  IF ( only writes contiguous )
  809. cx' @   BackX !
  810. Bdown'  Cy' @ -  B'fd @ *  B'fs @ + 8/ to temp \ CUrrent phase# to temp
  811. Temp Tharm !
  812. \ get the first corresponding y...
  813. BDown' Tharm @ B'Fs @ - B'Fd @ / - clipY TY !
  814. bdown'' lx !
  815. \ cr ." harm: " temp . ." :"
  816. rport 1 setapen
  817. begin
  818. ty @ i < If \ skip real low ones...
  819.   rport cx' @ lx @ Move
  820.   rport cx' @ ty @ 1+ Draw
  821.   Ty @ 1- lx !
  822. then
  823. \ next harmonic
  824. Temp Tharm +!
  825. \ convert tharm to Ty
  826. BDown' Tharm @ B'Fs @ - B'Fd @ / -  TY !
  827. \ ." (" Tharm @ . Ty @ . ." )"
  828. ty @ dup clipy ty ! bdown <
  829. until
  830. \ ." >"
  831. \ get the top..
  832. rport cx' @ lx @ move
  833. rport cx' @ bdown Draw
  834. \ ." <" cr
  835.  then  
  836. endof
  837. 15 of  \ eliminat low freqs
  838. 256 0 do
  839. I 170 20 n'text
  840.  128 0 do 
  841. rport Bleft j + bdown i+ readpixel
  842. 2 ccolor @ range  if \ wipe out if from 2 to ccolor
  843.   drop Rport 1 setapen Rport bleft j + Bdown i+ Writepixel
  844.   else drop 
  845.   then 
  846. loop
  847. loop 
  848. endof
  849. 16 of \ decrement ( not 0 )
  850. 4 -3 do
  851. 4 -3 do
  852.  Rport Cx' @ I+ clipx Cy' @ J + clipy  ReadPixel 
  853. dup 2 > if
  854. Loopix @ + 2 max rport swap setapen
  855.  Rport Cx' @ I+ clipx Cy' @ j + Clipy writePixel 
  856. else
  857. drop
  858. then
  859. loop
  860. loop
  861. rport CColor @ setapen
  862. endof
  863. 17 of \ increment ( not 0 )
  864. 4 -3 do
  865. 4 -3 do
  866.  Rport Cx' @ I+ clipx Cy' @ j + ClipY ReadPixel 
  867. dup 1 > if
  868. Loopix @ - 31 Min rport swap setapen
  869.  Rport Cx' @ I+ clipx Cy' @ J + Clipy writePixel 
  870. else drop
  871. then
  872. loop
  873. loop
  874. rport CColor @ setapen
  875. endof
  876.  
  877. 18 of \ set copy baseA...
  878. Curx'  CBAseXA !
  879. cury'  CbaseYA !
  880. endof
  881. 19 of \ set copy baseb...
  882. Curx'  CBAseXB !
  883. cury'  CbaseYB !
  884. endof
  885.  
  886. 20 of \ actually copy
  887. 3 -2 do
  888.  3 -2 do
  889. rport  rport cx' @ i+ clipx  cy' @ j + clipy readpixel setapen
  890. \ now stomp it
  891. Rport
  892.  cx' @ i+ clipx  cbaseXa @ - CbaseXB @ + CLipx
  893.  cy' @ j + clipy  cbaseYa @ - CbaseYB @ + CLipY WritePixel
  894. loop
  895. loop
  896. endof
  897.  
  898. 22 of \ Am modulate?
  899. Bdown'  Cy' @ -  B'fd @ *  B'fs @ +  locals| Temp | \ CUrrent phase# to temp
  900.  
  901. Bright bleft  do
  902. 14 temp  I bleft -  2048 */   Xqsin -8 scale 15 +  
  903. Rport swap setapen
  904. Rport I cy' @ WritePixel
  905. loop
  906. endof
  907.  
  908. 23 of \ copy whole lines..
  909. Bright Bleft DO
  910. Rport I Cbaseya @ ReadPixel Rport Swap Setapen
  911. Rport I Cy' @ WritePixel
  912. loop
  913. endof
  914. 24 of \ copy whole lines..
  915. BDown' Bdown DO
  916. Rport  CbaseXA @ I ReadPixel Rport Swap Setapen
  917. Rport  CX' @ I WritePixel
  918. loop
  919. endof
  920.  
  921. 25 of
  922. 1 flock !
  923. endof
  924. 26 of 2 flock !
  925. endof
  926. 27 of 4 flock !
  927. endof
  928. 28 of 8 flock !
  929. endof
  930. 29 of -10 HowLoud !
  931. endof
  932. 30 of -11 HowLoud !
  933. endof
  934. 31 of -12 HowLoud !
  935. endof
  936. endcase
  937. Else \ up button
  938. CdrMode @
  939. Case
  940. 2 of 
  941. cx' @ clipx vx !
  942. cy' @ clipy vy !
  943. endof
  944. endcase
  945. then
  946. then \ Cy' was too high? 
  947. eventpoll
  948.  until
  949. ;
  950.  
  951. {
  952. : DisplayIt ( x y Z -- ) \ hope that amt not> 128
  953. 4/ 1+ 31 min
  954. Rport swap  SetAPen
  955. rport rot rot WritePixel
  956. ;
  957. }
  958. \
  959. create @-8Scale -4 allot \ Code @-8scale
  960. hex
  961. 2057 w, \ a0 Get,
  962. 2010 w, \ A0 ()  d0 long Move,
  963. E080 W, \ D0 8 # Long Asr,
  964. 2E80 W, \ d0 Put,
  965. 361A w, 4EF6 W, 3018 W, \ next
  966. Decimal \ end-code
  967.  
  968.  
  969. \
  970. : ProcBPF
  971.  0 0 0 0  Locals| T#  S: f: W: |
  972.    B'Ze @ B'Zd @ - F' @@ + to F:
  973.    B'Zs @ F' @@ + to S:
  974. \ Do these little sub-loops, but ramp time before freq..
  975. 1 Wn'x !
  976. Bdown'' Dl'Y !
  977. N'P @ to W: \ Skip my nonsense ...
  978. B'Fe @ B'Fs @ DO
  979. I 3523 * -15 scale 170 20 n'text \ Standard freq display...  
  980. \  T'f @ I * 262143 and T'F ! \ scramble the phase somewhat..
  981.   t'f off
  982. \
  983.    Bleft Dl'X !
  984. \ set up wn'p =
  985. { skip more nonsense
  986.  262144 WN'X @ * i / dup N'P @ 2/ < If 1 wn'X +! then 
  987.  Dup to W:
  988.  250 25 N'text \ freq is below time
  989. }
  990. \ Now go over the sample block at this frequency, LPF them
  991. \
  992.    F: S: Do 
  993. \ freq = j..time = i
  994. \
  995. \ we gots to go slow here... cars is passing
  996.      T's Off
  997.      T'c Off
  998.      J I' !
  999. \ Insert Assembler here ...
  1000.  
  1001.       W: I+ I do 
  1002.       I c@ B>  \ Get yer sample...
  1003. \
  1004.      T'f @-8scale 2dup
  1005.      XQSin  t's +! 
  1006.      XQCOS  t'c +!
  1007.  
  1008.       I' @ T'F +! \ move the wave forward
  1009.      loop
  1010.  
  1011. {
  1012.  T'F @  I' @  W: I+ I
  1013. \ d0  d1    a1    a0
  1014. >CODE
  1015. A0 Pop,  a1 Pop,  D1 Pop,  D0 Pop,
  1016. begin,
  1017. A0 )+ D2 Byte Move, \ D2 = M(I)
  1018. D2 Byte Ext, \ Extend somewhat
  1019. \ save this fer a second - probly oughta save all the registers!
  1020. d2 push,
  1021. \
  1022. \ --- incr freq,
  1023. d0  d1 long add, \ T'F = T'F + I'
  1024. a0 a1 long cmpa,  
  1025. gt until,
  1026.  
  1027. >Forth 
  1028. }
  1029. \
  1030.  
  1031.     Rport  T's @ W: W/ -6 scale dup W*
  1032.      T'c @ W: W/ -6 scale dup W*
  1033.      + sqrt 4/ 1+ 31 min SetAPen
  1034.     Rport   Dl'X @ Dl'Y @   WritePixel { DisplayIt }
  1035. \
  1036.      1 Dl'X +!
  1037.    B'Zd @ +loop 
  1038.  
  1039.    -1 Dl'Y +!
  1040. \
  1041. \ BPFDone?
  1042.    GetEvent
  1043.   fCloseWindow = IF Leave then
  1044. B'Fd @  +loop \ next frequency
  1045. 3 Mode !
  1046. ;
  1047.  
  1048.  
  1049.  
  1050. : BPFMode
  1051. CurrentWindow @ BPFMode$ -1 SetWindowTitles
  1052. getbpfFilename
  1053. \ draw the box
  1054. Rport 2 setApen
  1055. Rport BLeft  Bdown 1+  Bright 2-    Bdown  Bhei +   RectFill
  1056. \ draw the loopix box
  1057. ProcBpf
  1058. ;
  1059. Hex
  1060. Create ColtoByte \ somewhat stretched
  1061. \ 0     1     2     3     4     5     6     7    
  1062. 00 c, 00 c, 04 c, 08 c, 0c c, 10 c, 14 c, 18 c, 
  1063. \ 8     9    10    11    12    13    14    15    
  1064. 1c c, 20 c, 24 c, 28 c, 2c c, 30 c, 34 c, 38 c, 
  1065. \ 16    17    18    19   20    21    22    23    
  1066. 3c c, 40 c, 44 c, 48 c, 4c c, 50 c, 55 c, 59 c, 
  1067. \ 24   25    26    27    28    29    30    31    
  1068. 5e c, 63 c, 68 c, 6d c, 72 c, 76 c, 7c c, 7f c, 
  1069. Decimal
  1070. \
  1071. : SynthMode 
  1072. CurrentWindow @ SynthMode$ -1 SetWindowTitles
  1073. 0 0 0 0 0 0 0 Locals| Value Ovalue Sx Sy F-> IFreq JFaze |
  1074. Bleft to SX
  1075. F' @@ F'Sz @ Erase
  1076. F' @@ to F->
  1077. 0 Phase Bhei 4* erase \ Phases of each of the sins
  1078.  rport 2 SetDrMd
  1079.  Rport 15 setapen
  1080. \
  1081. Bright Bleft DO \ for each column (time slice of b'zd samples)
  1082. Rport i 1+ Bdown Move
  1083. Rport I 1+ Bdown' Draw
  1084. 0 Accum B'Zd @ 4* Erase \ zero out the special hi-res memory
  1085. \
  1086. B'fs @ to Ifreq
  1087.  Bdown  Bdown'' DO \ for each frequency ...
  1088.  Rport J I ReadPixel ColToByte + C@
  1089. ?dup If to Value
  1090. \  zero out the Accumulator Array...
  1091. \ sum up a sinwave (properly phased) at this amplitude
  1092. i Phase to JFaze
  1093. B'Zd @ 0 DO
  1094. Value  JFaze @ -8 scale
  1095. XQsin I Accum +!  
  1096. Ifreq JFaze +!
  1097. Loop
  1098. then
  1099. B'Fd @ Ifreq + to Ifreq
  1100. -1 +loop
  1101. \ now transfer the fourbyte values to the f-> array
  1102. \ ." --- Accum --- " cr
  1103. B'Zd @ 0 do
  1104. I Accum @ 
  1105.      \ so i made it -5! I'm clipping, aint I?
  1106. \ -7 scale ( number of frequencies ) -5 scale 
  1107. HowLoud @ scale
  1108. dup 127 > if drop 127 then
  1109.  dup -127 < if drop -127 then  F-> C! 
  1110. F-> 1+ to F->
  1111. loop
  1112. \ cr
  1113. Rport i 1+ Bdown Move
  1114. Rport I 1+ Bdown' Draw
  1115. eventpoll if Mode @ 2 = not if leave then  then  \ stop me before I kill again..
  1116. Loop
  1117. 3 Mode !
  1118.  rport 1 setdrmd
  1119. ;
  1120. \ This is the  Main switching loop, exiting in each case
  1121. \ by hitting closegadget..
  1122. \
  1123. \
  1124. : ProcDrw
  1125. Mode Off
  1126. Begin
  1127. \ split up into subgroups they will stay there till their mode changes?
  1128. mode @ case
  1129. 0 of TopMode endof
  1130. 1 of doodleMode endof
  1131. 2 of SynthMode endof
  1132. 3 of PlayMode endof
  1133. 4 of TopMode endof
  1134. 6 of writemode endof
  1135. 7 of BPFMode   endof
  1136. 8 of GetDrwParms endof
  1137. 9 of InputMode endof
  1138. 10 of outputmode endof
  1139. \ 5 = quit
  1140. endcase
  1141.  
  1142. Mode @ 5 =
  1143. until
  1144. \ drop  \ we'll figger out why later...(figgered out??)
  1145. ;
  1146. : Drw
  1147. Decimal 
  1148. BigBegin
  1149.  if
  1150. PutUpScreen
  1151. ProcDrw 
  1152. ShutUpScreen \ and free core...
  1153. else
  1154. ." I couldn't get core... " cr
  1155. then
  1156. ?turnkey if bye else Depth IF ." funny depth:" depth . then   abort then
  1157. ." Drw is in " cr
  1158.