; ; wimp_main.s ; ; APCS interface to WIMP SWIs ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Steel library. ; ; Steel is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Steel is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Steel. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Initialising the WIMP ------------------------------------------------ ; --- wimp_initialise --- ; ; On entry: a1 == pointer to where to put the version number EXPORT wimp_initialise wimp_initialise STMFD sp!,{lr} ;Save the link register MOV ip,a1 ;Save this away for a bit MOV a1,#120 ;Make sure it's Arthur :-) MOV a2,#0 ;Don't start a WIMP task SWI XWimp_Initialise ;Start up the WIMP STRVC a1,[ip] ;Store the version number MOVVC a1,#0 ;If no error, return no error LDMFD sp!,{pc}^ ;Return to caller ; --- wimp_taskinit --- ; ; On entry: a1 == pointer to name of task ; a2 == pointer to version number (to be updated) ; a3 == pointer to task handle to set ; a4 == optional pointer to messages block EXPORT wimp_taskinit wimp_taskinit STMFD sp!,{a2,a3,lr} ;Stash lots of registers MOV a3,a1 ;Point to the task name LDR a1,[a2] ;Get the version number LDR a2,wimp__magic ;Load the strange magic value SWI XWimp_Initialise ;Initialise the WIMP LDMIA sp!,{a3,a4,lr} ;Get the pointers back STRVC a1,[a3] ;Store the version number STRVC a2,[a4] ;Store the task handle too MOVVC a1,#0 ;If no error, clear return MOVS pc,lr ;Return to caller wimp__magic DCB "TASK" ;The magic value for initing ;----- Closing the WIMP down again ------------------------------------------ ; --- wimp_closedown --- ; ; On entry: -- EXPORT wimp_closedown wimp_closedown SWI XWimp_CloseDown ;Close down the WIMP MOVVC a1,#0 ;If no error, return clear MOVS pc,lr ;Return to caller ; --- wimp_taskclose --- ; ; On entry: a1 == my task handle to use EXPORT wimp_taskclose wimp_taskclose LDR a2,wimp__magic ;Get the magic number again SWI XWimp_CloseDown ;Close down my task only MOVVC a1,#0 ;Clear error if it worked MOVS pc,lr ;Return to caller ;----- Everything else :-) -------------------------------------------------- ; --- wimp_create_wind --- ; ; On entry: a1 == pointer to window definition ; a2 == pointer to window handle to fill in EXPORT wimp_create_wind wimp_create_wind MOV a4,a2 ;Keep pointer to handle too MOV a2,a1 ;Point to window definition SWI XWimp_CreateWindow ;Create the new window STRVC a1,[a4] ;Store the handle away MOVVC a1,#0 ;And clear the error code MOVS pc,lr ;Return to caller ; --- wimp_create_icon --- ; ; On entry: a1 == pointer to icon creation block ; a2 == pointer to icon handle to fill in EXPORT wimp_create_icon wimp_create_icon MOV a4,a2 ;Keep pointer to icon handle MOV a2,a1 ;Point to the icon block SWI XWimp_CreateIcon ;Create the icon now STRVC a1,[a4] ;Store the icon handle away MOVVC a1,#0 ;Clear any error code MOVS pc,lr ;Return to caller ; --- wimp_delete_wind --- ; ; On entry: a1 == window handle EXPORT wimp_delete_wind wimp_delete_wind STMFD sp!,{a1} ;Store window handle on stack MOV a2,sp ;Point to saved handle SWI XWimp_DeleteWindow ;Delete the window MOVVC a1,#0 ;Return no error if success ADD sp,sp,#4 ;Restore stack pointer MOVS pc,lr ;Return to caller ; --- wimp_delete_icon --- ; ; On entry: a1 == window handle ; a2 == icon handle EXPORT wimp_delete_icon wimp_delete_icon STMFD sp!,{a1,a2} ;Stack registers for block MOV a2,sp ;Point to the block SWI XWimp_DeleteIcon ;Do the SWI MOVVC a1,#0 ;Clear the error indicator ADD sp,sp,#8 ;Restore stack pointer MOVS pc,lr ;Return to caller ; --- wimp_open_wind --- ; ; On entry: a1 == pointer to window block EXPORT wimp_open_wind wimp_open_wind MOV a2,a1 ;Point to window block SWI XWimp_OpenWindow ;Do the SWI MOVVC a1,#0 MOVS pc,lr ; --- wimp_close_wind --- ; ; On entry: a1 == window handle EXPORT wimp_close_wind wimp_close_wind STMFD sp!,{a1} ;Store window handle away MOV a2,sp ;Point to the `block' SWI XWimp_CloseWindow ;Close the window MOVVC a1,#0 ADD sp,sp,#4 ;Restore the stack MOVS pc,lr ; --- wimp_redraw_wind --- ; ; On entry: a1 == pointer to a redraw structure to fill in ; a2 == pointer to a `more' variable to fill in EXPORT wimp_redraw_wind wimp_redraw_wind MOV a3,a2 ;Keep this pointer safe MOV a2,a1 ;Point to redraw structure SWI XWimp_RedrawWindow ;Do the redraw window call STRVC a1,[a3] ;Store the `more' variable MOVVC a1,#0 MOVS pc,lr ;Return to caller ; --- wimp_update_wind --- ; ; On entry: a1 == pointer to a redraw structure to fill in ; a2 == pointer to a `more' variable to fill in EXPORT wimp_update_wind wimp_update_wind MOV a3,a2 ;Keep this pointer safe MOV a2,a1 ;Point to redraw structure SWI XWimp_UpdateWindow ;Do the update window call STRVC a1,[a3] ;Store the `more' variable MOVVC a1,#0 MOVS pc,lr ;Return to caller ; --- wimp_get_rectangle --- ; ; On entry: a1 == pointer to a redraw structure to fill in ; a2 == pointer to a `more' variable to fill in EXPORT wimp_get_rectangle wimp_get_rectangle MOV a3,a2 ;Keep this pointer safe MOV a2,a1 ;Point to redraw structure SWI XWimp_GetRectangle ;Get the next rectangle STRVC a1,[a3] ;Store the `more' variable MOVVC a1,#0 MOVS pc,lr ;Return to caller ; --- wimp_get_wind_state --- ; ; On entry: a1 == window handle ; a2 == pointer to block to fill in EXPORT wimp_get_wind_state wimp_get_wind_state STR a1,[a2,#0] ;Fill in the window handle SWI XWimp_GetWindowState MOVVC a1,#0 MOVS pc,lr ; --- wimp_get_wind_info --- ; ; On entry: a1 == pointer to block to fill in EXPORT wimp_get_wind_info wimp_get_wind_info MOV a2,a1 SWI XWimp_GetWindowInfo MOVVC a1,#0 MOVS pc,lr ; --- wimp_set_icon_state --- ; ; On entry: a1 == window handle ; a2 == icon handle ; a3 == EOR mask ; a4 == BIC mask EXPORT wimp_set_icon_state wimp_set_icon_state STMFD sp!,{a1-a4} MOV a2,sp SWI XWimp_SetIconState ADD sp,sp,#16 MOVVC a1,#0 MOVS pc,lr ; --- wimp_get_icon_info --- ; ; On entry: a1 == window handle ; a2 == icon handle ; a3 == pointer to structure to fill in EXPORT wimp_get_icon_info wimp_get_icon_info SUB sp,sp,#40 ;Make space for icon block STMIA sp,{a1,a2} ;Fill in the handles nicely MOV a2,sp ;Point to the block SWI XWimp_GetIconState ;Get information about icon ADDVS sp,sp,#40 ;If it failed, restore stack MOVVSS pc,lr ;And return to caller ADD sp,sp,#8 ;Point to icon info LDMIA sp!,{a1,a2,a4,ip} ;Get some of the data STMIA a3!,{a1,a2,a4,ip} ;Store in the caller's buffer LDMIA sp!,{a1,a2,a4,ip} ;Get the rest of the icon STMIA a3!,{a1,a2,a4,ip} ;And store that away too MOV a1,#0 ;Nothing went wrong MOVS pc,lr ;Return to caller ; --- wimp_get_point_info --- ; ; On entry: a1 == pointer to block to fill in EXPORT wimp_get_point_info wimp_get_point_info MOV a2,a1 ;Point to the block SWI XWimp_GetPointerInfo ;Get the mouse information MOVVC a1,#0 MOVS pc,lr ; --- wimp_drag_box --- ; ; On entry: a1 == pointer to a drag structure EXPORT wimp_drag_box wimp_drag_box MOV a2,a1 ;Point to the block SWI XWimp_DragBox ;Perform the drag MOVVC a1,#0 MOVS pc,lr ; --- wimp_force_redraw --- ; ; On entry: a1 == pointer to a redraw block EXPORT wimp_force_redraw wimp_force_redraw STMFD sp!,{v1,lr} ;Store v1 away nicely LDMIA a1,{a1-a4,v1} ;Get registers from the block SWI XWimp_ForceRedraw MOVVC a1,#0 LDMFD sp!,{v1,pc}^ ; --- wimp_set_caret_pos --- ; ; On entry: a1 == pointer to a caret structure to set EXPORT wimp_set_caret_pos wimp_set_caret_pos STMFD sp!,{v1,v2,lr} ;Store v1 and v2 away nicely LDMIA a1,{a1-a4,v1,v2} SWI XWimp_SetCaretPosition MOVVC a1,#0 LDMFD sp!,{v1,v2,pc}^ ; --- wimp_get_caret_pos --- ; ; On entry: a1 == pointer to caret structure to fill in EXPORT wimp_get_caret_pos wimp_get_caret_pos MOV a2,a1 SWI XWimp_GetCaretPosition MOVVC a1,#0 MOVS pc,lr ; --- wimp_create_menu --- ; ; On entry: a1 == pointer to menu ; a2 == x coordinate to open menu ; a3 == y coordinate to open menu EXPORT wimp_create_menu wimp_create_menu MOV a4,a3 MOV a3,a2 MOV a2,a1 SWI XWimp_CreateMenu MOVVC a1,#0 MOVS pc,lr ; --- wimp_decode_menu --- ; ; On entry: a1 == pointer to menu ; a2 == pointer to menu hit array ; a3 == pointer to buffer for string EXPORT wimp_decode_menu wimp_decode_menu MOV a4,a3 MOV a3,a2 MOV a2,a1 SWI XWimp_DecodeMenu MOVVC a1,#0 MOVS pc,lr ; --- wimp_which_icon --- ; ; On entry: a1 == pointer to strange which block thing ; a2 == pointer to where to store the results EXPORT wimp_which_icon wimp_which_icon LDMIA a1,{a1,a3,a4} ;Get arguments from block SWI XWimp_WhichIcon MOVVC a1,#0 MOVS pc,lr ; --- wimp_set_extent --- ; ; On entry: a1 == pointer to strange block with window handle EXPORT wimp_set_extent wimp_set_extent ADD a2,a1,#4 ;Point to extent block LDR a1,[a1] ;Get the window handle SWI XWimp_SetExtent MOVVC a1,#0 MOVS pc,lr ; --- wimp_set_point_shape --- ; ; On entry: a1 == pointer to a freaky pointer shape structure EXPORT wimp_set_point_shape wimp_set_point_shape STMFD sp!,{v1,v2,lr} LDMIA a1,{a1-a4,v1,v2} SWI XWimp_SetPointerShape MOVVC a1,#0 LDMFD sp!,{v1,v2,pc}^ ; --- wimp_open_template --- ; ; On entry: a1 == pointer to name of template file EXPORT wimp_open_template wimp_open_template MOV a2,a1 SWI XWimp_OpenTemplate MOVVC a1,#0 MOVS pc,lr ; --- wimp_close_template --- ; ; On entry: -- EXPORT wimp_close_template wimp_close_template SWI XWimp_CloseTemplate MOVVC a1,#0 MOVS pc,lr ; --- wimp_load_template --- ; ; On entry: a1 == pointer to a template structure EXPORT wimp_load_template wimp_load_template MOV ip,a1 ;Keep the pointer safe STMFD sp!,{v1-v3,lr} ;Save lots of registers LDMIA ip,{a1-a4,v1-v3} ;Get all the arguments CMP v1,#0 ;If no font array specified MOVEQ v1,#-1 ;Pass the *correct* value SWI XWimp_LoadTemplate ;Load the template STMVCIA ip,{a1-a4,v1-v3} ;Store the information back MOVVC a1,#0 ;Clear error indicator LDMFD sp!,{v1-v3,pc}^ ;Return to caller ; --- wimp_processkey --- ; ; On entry: a1 == key to process EXPORT wimp_processkey wimp_processkey SWI XWimp_ProcessKey MOVVC a1,#0 MOVS pc,lr ; --- wimp_starttask --- ; ; On entry: a1 == pointer to command to execute EXPORT wimp_starttask wimp_starttask SWI XWimp_StartTask MOVVC a1,#0 MOVS pc,lr ; --- wimp_reporterror --- ; ; On entry: a1 == pointer to error block ; a2 == Wimp_ReportError flags word ; a3 == pointer to application name EXPORT wimp_reporterror wimp_reporterror SWI XWimp_ReportError MOVVC a1,#0 MOVS pc,lr ; --- wimp_getwindowoutline --- ; ; On entry: a1 == pointer to a block to fill in EXPORT wimp_getwindowoutline wimp_getwindowoutline MOV a2,a1 SWI XWimp_GetWindowOutline MOVVC a1,#0 MOVS pc,lr ; --- wimp_ploticon --- ; ; On entry: a1 == pointer to icon to plot EXPORT wimp_ploticon wimp_ploticon MOV a2,a1 SWI XWimp_PlotIcon MOVVC a1,#0 MOVS pc,lr ; --- wimp_setmode --- ; ; On entry: a1 == new mode to set EXPORT wimp_setmode wimp_setmode SWI XWimp_SetMode MOVVC a1,#0 MOVS pc,lr ; --- wimp_setpalette --- ; ; On entry: a1 == pointer to palette to set EXPORT wimp_setpalette wimp_setpalette MOV a2,a1 SWI XWimp_SetPalette MOVVC a1,#0 MOVS pc,lr ; --- wimp_readpalette --- ; ; On entry: a1 == pointer to palette block to fill in EXPORT wimp_readpalette wimp_readpalette MOV a2,a1 SWI XWimp_ReadPalette MOVVSS pc,lr ; --- It seems we must mangle the colours now --- ; ; Since Wimp_ReadPalette leaves the bottom nibbles clear for ; no sensible reason, and RISC_OSLib's wimp.c bodges the ; palette to try and make it sensible, we must do the same ; here, being careful to preserve the GCOL numbers at the ; bottom of the palette words. MOV a1,#20 ;Do this once for each entry LDR a4,=&F0F0F000 ;Mask for copying nibbles 00 LDR a3,[a2] ;Get the next palette word AND ip,a3,a4 ;Get the top nibbles BIC a3,a3,a4,LSR #4 ;Clear the bottom nibbles ORR a3,a3,ip,LSR #4 ;Shift down to copy nibbles STR a3,[a2],#4 ;Store and bump a2 along SUBS a1,a1,#1 ;Done another one BNE %b00 ;If there's any more, loop MOVVC a1,#0 MOVS pc,lr ; --- wimp_setcolour --- ; ; On entry: a1 == colour to set EXPORT wimp_setcolour wimp_setcolour SWI XWimp_SetColour MOVVC a1,#0 MOVS pc,lr ; --- wimp_sendmessage --- ; ; On entry: a1 == the event type of the message ; a2 == pointer to the message to send ; a3 == the task handle of the recipient ; --- wimp_sendwmessage --- ; ; On entry: a1 == the event type again ; a2 == pointer to the message to send ; a3 == the window handle of the recipient ; a4 == the icon handle of the recipient ; --- Note --- ; ; Since the registers are set up perfectly in both cases, we can use the ; same routine! EXPORT wimp_sendmessage EXPORT wimp_sendwmessage wimp_sendmessage wimp_sendwmessage SWI XWimp_SendMessage MOVVC a1,#0 MOVS pc,lr ; --- wimp_create_submenu --- ; ; On entry: a1 == pointer to menu to open ; a2 == x coordinate to open it at ; a3 == y coordinate to open it at EXPORT wimp_create_submenu wimp_create_submenu MOV a4,a3 MOV a3,a2 MOV a2,a1 SWI XWimp_CreateSubMenu MOVVC a1,#0 MOVS pc,lr ; --- wimp_spriteop --- ; ; On entry: a1 == the reason code to pass ; a2 == the name of the sprite to do it on EXPORT wimp_spriteop wimp_spriteop STMFD sp!,{v1-v6,lr} MOV a3,a2 SWI XWimp_SpriteOp MOVVC a1,#0 LDMFD sp!,{v1-v6,pc}^ ; --- wimp_spriteop_full --- ; ; On entry: a1 == pointer to registers to use EXPORT wimp_spriteop_full wimp_spriteop_full STMFD sp!,{v1-v6,lr} MOV ip,a1 LDMIA ip,{a1-a4,v1-v6} SWI XWimp_SpriteOp STMVCIA ip,{a1-a4,v1-v6} MOVVC a1,#0 LDMFD sp!,{v1-v6,pc}^ ; --- wimp_baseofsprites --- ; ; On entry: -- ; On exit: a1 == pointer to WIMP sprite pool in RMA EXPORT wimp_baseofsprites wimp_baseofsprites SWI XWimp_SpriteOp MOV a1,a2 MOVS pc,lr ; --- wimp_blockcopy --- ; ; On entry: a1 == window handle ; a2 == pointer to source rectangle ; a3 == destination x coordinate ; a4 == destination y coordinate EXPORT wimp_blockcopy wimp_blockcopy STMFD sp!,{v1-v3,lr} MOV v3,a4 MOV v2,a3 LDMIA a2,{a2,a3,a4,v1} SWI XWimp_BlockCopy MOVVC a1,#0 LDMFD sp!,{v1-v3,pc}^ ; --- wimp_slotsize --- ; ; On entry: a1 == pointer to current slot size ; a2 == pointer to next slot size ; a3 == pointer to free pool size EXPORT wimp_slotsize wimp_slotsize STMFD sp!,{v1-v3,lr} ;Stack registers MOV a4,a1 ;Keep pointer to current MOV v2,a2 ;Keep pointer to next MOV v3,a3 ;Keep pointer to free LDR a1,[a1] ;Get the actual current slot LDR a2,[a2] ;Get the actual next slot SWI XWimp_SlotSize ;Set or read the slot size STRVC a1,[a4] ;Store current slot size STRVC a2,[v2] ;Store next slot size STRVC a3,[v3] ;Store free area size MOVVC a1,#0 ;Clear error marker LDMFD sp!,{v1-v3,pc}^ ;Return to caller ; --- wimp_readpixtrans --- ; ; On entry: a1 == pointer to sprite area ; a2 == pointer to sprite id (yuk) ; a3 == pointer to scale factors to fill in ; a4 == pointer to translation table to fill in EXPORT wimp_readpixtrans wimp_readpixtrans STMFD sp!,{v3,v4,lr} ; --- Put the registers in the right places --- MOV v4,a4 MOV v3,a3 MOV a3,a2 MOV a2,a1 ; --- Set up the reason code properly --- CMP a2,#0 ;Is it the WIMP or system CMPNE a2,#1 ;sprite area? MOVEQ a1,#&000 ;Then say it's system area BEQ %f00 ;And branch ahead ; --- Munge the sprite ID to get the right reason code --- LDR lr,[a3,#4] ;Get the sprite ID tag CMP lr,#0 ;Is it a name MOVEQ a1,#&100 ;Yes -- user area, named MOVNE a1,#&200 ;No -- user area, pointer ; --- Now get the pixel translation --- 00 LDR a3,[a3,#0] ;Get sprite name or pointer SWI XWimp_ReadPixTrans ;Do the actual operation MOVVC a1,#0 ;If it succeeded, no error LDMFD sp!,{v3,v4,pc}^ ;Return to caller ; --- Missing call --- ; ; We omit a veneer for Wimp_ClaimFreeMemory, since it's not much use unless ; you're in SVC mode, in which case you'd better be writing in assembler ; anyway. ; --- wimp_commandwindow --- ; ; On entry: a1 == pointer to a funny structure EXPORT wimp_commandwindow wimp_commandwindow MOV a2,a1 ;Keep pointer to structure LDR a3,[a2,#0] ;Get the operation code ; --- Work out what the operation is meant to be --- ; ; If we don't recognise the `tag' then all hell breaks loose. CMP a3,#0 ;Create window with title LDREQ a1,[a2,#4] ;Then find the title CMP a3,#1 ;Just make window `active' MOVEQ a1,#1 ;Horrors -- that's right CMP a3,#2 ;Close the window, prompting MOVEQ a1,#0 ;Then set up the code CMP a3,#3 ;Close the window, no prompt MOVEQ a1,#-1 ;Do that right too ; --- Now just do it --- SWI XWimp_CommandWindow MOVVC a1,#0 MOVS pc,lr ; --- wimp_textcolour --- ; ; On entry: a1 == colour to set EXPORT wimp_textcolour wimp_textcolour SWI XWimp_TextColour MOVVC a1,#0 MOVS pc,lr ; --- wimp_transferblock --- ; ; On entry: a1 == source task's handle ; a2 == address of buffer in source task ; a3 == destination task's handle ; a4 == address of buffer in destination task ; [sp] == amount of data to transfer EXPORT wimp_transferblock wimp_transferblock STMFD sp!,{v1,lr} ;Save v1 on the stack LDR v1,[sp,#8] ;Get the buffer length SWI XWimp_TransferBlock ;Do the operation MOVVC a1,#0 LDMFD sp!,{v1,pc}^ ; --- wimp_readsysinfo --- ; ; On entry: a1 == information to read ; a2 == where to put R0 on exit ; a3 == where to put R1 on exit EXPORT wimp_readsysinfo wimp_readsysinfo CMP a1,#5 MOVNE a3,#0 MOV a4,a2 SWI XWimp_ReadSysInfo MOVVSS pc,lr CMP a4,#0 STRNE a1,[a4] CMP a3,#0 STRNE a2,[a3] MOV a1,#0 MOVS pc,lr ; --- wimp_setfontcolours --- ; ; On entry: a1 == background colour ; a2 == foreground colour EXPORT wimp_setfontcolours wimp_setfontcolours SWI XWimp_SetFontColours MOVVC a1,#0 MOVS pc,lr ; --- wimp_getmenustate --- ; ; On entry: a1 == what to do ; a2 == pointer to buffer to fill in ; a3 == window handle (optional) ; a4 == icon handle (optional too) EXPORT wimp_getmenustate wimp_getmenustate SWI XWimp_GetMenuState MOVVC a1,#0 MOVS pc,lr ; --- wimp_addmessages --- ; ; On entry: a1 == pointer to messages array EXPORT wimp_addmessages wimp_addmessages SWI XWimp_AddMessages MOVVC a1,#0 MOVS pc,lr ; --- wimp_removemessages --- ; ; On entry: a1 == pointer to messages array EXPORT wimp_removemessages wimp_removemessages SWI XWimp_RemoveMessages MOVVC a1,#0 MOVS pc,lr ; --- Missing call --- ; ; We omit a veneer for Wimp_SetColourMapping, since it's for specialised use ; only probably, and not of use to an average application. ;----- That's all, folks ---------------------------------------------------- END