home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / assembly / acchead / acchead.s
Text File  |  1985-11-18  |  5KB  |  171 lines

  1.     move.l a7,a5
  2.     move.l #our_stack,a7
  3.     
  4.     bra main
  5.     
  6.     move.l #0,-(a7)
  7.     trap #1
  8.     
  9. aes    move.l #aespb,d1    * put address of aes parameter block in d1
  10.     move.w #$c8,d0        * aes function number call for op system
  11.     Trap #2            * call extended bdos
  12.     rts            * return from subroutine
  13.     
  14. vdi    move.l #vdipb,d1    * put address of vdi parameter block in d1
  15.     move.w #$73,d0        * vdi function number call for op system
  16.     trap #2            * call extended bdos
  17.     rts
  18.     
  19. main    move.w #10,opcode    * aes op 10= APPL_INIT
  20.     move.w #0,size_intin    * no integer inputs
  21.     move.w #1,size_intout    * 1 integer output i.e ap_id (see later)
  22.     move.w #0,size_addrin    * no address inputs
  23.     move.w #0,size_addrout    * no address outputs
  24.     move.l #0,global_res1    * initialise global reserved variables
  25.     move.l #0,global_res2    * to 0
  26.     move.l #0,global_res3
  27.     move.l #0,global_res4
  28.     jsr aes            * perform aes routine
  29.     move.w intout,ap_id    * save application identifier
  30.  
  31.     move.w #77,opcode    * aes op 77= graf_handle
  32.     move.w #0,size_intin    * no integers input
  33.     move.w #5,size_intout    * 5 integers output 
  34.     move.w #0,size_addrin    * no addresses input
  35.     move.w #0,size_addrout    * no addresses output
  36.     jsr aes            * perform aes routine
  37.     
  38.     move.w intout,gr_handle    * store graphics handle for future ref
  39.     
  40.     move.w #35,opcode    * aes op 35= menu_register
  41.     move.w #1,size_intin    * one integer passed in intin
  42.     move.w #1,size_intout    * one integer output via intout
  43.     move.w #1,size_addrin    * address passed via adrrin
  44.     move.w #0,size_addrout    * no addresses output
  45.     
  46.     move.w ap_id,intin    * pass application identifier to vdi
  47.     move.l #accname,addrin    * pass accessory name to vdi
  48.     
  49.     jsr aes
  50.     move.w intout,menu_id    * save menu identifier for future ref
  51.     
  52. loop_ever    move.w #25,contrl    * aes op 25= evnt_multi
  53.     move.w #16,size_intin    * 16 inputs
  54.     move.w #7,size_intout    * 7 outputs
  55.     move.w #1,size_addrin    * 1 address passed to function
  56.     move.w #0,size_addrout    * 0 addresses out
  57.     
  58.     move.w #%00010011,intin    * set flags for multi
  59.     move.w #1,intin+2    * mouse clicks
  60.     move.w #1,intin+4    * mouse buttons mask
  61.     move.w #1,intin+6    * mouse button state
  62.     move.l #intin+8,a0    * load address of intin into a0
  63.     move.w #10,d0        * load counter
  64. loop1    move.w #0,(a0)+        * set integers to zero
  65.     dbra d0,loop1        * loop to next integer
  66.     move.l #msgbuff,addrin    * pass address of buffer to vdi
  67.     jsr aes            * perform operation
  68.     move.w #%00010000,d0    * bit 4 mesage event flag
  69.     cmp.w intout,d0      * has a message event occurred
  70.     beq acc_open        * check if message is call acc
  71.     bra loop_ever        * if not loop forever
  72.     
  73. acc_open    move.w #40,d0    * AC_OPEN=40
  74.     cmp.w msgbuff,d0    * is event acc open
  75.     beq this_acc        * yes
  76.     bra loop_ever        * no
  77.     
  78. this_acc    move.w menu_id,d0    
  79.     cmp.w msgbuff+8,d0    * Is it ours
  80.     beq op_work        * yes
  81.     bra loop_ever        * no
  82.     
  83.     
  84.     
  85.     
  86. op_work    move.w #100,opcode    * vdi op 100= open virtual workstation
  87.     move.w #0,contrl+2        * no co-ordinates passedto function
  88.     move.w #11,contrl+6    * no of parameters passed through intin
  89.     move.w gr_handle,contrl+12    * pass handle to vdi
  90.     
  91.     move.w #9,d0        * set counter to 9
  92.     move.l #intin,a0    * put address of intin array into a0
  93. loop    move.w #1,(a0)+        * store 1 in first intin positon
  94.     dbra d0,loop        * loop until first 9 integers initialised
  95.     move.w #2,intin+20    * store 2 in intin(10)
  96.     jsr vdi            * perform vdi routine
  97.     
  98. * screen is now ready for your gem program 
  99. * normally we would open a window with only title and a closer
  100. * but let's do something simple e.g an alert mesage
  101.     move.w #52,opcode    * aes op 52= form_alert
  102.     move.w #1,size_intin
  103.     move.w #1,size_intout
  104.     move.w #1,size_addrin
  105.     move.w #0,size_addrout
  106.     
  107.     move.w #1,intin        * make button 1 default exit
  108.     move.l #alert_msg,addrin    * pass string address to aes
  109.     jsr aes
  110.  
  111. * normally after checking for mouse event & click on closer
  112. * we would close window     
  113.     move.w #101,opcode    * vdi op 101= close virtual workstaion
  114.     move.w #0,contrl+2
  115.     move.w #0,contrl+4
  116.     move.w #0,contrl+6
  117.     move.w #0,contrl+8
  118.     move.w gr_handle,contrl+12
  119.     
  120.     jsr vdi
  121.     bra loop_ever
  122.     
  123. * variable storage
  124. * arrays required by gem
  125. aespb    dc.l contrl,global,intin,intout,addrin,addrout
  126. contrl    
  127. opcode    ds.w 1
  128. size_intin    ds.w 1
  129. size_intout    ds.w 1
  130. size_addrin    ds.w 1
  131. size_addrout    ds.l 1
  132.         ds.w 5
  133.  
  134. global
  135. version        ds.w 1
  136. count        ds.w 1
  137. apid        ds.w 1
  138. private        ds.l 1
  139. tree_pointer    ds.l 1
  140. global_res1    ds.l 1
  141. global_res2    ds.l 1
  142. global_res3    ds.l 1
  143. global_res4    ds.l 1
  144.  
  145. intin        ds.w 128
  146. intout        ds.w 128
  147. ptsin        ds.w 128
  148. ptsout        ds.w 128
  149. addrin        ds.w 128
  150. addrout        ds.w 128
  151.  
  152. vdipb        dc.l contrl,intin,ptsin,intout,ptsout
  153.  
  154. * variables required by program
  155.  
  156. gr_handle    ds.w 1
  157. menu_id        ds.w 1
  158. msgbuff        ds.w 16
  159. ap_id        ds.w 1
  160.  
  161.  
  162. accname        dc.b "  OUR_ACC",0
  163. alert_msg    dc.b "[0][HOORAY][ok]",0
  164.  
  165. * reserve space for temporary stack for accessory use
  166.     
  167.         ds.l 64    * should be sufficient
  168. our_stack    ds.l 1
  169.     
  170. * Assemble with Devpac
  171.