summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sw/startram.bas148
-rw-r--r--sw/startram.bx6
2 files changed, 79 insertions, 75 deletions
diff --git a/sw/startram.bas b/sw/startram.bas
index 4a74fa5..69c0b6c 100644
--- a/sw/startram.bas
+++ b/sw/startram.bas
@@ -22,76 +22,78 @@
1210 POKE B%+29%,35%,203%,57%,143%,203%,57%,143%,18%,19%,121%,214%,1%
1220 Z0%=CALL(B%)
1230 DEF FNP2%(A%)=PEEK(A%)+SWAP%(PEEK(A%+1%))
-1240 P1%=1% : REM If TKN80 detected, patch INP() in BASIC for mode switch
-1250 M%=CALL(B%+59%)
-1260 IF M%=1% PRINT "No ";
-1270 PRINT "SRAM/flash memory card detected"
-1280 ON M% GOTO 1940,1290,1290,1310,1330
-1290 Z%=CALL(B%+168%)
-1300 PRINT "Map 0 setup complete"
-1310 OUT 31%,0%
-1320 PRINT "Memory mapping enabled"
-1330 DIM P%(2%)
-1340 FOR I%=0% TO 2%
-1350 P%(I%)=CALL(B%+289%,I%)
-1360 PRINT "IC" CHR$(49%+I%)" :";
-1370 IF P%(I%) THEN 1380 ELSE 1400
-1380 PRINT P%(I%)*8% "K SRAM"
-1390 GOTO 1580
-1400 IF I%=2% THEN 1410 ELSE 1570
-1410 F%=CALL(B%+385%)
-1420 V%=PEEK(F%)
-1430 D%=PEEK(F%+1%)
-1440 V0%=PEEK(F%+2%)
-1450 D0%=PEEK(F%+3%)
-1460 IF (V% AND D% AND V0% AND D0%)=255% THEN 1470 ELSE 1490
-1470 PRINT " WP flash or empty"
-1480 GOTO 1560
-1490 IF V%=191% AND D%>=181% AND D%<=183% THEN 1500 ELSE 1520
-1500 PRINT 2%**(D%-174%)"K flash (writable)"
-1510 GOTO 1560
-1520 IF V%=V0% AND D%=D0% THEN 1530 ELSE 1550
-1530 PRINT " WP flash"
-1540 GOTO 1560
-1550 PRINT " unknown flash (writable)"
-1560 GOTO 1580
-1570 PRINT " empty"
-1580 OUT 508%+SWAP%(I%),P%(I%)
-1590 NEXT I%
-1600 IF P%(0%)<9% THEN 1610 ELSE 1630
-1610 PRINT "Error: IC1 not SRAM or too small"
-1620 GOTO 1940
-1630 IF M%=5% THEN 1640 ELSE 1660
-1640 PRINT "Already running with BASIC in SRAM"
-1650 GOTO 1940
-1660 Z0%=CALL(B%+243%)
-1670 PRINT "Map 1-3 setup complete"
-1680 T0%=CALL(B%+190%)
-1690 W%=SWAP%(T0%) AND 255%
-1700 B0%=T0% AND 255%
-1710 IF B0%<>124% THEN 1720 ELSE 1760
-1720 PRINT "TKN80 found at";B0%/4%;"K in";W%;"-column mode"
-1730 P0%=(B0%/32%) OR 192%
-1740 OUT 30772%,P0%,31284%,P0%,63572%,P0%,64084%,P0%
-1750 GOTO 1790
-1760 P1%=0%
-1770 W%=40%
-1780 PRINT "No TKN80 found"
-1790 Z0%=CALL(B%+473%)
-1800 PRINT "Memory contents copied to SRAM"
-1810 OUT 31%,1%
-1820 IF W%=80% THEN 1830 ELSE 1880
-1830 FOR I%=0% TO 7%
-1840 FOR J%=0% TO 16% STEP 8%
-1850 POKE 884%+(I%+J%)*2%,J%*10%,120%+I%
-1860 NEXT J%
-1870 NEXT I%
-1880 PRINT "Now running with BASIC in SRAM"
-1890 Z0%=CALL(B%+526%)
-1900 IF P1% THEN 1910 ELSE 1930
-1910 Z0%=CALL(B%+692%)
-1920 PRINT "TKN80 mode switch BASIC patch installed"
-1930 IF FNP2%(65052%)=49152% THEN POKE 65053%,128%
-1940 B1%=(FNP2%(65052%)+1023%)/1024%
-1950 PRINT "RAM available to BASIC:" 64%-B1% "K (BOFA" B1% "K)"
-1960 CHAIN ""
+1240 DEF FNU(A%)=A%-65536*(A%<0%)
+1250 P1%=1% : REM If TKN80 detected, patch INP() in BASIC for mode switch
+1260 M%=CALL(B%+59%)
+1270 IF M%=1% PRINT "No ";
+1280 PRINT "SRAM/flash memory card detected"
+1290 ON M% GOTO 1950,1300,1300,1320,1340
+1300 Z%=CALL(B%+168%)
+1310 PRINT "Map 0 setup complete"
+1320 OUT 31%,0%
+1330 PRINT "Memory mapping enabled"
+1340 DIM P%(2%)
+1350 FOR I%=0% TO 2%
+1360 P%(I%)=CALL(B%+289%,I%)
+1370 PRINT "IC" CHR$(49%+I%)" :";
+1380 IF P%(I%) THEN 1390 ELSE 1410
+1390 PRINT P%(I%)*8% "K SRAM"
+1400 GOTO 1590
+1410 IF I%=2% THEN 1420 ELSE 1580
+1420 F%=CALL(B%+385%)
+1430 V%=PEEK(F%)
+1440 D%=PEEK(F%+1%)
+1450 V0%=PEEK(F%+2%)
+1460 D0%=PEEK(F%+3%)
+1470 IF (V% AND D% AND V0% AND D0%)=255% THEN 1480 ELSE 1500
+1480 PRINT " WP flash or empty"
+1490 GOTO 1570
+1500 IF V%=191% AND D%>=181% AND D%<=183% THEN 1510 ELSE 1530
+1510 PRINT 2%**(D%-174%)"K flash (writable)"
+1520 GOTO 1570
+1530 IF V%=V0% AND D%=D0% THEN 1540 ELSE 1560
+1540 PRINT " WP flash"
+1550 GOTO 1570
+1560 PRINT " unknown flash (writable)"
+1570 GOTO 1590
+1580 PRINT " empty"
+1590 OUT 508%+SWAP%(I%),P%(I%)
+1600 NEXT I%
+1610 IF P%(0%)<9% THEN 1620 ELSE 1640
+1620 PRINT "Error: IC1 not SRAM or too small"
+1630 GOTO 1950
+1640 IF M%=5% THEN 1650 ELSE 1670
+1650 PRINT "Already running with BASIC in SRAM"
+1660 GOTO 1950
+1670 Z0%=CALL(B%+243%)
+1680 PRINT "Map 1-3 setup complete"
+1690 T0%=CALL(B%+190%)
+1700 W%=SWAP%(T0%) AND 255%
+1710 B0%=T0% AND 255%
+1720 IF B0%<>124% THEN 1730 ELSE 1770
+1730 PRINT "TKN80 found at";B0%/4%;"K in";W%;"-column mode"
+1740 P0%=(B0%/32%) OR 192%
+1750 OUT 30772%,P0%,31284%,P0%,63572%,P0%,64084%,P0%
+1760 GOTO 1800
+1770 P1%=0%
+1780 W%=40%
+1790 PRINT "No TKN80 found"
+1800 Z0%=CALL(B%+473%)
+1810 PRINT "Memory contents copied to SRAM"
+1820 OUT 31%,1%
+1830 IF W%=80% THEN 1840 ELSE 1890
+1840 FOR I%=0% TO 7%
+1850 FOR J%=0% TO 16% STEP 8%
+1860 POKE 884%+(I%+J%)*2%,J%*10%,120%+I%
+1870 NEXT J%
+1880 NEXT I%
+1890 PRINT "Now running with BASIC in SRAM"
+1900 Z0%=CALL(B%+526%)
+1910 IF P1% THEN 1920 ELSE 1940
+1920 Z0%=CALL(B%+692%)
+1930 PRINT "TKN80 mode switch BASIC patch installed"
+1940 IF FNP2%(65052%)=49152% THEN POKE 65053%,128%
+1950 B=FNU(FNP2%(65052%))
+1960 PRINT "BASIC usable RAM:" INT((65536-B)/1024);
+1970 PRINT "K (BOFA" B ")"
+1980 CHAIN ""
diff --git a/sw/startram.bx b/sw/startram.bx
index e953701..198ac7d 100644
--- a/sw/startram.bx
+++ b/sw/startram.bx
@@ -11,6 +11,7 @@
!! and has problems during the SRAM size probing sequence.
Z80ASM <startram.o>, #0xc000, &1024
+ DEF FNUnsigned.(a) = a-65536.*(a<0)
!! *** TKN80: hook INP() for automatic BASIC patching?
PatchINP = 1 : REM If TKN80 detected, patch INP() in BASIC for mode switch
@@ -119,6 +120,7 @@ rambasic:
IF FNPeek2(65052)=49152 THEN POKE 65053,128
done:
- BOFAK = (FNPeek2(65052)+1023)/1024
- PRINT "RAM available to BASIC:" 64-BOFAK "K (BOFA" BOFAK "K)"
+ BOFA. = FNUnsigned.(FNPeek2(65052))
+ PRINT "BASIC usable RAM:" INT((65536.-BOFA.)/1024.);
+ PRINT "K (BOFA" BOFA. ")"
CHAIN ""