home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1995-04-02 | 5.8 KB | 132 lines |
- Name: 040_Broad
- Subject: The Broadcast message handler.
- Author: GUS
- (make sure you will notice the BASIC example near the end of this file)
- !module_title$ ="1stL_Broad"
- 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
- H dcd Broadcast_handler% ; offset to Broadcast message handler
- .module_header_end%
- #D\__________________________________________________________ help
- .module_help%
- help(module_title$,module_version$,module_help$)
- 'Q\__________________________________________________________ Broadcast handler
- )F; Broadcast messages can be sent by anyone and they are receive by
- *3; the Broadcast message handlers in WT modules.
- ,F; Normaly, this hanlder will receive more serious messages and not
- -9; 'clear screen' and 'plot pixel' as in this example.
- /R; The Broadcast message handler, in order to be fast, should be divided in two
- ; parts.
- 1N; The first part checks if it can service the message chunk and the second
- 22; checks if it can service the message number.
- 3N; The second part may appear so many times as the number of the servisable
- ; chunks.
- 5N; This method allows to check quickly if you can service a message. It can
- 6P; easily be used for other hadlers too, one of them is the WTService handler
- 7M; which can be used for broadcast messages with chunks bigger than &FFxx.
- .Broadcast_handler%
- :I ldr 9,servicable_pixel_chunk% ; get a Broadcast message chunk
- ;F teq 9,1,lsr#8 ; can we service this chunk?
- <+ beq about_pixels ;
- =O ldr 9,servicable_screen_chunk% ; get another Broadcast message chunk
- >E teq 9,1,lsr#8 ; can we service this one ?
- ?9 movnes 15,14 ; if not, exit.
- AO.about_screen ; The header of this routine looks dummy in this
- BT ; example but it jumps to the right routine fast when
- CI ; you dealling with many message numbers.
- EB cmp 11,#2 ; maximum servisable message number
- F8 addcc 15,15,11,lsl#2 ; jump to service routine
- G( movs 15,14 ; or exit
- HJ b clear_screen ; 1st service routine, (2nd,3rd,4th,5th...)
- I8 ; e.g. this could be:
- J9 ; b swap_screen
- K: ; b swap_screens
- L5 ; b fade_in
- M6 ; b fade_out
- OR.change_mode ; 2nd service routine (the last routine needs no B)
- stmfd 13!,{14}
- Q8 swi &20100+22 ; oh well, change mode...
- R swivc "XOS_WriteC" ;
- S. movvc 1,#0 ; claim message
- ldmfd 13!,{15}
- .clear_screen
- stmfd 13!,{14}
- X- swi &2010c ; clear screen
- Y. movvc 1,#0 ; claim message
- ldmfd 13!,{15}
- .about_pixels
- ^2 mov 10,#4288 ; set magic address
- _3 ldr 10,[10] ; read magic address
- `Q strb 11,[10,0] ; use message number to store colour pixel at VRAM
- a2 ; start plus offset
- b8 ; don't claim the message
- cL ; someone may try to anti-aliase the pixel...
- movs 15,14
- .servicable_screen_chunk%
- g! dcd screen_chunk% >>> 8
- .servicable_pixel_chunk%
- i! dcd pixel_chunk% >>> 8
- 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 don't have to remember each message Id you deal with.
- Here we go the hard way...
- "WT_SendBroadcastMsg",13,screen_chunk%+1 :
- change to mode 13
- P%=code%
- ~ [opt2
- R mov 0,#0 ; offset from screen start to store pixel
- < ldr 1,[15] ; get message chunk
- 4 mov 15,15 ; jump data
- dcd pixel_chunk%
- .loop
- P bic 1,1,#&ff ; clear old message number, the message
- T ; we send is not claimed so R1 is preserved
- Q and 2,0,#&ff ; get new message number, (pixel colour)
- 6 orr 1,1,2 ; make new Id
- T swi "WT_SendBroadcastMsg" ; send message to store a pixel on screen..
- add 0,0,#1
- cmp 0,#80*1024
- blt loop
- mov 15,14
- code%
- "WT_SendBroadcastMsg",,screen_chunk% :
- 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%
-