Make your own free website on Tripod.com

Here are some usefull program routines I've collected over the years.
____________________________________________________________________
TO GET A REMAINDER IN DIVISION
This like a PC's BASIC language MOD function
10 DEFFNMOD(X)=X-INT(X/D)*D
20 D=10:? FNMOD(25):REM for example to get the remainder for 25 divided by 10
--------------------------------------------------------------------
TO DETECT IF A DISK IN THE DRIVE IS WRITE-PROTECTED
10 OPEN15,8,15:PRINT#1,"M-R";CHR$(30);CHR$(0):GET#1,A$:CLOSE1
20 IF ASC(A$+CHR$(1))=1 THEN PRINT"DISK IS WRITE PROTECTED"
--------------------------------------------------------------------
TO DETECT IF DISK DRIVE OR PRINTER IS TURNED ON
10 OPEN15,DN,15:CLOSE15:REM DN=divice number usually 8 for disk,4 for printer
20 IF ST<>0 THEN PRINT"TURN ON DRIVE/PRINTER":END
or you can use the following on a C128
10 DN=8:POKE6,DN:POKE144,0:SYS65457:S=ST:SYS65454:S=S OR ST:IFS THEN PRINT"TURN ON DRIVE":END
---------------------------------------------------------------------
TO DETECT SCREEN WIDTH-128 only
A=PEEK(215):if A= 0 then you're in 40 column mode;128 means you're in 80 column mode
---------------------------------------------------------------------
TO CLEAR THE 40 COLUMN HI-RES SCREEN-128 only
SYS 27440
---------------------------------------------------------------------
TO SET and UNSET the Msb of a SPRITE-128 only
10 SN=1:rem SN is the value of the sprite Msb;1=SPRITE1.-2=SPRITE2-4=SPRITE3-8=SPRITE4,etc
20 POKE4582,255-PEEK(4582)AND(SN)
---------------------------------------------------------------------
TO CHANGE BANKS IN ML-128 only
LDA value:STA $FF00
where value equals one of the following:
3F=BANK 0
7F=BANK 1
BF=BANK 2
00=BANK 15
01=BANK 14
---------------------------------------------------------------------
TO PRINT MESSEGES IN ML-128 only
JSR $FF7D
.BYTE "HELLO"
.BYTE 0
RTS ;if used as a subroutine,else continue program here
---------------------------------------------------------------------
AN EASY WAY TO SWITCH TO BANK 15 IN ML-128 only
JSR 733-"A" register will equal 0 on return
---------------------------------------------------------------------
TO POSITION THE CURSOR WITHOUT USING CHAR-128 only
SYS65520,0,Y,X:PRINT"SOMETHING"
or use
POKE235,X:POKE236,Y:PRINT"SOMETHING"
---------------------------------------------------------------------
40 COLUMN DISPLAY ON 80 COLUMN SCREEN-128 only
first time program is RUN,switches VDC to 40 column mode;if ran a 2nd time,switches VDC back to 80 columns
10 READX$,O$:L=LEN(O$)-1
20 FOR J=1toL STEP2
30 O=DEC(MID$(O$,J,2)):X=DEC(MID$(X$,J,2))
40 SYS 52689,,X:RREG A
50 A=XOR(A,O):SYS52684,A,X
60 NEXTJ
70 DATA"00010216191B),"417853F11028)
---------------------------------------------------------------------






RETURN TO MAIN PAGE:
BASIC 7.0 Encyclopedia: