1 REM Ins{nd av Bert Holgersson <560> 1987-12-12 19.17.00 (DUMP) 10 REM * * R A M G E N Ver 1.1 ** 20 REM 30 REM - Formatting program for ABC80 UFD-Dos RAM-Disc 40 REM - BER <560> 871109 F|r RAM-floppy Ver 2.0 50 REM 60 REM ------------------------------------------------------------------------ 70 REM 80 REM - Get last sectornumber in RAM-disc 90 REM 100 REM - T% = Last usable sector in RAM-disc 110 REM 120 A%=PEEK(24689%)+256%*PEEK(24690%) : REM get adress to link in RAM 130 IF PEEK(A%)<>195% THEN ; : ; '** No RAM-disc installed !! **' : END : REM Installed ? 140 A%=A%+1% : REM Skip "JP" instruction 150 A%=PEEK(A%)+256%*PEEK(A%+1%) : REM Get adress to numbers of sectors 160 T%=PEEK(A%-1%) : REM Max sectornumber stored in front of entrypoint 170 REM 180 REM - F% = First usable sector in RAM-disc 190 REM 200 REM - 14 is bit map. The first sector DOS *MUST* have 210 REM 220 F%=14% 230 REM 240 REM - D8% = Selectcode for RAM-disc 250 REM - (Must match the one in the assembly file) 260 REM - C% = RAM-disc clustersize 270 REM 280 D8%=16% 290 C%=4% 300 REM 310 REM ----------------------------------------------------------------------- 320 REM 330 ; CHR$(12%)' FORMATING (Prep) of RAM-disc' 340 ; CHR$(151%)STRING$(78%,35%) 350 ; ' This routine formats RAM-disc to 'RIGHT$(NUM$(T%),2%)' sectors' 360 REM 370 REM A dummy read to RAM-disc, just to see if everything is OK 380 REM Sector read is 99. Anyone in the available span will do. 390 REM 400 S%=99% 410 GOSUB 1100 420 POKE 64769%,D8% : Z%=CALL(24678%,S%) : REM Check if possible to reach RAM 430 IF PEEK(64789%) THEN ; : ; '** Impossible to reach RAM - disc **' : STOP 440 REM 450 ; : ; ' Any files in RAM will be destroyed !' 460 ; : ; ' Start with exclamation mark (!), or' : ; ' stop with period (.) '; 470 INPUT I$ : IF I$='.' GOTO 1090 480 POKE 64769%,D8% : IF I$<>'!' GOTO 460 490 REM 500 REM Init Bitmaps 510 REM 520 ; ' Creating bitmap' 530 L%=32%/C%/8%-1% : REM Number of bytes to block up to LIB in bitmap 540 A%=T%-31% : REM Number of sectors "for you" 550 F%=A%/C%/8% : REM How many full bytes to indicate empty 560 R%=A%-(8%*F%*C%) : REM Sectors left for part of next byte 570 B%=128% : S%=0% : R%=R%/C% : REM Set bit 7,Init value, Make cluster out of sectors 580 FOR I%=1% TO R% : REM R% = Number of clusters to mark as free 590 S%=S% OR B% : REM Set bit for free cluster 600 B%=B%/2% : REM Shift one step right 610 NEXT I% 620 S%= NOT S% AND 255% : REM Invert byte ( Free cluster indicated by bit=0) 630 F%=F%+L% : REM To wich byte in bitmap it reaches 640 REM - Put Block together 650 FOR I%=0% TO 255% : P%=255% : REM Block "system part" of disc 660 IF I%>L% P%=0% : REM "Unblock" usable part of disc 670 IF I%>F% P%=S% : REM Last free cluster, not necessarily a full byte 680 IF I%>F%+1% P%=255% : REM Rest of disc "blocked" 690 IF I%>238% P%=1% 700 IF I%>246% P%=0% 710 POKE I%-2816%,P% : NEXT I% 720 ; ' Writing bitmap ( Sector 14 )' 730 S%=14% 740 GOSUB 1100 750 Z%=CALL(24675%,S%) 760 IF PEEK(64789%) GOTO 720 770 ; ' Writing locout sector ( Sector 15 )' 780 S%=15% 790 GOSUB 1100 800 Z%=CALL(24675%,S%) 810 IF PEEK(64789%) GOTO 770 820 REM 830 REM Init LIB:s 840 REM 850 ; ' Creating libsector(s)' 860 FOR I%=0% TO 255% : P%=0% 870 IF I%>15% P%=255% 880 POKE I%-2816%,P% : NEXT I% 890 ; ' Formatting lib sector :'; 900 FOR I%=16% TO 31% 910 ; I%; : S%=I% 920 GOSUB 1100 930 Z%=CALL(24675%,S%) 940 NEXT I% 950 ; : ; ' Formatting ready' 960 REM 970 REM - Do a test read of all available sectors, just to check 980 REM 990 ; ' Test reading sector :'; 1000 FOR I%=14% TO T% : ; I%; 1010 S%=I% 1020 GOSUB 1100 1030 Z%=CALL(24678%,S%) 1040 IF PEEK(64789%)=0 THEN 1070 : REM If everything OK 1050 ; ' Error'PEEK(64789%)' on sector'I% : ; ' RAMGEN error !-Press RETURN '; 1060 INPUT I$ 1070 NEXT I% 1080 ; : ; : ; ' RAM - disc is OK !' 1090 END 1100 IF C%=1% THEN S%=S%*32% 1110 RETURN