home *** CD-ROM | disk | FTP | other *** search
-
- AREA |Module$$Code|, CODE, READONLY
- GET OS:hdr.OSModule
- GET OS:hdr.Wimp
- GET OS:hdr.WimpReadSysInfo
- GET hdr.ibpatch
- GET hdr.debug
-
-
- ; The following SWIs are patched.
- ; Details of what they are patched to do are given below:
-
- EXPORT pre_wimp_createicon
- EXPORT pre_wimp_deleteicon
- EXPORT pre_wimp_createmenu
- EXPORT pre_wimp_getwindowstate
- EXPORT pre_wimp_getwindowinfo
- EXPORT pre_wimp_seticonstate
- EXPORT pre_wimp_geticonstate
- EXPORT pre_wimp_forceredraw
- EXPORT pre_wimp_whichicon
- EXPORT pre_wimp_dragbox
- EXPORT pre_wimp_getwindowoutline
- EXPORT pre_wimp_sendmessage
- EXPORT post_wimp_getpointerinfo
- EXPORT pre_wimp_resizeicon
-
-
- ; Patch Wimp_CreateIcon
- ; If you try to create an iconbar icon, the request is queued.
- ; A unique iconbar icon handle is returned, and our counter incremented.
-
- pre_wimp_createicon
- createicon_extra RN 6
- createicon_block RN 7
- createicon_element RN 8
-
- stmfd sp!, {r0-r3, r6-r8, lr}
- ldr r2, [r1, #0]
- cmp r2, #-1
- cmpne r2, #-2
- cmpne r2, #-3
- cmpne r2, #-4
- cmpne r2, #-5
- cmpne r2, #-6
- cmpne r2, #-7
- cmpne r2, #-8
- ldmnefds sp!, {r0-r3, r6-r8, pc}
-
- DEBUG_MSG "Wimp_CreateIcon called for iconbar, returned handle ", 0
-
- mov createicon_extra, r0
- mov createicon_block, r1
-
- ; create new element to add
- mov r0, #OSModule_Alloc
- mov r3, #element_add_size
- swi XOS_Module
- bvs pre_wimp_createicon_error
- mov createicon_element, r2
- mov r0, #element_add_type
- str r0, [createicon_element, #element_type]
- mov r0, #0
- str r0, [createicon_element, #element_next]
-
- ; store the icon's position and priority
- ldr r0, [createicon_block, #0]
- str r0, [createicon_element, #element_add_position]
- str createicon_extra, [createicon_element, #element_add_priority]
-
- ; copy icon flags
- ldr r0, [createicon_block, #20]
- str r0, [createicon_element, #element_add_icon_flags]
- ; copy icon data
- ldr r0, [createicon_block, #24+(4*0)]
- str r0, [createicon_element, #element_add_icon_data+(4*0)]
- ldr r0, [createicon_block, #24+(4*1)]
- str r0, [createicon_element, #element_add_icon_data+(4*1)]
- ldr r0, [createicon_block, #24+(4*2)]
- str r0, [createicon_element, #element_add_icon_data+(4*2)]
-
- ; store and update icon handle
- ldr r0, [r12, #block_icon_count]
- DEBUG_INT r0
- DEBUG_MSG "", 10
- str r0, [createicon_element, #element_add_icon]
- mov r9, r0
- add r0, r0, #1
- str r0, [r12, #block_icon_count]
-
- ; store task handle
- mov r0, #WimpReadSysInfo_Task
- swi XWimp_ReadSysInfo
- bvs pre_wimp_createicon_error
- str r0, [createicon_element, #element_add_task]
-
- ; add element at end of list
- ldr r1, [r12, #block_list_end]
- str createicon_element, [r1]
- add r0, createicon_element, #element_next
- str r0, [r12, #block_list_end]
-
- ; increment count of list elements
- ldr r0, [r12, #block_list_count]
- add r0, r0, #1
- str r0, [r12, #block_list_count]
-
- ; and return
- ldmfd sp!, {r0-r3, r6-r8, lr}
- mov r0, r9
- mov r9, #-1
- movs pc, lr
- pre_wimp_createicon_error
- mov r12, r0
- ldmfd sp!, {r0-r3, r6-r8, lr}
- mov r0, r12
- mov r9, #-1
- mov pc, lr
-
-
- ; Patch Wimp_DeleteIcon
- ; Queues requests to delete iconbar icons.
- ; This means that invalid icon handles are not caught, but that doesn't
- ; really matter.
-
- pre_wimp_deleteicon
- deleteicon_block RN 7
- deleteicon_element RN 8
-
- stmfd sp!, {r0-r3, r7-r8, lr}
- ldr r0, [r1, #0]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r3, r7-r8, pc}
-
- DEBUG_MSG "Wimp_DeleteIcon called for the iconbar, handle ", 0
-
- mov deleteicon_block, r1
-
- ; create new element to add
- mov r0, #OSModule_Alloc
- mov r3, #element_remove_size
- swi XOS_Module
- mov deleteicon_element, r2
- mov r0, #element_remove_type
- str r0, [deleteicon_element, #element_type]
- mov r0, #0
- str r0, [deleteicon_element, #element_next]
-
- ; copy icon handle
- ldr r0, [deleteicon_block, #4]
- DEBUG_INT r0
- DEBUG_MSG "", 10
- str r0, [deleteicon_element, #element_remove_icon]
-
- ; add element at end of list
- ldr r1, [r12, #block_list_end]
- str deleteicon_element, [r1]
- add r0, deleteicon_element, #element_next
- str r0, [r12, #block_list_end]
-
- ; increment count of list elements
- ldr r0, [r12, #block_list_count]
- add r0, r0, #1
- str r0, [r12, #block_list_count]
-
- ; and return
- mov r9, #-1
- ldmfds sp!, {r0-r3, r7-r8, pc}
-
-
- ; Patch Wimp_CreateMenu
- ; The position of the menu can be shifted by a given amount, and
- ; its title can even be removed if you want.
-
- pre_wimp_createmenu
- DEBUG_MSG "Wimp_CreateMenu called and adjusted", 10
-
- ; move x co-ordinate
- stmfd sp!, {r4-r5, lr}
- ldr r4, [r12, #block_x_offset]
- add r2, r2, r4
-
- ; move y co-ordinate
- ldr r5, [r12, #block_flags]
- and r5, r5, #block_flag_y_absolute
- cmp r5, #0
- ldr r4, [r12, #block_y_offset]
- addeq r3, r3, r4
- movne r3, r4
-
- ; remove title if necessary
- ldr r5, [r12, #block_flags]
- and r5, r5, #block_flag_remove_title
- cmp r5, #0
- movne r4, #0
- strneb r4, [r1]
-
- ; reset values
- mov r4, #0
- str r4, [r12, #block_x_offset]
- str r4, [r12, #block_y_offset]
- ldmfds sp!, {r4-r5, pc}
-
-
- ; Patch Wimp_GetWindowState
- ; If someone tries to read the state of the iconbar, they'll get the
- ; pre-recorded state set by our client task. It isn't very useful, but
- ; Alarm seems to need it.
-
- pre_wimp_getwindowstate
- stmfd sp!, {r0-r5, lr}
- ; is this operating on the iconbar?
- ldr r0, [r1]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r5, pc}
-
- DEBUG_MSG "Wimp_GetWindowState called for the iconbar", 10
-
- ; fill out the block from what we've been told
- ; r0 is the source, r1 is the destination
- add r0, r12, #block_iconbar_state + 4
- add r1, r1, #4
- ; transfer 32 bytes
- ldmia r0!, {r2-r5}
- stmia r1!, {r2-r5}
- ldmia r0!, {r2-r5}
- stmia r1!, {r2-r5}
- ; and return, claiming the SWI with a smile on our faces
- mov r9, #-1
- ldmfds sp!, {r0-r5, pc}
-
-
- ; Patch Wimp_GetWindowInfo
- ; If called for the iconbar, this will return initially the same info as
- ; Wimp_GetWindowState. Beyond that, the rest of the block will be zeroed.
- ; It won't list icons. Not terribly useful.
-
- pre_wimp_getwindowinfo
- stmfd sp!, {r0-r5, lr}
- ; is this operating on the iconbar?
- ; make sure to clear the option bit of r1 first
- bic r1, r1, #1
- ldr r0, [r1]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r5, pc}
-
- DEBUG_MSG "Wimp_GetWindowInfo called for the iconbar", 10
-
- ; fill out the block from what we've been told
- ; the first 32 bytes (after the handle) are as for GetWindowState
- ; r0 is the source, r1 is the destination
- add r0, r12, #block_iconbar_state + 4
- add r1, r1, #4
- ; transfer 32 bytes
- ldmia r0!, {r2-r5}
- stmia r1!, {r2-r5}
- ldmia r0!, {r2-r5}
- stmia r1!, {r2-r5}
- ; now fill the rest with zeros (56 bytes worth)
- ; if you were looking for an icon list, that's tough
- mov r2, #0
- mov r3, #0
- mov r4, #0
- mov r5, #0
- stmia r1!, {r2-r5}
- stmia r1!, {r2-r5}
- stmia r1!, {r2-r5}
- stmia r1!, {r2-r3}
- ; and return, claiming the SWI with fingers crossed
- mov r9, #-1
- ldmfds sp!, {r0-r5, pc}
-
- ;; complain atm
- ; ldmfd sp!, {r0-r1, lr}
- ; adr r0, error_get_window_info
- ; mov r9, #-1
- ; orrs pc, lr, #V
- ;
- ;; our complaint
- ;error_get_window_info
- ; DCD 0
- ; = "IconbarPatch can't handle Wimp_GetWindowInfo on the iconbar", 0
- ; ALIGN
-
-
- ; Patch Wimp_SetIconState
- ; If this applies to the iconbar, the call is queued.
- ; Bad icon handles will not be noticed at this stage.
-
- pre_wimp_seticonstate
- seticonstate_block RN 7
- seticonstate_element RN 8
-
- stmfd sp!, {r0-r3, r7-r8, lr}
- ldr r0, [r1, #0]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r3, r7-r8, pc}
-
- DEBUG_MSG "Wimp_SetIconState called for the iconbar, handle ", 0
-
- mov seticonstate_block, r1
-
- ; create new element to add
- mov r0, #OSModule_Alloc
- mov r3, #element_update_size
- swi XOS_Module
- mov seticonstate_element, r2
- mov r0, #element_update_type
- str r0, [seticonstate_element, #element_type]
- mov r0, #0
- str r0, [seticonstate_element, #element_next]
-
- ; copy icon handle
- ldr r0, [seticonstate_block, #4]
- DEBUG_INT r0
- DEBUG_MSG "", 10
- str r0, [seticonstate_element, #element_update_icon]
-
- ; copy bic and eor words
- ldr r0, [seticonstate_block, #12]
- str r0, [seticonstate_element, #element_update_bic]
- ldr r0, [seticonstate_block, #8]
- str r0, [seticonstate_element, #element_update_eor]
-
- ; add element at end of list
- ldr r1, [r12, #block_list_end]
- str seticonstate_element, [r1]
- add r0, seticonstate_element, #element_next
- str r0, [r12, #block_list_end]
-
- ; increment count of list elements
- ldr r0, [r12, #block_list_count]
- add r0, r0, #1
- str r0, [r12, #block_list_count]
-
- ; and return
- mov r9, #-1
- ldmfds sp!, {r0-r3, r7-r8, pc}
-
-
- ; Patch Wimp_GetIconState
- ; If this is applied to the iconbar, it will return some bogus information.
- ; This is necessary to get Alarm to accept iconbar mouse clicks. It seems
- ; to want to know the x co-ordinates of the icon.
-
- pre_wimp_geticonstate
- stmfd sp!, {r0-r3, lr}
- ldr r0, [r1]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r3, pc}
-
- [ :DEF:DEBUG
- DEBUG_MSG "Wimp_GetIconState called for the iconbar, handle ", 0
- ldr r0, [r1, #4]
- DEBUG_INT r0
- ]
-
- ; fill in bogus bounding box information
- mov r0, #1000
- str r0, [r1, #8 + 0]
- add r0, r0, #68
- str r0, [r1, #8 + 8]
- mov r0, #0
- str r0, [r1, #8 + 4]
- add r0, r0, #68
- str r0, [r1, #8 + 12]
-
- ; look for this icon in the queue of icons to add
- ; r2 is a pointer to the current element
- ldr r2, [r12, #block_list_begin]
- pre_wimp_geticonstate_loop
- ; if this is the end, fill in zero icon flags and data
- cmp r2, #0
- beq pre_wimp_geticonstate_bogus
- ; if this isn't the add type, look at the next element
- ldr r0, [r2, #element_type]
- cmp r0, #element_add_type
- ; if this isn't the right icon handle either, look at the next element
- ldreq r0, [r2, #element_add_icon]
- ldreq r3, [r1, #4]
- cmpeq r0, r3
- ; right, we're going to look at the next element then
- ldrne r2, [r2, #element_next]
- bne pre_wimp_geticonstate_loop
- ; this is the add type, so fill in correct info
- ldr r0, [r2, #element_add_icon_flags]
- str r0, [r1, #8 + 16]
- ldr r0, [r2, #element_add_icon_data + 0]
- str r0, [r1, #8 + 16 + 4 + 0]
- ldr r0, [r2, #element_add_icon_data + 4]
- str r0, [r1, #8 + 16 + 4 + 4]
- ldr r0, [r2, #element_add_icon_data + 8]
- str r0, [r1, #8 + 16 + 4 + 8]
- DEBUG_MSG ", good info", 10
- ; and finish
- b pre_wimp_geticonstate_finish
-
- ; fill in zero icon flags and data
- pre_wimp_geticonstate_bogus
- mov r0, #0
- str r0, [r1, #8 + 16]
- str r0, [r1, #8 + 20]
- str r0, [r1, #8 + 24]
- str r0, [r1, #8 + 28]
- DEBUG_MSG ", bogus info", 10
-
- ; claim the SWI and joyously return
- pre_wimp_geticonstate_finish
- mov r9, #-1
- ldmfds sp!, {r0-r3, pc}
-
-
- ; Patch Wimp_ForceRedraw
- ; This is ignored if applied to the iconbar, with no error.
- ; It doesn't matter, because ForceRedrawing the iconbar isn't very useful
- ; (you don't know where your icon will be) -- people should use
- ; Wimp_SetIconState instead.
-
- pre_wimp_forceredraw
- ; simply mask out if it applies to iconbar
- cmp r0, #-2
- moveq r9, #-1
- [ :DEF:DEBUG
- beq pre_wimp_forceredraw_debug
- ]
- movs pc, lr
-
- [ :DEF:DEBUG
- pre_wimp_forceredraw_debug
- DEBUG_MSG "Wimp_ForceRedraw called for the iconbar -- ignored", 10
- movs pc, lr
- ]
-
-
- ; Patch Wimp_WhichIcon
- ; Give an error if applied to the iconbar.
- ; This call really is especially useless on the iconbar, and I shouldn't
- ; think anyone uses it luckily (it only returns for your own icons, so its
- ; most useful task -- finding the iconbar icons that exist -- is ruled out).
-
- pre_wimp_whichicon
- ; does it apply to the iconbar?
- cmp r0, #-2
- cmpne r0, #-1
- movnes pc, lr
-
- ; yes, it does
- DEBUG_MSG "Wimp_WhichIcon called for the iconbar -- error", 10
- adr r0, error_which_icon
- mov r9, #-1
- orrs pc, lr, #V
-
- ; our complaint
- error_which_icon
- DCD 0
- = "IconbarPatch can't handle Wimp_WhichIcon on the iconbar", 0
- ALIGN
-
-
- ; Patch Wimp_DragBox
- ; This can allegedly be applied to the iconbar, but no-one does, and it's
- ; horrible anyway. So we return an error.
-
- pre_wimp_dragbox
- ; does it apply to iconbar?
- stmfd sp!, {r0-r1, lr}
- ; if this is a drag cancellation, let it through
- cmp r1, #0
- ldmlefds sp!, {r0-r1, pc}
- ; if this doesn't apply to the iconbar, let it through
- ldr r0, [r1]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r1, pc}
-
- ; complain if it does
- DEBUG_MSG "Wimp_DragBox called for the iconbar -- error", 10
- ldmfd sp!, {r0-r1, lr}
- adr r0, error_drag_box
- mov r9, #-1
- orrs pc, lr, #V
-
- ; our complaint
- error_drag_box
- DCD 0
- = "IconbarPatch can't handle Wimp_DragBox with respect to the iconbar", 0
- ALIGN
-
-
- ; Patch Wimp_SendMessage
- ; This patch is complementary to the one for Wimp_GetPointerInfo. That
- ; made our client's iconbar look like the real iconbar, now this forwards
- ; messages to iconbar icons onto their owners.
-
- pre_wimp_sendmessage
- ; was this message sent to an iconbar icon?
- stmfd sp!, {r0, lr}
- cmp r2, #-2
- ldmnefds sp!, {r0, pc}
-
- DEBUG_MSG "Wimp_SendMessage called for the iconbar", 10
-
- ; now check that the icon passed is the one we know about
- ldr r0, [r12, #block_pointer_icon]
- cmp r0, r3
- ; if it is, change the iconbar handle to the correct task handle and return
- ldreq r2, [r12, #block_pointer_task]
- ldmeqfds sp!, {r0, pc}
-
- ; if it isn't the icon we know about, panic with an error
- ldmfd sp!, {r0, lr}
- adr r0, error_send_message
- mov r9, #-1
- orrs pc, lr, #V
-
- ; our complaint
- error_send_message
- DCD 0
- = "IconbarPatch couldn't handle a Wimp_SendMessage to the iconbar because "
- = "it didn't know about the icon in question", 0
- ALIGN
-
-
- ; Patch Wimp_GetWindowOutline
- ; This is sometimes used in the same way as Wimp_GetWindowState on the
- ; iconbar. In particular, ResEd uses it. Luckily, we can use the same
- ; data provided by the client for Wimp_GetWindowState to fill a reply in.
-
- pre_wimp_getwindowoutline
- ; does it apply to iconbar?
- stmfd sp!, {r0-r1, lr}
- ldr r0, [r1]
- cmp r0, #-2
- cmpne r0, #-1
- ldmnefds sp!, {r0-r1, pc}
-
- DEBUG_MSG "Wimp_GetWindowOutline called for the iconbar", 10
-
- ; if it does, fill out the block: copy co-ordinates
- ldr r0, [r12, #block_iconbar_state + 4]
- str r0, [r1, #4]
- ldr r0, [r12, #block_iconbar_state + 8]
- str r0, [r1, #8]
- ldr r0, [r12, #block_iconbar_state + 12]
- str r0, [r1, #12]
- ldr r0, [r12, #block_iconbar_state + 16]
- str r0, [r1, #16]
- ; and return, whilst claiming the SWI as one of our own
- mov r9, #-1
- ldmfds sp!, {r0-r1, pc}
-
-
- ; Patch Wimp_GetPointerInfo
- ; This fiddles the returned data to make our client's window appear to be
- ; the iconbar. If the window handles match, it changes the returned window
- ; handle to the iconbar, and the icon handle to the one our client fills in.
-
- post_wimp_getpointerinfo
- ; is the pointer over the window we want to patch?
- stmfd sp!, {r2-r3, lr}
- ldr r2, [r1, #12]
- ldr r3, [r12, #block_window]
- cmp r2, r3
- ldmnefd sp!, {r2-r3, pc}
-
- [ :DEF:DEBUG
- DEBUG_MSG "Wimp_GetPointerInfo called for the iconbar, changed icon handle ", 0
- ldr r3, [r1, #16]
- DEBUG_INT r3
- DEBUG_MSG " to ", 0
- ldr r3, [r12, #block_pointer_icon]
- DEBUG_INT r3
- DEBUG_MSG "", 10
- ]
-
- ; if so, fill in the altered icon handle
- ldr r3, [r12, #block_pointer_icon]
- str r3, [r1, #16]
- ; and change the window handle
- mov r3, #-2
- str r3, [r1, #12]
- ldmfd sp!, {r2-r3, pc}
-
-
- ; Patch Wimp_ResizeIcon
- ; Just give an error if you try to resize an iconbar icon. It's not very
- ; useful anyway.
-
- pre_wimp_resizeicon
- ; Does it apply to the iconbar?
- cmp r0, #-1
- movnes pc, lr
-
- ; Yes, it does.
- DEBUG_MSG "Wimp_ResizeIcon called for the iconbar -- error", 10
- adr r0, error_resize_icon
- mov r9, #-1
- orrs pc, lr, #V
-
- ; Our complaint.
- error_resize_icon
- DCD 0
- = "IconbarPatch can't handle Wimp_ResizeIcon on the iconbar", 0
- ALIGN
-
-
- ;; The errors we return at nasty tasks doing nasty things.
- ;; (Yeah, like this module isn't nasty or anything. ;-) )
- ;
- ;cant_handle_error
- ; DCD 0
- ; = "IconbarPatch couldn't handle the SWI that was called", 0
- ; ALIGN
-
-
- END
-