home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / cshar_sn.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  31.6 KB  |  1,334 lines

  1. 18-Jun-88 14:44:25-MDT,33609;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:43:40 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22654; Sat, 18 Jun 88 14:43:38 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24788; Sat, 18 Jun 88 14:43:33 MDT
  8. Date: Sat, 18 Jun 88 14:43:33 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182043.AA24788@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: SoundDemo.c.shar
  13.  
  14. #! /bin/sh
  15. #
  16. # This is a shell archive.  Save this into a file, edit it
  17. # and delete all lines above this comment.  Then give this
  18. # file to sh by executing the command "sh file".  The files
  19. # will be extracted into the current directory owned by
  20. # you with default permissions.
  21. #
  22. # The files contained herein are:
  23. #
  24. #    1 SoundDemo.a
  25. #    8 SoundDemo.c
  26. #    7 SoundDemo.r
  27. #    2 Makefile
  28. #    1 Notes.r
  29. #    5 ErrDialog.c
  30. #    7 ErrDialog.r
  31. #
  32. echo 'Extracting SoundDemo.a'
  33. if test -f SoundDemo.a; then echo 'shar: will not overwrite SoundDemo.a'; else
  34. sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.a
  35. X* 
  36. X*    Sound Demonstration Program
  37. X*    written for the Boston MacWorld Expo
  38. X*    using the Macintosh Programmer's Workshop
  39. X*
  40. X*    (c) 1986 Fred A. Huxham
  41. X*
  42. X*------------------------------------------
  43. X*    This is some assembly language glue
  44. X*    to setup and restore register A5 around
  45. X*    the call to our Vertical Retrace Task
  46. X*------------------------------------------
  47. X*
  48. X    INCLUDE 'SysEqu.a'
  49. X
  50. X    IMPORT    mySoundVBL
  51. X    
  52. XVBLGlue    PROC        EXPORT
  53. X        MOVEM.L        A4-A5/D4-D7,-(SP)        ;Save our Registers
  54. X        MOVE.L        CurrentA5,A5            ;Restoring A5
  55. X        JSR            mySoundVBL                ;Jump to our VBL Task
  56. X        MOVEM.L        (SP)+,A4-A5/D4-D7        ;Restore our Registers
  57. X        RTS                                    ;and return
  58. X        ENDPROC
  59. X        
  60. X        END
  61. ________This_Is_The_END________
  62. if test `wc -l < SoundDemo.a` -ne 26; then
  63.     echo 'shar: SoundDemo.a was damaged during transit'
  64.   echo '      (should have been 26 bytes)'
  65. fi
  66. fi        ; : end of overwriting check
  67. echo 'Extracting SoundDemo.c'
  68. if test -f SoundDemo.c; then echo 'shar: will not overwrite SoundDemo.c'; else
  69. sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.c
  70. X/* 
  71. X*    Sound Demonstration Program
  72. X*    written for the Boston MacWorld Expo
  73. X*    using the Macintosh Programmer's Workshop
  74. X*
  75. X*    (c) 1986 Fred A. Huxham
  76. X*
  77. X*--------------------------------------
  78. X*    This is the Main code
  79. X*--------------------------------------
  80. X*
  81. X*/
  82. X
  83. X
  84. X/* Macintosh Include Files */
  85. X#include <types.h>
  86. X#include <resources.h>
  87. X#include <quickdraw.h>
  88. X#include <fonts.h>
  89. X#include <events.h>
  90. X#include <windows.h>
  91. X#include <controls.h>
  92. X#include <dialogs.h>
  93. X#include <segload.h>
  94. X#include <files.h>
  95. X#include <retrace.h>
  96. X
  97. X/* Constant Values */
  98. X#define    TRUE        1
  99. X#define    FALSE        0
  100. X#define    NIL            0
  101. X#define MiddleC        25
  102. X#define BuffSize    63
  103. X
  104. X/*------------------------------------------------------------------*/
  105. X/*    Our own definitions of the SquareWave Sound Data Structures        */
  106. X/*------------------------------------------------------------------*/
  107. X#define swMode (-1)
  108. X
  109. Xtypedef struct Tone {
  110. X    short    count;
  111. X    short    amplitude;
  112. X    short    duration;
  113. X} Tone;
  114. X
  115. Xtypedef Tone Tones[BuffSize];
  116. X
  117. Xtypedef struct SWSynthRec {
  118. X    short    mode;
  119. X    Tones    triplets;
  120. X} SWSynthRec, *SWSynthPtr;
  121. X
  122. X/* Global Variables */
  123. Xshort        Sound, theNote, **theNotes;
  124. XVBLTask        SoundTask;
  125. XIOParam        *SndParamPtr;
  126. XSWSynthPtr    SqWvPtr;
  127. X
  128. X/* External Functions */
  129. Xvoid    VBLGlue();
  130. X
  131. X/*==================================================================*/
  132. X/*    Our restart procedure for InitDialogs                            */
  133. X/*==================================================================*/
  134. Xvoid    reStartProc()
  135. X{
  136. X   ExitToShell();
  137. X}
  138. X
  139. X
  140. X/*==================================================================*/
  141. X/*    Our Vertical Blanking Interrupt routine                            */
  142. X/*==================================================================*/
  143. Xvoid    mySoundVBL()
  144. X{
  145. X    SoundTask.vblCount = 1;        /* Reset our task counter */
  146. X
  147. X    if(Sound) {
  148. X        if(SndParamPtr->ioActCount >= 370) SndParamPtr->ioActCount = 0;
  149. X    }
  150. X}
  151. X
  152. X
  153. X/*==================================================================*/
  154. X/*    This routine sets up the Square Wave Synthesizer buffer            */
  155. X/*==================================================================*/
  156. Xvoid    SetUpSqWv()
  157. X{
  158. X    short    i;
  159. X
  160. X    (*SqWvPtr).mode = swMode;
  161. X    for(i = 0; i < BuffSize - 1; i++) {
  162. X        (*SqWvPtr).triplets[i].count = 2994;
  163. X        (*SqWvPtr).triplets[i].amplitude = 200;
  164. X        (*SqWvPtr).triplets[i].duration = 1;
  165. X    }
  166. X    (*SqWvPtr).triplets[BuffSize - 1].count = 0;
  167. X    (*SqWvPtr).triplets[BuffSize - 1].amplitude = 0;
  168. X    (*SqWvPtr).triplets[BuffSize - 1].duration = 0;
  169. X
  170. X    SndParamPtr->ioBuffer = (Ptr)SqWvPtr;
  171. X    SndParamPtr->ioReqCount = (sizeof(SWSynthRec));
  172. X}
  173. X
  174. X
  175. X/*==================================================================*/
  176. X/*    This routine starts the sound                                    */
  177. X/*==================================================================*/
  178. Xvoid    StartOurSound()
  179. X{
  180. X    short    result;
  181. X
  182. X    result = PBWrite(SndParamPtr, TRUE);
  183. X    if(result) OSError("PBWrite", result, "");
  184. X    Sound = TRUE;
  185. X}
  186. X
  187. X
  188. X/*==================================================================*/
  189. X/*    This routine stops the sound                                    */
  190. X/*==================================================================*/
  191. Xvoid    StopOurSound()
  192. X{
  193. X    short    result;
  194. X
  195. X    result = PBKillIO(SndParamPtr, TRUE);
  196. X    if(result) OSError("PBKillIO", result, "");
  197. X    Sound = FALSE;
  198. X}
  199. X
  200. X
  201. X/*==================================================================*/
  202. X/*    This routine changes the note to play                            */
  203. X/*==================================================================*/
  204. XChangeNote(whichNote)
  205. X    short    whichNote;
  206. X{
  207. X    short    newCount, i;
  208. X    
  209. X    newCount = (*theNotes)[whichNote - 1];
  210. X
  211. X    (*SqWvPtr).mode = swMode;
  212. X    for(i = 0; i < BuffSize - 1; i++) {
  213. X        (*SqWvPtr).triplets[i].count = newCount;
  214. X        (*SqWvPtr).triplets[i].amplitude = 200;
  215. X        (*SqWvPtr).triplets[i].duration = 1;
  216. X    }
  217. X    (*SqWvPtr).triplets[BuffSize - 1].count = 0;
  218. X    (*SqWvPtr).triplets[BuffSize - 1].amplitude = 0;
  219. X    (*SqWvPtr).triplets[BuffSize - 1].duration = 0;
  220. X}
  221. X
  222. X
  223. X/*==================================================================*/
  224. X/*    DoModeless takes a dialog item and a modeless dialog pointer    */
  225. X/*    as arguments, and responds to the user's actions appropriately    */
  226. X/*==================================================================*/
  227. Xvoid    DoModeless(whichItem,whichDialog)
  228. Xshort        whichItem;
  229. XDialogPtr    whichDialog;
  230. X{
  231. X    short            itemType;
  232. X    ControlHandle    item;
  233. X    Rect            box;
  234. X
  235. X    if(whichItem >= 1 && whichItem <= 60) {
  236. X        GetDItem(whichDialog, theNote, &itemType, &item, &box);
  237. X        SetCtlValue(item, FALSE);
  238. X        GetDItem(whichDialog, whichItem, &itemType, &item, &box);
  239. X        SetCtlValue(item, TRUE);
  240. X        theNote = whichItem;
  241. X        ChangeNote(whichItem);
  242. X    }
  243. X}
  244. X
  245. X
  246. X/*==================================================================*/
  247. X/*    DoWindowStuff takes care of mouse-downs in the drag and goAway    */
  248. X/*    regions of the modeless dialog                                    */
  249. X/*==================================================================*/
  250. Xvoid    DoWindowStuff(theEvent,whichWindow,windowcode)
  251. XEventRecord    *theEvent;
  252. XWindowPtr     whichWindow;
  253. Xshort        windowcode;
  254. X{
  255. X    short    result;
  256. X    Rect    screenRect;
  257. X    
  258. X    SetRect(&screenRect,10,30,502,332);
  259. X    switch(windowcode) {
  260. X        case inDrag:
  261. X            DragWindow(whichWindow,&theEvent->where,&screenRect);
  262. X            break;
  263. X        case inGoAway:
  264. X            if(TrackGoAway(whichWindow,&theEvent->where)) {
  265. X                result = VRemove(&SoundTask);
  266. X                if(result) OSError("VRemove", result, "");
  267. X                StopOurSound();
  268. X                ExitToShell();
  269. X            }
  270. X            break;
  271. X    }
  272. X}
  273. X
  274. X
  275. X/*==================================================================*/
  276. X/*    Here's our main event loop                                        */
  277. X/*==================================================================*/
  278. Xmain()
  279. X{
  280. X    extern struct qd qd;
  281. X
  282. X    EventRecord        theEvent;
  283. X    DialogPtr        modeless,whichDialog;
  284. X    short            whichItem,windowcode, itemType, i, result;
  285. X    WindowPtr        whichWindow;
  286. X    Rect            box;
  287. X    ControlHandle    item;
  288. X
  289. X    /* The Standard Initializations */
  290. X    InitGraf(&qd.thePort);
  291. X    InitFonts();
  292. X    FlushEvents(everyEvent, 0);
  293. X    InitWindows();
  294. X    InitDialogs(reStartProc);
  295. X    InitCursor();
  296. X
  297. X    /* Initialize our global variables */
  298. X    Sound = FALSE;
  299. X    theNote = MiddleC;
  300. X
  301. X    /* Allocate our Pointers */
  302. X    SqWvPtr = (SWSynthPtr)NewPtr(sizeof(SWSynthRec));
  303. X    SndParamPtr = (IOParam *)NewPtr(sizeof(IOParam));
  304. X    
  305. X    /* Load the Notes resource */
  306. X    theNotes = (short **)GetResource('Note', 8888);
  307. X    if(ResError()) OSError("GetResource", ResError(), "in main()");
  308. X    DetachResource(theNotes);
  309. X    if(ResError()) OSError("DetachResource", ResError(), "in main()");
  310. X
  311. X
  312. X    /* Set up the fields of the VBLTask */
  313. X    SoundTask.qType = 1;                    /* 1 = vType */
  314. X    SoundTask.vblAddr = VBLGlue;
  315. X    SoundTask.vblCount = 1;
  316. X    SoundTask.vblPhase = 0;
  317. X
  318. X    /* Set up the Sound Parameter block */
  319. X    SndParamPtr->ioCompletion = NIL;
  320. X    SndParamPtr->ioRefNum = (-4);
  321. X
  322. X    /* Fill in our SquareWave Pointer */
  323. X    SetUpSqWv();
  324. X
  325. X    /* put up the modeless dialog with middle C checked */
  326. X    modeless = GetNewDialog(1000,NIL,(WindowPtr)-1);
  327. X    GetDItem(modeless, theNote, &itemType, &item, &box);
  328. X    SetCtlValue(item, TRUE);
  329. X    ShowWindow(modeless);
  330. X
  331. X    /* Install the VBLTask and then start the sound */
  332. X    result = VInstall(&SoundTask);
  333. X    if(result) OSError("VInstall", result, "");
  334. X    StartOurSound();
  335. X
  336. X    /* And here's the loop */
  337. X    while (TRUE)   {
  338. X        if(GetNextEvent(everyEvent,&theEvent)) {
  339. X            if(IsDialogEvent(&theEvent)) {
  340. X                if(DialogSelect(&theEvent,&whichDialog,&whichItem)) {
  341. X                    DoModeless(whichItem,whichDialog);
  342. X                }
  343. X            }
  344. X            switch (theEvent.what) {
  345. X                case mouseDown:
  346. X                    windowcode = FindWindow(&theEvent.where,&whichWindow);
  347. X                    DoWindowStuff(&theEvent,whichWindow,windowcode);
  348. X                    break;
  349. X            }
  350. X        }
  351. X    }
  352. X}
  353. ________This_Is_The_END________
  354. if test `wc -l < SoundDemo.c` -ne 283; then
  355.     echo 'shar: SoundDemo.c was damaged during transit'
  356.   echo '      (should have been 283 bytes)'
  357. fi
  358. fi        ; : end of overwriting check
  359. echo 'Extracting SoundDemo.r'
  360. if test -f SoundDemo.r; then echo 'shar: will not overwrite SoundDemo.r'; else
  361. sed 's/^X//' << '________This_Is_The_END________' > SoundDemo.r
  362. X/* 
  363. X*    Sound Demonstration Program
  364. X*    written for the Boston MacWorld Expo
  365. X*    using the Macintosh Programmer's Workshop
  366. X*
  367. X*    (c) 1986 Fred A. Huxham
  368. X*
  369. X*--------------------------------------
  370. X*    This is the Rez Code
  371. X*--------------------------------------
  372. X*
  373. X*/
  374. X
  375. X
  376. Xresource 'DLOG' (1000) {
  377. X    {40, 10, 330, 376},
  378. X    documentProc,
  379. X    invisible,
  380. X    goAway,
  381. X    0x0,
  382. X    1000,
  383. X    "SquareWave SoundDemo"
  384. X};
  385. X
  386. Xresource 'DITL' (1000) {
  387. X     {    /* array DITLarray: 65 elements */
  388. X        /* [1] */
  389. X        {8, 8, 24, 40},
  390. X        CheckBox {
  391. X            enabled,
  392. X            "C"
  393. X        };
  394. X        /* [2] */
  395. X        {24, 8, 40, 48},
  396. X        CheckBox {
  397. X            enabled,
  398. X            "C#"
  399. X        };
  400. X        /* [3] */
  401. X        {40, 8, 56, 48},
  402. X        CheckBox {
  403. X            enabled,
  404. X            "D"
  405. X        };
  406. X        /* [4] */
  407. X        {56, 8, 72, 56},
  408. X        CheckBox {
  409. X            enabled,
  410. X            "D#"
  411. X        };
  412. X        /* [5] */
  413. X        {72, 8, 88, 40},
  414. X        CheckBox {
  415. X            enabled,
  416. X            "E"
  417. X        };
  418. X        /* [6] */
  419. X        {88, 8, 104, 40},
  420. X        CheckBox {
  421. X            enabled,
  422. X            "F"
  423. X        };
  424. X        /* [7] */
  425. X        {104, 8, 120, 56},
  426. X        CheckBox {
  427. X            enabled,
  428. X            "F#"
  429. X        };
  430. X        /* [8] */
  431. X        {120, 8, 136, 48},
  432. X        CheckBox {
  433. X            enabled,
  434. X            "G"
  435. X        };
  436. X        /* [9] */
  437. X        {136, 8, 152, 48},
  438. X        CheckBox {
  439. X            enabled,
  440. X            "G#"
  441. X        };
  442. X        /* [10] */
  443. X        {152, 8, 168, 40},
  444. X        CheckBox {
  445. X            enabled,
  446. X            "A"
  447. X        };
  448. X        /* [11] */
  449. X        {168, 8, 184, 48},
  450. X        CheckBox {
  451. X            enabled,
  452. X            "A#"
  453. X        };
  454. X        /* [12] */
  455. X        {184, 8, 200, 48},
  456. X        CheckBox {
  457. X            enabled,
  458. X            "B"
  459. X        };
  460. X        /* [13] */
  461. X        {8, 80, 24, 112},
  462. X        CheckBox {
  463. X            enabled,
  464. X            "C"
  465. X        };
  466. X        /* [14] */
  467. X        {24, 80, 40, 120},
  468. X        CheckBox {
  469. X            enabled,
  470. X            "C#"
  471. X        };
  472. X        /* [15] */
  473. X        {40, 80, 56, 120},
  474. X        CheckBox {
  475. X            enabled,
  476. X            "D"
  477. X        };
  478. X        /* [16] */
  479. X        {56, 80, 72, 128},
  480. X        CheckBox {
  481. X            enabled,
  482. X            "D#"
  483. X        };
  484. X        /* [17] */
  485. X        {72, 80, 88, 112},
  486. X        CheckBox {
  487. X            enabled,
  488. X            "E"
  489. X        };
  490. X        /* [18] */
  491. X        {88, 80, 104, 112},
  492. X        CheckBox {
  493. X            enabled,
  494. X            "F"
  495. X        };
  496. X        /* [19] */
  497. X        {104, 80, 120, 128},
  498. X        CheckBox {
  499. X            enabled,
  500. X            "F#"
  501. X        };
  502. X        /* [20] */
  503. X        {120, 80, 136, 120},
  504. X        CheckBox {
  505. X            enabled,
  506. X            "G"
  507. X        };
  508. X        /* [21] */
  509. X        {136, 80, 152, 120},
  510. X        CheckBox {
  511. X            enabled,
  512. X            "G#"
  513. X        };
  514. X        /* [22] */
  515. X        {152, 80, 168, 112},
  516. X        CheckBox {
  517. X            enabled,
  518. X            "A"
  519. X        };
  520. X        /* [23] */
  521. X        {168, 80, 184, 120},
  522. X        CheckBox {
  523. X            enabled,
  524. X            "A#"
  525. X        };
  526. X        /* [24] */
  527. X        {184, 80, 200, 120},
  528. X        CheckBox {
  529. X            enabled,
  530. X            "B"
  531. X        };
  532. X        /* [25] */
  533. X        {8, 152, 24, 184},
  534. X        CheckBox {
  535. X            enabled,
  536. X            "C"
  537. X        };
  538. X        /* [26] */
  539. X        {24, 152, 40, 192},
  540. X        CheckBox {
  541. X            enabled,
  542. X            "C#"
  543. X        };
  544. X        /* [27] */
  545. X        {40, 152, 56, 192},
  546. X        CheckBox {
  547. X            enabled,
  548. X            "D"
  549. X        };
  550. X        /* [28] */
  551. X        {56, 152, 72, 200},
  552. X        CheckBox {
  553. X            enabled,
  554. X            "D#"
  555. X        };
  556. X        /* [29] */
  557. X        {72, 152, 88, 184},
  558. X        CheckBox {
  559. X            enabled,
  560. X            "E"
  561. X        };
  562. X        /* [30] */
  563. X        {88, 152, 104, 184},
  564. X        CheckBox {
  565. X            enabled,
  566. X            "F"
  567. X        };
  568. X        /* [31] */
  569. X        {104, 152, 120, 200},
  570. X        CheckBox {
  571. X            enabled,
  572. X            "F#"
  573. X        };
  574. X        /* [32] */
  575. X        {120, 152, 136, 192},
  576. X        CheckBox {
  577. X            enabled,
  578. X            "G"
  579. X        };
  580. X        /* [33] */
  581. X        {136, 152, 152, 192},
  582. X        CheckBox {
  583. X            enabled,
  584. X            "G#"
  585. X        };
  586. X        /* [34] */
  587. X        {152, 152, 168, 184},
  588. X        CheckBox {
  589. X            enabled,
  590. X            "A"
  591. X        };
  592. X        /* [35] */
  593. X        {168, 152, 184, 192},
  594. X        CheckBox {
  595. X            enabled,
  596. X            "A#"
  597. X        };
  598. X        /* [36] */
  599. X        {184, 152, 200, 192},
  600. X        CheckBox {
  601. X            enabled,
  602. X            "B"
  603. X        };
  604. X        /* [37] */
  605. X        {8, 224, 24, 256},
  606. X        CheckBox {
  607. X            enabled,
  608. X            "C"
  609. X        };
  610. X        /* [38] */
  611. X        {24, 224, 40, 264},
  612. X        CheckBox {
  613. X            enabled,
  614. X            "C#"
  615. X        };
  616. X        /* [39] */
  617. X        {40, 224, 56, 264},
  618. X        CheckBox {
  619. X            enabled,
  620. X            "D"
  621. X        };
  622. X        /* [40] */
  623. X        {56, 224, 72, 272},
  624. X        CheckBox {
  625. X            enabled,
  626. X            "D#"
  627. X        };
  628. X        /* [41] */
  629. X        {72, 224, 88, 256},
  630. X        CheckBox {
  631. X            enabled,
  632. X            "E"
  633. X        };
  634. X        /* [42] */
  635. X        {88, 224, 104, 256},
  636. X        CheckBox {
  637. X            enabled,
  638. X            "F"
  639. X        };
  640. X        /* [43] */
  641. X        {104, 224, 120, 272},
  642. X        CheckBox {
  643. X            enabled,
  644. X            "F#"
  645. X        };
  646. X        /* [44] */
  647. X        {120, 224, 136, 264},
  648. X        CheckBox {
  649. X            enabled,
  650. X            "G"
  651. X        };
  652. X        /* [45] */
  653. X        {136, 224, 152, 264},
  654. X        CheckBox {
  655. X            enabled,
  656. X            "G#"
  657. X        };
  658. X        /* [46] */
  659. X        {152, 224, 168, 256},
  660. X        CheckBox {
  661. X            enabled,
  662. X            "A"
  663. X        };
  664. X        /* [47] */
  665. X        {168, 224, 184, 264},
  666. X        CheckBox {
  667. X            enabled,
  668. X            "A#"
  669. X        };
  670. X        /* [48] */
  671. X        {184, 224, 200, 264},
  672. X        CheckBox {
  673. X            enabled,
  674. X            "B"
  675. X        };
  676. X        /* [49] */
  677. X        {8, 296, 24, 328},
  678. X        CheckBox {
  679. X            enabled,
  680. X            "C"
  681. X        };
  682. X        /* [50] */
  683. X        {24, 296, 40, 336},
  684. X        CheckBox {
  685. X            enabled,
  686. X            "C#"
  687. X        };
  688. X        /* [51] */
  689. X        {40, 296, 56, 336},
  690. X        CheckBox {
  691. X            enabled,
  692. X            "D"
  693. X        };
  694. X        /* [52] */
  695. X        {56, 296, 72, 344},
  696. X        CheckBox {
  697. X            enabled,
  698. X            "D#"
  699. X        };
  700. X        /* [53] */
  701. X        {72, 296, 88, 328},
  702. X        CheckBox {
  703. X            enabled,
  704. X            "E"
  705. X        };
  706. X        /* [54] */
  707. X        {88, 296, 104, 328},
  708. X        CheckBox {
  709. X            enabled,
  710. X            "F"
  711. X        };
  712. X        /* [55] */
  713. X        {104, 296, 120, 344},
  714. X        CheckBox {
  715. X            enabled,
  716. X            "F#"
  717. X        };
  718. X        /* [56] */
  719. X        {120, 296, 136, 336},
  720. X        CheckBox {
  721. X            enabled,
  722. X            "G"
  723. X        };
  724. X        /* [57] */
  725. X        {136, 296, 152, 336},
  726. X        CheckBox {
  727. X            enabled,
  728. X            "G#"
  729. X        };
  730. X        /* [58] */
  731. X        {152, 296, 168, 328},
  732. X        CheckBox {
  733. X            enabled,
  734. X            "A"
  735. X        };
  736. X        /* [59] */
  737. X        {168, 296, 184, 336},
  738. X        CheckBox {
  739. X            enabled,
  740. X            "A#"
  741. X        };
  742. X        /* [60] */
  743. X        {184, 296, 200, 336},
  744. X        CheckBox {
  745. X            enabled,
  746. X            "B"
  747. X        };
  748. X        /* [61] */
  749. X        {208, 152, 237, 216},
  750. X        StaticText {
  751. X            enabled,
  752. X            "Middle\nC"
  753. X        };
  754. X        /* [62] */
  755. X        {208, 80, 256, 144},
  756. X        StaticText {
  757. X            enabled,
  758. X            "One \nOctave\nBelow"
  759. X        };
  760. X        /* [63] */
  761. X        {208, 8, 256, 72},
  762. X        StaticText {
  763. X            enabled,
  764. X            "Two\nOctaves\nBelow"
  765. X        };
  766. X        /* [64] */
  767. X        {208, 224, 256, 288},
  768. X        StaticText {
  769. X            enabled,
  770. X            "One \nOctave\nAbove"
  771. X        };
  772. X        /* [65] */
  773. X        {208, 296, 256, 360},
  774. X        StaticText {
  775. X            enabled,
  776. X            "Two\nOctaves\nAbove"
  777. X        }
  778. X    }
  779. X};
  780. X
  781. Xresource 'ICN#' (128, "SoundIcon", purgeable, preload) {
  782. X     {    /* array: 2 elements */
  783. X        /* [1] */
  784. X        $"0000 1F00 0000 FF00 0007 F900 003F C100"
  785. X        $"01FE 0100 01F0 0100 0100 0100 0100 0100"
  786. X        $"0100 0100 0100 0100 0100 0100 FFFF FFFF"
  787. X        $"0100 0100 0100 3D00 0100 7F00 0100 7F00"
  788. X        $"FFFF FFFF 7F00 7F00 7F00 3C00 7F00 0000"
  789. X        $"7F00 0000 FFFF FFFF 0000 0000 0000 0000"
  790. X        $"0000 0000 0000 0000 FFFF FFFF 0000 0000"
  791. X        $"0000 0000 0000 0000 0000 0000 0000 0000";
  792. X        /* [2] */
  793. X        $"FFFF FFFF FE7F 4B7B A400 C007 C660 0801"
  794. X        $"C272 0601 C8D2 4E09 936B 6D29 A01B 2209"
  795. X        $"A068 7E01 DFAF 3E51 80A0 2C01 C05B 8421"
  796. X        $"C088 BE55 C106 5605 D193 E285 CA05 0107"
  797. X        $"8739 0127 8381 0117 CCA1 0017 D801 BDD7"
  798. X        $"C615 81A7 C147 6067 CCAB 32E7 D410 1C47"
  799. X        $"C020 0C47 C4F1 0283 E685 608B E18B 1587"
  800. X        $"E1BB 6027 F304 BB17 FC03 C1DB FFFF FFFF"
  801. X    }
  802. X};
  803. X
  804. Xresource 'BNDL' (128, "SoundDemo") {
  805. X    'Snd1',
  806. X    0,
  807. X     {    /* array TypeArray: 2 elements */
  808. X        /* [1] */
  809. X        'ICN#',
  810. X         {    /* array IDArray: 1 elements */
  811. X            /* [1] */
  812. X            0,
  813. X            128
  814. X        };
  815. X        /* [2] */
  816. X        'FREF',
  817. X         {    /* array IDArray: 1 elements */
  818. X            /* [1] */
  819. X            0,
  820. X            128
  821. X        }
  822. X    }
  823. X};
  824. X
  825. Xresource 'FREF' (128, "FREF 1") {
  826. X    'APPL',
  827. X    0,
  828. X    ""
  829. X};
  830. X
  831. Xdata 'Snd1' (0) {
  832. X    $"6522 536F 756E 6444 656D 6F22 0D41 2053"      /* e"SoundDemo".A S */
  833. X    $"6F75 6E64 2064 656D 6F6E 7374 7261 7469"      /* ound demonstrati */
  834. X    $"6F6E 2070 726F 6772 616D 0D77 7269 7474"      /* on program.writt */
  835. X    $"656E 2066 6F72 2074 6865 2042 6F73 746F"      /* en for the Bosto */
  836. X    $"6E20 4D61 6357 6F72 6C64 2045 7870 6F2E"      /* n MacWorld Expo. */
  837. X    $"2020 A931 3938 3620 4672 6564 2041 2E20"      /*   .1986 Fred A.  */
  838. X    $"4875 7868 616D"                               /* Huxham */
  839. X};
  840. X
  841. ________This_Is_The_END________
  842. if test `wc -l < SoundDemo.r` -ne 479; then
  843.     echo 'shar: SoundDemo.r was damaged during transit'
  844.   echo '      (should have been 479 bytes)'
  845. fi
  846. fi        ; : end of overwriting check
  847. echo 'Extracting Makefile'
  848. if test -f Makefile; then echo 'shar: will not overwrite Makefile'; else
  849. sed 's/^X//' << '________This_Is_The_END________' > Makefile
  850. X# 
  851. X#    Sound Demonstration Program
  852. X#    written for the Boston MacWorld Expo
  853. X#    using the Macintosh Programmer's Workshop
  854. X#
  855. X#    (c) 1986 Fred A. Huxham
  856. X#
  857. X#--------------------------------------
  858. X#    This is the Makefile
  859. X#--------------------------------------
  860. X#
  861. X#    Options for the C compiler and Assembler
  862. XCOptions = 
  863. XAOptions = -case on
  864. X
  865. X#------------------------------------------------------------
  866. X
  867. XSoundDemo.rsrc [dependency symbol] SoundDemo.r ErrDialog.r Notes.r
  868. X    Rez -o SoundDemo.rsrc -t RSRC -c 'MPS ' [line continuation symbol]
  869. X    {RIncludes}Types.r [line continuation symbol]
  870. X    SoundDemo.r [line continuation symbol]
  871. X    Notes.r [line continuation symbol]
  872. X    ErrDialog.r
  873. X    
  874. X#------------------------------------------------------------
  875. X
  876. XSoundDemo [dependency symbol] SoundDemo.a.o SoundDemo.c.o ErrDialog.c.o SoundDemo.rsrc
  877. X    Duplicate -r -y SoundDemo.rsrc SoundDemo
  878. X    Link -ot "APPL" -oc "Snd1" -o SoundDemo [line continuation symbol]
  879. X    SoundDemo.a.o [line continuation symbol]
  880. X    SoundDemo.c.o [line continuation symbol]
  881. X    ErrDialog.c.o [line continuation symbol]
  882. X    {CLibraries}CInterface.o [line continuation symbol]
  883. X    {CLibraries}CRuntime.o [line continuation symbol]
  884. X    {CLibraries}StdCLib.o
  885. X    SetFile -a B SoundDemo
  886. X
  887. X#------------------------------------------------------------
  888. ________This_Is_The_END________
  889. if test `wc -l < Makefile` -ne 38; then
  890.     echo 'shar: Makefile was damaged during transit'
  891.   echo '      (should have been 38 bytes)'
  892. fi
  893. fi        ; : end of overwriting check
  894. echo 'Extracting Notes.r'
  895. if test -f Notes.r; then echo 'shar: will not overwrite Notes.r'; else
  896. sed 's/^X//' << '________This_Is_The_END________' > Notes.r
  897. X/* 
  898. X*    Sound Demonstration Program
  899. X*    written for the Boston MacWorld Expo
  900. X*    using the Macintosh Programmer's Workshop
  901. X*
  902. X*    (c) 1986 Fred A. Huxham
  903. X*
  904. X*--------------------------------------
  905. X*    This is Rez file that defines the
  906. X*    square wave notes resource type
  907. X*--------------------------------------
  908. X*
  909. X*/
  910. X
  911. X
  912. Xtype 'Note' {
  913. X    array NoteArray {
  914. X        unsigned integer;
  915. X    };
  916. X};
  917. X
  918. Xresource 'Note' (8888, "SqWvNotes", appheap, preload) {
  919. X    {
  920. X        11977;
  921. X        11305;
  922. X        10670;
  923. X        10071;
  924. X        9506;
  925. X        8972;
  926. X        8469;
  927. X        7994;
  928. X        7545;
  929. X        7121;
  930. X        6722;
  931. X        6344;
  932. X        5988;
  933. X        5652;
  934. X        5335;
  935. X        5036;
  936. X        4753;
  937. X        4486;
  938. X        4234;
  939. X        3997;
  940. X        3772;
  941. X        3561;
  942. X        3361;
  943. X        3172;
  944. X        2994;
  945. X        2826;
  946. X        2668;
  947. X        2518;
  948. X        2377;
  949. X        2243;
  950. X        2117;
  951. X        1998;
  952. X        1886;
  953. X        1780;
  954. X        1680;
  955. X        1586;
  956. X        1497;
  957. X        1413;
  958. X        1334;
  959. X        1259;
  960. X        1188;
  961. X        1122;
  962. X        1059;
  963. X        999;
  964. X        943;
  965. X        890;
  966. X        840;
  967. X        793;
  968. X        749;
  969. X        707;
  970. X        667;
  971. X        629;
  972. X        594;
  973. X        561;
  974. X        529;
  975. X        500;
  976. X        472;
  977. X        445;
  978. X        420;
  979. X        397
  980. X    }
  981. X};
  982. ________This_Is_The_END________
  983. if test `wc -l < Notes.r` -ne 85; then
  984.     echo 'shar: Notes.r was damaged during transit'
  985.   echo '      (should have been 85 bytes)'
  986. fi
  987. fi        ; : end of overwriting check
  988. echo 'Extracting ErrDialog.c'
  989. if test -f ErrDialog.c; then echo 'shar: will not overwrite ErrDialog.c'; else
  990. sed 's/^X//' << '________This_Is_The_END________' > ErrDialog.c
  991. X/***************************************************************************/
  992. X/*                                                                         */
  993. X/*                               ErrDialog.c                               */
  994. X/*                                                                         */
  995. X/*              Contains code for ErrDialog, OSError & ErrMessage          */
  996. X/*                   For use when debugging application code               */
  997. X/*                                                                         */
  998. X/*              10/2/85   DJ Burnard                                       */
  999. X/*                                                                         */
  1000. X/*              10/27/85 - DJB Put error strings into STR# resource        */
  1001. X/*              11/30/85 - DJB Changed to an Alert!                        */
  1002. X/*              05/03/86 - DJB Ported to MPW                               */
  1003. X/*                                                                         */
  1004. X/***************************************************************************/
  1005. X
  1006. X/* include MPW C header files */
  1007. X#include <types.h>
  1008. X#include <strings.h>
  1009. X#include <memory.h>
  1010. X#include <quickdraw.h>
  1011. X#include <windows.h>
  1012. X#include <events.h>
  1013. X#include <dialogs.h>
  1014. X#include <resources.h>
  1015. X
  1016. X/* #include <corrections.h> */
  1017. X/* #include <mystring.h>    */
  1018. X
  1019. X#define    TRUE    1
  1020. X#define    FALSE    0
  1021. X#define    NIL          0
  1022. X
  1023. X/* constant for error dialog kept in the resource fork*/
  1024. X#define errDialogID      9999
  1025. X#define errStringID      9999
  1026. X#define myLastErr        -120
  1027. X#define noErr                0
  1028. X
  1029. X
  1030. X      
  1031. XStr255  *Num2String(theNum, theStr)
  1032. X  long        theNum;
  1033. X  Str255   *theStr;
  1034. X  /* This is a minor variation on the Binary-Decimal Conversion
  1035. X     Package of the same name. Here we have made the procedure
  1036. X     into a function returning a pointer to the string. */
  1037. X{
  1038. X    NumToString(theNum, theStr);
  1039. X    return theStr;
  1040. X}
  1041. X
  1042. Xlong   String2Num(theStr)
  1043. X  Str255   *theStr;
  1044. X  /* This is a minor variation on the Binary-Decimal Conversion
  1045. X     Package of the same name. Here we have made the procedure
  1046. X     into a function returning the long number. */
  1047. X{
  1048. X    long    theNum;
  1049. X    
  1050. X    StringToNum(theStr, &theNum);
  1051. X    return theNum;
  1052. X}
  1053. X
  1054. X
  1055. X/*
  1056. X * ErrMessage:                          djb 10/27/85
  1057. X *
  1058. X *    Retrieve a message describing Mac OS Errors 
  1059. X *    Expects the following parameters:
  1060. X *
  1061. X *      theOSErr - an OSErr - error code returned by OS routine
  1062. X *
  1063. X *    Message returned is in C format
  1064. X */
  1065. Xchar *ErrMessage(theOSErr, mesg)
  1066. X   OSErr   theOSErr;
  1067. X   char   *mesg;
  1068. X{
  1069. X   Str255   strtmp;
  1070. X   
  1071. X    if(theOSErr == noErr) {
  1072. X        strcpy(mesg, "noErr: False Alarm");
  1073. X    } else if(theOSErr > noErr) {
  1074. X        /* positive error code */
  1075. X        strcpy(mesg, Num2String(theOSErr, &strtmp));
  1076. X        strcat(mesg, " = Illegal Error Code > 0");
  1077. X    } else if((theOSErr < noErr) && (theOSErr > myLastErr)) {
  1078. X        /* get error message from STR# resource */
  1079. X        GetIndString(mesg, errStringID, -theOSErr);
  1080. X    } else {
  1081. X        /* an error code below the last one in STR# resource */
  1082. X        strcpy(mesg, Num2String(theOSErr, &strtmp));
  1083. X        strcat(mesg, ": Error not included in STR# resource");
  1084. X    }
  1085. X    return (mesg);
  1086. X}
  1087. X
  1088. X
  1089. X/*
  1090. X * OSError:                          djb 10/02/85
  1091. X *
  1092. X *    display an error message for system errors. 
  1093. X *    Expects the following parameters:
  1094. X *
  1095. X *      procName - C string (usually contains name of 
  1096. X *                      routine where error occurred)
  1097. X *      errNum   - error code returned by system (OSErr)
  1098. X *      msg      - C string (arbitrary error message)
  1099. X */
  1100. XOSError(procName, errNum, msg)                              
  1101. X   char    *procName, *msg;
  1102. X   OSErr   errNum;
  1103. X{
  1104. X   Str255   errMsg, trapMsg;
  1105. X   
  1106. X   /* paste together trap message */
  1107. X   strcpy(&trapMsg, procName);
  1108. X   strcat(&trapMsg, " reports an error");
  1109. X   
  1110. X   ErrDialog(&trapMsg, ErrMessage(errNum, &errMsg), msg);
  1111. X}
  1112. X
  1113. X
  1114. X/*
  1115. X * ErrDialog:                          djb 10/02/85
  1116. X *
  1117. X *    Alert programmer to an error situation 
  1118. X *    Expects the following parameters:
  1119. X *
  1120. X *      str1, str2, str3 - C strings (arbitrary error messages 
  1121. X *                           to the programmer)
  1122. X */
  1123. XErrDialog(str1, str2, str3)
  1124. X    char   *str1;
  1125. X    char   *str2;
  1126. X    char   *str3;
  1127. X{
  1128. X    char          *err = "Programmer Error:";
  1129. X   
  1130. X    ParamText(err, str1, str2, str3);
  1131. X    StopAlert(errDialogID, NIL);
  1132. X}
  1133. ________This_Is_The_END________
  1134. if test `wc -l < ErrDialog.c` -ne 145; then
  1135.     echo 'shar: ErrDialog.c was damaged during transit'
  1136.   echo '      (should have been 145 bytes)'
  1137. fi
  1138. fi        ; : end of overwriting check
  1139. echo 'Extracting ErrDialog.r'
  1140. if test -f ErrDialog.r; then echo 'shar: will not overwrite ErrDialog.r'; else
  1141. sed 's/^X//' << '________This_Is_The_END________' > ErrDialog.r
  1142. X/***************************************************************************/
  1143. X/*                                                                         */
  1144. X/*                               ErrDialog.r                               */
  1145. X/*                                                                         */
  1146. X/*                    Contains resource definitions for                       */
  1147. X/*                        ErrDialog, OSError & ErrMessage                       */
  1148. X/*                  For use when debugging application code                */
  1149. X/*                                                                         */
  1150. X/*                                                                         */
  1151. X/***************************************************************************/
  1152. X
  1153. Xresource 'ALRT' (9999) {
  1154. X    {69, 99, 300, 410},
  1155. X    9999,
  1156. X    ok,
  1157. X    visible,
  1158. X    1,
  1159. X    ok,
  1160. X    visible,
  1161. X    1,
  1162. X    ok,
  1163. X    visible,
  1164. X    1,
  1165. X    ok,
  1166. X    visible,
  1167. X    1
  1168. X};
  1169. X
  1170. Xresource 'DITL' (9999) {
  1171. X     {    /* array ditlarray: 5 elements */
  1172. X        {200, 120, 224, 176},
  1173. X        button {
  1174. X            enabled,
  1175. X            "OK"
  1176. X        };
  1177. X        {24, 64, 40, 288},
  1178. X        statictext {
  1179. X            disabled,
  1180. X            "^0"
  1181. X        };
  1182. X        {72, 16, 104, 288},
  1183. X        statictext {
  1184. X            disabled,
  1185. X            "^1"
  1186. X        };
  1187. X        {112, 16, 144, 288},
  1188. X        statictext {
  1189. X            disabled,
  1190. X            "^2"
  1191. X        };
  1192. X        {152, 16, 184, 288},
  1193. X        statictext {
  1194. X            disabled,
  1195. X            "^3"
  1196. X        }
  1197. X    }
  1198. X};
  1199. X
  1200. Xresource 'STR#' (9999) {
  1201. X     {    /* array stringarray: 120 elements */
  1202. X        "-1 = queue element not found during deletion";
  1203. X        "-2 = invalid queue element";
  1204. X        "-3 = core routine number out of range";
  1205. X        "-4 = unimplemented core routine";
  1206. X        "-5 = undocumented error code";
  1207. X        "-6 = undocumented error code";
  1208. X        "-7 = undocumented error code";
  1209. X        "-8 = undocumented error code";
  1210. X        "-9 = undocumented error code";
  1211. X        "-10 = undocumented error code";
  1212. X        "-11 = undocumented error code";
  1213. X        "-12 = undocumented error code";
  1214. X        "-13 = undocumented error code";
  1215. X        "-14 = undocumented error code";
  1216. X        "-15 = undocumented error code";
  1217. X        "-16 = undocumented error code";
  1218. X        "-17 = driver can't respond to Control call";
  1219. X        "-18 = driver can't respond to Status call";
  1220. X        "-19 = driver can't respond to Read call";
  1221. X        "-20 = driver can't respond to Write call";
  1222. X        "-21 = refNum doesn't match unit table";
  1223. X        "-22 = refNum specifies NIL handle in unit table";
  1224. X        "-23 = driver ccan't respond to Open call";
  1225. X        "-24 = driver ccan't respond to Close call";
  1226. X        "-25 = tried to remove an open driver";
  1227. X        "-26 = DrvrInstall couldn't find driver";
  1228. X        "-27 = I/O call aborted by KillIO";
  1229. X        "-28 = can't rd/wr/ctl/sts - drvr not open";
  1230. X        "-29 = undocumented error code";
  1231. X        "-30 = undocumented error code";
  1232. X        "-31 = undocumented error code";
  1233. X        "-32 = undocumented error code";
  1234. X        "-33 = file directory full ";
  1235. X        "-34 = all allocation blocks on the disk are full";
  1236. X        "-35 = no such volume or directory";
  1237. X        "-36 = disk I/O error";
  1238. X        "-37 = bad file or volume/directory name (empty?)";
  1239. X        "-38 = file not found";
  1240. X        "-39 = logical EOF reached during read operation";
  1241. X        "-40 = attempt to position mark before start of file";
  1242. X        "-41 = system heap is full";
  1243. X        "-42 = too many files open (12 max)";
  1244. X        "-43 = file not found";
  1245. X        "-44 = disk is write protected (hardware)";
  1246. X        "-45 = file is locked (File System flag)";
  1247. X        "-46 = volume is locked (File System flag)";
  1248. X        "-47 = file is busy (File System flag)";
  1249. X        "-48 = a file with this name already exists";
  1250. X        "-49 = file already open with write permission";
  1251. X        "-50 = error in user parameter list (bad volume)";
  1252. X        "-51 = refNum specifies nonexistent access path";
  1253. X        "-52 = undocumented error code";
  1254. X        "-53 = volume not on-line";
  1255. X        "-54 = R/W permission doesn't allow writing";
  1256. X        "-55 = drive/volume already on-line";
  1257. X        "-56 = no such drive number/ not in queue";
  1258. X        "-57 = not a Mac disk/ bad directory format";
  1259. X        "-58 = external file system error";
  1260. X        "-59 = problem during _Rename";
  1261. X        "-60 = bad master dir block - reinitialize";
  1262. X        "-61 = R/W or open permission doesn't allow writing";
  1263. X        "-62 = undocumented error code";
  1264. X        "-63 = undocumented error code";
  1265. X        "-64 = drive not installed";
  1266. X        "-65 = R/W requested for an off-line drive";
  1267. X        "-66 = couldn't find 5 nibbles in 200 tries";
  1268. X        "-67 = couldn't find valid address mark";
  1269. X        "-68 = verify compare during _Read failed";
  1270. X        "-69 = bad address mark checksum";
  1271. X        "-70 = bad address mark slip nibbles";
  1272. X        "-71 = couldn't find a data mark header";
  1273. X        "-72 = bad data mark checksum";
  1274. X        "-73 = bad data mark slip nibbles";
  1275. X        "-74 = write underrun occurred";
  1276. X        "-75 = step handshake failed";
  1277. X        "-76 = track 0 detect doesn't change";
  1278. X        "-77 = unable to initialize IWM";
  1279. X        "-78 = tried to read 2nd side of 1-side drive";
  1280. X        "-79 = unable to correctlt adjust disk speed";
  1281. X        "-80 = track number wrong on address mark";
  1282. X        "-81 = sector number never found on track";
  1283. X        "-82 = undocumented error code";
  1284. X        "-83 = undocumented error code";
  1285. X        "-84 = first low-level disk error";
  1286. X        "-85 = unable to read same clock value twice";
  1287. X        "-86 = time written didn't verify";
  1288. X        "-87 = parameter RAM didn't read-verify";
  1289. X        "-88 = InitUtil found parameter RAM uninitialized";
  1290. X        "-89 = SCC receiver error (framing, parity, ...)";
  1291. X        "-90 = break received (SCC)";
  1292. X        "-91 = undocumented error code";
  1293. X        "-92 = undocumented error code";
  1294. X        "-93 = undocumented error code";
  1295. X        "-94 = undocumented error code";
  1296. X        "-95 = undocumented error code";
  1297. X        "-96 = undocumented error code";
  1298. X        "-97 = undocumented error code";
  1299. X        "-98 = undocumented error code";
  1300. X        "-99 = undocumented error code";
  1301. X        "-100 = no scrap exists";
  1302. X        "-101 = undocumented error code";
  1303. X        "-102 = no object of that type in scrap";
  1304. X        "-103 = undocumented error code";
  1305. X        "-104 = undocumented error code";
  1306. X        "-105 = undocumented error code";
  1307. X        "-106 = undocumented error code";
  1308. X        "-107 = undocumented error code";
  1309. X        "-108 = not enough memory in heap zone";
  1310. X        "-109 = Master Pointer is NIL";
  1311. X        "-110 = specified address is odd or out of range";
  1312. X        "-111 = attempt to operate on a free block";
  1313. X        "-112 = trying to purge a locked or non-purgeable block";
  1314. X        "-113 = address in zone check failed";
  1315. X        "-114 = pointer ckeck failed";
  1316. X        "-115 = block ckeck failed";
  1317. X        "-116 = size check failed";
  1318. X        "-117 = undocumented error code";
  1319. X        "-118 = undocumented error code";
  1320. X        "-119 = undocumented error code";
  1321. X        "-120 = undocumented error code"
  1322. X    }
  1323. X};
  1324. ________This_Is_The_END________
  1325. if test `wc -l < ErrDialog.r` -ne 182; then
  1326.     echo 'shar: ErrDialog.r was damaged during transit'
  1327.   echo '      (should have been 182 bytes)'
  1328. fi
  1329. fi        ; : end of overwriting check
  1330. exit 0
  1331.