Note: Original (zip) of this at
http://www.codeguide.net/files/file.php?file=cmos
Mac
'+-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-+
'| Author John Rude |
'| Date Created 8-13-00 |
'| FileName: CmosRead.BAS |
'| Cmos Reader 1.0 |
'| If you have any question or |
'| comments Email me at |
'| rudesj@yahoo.com |
'+-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
' | Cmos can be read by OUTing to port &h70, Bit. then INPing |
' * Port &h71. *
' | To Write to the Cmos OUT to &h70, bit and the OUT &h71,Value |
' *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
'$INCLUDE: 'qb.bi' ' Used for assembly
DIM SHARED inregs AS RegTypeX
DIM SHARED outregs AS RegTypeX
DIM SHARED ScreenData$(12)
InitData
CLS
LOCATE 1, 1: PRINT "Cmos Reader 1.0 by John Rude."
LOCATE 11, 1: PRINT "Cmos Drive Report"
ShowCmos
FOR DRV% = 1 TO 2 ' Get drive info from CmOS
CALL CmosFloppyDrives(CHR$(64 + DRV%), Type$, Size$)
LOCATE 11 + DRV%, 1: PRINT CHR$(DRV% + 64); ": "; Type$, Size$
NEXT DRV%
LOCATE 15, 1: PRINT "Base Memory: "; BaseMemory; "KB"
' I can't get this one to work right!
LOCATE 16, 1: PRINT "Extented Memory: "; ExtendedMemory; "MB"
DO
CALL CmosTime(Hr$, Min$, Sec$, CmosTimes$)
CALL CmosDate(Year$, Month$, Day$, Century$, CmosDates$)
LOCATE 18, 1: PRINT "Cmos Time: "; CmosTimes$
LOCATE 19, 1: PRINT "Cmos Date: "; CmosDates$
LOCATE 20, 1: PRINT "Cmos Battery is a "; Battery$
IF VAL(Sec$) MOD 2 = 0 THEN ShowCmos
KBD$ = INKEY$
LOOP UNTIL KBD$ <> ""
KoolEnd
KoolShow
DO
KBD$ = INKEY$
LOOP UNTIL KBD$ <> ""
KoolEnd
FUNCTION AddZero$ (ADDhere$)
IF LEN(ADDhere$) = 1 THEN
ADDhere$ = "0" + ADDhere$
END IF
AddZero$ = ADDhere$
END FUNCTION
FUNCTION BaseMemory%
OUT &H70, &H15
BaseLow% = INP(&H71)
OUT &H70, &H16
BaseHi% = INP(&H71)
BaseMemory% = (BaseLow% + BaseHi% * 256)
END FUNCTION
FUNCTION Battery$
OUT &H70, &HD
BatteryStatus% = INP(&H71)
Batt$ = "Dead Battery"
IF BatteryStatus% AND 128 THEN
Batt$ = "Good Battery"
END IF
Battery$ = Batt$
END FUNCTION
SUB CmosDate (Year$, Month$, Day$, Century$, CmosDates$)
DateFormat$ = "-"
OUT &H70, &H9 ' Get Year
Year$ = HEX$(INP(&H71))
OUT &H70, &H8 ' Request Month from Cmos
Month$ = HEX$(INP(&H71))
OUT &H70, &H7 ' Request day from Cmos
Day$ = HEX$(INP(&H71))
OUT &H70, &H32 ' Request Century from Cmos
Century$ = HEX$(INP(&H71))
OUT &H70, &H37 ' Request Century from Cmos
Datec$ = HEX$(INP(&H71))
Year$ = AddZero(Year$)
Month$ = AddZero(Month$)
Day$ = AddZero(Day$)
CmosDates$ = Month$ + DateFormat$ + Day$ + DateFormat$ + Year$ + " Current Century - " + Century$
END SUB
SUB CmosFloppyDrives (Drive$, Type$, Size$)
OUT &H70, &H10 ' request Floppy info from Cmos
CmosReadDrive = INP(&H71) ' Dump info to variable
SELECT CASE ASC(UCASE$(Drive$))
CASE 65
Drive$ = "A:"
CmosReadDrive = CmosReadDrive \ 16
CASE ELSE
Drive$ = "B:"
CmosReadDrive = CmosReadDrive AND 15
END SELECT
SELECT CASE CmosReadDrive
CASE 0
Type$ = "No Drive Attached"
Size$ = "N/A"
CASE 1
Type$ = "360 KB"
Size$ = "5¬"
CASE 2
Type$ = "1.2 MB"
Size$ = "5¬"
CASE 3
Type$ = "730 KB"
Size$ = "3«"
CASE 4
Type$ = "1.44 MB"
Size$ = "3«"
END SELECT
END SUB
SUB CmosTime (Hr$, Min$, Sec$, CmosTimes$)
' Get the time from the Cmos Chip.
OUT &H70, 4 ' Request Hours from Cmos
Hr$ = HEX$(INP(&H71))
OUT &H70, 2 ' Request Minutes from Cmos
Min$ = HEX$(INP(&H71))
OUT &H70, 0 ' Request Seconds from Cmos
Sec$ = HEX$(INP(&H71))
TimeFormat$ = ":" ' The fromat of the time
Hr$ = AddZero(Hr$)
Min$ = AddZero(Min$)
Sec$ = AddZero(Sec$)
CmosTimes$ = Hr$ + TimeFormat$ + Min$ + TimeFormat$ + Sec$
END SUB
FUNCTION ExtendedMemory# ' This is a little weird! Not very acurate.
OUT &H70, 17
extlow% = INP(&H71)
OUT &H70, 18
extHigh% = INP(&H71)
OUT &H70, 30
extlow1% = INP(&H71)
OUT &H70, 31
extHigh1% = INP(&H71)
Ext# = extlow% + extlow1% + extHigh% * 256 + extHigh1% * 256
ExtendedMemory# = Ext# \ 1024
END FUNCTION
SUB InitData
ScreenData$(1) = "+-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-+"
ScreenData$(2) = "| Author John Rude |"
ScreenData$(3) = "| Date Created 8-13-00 |"
ScreenData$(4) = "| FileName: CmosRead.BAS |"
ScreenData$(5) = "| Cmos Reader 1.0 |"
ScreenData$(6) = "| If you have any question or |"
ScreenData$(7) = "| comments Email me at |"
ScreenData$(8) = "| rudesj@yahoo.com |"
ScreenData$(9) = "+-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-+"
END SUB
SUB KoolEnd
FOR duration = 0 TO 25
FOR x = 0 TO 79
SELECT CASE x MOD 2
CASE 0
inregs.ax = 1 + (7 * 256)
inregs.bx = 0 + (0 * 256)
inregs.cx = x + (0 * 256)
inregs.dx = x + (25 * 256)
CALL INTERRUPTX(&H10, inregs, outregs) ' Call Bios to scroll screen
CASE 1 ' up
inregs.ax = 1 + (6 * 256)
inregs.bx = 0 + (0 * 256)
inregs.cx = x + (0 * 256)
inregs.dx = x + (25 * 256)
CALL INTERRUPTX(&H10, inregs, outregs) ' Call bios to scroll screen
END SELECT ' down
NEXT x
DEF SEG = &H40
n1 = PEEK(&H6C)
DO
n2 = PEEK(&H6C)
LOOP UNTIL n1 <> n2
NEXT duration
END SUB
SUB KoolShow
FOR duration = 0 TO 16
PlaceInfo (duration)
FOR x = 0 TO 79
SELECT CASE x MOD 2
CASE 0
inregs.ax = 1 + (7 * 256) ' (AL) line blanked at bottom/ (AH) 7 Service
inregs.bx = 0 + (0 * 256) ' Attrib used on blank lines
inregs.cx = x + (0 * 256) ' Upper Left row/colum
inregs.dx = x + (25 * 256) ' Lower Right row/colum
CALL INTERRUPTX(&H10, inregs, outregs)
CASE 1
inregs.ax = 1 + (6 * 256) ' (AL) line blanked at bottom/ (AH) 7 Service
inregs.bx = 0 + (0 * 256) ' Attrib used on blank lines
inregs.cx = x + (0 * 256) ' Upper Left row/colum
inregs.dx = x + (25 * 256) ' Lower Right row/colum
CALL INTERRUPTX(&H10, inregs, outregs)
END SELECT
NEXT x
DEF SEG = &H40
n1 = PEEK(&H6C)
DO
n2 = PEEK(&H6C)
LOOP UNTIL n1 <> n2
NEXT duration
END SUB
SUB PlaceInfo (duration)
IF duration <= 9 THEN
FOR Placetext = 1 TO LEN(ScreenData$(duration)) STEP 2
LOCATE 1, Placetext: PRINT MID$(ScreenData$(10 - duration), Placetext, 1)
LOCATE 25, 1 + Placetext: PRINT MID$(ScreenData$(duration), Placetext + 1, 1);
NEXT Placetext
END IF
END SUB
SUB ShowCmos
LOCATE 2, 1: PRINT "Cmos Data:"
LOCATE 3, 1:
FOR i = 0 TO &H7F
OUT &H70, i
PRINT USING "\ \"; HEX$(INP(&H71));
NEXT i
END SUB
This message has been edited by iorr5t on Mar 24, 2003 10:03 AM
|
|