home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-04-03 | 5.3 KB | 124 lines |
- Name: 040_Vectr
- Subject: Defining WT Vectors from WT modules.
- Author: GUS
- (make sure you will notice the BASIC example near the end of this file)
- !module_title$ ="1stL_Vectr"
- module_version$ ="0.01"
- 'module_filename$=
- module_title$,10)
- +module_path$ ="WTExamples:1st_Look."
- 2module_help$ ="Examining Service hadler..."
- screen_chunk%=&12345600
- pixel_chunk% =&12345700
- code% 5*1024
- p%=4
- O%=code%
- [opt p%
- F\__________________________________________________________ header
- .module_start%
- ? dcd (module_end%-module_start%) <<8
- module_header_end%
- = "WTmd"
- dcd module_help%
- 9 dcd 0 ; no WTService handler
- 7 dcd 0 ; no Service handler
- 9 dcd 0 ; no Broadcast handler
- !I dcd WTVectors ; offset to WT Vector definition table
- .module_header_end%
- $D\__________________________________________________________ help
- .module_help%
- help(module_title$,module_version$,module_help$)
- (O\__________________________________________________________ WT Vector table
- *N; WT Vectors are simular to system Vectors but they can defined by ANYONE.
- +L; Wacky-Talky can handle up to 1<<27 vectors and each one of them can be
- ; claimed unlimited.
- .L; WT Vectors can optionally remain after a soft reset and you can deside
- /M; the priority of a routine that claims a vector. The last makes you sure
- 0P; that a routine attached to a vector will be called before some other which
- 1O; claimed the same vactor after the that first routine. Ignoring priorities
- 2); WT Vectors behave like system ones.
- 4K; If you try to Claim a vector which doesn't exist, the manager creates
- ; it for you.
- 6R; When you release a vector and your routine was the last one attached to that
- 7.; vector, the manager deletes that vector.
- 8G; When you Call a vector which doesn't exist, the manager calls the
- 9;; WTVector_UnknownVector which by default does nothing.
- ;S; WT modules can automatically claim/create WT Vectors if their header contains
- <M; such information. The manager will claim/create them after a successful
- =S; initialisation of the module and it will release/delete them after the module
- ; finalisation.
- @P; WT Vectors are used widely by the manager, an example is the WTModule file
- A:; protocol which extends the format of WTModule files.
- .WTVectors
- ED dcd &123400 ; vector Id and priority bits (31-27)
- FP dcd change_mode + 1 ; offset to vector and vector flags in 2 low bits
- G: dcd 0 ; R12 when vector is called
- HQ ; -1 for R12 = pointer to default 12byte workspace
- IQ ; -2 for R12 = contains of the 1st word of default
- JG ; module's 12byte workspace
- L# dcd &123402 ; Id
- M' dcd clear_screen + 1 ; offset
- N* dcd 0 ; workspace
- P# dcd &123401 ; Id
- Q' dcd about_pixels + 1 ; offset
- R* dcd 0 ; workspace
- T: dcd -1 ; no more vectors to define
- VQ\__________________________________________________________ vectored routines
- .change_mode
- stmfd 13!,{14}
- Z, swi &20100+22 ; change mode
- [ swivc "XOS_WriteC" ;
- ldmfd 13!,{15}
- .clear_screen
- stmfd 13!,{14}
- `- swi &2010c ; clear screen
- ldmfd 13!,{15}
- .about_pixels
- e2 mov 12,#4288 ; set magic address
- f3 ldr 12,[12] ; read magic address
- gB strb 1,[12,0] ; use R1 store colour pixel at VRAM
- movs 15,14
- jJ\__________________________________________________________ module end
- .module_end%
- lI\____________________________________________________________________
- Install a WT module from memory
- "WT_Install",code%
- "OS_File",10,module_path$+module_filename$,&b6f,,code%,O%
- _________________________________________________________ sending messages
- Of cource, if you use Token files supported by WTTokens module
- you wont have to remember each vector Id you deal with.
- Here we go the hard way...
- "WT_CallAVector",13,,,,,,,,,&123400 :
- change to mode 13
- P%=code%
- } [opt2
- ~R mov 0,#0 ; offset from screen start to store pixel
- G ldr 9,[15] ; get vector id to store pixel
- 4 mov 15,15 ; jump data
- dcd &123401
- .loop
- 7 and 1,0,#&ff ; pixel colour
- S swi "WT_CallAVector" ; call a vector to store a pixel on screen
- add 0,0,#1
- cmp 0,#80*1024
- blt loop
- mov 15,14
- code%
- "WT_CallAVector",,,,,,,,,,&123402 :
- clear screen
- I_____________________________________________________________________
- help(ttl$,version$,hlp$)
- hlp$<>"" hlp$=
- 13+hlp$
- ttl$<8 ttl$+=
- [optp%:=ttl$:=9:=version$
- :=" ("+
- $,5,11)+") by GUS, for 1st_Look on WT modules"
- ph(hlp$):=0:align:]:=0
- ph(ps$):
- "WT_CallDLRD",p%,"PH_Compress",P%,O%,ps$
- ,,P%,O%:=0
- id(s$):
- "WT_Tokenise",,s$
- ,t%:=t%
-