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.

678 lines
20 KiB

  1. ;========================================================================;
  2. ; ;
  3. ; GLOBAL DATA ;
  4. ; ;
  5. ;========================================================================;
  6. ;
  7. ; ѱ BIOS ü ǰų ܺ ȭϰ interface ʿ
  8. ; Ÿ.
  9. ;
  10. public KbStat, Card1st, Card2nd, HeKey, HjKey, HjStat, DisplayStat, KseCard
  11. public ModeStat, MemStat, Printer, CodeStat, HanStat, HjMenuStat, ErrStat
  12. public MachineType, ModeId, WinOffset, WinSegment, KbMisc, VideoActive
  13. public iVersion, HotStat, KbdType, HanSavePtr
  14. public HjMenuLine, UdcTblPtr, CodeBuf2Addr, EndSegment, EndOffset
  15. public EmsHandle, MaxMemSize, EmsSeg, CurEmsPage, CodeBufSize, MemSize
  16. public OldVdParms, OldSavePtr, OldKbInt, OldVideo, OldRtcInt, OldKbInt
  17. public OldInt17, OldInt15, OldKbioInt
  18. public PatGenAddr, HanPatternPtr, Ks2ChAddr
  19. public HanAddr, HanAddrH, UdcAddr, UdcAddrH
  20. public HanOn1st, HanOff1st, HanOn2nd, HanOff2nd
  21. public GetHan1st, GetUdc1st, PutUdc1st, GetHan2nd, GetUdc2nd, PutUdc2nd
  22. public CompleteCharCnt, CompleteCharBuf, InterimCharCnt
  23. public InterimCharBuf, Auto, TmpKbdType
  24. public InterimCurPage,InterimMaxCols,InterimCurPos
  25. public SavedChar1,SavedChar2
  26. public MenuPtr, CurrMenuCnt, SaveCurrPage, CrtMaxCols
  27. public SaveCurPos, SaveCurType, prebufptr
  28. public DispIChar1, DispIChar2, InterimDispP
  29. public PreInCode, CurInCode, TmpBuf, PreTmpBuf, KsKbBuf, TmpBufCnt
  30. if WINNT
  31. public ActiveCodePage
  32. endif
  33. IF Hwin31Sw
  34. PUBLIC OldInt2f
  35. ENDIF ;Hwin31Sw
  36. ;************************************
  37. StartInst:
  38. ;------------------------------------------------------------------------
  39. ; public data area̹Ƿ
  40. PublicData label word ; INT 10 entry FD
  41. CodeBuf1Addr label dword
  42. dw 0
  43. dw 0
  44. HanStat db 0 ; indicate whether HanGeul 1st byte have
  45. HjMenuStat db 0 ; progress HanJa menu or ChgEnvr
  46. db 08 dup(0) ; reserved
  47. db 'H'
  48. db 'B'
  49. dw offset WinData
  50. WinData db 'WINDOWS'
  51. WinOffset dw offset WinEnvrChange
  52. WinSegment dw 0 ; code segment address
  53. db LocalDataLng
  54. CodeStat db HangeulMode ; code/spec status
  55. KbStat db 0 ; general KBD status
  56. HjMenuLine db 0 ; hanja menu display line #
  57. LocalDataLng = $-CodeStat
  58. CodeBufSize dw ? ; 80*25*2, 80*30*2 ,Init ʱȭҰ
  59. iVersion db Version ; 5 byte
  60. ;------------------------------------------------------------------------
  61. ModeId db 0
  62. UdcTblPtr dw 0 ; UDC table address(real memory)
  63. CodeBuf2Addr dd 0 ; 2nd code buffer segment:offset address
  64. VideoActive db 80h ; service routine
  65. ModeStat db 0 ; video mode status
  66. DisplayStat db 0 ; Han1st, RunEsc
  67. PatGenAddr dw 0 ; pattern generator
  68. HanPatternPtr dw 0 ; pattern generator
  69. Ks2ChAddr dw 0 ; code conversion(KS -> CH)
  70. KbMisc db InterimCtrlDisp
  71. HotStat db 0
  72. Port3bf db 0 ; for KSE VGA card
  73. KseCard db 0
  74. KbdType db 0
  75. HjStat db 0 ; hanja, UDC font status
  76. OrgHjStat db 0 ; original hanja, UDC font status
  77. ; -------------kb.asm DATA -------------
  78. CompleteCharCnt dw 0
  79. CompleteCharBuf dw 16 dup(0)
  80. InterimCharCnt dw 0
  81. InterimCharBuf dw 2 dup(0)
  82. Auto db 0
  83. TmpKbdType db 0
  84. InterimCurPage db 0
  85. InterimMaxCols db 0
  86. InterimCurPos dw 0
  87. SavedChar1 db 0
  88. SavedChar2 db 0
  89. MenuPtr db 0
  90. CurrMenuCnt db 0
  91. SaveCurrPage db 0
  92. CrtMaxCols db 0
  93. SaveCurPos dw 0
  94. SaveCurType dw 0
  95. prebufptr dw 0
  96. ; interim display
  97. DispIChar1 DB 0
  98. DispIChar2 DB 0
  99. InterimDispP dw 0
  100. ;automata
  101. PreInCode dw 0
  102. CurInCode dw 0
  103. TmpBuf dw 0
  104. PreTmpBuf dw 0
  105. KsKbBuf dw 0
  106. TmpBufCnt db 0
  107. ; ------------- video.asm DATA -------------
  108. ; Display buffer
  109. GrpBufAddr dd ? ; grp buffer pointer
  110. ; Cursor position Ÿ pointer
  111. TextPos1Addr dw ? ; cursor buffer address
  112. TextPos2Addr dw ? ; cursor buffer address
  113. GrpPosAddr dw ? ; cursor buffer address
  114. OldTextPos1Addr dw ? ; Han1st/RunEsc
  115. OldTextPos2Addr dw ? ; Han1st/RunEsc
  116. OldGrpPosAddr dw ? ; Han1st/RunEsc
  117. OldChar db ?
  118. OldAttr db ?
  119. OldPage db ?
  120. OldCurPos dw ?
  121. OldCounter dw ?
  122. OldHanStat db 0
  123. EscIndex dw 0
  124. CursorStat db 0
  125. MaxRows db ?
  126. MaxPage db ?
  127. CurPos dw ? ; real position, be seted by char write
  128. CurMode db ?
  129. CurPage db ? ; function AH = 5
  130. OrgCurPos dw ? ; cursor display position for delete
  131. OrgCurType dw ? ; cursor display type for delete
  132. TimerTick db 0
  133. ScrUpDnFlag db 0 ; screen up data
  134. BlockAdj dw 0 ; block move,copy data
  135. HanSavePtr dd 7 dup(0)
  136. if WINNT
  137. WanSungCP = 949 ; For NT 5.0
  138. ActiveCodePage dw WanSungCP
  139. endif
  140. ;------------------------------------------------------------------------
  141. OldVdParms dd 0 ; MGA/CGA video parm pointer
  142. OldSavePtr dd 0 ; EGA/VGA parms pointer
  143. SizeInst equ ($ - StartInst)
  144. ;************************************
  145. OldKbInt dd 0 ; INT 9
  146. OldKbioInt dd 0 ; INT 16
  147. OldRtcInt dd 0 ; Int 8
  148. OldVideo dd 0 ; INT 10
  149. OldInt15 dd 0 ; INT 15 or HIMEM address
  150. OldInt17 dd 0 ; printer interrupt vector address
  151. IF Hwin31Sw
  152. OldInt2f dd 0 ; codechg dos int
  153. ENDIF ;Hwin31Sw
  154. ;
  155. EndSegment dw 0 ; ѱ BIOS ġ segment
  156. EndOffset dw 0 ; ѱ BIOS ġ offset
  157. ;
  158. MemStat db 0 ; memory
  159. MemSize dw 0
  160. EmsSeg dw 0
  161. EmsHandle dw 0
  162. CurEmsPage dw 0
  163. MaxMemSize dw 0
  164. HanAddr dw 0
  165. HanAddrH db 0
  166. UdcAddr dw 0
  167. UdcAddrH db 0
  168. ;
  169. Card1st db 0 ; active video card status
  170. Card2nd db 0 ; inactive video card status
  171. HeKey db 0 ; ý ѿ key
  172. HjKey db 0 ; ý key
  173. Printer db 0 ; printer type
  174. ErrStat db 0 ; initialize
  175. ;------------------------------------------------------------------------
  176. GetHan1st dw 0
  177. GetUdc1st dw 0
  178. PutUdc1st dw 0
  179. HanOn1st dw 0
  180. HanOff1st dw 0
  181. GetHan2nd dw 0
  182. GetUdc2nd dw 0
  183. PutUdc2nd dw 0
  184. HanOn2nd dw 0
  185. HanOff2nd dw 0
  186. MachineType db 0 ; machine type(AT/XT)
  187. ;------------------------------------------------------------------------
  188. public vdm_info
  189. vdm_info VDM_INFO_TBL<>
  190. if Debug
  191. public DebugData
  192. DebugData dw 0
  193. endif ; if Debug
  194. WinEnvrChange:
  195. @push ax, bx, cx, dx, di, si, es, ds, bp
  196. mov ax,cs
  197. mov es,ax
  198. mov ds,ax
  199. mov al,[CodeStat]
  200. mov [OldCodeStat],al
  201. mov ah,0fh
  202. int 10h
  203. call ChgEnvrDo
  204. @pop bp, ds, es, si, di, dx, cx, bx, ax
  205. WinEnvr PROC far
  206. ret
  207. WinEnvr ENDP
  208. ;------------------------------------------------------------------------
  209. ; initialize ٸ
  210. public TotalMenuCnt,MenuBuffer, MenuLineBuf, PatternBuf
  211. PatternBuf db 32 dup(0)
  212. TotalMenuCnt db 0
  213. MenuBuffer label byte ; hanja set buffer
  214. MenuLineBuf = MenuBuffer+376+1; hanja menu buffer
  215. ;
  216. ; Install:
  217. ; LoadUdc(-/-);
  218. ; InstallFontFileReal(-/-);
  219. ; InitMode(-/-);
  220. ; DispSignonMsg(-/-);
  221. ; [OrgHjStat] = [HjStat];
  222. ; CX = [EndSegment];
  223. ; DX = [EndOffset];
  224. ; [VideoActive] = 0;
  225. ; Restore BP, DI, SI, ES, DS;
  226. ;
  227. public Install, InitEnd
  228. Install:
  229. call LoadUdc
  230. if ComFile
  231. mov sp,offset TmpStack
  232. endif ; if ComFile
  233. call InstallFontFileReal
  234. mov al,[HjStat]
  235. test al,HjLoaded
  236. jz @f
  237. or [HjStat],HjModeEnable
  238. @@:
  239. mov [OrgHjStat],al
  240. call InitMode
  241. call DispSignonMsg
  242. mov cx,[EndSegment]
  243. mov dx,[EndOffset]
  244. mov [VideoActive],0
  245. InitEnd:
  246. if ComFile
  247. mov ah,49h
  248. mov es,ds:[EnvrParmPtr]
  249. int 21h
  250. mov ax,cs
  251. sub cx,ax
  252. add dx,15
  253. shr dx,1
  254. shr dx,1
  255. shr dx,1
  256. shr dx,1
  257. add dx,cx
  258. mov ax,3100h
  259. int 21h
  260. else
  261. pop bp
  262. pop si
  263. pop di
  264. pop es
  265. pop ds
  266. ret
  267. endif ; if ComFile
  268. ;------------------------------------------------------------------------
  269. ; << LoadUdc >>
  270. ; FUNCTION = install UDC file
  271. ; INPUT : none
  272. ; OUTPUT : none
  273. ; PROTECT : SS, SP, DS, ES
  274. ;
  275. ; LoadUdc(-/-)
  276. ; {
  277. ; }
  278. ;
  279. ; structure of header of UDCCON.SYS
  280. ; offset 00H-01H (2) : pointer of UDC map table
  281. ; offset 02H-03H (2) : size of UDC map table
  282. ; offset 04H-05H (2) : pointer of UDC index table
  283. ; offset 06H-07H (2) : size of UDC index table
  284. ; offset 08H-09H (2) : pointer of UDC set table
  285. ; offset 0aH-0bH (2) : size of UDC set table
  286. ; offset 0cH-0dH (2) : pointer of start of pattern
  287. ; offset 0eH-0fH (2) : size of pattern
  288. ; offset 10H-17H (8) : UDC file ID
  289. ; offset 18H-1fH (8) : last update date
  290. ; offset 20H-2fH (16) : reserved
  291. ;
  292. LoadUdc:
  293. test [HjStat],UdcArea
  294. jz LoadUdcEnd
  295. test [ErrStat],FontLoadErr
  296. jnz LoadUdcEnd
  297. mov dx,offset UdcFileName
  298. mov ax,3d00h
  299. int 21h
  300. mov bx,ax
  301. jnc HaveUdc
  302. LoadUdcEnd:
  303. ret
  304. HaveUdc:
  305. mov [UdcHandle],bx
  306. mov dx,[EndOffset]
  307. mov di,dx
  308. mov [UdcTblPtr],di
  309. mov cx,(30H+188*2+188*4+188*2) ; # of bytes to read
  310. mov ah,3fH
  311. int 21h
  312. jc LoadUdcErr
  313. mov ax,[di+UdcSetTblSize]
  314. shl ax,1
  315. add ax,[di+UdcSetTblPtr]
  316. add [EndOffset],ax ; save UdcTbl END address
  317. mov si,di
  318. add si,10H ; point to file identifier
  319. mov di,offset UdcConId
  320. mov cx,8 ; repeat counter
  321. rep movsw
  322. mov dx,[EndOffset]
  323. test [MemStat],RealMem
  324. jz @f
  325. mov [UdcAddr],dx ; save UdcFont address
  326. @@:
  327. mov cx,94*32
  328. mov bx,[UdcHandle]
  329. mov ah,3fH
  330. int 21h
  331. jc LoadUdcErr
  332. mov cx,ax
  333. mov si,dx
  334. mov ax,0c9a1h
  335. call WriteUdc
  336. jc LoadUdcErr
  337. mov dx,[EndOffset]
  338. mov cx,94*32
  339. mov bx,[UdcHandle]
  340. mov ah,3fH
  341. int 21h
  342. jc LoadUdcErr
  343. mov cx,ax
  344. mov si,dx
  345. mov ax,0fea1h
  346. call WriteUdc
  347. jc LoadUdcErr
  348. or [HjStat],UdcLoaded
  349. mov bx,[UdcHandle]
  350. mov ah,3eH ; close file handle
  351. int 21h
  352. ret
  353. LoadUdcErr:
  354. or [ErrStat],UdcLoadErr
  355. ret
  356. WriteUdc:
  357. test [MemStat],RealMem
  358. jz @f
  359. add [EndOffset],cx ; save END address
  360. clc
  361. ret
  362. @@:
  363. mov cx,94
  364. WriteUdcloop:
  365. mov bx,ax
  366. test [CodeStat],Chab
  367. jz @f
  368. call ChgKs2Ch
  369. @@:
  370. xchg cx,ax ; get code (ch,cl)
  371. call PutPattern
  372. xchg cx,ax
  373. mov ax,bx
  374. jc @f
  375. inc ax ; next code
  376. add si,32
  377. loop WriteUdcloop
  378. clc
  379. @@:
  380. ret
  381. UdcHandle label word
  382. UdcFileName db 'UDCCON.SYS',0
  383. TmpStack label word
  384. ;------------------------------------------------------------------------
  385. ; << InstallFontFileReal >>
  386. ; FUNCTION = ȭ real memory ġ
  387. ; INPUT : none
  388. ; OUTPUT : none
  389. ; PROTECT : SS, SP, DS, ES
  390. ;
  391. ; InstallFontFileReal(-/-)
  392. ; {
  393. ; }
  394. ;
  395. InstallFontFileReal:
  396. test [MemStat],RealMem
  397. jz NotRealFont
  398. cmp [MemSize],0
  399. jz NotRealFont
  400. mov dx,offset FontFileName
  401. mov ax,3d00h
  402. int 21h
  403. jc @f
  404. mov bx,ax
  405. mov ax,4200h
  406. xor cx,cx
  407. mov dx,30h
  408. int 21h ; set absolute file pointer
  409. or [HjStat],HjLoaded
  410. mov dx,[EndOffset]
  411. mov [HanAddr],dx
  412. xor ax,ax
  413. add [EndOffset],61440 ; 32*94*64 = 192512
  414. adc ah,0
  415. mov cl,4
  416. shl ah,cl
  417. add [EndSegment],ax
  418. add [EndSegment],2000h
  419. ReadRealLoop:
  420. mov ax,dx
  421. mov cl,4
  422. shr ax,cl
  423. mov cx,ds
  424. add cx,ax
  425. mov ds,cx
  426. and dx,0fh
  427. mov cx,4000h
  428. mov ah,3fh
  429. int 21h
  430. jc ReadRealErr
  431. or ax,ax
  432. jz @f
  433. add dx,ax
  434. jmp short ReadRealLoop
  435. ReadRealErr:
  436. or cs:[ErrStat],FontLoadErr
  437. @@:
  438. mov ax,cs
  439. mov ds,ax
  440. mov ah,3eh
  441. int 21h
  442. NotRealFont:
  443. ret
  444. ;------------------------------------------------------------------------
  445. ; << InitMode >>
  446. ; FUNCTION = ѱ video mode ʱȭ
  447. ; INPUT : none
  448. ; OUTPUT : none
  449. ; PROTECT : SS, SP, DS, ES
  450. ;
  451. ; InitMode(-/-)
  452. ; {
  453. ; Save ES;
  454. ; ES = 0;
  455. ; if ([Card1st] == DualMnt)
  456. ; {
  457. ; xchg [Card1st], [Card2nd];
  458. ; ES:[rEquip] = ES:[rEquip] || 00110000b;
  459. ; if ([Card1st] == ColorMnt)
  460. ; ES:[rEquip] = ES:[rEquip] && 11101111b;
  461. ; AX = 3;
  462. ; INT 10h;
  463. ; xchg [Card1st], [Card2nd];
  464. ; }
  465. ; ES:[rEquip] = ES:[rEquip] || 00110000b;
  466. ; if ([Card1st] == ColorMnt)
  467. ; ES:[rEquip] = ES:[rEquip] && 11101111b;
  468. ; AX = 3;
  469. ; INT 10h;
  470. ; Restore ES;
  471. ; }
  472. ;
  473. InitMode:
  474. test [Card1st],DualMnt
  475. jz InitMode1st
  476. push word ptr [CodeStat]
  477. or [CodeStat],HangeulMode
  478. int 11h
  479. cmp al,00110000b
  480. mov ax,7
  481. jpe @f
  482. mov al,3
  483. @@:
  484. int 10h
  485. pop ax
  486. mov [CodeStat],al
  487. InitMode1st:
  488. mov ah,0fh
  489. int 10h
  490. call ChgEnvrDo
  491. push ax
  492. push bx
  493. call SearchMode
  494. jc InitMode2nd
  495. mov bh,[si+sCodeVram]
  496. xor bl,bl
  497. xor ax,ax
  498. mov word ptr [CodeBuf1Addr],ax
  499. mov word ptr [CodeBuf1Addr+2],bx
  500. if WINNT ; if we run HBIOS on windowed mode for the first time,
  501. ; these variables are not initialized.
  502. cmp [ActiveCodePage], WanSungCP
  503. jnz @f
  504. or [CodeStat],HangeulVideoMode
  505. mov [MaxRows],25
  506. @@:
  507. endif
  508. InitMode2nd:
  509. pop bx
  510. pop ax
  511. ret
  512. ;------------------------------------------------------------------------
  513. ; << DispSignonMsg >>
  514. ; FUNCTION = ѱ BIOS ۱ font/UDC message display
  515. ; INPUT : none
  516. ; OUTPUT : none
  517. ; PROTECT : SS, SP, DS, ES
  518. ;
  519. ; DispSignonMsg(-/-)
  520. ; {
  521. ; SI = SignonMsg;
  522. ; DispMsg(SI/-);
  523. ; if ([OrgHjStat] == HjLoaded)
  524. ; {
  525. ; SI = FontMsg;
  526. ; DispMsg(SI/-);
  527. ; SI = LoadMsg;
  528. ; if ([ErrStat] == FontLoadErr), SI = FontErrMsg;
  529. ; DispMsg(SI/-);
  530. ; }
  531. ; if ([OrgHjStat] == UdcLoaded)
  532. ; {
  533. ; SI = UdcMsg;
  534. ; DispMsg(SI/-);
  535. ; SI = UdcConId;
  536. ; if ([ErrStat] == UdcLoadErr), SI = UdcErrMsg;
  537. ; DispMsg(SI/-);
  538. ; }
  539. ; }
  540. ;
  541. ; DispString(si/-)
  542. ; {
  543. ; if ([si] != 0)
  544. ; {
  545. ; AL = [si];
  546. ; + SI;
  547. ; AH = 0eh;
  548. ; BX = 7;
  549. ; INT 10h;
  550. ; }
  551. ; }
  552. ;
  553. DispSignonMsg:
  554. if WINNT
  555. ; Don't need to display version information
  556. test [ErrStat],FontLoadErr
  557. jz @f
  558. mov si,offset FontErrMsg
  559. call DispString
  560. @@:
  561. test [Card1st],FontCard or HanCard
  562. jnz DispNoneFontFile
  563. test [Card2nd],FontCard or HanCard
  564. jnz DispNoneFontFile
  565. test [OrgHjStat],HjLoaded
  566. jz DispNoneFontFile
  567. else
  568. mov si,offset SignonMsg
  569. test [CodeStat],Chab
  570. jz @f
  571. mov si,offset SignonMsgCh
  572. @@:
  573. call DispString
  574. test [Card1st],FontCard or HanCard
  575. jnz DispNoneFontFile
  576. test [Card2nd],FontCard or HanCard
  577. jnz DispNoneFontFile
  578. test [OrgHjStat],HjLoaded
  579. jz DispNoneFontFile
  580. ;mov si,offset FontMsg
  581. ;call DispString
  582. mov si,offset LoadMsg
  583. test [ErrStat],FontLoadErr
  584. jz @f
  585. mov si,offset FontErrMsg
  586. @@:
  587. call DispString
  588. endif
  589. DispNoneFontFile:
  590. test [OrgHjStat],UdcLoaded
  591. jz DispNoneUdc
  592. mov si,offset UdcMsg
  593. call DispString
  594. mov si,offset UdcConId
  595. test [ErrStat],UdcLoadErr
  596. jz @f
  597. mov si,offset UdcErrMsg
  598. @@:
  599. call DispString
  600. DispNoneUdc:
  601. ret
  602. DispString:
  603. lodsb
  604. or al,al
  605. jz @f
  606. mov ah,0eh
  607. mov bx,7
  608. int 10h
  609. jmp short DispString
  610. @@:
  611. ret
  612. if WINNT
  613. ; Don't need to display version information
  614. else
  615. SignonMsg db 'HBIOS ', Version, cr,lf ; [CHM0]
  616. db 'Copyright (C) Microsoft Corp 1993',cr,lf,0 ; [CHM0]
  617. SignonMsgCh db 'HBIOS e ', Version, cr,lf
  618. db 'Copyright (C) Microsoft Corp 1993',cr,lf,0
  619. LoadMsg db '** Ȯ ۲ ġǾϴ.',cr,lf,0
  620. endif
  621. UdcErrMsg label byte
  622. FontErrMsg db '** Ȯ ۲ ġ Ͽϴ.',cr,lf,0
  623. UdcMsg db 'UDC : ',0
  624. UdcConId db 16 dup(' '),cr,lf,0
  625. public FontFilename
  626. FontFilename db 'hfont.sys' ; [CHM001]
  627. db 80-8 dup(0)
  628. ;------------------------------------------------------------------------
  629.