AN AUTOMATIC CONFIGURE UTILITY

David Spencer takes the blues out of reconfiguring your machine.

This program requires RISC OS.

The process of reconfiguring the Arc's memory allocations in order to run a particular program is in general rather convoluted, even if an auto-configure type program is used. However, the simple machine code utility given here greatly simplifies the matter by allowing the memory allocations to be reconfigured on a temporary basis. Using this utility, it is not necessary to reset the computer, and the configurations set with *CONFIGURE are restored at the next hard reset.

To use the utility, type in and save the listing given here. Running the program will then save the machine code with the filename 'CONFIG'. The command is used in the form:
*CONFIG <area> [<size>]
where area is a number representing the memory area to alter (see table 1), and size is the desired size in kilobytes. For example:
*CONFIG 2 160
will result in 160K of screen memory being allocated. If the parameter size is omitted then the allocation is restored to its configured setting.

Table 1. Memory Area Numbers

Memory AreaNumber
System Heap0
RMA1
Screen2
System Sprites3
Font Cache4
RAM Filing System5

The only restriction to the use of this utility is that it will not work if an application is currently running. This means that the computer must be at the '*' prompt, and not, say, in Basic. Perhaps the easiest way to use this utility is to include the CONFIG commands in an Obey file which starts with the command QUIT. After the CONFIG commands the Obey file could run a Basic program if desired.

HOW IT WORKS

The operation of this utility is relatively straightforward. After the numeric parameters have been decoded, repeated calls to SWI "OS_ValidateAddress" are used to find the current size of the area being changed. The necessary change in size is then calculated and the new allocation set using the call SWI "OS_ChangeDynamicArea".

10 REM >ConfigSrc
20 REM Program Soft Reconfigure
30 REM Version A 1.00
40 REM Author David Spencer
50 REM RISC User June 1989
60 REM Program Subject to Copyright
70 :
80 DIM code 2000
90 FOR pass=0 TO 3 STEP 3
100 P%=code
110 [OPT pass
120 MOV R11,R14:ADR R0,defn:MOV R2,R12
130 MOV R3,#100:SWI "XOS_ReadArgs"
140 MOVVS PC,R11
150 LDR R0,[R12]:BL getno
160 MOV R10,R0:CMP R0,#6:BCC ne
170 .error ADR R0,bad
180 ORRS PC,R11,#1<<28
190 .ne LDR R0,[R12,#4]:CMP R0,#0
200 BNE notd:ADR R0,cmos
210 LDRB R1,[R0,R10]:MOV R0,#161
220 SWI "XOS_Byte"
230 SWI "XOS_ReadMemMapInfo"
240 CMP R10,#4:MOVEQ R2,R2,LSL #12
250 MULNE R2,R0,R2:B find
260 .notd BL getno:MOV R2,R2,LSL #10
270 .find SWI "XOS_ReadMemMapInfo"
280 MOV R8,R0:SUB R9,R8,#1
290 ADD R2,R2,R9:BIC R9,R2,R9
300 ADR R0,start:LDRB R0,[R0,R10]
310 MOV R0,R0,LSL #20:MOV R1,R0
320 .chk SWI "XOS_ValidateAddress"
330 BCS chkd:CMP R10,#2
340 ADDNE R1,R1,R8:SUBEQ R0,R0,R8
350 B chk
360 .chkd SUB R0,R1,R0
370 CMP R0,#0:SUBNE R0,R0,R8
380 SUB R1,R9,R0:MOV R0,R10
390 SWI "XOS_ChangeDynamicArea"
400 MOVVS PC,R11:MOVS PC,R11
410 :
420 .getno CMP R0,#0:BEQ error
430 LDRB R1,[R0]:CMP R1,#0
440 BNE error:MOV R1,#4:MOV R2,#0
450 .loop LDRB R3,[R0,R1]
460 ORR R2,R3,R2,LSL #8
470 SUBS R1,R1,#1:BNE loop
480 MOV R0,R2:MOV PC,R14
490 :
500 .start EQUB &1C:EQUB &18
510 EQUB &20:EQUB &14:EQUB &1E
520 EQUB &10:ALIGN
530 .defn EQUS "/E,/E":EQUB 0:ALIGN
540 .cmos EQUB 145:EQUB 146:EQUB 143
550 EQUB 147:EQUB 134:EQUB 144:ALIGN
560 .bad EQUD 0
570 EQUS "Bad memory area":EQUB 0
580 ]NEXT
590 SYS "OS_File",10,"Config",&FFC,,code,P%