Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1405 lines
28 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. dndispjp.c
  5. Abstract:
  6. DOS-based NT setup program video display routines for DOS/V.
  7. Author:
  8. Ted Miller (tedm) 30-March-1992
  9. Revision History:
  10. Originally dndisp.c.
  11. Modified 18-Feb-1995 (tedm) for DOS/V support, based on NT-J team's
  12. adaptation.
  13. --*/
  14. #ifdef JAPAN
  15. #ifdef DOS_V
  16. #include "winnt.h"
  17. #include <string.h>
  18. #define SCREEN_WIDTH 80
  19. #define SCREEN_HEIGHT 25
  20. #define STATUS_HEIGHT 1
  21. #define STATUS_LEFT_MARGIN 2
  22. #define HEADER_HEIGHT 3
  23. #define CHARACTER_MAX 256
  24. #if NEC_98
  25. extern
  26. VOID
  27. RestoreBootcode(VOID);
  28. VOID
  29. Screen_Buffer_Attr(
  30. SHORT x,
  31. SHORT y,
  32. UCHAR attr
  33. );
  34. extern CursorOnFlag; // For Cursor OFF
  35. #endif // NEC_98
  36. //
  37. // Display attributes
  38. //
  39. #if NEC_988
  40. #define ATT_FG_RED (0x40 | 0x01)
  41. #define ATT_FG_GREEN (0x80 | 0x01)
  42. #define ATT_FG_BLUE (0x20 | 0x01)
  43. #define ATT_FG_CYAN (ATT_FG_BLUE | ATT_FG_GREEN)
  44. #define ATT_FG_MAGENTA (ATT_FG_RED | ATT_FG_BLUE)
  45. #define ATT_FG_YELLOW (ATT_FG_RED | ATT_FG_GREEN)
  46. #define ATT_FG_WHITE (ATT_FG_RED | ATT_FG_GREEN | ATT_FG_BLUE)
  47. #define ATT_FG_BLACK (0x00 | 0x01)
  48. #define ATT_REVERSE 0x05
  49. #define ATT_BRINK 0x03
  50. #define ATT_BG_RED 0x00
  51. #define ATT_BG_GREEN 0x00
  52. #define ATT_BG_BLUE 0x00
  53. #define ATT_BG_CYAN 0x00
  54. #define ATT_BG_MAGENTA 0x00
  55. #define ATT_BG_YELLOW 0x00
  56. #define ATT_BG_WHITE 0x00
  57. #define ATT_BG_BLACK 0x00
  58. #define ATT_FG_INTENSE 0x00
  59. #define ATT_BG_INTENSE 0x00
  60. #define DEFAULT_ATTRIBUTE (ATT_FG_CYAN | ATT_REVERSE)
  61. #define STATUS_ATTRIBUTE (ATT_FG_WHITE | ATT_REVERSE)
  62. #define EDIT_ATTRIBUTE (ATT_FG_WHITE | ATT_REVERSE)
  63. #define EXITDLG_ATTRIBUTE (ATT_FG_WHITE | ATT_REVERSE)
  64. #define GAUGE_ATTRIBUTE (ATT_FG_YELLOW | ATT_REVERSE)
  65. #else // NEC_98
  66. #define ATT_FG_BLACK 0
  67. #define ATT_FG_BLUE 1
  68. #define ATT_FG_GREEN 2
  69. #define ATT_FG_CYAN 3
  70. #define ATT_FG_RED 4
  71. #define ATT_FG_MAGENTA 5
  72. #define ATT_FG_YELLOW 6
  73. #define ATT_FG_WHITE 7
  74. #define ATT_BG_BLACK (ATT_FG_BLACK << 4)
  75. #define ATT_BG_BLUE (ATT_FG_BLUE << 4)
  76. #define ATT_BG_GREEN (ATT_FG_GREEN << 4)
  77. #define ATT_BG_CYAN (ATT_FG_CYAN << 4)
  78. #define ATT_BG_RED (ATT_FG_RED << 4)
  79. #define ATT_BG_MAGENTA (ATT_FG_MAGENTA << 4)
  80. #define ATT_BG_YELLOW (ATT_FG_YELLOW << 4)
  81. #define ATT_BG_WHITE (ATT_FG_WHITE << 4)
  82. #define ATT_FG_INTENSE 8
  83. #define ATT_BG_INTENSE (ATT_FG_INTENSE << 4)
  84. #define DEFAULT_ATTRIBUTE (ATT_FG_WHITE | ATT_BG_BLUE)
  85. #define STATUS_ATTRIBUTE (ATT_FG_BLACK | ATT_BG_WHITE)
  86. #define EDIT_ATTRIBUTE (ATT_FG_BLACK | ATT_BG_WHITE)
  87. #define EXITDLG_ATTRIBUTE (ATT_FG_RED | ATT_BG_WHITE)
  88. #if NEC_98
  89. #define GAUGE_ATTRIBUTE (ATT_BG_YELLOW)
  90. #else
  91. #define GAUGE_ATTRIBUTE (ATT_BG_BLUE | ATT_FG_YELLOW | ATT_FG_INTENSE)
  92. #endif // NEC_98
  93. #endif // NEC_98
  94. //
  95. // This value gets initialized in DnInitializeDisplay.
  96. //
  97. #if NEC_98
  98. #define SCREEN_BUFFER ((UCHAR _far *)0xa0000000) // Normal Mode Text Vram
  99. #define SCREEN_BUFFER_CHR1(x,y) *((SCREEN_BUFFER + (2*((x)+(SCREEN_WIDTH*(y)))))+0)
  100. #define SCREEN_BUFFER_CHR2(x,y) *((SCREEN_BUFFER + (2*((x)+(SCREEN_WIDTH*(y)))))+1)
  101. UCHAR SCREEN_BUFFER_ATTRB[80][25];
  102. BOOLEAN CursorIsActuallyOn;
  103. #define IsANK(c) (!((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfe)))
  104. #else // NEC_98
  105. UCHAR _far *ScreenAddress;
  106. #define SCREEN_BUFFER (ScreenAddress)
  107. #define SCREEN_BUFFER_CHR(x,y) *(SCREEN_BUFFER + (2*((x)+(SCREEN_WIDTH*(y)))))
  108. #define SCREEN_BUFFER_ATT(x,y) *(SCREEN_BUFFER + (2*((x)+(SCREEN_WIDTH*(y))))+1)
  109. //
  110. // Macro to update a char location from the Pseudo text RAM to the display.
  111. //
  112. #define UPDATE_SCREEN_BUFFER(x,y,z) DnpUpdateBuffer(&SCREEN_BUFFER_CHR(x,y),z)
  113. BOOLEAN CursorIsActuallyOn;
  114. //
  115. // DBCS support
  116. //
  117. BOOLEAN DbcsTable[CHARACTER_MAX];
  118. #define ISDBCS(chr) DbcsTable[(chr)]
  119. #endif // NEC_98
  120. #if NEC_98
  121. #else // NEC_98
  122. VOID
  123. DnpInitializeDbcsTable(
  124. VOID
  125. );
  126. #endif // NEC_98
  127. //
  128. // Make these near because they are used in _asm blocks
  129. //
  130. UCHAR _near CurrentAttribute;
  131. UCHAR _near ScreenX;
  132. UCHAR _near ScreenY;
  133. BOOLEAN CursorOn;
  134. #if NEC_98
  135. #else // NEC_98
  136. UCHAR _far *
  137. DnpGetVideoAddress(
  138. VOID
  139. );
  140. VOID
  141. DnpUpdateBuffer(
  142. UCHAR _far *VideoAddress,
  143. int CharNum
  144. );
  145. #endif // NEC_98
  146. VOID
  147. DnpBlankScreenArea(
  148. IN UCHAR Attribute,
  149. IN UCHAR Left,
  150. IN UCHAR Right,
  151. IN UCHAR Top,
  152. IN UCHAR Bottom
  153. );
  154. VOID
  155. DnInitializeDisplay(
  156. VOID
  157. )
  158. /*++
  159. Routine Description:
  160. Put the display in a known state (80x25 standard text mode) and
  161. initialize the display package.
  162. Arguments:
  163. None.
  164. Return Value:
  165. None.
  166. --*/
  167. {
  168. #if NEC_98
  169. #else // NEC_98
  170. ScreenAddress = DnpGetVideoAddress();
  171. DnpInitializeDbcsTable();
  172. #endif // NEC_98
  173. CurrentAttribute = DEFAULT_ATTRIBUTE;
  174. CursorOn = FALSE;
  175. //
  176. // Set the display to standard 80x25 mode
  177. //
  178. #if NEC_98
  179. _asm {
  180. mov ax,0a00h // set CRT mode to 80 x 25
  181. int 18h
  182. push ds
  183. push cx
  184. push bx
  185. mov ax,0a800h
  186. mov ds,ax
  187. mov cx,3fffh
  188. blp:
  189. mov bx,cx
  190. mov ds:[bx],0
  191. loop blp
  192. mov ax,0b000h
  193. mov ds,ax
  194. mov cx,3fffh
  195. rlp:
  196. mov bx,cx
  197. mov ds:[bx],0
  198. loop rlp
  199. mov ax,0b800h
  200. mov ds,ax
  201. mov cx,3fffh
  202. glp:
  203. mov bx,cx
  204. mov ds:[bx],0
  205. loop glp
  206. mov ax,0e000h
  207. mov ds,ax
  208. mov cx,3fffh
  209. ilp:
  210. mov bx,cx
  211. mov ds:[bx],0
  212. loop ilp
  213. mov ah,042h
  214. mov ch,0c0h
  215. int 18h
  216. mov ax,8
  217. out 68h,al
  218. mov ax,1
  219. out 6ah,al
  220. mov ax,41h
  221. out 6ah,al
  222. mov ax,0dh
  223. out 0a2h,al
  224. pop bx
  225. pop cx
  226. pop ds
  227. }
  228. #else // NEC_98
  229. _asm {
  230. mov ax,3 // set video mode to 3
  231. int 10h
  232. }
  233. #endif // NEC_98
  234. //
  235. // Clear the entire screen
  236. //
  237. DnpBlankScreenArea(CurrentAttribute,0,SCREEN_WIDTH-1,0,SCREEN_HEIGHT-1);
  238. DnPositionCursor(0,0);
  239. //
  240. // Shut the cursor off.
  241. //
  242. #if NEC_98
  243. _asm {
  244. mov ah,12h // function -- cursor off
  245. int 18h
  246. }
  247. #else // NEC_98
  248. _asm {
  249. mov ah,2 // function -- position cursor
  250. mov bh,0 // display page
  251. mov dh,SCREEN_HEIGHT
  252. mov dl,0
  253. int 10h
  254. }
  255. #endif // NEC_98
  256. CursorIsActuallyOn = FALSE;
  257. }
  258. VOID
  259. DnClearClientArea(
  260. VOID
  261. )
  262. /*++
  263. Routine Description:
  264. Clear the client area of the screen, ie, the area between the header
  265. and status line.
  266. Arguments:
  267. None.
  268. Return Value:
  269. None.
  270. --*/
  271. {
  272. DnpBlankScreenArea( CurrentAttribute,
  273. 0,
  274. SCREEN_WIDTH-1,
  275. HEADER_HEIGHT,
  276. SCREEN_HEIGHT - STATUS_HEIGHT - 1
  277. );
  278. DnPositionCursor(0,HEADER_HEIGHT);
  279. }
  280. VOID
  281. DnSetGaugeAttribute(
  282. IN BOOLEAN Set
  283. )
  284. /*++
  285. Routine Description:
  286. Prepare for drawing the thermometer portion of a gas gauge.
  287. Arguments:
  288. Set - if TRUE, prepare for drawing the thermometer. If FALSE, restore
  289. the state for normal drawing.
  290. Return Value:
  291. None.
  292. --*/
  293. {
  294. static UCHAR SavedAttribute = 0;
  295. if(Set) {
  296. if(!SavedAttribute) {
  297. SavedAttribute = CurrentAttribute;
  298. CurrentAttribute = GAUGE_ATTRIBUTE;
  299. }
  300. } else {
  301. if(SavedAttribute) {
  302. CurrentAttribute = SavedAttribute;
  303. SavedAttribute = 0;
  304. }
  305. }
  306. }
  307. VOID
  308. DnPositionCursor(
  309. IN UCHAR X,
  310. IN UCHAR Y
  311. )
  312. /*++
  313. Routine Description:
  314. Position the cursor.
  315. Arguments:
  316. X,Y - cursor coords
  317. Return Value:
  318. None.
  319. --*/
  320. {
  321. #if NEC_98
  322. USHORT Cursor;
  323. #endif // NEC_98
  324. if(X >= SCREEN_WIDTH) {
  325. X = 0;
  326. Y++;
  327. }
  328. if(Y >= SCREEN_HEIGHT) {
  329. Y = HEADER_HEIGHT;
  330. }
  331. ScreenX = X;
  332. ScreenY = Y;
  333. //
  334. // Invoke BIOS
  335. //
  336. #if NEC_98
  337. Cursor = ((ScreenX + (SCREEN_WIDTH * ScreenY)) * 2 + (USHORT)SCREEN_BUFFER);
  338. if(CursorOnFlag) {
  339. _asm {
  340. mov ah,13h // function -- position cursor
  341. mov dx,Cursor
  342. int 18h
  343. mov ah,11h // function -- cursor on
  344. int 18h
  345. }
  346. CursorIsActuallyOn = TRUE;
  347. } else {
  348. _asm {
  349. mov ah,13h // function -- position cursor
  350. mov dx,Cursor
  351. int 18h
  352. mov ah,12h // function -- cursor off
  353. int 18h
  354. }
  355. CursorIsActuallyOn = FALSE;
  356. }
  357. #else // NEC_98
  358. _asm {
  359. mov ah,2 // function -- position cursor
  360. mov bh,0 // display page
  361. mov dh,ScreenY
  362. mov dl,ScreenX
  363. int 10h
  364. }
  365. CursorIsActuallyOn = TRUE;
  366. #endif // NEC_98
  367. }
  368. VOID
  369. DnWriteChar(
  370. IN CHAR chr
  371. )
  372. /*++
  373. Routine Description:
  374. Write a character in the current attribute at the current position.
  375. Arguments:
  376. chr - Character to write
  377. Return Value:
  378. None.
  379. --*/
  380. {
  381. if(chr == '\n') {
  382. ScreenX = 0;
  383. ScreenY++;
  384. return;
  385. }
  386. #if NEC_98
  387. if ( ( ScreenX < SCREEN_WIDTH ) && ( ScreenY < SCREEN_HEIGHT ) ) {
  388. SCREEN_BUFFER_CHR1(ScreenX,ScreenY) = chr;
  389. SCREEN_BUFFER_CHR2(ScreenX,ScreenY) = 0x00;
  390. Screen_Buffer_Attr(ScreenX,ScreenY, CurrentAttribute);
  391. }
  392. if(!CursorOn && CursorIsActuallyOn) {
  393. CursorIsActuallyOn = FALSE;
  394. _asm {
  395. mov ah,12h // function -- cursor off
  396. int 18h
  397. }
  398. }
  399. #else // NEC_98
  400. if ( ( ScreenX < SCREEN_WIDTH ) && ( ScreenY < SCREEN_HEIGHT ) ) {
  401. SCREEN_BUFFER_CHR(ScreenX,ScreenY) = chr;
  402. SCREEN_BUFFER_ATT(ScreenX,ScreenY) = CurrentAttribute;
  403. UPDATE_SCREEN_BUFFER(ScreenX, ScreenY,1);
  404. }
  405. //
  406. // shut cursor off if necessary
  407. //
  408. if(!CursorOn && CursorIsActuallyOn) {
  409. CursorIsActuallyOn = FALSE;
  410. _asm {
  411. mov ah,2 // function -- position cursor
  412. mov bh,0 // display page
  413. mov dh,SCREEN_HEIGHT
  414. mov dl,0
  415. int 10h
  416. }
  417. }
  418. #endif // NEC_98
  419. }
  420. VOID
  421. DnWriteWChar(
  422. #if NEC_98
  423. IN PUCHAR chr
  424. #else // NEC_98
  425. IN PCHAR chr
  426. #endif // NEC_98
  427. )
  428. /*++
  429. Routine Description:
  430. Write a DBCS character in the current attribute at the current position.
  431. Arguments:
  432. wchr - DBCS Character to write
  433. Return Value:
  434. None.
  435. --*/
  436. {
  437. #if NEC_98
  438. PUCHAR code = chr;
  439. UCHAR moji_1st,moji_2nd;
  440. USHORT sjis;
  441. moji_1st = *code;
  442. code++;
  443. moji_2nd = *code;
  444. code++;
  445. // Make Shift JIS
  446. sjis = (USHORT)moji_1st;
  447. sjis = (sjis << 8) + (USHORT)moji_2nd;
  448. // Shift JIS -> JIS code exchange
  449. moji_1st -= ((moji_1st <= 0x9f) ? 0x71 : 0xb1);
  450. moji_1st = (UCHAR)(moji_1st * 2 + 1);
  451. if (moji_2nd > 0x7f){ moji_2nd--; }
  452. if (moji_2nd >= 0x9e){ moji_2nd -= 0x7d; moji_1st++; }
  453. else { moji_2nd -= 0x1f; }
  454. // Create custom JIS code
  455. moji_1st += 0x60;
  456. // Grpah Mode Check
  457. if (memcmp(&sjis,"\340\340",2) == 0){
  458. SCREEN_BUFFER_CHR1(ScreenX,ScreenY) = (UCHAR)(sjis >> 8);
  459. SCREEN_BUFFER_CHR2(ScreenX,ScreenY) = 0x00;
  460. Screen_Buffer_Attr(ScreenX,ScreenY, CurrentAttribute);
  461. SCREEN_BUFFER_CHR1(ScreenX+1,ScreenY) = (UCHAR)(sjis & 0xff);
  462. SCREEN_BUFFER_CHR2(ScreenX+1,ScreenY) = 0x00;
  463. Screen_Buffer_Attr(ScreenX+1,ScreenY, CurrentAttribute);
  464. }
  465. else {
  466. SCREEN_BUFFER_CHR1(ScreenX,ScreenY) = moji_1st;
  467. SCREEN_BUFFER_CHR2(ScreenX,ScreenY) = moji_2nd;
  468. Screen_Buffer_Attr(ScreenX,ScreenY, CurrentAttribute);
  469. SCREEN_BUFFER_CHR1(ScreenX+1,ScreenY) = (UCHAR)(moji_1st - 0x80);
  470. SCREEN_BUFFER_CHR2(ScreenX+1,ScreenY) = moji_2nd;
  471. Screen_Buffer_Attr(ScreenX+1,ScreenY, CurrentAttribute);
  472. }
  473. //
  474. // shut cursor off if necessary
  475. //
  476. if(!CursorOn && CursorIsActuallyOn) {
  477. CursorIsActuallyOn = FALSE;
  478. _asm {
  479. mov ah,12h // function -- cursor off
  480. int 18h
  481. }
  482. }
  483. #else // NEC_98
  484. SCREEN_BUFFER_CHR(ScreenX,ScreenY) = *chr;
  485. SCREEN_BUFFER_ATT(ScreenX,ScreenY) = CurrentAttribute;
  486. SCREEN_BUFFER_CHR(ScreenX+1,ScreenY) = *(chr+1);
  487. SCREEN_BUFFER_ATT(ScreenX+1,ScreenY) = CurrentAttribute;
  488. UPDATE_SCREEN_BUFFER(ScreenX,ScreenY,2);
  489. //
  490. // shut cursor off if necessary
  491. //
  492. if(!CursorOn && CursorIsActuallyOn) {
  493. CursorIsActuallyOn = FALSE;
  494. _asm {
  495. mov ah,2 // function -- position cursor
  496. mov bh,0 // display page
  497. mov dh,SCREEN_HEIGHT // screen height
  498. mov dl,0
  499. int 10h
  500. }
  501. }
  502. #endif // NEC_98
  503. }
  504. VOID
  505. DnWriteString(
  506. IN PCHAR String
  507. )
  508. /*++
  509. Routine Description:
  510. Write a string on the client area in the current position and
  511. adjust the current position. The string is written in the current
  512. attribute.
  513. Arguments:
  514. String - null terminated string to write.
  515. Return Value:
  516. None.
  517. --*/
  518. {
  519. PCHAR p;
  520. #if NEC_98
  521. for(p=String; *p; p++) {
  522. if(!IsANK((UCHAR)*p)) {
  523. DnWriteWChar((PUCHAR)p);
  524. p++ ;
  525. ScreenX += 2 ;
  526. } else {
  527. DnWriteChar(*p);
  528. if(*p != '\n') {
  529. ScreenX++;
  530. }
  531. }
  532. }
  533. #else // NEC_98
  534. for(p=String; *p; p++) {
  535. if(ISDBCS((UCHAR)*p)) {
  536. DnWriteWChar(p);
  537. p++;
  538. ScreenX += 2;
  539. } else {
  540. DnWriteChar(*p);
  541. if(*p != '\n') {
  542. ScreenX++;
  543. }
  544. }
  545. }
  546. #endif // NEC_98
  547. }
  548. VOID
  549. DnWriteStatusText(
  550. IN PCHAR FormatString OPTIONAL,
  551. ...
  552. )
  553. /*++
  554. Routine Description:
  555. Update the status area
  556. Arguments:
  557. FormatString - if present, supplies a printf format string for the
  558. rest of the arguments. Otherwise the status area is cleared out.
  559. Return Value:
  560. None.
  561. --*/
  562. {
  563. va_list arglist;
  564. static CHAR String[SCREEN_WIDTH+1];
  565. int StringLength;
  566. UCHAR SavedAttribute;
  567. //
  568. // First, clear out the status area.
  569. //
  570. DnpBlankScreenArea( STATUS_ATTRIBUTE,
  571. 0,
  572. SCREEN_WIDTH-1,
  573. SCREEN_HEIGHT-STATUS_HEIGHT,
  574. SCREEN_HEIGHT-1
  575. );
  576. if(FormatString) {
  577. va_start(arglist,FormatString);
  578. StringLength = vsnprintf(String,sizeof(String),FormatString,arglist);
  579. String[sizeof(String)-1] = '\0';
  580. SavedAttribute = CurrentAttribute;
  581. CurrentAttribute = STATUS_ATTRIBUTE;
  582. DnPositionCursor(STATUS_LEFT_MARGIN,SCREEN_HEIGHT - STATUS_HEIGHT);
  583. DnWriteString(String);
  584. CurrentAttribute = SavedAttribute;
  585. }
  586. }
  587. VOID
  588. DnSetCopyStatusText(
  589. IN PCHAR Caption,
  590. IN PCHAR Filename
  591. )
  592. /*++
  593. Routine Description:
  594. Write or erase a copying message in the lower right part of the screen.
  595. Arguments:
  596. Filename - name of file currently being copied. If NULL, erases the
  597. copy status area.
  598. Return Value:
  599. None.
  600. --*/
  601. {
  602. unsigned CopyStatusAreaLen;
  603. CHAR StatusText[100];
  604. //
  605. // The 13 is for 8.3 and a space
  606. //
  607. CopyStatusAreaLen = strlen(Caption) + 13;
  608. //
  609. // First erase the status area.
  610. //
  611. DnpBlankScreenArea( STATUS_ATTRIBUTE,
  612. (UCHAR)(SCREEN_WIDTH - CopyStatusAreaLen),
  613. SCREEN_WIDTH - 1,
  614. SCREEN_HEIGHT - STATUS_HEIGHT,
  615. SCREEN_HEIGHT - 1
  616. );
  617. if(Filename) {
  618. UCHAR SavedAttribute;
  619. UCHAR SavedX,SavedY;
  620. SavedAttribute = CurrentAttribute;
  621. SavedX = ScreenX;
  622. SavedY = ScreenY;
  623. CurrentAttribute = STATUS_ATTRIBUTE;
  624. DnPositionCursor((UCHAR)(SCREEN_WIDTH-CopyStatusAreaLen),SCREEN_HEIGHT-1);
  625. memset(StatusText,0,sizeof(StatusText));
  626. strcpy(StatusText,Caption);
  627. strncpy(StatusText + strlen(StatusText),Filename,12);
  628. DnWriteString(StatusText);
  629. CurrentAttribute = SavedAttribute;
  630. ScreenX = SavedX;
  631. ScreenY = SavedY;
  632. }
  633. }
  634. VOID
  635. DnStartEditField(
  636. IN BOOLEAN CreateField,
  637. IN UCHAR X,
  638. IN UCHAR Y,
  639. IN UCHAR W
  640. )
  641. /*++
  642. Routine Description:
  643. Sets up the display package to start handling an edit field.
  644. Arguments:
  645. CreateField - if TRUE, caller is starting an edit field interaction.
  646. If FALSE, he is ending one.
  647. X,Y,W - supply coords and width in chars of the edit field.
  648. Return Value:
  649. None.
  650. --*/
  651. {
  652. static UCHAR SavedAttribute = 255;
  653. CursorOn = CreateField;
  654. if(CreateField) {
  655. if(SavedAttribute == 255) {
  656. SavedAttribute = CurrentAttribute;
  657. CurrentAttribute = EDIT_ATTRIBUTE;
  658. }
  659. DnpBlankScreenArea(EDIT_ATTRIBUTE,X,(UCHAR)(X+W-1),Y,Y);
  660. } else {
  661. if(SavedAttribute != 255) {
  662. CurrentAttribute = SavedAttribute;
  663. SavedAttribute = 255;
  664. }
  665. }
  666. }
  667. VOID
  668. DnExitDialog(
  669. VOID
  670. )
  671. {
  672. unsigned W,H,X,Y,i;
  673. PUCHAR CharSave;
  674. PUCHAR AttSave;
  675. ULONG Key,ValidKeys[3] = { ASCI_CR,DN_KEY_F3,0 };
  676. UCHAR SavedX,SavedY,SavedAttribute;
  677. BOOLEAN SavedCursorState = CursorOn;
  678. SavedAttribute = CurrentAttribute;
  679. CurrentAttribute = EXITDLG_ATTRIBUTE;
  680. SavedX = ScreenX;
  681. SavedY = ScreenY;
  682. //
  683. // Shut the cursor off.
  684. //
  685. CursorIsActuallyOn = FALSE;
  686. CursorOn = FALSE;
  687. #if NEC_98
  688. _asm {
  689. mov ah,12h // function -- cursor off
  690. int 18h
  691. }
  692. #else // NEC_98
  693. _asm {
  694. mov ah,2 // function -- position cursor
  695. mov bh,0 // display page
  696. mov dh,SCREEN_HEIGHT
  697. mov dl,0
  698. int 10h
  699. }
  700. #endif // NEC_98
  701. //
  702. // Count lines in the dialog and determine its width.
  703. //
  704. for(H=0; DnsExitDialog.Strings[H]; H++);
  705. W = strlen(DnsExitDialog.Strings[0]);
  706. #if NEC_98
  707. W += 2;
  708. #endif // NEC_98
  709. //
  710. // allocate two buffers for character save and attribute save
  711. //
  712. #if NEC_98
  713. CharSave = MALLOC((W*H+2)*2,TRUE);
  714. AttSave = MALLOC((W*H+2)*2,TRUE);
  715. #else // NEC_98
  716. CharSave = MALLOC(W*H,TRUE);
  717. AttSave = MALLOC(W*H,TRUE);
  718. #endif // NEC_98
  719. //
  720. // save the screen patch
  721. //
  722. #if NEC_98
  723. for(Y=0; Y<H; Y++) {
  724. for(X=0; X < (W+2) ;X++) {
  725. UCHAR attr,chr1,chr2;
  726. UCHAR x,y;
  727. x = (UCHAR)(X + (DnsExitDialog.X - 1));
  728. y = (UCHAR)(Y + DnsExitDialog.Y);
  729. chr1 = SCREEN_BUFFER_CHR1(x,y);
  730. chr2 = SCREEN_BUFFER_CHR2(x,y);
  731. attr = SCREEN_BUFFER_ATTRB[x][y];
  732. CharSave[(Y*W*2)+(X*2)] = chr1;
  733. CharSave[(Y*W*2)+(X*2+1)] = chr2;
  734. AttSave [(Y*W*2)+(X*2)] = attr;
  735. if((X == 0) && (chr2 != 0)){
  736. SCREEN_BUFFER_CHR1(x,y) = ' ';
  737. SCREEN_BUFFER_CHR2(x,y) = 0x00;
  738. }
  739. if((X == (W-1)) && (chr2 != 0)){
  740. if(((CharSave[(Y*W*2)+((X-1)*2+0)] - (UCHAR)0x80) == chr1) &&
  741. ( CharSave[(Y*W*2)+((X-1)*2+1)] == chr2)){
  742. SCREEN_BUFFER_CHR1(x,y) = ' ';
  743. SCREEN_BUFFER_CHR2(x,y) = 0x00;
  744. }
  745. }
  746. }
  747. }
  748. #else // NEC_98
  749. for(Y=0; Y<H; Y++) {
  750. for(X=0; X<W; X++) {
  751. UCHAR att,chr;
  752. UCHAR x,y;
  753. x = (UCHAR)(X + DnsExitDialog.X);
  754. y = (UCHAR)(Y + DnsExitDialog.Y);
  755. chr = SCREEN_BUFFER_CHR(x,y);
  756. att = SCREEN_BUFFER_ATT(x,y);
  757. CharSave[Y*W+X] = chr;
  758. AttSave[Y*W+X] = att;
  759. }
  760. }
  761. #endif // NEC_98
  762. //
  763. // Put up the dialog
  764. //
  765. for(i=0; i<H; i++) {
  766. DnPositionCursor(DnsExitDialog.X,(UCHAR)(DnsExitDialog.Y+i));
  767. DnWriteString(DnsExitDialog.Strings[i]);
  768. }
  769. CurrentAttribute = SavedAttribute;
  770. //
  771. // Wait for a valid keypress
  772. //
  773. Key = DnGetValidKey(ValidKeys);
  774. if(Key == DN_KEY_F3) {
  775. #if NEC_98
  776. //
  777. // On floppyless setup if user have canceled setup or setup be stopped
  778. // by error occurred,previous OS can't boot to be written boot code
  779. // and boot loader.
  780. //
  781. RestoreBootcode();
  782. #endif // NEC_98
  783. DnExit(1);
  784. }
  785. //
  786. // Restore the patch
  787. //
  788. #if NEC_98
  789. for(Y=0; Y<H; Y++) {
  790. for(X=0; X < (W+2); X++) {
  791. UCHAR attr,chr1,chr2;
  792. UCHAR x,y;
  793. x = (UCHAR)(X + (DnsExitDialog.X - 1));
  794. y = (UCHAR)(Y + DnsExitDialog.Y);
  795. chr1 = CharSave[(Y*W*2)+(X*2)];
  796. chr2 = CharSave[(Y*W*2)+(X*2+1)];
  797. attr = AttSave [(Y*W*2)+(X*2)];
  798. SCREEN_BUFFER_CHR1(x,y) = chr1;
  799. SCREEN_BUFFER_CHR2(x,y) = chr2;
  800. Screen_Buffer_Attr(x,y, attr);
  801. }
  802. }
  803. #else // NEC_98
  804. for(Y=0; Y<H; Y++) {
  805. for(X=0; X<W; X++) {
  806. UCHAR att,chr;
  807. UCHAR x,y;
  808. x = (UCHAR)(X + DnsExitDialog.X);
  809. y = (UCHAR)(Y + DnsExitDialog.Y);
  810. chr = CharSave[Y*W+X];
  811. att = AttSave[Y*W+X];
  812. SCREEN_BUFFER_CHR(x,y) = chr;
  813. SCREEN_BUFFER_ATT(x,y) = att;
  814. if((0 == X) && ISDBCS((UCHAR)SCREEN_BUFFER_CHR(x-1,y))) {
  815. UPDATE_SCREEN_BUFFER(x-1,y,2);
  816. } else if (ISDBCS((UCHAR)chr)) {
  817. X++ ;
  818. x = (UCHAR)(X + DnsExitDialog.X);
  819. y = (UCHAR)(Y + DnsExitDialog.Y);
  820. chr = CharSave[Y*W+X];
  821. att = AttSave[Y*W+X];
  822. SCREEN_BUFFER_CHR(x,y) = chr;
  823. SCREEN_BUFFER_ATT(x,y) = att;
  824. UPDATE_SCREEN_BUFFER(x-1,y,2);
  825. } else {
  826. UPDATE_SCREEN_BUFFER(x,y,1);
  827. }
  828. }
  829. }
  830. #endif // NEC_98
  831. FREE(CharSave);
  832. FREE(AttSave);
  833. CursorOn = SavedCursorState;
  834. if(CursorOn) {
  835. DnPositionCursor(SavedX,SavedY);
  836. } else {
  837. ScreenX = SavedX;
  838. ScreenY = SavedY;
  839. #if NEC_98
  840. _asm {
  841. mov ah,12h // function -- cursor off
  842. int 18h
  843. }
  844. #else // NEC_98
  845. _asm {
  846. mov ah,2
  847. mov bh,0
  848. mov dh,SCREEN_HEIGHT;
  849. mov dl,0
  850. int 10h
  851. }
  852. #endif // NEC_98
  853. CursorIsActuallyOn = FALSE;
  854. }
  855. }
  856. //
  857. // Internal support routines
  858. //
  859. VOID
  860. DnpBlankScreenArea(
  861. IN UCHAR Attribute,
  862. IN UCHAR Left,
  863. IN UCHAR Right,
  864. IN UCHAR Top,
  865. IN UCHAR Bottom
  866. )
  867. /*++
  868. Routine Description:
  869. Invoke the BIOS to blank a region of the screen.
  870. Arguments:
  871. Attribute - screen attribute to use to blank the region
  872. Left,Right,Top,Bottom - coords of region to blank
  873. Return Value:
  874. None.
  875. --*/
  876. {
  877. UCHAR x,y;
  878. #if NEC_98
  879. for(y=Top; y<=Bottom; y++) {
  880. for(x=Left; x<=Right; x++) {
  881. SCREEN_BUFFER_CHR1(x,y) = ' ';
  882. SCREEN_BUFFER_CHR2(x,y) = 0x00;
  883. Screen_Buffer_Attr(x,y, Attribute);
  884. }
  885. }
  886. #else // NEC_98
  887. for(y=Top; y<=Bottom; y++) {
  888. for(x=Left; x<=Right; x++) {
  889. SCREEN_BUFFER_CHR(x,y) = ' ';
  890. SCREEN_BUFFER_ATT(x,y) = Attribute;
  891. UPDATE_SCREEN_BUFFER(x,y,1);
  892. }
  893. }
  894. #endif // NEC_98
  895. }
  896. #if NEC_98
  897. #else // NEC_98
  898. //
  899. // Disable 4035 warning - no return value, since
  900. // the register state is set correctly with the
  901. // required return value
  902. //
  903. #pragma warning( disable : 4035 )
  904. UCHAR _far *
  905. DnpGetVideoAddress(
  906. VOID
  907. )
  908. /*++
  909. Routine Description:
  910. This function retrieves the location of the Video Text Ram if one exists,
  911. else will retrieve the location of the Pseudo (virtual) Text Ram.
  912. Arguments:
  913. None.
  914. Return Value:
  915. Either the Video Text RAM or Pseudo Text RAM address.
  916. --*/
  917. {
  918. _asm {
  919. push es
  920. push di
  921. mov ax, 0b800h
  922. mov es, ax
  923. xor di, di
  924. mov ax, 0fe00h
  925. int 10h
  926. mov dx, es
  927. mov ax, di
  928. pop di
  929. pop es
  930. }
  931. }
  932. UCHAR _far *
  933. DnpGetDbcsTable(
  934. VOID
  935. )
  936. {
  937. _asm {
  938. push ds
  939. push si
  940. mov ax, 06300h
  941. int 21h
  942. mov dx, ds
  943. mov ax, si
  944. pop si
  945. pop ds
  946. }
  947. }
  948. //
  949. // Reset the 4035 warning state back to the
  950. // default state
  951. //
  952. #pragma warning( default : 4035 )
  953. VOID
  954. DnpUpdateBuffer(
  955. UCHAR _far *VideoAddress,
  956. int CharNum
  957. )
  958. /*++
  959. Routine Description:
  960. Updates one character in the Pseudo Text RAM to the display. This
  961. function will have NO effect if the address points to the actual
  962. text RAM, usually B800:0000H+ in US mode.
  963. Arguments:
  964. The address location of where the character is in the text RAM.
  965. Return Value:
  966. None.
  967. --*/
  968. {
  969. _asm {
  970. push es
  971. push di
  972. mov ax, word ptr 6[bp]
  973. mov es, ax
  974. mov di, word ptr 4[bp]
  975. mov cx, CharNum
  976. mov ax, 0ff00h
  977. int 10h
  978. pop di
  979. pop es
  980. }
  981. }
  982. VOID
  983. DnpInitializeDbcsTable(
  984. VOID
  985. )
  986. {
  987. UCHAR _far *p;
  988. UCHAR _far *Table;
  989. int i;
  990. Table = DnpGetDbcsTable();
  991. for(p=Table; *p; p+=2) {
  992. for(i = (int)*p; i<=(int)*(p+1); i++) {
  993. DbcsTable[i] = TRUE;
  994. }
  995. }
  996. }
  997. #endif // NEC_98
  998. int
  999. DnGetGaugeChar(
  1000. VOID
  1001. )
  1002. {
  1003. #if NEC_98
  1004. return(0x20);
  1005. #else // NEC_98
  1006. return(0x14); //shaded square in cp932
  1007. #endif // NEC_98
  1008. }
  1009. #if NEC_98
  1010. VOID
  1011. Screen_Buffer_Attr(
  1012. SHORT x,
  1013. SHORT y,
  1014. UCHAR attr
  1015. )
  1016. {
  1017. UCHAR _far *pfgc;
  1018. SHORT fgc;
  1019. SHORT pc98col[] = { 0x5, 0x25, 0x85, 0x0a5, 0x045, 0x65, 0x0c5, 0x0e5};
  1020. SCREEN_BUFFER_ATTRB[x][y] = attr;
  1021. *((SCREEN_BUFFER + (2*((x)+(SCREEN_WIDTH*(y)))))+0x2000) = pc98col[((attr & 0x70) >> 4)];
  1022. pfgc = y * 80 * 16 + x;
  1023. fgc = attr & 0x0f;
  1024. _asm {
  1025. push ds
  1026. push cx
  1027. push bx
  1028. mov ax, 0a800h
  1029. mov ds,ax
  1030. mov cx,16
  1031. mov bx, pfgc
  1032. mov ax, fgc
  1033. and ax, 1;
  1034. mov al, 0
  1035. jz bfil
  1036. mov al,0ffh
  1037. bfil:
  1038. mov ds:[bx],al
  1039. add bx, 80
  1040. loop bfil
  1041. mov ax, 0b800h
  1042. mov ds,ax
  1043. mov cx,16
  1044. mov bx, pfgc
  1045. mov ax, fgc
  1046. and ax, 2;
  1047. mov al,0
  1048. jz gfil
  1049. mov al,0ffh
  1050. gfil:
  1051. mov ds:[bx],al
  1052. add bx, 80
  1053. loop gfil
  1054. mov ax, 0b000h
  1055. mov ds,ax
  1056. mov cx,16
  1057. mov bx, pfgc
  1058. mov ax, fgc
  1059. and ax, 4
  1060. mov al,0
  1061. jz rfil
  1062. mov al,0ffh
  1063. rfil:
  1064. mov ds:[bx],al
  1065. add bx, 80
  1066. loop rfil
  1067. mov ax, 0e000h
  1068. mov ds,ax
  1069. mov cx,16
  1070. mov bx, pfgc
  1071. mov ax, fgc
  1072. and ax, 8
  1073. mov al,0
  1074. jz ifil
  1075. mov al,0ffh
  1076. ifil:
  1077. mov ds:[bx],0ffh
  1078. add bx, 80
  1079. loop ifil
  1080. pop bx
  1081. pop cx
  1082. pop ds
  1083. }
  1084. }
  1085. int
  1086. WriteBackGrounf(
  1087. SHORT color
  1088. )
  1089. {
  1090. return(0);
  1091. }
  1092. #endif // NEC_98
  1093. #else
  1094. //
  1095. // Not compiling for DOS/V (ie, we're building the Japanese
  1096. // version of the 'standard' winnt.exe)
  1097. //
  1098. #include ".\dndisp.c"
  1099. #endif // def DOS_V
  1100. #else
  1101. #error Trying to use Japanese display routines but not compiling Japanese version!
  1102. #endif // def JAPAN