home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 2
/
DATAFILE_PDCD2.iso
/
utilities2
/
_dirmenu
/
!DirMenu
/
!MakeMod
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-07-27
|
9KB
|
175 lines
This program is run by DirMenu's !RunImage after it has set itself up
as a Wimp task.
It finds the task handles of the Filer and DirMenu and assembles a
module using these task handles. The module is ~ 500 bytes long
The module detects OS mouse button events (not Wimp), and sends an
event_CLICK to DirMenu if the click is with the menu button and is on a
Filer window title-bar.
It also attaches a Filter onto the Filer. If there is an Alt-Menu click
on a Filer windows, the click is sent to DirMenu, and a NULL event is
sent to the Filer.
I'm a bit of a newcomer to ARM assembler, so if my code is crap, please
tell me of any improvements I could make!
/filer_task =
FindTaskHandle( "Filer")
8dirmenu_task =
FindTaskHandle( "Directory Menu")
filer_task = 0
0, "Can't find Filer task"
dirmenu_task = 0
0, "Can't find DirMenu task"
key = 256-3:
codespace 1024
pass=0
P% = 0
O% = codespace
!GL% = codespace + 1024:
prevents assembler from overwriting memory
[ OPT pass+4+8
%Q;************
ULE specs ****************************************************
'9 EQUD 0 ; no startup
EQUD initialise
EQUD finalise
*N EQUD 0 ; no service calls are dealt with
EQUD title
EQUD helpstring
-< EQUD 0 ; no help table
.; EQUD 0 ; no SWI chunk
/= EQUD 0 ; no SWI handler
0; EQUD 0 ; no SWI table
1: EQUD 0 ; no SWI code
4S;********* Storage space for constants etc. ***********************************
6*.filertaskhandle: EQUD filer_task
7,.dirmenutaskhandle: EQUD dirmenu_task
82.pollblock: EQUS
20,
(0)): ALIGN
9=.title: EQUS "DirMenuMouse": EQUB 0: ALIGN
:j.helpstring: EQUS "DirMenuMouse" +
(9) + "0.22 (11 Jul 1993)
Julian Smith": EQUB 0: ALIGN
;8.filtername: EQUS "DirMenu": EQUB 0: ALIGN
<T.mask: EQUD
(1<<6) ; this mask lets through event_CLICK's only
=!.oldbuttonstate: EQUD 0
?S;******************************************************************************
.initialise
STMFD r13!, {r14}
E= MOV r0, #16 ; Claim OS events
F! ADR r1, eventcode
MOV r2, #0
SWI "OS_Claim"
JK MOV r0, #14 ; Enable OS mouse button events
MOV r1, #10
SWI "OS_Byte"
NJ ADR r0, filtername ; attach a filter to the Filer
O" ADR r1, filtercode
ADR r2, 0
Q' LDR r3, filertaskhandle
LDR r4, mask
S/ SWI "Filter_RegisterPostFilter"
LDMFD r13!, {PC}
XS;******************************************************************************
.finalise
STMFD r13!, {R14}
]E MOV r0, #16 ; Stop OS claiming events
^! ADR r1, eventcode
MOV r2, #0
` SWI "OS_Release"
bL MOV r0, #13 ; disable OS mouse button events
cO MOV r1, #10 ; hope nobody else is using them...
SWI "OS_Byte"
fM ADR r0, filtername ; de-register filter on the Filer
g" ADR r1, filtercode
ADR r2, 0
i' LDR r3, filertaskhandle
LDR r4, mask
k1 SWI "Filter_DeRegisterPostFilter"
LDMFD r13!, {PC}
pS;******************************************************************************
rQ.eventcode ; *********** look for menu clicks on filer titlebar ********
tP CMP r0, #10: MOVNES PC, r14 ; return if not a mouse button event
v@ STMFD r13!, {R0-R12, r14} ; save all registers
xC LDR r5, oldbuttonstate ; load old button state
yS
r3, r3, #%111 ; don't know whether higher bits are used
zR STR r3, oldbuttonstate ; store new button state for next time
CMP r5, #%000
}U LDMNEFD r13!, {r0-r12, PC} ; quit if previous button state isn't 000
CMP r3, #%010
X LDMNEFD r13!, {r0-r12, PC} ; quit if new button state isn't 010
K ; button change is from 000 to 010, i.e. menu button click, so:
C MOV r9, PC ; switch to SVC mode...
R r8, r9, #3
TEQP r8, #0
L MOV r0, r0 ; ...and store r14_svc on stack,
M STMFD r13!,{R14} ; because it is corrupted by SWIs
M ADR r1, pollblock ; get info on the window and icon
F SWI "XWimp_GetPointerInfo" ; that the pointer is over
N BVS quit ; in case not in wimp enviroment ?
Q LDR r0, [R1,#16] ; check icon handle is -4 (title bar)
ADD r0, r0, #4
CMP r0, #0
> BNE quit ; quit if it isn't
P MOV r0, #0 ; send a null event to the window to
B ADR r1, pollblock ; find its task handle
Q LDR r2, [R1,#12] ; the task handle will be put into r2
' SWI "XWimp_SendMessage"
N BVS quit ; in case not in wimp enviroment ?
F LDR r5, filertaskhandle ; check if the task handle
: CMP r2, r5 ; is the filer
> BNE quit ; quit if it isn't
J MOV r0, #6 ; everything is OK, so send an
K ADR r1, pollblock ; event_CLICK to DirMenu, using
L LDR r2, dirmenutaskhandle ; the pointer info found earlier
' SWI "XWimp_SendMessage"
N BVS quit ; in case not in wimp enviroment ?
.quit
= LDMFD r13!, {R14} ; restore r14_svc
F TEQP r9, #0 ; switch back to User mode
MOV r0, r0
J LDMFD r13!, {R0-R12, PC} ; restore registers and return
S;******************************************************************************
..filtercode ; look for Alt-Menu clicks
3 ; pollblock is pointed to by r1
Q LDR r2, [R1,#8] ; event will be event_CLICK, so mouse
K TST r2,#2 ; button info is at pollblock!8
O
Q PC,R14 ; return if Menu button is not pressed
R STMFD r13!, {R0-R1,R14} ; only need to preserve r0,R1 for poll
L MOV r0,#129 ; test for alt key using OS_Byte
MOV r2,#255
K MOV r1,#key ; Code for key to be tested for
SWI "OS_Byte"
CMP r2, #255:
J LDMNEFD r13!,{R0-R1,PC} ; return if alt is not pressed
V LDMFD r13,{R0-R1} ; re-load message block intended for Filer
S LDR r2, dirmenutaskhandle ; ...and send it straight on to DirMenu
& SWI "Wimp_SendMessage"
K LDMFD r13!,{R0-R1} ; re-load message block in case
E ; SendMessage corrupts it
G MOV r0, #0 ; change it to a Null event
H LDMFD r13!,{PC} ; and pass it on to Filer...
S;******************************************************************************
pass
Install the module in RMA area.
"OS_Module", 11, codespace, P%
FindTaskHandle( task_name$)
buff_len, buffer, r0, r1, r2
%buff_len = 256:
buffer buff_len
r0 = 0
r1 = buffer: r2 = 16
"TaskManager_EnumerateTasks", r0, r1, r2
r0=-1 = 0
string( buffer!4) = task_name$
=!buffer
string( x)
i,c, a$
i=0
c = ?(x+i)
c=0
a$ = a$ +