DECLARE FUNCTION AskForBaseAddress! (OldOne AS INTEGER) '*************************************************************************** '* This sample program will sequentially turn on all bits of port 0 of the * '* IOD64 and then sequentially turn them off. Each time it sets a new bit,* '* both port 0 and port 1 are read and the data displayed. This * '* demonstrates how to read and write to a port, and to use the read back * '* function of the board. * '*************************************************************************** ' DIM CURRENT%(3) ' 'print the string display ' CLS PRINT " SAMPLE 1.BAS : IOD-64S" PRINT PRINT "This sample program will sequentially turn on all bits of port 0 of the" PRINT "IOD64 and then sequentially turn them off. Each time it sets a new bit," PRINT "both port 0 and port 1 are read and the data displayed. This" PRINT "demonstrates how to read and write to a port, and to use the read back" PRINT "function of the board." LOCATE 10, 1 Address% = AskForBaseAddress!(&H300) CLS PRINT PRINT PRINT "Board Configuration" PRINT PRINT " -- Base Address is "; HEX$(Address%); " hex." PRINT " -- All remaining jumper settings are irrelevant." PRINT : PRINT : PRINT PRINT "Press a key to continue." ch$ = INPUT$(1) CLS LOCATE 1, 10 PRINT " I O D 6 4 C A R D S A M P L E P R O G R A M " LOCATE 6, 17 PRINT " PORT 0 OUTPUT PORT 0 INPUT PORT 1 INPUT" LOCATE 7, 17 PRINT " ------------- ------------ ------------ " LOCATE 10, 28 PRINT " PRESS F1 TO EXIT PROGRAM " ' 'main control loop ' CURRENT(0) = 0 SHIFTLEFT% = 1 OUT Address% + 8, &H1 ON KEY(1) GOSUB QUIT KEY(1) ON ' 'this loop will repeat endlessly until F1 is pressed ' CONT: OUT Address%, CURRENT%(0) 'write value to port 0 CURRENT%(1) = INP(Address%) 'read back back what we wrote to port 0 CURRENT%(2) = INP(Address% + 1) 'read the data on port 1 ' 'write the data to the screen ' X = 20 'starting x coordinate to write data to screen FOR INDEX = 0 TO 2 'for each array member VALUE% = CURRENT%(INDEX) FOR INDEX1 = 0 TO 7 'for each bit in array member */ LOCATE 8, X VALUE1% = VALUE% MOD 2 IF VALUE1% = 1 THEN PRINT "1" ELSE PRINT "0" VALUE% = (VALUE% - 1) / 2 ' roll next display bit X = X + 1 NEXT INDEX1 X = X + 10 NEXT INDEX ' 'compute value to turn on/off next bit in line ' IF CURRENT%(0) = 0 THEN SHIFTLEFT = 1 IF CURRENT%(0) = 255 THEN SHIFTLEFT = 0 IF SHIFTLEFT = 1 THEN CURRENT%(0) = CURRENT%(0) * 2 + 1 IF SHIFTLEFT = 0 THEN CURRENT%(0) = (CURRENT%(0) - 1) / 2 FOR X = 0 TO 3500: Y = Y + 1: NEXT X GOTO CONT QUIT: CLS END FUNCTION AskForBaseAddress (OldOne AS INTEGER) Msg$ = "" NewOne% = 0: Success = 0: Dummy% = 0 AddrInputPosX = 0: AddrInputPosY = 0 PRINT "Please enter the Base Address (0000-FFFF) for your card (in hex)" PRINT "or press ENTER for "; HEX$(OldOne%); "." PRINT ">"; AddrInputPosX = POS(0): AddrInputPosY = CSRLIN WHILE Success = 0 LOCATE AddrInputPosY, AddrInputPosX PRINT " " LOCATE AddrInputPosY, AddrInputPosX LINE INPUT Msg$ NewOne% = VAL("&H0" + LEFT$(Msg$, 4)) Success = 1 Dummy% = NewOne% IF (Msg$ = "") THEN LOCATE AddrInputPosY, AddrInputPosX PRINT HEX$(OldOne%) Success = 1 Dummy% = OldOne% END IF WEND AskForBaseAddress = Dummy% END FUNCTION