10
20
30
40
50
60
70
80
90
100 :
110
120
130
140
150
160 :
170 OSWRCH=&FFEE:OSNEWL=&FFE7:OSASCI=&FFE3:OSFILE=&FFDD:OSBYTE=&FFF4:ws=&A8
180 DIM mcode% &1000
190 FOR P=0 TO 1
200 P%=&8000:O%=mcode%
210 [OPT P*3+4
220 BRK:BRK:BRK:JMP Service
230 EQUB &82:EQUB Copyright-&8000
240 EQUB &00:EQUS "TESTROM"
250 .Copyright
260 EQUB &00:EQUS "(C)"
270 EQUB &00
280 :
290 .Service
300 PHA:LDA &DF0,X :\ Get workspace flags
310 BMI P%+4:EOR #&40 :\ Toggle bit 6 if bit 7 is zero
320 ASL A:BPL ServDisabled:PLA :\ Exit if the resultant bit 6 is clear
330 :
340 \ Do the service call dispatch
350 CMP #&24:BEQ Serv24 :\ How much high w/s needed
360 CMP #&22:BEQ Serv22 :\ Claim high workspace
370 CMP #&21:BEQ Serv21 :\ How much high shared workspace
380 CMP #&01:BEQ Serv01 :\ How much low shared workspace
390 :
400 CMP #&09:BEQ Serv09 :\ Test code
410 RTS
420 :
430 .ServDisabled
440 PLA:RTS :\ Restore service call and return
450 :
460 :
470 \ -----------------------------------------------------------
480 \ SERVICE &24 - State how much private Hazel workspace needed
490 \ -----------------------------------------------------------
500 .Serv24
510 DEY:RTS :\ Need one page of private workspace
520 :
530 \ -------------------------------------------
540 \ SERVICE &22 - Claim Hazel private workspace
550 \ -------------------------------------------
560 .Serv22
570 CPY #&DC:BCC P%+4:LDY #&DC :\ If run out of Hazel, point to top of Hazel
580 TYA:STA &DF0,X :\ Note location of private workspace
590 INY:LDA #&22:RTS :\ Claim one page of workspace and return
600 :
610 \ ---------------------------------------------------------
620 \ SERVICE &21 - State how much shared high workspace needed
630 \ ---------------------------------------------------------
640 .Serv21
650 CPY #&C9:BCS P%+4:LDY #&C9:RTS :\ Need at least nine pages of shared workspace
660 :
670 \ ------------------------------------------------------
680 \ SERVICE 1 - State how much shared low workspace needed
690 \ ------------------------------------------------------
700 .Serv01
710 LDA OSFILE :\ Check filing system entry point
720 CMP #&6C :\ If FileSwitch RAM exists, it will be a JMP abs
730 BCS Serv1bbc :\ It's a JMP (vec), so always use low workspace on BBC
740 LDA &DF0,X :\ Get workspace pointer
750 CMP #&DC:BCC Serv1done :\ If we haven't run out of Hazel, so use it
760 .Serv1bbc
770 LDA #&0E:STA &DF0,X :\ Note location of workspace in shared low memory at &0E00
780 CPY #&0E+1:BCS Serv1done :\ If enough shared workspace has been requested, exit
790 LDY #&0E+1 :\ We want one page of workspace
800 .Serv1done
810 \ ROMs sometimes do Break initialisation here
820 LDA #1:RTS :\ Restore and exit
830 :
840 .Serv2
850 RTS
860 :
870 \ Test code, display something with *HELP
880 .Serv09
890 LDX #0
900 .Serv09lp
910 LDA Serv09Text,X:BEQ Serv09b
920 JSR OSASCI:INX:BNE Serv09lp
930 .Serv09b
940 LDX &F4:LDA &DF0,X:JSR PrHex
950 LDA #ASC"0":JSR OSWRCH:JSR OSWRCH
960 JSR OSNEWL:LDA #9:RTS
970 .Serv09Text
980 EQUB 13:EQUS "Workspace at &":EQUB 0
990 .PrHex
1000 PHA:LSR A:LSR A:LSR A:LSR A:JSR PrNyb:PLA
1010 .PrNyb
1020 AND #15:CMP #10:BCC P%+4:ADC #6:ADC #48:JMP OSWRCH
1030 :
1040 \ Grab the workspace when I need to use it
1050 .GrabWS
1060 JSR FindWS :\ Point to my workspace
1070 LDA ws+1:BMI FindWSdone :\ Workspace in private high memory, done
1080 LDA #143:LDX #10:JSR OSBYTE :\ Claim the low shared workspace
1090 : :\ Continue through to set the pointer again
1100 \ Set (ws) to point to my workspace
1110 .FindWS
1120 LDX &F4:LDA &DF0,X:STA ws+1 :\ Get high byte of workspace pointer
1130 LDA #0:STA ws+0 :\ Set low byte to &00
1140 .FindWSdone
1150 RTS
1160 ]NEXT
1170 PRINT"*SAVE HIGHROM ";~mcode%;" ";~O%