home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / shareware / share_46 / sasm / Demo / MainCode < prev    next >
Text File  |  1994-03-21  |  4KB  |  102 lines

  1.  
  2.         ;xxxxxxxxxxxxxxxxxxxxxxxxxxxx
  3.         ;  Actual application code
  4.         ;xxxxxxxxxxxxxxxxxxxxxxxxxxxx
  5. .entry  adrl r1,task
  6.         ldr r1,[r1]                     ;load 'TASK' into r1
  7.         mov r0,200                      ;will work with Wimp version 2.00
  8.         adrl r2,title                   ;r2 points to title string
  9.         swi Wimp_Initialise             ;declare task to Wimp
  10.         adrl dp,data                    ;set up Data Pointer register
  11.         str r1,[dp,#TaskHandle]         ;store task handle returned by Wimp
  12.         adrl sp,stack+&40               ;set up stack pointer to top of stack
  13.         adrl r1,block
  14.         str r1,[dp,#BlockPtr]           ;store pointer to Wimp transfer block
  15.  
  16.         ;----- put the icon on the icon bar -----
  17.         adrl r1,icon_data               ;point to icon data
  18.         swi Wimp_CreateIcon             ;declare icon to Wimp
  19.         str r0,[dp,#IconHandle]         ;store icon handle returned from Wimp
  20.  
  21.         ;----- main Wimp Poll loop -----
  22. .poll_loop
  23.         mov r0,#PollMask        
  24.         ldr r1,[dp,#BlockPtr]
  25.         swi Wimp_Poll
  26.  
  27.         ;----- check the reason codes returned by Wimp -----
  28.         cmp r0,1
  29.         beq redraw_request              ;redraw window request returned
  30.         cmp r0,2
  31.         beq openwindow_request          ;open window request returned
  32.         cmp r0,3
  33.         beq closewindow_request         ;close window request returned
  34.         cmp r0,6
  35.         beq click                       ;mouse click
  36.         cmp r0,9
  37.         beq menu_selection              ;mouse click on the menu
  38.         cmp r0,17
  39.         cmpne r0,18
  40.         bne poll_loop                   ;nothing to do
  41.         
  42.         ;----- Message received -----
  43.         ldr r0,[r1,#16]                 ;get message type at block+16
  44.         cmp r0,0
  45.         beq die                         ;shut-down request
  46.         bal poll_loop                   ;no other messages expected
  47.  
  48.         ;----- Mouse click on an icon -----
  49. .click  ldr r2,[r1,#12]                 ;get window handle at block+12
  50.         cmn r2,#2                       ;if it's -1 it's the icon bar
  51.         bne poll_loop                   ;only the icon bar valid
  52. .00     ldrb r0,[r1,#8]                 ;get mouse button (dummy 00 label)
  53.         cmp r0,2
  54.         beq 10                          ;'menu' used so open the menu
  55.         cmp r0,4
  56.         beq 20                          ;'select' used 
  57.         bal poll_loop
  58.  
  59.         ;----- Mouse click on icon with 'menu' ------
  60. .10     ldr r2,[r1]                     ;get mouse X position
  61.         sub r2,r2,#100
  62.         mov r3,260                      ;r3 = height of menu
  63.         adrl r1,main_menu               ;point to menu structure
  64.         swi Wimp_CreateMenu             ;open the menu
  65.         bal poll_loop
  66.  
  67.         ;----- Mouse click on icon with 'select' ------
  68. .20     mov r1,2
  69.         bal report                      ;display the message box
  70.  
  71.  
  72.         ;----- Selection made from menu -----
  73. .menu_selection
  74.         ldr r0,[r1]                     ;get item number at block+0
  75.         cmp r0,0
  76.         cmpne r0,1                      ;if it's item 0 or 1 then transfer the
  77.         moveq r1,r0                     ;menu item selected to r1 to show the 
  78.         beq report                      ;appropriate message and go to 'report' 
  79.         cmp r0,2
  80.         beq die                         ;quit selected
  81.         bal poll_loop
  82.  
  83.         ;---- Close down the task -----
  84. .die    adrl r1,task
  85.         ldr r1,[r1]                     ;put 'TASK' in r1
  86.         ldr r0,[dp,#TaskHandle]         ;put task handle in r0
  87.         swi Wimp_CloseDown              ;quit
  88.         swi OS_Exit
  89.  
  90. .redraw_request
  91.         swi Wimp_RedrawWindow           ;actually no windows to redraw
  92.         bal poll_loop                   ;so just refer the call back to the Wimp
  93.  
  94. .openwindow_request
  95.         swi Wimp_CloseWindow            ;actually no windows to close
  96.         bal poll_loop                   ;so just refer the call back to the Wimp
  97.  
  98. .closewindow_request
  99.         swi Wimp_OpenWindow             ;actually no windows to open
  100.         bal poll_loop                   ;so just refer the call back to the Wimp
  101.  
  102.