home *** CD-ROM | disk | FTP | other *** search
- goto EXAMPLE
-
- function CurDefSeg%
- 'author......| Michael E. Flenniken
- 'version.....| 1.00 6/13/90 for PowerBASIC v2.00b
- 'parameters..| None
- 'success.....| Returns segment of the most recent DEF SEG
- 'notes.......| This is a two part function. sub GetDefSeg() must be present.
- ' | function CurDefSeg% must be initiallized. The first call to
- ' | CurDefSeg% intiallizes it and returns PB's data segment.
- ' | Subsequent calls returns the current DEF SEG
- 'warnings....| Use at your own risk.
- local CurDataSeg%
- static DefDataSeg%
-
- if DefDataSeg% = 0 then ' If this is the first time called
- def seg ' initiallize with PB data segment
- DefDataSeg% = peeki(26)
- CurDefSeg% = DefDataSeg%
- else ' Otherwise get and return the current def seg
- call GetDefSeg (DefDataSeg%, CurDataSeg%)
- CurDefSeg% = CurDataSeg%
- end if
-
- end function
-
-
- sub GetDefSeg inline ' (PBDataSeg%, CurSeg%)
-
- $inline &h55 ' PUSH BP ; Save BP
- $inline &h89, &hE5 ' MOV BP, SP ; Move SP to BP
- $inline &h1E ' PUSH DS ; Save DS
- $inline &hC4, &h7E, &h0A ' LES DI, [BP+0A] ; ES:DI is ptr to PBDataSeg%
- $inline &h26, &h8E, &h1D ' MOV DS, ES:[DI] ; set DS to PB data segment
- $inline &hBE, &h1A, &h00 ' MOV SI, 1A ; Current def seg @ offset 26
- $inline &hAD ' LODSW ; Load current def seg to AX
- $inline &hC4, &h7E, &h06 ' LES DI, [BP+06] ; ES:DI is ptr to CurSeg%
- $inline &hAB ' STOWSW ; Store AX to CurSeg%
- $inline &h1F ' POP DS ; Restore DS
- $inline &h5D ' POP BP ; Restore BP
-
- end sub
-
-
-
-
- EXAMPLE:
- cls
- ? "The PB data segment is"; CurDefSeg% ' Initiallize function CurDefSeg%
- def seg = 1000 ' Change def seg for demo
- ? : ? "The `def seg' is"; CurDefSeg% ' Show def seg
- call CheckKeyboardStatus ' Call routine that changes def seg
- ?: ? "The `def seg' is still"; CurDefSeg% ' Show that def seg was preserved
-
- sub CheckKeyboardStatus
-
- CurrentDefSeg% = CurDefSeg% ' Preserve current def seg
- def seg = &h40 ' Change def seg to BIOS data seg
- KeyStatus% = peek(&h17) ' Get the keyboard status byte
- def seg = CurrentDefSeg% ' Reset def seg
-
- ? ' Display status of keyboard
- if (KeyStatus% and &b01000000) <> 0 then
- ? "CapsLock is on"
- else
- ? "CapsLock is off"
- end if
- if (KeyStatus% and &b00100000) <> 0 then
- ? "NumLock is on"
- else
- ? "NumLock is off"
- end if
- if (KeyStatus% and &b00010000) <> 0 then
- ? "ScrollLock is on"
- else
- ? "ScrollLock is off"
- end if
-
- end sub