Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Extras » AU_Index/SourceCode
AU_Index/SourceCode
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Extras |
| Filename: | AU_Index/SourceCode |
| Read OK: | ✔ |
| File size: | 2A3B5 bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
Duplicates
There is 1 duplicate copy of this file in the archive:
- Archimedes archive » Acorn User » AU 1996-07.adf » Extras » AU_Index/SourceCode
- Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199607.adf » Extras » AU_Index/SourceCode
File contents
10REM Name : AUIndex (Source Code)
20REM Purpose : Easy Location Of Acorn User Articles
30REM Author : (c) The Flying Twig, 1994-96
40REM AKA Paul Burns
50REM Version : 1.00 (20 Dec 1995)
60
70ONERROR ONERROROFF:PRINT REPORT$;" at line ";ERL:END
80
90DIM code% 1024*28 :REM reserve 28k for assembler
100
110REM---------------------------------------------------------------------------
120
130FOR pass%=0TO2 STEP2
140P%=code%
150[OPTpass%
160
170B getstack ;Set up Stack Pointer
180
190.continue
200
210STMFD R13!,{R0-R12}
220
230 FNLongAdr("",11,menu%) ;Pointer to Menu Data
240 ADR R12,data% ;Pointer to Wimp Data
250 ADD R10,R12,#&1E00 ;Pointer to Program Data
260 ADD R9,R10,#&300 ;Pointer to Misc String buffer
270 B Start
280
290;-----------------------------------------------------------------------------
300; This section reserves space for Data (&2300 bytes)
310
320.data%
330]
340
350FOR i =0 TO &2300 STEP 4
360 [OPT pass%
370 EQUD 0
380 ]
390NEXT
400
410REM---------------------------------------------------------------------------
420REM This section sets up variables as offsets within the workspace to allow
430REM easy reference to data.
440
450REM Wimp Data Labels
460
470version%=&00
480task%=&04
490iconbar%=&08
500display%=&0C
510info%=&10
520search%=&14
530edit%=&18
540save%=&1C
550quit%=&20 :data%!quit%=0
560currentmenu%=&24
570templates=&28 :$(data%+templates)="<AUIndex$Resource>.Templates"
580spritename=&45 :$(data%+spritename)="!AUIndex"
590appname=&46
600edit=&50 :$(data%+edit)="edit"
610display=&55 :$(data%+display)="display"
620info=&5E :$(data%+info)="info"
630search=&63 :$(data%+search)="search"
640save=&6A :$(data%+save)="save"
650version=&70 :$(data%+version)="1.00 (20 Dec 1995)"
660block%=&84 :$(data%+block%+24)="!AUIndex"
670fonts%=&190
680update=&290 :$(data%+update)="update"
690update%=&298
700icons%=&3A0
710templates%=&1200
720
730indexdata%=data%+&1E00
740
750REM Data Labels for Program Specific Data
760
770indexhandle%=&00
780searchhandle%=&04
790indexmax%=&08
800searchmax%=&0C
810show%=&10
820filehandle%=&14
830indexrecord%=&18
840searchrecord%=&1C
850record%=&20
860max%=&24
870searchfile=&28 :$(indexdata%+searchfile)="<Wimp$ScrapDir>.SearchFile"
880indexfile=&46 :$(indexdata%+indexfile)="<AUIndex$Resource>.IndexFile"
890backslash=&66 :$(indexdata%+backslash)="\"
900editmonth%=&68
910displaymonth%=&6C
920multiple%=&70 :!(indexdata%+multiple%)=0
930editrecord%=&74
940scrapref%=&78
950updating%=&7C :!updating%=0
960months%=&130
970$(indexdata%+months%+&00)="Jan"
980$(indexdata%+months%+&10)="Feb"
990$(indexdata%+months%+&20)="Mar"
1000$(indexdata%+months%+&30)="Apr"
1010$(indexdata%+months%+&40)="May"
1020$(indexdata%+months%+&50)="Jun"
1030$(indexdata%+months%+&60)="Jul"
1040$(indexdata%+months%+&70)="Aug"
1050$(indexdata%+months%+&80)="Sep"
1060$(indexdata%+months%+&90)="Oct"
1070$(indexdata%+months%+&A0)="Nov"
1080$(indexdata%+months%+&B0)="Dec"
1090$(indexdata%+months%+&C0)="Xmas"
1100record=&200
1110
1120REM---------------------------------------------------------------------------
1130REM This section reserves space for the stack (&100 bytes).
1140
1150FOR i= 0 TO &100 STEP4
1160 [OPT pass%
1170 EQUD 0
1180 ]
1190NEXT
1200
1210REM---------------------------------------------------------------------------
1220REM Save Link and Stack Pointer onto stack
1230
1240[OPT pass%
1250ALIGN
1260
1270.getstack
1280STR R14,getstack-4
1290STR R13,getstack-8
1300ADR R13,getstack-8
1310B continue
1320
1330;-----------------------------------------------------------------------------
1340; MenuData
1350; This section sets up Menu Templates which can be passed to
1360; "MessageTrans_MakeMenu" to create a menu structure using the strings
1370; supplied in the Messages file.
1380
1390.menulist
1400EQUD 0 ;This reserves three words for storing
1410EQUD 0 ;the address of the Menu structures
1420EQUD 0 ;when they are created.
1430
1440.menu%
1450.ibmenu%
1460EQUS "IM0"+CHR$0 ;Message Token for the menu title.
1470EQUB 7 ;Menu Title foreground colour.
1480EQUB 2 ;Menu Title background colour.
1490EQUB 7 ;Menu work area foreground colour.
1500EQUB 0 ;Menu work area background colour.
1510EQUB 44 ;Height of each menu item (in OS units).
1520EQUB 0 ;Vertical gap between menu items.
1530
1540
1550EQUS "IM1"+CHR$0 ;Message Token for first menu item
1560ALIGN
1570EQUD 0 ;Menu Item flags
1580EQUD 0 ;Submenu pointer
1590EQUD &7000021 ;Icon flags
1600
1610EQUS "IM2"+CHR$0 ;Message Token for second menu item
1620ALIGN
1630EQUD &80 ;Menu Item flags (&80=last item)
1640EQUD 0 ;Submenu pointer
1650EQUD &7000021 ;Icon flags
1660
1670EQUB 0 ;terminating byte
1680ALIGN
1690
1700.mainmenu%
1710EQUS "MM0"+CHR$0 ;Message Token for the menu title.
1720EQUB 7 ;Menu Title foreground colour.
1730EQUB 2 ;Menu Title background colour.
1740EQUB 7 ;Menu work area foreground colour.
1750EQUB 0 ;Menu work area background colour.
1760EQUB 44 ;Height of each menu item (in OS units).
1770EQUB 0 ;Vertical gap between menu items.
1780
1790EQUS "MM1"+CHR$0 ;Message Token for first menu item
1800ALIGN
1810EQUD 0 ;Menu Item flags
1820EQUD 0 ;Submenu pointer
1830EQUD &7000021 ;Icon flags
1840
1850EQUS "MM2"+CHR$0 ;Message Token for second menu item
1860ALIGN
1870EQUD 0 ;Menu Item flags
1880EQUD 0 ;Submenu pointer
1890EQUD &7000021 ;Icon flags
1900
1910
1920EQUS "MM3"+CHR$0 ;Message Token for third menu item
1930ALIGN
1940EQUD 0 ;Menu Item flags
1950EQUD 0 ;Submenu pointer
1960EQUD &7000021 ;Icon flags
1970
1980EQUS "MM4"+CHR$0 ;Message Token for fourth menu item
1990ALIGN
2000EQUD 0 ;Menu Item flags
2010EQUD 0 ;Submenu pointer
2020EQUD &7000021 ;Icon flags
2030
2040EQUS "MM5"+CHR$0 ;Message Token for fifth menu item
2050ALIGN
2060EQUD &80 ;Menu Item flags (&80=last item)
2070EQUD 0 ;Submenu pointer
2080EQUD &7000021 ;Icon flags
2090
2100EQUB 0 ;Terminating byte
2110ALIGN
2120
2130.topicmenu%
2140EQUS "TM0"+CHR$0 ;Message Token for the menu title.
2150EQUB 7 ;Menu Title foreground colour.
2160EQUB 2 ;Menu Title background colour.
2170EQUB 7 ;Menu work area foreground colour.
2180EQUB 0 ;Menu work area background colour.
2190EQUB 44 ;Height of each menu item (in OS units).
2200EQUB 0 ;Vertical gap between menu items.
2210
2220]
2230FOR i=1 TO 32
2240[OPT pass%
2250
2260EQUS "TM"+STR$(i)+CHR$0 ;Message Token for ith menu item
2270ALIGN
2280EQUD 0 ;Menu Item flags
2290EQUD 0 ;Submenu pointer
2300EQUD &7000121 ;Icon flags
2310
2320]
2330NEXT
2340[OPT pass%
2350
2360EQUS "TM33"+CHR$0 ;Message Token for 33rd menu item
2370ALIGN
2380EQUD &84 ;Menu Item flags(&84=Writeable/last item)
2390EQUD 0 ;Submenu pointer
2400EQUD &7000121
2410
2420EQUB 0 ;Terminating byte
2430ALIGN
2440
2450
2460.writeabletext
2470]
2480FOR i=0TO256 STEP4
2490 [OPT pass%
2500 EQUD 0 ;256 byte array for text from writeable
2510 ;menu item.
2520 ]
2530NEXT
2540
2550REM---------------------------------------------------------------------------
2560REM Program code starts here
2570
2580[OPT pass%
2590
2600.Start
2610
2620;-----------------------------------------------------------------------------
2630; *** Initialise Wimp ***
2640; This section calls the Window Manager which will return its version number
2650; and our unique Task handle.
2660
2670MOV R0,#200 ;Minimum Version Number *100
2680MOV R1, #&4B000000 ;"TASK"
2690ADD R1,R1,#&00530000
2700ADD R1,R1,#&00004100
2710ADD R1,R1,#&00000054
2720ADD R2,R12,#appname ;Name to appear on Task Display
2730SWI "XWimp_Initialise"
2740 BVS SeriousError
2750STR R0,[R12,#version%] ;Wimp Version number *100
2760STR R1,[R12,#task%] ;Our Task handle
2770
2780;-----------------------------------------------------------------------------
2790; This subroutine sets up our icon on the icon bar.
2800
2810MVN R0,#0 ;Window handle (-1 Left side of IBar)
2820STR R0,[R12,#block%+0]
2830MOV R0,#0 ;Minimum X
2840STR R0,[R12,#block%+4]
2850MOV R0,#0 ;Minimum Y
2860STR R0,[R12,#block%+8]
2870MOV R0,#170 ;Maximum X
2880STR R0,[R12,#block%+12]
2890MOV R0,#68 ;Maximum Y
2900STR R0,[R12,#block%+16]
2910MOV R0, #&3000 ;Icon flags
2920ADD R0,R0,#&0002
2930STR R0,[R12,#block%+20]
2940ADD R1,R12,#block%
2950SWI "XWimp_CreateIcon"
2960 BVS SeriousError
2970STR R0,[R12,#iconbar%] ;Icon bar icon number
2980
2990;-----------------------------------------------------------------------------
3000; This section loads the window template files and creates the windows.
3010
3020ADD R1,R12,#templates
3030SWI "XWimp_OpenTemplate"
3040 BVS SeriousError
3050ADD R1,R12,#templates% ;Space for template data
3060ADD R2,R12,#icons% ;Space for indirected Icon data
3070ADD R3,R2,#templates%-icons% ;Size of space for indirected data
3080ADD R4,R12,#fonts% ;256 byte font count array
3090
3100ADD R5,R12,#display ;Main Display Window
3110MOV R6,#0 ;Template to start searching from
3120SWI "XWimp_LoadTemplate"
3130 BVS SeriousError
3140SWI "XWimp_CreateWindow"
3150 BVS SeriousError
3160STR R0,[R12,#display%] ;Display window handle
3170
3180ADD R5,R12,#info ;Info Dialogue box
3190MOV R6,#0
3200SWI "XWimp_LoadTemplate"
3210 BVS SeriousError
3220SWI "XWimp_CreateWindow"
3230 BVS SeriousError
3240STR R0,[R12,#info%] ;Info window handle
3250
3260ADD R5,R12,#search ;Search Dialogue box
3270MOV R6,#0
3280SWI "XWimp_LoadTemplate"
3290 BVS SeriousError
3300SWI "XWimp_CreateWindow"
3310 BVS SeriousError
3320STR R0,[R12,#search%] ;Search window handle
3330
3340ADD R5,R12,#edit ;Edit window
3350MOV R6,#0
3360SWI "XWimp_LoadTemplate"
3370 BVS SeriousError
3380SWI "XWimp_CreateWindow"
3390 BVS SeriousError
3400STR R0,[R12,#edit%] ;Edit window handle
3410
3420ADD R5,R12,#save ;Save Dialogue box
3430MOV R6,#0
3440SWI "XWimp_LoadTemplate"
3450 BVS SeriousError
3460SWI "XWimp_CreateWindow"
3470 BVS SeriousError
3480STR R0,[R12,#save%] ;Save window handle
3490
3500
3510ADD R5,R12,#update ;Update Dialogue box
3520MOV R6,#0
3530SWI "XWimp_LoadTemplate"
3540 BVS SeriousError
3550SWI "XWimp_CreateWindow"
3560 BVS SeriousError
3570STR R0,[R12,#update%] ;Update window handle
3580
3590SWI "XWimp_CloseTemplate"
3600
3610;-----------------------------------------------------------------------------
3620; This routine fills in the version number in the Info dialogue box.
3630
3640LDR R0,[R12,#info%]
3650MOV R1,#7
3660ADD R2,R12,#version
3670BL WriteIcon
3680;-----------------------------------------------------------------------------
3690
3700BL Init ;Initialise files
3710
3720;-----------------------------------------------------------------------------
3730; *** Wimp_Poll ***
3740; This routine repeatedly polls the wimp to find out what is happening
3750; around the desktop. The wimp returns an Event Reason Code and fills the
3760; parameter block with data dependant on the Event.
3770
3780 .mainloop
3790
3800MOV R0, #%11100000000000
3810ADD R0,R0,#%00000000010000 ;Mask out unwanted reason codes
3820
3830ADD R1,R12,#block%
3840SWI "Wimp_Poll"
3850
3860 CMP R0,#0: BLEQ ContUpdating
3870 CMP R0,#1: BLEQ RedrawWindowRequest
3880 CMP R0,#2: BLEQ OpenWindowRequest
3890 CMP R0,#3: SWIEQ "Wimp_CloseWindow"
3900;CMP R0,#4 ;Pointer_Leaving_Window
3910 CMP R0,#5: ;Pointer_Entering_Window
3920 CMP R0,#6: BLEQ MouseButtonClicked
3930 CMP R0,#7: BLEQ DragFinished
3940 CMP R0,#8: BLEQ KeyPressed
3950 CMP R0,#9: BLEQ MenuOptionSelected
3960;CMP R0,#10 ;Scroll_Request
3970;CMP R0,#11 ;Losing_Caret
3980;CMP R0,#12 ;Gaining_Caret
3990 CMP R0,#17 ;User_MessageReceived
4000 CMPNE R0,#18:BLEQ UserMessageReceived
4010;CMP R0,#19 ;User_Message_Ack
4020
4030
4040 LDR R0,[R12,#quit%] ;Check if we have been asked to quit
4050 CMP R0,#0
4060 BEQ mainloop
4070
4080;----------------------------------------------------------------------------
4090; This routine safley closes down our task.
4100
4110 LDR R0,[R12,#task%] ;This section tells the WIMP that we
4120 MOV R1, #&4B000000 ;are about to close down our task.
4130 ADD R1,R1,#&00530000
4140 ADD R1,R1,#&00004100
4150 ADD R1,R1,#&00000054
4160 SWI "XWimp_CloseDown"
4170
4180 MOV R0,#6
4190 ADD R1,R10,#searchfile
4200 SWI "OS_File"
4210
4220 FNLongAdr("",0,messages) ;This closes the Message file if it is
4230 SWI "XMessageTrans_CloseFile" ;still open.
4240
4250 SWI "XOS_Exit" ;This closes down our task.
4260
4270;-----------------------------------------------------------------------------
4280; *** Redraw_Window_Request ***
4290; This routine is called when part of one of our windows needs redrawing.
4300; Since none of our windows contain any 'User' graphics we can pass the call
4310; straight back to the Wimp to redraw the icons itself. A loop is needed to
4320; get a list of all the Rectangles that need redrawing.
4330
4340.RedrawWindowRequest
4350
4360STMFD R13!,{R0-R12,R14}
4370 ADD R1,R12,#block%
4380 SWI "Wimp_RedrawWindow"
4390 .redrawloop
4400 CMP R0,#0
4410 LDMEQFD R13!,{R0-R12,PC}^
4420 SWI "Wimp_GetRectangle"
4430B redrawloop
4440
4450;-----------------------------------------------------------------------------
4460; *** Open_Window_Request ***
4470; This routine is called when one of our windows needs opening or has been
4480; scrolled and needs redrawing with new scroll offsets. No special action
4490; needs to be performed so we simply open the window as requested.
4500
4510.OpenWindowRequest
4520
4530STMFD R13!,{R0-R12,R14}
4540
4550 SWI "Wimp_OpenWindow"
4560
4570LDMFD R13!,{R0-R12,PC}^
4580
4590;-----------------------------------------------------------------------------
4600; *** Mouse_Button_Click ***
4610; This routine is called when the mouse buttons change state while the
4620; pointer is over one of our windows - Dependant on the button type of the icon
4630; it is over, if any.
4640
4650.MouseButtonClicked
4660
4670STMFD R13!,{R0-R12,R14}
4680 LDR R2,[R12,#block%+0] ;X coordinate
4690 LDR R3,[R12,#block%+4] ;Y coordinate
4700 LDR R4,[R12,#block%+8] ;Mouse Button State
4710 LDR R5,[R12,#block%+12] ;Window handle
4720 LDR R6,[R12,#block%+16] ;Icon number
4730 LDR R7,[R12,#display%]
4740 LDR R8,[R12,#search%]
4750
4760 CMP R5,R7 ;This section will display the topic
4770 CMP R6,#43 ;selection menu if the menu button is
4780 FNLongAdr("EQ",1,menuinfo) ;pressed over the pop-up menu icon in
4790 MOVEQ R0,#0 ;the Display window.
4800 STREQ R0,[R1,#4]
4810 FNLongAdr("EQ",8,menulist)
4820 LDREQ R1,[R8,#8]
4830 STREQ R1,[R12,#currentmenu%]
4840 SUBEQ R2,R2,#64
4850 STREQ R2,[R9,#0]
4860 STREQ R3,[R9,#4]
4870 SWIEQ "Wimp_CreateMenu"
4880 LDMEQFD R13!,{R0-R12,PC}^
4890
4900 CMP R5,R7 ;This section will display the main
4910 CMPEQ R4,#2 ;Menu if the Menu button is pressed
4920 BLEQ UpdateStartEnd ;anywhere else in the Display window
4930 BLEQ UpdateLeafName ;after first updating the Save dialogue
4940 FNLongAdr("EQ",8,menulist) ;box with the current issue number
4950 LDREQ R1,[R8,#4]
4960 STREQ R1,[R12,#currentmenu%]
4970 SUBEQ R2,R2,#64
4980 STREQ R2,[R9,#0]
4990 STREQ R3,[R9,#4]
5000 SWIEQ "Wimp_CreateMenu"
5010 LDMEQFD R13!,{R0-R12,PC}^
5020
5030 CMN R5,#2 ;This section displays the Icon Bar
5040 CMPEQ R4,#2 ;Menu if the menu button is pressed
5050 FNLongAdr("EQ",8,menulist) ;over our icon bar icon.
5060 LDREQ R1,[R8,#0]
5070 STREQ R1,[R12,#currentmenu%]
5080 MOVEQ R3,#96
5090 ADDEQ R3,R3,#88 ; 44 units per menu item
5100 SUBEQ R2,R2,#64
5110 STREQ R2,[R9,#0]
5120 STREQ R3,[R9,#4]
5130 SWIEQ "Wimp_CreateMenu"
5140 LDMEQFD R13!,{R0-R12,PC}^
5150
5160 CMN R5,#2 ;This section will open the main window
5170 STREQ R7,[R12,#block%+0] ;if Select or adjust is pressed over
5180 ADDEQ R1,R12,#block% ;our icon bar icon
5190 SWIEQ "Wimp_GetWindowState"
5200 BLEQ OpenWindowRequest
5210
5220 CMP R5,R7 ;This section will call a subroutine
5230 TSTEQ R4,#(NOT 4) AND 7 ;to deal with Select being pressed over
5240 BLEQ SelectInDisplay ;the Display window.
5250 LDMEQFD R13!,{R0-R12,PC}^
5260
5270 CMP R5,R7 ;This section will call a subroutine
5280 TSTEQ R4,#(NOT 1) AND 7 ;to deal with adjust being pressed over
5290 BLEQ AdjustInDisplay ;the Display window
5300 LDMEQFD R13!,{R0-R12,PC}^
5310
5320 CMP R5,R8 ;This section will start a search if
5330 CMPEQ R6,#2 ;the OK icon clicked in the Search
5340 BLEQ StartSearch ;Dialogue box. If Select was used it
5350 TSTEQ R4,#(NOT 4) AND 7 ;will also close the Menu structure
5360 MVNEQ R1,#0
5370 SWIEQ "Wimp_CreateMenu"
5380 LDMEQFD R13!,{R0-R12,PC}^
5390
5400 LDR R8,[R12,#edit%]
5410 CMP R5,R8 ;This section displays the topic
5420 CMPEQ R6,#25 ;selection menu when Menu is pressed
5430 FNLongAdr("EQ",1,menuinfo) ;over the pop-up menu icon in the
5440 MVNEQ R0,#0 ;Edit window.
5450 STREQ R0,[R1,#4]
5460 FNLongAdr("EQ",1,menulist)
5470 LDR R1,[R1,#8]
5480 STREQ R1,[R12,#currentmenu%]
5490 SUBEQ R2,R2,#64
5500 STREQ R2,[R9,#0]
5510 STREQ R3,[R9,#4]
5520 SWIEQ "Wimp_CreateMenu"
5530 LDMEQFD R13!,{R0-R12,PC}^
5540
5550 CMP R5,R8 ;This section calls a subroutine to
5560 TSTEQ R4,#(NOT 4) AND 7 ;deal with Select being pressed over
5570 BLEQ SelectInEdit ;the Edit window.
5580 LDMEQFD R13!,{R0-R12,PC}^
5590
5600 CMP R5,R8 ;This section calls a subroutine to
5610 TSTEQ R4,#(NOT 1) AND 7 ;deal with Adjust being pressed over
5620 BLEQ AdjustInEdit ;the Edit window
5630 LDMEQFD R13!,{R0-R12,PC}^
5640
5650 LDR R8,[R12,#save%]
5660 CMP R5,R8 ;This section will call a subroutine
5670 TSTEQ R4,#(NOT 4) AND 7 ;to deal with Select being pressed
5680 BLEQ SelectInSave ;in the save dialogue box.
5690 LDMEQFD R13!,{R0-R12,PC}^
5700
5710 CMP R5,R8 ;This section will call a subroutine
5720 TSTEQ R4,#(NOT 1) AND 7 ;to deal with Adjust being pressed
5730 BLEQ AdjustInSave ;in the save dialogue box
5740 LDMEQFD R13!,{R0-R12,PC}^
5750
5760 LDR R8,[R12,#update%]
5770 CMP R5,R8
5780 CMP R6,#5
5790 MOVEQ R0,#1
5800 STREQ R0,[R10,#updating%]
5810
5820 CMP R5,R8
5830 CMP R6,#6
5840 MOVEQ R0,#0
5850 STREQ R0,[R10,#updating%]
5860 STREQ R8,[R12,#block%+0]
5870 ADDEQ R1,R12,#block%
5880 SWIEQ "Wimp_CloseWindow"
5890
5900LDMFD R13!,{R0-R12,PC}^
5910
5920;-----------------------------------------------------------------------------
5930; *** SelectInDisplay ***
5940; This subroutine deals with Select being clicked over the Display window.
5950
5960.SelectInDisplay
5970
5980STMFD R13!,{R0-R12,R14}
5990
6000 LDR R0,[R10,#show%] ;This section open the appropriate
6010 CMP R0,#1 ;file for the current display mode,
6020 MOV R0,#&4F ;either Indexfile or Searchfile
6030 ADDEQ R1,R10,#indexfile
6040 ADDNE R1,R10,#searchfile
6050 SWI "XOS_Find"
6060 BVS norecords
6070 STR R0,[R10,#filehandle%]
6080 STREQ R0,[R10,#indexhandle%]
6090 STRNE R0,[R10,#searchhandle%]
6100
6110 CMP R6,#20 ;This section displays the previous
6120 SWIEQ "Hourglass_On" ;record when the single left arrow is
6130 MOVEQ R0,#1 ;clicked on with Select.
6140 MOVEQ R1,#1
6150 BLEQ GetRecords
6160 BLEQ Update
6170 SWIEQ "Hourglass_Off"
6180 BEQ selectclosefile
6190
6200 CMP R6,#21 ;This section reads back 10 records
6210 SWIEQ "Hourglass_On" ;when the double left arrow is clicked
6220 MOVEQ R0,#10 ;on with Select.
6230 MOVEQ R1,#1
6240 BLEQ GetRecords
6250 BLEQ Update
6260 SWIEQ "Hourglass_Off"
6270 BEQ selectclosefile
6280
6290 CMP R6,#22 ;This section reads back 100 records
6300 SWIEQ "Hourglass_On" ;when the triple left arrow is clicked
6310 MOVEQ R0,#100 ;on with Select
6320 MOVEQ R1,#1
6330 BLEQ GetRecords
6340 BLEQ Update
6350 SWIEQ "Hourglass_Off"
6360 BEQ selectclosefile
6370
6380 CMP R6,#23 ;This section reads the next record
6390 SWIEQ "Hourglass_On" ;when the single right arrow is clicked
6400 MOVEQ R0,#1 ;on with select.
6410 MOVEQ R1,#0
6420 BLEQ GetRecords
6430 BLEQ Update
6440 SWIEQ "Hourglass_Off"
6450 BEQ selectclosefile
6460
6470 CMP R6,#24 ;This section reads forward 10 records
6480 SWIEQ "Hourglass_On" ;when the double right arrow is clicked
6490 MOVEQ R0,#10 ;on with Select.
6500 MOVEQ R1,#0
6510 BLEQ GetRecords
6520 BLEQ Update
6530 SWIEQ "Hourglass_Off"
6540 BEQ selectclosefile
6550
6560 CMP R6,#25 ;This section reads forward 100 records
6570 SWIEQ "Hourglass_On" ;when the triple right arrow is clicked
6580 MOVEQ R0,#100 ;on with Select.
6590 MOVEQ R1,#0
6600 BLEQ GetRecords
6610 BLEQ Update
6620 SWIEQ "Hourglass_Off"
6630 BEQ selectclosefile
6640
6650 CMP R6,#26 ;This section calls a subroutine which
6660 BLEQ ShowIndex ;switches mode to display the Entire
6670 MOVEQ R0,#0 ;Index when Select is clicked over the
6680 LDREQ R1,[R10,#filehandle%] ;Entire Index icon.
6690 SWIEQ "XOS_Find" ;It then closes the currently active
6700 MOVEQ R0,#&4F ;file and opens the Indexfile as the
6710 ADDEQ R1,R10,#indexfile ;currently active file.
6720 SWIEQ "XOS_Find"
6730 BVS noindex
6740 STREQ R0,[R10,#filehandle%]
6750 LDREQ R0,[R10,#record%]
6760 MOVEQ R1,#2
6770 BLEQ GetRecords
6780 BLEQ Update
6790 BEQ selectclosefile
6800
6810 CMP R6,#27 ;This section calls a subroutine which
6820 BLEQ ShowSearch ;swithces modes to display the
6830 MOVEQ R0,#0 ;Last Search when Select is clicked
6840 LDREQ R1,[R10,#filehandle%] ;over the Last Search icon.
6850 SWIEQ "XOS_Find" ;It then closes the currently active
6860 MOVEQ R0,#&4F ;file and opens the Searchfile as the
6870 ADDEQ R1,R10,#searchfile ;currently active file.
6880 SWIEQ "XOS_Find"
6890 BVS nosearch
6900 STREQ R0,[R10,#filehandle%]
6910 LDREQ R0,[R10,#record%]
6920 MOVEQ R1,#2
6930 BLEQ GetRecords
6940 BLEQ Update
6950 BEQ selectclosefile
6960
6970 CMP R6,#37 ;This section calls a subroutine to
6980 BLEQ editrecord ;to edit the current record when Select
6990 BEQ selectclosefile ;is clicked over the Edit Record icon.
7000
7010 CMP R6,#39 ;This section calls a subroutine to
7020 BLEQ lastmonth ;read back 1 issue when Select is
7030 BEQ selectclosefile ;clicked over the Month Down icon.
7040
7050 CMP R6,#40 ;This section calls a subroutine to
7060 BLEQ nextmonth ;read forward 1 issue when Select is
7070 BEQ selectclosefile ;clicked over the Month Up icon.
7080
7090 CMP R6,#41 ;This section calls a subroutine to
7100 BLEQ lastyear ;read back 12 issues when Select is
7110 BEQ selectclosefile ;clicked over the Year Down icon.
7120
7130 CMP R6,#42 ;This section calls a subroutine to
7140 BLEQ nextyear ;read forward 12 issues when Select is
7150 BEQ selectclosefile ;clicked over the Year Up icon.
7160
7170 .selectclosefile ;This section closes both the currently
7180 MOV R0,#0 ;active file prior to returning to the
7190 LDR R1,[R10,#filehandle%] ;Wimp_Poll loop.
7200 SWI "XOS_Find"
7210
7220LDMFD R13!,{R0-R12,PC}^
7230
7240;-----------------------------------------------------------------------------
7250; *** AdjustInDisplay ***
7260; This subroutine is is called to deal with Adjust being clicked over the
7270; Display window.
7280; NB; When Adjust is clicked over adjuster icons the RISC OS Style Guide
7290; requires the adjustment to be made in the opposite direction to the arrows.
7300
7310.AdjustInDisplay
7320
7330STMFD R13!,{R0-R12,R14}
7340
7350 LDR R0,[R10,#show%] ;This section opens the appropriate
7360 CMP R0,#1 ;file for the current display mode
7370 MOV R0,#&4F ;either Indexfile or Searchfile.
7380 ADDEQ R1,R10,#indexfile
7390 ADDNE R1,R10,#searchfile
7400 SWI "XOS_Find"
7410 BVS norecords
7420 STR R0,[R10,#filehandle%]
7430 STREQ R0,[R10,#indexhandle%]
7440 STRNE R0,[R10,#searchhandle%]
7450
7460 CMP R6,#20 ;This section reads the next record
7470 SWIEQ "Hourglass_On" ;when the single left arrow is clicked
7480 MOVEQ R0,#1 ;on with Adjust.
7490 MOVEQ R1,#0
7500 BLEQ GetRecords
7510 BLEQ Update
7520 SWIEQ "Hourglass_Off"
7530 BEQ adjustclosefile
7540
7550 CMP R6,#21 ;This section reads forward 10 records
7560 SWIEQ "Hourglass_On" ;when the double left arrow is clicked
7570 MOVEQ R0,#10 ;on with Adjust.
7580 MOVEQ R1,#0
7590 BLEQ GetRecords
7600 BLEQ Update
7610 SWIEQ "Hourglass_Off"
7620 BEQ adjustclosefile
7630
7640 CMP R6,#22 ;This section reads forward 100 records
7650 SWIEQ "Hourglass_On" ;when the triple left arrow is clicked
7660 MOVEQ R0,#100 ;on with Adjust.
7670 MOVEQ R1,#0
7680 BLEQ GetRecords
7690 BLEQ Update
7700 SWIEQ "Hourglass_Off"
7710 BEQ adjustclosefile
7720
7730 CMP R6,#23 ;This section reads Back 1 record
7740 SWIEQ "Hourglass_On" ;when the single right arrow is clicked
7750 MOVEQ R0,#1 ;on with Adjust.
7760 MOVEQ R1,#1
7770 BLEQ GetRecords
7780 BLEQ Update
7790 SWIEQ "Hourglass_Off"
7800 BEQ adjustclosefile
7810
7820 CMP R6,#24 ;This section reads back 10 records
7830 SWIEQ "Hourglass_On" ;when the double right arrow is clicked
7840 MOVEQ R0,#10 ;on with Adjust.
7850 MOVEQ R1,#1
7860 BLEQ GetRecords
7870 BLEQ Update
7880 SWIEQ "Hourglass_Off"
7890 BEQ adjustclosefile
7900
7910 CMP R6,#25 ;This section reads back 100 records
7920 SWIEQ "Hourglass_On" ;when the triple right arrow is clicked
7930 MOVEQ R0,#100 ;on with Adjust.
7940 MOVEQ R1,#1
7950 BLEQ GetRecords
7960 BLEQ Update
7970 SWIEQ "Hourglass_Off"
7980 BEQ adjustclosefile
7990
8000 CMP R6,#26 ;This section calls a subroutine which
8010 BLEQ ShowIndex ;switches modes to display the Entire
8020 MOVEQ R0,#0 ;Index when Adjust is clicked over the
8030 LDREQ R1,[R10,#filehandle%] ;Entire Index icon.
8040 SWIEQ "XOS_Find" ;It then closes the currently active
8050 MOVEQ R0,#&4F ;file and opens the IndexFile as the
8060 ADDEQ R1,R10,#indexfile ;currently active file.
8070 SWIEQ "XOS_Find"
8080 BVS noindex
8090 STREQ R0,[R10,#filehandle%]
8100 LDREQ R0,[R10,#record%]
8110 MOVEQ R1,#2
8120 BLEQ GetRecords
8130 BLEQ Update
8140 BEQ adjustclosefile
8150
8160 CMP R6,#27 ;This section calls a subroutine which
8170 BLEQ ShowSearch ;switches modes to display the Last
8180 MOVEQ R0,#0 ;Search when Adjust is clicked over the
8190 LDREQ R1,[R10,#filehandle%] ;Last Search icon.
8200 SWIEQ "XOS_Find"
8210 MOVEQ R0,#&4F
8220 ADDEQ R1,R10,#searchfile
8230 SWIEQ "XOS_Find"
8240 BVS nosearch
8250 STREQ R0,[R10,#filehandle%]
8260 LDREQ R0,[R10,#record%]
8270 MOVEQ R1,#2
8280 BLEQ GetRecords
8290 BLEQ Update
8300 BEQ adjustclosefile
8310
8320 CMP R6,#37 ;This section calls a subroutine to
8330 BLEQ editrecord ;to edit the current record when
8340 BEQ adjustclosefile ;Adjust is clicked over the Edit icon.
8350
8360 CMP R6,#39 ;This section calls a subroutine which
8370 BLEQ nextmonth ;reads forward 1 Issue when Adjust is
8380 BEQ adjustclosefile ;clicked over the Month Down icon.
8390
8400 CMP R6,#40 ;This section calls a subroutine which
8410 BLEQ lastmonth ;reads back 1 Issue when Adjust is
8420 BEQ adjustclosefile ;clicked over the Month Up icon.
8430
8440 CMP R6,#41 ;This section calls a subroutine which
8450 BLEQ nextyear ;reads forward 12 Issues when Adjust is
8460 BEQ adjustclosefile ;clicked over the Year Down icon.
8470
8480 CMP R6,#42 ;This section calls a subroutine which
8490 BLEQ lastyear ;reads back 12 Issues when Adjust is
8500 BEQ adjustclosefile ;clicked over the Year Up icon.
8510
8520 .adjustclosefile ;This section closes the currently
8530 MOV R0,#0 ;active file prior to returning to
8540 LDR R1,[R10,#filehandle%] ;the Wimp_Poll loop.
8550 SWI "XOS_Find"
8560
8570LDMFD R13!,{R0-R12,PC}^
8580
8590;-----------------------------------------------------------------------------
8600; *** ShowIndex ***
8610; This subroutine is called when the 'Entire Index' icon is clicked on in the
8620; Display window. It changes the values of the Current Record and Maximum
8630; Record number etc. for displaying the Entire Index.
8640
8650.ShowIndex
8660
8670STMFD R13!,{R0,R14}
8680
8690 LDR R0,[R10,#show%] ;This section ensures that we are
8700 CMP R0,#1 ;initially showing the Last Search
8710 LDMEQFD R13!,{R0,PC}^ ;otherwise we just Return.
8720
8730 LDR R0,[R10,#indexmax%] ;Set up Current Maximum Record as the
8740 STR R0,[R10,#max%] ;Maximum Record for the Entire Index.
8750
8760 LDR R0,[R10,#record%] ;Store Current Record as Current Search
8770 STR R0,[R10,#searchrecord%] ;Record.
8780
8790 LDR R0,[R10,#indexrecord%] ;Store Current Index Record as Current
8800 STR R0,[R10,#record%] ;Record.
8810
8820 MOV R0,#1 ;Set current mode to 1 to indicate
8830 STR R0,[R10,#show%] ; we are showing the 'Entire Index'.
8840
8850 LDR R0,[R12,#display%]
8860 STR R0,[R12,#block%+0]
8870
8880 MOV R0,#37 ;This section unshades the 'Edit
8890 STR R0,[R12,#block%+4] ;record' icon.
8900 MOV R0,#0
8910 STR R0,[R12,#block%+8]
8920 MOV R0,#%1<<22
8930 STR R0,[R12,#block%+12]
8940 ADD R1,R12,#block%
8950 SWI "Wimp_SetIconState"
8960
8970 MOV R0,#26 ;This section makes the 'Entire Index'
8980 STR R0,[R12,#block%+4] ;icon Selected.
8990 MOV R0,#%1<<21
9000 STR R0,[R12,#block%+8]
9010 MOV R0,#%1<<21
9020 STR R0,[R12,#block%+12]
9030 ADD R1,R12,#block%
9040 SWI "Wimp_SetIconState"
9050
9060 MOV R0,#27 ;This section makes the 'Last Search'
9070 STR R0,[R12,#block%+4] ;icon Deselected.
9080 MOV R0,#0
9090 STR R0,[R12,#block%+8]
9100 MOV R0,#%1<<21
9110 STR R0,[R12,#block%+12]
9120 ADD R1,R12,#block%
9130 SWI "Wimp_SetIconState"
9140
9150LDMFD R13!,{R0,PC}^
9160
9170;-----------------------------------------------------------------------------
9180; *** ShowSearch ***
9190; This subroutine is called when the 'Last Search' icon is clicked on in the
9200; Display window. It changes the values of the Current Record and the Current
9210; Maximum Record etc. for displaying the Last Search.
9220
9230.ShowSearch
9240
9250STMFD R13!,{R0-R1,R14}
9260
9270 LDR R0,[R10,#show%] ;This section ensures that we are
9280 CMP R0,#0 ;initially showing the 'Entire Index'
9290 LDMEQFD R13!,{R0-R1,PC}^ ;otherwise we just return.
9300
9310 LDR R0,[R10,#searchmax%] ;Set up Current Maximum as the Current
9320 STR R0,[R10,#max%] ;Search Maximum.
9330
9340 LDR R0,[R10,#record%] ;Store the Current Record number as
9350 STR R0,[R10,#indexrecord%] ;the Current Index Record number.
9360
9370 LDR R0,[R10,#searchrecord%] ;Set up the Current Record number as
9380 STR R0,[R10,#record%] ;the Current Search Record number.
9390
9400 MOV R0,#0 ;Set the current mode to 0 to indicate
9410 STR R0,[R10,#show%] ;we are showing the 'Last Search'.
9420
9430 LDR R0,[R12,#display%]
9440 STR R0,[R12,#block%+0]
9450
9460 MOV R0,#37 ;This section Shades the 'Edit Record'
9470 STR R0,[R12,#block%+4] ;icon.
9480 MOV R0,#1<<22
9490 STR R0,[R12,#block%+8]
9500 STR R0,[R12,#block%+12]
9510 ADD R1,R12,#block%
9520 SWI "Wimp_SetIconState"
9530
9540 MOV R0,#27 ;This section makes the 'Last Search'
9550 STR R0,[R12,#block%+4] ;icon selected.
9560 MOV R0,#%1<<21
9570 STR R0,[R12,#block%+8]
9580 MOV R0,#%1<<21
9590 STR R0,[R12,#block%+12]
9600 ADD R1,R12,#block%
9610 SWI "Wimp_SetIconState"
9620
9630 MOV R0,#26 ;This section makes the 'Entire Index'
9640 STR R0,[R12,#block%+4] ;icon selected.
9650 MOV R0,#0
9660 STR R0,[R12,#block%+8]
9670 MOV R0,#%1<<21
9680 STR R0,[R12,#block%+12]
9690 ADD R1,R12,#block%
9700 SWI "Wimp_SetIconState"
9710LDMFD R13!,{R0-R1,PC}^
9720
9730;-----------------------------------------------------------------------------
9740; *** Edit Current Record ***
9750; This subroutine is called when the 'Edit Record' icon is clicked on in the
9760; Display window. It opens the Edit window and positions the Caret in the
9770; window.
9780
9790.editrecord
9800
9810STMFD R13!,{R0-R12,R14}
9820
9830 BL geteditdetails ;Fill in details of the current record
9840
9850 LDR R0,[R10,#record%] ;Store Current Record Number as
9860 STR R0,[R10,#editrecord%] ; the Current Edit Record Number.
9870
9880 LDR R3,[R12,#edit%] ;This section opens the Edit window.
9890 STR R3,[R12,#block%]
9900 ADD R1,R12,#block%
9910 SWI "Wimp_GetWindowState"
9920 SWI "Wimp_OpenWindow"
9930
9940 MOV R0,R3 ;This section reads the string from
9950 MOV R1,#20 ;the Page Number icon and finds its
9960 MOV R2,R9 ;length.
9970 BL ReadIcon
9980 MOV R0,R9
9990 MOV R1,#13
10000 SWI "String_Len"
10010 MOV R5,R1
10020
10030 MOV R0,R3 ;This section positions the caret at
10040 MOV R1,#20 ;the end of the Page Number icon.
10050 MVN R4,#0
10060 SWI "Wimp_SetCaretPosition"
10070
10080LDMFD R13!,{R0-R12,PC}^
10090
10100;-----------------------------------------------------------------------------
10110; *** GetEditDetails ***
10120; This subroutine copies the details of the current record from the Display
10130; window into the Edit window for editing.
10140
10150.geteditdetails
10160
10170STMFD R13!,{R0-R12,R14}
10180
10190 MOV R2,R9
10200 LDR R8,[R12,#display%]
10210 LDR R7,[R12,#edit%]
10220
10230 LDR R0,[R10,#displaymonth%]
10240 STR R0,[R10,#editmonth%]
10250
10260 MOV R0,R8
10270 MOV R1,#32 ;The following sections read the string
10280 BL ReadIcon ;from icons in the Display window and
10290 MOV R0,R7 ;writes them into the equiveleant icon
10300 MOV R1,#17 ;in the Edit window, to allow them to
10310 BL WriteIcon ;edited.
10320
10330 MOV R0,R8
10340 MOV R1,#33
10350 BL ReadIcon
10360 MOV R0,R7
10370 MOV R1,#18
10380 BL WriteIcon
10390
10400 MOV R0,R8
10410 MOV R1,#34
10420 BL ReadIcon
10430 MOV R0,R7
10440 MOV R1,#19
10450 BL WriteIcon
10460
10470 MOV R0,R8
10480 MOV R1,#35
10490 BL ReadIcon
10500 MOV R0,R7
10510 MOV R1,#20
10520 BL WriteIcon
10530
10540 MOV R0,R8
10550 MOV R1,#30
10560 BL ReadIcon
10570 MOV R0,R7
10580 MOV R1,#21
10590 BL WriteIcon
10600
10610 MOV R0,R8
10620 MOV R1,#31
10630 BL ReadIcon
10640 MOV R0,R7
10650 MOV R1,#22
10660 BL WriteIcon
10670
10680 STR R0,[R12,#block%+0] ;This section displays the 'Delete'
10690 MOV R0,#26 ;icon in the Edit window by clearing
10700 STR R0,[R12,#block%+4] ;its Deleted bit.
10710 MOV R0,#0
10720 STR R0,[R12,#block%+8]
10730 MOV R0,#%1<<23
10740 STR R0,[R12,#block%+12]
10750
10760 ADD R1,R12,#block%
10770 SWI "Wimp_SetIconState"
10780
10790LDMFD R13!,{R0-R12,PC}^
10800
10810;-----------------------------------------------------------------------------
10820; *** SelectInEdit ***
10830; This subroutine deals with Select being pressed over the Edit Window.
10840
10850.SelectInEdit
10860
10870STMFD R13!,{R0-R12,R14}
10880
10890 MOV R0,R8
10900
10910 CMP R6,#9 ;This section decreases the Month icon.
10920 BLEQ monthdown
10930
10940 CMP R6,#10 ;This section increases the Month icon.
10950 BLEQ monthup
10960
10970 CMP R6,#11 ;This section decreases the Year icon.
10980 MOVEQ R1,#18
10990 BLEQ down
11000
11010 CMP R6,#12 ;This section increases the Year icon.
11020 MOVEQ R1,#18
11030 BLEQ up
11040
11050 CMP R6,#13 ;This section decreases the Issue icon.
11060 MOVEQ R1,#19
11070 BLEQ down
11080
11090 CMP R6,#14 ;This section increases the Issue icon.
11100 MOVEQ R1,#19
11110 BLEQ up
11120
11130 CMP R6,#15 ;This section decreases the Page icon.
11140 MOVEQ R1,#20
11150 BLEQ down
11160
11170 CMP R6,#16 ;This section increases the Page icon.
11180 MOVEQ R1,#20
11190 BLEQ up
11200
11210 CMP R6,#23 ;This section calls a subroutine to
11220 BLEQ storerecord ;add and/or delete the record.
11230 MOVEQ R0,#13
11240 STREQB R0,[R9]
11250 LDREQ R0,[R12,#edit%]
11260 MOVEQ R2,R9
11270 MOVEQ R1,#22
11280 BLEQ WriteIcon
11290
11300 CMP R6,#24 ;This section calls a subroutine to
11310 BLEQ canceledit ;to close the edit window.
11320
11330 CMP R6,#26 ;This section calls a subroutine to
11340 BLEQ storerecord ;delete the record.
11350
11360LDMFD R13!,{R0-R12,PC}^
11370
11380;-----------------------------------------------------------------------------
11390; *** AdjustInEdit ***
11400; This subroutine deals with Adjust being clicked over the Edit window.
11410; NB; When Adjust is clicked over the adjuster icons, the Risc OS Style Guide
11420; requires the adjustment to be made in the opposite direction to the arrow.
11430
11440.AdjustInEdit
11450
11460STMFD R13!,{R0-R12,R14}
11470
11480 MOV R0,R8
11490
11500 CMP R6,#9 ;This section increases the Month icon.
11510 BLEQ monthup
11520
11530 CMP R6,#10 ;This section decreases the Month Icon.
11540 BLEQ monthdown
11550
11560 CMP R6,#11 ;This section increases the Year icon.
11570 MOVEQ R1,#18
11580 BLEQ up
11590
11600 CMP R6,#12 ;This section decreases the Year icon.
11610 MOVEQ R1,#18
11620 BLEQ down
11630
11640 CMP R6,#13 ;This section increases the Issue icon.
11650 MOVEQ R1,#19
11660 BLEQ up
11670
11680 CMP R6,#14 ;This section decreases the Issue icon.
11690 MOVEQ R1,#19
11700 BLEQ down
11710
11720 CMP R6,#15 ;This section increases the Page icon.
11730 MOVEQ R1,#20
11740 BLEQ up
11750
11760 CMP R6,#16 ;This section decreases the Page icon.
11770 MOVEQ R1,#20
11780 BLEQ down
11790
11800 CMP R6,#23 ;This section calls a subroutine to
11810 BLEQ storerecord ;Add and/or Delete the record.
11820 MOVEQ R0,#13
11830 STREQB R0,[R9]
11840 LDREQ R0,[R12,#edit%]
11850 MOVEQ R2,R9
11860 MOVEQ R1,#22
11870 BLEQ WriteIcon
11880
11890 CMP R6,#24 ;This section calls a subroutine to
11900 BLEQ canceledit ;close the Edit window
11910
11920 CMP R6,#26 ;This section calls a subroutine to
11930 BLEQ storerecord ;delete the record.
11940
11950LDMFD R13!,{R0-R12,PC}^
11960
11970;-----------------------------------------------------------------------------
11980; *** CancelEdit ***
11990; This subroutine closes the Edit Window.
12000
12010.canceledit
12020
12030STMFD R13!,{R0-R12,R14}
12040
12050 LDR R0,[R12,#edit%]
12060 STR R0,[R12,#block%+0]
12070 ADD R1,R12,#block%
12080 SWI "Wimp_CloseWindow"
12090
12100LDMFD R13!,{R0-R12,PC}^
12110
12120;-----------------------------------------------------------------------------
12130; *** MonthDown ***
12140; This subroutine decreases the value in the Month icon.
12150
12160.monthdown
12170
12180STMFD R13!,{R0-R12,R14}
12190
12200 LDR R0,[R10,#editmonth%] ;This section decreases the value of
12210 CMP R0,#1 ;the Current Month. It is set to 13
12220 MOVEQ R0,#13 ;if it was originally 1.
12230 SUBNE R0,R0,#1
12240 STR R0,[R10,#editmonth%]
12250
12260 MOV R2,#months%-&10 ;This section gets the name of the
12270 ADD R2,R2,R0,LSL #4 ;of the Current Month from a look-up
12280 ADD R2,R10,R2 ;table and writes it into the Month
12290 MOV R1,#17 ;icon.
12300 LDR R0,[R12,#edit%]
12310 BL WriteIcon
12320
12330LDMFD R13!,{R0-R12,PC}^
12340
12350;-----------------------------------------------------------------------------
12360; *** MonthUp ***
12370; This subroutine increases the value of the Month icon.
12380
12390.monthup
12400
12410STMFD R13!,{R0-R12,R14}
12420
12430 LDR R0,[R10,#editmonth%] ;This section increases the value of
12440 CMP R0,#13 ;the Current Month. It is set to 1 if
12450 MOVEQ R0,#1 ;if it was originally 13.
12460 ADDNE R0,R0,#1
12470 STR R0,[R10,#editmonth%]
12480
12490 MOV R2,#months%-&10 ;This section gets the name of the
12500 ADD R2,R2,R0,LSL #4 ;the current month from a look-up
12510 ADD R2,R10,R2 ;table and writes it into the month
12520 MOV R1,#17 ;icon.
12530 LDR R0,[R12,#edit%]
12540 BL WriteIcon
12550
12560LDMFD R13!,{R0-R12,PC}^
12570
12580;-----------------------------------------------------------------------------
12590; *** Up ***
12600; This subroutine increases the value of the icon specified by the Window
12610; Handle in R0 and an Icon Handle in R1.
12620
12630.up
12640
12650STMFD R13!,{R0-R12,R14}
12660
12670 MOV R2,R9 ;This section reads the string from
12680 BL ReadIcon ;the icon specified and find its value.
12690 MOV R8,R0
12700 MOV R7,R1
12710 MOV R0,R2
12720 MOV R1,#13
12730 SWI "String_Val"
12740
12750 MOV R0, #&2700 ;This section checks if the value is
12760 ADD R0,R0,#&000F ;9999 (&270F) and if so sets the value
12770 CMP R1,R0 ;to zero otherwise it incements it.
12780 MOVEQ R1,#0
12790 ADDNE R1,R1,#1
12800
12810 MOV R0,R1 ;This section converts the new value
12820 MOV R1,R9 ;to its string equivelent and writes
12830 MOV R6,#&100 ;it back into appropriate icon.
12840 SWI "OS_ConvertInteger2"
12850 MOV R0,#13
12860 STRB R0,[R1]
12870 MOV R0,R8
12880 MOV R1,R7
12890 MOV R2,R9
12900 BL WriteIcon
12910
12920LDMFD R13!,{R0-R12,PC}^
12930
12940;-----------------------------------------------------------------------------
12950; *** Down ***
12960; This subroutine decreases the value of the icon specified by the Window
12970; handle in R0 and the Icon handle in R1.
12980
12990.down
13000
13010STMFD R13!,{R0-R12,R14}
13020
13030 MOV R2,R9 ;This section reads the string from the
13040 BL ReadIcon ;icon specified and fins its value.
13050 MOV R8,R0
13060 MOV R7,R1
13070 MOV R0,R2
13080 MOV R1,#13
13090 SWI "String_Val"
13100
13110 CMP R1,#0 ;This section checks if the value is 0
13120 MOVEQ R1, #&2700 ;and if so sets it to 9999 (&2704)
13130 ADDEQ R1,R1,#&000F ;otherwise it decrements it.
13140 SUBNE R1,R1,#1
13150
13160 MOV R0,R1 ;This section converts the new value
13170 MOV R1,R9 ;to its string equivelent and writes
13180 MOV R6,#&100 ;it back into the appropriate icon.
13190 SWI "OS_ConvertInteger2"
13200 MOV R0,#13
13210 STRB R0,[R1]
13220 MOV R0,R8
13230 MOV R1,R7
13240 MOV R2,R9
13250 BL WriteIcon
13260
13270LDMFD R13!,{R0-R12,PC}^
13280
13290;-----------------------------------------------------------------------------
13300; *** Next Month ***
13310; This procedure reads in records until the issue number is increased by at
13320; least one.
13330
13340.nextmonth
13350
13360STMFD R13!,{R0-R12,R14}
13370
13380 SWI "Hourglass_On"
13390
13400 LDR R0,[R12,#display%] ;This section reads the Issue Number
13410 MOV R1,#34 ;icon from the Display window.
13420 MOV R2,R9
13430 BL ReadIcon
13440
13450 MOV R0,R9 ;This section gets the value of the
13460 MOV R1,#13 ;Issue Number.
13470 SWI "String_Val"
13480 MOV R8,R1
13490
13500 .nextmonthloop ;This is the start of a loop.
13510 LDR R0,[R10,#record%] ;This section exits the loop if we have
13520 LDR R1,[R10,#max%] ;reached the last record in the Index.
13530 CMP R0,R1
13540 BEQ nextmonthloopend
13550
13560 MOV R0,#1 ;This section reads in the next record.
13570 MOV R1,#0
13580 BL GetRecords
13590
13600 ADD R0,R10,#record ;This section finds the start of the
13610 ADD R1,R10,#backslash ;third field (Issue number).
13620 MOV R2,#13
13630 MOV R3,#0
13640 SWI "String_Instr"
13650 ADD R3,R3,#1
13660 SWI "String_Instr"
13670
13680 ADD R0,R0,R3 ;This section gets the value of the
13690 ADD R0,R0,#1 ;Issue Number field.
13700 MOV R1,#ASC("\")
13710 SWI "String_Val"
13720
13730 CMP R1,R8 ;This section compares the issue number
13740 BLE nextmonthloop ;that we're looking for with the issue
13750 .nextmonthloopend ;number that we have found.
13760
13770 BL Update
13780
13790 SWI "Hourglass_Off"
13800
13810LDMFD R13!,{R0-R12,PC}^
13820
13830;-----------------------------------------------------------------------------
13840; *** LastMonth ***
13850; This subroutine reads back records until the Issue Number is decreased by
13860; at least one.
13870
13880.lastmonth
13890
13900STMFD R13!,{R0-R12,R14}
13910
13920 SWI "Hourglass_On"
13930
13940 LDR R0,[R12,#display%] ;This section reads the Issue Number
13950 MOV R1,#34 ;from the Display window.
13960 MOV R2,R9
13970 BL ReadIcon
13980
13990 MOV R0,R9 ;This section gets the value of the
14000 MOV R1,#13 ;Issue Number.
14010 SWI "String_Val"
14020 SUB R8,R1,#1
14030
14040 MOV R0,#1 ;This section reads back to the start
14050 MOV R1,#1 ;of the current record.
14060 BL GetRecords
14070
14080 .lastmonthloop ;This is the start of a loop.
14090 LDR R0,[R10,#record%] ;This section exits the loop if we have
14100 MOV R1,#1 ;reached the first record in the file.
14110 CMP R0,R1
14120 BEQ lastmonthloopend
14130
14140 MOV R0,#1 ;This section reads back a record.
14150 MOV R1,#1
14160 BL GetRecords
14170
14180 ADD R0,R10,#record ;This section finds the start of the
14190 ADD R1,R10,#backslash ;third field (Issue Number).
14200 MOV R2,#13
14210 MOV R3,#0
14220 SWI "String_Instr"
14230 ADD R3,R3,#1
14240 SWI "String_Instr"
14250
14260 ADD R0,R0,R3 ;This section gets the value of the
14270 ADD R0,R0,#1 ;Issue Number field.
14280 MOV R1,#ASC("\")
14290 SWI "String_Val"
14300
14310 CMP R1,R8 ;This section compares the Issue number
14320 BGE lastmonthloop ;that we're looking for with the Issue
14330 ;number that we've found.
14340 .lastmonthloopend
14350
14360 MOV R0,#1
14370 MOV R1,#0
14380 BL GetRecords
14390
14400 BL Update
14410 SWI "Hourglass_Off"
14420
14430LDMFD R13!,{R0-R12,PC}^
14440
14450;-----------------------------------------------------------------------------
14460; *** NextYear ***
14470; This subroutine reads in records until the Issue Number is increased by at
14480; least 12.
14490
14500.nextyear
14510
14520STMFD R13!,{R0-R12,R14}
14530
14540 SWI "Hourglass_On"
14550
14560 LDR R0,[R12,#display%] ;This section reads the Issue number
14570 MOV R1,#34 ;from the Display window.
14580 MOV R2,R9
14590 BL ReadIcon
14600
14610 MOV R0,R9 ;This section gets the value of the
14620 MOV R1,#13 ;Issue Number.
14630 SWI "String_Val"
14640 ADD R8,R1,#11
14650
14660 .nextyearloop ;This is the start of a loop.
14670 LDR R0,[R10,#record%] ;This section exits the loop if we have
14680 LDR R1,[R10,#max%] ;reached the last record in the Index.
14690 CMP R0,R1
14700 BEQ nextyearloopend
14710
14720 MOV R0,#1 ;This section reads in the next record.
14730 MOV R1,#0
14740 BL GetRecords
14750
14760 ADD R0,R10,#record ;This section finds the start of the
14770 ADD R1,R10,#backslash ;third field (Issue Number).
14780 MOV R2,#13
14790 MOV R3,#0
14800 SWI "String_Instr"
14810 ADD R3,R3,#1
14820 SWI "String_Instr"
14830
14840 ADD R0,R0,R3 ;This section gets the value of the
14850 ADD R0,R0,#1 ;Issue Number.
14860 MOV R1,#ASC("\")
14870 SWI "String_Val"
14880
14890 CMP R1,R8 ;This section compares the Issue Number
14900 BLE nextyearloop ;that we're looking for with the Issue
14910 ;Number that we've found.
14920 .nextyearloopend
14930
14940 BL Update
14950 SWI "Hourglass_Off"
14960
14970LDMFD R13!,{R0-R12,PC}^
14980
14990;-----------------------------------------------------------------------------
15000; *** LastYear ***
15010; This subroutine reads back records until the Issue number is decreased by
15020; at least 12.
15030
15040.lastyear
15050
15060STMFD R13!,{R0-R12,R14}
15070
15080 SWI "Hourglass_On"
15090
15100 LDR R0,[R12,#display%] ;This section reads the Issue Number
15110 MOV R1,#34 ;from the Display window.
15120 MOV R2,R9
15130 BL ReadIcon
15140
15150 MOV R0,R9 ;This section gets the value of the
15160 MOV R1,#13 ;Issue Number.
15170 SWI "String_Val"
15180 SUB R8,R1,#12
15190
15200 MOV R0,#1 ;This section reads back to the start
15210 MOV R1,#1 ;of the current record.
15220 BL GetRecords
15230
15240 .lastyearloop ;This is the start of a loop.
15250 LDR R0,[R10,#record%] ;This section exits the loop if we have
15260 MOV R1,#1 ;reached the first record.
15270 CMP R0,R1
15280 BEQ lastyearloopend
15290
15300 MOV R0,#1 ;This section reads back 1 record.
15310 MOV R1,#1
15320 BL GetRecords
15330
15340 ADD R0,R10,#record ;This section finds the start of the
15350 ADD R1,R10,#backslash ;third field (Issue Number).
15360 MOV R2,#13
15370 MOV R3,#0
15380 SWI "String_Instr"
15390 ADD R3,R3,#1
15400 SWI "String_Instr"
15410
15420 ADD R0,R0,R3 ;This section gets the value of the
15430 ADD R0,R0,#1 ;Issue Number
15440 MOV R1,#ASC("\")
15450 SWI "String_Val"
15460
15470 CMP R1,R8 ;This section compares the Issue number
15480 BGE lastyearloop ;that we're looking for with the Issue
15490 ;Number that we've found.
15500 .lastyearloopend
15510
15520 BL Update
15530 SWI "Hourglass_Off"
15540
15550LDMFD R13!,{R0-R12,PC}^
15560
15570;-----------------------------------------------------------------------------
15580; *** SelectInSave ***
15590;This subroutine deals with Select being clicked over the Save Dialogue Box.
15600
15610.SelectInSave
15620
15630STMFD R13!,{R0-R12,R14}
15640
15650 MOV R0,R8
15660
15670 CMP R6,#4 ;This section changes the state of the
15680 LDREQ R0,[R10,#multiple%] ;Multiple Issue icon and updates the
15690 EOREQ R0,R0,#1 ;Leafname as appropriate when Select
15700 STREQ R0,[R10,#multiple%] ;is clicked over the Multiple icon.
15710 BLEQ UpdateLeafName
15720
15730 CMP R6,#1 ;This calls a subroutine to start a
15740 BLEQ StartDrag ;Drag when the user drags the File Icon
15750
15760 CMP R6,#3 ;This section reads the Filename from
15770 MOVEQ R1,#2 ;the icon when Select is clicked over
15780 MOVEQ R2,R9 ;the 'OK' icon. It then saves the
15790 BLEQ ReadIcon ;records to the file and closes the
15800 BLEQ SaveIssue ;Menu Structure.
15810 MVNEQ R1,#0
15820 SWIEQ "Wimp_CreateMenu"
15830
15840 MOV R1,#7 ;This is Start Issue icon number
15850
15860 CMP R6,#8 ;This decreses the value of the Start
15870 BLEQ down ;Issue Icon and updates the Leafname
15880 LDREQ R1,[R10,#multiple%] ;if neccessary, when Select is clicked
15890 CMPEQ R1,#0 ;over the Start Down icon in the Save
15900 MOVEQ R1,#7 ;Dialogue box.
15910 MOVEQ R2,R9
15920 BLEQ ReadIcon
15930 MOVEQ R1,#10
15940 BLEQ WriteIcon
15950 BLEQ UpdateLeafName
15960
15970 CMP R6,#9 ;This increases the value of the Start
15980 BLEQ up ;Issue Icon and updates the Leafname
15990 LDREQ R1,[R10,#multiple%] ;if neccessary, when Select is clicked
16000 CMPEQ R1,#0 ;over the Start Up icon in the Save
16010 MOVEQ R1,#7 ;Dialogue box.
16020 MOVEQ R2,R9
16030 BLEQ ReadIcon
16040 MOVEQ R1,#10
16050 BLEQ WriteIcon
16060 BLEQ UpdateLeafName
16070
16080 MOV R1,#10 ;This is the End Issue Icon number.
16090
16100 CMP R6,#11 ;This section decreases the End Issue
16110 BLEQ down ;icon when Select is clicked.
16120
16130 CMP R6,#12 ;This section increases the End Issue
16140 BLEQ up ;icon when Select is clicked.
16150
16160LDMFD R13!,{R0-R12,PC}^
16170
16180;-----------------------------------------------------------------------------
16190; *** AdjustInSave ***
16200; This subroutine deals with Adjust being clicked over the Save dialogue box.
16210; NB ; When Adjust is clicked over the adjuster icons, the Risc OS Style Guide
16220; requires the adjustment to be made in the opposite direction to the arrow.
16230
16240.AdjustInSave
16250
16260STMFD R13!,{R0-R12,R14}
16270
16280 MOV R0,R8 ;Save window handle.
16290
16300 CMP R6,#4 ;This section updates the multiple
16310 LDREQ R0,[R10,#multiple%] ;flag and calls a subroutine to update
16320 EOREQ R0,R0,#1 ;the leafname in the filename icon.
16330 STREQ R0,[R10,#multiple%]
16340 BLEQ UpdateLeafName
16350
16360 CMP R6,#1 ;This calls a subroutine to start a
16370 BLEQ StartDrag ;Drag when the user drags the fileicon.
16380
16390 CMP R6,#3 ;This section reads the filename from
16400 MOVEQ R1,#2 ;the filename icon and calls a subroutine
16410 MOVEQ R2,R9 ;to save the selected issues.
16420 BLEQ ReadIcon
16430 BLEQ SaveIssue
16440
16450 MOV R1,#7 ;'Start' icon number.
16460
16470 CMP R6,#8 ;This section increases the value in
16480 BLEQ up ;Start icon and calls a subroutine to
16490 LDREQ R1,[R10,#multiple%] ;change the leafname in the filename
16500 CMPEQ R1,#0 ;icon.
16510 MOVEQ R1,#7
16520 MOVEQ R2,R9
16530 BLEQ ReadIcon
16540 MOVEQ R1,#10
16550 BLEQ WriteIcon
16560 BLEQ UpdateLeafName
16570
16580 CMP R6,#9 ;This section decreases the value of
16590 BLEQ down ;Start icon and calls a subroutine to
16600 LDREQ R1,[R10,#multiple%] ;change the leafname in the filename
16610 CMPEQ R1,#0 ;icon.
16620 MOVEQ R1,#7
16630 MOVEQ R2,R9
16640 BLEQ ReadIcon
16650 MOVEQ R1,#10
16660 BLEQ WriteIcon
16670 BLEQ UpdateLeafName
16680
16690 MOV R1,#10 ;'End' icon number.
16700
16710 CMP R6,#11 ;This section increases the value of
16720 BLEQ up ;the End icon.
16730
16740 CMP R6,#12 ;This section decreases the value of
16750 BLEQ down ;the End icon.
16760
16770LDMFD R13!,{R0-R12,PC}^
16780
16790;-----------------------------------------------------------------------------
16800; *** StartDrag ***
16810; This subroutine initiates a drag operation when the user drags our file icon
16820; from the Save dialogue box. Depending on how the host computer is configured
16830; either a dashed outline or a solid sprite will follow the mouse pointer for
16840; the duration of the drag. A 'Drag_Finished' reason code will be returned to
16850; us by Wimp_Poll when the user releases all the mouse buttons.
16860
16870.StartDrag
16880
16890STMFD R13!,{R0-R12,R14}
16900
16910 LDR R0,[R12,#save%] ;This section stores the Save window
16920 STR R0,[R12,#block%+0] ;handle in the Wimp Parameter Block and
16930 STR R0,[R9,#0] ;the Misc. workspace.
16940
16950 MOV R0,#1 ;This section stores the icon handle of
16960 STR R0,[R12,#block%+4] ;the File icon in the Wimp Block.
16970
16980 ADD R1,R12,#block% ;This section gets information about
16990 SWI "Wimp_GetIconState" ;the position of the File icon.
17000
17010 MOV R1,R9 ;This section gets information about
17020 SWI "Wimp_GetWindowState" ;the position of the Save Dialogue box.
17030
17040 LDR R1,[R9,#4] ;Visible area minimum x coordinate
17050 LDR R2,[R9,#20] ;Scroll x offset relative to work origin
17060 SUB R1,R1,R2 ;calculate x offset of icon in window.
17070
17080 LDR R2,[R9,#16] ;Visible area maximum y coordinate.
17090 LDR R3,[R9,#24] ;Scroll y offset relative to work origin
17100 SUB R2,R2,R3 ;calculate y offset of icon in window.
17110
17120 LDR R0,[R12,#block%+8] ;This section calculates the actual max
17130 ADD R0,R0,R1 ;y coordinate of the icon in screen
17140 STR R0,[R12,#block%+8] ;coordinates.
17150
17160 LDR R0,[R12,#block%+12] ;This section calculates the actual max
17170 ADD R0,R0,R2 ;x coordinate of the icon in screen
17180 STR R0,[R12,#block%+12] ;coordinates.
17190
17200 LDR R0,[R12,#block%+16] ;This section calculates the actual min
17210 ADD R0,R0,R1 ;y coordinate of the icon in screen
17220 STR R0,[R12,#block%+16] ;coordinates.
17230
17240 LDR R0,[R12,#block%+20] ;This section calculates the actual min
17250 ADD R0,R0,R2 ;x coordinate of the icon in screen
17260 STR R0,[R12,#block%+20] ;coordinates.
17270
17280 MOV R0,#5 ;Drag type 5 - Drag fixed sixe box
17290 STR R0,[R12,#block%+4]
17300
17310 MOV R0,#0 ;This section sets the parent box, which
17320 STR R0,[R12,#block%+24] ;the icon can be dragged around inside,
17330 STR R0,[R12,#block%+28] ;to maximum size.
17340 MVN R0,#0
17350 STR R0,[R12,#block%+32]
17360 STR R0,[R12,#block%+36]
17370
17380 ADD R1,R12,#block% ;This section starts a drag operation.
17390 SWI "Wimp_DragBox"
17400
17410LDMFD R13!,{R0-R12,PC}^
17420
17430;------------------------------------------------------------------------------
17440; *** KeyPressed ***
17450; This section deals with keypresses in any of our writeable icons. Printable
17460; characters which are allowed by the icons validation string will be written
17470; automatically into the writable icon. Only non printable characters are
17480; returned to us via a 'Key_Pressed' reason code from Wimp_Poll.
17490
17500.KeyPressed
17510
17520STMFD R13!,{R0-R12,R14}
17530
17540 LDR R2,[R12,#block%+0] ;Window handle.
17550 LDR R3,[R12,#block%+4] ;Icon handle.
17560 LDR R4,[R12,#block%+24] ;Keycode pressed.
17570 LDR R5,[R12,#search%] ;Search window handle.
17580 LDR R6,[R12,#edit%] ;Edit window handle.
17590
17600 CMP R2,R5 ;This section starts a search if Return
17610 CMPEQ R3,#1 ;is pressed in the writeable icon in
17620 CMPEQ R4,#13 ;Search Window. It also removes the
17630 BLEQ StartSearch ;Menu from the screen.
17640 MVNEQ R1,#0
17650 SWIEQ "Wimp_CreateMenu"
17660 LDMEQFD R13!,{R0-R12,PC}^
17670 ;This section calls a subroutine to
17680 CMP R6,R2 ;move the caret down into the next
17690 CMPEQ R4,#13 ;writeable icon when Return is pressed
17700 BLEQ movecaretdown ;in the Edit window.
17710 LDMEQFD R13!,{R0-R12,PC}^
17720
17730 CMP R6,R2 ;This section calls a subroutine to
17740 MOVEQ R8, #&100 ;move the caret down into the next
17750 ADDEQ R8,R8,#&08E ;writeable icon when the Down arrow is
17760 CMPEQ R4,R8 ;pressed within the Edit window.
17770 BLEQ movecaretdown
17780 LDMEQFD R13!,{R0-R12,PC}^
17790
17800 CMP R6,R2 ;This section calls a subroutine to
17810 MOVEQ R8, #&100 ;move the caret up into the next
17820 ADDEQ R8,R8,#&08F ;writeable icon when the Up arrow is
17830 CMPEQ R4,R8 ;pressed within the Edit window.
17840 BLEQ movecaretup
17850 LDMEQFD R13!,{R0-R12,PC}^
17860
17870 LDR R8,[R12,#save%] ;This section calls a subroutine to
17880 CMP R2,R8 ;save or export article data when
17890 CMPEQ R4,#13 ;Return is pressed within the Filename
17900 CMPEQ R3,#2 ;icon in the Save dialogue box. It
17910 MOVEQ R0,R8 ;also closes the menu.
17920 MOVEQ R1,#2
17930 MOVEQ R2,R9
17940 BLEQ ReadIcon
17950 BLEQ SaveIssue
17960 MVNEQ R1,#0
17970 SWIEQ "Wimp_CreateMenu"
17980 LDMEQFD R13!,{R0-R12,PC}^
17990
18000 CMP R2,R8 ;This section updates the default
18010 CMPEQ R4,#13 ;Filename when Return is pressed in
18020 CMPEQ R3,#7 ;Start issue icon.
18030 LDREQ R0,[R10,#multiple%]
18040 CMPEQ R0,#0
18050 MOVEQ R0,R8
18060 MOVEQ R1,#7
18070 MOVEQ R2,R9
18080 BLEQ ReadIcon
18090 MOVEQ R1,#10
18100 BLEQ WriteIcon
18110 BLEQ UpdateLeafName
18120 LDMEQFD R13!,{R0-R12,PC}^
18130
18140 LDR R0,[R12,#block%+24] ;This section passes any keypresses we
18150 SWI "Wimp_ProcessKey" ;don't understand back to the WIMP.
18160
18170LDMFD R13!,{R0-R12,PC}^
18180
18190;------------------------------------------------------------------------------
18200; *** MoveCaretUp ***
18210; This section moves the caret into the previous icon in the Edit window.
18220
18230.movecaretup
18240
18250STMFD R13!,{R0-R12,R14}
18260
18270 CMP R3,#18 ;This section checks that the caret is
18280 LDMLSFD R13!,{R0-R12,PC}^ ;not in the first writeable icon.
18290
18300 SUB R7,R3,#1 ;This section reads the contents of
18310 MOV R0,R2 ;previous icon into the misc. buffer.
18320 MOV R1,R7
18330 MOV R2,R9
18340 BL ReadIcon
18350
18360 MOV R0,R9 ;This section finds the length of the
18370 MOV R1,#13 ;string in the previous writeable icon.
18380 SWI "String_Len"
18390 ;This section moves the caret to after
18400 MOV R5,R1 ;the last character in the previous
18410 MOV R0,R6 ;writeable icon.
18420 MOV R1,R7
18430 MVN R4,#0
18440 SWI "Wimp_SetCaretPosition"
18450
18460LDMFD R13!,{R0-R12,PC}^
18470
18480;------------------------------------------------------------------------------
18490; *** MoveCaretDown ***
18500; This section moves the caret into the next writeable icon in the Edit
18510; window.
18520
18530.movecaretdown
18540
18550STMFD R13!,{R0-R12,R14}
18560
18570 CMP R3,#22 ;This section checks that the caret is
18580 ADDLT R7,R3,#1 ;not in the last icon already and then
18590 MOVLT R0,R2 ;reads the string into misc. buffer.
18600 MOVLT R1,R7
18610 MOVLT R2,R9
18620 BLLT ReadIcon
18630
18640 MOVLT R0,R9 ;This section finds the length of the
18650 MOVLT R1,#13 ;string.
18660 SWILT "String_Len"
18670
18680 MOVLT R5,R1 ;This section positions the caret after
18690 MOVLT R0,R6 ;the last character in the next icon.
18700 MOVLT R1,R7
18710 MVNLT R4,#0
18720 SWILT "Wimp_SetCaretPosition"
18730 LDMLTFD R13!,{R0-R12,PC}^
18740
18750 CMP R4,#13 ;This section checks if the Return key
18760 LDMNEFD R13!,{R0-R12,PC}^ ;was pressed else ends the subroutine
18770
18780 BL storerecord ;This section calls a subroutine to
18790 MOV R0,#13 ;update the IndexFile with the edited
18800 STRB R0,[R9] ;record. The description icon is then
18810 LDR R0,[R12,#edit%] ;cleared.
18820 MOV R2,R9
18830 MOV R1,#22
18840 BL WriteIcon
18850
18860 LDR R6,[R10,#editrecord%] ;This section checks to see if we have
18870 CMP R6,#0 ;been adding new records. If so the
18880 MOVEQ R1,#20 ;caret is positioned at the end of the
18890 MOVEQ R2,R9 ;Page No. icon, ready for the next
18900 BLEQ ReadIcon ;record to be input.
18910 MOVEQ R0,R9
18920 MOVEQ R1,#13
18930 SWIEQ "String_Len"
18940 MOVEQ R5,R1
18950 LDREQ R0,[R12,#edit%]
18960 MOVEQ R1,#20
18970 MVNEQ R4,#0
18980 SWIEQ "Wimp_SetCaretPosition"
18990
19000LDMFD R13!,{R0-R12,PC}^
19010
19020;------------------------------------------------------------------------------
19030; *** StoreRecord ***
19040; This subroutine updates the IndexFile by removing and adding the record as
19050; appropriate. If the record is a new one it is simply added. If it is being
19060; edited the older version of the record is removed first. If the record is
19070; to be deleted it is just removed.
19080
19090.storerecord
19100
19110STMFD R13!,{R0-R12,R14}
19120
19130 SWI "Hourglass_On"
19140
19150 LDR R8,[R12,#edit%]
19160 ;The first part of this subroutine
19170 ;creates a record from the contents of
19180 ;all the icons in the Edit window.
19190
19200 LDR R0,[R10,#editmonth%] ;This is section converts the numeric
19210 ADD R1,R10,#record ;month number into a string which
19220 MOV R2,#&100 ;represents the number.
19230 SWI "OS_ConvertInteger1"
19240 MOV R2,R1
19250 MOV R0,#ASC("\")
19260 STRB R0,[R2],#1
19270
19280 MOV R0,R8 ;This section adds the year.
19290 MOV R1,#18
19300 BL ReadIcon
19310 MOV R0,R2
19320 MOV R1,#13
19330 SWI "String_Len"
19340 CMP R1,#0
19350 MOVEQ R1,#1
19360 MOVEQ R0,#ASC("0")
19370 STREQB R0,[R2]
19380 ADD R2,R2,R1
19390 MOV R0,#ASC("\")
19400 STRB R0,[R2],#1
19410
19420 MOV R0,R8 ;This section adds the Issue No.
19430 MOV R1,#19
19440 BL ReadIcon
19450 MOV R0,R2
19460 MOV R1,#13
19470 SWI "String_Len"
19480 CMP R1,#0
19490 MOVEQ R1,#1
19500 MOVEQ R0,#ASC("0")
19510 STREQB R0,[R2]
19520 ADD R2,R2,R1
19530 MOV R0,#ASC("\")
19540 STRB R0,[R2],#1
19550 ;This section adds the Page No.
19560 MOV R0,R8
19570 MOV R1,#20
19580 BL ReadIcon
19590 MOV R0,R2
19600 MOV R1,#13
19610 SWI "String_Len"
19620 CMP R1,#0
19630 MOVEQ R1,#1
19640 MOVEQ R0,#ASC("0")
19650 STREQB R0,[R2]
19660 ADD R2,R2,R1
19670 MOV R0,#ASC("\")
19680 STRB R0,[R2],#1
19690
19700 MOV R0,R8 ;This section adds the Topic.
19710 MOV R1,#21
19720 BL ReadIcon
19730 MOV R0,R2
19740 MOV R1,#13
19750 SWI "String_Len"
19760 ADD R2,R2,R1
19770 MOV R0,#ASC("\")
19780 STRB R0,[R2],#1
19790
19800 MOV R0,R8 ;This section adds the Description.
19810 MOV R1,#22
19820 BL ReadIcon
19830 MOV R0,R2
19840 MOV R1,#13
19850 SWI "String_Len"
19860 CMP R1,#1
19870 SWILE "Hourglass_Off"
19880 LDMLEFD R13!,{R0-R12,PC}^
19890 ADD R2,R2,R1
19900 MOV R0,#13
19910 STRB R0,[R2],#1
19920
19930 MOV R0,#&CF ;This section opens the IndexFile for
19940 ADD R1,R10,#indexfile ;updating.
19950 SWI "XOS_Find"
19960 BVS noindex
19970 STR R0,[R10,#indexhandle%]
19980 STR R0,[R10,#filehandle%]
19990
20000 LDR R0,[R10,#editrecord%] ;This section removes the old record
20010 CMP R0,#0 ;if neccesary and closes the edit
20020 BLNE remove ;window afterwards.
20030 LDRNE R0,[R12,#edit%]
20040 STRNE R0,[R12,#block%+0]
20050 ADDNE R1,R12,#block%
20060 SWINE "Wimp_CloseWindow"
20070
20080 CMP R6,#26 ;This section adds the record to the
20090 MOVNE R8,#0
20100 BLNE findplace
20110 BLNE insert ;index if necessay.
20120
20130 LDR R0,[R10,#show%] ;This section updates a count of the
20140 CMP R0,#1 ;number of records in the current file
20150 LDREQ R1,[R10,#indexmax%] ;if necessary.
20160 STREQ R1,[R10,#max%]
20170
20180 LDR R0,[R10,#record%] ;This section checks if the new record
20190 LDR R1,[R10,#max%] ;is greater than the maximum and if so
20200 CMP R0,R1 ;updates the maximum.
20210 STRGT R1,[R10,#record%]
20220 MOVGT R0,R1
20230
20240 MOV R1,#2 ;This section reads the current record
20250 BL GetRecords ;into the record buffer
20260
20270 MOV R0,#0 ;This section closes the index file
20280 LDR R1,[R10,#indexhandle%]
20290 SWI "XOS_Find"
20300
20310 BL Update
20320 SWI "Hourglass_Off"
20330
20340LDMFD R13!,{R0-R12,PC}^
20350
20360;------------------------------------------------------------------------------
20370; *** Remove ***
20380; This section removes the original copy of the record which is being edited
20390; from the index file.
20400
20410;On Entry
20420; R0 = Number of record to be deleted
20430
20440.remove
20450
20460STMFD R13!,{R0-R12,R14}
20470
20480 LDR R7,[R10,#indexmax%] ;This section multiplies the number of
20490 SUB R7,R7,R0 ;records 'til the end of the file by
20500 MOV R8, R7, LSL #3 ;by 88 - the length of each record.
20510 ADD R8,R8,R7, LSL #4
20520 ADD R8,R8,R7, LSL #6
20530 MOV R5,R0
20540
20550 CMP R8,#0 ;This section moves the file extent
20560 MOVEQ R0,#2 ;back by 88 bytes - one record.
20570 LDREQ R1,[R10,#indexhandle%]
20580 SWIEQ "OS_Args"
20590 MOVEQ R0,#3
20600 SUBEQ R2,R2,#88
20610 SWIEQ "OS_Args"
20620 LDREQ R0,[R10,#indexmax%]
20630 SUBEQ R0,R0,#1
20640 STREQ R0,[R10,#indexmax%]
20650 LDMEQFD R13!,{R0-R12,PC}^
20660
20670 MOV R0,#2 ;This section grabs enough memory to
20680 FNLongAdr("",1,heap) ;store the records after the record to
20690 MOV R3,R8 ;be deleted.
20700 SWI "XOS_Heap"
20710 BLVS noroom
20720 LDMVSFD R13!,{R0-R12,PC}^
20730 MOV R6,R2
20740
20750 MOV R7, R5, LSL #3
20760 ADD R7,R7,R5, LSL #4
20770 ADD R7,R7,R5, LSL #6
20780
20790 MOV R0,#3 ;This section loads in all the records
20800 LDR R1,[R10,#indexhandle%] ;after the record to be deleted
20810 MOV R3,R8
20820 MOV R4,R7
20830 SWI "XOS_GBPB"
20840 BVS noindex
20850
20860 ADD R2,R7,R8 ;This section moves the file pointer
20870 SUB R2,R2,#88 ;back 1 record - 88 bytes.
20880 SWI "XOS_Args"
20890 BVS noindex
20900
20910 MOV R0,#1 ;This section saves out the records
20920 MOV R2,R6 ;Thus deleting the required record.
20930 MOV R3,R8
20940 SUB R4,R7,#88
20950 SWI "XOS_GBPB"
20960 BCS cantupdate
20970
20980 MOV R0,#3 ;This section releases the memory
20990 FNLongAdr("",1,heap) ;claimed.
21000 MOV R2,R6
21010 SWI "XOS_Heap"
21020 BVS noheap
21030
21040 LDR R0,[R10,#indexmax%] ;This section decrements the number of
21050 SUB R0,R0,#1 ;records.
21060 STR R0,[R10,#indexmax%]
21070
21080LDMFD R13!,{R0-R12,PC}^
21090
21100;------------------------------------------------------------------------------
21110; *** FindPlace ***
21120; This subroutine locates the position in the file where the new record needs
21130; to inserted. It checks the Issue Number and the Page number.
21140
21150;On Exit
21160; R8 = Position in file where the record should be inserted after.
21170
21180.findplace
21190
21200STMFD R13!,{R0-R7,R9-R12,R14}
21210
21220 ADD R0,R10,#record ;Get Issue Number to Search For and
21230 ADD R1,R10,#backslash ;holds it in R6
21240 MOV R2,#13
21250 MOV R3,#0
21260 SWI "String_Instr"
21270 ADD R3,R3,#1
21280 SWI "String_Instr"
21290 ADD R3,R3,#1
21300 ADD R0,R0,R3
21310 MOV R1,#ASC("\")
21320 SWI "String_Val"
21330 MOV R6,R1
21340
21350
21360 .issueloop ;This loop steps through the records
21370 ;until the correct issue is found.
21380
21390 MOV R0,#2 ;This section finds the length
21400 LDR R1,[R10,#indexhandle%] ;of the file and checks that the
21410 SWI "XOS_Args" ;end has not been reached.
21420 BVS noindex
21430 CMP R8,R2
21440 LDMGEFD R13!,{R0-R7,R9-R12,PC}^
21450
21460 MOV R0,#1 ;This section positions the file
21470 MOV R2,R8 ;pointer
21480 SWI "XOS_Args"
21490 BVS noindex
21500
21510 MOV R0,R9 ;This section reads each record into a
21520 MOV R2,#256 ;buffer
21530 MOV R3,#13
21540 MOV R4,#0
21550 SWI "XString_Get$#"
21560 BVS noindex
21570
21580 MOV R0,R9 ;This section isolates the Issue number
21590 ADD R1,R10,#backslash ;and and gets its value into R1
21600 MOV R2,#13
21610 MOV R3,#0
21620 SWI "String_Instr"
21630 ADD R3,R3,#1
21640 SWI "String_Instr"
21650 ADD R3,R3,#1
21660 ADD R0,R0,R3
21670 MOV R1,#ASC("\")
21680 SWI "String_Val"
21690
21700 CMP R1,R6 ;This section compares the issue number
21710 ADDLT R8,R8,#88 ;of the current record with the issue
21720 BLT issueloop ;number we are looking for and repeats
21730 ;the loop if it is less.
21740
21750
21760 ADD R0,R10,#record ;This section gets the page number to
21770 ADD R1,R10,#backslash ;search for and holds the result in R6
21780 MOV R2,#13
21790 MOV R3,#0
21800 SWI "String_Instr"
21810 ADD R3,R3,#1
21820 SWI "String_Instr"
21830 ADD R3,R3,#1
21840 SWI "String_Instr"
21850 ADD R3,R3,#1
21860 ADD R0,R0,R3
21870 MOV R1,#ASC("\")
21880 SWI "String_Val"
21890 MOV R6,R1
21900
21910 MOV R5,#0
21920
21930 .pageloop ;This loop steps through the records
21940 ;until the correct page is found.
21950
21960 MOV R0,#2 ;This section finds the length of the
21970 LDR R1,[R10,#indexhandle%] ;file and checks we have not reached
21980 SWI "XOS_Args" ;the end already
21990 BVS noindex
22000 CMP R2,R8
22010 LDMLEFD R13!,{R0-R7,R9-R12,PC}^
22020
22030 MOV R0,#1 ;This section reads each record into
22040 MOV R2,R8 ;a buffer.
22050 SWI "XOS_Args"
22060 BVS noindex
22070 MOV R0,R9
22080 MOV R2,#256
22090 MOV R3,#13
22100 MOV R4,#0
22110 SWI "XString_Get$#"
22120 BVS noindex
22130
22140 MOV R0,R9 ;This section isolates the Page number
22150 ADD R1,R10,#backslash ;from each record.
22160 MOV R2,#13
22170 MOV R3,#0
22180 SWI "String_Instr"
22190 ADD R3,R3,#1
22200 SWI "String_Instr"
22210 ADD R3,R3,#1
22220 SWI "String_Instr"
22230 ADD R3,R3,#1
22240 ADD R0,R0,R3
22250 MOV R1,#ASC("\")
22260 SWI "String_Val"
22270
22280 CMP R1,R5 ;This section compares the two page
22290 MOVLT R2,R8 ;numbers and exits the subroutine if
22300 LDMLTFD R13!,{R0-R7,R9-R12,PC}^ ;necessary.
22310
22320 MOV R5,R1
22330
22340 CMP R1,R6 ;This section repeats the loop if
22350 ADDLE R8,R8,#88 ;the page numbers are not equal.
22360 BLE pageloop
22370
22380 MOV R2,R8
22390
22400LDMFD R13!,{R0-R7,R9-R12,PC}^
22410
22420;-----------------------------------------------------------------------------
22430; *** Insert ***
22440; This subroutine inserts the new record into the file at the place pointed to
22450; by 'findplace'.
22460
22470.insert
22480
22490STMFD R13!,{R0-R12,R14}
22500
22510 MOV R8,#0
22520 BL findplace
22530
22540 LDR R0,[R10,#indexmax%] ;This section calculates the length of
22550 MOV R7, R0, LSL #3 ;the indexfile by multiplying the
22560 ADD R7,R7,R0, LSL #4 ;number of records by 88. The number
22570 ADD R7,R7,R0, LSL #6 ;of bytes after the insertion point is
22580 SUB R7,R7,R8 ;calculated from R8.
22590
22600 CMP R7,#0 ;The next section is skipped if the new
22610 BLE saverecord ;record is to go at the end of the file
22620
22630 MOV R0,#2 ;This section claims enough free memory
22640 FNLongAdr("",1,heap) ;to load in the records after the
22650 MOV R3,R7 ;insertion point.
22660 SWI "XOS_Heap"
22670 BLVS noroom
22680 LDMVSFD R13!,{R0-R12,PC}^
22690 MOV R6,R2
22700
22710 MOV R0,#3 ;This section loads in all the records
22720 LDR R1,[R10,#indexhandle%] ;after the insertion point.
22730 MOV R3,R7
22740 MOV R4,R8
22750 SWI "XOS_GBPB"
22760 BVS cantupdate
22770
22780 .saverecord
22790 ADD R0,R10,#record ;This section calculates the number of
22800 MOV R1,#13 ;of bytes needed to pad the new record
22810 SWI "String_Len" ;out to 88 bytes.
22820 MOV R2,#13
22830 STRB R2,[R0,R1]
22840 ADD R0,R0,R1
22850 RSB R1,R1,#87
22860 SUB R1,R1,#1
22870
22880 MOV R2,#0 ;This section fills the remainder of
22890.insertloop ;the record with zero bytes.
22900 STRB R2,[R0,R1]
22910 SUBS R1,R1,#1
22920 BNE insertloop
22930
22940 MOV R0,#1 ;This section saves the new record into
22950 LDR R1,[R10,#indexhandle%] ;the index file.
22960 ADD R2,R10,#record
22970 MOV R3,#88
22980 MOV R4,R8
22990 SWI "XOS_GBPB"
23000 BVS cantupdate
23010
23020 LDR R0,[R10,#indexmax%] ;This section increments the maximum
23030 ADD R0,R0,#1 ;record number.
23040 STR R0,[R10,#indexmax%]
23050
23060 CMP R7,#0 ;This section ends the subroutine if
23070 LDMEQFD R13!,{R0-R12,PC}^ ;the record was inserted at the end.
23080
23090 MOV R0,#1 ;This section writes the remainder of
23100 MOV R2,R6 ;the records back into the file.
23110 MOV R3,R7
23120 SWI "XOS_GBPB"
23130 BVS cantupdate
23140
23150 MOV R0,#3 ;This section releases the memory
23160 FNLongAdr("",1,heap) ;claimed.
23170 MOV R2,R6
23180 SWI "XOS_Heap"
23190 BVS noheap
23200
23210LDMFD R13!,{R0-R12,PC}^
23220
23230;------------------------------------------------------------------------------
23240; *** DragFinished ***
23250; This subroutine is called when the user releases all the mouse buttons after
23260; performing a drag operation. i.e. dragging our save icon to a directory
23270; display.
23280
23290.DragFinished
23300
23310STMFD R13!,{R0-R12,R14}
23320
23330 LDR R0,[R12,#save%] ;This section reads the string from
23340 MOV R1,#2 ;the filename icon (#2) in the save
23350 MOV R2,R9 ;dialogue.
23360 BL ReadIcon
23370
23380 MOV R0,R9 ;This section finds the length of the
23390 MOV R1,#13 ;filename.
23400 SWI "String_Len"
23410 MOV R8,R1
23420
23430 SUB R1,R1,#1 ;This section locates the last '.' in
23440 .dragfinishedloop ;filename. Note; Sub-directory names
23450 LDRB R0,[R9,R1] ;are seperated by a full stop, so the
23460 CMP R0,#ASC(".") ;name after the final full stop is the
23470 ADDEQ R1,R1,#1 ;leafname.
23480 CMPNE R1,#0
23490 SUBNE R1,R1,#1
23500 BNE dragfinishedloop
23510
23520 SUB R8,R8,R1
23530
23540 MOV R0,R9 ;This section isolates the leafname.
23550 MOV R1,R9
23560 MOV R2,#13
23570 MOV R3,R8
23580 SWI "String_Right$"
23590
23600 ADD R1,R12,#block% ;This section gets details of the mouse
23610 SWI "Wimp_GetPointerInfo" ;pointer and uses the information to
23620 ;create a message block. This message
23630 ;is then sent to the Task Manager.
23640
23650 LDR R0,[R12,#block%+0] ;Mouse X coordinate
23660 STR R0,[R12,#block%+28]
23670
23680 LDR R0,[R12,#block%+4] ;Mouse Y coordinate
23690 STR R0,[R12,#block%+32]
23700
23710 LDR R0,[R12,#block%+12] ;Window Handle
23720 STR R0,[R12,#block%+20]
23730
23740 LDR R3,[R12,#block%+16] ;Icon Handle
23750 STR R3,[R12,#block%+24]
23760
23770 MOV R0,#0 ;Our Reference - 0 for initial message
23780 STR R0,[R12,#block%+12]
23790
23800 MOV R0,#1 ;Message number - 1 DataSave
23810 STR R0,[R12,#block%+16]
23820
23830 MOV R0,#88 ;Estimated size of file
23840 STR R0,[R12,#block%+36] ;The file will always be at least 88
23850
23860 MOV R0,#&0AC ;Filetype
23870 STR R0,[R12,#block%+40]
23880
23890 MOV R0,R9 ;Proposed Leafname
23900 ADD R1,R12,#block%+44
23910 MOV R2,#13
23920 SWI "String_Move$"
23930
23940 MOV R0,#0 ;This section adds a terminating zero
23950 ADD R2,R12,#block%+44 ;byte to the leafname.
23960 ADD R1,R2,R8
23970 STRB R0,[R1],#1
23980
23990 ADD R2,R8,#44+3 ;This section finds the length of the
24000 BIC R2,R2,#%11 ;entire message block and rounds it up
24010 STR R2,[R12,#block%+0] ;to the nearest word.
24020
24030 MOV R0,#18 ;This section calls the Wimp to pass
24040 ADD R1,R12,#block% ;our message block to the Task Manager
24050 LDR R2,[R12,#block%+20]
24060 SWI "Wimp_SendMessage"
24070
24080LDMFD R13!,{R0-R12,PC}^
24090
24100;------------------------------------------------------------------------------
24110; *** DataSaveAck ***
24120; This subroutine is called when the target task acknolwlegdes that we can go
24130; ahead and save our data. The 'target task' will be either the Filer if the
24140; user wants to save the file to disc or another application if the user wants
24150; to export our data.
24160
24170.DataSaveAck
24180
24190STMFD R13!,{R0-R12,R14}
24200
24210 ADD R0,R12,#block%+44 ;This section copies the filename from
24220 MOV R1,R9 ;the message block into workspace.
24230 MOV R2,#0
24240 SWI "String_Move$"
24250
24260
24270 LDR R0,[R12,#block%+0] ;This section copies the contents of
24280 LDR R8,[R12,#block%+4] ;the message block into R0-R8 so that
24290 LDR R1,[R12,#block%+8] ;the message block can be rebuilt as
24300 LDR R2,[R12,#block%+20] ;soon as we have finished saving.
24310 LDR R3,[R12,#block%+24]
24320 LDR R4,[R12,#block%+28]
24330 LDR R5,[R12,#block%+32]
24340 LDR R6,[R12,#block%+36]
24350 LDR R7,[R12,#block%+40]
24360
24370 BL SaveIssue
24380
24390 STR R0,[R12,#block%+0] ;The section rebuilds the wimp message
24400 STR R1,[R12,#block%+12] ;block.
24410 STR R2,[R12,#block%+20]
24420 STR R3,[R12,#block%+24]
24430 STR R4,[R12,#block%+28]
24440 STR R5,[R12,#block%+32]
24450 STR R6,[R12,#block%+36]
24460 STR R7,[R12,#block%+40]
24470 MOV R0,#3
24480 STR R0,[R12,#block%+16]
24490
24500 MOV R0,#18 ;This section sends a 'Data_Load'
24510 ADD R1,R12,#block% ;message to the target task, to confirm
24520 MOV R2,R8 ;that we have sent all our data.
24530 SWI "Wimp_SendMessage"
24540
24550 MVN R1,#0 ;This section ensures that the menu
24560 SWI "Wimp_CreateMenu" ;is removed from the screen.
24570
24580LDMFD R13!,{R0-R12,PC}^
24590
24600
24610;------------------------------------------------------------------------------
24620; *** SaveIssue ***
24630; This subroutine performs the actual save operation after the Wimp protocol
24640; has been performed.
24650
24660.SaveIssue
24670
24680STMFD R13!,{R0-R12,R14}
24690
24700 MOV R0,#11 ;This section creates an empty file of
24710 MOV R1,R9 ;type &0AC (IndexFile).
24720 MOV R2,#&0AC
24730 MOV R4,#0
24740 MOV R5,#0
24750 SWI "XOS_File"
24760 BVS NonSeriousError
24770
24780 MOV R0,#&CF ;This section opens the new file for
24790 MOV R1,R9 ;read/write access.
24800 SWI "XOS_Find"
24810 BVS NonSeriousError
24820 STR R0,[R10,#searchhandle%]
24830
24840 MOV R0,#&4F ;This section opens the Index for read
24850 ADD R1,R10,#indexfile ;access.
24860 SWI "XOS_Find"
24870 BVS noindex
24880 STR R0,[R10,#filehandle%]
24890
24900 LDR R0,[R10,#record%] ;This section updates the current
24910 LDR R1,[R10,#show%] ;record number for the current display
24920 CMP R1,#1 ;mode.
24930 STREQ R0,[R10,#indexrecord%]
24940 STRNE R0,[R10,#searchrecord%]
24950
24960 LDR R0,[R12,#save%] ;This section finds the value of the
24970 MOV R1,#7 ;start issue.
24980 MOV R2,R9
24990 BL ReadIcon
25000 MOV R0,R9
25010 MOV R1,#13
25020 SWI "String_Val"
25030 MOV R7,R1
25040
25050 LDR R0,[R12,#save%] ;This section finds the value of the
25060 MOV R1,#10 ;end issue. All records belonging to
25070 MOV R2,R9 ;these issues will be saved.
25080 BL ReadIcon
25090 MOV R0,R9
25100 MOV R1,#13
25110 SWI "String_Val"
25120 MOV R6,R1
25130 CMP R6,R7
25140 MOVLT R6,R7
25150 ADD R6,R6,#1
25160
25170 MOV R5,#1
25180
25190 .startloop ;This section checks if the end of the
25200 LDR R0,[R10,#indexmax%] ;file has been reached.
25210 CMP R5,R0
25220 LDRGT R7,[R10,#record%]
25230 BGT startloopend
25240 ;This section reads in a record
25250 MOV R0,R5
25260 MOV R1,#2
25270 BL GetRecords
25280
25290 ADD R0,R10,#record ;This section extract the issue number
25300 ADD R1,R10,#backslash ;from the record string.
25310 MOV R2,#13
25320 MOV R3,#0
25330 SWI "String_Instr"
25340 ADD R3,R3,#1
25350 SWI "String_Instr"
25360
25370 ADD R0,R0,R3
25380 ADD R0,R0,#1
25390 MOV R1,#ASC("\")
25400 SWI "String_Val"
25410
25420 CMP R1,R7 ;This section compares the Start issue
25430 ADDLT R5,R5,#1 ;with the issue of the record.
25440 BLT startloop
25450 LDR R7,[R10,#record%]
25460 SUBGT R7,R7,#1
25470 .startloopend
25480
25490 .endloop
25500 LDR R0,[R10,#indexmax%] ;This section checks if the end of the
25510 CMP R5,R0 ;file has been reached.
25520 BGT endloopend
25530
25540 MOV R0,R5 ;This section reads in a record.
25550 MOV R1,#2
25560 BL GetRecords
25570
25580 ADD R0,R10,#record ;This section extracts the issue number
25590 ADD R1,R10,#backslash ;from the record string.
25600 MOV R2,#13
25610 MOV R3,#0
25620 SWI "String_Instr"
25630 ADD R3,R3,#1
25640 SWI "String_Instr"
25650
25660 ADD R0,R0,R3
25670 ADD R0,R0,#1
25680 MOV R1,#ASC("\")
25690 SWI "String_Val"
25700
25710 CMP R1,R6 ;This section compares the end issue
25720 ADDLT R5,R5,#1 ;number with the issue number of the
25730 BLT endloop ;record.
25740
25750 .endloopend
25760 LDR R6,[R10,#record%]
25770
25780 MOV R0, R7, LSL #3 ;This section multiplies the record no.
25790 ADD R0,R0,R7, LSL #4 ;of the Start record by 88 to get its
25800 ADD R0,R0,R7, LSL #6 ;position in the file.
25810 MOV R7,R0
25820
25830 MOV R0, R6, LSL #3 ;This section multiplies the record no.
25840 ADD R0,R0,R6, LSL #4 ;of the End record by 88 to get its
25850 ADD R0,R0,R6, LSL #6 ;position in the file.
25860 MOV R6,R0
25870 ;This section claims enough memory to
25880 MOV R0,#2 ;load in the records to be saved.
25890 FNLongAdr("",1,heap)
25900 SUBS R3,R6,R7
25910 MOVEQ R3,#1
25920 SWI "XOS_Heap"
25930 BVS noroom
25940 MOV R5,R2
25950
25960 MOV R0,#3 ;This section loads in the records
25970 LDR R1,[R10,#filehandle%] ;which are to be saved.
25980 SUB R3,R6,R7
25990 MOV R4,R7
26000 SWI "XOS_GBPB"
26010 BVS noindex
26020
26030 MOV R0,#0 ;This section closes the index file.
26040 SWI "XOS_Find"
26050
26060 MOV R0,#1 ;This section saves the recordfs to the
26070 LDR R1,[R10,#searchhandle%] ;specified file.
26080 MOV R2,R5
26090 SUB R3,R6,R7
26100 MOV R4,#0
26110 SWI "XOS_GBPB"
26120 BVS NonSeriousError
26130
26140 MOV R0,#0 ;This section closes the new file.
26150 SWI "XOS_Find"
26160
26170LDMFD R13!,{R0-R12,PC}^
26180
26190;------------------------------------------------------------------------------
26200; *** UserMessageRecieved ***
26210; This subroutine deals with all User Messages which are sent by other tasks
26220; to us.
26230
26240.breakpoint
26250MOV PC,R14
26260
26270.UserMessageReceived
26280
26290STMFD R13!,{R0-R12,R14}
26300
26310 LDR R0,[R12,#block%+16] ;This gets the message Reason code.
26320
26330 CMP R0,#0 ;This message tells us to close down
26340 MOVEQ R0,#1 ;our application.
26350 STREQ R0,[R12,#quit%]
26360
26370 CMP R0,#1 ;Another application is trying to save
26380 BLEQ DataSave ;data and wants us to import it.
26390
26400 CMP R0,#2 ;Another task is giving us the go ahead
26410 BLEQ DataSaveAck ;to save our data.
26420
26430 CMP R0,#3 ;The filer wants us to load a file.
26440 BLEQ DataLoad
26450; BLEQ breakpoint
26460
26470 MOV R1, #&500 ;A task is requesting interactive help
26480 ADD R1,R1,#&002 ;from us.
26490 CMP R0,R1
26500 BLEQ sendhelp
26510
26520 MOV R1, #&40000 ;Our application updates files from
26530 ADD R1,R1,#&000C2 ;within our resources directory. If
26540 CMP R0,R1 ;two copies of our application are
26550 ADDEQ R0,R12,#block%+28 ;running then this could cause one copy
26560 ADDEQ R1,R12,#appname ;to crash when the first copy updated a
26570 MOVEQ R2,#13 ;a file that was expected to be
26580 MOVEQ R3,#0 ;unchanged.
26590 SWIEQ "String_Instr" ;This message is broadcast every time
26600 CMPEQ R3,#0 ;a new application is registered with
26610 MOVEQ R0,#1 ;the Wimp. We examine the new task name
26620 STREQ R0,[R12,#quit%] ;and if it is identical to our own then
26630 LDREQ R0,[R12,#task%] ;we must terminate.
26640 LDREQ R1,[R12,#block%+4]
26650 CMPEQ R0,R1
26660 MOVEQ R0,#0
26670 STREQ R0,[R12,#quit%]
26680
26690LDMFD R13!,{R0-R12,PC}^
26700
26710;-----------------------------------------------------------------------------
26720; *** SendHelp ***
26730; This subroutine is called when an Interactive Help application request help
26740; information about our application.
26750
26760.sendhelp
26770
26780STMFD R13!,{R0-R12,R14}
26790
26800 LDR R0,[R12,#block%+32] ;This is handle of the window needing
26810 ;help
26820
26830 LDR R1,[R12,#display%] ;This section deals with help about
26840 CMP R0,R1 ;the Display window.
26850 BLEQ displayhelp
26860 LDMEQFD R13!,{R0-R12,PC}^
26870
26880 LDR R1,[R12,#edit%] ;This section deals with help about
26890 CMP R0,R1 ;the Edit window.
26900 BLEQ edithelp
26910 LDMEQFD R13!,{R0-R12,PC}^
26920
26930 LDR R1,[R12,#search%] ;This section deals with help about
26940 CMP R0,R1 ;the Search window.
26950 BLEQ searchhelp
26960
26970LDMFD R13!,{R0-R12,PC}^
26980
26990;-----------------------------------------------------------------------------
27000; *** DisplayHelp ***
27010;This subroutine sends help messages about icons within the Display window.
27020
27030.displayhelp
27040
27050STMFD R13!,{R0-R12,R14}
27060
27070 LDR R0,[R12,#block%+36]
27080 ADR R1,dispnoicon
27090
27100 CMP R0,#20 ;This section checks the icon number
27110 ADREQ R1,disp20help ;of the icon that the pointer is over
27120 CMP R0,#21 ;and sets R1 to point to a message
27130 ADREQ R1,disp21help ;token.
27140 CMP R0,#22
27150 ADREQ R1,disp22help
27160 CMP R0,#23
27170 ADREQ R1,disp23help
27180 CMP R0,#24
27190 ADREQ R1,disp24help
27200 CMP R0,#25
27210 ADREQ R1,disp25help
27220 CMP R0,#26
27230 ADREQ R1,disp26help
27240 CMP R0,#27
27250 ADREQ R1,disp27help
27260 CMP R0,#28
27270 ADREQ R1,disp28help
27280 CMP R0,#29
27290 ADREQ R1,disp29help
27300 CMP R0,#30
27310 ADREQ R1,disp30help
27320 CMP R0,#31
27330 ADREQ R1,disp31help
27340 CMP R0,#32
27350 ADREQ R1,disp32help
27360 CMP R0,#33
27370 ADREQ R1,disp33help
27380 CMP R0,#34
27390 ADREQ R1,disp34help
27400 CMP R0,#35
27410 ADREQ R1,disp35help
27420 CMP R0,#37
27430 ADREQ R1,disp37help
27440 CMP R0,#38
27450 ADREQ R1,disp38help
27460 CMP R0,#39
27470 ADREQ R1,disp39help
27480 CMP R0,#40
27490 ADREQ R1,disp40help
27500 CMP R0,#41
27510 ADREQ R1,disp41help
27520 CMP R0,#42
27530 ADREQ R1,disp42help
27540 CMP R0,#43
27550 ADREQ R1,disp43help
27560
27570 BL sendhelpmessage
27580
27590LDMFD R13!,{R0-R12,PC}^
27600
27610;-----------------------------------------------------------------------------
27620; The following section contains message tokens which are to be looked up and
27630; sent to the requesting task.
27640
27650
27660.dispnoicon :EQUS "HDNoIcon"+CHR$0
27670.disp20help :EQUS "HDBack1"+CHR$0
27680.disp21help :EQUS "HDBack10"+CHR$0
27690.disp22help :EQUS "HDBack100"+CHR$0
27700.disp23help :EQUS "HDForward1"+CHR$0
27710.disp24help :EQUS "HDForward10"+CHR$0
27720.disp25help :EQUS "HDForward100"+CHR$0
27730.disp26help :EQUS "HDIndex"+CHR$0
27740.disp27help :EQUS "HDSearch"+CHR$0
27750.disp28help :EQUS "HDRecord"+CHR$0
27760.disp29help :EQUS "HDMax"+CHR$0
27770.disp30help :EQUS "HDTopic"+CHR$0
27780.disp31help :EQUS "HDDetails"+CHR$0
27790.disp32help :EQUS "HDMonth"+CHR$0
27800.disp33help :EQUS "HDYear"+CHR$0
27810.disp34help :EQUS "HDIssue"+CHR$0
27820.disp35help :EQUS "HDPage"+CHR$0
27830.disp37help :EQUS "HDEdit"+CHR$0
27840.disp38help :EQUS "HDNotFound"+CHR$0
27850.disp39help :EQUS "HDBackM"+CHR$0
27860.disp40help :EQUS "HDForwardM"+CHR$0
27870.disp41help :EQUS "HDBackY"+CHR$0
27880.disp42help :EQUS "HDForwardY"+CHR$0
27890.disp43help :EQUS "HDTopicMenu"+CHR$0
27900
27910ALIGN
27920
27930;-----------------------------------------------------------------------------
27940; *** EditHelp ***
27950;This subroutine sends help messages about icons within the Edit window.
27960
27970.edithelp
27980
27990STMFD R13!,{R0-R12,R14}^
28000
28010 LDR R0,[R12,#block%+36]
28020
28030 ADR R1,editnoicon ;This scetion checks the icon number of
28040 CMP R0,#9 ;the icon the pointer is over and sets
28050 ADREQ R1,edit9help ;R1 to point to a message token.
28060 CMP R0,#10
28070 ADREQ R1,edit10help
28080 CMP R0,#11
28090 ADREQ R1,edit11help
28100 CMP R0,#12
28110 ADREQ R1,edit12help
28120 CMP R0,#13
28130 ADREQ R1,edit13help
28140 CMP R0,#14
28150 ADREQ R1,edit14help
28160 CMP R0,#15
28170 ADREQ R1,edit15help
28180 CMP R0,#16
28190 ADREQ R1,edit16help
28200 CMP R0,#17
28210 ADREQ R1,edit17help
28220 CMP R0,#18
28230 ADREQ R1,edit18help
28240 CMP R0,#19
28250 ADREQ R1,edit19help
28260 CMP R0,#20
28270 ADREQ R1,edit20help
28280 CMP R0,#21
28290 ADREQ R1,edit21help
28300 CMP R0,#22
28310 ADREQ R1,edit22help
28320 CMP R0,#23
28330 ADREQ R1,edit23help
28340 CMP R0,#24
28350 ADREQ R1,edit24help
28360 CMP R0,#25
28370 ADREQ R1,edit25help
28380 CMP R0,#26
28390 ADREQ R1,edit26help
28400
28410 BL sendhelpmessage
28420
28430LDMFD R13!,{R0-R12,PC}^
28440
28450;------------------------------------------------------------------------------
28460; This section contins message tokens which are to be looked up and sent to
28470; the requesting task.
28480
28490.editnoicon :EQUS "HENoIcon"+CHR$(0)
28500.edit9help :EQUS "HEBackM"+CHR$(0)
28510.edit10help :EQUS "HEForwardM"+CHR$(0)
28520.edit11help :EQUS "HEBackY"+CHR$(0)
28530.edit12help :EQUS "HEForwardY"+CHR$(0)
28540.edit13help :EQUS "HEBackI"+CHR$(0)
28550.edit14help :EQUS "HEForwardI"+CHR$(0)
28560.edit15help :EQUS "HEBackP"+CHR$(0)
28570.edit16help :EQUS "HEForwardP"+CHR$(0)
28580.edit17help :EQUS "HEMonth"+CHR$(0)
28590.edit18help :EQUS "HEYear"+CHR$(0)
28600.edit19help :EQUS "HEIssue"+CHR$(0)
28610.edit20help :EQUS "HEPage"+CHR$(0)
28620.edit21help :EQUS "HETopic"+CHR$(0)
28630.edit22help :EQUS "HEDetails"+CHR$(0)
28640.edit23help :EQUS "HEOK"+CHR$(0)
28650.edit24help :EQUS "HECancel"+CHR$(0)
28660.edit25help :EQUS "HETopicMenu"+CHR$(0)
28670.edit26help :EQUS "HEDelete"+CHR$(0)
28680ALIGN
28690
28700;------------------------------------------------------------------------------
28710; *** SearchHelp ***
28720; This subroutine sends help messages about icons in the Search dialogue box.
28730
28740.searchhelp
28750
28760STMFD R13!,{R0-R12,R14}^
28770
28780 LDR R0,[R12,#block%+36]
28790 ADR R1,searchnoicon
28800 CMP R0,#1
28810 ADREQ R1,search1help
28820 CMP R0,#2
28830 ADREQ R1,search2help
28840 BL sendhelpmessage
28850
28860LDMFD R13!,{R0-R12,PC}^
28870
28880;-----------------------------------------------------------------------------
28890; This section contains message tokens which are to be looked up and sent to
28900; the requesting task.
28910
28920.searchnoicon:EQUS "HSNoIcon"+CHR$(0)
28930.search1help :EQUS "HSWriteable"+CHR$(0)
28940.search2help :EQUS "HSOK"+CHR$(0)
28950ALIGN
28960
28970;-----------------------------------------------------------------------------
28980; *** SendHelpMessage ***
28990; This subroutine looks up the message token pointed to by R1 in the Messages
29000; file and sends the Help Text back to the Task which requested it.
29010
29020.sendhelpmessage
29030
29040STMFD R13!,{R0-R12,R14}
29050
29060 LDR R0,[R12,#block%+8] ;This copies the Task handle from
29070 STR R0,[R12,#block%+12] ;Sender field to the Destination field.
29080
29090 MOV R0, #&500 ;&503 is the message number of a reply
29100 ADD R0,R0,#&003 ;to a help request.
29110 STR R0,[R12,#block%+16]
29120
29130 FNLongAdr("",0,messages) ;This section looks up the actual text
29140 ADD R2,R12,#block%+20 ;in our Messages file.
29150 MOV R3,#256-20
29160 SWI "MessageTrans_Lookup"
29170
29180 ADD R1,R3,#24 ;This section sends the Help text
29190 BIC R1,R1,#%11 ;message to the Task that requested it.
29200 STR R1,[R12,#block%+0]
29210 MOV R0,#17
29220 ADD R1,R12,#block%
29230 LDR R2,[R12,#block%+4]
29240 SWI "Wimp_SendMessage"
29250
29260LDMFD R13!,{R0-R12,PC}^
29270
29280;-----------------------------------------------------------------------------
29290; *** DataLoad ***
29300; This subroutine is called when a file icon is dragged to our iconbar icon.
29310; If the file is of a filetype we understand then we must try to load it.
29320; In our case a user will drag a file to our icon when they want to add its
29330; contents to the Index.
29340
29350.DataLoad
29360
29370STMFD R13!,{R0-R12,R14}
29380
29390
29400 LDR R0,[R12,#block%+40] ;This section ensures that the file is
29410 MOV R1, #&0AC ;of Filetype &0AC (IndexFile).
29420 CMP R0,R1
29430 LDMNEFD R13!,{R0-R12,PC}^
29440
29450 SWI "Hourglass_On"
29460
29470 MOV R0,#&4F ;This section opens the users file for
29480 ADD R1,R12,#block%+44 ;read access only.
29490 SWI "XOS_Find"
29500 BLVS noinput
29510 LDMVSFD R13!,{R0-R12,PC}^
29520 MOV R7,R0
29530 ;This section loads the first record of
29540 MOV R0,#3 ;the users file.
29550 MOV R1,R7
29560 ADD R2,R10,#record
29570 MOV R3,#88
29580 MOV R4,#0
29590 SWI "XOS_GBPB"
29600 BLVS noinput
29610 LDMVSFD R13!,{R0-R12,PC}^
29620
29630 MOV R0,#0 ;This section closes the users file.
29640 MOV R1,R7
29650 SWI "XOS_Find"
29660
29670 MOV R0,#&4F ;This section opens the index file for
29680 ADD R1,R10,#indexfile ;read access only.
29690 SWI "XOS_Find"
29700 BLVS noindex
29710 LDMVSFD R13!,{R0-R12,PC}^
29720 STR R0,[R10,#indexhandle%]
29730
29740 MOV R8,#0
29750 BL findplace
29760
29770 MOV R0,#0 ;This section closes the index file.
29780 LDR R1,[R10,#indexhandle%]
29790 SWI "XOS_Find"
29800 BVS noindex
29810
29820 SWI "Hourglass_Off"
29830
29840 LDR R0,[R10,#indexmax%]
29850 MOV R1, R0,LSL #6
29860 ADD R1,R1,R0,LSL #4
29870 ADD R1,R1,R0,LSL #3
29880 CMP R8,R1
29890 MOVEQ R0,#1
29900 MOVNE R0,#0
29910 STR R0,UpdateType
29920
29930 LDR R0,[R12,#update%]
29940 MOV R1,#2
29950 ADD R2,R12,#block%+44
29960 BL WriteIcon
29970
29980 LDR R0,[R12,#update%]
29990 MOV R1,#3
30000 MOV R2,#0
30010 BL WriteIconNo
30020
30030 STR R0,[R12,#block%+0]
30040 ADD R1,R12,#block%
30050 SWI "Wimp_GetWindowState"
30060 BL OpenWindowRequest
30070
30080 MOV R0,#0
30090 STR R0,UpdatePointer
30100 STR R0,currentplace
30110
30120LDMFD R13!,{R0-R12,PC}^
30130
30140;-----------------------------------------------------------------------------
30150
30160.ContUpdating
30170
30180LDR R8,[R10,#updating%]
30190CMP R8,#0
30200 MOVEQS PC,R14
30210
30220STMFD R13!,{R0-R12,R14}
30230
30240 LDR R0,UpdateType
30250 CMP R0,#0
30260 BLNE AppendFile
30270 LDMNEFD R13!,{R0-R12,PC}^
30280
30290 MOV R0,#&CF ;This section opens our indexfile for
30300 ADD R1,R10,#indexfile ;update.
30310 SWI "XOS_Find"
30320 STR R0,[R10,#indexhandle%]
30330 MOV R1,R0
30340 MOV R0,#254
30350 SWI "OS_Args"
30360 TST R0,#%1<<7
30370 BLEQ cantupdate
30380
30390 MOV R0,#&4F ;This section opens the users file for
30400 ADD R1,R12,#block%+44 ;read access only.
30410 SWI "XOS_Find"
30420 BLVS noinput
30430 LDMVSFD R13!,{R0-R12,PC}^
30440 MOV R7,R0
30450
30460 ;This section loads each record of the
30470 MOV R0,#3 ;users file and uses the 'insert'
30480 MOV R1,R7 ;to add it in the correct position in
30490 ADD R2,R10,#record ;the Index file.
30500 MOV R3,#88
30510 LDR R4,UpdatePointer
30520 SWI "XOS_GBPB"
30530 BLVS noinput
30540 LDMVSFD R13!,{R0-R12,PC}^
30550 LDRCC R8,currentplace
30560 BLCC findplace
30570 STRCC R8,currentplace
30580 BLCC insert
30590 BLCS FinishUpdating
30600 STR R4,UpdatePointer
30610
30620 LDR R0,[R12,#update%]
30630 MOV R1,#3
30640 BL ReadIconNo
30650 ADD R2,R2,#1
30660 BL WriteIconNo
30670
30680 MOV R0,#0 ;This section closes the Index file.
30690 LDR R1,[R10,#indexhandle%]
30700 SWI "XOS_Find"
30710
30720 MOV R0,#0 ;This section closes the users file.
30730 MOV R1,R7
30740 SWI "XOS_Find"
30750
30760LDMFD R13!,{R0-R12,PC}^
30770
30780;-----------------------------------------------------------------------------
30790.currentplace
30800EQUD 0
30810.UpdateType
30820EQUD 0
30830
30840.FinishUpdating
30850
30860STMFD R13!,{R0-R12,R14}
30870
30880
30890 MOV R0,#0
30900 STR R0,[R10,#updating%]
30910
30920 LDR R0,[R12,#update%]
30930 STR R0,[R12,#block%+0]
30940 ADD R1,R12,#block%
30950 SWI "Wimp_CloseWindow"
30960
30970 LDR R0,[R10,#show%] ;This section ensures that the program
30980 CMP R0,#1 ;is in Entire Index mode when the
30990 LDREQ R0,[R10,#indexhandle%] ;subroutine ends. Otherwise problems
31000 STREQ R0,[R10,#filehandle%] ;occur if the user switches back to
31010 LDREQ R0,[R10,#indexmax%] ;display the Entire Index later on.
31020 STREQ R0,[R10,#max%]
31030 LDREQ R0,[R10,#record%]
31040 MOVEQ R1,#2
31050 BLEQ GetRecords
31060
31070 BL Update
31080
31090LDMFD R13!,{R0-R12,PC}^
31100
31110
31120.UpdatePointer
31130EQUD 0
31140
31150;-----------------------------------------------------------------------------
31160
31170.AppendFile
31180
31190STMFD R13!,{R0-R12,R14}
31200
31210 SWI "Hourglass_On"
31220
31230 MOV R0,#5
31240 ADD R1,R12,#block%+44
31250 SWI "XOS_File"
31260 BLVS noinput
31270
31280 MOV R3,R4
31290 MOV R7,R4
31300 MOV R0,#6
31310 SWI "XOS_Module"
31320 BVS noroom
31330
31340 MOV R8,R2
31350 MOV R0,#&FF
31360 ADD R1,R12,#block%+44
31370 MOV R2,R8
31380 MOV R3,#0
31390 SWI "XOS_File"
31400 BLVS noinput
31410
31420 MOV R0,#&CF
31430 ADD R1,R10,#indexfile
31440 SWI "XOS_Find"
31450 BLVS cantupdate
31460 STR R0,[R10,#indexhandle%]
31470
31480 MOV R1,R0
31490 MOV R0,#2
31500 SWI "XOS_Args"
31510 BVS noindex
31520
31530 MOV R4,R2
31540 MOV R2,R8
31550 MOV R0,#1
31560 MOV R3,R7
31570 SWI "XOS_GBPB"
31580 BLVS cantupdate
31590
31600 LDR R1,[R10,#indexmax%]
31610 LDR R0,[R10,#indexhandle%]
31620 BL CountRecords
31630 STR R0,[R10,#indexmax%]
31640
31650 SUB R2,R0,R1
31660 LDR R0,[R12,#update%]
31670 MOV R1,#3
31680 BL WriteIconNo
31690
31700 SWI "Hourglass_Off"
31710 BL FinishUpdating
31720
31730 MOV R0,#0
31740 LDR R1,[R10,#indexhandle%]
31750 SWI "XOS_Find"
31760
31770 MOV R0,#7
31780 MOV R2,R8
31790 SWI "XOS_Module"
31800
31810
31820LDMFD R13!,{R0-R12,PC}^
31830
31840;-----------------------------------------------------------------------------
31850; *** DataSave ***
31860; This subroutine is called when an external task wants to save data to our
31870; application. This would be if the user dragged a file icon from a save
31880; dialogue box onto our icon.
31890
31900.DataSave
31910
31920STMFD R13!,{R0-R12,R14}
31930
31940 LDR R0,[R12,#block%+4] ;This section ensures that we are not
31950 LDR R1,[R12,#task%] ;trying to load our own data. ie the
31960 CMP R0,R1 ;message was sent by a task other than
31970 LDMEQFD R13!,{R0-R12,PC}^ ;ourselves.
31980
31990 ADR R0,scrapfilename ;This section ensures that <Wimp$Scrap>
32000 MOV R1,R9 ;has been asigned a value.
32010 MVN R2,#0
32020 MOV R3,#0
32030 SWI "XOS_ReadVarVal"
32040 CMP R2,#0
32050 BLEQ noscrapfile
32060 LDMEQFD R13!,{R0-R12,PC}^
32070
32080 MOV R1,#60 ;Length Of Block
32090 STR R1,[R12,#block%+0]
32100
32110 LDR R1,[R12,#block%+8] ;This is the senders reference.
32120 STR R1,[R10,#scrapref%]
32130 STR R1,[R12,#block%+12]
32140
32150 MOV R1,#2 ;Message number - 2 DataSaveAck
32160 STR R1,[R12,#block%+16]
32170
32180 ADR R0,scrapfile ;This section tags the filename
32190 ADD R1,R12,#block%+44 ;<Wimp$Scrap> to the end of the message
32200 MOV R2,#0
32210 SWI "String_Move$"
32220
32230 MVN R1,#0 ;This tells the saving application that
32240 STR R1,[R12,#block%+36] ;the saved data is not 'safe' ie on disc
32250
32260 MOV R0,#17 ;This section sends the DataSaveAck
32270 ADD R1,R12,#block% ;message to the saving task.
32280 LDR R2,[R12,#block%+4]
32290 SWI "Wimp_SendMessage"
32300
32310LDMFD R13!,{R0-R12,PC}^
32320
32330;-----------------------------------------------------------------------------
32340; This section contains strings which are used by the above subroutines.
32350
32360.scrapfile
32370
32380EQUS "<Wimp$Scrap>"
32390EQUB 0
32400ALIGN
32410
32420.scrapfilename
32430
32440EQUS "Wimp$Scrap"
32450EQUB 0
32460ALIGN
32470
32480;-----------------------------------------------------------------------------
32490; This section contains two words of memory which are used to store
32500; information about the currently open menu structure.
32510
32520.menuinfo
32530EQUD 0
32540EQUD 0
32550ALIGN
32560
32570;-----------------------------------------------------------------------------
32580; *** MenuOptionSelected ***
32590; This subroutine is called when the user selects a menu option from one of
32600; our menus.
32610
32620.MenuOptionSelected
32630
32640STMFD R13!,{R0-R12,R14}
32650
32660 ADR R7,menuinfo ;This section finds out which mouse
32670 MOV R1,R9 ;button was used to make the selection
32680 SWI "Wimp_GetPointerInfo" ;If Adjust was used the menu should
32690 LDR R0,[R9,#8] ;remain on screen.
32700 STR R0,[R7]
32710
32720 FNLongAdr("",8,menulist) ;This section loads the addresses of
32730 LDR R0,[R12,#currentmenu%] ;each of the three possible menus
32740 LDR R1,[R8,#0]
32750 LDR R2,[R8,#4]
32760 LDR R3,[R8,#8]
32770
32780
32790 CMP R0,R1 ;This section deals with the Icon Bar
32800 BLEQ DecodeIBMenu ;menu.
32810
32820 CMP R0,R2 ;This section deals with the Main menu
32830 BLEQ DecodeMainMenu ;over the Display window.
32840
32850 CMP R0,R3 ;This section deals with the Topic menu
32860 BLEQ DecodeTopicMenu ;over the pop-up menu icons.
32870
32880 LDR R1,[R7] ;This section checks which mouse button
32890 TST R1,#(NOT 1) AND 255 ;was used to select the menu option.
32900 LDREQ R1,[R12,#currentmenu%] ;If Adjust was used the menu is kept
32910 SWIEQ "Wimp_CreateMenu" ;open.
32920
32930LDMFD R13!,{R0-R12,PC}^
32940
32950;-----------------------------------------------------------------------------
32960; *** DecodeMainMenu ***
32970;This section deals with options selected from the Main menu.
32980
32990.DecodeMainMenu
33000
33010STMFD R13!,{R0-R12,R14}
33020
33030 LDR R1,[R12,#block%+0] ;This section starts a search if the
33040 CMP R1,#1 ;user selects Search from the menu.
33050 BLEQ StartSearch
33060
33070 CMP R1,#2 ;This section opens the Edit window to
33080 MOVEQ R0,#0 ;allow the Index to be Updated.
33090 STREQ R0,[R10,#editrecord%] ;It also positions the caret in the
33100 BLEQ getcurrentissue ;page number icon.
33110 LDREQ R0,[R12,#edit%]
33120 ADDEQ R1,R12,#block%
33130 STREQ R0,[R12,#block%]
33140 SWIEQ "Wimp_GetWindowState"
33150 SWIEQ "Wimp_OpenWindow"
33160 LDREQ R0,[R12,#edit%]
33170 MOVEQ R1,#20
33180 MVNEQ R4,#0
33190 MOVEQ R5,#0
33200 SWIEQ "Wimp_SetCaretPosition"
33210
33220 CMP R1,#4 ;This ssection sets our Quit flag to
33230 MOVEQ R1,#1 ;1 to indicate that we should quit when
33240 STREQ R1,[R12,#quit%] ;we return to our Wimp_Poll loop.
33250
33260LDMFD R13!,{R0-R12,PC}^
33270
33280;-----------------------------------------------------------------------------
33290; This section contains strings that are used to get the Month and Year from
33300; the UTC format that the internal system clock gives into a suitable format
33310; for use by our application.
33320
33330.monthstring
33340
33350EQUS "%MN" ;Month as a number.
33360EQUB 0
33370
33380
33390.yearstring
33400
33410EQUS "%CE%YR" ;Century number and year number.
33420EQUB 0
33430
33440;-----------------------------------------------------------------------------
33450; This section contains a five-byte data block which is filled with the UTC
33460; (Universal Time Coordinate) from the System clock.
33470
33480.time
33490
33500EQUB 3
33510EQUB 0
33520EQUB 0
33530EQUB 0
33540EQUB 0
33550ALIGN
33560
33570;-----------------------------------------------------------------------------
33580; *** GetCurrentIssue ***
33590; This section reads the time from the system clock and uses it to calculate
33600; values for the current Month, Year and Issue Number. This assists the user
33610; when they come to update the index with a new issue.
33620
33630.getcurrentissue
33640
33650STMFD R13!,{R0-R12,R14}
33660
33670 MOV R0,#14 ;Read CMOS Clock
33680 ADR R1,time
33690 SWI "OS_Word"
33700
33710 MOV R0,R1 ;This section converts the 5-byte UTC
33720 MOV R1,R9 ;into a Month number as a string.
33730 MOV R2,#&100
33740 ADR R3,monthstring
33750 SWI "OS_ConvertDateAndTime"
33760
33770 MOV R1,#0 ;This gets the value of the current
33780 SWI "String_Val" ;month number and stores it for later
33790 ADD R8,R1,#1 ;reference to the month look-up table.
33800 STR R8,[R10,#editmonth%]
33810
33820 MOV R2,#months%-&10 ;This section looks up the month number
33830 ADD R2,R2,R8,LSL #4 ;in the look-up table and fills in the
33840 ADD R2,R10,R2 ;Month icon in the Edit window.
33850 MOV R1,#17
33860 LDR R0,[R12,#edit%]
33870 BL WriteIcon
33880
33890 ADR R0,time ;This section converts the 5-byte UTC
33900 MOV R1,R9 ;to a Year number as a string.
33910 MOV R2,#&100
33920 ADR R3,yearstring
33930 SWI "OS_ConvertDateAndTime"
33940
33950 MOV R0,#13 ;This section gets the value of the
33960 STRB R0,[R1] ;Year number.
33970 MOV R0,R9
33980 MOV R1,#13
33990 SWI "String_Val"
34000 MOV R7,R1
34010
34020 MOV R1,#18 ;This section writes the string of the
34030 LDR R0,[R12,#edit%] ;year number into the Year icon in the
34040 MOV R2,R9 ;Edit window.
34050 BL WriteIcon
34060
34070
34080 MOV R0, #&7C0 ; 1994 ;This section calculates the Issue
34090 ADD R0,R0,#&00A ;number of the current issue.
34100 SUB R7,R7,R0
34110 MOV R0, R7, LSL #3 ; *13
34120 ADD R0,R0,R7, LSL #2
34130 ADD R0,R0,R7
34140 ADD R0,R0,R8
34150 ADD R0,R0,#137
34160 MOV R1,R9
34170 MOV R2,#&100
34180 SWI "OS_ConvertInteger2"
34190 MOV R0,#13
34200 STRB R0,[R1]
34210
34220 MOV R1,#19 ;This section writes the Issue number
34230 LDR R0,[R12,#edit%] ;into the appropriate icon.
34240 MOV R2,R9
34250 BL WriteIcon
34260
34270 MOV R0,#13 ;This section blanks the page number,
34280 STR R0,[R9] ;topic and description icons.
34290 LDR R0,[R12,#edit%]
34300 MOV R2,R9
34310 MOV R1,#20
34320 BL WriteIcon
34330 MOV R1,#21
34340 BL WriteIcon
34350 MOV R1,#22
34360 BL WriteIcon
34370
34380 STR R0,[R12,#block%+0] ;This section
34390 MOV R0,#26
34400 STR R0,[R12,#block%+4]
34410 MOV R0,#%1<<23
34420 STR R0,[R12,#block%+8]
34430 STR R0,[R12,#block%+12]
34440 ADD R1,R12,#block%
34450 SWI "Wimp_SetIconState"
34460
34470LDMFD R13!,{R0-R12,PC}^
34480
34490;-----------------------------------------------------------------------------
34500; *** UpdateLeafName ***
34510; This section changes the default leafname, which is written into the
34520; filename icon in the save window, when the user changes the Issue that they
34530; wish to save.
34540
34550.UpdateLeafName
34560
34570STMFD R13!,{R0-R12,R14}
34580
34590 LDR R0,[R10,#multiple%] ;This section shades the multiple
34600 CMP R0,#0 ;issues section of the window if the
34610 LDRNE R0,[R12,#save%] ;Multiple option is not selected.
34620 MOVNE R1,#2 ;If it is selected then a default name
34630 ADRNE R2,multiple ;of 'Multiple' is used.
34640 BLNE WriteIcon
34650 BLNE UnshadeSave
34660 BLEQ ShadeSave
34670 LDMNEFD R13!,{R0-R12,PC}^
34680
34690 LDR R0,[R12,#save%] ;This section reads the contents of
34700 MOV R1,#7 ;start issue number and finds its
34710 MOV R2,R9 ;value.
34720 BL ReadIcon
34730 MOV R0,R9
34740 MOV R1,#13
34750 SWI "String_Val"
34760
34770 CMP R1,#137
34780 BGT AfterDec93
34790
34800 ADD R0,R1,#6 ;This section gets the first 3 letters
34810 MOV R1,#12 ;of the Month of issue.
34820 BL Divide
34830 MOV R8,R2
34840 MOV R0,#months%
34850 ADD R0,R0,R3,LSL #4
34860 ADD R0,R10,R0
34870 MOV R1,R9
34880 MOV R2,#13
34890 MOV R3,#3
34900 SWI "String_Left$"
34910
34920
34930 ADD R0,R8,#82 ;This section gets the string of the
34940 ADD R1,R9,#3 ;year of issue and adds it to the
34950 MOV R2,#253 ;month name (eg 'Apr95').
34960 SWI "OS_ConvertInteger1"
34970 MOV R0,#13
34980 STRB R0,[R1]
34990 LDR R0,[R12,#save%]
35000 MOV R1,#2
35010 MOV R2,R9
35020 BL WriteIcon
35030
35040LDMFD R13!,{R0-R12,PC}^
35050
35060
35070.AfterDec93
35080 SUB R0,R1,#138
35090 MOV R1,#13
35100 BL Divide
35110 MOV R8,R2
35120 MOV R0,#months%
35130 ADD R0,R0,R3,LSL #4
35140 ADD R0,R10,R0
35150 MOV R1,R9
35160 MOV R2,#13
35170 MOV R3,#3
35180 SWI "String_Left$"
35190
35200 ADD R0,R8,#94 ;This section gets the string of the
35210 ADD R1,R9,#3 ;year of issue and adds it to the
35220 MOV R2,#253 ;month name (eg 'Apr95').
35230 SWI "OS_ConvertInteger1"
35240 MOV R0,#13
35250 STRB R0,[R1]
35260 LDR R0,[R12,#save%]
35270 MOV R1,#2
35280 MOV R2,R9
35290 BL WriteIcon
35300
35310LDMFD R13!,{R0-R12,PC}^
35320
35330
35340;-----------------------------------------------------------------------------
35350; *** UpdateStartEnd ***
35360; This section fills the Start and End icons in with the Issue number of the
35370; Record being displyed.
35380
35390.UpdateStartEnd
35400
35410STMFD R13!,{R0-R12,R14}
35420
35430 LDR R0,[R12,#display%] ;This section reads the Issue number
35440 MOV R1,#34 ;from the Display window.
35450 MOV R2,R9
35460 BL ReadIcon
35470
35480 LDR R0,[R12,#save%] ;This section writes the Issue number
35490 MOV R1,#7 ;into the Start and End icons in the
35500 BL WriteIcon ;Save window.
35510 MOV R1,#10
35520 BL WriteIcon
35530
35540LDMFD R13!,{R0-R12,PC}^
35550
35560;-----------------------------------------------------------------------------
35570; This section contains the string 'Multiple' which is copied into the
35580; filename icon as the default filename if more than one issue is to be saved.
35590
35600.multiple
35610
35620EQUS "Multiple"
35630EQUB 0
35640ALIGN
35650
35660;-----------------------------------------------------------------------------
35670; *** DecodeIBMenu ***
35680;This section deals with options selected from the IconBar menu.
35690
35700.DecodeIBMenu
35710
35720STMFD R13!,{R0-R12,R14}
35730
35740 LDR R1,[R12,#block%+0] ;This section sets our Quit flag to
35750 CMP R1,#1 ;to 1 to indicate that we should quit
35760 MOVEQ R1,#1 ;when we return to our Wimp_Poll loop.
35770 STREQ R1,[R12,#quit%]
35780
35790LDMFD R13!,{R0-R12,PC}^
35800
35810;-----------------------------------------------------------------------------
35820; *** DecodeTopicMenu ***
35830
35840.DecodeTopicMenu
35850
35860STMFD R13!,{R0-R12,R14}
35870
35880 SWI "Hourglass_On"
35890
35900 FNLongAdr("",1,menulist) ;This section gets the address of the
35910 LDR R1,[R1,#8] ;menu structure and converts it to its
35920 ADD R2,R12,#block% ;textual equivilent.
35930 MOV R3,R9
35940 SWI "Wimp_DecodeMenu"
35950
35960 FNLongAdr("",0,menuinfo) ;This section checks which window
35970 LDR R0,[R0,#4] ;was used to invoke the menu.
35980 CMN R0,#1
35990
36000 LDREQ R0,[R12,#edit%] ;If the Edit menu was used this section
36010 MOVEQ R1,#21 ;copies the menu option into the Topic
36020 MOVEQ R2,R9 ;icon in the edit window.
36030 BLEQ WriteIcon
36040 SWIEQ "Hourglass_Off"
36050 LDMEQFD R13!,{R0-R12,PC}^
36060
36070 MOV R0,R9 ;This section converts the Topic to all
36080 MOV R1,#13 ;lowercase letters.
36090 SWI "String_ToLowerCase"
36100
36110 LDR R8,[R10,#record%] ;This section notes the record to stop
36120 SUBS R8,R8,#1 ;at if a matching topic is not located.
36130 LDREQ R8,[R10,#max%]
36140
36150 LDR R0,[R10,#show%] ;This section opens the currently
36160 CMP R0,#1 ;active file.
36170 MOV R0,#&4F
36180 ADDEQ R1,R10,#indexfile
36190 ADDNE R1,R10,#searchfile
36200 SWI "XOS_Find"
36210 BVS norecords
36220 STR R0,[R10,#filehandle%]
36230
36240 .topicmenuloop ;This section reads in records until
36250 ;one is found which matches the chosen
36260 ;topic.
36270 LDR R0,[R10,#max%]
36280 LDR R1,[R10,#record%]
36290
36300 CMP R1,R8 ;This section checks if we have gone
36310 MOVEQ R0,#1 ;through the entire file without
36320 MOVEQ R1,#0 ;finding a match.
36330 BLEQ GetRecords
36340 BLEQ Update
36350 SWIEQ "Hourglass_Off"
36360 BEQ topicmenuloopend
36370
36380 MOV R0,#1 ;This section reads in a record and
36390 MOV R1,#0 ;copies it into another buffer.
36400 BL GetRecords
36410 ADD R0,R10,#record
36420 ADD R1,R12,#block%
36430 MOV R2,#13
36440 SWI "String_Move$"
36450
36460 MOV R0,R1 ;This section changes the record to
36470 MOV R1,R2 ;lowercase letters.
36480 SWI "String_ToLowerCase"
36490
36500 ADD R1,R10,#backslash ;This section isolates the Topic
36510 MOV R2,#13 ;field.
36520 MOV R3,#0
36530 SWI "String_Instr"
36540 ADD R3,R3,#1
36550 SWI "String_Instr"
36560 ADD R3,R3,#1
36570 SWI "String_Instr"
36580 ADD R3,R3,#1
36590 SWI "String_Instr"
36600
36610 ADD R5,R3,#1 ;This section compares the two topics
36620 MOV R1,R9
36630 SWI "String_Instr"
36640
36650 CMP R3,R5 ;This section loops back if they are
36660 BNE topicmenuloop ;not the same.
36670
36680 .topicmenuloopend
36690 MOV R0,#0 ;This section closes the file.
36700 LDR R1,[R10,#filehandle%]
36710 SWI "XOS_Find"
36720
36730 BL Update
36740 SWI "Hourglass_Off"
36750
36760LDMFD R13!,{R0-R12,PC}^
36770
36780;-----------------------------------------------------------------------------
36790; *** StartSearch ***
36800; This subroutine performs a search on the index file using the string given
36810; in the Search window.
36820
36830.StartSearch
36840
36850STMFD R13!,{R0-R12,R14}
36860
36870 SWI "Hourglass_On"
36880
36890 LDR R0,[R12,#search%] ;This section reads in the string to
36900 MOV R1,#1 ;search for.
36910 MOV R2,R9
36920 BL ReadIcon
36930
36940 MOV R0,R9 ;This section converts it to lower case
36950 MOV R1,#13
36960 SWI "String_ToLowerCase"
36970
36980 LDR R1,[R10,#show%] ;This section stores the current record
36990 CMP R1,#1 ;if the Indexfile is being displayed.
37000 LDREQ R0,[R10,#record%]
37010 STREQ R0,[R10,#indexrecord%]
37020
37030 MOV R0,#&8F ;This section opens the Search file
37040 ADD R1,R10,#searchfile ;for write access.
37050 SWI "XOS_Find"
37060 BVS nosearch
37070 STR R0,[R10,#searchhandle%]
37080
37090 MOV R0,#&4F ;This section opens the Indexfile for
37100 ADD R1,R10,#indexfile ;read access.
37110 SWI "XOS_Find"
37120 BVS noindex
37130 STR R0,[R10,#indexhandle%]
37140 STR R0,[R10,#filehandle%]
37150
37160 MOV R8,#1
37170
37180.searchloop
37190 BL percentage ;This shows percentage completion
37200 ;underneath the Hourglass.
37210 MOV R0,R8 ;This section reads in a record.
37220 MOV R1,#2
37230 BL GetRecords
37240
37250 ADD R0,R10,#record ;This section copies the string and
37260 ADD R1,R9,#90 ;converts it to lower case.
37270 MOV R2,#13
37280 SWI "String_Move$"
37290 MOV R1,#13
37300 SWI "String_ToLowerCase"
37310
37320 MOV R1,R9 ;This checks if the search string is
37330 MOV R2,#13 ;contained in the record.
37340 MOV R3,#0
37350 SWI "String_Instr"
37360
37370 CMN R3,#1
37380 BEQ searchloopend
37390
37400 MOV R0,#0 ;This section finds the position in
37410 LDR R1,[R10,#searchhandle%] ;in the search file of the file
37420 SWI "XOS_Args" ;pointer.
37430 BVS nosearch
37440 MOV R7,R2
37450
37460 ADD R0,R9,#90 ;This scetion saves the record into
37470 MOV R2,#13 ;the Searchfile.
37480 SWI "XString_Put$#"
37490 BVS nosearch
37500
37510 ADD R2,R7,#88 ;This section moves the file pointer
37520 MOV R0,#1 ;on by 88 bytes (one record).
37530 SWI "XOS_Args"
37540 BVS nosearch
37550
37560 .searchloopend
37570 LDR R1,[R10,#indexmax%] ;This section loops back if we have
37580 CMP R8,R1 ;not reached the end of the file.
37590 ADDNE R8,R8,#1
37600 BNE searchloop
37610
37620 MOV R0,#100 ;This turns of the percentage indicator
37630 SWI "Hourglass_Percentage"
37640
37650 LDR R0,[R10,#searchhandle%] ;This section counts the number of
37660 BL CountRecords ;records in the Searchfile.
37670 STR R0,[R10,#searchmax%]
37680
37690 CMP R0,#0 ;If no matches wee found this sounds a
37700 BLEQ shadesearch ;short bleep and ensures that the user
37710 SWIEQ &100+7 ; Bleep ;cannot switch to display the Searchfile
37720 BLNE unshadesearch
37730
37740 MOV R0,#1 ;This section sets the current record
37750 STR R0,[R10,#searchrecord%] ;in the Search file to no.1
37760
37770 LDR R0,[R10,#show%] ;This section loads back the record
37780 CMP R0,#1 ;that was showing before the search
37790 LDREQ R0,[R10,#indexrecord%] ;was started.
37800 MOVEQ R1,#2
37810 BLEQ GetRecords
37820
37830 LDRNE R0,[R10,#searchhandle%] ;This section switches to showing the
37840 STRNE R0,[R10,#filehandle%] ;searchfile.
37850 LDRNE R0,[R10,#searchmax%]
37860 STRNE R0,[R10,#max%]
37870 LDRNE R0,[R10,#searchrecord%]
37880 MOVNE R1,#2
37890 BLNE GetRecords
37900
37910 MOV R0,#0 ;This section closes the search file.
37920 LDR R1,[R10,#searchhandle%]
37930 SWI "XOS_Find"
37940
37950 MOV R0,#0 ;This section closes the Indexfile.
37960 LDR R1,[R10,#indexhandle%]
37970 SWI "XOS_Find"
37980
37990 BL Update
38000 SWI "Hourglass_Off"
38010
38020LDMFD R13!,{R0-R12,PC}^
38030
38040;-----------------------------------------------------------------------------
38050; *** Percentage ***
38060; This section shows a percentage indicator underneath the hourglass, showing
38070; the percentage of the search completed.
38080
38090.percentage
38100
38110STMFD R13!,{R0-R12,R14}
38120
38130 MOV R0,#0 ;This finds the current position in
38140 LDR R1,[R10,#indexhandle%] ;Indexfile.
38150 SWI "OS_Args"
38160
38170 MOV R4,R2,LSL #3 ;This section multiplies the position
38180 ADD R4,R4,R2,LSL #1 ;by 100
38190 MOV R3,R4,LSL #3
38200 ADD R3,R3,R4,LSL #1
38210
38220 MOV R0,#2 ;This section finds the total extent
38230 SWI "OS_Args" ;of the file.
38240 MOV R1,R2
38250 MOV R0,R3
38260
38270 BL Divide ;This divides one by the other to find
38280 ;the percentage complete.
38290
38300 MOV R0,R2 ;This section displays the percentage
38310 SWI "Hourglass_Percentage" ;under the hourglass.
38320
38330LDMFD R13!,{R0-R12,PC}^
38340
38350;-----------------------------------------------------------------------------
38360; *** ShadeSearch ***
38370; This subroutine greys out the 'Last Search' icon in the Display window so
38380; that it is unselectable when no matches could be found with the last search.
38390
38400.shadesearch
38410
38420STMFD R13!,{R0-R1,R14}
38430
38440 LDR R0,[R12,#display%]
38450 STR R0,[R12,#block%+0]
38460 MOV R0,#38
38470 STR R0,[R12,#block%+4]
38480 MOV R0,#0
38490 STR R0,[R12,#block%+8]
38500 MOV R0,#%1<<23
38510 STR R0,[R12,#block%+12]
38520
38530 ADD R1,R12,#block%
38540 SWI "Wimp_SetIconState"
38550
38560 BL ShowIndex
38570
38580LDMFD R13!,{R0-R1,PC}^
38590
38600;-----------------------------------------------------------------------------
38610; *** UnshadeSeacrh ***
38620; This section ensures that the 'Last Search' icon is selectable after a
38630; search has found some matching records. It also ensures that the 'Not Found'
38640; icon has its Deleted bit set so that it is not displayed.
38650
38660.unshadesearch
38670
38680STMFD R13!,{R0-R1,R14}
38690
38700 LDR R0,[R12,#display%] ;This section deletes the 'Not Found'
38710 STR R0,[R12,#block%+0] ;icon.
38720 MOV R0,#38
38730 STR R0,[R12,#block%+4]
38740 MOV R0,#%1<<23
38750 STR R0,[R12,#block%+8]
38760 STR R0,[R12,#block%+12]
38770 ADD R1,R12,#block%
38780 SWI "Wimp_SetIconState"
38790
38800 MOV R0,#27 ;This section ensures that the 'greyed
38810 STR R0,[R12,#block%+4] ;out' bit is not set for the 'Last
38820 MOV R0,#0 ;Search' icon.
38830 STR R0,[R12,#block%+8]
38840 MOV R0,#1<<22
38850 STR R0,[R12,#block%+12]
38860
38870 ADD R1,R12,#block%
38880 SWI "Wimp_SetIconState"
38890
38900 BL ShowSearch
38910
38920LDMFD R13!,{R0-R1,PC}^
38930
38940;-----------------------------------------------------------------------------
38950; *** ShadeSave ***
38960; This subroutine shades out the icons in the bottom section of the Save
38970; dialogue box when the 'Multiple' icon is not selected.
38980
38990.ShadeSave
39000
39010STMFD R13!,{R0-R1,R14}
39020
39030 LDR R0,[R12,#save%] ;This section sets up the details that
39040 STR R0,[R12,#block%+0] ;apply to all the icons.
39050 MOV R0,#%1<<22
39060 STR R0,[R12,#block%+8]
39070 STR R0,[R12,#block%+12]
39080
39090 ADD R1,R12,#block%
39100 MOV R2,#10
39110
39120.shadesaveloop ;This loop greys out each icon in turn.
39130 STR R2,[R12,#block%+4]
39140 SWI "Wimp_SetIconState"
39150 CMP R2,#12
39160 ADDNE R2,R2,#1
39170 BNE shadesaveloop
39180
39190LDMFD R13!,{R0-R1,PC}^
39200
39210;-----------------------------------------------------------------------------
39220; *** UnshadeSave ***
39230; This subroutine ensures that the icons in the bottom part of the Save
39240; dialogue box are unshaded and selectable, when the 'Multiple' icon is
39250; selected.
39260
39270.UnshadeSave
39280
39290STMFD R13!,{R0-R1,R14}
39300
39310 LDR R0,[R12,#save%] ;This section sets up the details that
39320 STR R0,[R12,#block%+0] ;that apply to all the icons.
39330 MOV R0,#0
39340 STR R0,[R12,#block%+8]
39350 MOV R0,#%1<<22
39360 STR R0,[R12,#block%+12]
39370 ADD R1,R12,#block%
39380 MOV R2,#10
39390
39400.unshadesaveloop ;This section unshades each icon in
39410 STR R2,[R12,#block%+4] ;turn.
39420 SWI "Wimp_SetIconState"
39430 CMP R2,#12
39440 ADDNE R2,R2,#1
39450 BNE unshadesaveloop
39460
39470LDMFD R13!,{R0-R1,PC}^
39480
39490;-----------------------------------------------------------------------------
39500; *** WriteIcon ***
39510;This subroutine takes a string pointed to by R2 and copies it into the
39520;indirection buffer of the icon specified by R0/R1.
39530
39540.WriteIcon
39550;R0=WindowHandle
39560;R1=IconHandle
39570;R2=PointerToText
39580
39590STMFD R13!,{R0-R8,R14}
39600
39610 MOV R7,R0 ;This section copies the parameters
39620 MOV R6,R1 ;into high numbered registers for later
39630 MOV R5,R2 ;use.
39640
39650 MOV R0,R2 ;This section finds the length of the
39660 MOV R1,#13 ;text string.
39670 SWI "String_Len"
39680 MOV R8,R1
39690
39700 STR R7,[R12,#block%+0] ;This section gets the icons details
39710 STR R6,[R12,#block%+4] ;which include the address of its
39720 ADD R1,R12,#block% ;indirection buffer.
39730 SWI "Wimp_GetIconState"
39740
39750 LDR R2,[R12,#block%+36] ;This section ensures that the string
39760 CMP R8,R2 ;supplied is not longer than the icons
39770 MOVGT R1,#13 ;indirection buffer. If it is then the
39780 STRGT R1,[R5,R2] ;string is truncated.
39790 MOVGT R8,R2
39800
39810 MOV R0,R5 ;This section copies the string into
39820 LDR R1,[R12,#block%+28] ;the icons indirection buffer.
39830 MOV R2,#13
39840 SWI "String_Move$"
39850
39860 ADD R1,R12,#block% ;This section checks if the caret is in
39870 SWI "Wimp_GetCaretPosition" ;the icon that has been updated. If so
39880 LDR R0,[R12,#block%+0] ;the caret needs to be redrawn.
39890 LDR R1,[R12,#block%+4]
39900 LDR R2,[R12,#block%+20]
39910 CMP R0,R7
39920 CMPEQ R1,R6
39930 BNE wicontinue
39940 CMP R2,R8
39950 MOVGT R5,R8
39960 MOVLE R5,R2
39970 MVN R4,#0
39980 SWI "Wimp_SetCaretPosition"
39990
40000 .wicontinue ;This section ensures that the icon is
40010 ADD R1,R12,#block% ;redrawn by the Wimp after it has been
40020 STR R7,[R12,#block%+0] ;updated.
40030 STR R6,[R12,#block%+4]
40040 MOV R3,#0
40050 STR R3,[R12,#block%+8]
40060 STR R3,[R12,#block%+12]
40070 SWI "Wimp_SetIconState"
40080
40090LDMFD R13!,{R0-R8,PC}^
40100
40110;-----------------------------------------------------------------------------
40120; *** WriteIconNo ***
40130;This subroutine takes a value R2 and copies it's string equivilent into the
40140;indirection buffer of the icon specified by R0/R1.
40150
40160.WriteIconNo
40170;R0=Window Handle
40180;R1=Icon Handle
40190;R2=Value
40200
40210STMFD R13!,{R0-R12,R14}
40220
40230MOV R7,R0
40240MOV R8,R1
40250
40260MOV R0,R2
40270MOV R1,R9
40280MOV R2,#255
40290SWI "OS_BinaryToDecimal"
40300
40310MOV R0,#13
40320STRB R0,[R9,R2]
40330
40340MOV R0,R7
40350MOV R1,R8
40360MOV R2,R9
40370BL WriteIcon
40380
40390LDMFD R13!,{R0-R12,PC}^
40400
40410;-----------------------------------------------------------------------------
40420; *** ReadIcon ***
40430; This subroutine copies the contents of an icon into the buffer pointed to by
40440; R2.
40450
40460.ReadIcon
40470;R0=Window Handle
40480;R1=IconHandle
40490;R2=Pointer to buffer
40500
40510STMFD R13!,{R0-R2,R14}
40520
40530 STR R0,[R12,#block%+0] ;This section gets the details of the
40540 STR R1,[R12,#block%+4] ;icon, including the address of it's
40550 ADD R1,R12,#block% ;indirection buffer which contains the
40560 SWI "XWimp_GetIconState" ;text string.
40570
40580 LDR R0,[R12,#block%+28] ;This section copies the string into
40590 MOV R1,R2 ;the specified buffer.
40600 MOV R2,#13
40610 SWI "String_Move$"
40620
40630LDMFD R13!,{R0-R2,PC}^
40640
40650;-----------------------------------------------------------------------------
40660; *** ReadIconNo ***
40670; This subroutine copies the contents of an icon into the buffer pointed to by
40680; R2, converting it into a decimal integer.
40690
40700.ReadIconNo
40710;R0=Window Handle
40720;R1=IconHandle
40730
40740STMFD R13!,{R0-R1,R3-R12,R14}
40750
40760MOV R2,R9
40770BL ReadIcon
40780
40790MOV R0,#10
40800MOV R1,R9
40810SWI "OS_ReadUnsigned"
40820
40830LDMFD R13!,{R0-R1,R3-R12,PC}^
40840
40850;-----------------------------------------------------------------------------
40860; *** Init ***
40870
40880.Init
40890
40900STMFD R13!,{R0-R12,R14}
40910
40920 BL InitMessages
40930
40940 LDR R0,[R12,#display%] ;This section ensures that the 'Not
40950 STR R0,[R12,#block%+0] ;Found' icon has its 'Deleted' bit set
40960 MOV R0,#38 ;so that it is initially not displayed.
40970 STR R0,[R12,#block%+4]
40980 MOV R0,#1<<23
40990 STR R0,[R12,#block%+8]
41000 STR R0,[R12,#block%+12]
41010 ADD R1,R12,#block%
41020 SWI "XWimp_SetIconState"
41030
41040 BL ShadeSave
41050
41060 MOV R0,#&4F ;This section trys to open the Search
41070 ADD R1,R10,#searchfile ;file. If it cannot be found a new one
41080 SWI "XOS_Find" ;is created.
41090 STRVC R0,[R10,#searchhandle%]
41100 BLVS CreateSearchFile
41110 LDRVS R0,[R10,#searchhandle%]
41120
41130 BL CountRecords ;The number of records in the Search
41140 STR R0,[R10,#searchmax%] ;file is counted. If there are no
41150 CMP R0,#0 ;then the 'Last Search' icon is greyed
41160 LDREQ R0,[R12,#display%] ;out so that it cannot be selected by
41170 STREQ R0,[R12,#block%+0] ;the user.
41180 MOVEQ R0,#27
41190 STREQ R0,[R12,#block%+4]
41200 MOVEQ R0,#%1<<22
41210 STREQ R0,[R12,#block%+8]
41220 STREQ R0,[R12,#block%+12]
41230 ADD R1,R12,#block%
41240 SWI "Wimp_SetIconState"
41250
41260 MOV R0,#&4F ;This section opens the Indexfile.
41270 ADD R1,R10,#indexfile
41280 SWI "XOS_Find"
41290 BVS noindex
41300 STR R0,[R10,#indexhandle%]
41310 STR R0,[R10,#filehandle%]
41320
41330 BL CountRecords ;This section counts the number of
41340 STR R0,[R10,#indexmax%] ;records in the Indexfile.
41350 STR R0,[R10,#max%]
41360 STR R0,[R10,#record%]
41370 STR R0,[R10,#indexrecord%]
41380
41390 MOV R0,#1 ;This section initialises the variables
41400 STR R0,[R10,#show%]
41410 STR R0,[R10,#searchrecord%]
41420
41430 MOV R0,#2 ;This section moves the Indexfile file
41440 LDR R1,[R10,#indexhandle%] ;pointer to the end of the file.
41450 SWI "XOS_Args"
41460 BVS noindex
41470 MOV R0,#1
41480 SWI "XOS_Args"
41490 BVS noindex
41500
41510 LDR R0,[R10,#record%] ;This section reads in the latest
41520 MOV R1,#2 ;in the Indexfile.
41530 BL GetRecords
41540
41550 MOV R0,#0 ;This section closes the indexfile.
41560 LDR R1,[R10,#indexhandle%] ;It is bad practice to leave file open
41570 SWI "XOS_Find" ;ocross calls to Wimp_Poll
41580
41590 MOV R0,#0 ;This section closes the Searchfile
41600 LDR R1,[R10,#searchhandle%]
41610 SWI "XOS_Find"
41620
41630 BL Update ;This updates the Display window.
41640
41650LDMFD R13!,{R0-R12,PC}^
41660
41670;-----------------------------------------------------------------------------
41680; *** CreateSearchFile ***
41690; This subroutine is called when no Searchfile can be found during
41700; initialisation. It creates a blank Searchfile.
41710
41720.CreateSearchFile
41730
41740STMFD R13!,{R0-R12,R14}
41750
41760 MOV R0,#11 ;This section creates an empty file
41770 ADD R1,R10,#searchfile ;of type &0AC (IndexFile).
41780 MOV R2,#&0AC
41790 MOV R4,#0
41800 MOV R5,#0
41810 SWI "XOS_File"
41820 BVS nosearch
41830
41840 MOV R0,#&4F ;This section opens the file.
41850 ADD R1,R10,#searchfile
41860 SWI "XOS_Find"
41870 BVS nosearch
41880
41890 STR R0,[R10,#searchhandle%]
41900
41910LDMFD R13!,{R0-R12,PC}^
41920
41930;-----------------------------------------------------------------------------
41940; *** InitMessages ***
41950; This section opens the applications Messages file and creates look-up tables
41960; and Menu structures from the messages.
41970
41980.InitMessages
41990
42000STMFD R13!,{R0-R12,R14}
42010
42020 MOV R0,#0 ;This section finds the upper memory
42030 MOV R1,#0 ;limit that can be accessed by our
42040 SWI "XOS_ChangeEnvironment" ;application.
42050 BVS SeriousError
42060 SUB R0,R1,#1
42070 BIC R0,R0,#%11
42080
42090 FNLongAdr("",1,heap) ;This section asigns the memory between
42100 SUB R3,R0,R1 ;the end of the program and the end of
42110 MOV R0,#0 ;our application space to be used as a
42120 SWI "XOS_Heap" ;Heap.
42130 BVS SeriousError
42140
42150 ADR R1,messagefilename ;This section finds out how big the
42160 SWI "XMessageTrans_FileInfo" ;Messages file is and claims a heap
42170 BVS nomessages ;block of the same size.
42180 MOV R0,#2
42190 FNLongAdr("",1,heap)
42200 MOV R3,R2
42210 SWI "XOS_Heap"
42220 BLVS noroom
42230 LDMVSFD R13!,{R0-R12,PC}^
42240
42250 ADR R0,messages ;This section opens the messages file
42260 ADR R1,messagefilename ;and loads it into the heap block.
42270 SWI "XMessageTrans_OpenFile"
42280 BVS nomessages
42290
42300 FNLongAdr("",0,messages) ;The following section reads in the
42310 ADD R8,R10,#months% ;Month names from the file and builds
42320 MOV R9,#0 ;up a look-up table of names.
42330
42340 .IMloop1
42350 ADD R1,R8,R9
42360 MOV R2,R1
42370 MOV R3,#&10
42380
42390 SWI "XMessageTrans_Lookup"
42400 BVS NonSeriousError ;nomessages
42410 MOV R7,#13
42420 STRB R7,[R2,R3]
42430 CMP R9,#&C0
42440 ADDNE R9,R9,#&10
42450 BNE IMloop1
42460
42470 MOV R0,#2 ;This section claims space for the
42480 FNLongAdr("",1,heap) ;iconbar menu structure.
42490 MOV R3,#72
42500 SWI "XOS_Heap"
42510 BLVS noroom
42520 LDMVSFD R13!,{R0-R12,PC}^
42530 FNLongAdr("",8,menulist)
42540 STR R2,[R8,#0]
42550
42560 FNLongAdr("",0,messages) ;This section creates the iconbar menu
42570 FNLongAdr("",1,ibmenu%) ;structure.
42580 MOV R3,#72
42590 SWI "XMessageTrans_MakeMenus"
42600 BVS nomessages
42610
42620 MOV R0,#2 ;This section claims space for the Main
42630 FNLongAdr("",1,heap) ;menu structure.
42640 MOV R3,#148
42650 SWI "XOS_Heap"
42660 BLVS noroom
42670 LDMVSFD R13!,{R0-R12,PC}^
42680 STR R2,[R8,#4]
42690
42700 FNLongAdr("",0,messages) ;This section creates the Main menu
42710 FNLongAdr("",1,mainmenu%) ;structure.
42720 MOV R3,#148
42730 SWI "XMessageTrans_MakeMenus"
42740 BVS nomessages
42750
42760 MOV R0,#2 ;This section claims space for the Topic
42770 FNLongAdr("",1,heap) ;menu structure.
42780 MOV R3,#820
42790 SWI "XOS_Heap"
42800 BLVS noroom
42810 LDMVSFD R13!,{R0-R12,PC}^
42820 STR R2,[R8,#8]
42830
42840 ADD R1,R2,R3 ;This section fills in the details of the
42850 SUB R1,R1,#12 ;last item on the topic menu which is a
42860 FNLongAdr("",7,writeabletext) ;writeable menu option.
42870 MOV R6,#0
42880 MOV R5,#256
42890 STR R7,[R1],#4
42900 STR R6,[R1],#4
42910 STR R5,[R1]
42920
42930 FNLongAdr("",0,messages) ;This section creates the Topic menu
42940 FNLongAdr("",1,topicmenu%) ;structure.
42950 MOV R3,#820
42960 SWI "XMessageTrans_MakeMenus"
42970 BVS nomessages
42980
42990 LDR R1,[R12,#info%] ;This section puts the Info window
43000 LDR R0,[R8,#0] ;handle in the Main menu structure as a
43010 STR R1,[R0,#32] ;a pointer to a sub-menu.
43020 LDR R0,[R8,#4]
43030 STR R1,[R0,#32]
43040
43050 LDR R1,[R12,#search%] ;This section puts the Search and Save
43060 STR R1,[R0,#56] ;window handles into the Main menu
43070 LDR R1,[R12,#save%] ;structure as pointers to sub-menus.
43080 STR R1,[R0,#104]
43090
43100LDMFD R13!,{R0-R12,PC}^
43110
43120;-----------------------------------------------------------------------------
43130; This section contains the pathname of the Meassages file.
43140
43150.messagefilename
43160EQUS "<AUIndex$Resource>.Messages"
43170EQUB 0
43180ALIGN
43190
43200;-----------------------------------------------------------------------------
43210; This section contains a Message file descriptor which is used to information
43220; about the Messages file.
43230
43240.messages
43250EQUD 0
43260EQUD 0
43270EQUD 0
43280EQUD 0
43290EQUD 0
43300ALIGN
43310
43320;-----------------------------------------------------------------------------
43330; *** CountRecords ***
43340; This section counts the number of records in the file specified in R0.
43350
43360.CountRecords
43370
43380;On Entry
43390;R0=filehandle
43400;
43410;On Exit
43420;R0=No. records in file
43430
43440STMFD R13!,{R1-R12,R14}
43450
43460 MOV R1,R0 ;This section finds the length of the
43470 MOV R0,#2 ;file.
43480 SWI "XOS_Args"
43490 BVS norecords
43500
43510 MOV R0,R2 ;This section divides the length of the
43520 MOV R1,#88 ;file by the length of a record, 88 bytes
43530 BL Divide ;to find the number of records.
43540 MOV R0,R2
43550
43560LDMFD R13!,{R1-R12,PC}^
43570
43580;-----------------------------------------------------------------------------
43590; *** GetRecords ***
43600; This subroutine reads in a number of records in the direction specified by
43610; R1. The routine only reads in 1 record but skips the specified number of
43620; records inbetween.
43630
43640.GetRecords
43650
43660;On Entry
43670;R0=No. Of Records to read
43680;R1=Direction 0-next
43690; 1-last
43700; 2-Read specified record
43710
43720STMFD R13!,{R0-R12,R14}
43730
43740 MOV R5,R0 ;This section copies the parameters into
43750 MOV R4,R1 ;high numbered registers for later use.
43760 LDR R8,[R10,#record%]
43770 LDR R7,[R10,#max%]
43780
43790 CMP R4,#1 ;This section checks which direction to
43800 BEQ backwards ;read in.
43810 CMP R4,#2
43820 MOVEQ R8,R0
43830 BEQ readrecord
43840
43850 CMP R8,R7 ;This section counts forward the
43860 MOVEQ R8,#0 ;specified number of records.
43870 ADD R8,R8,R5
43880 CMP R8,R7
43890 MOVGT R8,R7
43900
43910 B readrecord ;Forward branch
43920
43930 .backwards
43940 CMP R8,#1 ;This section counts backwards the
43950 MOVEQ R8,R7 ;specofied number of records.
43960 ADDEQ R8,R8,#1
43970 SUB R8,R8,R5
43980 CMP R8,#1
43990 MOVLT R8,#1
44000
44010 .readrecord
44020 SUB R8,R8,#1 ;This section multiplies the target
44030 MOV R2, R8, LSL #3 ;record number by 88 to find the position
44040 ADD R2,R2,R8, LSL #4 ;in the file where it starts.
44050 ADD R2,R2,R8, LSL #6
44060
44070 MOV R0,#1 ;This section moves the filepointer to
44080 LDR R1,[R10,#filehandle%] ;the correct position in the file.
44090 SWI "OS_Args"
44100 BVS norecords
44110
44120 ADD R0,R10,#record ;This section reads in the record up to
44130 LDR R1,[R10,#filehandle%] ;the end of the last field.
44140 MOV R2,#256
44150 MOV R3,#13
44160 MOV R4,#0
44170 SWI "String_Get$#"
44180 BVS norecords
44190
44200 ADD R8,R8,#1 ;This section updates the current record
44210 STR R8,[R10,#record%] ;number.
44220
44230LDMFD R13!,{R0-R12,PC}^
44240
44250;-----------------------------------------------------------------------------
44260; *** Update ***
44270; This subroutine takes the record stored in the Record buffer and isolates
44280; each field in turn to update each of the icons in the Display window.
44290.Update
44300
44310STMFD R13!,{R0-R12,R14}
44320
44330 LDR R8,[R12,#display%]
44340 ADD R7,R10,#record
44350 LDR R6,[R10,#record%]
44360 LDR R5,[R10,#max%]
44370
44380 MOV R0,R6 ;Record Number
44390 MOV R1,R9
44400 MOV R2,#256
44410 SWI "OS_ConvertInteger4"
44420 MOV R2,#13
44430 STRB R2,[R1,#1]
44440 MOV R0,R8
44450 MOV R1,#28
44460 MOV R2,R9
44470 BL WriteIcon
44480
44490 MOV R0,R5 ;Maximum Record Number
44500 MOV R1,R9
44510 MOV R2,#256
44520 SWI "OS_ConvertInteger4"
44530 MOV R2,#13
44540 STRB R2,[R1,#1]
44550 MOV R0,R8
44560 MOV R1,#29
44570 MOV R2,R9
44580 BL WriteIcon
44590 ;Month of Issue
44600 MOV R0,R7
44610 ADD R1,R10,#backslash
44620 MOV R2,#13
44630 MOV R3,#0
44640 SWI "String_Instr"
44650 MOV R0,R7
44660 MOV R1,R9
44670 MOV R2,#13
44680 MOV R4,#0
44690 SWI "String_Mid$"
44700 MOV R0,R1
44710 MOV R1,#13
44720 SWI "String_Val"
44730 STR R1,[R10,#displaymonth%]
44740 MOV R2,#months%-&10
44750 ADD R2,R2,R1,LSL #4
44760 ADD R2,R10,R2
44770 MOV R1,#32
44780 MOV R0,R8
44790 BL WriteIcon
44800
44810
44820 ADD R4,R3,#1 ;Year Of Issue
44830 MOV R0,R7
44840 ADD R1,R10,#backslash
44850 MOV R2,#13
44860 ADD R3,R3,#1
44870 SWI "String_Instr"
44880 MOV R5,R3
44890 MOV R1,R9
44900 MOV R0,R7
44910 MOV R2,#13
44920 SUB R3,R3,R4
44930 SWI "String_Mid$"
44940 MOV R0,R8
44950 MOV R1,#33
44960 MOV R2,R9
44970 BL WriteIcon
44980
44990 ;Issue Number
45000 MOV R3,R5
45010 ADD R4,R3,#1
45020 MOV R0,R7
45030 ADD R1,R10,#backslash
45040 MOV R2,#13
45050 ADD R3,R3,#1
45060 SWI "String_Instr"
45070 MOV R5,R3
45080 MOV R0,R7
45090 MOV R1,R9
45100 MOV R2,#13
45110 SUB R3,R3,R4
45120 SWI "String_Mid$"
45130 MOV R0,R8
45140 MOV R1,#34
45150 MOV R2,R9
45160 BL WriteIcon
45170
45180 ;Page Number
45190 MOV R3,R5
45200 ADD R4,R3,#1
45210 MOV R0,R7
45220 ADD R1,R10,#backslash
45230 MOV R2,#13
45240 ADD R3,R3,#1
45250 SWI "String_Instr"
45260 MOV R5,R3
45270 MOV R0,R7
45280 MOV R1,R9
45290 MOV R2,#13
45300 SUB R3,R3,R4
45310 SWI "String_Mid$"
45320 MOV R0,R8
45330 MOV R1,#35
45340 MOV R2,R9
45350 BL WriteIcon
45360
45370 MOV R3,R5 ;Topic Of Article
45380 ADD R4,R3,#1
45390 MOV R0,R7
45400 ADD R1,R10,#backslash
45410 MOV R2,#13
45420 ADD R3,R3,#1
45430 SWI "String_Instr"
45440 MOV R5,R3
45450 MOV R0,R7
45460 MOV R1,R9
45470 MOV R2,#13
45480 SUB R3,R3,R4
45490 SWI "String_Mid$"
45500 MOV R0,R8
45510 MOV R1,#30
45520 MOV R2,R9
45530 BL WriteIcon
45540
45550 MOV R0,R7 ;Description Of Article.
45560 MOV R1,#13
45570 SWI "String_Len"
45580 MOV R0,R5
45590 SUB R3,R1,R0
45600 SUB R3,R3,#1
45610 MOV R0,R7
45620 MOV R1,R9
45630 MOV R2,#13
45640 SWI "String_Right$"
45650 MOV R0,R8
45660 MOV R1,#31
45670 MOV R2,R9
45680 BL WriteIcon
45690
45700LDMFD R13!,{R0-R12,PC}^
45710
45720;-----------------------------------------------------------------------------
45730; *** Divide ***
45740; This subroutine performs an integer division using R0 and R1. This routine
45750; has been adapted from an algorithm by Peter Cockerell.
45760
45770.Divide
45780; Performs R2=R0 DIV R1
45790; and R3=R0 MOD R1
45800
45810STMFD R13!,{R0-R1,R4-R12,R14}
45820
45830 CMP R1,#0 ;Trap Division by Zero errors.
45840 BEQ divbyzero
45850
45860 MOV R2,#0 ;Initialise registers.
45870 MOV R3,#0
45880 MOV R4,#32 ;Initialise counter.
45890
45900 .divloop1
45910 SUBS R4,R4,#1 ;Shift R0 until first set bit is in bit
45920 LDMEQFD R13!,{R0-R1,R4-R12,PC}^ ;31. If the couter reaches 0 first then
45930 MOVS R0,R0,ASL #1 ;R0 was zero to start with.
45940 BPL divloop1
45950
45960 .divloop2
45970 MOVS R0,R0,ASL #1 ;Shift top bit of R0 into R3
45980 ADC R3,R3,R3 ;This value is then subtracted from R1 if
45990 CMP R3,R1 ;it does not produce a negative result.
46000 SUBCS R3,R3,R1
46010
46020 ADC R2,R2,R2 ;Repeat for each significant bit of R0.
46030 SUBS R4,R4,#1
46040 BNE divloop2
46050
46060LDMFD R13!,{R0-R1,R4-R12,PC}^
46070
46080;-----------------------------------------------------------------------------
46090; *** Error Handling Routines ***
46100;-----------------------------------------------------------------------------
46110;This subroutine deals with Division By Zero errors.
46120
46130 .divbyzero
46140
46150LDMFD R13!,{R0-R1,R4-R12,R14} ;This section simply reports the error
46160 ADR R0,divbyzeroerror ;to the user.
46170 MOV R1,#3
46180 MOV R2,#0
46190 SWI "Wimp_ReportError"
46200MOV PC,R14
46210
46220;-----------------------------------------------------------------------------
46230; This section contains the string used in the DivByZero error message.
46240
46250.divbyzeroerror
46260EQUD 0
46270EQUS "Division By Zero"
46280EQUB 0
46290ALIGN
46300
46310;-----------------------------------------------------------------------------
46320;This section deals with not being able to access the Indexfile.
46330
46340.noindex
46350 ADR R0,noindexerror
46360 FNLongAdr("",1,messages)
46370 MOV R2,#0
46380 SWI "XMessageTrans_ErrorLookup"
46390 B SeriousError
46400
46410;-----------------------------------------------------------------------------
46420; This section contains the Message Token for the NoIndex error.
46430
46440.noindexerror
46450EQUD 0
46460EQUS "NoIndex"
46470EQUB 0
46480ALIGN
46490
46500;-----------------------------------------------------------------------------
46510;This section deals with not being able to access the Indexfile for update.
46520
46530.cantupdate
46540 MOV R0,#0
46550 STR R0,[R10,#updating%]
46560 LDR R0,[R12,#update%]
46570 STR R0,[R12,#block%+0]
46580 ADD R1,R12,#block%
46590 SWI "Wimp_CloseWindow"
46600
46610 ADR R0,cantupdateerror
46620 FNLongAdr("",1,messages)
46630 MOV R2,#0
46640 SWI "XMessageTrans_ErrorLookup"
46650 B NonSeriousError
46660
46670;-----------------------------------------------------------------------------
46680; This section contains the Message Token for the cantupdate error.
46690
46700.cantupdateerror
46710EQUD 0
46720EQUS "CantUpdate"
46730EQUB 0
46740ALIGN
46750;-----------------------------------------------------------------------------
46760; This section deals with not being able to access the Searchfile.
46770
46780.nosearch
46790 ADR R0,nosearcherror
46800 FNLongAdr("",1,messages)
46810 MOV R2,#0
46820 SWI "XMessageTrans_ErrorLookup"
46830 B SeriousError
46840
46850;-----------------------------------------------------------------------------
46860; This section contains the Message Token for the NoSearch error.
46870
46880.nosearcherror
46890EQUD 0
46900EQUS "NoSearch"
46910EQUB 0
46920ALIGN
46930
46940;-----------------------------------------------------------------------------
46950; This section produces an error when the Indexfile contains no records.
46960
46970.norecords
46980 ADR R0,norecordserror
46990 FNLongAdr("",1,messages)
47000 MOV R2,#0
47010 SWI "XMessageTrans_ErrorLookup"
47020 B SeriousError
47030
47040;-----------------------------------------------------------------------------
47050; This section contains the Message Token for the NoRecords error.
47060
47070.norecordserror
47080EQUD 0
47090EQUS "NoRecords"
47100EQUB 0
47110ALIGN
47120
47130;-----------------------------------------------------------------------------
47140; This section deals with not being able to access a file that is to be
47150; merged with the index.
47160
47170.noinput
47180STMFD R13!,{R0-R12,R14}
47190
47200 ADR R0,noinputerror
47210 FNLongAdr("",1,messages)
47220 MOV R2,#0
47230 SWI "XMessageTrans_ErrorLookup"
47240 B NonSeriousError
47250
47260;-----------------------------------------------------------------------------
47270; This section contains the Message Token for the NoInput error.
47280
47290.noinputerror
47300EQUD 0
47310EQUS "NoInput"
47320EQUB 0
47330ALIGN
47340
47350;-----------------------------------------------------------------------------
47360; This section deals with not being able to open a file that is to be used to
47370; save out records to.
47380
47390.nooutput
47400STMFD R13!,{R0-R12,R14}
47410
47420 ADR R0,nooutputerror
47430 FNLongAdr("",1,messages)
47440 MOV R2,#0
47450 SWI "XMessageTrans_ErrorLookup"
47460 B NonSeriousError
47470
47480;-----------------------------------------------------------------------------
47490; This section contains the Message Token for the NoOutput error.
47500
47510.nooutputerror
47520EQUD 0
47530EQUS "NoOutput"
47540EQUB 0
47550ALIGN
47560
47570;-----------------------------------------------------------------------------
47580; This section deals with not being able to open a Scrapfile.
47590
47600.noscrapfile
47610STMFD R13!,{R0-R12,R14}
47620
47630 ADR R0,noscrapfileerror
47640 FNLongAdr("",1,messages)
47650 MOV R2,#0
47660 SWI "XMessageTrans_ErrorLookup"
47670 B NonSeriousError
47680
47690;-----------------------------------------------------------------------------
47700; This section contains the Message Token for the NoScrapFile error.
47710
47720.noscrapfileerror
47730EQUD 0
47740EQUS "NoScrapFile"
47750EQUB 0
47760ALIGN
47770
47780;-----------------------------------------------------------------------------
47790; This section deals with not being able to access the Messages file.
47800
47810.nomessages
47820 ADR R0,nomessageserror
47830 B SeriousError
47840
47850;-----------------------------------------------------------------------------
47860; This section contains the NoMessages error message.
47870
47880.nomessageserror
47890EQUD 0
47900EQUS "AUIndex is unable to"
47910EQUS " access its Messages file"
47920EQUS " and must exit immediately"
47930EQUB 0
47940ALIGN
47950
47960;-----------------------------------------------------------------------------
47970; This section deals with not being able to access our Heap.
47980
47990.noheap
48000 ADR R0,noheaperror
48010 FNLongAdr("",1,messages)
48020 MOV R2,#0
48030 SWI "XMessageTrans_ErrorLookup"
48040 B SeriousError
48050
48060;-----------------------------------------------------------------------------
48070; This section contains the Message Token for the NoHeap error.
48080
48090.noheaperror
48100EQUD 0
48110EQUS "NoHeap"
48120EQUB 0
48130ALIGN
48140
48150;-----------------------------------------------------------------------------
48160; This section deals with not being able to claim a large enough Heap block.
48170
48180.noroom
48190 ADR R0,noroomerror
48200 FNLongAdr("",1,messages)
48210 MOV R2,#0
48220 SWI "XMessageTrans_ErrorLookup"
48230 B NonSeriousError
48240
48250;-----------------------------------------------------------------------------
48260; This section contains the Message Token for the NoRoom error.
48270
48280.noroomerror
48290EQUD 0
48300EQUS "NoRoom"
48310EQUB 0
48320ALIGN
48330
48340;-----------------------------------------------------------------------------
48350; This section tidies up after a non serious error has occurred. It reports
48360; the error to the user and closes any open files.
48370
48380.NonSeriousError
48390
48400 MOV R1,#%1
48410 ADD R2,R12,#appname
48420 SWI "Wimp_ReportError"
48430
48440 MOV R0,#0
48450 LDR R1,[R10,#indexhandle%]
48460 SWI "XOS_Find"
48470 LDR R1,[R10,#searchhandle%]
48480 SWI "XOS_Find"
48490
48500LDMFD R13!,{R0-R12,PC}^
48510
48520;-----------------------------------------------------------------------------
48530; This section closes down our task after an unrecoverable error has occured.
48540
48550.SeriousError
48560
48570 MOV R1,#%1
48580 ADD R2,R12,#appname
48590 SWI "Wimp_ReportError"
48600 SWI "OS_Exit"
48610
48620;-----------------------------------------------------------------------------
48630.heap
48640]
48650NEXT
48660OSCLI" BreakSet "+STR$~(breakpoint)
48670OSCLI "SAVE ""<AUIndex$Dir>.!RunImage"" "+STR$~(code%)+" "+STR$~(P%)
48680OSCLI "SetType <AUIndex$Dir>.!RunImage Absolute"
48690CALL code%
48700END
48710
48720;-----------------------------------------------------------------------------
48730; *** LongAdr ***
48740; This function is a macro which assembles code to emulate the ADR directive
48750; for addresses greater than 4096 bytes away from the PC.
48760; ADD and SUB instructions can only use immediate values with up to 8
48770; significant bits,so two instructions are used.
48780
48790DEFFNLongAdr(condition$,reg%,pointer%)
48800
48810 IF ABS(pointer%-P%)>65536 THEN
48820 ERROR 1,"LongAdr only works for addresses within �64 KBytes at &"+STR$(~P%)
48830 ENDIF
48840
48850 IF condition$="" THEN condition$="AL"
48860 cc%=INSTR("EQNECSCCMIPLVSVCHILSGELTGTLEALNV",condition$)
48870
48880 IF cc%=0 THEN
48890 ERROR 1, "Bad Condition Code in LongAdr at &"+STR$(~P%)
48900 ENDIF
48910
48920 cc%=(cc%-1) DIV 2
48930
48940 diff%=pointer%-(P%+8)
48950
48960 op1%=(cc%<<28)
48970 op1%+=&024F0000
48980 op1%+=(reg%<<12)
48990 op1%+=ABS(diff%) AND &FF
49000
49010 op2%=(cc%<<28)
49020 op2%+=&02400C00
49030 op2%+=(reg%<<16)
49040 op2%+=(reg%<<12)
49050 op2%+=ABS(diff%)>>8 AND &FF
49060
49070 IF diff%>=0 THEN
49080 op1%+=4<<20
49090 op2%+=4<<20
49100 ENDIF
49110
49120 [OPT pass%
49130 EQUD op1% ;Assemble the two instructions
49140 EQUD op2%
49150 ]
49160
49170=0
&� Name : AUIndex (Source Code)
5� Purpose : Easy Location Of Acorn User Articles
-� Author : (c) The Flying Twig, 1994-96
(� AKA Paul Burns
2#� Version : 1.00 (20 Dec 1995)
<
F� :� �$;" at line ";�:�
P
ZE� code% 1024*28 :� reserve 28k for assembler
d
nP�---------------------------------------------------------------------------
x
�� pass%=0�2 �2
�P%=code%
�
[OPTpass%
�
�AB getstack ;Set up Stack Pointer
�
�
.continue
�
�STMFD R13!,{R0-R12}
�
�@ �LongAdr("",11,menu%) ;Pointer to Menu Data
�A ADR R12,data% ;Pointer to Wimp Data
�D ADD R10,R12,#&1E00 ;Pointer to Program Data
J ADD R9,R10,#&300 ;Pointer to Misc String buffer
B Start
"R;-----------------------------------------------------------------------------
,8; This section reserves space for Data (&2300 bytes)
6
@
.data%
J]
T
^� i =0 � &2300 � 4
h [OPT pass%
r EQUD 0
| ]
��
�
�P�---------------------------------------------------------------------------
�M� This section sets up variables as offsets within the workspace to allow
�� easy reference to data.
�
�� Wimp Data Labels
�
�version%=&00
�
task%=&04
�iconbar%=&08
�display%=&0C
�
info%=&10
search%=&14
edit%=&18
save%=&1C
&*quit%=&20 :data%!quit%=0
0currentmenu%=&24
:Ntemplates=&28 :$(data%+templates)="<AUIndex$Resource>.Templates"
D;spritename=&45 :$(data%+spritename)="!AUIndex"
Nappname=&46
X1edit=&50 :$(data%+edit)="edit"
b7display=&55 :$(data%+display)="display"
l1info=&5E :$(data%+info)="info"
v5search=&63 :$(data%+search)="search"
�1save=&6A :$(data%+save)="save"
�Bversion=&70 :$(data%+version)="1.00 (20 Dec 1995)"
�:block%=&84 :$(data%+block%+24)="!AUIndex"
�fonts%=&190
�5update=&290 :$(data%+update)="update"
�update%=&298
�icons%=&3A0
�templates%=&1200
�
�indexdata%=data%+&1E00
�
�,� Data Labels for Program Specific Data
�
indexhandle%=&00
searchhandle%=&04
indexmax%=&08
searchmax%=&0C
*
show%=&10
4filehandle%=&14
>indexrecord%=&18
Hsearchrecord%=&1C
Rrecord%=&20
\max%=&24
fRsearchfile=&28 :$(indexdata%+searchfile)="<Wimp$ScrapDir>.SearchFile"
pSindexfile=&46 :$(indexdata%+indexfile)="<AUIndex$Resource>.IndexFile"
z8backslash=&66 :$(indexdata%+backslash)="\"
�editmonth%=&68
�displaymonth%=&6C
�6multiple%=&70 :!(indexdata%+multiple%)=0
�editrecord%=&74
�scrapref%=&78
�)updating%=&7C :!updating%=0
�months%=&130
�#$(indexdata%+months%+&00)="Jan"
�#$(indexdata%+months%+&10)="Feb"
�#$(indexdata%+months%+&20)="Mar"
�#$(indexdata%+months%+&30)="Apr"
�#$(indexdata%+months%+&40)="May"
�#$(indexdata%+months%+&50)="Jun"
#$(indexdata%+months%+&60)="Jul"
#$(indexdata%+months%+&70)="Aug"
#$(indexdata%+months%+&80)="Sep"
$#$(indexdata%+months%+&90)="Oct"
.#$(indexdata%+months%+&A0)="Nov"
8#$(indexdata%+months%+&B0)="Dec"
B$$(indexdata%+months%+&C0)="Xmas"
Lrecord=&200
V
`P�---------------------------------------------------------------------------
j=� This section reserves space for the stack (&100 bytes).
t
~� i= 0 � &100 �4
� [OPT pass%
� EQUD 0
� ]
��
�
�P�---------------------------------------------------------------------------
�-� Save Link and Stack Pointer onto stack
�
�[OPT pass%
� ALIGN
�
�
.getstack
STR R14,getstack-4
STR R13,getstack-8
ADR R13,getstack-8
B continue
(
2R;-----------------------------------------------------------------------------
<; MenuData
F@; This section sets up Menu Templates which can be passed to
PJ; "MessageTrans_MakeMenu" to create a menu structure using the strings
Z$; supplied in the Messages file.
d
n
.menulist
xQEQUD 0 ;This reserves three words for storing
�NEQUD 0 ;the address of the Menu structures
�BEQUD 0 ;when they are created.
�
�
.menu%
�.ibmenu%
�JEQUS "IM0"+�0 ;Message Token for the menu title.
�IEQUB 7 ;Menu Title foreground colour.
�IEQUB 2 ;Menu Title background colour.
�MEQUB 7 ;Menu work area foreground colour.
�MEQUB 0 ;Menu work area background colour.
�SEQUB 44 ;Height of each menu item (in OS units).
�LEQUB 0 ;Vertical gap between menu items.
�
JEQUS "IM1"+�0 ;Message Token for first menu item
ALIGN
";EQUD 0 ;Menu Item flags
,;EQUD 0 ;Submenu pointer
66EQUD &7000021 ;Icon flags
@
JKEQUS "IM2"+�0 ;Message Token for second menu item
T ALIGN
^KEQUD &80 ;Menu Item flags (&80=last item)
h;EQUD 0 ;Submenu pointer
r6EQUD &7000021 ;Icon flags
|
�<EQUB 0 ;terminating byte
� ALIGN
�
�.mainmenu%
�JEQUS "MM0"+�0 ;Message Token for the menu title.
�IEQUB 7 ;Menu Title foreground colour.
�IEQUB 2 ;Menu Title background colour.
�MEQUB 7 ;Menu work area foreground colour.
�MEQUB 0 ;Menu work area background colour.
�SEQUB 44 ;Height of each menu item (in OS units).
�LEQUB 0 ;Vertical gap between menu items.
�
�JEQUS "MM1"+�0 ;Message Token for first menu item
ALIGN
;EQUD 0 ;Menu Item flags
;EQUD 0 ;Submenu pointer
&6EQUD &7000021 ;Icon flags
0
:KEQUS "MM2"+�0 ;Message Token for second menu item
D ALIGN
N;EQUD 0 ;Menu Item flags
X;EQUD 0 ;Submenu pointer
b6EQUD &7000021 ;Icon flags
l
v
�JEQUS "MM3"+�0 ;Message Token for third menu item
� ALIGN
�;EQUD 0 ;Menu Item flags
�;EQUD 0 ;Submenu pointer
�6EQUD &7000021 ;Icon flags
�
�KEQUS "MM4"+�0 ;Message Token for fourth menu item
� ALIGN
�;EQUD 0 ;Menu Item flags
�;EQUD 0 ;Submenu pointer
�6EQUD &7000021 ;Icon flags
�
�JEQUS "MM5"+�0 ;Message Token for fifth menu item
ALIGN
KEQUD &80 ;Menu Item flags (&80=last item)
;EQUD 0 ;Submenu pointer
6EQUD &7000021 ;Icon flags
*
4<EQUB 0 ;Terminating byte
> ALIGN
H
R.topicmenu%
\JEQUS "TM0"+�0 ;Message Token for the menu title.
fIEQUB 7 ;Menu Title foreground colour.
pIEQUB 2 ;Menu Title background colour.
zMEQUB 7 ;Menu work area foreground colour.
�MEQUB 0 ;Menu work area background colour.
�SEQUB 44 ;Height of each menu item (in OS units).
�LEQUB 0 ;Vertical gap between menu items.
�
�]
�� i=1 � 32
�[OPT pass%
�
�EEQUS "TM"+�(i)+�0 ;Message Token for ith menu item
� ALIGN
�;EQUD 0 ;Menu Item flags
�;EQUD 0 ;Submenu pointer
�6EQUD &7000121 ;Icon flags
]
�
$[OPT pass%
.
8IEQUS "TM33"+�0 ;Message Token for 33rd menu item
B ALIGN
LTEQUD &84 ;Menu Item flags(&84=Writeable/last item)
V;EQUD 0 ;Submenu pointer
`EQUD &7000121
j
t<EQUB 0 ;Terminating byte
~ ALIGN
�
�
�.writeabletext
�]
�� i=0�256 �4
� [OPT pass%
�R EQUD 0 ;256 byte array for text from writeable
�6 ;menu item.
� ]
��
�
�P�---------------------------------------------------------------------------
� Program code starts here
[OPT pass%
(
.Start
2
<R;-----------------------------------------------------------------------------
F8; *** Initialise Wimp ***
PP; This section calls the Window Manager which will return its version number
Z!; and our unique Task handle.
d
nGMOV R0,#200 ;Minimum Version Number *100
x2MOV R1, #&4B000000 ;"TASK"
�ADD R1,R1,#&00530000
�ADD R1,R1,#&00004100
�ADD R1,R1,#&00000054
�JADD R2,R12,#appname ;Name to appear on Task Display
�SWI "XWimp_Initialise"
� BVS SeriousError
�DSTR R0,[R12,#version%] ;Wimp Version number *100
�;STR R1,[R12,#task%] ;Our Task handle
�
�R;-----------------------------------------------------------------------------
�7; This subroutine sets up our icon on the icon bar.
�
�PMVN R0,#0 ;Window handle (-1 Left side of IBar)
STR R0,[R12,#block%+0]
5MOV R0,#0 ;Minimum X
STR R0,[R12,#block%+4]
"5MOV R0,#0 ;Minimum Y
,STR R0,[R12,#block%+8]
65MOV R0,#170 ;Maximum X
@STR R0,[R12,#block%+12]
J5MOV R0,#68 ;Maximum Y
TSTR R0,[R12,#block%+16]
^6MOV R0, #&3000 ;Icon flags
hADD R0,R0,#&0002
rSTR R0,[R12,#block%+20]
|ADD R1,R12,#block%
�SWI "XWimp_CreateIcon"
� BVS SeriousError
�@STR R0,[R12,#iconbar%] ;Icon bar icon number
�
�R;-----------------------------------------------------------------------------
�K; This section loads the window template files and creates the windows.
�
�ADD R1,R12,#templates
� SWI "XWimp_OpenTemplate"
� BVS SeriousError
�CADD R1,R12,#templates% ;Space for template data
�JADD R2,R12,#icons% ;Space for indirected Icon data
�MADD R3,R2,#templates%-icons% ;Size of space for indirected data
EADD R4,R12,#fonts% ;256 byte font count array
?ADD R5,R12,#display ;Main Display Window
&LMOV R6,#0 ;Template to start searching from
0 SWI "XWimp_LoadTemplate"
: BVS SeriousError
D SWI "XWimp_CreateWindow"
N BVS SeriousError
XASTR R0,[R12,#display%] ;Display window handle
b
l=ADD R5,R12,#info ;Info Dialogue box
vMOV R6,#0
� SWI "XWimp_LoadTemplate"
� BVS SeriousError
� SWI "XWimp_CreateWindow"
� BVS SeriousError
�>STR R0,[R12,#info%] ;Info window handle
�
�?ADD R5,R12,#search ;Search Dialogue box
�MOV R6,#0
� SWI "XWimp_LoadTemplate"
� BVS SeriousError
� SWI "XWimp_CreateWindow"
� BVS SeriousError
�@STR R0,[R12,#search%] ;Search window handle
7ADD R5,R12,#edit ;Edit window
MOV R6,#0
SWI "XWimp_LoadTemplate"
* BVS SeriousError
4 SWI "XWimp_CreateWindow"
> BVS SeriousError
H>STR R0,[R12,#edit%] ;Edit window handle
R
\=ADD R5,R12,#save ;Save Dialogue box
fMOV R6,#0
p SWI "XWimp_LoadTemplate"
z BVS SeriousError
� SWI "XWimp_CreateWindow"
� BVS SeriousError
�>STR R0,[R12,#save%] ;Save window handle
�
�
�AADD R5,R12,#update ;Update Dialogue box
�MOV R6,#0
� SWI "XWimp_LoadTemplate"
� BVS SeriousError
� SWI "XWimp_CreateWindow"
� BVS SeriousError
�BSTR R0,[R12,#update%] ;Update window handle
�
!SWI "XWimp_CloseTemplate"
R;-----------------------------------------------------------------------------
$H; This routine fills in the version number in the Info dialogue box.
.
8LDR R0,[R12,#info%]
BMOV R1,#7
LADD R2,R12,#version
VBL WriteIcon
`R;-----------------------------------------------------------------------------
j
t<BL Init ;Initialise files
~
�R;-----------------------------------------------------------------------------
�4; *** Wimp_Poll ***
�J; This routine repeatedly polls the wimp to find out what is happening
�M; around the desktop. The wimp returns an Event Reason Code and fills the
�7; parameter block with data dependant on the Event.
�
� .mainloop
�
�"MOV R0, #%11100000000000
�JADD R0,R0,#%00000000010000 ;Mask out unwanted reason codes
�
�ADD R1,R12,#block%
SWI "Wimp_Poll"
( CMP R0,#0: BLEQ ContUpdating
/ CMP R0,#1: BLEQ RedrawWindowRequest
(- CMP R0,#2: BLEQ OpenWindowRequest
2. CMP R0,#3: SWIEQ "Wimp_CloseWindow"
<B;CMP R0,#4 ;Pointer_Leaving_Window
FC CMP R0,#5: ;Pointer_Entering_Window
P. CMP R0,#6: BLEQ MouseButtonClicked
Z( CMP R0,#7: BLEQ DragFinished
d& CMP R0,#8: BLEQ KeyPressed
n. CMP R0,#9: BLEQ MenuOptionSelected
x:;CMP R0,#10 ;Scroll_Request
�8;CMP R0,#11 ;Losing_Caret
�9;CMP R0,#12 ;Gaining_Caret
�@ CMP R0,#17 ;User_MessageReceived
�/ CMPNE R0,#18:BLEQ UserMessageReceived
�<;CMP R0,#19 ;User_Message_Ack
�
�
�O LDR R0,[R12,#quit%] ;Check if we have been asked to quit
� CMP R0,#0
� BEQ mainloop
�
�Q;----------------------------------------------------------------------------
�/; This routine safley closes down our task.
O LDR R0,[R12,#task%] ;This section tells the WIMP that we
M MOV R1, #&4B000000 ;are about to close down our task.
" ADD R1,R1,#&00530000
, ADD R1,R1,#&00004100
6 ADD R1,R1,#&00000054
@ SWI "XWimp_CloseDown"
J
T MOV R0,#6
^ ADD R1,R10,#searchfile
h SWI "OS_File"
r
|P �LongAdr("",0,messages) ;This closes the Message file if it is
�7 SWI "XMessageTrans_CloseFile" ;still open.
�
�F SWI "XOS_Exit" ;This closes down our task.
�
�R;-----------------------------------------------------------------------------
�6; *** Redraw_Window_Request ***
�M; This routine is called when part of one of our windows needs redrawing.
�P; Since none of our windows contain any 'User' graphics we can pass the call
�O; straight back to the Wimp to redraw the icons itself. A loop is needed to
�;; get a list of all the Rectangles that need redrawing.
�
�.RedrawWindowRequest
�
STMFD R13!,{R0-R12,R14}
ADD R1,R12,#block%
SWI "Wimp_RedrawWindow"
& .redrawloop
0 CMP R0,#0
: LDMEQFD R13!,{R0-R12,PC}^
D SWI "Wimp_GetRectangle"
NB redrawloop
X
bR;-----------------------------------------------------------------------------
l6; *** Open_Window_Request ***
vN; This routine is called when one of our windows needs opening or has been
�M; scrolled and needs redrawing with new scroll offsets. No special action
�F; needs to be performed so we simply open the window as requested.
�
�.OpenWindowRequest
�
�STMFD R13!,{R0-R12,R14}
�
� SWI "Wimp_OpenWindow"
�
�LDMFD R13!,{R0-R12,PC}^
�
�R;-----------------------------------------------------------------------------
�6; *** Mouse_Button_Click ***
J; This routine is called when the mouse buttons change state while the
S; pointer is over one of our windows - Dependant on the button type of the icon
; it is over, if any.
*.MouseButtonClicked
4
>STMFD R13!,{R0-R12,R14}
H8 LDR R2,[R12,#block%+0] ;X coordinate
R8 LDR R3,[R12,#block%+4] ;Y coordinate
\> LDR R4,[R12,#block%+8] ;Mouse Button State
f9 LDR R5,[R12,#block%+12] ;Window handle
p7 LDR R6,[R12,#block%+16] ;Icon number
z LDR R7,[R12,#display%]
� LDR R8,[R12,#search%]
�
�O CMP R5,R7 ;This section will display the topic
�P CMP R6,#43 ;selection menu if the menu button is
�O �LongAdr("EQ",1,menuinfo) ;pressed over the pop-up menu icon in
�< �Q R0,#0 ;the Display window.
� STREQ R0,[R1,#4]
� �LongAdr("EQ",8,menulist)
� LDREQ R1,[R8,#8]
�% STREQ R1,[R12,#currentmenu%]
� SUBEQ R2,R2,#64
� STREQ R2,[R9,#0]
� STREQ R3,[R9,#4]
SWIEQ "Wimp_CreateMenu"
LDMEQFD R13!,{R0-R12,PC}^
$N CMP R5,R7 ;This section will display the main
.N CMPEQ R4,#2 ;Menu if the Menu button is pressed
8O BLEQ UpdateStartEnd ;anywhere else in the Display window
BR BLEQ UpdateLeafName ;after first updating the Save dialogue
LL �LongAdr("EQ",8,menulist) ;box with the current issue number
V LDREQ R1,[R8,#4]
`% STREQ R1,[R12,#currentmenu%]
j SUBEQ R2,R2,#64
t STREQ R2,[R9,#0]
~ STREQ R3,[R9,#4]
� SWIEQ "Wimp_CreateMenu"
� LDMEQFD R13!,{R0-R12,PC}^
�
�N CMN R5,#2 ;This section displays the Icon Bar
�N CMPEQ R4,#2 ;Menu if the menu button is pressed
�B �LongAdr("EQ",8,menulist) ;over our icon bar icon.
� LDREQ R1,[R8,#0]
�% STREQ R1,[R12,#currentmenu%]
� �Q R3,#96
�C ADDEQ R3,R3,#88 ; 44 units per menu item
� SUBEQ R2,R2,#64
� STREQ R2,[R9,#0]
STREQ R3,[R9,#4]
SWIEQ "Wimp_CreateMenu"
LDMEQFD R13!,{R0-R12,PC}^
(R CMN R5,#2 ;This section will open the main window
2O STREQ R7,[R12,#block%+0] ;if Select or adjust is pressed over
<= ADDEQ R1,R12,#block% ;our icon bar icon
F# SWIEQ "Wimp_GetWindowState"
P BLEQ OpenWindowRequest
Z
dO CMP R5,R7 ;This section will call a subroutine
nN TSTEQ R4,#(� 4) � 7 ;to deal with Select being pressed over
x? BLEQ SelectInDisplay ;the Display window.
� LDMEQFD R13!,{R0-R12,PC}^
�
�O CMP R5,R7 ;This section will call a subroutine
�N TSTEQ R4,#(� 1) � 7 ;to deal with adjust being pressed over
�> BLEQ AdjustInDisplay ;the Display window
� LDMEQFD R13!,{R0-R12,PC}^
�
�O CMP R5,R8 ;This section will start a search if
�M CMPEQ R6,#2 ;the OK icon clicked in the Search
�O BLEQ StartSearch ;Dialogue box. If Select was used it
�J TSTEQ R4,#(� 4) � 7 ;will also close the Menu structure
� MVNEQ R1,#0
� SWIEQ "Wimp_CreateMenu"
! LDMEQFD R13!,{R0-R12,PC}^
LDR R8,[R12,#edit%]
"K CMP R5,R8 ;This section displays the topic
,O CMPEQ R6,#25 ;selection menu when Menu is pressed
6K �LongAdr("EQ",1,menuinfo) ;over the pop-up menu icon in the
@8 MVNEQ R0,#0 ;Edit window.
J STREQ R0,[R1,#4]
T �LongAdr("EQ",1,menulist)
^ LDR R1,[R1,#8]
h% STREQ R1,[R12,#currentmenu%]
r SUBEQ R2,R2,#64
| STREQ R2,[R9,#0]
� STREQ R3,[R9,#4]
� SWIEQ "Wimp_CreateMenu"
� LDMEQFD R13!,{R0-R12,PC}^
�
�N CMP R5,R8 ;This section calls a subroutine to
�K TSTEQ R4,#(� 4) � 7 ;deal with Select being pressed over
�< BLEQ SelectInEdit ;the Edit window.
� LDMEQFD R13!,{R0-R12,PC}^
�
�N CMP R5,R8 ;This section calls a subroutine to
�K TSTEQ R4,#(� 1) � 7 ;deal with Adjust being pressed over
�; BLEQ AdjustInEdit ;the Edit window
� LDMEQFD R13!,{R0-R12,PC}^
LDR R8,[R12,#save%]
O CMP R5,R8 ;This section will call a subroutine
&I TSTEQ R4,#(� 4) � 7 ;to deal with Select being pressed
0E BLEQ SelectInSave ;in the save dialogue box.
: LDMEQFD R13!,{R0-R12,PC}^
D
NO CMP R5,R8 ;This section will call a subroutine
XI TSTEQ R4,#(� 1) � 7 ;to deal with Adjust being pressed
bD BLEQ AdjustInSave ;in the save dialogue box
l LDMEQFD R13!,{R0-R12,PC}^
v
� LDR R8,[R12,#update%]
� CMP R5,R8
� CMP R6,#5
� �Q R0,#1
�" STREQ R0,[R10,#updating%]
�
� CMP R5,R8
� CMP R6,#6
� �Q R0,#0
�" STREQ R0,[R10,#updating%]
�! STREQ R8,[R12,#block%+0]
� ADDEQ R1,R12,#block%
�! SWIEQ "Wimp_CloseWindow"
LDMFD R13!,{R0-R12,PC}^
R;-----------------------------------------------------------------------------
*2; *** SelectInDisplay ***
4N; This subroutine deals with Select being clicked over the Display window.
>
H.SelectInDisplay
R
\STMFD R13!,{R0-R12,R14}
f
pM LDR R0,[R10,#show%] ;This section open the appropriate
zN CMP R0,#1 ;file for the current display mode,
�J MOV R0,#&4F ;either Indexfile or Searchfile
� ADDEQ R1,R10,#indexfile
�! ADDNE R1,R10,#searchfile
� SWI "XOS_Find"
� BVS norecords
�# STR R0,[R10,#filehandle%]
�% STREQ R0,[R10,#indexhandle%]
�& STRNE R0,[R10,#searchhandle%]
�
�N CMP R6,#20 ;This section displays the previous
�P SWIEQ "Hourglass_On" ;record when the single left arrow is
�@ �Q R0,#1 ;clicked on with Select.
� �Q R1,#1
BLEQ GetRecords
BLEQ Update
SWIEQ "Hourglass_Off"
$ BEQ selectclosefile
.
8N CMP R6,#21 ;This section reads back 10 records
BQ SWIEQ "Hourglass_On" ;when the double left arrow is clicked
L8 �Q R0,#10 ;on with Select.
V �Q R1,#1
` BLEQ GetRecords
j BLEQ Update
t SWIEQ "Hourglass_Off"
~ BEQ selectclosefile
�
�O CMP R6,#22 ;This section reads back 100 records
�Q SWIEQ "Hourglass_On" ;when the triple left arrow is clicked
�7 �Q R0,#100 ;on with Select
� �Q R1,#1
� BLEQ GetRecords
� BLEQ Update
� SWIEQ "Hourglass_Off"
� BEQ selectclosefile
�
�N CMP R6,#23 ;This section reads the next record
�R SWIEQ "Hourglass_On" ;when the single right arrow is clicked
8 �Q R0,#1 ;on with select.
�Q R1,#0
BLEQ GetRecords
BLEQ Update
( SWIEQ "Hourglass_Off"
2 BEQ selectclosefile
<
FQ CMP R6,#24 ;This section reads forward 10 records
PR SWIEQ "Hourglass_On" ;when the double right arrow is clicked
Z8 �Q R0,#10 ;on with Select.
d �Q R1,#0
n BLEQ GetRecords
x BLEQ Update
� SWIEQ "Hourglass_Off"
� BEQ selectclosefile
�
�R CMP R6,#25 ;This section reads forward 100 records
�R SWIEQ "Hourglass_On" ;when the triple right arrow is clicked
�8 �Q R0,#100 ;on with Select.
� �Q R1,#0
� BLEQ GetRecords
� BLEQ Update
� SWIEQ "Hourglass_Off"
� BEQ selectclosefile
�
�Q CMP R6,#26 ;This section calls a subroutine which
O BLEQ ShowIndex ;switches mode to display the Entire
N �Q R0,#0 ;Index when Select is clicked over the
> LDREQ R1,[R10,#filehandle%] ;Entire Index icon.
"O SWIEQ "XOS_Find" ;It then closes the currently active
,L �Q R0,#&4F ;file and opens the Indexfile as the
6B ADDEQ R1,R10,#indexfile ;currently active file.
@ SWIEQ "XOS_Find"
J BVS noindex
T# STREQ R0,[R10,#filehandle%]
^ LDREQ R0,[R10,#record%]
h �Q R1,#2
r BLEQ GetRecords
| BLEQ Update
� BEQ selectclosefile
�
�Q CMP R6,#27 ;This section calls a subroutine which
�I BLEQ ShowSearch ;swithces modes to display the
�K �Q R0,#0 ;Last Search when Select is clicked
�F LDREQ R1,[R10,#filehandle%] ;over the Last Search icon.
�O SWIEQ "XOS_Find" ;It then closes the currently active
�M �Q R0,#&4F ;file and opens the Searchfile as the
�B ADDEQ R1,R10,#searchfile ;currently active file.
� SWIEQ "XOS_Find"
� BVS nosearch
�# STREQ R0,[R10,#filehandle%]
� LDREQ R0,[R10,#record%]
�Q R1,#2
BLEQ GetRecords
BLEQ Update
& BEQ selectclosefile
0
:N CMP R6,#37 ;This section calls a subroutine to
DR BLEQ editrecord ;to edit the current record when Select
NQ BEQ selectclosefile ;is clicked over the Edit Record icon.
X
bN CMP R6,#39 ;This section calls a subroutine to
lL BLEQ lastmonth ;read back 1 issue when Select is
vM BEQ selectclosefile ;clicked over the Month Down icon.
�
�N CMP R6,#40 ;This section calls a subroutine to
�O BLEQ nextmonth ;read forward 1 issue when Select is
�K BEQ selectclosefile ;clicked over the Month Up icon.
�
�N CMP R6,#41 ;This section calls a subroutine to
�N BLEQ lastyear ;read back 12 issues when Select is
�L BEQ selectclosefile ;clicked over the Year Down icon.
�
�N CMP R6,#42 ;This section calls a subroutine to
�Q BLEQ nextyear ;read forward 12 issues when Select is
�J BEQ selectclosefile ;clicked over the Year Up icon.
�
R .selectclosefile ;This section closes both the currently
Q MOV R0,#0 ;active file prior to returning to the
; LDR R1,[R10,#filehandle%] ;Wimp_Poll loop.
SWI "XOS_Find"
*
4LDMFD R13!,{R0-R12,PC}^
>
HR;-----------------------------------------------------------------------------
R4; *** AdjustInDisplay ***
\M; This subroutine is is called to deal with Adjust being clicked over the
f; Display window.
pL; NB; When Adjust is clicked over adjuster icons the RISC OS Style Guide
zQ; requires the adjustment to be made in the opposite direction to the arrows.
�
�.AdjustInDisplay
�
�STMFD R13!,{R0-R12,R14}
�
�N LDR R0,[R10,#show%] ;This section opens the appropriate
�M CMP R0,#1 ;file for the current display mode
�K MOV R0,#&4F ;either Indexfile or Searchfile.
� ADDEQ R1,R10,#indexfile
�! ADDNE R1,R10,#searchfile
� SWI "XOS_Find"
� BVS norecords
�# STR R0,[R10,#filehandle%]
% STREQ R0,[R10,#indexhandle%]
& STRNE R0,[R10,#searchhandle%]
$N CMP R6,#20 ;This section reads the next record
.Q SWIEQ "Hourglass_On" ;when the single left arrow is clicked
88 �Q R0,#1 ;on with Adjust.
B �Q R1,#0
L BLEQ GetRecords
V BLEQ Update
` SWIEQ "Hourglass_Off"
j BEQ adjustclosefile
t
~Q CMP R6,#21 ;This section reads forward 10 records
�Q SWIEQ "Hourglass_On" ;when the double left arrow is clicked
�8 �Q R0,#10 ;on with Adjust.
� �Q R1,#0
� BLEQ GetRecords
� BLEQ Update
� SWIEQ "Hourglass_Off"
� BEQ adjustclosefile
�
�R CMP R6,#22 ;This section reads forward 100 records
�Q SWIEQ "Hourglass_On" ;when the triple left arrow is clicked
�8 �Q R0,#100 ;on with Adjust.
� �Q R1,#0
BLEQ GetRecords
BLEQ Update
SWIEQ "Hourglass_Off"
BEQ adjustclosefile
(
2L CMP R6,#23 ;This section reads Back 1 record
<R SWIEQ "Hourglass_On" ;when the single right arrow is clicked
F8 �Q R0,#1 ;on with Adjust.
P �Q R1,#1
Z BLEQ GetRecords
d BLEQ Update
n SWIEQ "Hourglass_Off"
x BEQ adjustclosefile
�
�N CMP R6,#24 ;This section reads back 10 records
�R SWIEQ "Hourglass_On" ;when the double right arrow is clicked
�8 �Q R0,#10 ;on with Adjust.
� �Q R1,#1
� BLEQ GetRecords
� BLEQ Update
� SWIEQ "Hourglass_Off"
� BEQ adjustclosefile
�
�O CMP R6,#25 ;This section reads back 100 records
�R SWIEQ "Hourglass_On" ;when the triple right arrow is clicked
�8 �Q R0,#100 ;on with Adjust.
�Q R1,#1
BLEQ GetRecords
BLEQ Update
" SWIEQ "Hourglass_Off"
, BEQ adjustclosefile
6
@Q CMP R6,#26 ;This section calls a subroutine which
JP BLEQ ShowIndex ;switches modes to display the Entire
TN �Q R0,#0 ;Index when Adjust is clicked over the
^> LDREQ R1,[R10,#filehandle%] ;Entire Index icon.
hO SWIEQ "XOS_Find" ;It then closes the currently active
rL �Q R0,#&4F ;file and opens the IndexFile as the
|B ADDEQ R1,R10,#indexfile ;currently active file.
� SWIEQ "XOS_Find"
� BVS noindex
�# STREQ R0,[R10,#filehandle%]
� LDREQ R0,[R10,#record%]
� �Q R1,#2
� BLEQ GetRecords
� BLEQ Update
� BEQ adjustclosefile
�
�Q CMP R6,#27 ;This section calls a subroutine which
�N BLEQ ShowSearch ;switches modes to display the Last
�O �Q R0,#0 ;Search when Adjust is clicked over the
�= LDREQ R1,[R10,#filehandle%] ;Last Search icon.
SWIEQ "XOS_Find"
�Q R0,#&4F
ADDEQ R1,R10,#searchfile
& SWIEQ "XOS_Find"
0 BVS nosearch
:# STREQ R0,[R10,#filehandle%]
D LDREQ R0,[R10,#record%]
N �Q R1,#2
X BLEQ GetRecords
b BLEQ Update
l BEQ adjustclosefile
v
�N CMP R6,#37 ;This section calls a subroutine to
�K BLEQ editrecord ;to edit the current record when
�Q BEQ adjustclosefile ;Adjust is clicked over the Edit icon.
�
�Q CMP R6,#39 ;This section calls a subroutine which
�P BLEQ nextmonth ;reads forward 1 Issue when Adjust is
�M BEQ adjustclosefile ;clicked over the Month Down icon.
�
�Q CMP R6,#40 ;This section calls a subroutine which
�M BLEQ lastmonth ;reads back 1 Issue when Adjust is
�K BEQ adjustclosefile ;clicked over the Month Up icon.
�
�Q CMP R6,#41 ;This section calls a subroutine which
!R BLEQ nextyear ;reads forward 12 Issues when Adjust is
!L BEQ adjustclosefile ;clicked over the Year Down icon.
!
! Q CMP R6,#42 ;This section calls a subroutine which
!*O BLEQ lastyear ;reads back 12 Issues when Adjust is
!4J BEQ adjustclosefile ;clicked over the Year Up icon.
!>
!HM .adjustclosefile ;This section closes the currently
!RM MOV R0,#0 ;active file prior to returning to
!\? LDR R1,[R10,#filehandle%] ;the Wimp_Poll loop.
!f SWI "XOS_Find"
!p
!zLDMFD R13!,{R0-R12,PC}^
!�
!�R;-----------------------------------------------------------------------------
!�3; *** ShowIndex ***
!�Q; This subroutine is called when the 'Entire Index' icon is clicked on in the
!�M; Display window. It changes the values of the Current Record and Maximum
!�9; Record number etc. for displaying the Entire Index.
!�
!�.ShowIndex
!�
!�STMFD R13!,{R0,R14}
!�
!�L LDR R0,[R10,#show%] ;This section ensures that we are
!�M CMP R0,#1 ;initially showing the Last Search
"E LDMEQFD R13!,{R0,PC}^ ;otherwise we just Return.
"
"P LDR R0,[R10,#indexmax%] ;Set up Current Maximum Record as the
"$P STR R0,[R10,#max%] ;Maximum Record for the Entire Index.
".
"8R LDR R0,[R10,#record%] ;Store Current Record as Current Search
"B3 STR R0,[R10,#searchrecord%] ;Record.
"L
"VQ LDR R0,[R10,#indexrecord%] ;Store Current Index Record as Current
"`3 STR R0,[R10,#record%] ;Record.
"j
"tM MOV R0,#1 ;Set current mode to 1 to indicate
"~O STR R0,[R10,#show%] ; we are showing the 'Entire Index'.
"�
"� LDR R0,[R12,#display%]
"� STR R0,[R12,#block%+0]
"�
"�K MOV R0,#37 ;This section unshades the 'Edit
"�9 STR R0,[R12,#block%+4] ;record' icon.
"� MOV R0,#0
"� STR R0,[R12,#block%+8]
"� MOV R0,#%1<<22
"� STR R0,[R12,#block%+12]
"� ADD R1,R12,#block%
"� SWI "Wimp_SetIconState"
#
#
Q MOV R0,#26 ;This section makes the 'Entire Index'
#: STR R0,[R12,#block%+4] ;icon Selected.
# MOV R0,#%1<<21
#( STR R0,[R12,#block%+8]
#2 MOV R0,#%1<<21
#< STR R0,[R12,#block%+12]
#F ADD R1,R12,#block%
#P SWI "Wimp_SetIconState"
#Z
#dP MOV R0,#27 ;This section makes the 'Last Search'
#n< STR R0,[R12,#block%+4] ;icon Deselected.
#x MOV R0,#0
#� STR R0,[R12,#block%+8]
#� MOV R0,#%1<<21
#� STR R0,[R12,#block%+12]
#� ADD R1,R12,#block%
#� SWI "Wimp_SetIconState"
#�
#�LDMFD R13!,{R0,PC}^
#�
#�R;-----------------------------------------------------------------------------
#�0; *** ShowSearch ***
#�P; This subroutine is called when the 'Last Search' icon is clicked on in the
#�Q; Display window. It changes the values of the Current Record and the Current
#�9; Maximum Record etc. for displaying the Last Search.
$
$.ShowSearch
$
$"STMFD R13!,{R0-R1,R14}
$,
$6L LDR R0,[R10,#show%] ;This section ensures that we are
$@P CMP R0,#0 ;initially showing the 'Entire Index'
$JE LDMEQFD R13!,{R0-R1,PC}^ ;otherwise we just return.
$T
$^Q LDR R0,[R10,#searchmax%] ;Set up Current Maximum as the Current
$h; STR R0,[R10,#max%] ;Search Maximum.
$r
$|N LDR R0,[R10,#record%] ;Store the Current Record number as
$�L STR R0,[R10,#indexrecord%] ;the Current Index Record number.
$�
$�O LDR R0,[R10,#searchrecord%] ;Set up the Current Record number as
$�M STR R0,[R10,#record%] ;the Current Search Record number.
$�
$�Q MOV R0,#0 ;Set the current mode to 0 to indicate
$�M STR R0,[R10,#show%] ;we are showing the 'Last Search'.
$�
$� LDR R0,[R12,#display%]
$� STR R0,[R12,#block%+0]
$�
$�Q MOV R0,#37 ;This section Shades the 'Edit Record'
$�1 STR R0,[R12,#block%+4] ;icon.
% MOV R0,#1<<22
% STR R0,[R12,#block%+8]
% STR R0,[R12,#block%+12]
%& ADD R1,R12,#block%
%0 SWI "Wimp_SetIconState"
%:
%DP MOV R0,#27 ;This section makes the 'Last Search'
%N: STR R0,[R12,#block%+4] ;icon selected.
%X MOV R0,#%1<<21
%b STR R0,[R12,#block%+8]
%l MOV R0,#%1<<21
%v STR R0,[R12,#block%+12]
%� ADD R1,R12,#block%
%� SWI "Wimp_SetIconState"
%�
%�Q MOV R0,#26 ;This section makes the 'Entire Index'
%�: STR R0,[R12,#block%+4] ;icon selected.
%� MOV R0,#0
%� STR R0,[R12,#block%+8]
%� MOV R0,#%1<<21
%� STR R0,[R12,#block%+12]
%� ADD R1,R12,#block%
%� SWI "Wimp_SetIconState"
%�LDMFD R13!,{R0-R1,PC}^
%�
&R;-----------------------------------------------------------------------------
&:; *** Edit Current Record ***
&P; This subroutine is called when the 'Edit Record' icon is clicked on in the
& M; Display window. It opens the Edit window and positions the Caret in the
&*
; window.
&4
&>.editrecord
&H
&RSTMFD R13!,{R0-R12,R14}
&\
&fQ BL geteditdetails ;Fill in details of the current record
&p
&zJ LDR R0,[R10,#record%] ;Store Current Record Number as
&�L STR R0,[R10,#editrecord%] ; the Current Edit Record Number.
&�
&�O LDR R3,[R12,#edit%] ;This section opens the Edit window.
&� STR R3,[R12,#block%]
&� ADD R1,R12,#block%
&�" SWI "Wimp_GetWindowState"
&� SWI "Wimp_OpenWindow"
&�
&�N MOV R0,R3 ;This section reads the string from
&�N MOV R1,#20 ;the Page Number icon and finds its
&�3 MOV R2,R9 ;length.
&� BL ReadIcon
&� MOV R0,R9
' MOV R1,#13
' SWI "String_Len"
' MOV R5,R1
'$
'.O MOV R0,R3 ;This section positions the caret at
'8L MOV R1,#20 ;the end of the Page Number icon.
'B MVN R4,#0
'L$ SWI "Wimp_SetCaretPosition"
'V
'`LDMFD R13!,{R0-R12,PC}^
'j
'tR;-----------------------------------------------------------------------------
'~5; *** GetEditDetails ***
'�O; This subroutine copies the details of the current record from the Display
'�.; window into the Edit window for editing.
'�
'�.geteditdetails
'�
'�STMFD R13!,{R0-R12,R14}
'�
'� MOV R2,R9
'� LDR R8,[R12,#display%]
'� LDR R7,[R12,#edit%]
'�
'�$ LDR R0,[R10,#displaymonth%]
( ! STR R0,[R10,#editmonth%]
(
( MOV R0,R8
(R MOV R1,#32 ;The following sections read the string
((P BL ReadIcon ;from icons in the Display window and
(2Q MOV R0,R7 ;writes them into the equiveleant icon
(<P MOV R1,#17 ;in the Edit window, to allow them to
(F3 BL WriteIcon ;edited.
(P
(Z MOV R0,R8
(d MOV R1,#33
(n BL ReadIcon
(x MOV R0,R7
(� MOV R1,#18
(� BL WriteIcon
(�
(� MOV R0,R8
(� MOV R1,#34
(� BL ReadIcon
(� MOV R0,R7
(� MOV R1,#19
(� BL WriteIcon
(�
(� MOV R0,R8
(� MOV R1,#35
(� BL ReadIcon
) MOV R0,R7
) MOV R1,#20
) BL WriteIcon
)"
), MOV R0,R8
)6 MOV R1,#30
)@ BL ReadIcon
)J MOV R0,R7
)T MOV R1,#21
)^ BL WriteIcon
)h
)r MOV R0,R8
)| MOV R1,#31
)� BL ReadIcon
)� MOV R0,R7
)� MOV R1,#22
)� BL WriteIcon
)�
)�N STR R0,[R12,#block%+0] ;This section displays the 'Delete'
)�O MOV R0,#26 ;icon in the Edit window by clearing
)�< STR R0,[R12,#block%+4] ;its Deleted bit.
)� MOV R0,#0
)� STR R0,[R12,#block%+8]
)� MOV R0,#%1<<23
)�! STR R0,[R12,#block%+12]
)�
* ADD R1,R12,#block%
*! SWI "Wimp_SetIconState"
*
*&LDMFD R13!,{R0-R12,PC}^
*0
*:R;-----------------------------------------------------------------------------
*D5; *** SelectInEdit ***
*NK; This subroutine deals with Select being pressed over the Edit Window.
*X
*b.SelectInEdit
*l
*vSTMFD R13!,{R0-R12,R14}
*�
*� MOV R0,R8
*�
*�R CMP R6,#9 ;This section decreases the Month icon.
*� BLEQ monthdown
*�
*�R CMP R6,#10 ;This section increases the Month icon.
*� BLEQ monthup
*�
*�Q CMP R6,#11 ;This section decreases the Year icon.
*� �Q R1,#18
*� BLEQ down
*�
+Q CMP R6,#12 ;This section increases the Year icon.
+ �Q R1,#18
+ BLEQ up
+
+*R CMP R6,#13 ;This section decreases the Issue icon.
+4 �Q R1,#19
+> BLEQ down
+H
+RR CMP R6,#14 ;This section increases the Issue icon.
+\ �Q R1,#19
+f BLEQ up
+p
+zQ CMP R6,#15 ;This section decreases the Page icon.
+� �Q R1,#20
+� BLEQ down
+�
+�Q CMP R6,#16 ;This section increases the Page icon.
+� �Q R1,#20
+� BLEQ up
+�
+�N CMP R6,#23 ;This section calls a subroutine to
+�I BLEQ storerecord ;add and/or delete the record.
+� �Q R0,#13
+� STREQB R0,[R9]
+� LDREQ R0,[R12,#edit%]
+� �Q R2,R9
, �Q R1,#22
, BLEQ WriteIcon
,
,$N CMP R6,#24 ;This section calls a subroutine to
,.E BLEQ canceledit ;to close the edit window.
,8
,BN CMP R6,#26 ;This section calls a subroutine to
,L> BLEQ storerecord ;delete the record.
,V
,`LDMFD R13!,{R0-R12,PC}^
,j
,tR;-----------------------------------------------------------------------------
,~5; *** AdjustInEdit ***
,�K; This subroutine deals with Adjust being clicked over the Edit window.
,�Q; NB; When Adjust is clicked over the adjuster icons, the Risc OS Style Guide
,�P; requires the adjustment to be made in the opposite direction to the arrow.
,�
,�.AdjustInEdit
,�
,�STMFD R13!,{R0-R12,R14}
,�
,� MOV R0,R8
,�
,�R CMP R6,#9 ;This section increases the Month icon.
,� BLEQ monthup
-
-
R CMP R6,#10 ;This section decreases the Month Icon.
- BLEQ monthdown
-
-(Q CMP R6,#11 ;This section increases the Year icon.
-2 �Q R1,#18
-< BLEQ up
-F
-PQ CMP R6,#12 ;This section decreases the Year icon.
-Z �Q R1,#18
-d BLEQ down
-n
-xR CMP R6,#13 ;This section increases the Issue icon.
-� �Q R1,#19
-� BLEQ up
-�
-�R CMP R6,#14 ;This section decreases the Issue icon.
-� �Q R1,#19
-� BLEQ down
-�
-�Q CMP R6,#15 ;This section increases the Page icon.
-� �Q R1,#20
-� BLEQ up
-�
-�Q CMP R6,#16 ;This section decreases the Page icon.
-� �Q R1,#20
. BLEQ down
.
.N CMP R6,#23 ;This section calls a subroutine to
."I BLEQ storerecord ;Add and/or Delete the record.
., �Q R0,#13
.6 STREQB R0,[R9]
.@ LDREQ R0,[R12,#edit%]
.J �Q R2,R9
.T �Q R1,#22
.^ BLEQ WriteIcon
.h
.rN CMP R6,#24 ;This section calls a subroutine to
.|A BLEQ canceledit ;close the Edit window
.�
.�N CMP R6,#26 ;This section calls a subroutine to
.�> BLEQ storerecord ;delete the record.
.�
.�LDMFD R13!,{R0-R12,PC}^
.�
.�R;-----------------------------------------------------------------------------
.�4; *** CancelEdit ***
.�-; This subroutine closes the Edit Window.
.�
.�.canceledit
.�
.�STMFD R13!,{R0-R12,R14}
/
/ LDR R0,[R12,#edit%]
/ STR R0,[R12,#block%+0]
/& ADD R1,R12,#block%
/0 SWI "Wimp_CloseWindow"
/:
/DLDMFD R13!,{R0-R12,PC}^
/N
/XR;-----------------------------------------------------------------------------
/b1; *** MonthDown ***
/l<; This subroutine decreases the value in the Month icon.
/v
/�.monthdown
/�
/�STMFD R13!,{R0-R12,R14}
/�
/�L LDR R0,[R10,#editmonth%] ;This section decreases the value of
/�N CMP R0,#1 ;the Current Month. It is set to 13
/�@ �Q R0,#13 ;if it was originally 1.
/� SUBNE R0,R0,#1
/�" STR R0,[R10,#editmonth%]
/�
/�M MOV R2,#months%-&10 ;This section gets the name of the
/�O ADD R2,R2,R0,LSL #4 ;of the Current Month from a look-up
/�N ADD R2,R10,R2 ;table and writes it into the Month
01 MOV R1,#17 ;icon.
0 LDR R0,[R12,#edit%]
0 BL WriteIcon
0
0*LDMFD R13!,{R0-R12,PC}^
04
0>R;-----------------------------------------------------------------------------
0H/; *** MonthUp ***
0R<; This subroutine increases the value of the Month icon.
0\
0f.monthup
0p
0zSTMFD R13!,{R0-R12,R14}
0�
0�L LDR R0,[R10,#editmonth%] ;This section increases the value of
0�P CMP R0,#13 ;the Current Month. It is set to 1 if
0�A �Q R0,#1 ;if it was originally 13.
0� ADDNE R0,R0,#1
0�" STR R0,[R10,#editmonth%]
0�
0�M MOV R2,#months%-&10 ;This section gets the name of the
0�L ADD R2,R2,R0,LSL #4 ;the current month from a look-up
0�N ADD R2,R10,R2 ;table and writes it into the month
0�1 MOV R1,#17 ;icon.
0� LDR R0,[R12,#edit%]
0� BL WriteIcon
1
1LDMFD R13!,{R0-R12,PC}^
1
1$R;-----------------------------------------------------------------------------
1.-; *** Up ***
18M; This subroutine increases the value of the icon specified by the Window
1B,; Handle in R0 and an Icon Handle in R1.
1L
1V.up
1`
1jSTMFD R13!,{R0-R12,R14}
1t
1~N MOV R2,R9 ;This section reads the string from
1�R BL ReadIcon ;the icon specified and find its value.
1� MOV R8,R0
1� MOV R7,R1
1� MOV R0,R2
1� MOV R1,#13
1� SWI "String_Val"
1�
1�O MOV R0, #&2700 ;This section checks if the value is
1�Q ADD R0,R0,#&000F ;9999 (&270F) and if so sets the value
1�N CMP R1,R0 ;to zero otherwise it incements it.
1� �Q R1,#0
1� ADDNE R1,R1,#1
2
2
O MOV R0,R1 ;This section converts the new value
2O MOV R1,R9 ;to its string equivelent and writes
2J MOV R6,#&100 ;it back into appropriate icon.
2(" SWI "OS_ConvertInteger2"
22 MOV R0,#13
2< STRB R0,[R1]
2F MOV R0,R8
2P MOV R1,R7
2Z MOV R2,R9
2d BL WriteIcon
2n
2xLDMFD R13!,{R0-R12,PC}^
2�
2�R;-----------------------------------------------------------------------------
2�-; *** Down ***
2�M; This subroutine decreases the value of the icon specified by the Window
2�-; handle in R0 and the Icon handle in R1.
2�
2� .down
2�
2�STMFD R13!,{R0-R12,R14}
2�
2�R MOV R2,R9 ;This section reads the string from the
2�N BL ReadIcon ;icon specified and fins its value.
2� MOV R8,R0
3 MOV R7,R1
3 MOV R0,R2
3 MOV R1,#13
3" SWI "String_Val"
3,
36Q CMP R1,#0 ;This section checks if the value is 0
3@J �Q R1, #&2700 ;and if so sets it to 9999 (&2704)
3JG ADDEQ R1,R1,#&000F ;otherwise it decrements it.
3T SUBNE R1,R1,#1
3^
3hO MOV R0,R1 ;This section converts the new value
3rO MOV R1,R9 ;to its string equivelent and writes
3|N MOV R6,#&100 ;it back into the appropriate icon.
3�" SWI "OS_ConvertInteger2"
3� MOV R0,#13
3� STRB R0,[R1]
3� MOV R0,R8
3� MOV R1,R7
3� MOV R2,R9
3� BL WriteIcon
3�
3�LDMFD R13!,{R0-R12,PC}^
3�
3�R;-----------------------------------------------------------------------------
3�2; *** Next Month ***
3�O; This procedure reads in records until the issue number is increased by at
4; least one.
4
4.nextmonth
4&
40STMFD R13!,{R0-R12,R14}
4:
4D SWI "Hourglass_On"
4N
4XO LDR R0,[R12,#display%] ;This section reads the Issue Number
4bI MOV R1,#34 ;icon from the Display window.
4l MOV R2,R9
4v BL ReadIcon
4�
4�N MOV R0,R9 ;This section gets the value of the
4�9 MOV R1,#13 ;Issue Number.
4� SWI "String_Val"
4� MOV R8,R1
4�
4�H .nextmonthloop ;This is the start of a loop.
4�R LDR R0,[R10,#record%] ;This section exits the loop if we have
4�Q LDR R1,[R10,#max%] ;reached the last record in the Index.
4� CMP R0,R1
4� BEQ nextmonthloopend
4�
4�R MOV R0,#1 ;This section reads in the next record.
5 MOV R1,#0
5 BL GetRecords
5
5 O ADD R0,R10,#record ;This section finds the start of the
5*G ADD R1,R10,#backslash ;third field (Issue number).
54 MOV R2,#13
5> MOV R3,#0
5H SWI "String_Instr"
5R ADD R3,R3,#1
5\ SWI "String_Instr"
5f
5pN ADD R0,R0,R3 ;This section gets the value of the
5z? ADD R0,R0,#1 ;Issue Number field.
5� MOV R1,#�("\")
5� SWI "String_Val"
5�
5�R CMP R1,R8 ;This section compares the issue number
5�Q BLE nextmonthloop ;that we're looking for with the issue
5�F .nextmonthloopend ;number that we have found.
5�
5� BL Update
5�
5� SWI "Hourglass_Off"
5�
5�LDMFD R13!,{R0-R12,PC}^
5�
6R;-----------------------------------------------------------------------------
64; *** LastMonth ***
6O; This subroutine reads back records until the Issue Number is decreased by
6$; at least one.
6.
68.lastmonth
6B
6LSTMFD R13!,{R0-R12,R14}
6V
6` SWI "Hourglass_On"
6j
6tO LDR R0,[R12,#display%] ;This section reads the Issue Number
6~D MOV R1,#34 ;from the Display window.
6� MOV R2,R9
6� BL ReadIcon
6�
6�N MOV R0,R9 ;This section gets the value of the
6�9 MOV R1,#13 ;Issue Number.
6� SWI "String_Val"
6� SUB R8,R1,#1
6�
6�P MOV R0,#1 ;This section reads back to the start
6�B MOV R1,#1 ;of the current record.
6� BL GetRecords
6�
7 H .lastmonthloop ;This is the start of a loop.
7
R LDR R0,[R10,#record%] ;This section exits the loop if we have
7Q MOV R1,#1 ;reached the first record in the file.
7 CMP R0,R1
7( BEQ lastmonthloopend
72
7<M MOV R0,#1 ;This section reads back a record.
7F MOV R1,#1
7P BL GetRecords
7Z
7dO ADD R0,R10,#record ;This section finds the start of the
7nG ADD R1,R10,#backslash ;third field (Issue Number).
7x MOV R2,#13
7� MOV R3,#0
7� SWI "String_Instr"
7� ADD R3,R3,#1
7� SWI "String_Instr"
7�
7�N ADD R0,R0,R3 ;This section gets the value of the
7�? ADD R0,R0,#1 ;Issue Number field.
7� MOV R1,#�("\")
7� SWI "String_Val"
7�
7�R CMP R1,R8 ;This section compares the Issue number
7�Q BGE lastmonthloop ;that we're looking for with the Issue
7�D ;number that we've found.
8 .lastmonthloopend
8
8 MOV R0,#1
8" MOV R1,#0
8, BL GetRecords
86
8@ BL Update
8J SWI "Hourglass_Off"
8T
8^LDMFD R13!,{R0-R12,PC}^
8h
8rR;-----------------------------------------------------------------------------
8|3; *** NextYear ***
8�P; This subroutine reads in records until the Issue Number is increased by at
8�; least 12.
8�
8�
.nextyear
8�
8�STMFD R13!,{R0-R12,R14}
8�
8� SWI "Hourglass_On"
8�
8�O LDR R0,[R12,#display%] ;This section reads the Issue number
8�D MOV R1,#34 ;from the Display window.
8� MOV R2,R9
8� BL ReadIcon
9
9N MOV R0,R9 ;This section gets the value of the
99 MOV R1,#13 ;Issue Number.
9& SWI "String_Val"
90 ADD R8,R1,#11
9:
9DH .nextyearloop ;This is the start of a loop.
9NR LDR R0,[R10,#record%] ;This section exits the loop if we have
9XQ LDR R1,[R10,#max%] ;reached the last record in the Index.
9b CMP R0,R1
9l BEQ nextyearloopend
9v
9�R MOV R0,#1 ;This section reads in the next record.
9� MOV R1,#0
9� BL GetRecords
9�
9�O ADD R0,R10,#record ;This section finds the start of the
9�G ADD R1,R10,#backslash ;third field (Issue Number).
9� MOV R2,#13
9� MOV R3,#0
9� SWI "String_Instr"
9� ADD R3,R3,#1
9� SWI "String_Instr"
9�
9�N ADD R0,R0,R3 ;This section gets the value of the
:9 ADD R0,R0,#1 ;Issue Number.
: MOV R1,#�("\")
: SWI "String_Val"
:
:*R CMP R1,R8 ;This section compares the Issue Number
:4Q BLE nextyearloop ;that we're looking for with the Issue
:>D ;Number that we've found.
:H .nextyearloopend
:R
:\ BL Update
:f SWI "Hourglass_Off"
:p
:zLDMFD R13!,{R0-R12,PC}^
:�
:�R;-----------------------------------------------------------------------------
:�0; *** LastYear ***
:�O; This subroutine reads back records until the Issue number is decreased by
:�; at least 12.
:�
:�
.lastyear
:�
:�STMFD R13!,{R0-R12,R14}
:�
:� SWI "Hourglass_On"
:�
:�O LDR R0,[R12,#display%] ;This section reads the Issue Number
;D MOV R1,#34 ;from the Display window.
; MOV R2,R9
; BL ReadIcon
;$
;.N MOV R0,R9 ;This section gets the value of the
;89 MOV R1,#13 ;Issue Number.
;B SWI "String_Val"
;L SUB R8,R1,#12
;V
;`P MOV R0,#1 ;This section reads back to the start
;jB MOV R1,#1 ;of the current record.
;t BL GetRecords
;~
;�H .lastyearloop ;This is the start of a loop.
;�R LDR R0,[R10,#record%] ;This section exits the loop if we have
;�E MOV R1,#1 ;reached the first record.
;� CMP R0,R1
;� BEQ lastyearloopend
;�
;�M MOV R0,#1 ;This section reads back 1 record.
;� MOV R1,#1
;� BL GetRecords
;�
;�O ADD R0,R10,#record ;This section finds the start of the
;�G ADD R1,R10,#backslash ;third field (Issue Number).
<