Created
November 19, 2018 01:50
-
-
Save iconjack/3aeda081155d28e2ae8beb04a6c20c72 to your computer and use it in GitHub Desktop.
BIOS SETUP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PAGE 58,132 | |
;---------------------------------------------------------------------------- | |
; Hier sind der neu SETUP komputerprogramm. | |
;---------------------------------------------------------------------------- | |
.386P | |
FALSE EQU 0 | |
TRUE EQU NOT FALSE | |
;---------------------------------------------------------------------------- | |
; a couple of things I use out the ROM DATA area | |
;---------------------------------------------------------------------------- | |
DEVFLG EQU 0010H | |
MFLAGS EQU 00B5H | |
INCLUDE CMSEQU.INC | |
.LIST | |
;---------------------------------------------------------------------------- | |
; Set the DOS flag to TRUE if you generating a DOS executable file. This | |
; is useful for debugging SETUP by itself without having to blow ROMS. | |
; For inclusion in the ROM BIOS, set the DOS flag to FALSE. | |
;---------------------------------------------------------------------------- | |
;DOS EQU TRUE | |
;---------------------------------------------------------------------------- | |
; CMOS RAM Usage | |
;---------------------------------------------------------------------------- | |
; | |
;---------------------------------------------------------------------------- | |
; These are attributes which can be passed to the ShowString procedure. | |
; The reason that they are defined here rather than with the procedure | |
; is that MASM will generate a NOP when MOV BH,<attributes> is used. | |
;---------------------------------------------------------------------------- | |
leaveIt EQU 00000000B ; just display the text | |
leftJust EQU 00000001B ; left justify (field width in CL) | |
rightJust EQU 00000010B ; right justify | |
centerIt EQU 00000011B ; center = left + right justify | |
justBits EQU 00000011B ; mask for justification bits | |
newCursor EQU 00000100B ; cursor position supplied in DX | |
invertIt EQU 00001000B ; show string in reverse video | |
moveCursor EQU 00010000B ; update the cursor after showing text | |
customAttr EQU 00100000B ; custom attribute supplied in BL | |
specialAttr EQU 01000000B ; use the "special" attribute | |
;---------------------------------------------------------------------------- | |
; this macro deposits a string, prefixing it with a length byte | |
;---------------------------------------------------------------------------- | |
STRING MACRO theString | |
LOCAL SIMON | |
LOCAL GARFUNKLE | |
DB (OFFSET GARFUNKLE)-(OFFSET SIMON) | |
SIMON: DB theString | |
GARFUNKLE: | |
ENDM | |
;---------------------------------------------------------------------------- | |
; this macro converts a BCD number in AL to binary | |
;---------------------------------------------------------------------------- | |
BIN MACRO | |
DB 0D4H,16 ; AAM 16 | |
AAD | |
ENDM | |
;---------------------------------------------------------------------------- | |
; this macro converts a binary number in AL to BCD | |
;---------------------------------------------------------------------------- | |
BCD MACRO | |
AAM | |
DB 0D5H,16 ; AAD 16 | |
ENDM | |
;---------------------------------------------------------------------------- | |
IOWAIT MACRO | |
OUT 0EDH,AX | |
ENDM | |
;---------------------------------------------------------------------------- | |
; these are global variables for SETUP which can be accessed off of BP | |
;---------------------------------------------------------------------------- | |
; | |
theField EQU 0 ; [2] pointer to current field | |
numberBuf EQU 2 ; [6] temp storage for converting nums | |
pageNum EQU 8 ; [1] page number for help | |
pageMax EQU 9 ; [1] help page count for current item | |
globalSize EQU 10 ; total size of global area | |
;---------------------------------------------------------------------------- | |
; these are the object message codes | |
;---------------------------------------------------------------------------- | |
; | |
mDec EQU -1 | |
mDisp EQU 0 | |
mInc EQU +1 | |
mHelp EQU 3 | |
mSanity EQU 4 | |
;---------------------------------------------------------------------------- | |
; this is the object structure | |
;---------------------------------------------------------------------------- | |
OBJECT STRUC | |
messageProc DW 0 ; offset of message handler routine | |
fieldPos DW 0 ; location of the field on the screen | |
fieldWidth DB 0 ; width of the objects field | |
helpText DW 0 ; offset to object's help text | |
OBJECT ENDS | |
;---------------------------------------------------------------------------- | |
BIOSCODE SEGMENT USE16 | |
ASSUME CS:BIOSCODE | |
ORG 100H | |
;---------------------------------------------------------------------------- | |
; Le Beginnin | |
;---------------------------------------------------------------------------- | |
SETUP PROC FAR ; entr vu | |
PUSHA | |
PUSH DS | |
PUSH ES | |
PUSH FS | |
MOV AX,0040H | |
MOV DS,AX | |
; | |
; set SETUP running bit | |
; | |
OR BYTE PTR DS:[MFLAGS],00000001B | |
; | |
; clear all CMOS errors | |
; | |
MOV AX,000EH | |
CALL CMOSWrite | |
; | |
; get current cursor location and cursor type and save them | |
; | |
MOV AH,3 ; Read Cursor Position | |
INT 10H | |
PUSH CX | |
PUSH DX | |
; | |
; set video mode | |
; Use mode 7 if MONO, else use mode 3 | |
; | |
MOV AL,BYTE PTR DS:[DEVFLG] | |
NOT AL | |
TEST AL,00110000B ; bits 4,5 = video | |
MOV AL,3 ; | |
JNZ SHORT @F ; jump if not MONO | |
MOV AL,7 ; it is MONO | |
@@: MOV AH,0 ; = set video mode function | |
INT 10H | |
; | |
; get rid of the unsightly cursor | |
; | |
MOV CX,2000H ; top = 32, bottom = 0 | |
MOV AH,1 | |
INT 10H | |
; | |
; set up segment registers | |
; | |
PUSH CS | |
POP DS | |
PUSH SS | |
POP ES | |
; | |
; announce ourselves | |
; | |
MOV BH,centerIt+invertIt | |
MOV CL,80 | |
CALL ShowThis | |
STRING 'Dell Computer Corporation' | |
MOV DX,100H | |
MOV BH,centerIt+invertIt+newCursor | |
MOV CL,80 | |
CALL ShowThis | |
STRING 'System 425/E SETUP 1.0' | |
; | |
; print the static text on the screen | |
; | |
LEA SI,staticText | |
@@: MOV DX,[SI] | |
ADD SI,2 | |
MOV BH,newCursor | |
CALL ShowString | |
CMP SI,OFFSET staticEnd | |
JNE @B | |
;---------------------------------------------------------------------------- | |
; put some pretty boxes around the major areas | |
;---------------------------------------------------------------------------- | |
LEA SI,lineTable | |
MOV BH,0 ; video page number | |
line_loop: LODSW ; get cursor position | |
XCHG AX,DX ; to DX | |
LODSW ; get count and glyph | |
SHR AH,1 ; C = vert/horz, AH = count | |
MOV CX,1 ; assume horizontal | |
JNC SHORT @F ; jump if so | |
XCHG CH,CL ; change to vertical | |
@@: MOV BL,AH ; BL = loop count | |
@@: PUSHA ; caveat INT 10! | |
MOV AH,2 ; set cursor | |
INT 10H | |
MOV AH,0AH ; write character | |
MOV CX,1 ; count | |
INT 10H | |
POPA | |
ADD DX,CX ; add displacement | |
DEC BX | |
JNZ @B | |
CMP SI,OFFSET lineEnd | |
JNE line_loop ; jump if more lines | |
JMP SHORT @F ; jump around table | |
lineTable DB 2CH,02H,0B3H,45 | |
DB 00H,17H,0C4H,160 | |
DB 2CH,17H,0C1H,2 | |
DB 2DH,12H,0C4H,70 | |
DB 2CH,12H,0C3H,2 | |
lineEnd EQU $ | |
@@: | |
; | |
; put some help text near the bottom of the screen | |
; | |
MOV DX,1800H | |
MOV BH,centerIt+invertIt+newCursor | |
MOV CL,80 | |
CALL ShowThis | |
STRING 'TAB, SHIFT-TAB change fields ³ , change values ³ ESC exit ³ Alt-B reboot ' | |
; | |
; put some key help for the help window | |
; | |
MOV DX,112DH | |
MOV BH,invertIt+newCursor | |
CALL ShowThis | |
STRING ' PgDn next page ³ PgUp prev page ' | |
;---------------------------------------------------------------------------- | |
; put the non-changable items on the screen | |
; | |
; BIOS version and date | |
; | |
MOV DX,132EH | |
MOV BH,newCursor | |
CALL ShowThis | |
STRING 'BIOS version' | |
MOV AX,0F000H | |
MOV ES,AX | |
MOV BP,0E842H | |
MOV CX,3 | |
MOV DX,133BH | |
MOV BX,0FH ;7 | |
MOV AL,1 | |
MOV AH,13H | |
INT 10H ; INT 10 Display String | |
MOV AL,' ' | |
MOV AH,0EH ; Teletype Output | |
INT 10H | |
INT 10H | |
MOV AL,'(' | |
INT 10H | |
MOV BP,0FFF5H | |
MOV CX,8 | |
MOV DX,1341H | |
MOV BX,0FH | |
MOV AL,1 | |
MOV AH,13H | |
INT 10H ; Display String | |
MOV AL,')' | |
MOV AH,0EH | |
INT 10H | |
; | |
; allocate some space on the stack for global variables | |
; initialize BP to point to our global variable area on the stack | |
; | |
SUB SP,globalSize | |
MOV BP,SP | |
; since INT 10 AH=13 uses BP, don't call that one anymore | |
IF FALSE | |
; | |
; CPU speed is ... | |
; | |
MOV DX,152EH | |
MOV BH,newCursor+moveCursor | |
CALL ShowThis | |
STRING 'CPU speed is ' | |
IFNDEF DOS | |
MOV AX,0 | |
; CALL PMGARead | |
TEST AL,00000001B | |
MOV AL,16H | |
JNZ SHORT @F | |
MOV AL,8 | |
ENDIF | |
@@: | |
CALL ConvertNum | |
MOV BH,customAttr | |
MOV BL,0FH | |
CALL ShowString | |
MOV BH,newCursor | |
MOV DX,153DH | |
CALL ShowThis | |
STRING ' MHz.' | |
; | |
; Memory installed | |
; | |
MOV DX,162EH | |
MOV BH,0 | |
MOV AH,2 ; Set Cursor Position | |
INT 10H | |
MOV AL,4 | |
OUT 0E0H,AL | |
IN AL,0E1H | |
XOR AH,AH | |
SHL AX,9 | |
CALL ToDecimal | |
MOV BH,leaveIt+customAttr | |
MOV BL,0FH | |
CALL ShowString | |
MOV BH,leaveIt | |
CALL ShowThis | |
STRING 'KB RAM installed.' | |
ENDIF | |
ASSUME DS:BIOSCODE | |
PUSH CS | |
POP DS | |
IF FALSE | |
;---------------------------------------------------------------------------- | |
; check validity of CMOS RAM | |
; if invalid, set all fields to their default value | |
;---------------------------------------------------------------------------- | |
MOV BX,5F40H | |
CALL CMOSCheck | |
XCHG AX,BX | |
MOV AL,5FH | |
CALL CMOSRead | |
CMP AL,BH | |
JE SHORT DoSanity | |
; | |
LEA DI,Objects | |
MOV CX,objectCount | |
@@: MOV AH,2 | |
CALL [DI].messageProc | |
ADD DI,SIZE OBJECT | |
LOOP @B | |
ENDIF | |
;---------------------------------------------------------------------------- | |
; perform a sanity check on each field | |
;---------------------------------------------------------------------------- | |
DoSanity: LEA DI,Objects | |
MOV CX,objectCount | |
@@: MOV AH,mSanity | |
CALL [DI].messageProc | |
ADD DI,SIZE OBJECT | |
LOOP @B | |
; | |
; initialize the fields | |
; | |
InitFields: MOV WORD PTR theField[BP],0 | |
LEA DI,Objects | |
MOV CX,objectCount | |
@@: PUSH CX | |
MOV AH,0 | |
CALL [DI].messageProc | |
ADD DI,SIZE OBJECT | |
POP CX | |
LOOP @B | |
; | |
; initialize current field to the first one | |
; | |
MOV DI,OFFSET Objects | |
MOV WORD PTR theField[BP],DI | |
MOV BYTE PTR pageNum[BP],0 | |
JMP SHORT show_help | |
; | |
;---------------------------------------------------------------------------- | |
; Event Loop | |
;---------------------------------------------------------------------------- | |
; | |
; The Periodic routine is called repetitively while tooling for keystrokes | |
; to give the illusion of multitasking. Put code which handles things that | |
; need constant attention in this routine. For example, the TIME field. | |
; | |
NextEvent: PUSH CS | |
POP DS | |
CALL Periodic | |
; | |
; look for a keystroke | |
; | |
MOV AH,1 | |
INT 16H | |
JZ NextEvent | |
; | |
; key pressed | |
; | |
MOV AH,0 | |
INT 16H | |
CMP AL,0 | |
JE Extended | |
; | |
; regular-style ASCII character | |
; | |
CMP AL,1BH ; ESC? | |
JE SHORT ExitSETUP | |
CMP AL,9 ; TAB? | |
JNE NextEvent | |
; | |
; advance field | |
; | |
MOV DX,SIZE OBJECT | |
; | |
; This code will skip forward or backward to the next field. | |
; Use DX = +sizeof( OBJECT ) for moving forward, | |
; DX = -sizeof( OBJECT ) for moving backward. | |
; | |
AdvField: MOV DI,theField[BP] ; get the old field | |
MOV WORD PTR theField[BP],0 ; select no field | |
MOV AH,0 | |
CALL [DI].messageProc ; redisplay the old field | |
ADD DI,DX ; skip to next field | |
CMP DI,OFFSET objectEnd ; at the end? | |
JNE SHORT @F ; jump if not | |
MOV DI,OFFSET Objects ; else cycle back to first field | |
@@: CMP DI,OFFSET Objects ; at the beginning? | |
JNC SHORT @F ; jump if not | |
MOV DI,OFFSET lastObj ; else cycle back to last field | |
@@: MOV theField[BP],DI ; store the new field | |
MOV AH,0 | |
CALL [DI].messageProc | |
MOV BYTE PTR pageNum[BP],0 ; reset help to first page | |
; | |
; display the current page of help for the current field | |
; | |
PUBLIC show_help | |
show_help: CALL ClearHelp | |
MOV DI,theField[BP] | |
MOV SI,[DI+5] ; help pointer | |
OR SI,SI ; 0 means not implemented | |
JZ SHORT NEIsle | |
CMP SI,0FFFFH ; $FFFF means call object | |
JNZ SHORT @F | |
; | |
; tell the object to display its help | |
; | |
MOV AH,mHelp | |
CALL [DI].messageProc | |
; JMP SHORT NEIsle | |
JC SHORT NEIsle | |
@@: MOV AL,CS:[SI] | |
INC SI | |
MOV pageMax[BP],AL | |
; | |
; skip 15 * pageNum lines | |
; | |
MOV CH,pageNum[BP] | |
OR CH,CH | |
JZ SHORT show_page | |
skip_page: MOV CL,15 | |
skip_line: MOV AL,CS:[SI] | |
INC SI | |
CBW | |
ADD SI,AX | |
DEC CL | |
JNZ skip_line | |
DEC CH | |
JNZ skip_page | |
show_page: CALL ShowPage | |
NEIsle: JMP NextEvent | |
; | |
; exit SETUP | |
; | |
ExitSETUP: | |
; | |
; deallocate space from stack | |
; | |
ADD SP,globalSize | |
; | |
; get old cursor position and cursor type | |
; | |
POP DX | |
POP CX | |
MOV AH,1 ; Set Cursor Type | |
INT 10H | |
MOV BH,0 ; page number | |
MOV AH,2 ; Set Cursor Position | |
INT 10H | |
; | |
; CLS | |
; | |
MOV AX,3 | |
INT 10H | |
MOV AX,0040H | |
MOV DS,AX | |
AND BYTE PTR DS:[MFLAGS],11111110B | |
POP FS | |
POP ES | |
POP DS | |
POPA | |
IFDEF DOS | |
MOV AX,4C00H | |
INT 21H | |
ELSE | |
RET | |
ENDIF | |
ASSUME DS:BIOSCODE | |
; | |
; extended key | |
; | |
Extended: CMP AH,15 ; BACKTAB? | |
JNE SHORT @F | |
; | |
; back up a field | |
; | |
MOV DX,-SIZE OBJECT | |
JMP AdvField | |
; | |
; test for more extended keys | |
; | |
@@: CMP AH,77 ; right arrow | |
JE SHORT @F | |
CMP AH,75 ; left arrow | |
JNE SHORT BootCheck | |
@@: SUB AH,76 | |
; | |
MOV DI,theField[BP] | |
CALL [DI].messageProc | |
JMP NextEvent | |
BootCheck: CMP AH,48 ; ALT-B | |
JNE SHORT @F | |
IFDEF DOS | |
MOV AX,3 | |
INT 10H | |
JMP ExitSETUP | |
ELSE | |
; | |
; SETA20 | |
; | |
DB 0EAH ; far call | |
DW 0FF8AH | |
DW 0F000H | |
; | |
; SHUTDN | |
; | |
DB 0EAH ; far jmp | |
DW 0FF92H | |
DW 0F000H | |
ENDIF | |
@@: CMP AH,32 ; ALT-D | |
JNE SHORT @F | |
MOV DI,theField[BP] | |
MOV AH,2 ; force default value | |
CALL [DI].messageProc | |
JMP NextEvent | |
; | |
; check for PgUp and PgDn keys | |
; | |
@@: CMP AH,73 ; PgUp | |
JNE SHORT @F | |
DEC BYTE PTR pageNum[BP] | |
JNS show_help | |
INC BYTE PTR pageNum[BP] | |
JMP show_help | |
@@: CMP AH,81 ; PgDn | |
JNE SHORT @F | |
INC BYTE PTR pageNum[BP] | |
MOV AL,pageMax[BP] | |
CMP AL,pageNum[BP] | |
JNE show_help | |
DEC BYTE PTR pageNum[BP] | |
JMP show_help | |
@@: JMP NextEvent | |
;---------------------------------------------------------------------------- | |
; static text | |
; this stuff comes in pairs: cursor position, string | |
;---------------------------------------------------------------------------- | |
staticText DB 1,3 | |
STRING 'Time: : :' | |
DB 19,3 | |
STRING 'Date: ,' | |
DB 6,5 | |
STRING 'Floppy Drive A:' | |
DB 6,6 | |
STRING 'Floppy Drive B:' | |
DB 8,8 | |
STRING 'Hard Drive 0:' | |
DB 8,9 | |
STRING 'Hard Drive 1:' | |
DB 9,11 | |
STRING 'Base Memory:' | |
DB 5,12 | |
STRING 'Extended Memory:' | |
DB 6,13 | |
STRING 'BIOS Shadowing:' | |
DB 5,14 | |
STRING 'Video Shadowing:' | |
DB 10,16 | |
STRING '486 Cache:' | |
DB 1,17 | |
STRING 'Compatability Speed:' | |
DB 9,18 | |
STRING 'Serial Port:' | |
DB 7,19 | |
STRING 'Parallel Port:' | |
staticEnd EQU $ ; marks the end of the static text | |
Periodic PROC NEAR | |
; | |
; the first three objects, i.e. the time, need to be periodically updated | |
; because they are changing by themselves | |
; | |
LEA DI,Objects | |
MOV CX,3 | |
@@: MOV AH,0 | |
CALL [DI].messageProc | |
ADD DI,SIZE OBJECT | |
LOOP @B | |
RET | |
Periodic ENDP | |
;---------------------------------------------------------------------------- | |
; | |
; CS:SI points to list of strings | |
; DL index of string to retrieve | |
; | |
GetText PROC NEAR | |
PUSH AX | |
XOR AX,AX | |
CLD | |
@@: LODSB | |
CMP AL,0 | |
JNZ @B | |
DEC DL | |
JNS @B | |
PUSH CS | |
POP ES | |
POP AX | |
RET | |
GetText ENDP | |
; | |
;---------------------------------------------------------------------------- | |
FloppyA PROC NEAR | |
PUSHA | |
MOV AL,CMFDSK | |
MOV CH,4 ; bit field width | |
MOV CL,4 ; starting bit number | |
MOV DH,5 ; limit value | |
MOV DL,4 ; default value | |
LEA SI,FloppyTexts | |
CALL SimpleObj | |
POPA | |
RET | |
FloppyA ENDP | |
FloppyB PROC NEAR | |
PUSHA | |
MOV AL,CMFDSK | |
MOV CH,4 ; bit field width | |
MOV CL,0 ; starting bit number | |
MOV DH,5 ; limit value | |
MOV DL,0 ; default value | |
LEA SI,FloppyTexts | |
CALL SimpleObj | |
POPA | |
RET | |
FloppyB ENDP | |
;---------------------------------------------------------------------------- | |
FloppyTexts DB 0 | |
STRING 'None' | |
DB 0 | |
STRING '5¬ inch, 360 KB' | |
DB 0 | |
STRING '5¬ inch, 1.2 MB' | |
DB 0 | |
STRING '3« inch, 720 KB' | |
DB 0 | |
STRING '3« inch, 1.44 MB' | |
;---------------------------------------------------------------------------- | |
; This is some trashy code that needs rewriting. | |
;---------------------------------------------------------------------------- | |
PUBLIC HardDisk0 | |
HardDisk0 PROC NEAR | |
PUSHA | |
PUSH DS | |
CMP AH,mHelp | |
JE HDHelp | |
; | |
; get the current hard disk type | |
; | |
MOV AL,12H ; hard disk type | |
CALL CMOSRead | |
SHR AL,4 | |
CMP AL,00001111B | |
JNE SHORT got_type | |
MOV AL,19H | |
CALL CMOSRead | |
; | |
; AL has current type | |
; | |
got_type: CMP AH,mSanity | |
JNE @F | |
MOV AH,0 | |
CMP AL,48 | |
JC @F | |
MOV AH,2 | |
@@: MOV DH,48 | |
ADD AL,AH | |
JNS SHORT @F | |
ADD AL,DH | |
@@: CMP AL,DH | |
JNE SHORT @F | |
SUB AL,DH | |
; | |
; AL has new type | |
; write it back to CMOS RAM | |
; | |
@@: CMP AH,2 | |
JNE SHORT @F | |
MOV AL,2 ; jam default | |
@@: MOV BL,AL ; save new type for display | |
MOV AH,AL | |
MOV AL,19H | |
CALL CMOSWrite | |
CMP AH,15 | |
JC SHORT @F | |
MOV AH,15 | |
@@: SHL AH,4 | |
MOV AL,12H | |
CALL CMOSWrite | |
; | |
; now display the result | |
; | |
@@: MOV DX,[DI].fieldPos | |
MOV CL,[DI].fieldWidth | |
MOV BH,newCursor+centerIt+specialAttr | |
CMP DI,theField[BP] | |
JNE SHORT @F | |
MOV BH,newCursor+centerIt+specialAttr+invertIt | |
@@: CMP BL,0 | |
JNE SHORT @F | |
; | |
; display "Not Installed" | |
; | |
CALL ShowThis | |
STRING 'Not Installed' | |
JMP HD0Exit | |
@@: CALL ShowThis | |
STRING ' Type ' | |
SHR CL,1 | |
ADD CL,2 | |
ADD DL,CL | |
MOV BH,0 | |
MOV AH,2 ; Set Cursor Position | |
INT 10H | |
XOR AX,AX | |
MOV AL,BL | |
MOV CL,10 | |
DIV CL | |
PUSH AX | |
OR AL,AL | |
JZ SHORT @F | |
ADD AL,90H | |
DAA | |
ADC AL,40H | |
DAA | |
MOV AH,0EH ; Teletype Output | |
INT 10H ; write the 1st digit | |
@@: POP AX | |
MOV AL,AH | |
ADD AL,40H | |
DAA | |
ADC AL,90H | |
DAA | |
MOV AH,0EH ; Teletype Output | |
INT 10H ; write the 2nd digit | |
JMP HD0Exit | |
; | |
; display hard disk help | |
; | |
;---------------------------------------------------------------------------- | |
; offsets into the hard disk parameter table entries | |
;---------------------------------------------------------------------------- | |
hdHeads EQU 2 | |
hdCyls EQU 0 | |
hdSecs EQU 14 | |
hdPreComp EQU 5 | |
hdLandZone EQU 12 | |
;---------------------------------------------------------------------------- | |
PUBLIC HDHelp | |
HDHelp: CMP BYTE PTR [BP].pageNum,2 | |
JC first_page | |
MOV CL,35 ; width of help window | |
MOV DX,022DH ; top left corner of help window | |
INC DH | |
MOV BH,newCursor+leftJust | |
CALL ShowThis | |
; | | | |
STRING 'Typ Hds Cyls Secs Pre LZ MB ' | |
INC DH | |
PUSH 0F000H | |
POP FS | |
XOR AX,AX | |
MOV AL,pageNum[BP] | |
; DEC AL | |
SUB AL,2 | |
MOV CX,12 | |
MUL CL | |
MOV DI,AX | |
SHL DI,4 | |
ADD DI,0E401H | |
INC AX | |
MOV SI,AX | |
ADD SI,CX | |
CMP SI,48 | |
JB SHORT @F | |
MOV SI,48 | |
@@: PUSH SI ; stopping point | |
INC DH | |
MOV DL,2DH | |
CALL ToDecimal | |
MOV BH,newCursor+rightJust | |
ADD DL,1 | |
MOV CL,2 | |
CALL ShowString | |
PUSH AX | |
MOV AL,FS:hdHeads[DI] | |
CALL ToDecimal | |
ADD DL,5 | |
MOV CL,2 | |
CALL ShowString | |
MOV AX,FS:hdCyls[DI] | |
CALL ToDecimal | |
ADD DL,4 | |
MOV CL,4 | |
CALL ShowString | |
XOR AX,AX | |
MOV AL,FS:hdSecs[DI] | |
CALL ToDecimal | |
ADD DL,8 | |
MOV CL,2 | |
CALL ShowString | |
MOV AX,FS:hdPreComp[DI] | |
CALL ToDecimal | |
ADD DL,2 | |
MOV CL,5 | |
OR AX,AX | |
JNS SHORT precomp | |
MOV BYTE PTR[SI],0 | |
precomp: CALL ShowString | |
MOV AX,FS:hdLandZone[DI] | |
CALL ToDecimal | |
ADD DL,5 | |
MOV CL,5 | |
CALL ShowString | |
PUSH DX | |
MOV AX,FS:hdSecs[DI] | |
MUL BYTE PTR FS:hdHeads[DI] | |
MUL WORD PTR FS:hdCyls[DI] | |
SHRD AX,DX,11 | |
POP DX | |
CALL ToDecimal | |
ADD DL,6 | |
MOV CL,4 | |
CALL ShowString | |
ADD DI,16 | |
POP AX | |
INC AX | |
POP SI | |
CMP AX,SI | |
JNE @B | |
STC | |
JMP SHORT HD0Exit | |
; | |
; display the first page of hard disk help | |
; | |
first_page: | |
POP DS | |
POPA | |
CLC | |
MOV SI,OFFSET HD0Help | |
RET | |
; CALL ShowPage | |
; | |
; MOV BYTE PTR pageMax[BP],5 | |
HD0Exit: POP DS | |
POPA | |
RET | |
HardDisk0 ENDP | |
;---------------------------------------------------------------------------- | |
HardDisk1 PROC NEAR | |
JMP HardDisk0 | |
HardDisk1 ENDP | |
;---------------------------------------------------------------------------- | |
Hour PROC NEAR | |
MOV SI,3 | |
JMP SHORT TimeHelper | |
Hour ENDP | |
;---------------------------------------------------------------------------- | |
Minute PROC NEAR | |
MOV SI,2 | |
JMP SHORT TimeHelper | |
Minute ENDP | |
;---------------------------------------------------------------------------- | |
Second PROC NEAR | |
MOV SI,1 | |
JMP SHORT TimeHelper | |
Second ENDP | |
;---------------------------------------------------------------------------- | |
; this routine is called by the Hour, Minute, and Second routines | |
;---------------------------------------------------------------------------- | |
; | |
; SI = 1 for Seconds, 2 for Minutes, 3 for Hours | |
; | |
PUBLIC TimeHelper | |
TimeHelper PROC NEAR | |
PUSHA | |
PUSH DS | |
@@: PUSH AX | |
MOV AH,2 | |
INT 1AH | |
POP AX | |
PUSH CX | |
PUSH DX | |
; | |
; determine limit value and store in BL | |
; | |
MOV BL,60H ; limit value for minutes, seconds | |
CMP SI,3 ; hours? | |
JNE SHORT @F ; jump if not | |
MOV BL,24H ; limit value for hours | |
; | |
; load the default value | |
; | |
@@: MOV BH,CS:DefaultTime[SI] | |
; | |
; get appropriate byte off stack | |
; | |
ADD SI,SP | |
MOV AL,SS:[SI] | |
CMP AH,0 | |
JNE @F | |
POP DX | |
POP CX | |
JMP show_time | |
; | |
@@: CMP AH,4 | |
JNE SHORT @F | |
; | |
; perform sanity check | |
; | |
MOV AH,0 | |
CMP AL,BL | |
JC SHORT @F | |
MOV AH,2 | |
@@: CMP AH,2 | |
JNE @F | |
MOV AL,BH | |
; | |
; calculate new value | |
; | |
@@: AND AH,99H ; maps $FF -> $99, $01 -> $01, $00 -> $00 | |
ADD AL,AH | |
DAA ; we steady be doin BCD arithmetic | |
JNS SHORT @F ; jump if no wrap | |
ADD AL,BL ; wrapped, add limit value | |
DAA ; mo BCD | |
@@: CMP AL,BL ; check for wrap at the high end | |
JNE SHORT put_time ; jump if no wrap | |
MOV AL,0 | |
put_time: MOV SS:[SI],AL ; put value back on stack | |
MOV BL,AL ; save AL from INT 1A | |
POP DX ; get the time back | |
POP CX ; in CX, DX | |
MOV AH,3 | |
INT 1AH ; store it back in CMOS | |
@@: MOV AL,BL ; recover the new value | |
show_time: CALL ShowNum | |
POP DS | |
POPA | |
RET | |
TimeHelper ENDP | |
DefaultTime DB 0,0,30H,09H | |
;---------------------------------------------------------------------------- | |
; Display the day of the week. | |
;---------------------------------------------------------------------------- | |
PUBLIC ShowDay | |
ShowDay PROC NEAR | |
CALL DayOfWeek | |
PUSH DS | |
PUSH CS | |
POP DS | |
MOV BX,AX | |
ADD BX,BX | |
ADD BX,BX | |
LEA SI,DayNames[BX] | |
MOV DX,0319H | |
MOV BH,newCursor | |
CALL ShowString | |
POP DS | |
RET | |
DayNames DB 3,'Sat',3,'Sun',3,'Mon',3,'Tue',3,'Wed',3,'Thu',3,'Fri' | |
ShowDay ENDP | |
;---------------------------------------------------------------------------- | |
PUBLIC DayOfWeek | |
DayOfWeek PROC NEAR | |
MOV AH,4 | |
INT 1AH | |
; | |
; CH = century in BCD (19 or 20) | |
; CL = year in BCD | |
; DH = month in BCD | |
; DL = day in BCD | |
; | |
MOV AL,CL | |
DB 0D4H,16 ; AAM 16 | |
AAD | |
MOV CL,12 | |
DIV CL ; AL = Y / 12, AH = Y % 12 | |
ADD AL,AH | |
MOV CL,AH | |
SHR AH,2 | |
AND CL,3 | |
JNZ @F | |
; | |
; leaper | |
; | |
CMP DH,3 | |
SBB AL,0 | |
@@: ADD AL,AH | |
XCHG AL,DH | |
DB 0D4H,16 | |
AAD | |
CBW | |
XCHG AX,BX | |
ADD DH,CS:Key[BX] | |
MOV AL,DL | |
DB 0D4H,16 | |
AAD | |
ADD AL,DH | |
; | |
; Note about the next instruction: don't use CBW! | |
; | |
MOV AH,0 | |
MOV CL,7 | |
DIV CL | |
; CMP CH,20H | |
; SBB AH,1 | |
MOV AL,AH | |
CBW | |
RET | |
Key DB 0,1,4,4,0,2,5,0,3,6,1,4,6 | |
DayOfWeek ENDP | |
;---------------------------------------------------------------------------- | |
; | |
; This routine displays the value in AL in the object's (DI) field. | |
; | |
ShowNum PROC NEAR | |
; | |
; | |
MOV DX,fieldPos[DI] ; cursor position for this field | |
MOV CL,fieldWidth[DI] ; field width | |
MOV BH,newCursor+centerIt+specialAttr | |
CALL ConvertNum | |
CMP DI,theField[BP] | |
JNE SHORT @F | |
MOV BH,newCursor+centerIt+specialAttr+invertIt | |
@@: CALL ShowString | |
RET | |
ShowNum ENDP | |
;---------------------------------------------------------------------------- | |
Month PROC NEAR | |
PUSHA | |
; | |
; get the date in CX, DX | |
; | |
PUSH AX | |
MOV AH,4 ; INT 1A Get Date | |
INT 1AH | |
POP AX | |
; | |
MOV AL,2 ; default month | |
CMP AH,2 | |
JE SHORT PutMonth | |
MOV AL,DH ; get the month (BCD) | |
; | |
; convert to binary | |
; | |
CMP AL,10H | |
JB SHORT @F | |
SUB AL,6 | |
@@: DEC AL ; normalize to 0..11 | |
CMP AH,mSanity | |
JNE @F | |
MOV AH,0 | |
CMP AL,12 | |
JC @F | |
MOV AL,2 | |
JMP SHORT PutMonth | |
@@: ADD AL,AH ; compute new month | |
JNS SHORT @F ; jump if not too low | |
MOV AL,11 ; wrap to Dec | |
@@: CMP AL,12 ; check high end of range | |
JNE SHORT PutMonth ; jump if not too high | |
MOV AL,0 ; wrap to Jan | |
; | |
; put the newly computed month back in CMOS | |
; | |
PutMonth: MOV DH,AL | |
INC DH ; back to 1..12 | |
; | |
; convert to BCD | |
; | |
CMP DH,10 | |
JB SHORT @F | |
ADD DH,6 | |
@@: MOV BL,AL | |
MOV AH,5 ; INT 1A Set Date | |
INT 1AH | |
MOV AL,BL | |
; | |
; display the month | |
; | |
XOR AH,AH | |
ADD AX,AX | |
ADD AX,AX | |
ADD AX,OFFSET monthNames | |
MOV SI,AX | |
MOV DX,fieldPos[DI] ; cursor position for this field | |
MOV CL,fieldWidth[DI] ; field width | |
MOV BH,newCursor+centerIt+specialAttr | |
CMP DI,theField[BP] | |
JNE SHORT @F | |
MOV BH,newCursor+centerIt+specialAttr+invertIt | |
@@: CALL ShowString | |
CALL ShowDay | |
POPA | |
RET | |
Month ENDP | |
monthNames DB 3,'Jan',3,'Feb',3,'Mar',3,'Apr',3,'May',3,'Jun' | |
DB 3,'Jul',3,'Aug',3,'Sep',3,'Oct',3,'Nov',3,'Dec' | |
PUBLIC Day | |
Day PROC NEAR | |
PUSHA | |
PUSH DS | |
; | |
; get day and year in CX, DX | |
; | |
PUSH AX | |
MOV AH,4 | |
INT 1AH | |
POP AX | |
; | |
MOV AL,19H ; default day | |
CMP AH,2 | |
JE SHORT PutDay | |
MOV AL,DL ; get day of month | |
; | |
; get number of days in month in BL | |
; | |
CALL MonthDays | |
CMP AL,BL | |
JBE @F | |
MOV AL,19H | |
JMP SHORT PutDay | |
@@: AND AH,99H ; convert AH to BCD | |
ADD AL,AH ; compute new value | |
DAA | |
JNE SHORT @F ; cycle at zero | |
MOV AL,BL | |
@@: CMP AL,BL | |
JBE SHORT PutDay ; jump if in range | |
MOV AL,01H ; cycle around to the 1st | |
; | |
; put the new day back in CMOS | |
; | |
PutDay: MOV DL,AL | |
MOV AH,5 | |
INT 1AH | |
MOV AL,DL | |
CALL ShowNum | |
CALL ShowDay | |
POP DS | |
POPA | |
RET | |
Day ENDP | |
;---------------------------------------------------------------------------- | |
PUBLIC Year | |
Year PROC NEAR | |
PUSHA | |
; | |
; call INT 1A, function 4 Get Date and Year | |
; returns CH = century, CL = year (both in BCD) | |
; | |
PUSH AX | |
MOV AH,4 | |
INT 1AH | |
MOV AL,CL | |
BIN | |
MOV CL,AL | |
MOV AL,CH | |
BIN | |
MOV CH,AL | |
POP AX | |
CMP AH,2 | |
JE def_year | |
CMP AH,mSanity | |
JNE no_sanity | |
MOV AH,0 | |
CMP CH,19 | |
JB def_year | |
CMP CH,20 | |
JBE check_year | |
def_year: MOV CX,19*256+61 | |
MOV AH,0 | |
check_year: CMP CL,100 | |
JNB def_year | |
no_sanity: ADD CL,AH | |
JS SHORT @F | |
CMP CL,100 | |
JB store_year | |
MOV CL,0 | |
JMP SHORT tog_cent | |
@@: MOV CL,99 | |
tog_cent: XOR CH,00000111B | |
store_year: MOV AL,CH | |
BCD | |
MOV CH,AL | |
MOV AL,CL | |
BCD | |
MOV CL,AL | |
MOV AH,5 | |
INT 1AH | |
; | |
; display the year | |
; | |
disp_year: PUSH CX | |
MOV CL,[DI].fieldWidth | |
MOV DX,[DI].fieldPos | |
MOV BH,newCursor+centerIt+specialAttr | |
CMP DI,theField[BP] | |
JNE SHORT @F | |
MOV BH,newCursor+centerIt+specialAttr+invertIt | |
@@: CALL ShowThis | |
STRING ' ' | |
MOV DX,[DI].fieldPos | |
MOV BH,0 | |
MOV AH,2 ; Set Cursor Position | |
INT 10H | |
POP CX | |
MOV AL,CH ; century | |
SHR AL,4 | |
ADD AL,'0' | |
MOV AH,0EH | |
INT 10H | |
MOV AL,CH | |
AND AL,00001111B | |
ADD AL,'0' | |
MOV AH,0EH | |
INT 10H | |
MOV AL,CL | |
SHR AL,4 | |
ADD AL,'0' | |
MOV AH,0EH | |
INT 10H | |
MOV AL,CL | |
AND AL,00001111B | |
ADD AL,'0' | |
MOV AH,0EH | |
INT 10H | |
CALL ShowDay | |
POPA | |
RET | |
Year ENDP | |
;---------------------------------------------------------------------------- | |
; This routine returns the number of days in the given month for the year. | |
; | |
; >: CX, DX = month and year as returned by INT 1A | |
; <: BX = number of days in the month (in BCD) | |
;---------------------------------------------------------------------------- | |
PUBLIC MonthDays | |
MonthDays PROC NEAR | |
PUSH AX | |
XOR BX,BX | |
MOV AL,DH | |
; CALL BCDBinary | |
BIN | |
MOV BL,AL | |
DEC BX | |
MOV BL,CS:DayTable[BX] | |
CMP BL,28H | |
JNZ @F | |
MOV AL,CL | |
DB 0D4H,16 | |
AAD | |
AND AL,00000011B | |
CMP AL,1 | |
ADC BL,0 | |
@@: POP AX | |
RET | |
DayTable DB 31H,28H,31H,30H,31H,30H,31H,31H,30H,31H,30H,31H | |
MonthDays ENDP | |
;---------------------------------------------------------------------------- | |
; BCD to Binary | |
; | |
; >: AL = BCD number | |
; <: AL = binary | |
;---------------------------------------------------------------------------- | |
BCDBinary PROC NEAR | |
DB 0D4H,16 ; AAM 16 | |
AAD | |
RET | |
BCDBinary ENDP | |
;---------------------------------------------------------------------------- | |
;---------------------------------------------------------------------------- | |
PUBLIC BaseMem | |
BaseMem PROC NEAR | |
PUSHA | |
MOV AL,0 | |
MOV CH,2 ; bit field width | |
MOV CL,0 ; starting bit number | |
MOV DH,3 ; limit value | |
MOV DL,0 ; default value | |
LEA SI,BMTexts | |
MOV BX,OFFSET BMMapper | |
CALL SimpleObj | |
POPA | |
RET | |
BMMapper: OR AL,AL | |
JS BMWrite | |
PUSH BX | |
MOV AL,CMBMH | |
CALL CMOSRead | |
MOV BL,AL | |
MOV AL,CMBML | |
CALL CMOSRead | |
ROL AL,2 | |
ADD AL,BL | |
AND AL,00000011B | |
POP BX | |
RET | |
BMWrite: PUSH AX | |
SUB AX,80H | |
JNZ @F | |
MOV AX,280H | |
@@: PUSH AX | |
MOV AL,CMBMH | |
CALL CMOSWrite | |
POP AX | |
MOV AH,AL | |
MOV AL,CMBML | |
CALL CMOSWrite | |
POP AX | |
RET | |
BMTexts DB 0 | |
STRING '640K' | |
DB 0 | |
STRING '256K' | |
DB 0 | |
STRING '512K' | |
BaseMem ENDP | |
;---------------------------------------------------------------------------- | |
; bit 3 of $1F | |
;---------------------------------------------------------------------------- | |
BIOSShadow PROC NEAR | |
PUSHA | |
MOV AL,1FH ; CMOS index | |
MOV CH,1 ; bit field width | |
MOV CL,3 ; starting bit | |
MOV DH,2 ; state count | |
MOV DL,0 ; default | |
LEA SI,OnOffTexts | |
CALL SimpleObj | |
POPA | |
RET | |
BIOSShadow ENDP | |
;---------------------------------------------------------------------------- | |
; bit 4 of $1F | |
;---------------------------------------------------------------------------- | |
VideoShadow PROC NEAR | |
PUSHA | |
MOV AL,1FH ; CMOS index | |
MOV CH,1 ; bit field width | |
MOV CL,4 ; starting bit | |
MOV DH,2 ; state count | |
MOV DL,0 ; default | |
LEA SI,OnOffTexts | |
CALL SimpleObj | |
POPA | |
RET | |
VideoShadow ENDP | |
Cache486 PROC NEAR | |
PUSHA | |
MOV AL,34H ; CMOS index | |
MOV CH,1 ; bit field width | |
MOV CL,5 ; starting bit | |
MOV DH,2 ; state count | |
MOV DL,0 ; default | |
LEA SI,OnOffTexts | |
CALL SimpleObj | |
POPA | |
RET | |
Cache486 ENDP | |
CompatSpeed PROC NEAR | |
PUSHA | |
MOV AL,1FH ; CMOS index | |
MOV CH,2 ; bit field width | |
MOV CL,1 ; starting bit | |
MOV DH,3 ; state count | |
MOV DL,0 ; default | |
LEA SI,SpeedTexts | |
CALL SimpleObj | |
POPA | |
RET | |
SpeedTexts DB 0 | |
STRING '4.77 MHz' | |
DB 0 | |
STRING '8 MHz' | |
DB 0 | |
STRING '33 MHz' | |
CompatSpeed ENDP | |
;---------------------------------------------------------------------------- | |
; the next four objects, Serial, Parallel, Coprocessor, and Modem, can | |
; all either be off or on and share the following text | |
;---------------------------------------------------------------------------- | |
OnOffTexts DB 0 | |
STRING 'Off' | |
DB 0 | |
STRING 'On' | |
;---------------------------------------------------------------------------- | |
Serial PROC NEAR | |
PUSHA | |
MOV AL,34H ; CMOS index | |
MOV CL,1 ; start bit | |
MOV CH,1 ; width of bit field | |
MOV DL,1 ; default value | |
MOV DH,2 ; number of settings | |
LEA SI,OnOffTexts | |
CALL SimpleObj | |
POPA | |
RET | |
Serial ENDP | |
;---------------------------------------------------------------------------- | |
Parallel PROC NEAR | |
PUSHA | |
MOV AL,34H ; CMOS index | |
MOV CL,2 ; start bit | |
MOV CH,1 ; width of bit field | |
MOV DL,1 ; default value | |
MOV DH,2 ; number of settings | |
LEA SI,OnOffTexts | |
CALL SimpleObj | |
POPA | |
RET | |
Parallel ENDP | |
;---------------------------------------------------------------------------- | |
;---------------------------------------------------------------------------- | |
; this routine is used by those objects which | |
; | |
; 1. have static help | |
; 2. have a simple list of choices, 0..n, in some bitfield of a CMOS | |
; RAM location | |
; | |
; >: AH = message code | |
; AL = CMOS index | |
; CL = start bit of field | |
; CH = length of bit field (1..8) | |
; DH = field limit value | |
; DL = default value | |
; SI = text pointer | |
; BX = routine to call if AL = 0 | |
; | |
;---------------------------------------------------------------------------- | |
PUBLIC SimpleObj | |
SimpleObj PROC NEAR | |
PUSH SI | |
MOV SI,BX | |
MOV BL,AL ; make a copy of CMOS index | |
OR AL,AL | |
JZ @F | |
MOV SI,OFFSET CMOSRW | |
@@: CALL SI ; read the old value | |
SHR AL,CL ; right justify bit field | |
XOR BH,BH | |
XCHG CH,CL | |
MOV BH,00000001B | |
SHL BH,CL | |
DEC BH ; BH = bit field mask | |
AND AL,BH ; AL = normalized old value | |
CMP AH,4 ; perform sanity check? | |
JNE SHORT @F ; nah | |
MOV AH,0 | |
CMP AL,DH ; supposed to be less than this | |
JC SHORT @F ; jump if sane | |
MOV AH,2 ; change message to "set default" | |
@@: ADD AL,AH ; calculate new value | |
JNS SHORT @F | |
ADD AL,DH ; add limit value | |
@@: CMP AL,DH | |
JNE SHORT @F ; jump if in range | |
SUB AL,DH ; subtract limit, i.e. AL = 0 | |
@@: CMP AH,2 | |
JE SHORT @F ; jump if default requested | |
MOV DL,AL | |
; | |
; slide the bit field back in place and put it back in CMOS | |
; | |
@@: XCHG CH,CL ; start bit in CL | |
MOV AH,DL ; get value to be stored | |
SHL AH,CL ; shlide it back into position | |
SHL BH,CL ; shlide the mask over as well | |
NOT BH | |
MOV AL,BL ; get saved CMOS index | |
CALL SI ; get the old value | |
AND AL,BH ; mask off our bitfield | |
OR AH,AL ; insert our bitfield | |
MOV AL,BL ; get CMOS index once again | |
OR AL,10000000B ; set write bit | |
CALL SI | |
POP SI | |
CALL GetText | |
MOV DX,[DI].fieldPos | |
MOV CL,[DI].fieldWidth | |
MOV BH,newCursor+centerIt+specialAttr | |
CMP DI,theField[BP] | |
JNE SHORT @F | |
MOV BH,newCursor+centerIt+specialAttr+invertIt | |
@@: CALL ShowString | |
RET | |
SimpleObj ENDP | |
CMOSRW PROC NEAR | |
OR AL,AL | |
JNS CMOSRead | |
AND AL,01111111B | |
JMP CMOSWrite | |
CMOSRW ENDP | |
; | |
; AL = packed BCD | |
; | |
; DS:SI = numberBuf[BP] = AL converted to ASCII | |
; | |
ConvertNum PROC NEAR | |
MOV BYTE PTR numberBuf[BP],2 | |
DB 0D4H,10H | |
ADD AX,3030H | |
XCHG AL,AH | |
MOV WORD PTR numberBuf[BP+1],AX | |
LEA SI,numberBuf[BP] | |
PUSH SS | |
POP DS | |
RET | |
ConvertNum ENDP | |
;---------------------------------------------------------------------------- | |
SETUP ENDP | |
;---------------------------------------------------------------------------- | |
; | |
; DS:SI = string | |
; BH = attributes | |
; BL = text attribute (if custom attribute selected) | |
; CL = field width (if applicable) | |
; DH,DL = cursor position (if applicable) | |
; | |
; >: SI = just past string | |
; all others unharmed | |
; | |
PUBLIC ShowString | |
ShowString PROC NEAR | |
PUSH ES | |
PUSHA | |
TEST BH,newCursor | |
JZ SHORT @F ; jump if caller wants old cursor | |
PUSH BX | |
MOV BH,0 | |
MOV AH,2 ; INT 10 Set Cursor Position | |
INT 10H | |
POP BX | |
; | |
; determine character attribute | |
; | |
@@: TEST BH,customAttr | |
JNZ SHORT just_do_it ; jump if caller wants custom attribute | |
; | |
; get text attribute in BL | |
; | |
XCHG BH,BL ; save BH from Return Video Status call | |
MOV AH,0FH ; $0F = Return Video Status | |
INT 10H ; returns video mode in AL | |
XCHG BH,BL ; restore BH | |
AND AL,4 ; 3 -> 0, 7 -> 4. | |
CBW ; AX = 0 or 4 | |
MOV DI,AX | |
; | |
; new code for LCD | |
; | |
PUSH DS | |
MOV AX,40H | |
MOV DS,AX | |
TEST BYTE PTR DS:[0E4H],00000100B | |
POP DS | |
JZ @F | |
ADD DI,8 | |
; | |
; end of new code | |
; | |
@@: TEST BH,specialAttr | |
JZ SHORT @F ; jump if they don't want special | |
ADD DI,2 ; skip to special attr part of table | |
@@: TEST BH,invertIt | |
JZ SHORT @F ; jump if they don't want invert | |
INC DI ; skip to invert attr part of table | |
@@: MOV BL,CS:attrTable[DI] ; load the attribute | |
; | |
; deal with justification | |
; | |
just_do_it: MOV AL,BH | |
AND AL,justBits | |
JNZ SHORT @F ; jump if justification requested | |
; | |
; accomplish no justification by pretending requested field width | |
; is equal to the number of bytes in the string | |
; | |
MOV CL,[SI] | |
; | |
; CL has field width | |
; | |
@@: SUB CL,[SI] ; get number of pad chars | |
XOR CH,CH | |
CMP AL,rightJust | |
JE SHORT @F ; jump if only right justification | |
XCHG CH,CL ; give all the pads chars to the left | |
CMP AL,leftJust | |
JE SHORT @F ; jump if only left justification | |
; | |
; both left & right justification requested so center the string | |
; split the pad chars evenly between the left and right sides | |
; | |
SHR CH,1 ; split the pad chars between left | |
MOV CL,CH ; and right sides | |
ADC CH,0 ; give odd char to right side | |
; | |
; at this point CL,CH = number of left, right pad chars | |
; | |
@@: MOV DI,CX ; save CX | |
; | |
; write out the left pad chars | |
; | |
CALL WriteBlanks | |
; | |
; write out the string | |
; DX has correct cursor position from WriteBlanks call | |
; | |
@@: XOR CX,CX | |
MOV CL,[SI] | |
PUSH BX | |
MOV BH,CH ; page number (= 0) | |
MOV AH,13H ; Display String | |
MOV AL,1 | |
LEA BP,[SI+1] | |
PUSH DS | |
POP ES | |
INT 10H | |
POP BX | |
; | |
; write out the right pad chars | |
; | |
MOV CX,DI | |
XCHG CH,CL | |
CALL WriteBlanks | |
XOR AX,AX | |
LODSB | |
ADD SI,AX | |
; | |
; I want restore all registers except SI, so I am cramming the new SI | |
; on the stack where the old SI was. | |
; | |
MOV BP,SP ; can't index off of SP | |
MOV [BP+2],SI ; old SI is one deep on stack | |
POPA | |
POP ES | |
RET | |
; [ color ] [ mono ] [ LCD ] | |
attrTable DB 03H,30H,02H,3FH,07H,70H,0FH,7FH,0AH,61H,0FH,60H | |
ShowString ENDP | |
;---------------------------------------------------------------------------- | |
ShowThis PROC NEAR | |
POP SI | |
PUSH DS | |
PUSH CS | |
POP DS | |
CALL ShowString | |
POP DS | |
JMP SI | |
ShowThis ENDP | |
; | |
; CL = number of blanks to write | |
; BL = char attribute | |
; | |
; AX trashed | |
; DX new cursor position | |
; BX unchanged | |
; CX unchanged | |
; | |
PUBLIC WriteBlanks | |
WriteBlanks PROC NEAR | |
PUSH BX ; save attributes (BH) | |
PUSH CX ; save right pad count (CH) | |
MOV AL,' ' | |
XOR CH,CH | |
MOV BH,0 | |
; | |
; special check for 0 characters | |
; this was put in because PCKSCRN writes 64K chars when CX = 0 | |
; | |
JCXZ @F | |
MOV AH,9 ; INT 10 Write Character and Attribute | |
INT 10H | |
; | |
; move the cursor | |
; | |
@@: MOV AH,3 ; INT 10 Read Cursor Position | |
INT 10H | |
POP CX ; get back pad count waxed by Read Cursor | |
ADD DL,CL ; move the cursor that many columns | |
MOV AH,2 ; INT 10 Set Cursor Position | |
INT 10H | |
POP BX | |
RET | |
WriteBlanks ENDP | |
WriteChar PROC NEAR | |
MOV BH,0 | |
MOV CX,1 | |
MOV AH,0AH | |
INT 10H ; Write Character Only | |
RET | |
WriteChar ENDP | |
CMOSRead PROC NEAR | |
OUT 70H,AL | |
IOWAIT | |
IN AL,71H | |
RET | |
CMOSRead ENDP | |
CMOSWrite PROC NEAR | |
PUSH AX | |
PUSH BX | |
OUT 70H,AL | |
IOWAIT | |
XCHG AL,AH | |
OUT 71H,AL | |
; | |
; if writing the checksum byte, don't perform checksumming | |
; | |
CMP AH,5FH | |
JE SHORT CWExit | |
; | |
; checksum the extended CMOS | |
; write the checksum at index $5F | |
; | |
MOV BX,5F40H ; checksum 40-5F (not inclusive) | |
CALL CMOSCheck | |
MOV AL,BH | |
CALL CMOSWrite | |
IFNDEF DOS | |
; CALL cmsum | |
ENDIF | |
CWExit: POP BX | |
POP AX | |
RET | |
CMOSWrite ENDP | |
;---------------------------------------------------------------------------- | |
; checksum a range of CMOS RAM | |
; >: BL = first CMOS index to sum | |
; BH = first CMOS index not to sum | |
; <: AH = checksum | |
;---------------------------------------------------------------------------- | |
CMOSCheck PROC NEAR | |
; | |
; AH = running sum | |
; BL = running index | |
; BH = index limit | |
; | |
XOR AX,AX | |
@@: MOV AL,BL | |
CALL CMOSRead | |
ADD AH,AL | |
INC BL | |
CMP BL,BH | |
JNE @B | |
RET | |
CMOSCheck ENDP | |
;---------------------------------------------------------------------------- | |
; >: AX, value to be converted to decimal | |
; puts result in numberBuf[BP] | |
; <: DS:SI points to result | |
; | |
;---------------------------------------------------------------------------- | |
ToDecimal PROC NEAR | |
PUSH AX | |
PUSH BX | |
PUSH DX | |
PUSH DI | |
PUSH ES | |
MOV BX,10 | |
MOV DX,SS | |
MOV DS,DX | |
MOV ES,DX | |
LEA DI,numberBuf[BP] | |
MOV SI,DI | |
MOV [DI],BH ; initialize result length to zero | |
INC DI | |
CALL @F | |
POP ES | |
POP DI | |
POP DX | |
POP BX | |
POP AX | |
RET | |
@@: XOR DX,DX | |
DIV BX ; AX = quotient, DX = remainder | |
OR AX,AX | |
JZ SHORT @F | |
PUSH DX | |
CALL @B | |
POP DX | |
@@: MOV AL,DL | |
ADD AL,'0' | |
STOSB | |
INC BYTE PTR [SI] | |
RET | |
ToDecimal ENDP | |
;---------------------------------------------------------------------------- | |
; ClearHelp | |
; Clears the help window | |
;---------------------------------------------------------------------------- | |
ClearHelp PROC NEAR | |
PUSHA | |
MOV AX,0600H | |
MOV BH,7 | |
MOV CX,022DH | |
MOV DX,104FH | |
INT 10H | |
POPA | |
RET | |
ClearHelp ENDP | |
;---------------------------------------------------------------------------- | |
; ShowPage | |
; This routine displays a "page" of text in the help window. It is used | |
; by objects whose help text is static. | |
; | |
; >: CS:SI pointer to page of text | |
; there should be exactly 15 lines, each in STRING format | |
; <: none | |
; | |
;---------------------------------------------------------------------------- | |
ShowPage PROC NEAR | |
PUSHA | |
MOV AX,CS | |
MOV ES,AX | |
MOV CL,35 ; width of help window | |
MOV DX,022EH ; top left corner of help window | |
@@: MOV BH,newCursor+leftJust | |
CALL ShowString | |
INC DH ; go to next line | |
CMP DH,11H | |
JNE @B | |
POPA | |
RET | |
ShowPage ENDP | |
;---------------------------------------------------------------------------- | |
; Help for objects with static help text. | |
;---------------------------------------------------------------------------- | |
; | |
; Each line ends with a NUL. Each page should be 15 lines. | |
; | |
; | | | |
; | |
; | |
HourHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the time in' | |
STRING '24-hour format (hours:minutes:' | |
STRING 'seconds) for your System 316LT' | |
STRING 'computer''s built-in clock.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow key to increase' | |
STRING 'the value of each field (hours,' | |
STRING 'minutes, seconds) in the Time' | |
STRING 'category.' | |
DB 0,0,0,0 | |
MinuteHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the time in' | |
STRING '24-hour format (hours:minutes:' | |
STRING 'seconds) for your System 316LT' | |
STRING 'computer''s built-in clock.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow to increase' | |
STRING 'the value of each field (hours,' | |
STRING 'minutes, seconds) in the Time' | |
STRING 'category.' | |
DB 0,0,0,0 | |
SecondHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the time in' | |
STRING '24-hour format (hours:minutes:' | |
STRING 'seconds) for your System 316LT' | |
STRING 'computer''s built-in clock.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow to increase' | |
STRING 'the value of each field (hours,' | |
STRING 'minutes, seconds) in the Time' | |
STRING 'category.' | |
DB 0,0,0,0 | |
MonthHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the date for' | |
STRING 'your 316LT computer''s built-in' | |
STRING 'calendar. The day of the week' | |
STRING 'is linked with the month, day,' | |
STRING 'and year fields. If you change' | |
STRING 'one of these fields, the day of' | |
STRING 'the week is updated as well.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow key to increase' | |
STRING 'each field (month, day, year) in' | |
STRING 'the Date category.' | |
DB 0,0 | |
DayHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the date for' | |
STRING 'your 316LT computer''s built-in' | |
STRING 'calendar. The day of the week' | |
STRING 'is linked with the month, day,' | |
STRING 'and year fields. If you change' | |
STRING 'one of these fields, the day of' | |
STRING 'the week is updated as well.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow key to increase' | |
STRING 'each field (month, day, year) in' | |
STRING 'the Date category.' | |
DB 0,0 | |
YearHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the date for' | |
STRING 'your 316LT computer''s built-in' | |
STRING 'calendar. The day of the week' | |
STRING 'is linked with the month, day,' | |
STRING 'and year fields. If you change' | |
STRING 'one of these fields, the day of' | |
STRING 'the week is updated as well.' | |
DB 0 | |
STRING 'Use the left-arrow key to decrease' | |
STRING 'or the right-arrow key to increase' | |
STRING 'each field (month, day, year) in' | |
STRING 'the Date category.' | |
DB 0,0 | |
IntHelp: DB 1 | |
DB 0 | |
STRING 'This category indicates the type' | |
STRING 'of diskette drive you have' | |
STRING 'installed inside your System' | |
STRING '316LT.' | |
DB 0 | |
STRING 'All System 316LT computers contain' | |
STRING 'a 3«-inch, 1.44-MB diskette drive.' | |
DB 0 | |
STRING 'Change the setting only if you' | |
STRING 'change the type of drive' | |
STRING 'installed.' | |
DB 0,0,0 | |
ExtHelp: DB 1 | |
DB 0 | |
STRING 'This category indicates the type' | |
STRING 'of external drive connected to' | |
STRING 'your System 316LT.' | |
DB 0 | |
STRING 'If there is no external diskette' | |
STRING 'drive connected to your computer,' | |
STRING 'this category must be designated' | |
STRING 'as "None."' | |
DB 0,0,0,0,0,0 | |
HD0Help: DB 6 | |
DB 0 | |
STRING 'This category indicates the type' | |
STRING 'of hard-disk drive installed' | |
STRING 'inside your System 316LT.' | |
DB 0 | |
STRING 'System 316LT computers usually' | |
STRING 'contain one of the following:' | |
DB 0 | |
STRING ' 20-MB hard-disk drive (Type 2)' | |
STRING ' 40-MB hard-disk drive (Type 17)' | |
DB 0,0,0 | |
STRING 'Press <PgDn> for more information.' | |
DB 0 | |
DB 0 | |
STRING 'If you have a different hard-disk' | |
STRING 'drive, press <PgDn> to find the' | |
STRING 'correct drive-type number. See' | |
STRING 'the hard-disk drive specifications' | |
STRING 'to determine the drive-type' | |
STRING 'number.' | |
DB 0,0,0,0,0,0,0,0 | |
MemHelp: DB 1 | |
DB 0 | |
STRING 'This category determines whether' | |
STRING 'memory above 1 MB in your System' | |
STRING '316LT is used for extended or' | |
STRING 'expanded memory.' | |
DB 0 | |
STRING 'To use expanded memory with MS-DOS' | |
STRING 'applications that support it, you' | |
STRING 'must install the EMM.SYS driver in' | |
STRING 'your CONFIG.SYS file. See your' | |
STRING 'user''s manual for more infor-' | |
STRING 'mation.' | |
DB 0,0,0 | |
ShadHelp: DB 1 | |
DB 0 | |
STRING 'This category directs the System' | |
STRING '316LT to copy the system BIOS and' | |
STRING 'the VGA BIOS from ROM to RAM so' | |
STRING 'these instructions can execute' | |
STRING 'faster.' | |
DB 0 | |
STRING 'If you choose "None" or "VGA at' | |
STRING '$E000," 256 KB of the first mega-' | |
STRING 'byte of memory are available for' | |
STRING 'use as extended or expanded' | |
STRING 'memory.' | |
DB 0,0,0 | |
SleepHelp: DB 1 ; page count | |
DB 0 | |
STRING 'This category determines how soon' | |
STRING 'the System 316LT enters a Sleep' | |
STRING 'mode when the computer is running' | |
STRING 'but not being used. The category' | |
STRING 'allows you to conserve power when' | |
STRING 'the computer is running off the' | |
STRING 'battery pack.' | |
DB 0 | |
STRING 'In Sleep mode, the computer''s' | |
STRING 'display backlight is off and the' | |
STRING 'computer runs at 8 MHz. To end' | |
STRING 'Sleep mode, press any key on the' | |
STRING 'keyboard.' | |
DB 0 | |
; | | | |
HDTimeHelp: DB 1 | |
DB 0 | |
STRING 'This category specifies how soon' | |
STRING 'the hard-disk drive''s motor' | |
STRING 'spins down when it is not being' | |
STRING 'used.' | |
DB 0 | |
STRING 'The category allows you to con-' | |
STRING 'serve power when the computer is' | |
STRING 'running off the battery pack.' | |
DB 0 | |
STRING 'All the computer''s functions re-' | |
STRING 'main operative during a hard-disk' | |
STRING 'drive time out. The motor spins' | |
STRING 'back up the next time the hard-' | |
STRING 'disk drive is accessed.' | |
KludgeHelp: DB 1 | |
DB 0 | |
STRING 'This category enables and disables' | |
STRING 'the <CTRL>+<ALT>+<F12> key combin-' | |
STRING 'ation that enhances video contrast' | |
STRING 'while running under MS-DOS. The' | |
STRING 'category allows you to conserve' | |
STRING 'power when the computer is running' | |
STRING 'off the battery pack.' | |
DB 0 | |
STRING 'See your user''s manual for infor-' | |
STRING 'mation on this key combination.' | |
DB 0,0,0,0 | |
SBKeyHelp: DB 1 | |
DB 0 | |
STRING 'This category enables or disables' | |
STRING 'the Standby button on the key-' | |
STRING 'board panel. Pushing the Standby' | |
STRING 'button while it is enabled will' | |
STRING 'cause the computer''s display' | |
STRING 'backlight and hard-disk drive to' | |
STRING 'turn off, and the CPU to slow' | |
STRING 'down to 8 MHz.' | |
DB 0,0,0,0,0,0 | |
SerialHelp: DB 1 | |
DB 0 | |
STRING 'This category enables or disables' | |
STRING 'your computer''s serial port. It' | |
STRING 'allows you to conserve power when' | |
STRING 'the computer is running off the' | |
STRING 'battery pack.' | |
DB 0 | |
STRING 'Disable the port only if no' | |
STRING 'external device is connected to' | |
STRING 'it or if you are not using that' | |
STRING 'serial device during your current' | |
STRING 'work session. After you disable' | |
STRING 'the port, you cannot use it until' | |
STRING 'you reenable it and reboot the' | |
STRING 'computer.' | |
; | | | |
ParaHelp: DB 1 | |
DB 0 | |
STRING 'This category enables or disables' | |
STRING 'your computer''s parallel port.' | |
STRING 'It allows you to conserve power' | |
STRING 'when the computer is running off' | |
STRING 'the battery pack.' | |
DB 0 | |
STRING 'Disable the port only if no' | |
STRING 'external device is connected to' | |
STRING 'it or if you are not using that' | |
STRING 'parallel device during your cur-' | |
STRING 'rent work session. After you dis-' | |
STRING 'able the port, you cannot use it' | |
STRING 'until you reenable it and reboot' | |
STRING 'the computer.' | |
CopHelp: DB 1 | |
DB 0 | |
STRING 'This category enables or disables' | |
STRING 'your computer''s math coprocessor' | |
STRING 'if you have one installed in the' | |
STRING 'computer. It allows you to' | |
STRING 'conserve power when the computer' | |
STRING 'is running off the battery pack.' | |
DB 0 | |
STRING 'Disable the chip only if you do' | |
STRING 'not need it for mathematical' | |
STRING 'calculations during your current' | |
STRING 'work session. After you disable' | |
STRING 'the chip, you cannot use it until' | |
STRING 'you reenable it and reboot the' | |
STRING 'computer.' | |
ModemHelp: DB 1 | |
; DB 0,0,0 | |
; STRING 'If you have an internal modem' | |
; STRING 'installed, and you do not plan' | |
; STRING 'to use it during this session,' | |
; STRING 'you can turn it off with this' | |
; STRING 'setting.' | |
; STRING 'Turning it off will extend your' | |
; STRING 'computers battery life.' | |
; DB 0,0,0,0,0 | |
PortHelp: DB 1 | |
; DB 0,0,0 | |
; STRING 'If you have an internal modem' | |
; STRING 'installed, you can assign it' | |
; STRING 'to either COM1 or COM2. Some' | |
; STRING 'communications software may re-' | |
; STRING 'quire your modem to be assigned to' | |
; STRING 'a specific COM port.' | |
; DB 0,0,0,0,0,0 | |
; | | | |
FlopAsHelp: DB 1 | |
DB 0 | |
STRING 'This category determines whether' | |
STRING 'the internal drive or the' | |
STRING 'external drive is designated as' | |
STRING 'drive A.' | |
DB 0 | |
STRING 'Normally, the diskette drive' | |
STRING 'inside your System 316LT is' | |
STRING 'designated as drive A, and the' | |
STRING 'external drive (if you have one)' | |
STRING 'is designated as drive B. This' | |
STRING 'category is useful when you need' | |
STRING 'to boot a diskette in your' | |
STRING 'external drive that can be used' | |
STRING 'in drive A only.' | |
VolumeHelp: DB 1 | |
DB 0 | |
STRING 'This category sets the volume of' | |
STRING 'your computer''s speaker.' | |
DB 0 | |
STRING 'The speaker allows you to hear' | |
STRING 'beep codes and sounds generated' | |
STRING 'by application programs.' | |
DB 0,0,0,0,0,0,0,0 | |
;---------------------------------------------------------------------------- | |
; | |
; these are the "objects" | |
; each object has the following fields (instance data): | |
; | |
; 1. offset to the object's message handler routine | |
; the message code is passed in AH and has the following meaning: | |
; | |
; AH = -1 decrease your value and print it | |
; AH = 0 just print your value | |
; AH = +1 increase your value and print it | |
; AH = 2 set your value to the default | |
; AH = 3 display help (page number in global pageNum) | |
; AH = 4 perform sanity check, set default if insane | |
; | |
; 2. cursor position of beginning of field [2] | |
; 3. width of field [1] | |
; 4. help text pointer [2] | |
; | |
; if $0000, then help has not been implemented for this object yet. | |
; if $FFFF, then send a show help message to the object. | |
; | |
;---------------------------------------------------------------------------- | |
Objects: OBJECT <OFFSET Hour, 0308H, 2, OFFSET HourHelp> | |
OBJECT <OFFSET Minute, 030BH, 2, OFFSET HourHelp> | |
OBJECT <OFFSET Second, 030EH, 2, OFFSET HourHelp> | |
OBJECT <OFFSET Month, 031EH, 3, OFFSET MonthHelp> | |
OBJECT <OFFSET Day, 0322H, 2, OFFSET MonthHelp> | |
OBJECT <OFFSET Year, 0326H, 4, OFFSET MonthHelp> | |
OBJECT <OFFSET FloppyA, 0517H, 20, OFFSET IntHelp> | |
OBJECT <OFFSET FloppyB, 0617H, 20, OFFSET ExtHelp> | |
OBJECT <OFFSET HardDisk0, 0817H, 20, 0FFFFH> | |
; HDD 1 | |
OBJECT <OFFSET BaseMem, 0B17H, 20, OFFSET MemHelp> | |
OBJECT <OFFSET BIOSShadow, 0D17H, 20, OFFSET ShadHelp> | |
OBJECT <OFFSET VideoShadow, 0E17H, 20, OFFSET ShadHelp> | |
OBJECT <OFFSET Cache486, 1017H, 20, OFFSET ShadHelp> | |
OBJECT <OFFSET CompatSpeed, 1117H, 20, OFFSET ShadHelp> | |
OBJECT <OFFSET Serial, 1217H, 20, OFFSET SerialHelp> | |
lastObj: OBJECT <OFFSET Parallel, 1317H, 20, OFFSET ParaHelp> | |
objectEnd LABEL WORD | |
objectCount EQU (objectEnd - Objects) / (SIZE OBJECT) | |
BIOSCODE ENDS | |
END SETUP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment