home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilst / wt_070 / Documents / Examples / 1st_Look / 050_Vectr (.txt) < prev   
Encoding:
RISC OS BBC BASIC V Source  |  1995-04-03  |  5.3 KB  |  124 lines

  1.     Name: 040_Vectr
  2.  Subject: Defining WT Vectors from WT modules.
  3.   Author: GUS
  4.  (make sure you will notice the BASIC example near the end of this file)
  5.     !module_title$   ="1stL_Vectr"
  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. 9  dcd  0                       ; no Broadcast handler
  26. !I  dcd  WTVectors               ; offset to WT Vector definition table
  27. .module_header_end%
  28. $D\__________________________________________________________ help
  29. .module_help%
  30. help(module_title$,module_version$,module_help$)
  31. (O\__________________________________________________________ WT Vector table
  32. *N; WT Vectors are simular to system Vectors but they can defined by ANYONE.
  33. +L; Wacky-Talky can handle up to 1<<27 vectors and each one of them can be
  34. ; claimed unlimited.
  35. .L; WT Vectors can optionally remain after a soft reset and you can deside
  36. /M; the priority of a routine that claims a vector. The last makes you sure
  37. 0P; that a routine attached to a vector will be called before some other which
  38. 1O; claimed the same vactor after the that first routine. Ignoring priorities
  39. 2); WT Vectors behave like system ones.
  40. 4K; If you try to Claim a vector which doesn't exist, the manager creates
  41. ; it for you.
  42. 6R; When you release a vector and your routine was the last one attached to that
  43. 7.; vector, the manager deletes that vector.
  44. 8G; When you Call a vector which doesn't exist, the manager calls the
  45. 9;; WTVector_UnknownVector which by default does nothing.
  46. ;S; WT modules can automatically claim/create WT Vectors if their header contains
  47. <M; such information. The manager will claim/create them after a successful
  48. =S; initialisation of the module and it will release/delete them after the module
  49. ; finalisation.
  50. @P; WT Vectors are used widely by the manager, an example is the WTModule file
  51. A:; protocol which extends the format of WTModule files.
  52. .WTVectors
  53. ED  dcd &123400              ; vector Id and priority bits (31-27)
  54. FP  dcd change_mode + 1      ; offset to vector and vector flags in 2 low bits
  55. G:  dcd 0                    ; R12 when vector is called
  56. HQ                           ; -1 for R12 = pointer to default 12byte workspace
  57. IQ                           ; -2 for R12 = contains of the 1st word of default
  58. JG                           ;              module's 12byte workspace
  59. L#  dcd &123402              ; Id
  60. M'  dcd clear_screen + 1     ; offset
  61. N*  dcd 0                    ; workspace
  62. P#  dcd &123401              ; Id
  63. Q'  dcd about_pixels + 1     ; offset
  64. R*  dcd 0                    ; workspace
  65. T:  dcd -1                   ; no more vectors to define
  66. VQ\__________________________________________________________ vectored routines
  67. .change_mode
  68.   stmfd   13!,{14}
  69. Z,  swi     &20100+22        ; change mode
  70. [   swivc   "XOS_WriteC"     ;
  71.   ldmfd   13!,{15}
  72. .clear_screen
  73.   stmfd   13!,{14}
  74. `-  swi     &2010c           ; clear screen
  75.   ldmfd   13!,{15}
  76. .about_pixels
  77. e2  mov     12,#4288         ; set magic address
  78. f3  ldr     12,[12]          ; read magic address
  79. gB  strb    1,[12,0]         ; use R1 store colour pixel at VRAM
  80.   movs    15,14
  81. jJ\__________________________________________________________ module end
  82. .module_end%
  83. lI\____________________________________________________________________
  84.  Install a WT module from memory
  85. "WT_Install",code%
  86. "OS_File",10,module_path$+module_filename$,&b6f,,code%,O%
  87. _________________________________________________________ sending messages
  88.  Of cource, if you use Token files supported by WTTokens module
  89.  you wont have to remember each vector Id you deal with.
  90.  Here we go the hard way...
  91. "WT_CallAVector",13,,,,,,,,,&123400     :
  92.  change to mode 13
  93. P%=code%
  94. }    [opt2
  95. ~R  mov     0,#0                       ; offset from screen start to store pixel
  96. G  ldr     9,[15]                     ; get vector id to store pixel
  97. 4  mov     15,15                      ; jump data
  98.   dcd     &123401
  99.     .loop
  100. 7  and     1,0,#&ff                   ; pixel colour
  101. S  swi     "WT_CallAVector"           ; call a vector to store a pixel on screen
  102.   add     0,0,#1
  103.   cmp     0,#80*1024
  104.   blt     loop
  105.   mov     15,14
  106. code%
  107. "WT_CallAVector",,,,,,,,,,&123402     :
  108.  clear screen
  109. I_____________________________________________________________________
  110. help(ttl$,version$,hlp$)
  111. hlp$<>"" hlp$=
  112. 13+hlp$
  113.  ttl$<8 ttl$+=
  114. [optp%:=ttl$:=9:=version$
  115. :=" ("+
  116. $,5,11)+") by GUS, for 1st_Look on WT modules"
  117. ph(hlp$):=0:align:]:=0
  118. ph(ps$):
  119. "WT_CallDLRD",p%,"PH_Compress",P%,O%,ps$ 
  120. ,,P%,O%:=0
  121. id(s$):
  122. "WT_Tokenise",,s$ 
  123. ,t%:=t%
  124.