home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 083.lha / morse.asm < prev    next >
Assembly Source File  |  1986-11-20  |  53KB  |  1,427 lines

  1. ** morse.s
  2. ** Based on a combo of MY KINGDOM FOR A RASTPORT and morsecode.s
  3. ** A program in assembly language to make morse code sending and
  4. ** random code generating routines.  Started on April 30, 1097.
  5. ** By        Peter V. Inskeep
  6. **           6 Clearview Drive
  7. **           Long Valley, N. J., 07853
  8. *
  9. **  Includes not needed if the equates are used to speed assembly
  10. ;   INCLUDE    'exec/types.i'     ;these will conflict with the 
  11. ;   INCLUDE    'exec/io.i'
  12. ;   INCLUDE    'intuition/intuition.i'  ;equates below
  13. ;   INCLUDE    'outfile.equ'
  14. useoutfile  equ  1  ;equ 1 if you are not using outfile.equ
  15. useincludes equ  1  ;equ 1 if you are not using any includes at all
  16.    XREF   _LVOGetMsg
  17.    XREF   _LVOReplyMsg
  18.    XREF   _LVOSetMenuStrip
  19.    XREF   _LVOClearMenuStrip
  20.    XREF   _LVOPrintIText
  21.    XREF   _LVOClearScreen
  22.    XREF   _LVODrawBorder
  23.    XREF   _LVOOpenWindow
  24.    XREF   _LVOCloseWindow
  25.    XREF   _LVOAddDevice     ;exec function
  26.    XREF   _LVOOpenDevice    ;exec function
  27.    XREF   _LVOCloseDevice
  28.    XREF   _LVORemDevice
  29.    xref   _LVOOpenLibrary
  30.    xref   _LVOCloseLibrary
  31.    xref   _LVOOpen
  32.    xref   _LVOWaitForChar
  33.    xref   _LVOExecute
  34.    xref   _LVOClose
  35.    xref   _LVOInput
  36.    xref   _LVOOutput
  37.    xref   _LVOInput
  38.    xref   _LVOOutput                 
  39.    xref   _LVODoIO
  40.    xref   _LVOSendIO
  41.    xref   _LVOAbortIO
  42.    xref   _LVOCheckIO
  43.    xref   _LVOAddGadget
  44.    XREF   _LVOAllocMem
  45.    XREF   _LVOFreeMem
  46.  
  47. ***  Outfile.equ equates - items defined in outfile.equ only
  48. ***  do not use these if using outfile.equ, but do if using include
  49.    IFEQ  1-useoutfile  ;IF NOT EQUAL ZERO THEN THESE ARE NOT USED
  50. AbsExecBase    equ $4
  51. MEMF_PUBLIC  EQU  $01
  52. MEMF_CHIP  EQU  $02
  53. MEMF_FAST  EQU  $04
  54. MEMF_CLEAR  EQU  $10000
  55.   ENDC
  56. ***   DMA CHIP ADDRESSES - FROM THE HARDWARE MANUAL
  57. ***   NOT CURRENTLY IN INCLUDE OR OUTFILE.EQU SO ALWAYS USE  
  58. Chipadr        equ $dff000      ;base address of chip
  59. DMAconw        equ Chipadr+$96  ;DMA control write register
  60. Aud0Lc         equ Chipadr+$a0  ;Channel 0 waveform sample location
  61. Aud0Len        equ Chipadr+$a4  ;Channel 0 waveform sample length
  62. Aud0per        equ Chipadr+$a6  ;channel 0 period
  63. Aud0vol        equ Chipadr+$a8  ;channel 0 volume
  64. Aud1Lc         equ Chipadr+$b0  ;Channel 1 waveform sample location
  65. Aud1Len        equ Chipadr+$b4  ;Channel 1 waveform sample length
  66. Aud1per        equ Chipadr+$b6  ;channel 1 period
  67. Aud1vol        equ Chipadr+$b8  ;channel 1 volume
  68. Setclr         equ $08000       ;DMA SEETCLR bit
  69. OffDMA         equ 0            ;Disable DMA
  70. Aud0en         equ $01          ;enable/disable Channel 0
  71. Aud1en         equ $02          ;Enable/disable Channel 1
  72. DMAen          equ $0200        ;Enable DMA
  73. ALT0           equ $b0          ;type ALT-0 to go to a random number
  74.  
  75. **  INCLUDE EQUATES FROM EITHER INCLUDE OR OUTFILE.EQU
  76. **  Do not use these [set not =] if using include or outfile.equ
  77.    IFEQ  1-useincludes  ;IF NOT ZERO THEN WILL NOT BE EQUATED
  78. wd_RPort   equ  $32
  79. wd_FirstGadget  equ  $3e
  80. wd_Size    equ  $7c
  81. ig_ImageData  equ  $0a
  82. ig_SIZEOF  EQU  $14
  83. wd_UserPort   equ   $56
  84. nw_FirstGadget equ  $12
  85. im_Class   equ   $14
  86. im_Code    equ   $18
  87. im_MouseX  equ   $20
  88. im_MouseY  equ   $22
  89. im_Seconds equ   $24
  90. im_Micros  equ   $28
  91. MP_SIGBIT   equ   $0f
  92. MENUENABLED   equ   $01
  93. MIDRAWN   equ   $100
  94. ITEMTEXT   equ   $02
  95. ITEMENABLED   equ   $10
  96. WBENCHSCREEN   equ   $01
  97. HIGHCOMP   equ   $40
  98. WINDOWSIZING   equ   $01
  99. WINDOWDRAG   equ   $02
  100. WINDOWDEPTH   equ   $04
  101. WINDOWCLOSE   equ   $08
  102. SMART_REFRESH   equ   $00
  103. ACTIVATE   equ   $1000
  104. GIMMEZEROZERO   equ   $400
  105. VANILLAKEY    EQU  $00200000    ;SEE OPENWINDOW IN INTUITION REF MANL
  106. FOLLOWMOUSE  EQU   $0008
  107. CHECKIT  EQU $00000001
  108. COMMSEQ  EQU $0004
  109. MENUTOGGLE   EQU  $0008
  110. CMD_READ  EQU  $02
  111. CMD_WRITE  EQU $03
  112. MN_SIZE  EQU   $99
  113. IO_DEVICE  EQU   $14
  114. IO_UNIT    EQU   $18
  115. IO_COMMAND  EQU  $1C
  116. IO_FLAGS   EQU   $1E
  117. IO_ERROR   EQU   $1F
  118. IO_ACTUAL  EQU   $20
  119. IO_LENGTH  EQU   $24
  120. IO_DATA    EQU   $28
  121. IO_OFFSET  EQU   $2C
  122. IOSTD_SIZE  EQU  $30
  123. pi_SIZEOF   EQU  $16
  124. pi_Flags    EQU  $00
  125. pi_HorizPot EQU  $02
  126. pi_VertPot  EQU  $04
  127. pi_HorizBody  EQU  $06
  128. pi_VertBody   EQU  $08
  129. pi_HPotRes  EQU  $0e
  130. pi_VPotRes  EQU  $10
  131. AUTOKNOB   EQU  $01
  132. FREEHORIZ  EQU  $02
  133. FREEVERT   EQU  $04
  134. KNOBHIT    EQU  $0100
  135. KNOBHMIN   EQU  6
  136. KNOBVMIN   EQU  4
  137. gg_NextGadget equ  $00
  138. gg_LeftEdge   equ  $04
  139. gg_TopEdge    equ  $06
  140. gg_Width      equ  $08
  141. gg_Height     equ  $0a
  142. gg_Flags      equ  $0c
  143. gg_Activation  equ  $0e
  144. gg_GadgetType  equ  $10
  145. gg_GadgetRender equ  $12
  146. gg_SelectRender  equ  $16
  147. gg_GadgetText  equ  $1a
  148. gg_MutualExclude  equ  $1e
  149. gg_SpecialInfo   equ  $22
  150. gg_GadgetID    equ  $26
  151. gg_UserData    equ  $28
  152. gg_SIZEOF    equ  $1c
  153. RELVERIFY  EQU  $01
  154. RIGHTBORDER  EQU  $10
  155. BOTTOMBORDER  EQU  $80
  156. PROPGADGET  EQU  $03
  157. GZZGADGET  EQU  $2000
  158. CLOSEWINDOW  EQU  $0200
  159. GADGETUP  EQU  $40
  160. MENUPICK  EQU  $0100
  161. GRELRIGHT  EQU  $10
  162. GRELHEIGHT  EQU  $40
  163. GRELWIDTH  EQU  $20
  164. GRELBOTTOM  EQU  $08
  165. GADGIMAGE  EQU  $04
  166. GADGHIMAGE  EQU  $02
  167. GADGHCOMP  EQU  $00
  168. RP_JAM1  EQU  $00
  169. RP_JAM2  EQU  $01
  170.  
  171.    ENDC
  172. ***  Program equates not defined in Include or Outfile.equ
  173. maxspeed   equ  $a00
  174. maxstring      equ 1000    ;max string size
  175. linelen        equ 54      ;set to typed line length
  176. Count          equ $ffff        ;counter for delay timer
  177. bufferlen      equ 400  ;keyboard buffer length not more than #keybuf
  178. gwide   equ   22  ;how wide the gadget box is ( -GRELWIDTH)
  179. ghigh   equ  -40  ;how high the gadget box is (-GRELHEIGHT
  180. gleft   equ  -22  ;where the left edge of the box is (-GRELRIGHT)
  181. gtop    equ   15  ; -40  ;where the top of the box is (-GRELBOTTOM)
  182. g1wide  equ  400
  183. g1high  equ   12      ; -15
  184. g1left  equ   100
  185. g1top    equ  -13
  186. ** The following macro added by P.V.Inskeep, on 30,May,1987, to
  187. ** accomodate the need to copy a structure size into a program
  188. ** being written, and to consume the correct number of BYTES!
  189.   IFND  MYSTRUCT    
  190. MYSTRUCT    MACRO     ;mystructname,mystructendaddr
  191. \1          ds.b      \2
  192.         ENDM
  193.   ENDC
  194. tart:
  195.    jsr    getmem  ;allocate some chim memory
  196.    jsr    inits   ;set up some chip mem pointers
  197. ***   Open the Intuition Library ***
  198.    movea.l    #IntuitionName,a1     ;ask for intuition.library
  199.    clr.l      d0                    ;accept any version 0 or greater
  200.    movea.l    AbsExecBase,a6       ;the one fixed location in Amiga
  201.    jsr        _LVOOpenLibrary(a6)   ;assembly language programming
  202.    move.l     d0,IntuitionLibrary   ;store the pointer here
  203.    beq        Abort      ;if zero then open failed so we go away
  204. ** Open graphics - need for clear screen
  205.    movea.l    #GraphicsName,a1     ;ask for the graphics.library
  206.    clr.l      d0                   ;any version
  207.    movea.l    AbsExecBase,a6
  208.    jsr        _LVOOpenLibrary(a6)
  209.    move.l     d0,GraphicsLibrary   ;store the pointer here
  210.    beq        Abort
  211. ***   Open our simple window
  212.    movea.l    #newwindow,a0
  213.    movea.l    IntuitionLibrary,a6
  214.    jsr        _LVOOpenWindow(a6)
  215.    move.l     d0,MyWindow        ;pointer to newly opened window
  216.    beq        Abort              ;the rastport pointer is located
  217.    movea.l    MyWindow,a0        ;at an address which is offset from
  218.    movea.l    wd_RPort(a0),a1    ;the window pointer by the value of
  219.    move.l     a1,myrport         ;wd_RPort, which is hex $32
  220.  
  221. ** Initializations - nothing works unless these are initialized before
  222. ** being used in the various routines.
  223.    move.l    #1,randflag  ;set random for keyboard input
  224.    move.l    #0,codecntr  ;zero out code counter
  225.    move.l    #0,kbcntr    ;zero out keyboard counter
  226.    move.l    #keybuf,kbptr     ;the current keyboard buffer position
  227.    move.l    #keybuf,codeptr   ;the current code char position
  228.    move.l    #keybuf,d0     
  229.    add.l     #bufferlen,d0      ;get to end of keybuf
  230.    move.l    d0,kbendptr  ;the end of keybuf
  231.    move.l    #mymenu,menupoint   ;initialize pointer to menu structure
  232.    move.l    #menuitemone,firstmenuitem    ;init 1st menuitem pointer
  233.    move.l    #firstitemtext,itemonetext    ;init 1st item intuitext struct
  234.    move.l    #fititle,fitext               ;init title in 1st menu item
  235.    move.l    #menuitemtwo,menuitemone      ;init the second menu item
  236.    move.l    #seconditemtext,itemtwotext   ;and its text
  237.    move.l    #sititle,sitext
  238.    move.l    #menuitem3,menuitemtwo      ;init third menu item
  239.    move.l    #thirditemtext,item3text    ;and its text
  240.    move.l    #tititle,titext
  241.    move.l    #onelinelist,oneline1    ;init drawline border coordinates
  242.    move.l    #onecharbuf,onecharptr   ;for writing one char
  243.    move.l    #5,ranword   ;for random char generator spacing
  244.    lea       buffer,a1    ;initialize the buffer
  245.    move.l    a1,bufptr    ;pointer
  246. ** Set the Menu Strip
  247.    movea.l   MyWindow,a0    ;pointers to window and to menu structure
  248.    movea.l   menupoint,a1   ;needed to call SetMenuStrip
  249.    movea.l   IntuitionLibrary,a6
  250.    jsr       _LVOSetMenuStrip(a6)
  251.  
  252. IntroMessage:
  253.    jsr   welcomssg  ;see if the messages work
  254.    move.l  #200,d0   ;this is a short pause routine to let
  255.                       ;the user read the intro message
  256.    jsr   pause      ;time to read the screen
  257.    jsr   setmessage     ;set up the message center
  258.    bra      openconsole
  259. *****  We went to the openconsole routine *****
  260.    cnop   0,4
  261. ;try the IORequest block structure here  KEEP THIS 4/10/87
  262.    MYSTRUCT  myio,IOSTD_SIZE
  263.    cnop 0,4
  264.  
  265. ** Open Console.Device
  266. ** Start by init the iodata field to a pointer to  MyWindow
  267. **   The open console device fills in all the rest.
  268. **   for the specific commands.  see int. manual pg 174
  269. openconsole:
  270. ;initialize to call adddevice
  271.    move.l   #myio,a0   ;the reserved block pointer is ioreqptr
  272.    move.l   a0,ioreqptr   ;set up a ioblock pointer
  273.    move.l   MyWindow,d1   ;get the window pointer
  274.    move.l   d1,IO_DATA(a0)  ;put the window ptr in IO_DATA
  275.    move.l   #wd_Size,IO_LENGTH(a0)   ;poke size of a window structure
  276. ;add device
  277.    movea.l  ioreqptr,a1   ;pointer to the io request block
  278.    movea.l  AbsExecBase,a6
  279.    jsr      _LVOAddDevice(a6)  
  280. **open device
  281.    movea.l  #consolename,a0    ;console.device any other not do anything
  282.    move.l   #0,d0   ;unit number
  283.    movea.l  ioreqptr,a1   ;IORequest block structure i built
  284.    move.l   #0,d1  ;flags dont know what to put
  285.    movea.l  AbsExecBase,a6
  286.    jsr      _LVOOpenDevice(a6)  ;returns 0 if success, error if not
  287.    move.l   d0,consoleflag  ;keeps track of successful console open   
  288.    tst.l    d0    ;zero is success, not zero is error number
  289.    beq      success
  290.    move.l   #consolefail,IntuMsg  ;open console failed mssg
  291.    move.w   #200,offsetleft     ;print the message in the
  292.    move.w   #175,offsettop       ;middle of the screen
  293.    jsr      printthis
  294.    bra      close1
  295. success:
  296.   move.l  #iobuffer,d4  ;load a zero term mssg to print
  297.    jsr  conwrite   ;a short success message
  298.    tst.l    d0     ;zero is success
  299.    bne      close1
  300.    bra  passover  ;pass over the morse gadget initializations
  301. closeconsole:
  302.    movea.l  ioreqptr,a1
  303.    movea.l  AbsExecBase,a6
  304.    jsr      _LVOCloseDevice(a6)
  305.    rts
  306. ** put the message pointer in d4, with zero terminated
  307. conwrite:
  308.    movea.l  ioreqptr,a0   ;pointer to iorequestblock structure
  309.    move.l  #-1,IO_LENGTH(A0)  ;use -1 only if text null terminated.
  310. ;   otherwise, load iolength with buffer text length
  311.    move.l  d4,IO_DATA(A0)
  312.    move.w  #CMD_WRITE,IO_COMMAND(a0)    ;WORD LENGTH
  313.    movea.l a0,a1    ;iorequestblock structure
  314.    movea.l AbsExecBase,a6
  315.    jsr     _LVODoIO(a6)
  316.    rts
  317. conread:
  318.    movea.l  ioreqptr,a0 
  319.    move.l  #10,IO_LENGTH(a0)   ;read a maximum of ten chars.
  320.    move.w  #CMD_READ,IO_COMMAND(a0)   ;set up the read command
  321.    move.l  a0,a1
  322.    move.l  bufptr,IO_DATA(a0)  ;fill the buffer from dos
  323.    movea.l AbsExecBase,a6
  324.    jsr     _LVODoIO(a6)
  325.    rts
  326. **  Write one char in kbptr to the screen
  327. conwone:
  328.    movea.l  ioreqptr,a1   ;pointer to iorequestblock structure
  329.    move.l   #1,IO_LENGTH(a1)  ;use 1 to write one character
  330.    move.l   kbptr,IO_DATA(a1)
  331.    move.w   #CMD_WRITE,IO_COMMAND(a1)    ;WORD LENGTH
  332.    movea.l  AbsExecBase,a6
  333.    jsr      _LVOSendIO(a6)
  334.    rts
  335. ** Read one char fm keyboard (kbptr) 
  336. conrone:
  337.    movea.l  ioreqptr,a1  ;get ioreqblock base pointer
  338.    move.l   #1,IO_LENGTH(a1)   ;read 1 char
  339.    move.w   #CMD_READ,IO_COMMAND(a1)   ;set the read command
  340.    move.l   kbptr,IO_DATA(a1)  ;pointer where to store char
  341.    movea.l  AbsExecBase,a6     ;needs base ptr in a1
  342.    jsr      _LVOSendIO(a6)
  343.    rts
  344. ** gets a char if there is one in keyboard, and writes it
  345. conchar:
  346.    clr.l    d4   ;sending a dot or dash
  347.    movea.l  ioreqptr,a0
  348.    move.w   30(a0),d4  ;bit 6 of #30 in iorequest block will be 
  349.    btst     #14,d4   ;1 if a char is available in read, otherwise
  350.    beq      1$      ;it will be zero
  351.    jsr    conrone   ;conchar is used in element to get a char while
  352.    jsr   conwone    ;there was a char
  353.    jsr   addkeyst   ;increment keyboard buffer ptr
  354. 1$  rts
  355. getmem:   ;for image and audio
  356.     move.l   #imagebytes,d0   ;#sizepubmem,d0
  357.     move.l   #(MEMF_CHIP!MEMF_PUBLIC),d1   ;!MEMF_CLEAR),d1
  358.     movea.l  AbsExecBase,a6
  359.     jsr      _LVOAllocMem(a6)
  360.     tst.l    d0   ;a ptr to the memoryblock or 0 if error
  361.     beq      Abort
  362.     move.l   d0,memblock   ;ptr to reserved memory block
  363.     move.l   d0,a0   ;ptr to reserved mem block
  364.     clr.l    d0    ;set up dbra register
  365.     move.l   #imagebytes,d0   ;#sizepubmem,d0   ;how many iterations
  366.     sub.l    #1,d0   ;goes to minus 1
  367.     lea.l    theimage,a1   ;ptr to beginning of initial data
  368. 1$  move.b   (a1)+,(a0)+   ;move data from begin to memblock
  369.     dbra     d0,1$  ;loop until all copied
  370. ;image2 - pitch - transformation
  371.     move.l   #pitchbytes,d0   ;#sizepubmem,d0
  372.     move.l   #(MEMF_CHIP!MEMF_PUBLIC),d1   ;!MEMF_CLEAR),d1
  373.     movea.l  AbsExecBase,a6
  374.     jsr      _LVOAllocMem(a6)
  375.     tst.l    d0   ;a ptr to the memoryblock or 0 if error
  376.     beq      Abort
  377.     move.l   d0,pitchblock   ;ptr to reserved memory block
  378.     move.l   d0,a0   ;ptr to reserved mem block
  379.     clr.l    d0    ;set up dbra register
  380.     move.l   #pitchbytes,d0   ;#sizepubmem,d0   ;how many iterations
  381.     sub.l    #1,d0   ;goes to minus 1
  382.     lea.l    pitchimage,a1   ;ptr to beginning of initial data
  383. 3$  move.b   (a1)+,(a0)+   ;move data from begin to memblock
  384.     dbra     d0,3$  ;loop until all copied
  385.     ;now the audio block moves to chip memory
  386.     move.l   #sizeaudio,d0
  387.     move.l   #(MEMF_CHIP!MEMF_PUBLIC),d1   ;!MEMF_CLEAR),d1
  388.     movea.l  AbsExecBase,a6
  389.     jsr      _LVOAllocMem(a6)
  390.     tst.l    d0   ;a ptr to the memoryblock or 0 if error
  391.     beq      Abort
  392.     move.l   d0,audioblock   ;ptr to reserved memory block
  393.     move.l   d0,a0   ;ptr to reserved mem block
  394.     clr.l    d0    ;set up dbra register
  395.     move.l   #sizeaudio,d0   ;how many iterations
  396.     sub.l    #1,d0   ;goes to minus 1
  397.     lea.l    Wavesample,a1   ;ptr to beginning of initial data
  398. 2$  move.b   (a1)+,(a0)+   ;move data from begin to memblock
  399.     dbra     d0,2$  ;loop until all copied
  400.     rts    
  401. *  Initialize the variables
  402. inits:
  403.    lea       image1,a0   ;gadget1 image structure ptr
  404.    movea.l   memblock,a1  ;ptr to gadget knob image data
  405.    move.l    a1,ig_ImageData(a0)  ;initialize image1 data ptr
  406.    lea       image2,a0
  407.    movea.l   pitchblock,a1
  408.    move.l    a1,ig_ImageData(a0)  ;init image2 data ptr
  409.    lea       prop1,a0
  410.    clr.l     d0
  411.    move.w    pi_VertPot(a0),d0
  412.    move.l    d0,elmdelay
  413.    move.l    d0,dashdelay
  414.    lea       prop2,a0
  415.    clr.l     d0
  416.    move.w   pi_HorizPot(a0),d0   ;frequency  ;also word length
  417.    divu     #40,d0     ;divide down by 40
  418.    move.w   d0,frequency  ;store the new frequency
  419.    jsr   sound
  420.    rts
  421. passover:
  422.    jsr   sound    ;initialize the sound
  423.    jsr   ChanneL0 ;make a noise
  424.    move.l   #testmsg,d4
  425.    jsr   conwrite  ;print a message
  426.    tst.l  d0
  427.    bne    close1   ;if it fails
  428.    jsr    zerokeybuf   ;fill keybuf with zeros
  429.    jsr    conrone   ;read once to set to #14 bit  
  430. ;   jsr   testhex
  431.    bra   ponder3
  432. keytest:
  433.    jsr    conchar     ;is there a char at keyboard
  434.    jsr    codetable   ;see if there is a char to send
  435.    bra    ponder3     ;loop back and do it again
  436. zerokeybuf:
  437.    move.l    #keybuf,a0  ;start of keyboard buffer
  438.    clr.l     d1
  439.    move.l    #bufferlen,d1    ;one less than buffer length
  440.    sub.l     #1,d1           
  441. 1$   move.b   #0,(a0)+   ;zero fill
  442.    dbra      d1,1$   ;decrement and branch
  443.    rts
  444.  
  445. ** The main routine for the menuitem selection.
  446. ** The Message Reading SubRoutine **
  447. ponder3:
  448.    jsr     getmessage  ;go see if there is a message to read
  449.    tst.l   d0    ;returns zero if none
  450.    beq     ponder5     ;return if no message
  451.    clr.l   d0  ;myclass contains the idcmp message upon [ponder4]
  452.    move.l  myclass,d0    ;return from getmessage
  453.    cmp.w   #MENUPICK,d0  ;was a menu picked
  454.    beq     whichmenu     ;if so, then go find out which menu item
  455.    cmp.w   #CLOSEWINDOW,d0   ;or was it the closewindow gadget?
  456.    beq     close1        ;if so, go close everything out
  457.    cmp.w   #GADGETUP,D0  ;or was the gadget hit to change speed
  458.    beq     chgspeed      ;change the delay loop values 
  459. ponder5    bra  keytest  ;forever2  ;no message
  460.  
  461. ** Which Menu Item was selected?
  462. whichmenu:
  463.    clr.l   d0  ;mycode shows which menu item was selected
  464.    move.w   mycode,d0  ;mycode is word, not longword
  465. **  The next instructions masks mycode to isolate the six middle bits
  466. **  which contain the item number, and then compare it to item 1
  467.    and.w    #%0000011111100000,d0   ;15-11=sub; 10-5=item; 4-0=menu
  468.    cmp.w    #%0000000000000000,d0    ;0 is the 1st item #
  469.    beq      itemnr1    ;the 1st menu item was picked
  470.    cmp.w    #%0000000000100000,d0    ;1 is the 2nd item #
  471.    beq      itemnr2    ;the 2nd menu item was picked
  472.    cmp.w    #%0000000001000000,d0    ;10 is the 3rd item #
  473.    beq      itemnr3    ;the 3rd item was picked
  474.    jsr      erase      ;erase rectangle bounded by above
  475.    move.l   #playmouse,IntuMsg    ;if not either of the above
  476.    move.w   #280,offsetleft       ;print the message play with
  477.    move.w   #5,offsettop         ;your mouse
  478.    jsr      printthis  ;prints string pointed to by IntuMsg
  479.    bra      ponder5    ;loop back to the beginning
  480. itemnr1:  ;send faster
  481.    jsr      erase
  482.    move.l   #pickitem1,IntuMsg  ;random;first item picked so
  483.    move.w   #270,offsetleft     ;print the message on the
  484.    move.w   #5,offsettop       ;right side of the screen
  485.    jsr      printthis
  486.    jsr      meitem1    ;send faster
  487.    bra      ponder5
  488. itemnr2:               ;send slower
  489.    jsr      erase
  490.    move.l   #pickitem2,IntuMsg  ;random;first item picked so
  491.    move.w   #270,offsetleft          ;print the message on the
  492.    move.w   #5,offsettop            ;right side of the screen
  493.    jsr      printthis
  494.    jsr      meitem2     ;send slower
  495.    bra      ponder5
  496. itemnr3:                ;switch random
  497.    jsr      erase
  498.    move.l   #pickitem3,IntuMsg    ;second item picked so
  499.    move.w   #270,offsetleft       ;print the message in the
  500.    move.w   #5,offsettop         ;middle of the screen
  501.    jsr      printthis
  502.    jsr      meitem3   ;switch random on/off
  503.    bra      ponder5   ;use the same exit point
  504.  
  505. **  Random Number Generator - Uses MICROS **
  506. random:
  507.     clr.l    d4
  508.     jsr      GETRANDOM  ;a random nr 0-9 in d0
  509.     asl      #4,d0  ;shift left 3 to max 127
  510.     move.l   d0,d4  ;store
  511.     jsr      GETRANDOM  ;get another
  512.     add.l    d4,d0  ;combine them
  513.     add.l    #65,d0   ;at least an "a"
  514.     and.l    #$7f,d0
  515.     cmp.l    #64,d0  ;decimal 42
  516.     ble      random    
  517.     cmp.l    #124,d0
  518.     bge      random
  519.     cmp.l    #97,d0
  520.     bge      1$
  521.     cmp.l    #63,d0
  522.     bge      random
  523. 1$  cmp.l    lastrandom,d0
  524.     beq      random   ;if they are the same dont use it
  525.     jsr      aspace  ;see if time for a space
  526.     move.l   d0,-(sp)
  527.     lea      onecharbuf,a0
  528.     move.l   a0,d4
  529.     move.b   d0,(a0) 
  530.     jsr      conwrite  ;write it out
  531.     move.l   (sp)+,d0  ;get the character back
  532.     move.l   d0,lastrandom  ;store for comparison
  533.     rts   
  534.  
  535. GETRANDOM:
  536.    JSR   onerandom    ;make a random number fm 0 to 9
  537.    moveq    #0,d0      ;clear d0 long
  538.    MOVE.B   CELL1,D0   ;get the random # always in cell1
  539.    RTS      ;to from whence it came
  540. ** GENERATE RANDOM #'S FROM TRANSACTOR, MAY, 1987 
  541. ** MUST INITIALIZE WITH 21 RANDOM SINGLE DIGIT NUMBERS <10
  542. onerandom:
  543.    moveq    #0,d0
  544.    moveq    #0,d1
  545.    moveq    #0,d2
  546.    MOVE.B   CELL21,D0
  547.    ADD.B    CELL2,D0
  548.    CMP.B    #10,D0
  549.    blt      TEMP
  550.    SUB.B    #10,D0
  551. TEMP  MOVE.B  D0,TMP
  552.    movea.l   #CBASE+21,a0
  553.    movea.l   #CBASE+22,a1
  554.    move.l    #19,D1
  555. LOOP  move.b  -(A0),-(a1)        ;d2
  556.     dbra    d1,LOOP
  557.     move.b  TMP,CELL1  ;THIS IS THE RANDOM DIGIT FROM 0 TO 9
  558.     rts
  559. aspace:
  560.     move.l  ranword,d5  ;what's in ranword
  561.     tst.l   d5   ;if zero, then reseed
  562.     beq     1$
  563.     sub.l   #1,ranword  ;if not, reduce and return
  564. 2$  rts
  565. 1$  jsr     GETRANDOM  ;reseed the ranword
  566.     move.l  d0,ranword
  567.     move.l  #32,d0   ;put a space in the character generator
  568.     bra     2$
  569.     
  570. * CLEAR THE SCREEN**
  571. clear:
  572.    move.l   #longnull,IntuMsg    ;this prints a null message
  573.    move.w   #0,offsetleft      ;in the top left corner of the
  574.    move.w   #0,offsettop       ;screen so we can set the 'cursor'
  575.    jsr      printthis          ;for the call to ClearScreen
  576.    movea.l  myrport,a1         ;this windows rastport
  577.    movea.l  GraphicsLibrary,a6   ;the graphics.library
  578.    jsr      _LVOClearScreen(a6)  ;clears from the 'cursor' or pen
  579.    move.w   #10,offsetleft     ;position to the end of the rastport
  580.    move.w   #0,offsettop      ;or end of the window
  581.    rts
  582. setmessage:
  583.    movea.l  MyWindow,a0   ;pointer to my window
  584.    movea.l  wd_UserPort(a0),a0  ;pointer to our window's userport
  585.    move.l   a0,userport         ;save it
  586.    move.l   a0,a1   ;IntuiMessage apprs to be false not needed
  587.    move.l   a1,intuimessage     ;with our userport (and window)
  588.    rts
  589. getmessage:
  590.    clr.l    d4               ;need this for junk
  591.    movea.l  userport,a0      ;get userport pointer for call to GetMsg
  592.    movea.l  AbsExecBase,a6  ;GetMsg is exec.lib, not intuition.lib
  593.    jsr      _LVOGetMsg(a6)
  594.    tst.l    d0               ;returns null if no message
  595.    beq      getmssg1         ;escape if null
  596.    move.l   d0,idcmpmessage  ;pointer to this message structure needed
  597.    movea.l  idcmpmessage,a0  ;for address indirect with displacement
  598.    move.l   im_Class(a0),myclass  ;which ICDMP flag ie., MENUPICK
  599.    move.w   im_Code(a0),mycode    ;word-which menu item # 0,1,etc.
  600.    move.w   im_MouseX(a0),mousex  ;mouse x & y coordinates if
  601.    move.w   im_MouseY(a0),mousey  ;FOLLOWMOUSE flag is set in window
  602.    move.l   im_Seconds(a0),seconds  ;these are here in case you want to
  603.    move.l   im_Micros(a0),micros    ;use them for random # or timing
  604.    movea.l  idcmpmessage,a1  ;we want to reply to this message, which
  605.    movea.l  AbsExecBase,a6  ;is pointed to by idcmpmessage, so that
  606.    jsr      _LVOReplyMsg(a6) ;messages don't pile up
  607.    move.l   idcmpmessage,d0  ;if d0 not 0 then return with message
  608. getmssg1    rts
  609.  
  610. ** Intuition Message
  611. welcomssg:
  612.    move.w   #10,offsettop
  613.    move.w   #50,offsetleft
  614.    move.l   #line1,IntuMsg    ;get pointer for first line to be
  615.    bsr      lineprint    ;printed
  616.    move.l   #line2,IntuMsg   ;second line
  617.    bsr   lineprint
  618.    move.l   #line3,IntuMsg
  619.    bsr   lineprint
  620.    move.l   #line4,IntuMsg
  621.    bsr   lineprint
  622.    move.l   #line5,IntuMsg
  623.    bsr   lineprint
  624.    move.l   #line6,IntuMsg
  625.    bsr   lineprint
  626.    move.l   #line7,IntuMsg
  627.    bsr   lineprint
  628.    rts
  629. lineprint   add.w    #20,offsettop
  630.    jsr      printthis
  631.    rts
  632.  
  633. ** the following will print what is in "IntuMsg"
  634. printthis:
  635.    movea.l   #0,a0   ;clear these else doesn't work
  636.    movea.l  #0,a1
  637.    clr.l    d0
  638.    clr.l    d1
  639.    movea.l  myrport,a0           ;pointer to rastport struct
  640.    movea.l  #intuitext,a1        ;pointer to intuitext struct
  641.    move.w   offsetleft,d0        ;leftedge offset
  642.    move.w   offsettop,d1         ;top edge offset
  643.    movea.l  IntuitionLibrary,a6  ;set library pointer
  644.    jsr      _LVOPrintIText(a6)   ;call print
  645.    rts
  646.  
  647. ** Pause routine expects delay value in d0, with constant 10000
  648. pause:
  649.    move.l   #10000,d1
  650.    move.l   d0,d2       ;put outter loop value in d2
  651. pause1   move.l  d1,d3  ;inner loop value in d3
  652. pause2      nop
  653.    dbra     d3,pause2   ;decrease inner loop till minus 1
  654.    dbra     d2,pause1   ;same for outter loop
  655.    rts                  ;all done
  656.  
  657. ** ERASE Part of Screen Routine - Fills a rectangle with the  **
  658. ** background color.  The rectangle is bounded by the starting
  659. ** and ending x,y coordinates (top left & bottom right)
  660. ** Start x pos in d0, end x pos in d1, both y pos' in d2
  661. ** Start at the bottom of the rectangleand draw lines in
  662. ** the background color up to the top of the screen
  663. erase:
  664.    move.w   #00,d0
  665.    move.w   #599,d1
  666.    move.w   #15,d2
  667.    move.w   d0,stx         ;starting x position
  668.    move.w   d1,endx        ;ending x position
  669.    move.w   d2,sty         ;starting y position
  670.    move.w   d2,endy        ;ending y position
  671. grids1   jsr  drawline     ;draw one horizontal line a pixel high
  672.    subi.w   #1,sty         ;reduce y position
  673.    subi.w   #1,endy        ;reduce y position
  674.    dbra     d2,grids1      ;go back and draw another line
  675.    rts
  676.  
  677. **  call this subroutine to draw a single line from coordinates
  678. **  stx,sty to endx,endy - initialize those values before calling
  679. **  the subroutine by move.w   #nn,stx etc
  680. drawline:
  681.    movea.l  myrport,a0       ;pointer to our rastport
  682.    movea.l  #oneline,a1      ;pointer to border structure
  683.    move.l   #0,d0            ;offsets-left & top
  684.    move.l   #0,d1
  685.    move.l   IntuitionLibrary,a6
  686.    jsr      _LVODrawBorder(a6)
  687.    rts    
  688.  
  689. ***   Close the intuition window only ***
  690. windowclose  movea.l   MyWindow,a0
  691.    movea.l  IntuitionLibrary,a6
  692.    jsr      _LVOCloseWindow(a6)      ;now close the window
  693.    rts
  694.  
  695. *  Exit program
  696. close1:
  697.    move.l   consoleflag,d0
  698.    tst.l    d0
  699.    bne      close2
  700.    jsr closeconsole
  701. close2:
  702. close    clr.l    d0
  703. ***   Close out and be gone  ***
  704. bailout:
  705.    jsr   clear  ;clear the screen
  706.    move.w   #200,offsetleft  ;position a goodbye message
  707.    move.w   #50,offsettop
  708.    move.l   #goodbye,IntuMsg
  709.    jsr      printthis
  710.    move.l   #100,d0 
  711.    jsr      pause           
  712.    movea.l   MyWindow,a0    ;clear the menu strip to
  713.    movea.l  IntuitionLibrary,a6      ;avoid conflicts when the
  714.    jsr      _LVOClearMenuStrip(a6)   ;program is ended
  715. bailout1    movea.l   MyWindow,a0
  716.    movea.l  IntuitionLibrary,a6
  717.    jsr      _LVOCloseWindow(a6)      ;now close the window
  718. Abort:
  719.   clr.l     d0
  720.   rts                  ;all done, program has ended
  721.  
  722. **   The Code Table
  723. **   code element to be sent is in d0
  724. codetable:
  725.    jsr    getcodechar   ;get the next char fm keybuf
  726.    cmpi.b   #0,d0
  727.    beq      codet3  ;leave if char zero      
  728.    cmpi.b   #32,d0   ;is it a space? if so, skip code
  729.    beq      endword
  730.    movea.l  #alphacode,a0     ;get table pointer
  731.    clr.l    d1                ;clr counter
  732.    move.b   (a0),d1           ;set count at # of chars in table
  733.    adda.l   #1,a0             ;move up to beginning of table
  734. codet1   cmp.b    0(a0,d1),d0       ;index into table d1 bytes & compare
  735.    beq      codet2            ;char found
  736.    dbra     d1,codet1         ;decrement counter & try again
  737.    bra      codet3            ;exit-no match found
  738. codet2   move.b   d1,ltrcode        ;save the letter code number
  739.    jmp      findltr           ;get the letter
  740. codet4:
  741.    bne      codet3
  742.    move.l   d0,-(sp)        ;save char
  743.    move.l   #linelen,carreturn
  744.    move.l   (sp)+,d0        ;restore char
  745. codet3    rts   ;to keytest and start again
  746.  
  747. endword:
  748.    clr.l   d0
  749.    move.b  wordspce,d0       ;set up dbra loop
  750. endword1  jsr     element    ;basic element spacing
  751.    dbra    d0,endword1
  752.    jmp     codet4            ;go update the line counter
  753.  
  754. findltr  move.b   ltrcode,d0  ;get the number back
  755.    add.b    d0,d0             ;double it
  756.    movea.l  #dotdash,a0       ;get table base
  757.    move.b   0(a0,d0),d1       ;the length of the code elements
  758.    subq.b   #1,d1             ;dec by one for dbra ending in -1
  759.    addq.b   #1,d0             ;up addr to code description
  760.    move.b   0(a0,d0),d2       ;get the morse letter
  761. nextelm  btst     d1,d2       ;if bit 1 then dash
  762.    bne.s    dash
  763. dot   jsr   sndon       ;turn on the sound
  764.    jsr      element     ;sound one dot element
  765. elmstart jsr   sndoff   ;turn sound off
  766.    jsr   noelement      ;char space
  767. elmdone  dbra     d1,nextelm  ;if not -1 then get next element
  768. endchar  clr.l    d1
  769.    move.b   charspce,d1       ;do the character space-3 elms
  770. endchar1 jsr   element        ;make space rem to make charspce one
  771.    dbra     d1,endchar1       ;less than desired spaceing.
  772.    jmp      codet4            ;all done-get next character
  773. dash  jsr   sndon
  774.    jsr      dashelement ;this is longer by the weighting ratio
  775.    jmp      elmstart    ;the dash is done
  776.  
  777. ***  KeyBuffer Maintainence routine. Does not alter d0 ***
  778. addkeyst:
  779.    add.l   #1,kbptr
  780.    add.l   #1,kbcntr ;increment the keyboard counter
  781.    move.l  kbendptr,d4   ;set up a compare
  782.    cmp.l   kbptr,d4   ;is ptr less?
  783.    bgt     1$     ;d4 is > kbptr so branch
  784.    move.l  #keybuf,kbptr  ;reset to the beginnng
  785. 1$  rts
  786.  
  787. ** This gets a char and increments codeptr
  788. getcodechar:
  789.    clr.l   d1
  790.    clr.l   d0
  791.    move.l  randflag,d1
  792.    tst.l   d1     ;if zero, then fetch code from random routine
  793.    beq    random  ;this will send random code until menu changed
  794.    move.l  codecntr,d1  ;see that code does not get ahead of keyboard
  795.    cmp.l   kbcntr,d1    ;is d0 bigger, then dont send anything
  796.    bge     1$           ;just return until keyboard catches up
  797.    clr.l   d0
  798.    movea.l  codeptr,a0   ;set up indirect to get char to send
  799.    move.b  (a0),d0    ;get the char
  800.    add.l   #1,codeptr  ;increment before testing
  801.    add.l   #1,codecntr  ;increment the code counter
  802.    move.l  kbendptr,d4     ;are we at the end of the buffer
  803.    move.l  codeptr,d5
  804.    cmp.l   d5,d4 
  805.    bgt     1$     ;branch if d4 > codeptr
  806.    move.l  #keybuf,codeptr   ;reset to the beginning
  807. 1$  rts    ;returns with char in d0, & pointer incremented
  808.  
  809. ** Chage Speed With Proportional Gadget **
  810. chgspeed:
  811.     clr.l    d0  ;cuz we're going from word to long
  812.     clr.l    d1
  813.     lea.l    prop1,a0   ;get the prop struct base ptr
  814.     move.w   pi_VertPot(a0),d0   ;must be word length
  815.     divu     #2,d0   ;cut it down
  816.     move.w   #maxspeed,d1
  817.     add.w    d0,d1
  818.     move.l   d1,elmdelay  ;do the dot
  819.     move.l   d1,dashdelay  ;do the dash
  820.     lea.l    prop2,a0   ;get pitch prop struct base ptr
  821.     clr.l    d0
  822.     move.w   pi_HorizPot(a0),d0   ;frequency  ;also word length
  823.     divu     #40,d0     ;divide down by 40
  824.     move.w   d0,frequency  ;store the new frequency
  825.     jsr   sound
  826. ;tell the screen that we did this
  827.    jsr      erase
  828.    clr.l    d0
  829.    move.w   frequency,d0
  830.    jsr      printhex
  831.    move.l   #hexprint,IntuMsg 
  832.    move.w   #270,offsetleft   
  833.    move.w   #5,offsettop      
  834.    jsr      printthis
  835.    bra      ponder5    
  836.  
  837. ** Independant Menu Picks **
  838. ** send faster
  839. meitem1:
  840.    subi.l   #1,elmdelay1  ;menu item says go faster
  841.    subi.l   #3,dashdelay1
  842.    beq    meitem2       ;unless we get to zero
  843.    rts
  844. **  send slower
  845. meitem2:          ;send slower
  846.    addi.l   #1,elmdelay1   ;menu says go slower
  847.    addi.l   #3,dashdelay1
  848.    rts
  849. **  switch random = 0  keyboard = 1
  850. meitem3:
  851.    tst.l   randflag    ;what is current state?
  852.    beq.s   1$    ;its zero, so we want to make it one
  853.    move.l   #0,randflag  ;it was one, so make it zero
  854. 2$  rts
  855. 1$  move.l   #1,randflag  ;make it one
  856.    move.l   codeptr,d4   ;reprint remaining keyboard buffer
  857.    jsr   conwrite
  858.    bra   2$    ;exit at one place     
  859.  
  860. sound:
  861.     movea.l audioblock,a2  ;Find address of waveform sample data
  862.     move.l  a2,Aud0Lc      ;set waveform location channel 0
  863.     move.l  a2,Aud1Lc      ;set waveform location channel 1
  864. * Length = number of WORDS (not bytes) in waveform sample
  865.     move.w  #16,Aud0Len    ;Set sample length channel 0
  866.     move.w  #16,Aud1Len    ;set sample length channel 1
  867. * volume can go up to 64
  868.     move.w  #64,Aud0vol    ;Set channel 0 volume at maximum
  869.     move.w  #64,Aud1vol    ;Set Channel 1 volume at maximum
  870.     move.w  frequency,d0   ;bigger period higher sound
  871.     move.w  d0,Aud0per     ;reset channel 0 period
  872. ;    add.w   d0,d0          ;make a different pitch
  873.     move.w  d0,Aud1per     ;set channel 1 period
  874.     rts
  875. ChanneL0:
  876.     move.w  #(Setclr+DMAen+Aud0en),DMAconw     ;enable channel 0
  877.     bsr Timedelay                              ;delay
  878.     move.w  #(OffDMA+Aud0en),DMAconw           ;disable channel 0
  879. ChanneL1:
  880.     move.w  #(Setclr+DMAen+Aud1en),DMAconw     ;enable channel 1
  881.     bsr Timedelay                              ;delay
  882.     move.w  #(OffDMA+Aud1en),DMAconw           ;disable channel 1
  883.     rts
  884. sndon:
  885.    move.w  #(Setclr+DMAen+Aud1en),DMAconw     ;turn sound on
  886.    move.w  #(Setclr+DMAen+Aud0en),DMAconw     ;ch 0 & 1
  887.    rts
  888. sndoff:
  889.    move.w  #(OffDMA+Aud1en),DMAconw   ;turn sound off
  890.    move.w  #(OffDMA+Aud0en),DMAconw   ;ch 0 & 1
  891.    rts
  892. noelement   movem.l  d0-d4/a0-a4,-(sp)    ;save the registers
  893.    jsr    conchar    ;get a key      
  894.    clr.l    d1
  895.    move.l   elmdelay1,d1   ;set up a double # time delay loop
  896. 2$  clr.l    d0
  897.    move.l   elmdelay,d0    ;with delay & delay1 with delay
  898. 3$  nop
  899.    dbra     d0,3$    ;as the largest #
  900.    dbra     d1,2$
  901.    movem.l  (sp)+,d0-d4/a0-a4
  902.    rts
  903. element   movem.l  d0-d4/a0-a4,-(sp)    ;save the registers
  904.    jsr    conchar
  905.    clr.l    d1
  906.    move.l   elmdelay1,d1   ;set up a double # time delay loop
  907. element2  clr.l    d0
  908.    move.l   elmdelay,d0    ;with delay & delay1 with delay
  909. element3  nop
  910.    dbra     d0,element3    ;as the largest #
  911.    dbra     d1,element2
  912.    movem.l  (sp)+,d0-d4/a0-a4
  913.    rts
  914. dashelement  movem.l   d0-d4/a0-a4,-(sp)    ;save the registers
  915.    clr.l    d1
  916.    move.l   dashdelay1,d1
  917. dashelm2  clr.l    d0
  918.    move.l   dashdelay,d0
  919. dashelm3  nop
  920.    dbra     d0,dashelm3
  921.    dbra     d1,dashelm2
  922.    movem.l  (sp)+,d0-d4/a0-a4
  923.    rts
  924. Timedelay:
  925.    movem.l   d0-d1,-(sp)
  926.    move.w #12,d0
  927. *   move.l d1,-(a7)
  928.    subq.w #1,d0
  929. 1$   move.w #Count,d1
  930. 2$  nop
  931.    dbra d1,2$
  932.    dbra d0,1$
  933. *   move.l (a7)+,d1
  934.    movem.l   (sp)+,d0-d1
  935.    rts
  936.  
  937. printhex:
  938. ;prints a 16-bit hex number using d0 and hexfield
  939.    clr.l   d1  ;nibble holder
  940.    clr.l   d2  ;downcounter
  941.    moveq   #3,d2
  942.    lea.l   hexfield,a0
  943.    lea.l   hexlist,a1
  944.    bra     1$
  945. 2$ sub.l   #1,d2
  946.    asr.l   #4,d0  ;shift to next nibble 
  947. 1$ move.l  d0,d1  ;move it 
  948.    andi.l  #$0f,d1  ;what is the nibble
  949.    move.b  0(a1,d1.l),d1  ;get the ascii equivalent
  950.    move.b  d1,0(a0,d2.l)  ;put it in the hexfield
  951.    tst.l   d2
  952.    beq     3$
  953.    bra     2$
  954. 3$ rts
  955. testhex:
  956.    jsr      erase
  957.    move.l   elmdelay,d0
  958.    jsr      printhex
  959.    move.l   #hexprint,IntuMsg  ;random;first item picked so
  960.    move.w   #210,offsetleft     ;print the message on the
  961.    move.w   #5,offsettop       ;right side of the screen
  962.    jsr      printthis
  963.    rts
  964. yestheend:
  965.       
  966.    SECTION     data,DATA
  967.  
  968. CBASE    DC.B     9
  969. CELL1    DC.B     4
  970. CELL2    DC.B     7,2,5,8,3,6,1,0,2,8,4,6,9,5,1,0,7,5,2
  971. CELL21   DC.B     3
  972. TMP      DC.B     0,0,0,0
  973.          CNOP     0,4
  974.  
  975. ;dosname  dc.b     'dos.library',0
  976. ;conname  dc.b     'raw:10/120/620/80/MORSE CODE - NO2D - 1987',0
  977. ;   cnop  0,4
  978. hexlist  dc.b  '0123456789abcdef',0
  979. consolename  dc.b  'console.device',0
  980. IntuitionName   dc.b  'intuition.library',0
  981. GraphicsName    dc.b  'graphics.library',0
  982.     cnop   0,4    ;this is used to allign following stuff on a
  983. **  long word address. If not done disaster can strike
  984.  
  985. menuflags   EQU   MENUENABLED!MIDRAWN   ;FROM INTUITION MENU STRUCTURE
  986. itemflags   EQU   ITEMTEXT!ITEMENABLED!HIGHCOMP!COMMSEQ
  987. item3flags  EQU   ITEMTEXT!ITEMENABLED!HIGHCOMP!CHECKIT!COMMSEQ!MENUTOGGLE
  988. MyGadgets   EQU   WINDOWSIZING!WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE
  989. MyFeatures  EQU   SMART_REFRESH!ACTIVATE!GIMMEZEROZERO   ;!VANILLAKEY
  990. MyFlags     EQU   MyGadgets!MyFeatures
  991. gadgrel     EQU   GRELRIGHT!GRELHEIGHT   ; !GRELBOTTOM
  992. gadg1rel    EQU   GRELHEIGHT!GRELBOTTOM
  993. gadgflags   EQU   GADGHIMAGE!GADGIMAGE
  994. gadg1flags  EQU   GADGHIMAGE!GADGIMAGE
  995. gadgtype    EQU   PROPGADGET!GZZGADGET
  996. propflags   EQU   FREEVERT!KNOBHIT      ;!FREEHORIZ  !AUTOKNOB
  997. prop1flags  EQU   KNOBHIT!FREEHORIZ           ;!AUTOKNOB
  998. menupick    EQU   MENUPICK
  999. MyTitle:    dc.b  ' NO2D MORSE CODE ',0   ;the title of our window
  1000. iobuffer    dc.b  ' The iobuffer has opened successfully.',10,13,0
  1001. menutitle   dc.b  'Morse Menu',0      ;null term string
  1002. fititle     dc.b  'Send Faster',0    ;first item in menu
  1003. sititle     dc.b  'Send Slower',0   ;second item in menu
  1004. tititle     dc.b  'Send Random',0   ;third menu item
  1005. offsetleft  dc.w  0
  1006. offsettop   dc.w  0
  1007. frequency   dc.w  600
  1008.       cnop   0,4
  1009.  
  1010. **  MENU and MENU ITEM STRUCTURES
  1011. mymenu:
  1012.    dc.l  0    ;menu pointer
  1013.    dc.w  0,0,150,100  ;leftedge,topedge,width,height
  1014.    dc.w  MIDRAWN!MENUENABLED  ;menuflags MENUENABLED & MIDRAWN
  1015.    dc.l  menutitle    ;pointer to title string
  1016. firstmenuitem  dc.l  0   ;pointer to first menu item (menuitemone)
  1017.    dc.w   0,0,0,0     ;for the jazz-beat (who knows what that means)
  1018.  
  1019. ** The first menu item structure **
  1020. menuitemone  dc.l  0     ;pointer to second menuitem
  1021.    dc.w  0,0,130,11      ;left,top,width,height of select box
  1022.    dc.w   itemflags      ;see flags set above
  1023.    dc.l   0              ;mutual exclude null=no item excluded
  1024. itemonetext   dc.l   0   ;pointer to intuitext struct for item text
  1025.    dc.l   0              ;pointer to highlight alternate image/text
  1026.    dc.b   70,0     ;set if COMMSEQ flag is set & a kluge byte 'f'
  1027.    dc.l   0       ;subitem if any
  1028.    dc.w   0       ;next selected item in drag 'mi_NextSelect'
  1029. ** remember to initialize all of these things
  1030. firstitemtext:
  1031.    dc.b  0,1,4,0  ;pens drawmode & kluge
  1032.    dc.w  0,0      ;leftedge,topedge
  1033.    dc.l  0        ;textfont null = default
  1034. fitext  dc.l  0   ;textpointer
  1035.    dc.l  0        ;pointer to next intuitext struct
  1036.  
  1037. ** The second menu item structure **
  1038. menuitemtwo  dc.l  0  ;pointer to third menuitem
  1039.    dc.w  3,15,130,11  ;left,top,width,height of select box
  1040.    dc.w   itemflags   ;see flags set above
  1041.    dc.l   0           ;mutual exclude null=no item excluded
  1042. itemtwotext   dc.l   0   ;aptr to intuitext struct for this item text
  1043.    dc.l   0              ;aptr to highlight alternate image/text
  1044.    dc.b   83,0     ;set if COMMSEQ flag is set & a kluge byte 's'
  1045.    dc.l   0       ;subitem if any
  1046.    dc.w   0       ;next selected item in drag 'mi_NextSelect'
  1047. ** remember to initialize all of these things
  1048. seconditemtext:
  1049.    dc.b  0,1,4,0  ;pens drawmode & kluge
  1050.    dc.w  0,0      ;leftedge,topedge
  1051.    dc.l  0        ;textfont null = default
  1052. sitext  dc.l  0   ;textpointer
  1053.    dc.l  0        ;pointer to next intuitext struct
  1054.    cnop  0,4
  1055.  
  1056. ** The third menu item structure **
  1057. menuitem3  dc.l  0     ;pointer to second menuitem
  1058.    dc.w  3,30,150,11   ;left,top,width,height of select box
  1059.    dc.w   item3flags   ;see flags set above
  1060.    dc.l   0            ;mutual exclude null=no item excluded
  1061. item3text   dc.l   0   ;pointer to intuitext struct for item text
  1062.    dc.l   0            ;pointer to highlight alternate image/text
  1063.    dc.b   65,0     ;set only if COMMSEQ flag is set & a kluge byte
  1064.    dc.l   0       ;subitem if any
  1065.    dc.w   0       ;next selected item in drag 'mi_NextSelect'
  1066. ** remember to initialize all of these things
  1067. thirditemtext:
  1068.    dc.b  0,1,4,0  ;pens drawmode & kluge
  1069.    dc.w  12,0      ;leftedge,topedge
  1070.    dc.l  0        ;textfont null = default
  1071. titext  dc.l  0   ;textpointer
  1072.    dc.l  0        ;pointer to next intuitext struct
  1073.  
  1074. **  An IntuiText Structure.  Use this to do the "printthis"
  1075. **  routine, with pointer to message in IntuMsg
  1076. intuitext:
  1077.   dc.b  1,1,2,0   ;FT & bk pen, drawmode, kluge
  1078.   dc.w  0,0       ;leftedge topedge
  1079.   dc.l  0         ;textfont normal if 0
  1080. IntuMsg  dc.l  0  ;pointer to null terminated text to be printed
  1081.   dc.l  0         ;next intuitext structure-null if none`
  1082.    cnop   0,4
  1083.  
  1084. line1  dc.b  'Welcome to the Morse Code Practice Program.',0
  1085. line2  dc.b  'It is designed to help you improve your Morse Code',0
  1086. line3  dc.b  'sending and receiving speed, with the hope that it',0
  1087. line4  dc.b  'will encourage you to get your amatuer radio license',0
  1088. line5  dc.b  'or to upgrade.  This is written in Assembly Language,',0
  1089. line6  dc.b  'and free distribution is encouraged.',0
  1090. line7  dc.b  'by Peter V. Inskeep, NO2D  --  72017,1211.',0
  1091. goodbye     dc.b  'GOOD BYE NOW!',0
  1092. pickgadget  dc.b  'Gadget Picked',0
  1093. pickitem1   dc.b  'Send Faster',0
  1094. pickitem2   dc.b  'Send Slower',0
  1095. pickitem3   dc.b  'Switch Code Source',0
  1096. playmouse   dc.b  'Playing with your Mouse?',0
  1097. consolefail dc.b  'Console.Device Failed to Open',0
  1098. consoleopen dc.b  'Console Opened Successfully',0
  1099. gottamsg   dc.b   'I got a message',0
  1100. ;bitresult  dc.b   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0  ;one extra for null
  1101.    cnop  0,4
  1102. longnull   dc.b   32,0,0,0,0
  1103.    cnop  0,4
  1104. hexprint   dc.b   '$ '
  1105. hexfield   dc.b   'fedc',0  ;five bytes, four used zero ends it
  1106.    cnop  0,4
  1107. ** A border structure to support the erase routine.
  1108.  oneline:
  1109.   dc.w  0,0    ;left & top offsets
  1110.   dc.b  0,0    ;1,2 forground and background pens
  1111.   dc.b  0      ;jam1 drawing modes
  1112.   dc.b  2      ;number of xy coordinates to be drawn
  1113. oneline1  dc.l  0    ;where the coordinates are (onelinelist)
  1114.   dc.l  0      ;next border structure-null if none
  1115. A   cnop   0,4
  1116. onelinelist:
  1117. stx   dc.w  1    ;stuff these with the line starting and ending
  1118. sty   dc.w  1    ;coordinates for each line you want to draw
  1119. endx  dc.w  1    ;then call the border subroutine with the
  1120. endy  dc.w  1    ;oneline border structure address
  1121.    cnop    0,4
  1122. ************** Gadget Rendering Section  **************************;  
  1123. g1txt   dc.b   'Slow',0
  1124. g2txt   dc.b   'Fast',0
  1125.  
  1126. g2itxt:
  1127.    dc.b   1   ft pen
  1128.    dc.b   0   bk pen
  1129.    dc.b   RP_JAM1  draw mode
  1130.    dc.w   0     left edge  ;where the word Fast will print relative
  1131.    dc.w   150         top edge  ;to the top left of gadget box 
  1132.    dc.l   0   font ptr 0=default
  1133.    dc.l   g2txt  text ptr   "Fast"
  1134.    dc.l   0      ptr to next text struct
  1135. g1itxt:
  1136.    dc.b   1   ft pen
  1137.    dc.b   0   bk pen
  1138.    dc.b   RP_JAM1  draw mode
  1139.    dc.w   0    left edge  ;where the word Slow will print
  1140.    dc.w   -10   top edge
  1141.    dc.l   0   font ptr 0=default
  1142.    dc.l   g1txt  text ptr  "Slow"
  1143.    dc.l   g2itxt   ;0      ptr to next text struct
  1144.  
  1145. g1xy:  ;coordinated for drawing the box x first, then y
  1146.    dc.w   10,10
  1147.    dc.w   10,50
  1148.    dc.w   100,50
  1149.    dc.w   100,10
  1150.    dc.w   10,10
  1151.  
  1152. border1:
  1153.    dc.w   200   ;leftedge
  1154.    dc.w   40   ;topedge
  1155.    dc.b   1   ;frontpen
  1156.    dc.b   2   ;backpen
  1157.    dc.b   RP_JAM1   ;drawmode
  1158.    dc.b   5   ;count of xy pairs
  1159.    dc.l   g1xy  ;vector coordinate pairs rel to lefttop
  1160.    dc.l   0
  1161.    cnop   0,4
  1162. image2:
  1163.    dc.w   0,0,64,11,1
  1164.    dc.l   0   ;image data pointer
  1165.    dc.b   1,0
  1166.    dc.l   0
  1167.    cnop   0,4
  1168. image1:
  1169.    dc.w   0    ;left
  1170.    dc.w   0    ;top
  1171.    dc.w   16   ;no. of pixels wide 
  1172.    dc.w   14   ;no. of rows high
  1173.    dc.w   1    ;bitplane depth 1 or 2 for what I am doing use 1
  1174. im1addr   dc.l   0   ;testimage
  1175.    dc.b   1    ;PlanePick
  1176.    dc.b   0    ;PlaneOnOff
  1177.    dc.l   0    ;next image
  1178. prop2:
  1179.    dc.w   prop1flags 
  1180.    dc.w   $3000 ;pi_HorizPot  
  1181.    dc.w   $0   
  1182.    dc.w   $800   
  1183.    dc.w   $0   
  1184.    dc.w   20      
  1185.    dc.w   20      
  1186.    dc.w   500     
  1187.    dc.w   500     
  1188.    dc.w   0   ;g1left   
  1189.    dc.w   0   ;g1top    
  1190. prop1:
  1191.    dc.w   propflags    ;flags  00
  1192.    dc.w   0       ;pi_HorizPot  02
  1193.    dc.w   $6000   ;pi_VertPot   04  ;code speed for propgadget
  1194.    dc.w   $0      ;pi_HorizBody the portion of the total that will  06
  1195.    dc.w   $400    ;pi_VertBody show in the gadget window  08
  1196.    dc.w   20      ;pi_CWidth  0a
  1197.    dc.w   20      ;pi_CHeight  0c
  1198.    dc.w   500     ;pi_HPotRes  0e
  1199.    dc.w   500     ;pi_VPotRes  10
  1200.    dc.w   gleft   ;pi_LeftBorder  12
  1201.    dc.w   gtop    ;pi_TopBorder  14
  1202. gadget2:
  1203.    dc.l   0        ;ptr to next gadget in list
  1204.    dc.w   g1left    ;left edge of gadget relative or absolute
  1205.    dc.w   g1top     ;top edge of gadget relative or absolute
  1206.    dc.w   g1wide    ;width of the gadget itself
  1207.    dc.w   g1high    ;height of the gadget
  1208.    dc.w   gadg1flags!gadg1rel   ;flags
  1209.    dc.w   RELVERIFY!BOTTOMBORDER    ;!TOPBORDER ;activation
  1210.    dc.w   PROPGADGET!GZZGADGET   ;gadget type  (03) & ($2000)
  1211.    dc.l   image2   ;ptr- border, image, or none(0)
  1212.    dc.l   0   ;select render alternate border, image
  1213.    dc.l   0   ;g1itxt   ;gadget text if any
  1214.    dc.l   0   ;mutual exclude
  1215.    dc.l   prop2   ;special info for prop, string and interger gadgets
  1216.    dc.w   1   ;user defined gadget id field
  1217.    dc.l   0   ;pointer to user data
  1218.  
  1219. gadget1:
  1220.    dc.l   gadget2        ;ptr to next gadget in list
  1221.    dc.w   gleft    ;left edge of gadget relative or absolute
  1222.    dc.w   gtop     ;top edge of gadget relative or absolute
  1223.    dc.w   gwide    ;width of the gadget itself
  1224.    dc.w   ghigh    ;height of the gadget
  1225.    dc.w   gadgflags!gadgrel   ;flags
  1226.    dc.w   RELVERIFY!RIGHTBORDER    ;!TOPBORDER ;activation
  1227.    dc.w   PROPGADGET!GZZGADGET   ;gadget type  (03) & ($2000)
  1228.    dc.l   image1   ;ptr- border, image, or none(0)
  1229.    dc.l   0   ;select render alternate border, image
  1230.    dc.l   0   ;g1itxt   ;gadget text if any
  1231.    dc.l   0   ;mutual exclude
  1232.    dc.l   prop1   ;special info for prop, string and interger gadgets
  1233.    dc.w   1   ;user defined gadget id field
  1234.    dc.l   0   ;pointer to user data
  1235.    
  1236. **  A NEW WINDOW STRUCTURE - GADGETUP ADDED 8/27/87  **
  1237. newwindow:
  1238.   dc.w  0,0,640,200   ;Left,Top,Width,Height
  1239.   dc.b  0,1           ;DetailPen, BlockPen
  1240.   dc.l  CLOSEWINDOW!MENUPICK!GADGETUP         ;!FOLLOWMOUSE;IDCMFlags
  1241.   dc.l  MyFlags       ;Flags-described above
  1242.   dc.l  gadget1       ;gadget pointer load yours here 
  1243.   dc.l  0             ;CheckMark    Default
  1244.   dc.l  MyTitle       ;Title-see above
  1245.   dc.l  0             ;Screen: 0=Default
  1246.   dc.l  0             ;BitMap   Default
  1247.   dc.w  50,50,640,200 ;Minwidth,height;Maxwidth,height
  1248.   dc.w  WBENCHSCREEN  ;Type- customscreen is more work
  1249.   cnop   0,4
  1250. onecharbuf  dc.b  0,0,0,0,0,0,0,0  ;buffer for onechar (onecharptr)
  1251.    cnop   0,4
  1252. testmsg  dc.b  'MORSE CODE TEST PROGRAM',13,10
  1253.          dc.b  'by Peter Inskeep - NO2D',13,10
  1254.          dc.b  'Dated January 10, 1987',13,10,13,10
  1255.   dc.b  'Type lower case characters on the keyboard.  Each',13,10
  1256.   dc.b  'character should print on the screen and its morse',13,10
  1257.   dc.b  'code will sound through both speakers.',13,10,10
  1258.   dc.b  'Use the Prop Gadgets at the right edge and the bottom of',13,10
  1259.   dc.b  'the window to change sending speed and pitch.',13,10,10
  1260.   dc.b  'Or, use the Menu to send faster or slower,',13,10
  1261.   dc.b  'or to switch between keyboard and random sending.',13,10,10
  1262.   dc.b  'Have FUN and Learn.',13,10,0
  1263.  
  1264. endline   dc.b  13,10,0
  1265. decitable   dc.w   10000,1000,100,10
  1266. testbuff dc.b  '0',13,10,0
  1267. ;ConsoleDeviceName:
  1268. ;  dc.b  'console.device',0
  1269. ;NotFound:
  1270. ;  dc.b  13,10,'No char-match found',13,10,0
  1271. ;  cnop   0,4
  1272.  
  1273. ** Timing counters for dot and dash sound elements
  1274. elmdelay    dc.l  $0500
  1275. elmdelay1   dc.l  $0002
  1276. dashdelay   dc.l  $0500
  1277. dashdelay1  dc.l  $0006
  1278. charspce    dc.b  2
  1279. wordspce    dc.b  7
  1280. dashlen     dc.b  2         ;we may not need this if we use dashdelay
  1281.  
  1282. alphacode:
  1283.   dc.b  43            ;44 chars in table [0-43]
  1284.   dc.b  '?.,-/=\;'    ;8 char ;=(._._.) \(..._._) ;(_..._)
  1285.   dc.b  '0987654321'  ;10 char
  1286.   dc.b  'jqyzxcpbvflowgdkurhsmnaite',0  ;26 char
  1287. dotdash:
  1288.   dc.b  6,%00001100   ; ?
  1289.   dc.b  6,%00010101   ; .
  1290.   dc.b  6,%00110011   ; ,
  1291.   dc.b  5,%00010001   ; -
  1292.   dc.b  5,%00010010   ; /
  1293.   dc.b  5,%00001010   ; =  .-.-.
  1294.   dc.b  6,%00000101   ; \  ...-.-
  1295.   dc.b  5,%00010001   ; ;  -...-
  1296.   dc.b  5,%00011111   ; 0
  1297.   dc.b  5,%00011110   ; 9
  1298.   dc.b  5,%00011100   ; 8
  1299.   dc.b  5,%00011000   ; 7
  1300.   dc.b  5,%00010000   ; 6
  1301.   dc.b  5,%00000000   ; 5
  1302.   dc.b  5,%00000001   ; 4
  1303.   dc.b  5,%00000011   ; 3
  1304.   dc.b  5,%00000111   ; 2
  1305.   dc.b  5,%00001111   ; 1
  1306.   dc.b  4,%00000111   ; j
  1307.   dc.b  4,%00001101   ; q
  1308.   dc.b  4,%00001011   ; y
  1309.   dc.b  4,%00001100   ; z
  1310.   dc.b  4,%00001001   ; x
  1311.   dc.b  4,%00001010   ; c
  1312.   dc.b  4,%00000110   ; p
  1313.   dc.b  4,%00001000   ; b
  1314.   dc.b  4,%00000001   ; v
  1315.   dc.b  4,%00000010   ; f
  1316.   dc.b  4,%00000100   ; l
  1317.   dc.b  3,%00000111   ; o
  1318.   dc.b  3,%00000011   ; w
  1319.   dc.b  3,%00000110   ; g
  1320.   dc.b  3,%00000100   ; d
  1321.   dc.b  3,%00000101   ; k
  1322.   dc.b  3,%00000001   ; u
  1323.   dc.b  3,%00000010   ; r
  1324.   dc.b  4,%00000000   ; h
  1325.   dc.b  3,%00000000   ; s
  1326.   dc.b  2,%00000011   ; m
  1327.   dc.b  2,%00000010   ; n
  1328.   dc.b  2,%00000001   ; a
  1329.   dc.b  2,%00000000   ; i
  1330.   dc.b  1,%00000001   ; t
  1331.   dc.b  1,%00000000   ; e
  1332.    cnop   0,4  
  1333.   SECTION   IMAGEDATA,DATA
  1334. beginpubmem:  
  1335. theimage:
  1336.    dc.w   %1111111111111111
  1337.    dc.w   %1100000000000011
  1338.    dc.w   %1100001111100011
  1339.    dc.w   %1100010000010011
  1340.    dc.w   %1100010000000011
  1341.    dc.w   %1100001111100011
  1342.    dc.w   %1100000000010011
  1343.    dc.w   %1100000000010011
  1344.    dc.w   %1100010000010011
  1345.    dc.w   %1100001111100011
  1346.    dc.w   %1100000000000011
  1347.    dc.w   %1100000000000011
  1348.    dc.w   %1100000000000011
  1349.    dc.w   %1111111111111111
  1350. imagebytes  equ *-beginpubmem
  1351. pitchimage:
  1352.  dc.w  %1111111111111111,%1111111111111111,%1111111111111111,%1111111111111111
  1353.  dc.w  %1100000000000000,%0000000000000000,%0000000000000000,%0000000000000011
  1354.  dc.w  %1100111110000111,%1111100001111111,%1110000001111000,%0001100000110011
  1355.  dc.w  %1100110001100000,%1100000000000110,%0000000011000110,%0001100000110011
  1356.  dc.w  %1100110001100000,%1100000000000110,%0000000110000000,%0001100000110011
  1357.  dc.w  %1100111110000000,%1100000000000110,%0000000110000000,%0001111111110011
  1358.  dc.w  %1100110000000000,%1100000000000110,%0000000110000000,%0001100000110011
  1359.  dc.w  %1100110000000000,%1100000000000110,%0000000011000110,%0001100000110011
  1360.  dc.w  %1100110000000111,%1111100000000110,%0000000001111000,%0001100000110011
  1361.  dc.w  %1100000000000000,%0000000000000000,%0000000000000000,%0000000000000011
  1362.  dc.w  %1111111111111111,%1111111111111111,%1111111111111111,%1111111111111111
  1363. pitchbytes  equ *-pitchimage
  1364.    dcb.w   50,1
  1365. sizepubmem equ *-beginpubmem
  1366.    cnop 0,4
  1367. beginaudio:  
  1368. Wavesample:
  1369.         dc.b 0,32,64,96,120,120,120,120,120,120,120,120
  1370.         dc.b 90,64,32,0,-32,-64,-90,-120,-120,-120
  1371.         dc.b -120,-120,-120,-120,-120,-120,-96,-64,-32,0
  1372. sizeaudio  equ *-beginaudio
  1373.   SECTION   mem,BSS
  1374. IntuitionLibrary   ds.l  1   ;keep address of Intuition here
  1375. GraphicsLibrary    ds.l  1   ;keep address of Graphics here
  1376. DeviceLibrary      ds.l  1
  1377. DosLibrary    ds.l  1   ;DOS Library pointer
  1378. decinumber    ds.l  1   ;number to become decimal string
  1379. readbufptr    ds.l  1   ;for conread a 0 term string 
  1380. readbuffer    ds.l  100 ;storage for readbufptr
  1381. onecharptr    ds.l  1   ;pointer for one character write buffer
  1382. bufptr        ds.l  1   ;a general buffer pointer
  1383. buffer        ds.l  20  ;a one screen line buffer
  1384. handle        ds.l  1   ;console file read handle
  1385. prtbuff       ds.l  25  ;buffer for special print (end in 0)
  1386. prtptr        ds.l  1   :pointer for the spec.print buffer
  1387. outfile       ds.l  1   ;pointer for output(a6) call
  1388. codecntr      ds.l  1   ;counter for code sending
  1389. kbcntr        ds.l  1   ;counter for keyboard usage (with codecntr)
  1390. ltrcode       ds.l  1   ;store letter number here
  1391. carreturn     ds.l  1   ;holds carriage return in linelen
  1392. MyWindow      ds.l  1   ;address of the structure describing our window
  1393. mywdsize      ds.l  1   ;size of the window 
  1394. bucket        ds.l  1   ;a place to dump things
  1395. intuimessage  ds.l  1   ;pointer to IntuiMessage message structure
  1396. userport      ds.l  1   ;pointer to wd_UserPort structure
  1397. myclass       ds.l  1   ;ICDMP Class or equal to flag ie., MENUPICK
  1398. menupoint     ds.l  1   ;pointer to menu structure
  1399. idcmpmessage  ds.l  1   ;the message class reported by intuimessage
  1400. myrport     ds.l   1   ;this windows rastport
  1401. seconds     ds.l   1   ;seconds in IntuiMessage
  1402. micros      ds.l   1   ;microseconds in IntuiMessage
  1403. keybuf      ds.l  bufferlen    ;keystroke buffer 
  1404. kbptr       ds.l   1   ;keybuf current position pointer
  1405. kbendptr    ds.l   1   ;end of keybuf pointer
  1406. codeptr     ds.l   1   ;code sending current position (not same as kbptr)
  1407. prtachar    ds.l   1   ;need byte, but try this instead
  1408. randflag    ds.l   1   ;random flag 1=keyboard 0=random
  1409. consoleflag  ds.l  1   ;flag for success opening console 0=success
  1410. ioreadbuffer   ds.l   20 ;read buffer 80 characters max
  1411. iowritbuf   ds.l   1   ;one char write buffer, but longword
  1412. ioreadbuf   ds.l   1   ;one char read buffer, but longword
  1413. ioreqptr    ds.l   1   ;pointer to io request block
  1414. ;mygadptr   ds.l   1   ;ptr to regular gadget structure
  1415. ;mypropptr  ds.l   1   ;pointer to proportional gadget info structure
  1416. ranword     ds.l   1   ;a cntr for random word space
  1417. memblock    ds.l   1   ;pointer to image data in memory
  1418. pitchblock  ds.l   1   ;ptr to pitch image data
  1419. audioblock  ds.l   1   ;ptr to audio data block
  1420. lastrandom  ds.l   1   ;store the last random # here
  1421. mousex      ds.w   1   ;x mouse coordinate
  1422. mousey      ds.w   1   ;y mouse coordinate
  1423. mycode      ds.w   1   ;for things line menu# ie, 0,1,2,3, etc.
  1424. infrequency   ds.w   1   ;holds sound frequency fm horizpot
  1425.  
  1426.    END    
  1427.