; Copyright 1996 Acorn Computers Ltd ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. ; You may obtain a copy of the License at ; ; http://www.apache.org/licenses/LICENSE-2.0 ; ; Unless required by applicable law or agreed to in writing, software ; distributed under the License is distributed on an "AS IS" BASIS, ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; See the License for the specific language governing permissions and ; limitations under the License. ; ; > s.StartLoop ; ---------------------------------------------------------------------------------------------------------------------- ; Application title and 'TASK' word store taskidentifier DCB "TASK" tasktitle DCB "TaskID",0 ALIGN ; ---------------------------------------------------------------------------------------------------------------------- ; Set up error blocks MakeErrorBlock Pinboard_NoWimp ErrorOldWimp SWI XWimp_CloseDown SWI XOS_WriteI+4 ; just in case (old Wimp!) ADR r0,ErrorBlock_Pinboard_NoWimp BL msgtrans_errorlookup ErrorNoWimp SWI OS_GenerateError ; can't use Wimp to report error! CloseWimp Push "r0,lr" LDR r0, mytaskhandle ; Get task handle LDR r1, taskidentifier SWI XWimp_CloseDown MOV r0, #0 STR r0, mytaskhandle Pull "r0,pc",,^ ; ---------------------------------------------------------------------------------------------------------------------- template_filename DCB "Pinboard:Templates",0 ALIGN info_name DCB "Proginfo",0 ALIGN saveas_name DCB "saveas",0 ALIGN back_name DCB "Back",0 ALIGN bgcol DCD &77777700 MessagesList DCD Message_DataLoad DCD Message_DataLoadAck DCD Message_DataSaveAck DCD Message_ModeChange DCD Message_PaletteChange DCD Message_SaveDesktop DCD Message_MenusDeleted DCD Message_HelpRequest DCD Message_Iconize DCD Message_IconizeAt DCD Message_TaskNameIs DCD Message_WindowClosed DCD Message_TaskCloseDown DCD Message_WindowInfo DCD Message_FilerSelection DCD Message_FontChanged DCD 0 ; ---------------------------------------------------------------------------------------------------------------------- ; Start up the wimp task for Pinboard Start MOV r11, r12 LDR r12, [r12] ; get workspace pointer addr r0, ErrorBlock_CantStartPinboard MOV r1,#0 ; Relies on global error message MOV r2,#0 ADRL r4,Title SWI XMessageTrans_ErrorLookup CMP r12, #0 SWILE OS_GenerateError ; abort if module not initialised LDR r14, mytaskhandle ; abort if already a task CMP r14, #0 SWIGE OS_GenerateError ADRL sp, stacktop ; STACK IS NOW VALID! BL msgtrans_openfile SWIVS OS_GenerateError ADR r0,message_file_block+4 ADR r1,tasktitle ADR r2,dataarea MOV r3,#&100 SWI XMessageTrans_Lookup ADRVSL r2,Title LDR r0, bgcol STR r0, background_colour MOV r0,#0 STR r0,poll_word STR r0,slot_size ; We don't have a slot. STR r0,GotToClearBackdrop STR r0,MonotonicID STR r0,backdrop_options ORR r0, r0, #PinboardOption_UseWinToCorner ORR r0, r0, #PinboardOption_WinToCornerLR ORR r0, r0, #PinboardOption_WinToCornerHV STR r0, Pinboard_options MOV r0, #-1 STR r0, IconizeAtX STR r0, IconizeAtY MOV r0, #Default_IconizeAtFlags STR r0, IconizeAtFlags MOV r0, #0 STR r0,Pinboard_Icons STR r0,Window_Icons STR r0,All_PB_Icons STR r0,TinyDirs_Icons STR r0,Pinboard_Selected STR r0,TinyDirs_Selected STR r0,Windows_Selected STR r0,Iconbar_Icons STR r0,soft_selection_window SUB r0,r0,#1 STR r0,CachedBackdropMode STR r0,TinyDirs_Handle MOV r0, #300 ; We know about wimp 3.00 and have a messages list. LDR r1, taskidentifier ADR r3, MessagesList SWI XWimp_Initialise LDR r3, =269 ; Wimp version required CMP r0, #256 ; needs Wimp with Wimp_PollWord, draggable iconbar icons ; and Iconize and close window messages. BCC ErrorOldWimp STR r1, mytaskhandle ; Store task handle ADR r1, template_filename ; Load in the templates SWI XWimp_OpenTemplate BLVS CloseWimp SWIVS OS_GenerateError ADR r1, dataarea ; Get template for back window. LDR r2, =indirected_data_offset ADD r2,r2,r12 ADD r3, r2, #indirected_space MOV r4, #-1 ; No font array ADR r5, back_name ; Name of window. MOV r6, #0 ; Search from first template. SWI XWimp_LoadTemplate BLVS CloseWimp SWIVS OS_GenerateError BL read_mode_variables ; Read screen bounding box. [ truncate_filenames BL read_font_widths ] ADR r1, bounding_box ; Set correct extent LDMIA r1, {r2,r3,r4,r5} ADD r4,r4,#100 ADD r5,r5,#100 ADRL r1, dataarea+40 STMIA r1, {r2,r3,r4,r5} ADR r1, dataarea ; Create the backdrop window SWI XWimp_CreateWindow STRVC r0, backdrop_handle BLVS CloseWimp SWIVS OS_GenerateError ;ADR r1, dataarea ; Get template for info box. ;LDR r2, =indirected_data_offset ;ADD r2,r2,r12 ;ADD r3, r2, #indirected_space ;MOV r4, #-1 ;ADR r5, info_name ;MOV r6, #0 ;SWI XWimp_LoadTemplate ;BLVS CloseWimp ;SWIVS OS_GenerateError ;ADR r1, dataarea ; Create the info window ;SWI XWimp_CreateWindow ;STRVC r0, info_dbox_handle ADR r1, dataarea ; Get template for saveas box. LDR r2, =save_filename_offset ADD r2,r2,r12 ADD r3, r2, #&180 MOV r4, #-1 ADR r5, saveas_name MOV r6, #0 SWI XWimp_LoadTemplate BLVS CloseWimp SWIVS OS_GenerateError ADR r1, dataarea ; Create the info window LDR r14,[r1,#88+2*32+20] DebugS sa,"Default name is ",R14 STR r14,save_filename_address SWI XWimp_CreateWindow STRVC r0, saveas_handle SWI XWimp_CloseTemplate BL set_icon_bar_height ADR r1, dataarea ; Open the backdrop window MOV r0, r1 LDR r2, backdrop_handle STR r2, [r0],#4 ADR r3, bounding_box ; Screen bounding box. LDMIA r3, {r4,r5,r6,r7} LDR r5, icon_bar_height ; Don't cover iconbar. ADD r6,r6,#100 ADD r7,r7,#100 STMIA r0!, {r4,r5,r6,r7} MOV r8, #-2 ; bottom of stack STMIA r0, {r6,r7,r8} ; Scroll x / Scroll y & open behind. Debug bd,"Open Window" SWI XWimp_OpenWindow ; Go open the window. BLVS CloseWimp SWIVS OS_GenerateError BL FreeAll ; Free icon list, backdrop path etc. if used [ defaultbackdrop BL CheckLCD ] [ useECFforLCD BL setupECF ] ; ---------------------------------------------------------------------------------------------------------------------- ; Wimp polling routine repollwimp Debug sa,"Repoll wimp" BLVS ReportError ; See if we need to add tinydirs icon. LDR r0,Pinboard_options TST r0,#PinboardOption_TinyDirs BEQ %FT01 LDR r0,TinyDirs_Icons CMP r0,#0 BNE %FT01 Debug sa,"Calling add tiny dirs" Push "PC" B Int_AddTinyDirs MOV r0,r0 01 ; Call Wimp_Poll Debug sa,"Calling Wimp_Poll" MOV R0, #&31 ORR R0, R0, #&400000 ; Poll word (low priority) ADR R1,dataarea ADR r3, poll_word SWI XWimp_Poll ; can't call non-X form Debug sa,"Wimp_poll returned ",r0 BVS repollwimp Debug sa,"No error in wimp_poll" ; Call the appropriate routine using a fast jump table ADR LR,repollwimp CMP R0,#(endjptable-jptable)/4 ADDCC PC,PC,R0,ASL #2 MOV PC,LR jptable MOV PC,LR ; 0 null reason B Redraw ; 1 redraw window B open_window ; 2 open window MOV PC,LR ; 3 close window MOV PC,LR ; 4 pointer leaving window MOV PC,LR ; 5 pointer entering window B mouse_click ; 6 mouse click B drag_end ; 7 drag box complete B Save_KeyPressed ; 8 key pressed. B menu_selection ; 9 menu selection MOV PC,LR ; 10 MOV PC,LR ; 11 MOV PC,LR ; 12 B poll_word_set ; 13 poll word non-zero MOV PC,LR ; 14 MOV PC,LR ; 15 MOV PC,LR ; 16 B message_received ; 17 message_received B message_received ; 18 message_received_ack B message_bounced ; 19 message_bounced endjptable ;---------------------------------------------------------------------------------------------------------------------- ; open_window ; Open window unless it's the backdrop window which is opened only on a mode change. ; open_window Push "LR" Debug pi,"open_window" LDR r0,backdrop_handle LDR r14,[r1] CMP r0,r14 SWINE XWimp_OpenWindow ; 2 open window Pull "PC" ; ---------------------------------------------------------------------------------------------------------------------- poll_word_set Push "LR" LDR R0,poll_word TST R0,#PollWordReason_Buffered BICNE R0,R0,#PollWordReason_Buffered STRNE R0,poll_word BLNE ReadBufferedList Pull "PC",VS LDR R0,poll_word TST R0,#PollWordReason_Recache BICNE R0,R0,#PollWordReason_Recache STRNE R0,poll_word BLNE CacheBackdropSprite LDR lr,poll_word TST lr,#PollWordReason_Remove BICNE lr,lr,#PollWordReason_Remove STRNE lr,poll_word BLNE ClearBackdrop Pull "PC" ; ---------------------------------------------------------------------------------------------------------------------- Redraw ROUT Push "LR" [ useECFforLCD MOV r0,#1 SWI XOS_ReadSysInfo Pull "PC",VS MOV r11,r1 ; save monitor type ] ADR r1,dataarea LDR r9,backdrop_handle Debug td,"Window handle = ",r9 STR r9,[r1] LDR r9,backdrop_options Debug td,"Redraw: options are ",r9 SWI XWimp_RedrawWindow Pull "PC",VS 01 CMP r0,#0 Pull "PC",EQ TST r9,#bd_OptionActive TSTNE r9,#bd_OptionScaled :OR: bd_OptionTiled BNE %FT10 [ useECFforLCD CMP r11,#5 LDRNE r0,=128+4 SWINE XWimp_SetColour MOVEQ r0,#&30 ADREQ r1,backdropECF SWIEQ XOS_SetColour | ;LDR r0,=128+4 ;SWI XWimp_SetColour Push "r0-r4" LDR r0, background_colour MOV r3, #128+256 MOV r4, #0 SWI XColourTrans_SetGCOL Pull "r0-r4" ] Pull "PC",VS SWI XOS_WriteI+16 ; Clear background to colour 4 Pull "PC",VS 10 TST r9,#bd_OptionActive BEQ %FT02 TST r9, #bd_OptionJPEG BEQ %FT12 BL plot_jpeg LDR r9, backdrop_options B %FT02 12 TST r9,#bd_OptionTiled LDREQ r0,=34+&200 ; Not tiled, plot at pre-calculated x,y MOVEQ r1,#&8000 ADDEQ r2,r1,#&10 LDREQ r3,Sprite_x LDREQ r4,Sprite_y MOVEQ r5,#0 SWIEQ XOS_SpriteOp Pull "PC",VS BEQ %FT02 ; Tiled sprite plotting goes here. LDR r14,[r1,#28] ; X0 of current rectangle. LDR r0,scale_x1 DivRem r3,r14,r0,r2 MUL r6,r0,r3 Debug bd,"First x ",r6 LDR r0,Screen_y1 LDR r14,scale_y1 MOV r9,#1 LDR r10,YEig MOV r9,r9,ASL r10 SUB r3,r14,r9 LDR r4,[r1,#32] ; Y0 of current rectangle. SUB r2,r0,r4 ; r2 = ScrY1 - Y0 ADD r2,r2,r3 ; r2 = (ScrY1-Y0)+YSize-1 DivRem r3,r2,r14,r5 ; r3 = (ScrY1-Y0+YSize-1) / YSize LDR r14,scale_y1 MUL r5,r3,r14 ; r5 = INT ( (ScrY1-Y0+YSize-1) / YSize ) * YSize SUB r4,r0,r5 ; r3 = ScrY1 - r5 (Base Y) Debug bd,"First y ",r4 MOV r3,r6 LDR r7,scale_y1 LDR r6,scale_x1 MOV r8,r3 ; r8 = Base X LDR r9, [r1,#36] ; r9 = Max X LDR r10,[r1,#40] ; r10 = Max Y 21 LDR r0,=34+&200 MOV r1,#&8000 ADD r2,r1,#&10 MOV r5,#0 SWI XOS_SpriteOp ADD r3,r3,r6 CMP r3,r9 BLE %BT21 MOV r3,r8 ADD r4,r4,r7 CMP r4,r10 BLE %BT21 LDR r9,backdrop_options 02 ADR r1,dataarea SWI XWimp_GetRectangle Pull "PC",VS B %BT01 ;--------------------------------------------------------------- ; plot_jpeg ; ; Plot a JPEG backdrop plot_jpeg ENTRY TST r9,#bd_OptionTiled BNE %FT10 TST r9, #bd_OptionScaled BNE %FT20 TST r9, #bd_OptionCentred BNE %FT20 B %FT80 10 ; Tiled backdrop MOV r7, #0 LDR r8, icon_bar_height LDR r9, Screen_x1 LDR r10, Screen_y1 12 MOV r0, #&8000 MOV r1, r7 MOV r2, r8 MOV r3, #0 LDR r4, slot_size MOV r5, #1 SWI XJPEG_PlotScaled ; trap error LDR r2, scale_x1 ; width of image in OS units ADD r7, r7, r2 CMP r7, r9 BLT %BT12 MOV r7, #0 ; height of image in OS units LDR r2, scale_y1 ADD r8, r8, r2 CMP r8, r10 BLT %BT12 B %FT80 20 ; Scaled/centred backdrop MOV r0, #&8000 LDR r1, Sprite_x LDR r2, Sprite_y ADR r3, ScaleFactors LDR r4, slot_size MOV r5, #1 SWI XJPEG_PlotScaled 80 EXIT LNK s.Messages