home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilst / wt_070 / Documents / Examples / 1st_Look / 040_Broad (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1995-04-02  |  5.8 KB  |  132 lines

  1.     Name: 040_Broad
  2.  Subject: The Broadcast message handler.
  3.   Author: GUS
  4.  (make sure you will notice the BASIC example near the end of this file)
  5.     !module_title$   ="1stL_Broad"
  6. module_version$ ="0.01"
  7. 'module_filename$=
  8. module_title$,10)
  9. +module_path$    ="WTExamples:1st_Look."
  10. 2module_help$    ="Examining Service hadler..."
  11. screen_chunk%=&12345600
  12. pixel_chunk% =&12345700
  13.  code% 5*1024
  14.  p%=4 
  15. O%=code%
  16. [opt p%
  17. F\__________________________________________________________ header
  18. .module_start%
  19. ?  dcd  (module_end%-module_start%) <<8 
  20.  module_header_end%
  21.   =    "WTmd"
  22.   dcd  module_help%
  23. 9  dcd  0                       ; no WTService handler
  24. 7  dcd  0                       ; no Service handler
  25.  H  dcd  Broadcast_handler%      ; offset to Broadcast message handler
  26. .module_header_end%
  27. #D\__________________________________________________________ help
  28. .module_help%
  29. help(module_title$,module_version$,module_help$)
  30. 'Q\__________________________________________________________ Broadcast handler
  31. )F; Broadcast messages can be sent by anyone and they are receive by
  32. *3; the Broadcast message handlers in WT modules.
  33. ,F; Normaly, this hanlder will receive more serious messages and not
  34. -9; 'clear screen' and 'plot pixel' as in this example.
  35. /R; The Broadcast message handler, in order to be fast, should be divided in two
  36. ; parts.
  37. 1N; The first part checks if it can service the message chunk and the second
  38. 22; checks if it can service the message number.
  39. 3N; The second part may appear so many times as the number of the servisable
  40. ; chunks.
  41. 5N; This method allows to check quickly if you can service a message. It can
  42. 6P; easily be used for other hadlers too, one of them is the WTService handler
  43. 7M; which can be used for broadcast messages with chunks bigger than &FFxx.
  44. .Broadcast_handler%
  45. :I  ldr     9,servicable_pixel_chunk%   ; get a Broadcast message chunk
  46. ;F  teq     9,1,lsr#8                   ; can we service this chunk?
  47. <+  beq     about_pixels                ;
  48. =O  ldr     9,servicable_screen_chunk%  ; get another Broadcast message chunk
  49. >E  teq     9,1,lsr#8                   ; can we service this one ?
  50. ?9  movnes  15,14                       ; if not, exit.
  51. AO.about_screen              ; The header of this routine looks dummy in this
  52. BT                           ; example but it jumps to the right routine fast when
  53. CI                           ; you dealling with many message numbers. 
  54. EB  cmp     11,#2            ; maximum servisable message number
  55. F8  addcc   15,15,11,lsl#2   ; jump to service routine
  56. G(  movs    15,14            ; or exit
  57. HJ  b       clear_screen     ; 1st service routine, (2nd,3rd,4th,5th...)
  58. I8                           ;     e.g. this could be:
  59. J9                           ;          b   swap_screen
  60. K:                           ;          b   swap_screens
  61. L5                           ;          b   fade_in
  62. M6                           ;          b   fade_out
  63. OR.change_mode               ; 2nd service routine (the last routine needs no B)
  64.   stmfd   13!,{14}
  65. Q8  swi     &20100+22        ; oh well, change mode...
  66. R   swivc   "XOS_WriteC"     ;
  67. S.  movvc   1,#0             ; claim message
  68.   ldmfd   13!,{15}
  69. .clear_screen
  70.   stmfd   13!,{14}
  71. X-  swi     &2010c           ; clear screen
  72. Y.  movvc   1,#0             ; claim message
  73.   ldmfd   13!,{15}
  74. .about_pixels
  75. ^2  mov     10,#4288         ; set magic address
  76. _3  ldr     10,[10]          ; read magic address
  77. `Q  strb    11,[10,0]        ; use message number to store colour pixel at VRAM
  78. a2                           ; start plus offset
  79. b8                           ; don't claim the message
  80. cL                           ; someone may try to anti-aliase the pixel...
  81.   movs    15,14
  82. .servicable_screen_chunk%
  83. g!  dcd     screen_chunk% >>> 8
  84. .servicable_pixel_chunk%
  85. i!  dcd     pixel_chunk%  >>> 8
  86. jJ\__________________________________________________________ module end
  87. .module_end%
  88. lI\____________________________________________________________________
  89.  Install a WT module from memory
  90. "WT_Install",code%
  91. "OS_File",10,module_path$+module_filename$,&b6f,,code%,O%
  92. _________________________________________________________ sending messages
  93.  Of cource, if you use Token files supported by WTTokens module
  94.  you don't have to remember each message Id you deal with.
  95.  Here we go the hard way...
  96. "WT_SendBroadcastMsg",13,screen_chunk%+1    :
  97.  change to mode 13
  98. P%=code%
  99. ~    [opt2
  100. R  mov     0,#0                       ; offset from screen start to store pixel
  101. <  ldr     1,[15]                     ; get message chunk
  102. 4  mov     15,15                      ; jump data
  103.   dcd     pixel_chunk%
  104. .loop    
  105. P  bic     1,1,#&ff                   ; clear old message number, the message
  106. T                                     ; we send is not claimed so R1 is preserved
  107. Q  and     2,0,#&ff                   ; get new message number, (pixel colour)
  108. 6  orr     1,1,2                      ; make new Id
  109. T  swi     "WT_SendBroadcastMsg"      ; send message to store a pixel on screen..
  110.   add     0,0,#1
  111.   cmp     0,#80*1024
  112.   blt     loop
  113.   mov     15,14
  114. code%
  115. "WT_SendBroadcastMsg",,screen_chunk%    :
  116.  clear screen
  117. I_____________________________________________________________________
  118. help(ttl$,version$,hlp$)
  119. hlp$<>"" hlp$=
  120. 13+hlp$
  121.  ttl$<8 ttl$+=
  122. [optp%:=ttl$:=9:=version$
  123. :=" ("+
  124. $,5,11)+") by GUS, for 1st_Look on WT modules"
  125. ph(hlp$):=0:align:]:=0
  126. ph(ps$):
  127. "WT_CallDLRD",p%,"PH_Compress",P%,O%,ps$ 
  128. ,,P%,O%:=0
  129. id(s$):
  130. "WT_Tokenise",,s$ 
  131. ,t%:=t%
  132.