1 ; **************************************************************************** 2 ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.10 3 ; ---------------------------------------------------------------------------- 4 ; Last Update: 28/01/2025 (Previous: 29/12/2024) 5 ; ---------------------------------------------------------------------------- 6 ; Beginning: 04/01/2016 7 ; ---------------------------------------------------------------------------- 8 ; Assembler: NASM version 2.15 (trdos386.s) 9 ; ---------------------------------------------------------------------------- 10 ; Turkish Rational DOS 11 ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016) 12 ; 13 ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan 14 ; unix386.s (03/01/2016) 15 ; 16 ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan 17 ; TRDOS2.ASM (09/11/2011) 18 ; 19 ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 20 ; **************************************************************************** 21 ; nasm trdos386.s -l trdos386.txt -o TRDOS386.SYS 22 23 KLOAD equ 10000h ; Kernel loading address 24 ; NOTE: Retro UNIX 8086 v1 boot code loads kernel at 1000h:0000h 25 KCODE equ 08h ; Code segment descriptor (ring 0) 26 KDATA equ 10h ; Data segment descriptor (ring 0) 27 ; 19/03/2015 28 UCODE equ 1Bh ; 18h + 3h (ring 3) 29 UDATA equ 23h ; 20h + 3h (ring 3) 30 ; 24/03/2015 31 TSS equ 28h ; Task state segment descriptor (ring 0) 32 ; 19/03/2015 33 CORE equ 400000h ; Start of USER's virtual/linear address space 34 ; (at the end of the 1st 4MB) 35 ECORE equ 0FFC00000h ; End of USER's virtual address space (4GB - 4MB) 36 ; ULIMIT = (ECORE/4096) - 1 = 0FFBFFh (in GDT) 37 ;; 27/12/2013 38 ;KEND equ KLOAD + 65536 ; (28/12/2013) (end of kernel space) 39 ; 04/07/2016 40 KEND equ KERNELFSIZE + KLOAD 41 42 ; IBM PC/AT BIOS ----- 10/06/85 (postequ.inc) 43 ;--------- CMOS TABLE LOCATION ADDRESS'S ------------------------------------- 44 CMOS_SECONDS EQU 00H ; SECONDS (BCD) 45 CMOS_SEC_ALARM EQU 01H ; SECONDS ALARM (BCD) 46 CMOS_MINUTES EQU 02H ; MINUTES (BCD) 47 CMOS_MIN_ALARM EQU 03H ; MINUTES ALARM (BCD) 48 CMOS_HOURS EQU 04H ; HOURS (BCD 49 CMOS_HR_ALARM EQU 05H ; HOURS ALARM (BCD) 50 CMOS_DAY_WEEK EQU 06H ; DAY OF THE WEEK (BCD) 51 CMOS_DAY_MONTH EQU 07H ; DAY OF THE MONTH (BCD) 52 CMOS_MONTH EQU 08H ; MONTH (BCD) 53 CMOS_YEAR EQU 09H ; YEAR (TWO DIGITS) (BCD) 54 CMOS_CENTURY EQU 32H ; DATE CENTURY BYTE (BCD) 55 CMOS_REG_A EQU 0AH ; STATUS REGISTER A 56 CMOS_REG_B EQU 0BH ; STATUS REGISTER B ALARM 57 CMOS_REG_C EQU 0CH ; STATUS REGISTER C FLAGS 58 CMOS_REG_D EQU 0DH ; STATUS REGISTER D BATTERY 59 CMOS_SHUT_DOWN EQU 0FH ; SHUTDOWN STATUS COMMAND BYTE 60 ;---------------------------------------- 61 ; CMOS EQUATES FOR THIS SYSTEM ; 62 ;----------------------------------------------------------------------------- 63 CMOS_PORT EQU 070H ; I/O ADDRESS OF CMOS ADDRESS PORT 64 CMOS_DATA EQU 071H ; I/O ADDRESS OF CMOS DATA PORT 65 NMI EQU 10000000B ; DISABLE NMI INTERRUPTS MASK - 66 ; HIGH BIT OF CMOS LOCATION ADDRESS 67 68 ; Memory Allocation Table Address 69 ; 05/11/2014 70 ; 31/10/2014 71 MEM_ALLOC_TBL equ 100000h ; Memory Allocation Table at the end of 72 ; the 1st 1 MB memory space. 73 ; (This address must be aligned 74 ; on 128 KB boundary, if it will be 75 ; changed later.) 76 ; ((lower 17 bits of 32 bit M.A.T. 77 ; address must be ZERO)). 78 ; ((((Reason: 32 bit allocation 79 ; instructions, dword steps))) 80 ; (((byte >> 12 --> page >> 5))) 81 ;04/11/2014 82 PDE_A_PRESENT equ 1 ; Present flag for PDE 83 PDE_A_WRITE equ 2 ; Writable (write permission) flag 84 PDE_A_USER equ 4 ; User (non-system/kernel) page flag 85 ; 86 PTE_A_PRESENT equ 1 ; Present flag for PTE (bit 0) 87 PTE_A_WRITE equ 2 ; Writable (write permission) flag (bit 1) 88 PTE_A_USER equ 4 ; User (non-system/kernel) page flag (bit 2) 89 PTE_A_ACCESS equ 32 ; Accessed flag (bit 5) ; 09/03/2015 90 91 ; 17/02/2015 (unix386.s) 92 ; 10/12/2014 - 30/12/2014 (0B000h -> 9000h) (dsectrm2.s) 93 DPT_SEGM equ 09000h ; FDPT segment (EDD v1.1, EDD v3) 94 ; 95 HD0_DPT equ 0 ; Disk parameter table address for hd0 96 HD1_DPT equ 32 ; Disk parameter table address for hd1 97 HD2_DPT equ 64 ; Disk parameter table address for hd2 98 HD3_DPT equ 96 ; Disk parameter table address for hd3 99 100 ; 15/11/2020 101 VBE3INFOSEG equ 97E0h ; 512 bytes before Video_Pg_Backup 102 ; 15/12/2020 103 VBE3MODEINFOSEG equ 97C0h ; 512 bytes before VBE3INFOBLOCK 104 105 ; 29/11/2020 106 VBE3INFOBLOCK equ 97E00h ; linear address (512 bytes) 107 VBE3MODEINFOBLOCK equ 97C00h ; linear address (256 bytes) 108 VBE3SAVERESTOREBLOCK equ 97600h ; linear address (2048 bytes) 109 VBE3CRTCINFOBLOCK equ 97D80h ; linear address (64 bytes) ; 17/01/2021 110 VBE3BIOSDATABLOCK equ 97000h ; linear address (1536 bytes) 111 VBE3STACKADDR equ 96000h ; linear address (1024 bytes) 112 ; VBE3 32 bit Protected Mode Interface (16 bit) Selectors (in GDT) 113 VBE3CS equ 30h ; _vbe3_CS: 114 VBE3BDS equ 38h ; _vbe3_BDS: 115 VBE3A000 equ 40h ; _A0000Sel: 116 VBE3B000 equ 48h ; _B0000Sel: 117 VBE3B800 equ 50h ; _B8000Sel: 118 VBE3DS equ 58h ; _vbe3_DS: 119 VBE3SS equ 60h ; _vbe3_SS: 120 VBE3ES equ 68h ; _vbe3_ES: 121 KCODE16 equ 70h ; _16bit_CS: 122 ; 14/01/2021 123 ; 06/12/2020 124 VBE3VIDEOSTATE equ 95800h ; 2048 bytes 125 ; 05/01/2021 126 VGAFONT16USER equ 94000h ; 8x16 pixels user font (256 chars) 127 ; (reserved/allocated font space: 4096 bytes) 128 129 VGAFONT8USER equ 95000h ; 8x8 pixels user font (256 chars) 130 ; (reserved/allocated font space: 2048 bytes) 131 ; 17/01/2021 132 ; temporary (initial) location for EDID information 133 VBE3EDIDINFOBLOCK equ 97D00h ; linear address (128 bytes) 134 135 ; FDPT (Phoenix, Enhanced Disk Drive Specification v1.1, v3.0) 136 ; (HDPT: Programmer's Guide to the AMIBIOS, 1993) 137 ; 138 FDPT_CYLS equ 0 ; 1 word, number of cylinders 139 FDPT_HDS equ 2 ; 1 byte, number of heads 140 FDPT_TT equ 3 ; 1 byte, A0h = translated FDPT with logical values 141 ; otherwise it is standard FDPT with physical values 142 FDPT_PCMP equ 5 ; 1 word, starting write precompensation cylinder 143 ; (obsolete for IDE/ATA drives) 144 FDPT_CB equ 8 ; 1 byte, drive control byte 145 ; Bits 7-6 : Enable or disable retries (00h = enable) 146 ; Bit 5 : 1 = Defect map is located at last cyl. + 1 147 ; Bit 4 : Reserved. Always 0 148 ; Bit 3 : Set to 1 if more than 8 heads 149 ; Bit 2-0 : Reserved. Always 0 150 FDPT_LZ equ 12 ; 1 word, landing zone (obsolete for IDE/ATA drives) 151 FDPT_SPT equ 14 ; 1 byte, sectors per track 152 153 ; Floppy Drive Parameters Table (Programmer's Guide to the AMIBIOS, 1993) 154 ; (11 bytes long) will be used by diskette handler/bios 155 ; which is derived from IBM PC-AT BIOS (DISKETTE.ASM, 21/04/1986). 156 157 ; 01/02/2016 158 Logical_DOSDisks equ 90000h + 100h ; 26*256 = 6656 bytes 159 Directory_Buffer equ 80000h ; max = 64K Bytes 160 FAT_Buffer equ 91C00h ; 1536 bytes (3 sectors) 161 ; 15/02/2016 162 Cluster_Buffer equ 70000h ; max = 64K Bytes ; buffer for file read & write 163 ; 11/04/2016 164 Env_Page: equ 93000h ; 512 bytes (4096 bytes) 165 Env_Page_Size equ 512 ; (4096 bytes) 166 ; 30/07/2016 167 Video_Pg_Backup equ 98000h ; Mode 3h, video page backup (32K, 8 pages) 168 169 ; 29/11/2020 170 ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 96000h (available) 171 ; 06/12/2020 172 ; Free/Reserved memory blocks (in 1st 1MB): 93200h to 95800h (available) 173 174 ; 15/12/2020 175 LFB_ADDR equ LFB_Info+LFBINFO.LFB_addr 176 LFB_SIZE equ LFB_Info+LFBINFO.LFB_size 177 178 ; 04/12/2023 - TRDOS 386 v2.0.7 179 SYSTEMSTACK_ADDR equ 97000h ; max. 3072 bytes (96400h-97000h) 180 VBE3BIOSCODE_ADDR equ 60000h ; Protected Mode Video Bios (64KB) 181 ;AC97DMABUFFR_ADDR equ 40000h ; AC97 & VIA VT8233 DMA Buffer (128KB) 182 SB16DMABUFFR_ADDR equ 50000h ; Sound Blaster 16 DMA Buffer (64KB) 183 sb16_dma_buffer equ SB16DMABUFFR_ADDR 184 185 ; 29/08/2023 - TRDOS 386 v2.0.6 186 ; 30/11/2020 187 ; 29/11/2020 - TRDOS 386 v2.0.3 188 189 struc PMInfo ; VESA VBE3 PMInfoBlock ('PMID' block) 190 191 00000000 ???????? .Signature: resb 4 ; db 'PMID' ; PM Info Block Signature 192 00000004 ???? .EntryPoint: resw 1 ; Offset of PM entry point within BIOS 193 00000006 ???? .PMInitialize: resw 1 ; Offset of PM initialization entry point 194 00000008 ???? .BIOSDataSel: resw 1 ; Selector to BIOS data area emulation block 195 0000000A ???? .A0000Sel: resw 1 ; Selector to access A0000h physical mem 196 0000000C ???? .B0000Sel: resw 1 ; Selector to access B0000h physical mem 197 0000000E ???? .B8000Sel: resw 1 ; Selector to access B8000h physical mem 198 00000010 ???? .CodeSegSel: resw 1 ; Selector to access code segment as data 199 00000012 ?? .InProtectMode: resb 1 ; Set to 1 when in protected mode 200 00000013 ?? .Checksum: resb 1 ; Checksum byte for structure 201 .size: 202 203 endstruc 204 205 [BITS 16] ; We need 16-bit intructions for Real mode 206 207 [ORG 0] 208 ; 12/11/2014 209 ; Save boot drive number (that is default root drive) 210 00000000 8816[3866] mov [boot_drv], dl ; physical drv number 211 212 ; Determine installed memory 213 ; 31/10/2014 214 ; 215 00000004 B801E8 mov ax, 0E801h ; Get memory size 216 00000007 CD15 int 15h ; for large configurations 217 00000009 7308 jnc short chk_ms 218 0000000B B488 mov ah, 88h ; Get extended memory size 219 0000000D CD15 int 15h 220 ; 221 ;mov al, 17h ; Extended memory (1K blocks) low byte 222 ;out 70h, al ; select CMOS register 223 ;in al, 71h ; read data (1 byte) 224 ;mov cl, al 225 ;mov al, 18h ; Extended memory (1K blocks) high byte 226 ;out 70h, al ; select CMOS register 227 ;in al, 71h ; read data (1 byte) 228 ;mov ch, al 229 ; 230 0000000F 89C1 mov cx, ax 231 00000011 31D2 xor dx, dx 232 chk_ms: 233 00000013 890E[3466] mov [mem_1m_1k], cx 234 00000017 8916[3666] mov [mem_16m_64k], dx 235 ; 24/11/2023 236 0000001B 8916[180F] mov [real_mem_16m_64k], dx 237 238 ; 05/11/2014 239 ;and dx, dx 240 ;jz short L2 241 0000001F 81F90004 cmp cx, 1024 242 ;jnb short L0 243 00000023 7351 jnb short V0 ; 14/11/2020 244 ; insufficient memory_error 245 ; Minimum 2 MB memory is needed... 246 ; 05/11/2014 247 ; (real mode error printing) 248 00000025 FB sti 249 00000026 BE[3A00] mov si, msg_out_of_memory 250 00000029 BB0700 mov bx, 7 251 0000002C B40E mov ah, 0Eh ; write tty 252 oom_1: 253 0000002E AC lodsb 254 0000002F 08C0 or al, al 255 00000031 7404 jz short oom_2 256 00000033 CD10 int 10h 257 00000035 EBF7 jmp short oom_1 258 oom_2: 259 00000037 F4 hlt 260 00000038 EBFD jmp short oom_2 261 262 ; 20/02/2017 263 ; 05/11/2014 264 msg_out_of_memory: 265 0000003A 070D0A db 07h, 0Dh, 0Ah 266 0000003D 496E73756666696369- db 'Insufficient memory !' 266 00000046 656E74206D656D6F72- 266 0000004F 792021 267 00000052 0D0A db 0Dh, 0Ah 268 _int13h_48h_buffer: ; 07/07/2016 269 00000054 284D696E696D756D20- db '(Minimum 2MB memory is needed.)' 269 0000005D 324D42206D656D6F72- 269 00000066 79206973206E656564- 269 0000006F 65642E29 270 00000073 0D0A00 db 0Dh, 0Ah, 0 271 V0: 272 ; 18/10/2023 - TRDOS 386 v2.0.7 273 ; set video mode to 03h again 274 ; (to reset video bios data in ROMBIOS DATA AREA) 275 00000076 B80300 mov ax, 3 276 00000079 CD10 int 10h 277 ; copy IVT and ROMBIOS DATA AREA to VBE3 BIOS data area 278 0000007B BF0097 mov di, VBE3BIOSDATABLOCK>>4 279 0000007E 8EC7 mov es, di 280 00000080 31F6 xor si, si 281 00000082 31FF xor di, di 282 00000084 8EDE mov ds, si ; 0 283 00000086 B90003 mov cx, 300h ; 600h / 2 284 00000089 F3A5 rep movsw 285 0000008B 0E push cs 286 0000008C 1F pop ds 287 288 ; 24/11/2023 289 ; 15/12/2020 290 ;mov si, [mem_16m_64k] 291 ;mov [real_mem_16m_64k], si 292 293 ; 15/11/2020 294 ; 14/11/2020 (TRDOS 386 v2.0.3) 295 ; check VESA (VBE) VIDEO BIOS version 296 297 0000008D B8034F mov ax, 4F03h ; Return current VBE mode 298 00000090 CD10 int 10h 299 00000092 83F84F cmp ax, 004Fh ; successful (vbe) function call 300 ;jne short L0 ; not a VESA VBE compatible bios 301 ; 18/10/2023 302 00000095 7561 jne short V1 ; restore es 303 304 ; 27/11/2023 305 ; 24/11/2023 - temporary 306 ;jmp short V1 307 308 ;mov ah, 3 309 ;;jmp short V1 310 311 ; 15/11/2020 312 00000097 BBE097 mov bx, VBE3INFOSEG ; 97E0h for current version 313 0000009A 8EC3 mov es, bx 314 0000009C 31FF xor di, di 315 0000009E 2666C70556424532 mov dword [es:di], 'VBE2' ; request VESA VBE3 info 316 ; es:di = buffer address (512 bytes) 317 ;mov ax, 4F00h ; Return VBE controller information 318 000000A6 86E0 xchg al, ah 319 000000A8 CD10 int 10h 320 321 ; dx = cs 322 ; es = VBE3INFOSEG (97E0h) 323 ; di = 0 324 ; ss = (endofkernelfile/16)+16 325 ; sp = 0FFFEh 326 327 000000AA 83F84F cmp ax, 004Fh 328 000000AD 7549 jne short V1 ; old vga bios (not VESA compatible) 329 330 ; 15/11/2020 331 000000AF 2666813D56455341 cmp dword [es:di], 'VESA' 332 000000B7 753F jne short V1 333 334 ;mov ax, [es:di+4] 335 ; ; ax = vbe version in BCD format (0200h or 0300h) 336 ;mov [vbe3], ah ; version number (major) 337 338 ; 15/11/2020 339 000000B9 268A4505 mov al, [es:di+5] 340 ; al = high byte of VBE version number (02h or 03h) 341 342 000000BD A2[8609] mov [vbe3], al ; version number (major) 343 ; 02h or 03h is expected 344 ; 17/01/2021 345 ; Read EDID 346 000000C0 B301 mov bl, 01h ; Read EDID 347 000000C2 31C9 xor cx, cx ; Controller unit number 348 ; (00 = primary controller) 349 000000C4 31D2 xor dx, dx ; EDID block number = 0 350 000000C6 B8C097 mov ax, VBE3MODEINFOSEG ; 97C0h for current version 351 000000C9 8EC0 mov es, ax 352 000000CB BF0001 mov di, VBE3EDIDINFOBLOCK - VBE3MODEINFOBLOCK 353 ; es:di = temporary address of 128 bytes EDID information 354 000000CE B8154F mov ax, 4F15h ; VBE/DDC Services 355 000000D1 CD10 int 10h 356 ;cmp ax, 4Fh 357 ;jne short v2 358 000000D3 A2[D341] mov [edid], al ; 4Fh > 0 359 ;V2: 360 ; 17/01/2021 361 000000D6 31FF xor di, di 362 ; 15/12/2020 363 ; Get linear frame buffer info (for VESA VBE mode 118h) 364 ;mov si, VBE3MODEINFOSEG ; 97C0h for current version 365 ;mov es, si 366 ; di = 0 367 000000D8 B91841 mov cx, 04118h ; 1024*768, 24 bpp, LFB 368 000000DB B8014F mov ax, 4F01h ; Return VBE mode information 369 000000DE CD10 int 10h 370 ;cmp ax, 4Fh 371 ;jne short V1 372 ; 19/12/2020 373 ;mov si, [es:di+MODEINFO.PhysBasePtr+2] 374 ; hw of LFB base address 375 ; MODEINFO structure starts from offset -2 376 000000E0 268B752A mov si, [es:di+MODEINFO.PhysBasePtr] ; hw of LFB addr 377 000000E4 8936[1A0F] mov [def_LFB_addr], si ; k_LFB_size = 3145728 bytes 378 000000E8 81EE0001 sub si, 256 379 380 ; 15/12/2020 381 ; check memory and decrease it to 3.5 GB if it is 4GB 382 ; (reserve upper memory for LFB) 383 000000EC 8B3E[3666] mov di, [mem_16m_64k] 384 ; 24/11/2023 385 ;mov [real_mem_16m_64k], di 386 387 000000F0 39F7 cmp di, si 388 000000F2 7604 jna short V1 389 390 000000F4 8936[3666] mov [mem_16m_64k], si 391 392 ; VESA VBE3 video hardware 393 ; (example: NVIDIA GEFORCE FX550, 256 MB) 394 ; uses upper memory from 0D0000000h to 0DFFFFFFFh 395 396 ;;cmp di, 0CF00h ; 3328 MB - 16MB 397 ;jna short V1 ; <= 3328 MB memory, it is not required 398 ; decrease 399 ;cmp al, 3 400 ;jb short V2 401 ; VESA VBE 3 402 ;mov word [mem_16m_64k], 0CF00h ; 3328 MB - 16MB 403 ;jmp short V1 404 ;V2: 405 ; VESA VBE 2 406 ; Check Bochs/Qemu/VirtualBox Emulator 407 ; LFB base address: 0E0000000h 408 ;sub ax, ax ; 0 409 ;mov dx, 1CEh ; VBE_DISPI_IOPORT_INDEX 410 ;out dx, ax ; VBE_DISPI_INDEX_ID register 411 ;inc dx 412 ;in ax, dx 413 ;and al, 0F0h 414 ;cmp ax, 0B0C0h 415 ;jne short V1 416 ; 417 ; BOCHS/QEMU/VIRTUALBOX 418 ;mov word [mem_16m_64k], 0DF00h ; 3584 MB - 16MB 419 V1: 420 000000F8 1E push ds 421 000000F9 07 pop es ; restore extra data segment 422 L0: 423 424 %include 'diskinit.s' ; 07/03/2015 1 <1> ; **************************************************************************** 2 <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskinit.s 3 <1> ; ---------------------------------------------------------------------------- 4 <1> ; Last Update: 09/08/2022 (Previous: 29/08/2020 - Kernel v2.0.4) 5 <1> ; ---------------------------------------------------------------------------- 6 <1> ; Beginning: 24/01/2016 7 <1> ; ---------------------------------------------------------------------------- 8 <1> ; Assembler: NASM version 2.15 (trdos386.s) 9 <1> ; ---------------------------------------------------------------------------- 10 <1> ; Turkish Rational DOS 11 <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016) 12 <1> ; 13 <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan 14 <1> ; diskinit.inc (10/07/2015) 15 <1> ; 16 <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 17 <1> ; **************************************************************************** 18 <1> 19 <1> ; Retro UNIX 386 v1 Kernel - DISKINIT.INC 20 <1> ; Last Modification: 12/07/2022 (Previous: 10/07/2015) 21 <1> 22 <1> ; DISK I/O SYSTEM INITIALIZATION - Erdogan Tan (Retro UNIX 386 v1 project) 23 <1> 24 <1> ; ///////// DISK I/O SYSTEM STRUCTURE INITIALIZATION /////////////// 25 <1> 26 <1> ; 09/08/2022 27 <1> ; 08/08/2022 28 <1> ; 14/07/2022 (TRDOS 386 v2.0.5) 29 <1> ; 12/07/2022 (Retro UNIX 386 v1.2) 30 <1> ; 29/08/2020 31 <1> ; 17/07/2020 32 <1> ; 14/07/2020 (TRDOS 386 v2.0.2) 33 <1> ; 10/12/2014 - 02/02/2015 - dsectrm2.s 34 <1> ;L0: 35 <1> ; 12/11/2014 (Retro UNIX 386 v1 - beginning) 36 <1> ; Detecting disk drives... (by help of ROM-BIOS) 37 000000FA BA7F00 <1> mov dx, 7Fh 38 <1> L1: 39 000000FD FEC2 <1> inc dl 40 000000FF B441 <1> mov ah, 41h ; Check extensions present 41 <1> ; Phoenix EDD v1.1 - EDD v3 42 00000101 BBAA55 <1> mov bx, 55AAh 43 00000104 CD13 <1> int 13h 44 00000106 721A <1> jc short L2 45 <1> 46 00000108 81FB55AA <1> cmp bx, 0AA55h 47 0000010C 7514 <1> jne short L2 48 0000010E FE06[3B66] <1> inc byte [hdc] ; count of hard disks (EDD present) 49 00000112 8816[3A66] <1> mov [last_drv], dl ; last hard disk number 50 00000116 BB[BE65] <1> mov bx, hd0_type - 80h 51 00000119 01D3 <1> add bx, dx 52 0000011B 880F <1> mov [bx], cl ; Interface support bit map in CX 53 <1> ; Bit 0 - 1, Fixed disk access subset ready 54 <1> ; Bit 1 - 1, Drv locking and ejecting ready 55 <1> ; Bit 2 - 1, Enhanced Disk Drive Support 56 <1> ; (EDD) ready (DPTE ready) 57 <1> ; Bit 3 - 1, 64bit extensions are present 58 <1> ; (EDD-3) 59 <1> ; Bit 4 to 15 - 0, Reserved 60 0000011D 80FA83 <1> cmp dl, 83h ; drive number < 83h 61 00000120 72DB <1> jb short L1 62 <1> L2: 63 <1> ; 23/11/2014 64 <1> ; 19/11/2014 65 00000122 30D2 <1> xor dl, dl ; 0 66 <1> ; 04/02/2016 (esi -> si) 67 00000124 BE[3C66] <1> mov si, fd0_type 68 <1> L3: 69 <1> ; 14/01/2015 70 00000127 8816[3966] <1> mov [drv], dl 71 <1> ; 72 0000012B B408 <1> mov ah, 08h ; Return drive parameters 73 0000012D CD13 <1> int 13h 74 0000012F 7210 <1> jc short L4 75 <1> ; BL = drive type (for floppy drives) 76 <1> ; DL = number of floppy drives 77 <1> ; 78 <1> ; ES:DI = Address of DPT from BIOS 79 <1> ; 80 00000131 881C <1> mov [si], bl ; Drive type 81 <1> ; 4 = 1.44 MB, 80 track, 3 1/2" 82 <1> ; 14/01/2015 83 00000133 E8DD01 <1> call set_disk_parms 84 <1> ; 10/12/2014 85 00000136 81FE[3C66] <1> cmp si, fd0_type 86 0000013A 7705 <1> ja short L4 87 0000013C 46 <1> inc si ; fd1_type 88 0000013D B201 <1> mov dl, 1 89 0000013F EBE6 <1> jmp short L3 90 <1> L4: 91 00000141 B27F <1> mov dl, 7Fh 92 <1> ; 24/12/2014 93 00000143 803E[3B66]00 <1> cmp byte [hdc], 0 ; EDD present or not ? 94 <1> ;ja L10 ; yes, all fixed disk operations 95 <1> ; will be performed according to 96 <1> ; present EDD specification 97 <1> ; 14/07/2022 98 00000148 7603 <1> jna short L5 99 0000014A E98B00 <1> jmp L10 100 <1> 101 <1> L5: 102 <1> ; 17/07/2020 103 <1> ; Note: Virtual CPU will not come here while 104 <1> ; running in QEMU, Bochs, VirtualBox emulators !!! 105 <1> 106 <1> ; 17/07/2020 107 <1> ; Older BIOS (INT 13h, AH = 48h is not available) 108 <1> 109 0000014D FEC2 <1> inc dl 110 0000014F 8816[3966] <1> mov [drv], dl 111 00000153 8816[3A66] <1> mov [last_drv], dl ; 14/01/2015 112 00000157 B408 <1> mov ah, 08h ; Return drive parameters 113 00000159 CD13 <1> int 13h ; (conventional function) 114 <1> ;jc L13 ; fixed disk drive not ready 115 <1> ; 14/07/2022 116 0000015B 7303 <1> jnc short L6 117 0000015D E9A501 <1> jmp L13 118 <1> L6: 119 00000160 8816[3B66] <1> mov [hdc], dl ; number of drives 120 <1> ;; 14/01/2013 121 <1> ;;push cx 122 00000164 E8AC01 <1> call set_disk_parms 123 <1> ;;pop cx 124 <1> ; 125 <1> ;;and cl, 3Fh ; sectors per track (bits 0-6) 126 00000167 8A16[3966] <1> mov dl, [drv] 127 0000016B BB0401 <1> mov bx, 65*4 ; hd0 parameters table (INT 41h) 128 0000016E 80FA80 <1> cmp dl, 80h 129 00000171 7603 <1> jna short L7 130 00000173 83C314 <1> add bx, 5*4 ; hd1 parameters table (INT 46h) 131 <1> L7: 132 00000176 31C0 <1> xor ax, ax 133 00000178 8ED8 <1> mov ds, ax 134 0000017A 8B37 <1> mov si, [bx] 135 0000017C 8B4702 <1> mov ax, [bx+2] 136 0000017F 8ED8 <1> mov ds, ax 137 00000181 3A4C0E <1> cmp cl, [si+FDPT_SPT] ; sectors per track 138 <1> ;jne L12 ; invalid FDPT 139 <1> ; 14/07/2022 140 00000184 7403 <1> je short L7_8 141 00000186 E97801 <1> jmp L12 142 <1> L7_8: 143 00000189 BF0000 <1> mov di, HD0_DPT 144 0000018C 80FA80 <1> cmp dl, 80h 145 0000018F 7603 <1> jna short L8 146 00000191 BF2000 <1> mov di, HD1_DPT 147 <1> L8: 148 <1> ; 30/12/2014 149 00000194 B80090 <1> mov ax, DPT_SEGM 150 00000197 8EC0 <1> mov es, ax 151 <1> ; 24/12/2014 152 00000199 B90800 <1> mov cx, 8 153 0000019C F3A5 <1> rep movsw ; copy 16 bytes to the kernel's DPT location 154 0000019E 8CC8 <1> mov ax, cs 155 000001A0 8ED8 <1> mov ds, ax 156 <1> 157 <1> ; 02/02/2015 158 <1> ;mov cl, [drv] 159 <1> ;mov bl, cl 160 <1> ;mov ax, 1F0h 161 <1> ;and bl, 1 162 <1> ;jz short L9 163 <1> ;shl bl, 4 164 <1> ;sub ax, 1F0h-170h 165 <1> 166 <1> ; 17/07/2020 167 <1> ; (Only 1F0h port address must be valid for old ROM BIOSes) 168 000001A2 B8F001 <1> mov ax, 1F0h 169 000001A5 B3A0 <1> mov bl, 0A0h 170 000001A7 80FA80 <1> cmp dl, 80h 171 000001AA 7603 <1> jna short L9 172 <1> ; dl = 81h 173 000001AC 80C310 <1> add bl, 10h ; slave disk 174 <1> ;sub ax, 1F0h-170h 175 <1> L9: 176 000001AF AB <1> stosw ; I/O PORT Base Address (1F0h, 170h) 177 000001B0 050602 <1> add ax, 206h 178 000001B3 AB <1> stosw ; CONTROL PORT Address (3F6h, 376h) 179 000001B4 88D8 <1> mov al, bl ; bit 4, master/slave disk bit 180 <1> ;add al, 0A0h ; 17/07/2020 181 000001B6 AA <1> stosb ; Device/Head Register upper nibble 182 <1> ; 183 000001B7 FE06[3966] <1> inc byte [drv] 184 <1> ;mov bx, hd0_type - 80h 185 <1> ;add bx, cx 186 <1> ; 09/08/2022 - BugFix 187 000001BB 30FF <1> xor bh, bh 188 000001BD 88D3 <1> mov bl, dl 189 000001BF 81C3[BE65] <1> add bx, hd0_type - 80h 190 000001C3 800F80 <1> or byte [bx], 80h ; present sign (when lower nibble is 0) 191 000001C6 A0[3B66] <1> mov al, [hdc] 192 000001C9 FEC8 <1> dec al 193 <1> ;jz L13 194 <1> ; 14/07/2022 195 000001CB 7408 <1> jz short L9_10 196 000001CD 80FA80 <1> cmp dl, 80h 197 <1> ;jna L5 ; Max. 2 hard disks ; 17/07/2020 198 <1> ; 14/07/2022 199 000001D0 7703 <1> ja short L9_10 200 000001D2 E978FF <1> jmp L5 201 <1> L9_10: 202 000001D5 E92D01 <1> jmp L13 203 <1> L10: 204 000001D8 FEC2 <1> inc dl 205 <1> ; 25/12/2014 206 000001DA 8816[3966] <1> mov [drv], dl 207 000001DE B408 <1> mov ah, 08h ; Return drive parameters 208 000001E0 CD13 <1> int 13h ; (conventional function) 209 <1> ;jc L13 210 <1> ; 14/07/2022 211 000001E2 72F1 <1> jc short L9_10 212 <1> ; 14/01/2015 213 <1> ;mov dl, [drv] 214 <1> ; 09/08/2022 215 <1> ;push dx 216 000001E4 51 <1> push cx 217 000001E5 E82B01 <1> call set_disk_parms 218 000001E8 59 <1> pop cx 219 <1> ;pop dx 220 <1> ; 09/08/2022 221 000001E9 8A16[3966] <1> mov dl, [drv] 222 <1> ; 06/07/2016 (BugFix for >64K kernel files) 223 <1> ; 04/02/2016 (esi -> si) 224 <1> ;mov si, _end ; 30 byte temporary buffer address 225 <1> ; ; at the '_end' of kernel. 226 <1> ;mov word [si], 30 227 <1> ; 06/07/2016 228 000001ED BE[5400] <1> mov si, _int13h_48h_buffer 229 <1> ; 09/07/2016 230 000001F0 B81E00 <1> mov ax, 001Eh 231 000001F3 8824 <1> mov [si], ah ; 0 232 000001F5 46 <1> inc si 233 000001F6 8904 <1> mov [si], ax 234 <1> ; word [si] = 30 235 <1> ; 236 000001F8 B448 <1> mov ah, 48h ; Get drive parameters (EDD function) 237 000001FA CD13 <1> int 13h 238 <1> ;jc L13 239 <1> ; 14/07/2022 240 000001FC 72D7 <1> jc short L9_10 241 <1> 242 <1> ; 29/08/2020 243 <1> ; 04/02/2016 (ebx -> bx) 244 <1> ; 14/01/2015 245 000001FE 28FF <1> sub bh, bh 246 00000200 88D3 <1> mov bl, dl 247 <1> ;sub bl, 80h 248 <1> ; 29/08/2020 249 00000202 81C3[BE65] <1> add bx, (hd0_type - 80h) 250 <1> ;mov al, [bx] 251 00000206 8A07 <1> mov al, [bx] 252 00000208 0C80 <1> or al, 80h 253 0000020A 8807 <1> mov [bx], al 254 0000020C 81EB[3C66] <1> sub bx, hd0_type - 2 ; 15/01/2015 255 <1> ;add bx, drv.status 256 <1> ;mov [bx], al 257 <1> ; 29/08/2020 258 00000210 8887[5E66] <1> mov [bx+drv.status], al 259 <1> ; 04/02/2016 (eax -> ax) 260 <1> ;mov ax, [si+16] 261 <1> ; 14/07/2020 262 <1> ;mov di, [si+18] 263 <1> ;;test ax, [si+18] 264 <1> ;test ax, di ; 14/07/2020 265 <1> ;jz short L10_A0h ; (!) ; 17/07/2020 266 <1> ; 'CHS only' disks on EDD system 267 <1> ; are reported with ZERO disk size 268 <1> ; (if so, we must not overwrite 269 <1> ; calculated disk size in 'set_disk_parms') 270 <1> ; 29/08/2020 271 00000214 8B4410 <1> mov ax, [si+16] 272 00000217 8B7C12 <1> mov di, [si+18] 273 0000021A 09C0 <1> or ax, ax 274 0000021C 7504 <1> jnz short L10_LBA 275 0000021E 09FF <1> or di, di 276 00000220 740B <1> jz short L10_A0h 277 <1> L10_LBA: 278 <1> ;sub bx, drv.status 279 00000222 C1E302 <1> shl bx, 2 280 <1> ;add bx, drv.size ; disk size (in sectors) 281 <1> ;mov [bx], ax 282 <1> ; 29/08/2020 283 00000225 8987[4266] <1> mov [bx+drv.size], ax 284 <1> ;mov ax, [si+18] 285 <1> ;;mov [bx], ax 286 <1> ;mov [bx+2], ax ; BugFix ; 15/07/2020 287 <1> ; 14/07/2020 288 <1> ;mov [bx+2], di ; 15/07/2020 289 <1> ; 29/08/2020 290 00000229 89BF[4466] <1> mov [bx+drv.size+2], di 291 <1> L10_A0h: 292 <1> ; 17/07/2020 293 <1> ; Note: Virtual CPU will jump here from above (!) test 294 <1> ; while running in QEMU 295 <1> 296 <1> ; Jump here to fix a ZERO (LBA) disk size problem 297 <1> ; for CHS disks (28/02/2015) 298 <1> 299 <1> ; 30/12/2014 300 0000022D BF0000 <1> mov di, HD0_DPT 301 00000230 88D0 <1> mov al, dl 302 00000232 83E003 <1> and ax, 3 303 00000235 C0E005 <1> shl al, 5 ; * 32 304 00000238 01C7 <1> add di, ax 305 0000023A B80090 <1> mov ax, DPT_SEGM 306 0000023D 8EC0 <1> mov es, ax 307 <1> ; 308 0000023F 88E8 <1> mov al, ch ; max. cylinder number (bits 0-7) 309 00000241 88CC <1> mov ah, cl 310 00000243 C0EC06 <1> shr ah, 6 ; max. cylinder number (bits 8-9) 311 00000246 40 <1> inc ax ; logical cylinders (limit 1024) 312 00000247 AB <1> stosw 313 00000248 88F0 <1> mov al, dh ; max. head number 314 <1> ; 315 0000024A 30F6 <1> xor dh, dh ; 29/08/2020 (dh = 0 is needed here) 316 <1> ; 317 0000024C FEC0 <1> inc al 318 0000024E AA <1> stosb ; logical heads (limits 256) 319 0000024F B0A0 <1> mov al, 0A0h ; Indicates translated table 320 00000251 AA <1> stosb 321 00000252 8A440C <1> mov al, [si+12] 322 00000255 AA <1> stosb ; physical sectors per track 323 00000256 31C0 <1> xor ax, ax 324 <1> ;dec ax ; 02/01/2015 325 00000258 AB <1> stosw ; precompensation (obsolete) 326 <1> ;xor al, al ; 02/01/2015 327 00000259 AA <1> stosb ; reserved 328 0000025A B008 <1> mov al, 8 ; drive control byte 329 <1> ; (do not disable retries, 330 <1> ; more than 8 heads) 331 0000025C AA <1> stosb 332 0000025D 8B4404 <1> mov ax, [si+4] 333 00000260 AB <1> stosw ; physical number of cylinders 334 <1> ;push ax ; 02/01/2015 335 00000261 8A4408 <1> mov al, [si+8] 336 00000264 AA <1> stosb ; physical num. of heads (limit 16) 337 00000265 29C0 <1> sub ax, ax 338 <1> ;pop ax ; 02/01/2015 339 00000267 AB <1> stosw ; landing zone (obsolete) 340 00000268 88C8 <1> mov al, cl ; logical sectors per track (limit 63) 341 0000026A 243F <1> and al, 3Fh 342 0000026C AA <1> stosb 343 <1> ;sub al, al ; checksum 344 <1> ;stosb 345 <1> ; 346 0000026D 83C61A <1> add si, 26 ; (BIOS) DPTE address pointer 347 00000270 AD <1> lodsw 348 00000271 50 <1> push ax ; * ; (BIOS) DPTE offset 349 00000272 AD <1> lodsw 350 00000273 50 <1> push ax ; ** ; (BIOS) DPTE segment 351 <1> ; 352 <1> ; checksum calculation 353 00000274 89FE <1> mov si, di 354 00000276 06 <1> push es 355 00000277 1F <1> pop ds 356 <1> ;mov cx, 16 357 00000278 B90F00 <1> mov cx, 15 358 0000027B 29CE <1> sub si, cx 359 0000027D 30E4 <1> xor ah, ah 360 <1> ;del cl 361 <1> L11: 362 0000027F AC <1> lodsb 363 00000280 00C4 <1> add ah, al 364 00000282 E2FB <1> loop L11 365 <1> ; 366 00000284 88E0 <1> mov al, ah 367 00000286 F6D8 <1> neg al ; -x+x = 0 368 00000288 AA <1> stosb ; put checksum in byte 15 of the tbl 369 <1> ; 370 00000289 1F <1> pop ds ; ** ; (BIOS) DPTE segment 371 0000028A 5E <1> pop si ; * ; (BIOS) DPTE offset 372 <1> 373 <1> ; 08/08/2022 (TRDOS 386 v2.0.5) 374 <1> ; (Recent version of Retro UNIX 386 v1 'diskinit.s' file 375 <1> ; -12/07/2022- does not contain following 2020 code) (*) 376 <1> 377 <1> ; 14/07/2020 (TRDOS 386 v2.0.2) 378 <1> ; 0FFFFh:0FFFFh = invalid DPTE address 379 0000028B 8B0C <1> mov cx, [si] 380 0000028D 8B4402 <1> mov ax, [si+2] 381 00000290 21C1 <1> and cx, ax 382 00000292 41 <1> inc cx 383 00000293 7404 <1> jz short L11c ; 0FFFFh:0FFFFh 384 00000295 0B04 <1> or ax, [si] 385 00000297 752A <1> jnz short L11e ; <> 0 386 <1> L11c: 387 <1> ; 17/07/2020 388 <1> ; TRDOS 386 v2 DRVINIT assumptions: 389 <1> ; (also by regarding QEMU, Bochs and VirtualBox settings) 390 <1> ; Hard disk 0 port address: 1F0h 391 <1> ; Hard disk 1 port address: 1F0h 392 <1> ; Hard disk 2 port address: 170h 393 <1> ; Hard disk 3 port address: 170h 394 <1> 395 <1> ; in QEMU, hda=hd0 (1F0h) and hdb=hd1 (1F0h) -IRQ14- 396 <1> ; and hdc=hd2 (170h) and hdd=hd3 (170h) -IRQ15- 397 <1> 398 00000299 B8F001 <1> mov ax, 1F0h 399 <1> 400 <1> ; 15/07/2020 401 <1> ; 14/07/2020 402 <1> ; Invalid DPTE address... 403 <1> ; Default DPTE parms must be set for DISK_IO_CONT 404 <1> ; (diskio.s) 405 <1> ; 17/07/2020 406 <1> 407 <1> ;mov bl, dl 408 <1> ;and bl, 1 409 <1> ;jz short L11d 410 <1> 411 0000029C B3A0 <1> mov bl, 0A0h 412 <1> 413 0000029E F6C201 <1> test dl, 1 414 000002A1 7403 <1> jz short L11g ; Master (as default, for 80h & 82h)) 415 <1> ;shl bl, 4 ; bl = 16 (bit 4 = 1 -> slave) 416 000002A3 80C310 <1> add bl, 10h ; Slave (as default, for 81h & 83h) 417 <1> L11g: 418 <1> ; 17/07/2020 419 000002A6 80FA82 <1> cmp dl, 82h ; Hard disk 3 or 4 ? 420 000002A9 7203 <1> jb short L11d ; Primary ATA channel (hd0, hd1) 421 <1> ; (port address = 1F0h) 422 <1> 423 <1> ; Secondary ATA channel (hd2, hd3) 424 <1> ; (port address = 170h) 425 <1> 426 000002AB 2D8000 <1> sub ax, 1F0h-170h 427 <1> L11d: 428 <1> ; 14/07/2020 429 000002AE AB <1> stosw ; I/O PORT Base Address (1F0h, 170h) 430 000002AF 050602 <1> add ax, 206h 431 000002B2 AB <1> stosw ; CONTROL PORT Address (3F6h, 376h) 432 000002B3 88D8 <1> mov al, bl ; Master/Slave bit (0 = Master) 433 <1> ; 17/07/2020 434 <1> ;or al, 0A0h ; CHS (LBA enable bit = 0) 435 <1> ; (Bits 5&7, reserved bits = 1) 436 000002B5 30E4 <1> xor ah, ah 437 <1> ;stosb ; Device/Head Register upper nibble 438 000002B7 AB <1> stosw 439 000002B8 30C0 <1> xor al, al 440 000002BA B90500 <1> mov cx, 5 441 000002BD F3AB <1> rep stosw ; clear remain part of the (fake) DPTE 442 000002BF 0E <1> push cs 443 000002C0 1F <1> pop ds 444 000002C1 EB2E <1> jmp short L11f 445 <1> 446 <1> ; 08/08/2022 (TRDOS 386 v2.0.5) 447 <1> ; (Recent version of Retro UNIX 386 v1 'diskinit.s' file 448 <1> ; -12/07/2022- does not contain above 2020 code) (*) 449 <1> L11e: 450 <1> ; 23/02/2015 451 000002C3 57 <1> push di 452 <1> ; ES:DI points to DPTE (FDPTE) location 453 <1> ;;mov cx, 8 454 <1> ;mov cl, 8 455 000002C4 B90800 <1> mov cx, 8 ; 14/07/2020 456 000002C7 F3A5 <1> rep movsw 457 <1> ; 458 <1> ; 23/02/2015 459 <1> ; (P)ATA drive and LBA validation 460 <1> ; (invalidating SATA drives and setting 461 <1> ; CHS type I/O for old type fixed disks) 462 000002C9 5B <1> pop bx 463 000002CA 8CC8 <1> mov ax, cs 464 000002CC 8ED8 <1> mov ds, ax 465 000002CE 268B07 <1> mov ax, [es:bx] 466 000002D1 3DF001 <1> cmp ax, 1F0h 467 000002D4 7413 <1> je short L11a 468 000002D6 3D7001 <1> cmp ax, 170h 469 000002D9 740E <1> je short L11a 470 <1> ; invalidation 471 <1> ; (because base port address is not 1F0h or 170h) 472 <1> ;xor bh, bh 473 <1> ;mov bl, dl 474 <1> ; 29/08/2020 475 <1> ;xor dh, dh ; 0 476 000002DB 89D3 <1> mov bx, dx 477 <1> ;sub bl, 80h 478 <1> ;mov byte [bx+hd0_type], 0 ; not a valid disk drive ! 479 <1> ;or byte [bx+drv.status+2], 0F0h ; (failure sign) 480 <1> ; 29/08/2020 481 000002DD C687[BE65]00 <1> mov byte [bx+hd0_type-80h], 0 482 000002E2 808F[E065]F0 <1> or byte [bx+drv.status-7Eh], 0F0h 483 000002E7 EB0F <1> jmp short L11b 484 <1> L11a: 485 <1> ; LBA validation 486 000002E9 268A4704 <1> mov al, [es:bx+4] ; Head register upper nibble 487 000002ED A840 <1> test al, 40h ; LBA bit (bit 6) 488 000002EF 7507 <1> jnz short L11b ; LBA type I/O is OK! (E0h or F0h) 489 <1> L11f: 490 <1> ; force CHS type I/O for this drive (A0h or B0h) 491 <1> ;sub bh, bh 492 <1> ;mov bl, dl 493 <1> ; 29/08/2020 494 <1> ;xor dh, dh ; 0 495 000002F1 89D3 <1> mov bx, dx 496 <1> ;sub bl, 80h ; 26/02/2015 497 <1> ;and byte [bx+drv.status+2], 0FEh ; clear bit 0 498 <1> ; bit 0 = LBA ready bit 499 <1> ; 29/08/2020 500 000002F3 80A7[E065]FE <1> and byte [bx+drv.status-7Eh], 0FEh 501 <1> ; 'diskio' procedure will check this bit ! 502 <1> L11b: 503 000002F8 3A16[3A66] <1> cmp dl, [last_drv] ; 25/12/2014 504 000002FC 7307 <1> jnb short L13 505 000002FE E9D7FE <1> jmp L10 506 <1> 507 <1> L12: 508 <1> ; Restore data registers 509 00000301 8CC8 <1> mov ax, cs 510 00000303 8ED8 <1> mov ds, ax 511 <1> L13: 512 <1> ; 13/12/2014 513 00000305 0E <1> push cs 514 00000306 07 <1> pop es 515 <1> L14: 516 <1> ; clear keyboard buffer 517 00000307 B411 <1> mov ah, 11h 518 00000309 CD16 <1> int 16h 519 0000030B 7440 <1> jz short L16 ; no keys in keyboard buffer 520 0000030D B010 <1> mov al, 10h 521 0000030F CD16 <1> int 16h 522 00000311 EBF4 <1> jmp short L14 523 <1> 524 <1> set_disk_parms: 525 <1> ; 08/08/2022 - TRDOS 386 v2.0.5 526 <1> ; 09/05/2022 - Retro UNIX 386 v1.2 527 <1> ; 29/08/2020 - TRDOS 386 v2.0.2 528 <1> ; 04/02/2016 (ebx -> bx) 529 <1> ; 10/07/2015 530 <1> ; 14/01/2015 531 <1> ;push bx 532 00000313 28FF <1> sub bh, bh 533 00000315 8A1E[3966] <1> mov bl, [drv] 534 00000319 80FB80 <1> cmp bl, 80h 535 0000031C 7203 <1> jb short sdp0 536 0000031E 80EB7E <1> sub bl, 7Eh 537 <1> sdp0: 538 <1> ;add bx, drv.status 539 <1> ;mov byte [bx], 80h ; 'Present' flag 540 <1> ; 29/08/2020 541 00000321 C687[5E66]80 <1> mov byte [bx+drv.status], 80h 542 <1> ; 543 00000326 88E8 <1> mov al, ch ; last cylinder (bits 0-7) 544 00000328 88CC <1> mov ah, cl ; 545 0000032A C0EC06 <1> shr ah, 6 ; last cylinder (bits 8-9) 546 <1> ;sub bx, drv.status 547 0000032D D0E3 <1> shl bl, 1 548 <1> ;add bx, drv.cylinders 549 0000032F 40 <1> inc ax ; convert max. cyl number to cyl count 550 <1> ;mov [bx], ax 551 <1> ; 08/08/2022 552 <1> ; 29/08/2020 553 <1> ;mov [bx+drv.cylinders], ax 554 <1> ; 555 00000330 50 <1> push ax ; ** cylinders 556 <1> ;sub bx, drv.cylinders 557 <1> ;add bx, drv.heads 558 00000331 30E4 <1> xor ah, ah 559 00000333 88F0 <1> mov al, dh ; heads 560 00000335 40 <1> inc ax 561 <1> ;mov [bx], ax 562 <1> ; 08/08/2022 563 <1> ; 29/08/2020 564 <1> ;mov [bx+drv.heads], ax 565 <1> ;sub bx, drv.heads 566 <1> ;add bx, drv.spt 567 00000336 30ED <1> xor ch, ch 568 00000338 80E13F <1> and cl, 3Fh ; sectors (bits 0-6) 569 <1> ;mov [bx], cx 570 <1> ; 08/08/2022 571 <1> ; 29/08/2020 572 <1> ;mov [bx+drv.spt], cx 573 <1> ;sub bx, drv.spt 574 0000033B D1E3 <1> shl bx, 1 575 <1> ;add bx, drv.size ; disk size (in sectors) 576 <1> ; LBA size = cylinders * heads * secpertrack 577 0000033D F7E1 <1> mul cx 578 0000033F 89C2 <1> mov dx, ax ; heads*spt 579 00000341 58 <1> pop ax ; ** cylinders 580 <1> ; 09/05/2022 (fd0&fd1 drv.size = cyls*spt*heads) 581 <1> ;dec ax ; 1 cylinder reserved (!?) ; (*) 582 00000342 F7E2 <1> mul dx ; cylinders * (heads*spt) 583 <1> ;mov [bx], ax 584 <1> ;mov [bx+2], dx 585 <1> ; 29/08/2020 586 00000344 8987[4266] <1> mov [bx+drv.size], ax 587 00000348 8997[4466] <1> mov [bx+drv.size+2], dx 588 <1> ; 589 <1> ;pop bx 590 0000034C C3 <1> retn 591 <1> 592 <1> L16: ; 28/05/2016 425 426 ; 10/11/2014 427 0000034D FA cli ; Disable interrupts (clear interrupt flag) 428 ; Reset Interrupt MASK Registers (Master&Slave) 429 ;mov al, 0FFh ; mask off all interrupts 430 ;out 21h, al ; on master PIC (8259) 431 ;jmp $+2 ; (delay) 432 ;out 0A1h, al ; on slave PIC (8259) 433 ; 434 ; Disable NMI 435 0000034E B080 mov al, 80h 436 00000350 E670 out 70h, al ; set bit 7 to 1 for disabling NMI 437 ;23/02/2015 438 ;nop ; 439 ;in al, 71h ; read in 71h just after writing out to 70h 440 ; for preventing unknown state (!?) 441 ; 442 ; 20/08/2014 443 ; Moving the kernel 64 KB back (to physical address 0) 444 ; DS = CS = 1000h 445 ; 05/11/2014 446 00000352 31C0 xor ax, ax 447 00000354 8EC0 mov es, ax ; ES = 0 448 ; 449 ; 04/07/2016 - TRDOS 386 (64K - 128K kernel) 450 00000356 31F6 xor si, si 451 00000358 31FF xor di, di 452 ;mov cx, 16384 453 ;rep movsd 454 ; 02/12/2023 455 0000035A B90080 mov cx, 32768 456 0000035D F3A5 rep movsw 457 ; 458 0000035F 06 push es ; 0 459 00000360 68[6403] push L17 460 00000363 CB retf 461 L17: 462 00000364 B90010 mov cx, 1000h 463 00000367 8EC1 mov es, cx ; 1000h 464 00000369 01C9 add cx, cx 465 0000036B 8ED9 mov ds, cx ; 2000h 466 ;sub si, si 467 ;sub di, di 468 ;mov cx, 16384 469 ;rep movsd 470 ; 02/12/2023 471 ; si = di = 0 472 0000036D B90080 mov cx, 32768 473 00000370 F3A5 rep movsw 474 475 ; Turn off the floppy drive motor 476 00000372 BAF203 mov dx, 3F2h 477 00000375 EE out dx, al ; 0 ; 31/12/2013 478 479 ; Enable access to memory above one megabyte 480 L18: 481 00000376 E464 in al, 64h 482 00000378 A802 test al, 2 483 0000037A 75FA jnz short L18 484 0000037C B0D1 mov al, 0D1h ; Write output port 485 0000037E E664 out 64h, al 486 L19: 487 00000380 E464 in al, 64h 488 00000382 A802 test al, 2 489 00000384 75FA jnz short L19 490 00000386 B0DF mov al, 0DFh ; Enable A20 line 491 00000388 E660 out 60h, al 492 ;L20: 493 ; 494 ; Load global descriptor table register 495 496 ;mov ax, cs 497 ;mov ds, ax 498 499 0000038A 2E0F0116[A865] lgdt [cs:gdtd] 500 501 00000390 0F20C0 mov eax, cr0 502 ;or al, 1 ; 24/07/2023 503 00000393 40 inc ax 504 00000394 0F22C0 mov cr0, eax 505 506 ; Jump to 32 bit code 507 508 00000397 66 db 66h ; Prefix for 32-bit 509 00000398 EA db 0EAh ; Opcode for far jump 510 00000399 [9F030000] dd StartPM ; Offset to start, 32-bit 511 ; (1000h:StartPM = StartPM + 10000h) 512 0000039D 0800 dw KCODE ; This is the selector for CODE32_DESCRIPTOR, 513 ; assuming that StartPM resides in code32 514 515 ; 20/02/2017 516 517 518 [BITS 32] 519 520 StartPM: 521 ; Kernel Base Address = 0 ; 30/12/2013 522 0000039F 66B81000 mov ax, KDATA ; Save data segment identifier 523 000003A3 8ED8 mov ds, ax ; Move a valid data segment into DS register 524 000003A5 8EC0 mov es, ax ; Move data segment into ES register 525 000003A7 8EE0 mov fs, ax ; Move data segment into FS register 526 000003A9 8EE8 mov gs, ax ; Move data segment into GS register 527 000003AB 8ED0 mov ss, ax ; Move data segment into SS register 528 ;mov esp, 90000h ; Move the stack pointer to 090000h 529 ; 04/12/2023 - TRDOS 386 v2.0.7 530 ;mov esp, 97000h ; 3072 bytes system stack (96400h-97000h) 531 000003AD BC00700900 mov esp, SYSTEMSTACK_ADDR ; 97000h (max. 3072 bytes) 532 533 clear_bss: ; Clear uninitialized data area 534 ; 11/03/2015 535 000003B2 31C0 xor eax, eax ; 0 536 000003B4 B9790A0000 mov ecx, (bss_end - bss_start)/4 537 ;shr ecx, 2 ; bss section is already aligned for double words 538 000003B9 BF[D3790100] mov edi, bss_start 539 000003BE F3AB rep stosd 540 541 memory_init: 542 ; Initialize memory allocation table and page tables 543 ; 04/12/2023 544 ; 29/11/2023 545 ; 27/11/2023 546 ; 23/11/2023 (TRDOS 386 v2.0.7) 547 ; 24/07/2022 (TRDOS 386 v2.0.5) 548 ; 18/04/2021 (TRDOS 386 v2.0.4) 549 ; 16/11/2014 550 ; 15/11/2014 551 ; 07/11/2014 552 ; 06/11/2014 553 ; 05/11/2014 554 ; 04/11/2014 555 ; 31/10/2014 (Retro UNIX 386 v1 - Beginning) 556 ; 557 ; xor eax, eax 558 ; xor ecx, ecx 559 000003C0 B108 mov cl, 8 560 000003C2 BF00001000 mov edi, MEM_ALLOC_TBL 561 000003C7 F3AB rep stosd ; clear Memory Allocation Table 562 ; for the first 1 MB memory 563 ; 564 000003C9 668B0D[34660000] mov cx, [mem_1m_1k] ; Number of contiguous KB between 565 ; 1 and 16 MB, max. 3C00h = 15 MB. 566 ;shr cx, 2 ; convert 1 KB count to 4 KB count 567 ; 24/07/2022 568 000003D0 C1E902 shr ecx, 2 569 000003D3 890D[C87C0100] mov [free_pages], ecx 570 000003D9 668B15[36660000] mov dx, [mem_16m_64k] ; Number of contiguous 64 KB blocks 571 ; between 16 MB and 4 GB. 572 000003E0 6609D2 or dx, dx 573 000003E3 7425 jz short mi_0 574 575 ; 04/12/2023 576 %if 1 577 ; 02/12/2023 - temporary (2816MB limit) 578 ;cmp dx, 44800 ; 0AF00h 579 000003E5 6681FA009F cmp dx, 40704 ; (2560MB limit) 580 000003EA 7604 jna short mi_x 581 ;mov dx, 44800 582 000003EC 66BA009F mov dx, 40704 583 mi_x: 584 %endif 585 ; 23/11/2023 - temporary 586 ;and dx, 3FFFh 587 588 000003F0 668915[36660000] mov [mem_16m_64k], dx 589 590 000003F7 6689D0 mov ax, dx 591 000003FA C1E004 shl eax, 4 ; 64 KB -> 4 KB (page count) 592 000003FD 0105[C87C0100] add [free_pages], eax 593 00000403 0500100000 add eax, 4096 ; 16 MB = 4096 pages 594 00000408 EB06 jmp short mi_1 595 mi_0: 596 ;mov ax, cx 597 ; 24/07/2022 598 0000040A 89C8 mov eax, ecx 599 0000040C 66050001 add ax, 256 ; add 256 pages for the first 1 MB 600 ;add eax, 256 601 mi_1: 602 00000410 A3[C47C0100] mov [memory_size], eax ; Total available memory in pages 603 ; 1 alloc. tbl. bit = 1 memory page 604 ; 32 allocation bits = 32 mem. pages 605 ; 606 00000415 05FF7F0000 add eax, 32767 ; 32768 memory pages per 1 M.A.T. page 607 0000041A C1E80F shr eax, 15 ; ((32768 * x) + y) pages (y < 32768) 608 ; --> x + 1 M.A.T. pages, if y > 0 609 ; --> x M.A.T. pages, if y = 0 610 0000041D 66A3[D87C0100] mov [mat_size], ax ; Memory Alloc. Table Size in pages 611 00000423 C1E00C shl eax, 12 ; 1 M.A.T. page = 4096 bytes 612 ; ; Max. 32 M.A.T. pages (4 GB memory) 613 00000426 89C3 mov ebx, eax ; M.A.T. size in bytes 614 ; Set/Calculate Kernel's Page Directory Address 615 00000428 81C300001000 add ebx, MEM_ALLOC_TBL 616 0000042E 891D[C07C0100] mov [k_page_dir], ebx ; Kernel's Page Directory address 617 ; just after the last M.A.T. page 618 ; 619 00000434 83E804 sub eax, 4 ; convert M.A.T. size to offset value 620 00000437 A3[D07C0100] mov [last_page], eax ; last page offset in the M.A.T. 621 ; ; (allocation status search must be 622 ; stopped after here) 623 0000043C 31C0 xor eax, eax 624 0000043E 48 dec eax ; FFFFFFFFh (set all bits to 1) 625 ;push cx 626 ; 18/04/2021 627 0000043F 51 push ecx 628 ; ecx = 3840 ; 27/11/2023 629 ; (Note: ecx < 3840 if the total memory is less than 16 MB) 630 00000440 C1E905 shr ecx, 5 ; convert 1 - 16 MB page count to 631 ; count of 32 allocation bits 632 ; ecx = 120 ; 27/11/2023 633 00000443 F3AB rep stosd 634 ;pop cx 635 ; 18/04/2021 636 00000445 59 pop ecx 637 00000446 40 inc eax ; 0 638 00000447 80E11F and cl, 31 ; remain bits 639 0000044A 7412 jz short mi_4 640 0000044C 8907 mov [edi], eax ; reset 641 mi_2: 642 0000044E 0FAB07 bts [edi], eax ; 06/11/2014 643 00000451 FEC9 dec cl 644 00000453 7404 jz short mi_3 645 00000455 FEC0 inc al 646 00000457 EBF5 jmp short mi_2 647 mi_3: 648 00000459 28C0 sub al, al ; 0 649 0000045B 83C704 add edi, 4 ; 15/11/2014 650 mi_4: 651 0000045E 6609D2 or dx, dx ; check 16 MB to 4 GB memory space 652 00000461 7421 jz short mi_6 ; max. 16 MB memory, no more... 653 ; 654 00000463 B900021000 mov ecx, MEM_ALLOC_TBL + 512 ; End of first 16 MB memory 655 ; 656 00000468 29F9 sub ecx, edi ; displacement (to end of 16 MB) 657 0000046A 7406 jz short mi_5 ; jump if EDI points to 658 ; end of first 16 MB 659 0000046C D1E9 shr ecx, 1 ; convert to dword count 660 0000046E D1E9 shr ecx, 1 ; (shift 2 bits right) 661 00000470 F3AB rep stosd ; reset all bits for reserved pages 662 ; (memory hole under 16 MB) 663 mi_5: 664 00000472 6689D1 mov cx, dx ; count of 64 KB memory blocks 665 00000475 D1E9 shr ecx, 1 ; 1 alloc. dword per 128 KB memory 666 00000477 9C pushf ; 16/11/2014 667 00000478 48 dec eax ; FFFFFFFFh (set all bits to 1) 668 00000479 F3AB rep stosd 669 0000047B 40 inc eax ; 0 670 0000047C 9D popf ; 16/11/2014 671 0000047D 7305 jnc short mi_6 672 0000047F 6648 dec ax ; eax = 0000FFFFh 673 00000481 AB stosd 674 00000482 6640 inc ax ; 0 675 mi_6: 676 00000484 39DF cmp edi, ebx ; check if EDI points to 677 00000486 730A jnb short mi_7 ; end of memory allocation table 678 ; ; (>= MEM_ALLOC_TBL + 4906) 679 00000488 89D9 mov ecx, ebx ; end of memory allocation table 680 0000048A 29F9 sub ecx, edi ; convert displacement/offset 681 0000048C D1E9 shr ecx, 1 ; to dword count 682 0000048E D1E9 shr ecx, 1 ; (shift 2 bits right) 683 00000490 F3AB rep stosd ; reset all remain M.A.T. bits 684 mi_7: 685 ; Reset M.A.T. bits in M.A.T. (allocate M.A.T. pages) 686 00000492 BA00001000 mov edx, MEM_ALLOC_TBL 687 ;sub ebx, edx ; Mem. Alloc. Tbl. size in bytes 688 ;shr ebx, 12 ; Mem. Alloc. Tbl. size in pages 689 00000497 668B0D[D87C0100] mov cx, [mat_size] ; Mem. Alloc. Tbl. size in pages 690 0000049E 89D7 mov edi, edx 691 000004A0 C1EF0F shr edi, 15 ; convert M.A.T. address to 692 ; byte offset in M.A.T. 693 ; (1 M.A.T. byte points to 694 ; 32768 bytes) 695 ; Note: MEM_ALLOC_TBL address 696 ; must be aligned on 128 KB 697 ; boundary! 698 000004A3 01D7 add edi, edx ; points to M.A.T.'s itself 699 ; eax = 0 700 000004A5 290D[C87C0100] sub [free_pages], ecx ; 07/11/2014 701 mi_8: 702 000004AB 0FB307 btr [edi], eax ; clear bit 0 to bit x (1 to 31) 703 ;dec bl 704 000004AE FEC9 dec cl 705 000004B0 7404 jz short mi_9 706 000004B2 FEC0 inc al 707 000004B4 EBF5 jmp short mi_8 708 mi_9: 709 ; 710 ; Reset Kernel's Page Dir. and Page Table bits in M.A.T. 711 ; (allocate pages for system page tables) 712 713 ; edx = MEM_ALLOC_TBL 714 000004B6 8B0D[C47C0100] mov ecx, [memory_size] ; memory size in pages (PTEs) 715 000004BC 81C1FF030000 add ecx, 1023 ; round up (1024 PTEs per table) 716 000004C2 C1E90A shr ecx, 10 ; convert memory page count to 717 ; page table count (PDE count) 718 ; 719 000004C5 51 push ecx ; (**) PDE count (<= 1024) 720 ; 721 000004C6 41 inc ecx ; +1 for kernel page directory 722 ; 723 000004C7 290D[C87C0100] sub [free_pages], ecx ; 07/11/2014 724 ; 725 000004CD 8B35[C07C0100] mov esi, [k_page_dir] ; Kernel's Page Directory address 726 000004D3 C1EE0C shr esi, 12 ; convert to page number 727 mi_10: 728 000004D6 89F0 mov eax, esi ; allocation bit offset 729 000004D8 89C3 mov ebx, eax 730 000004DA C1EB03 shr ebx, 3 ; convert to alloc. byte offset 731 000004DD 80E3FC and bl, 0FCh ; clear bit 0 and bit 1 732 ; to align on dword boundary 733 000004E0 83E01F and eax, 31 ; set allocation bit position 734 ; (bit 0 to bit 31) 735 ; 736 000004E3 01D3 add ebx, edx ; offset in M.A.T. + M.A.T. address 737 ; 738 000004E5 0FB303 btr [ebx], eax ; reset relevant bit (0 to 31) 739 ; 740 000004E8 46 inc esi ; next page table 741 000004E9 E2EB loop mi_10 ; allocate next kernel page table 742 ; (ecx = page table count + 1) 743 ; 744 000004EB 59 pop ecx ; (**) PDE count (= pg. tbl. count) 745 ; 746 ; Initialize Kernel Page Directory and Kernel Page Tables 747 ; 748 ; Initialize Kernel's Page Directory 749 000004EC 8B3D[C07C0100] mov edi, [k_page_dir] 750 000004F2 89F8 mov eax, edi 751 000004F4 0C03 or al, PDE_A_PRESENT + PDE_A_WRITE 752 ; supervisor + read&write + present 753 000004F6 89CA mov edx, ecx ; (**) PDE count (= pg. tbl. count) 754 mi_11: 755 000004F8 0500100000 add eax, 4096 ; Add page size (PGSZ) 756 ; EAX points to next page table 757 000004FD AB stosd 758 000004FE E2F8 loop mi_11 759 00000500 29C0 sub eax, eax ; Empty PDE 760 ;mov cx, 1024 ; Entry count (PGSZ/4) 761 ; 29/11/2023 762 00000502 B504 mov ch, 4 ; cx = 4*256 = 1024 763 00000504 29D1 sub ecx, edx 764 00000506 7402 jz short mi_12 765 00000508 F3AB rep stosd ; clear remain (empty) PDEs 766 ; 767 ; Initialization of Kernel's Page Directory is OK, here. 768 mi_12: 769 ; Initialize Kernel's Page Tables 770 ; 771 ; (EDI points to address of page table 0) 772 ; eax = 0 773 0000050A 8B0D[C47C0100] mov ecx, [memory_size] ; memory size in pages 774 00000510 89CA mov edx, ecx ; (***) 775 00000512 B003 mov al, PTE_A_PRESENT + PTE_A_WRITE 776 ; supervisor + read&write + present 777 mi_13: 778 00000514 AB stosd 779 00000515 0500100000 add eax, 4096 780 0000051A E2F8 loop mi_13 781 ;and dx, 1023 ; (***) 782 ; 30/08/2023 783 0000051C 81E2FF030000 and edx, 1023 784 00000522 7408 jz short mi_14 785 ;mov cx, 1024 786 ; 30/08/2023 787 00000524 B504 mov ch, 4 ; 4*256 = 1024 788 ;sub cx, dx ; from dx (<= 1023) to 1024 789 ; 24/07/2022 790 00000526 29D1 sub ecx, edx 791 00000528 31C0 xor eax, eax 792 0000052A F3AB rep stosd ; clear remain (empty) PTEs 793 ; of the last page table 794 mi_14: 795 ; Initialization of Kernel's Page Tables is OK, here. 796 ; 797 0000052C 89F8 mov eax, edi ; end of the last page table page 798 ; (beginging of user space pages) 799 800 0000052E C1E80F shr eax, 15 ; convert to M.A.T. byte offset 801 00000531 24FC and al, 0FCh ; clear bit 0 and bit 1 for 802 ; aligning on dword boundary 803 00000533 A3[D47C0100] mov [first_page], eax 804 00000538 A3[CC7C0100] mov [next_page], eax ; The first free page pointer 805 ; for user programs 806 ; (Offset in Mem. Alloc. Tbl.) 807 ; 808 ; Linear/FLAT (1 to 1) memory paging for the kernel is OK, here. 809 ; 810 811 ; Enable paging 812 ; 813 0000053D A1[C07C0100] mov eax, [k_page_dir] 814 00000542 0F22D8 mov cr3, eax 815 00000545 0F20C0 mov eax, cr0 816 00000548 0D00000080 or eax, 80000000h ; set paging bit (bit 31) 817 0000054D 0F22C0 mov cr0, eax 818 ;jmp KCODE:StartPMP 819 820 00000550 EA db 0EAh ; Opcode for far jump 821 00000551 [57050000] dd StartPMP ; 32 bit offset 822 00000555 0800 dw KCODE ; kernel code segment descriptor 823 824 StartPMP: 825 ; 06/11//2014 826 ; Clear video page 0 827 ; 828 ; Temporary Code 829 ; 830 00000557 B9E8030000 mov ecx, 80*25/2 831 0000055C BF00800B00 mov edi, 0B8000h 832 ; 30/01/2016 833 ;xor eax, eax ; black background, black fore color 834 00000561 B800070007 mov eax, 07000700h ; black background, light gray fore color 835 00000566 F3AB rep stosd 836 837 ; 19/08/2014 838 ; Kernel Base Address = 0 839 ; It is mapped to (physically) 0 in the page table. 840 ; So, here is exactly 'StartPMP' address. 841 842 ; 29/01/2016 (TRDOS 386 = TRDOS v2.0) 843 00000568 BE[6A3F0100] mov esi, starting_msg 844 ;; 14/08/2015 (kernel version message will appear 845 ;; when protected mode and paging is enabled) 846 0000056D BF00800B00 mov edi, 0B8000h ; 27/08/2014 847 848 ; 30/11/2020 849 ; 14/11/2020 (TRDOS 386 v2.0.3) 850 ;cmp byte [vbe3], 3 ; 03h 851 ;jne short pkv_1 852 ;;mov ah, 0Bh ; Black background, light cyan forecolor 853 ;; Light red TRDOS 386 version text shows VBE3 is ready ! 854 ;mov ah, 0Ch ; Black background, light red forecolor 855 ;jmp short pkv_2 856 ;pkv_1: 857 00000572 B40A mov ah, 0Ah ; Black background, light green forecolor 858 ;pkv_2: 859 ; 20/08/2014 860 00000574 E8BE030000 call printk 861 862 ; 'UNIX v7/x86' source code by Robert Nordier (1999) 863 ; // Set IRQ offsets 864 ; 865 ; Linux (v0.12) source code by Linus Torvalds (1991) 866 ; 867 ;; ICW1 868 00000579 B011 mov al, 11h ; Initialization sequence 869 0000057B E620 out 20h, al ; 8259A-1 870 ; jmp $+2 871 0000057D E6A0 out 0A0h, al ; 8259A-2 872 ;; ICW2 873 0000057F B020 mov al, 20h ; Start of hardware ints (20h) 874 00000581 E621 out 21h, al ; for 8259A-1 875 ; jmp $+2 876 00000583 B028 mov al, 28h ; Start of hardware ints (28h) 877 00000585 E6A1 out 0A1h, al ; for 8259A-2 878 ; 879 00000587 B004 mov al, 04h ;; ICW3 880 00000589 E621 out 21h, al ; IRQ2 of 8259A-1 (master) 881 ; jmp $+2 882 0000058B B002 mov al, 02h ; is 8259A-2 (slave) 883 0000058D E6A1 out 0A1h, al ; 884 ;; ICW4 885 0000058F B001 mov al, 01h ; 886 00000591 E621 out 21h, al ; 8086 mode, normal EOI 887 ; jmp $+2 888 00000593 E6A1 out 0A1h, al ; for both chips. 889 890 ;mov al, 0FFh ; mask off all interrupts for now 891 ;out 21h, al 892 ;; jmp $+2 893 ;out 0A1h, al 894 895 ; 02/04/2015 896 ; 26/03/2015 System call (INT 30h) modification 897 ; DPL = 3 (Interrupt service routine can be called from user mode) 898 ; 899 ;; Linux (v0.12) source code by Linus Torvalds (1991) 900 ; setup_idt: 901 ; 902 ;; 16/02/2015 903 ;;mov dword [DISKETTE_INT], fdc_int ; IRQ 6 handler 904 ; 21/08/2014 (timer_int) 905 00000595 BE[083C0100] mov esi, ilist 906 0000059A 8D3D[D8790100] lea edi, [idt] 907 ; 26/03/2015 908 000005A0 B930000000 mov ecx, 48 ; 48 hardware interrupts (INT 0 to INT 2Fh) 909 ; 02/04/2015 910 000005A5 BB00000800 mov ebx, 80000h 911 rp_sidt1: 912 000005AA AD lodsd 913 000005AB 89C2 mov edx, eax 914 000005AD 66BA008E mov dx, 8E00h 915 000005B1 6689C3 mov bx, ax 916 000005B4 89D8 mov eax, ebx ; /* selector = 0x0008 = cs */ 917 ; /* interrupt gate - dpl=0, present */ 918 000005B6 AB stosd ; selector & offset bits 0-15 919 000005B7 89D0 mov eax, edx 920 000005B9 AB stosd ; attributes & offset bits 16-23 921 000005BA E2EE loop rp_sidt1 922 ; 15/04/2016 923 ; TRDOS 386 (TRDOS v2.0) /// 32 sofware interrupts /// 924 ;mov cl, 16 ; 16 software interrupts (INT 30h to INT 3Fh) 925 000005BC B120 mov cl, 32 ; 32 software interrupts (INT 30h to INT 4Fh) 926 rp_sidt2: 927 000005BE AD lodsd 928 000005BF 21C0 and eax, eax 929 000005C1 7413 jz short rp_sidt3 930 000005C3 89C2 mov edx, eax 931 000005C5 66BA00EE mov dx, 0EE00h ; P=1b/DPL=11b/01110b 932 000005C9 6689C3 mov bx, ax 933 000005CC 89D8 mov eax, ebx ; selector & offset bits 0-15 934 000005CE AB stosd 935 000005CF 89D0 mov eax, edx 936 000005D1 AB stosd 937 000005D2 E2EA loop rp_sidt2 938 000005D4 EB16 jmp short sidt_OK 939 rp_sidt3: 940 000005D6 B8[AE0D0000] mov eax, ignore_int 941 000005DB 89C2 mov edx, eax 942 000005DD 66BA00EE mov dx, 0EE00h ; P=1b/DPL=11b/01110b 943 000005E1 6689C3 mov bx, ax 944 000005E4 89D8 mov eax, ebx ; selector & offset bits 0-15 945 rp_sidt4: 946 000005E6 AB stosd 947 000005E7 92 xchg eax, edx 948 000005E8 AB stosd 949 000005E9 92 xchg edx, eax 950 000005EA E2FA loop rp_sidt4 951 sidt_OK: 952 000005EC 0F011D[AE650000] lidt [idtd] 953 ; 954 ; TSS descriptor setup ; 24/03/2015 955 000005F3 B8[587C0100] mov eax, task_state_segment 956 000005F8 66A3[5A650000] mov [gdt_tss0], ax 957 000005FE C1C010 rol eax, 16 958 00000601 A2[5C650000] mov [gdt_tss1], al 959 00000606 8825[5F650000] mov [gdt_tss2], ah 960 0000060C 66C705[BE7C0100]68- mov word [tss.IOPB], tss_end - task_state_segment 960 00000614 00 961 ; 962 ; IO Map Base address (When this address points 963 ; to end of the TSS, CPU does not use IO port 964 ; permission bit map for RING 3 IO permissions, 965 ; access to any IO ports in ring 3 will be forbidden.) 966 ; 967 ;mov [tss.esp0], esp ; TSS offset 4 968 ;mov word [tss.ss0], KDATA ; TSS offset 8 (SS) 969 00000615 66B82800 mov ax, TSS ; It is needed when an interrupt 970 ; occurs (or a system call -software INT- is requested) 971 ; while cpu running in ring 3 (in user mode). 972 ; (Kernel stack pointer and segment will be loaded 973 ; from offset 4 and 8 of the TSS, by the CPU.) 974 00000619 0F00D8 ltr ax ; Load task register 975 ; 976 esp0_set0: 977 978 ; 29/11/2023 - Erdogan Tan 979 ; ------------------------ 980 ; If we read following -disabled- stack page setting code... 981 ; When the memory size >= 3GB, one of page tables conflicts with the stack page 982 ; at 4MB-4096 address. So, to leave stack pointer at 90000h is better/default. 983 ; (Problem may not appears for <= 2.5GB main memory but following code is also 984 ; defective because kernel stack page would be seen as unallocated in the M.A.T. 985 ; without by adding a memory allocation code.) 986 ; 987 ; 1st 4MB layout: 1MB kernel -base- reserved + max. 128 KB M.A.T. (at 100000h) 988 ; + Kernel's page directory (4KB) -just after the M.A.T.- 989 ; + Kernel's page tables (main memory size / 1024) 990 ; Note: 991 ; 1 or 2 additional kernel page table(s) may be needed for Linear Frame Buffer 992 ; .. but, it/they will not have to be contiguous with other kernel page tables. 993 ; ------------------------ 994 995 ; 27/11/2023 - TRDOS 386 v2.0.7 996 %if 0 997 ; 30/07/2015 998 mov ecx, [memory_size] ; memory size in pages 999 shl ecx, 12 ; convert page count to byte count 1000 cmp ecx, CORE ; beginning of user's memory space (400000h) 1001 ; (kernel mode virtual address) 1002 jna short esp0_set1 1003 ; 1004 ; If available memory > CORE (end of the 1st 4 MB) 1005 ; set stack pointer to CORE 1006 ;(Because, PDE 0 is reserved for kernel space in user's page directory) 1007 ;(PDE 0 points to page table of the 1st 4 MB virtual address space) 1008 mov ecx, CORE 1009 esp0_set1: 1010 mov esp, ecx ; top of kernel stack (**tss.esp0**) 1011 %endif 1012 1013 esp0_set_ok: 1014 ; 30/07/2015 (**tss.esp0**) 1015 0000061C 8925[5C7C0100] mov [tss.esp0], esp ; 90000h ; 29/11/2023 1016 ; <-- 97000h ; 04/12/2023 (max. 3072 bytes) 1017 00000622 66C705[607C0100]10- mov word [tss.ss0], KDATA 1017 0000062A 00 1018 ; 14/08/2015 1019 ; 10/11/2014 (Retro UNIX 386 v1 - Erdogan Tan) 1020 ; 1021 ;cli ; Disable interrupts (for CPU) 1022 ; (CPU will not handle hardware interrupts, except NMI!) 1023 ; 1024 0000062B 30C0 xor al, al ; Enable all hardware interrupts! 1025 0000062D E621 out 21h, al ; (IBM PC-AT compatibility) 1026 0000062F EB00 jmp $+2 ; (All conventional PC-AT hardware 1027 00000631 E6A1 out 0A1h, al ; interrupts will be in use.) 1028 ; (Even if related hardware component 1029 ; does not exist!) 1030 ; Enable NMI 1031 00000633 B07F mov al, 7Fh ; Clear bit 7 to enable NMI (again) 1032 00000635 E670 out 70h, al 1033 ; 23/02/2015 1034 00000637 90 nop 1035 00000638 E471 in al, 71h ; read in 71h just after writing out to 70h 1036 ; for preventing unknown state (!?) 1037 ; 1038 ; Only a NMI can occur here... (Before a 'STI' instruction) 1039 ; 1040 ; 02/09/2014 1041 ;xor bx, bx 1042 ; 24/07/2022 1043 0000063A 31DB xor ebx, ebx 1044 0000063C 66BA0002 mov dx, 0200h ; Row 2, column 0 ; 07/03/2015 1045 00000640 E8E81C0000 call _set_cpos ; 24/01/2016 1046 1047 ; 14/11/2020 (TRDOS 386 v2.0.3) 1048 ; Check VBE3 protected mode interface/feature(s) 1049 1050 ;cmp byte [vbe3], 3 ; 03h 1051 ;jne short display_mem_info 1052 1053 ; 20/11/2020 1054 00000645 803D[86090000]02 cmp byte [vbe3], 2 ; 02h 1055 0000064C 7707 ja short vbe3_pmid_chk 1056 ;;jb short display_mem_info 1057 ;jb display_mem_info ; 02/12/2020 1058 0000064E 7220 jb short jmp_display_mem_info ; 24/07/2022 1059 00000650 E9EE010000 jmp check_boch_plex86_vbe 1060 1061 vbe3_pmid_chk: 1062 00000655 B9EA7F0000 mov ecx, 32768 - (20+2) ; 32766 - PMInfoBlockSize 1063 0000065A BE02000C00 mov esi, 0C0002h ; 1st word of the video bios rom is 0AA55h 1064 1065 chk_pmi_sign: 1066 ;mov eax, [esi] 1067 ;cmp eax, 'PMID' 1068 ; 30/11/2020 1069 ;cmp al, 'P' 1070 ;jne short chk_pmi_sign_next 1071 0000065F 813E504D4944 cmp dword [esi], 'PMID' 1072 ;je short display_vbios_product_name 1073 00000665 740E je short verify_pmib_chksum ; 15/11/2020 1074 ;chk_pmi_sign_next: 1075 00000667 46 inc esi ; inc si 1076 00000668 E2F5 loop chk_pmi_sign 1077 1078 not_valid_pmib: 1079 0000066A FE0D[86090000] dec byte [vbe3] ; 2 = VBE2 compatible 1080 ; (vbe3 feature is defective in this vbios) 1081 ;jmp short display_mem_info 1082 jmp_display_mem_info: ; 24/07/2022 1083 ; 02/12/2020 1084 00000670 E987010000 jmp display_mem_info 1085 1086 verify_pmib_chksum: 1087 ; 18/10/2023 1088 ; (ATI RV370 video bios contains ZERO at Checksum offset.) 1089 00000675 31C0 xor eax, eax 1090 00000677 384613 cmp byte [esi+19], al ; 0 ; Checksum byte 1091 0000067A 7611 jna short skip_verify_pmib_chksum ; may be ATI video bios 1092 ;cmp dword [esi+16], 0C000h 1093 ; ; CodeSegSel = 0C000h, InProtectMode = 0, Checksum = 0 1094 ;je short skip_verify_pmib_chksum ; may be ATI video bios 1095 ; 18/10/2023 1096 ; 15/11/2020 1097 ;xor eax, eax 1098 ;;mov ecx, eax 1099 ;mov cl, 20 1100 0000067C 66B91400 mov cx, 20 ; 30/11/2020 1101 00000680 56 push esi 1102 pmib_sum_bytes: 1103 00000681 AC lodsb 1104 00000682 00C4 add ah, al 1105 00000684 E2FB loop pmib_sum_bytes 1106 00000686 5E pop esi 1107 00000687 08E4 or ah, ah 1108 00000689 75DF jnz short not_valid_pmib ; AH must be 0 1109 1110 ; 18/10/2023 1111 0000068B 30C0 xor al, al ; eax = 0 1112 1113 ; 28/02/2021 1114 ; Set default (initial) truecolor bpp value to 32 1115 ; (for VBE3 video bios.. because vbe3 video bioses 1116 ; use 32bpp -for truecolor modes- instead of 24bpp) 1117 ; (This setting may be changed via 'sysvideo' bx=0908h) 1118 1119 skip_verify_pmib_chksum: ; 18/10/2023 1120 1121 0000068D C605[83790100]20 mov byte [truecolor], 32 ; (RGB: 00RRGGBBh) 1122 1123 display_vbios_product_name: ; 14/11/2020 1124 1125 ; ESI points to 'PMID' (0C0000h + 'PMID' offset) 1126 1127 ; 15/11/2020 1128 ;mov [pmid_addr], si ; PMInfoBlock offset 1129 ; ; (in VGA bios, 0C0000h + offset) 1130 ; 02/12/2020 1131 ;push esi ; * pmid_addr 1132 00000694 89F7 mov edi, esi 1133 1134 ;mov esi, [VBE3INFOBLOCK+22] ; 097E00h + 16h 1135 ; ; OemVendorNamePtr (seg16:off16) 1136 00000696 8B35067E0900 mov esi, [VBE3INFOBLOCK+6] ; 097E00h + 06h 1137 ; OemStringPtr (seg16:off16) 1138 ; 18/10/2023 1139 ;xor al, al ; eax = 0 1140 0000069C 6696 xchg ax, si ; ax = offset, si = 0 1141 0000069E C1EE0C shr esi, 12 ; (to convert segment to base addr) 1142 000006A1 6601C6 add si, ax ; esi has an address < 1 MB limit 1143 ; (OemVendorName is in VBE3INFOBLOCK) 1144 ; Example: 1145 ; TRDOS 386 v2.0.3 VESA VBE3 protected mode 1146 ; interface development reference is ... 1147 ; NVIDIA GeForce FX5500 VGA BIOS -C000h:029Ch- 1148 ; Version 4.34.20.54.00 -C000h:02EDh- 1149 ; ((OemString is 'NVIDIA')) 1150 ; ((OemVendorName is 'NVIDIA Corporation')) 1151 ; ((OemProductName is 'NV34 Board - p162-1nz)) 1152 1153 ;mov ah, 0Eh ; Black background, yellow forecolor 1154 ; 30/11/2020 1155 000006A4 B40C mov ah, 0Ch ; Black background, light red forecolor 1156 1157 000006A6 E8903A0000 call print_kmsg 1158 1159 ;mov ah, 07h 1160 1161 000006AB BE[65790100] mov esi, vesa_vbe3_bios_msg 1162 ;call print_kmsg 1163 000006B0 E88C3A0000 call pkmsg_loop ; 30/11/2020 1164 1165 ; 02/12/2020 1166 ;pop edi ; * pmid_addr 1167 1168 ; 04/12/2023 - TRDOS 386 v2.0.7 1169 %if 0 1170 ; 24/07/2022 1171 ; 29/11/2020 1172 vbe3pminit: 1173 ; 30/11/2020 1174 ;cmp byte [vbe3], 3 ; is VESA VBE3 PMI ready ? 1175 ;jne short di4 1176 1177 ; Allocate 64KB contiguous (kernel) memory block 1178 xor eax, eax 1179 mov ecx, 65536 1180 call allocate_memory_block 1181 ;jc short di4 1182 ;jc di0 ; 30/11/2020 1183 ; 24/07/2022 1184 jnc short vbe3pminit0 1185 jmp di0 1186 1187 vbe3pminit0: 1188 ; of course this block must be in the 1st 16MB 1189 ; because vbe3 pmi segments will be 16 bit segments 1190 ; (80286 type segment descriptors in GDT) 1191 1192 mov [vbe3bios_addr], eax 1193 %endif 1194 1195 ; 04/12/2023 - TRDOS 386 v2.0.7 ; (+!*!+) 1196 ; fixed PM-VBIOS address (no need to add a memory block) 1197 ; in the reserved -and already allocated- area under 1MB 1198 ; (purpose: to prevent page faults if memory size > 2.5GB) 1199 ; ((User's page dir contains only the 1st 4MB of system mem 1200 ; as PDE. So, this causes to page faults during an interrupt 1201 ; in user mode, because if memory size > 2.5GB, kernel 1202 ; page tables overs/passes 4MB limit and PM-VBIOS 1203 ; is located after kernel page tables.)) 1204 vbe3pminit: 1205 000006B5 B800000600 mov eax, VBE3BIOSCODE_ADDR ; 60000h ; (+!*!+) 1206 1207 ; set [pmid_addr] to the new location 1208 000006BA BE00000C00 mov esi, 0C0000h 1209 1210 ; 30/11/2020 1211 000006BF 29F7 sub edi, esi ; izolate offset 1212 000006C1 01C7 add edi, eax ; new address 1213 000006C3 893D[34A30100] mov [pmid_addr], edi ; new 'PMID' location 1214 1215 ; Move VIDEO BIOS from 0C0000h to EAX 1216 000006C9 B900400000 mov ecx, 65536/4 1217 000006CE 89C7 mov edi, eax ; 30/11/2020 1218 000006D0 F3A5 rep movsd 1219 1220 ; 02/12/2020 1221 ; 30/11/2020 1222 ; set vbe3 segment selectors 1223 1224 ; 04/12/2023 - TRDOS 386 v2.0.7 ; (+!*!+) 1225 %if 0 1226 ; VBE3CS (VESA VBE3 video bios code segment) 1227 mov edi, _vbe3_CS+2 ; base address bits 0..15 1228 stosw ; edi = _vbe3_CS+4 1229 ror eax, 16 1230 mov [edi], al ; base address, bits 16..23 1231 1232 ; VBE3DS ('CodeSegSel' in PMInfoBlock) 1233 mov edi, _vbe3_DS+4 ; base addr bits 16..23 1234 mov [edi], al 1235 rol eax, 16 1236 mov [edi-2], ax ; base address, bits 0..15 1237 %endif 1238 ; VBE3BDS (BIOSDataSel in PMInfoBlock) 1239 000006D2 BF[6A650000] mov edi, _vbe3_BDS+2 ; base addr bits 0..15 1240 000006D7 B800700900 mov eax, VBE3BIOSDATABLOCK ; 1536 bytes 1241 000006DC 66AB stosw ; edi = _vbe3_BDS+4 1242 000006DE C1E810 shr eax, 16 1243 000006E1 8807 mov [edi], al ; base address, bits 16..23 1244 1245 ; VBE3SS (1024 bytes) 1246 000006E3 BF[92650000] mov edi, _vbe3_SS+2 ; base addr bits 0..15 1247 000006E8 B800600900 mov eax, VBE3STACKADDR ; size = 1024 bytes 1248 000006ED 66AB stosw ; edi = _vbe3_SS+4 1249 000006EF C1E810 shr eax, 16 1250 000006F2 8807 mov [edi], al ; base address, bits 16..23 1251 1252 ; stack pointer (esp) will be set to 1020 1253 ; (before VBE3 PMI call) 1254 1255 ; VBE3ES (max: 2048 bytes) 1256 000006F4 BF[9A650000] mov edi, _vbe3_ES+2 ; base addr bits 0..15 1257 000006F9 B800760900 mov eax, VBE3SAVERESTOREBLOCK 1258 000006FE 66AB stosw ; edi = _vbe3_ES+4 1259 00000700 C1E810 shr eax, 16 1260 00000703 8807 mov [edi], al ; base address, bits 16..23 1261 1262 ;Note: low word of _VBE3_ES base address will be 1263 ; set -again- by VBE3 PMI caller routine 1264 1265 ; 09/12/2020 1266 ;; set pmi32 (as VBE3 PMI is ready) 1267 ;inc byte [pmi32] ; = 1 1268 1269 ; KCODE16 (set PMI far return segment) 1270 00000705 BF[A2650000] mov edi, _16bit_CS+2 ; base addr bits 0..15 1271 0000070A B8[92070000] mov eax, pminit_return_addr16 1272 0000070F 66AB stosw ; edi = _16bit_CS+4 1273 00000711 C1E810 shr eax, 16 1274 00000714 8807 mov [edi], al ; base address, bits 16..23 1275 1276 ; 30/11/2020 1277 ; clear mem from VBE3 BIOS data area emu block 1278 ; to end of vbe3 buffers 1279 1280 ; 18/10/2023 - TRDOS v2.0.7 1281 ; (VBE3BIOSDATABLOCK contains a copy of the 1st 1282 ; 1536 bytes of the memory, IVT, ROMBIOS DATA etc.) 1283 ; ((it must not be cleared here)) 1284 %if 0 1285 ; 01/12/2020 1286 mov edi, VBE3BIOSDATABLOCK ; 97000h 1287 ;mov cx, (VBE3INFOBLOCK-VBE3BIOSDATABLOCK)/4 1288 ; ; ecx = 3584/4 double words 1289 ; 21/12/2020 1290 mov cx, (VBE3MODEINFOBLOCK-VBE3BIOSDATABLOCK)/4 1291 ; ecx = 3072/4 double words 1292 ;xor eax, eax 1293 xor al, al 1294 rep stosd 1295 %endif 1296 ; 18/10/2023 - TRDOS v2.0.7 1297 ; (VBE3BIOSDATABLOCK contains a copy of the 1st 1298 ; 1536 bytes of the memory, IVT, ROMBIOS DATA etc.) 1299 ; ((it must not be cleared here)) 1300 00000716 BF00760900 mov edi, VBE3SAVERESTOREBLOCK ; 97600h 1301 0000071B 66B98001 mov cx, (VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK)/4 1302 ; ecx = 1536/4 = 384 double words 1303 ;xor eax, eax 1304 0000071F 30C0 xor al, al 1305 00000721 F3AB rep stosd 1306 1307 ; Filling PMInfoBlock selector fields 1308 00000723 8B3D[34A30100] mov edi, [pmid_addr] 1309 00000729 66C747083800 mov word [edi+PMInfo.BIOSDataSel], VBE3BDS 1310 0000072F 66C7470A4000 mov word [edi+PMInfo.A0000Sel], VBE3A000 1311 00000735 66C7470C4800 mov word [edi+PMInfo.B0000Sel], VBE3B000 1312 0000073B 66C7470E5000 mov word [edi+PMInfo.B8000Sel], VBE3B800 1313 00000741 66C747105800 mov word [edi+PMInfo.CodeSegSel], VBE3DS 1314 00000747 C6471201 mov byte [edi+PMInfo.InProtectMode], 1 1315 1316 ; Calculate and write checksum byte 1317 0000074B 89FE mov esi, edi 1318 0000074D B113 mov cl, PMInfo.size - 1 1319 ;xor ah, ah 1320 pmid_chksum: 1321 0000074F AC lodsb 1322 00000750 00C4 add ah, al 1323 00000752 E2FB loop pmid_chksum 1324 00000754 F6DC neg ah ; 1 -> 255, 255 -> 1 1325 00000756 8826 mov [esi], ah ; checksum 1326 1327 ; far call PM initialization 1328 ; (VBE3 video bios will return via 'retf') 1329 1330 00000758 668B4706 mov ax, [edi+PMInfo.PMInitialize] 1331 ; 30/11/2020 1332 0000075C C1E010 shl eax, 16 ; save entry address in hw 1333 ; ax = 0 1334 1335 ; 02/12/2020 1336 0000075F 68[B6070000] push pminit_ok ; normal, near return address 1337 1338 ; 30/11/2020 1339 _VBE3PMI_fcall: 1340 ; ax = function, hw of eax = entry address 1341 00000764 9C pushf ; save 32 bit flags 1342 00000765 56 push esi ; * 1343 00000766 55 push ebp ; ** 1344 1345 00000767 89E5 mov ebp, esp ; save 32 bit stack pointer 1346 1347 00000769 89C6 mov esi, eax 1348 1349 0000076B FA cli 1350 1351 ; Disable interrupts (clear interrupt flag) 1352 ; Reset Interrupt MASK Registers (Master&Slave) 1353 0000076C B0FF mov al, 0FFh ; mask off all interrupts 1354 0000076E E621 out 21h, al ; on master PIC (8259) 1355 00000770 EB00 jmp $+2 ; (delay) 1356 00000772 E6A1 out 0A1h, al ; on slave PIC (8259) 1357 1358 ; 02/12/2020 1359 00000774 66B86000 mov ax, VBE3SS 1360 00000778 8ED0 mov ss, ax 1361 1362 0000077A BCFC030000 mov esp, 1020 ; 30/11/2020 1363 1364 ; 01/12/2020 1365 ;lss esp, [stack16] 1366 1367 0000077F C1E810 shr eax, 16 ; now, entry address is in lw 1368 1369 ; 30/11/2020 - 16 bit pm selector test (OK) 1370 ; (32 bit stack push/pop & retf with 32 bit code segment) 1371 ; (16 bit stack push/pop with 16 bit code segment) 1372 1373 ; return 1374 ;push KCODE16 1375 ;push 0 ; 30/11/2020 (pminit_return_addr16) 1376 1377 ; 30/11/2020 (16 bit stack during retf from video bios) 1378 00000782 C7042400007000 mov dword [esp], KCODE16 << 16 1379 ; ip = 0, cs = KCODE16 1380 ; 01/12/2020 1381 ;mov dword [VBE3STACKADDR+1020], KCODE16*65536 1382 1383 ;mov [jumpfar16], eax 1384 1385 ; 02/12/2020 1386 ; 30/11/2020 (32 bit stack during retf from kernel) 1387 ; far jump/call via retf 1388 00000789 6A30 push VBE3CS ; VBE3 video bios's code segment 1389 0000078B 50 push eax ; PMInitialize or EntryPoint 1390 1391 ;mov ax, si ; restore function 1392 ; 24/07/2022 1393 0000078C 89F0 mov eax, esi 1394 1395 ; 02/12/2020 1396 0000078E 31F6 xor esi, esi ; (not necessary, it is not used) 1397 1398 00000790 CB retf ; far return (to 16 bit code segment) 1399 1400 ; 01/12/2020 1401 ;db 0EAh ; far jump to 16 bit code segment 1402 ;jumpfar16: 1403 ;dd 0 1404 ;dw VBE3CS 1405 1406 ;stack16: 1407 ;dd 1020 1408 ;dw VBE3SS 1409 1410 00000791 90 align 2 1411 1412 pminit_return_addr16: 1413 ; 02/12/2020 1414 ; 30/11/2020 1415 ;;db 66h ; Prefix for 32-bit 1416 ;db 0EAh ; Opcode for far jump 1417 ;dd pminit_return_addr32 ; 32 bit Offset 1418 ;dw KCODE ; 32 bit code segment 1419 ; 01/12/2020 1420 00000792 EA[99070000]0800 jmp KCODE:pminit_return_addr32 1421 1422 pminit_return_addr32: 1423 ; restore 32 bit kernel selectors and 32 bit stack addr 1424 00000799 BE10000000 mov esi, KDATA 1425 0000079E 8EDE mov ds, si 1426 000007A0 8EC6 mov es, si 1427 000007A2 8ED6 mov ss, si 1428 000007A4 89EC mov esp, ebp ; top of stack = iretd return addr 1429 1430 000007A6 5D pop ebp ; ** 1431 000007A7 5E pop esi ; * 1432 000007A8 9D popf ; restore 32 bit flags 1433 1434 ; enable interrupts 1435 1436 000007A9 FA cli 1437 1438 ; 21/12/2020 1439 000007AA 50 push eax 1440 1441 000007AB 30C0 xor al, al ; Enable all hardware interrupts! 1442 000007AD E621 out 21h, al ; (IBM PC-AT compatibility) 1443 000007AF EB00 jmp $+2 ; (All conventional PC-AT hardware 1444 000007B1 E6A1 out 0A1h, al ; interrupts will be in use.) 1445 ; (Even if related hardware component 1446 ; does not exist!) 1447 000007B3 58 pop eax 1448 1449 000007B4 FB sti 1450 1451 ; top of stack = return address 1452 ; ('pminit_ok' for PMinit) 1453 1454 000007B5 C3 retn 1455 1456 pminit_ok: 1457 ; 03/12/2020 1458 ; (set [pmid_addr] to PMI entry point for next calls) 1459 000007B6 8305[34A30100]04 add dword [pmid_addr], PMInfo.EntryPoint ; + 4 1460 1461 ; 17/01/2021 1462 ; copy EDID data from temporary location to final address 1463 000007BD 803D[D3410000]4F cmp byte [edid], 4Fh 1464 000007C4 7510 jne short vbe3h_chcl 1465 ;mov ecx, 32 ; 128 bytes, 32 dwords 1466 ; 24/07/2022 1467 000007C6 31C9 xor ecx, ecx 1468 000007C8 B120 mov cl, 32 1469 000007CA BE007D0900 mov esi, VBE3EDIDINFOBLOCK ; 97D00h 1470 000007CF BF[ACA20100] mov edi, edid_info 1471 000007D4 F3A5 rep movsd 1472 ; 17/01/2021 1473 vbe3h_chcl: 1474 ; 16/01/2021 1475 ;; 06/12/2020 1476 ;; Save video mode 03h regs/dac/bios state 1477 ; 1478 ;mov ax, 4F04h ; VESA VBE Function 04h 1479 ; ; Save/Restore State 1480 ;sub dl, dl ; 0 = return buffer size 1481 ;mov cx, 0Fh ; ctrl/bios/dac/regs 1482 ; 1483 ;call int10h_32bit_pmi 1484 ;; bx = number of 64-byte blocks to hold the state buff 1485 ; 1486 ;;mov [vbe3stbufsize], bx 1487 ;; 16/01/2021 1488 ;or word [vbe3stbsflags], 32768 ; set bit 15 1489 ;mov ax, bx 1490 ;shl ax, 6 ; * 64 1491 ;mov [vbestatebufsize+30], ax 1492 ; 1493 ;; 06/12/2020 1494 ;; check 'vbe3stbufsize' (it must be <= 32) 1495 ; 1496 ;cmp bx, 32 1497 ;ja short display_mem_info ; light red forecolor 1498 ; 1499 ;; 16/01/2021 1500 ;or byte [vbe3stbsflags], 1 ; set bit 0 1501 1502 ; 30/11/2020 1503 ; Change VESA VBE3 BIOS text color in order to give 1504 ; "VBE3 PMI initialization has been successed" meaning 1505 1506 000007D6 BE40810B00 mov esi, 0B8000h + 160*2 ; row 2 1507 000007DB 89F7 mov edi, esi 1508 vbe3h_chcl_next: 1509 000007DD 66AD lodsw 1510 000007DF 80FC0C cmp ah, 0Ch ; light red forecolor 1511 000007E2 7518 jne short display_mem_info 1512 000007E4 B40E mov ah, 0Eh ; yellow forecolor 1513 000007E6 66AB stosw 1514 000007E8 EBF3 jmp short vbe3h_chcl_next 1515 1516 di5: 1517 ; 18/10/2023 - TRDOS 386 v2.0.7 1518 ; ATI RV370 Video BIOS (VESA VBE2) 1519 ; has PMI. (as described in VESA VBE3 specification) 1520 ; 1521 000007EA FE05[86090000] inc byte [vbe3] ; [vbe3] = 2 -> 3 1522 ; will be decreased to 2 again if 'PMID' 1523 ; signature will not be found. 1524 000007F0 E960FEFFFF jmp vbe3_pmid_chk ; check for ATI Video BIOS 1525 1526 di0: 1527 ; 30/11/2020 1528 ; Memory allocation error ! 1529 000007F5 C605[86090000]00 mov byte [vbe3], 0 ; disable VBE3 1530 1531 display_mem_info: 1532 ; 19/12/2020 1533 ; temporary 1534 ; 24/11/2023 1535 000007FC 803D[86090000]02 cmp byte [vbe3], 2 1536 00000803 7205 jb short dmi 1537 00000805 E84D390000 call default_lfb_info 1538 dmi: 1539 ; 06/11/2014 1540 0000080A E8D3380000 call memory_info 1541 ; 14/08/2015 1542 ;call getch ; 28/02/2015 1543 1544 ; 07/12/2023 1545 ; check EDID info for LCD monitor -screen resolution- 1546 ; for modifying VGA mode 13h CRTC parameters 1547 ; (if it is needed or not) 1548 1549 0000080F E82D010000 call video_mode_13h_parms 1550 1551 drv_init: 1552 00000814 FB sti ; Enable Interrupts 1553 ; 06/02/2015 1554 00000815 8B15[3E660000] mov edx, [hd0_type] ; hd0, hd1, hd2, hd3 1555 0000081B 668B1D[3C660000] mov bx, [fd0_type] ; fd0, fd1 1556 ; 22/02/2015 1557 00000822 6621DB and bx, bx 1558 00000825 756C jnz short di1 1559 ; 1560 00000827 09D2 or edx, edx 1561 00000829 757A jnz short di2 1562 ; 1563 setup_error: 1564 0000082B BE[0E3F0100] mov esi, setup_error_msg 1565 psem: 1566 00000830 AC lodsb 1567 00000831 08C0 or al, al 1568 ;jz short haltx ; 22/02/2015 1569 00000833 747C jz short di3 1570 00000835 56 push esi 1571 ; 13/05/2016 1572 00000836 BB07000000 mov ebx, 7 ; Black background, 1573 ; light gray forecolor 1574 ; Video page 0 (BH=0) 1575 0000083B E8551A0000 call _write_tty 1576 00000840 5E pop esi 1577 00000841 EBED jmp short psem 1578 1579 check_boch_plex86_vbe: 1580 ; 20/10/2023 1581 ; 18/10/2023 1582 ; 20/11/2020 1583 ; check Bochs/Plex86 VGABios VBE extension 1584 ; (check if TRDOS 386 v2 is running on emulators) 1585 ; BOCHS/QEMU/VIRTUALBOX 1586 ; 1587 ; ref: vbe_display_api.txt 1588 1589 ; bochs/plex86 VGAbios VBE source code 1590 ; by Jeroen Janssen (2002) 1591 ; and Volker Ruppert (2003-2020) 1592 1593 ; 20/10/2023 1594 ; (ATI RV370 video bios has PMI support but 1595 ; it is a VESA VBE2 bios. So, even if [vbe3] is set 1596 ; to 3 for PMI functionality, it is better to display 1597 ; VESA VBE number as it is declared by the video bios.) 1598 1599 00000843 C605[6E790100]32 mov byte [vbe_vnumber], "2" ; 20/10/2023 1600 1601 0000084A 29C0 sub eax, eax ; 0 1602 0000084C 66BACE01 mov dx, 1CEh ; VBE_DISPI_IOPORT_INDEX 1603 00000850 66EF out dx, ax ; VBE_DISPI_INDEX_ID register 1604 ;mov ax, 0B0C0h ; VBE_DISPI_ID0 1605 ;mov dx, 1CFh ; VBE_DISPI_IOPORT_DATA 1606 00000852 6642 inc dx 1607 ;out dx, ax 1608 ;nop 1609 00000854 66ED in ax, dx 1610 00000856 80FCB0 cmp ah, 0B0h 1611 ;jne short not_boch_qemu_vbe 1612 ; 18/10/2023 1613 ;jne short display_mem_info 1614 00000859 758F jne short di5 ; ATI VESA VBE2 bios or another 1615 1616 0000085B 3CC5 cmp al, 0C5h ; it must be 0B0C4h or 0B0C5h .. 1617 ;ja short not_boch_qemu_vbe 1618 0000085D 779D ja short display_mem_info 1619 0000085F 3CC0 cmp al, 0C0h ; 0B0C0h to 0B0C5h .. ; Qemu 1620 ;cmp al, 0C4h ; 0BC04h or 0B0C5h is OK ; Bochs 1621 ;jb short not_boch_qemu_vbe 1622 00000861 7299 jb short display_mem_info 1623 1624 ; save VESA VBE2 bios (bochs/qemu) signature 1625 ; for enabling VBE2 functions in TRDOS 386 v2 kernel 1626 00000863 A2[87090000] mov [vbe2bios], al ; 0C4h or 0C5h (for BOCHS) 1627 ; (0C0h-0C5h for QEMU) 1628 ; 20/10/2023 1629 ;mov byte [vbe_vnumber], "2" 1630 1631 ; 26/11/2020 1632 ; "BOCHS/QEMU/VIRTUALBOX VBE2 Video BIOS ..". 1633 00000868 BE[50790100] mov esi, vbe2_bochs_vbios ; BOCH/QEMU vbios msg 1634 0000086D B40E mov ah, 0Eh ; Yellow font 1635 0000086F E8C7380000 call print_kmsg 1636 1637 ; this is not necessary ! (20/11/2020) 1638 00000874 803D[87090000]C4 cmp byte [vbe2bios], 0C4h 1639 ;jb display_mem_info ; (QEMU) 1640 ; 02/12/2023 1641 0000087B 720E jb short not_boch_qemu_vbe 1642 1643 ; Display kernel version message if 0E9h hack port 1644 ; is enabled (bochs emulator feature) 1645 0000087D 66BAE900 mov dx, 0E9h ; hack port for BOCHS 1646 00000881 BE[A9790100] mov esi, kernel_version_msg 1647 kvmsg_next_char: 1648 00000886 AC lodsb 1649 00000887 08C0 or al, al 1650 00000889 7505 jnz short put_kvmsg_in_hack_port 1651 not_boch_qemu_vbe: 1652 0000088B E96CFFFFFF jmp display_mem_info 1653 put_kvmsg_in_hack_port: 1654 00000890 EE out dx, al 1655 00000891 EBF3 jmp short kvmsg_next_char 1656 1657 di1: 1658 ; supress 'jmp short T6' 1659 ; (activate fdc motor control code) 1660 00000893 66C705[E8090000]90- mov word [T5], 9090h ; nop 1660 0000089B 90 1661 ; 1662 ;mov ax, int_0Eh ; IRQ 6 handler 1663 ;mov di, 0Eh*4 ; IRQ 6 vector 1664 ;stosw 1665 ;mov ax, cs 1666 ;stosw 1667 ;; 16/02/2015 1668 ;;mov dword [DISKETTE_INT], fdc_int ; IRQ 6 handler 1669 ; 1670 0000089C E8CF450000 CALL DSKETTE_SETUP ; Initialize Floppy Disks 1671 ; 1672 000008A1 09D2 or edx, edx 1673 000008A3 740C jz short di3 1674 di2: 1675 000008A5 E8FC450000 call DISK_SETUP ; Initialize Fixed Disks 1676 ;jc setup_error 1677 ; 24/07/2022 1678 000008AA 7305 jnc short di3 1679 000008AC E97AFFFFFF jmp setup_error 1680 di3: 1681 000008B1 E800380000 call setup_rtc_int ; 22/05/2015 (dsectrpm.s) 1682 ; 1683 000008B6 E8E9340100 call display_disks ; 07/03/2015 (Temporary) 1684 ;haltx: 1685 ; 14/08/2015 1686 ;call getch ; 22/02/2015 1687 ;sti ; Enable interrupts (for CPU) 1688 ; ; 29/01/2016 1689 ; sub ah, ah ; read time count 1690 ; call int1Ah 1691 ; mov edx, ecx ; 18.2 * seconds 1692 ;md_info_msg_wait1: 1693 ; ; 29/01/2016 1694 ; mov ah, 1 1695 ; call int16h 1696 ; jz short md_info_msg_wait2 1697 ; xor ah, ah ; 0 1698 ; call int16h 1699 ; jmp short md_info_msg_ok 1700 ;md_info_msg_wait2: 1701 ; sub ah, ah ; read time count 1702 ; call int1Ah 1703 ; cmp edx, ecx ; ; 18.2 * seconds 1704 ; jna short md_info_msg_wait3 1705 ; xchg edx, ecx 1706 ;md_info_msg_wait3: 1707 ; sub ecx, edx 1708 ; cmp ecx, 127 ; 7 seconds (18.2 * 7) 1709 ; jb short md_info_msg_wait1 1710 ;md_info_msg_ok: 1711 1712 ; 15/12/2020 1713 ; set initial values of LFB parameters 1714 1715 000008BB 803D[86090000]02 cmp byte [vbe3], 2 1716 000008C2 7225 jb short di4 1717 1718 ;mov ax, [def_LFB_addr] 1719 ;shl eax, 16 1720 ;mov [LFB_ADDR], eax 1721 ;mov eax, 1024*768*3 1722 ;mov [LFB_SIZE], eax 1723 1724 000008C4 BEFE7B0900 mov esi, VBE3MODEINFOBLOCK - 2 1725 000008C9 66C7061801 mov word [esi], 0118h ; default vbe mode 1726 ; 1024*768, 24bpp 1727 000008CE E88E300000 call set_lfbinfo_table 1728 1729 ;;; 1730 ; 28/11/2023 1731 ; 20/10/2023 - TRDOS 386 v2.0.7 1732 000008D3 8B35[3CA30100] mov esi, [LFB_ADDR] ; LFB base address (in bytes) 1733 ;mov edx, [LFB_SIZE] ; 28/11/2023 1734 ;add edx, 4095 1735 ;;; 1736 ;mov edx, ((1024*768*4)+4095)>>12 ; 28/11/2023 1737 000008D9 BAE9070000 mov edx, ((1920*1080*4)+4095)>>12 ; 28/11/2023 1738 ; edx = LFB size in pages 1739 1740 ; 29/11/2023 1741 ;mov ebx, esi 1742 ;;add ebx, 4095 ; LFB start addr is always in page boundary 1743 ;shr ebx, 12 ; convert byte address to page address 1744 000008DE 8B0D[C47C0100] mov ecx, [memory_size] 1745 ;cmp ebx, ecx 1746 ;jnb short di4 ; LFB addr >= main memory size 1747 1748 ; (set the overlapped pages as allocated for kernel) 1749 ;;; 1750 ; 28/11/2023 1751 ; (and set all of LFB pages in the kernel's page tables) 1752 1753 000008E4 E850590000 call allocate_lfb_pages_for_kernel 1754 di4: 1755 ; 08/09/2016 1756 000008E9 0F20C0 mov eax, cr0 1757 000008EC A810 test al, 10h ; Bit 4, ET (Extension Type) 1758 000008EE 7408 jz short sysinit 1759 ; 27/02/2017 1760 000008F0 FE05[7C890100] inc byte [fpready] 1761 ; 80387 (FPU) is ready 1762 000008F6 DBE3 fninit ; Initialize Floating-Point Unit 1763 sysinit: 1764 ; 30/06/2015 1765 000008F8 E84D630000 call sys_init 1766 ; 1767 ;jmp cpu_reset ; 22/02/2015 1768 hang: 1769 ; 23/02/2015 1770 ;sti ; Enable interrupts 1771 000008FD F4 hlt 1772 ; 1773 ;nop 1774 ;; 03/12/2014 1775 ;; 28/08/2014 1776 ;mov ah, 11h 1777 ;call getc 1778 ;jz _c8 1779 ; 1780 ; 23/02/2015 1781 ; 06/02/2015 1782 ; 07/09/2014 1783 000008FE 31DB xor ebx, ebx 1784 00000900 8A1D[EE7C0100] mov bl, [ptty] ; active_page 1785 00000906 89DE mov esi, ebx 1786 ;shl si, 1 1787 ; 24/07/2022 1788 00000908 D1E6 shl esi, 1 1789 0000090A 81C6[F07C0100] add esi, ttychr 1790 00000910 668B06 mov ax, [esi] 1791 00000913 6621C0 and ax, ax 1792 ;jz short _c8 1793 00000916 74E5 jz short hang 1794 00000918 66C7060000 mov word [esi], 0 1795 0000091D 80FB03 cmp bl, 3 ; Video page 3 1796 ;jb short _c8 1797 00000920 72DB jb short hang 1798 ; 1799 ; 13/05/2016 1800 ; 07/09/2014 1801 nxtl: 1802 ;push bx 1803 ; 18/04/2021 1804 00000922 53 push ebx 1805 00000923 66BB0E00 mov bx, 0Eh ; Yellow character 1806 ; on black background 1807 ; bh = 0 (video page 0) 1808 ; Retro UNIX 386 v1 - Video Mode 0 1809 ; (PC/AT Video Mode 3 - 80x25 Alpha.) 1810 ;push ax 1811 ; 18/04/2021 1812 00000927 50 push eax 1813 00000928 E868190000 call _write_tty 1814 ;pop ax 1815 ; 18/04/2021 1816 0000092D 58 pop eax 1817 ;pop bx 1818 0000092E 5B pop ebx 1819 0000092F 3C0D cmp al, 0Dh ; carriage return (enter) 1820 ;jne short _c8 1821 00000931 75CA jne short hang 1822 00000933 B00A mov al, 0Ah ; next line 1823 00000935 EBEB jmp short nxtl 1824 1825 ;_c8: 1826 ; ; 25/08/2014 1827 ; cli ; Disable interrupts 1828 ; mov al, [scounter + 1] 1829 ; and al, al 1830 ; jnz hang 1831 ; call rtc_p 1832 ; jmp hang 1833 1834 ; 27/08/2014 1835 ; 20/08/2014 1836 printk: 1837 ;mov edi, [scr_row] 1838 pkl: 1839 00000937 AC lodsb 1840 00000938 08C0 or al, al 1841 0000093A 7404 jz short pkr 1842 0000093C 66AB stosw 1843 0000093E EBF7 jmp short pkl 1844 pkr: 1845 00000940 C3 retn 1846 1847 ; ************************************* 1848 video_mode_13h_parms: 1849 ; 07/12/2023 - TRDOS 386 v2.0.7 1850 ; Check EDID information for LCD monitors 1851 ; and change mode 13h parameters if it is required 1852 ; (if resolution > 1280x1024, it is LCD/panel monitor 1853 ; and Video Mode 13h parameters will be modified for 60HZ 1854 ; because LCD monitors does/can not display 320x200 70HZ 1855 ; standard VGA mode) 1856 1857 00000941 803D[D3410000]4F cmp byte [edid], 4Fh 1858 00000948 753B jne short CRT_monitor 1859 1860 0000094A BE[ACA20100] mov esi, edid_info 1861 0000094F 83C626 add esi, 26h ; EDID Standard Timing Identification 1862 00000952 B908000000 mov ecx, 8 1863 chk_edid: 1864 00000957 66AD lodsw 1865 00000959 3C81 cmp al, 129 ; (1280/8)-31 1866 0000095B 770E ja short LCD_monitor ; 16:9 1867 0000095D 3C01 cmp al, 1 1868 0000095F 7624 jna short CRT_monitor 1869 00000961 E2F4 loop chk_edid 1870 ;jmp short CRT_monitor 1871 00000963 C3 retn 1872 mode13h_crtc_60hz: 1873 00000964 0B3EB9858FB8E2 db 0Bh, 3Eh, 0B9h, 85h, 8Fh, 0B8h, 0E2h 1874 LCD_monitor: 1875 ; modify default (CRTC register) parameters for 60HZ 1876 ; (320x200 letterbox type screen will appear on LCD screen) 1877 ; 1878 ; Note: When/While [PMI32] -protected mode video bios- 1879 ; feature is enabled -by user- for MODE 13h, internal 1880 ; (TRDOS 386) VGA -video mode setting- parameters 1881 ; will not be used (will be bypassed) 1882 ; by TRDOS 386 kernel for all standard VGA modes. 1883 ; ((NVIDIA/ATI Video Bios PMI will be used.)) 1884 ; 1885 ; ref: github, juj/60hz.cpp 1886 ; https://gist.github.com/juj/ 1887 ; 1888 0000096B B107 mov cl, 7 1889 0000096D BE[64090000] mov esi, mode13h_crtc_60hz 1890 00000972 BF[7A690000] mov edi, vga_mode_13h+10+6 ; CRTC Registers (index: 6) 1891 00000977 A4 movsb ; Vertical Total Register 1892 00000978 A4 movsb ; Overflow Register 1893 00000979 BF[84690000] mov edi, vga_mode_13h+10+16 ; CRTC Regs (index: 16) 1894 0000097E A4 movsb ; Vertical Retrace Start Register 1895 0000097F A4 movsb ; Vertical Retrace End Register 1896 00000980 A4 movsb ; Vertical Display Enable/End Register 1897 00000981 47 inc edi 1898 00000982 47 inc edi 1899 00000983 A4 movsb ; Vertical Blanking Start Register 1900 00000984 A4 movsb ; Vertical Blanking End Register 1901 CRT_monitor: 1902 00000985 C3 retn 1903 ; ************************************* 1904 1905 ; 14/11/2020 (TRDOS 386 v2.0.3) 1906 00000986 00 vbe3: db 0 ; VESA VBE version (must be 03h) 1907 ; for using video bios calls in protected mode 1908 vbe2bios: 1909 00000987 B0 db 0B0h ; 1910 ;pmid_addr: 1911 ;dw 0 ; > 0 if 'PMID' sign is found 1912 ; ; ('pmid' offset addr in VGA bios seg, 0C000h) 1913 ;; 02/12/2020 1914 ;dw 0 ; 32 bit address in pmid_addr 1915 1916 ; 28/02/2017 1917 ; 22/01/2017 1918 ; 15/01/2017 1919 ; 14/01/2017 1920 ; 02/01/2017 1921 ; 25/12/2016 1922 ; 19/12/2016 1923 ; 10/12/2016 (callback) 1924 ; 06/06/2016 1925 ; 23/05/2016 1926 ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications 1927 ; 25/07/2015 1928 ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer) 1929 ; 17/02/2015 1930 ; 06/02/2015 (unix386.s) 1931 ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 1932 ; 1933 ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85) 1934 ; 1935 ;-- HARDWARE INT 08 H - ( IRQ LEVEL 0 ) --------------------------------------- 1936 ; THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF : 1937 ; THE 8254 TIMER. INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR : 1938 ; IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND. : 1939 ; : 1940 ; THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE : 1941 ; POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY. : 1942 ; THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40) : 1943 ; OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE : 1944 ; DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS. : 1945 ; THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH : 1946 ; INTERRUPT 1CH AT EVERY TIME TICK. THE USER MUST CODE A : 1947 ; ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE. : 1948 ;------------------------------------------------------------------------------- 1949 ; 1950 1951 timer_int: ; IRQ 0 1952 ;int_08h: ; Timer 1953 ; 14/10/2015 1954 ; Here, we are simulating system call entry (for task switch) 1955 ; (If multitasking is enabled, 1956 ; 'clock' procedure may jump to 'sysrelease') 1957 1958 00000988 1E push ds 1959 00000989 06 push es 1960 0000098A 0FA0 push fs 1961 0000098C 0FA8 push gs 1962 1963 0000098E 60 pushad ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi 1964 0000098F 66B91000 mov cx, KDATA 1965 00000993 8ED9 mov ds, cx 1966 00000995 8EC1 mov es, cx 1967 00000997 8EE1 mov fs, cx 1968 00000999 8EE9 mov gs, cx 1969 1970 0000099B 0F20D9 mov ecx, cr3 1971 0000099E 890D[84950100] mov [cr3reg], ecx ; save current cr3 register value/content 1972 1973 ; 14/01/2017 1974 000009A4 3B0D[C07C0100] cmp ecx, [k_page_dir] 1975 000009AA 7409 je short T3 1976 1977 000009AC 8B0D[C07C0100] mov ecx, [k_page_dir] 1978 000009B2 0F22D9 mov cr3, ecx 1979 T3: 1980 ;sti ; INTERRUPTS BACK ON 1981 000009B5 66FF05[407D0100] INC word [TIMER_LOW] ; INCREMENT TIME 1982 000009BC 7507 JNZ short T4 ; GO TO TEST_DAY 1983 000009BE 66FF05[427D0100] INC word [TIMER_HIGH] ; INCREMENT HIGH WORD OF TIME 1984 T4: ; TEST_DAY 1985 000009C5 66833D[427D0100]18 CMP word [TIMER_HIGH],018H ; TEST FOR COUNT EQUALING 24 HOURS 1986 000009CD 7519 JNZ short T5 ; GO TO DISKETTE_CTL 1987 000009CF 66813D[407D0100]B0- CMP word [TIMER_LOW],0B0H 1987 000009D7 00 1988 000009D8 750E JNZ short T5 ; GO TO DISKETTE_CTL 1989 1990 ;----- TIMER HAS GONE 24 HOURS 1991 ;;SUB AX,AX 1992 ;MOV [TIMER_HIGH],AX 1993 ;MOV [TIMER_LOW],AX 1994 000009DA 29C0 sub eax, eax 1995 000009DC A3[407D0100] mov [TIMER_LH], eax 1996 ; 1997 000009E1 C605[447D0100]01 MOV byte [TIMER_OFL],1 1998 1999 ;----- TEST FOR DISKETTE TIME OUT 2000 2001 T5: 2002 ; 23/12/2014 2003 000009E8 EB1D jmp short T6 ; will be replaced with nop, nop 2004 ; (9090h) if a floppy disk 2005 ; is detected. 2006 ;mov al,[CS:MOTOR_COUNT] 2007 000009EA A0[477D0100] mov al, [MOTOR_COUNT] 2008 000009EF FEC8 dec al 2009 ;mov [CS:MOTOR_COUNT], al ; DECREMENT DISKETTE MOTOR CONTROL 2010 000009F1 A2[477D0100] mov [MOTOR_COUNT], al 2011 ;mov [ORG_MOTOR_COUNT], al 2012 000009F6 750F JNZ short T6 ; RETURN IF COUNT NOT OUT 2013 000009F8 B0F0 mov al,0F0h 2014 ;AND [CS:MOTOR_STATUS],al ; TURN OFF MOTOR RUNNING BITS 2015 000009FA 2005[467D0100] and [MOTOR_STATUS], al 2016 ;and [ORG_MOTOR_STATUS], al 2017 00000A00 B00C MOV AL,0CH ; bit 3 = enable IRQ & DMA, 2018 ; bit 2 = enable controller 2019 ; 1 = normal operation 2020 ; 0 = reset 2021 ; bit 0, 1 = drive select 2022 ; bit 4-7 = motor running bits 2023 00000A02 66BAF203 MOV DX,03F2H ; FDC CTL PORT 2024 00000A06 EE OUT DX,AL ; TURN OFF THE MOTOR 2025 T6: 2026 ;inc word [CS:wait_count] ; 22/12/2014 (byte -> word) 2027 ; TIMER TICK INTERRUPT 2028 ;;inc word [wait_count] ;;27/02/2015 2029 ;INT 1CH ; TRANSFER CONTROL TO A USER ROUTINE 2030 ;cli 2031 00000A07 E85E040000 call u_timer ; TRANSFER CONTROL TO A USER ROUTINE 2032 ; 23/05/2016 2033 00000A0C E842170100 call clock ; Multi Tasking control procedure 2034 T7: 2035 ; 14/10/2015 2036 00000A11 B020 MOV AL,EOI ; GET END OF INTERRUPT MASK 2037 00000A13 FA CLI ; DISABLE INTERRUPTS TILL STACK CLEARED 2038 00000A14 E620 OUT INTA00,AL ; END OF INTERRUPT TO 8259 - 1 2039 ; 2040 ;;; 2041 ; 21/08/2024 2042 00000A16 803D[4D890100]FF cmp byte [p_change], 0FFh ; CTRL+BREAK signature 2043 00000A1D 7424 je short T9 ; current program will be forced to sysrelease 2044 ;;; 2045 rtc_int_2: 2046 ; 26/12/2016 2047 ;mov ecx, [cr3reg] 2048 ; 13/01/2017 2049 00000A1F 803D[EC940100]00 cmp byte [u.t_lock], 0 ; T_LOCK 2050 00000A26 7730 ja short timer_int_return ; Timer Lock : 'sysrele' is needed ! 2051 ; 28/02/2017 2052 ; We need to exit if the user's IRQ callback service is in progress! 2053 ; (To prevent a conflict!) 2054 00000A28 803D[F0940100]00 cmp byte [u.r_lock], 0 ; R_LOCK, IRQ callback service lock ! 2055 00000A2F 7727 ja short timer_int_return ; Timer Lock : 'sysrele' is needed ! 2056 ; 15/01/2017 2057 00000A31 803D[4C890100]02 cmp byte [priority], 2 2058 00000A38 733A jnb short T8 ; current process has a timer event (15/01/2017) 2059 ; 22/05/2016 2060 00000A3A 803D[4D890100]00 cmp byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p' 2061 00000A41 7615 jna short timer_int_return ; 23/05/2016 2062 2063 ; 15/01/2017 2064 ; present process must be changed with high priority process 2065 T9: ; 21/08/2024 2066 ;xor al, al 2067 00000A43 31C0 xor eax, eax ; 26/12/2016 2068 00000A45 A2[4D890100] mov [p_change], al ; 0 2069 ;mov byte [priority], 2 ; 15/01/2017 (there is a timer event) 2070 2071 00000A4A 803D[68940100]FF cmp byte [sysflg], 0FFh ; user or system space ? 2072 00000A51 7416 je short rtc_int_3 ; user space ([sysflg]= 0FFh) 2073 2074 ; system space, wait for 'sysret' 2075 ; to change running process 2076 ; with high priority (event) process 2077 2078 00000A53 A2[BC940100] mov [u.quant], al ; 0 2079 2080 timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2') 2081 00000A58 8B0D[84950100] mov ecx, [cr3reg] ; previous value/content of cr3 register 2082 00000A5E 0F22D9 mov cr3, ecx ; restore cr3 register content 2083 ; 2084 00000A61 61 popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax 2085 ; 2086 00000A62 0FA9 pop gs 2087 00000A64 0FA1 pop fs 2088 00000A66 07 pop es 2089 00000A67 1F pop ds 2090 ; 2091 00000A68 CF iretd ; return from interrupt 2092 2093 rtc_int_3: 2094 00000A69 FE05[68940100] inc byte [sysflg] ; now, we are in system space 2095 ; 2096 00000A6F E901C40000 jmp sysrelease ; change running process immediatelly 2097 2098 T8: 2099 ; 13/01/2017 (eax -> ebx) 2100 ; callback checking... (19/12/2016) 2101 00000A74 31DB xor ebx, ebx 2102 00000A76 871D[E8940100] xchg ebx, [u.tcb] ; callback address (0 = normal return) 2103 00000A7C 09DB or ebx, ebx 2104 00000A7E 74D8 jz short timer_int_return 2105 2106 ; Set user's callback routine as return address from this interrupt 2107 ; and set normal return address as return address from callback 2108 ; routine!!! (19/12/2016) 2109 2110 ; 14/01/2017 2111 ; 13/01/2017 - Timer Lock (T_LOCK) 2112 00000A80 FE05[EC940100] inc byte [u.t_lock] 2113 00000A86 8A0D[68940100] mov cl, [sysflg] 2114 00000A8C 880D[ED940100] mov [u.t_mode], cl 2115 2116 00000A92 8B2D[5C7C0100] mov ebp, [tss.esp0] ; kernel stack address (for ring 0) 2117 00000A98 83ED14 sub ebp, 20 ; eip, cs, eflags, esp, ss 2118 00000A9B 892D[6C940100] mov [u.sp], ebp 2119 00000AA1 8925[70940100] mov [u.usp], esp 2120 2121 ;or word [ebp+8], 200h ; 22/01/2017, force enabling interrupts 2122 2123 00000AA7 8B44241C mov eax, [esp+28] ; pushed eax 2124 00000AAB A3[74940100] mov [u.r0], eax 2125 2126 00000AB0 E897030100 call wswap ; save user's registers & status 2127 2128 ; software int is in ring 0 but timer int must return to ring 3 2129 ; so, ring 3 return address and stack registers 2130 ; (eip, cs, eflags, esp, ss) 2131 ; must be copied to timer int return 2132 ; eip will be replaced by callback service routine address 2133 2134 00000AB5 C605[68940100]FF mov byte [sysflg], 0FFh ; user mode 2135 2136 ; system mode (system call) 2137 ;mov ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u), 2138 ; ESP (u), SS (UDATA) 2139 2140 00000ABC 8B4510 mov eax, [ebp+16] ; SS (UDATA 2141 00000ABF 89E6 mov esi, esp 2142 00000AC1 50 push eax 2143 00000AC2 50 push eax 2144 00000AC3 89E7 mov edi, esp 2145 00000AC5 893D[70940100] mov [u.usp], edi 2146 00000ACB B908000000 mov ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS 2147 00000AD0 F3A5 rep movsd 2148 00000AD2 B104 mov cl, 4 2149 00000AD4 F3AB rep stosd 2150 00000AD6 893D[6C940100] mov [u.sp], edi 2151 00000ADC 89EE mov esi, ebp 2152 00000ADE B105 mov cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA) 2153 00000AE0 F3A5 rep movsd 2154 2155 00000AE2 8B0D[CC940100] mov ecx, [u.pgdir] 2156 00000AE8 890D[84950100] mov [cr3reg], ecx 2157 2158 ; 13/01/207 (eax -> ebx) 2159 ; EBX = callback routine address (virtual, not physical address!) 2160 2161 ; 09/01/2017 2162 ; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'sysrele' 2163 ; system call !!! 2164 ; 25/12/2016 2165 ; Callback Note: (19/12/2016) 2166 ; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'RETN' !!! 2167 ; pushf ; save flags 2168 ; 2169 ; popf ; restore flags 2170 ; retn ; return to normal running address 2171 ; 2172 2173 ; 15/01/2017 2174 ; 14/01/2017 2175 ; 13/01/2017 (eax -> ebx) 2176 ; 10/01/2017 2177 set_callback_addr: 2178 ; 09/01/2017 (**) 2179 ; 02/01/2017 (*) 2180 ; 25/12/2016 (*) 2181 ; 19/12/2016 (TRDOS 386 feature only!) 2182 ; 2183 ; This routine sets return address 2184 ; to start of user's interrupt 2185 ; service (callback) address 2186 ;; and sets callback 'retn' address to normal 2187 ;; return address of user's running code! 2188 ; 2189 ; INPUT: 2190 ; EBX = callback routine/service address 2191 ; (virtual, not physical address!) 2192 ; [u.sp] = kernel stack, points to 2193 ; user's EIP,CS,EFLAGS,ESP,SS 2194 ; registers. 2195 ; OUTPUT: 2196 ; EIP (user) = callback (service) address 2197 ; CS (user) = UCODE 2198 ; EFLAGS (user) = flags before callback 2199 ; ESP (user) = ESP-4 (user, before callback) 2200 ; [ESP](user) = EIP (user) before callback 2201 ; 2202 ; Note: If CPU was in user mode while entering 2203 ; the timer interrupt service routine, 2204 ; 'IRET' will get return to callback routine 2205 ; immediately. If CPU was in system/kernel mode 2206 ; 'iret' will get return to system call and 2207 ; then, callback routine will be return address 2208 ; from system call. (User's callback/service code 2209 ; will be able to return to normal return address 2210 ; via an 'retn' at the end.) 2211 ; 2212 ; Note(**): User's callback service code must be ended 2213 ; with a 'sysrele' sytstem call ! (09/01/2017) 2214 ; 2215 ; For example: 2216 ; 2217 ; timer_callback: 2218 ; ... 2219 ; inc dword [time_counter] 2220 ; ... 2221 ; mov eax, 39 ; 'sysrele' 2222 ; int 40h ; TRDOS 386 system call (interrupt) 2223 ; 2224 ; 2225 ;; Note(*): User's callback service code must preserve cpu 2226 ;; flags if it has any instructions which changes 2227 ;; flags in the service code. (25/12/2016) 2228 ;; 2229 ;; For example: 2230 ;; 2231 ;; timer_callback: 2232 ;; pushf ; save flags 2233 ;; ; this instruction changes zero flag 2234 ;; inc dword [time_counter] 2235 ;; popf ; restore flags 2236 ;; retn ; return to normal user code 2237 ;; (which is interrupted by the 2238 ;; timer interput) 2239 ;; 2240 2241 ; 15/01/2017 2242 00000AEE 8B2D[6C940100] mov ebp, [u.sp]; kernel's stack, points to EIP (user) 2243 00000AF4 895D00 mov [ebp], ebx 2244 00000AF7 E95CFFFFFF jmp timer_int_return 2245 2246 ; 15/01/2017 2247 ; 13/01/2017 2248 ; 19/12/2016 2249 ; 06/06/2016 2250 ; 23/05/2016 2251 ; 22/05/2016 2252 ; 19/05/2016 - TRDOS 386 (TRDOS v2.0) 2253 ; 26/02/2015 2254 ; 07/09/2014 2255 ; 25/08/2014 2256 rtc_int: ; Real Time Clock Interrupt (IRQ 8) 2257 ; 22/05/2016 2258 00000AFC 1E push ds ; ** ; 23/05/2016 2259 00000AFD 50 push eax ; * 2260 00000AFE 66B81000 mov ax, KDATA 2261 00000B02 8ED8 mov ds, ax 2262 ; 2263 00000B04 8A25[3E7D0100] mov ah, [RTC_2Hz] ; 2 Hz interrupt to 1 Hz function 2264 00000B0A 80F401 xor ah, 1 2265 00000B0D 8825[3E7D0100] mov [RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second 2266 00000B13 753B jnz short rtc_int_return ; half second 2267 ; 1 second 2268 rtc_int_0: 2269 ; 22/05/2016 2270 00000B15 58 pop eax ; * 2271 ; 2272 ; 14/10/2015 ('timer_int') 2273 ; Here, we are simulating system call entry (for task switch) 2274 ; (If multitasking is enabled, 2275 ; 'clock' procedure may jump to 'sysrelease') 2276 ;push ds ; ** ; 23/05/2016 2277 00000B16 06 push es 2278 00000B17 0FA0 push fs 2279 00000B19 0FA8 push gs 2280 00000B1B 60 pushad ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi 2281 00000B1C 66B91000 mov cx, KDATA 2282 ;mov ds, cx ; 06/06/2016 2283 00000B20 8EC1 mov es, cx 2284 00000B22 8EE1 mov fs, cx 2285 00000B24 8EE9 mov gs, cx 2286 ; 2287 00000B26 0F20D9 mov ecx, cr3 2288 00000B29 890D[84950100] mov [cr3reg], ecx ; save current cr3 register value/content 2289 ; 2290 00000B2F 803D[EC940100]00 cmp byte [u.t_lock], 0 ; timer lock (callback) status ? 2291 00000B36 7711 ja short rtc_int_1 ; yes 2292 2293 ; 15/01/2017 2294 00000B38 3B0D[C07C0100] cmp ecx, [k_page_dir] 2295 00000B3E 7409 je short rtc_int_1 2296 2297 00000B40 8B0D[C07C0100] mov ecx, [k_page_dir] 2298 00000B46 0F22D9 mov cr3, ecx 2299 rtc_int_1: 2300 ; Timer event (kernel) functions must be performed with 2301 ; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! - 2302 ; 2303 ; 25/08/2014 2304 00000B49 E818030000 call rtc_p ; 19/05/2016 - major modification 2305 2306 ; 23/05/2016 2307 00000B4E 28E4 sub ah, ah ; 0 2308 ; 22/05/2016 - TRDOS 386 timer event modifications 2309 rtc_int_return: ; 19/05/2016 2310 ; 22/02/2015 - dsectpm.s 2311 ; [ source: http://wiki.osdev.org/RTC ] 2312 ; read status register C to complete procedure 2313 ;(it is needed to get a next IRQ 8) 2314 00000B50 B00C mov al, 0Ch ; 2315 00000B52 E670 out 70h, al ; select register C 2316 00000B54 90 nop 2317 00000B55 E471 in al, 71h ; just throw away contents 2318 ; 22/02/2015 2319 00000B57 B020 MOV AL,EOI ; END OF INTERRUPT 2320 ;CLI ; DISABLE INTERRUPTS TILL STACK CLEARED 2321 00000B59 E6A0 OUT INTB00,AL ; FOR CONTROLLER #2 2322 2323 ; 23/05/2016 2324 00000B5B B020 MOV AL,EOI ; GET END OF INTERRUPT MASK 2325 00000B5D FA CLI ; DISABLE INTERRUPTS TILL STACK CLEARED 2326 00000B5E E620 OUT INTA00,AL ; END OF INTERRUPT TO 8259 - 1 2327 ; 2328 ; 23/05/2016 2329 00000B60 20E4 and ah, ah 2330 ;jz rtc_int_2 2331 ; 24/07/2022 2332 00000B62 7505 jnz short rtc_int_4 2333 00000B64 E9B6FEFFFF jmp rtc_int_2 2334 rtc_int_4: 2335 ; ah = 1 (half second) 2336 00000B69 58 pop eax ; * 2337 00000B6A 1F pop ds ; ** 2338 00000B6B CF iretd 2339 2340 ; //////////////// 2341 2342 ; 28/08/2014 2343 irq0: 2344 00000B6C 6A00 push dword 0 2345 00000B6E EB48 jmp short which_irq 2346 irq1: 2347 00000B70 6A01 push dword 1 2348 00000B72 EB44 jmp short which_irq 2349 irq2: 2350 00000B74 6A02 push dword 2 2351 00000B76 EB40 jmp short which_irq 2352 irq3: 2353 ; 20/11/2015 2354 ; 24/10/2015 2355 00000B78 2EFF15[DD220100] call dword [cs:com2_irq3] 2356 00000B7F 6A03 push dword 3 2357 00000B81 EB35 jmp short which_irq 2358 irq4: 2359 ; 20/11/2015 2360 ; 24/10/2015 2361 00000B83 2EFF15[D9220100] call dword [cs:com1_irq4] 2362 00000B8A 6A04 push dword 4 2363 00000B8C EB2A jmp short which_irq 2364 irq5: 2365 00000B8E 6A05 push dword 5 2366 00000B90 EB26 jmp short which_irq 2367 irq6: 2368 00000B92 6A06 push dword 6 2369 00000B94 EB22 jmp short which_irq 2370 irq7: 2371 00000B96 6A07 push dword 7 2372 00000B98 EB1E jmp short which_irq 2373 irq8: 2374 00000B9A 6A08 push dword 8 2375 00000B9C EB1A jmp short which_irq 2376 irq9: 2377 00000B9E 6A09 push dword 9 2378 00000BA0 EB16 jmp short which_irq 2379 irq10: 2380 00000BA2 6A0A push dword 10 2381 00000BA4 EB12 jmp short which_irq 2382 irq11: 2383 00000BA6 6A0B push dword 11 2384 00000BA8 EB0E jmp short which_irq 2385 irq12: 2386 00000BAA 6A0C push dword 12 2387 00000BAC EB0A jmp short which_irq 2388 irq13: 2389 00000BAE 6A0D push dword 13 2390 00000BB0 EB06 jmp short which_irq 2391 irq14: 2392 00000BB2 6A0E push dword 14 2393 00000BB4 EB02 jmp short which_irq 2394 irq15: 2395 00000BB6 6A0F push dword 15 2396 ;jmp short which_irq 2397 2398 ; 22/01/2017 2399 ; 19/10/2015 2400 ; 29/08/2014 2401 ; 21/08/2014 2402 which_irq: 2403 00000BB8 870424 xchg eax, [esp] ; 28/08/2014 2404 00000BBB 53 push ebx 2405 00000BBC 56 push esi 2406 00000BBD 57 push edi 2407 00000BBE 1E push ds 2408 00000BBF 06 push es 2409 ; 2410 00000BC0 88C3 mov bl, al 2411 ; 2412 00000BC2 B810000000 mov eax, KDATA 2413 00000BC7 8ED8 mov ds, ax 2414 00000BC9 8EC0 mov es, ax 2415 ; 19/10/2015 2416 00000BCB FC cld 2417 ; 27/08/2014 2418 00000BCC 8105[FE3B0100]A000- add dword [scr_row], 0A0h 2418 00000BD4 0000 2419 ; 2420 00000BD6 B417 mov ah, 17h ; blue (1) background, 2421 ; light gray (7) forecolor 2422 00000BD8 8B3D[FE3B0100] mov edi, [scr_row] 2423 00000BDE B049 mov al, 'I' 2424 00000BE0 66AB stosw 2425 00000BE2 B052 mov al, 'R' 2426 00000BE4 66AB stosw 2427 00000BE6 B051 mov al, 'Q' 2428 00000BE8 66AB stosw 2429 00000BEA B020 mov al, ' ' 2430 00000BEC 66AB stosw 2431 00000BEE 88D8 mov al, bl 2432 00000BF0 3C0A cmp al, 10 2433 00000BF2 7208 jb short ii1 2434 00000BF4 B031 mov al, '1' 2435 00000BF6 66AB stosw 2436 00000BF8 88D8 mov al, bl 2437 00000BFA 2C0A sub al, 10 2438 ii1: 2439 00000BFC 0430 add al, '0' 2440 00000BFE 66AB stosw 2441 00000C00 B020 mov al, ' ' 2442 00000C02 66AB stosw 2443 00000C04 B021 mov al, '!' 2444 00000C06 66AB stosw 2445 00000C08 B020 mov al, ' ' 2446 00000C0A 66AB stosw 2447 ; 23/02/2015 2448 00000C0C 80FB07 cmp bl, 7 ; check for IRQ 8 to IRQ 15 2449 00000C0F 7604 jna ii2 2450 ; 22/01/2017 2451 00000C11 B020 mov al, 20h ; END OF INTERRUPT COMMAND TO 2452 00000C13 E6A0 out 0A0h, al ; the 2nd 8259 2453 ii2: 2454 00000C15 B020 mov al, 20h ; END OF INTERRUPT COMMAND TO 2455 00000C17 E620 out 20h, al ; the 2nd 8259 2456 00000C19 E9CA010000 jmp iiret 2457 ; 2458 ; 22/08/2014 2459 ;mov al, 20h ; END OF INTERRUPT COMMAND TO 8259 2460 ;out 20h, al ; 8259 PORT 2461 ; 2462 ;pop es 2463 ;pop ds 2464 ;pop edi 2465 ;pop esi 2466 ;pop ebx 2467 ;pop eax 2468 ;iret 2469 2470 ; 02/04/2015 2471 ; 25/08/2014 2472 exc0: 2473 00000C1E 6A00 push dword 0 2474 00000C20 E990000000 jmp cpu_except 2475 exc1: 2476 00000C25 6A01 push dword 1 2477 00000C27 E989000000 jmp cpu_except 2478 exc2: 2479 00000C2C 6A02 push dword 2 2480 00000C2E E982000000 jmp cpu_except 2481 exc3: 2482 00000C33 6A03 push dword 3 2483 00000C35 EB7E jmp cpu_except 2484 exc4: 2485 00000C37 6A04 push dword 4 2486 00000C39 EB7A jmp cpu_except 2487 exc5: 2488 00000C3B 6A05 push dword 5 2489 00000C3D EB76 jmp cpu_except 2490 exc6: 2491 00000C3F 6A06 push dword 6 2492 00000C41 EB72 jmp cpu_except 2493 exc7: 2494 00000C43 6A07 push dword 7 2495 00000C45 EB6E jmp cpu_except 2496 exc8: 2497 ; [esp] = Error code 2498 00000C47 6A08 push dword 8 2499 00000C49 EB5C jmp cpu_except_en 2500 exc9: 2501 00000C4B 6A09 push dword 9 2502 00000C4D EB66 jmp cpu_except 2503 exc10: 2504 ; [esp] = Error code 2505 00000C4F 6A0A push dword 10 2506 00000C51 EB54 jmp cpu_except_en 2507 exc11: 2508 ; [esp] = Error code 2509 00000C53 6A0B push dword 11 2510 00000C55 EB50 jmp cpu_except_en 2511 exc12: 2512 ; [esp] = Error code 2513 00000C57 6A0C push dword 12 2514 00000C59 EB4C jmp cpu_except_en 2515 exc13: 2516 ; [esp] = Error code 2517 00000C5B 6A0D push dword 13 2518 00000C5D EB48 jmp cpu_except_en 2519 exc14: 2520 ; [esp] = Error code 2521 00000C5F 6A0E push dword 14 2522 00000C61 EB44 jmp short cpu_except_en 2523 exc15: 2524 00000C63 6A0F push dword 15 2525 00000C65 EB4E jmp cpu_except 2526 exc16: 2527 00000C67 6A10 push dword 16 2528 00000C69 EB4A jmp cpu_except 2529 exc17: 2530 ; [esp] = Error code 2531 00000C6B 6A11 push dword 17 2532 00000C6D EB38 jmp short cpu_except_en 2533 exc18: 2534 00000C6F 6A12 push dword 18 2535 00000C71 EB42 jmp short cpu_except 2536 exc19: 2537 00000C73 6A13 push dword 19 2538 00000C75 EB3E jmp short cpu_except 2539 exc20: 2540 00000C77 6A14 push dword 20 2541 00000C79 EB3A jmp short cpu_except 2542 exc21: 2543 00000C7B 6A15 push dword 21 2544 00000C7D EB36 jmp short cpu_except 2545 exc22: 2546 00000C7F 6A16 push dword 22 2547 00000C81 EB32 jmp short cpu_except 2548 exc23: 2549 00000C83 6A17 push dword 23 2550 00000C85 EB2E jmp short cpu_except 2551 exc24: 2552 00000C87 6A18 push dword 24 2553 00000C89 EB2A jmp short cpu_except 2554 exc25: 2555 00000C8B 6A19 push dword 25 2556 00000C8D EB26 jmp short cpu_except 2557 exc26: 2558 00000C8F 6A1A push dword 26 2559 00000C91 EB22 jmp short cpu_except 2560 exc27: 2561 00000C93 6A1B push dword 27 2562 00000C95 EB1E jmp short cpu_except 2563 exc28: 2564 00000C97 6A1C push dword 28 2565 00000C99 EB1A jmp short cpu_except 2566 exc29: 2567 00000C9B 6A1D push dword 29 2568 00000C9D EB16 jmp short cpu_except 2569 exc30: 2570 00000C9F 6A1E push dword 30 2571 00000CA1 EB04 jmp short cpu_except_en 2572 exc31: 2573 00000CA3 6A1F push dword 31 2574 00000CA5 EB0E jmp short cpu_except 2575 2576 ; 19/10/2015 2577 ; 19/09/2015 2578 ; 01/09/2015 2579 ; 28/08/2015 2580 ; 28/08/2014 2581 cpu_except_en: 2582 00000CA7 87442404 xchg eax, [esp+4] ; Error code 2583 00000CAB 36A3[88960100] mov [ss:error_code], eax 2584 00000CB1 58 pop eax ; Exception number 2585 00000CB2 870424 xchg eax, [esp] 2586 ; eax = eax before exception 2587 ; [esp] -> exception number 2588 ; [esp+4] -> EIP to return 2589 ; 22/01/2017 2590 ; 19/10/2015 2591 ; 19/09/2015 2592 ; 01/09/2015 2593 ; 28/08/2015 2594 ; 29/08/2014 2595 ; 28/08/2014 2596 ; 25/08/2014 2597 ; 21/08/2014 2598 cpu_except: ; CPU Exceptions 2599 00000CB5 FC cld 2600 00000CB6 870424 xchg eax, [esp] 2601 ; eax = Exception number 2602 ; [esp] = eax (before exception) 2603 00000CB9 53 push ebx 2604 00000CBA 56 push esi 2605 00000CBB 57 push edi 2606 00000CBC 1E push ds 2607 00000CBD 06 push es 2608 ; 28/08/2015 2609 00000CBE 66BB1000 mov bx, KDATA 2610 00000CC2 8EDB mov ds, bx 2611 00000CC4 8EC3 mov es, bx 2612 00000CC6 0F20DB mov ebx, cr3 2613 00000CC9 53 push ebx ; (*) page directory 2614 ; 19/10/2015 2615 00000CCA FC cld 2616 ; 25/03/2015 2617 00000CCB 8B1D[C07C0100] mov ebx, [k_page_dir] 2618 00000CD1 0F22DB mov cr3, ebx 2619 ; 28/08/2015 2620 00000CD4 83F80E cmp eax, 0Eh ; 14, PAGE FAULT 2621 00000CD7 7510 jne short cpu_except_nfp 2622 00000CD9 E8A94D0000 call page_fault_handler 2623 00000CDE 21C0 and eax, eax 2624 ;jz iiretp ; 01/09/2015 2625 ; 24/07/2022 2626 00000CE0 7505 jnz short cpu_except_pf 2627 00000CE2 E9FD000000 jmp iiretp 2628 cpu_except_pf: ; 24/07/2022 2629 00000CE7 B00E mov al, 0Eh ; 14 2630 cpu_except_nfp: 2631 ; 23/08/2016 2632 00000CE9 803D[DE670000]03 cmp byte [CRT_MODE], 3 2633 00000CF0 7409 je short cpu_except_mode_3 2634 00000CF2 50 push eax 2635 00000CF3 B003 mov al, 3 2636 00000CF5 E8490E0000 call _set_mode 2637 00000CFA 58 pop eax 2638 cpu_except_mode_3: 2639 ; 02/04/2015 2640 00000CFB BB[FD080000] mov ebx, hang 2641 00000D00 875C241C xchg ebx, [esp+28] 2642 ; EIP (points to instruction which faults) 2643 ; New EIP (hang) 2644 00000D04 891D[8C960100] mov [FaultOffset], ebx 2645 00000D0A C744242008000000 mov dword [esp+32], KCODE ; kernel's code segment 2646 00000D12 814C242400020000 or dword [esp+36], 200h ; enable interrupts (set IF) 2647 ; 2648 00000D1A 88C4 mov ah, al 2649 00000D1C 240F and al, 0Fh 2650 00000D1E 3C09 cmp al, 9 2651 00000D20 7602 jna short h1ok 2652 00000D22 0407 add al, 'A'-':' 2653 h1ok: 2654 00000D24 C0EC04 shr ah, 4 2655 00000D27 80FC09 cmp ah, 9 2656 00000D2A 7603 jna short h2ok 2657 00000D2C 80C407 add ah, 'A'-':' 2658 h2ok: 2659 00000D2F 86C4 xchg ah, al 2660 00000D31 66053030 add ax, '00' 2661 00000D35 66A3[583E0100] mov [excnstr], ax 2662 ; 2663 ; 29/08/2014 2664 00000D3B A1[8C960100] mov eax, [FaultOffset] 2665 00000D40 51 push ecx 2666 00000D41 52 push edx 2667 00000D42 89E3 mov ebx, esp 2668 ; 28/08/2015 2669 00000D44 B910000000 mov ecx, 16 ; divisor value to convert binary number 2670 ; to hexadecimal string 2671 ;mov ecx, 10 ; divisor to convert 2672 ; binary number to decimal string 2673 b2d1: 2674 00000D49 31D2 xor edx, edx 2675 00000D4B F7F1 div ecx 2676 ;push dx 2677 ; 18/04/2021 2678 00000D4D 52 push edx 2679 00000D4E 39C8 cmp eax, ecx 2680 00000D50 73F7 jnb short b2d1 2681 00000D52 BF[633E0100] mov edi, EIPstr ; EIP value 2682 ; points to instruction which faults 2683 ; 28/08/2015 2684 00000D57 89C2 mov edx, eax 2685 b2d2: 2686 ;add al, '0' 2687 00000D59 8A82[C3410000] mov al, [edx+hexchrs] 2688 00000D5F AA stosb ; write hexadecimal digit to its place 2689 00000D60 39E3 cmp ebx, esp 2690 00000D62 7605 jna short b2d3 2691 ;pop ax 2692 ; 18/04/2021 2693 00000D64 58 pop eax 2694 00000D65 88C2 mov dl, al 2695 00000D67 EBF0 jmp short b2d2 2696 b2d3: 2697 00000D69 B068 mov al, 'h' ; 28/08/2015 2698 00000D6B AA stosb 2699 00000D6C B020 mov al, 20h ; space 2700 00000D6E AA stosb 2701 00000D6F 30C0 xor al, al ; to do it an ASCIIZ string 2702 00000D71 AA stosb 2703 ; 2704 00000D72 5A pop edx 2705 00000D73 59 pop ecx 2706 ; 2707 00000D74 B44F mov ah, 4Fh ; red (4) background, 2708 ; white (F) forecolor 2709 00000D76 BE[483E0100] mov esi, exc_msg ; message offset 2710 ; 2711 ; 20/01/2017 (!cpu exception!) 2712 ; 2713 00000D7B 8105[FE3B0100]A000- add dword [scr_row], 0A0h 2713 00000D83 0000 2714 00000D85 8B3D[FE3B0100] mov edi, [scr_row] 2715 ; 2716 00000D8B C605[68940100]00 mov byte [sysflg], 0 ; system mode 2717 00000D92 FB sti 2718 ; 2719 00000D93 E89FFBFFFF call printk 2720 ; 2721 00000D98 B410 mov ah, 10h 2722 00000D9A E87D010000 call int16h ; getc 2723 ; 2724 00000D9F B003 mov al, 3 2725 00000DA1 E89D0D0000 call _set_mode 2726 ; 2727 ;mov eax, 1 2728 ; 30/11/2023 2729 00000DA6 31C0 xor eax, eax 2730 00000DA8 40 inc eax 2731 ; eax = 1 2732 00000DA9 E9E4C10000 jmp sysexit ; terminate process !!! 2733 2734 ; 22/01/2017 2735 ; 18/04/2016 2736 ; 28/08/2015 2737 ; 23/02/2015 2738 ; 20/08/2014 2739 ignore_int: 2740 00000DAE 50 push eax 2741 00000DAF 53 push ebx ; 23/02/2015 2742 00000DB0 56 push esi 2743 00000DB1 57 push edi 2744 00000DB2 1E push ds 2745 00000DB3 06 push es 2746 ; 18/04/2016 2747 00000DB4 66B81000 mov ax, KDATA 2748 00000DB8 8ED8 mov ds, ax 2749 00000DBA 8EC0 mov es, ax 2750 ; 28/08/2015 2751 00000DBC 0F20D8 mov eax, cr3 2752 00000DBF 50 push eax ; (*) page directory 2753 ; 2754 00000DC0 B467 mov ah, 67h ; brown (6) background, 2755 ; light gray (7) forecolor 2756 00000DC2 BE[103D0100] mov esi, int_msg ; message offset 2757 piemsg: 2758 ; 27/08/2014 2759 00000DC7 8105[FE3B0100]A000- add dword [scr_row], 0A0h 2759 00000DCF 0000 2760 00000DD1 8B3D[FE3B0100] mov edi, [scr_row] 2761 ; 2762 00000DD7 E85BFBFFFF call printk 2763 ; 2764 ; 23/02/2015 2765 00000DDC B020 mov al, 20h ; END OF INTERRUPT COMMAND TO 2766 00000DDE E6A0 out 0A0h, al ; the 2nd 8259 2767 ; 22/08/2014 2768 00000DE0 B020 mov al, 20h ; END OF INTERRUPT COMMAND TO 8259 2769 00000DE2 E620 out 20h, al ; 8259 PORT 2770 iiretp: 2771 ; 22/01/2017 2772 ; 01/09/2015 2773 ; 28/08/2015 2774 00000DE4 58 pop eax ; (*) page directory 2775 00000DE5 0F22D8 mov cr3, eax 2776 iiret: 2777 00000DE8 07 pop es 2778 00000DE9 1F pop ds 2779 00000DEA 5F pop edi 2780 00000DEB 5E pop esi 2781 00000DEC 5B pop ebx ; 29/08/2014 2782 00000DED 58 pop eax 2783 00000DEE CF iretd 2784 2785 ; 23/05/2016 2786 ; 22/08/2014 2787 ; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm) 2788 ; (INT 1Ah) 2789 ;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991) 2790 time_of_day: 2791 00000DEF E8E3560000 call UPD_IPR ; WAIT TILL UPDATE NOT IN PROGRESS 2792 00000DF4 726F jc short time_of_day_retn ; 23/05/2016 2793 00000DF6 B000 mov al, CMOS_SECONDS 2794 00000DF8 E810570000 call CMOS_READ 2795 00000DFD A2[307D0100] mov [time_seconds], al 2796 00000E02 B002 mov al, CMOS_MINUTES 2797 00000E04 E804570000 call CMOS_READ 2798 00000E09 A2[317D0100] mov [time_minutes], al 2799 00000E0E B004 mov al, CMOS_HOURS 2800 00000E10 E8F8560000 call CMOS_READ 2801 00000E15 A2[327D0100] mov [time_hours], al 2802 00000E1A B006 mov al, CMOS_DAY_WEEK 2803 00000E1C E8EC560000 call CMOS_READ 2804 00000E21 A2[337D0100] mov [date_wday], al 2805 00000E26 B007 mov al, CMOS_DAY_MONTH 2806 00000E28 E8E0560000 call CMOS_READ 2807 00000E2D A2[347D0100] mov [date_day], al 2808 00000E32 B008 mov al, CMOS_MONTH 2809 00000E34 E8D4560000 call CMOS_READ 2810 00000E39 A2[357D0100] mov [date_month], al 2811 00000E3E B009 mov al, CMOS_YEAR 2812 00000E40 E8C8560000 call CMOS_READ 2813 00000E45 A2[367D0100] mov [date_year], al 2814 00000E4A B032 mov al, CMOS_CENTURY 2815 00000E4C E8BC560000 call CMOS_READ 2816 00000E51 A2[377D0100] mov [date_century], al 2817 ; 2818 00000E56 B000 mov al, CMOS_SECONDS 2819 00000E58 E8B0560000 call CMOS_READ 2820 00000E5D 3A05[307D0100] cmp al, [time_seconds] 2821 00000E63 758A jne short time_of_day 2822 2823 time_of_day_retn: 2824 00000E65 C3 retn 2825 2826 ; 15/01/2017 2827 ; 10/06/2016 2828 ; 07/06/2016 2829 ; 06/06/2016 2830 ; 23/05/2016 2831 rtc_p: 2832 00000E66 B101 mov cl, 1 ; 15/01/2017 2833 00000E68 EB02 jmp short rtc_p0 2834 u_timer: 2835 ; Timer Events with 18.2 Hz Timer Ticks 2836 ; (and also timer events with RTC seconds) 2837 00000E6A 28C9 sub cl, cl ; mov cl, 0 ; 15/01/2017 2838 rtc_p0: 2839 ; 19/05/2016 - TRDOS 386 (TRDOS v2.0) 2840 ; Major Modification: 2841 ; Check and Perform Timer Events (for RTC) 2842 ; 25/08/2014 - 07/09/2014 2843 ; Retro UNIX 386 v1: 2844 ; Print Real Time Clock content 2845 2846 ; 15/01/2017 2847 00000E6C 880D[4C890100] mov byte [priority], cl ; 0 or 1 (not 2) 2848 00000E72 8A2D[4F890100] mov ch, [timer_events] 2849 00000E78 20ED and ch, ch 2850 00000E7A 7420 jz short rtc_p3 2851 2852 00000E7C BE[88950100] mov esi, timer_set ; beginning address of 2853 ; timer events space 2854 rtc_p1: 2855 00000E81 8B06 mov eax, [esi] 2856 00000E83 20C0 and al, al ; 0 = free, >0 = process no. 2857 00000E85 7416 jz short rtc_p4 2858 ; 2859 00000E87 C1C810 ror eax, 16 2860 ; ah = response value, al = interrupt type 2861 ; 15/01/2017 2862 ; cl = interrupt source 2863 ; 1 = RTC, 0 = PIT 2864 00000E8A 38C8 cmp al, cl 2865 00000E8C 750A jne short rtc_p2 ; not as requested or undefined ! 2866 00000E8E 3C01 cmp al, 1 ; 1 ; RTC interrupt ? 2867 00000E90 7410 je short rtc_p5 ; yes, check for response 2868 ; 06/06/2016 - 18.2 Hz Timer Ticks 2869 00000E92 836E080A sub dword [esi+8], 10 ; 1 tick = 10 2870 00000E96 7613 jna short rtc_p6 ; continue for responding 2871 rtc_p2: 2872 ; 15/01/2017 (cl -> ch) 2873 ; 07/06/2016 2874 00000E98 FECD dec ch ; remain count of timer events 2875 00000E9A 7501 jnz short rtc_p4 2876 rtc_p3: 2877 00000E9C C3 retn 2878 rtc_p4: 2879 ;cmp esi, timer_set + 240 ; 15*16 (last event) 2880 ;jnb short rtc_p3 ; end of timer event space 2881 00000E9D 83C610 add esi, 16 ; next timer event 2882 00000EA0 EBDF jmp short rtc_p1 2883 rtc_p5: 2884 ; current timer count ; 06/06/2016 (182) 2885 00000EA2 816E08B6000000 sub dword [esi+8], 182 ; 1 second (10*18.2) 2886 00000EA9 77ED ja short rtc_p2 ; check for the next 2887 rtc_p6: 2888 ; it is the time of response! 2889 00000EAB 8B5E04 mov ebx, [esi+4] ; set (count limit) value 2890 00000EAE 895E08 mov [esi+8], ebx ; reset count down value 2891 ; to count limit 2892 ; 19/12/2016 2893 ; 10/12/2016 - timer callback modification 2894 00000EB1 8B7E0C mov edi, [esi+12] ; response (or callback) address 2895 00000EB4 807E0100 cmp byte [esi+1], 0 ; >0 = callback 2896 00000EB8 762A jna short rtc_p8 2897 2898 ; timer callback ! 2899 00000EBA 0FB61E movzx ebx, byte [esi] ; process number (>0) 2900 00000EBD 89D8 mov eax, ebx 2901 00000EBF C0E302 shl bl, 2 ; *4 2902 00000EC2 89BB[04940100] mov [ebx+p.tcb-4], edi ; user's callback service addr 2903 00000EC8 3A05[C5940100] cmp al, [u.uno] 2904 00000ECE 7521 jne short rtc_p9 2905 00000ED0 893D[E8940100] mov [u.tcb], edi 2906 rtc_p7: 2907 ; 15/01/2017 2908 00000ED6 B002 mov al, 2 2909 00000ED8 A2[4C890100] mov [priority], al ; 2 2910 ; 10/01/2017 2911 ;mov byte [u.pri], 2 2912 00000EDD A2[BE940100] mov [u.pri], al ; 2 2913 00000EE2 EBB4 jmp short rtc_p2 2914 rtc_p8: 2915 ; response address is physical address of 2916 ; the program's response (signal return) byte 2917 ; 06/06/2016 2918 ;mov edi, [esi+12] ; response address 2919 00000EE4 8827 mov [edi], ah ; response value 2920 ; 2921 00000EE6 C1C010 rol eax, 16 2922 ; 15/01/2017 2923 00000EE9 3A05[C5940100] cmp al, [u.uno] ; running process ? 2924 00000EEF 74E5 je short rtc_p7 2925 rtc_p9: 2926 ; al = process number ; 10/06/2016 2927 00000EF1 B202 mov dl, 2 ; priority, 2 = event (high) 2928 00000EF3 E810120100 call set_run_sequence ; 19/05/2016 2929 00000EF8 EB9E jmp short rtc_p2 ; 10/06/2016 2930 2931 ; Default IRQ 7 handler against spurious IRQs (from master PIC) 2932 ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC) 2933 default_irq7: 2934 ;push ax 2935 ; 18/04/2021 2936 00000EFA 50 push eax 2937 00000EFB B00B mov al, 0Bh ; In-Service register 2938 00000EFD E620 out 20h, al 2939 00000EFF EB00 jmp short $+2 2940 00000F01 EB00 jmp short $+2 2941 00000F03 E420 in al, 20h 2942 00000F05 2480 and al, 80h ; bit 7 (is it real IRQ 7 or fake?) 2943 00000F07 7404 jz short irq7_iret ; Fake (spurious) IRQ, do not send EOI 2944 00000F09 B020 mov al, 20h ; EOI 2945 00000F0B E620 out 20h, al 2946 irq7_iret: 2947 ;pop ax 2948 ; 18/04/2021 2949 00000F0D 58 pop eax 2950 00000F0E CF iretd 2951 2952 bcd_to_ascii: 2953 ; 25/08/2014 2954 ; INPUT -> 2955 ; al = Packed BCD number 2956 ; OUTPUT -> 2957 ; ax = ASCII word/number 2958 ; 2959 ; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011) 2960 ; 2961 00000F0F D410 db 0D4h, 10h ; Undocumented inst. AAM 2962 ; AH = AL / 10h 2963 ; AL = AL MOD 10h 2964 00000F11 660D3030 or ax, '00' ; Make it ASCII based 2965 2966 00000F15 86C4 xchg ah, al 2967 2968 00000F17 C3 retn 2969 2970 ; 15/12/2020 2971 real_mem_16m_64k: 2972 00000F18 0000 dw 0 ; Real size of system memory (if > 16MB) 2973 ; as number of 64K blocks - 256 2974 ; (This is for saving real system memory 2975 ; because if system memory is larger than 2976 ; 3 GB and if a VESA VBE video bios 2977 ; is detected, 'mem_16m_64K' may be 2978 ; decreased to reserve LFB space 2979 ; at the end of system memory.) 2980 ; Upper memory space from LFB base address 2981 ; to 4GB will not be included by M.A.T. 2982 def_LFB_addr: 2983 00000F1A 0000 dw 0 ; HW of default LFB addr (for mode 118h) 2984 2985 2986 %include 'keyboard.s' ; 07/03/2015 1 <1> ; **************************************************************************** 2 <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - keyboard.s 3 <1> ; ---------------------------------------------------------------------------- 4 <1> ; Last Update: 07/08/2022 (Previous: 12/04/2021) 5 <1> ; ---------------------------------------------------------------------------- 6 <1> ; Beginning: 17/01/2016 7 <1> ; ---------------------------------------------------------------------------- 8 <1> ; Assembler: NASM version 2.15 (trdos386.s) 9 <1> ; ---------------------------------------------------------------------------- 10 <1> ; Turkish Rational DOS 11 <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016) 12 <1> ; 13 <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan 14 <1> ; keyboard.inc (17/10/2015) 15 <1> ; 16 <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 17 <1> ; **************************************************************************** 18 <1> 19 <1> ; Ref: Retro UNIX 386 v1.2 - keyboard.s - 11/06/2022 20 <1> 21 <1> ; Retro UNIX 386 v1 Kernel - KEYBOARD.INC 22 <1> ; Last Modification: 17/10/2015 23 <1> ; (Keyboard Data is in 'KYBDATA.INC') 24 <1> ; 25 <1> ; ///////// KEYBOARD FUNCTIONS (PROCEDURES) /////////////// 26 <1> 27 <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0) 28 <1> 29 <1> ; 03/12/2014 30 <1> ; 26/08/2014 31 <1> ; KEYBOARD I/O 32 <1> ; (INT_16h - Retro UNIX 8086 v1 - U9.ASM, 30/06/2014) 33 <1> 34 <1> ;NOTE: 'k0' to 'k7' are name of OPMASK registers. 35 <1> ; (The reason of using '_k' labels!!!) (27/08/2014) 36 <1> ;NOTE: 'NOT' keyword is '~' unary operator in NASM. 37 <1> ; ('NOT LC_HC' --> '~LC_HC') (bit reversing operator) 38 <1> 39 <1> int16h: ; 30/06/2015 40 <1> ;getc: 41 00000F1C 9C <1> pushfd ; 28/08/2014 42 00000F1D 0E <1> push cs 43 00000F1E E826000000 <1> call KEYBOARD_IO_1 ; getc_int 44 00000F23 C3 <1> retn 45 <1> 46 <1> ; 24/07/2022 - TRDOS 386 v2.0.5 47 <1> 48 <1> ;----- SHIFT STATUS 49 <1> _K3E: ; GET THE EXTENDED SHIFT STATUS FLAGS 50 00000F24 8A25[AA670000] <1> mov ah, [KB_FLAG_1] ; GET SYSTEM SHIFT KEY STATUS 51 00000F2A 80E404 <1> and ah, SYS_SHIFT ; MASK ALL BUT SYS KEY BIT 52 <1> ;mov cl, 5 ; SHIFT THEW SYSTEMKEY BIT OVER TO 53 <1> ;shl ah, cl ; BIT 7 POSITION 54 00000F2D C0E405 <1> shl ah, 5 55 00000F30 A0[AA670000] <1> mov al, [KB_FLAG_1] ; GET SYSTEM SHIFT STATES BACK 56 00000F35 2473 <1> and al, 01110011b ; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT 57 00000F37 08C4 <1> or ah, al ; MERGE REMAINING BITS INTO AH 58 00000F39 A0[AC670000] <1> mov al, [KB_FLAG_3] ; GET RIGHT CTL AND ALT 59 00000F3E 240C <1> and al, 00001100b ; ELIMINATE LC_E0 AND LC_E1 60 00000F40 08C4 <1> or ah, al ; OR THE SHIFT FLAGS TOGETHER 61 <1> _K3: 62 00000F42 A0[A9670000] <1> mov al, [KB_FLAG] ; GET THE SHIFT STATUS FLAGS 63 <1> ; 24/07/2022 64 00000F47 EB38 <1> jmp short _KIO_EXIT ; RETURN TO CALLER 65 <1> 66 <1> getc_int: 67 <1> ; 28/02/2015 68 <1> ; 03/12/2014 (derivation from pc-xt-286 bios source code -1986-, 69 <1> ; instead of pc-at bios - 1985-) 70 <1> ; 28/08/2014 (_k1d) 71 <1> ; 30/06/2014 72 <1> ; 03/03/2014 73 <1> ; 28/02/2014 74 <1> ; Derived from "KEYBOARD_IO_1" procedure of IBM "pc-xt-286" 75 <1> ; rombios source code (21/04/1986) 76 <1> ; 'keybd.asm', INT 16H, KEYBOARD_IO 77 <1> ; 78 <1> ; KYBD --- 03/06/86 KEYBOARD BIOS 79 <1> ; 80 <1> ;--- INT 16 H ----------------------------------------------------------------- 81 <1> ; KEYBOARD I/O : 82 <1> ; THESE ROUTINES PROVIDE READ KEYBOARD SUPPORT : 83 <1> ; INPUT : 84 <1> ; (AH)= 00H READ THE NEXT ASCII CHARACTER ENTERED FROM THE KEYBOARD, : 85 <1> ; RETURN THE RESULT IN (AL), SCAN CODE IN (AH). : 86 <1> ; THIS IS THE COMPATIBLE READ INTERFACE, EQUIVALENT TO THE : 87 <1> ; STANDARD PC OR PCAT KEYBOARD : 88 <1> ;-----------------------------------------------------------------------------: 89 <1> ; (AH)= 01H SET THE ZERO FLAG TO INDICATE IF AN ASCII CHARACTER IS : 90 <1> ; AVAILABLE TO BE READ FROM THE KEYBOARD BUFFER. : 91 <1> ; (ZF)= 1 -- NO CODE AVAILABLE : 92 <1> ; (ZF)= 0 -- CODE IS AVAILABLE (AX)= CHARACTER : 93 <1> ; IF (ZF)= 0, THE NEXT CHARACTER IN THE BUFFER TO BE READ IS : 94 <1> ; IN (AX), AND THE ENTRY REMAINS IN THE BUFFER. : 95 <1> ; THIS WILL RETURN ONLY PC/PCAT KEYBOARD COMPATIBLE CODES : 96 <1> ;-----------------------------------------------------------------------------: 97 <1> ; (AH)= 02H RETURN THE CURRENT SHIFT STATUS IN AL REGISTER : 98 <1> ; THE BIT SETTINGS FOR THIS CODE ARE INDICATED IN THE : 99 <1> ; EQUATES FOR @KB_FLAG : 100 <1> ;-----------------------------------------------------------------------------: 101 <1> ; (AH)= 03H SET TYPAMATIC RATE AND DELAY : 102 <1> ; (AL) = 05H : 103 <1> ; (BL) = TYPAMATIC RATE (BITS 5 - 7 MUST BE RESET TO 0) : 104 <1> ; : 105 <1> ; REGISTER RATE REGISTER RATE : 106 <1> ; VALUE SELECTED VALUE SELECTED : 107 <1> ; -------------------------------------------- : 108 <1> ; 00H 30.0 10H 7.5 : 109 <1> ; 01H 26.7 11H 6.7 : 110 <1> ; 02H 24.0 12H 6.0 : 111 <1> ; 03H 21.8 13H 5.5 : 112 <1> ; 04H 20.0 14H 5.0 : 113 <1> ; 05H 18.5 15H 4.6 : 114 <1> ; 06H 17.1 16H 4.3 : 115 <1> ; 07H 16.0 17H 4.0 : 116 <1> ; 08H 15.0 18H 3.7 : 117 <1> ; 09H 13.3 19H 3.3 : 118 <1> ; 0AH 12.0 1AH 3.0 : 119 <1> ; 0BH 10.9 1BH 2.7 : 120 <1> ; 0CH 10.0 1CH 2.5 : 121 <1> ; 0DH 9.2 1DH 2.3 : 122 <1> ; 0EH 8.6 1EH 2.1 : 123 <1> ; 0FH 8.0 1FH 2.0 : 124 <1> ; : 125 <1> ; (BH) = TYPAMATIC DELAY (BITS 2 - 7 MUST BE RESET TO 0) : 126 <1> ; : 127 <1> ; REGISTER DELAY : 128 <1> ; VALUE VALUE : 129 <1> ; ------------------ : 130 <1> ; 00H 250 ms : 131 <1> ; 01H 500 ms : 132 <1> ; 02H 750 ms : 133 <1> ; 03H 1000 ms : 134 <1> ;-----------------------------------------------------------------------------: 135 <1> ; (AH)= 05H PLACE ASCII CHARACTER/SCAN CODE COMBINATION IN KEYBOARD : 136 <1> ; BUFFER AS IF STRUCK FROM KEYBOARD : 137 <1> ; ENTRY: (CL) = ASCII CHARACTER : 138 <1> ; (CH) = SCAN CODE : 139 <1> ; EXIT: (AH) = 00H = SUCCESSFUL OPERATION : 140 <1> ; (AL) = 01H = UNSUCCESSFUL - BUFFER FULL : 141 <1> ; FLAGS: CARRY IF ERROR : 142 <1> ;-----------------------------------------------------------------------------: 143 <1> ; (AH)= 10H EXTENDED READ INTERFACE FOR THE ENHANCED KEYBOARD, : 144 <1> ; OTHERWISE SAME AS FUNCTION AH=0 : 145 <1> ;-----------------------------------------------------------------------------: 146 <1> ; (AH)= 11H EXTENDED ASCII STATUS FOR THE ENHANCED KEYBOARD, : 147 <1> ; OTHERWISE SAME AS FUNCTION AH=1 : 148 <1> ;-----------------------------------------------------------------------------: 149 <1> ; (AH)= 12H RETURN THE EXTENDED SHIFT STATUS IN AX REGISTER : 150 <1> ; AL = BITS FROM KB_FLAG, AH = BITS FOR LEFT AND RIGHT : 151 <1> ; CTL AND ALT KEYS FROM KB_FLAG_1 AND KB_FLAG_3 : 152 <1> ; OUTPUT : 153 <1> ; AS NOTED ABOVE, ONLY (AX) AND FLAGS CHANGED : 154 <1> ; ALL REGISTERS RETAINED : 155 <1> ;------------------------------------------------------------------------------ 156 <1> 157 <1> ; 07/08/2022 158 <1> ; 24/07/2022 - TRDOS 386 v2.0.5 159 <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop) 160 <1> ; 15/01/2017 161 <1> ; 14/01/2017 162 <1> ; 02/01/2017 163 <1> ; 29/05/2016 164 <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 165 <1> int32h: ; Keyboard BIOS 166 <1> 167 <1> KEYBOARD_IO_1: 168 <1> ;sti ; INTERRUPTS BACK ON 169 <1> ; 29/05/2016 170 00000F49 80642408BE <1> and byte [esp+8], 10111110b ; clear zero flag and cary flag 171 <1> ; 172 00000F4E 1E <1> push ds ; SAVE CURRENT DS 173 00000F4F 53 <1> push ebx ; SAVE BX TEMPORARILY 174 <1> ;push ecx ; SAVE CX TEMPORARILY 175 00000F50 66BB1000 <1> mov bx, KDATA 176 00000F54 8EDB <1> mov ds, bx ; PUT SEGMENT VALUE OF DATA AREA INTO DS 177 <1> ; 14/01/2017 178 00000F56 8B1C24 <1> mov ebx, [esp] 179 <1> ;; 15/01/2017 180 <1> ; 02/01/2017 181 <1> ;;mov byte [intflg], 32h ; keyboard interrupt 182 00000F59 FB <1> sti 183 <1> ; 184 00000F5A 08E4 <1> or ah, ah ; CHECK FOR (AH)= 00H 185 00000F5C 7433 <1> jz short _K1 ; ASCII_READ 186 00000F5E FECC <1> dec ah ; CHECK FOR (AH)= 01H 187 00000F60 744C <1> jz short _K2 ; ASCII_STATUS 188 00000F62 FECC <1> dec ah ; CHECK FOR (AH)= 02H 189 00000F64 74DC <1> jz short _K3 ; SHIFT STATUS 190 00000F66 FECC <1> dec ah ; CHECK FOR (AH)= 03H 191 00000F68 746F <1> jz short _K300 ; SET TYPAMATIC RATE/DELAY 192 00000F6A 80EC02 <1> sub ah, 2 ; CHECK FOR (AH)= 05H 193 <1> ;jz short _K500 ; KEYBOARD WRITE 194 <1> ; 07/08/2022 195 00000F6D 7505 <1> jnz short _KIO1 196 00000F6F E988000000 <1> jmp _K500 197 <1> _KIO1: 198 00000F74 80EC0B <1> sub ah, 11 ; AH = 10H 199 00000F77 740C <1> jz short _K1E ; EXTENDED ASCII READ 200 00000F79 FECC <1> dec ah ; CHECK FOR (AH)= 11H 201 00000F7B 7422 <1> jz short _K2E ; EXTENDED_ASCII_STATUS 202 00000F7D FECC <1> dec ah ; CHECK FOR (AH)= 12H 203 00000F7F 74A3 <1> jz short _K3E ; EXTENDED_SHIFT_STATUS 204 <1> _KIO_EXIT: 205 <1> ; 02/01/2017 206 00000F81 FA <1> cli 207 <1> ;;mov byte [intflg], 0 ;; 15/01/2017 208 <1> ; 209 <1> ;pop ecx ; RECOVER REGISTER 210 00000F82 5B <1> pop ebx ; RECOVER REGISTER 211 00000F83 1F <1> pop ds ; RECOVER SEGMENT 212 00000F84 CF <1> iretd ; INVALID COMMAND, EXIT 213 <1> 214 <1> ; 24/07/2022 215 <1> ; 216 <1> ; ;----- SHIFT STATUS 217 <1> ;_K3E: ; GET THE EXTENDED SHIFT STATUS FLAGS 218 <1> ; mov ah, [KB_FLAG_1] ; GET SYSTEM SHIFT KEY STATUS 219 <1> ; and ah, SYS_SHIFT ; MASK ALL BUT SYS KEY BIT 220 <1> ; ;mov cl, 5 ; SHIFT THEW SYSTEMKEY BIT OVER TO 221 <1> ; ;shl ah, cl ; BIT 7 POSITION 222 <1> ; shl ah, 5 223 <1> ; mov al, [KB_FLAG_1] ; GET SYSTEM SHIFT STATES BACK 224 <1> ; and al, 01110011b ; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT 225 <1> ; or ah, al ; MERGE REMAINING BITS INTO AH 226 <1> ; mov al, [KB_FLAG_3] ; GET RIGHT CTL AND ALT 227 <1> ; and al, 00001100b ; ELIMINATE LC_E0 AND LC_E1 228 <1> ; or ah, al ; OR THE SHIFT FLAGS TOGETHER 229 <1> ;_K3: 230 <1> ; mov al, [KB_FLAG] ; GET THE SHIFT STATUS FLAGS 231 <1> ; ; 24/07/2022 232 <1> ; jmp short _KIO_EXIT ; RETURN TO CALLER 233 <1> 234 <1> ;----- ASCII CHARACTER 235 <1> _K1E: 236 00000F85 E89F000000 <1> call _K1S ; GET A CHARACTER FROM THE BUFFER (EXTENDED) 237 00000F8A E812010000 <1> call _KIO_E_XLAT ; ROUTINE TO XLATE FOR EXTENDED CALLS 238 00000F8F EBF0 <1> jmp short _KIO_EXIT ; GIVE IT TO THE CALLER 239 <1> _K1: 240 00000F91 E893000000 <1> call _K1S ; GET A CHARACTER FROM THE BUFFER 241 00000F96 E811010000 <1> call _KIO_S_XLAT ; ROUTINE TO XLATE FOR STANDARD CALLS 242 00000F9B 72F4 <1> jc short _K1 ; CARRY SET MEANS TROW CODE AWAY 243 <1> _K1A: 244 00000F9D EBE2 <1> jmp short _KIO_EXIT ; RETURN TO CALLER 245 <1> 246 <1> ;----- ASCII STATUS 247 <1> _K2E: 248 00000F9F E8D0000000 <1> call _K2S ; TEST FOR CHARACTER IN BUFFER (EXTENDED) 249 00000FA4 7420 <1> jz short _K2B ; RETURN IF BUFFER EMPTY 250 00000FA6 9C <1> pushf ; SAVE ZF FROM TEST 251 00000FA7 E8F5000000 <1> call _KIO_E_XLAT ; ROUTINE TO XLATE FOR EXTENDED CALLS 252 00000FAC EB17 <1> jmp short _K2A ; GIVE IT TO THE CALLER 253 <1> _K2: 254 00000FAE E8C1000000 <1> call _K2S ; TEST FOR CHARACTER IN BUFFER 255 00000FB3 7411 <1> jz short _K2B ; RETURN IF BUFFER EMPTY 256 00000FB5 9C <1> pushf ; SAVE ZF FROM TEST 257 00000FB6 E8F1000000 <1> call _KIO_S_XLAT ; ROUTINE TO XLATE FOR STANDARD CALLS 258 00000FBB 7308 <1> jnc short _K2A ; CARRY CLEAR MEANS PASS VALID CODE 259 00000FBD 9D <1> popf ; INVALID CODE FOR THIS TYPE OF CALL 260 00000FBE E866000000 <1> call _K1S ; THROW THE CHARACTER AWAY 261 00000FC3 EBE9 <1> jmp short _K2 ; GO LOOK FOR NEXT CHAR, IF ANY 262 <1> _K2A: 263 00000FC5 9D <1> popf ; RESTORE ZF FROM TEST 264 <1> _K2B: 265 <1> ; 02/01/2017 266 00000FC6 FA <1> cli 267 <1> ;; mov byte [intflg], 0 ;; 15/01/2017 268 <1> ; 269 <1> ;pop ecx ; RECOVER REGISTER 270 00000FC7 5B <1> pop ebx ; RECOVER REGISTER 271 00000FC8 1F <1> pop ds ; RECOVER SEGMENT 272 <1> ; (*) 29/05/2016 273 <1> ; (*) retf 4 ; THROW AWAY (e)FLAGS 274 00000FC9 7208 <1> jc short _k2d 275 00000FCB 7505 <1> jnz short _k2c 276 00000FCD 804C240840 <1> or byte [esp+8], 01000000b ; set zero flag bit of eflags register 277 <1> _k2c: 278 00000FD2 CF <1> iretd 279 <1> _k2d: 280 <1> ; 29/05/2016 -set carry flag on stack- 281 <1> ; [esp] = EIP 282 <1> ; [esp+4] = CS 283 <1> ; [esp+8] = E-FLAGS 284 00000FD3 804C240801 <1> or byte [esp+8], 1 ; set carry bit of eflags register 285 <1> ; [esp+12] = ESP (user) 286 <1> ; [esp+16] = SS (User) 287 00000FD8 CF <1> iretd 288 <1> 289 <1> ; (*) 29/05/2016 - 'retf 4' intruction causes to stack fault 290 <1> ; (OUTER-PRIVILEGE-LEVEL) 291 <1> ; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986 292 <1> ; // RETF instruction: 293 <1> ; 294 <1> ; IF OperandMode=32 THEN 295 <1> ; Load CS:EIP from stack; 296 <1> ; Set CS RPL to CPL; 297 <1> ; Increment ESP by 8 plus the immediate offset if it exists; 298 <1> ; Load SS:ESP from stack; 299 <1> ; ELSE (* OperandMode=16 *) 300 <1> ; Load CS:IP from stack; 301 <1> ; Set CS RPL to CPL; 302 <1> ; Increment SP by 4 plus the immediate offset if it exists; 303 <1> ; Load SS:SP from stack; 304 <1> ; FI; 305 <1> ; 306 <1> ; // 307 <1> 308 <1> ; 24/07/2022 309 <1> ;----- SET TYPAMATIC RATE AND DELAY 310 <1> _K300: 311 00000FD9 3C05 <1> cmp al, 5 ; CORRECT FUNCTION CALL? 312 00000FDB 75A4 <1> jne short _KIO_EXIT ; NO, RETURN 313 00000FDD F6C3E0 <1> test bl, 0E0h ; TEST FOR OUT-OF-RANGE RATE 314 00000FE0 759F <1> jnz short _KIO_EXIT ; RETURN IF SO 315 00000FE2 F6C7FC <1> test bh, 0FCh ; TEST FOR OUT-OF-RANGE DELAY 316 00000FE5 759A <1> jnz short _KIO_EXIT ; RETURN IF SO 317 00000FE7 B0F3 <1> mov al, KB_TYPA_RD ; COMMAND FOR TYPAMATIC RATE/DELAY 318 00000FE9 E875060000 <1> call SND_DATA ; SEND TO KEYBOARD 319 <1> ;mov cx, 5 ; SHIFT COUNT 320 <1> ;shl bh, cl ; SHIFT DELAY OVER 321 00000FEE C0E705 <1> shl bh, 5 322 00000FF1 88D8 <1> mov al, bl ; PUT IN RATE 323 00000FF3 08F8 <1> or al, bh ; AND DELAY 324 00000FF5 E869060000 <1> call SND_DATA ; SEND TO KEYBOARD 325 00000FFA EB85 <1> jmp _KIO_EXIT ; RETURN TO CALLER 326 <1> 327 <1> ;----- WRITE TO KEYBOARD BUFFER 328 <1> _K500: 329 00000FFC 56 <1> push esi ; SAVE SI (esi) 330 00000FFD FA <1> cli ; 331 00000FFE 8B1D[BA670000] <1> mov ebx, [BUFFER_TAIL] ; GET THE 'IN TO' POINTER TO THE BUFFER 332 00001004 89DE <1> mov esi, ebx ; SAVE A COPY IN CASE BUFFER NOT FULL 333 00001006 E8D1000000 <1> call _K4 ; BUMP THE POINTER TO SEE IF BUFFER IS FULL 334 0000100B 3B1D[B6670000] <1> cmp ebx, [BUFFER_HEAD] ; WILL THE BUFFER OVERRUN IF WE STORE THIS? 335 00001011 740D <1> je short _K502 ; YES - INFORM CALLER OF ERROR 336 00001013 66890E <1> mov [esi], cx ; NO - PUT ASCII/SCAN CODE INTO BUFFER 337 00001016 891D[BA670000] <1> mov [BUFFER_TAIL], ebx ; ADJUST 'IN TO' POINTER TO REFLECT CHANGE 338 0000101C 28C0 <1> sub al, al ; TELL CALLER THAT OPERATION WAS SUCCESSFUL 339 0000101E EB02 <1> jmp short _K504 ; SUB INSTRUCTION ALSO RESETS CARRY FLAG 340 <1> _K502: 341 00001020 B001 <1> mov al, 01h ; BUFFER FULL INDICATION 342 <1> _K504: 343 00001022 FB <1> sti 344 00001023 5E <1> pop esi ; RECOVER SI (esi) 345 00001024 E958FFFFFF <1> jmp _KIO_EXIT ; RETURN TO CALLER WITH STATUS IN AL 346 <1> 347 <1> ;----- READ THE KEY TO FIGURE OUT WHAT TO DO ----- 348 <1> _K1S: 349 00001029 FA <1> cli ; 03/12/2014 350 0000102A 8B1D[B6670000] <1> mov ebx, [BUFFER_HEAD] ; GET POINTER TO HEAD OF BUFFER 351 00001030 3B1D[BA670000] <1> cmp ebx, [BUFFER_TAIL] ; TEST END OF BUFFER 352 <1> ;jne short _K1U ; IF ANYTHING IN BUFFER SKIP INTERRUPT 353 00001036 750F <1> jne short _k1x ; 03/12/2014 354 <1> ; 355 <1> ; 03/12/2014 356 <1> ; 28/08/2014 357 <1> ; PERFORM OTHER FUNCTION ?? here ! 358 <1> ;; MOV AX, 9002h ; MOVE IN WAIT CODE & TYPE 359 <1> ;; INT 15H ; PERFORM OTHER FUNCTION 360 <1> _K1T: ; ASCII READ 361 00001038 FB <1> sti ; INTERRUPTS BACK ON DURING LOOP 362 00001039 90 <1> nop ; ALLOW AN INTERRUPT TO OCCUR 363 <1> _K1U: 364 0000103A FA <1> cli ; INTERRUPTS BACK OFF 365 0000103B 8B1D[B6670000] <1> mov ebx, [BUFFER_HEAD] ; GET POINTER TO HEAD OF BUFFER 366 00001041 3B1D[BA670000] <1> cmp ebx, [BUFFER_TAIL] ; TEST END OF BUFFER 367 <1> _k1x: 368 00001047 53 <1> push ebx ; SAVE ADDRESS 369 00001048 9C <1> pushf ; SAVE FLAGS 370 00001049 E8C9060000 <1> call MAKE_LED ; GO GET MODE INDICATOR DATA BYTE 371 0000104E 8A1D[AB670000] <1> mov bl, [KB_FLAG_2] ; GET PREVIOUS BITS 372 00001054 30C3 <1> xor bl, al ; SEE IF ANY DIFFERENT 373 00001056 80E307 <1> and bl, 07h ; KB_LEDS ; ISOLATE INDICATOR BITS 374 00001059 7406 <1> jz short _K1V ; IF NO CHANGE BYPASS UPDATE 375 0000105B E863060000 <1> call SND_LED1 376 00001060 FA <1> cli ; DISABLE INTERRUPTS 377 <1> _K1V: 378 00001061 9D <1> popf ; RESTORE FLAGS 379 00001062 5B <1> pop ebx ; RESTORE ADDRESS 380 00001063 74D3 <1> je short _K1T ; LOOP UNTIL SOMETHING IN BUFFER 381 <1> ; 382 00001065 668B03 <1> mov ax, [ebx] ; GET SCAN CODE AND ASCII CODE 383 00001068 E86F000000 <1> call _K4 ; MOVE POINTER TO NEXT POSITION 384 0000106D 891D[B6670000] <1> mov [BUFFER_HEAD], ebx ; STORE VALUE IN VARIABLE 385 00001073 C3 <1> retn ; RETURN 386 <1> 387 <1> ;----- READ THE KEY TO SEE IF ONE IS PRESENT ----- 388 <1> _K2S: 389 00001074 FA <1> cli ; INTERRUPTS OFF 390 00001075 8B1D[B6670000] <1> mov ebx, [BUFFER_HEAD] ; GET HEAD POINTER 391 0000107B 3B1D[BA670000] <1> cmp ebx, [BUFFER_TAIL] ; IF EQUAL (Z=1) THEN NOTHING THERE 392 00001081 668B03 <1> mov ax, [ebx] 393 00001084 9C <1> pushf ; SAVE FLAGS 394 <1> ;push ax ; SAVE CODE 395 <1> ; 12/04/2021 396 00001085 50 <1> push eax 397 00001086 E88C060000 <1> call MAKE_LED ; GO GET MODE INDICATOR DATA BYTE 398 0000108B 8A1D[AB670000] <1> mov bl, [KB_FLAG_2] ; GET PREVIOUS BITS 399 00001091 30C3 <1> xor bl, al ; SEE IF ANY DIFFERENT 400 00001093 80E307 <1> and bl, 07h ; KB_LEDS ; ISOLATE INDICATOR BITS 401 00001096 7405 <1> jz short _K2T ; IF NO CHANGE BYPASS UPDATE 402 00001098 E80F060000 <1> call SND_LED ; GO TURN ON MODE INDICATORS 403 <1> _K2T: 404 <1> ;pop ax ; RESTORE CODE 405 <1> ; 12/04/2021 406 0000109D 58 <1> pop eax 407 0000109E 9D <1> popf ; RESTORE FLAGS 408 0000109F FB <1> sti ; INTERRUPTS BACK ON 409 000010A0 C3 <1> retn ; RETURN 410 <1> 411 <1> ;----- ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS ----- 412 <1> _KIO_E_XLAT: 413 000010A1 3CF0 <1> cmp al, 0F0h ; IS IT ONE OF THE FILL-INs? 414 000010A3 7506 <1> jne short _KIO_E_RET ; NO, PASS IT ON 415 000010A5 08E4 <1> or ah, ah ; AH = 0 IS SPECIAL CASE 416 000010A7 7402 <1> jz short _KIO_E_RET ; PASS THIS ON UNCHANGED 417 000010A9 30C0 <1> xor al, al ; OTHERWISE SET AL = 0 418 <1> _KIO_E_RET: 419 000010AB C3 <1> retn ; GO BACK 420 <1> 421 <1> ;----- ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS ----- 422 <1> _KIO_S_XLAT: 423 000010AC 80FCE0 <1> cmp ah, 0E0h ; IS IT KEYPAD ENTER OR / ? 424 000010AF 750F <1> jne short _KIO_S2 ; NO, CONTINUE 425 000010B1 3C0D <1> cmp al, 0Dh ; KEYPAD ENTER CODE? 426 000010B3 7408 <1> je short _KIO_S1 ; YES, MASSAGE A BIT 427 000010B5 3C0A <1> cmp al, 0Ah ; CTRL KEYPAD ENTER CODE? 428 000010B7 7404 <1> je short _KIO_S1 ; YES, MASSAGE THE SAME 429 000010B9 B435 <1> mov ah, 35h ; NO, MUST BE KEYPAD / 430 <1> _kio_ret: ; 03/12/2014 431 000010BB F8 <1> clc 432 000010BC C3 <1> retn 433 <1> ;jmp short _KIO_USE ; GIVE TO CALLER 434 <1> _KIO_S1: 435 000010BD B41C <1> mov ah, 1Ch ; CONVERT TO COMPATIBLE OUTPUT 436 <1> ;jmp short _KIO_USE ; GIVE TO CALLER 437 000010BF C3 <1> retn 438 <1> _KIO_S2: 439 000010C0 80FC84 <1> cmp ah, 84h ; IS IT ONE OF EXTENDED ONES? 440 000010C3 7715 <1> ja short _KIO_DIS ; YES, THROW AWAY AND GET ANOTHER CHAR 441 000010C5 3CF0 <1> cmp al, 0F0h ; IS IT ONE OF THE FILL-INs? 442 000010C7 7506 <1> jne short _KIO_S3 ; NO, TRY LAST TEST 443 000010C9 08E4 <1> or ah, ah ; AH = 0 IS SPECIAL CASE 444 000010CB 740C <1> jz short _KIO_USE ; PASS THIS ON UNCHANGED 445 000010CD EB0B <1> jmp short _KIO_DIS ; THROW AWAY THE REST 446 <1> _KIO_S3: 447 000010CF 3CE0 <1> cmp al, 0E0h ; IS IT AN EXTENSION OF A PREVIOUS ONE? 448 <1> ;jne short _KIO_USE ; NO, MUST BE A STANDARD CODE 449 000010D1 75E8 <1> jne short _kio_ret 450 000010D3 08E4 <1> or ah, ah ; AH = 0 IS SPECIAL CASE 451 000010D5 7402 <1> jz short _KIO_USE ; JUMP IF AH = 0 452 000010D7 30C0 <1> xor al, al ; CONVERT TO COMPATIBLE OUTPUT 453 <1> ;jmp short _KIO_USE ; PASS IT ON TO CALLER 454 <1> _KIO_USE: 455 <1> ;clc ; CLEAR CARRY TO INDICATE GOOD CODE 456 000010D9 C3 <1> retn ; RETURN 457 <1> _KIO_DIS: 458 000010DA F9 <1> stc ; SET CARRY TO INDICATE DISCARD CODE 459 000010DB C3 <1> retn ; RETURN 460 <1> 461 <1> ;----- INCREMENT BUFFER POINTER ROUTINE ----- 462 <1> _K4: 463 000010DC 43 <1> inc ebx 464 000010DD 43 <1> inc ebx ; MOVE TO NEXT WORD IN LIST 465 000010DE 3B1D[B2670000] <1> cmp ebx, [BUFFER_END] ; AT END OF BUFFER? 466 <1> ;jne short _K5 ; NO, CONTINUE 467 000010E4 7206 <1> jb short _K5 468 000010E6 8B1D[AE670000] <1> mov ebx, [BUFFER_START] ; YES, RESET TO BUFFER BEGINNING 469 <1> _K5: 470 000010EC C3 <1> retn 471 <1> 472 <1> ; 20/02/2015 473 <1> ; 05/12/2014 474 <1> ; 26/08/2014 475 <1> ; KEYBOARD (HARDWARE) INTERRUPT - IRQ LEVEL 1 476 <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014) 477 <1> ; 478 <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 479 <1> ; rombios source code (06/10/1985) 480 <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1) 481 <1> 482 <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC') 483 <1> 484 <1> ;--------- 8042 COMMANDS ------------------------------------------------------- 485 <1> ENA_KBD equ 0AEh ; ENABLE KEYBOARD COMMAND 486 <1> DIS_KBD equ 0ADh ; DISABLE KEYBOARD COMMAND 487 <1> SHUT_CMD equ 0FEh ; CAUSE A SHUTDOWN COMMAND 488 <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------ 489 <1> STATUS_PORT equ 064h ; 8042 STATUS PORT 490 <1> INPT_BUF_FULL equ 00000010b ; 1 = +INPUT BUFFER FULL 491 <1> PORT_A equ 060h ; 8042 KEYBOARD SCAN CODE/CONTROL PORT 492 <1> ;---------- 8042 KEYBOARD RESPONSE --------------------------------------------- 493 <1> KB_ACK equ 0FAh ; ACKNOWLEDGE PROM TRANSMISSION 494 <1> KB_RESEND equ 0FEh ; RESEND REQUEST 495 <1> KB_OVER_RUN equ 0FFh ; OVER RUN SCAN CODE 496 <1> ;---------- KEYBOARD/LED COMMANDS ---------------------------------------------- 497 <1> KB_ENABLE equ 0F4h ; KEYBOARD ENABLE 498 <1> LED_CMD equ 0EDh ; LED WRITE COMMAND 499 <1> KB_TYPA_RD equ 0F3h ; TYPAMATIC RATE/DELAY COMMAND 500 <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------ 501 <1> NUM_KEY equ 69 ; SCAN CODE FOR NUMBER LOCK KEY 502 <1> SCROLL_KEY equ 70 ; SCAN CODE FOR SCROLL LOCK KEY 503 <1> ALT_KEY equ 56 ; SCAN CODE FOR ALTERNATE SHIFT KEY 504 <1> CTL_KEY equ 29 ; SCAN CODE FOR CONTROL KEY 505 <1> CAPS_KEY equ 58 ; SCAN CODE FOR SHIFT LOCK KEY 506 <1> DEL_KEY equ 83 ; SCAN CODE FOR DELETE KEY 507 <1> INS_KEY equ 82 ; SCAN CODE FOR INSERT KEY 508 <1> LEFT_KEY equ 42 ; SCAN CODE FOR LEFT SHIFT 509 <1> RIGHT_KEY equ 54 ; SCAN CODE FOR RIGHT SHIFT 510 <1> SYS_KEY equ 84 ; SCAN CODE FOR SYSTEM KEY 511 <1> ;---------- ENHANCED KEYBOARD SCAN CODES --------------------------------------- 512 <1> ID_1 equ 0ABh ; 1ST ID CHARACTER FOR KBX 513 <1> ID_2 equ 041h ; 2ND ID CHARACTER FOR KBX 514 <1> ID_2A equ 054h ; ALTERNATE 2ND ID CHARACTER FOR KBX 515 <1> F11_M equ 87 ; F11 KEY MAKE 516 <1> F12_M equ 88 ; F12 KEY MAKE 517 <1> MC_E0 equ 224 ; GENERAL MARKER CODE 518 <1> MC_E1 equ 225 ; PAUSE KEY MARKER CODE 519 <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG---------------------------------------- 520 <1> RIGHT_SHIFT equ 00000001b ; RIGHT SHIFT KEY DEPRESSED 521 <1> LEFT_SHIFT equ 00000010b ; LEFT SHIFT KEY DEPRESSED 522 <1> CTL_SHIFT equ 00000100b ; CONTROL SHIFT KEY DEPRESSED 523 <1> ALT_SHIFT equ 00001000b ; ALTERNATE SHIFT KEY DEPRESSED 524 <1> SCROLL_STATE equ 00010000b ; SCROLL LOCK STATE IS ACTIVE 525 <1> NUM_STATE equ 00100000b ; NUM LOCK STATE IS ACTIVE 526 <1> CAPS_STATE equ 01000000b ; CAPS LOCK STATE IS ACTIVE 527 <1> INS_STATE equ 10000000b ; INSERT STATE IS ACTIVE 528 <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG_1 ------------------------------------- 529 <1> L_CTL_SHIFT equ 00000001b ; LEFT CTL KEY DOWN 530 <1> L_ALT_SHIFT equ 00000010b ; LEFT ALT KEY DOWN 531 <1> SYS_SHIFT equ 00000100b ; SYSTEM KEY DEPRESSED AND HELD 532 <1> HOLD_STATE equ 00001000b ; SUSPEND KEY HAS BEEN TOGGLED 533 <1> SCROLL_SHIFT equ 00010000b ; SCROLL LOCK KEY IS DEPRESSED 534 <1> NUM_SHIFT equ 00100000b ; NUM LOCK KEY IS DEPRESSED 535 <1> CAPS_SHIFT equ 01000000b ; CAPS LOCK KEY IS DEPRE55ED 536 <1> INS_SHIFT equ 10000000b ; INSERT KEY IS DEPRESSED 537 <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 ----------------------------------- 538 <1> KB_LEDS equ 00000111b ; KEYBOARD LED STATE BITS 539 <1> ; equ 00000001b ; SCROLL LOCK INDICATOR 540 <1> ; equ 00000010b ; NUM LOCK INDICATOR 541 <1> ; equ 00000100b ; CAPS LOCK INDICATOR 542 <1> ; equ 00001000b ; RESERVED (MUST BE ZERO) 543 <1> KB_FA equ 00010000b ; ACKNOWLEDGMENT RECEIVED 544 <1> KB_FE equ 00100000b ; RESEND RECEIVED FLAG 545 <1> KB_PR_LED equ 01000000b ; MODE INDICATOR UPDATE 546 <1> KB_ERR equ 10000000b ; KEYBOARD TRANSMIT ERROR FLAG 547 <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 ----------------------------------- 548 <1> LC_E1 equ 00000001b ; LAST CODE WAS THE E1 HIDDEN CODE 549 <1> LC_E0 equ 00000010b ; LAST CODE WAS THE E0 HIDDEN CODE 550 <1> R_CTL_SHIFT equ 00000100b ; RIGHT CTL KEY DOWN 551 <1> R_ALT_SHIFT equ 00001000b ; RIGHT ALT KEY DOWN 552 <1> GRAPH_ON equ 00001000b ; ALT GRAPHICS KEY DOWN (WT ONLY) 553 <1> KBX equ 00010000b ; ENHANCED KEYBOARD INSTALLED 554 <1> SET_NUM_LK equ 00100000b ; FORCE NUM LOCK IF READ ID AND KBX 555 <1> LC_AB equ 01000000b ; LAST CHARACTER WAS FIRST ID CHARACTER 556 <1> RD_ID equ 10000000b ; DOING A READ ID (MUST BE BIT0) 557 <1> ; 558 <1> ;----------- INTERRUPT EQUATES ------------------------------------------------- 559 <1> EOI equ 020h ; END OF INTERRUPT COMMAND TO 8259 560 <1> INTA00 equ 020h ; 8259 PORT 561 <1> 562 <1> 563 <1> kb_int: 564 <1> 565 <1> ; 24/07/2022 - TRDOS 386 v2.0.5 566 <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop) 567 <1> ; 17/10/2015 ('ctrlbrk') 568 <1> ; 05/12/2014 569 <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-) 570 <1> ; 26/08/2014 571 <1> ; 572 <1> ; 03/06/86 KEYBOARD BIOS 573 <1> ; 574 <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------ 575 <1> ; ; 576 <1> ; KEYBOARD INTERRUPT ROUTINE ; 577 <1> ; ; 578 <1> ;-------------------------------------------------------------------------------- 579 <1> 580 <1> KB_INT_1: 581 000010ED FB <1> sti ; ENABLE INTERRUPTS 582 <1> ;push ebp 583 000010EE 50 <1> push eax 584 000010EF 53 <1> push ebx 585 000010F0 51 <1> push ecx 586 000010F1 52 <1> push edx 587 000010F2 56 <1> push esi 588 000010F3 57 <1> push edi 589 000010F4 1E <1> push ds 590 000010F5 06 <1> push es 591 000010F6 FC <1> cld ; FORWARD DIRECTION 592 000010F7 66B81000 <1> mov ax, KDATA 593 000010FB 8ED8 <1> mov ds, ax 594 000010FD 8EC0 <1> mov es, ax 595 <1> ; 596 <1> ;----- WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED 597 000010FF B0AD <1> mov al, DIS_KBD ; DISABLE THE KEYBOARD COMMAND 598 00001101 E84B050000 <1> call SHIP_IT ; EXECUTE DISABLE 599 00001106 FA <1> cli ; DISABLE INTERRUPTS 600 00001107 B900000100 <1> mov ecx, 10000h ; SET MAXIMUM TIMEOUT 601 <1> KB_INT_01: 602 0000110C E464 <1> in al, STATUS_PORT ; READ ADAPTER STATUS 603 0000110E A802 <1> test al, INPT_BUF_FULL ; CHECK INPUT BUFFER FULL STATUS BIT 604 00001110 E0FA <1> loopnz KB_INT_01 ; WAIT FOR COMMAND TO BE ACCEPTED 605 <1> ; 606 <1> ;----- READ CHARACTER FROM KEYBOARD INTERFACE 607 00001112 E460 <1> in al, PORT_A ; READ IN THE CHARACTER 608 <1> ; 609 <1> ;----- SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 610 <1> ;mov ah, 04Fh ; SYSTEM INTERCEPT - KEY CODE FUNCTION 611 <1> ;stc ; SET CY=1 (IN CASE OF IRET) 612 <1> ;int 15h ; CASETTE CALL (AL)=KEY SCAN CODE 613 <1> ; ; RETURNS CY=1 FOR INVALID FUNCTION 614 <1> ;jc KB_INT_02 ; CONTINUE IF CARRY FLAG SET ((AL)=CODE) 615 <1> ;jmp K26 ; EXIT IF SYSTEM HANDLES SCAN CODE 616 <1> ; ; EXÝT HANDLES HARDWARE EOI AND ENABLE 617 <1> ; 618 <1> ;----- CHECK FOR A RESEND COMMAND TO KEYBOARD 619 <1> KB_INT_02: ; (AL)= SCAN CODE 620 00001114 FB <1> sti ; ENABLE INTERRUPTS AGAIN 621 00001115 3CFE <1> cmp al, KB_RESEND ; IS THE INPUT A RESEND 622 00001117 740E <1> je short KB_INT_4 ; GO IF RESEND 623 <1> ; 624 <1> ;----- CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD 625 00001119 3CFA <1> cmp al, KB_ACK ; IS THE INPUT AN ACKNOWLEDGE 626 0000111B 7514 <1> jne short KB_INT_2 ; GO IF NOT 627 <1> ; 628 <1> ;----- A COMMAND TO THE KEYBOARD WAS ISSUED 629 0000111D FA <1> cli ; DISABLE INTERRUPTS 630 0000111E 800D[AB670000]10 <1> or byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED 631 <1> ;jmp K26 ; RETURN IF NOT ACK RETURNED FOR DATA) 632 <1> ; 12/04/2021 633 00001125 EB76 <1> jmp short ID_EX ; K26 634 <1> ; 635 <1> ;----- RESEND THE LAST BYTE 636 <1> KB_INT_4: 637 00001127 FA <1> cli ; DISABLE INTERRUPTS 638 00001128 800D[AB670000]20 <1> or byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED 639 <1> ;jmp K26 ; RETURN IF NOT ACK RETURNED FOR DATA) 640 <1> ; 12/04/2021 641 0000112F EB6C <1> jmp short ID_EX ; K26 642 <1> ; 643 <1> ;----- UPDATE MODE INDICATORS IF CHANGE IN STATE 644 <1> KB_INT_2: 645 <1> ;push ax ; SAVE DATA IN 646 <1> ; 12/04/2021 647 00001131 50 <1> push eax 648 00001132 E8E0050000 <1> call MAKE_LED ; GO GET MODE INDICATOR DATA BYTE 649 00001137 8A1D[AB670000] <1> mov bl, [KB_FLAG_2] ; GET PREVIOUS BITS 650 0000113D 30C3 <1> xor bl, al ; SEE IF ANY DIFFERENT 651 0000113F 80E307 <1> and bl, KB_LEDS ; ISOLATE INDICATOR BITS 652 00001142 7405 <1> jz short UP0 ; IF NO CHANGE BYPASS UPDATE 653 00001144 E863050000 <1> call SND_LED ; GO TURN ON MODE INDICATORS 654 <1> UP0: 655 <1> ;pop ax ; RESTORE DATA IN 656 <1> ; 12/04/2021 657 00001149 58 <1> pop eax 658 <1> ;------------------------------------------------------------------------ 659 <1> ; START OF KEY PROCESSING ; 660 <1> ;------------------------------------------------------------------------ 661 0000114A 88C4 <1> mov ah, al ; SAVE SCAN CODE IN AH ALSO 662 <1> ; 663 <1> ;----- TEST FOR OVERRUN SCAN CODE FROM KEYBOARD 664 0000114C 3CFF <1> cmp al, KB_OVER_RUN ; IS THIS AN OVERRUN CHAR 665 <1> ;je K62 ; BUFFER_FULL_BEEP 666 <1> ; 12/04/2021 667 0000114E 7505 <1> jne short K16 668 00001150 E9E8040000 <1> jmp K62 669 <1> K16: 670 00001155 8A3D[AC670000] <1> mov bh, [KB_FLAG_3] ; LOAD FLAGS FOR TESTING 671 <1> ; 672 <1> ;----- TEST TO SEE IF A READ_ID IS IN PROGRESS 673 0000115B F6C7C0 <1> test bh, RD_ID+LC_AB ; ARE WE DOING A READ ID? 674 0000115E 7442 <1> jz short NOT_ID ; CONTINUE IF NOT 675 00001160 7914 <1> jns short TST_ID_2 ; IS THE RD_ID FLAG ON? 676 00001162 3CAB <1> cmp al, ID_1 ; IS THIS THE 1ST ID CHARACTER? 677 00001164 7507 <1> jne short RST_RD_ID 678 00001166 800D[AC670000]40 <1> or byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK 679 <1> RST_RD_ID: 680 0000116D 8025[AC670000]7F <1> and byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG 681 00001174 EB27 <1> jmp short ID_EX ; AND EXIT 682 <1> ; 12/04/2021 683 <1> ;jmp K26 684 <1> ; 685 <1> TST_ID_2: 686 00001176 8025[AC670000]BF <1> and byte [KB_FLAG_3], ~LC_AB ; RESET FLAG 687 0000117D 3C54 <1> cmp al, ID_2A ; IS THIS THE 2ND ID CHARACTER? 688 0000117F 7415 <1> je short KX_BIT ; JUMP IF SO 689 00001181 3C41 <1> cmp al, ID_2 ; IS THIS THE 2ND ID CHARACTER? 690 00001183 7518 <1> jne short ID_EX ; LEAVE IF NOT 691 <1> ; 12/04/2021 692 <1> ;jne K26 693 <1> ; 694 <1> ;----- A READ ID SAID THAT IT WAS ENHANCED KEYBOARD 695 00001185 F6C720 <1> test bh, SET_NUM_LK ; SHOULD WE SET NUM LOCK? 696 00001188 740C <1> jz short KX_BIT ; EXIT IF NOT 697 0000118A 800D[A9670000]20 <1> or byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON 698 00001191 E816050000 <1> call SND_LED ; GO SET THE NUM LOCK INDICATOR 699 <1> KX_BIT: 700 00001196 800D[AC670000]10 <1> or byte [KB_FLAG_3], KBX ; INDICATE ENHANCED KEYBOARD WAS FOUND 701 0000119D E9CB010000 <1> ID_EX: jmp K26 ; EXIT 702 <1> ; 703 <1> NOT_ID: 704 000011A2 3CE0 <1> cmp al, MC_E0 ; IS THIS THE GENERAL MARKER CODE? 705 000011A4 7509 <1> jne short TEST_E1 706 000011A6 800D[AC670000]12 <1> or byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND 707 000011AD EB0B <1> jmp short EXIT ; THROW AWAY THIS CODE 708 <1> ; 12/04/2021 709 <1> ;jmp K26A 710 <1> TEST_E1: 711 000011AF 3CE1 <1> cmp al, MC_E1 ; IS THIS THE PAUSE KEY? 712 000011B1 750C <1> jne short NOT_HC 713 000011B3 800D[AC670000]11 <1> or byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND 714 000011BA E9B5010000 <1> EXIT: jmp K26A ; THROW AWAY THIS CODE 715 <1> ; 716 <1> NOT_HC: 717 000011BF 247F <1> and al, 07Fh ; TURN OFF THE BREAK BIT 718 000011C1 F6C702 <1> test bh, LC_E0 ; LAST CODE THE E0 MARKER CODE 719 000011C4 7410 <1> jz short NOT_LC_E0 ; JUMP IF NOT 720 <1> ; 721 000011C6 BF[96660000] <1> mov edi, _K6+6 ; IS THIS A SHIFT KEY? 722 000011CB AE <1> scasb 723 <1> ;je K26 ; K16B ; YES, THROW AWAY & RESET FLAG 724 <1> ; 12/04/2021 725 000011CC 745B <1> je short K16B ; K26 726 000011CE AE <1> scasb 727 000011CF 756D <1> jne short K16A ; NO, CONTINUE KEY PROCESSING 728 <1> ;jmp short K16B ; YES, THROW AWAY & RESET FLAG 729 000011D1 E997010000 <1> jmp K26 730 <1> ; 731 <1> NOT_LC_E0: 732 000011D6 F6C701 <1> test bh, LC_E1 ; LAST CODE THE E1 MARKER CODE? 733 000011D9 7425 <1> jz short T_SYS_KEY ; JUMP IF NOT 734 000011DB B904000000 <1> mov ecx, 4 ; LENGHT OF SEARCH 735 000011E0 BF[94660000] <1> mov edi, _K6+4 ; IS THIS AN ALT, CTL, OR SHIFT? 736 000011E5 F2AE <1> repne scasb ; CHECK IT 737 000011E7 74D1 <1> je short EXIT ; THROW AWAY IF SO 738 <1> ; 12/04/2021 739 <1> ;je K26A 740 <1> ; 741 000011E9 3C45 <1> cmp al, NUM_KEY ; IS IT THE PAUSE KEY? 742 000011EB 753C <1> jne short K16B ; NO, THROW AWAY & RESET FLAG 743 <1> ; 12/04/2021 744 <1> ;jne K26 745 000011ED F6C480 <1> test ah, 80h ; YES, IS IT THE BREAK OF THE KEY? 746 000011F0 7537 <1> jnz short K16B ; YES, THROW THIS AWAY, TOO 747 <1> ; 24/07/2022 748 <1> ;jnz K26 749 <1> ; 20/02/2015 750 000011F2 F605[AA670000]08 <1> test byte [KB_FLAG_1],HOLD_STATE ; NO, ARE WE PAUSED ALREADY? 751 000011F9 752E <1> jnz short K16B ; YES, THROW AWAY 752 <1> ; 12/04/2021 753 <1> ;jnz K26 754 000011FB E9B1020000 <1> jmp K39P ; NO, THIS IS THE REAL PAUSE STATE 755 <1> ; 756 <1> ;----- TEST FOR SYSTEM KEY 757 <1> T_SYS_KEY: 758 00001200 3C54 <1> cmp al, SYS_KEY ; IS IT THE SYSTEM KEY? 759 00001202 753A <1> jnz short K16A ; CONTINUE IF NOT 760 <1> ; 761 00001204 F6C480 <1> test ah, 80h ; CHECK IF THIS A BREAK CODE 762 00001207 7525 <1> jnz short K16C ; DO NOT TOUCH SYSTEM INDICATOR IF TRUE 763 <1> ; 764 00001209 F605[AA670000]04 <1> test byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 765 00001210 7517 <1> jnz short K16B ; IF YES, DO NOT PROCESS SYSTEM INDICATOR 766 <1> ; 12/04/2021 767 <1> ;jnz K26 768 <1> ; 769 00001212 800D[AA670000]04 <1> or byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED 770 00001219 B020 <1> mov al, EOI ; END OF INTERRUPT COMMAND 771 0000121B E620 <1> out 20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT 772 <1> ; INTERRUPT-RETURN-NO-EOI 773 0000121D B0AE <1> mov al, ENA_KBD ; INSURE KEYBOARD IS ENABLED 774 0000121F E82D040000 <1> call SHIP_IT ; EXECUTE ENABLE 775 <1> ; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!! 776 <1> ;MOV AL, 8500H ; FUNCTION VALUE FOR MAKE OF SYSTEM KEY 777 <1> ;STI ; MAKE SURE INTERRUPTS ENABLED 778 <1> ;INT 15H ; USER INTERRUPT 779 00001224 E957010000 <1> jmp K27A ; END PROCESSING 780 <1> ; 781 00001229 E93F010000 <1> K16B: jmp K26 ; IGNORE SYSTEM KEY 782 <1> ; 783 <1> K16C: 784 0000122E 8025[AA670000]FB <1> and byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN 785 00001235 B020 <1> mov al, EOI ; END OF INTERRUPT COMMAND 786 00001237 E620 <1> out 20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT 787 <1> ; INTERRUPT-RETURN-NO-EOI 788 <1> ;MOV AL, ENA_KBD ; INSURE KEYBOARD IS ENABLED 789 <1> ;CALL SHIP_IT ; EXECUTE ENABLE 790 <1> ; 791 <1> ;MOV AX, 8501H ; FUNCTION VALUE FOR BREAK OF SYSTEM KEY 792 <1> ;STI ; MAKE SURE INTERRUPTS ENABLED 793 <1> ;INT 15H ; USER INTERRUPT 794 <1> ;JMP K27A ; INGONRE SYSTEM KEY 795 <1> ; 796 00001239 E93B010000 <1> jmp K27 ; IGNORE SYSTEM KEY 797 <1> ; 798 <1> ;----- TEST FOR SHIFT KEYS 799 <1> K16A: 800 0000123E 8A1D[A9670000] <1> mov bl, [KB_FLAG] ; PUT STATE FLAGS IN BL 801 00001244 BF[90660000] <1> mov edi, _K6 ; SHIFT KEY TABLE offset 802 00001249 B908000000 <1> mov ecx, _K6L ; LENGTH 803 0000124E F2AE <1> repne scasb ; LOOK THROUGH THE TABLE FOR A MATCH 804 00001250 88E0 <1> mov al, ah ; RECOVER SCAN CODE 805 <1> ;jne K25 ; IF NO MATCH, THEN SHIFT NOT FOUND 806 <1> ; 12/04/2021 807 00001252 7405 <1> je short K17 808 00001254 E9FC000000 <1> jmp K25 809 <1> ; 810 <1> ;------ SHIFT KEY FOUND 811 <1> K17: 812 00001259 81EF[91660000] <1> sub edi, _K6+1 ; ADJUST PTR TO SCAN CODE MATCH 813 0000125F 8AA7[98660000] <1> mov ah, [edi+_K7] ; GET MASK INTO AH 814 00001265 B102 <1> mov cl, 2 ; SETUP COUNT FOR FLAG SHIFTS 815 00001267 A880 <1> test al, 80h ; TEST FOR BREAK KEY 816 <1> ;jnz short K23 ; JUMP OF BREAK 817 <1> ; 12/04/2021 818 00001269 7405 <1> jz short K17C 819 0000126B E981000000 <1> jmp K23 820 <1> ; 821 <1> ;----- SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE 822 <1> K17C: 823 00001270 80FC10 <1> cmp ah, SCROLL_SHIFT 824 00001273 7324 <1> jae short K18 ; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY 825 <1> ; 826 <1> ;----- PLAIN SHIFT KEY, SET SHIFT ON 827 00001275 0825[A9670000] <1> or [KB_FLAG], ah ; TURN ON SHIFT BIT 828 0000127B A80C <1> test al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL? 829 <1> ;;jnz short K17D ; YES, MORE FLAGS TO SET 830 <1> ;jz K26 ; NO, INTERRUPT RETURN 831 <1> ; 12/04/2021 832 0000127D 7415 <1> jz short k17f 833 <1> K17D: 834 0000127F F6C702 <1> test bh, LC_E0 ; IS THIS ONE OF NEW KEYS? 835 00001282 7408 <1> jz short K17E ; NO, JUMP 836 00001284 0825[AC670000] <1> or [KB_FLAG_3], ah ; SET BITS FOR RIGHT CTRL, ALT 837 <1> ;jmp K26 ; INTERRUPT RETURN 838 <1> ; 12/04/2021 839 0000128A EB08 <1> jmp short k17f 840 <1> K17E: 841 0000128C D2EC <1> shr ah, cl ; MOVE FLAG BITS TWO POSITIONS 842 0000128E 0825[AA670000] <1> or [KB_FLAG_1], ah ; SET BITS FOR LEFT CTRL, ALT 843 <1> k17f: ; 12/04/2021 844 00001294 E9D4000000 <1> jmp K26 845 <1> ; 846 <1> ;----- TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT 847 <1> K18: ; SHIFT-TOGGLE 848 00001299 F6C304 <1> test bl, CTL_SHIFT ; CHECK CTL SHIFT STATE 849 0000129C 7402 <1> jz short K18A ; JUMP IF NOT CTL STATE 850 <1> ;jnz K25 ; JUMP IF CTL STATE 851 <1> ; 12/04/2021 852 0000129E EB1C <1> jmp short k20a ; K25 853 <1> K18A: 854 000012A0 3C52 <1> cmp al, INS_KEY ; CHECK FOR INSERT KEY 855 000012A2 7522 <1> jne short K22 ; JUMP IF NOT INSERT KEY 856 000012A4 F6C308 <1> test bl, ALT_SHIFT ; CHECK FOR ALTERNATE SHIFT 857 000012A7 7402 <1> jz short K18B ; JUMP IF NOT ALTERNATE SHIFT 858 <1> ;jnz K25 ; JUMP IF ALTERNATE SHIFT 859 <1> ; 12/04/2021 860 000012A9 EB11 <1> jmp short k20a ; K25 861 <1> K18B: 862 000012AB F6C702 <1> test bh, LC_E0 ;20/02/2015 ; IS THIS NEW INSERT KEY? 863 000012AE 7516 <1> jnz short K22 ; YES, THIS ONE'S NEVER A '0' 864 <1> K19: 865 000012B0 F6C320 <1> test bl, NUM_STATE ; CHECK FOR BASE STATE 866 000012B3 750C <1> jnz short K21 ; JUMP IF NUM LOCK IS ON 867 000012B5 F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE 868 000012B8 740C <1> jz short K22 ; JUMP IF BASE STATE 869 <1> K20: ; NUMERIC ZERO, NOT INSERT KEY 870 000012BA 88C4 <1> mov ah, al ; PUT SCAN CODE BACK IN AH 871 <1> k20a: ; 12/04/2021 872 000012BC E994000000 <1> jmp K25 ; NUMERAL '0', STNDRD. PROCESSING 873 <1> K21: ; MIGHT BE NUMERIC 874 000012C1 F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT 875 000012C4 74F4 <1> jz short K20 ; IS NUMERIC, STD. PROC. 876 <1> ; 877 <1> K22: ; SHIFT TOGGLE KEY HIT; PROCESS IT 878 000012C6 8425[AA670000] <1> test ah, [KB_FLAG_1] ; IS KEY ALREADY DEPRESSED 879 <1> ;jnz short K26 ; JUMP IF KEY ALREADY DEPRESSED 880 <1> ; 12/04/2021 881 000012CC 75C6 <1> jnz short k17f ; K26 882 <1> K22A: 883 000012CE 0825[AA670000] <1> or [KB_FLAG_1], ah ; INDICATE THAT THE KEY IS DEPRESSED 884 000012D4 3025[A9670000] <1> xor [KB_FLAG], ah ; TOGGLE THE SHIFT STATE 885 <1> ; 886 <1> ;----- TOGGLE LED IF CAPS, NUM OR SCROLL KEY DEPRESSED 887 000012DA F6C470 <1> test ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE? 888 000012DD 7407 <1> jz short K22B ; GO IF NOT 889 <1> ; 890 <1> ; 12/04/2021 (32 bit push/pop) 891 000012DF 50 <1> push eax ; push ax ; SAVE SCAN CODE AND SHIFT MASK 892 000012E0 E8C7030000 <1> call SND_LED ; GO TURN MODE INDICATORS ON 893 000012E5 58 <1> pop eax ; pop ax ; RESTORE SCAN CODE 894 <1> K22B: 895 000012E6 3C52 <1> cmp al, INS_KEY ; TEST FOR 1ST MAKE OF INSERT KEY 896 <1> ;jne short K26 ; JUMP IF NOT INSERT KEY 897 <1> ; 12/04/2021 898 000012E8 75AA <1> jne short k17f ; K26 899 000012EA 88C4 <1> mov ah, al ; SCAN CODE IN BOTH HALVES OF AX 900 000012EC E999000000 <1> jmp K28 ; FLAGS UPDATED, PROC. FOR BUFFER 901 <1> ; 902 <1> ;----- BREAK SHIFT FOUND 903 <1> K23: ; BREAK-SHIFT-FOUND 904 000012F1 80FC10 <1> cmp ah, SCROLL_SHIFT ; IS THIS A TOGGLE KEY 905 000012F4 F6D4 <1> not ah ; INVERT MASK 906 000012F6 7355 <1> jae short K24 ; YES, HANDLE BREAK TOGGLE 907 000012F8 2025[A9670000] <1> and [KB_FLAG], ah ; TURN OFF SHIFT BIT 908 000012FE 80FCFB <1> cmp ah, ~CTL_SHIFT ; IS THIS ALT OR CTL? 909 00001301 7730 <1> ja short K23D ; NO, ALL DONE 910 <1> ; 911 00001303 F6C702 <1> test bh, LC_E0 ; 2ND ALT OR CTL? 912 00001306 7408 <1> jz short K23A ; NO, HANSLE NORMALLY 913 00001308 2025[AC670000] <1> and [KB_FLAG_3], ah ; RESET BIT FOR RIGHT ALT OR CTL 914 0000130E EB08 <1> jmp short K23B ; CONTINUE 915 <1> K23A: 916 00001310 D2FC <1> sar ah, cl ; MOVE THE MASK BIT TWO POSITIONS 917 00001312 2025[AA670000] <1> and [KB_FLAG_1], ah ; RESET BIT FOR LEFT ALT AND CTL 918 <1> K23B: 919 00001318 88C4 <1> mov ah, al ; SAVE SCAN CODE 920 0000131A A0[AC670000] <1> mov al, [KB_FLAG_3] ; GET RIGHT ALT & CTRL FLAGS 921 0000131F D2E8 <1> shr al, cl ; MOVE TO BITS 1 & 0 922 00001321 0A05[AA670000] <1> or al, [KB_FLAG_1] ; PUT IN LEFT ALÞT & CTL FLAGS 923 00001327 D2E0 <1> shl al, cl ; MOVE BACK TO BITS 3 & 2 924 00001329 240C <1> and al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE 925 0000132B 0805[A9670000] <1> or [KB_FLAG], al ; PUT RESULT IN THE REAL FLAGS 926 00001331 88E0 <1> mov al, ah 927 <1> K23D: 928 00001333 3CB8 <1> cmp al, ALT_KEY+80h ; IS THIS ALTERNATE SHIFT RELEASE 929 00001335 7536 <1> jne short K26 ; INTERRUPT RETURN 930 <1> ; 931 <1> ;----- ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER 932 00001337 A0[AD670000] <1> mov al, [ALT_INPUT] 933 0000133C B400 <1> mov ah, 0 ; SCAN CODE OF 0 934 0000133E 8825[AD670000] <1> mov [ALT_INPUT], ah ; ZERO OUT THE FIELD 935 00001344 3C00 <1> cmp al, 0 ; WAS THE INPUT = 0? 936 00001346 7425 <1> je short K26 ; INTERRUPT_RETURN 937 <1> ; 29/01/2016 938 <1> ;jmp K61 ; IT WASN'T, SO PUT IN BUFFER 939 00001348 E9AB020000 <1> jmp _K60 940 <1> ; 941 <1> K24: ; BREAK-TOGGLE 942 0000134D 2025[AA670000] <1> and [KB_FLAG_1], ah ; INDICATE NO LONGER DEPRESSED 943 00001353 EB18 <1> jmp short K26 ; INTERRUPT_RETURN 944 <1> ; 945 <1> ;----- TEST FOR HOLD STATE 946 <1> ; AL, AH = SCAN CODE 947 <1> K25: ; NO-SHIFT-FOUND 948 00001355 3C80 <1> cmp al, 80h ; TEST FOR BREAK KEY 949 00001357 7314 <1> jae short K26 ; NOTHING FOR BREAK CHARS FROM HERE ON 950 00001359 F605[AA670000]08 <1> test byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE 951 00001360 7428 <1> jz short K28 ; BRANCH AROUND TEST IF NOT 952 00001362 3C45 <1> cmp al, NUM_KEY 953 00001364 7407 <1> je short K26 ; CAN'T END HOLD ON NUM_LOCK 954 00001366 8025[AA670000]F7 <1> and byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT 955 <1> K26: 956 0000136D 8025[AC670000]FC <1> and byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG 957 <1> K26A: ; INTERRUPT-RETURN 958 00001374 FA <1> cli ; TURN OFF INTERRUPTS 959 00001375 B020 <1> mov al, EOI ; END OF INTERRUPT COMMAND 960 00001377 E620 <1> out 20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT 961 <1> K27: ; INTERRUPT-RETURN-NO-EOI 962 00001379 B0AE <1> mov al, ENA_KBD ; INSURE KEYBOARD IS ENABLED 963 0000137B E8D1020000 <1> call SHIP_IT ; EXECUTE ENABLE 964 <1> K27A: 965 00001380 FA <1> cli ; DISABLE INTERRUPTS 966 <1> ;;mov byte [intflg], 0 ; 07/01/2017 ;; 15/01/2017 967 00001381 07 <1> pop es ; RESTORE REGISTERS 968 00001382 1F <1> pop ds 969 00001383 5F <1> pop edi 970 00001384 5E <1> pop esi 971 00001385 5A <1> pop edx 972 00001386 59 <1> pop ecx 973 00001387 5B <1> pop ebx 974 00001388 58 <1> pop eax 975 <1> ;pop ebp 976 00001389 CF <1> iretd ; RETURN 977 <1> 978 <1> ;----- NOT IN HOLD STATE 979 <1> K28: ; NO-HOLD-STATE 980 0000138A 3C58 <1> cmp al, 88 ; TEST FOR OUT-OF-RANGE SCAN CODES 981 0000138C 77DF <1> ja short K26 ; IGNORE IF OUT-OF-RANGE 982 <1> ; 983 0000138E F6C308 <1> test bl, ALT_SHIFT ; ARE WE IN ALTERNATE SHIFT 984 00001391 740E <1> jz short K28A ; IF NOT ALTERNATE 985 <1> ; 12/04/2021 986 <1> ;jz K38 987 <1> ; 988 00001393 F6C710 <1> test bh, KBX ; IS THIS THE ENCHANCED KEYBOARD? 989 00001396 740E <1> jz short K29 ; NO, ALT STATE IS REAL 990 <1> ;28/02/2015 991 00001398 F605[AA670000]04 <1> test byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN? 992 0000139F 7405 <1> jz short K29 ; NO, ALT STATE IS REAL 993 <1> ; 12/04/2021 994 <1> ;jnz K38 ; YES, THIS IS PHONY ALT STATE 995 <1> ; ; DUE TO PRESSING SYSREQ 996 000013A1 E9C4000000 <1> K28A: jmp K38 997 <1> ; 998 <1> ;----- TEST FOR RESET KEY SEQUENCE (CTL ALT DEL) 999 <1> K29: ; TEST-RESET 1000 000013A6 F6C304 <1> test bl, CTL_SHIFT ; ARE WE IN CONTROL SHIFT ALSO? 1001 000013A9 740B <1> jz short K31 ; NO_RESET 1002 000013AB 3C53 <1> cmp al, DEL_KEY ; CTL-ALT STATE, TEST FOR DELETE KEY 1003 000013AD 7507 <1> jne short K31 ; NO_RESET, IGNORE 1004 <1> ; 1005 <1> ;----- CTL-ALT-DEL HAS BEEN FOUND 1006 <1> ; 26/08/2014 1007 <1> cpu_reset: 1008 <1> ; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN) 1009 <1> ; Send FEh (system reset command) to the keyboard controller. 1010 000013AF B0FE <1> mov al, SHUT_CMD ; SHUTDOWN COMMAND 1011 000013B1 E664 <1> out STATUS_PORT, al ; SEND TO KEYBOARD CONTROL PORT 1012 <1> khere: 1013 000013B3 F4 <1> hlt ; WAIT FOR 80286 RESET 1014 000013B4 EBFD <1> jmp short khere ; INSURE HALT 1015 <1> ; 1016 <1> ;----- IN ALTERNATE SHIFT, RESET NOT FOUND 1017 <1> K31: ; NO-RESET 1018 000013B6 3C39 <1> cmp al, 57 ; TEST FOR SPACE KEY 1019 000013B8 7507 <1> jne short K311 ; NOT THERE 1020 000013BA B020 <1> mov al, ' ' ; SET SPACE CHAR 1021 <1> k31a: ; 12/04/2021 1022 000013BC E929020000 <1> jmp K57 ; BUFFER_FILL 1023 <1> K311: 1024 000013C1 3C0F <1> cmp al, 15 ; TEST FOR TAB KEY 1025 000013C3 7506 <1> jne short K312 ; NOT THERE 1026 000013C5 66B800A5 <1> mov ax, 0A500h ; SET SPECIAL CODE FOR ALT-TAB 1027 <1> ;jmp K57 ; BUFFER_FILL 1028 <1> ; 12/04/2021 1029 000013C9 EBF1 <1> jmp short k31a 1030 <1> K312: 1031 000013CB 3C4A <1> cmp al, 74 ; TEST FOR KEY PAD - 1032 <1> ;je short K37B ; GO PROCESS 1033 <1> ; 12/04/2021 1034 000013CD 7404 <1> je short k312a 1035 000013CF 3C4E <1> cmp al, 78 ; TEST FOR KEY PAD + 1036 <1> ;je short K37B ; GO PROCESS 1037 <1> ; 12/04/2021 1038 000013D1 7505 <1> jne short K32 1039 <1> k312a: 1040 000013D3 E988000000 <1> jmp K37B 1041 <1> ; 1042 <1> ;----- LOOK FOR KEY PAD ENTRY 1043 <1> K32: ; ALT-KEY-PAD 1044 000013D8 BF[6C660000] <1> mov edi, K30 ; ALT-INPUT-TABLE offset 1045 000013DD B90A000000 <1> mov ecx, 10 ; LOOK FOR ENTRY USING KEYPAD 1046 000013E2 F2AE <1> repne scasb ; LOOK FOR MATCH 1047 000013E4 7521 <1> jne short K33 ; NO_ALT_KEYPAD 1048 000013E6 F6C702 <1> test bh, LC_E0 ; IS THIS ONE OF THE NEW KEYS? 1049 000013E9 7579 <1> jnz short K37C ; YES, JUMP, NOT NUMPAD KEY 1050 000013EB 81EF[6D660000] <1> sub edi, K30+1 ; DI NOW HAS ENTRY VALUE 1051 000013F1 A0[AD670000] <1> mov al, [ALT_INPUT] ; GET THE CURRENT BYTE 1052 000013F6 B40A <1> mov ah, 10 ; MULTIPLY BY 10 1053 000013F8 F6E4 <1> mul ah 1054 000013FA 6601F8 <1> add ax, di ; ADD IN THE LATEST ENTRY 1055 000013FD A2[AD670000] <1> mov [ALT_INPUT], al ; STORE IT AWAY 1056 <1> K32A: 1057 00001402 E966FFFFFF <1> jmp K26 ; THROW AWAY THAT KEYSTROKE 1058 <1> ; 1059 <1> ;----- LOOK FOR SUPERSHIFT ENTRY 1060 <1> K33: ; NO-ALT-KEYPAD 1061 00001407 C605[AD670000]00 <1> mov byte [ALT_INPUT], 0 ; ZERO ANY PREVIOUS ENTRY INTO INPUT 1062 0000140E B91A000000 <1> mov ecx, 26 ; (DI),(ES) ALREADY POINTING 1063 00001413 F2AE <1> repne scasb ; LOOK FOR MATCH IN ALPHABET 1064 00001415 7445 <1> je short K37A ; MATCH FOUND, GO FILLL THE BUFFER 1065 <1> ; 1066 <1> ;----- LOOK FOR TOP ROW OF ALTERNATE SHIFT 1067 <1> K34: ; ALT-TOP-ROW 1068 00001417 3C02 <1> cmp al, 2 ; KEY WITH '1' ON IT 1069 00001419 7245 <1> jb short K37B ; MUST BE ESCAPE 1070 0000141B 3C0D <1> cmp al, 13 ; IS IT IN THE REGION 1071 0000141D 7705 <1> ja short K35 ; NO, ALT SOMETHING ELSE 1072 0000141F 80C476 <1> add ah, 118 ; CONVERT PSEUDO SCAN CODE TO RANGE 1073 00001422 EB38 <1> jmp short K37A ; GO FILL THE BUFFER 1074 <1> ; 1075 <1> ;----- TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES 1076 <1> K35: ; ALT-FUNCTION 1077 00001424 3C57 <1> cmp al, F11_M ; IS IT F11? 1078 00001426 7209 <1> jb short K35A ; 20/02/2015 ; NO, BRANCH 1079 00001428 3C58 <1> cmp al, F12_M ; IS IT F12? 1080 0000142A 7705 <1> ja short K35A ; 20/02/2015 ; NO, BRANCH 1081 0000142C 80C434 <1> add ah, 52 ; CONVERT TO PSEUDO SCAN CODE 1082 0000142F EB2B <1> jmp short K37A ; GO FILL THE BUFFER 1083 <1> K35A: 1084 00001431 F6C702 <1> test bh, LC_E0 ; DO WE HAVE ONE OF THE NEW KEYS? 1085 00001434 741B <1> jz short K37 ; NO, JUMP 1086 00001436 3C1C <1> cmp al, 28 ; TEST FOR KEYPAD ENTER 1087 00001438 7506 <1> jne short K35B ; NOT THERE 1088 0000143A 66B800A6 <1> mov ax, 0A600h ; SPECIAL CODE 1089 <1> ;jmp K57 ; BUFFER FILL 1090 <1> ; 12/04/2021 1091 0000143E EB0C <1> jmp short k35c 1092 <1> K35B: 1093 00001440 3C53 <1> cmp al, 83 ; TEST FOR DELETE KEY 1094 00001442 7420 <1> je short K37C ; HANDLE WITH OTHER EDIT KEYS 1095 00001444 3C35 <1> cmp al, 53 ; TEST FOR KEYPAD / 1096 00001446 75BA <1> jne short K32A ; NOT THERE, NO OTHER E0 SPECIALS 1097 <1> ; 12/04/2021 1098 <1> ;jne K26 1099 00001448 66B800A4 <1> mov ax, 0A400h ; SPECIAL CODE1 1100 <1> k35c: ; 12/04/2021 1101 0000144C E999010000 <1> jmp K57 ; BUFFER FILL 1102 <1> K37: 1103 00001451 3C3B <1> cmp al, 59 ; TEST FOR FUNCTION KEYS (F1) 1104 00001453 720B <1> jb short K37B ; NO FN, HANDLE W/OTHER EXTENDED 1105 00001455 3C44 <1> cmp al, 68 ; IN KEYPAD REGION? 1106 00001457 77A9 <1> ja short K32A ; IF SO, IGNORE 1107 <1> ; 12/04/2021 1108 <1> ;ja K26 1109 00001459 80C42D <1> add ah, 45 ; CONVERT TO PSEUDO SCAN CODE 1110 <1> K37A: 1111 0000145C B000 <1> mov al, 0 ; ASCII CODE OF ZERO 1112 <1> ;jmp K57 ; PUT IT IN THE BUFFER 1113 <1> ; 12/04/2021 1114 0000145E EBEC <1> jmp short k35c 1115 <1> K37B: 1116 00001460 B0F0 <1> mov al, 0F0h ; USE SPECIAL ASCII CODE 1117 <1> ;jmp K57 ; PUT IT IN THE BUFFER 1118 <1> ; 12/04/2021 1119 00001462 EBE8 <1> jmp short k35c 1120 <1> K37C: 1121 00001464 0450 <1> add al, 80 ; CONVERT SCAN CODE (EDIT KEYS) 1122 00001466 88C4 <1> mov ah, al ; (SCAN CODE NOT IN AH FOR INSERT) 1123 00001468 EBF2 <1> jmp short K37A ; PUT IT IN THE BUFFER 1124 <1> ; 1125 <1> ;----- NOT IN ALTERNATE SHIFT 1126 <1> K38: ; NOT-ALT-SHIFT 1127 <1> ; BL STILL HAS SHIFT FLAGS 1128 0000146A F6C304 <1> test bl, CTL_SHIFT ; ARE WE IN CONTROL SHIFT? 1129 <1> ;;jnz short K38A ; YES, START PROCESSING 1130 <1> ;jz K44 ; NOT-CTL-SHIFT 1131 <1> ; 12/04/2021 1132 0000146D 7505 <1> jnz short K38A ; YES, START PROCESSING 1133 0000146F E9AB000000 <1> jmp K44 ; NOT-CTL-SHIFT 1134 <1> ; 1135 <1> ;----- CONTROL SHIFT, TEST SPECIAL CHARACTERS 1136 <1> ;----- TEST FOR BREAK 1137 <1> K38A: 1138 00001474 3C46 <1> cmp al, SCROLL_KEY ; TEST FOR BREAK 1139 00001476 7530 <1> jne short K39 ; JUMP, NO-BREAK 1140 00001478 F6C710 <1> test bh, KBX ; IS THIS THE ENHANCED KEYBOARD? 1141 0000147B 7405 <1> jz short K38B ; NO, BREAK IS VALID 1142 0000147D F6C702 <1> test bh, LC_E0 ; YES, WAS LAST CODE AN E0? 1143 00001480 7426 <1> jz short K39 ; NO-BREAK, TEST FOR PAUSE 1144 <1> K38B: 1145 00001482 8B1D[B6670000] <1> mov ebx, [BUFFER_HEAD] ; RESET BUFFER TO EMPTY 1146 00001488 891D[BA670000] <1> mov [BUFFER_TAIL], ebx 1147 0000148E C605[A8670000]80 <1> mov byte [BIOS_BREAK], 80h ; TURN ON BIOS_BREAK BIT 1148 <1> ; 1149 <1> ;----- ENABLE KEYBOARD 1150 00001495 B0AE <1> mov al, ENA_KBD ; ENABLE KEYBOARD 1151 00001497 E8B5010000 <1> call SHIP_IT ; EXECUTE ENABLE 1152 <1> ; 1153 <1> ; CTRL+BREAK code here !!! 1154 <1> ;INT 1BH ; BREAK INTERRUPT VECTOR 1155 <1> ; 17/10/2015 1156 0000149C E84D590000 <1> call ctrlbrk ; control+break subroutine 1157 <1> ; 1158 <1> ;sub ax, ax ; PUT OUT DUMMY CHARACTER 1159 <1> ; 12/04/2021 1160 000014A1 29C0 <1> sub eax, eax 1161 000014A3 E942010000 <1> jmp K57 ; BUFFER_FILL 1162 <1> ; 1163 <1> ;----- TEST FOR PAUSE 1164 <1> K39: ; NO_BREAK 1165 000014A8 F6C710 <1> test bh, KBX ; IS THIS THE ENHANCED KEYBOARD? 1166 000014AB 7537 <1> jnz short K41 ; YES, THEN THIS CAN'T BE PAUSE 1167 000014AD 3C45 <1> cmp al, NUM_KEY ; LOOK FOR PAUSE KEY 1168 000014AF 7533 <1> jne short K41 ; NO-PAUSE 1169 <1> K39P: 1170 000014B1 800D[AA670000]08 <1> or byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG 1171 <1> ; 1172 <1> ;----- ENABLE KEYBOARD 1173 000014B8 B0AE <1> mov al, ENA_KBD ; ENABLE KEYBOARD 1174 000014BA E892010000 <1> call SHIP_IT ; EXECUTE ENABLE 1175 <1> K39A: 1176 000014BF B020 <1> mov al, EOI ; END OF INTERRUPT TO CONTROL PORT 1177 000014C1 E620 <1> out 20h, al ;out INTA00, al ; ALLOW FURTHER KEYSTROKE INTERRUPTS 1178 <1> ; 1179 <1> ;----- DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON 1180 000014C3 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; IS THIS BLACK AND WHITE CARD 1181 000014CA 740A <1> je short K40 ; YES, NOTHING TO DO 1182 000014CC 66BAD803 <1> mov dx, 03D8h ; PORT FOR COLOR CARD 1183 000014D0 A0[DF670000] <1> mov al, [CRT_MODE_SET] ; GET THE VALUE OF THE CURRENT MODE 1184 000014D5 EE <1> out dx, al ; SET THE CRT MODE, SO THAT CRT IS ON 1185 <1> ; 1186 <1> K40: ; PAUSE-LOOP 1187 000014D6 F605[AA670000]08 <1> test byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG 1188 000014DD 75F7 <1> jnz short K40 ; LOOP UNTIL FLAG TURNED OFF 1189 <1> ; 1190 000014DF E995FEFFFF <1> jmp K27 ; INTERRUPT_RETURN_NO_EOI 1191 <1> ; 1192 <1> ;----- TEST SPECIAL CASE KEY 55 1193 <1> K41: ; NO-PAUSE 1194 000014E4 3C37 <1> cmp al, 55 ; TEST FOR */PRTSC KEY 1195 000014E6 7513 <1> jne short K42 ; NOT-KEY-55 1196 000014E8 F6C710 <1> test bh, KBX ; IS THIS THE ENHANCED KEYBOARD? 1197 000014EB 7405 <1> jz short K41A ; NO, CTL-PRTSC IS VALID 1198 000014ED F6C702 <1> test bh, LC_E0 ; YES, WAS LAST CODE AN E0? 1199 000014F0 7421 <1> jz short K42B ; NO, TRANSLATE TO A FUNCTION 1200 <1> K41A: 1201 000014F2 66B80072 <1> mov ax, 114*256 ; START/STOP PRINTING SWITCH 1202 000014F6 E9EF000000 <1> jmp K57 ; BUFFER_FILL 1203 <1> ; 1204 <1> ;----- SET UP TO TRANSLATE CONTROL SHIFT 1205 <1> K42: ; NOT-KEY-55 1206 000014FB 3C0F <1> cmp al, 15 ; IS IT THE TAB KEY? 1207 000014FD 7414 <1> je short K42B ; YES, XLATE TO FUNCTION CODE 1208 000014FF 3C35 <1> cmp al, 53 ; IS IT THE / KEY? 1209 00001501 750E <1> jne short K42A ; NO, NO MORE SPECIAL CASES 1210 00001503 F6C702 <1> test bh, LC_E0 ; YES, IS IT FROM THE KEY PAD? 1211 00001506 7409 <1> jz short K42A ; NO, JUST TRANSLATE 1212 00001508 66B80095 <1> mov ax, 9500h ; YES, SPECIAL CODE FOR THIS ONE 1213 0000150C E9D9000000 <1> jmp K57 ; BUFFER FILL 1214 <1> K42A: 1215 <1> ;;mov ebx, _K8 ; SET UP TO TRANSLATE CTL 1216 00001511 3C3B <1> cmp al, 59 ; IS IT IN CHARACTER TABLE? 1217 <1> ;jb short K45F ; YES, GO TRANSLATE CHAR 1218 <1> ;;jb K56 ; 20/02/2015 1219 <1> ;;jmp K64 ; 20/02/2015 1220 <1> K42B: 1221 00001513 BB[A0660000] <1> mov ebx, _K8 ; SET UP TO TRANSLATE CTL 1222 <1> ;jb K56 ;; 20/02/2015 1223 <1> ; 12/04/2021 1224 00001518 7267 <1> jb short K45F 1225 0000151A E9B9000000 <1> jmp K64 1226 <1> ; 1227 <1> ;----- NOT IN CONTROL SHIFT 1228 <1> K44: ; NOT-CTL-SHIFT 1229 0000151F 3C37 <1> cmp al, 55 ; PRINT SCREEN KEY? 1230 00001521 7528 <1> jne short K45 ; NOT PRINT SCREEN 1231 00001523 F6C710 <1> test bh, KBX ; IS THIS ENHANCED KEYBOARD? 1232 00001526 7407 <1> jz short K44A ; NO, TEST FOR SHIFT STATE 1233 00001528 F6C702 <1> test bh, LC_E0 ; YES, LAST CODE A MARKER? 1234 0000152B 7507 <1> jnz short K44B ; YES, IS PRINT SCREEN 1235 0000152D EB41 <1> jmp short K45C ; NO, TRANSLATE TO '*' CHARACTER 1236 <1> K44A: 1237 0000152F F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN? 1238 00001532 743C <1> jz short K45C ; NO, TRANSLATE TO '*' CHARACTER 1239 <1> ; 1240 <1> ;----- ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION 1241 <1> K44B: 1242 00001534 B0AE <1> mov al, ENA_KBD ; INSURE KEYBOARD IS ENABLED 1243 00001536 E816010000 <1> call SHIP_IT ; EXECUTE ENABLE 1244 0000153B B020 <1> mov al, EOI ; END OF CURRENT INTERRUPT 1245 0000153D E620 <1> out 20h, al ;out INTA00, al ; SO FURTHER THINGS CAN HAPPEN 1246 <1> ; Print Screen !!! ; ISSUE PRINT SCREEN INTERRUPT (INT 05h) 1247 <1> ;PUSH BP ; SAVE POINTER 1248 <1> ;INT 5H ; ISSUE PRINT SCREEN INTERRUPT 1249 <1> ;POP BP ; RESTORE POINTER 1250 0000153F 8025[AC670000]FC <1> and byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS 1251 00001546 E92EFEFFFF <1> jmp K27 ; GO BACK WITHOUT EOI OCCURRING 1252 <1> ; 1253 <1> ;----- HANDLE IN-CORE KEYS 1254 <1> K45: ; NOT-PRINT-SCREEN 1255 0000154B 3C3A <1> cmp al, 58 ; TEST FOR IN-CORE AREA 1256 0000154D 7734 <1> ja short K46 ; JUMP IF NOT 1257 0000154F 3C35 <1> cmp al, 53 ; IS THIS THE '/' KEY? 1258 00001551 7505 <1> jne short K45A ; NO, JUMP 1259 00001553 F6C702 <1> test bh, LC_E0 ; WAS THE LAST CODE THE MARKER? 1260 00001556 7518 <1> jnz short K45C ; YES, TRANSLATE TO CHARACTER 1261 <1> K45A: 1262 00001558 B91A000000 <1> mov ecx, 26 ; LENGHT OF SEARCH 1263 0000155D BF[76660000] <1> mov edi, K30+10 ; POINT TO TABLE OF A-Z CHARS 1264 00001562 F2AE <1> repne scasb ; IS THIS A LETTER KEY? 1265 <1> ; 20/02/2015 1266 00001564 7505 <1> jne short K45B ; NO, SYMBOL KEY 1267 <1> ; 1268 00001566 F6C340 <1> test bl, CAPS_STATE ; ARE WE IN CAPS_LOCK? 1269 00001569 750C <1> jnz short K45D ; TEST FOR SURE 1270 <1> K45B: 1271 0000156B F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE? 1272 0000156E 750C <1> jnz short K45E ; YES, UPPERCASE 1273 <1> ; NO, LOWERCASE 1274 <1> K45C: 1275 00001570 BB[F8660000] <1> mov ebx, K10 ; TRANSLATE TO LOWERCASE LETTERS 1276 00001575 EB51 <1> jmp short K56 1277 <1> K45D: ; ALMOST-CAPS-STATE 1278 00001577 F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO? 1279 0000157A 75F4 <1> jnz short K45C ; SHIFTED TEMP OUT OF CAPS STATE 1280 <1> K45E: 1281 0000157C BB[50670000] <1> mov ebx, K11 ; TRANSLATE TO UPPER CASE LETTERS 1282 00001581 EB45 <1> K45F: jmp short K56 1283 <1> ; 1284 <1> ;----- TEST FOR KEYS F1 - F10 1285 <1> K46: ; NOT IN-CORE AREA 1286 00001583 3C44 <1> cmp al, 68 ; TEST FOR F1 - F10 1287 <1> ;ja short K47 ; JUMP IF NOT 1288 <1> ;jmp short K53 ; YES, GO DO FN KEY PROCESS 1289 00001585 7635 <1> jna short K53 1290 <1> ; 1291 <1> ;----- HANDLE THE NUMERIC PAD KEYS 1292 <1> K47: ; NOT F1 - F10 1293 00001587 3C53 <1> cmp al, 83 ; TEST NUMPAD KEYS 1294 00001589 772D <1> ja short K52 ; JUMP IF NOT 1295 <1> ; 1296 <1> ;----- KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION 1297 <1> K48: 1298 0000158B 3C4A <1> cmp al, 74 ; SPECIAL CASE FOR MINUS 1299 0000158D 74ED <1> je short K45E ; GO TRANSLATE 1300 0000158F 3C4E <1> cmp al, 78 ; SPECIAL CASE FOR PLUS 1301 00001591 74E9 <1> je short K45E ; GO TRANSLATE 1302 00001593 F6C702 <1> test bh, LC_E0 ; IS THIS ONE OFTHE NEW KEYS? 1303 00001596 750A <1> jnz short K49 ; YES, TRANSLATE TO BASE STATE 1304 <1> ; 1305 00001598 F6C320 <1> test bl, NUM_STATE ; ARE WE IN NUM LOCK 1306 0000159B 7514 <1> jnz short K50 ; TEST FOR SURE 1307 0000159D F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE? 1308 <1> ;jnz short K51 ; IF SHIFTED, REALLY NUM STATE 1309 000015A0 75DA <1> jnz short K45E 1310 <1> ; 1311 <1> ;----- BASE CASE FOR KEYPAD 1312 <1> K49: 1313 000015A2 3C4C <1> cmp al, 76 ; SPECIAL CASE FOR BASE STATE 5 1314 000015A4 7504 <1> jne short K49A ; CONTINUE IF NOT KEYPAD 5 1315 000015A6 B0F0 <1> mov al, 0F0h ; SPECIAL ASCII CODE 1316 000015A8 EB40 <1> jmp short K57 ; BUFFER FILL 1317 <1> K49A: 1318 000015AA BB[F8660000] <1> mov ebx, K10 ; BASE CASE TABLE 1319 000015AF EB27 <1> jmp short K64 ; CONVERT TO PSEUDO SCAN 1320 <1> ; 1321 <1> ;----- MIGHT BE NUM LOCK, TEST SHIFT STATUS 1322 <1> K50: ; ALMOST-NUM-STATE 1323 000015B1 F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT 1324 000015B4 75EC <1> jnz short K49 ; SHIFTED TEMP OUT OF NUM STATE 1325 000015B6 EBC4 <1> K51: jmp short K45E ; REALLY NUM STATE 1326 <1> ; 1327 <1> ;----- TEST FOR THE NEW KEYS ON WT KEYBOARDS 1328 <1> K52: ; NOT A NUMPAD KEY 1329 000015B8 3C56 <1> cmp al, 86 ; IS IT THE NEW WT KEY? 1330 <1> ;jne short K53 ; JUMP IF NOT 1331 <1> ;jmp short K45B ; HANDLE WITH REST OF LETTER KEYS 1332 000015BA 74AF <1> je short K45B 1333 <1> ; 1334 <1> ;----- MUST BE F11 OR F12 1335 <1> K53: ; F1 - F10 COME HERE, TOO 1336 000015BC F6C303 <1> test bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE 1337 000015BF 74E1 <1> jz short K49 ; JUMP, LOWER CASE PSEUDO SC'S 1338 <1> ; 20/02/2015 1339 000015C1 BB[50670000] <1> mov ebx, K11 ; UPPER CASE PSEUDO SCAN CODES 1340 000015C6 EB10 <1> jmp short K64 ; TRANSLATE SCAN 1341 <1> ; 1342 <1> ;----- TRANSLATE THE CHARACTER 1343 <1> K56: ; TRANSLATE-CHAR 1344 000015C8 FEC8 <1> dec al ; CONVERT ORIGIN 1345 000015CA D7 <1> xlat ; CONVERT THE SCAN CODE TO ASCII 1346 000015CB F605[AC670000]02 <1> test byte [KB_FLAG_3], LC_E0 ; IS THIS A NEW KEY? 1347 000015D2 7416 <1> jz short K57 ; NO, GO FILL BUFFER 1348 000015D4 B4E0 <1> mov ah, MC_E0 ; YES, PUT SPECIAL MARKER IN AH 1349 000015D6 EB12 <1> jmp short K57 ; PUT IT INTO THE BUFFER 1350 <1> ; 1351 <1> ;----- TRANSLATE SCAN FOR PSEUDO SCAN CODES 1352 <1> K64: ; TRANSLATE-SCAN-ORGD 1353 000015D8 FEC8 <1> dec al ; CONVERT ORIGIN 1354 000015DA D7 <1> xlat ; CTL TABLE SCAN 1355 000015DB 88C4 <1> mov ah, al ; PUT VALUE INTO AH 1356 000015DD B000 <1> mov al, 0 ; ZERO ASCII CODE 1357 000015DF F605[AC670000]02 <1> test byte [KB_FLAG_3], LC_E0 ; IS THIS A NEW KEY? 1358 000015E6 7402 <1> jz short K57 ; NO, GO FILL BUFFER 1359 000015E8 B0E0 <1> mov al, MC_E0 ; YES, PUT SPECIAL MARKER IN AL 1360 <1> ; 1361 <1> ;----- PUT CHARACTER INTO BUFFER 1362 <1> K57: ; BUFFER_FILL 1363 000015EA 3CFF <1> cmp al, -1 ; IS THIS AN IGNORE CHAR 1364 000015EC 7405 <1> je short K59 ; YES, DO NOTHING WITH IT 1365 <1> ;je K26 ; YES, DO NOTHING WITH IT 1366 000015EE 80FCFF <1> cmp ah, -1 ; LOOK FOR -1 PSEUDO SCAN 1367 <1> ;;jne short K61 ; NEAR_INTERRUPT_RETURN 1368 <1> ;je K26 ; INTERRUPT_RETURN 1369 <1> ; 12/04/2021 1370 000015F1 7505 <1> jne short _K60 ; NEAR_INTERRUPT_RETURN 1371 <1> K59: ; NEAR_INTERRUPT_RETURN 1372 000015F3 E975FDFFFF <1> jmp K26 ; INTERRUPT_RETURN 1373 <1> 1374 <1> _K60: ; 29/01/2016 1375 000015F8 80FC68 <1> cmp ah, 68h ; ALT + F1 key 1376 000015FB 721D <1> jb short K61 1377 000015FD 80FC6F <1> cmp ah, 6Fh ; ALT + F8 key 1378 00001600 7718 <1> ja short K61 1379 <1> ; 1380 00001602 8A1D[EE7C0100] <1> mov bl, [ACTIVE_PAGE] 1381 00001608 80C368 <1> add bl, 68h 1382 0000160B 38E3 <1> cmp bl, ah 1383 0000160D 740B <1> je short K61 1384 <1> ; 24/07/2022 1385 <1> ;push ax 1386 0000160F 50 <1> push eax 1387 00001610 88E0 <1> mov al, ah 1388 00001612 2C68 <1> sub al, 68h 1389 00001614 E850090000 <1> call set_active_page 1390 00001619 58 <1> pop eax 1391 <1> ;pop ax 1392 <1> K61: ; NOT-CAPS-STATE 1393 0000161A 8B1D[BA670000] <1> mov ebx, [BUFFER_TAIL] ; GET THE END POINTER TO THE BUFFER 1394 00001620 89DE <1> mov esi, ebx ; SAVE THE VALUE 1395 00001622 E8B5FAFFFF <1> call _K4 ; ADVANCE THE TAIL 1396 00001627 3B1D[B6670000] <1> cmp ebx, [BUFFER_HEAD] ; HAS THE BUFFER WRAPPED AROUND 1397 0000162D 740E <1> je short K62 ; BUFFER_FULL_BEEP 1398 0000162F 668906 <1> mov [esi], ax ; STORE THE VALUE 1399 00001632 891D[BA670000] <1> mov [BUFFER_TAIL], ebx ; MOVE THE POINTER UP 1400 00001638 E930FDFFFF <1> jmp K26 1401 <1> ;;cli ; TURN OFF INTERRUPTS 1402 <1> ;;mov al, EOI ; END OF INTERRUPT COMMAND 1403 <1> ;;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT 1404 <1> ;mov al, ENA_KBD ; INSURE KEYBOARD IS ENABLED 1405 <1> ;call SHIP_IT ; EXECUTE ENABLE 1406 <1> ;mov ax, 9102h ; MOVE IN POST CODE & TYPE 1407 <1> ;int 15h ; PERFORM OTHER FUNCTION 1408 <1> ;;and byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG 1409 <1> ;jmp K27A ; INTERRUPT_RETURN 1410 <1> ;;jmp K27 1411 <1> ; 1412 <1> ;----- BUFFER IS FULL SOUND THE BEEPER 1413 <1> K62: 1414 0000163D B020 <1> mov al, EOI ; ENABLE INTERRUPT CONTROLLER CHIP 1415 0000163F E620 <1> out INTA00, al 1416 00001641 66B9A602 <1> mov cx, 678 ; DIVISOR FOR 1760 HZ 1417 00001645 B304 <1> mov bl, 4 ; SHORT BEEP COUNT (1/16 + 1/64 DELAY) 1418 00001647 E8420D0000 <1> call beep ; GO TO COMMON BEEP HANDLER 1419 0000164C E928FDFFFF <1> jmp K27 ; EXIT 1420 <1> 1421 <1> SHIP_IT: 1422 <1> ;--------------------------------------------------------------------------------- 1423 <1> ; SHIP_IT 1424 <1> ; THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES 1425 <1> ; TO THE KEYBOARD CONTROLLER. 1426 <1> ;--------------------------------------------------------------------------------- 1427 <1> ; 1428 <1> 1429 <1> ;push ax ; SAVE DATA TO SEND 1430 <1> ; 12/04/2021 1431 00001651 50 <1> push eax 1432 <1> 1433 <1> ;----- WAIT FOR COMMAND TO ACCEPTED 1434 00001652 FA <1> cli ; DISABLE INTERRUPTS TILL DATA SENT 1435 <1> ; xor ecx, ecx ; CLEAR TIMEOUT COUNTER 1436 00001653 B900000100 <1> mov ecx, 10000h 1437 <1> S10: 1438 00001658 E464 <1> in al, STATUS_PORT ; READ KEYBOARD CONTROLLER STATUS 1439 0000165A A802 <1> test al, INPT_BUF_FULL ; CHECK FOR ITS INPUT BUFFER BUSY 1440 0000165C E0FA <1> loopnz S10 ; WAIT FOR COMMAND TO BE ACCEPTED 1441 <1> 1442 <1> ;pop ax ; GET DATA TO SEND 1443 <1> ; 12/04/2021 1444 0000165E 58 <1> pop eax 1445 <1> 1446 0000165F E664 <1> out STATUS_PORT, al ; SEND TO KEYBOARD CONTROLLER 1447 00001661 FB <1> sti ; ENABLE INTERRUPTS AGAIN 1448 00001662 C3 <1> retn ; RETURN TO CALLER 1449 <1> 1450 <1> ; 12/04/2021 (32 bit push/pop) 1451 <1> SND_DATA: 1452 <1> ; --------------------------------------------------------------------------------- 1453 <1> ; SND_DATA 1454 <1> ; THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES 1455 <1> ; TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO 1456 <1> ; HANDLES ANY RETRIES IF REQUIRED 1457 <1> ; --------------------------------------------------------------------------------- 1458 <1> ; 1459 00001663 50 <1> push eax ; push ax ; SAVE REGISTERS 1460 00001664 53 <1> push ebx ; push bx 1461 00001665 51 <1> push ecx 1462 00001666 88C7 <1> mov bh, al ; SAVE TRANSMITTED BYTE FOR RETRIES 1463 00001668 B303 <1> mov bl, 3 ; LOAD RETRY COUNT 1464 <1> SD0: 1465 0000166A FA <1> cli ; DISABLE INTERRUPTS 1466 0000166B 8025[AB670000]CF <1> and byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS 1467 <1> ; 1468 <1> ;----- WAIT FOR COMMAND TO BE ACCEPTED 1469 00001672 B900000100 <1> mov ecx, 10000h ; MAXIMUM WAIT COUNT 1470 <1> SD5: 1471 00001677 E464 <1> in al, STATUS_PORT ; READ KEYBOARD PROCESSOR STATUS PORT 1472 00001679 A802 <1> test al, INPT_BUF_FULL ; CHECK FOR ANY PENDING COMMAND 1473 0000167B E0FA <1> loopnz SD5 ; WAIT FOR COMMAND TO BE ACCEPTED 1474 <1> ; 1475 0000167D 88F8 <1> mov al, bh ; REESTABLISH BYTE TO TRANSMIT 1476 0000167F E660 <1> out PORT_A, al ; SEND BYTE 1477 00001681 FB <1> sti ; ENABLE INTERRUPTS 1478 <1> ;mov cx, 01A00h ; LOAD COUNT FOR 10 ms+ 1479 00001682 B9FFFF0000 <1> mov ecx, 0FFFFh 1480 <1> SD1: 1481 00001687 F605[AB670000]30 <1> test byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET 1482 0000168E 750F <1> jnz short SD3 ; IF SET, SOMETHING RECEIVED GO PROCESS 1483 00001690 E2F5 <1> loop SD1 ; OTHERWISE WAIT 1484 <1> SD2: 1485 00001692 FECB <1> dec bl ; DECREMENT RETRY COUNT 1486 00001694 75D4 <1> jnz short SD0 ; RETRY TRANSMISSION 1487 00001696 800D[AB670000]80 <1> or byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG 1488 0000169D EB09 <1> jmp short SD4 ; RETRIES EXHAUSTED FORGET TRANSMISSION 1489 <1> SD3: 1490 0000169F F605[AB670000]10 <1> test byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE 1491 000016A6 74EA <1> jz short SD2 ; IF NOT, GO RESEND 1492 <1> SD4: 1493 000016A8 59 <1> pop ecx ; RESTORE REGISTERS 1494 000016A9 5B <1> pop ebx ; pop bx 1495 000016AA 58 <1> pop eax ; pop ax 1496 000016AB C3 <1> retn ; RETURN, GOOD TRANSMISSION 1497 <1> 1498 <1> SND_LED: 1499 <1> ; --------------------------------------------------------------------------------- 1500 <1> ; SND_LED 1501 <1> ; THIS ROUTINES TURNS ON THE MODE INDICATORS. 1502 <1> ; 1503 <1> ;---------------------------------------------------------------------------------- 1504 <1> ; 1505 000016AC FA <1> cli ; TURN OFF INTERRUPTS 1506 000016AD F605[AB670000]40 <1> test byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE 1507 000016B4 755F <1> jnz short SL1 ; DON'T UPDATE AGAIN IF UPDATE UNDERWAY 1508 <1> ; 1509 000016B6 800D[AB670000]40 <1> or byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS 1510 000016BD B020 <1> mov al, EOI ; END OF INTERRUPT COMMAND 1511 000016BF E620 <1> out 20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT 1512 000016C1 EB11 <1> jmp short SL0 ; GO SEND MODE INDICATOR COMMAND 1513 <1> SND_LED1: 1514 000016C3 FA <1> cli ; TURN OFF INTERRUPTS 1515 000016C4 F605[AB670000]40 <1> test byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE 1516 000016CB 7548 <1> jnz short SL1 ; DON'T UPDATE AGAIN IF UPDATE UNDERWAY 1517 <1> ; 1518 000016CD 800D[AB670000]40 <1> or byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS 1519 <1> SL0: 1520 000016D4 B0ED <1> mov al, LED_CMD ; LED CMD BYTE 1521 000016D6 E888FFFFFF <1> call SND_DATA ; SEND DATA TO KEYBOARD 1522 000016DB FA <1> cli 1523 000016DC E836000000 <1> call MAKE_LED ; GO FORM INDICATOR DATA BYTE 1524 000016E1 8025[AB670000]F8 <1> and byte [KB_FLAG_2], 0F8h ; ~KB_LEDS ; CLEAR MODE INDICATOR BITS 1525 000016E8 0805[AB670000] <1> or [KB_FLAG_2], al ; SAVE PRESENT INDICATORS FOR NEXT TIME 1526 000016EE F605[AB670000]80 <1> test byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED 1527 000016F5 750F <1> jnz short SL2 ; IF SO, BYPASS SECOND BYTE TRANSMISSION 1528 <1> ; 1529 000016F7 E867FFFFFF <1> call SND_DATA ; SEND DATA TO KEYBOARD 1530 000016FC FA <1> cli ; TURN OFF INTERRUPTS 1531 000016FD F605[AB670000]80 <1> test byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED 1532 00001704 7408 <1> jz short SL3 ; IF NOT, DON'T SEND AN ENABLE COMMAND 1533 <1> SL2: 1534 00001706 B0F4 <1> mov al, KB_ENABLE ; GET KEYBOARD CSA ENABLE COMMAND 1535 00001708 E856FFFFFF <1> call SND_DATA ; SEND DATA TO KEYBOARD 1536 0000170D FA <1> cli ; TURN OFF INTERRUPTS 1537 <1> SL3: 1538 0000170E 8025[AB670000]3F <1> and byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR 1539 <1> SL1: ; UPDATE AND TRANSMIT ERROR FLAG 1540 00001715 FB <1> sti ; ENABLE INTERRUPTS 1541 00001716 C3 <1> retn ; RETURN TO CALLER 1542 <1> 1543 <1> MAKE_LED: 1544 <1> ;--------------------------------------------------------------------------------- 1545 <1> ; MAKE_LED 1546 <1> ; THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF 1547 <1> ; THE MODE INDICATORS. 1548 <1> ;--------------------------------------------------------------------------------- 1549 <1> ; 1550 <1> ;push cx ; SAVE CX 1551 00001717 A0[A9670000] <1> mov al, [KB_FLAG] ; GET CAPS & NUM LOCK INDICATORS 1552 0000171C 2470 <1> and al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS 1553 <1> ;mov cl, 4 ; SHIFT COUNT 1554 <1> ;rol al, cl ; SHIFT BITS OVER TO TURN ON INDICATORS 1555 0000171E C0C004 <1> rol al, 4 ; 20/02/2015 1556 00001721 2407 <1> and al, 07h ; MAKE SURE ONLY MODE BITS ON 1557 <1> ;pop cx 1558 00001723 C3 <1> retn ; RETURN TO CALLER 1559 <1> 1560 <1> ; % include 'kybdata.s' ; KEYBOARD DATA 1561 <1> 1562 <1> 1563 <1> ; /// End Of KEYBOARD FUNCTIONS /// 2987 2988 %include 'video.s' ; 07/03/2015 1 <1> ; **************************************************************************** 2 <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.7 - video.s 3 <1> ; ---------------------------------------------------------------------------- 4 <1> ; Last Update: 29/11/2023 (Previous: 07/08/2022 - Kernel v2.0.5) 5 <1> ; ---------------------------------------------------------------------------- 6 <1> ; Beginning: 16/01/2016 7 <1> ; ---------------------------------------------------------------------------- 8 <1> ; Assembler: NASM version 2.15 (trdos386.s) 9 <1> ; ---------------------------------------------------------------------------- 10 <1> ; Turkish Rational DOS 11 <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016) 12 <1> ; 13 <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan 14 <1> ; video.inc (13/08/2015) 15 <1> ; 16 <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 17 <1> ; **************************************************************************** 18 <1> 19 <1> ; Retro UNIX 386 v1 Kernel - VIDEO.INC 20 <1> ; Last Modification: 13/08/2015 21 <1> ; (Video Data is in 'VIDATA.INC') 22 <1> ; 23 <1> ; ///////// VIDEO (CGA) FUNCTIONS /////////////// 24 <1> 25 <1> ; 16/01/2016 (32 bit modifications, TRDOS386 - TRDOS v2.0, video.s) 26 <1> ; INT 31H (TRDOS 386) = INT 10H (IBM PC/AT REAL MODE) 27 <1> 28 <1> ; IBM PC-AT BIOS Source Code 29 <1> ; TITLE VIDEO1 --- 06/10/85 VIDEO DISPLAY BIOS 30 <1> 31 <1> _int10h: 32 <1> ; 23/03/2016 33 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 34 00001724 9C <1> pushfd 35 00001725 0E <1> push cs 36 00001726 E851000000 <1> call VIDEO_IO_1 37 0000172B C3 <1> retn 38 <1> 39 <1> ;--- INT 10 H ------------------------------------------------------------------- 40 <1> ; VIDEO_IO : 41 <1> ; THESE ROUTINES PROVIDE THE CRT DISPLAY INTERFACE : 42 <1> ; THE FOLLOWING FUNCTIONS ARE PROVIDED: : 43 <1> ; : 44 <1> ; (AH)= 00H SET MODE (AL) CONTAINS MODE VALUE : 45 <1> ; (AL) = 00H 40X25 BW MODE (POWER ON DEFAULT) : 46 <1> ; (AL) = 01H 40X25 COLOR : 47 <1> ; (AL) = 02H 80X25 BW : 48 <1> ; (AL) = 03H 80X25 COLOR : 49 <1> ; GRAPHICS MODES : 50 <1> ; (AL) = 04H 320X200 COLOR : 51 <1> ; (AL) = 05H 320X200 BW MODE : 52 <1> ; (AL) = 06H 640X200 BW MODE : 53 <1> ; (AL) = 07H 80X25 MONOCHROME (USED INTERNAL TO VIDEO ONLY) : 54 <1> ; *** NOTES -BW MODES OPERATE SAME AS COLOR MODES, BUT COLOR : 55 <1> ; BURST IS NOT ENABLED : 56 <1> ; -CURSOR IS NOT DISPLAYED IN GRAPHICS MODE : 57 <1> ; (AH)= 01H SET CURSOR TYPE : 58 <1> ; (CH) = BITS 4-0 = START LINE FOR CURSOR : 59 <1> ; ** HARDWARE WILL ALWAYS CAUSE BLINK : 60 <1> ; ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING : 61 <1> ; OR NO CURSOR AT ALL : 62 <1> ; (CL) = BITS 4-0 = END LINE FOR CURSOR : 63 <1> ; (AH)= 02H SET CURSOR POSITION : 64 <1> ; (DH,DL) = ROW,COLUMN (00H,00H) IS UPPER LEFT : 65 <1> ; (BH) = A PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES) : 66 <1> ; (AH)= 03H READ CURSOR POSITION : 67 <1> ; (BH) = PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES) : 68 <1> ; ON EXIT (DH,DL) = ROW,COLUMN OF CURRENT CURSOR : 69 <1> ; (CH,CL) = CURSOR MODE CURRENTLY SET : 70 <1> ; (AH)= 04H READ LIGHT PEN POSITION : 71 <1> ; ON EXIT: : 72 <1> ; (AH) = 00H -- LIGHT PEN SWITCH NOT DOWN/NOT TRIGGERED : 73 <1> ; (AH) = 01H -- VALID LIGHT PEN VALUE IN REGISTERS : 74 <1> ; (DH,DL) = ROW,COLUMN OF CHARACTER LP POSITION : 75 <1> ; (CH) = RASTER LINE (0-199) : 76 <1> ; (BX) = PIXEL COLUMN (0-319,639) : 77 <1> ; (AH)= 05H SELECT ACTIVE DISPLAY PAGE (VALID ONLY FOR ALPHA MODES) : 78 <1> ; (AL) = NEW PAGE VALUE (0-7 FOR MODES 0&1, 0-3 FOR MODES 2&3) : 79 <1> ; (AH)= 06H SCROLL ACTIVE PAGE UP : 80 <1> ; (AL) = NUMBER OF LINES. ( LINES BLANKED AT BOTTOM OF WINDOW ) : 81 <1> ; (AL) = 00H MEANS BLANK ENTIRE WINDOW : 82 <1> ; (CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL : 83 <1> ; (DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL : 84 <1> ; (BH) = ATTRIBUTE TO BE USED ON BLANK LINE : 85 <1> ; (AH)= 07H SCROLL ACTIVE PAGE DOWN : 86 <1> ; (AL) = NUMBER OF LINES, INPUT LINES BLANKED AT TOP OF WINDOW : 87 <1> ; (AL) = 00H MEANS BLANK ENTIRE WINDOW : 88 <1> ; (CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL : 89 <1> ; (DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL : 90 <1> ; (BH) = ATTRIBUTE TO BE USED ON BLANK LINE : 91 <1> ; : 92 <1> ; CHARACTER HANDLING ROUTINES : 93 <1> ; : 94 <1> ; (AH)= 08H READ ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION : 95 <1> ; (BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY) : 96 <1> ; ON EXIT: : 97 <1> ; (AL) = CHAR READ : 98 <1> ; (AH) = ATTRIBUTE OF CHARACTER READ (ALPHA MODES ONLY) : 99 <1> ; (AH)= 09H WRITE ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION : 100 <1> ; (BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY) : 101 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE : 102 <1> ; (AL) = CHAR TO WRITE : 103 <1> ; (BL) = ATTRIBUTE OF CHARACTER (ALPHA)/COLOR OF CHAR (GRAPHICS) : 104 <1> ; SEE NOTE ON WRITE DOT FOR BIT 7 OF BL = 1. : 105 <1> ; (AH) = 0AH WRITE CHARACTER ONLY AT CURRENT CURSOR POSITION : 106 <1> ; (BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY) : 107 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE : 108 <1> ; (AL) = CHAR TO WRITE : 109 <1> ; NOTE: USE FUNCTION (AH)= 09H IN GRAPHICS MODES : 110 <1> ; FOR READ/WRITE CHARACTER INTERFACE WHILE IN GRAPHICS MODE, THE : 111 <1> ; CHARACTERS ARE FORMED FROM A CHARACTER GENERATOR IMAGE : 112 <1> ; MAINTAINED IN THE SYSTEM ROM. ONLY THE 1ST 128 CHARS : 113 <1> ; ARE CONTAINED THERE. TO READ/WRITE THE SECOND 128 CHARS, : 114 <1> ; THE USER MUST INITIALIZE THE POINTER AT INTERRUPT 1FH : 115 <1> ; (LOCATION 0007CH) TO POINT TO THE 1K BYTE TABLE CONTAINING : 116 <1> ; THE CODE POINTS FOR THE SECOND 128 CHARS (128-255). : 117 <1> ; FOR WRITE CHARACTER INTERFACE IN GRAPHICS MODE, THE REPLICATION FACTOR : 118 <1> ; CONTAINED IN (CX) ON ENTRY WILL PRODUCE VALID RESULTS ONLY : 119 <1> ; FOR CHARACTERS CONTAINED ON THE SAME ROW. CONTINUATION TO : 120 <1> ; SUCCEEDING LINES WILL NOT PRODUCE CORRECTLY. : 121 <1> ; : 122 <1> ; GRAPHICS INTERFACE : 123 <1> ; (AH)= 0BH SET COLOR PALETTE : 124 <1> ; (BH) = PALETTE COLOR ID BEING SET (0-127) : 125 <1> ; (BL) = COLOR VALUE TO BE USED WITH THAT COLOR ID : 126 <1> ; NOTE: FOR THE CURRENT COLOR CARD, THIS ENTRY POINT HAS : 127 <1> ; MEANING ONLY FOR 320X200 GRAPHICS. : 128 <1> ; COLOR ID = 0 SELECTS THE BACKGROUND COLOR (0-15) : 129 <1> ; COLOR ID = 1 SELECTS THE PALETTE TO BE USED: : 130 <1> ; 0 = GREEN(1)/RED(2)/YELLOW(3) : 131 <1> ; 1 = CYAN(1)/MAGENTA(2)/WHITE(3) : 132 <1> ; IN 40X25 OR 80X25 ALPHA MODES, THE VALUE SET FOR : 133 <1> ; PALETTE COLOR 0 INDICATES THE BORDER COLOR : 134 <1> ; TO BE USED (VALUES 0-31, WHERE 16-31 SELECT : 135 <1> ; THE HIGH INTENSITY BACKGROUND SET. : 136 <1> ; (AH)= 0CH WRITE DOT : 137 <1> ; (DX) = ROW NUMBER : 138 <1> ; (CX) = COLUMN NUMBER : 139 <1> ; (AL) = COLOR VALUE : 140 <1> ; IF BIT 7 OF AL = 1, THEN THE COLOR VALUE IS EXCLUSIVE : 141 <1> ; ORed WITH THE CURRENT CONTENTS OF THE DOT : 142 <1> ; (AH)= ODH READ DOT : 143 <1> ; (DX) = ROW NUMBER : 144 <1> ; (CX) = COLUMN NUMBER : 145 <1> ; (AL) = RETURNS THE DOT READ : 146 <1> ; : 147 <1> ; ASCII TELETYPE ROUTINE FOR OUTPUT : 148 <1> ; : 149 <1> ; (AH)= 0EH WRITE TELETYPE TO ACTIVE PAGE : 150 <1> ; (AL) = CHAR TO WRITE : 151 <1> ; (BL) = FOREGROUND COLOR IN GRAPHICS MODE : 152 <1> ; NOTE -- SCREEN WIDTH IS CONTROLLED BY PREVIOUS MODE SET : 153 <1> ; (AH)= 0FH CURRENT VIDEO STATE : 154 <1> ; RETURNS THE CURRENT VIDEO STATE : 155 <1> ; (AL) = MODE CURRENTLY SET ( SEE (AH)=00H FOR EXPLANATION) : 156 <1> ; (AH) = NUMBER OR CHARACTER COLUMNS ON SCREEN : 157 <1> ; (BH) = CURRENT ACTIVE DISPLAY PAGE : 158 <1> ; (AH)= 10H RESERVED : 159 <1> ; (AH)= 11H RESERVED : 160 <1> ; (AH)= 12H RESERVED : 161 <1> ; (AH)= 13H WRITE STRING : 162 <1> ; ES:BP - POINTER T0 STRING TO BE WRITTEN : 163 <1> ; CX - LENGTH OF CHARACTER STRING TO WRITTEN : 164 <1> ; DX - CURSOR POSITION FOR STRING TO BE WRITTEN : 165 <1> ; BH - PAGE NUMBER : 166 <1> ; (AL)= 00H WRITE CHARACTER STRING : 167 <1> ; BL - ATTRIBUTE : 168 <1> ; STRING IS : 169 <1> ; CURSOR NOT MOVED : 170 <1> ; (AL)= 01H WRITE CHARACTER STRING AND MOVE CURSOR : 171 <1> ; BL - ATTRIBUTE : 172 <1> ; STRING IS : 173 <1> ; CURSOR MOVED : 174 <1> ; (AL)= 02H WRITE CHARACTER AND ATTRIBUTE STRING : 175 <1> ; (VALID FOR ALPHA MODES ONLY) : 176 <1> ; STRING IS : 177 <1> ; CURSOR IS NOT MOVED : 178 <1> ; (AL)= 03H WRITE CHARACTER AND ATTRIBUTE STRING AND MOVE CURSOR : 179 <1> ; (VALID FOR ALPHA MODES ONLY) : 180 <1> ; STRING IS : 181 <1> ; CURSOR IS MOVED : 182 <1> ; NOTE: CARRIAGE RETURN, LINE FEED, BACKSPACE, AND BELL ARE : 183 <1> ; TREATED AS COMMANDS RATHER THAN PRINTABLE CHARACTERS. : 184 <1> ; : 185 <1> ; BX,CX,DX,SI,DI,BP,SP,DS,ES,SS PRESERVED DURING CALLS EXCEPT FOR : 186 <1> ; BX,CX,DX RETURN VALUES ON FUNCTIONS 03H,04H,0DH AND 0FH. ON ALL CALLS : 187 <1> ; AX IS MODIFIED. : 188 <1> ;-------------------------------------------------------------------------------- 189 <1> 190 0000172C [FD1A0000] <1> M1: dd SET_MODE ; TABLE OF ROUTINES WITHIN VIDEO I/O 191 00001730 [B31E0000] <1> dd SET_CTYPE 192 00001734 [E11E0000] <1> dd SET_CPOS 193 00001738 [051F0000] <1> dd READ_CURSOR 194 <1> ;dd VIDEO_RETURN ; READ_LPEN 195 0000173C [FB1A0000] <1> dd set_mode_ncm ; Set mode without clearing video memory 196 00001740 [4B1F0000] <1> dd ACT_DISP_PAGE 197 00001744 [D51F0000] <1> dd SCROLL_UP 198 00001748 [EC200000] <1> dd SCROLL_DOWN 199 0000174C [6B210000] <1> dd READ_AC_CURRENT 200 00001750 [C8210000] <1> dd WRITE_AC_CURRENT 201 00001754 [EE210000] <1> dd WRITE_C_CURRENT 202 00001758 [F62A0000] <1> dd SET_COLOR 203 0000175C [5E2B0000] <1> dd WRITE_DOT 204 00001760 [2D2B0000] <1> dd READ_DOT 205 00001764 [78220000] <1> dd WRITE_TTY 206 00001768 [E31A0000] <1> dd VIDEO_STATE 207 0000176C [2B360000] <1> dd vga_pal_funcs ; 10/08/2016 (TRDOS 386) 208 00001770 [43300000] <1> dd font_setup ; 10/07/2016 (TRDOS 386) 209 00001774 [321B0000] <1> dd VIDEO_RETURN ; RESERVED 210 00001778 [EE230000] <1> dd WRITE_STRING ; 23/06/2016 (TRDOS 386) 211 <1> M1L EQU $ - M1 212 <1> 213 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 214 <1> ; [VESA VBE3-PMI functions] 215 <1> ; (fixing page table problems for LFB/PMI for >2.5GB main memory) 216 <1> ; ((Addresses of kernel page tables and PMI videobios address 217 <1> ; must be < 4MB or cr3 register must contain kernel's page dir 218 <1> ; during video interrupt. Save-change-restore cr3 register 219 <1> ; content here is a bugfix method to prevent page faults 220 <1> ; for -real- computers with >2.5GB main memory.)) 221 <1> ; {INT 31h was not changing cr3 while it contains user's 222 <1> ; page directory addr and accessing beyond of the 1st 4MB was 223 <1> ; causing to page faults.. because, after the 1st 4MB, user's 224 <1> ; page tables contain non-linear/virtual memory pages.} 225 <1> ; 226 <1> ; 02/08/2022 - TRDOS 386 v2.0.5 227 <1> ; 06/12/2020 228 <1> ; 05/12/2020 229 <1> ; 03/12/2020 230 <1> ; 27/11/2020 - TRDOS 386 v2.0.3 231 <1> ; 14/01/2017 232 <1> ; 02/01/2017 233 <1> ; 04/07/2016 234 <1> ; 12/05/2016 235 <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 236 <1> int31h: ; Video BIOS 237 <1> 238 <1> ; BH = Video page number 239 <1> ; BL = Color/Attribute 240 <1> ; AH = Function number 241 <1> ; AL = Character 242 <1> 243 <1> VIDEO_IO_1: 244 <1> ;sti ; INTERRUPTS BACK ON 245 0000177C FC <1> cld ; SET DIRECTION FORWARD 246 <1> 247 <1> ;cmp ah, M1L/4 ; TEST FOR WITHIN TABLE RANGE 248 <1> ;jnb short M4 ; BRANCH TO EXIT IF NOT A VALID COMMAND 249 <1> 250 <1> ; 26/11/2020 251 0000177D 80FC14 <1> cmp ah, M1L/4 252 00001780 7205 <1> jb short VGA_func 253 <1> 254 00001782 80FC4F <1> cmp ah, 4Fh 255 00001785 7532 <1> jne short M4 ; invalid ! 256 <1> 257 <1> VGA_func: ; 26/11/2020 258 00001787 06 <1> push es ; * 259 00001788 1E <1> push ds ; ** ; SAVE WORK AND PARAMETER REGISTERS 260 <1> 261 <1> ; 26/11/2020 262 00001789 50 <1> push eax ; - 263 <1> 264 0000178A 66B81000 <1> mov ax, KDATA ; POINT DS: TO DATA SEGMENT 265 0000178E 8ED8 <1> mov ds, ax 266 00001790 8EC0 <1> mov es, ax 267 <1> 268 <1> ; 26/11/2020 269 00001792 58 <1> pop eax ; + 270 <1> ; 271 00001793 FB <1> sti 272 00001794 80FC4F <1> cmp ah, 4Fh 273 00001797 747A <1> je short VBE_func 274 <1> 275 <1> ; 04/12/2020 276 00001799 A3[44890100] <1> mov [video_eax], eax 277 <1> 278 <1> ; 21/12/2020 279 0000179E 803D[DE670000]FF <1> cmp byte [CRT_MODE], 0FFh ; Current mode is a VESA VBE mode ? 280 000017A5 7213 <1> jb short VGA_func_std 281 <1> 282 000017A7 08E4 <1> or ah, ah ; set mode ? 283 000017A9 750F <1> jnz short VGA_func_std ; no 284 <1> 285 000017AB 803D[86090000]03 <1> cmp byte [vbe3], 3 ; (real) VESA VBE 3 video bios ? 286 000017B2 7506 <1> jne short VGA_func_std ; no 287 <1> 288 000017B4 E995010000 <1> jmp vesa_vbe3_pmi 289 <1> 290 <1> ; 21/12/2020 291 <1> M4: ; COMMAND NOT VALID 292 000017B9 CF <1> iretd ; DO NOTHING IF NOT IN VALID RANGE 293 <1> 294 <1> VGA_func_std: 295 <1> ; 06/12/2020 296 <1> ; 03/12/2020 297 000017BA 80FC0F <1> cmp ah, 0Fh 298 000017BD 773D <1> ja short VGA_funcs_0 ; only CGA funcs will be handled by 299 <1> ; 06/12/2020 ; vga bios firmware 300 <1> ; 03/12/2020 301 <1> ;test ah, 7Fh ; set mode ? 302 <1> ;;or ah, ah ; only 'set mode' will be handled by 303 <1> ;jnz short VGA_funcs_0 ; vga bios firmware 304 <1> ;jz short vbe_pmi32_0 305 <1> 306 <1> ; 28/11/2020 307 000017BF 803D[2CA30100]00 <1> cmp byte [pmi32], 0 ; 32 bit protected mode interface for 308 000017C6 7634 <1> jna short VGA_funcs_0 ; video hardware's vga bios firmware 309 <1> ; ([pmi32] > 0 if it is activated) 310 <1> ; note: 311 <1> ; [vbe3] = 3 is required to activate 312 <1> ; 07/12/2020 313 000017C8 20E4 <1> and ah, ah ; is this set mode ? 314 000017CA 7413 <1> jz short vbe_pmi32_2 ; yes 315 <1> 316 000017CC 80FC04 <1> cmp ah, 04h ; set mode ('no clear memory' option) 317 000017CF 742B <1> je short VGA_funcs_0 318 <1> 319 <1> ; 07/12/2020 320 000017D1 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; current mode > 7 ? 321 000017D8 7622 <1> jna short VGA_funcs_0 ; no 322 <1> 323 <1> ; when mode 3 is active, 324 <1> ; video bios functions are not redirected 325 <1> ; to VESA VBE3 PMI except 'set mode' function 326 <1> 327 <1> vbe_pmi32_0: 328 <1> ; 06/12/2020 329 <1> ;or ah, ah 330 <1> ;jnz short vbe_pmi32_2 331 <1> ; ah = 0 ; 'set mode' 332 <1> ;cmp al, 3 ; 80x25 text mode, 16 colors, default mode for MainProg 333 <1> ;jne short vbe_pmi32_1 334 <1> ;cmp byte [CRT_MODE], 3 ; If current video mode <> 3 and requested 335 <1> ; ; video mode is 3, use internal 'set mode'; 336 <1> ; ; otherwise, use vesa vbe 3 bios's 'set mode'. 337 <1> ;jne short VGA_funcs_0 338 <1> vbe_pmi32_1: 339 000017DA E96F010000 <1> jmp vesa_vbe3_pmi 340 <1> ;vbe_pmi32_2: 341 <1> ;cmp ah, 04h ; set mode (no clear mem option) 342 <1> ;jne short vbe_pmi32_1 343 <1> 344 <1> vbe_pmi32_2: 345 <1> ; 07/12/2020 346 000017DF 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; current mode > 7 ? 347 000017E6 77F2 <1> ja short vbe_pmi32_1 ; yes 348 <1> 349 000017E8 3C07 <1> cmp al, 7 ; requested mode > 7 ? 350 000017EA 7610 <1> jna short VGA_funcs_0 ; no (CGA) 351 <1> 352 000017EC 3C13 <1> cmp al, 13h 353 000017EE 76EA <1> jna short vbe_pmi32_1 354 <1> 355 000017F0 A880 <1> test al, 80h 356 000017F2 7408 <1> jz short VGA_funcs_0 ; unknown or special 357 <1> 358 000017F4 3C87 <1> cmp al, 87h ; requested mode > 7 ? 359 <1> ; (with no clear mem ops) 360 000017F6 7604 <1> jna short VGA_funcs_0 ; no (CGA) 361 <1> 362 000017F8 3C93 <1> cmp al, 93h 363 000017FA 76DE <1> jna short vbe_pmi32_1 364 <1> 365 <1> ; > 13h video modes are unknown or special 366 <1> ; they must be handled by kernel 367 <1> 368 <1> ; CGA video modes will be handled by kernel 369 <1> 370 <1> VGA_funcs_0: 371 000017FC 52 <1> push edx ; *** 372 000017FD 51 <1> push ecx ; **** 373 000017FE 53 <1> push ebx ; ***** 374 000017FF 56 <1> push esi ; ****** 375 00001800 57 <1> push edi ; ******* 376 00001801 55 <1> push ebp ; ******** 377 <1> 378 <1> ;mov [video_eax], eax ; 12/05/2016 379 00001802 BF00800B00 <1> mov edi, 0B8000h ; GET offset FOR COLOR CARD 380 <1> 381 <1> ; 23/03/2016 382 00001807 C0E402 <1> shl ah, 2 ; dword ; TIMES 2 FOR WORD TABLE LOOKUP 383 0000180A 0FB6F4 <1> movzx esi, ah ; MOVE OFFSET INTO LOOK UP REGISTER (SI) 384 <1> ;mov ah, [CRT_MODE] ; MOVE CURRENT MODE INTO (AH) REGISTER 385 <1> 386 <1> ;;15/01/2017 387 <1> ; 14/01/2017 388 <1> ; 02/01/2017 389 <1> ;;mov byte [intflg], 31h ; video interrupt 390 <1> ;sti ; 26/11/2020 391 <1> ; 392 <1> 393 0000180D FFA6[2C170000] <1> jmp dword [esi+M1] ; GO TO SELECTED FUNCTION 394 <1> 395 <1> VBE_func: 396 <1> ; 26/11/2020 397 <1> ;sti 398 00001813 55 <1> push ebp ; *** ; 27/11/2020 399 00001814 56 <1> push esi ; **** 400 <1> 401 <1> ; Note: 402 <1> ; ebx, ecx, edx, edi, ebp registers 403 <1> ; must be saved by VBE functions and 404 <1> ; eax register must be set 405 <1> ; (according to VBE 3 standard) 406 <1> ; before return from this interrupt 407 <1> ; (every function must restore and set 408 <1> ; registers except esp, esi, es, ds) 409 <1> 410 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 411 00001815 0F20DE <1> mov esi, cr3 412 00001818 56 <1> push esi ; ***** 413 <1> ;cmp esi, [k_page_dir] 414 <1> ;je short VBE_func_x 415 00001819 8B35[C07C0100] <1> mov esi, [k_page_dir] 416 0000181F 0F22DE <1> mov cr3, esi 417 <1> ;VBE_func_x: 418 00001822 803D[86090000]02 <1> cmp byte [vbe3], 2 419 00001829 7744 <1> ja short VESA_VBE3_PMI_CALL ; VBE3 video bios ('PMID') 420 <1> ;je short VBE_func_0 ; Bochs/Qemu/VirtualBox emulator 421 0000182B 726C <1> jb short VBE_unknown ; invalid ([vbe3] = 0) 422 <1> 423 <1> ;jmp VESA_VBE3_PMI_CALL 424 <1> 425 <1> VBE_func_0: 426 <1> ; Bochs/Plex86 VGAbios VBE extension 427 <1> ; (TRDOS 386 v2.0.3 can use VBE graphics modes on emulators) 428 <1> ; BOCHS/QEMU/VIRTUALBOX 429 <1> 430 0000182D 8A25[87090000] <1> mov ah, [vbe2bios] 431 00001833 80FCC0 <1> cmp ah, 0C0h 432 00001836 7261 <1> jb short VBE_unknown 433 00001838 80FCC5 <1> cmp ah, 0C5h 434 0000183B 775C <1> ja short VBE_unknown 435 <1> 436 <1> ; TRDOS 386 is running on BOCHS or QEMU 437 0000183D B44F <1> mov ah, 4Fh 438 <1> VBE_func_1: 439 0000183F 0FB6F0 <1> movzx esi, al ; VESA VBE function number 440 <1> ;shl si, 2 ; dword 441 <1> ; 02/08/2022 442 00001842 C1E602 <1> shl esi, 2 443 00001845 6683FE14 <1> cmp si, N1L 444 00001849 734E <1> jnb short VBE_unknown 445 <1> ;sti 446 <1> 447 0000184B FF96[5B180000] <1> call dword [esi+N1] ; call VBE function 448 <1> 449 <1> ;jmp short VBE_bios_return 450 <1> 451 <1> VBE_bios_return: 452 00001851 FA <1> cli 453 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 454 00001852 5E <1> pop esi ; ***** 455 <1> ;cmp esi, [k_page_dir] 456 <1> ;je short VBE_bios_return_x 457 00001853 0F22DE <1> mov cr3, esi 458 <1> ;VBE_bios_return_x: 459 00001856 5E <1> pop esi ; **** 460 00001857 5D <1> pop ebp ; *** ; 27/11/2020 461 00001858 07 <1> pop es ; ** 462 00001859 1F <1> pop ds ; * 463 0000185A CF <1> iretd 464 <1> 465 <1> ; 26/11/2020 466 <1> N1: 467 0000185B [BC180000] <1> dd vbe_biosfn_return_ctrl_info 468 0000185F [E3380000] <1> dd vbe_biosfn_return_mode_info 469 00001863 [9D390000] <1> dd vbe_biosfn_set_mode 470 00001867 [6D3A0000] <1> dd vbe_biosfn_return_current_mode 471 0000186B [8C3A0000] <1> dd vbe_biosfn_save_restore_state 472 <1> ;dd vbe_biosfn_display_window_ctrl 473 <1> ;dd vbe_biosfn_set_get_log_scanline 474 <1> ;dd vbe_biosfn_set_get_disp_start 475 <1> ;dd vbe_biosfn_set_get_dac_pal_frm 476 <1> ;dd vbe_biosfn_set_get_palette_data 477 <1> 478 <1> N1L EQU $ - N1 479 <1> 480 <1> 481 <1> VESA_VBE3_PMI_CALL: ; VESA VBE video bios (firmware) functions 482 <1> ; by using VESA VBE3 Protected Mode Interface 483 <1> 484 <1> ; 02/08/2022 - TRDOS 386 v2.0.5 485 <1> ; 29/11/2020 486 <1> ; 26/11/2020 - TRDOS 386 v2.0.3 video.s 487 <1> 488 <1> ; We are here because.. 489 <1> ; 'PMID' has been verified by TRDOS 386 v2.0.3 kernel. 490 <1> ; (Otherwise bochs/plex86 compatible VBE functions and 491 <1> ; modes would be used on BOCHS/QEMU/VIRTUALBOX emulators 492 <1> ; or only standard/old VGA graphics modes would be used.) 493 <1> 494 <1> ; (TRDOS 386 v2.0.3 can use VESA VBE graphics modes if 495 <1> ; the video bios is full compatible with VBE3 standard) 496 <1> 497 <1> ; 29/11/2020 498 <1> 499 0000186F 0FB6F0 <1> movzx esi, al ; VESA VBE 3 function number 500 <1> ;shl si, 2 ; dword 501 <1> ; 02/08/2022 502 00001872 C1E602 <1> shl esi, 2 503 00001875 6683FE14 <1> cmp si, P1L 504 00001879 731E <1> jnb short VBE_unknown 505 <1> ;sti 506 <1> 507 0000187B 57 <1> push edi ; ***** 508 <1> 509 0000187C FF96[85180000] <1> call dword [esi+P1] ; call VBE 3 function 510 <1> 511 00001882 5F <1> pop edi ; ***** 512 <1> 513 00001883 EBCC <1> jmp short VBE_bios_return 514 <1> 515 <1> P1: 516 00001885 [9F180000] <1> dd vbe3_pmfn_return_ctrl_info 517 00001889 [C2180000] <1> dd vbe3_pmfn_return_mode_info 518 0000188D [FE180000] <1> dd vbe3_pmfn_set_mode 519 00001891 [F9180000] <1> dd vbe3_pmfn_return_current_mode 520 00001895 [071A0000] <1> dd vbe3_pmfn_save_restore_state 521 <1> ;dd vbe3_pmfn_display_window_ctrl 522 <1> ;dd vbe3_pmfn_set_get_log_scanline 523 <1> ;dd vbe3_pmfn_set_get_disp_start 524 <1> ;dd vbe3_pmfn_set_get_dac_pal_frm 525 <1> ;dd vbe3_pmfn_set_get_palette_data 526 <1> ;dd vbe3_pmfn_return_pmi ; invalid for TRDOS 386 v2 527 <1> ;dd vbe3_pmfn_set_get_pixel_clock 528 <1> 529 <1> P1L EQU $ - P1 530 <1> 531 <1> ; ; 29/11/2020 532 <1> ; mov edi, VBE3MODEINFOBLOCK >> 4 ; / 16 533 <1> ; 534 <1> ; cmp al, 04h 535 <1> ; jb short vbe3_pm_f ; function: 4F00h to 4F03h 536 <1> ; ja short vbe3_pmi_f5B ; function: 4F05h to 4F0Bh 537 <1> ; 538 <1> ; ; check buffer length (must be <= 2048 bytes) 539 <1> ; 540 <1> ; and dl, dl ; 0 541 <1> ; jz short vbe3_pm_f 542 <1> ; ; Return Save/Restore State buffer size 543 <1> ; 544 <1> ; push ebx ; buffer address 545 <1> ; push edx ; function: save (01h) or restore (02h) 546 <1> ; call 547 <1> ; 548 <1> ;vbe3_pm_f03: 549 <1> ; cmp al, 2 550 <1> ; ja short vbe3_pm_f ; function 4F03h 551 <1> ; jb short vbe3_pm_f1 552 <1> ; 553 <1> ; 554 <1> ;vbe3_pm_f1: 555 <1> ; 556 <1> ; 557 <1> ;vbe3_pmi_f5B: 558 <1> ; cmp al, 09h 559 <1> ; jna short vbe3_pm_f ; funcs 05h to 09h are usable 560 <1> ; 561 <1> ; cmp al, 0Bh ; Get/Set pixel clock, last function 562 <1> ; jne short VBE_unknown 563 <1> ; ; (do not use 'uncertain' functions 564 <1> ; ; because of system-user buff transfers) 565 <1> ;vbe3_pm_f: 566 <1> ; mov byte [vbe3_pm_fn], al ; set 567 <1> ; ; prepare 16 bit pm segments & registers for pmi call 568 <1> ; call VESA_VBE3_PM_FUNCTION 569 <1> ; 570 <1> ; 571 <1> 572 <1> ; 26/11/2020 573 <1> VBE_unknown: 574 00001899 66B80001 <1> mov ax, 0100h ; ah = 1 : Function call failed 575 <1> ; al = 0 : Function is not supported 576 <1> 577 0000189D EBB2 <1> jmp short VBE_bios_return 578 <1> 579 <1> vbe3_pmfn_return_ctrl_info: 580 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 581 <1> ; 12/12/2020 582 <1> ; 583 <1> ; VBE function 4F00h - Return VBE Controller Information 584 <1> ; 585 <1> ; Input: 586 <1> ; EDI = Pointer to buffer in which to place 587 <1> ; VbeInfoBlock structure 588 <1> ; 589 <1> ; AX = 4F00h 590 <1> ; Output: 591 <1> ; AX = VBE return status 592 <1> ; AX = 004Fh -> succeeded 593 <1> ; AX <> 004Fh -> failed 594 <1> ; 595 <1> ; Modified registers: eax (+ edi for kernel's own call) 596 <1> 597 <1> ; NOTE: TRDOS 386 v2 (v2.0.3) kernel calls this function 598 <1> ; during startup while cpu is in real mode 599 <1> ; (by using int 10h, 4F02h) and saves VbeInfoBlock at 600 <1> ; VBE3INFOBLOCK address (97E00h for TRDOS 386 v2.0.3). 601 <1> ; 602 <1> ; So... 603 <1> ; This VBE function is adjusted to return/move same info 604 <1> ; from VBE3INFOBLOCK to user's buffer in EDI. 605 <1> 606 <1> ; int 31h (int 10h) entrance 607 <1> 608 0000189F 21FF <1> and edi, edi 609 000018A1 7423 <1> jz short vbe3_func_fail ; invalid buffer address ! 610 <1> 611 <1> ;_vbe3_pmfn_return_ctrl_info: 612 <1> ;or edi, edi 613 <1> ;jnz short _vbe_biosfn_return_ctrl_info 614 <1> ; 615 <1> ;; this option may not be necessary - 12/12/2020 616 <1> ; 617 <1> ;; edi = 0, kernel forces to get ctrl info again 618 <1> ;; by using VESA VBE3 video bios's pmi 619 <1> ; 620 <1> ;;push edi 621 <1> ;; far call to VESA VBE3 PMI 622 <1> ;;mov ax, 4F00h ; Return VBE Controller Info 623 <1> ;mov edi, VBE3INFOBLOCK-VBE3SAVERESTOREBLOCK 624 <1> ;; ES selector base address = VBE3SAVERESTOREBLOCK 625 <1> ;call int10h_32bit_pmi 626 <1> ;;pop edi 627 <1> ;mov edi, VBE3INFOBLOCK ; retn to the kernel sub 628 <1> ;cmp ax, 004Fh 629 <1> ;je short vbe_ctrl_info_retn 630 <1> ;stc 631 <1> ;retn 632 <1> 633 <1> _vbe_biosfn_return_ctrl_info: 634 000018A3 57 <1> push edi 635 000018A4 51 <1> push ecx 636 000018A5 BE007E0900 <1> mov esi, VBE3INFOBLOCK 637 <1> ;mov ecx, 512 638 <1> ; 02/08/2022 639 000018AA 29C9 <1> sub ecx, ecx 640 000018AC B502 <1> mov ch, 2 641 <1> ; ecx = 512 642 000018AE E8DDF60000 <1> call transfer_to_user_buffer 643 000018B3 59 <1> pop ecx 644 000018B4 5F <1> pop edi 645 000018B5 720F <1> jc short vbe3_func_fail 646 <1> 647 000018B7 31C0 <1> xor eax, eax 648 000018B9 B04F <1> mov al, 4Fh ; successful 649 <1> ;vbe_ctrl_info_retn: 650 000018BB C3 <1> retn 651 <1> 652 <1> vbe_biosfn_return_ctrl_info: 653 <1> ; 12/12/2020 654 <1> ; 655 <1> ; VBE function 4F00h - Return VBE Controller Information 656 <1> ; 657 <1> ; Input: 658 <1> ; EDI = Pointer to buffer in which to place 659 <1> ; VbeInfoBlock structure 660 <1> ; 661 <1> ; AX = 4F00h 662 <1> ; Output: 663 <1> ; AX = VBE return status 664 <1> ; AX = 004Fh -> succeeded 665 <1> ; AX <> 004Fh -> failed 666 <1> ; 667 <1> ; Modified registers: eax 668 <1> 669 000018BC 21FF <1> and edi, edi 670 000018BE 7406 <1> jz short vbe3_func_fail ; invalid buffer addr ! 671 000018C0 EBE1 <1> jmp short _vbe_biosfn_return_ctrl_info 672 <1> 673 <1> vbe3_pmfn_return_mode_info: 674 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 675 <1> ; 21/12/2020 676 <1> ; 12/12/2020 677 <1> ; 678 <1> ; VBE function 4F01h - Return VBE Mode Information 679 <1> ; 680 <1> ; Input: 681 <1> ; CX = Mode number (VESA VBE mode number) 682 <1> ; EDI = Pointer to ModeInfoBlock structure 683 <1> ; (256 bytes) -User's buffer address- 684 <1> ; EDI = 0 -> kernel call 685 <1> ; (do not transfer ModeInfoBlock 686 <1> ; to user's buffer address) 687 <1> ; AX = 4F01h 688 <1> ; Output: 689 <1> ; AX = VBE return status 690 <1> ; AX = 004Fh -> succeeded 691 <1> ; AX <> 004Fh -> failed 692 <1> ; 693 <1> ; Modified registers: eax, esi, edi 694 <1> 695 <1> ; int 31h (int 10h) entrance 696 <1> 697 000018C2 09FF <1> or edi, edi 698 000018C4 7506 <1> jnz short _vbe3_pmfn_return_mode_info 699 <1> 700 <1> vbe3_func_fail: 701 000018C6 B84F010000 <1> mov eax, 014Fh ; ah = 1 : Function call failed 702 <1> ; al = 4Fh : Function is supported 703 000018CB C3 <1> retn 704 <1> 705 <1> ; jump from '_vbe_biosfn_return_mode_info' 706 <1> _vbe3_pmfn_return_mode_info: 707 000018CC 57 <1> push edi 708 <1> 709 <1> ;; clear vbe3 'mode info block' buffer 710 <1> ;push ecx 711 <1> ;xor eax, eax 712 <1> ;mov ecx, 256/4 713 <1> ;mov edi, VBE3MODEINFOBLOCK 714 <1> ;rep stosd 715 <1> ;pop ecx 716 <1> 717 <1> ; far call to VESA VBE3 PMI 718 <1> ;mov ax, 4F01h ; Return VBE Mode Information 719 000018CD BF00060000 <1> mov edi, VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK 720 <1> ; ES selector base address = VBE3SAVERESTOREBLOCK 721 000018D2 E812010000 <1> call int10h_32bit_pmi 722 <1> 723 000018D7 5F <1> pop edi 724 <1> 725 <1> ;cmp ax, 004Fh 726 <1> ;jne short vbe3_func_retn ; failed ! 727 <1> 728 000018D8 21FF <1> and edi, edi 729 <1> ;jz short vbe3_func_success 730 <1> ; 21/12/2020 731 000018DA 741C <1> jz short vbe3_func_retn 732 <1> 733 000018DC 6683F84F <1> cmp ax, 004Fh 734 000018E0 7516 <1> jne short vbe3_func_retn ; failed ! 735 <1> 736 000018E2 51 <1> push ecx 737 000018E3 BE007C0900 <1> mov esi, VBE3MODEINFOBLOCK 738 <1> ;mov ecx, 256 739 <1> ; 02/08/2022 740 000018E8 29C9 <1> sub ecx, ecx 741 000018EA FEC5 <1> inc ch 742 <1> ; ecx = 256 743 000018EC E89FF60000 <1> call transfer_to_user_buffer 744 000018F1 59 <1> pop ecx 745 000018F2 72D2 <1> jc short vbe3_func_fail 746 <1> 747 000018F4 31C0 <1> xor eax, eax 748 000018F6 B04F <1> mov al, 4Fh ; successful 749 <1> vbe3_func_success: 750 <1> vbe3_func_retn: 751 000018F8 C3 <1> retn 752 <1> 753 <1> vbe3_pmfn_return_current_mode: 754 <1> ; 12/12/2020 755 <1> ; 756 <1> ; VBE function 4F03h - Return Current VBE Mode 757 <1> ; 758 <1> ; Input: 759 <1> ; none (AX = 4F03h) 760 <1> ; Output: 761 <1> ; AX = VBE return status 762 <1> ; AX = 004Fh -> succeeded 763 <1> ; AX <> 004Fh -> failed 764 <1> ; BX = Current VBE mode 765 <1> ; bit 0-13 = Mode number 766 <1> ; bit 14 = 0 Windowed frame buffer model 767 <1> ; = 1 Linear frame buffer model 768 <1> ; bit 15 769 <1> ; = 0 Memory cleared at last mode set 770 <1> ; = 1 Memory not cleared at last mode set 771 <1> ; 772 <1> ; Modified registers: eax, ebx 773 <1> 774 <1> ; int 31h (int 10h) entrance 775 <1> 776 <1> ; far call to VESA VBE3 PMI 777 <1> 778 <1> ;mov eax, 4F03h ; Return Current VBE Mode 779 <1> vbe3_pmfn_far_call: 780 <1> ; ES selector base address = VBE3SAVERESTOREBLOCK 781 <1> ;call int10h_32bit_pmi 782 <1> ;retn 783 000018F9 E9EB000000 <1> jmp int10h_32bit_pmi 784 <1> 785 <1> vbe3_pmfn_set_mode: 786 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 787 <1> ; 22/12/2020 788 <1> ; 21/12/2020 789 <1> ; 12/12/2020 790 <1> ; 791 <1> ; VBE function 4F02h - Set VBE Mode 792 <1> ; 793 <1> ; Input: 794 <1> ; BX = Desired Mode to set 795 <1> ; bit 0-13 = Mode number 796 <1> ; bit 14 = 0 Windowed frame buffer model 797 <1> ; = 1 Linear frame buffer model 798 <1> ; bit 15 799 <1> ; = 0 Memory cleared at last mode set 800 <1> ; = 1 Memory not cleared at last mode set 801 <1> ; Output: 802 <1> ; AX = VBE return status 803 <1> ; AX = 004Fh -> succeeded 804 <1> ; AX <> 004Fh -> failed 805 <1> ; 806 <1> ; Modified registers: eax, ebx, esi (21/12/2020) 807 <1> 808 <1> ; int 31h (int 10h) entrance 809 <1> 810 <1> ; 22/12/2020 (VESA VBE3 feature) 811 <1> ; BX bit 11 is flag for 812 <1> ; user specified CRTC values for refresh rate 813 <1> ; 'test bh, 8' 814 <1> ; if bit 11 is set, EDI points to 'CRTCInfoBlock' 815 <1> 816 <1> ; 22/12/2020 817 <1> ;; test bx for VBE video mode 818 <1> ;test bh, 1 819 <1> ;jnz short vbe3_sm_0 820 <1> 821 <1> ;; use internal VBE mode set procedure 822 <1> ;; for non-vbe (std VGA/CGA) modes 823 <1> ; 824 <1> ;; (it is useful -as 4F02h function- 825 <1> ;; to jump 'vbe_biosfn_set_mode' 826 <1> ;; instead of direct jump to '_set_mode') 827 <1> ;; ((eliminates additional push-pops and settings)) 828 <1> 829 <1> ;jmp vbe_biosfn_set_mode 830 <1> 831 <1> vbe3_sm_0: 832 <1> ;;push ds ; * 833 <1> ;;push es ; ** 834 <1> ;;push ebp ; *** 835 <1> ;;push esi ; **** 836 <1> 837 <1> ; Fit bx to VESA VBE2 type mode setting 838 <1> ; (bx bit 11 is used for custom CRTC values in VBE3) 839 <1> ; clear bit 9 to 11 (clear bh bit 1 to bit 3) 840 <1> 841 <1> ; 22/12/2020 842 000018FE 57 <1> push edi ; ***** 843 000018FF F6C708 <1> test bh, 8 ; Use user specified CRTC values 844 00001902 7530 <1> jnz short vbe3_sm_3 ; for refresh rate 845 <1> vbe3_sm_4: 846 00001904 80E7C1 <1> and bh, 0C1h ; use bit 15, 14, 8 only (for bh) 847 <1> ;mov [vbe_mode_x], bh 848 <1> 849 00001907 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 ; is current mode 03h ? 850 0000190E 7509 <1> jne short vbe3_sm_1 ; no 851 <1> 852 <1> ; save mode 03h video pages and cursor positions 853 00001910 57 <1> push edi ; **!*** 854 00001911 51 <1> push ecx ; ****** 855 <1> ;push esi 856 <1> 857 00001912 E8CE040000 <1> call save_mode3_multiscreen 858 <1> 859 <1> ;pop esi 860 00001917 59 <1> pop ecx ; ****** 861 00001918 5F <1> pop edi ; **!*** 862 <1> vbe3_sm_1: 863 <1> ; ax = 4F02h 864 <1> ; bx = video mode number (vbe2 type) 865 00001919 E8CB000000 <1> call int10h_32bit_pmi 866 <1> ; call to far call to VBE3 PMI 867 <1> 868 0000191E 6683F84F <1> cmp ax, 004Fh ; succeeded ? 869 00001922 750E <1> jne short vbe3_sm_2 870 <1> ; set current mode byte/sign to extended (SVGA) mode 871 00001924 C605[DE670000]FF <1> mov byte [CRT_MODE], 0FFh ; VESA VBE mode 872 <1> ; set current VBE mode word to bx input 873 0000192B 66891D[2EA30100] <1> mov [video_mode], bx 874 <1> vbe3_sm_2: 875 <1> ; 22/12/2020 876 00001932 5F <1> pop edi ; ***** 877 00001933 C3 <1> retn 878 <1> 879 <1> vbe3_sm_3: 880 <1> ; 22/12/2020 881 <1> ; copy user's CRTCInfoBlock to the buffer 882 00001934 51 <1> push ecx 883 00001935 89FE <1> mov esi, edi 884 00001937 BF807D0900 <1> mov edi, VBE3CRTCINFOBLOCK 885 <1> ;mov ecx, 64 886 <1> ; 02/08/2022 887 0000193C 29C9 <1> sub ecx, ecx 888 0000193E B140 <1> mov cl, 64 889 00001940 E895F60000 <1> call transfer_from_user_buffer 890 00001945 59 <1> pop ecx 891 <1> ; set offset (es base addr is VBE3SAVERESTOREBLOCK) 892 00001946 81EF00760900 <1> sub edi, VBE3SAVERESTOREBLOCK 893 0000194C EBB6 <1> jmp short vbe3_sm_4 894 <1> 895 <1> vesa_vbe3_pmi: 896 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 897 <1> ; 12/12/2020 898 <1> ; 08/12/2020 899 <1> ; 07/12/2020 900 <1> ; 05/12/2020, 06/12/2020 901 <1> ; 03/12/2020, 04/12/2020 902 <1> ; 28/11/2020 (TRDOS 386 v2.0.3) 903 <1> ; VGA BIOS functions via 904 <1> ; VESA VBE3 Protected Mode Inface 905 <1> ; [vbe3] = 3 and [pmi32] > 0 906 <1> 907 <1> ; 04/12/2020 908 <1> ; Only 'set mode' will be redirected to vbe3 video bios 909 <1> ; (by setting mode 3 multiscreen parameters before and after) 910 <1> 911 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 912 0000194E 50 <1> push eax 913 0000194F 0F20D8 <1> mov eax, cr3 914 00001952 870424 <1> xchg eax, [esp] ; **!** 915 00001955 50 <1> push eax 916 <1> ;cmp esi, [k_page_dir] 917 <1> ;je short vesa_vbe3_pmi_x 918 00001956 A1[C07C0100] <1> mov eax, [k_page_dir] 919 0000195B 0F22D8 <1> mov cr3, eax 920 <1> ;vesa_vbe3_pmi_x: 921 0000195E 58 <1> pop eax 922 <1> 923 <1> ; 06/12/2020 924 0000195F 20E4 <1> and ah, ah ; 0 = set mode function 925 00001961 7402 <1> jz short vbe3_pmi_0 926 00001963 EB7D <1> jmp vbe3_pmi_9 927 <1> 928 <1> vbe3_pmi_0: 929 <1> ; 07/12/2020 930 00001965 88C4 <1> mov ah, al 931 00001967 80E480 <1> and ah, 80h ; 0 or 80h 932 0000196A 30E0 <1> xor al, ah ; 8?h -> 0?h 933 <1> 934 <1> ;cmp al, 13h ; mode number above 13h is returned 935 <1> ;jna short vbe3_pmi_1 936 <1> ; ; back to default code due to uncertainty 937 <1> ; ; (>13h is not std for all svga bioses) 938 <1> ;jmp VGA_funcs_0 939 <1> vbe3_pmi_1: 940 <1> ; 07/12/2020 941 <1> ; Possible cases for VBE3 (PMI, ah=0) set mode: 942 <1> ; current mode > 07h and requested mode: any 943 <1> ; current mode <= 07h and requested mode > 07h 944 <1> 945 <1> ; 06/12/2020 946 0000196C 8825[53890100] <1> mov byte [noclearmem], ah ; 0 or 80h 947 <1> ; check current video mode if it is 03h 948 00001972 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 ; current mode 949 00001979 750B <1> jne short vbe3_pmi_3 950 <1> ; 07/12/2020 951 <1> ; check new video mode if it is 03h also 952 <1> ;cmp al, 3 953 <1> ;jne short vbe3_pmi_2 954 <1> ;mov byte [p_crt_mode], 80h ; clear video memory 955 <1> ;jmp short vbe3_pmi_5 956 <1> vbe3_pmi_2: 957 <1> ; case 1: 958 <1> ; Current mode is 03h and new mode is not 03h 959 <1> 960 <1> ; save video pages and cursor positions 961 0000197B 56 <1> push esi 962 0000197C 57 <1> push edi 963 0000197D 51 <1> push ecx 964 <1> 965 <1> ; 12/12/2020 966 <1> ;mov esi, 0B8000h ; mode 3 video memory 967 <1> ;mov edi, 98000h ; backup location 968 <1> ;mov ecx, (0B8000h-0B0000h)/4 969 <1> ;rep movsd 970 <1> ; 971 <1> ;mov byte [p_crt_mode], 3 ; previous mode, backup sign 972 <1> ;xchg cl, [ACTIVE_PAGE] 973 <1> ;mov [p_crt_page], cl ; save as previous active page 974 <1> ; 975 <1> ;; save cursor positions 976 <1> ;mov esi, CURSOR_POSN 977 <1> ;mov edi, cursor_pposn ; cursor positions backup 978 <1> ;mov cl, 4 979 <1> ;rep movsd 980 <1> 981 <1> ; 12/12/2020 982 0000197E E862040000 <1> call save_mode3_multiscreen 983 <1> 984 00001983 59 <1> pop ecx 985 00001984 5F <1> pop edi 986 00001985 5E <1> pop esi 987 <1> vbe3_pmi_3: 988 <1> ; 08/12/2020 989 <1> ; 07/12/2020 990 <1> ; case 3 or case 4 991 00001986 A2[DE670000] <1> mov [CRT_MODE], al 992 0000198B 3C03 <1> cmp al, 3 993 0000198D 7407 <1> je short vbe3_pmi_4 994 <1> ; case 4: 995 <1> ; Current mode is not 03h and also new mode is not 03h 996 0000198F 800D[51890100]80 <1> or byte [p_crt_mode], 80h ; 83h (case 1 -> case 4) 997 <1> ;jmp short vbe3_pmi_5 998 <1> vbe3_pmi_4: 999 <1> ; case 3: 1000 <1> ; 1001 <1> ; Current mode is not 03h and new mode is 03h 1002 <1> 1003 <1> ;vbe3_pmi_5: 1004 <1> ;mov [CRT_MODE], al 1005 <1> 1006 00001996 E84E000000 <1> call int10h_32bit_pmi 1007 <1> 1008 0000199B 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 ; new video mode 1009 <1> ;jne vbe3_pmi_8 ; video mode <> 03h 1010 000019A2 7532 <1> jne short vbe3_pmi_8 1011 <1> 1012 <1> ;push eax ; 04/12/2020 1013 000019A4 53 <1> push ebx 1014 000019A5 51 <1> push ecx 1015 000019A6 52 <1> push edx 1016 000019A7 57 <1> push edi ; 03/12/2020 1017 <1> 1018 <1> ; 12/12/2020 1019 000019A8 56 <1> push esi 1020 000019A9 E869040000 <1> call restore_mode3_multiscreen 1021 000019AE 5E <1> pop esi 1022 <1> ; AL = active video page 1023 <1> 1024 <1> ; 12/12/2020 1025 <1> ;mov al, [p_crt_page] ; previous mode 3 active page 1026 <1> ; 1027 <1> ;;test byte [p_crt_mode], 7Fh ; 83h or 80h or 03h 1028 <1> ;;jz short vbe3_pmi_6 ; do not restore video pages 1029 <1> ; ; clear current video page 1030 <1> ;; case 3 1031 <1> ; 1032 <1> ;; ([p_crt_mode] = 03h) 1033 <1> ; 1034 <1> ;; New video mode is 3 while current video mode is not 3 1035 <1> ;; (multi screen) video pages will be restored from 098000h 1036 <1> ; 1037 <1> ;; restore video pages and cursor positions 1038 <1> ; 1039 <1> ;mov [ACTIVE_PAGE], al ; current mode 3 active page 1040 <1> ; 1041 <1> ;push esi 1042 <1> ; 1043 <1> ;; restore video pages 1044 <1> ;mov esi, 98000h 1045 <1> ;mov edi, 0B8000h 1046 <1> ;;mov ecx, 2000h 1047 <1> ;mov cx, 2000h ; 8K dwords (32K) 1048 <1> ;rep movsd 1049 <1> ; 1050 <1> ;mov [p_crt_mode], cl ; reset ('case 3' end condition) 1051 <1> ; 1052 <1> ;; restore cursor positions 1053 <1> ;mov esi, cursor_pposn 1054 <1> ;mov edi, CURSOR_POSN 1055 <1> ;;mov ecx, 4 ; restore all cursor positions (16 bytes) 1056 <1> ;mov cl, 4 1057 <1> ;rep movsd 1058 <1> ; 1059 <1> ;pop esi 1060 <1> ; 1061 <1> ;; 07/12/2020 1062 <1> ;; restore CRT_START according to ACTIVE_PAGE 1063 <1> ;mov [CRT_START], cx ; 0 1064 <1> ; 1065 <1> ;; check active page and set it again if it is not 0 1066 <1> ;or al, al 1067 <1> ;jz short vbe3_pmi_7 1068 <1> ; 1069 <1> ;mov cl, al 1070 <1> ;vbe3_pmi_5: 1071 <1> ;add word [CRT_START], 4096 1072 <1> ;dec cl 1073 <1> ;jnz short vbe3_pmi_5 1074 <1> 1075 000019AF B405 <1> mov ah, 05h ; set current video page 1076 <1> ;al = video page 1077 000019B1 E833000000 <1> call int10h_32bit_pmi 1078 <1> 1079 <1> ; check current cursor position & set it again if not 0,0 1080 <1> ;movzx ebx, byte [ACTIVE_PAGE] 1081 000019B6 0FB6D8 <1> movzx ebx, al 1082 000019B9 D0E3 <1> shl bl, 1 1083 000019BB 81C3[DE7C0100] <1> add ebx, CURSOR_POSN 1084 000019C1 668B13 <1> mov dx, [ebx] 1085 000019C4 6621D2 <1> and dx, dx 1086 000019C7 7409 <1> jz short vbe3_pmi_7 1087 <1> 1088 <1> ;dx = cursor position (dl = column, dh = row) 1089 <1> ;mov bh, [ACTIVE_PAGE] ; 06/12/2020 1090 000019C9 88C7 <1> mov bh, al 1091 000019CB B402 <1> mov ah, 02h ; set cursor position 1092 000019CD E817000000 <1> call int10h_32bit_pmi 1093 <1> 1094 <1> ;jmp short vbe3_pmi_7 1095 <1> 1096 <1> ;vbe3_pmi_6: 1097 <1> ; ; 07/12/2020 1098 <1> ; ; case 1, previous mode is 03h, current mode is 03h 1099 <1> ; ; 03/12/2020 1100 <1> ; cmp byte [noclearmem], 0 1101 <1> ; jna short vbe3_pmi_7 ; do not clear memory 1102 <1> ; ; clear video page 1103 <1> ; mov ecx, 1024 ; 4096/4 1104 <1> ; mov eax, 07200720h 1105 <1> ; mov edi, 0B8000h ; [crt_base] 1106 <1> ; add di, [CRT_START] 1107 <1> ; rep stosd ; FILL THE REGEN BUFFER WITH BLANKS 1108 <1> 1109 <1> vbe3_pmi_7: 1110 000019D2 5F <1> pop edi 1111 000019D3 5A <1> pop edx 1112 000019D4 59 <1> pop ecx 1113 000019D5 5B <1> pop ebx 1114 <1> ;pop eax ; 04/12/2020 1115 <1> vbe3_pmi_8: 1116 <1> ; 04/12/2020 1117 <1> ;(TRDOS 386 v2.0.3, INT 31h, ah=0 return) 1118 000019D6 31C0 <1> xor eax, eax ; eax = 0 -> succesful 1119 <1> vesa_vbe3_pmi_retn: 1120 <1> ; 29/11/2023 - TRDOS 386 v2.0.7 1121 000019D8 870424 <1> xchg eax, [esp] ; **!** 1122 <1> ;cmp eax, [k_page_dir] 1123 <1> ;je short vesa_vbe3_pmi_retn_x 1124 000019DB 0F22D8 <1> mov cr3, eax 1125 <1> ;vesa_vbe3_pmi_retn_x: 1126 000019DE 58 <1> pop eax 1127 <1> ; 1128 000019DF 07 <1> pop es ; ** 1129 000019E0 1F <1> pop ds ; * 1130 000019E1 CF <1> iretd 1131 <1> 1132 <1> vbe3_pmi_9: 1133 <1> ; 06/12/2020 1134 <1> ;cmp ah, 10h ; Set/Get Palette Registers 1135 <1> ;jnb short vbe3_pmi_10 1136 <1> ; 05/12/2020 1137 000019E2 E802000000 <1> call int10h_32bit_pmi 1138 000019E7 EBEF <1> jmp short vesa_vbe3_pmi_retn 1139 <1> 1140 <1> ;vbe3_pmi_10: 1141 <1> ; 06/12/2020 1142 <1> ;jmp VGA_funcs_0 1143 <1> 1144 <1> int10h_32bit_pmi: 1145 <1> ; 03/12/2020 1146 <1> ; 28/11/2020 1147 <1> ; calling standard VGA Bios (INT 10h) functions 1148 <1> ; by using 32 bit protected mode interface of 1149 <1> ; VESA VBE3 Video Bios (with 'PMID' signature) 1150 <1> 1151 <1> ; 03/12/2020 1152 <1> ; eax, ebx, ecx, edx, edi will be used by vbios pmi 1153 <1> ; (esi and ebp will not be used) 1154 <1> 1155 <1> ; 03/12/2020 1156 000019E9 56 <1> push esi 1157 000019EA C1E010 <1> shl eax, 16 ; move function number (ax) to hw 1158 000019ED 8B35[34A30100] <1> mov esi, [pmid_addr] ; linear address of 1159 <1> ; PMInfo.Entrypoint pointer 1160 <1> ;mov ax, [esi+PMInfo.EntryPoint] 1161 000019F3 668B06 <1> mov ax, [esi] 1162 000019F6 C1C010 <1> rol eax, 16 ; move PM entry address to hw 1163 <1> ; and move function number to lw (ax) 1164 000019F9 5E <1> pop esi 1165 <1> 1166 <1> ; top of stack: ; (*) 1167 <1> ; return (the caller) address of "int10h_32bit_pmi" 1168 <1> 1169 000019FA E965EDFFFF <1> jmp _VBE3PMI_fcall ; will return to the caller (*) 1170 <1> 1171 <1> _vbe3_pmfn_srs_8: 1172 <1> ; 17/01/2021 1173 000019FF 31DB <1> xor ebx, ebx ; points to VBE3SAVERESTOREBLOCK 1174 <1> _vbe3_pmfn_srs_9: ; 24/01/2021 1175 00001A01 66B8044F <1> mov ax, 4F04h 1176 00001A05 EBE2 <1> jmp short int10h_32bit_pmi 1177 <1> 1178 <1> vbe3_pmfn_save_restore_state: 1179 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 1180 <1> ; 24/01/2021 1181 <1> ; 23/01/2021 1182 <1> ; 16/01/2021 - 17/01/2021 1183 <1> ; 14/01/2021 1184 <1> ; 1185 <1> ; VBE function 4F04h - Save/Restore Video State 1186 <1> ; 1187 <1> ; Input: 1188 <1> ; DL = sub function 1189 <1> ; CL = requested state 1190 <1> ; EBX = pointer to buffer (if DL<>00h) 1191 <1> ; AX = 4F04h 1192 <1> ; Output: 1193 <1> ; AX = 004Fh (successful) 1194 <1> ; AH > 0 -> error 1195 <1> ; BX = Number of 64-byte blocks 1196 <1> ; to hold the state buffer (if DL=00h) 1197 <1> 1198 <1> ; Modified registers: eax, ebx, esi, edi 1199 <1> 1200 00001A07 21DB <1> and ebx, ebx ; user's buffer address 1201 00001A09 750A <1> jnz short _vbe3_pmfn_save_restore_state 1202 <1> 1203 00001A0B 08D2 <1> or dl, dl 1204 00001A0D 740C <1> jz short _vbe3_pmfn_srs_0 1205 <1> 1206 <1> ; function failed 1207 <1> ;;mov eax, 0100h 1208 <1> ;sub eax, eax 1209 <1> ;inc ah ; eax = 0100h 1210 <1> ;retn 1211 <1> ; 16/01/2021 1212 <1> _vbe3_pmfn_srs_fail: 1213 00001A0F B84F010000 <1> mov eax, 014Fh ; ah = 1 : Function call failed 1214 <1> ; al = 4Fh : Function is supported 1215 <1> _vbe3_srs_retn: 1216 00001A14 C3 <1> retn 1217 <1> 1218 <1> _vbe3_pmfn_save_restore_state: 1219 00001A15 20D2 <1> and dl, dl 1220 00001A17 7555 <1> jnz short _vbe3_pmfn_srs_2 1221 <1> _vbe3_pmfn_srs: 1222 00001A19 31DB <1> xor ebx, ebx 1223 <1> _vbe3_pmfn_srs_0: 1224 <1> ; 24/01/2021 1225 00001A1B 83F90F <1> cmp ecx, 0Fh 1226 <1> ;ja short _vbe3_pmfn_srs_1 1227 00001A1E 77EF <1> ja short _vbe3_pmfn_srs_fail 1228 <1> 1229 <1> ; !!! CLEAR CL BIT 2 !!! 1230 <1> ; (when bit 2 is set, function causes cpu exception) 1231 <1> ; BIOS data will not be saved and restored 1232 <1> ; (to prevent protected mode page fault error) 1233 00001A20 80E1FD <1> and cl, ~2 ; and cl, not 2 1234 <1> 1235 <1> ; 24/01/2021 1236 <1> ;mov bl, 1 1237 00001A23 FEC3 <1> inc bl ; = 1 1238 <1> ;shl bx, cl 1239 <1> ; 02/08/2022 1240 00001A25 D3E3 <1> shl ebx, cl 1241 00001A27 66231D[38A30100] <1> and bx, [vbe3stbsflags] 1242 00001A2E 7415 <1> jz short _vbe3_pmfn_srs_1 1243 <1> ;mov bx, cx 1244 00001A30 89CB <1> mov ebx, ecx ; <= 15 1245 00001A32 D0E3 <1> shl bl, 1 ; 0, 2, 8 .. 30 1246 00001A34 668B9B[3D3B0000] <1> mov bx, [vbestatebufsize+ebx] 1247 00001A3B 89DF <1> mov edi, ebx 1248 <1> ; edi = state buffer size in bytes 1249 <1> ;shr bx, 6 ; / 64 1250 <1> ; 02/08/2022 1251 00001A3D C1EB06 <1> shr ebx, 6 1252 <1> ;mov ax, 4Fh 1253 00001A40 28E4 <1> sub ah, ah 1254 00001A42 B04F <1> mov al, 4Fh 1255 00001A44 C3 <1> retn 1256 <1> _vbe3_pmfn_srs_1: 1257 <1> ; ax = 4F04h 1258 <1> ;call int10h_32bit_pmi 1259 <1> ; 24/01/2021 1260 <1> ;call _vbe3_pmfn_srs_8 1261 <1> ; ebx = 0 1262 00001A45 E8B7FFFFFF <1> call _vbe3_pmfn_srs_9 1263 00001A4A 6683F84F <1> cmp ax, 004Fh 1264 00001A4E 75C4 <1> jne short _vbe3_srs_retn 1265 <1> ; 24/01/2021 1266 <1> ;cmp ecx, 0Fh 1267 <1> ;ja short _vbe3_srs_retn 1268 <1> ; 24/01/2021 1269 <1> ;mov ax, 1 1270 00001A50 B001 <1> mov al, 1 1271 <1> ;shl ax, cl 1272 <1> ; 02/08/2022 1273 00001A52 D3E0 <1> shl eax, cl 1274 00001A54 660905[38A30100] <1> or [vbe3stbsflags], ax ; set flag for state option 1275 <1> ; 23/01/2021 1276 00001A5B 89DF <1> mov edi, ebx 1277 00001A5D 89C8 <1> mov eax, ecx 1278 00001A5F D0E0 <1> shl al, 1 1279 <1> ;shl di, 6 ; * 64 1280 <1> ; 02/08/2022 1281 00001A61 C1E706 <1> shl edi, 6 1282 00001A64 6689B8[3D3B0000] <1> mov [vbestatebufsize+eax], di 1283 <1> ; save buf size for option 1284 <1> ;xchg edi, ebx 1285 <1> ; edi = state buffer size in bytes 1286 00001A6B B04F <1> mov al, 4Fh 1287 00001A6D C3 <1> retn 1288 <1> 1289 <1> _vbe3_pmfn_srs_2: 1290 <1> ; 24/01/2021 1291 <1> ; !!! CLEAR CL BIT 2 !!! 1292 <1> ; (when bit 2 is set, function causes cpu exception) 1293 <1> ; BIOS data will not be saved and restored 1294 <1> ; (to prevent protected mode page fault error) 1295 <1> 1296 00001A6E F6C1FD <1> test cl, ~2 ; test cl, not 2 1297 00001A71 749C <1> jz short _vbe3_pmfn_srs_fail 1298 <1> 1299 00001A73 80FA02 <1> cmp dl, 2 1300 00001A76 7748 <1> ja short _vbe3_pmfn_srs_5 1301 <1> 1302 <1> ;and cl, ~2 ; and cl, not 2 1303 <1> 1304 00001A78 53 <1> push ebx ; * ; buffer address 1305 <1> ; save or restore state 1306 <1> ; (get required buffer size at first) 1307 00001A79 52 <1> push edx ; ** 1308 00001A7A 28D2 <1> sub dl, dl ; 0 1309 00001A7C E898FFFFFF <1> call _vbe3_pmfn_srs 1310 00001A81 5A <1> pop edx ; ** 1311 <1> ; 24/01/2021 1312 00001A82 5B <1> pop ebx ; * 1313 00001A83 08E4 <1> or ah, ah 1314 00001A85 7538 <1> jnz short _vbe3_pmfn_srs_4 ; error 1315 <1> 1316 <1> ; edi = buffer size in bytes 1317 00001A87 81FF00080000 <1> cmp edi, 2048 1318 00001A8D 772B <1> ja short _vbe3_pmfn_srs_3 1319 <1> 1320 00001A8F 80FA01 <1> cmp dl, 1 1321 00001A92 7531 <1> jne short _vbe3_pmfn_srs_6 ; restore state 1322 <1> 1323 <1> ; save video state 1324 <1> ;xor ebx, ebx ; points to VBE3SAVERESTOREBLOCK 1325 <1> ;mov ax, 4F04h 1326 <1> ;call int10h_32bit_pmi 1327 <1> 1328 <1> ; 24/01/2021 1329 00001A94 E842000000 <1> call _vbe3_pmfn_srs_7 1330 <1> 1331 00001A99 6683F84F <1> cmp ax, 004Fh 1332 00001A9D 7520 <1> jne short _vbe3_pmfn_srs_4 1333 <1> 1334 00001A9F 09DB <1> or ebx, ebx ; kernel ('sysvideo') ? 1335 00001AA1 741C <1> jz short _vbe3_pmfn_srs_4 ; yes 1336 <1> 1337 <1> ; the caller is user 1338 00001AA3 51 <1> push ecx ; * 1339 00001AA4 89F9 <1> mov ecx, edi ; state buffer size 1340 00001AA6 BE00760900 <1> mov esi, VBE3SAVERESTOREBLOCK ; source 1341 <1> ; (vbe3 pmi buff) 1342 00001AAB 89DF <1> mov edi, ebx ; destination (user buff) 1343 00001AAD E8DEF40000 <1> call transfer_to_user_buffer 1344 00001AB2 59 <1> pop ecx ; * 1345 00001AB3 7205 <1> jc short _vbe3_pmfn_srs_3 1346 <1> 1347 00001AB5 29C0 <1> sub eax, eax 1348 00001AB7 B04F <1> mov al, 4Fh 1349 00001AB9 C3 <1> retn 1350 <1> 1351 <1> ; 24/01/2021 1352 <1> _vbe3_pmfn_srs_3: 1353 00001ABA B84F010000 <1> mov eax, 014Fh 1354 <1> _vbe3_pmfn_srs_4: 1355 00001ABF C3 <1> retn 1356 <1> _vbe3_pmfn_srs_5: 1357 00001AC0 31C0 <1> xor eax, eax 1358 00001AC2 FEC4 <1> inc ah 1359 <1> ; eax = 0100h, function is not supported 1360 00001AC4 C3 <1> retn 1361 <1> 1362 <1> _vbe3_pmfn_srs_6: 1363 <1> ; restore video state 1364 <1> ; 24/01/2021 1365 <1> ;pop ebx ; * 1366 <1> ; 23/01/2021 1367 00001AC5 09DB <1> or ebx, ebx ; 0 ? 1368 00001AC7 7412 <1> jz short _vbe3_pmfn_srs_7 ; 'sysvideo' call 1369 <1> ; 24/01/2021 1370 <1> ;jz _vbe3_pmfn_srs_8 1371 00001AC9 89DE <1> mov esi, ebx 1372 <1> ; esi = user's video state buffer 1373 00001ACB 51 <1> push ecx ; * 1374 00001ACC 89F9 <1> mov ecx, edi ; state buffer size 1375 00001ACE BF00760900 <1> mov edi, VBE3SAVERESTOREBLOCK ; destination 1376 <1> ; (vbe3 pmi buff) 1377 <1> ;mov esi, ebx ; source (user buff) 1378 00001AD3 E802F50000 <1> call transfer_from_user_buffer 1379 00001AD8 59 <1> pop ecx ; * 1380 00001AD9 72DF <1> jc short _vbe3_pmfn_srs_3 1381 <1> _vbe3_pmfn_srs_7: 1382 00001ADB 53 <1> push ebx ; * 1383 <1> ; restore video state 1384 <1> ;xor ebx, ebx ; points to VBE3SAVERESTOREBLOCK 1385 <1> ;mov ax, 4F04h 1386 <1> ;call int10h_32bit_pmi 1387 <1> ; 17/01/2021 1388 00001ADC E81EFFFFFF <1> call _vbe3_pmfn_srs_8 1389 00001AE1 5B <1> pop ebx ; * 1390 00001AE2 C3 <1> retn 1391 <1> 1392 <1> VIDEO_STATE: 1393 <1> ; 26/06/2016 1394 <1> ; 12/05/2016 1395 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 1396 <1> 1397 <1> ;--------------------------------------------------- 1398 <1> ; VIDEO STATE 1399 <1> ; RETURNS THE CURRENT VIDEO STATE IN AX 1400 <1> ; AH = NUMBER OF COLUMNS ON THE SCREEN 1401 <1> ; AL = CURRENT VIDEO MODE 1402 <1> ; BH = CURRENT ACTIVE PAGE 1403 <1> ;--------------------------------------------------- 1404 <1> 1405 00001AE3 8A25[E0670000] <1> mov ah, [CRT_COLS] ; GET NUMBER OF COLUMNS 1406 00001AE9 A0[DE670000] <1> mov al, [CRT_MODE] ; CURRENT MODE 1407 <1> ;movzx esi, al 1408 <1> ;mov ah, [esi+M6] 1409 <1> ; BH = active page 1410 00001AEE 8A3D[EE7C0100] <1> mov bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE 1411 00001AF4 FA <1> cli ; 02/01/2017 1412 00001AF5 5D <1> pop ebp ; RECOVER REGISTERS 1413 00001AF6 5F <1> pop edi 1414 00001AF7 5E <1> pop esi 1415 00001AF8 59 <1> pop ecx ; DISCARD SAVED BX 1416 00001AF9 EB41 <1> jmp short M15 ; RETURN TO CALLER 1417 <1> 1418 <1> set_mode_ncm: 1419 <1> ; 17/11/2020 (TRDOS 386 v2.0.3) 1420 <1> ; 04/07/2016 - TRDOS 386 (TRDOS v2.0) 1421 <1> ; set mode without clearing the video memory 1422 <1> ; (ony for graphics modes) 1423 <1> 1424 <1> ;cmp al, 7 ; IBM PC CGA modes 1425 <1> ;jna short SET_MODE ; normal function (clear) 1426 <1> ;; do not clear memory 1427 <1> ;;mov [noclearmem], al ; > 0 1428 <1> ;mov byte [noclearmem], 80h ; 17/11/2020 1429 <1> ;call _set_mode 1430 <1> ;mov byte [noclearmem], 0 1431 <1> ;jmp short VIDEO_RETURN 1432 <1> 1433 <1> ; 17/11/2020 (TRDOS v2.0.3) 1434 00001AFB 0C80 <1> or al, 80h ; not clear memory option 1435 <1> 1436 <1> ; 05/12/2020 1437 <1> ; 27/11/2020 1438 <1> ; 17/11/2020 1439 <1> ; 08/08/2016, 10/08/2016 1440 <1> ; 29/07/2016, 30/07/2016 1441 <1> ; 25/07/2016, 26/07/2016, 27/07/2016 1442 <1> ; 02/07/2016, 18/07/2016, 23/07/2016 1443 <1> ; 24/06/2016, 26/06/2016 1444 <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 1445 <1> SET_MODE: 1446 <1> ; For 32 bit TRDOS and Retro UNIX 386: 1447 <1> ; valid video mode: 03h only! 1448 <1> ; (VGA modes will be selected with another routine) 1449 <1> ; 1450 <1> ; set_txt_mode ; 80*25 (16 fore colors, 8 back colors) 1451 <1> 1452 <1> ; 27/11/2020 1453 <1> 1454 <1> ; Check if current mode is 1455 <1> ; Bochs/Plex86 VBE graphics mode 1456 00001AFD 803D[DE670000]FF <1> cmp byte [CRT_MODE], 0FFh ; VESA VBE graphics mode 1457 00001B04 7220 <1> jb short _set_mode_ ; signature 1458 <1> ; VBE mode number is in 1459 <1> ; [video_mode] bit 0to8 1460 00001B06 88C3 <1> mov bl, al ; save video mode 1461 00001B08 E87C230000 <1> call dispi_get_enable 1462 00001B0D 50 <1> push eax ; save current VBE dispi status 1463 <1> ; Disable Bochs/Plex86 VBE dispi 1464 <1> ;mov ax, 0 ; VBE_DISPI_DISABLED 1465 00001B0E 31C0 <1> xor eax, eax ; 0 1466 00001B10 E849230000 <1> call dispi_set_enable 1467 00001B15 88D8 <1> mov al, bl ; restore video mode 1468 00001B17 E827000000 <1> call _set_mode 1469 00001B1C 58 <1> pop eax ; restore current VBE dispi status 1470 00001B1D 7313 <1> jnc short VIDEO_RETURN 1471 <1> ; ! unimplemented or invalid video mode number ! 1472 <1> ; VBE dispi must be enabled again 1473 <1> ; (return to run on current VBE graphics mode) 1474 <1> ;;mov al, [video_mode+1] ; bit 8 to 15 1475 <1> ;;and al, 0C0h ; isolate bit 14 and bit 15 1476 <1> ;;or al, 1 ; VBE_DISPI_ENABLED 1477 00001B1F E83A230000 <1> call dispi_set_enable 1478 00001B24 EB07 <1> jmp short _video_func_err 1479 <1> 1480 <1> _set_mode_: 1481 <1> ; VGA bios (non-VBE) 'setmode' procedure 1482 <1> 1483 <1> ; 26/11/2020 (TRDOS v2.0.3) 1484 <1> 1485 <1> ;------------------------------------------------------ 1486 <1> ; SET MODE : 1487 <1> ; THIS ROUTINE INITIALIZES THE ATTACHMENT TO : 1488 <1> ; THE SELECTED MODE, THE SCREEN IS BLANKED. : 1489 <1> ; INPUT : 1490 <1> ; (AL) - MODE SELECTED (RANGE 0-7) : 1491 <1> ; OUTPUT : 1492 <1> ; NONE : 1493 <1> ;------------------------------------------------------ 1494 <1> 1495 00001B26 E818000000 <1> call _set_mode ; 24/06/2016 (set_txt_mode) 1496 <1> ; 26/11/2020 1497 00001B2B 7305 <1> jnc short VIDEO_RETURN 1498 <1> 1499 <1> ; 26/11/2020 1500 <1> _video_func_err: 1501 00001B2D 31C0 <1> xor eax, eax ; function call failed 1502 00001B2F 48 <1> dec eax ; 0FFFFFFFFh ; - 1 1503 00001B30 EB05 <1> jmp short _video_return 1504 <1> 1505 <1> ; 12/05/2016 1506 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 1507 <1> 1508 <1> ;----- NORMAL RETURN FROM ALL VIDEO RETURNS 1509 <1> 1510 <1> VIDEO_RETURN: 1511 00001B32 A1[44890100] <1> mov eax, [video_eax] ; 12/05/2016 1512 <1> _video_return: 1513 00001B37 FA <1> cli ; 02/01/2017 1514 00001B38 5D <1> pop ebp ; ******** ; 26/11/2020 1515 00001B39 5F <1> pop edi ; ******* 1516 00001B3A 5E <1> pop esi ; ****** 1517 00001B3B 5B <1> pop ebx ; ***** 1518 <1> M15: ; VIDEO_RETURN_C 1519 <1> ;;15/01/2017 1520 <1> ; 02/01/2017 1521 <1> ;;mov byte [intflg], 0 1522 <1> ; 1523 00001B3C 59 <1> pop ecx ; **** ; 26/11/2020 1524 00001B3D 5A <1> pop edx ; *** 1525 00001B3E 1F <1> pop ds ; ** 1526 00001B3F 07 <1> pop es ; * ; RECOVER SEGMENTS 1527 00001B40 CF <1> iretd ; ALL DONE 1528 <1> 1529 <1> set_txt_mode: 1530 <1> 1531 <1> ; 29/07/2016 1532 <1> ; 27/06/2016 1533 00001B41 B003 <1> mov al, 3 ; 26/11/2020 (bit 7 = 0) 1534 <1> 1535 <1> ; 17/11/2020 (TRDOS v2.0.3) 1536 <1> ;mov byte [noclearmem], 0 1537 <1> 1538 <1> ; 04/08/2022 1539 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 1540 <1> ; 12/04/2021 1541 <1> ; 10/08/2016 1542 <1> ; 08/08/2016 1543 <1> ; 30/07/2016 1544 <1> ; 29/07/2016 1545 <1> ; 25/07/2016 - 26/07/2016 - 27/07/2016 1546 <1> ; 07/07/2016 - 18/07/2016 - 23/07/2016 1547 <1> ; 02/07/2016 - 03/07/2016 - 04/07/2016 1548 <1> ; 26/06/2016 1549 <1> ; 24/06/2016 (set_txt_mode -> _set_mode) 1550 <1> ; 17/06/2016 1551 <1> ; 29/05/2016 1552 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 1553 <1> 1554 <1> _set_mode: 1555 <1> ; 12/12/2020 1556 <1> ; 26/11/2020 1557 <1> ; call from 'biosfn_set_video_mode' 1558 <1> ; (bochs/plex86 video bios code) 1559 <1> ; call from 'SET_MODE' 1560 <1> ; (TRDOS 386 v2 default, IBM PC/AT rom bios code) 1561 <1> ; continue from 'set_txt_mode' 1562 <1> 1563 <1> ; INPUT: 1564 <1> ; al = VGA video mode 1565 <1> ; RETURN: 1566 <1> ; cf = 1 -> video mode not implemented 1567 <1> ; cf = 0 -> OK 1568 <1> ; 1569 <1> ; Modified registers: eax, bx, ecx, esi, edi, (ebp) 1570 <1> 1571 <1> ; 17/11/2020 (TRDOS v2.0.3) 1572 <1> ; no clear memory option 1573 <1> ; (from mode number byte bit 7) 1574 00001B43 88C4 <1> mov ah, al 1575 00001B45 80E480 <1> and ah, 80h 1576 <1> ;mov [noclearmem], al 1577 00001B48 8825[53890100] <1> mov [noclearmem], ah 1578 <1> ;and al, 7Fh ; clear bit 7 1579 <1> ;;xor [noclearmem], al ; clear bit 0 to 6 1580 <1> ; 26/11/2020 1581 00001B4E 30E0 <1> xor al, ah ; and al, 7Fh 1582 <1> 1583 <1> ; 19/11/2020 1584 <1> 1585 <1> ; Video mode 03h action principle: 1586 <1> ; 1587 <1> ; for case 1: 1588 <1> ; Current mode is 03h and next/requested mode is not 03h 1589 <1> ; - save mode (set mode 03h flag) 1590 <1> ; - save 8 video pages (which are will be restored) 1591 <1> ; - save active page number (which will be reactivated) 1592 <1> ; - set active page to 0 always (no multi screen) 1593 <1> ; - save 8 cursor positions (which will be restored) 1594 <1> ; - use 'noclearmem' option 1595 <1> ; [p_crt_mode] = 0 -> 03h 1596 <1> ; 1597 <1> ; for case 2: 1598 <1> ; Current mode is 03h and next/requested mode is also 03h 1599 <1> ; - clear active video page if 'noclearmem' is not set 1600 <1> ; [p_crt_mode] = 0 -> 80h -> 0 1601 <1> ; 1602 <1> ; for case 3: 1603 <1> ; Current mode is not 03h and next/requested mode is 03h 1604 <1> ; - restore video pages (8 video pages were saved) 1605 <1> ; - restore active page number (which were saved) 1606 <1> ; - restore 8 cursor positions (which were saved) 1607 <1> ; - reset/clear mode 03h flag 1608 <1> ; [p_crt_mode] = 03h -> 0 1609 <1> ; 1610 <1> ; for case 4: 1611 <1> ; Current mode is not 03h and next/requested mode is not 03h 1612 <1> ; - use 'noclearmem' option 1613 <1> ; - set active page to 0 always 1614 <1> ; [p_crt_mode] = 03h -> 83h -> 03h 1615 <1> ; 1616 <1> ; initial (boot time) values: 1617 <1> ; [p_crt_mode] = 0 ("there isn't a page backup, yet") 1618 <1> ; [CRT_MODE] = 3 (kernel's starting mode) 1619 <1> 1620 <1> ; 26/11/2020 1621 00001B50 3C03 <1> cmp al, 03h ; mode 3, 80x25 text, 16 colors 1622 00001B52 7515 <1> jne short _sm_0 ; (default mode for TRDOS 386 mainprog) 1623 <1> 1624 <1> ; case 2 or case 3 1625 <1> 1626 <1> ; check current video mode if it is 03h 1627 00001B54 08E4 <1> or ah, ah ; 80h or 0 ('noclearmem' option) 1628 00001B56 7521 <1> jnz short _sm_1 ; do not clear display page 1629 <1> 1630 <1> ; 26/11/2020 1631 <1> ; Note: 1632 <1> ; [CRT_MODE] = 0FFh for VESA VBE video modes 1633 <1> ; [video_mode] = standard VGA and VESA VBE video modes 1634 <1> 1635 00001B58 3805[DE670000] <1> cmp [CRT_MODE], al ; 03h 1636 00001B5E 7520 <1> jne short _sm_2 ; case 3 ([p_crt_mode] = 03h) 1637 <1> 1638 <1> ; case 2 1639 <1> 1640 <1> ; [p_crt_mode] = 0 1641 <1> 1642 <1> ; 19/11/2020 1643 <1> ; If '_set_mode' procedure is called for video mode 3 1644 <1> ; while video mode is 3, video page will be cleared 1645 <1> ; and cursor position of video page will be reset. 1646 <1> 1647 <1> ; clear display page 1648 00001B60 C605[51890100]80 <1> mov byte [p_crt_mode], 80h ; clear page sign 1649 00001B67 EB1C <1> jmp short _sm_3 ; bypass save video page routine 1650 <1> _sm_0: 1651 <1> ; case 1 or case 4 1652 <1> 1653 <1> ; 05/12/2020 1654 00001B69 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 ; is current mode 03h? 1655 00001B70 7507 <1> jne short _sm_1 ; case 4 ; [p_crt_mode] = 03h 1656 <1> 1657 <1> ; case 1 1658 <1> ; [p_crt_mode] = 0 1659 <1> 1660 <1> ; 19/11/2020 1661 <1> ; If '_set_mode' procedure is called for a video mode 1662 <1> ; except video mode 3 while current video mode 1663 <1> ; is 3, all video pages of mode 3 will be copied 1664 <1> ; to 98000h address as backup, before mode change. 1665 <1> 1666 <1> _sm_save_pm: 1667 <1> ; 12/12/2020 1668 <1> ;; 03/07/2016 1669 <1> ;; save video pages 1670 <1> ;mov esi, 0B8000h 1671 <1> ;mov edi, 98000h ; 30/07/2016 1672 <1> ;mov ecx, (0B8000h-0B0000h)/4 1673 <1> ;rep movsd 1674 <1> 1675 <1> ;mov byte [p_crt_mode], 3 ; previous mode, backup sign 1676 <1> ;; 26/11/2020 1677 <1> ;xchg cl, [ACTIVE_PAGE] 1678 <1> ;mov [p_crt_page], cl ; save as previous active page 1679 <1> ; 1680 <1> ;; save cursor positions 1681 <1> ;mov esi, CURSOR_POSN 1682 <1> ;mov edi, cursor_pposn ; cursor positions backup 1683 <1> ;mov cl, 4 1684 <1> ;rep movsd 1685 <1> 1686 <1> ; 12/12/2020 1687 00001B72 E86E020000 <1> call save_mode3_multiscreen 1688 <1> 1689 <1> ; 29/07/2016 1690 <1> ;;mov [ACTIVE_PAGE], cl ; 0 1691 <1> ;xchg cl, [ACTIVE_PAGE] 1692 <1> ;mov [p_crt_page], cl ; previous page (for mode 3) 1693 <1> 1694 <1> ; [ACTIVE_PAGE] = 0 1695 <1> 1696 00001B77 EB07 <1> jmp short _sm_2 ; case 1 - 19/11/2020 1697 <1> _sm_1: 1698 <1> ; 26/11/2020 1699 <1> ; 19/11/2020 1700 <1> 1701 <1> ; case 4 1702 00001B79 800D[51890100]80 <1> or byte [p_crt_mode], 80h 1703 <1> ; here [p_crt_mode] must be 83h 1704 <1> ; (for case 4) 1705 <1> ; (because video mode 03h 1706 <1> ; was changed before as in case 1) 1707 <1> 1708 <1> _sm_2: ; case 4 (jump to _sm_2) - 19/11/2020 1709 <1> 1710 <1> ; 19/11/2020 1711 <1> ; case 3 1712 <1> ; If '_set_mode' procedure is called for video mode 3 1713 <1> ; while video mode is not 3 and if there is video 1714 <1> ; page backup for video mode 3, all (of 8) mode 3 1715 <1> ; video pages will be restored from 98000h. 1716 <1> 1717 00001B80 A2[DE670000] <1> mov [CRT_MODE], al ; save mode in global variable 1718 <1> _sm_3: 1719 <1> ; 04/08/2022 (TRDOS 386 v2.0.5) 1720 <1> ; 30/07/2016 1721 <1> ; 26/07/2016 1722 <1> ; 25/07/2016 1723 <1> ; set_mode_vga: 1724 <1> ; 18/07/2016 1725 <1> ; 14/07/2016 1726 <1> ; 09/07/2016 1727 <1> ; 04/07/2016 1728 <1> ; 03/07/2016 (TRDOS 386 = TRDOS v2.0) 1729 <1> ; /// video mode 13h /// 1730 <1> ; derived from 'Plex86/Bochs VGABios' source code 1731 <1> ; vgabios-0.7a (2011) 1732 <1> ; by the LGPL VGABios developers Team (2001-2008) 1733 <1> ; 'vgabios.c', 'vgatables.h' 1734 <1> ; 1735 <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 1736 <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm') 1737 <1> ; 1738 00001B85 88C4 <1> mov ah, al 1739 00001B87 B910000000 <1> mov ecx, vga_mode_count 1740 00001B8C BE[FA670000] <1> mov esi, vga_modes 1741 00001B91 31DB <1> xor ebx, ebx 1742 <1> _sm_4: 1743 00001B93 AC <1> lodsb 1744 00001B94 38C4 <1> cmp ah, al 1745 00001B96 7406 <1> je short _sm_5 1746 00001B98 FEC3 <1> inc bl 1747 00001B9A E2F7 <1> loop _sm_4 1748 <1> 1749 <1> ; UNIMPLEMENTED VIDEO MODE ! 1750 <1> ;xor eax, eax 1751 <1> ;mov [video_eax], eax ; 0 1752 <1> 1753 <1> ; 26/11/2020 1754 00001B9C F9 <1> stc ; unimplemented video mode ! (cf=1) 1755 <1> 1756 00001B9D C3 <1> retn 1757 <1> 1758 <1> ;----- EBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE 1759 <1> 1760 <1> _sm_5: ; 25/07/2016 1761 <1> ;mov esi, ebx 1762 <1> ;add esi, vga_memmodel 1763 <1> ;mov al, [esi] 1764 <1> ; 19/11/2020 1765 00001B9E 8A83[4A680000] <1> mov al, [ebx+vga_memmodel] 1766 00001BA4 A2[6A890100] <1> mov [VGA_MTYPE], al 1767 <1> 1768 00001BA9 89DF <1> mov edi, ebx 1769 00001BAB 81C7[5A680000] <1> add edi, vga_dac_s 1770 00001BB1 C0E302 <1> shl bl, 2 ; byte -> dword 1771 00001BB4 81C3[0A680000] <1> add ebx, vga_mode_tbl_ptr 1772 <1> 1773 <1> ;mov dword [VGA_BASE], 0B8000h 1774 <1> ;cmp ah, 0Dh ; [CRT_MODE] 1775 <1> ;jb short M9 1776 <1> ;mov dword [VGA_BASE], 0A0000h 1777 <1> ;M9: 1778 00001BBA 8B33 <1> mov esi, [ebx] 1779 00001BBC 89F3 <1> mov ebx, esi 1780 00001BBE 83C614 <1> add esi, vga_p_cm_pos ; ebx + 20 1781 00001BC1 668B06 <1> mov ax, [esi] ; get the cursor mode from the table 1782 00001BC4 66A3[F7670000] <1> mov [CURSOR_MODE], ax ; save cursor mode (initial value) 1783 <1> ; al = 6, ah = 7 1784 <1> ; al = 0Dh, ah = 0Eh ; 25/07/2016 1785 00001BCA E893020000 <1> call cursor_shape_fix 1786 <1> ; al = 14, ah = 15 (If [CHAR_HEIGHT] = 16) 1787 00001BCF 668906 <1> mov [esi], ax 1788 <1> 1789 00001BD2 56 <1> push esi ; * 1790 <1> 1791 <1> ; 17/04/2021 1792 00001BD3 B603 <1> mov dh, 03h 1793 <1> ; 1794 00001BD5 8A25[E5670000] <1> mov ah, [VGA_MODESET_CTL] 1795 00001BDB 80E408 <1> and ah, 8 ; default palette loading ? 1796 00001BDE 7520 <1> jnz short _sm_6 1797 <1> ;mov dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register) 1798 <1> ; 17/04/2021 1799 00001BE0 B2C6 <1> mov dl, 0C6h 1800 00001BE2 B0FF <1> mov al, 0FFh ; PEL mask 1801 00001BE4 EE <1> out dx, al 1802 00001BE5 8A27 <1> mov ah, [edi] ; DAC model (selection number) 1803 00001BE7 E8F80F0000 <1> call load_dac_palette 1804 <1> ; ecx = 0 1805 00001BEC F605[E5670000]02 <1> test byte [VGA_MODESET_CTL], 2 ; gray scale summing 1806 00001BF3 740B <1> jz short _sm_6 1807 00001BF5 53 <1> push ebx 1808 00001BF6 29DB <1> sub ebx, ebx ; sub bl, bl 1809 <1> ;mov cx, 256 1810 <1> ; 02/08/2022 1811 <1> ;sub ecx, ecx 1812 <1> ; ecx = 0 1813 00001BF8 FEC5 <1> inc ch 1814 <1> ; ecx = 256 1815 00001BFA E837100000 <1> call gray_scale_summing 1816 00001BFF 5B <1> pop ebx 1817 <1> _sm_6: 1818 <1> ; Reset Attribute Ctl flip-flop 1819 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 1820 <1> ; 17/03/2021 1821 00001C00 B2DA <1> mov dl, 0DAh ; dx = 3DAh 1822 00001C02 EC <1> in al, dx 1823 <1> ; Set Attribute Ctl 1824 00001C03 89DE <1> mov esi, ebx ; addr of params tbl for selected mode 1825 00001C05 83C623 <1> add esi, 35 ; actl regs 1826 00001C08 30E4 <1> xor ah, ah ; 0 1827 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 1828 <1> ; 17/04/2021 1829 00001C0A B2C0 <1> mov dl, 0C0h 1830 <1> _sm_7: 1831 00001C0C 88E0 <1> mov al, ah 1832 00001C0E EE <1> out dx, al ; index 1833 00001C0F AC <1> lodsb 1834 <1> ; DX = 3C0h = VGAREG_ACTL_WRITE_DATA 1835 00001C10 EE <1> out dx, al ; value 1836 00001C11 FEC4 <1> inc ah 1837 00001C13 80FC14 <1> cmp ah, 20 ; number of actl registers 1838 00001C16 72F4 <1> jb short _sm_7 1839 <1> ; 1840 00001C18 88E0 <1> mov al, ah ; 20 1841 00001C1A EE <1> out dx, al ; index 1842 00001C1B 28C0 <1> sub al, al ; 0 1843 00001C1D EE <1> out dx, al ; value 1844 <1> ; 1845 <1> ; Set Sequencer Ctl 1846 00001C1E 89DE <1> mov esi, ebx ; addr of params tbl for selected mode 1847 00001C20 83C605 <1> add esi, 5 ; sequ regs 1848 <1> ; 1849 <1> ;mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 1850 <1> ; 17/04/2021 1851 00001C23 B2C4 <1> mov dl, 0C4h 1852 00001C25 EE <1> out dx, al ; 0 1853 <1> ;inc dx ; 3C5h ; VGAREG_SEQU_DATA 1854 <1> ; 17/04/2021 1855 00001C26 FEC2 <1> inc dl ; dx = 3C5h 1856 00001C28 B003 <1> mov al, 3 1857 00001C2A EE <1> out dx, al 1858 00001C2B B401 <1> mov ah, 1 1859 <1> _sm_8: 1860 00001C2D 88E0 <1> mov al, ah 1861 <1> ;mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 1862 <1> ;dec dx 1863 <1> ; 17/04/2021 1864 00001C2F FECA <1> dec dl ; dx = 3C4h 1865 00001C31 EE <1> out dx, al ; index 1866 00001C32 AC <1> lodsb 1867 <1> ;inc dx ; 3C5h ; VGAREG_SEQU_DATA 1868 <1> ; 17/04/2021 1869 00001C33 FEC2 <1> inc dl 1870 00001C35 EE <1> out dx, al 1871 00001C36 80FC04 <1> cmp ah, 4 ; number of sequ regs 1872 00001C39 7304 <1> jnb short _sm_9 1873 00001C3B FEC4 <1> inc ah 1874 00001C3D EBEE <1> jmp short _sm_8 1875 <1> _sm_9: 1876 <1> ; Set Grafx Ctl 1877 00001C3F 89DE <1> mov esi, ebx ; addr of params tbl for selected mode 1878 00001C41 83C637 <1> add esi, 55 ; grdc regs 1879 00001C44 30E4 <1> xor ah, ah ; 0 1880 <1> _sm_10: 1881 00001C46 88E0 <1> mov al, ah 1882 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 1883 <1> ; 17/04/2021 1884 00001C48 B2CE <1> mov dl, 0CEh 1885 00001C4A EE <1> out dx, al 1886 00001C4B AC <1> lodsb 1887 <1> ;inc dx ; 3CFh ; VGAREG_GRDC_DATA 1888 <1> ; 17/04/2021 1889 00001C4C FEC2 <1> inc dl ; 3CFh 1890 00001C4E EE <1> out dx, al 1891 00001C4F FEC4 <1> inc ah 1892 00001C51 80FC09 <1> cmp ah, 9 ; number of grdc regs 1893 00001C54 72F0 <1> jb short _sm_10 1894 <1> ; 1895 <1> ; Disable CRTC write protection 1896 <1> ;mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 1897 <1> ; 17/04/2021 1898 00001C56 B2D4 <1> mov dl, 0D4h 1899 <1> ;mov al, 11h 1900 <1> ;out dx, al 1901 <1> ;inc dx 1902 <1> ;sub al, al 1903 <1> ;out dx, al 1904 00001C58 66B81100 <1> mov ax, 11h 1905 00001C5C 66EF <1> out dx, ax 1906 00001C5E 89DE <1> mov esi, ebx ; addr of params tbl for selected mode 1907 00001C60 83C60A <1> add esi, 10 ; crtc regs 1908 <1> ; ah = 0 1909 <1> _sm_11: 1910 00001C63 88E0 <1> mov al, ah 1911 <1> ; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS 1912 00001C65 EE <1> out dx, al ; index 1913 00001C66 AC <1> lodsb 1914 <1> ;inc dx ; VGAREG_VGA_CRTC_ADDRESS + 1 1915 <1> ; 17/04/2021 1916 00001C67 FEC2 <1> inc dl 1917 00001C69 EE <1> out dx, al ; value 1918 00001C6A 80FC18 <1> cmp ah, 24 ; number of crtc registers - 1 1919 00001C6D 7306 <1> jnb short _sm_12 1920 00001C6F FEC4 <1> inc ah 1921 <1> ;dec dx ; 3D4h 1922 <1> ; 17/04/2021 1923 00001C71 FECA <1> dec dl 1924 00001C73 EBEE <1> jmp short _sm_11 1925 <1> _sm_12: 1926 <1> ; Set the misc register 1927 <1> ;mov dx, 3CCh ; VGAREG_READ_MISC_OUTPUT 1928 <1> ; 17/04/2021 1929 00001C75 B2CC <1> mov dl, 0CCh 1930 00001C77 8A4309 <1> mov al, [ebx+9] ; misc reg 1931 00001C7A EE <1> out dx, al 1932 <1> ; 1933 <1> ; Enable video 1934 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 1935 <1> ; 17/04/2021 1936 00001C7B B2C0 <1> mov dl, 0C0h 1937 00001C7D B020 <1> mov al, 20h 1938 00001C7F EE <1> out dx, al ; set bit 5 to 1 1939 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 1940 <1> ; 17/04/2021 1941 00001C80 B2DA <1> mov dl, 0DAh 1942 00001C82 EC <1> in al, dx 1943 <1> ; 1944 <1> ; 17/11/2020 1945 <1> ;cmp byte [noclearmem], 0 1946 <1> ;ja short _sm_15 1947 <1> 1948 00001C83 F605[53890100]80 <1> test byte [noclearmem], 80h 1949 00001C8A 753B <1> jnz short _sm_15 1950 <1> 1951 <1> ; 29/07/2016 1952 00001C8C 31C0 <1> xor eax, eax 1953 <1> ;mov ecx, 4000h ; 16K words (32K) 1954 <1> ; 02/08/2022 1955 00001C8E 29C9 <1> sub ecx, ecx 1956 00001C90 B540 <1> mov ch, 40h 1957 <1> ; ecx = 4000h 1958 00001C92 803D[6A890100]02 <1> cmp byte [VGA_MTYPE], 2 ; CTEXT, MTEXT, CGA 1959 00001C99 7715 <1> ja short _sm_14 ; no ? (0A0000h) 1960 00001C9B BF00800B00 <1> mov edi, 0B8000h 1961 00001CA0 7409 <1> je short _sm_13 ; CGA graphics mode 1962 <1> ; 08/08/2016 1963 00001CA2 A3[66890100] <1> mov [VGA_INT43H], eax ; 0 ; default font 1964 00001CA7 66B82007 <1> mov ax, 0720h ; CGA text mode 1965 <1> _sm_13: 1966 00001CAB F366AB <1> rep stosw 1967 00001CAE EB17 <1> jmp short _sm_15 1968 <1> 1969 <1> _sm_14: 1970 00001CB0 BF00000A00 <1> mov edi, 0A0000h 1971 <1> ; ecx = 16384 dwords (64K) 1972 <1> ;mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 1973 <1> ; 17/04/2021 1974 00001CB5 B2C4 <1> mov dl, 0C4h 1975 00001CB7 B002 <1> mov al, 2 1976 00001CB9 EE <1> out dx, al 1977 <1> ;mov dx, 3C5h ; VGAREG_SEQU_DATA 1978 <1> ;inc dx 1979 <1> ; 17/04/2021 1980 00001CBA FEC2 <1> inc dl ; 3C5h 1981 00001CBC EC <1> in al, dx ; mmask 1982 <1> ;push ax 1983 <1> ; 12/04/2021 1984 00001CBD 50 <1> push eax 1985 00001CBE B00F <1> mov al, 0Fh ; all planes 1986 00001CC0 EE <1> out dx, al 1987 00001CC1 30C0 <1> xor al, al ; 0 1988 00001CC3 F3AB <1> rep stosd ; ecx = 163684 (64K) 1989 <1> ;pop ax 1990 <1> ; 12/04/2021 1991 00001CC5 58 <1> pop eax 1992 00001CC6 EE <1> out dx, al ; mmask 1993 <1> _sm_15: 1994 <1> ; ebx = addr of params tbl for selected mode 1995 <1> ; 10/08/2016 1996 00001CC7 668B03 <1> mov ax, [ebx] ; num of columns, 'twidth' 1997 00001CCA A2[E0670000] <1> mov [CRT_COLS], al 1998 <1> ;; 26/07/2016 1999 <1> ;; CRTC_ADDRESS = 3D4h (always) 2000 <1> ;mov ah, [ebx+1] ; num of rows, 'theightm1' 2001 00001CCF FEC4 <1> inc ah ; 09/07/2016 2002 00001CD1 8825[E6670000] <1> mov [VGA_ROWS], ah 2003 <1> ; 10/08/2016 2004 00001CD7 8A4302 <1> mov al, [ebx+2] 2005 00001CDA A2[E2670000] <1> mov [CHAR_HEIGHT], al 2006 <1> ; 29/07/2016 2007 <1> ; length of regen buffer in bytes 2008 00001CDF 668B4B03 <1> mov cx, [ebx+3] ; 'slength_l' 2009 00001CE3 66890D[54890100] <1> mov [CRT_LEN], cx 2010 <1> ; 2011 <1> ; 27/07/2016 2012 00001CEA 30E4 <1> xor ah, ah 2013 00001CEC A0[EE7C0100] <1> mov al, [ACTIVE_PAGE] ; may be > 0 for mode 3 2014 <1> ;mul word [CRT_LEN] ; 4096 for mode 3 2015 00001CF1 66F7E1 <1> mul cx ; 29/07/2016 2016 00001CF4 66A3[DC7C0100] <1> mov [CRT_START], ax 2017 <1> ; 2018 00001CFA B060 <1> mov al, 60h 2019 <1> ;cmp byte [noclearmem], 0 2020 <1> ;jna short _sm_16 2021 <1> ;add al, 80h 2022 00001CFC 0A05[53890100] <1> or al, [noclearmem] ; 17/11/2020 2023 <1> _sm_16: 2024 00001D02 A2[E3670000] <1> mov [VGA_VIDEO_CTL], al 2025 00001D07 C605[E4670000]F9 <1> mov byte [VGA_SWITCHES], 0F9h 2026 00001D0E 8025[E5670000]7F <1> and byte [VGA_MODESET_CTL], 7Fh 2027 <1> 2028 00001D15 5E <1> pop esi ; * 2029 <1> 2030 <1> ; 26/07/2016 2031 <1> ; 07/07/2016 2032 00001D16 668B0D[F7670000] <1> mov cx, [CURSOR_MODE] ; restore cursor mode (initial value) 2033 00001D1D 66870E <1> xchg cx, [esi] ; cl = start line, ch = end line 2034 <1> ; reset to initial value 2035 00001D20 86CD <1> xchg ch, cl ; ch = start line, cl = end line 2036 00001D22 66890D[F7670000] <1> mov [CURSOR_MODE], cx ; save (fixed) cursor mode 2037 <1> 2038 <1> ; 27/07/2016 2039 00001D29 803D[6A890100]02 <1> cmp byte [VGA_MTYPE], 2 ; CTEXT, MTEXT 2040 00001D30 7317 <1> jnb short _sm_17 2041 <1> 2042 <1> ; Set cursor shape 2043 <1> ;mov cx, 0607h 2044 <1> ;call _set_ctype 2045 <1> 2046 <1> ; 29/07/2016 2047 00001D32 B40A <1> mov ah, 10 ; 6845 register for cursor set 2048 00001D34 E81F060000 <1> call m16 ; output cx register 2049 <1> 2050 <1> ; 25/07/2016 2051 00001D39 803D[DE670000]03 <1> cmp byte [CRT_MODE], 03h 2052 00001D40 7507 <1> jne short _sm_17 2053 <1> ; 26/07/2016 2054 <1> 2055 00001D42 A0[EE7C0100] <1> mov al, [ACTIVE_PAGE] 2056 00001D47 EB0B <1> jmp short _sm_18 2057 <1> _sm_17: 2058 <1> ; Set cursor pos for page 0..7 2059 <1> ;sub ax, ax ; eax = 0 2060 00001D49 29C0 <1> sub eax, eax ; 17/11/2020 2061 00001D4B BF[DE7C0100] <1> mov edi, CURSOR_POSN 2062 00001D50 AB <1> stosd 2063 00001D51 AB <1> stosd 2064 00001D52 AB <1> stosd 2065 00001D53 AB <1> stosd 2066 <1> ;; Set active page 0 2067 <1> ;mov [ACTIVE_PAGE], al ; 0 2068 <1> _sm_18: 2069 <1> ; 29/07/2016 2070 00001D54 803D[6A890100]02 <1> cmp byte [VGA_MTYPE], 2 ; CTEXT, MTEXT 2071 <1> ;jnb _sm_23 2072 <1> ; 04/08/2022 2073 00001D5B 7205 <1> jb short _sm_24 2074 00001D5D E90C020000 <1> jmp _set_active_page 2075 <1> _sm_24: 2076 <1> ;cmp byte [CHAR_HEIGHT], 16 2077 <1> ;je short _sm_19 2078 <1> 2079 <1> ;; copy and activate 8x16 font 2080 <1> 2081 <1> ; 26/07/2016 2082 00001D62 B004 <1> mov al, 04h 2083 <1> ;sub bl, bl 2084 <1> ; AX = 1104H ; Load ROM 8x16 Character Set 2085 <1> ; (BL = font block to load (EGA: 0-3; VGA: 0-7)) 2086 00001D64 E844160000 <1> call load_text_8_16_pat 2087 <1> 2088 <1> ; video_func_1103h: 2089 <1> ; biosfn_set_text_block_specifier: 2090 <1> ; BL = font block selector code 2091 <1> ; NOTE: TRDOS 386 only uses and sets font block 0 2092 <1> ; (It is as BL = 0 for TRDOS 386) 2093 00001D69 66BAC403 <1> mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 2094 <1> ;;mov ah, bl 2095 <1> ;sub ah, ah ; 0 2096 <1> ;mov al, 03h 2097 <1> ; 19/11/2020 2098 00001D6D 66B80300 <1> mov ax, 03h 2099 00001D71 66EF <1> out dx, ax 2100 <1> _sm_19: 2101 <1> ; 29/07/2016 2102 <1> ; 26/07/2016 2103 <1> ; 24/06/2016 2104 <1> ;mov edi, 0B8000h 2105 <1> ;mov cx, 4000h ; 16K words (32K) 2106 <1> ; 2107 00001D73 30C0 <1> xor al, al 2108 00001D75 3805[51890100] <1> cmp [p_crt_mode], al ; 0 2109 00001D7B 7705 <1> ja short _sm_20 ; 03h, 80h or 83h 2110 <1> 2111 <1> ; case 1 - 19/11/2020 2112 <1> ; 2113 <1> ; If [pc_crt_mode] = 0, that means, previous mode is 03h 2114 <1> ; and current mode is not 03h (case 1) 2115 <1> 2116 <1> ; 30/07/2016 2117 <1> ; 24/06/2016 2118 <1> ; TRDOS 386 (TRDOS v2) 'set mode' modification 2119 <1> ; (for multiscreen feature): 2120 <1> ; If '_set_mode' procedure is called for video mode 3 2121 <1> ; while video mode is 3, video page will be cleared 2122 <1> ; and cursor position of video page will be reset. 2123 <1> ; If '_set_mode' procedure is called for a video mode 2124 <1> ; except video mode 3, while current video mode 2125 <1> ; is 3, all video pages of mode 3 will be copied 2126 <1> ; to 98000h address as backup, before mode change. 2127 <1> ; If '_set_mode' procedure is called for video mode 3 2128 <1> ; while video mode is not 3 and if there is video 2129 <1> ; page backup for video mode 3, all (of 8) mode 3 2130 <1> ; video pages will be restored from 98000h. 2131 <1> 2132 <1> ; 19/11/2020 2133 <1> ;mov [ACTIVE_PAGE], al ; 0 2134 <1> 2135 <1> ; Here, 2136 <1> ; video memory already cleared if [noclearmem] <> 80h 2137 <1> 2138 <1> ;mov ax, 0720h 2139 <1> ;mov cx, 4000h ; 16K words (32K) 2140 <1> ;mov edi, 0B8000h 2141 <1> ;rep stosw 2142 <1> ;sub al, al 2143 <1> 2144 <1> ;jmp short _sm_23 2145 <1> 2146 <1> ; Set hardware side for the new active video page 2147 <1> 2148 00001D7D E9EC010000 <1> jmp _set_active_page ; 19/11/2020 2149 <1> 2150 <1> _sm_20: 2151 <1> ; 19/11/2020 2152 <1> ; case 2 or case 3 or case 4 - 19/11/2020 2153 <1> 2154 <1> ; 19/11/2020 2155 00001D82 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 ; new video mode 2156 00001D89 754E <1> jne short _sm_22 ; al = 0 (& video mode <> 03h) 2157 <1> ; case 4 - 19/11/2020 2158 <1> ; ([p_crt_mode] = 83h) 2159 <1> 2160 <1> ; case 2 or case 3 - 19/11/2020 2161 <1> 2162 <1> ;movzx ebx, byte [ACTIVE_PAGE] 2163 <1> ; 19/11/2020 2164 00001D8B A0[52890100] <1> mov al, [p_crt_page] ; previous mode 3 active page 2165 <1> ;movzx ebx, al 2166 <1> ;shl bl, 1 ; * 2 2167 <1> ;add ebx, CURSOR_POSN 2168 <1> 2169 <1> ; 29/07/2016 2170 00001D90 F605[51890100]7F <1> test byte [p_crt_mode], 7Fh ; 83h or 80h or 03h 2171 00001D97 740F <1> jz short _sm_21 ; do not restore video pages 2172 <1> ; case 2 - 19/11/2020 2173 <1> ; case 3 - 19/11/2020 2174 <1> 2175 <1> ; ([p_crt_mode] = 03h) 2176 <1> 2177 <1> ; New video mode is 3 while current video mode is not 3 2178 <1> ; (multi screen) video pages will be restored from 098000h 2179 <1> 2180 <1> ; 19/11/2020 2181 00001D99 A2[EE7C0100] <1> mov [ACTIVE_PAGE], al ; current mode 3 active page 2182 <1> 2183 <1> ; 12/12/2020 2184 <1> ;; restore video pages 2185 <1> ;mov esi, 98000h ; 30/07/2016 2186 <1> ;mov edi, 0B8000h 2187 <1> ;mov cx, 2000h ; 8K dwords (32K) 2188 <1> ;rep movsd 2189 <1> ; 2190 <1> ;; 19/11/2020 2191 <1> ;mov [p_crt_mode], cl ; reset ('case 3' end condition) 2192 <1> ; 2193 <1> ;; restore cursor positions 2194 <1> ;mov esi, cursor_pposn 2195 <1> ;mov edi, CURSOR_POSN 2196 <1> ;;mov ecx, 4 ; restore all cursor positions (16 bytes) 2197 <1> ;mov cl, 4 2198 <1> ;rep movsd 2199 <1> 2200 <1> ; 12/12/2020 2201 00001D9E E89A000000 <1> call _restore_mode3_multiscreen 2202 <1> 2203 <1> ;jmp short _sm_23 ; do not clear current video pages 2204 <1> 2205 <1> ; 19/11/2020 2206 00001DA3 E9C6010000 <1> jmp _set_active_page 2207 <1> 2208 <1> _sm_21: 2209 <1> ; 19/11/2020 2210 <1> ; case 2 2211 <1> ; 2212 <1> ; ([p_crt_mode] = 80h) 2213 <1> ; 2214 <1> ; User has requested to set video mode 3 again while 2215 <1> ; current video mode is 3.. that means, set mode 03h 2216 <1> ; parameters again and clear video page. 2217 <1> ; ('noclearmem' option effects the result) 2218 <1> 2219 <1> ; 19/11/2020 2220 00001DA8 F605[53890100]80 <1> test byte [noclearmem], 80h 2221 00001DAF 7528 <1> jnz short _sm_22 ; 'do not clear video memory' 2222 <1> ; continue with current text 2223 <1> ; (user's option/choice) 2224 <1> ; clear video page 2225 <1> ;mov cx, [CRT_LEN] ; 4096 2226 <1> ;shr cx, 1 ; 2048 ; 16/11/2020 2227 00001DB1 66B82007 <1> mov ax, 0720h 2228 <1> ; 26/11/2020 2229 <1> ;mov ecx, 2048 ; 4096/2 2230 <1> ; 02/08/2022 2231 00001DB5 29C9 <1> sub ecx, ecx 2232 00001DB7 B508 <1> mov ch, 08h 2233 <1> ; ecx = 0800h 2234 00001DB9 BF00800B00 <1> mov edi, 0B8000h ; [crt_base] 2235 00001DBE 66033D[DC7C0100] <1> add di, [CRT_START] 2236 00001DC5 F366AB <1> rep stosw ; FILL THE REGEN BUFFER WITH BLANKS 2237 <1> ; 2238 <1> ; 19/11/2020 2239 00001DC8 A0[EE7C0100] <1> mov al, [ACTIVE_PAGE] ; 0 to 7 (for video mode 3) 2240 00001DCD 0FB6D8 <1> movzx ebx, al 2241 00001DD0 D0E3 <1> shl bl, 1 2242 00001DD2 66898B[DE7C0100] <1> mov [ebx+CURSOR_POSN], cx ; reset cursor position 2243 <1> _sm_22: 2244 <1> ;mov [p_crt_mode], al ; 0 ; reset 2245 <1> ; 19/11/2020 2246 <1> ;and byte [p_crt_mode], 3 ; 83h -> 3, 80h -> 0 2247 00001DD9 8025[51890100]7F <1> and byte [p_crt_mode], 7Fh ; 83h -> 3, 80h -> 0 2248 <1> _sm_23: 2249 <1> ; al = video page number 2250 <1> ; [CRT_LEN] = length of regen buffer in bytes 2251 <1> ;call _set_active_page 2252 <1> ; 16/11/2020 2253 00001DE0 E989010000 <1> jmp _set_active_page 2254 <1> 2255 <1> ;----- NORMAL RETURN FROM ALL VIDEO RETURNS 2256 <1> ;retn 2257 <1> 2258 <1> save_mode3_multiscreen: 2259 <1> ; 02/08/2022 (TRDOS v2.0.5) 2260 <1> ; 12/12/2020 (TRDOS v2.0.3) 2261 <1> ; save mode 03h video pages and cursor positions 2262 <1> ; 2263 <1> ; Modified registers: ecx (=0), esi, edi 2264 <1> 2265 <1> ; 12/12/2020 2266 <1> ; moved here from '_set_mode' 2267 <1> ; 03/07/2016 2268 <1> ; save video pages 2269 00001DE5 BE00800B00 <1> mov esi, 0B8000h 2270 00001DEA BF00800900 <1> mov edi, 98000h ; 30/07/2016 2271 <1> ;mov ecx, (0B8000h-0B0000h)/4 2272 <1> ; 02/08/2022 2273 00001DEF 29C9 <1> sub ecx, ecx 2274 00001DF1 B520 <1> mov ch, 20h 2275 <1> ; ecx = 2000h 2276 00001DF3 F3A5 <1> rep movsd 2277 <1> 2278 00001DF5 C605[51890100]03 <1> mov byte [p_crt_mode], 3 ; previous mode, backup sign 2279 <1> ; 26/11/2020 2280 00001DFC 860D[EE7C0100] <1> xchg cl, [ACTIVE_PAGE] 2281 00001E02 880D[52890100] <1> mov [p_crt_page], cl ; save as previous active page 2282 <1> 2283 <1> ; save cursor positions 2284 00001E08 BE[DE7C0100] <1> mov esi, CURSOR_POSN 2285 00001E0D BF[56890100] <1> mov edi, cursor_pposn ; cursor positions backup 2286 00001E12 B104 <1> mov cl, 4 2287 00001E14 F3A5 <1> rep movsd 2288 00001E16 C3 <1> retn 2289 <1> 2290 <1> restore_mode3_multiscreen: 2291 <1> ; 02/08/2022 (TRDOS v2.0.5) 2292 <1> ; 12/12/2020 (TRDOS v2.0.3) 2293 <1> ; restore mode 03h video pages and cursor positions 2294 <1> ; 2295 <1> ; Input: 2296 <1> ; settings from the last 'save_mode3_multiscreen' 2297 <1> ; 2298 <1> ; Output: 2299 <1> ; AL = active video page = [ACTIVE_PAGE] 2300 <1> ; 2301 <1> ; Modified registers: al, ecx (=0), esi, edi 2302 <1> 2303 00001E17 A0[52890100] <1> mov al, [p_crt_page] ; previous mode 3 active page 2304 00001E1C A2[EE7C0100] <1> mov [ACTIVE_PAGE], al ; current mode 3 active page 2305 <1> 2306 <1> ; 12/12/2020 2307 <1> ; moved here from 'vesa_vbe3_pmi' 2308 <1> 2309 <1> ; 07/12/2020 2310 <1> ; restore CRT_START according to ACTIVE_PAGE 2311 <1> ;mov [CRT_START], cx ; 0 2312 <1> ; 12/12/2020 2313 00001E21 66C705[DC7C0100]00- <1> mov word [CRT_START], 0 2313 00001E29 00 <1> 2314 <1> 2315 <1> ; check active page and set it again if it is not 0 2316 00001E2A 08C0 <1> or al, al 2317 <1> ;;jz short vbe3_pmi_7 2318 <1> ;jz short _restore_mode3_multiscreen 2319 00001E2C 740F <1> jz short r_m3_ms_1 2320 00001E2E 88C1 <1> mov cl, al 2321 <1> ;vbe3_pmi_5: 2322 <1> r_m3_ms_0: 2323 00001E30 668105[DC7C0100]00- <1> add word [CRT_START], 4096 2323 00001E38 10 <1> 2324 00001E39 FEC9 <1> dec cl 2325 <1> ;jnz short vbe3_pmi_5 2326 00001E3B 75F3 <1> jnz short r_m3_ms_0 2327 <1> r_m3_ms_1: 2328 <1> ; 12/12/2020 2329 <1> ; moved here from '_set_mode' 2330 <1> _restore_mode3_multiscreen: 2331 <1> ; Modified registers: ecx, esi, edi 2332 <1> 2333 <1> ; restore video pages 2334 00001E3D BE00800900 <1> mov esi, 98000h ; 30/07/2016 2335 00001E42 BF00800B00 <1> mov edi, 0B8000h 2336 <1> ;mov cx, 2000h ; 8K dwords (32K) 2337 <1> ;mov ecx, 2000h 2338 <1> ; 02/08/2022 2339 00001E47 29C9 <1> sub ecx, ecx 2340 00001E49 B520 <1> mov ch, 20h 2341 <1> ; ecx = 2000h 2342 00001E4B F3A5 <1> rep movsd 2343 <1> 2344 <1> ; 19/11/2020 2345 00001E4D 880D[51890100] <1> mov [p_crt_mode], cl ; reset ('case 3' end condition) 2346 <1> 2347 <1> ; restore cursor positions 2348 00001E53 BE[56890100] <1> mov esi, cursor_pposn 2349 00001E58 BF[DE7C0100] <1> mov edi, CURSOR_POSN 2350 <1> ;mov ecx, 4 ; restore all cursor positions (16 bytes) 2351 00001E5D B104 <1> mov cl, 4 2352 00001E5F F3A5 <1> rep movsd 2353 00001E61 C3 <1> retn 2354 <1> 2355 <1> cursor_shape_fix: 2356 <1> ; 12/04/2021 2357 <1> ; 07/07/2016 2358 <1> ; (Cursor start and cursor end line values -6,7- 2359 <1> ; will be fixed depending on character height) 2360 <1> ; 2361 <1> ; derived from 'Plex86/Bochs VGABios' source code 2362 <1> ; vgabios-0.7a (2011) 2363 <1> ; by the LGPL VGABios developers Team (2001-2008) 2364 <1> ; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)' 2365 <1> ; 2366 <1> ; INPUT -> 2367 <1> ; AL = cursor start line (=6) 2368 <1> ; AH = cursor end line (=7) 2369 <1> ; OUTPUT -> 2370 <1> ; AL = cursor start line (=14) 2371 <1> ; AH = cursor end line (=15) 2372 <1> ; 2373 <1> ;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20)) 2374 <1> 2375 <1> ;test byte [VGA_MODESET_CTL], 1 ; VGA active 2376 <1> ;jz short csf_3 2377 00001E62 803D[E2670000]08 <1> cmp byte [CHAR_HEIGHT], 8 2378 00001E69 7647 <1> jna short csf_3 2379 00001E6B 80FC08 <1> cmp ah, 8 2380 00001E6E 7342 <1> jnb short csf_3 2381 00001E70 3C20 <1> cmp al, 20h 2382 00001E72 733E <1> jnb short csf_3 2383 <1> ; 2384 <1> ;push ax 2385 <1> ; 12/04/2021 2386 00001E74 50 <1> push eax 2387 <1> ; { 2388 <1> ; if(CL!=(CH+1)) 2389 00001E75 FEC0 <1> inc al 2390 00001E77 38C4 <1> cmp ah, al ; ah != al + 1 2391 00001E79 740F <1> je short csf_1 2392 <1> ; CH = ((CH+1) * cheight / 8) -1; 2393 00001E7B 8A25[E2670000] <1> mov ah, [CHAR_HEIGHT] 2394 00001E81 F6E4 <1> mul ah 2395 00001E83 C0E803 <1> shr al, 3 ; / 8 2396 00001E86 FEC8 <1> dec al ; - 1 2397 00001E88 EB0E <1> jmp short csf_2 2398 <1> csf_1: 2399 <1> ; } 2400 <1> ; else ; ah = al + 1 2401 <1> ; { 2402 00001E8A FEC4 <1> inc ah ; ah = ah + 1 2403 <1> ; CH = ((CL+1) * cheight / 8) - 2; 2404 00001E8C A0[E2670000] <1> mov al, [CHAR_HEIGHT] 2405 00001E91 F6E4 <1> mul ah 2406 00001E93 C0E803 <1> shr al, 3 ; / 8 2407 00001E96 2C02 <1> sub al, 2 ; - 2 2408 <1> ; al = 14 (if [CHAR_HEIGHT] = 16) 2409 <1> csf_2: 2410 00001E98 880424 <1> mov [esp], al 2411 00001E9B 8A642401 <1> mov ah, [esp+1] 2412 <1> ; CL = ((CL+1) * cheight / 8) - 1; 2413 00001E9F FEC4 <1> inc ah 2414 00001EA1 A0[E2670000] <1> mov al, [CHAR_HEIGHT] 2415 00001EA6 F6E4 <1> mul ah 2416 00001EA8 C0E803 <1> shr al, 3 ; / 8 2417 00001EAB FEC8 <1> dec al ; - 1 2418 00001EAD 88442401 <1> mov [esp+1], al 2419 <1> ; ah = 15 (if [CHAR_HEIGHT] = 16) 2420 <1> ; 2421 <1> ;pop ax 2422 <1> ; 12/04/2021 2423 00001EB1 58 <1> pop eax 2424 <1> csf_3: 2425 00001EB2 C3 <1> retn 2426 <1> 2427 <1> SET_CTYPE: 2428 <1> ; 04/08/2022 (TRDOS 386 v2.0.5) 2429 <1> ; 12/09/2016 2430 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2431 00001EB3 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 2432 <1> ;ja VIDEO_RETURN ; 12/09/2016 2433 <1> ; 04/08/2022 2434 00001EBA 7738 <1> ja short set_cpos_inv_vp 2435 00001EBC E805000000 <1> call _set_ctype 2436 00001EC1 E96CFCFFFF <1> jmp VIDEO_RETURN 2437 <1> 2438 <1> _set_ctype: 2439 <1> ; 02/09/2014 (Retro UNIX 386 v1) 2440 <1> ; 2441 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2442 <1> 2443 <1> ; (CH) = BITS 4-0 = START LINE FOR CURSOR 2444 <1> ; ** HARDWARE WILL ALWAYS CAUSE BLINK 2445 <1> ; ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING 2446 <1> ; OR NO CURSOR AT ALL 2447 <1> ; (CL) = BITS 4-0 = END LINE FOR CURSOR 2448 <1> 2449 <1> ;------------------------------------------------ 2450 <1> ; SET_CTYPE 2451 <1> ; THIS ROUTINE SETS THE CURSOR VALUE 2452 <1> ; INPUT 2453 <1> ; (CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE 2454 <1> ; OUTPUT 2455 <1> ; NONE 2456 <1> ;------------------------------------------------ 2457 <1> 2458 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 2459 <1> ; 2460 <1> ; 07/07/2016 2461 <1> ; Fixing cursor start and stop line depending on 2462 <1> ; current character height (=16) 2463 <1> ; (Note: Default/initial values are 6 and 7. 2464 <1> ; If set values are 6 (start) & 7 (stop) and 2465 <1> ; [CHAR_HEIGHT] = 16 : 2466 <1> ; After fixing, start line will be 14, stop line 2467 <1> ; will be 15.) 2468 <1> 2469 <1> ;mov ax, cx 2470 <1> ; 02/08/2022 2471 00001EC6 89C8 <1> mov eax, ecx 2472 <1> 2473 00001EC8 86E0 <1> xchg al, ah 2474 <1> ; AL = start line, AH = stop line 2475 00001ECA E893FFFFFF <1> call cursor_shape_fix 2476 <1> ; AL = start line (fixed), AH = stop line (fixed) 2477 <1> ;mov cx, ax 2478 <1> ; 02/08/2022 2479 00001ECF 89C1 <1> mov ecx, eax 2480 00001ED1 86CD <1> xchg ch, cl 2481 <1> ; CH = start line (fixed), CL = stop line (fixed) 2482 <1> ; 2483 00001ED3 B40A <1> mov ah, 10 ; 6845 register for cursor set 2484 00001ED5 66890D[F7670000] <1> mov [CURSOR_MODE], cx ; save in data area 2485 <1> ;call m16 ; output cx register 2486 <1> ;retn 2487 00001EDC E977040000 <1> jmp m16 2488 <1> 2489 <1> SET_CPOS: 2490 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 2491 <1> ; 12/09/2016 2492 <1> ; 07/07/2016 2493 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2494 00001EE1 80FF07 <1> cmp bh, 7 ; video page > 7 ; 07/07/2016 2495 <1> ;ja VIDEO_RETURN 2496 <1> ; 02/08/2022 2497 00001EE4 770E <1> ja short set_cpos_inv_vp 2498 <1> ; 2499 00001EE6 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 2500 00001EED 770A <1> ja short vga_set_cpos ; 12/09/2016 2501 00001EEF E839040000 <1> call _set_cpos 2502 <1> set_cpos_inv_vp: ; 02/08/2022 2503 00001EF4 E939FCFFFF <1> jmp VIDEO_RETURN 2504 <1> 2505 <1> vga_set_cpos: 2506 <1> ; 12/09/2016 2507 <1> ; 09/07/2016 2508 <1> ; set cursor position 2509 <1> ; NOTE: Hardware cursor position will not be set 2510 <1> ; in any VGA modes (>7) 2511 <1> ; But, cursor position will be saved into 2512 <1> ; [CURSOR_POSN]. 2513 <1> ; TRDOS 386 (TRDOS v2.0) uses only one page 2514 <1> ; (page 0) for all graphics modes. 2515 <1> 2516 00001EF9 668915[DE7C0100] <1> mov [CURSOR_POSN], dx ; save cursor pos for pg 0 2517 <1> ; 04/08/2016 2518 <1> ;mov bh, [ACTIVE_PAGE] ; = 0 2519 <1> ;call _set_cpos 2520 00001F00 E92DFCFFFF <1> jmp VIDEO_RETURN 2521 <1> 2522 <1> READ_CURSOR: 2523 <1> ; 12/09/2016 2524 <1> ; 07/07/2016 2525 <1> ; 12/05/2016 2526 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2527 <1> ; 2528 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2529 <1> 2530 <1> ;------------------------------------------------------ 2531 <1> ; READ_CURSOR 2532 <1> ; THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE 2533 <1> ; 845, FORMATS IT, AND SENDS IT BACK TO THE CALLER 2534 <1> ; INPUT 2535 <1> ; BH - PAGE OF CURSOR 2536 <1> ; OUTPUT 2537 <1> ; DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION 2538 <1> ; CX - CURRENT CURSOR MODE 2539 <1> ;------------------------------------------------------ 2540 <1> 2541 <1> ; BH = Video page number (0 to 7) 2542 <1> 2543 <1> ; 07/07/2016 2544 00001F05 80FF07 <1> cmp bh, 7 ; video page > 7 (invalid) 2545 00001F08 7606 <1> jna short read_cursor_1 2546 <1> ; invalid video page (input) 2547 00001F0A 31C9 <1> xor ecx, ecx ; 0 2548 00001F0C 31D2 <1> xor edx, edx ; 0 2549 00001F0E EB15 <1> jmp short read_cursor_2 2550 <1> read_cursor_1: 2551 <1> ; 12/09/2016 2552 00001F10 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; vga mode 2553 00001F17 7727 <1> ja short vga_get_cpos 2554 <1> ; 2555 00001F19 E815000000 <1> call get_cpos 2556 00001F1E 0FB70D[F7670000] <1> movzx ecx, word [CURSOR_MODE] 2557 <1> read_cursor_2: 2558 00001F25 5D <1> pop ebp 2559 00001F26 5F <1> pop edi 2560 00001F27 5E <1> pop esi 2561 00001F28 5B <1> pop ebx 2562 00001F29 58 <1> pop eax ; DISCARD SAVED CX AND DX 2563 00001F2A 58 <1> pop eax 2564 00001F2B A1[44890100] <1> mov eax, [video_eax] ; 12/05/2016 2565 <1> ;;15/01/2017 2566 <1> ;;mov byte [intflg], 0 ; 07/01/2017 2567 00001F30 1F <1> pop ds 2568 00001F31 07 <1> pop es 2569 00001F32 CF <1> iretd 2570 <1> 2571 <1> get_cpos: 2572 <1> ; 12/05/2016 2573 <1> ; 16/01/2016 2574 <1> ; BH = Video page number (0 to 7) 2575 <1> ; 2576 00001F33 D0E7 <1> shl bh, 1 ; WORD OFFSET 2577 00001F35 0FB6F7 <1> movzx esi, bh 2578 00001F38 0FB796[DE7C0100] <1> movzx edx, word [esi+CURSOR_POSN] 2579 00001F3F C3 <1> retn 2580 <1> 2581 <1> vga_get_cpos: 2582 <1> ; 12/09/2016 2583 <1> ; get cursor position (vga) 2584 00001F40 0FB715[DE7C0100] <1> movzx edx, word [CURSOR_POSN] ; cursor pos for pg 0 2585 00001F47 31C9 <1> xor ecx, ecx ; Cursor Mode = 0 (invalid) 2586 00001F49 EBDA <1> jmp short read_cursor_2 2587 <1> 2588 <1> ACT_DISP_PAGE: 2589 <1> ; 07/07/2016 2590 <1> ; 26/06/2016 2591 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2592 <1> ; 2593 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2594 <1> ; 2595 <1> ;----------------------------------------------------- 2596 <1> ; ACT_DISP_PAGE 2597 <1> ; THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING 2598 <1> ; THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT 2599 <1> ; INPUT 2600 <1> ; AL HAS THE NEW ACTIVE DISPLAY PAGE 2601 <1> ; OUTPUT 2602 <1> ; THE 6845 IS RESET TO DISPLAY THAT PAGE 2603 <1> ;----------------------------------------------------- 2604 <1> ; 07/07/2016 2605 00001F4B 3C07 <1> cmp al, 7 ; > 7 = invalid video page number 2606 <1> ;ja VIDEO_RETURN 2607 00001F4D 7715 <1> ja short adp_2 ; 18/11/2020 2608 <1> ;cmp byte [CRT_MODE], 3 2609 <1> ;je short adp_1 2610 <1> ; 18/11/2020 2611 00001F4F 8A25[DE670000] <1> mov ah, [CRT_MODE] 2612 00001F55 80FC03 <1> cmp ah, 3 2613 00001F58 7605 <1> jna short adp_1 ; mode 01h, 00h (01h), 02h (03h), 03h 2614 00001F5A 80FC07 <1> cmp ah, 7 ; mode 07h (03h) 2615 00001F5D 7505 <1> jne short adp_2 2616 <1> ;and al, al 2617 <1> ;jnz VIDEO_RETURN 2618 <1> ;;sub al, al ; 0 ; force to page 0 2619 <1> adp_1: 2620 00001F5F E805000000 <1> call set_active_page 2621 <1> adp_2: 2622 00001F64 E9C9FBFFFF <1> jmp VIDEO_RETURN 2623 <1> 2624 <1> set_active_page: ; tty_sw 2625 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 2626 <1> ; 09/12/2017 2627 <1> ; 26/07/2016 2628 <1> ; 26/06/2016 2629 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2630 <1> ; 30/06/2015 2631 <1> ; 04/03/2014 (act_disp_page --> tty_sw) 2632 <1> ; 10/12/2013 2633 <1> ; 04/12/2013 2634 <1> ; 2635 00001F69 A2[EE7C0100] <1> mov [ACTIVE_PAGE], al ; save active page value ; [ptty] 2636 <1> _set_active_page: 2637 <1> ; 27/06/2015 2638 <1> ;movzx ebx, al 2639 <1> ; 02/08/2022 2640 00001F6E 0FB6C0 <1> movzx eax, al 2641 00001F71 89C3 <1> mov ebx, eax 2642 <1> ; 2643 <1> ;cbw ; 07/09/2014 (ah=0) 2644 <1> ; 02/08/2022 2645 <1> ;sub ah, ah ; 09/12/2017 2646 00001F73 66F725[54890100] <1> mul word [CRT_LEN] ; get saved length of regen buffer 2647 <1> ; display page times regen length 2648 <1> ; 10/12/2013 2649 00001F7A 66A3[DC7C0100] <1> mov [CRT_START], ax ; save start address for later 2650 <1> ;mov cx, ax ; start address to cx 2651 <1> ; 02/08/2022 2652 00001F80 89C1 <1> mov ecx, eax 2653 <1> _M16: 2654 <1> ;;sar cx, 1 2655 <1> ;shr cx, 1 ; divide by 2 for 6845 handling 2656 <1> ; 02/08/2022 2657 00001F82 D1E9 <1> shr ecx, 1 2658 00001F84 B40C <1> mov ah, 12 ; 6845 register for start address 2659 00001F86 E8CD030000 <1> call m16 2660 <1> ;sal bx, 1 2661 <1> ; 01/09/2014 2662 00001F8B D0E3 <1> shl bl, 1 ; *2 for word offset 2663 00001F8D 81C3[DE7C0100] <1> add ebx, CURSOR_POSN 2664 00001F93 668B13 <1> mov dx, [ebx] ; get cursor for this page 2665 <1> ; 16/01/2016 2666 <1> ;call m18 2667 <1> ;retn 2668 00001F96 E9A9030000 <1> jmp m18 2669 <1> 2670 <1> position: 2671 <1> ; 02/08/2022 - TRDOS 386 v2.0.5 2672 <1> ; 17/04/2021 - TRDOS 386 v2.0.4 2673 <1> ; 24/06/2016 2674 <1> ; 12/05/2016 - TRDOS 386 (TRDOS v2.0) 2675 <1> ; 27/06/2015 2676 <1> ; 02/09/2014 2677 <1> ; 30/08/2014 (Retro UNIX 386 v1) 2678 <1> ; 04/12/2013 (Retro UNIX 8086 v1) 2679 <1> ; 2680 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2681 <1> ; 2682 <1> ;----------------------------------------- 2683 <1> ; POSITION 2684 <1> ; THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS 2685 <1> ; OF A CHARACTER IN THE ALPHA MODE 2686 <1> ; INPUT 2687 <1> ; AX = ROW, COLUMN POSITION 2688 <1> ; OUTPUT 2689 <1> ; AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 2690 <1> ;----------------------------------------- 2691 <1> 2692 <1> ; DX = ROW, COLUMN POSITION 2693 <1> ;movzx eax, byte [CRT_COLS] ; 27/06/2015 2694 00001F9B 31C0 <1> xor eax, eax ; 02/09/2014 2695 00001F9D B050 <1> mov al, 80 ; determine bytes to row 2696 00001F9F F6E6 <1> mul dh ; row value 2697 <1> ;xor dh, dh ; 0 2698 <1> ;add ax, dx ; add column value to the result 2699 <1> ; 16/04/2021 2700 00001FA1 00D0 <1> add al, dl 2701 00001FA3 80D400 <1> adc ah, 0 2702 <1> ; 02/08/2022 2703 00001FA6 D1E0 <1> shl eax, 1 2704 <1> ;shl ax, 1 ; * 2 for attribute bytes 2705 <1> ; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 2706 00001FA8 C3 <1> retn 2707 <1> 2708 <1> find_position: 2709 <1> ; 17/04/2021 - TRDOS 386 v2.0.4 2710 <1> ; 24/06/2016 2711 <1> ; 12/05/2016 - TRDOS 386 (TRDOS v2.0) 2712 <1> ; 27/06/2015 2713 <1> ; 07/09/2014 2714 <1> ; 02/09/2014 2715 <1> ; 30/08/2014 (Retro UNIX 386 v1) 2716 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2717 <1> 2718 00001FA9 0FB6CF <1> movzx ecx, bh ; video page number 2719 <1> ; 17/04/2021 2720 <1> ;mov esi, ecx 2721 <1> ;shl si, 1 2722 <1> ;mov dx, [esi+CURSOR_POSN] 2723 <1> ;jz short p21 2724 <1> ;xor si, si 2725 <1> ; 17/04/2021 2726 00001FAC 31F6 <1> xor esi, esi 2727 00001FAE D0E1 <1> shl cl, 1 2728 00001FB0 668B91[DE7C0100] <1> mov dx, [ecx+CURSOR_POSN] 2729 00001FB7 740B <1> jz short p21 2730 00001FB9 D0E9 <1> shr cl, 1 2731 <1> p20: 2732 00001FBB 660335[54890100] <1> add si, [CRT_LEN] ; 24/06/2016 2733 <1> ;add si, 80*25*2 ; add length of buffer for one page 2734 00001FC2 E2F7 <1> loop p20 2735 <1> p21: 2736 00001FC4 6621D2 <1> and dx, dx 2737 00001FC7 7407 <1> jz short p22 2738 00001FC9 E8CDFFFFFF <1> call position ; determine location in regen in page 2739 00001FCE 01C6 <1> add esi, eax ; add location to start of regen page 2740 <1> p22: 2741 <1> ;mov dx, [addr_6845] ; get base address of active display 2742 <1> ;mov dx, 03D4h ; I/O address of color card 2743 <1> ;add dx, 6 ; point at status port 2744 00001FD0 66BADA03 <1> mov dx, 03DAh ; status port 2745 <1> ; cx = 0 2746 00001FD4 C3 <1> retn 2747 <1> 2748 <1> SCROLL_UP: 2749 <1> ; 04/08/2022 (TRDOS 386 v2.0.5) 2750 <1> ; 07/07/2016 2751 <1> ; 26/06/2016 2752 <1> ; 12/05/2016 2753 <1> ; 30/01/2016 2754 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2755 <1> ; 07/09/2014 2756 <1> ; 02/09/2014 2757 <1> ; 01/09/2014 (Retro UNIX 386 v1 - beginning) 2758 <1> ; 04/04/2014 2759 <1> ; 04/12/2013 2760 <1> ; 2761 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 2762 <1> ; 2763 <1> ;---------------------------------------------- 2764 <1> ; SCROLL UP 2765 <1> ; THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP 2766 <1> ; ON THE SCREEN 2767 <1> ; INPUT 2768 <1> ; (AH) = CURRENT CRT MODE 2769 <1> ; (AL) = NUMBER OF ROWS TO SCROLL 2770 <1> ; (CX) = ROW/COLUMN OF UPPER LEFT CORNER 2771 <1> ; (DX) = ROW/COLUMN OF LOWER RIGHT CORNER 2772 <1> ; (BH) = ATTRIBUTE TO BE USED ON BLANKED LINE 2773 <1> ; (DS) = DATA SEGMENT 2774 <1> ; (ES) = REGEN BUFFER SEGMENT 2775 <1> ; OUTPUT 2776 <1> ; NONE -- THE REGEN BUFFER IS MODIFIED 2777 <1> ;-------------------------------------------- 2778 <1> 2779 <1> ; 07/07/2016 2780 00001FD5 38F5 <1> cmp ch, dh 2781 <1> ;ja VIDEO_RETURN 2782 <1> ; 04/08/2022 2783 00001FD7 7709 <1> ja short _s_u_retn 2784 <1> 2785 00001FD9 38D1 <1> cmp cl, dl 2786 <1> ;ja VIDEO_RETURN 2787 <1> ; 04/08/2022 2788 00001FDB 7705 <1> ja short _s_u_retn 2789 <1> ; 2790 00001FDD E805000000 <1> call _scroll_up 2791 <1> _s_u_retn: 2792 00001FE2 E94BFBFFFF <1> jmp VIDEO_RETURN 2793 <1> 2794 <1> _scroll_up: ; from 'write_tty' 2795 <1> ; 2796 <1> ; cl = left upper column 2797 <1> ; ch = left upper row 2798 <1> ; dl = right lower column 2799 <1> ; dh = right lower row 2800 <1> ; 2801 <1> ; al = line count 2802 <1> ; bl = attribute to be used on blanked line 2803 <1> ; bh = video page number (0 to 7) 2804 <1> 2805 00001FE7 E89B000000 <1> call test_line_count ; 16/01/2016 2806 <1> 2807 00001FEC 8A25[DE670000] <1> mov ah, [CRT_MODE] ; current video mode 2808 <1> ;;cmp byte [CRT_MODE], 4 2809 <1> ;cmp ah, 4 ; 07/07/2016 2810 <1> ;jnb GRAPHICS_UP ; 26/06/2016 2811 <1> ; 18/11/2020 2812 00001FF2 80FC04 <1> cmp ah, 4 2813 00001FF5 720A <1> jb short n0 2814 00001FF7 80FC07 <1> cmp ah, 7 ; TEST FOR BW CARD 2815 <1> ; (80x25 text, mono) 2816 00001FFA 7405 <1> je short n0 ; same with mode 3 for TRDOS 386 2817 00001FFC E91B050000 <1> jmp GRAPHICS_UP 2818 <1> n0: 2819 <1> ; 07/07/2016 2820 00002001 80FF07 <1> cmp bh, 7 ; video page number 2821 00002004 7606 <1> jna short n1 2822 00002006 8A3D[EE7C0100] <1> mov bh, [ACTIVE_PAGE] 2823 <1> n1: 2824 0000200C 88DC <1> mov ah, bl ; attribute 2825 <1> ;push ax ; * 2826 <1> ; 12/04/2021 2827 0000200E 50 <1> push eax ; * 2828 <1> ;mov esi, [CRT_BASE] 2829 0000200F BE00800B00 <1> mov esi, 0B8000h 2830 00002014 3A3D[EE7C0100] <1> cmp bh, [ACTIVE_PAGE] 2831 0000201A 750B <1> jne short n2 2832 <1> ; 2833 0000201C 66A1[DC7C0100] <1> mov ax, [CRT_START] 2834 00002022 6601C6 <1> add si, ax 2835 00002025 EB11 <1> jmp short n4 2836 <1> n2: 2837 00002027 20FF <1> and bh, bh 2838 00002029 740D <1> jz short n4 2839 0000202B 88F8 <1> mov al, bh 2840 <1> n3: 2841 0000202D 660335[54890100] <1> add si, [CRT_LEN] 2842 00002034 FEC8 <1> dec al 2843 00002036 75F5 <1> jnz short n3 2844 <1> n4: 2845 00002038 E85B000000 <1> call scroll_position ; 16/01/2016 2846 0000203D 7420 <1> jz short n6 2847 <1> 2848 0000203F 01CE <1> add esi, ecx ; from address for scroll 2849 00002041 88F5 <1> mov ch, dh ; #rows in block 2850 00002043 28C5 <1> sub ch, al ; #rows to be moved 2851 <1> n5: 2852 00002045 E88A000000 <1> call n10 ; 16/01/2016 2853 <1> 2854 0000204A 51 <1> push ecx 2855 0000204B 0FB60D[E0670000] <1> movzx ecx, byte [CRT_COLS] 2856 00002052 00C9 <1> add cl, cl 2857 00002054 01CE <1> add esi, ecx ; next line 2858 00002056 01CF <1> add edi, ecx 2859 00002058 59 <1> pop ecx 2860 <1> 2861 00002059 FECD <1> dec ch ; count of lines to move 2862 0000205B 75E8 <1> jnz short n5 ; row loop 2863 <1> ; ch = 0 2864 0000205D 88C6 <1> mov dh, al ; #rows 2865 <1> n6: 2866 <1> ; attribute in ah 2867 0000205F B020 <1> mov al, ' ' ; fill with blanks 2868 <1> n7: 2869 00002061 E87B000000 <1> call n11 ; 16/01/2016 2870 <1> 2871 00002066 8A0D[E0670000] <1> mov cl, [CRT_COLS] 2872 0000206C 00C9 <1> add cl, cl 2873 0000206E 01CF <1> add edi, ecx 2874 <1> 2875 00002070 FECE <1> dec dh 2876 00002072 75ED <1> jnz short n7 2877 <1> n16: 2878 00002074 3A3D[EE7C0100] <1> cmp bh, [ACTIVE_PAGE] 2879 0000207A 750A <1> jne short n8 2880 <1> 2881 <1> ;cmp byte [CRT_MODE], 7 ; is this the black and white card 2882 <1> ;je short n8 ; if so, skip the mode reset 2883 <1> 2884 0000207C A0[DF670000] <1> mov al, [CRT_MODE_SET] ; get the value of mode set 2885 00002081 66BAD803 <1> mov dx, 03D8h ; always set color card port 2886 00002085 EE <1> out dx, al 2887 <1> n8: 2888 00002086 C3 <1> retn 2889 <1> 2890 <1> test_line_count: 2891 <1> ; 12/04/2021 2892 <1> ; 12/05/2016 2893 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2894 <1> ; 07/09/2014 (scroll_up) 2895 00002087 08C0 <1> or al, al 2896 00002089 740C <1> jz short al_set2 2897 <1> ;push dx 2898 <1> ; 12/04/2021 2899 0000208B 52 <1> push edx 2900 0000208C 28EE <1> sub dh, ch ; subtract upper row from lower row number 2901 0000208E FEC6 <1> inc dh ; adjust difference by 1 2902 00002090 38C6 <1> cmp dh, al ; line count = amount of rows in window? 2903 00002092 7502 <1> jne short al_set1 ; if not the we're all set 2904 00002094 30C0 <1> xor al, al ; otherwise set al to zero 2905 <1> al_set1: 2906 <1> ;pop dx 2907 <1> ; 12/04/2021 2908 00002096 5A <1> pop edx 2909 <1> al_set2: 2910 00002097 C3 <1> retn 2911 <1> 2912 <1> scroll_position: 2913 <1> ; 12/04/2021 2914 <1> ; 26/06/2016 2915 <1> ; 30/01/2016 2916 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 2917 <1> ; 07/09/2014 (scroll_up) 2918 <1> 2919 <1> ; (*) [esp+4] = ax (al = line count, ah = attribute) 2920 <1> 2921 <1> ;push dx 2922 <1> ; 12/04/2021 2923 00002098 52 <1> push edx 2924 00002099 6689CA <1> mov dx, cx ; now, upper left position in DX 2925 0000209C E8FAFEFFFF <1> call position 2926 000020A1 01C6 <1> add esi, eax 2927 000020A3 89F7 <1> mov edi, esi 2928 <1> ;pop dx ; lower right position in DX 2929 <1> ; 12/04/2021 2930 000020A5 5A <1> pop edx 2931 000020A6 6629CA <1> sub dx, cx 2932 000020A9 FEC6 <1> inc dh ; dh = #rows 2933 000020AB FEC2 <1> inc dl ; dl = #cols in block 2934 000020AD 59 <1> pop ecx ; return address 2935 <1> ;pop ax ; * ; al = line count, ah = attribute 2936 <1> ; 12/04/2021 2937 000020AE 58 <1> pop eax ; (*) 2938 000020AF 51 <1> push ecx ; return address 2939 000020B0 0FB7C8 <1> movzx ecx, ax 2940 000020B3 8A25[E0670000] <1> mov ah, [CRT_COLS] 2941 000020B9 F6E4 <1> mul ah ; determine offset to from address 2942 <1> ;add ax, ax ; *2 for attribute byte 2943 <1> ; 02/08/2022 2944 <1> ;shl eax, 1 2945 000020BB 01C0 <1> add eax, eax 2946 <1> ; 2947 <1> ;push ax ; offset 2948 <1> ;push dx 2949 <1> ; 12/04/2021 2950 000020BD 50 <1> push eax ; offset 2951 000020BE 52 <1> push edx 2952 <1> ; 2953 <1> ; 04/04/2014 2954 000020BF 66BADA03 <1> mov dx, 3DAh ; guaranteed to be color card here 2955 <1> n9: ; wait_display_enable 2956 000020C3 EC <1> in al, dx ; get port 2957 000020C4 A808 <1> test al, RVRT ; wait for vertical retrace 2958 000020C6 74FB <1> jz short n9 ; wait_display_enable 2959 000020C8 B025 <1> mov al, 25h 2960 000020CA B2D8 <1> mov dl, 0D8h ; address control port 2961 000020CC EE <1> out dx, al ; turn off video during vertical retrace 2962 <1> ;pop dx ; #rows, #cols 2963 <1> ;pop ax ; offset 2964 <1> ; 12/04/2021 2965 000020CD 5A <1> pop edx ; #rows, #cols 2966 000020CE 58 <1> pop eax ; offset 2967 000020CF 6691 <1> xchg ax, cx ; 2968 <1> ; ecx = offset, al = line count, ah = attribute 2969 <1> ; 2970 000020D1 08C0 <1> or al, al 2971 000020D3 C3 <1> retn 2972 <1> n10: 2973 <1> ; Move rows 2974 000020D4 88D1 <1> mov cl, dl ; get # of cols to move 2975 000020D6 56 <1> push esi 2976 000020D7 57 <1> push edi ; save start address 2977 <1> n10r: 2978 000020D8 66A5 <1> movsw ; move that line on screen 2979 000020DA FEC9 <1> dec cl 2980 000020DC 75FA <1> jnz short n10r 2981 000020DE 5F <1> pop edi 2982 000020DF 5E <1> pop esi ; recover addresses 2983 000020E0 C3 <1> retn 2984 <1> n11: 2985 <1> ; Clear rows 2986 <1> ; dh = #rows 2987 000020E1 88D1 <1> mov cl, dl ; get # of cols to clear 2988 000020E3 57 <1> push edi ; save address 2989 <1> n11r: 2990 000020E4 66AB <1> stosw ; store fill character 2991 000020E6 FEC9 <1> dec cl 2992 000020E8 75FA <1> jnz short n11r 2993 000020EA 5F <1> pop edi ; recover address 2994 000020EB C3 <1> retn 2995 <1> 2996 <1> SCROLL_DOWN: 2997 <1> ; 12/04/2021 2998 <1> ; 07/07/2016 2999 <1> ; 27/06/2016 3000 <1> ; 26/06/2016 3001 <1> ; 12/05/2016 3002 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3003 <1> ; 3004 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3005 <1> 3006 <1> ;------------------------------------------ 3007 <1> ; SCROLL DOWN 3008 <1> ; THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED 3009 <1> ; BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES 3010 <1> ; WITH A DEFINED CHARACTER 3011 <1> ; INPUT 3012 <1> ; (AH) = CURRENT CRT MODE 3013 <1> ; (AL) = NUMBER OF LINES TO SCROLL 3014 <1> ; (CX) = UPPER LEFT CORNER OF RECION 3015 <1> ; (DX) = LOWER RIGHT CORNER OF REGION 3016 <1> ; (BH) = FILL CHARACTER 3017 <1> ; (DS) = DATA SEGMENT 3018 <1> ; (ES) = REGEN SEGMENT 3019 <1> ; OUTPUT 3020 <1> ; NONE -- SCREEN IS SCROLLED 3021 <1> ;------------------------------------------ 3022 <1> 3023 <1> ; 07/07/2016 3024 000020EC 38F5 <1> cmp ch, dh 3025 <1> ;ja VIDEO_RETURN 3026 000020EE 7709 <1> ja short _s_d_retn ; 18/11/2020 3027 000020F0 38D1 <1> cmp cl, dl 3028 <1> ;ja VIDEO_RETURN 3029 000020F2 7705 <1> ja short _s_d_retn ; 18/11/2020 3030 <1> ; 3031 000020F4 E805000000 <1> call _scroll_down 3032 <1> _s_d_retn: 3033 000020F9 E934FAFFFF <1> jmp VIDEO_RETURN 3034 <1> 3035 <1> _scroll_down: ; 27/06/2016 3036 <1> 3037 <1> ; cl = left upper column 3038 <1> ; ch = left upper row 3039 <1> ; dl = right lower column 3040 <1> ; dh = right lower row 3041 <1> ; 3042 <1> ; al = line count 3043 <1> ; bl = attribute to be used on blanked line 3044 <1> ; bh = video page number (0 to 7) 3045 <1> 3046 <1> ; !!!! 3047 000020FE FD <1> std ; DIRECTION FOR SCROLL DOWN 3048 <1> ; !!!! 3049 000020FF E883FFFFFF <1> call test_line_count ; 16/01/2016 3050 <1> 3051 00002104 8A25[DE670000] <1> mov ah, [CRT_MODE] ; current video mode 3052 <1> ;;cmp byte [CRT_MODE], 4 3053 <1> ;cmp ah, 4 ; 07/07/2016 3054 <1> ;jnb GRAPHICS_DOWN ; 26/06/2016 3055 <1> ; 18/11/2020 3056 0000210A 80FC04 <1> cmp ah, 4 3057 0000210D 720A <1> jb short _n0 3058 0000210F 80FC07 <1> cmp ah, 7 ; TEST FOR BW CARD 3059 <1> ; (80x25 text, mono) 3060 00002112 7405 <1> je short _n0 ; same with mode 3 for TRDOS 386 3061 00002114 E9D5060000 <1> jmp GRAPHICS_DOWN 3062 <1> _n0: 3063 <1> ; 07/07/2016 3064 00002119 80FF07 <1> cmp bh, 7 ; video page number 3065 0000211C 7606 <1> jna short n12 3066 0000211E 8A3D[EE7C0100] <1> mov bh, [ACTIVE_PAGE] 3067 <1> ; 3068 <1> n12: ; CONTINUE_DOWN 3069 00002124 88DC <1> mov ah, bl 3070 <1> ;push ax ; * ; save attribute in ah 3071 <1> ; 12/04/2021 3072 00002126 50 <1> push eax 3073 00002127 6689D0 <1> mov ax, dx ; LOWER RIGHT CORNER 3074 0000212A E869FFFFFF <1> call scroll_position ; GET REGEN LOCATION 3075 0000212F 741F <1> jz short n14 3076 00002131 29CE <1> sub esi, ecx ; SI IS FROM ADDRESS 3077 00002133 88F5 <1> mov ch, dh ; #rows in block 3078 00002135 28C5 <1> sub ch, al ; #rows to be moved 3079 <1> n13: 3080 00002137 E898FFFFFF <1> call n10 ; MOVE ONE ROW 3081 <1> 3082 0000213C 51 <1> push ecx 3083 0000213D 8A0D[E0670000] <1> mov cl, [CRT_COLS] 3084 00002143 00C9 <1> add cl, cl 3085 00002145 29CE <1> sub esi, ecx ; next line 3086 00002147 29CF <1> sub edi, ecx 3087 00002149 59 <1> pop ecx 3088 <1> 3089 0000214A FECD <1> dec ch ; count of lines to move 3090 0000214C 75E9 <1> jnz short n13 ; row loop 3091 <1> ; ch = 0 3092 0000214E 88C6 <1> mov dh, al ; #rows 3093 <1> n14: 3094 <1> ; attribute in ah 3095 00002150 B020 <1> mov al, ' ' ; fill with blanks 3096 <1> n15: 3097 00002152 E88AFFFFFF <1> call n11 ; 16/01/2016 3098 <1> 3099 00002157 8A0D[E0670000] <1> mov cl, [CRT_COLS] 3100 0000215D 00C9 <1> add cl, cl 3101 0000215F 29CF <1> sub edi, ecx 3102 <1> 3103 00002161 FECE <1> dec dh 3104 00002163 75ED <1> jnz short n15 3105 <1> ; 3106 <1> ; 18/11/2020 3107 00002165 FC <1> cld ; clear direction flag 3108 <1> ; 3109 00002166 E909FFFFFF <1> jmp n16 ; 27/06/2016 3110 <1> 3111 <1> ; cmp bh, [ACTIVE_PAGE] 3112 <1> ; jne short n16 3113 <1> ; 3114 <1> ; ;cmp byte [CRT_MODE], 7 ; is this the black and white card 3115 <1> ; ;je short n16 ; if so, skip the mode reset 3116 <1> ; 3117 <1> ; mov al, [CRT_MODE_SET] ; get the value of mode set 3118 <1> ; mov dx, 03D8h ; always set color card port 3119 <1> ; out dx, al 3120 <1> ;n16: 3121 <1> ; ; !!!! 3122 <1> ; cld ; Clear direction flag ! 3123 <1> ; ; !!!! 3124 <1> ; retn 3125 <1> 3126 <1> READ_AC_CURRENT: 3127 <1> ; 08/07/2016 3128 <1> ; 26/06/2016 3129 <1> ; 12/05/2016 3130 <1> ; 18/01/2016 3131 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3132 <1> ; 3133 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3134 <1> ; 3135 <1> ; 08/07/2016 3136 0000216B 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; 6!? 3137 00002172 7607 <1> jna short read_ac_c 3138 00002174 31C0 <1> xor eax, eax 3139 00002176 E9BCF9FFFF <1> jmp _video_return 3140 <1> read_ac_c: 3141 0000217B E805000000 <1> call _read_ac_current 3142 <1> ; 12/05/2016 3143 <1> ;jmp VIDEO_RETURN 3144 00002180 E9B2F9FFFF <1> jmp _video_return 3145 <1> 3146 <1> ;------------------------------------------------------------------------ 3147 <1> ; READ_AC_CURRENT : 3148 <1> ; THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT : 3149 <1> ; CURSOR POSITION AND RETURNS THEM TO THE CALLER : 3150 <1> ; INPUT : 3151 <1> ; (AH) = CURRENT CRT MODE : 3152 <1> ; (BH) = DISPLAY PAGE ( ALPHA MODES ONLY ) : 3153 <1> ; (DS) = DATA SEGMENT : 3154 <1> ; (ES) = REGEN SEGMENT : 3155 <1> ; OUTPUT : 3156 <1> ; (AL) = CHARACTER READ : 3157 <1> ; (AH) = ATTRIBUTE READ : 3158 <1> ;------------------------------------------------------------------------ 3159 <1> 3160 <1> _read_ac_current: 3161 <1> ; 26/06/2016 3162 <1> ; 12/05/2016 3163 <1> ; 18/01/2016 3164 <1> 3165 00002185 8A25[DE670000] <1> mov ah, [CRT_MODE] ; current video mode 3166 0000218B 80FC04 <1> cmp ah, 4 3167 0000218E 720A <1> jb short p10 3168 <1> ; 18/11/2020 3169 <1> ;cmp byte [CRT_MODE], 4 3170 <1> ;jnb GRAPHICS_READ ; 26/06/2016 3171 <1> 3172 00002190 80FC07 <1> cmp ah, 7 ; TEST FOR BW CARD (80x25 monochrome text) 3173 00002193 7405 <1> je short p10 ; same with mode 3 in TRDOS 386 3174 00002195 E9A0080000 <1> jmp GRAPHICS_READ 3175 <1> p10: 3176 0000219A E80AFEFFFF <1> call find_position ; GET REGEN LOCATION AND PORT ADDRESS 3177 <1> ; 3178 <1> ; esi = regen location 3179 <1> ; dx = status port 3180 <1> ; 3181 <1> 3182 <1> ; 18/11/2020 3183 <1> ; convert display mode to a zero value 3184 <1> ; for 80 column color mode 3185 <1> ;mov ah, [CRT_MODE] 3186 <1> ;sub ah, 2 3187 <1> ;shr ah, 1 3188 <1> ;jnz short p13 3189 <1> 3190 <1> ; 05/12/2020 3191 <1> ; 18/11/2020 (TRDOS 386 v2.0.3) 3192 <1> ;xor bl, bl ; 0 3193 0000219F 803D[DE670000]03 <1> cmp byte [CRT_MODE], 03h ; 80x25 color text 3194 <1> ;je short p11 ; Note: Only mode 03h and mode 01h are 3195 <1> ;inc bl ; 1 ; in use by TRDOS 386 as text modes 3196 <1> ;jmp short p14 ; (07h, 00h and 02h are redirected) 3197 000021A6 7516 <1> jne short p13 3198 <1> 3199 <1> ; 05/12/2020 3200 000021A8 3A3D[EE7C0100] <1> cmp bh, [ACTIVE_PAGE] 3201 000021AE 750E <1> jne short p13 3202 <1> 3203 <1> ; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80 3204 <1> p11: 3205 000021B0 FB <1> sti ; enable interrupts first 3206 <1> ; 05/12/2020 3207 000021B1 90 <1> nop 3208 <1> ; 18/11/2020 3209 <1> ;or bl, bl 3210 <1> ;jnz short p13 ; mode 01h (and mode 00h) - 40x25 color text 3211 000021B2 FA <1> cli ; block interrupts for single loop 3212 000021B3 EC <1> in al, dx ; get status from the adapter 3213 000021B4 A801 <1> test al, RHRZ ; is horizontal retrace low 3214 000021B6 75F8 <1> jnz short p11 ; wait until it is 3215 <1> p12: ; wait for either retrace high 3216 000021B8 EC <1> in al, dx ; get status again 3217 000021B9 A809 <1> test al, RVRT+RHRZ ; is horizontal or vertical retrace high 3218 000021BB 74FB <1> jz short p12 ; wait until either retrace active 3219 <1> ;p14: 3220 000021BD FB <1> sti 3221 <1> p13: 3222 000021BE 81C600800B00 <1> add esi, 0B8000h 3223 000021C4 668B06 <1> mov ax, [esi] 3224 <1> 3225 000021C7 C3 <1> retn ; 18/01/2016 3226 <1> 3227 <1> WRITE_AC_CURRENT: 3228 <1> ; 08/07/2016 3229 <1> ; 26/06/2016 3230 <1> ; 24/06/2016 3231 <1> ; 12/05/2016 3232 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3233 <1> ; 3234 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3235 <1> ; 3236 <1> ;---------------------------------------------------------------- 3237 <1> ; WRITE_AC_CURRENT : 3238 <1> ; THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER : 3239 <1> ; AT THE CURRENT CURSOR POSITION : 3240 <1> ; INPUT : 3241 <1> ; (AH) = CURRENT CRT MODE : 3242 <1> ; (BH) = DISPLAY PAGE : 3243 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE : 3244 <1> ; (AL) = CHAR TO WRITE : 3245 <1> ; (BL) = ATTRIBUTE OF CHAR TO WRITE : 3246 <1> ; (DS) = DATA SEGMENT : 3247 <1> ; (ES) = REGEN SEGMENT : 3248 <1> ; OUTPUT : 3249 <1> ; DISPLAY REGEN BUFFER UPDATED : 3250 <1> ;---------------------------------------------------------------- 3251 <1> 3252 <1> ; 08/07/2016 3253 000021C8 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; 6!? 3254 000021CF 760A <1> jna short write_ac_c 3255 <1> 3256 000021D1 E8B60A0000 <1> call vga_write_char_attr 3257 000021D6 E957F9FFFF <1> jmp VIDEO_RETURN 3258 <1> 3259 <1> write_ac_c: 3260 000021DB E834000000 <1> call _write_c_current 3261 <1> 3262 000021E0 0FB6F7 <1> movzx esi, bh ; video page number (0 to 7) 3263 000021E3 889E[E7670000] <1> mov [esi+chr_attrib], bl ; color/attribute 3264 <1> 3265 000021E9 E944F9FFFF <1> jmp VIDEO_RETURN 3266 <1> 3267 <1> WRITE_C_CURRENT: 3268 <1> ; 08/07/2016 3269 <1> ; 26/06/2016 3270 <1> ; 12/05/2016 3271 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3272 <1> ; 3273 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3274 <1> ; 3275 <1> ;---------------------------------------------------------------- 3276 <1> ; WRITE_C_CURRENT : 3277 <1> ; THIS ROUTINE WRITES THE CHARACTER AT : 3278 <1> ; THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED : 3279 <1> ; INPUT : 3280 <1> ; (AH) = CURRENT CRT MODE : 3281 <1> ; (BH) = DISPLAY PAGE : 3282 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE : 3283 <1> ; (AL) = CHAR TO WRITE : 3284 <1> ; (DS) = DATA SEGMENT : 3285 <1> ; (ES) = REGEN SEGMENT : 3286 <1> ; OUTPUT : 3287 <1> ; DISPLAY REGEN BUFFER UPDATED : 3288 <1> ;---------------------------------------------------------------- 3289 <1> 3290 <1> ; 08/07/2016 3291 000021EE 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; 6!? 3292 000021F5 760A <1> jna short write_c_c 3293 <1> 3294 000021F7 E8900A0000 <1> call vga_write_char_only 3295 000021FC E931F9FFFF <1> jmp VIDEO_RETURN 3296 <1> 3297 <1> write_c_c: 3298 <1> ;and bh, 7 ; video page number (<= 7) 3299 00002201 0FB6F7 <1> movzx esi, bh 3300 00002204 8A9E[E7670000] <1> mov bl, [esi+chr_attrib] 3301 <1> 3302 0000220A E805000000 <1> call _write_c_current 3303 0000220F E91EF9FFFF <1> jmp VIDEO_RETURN 3304 <1> 3305 <1> _write_c_current: ; from 'write_tty' 3306 <1> ; 12/04/2021 3307 <1> ; 18/11/2020 3308 <1> ; 26/06/2016 3309 <1> ; 24/06/2016 3310 <1> ; 12/05/2016 3311 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3312 <1> ; 30/08/2014 (Retro UNIX 386 v1) 3313 <1> ; 18/01/2014 3314 <1> ; 04/12/2013 3315 <1> ; 3316 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3317 <1> 3318 <1> ; 18/11/2020 3319 00002214 8A25[DE670000] <1> mov ah, [CRT_MODE] ; current video mode 3320 0000221A 80FC04 <1> cmp ah, 4 3321 0000221D 720A <1> jb short p40 3322 <1> 3323 <1> ;cmp byte [CRT_MODE], 4 3324 <1> ;jnb GRAPHICS_WRITE ; 26/06/2016 3325 <1> 3326 0000221F 80FC07 <1> cmp ah, 7 ; TEST FOR BW CARD 3327 00002222 7405 <1> je short p40 3328 00002224 E963070000 <1> jmp GRAPHICS_WRITE 3329 <1> p40: 3330 <1> ; al = character 3331 <1> ; bl = color/attribute 3332 <1> ; bh = video page 3333 <1> ; cx = count of characters to write 3334 <1> ;push dx 3335 <1> ; 12/04/2021 3336 00002229 52 <1> push edx ; * 3337 0000222A 88DC <1> mov ah, bl ; color/attribute (12/05/2016) 3338 <1> ;push ax ; save character & attribute/color 3339 <1> ;push cx 3340 <1> ; 12/04/2021 3341 0000222C 50 <1> push eax ; ** ; save character & attribute/color 3342 0000222D 51 <1> push ecx ; *** 3343 0000222E E876FDFFFF <1> call find_position ; get regen location and port address 3344 <1> ;pop cx 3345 <1> ; 12/04/2021 3346 00002233 59 <1> pop ecx ; *** 3347 <1> ; esi = regen location 3348 <1> ; dx = status port 3349 <1> ; 3350 00002234 81C600800B00 <1> add esi, 0B8000h ; 30/08/2014 (crt_base) 3351 <1> ; 3352 <1> ; 18/11/2020 3353 <1> ; convert display mode to a zero value 3354 <1> ; for 80 column color mode 3355 <1> ;mov ah, [CRT_MODE] 3356 <1> ;sub ah, 2 3357 <1> ;shr ah, 1 3358 <1> ;jnz short p44 ; 26/06/2016 3359 <1> 3360 <1> ; 05/12/2020 3361 <1> ; 18/11/2020 (TRDOS 386 v2.0.3) 3362 <1> ;xor bl, bl ; 0 3363 0000223A 803D[DE670000]03 <1> cmp byte [CRT_MODE], 03h ; 80x25 color text 3364 <1> ;je short p41 ; Note: Only mode 03h and mode 01h are 3365 <1> ;inc bl ; 1 ; in use by TRDOS 386 as text modes 3366 <1> ;jmp short p43 ; (07h, 00h and 02h are redirected) 3367 <1> ; 05/12/2020 3368 00002241 751A <1> jne short p44 3369 <1> p46: 3370 <1> ; 05/12/2020 3371 00002243 3A3D[EE7C0100] <1> cmp bh, [ACTIVE_PAGE] 3372 00002249 7512 <1> jne short p44 3373 <1> 3374 <1> ; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80 3375 <1> p41: 3376 <1> ; 05/12/2020 3377 0000224B FB <1> sti ; enable interrupts first 3378 0000224C 90 <1> nop 3379 <1> ; 18/11/2020 3380 <1> ;or bl, bl 3381 <1> ;jnz short p44 ; mode 01h (and mode 00h) - 40x25 color text 3382 0000224D FA <1> cli ; block interrupts for single loop 3383 0000224E EC <1> in al, dx ; get status from the adapter 3384 0000224F A808 <1> test al, RVRT ; check for vertical retrace first 3385 00002251 7509 <1> jnz short p43 ; Do fast write now if vertical retrace 3386 00002253 A801 <1> test al, RHRZ ; is horizontal retrace low 3387 00002255 75F4 <1> jnz short p41 ; wait until it is 3388 <1> p42: ; wait for either retrace high 3389 00002257 EC <1> in al, dx ; get status again 3390 00002258 A809 <1> test al, RVRT+RHRZ ; is horizontal or vertical retrace high 3391 0000225A 74FB <1> jz short p42 ; wait until either retrace active 3392 <1> p43: 3393 0000225C FB <1> sti 3394 <1> p44: 3395 0000225D 668B0424 <1> mov ax, [esp] ; restore the character (al) & attribute (ah) 3396 00002261 668906 <1> mov [esi], ax 3397 <1> 3398 00002264 6649 <1> dec cx 3399 00002266 740D <1> jz short p45 3400 <1> 3401 00002268 46 <1> inc esi 3402 00002269 46 <1> inc esi 3403 <1> 3404 <1> ; 05/12/2020 3405 0000226A 803D[DE670000]03 <1> cmp byte [CRT_MODE], 03h 3406 00002271 75EA <1> jne short p44 3407 <1> ;jmp short p41 3408 00002273 EBCE <1> jmp short p46 3409 <1> p45: 3410 <1> ;pop ax 3411 <1> ;pop dx 3412 <1> ; 12/04/2021 3413 00002275 58 <1> pop eax ; ** 3414 00002276 5A <1> pop edx ; * 3415 00002277 C3 <1> retn 3416 <1> 3417 <1> ; 09/07/2016 3418 <1> ; 26/06/2016 3419 <1> ; 24/06/2016 3420 <1> ; 12/05/2016 3421 <1> ; 18/01/2016 3422 <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0) 3423 <1> ; 30/06/2015 3424 <1> ; 27/06/2015 3425 <1> ; 11/03/2015 3426 <1> ; 02/09/2014 3427 <1> ; 30/08/2014 3428 <1> ; VIDEO FUNCTIONS 3429 <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014) 3430 <1> 3431 <1> WRITE_TTY: 3432 <1> ; 09/12/2017 3433 <1> ; 09/07/2016 3434 <1> ; 01/07/2016 3435 <1> ; 26/06/2016 3436 <1> ; 24/06/2016 3437 <1> ; 13/05/2016 3438 <1> ; 12/05/2016 3439 <1> ; 30/01/2016 3440 <1> ; 18/01/2016 3441 <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0) 3442 <1> ; 13/08/2015 3443 <1> ; 02/09/2014 3444 <1> ; 30/08/2014 (Retro UNIX 386 v1 - beginning) 3445 <1> ; 01/02/2014 (Retro UNIX 8086 v1 - last update) 3446 <1> ; 03/12/2013 (Retro UNIX 8086 v1 - beginning) 3447 <1> ; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI) 3448 <1> ; 3449 <1> ; INPUT -> AL = Character to be written 3450 <1> ; BL = Color (Forecolor, Backcolor) 3451 <1> ; BH = Video Page (0 to 7) 3452 <1> 3453 <1> ; 09/07/2016 3454 00002278 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 3455 0000227F 760A <1> jna short write_tty_cga 3456 <1> 3457 00002281 E8EB0C0000 <1> call vga_write_teletype 3458 00002286 E9A7F8FFFF <1> jmp VIDEO_RETURN 3459 <1> 3460 <1> write_tty_cga: 3461 <1> ; 13/05/2016 3462 <1> ;call _write_tty 3463 <1> ; 01/07/2016 3464 0000228B E818000000 <1> call _write_tty_m3 3465 00002290 E99DF8FFFF <1> jmp VIDEO_RETURN 3466 <1> 3467 <1> RVRT equ 00001000b ; VIDEO VERTICAL RETRACE BIT 3468 <1> RHRZ equ 00000001b ; VIDEO HORIZONTAL RETRACE BIT 3469 <1> 3470 <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code 3471 <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO 3472 <1> ; 3473 <1> ; 06/10/85 VIDEO DISPLAY BIOS 3474 <1> ; 3475 <1> ;--- WRITE_TTY ------------------------------------------------------------------ 3476 <1> ; : 3477 <1> ; THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE : 3478 <1> ; VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT : 3479 <1> ; CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION. : 3480 <1> ; IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN : 3481 <1> ; IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW : 3482 <1> ; ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW, : 3483 <1> ; FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE. : 3484 <1> ; WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE : 3485 <1> ; NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS : 3486 <1> ; LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE, : 3487 <1> ; THE 0 COLOR IS USED. : 3488 <1> ; ENTRY -- : 3489 <1> ; (AH) = CURRENT CRT MODE : 3490 <1> ; (AL) = CHARACTER TO BE WRITTEN : 3491 <1> ; NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE : 3492 <1> ; HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS : 3493 <1> ; (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE : 3494 <1> ; EXIT -- : 3495 <1> ; ALL REGISTERS SAVED : 3496 <1> ;-------------------------------------------------------------------------------- 3497 <1> 3498 <1> ; 02/08/2022 (TRDOS 386 v2.0.5) 3499 <1> ; 18/11/2020 (TRDOS 386 v2.0.3) 3500 <1> ; 09/12/2017 3501 <1> ; 08/07/2016 3502 <1> ; 26/06/2016 3503 <1> ; 24/06/2016 3504 <1> _write_tty: 3505 <1> ; 13/05/2016 3506 <1> ; --- 18/11/2020 --- 3507 <1> ; NOTE: 3508 <1> ; Only kernel calls "_write_tty" procedure... 3509 <1> ; TRDOS 386 v2 kernel uses video mode 3 for displaying 3510 <1> ; (some error) messages and also mainprog command interpreter 3511 <1> ; (in kernel) uses "_write_tty". 3512 <1> ; So, here video mode must be set to 3 if it is not 3. 3513 <1> 3514 00002295 FA <1> cli ; disable interrupts 3515 <1> ; 3516 <1> ; 01/09/2014 3517 00002296 803D[DE670000]03 <1> cmp byte [CRT_MODE], 3 3518 0000229D 7409 <1> je short _write_tty_m3 3519 <1> ; 3520 <1> set_mode_3: 3521 0000229F 53 <1> push ebx 3522 000022A0 50 <1> push eax 3523 <1> ;call _set_mode 3524 <1> ; 18/11/2020 3525 000022A1 E89BF8FFFF <1> call set_txt_mode ; set video mode to 03h 3526 000022A6 58 <1> pop eax 3527 000022A7 5B <1> pop ebx 3528 <1> ; 3529 <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3) 3530 000022A8 0FB6F7 <1> movzx esi, bh ; 12/05/2016 3531 <1> ;shl si, 1 3532 <1> ; 02/08/2022 3533 000022AB D1E6 <1> shl esi, 1 3534 000022AD 81C6[DE7C0100] <1> add esi, CURSOR_POSN 3535 000022B3 668B16 <1> mov dx, [esi] 3536 <1> ; 3537 <1> ; dx now has the current cursor position 3538 <1> ; 3539 000022B6 3C0D <1> cmp al, 0Dh ; CR ; is it carriage return or control character 3540 <1> ;jbe short u8 3541 <1> ; 17/04/2021 3542 000022B8 7241 <1> jb short u8 3543 000022BA 746F <1> je short u9 3544 <1> ; 3545 <1> ; write the char to the screen 3546 <1> u0: 3547 <1> ; al = character 3548 <1> ; bl = attribute/color 3549 <1> ; bh = video page number (0 to 7) 3550 <1> ; 3551 <1> ;mov cx, 1 ; 24/06/2016 3552 <1> ; 02/08/2022 3553 000022BC 29C9 <1> sub ecx, ecx 3554 000022BE FEC1 <1> inc cl ; ecx = 1 3555 <1> ; cx = count of characters to write 3556 <1> ; 3557 000022C0 E84FFFFFFF <1> call _write_c_current ; 16/01/2015 3558 <1> ; 3559 <1> ; position the cursor for next char 3560 000022C5 FEC2 <1> inc dl ; next column 3561 000022C7 3A15[E0670000] <1> cmp dl, [CRT_COLS] ; test for column overflow 3562 <1> ;jne _set_cpos 3563 <1> ; 02/08/2022 3564 000022CD 7402 <1> je short u13 3565 000022CF EB5C <1> jmp _set_cpos 3566 <1> u13: 3567 000022D1 B200 <1> mov dl, 0 ; column = 0 3568 <1> u10: ; (line feed found) 3569 000022D3 80FE18 <1> cmp dh, 25-1 ; check for last row 3570 000022D6 721F <1> jb short u6 3571 <1> ; 3572 <1> ; scroll required 3573 <1> u1: 3574 <1> ; SET CURSOR POSITION (04/12/2013) 3575 000022D8 E850000000 <1> call _set_cpos 3576 <1> ; 3577 <1> ; determine value to fill with during scroll 3578 <1> u2: 3579 <1> ; bh = video page number 3580 <1> ; 3581 000022DD E8A3FEFFFF <1> call _read_ac_current ; 18/01/2016 3582 <1> ; 3583 <1> ; al = character, ah = attribute 3584 <1> ; bh = video page number 3585 <1> ; 18/11/2020 3586 000022E2 88E3 <1> mov bl, ah ; color/attribute 3587 <1> u3: 3588 <1> ;;mov ax, 0601h ; scroll one line 3589 <1> ;;sub cx, cx ; upper left corner 3590 <1> ;;mov dh, 25-1 ; lower right row 3591 <1> ;;;mov dl, [CRT_COLS] 3592 <1> ;mov dl, 80 ; lower right column 3593 <1> ;;dec dl 3594 <1> ;;mov dl, 79 3595 <1> 3596 <1> ;;call scroll_up ; 04/12/2013 3597 <1> ;;; 11/03/2015 3598 <1> ; 02/09/2014 3599 <1> ;;;mov cx, [crt_ulc] ; Upper left corner (0000h) 3600 <1> ;;;mov dx, [crt_lrc] ; Lower right corner (184Fh) 3601 <1> ; 11/03/2015 3602 <1> ;sub cx, cx 3603 <1> ; 17/04/2021 3604 000022E4 29C9 <1> sub ecx, ecx 3605 <1> ;mov dx, 184Fh ; dl = 79 (column), dh = 24 (row) 3606 <1> ; 18/11/2020 3607 000022E6 B618 <1> mov dh, 25-1 3608 000022E8 8A15[E0670000] <1> mov dl, [CRT_COLS] 3609 000022EE FECA <1> dec dl 3610 <1> ; 3611 000022F0 B001 <1> mov al, 1 ; scroll 1 line up 3612 <1> ; ah = attribute 3613 <1> ;mov bl, al ; 12/05/2016 3614 000022F2 E9F0FCFFFF <1> jmp _scroll_up ; 16/01/2016 3615 <1> ;u4: 3616 <1> ;;int 10h ; video-call return 3617 <1> ; scroll up the screen 3618 <1> ; tty return 3619 <1> ;u5: 3620 <1> ;retn ; return to the caller 3621 <1> 3622 <1> u6: ; set-cursor-inc 3623 000022F7 FEC6 <1> inc dh ; next row 3624 <1> ; set cursor 3625 <1> ;u7: 3626 <1> ;;mov ah, 02h 3627 <1> ;;jmp short u4 ; establish the new cursor 3628 <1> ;call _set_cpos 3629 <1> ;jmp short u5 3630 000022F9 EB32 <1> jmp _set_cpos 3631 <1> 3632 <1> ; check for control characters 3633 <1> u8: 3634 <1> ;je short u9 ; 17/04/2021 3635 000022FB 3C0A <1> cmp al, 0Ah ; is it a line feed (0Ah) 3636 000022FD 74D4 <1> je short u10 3637 000022FF 3C07 <1> cmp al, 07h ; is it a bell 3638 00002301 747C <1> je short u11 3639 00002303 3C08 <1> cmp al, 08h ; is it a backspace 3640 <1> ;jne short u0 3641 00002305 741C <1> je short bs ; 12/12/2013 3642 <1> ; 12/12/2013 (tab stop) 3643 00002307 3C09 <1> cmp al, 09h ; is it a tab stop 3644 00002309 75B1 <1> jne short u0 3645 0000230B 88D0 <1> mov al, dl 3646 <1> ;cbw 3647 0000230D 30E4 <1> xor ah, ah ; 09/12/2017 3648 0000230F B108 <1> mov cl, 8 3649 00002311 F6F1 <1> div cl 3650 00002313 28E1 <1> sub cl, ah 3651 <1> ts: 3652 <1> ; 02/09/2014 3653 <1> ; 01/09/2014 3654 <1> ;mov al, 20h 3655 <1> tsloop: 3656 <1> ;push cx 3657 <1> ; 12/04/2021 3658 00002315 51 <1> push ecx ; * 3659 <1> ; 18/11/2020 3660 <1> ;push ax 3661 <1> ;;mov bh, [ACTIVE_PAGE] 3662 <1> ; 05/12/2020 3663 <1> ;push bx 3664 00002316 B020 <1> mov al, 20h ; al = space (blank) 3665 <1> ; bl = color/attribute 3666 00002318 E88BFFFFFF <1> call _write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3) 3667 <1> ; 05/12/2020 3668 <1> ; bx is preserved in '_write_tty_m3' 3669 <1> ; 18/11/2020 3670 <1> ;pop bx ; BL = color/attribute, Bh = video page 3671 <1> ;pop ax ; AL = character 3672 <1> ; 12/04/2021 3673 <1> ;pop cx 3674 0000231D 59 <1> pop ecx ; * 3675 0000231E FEC9 <1> dec cl 3676 00002320 75F3 <1> jnz short tsloop 3677 00002322 C3 <1> retn 3678 <1> bs: 3679 <1> ; back space found 3680 <1> 3681 00002323 08D2 <1> or dl, dl ; is it already at start of line 3682 <1> ;je short u7 ; set_cursor 3683 00002325 7406 <1> jz short _set_cpos 3684 <1> ;dec dx ; no -- just move it back 3685 <1> ; 17/04/2021 3686 00002327 FECA <1> dec dl ; move to 1 column back 3687 <1> ;jmp short u7 3688 00002329 EB02 <1> jmp short _set_cpos 3689 <1> 3690 <1> ; carriage return found 3691 <1> u9: 3692 0000232B B200 <1> mov dl, 0 ; move to first column 3693 <1> ;jmp short u7 3694 <1> ;jmp short _set_cpos ; 30/01/2016 3695 <1> 3696 <1> ; line feed found 3697 <1> ;u10: 3698 <1> ; cmp dh, 25-1 ; bottom of screen 3699 <1> ; jne short u6 ; no, just set the cursor 3700 <1> ; jmp u1 ; yes, scroll the screen 3701 <1> 3702 <1> _set_cpos: 3703 <1> ; 02/08/2022 - TRDOS 386 v2.0.5 3704 <1> ; 17/04/2021 - TRDOS 386 v2.0.4 3705 <1> ; 12/05/2016 - TRDOS 386 (TRDOS v2.0) 3706 <1> ; 27/06/2015 3707 <1> ; 01/09/2014 3708 <1> ; 30/08/2014 (Retro UNIX 386 v1) 3709 <1> ; 3710 <1> ; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 3711 <1> ; 3712 <1> ; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS 3713 <1> ; 3714 <1> ;---------------------------------------------- 3715 <1> ; SET_CPOS 3716 <1> ; THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE 3717 <1> ; NEW X-Y VALUES PASSED 3718 <1> ; INPUT 3719 <1> ; DX - ROW,COLUMN OF NEW CURSOR 3720 <1> ; BH - DISPLAY PAGE OF CURSOR 3721 <1> ; OUTPUT 3722 <1> ; CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY 3723 <1> ;---------------------------------------------- 3724 <1> ; 3725 0000232D BE[DE7C0100] <1> mov esi, CURSOR_POSN 3726 00002332 0FB6C7 <1> movzx eax, bh ; BH = video page number 3727 <1> ; or al, al 3728 <1> ; jz short _set_cpos_0 3729 00002335 D0E0 <1> shl al, 1 ; word offset 3730 00002337 01C6 <1> add esi, eax 3731 <1> ;_set_cpos_0: 3732 00002339 668916 <1> mov [esi], dx ; save the pointer 3733 0000233C 383D[EE7C0100] <1> cmp [ACTIVE_PAGE], bh 3734 00002342 7532 <1> jne short m17 3735 <1> ;call m18 ; CURSOR SET 3736 <1> ;m17: ; SET_CPOS_RETURN 3737 <1> ; 01/09/2014 3738 <1> ; retn 3739 <1> ; DX = row/column 3740 <1> m18: 3741 00002344 E852FCFFFF <1> call position ; determine location in regen buffer 3742 00002349 668B0D[DC7C0100] <1> mov cx, [CRT_START] 3743 00002350 6601C1 <1> add cx, ax ; add char position in regen buffer 3744 <1> ; to the start address (offset) for this page 3745 00002353 66D1E9 <1> shr cx, 1 ; divide by 2 for char only count 3746 00002356 B40E <1> mov ah, 14 ; register number for cursor 3747 <1> ;call m16 ; output value to the 6845 3748 <1> ;retn 3749 <1> 3750 <1> ;----- THIS ROUTINE OUTPUTS THE CX REGISTER 3751 <1> ; TO THE 6845 REGISTERS NAMED IN (AH) 3752 <1> m16: 3753 00002358 FA <1> cli 3754 <1> ;mov dx, [addr_6845] ; address register 3755 00002359 66BAD403 <1> mov dx, 03D4h ; I/O address of color card 3756 0000235D 88E0 <1> mov al, ah ; get value 3757 0000235F EE <1> out dx, al ; register set 3758 <1> ;inc dx ; data register 3759 <1> ; 17/04/2021 3760 00002360 FEC2 <1> inc dl 3761 00002362 EB00 <1> jmp $+2 ; i/o delay 3762 00002364 88E8 <1> mov al, ch ; data 3763 00002366 EE <1> out dx, al 3764 <1> ;dec dx 3765 <1> ; 17/04/2021 3766 00002367 FECA <1> dec dl 3767 00002369 88E0 <1> mov al, ah 3768 0000236B FEC0 <1> inc al ; point to other data register 3769 0000236D EE <1> out dx, al ; set for second register 3770 <1> ;inc dx 3771 <1> ; 17/04/2021 3772 0000236E FEC2 <1> inc dl 3773 00002370 EB00 <1> jmp $+2 ; i/o delay 3774 00002372 88C8 <1> mov al, cl ; second data value 3775 00002374 EE <1> out dx, al 3776 00002375 FB <1> sti 3777 <1> m17: 3778 00002376 C3 <1> retn 3779 <1> 3780 <1> _beep: 3781 <1> ; 12/02/2021 (TRDOS v2.0.3) 3782 00002377 FA <1> cli 3783 00002378 E811000000 <1> call beep 3784 0000237D FB <1> sti 3785 0000237E C3 <1> retn 3786 <1> 3787 <1> beeper: 3788 <1> ; 04/08/2016 3789 <1> ; 12/05/2016 - TRDOS 386 (TRDOS v2.0) 3790 <1> ; 30/08/2014 (Retro UNIX 386 v1) 3791 <1> ; 18/01/2014 3792 <1> ; 03/12/2013 3793 <1> ; bell found 3794 <1> u11: 3795 0000237F FB <1> sti 3796 00002380 3A3D[EE7C0100] <1> cmp bh, [ACTIVE_PAGE] 3797 00002386 7552 <1> jne short u12 ; Do not sound the beep 3798 <1> ; if it is not written on the active page 3799 <1> beeper_gfx: ; 04/08/2016 3800 00002388 66B93305 <1> mov cx, 1331 ; divisor for 896 hz tone 3801 0000238C B31F <1> mov bl, 31 ; set count for 31/64 second for beep 3802 <1> ;call beep ; sound the pod bell 3803 <1> ;jmp short u5 ; tty_return 3804 <1> ;retn 3805 <1> 3806 <1> TIMER equ 040h ; 8254 TIMER - BASE ADDRESS 3807 <1> PORT_B equ 061h ; PORT B READ/WRITE DIAGNOSTIC REGISTER 3808 <1> GATE2 equ 00000001b ; TIMER 2 INPUT CATE CLOCK BIT 3809 <1> SPK2 equ 00000010b ; SPEAKER OUTPUT DATA ENABLE BIT 3810 <1> 3811 <1> beep: 3812 <1> ; 12/02/2021 3813 <1> ; 07/02/2015 3814 <1> ; 30/08/2014 (Retro UNIX 386 v1) 3815 <1> ; 18/01/2014 3816 <1> ; 03/12/2013 3817 <1> ; 3818 <1> ; TEST4.ASM - 06/10/85 POST AND BIOS UTILITY ROUTINES 3819 <1> ; 3820 <1> ; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE 3821 <1> ; 3822 <1> ; ENTRY: 3823 <1> ; (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND ) 3824 <1> ; (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ) 3825 <1> ; EXIT: : 3826 <1> ; (AX),(BL),(CX) MODIFIED. 3827 <1> 3828 0000238E 9C <1> pushfd ; 18/01/2014 ; save interrupt status 3829 0000238F FA <1> cli ; block interrupts during update 3830 00002390 B0B6 <1> mov al, 10110110b ; select timer 2, lsb, msb binary 3831 00002392 E643 <1> out TIMER+3, al ; write timer mode register 3832 00002394 EB00 <1> jmp $+2 ; I/O delay 3833 00002396 88C8 <1> mov al, cl ; divisor for hz (low) 3834 00002398 E642 <1> out TIMER+2,AL ; write timer 2 count - lsb 3835 0000239A EB00 <1> jmp $+2 ; I/O delay 3836 0000239C 88E8 <1> mov al, ch ; divisor for hz (high) 3837 0000239E E642 <1> out TIMER+2, al ; write timer 2 count - msb 3838 000023A0 E461 <1> in al, PORT_B ; get current setting of port 3839 000023A2 88C4 <1> mov ah, al ; save that setting 3840 000023A4 0C03 <1> or al, GATE2+SPK2 ; gate timer 2 and turn speaker on 3841 000023A6 E661 <1> out PORT_B, al ; and restore interrupt status 3842 <1> ; 12/02/2021 3843 000023A8 9D <1> popfd ; 18/01/2014 3844 <1> ;sti 3845 <1> g7: ; 1/64 second per count (bl) 3846 000023A9 B90B040000 <1> mov ecx, 1035 ; delay count for 1/64 of a second 3847 000023AE E828000000 <1> call waitf ; go to beep delay 1/64 count 3848 000023B3 FECB <1> dec bl ; (bl) length count expired? 3849 000023B5 75F2 <1> jnz short g7 ; no - continue beeping speaker 3850 <1> ; 3851 000023B7 9C <1> pushfd ; 12/02/2021 ; save interrupt status 3852 000023B8 FA <1> cli ; 18/01/2014 ; block interrupts during update 3853 000023B9 E461 <1> in al, PORT_B ; get current port value 3854 <1> ;or al, not (GATE2+SPK2) ; isolate current speaker bits in case 3855 000023BB 0CFC <1> or al, ~(GATE2+SPK2) 3856 000023BD 20C4 <1> and ah, al ; someone turned them off during beep 3857 000023BF 88E0 <1> mov al, ah ; recover value of port 3858 <1> ;or al, not (GATE2+SPK2) ; force speaker data off 3859 000023C1 0CFC <1> or al, ~(GATE2+SPK2) ; isolate current speaker bits in case 3860 000023C3 E661 <1> out PORT_B, al ; and stop speaker timer 3861 000023C5 9D <1> popfd ; 12/02/2021 ; restore interrupt flag state 3862 <1> ;sti 3863 <1> ;mov ecx, 1035 ; force 1/64 second delay (short) 3864 <1> ; 17/04/2021 3865 000023C6 66B90B04 <1> mov cx, 1035 3866 000023CA E80C000000 <1> call waitf ; minimum delay between all beeps 3867 000023CF 9C <1> pushfd ; save interrupt status 3868 000023D0 FA <1> cli ; block interrupts during update 3869 000023D1 E461 <1> in al, PORT_B ; get current port value in case 3870 000023D3 2403 <1> and al, GATE2+SPK2 ; someone turned them on 3871 000023D5 08E0 <1> or al, ah ; recover value of port_b 3872 000023D7 E661 <1> out PORT_B, al ; restore speaker status 3873 000023D9 9D <1> popfd ; restore interrupt flag state 3874 <1> u12: 3875 000023DA C3 <1> retn 3876 <1> 3877 <1> REFRESH_BIT equ 00010000b ; REFRESH TEST BIT 3878 <1> 3879 <1> WAITF: 3880 <1> waitf: 3881 <1> ; 30/08/2014 (Retro UNIX 386 v1) 3882 <1> ; 03/12/2013 3883 <1> ; 3884 <1> ; push ax ; save work register (ah) 3885 <1> ;waitf1: 3886 <1> ; use timer 1 output bits 3887 <1> ; in al, PORT_B ; read current counter output status 3888 <1> ; and al, REFRESH_BIT ; mask for refresh determine bit 3889 <1> ; cmp al, ah ; did it just change 3890 <1> ; je short waitf1 ; wait for a change in output line 3891 <1> ; ; 3892 <1> ; mov ah, al ; save new lflag state 3893 <1> ; loop waitf1 ; decrement half cycles till count end 3894 <1> ; ; 3895 <1> ; pop ax ; restore (ah) 3896 <1> ; retn ; return (cx)=0 3897 <1> 3898 <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s) 3899 <1> ; 17/12/2014 (dsectrm2.s) 3900 <1> ; WAITF 3901 <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 /// 3902 <1> ; 3903 <1> ;---WAITF----------------------------------------------------------------------- 3904 <1> ; FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR) 3905 <1> ; ENTRY: 3906 <1> ; (CX) = COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT 3907 <1> ; MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE 3908 <1> ; EXIT: 3909 <1> ; AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS) 3910 <1> ; (CX) = 0 3911 <1> ;------------------------------------------------------------------------------- 3912 <1> 3913 <1> ; Refresh period: 30 micro seconds (15-80 us) 3914 <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH) 3915 <1> 3916 <1> ;WAITF: ; DELAY FOR (CX)*15.085737 US 3917 <1> ;push AX ; SAVE WORK REGISTER (AH) 3918 <1> ; 11/04/2021 3919 000023DB 50 <1> push eax 3920 <1> ; 16/12/2014 3921 <1> ;shr cx, 1 ; convert to count of 30 micro seconds 3922 000023DC D1E9 <1> shr ecx, 1 ; 21/02/2015 3923 <1> ;17/12/2014 3924 <1> ;WAITF1: 3925 <1> ; in al, PORT_B ;061h ; READ CURRENT COUNTER OUTPUT STATUS 3926 <1> ; and al, REFRESH_BIT ;00010000b ; MASK FOR REFRESH DETERMINE BIT 3927 <1> ; cmp al, ah ; DID IT JUST CHANGE 3928 <1> ; je short WAITF1 ; WAIT FOR A CHANGE IN OUTPUT LINE 3929 <1> ; mov ah, al ; SAVE NEW FLAG STATE 3930 <1> ; loop WAITF1 ; DECREMENT HALF CYCLES TILL COUNT END 3931 <1> ; 3932 <1> ; 17/12/2014 3933 <1> ; 3934 <1> ; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999 3935 <1> ; 3936 <1> ;WAIT_REFRESH: Uses port 61, bit 4 to have CPU speed independent waiting. 3937 <1> ; INPUT: CX = number of refresh periods to wait 3938 <1> ; (refresh periods = 1 per 30 microseconds on most machines) 3939 <1> WR_STATE_0: 3940 000023DE E461 <1> in al, PORT_B ; IN AL,SYS1 3941 000023E0 A810 <1> test al, 010h 3942 000023E2 74FA <1> JZ short WR_STATE_0 3943 <1> WR_STATE_1: 3944 000023E4 E461 <1> in al, PORT_B ; IN AL,SYS1 3945 000023E6 A810 <1> test al, 010h 3946 000023E8 75FA <1> jnz short WR_STATE_1 3947 000023EA E2F2 <1> loop WR_STATE_0 3948 <1> ; 3949 <1> ;pop ax ; RESTORE (AH) 3950 <1> ; 11/04/2021 3951 000023EC 58 <1> pop eax 3952 000023ED C3 <1> retn ; (CX) = 0 3953 <1> 3954 <1> ; 03/08/2022 3955 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 3956 <1> ; 09/07/2016 3957 <1> ; 01/07/2016 3958 <1> ; 24/06/2016 3959 <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0) 3960 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 3961 <1> ;------------------------------------------------------------------------------- 3962 <1> ; WRITE_STRING : 3963 <1> ; THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT. : 3964 <1> ; INPUT : 3965 <1> ; (AL) = WRITE STRING COMMAND 0 - 3 : 3966 <1> ; (BH) = DISPLAY PAGE (ACTIVE PAGE) : 3967 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN : 3968 <1> ; (DX) = CURSOR POSITION FOR START OF STRING WRITE : 3969 <1> ; (BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0 OR (AL) = 1 : 3970 <1> ; (EBP) = SOURCE STRING OFFSET : 3971 <1> ; OUTPUT : 3972 <1> ; NONE : 3973 <1> ;------------------------------------------------------------------------------- 3974 <1> 3975 <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor 3976 <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor 3977 <1> ; AL = 02h: Use attributes in string; do not update cursor 3978 <1> ; AL = 03h: Use attributes in string; update cursor 3979 <1> 3980 <1> WRITE_STRING: 3981 <1> ; 03/08/2022 3982 <1> ; 02/08/2022 3983 <1> ; 12/09/2016 3984 <1> ; 09/07/2016 3985 <1> ;cmp byte [CRT_MODE], 7 ; 6?! 3986 <1> ;ja VIDEO_RETURN ; not a valid function for VGA modes 3987 <1> ; 3988 000023EE A2[50890100] <1> mov [w_str_cmd], al ; save (AL) command 3989 000023F3 3C04 <1> cmp al, 4 ; TEST FOR INVALID WRITE STRING OPTION 3990 <1> ;jnb VIDEO_RETURN ; IF OPTION INVALID THEN RETURN 3991 <1> ; 02/08/2022 3992 000023F5 7361 <1> jnb short P55 3993 <1> 3994 <1> ;jcxz VIDEO_RETURN ; IF ZERO LENGTH STRING THEN RETURN 3995 <1> 3996 000023F7 67E35E <1> jcxz P55 ; 01/07/2016 3997 <1> 3998 <1> ; 01/07/2016 3999 <1> ;and ecx, 0FFFFh 4000 <1> ; ecx = byte count 4001 <1> ;push ecx 4002 000023FA 89EE <1> mov esi, ebp ; user buffer 4003 000023FC BF00000700 <1> mov edi, Cluster_Buffer ; system buffer 4004 00002401 E8D4EB0000 <1> call transfer_from_user_buffer 4005 <1> ;pop ecx 4006 <1> ;jc VIDEO_RETURN 4007 <1> ; 02/08/2022 4008 00002406 7250 <1> jc short P55 4009 <1> ; ecx = transfer (byte) count = character count 4010 00002408 BD00000700 <1> mov ebp, Cluster_Buffer 4011 <1> ; 12/09/2016 4012 0000240D 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; 6?! 4013 <1> ;ja vga_write_string 4014 <1> ; 02/08/2022 4015 00002414 7605 <1> jna short P57 4016 00002416 E99C000000 <1> jmp vga_write_string 4017 <1> P57: 4018 0000241B 0FB6F7 <1> movzx esi, bh ; GET CURRENT CURSOR PAGE 4019 <1> ;sal si, 1 ; CONVERT TO PAGE OFFSET (SI = PAGE) 4020 <1> ; 02/08/2022 4021 0000241E D1E6 <1> sal esi, 1 4022 <1> ; ***** 4023 00002420 66FFB6[DE7C0100] <1> push word [esi+CURSOR_POSN] ; SAVE CURRENT CURSOR POSITION IN STACK 4024 <1> 4025 <1> ;mov ax, 0200h ; SET NEW CURSOR POSITION 4026 <1> ;int 10h 4027 <1> P50next: 4028 00002427 51 <1> push ecx ; **** 4029 00002428 53 <1> push ebx ; *** ; 18/11/2020 4030 00002429 56 <1> push esi ; ** 4031 0000242A 52 <1> push edx ; * 4032 0000242B E8FDFEFFFF <1> call _set_cpos 4033 <1> P50: 4034 00002430 8A4500 <1> mov al, [ebp] ; GET CHARACTER FROM INPUT STRING 4035 00002433 45 <1> inc ebp ; BUMP POINTER TO CHARACTER 4036 <1> 4037 <1> ;----- TEST FOR SPECIAL CHARACTER'S 4038 <1> 4039 00002434 3C08 <1> cmp al, 08h ; IS IT A BACKSPACE 4040 00002436 7410 <1> je short P51 ; BACK_SPACE 4041 00002438 3C0D <1> cmp al, 0Dh ; CR ; IS IT CARRIAGE RETURN 4042 0000243A 740C <1> je short P51 ; CAR_RET 4043 0000243C 3C0A <1> cmp al, 0Ah ; LF ; IS IT A LINE FEED 4044 0000243E 7408 <1> je short P51 ; LINE_FEED 4045 <1> ; 18/11/2020 4046 00002440 3C09 <1> cmp al, 09h ; is it a tab stop 4047 00002442 7404 <1> je short P51 4048 <1> ; 4049 00002444 3C07 <1> cmp al, 07h ; IS IT A BELL 4050 00002446 7515 <1> jne short P52 ; IF NOT THEN DO WRITE CHARACTER 4051 <1> P51: 4052 <1> ;mov ah, 0Eh ; TTY_CHARACTER_WRITE 4053 <1> ;int 10h ; WRITE TTY CHARACTER TO THE CRT 4054 <1> 4055 00002448 E85BFEFFFF <1> call _write_tty_m3 4056 <1> 4057 0000244D 5A <1> pop edx ; * 4058 0000244E 5E <1> pop esi ; ** 4059 <1> 4060 0000244F 668B96[DE7C0100] <1> mov dx, [esi+CURSOR_POSN] ; GET CURRENT CURSOR POSITION 4061 00002456 EB44 <1> jmp short P54 ; SET CURSOR POSITION AND CONTINUE 4062 <1> P55: 4063 00002458 E9D5F6FFFF <1> jmp VIDEO_RETURN 4064 <1> P52: 4065 <1> ;mov cx, 1 ; SET CHARACTER WRITE AMOUNT TO ONE 4066 <1> ; 02/08/2022 4067 0000245D 29C9 <1> sub ecx, ecx 4068 0000245F FEC1 <1> inc cl 4069 <1> ; ecx = 1 4070 00002461 803D[50890100]02 <1> cmp byte [w_str_cmd], 2 ; IS THE ATTRIBUTE IN THE STRING 4071 00002468 7204 <1> jb short P53 ; IF NOT THEN SKIP 4072 0000246A 8A5D00 <1> mov bl, [ebp] ; ELSE GET NEW ATTRIBUTE 4073 0000246D 45 <1> inc ebp ; BUMP STRING POINTER 4074 <1> P53: 4075 <1> ;mov ah, 09h ; GOT_CHARACTER 4076 <1> ;int 10h ; WRITE CHARACTER TO THE CRT 4077 <1> 4078 0000246E E8A1FDFFFF <1> call _write_c_current 4079 <1> 4080 00002473 5A <1> pop edx ; * 4081 <1> 4082 <1> ; 05/12/2020 4083 <1> ; bx is preserved in '_write_c_current' 4084 <1> ; 18/11/2020 4085 <1> ;mov ebx, [esp+4] ; *** 4086 <1> 4087 00002474 0FB6F7 <1> movzx esi, bh ; video page number (0 to 7) 4088 00002477 889E[E7670000] <1> mov [esi+chr_attrib], bl ; color/attribute 4089 <1> 4090 0000247D FEC2 <1> inc dl ; INCREMENT COLUMN COUNTER 4091 0000247F 3A15[E0670000] <1> cmp dl, [CRT_COLS] ; IF COLS ARE WITHIN RANGE FOR THIS MODE 4092 <1> ;jb short P54 ; THEN GO TO COLUMNS SET 4093 00002485 7214 <1> jb short P56 ; 05/12/2020 4094 00002487 FEC6 <1> inc dh ; BUMP ROW COUNTER BY ONE 4095 00002489 28D2 <1> sub dl, dl ; SET COLUMN COUNTER TO ZERO 4096 0000248B 80FE19 <1> cmp dh, 25 ; IF ROWS ARE LESS THAN 25 THEN 4097 <1> ;jb short P54 ; GO TO ROWS_COLUMNS_SET 4098 0000248E 720B <1> jb short P56 ; 05/12/2020 4099 <1> 4100 <1> ; 18/11/2020 4101 <1> ;mov ax, 0E0Ah ; ELSE SCROLL SCREEN 4102 <1> ;int 10h ; RESET ROW COUNTER TO 24 4103 <1> 4104 <1> ; 18/11/2020 4105 00002490 B00A <1> mov al, 0Ah ; line feed 4106 <1> 4107 00002492 E811FEFFFF <1> call _write_tty_m3 4108 <1> 4109 00002497 66BA0018 <1> mov dx, 1800h ; Column = 0, Row = 24 4110 <1> P56: 4111 <1> ; 05/12/2020 4112 <1> ; 18/11/2020 4113 0000249B 5E <1> pop esi ; ** 4114 <1> P54: ; ROW_COLUMNS_SET 4115 <1> ;mov ax, 0200h ; SET NEW CURSOR POSITION COMMAND 4116 <1> ;int 10h ; ESTABLISH NEW CURSOR POSITION 4117 <1> 4118 <1> ; 18/11/2020 4119 0000249C 5B <1> pop ebx ; *** 4120 0000249D 59 <1> pop ecx ; **** 4121 <1> 4122 <1> ;loop P50 ; DO IT ONCE MORE UNTIL (CX) = ZERO 4123 0000249E 6649 <1> dec cx 4124 000024A0 7585 <1> jnz short P50next 4125 <1> 4126 000024A2 665A <1> pop dx ; ***** ; RESTORE OLD CURSOR COORDINATES 4127 <1> 4128 000024A4 F605[50890100]01 <1> test byte [w_str_cmd], 1 ; IF CURSOR WAS NOT TO BE MOVED 4129 <1> ;jnz VIDEO_RETURN ; THEN EXIT WITHOUT RESETTING OLD VALUE 4130 <1> ; 03/08/2022 4131 000024AB 7505 <1> jnz short P58 4132 <1> 4133 <1> ;mov ax, 0200h ; ELSE RESTORE OLD CURSOR POSITION 4134 <1> ;int 10h 4135 <1> ; DONE - EXIT WRITE STRING 4136 000024AD E87BFEFFFF <1> call _set_cpos 4137 <1> P58: 4138 000024B2 E97BF6FFFF <1> jmp VIDEO_RETURN ; RETURN TO CALLER 4139 <1> 4140 <1> vga_write_string: 4141 <1> ; 04/08/2022 - TRDOS 386 Kernel v2.0.5 4142 <1> ; 12/09/2016 - TRDOS 386 (TRDOS v2.0) 4143 <1> ; 4144 <1> ; derived from 'Plex86/Bochs VGABios' source code 4145 <1> ; vgabios-0.7a (2011) 4146 <1> ; by the LGPL VGABios developers Team (2001-2008) 4147 <1> ; 'vgabios.c', ' biosfn_write_string' 4148 <1> 4149 <1> ; INPUT : 4150 <1> ; (AL) = WRITE STRING COMMAND 0 - 3 : 4151 <1> ; (BH) = DISPLAY PAGE (ACTIVE PAGE) : 4152 <1> ; (CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN : 4153 <1> ; (DX) = CURSOR POSITION FOR START OF STRING WRITE : 4154 <1> ; (BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0 OR (AL) = 1 : 4155 <1> ; (EBP) = SOURCE STRING OFFSET : 4156 <1> ; OUTPUT : 4157 <1> ; NONE : 4158 <1> ;-------------------------------------------------------------------------; 4159 <1> 4160 <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor 4161 <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor 4162 <1> ; AL = 02h: Use attributes in string; do not update cursor 4163 <1> ; AL = 03h: Use attributes in string; update cursor 4164 <1> 4165 <1> ; biosfn_write_string(GET_AL(),GET_BH(),GET_BL(),CX,GET_DH(),GET_DL(),ES,BP); 4166 <1> ; static void biosfn_write_string (flag,page,attr,count,row,col,seg,offset) 4167 <1> 4168 <1> ; // Read curs info for the page 4169 <1> ; biosfn_get_cursor_pos(page,&dummy,&oldcurs); 4170 <1> ; bh = video page = 0 4171 <1> ;movzx esi, word [CURSOR_POSN] ; current cursor position for video page 0 4172 <1> 4173 <1> ; // if row=0xff special case : use current cursor position 4174 <1> ; if(row==0xff) 4175 <1> ; {col=oldcurs&0x00ff; 4176 <1> ; row=(oldcurs&0xff00)>>8; 4177 <1> ; } 4178 <1> 4179 <1> ;mov al, [w_str_cmd] 4180 <1> 4181 000024B7 80FEFF <1> cmp dh, 0FFh 4182 000024BA 7407 <1> je short vga_wstr_1 ; user current cursor position 4183 <1> vga_wstr_0: 4184 <1> ; set cursor position 4185 000024BC 668915[DE7C0100] <1> mov [CURSOR_POSN], dx ; save cursor pos for pg 0 4186 <1> vga_wstr_1: 4187 000024C3 66FF35[DE7C0100] <1> push word [CURSOR_POSN] ; * 4188 <1> 4189 <1> ; ebp = string offset in system buffer (user buffer was copied to) 4190 <1> 4191 <1> ; while(count--!=0) 4192 <1> ; { 4193 <1> ; car=read_byte(seg,offset++); 4194 <1> ; if((flag&0x02)!=0) 4195 <1> ; attr=read_byte(seg,offset++); 4196 <1> ; biosfn_write_teletype(car,page,attr,WITH_ATTR); 4197 <1> ; } 4198 <1> 4199 <1> ;push eax ; ** 4200 <1> ;test al, 2 4201 000024CA F605[50890100]02 <1> test byte [w_str_cmd], 2 4202 000024D1 751D <1> jnz short vga_wstr_3 4203 000024D3 881D[EF7C0100] <1> mov [ccolor], bl 4204 <1> vga_wstr_2: 4205 000024D9 51 <1> push ecx 4206 000024DA 8A4500 <1> mov al, [ebp] 4207 000024DD E88F0A0000 <1> call vga_write_teletype 4208 000024E2 59 <1> pop ecx 4209 000024E3 6649 <1> dec cx 4210 000024E5 741E <1> jz short vga_wstr_4 4211 000024E7 45 <1> inc ebp 4212 000024E8 8A1D[EF7C0100] <1> mov bl, [ccolor] 4213 000024EE EBE9 <1> jmp short vga_wstr_2 4214 <1> vga_wstr_3: 4215 000024F0 51 <1> push ecx 4216 000024F1 8A4500 <1> mov al, [ebp] 4217 000024F4 45 <1> inc ebp 4218 000024F5 8A5D00 <1> mov bl, [ebp] 4219 000024F8 E8740A0000 <1> call vga_write_teletype 4220 000024FD 59 <1> pop ecx 4221 000024FE 6649 <1> dec cx 4222 00002500 7403 <1> jz short vga_wstr_4 4223 00002502 45 <1> inc ebp 4224 00002503 EBEB <1> jmp short vga_wstr_3 4225 <1> vga_wstr_4: 4226 <1> ; // Set back curs pos 4227 <1> ; if((flag&0x01)==0) 4228 <1> ; biosfn_set_cursor_pos(page,oldcurs); 4229 <1> ; } 4230 <1> ;pop eax ; ** 4231 00002505 665A <1> pop dx ; word [CURSOR_POSN] ; * 4232 <1> ;test al, 1 4233 00002507 F605[50890100]01 <1> test byte [w_str_cmd], 1 4234 <1> ;jnz VIDEO_RETURN 4235 <1> ; 04/08/2022 4236 0000250E 7507 <1> jnz short vga_wstr_5 4237 00002510 668915[DE7C0100] <1> mov [CURSOR_POSN], dx 4238 <1> vga_wstr_5: 4239 00002517 E916F6FFFF <1> jmp VIDEO_RETURN 4240 <1> 4241 <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5 4242 <1> ; 07/07/2016 4243 <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0) 4244 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 4245 <1> ;------------------------------------------------------ 4246 <1> ; SCROLL UP 4247 <1> ; THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT 4248 <1> ; ENTRY --- 4249 <1> ; CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL 4250 <1> ; DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL 4251 <1> ; BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS 4252 <1> ; BH = FILL VALUE FOR BLANKED LINES 4253 <1> ; AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD) 4254 <1> ; DS = DATA SEGMENT 4255 <1> ; ES = REGEN SEGMENT 4256 <1> ; EXIT -- 4257 <1> ; NOTHING, THE SCREEN IS SCROLLED 4258 <1> ;-------------------------------------------------------- 4259 <1> 4260 <1> ; cl = upper left column 4261 <1> ; ch = upper left row 4262 <1> ; dl = lower rigth column 4263 <1> ; dh = lower right row 4264 <1> ; 4265 <1> ; al = line count (AL=0 means blank entire fields) 4266 <1> ; bl = fill value for blanked lines 4267 <1> ; bh = unused 4268 <1> 4269 <1> GRAPHICS_UP: 4270 <1> ; 07/07/2016 4271 <1> ; AH = Current video mode, [CRT_MODE] 4272 0000251C 80FC07 <1> cmp ah, 7 4273 0000251F 7762 <1> ja short vga_graphics_up 4274 <1> ;je n0 4275 <1> 4276 00002521 88C7 <1> mov bh, al ; save line count in BH 4277 <1> ;mov ax, cx ; GET UPPER LEFT POSITION INTO AX REG 4278 <1> ; 03/08/2022 4279 00002523 89C8 <1> mov eax, ecx 4280 <1> 4281 <1> ;----- USE CHARACTER SUBROUTINE FOR POSITIONING 4282 <1> ;----- ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE 4283 <1> 4284 00002525 E8BA050000 <1> call GRAPH_POSN 4285 <1> ;movzx edi, ax ; SAVE RESULT AS DESTINATION ADDRESS 4286 <1> ; 03/08/2022 4287 0000252A 89C7 <1> mov edi, eax 4288 <1> 4289 <1> ;----- DETERMINE SIZE OF WINDOW 4290 <1> 4291 0000252C 6629CA <1> sub dx, cx 4292 0000252F 6681C20101 <1> add dx, 101h ; ADJUST VALUES 4293 00002534 C0E602 <1> sal dh, 2 ; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR 4294 <1> ; AND EVEN/ODD ROWS 4295 <1> ;----- DETERMINE CRT MODE 4296 <1> 4297 00002537 803D[DE670000]06 <1> cmp byte [CRT_MODE], 6 ; TEST FOR MEDIUM RES 4298 0000253E 7304 <1> jnc short _R7_ ; FIND_SOURCE 4299 <1> 4300 <1> ;----- MEDIUM RES UP 4301 00002540 D0E2 <1> sal dl, 1 ; # COLUMNS * 2, SINCE 2 BYTES/CHAR 4302 <1> ;sal di, 1 ; OFFSET *2 SINCE 2 BYTES/CHAR 4303 <1> ; 03/08/2022 4304 00002542 D1E7 <1> sal edi, 1 4305 <1> 4306 <1> ;----- DETERMINE THE SOURCE ADDRESS IN THE BUFFER 4307 <1> _R7_: ; FIND_SOURCE 4308 00002544 81C700800B00 <1> add edi, 0B8000h 4309 0000254A C0E702 <1> sal bh, 2 ; multiply number of lines by 4 4310 0000254D 7430 <1> jz short _R11 ; IF ZERO, THEN BLANK ENTIRE FIELD 4311 0000254F B050 <1> mov al, 80 ; 80 BYTES/ROW 4312 00002551 F6E7 <1> mul bh ; determine offset to source 4313 <1> ;movzx esi, ax ; offset to source 4314 <1> ; 03/08/2022 4315 00002553 89C6 <1> mov esi, eax 4316 00002555 01FE <1> add esi, edi ; SET UP SOURCE 4317 00002557 88F4 <1> mov ah, dh ; NUMBER OF ROWS IN FIELD 4318 00002559 28FC <1> sub ah, bh ; determine number to move 4319 <1> 4320 <1> ;----- LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS 4321 <1> _R8: ; ROW_LOOP 4322 0000255B E8FD030000 <1> call _R17 ; MOVE ONE ROW 4323 00002560 6681EEB01F <1> sub si, 2000h-80 ; MOVE TO NEXT ROW 4324 00002565 6681EFB01F <1> sub di, 2000h-80 4325 0000256A FECC <1> dec ah ; NUMBER OF ROWS TO MOVE 4326 0000256C 75ED <1> jnz short _R8 ; CONTINUE TILL ALL MOVED 4327 <1> 4328 <1> ;----- FILL IN THE VACATED LINE(S) 4329 <1> _R9: ; CLEAR ENTRY 4330 0000256E 88D8 <1> mov al, bl ; attribute to fill with 4331 <1> _R10_: 4332 00002570 E804040000 <1> call _R18 ; CLEAR THAT ROW 4333 00002575 6681EFB01F <1> sub di, 2000h-80 ; POINT TO NEXT LINE 4334 0000257A FECF <1> dec bh ; number of lines to fill 4335 0000257C 75F2 <1> jnz short _R10_ ; CLEAR LOOP 4336 0000257E C3 <1> retn ; EVERYYHING DONE 4337 <1> 4338 <1> _R11: ; BLANK_FIELD 4339 0000257F 88F7 <1> mov bh, dh ; set blank count to everything in field 4340 00002581 EBEB <1> jmp short _R9 ; CLEAR THE FIELD 4341 <1> 4342 <1> vga_graphics_up: 4343 <1> ; 03/08/2022 - TRDOS 386 Kertnel v2.0.5 4344 <1> ; 12/04/2021 4345 <1> ; 08/08/2016 4346 <1> ; 07/08/2016 4347 <1> ; 04/08/2016 4348 <1> ; 01/08/2016 4349 <1> ; 31/07/2016 4350 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 4351 <1> ; 4352 <1> ; derived from 'Plex86/Bochs VGABios' source code 4353 <1> ; vgabios-0.7a (2011) 4354 <1> ; by the LGPL VGABios developers Team (2001-2008) 4355 <1> ; 'vgabios.c', 'biosfn_scroll' 4356 <1> ; 4357 <1> 4358 <1> ; cl = upper left column 4359 <1> ; ch = upper left row 4360 <1> ; dl = lower rigth column 4361 <1> ; dh = lower right row 4362 <1> ; 4363 <1> ; al = line count (AL=0 means blank entire fields) 4364 <1> ; bl = fill value for blanked lines 4365 <1> ; bh = unused 4366 <1> ; 4367 <1> ; ah = [CRT_MODE], current video mode 4368 <1> 4369 00002583 88C7 <1> mov bh, al ; 31/07/2016 4370 00002585 BE[02680000] <1> mov esi, vga_g_modes 4371 0000258A 89F7 <1> mov edi, esi 4372 0000258C 83C708 <1> add edi, vga_g_mode_count 4373 <1> vga_g_up_0: 4374 0000258F AC <1> lodsb 4375 00002590 38E0 <1> cmp al, ah ; [CRT_MODE] 4376 00002592 7405 <1> je short vga_g_up_1 4377 00002594 39FE <1> cmp esi, edi 4378 00002596 72F7 <1> jb short vga_g_up_0 4379 <1> ;xor bh, bh ; 31/07/2016) 4380 00002598 C3 <1> retn ; nothing to do 4381 <1> vga_g_up_1: 4382 00002599 88F8 <1> mov al, bh ; 31/07/2016 4383 0000259B 83C64F <1> add esi, vga_g_memmodel - (vga_g_modes + 1) 4384 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 4385 <1> 4386 <1> ; if(rlr>=nbrows)rlr=nbrows-1; 4387 <1> ; if(clr>=nbcols)clr=nbcols-1; 4388 <1> ; if(nblines>nbrows)nblines=0; 4389 <1> ; cols=clr-cul+1; 4390 <1> 4391 0000259E 3A35[E6670000] <1> cmp dh, [VGA_ROWS] 4392 000025A4 7208 <1> jb short vga_g_up_2 4393 000025A6 8A35[E6670000] <1> mov dh, [VGA_ROWS] 4394 000025AC FECE <1> dec dh 4395 <1> vga_g_up_2: 4396 000025AE 3A15[E0670000] <1> cmp dl, [CRT_COLS] ; = [VGA_COLS] 4397 000025B4 7208 <1> jb short vga_g_up_3 4398 000025B6 8A15[E0670000] <1> mov dl, [CRT_COLS] 4399 000025BC FECA <1> dec dl 4400 <1> vga_g_up_3: 4401 000025BE 3A05[E6670000] <1> cmp al, [VGA_ROWS] 4402 000025C4 7602 <1> jna short vga_g_up_4 4403 000025C6 28C0 <1> sub al, al ; 0 4404 <1> vga_g_up_4: 4405 000025C8 88D7 <1> mov bh, dl ; clr 4406 000025CA 28CF <1> sub bh, cl ; cul 4407 000025CC FEC7 <1> inc bh ; cols = clr-cul+1 4408 <1> 4409 000025CE 20C0 <1> and al, al ; nblines = 0 4410 000025D0 7559 <1> jnz short vga_g_up_6 4411 000025D2 20ED <1> and ch, ch ; rul = 0 4412 000025D4 7555 <1> jnz short vga_g_up_6 4413 000025D6 20C9 <1> and cl, cl ; cul = 0 4414 000025D8 7551 <1> jnz short vga_g_up_6 4415 <1> 4416 <1> ;push ax 4417 <1> ; 12/04/2021 4418 000025DA 50 <1> push eax 4419 000025DB A0[E6670000] <1> mov al, [VGA_ROWS] 4420 000025E0 FEC8 <1> dec al 4421 000025E2 38C6 <1> cmp dh, al ; rlr = nbrows-1 4422 000025E4 7545 <1> jne short vga_g_up_5 4423 000025E6 A0[E0670000] <1> mov al, [CRT_COLS] ; = VGA_COLS 4424 000025EB FEC8 <1> dec al 4425 000025ED 38C2 <1> cmp dl, al ; clr = nbcols-1 4426 <1> ;jne short vga_g_up_5 4427 <1> ;;pop ax 4428 <1> ; 12/04/2021 4429 000025EF 58 <1> pop eax 4430 000025F0 7539 <1> jne short vga_g_up_5 4431 <1> 4432 000025F2 66B80502 <1> mov ax, 0205h 4433 000025F6 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4434 000025FA 66EF <1> out dx, ax 4435 000025FC A0[E6670000] <1> mov al, [VGA_ROWS] 4436 00002601 8A25[E0670000] <1> mov ah, [CRT_COLS] ; = [VGA_COLS] 4437 00002607 F6E4 <1> mul ah 4438 00002609 0FB7D0 <1> movzx edx, ax 4439 <1> ; 08/08/2016 4440 0000260C 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 4441 00002613 F7E2 <1> mul edx 4442 <1> ; eax = byte count 4443 00002615 89C1 <1> mov ecx, eax 4444 <1> ;; 07/08/2016 4445 <1> ;shl dx, 3 ; * 8 ; * [CHAR_HEIGHT] 4446 <1> ;mov ecx, edx 4447 00002617 88D8 <1> mov al, bl ; fill value for blanked lines 4448 00002619 BF00000A00 <1> mov edi, 0A0000h 4449 0000261E F3AA <1> rep stosb 4450 <1> 4451 <1> ;mov ax, 5 4452 <1> ; 03/08/2022 4453 00002620 30E4 <1> xor ah, ah 4454 00002622 B005 <1> mov al, 5 4455 <1> 4456 00002624 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4457 00002628 66EF <1> out dx, ax ; 0005h 4458 <1> 4459 0000262A C3 <1> retn 4460 <1> 4461 <1> vga_g_up_5: 4462 <1> ;;pop ax 4463 <1> ; 12/04/2021 4464 <1> ;pop eax 4465 <1> 4466 <1> vga_g_up_6: 4467 <1> ; [ESI] = VGA memory model number for current video mode 4468 <1> ; 4469 <1> ; LINEAR8 equ 5 4470 <1> ; PLANAR4 equ 4 4471 <1> ; PLANAR1 equ 3 4472 <1> 4473 0000262B 803E04 <1> cmp byte [esi], PLANAR4 4474 0000262E 7424 <1> je short vga_g_up_planar 4475 00002630 803E03 <1> cmp byte [esi], PLANAR1 4476 00002633 741F <1> je short vga_g_up_planar 4477 <1> vga_g_up_linear8: 4478 <1> ; 07/07/2016 (TEMPORARY) 4479 <1> ; 4480 <1> ; cl = upper left column ; cul 4481 <1> ; ch = upper left row ; rul 4482 <1> ; dl = lower rigth column ; clr 4483 <1> ; dh = lower right row ; rlr 4484 <1> 4485 <1> vga_g_up_l0: 4486 <1> ;{for(i=rul;i<=rlr;i++) 4487 <1> ; if((i+nblines>rlr)||(nblines==0)) 4488 00002635 08C0 <1> or al, al 4489 00002637 7414 <1> jz short vga_g_up_l2 4490 00002639 88C4 <1> mov ah, al 4491 0000263B 00EC <1> add ah, ch ; i+nblines 4492 <1> ;jc short vga_g_up_l2 4493 0000263D 38F4 <1> cmp ah, dh 4494 0000263F 770C <1> ja short vga_g_up_l2 4495 <1> ; else 4496 <1> ; vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight); 4497 00002641 E8F2000000 <1> call vgamem_copy_l8 4498 <1> vga_g_up_l1: 4499 00002646 FEC5 <1> inc ch 4500 00002648 38F5 <1> cmp ch, dh 4501 0000264A 76E9 <1> jna short vga_g_up_l0 4502 0000264C C3 <1> retn 4503 <1> vga_g_up_l2: 4504 <1> ; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr); 4505 0000264D E84C010000 <1> call vgamem_fill_l8 4506 00002652 EBF2 <1> jmp short vga_g_up_l1 4507 <1> 4508 <1> vga_g_up_planar: 4509 <1> ; cl = upper left column ; cul 4510 <1> ; ch = upper left row ; rul 4511 <1> ; dl = lower rigth column ; clr 4512 <1> ; dh = lower right row ; rlr 4513 <1> vga_g_up_pl0: 4514 <1> ;{for(i=rul;i<=rlr;i++) 4515 <1> ; if((i+nblines>rlr)||(nblines==0)) 4516 00002654 20C0 <1> and al, al 4517 00002656 7414 <1> jz short vga_g_up_pl2 4518 00002658 88C4 <1> mov ah, al 4519 0000265A 00EC <1> add ah, ch ; i+nblines 4520 <1> ;jc short vga_g_up_pl2 4521 0000265C 38F4 <1> cmp ah, dh 4522 0000265E 770C <1> ja short vga_g_up_pl2 4523 <1> ; else 4524 <1> ; vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight); 4525 00002660 E80E000000 <1> call vgamem_copy_pl4 4526 <1> vga_g_up_pl1: 4527 00002665 FEC5 <1> inc ch 4528 00002667 38F5 <1> cmp ch, dh 4529 00002669 76E9 <1> jna short vga_g_up_pl0 4530 0000266B C3 <1> retn 4531 <1> vga_g_up_pl2: 4532 <1> ; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr); 4533 0000266C E870000000 <1> call vgamem_fill_pl4 4534 00002671 EBF2 <1> jmp short vga_g_up_pl1 4535 <1> 4536 <1> vgamem_copy_pl4: 4537 <1> ; 08/08/2016 4538 <1> ; 07/08/2016 4539 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 4540 <1> ; 4541 <1> ; derived from 'Plex86/Bochs VGABios' source code 4542 <1> ; vgabios-0.7a (2011) 4543 <1> ; by the LGPL VGABios developers Team (2001-2008) 4544 <1> ; 'vgabios.c', 'vgamem_copy_pl4' 4545 <1> ; 4546 <1> ; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight) 4547 <1> ; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i), 4548 <1> ; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight 4549 <1> 4550 <1> ; src=ysrc*cheight*nbcols+xstart; 4551 <1> ; dest=ydest*cheight*nbcols+xstart; 4552 <1> 4553 00002673 52 <1> push edx 4554 00002674 50 <1> push eax 4555 <1> 4556 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0105) 4557 00002675 66B80501 <1> mov ax, 0105h 4558 00002679 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4559 0000267D 66EF <1> out dx, ax 4560 <1> 4561 <1> ; 07/08/2016 4562 <1> ;mov ah, [esp+1] 4563 <1> ;movzx edx, ah ; ysrc 4564 0000267F 0FB6542401 <1> movzx edx, byte [esp+1] 4565 <1> ; 08/08/2016 4566 00002684 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 4567 0000268B 8A25[E0670000] <1> mov ah, [CRT_COLS] ; nbcols 4568 00002691 F6E4 <1> mul ah 4569 <1> ;; 07/08/2016 4570 <1> ;movzx eax, byte [CRT_COLS] 4571 <1> ;shl ax, 3 ; * 8 ; * [CHAR_HEIGHT] 4572 00002693 50 <1> push eax ; cheight * nbcols 4573 00002694 F7E2 <1> mul edx ; * ysrc 4574 <1> ; eax = ysrc * cheight * nbcols 4575 <1> ; edx = 0 4576 00002696 88CA <1> mov dl, cl ; edx = xstart 4577 00002698 01D0 <1> add eax, edx 4578 0000269A 89C6 <1> mov esi, eax ; src 4579 0000269C 88EA <1> mov dl, ch ; ydest 4580 0000269E 58 <1> pop eax ; cheight * nbcols 4581 0000269F F7E2 <1> mul edx 4582 <1> ; eax = ydest * cheight * nbcols 4583 000026A1 88CA <1> mov dl, cl ; edx = xstart 4584 000026A3 01D0 <1> add eax, edx 4585 000026A5 89C7 <1> mov edi, eax ; dest 4586 <1> ; esi = src 4587 <1> ; edi = dest 4588 <1> ; for(i=0;i ; { 4590 <1> ; memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols); 4591 <1> ; } 4592 000026A7 51 <1> push ecx 4593 000026A8 B900000A00 <1> mov ecx, 0A0000h 4594 000026AD 01CE <1> add esi, ecx 4595 000026AF 01CF <1> add edi, ecx 4596 <1> ; 08/08/2016 4597 000026B1 8A35[E2670000] <1> mov dh, [CHAR_HEIGHT] 4598 <1> ;; 07/08/2016 4599 <1> ;mov dh, 8 ; 07/08/2016 4600 000026B7 28D2 <1> sub dl, dl ; i 4601 <1> vgamem_copy_pl4_0: 4602 000026B9 56 <1> push esi 4603 000026BA 57 <1> push edi 4604 000026BB 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] 4605 000026C2 F6E2 <1> mul dl 4606 <1> ; eax = i * nbcols 4607 000026C4 01C7 <1> add edi, eax ; dest+i*nbcols 4608 000026C6 01C6 <1> add esi, eax 4609 000026C8 0FB6CF <1> movzx ecx, bh ; cols 4610 000026CB F3A4 <1> rep movsb 4611 000026CD 5F <1> pop edi 4612 000026CE 5E <1> pop esi 4613 000026CF FECE <1> dec dh 4614 000026D1 75E6 <1> jnz short vgamem_copy_pl4_0 4615 <1> vgamem_copy_pl4_1: 4616 000026D3 59 <1> pop ecx 4617 <1> 4618 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0005); 4619 000026D4 66B80500 <1> mov ax, 0005h 4620 000026D8 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4621 000026DC 66EF <1> out dx, ax 4622 <1> 4623 000026DE 58 <1> pop eax 4624 000026DF 5A <1> pop edx 4625 <1> 4626 000026E0 C3 <1> retn 4627 <1> 4628 <1> vgamem_fill_pl4: 4629 <1> ; 08/08/2016 4630 <1> ; 07/08/2016 4631 <1> ; 04/08/2016 4632 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 4633 <1> ; 4634 <1> ; derived from 'Plex86/Bochs VGABios' source code 4635 <1> ; vgabios-0.7a (2011) 4636 <1> ; by the LGPL VGABios developers Team (2001-2008) 4637 <1> ; 'vgabios.c', 'vgamem_fill_pl4' 4638 <1> ; 4639 <1> ; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr) 4640 <1> ; cl = xstart, edi = ch = ystart, bh = cols, 4641 <1> ; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0 4642 <1> 4643 <1> ; dest=ystart*cheight*nbcols+xstart; 4644 000026E1 52 <1> push edx 4645 000026E2 50 <1> push eax 4646 <1> 4647 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0205) 4648 000026E3 66B80502 <1> mov ax, 0205h 4649 000026E7 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4650 000026EB 66EF <1> out dx, ax 4651 <1> 4652 <1> ; 08/08/2016 4653 000026ED 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 4654 000026F4 F6E5 <1> mul ch 4655 <1> ;; 07/08/2016 4656 <1> ;movzx eax, ch 4657 <1> ;shl ax, 3 ; * 8 ; * [CHAR_HEIGHT] 4658 000026F6 0FB615[E0670000] <1> movzx edx, byte [CRT_COLS] ; = [VGA_COLS] 4659 000026FD F7E2 <1> mul edx 4660 <1> ; edx = 0 4661 000026FF 88CA <1> mov dl, cl 4662 00002701 01D0 <1> add eax, edx 4663 00002703 89C7 <1> mov edi, eax 4664 <1> ; edi = dest 4665 <1> ; for(i=0;i ; { 4667 <1> ; memsetb(0xa000,dest+i*nbcols,attr,cols); 4668 <1> ; } 4669 00002705 81C700000A00 <1> add edi, 0A0000h 4670 0000270B 51 <1> push ecx 4671 <1> ; 08/08/2016 4672 0000270C 8A35[E2670000] <1> mov dh, [CHAR_HEIGHT] 4673 <1> ;; 07/08/2016 4674 <1> ;mov dh, 8 ; 07/08/2016 4675 00002712 28D2 <1> sub dl, dl ; i 4676 <1> vgamem_fill_pl4_0: 4677 00002714 57 <1> push edi 4678 00002715 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] 4679 0000271C F6E2 <1> mul dl 4680 <1> ; eax = i * nbcols 4681 0000271E 01C7 <1> add edi, eax ; dest+i*nbcols 4682 00002720 88D8 <1> mov al, bl ; attr ; 04/08/2016 4683 00002722 0FB6CF <1> movzx ecx, bh ; cols 4684 00002725 F3AA <1> rep stosb 4685 00002727 5F <1> pop edi 4686 00002728 75EA <1> jnz short vgamem_fill_pl4_0 4687 <1> vgamem_fill_pl4_1: 4688 0000272A 59 <1> pop ecx 4689 <1> 4690 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0005); 4691 0000272B 66B80500 <1> mov ax, 0005h 4692 0000272F 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4693 00002733 66EF <1> out dx, ax 4694 <1> 4695 00002735 58 <1> pop eax 4696 00002736 5A <1> pop edx 4697 <1> 4698 00002737 C3 <1> retn 4699 <1> 4700 <1> vgamem_copy_l8: 4701 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 4702 <1> ; 08/08/2016 4703 <1> ; 07/08/2016 4704 <1> ; 06/08/2016 4705 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 4706 <1> ; 4707 <1> ; TEMPORARY 4708 <1> ; 4709 <1> ; derived from 'Plex86/Bochs VGABios' source code 4710 <1> ; vgabios-0.7a (2011) 4711 <1> ; by the LGPL VGABios developers Team (2001-2008) 4712 <1> ; 'vgabios.c', 'vgamem_copy_pl4' 4713 <1> ; 4714 <1> ; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight) 4715 <1> ; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i), 4716 <1> ; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight 4717 <1> 4718 <1> ; src=ysrc*cheight*nbcols+xstart; 4719 <1> ; dest=ydest*cheight*nbcols+xstart; 4720 <1> 4721 00002738 52 <1> push edx 4722 00002739 50 <1> push eax 4723 <1> 4724 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0105) 4725 <1> ;mov ax, 0105h 4726 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4727 <1> ;out dx, ax 4728 <1> 4729 <1> ;mov ah, [esp+1] 4730 <1> 4731 0000273A 0FB6D4 <1> movzx edx, ah ; ysrc 4732 <1> ; 08/08/2016 4733 0000273D 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 4734 00002744 8A25[E0670000] <1> mov ah, [CRT_COLS] ; nbcols 4735 0000274A F6E4 <1> mul ah 4736 <1> ;; 07/08/2016 4737 <1> ;movzx eax, byte [CRT_COLS] 4738 <1> ;shl ax, 3 ; * 8 ; * [CHAR_HEIGHT] 4739 0000274C 50 <1> push eax ; cheight * nbcols 4740 0000274D F7E2 <1> mul edx ; * ysrc 4741 <1> ; eax = ysrc * cheight * nbcols 4742 <1> ; edx = 0 4743 0000274F 88CA <1> mov dl, cl ; edx = xstart 4744 00002751 01D0 <1> add eax, edx 4745 00002753 89C6 <1> mov esi, eax ; src 4746 <1> ;shl si, 3 ; * 8 ; 06/08/2016 4747 <1> ; 02/08/2022 4748 00002755 C1E603 <1> shl esi, 3 4749 00002758 88EA <1> mov dl, ch ; ydest 4750 0000275A 58 <1> pop eax ; cheight * nbcols 4751 0000275B F7E2 <1> mul edx 4752 <1> ; eax = ydest * cheight * nbcols 4753 0000275D 88CA <1> mov dl, cl ; edx = xstart 4754 0000275F 01D0 <1> add eax, edx 4755 00002761 89C7 <1> mov edi, eax ; dest 4756 <1> ;shl di, 3 ; * 8 ; 06/08/2016 4757 <1> ; 02/08/2022 4758 00002763 C1E703 <1> shl edi, 3 4759 <1> ; esi = src 4760 <1> ; edi = dest 4761 <1> ; for(i=0;i ; { 4763 <1> ; memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols); 4764 <1> ; } 4765 00002766 51 <1> push ecx 4766 00002767 B900000A00 <1> mov ecx, 0A0000h 4767 0000276C 01CE <1> add esi, ecx 4768 0000276E 01CF <1> add edi, ecx 4769 <1> ; 08/08/2016 4770 00002770 8A35[E2670000] <1> mov dh, [CHAR_HEIGHT] 4771 <1> ;; 07/08/2016 4772 <1> ;mov dh, 8 ; 07/08/2016 4773 00002776 28D2 <1> sub dl, dl ; i 4774 <1> vgamem_copy_l8_0: 4775 00002778 56 <1> push esi 4776 00002779 57 <1> push edi 4777 0000277A 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] 4778 00002781 F6E2 <1> mul dl 4779 <1> ; eax = i * nbcols 4780 <1> ;shl ax, 3 ; * 8 ; 06/08/2016 4781 <1> ; 02/08/2022 4782 00002783 C1E003 <1> shl eax, 3 4783 00002786 01C7 <1> add edi, eax ; dest+i*nbcols 4784 00002788 01C6 <1> add esi, eax 4785 0000278A 0FB6CF <1> movzx ecx, bh ; cols 4786 <1> ;shl cx, 3 ; * 8 ; 06/08/2016 4787 <1> ; 02/08/2022 4788 0000278D C1E103 <1> shl ecx, 3 4789 00002790 F3A4 <1> rep movsb 4790 00002792 5F <1> pop edi 4791 00002793 5E <1> pop esi 4792 00002794 FEC2 <1> inc dl ; 06/08/2016 4793 00002796 FECE <1> dec dh 4794 00002798 75DE <1> jnz short vgamem_copy_l8_0 4795 <1> vgamem_copy_l8_1: 4796 0000279A 59 <1> pop ecx 4797 <1> 4798 <1> ;; outw(VGAREG_GRDC_ADDRESS, 0x0005); 4799 <1> ;mov ax, 0005h 4800 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4801 <1> ;out dx, ax 4802 <1> 4803 0000279B 58 <1> pop eax 4804 0000279C 5A <1> pop edx 4805 <1> 4806 0000279D C3 <1> retn 4807 <1> 4808 <1> vgamem_fill_l8: 4809 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 4810 <1> ; 08/08/2016 4811 <1> ; 07/08/2016 4812 <1> ; 06/08/2016 4813 <1> ; 04/08/2016 4814 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 4815 <1> ; 4816 <1> ; TEMPORARY 4817 <1> ; 4818 <1> ; derived from 'Plex86/Bochs VGABios' source code 4819 <1> ; vgabios-0.7a (2011) 4820 <1> ; by the LGPL VGABios developers Team (2001-2008) 4821 <1> ; 'vgabios.c', 'vgamem_fill_pl4' 4822 <1> ; 4823 <1> ; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr) 4824 <1> ; cl = xstart, edi = ch = ystart, bh = cols, 4825 <1> ; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0 4826 <1> 4827 <1> ; dest=ystart*cheight*nbcols+xstart; 4828 0000279E 52 <1> push edx 4829 0000279F 50 <1> push eax 4830 <1> 4831 <1> ;; outw(VGAREG_GRDC_ADDRESS, 0x0205) 4832 <1> ;mov ax, 0205h 4833 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4834 <1> ;out dx, ax 4835 <1> 4836 <1> ; 08/08/2016 4837 000027A0 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 4838 000027A7 F6E5 <1> mul ch 4839 <1> ;; 07/08/2016 4840 <1> ;movzx eax, ch 4841 <1> ;shl ax, 3 ; * 8 ; * [CHAR_HEIGHT] 4842 000027A9 0FB615[E0670000] <1> movzx edx, byte [CRT_COLS] ; = [VGA_COLS] 4843 000027B0 F7E2 <1> mul edx 4844 <1> ; edx = 0 4845 000027B2 88CA <1> mov dl, cl 4846 000027B4 01D0 <1> add eax, edx 4847 000027B6 89C7 <1> mov edi, eax 4848 <1> ;shl di, 3 ; * 8 ; 06/08/2016 4849 <1> ; 02/08/2022 4850 000027B8 C1E703 <1> shl edi, 3 4851 <1> ; edi = dest 4852 <1> ; for(i=0;i ; { 4854 <1> ; memsetb(0xa000,dest+i*nbcols,attr,cols); 4855 <1> ; } 4856 000027BB 81C700000A00 <1> add edi, 0A0000h 4857 000027C1 51 <1> push ecx 4858 <1> ; 08/08/2016 4859 000027C2 8A35[E2670000] <1> mov dh, [CHAR_HEIGHT] 4860 <1> ;; 07/08/2016 4861 <1> ;mov dh, 8 ; 07/08/2016 4862 000027C8 28D2 <1> sub dl, dl ; i 4863 <1> vgamem_fill_l8_0: 4864 000027CA 57 <1> push edi 4865 000027CB 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] 4866 000027D2 F6E2 <1> mul dl 4867 <1> ; eax = i * nbcols 4868 <1> ;shl ax, 3 ; * 8 ; 06/08/2016 4869 <1> ; 02/08/2022 4870 000027D4 C1E003 <1> shl eax, 3 4871 000027D7 01C7 <1> add edi, eax ; dest+i*nbcols 4872 000027D9 88D8 <1> mov al, bl ; attr ; 04/08/2016 4873 000027DB 0FB6CF <1> movzx ecx, bh ; cols 4874 <1> ;shl cx, 3 ; * 8 ; 06/08/2016 4875 <1> ; 02/08/2022 4876 000027DE C1E103 <1> shl ecx, 3 4877 000027E1 F3AA <1> rep stosb 4878 000027E3 5F <1> pop edi 4879 000027E4 FEC2 <1> inc dl ; 06/08/2016 4880 000027E6 FECE <1> dec dh 4881 000027E8 75E0 <1> jnz short vgamem_fill_l8_0 4882 <1> vgamem_fill_l8_1: 4883 000027EA 59 <1> pop ecx 4884 <1> 4885 <1> ;; outw(VGAREG_GRDC_ADDRESS, 0x0005); 4886 <1> ;mov ax, 0005h 4887 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 4888 <1> ;out dx, ax 4889 <1> 4890 000027EB 58 <1> pop eax 4891 000027EC 5A <1> pop edx 4892 <1> 4893 000027ED C3 <1> retn 4894 <1> 4895 <1> ; 03/08/2022 - TRDOS 386 Kernel V2.0.5 4896 <1> ; 07/07/2016 4897 <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0) 4898 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 4899 <1> ;------------------------------------------------------ 4900 <1> ; SCROLL DOWN 4901 <1> ; THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT 4902 <1> ; ENTRY -- 4903 <1> ; CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL 4904 <1> ; DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL 4905 <1> ; BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS 4906 <1> ; BH = FILL VALUE FOR BLANKED LINES 4907 <1> ; AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD) 4908 <1> ; DS = DATA SEGMENT 4909 <1> ; ES = REGEN SEGMENT 4910 <1> ; EXIT -- 4911 <1> ; NOTHING, THE SCREEN IS SCROLLED 4912 <1> ;-------------------------------------------------------- 4913 <1> 4914 <1> ; cl = upper left column 4915 <1> ; ch = upper left row 4916 <1> ; dl = lower rigth column 4917 <1> ; dh = lower right row 4918 <1> ; 4919 <1> ; al = line count (AL=0 means blank entire fields) 4920 <1> ; bl = fill value for blanked lines 4921 <1> ; bh = unused 4922 <1> 4923 <1> GRAPHICS_DOWN: 4924 <1> ; 07/07/2016 4925 <1> ; ah = Current video mode, [CRT_MODE] 4926 <1> ; std ; SET DIRECTION 4927 000027EE 80FC07 <1> cmp ah, 7 4928 000027F1 7769 <1> ja short vga_graphics_down ; 03/08/2022 4929 <1> ;je _n0 4930 <1> 4931 000027F3 88C7 <1> mov bh, al ; save line count in BH 4932 <1> ;mov ax, dx ; GET LOWER RIGHT POSITION INTO AX REG 4933 <1> ; 03/08/2022 4934 000027F5 89D0 <1> mov eax, edx 4935 <1> 4936 <1> ;----- USE CHARACTER SUBROUTINE FOR POSITIONING 4937 <1> ;----- ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE 4938 <1> 4939 000027F7 E8E8020000 <1> call GRAPH_POSN 4940 <1> ;movzx edi, ax ; SAVE RESULT AS DESTINATION ADDRESS 4941 <1> ; 03/08/2022 4942 000027FC 89C7 <1> mov edi, eax 4943 <1> 4944 <1> ;----- DETERMINE SIZE OF WINDOW 4945 <1> 4946 000027FE 6629CA <1> sub dx, cx 4947 00002801 6681C20101 <1> add dx, 101h ; ADJUST VALUES 4948 00002806 C0E602 <1> sal dh, 2 ; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR 4949 <1> ; AND EVEN/ODD ROWS 4950 <1> ;----- DETERMINE CRT MODE 4951 <1> 4952 00002809 803D[DE670000]06 <1> cmp byte [CRT_MODE], 6 ; TEST FOR MEDIUM RES 4953 00002810 7305 <1> jnc short _R12 ; FIND_SOURCE_DOWN 4954 <1> 4955 <1> ;----- MEDIUM RES DOWN 4956 00002812 D0E2 <1> sal dl, 1 ; # COLUMNS * 2, SINCE 2 BYTES/CHAR 4957 <1> ;sal di, 1 ; OFFSET *2 SINCE 2 BYTES/CHAR 4958 <1> ; 03/08/2022 4959 00002814 D1E7 <1> sal edi, 1 4960 <1> ;inc di ; POINT TO LAST BYTE 4961 <1> ; 03/08/2022 4962 00002816 47 <1> inc edi 4963 <1> 4964 <1> ;----- DETERMINE THE SOURCE ADDRESS IN THE BUFFER 4965 <1> 4966 <1> _R12: ; FIND_SOURCE_DOWN 4967 00002817 81C700800B00 <1> add edi, 0B8000h 4968 0000281D 6681C7F000 <1> add di, 240 ; POINT TO LAST ROW OF PIXELS 4969 00002822 C0E702 <1> sal bh, 2 ; multiply number of lines by 4 4970 00002825 74(06) <1> jz short 6 ; IF ZERO, THEN BLANK ENTIRE FIELD 4971 00002827 B050 <1> mov al, 80 ; 80 BYTES/ROW 4972 00002829 F6E7 <1> mul bh ; determine offset to source 4973 0000282B 89FE <1> mov esi, edi ; SET UP SOURCE 4974 <1> ;sub si, ax ; SUBTRACT THE OFFSET 4975 <1> ; 03/08/2022 4976 0000282D 29C6 <1> sub esi, eax 4977 0000282F 88F4 <1> mov ah, dh ; NUMBER OF ROWS IN FIELD 4978 00002831 28FC <1> sub ah, bh ; determine number to move 4979 <1> 4980 <1> ;----- LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS 4981 <1> 4982 <1> _R13: ; ROW_LOOP_DOWN 4983 00002833 E825010000 <1> call _R17 ; MOVE ONE ROW 4984 00002838 6681EE5020 <1> sub si, 2000h+80 ; MOVE TO NEXT ROW 4985 0000283D 6681EF5020 <1> sub di, 2000h+80 4986 00002842 FECC <1> dec ah ; NUMBER OF ROWS TO MOVE 4987 00002844 75ED <1> jnz short _R13 ; CONTINUE TILL ALL MOVED 4988 <1> 4989 <1> ;----- FILL IN THE VACATED LINE(S) 4990 <1> _R14: ; CLEAR_ENTRY_DOWN 4991 00002846 88D8 <1> mov al, bl ; attribute to fill with 4992 <1> _R15_: ; CLEAR_LOOP_DOWN 4993 00002848 E82C010000 <1> call _R18 ; CLEAR A ROW 4994 0000284D 6681EF5020 <1> sub di, 2000h+80 ; POINT TO NEXT LINE 4995 00002852 FECF <1> dec bh ; number of lines to fill 4996 00002854 75F2 <1> jnz short _R15_ ; CLEAR_LOOP_DOWN 4997 <1> ; 18/11/2020 4998 00002856 FC <1> cld ; RESET THE DIRECTION FLAG 4999 <1> 5000 00002857 C3 <1> retn ; EVERYTHING DONE 5001 <1> 5002 <1> _R16: ; BLANK_FIELD_DOWN 5003 00002858 88F7 <1> mov bh, dh ; set blank count to everything in field 5004 0000285A EBEA <1> jmp short _R14 ; CLEAR THE FIELD 5005 <1> 5006 <1> vga_graphics_down: 5007 <1> ; 03/08/2022 - TRDOS 386 Kertnel v2.0.5 5008 <1> ; 12/04/2021 5009 <1> ; 08/08/2016 5010 <1> ; 07/08/2016 5011 <1> ; 31/07/2016 5012 <1> ; 07/07/2016 - TRDOS 386 (TRDOS v2.0) 5013 <1> ; 5014 <1> ; derived from 'Plex86/Bochs VGABios' source code 5015 <1> ; vgabios-0.7a (2011) 5016 <1> ; by the LGPL VGABios developers Team (2001-2008) 5017 <1> ; 'vgabios.c', 'biosfn_scroll' 5018 <1> ; 5019 <1> 5020 <1> ; cl = upper left column 5021 <1> ; ch = upper left row 5022 <1> ; dl = lower rigth column 5023 <1> ; dh = lower right row 5024 <1> ; 5025 <1> ; al = line count (AL=0 means blank entire fields) 5026 <1> ; bl = fill value for blanked lines 5027 <1> ; bh = unused 5028 <1> ; 5029 <1> ; ah = [CRT_MODE], current video mode 5030 <1> 5031 0000285C FC <1> cld ; !!! Clear direction flag !!! 5032 <1> 5033 0000285D 88C7 <1> mov bh, al ; 31/07/2016 5034 <1> 5035 0000285F BE[FA670000] <1> mov esi, vga_modes 5036 00002864 89F7 <1> mov edi, esi 5037 00002866 83C710 <1> add edi, vga_mode_count 5038 <1> vga_g_down_0: 5039 00002869 AC <1> lodsb 5040 0000286A 38E0 <1> cmp al, ah ; [CRT_MODE] 5041 0000286C 7405 <1> je short vga_g_down_1 5042 0000286E 39FE <1> cmp esi, edi 5043 00002870 72F7 <1> jb short vga_g_down_0 5044 <1> ; xor bh, bh ; 31/07/2016 5045 00002872 C3 <1> retn ; nothing to do 5046 <1> vga_g_down_1: 5047 00002873 88F8 <1> mov al, bh ; 31/07/2016 5048 00002875 83C64F <1> add esi, vga_memmodel - (vga_modes + 1) 5049 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 5050 <1> 5051 <1> ; if(rlr>=nbrows)rlr=nbrows-1; 5052 <1> ; if(clr>=nbcols)clr=nbcols-1; 5053 <1> ; if(nblines>nbrows)nblines=0; 5054 <1> ; cols=clr-cul+1; 5055 <1> 5056 00002878 3A35[E6670000] <1> cmp dh, [VGA_ROWS] 5057 0000287E 7208 <1> jb short vga_g_down_2 5058 00002880 8A35[E6670000] <1> mov dh, [VGA_ROWS] 5059 00002886 FECE <1> dec dh 5060 <1> vga_g_down_2: 5061 00002888 3A15[E0670000] <1> cmp dl, [CRT_COLS] ; = [VGA_COLS] 5062 0000288E 7208 <1> jb short vga_g_down_3 5063 00002890 8A15[E0670000] <1> mov dl, [CRT_COLS] 5064 00002896 FECA <1> dec dl 5065 <1> vga_g_down_3: 5066 00002898 3A05[E6670000] <1> cmp al, [VGA_ROWS] 5067 0000289E 7602 <1> jna short vga_g_down_4 5068 000028A0 28C0 <1> sub al, al ; 0 5069 <1> vga_g_down_4: 5070 000028A2 88F7 <1> mov bh, dh ; clr 5071 000028A4 28CF <1> sub bh, cl ; cul 5072 000028A6 FEC7 <1> inc bh ; cols = clr-cul+1 5073 <1> 5074 000028A8 20C0 <1> and al, al ; nblines = 0 5075 000028AA 7559 <1> jnz short vga_g_down_6 5076 000028AC 20ED <1> and ch, ch ; rul = 0 5077 000028AE 7555 <1> jnz short vga_g_down_6 5078 000028B0 20C9 <1> and cl, cl ; cul = 0 5079 000028B2 7551 <1> jnz short vga_g_down_6 5080 <1> 5081 000028B4 50 <1> push eax ; push ax ; 12/04/2021 5082 000028B5 A0[E6670000] <1> mov al, [VGA_ROWS] 5083 000028BA FEC8 <1> dec al 5084 000028BC 38C6 <1> cmp dh, al ; rlr = nbrows-1 5085 000028BE 7545 <1> jne short vga_g_down_5 5086 000028C0 A0[E0670000] <1> mov al, [CRT_COLS] ; = VGA_COLS 5087 000028C5 FEC8 <1> dec al 5088 000028C7 38C2 <1> cmp dl, al ; clr = nbcols-1 5089 <1> ;jne short vga_g_down_5 5090 <1> ; 12/04/2021 5091 000028C9 58 <1> pop eax ; pop ax 5092 000028CA 7539 <1> jne short vga_g_down_5 5093 <1> 5094 000028CC 66B80502 <1> mov ax, 0205h 5095 000028D0 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 5096 000028D4 66EF <1> out dx, ax 5097 000028D6 A0[E6670000] <1> mov al, [VGA_ROWS] 5098 000028DB 8A25[E0670000] <1> mov ah, [CRT_COLS] ; = [VGA_COLS] 5099 000028E1 F6E4 <1> mul ah 5100 000028E3 0FB7D0 <1> movzx edx, ax 5101 <1> ; 08/08/2016 5102 000028E6 0FB605[E2670000] <1> movzx eax, byte [CHAR_HEIGHT] 5103 000028ED F7E2 <1> mul edx 5104 <1> ; eax = byte count 5105 000028EF 89C1 <1> mov ecx, eax 5106 <1> ;; 07/08/2016 5107 <1> ;shl dx, 3 ; * 8 ; * [CHAR_HEIGHT] 5108 <1> ;mov ecx, edx 5109 000028F1 88D8 <1> mov al, bl ; fill value for blanked lines 5110 000028F3 BF00000A00 <1> mov edi, 0A0000h 5111 000028F8 F3AA <1> rep stosb 5112 <1> 5113 <1> ; 03/08/2022 5114 000028FA 30E4 <1> xor ah, ah ; 0 5115 <1> 5116 000028FC B005 <1> mov al, 5 5117 000028FE 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 5118 00002902 66EF <1> out dx, ax ; 0005h 5119 <1> 5120 00002904 C3 <1> retn 5121 <1> 5122 <1> vga_g_down_5: 5123 <1> ; 12/04/2021 5124 <1> ;pop eax ; pop ax 5125 <1> 5126 <1> vga_g_down_6: 5127 <1> ; [ESI] = VGA memory model number for current video mode 5128 <1> ; 5129 <1> ; LINEAR8 equ 5 5130 <1> ; PLANAR4 equ 4 5131 <1> ; PLANAR1 equ 3 5132 <1> 5133 00002905 803E04 <1> cmp byte [esi], PLANAR4 5134 00002908 742C <1> je short vga_g_down_planar 5135 0000290A 803E03 <1> cmp byte [esi], PLANAR1 5136 0000290D 7427 <1> je short vga_g_down_planar 5137 <1> vga_g_down_linear8: 5138 <1> ; 07/07/2016 (TEMPORARY) 5139 <1> ; 5140 <1> ; cl = upper left column ; cul 5141 <1> ; ch = upper left row ; rul 5142 <1> ; dl = lower rigth column ; clr 5143 <1> ; dh = lower right row ; rlr 5144 <1> 5145 <1> vga_g_down_l0: 5146 <1> ;{for(i=rlr;i>=rul;i--) 5147 <1> ; if((i or al, al 5149 00002911 741C <1> jz short vga_g_down_l2 5150 00002913 88C4 <1> mov ah, al 5151 00002915 00EC <1> add ah, ch 5152 <1> ;jc short vga_g_down_l2 5153 00002917 86F5 <1> xchg ch, dh 5154 00002919 38E5 <1> cmp ch, ah 5155 0000291B 7212 <1> jb short vga_g_down_l2 5156 0000291D 88EC <1> mov ah, ch 5157 0000291F 28C4 <1> sub ah, al ; ah = i - nblines 5158 <1> ; else 5159 <1> ; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight); 5160 00002921 E812FEFFFF <1> call vgamem_copy_l8 5161 <1> vga_g_down_l1: 5162 00002926 86EE <1> xchg dh, ch 5163 00002928 FECE <1> dec dh 5164 0000292A 38EE <1> cmp dh, ch 5165 0000292C 73E1 <1> jnb short vga_g_down_l0 5166 0000292E C3 <1> retn 5167 <1> 5168 <1> vga_g_down_l2: 5169 <1> ; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr); 5170 0000292F E86AFEFFFF <1> call vgamem_fill_l8 5171 00002934 EBF0 <1> jmp short vga_g_down_l1 5172 <1> 5173 <1> vga_g_down_planar: 5174 <1> ; cl = upper left column ; cul 5175 <1> ; ch = upper left row ; rul 5176 <1> ; dl = lower rigth column ; clr 5177 <1> ; dh = lower right row ; rlr 5178 <1> vga_g_down_pl0: 5179 <1> ;{for(i=rlr;i>=rul;i--) 5180 <1> ; if((i or al, al 5182 00002938 741C <1> jz short vga_g_down_pl2 5183 0000293A 88C4 <1> mov ah, al 5184 0000293C 00EC <1> add ah, ch 5185 <1> ;jc short vga_g_down_pl2 5186 0000293E 86F5 <1> xchg ch, dh 5187 00002940 38E5 <1> cmp ch, ah 5188 00002942 7212 <1> jb short vga_g_down_pl2 5189 00002944 88EC <1> mov ah, ch 5190 00002946 28C4 <1> sub ah, al ; ah = i - nblines 5191 <1> ; else 5192 <1> ; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight); 5193 00002948 E826FDFFFF <1> call vgamem_copy_pl4 5194 <1> vga_g_down_pl1: 5195 0000294D 86EE <1> xchg dh, ch 5196 0000294F FECE <1> dec dh 5197 00002951 38EE <1> cmp dh, ch 5198 00002953 73E1 <1> jnb short vga_g_down_pl0 5199 00002955 C3 <1> retn 5200 <1> 5201 <1> vga_g_down_pl2: 5202 <1> ; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr); 5203 00002956 E886FDFFFF <1> call vgamem_fill_pl4 5204 0000295B EBF0 <1> jmp short vga_g_down_pl1 5205 <1> 5206 <1> 5207 <1> 5208 <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0) 5209 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5210 <1> 5211 <1> ;----- ROUTINE TO MOVE ONE ROW OF INFORMATION 5212 <1> 5213 <1> _R17: 5214 0000295D 0FB6CA <1> movzx ecx, dl ; NUMBER OF BYTES IN THE ROW 5215 00002960 56 <1> push esi 5216 00002961 57 <1> push edi ; SAVE POINTERS 5217 00002962 F3A4 <1> rep movsb ; MOVE THE EVEN FIELD 5218 00002964 5F <1> pop edi 5219 00002965 5E <1> pop esi 5220 00002966 6681C60020 <1> add si, 2000h 5221 0000296B 6681C70020 <1> add di, 2000h ; POINT TO THE ODD FIELD 5222 00002970 56 <1> push esi 5223 00002971 57 <1> push edi ; SAVE THE POINTERS 5224 00002972 88D1 <1> mov cl, dl ; COUNT BACK 5225 00002974 F3A4 <1> rep movsb ; MOVE THE ODD FIELD 5226 00002976 5F <1> pop edi 5227 00002977 5E <1> pop esi ; POINTERS BACK 5228 00002978 C3 <1> retn ; RETURN TO CALLER 5229 <1> 5230 <1> ;----- CLEAR A SINGLE ROW 5231 <1> 5232 <1> _R18: 5233 00002979 0FB6CA <1> movzx ecx, dl ; NUMBER OF BYTES IN FIELD 5234 0000297C 57 <1> push edi ; SAVE POINTER 5235 0000297D F3AA <1> rep stosb ; STORE THE NEW VALUE 5236 0000297F 5F <1> pop edi ; POINTER BACK 5237 00002980 6681C70020 <1> add di, 2000h ; POINT TO ODD FIELD 5238 00002985 57 <1> push edi 5239 00002986 88D1 <1> mov cl, dl 5240 00002988 F3AA <1> rep stosb ; FILL THE ODD FIELD 5241 0000298A 5F <1> pop edi 5242 0000298B C3 <1> retn ; RETURN TO CALLER 5243 <1> 5244 <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5 5245 <1> ; 04/07/2016 5246 <1> ; 01/07/2016 5247 <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0) 5248 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5249 <1> ;-------------------------------------------------- 5250 <1> ; GRAPHICS WRITE 5251 <1> ; THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT 5252 <1> ; POSITION ON THE SCREEN. 5253 <1> ; ENTRY -- 5254 <1> ; AL = CHARACTER TO WRITE 5255 <1> ; BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR 5256 <1> ; IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER 5257 <1> ; (0 IS USED FOR THE BACKGROUND COLOR) 5258 <1> ; CX = NUMBER OF CHARS TO WRITE 5259 <1> ; DS = DATA SEGMENT 5260 <1> ; ES = REGEN SEGMENT 5261 <1> ; EXIT -- 5262 <1> ; NOTHING IS RETURNED 5263 <1> ; 5264 <1> ; GRAPHICS READ 5265 <1> ; THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR 5266 <1> ; POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE 5267 <1> ; CHARACTER GENERATOR CODE POINTS 5268 <1> ; ENTRY -- 5269 <1> ; NONE (0 IS ASSUMED AS THE BACKGROUND COLOR) 5270 <1> ; EXIT -- 5271 <1> ; AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND) 5272 <1> ; 5273 <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM 5274 <1> ; FOR THE 1ST 128 CHARS. TO ACCESS CHARS IN THE SECOND HALF, THE USER 5275 <1> ; MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO 5276 <1> ; POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES). 5277 <1> ; FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS 5278 <1> ;----------------------------------------------------- 5279 <1> 5280 <1> GRAPHICS_WRITE: 5281 0000298C 25FF000000 <1> and eax, 0FFh ; ZERO TO HIGH OF CODE POINT 5282 00002991 50 <1> push eax ; SAVE CODE POINT VALUE 5283 <1> 5284 <1> ;----- DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS 5285 <1> 5286 00002992 E846010000 <1> call S26 ; FIND LOCATION IN REGEN BUFFER 5287 00002997 89C7 <1> mov edi, eax ; REGEN POINTER IN DI 5288 <1> 5289 <1> ;----- DETERMINE REGION TO GET CODE POINTS FROM 5290 <1> 5291 00002999 58 <1> pop eax ; RECOVER CODE POINT 5292 <1> 5293 0000299A BE[50530100] <1> mov esi, CRT_CHAR_GEN ; OFFSET OF IMAGES 5294 <1> 5295 <1> ;----- DETERMINE GRAPHICS MODE IN OPERATION 5296 <1> ; DETERMINE_MODE 5297 <1> ;sal ax, 3 ; MULTIPLY CODE POINT VALUE BY 8 5298 <1> ; 03/08/2022 5299 0000299F C1E003 <1> sal eax, 3 5300 000029A2 01C6 <1> add esi, eax ; SI HAS OFFSET OF DESIRED CODES 5301 <1> 5302 000029A4 803D[DE670000]06 <1> cmp byte [CRT_MODE], 6 5303 000029AB 7231 <1> jc short S6 ; TEST FOR MEDIUM RESOLUTION MODE 5304 <1> 5305 <1> ;----- HIGH RESOLUTION MODE 5306 <1> 5307 000029AD 81C700800B00 <1> add edi, 0B8000h 5308 <1> S1: ; HIGH_CHAR 5309 000029B3 57 <1> push edi ; SAVE REGEN POINTER 5310 000029B4 56 <1> push esi ; SAVE CODE POINTER 5311 000029B5 B604 <1> mov dh, 4 ; NUMBER OF TIMES THROUGH LOOP 5312 <1> S2: 5313 000029B7 AC <1> lodsb ; GET BYTE FROM CODE POINTS 5314 000029B8 F6C380 <1> test bl, 80h ; SHOULD WE USE THE FUNCTION 5315 000029BB 7515 <1> jnz short S5 ; TO PUT CHAR IN 5316 000029BD AA <1> stosb ; STORE IN REGEN BUFFER 5317 000029BE AC <1> lodsb 5318 <1> S4: 5319 000029BF 8887FF1F0000 <1> mov [edi+2000h-1], al ; STORE IN SECOND HALF 5320 000029C5 83C74F <1> add edi, 79 ; MOVE TO NEXT ROW IN REGEN 5321 000029C8 FECE <1> dec dh ; DONE WITH LOOP 5322 000029CA 75EB <1> jnz short S2 5323 000029CC 5E <1> pop esi 5324 000029CD 5F <1> pop edi ; RECOVER REGEN POINTER 5325 000029CE 47 <1> inc edi ; POINT TO NEXT CHAR POSITION 5326 000029CF E2E2 <1> loop S1 ; MORE CHARS TO WRITE 5327 000029D1 C3 <1> retn 5328 <1> 5329 <1> S5: 5330 000029D2 3207 <1> xor al, [edi] ; EXCLUSIVE OR WITH CURRENT 5331 000029D4 AA <1> stosb ; STORE THE CODE POINT 5332 000029D5 AC <1> lodsb ; AGAIN FOR ODD FIELD 5333 000029D6 3287FF1F0000 <1> xor al, [edi+2000h-1] 5334 000029DC EBE1 <1> jmp short S4 ; BACK TO MAINSTREAM 5335 <1> 5336 <1> ;----- MEDIUM RESOLUTION WRITE 5337 <1> S6: ; MED_RES_WRITE 5338 000029DE 88DA <1> mov dl, bl ; SAVE HIGH COLOR BIT 5339 <1> ; 03/08/2022 5340 000029E0 D1E7 <1> sal edi, 1 5341 <1> ;sal di, 1 ; OFFSET*2 SINCE 2 BYTES/CHAR 5342 <1> ; EXPAND BL TO FULL WORD OF COLOR 5343 000029E2 80E303 <1> and bl, 3 ; ISOLATE THE COLOR BITS ( LOW 2 BITS ) 5344 000029E5 B055 <1> mov al, 055h ; GET BIT CONVERSION MULTIPLIER 5345 000029E7 F6E3 <1> mul bl ; EXPAND 2 COLOR BITS TO 4 REPLICATIONS 5346 000029E9 88C3 <1> mov bl, al ; PLACE BACK IN WORK REGISTER 5347 000029EB 88C7 <1> mov bh, al ; EXPAND TO 8 REPLICATIONS OF COLOR BITS 5348 000029ED 81C700800B00 <1> add edi, 0B8000h 5349 <1> S7: ; MED_CHAR 5350 000029F3 57 <1> push edi ; SAVE REGEN POINTER 5351 000029F4 56 <1> push esi ; SAVE THE CODE POINTER 5352 000029F5 B604 <1> mov dh, 4 ; NUMBER OF LOOPS 5353 <1> S8: 5354 000029F7 AC <1> lodsb ; GET CODE POINT 5355 000029F8 E8B1000000 <1> call S21 ; DOUBLE UP ALL THE BITS 5356 000029FD 6621D8 <1> and ax, bx ; CONVERT TO FOREGROUND COLOR ( 0 BACK ) 5357 00002A00 86C4 <1> xchg ah, al ; SWAP HIGH/LOW BYTES FOR WORD MOVE 5358 00002A02 F6C280 <1> test dl, 80h ; IS THIS XOR FUNCTION 5359 00002A05 7403 <1> jz short S9 ; NO, STORE IT IN AS IS 5360 00002A07 663307 <1> xor ax, [edi] ; DO FUNCTION WITH LOW/HIGH 5361 <1> S9: 5362 00002A0A 668907 <1> mov [edi], ax ; STORE FIRST BYTE HIGH, SECOND LOW 5363 00002A0D AC <1> lodsb ; GET CODE POINT 5364 00002A0E E89B000000 <1> call S21 5365 00002A13 6621D8 <1> and ax, bx ; CONVERT TO COLOR 5366 00002A16 86C4 <1> xchg ah, al ; SWAP HIGH/LOW BYTES FOR WORD MOVE 5367 00002A18 F6C280 <1> test dl, 80h ; AGAIN, IS THIS XOR FUNCTION 5368 00002A1B 7407 <1> jz short _S10 ; NO, JUST STORE THE VALUES 5369 00002A1D 66338700200000 <1> xor ax, [edi+2000h] ; FUNCTION WITH FIRST HALF LOW 5370 <1> _S10: 5371 00002A24 66898700200000 <1> mov [edi+2000h], ax ; STORE SECOND PORTION HIGH 5372 00002A2B 6683C750 <1> add di, 80 ; POINT TO NEXT LOCATION 5373 00002A2F FECE <1> dec dh 5374 00002A31 75C4 <1> jnz short S8 ; KEEP GOING 5375 00002A33 5E <1> pop esi ; RECOVER CODE POINTER 5376 00002A34 5F <1> pop edi ; RECOVER REGEN POINTER 5377 00002A35 47 <1> inc edi ; POINT TO NEXT CHAR POSITION 5378 00002A36 47 <1> inc edi 5379 00002A37 E2BA <1> loop S7 ; MORE TO WRITE 5380 00002A39 C3 <1> retn 5381 <1> 5382 <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5 5383 <1> ; 04/07/2016 5384 <1> ; 01/07/2016 5385 <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0) 5386 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5387 <1> ;---------------------------------------- 5388 <1> ; GRAPHICS READ 5389 <1> ;---------------------------------------- 5390 <1> GRAPHICS_READ: 5391 00002A3A E89E000000 <1> call S26 ; CONVERTED TO OFFSET IN REGEN 5392 00002A3F 89C6 <1> mov esi, eax ; SAVE IN SI 5393 00002A41 81C600800B00 <1> add esi, 0B8000h ; 01/07/2016 5394 00002A47 83EC08 <1> sub esp, 8 ; ALLOCATE SPACE FOR THE READ CODE POINT 5395 00002A4A 89E5 <1> mov ebp, esp ; POINTER TO SAVE AREA 5396 <1> 5397 <1> ;----- DETERMINE GRAPHICS MODES 5398 00002A4C B604 <1> mov dh, 4 ; number of passes ; 01/07/2016 5399 00002A4E 803D[DE670000]06 <1> cmp byte [CRT_MODE], 6 5400 00002A55 7219 <1> jc short S12 ; MEDIUM RESOLUTION 5401 <1> 5402 <1> ;----- HIGH RESOLUTION READ 5403 <1> ;----- GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT 5404 <1> ;mov dh,4 ; NUMBER OF PASSES 5405 <1> S11: 5406 00002A57 8A06 <1> mov al, [esi] ; GET FIRST BYTE 5407 00002A59 884500 <1> mov [ebp], al ; SAVE IN STORAGE AREA 5408 00002A5C 45 <1> inc ebp ; NEXT LOCATION 5409 00002A5D 8A8600200000 <1> mov al, [esi+2000h] ; GET LOWER REGION BYTE 5410 00002A63 884500 <1> mov [ebp], al ; ADJUST AND STORE 5411 00002A66 45 <1> inc ebp 5412 00002A67 83C650 <1> add esi, 80 ; POINTER INTO REGEN 5413 00002A6A FECE <1> dec dh ; LOOP CONTROL 5414 00002A6C 75E9 <1> jnz short S11 ; DO IT SOME MORE 5415 00002A6E EB1C <1> jmp short S14 ; GO MATCH THE SAVED CODE POINTS 5416 <1> 5417 <1> ;----- MEDIUM RESOLUTION READ 5418 <1> S12: 5419 <1> ;sal si, 1 ; OFFSET*2 SINCE 2 BYTES/CHAR 5420 <1> ; 03/08/2022 5421 00002A70 D1E6 <1> sal esi, 1 5422 <1> ;mov dh, 4 ; NUMBER OF PASSES 5423 <1> S13: 5424 00002A72 E84B000000 <1> call S23 ; GET BYTES FROM REGEN INTO SINGLE SAVE 5425 00002A77 81C6FE1F0000 <1> add esi, 2000h-2 ; GO TO LOWER REGION 5426 00002A7D E840000000 <1> call S23 ; GET THIS PAIR INTO SAVE 5427 00002A82 81EEB21F0000 <1> sub esi, 2000h-80+2 ; ADJUST POINTER BACK INTO UPPER 5428 00002A88 FECE <1> dec dh 5429 00002A8A 75E6 <1> jnz short S13 ; KEEP GOING UNTIL ALL 8 DONE 5430 <1> 5431 <1> ;----- SAVE AREA HAS CHARACTER IN IT, MATCH IT 5432 <1> S14: ; FIND_CHAR 5433 00002A8C BF[50530100] <1> mov edi, CRT_CHAR_GEN ; ESTABLISH ADDRESSING 5434 00002A91 83ED08 <1> sub ebp, 8 ; ADJUST POINTER TO START OF SAVE AREA 5435 00002A94 89EE <1> mov esi, ebp 5436 <1> S15: 5437 <1> ;mov ax, 256 ; NUMBER TO TEST AGAINST 5438 <1> ; 03/08/2022 5439 00002A96 29C0 <1> sub eax, eax 5440 00002A98 FEC4 <1> inc ah 5441 <1> ; eax = 256 5442 <1> S16: 5443 00002A9A 56 <1> push esi ; SAVE SAVE AREA POINTER 5444 00002A9B 57 <1> push edi ; SAVE CODE POINTER 5445 <1> ;mov ecx, 4 ; NUMBER OF WORDS TO MATCH 5446 <1> ;repe cmpsw ; COMPARE THE 8 BYTES AS WORDS 5447 00002A9C A7 <1> cmpsd ; compare first 4 bytes 5448 00002A9D 7501 <1> jne short S17 ; 5449 00002A9F A7 <1> cmpsd ; compare last 4 bytes 5450 <1> S17: 5451 00002AA0 5F <1> pop edi ; RECOVER THE POINTERS 5452 00002AA1 5E <1> pop esi 5453 <1> ;jz short S18 ; IF ZERO FLAG SET, THEN MATCH OCCURRED 5454 00002AA2 7406 <1> je short S18 5455 <1> ; ; NO MATCH, MOVE ON TO NEXT 5456 00002AA4 83C708 <1> add edi, 8 ; NEXT CODE POINT 5457 <1> ;dec ax ; LOOP CONTROL 5458 <1> ; 03/08/2022 5459 00002AA7 48 <1> dec eax 5460 00002AA8 75F0 <1> jnz short S16 ; DO ALL OF THEM 5461 <1> 5462 <1> ;----- CHARACTER IS FOUND ( AL=0 IF NOT FOUND ) 5463 <1> S18: 5464 00002AAA 83C408 <1> add esp, 8 ; READJUST THE STACK, THROW AWAY SAVE 5465 00002AAD C3 <1> retn ; ALL DONE 5466 <1> 5467 <1> ; 12/04/2021 5468 <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0) 5469 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5470 <1> ;-------------------------------------------- 5471 <1> ; EXPAND BYTE 5472 <1> ; THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL 5473 <1> ; OF THE BITS, TURNING THE 8 BITS INTO 16 BITS. 5474 <1> ; THE RESULT IS LEFT IN AX 5475 <1> ;-------------------------------------------- 5476 <1> S21: 5477 <1> ; 03/08/2022 5478 <1> ;push cx ; SAVE REGISTER 5479 <1> ; 12/04/2021 5480 00002AAE 51 <1> push ecx 5481 <1> ;;mov cx, 8 ; SHIFT COUNT REGISTER FOR ONE BYTE 5482 <1> ;mov cl, 8 5483 00002AAF B408 <1> mov ah, 8 5484 <1> S22: 5485 00002AB1 D0C8 <1> ror al, 1 ; SHIFT BITS, LOW BIT INTO CARRY FLAG 5486 <1> ;rcr bp, 1 ; MOVE CARRY FLAG (LOW BIT INTO RESULTS 5487 <1> ;sar bp, 1 ; SIGN EXTEND HIGH BIT (DOUBLE IT) 5488 <1> ; 03/08/2022 5489 00002AB3 66D1D9 <1> rcr cx, 1 5490 00002AB6 66D1F9 <1> sar cx, 1 5491 <1> 5492 <1> ;;loop S22 ; REPEAT FOR ALL 8 BITS 5493 <1> ;dec cl 5494 <1> ;jnz short S22 5495 <1> ;xchg ax, bp ; MOVE RESULTS TO PARAMETER REGISTER 5496 <1> ; 03/08/5022 5497 00002AB9 FECC <1> dec ah 5498 00002ABB 75F4 <1> jnz short S22 5499 00002ABD 6689C8 <1> mov ax, cx 5500 <1> ;pop cx ; RECOVER REGISTER 5501 <1> ; 12/04/2021 5502 00002AC0 59 <1> pop ecx 5503 00002AC1 C3 <1> retn ; ALL DONE 5504 <1> 5505 <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0) 5506 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5507 <1> ;-------------------------------------------------- 5508 <1> ; MED_READ_BYTE 5509 <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER, 5510 <1> ; COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE 5511 <1> ; THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT 5512 <1> ; POSITION IN THE SAVE AREA 5513 <1> ; ENTRY -- 5514 <1> ; SI,DS = POINTER TO REGEN AREA OF INTEREST 5515 <1> ; BX = EXPANDED FOREGROUND COLOR 5516 <1> ; BP = POINTER TO SAVE AREA 5517 <1> ; EXIT -- 5518 <1> ; SI AND BP ARE INCREMENTED 5519 <1> ;---------------------------------------------------- 5520 <1> S23: 5521 00002AC2 66AD <1> lodsw ; GET FIRST BYTE AND SECOND BYTES 5522 00002AC4 86E0 <1> xchg al, ah ; SWAP FOR COMPARE 5523 <1> ;mov cx, 0C000h ; 2 BIT MASK TO TEST THE ENTRIES 5524 <1> ; 02/08/2022 5525 00002AC6 29C9 <1> sub ecx, ecx 5526 00002AC8 B5C0 <1> mov ch, 0C0h 5527 <1> ; ecx = 0C000h 5528 <1> ;mov dl, 0 ; RESULT REGISTER 5529 <1> ; 03/08/2022 5530 00002ACA 28D2 <1> sub dl, dl 5531 <1> S24: 5532 <1> ;test ax, cx ; IS THIS SECTION BACKCROUND? 5533 <1> ; 03/08/2022 5534 00002ACC 85C8 <1> test eax, ecx 5535 00002ACE 7401 <1> jz short S25 ; IF ZERO, IT IS BACKGROUND (CARRY=0) 5536 00002AD0 F9 <1> stc ; WASN'T, SO SET CARRY 5537 <1> S25: 5538 00002AD1 D0D2 <1> rcl dl, 1 ; MOVE THAT BIT INTO THE RESULT 5539 <1> ;shr cx, 2 ; MOVE THE MASK TO THE RIGHT BY 2 BITS 5540 <1> ; 02/08/2022 5541 00002AD3 C1E902 <1> shr ecx, 2 5542 00002AD6 73F4 <1> jnc short S24 ; DO IT AGAIN IF MASK DIDN'T FALL OUT 5543 00002AD8 885500 <1> mov [ebp], dl ; STORE RESULT IN SAVE AREA 5544 00002ADB 45 <1> inc ebp ; ADJUST POINTER 5545 00002ADC C3 <1> retn ; ALL DONE 5546 <1> 5547 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 5548 <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0) 5549 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5550 <1> ;----------------------------------------- 5551 <1> ; V4_POSITION 5552 <1> ; THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN 5553 <1> ; THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET 5554 <1> ; INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR. 5555 <1> ; FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST 5556 <1> ; BE DOUBLED. 5557 <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED 5558 <1> ; EXIT-- 5559 <1> ; AX CONTAINS OFFSET INTO REGEN BUFFER 5560 <1> ;----------------------------------------- 5561 <1> S26: 5562 00002ADD 0FB705[DE7C0100] <1> movzx eax, word [CURSOR_POSN] ; GET CURRENT CURSOR 5563 <1> GRAPH_POSN: 5564 00002AE4 53 <1> push ebx ; SAVE REGISTER 5565 00002AE5 0FB6D8 <1> movzx ebx, al ; SAVE A COPY OF CURRENT CURSOR 5566 00002AE8 A0[E0670000] <1> mov al, [CRT_COLS] ; GET BYTES PER COLUMN 5567 00002AED F6E4 <1> mul ah ; MULTIPLY BY ROWS 5568 <1> ;shl ax, 2 ; MULTIPLY * 4 SINCE 4 ROWS/BYTE 5569 <1> ; 02/08/2022 5570 00002AEF C1E002 <1> shl eax, 2 5571 00002AF2 01D8 <1> add eax, ebx ; DETERMINE OFFSET 5572 00002AF4 5B <1> pop ebx ; RECOVER POINTER 5573 00002AF5 C3 <1> retn ; ALL DONE 5574 <1> 5575 <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5 5576 <1> ; 09/07/2016 5577 <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0) 5578 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5579 <1> ;--------------------------------------------- 5580 <1> ; SET_COLOR 5581 <1> ; THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR, 5582 <1> ; AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS 5583 <1> ; INPUT 5584 <1> ; (BH) HAS COLOR ID 5585 <1> ; IF BH=0, THE BACKGROUND COLOR VALUE IS SET 5586 <1> ; FROM THE LOW BITS OF BL (0-31) 5587 <1> ; IF BH=1, THE PALETTE SELECTION IS MADE 5588 <1> ; BASED ON THE LOW BIT OF BL: 5589 <1> ; 0 = GREEN, RED, YELLOW FOR COLORS 1,2,3 5590 <1> ; 1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3 5591 <1> ; (BL) HAS THE COLOR VALUE TO BE USED 5592 <1> ; OUTPUT 5593 <1> ; THE COLOR SELECTION IS UPDATED 5594 <1> ;---------------------------------------------- 5595 <1> SET_COLOR: 5596 00002AF6 803D[DE670000]07 <1> cmp byte [CRT_MODE], 7 ; 09/07/2016 5597 <1> ;ja VIDEO_RETURN ; nothing to do for VGA modes 5598 <1> ; 03/08/2022 5599 00002AFD 7605 <1> jna short M21 5600 00002AFF E92EF0FFFF <1> jmp VIDEO_RETURN 5601 <1> M21: 5602 <1> ;mov dx, [ADDR_6845] ; I/O PORT FOR PALETTE 5603 <1> ;mov dx, 3D4h 5604 <1> ;add dx, 5 ; OVERSCAN PORT 5605 00002B04 66BAD903 <1> mov dx, 3D9h 5606 00002B08 A0[E1670000] <1> mov al, [CRT_PALETTE] ; GET THE CURRENT PALETTE VALUE 5607 00002B0D 08FF <1> or bh, bh ; IS THIS COLOR 0? 5608 00002B0F 7512 <1> jnz short M20 ; OUTPUT COLOR 1 5609 <1> 5610 <1> ;----- HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR 5611 <1> 5612 00002B11 24E0 <1> and al, 0E0h ; TURN OFF LOW 5 BITS OF CURRENT 5613 00002B13 80E31F <1> and bl, 01Fh ; TURN OFF HIGH 3 BITS OF INPUT VALUE 5614 00002B16 08D8 <1> or al, bl ; PUT VALUE INTO REGISTER 5615 <1> M19: ; OUTPUT THE PALETTE 5616 00002B18 EE <1> out dx, al ; OUTPUT COLOR SELECTION TO 3D9 PORT 5617 00002B19 A2[E1670000] <1> mov [CRT_PALETTE], al ; SAVE THE COLOR VALUE 5618 00002B1E E90FF0FFFF <1> jmp VIDEO_RETURN 5619 <1> 5620 <1> ;----- HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED 5621 <1> 5622 <1> M20: 5623 00002B23 24DF <1> and al, 0DFH ; TURN OFF PALETTE SELECT BIT 5624 00002B25 D0EB <1> shr bl, 1 ; TEST THE LOW ORDER BIT OF BL 5625 00002B27 73EF <1> jnc short M19 ; ALREADY DONE 5626 00002B29 0C20 <1> or al, 20H ; TURN ON PALETTE SELECT BIT 5627 00002B2B EBEB <1> jmp short M19 ; GO DO IT 5628 <1> 5629 <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5 5630 <1> ; 09/07/2016 5631 <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0) 5632 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5633 <1> ;-------------------------------------------- 5634 <1> ; READ DOT -- WRITE DOT 5635 <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE 5636 <1> ; DOT AT THE INDICATED LOCATION 5637 <1> ; ENTRY -- 5638 <1> ; DX = ROW (0-199) (THE ACTUAL VALUE DEPENDS ON THE MODE) 5639 <1> ; CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED ) 5640 <1> ; AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE, 5641 <1> ; REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED) 5642 <1> ; BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION 5643 <1> ; DS = DATA SEGMENT 5644 <1> ; ES = REGEN SEGMENT 5645 <1> ; 5646 <1> ; EXIT 5647 <1> ; AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY 5648 <1> ;---------------------------------------------- 5649 <1> 5650 <1> READ_DOT: 5651 <1> ; 09/07/2016 5652 00002B2D 8A25[DE670000] <1> mov ah, [CRT_MODE] 5653 00002B33 80FC07 <1> cmp ah, 7 ; 6!? 5654 00002B36 760A <1> jna short read_dot_cga 5655 <1> 5656 00002B38 E8B3030000 <1> call vga_read_pixel 5657 <1> ; al = pixel value 5658 <1> read_dot_retn: ; 03/08/2022 5659 00002B3D E9F5EFFFFF <1> jmp _video_return 5660 <1> 5661 <1> read_dot_cga: 5662 <1> ;je VIDEO_RETURN ; 7 5663 00002B42 80FC04 <1> cmp ah, 4 ; graphics ? 5664 <1> ;jb VIDEO_RETURN ; no, text mode, nothing to do 5665 <1> ; 03/08/2022 5666 00002B45 72F6 <1> jb short read_dot_retn 5667 <1> 5668 00002B47 E84F000000 <1> call R3 ; DETERMINE BYTE POSITION OF DOT 5669 00002B4C 8A06 <1> mov al, [esi] ; GET THE BYTE 5670 00002B4E 20E0 <1> and al, ah ; MASK OFF THE OTHER BITS IN THE BYTE 5671 00002B50 D2E0 <1> shl al, cl ; LEFT JUSTIFY THE VALUE 5672 00002B52 88F1 <1> mov cl, dh ; GET NUMBER OF BITS IN RESULT 5673 00002B54 D2C0 <1> rol al, cl ; RIGHT JUSTIFY THE RESULT 5674 <1> ;jmp VIDEO_RETURN ; RETURN FROM VIDEO I/O 5675 00002B56 0FB6C0 <1> movzx eax, al 5676 00002B59 E9D9EFFFFF <1> jmp _video_return 5677 <1> 5678 <1> ; 03/08/2022 5679 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 5680 <1> ; 12/04/2021 5681 <1> ; 09/07/2016 5682 <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0) 5683 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5684 <1> 5685 <1> WRITE_DOT: 5686 <1> ; 09/07/2016 5687 00002B5E 8A25[DE670000] <1> mov ah, [CRT_MODE] 5688 00002B64 80FC07 <1> cmp ah, 7 ; 6!? 5689 00002B67 760A <1> jna short write_dot_cga 5690 <1> 5691 00002B69 E8F2020000 <1> call vga_write_pixel 5692 <1> write_dot_retn: ; 03/08/2022 5693 00002B6E E9BFEFFFFF <1> jmp VIDEO_RETURN 5694 <1> 5695 <1> write_dot_cga: 5696 <1> ;je VIDEO_RETURN ; 7 5697 00002B73 80FC04 <1> cmp ah, 4 ; graphics ? 5698 <1> ;jb VIDEO_RETURN ; no, text mode, nothing to do 5699 <1> ; 03/08/2022 5700 00002B76 72F6 <1> jb short write_dot_retn 5701 <1> 5702 <1> ;;push ax ; SAVE DOT VALUE 5703 <1> ;push ax ; TWICE 5704 <1> ; 12/04/2021 5705 00002B78 50 <1> push eax 5706 00002B79 E81D000000 <1> call R3 ; DETERMINE BYTE POSITION OF THE DOT 5707 00002B7E D2E8 <1> shr al, cl ; SHIFT TO SET UP THE BITS FOR OUTPUT 5708 00002B80 20E0 <1> and al, ah ; STRIP OFF THE OTHER BITS 5709 00002B82 8A0E <1> mov cl, [esi] ; GET THE CURRENT BYTE 5710 <1> ;pop bx ; RECOVER XOR FLAG 5711 <1> ; 12/04/2021 5712 00002B84 5B <1> pop ebx 5713 00002B85 F6C380 <1> test bl, 80h ; IS IT ON 5714 00002B88 750D <1> jnz short R2 ; YES, XOR THE DOT 5715 00002B8A F6D4 <1> not ah ; SET MASK TO REMOVE THE INDICATED BITS 5716 00002B8C 20E1 <1> and cl, ah 5717 00002B8E 08C8 <1> or al, cl ; OR IN THE NEW VALUE OF THOSE BITS 5718 <1> R1: ; FINISH_DOT 5719 00002B90 8806 <1> mov [esi], al ; RESTORE THE BYTE IN MEMORY 5720 <1> ;;pop AX 5721 00002B92 E99BEFFFFF <1> jmp VIDEO_RETURN ; RETURN FROM VIDEO I/O 5722 <1> R2: ; XOR_DOT 5723 00002B97 30C8 <1> xor al, cl ; EXCLUSIVE OR THE DOTS 5724 00002B99 EBF5 <1> jmp short R1 ; FINISH UP THE WRITING 5725 <1> 5726 <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5 5727 <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0) 5728 <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code) 5729 <1> 5730 <1> ;---------------------------------------------- 5731 <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE 5732 <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE. 5733 <1> ; ENTRY -- 5734 <1> ; DX = ROW VALUE (0-199) 5735 <1> ; CX = COLUMN VALUE (0-639) 5736 <1> ; EXIT -- 5737 <1> ; SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST 5738 <1> ; AH = MASK TO STRIP OFF THE BITS OF INTEREST 5739 <1> ; CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH 5740 <1> ; DH = # BITS IN RESULT 5741 <1> ; BX = MODIFIED 5742 <1> ;----------------------------------------------- 5743 <1> R3: 5744 <1> 5745 <1> ;----- DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40 5746 <1> ;----- ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW ) 5747 <1> 5748 00002B9B 0FB7F0 <1> movzx esi, ax ; WILL SAVE AL AND AH DURING OPERATION 5749 00002B9E B028 <1> mov al, 40 5750 00002BA0 F6E2 <1> mul dl ; AX= ADDRESS OF START OF INDICATED ROW 5751 00002BA2 A808 <1> test al, 08H ; TEST FOR EVEN/ODD ROW CALCULATED 5752 00002BA4 7404 <1> JZ short R4 ; JUMP IF EVEN ROW 5753 00002BA6 6605D81F <1> add ax, 2000h-40 ; OFFSET TO LOCATION OF ODD ROWS ADJUST 5754 <1> R4: ; EVEN_ROW 5755 <1> ;xchg si, ax ; MOVE POINTER TO (SI) AND RECOVER (AX) 5756 <1> ; 02/08/2022 5757 00002BAA 96 <1> xchg esi, eax 5758 00002BAB 81C600800B00 <1> add esi, 0B8000h 5759 <1> ;mov dx, cx ; COLUMN VALUE TO DX 5760 00002BB1 0FB7D1 <1> movzx edx, cx 5761 <1> 5762 <1> ;----- DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT 5763 <1> 5764 <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE 5765 <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES ) 5766 <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M ) 5767 <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M ) 5768 <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M ) 5769 <1> 5770 00002BB4 66BBC002 <1> mov bx, 2C0h 5771 00002BB8 66B90203 <1> mov cx, 302h ; SET PARMS FOR MED RES 5772 00002BBC 803D[DE670000]06 <1> cmp byte [CRT_MODE], 6 5773 00002BC3 7208 <1> jc short R5 ; HANDLE IF MED RES 5774 00002BC5 66BB8001 <1> mov bx, 180h 5775 00002BC9 66B90307 <1> mov cx, 703h ; SET PARMS FOR HIGH RES 5776 <1> 5777 <1> ;----- DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK 5778 <1> R5: 5779 00002BCD 20D5 <1> and ch, dl ; ADDRESS OF PEL WITHIN BYTE TO CH 5780 <1> 5781 <1> ;----- DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN 5782 <1> 5783 <1> ;shr dx, cl ; SHIFT BY CORRECT AMOUNT 5784 <1> ;add si, dx ; INCREMENT THE POINTER 5785 <1> ; 02/08/2022 5786 00002BCF D3EA <1> shr edx, cl 5787 00002BD1 01D6 <1> add esi, edx 5788 00002BD3 88FE <1> mov dh, bh ; GET THE # OF BITS IN RESULT TO DH 5789 <1> 5790 <1> ;----- MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET) 5791 <1> 5792 00002BD5 28C9 <1> sub cl, cl ; ZERO INTO STORAGE LOCATION 5793 <1> R6: 5794 00002BD7 D0C8 <1> ror al, 1 ; LEFT JUSTIFY VALUE IN AL (FOR WRITE) 5795 00002BD9 00E9 <1> add cl, ch ; ADD IN THE BIT OFFSET VALUE 5796 00002BDB FECF <1> dec bh ; LOOP CONTROL 5797 00002BDD 75F8 <1> jnz short R6 ; ON EXIT, CL HAS COUNT TO RESTORE BITS 5798 00002BDF 88DC <1> mov ah, bl ; GET MASK TO AH 5799 00002BE1 D2EC <1> shr ah, cl ; MOVE THE MASK TO CORRECT LOCATION 5800 00002BE3 C3 <1> retn ; RETURN WITH EVERYTHING SET UP 5801 <1> 5802 <1> load_dac_palette: 5803 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 5804 <1> ; 29/07/2016 5805 <1> ; 23/07/2016 5806 <1> ; 03/07/2016 (TRDOS 386 = TRDOS v2.0) 5807 <1> ; (set_mode_vga) 5808 <1> ; derived from 'Plex86/Bochs VGABios' source code 5809 <1> ; vgabios-0.7a (2011) 5810 <1> ; by the LGPL VGABios developers Team (2001-2008) 5811 <1> ; 'vgabios.c', 'load_dac_palette' 5812 <1> ; 5813 <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 5814 <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm') 5815 <1> ; 5816 <1> ; INPUT -> AH = DAC selection number (3, 2 or 1) 5817 <1> ; OUTPUT -> ECX = 0, AX = 0 5818 <1> ; (Modifed registers: EAX, ECX, EDX, ESI) 5819 <1> ; 5820 00002BE4 66BAC803 <1> mov dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS 5821 00002BE8 28C0 <1> sub al, al ; 0 5822 00002BEA EE <1> out dx, al ; 0 ; color index, always 0 at the beginning 5823 <1> ;inc dx ; 3C9h ; VGAREG_DAC_DATA 5824 <1> ; 02/08/2022 5825 00002BEB FEC2 <1> inc dl ; dx = 3C9h 5826 <1> ;mov ecx, 256 ; always 256*3 values 5827 <1> ; 02/08/2022 5828 00002BED 31C9 <1> xor ecx, ecx 5829 00002BEF FEC5 <1> inc ch 5830 <1> ; ecx = 256 5831 <1> 5832 <1> ;push esi 5833 00002BF1 88E0 <1> mov al, ah 5834 00002BF3 B43F <1> mov ah, 3Fh ; 3Fh except DAC selection number 3 5835 00002BF5 3C02 <1> cmp al, 2 5836 00002BF7 7414 <1> je short l_dac_p_2 5837 00002BF9 7719 <1> ja short l_dac_p_3 5838 00002BFB 20C0 <1> and al, al 5839 00002BFD 7507 <1> jnz short l_dac_p_1 5840 <1> l_dac_p_0: 5841 00002BFF BE[104E0100] <1> mov esi, palette0 5842 00002C04 EB15 <1> jmp short l_dac_p_4 5843 <1> l_dac_p_1: 5844 00002C06 BE[D04E0100] <1> mov esi, palette1 5845 00002C0B EB0E <1> jmp short l_dac_p_4 5846 <1> l_dac_p_2: 5847 00002C0D BE[904F0100] <1> mov esi, palette2 5848 00002C12 EB07 <1> jmp short l_dac_p_4 5849 <1> l_dac_p_3: 5850 00002C14 B4FF <1> mov ah, 0FFh ; dac registers 5851 00002C16 BE[50500100] <1> mov esi, palette3 5852 <1> l_dac_p_4: 5853 00002C1B AC <1> lodsb 5854 00002C1C EE <1> out dx, al ; Red 5855 00002C1D AC <1> lodsb 5856 00002C1E EE <1> out dx, al ; Green 5857 00002C1F AC <1> lodsb 5858 00002C20 EE <1> out dx, al ; Blue 5859 00002C21 20E4 <1> and ah, ah 5860 00002C23 7405 <1> jz short l_dac_p_5 5861 00002C25 FECC <1> dec ah 5862 00002C27 E2F2 <1> loop l_dac_p_4 5863 <1> ;pop esi 5864 00002C29 C3 <1> retn 5865 <1> l_dac_p_5: 5866 <1> ; 29/07/2016 5867 00002C2A FEC9 <1> dec cl 5868 00002C2C 7407 <1> jz short l_dac_p_7 5869 <1> ; 5870 00002C2E 28C0 <1> sub al, al ; 0 5871 <1> l_dac_p_6: 5872 00002C30 EE <1> out dx, al ; outb(VGAREG_DAC_DATA,0); 5873 00002C31 EE <1> out dx, al 5874 00002C32 EE <1> out dx, al 5875 00002C33 E2FB <1> loop l_dac_p_6 5876 <1> l_dac_p_7: 5877 <1> ;pop esi 5878 00002C35 C3 <1> retn 5879 <1> 5880 <1> gray_scale_summing: 5881 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 5882 <1> ; 12/04/2021 5883 <1> ; 03/07/2016 (TRDOS 386 = TRDOS v2.0) 5884 <1> ; (set_mode_vga) 5885 <1> ; derived from 'Plex86/Bochs VGABios' source code 5886 <1> ; vgabios-0.7a (2011) 5887 <1> ; by the LGPL VGABios developers Team (2001-2008) 5888 <1> ; 'vgabios.c', 'biosfn_perform_gray_scale_summing' 5889 <1> ; 5890 <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 5891 <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm') 5892 <1> ; 5893 <1> 5894 <1> ; INPUT -> EBX = Start address (color index <= 255) 5895 <1> ; ECX = Count (<= 256) 5896 <1> ; OUTPUT -> (E)CX = 0 5897 <1> ; (Modifed registers: EAX, ECX, EDX, EBX) 5898 <1> 5899 00002C36 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 5900 00002C3A EC <1> in al, dx 5901 00002C3B 30C0 <1> xor al, al ; 0 5902 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 5903 <1> ; 03/08/2022 5904 00002C3D B2C0 <1> mov dl, 0C0h 5905 00002C3F EE <1> out dx, al ; clear bit 5 5906 <1> ; (while loading palette registers) 5907 <1> ; set read address and switch to read mode 5908 <1> g_s_s_1: 5909 <1> ;mov dx, 3C7h ; VGAREG_DAC_READ_ADDRESS 5910 <1> ; 03/08/2022 5911 00002C40 B2C7 <1> mov dl, 0C7h 5912 00002C42 88D8 <1> mov al, bl 5913 00002C44 EE <1> out dx, al 5914 <1> ; get 6-bit wide RGB data values 5915 <1> ; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue) 5916 <1> ; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8; 5917 <1> ;mov dx, 3C9h ; VGAREG_DAC_DATA 5918 <1> ; 03/08/2022 5919 00002C45 B2C9 <1> mov dl, 0C9h 5920 00002C47 EC <1> in al, dx ; red 5921 00002C48 B44D <1> mov ah, 77 ; 0.3* Red 5922 00002C4A F6E4 <1> mul ah 5923 <1> ;push ax 5924 <1> ; 12/04/2021 5925 00002C4C 50 <1> push eax 5926 00002C4D EC <1> in al, dx ; green 5927 00002C4E B497 <1> mov ah, 151 ; 0.59 * Green 5928 00002C50 F6E4 <1> mul ah 5929 <1> ;push ax 5930 <1> ; 12/04/2021 5931 00002C52 50 <1> push eax 5932 00002C53 EC <1> in al, dx ; blue 5933 00002C54 B41C <1> mov ah, 28 ; 0.11 * Blue 5934 00002C56 F6E4 <1> mul ah 5935 <1> ;pop dx 5936 <1> ; 12/04/2021 5937 00002C58 5A <1> pop edx 5938 00002C59 6601D0 <1> add ax, dx 5939 <1> ;pop dx 5940 <1> ; 12/04/2021 5941 00002C5C 5A <1> pop edx 5942 00002C5D 6601D0 <1> add ax, dx 5943 00002C60 66058000 <1> add ax, 80h 5944 00002C64 B03F <1> mov al, 3Fh 5945 00002C66 38C4 <1> cmp ah, al ; if(i>0x3f)i=0x3f 5946 00002C68 7602 <1> jna short g_s_s_2 5947 00002C6A 88C4 <1> mov ah, al 5948 <1> g_s_s_2: 5949 <1> ;mov dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS 5950 <1> ; 03/08/2022 5951 00002C6C B2C8 <1> mov dl, 0C8h 5952 00002C6E 88D8 <1> mov al, bl ; color index 5953 00002C70 EE <1> out dx, al 5954 00002C71 88E0 <1> mov al, ah ; intensity 5955 <1> ;inc dx ; 3C9h ; VGAREG_DAC_DATA 5956 <1> ; 03/08/2022 5957 00002C73 FEC2 <1> inc dl 5958 00002C75 EE <1> out dx, al ; R (R=G=B) 5959 00002C76 88E0 <1> mov al, ah ; intensity 5960 00002C78 EE <1> out dx, al ; G (R=G=B) 5961 00002C79 88E0 <1> mov al, ah ; intensity 5962 00002C7B EE <1> out dx, al ; B (R=G=B) 5963 <1> ;dec cx 5964 <1> ; 03/08/2022 5965 00002C7C 49 <1> dec ecx 5966 00002C7D 7404 <1> jz short g_s_s_3 5967 00002C7F FEC3 <1> inc bl ; next color index value 5968 00002C81 EBBD <1> jmp short g_s_s_1 5969 <1> g_s_s_3: 5970 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 5971 <1> ; 03/08/2022 5972 00002C83 B2DA <1> mov dl, 0DAh 5973 00002C85 EC <1> in al, dx 5974 00002C86 B020 <1> mov al, 20h 5975 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 5976 <1> ; 03/08/2022 5977 00002C88 B2C0 <1> mov dl, 0C0h 5978 00002C8A EE <1> out dx, al ; 20h -> set bit 5 5979 <1> ; (after loading palette regs) 5980 00002C8B C3 <1> retn 5981 <1> 5982 <1> vga_write_char_attr: 5983 <1> vga_write_char_only: 5984 <1> ; 08/07/2016 (TRDOS 386 = TRDOS v2.0) 5985 <1> ; 5986 <1> ; derived from 'Plex86/Bochs VGABios' source code 5987 <1> ; vgabios-0.7a (2011) 5988 <1> ; by the LGPL VGABios developers Team (2001-2008) 5989 <1> ; 'vgabios.c', 'biosfn_write_char_attr' 5990 <1> ; 'biosfn_write_char_only' 5991 <1> 5992 <1> ; INPUT -> 5993 <1> ; [CRT_MODE] = current video mode (>7) 5994 <1> ; CX = Count of characters to write 5995 <1> ; AL = Character to write 5996 <1> ; BL = Color of character 5997 <1> ; OUTPUT -> 5998 <1> ; Regen buffer updated 5999 <1> 6000 00002C8C 8A25[DE670000] <1> mov ah, [CRT_MODE] 6001 00002C92 668B15[DE7C0100] <1> mov dx, [CURSOR_POSN] ; cursor pos for page 0 6002 <1> 6003 00002C99 BE[FA670000] <1> mov esi, vga_modes 6004 00002C9E 89F7 <1> mov edi, esi 6005 00002CA0 83C710 <1> add edi, vga_mode_count 6006 <1> vga_wca_0: 6007 00002CA3 AC <1> lodsb 6008 00002CA4 38E0 <1> cmp al, ah ; [CRT_MODE] 6009 00002CA6 7405 <1> je short vga_wca_2 6010 00002CA8 39FE <1> cmp esi, edi 6011 00002CAA 72F7 <1> jb short vga_wca_0 6012 <1> vga_wca_1: 6013 00002CAC C3 <1> retn ; nothing to do 6014 <1> vga_wca_2: 6015 00002CAD 83C64F <1> add esi, vga_memmodel - (vga_modes + 1) 6016 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 6017 <1> 6018 <1> ; biosfn_write_char_attr (car,page,attr,count) 6019 <1> ; AL = car, page = 0, BL = attr, CX = count 6020 00002CB0 803E04 <1> cmp byte [esi], PLANAR4 6021 00002CB3 741D <1> je short vga_wca_planar 6022 00002CB5 803E03 <1> cmp byte [esi], PLANAR1 6023 00002CB8 7418 <1> je short vga_wca_planar 6024 <1> vga_wca_linear8: 6025 <1> ; while((count-->0) && (xcurs ; CX = count 6027 00002CBA 6621C9 <1> and cx, cx 6028 00002CBD 74ED <1> jz short vga_wca_1 6029 00002CBF 3A15[E0670000] <1> cmp dl, [CRT_COLS] 6030 00002CC5 73E5 <1> jnb short vga_wca_1 6031 <1> ; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); 6032 <1> ; AL = car, BL = attr, DL = xcurs, DH = ycurs, 6033 <1> ; [CRT_COLS] = nbcols 6034 00002CC7 E81E000000 <1> call write_gfx_char_lin 6035 00002CCC 6649 <1> dec cx ; count 6036 00002CCE FEC2 <1> inc dl ; xcurs 6037 00002CD0 EBE8 <1> jmp short vga_wca_linear8 6038 <1> vga_wca_planar: 6039 <1> ; while((count-->0) && (xcurs ; CX = count 6041 00002CD2 6621C9 <1> and cx, cx 6042 00002CD5 74D5 <1> jz short vga_wca_1 6043 00002CD7 3A15[E0670000] <1> cmp dl, [CRT_COLS] 6044 00002CDD 73CD <1> jnb short vga_wca_1 6045 <1> ; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); 6046 <1> ; AL = car, BL = attr, DL = xcurs, DH = ycurs, 6047 <1> ; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight 6048 00002CDF E8A7000000 <1> call write_gfx_char_pl4 6049 00002CE4 6649 <1> dec cx ; count 6050 00002CE6 FEC2 <1> inc dl ; xcurs 6051 00002CE8 EBE8 <1> jmp short vga_wca_planar 6052 <1> 6053 <1> write_gfx_char_lin: 6054 <1> ; 02/08/2022 (TRDOS 386 v2.0.5) 6055 <1> ; 08/01/2021 6056 <1> ; 05/01/2021 (TRDOS 386 v2.0.3) 6057 <1> ; 08/08/2016 6058 <1> ; 31/07/2016 6059 <1> ; 08/07/2016 (TRDOS 386 = TRDOS v2.0) 6060 <1> ; 6061 <1> ; derived from 'Plex86/Bochs VGABios' source code 6062 <1> ; vgabios-0.7a (2011) 6063 <1> ; by the LGPL VGABios developers Team (2001-2008) 6064 <1> ; 'vgabios.c', 'write_gfx_char_lin' 6065 <1> 6066 <1> ; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols) 6067 <1> ; INPUT -> 6068 <1> ; AL = car, BL = attr, DL = xcurs, DH = ycurs, 6069 <1> ; [CRT_COLS] = nbcols 6070 <1> ; OUTPUT -> 6071 <1> ; Regen buffer updated 6072 <1> 6073 00002CEA 51 <1> push ecx 6074 00002CEB 53 <1> push ebx 6075 00002CEC 52 <1> push edx 6076 00002CED 50 <1> push eax 6077 <1> ; addr=xcurs*8+ycurs*nbcols*64; 6078 <1> ; 08/08/2016 6079 00002CEE 0FB6F0 <1> movzx esi, al ; car 6080 <1> ; 08/01/2021 6081 <1> ;movzx eax, dh ; ycurs 6082 <1> ;mov ah, [CRT_COLS] ; nbcols 6083 <1> ;mul ah 6084 00002CF1 A0[E0670000] <1> mov al, [CRT_COLS] 6085 00002CF6 F6E6 <1> mul dh 6086 <1> ;shl ax, 6 ; * 64 6087 <1> ;shl ax, 3 ; 8 * ycurs * [CRT_COLS] 6088 <1> ; 02/08/2022 6089 00002CF8 C1E003 <1> shl eax, 3 6090 <1> ;sub dh, dh 6091 <1> ;shl dx, 3 ; xcurs * 8 6092 <1> ;movzx edi, dx 6093 00002CFB BF00000A00 <1> mov edi, 0A0000h 6094 00002D00 30F6 <1> xor dh, dh 6095 00002D02 6689D7 <1> mov di, dx 6096 <1> ;movzx edi, dl 6097 00002D05 66C1E703 <1> shl di, 3 ; xcurs * 8 6098 <1> ;xor dh, dh 6099 00002D09 8A15[E2670000] <1> mov dl, [CHAR_HEIGHT] 6100 00002D0F 66F7E2 <1> mul dx 6101 <1> ; eax = ycurs*nbcols*8*[CHAR_HEIGHT] 6102 <1> ;add edi, eax ; addr 6103 <1> ;add edi, 0A0000h 6104 00002D12 6601C7 <1> add di, ax 6105 <1> ;shl si, 3 ; car * 8 6106 00002D15 30E4 <1> xor ah, ah 6107 00002D17 A0[E2670000] <1> mov al, [CHAR_HEIGHT] 6108 00002D1C 66F7E6 <1> mul si 6109 00002D1F 6689C6 <1> mov si, ax 6110 <1> ;; esi = src = car * 8 6111 <1> ; esi = src = car * [CHAR_HEIGHT] 6112 <1> ; i = 0 6113 <1> ;add esi, vgafont8 ; fdata [src+i] 6114 <1> ; 08/08/2016 6115 00002D22 A1[66890100] <1> mov eax, [VGA_INT43H] 6116 00002D27 09C0 <1> or eax, eax ; 0 ? 6117 00002D29 743E <1> jz short wfxl_7 ; yes, default font 6118 <1> ;cmp eax, vgafont16 6119 <1> ;je short wgfxl_0 6120 <1> ;cmp eax, vgafont14 6121 <1> ;je short wgfxl_0 6122 <1> ;cmp eax, vgafont8 6123 <1> ;je short wgfxl_0 6124 <1> ;; 05/01/2021 (TRDOS 386 v2.0.3) 6125 <1> ;; user font 6126 <1> ;mov eax, VGAFONTUSR ; 8x16 or 8x8 or 8x14 font 6127 <1> ; ; (256 characters) 6128 <1> wgfxl_0: 6129 00002D2B 01C6 <1> add esi, eax 6130 <1> wgfxl_1: 6131 00002D2D 28FF <1> sub bh, bh ; i = 0 6132 <1> wgfxl_2: 6133 <1> ; for(i=0;i<8;i++) 6134 00002D2F 57 <1> push edi ; addr 6135 00002D30 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] ; nbcols 6136 00002D37 F6E7 <1> mul bh ; nbcols*i 6137 <1> ;shl ax, 3 ; i*nbcols*8 6138 <1> ; 02/08/2022 6139 00002D39 C1E003 <1> shl eax, 3 6140 <1> ; dest=addr+i*nbcols*8; 6141 00002D3C 01C7 <1> add edi, eax ; dest + j ; j = 0 6142 00002D3E B180 <1> mov cl, 80h ; mask = 0x80; 6143 <1> ; esi = fdata + src + i 6144 <1> ; for(j=0;j<8;j++) 6145 00002D40 29D2 <1> sub edx, edx ; j = 0 6146 <1> wgfxl_3: 6147 00002D42 8A06 <1> mov al, [esi] ; al = fdata[src+i] 6148 00002D44 20C8 <1> and al, cl ; if (fdata[src+i] & mask) 6149 00002D46 7402 <1> jz short wgfxl_4 ; data = 0, zf = 1 6150 00002D48 88D8 <1> mov al, bl ; data = attr; 6151 <1> wgfxl_4: 6152 <1> ; write_byte(0xa000,dest+j,data); 6153 00002D4A AA <1> stosb ; dest + j (+ 0A0000h) 6154 <1> ;inc dl ; j++ 6155 <1> ;cmp dl, 8 6156 00002D4B 80FA07 <1> cmp dl, 7 6157 00002D4E 720E <1> jb short wgfxl_5 6158 00002D50 5F <1> pop edi 6159 <1> ; 08/08/2016 6160 <1> ;cmp bh, 7 6161 <1> ;jnb short wgfxl_6 6162 00002D51 FEC7 <1> inc bh ; i++ 6163 00002D53 3A3D[E2670000] <1> cmp bh, [CHAR_HEIGHT] 6164 00002D59 7309 <1> jnb short wgfxl_6 6165 00002D5B 46 <1> inc esi 6166 00002D5C EBD1 <1> jmp short wgfxl_2 6167 <1> wgfxl_5: 6168 00002D5E D0E9 <1> shr cl, 1 ; mask >>= 1; 6169 00002D60 FEC2 <1> inc dl ; j++ 6170 00002D62 EBDE <1> jmp short wgfxl_3 6171 <1> wgfxl_6: 6172 00002D64 58 <1> pop eax 6173 00002D65 5A <1> pop edx 6174 00002D66 5B <1> pop ebx 6175 00002D67 59 <1> pop ecx 6176 00002D68 C3 <1> retn 6177 <1> wfxl_7: 6178 <1> ; 08/01/2021 6179 <1> ; 05/01/2021 6180 <1> ; Default font (8x8 or 8x14 or 8x16) 6181 00002D69 A0[E2670000] <1> mov al, [CHAR_HEIGHT] 6182 00002D6E 3C08 <1> cmp al, 8 6183 00002D70 7507 <1> jne short wfxl_8 6184 00002D72 B8[50530100] <1> mov eax, vgafont8 6185 00002D77 EBB2 <1> jmp short wgfxl_0 6186 <1> wfxl_8: 6187 00002D79 3C0E <1> cmp al, 14 6188 00002D7B 7507 <1> jne short wfxl_9 6189 00002D7D B8[505B0100] <1> mov eax, vgafont14 6190 00002D82 EBA7 <1> jmp short wgfxl_0 6191 <1> wfxl_9: 6192 00002D84 B8[50690100] <1> mov eax, vgafont16 6193 00002D89 EBA0 <1> jmp short wgfxl_0 6194 <1> 6195 <1> write_gfx_char_pl4: 6196 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 6197 <1> ; 08/08/2016 6198 <1> ; 08/07/2016 (TRDOS 386 = TRDOS v2.0) 6199 <1> ; 6200 <1> ; derived from 'Plex86/Bochs VGABios' source code 6201 <1> ; vgabios-0.7a (2011) 6202 <1> ; by the LGPL VGABios developers Team (2001-2008) 6203 <1> ; 'vgabios.c', 'write_gfx_char_pl4' 6204 <1> 6205 <1> ; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight) 6206 <1> ; INPUT -> 6207 <1> ; AL = car, BL = attr, DL = xcurs, DH = ycurs, 6208 <1> ; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight 6209 <1> ; OUTPUT -> 6210 <1> ; Regen buffer updated 6211 <1> 6212 00002D8B 51 <1> push ecx 6213 00002D8C 53 <1> push ebx 6214 00002D8D 52 <1> push edx 6215 00002D8E 50 <1> push eax 6216 <1> wgfxpl_f0: 6217 <1> ; switch(cheight) 6218 00002D8F 8A25[E2670000] <1> mov ah, [CHAR_HEIGHT] 6219 00002D95 80FC10 <1> cmp ah, 16 ; case 16: 6220 00002D98 7507 <1> jne short wgfxpl_f1 6221 <1> ; fdata = &vgafont16; 6222 00002D9A BE[50690100] <1> mov esi, vgafont16 6223 00002D9F EB13 <1> jmp short wgfxpl_f3 6224 <1> wgfxpl_f1: 6225 00002DA1 80FC0E <1> cmp ah, 14 ; case 14: 6226 00002DA4 7507 <1> jne short wgfxpl_f2 6227 00002DA6 BE[505B0100] <1> mov esi, vgafont14 6228 00002DAB EB07 <1> jmp short wgfxpl_f3 6229 <1> wgfxpl_f2: 6230 <1> ; default: 6231 <1> ; fdata = &vgafont8; 6232 00002DAD BE[50530100] <1> mov esi, vgafont8 6233 00002DB2 B408 <1> mov ah, 8 6234 <1> wgfxpl_f3: 6235 <1> ; al = car 6236 00002DB4 F6E4 <1> mul ah ; ah = cheight 6237 00002DB6 25FFFF0000 <1> and eax, 0FFFFh ; car * cheight 6238 <1> ; src = car * cheight; 6239 00002DBB 01C6 <1> add esi, eax ; esi = fdata[src+i] 6240 <1> ; addr=xcurs*8+ycurs*nbcols*64; 6241 00002DBD 88F0 <1> mov al, dh ; ycurs 6242 00002DBF 8A25[E0670000] <1> mov ah, [CRT_COLS] ; nbcols 6243 00002DC5 F6E4 <1> mul ah 6244 <1> ; 08/08/2016 6245 <1> ;shl ax, 6 ; * 64 6246 <1> ;shl ax, 3 ; * 8 6247 <1> ; 02/08/2022 6248 00002DC7 C1E003 <1> shl eax, 3 6249 <1> ;sub dh, dh ; 0 6250 <1> ;shl dx, 3 ; xcurs * 8 6251 <1> ;movzx edi, dx 6252 00002DCA 0FB6FA <1> movzx edi, dl 6253 <1> ;shl di, 3 ; xcurs * 8 6254 <1> ; 02/08/2022 6255 00002DCD C1E703 <1> shl edi, 3 6256 00002DD0 30F6 <1> xor dh, dh 6257 00002DD2 8A15[E2670000] <1> mov dl, [CHAR_HEIGHT] 6258 00002DD8 66F7E2 <1> mul dx 6259 <1> ; eax = ycurs*nbcols*8*[CHAR_HEIGHT] 6260 00002DDB 01C7 <1> add edi, eax ; addr 6261 00002DDD 81C700000A00 <1> add edi, 0A0000h 6262 <1> ; 6263 <1> ; outw(VGAREG_SEQU_ADDRESS, 0x0f02); 6264 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0205); 6265 00002DE3 66BAC403 <1> mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 6266 00002DE7 66B8020F <1> mov ax, 0F02h 6267 00002DEB 66EF <1> out dx, ax 6268 00002DED 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6269 00002DF1 66B80502 <1> mov ax, 0205h 6270 00002DF5 66EF <1> out dx, ax 6271 <1> ; 6272 00002DF7 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6273 00002DFB F6C380 <1> test bl, 80h ; if(attr&0x80) 6274 00002DFE 7406 <1> jz short wgfxpl_f4 ; else 6275 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x1803); 6276 00002E00 66B80318 <1> mov ax, 1803h 6277 00002E04 EB04 <1> jmp short wgfxpl_f5 6278 <1> wgfxpl_f4: 6279 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0003); 6280 00002E06 66B80300 <1> mov ax, 0003h 6281 <1> wgfxpl_f5: 6282 00002E0A 66EF <1> out dx, ax 6283 <1> ; 6284 00002E0C 28FF <1> sub bh, bh ; i = 0 6285 <1> wgfxpl_0: 6286 <1> ; for(i=0;i push edi ; addr 6288 00002E0F 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] ; nbcols 6289 00002E16 F6E7 <1> mul bh ; nbcols*i 6290 <1> ; dest=addr+i*nbcols 6291 00002E18 01C7 <1> add edi, eax ; dest 6292 00002E1A B580 <1> mov ch, 80h ; mask = 0x80; 6293 <1> ; for(j=0;j<8;j++) 6294 00002E1C 28C9 <1> sub cl, cl ; j = 0 6295 <1> wgfxpl_1: 6296 00002E1E D2ED <1> shr ch, cl ; mask=0x80>>j; 6297 <1> ; 6298 <1> ; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08); 6299 <1> ; read_byte(0xa000,dest); 6300 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6301 00002E20 88EC <1> mov ah, ch 6302 00002E22 B008 <1> mov al, 8 6303 00002E24 66EF <1> out dx, ax 6304 00002E26 8A07 <1> mov al, [edi] ; ? (io delay?) 6305 <1> ; 6306 00002E28 28C0 <1> sub al, al ; attr = 0 6307 <1> ; if (fdata[src+i] & mask) 6308 00002E2A 842E <1> test byte [esi], ch 6309 00002E2C 7404 <1> jz short wgfxpl_2 ; zf = 1 6310 <1> ; write_byte(0xa000,dest,attr&0x0f); 6311 00002E2E 88D8 <1> mov al, bl ; attr; 6312 00002E30 240F <1> and al, 0Fh ; attr&0x0f 6313 <1> wgfxpl_2: 6314 <1> ; write_byte(0xa000,dest,0x00); 6315 00002E32 8807 <1> mov [edi], al ; dest (+ 0A0000h) 6316 00002E34 FEC1 <1> inc cl ; j++ 6317 00002E36 80F908 <1> cmp cl, 8 6318 00002E39 72E3 <1> jb short wgfxpl_1 6319 00002E3B 5F <1> pop edi 6320 <1> ; 08/08/2016 6321 <1> ;cmp bh, 7 6322 <1> ;jnb short wgfxpl_3 6323 00002E3C FEC7 <1> inc bh ; i++ 6324 00002E3E 3A3D[E2670000] <1> cmp bh, [CHAR_HEIGHT] 6325 00002E44 7303 <1> jnb short wgfxpl_3 6326 00002E46 46 <1> inc esi 6327 00002E47 EBC5 <1> jmp short wgfxpl_0 6328 <1> wgfxpl_3: 6329 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6330 00002E49 66B808FF <1> mov ax, 0FF08h 6331 00002E4D 66EF <1> out dx, ax 6332 00002E4F 66B80500 <1> mov ax, 0005h 6333 00002E53 66EF <1> out dx, ax 6334 00002E55 66B80300 <1> mov ax, 0003h 6335 00002E59 66EF <1> out dx, ax 6336 <1> ; 6337 00002E5B 58 <1> pop eax 6338 00002E5C 5A <1> pop edx 6339 00002E5D 5B <1> pop ebx 6340 00002E5E 59 <1> pop ecx 6341 00002E5F C3 <1> retn 6342 <1> 6343 <1> vga_write_pixel: 6344 <1> ; 02/08/2022 (TRDOS 386 Kerbel v2.0.5) 6345 <1> ; 09/07/2016 (TRDOS 386 = TRDOS v2.0) 6346 <1> ; 6347 <1> ; derived from 'Plex86/Bochs VGABios' source code 6348 <1> ; vgabios-0.7a (2011) 6349 <1> ; by the LGPL VGABios developers Team (2001-2008) 6350 <1> ; 'vgabios.c', 'biosfn_write_pixel' 6351 <1> 6352 <1> ; INPUT -> 6353 <1> ; DX = row (0-239) 6354 <1> ; CX = column (0-799) 6355 <1> ; AL = pixel value 6356 <1> ; (AH = [CRT_MODE]) 6357 <1> ; OUTPUT -> 6358 <1> ; none 6359 <1> 6360 00002E60 88C3 <1> mov bl, al ; pixel value 6361 <1> ;mov ah, [CRT_MODE] 6362 00002E62 BE[FA670000] <1> mov esi, vga_modes 6363 00002E67 89F7 <1> mov edi, esi 6364 00002E69 83C710 <1> add edi, vga_mode_count 6365 <1> vga_wp_0: 6366 00002E6C AC <1> lodsb 6367 00002E6D 38E0 <1> cmp al, ah ; [CRT_MODE] 6368 00002E6F 7405 <1> je short vga_wp_1 6369 00002E71 39FE <1> cmp esi, edi 6370 00002E73 72F7 <1> jb short vga_wp_0 6371 00002E75 C3 <1> retn ; nothing to do 6372 <1> vga_wp_1: 6373 00002E76 83C64F <1> add esi, vga_memmodel - (vga_modes + 1) 6374 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 6375 00002E79 BF00000A00 <1> mov edi, 0A0000h 6376 <1> ; 6377 00002E7E 803E04 <1> cmp byte [esi], PLANAR4 6378 00002E81 741C <1> je short vga_wp_planar 6379 00002E83 803E03 <1> cmp byte [esi], PLANAR1 6380 00002E86 7417 <1> je short vga_wp_planar 6381 <1> vga_wp_linear8: 6382 <1> ; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8); 6383 00002E88 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols 6384 <1> ;shl ax, 3 ; * 8 6385 <1> ; 02/08/2022 6386 00002E8F C1E003 <1> shl eax, 3 6387 00002E92 66F7E2 <1> mul dx 6388 00002E95 50 <1> push eax 6389 <1> ;mov edi, 0A0000h 6390 00002E96 6601CF <1> add di, cx 6391 00002E99 58 <1> pop eax 6392 00002E9A 01C7 <1> add edi, eax ; addr 6393 <1> ; write_byte(0xa000,addr,AL); 6394 00002E9C 881F <1> mov [edi], bl 6395 00002E9E C3 <1> retn 6396 <1> vga_wp_planar: 6397 <1> ; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS); 6398 00002E9F 0FB7C1 <1> movzx eax, cx 6399 00002EA2 66C1E803 <1> shr ax, 3 ; CX/8 6400 00002EA6 50 <1> push eax 6401 00002EA7 28E4 <1> sub ah, ah ; 0 6402 00002EA9 A0[E0670000] <1> mov al, [CRT_COLS] ; = [VGA_COLS] ; nbcols 6403 00002EAE 66F7E2 <1> mul dx 6404 <1> ;mov edi, 0A0000h 6405 00002EB1 6601C7 <1> add di, ax 6406 00002EB4 58 <1> pop eax 6407 00002EB5 01C7 <1> add edi, eax ; addr 6408 00002EB7 80E107 <1> and cl, 7 6409 00002EBA B580 <1> mov ch, 80h ; mask 6410 00002EBC D2ED <1> shr ch, cl ; mask = 0x80 >> (CX & 0x07); 6411 <1> 6412 <1> ; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08); 6413 00002EBE 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6414 00002EC2 88EC <1> mov ah, ch 6415 00002EC4 B008 <1> mov al, 8 6416 00002EC6 66EF <1> out dx, ax 6417 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x0205); 6418 00002EC8 66B80502 <1> mov ax, 0205h 6419 00002ECC 66EF <1> out dx, ax 6420 <1> ; data = read_byte(0xa000,addr); 6421 00002ECE 8A07 <1> mov al, [edi] ; (delay?) 6422 <1> ; if (AL & 0x80) 6423 <1> ; { 6424 <1> ; outw(VGAREG_GRDC_ADDRESS, 0x1803); 6425 <1> ; } 6426 00002ED0 F6C380 <1> test bl, 80h 6427 00002ED3 7406 <1> jz short vga_wp_2 6428 00002ED5 66B80318 <1> mov ax, 1803h 6429 00002ED9 66EF <1> out dx, ax 6430 <1> vga_wp_2: 6431 <1> ; write_byte(0xa000,addr,AL); 6432 00002EDB 881F <1> mov [edi], bl 6433 <1> ; 6434 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6435 00002EDD 66B808FF <1> mov ax, 0FF08h 6436 00002EE1 66EF <1> out dx, ax 6437 00002EE3 66B80500 <1> mov ax, 0005h 6438 00002EE7 66EF <1> out dx, ax 6439 00002EE9 66B80300 <1> mov ax, 0003h 6440 00002EED 66EF <1> out dx, ax 6441 <1> ; 6442 00002EEF C3 <1> retn 6443 <1> 6444 <1> vga_read_pixel: 6445 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 6446 <1> ; 09/07/2016 (TRDOS 386 = TRDOS v2.0) 6447 <1> ; 6448 <1> ; derived from 'Plex86/Bochs VGABios' source code 6449 <1> ; vgabios-0.7a (2011) 6450 <1> ; by the LGPL VGABios developers Team (2001-2008) 6451 <1> ; 'vgabios.c', 'biosfn_read_pixel' 6452 <1> 6453 <1> ; INPUT -> 6454 <1> ; DX = row (0-239) 6455 <1> ; CX = column (0-799) 6456 <1> ; (AH = [CRT_MODE]) 6457 <1> ; OUTPUT -> 6458 <1> ; AL = pixel value 6459 <1> 6460 <1> ;mov ah, [CRT_MODE] 6461 00002EF0 BE[FA670000] <1> mov esi, vga_modes 6462 00002EF5 89F7 <1> mov edi, esi 6463 00002EF7 83C710 <1> add edi, vga_mode_count 6464 <1> vga_rp_0: 6465 00002EFA AC <1> lodsb 6466 00002EFB 38E0 <1> cmp al, ah ; [CRT_MODE] 6467 00002EFD 7405 <1> je short vga_rp_1 6468 00002EFF 39FE <1> cmp esi, edi 6469 00002F01 72F7 <1> jb short vga_rp_0 6470 00002F03 C3 <1> retn ; nothing to do 6471 <1> vga_rp_1: 6472 00002F04 83C64F <1> add esi, vga_memmodel - (vga_modes + 1) 6473 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 6474 00002F07 BF00000A00 <1> mov edi, 0A0000h 6475 <1> ; 6476 00002F0C 803E04 <1> cmp byte [esi], PLANAR4 6477 00002F0F 741C <1> je short vga_rp_planar 6478 00002F11 803E03 <1> cmp byte [esi], PLANAR1 6479 00002F14 7417 <1> je short vga_rp_planar 6480 <1> vga_rp_linear8: 6481 <1> ; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8); 6482 00002F16 0FB605[E0670000] <1> movzx eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols 6483 <1> ;shl ax, 3 ; * 8 6484 <1> ; 02/08/2022 6485 00002F1D C1E003 <1> shl eax, 3 6486 00002F20 66F7E2 <1> mul dx 6487 00002F23 50 <1> push eax 6488 <1> ;mov edi, 0A0000h 6489 00002F24 6601CF <1> add di, cx 6490 00002F27 58 <1> pop eax 6491 00002F28 01C7 <1> add edi, eax ; addr 6492 <1> ; attr=read_byte(0xa000,addr); 6493 00002F2A 8A07 <1> mov al, [edi] ; pixel value 6494 00002F2C C3 <1> retn 6495 <1> vga_rp_planar: 6496 <1> ; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS); 6497 00002F2D 0FB7C1 <1> movzx eax, cx 6498 00002F30 66C1E803 <1> shr ax, 3 ; CX/8 6499 00002F34 50 <1> push eax 6500 00002F35 28E4 <1> sub ah, ah ; 0 6501 00002F37 A0[E0670000] <1> mov al, [CRT_COLS] ; = [VGA_COLS] ; nbcols 6502 00002F3C 66F7E2 <1> mul dx 6503 <1> ;mov edi, 0A0000h 6504 00002F3F 6601C7 <1> add di, ax 6505 00002F42 58 <1> pop eax 6506 00002F43 01C7 <1> add edi, eax ; addr 6507 00002F45 80E107 <1> and cl, 7 6508 00002F48 B580 <1> mov ch, 80h ; mask 6509 00002F4A D2ED <1> shr ch, cl ; mask = 0x80 >> (CX & 0x07); 6510 <1> ; attr = 0x00; 6511 00002F4C 30DB <1> xor bl, bl ; attr = bl = 0, 6512 00002F4E 30C9 <1> xor cl, cl ; i = cl = 0 6513 <1> ; for(i=0;i<4;i++) 6514 <1> ; { 6515 <1> ; outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04); 6516 <1> ; data = read_byte(0xa000,addr) & mask; 6517 <1> ; if (data > 0) attr |= (0x01 << i); 6518 <1> ; } 6519 <1> vga_rp_2: 6520 00002F50 88CC <1> mov ah, cl ; i << 8 6521 00002F52 B004 <1> mov al, 4 ; | 0x04 6522 00002F54 66BACE03 <1> mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 6523 00002F58 66EF <1> out dx, ax 6524 <1> ; data = read_byte(0xa000,addr) & mask; 6525 00002F5A 8A07 <1> mov al, [edi] 6526 00002F5C 20E8 <1> and al, ch ; & mask 6527 <1> ; if (data > 0) attr |= (0x01 << i); 6528 00002F5E 08C0 <1> or al, al 6529 00002F60 7408 <1> jz short vga_rp_3 ; al = 0 6530 00002F62 B701 <1> mov bh, 1 6531 00002F64 D2E7 <1> shl bh, cl ; (0x01 << i) 6532 00002F66 08FB <1> or bl, bh ; attr |= (0x01 << i) 6533 00002F68 88D8 <1> mov al, bl ; pixel value 6534 <1> vga_rp_3: 6535 00002F6A C3 <1> retn 6536 <1> 6537 <1> vga_beeper: 6538 <1> ; 04/08/2016 (TRDOS 386 = TRDOS v2.0) 6539 00002F6B FB <1> sti 6540 <1> ;mov bh, [ACTIVE_PAGE] 6541 00002F6C E917F4FFFF <1> jmp beeper_gfx 6542 <1> 6543 <1> vga_write_teletype: 6544 <1> ; 03/08/2022 (TRDOS 386 Kernel v2.0.5) 6545 <1> ; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop) 6546 <1> ; 09/12/2017 6547 <1> ; 06/08/2016 6548 <1> ; 04/08/2016 6549 <1> ; 01/08/2016 6550 <1> ; 31/07/2016 6551 <1> ; 09/07/2016 (TRDOS 386 = TRDOS v2.0) 6552 <1> ; 6553 <1> ; derived from 'Plex86/Bochs VGABios' source code 6554 <1> ; vgabios-0.7a (2011) 6555 <1> ; by the LGPL VGABios developers Team (2001-2008) 6556 <1> ; 'vgabios.c', 'biosfn_write_teletype' 6557 <1> ; 'biosfn_write_char_only' 6558 <1> 6559 <1> ; INPUT -> 6560 <1> ; [CRT_MODE] = current video mode (>7) 6561 <1> ; AL = Character to write 6562 <1> ; BL = Color of character 6563 <1> ; OUTPUT -> 6564 <1> ; Regen buffer updated 6565 <1> 6566 <1> ; biosfn_write_teletype (car, page, attr, flag) 6567 <1> ; car = character (AL) 6568 <1> ; page = 0 6569 <1> ; attr = color (BL) 6570 <1> ; 'flag' not used 6571 <1> 6572 00002F71 8A25[DE670000] <1> mov ah, [CRT_MODE] 6573 00002F77 88C7 <1> mov bh, al ; character 6574 00002F79 668B15[DE7C0100] <1> mov dx, [CURSOR_POSN] ; cursor pos for page 0 6575 <1> 6576 00002F80 BE[02680000] <1> mov esi, vga_g_modes 6577 00002F85 89F7 <1> mov edi, esi 6578 00002F87 83C708 <1> add edi, vga_g_mode_count 6579 <1> vga_wtty_0: 6580 00002F8A AC <1> lodsb 6581 00002F8B 38E0 <1> cmp al, ah ; [CRT_MODE] 6582 00002F8D 7405 <1> je short vga_wtty_2 6583 00002F8F 39FE <1> cmp esi, edi 6584 00002F91 72F7 <1> jb short vga_wtty_0 6585 <1> vga_wtty_1: 6586 00002F93 C3 <1> retn ; nothing to do 6587 <1> vga_wtty_2: 6588 00002F94 80FF07 <1> cmp bh, 07h ; bell (beep) 6589 00002F97 74D2 <1> je short vga_beeper ; u11 6590 00002F99 80FF08 <1> cmp bh, 08h ; backspace 6591 00002F9C 7508 <1> jne short vga_wtty_3 6592 <1> ; if(xcurs>0)xcurs--; 6593 00002F9E 08D2 <1> or dl, dl ; xcurs (column) 6594 00002FA0 74F1 <1> jz short vga_wtty_1 6595 00002FA2 FECA <1> dec dl ; xcurs--; 6596 00002FA4 EB55 <1> jmp short vga_wtty_12 6597 <1> vga_wtty_3: 6598 00002FA6 80FF0D <1> cmp bh, 0Dh ; carriage return (\r) 6599 00002FA9 7504 <1> jne short vga_wtty_4 6600 <1> ; xcurs=0; 6601 00002FAB 28D2 <1> sub dl, dl ; 0 6602 00002FAD EB4C <1> jmp short vga_wtty_12 6603 <1> vga_wtty_4: 6604 00002FAF 80FF0A <1> cmp bh, 0Ah ; new line (\n) 6605 00002FB2 7504 <1> jne short vga_wtty_5 6606 <1> ; ycurs++; 6607 00002FB4 FEC6 <1> inc dh ; next row 6608 00002FB6 EB5E <1> jmp short vga_wtty_11 6609 <1> vga_wtty_5: 6610 00002FB8 80FF09 <1> cmp bh, 09h ; tab stop 6611 00002FBB 7523 <1> jne short vga_wtty_8 6612 00002FBD 88D0 <1> mov al, dl 6613 <1> ;cbw 6614 00002FBF 30E4 <1> xor ah, ah ; 09/12/2017 6615 00002FC1 B108 <1> mov cl, 8 6616 00002FC3 F6F1 <1> div cl 6617 00002FC5 28E1 <1> sub cl, ah 6618 <1> ; 6619 00002FC7 B720 <1> mov bh, 20h ; space 6620 <1> vga_wtty_6: ; tab stop loop 6621 <1> ;push cx 6622 <1> ;push bx 6623 <1> ; 12/04/2021 6624 00002FC9 51 <1> push ecx 6625 00002FCA 53 <1> push ebx 6626 00002FCB E810000000 <1> call vga_wtty_8 6627 <1> ;pop bx ; bh = character, bl = color 6628 <1> ;pop cx 6629 <1> ; 12/04/2021 6630 00002FD0 5B <1> pop ebx ; bh = character, bl = color 6631 00002FD1 59 <1> pop ecx 6632 00002FD2 FEC9 <1> dec cl 6633 00002FD4 7409 <1> jz short vga_wtty_7 6634 00002FD6 668B15[DE7C0100] <1> mov dx, [CURSOR_POSN] ; new cursor position (pg 0) 6635 00002FDD EBEA <1> jmp short vga_wtty_6 6636 <1> vga_wtty_7: 6637 00002FDF C3 <1> retn 6638 <1> ; 6639 <1> vga_wtty_8: 6640 00002FE0 83C64F <1> add esi, vga_g_memmodel - (vga_g_modes + 1) 6641 <1> ; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1) 6642 00002FE3 BF00000A00 <1> mov edi, 0A0000h 6643 <1> ; 6644 00002FE8 88F8 <1> mov al, bh ; character 6645 <1> ; 6646 00002FEA 803E04 <1> cmp byte [esi], PLANAR4 6647 00002FED 7414 <1> je short vga_wtty_planar 6648 00002FEF 803E03 <1> cmp byte [esi], PLANAR1 6649 00002FF2 740F <1> je short vga_wtty_planar 6650 <1> vga_wtty_linear8: 6651 <1> ; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols); 6652 <1> ; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 6653 <1> ; [CRT_COLS] = nbcols 6654 00002FF4 E8F1FCFFFF <1> call write_gfx_char_lin 6655 00002FF9 EB0D <1> jmp short vga_wtty_9 6656 <1> 6657 <1> vga_wtty_12: 6658 <1> ; 09/07/2016 6659 <1> ; set cursor position 6660 <1> ; NOTE: Hardware cursor position will not be set 6661 <1> ; in any VGA modes (>7) 6662 <1> ; But, cursor position will be saved into 6663 <1> ; [CURSOR_POSN]. 6664 <1> ; TRDOS 386 (TRDOS v2.0) uses only one page 6665 <1> ; (page 0) for all graphics modes. 6666 <1> 6667 00002FFB 668915[DE7C0100] <1> mov [CURSOR_POSN], dx ; save cursor pos for pg 0 6668 <1> ; 04/08/2016 6669 <1> ;mov bh, [ACTIVE_PAGE] ; = 0 6670 <1> ;call _set_cpos 6671 00003002 C3 <1> retn 6672 <1> 6673 <1> vga_wtty_planar: 6674 <1> ; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight); 6675 <1> ; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 6676 <1> ; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight 6677 00003003 E883FDFFFF <1> call write_gfx_char_pl4 6678 <1> vga_wtty_9: 6679 00003008 FEC2 <1> inc dl ; xcurs++; 6680 <1> vga_wtty_10: 6681 <1> ; Do we need to wrap ? 6682 <1> ; if(xcurs==nbcols) 6683 0000300A 3A15[E0670000] <1> cmp dl, [CRT_COLS] ; [VGA_COLS] 6684 00003010 7204 <1> jb short vga_wtty_11 ; no 6685 00003012 28D2 <1> sub dl, dl ; xcurs=0; 6686 00003014 FEC6 <1> inc dh ; ycurs++; 6687 <1> vga_wtty_11: 6688 <1> ; Do we need to scroll ? 6689 <1> ; if(ycurs==nbrows) 6690 00003016 3A35[E6670000] <1> cmp dh, [VGA_ROWS] 6691 0000301C 72DD <1> jb short vga_wtty_12 ; no 6692 <1> ; 6693 <1> ; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir) 6694 <1> ; al = nblines = 1, bl = attr (color) = 0 6695 <1> ; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0 6696 <1> ; dir = SCROLL_UP 6697 <1> 6698 0000301E B001 <1> mov al, 1 6699 00003020 28DB <1> sub bl, bl ; 0 ; blank/black line (attr=0) will be used 6700 <1> ;sub cx, cx ; 0,0 6701 <1> ; 03/08/2022 6702 00003022 29C9 <1> sub ecx, ecx 6703 <1> 6704 <1> ; 06/08/2016 6705 00003024 8A35[E6670000] <1> mov dh, [VGA_ROWS] 6706 0000302A FECE <1> dec dh ; nbrows -1 6707 <1> 6708 <1> ;push dx ; 04/08/2016 6709 <1> ; 12/04/2021 6710 0000302C 52 <1> push edx 6711 0000302D 8A15[E0670000] <1> mov dl, [CRT_COLS] 6712 00003033 FECA <1> dec dl ; nbcols -1 6713 <1> 6714 00003035 8A25[DE670000] <1> mov ah, [CRT_MODE] 6715 <1> 6716 <1> ; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP); 6717 0000303B E843F5FFFF <1> call vga_graphics_up 6718 <1> ; 04/08/2016 6719 <1> ;pop dx 6720 <1> ; 12/04/2021 6721 00003040 5A <1> pop edx 6722 <1> 6723 <1> ;dec dh ; ycurs-=1 6724 00003041 EBB8 <1> jmp short vga_wtty_12 6725 <1> 6726 <1> font_setup: 6727 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 6728 <1> ; 09/01/2021 (TRDOS 386 v2.0.3) 6729 <1> ; 09/07/2016 6730 <1> ; character generator (font loading) functions 6731 <1> ; 6732 <1> ; derived from 'Plex86/Bochs VGABios' source code 6733 <1> ; vgabios-0.7a (2011) 6734 <1> ; by the LGPL VGABios developers Team (2001-2008) 6735 <1> ; 'vgabios.c', 'int10_func' 6736 <1> 6737 <1> ; AX = 1100H ; Load User-Defined Font (EGA/VGA) 6738 <1> ; 6739 <1> ; BH = height of each character (bytes per character definition) 6740 <1> ; (BL = font block to load (EGA: 0-3; VGA: 0-7)) 6741 <1> ; CX = number of characters to redefine (<=256) 6742 <1> ; DX = ASCII code of the first character defined at ES:BP 6743 <1> ; EBP = address of font-definition information 6744 <1> ; (in user's memory space) 6745 <1> 6746 <1> ; case 0x11: 6747 <1> ; switch(GET_AL()) 6748 <1> ; { 6749 <1> ; case 0x00: 6750 <1> ; case 0x10: 6751 <1> ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH()); 6752 <1> ; break; 6753 <1> 6754 <1> ; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA) 6755 00003043 08C0 <1> or al, al ; 0 6756 00003045 7404 <1> jz short font_setup_0 6757 00003047 3C10 <1> cmp al, 10h 6758 00003049 7511 <1> jne short font_setup_1 6759 <1> font_setup_0: 6760 0000304B E8CE000000 <1> call transfer_user_fonts 6761 00003050 721C <1> jc short font_setup_error 6762 00003052 E8AD010000 <1> call load_text_user_pat 6763 00003057 E9D6EAFFFF <1> jmp VIDEO_RETURN 6764 <1> font_setup_1: 6765 <1> ; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA) 6766 <1> ; case 0x01: 6767 <1> ; case 0x11: 6768 <1> ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL()); 6769 <1> ; break; 6770 0000305C 3C01 <1> cmp al, 1 6771 0000305E 7404 <1> je short font_setup_2 6772 00003060 3C11 <1> cmp al, 11h 6773 00003062 7511 <1> jne short font_setup_3 6774 <1> font_setup_2: 6775 <1> ; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA) 6776 <1> ; (BL = font block to load (EGA: 0-3; VGA: 0-7)) 6777 00003064 E8C9020000 <1> call load_text_8_14_pat 6778 00003069 E9C4EAFFFF <1> jmp VIDEO_RETURN 6779 <1> font_setup_error: 6780 0000306E 29C0 <1> sub eax, eax ; 0 -> fonts could not be loaded 6781 00003070 E9C2EAFFFF <1> jmp _video_return 6782 <1> font_setup_3: 6783 <1> ; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA) 6784 <1> ; case 0x02: 6785 <1> ; case 0x12: 6786 <1> ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL()); 6787 <1> ; break; 6788 00003075 3C02 <1> cmp al, 2 6789 00003077 7404 <1> je short font_setup_4 6790 00003079 3C12 <1> cmp al, 12h 6791 0000307B 750A <1> jne short font_setup_5 6792 <1> font_setup_4: 6793 <1> ; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA) 6794 <1> ; (BL = font block to load (EGA: 0-3; VGA: 0-7)) 6795 0000307D E8E1020000 <1> call load_text_8_8_pat 6796 00003082 E9ABEAFFFF <1> jmp VIDEO_RETURN 6797 <1> font_setup_5: 6798 <1> ; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA) 6799 <1> ; case 0x04: 6800 <1> ; case 0x14: 6801 <1> ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL()); 6802 <1> ; break; 6803 00003087 3C04 <1> cmp al, 4 6804 00003089 7404 <1> je short font_setup_6 6805 0000308B 3C14 <1> cmp al, 14h 6806 0000308D 750A <1> jne short font_setup_7 6807 <1> font_setup_6: 6808 <1> ; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA) 6809 <1> ; (BL = font block to load (EGA: 0-3; VGA: 0-7)) 6810 0000308F E819030000 <1> call load_text_8_16_pat 6811 00003094 E999EAFFFF <1> jmp VIDEO_RETURN 6812 <1> font_setup_7: 6813 <1> ; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed 6814 <1> ; for TRDOS 386 (TRDOS v2.0) video functionality; 6815 <1> ; because, originally EXT_PTR (font address) was used for 6816 <1> ; chars 80h to 0FFh (after the first 128 ASCII char fonts), for 6817 <1> ; CGA graphics mode; currenty, 'vgafont8' address has 256 chars! 6818 <1> ; 6819 <1> ; case 0x20: 6820 <1> ; biosfn_load_gfx_8_8_chars(ES,BP); 6821 <1> ; break; 6822 <1> ; case 0x21: 6823 <1> ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL()); 6824 <1> ; break; 6825 <1> ; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA) 6826 <1> ; BL screen rows code: 00H = user-specified (in DL) 6827 <1> ; 01H = 14 rows 6828 <1> ; 02H = 25 rows 6829 <1> ; 03H = 43 rows 6830 <1> ; CX bytes per character definition 6831 <1> ; DL (when BL=0) custom number of character rows on screen 6832 <1> ; EBP address of font-definition information (user's mem space) 6833 <1> 6834 00003099 3C21 <1> cmp al, 21h 6835 0000309B 7531 <1> jne short font_setup_9 6836 <1> 6837 <1> ; TRDOS 386 modification ! 6838 <1> ; dh = 0 -> 256 characters 6839 <1> ; dh = 80h -> second 128 characters 6840 <1> ; dh = 0FFh -> first 128 characters 6841 <1> 6842 <1> ; 09/01/2021 (TRDOS 386 v2.0.3) 6843 <1> ;push ebx 6844 0000309D 51 <1> push ecx 6845 0000309E 52 <1> push edx 6846 0000309F 30D2 <1> xor dl, dl 6847 000030A1 88CF <1> mov bh, cl ; character height 6848 <1> ;mov cx, 100h ; 256 6849 <1> ; 03/08/2022 6850 000030A3 31C9 <1> xor ecx, ecx 6851 000030A5 FEC5 <1> inc ch 6852 <1> ; ecx = 100h 6853 000030A7 08F6 <1> or dh, dh ; 0 6854 000030A9 7410 <1> jz short font_setup_8 6855 000030AB FECD <1> dec ch ; cx = 0 6856 000030AD 80FEFF <1> cmp dh, 0FFh 6857 000030B0 7409 <1> je short font_setup_8 ; 1st 128 chars 6858 <1> ; 2nd 128 chars 6859 000030B2 80FE80 <1> cmp dh, 80h 6860 000030B5 75B7 <1> jne short font_setup_error ; invalid ! 6861 000030B7 88F1 <1> mov cl, dh 6862 000030B9 86F2 <1> xchg dl, dh 6863 <1> ; number of chars, cx = 80h 6864 <1> ; start char, dl = 80h 6865 <1> font_setup_8: 6866 000030BB E85E000000 <1> call transfer_user_fonts 6867 000030C0 5A <1> pop edx 6868 000030C1 59 <1> pop ecx 6869 <1> ;pop ebx 6870 000030C2 72AA <1> jc short font_setup_error 6871 <1> ; ebp = user's font data address in system's memory space 6872 000030C4 E82F030000 <1> call load_gfx_user_chars 6873 000030C9 E964EAFFFF <1> jmp VIDEO_RETURN 6874 <1> font_setup_9: 6875 <1> ; case 0x22: 6876 <1> ; biosfn_load_gfx_8_14_chars(GET_BL()); 6877 <1> ; break; 6878 000030CE 3C22 <1> cmp al, 22h 6879 000030D0 750A <1> jne short font_setup_10 6880 000030D2 E85D030000 <1> call load_gfx_8_14_chars 6881 000030D7 E956EAFFFF <1> jmp VIDEO_RETURN 6882 <1> font_setup_10: 6883 <1> ; case 0x23: 6884 <1> ; biosfn_load_gfx_8_8_dd_chars(GET_BL()); 6885 <1> ; break; 6886 000030DC 3C23 <1> cmp al, 23h 6887 000030DE 750A <1> jne short font_setup_11 6888 000030E0 E890030000 <1> call load_gfx_8_8_chars 6889 000030E5 E948EAFFFF <1> jmp VIDEO_RETURN 6890 <1> font_setup_11: 6891 <1> ; case 0x24: 6892 <1> ; biosfn_load_gfx_8_16_chars(GET_BL()); 6893 <1> ; break; 6894 000030EA 3C24 <1> cmp al, 24h 6895 000030EC 750A <1> jne short font_setup_12 6896 000030EE E8C3030000 <1> call load_gfx_8_16_chars 6897 000030F3 E93AEAFFFF <1> jmp VIDEO_RETURN 6898 <1> font_setup_12: 6899 <1> ; case 0x30: 6900 <1> ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX); 6901 <1> ; break; 6902 000030F8 3C30 <1> cmp al, 30h 6903 000030FA 750A <1> jne short font_setup_13 6904 000030FC E8F6030000 <1> call get_font_info 6905 <1> ; eax = return value (info: 4 bytes for 4 parms) 6906 <1> ; eax = 0 -> invalid function (input) 6907 00003101 E931EAFFFF <1> jmp _video_return 6908 <1> font_setup_13: 6909 00003106 3C03 <1> cmp al, 03h ; AX = 1103h 6910 00003108 750D <1> jne short font_setup_14 6911 <1> ; biosfn_set_text_block_specifier: 6912 <1> ; BL = font block selector code 6913 <1> ; NOTE: TRDOS 386 only uses and sets font block 0 6914 <1> ; (It is as BL = 0 for TRDOS 386) 6915 0000310A 66BAC403 <1> mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 6916 <1> ;mov ah, bl 6917 0000310E 28E4 <1> sub ah, ah ; 0 6918 <1> ;mov al, 03h 6919 00003110 66EF <1> out dx, ax 6920 00003112 E91BEAFFFF <1> jmp VIDEO_RETURN 6921 <1> 6922 <1> font_setup_14: 6923 00003117 29C0 <1> sub eax, eax ; 0 = invalid function 6924 00003119 E919EAFFFF <1> jmp _video_return 6925 <1> 6926 <1> transfer_user_fonts: 6927 <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5) 6928 <1> ; 19/01/2021 6929 <1> ; 09/01/2021 6930 <1> ; 05/01/2021 (TRDOS 386 v2.0.3) 6931 <1> 6932 <1> ; BH = height of each character (bytes per character) 6933 <1> ; CX = number of characters to redefine (<=256) 6934 <1> ; DX = ASCII code of the first character defined at EBP 6935 <1> ; EBP = address of font-definition information 6936 <1> ; (in user's memory space) 6937 <1> 6938 <1> ; Modified registers: eax, edx, ecx, esi, edi, ebp 6939 <1> ; 6940 <1> ; output: 6941 <1> ; ebp = user font data address in system memory 6942 <1> 6943 0000311E 81E2FFFF0000 <1> and edx, 0FFFFh 6944 00003124 81E1FFFF0000 <1> and ecx, 0FFFFh 6945 0000312A 7537 <1> jnz short transfer_user_fonts_5 6946 <1> 6947 0000312C 09D2 <1> or edx, edx 6948 0000312E 7531 <1> jnz short transfer_user_fonts_4 6949 00003130 09ED <1> or ebp, ebp 6950 00003132 752D <1> jnz short transfer_user_fonts_4 6951 <1> 6952 <1> ; cx = 0, dx = 0, ebp = 0 6953 <1> ; copy system font to user font 6954 <1> 6955 00003134 B140 <1> mov cl, 64 ; 64 dwords 6956 <1> 6957 00003136 80FF10 <1> cmp bh, 16 6958 00003139 7417 <1> je short transfer_user_fonts_2 6959 0000313B 80FF08 <1> cmp bh, 8 6960 0000313E 7406 <1> je short transfer_user_fonts_1 6961 <1> 6962 00003140 BD[505B0100] <1> mov ebp, vgafont14 6963 00003145 C3 <1> retn 6964 <1> 6965 <1> transfer_user_fonts_1: 6966 00003146 BF00500900 <1> mov edi, VGAFONT8USER 6967 0000314B BE[50530100] <1> mov esi, vgafont8 6968 00003150 EB0A <1> jmp short transfer_user_fonts_3 6969 <1> 6970 <1> transfer_user_fonts_2: 6971 00003152 BF00400900 <1> mov edi, VGAFONT16USER 6972 00003157 BE[50690100] <1> mov esi, vgafont16 6973 <1> transfer_user_fonts_3: 6974 0000315C 89FD <1> mov ebp, edi 6975 0000315E F3A5 <1> rep movsd 6976 00003160 C3 <1> retn 6977 <1> 6978 <1> transfer_user_fonts_4: 6979 00003161 F9 <1> stc 6980 00003162 C3 <1> retn 6981 <1> 6982 <1> transfer_user_fonts_5: 6983 00003163 09ED <1> or ebp, ebp 6984 00003165 74FA <1> jz short transfer_user_fonts_4 ; invalid address ! 6985 <1> 6986 00003167 6681F90001 <1> cmp cx, 256 6987 0000316C 77F3 <1> ja short transfer_user_fonts_4 6988 0000316E 29D1 <1> sub ecx, edx 6989 00003170 76EF <1> jna short transfer_user_fonts_4 6990 <1> 6991 00003172 80FF0E <1> cmp bh, 14 ; 8x14 font 6992 <1> ; (there is not an alternative buffer) 6993 00003175 7524 <1> jne short transfer_user_fonts_6 6994 <1> 6995 <1> ; use system's 8x14 font space if permission flag is 1 6996 00003177 F605[8EA30100]80 <1> test byte [ufont], 80h 6997 0000317E 74E1 <1> jz short transfer_user_fonts_4 ; not allowed 6998 <1> 6999 <1> ; permission is given (for vgafont14 location etc.) 7000 <1> ; (for permanent font modification) 7001 <1> ; 7002 <1> ; 19/01/2021 7003 <1> ; Note: Permission flag can be set by 'root' while 7004 <1> ; system is not in multi tasking/user mode 7005 <1> ; while [multi_tasking] = 0 and [u.uid] = 0 7006 <1> 7007 <1> ;push edx 7008 <1> ; 02/08/2022 7009 00003180 87CA <1> xchg edx, ecx 7010 <1> ;xor ah, ah 7011 <1> ; 02/08/2022 7012 00003182 31C0 <1> xor eax, eax 7013 00003184 88F8 <1> mov al, bh ; mov al, 14 7014 <1> ;mul cx 7015 <1> ; 02/08/2022 7016 00003186 F7E2 <1> mul edx ; char count * 14 7017 <1> ; 02/08/2022 7018 00003188 89CA <1> mov edx, ecx ; ascii code 7019 0000318A 89C1 <1> mov ecx, eax 7020 <1> ; ecx = byte count 7021 <1> ;pop edx 7022 <1> ; 02/08/2022 7023 <1> ;xor eax, eax 7024 0000318C 30E4 <1> xor ah, ah 7025 0000318E 88F8 <1> mov al, bh ; mov ax, 14 ; bytes per character 7026 <1> ;mul dx 7027 <1> ;mov dx, ax ; char offset 7028 <1> ; 02/08/2022 7029 00003190 F7E2 <1> mul edx 7030 00003192 89C2 <1> mov edx, eax ; char offset 7031 00003194 BF[505B0100] <1> mov edi, vgafont14 7032 00003199 EB48 <1> jmp short transfer_user_fonts_8 7033 <1> transfer_user_fonts_6: 7034 0000319B 80FF08 <1> cmp bh, 8 ; 8x8 font 7035 0000319E 7520 <1> jne short transfer_user_fonts_7 ; 8x16 font 7036 <1> ;shl dx, 3 ; * 8 7037 <1> ;shl cx, 3 ; * 8 7038 <1> ; 02/08/2022 7039 000031A0 C1E203 <1> shl edx, 3 ; byte offset 7040 000031A3 C1E103 <1> shl ecx, 3 ; byte count 7041 <1> ; 09/01/2021 7042 000031A6 BF00500900 <1> mov edi, VGAFONT8USER 7043 000031AB F605[8EA30100]08 <1> test byte [ufont], 8 ; already loaded ? 7044 000031B2 752F <1> jnz short transfer_user_fonts_8 ; yes 7045 000031B4 BE[50530100] <1> mov esi, vgafont8 7046 000031B9 E839000000 <1> call transfer_user_fonts_10 7047 000031BE EB23 <1> jmp short transfer_user_fonts_8 7048 <1> transfer_user_fonts_7: 7049 000031C0 80FF10 <1> cmp bh, 16 ; 8x16 font 7050 000031C3 759C <1> jne short transfer_user_fonts_4 ; invalid ! 7051 <1> ;shl dx, 4 ; * 16 7052 <1> ;shl cx, 4 ; * 16 7053 <1> ; 02/08/2022 7054 000031C5 C1E204 <1> shl edx, 4 ; byte offset 7055 000031C8 C1E104 <1> shl ecx, 4 ; byte count 7056 000031CB BF00400900 <1> mov edi, VGAFONT16USER 7057 000031D0 F605[8EA30100]10 <1> test byte [ufont], 16 ; already loaded ? 7058 000031D7 750A <1> jnz short transfer_user_fonts_8 ; yes 7059 000031D9 BE[50690100] <1> mov esi, vgafont16 7060 000031DE E814000000 <1> call transfer_user_fonts_10 7061 <1> transfer_user_fonts_8: 7062 000031E3 01D7 <1> add edi, edx ; char offset 7063 <1> ; 09/07/2016 7064 <1> ;and ecx, 0FFFFh 7065 <1> ; ECX = byte count 7066 <1> ;push ecx 7067 000031E5 89EE <1> mov esi, ebp ; user's font buffer 7068 <1> ; 09/01/2021 7069 000031E7 89FD <1> mov ebp, edi ; system addr for user's font 7070 <1> ; 05/01/2021 7071 <1> ;mov edi, Cluster_Buffer ; system buffer 7072 000031E9 E8ECDD0000 <1> call transfer_from_user_buffer 7073 <1> ;pop ecx 7074 <1> ; ecx = transfer (byte) count = character count 7075 000031EE 7206 <1> jc short transfer_user_fonts_9 7076 <1> ; 05/01/2021 7077 <1> ;mov ebp, Cluster_Buffer 7078 <1> 7079 000031F0 083D[8EA30100] <1> or byte [ufont], bh 7080 <1> ; 8x8 or 8x16 user font ready 7081 <1> transfer_user_fonts_9: 7082 000031F6 C3 <1> retn 7083 <1> 7084 <1> transfer_user_fonts_10: 7085 <1> ; 02/08/2022 7086 <1> ; 09/01/2021 7087 000031F7 56 <1> push esi 7088 000031F8 57 <1> push edi 7089 000031F9 51 <1> push ecx 7090 <1> ;mov cx, 64 7091 <1> ; 02/08/2022 7092 000031FA 31C9 <1> xor ecx, ecx 7093 000031FC B140 <1> mov cl, 64 7094 000031FE F3A5 <1> rep movsd 7095 00003200 59 <1> pop ecx 7096 00003201 5F <1> pop edi 7097 00003202 5E <1> pop esi 7098 00003203 C3 <1> retn 7099 <1> 7100 <1> load_text_user_pat: 7101 <1> ; 02/08/2022 (TRDOS 3386 v2.0.5) 7102 <1> ; 26/07/2016 7103 <1> ; 09/07/2016 7104 <1> ; load user defined (EGA/VGA) text fonts 7105 <1> ; 7106 <1> ; derived from 'Plex86/Bochs VGABios' source code 7107 <1> ; vgabios-0.7a (2011) 7108 <1> ; by the LGPL VGABios developers Team (2001-2008) 7109 <1> ; 'vgabios.c', 'biosfn_load_text_user_pat' 7110 <1> 7111 <1> ; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH) 7112 <1> 7113 <1> ; get_font_access(); 7114 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7115 <1> ; for(i=0;i ; { 7117 <1> ; src = BP + i * BH; 7118 <1> ; dest = blockaddr + (DX + i) * 32; 7119 <1> ; memcpyb(0xA000, dest, ES, src, BH); 7120 <1> ; } 7121 <1> ; release_font_access(); 7122 <1> ; if(AL>=0x10) 7123 <1> ; { 7124 <1> ; set_scan_lines(BH); 7125 <1> ; } 7126 <1> 7127 00003204 50 <1> push eax 7128 00003205 E839000000 <1> call get_font_access 7129 0000320A 28DB <1> sub bl, bl ; i = 0 7130 <1> ; 02/08/2022 7131 <1> ; ecx <= 256 7132 0000320C 30ED <1> xor ch, ch 7133 <1> ltup_1: 7134 0000320E 88D8 <1> mov al, bl 7135 00003210 F6E7 <1> mul bh 7136 <1> ;movzx esi, ax 7137 <1> ; 02/08/2022 7138 00003212 89C6 <1> mov esi, eax 7139 00003214 01EE <1> add esi, ebp 7140 00003216 88D8 <1> mov al, bl 7141 00003218 28E4 <1> sub ah, ah 7142 <1> ;add ax, dx ; (DX + i) 7143 <1> ;shl ax, 5 ; * 32 7144 <1> ; 02/08/2022 7145 0000321A 01D0 <1> add eax, edx 7146 0000321C C1E005 <1> shl eax, 5 7147 <1> ;movzx edi, ax 7148 <1> ; 02/08/2022 7149 0000321F 89C7 <1> mov edi, eax 7150 00003221 81C700000A00 <1> add edi, 0A0000h 7151 00003227 51 <1> push ecx 7152 <1> ;movzx ecx, bh 7153 <1> ; 02/08/2022 7154 00003228 88F9 <1> mov cl, bh 7155 0000322A F3A4 <1> rep movsb 7156 0000322C 59 <1> pop ecx 7157 0000322D FEC3 <1> inc bl 7158 0000322F 38CB <1> cmp bl, cl 7159 00003231 75DB <1> jne short ltup_1 7160 <1> ; 7161 00003233 E83E000000 <1> call release_font_access 7162 <1> ; 7163 00003238 58 <1> pop eax 7164 <1> ; if(AL>=0x10) 7165 00003239 3C10 <1> cmp al, 10h 7166 0000323B 7205 <1> jb short ltup_2 7167 <1> ; set_scan_lines(BH); 7168 0000323D E86F000000 <1> call set_scan_lines 7169 <1> ltup_2: 7170 00003242 C3 <1> retn 7171 <1> 7172 <1> get_font_access: 7173 <1> ; 02/08/2022 7174 <1> ; 09/07/2016 7175 <1> ; 7176 <1> ; derived from 'Plex86/Bochs VGABios' source code 7177 <1> ; vgabios-0.7a (2011) 7178 <1> ; by the LGPL VGABios developers Team (2001-2008) 7179 <1> ; 'vgabios.c', 'get_font_access' 7180 <1> 7181 <1> ; get_font_access() 7182 00003243 52 <1> push edx 7183 00003244 66BAC403 <1> mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 7184 <1> ; 02/08/2022 7185 00003248 31C0 <1> xor eax, eax 7186 <1> ;mov ax, 0100h 7187 0000324A B401 <1> mov ah, 1 7188 <1> ; ax = 0100h 7189 0000324C 66EF <1> out dx, ax 7190 0000324E 66B80204 <1> mov ax, 0402h 7191 00003252 66EF <1> out dx, ax 7192 00003254 66B80407 <1> mov ax, 0704h 7193 00003258 66EF <1> out dx, ax 7194 0000325A 66B80003 <1> mov ax, 0300h 7195 0000325E 66EF <1> out dx, ax 7196 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 7197 <1> ; 02/08/2022 7198 00003260 B2CE <1> mov dl, 0CEh 7199 00003262 66B80402 <1> mov ax, 0204h 7200 00003266 66EF <1> out dx, ax 7201 00003268 66B80500 <1> mov ax, 0005h 7202 0000326C 66EF <1> out dx, ax 7203 0000326E 66B80604 <1> mov ax, 0406h 7204 00003272 66EF <1> out dx, ax 7205 00003274 5A <1> pop edx 7206 00003275 C3 <1> retn 7207 <1> 7208 <1> release_font_access: 7209 <1> ; 02/08/2022 7210 <1> ; 29/07/2016 7211 <1> ; 09/07/2016 7212 <1> ; 7213 <1> ; derived from 'Plex86/Bochs VGABios' source code 7214 <1> ; vgabios-0.7a (2011) 7215 <1> ; by the LGPL VGABios developers Team (2001-2008) 7216 <1> ; 'vgabios.c', 'release_font_access' 7217 <1> 7218 00003276 66BAC403 <1> mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 7219 <1> ;mov ax, 0100h 7220 <1> ; 02/08/2022 7221 0000327A 29C0 <1> sub eax, eax 7222 0000327C B401 <1> mov ah, 1 7223 <1> ; ax = 0100h 7224 0000327E 66EF <1> out dx, ax 7225 00003280 66B80203 <1> mov ax, 0302h 7226 00003284 66EF <1> out dx, ax 7227 00003286 66B80403 <1> mov ax, 0304h 7228 0000328A 66EF <1> out dx, ax 7229 0000328C 66B80003 <1> mov ax, 0300h 7230 00003290 66EF <1> out dx, ax 7231 <1> ;mov dx, 3CCh ; VGAREG_READ_MISC_OUTPUT 7232 <1> ; 02/08/2022 7233 00003292 B2CC <1> mov dl, 0CCh 7234 00003294 EC <1> in al, dx 7235 00003295 2401 <1> and al, 01h 7236 00003297 C0E002 <1> shl al, 2 7237 0000329A 0C0A <1> or al, 0Ah 7238 0000329C 88C4 <1> mov ah, al 7239 0000329E B006 <1> mov al, 06h 7240 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 7241 <1> ; 02/08/2022 7242 000032A0 B2CE <1> mov dl, 0CEh 7243 000032A2 66EF <1> out dx, ax 7244 000032A4 66B80400 <1> mov ax, 0004h 7245 000032A8 66EF <1> out dx, ax 7246 000032AA 66B80510 <1> mov ax, 1005h 7247 000032AE 66EF <1> out dx, ax 7248 000032B0 C3 <1> retn 7249 <1> 7250 <1> set_scan_lines: 7251 <1> ; 02/08/2022 7252 <1> ; 09/07/2016 7253 <1> ; 7254 <1> ; derived from 'Plex86/Bochs VGABios' source code 7255 <1> ; vgabios-0.7a (2011) 7256 <1> ; by the LGPL VGABios developers Team (2001-2008) 7257 <1> ; 'vgabios.c', 'set_scan_lines' 7258 <1> 7259 <1> ; set_scan_lines(lines) 7260 <1> ; BH = lines 7261 <1> 7262 <1> ; outb(crtc_addr, 0x09); 7263 000032B1 66BAD403 <1> mov dx, 3D4h ; CRTC_ADDRESS = 3D4h (always) 7264 000032B5 B009 <1> mov al, 09h 7265 000032B7 EE <1> out dx, al 7266 <1> ; crtc_r9 = inb(crtc_addr+1); 7267 <1> ;inc dx ; 3D5h 7268 <1> ; 02/08/2022 7269 000032B8 FEC2 <1> inc dl 7270 000032BA EC <1> in al, dx 7271 <1> ; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1); 7272 000032BB 24E0 <1> and al, 0E0h 7273 000032BD FECF <1> dec bh ; lines - 1 7274 000032BF 08F8 <1> or al, bh 7275 <1> ; outb(crtc_addr+1, crtc_r9); 7276 000032C1 EE <1> out dx, al 7277 <1> ;inc bh 7278 <1> ; if(lines==8) 7279 <1> ;cmp bh, 8 7280 000032C2 80FF07 <1> cmp bh, 7 7281 000032C5 7506 <1> jne short ssl_1 7282 <1> ; biosfn_set_cursor_shape(0x06,0x07); 7283 000032C7 66B90706 <1> mov cx, 0607h 7284 000032CB EB06 <1> jmp short ssl_2 7285 <1> ssl_1: 7286 <1> ; biosfn_set_cursor_shape(lines-4,lines-3); 7287 000032CD 88F9 <1> mov cl, bh ; lines - 1 7288 000032CF 88CD <1> mov ch, cl ; lines - 1 (16 -> 15) 7289 000032D1 FECD <1> dec ch ; lines - 2 (16 -> 14) 7290 <1> ssl_2: 7291 <1> ; CH = start line, CL = stop line 7292 000032D3 B40A <1> mov ah, 10 ; 6845 register for cursor set 7293 000032D5 66890D[F7670000] <1> mov [CURSOR_MODE], cx ; save in data area 7294 000032DC E877F0FFFF <1> call m16 ; output cx register 7295 <1> ; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines); 7296 000032E1 FEC7 <1> inc bh ; lines 7297 000032E3 883D[E2670000] <1> mov [CHAR_HEIGHT], bh 7298 <1> ; outb(crtc_addr, 0x12); 7299 000032E9 66BAD403 <1> mov dx, 3D4h ; CRTC_ADDRESS 7300 000032ED B012 <1> mov al, 12h 7301 000032EF EE <1> out dx, al 7302 <1> ; vde = inb(crtc_addr+1); 7303 <1> ;inc dx 7304 <1> ; 02/08/2022 7305 000032F0 FEC2 <1> inc dl 7306 000032F2 EC <1> in al, dx 7307 000032F3 88C4 <1> mov ah, al 7308 <1> ; outb(crtc_addr, 0x07); 7309 <1> ;dec dx 7310 <1> ; 02/08/2022 7311 000032F5 FECA <1> dec dl 7312 000032F7 B007 <1> mov al, 07h 7313 000032F9 EE <1> out dx, al 7314 <1> ; ovl = inb(crtc_addr+1); 7315 <1> ;inc dx 7316 <1> ; 02/08/2022 7317 000032FA FEC2 <1> inc dl 7318 000032FC EC <1> in al, dx 7319 <1> ; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1); 7320 000032FD 88E2 <1> mov dl, ah ; vde 7321 000032FF 88C6 <1> mov dh, al ; ovl 7322 <1> ;and ax, 02h 7323 <1> ;shl ax, 7 7324 <1> ; 02/08/2022 7325 00003301 31C0 <1> xor eax, eax 7326 00003303 88F0 <1> mov al, dh 7327 00003305 2402 <1> and al, 2 7328 00003307 C1E007 <1> shl eax, 7 7329 <1> ;mov cx, ax ; (ovl & 0x02) << 7) 7330 <1> ; 02/08/2022 7331 0000330A 89C1 <1> mov ecx, eax 7332 0000330C 28E4 <1> sub ah, ah 7333 0000330E 88F0 <1> mov al, dh ; ovl 7334 <1> ;and ax, 40h 7335 <1> ;shl ax, 3 ; (ovl & 0x40) << 3) 7336 <1> ;inc ax ; + 1 7337 <1> ;add ax, cx 7338 <1> ; 02/08/2022 7339 00003310 2440 <1> and al, 40h 7340 00003312 C1E003 <1> shl eax, 3 7341 00003315 40 <1> inc eax 7342 00003316 01C8 <1> add eax, ecx 7343 00003318 30F6 <1> xor dh, dh 7344 <1> ;add ax, dx ; + vde 7345 <1> ; 02/08/2022 7346 0000331A 01D0 <1> add eax, edx 7347 <1> ; rows = vde / lines; 7348 0000331C F6F7 <1> div bh 7349 <1> ;dec al ; rows -1 7350 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1); 7351 0000331E A2[E6670000] <1> mov [VGA_ROWS], al ; rows (not 'rows-1' !) 7352 <1> ; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2); 7353 <1> ;mov ah, [CRT_COLS] 7354 <1> ;mul ah 7355 <1> ; 17/11/2020 7356 00003323 F625[E0670000] <1> mul byte [CRT_COLS] 7357 <1> ;shl ax, 1 7358 <1> ; 02/08/2022 7359 00003329 D1E0 <1> shl eax, 1 7360 0000332B 66A3[54890100] <1> mov [CRT_LEN], ax 7361 00003331 C3 <1> retn 7362 <1> 7363 <1> load_text_8_14_pat: 7364 <1> ; 02/08/2022 (TRDOS 3386 v2.0.5) 7365 <1> ; 26/07/2016 7366 <1> ; 25/07/2016 7367 <1> ; 23/07/2016 7368 <1> ; 09/07/2016 7369 <1> ; load user defined (EGA/VGA) text fonts 7370 <1> ; 7371 <1> ; derived from 'Plex86/Bochs VGABios' source code 7372 <1> ; vgabios-0.7a (2011) 7373 <1> ; by the LGPL VGABios developers Team (2001-2008) 7374 <1> ; 'vgabios.c', 'biosfn_load_text_8_14_pat' 7375 <1> 7376 <1> ; biosfn_load_text_8_14_pat (AL,BL) 7377 <1> 7378 <1> ; get_font_access(); 7379 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7380 <1> ; for(i=0;i<0x100;i++) 7381 <1> ; { 7382 <1> ; src = i * 14; 7383 <1> ; dest = blockaddr + i * 32; 7384 <1> ; memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14); 7385 <1> ; } 7386 <1> ; release_font_access(); 7387 <1> ; if(AL>=0x10) 7388 <1> ; { 7389 <1> ; set_scan_lines(14); 7390 <1> ; } 7391 <1> 7392 00003332 50 <1> push eax 7393 00003333 E80BFFFFFF <1> call get_font_access 7394 <1> 7395 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7396 <1> ;mov dl, bl 7397 <1> ;and dl, 3 7398 <1> ;shl dx, 14 7399 <1> ;xchg dx, bx 7400 <1> ;and dl, 4 7401 <1> ;shl dx, 11 7402 <1> ;add dx, bx 7403 <1> 7404 <1> ;xor dx, dx ; blockaddr = 0 7405 <1> ; Always block 0 for TRDOS 386 ! (blockaddr=0) 7406 <1> 7407 00003338 28DB <1> sub bl, bl ; i = 0 7408 0000333A B70E <1> mov bh, 14 7409 0000333C BE[505B0100] <1> mov esi, vgafont14 7410 00003341 BF00000A00 <1> mov edi, 0A0000h 7411 <1> ; 02/08/2022 7412 00003346 29C9 <1> sub ecx, ecx 7413 <1> lt8_14_1: 7414 <1> ;mov al, bl 7415 <1> ;mul bh 7416 <1> ;movzx esi, ax 7417 <1> ;add esi, vgafont14 7418 <1> ;mov al, bl 7419 <1> ;sub ah, ah 7420 <1> ;shl ax, 5 ; * 32 7421 <1> ;;add ax, dx ; blockaddr + i * 32; 7422 <1> ;movzx edi, ax ; dest 7423 <1> ;add edi, 0A0000h 7424 <1> ;02/08/2022 7425 <1> ;movzx ecx, bh 7426 00003348 88F9 <1> mov cl, bh 7427 0000334A F3A4 <1> rep movsb 7428 0000334C 83C712 <1> add edi, 18 ; 32 - 14 7429 0000334F FEC3 <1> inc bl 7430 00003351 75F5 <1> jnz short lt8_14_1 7431 <1> ; 7432 00003353 E81EFFFFFF <1> call release_font_access 7433 <1> ; 7434 00003358 58 <1> pop eax 7435 <1> ; if(AL>=0x10) 7436 00003359 3C10 <1> cmp al, 10h 7437 0000335B 7205 <1> jb short lt8_14_4 7438 <1> ; BH = 14 7439 <1> ; set_scan_lines(14); 7440 0000335D E84FFFFFFF <1> call set_scan_lines 7441 <1> lt8_14_4: 7442 00003362 C3 <1> retn 7443 <1> 7444 <1> load_text_8_8_pat: 7445 <1> ; 02/08/2022 (TRDOS 3386 v2.0.5) 7446 <1> ; 05/01/2021 (TRDOS 386 v2.0.3) 7447 <1> ; 26/07/2016 7448 <1> ; 25/07/2016 7449 <1> ; 23/07/2016 7450 <1> ; 09/07/2016 7451 <1> ; load user defined (EGA/VGA) text fonts 7452 <1> ; 7453 <1> ; derived from 'Plex86/Bochs VGABios' source code 7454 <1> ; vgabios-0.7a (2011) 7455 <1> ; by the LGPL VGABios developers Team (2001-2008) 7456 <1> ; 'vgabios.c', 'biosfn_load_text_8_8_pat' 7457 <1> 7458 <1> ; biosfn_load_text_8_8_pat (AL,BL) 7459 <1> 7460 <1> ; get_font_access(); 7461 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7462 <1> ; for(i=0;i<0x100;i++) 7463 <1> ; { 7464 <1> ; src = i * 8; 7465 <1> ; dest = blockaddr + i * 32; 7466 <1> ; memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8); 7467 <1> ; } 7468 <1> ; release_font_access(); 7469 <1> ; if(AL>=0x10) 7470 <1> ; { 7471 <1> ; set_scan_lines(8); 7472 <1> ; } 7473 <1> 7474 00003363 50 <1> push eax 7475 00003364 E8DAFEFFFF <1> call get_font_access 7476 <1> 7477 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7478 <1> ;mov dl, bl 7479 <1> ;and dl, 3 7480 <1> ;shl dx, 14 7481 <1> ;xchg dx, bx 7482 <1> ;and dl, 4 7483 <1> ;shl dx, 11 7484 <1> ;add dx, bx 7485 <1> 7486 <1> ;xor dx, dx ; blockaddr = 0 7487 <1> ; Always block 0 for TRDOS 386 ! (blockaddr=0) 7488 <1> 7489 00003369 28DB <1> sub bl, bl ; i = 0 7490 0000336B B708 <1> mov bh, 8 7491 <1> ;mov esi, vgafont8 7492 0000336D BF00000A00 <1> mov edi, 0A0000h 7493 <1> 7494 <1> ; 02/08/2022 7495 00003372 29C9 <1> sub ecx, ecx 7496 <1> 7497 <1> ; 05/01/2021 7498 00003374 F605[8EA30100]80 <1> test byte [ufont], 80h 7499 0000337B 7410 <1> jz short lt8_8_0 7500 <1> ; user font permission (after set mode) 7501 0000337D F605[8EA30100]08 <1> test byte [ufont], 8 7502 00003384 7407 <1> jz short lt8_8_0 7503 00003386 BE00500900 <1> mov esi, VGAFONT8USER 7504 0000338B EB05 <1> jmp short lt8_8_1 7505 <1> lt8_8_0: 7506 0000338D BE[50530100] <1> mov esi, vgafont8 7507 <1> lt8_8_1: 7508 <1> ;mov al, bl 7509 <1> ;mul bh 7510 <1> ;movzx esi, ax 7511 <1> ;add esi, vgafont8 7512 <1> ;mov al, bl 7513 <1> ;sub ah, ah 7514 <1> ;shl ax, 5 ; * 32 7515 <1> ;;add ax, dx ; blockaddr + i * 32; 7516 <1> ;movzx edi, ax ; dest 7517 <1> ;add edi, 0A0000h 7518 <1> ; 02/08/2022 7519 <1> ;movzx ecx, bh 7520 00003392 88F9 <1> mov cl, bh 7521 00003394 F3A4 <1> rep movsb 7522 00003396 83C718 <1> add edi, 24 ; 32 - 8 7523 00003399 FEC3 <1> inc bl 7524 0000339B 75F5 <1> jnz short lt8_8_1 7525 <1> ; 7526 0000339D E8D4FEFFFF <1> call release_font_access 7527 <1> ; 7528 000033A2 58 <1> pop eax 7529 <1> ; if(AL>=0x10) 7530 000033A3 3C10 <1> cmp al, 10h 7531 000033A5 7205 <1> jb short lt8_8_2 7532 <1> ; BH = 8 7533 <1> ; set_scan_lines(8); 7534 000033A7 E805FFFFFF <1> call set_scan_lines 7535 <1> lt8_8_2: 7536 000033AC C3 <1> retn 7537 <1> 7538 <1> load_text_8_16_pat: 7539 <1> ; 02/08/2022 (TRDOS 3386 v2.0.5) 7540 <1> ; 05/01/2021 (TRDOS 386 v2.0.3) 7541 <1> ; 26/07/2016 7542 <1> ; 25/07/2016 7543 <1> ; 23/07/2016 7544 <1> ; 09/07/2016 7545 <1> ; load user defined (EGA/VGA) text fonts 7546 <1> ; 7547 <1> ; derived from 'Plex86/Bochs VGABios' source code 7548 <1> ; vgabios-0.7a (2011) 7549 <1> ; by the LGPL VGABios developers Team (2001-2008) 7550 <1> ; 'vgabios.c', 'biosfn_load_text_8_16_pat' 7551 <1> 7552 <1> ; biosfn_load_text_8_16_pat (AL,BL) 7553 <1> 7554 <1> ; get_font_access(); 7555 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7556 <1> ; for(i=0;i<0x100;i++) 7557 <1> ; { 7558 <1> ; src = i * 16; 7559 <1> ; dest = blockaddr + i * 32; 7560 <1> ; memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16); 7561 <1> ; } 7562 <1> ; release_font_access(); 7563 <1> ; if(AL>=0x10) 7564 <1> ; { 7565 <1> ; set_scan_lines(16); 7566 <1> ; } 7567 <1> 7568 000033AD 50 <1> push eax 7569 000033AE E890FEFFFF <1> call get_font_access 7570 <1> 7571 <1> ; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11); 7572 <1> ;mov dl, bl 7573 <1> ;and dl, 3 7574 <1> ;shl dx, 14 7575 <1> ;xchg dx, bx 7576 <1> ;and dl, 4 7577 <1> ;shl dx, 11 7578 <1> ;add dx, bx 7579 <1> 7580 <1> ;xor dx, dx ; blockaddr = 0 7581 <1> ; Always block 0 for TRDOS 386 ! (blockaddr=0) 7582 <1> 7583 000033B3 28DB <1> sub bl, bl ; i = 0 7584 000033B5 B710 <1> mov bh, 16 7585 <1> ;mov esi, vgafont16 7586 000033B7 BF00000A00 <1> mov edi, 0A0000h 7587 <1> ;movzx eax, bh 7588 <1> ; 02/08/2022 7589 000033BC 29C0 <1> sub eax, eax 7590 000033BE 88F8 <1> mov al, bh 7591 <1> 7592 <1> ; 05/01/2021 7593 000033C0 F605[8EA30100]80 <1> test byte [ufont], 80h 7594 000033C7 7410 <1> jz short lt8_16_0 7595 <1> ; user font permission (after set mode) 7596 000033C9 F605[8EA30100]10 <1> test byte [ufont], 16 7597 000033D0 7407 <1> jz short lt8_16_0 7598 000033D2 BE00400900 <1> mov esi, VGAFONT16USER 7599 000033D7 EB05 <1> jmp short lt8_16_1 7600 <1> lt8_16_0: 7601 000033D9 BE[50690100] <1> mov esi, vgafont16 7602 <1> lt8_16_1: 7603 <1> ;mov al, bl 7604 <1> ;mul bh 7605 <1> ;movzx esi, ax 7606 <1> ;add esi, vgafont16 7607 <1> ;mov al, bl ; i 7608 <1> ;sub ah, ah 7609 <1> ;shl ax, 5 ; * 32 7610 <1> ;;add ax, dx ; blockaddr + i * 32; 7611 <1> ;movzx edi, ax ; dest 7612 <1> ;add edi, 0A0000h 7613 <1> ;movzx ecx, bh 7614 000033DE 89C1 <1> mov ecx, eax ; 16 7615 000033E0 F3A4 <1> rep movsb 7616 000033E2 01C7 <1> add edi, eax ; add edi, 16 7617 000033E4 FEC3 <1> inc bl 7618 000033E6 75F6 <1> jnz short lt8_16_1 7619 <1> ; 7620 000033E8 E889FEFFFF <1> call release_font_access 7621 <1> ; 7622 000033ED 58 <1> pop eax 7623 <1> ; if(AL>=0x10) 7624 000033EE 3C10 <1> cmp al, 10h 7625 000033F0 7205 <1> jb short lt8_16_2 7626 <1> ; BH = 16 7627 <1> ; set_scan_lines(16); 7628 000033F2 E8BAFEFFFF <1> call set_scan_lines 7629 <1> lt8_16_2: 7630 000033F7 C3 <1> retn 7631 <1> 7632 <1> load_gfx_user_chars: 7633 <1> ; 08/01/2021 7634 <1> ; 05/01/2021 (TRDOS 386 v2.0.3) 7635 <1> ; 08/08/2016 7636 <1> ; 10/07/2016 7637 <1> ; Setup User-Defined Font for Graphics Mode (VGA) 7638 <1> ; 7639 <1> ; derived from 'Plex86/Bochs VGABios' source code 7640 <1> ; vgabios-0.7a (2011) 7641 <1> ; by the LGPL VGABios developers Team (2001-2008) 7642 <1> ; 'vgabios.c', 'biosfn_load_gfx_user_chars' 7643 <1> 7644 <1> ; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL) 7645 <1> ; /* set 0x43 INT pointer */ 7646 <1> ; write_word(0x0, 0x43*4, BP); 7647 <1> ; write_word(0x0, 0x43*4+2, ES); 7648 <1> 7649 <1> ; 08/01/2021 7650 <1> 7651 <1> ; BL screen rows code: 00H = user-specified (in DL) 7652 <1> ; 01H = 14 rows 7653 <1> ; 02H = 25 rows 7654 <1> ; 03H = 43 rows 7655 <1> ; CX bytes per character definition 7656 <1> ; DL (when BL=0) custom number of character rows on screen 7657 <1> ; EBP address of font-definition information (user's mem space) 7658 <1> 7659 <1> ; 05/01/2021 7660 <1> ;xor eax, eax 7661 <1> ;dec eax ; 0FFFFFFFFh (user defined fonts) 7662 <1> ;mov [VGA_INT43H], eax 7663 <1> 7664 <1> ; 08/01/2021 7665 <1> ; ebp = video font data (buffer) address 7666 000033F8 892D[66890100] <1> mov [VGA_INT43H], ebp 7667 <1> 7668 <1> ; switch (BL) { 7669 <1> ; case 0: 7670 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1); 7671 <1> ; break; 7672 000033FE 20DB <1> and bl, bl 7673 00003400 7508 <1> jnz short l_gfx_uc_1 7674 00003402 8815[E6670000] <1> mov [VGA_ROWS], dl ; not DL-1 ! 7675 00003408 EB23 <1> jmp short l_gfx_uc_4 7676 <1> l_gfx_uc_1: 7677 <1> ; case 1: 7678 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13); 7679 <1> ; break; 7680 0000340A FECB <1> dec bl 7681 0000340C 7509 <1> jnz short l_gfx_uc_2 7682 <1> ; bl = 1 7683 0000340E C605[E6670000]0E <1> mov byte [VGA_ROWS], 14 ; not 13 ! 7684 00003415 EB16 <1> jmp short l_gfx_uc_4 7685 <1> l_gfx_uc_2: 7686 00003417 FECB <1> dec bl 7687 00003419 740B <1> jz short l_gfx_uc_3 ; bl = 2 7688 0000341B FECB <1> dec bl 7689 0000341D 750E <1> jnz short l_gfx_uc_4 ; bl > 3 7690 <1> ; bl = 3 7691 <1> ; case 3: 7692 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42); 7693 <1> ; break; 7694 0000341F C605[E6670000]2B <1> mov byte [VGA_ROWS], 43 ; not 42 ! 7695 <1> l_gfx_uc_3: 7696 <1> ; case 2: 7697 <1> ; default: 7698 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24); 7699 <1> ; break; 7700 <1> ; bl = 2 or bl > 3 7701 00003426 C605[E6670000]19 <1> mov byte [VGA_ROWS], 25 ; not 24 ! 7702 <1> ; } 7703 <1> l_gfx_uc_4: 7704 <1> ; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX); 7705 0000342D 880D[E2670000] <1> mov [CHAR_HEIGHT], cl 7706 <1> ; } 7707 00003433 C3 <1> retn 7708 <1> 7709 <1> load_gfx_8_14_chars: 7710 <1> ; 08/08/2016 7711 <1> ; 10/07/2016 7712 <1> ; Setup ROM 8x14 Font for Graphics Mode (VGA) 7713 <1> ; 7714 <1> ; derived from 'Plex86/Bochs VGABios' source code 7715 <1> ; vgabios-0.7a (2011) 7716 <1> ; by the LGPL VGABios developers Team (2001-2008) 7717 <1> ; 'vgabios.c', 'biosfn_load_gfx_8_14_chars' 7718 <1> 7719 <1> ; biosfn_load_gfx_8_14_chars (BL) 7720 <1> ; /* set 0x43 INT pointer */ 7721 <1> ; write_word(0x0, 0x43*4, &vgafont14); 7722 <1> ; write_word(0x0, 0x43*4+2, 0xC000); 7723 00003434 C705[66890100]- <1> mov dword [VGA_INT43H], vgafont14 7723 0000343A [505B0100] <1> 7724 <1> 7725 <1> ; BL screen rows code: 00H = user-specified (in DL) 7726 <1> ; 01H = 14 rows 7727 <1> ; 02H = 25 rows 7728 <1> ; 03H = 43 rows 7729 <1> ; DL (when BL=0) custom number of char rows on screen 7730 <1> 7731 <1> ; switch (BL) { 7732 <1> ; case 0: 7733 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1); 7734 <1> ; break; 7735 0000343E 20DB <1> and bl, bl 7736 00003440 7508 <1> jnz short l_gfx_8_14c_1 7737 00003442 8815[E6670000] <1> mov [VGA_ROWS], dl ; not DL-1 ! 7738 00003448 EB23 <1> jmp short l_gfx_8_14c_4 7739 <1> l_gfx_8_14c_1: 7740 <1> ; case 1: 7741 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13); 7742 <1> ; break; 7743 0000344A FECB <1> dec bl 7744 0000344C 7509 <1> jnz short l_gfx_8_14c_2 7745 <1> ; bl = 1 7746 0000344E C605[E6670000]0E <1> mov byte [VGA_ROWS], 14 ; not 13 ! 7747 00003455 EB16 <1> jmp short l_gfx_8_14c_4 7748 <1> l_gfx_8_14c_2: 7749 00003457 FECB <1> dec bl 7750 00003459 740B <1> jz short l_gfx_8_14c_3 ; bl = 2 7751 0000345B FECB <1> dec bl 7752 0000345D 750E <1> jnz short l_gfx_8_14c_4 ; bl > 3 7753 <1> ; bl = 3 7754 <1> ; case 3: 7755 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42); 7756 <1> ; break; 7757 0000345F C605[E6670000]2B <1> mov byte [VGA_ROWS], 43 ; not 42 ! 7758 <1> l_gfx_8_14c_3: 7759 <1> ; case 2: 7760 <1> ; default: 7761 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24); 7762 <1> ; break; 7763 <1> ; bl = 2 or bl > 3 7764 00003466 C605[E6670000]19 <1> mov byte [VGA_ROWS], 25 ; not 24 ! 7765 <1> ; } 7766 <1> l_gfx_8_14c_4: 7767 <1> ; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14); 7768 0000346D C605[E2670000]0E <1> mov byte [CHAR_HEIGHT], 14 7769 <1> ; } 7770 00003474 C3 <1> retn 7771 <1> 7772 <1> load_gfx_8_8_chars: 7773 <1> ; 08/08/2016 7774 <1> ; 10/07/2016 7775 <1> ; Setup ROM 8x14 Font for Graphics Mode (VGA) 7776 <1> ; 7777 <1> ; derived from 'Plex86/Bochs VGABios' source code 7778 <1> ; vgabios-0.7a (2011) 7779 <1> ; by the LGPL VGABios developers Team (2001-2008) 7780 <1> ; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars' 7781 <1> 7782 <1> ; biosfn_load_gfx_8_8_dd_chars (BL) 7783 <1> ; /* set 0x43 INT pointer */ 7784 <1> ; write_word(0x0, 0x43*4, &vgafont8); 7785 <1> ; write_word(0x0, 0x43*4+2, 0xC000); 7786 00003475 C705[66890100]- <1> mov dword [VGA_INT43H], vgafont8 7786 0000347B [50530100] <1> 7787 <1> 7788 <1> ; BL screen rows code: 00H = user-specified (in DL) 7789 <1> ; 01H = 14 rows 7790 <1> ; 02H = 25 rows 7791 <1> ; 03H = 43 rows 7792 <1> ; DL (when BL=0) custom number of char rows on screen 7793 <1> 7794 <1> ; switch (BL) { 7795 <1> ; case 0: 7796 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1); 7797 <1> ; break; 7798 0000347F 20DB <1> and bl, bl 7799 00003481 7508 <1> jnz short l_gfx_8_8c_1 7800 00003483 8815[E6670000] <1> mov [VGA_ROWS], dl ; not DL-1 ! 7801 00003489 EB23 <1> jmp short l_gfx_8_8c_4 7802 <1> l_gfx_8_8c_1: 7803 <1> ; case 1: 7804 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13); 7805 <1> ; break; 7806 0000348B FECB <1> dec bl 7807 0000348D 7509 <1> jnz short l_gfx_8_8c_2 7808 <1> ; bl = 1 7809 0000348F C605[E6670000]0E <1> mov byte [VGA_ROWS], 14 ; not 13 ! 7810 00003496 EB16 <1> jmp short l_gfx_8_8c_4 7811 <1> l_gfx_8_8c_2: 7812 00003498 FECB <1> dec bl 7813 0000349A 740B <1> jz short l_gfx_8_8c_3 ; bl = 2 7814 0000349C FECB <1> dec bl 7815 0000349E 750E <1> jnz short l_gfx_8_8c_4 ; bl > 3 7816 <1> ; bl = 3 7817 <1> ; case 3: 7818 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42); 7819 <1> ; break; 7820 000034A0 C605[E6670000]2B <1> mov byte [VGA_ROWS], 43 ; not 42 ! 7821 <1> l_gfx_8_8c_3: 7822 <1> ; case 2: 7823 <1> ; default: 7824 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24); 7825 <1> ; break; 7826 <1> ; bl = 2 or bl > 3 7827 000034A7 C605[E6670000]19 <1> mov byte [VGA_ROWS], 25 ; not 24 ! 7828 <1> ; } 7829 <1> l_gfx_8_8c_4: 7830 <1> ; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8); 7831 000034AE C605[E2670000]08 <1> mov byte [CHAR_HEIGHT], 8 7832 <1> ; } 7833 000034B5 C3 <1> retn 7834 <1> 7835 <1> load_gfx_8_16_chars: 7836 <1> ; 08/08/2016 7837 <1> ; 10/07/2016 7838 <1> ; Setup ROM 8x14 Font for Graphics Mode (VGA) 7839 <1> ; 7840 <1> ; derived from 'Plex86/Bochs VGABios' source code 7841 <1> ; vgabios-0.7a (2011) 7842 <1> ; by the LGPL VGABios developers Team (2001-2008) 7843 <1> ; 'vgabios.c', 'biosfn_load_gfx_8_16_chars' 7844 <1> 7845 <1> ; biosfn_load_gfx_8_16_chars (BL) 7846 <1> ; /* set 0x43 INT pointer */ 7847 <1> ; write_word(0x0, 0x43*4, &vgafont16); 7848 <1> ; write_word(0x0, 0x43*4+2, 0xC000); 7849 000034B6 C705[66890100]- <1> mov dword [VGA_INT43H], vgafont16 7849 000034BC [50690100] <1> 7850 <1> 7851 <1> ; BL screen rows code: 00H = user-specified (in DL) 7852 <1> ; 01H = 14 rows 7853 <1> ; 02H = 25 rows 7854 <1> ; 03H = 43 rows 7855 <1> ; DL (when BL=0) custom number of char rows on screen 7856 <1> 7857 <1> ; switch (BL) { 7858 <1> ; case 0: 7859 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1); 7860 <1> ; break; 7861 000034C0 20DB <1> and bl, bl 7862 000034C2 7508 <1> jnz short l_gfx_8_16c_1 7863 000034C4 8815[E6670000] <1> mov [VGA_ROWS], dl ; not DL-1 ! 7864 000034CA EB23 <1> jmp short l_gfx_8_16c_4 7865 <1> l_gfx_8_16c_1: 7866 <1> ; case 1: 7867 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13); 7868 <1> ; break; 7869 000034CC FECB <1> dec bl 7870 000034CE 7509 <1> jnz short l_gfx_8_16c_2 7871 <1> ; bl = 1 7872 000034D0 C605[E6670000]0E <1> mov byte [VGA_ROWS], 14 ; not 13 ! 7873 000034D7 EB16 <1> jmp short l_gfx_8_16c_4 7874 <1> l_gfx_8_16c_2: 7875 000034D9 FECB <1> dec bl 7876 000034DB 740B <1> jz short l_gfx_8_16c_3 ; bl = 2 7877 000034DD FECB <1> dec bl 7878 000034DF 750E <1> jnz short l_gfx_8_16c_4 ; bl > 3 7879 <1> ; bl = 3 7880 <1> ; case 3: 7881 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42); 7882 <1> ; break; 7883 000034E1 C605[E6670000]2B <1> mov byte [VGA_ROWS], 43 ; not 42 ! 7884 <1> l_gfx_8_16c_3: 7885 <1> ; case 2: 7886 <1> ; default: 7887 <1> ; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24); 7888 <1> ; break; 7889 <1> ; bl = 2 or bl > 3 7890 000034E8 C605[E6670000]19 <1> mov byte [VGA_ROWS], 25 ; not 24 ! 7891 <1> ; } 7892 <1> l_gfx_8_16c_4: 7893 <1> ; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16); 7894 000034EF C605[E2670000]10 <1> mov byte [CHAR_HEIGHT], 16 7895 <1> ; } 7896 000034F6 C3 <1> retn 7897 <1> 7898 <1> get_font_info: 7899 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 7900 <1> ; 08/01/2021 (TRDOS 386 v2.0.3) 7901 <1> ; 19/09/2016 7902 <1> ; 08/08/2016 7903 <1> ; 10/07/2016 7904 <1> ; Get Current Character Generator Info (VGA) 7905 <1> ; 7906 <1> ; derived from 'Plex86/Bochs VGABios' source code 7907 <1> ; vgabios-0.7a (2011) 7908 <1> ; by the LGPL VGABios developers Team (2001-2008) 7909 <1> ; 'vgabios.c', 'biosfn_get_font_info' 7910 <1> 7911 <1> ; Modified for TRDOS 386 ! 7912 <1> ; 7913 <1> ; INPUT -> 7914 <1> ; AX = 1130h 7915 <1> ; BL = 0 -> Get info for current VGA font 7916 <1> ; (BH = unused) 7917 <1> ; 19/09/2016 7918 <1> ; BL > 0 -> Get requested character font data 7919 <1> ; BL = 1 -> vgafont8 7920 <1> ; BL = 2 -> vgafont14 7921 <1> ; BL = 3 -> vgafont16 7922 <1> ; ;08/01/2021 7923 <1> ; BL = 4 -> user defined 8x8 font 7924 <1> ; BL = 5 -> user defined 8x14 font 7925 <1> ; BL = 6 -> user defined 8x16 font 7926 <1> ; BL > 6 -> Invalid function (for now!) 7927 <1> ; BH = ASCII code of the first character 7928 <1> ; ECX = Number of characters from the 1st char 7929 <1> ; ECX >= 256 -> All (256-BH) characters 7930 <1> ; ECX = 0 -> All characters (BH = unused) 7931 <1> ; EDX = User's Buffer Address 7932 <1> ; OUTPUT -> 7933 <1> ; AL = height (scanlines), bytes per character 7934 <1> ; AH = screen rows 7935 <1> ; Byte 16-23 of EAX = number of columns 7936 <1> ; Byte 24-31 of EAX = 7937 <1> ; 0 -> default font (not configured yet) 7938 <1> ; 0FFh -> user defined font 7939 <1> ; 14 = vgafont14 7940 <1> ; 8 = vgafont8 7941 <1> ; 16 = vgafont16 7942 <1> ; If BL input > 0 -> 7943 <1> ; EAX = Actual transfer count 7944 <1> ; 7945 000034F7 20DB <1> and bl, bl 7946 000034F9 740F <1> jz short gfi_1 7947 <1> ; invalid function (input) 7948 <1> ; 08/01/2021 7949 000034FB 80FB04 <1> cmp bl, 4 7950 000034FE 7263 <1> jb short gfi_5 7951 00003500 7441 <1> je short gfi_3 7952 00003502 80FB06 <1> cmp bl, 6 7953 00003505 744C <1> je short gfi_4 7954 <1> ; bh = 5 or bh > 6 7955 <1> gfi_0: 7956 00003507 31C0 <1> xor eax, eax ; 0 7957 00003509 C3 <1> retn 7958 <1> gfi_1: 7959 0000350A A0[E2670000] <1> mov al, [CHAR_HEIGHT] 7960 0000350F 8A25[E6670000] <1> mov ah, [VGA_ROWS] 7961 00003515 C1E010 <1> shl eax, 16 7962 00003518 A0[E0670000] <1> mov al, [CRT_COLS] 7963 0000351D 8B0D[66890100] <1> mov ecx, [VGA_INT43H] 7964 00003523 21C9 <1> and ecx, ecx 7965 00003525 7418 <1> jz short gfi_2 ; 0 = default font 7966 <1> ; 08/01/2021 7967 00003527 FECC <1> dec ah ; 0FFh 7968 00003529 81F900400900 <1> cmp ecx, VGAFONT16USER 7969 0000352F 740E <1> je short gfi_2 7970 00003531 81F900500900 <1> cmp ecx, VGAFONT8USER 7971 00003537 7406 <1> je short gfi_2 7972 00003539 8A25[E2670000] <1> mov ah, [CHAR_HEIGHT] ; font size = height 7973 <1> gfi_2: 7974 0000353F C1C010 <1> rol eax, 16 7975 00003542 C3 <1> retn 7976 <1> gfi_3: 7977 <1> ; 08/01/2021 7978 00003543 F605[8EA30100]08 <1> test byte [ufont], 08h ; 8x8 user font 7979 0000354A 74BB <1> jz short gfi_0 ; not loaded ! 7980 0000354C BE00500900 <1> mov esi, VGAFONT8USER ; * 7981 <1> ;mov bl, 8 7982 <1> ;jmp short gfi_8 7983 00003551 EB4A <1> jmp short gfi_10 7984 <1> gfi_4: 7985 <1> ; 08/01/2021 7986 00003553 F605[8EA30100]10 <1> test byte [ufont], 10h ; 8x16 user font 7987 0000355A 74AB <1> jz short gfi_0 ; not loaded ! 7988 0000355C BE00400900 <1> mov esi, VGAFONT16USER ; * 7989 00003561 EB15 <1> jmp short gfi_7 7990 <1> gfi_5: 7991 00003563 80FB02 <1> cmp bl, 2 7992 00003566 7230 <1> jb short gfi_9 7993 00003568 7709 <1> ja short gfi_6 7994 <1> ; BL = 2 -> vgafont14 7995 0000356A BE[505B0100] <1> mov esi, vgafont14 ; * 7996 0000356F B30E <1> mov bl, 14 7997 00003571 EB07 <1> jmp short gfi_8 7998 <1> gfi_6: 7999 <1> ; BL = 3 -> vgafont16 8000 00003573 BE[50690100] <1> mov esi, vgafont16 ; * 8001 <1> gfi_7: 8002 00003578 B310 <1> mov bl, 16 8003 <1> gfi_8: 8004 0000357A 89D7 <1> mov edi, edx ; ** 8005 0000357C 09C9 <1> or ecx, ecx 8006 0000357E 7421 <1> jz short gfi_11 ; all chars from the 00h 8007 <1> ;mov al, bh ; character index 8008 <1> ; 03/08/2022 8009 00003580 0FB6C7 <1> movzx eax, bh 8010 00003583 F6E3 <1> mul bl ; char index * char height/size 8011 <1> ;movzx edx, ax 8012 <1> ; 03/08/2022 8013 <1> ;add esi, edx ; * 8014 00003585 01C6 <1> add esi, eax 8015 00003587 31D2 <1> xor edx, edx 8016 00003589 FECA <1> dec dl 8017 <1> ; edx = 0FFh = 255 8018 <1> ;mov dx, 255 8019 0000358B 28FA <1> sub dl, bh 8020 <1> ;inc dx 8021 <1> ; 03/08/2022 8022 0000358D 42 <1> inc edx 8023 0000358E 39D1 <1> cmp ecx, edx 8024 00003590 770F <1> ja short gfi_11 8025 00003592 7411 <1> je short gfi_12 8026 00003594 89D1 <1> mov ecx, edx 8027 00003596 EB0D <1> jmp short gfi_12 8028 <1> gfi_9: 8029 <1> ;BL = 1 -> vgafont8 8030 00003598 BE[50530100] <1> mov esi, vgafont8 ; * 8031 <1> gfi_10: 8032 0000359D B308 <1> mov bl, 8 8033 0000359F EBD9 <1> jmp short gfi_8 8034 <1> gfi_11: 8035 <1> ;mov ecx, 256 8036 <1> ; 03/08/2022 8037 000035A1 29C9 <1> sub ecx, ecx 8038 000035A3 FEC5 <1> inc ch 8039 <1> ; ecx = 100h 8040 <1> gfi_12: 8041 <1> ; 08/01/2021 8042 000035A5 89C8 <1> mov eax, ecx ; character count 8043 000035A7 30FF <1> xor bh, bh 8044 000035A9 66F7E3 <1> mul bx ; char count * char height/size 8045 000035AC 89C1 <1> mov ecx, eax 8046 <1> 8047 <1> ; ESI = source address in system space 8048 <1> ; EDI = user's buffer address 8049 <1> ; ECX = transfer (byte) count 8050 000035AE E8DDD90000 <1> call transfer_to_user_buffer 8051 000035B3 89C8 <1> mov eax, ecx ; actual transfer count 8052 000035B5 C3 <1> retn 8053 <1> 8054 <1> set_all_palette_reg: 8055 <1> ; 03/08/2022 8056 <1> ; 10/08/2016 8057 <1> ; Set All Palette Registers and Overscan 8058 <1> ; EDX = Address of 17 bytes; 8059 <1> ; an rgbRGB value for each of 16 palette 8060 <1> ; registers plus one for the border. 8061 <1> 8062 000035B6 89D6 <1> mov esi, edx ; user buffer 8063 <1> ;mov ecx, 17 8064 <1> ; 03/08/2022 8065 000035B8 29C9 <1> sub ecx, ecx 8066 000035BA B111 <1> mov cl, 17 8067 000035BC 89E7 <1> mov edi, esp 8068 000035BE 83EC14 <1> sub esp, 20 8069 000035C1 E814DA0000 <1> call transfer_from_user_buffer 8070 <1> ;jc VIDEO_RETURN 8071 <1> 8072 000035C6 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8073 000035CA EC <1> in al, dx 8074 <1> ;mov cl, 0 8075 <1> ; 03/08/2022 8076 000035CB 28C9 <1> sub cl, cl 8077 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8078 <1> ; 03/08/2022 8079 000035CD B2C0 <1> mov dl, 0C0h 8080 <1> set_palette_loop: 8081 000035CF 88C8 <1> mov al, cl 8082 000035D1 EE <1> out dx, al 8083 000035D2 8A07 <1> mov al, [edi] 8084 000035D4 EE <1> out dx, al 8085 000035D5 47 <1> inc edi 8086 000035D6 FEC1 <1> inc cl 8087 000035D8 80F910 <1> cmp cl, 10h 8088 000035DB 75F2 <1> jne short set_palette_loop 8089 000035DD B011 <1> mov al, 11h 8090 000035DF EE <1> out dx, al 8091 000035E0 8A07 <1> mov al, [edi] 8092 000035E2 EE <1> out dx, al 8093 000035E3 B020 <1> mov al, 20h 8094 000035E5 EE <1> out dx, al 8095 <1> ; ifdef VBOX 8096 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8097 <1> ; 03/08/2022 8098 000035E6 B2DA <1> mov dl, 0DAh 8099 000035E8 EC <1> in al, dx 8100 <1> ; endif ; VBOX 8101 000035E9 83C414 <1> add esp, 20 8102 000035EC E941E5FFFF <1> jmp VIDEO_RETURN 8103 <1> 8104 <1> ; 07/08/2022 8105 <1> toggle_intensity: 8106 <1> ; 03/08/2022 8107 <1> ; 10/08/2016 8108 <1> ; Select Foreground Blink or Bold Background 8109 <1> ; BL = 00h = enable bold backgrounds 8110 <1> ; (16 background colors) 8111 <1> ; 01h = enable blinking foreground 8112 <1> ; (8 background colors) 8113 <1> 8114 000035F1 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8115 000035F5 EC <1> in al, dx 8116 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8117 <1> ; 03/08/2022 8118 000035F6 B2C0 <1> mov dl, 0C0h 8119 000035F8 B010 <1> mov al, 10h 8120 000035FA EE <1> out dx, al 8121 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8122 <1> ; 03/08/2022 8123 000035FB FEC2 <1> inc dl ; dx = 3C1h 8124 000035FD EC <1> in al, dx 8125 000035FE 24F7 <1> and al, 0F7h 8126 00003600 80E301 <1> and bl, 01h 8127 00003603 C0E303 <1> shl bl, 3 8128 00003606 08D8 <1> or al, bl 8129 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8130 <1> ; 03/08/2022 8131 00003608 FECA <1> dec dl ; dx = 3C0h 8132 0000360A EE <1> out dx, al 8133 0000360B B020 <1> mov al, 20h 8134 0000360D EE <1> out dx, al 8135 <1> ; ifdef VBOX 8136 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8137 <1> ; 03/08/2022 8138 0000360E B2DA <1> mov dl, 0DAh 8139 00003610 EC <1> in al, dx 8140 <1> ; endif ; VBOX 8141 00003611 E91CE5FFFF <1> jmp VIDEO_RETURN 8142 <1> 8143 <1> ; 07/08/2022 8144 <1> vga_palf_unknown: 8145 00003616 29C0 <1> sub eax, eax ; 0 = invalid function 8146 00003618 E91AE5FFFF <1> jmp _video_return 8147 <1> 8148 <1> ; 07/08/2022 8149 <1> vga_palf_101B: 8150 0000361D 3C1B <1> cmp al, 1Bh 8151 <1> ;jne short vga_palf_unknown 8152 0000361F 77F5 <1> ja short vga_palf_unknown 8153 <1> 8154 00003621 E810F6FFFF <1> call gray_scale_summing 8155 00003626 E907E5FFFF <1> jmp VIDEO_RETURN 8156 <1> 8157 <1> vga_pal_funcs: 8158 <1> ; 07/08/2022 8159 <1> ; 10/08/2016 8160 <1> ; VGA Palette functions 8161 <1> ; 8162 <1> ; derived from 'Plex86/Bochs VGABios' source code 8163 <1> ; vgabios-0.7a (2011) 8164 <1> ; by the LGPL VGABios developers Team (2001-2008) 8165 <1> ; 'vgabios.c', 'vgarom.asm' 8166 <1> 8167 0000362B 3C00 <1> cmp al, 0 8168 0000362D 7467 <1> je short set_single_palette_reg 8169 <1> vga_palf_1002: 8170 0000362F 3C02 <1> cmp al, 2 8171 00003631 7483 <1> je short set_all_palette_reg 8172 <1> ; 07/08/2022 8173 00003633 7702 <1> ja short vga_palf_1003 8174 00003635 EB5D <1> jmp short set_overscan_border_color 8175 <1> ; 07/08/2022 8176 <1> ;vga_palf_1001: 8177 <1> ; cmp al, 1 8178 <1> ; je short set_overscan_border_color 8179 <1> vga_palf_1003: 8180 00003637 3C03 <1> cmp al, 3 8181 00003639 74B6 <1> je short toggle_intensity 8182 <1> vga_palf_1007: 8183 0000363B 3C07 <1> cmp al, 7 8184 0000363D 747F <1> je short get_single_palette_reg 8185 0000363F 72D5 <1> jb short vga_palf_unknown 8186 <1> vga_palf_1008: 8187 00003641 3C08 <1> cmp al, 8 8188 00003643 7477 <1> je short read_overscan_border_color 8189 <1> vga_palf_1009: 8190 00003645 3C09 <1> cmp al, 9 8191 <1> ;je short get_all_palette_reg 8192 <1> ; 07/08/2022 8193 00003647 7505 <1> jne short vga_palf_1010 8194 00003649 E966010000 <1> jmp get_all_palette_reg 8195 <1> vga_palf_1010: 8196 0000364E 3C10 <1> cmp al, 10h 8197 <1> ;je short set_single_dac_reg 8198 <1> ; 07/08/2022 8199 00003650 7707 <1> ja short vga_palf_1012 8200 00003652 72C2 <1> jb short vga_palf_unknown 8201 00003654 E908010000 <1> jmp set_single_dac_reg 8202 <1> vga_palf_1012: 8203 00003659 3C12 <1> cmp al, 12h 8204 <1> ;je short set_all_dac_reg 8205 <1> ; 07/08/2022 8206 0000365B 7707 <1> ja short vga_palf_1013 8207 0000365D 72B7 <1> jb short vga_palf_unknown 8208 0000365F E916010000 <1> jmp set_all_dac_reg 8209 <1> vga_palf_1013: 8210 00003664 3C13 <1> cmp al, 13h 8211 <1> ;je short select_video_dac_color_page 8212 <1> ; 07/08/2022 8213 00003666 7505 <1> jne short vga_palf_1015 8214 00003668 E992010000 <1> jmp select_video_dac_color_page 8215 <1> vga_palf_1015: 8216 0000366D 3C15 <1> cmp al, 15h 8217 <1> ;je short read_single_dac_reg 8218 <1> ; 07/08/2022 8219 0000366F 7707 <1> ja short vga_palf_1017 8220 00003671 72A3 <1> jb short vga_palf_unknown 8221 00003673 E98D000000 <1> jmp read_single_dac_reg 8222 <1> vga_palf_1017: 8223 00003678 3C17 <1> cmp al, 17h 8224 <1> ;je short read_all_dac_reg 8225 <1> ; 07/08/2022 8226 0000367A 7707 <1> ja short vga_palf_1018 8227 0000367C 7298 <1> jb short vga_palf_unknown 8228 0000367E E9A0000000 <1> jmp read_all_dac_reg 8229 <1> vga_palf_1018: 8230 00003683 3C18 <1> cmp al, 18h 8231 00003685 7464 <1> je short set_pel_mask 8232 <1> vga_palf_1019: 8233 00003687 3C19 <1> cmp al, 19h 8234 00003689 746C <1> je short read_pel_mask 8235 <1> vga_palf_101A: 8236 0000368B 3C1A <1> cmp al, 1Ah 8237 <1> ;je short read_video_dac_state 8238 <1> ; 07/08/2022 8239 0000368D 758E <1> jne short vga_palf_101B 8240 0000368F E9AD010000 <1> jmp read_video_dac_state 8241 <1> 8242 <1> ; 07/08/2022 8243 <1> set_overscan_border_color: 8244 <1> ; 10/08/2016 8245 <1> ; Set Overscan/Border Color Register 8246 <1> ; BH = 6-bit RGB color to display 8247 <1> ; for that attribute 8248 <1> 8249 00003694 B311 <1> mov bl, 11h 8250 <1> ; 07/08/2022 8251 <1> ;jmp short set_single_palette_reg 8252 <1> 8253 <1> set_single_palette_reg: 8254 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 8255 <1> ; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop) 8256 <1> ; 10/08/2016 8257 <1> ; Set One Palette Register 8258 <1> ; BL = register number to set 8259 <1> ; (a 4-bit attribute nibble: 00h-0Fh) 8260 <1> ; BH = 6-bit RGB color to display 8261 <1> ; for that attribute 8262 <1> 8263 00003696 80FB14 <1> cmp bl, 14h 8264 <1> ;;ja short no_actl_reg1 8265 <1> ;ja VIDEO_RETURN 8266 <1> ; 03/08/2022 8267 00003699 7605 <1> jna short sspr_1 8268 0000369B E992E4FFFF <1> jmp VIDEO_RETURN 8269 <1> sspr_1: 8270 <1> ;push ax 8271 <1> ;push dx 8272 <1> ; 12/04/2021 8273 000036A0 50 <1> push eax 8274 000036A1 52 <1> push edx 8275 000036A2 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8276 000036A6 EC <1> in al, dx 8277 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8278 <1> ; 03/08/2022 8279 000036A7 B2C0 <1> mov dl, 0C0h 8280 000036A9 88D8 <1> mov al, bl 8281 000036AB EE <1> out dx, al 8282 000036AC 88F8 <1> mov al, bh 8283 000036AE EE <1> out dx, al 8284 000036AF B020 <1> mov al, 20h 8285 000036B1 EE <1> out dx, al 8286 <1> ; ifdef VBOX 8287 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8288 <1> ; 03/08/2022 8289 000036B2 B2DA <1> mov dl, 0DAh 8290 000036B4 EC <1> in al, dx 8291 <1> ; endif ; VBOX 8292 <1> ;pop dx 8293 <1> ;pop ax 8294 <1> ; 12/04/2021 8295 000036B5 5A <1> pop edx 8296 000036B6 58 <1> pop eax 8297 <1> ;no_actl_reg1: 8298 000036B7 E976E4FFFF <1> jmp VIDEO_RETURN 8299 <1> 8300 <1> ; 07/08/2022 8301 <1> read_overscan_border_color: 8302 <1> ; 10/08/2016 8303 <1> ; Read Overscan Register 8304 <1> ; OUTPUT: 8305 <1> ; BH = current rgbRGB value 8306 <1> ; of the overscan/border register 8307 <1> 8308 000036BC B311 <1> mov bl, 11h 8309 <1> ; 07/08/2022 8310 <1> ;jmp short get_single_palette_reg 8311 <1> 8312 <1> get_single_palette_reg: 8313 <1> ; 03/08/2022 8314 <1> ; 10/08/2016 8315 <1> ; Read One Palette Register 8316 <1> ; INPUT: 8317 <1> ; BL = Palette register to read (00h-0Fh) 8318 <1> ; OUTPUT: 8319 <1> ; BH = Current rgbRGB value of specified register 8320 <1> ; for that attribute 8321 <1> 8322 000036BE 80FB14 <1> cmp bl, 14h 8323 <1> ;;ja short no_actl_reg2 8324 <1> ;ja VIDEO_RETURN 8325 <1> ; 03/08/2022 8326 000036C1 7605 <1> jna short gspr_1 8327 000036C3 E96AE4FFFF <1> jmp VIDEO_RETURN 8328 <1> gspr_1: 8329 000036C8 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8330 <1> ; 03/08/2022 8331 000036CC B2DA <1> mov dl, 0DAh 8332 000036CE EC <1> in al, dx 8333 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8334 <1> ; 03/08/2022 8335 000036CF B2C0 <1> mov dl, 0C0h 8336 000036D1 88D8 <1> mov al, bl 8337 000036D3 EE <1> out dx, al 8338 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8339 <1> ; 03/08/2022 8340 000036D4 FEC2 <1> inc dl ; dx = 3C1h 8341 000036D6 EC <1> in al, dx 8342 000036D7 8844240D <1> mov [esp+13], al ; bh 8343 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8344 <1> ; 03/08/2022 8345 000036DB B2DA <1> mov dl, 0DAh 8346 000036DD EC <1> in al, dx 8347 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8348 <1> ; 03/08/2022 8349 000036DE B2C0 <1> mov dl, 0C0h 8350 000036E0 B020 <1> mov al, 20h 8351 000036E2 EE <1> out dx, al 8352 <1> ; ifdef VBOX 8353 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8354 <1> ; 03/08/2022 8355 000036E3 B2DA <1> mov dl, 0DAh 8356 000036E5 EC <1> in al, dx 8357 <1> ; endif ; VBOX 8358 000036E6 E947E4FFFF <1> jmp VIDEO_RETURN 8359 <1> 8360 <1> set_pel_mask: 8361 <1> ; 10/08/2016 8362 <1> ; BL = mask value 8363 000036EB 66BAC603 <1> mov dx, 3C6h ; VGAREG_PEL_MASK 8364 000036EF 88D8 <1> mov al, bl 8365 000036F1 EE <1> out dx, al 8366 000036F2 E93BE4FFFF <1> jmp VIDEO_RETURN 8367 <1> 8368 <1> read_pel_mask: 8369 <1> ; 10/08/2016 8370 <1> ; Output: BL = mask value 8371 000036F7 66BAC603 <1> mov dx, 3C6h ; VGAREG_PEL_MASK 8372 000036FB EC <1> in al, dx 8373 000036FC 8844240C <1> mov [esp+12], al ; bl 8374 00003700 E92DE4FFFF <1> jmp VIDEO_RETURN 8375 <1> 8376 <1> read_single_dac_reg: 8377 <1> ; 02/08/2022 8378 <1> ; 10/08/2016 8379 <1> ; Read One DAC Color Register 8380 <1> ; INPUT: 8381 <1> ; BX = color register to read (0-255) 8382 <1> ; OUTPUT: 8383 <1> ; CH = green value (00h-3Fh) 8384 <1> ; CL = blue value (00h-3Fh) 8385 <1> ; DH = red value (00h-3Fh) 8386 <1> 8387 00003705 66BAC703 <1> mov dx, 3C7h ; VGAREG_DAC_READ_ADDRESS 8388 00003709 88D8 <1> mov al, bl 8389 0000370B EE <1> out dx, al 8390 <1> ;mov dx, 3C9h ; VGAREG_DAC_DATA 8391 <1> ; 02/08/2022 8392 0000370C B2C9 <1> mov dl, 0C9h 8393 0000370E EC <1> in al, dx 8394 0000370F 88442415 <1> mov [esp+21], al ; dh 8395 00003713 EC <1> in al, dx 8396 00003714 88C5 <1> mov ch, al 8397 00003716 EC <1> in al, dx 8398 00003717 88C1 <1> mov cl, al 8399 00003719 66894C2410 <1> mov [esp+16], cx ; cx 8400 0000371E E90FE4FFFF <1> jmp VIDEO_RETURN 8401 <1> 8402 <1> read_all_dac_reg: 8403 <1> ; 02/08/2022 8404 <1> ; 12/08/2016 8405 <1> ; 11/08/2016 8406 <1> ; 10/08/2016 8407 <1> ; Read a Block of DAC Color Registers 8408 <1> ; BX = first DAC register to read (0-00FFh) 8409 <1> ; ECX = number of registers to read (0-00FFh) 8410 <1> ; EDX = addr of a buffer to hold R,G,B values 8411 <1> ; (CX*3 bytes long) 8412 <1> 8413 00003723 89D7 <1> mov edi, edx ; user buffer 8414 00003725 89CA <1> mov edx, ecx 8415 <1> ;shl dx, 1 ; *2 8416 <1> ; 02/08/2022 8417 00003727 D1E2 <1> shl edx, 1 8418 00003729 01CA <1> add edx, ecx ; edx = 3*ecx 8419 0000372B 89E5 <1> mov ebp, esp 8420 0000372D 89EE <1> mov esi, ebp 8421 0000372F 29D6 <1> sub esi, edx 8422 00003731 6683E6FC <1> and si, 0FFFCh ; (dword alignment) 8423 00003735 89F4 <1> mov esp, esi 8424 00003737 52 <1> push edx ; 3*ecx 8425 00003738 66BAC703 <1> mov dx, 3C7h ; VGAREG_DAC_READ_ADDRESS 8426 0000373C 88D8 <1> mov al, bl 8427 0000373E EE <1> out dx, al 8428 0000373F 66BAC903 <1> mov dx, 3C9h ; VGAREG_DAC_DATA 8429 00003743 89F3 <1> mov ebx, esi 8430 <1> read_dac_loop: 8431 00003745 EC <1> in al, dx 8432 00003746 8803 <1> mov [ebx], al 8433 00003748 43 <1> inc ebx 8434 00003749 EC <1> in al, dx 8435 0000374A 8803 <1> mov [ebx], al 8436 0000374C 43 <1> inc ebx 8437 0000374D EC <1> in al, dx 8438 0000374E 8803 <1> mov [ebx], al 8439 00003750 43 <1> inc ebx 8440 <1> ;dec cx 8441 <1> ; 02/08/2022 8442 00003751 49 <1> dec ecx 8443 00003752 75F1 <1> jnz short read_dac_loop 8444 00003754 59 <1> pop ecx ; 3*ecx 8445 <1> ; ECX = transfer (byte) count 8446 <1> ; ESI = source address in system space 8447 <1> ; EDI = user's buffer address 8448 00003755 E836D80000 <1> call transfer_to_user_buffer 8449 0000375A 89EC <1> mov esp, ebp 8450 0000375C E9D1E3FFFF <1> jmp VIDEO_RETURN 8451 <1> 8452 <1> set_single_dac_reg: 8453 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 8454 <1> ; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop) 8455 <1> ; 10/08/2016 8456 <1> ; Set One DAC Color Register 8457 <1> ; BX = color register to set (0-255) 8458 <1> ; CH = green value (00h-3Fh) 8459 <1> ; CL = blue value (00h-3Fh) 8460 <1> ; DH = red value (00h-3Fh) 8461 <1> 8462 <1> ;push dx 8463 <1> ; 12/04/2021 8464 00003761 52 <1> push edx 8465 00003762 66BAC803 <1> mov dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS 8466 00003766 88D8 <1> mov al, bl 8467 00003768 EE <1> out dx, al 8468 <1> ;;mov dx, 3C9h ; VGAREG_DAC_DATA 8469 <1> ;inc dx 8470 <1> ; 03/08/2022 8471 00003769 FEC2 <1> inc dl 8472 <1> ;pop ax 8473 <1> ; 12/04/2021 8474 0000376B 58 <1> pop eax 8475 0000376C 88E0 <1> mov al, ah 8476 0000376E EE <1> out dx, al 8477 0000376F 88E8 <1> mov al, ch 8478 00003771 EE <1> out dx, al 8479 00003772 88C8 <1> mov al, cl 8480 00003774 EE <1> out dx, al 8481 00003775 E9B8E3FFFF <1> jmp VIDEO_RETURN 8482 <1> 8483 <1> set_all_dac_reg: 8484 <1> ; 02/08/2022 8485 <1> ; 12/08/2016 8486 <1> ; 11/08/2016 8487 <1> ; 10/08/2016 8488 <1> ; Set a Block of DAC Color Register 8489 <1> ; BX = first DAC register to set (0-00FFh) 8490 <1> ; ECX = number of registers to set (0-00FFh) 8491 <1> ; EDX = addr of a table of R,G,B values 8492 <1> ; (it will be CX*3 bytes long) 8493 <1> 8494 0000377A 89D6 <1> mov esi, edx ; user buffer 8495 0000377C 89CA <1> mov edx, ecx 8496 <1> ;shl cx, 1 ; *2 8497 <1> ; 02/08/2022 8498 0000377E D1E1 <1> shl ecx, 1 8499 00003780 01D1 <1> add ecx, edx ; ecx = 3*ecx 8500 00003782 89E5 <1> mov ebp, esp 8501 00003784 89EF <1> mov edi, ebp 8502 00003786 29CF <1> sub edi, ecx 8503 00003788 6683E7FC <1> and di, 0FFFCh ; (dword alignment) 8504 0000378C 89FC <1> mov esp, edi 8505 0000378E E847D80000 <1> call transfer_from_user_buffer 8506 <1> ;jc VIDEO_RETURN 8507 <1> 8508 00003793 89D1 <1> mov ecx, edx 8509 00003795 66BAC803 <1> mov dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS 8510 00003799 88D8 <1> mov al, bl 8511 0000379B EE <1> out dx, al 8512 <1> ;mov dx, 3C9h ; VGAREG_DAC_DATA 8513 <1> ; 02/08/2022 8514 0000379C FEC2 <1> inc dl 8515 <1> set_dac_loop: 8516 0000379E 8A07 <1> mov al, [edi] 8517 000037A0 EE <1> out dx, al 8518 000037A1 47 <1> inc edi 8519 000037A2 8A07 <1> mov al, [edi] 8520 000037A4 EE <1> out dx, al 8521 000037A5 47 <1> inc edi 8522 000037A6 8A07 <1> mov al, [edi] 8523 000037A8 EE <1> out dx, al 8524 000037A9 47 <1> inc edi 8525 <1> ;dec cx 8526 <1> ; 02/08/2022 8527 000037AA 49 <1> dec ecx 8528 000037AB 75F1 <1> jnz short set_dac_loop 8529 000037AD 89EC <1> mov esp, ebp 8530 000037AF E97EE3FFFF <1> jmp VIDEO_RETURN 8531 <1> 8532 <1> get_all_palette_reg: 8533 <1> ; 03/08/2022 8534 <1> ; 10/08/2016 8535 <1> ; Read All Palette Registers 8536 <1> ; EDX = Address of 17-byte buffer 8537 <1> ; to receive data 8538 <1> 8539 000037B4 89D7 <1> mov edi, edx 8540 000037B6 89E3 <1> mov ebx, esp 8541 000037B8 89DE <1> mov esi, ebx 8542 000037BA 83EC14 <1> sub esp, 20 8543 <1> 8544 000037BD B100 <1> mov cl, 0 8545 <1> get_palette_loop: 8546 000037BF 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8547 000037C3 EC <1> in al, dx 8548 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8549 <1> ; 03/08/2022 8550 000037C4 B2C0 <1> mov dl, 0C0h 8551 000037C6 88C8 <1> mov al, cl 8552 000037C8 EE <1> out dx, al 8553 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8554 <1> ; 03/08/2022 8555 <1> ;mov dl, 0C1h 8556 000037C9 FEC2 <1> inc dl 8557 000037CB EC <1> in al, dx 8558 000037CC 8803 <1> mov [ebx], al 8559 000037CE 43 <1> inc ebx 8560 000037CF FEC1 <1> inc cl 8561 000037D1 80F910 <1> cmp cl, 10h 8562 000037D4 75E9 <1> jne short get_palette_loop 8563 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8564 <1> ; 03/08/2022 8565 000037D6 B2DA <1> mov dl, 0DAh 8566 000037D8 EC <1> in al, dx 8567 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8568 <1> ; 03/08/2022 8569 000037D9 B2C0 <1> mov dl, 0C0h 8570 000037DB B011 <1> mov al, 11h 8571 000037DD EE <1> out dx, al 8572 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8573 <1> ; 03/08/2022 8574 000037DE FEC2 <1> inc dl ; dx = 3C1h 8575 000037E0 EC <1> in al, dx 8576 000037E1 8803 <1> mov [ebx], al 8577 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8578 <1> ; 03/08/2022 8579 000037E3 B2DA <1> mov dl, 0DAh 8580 000037E5 EC <1> in al, dx 8581 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8582 <1> ; 03/08/2022 8583 000037E6 B2C0 <1> mov dl, 0C0h 8584 000037E8 B020 <1> mov al, 20h 8585 000037EA EE <1> out dx, al 8586 <1> ; ifdef VBOX 8587 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8588 <1> ; 03/08/2022 8589 000037EB B2DA <1> mov dl, 0DAh 8590 000037ED EC <1> in al, dx 8591 <1> ; endif ; VBOX 8592 <1> 8593 <1> ;mov ecx, 17 ; transfer (byte) count 8594 <1> ; 03/08/2022 8595 000037EE 29C9 <1> sub ecx, ecx 8596 000037F0 B111 <1> mov cl, 17 8597 <1> 8598 <1> ; ESI = source address in system space 8599 <1> ; EDI = user's buffer address 8600 000037F2 E899D70000 <1> call transfer_to_user_buffer 8601 <1> 8602 000037F7 83C414 <1> add esp, 20 8603 000037FA E933E3FFFF <1> jmp VIDEO_RETURN 8604 <1> 8605 <1> select_video_dac_color_page: 8606 <1> ; 02/08/2022 (TRDOS 386 v2.0.5, code optimization) 8607 <1> ; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop) 8608 <1> ; 10/08/2016 8609 <1> ; DAC Color Paging Functions 8610 <1> ; BL = 00H = select color paging mode 8611 <1> ; BH = paging mode 8612 <1> ; 00h = 4 blocks of 64 registers 8613 <1> ; 01h = 16 blocks of 16 registers 8614 <1> ; BL = 01H = activate color page 8615 <1> ; BH = DAC color page number 8616 <1> ; 00h-03h (4-page/64-reg mode) 8617 <1> ; 00h-0Fh (16-page/16-reg mode) 8618 <1> 8619 000037FF 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8620 00003803 EC <1> in al, dx 8621 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8622 <1> ; 02/08/2022 8623 00003804 B240 <1> mov dl, 40h 8624 00003806 B010 <1> mov al, 10h 8625 00003808 EE <1> out dx, al 8626 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8627 <1> ; 02/08/2022 8628 00003809 FEC2 <1> inc dl ; mov dl, 0C1h 8629 0000380B EC <1> in al, dx 8630 0000380C 80E301 <1> and bl, 01h 8631 0000380F 750C <1> jnz short set_dac_page 8632 00003811 247F <1> and al, 07Fh 8633 00003813 C0E707 <1> shl bh, 7 8634 00003816 08F8 <1> or al, bh 8635 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8636 <1> ; 02/08/2022 8637 00003818 FECA <1> dec dl ; mov dl, 0C0h 8638 0000381A EE <1> out dx, al 8639 0000381B EB19 <1> jmp short set_actl_normal 8640 <1> set_dac_page: 8641 <1> ;push ax 8642 <1> ; 12/04/2021 8643 0000381D 50 <1> push eax 8644 0000381E 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8645 00003822 EC <1> in al, dx 8646 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8647 <1> ; 02/08/2022 8648 00003823 B2C0 <1> mov dl, 0C0h 8649 00003825 B014 <1> mov al, 14h 8650 00003827 EE <1> out dx, al 8651 <1> ;pop ax 8652 <1> ; 12/04/2021 8653 00003828 58 <1> pop eax 8654 00003829 2480 <1> and al, 80h 8655 0000382B 7503 <1> jnz short set_dac_16_page 8656 0000382D C0E702 <1> shl bh, 2 8657 <1> set_dac_16_page: 8658 00003830 80E70F <1> and bh, 0Fh 8659 00003833 88F8 <1> mov al, bh 8660 00003835 EE <1> out dx, al 8661 <1> set_actl_normal: 8662 00003836 B020 <1> mov al, 20h 8663 00003838 EE <1> out dx, al 8664 <1> ; ifdef VBOX 8665 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 8666 <1> ; 02/08/2022 8667 00003839 B2DA <1> mov dl, 0DAh 8668 0000383B EC <1> in al, dx 8669 <1> ; endif ; VBOX 8670 0000383C E9F1E2FFFF <1> jmp VIDEO_RETURN 8671 <1> 8672 <1> read_video_dac_state: 8673 <1> ; 10/08/2016 8674 <1> ; Query DAC Color Paging State 8675 <1> ; Output: 8676 <1> ; BH = current active DAC color page 8677 <1> ; BL = current active DAC paging mode 8678 <1> 8679 00003841 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8680 00003845 EC <1> in al, dx 8681 00003846 66BAC003 <1> mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8682 0000384A B010 <1> mov al, 10h 8683 0000384C EE <1> out dx, al 8684 0000384D 66BAC103 <1> mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8685 00003851 EC <1> in al, dx 8686 00003852 88C3 <1> mov bl, al 8687 00003854 C0EB07 <1> shr bl, 7 8688 00003857 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8689 0000385B EC <1> in al, dx 8690 0000385C 66BAC003 <1> mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8691 00003860 B014 <1> mov al, 14h 8692 00003862 EE <1> out dx, al 8693 00003863 66BAC103 <1> mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 8694 00003867 EC <1> in al, dx 8695 00003868 88C7 <1> mov bh, al 8696 0000386A 80E70F <1> and bh, 0Fh 8697 0000386D F6C301 <1> test bl, 01 8698 00003870 7503 <1> jnz short get_dac_16_page 8699 00003872 C0EF02 <1> shr bh, 2 8700 <1> get_dac_16_page: 8701 00003875 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8702 00003879 EC <1> in al, dx 8703 0000387A 66BAC003 <1> mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 8704 0000387E B020 <1> mov al, 20h 8705 00003880 EE <1> out dx, al 8706 <1> ; ifdef VBOX 8707 00003881 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 8708 00003885 EC <1> in al, dx 8709 <1> ; endif ; VBOX 8710 00003886 66895C240C <1> mov [esp+12], bx ; bx 8711 0000388B E9A2E2FFFF <1> jmp VIDEO_RETURN 8712 <1> 8713 <1> ; 23/11/2020 - TRDOS 386 v2.0.3 8714 <1> ; VBE 2 BOCHS/QEMU emulator extensions 8715 <1> ; for TRDOS 386 v2 kernel (video bios) 8716 <1> 8717 <1> ; BOCH/QEMU VBE2 VGA BIOS code 8718 <1> ; by Jeroen Janssen (2002) 8719 <1> ; by Volker Rupper (2003-2020) 8720 <1> ; vbe.c (02/01/2020) 8721 <1> 8722 <1> ; vbe.h (02/01/2020) 8723 <1> 8724 <1> VBE_DISPI_BANK_ADDRESS equ 0A0000h 8725 <1> VBE_DISPI_BANK_SIZE_KB equ 64 8726 <1> 8727 <1> VBE_DISPI_MAX_XRES equ 2560 8728 <1> VBE_DISPI_MAX_YRES equ 1600 8729 <1> 8730 <1> VBE_DISPI_IOPORT_INDEX equ 01CEh 8731 <1> VBE_DISPI_IOPORT_DATA equ 01CFh 8732 <1> 8733 <1> VBE_DISPI_INDEX_ID equ 00h 8734 <1> VBE_DISPI_INDEX_XRES equ 01h 8735 <1> VBE_DISPI_INDEX_YRES equ 02h 8736 <1> VBE_DISPI_INDEX_BPP equ 03h 8737 <1> VBE_DISPI_INDEX_ENABLE equ 04h 8738 <1> VBE_DISPI_INDEX_BANK equ 05h 8739 <1> VBE_DISPI_INDEX_VIRT_WIDTH equ 06h 8740 <1> VBE_DISPI_INDEX_VIRT_HEIGHT equ 07h 8741 <1> VBE_DISPI_INDEX_X_OFFSET equ 08h 8742 <1> VBE_DISPI_INDEX_Y_OFFSET equ 09h 8743 <1> VBE_DISPI_INDEX_VIDEO_MEMORY_64K equ 0Ah 8744 <1> VBE_DISPI_INDEX_DDC equ 0Bh 8745 <1> 8746 <1> VBE_DISPI_ID0 equ 0B0C0h 8747 <1> VBE_DISPI_ID1 equ 0B0C1h 8748 <1> VBE_DISPI_ID2 equ 0B0C2h 8749 <1> VBE_DISPI_ID3 equ 0B0C3h 8750 <1> VBE_DISPI_ID4 equ 0B0C4h 8751 <1> VBE_DISPI_ID5 equ 0B0C5h 8752 <1> 8753 <1> VBE_DISPI_DISABLED equ 00h 8754 <1> VBE_DISPI_ENABLED equ 01h 8755 <1> VBE_DISPI_GETCAPS equ 02h 8756 <1> VBE_DISPI_8BIT_DAC equ 20h 8757 <1> VBE_DISPI_LFB_ENABLED equ 40h 8758 <1> VBE_DISPI_NOCLEARMEM equ 80h 8759 <1> 8760 <1> VBE_DISPI_LFB_PHYSICAL_ADDRESS equ 0E0000000h 8761 <1> 8762 <1> ; *** 8763 <1> 8764 <1> ;// VBE Return Status Info 8765 <1> ;// AL 8766 <1> VBE_RETURN_STATUS_SUPPORTED equ 4Fh 8767 <1> VBE_RETURN_STATUS_UNSUPPORTED equ 00h 8768 <1> ;// AH 8769 <1> VBE_RETURN_STATUS_SUCCESSFULL equ 00h 8770 <1> VBE_RETURN_STATUS_FAILED equ 01h 8771 <1> VBE_RETURN_STATUS_NOT_SUPPORTED equ 02h 8772 <1> VBE_RETURN_STATUS_INVALID equ 03h 8773 <1> 8774 <1> ;// VBE Mode Numbers 8775 <1> 8776 <1> VBE_MODE_VESA_DEFINED equ 0100h 8777 <1> VBE_MODE_REFRESH_RATE_USE_CRTC equ 0800h 8778 <1> VBE_MODE_LINEAR_FRAME_BUFFER equ 4000h 8779 <1> VBE_MODE_PRESERVE_DISPLAY_MEMORY equ 8000h 8780 <1> 8781 <1> ;// Mode Attributes 8782 <1> 8783 <1> VBE_MODE_ATTRIBUTE_SUPPORTED equ 0001h 8784 <1> VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE equ 0002h 8785 <1> VBE_MODE_ATTRIBUTE_COLOR_MODE equ 0008h 8786 <1> VBE_MODE_ATTRIBUTE_GRAPHICS_MODE equ 0010h 8787 <1> VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE equ 0080h 8788 <1> VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE equ 0100h 8789 <1> VBE_MODE_ATTRIBUTE_INTERLACE_MODE equ 0200h 8790 <1> 8791 <1> ;// Window attributes 8792 <1> 8793 <1> VBE_WINDOW_ATTRIBUTE_RELOCATABLE equ 01h 8794 <1> VBE_WINDOW_ATTRIBUTE_READABLE equ 02h 8795 <1> VBE_WINDOW_ATTRIBUTE_WRITEABLE equ 04h 8796 <1> 8797 <1> ;/* Video memory */ 8798 <1> VGAMEM_GRAPH equ 0A000h 8799 <1> VGAMEM_CTEXT equ 0B800h 8800 <1> ;VGAMEM_MTEXT equ 0B000h 8801 <1> 8802 <1> ;// Memory model 8803 <1> 8804 <1> ;VBE_MEMORYMODEL_TEXT_MODE equ 00h 8805 <1> ;VBE_MEMORYMODEL_CGA_GRAPHICS equ 01h 8806 <1> ;VBE_MEMORYMODEL_PLANAR equ 03h 8807 <1> VBE_MEMORYMODEL_PACKED_PIXEL equ 04h 8808 <1> ;VBE_MEMORYMODEL_NON_CHAIN_4_256 equ 05h 8809 <1> VBE_MEMORYMODEL_DIRECT_COLOR equ 06h 8810 <1> ;VBE_MEMORYMODEL_YUV equ 07h 8811 <1> 8812 <1> ;// DirectColorModeInfo 8813 <1> 8814 <1> ;VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE equ 01h 8815 <1> VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE equ 02h 8816 <1> 8817 <1> VBE_DISPI_TOTAL_VIDEO_MEMORY_MB equ 16 8818 <1> 8819 <1> ; 24/11/2020 8820 <1> ; vbe.c 8821 <1> 8822 <1> %if 1 8823 <1> 8824 <1> _vbe_biosfn_return_mode_info: 8825 <1> ; 15/12/2020 8826 <1> ; 12/12/2020 8827 <1> ; Return VBE Mode Information 8828 <1> ; (call from 'sysvideo') 8829 <1> ; 8830 <1> ; Input: 8831 <1> ; cx = video (bios) mode 8832 <1> ; Output: 8833 <1> ; cf = 0 -> (successful) 8834 <1> ; MODE_INFO_LIST addr contains MODEINFO 8835 <1> ; cf = 1 -> error 8836 <1> ; 8837 <1> ; Modified registers: eax, edx, edi 8838 <1> ; 8839 <1> 8840 <1> ; pushes for subroutine stack pops compatibility 8841 <1> 8842 <1> ;push ds ; * 8843 <1> ;push es ; ** 8844 <1> 8845 00003890 55 <1> push ebp ; *** 8846 00003891 56 <1> push esi ; **** 8847 <1> 8848 00003892 31FF <1> xor edi, edi ; mov edi, 0 8849 <1> 8850 00003894 803D[86090000]03 <1> cmp byte [vbe3], 3 8851 0000389B 7221 <1> jb short _vbe_rmi_1 8852 <1> 8853 <1> ;sub edi, edi ; 0 = kernel call (sign) 8854 <1> ; ; no transfer to user's buffer 8855 <1> 8856 <1> ; cx = Video mode (for 4F01h, with LFB flag) 8857 <1> 8858 0000389D 66B8014F <1> mov ax, 4F01h 8859 <1> 8860 000038A1 E826E0FFFF <1> call _vbe3_pmfn_return_mode_info 8861 <1> 8862 000038A6 6683F84F <1> cmp ax, 004Fh 8863 000038AA 7533 <1> jne short _vbe_rmi_2 ; fail 8864 <1> 8865 <1> ; 15/12/2020 8866 <1> ; cx = vbe video mode 8867 000038AC 80E501 <1> and ch, 01h ; clear LFB flag 8868 000038AF BEFE7B0900 <1> mov esi, VBE3MODEINFOBLOCK - 2 8869 000038B4 66890E <1> mov [esi], cx ; MODEINFO.mode 8870 000038B7 E8A5000000 <1> call set_lfbinfo_table 8871 000038BC EB22 <1> jmp short _vbe_rmi_3 ; cf = 0 8872 <1> _vbe_rmi_1: 8873 000038BE 803D[86090000]02 <1> cmp byte [vbe3], 2 8874 000038C5 7219 <1> jb short _vbe_rmi_3 ; cf = 1 8875 000038C7 A0[87090000] <1> mov al, [vbe2bios] ; 0C0h-0C5h for emu (*) 8876 000038CC 3CC0 <1> cmp al, 0C0h ; BOCHS/QEMU/VIRTUALBOX (*) ? 8877 000038CE 7210 <1> jb short _vbe_rmi_3 ; cf = 1 8878 000038D0 3CC5 <1> cmp al, 0C5h ; (*) 8879 000038D2 770B <1> ja short _vbe_rmi_2 ; unknown vbios !? 8880 <1> 8881 <1> ;xor edi, edi ; 0 = kernel call (sign) 8882 <1> ; ; no transfer to user's buffer 8883 <1> 8884 <1> ;mov ax, 4F01h 8885 <1> 8886 <1> ; cx = Video mode (for 4F01h, with LFB flag) 8887 <1> 8888 000038D4 E80A000000 <1> call vbe_biosfn_return_mode_info 8889 000038D9 6683F84F <1> cmp ax, 004Fh ; successful ? 8890 000038DD 7401 <1> je short _vbe_rmi_3 ; cf = 0 8891 <1> _vbe_rmi_2: 8892 000038DF F9 <1> stc 8893 <1> ; cf = 1 8894 <1> _vbe_rmi_3: 8895 000038E0 5E <1> pop esi ; **** 8896 000038E1 5D <1> pop ebp ; *** 8897 <1> 8898 <1> ;pop es ; ** 8899 <1> ;pop ss ; * 8900 <1> 8901 000038E2 C3 <1> retn 8902 <1> 8903 <1> 8904 <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 8905 <1> ; * --------------------------------------------------------- 8906 <1> ; * Function 01h - Return VBE Mode Information 8907 <1> ; * --------------------------------------------------------- 8908 <1> ; * Input: 8909 <1> ; * AX = 4F01h 8910 <1> ; * CX = Mode number 8911 <1> ; * (ES:DI) EDI = Pointer to ModeInfoBlock structure 8912 <1> ; * Output: 8913 <1> ; * AX = VBE Return Status 8914 <1> ; * 8915 <1> ; *---------------------------------------------------------- 8916 <1> ; * 8917 <1> 8918 <1> vbe_biosfn_return_mode_info: 8919 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 8920 <1> ; 15/12/2020 8921 <1> ; 14/12/2020 8922 <1> ; 12/12/2020 8923 <1> ; 11/12/2020 (TRDOS 386 v2.0.3) 8924 <1> ; 8925 <1> ; Input: 8926 <1> ; cx = video (bios) mode 8927 <1> ; edi = ModeInfoBlock buffer address 8928 <1> ; (in user's memory space) 8929 <1> ; (ax = 4F01h) 8930 <1> ; Output: 8931 <1> ; ax = 004Fh (successful) 8932 <1> ; ah > 0 -> error 8933 <1> ; 8934 <1> ; Modified registers: esi 8935 <1> 8936 <1> ;;push ds ; * 8937 <1> ;;push es ; ** 8938 <1> ;;push ebp ; *** 8939 <1> ;;push esi ; **** 8940 <1> 8941 000038E3 F6C501 <1> test ch, 1 8942 000038E6 7505 <1> jnz short vbe_rmi_1 8943 <1> 8944 <1> ; mode number < 100h 8945 <1> ; CGA/VGA mode is not proper this VBE function 8946 <1> 8947 000038E8 29C0 <1> sub eax, eax 8948 <1> vbe_rmi_0: 8949 <1> ;mov ax, 0100h ; Function is not supported 8950 000038EA B401 <1> mov ah, 1 8951 000038EC C3 <1> retn 8952 <1> vbe_rmi_1: 8953 000038ED 52 <1> push edx ; ***** 8954 000038EE 51 <1> push ecx ; ****** 8955 000038EF 53 <1> push ebx ; ******* 8956 000038F0 57 <1> push edi ; ******** 8957 <1> 8958 <1> ; 14/12/2020 8959 000038F1 89CB <1> mov ebx, ecx 8960 <1> 8961 <1> ;xor eax, eax 8962 000038F3 80E7C1 <1> and bh, 0C1h ; use bit 15, 14, 8 only (for bh) 8963 000038F6 883D[2DA30100] <1> mov [vbe_mode_x], bh 8964 <1> ;and bx, 1FFh 8965 000038FC 80E701 <1> and bh, 1 8966 <1> ;mov bh, 1 8967 <1> 8968 <1> ; Alternative 2 (instead of 'Mode_info_find_mode') 8969 000038FF E86A060000 <1> call set_mode_info_list ; (alternative 2) 8970 <1> 8971 <1> ; eax = 0 8972 <1> 8973 <1> ;mov bx, [esi] ; mode 8974 <1> 8975 <1> ; Alternative 1 (instead of 'set_mode_info_list') 8976 <1> ;call mode_info_find_mode ; (alternative 1) 8977 <1> 8978 00003904 09F6 <1> or esi, esi 8979 <1> ; 14/12/2020 8980 00003906 744C <1> jz short vbe_rmi_4 ; VBE mode number is wrong 8981 <1> ; or it is not supported 8982 <1> 8983 <1> ; 15/12/2020 8984 <1> ;mov bx, [esi] ; mode 8985 <1> 8986 <1> ; 12/12/2020 8987 <1> ;call set_lfbinfo_table 8988 <1> 8989 00003908 F605[2DA30100]40 <1> test byte [vbe_mode_x], 40h ; LFB model ? 8990 0000390F 7404 <1> jz short vbe_rmi_2 8991 <1> 8992 00003911 C6461C01 <1> mov byte [esi+MODEINFO.NumberOfBanks], 1 8993 <1> vbe_rmi_2: 8994 <1> ; (vbe.c, 02/01/2020, vruppert) 8995 <1> ; 11/12/2020 (Erdogan Tan, video.s) 8996 <1> ; Bochs Graphics Adapter 8997 <1> ; vendor_id: 1111h, device id: 1234h 8998 <1> 8999 00003915 E835070000 <1> call pci_get_lfb_addr 9000 <1> ;or eax, eax 9001 0000391A 7404 <1> jz short vbe_rmi_3 9002 <1> ; zf = 0, ax > 0 (high word of LFB address) 9003 <1> ; set/change LFB address in MODEINFO structure 9004 0000391C 6689462C <1> mov [esi+MODEINFO.PhysBasePtr+2], ax 9005 <1> ; 12/12/2020 9006 <1> ;mov [edi+LFBINFO.LFB_addr+2], ax 9007 <1> vbe_rmi_3: 9008 <1> ;test byte [esi+MODEINFO.WinAAttributes], 1 9009 <1> ; ; VBE_WINDOW_ATTRIBUTE_RELOCATABLE = 1 9010 <1> ;jz short vbe_rmi_4 9011 <1> ;; 11/12/2020 9012 <1> ;; In fact, this is far call address in (Bochs/BGA) Video Bios 9013 <1> ;; Direct user access to kernel subroutines is not possible 9014 <1> ;; in TRDOS 386. Also, TRDOS 386 kernel will support only LFB. 9015 <1> ;; Bank select may be a seperate sysvideo function in future 9016 <1> ;; (if it will be required). 9017 <1> ;mov dword [esi+MODEINFO.WinFuncPtr], dispi_set_bank_farcall 9018 <1> ;vbe_rmi_4: 9019 <1> ; 12/12/2020 9020 00003920 E83C000000 <1> call set_lfbinfo_table 9021 <1> 9022 <1> ; 11/12/2020 9023 <1> ; copy 68 bytes of MODE_INFO_LIST to user 9024 <1> 9025 00003925 8B3C24 <1> mov edi, [esp] ; user's buffer address 9026 <1> ; 12/12/2020 9027 00003928 09FF <1> or edi, edi ; 0 = kernel call 9028 <1> ; (call from '_vbe_biosfn_return_mode_info') 9029 0000392A 7431 <1> jz short vbe_rmi_6 9030 <1> 9031 <1> ; 15/12/2020 9032 <1> ; prepare 256 bytes MODEINFO buffer at VBE3MODEINFOBLOCK 9033 <1> ; and then, copy buffer conttent to user's buffer 9034 0000392C 57 <1> push edi 9035 0000392D BE[4CA30100] <1> mov esi, MODE_INFO_LIST + 2 ; MODEINFO.ModeAttributes 9036 00003932 BF007C0900 <1> mov edi, VBE3MODEINFOBLOCK 9037 <1> ;mov ecx, 66/4 ; 66 bytes 9038 <1> ; 03/08/2022 9039 00003937 29C9 <1> sub ecx, ecx 9040 00003939 B110 <1> mov cl, 66/4 9041 0000393B F3A5 <1> rep movsd 9042 0000393D 31C0 <1> xor eax, eax 9043 0000393F B12F <1> mov cl, (256-68)/4 ; 188 bytes 9044 00003941 F3AB <1> rep stosd 9045 00003943 66AB <1> stosw ; 2 bytes 9046 00003945 5F <1> pop edi 9047 00003946 BE007C0900 <1> mov esi, VBE3MODEINFOBLOCK 9048 <1> ;mov cx, 256 9049 0000394B FEC5 <1> inc ch ; cx = 256 9050 0000394D E83ED60000 <1> call transfer_to_user_buffer 9051 00003952 7309 <1> jnc short vbe_rmi_5 9052 <1> vbe_rmi_4: 9053 <1> ;mov eax, 014Fh ; fail/error 9054 00003954 31C0 <1> xor eax, eax 9055 00003956 B401 <1> mov ah, 01h 9056 <1> ;jmp short vbe_rmi_6 9057 00003958 E981000000 <1> jmp vbe_sm_ret1 ; 11/12/2020 9058 <1> vbe_rmi_5: 9059 <1> ; 256 bytes of MODEINFO have been transferred to user 9060 <1> ;mov eax, 4Fh ; succesfull 9061 <1> vbe_rmi_6: ; 12/12/2020 9062 0000395D 31C0 <1> xor eax, eax 9063 <1> ;vbe_rmi_6: 9064 0000395F EB7D <1> jmp vbe_sm_ret1 ; 11/12/2020 9065 <1> 9066 <1> ;pop edi ; ******** 9067 <1> ;pop ebx ; ******* 9068 <1> ;pop ecx ; ****** 9069 <1> ;pop edx ; ***** 9070 <1> 9071 <1> ;;pop esi ; **** 9072 <1> ;;pop ebp ; *** 9073 <1> ;;pop es ; ** 9074 <1> ;;pop ds ; * 9075 <1> 9076 <1> ;retn 9077 <1> 9078 <1> set_lfbinfo_table: 9079 <1> ; 19/12/2020 9080 <1> ; 11/12/2020 9081 <1> ; Set/Fill LFBINFO structure/table 9082 <1> ; 9083 <1> ; Input: 9084 <1> ; esi = Mode info list address 9085 <1> ; Output: 9086 <1> ; LFB_Info address is filled with LFBINFO 9087 <1> ; edi = LFB_Info address 9088 <1> ; 9089 <1> ; Modified registers: eax, edx (=0), edi 9090 <1> 9091 00003961 BF[3AA30100] <1> mov edi, LFB_Info 9092 00003966 8B462A <1> mov eax, [esi+MODEINFO.PhysBasePtr] 9093 00003969 894702 <1> mov [edi+LFBINFO.LFB_addr], eax ; LFB address 9094 <1> ;mov ax, [esi+MODEINFO.mode] 9095 0000396C 668B06 <1> mov ax, [esi] 9096 0000396F 668907 <1> mov [edi+LFBINFO.mode],ax 9097 00003972 8A461B <1> mov al, [esi+MODEINFO.BitsPerPixel] 9098 00003975 88470E <1> mov [edi+LFBINFO.bpp], al 9099 00003978 29C0 <1> sub eax, eax 9100 0000397A 668B4614 <1> mov ax, [esi+MODEINFO.XResolution] 9101 0000397E 6689470A <1> mov [edi+LFBINFO.X_res], ax 9102 00003982 89C2 <1> mov edx, eax ; 19/12/2020 9103 00003984 668B4616 <1> mov ax, [esi+MODEINFO.YResolution] 9104 00003988 6689470C <1> mov [edi+LFBINFO.Y_res], ax 9105 <1> ; eax = Y_res ; screen height 9106 <1> ; 19/12/2020 9107 0000398C F7E2 <1> mul edx ; X_res*Y_res 9108 <1> ; edx = 0 9109 0000398E 8A570E <1> mov dl, [edi+LFBINFO.bpp] 9110 <1> ; Note: 9111 <1> ; Bits per pixel may be 8,16,24,32 for TRDOS 386 v2. 9112 <1> ; (4 bits for pixel is not used for VESA modes here) 9113 00003991 C0EA03 <1> shr dl, 3 ; convert bits to byte 9114 00003994 F7E2 <1> mul edx 9115 <1> ; eax = screen/page/buffer size in bytes 9116 00003996 894706 <1> mov [edi+LFBINFO.LFB_size], eax 9117 <1> ; edx = 0 9118 <1> ; clear reserved byte in LFBINFO structure/table 9119 00003999 88570F <1> mov [edi+LFBINFO.reserved], dl ; not necessary 9120 0000399C C3 <1> retn 9121 <1> 9122 <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 9123 <1> ; * --------------------------------------------------------- 9124 <1> ; * Function 02h - Set VBE Mode 9125 <1> ; * --------------------------------------------------------- 9126 <1> ; * Input: 9127 <1> ; * AX = 4F02h 9128 <1> ; * BX = Desired Mode to set 9129 <1> ; * Output: 9130 <1> ; * AX = VBE Return Status 9131 <1> ; * 9132 <1> ; *---------------------------------------------------------- 9133 <1> ; * 9134 <1> 9135 <1> vbe_biosfn_set_mode: 9136 <1> ; 07/03/2021 9137 <1> ; 12/12/2020 9138 <1> ; 11/12/2020 (LFBINFO table for VESA VBE modes) 9139 <1> ; 27/11/2020 9140 <1> ; 25/11/2020 9141 <1> ; 23/11/2020 (TRDOS 386 v2.0.3) 9142 <1> ; (ref: vbe.c, 02/01/2020, vruppert) 9143 <1> ; 9144 <1> ; Input: 9145 <1> ; bx = video (bios) mode 9146 <1> ; ax = 4F02h 9147 <1> ; Output: 9148 <1> ; ax = 004Fh (successful) 9149 <1> ; ah > 0 -> error 9150 <1> ; 9151 <1> ; Modified registers: esi 9152 <1> 9153 <1> ; 27/11/2020 9154 <1> 9155 <1> ;;push ds ; * 9156 <1> ;;push es ; ** 9157 <1> ;;push ebp ; *** 9158 <1> ;;push esi ; **** 9159 <1> 9160 <1> ; 11/12/2020 9161 0000399D 52 <1> push edx ; ***** 9162 0000399E 51 <1> push ecx ; ****** 9163 0000399F 53 <1> push ebx ; ******* 9164 000039A0 57 <1> push edi ; ******** 9165 <1> 9166 <1> ;xor eax, eax 9167 000039A1 80E7C1 <1> and bh, 0C1h ; use bit 15, 14, 8 only (for bh) 9168 000039A4 883D[2DA30100] <1> mov [vbe_mode_x], bh 9169 000039AA 80E701 <1> and bh, 1 9170 000039AD 753C <1> jnz short vbe_sm_3 ; VESA VBE mode 9171 <1> 9172 <1> ;;test bx, 4000h ; VBE_MODE_LINEAR_FRAME_BUFFER 9173 <1> ;test bh, 40h 9174 <1> ;jz short vbe_sm_0 9175 <1> ;; lfb_flag 9176 <1> ;mov al, 40h ; VBE_DISPI_LFB_ENABLED 9177 <1> vbe_sm_0: 9178 <1> ; 27/11/2020 9179 000039AF B080 <1> mov al, 80h 9180 <1> ;test bh, 80h ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 9181 <1> ;jnz short vbe_sm_1 ; no_clear 9182 <1> ;; clear 9183 <1> ;sub al, al ; 0 9184 000039B1 8405[2DA30100] <1> test [vbe_mode_x], al ; 80h 9185 000039B7 7402 <1> jz short vbe_sm_1 ; clear display memory 9186 <1> ; no_clear 9187 000039B9 08C3 <1> or bl, al ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 9188 <1> vbe_sm_1: 9189 <1> ; check non vesa mode 9190 <1> ;;cmp bx, 100h ; VBE_MODE_VESA_DEFINED 9191 <1> ;;jna short vbe_sm_2 9192 <1> ;and bh, 1 9193 <1> ;jnz short vbe_sm_3 9194 <1> 9195 <1> ; BX <= 1FFh 9196 <1> 9197 <1> ; 27/11/2020 9198 <1> ;or bl, al ; al = 80h if no_clear option is set 9199 <1> ; ; al = 0 if no_clear option is not set 9200 <1> 9201 <1> ; 25/11/2020 9202 <1> ; VBE DISPI will be disabled in 'biosfn_set_video_mode' 9203 <1> 9204 <1> ;xor al, al ; 0 ; VBE_DISPI_DISABLED 9205 <1> ;call dispi_set_enable 9206 <1> 9207 <1> ; call the vgabios in order to set the video mode 9208 <1> ; this allows for going back to textmode with a VBE call 9209 <1> ; (some applications expect that to work) 9210 <1> 9211 <1> ;and bx, 0FFh 9212 <1> 9213 <1> ; 27/11/2020 9214 <1> biosfn_set_video_mode: 9215 <1> ; _call: call subroutine 9216 <1> ; 26/11/2020 (TRDOS 386 v2.0.3) 9217 <1> ; (ref: vgabios.c, 02/01/2020, vruppert) 9218 <1> ; Input: 9219 <1> ; bl = VGA video (bios) mode 9220 <1> ; Output: 9221 <1> ; cf = 1 -> error 9222 <1> ; cf = 0 -> ok 9223 <1> ; 9224 <1> ; Modified registers: esi 9225 <1> 9226 <1> ; 'dispi_set_enable(VBE_DISPI_DISABLED);' 9227 <1> 9228 <1> ;mov ax, 0 ; VBE_DISPI_DISABLED 9229 000039BB 31C0 <1> xor eax, eax ; 0 9230 000039BD E89C040000 <1> call dispi_set_enable 9231 <1> 9232 000039C2 88D8 <1> mov al, bl 9233 <1> ;jmp _set_mode ; (in 'biosfn_set_video_mode' sub) 9234 000039C4 E87AE1FFFF <1> call _set_mode ; will return with cf=1 only if 9235 <1> ; desired mode is not implemented 9236 <1> ; _retn: return from subroutine 9237 000039C9 721A <1> jc short vbe_sm_2 ; 25/11/2020 9238 <1> 9239 <1> ; 26/11/2020 9240 000039CB 31C0 <1> xor eax, eax 9241 000039CD A0[DE670000] <1> mov al, [CRT_MODE] 9242 <1> ; 27/11/2020 9243 000039D2 8A25[53890100] <1> mov ah, [noclearmem] ; 80h or 0 9244 <1> ;and ah 80h 9245 000039D8 66A3[2EA30100] <1> mov [video_mode], ax ; bit 15 = no_clear flag 9246 <1> ; bit 14 = 0 (not LFB model) 9247 <1> vbe_sm_ret1: 9248 <1> ; 11/12/2020 9249 <1> ; (vbe_rmi_4 and vbe_rmi_6 jump here) 9250 <1> ; 27/11/2020 9251 000039DE B04F <1> mov al, 4Fh ; Function call successful 9252 <1> ; eax = 004Fh 9253 <1> vbe_sm_ret2: 9254 <1> ; 11/12/2020 9255 000039E0 5F <1> pop edi ; ******** 9256 000039E1 5B <1> pop ebx ; ******* 9257 000039E2 59 <1> pop ecx ; ****** 9258 000039E3 5A <1> pop edx ; ***** 9259 <1> 9260 <1> ;;pop esi ; **** 9261 <1> ;;pop ebp ; *** 9262 <1> ;;pop es ; ** 9263 <1> ;;pop ds ; * 9264 <1> 9265 000039E4 C3 <1> retn 9266 <1> 9267 <1> vbe_sm_2: 9268 <1> ;mov ax, 0100h ; Function is not supported 9269 <1> ; 27/11/2020 9270 000039E5 31C0 <1> xor eax, eax 9271 000039E7 B401 <1> mov ah, 01h 9272 <1> ; eax = 0100h 9273 <1> ;retn 9274 000039E9 EBF5 <1> jmp short vbe_sm_ret2 9275 <1> 9276 <1> vbe_sm_3: 9277 <1> ; 12/12/2020 9278 <1> ; check current mode, if it is 03h 9279 <1> ; save page contents and cursor positions 9280 000039EB 803D[DE670000]03 <1> cmp byte [CRT_MODE], 03h 9281 <1> ;jne short vbe_sm_0 9282 000039F2 7505 <1> jne short vbe_sm_4 ; 07/03/2021 9283 000039F4 E8ECE3FFFF <1> call save_mode3_multiscreen 9284 <1> ; set current mode to extended (SVGA) mode 9285 <1> ;mov byte [CRT_MODE], 0FFh ; VESA VBE mode 9286 <1> vbe_sm_4: 9287 <1> ; 27/11/2020 9288 <1> ; bx = mode (bit 0 to 8) 9289 <1> 9290 <1> ; 25/11/2020 9291 <1> 9292 <1> ; Alternative 2 (instead of 'Mode_info_find_mode') 9293 <1> ;push edi 9294 000039F9 E870050000 <1> call set_mode_info_list ; (alternative 2) 9295 <1> ;pop edi 9296 <1> 9297 <1> ;mov bx, [esi] ; mode 9298 <1> 9299 <1> ; Alternative 1 (instead of 'set_mode_info_list') 9300 <1> ;call mode_info_find_mode ; (alternative 1) 9301 <1> 9302 000039FE 09F6 <1> or esi, esi 9303 00003A00 74E3 <1> jz short vbe_sm_2 ; VBE mode number is wrong 9304 <1> ; or it is not supported 9305 <1> 9306 <1> ; 11/12/2020 9307 00003A02 668B1E <1> mov bx, [esi] ; mode 9308 <1> 9309 <1> ; 27/11/2020 9310 00003A05 0A3D[2DA30100] <1> or bh, [vbe_mode_x] 9311 <1> 9312 <1> ; save VESA VBE mode 9313 00003A0B 66891D[2EA30100] <1> mov [video_mode], bx 9314 <1> ; 27/11/2020 9315 <1> ; bit 0 to 8 = VESA VBE mode 9316 <1> ; bit 9 to 13 = 0 (bit 0 to 13 = mode) 9317 <1> ; bit 14 = Linear/Flat Frame Buffer flag 9318 <1> ; bit 15 = 'memory not cleared 9319 <1> ; at last mode set' flag 9320 <1> 9321 <1> ; first disable current mode 9322 <1> ; (when switching between vesa modes) 9323 <1> ; 'dispi_set_enable(VBE_DISPI_DISABLED);' 9324 <1> 9325 <1> ;mov ax, VBE_DISPI_DISABLED ; 0 9326 00003A12 29C0 <1> sub eax, eax ; 0 9327 <1> 9328 00003A14 E845040000 <1> call dispi_set_enable 9329 <1> 9330 <1> ; 11/12/2020 9331 00003A19 8A461B <1> mov al, [esi+MODEINFO.BitsPerPixel] 9332 <1> ; ah = 0 9333 <1> 9334 <1> ;cmp byte [esi+MODEINFO.BitsPerPixel], 8 9335 00003A1C 3C08 <1> cmp al, 8 9336 00003A1E 750B <1> jne short vbe_sm_5 9337 <1> 9338 <1> ; 11/12/2020 9339 <1> ;push edi 9340 00003A20 50 <1> push eax 9341 <1> ; 'load_dac_palette(3);' 9342 00003A21 56 <1> push esi 9343 00003A22 B403 <1> mov ah, 3 ; palette3, 256 colors 9344 00003A24 E8BBF1FFFF <1> call load_dac_palette 9345 00003A29 5E <1> pop esi 9346 <1> ; 11/12/2020 9347 00003A2A 58 <1> pop eax 9348 <1> ;pop edi 9349 <1> vbe_sm_5: 9350 <1> ;'dispi_set_bpp(cur_info->info.BitsPerPixel);' 9351 <1> ; 11/12/2020 (al = bits per pixel, ah = 0) 9352 <1> ;xor ah, ah 9353 <1> ;mov al, [esi+MODEINFO.BitsPerPixel] 9354 00003A2B E841040000 <1> call dispi_set_bpp 9355 <1> ;'dispi_set_xres(cur_info->info.XResolution);' 9356 00003A30 668B4614 <1> mov ax, [esi+MODEINFO.XResolution] 9357 00003A34 E83E040000 <1> call dispi_set_xres 9358 <1> ;'dispi_set_yres(cur_info->info.YResolution);' 9359 00003A39 668B4616 <1> mov ax, [esi+MODEINFO.YResolution] 9360 00003A3D E83B040000 <1> call dispi_set_yres 9361 <1> 9362 <1> ;'dispi_set_bank(0);' 9363 <1> ;xor ax, ax 9364 00003A42 31C0 <1> xor eax, eax ; 0 9365 00003A44 E83A040000 <1> call dispi_set_bank 9366 <1> ;'dispi_set_enable(VBE_DISPI_ENABLED|no_clear|lfb_flag);' 9367 <1> ;mov ax, di 9368 <1> ; ah = 0 ; 27/11/2020 9369 00003A49 A0[2DA30100] <1> mov al, [vbe_mode_x] ; restore VBE mode bit 14 & 15 9370 00003A4E 0C01 <1> or al, 1 ; VBE_DISPI_ENABLED 9371 00003A50 E809040000 <1> call dispi_set_enable 9372 <1> 9373 <1> ; 'vga_compat_setup();' 9374 00003A55 E83E040000 <1> call vga_compat_setup 9375 <1> 9376 <1> ; 11/12/2020 9377 00003A5A E802FFFFFF <1> call set_lfbinfo_table 9378 <1> 9379 <1> ; 26/11/2020 9380 00003A5F 31C0 <1> xor eax, eax 9381 00003A61 FEC8 <1> dec al 9382 00003A63 A2[DE670000] <1> mov [CRT_MODE], al ; 0FFh = VESA VBE mode sign 9383 <1> 9384 <1> ; 27/11/2020 9385 00003A68 E971FFFFFF <1> jmp vbe_sm_ret1 ; Function call successful 9386 <1> 9387 <1> ; 27/11/2020 9388 <1> ;mov al, 4Fh 9389 <1> ; ; eax = 004Fh = Function call successful 9390 <1> ;jmp short vbe_sm_ret2 9391 <1> 9392 <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 9393 <1> ; * --------------------------------------------------------- 9394 <1> ; * Function 03h - Return Current VBE Mode 9395 <1> ; * --------------------------------------------------------- 9396 <1> ; * Input: 9397 <1> ; * AX = 4F03h 9398 <1> ; * Output: 9399 <1> ; * AX = VBE Return Status 9400 <1> ; * BX = Current VBE Mode 9401 <1> ; * 9402 <1> ; *---------------------------------------------------------- 9403 <1> ; * 9404 <1> 9405 <1> vbe_biosfn_return_current_mode: 9406 <1> ; 11/12/2020 9407 <1> ; 27/11/2020 (TRDOS 386 v2.0.3) 9408 <1> ; (ref: vbe.c, 02/01/2020, vruppert) 9409 <1> ; 9410 <1> ; Input: 9411 <1> ; none 9412 <1> ; Output: 9413 <1> ; ax = 004Fh (successful) 9414 <1> ; ah > 0 -> error 9415 <1> ; bx = current video (bios) mode (if ah = 0) 9416 <1> ; 9417 <1> ; Modified registers: eax, ebx 9418 <1> 9419 <1> ; 27/11/2020 9420 <1> 9421 <1> ;;push ds ; * 9422 <1> ;;push es ; ** 9423 <1> ;;push ebp ; *** 9424 <1> ;;push esi ; **** 9425 <1> 9426 <1> ;push edx ; ***** 9427 <1> 9428 <1> ; (vbe.c) 9429 <1> ;call dispi_get_enable 9430 <1> ; ; ax = vbe display interface status 9431 <1> ;and al, 1 ; VBE_DISPI_ENABLED 9432 <1> ;jnz short vbe_gm_1 ; VBE graphics mode 9433 <1> 9434 00003A6D A0[DE670000] <1> mov al, [CRT_MODE] ; current cga/vga mode 9435 00003A72 3CFF <1> cmp al, 0FFh ; VBE extension signature 9436 00003A74 720E <1> jb short vbe_gm_1 ; get CGA/VGA mode 9437 <1> 9438 <1> ; get VBE mode 9439 <1> vbe_gm_0: 9440 00003A76 66A1[2EA30100] <1> mov ax, [video_mode] 9441 <1> ; BX bits: 9442 <1> ; bit 0 to 8 = VESA VBE video mode 9443 <1> ; bit 9 to 13 = 0 9444 <1> ; bit 14 = last mode set LFB option 9445 <1> ; 1 - linear/flat frame buffer 9446 <1> ; 0 - windowed frame buffer 9447 <1> ; bit 15 = last mode set no_clear option 9448 <1> ; 0 - video memory cleared 9449 <1> ; 1 - video memory not cleared 9450 <1> 9451 <1> vbe_gm_return: 9452 <1> ;pop edx ; ****** 9453 00003A7C 0FB7D8 <1> movzx ebx, ax 9454 <1> ;vbe_srs_retn: 9455 00003A7F 31C0 <1> xor eax, eax ; 0 9456 00003A81 B04F <1> mov al, 4Fh ; ax = 004Fh (successful) 9457 00003A83 C3 <1> retn 9458 <1> 9459 <1> vbe_gm_1: 9460 <1> ; legacy (old, standard) CGA/VGA bios video mode 9461 00003A84 8A25[53890100] <1> mov ah, [noclearmem] ; 80h or 0 9462 <1> ; BX bits: 9463 <1> ; bit 0 to 7 = video mode 9464 <1> ; bit 8 to 13 = 0 9465 <1> ; bit 14 = 0 (not LFB mode) CGA/VGA 9466 <1> ; bit 15 = 1 if [noclearmem] = 80h 9467 <1> ; 0 if [noclearmem] = 0 9468 00003A8A EBF0 <1> jmp short vbe_gm_return 9469 <1> 9470 <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 9471 <1> ; * --------------------------------------------------------- 9472 <1> ; * Function 04h - Save/Restore State 9473 <1> ; * --------------------------------------------------------- 9474 <1> ; * Input: 9475 <1> ; * AX = 4F04h 9476 <1> ; * DL = 00h Return Save/Restore State buff size 9477 <1> ; * 01h Save State 9478 <1> ; * 02h Restore State 9479 <1> ; * CX = Requested states 9480 <1> ; * bit 0 - controller hardware state 9481 <1> ; * bit 1 - BIOS data state 9482 <1> ; * bit 2 - DAC state 9483 <1> ; * bit 3 - register state 9484 <1> ; * (ES:BX) EBX = Pointer to buffer (if DL <> 00h) 9485 <1> ; * Output: 9486 <1> ; * AX = VBE Return Status 9487 <1> ; * BX = Number of 64-byte blocks 9488 <1> ; * to hold the state buffer (if DL=00h) 9489 <1> ; * 9490 <1> ; *---------------------------------------------------------- 9491 <1> ; * 9492 <1> 9493 <1> vbe_biosfn_save_restore_state: 9494 <1> ; 23/01/2021 9495 <1> ; 16/01/2021 9496 <1> ; 14/01/2021 9497 <1> ; 13/01/2021 9498 <1> ; 12/01/2021 9499 <1> ; 11/01/2021 (TRDOS 386 v2.0.3) 9500 <1> ; (ref: vbe.c, 02/01/2020, vruppert) 9501 <1> ; 9502 <1> ; Input: 9503 <1> ; dl = sub function 9504 <1> ; cl = requested state 9505 <1> ; ebx = pointer to buffer (if dl<>00h) 9506 <1> ; Output: 9507 <1> ; ax = 004Fh (successful) 9508 <1> ; ah > 0 -> error 9509 <1> ; bx = Number of 64-byte blocks 9510 <1> ; to hold the state buffer (if DL=00h) 9511 <1> 9512 <1> ; Modified registers: eax, ebx, edi 9513 <1> 9514 <1> ; 14/01/2021 9515 00003A8C 09DB <1> or ebx, ebx ; user's buffer address 9516 00003A8E 750A <1> jnz short _vbe_biosfn_save_restore_state 9517 <1> 9518 00003A90 20D2 <1> and dl, dl 9519 00003A92 7406 <1> jz short _vbe_biosfn_save_restore_state 9520 <1> 9521 <1> ; function failed 9522 <1> ;mov eax, 0100h 9523 <1> ;xor eax, eax 9524 <1> ;inc ah ; eax = 0100h 9525 <1> ; 16/01/2021 9526 00003A94 B84F010000 <1> mov eax, 014Fh 9527 00003A99 C3 <1> retn 9528 <1> 9529 <1> _vbe_biosfn_save_restore_state: 9530 <1> ; 23/01/2021 9531 <1> ; 14/01/2021 9532 <1> ; ebx = 0 if the caller is kernel ('sysvideo') 9533 <1> 9534 <1> ; 13/01/2021 9535 00003A9A 57 <1> push edi 9536 00003A9B 52 <1> push edx 9537 00003A9C 51 <1> push ecx 9538 <1> 9539 <1> ; 23/01/2021 9540 <1> ; 12/01/2021 9541 00003A9D 80FA02 <1> cmp dl, 2 9542 00003AA0 7757 <1> ja short vbe_srs_7 ; 23/01/2021 9543 <1> ; invalid sub function 9544 00003AA2 83F90F <1> cmp ecx, 0Fh 9545 00003AA5 7752 <1> ja short vbe_srs_7 ; invalid ! 9546 <1> 9547 00003AA7 20D2 <1> and dl, dl 9548 00003AA9 7515 <1> jnz short vbe_srs_4 9549 <1> 9550 <1> ; DL = 0 9551 <1> ; Return Save/Restore State buffer size 9552 <1> 9553 <1> ;mov ebx, ecx 9554 <1> ;shl bl, 1 9555 <1> ;mov bx, [ebx+vbestatebufsize] 9556 00003AAB E881000000 <1> call vbe_srs_gbs 9557 <1> 9558 <1> ; ; 11/01/2021 9559 <1> ; test cl, 8 9560 <1> ; jz short vbe_srs_3 9561 <1> ; ; vbe_biosfn_read_video_state_size(); 9562 <1> ; ; return 9 * 2; 9563 <1> ; mov bl, 18 ; register state size 9564 <1> ;vbe_srs_0: 9565 <1> ; test cl, 1 9566 <1> ; jz short vbe_srs_1 9567 <1> ; ; size += 0x46; 9568 <1> ; add bl, 70 ; controller state size 9569 <1> ;vbe_srs_1: 9570 <1> ; test cl, 2 9571 <1> ; jz short vbe_srs_2 9572 <1> ; ; size += (5 + 8 + 5) * 2 + 6; 9573 <1> ; ;add bl, 42 ; BIOS data state size ; Bochs/Plex86 9574 <1> ; ; 12/01/2021 9575 <1> ; add bl, 40 ; TRDOS 386 v2 VBIOS data state size 9576 <1> ;vbe_srs_2: 9577 <1> ; test cl, 4 9578 <1> ; jz short vbe_srs_3 9579 <1> ; ; size += 3 + 256 * 3 + 1; 9580 <1> ; add bx, 772 ; DAC state size 9581 <1> 9582 <1> vbe_srs_3: 9583 00003AB0 6683C33F <1> add bx, 63 9584 00003AB4 66C1EB06 <1> shr bx, 6 ; / 64 9585 <1> 9586 <1> vbe_srs_retn: 9587 00003AB8 31C0 <1> xor eax, eax ; 0 9588 <1> vbe_srs_0: ; 16/01/2021 9589 00003ABA B04F <1> mov al, 4Fh ; ax = 004Fh (successful) 9590 <1> ;vbe_srs_0: 9591 <1> ; 13/01/2021 9592 00003ABC 59 <1> pop ecx 9593 00003ABD 5A <1> pop edx 9594 00003ABE 5F <1> pop edi 9595 <1> 9596 00003ABF C3 <1> retn 9597 <1> 9598 <1> ; 23/01/2021 9599 <1> ;vbe_srs_10: 9600 <1> ;; 14/01/2021 9601 <1> ; return to 'sysvideo' 9602 <1> ;mov ebx, ecx ; transfer count 9603 <1> ; ; (byte count for saving current video state) 9604 <1> ;jmp short vbe_srs_retn 9605 <1> 9606 <1> vbe_srs_4: 9607 <1> ; 23/01/2021 9608 00003AC0 80E10F <1> and cl, 0Fh ; 8, 4, 2, 1 9609 00003AC3 7434 <1> jz short vbe_srs_7 ; cx = 0 -> invalid ! 9610 <1> 9611 00003AC5 BF00760900 <1> mov edi, VBE3SAVERESTOREBLOCK 9612 <1> 9613 00003ACA 80FA01 <1> cmp dl, 1 9614 00003ACD 7730 <1> ja short vbe_srs_8 9615 <1> 9616 <1> ; save video state 9617 <1> 9618 00003ACF F6C107 <1> test cl, 07h ; 4, 2, 1 9619 00003AD2 740A <1> jz short vbe_srs_5 ; vbe dispi regs state 9620 <1> 9621 00003AD4 E884000000 <1> call biosfn_save_video_state 9622 <1> ; edi = current position 9623 <1> ; in VBE3SAVERESTOREBLOCK 9624 <1> ; (VGA save_state offset) 9625 <1> ; modified regs: edi, eax, edx, ch 9626 00003AD9 F6C108 <1> test cl, 8 9627 00003ADC 7405 <1> jz short vbe_srs_6 9628 <1> vbe_srs_5: 9629 00003ADE E8AB010000 <1> call vbe_biosfn_save_video_state 9630 <1> ; edi = end position 9631 <1> ; in VBE3SAVERESTOREBLOCK 9632 <1> ; (VGA save_state offset) 9633 <1> ; modified regs: edi, eax, edx, ch 9634 <1> vbe_srs_6: 9635 <1> ; 23/01/2021 9636 00003AE3 21DB <1> and ebx, ebx 9637 00003AE5 74D1 <1> jz short vbe_srs_retn ; the caller is kernel 9638 <1> 9639 00003AE7 BE00760900 <1> mov esi, VBE3SAVERESTOREBLOCK 9640 00003AEC 29F7 <1> sub edi, esi 9641 00003AEE 89F9 <1> mov ecx, edi ; transfer count in bytes 9642 <1> 9643 <1> ;; 14/01/2021 9644 <1> ;and ebx, ebx 9645 <1> ;jz short vbe_srs_10 ; the caller is kernel 9646 <1> 9647 00003AF0 89DF <1> mov edi, ebx ; user's buffer address 9648 00003AF2 E899D40000 <1> call transfer_to_user_buffer 9649 00003AF7 73BF <1> jnc short vbe_srs_retn 9650 <1> vbe_srs_7: 9651 <1> ; // function failed 9652 <1> ;mov eax, 0100h 9653 00003AF9 31C0 <1> xor eax, eax 9654 00003AFB FEC4 <1> inc ah ; eax = 0100h 9655 <1> ; 16/01/2021 9656 <1> ; ax = 0014Fh 9657 <1> ;retn 9658 <1> ; 13/01/2021 9659 00003AFD EBBB <1> jmp short vbe_srs_0 9660 <1> vbe_srs_8: 9661 <1> ;cmp dl, 2 9662 <1> ;jne short vbe_srs_7 9663 <1> ; ; invalid sub function 9664 <1> 9665 <1> ; 14/01/2021 9666 00003AFF 09DB <1> or ebx, ebx ; user's buffer address 9667 <1> ;jnz short vbe_srs_11 9668 <1> 9669 <1> ; the caller is kernel ('sysvideo') 9670 <1> ;jmp short vbe_srs_12 9671 <1> ; 23/01/2021 9672 00003B01 7414 <1> jz short vbe_srs_12 ; 'sysvideo' call 9673 <1> vbe_srs_11: 9674 00003B03 89DE <1> mov esi, ebx ; user's buffer address 9675 <1> ; 23/01/2021 9676 <1> ;push ebx 9677 <1> 9678 00003B05 E827000000 <1> call vbe_srs_gbs 9679 <1> 9680 <1> ; restore video state 9681 <1> 9682 <1> ;mov edi, VBE3SAVERESTOREBLOCK 9683 00003B0A 51 <1> push ecx 9684 00003B0B 89D9 <1> mov ecx, ebx ; transfer count in bytes 9685 00003B0D E8C8D40000 <1> call transfer_from_user_buffer 9686 00003B12 59 <1> pop ecx 9687 <1> ; 23/01/2021 9688 <1> ;pop ebx 9689 00003B13 89F3 <1> mov ebx, esi 9690 00003B15 72E2 <1> jc short vbe_srs_7 9691 <1> 9692 <1> vbe_srs_12: 9693 <1> ;mov esi, VBE3SAVERESTOREBLOCK 9694 00003B17 89FE <1> mov esi, edi 9695 <1> 9696 00003B19 F6C107 <1> test cl, 07h ; 4, 2, 1 9697 00003B1C 740C <1> jz short vbe_srs_9 ; vbe dispi regs state 9698 <1> 9699 00003B1E E8A2010000 <1> call biosfn_restore_video_state 9700 00003B23 72D4 <1> jc short vbe_srs_7 ; invalid buffer content ! 9701 <1> ; esi = current position 9702 <1> ; in VBE3SAVERESTOREBLOCK 9703 <1> ; (VGA save_state offset) 9704 <1> ; modified regs: esi, eax, edx, ch 9705 00003B25 F6C108 <1> test cl, 8 9706 <1> ;jz short vbe_srs_10 9707 <1> ; 23/01/2020 9708 00003B28 EB8E <1> jmp short vbe_srs_retn 9709 <1> vbe_srs_9: 9710 00003B2A E8F1020000 <1> call vbe_biosfn_restore_video_state 9711 <1> 9712 <1> ; modified regs: esi, eax, edx, ch 9713 <1> 9714 00003B2F EB87 <1> jmp short vbe_srs_retn 9715 <1> 9716 <1> ;vbe_srs_10: 9717 <1> ; ; successful 9718 <1> ; xor eax, eax ; 0 9719 <1> ; mov al, 4Fh ; ax = 004Fh (successful) 9720 <1> ; retn 9721 <1> 9722 <1> vbe_srs_gbs: 9723 <1> ; return buffer size according to flags 9724 00003B31 89CB <1> mov ebx, ecx ; options/flags 9725 00003B33 D0E3 <1> shl bl, 1 9726 00003B35 668B9B[3D3B0000] <1> mov bx, [ebx+vbestatebufsize] 9727 00003B3C C3 <1> retn 9728 <1> 9729 <1> vbestatebufsize: 9730 <1> ; ---------------------------------------- 9731 <1> ; CL = 0 1 2 3 4 5 6 7 9732 <1> ; ---------------------------------------- 9733 00003B3D 0000460028006E0004- <1> dw 0, 70, 40, 110, 772, 842, 812, 882 9733 00003B46 034A032C037203 <1> 9734 <1> ; ---------------------------------------- 9735 <1> ; CL = 8 9 10 11 12 13 14 15 9736 <1> ; ---------------------------------------- 9737 00003B4D 120058003A00800016- <1> dw 18, 88, 58, 128, 790, 860, 830, 900 9737 00003B56 035C033E038403 <1> 9738 <1> 9739 <1> ; 11/01/2021 9740 <1> VGAREG_ACTL_ADDRESS equ 3C0h 9741 <1> VGAREG_ACTL_WRITE_DATA equ 3C0h 9742 <1> VGAREG_ACTL_READ_DATA equ 3C1h 9743 <1> 9744 <1> VGAREG_INPUT_STATUS equ 3C2h 9745 <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h 9746 <1> VGAREG_VIDEO_ENABLE equ 3C3h 9747 <1> VGAREG_SEQU_ADDRESS equ 3C4h 9748 <1> VGAREG_SEQU_DATA equ 3C5h 9749 <1> 9750 <1> VGAREG_PEL_MASK equ 3C6h 9751 <1> VGAREG_DAC_STATE equ 3C7h 9752 <1> VGAREG_DAC_READ_ADDRESS equ 3C7h 9753 <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h 9754 <1> VGAREG_DAC_DATA equ 3C9h 9755 <1> 9756 <1> VGAREG_READ_FEATURE_CTL equ 3CAh 9757 <1> VGAREG_READ_MISC_OUTPUT equ 3CCh 9758 <1> 9759 <1> VGAREG_GRDC_ADDRESS equ 3CEh 9760 <1> VGAREG_GRDC_DATA equ 3CFh 9761 <1> 9762 <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h 9763 <1> ;VGAREG_MDA_CRTC_DATA equ 3B5h 9764 <1> VGAREG_VGA_CRTC_ADDRESS equ 3D4h 9765 <1> VGAREG_VGA_CRTC_DATA equ 3D5h 9766 <1> 9767 <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh 9768 <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh 9769 <1> VGAREG_ACTL_RESET equ 3DAh 9770 <1> 9771 <1> ;VGAREG_MDA_MODECTL equ 3B8h 9772 <1> VGAREG_CGA_MODECTL equ 3D8h 9773 <1> VGAREG_CGA_PALETTE equ 3D9h 9774 <1> 9775 <1> biosfn_save_video_state: 9776 <1> ; 03/08/2022 (TRDOS 386 v2.0.5) 9777 <1> ; 22/01/2021 9778 <1> ; 12/01/2021 9779 <1> ; 11/01/2021 (TRDOS 386 v2.0.3) 9780 <1> ; (vgabios.c) 9781 <1> 9782 <1> ; modified registers: eax, edx, edi, ch 9783 <1> 9784 <1> ;mov edi, VBE3SAVERESTOREBLOCK 9785 <1> 9786 <1> ; input: edi = state buffer address 9787 <1> 9788 00003B5D F6C101 <1> test cl, 1 9789 00003B60 0F8485000000 <1> jz bfn_svs_4 9790 <1> 9791 00003B66 66BAC403 <1> mov dx, VGAREG_SEQU_ADDRESS ; 3C7h 9792 00003B6A EC <1> in al, dx 9793 00003B6B AA <1> stosb 9794 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 9795 00003B6C B2D4 <1> mov dl, 0D4h 9796 00003B6E EC <1> in al, dx 9797 00003B6F AA <1> stosb 9798 <1> ;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 9799 00003B70 B2CE <1> mov dl, 0CEh 9800 00003B72 EC <1> in al, dx 9801 00003B73 AA <1> stosb 9802 <1> ;mov dx, VGAREG_ACTL_RESET ; 3DAh 9803 00003B74 B2DA <1> mov dl, 0DAh 9804 00003B76 EC <1> in al, dx 9805 <1> ;mov dx, VGAREG_ACTL_ADDRESS ; 3C0h 9806 00003B77 B2C0 <1> mov dl, 0C0h 9807 00003B79 EC <1> in al, dx 9808 00003B7A AA <1> stosb 9809 00003B7B 88C4 <1> mov ah, al ; ar_index 9810 <1> ;mov dx, VGAREG_READ_FEATURE_CTL ; 3CAh 9811 00003B7D B2CA <1> mov dl, 0CAh 9812 00003B7F EC <1> in al, dx 9813 00003B80 AA <1> stosb 9814 <1> ; (5 bytes are writen above) 9815 <1> 9816 <1> ; for(i=1;i<=4;i++){ 9817 00003B81 B001 <1> mov al, 1 9818 <1> ;;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 9819 <1> ;mov dl, 0C4h 9820 00003B83 B504 <1> mov ch, 4 9821 <1> bfn_svs_0: 9822 <1> ; outb(VGAREG_SEQU_ADDRESS, i); 9823 <1> ;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 9824 00003B85 B2C4 <1> mov dl, 0C4h 9825 00003B87 EE <1> out dx, al 9826 <1> ;mov dx, VGAREG_SEQU_DATA ; 3C5h 9827 00003B88 FEC2 <1> inc dl ; dx = 3C5h 9828 <1> ; inb(VGAREG_SEQU_DATA) 9829 00003B8A 50 <1> push eax 9830 00003B8B EC <1> in al, dx 9831 00003B8C AA <1> stosb ; (4 bytes in loop) 9832 00003B8D 58 <1> pop eax 9833 <1> ;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 9834 <1> ;dec dl 9835 00003B8E FEC0 <1> inc al ; i++ 9836 00003B90 FECD <1> dec ch 9837 00003B92 75F1 <1> jnz short bfn_svs_0 9838 <1> 9839 <1> ; outb(VGAREG_SEQU_ADDRESS, 0); 9840 00003B94 28C0 <1> sub al, al ; 0 9841 00003B96 EE <1> out dx, al 9842 <1> ; inb(VGAREG_SEQU_DATA) 9843 <1> ;mov dx, VGAREG_SEQU_DATA ; 3C5h 9844 00003B97 FEC2 <1> inc dl ; dx = 3C5h 9845 00003B99 EC <1> in al, dx 9846 00003B9A AA <1> stosb ; (+1 byte) 9847 <1> 9848 <1> ; for(i=0;i<=0x18;i++) { 9849 00003B9B 28C0 <1> sub al, al ; 0 9850 <1> ;;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 9851 <1> ;mov dl, 0D4h 9852 00003B9D B519 <1> mov ch, 25 9853 <1> bfn_svs_1: 9854 <1> ; outb(crtc_addr,i); 9855 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 9856 00003B9F B2D4 <1> mov dl, 0D4h 9857 00003BA1 EE <1> out dx, al 9858 <1> ;mov dx, VGAREG_VGA_CRTC_DATA ; 3D5h 9859 00003BA2 FEC2 <1> inc dl ; dx = 3D5h 9860 <1> ; inb(crtc_addr+1) 9861 00003BA4 50 <1> push eax 9862 00003BA5 EC <1> in al, dx 9863 00003BA6 AA <1> stosb ; (25 bytes in loop) 9864 00003BA7 58 <1> pop eax 9865 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 9866 <1> ;dec dl 9867 00003BA8 FEC0 <1> inc al ; i++ 9868 00003BAA FECD <1> dec ch 9869 00003BAC 75F1 <1> jnz short bfn_svs_1 9870 <1> 9871 00003BAE 80E420 <1> and ah, 20h ; (ar_index & 0x20) 9872 <1> ; for(i=0;i<=0x13;i++) { 9873 00003BB1 28C0 <1> sub al, al ; 0 9874 00003BB3 B514 <1> mov ch, 20 9875 <1> bfn_svs_2: 9876 <1> ; inb(VGAREG_ACTL_RESET); 9877 <1> ;mov dx, VGAREG_ACTL_RESET ; 3DAh 9878 00003BB5 B2DA <1> mov dl, 0DAh 9879 00003BB7 50 <1> push eax 9880 00003BB8 EC <1> in al, dx 9881 00003BB9 8A0424 <1> mov al, [esp] 9882 <1> ; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20)); 9883 00003BBC 08E0 <1> or al, ah 9884 <1> ;mov dx, VGAREG_ACTL_ADDRESS ; 3C0h 9885 00003BBE B2C0 <1> mov dl, 0C0h 9886 00003BC0 EE <1> out dx, al 9887 <1> ;mov dx, VGAREG_ACTL_READ_DATA ; 3C1h 9888 <1> ;mov dl, 0C1h 9889 00003BC1 FEC2 <1> inc dl 9890 00003BC3 EC <1> in al, dx 9891 00003BC4 AA <1> stosb ; (20 bytes in loop) 9892 00003BC5 58 <1> pop eax 9893 00003BC6 FEC0 <1> inc al ; i++ 9894 00003BC8 FECD <1> dec ch 9895 00003BCA 75E9 <1> jnz short bfn_svs_2 9896 <1> 9897 <1> ; inb(VGAREG_ACTL_RESET); 9898 <1> ;mov dx, VGAREG_ACTL_RESET ; 3DAh 9899 00003BCC B2DA <1> mov dl, 0DAh 9900 00003BCE EC <1> in al, dx 9901 <1> 9902 <1> ; for(i=0;i<=8;i++) { 9903 00003BCF 28C0 <1> sub al, al ; 0 9904 <1> ;;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 9905 <1> ;mov dl, 0CEh 9906 00003BD1 B509 <1> mov ch, 9 9907 <1> bfn_svs_3: 9908 <1> ; outb(VGAREG_GRDC_ADDRESS,i) 9909 <1> ;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 9910 00003BD3 B2CE <1> mov dl, 0CEh 9911 00003BD5 EE <1> out dx, al 9912 <1> ; inb(VGAREG_ACTL_READ_DATA) 9913 00003BD6 50 <1> push eax 9914 <1> ;mov dx, VGAREG_GRDC_DATA ; 3CFh 9915 <1> ;mov dl, 0CFh 9916 00003BD7 FEC2 <1> inc dl 9917 00003BD9 EC <1> in al, dx 9918 00003BDA AA <1> stosb ; (9 bytes in loop) 9919 00003BDB 58 <1> pop eax 9920 <1> ;dec dl 9921 00003BDC FEC0 <1> inc al ; i++ 9922 00003BDE FECD <1> dec ch 9923 00003BE0 75F1 <1> jnz short bfn_svs_3 9924 <1> 9925 <1> ; write_word(ES, BX, crtc_addr); BX+= 2; 9926 <1> ; (offset 64) 9927 00003BE2 66B8D403 <1> mov ax, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 9928 00003BE6 66AB <1> stosw ; (2 bytes (1 word)) 9929 <1> 9930 <1> ; /* XXX: read plane latches */ 9931 00003BE8 31C0 <1> xor eax, eax ; 0 9932 00003BEA AB <1> stosd ; (4 bytes) 9933 <1> 9934 <1> ; (total 70 bytes are written above as controller hardware state) 9935 <1> 9936 <1> bfn_svs_4: 9937 <1> ; 12/01/2021 (TRDOS 386 v2.0.3) 9938 00003BEB F6C102 <1> test cl, 2 9939 00003BEE 7476 <1> jz short bfn_svs_6 9940 <1> 9941 <1> ; VIDEO BIOS DATA 9942 <1> ; !!! this data is valid for TRDOS 386 v2 kernel only !!! 9943 <1> ; (this is not same with BOCHS/PLEX86 video bios, BIOS data) 9944 <1> 9945 <1> ; if (CX & 2) { 9946 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++; 9947 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2; 9948 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2; 9949 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2; 9950 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++; 9951 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2; 9952 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++; 9953 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++; 9954 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++; 9955 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2; 9956 <1> ;for(i=0;i<8;i++) { 9957 <1> ; write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i)); 9958 <1> ; BX += 2; 9959 <1> ;} 9960 <1> ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2; 9961 <1> ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++; 9962 <1> ;/* current font */ 9963 <1> ;write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2; 9964 <1> ;write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2; 9965 <1> ;write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2; 9966 <1> ;write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2; 9967 <1> 9968 <1> ; !!! save TRDOS 386 v2 kernel spesific video bios data !!! 9969 <1> ; (which is/are used by 'SET_MODE' function and/or it's sub functions) 9970 <1> 9971 00003BF0 66B8D403 <1> mov ax, 3D4h ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2 9972 00003BF4 66AB <1> stosw 9973 00003BF6 A0[DE670000] <1> mov al, [CRT_MODE] ; Current video mode (0FFh for VESA VBE modes) 9974 00003BFB AA <1> stosb 9975 00003BFC A0[DF670000] <1> mov al, [CRT_MODE_SET] ; 29h for mode 03h ; TRDOS 386 feature only ! 9976 00003C01 AA <1> stosb 9977 00003C02 66A1[2EA30100] <1> mov ax, [video_mode] ; Current VESA VBE (SVGA, extended VGA) mode 9978 00003C08 66AB <1> stosw ; (valid if [CRT_MODE] = 0FFh) 9979 00003C0A 66A1[54890100] <1> mov ax, [CRT_LEN] ; page size (in bytes) 9980 00003C10 66AB <1> stosw 9981 00003C12 66A1[DC7C0100] <1> mov ax, [CRT_START] ; video page start offset 9982 00003C18 66AB <1> stosw 9983 00003C1A A0[E0670000] <1> mov al, [CRT_COLS] ; nbcols, characters per row 9984 00003C1F AA <1> stosb 9985 00003C20 A0[E6670000] <1> mov al, [VGA_ROWS] ; nbrows, (character) rows per page (not rows-1) 9986 00003C25 AA <1> stosb 9987 00003C26 A0[E2670000] <1> mov al, [CHAR_HEIGHT] ; character font height (8 or 16 or 14) 9988 00003C2B AA <1> stosb 9989 00003C2C A0[E3670000] <1> mov al, [VGA_VIDEO_CTL] ; ROM BIOS DATA AREA Offset 87h 9990 00003C31 AA <1> stosb 9991 00003C32 A0[E4670000] <1> mov al, [VGA_SWITCHES] ; feature bit switches 9992 00003C37 AA <1> stosb 9993 00003C38 A0[E5670000] <1> mov al, [VGA_MODESET_CTL] ; basic mode set options 9994 00003C3D AA <1> stosb 9995 <1> ; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 9996 <1> ; (bochs/plex86 does not use and return those) 9997 00003C3E A0[E1670000] <1> mov al, [CRT_PALETTE] ; current color palette ; TRDOS 386 feature only ! 9998 00003C43 AA <1> stosb 9999 00003C44 A0[EE7C0100] <1> mov al, [ACTIVE_PAGE] ; current video page 10000 00003C49 AA <1> stosb 10001 00003C4A 66A1[F7670000] <1> mov ax, [CURSOR_MODE] ; cursor type 10002 00003C50 66AB <1> stosw 10003 <1> ;mov eax, [CURSOR_POSN] ; cursor position for video page 0 and 1 10004 <1> ;stosd 10005 <1> ;mov eax, [CURSOR_POSN+4] ; cursor position for video page 2 and 3 10006 <1> ;stosd 10007 <1> ;mov eax, [CURSOR_POSN+8] ; cursor position for video page 4 and 5 10008 <1> ;stosd 10009 <1> ;mov eax, [CURSOR_POSN+12] ; cursor position for video page 6 and 7 10010 <1> ;stosd 10011 00003C52 56 <1> push esi 10012 00003C53 B504 <1> mov ch, 4 10013 00003C55 BE[DE7C0100] <1> mov esi, CURSOR_POSN 10014 <1> bfn_svs_5: 10015 00003C5A A5 <1> movsd 10016 00003C5B FECD <1> dec ch 10017 00003C5D 75FB <1> jnz short bfn_svs_5 10018 00003C5F 5E <1> pop esi 10019 <1> ; (font addr) protected mode address in kernel's/system memory space 10020 <1> ; (not accessable/meaningful address value by user) 10021 00003C60 A1[66890100] <1> mov eax, [VGA_INT43H] ; VGA current (default) font address 10022 00003C65 AB <1> stosd 10023 <1> 10024 <1> ; (total 40 bytes are written above as BIOS data state) 10025 <1> 10026 <1> bfn_svs_6: 10027 <1> ; 12/01/2021 10028 00003C66 F6C104 <1> test cl, 4 10029 00003C69 7422 <1> jz short bfn_svs_8 10030 <1> 10031 <1> ;/* XXX: check this */ 10032 <1> ; /* read/write mode dac */ 10033 <1> ;write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++; 10034 <1> ; ; /* pix address */ 10035 <1> ;write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++; 10036 <1> ;write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++; 10037 <1> ;// Set the whole dac always, from 0 10038 <1> ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00); 10039 <1> ;for(i=0;i<256*3;i++) { 10040 <1> ; write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++; 10041 <1> ;} 10042 <1> ;write_byte(ES, BX, 0); BX++; /* color select register */ 10043 <1> 10044 <1> ; /* read/write mode dac */ 10045 00003C6B 66BAC703 <1> mov dx, 3C7h ; VGAREG_DAC_STATE 10046 00003C6F EC <1> in al, dx 10047 00003C70 AA <1> stosb 10048 <1> ; /* pix address */ 10049 <1> ;mov dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h 10050 <1> ;mov dl, 0C8h 10051 00003C71 FEC2 <1> inc dl 10052 00003C73 EC <1> in al, dx 10053 00003C74 AA <1> stosb 10054 <1> ;mov dx, VGAREG_PEL_MASK ; 3C6h 10055 00003C75 B2C6 <1> mov dl, 0C6h 10056 00003C77 EC <1> in al, dx 10057 00003C78 AA <1> stosb 10058 <1> ;// Set the whole dac always, from 0 10059 00003C79 30C0 <1> xor al, al ; 0 10060 <1> ;mov dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h 10061 00003C7B B2C8 <1> mov dl, 0C8h 10062 00003C7D EE <1> out dx, al 10063 <1> 10064 00003C7E 51 <1> push ecx ; 22/01/2021 10065 <1> ;for(i=0;i<256*3;i++) { 10066 <1> ;mov ecx, 256*3 ; 768 bytes 10067 <1> ; 03/08/2022 10068 00003C7F 29C9 <1> sub ecx, ecx 10069 00003C81 B503 <1> mov ch, 3 10070 <1> ; ecx = 300h = 768 10071 <1> ;mov dx, VGAREG_DAC_DATA ; 3C9h 10072 <1> ;mov dl, 0C9h 10073 00003C83 FEC2 <1> inc dl ; dx = 3C9h 10074 <1> bfn_svs_7: 10075 00003C85 EC <1> in al, dx 10076 00003C86 AA <1> stosb 10077 00003C87 E2FC <1> loop bfn_svs_7 10078 00003C89 59 <1> pop ecx ; 22/01/2021 10079 <1> 10080 <1> ; /* color select register */ 10081 00003C8A 28C0 <1> sub al, al ; 0 10082 00003C8C AA <1> stosb 10083 <1> 10084 <1> ; (total 772 bytes are written above as DAC state) 10085 <1> bfn_svs_8: 10086 00003C8D C3 <1> retn 10087 <1> 10088 <1> vbe_biosfn_save_video_state: 10089 <1> ; 23/01/2021 10090 <1> ; 13/01/2021 10091 <1> ; 12/01/2021 (TRDOS 386 v2.0.3) 10092 <1> ; (vbe.c) 10093 <1> 10094 <1> ; modified registers: eax, edx, edi, ch 10095 <1> 10096 <1> ; input: edi = state buffer address 10097 <1> ; output: 10098 <1> ; VBE DISPI register contents will be saved 10099 <1> ; (18 bytes, 9 words) 10100 <1> 10101 <1> ; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 10102 <1> ; enable = inw(VBE_DISPI_IOPORT_DATA); 10103 <1> ; write_word(ES, BX, enable); 10104 <1> ; BX += 2; 10105 <1> ; if (!(enable & VBE_DISPI_ENABLED)) 10106 <1> ; return; 10107 <1> ; for(i = VBE_DISPI_INDEX_XRES; 10108 <1> ; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 10109 <1> ; if (i != VBE_DISPI_INDEX_ENABLE) { 10110 <1> ; outw(VBE_DISPI_IOPORT_INDEX, i); 10111 <1> ; write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA)); 10112 <1> ; BX += 2; 10113 <1> ; } 10114 <1> ; } 10115 <1> 10116 00003C8E 66BACE01 <1> mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10117 <1> ;mov eax, 04h ; VBE_DISPI_INDEX_ENABLE 10118 <1> ;03/08/2022 10119 00003C92 66EF <1> out dx, ax 10120 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10121 00003C94 FEC2 <1> inc dl 10122 00003C96 66ED <1> in ax, dx ; enable (status) 10123 00003C98 66AB <1> stosw 10124 00003C9A 6683E001 <1> and ax, 1 ; VBE_DISPI_ENABLED 10125 00003C9E 7505 <1> jnz short vbe_bfn_svs_0 10126 <1> ; 23/01/2021 10127 <1> ; ax = 0 10128 <1> ; VBE_DISPI_DISABLED 10129 <1> ; 13/01/2021 10130 <1> ; clear remain 8 bytes 10131 <1> ;xor eax, eax 10132 00003CA0 AB <1> stosd ; 2 10133 00003CA1 AB <1> stosd ; 2 10134 00003CA2 AB <1> stosd ; 2 10135 00003CA3 AB <1> stosd ; 2 10136 00003CA4 C3 <1> retn 10137 <1> vbe_bfn_svs_0: 10138 <1> ; VBE_DISPI_ENABLED 10139 <1> 10140 <1> ;sub eax, eax 10141 00003CA5 28C0 <1> sub al, al ; eax = 0 10142 <1> 10143 <1> ; from VBE_DISPI_INDEX_XRES 10144 <1> ; to VBE_DISPI_INDEX_BPP 10145 <1> 10146 00003CA7 B503 <1> mov ch, 3 10147 <1> ; al = 0 ; VBE_DISPI_INDEX_XRES - 1 10148 <1> 10149 00003CA9 E804000000 <1> call vbe_bfn_svs_1 10150 <1> 10151 <1> ; from VBE_DISPI_INDEX_BANK 10152 <1> ; to VBE_DISPI_INDEX_Y_OFFSET 10153 <1> 10154 00003CAE FEC0 <1> inc al 10155 <1> ; al = 4 ; VBE_DISPI_INDEX_BANK - 1 10156 <1> 10157 00003CB0 B505 <1> mov ch, 5 10158 <1> vbe_bfn_svs_1: 10159 00003CB2 FEC0 <1> inc al ; from VBE_DISPI_INDEX_XRES 10160 <1> ; to VBE_DISPI_INDEX_BPP 10161 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10162 00003CB4 FECA <1> dec dl ; 1CEh 10163 00003CB6 66EF <1> out dx, ax 10164 00003CB8 50 <1> push eax 10165 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10166 00003CB9 FEC2 <1> inc dl ; 1CFh 10167 00003CBB 66ED <1> in ax, dx 10168 00003CBD 66AB <1> stosw 10169 00003CBF 58 <1> pop eax 10170 00003CC0 FECD <1> dec ch 10171 00003CC2 75EE <1> jnz short vbe_bfn_svs_1 10172 00003CC4 C3 <1> retn 10173 <1> 10174 <1> biosfn_restore_video_state: 10175 <1> ; 22/01/2021 10176 <1> ; 13/01/2021 10177 <1> ; 12/01/2021 (TRDOS 386 v2.0.3) 10178 <1> ; (vgabios.c) 10179 <1> 10180 <1> ; modified registers: eax, edx, esi, edi, ch 10181 <1> 10182 <1> ;mov esi, VBE3SAVERESTOREBLOCK 10183 <1> 10184 <1> ; input: esi = state buffer address 10185 <1> 10186 00003CC5 F6C101 <1> test cl, 1 10187 00003CC8 0F84A9000000 <1> jz bfn_rvs_6 10188 <1> 10189 00003CCE 66817E40D403 <1> cmp word [esi+64], 3D4h ; must be 3D4h 10190 00003CD4 7402 <1> je short bfn_rvs_0 10191 <1> ; it is seen as valid buffer 10192 00003CD6 F9 <1> stc 10193 00003CD7 C3 <1> retn 10194 <1> 10195 <1> bfn_rvs_0: 10196 00003CD8 89F7 <1> mov edi, esi ; addr1 10197 00003CDA 83C605 <1> add esi, 5 ; skip 1st 5 bytes for now 10198 <1> 10199 <1> ; // Reset Attribute Ctl flip-flop 10200 <1> ; inb(VGAREG_ACTL_RESET); 10201 00003CDD 66BADA03 <1> mov dx, 3DAh ; VGAREG_ACTL_RESET 10202 00003CE1 EC <1> in al, dx 10203 <1> 10204 <1> ; for(i=1;i<=4;i++){ 10205 00003CE2 B001 <1> mov al, 1 10206 <1> ;;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 10207 <1> ;mov dl, 0C4h 10208 00003CE4 B504 <1> mov ch, 4 10209 <1> bfn_rvs_1: 10210 <1> ; outb(VGAREG_SEQU_ADDRESS, i); 10211 <1> ;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 10212 00003CE6 B2C4 <1> mov dl, 0C4h 10213 00003CE8 EE <1> out dx, al 10214 <1> ;mov dx, VGAREG_SEQU_DATA ; 3C5h 10215 00003CE9 FEC2 <1> inc dl ; dx = 3C5h 10216 <1> ; outb(VGAREG_SEQU_DATA) 10217 00003CEB 50 <1> push eax 10218 00003CEC AC <1> lodsb ; (4 bytes in loop) 10219 00003CED EE <1> out dx, al 10220 00003CEE 58 <1> pop eax 10221 <1> ;mov dx, VGAREG_SEQU_ADDRESS ; 3C4h 10222 <1> ;dec dl 10223 00003CEF FEC0 <1> inc al ; i++ 10224 00003CF1 FECD <1> dec ch 10225 00003CF3 75F1 <1> jnz short bfn_rvs_1 10226 <1> 10227 <1> ; outb(VGAREG_SEQU_ADDRESS, 0); 10228 00003CF5 28C0 <1> sub al, al ; 0 10229 00003CF7 EE <1> out dx, al 10230 <1> ; outb(VGAREG_SEQU_DATA) 10231 <1> ;mov dx, VGAREG_SEQU_DATA ; 3C5h 10232 00003CF8 FEC2 <1> inc dl ; dx = 3C5h 10233 00003CFA AC <1> lodsb ; (+1 byte) 10234 00003CFB EE <1> out dx, al 10235 <1> 10236 <1> ; // Disable CRTC write protection 10237 <1> ; outw(crtc_addr,0x0011); 10238 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10239 00003CFC B2D4 <1> mov dl, 0D4h 10240 00003CFE 66B81100 <1> mov ax, 11h 10241 00003D02 66EF <1> out dx, ax 10242 <1> 10243 <1> ; // Set CRTC regs 10244 <1> 10245 <1> ; for(i=0;i<=0x18;i++) { 10246 <1> ; if (i != 0x11) { 10247 00003D04 28C0 <1> sub al, al ; 0 10248 <1> ;;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10249 <1> ;mov dl, 0D4h 10250 00003D06 B519 <1> mov ch, 25 10251 <1> bfn_rvs_2: 10252 <1> ; outb(crtc_addr,i); 10253 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10254 00003D08 B2D4 <1> mov dl, 0D4h 10255 00003D0A EE <1> out dx, al 10256 <1> ;mov dx, VGAREG_VGA_CRTC_DATA ; 3D5h 10257 00003D0B FEC2 <1> inc dl ; dx = 3D5h 10258 <1> ; inb(crtc_addr+1) 10259 00003D0D 50 <1> push eax 10260 00003D0E AC <1> lodsb ; (25 bytes in loop) 10261 00003D0F EE <1> out dx, al 10262 00003D10 58 <1> pop eax 10263 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10264 <1> ;dec dl 10265 00003D11 FEC0 <1> inc al ; i++ 10266 00003D13 3C11 <1> cmp al, 17 ; 11h 10267 00003D15 7505 <1> jne short bfn_rvs_3 10268 00003D17 AC <1> lodsb 10269 00003D18 88C4 <1> mov ah, al ; * 10270 00003D1A B012 <1> mov al, 18 10271 <1> bfn_rvs_3: 10272 00003D1C FECD <1> dec ch 10273 00003D1E 75E8 <1> jnz short bfn_rvs_2 10274 <1> 10275 <1> ; // select crtc base address 10276 <1> ; v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01; 10277 <1> ;if (crtc_addr = 0x3d4) 10278 <1> ; v |= 0x01; 10279 <1> ; outb(VGAREG_WRITE_MISC_OUTPUT, v); 10280 <1> 10281 <1> ;;mov dx, VGAREG_READ_MISC_OUTPUT ; 3CCh 10282 <1> ;mov dl, 0CCh 10283 <1> ;in al, dl 10284 <1> ;and al, 1 10285 <1> ;;mov dx, VGAREG_WRITE_MISC_OUTPUT ; 3C2h 10286 <1> ;mov dl, 0C2h 10287 <1> ;or al, 1 10288 <1> ;out dx, al 10289 <1> 10290 <1> ; // enable write protection if needed 10291 <1> ;outb(crtc_addr, 0x11); 10292 <1> ;outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11)); 10293 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10294 00003D20 B2D4 <1> mov dl, 0D4h 10295 00003D22 B011 <1> mov al, 11h 10296 00003D24 EE <1> out dx, al 10297 00003D25 88E0 <1> mov al, ah ; * 10298 00003D27 FEC2 <1> inc dl ; dx = 3D5h 10299 00003D29 EE <1> out dx, al 10300 <1> 10301 <1> ; // Set Attribute Ctl 10302 00003D2A 8A6703 <1> mov ah, [edi+3] ; addr1+3, ah = ar_index 10303 00003D2D 80E420 <1> and ah, 20h ; (ar_index & 0x20) 10304 <1> 10305 <1> ; inb(VGAREG_ACTL_RESET); 10306 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 10307 00003D30 B2DA <1> mov dl, 0DAh 10308 00003D32 EC <1> in al, dx 10309 <1> 10310 <1> ; for(i=0;i<=0x13;i++) { 10311 00003D33 28C0 <1> sub al, al ; 0 10312 00003D35 B514 <1> mov ch, 20 10313 <1> bfn_rvs_4: 10314 <1> ; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20)); 10315 00003D37 50 <1> push eax 10316 00003D38 08E0 <1> or al, ah 10317 <1> ;mov dx, VGAREG_ACTL_ADDRESS ; 3C0h 10318 00003D3A B2C0 <1> mov dl, 0C0h 10319 00003D3C EE <1> out dx, al 10320 <1> ;mov dx, VGAREG_ACTL_WRITE_DATA ; 3C0h 10321 <1> ;mov dl, 0C0h 10322 00003D3D AC <1> lodsb ; (20 bytes in loop) 10323 00003D3E EE <1> out dx, al 10324 00003D3F 58 <1> pop eax 10325 00003D40 FEC0 <1> inc al ; i++ 10326 00003D42 FECD <1> dec ch 10327 00003D44 75F1 <1> jnz short bfn_rvs_4 10328 <1> 10329 <1> ; outb(VGAREG_ACTL_ADDRESS, ar_index); 10330 <1> ;mov dx, VGAREG_ACTL_ADDRESS ; 3C0h 10331 <1> ;mov dl, 0C0h 10332 00003D46 88E0 <1> mov al, ah ; ar_index 10333 00003D48 EE <1> out dx, al 10334 <1> 10335 <1> ; inb(VGAREG_ACTL_RESET); 10336 <1> ;mov dx, VGAREG_ACTL_RESET ; 3DAh 10337 00003D49 B2DA <1> mov dl, 0DAh 10338 00003D4B EC <1> in al, dx 10339 <1> 10340 <1> ; for(i=0;i<=8;i++) { 10341 00003D4C 28C0 <1> sub al, al ; 0 10342 <1> ;;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 10343 <1> ;mov dl, 0CEh 10344 00003D4E B509 <1> mov ch, 9 10345 <1> bfn_rvs_5: 10346 <1> ; outb(VGAREG_GRDC_ADDRESS,i) 10347 <1> ;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 10348 00003D50 B2CE <1> mov dl, 0CEh 10349 00003D52 EE <1> out dx, al 10350 <1> ; outb(VGAREG_ACTL_READ_DATA) 10351 00003D53 50 <1> push eax 10352 <1> ;mov dx, VGAREG_GRDC_DATA ; 3CFh 10353 <1> ;mov dl, 0CFh 10354 00003D54 FEC2 <1> inc dl 10355 00003D56 AC <1> lodsb ; (9 bytes in loop) 10356 00003D57 EE <1> out dx, al 10357 00003D58 58 <1> pop eax 10358 <1> ;dec dl 10359 00003D59 FEC0 <1> inc al ; i++ 10360 00003D5B FECD <1> dec ch 10361 00003D5D 75F1 <1> jnz short bfn_rvs_5 10362 <1> 10363 <1> ; BX += 2; /* crtc_addr */ ; 3D4h 10364 <1> ; BX += 4; /* plane latches */ ; 0 10365 00003D5F 83C606 <1> add esi, 6 10366 00003D62 56 <1> push esi ; * 10367 <1> 10368 <1> ;outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++; 10369 <1> ;outb(crtc_addr, read_byte(ES, addr1)); addr1++; 10370 <1> ;outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++; 10371 <1> ;addr1++; 10372 <1> ;outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++; 10373 <1> 10374 00003D63 89FE <1> mov esi, edi ; start of state buffer 10375 <1> 10376 <1> ;mov dx, VGAREG_SEQU_ADDRESS ; 3C7h 10377 00003D65 B2C7 <1> mov dl, 0C7h 10378 00003D67 AC <1> lodsb 10379 00003D68 EE <1> out dx, al 10380 <1> ;mov dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h 10381 00003D69 B2D4 <1> mov dl, 0D4h 10382 00003D6B AC <1> lodsb 10383 00003D6C EE <1> out dx, al 10384 <1> ;mov dx, VGAREG_GRDC_ADDRESS ; 3CEh 10385 00003D6D B2CE <1> mov dl, 0CEh 10386 00003D6F AC <1> lodsb 10387 00003D70 EE <1> out dx, al 10388 00003D71 AC <1> lodsb ; addr1++ 10389 <1> ;mov dx, VGAREG_VGA_WRITE_FEATURE_CTL ; 3DAh 10390 00003D72 B2DA <1> mov dl, 0DAh 10391 00003D74 AC <1> lodsb 10392 00003D75 EE <1> out dx, al 10393 <1> 10394 00003D76 5E <1> pop esi ; * 10395 <1> 10396 <1> ; (total 70 bytes are read above as controller hardware state) 10397 <1> 10398 <1> bfn_rvs_6: 10399 <1> ; 13/01/2021 10400 00003D77 F6C102 <1> test cl, 2 10401 00003D7A 747D <1> jz short bfn_rvs_9 10402 <1> 10403 <1> ; VIDEO BIOS DATA 10404 <1> ; !!! this data is valid for TRDOS 386 v2 kernel only !!! 10405 <1> ; (this is not same with BOCHS/PLEX86 video bios, BIOS data) 10406 <1> 10407 <1> ; if (CX & 2) { 10408 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++; 10409 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2; 10410 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2; 10411 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2; 10412 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++; 10413 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2; 10414 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++; 10415 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++; 10416 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++; 10417 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2; 10418 <1> ;for(i=0;i<8;i++) { 10419 <1> ; write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX)); 10420 <1> ; BX += 2; 10421 <1> ;} 10422 <1> ;write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2; 10423 <1> ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++; 10424 <1> ;/* current font */ 10425 <1> ;write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2; 10426 <1> ;write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2; 10427 <1> ;write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2; 10428 <1> ;write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2; 10429 <1> 10430 <1> ; !!! save TRDOS 386 v2 kernel spesific video bios data !!! 10431 <1> ; (which is/are used by 'SET_MODE' function and/or it's sub functions) 10432 <1> 10433 00003D7C 66AD <1> lodsw ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2 10434 <1> ; skip 3D4h check if it is already checked 10435 00003D7E F6C101 <1> test cl, 1 10436 00003D81 7508 <1> jnz short bfn_rvs_7 10437 00003D83 663DD403 <1> cmp ax, 3D4h 10438 00003D87 7402 <1> je short bfn_rvs_7 10439 00003D89 F9 <1> stc 10440 00003D8A C3 <1> retn 10441 <1> bfn_rvs_7: 10442 00003D8B AC <1> lodsb 10443 00003D8C A2[DE670000] <1> mov [CRT_MODE], al ; Current video mode (0FFh for VESA VBE modes) 10444 00003D91 AC <1> lodsb 10445 00003D92 A2[DF670000] <1> mov [CRT_MODE_SET], al ; 29h for mode 03h ; TRDOS 386 feature only ! 10446 00003D97 66AD <1> lodsw 10447 00003D99 66A3[2EA30100] <1> mov [video_mode], ax ; Current VESA VBE (SVGA, extended VGA) mode 10448 00003D9F 66AD <1> lodsw ; (valid if [CRT_MODE] = 0FFh) 10449 00003DA1 66A3[54890100] <1> mov [CRT_LEN], ax ; page size (in bytes) 10450 00003DA7 66AD <1> lodsw 10451 00003DA9 66A3[DC7C0100] <1> mov [CRT_START], ax ; video page start offset 10452 00003DAF AC <1> lodsb 10453 00003DB0 A2[E0670000] <1> mov [CRT_COLS], al ; nbcols, characters per row 10454 00003DB5 AC <1> lodsb 10455 00003DB6 A2[E6670000] <1> mov [VGA_ROWS], al ; nbrows, (character) rows per page (not rows-1) 10456 00003DBB AC <1> lodsb 10457 00003DBC A2[E2670000] <1> mov [CHAR_HEIGHT], al ; character font height (8 or 16 or 14) 10458 00003DC1 AC <1> lodsb 10459 00003DC2 A2[E3670000] <1> mov [VGA_VIDEO_CTL], al ; ROM BIOS DATA AREA Offset 87h 10460 00003DC7 AC <1> lodsb 10461 00003DC8 A2[E4670000] <1> mov [VGA_SWITCHES], al ; feature bit switches 10462 00003DCD AC <1> lodsb 10463 00003DCE A2[E5670000] <1> mov [VGA_MODESET_CTL], al ; basic mode set options 10464 <1> ; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 10465 <1> ; (bochs/plex86 does not use and return those) 10466 00003DD3 AC <1> lodsb 10467 00003DD4 A2[E1670000] <1> mov [CRT_PALETTE], al ; current color palette ; TRDOS 386 feature only ! 10468 00003DD9 AC <1> lodsb 10469 00003DDA A2[EE7C0100] <1> mov [ACTIVE_PAGE], al ; current video page 10470 00003DDF 66AD <1> lodsw 10471 00003DE1 66A3[F7670000] <1> mov [CURSOR_MODE], ax ; cursor type 10472 <1> ;lodsd 10473 <1> ;mov [CURSOR_POSN], eax ; cursor position for video page 0 and 1 10474 <1> ;lodsd 10475 <1> ;mov [CURSOR_POSN+4], eax ; cursor position for video page 2 and 3 10476 <1> ;lodsd 10477 <1> ;mov [CURSOR_POSN+8], eax ; cursor position for video page 4 and 5 10478 <1> ;lodsd 10479 <1> ;mov [CURSOR_POSN+12], eax ; cursor position for video page 6 and 7 10480 00003DE7 B504 <1> mov ch, 4 10481 00003DE9 BF[DE7C0100] <1> mov edi, CURSOR_POSN 10482 <1> bfn_rvs_8: 10483 00003DEE A5 <1> movsd 10484 00003DEF FECD <1> dec ch 10485 00003DF1 75FB <1> jnz short bfn_rvs_8 10486 <1> ; (font addr) protected mode address in kernel's/system memory space 10487 <1> ; (not accessable/meaningful address value by user) 10488 00003DF3 AD <1> lodsd 10489 00003DF4 A3[66890100] <1> mov [VGA_INT43H], eax ; VGA current (default) font address 10490 <1> 10491 <1> ; (total 40 bytes are read&written above as BIOS data state) 10492 <1> bfn_rvs_9: 10493 <1> ; 13/01/2021 10494 00003DF9 F6C104 <1> test cl, 4 10495 00003DFC 7421 <1> jz short bfn_rvs_11 10496 <1> 10497 <1> ;BX++; 10498 <1> ;v = read_byte(ES, BX); BX++; 10499 <1> ;outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++; 10500 <1> ;// Set the whole dac always, from 0 10501 <1> ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00); 10502 <1> ;for(i=0;i<256*3;i++) { 10503 <1> ; outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++; 10504 <1> ;} 10505 <1> ;BX++; 10506 <1> ;outb(VGAREG_DAC_WRITE_ADDRESS, v); 10507 <1> 10508 <1> ; /* read/write mode dac */ 10509 00003DFE AC <1> lodsb ; skip ; VGAREG_DAC_STATE 10510 00003DFF AC <1> lodsb 10511 00003E00 88C4 <1> mov ah, al ; * ; v 10512 00003E02 AC <1> lodsb 10513 00003E03 66BAC603 <1> mov dx, VGAREG_PEL_MASK ; 3C6h 10514 00003E07 EE <1> out dx, al 10515 <1> ;// Set the whole dac always, from 0 10516 00003E08 30C0 <1> xor al, al ; 0 10517 <1> ;mov dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h 10518 00003E0A B2C8 <1> mov dl, 0C8h 10519 00003E0C EE <1> out dx, al 10520 <1> 10521 00003E0D 51 <1> push ecx ; 22/01/2021 10522 <1> ;for(i=0;i<256*3;i++) { 10523 <1> ;mov ecx, 256*3 ; 768 bytes 10524 <1> ; 03/08/2022 10525 00003E0E 29C9 <1> sub ecx, ecx 10526 00003E10 B503 <1> mov ch, 3 10527 <1> ; ecx = 300h = 768 10528 <1> ;mov dx, VGAREG_DAC_DATA ; 3C9h 10529 <1> ;mov dl, 0C9h 10530 00003E12 FEC2 <1> inc dl ; dx = 3C9h 10531 <1> bfn_rvs_10: 10532 00003E14 AC <1> lodsb 10533 00003E15 EE <1> out dx, al 10534 00003E16 E2FC <1> loop bfn_rvs_10 10535 00003E18 59 <1> pop ecx ; 22/01/2021 10536 <1> 10537 <1> ; /* color select register */ 10538 00003E19 AC <1> lodsb ; skip 10539 <1> 10540 00003E1A 88E0 <1> mov al, ah ; * ; v 10541 <1> 10542 <1> ;mov dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h 10543 <1> ;mov dl, 0C8h 10544 00003E1C FECA <1> dec dl ; dx = 3C8h 10545 00003E1E EE <1> out dx, al ; * ; v 10546 <1> 10547 <1> ; (total 772 bytes are read above as DAC state) 10548 <1> bfn_rvs_11: 10549 00003E1F C3 <1> retn 10550 <1> 10551 <1> vbe_biosfn_restore_video_state: 10552 <1> ; 23/01/2021 10553 <1> ; 13/01/2021 (TRDOS 386 v2.0.3) 10554 <1> ; (vbe.c) 10555 <1> 10556 <1> ; modified registers: eax, edx, esi, ch 10557 <1> 10558 <1> ; input: esi = state buffer address 10559 <1> ; output: 10560 <1> ; VBE DISPI register contents will be restored 10561 <1> ; (18 bytes, 9 words) 10562 <1> 10563 <1> ; enable = read_word(ES, BX); 10564 <1> ; BX += 2; 10565 <1> ; 10566 <1> ; if (!(enable & VBE_DISPI_ENABLED)) { 10567 <1> ; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 10568 <1> ; outw(VBE_DISPI_IOPORT_DATA, enable); 10569 <1> ; } else { 10570 <1> ; outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 10571 <1> ; outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 10572 <1> ; BX += 2; 10573 <1> ; outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 10574 <1> ; outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 10575 <1> ; BX += 2; 10576 <1> ; outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 10577 <1> ; outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 10578 <1> ; BX += 2; 10579 <1> ; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 10580 <1> ; outw(VBE_DISPI_IOPORT_DATA, enable); 10581 <1> ; 10582 <1> ; for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) 10583 <1> ; { 10584 <1> ; outw(VBE_DISPI_IOPORT_INDEX, i); 10585 <1> ; outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 10586 <1> ; BX += 2; 10587 <1> ; } 10588 <1> ; } 10589 <1> 10590 00003E20 66AD <1> lodsw ; enable (status, enabled=1, disabled=0) 10591 00003E22 66BACE01 <1> mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10592 <1> ; 23/01/2021 10593 00003E26 6683E001 <1> and ax, 1 ; VBE_DISPI_ENABLED 10594 00003E2A 750B <1> jnz short vbe_bfn_rvs_1 10595 <1> ; ax = 0 10596 <1> ; VBE_DISPI_DISABLED 10597 <1> vbe_bfn_rvs_0: 10598 <1> ; enable (disable) dispi 10599 <1> ; dx = 01CEh ; VBE_DISPI_IOPORT_INDEX 10600 <1> ; ah = 0 10601 00003E2C 50 <1> push eax 10602 00003E2D B004 <1> mov al, 04h ; VBE_DISPI_INDEX_ENABLE 10603 00003E2F 66EF <1> out dx, ax 10604 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10605 00003E31 FEC2 <1> inc dl 10606 00003E33 58 <1> pop eax 10607 00003E34 66EF <1> out dx, ax ; enable (or disable) 10608 00003E36 C3 <1> retn 10609 <1> vbe_bfn_rvs_1: 10610 <1> ; VBE_DISPI_ENABLED 10611 <1> 10612 <1> ; from VBE_DISPI_INDEX_XRES 10613 <1> ; to VBE_DISPI_INDEX_BPP 10614 <1> 10615 00003E37 B503 <1> mov ch, 3 10616 00003E39 28C0 <1> sub al, al ; 0 ; VBE_DISPI_INDEX_XRES - 1 10617 <1> ; ax = 0 10618 <1> 10619 00003E3B E80B000000 <1> call vbe_bfn_rvs_2 10620 <1> 10621 <1> ;outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 10622 <1> ;outw(VBE_DISPI_IOPORT_DATA, enable); 10623 <1> 10624 <1> ; 23/01/2021 10625 00003E40 B001 <1> mov al, 1 ; VBE_DISPI_ENABLED 10626 <1> ; ax = 1 10627 00003E42 E8E5FFFFFF <1> call vbe_bfn_rvs_0 10628 <1> 10629 <1> ; from VBE_DISPI_INDEX_BANK 10630 <1> ; to VBE_DISPI_INDEX_Y_OFFSET 10631 <1> 10632 00003E47 B505 <1> mov ch, 5 10633 <1> ; 23/01/2021 10634 00003E49 B004 <1> mov al, 4 ; VBE_DISPI_INDEX_BANK - 1 10635 <1> ; ax = 4 10636 <1> vbe_bfn_rvs_2: 10637 00003E4B FEC0 <1> inc al ; from VBE_DISPI_INDEX_XRES 10638 <1> ; to VBE_DISPI_INDEX_BPP 10639 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10640 <1> ;mov dl, 0CEh 10641 00003E4D 66EF <1> out dx, ax 10642 00003E4F 50 <1> push eax 10643 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10644 00003E50 FEC2 <1> inc dl ; 1CFh 10645 00003E52 66AD <1> lodsw 10646 00003E54 66EF <1> out dx, ax 10647 00003E56 58 <1> pop eax 10648 00003E57 FECA <1> dec dl ; 1CEh 10649 00003E59 FECD <1> dec ch 10650 00003E5B 75EE <1> jnz short vbe_bfn_rvs_2 10651 00003E5D C3 <1> retn 10652 <1> 10653 <1> ; --------------------------------------------------------- 10654 <1> 10655 <1> dispi_set_enable: 10656 <1> ; 03/08/2022 10657 <1> ; 23/11/2020 10658 <1> ; Input: 10659 <1> ; ax = VBE_DISPI_ENABLED = 1 10660 <1> ; or VBE_DISPI_DISABLED = 0 10661 <1> ; 10662 <1> ; Modified registers: none 10663 <1> 10664 <1> ;push edx 10665 <1> ;push eax 10666 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10667 <1> ;mov ax, 04h ; VBE_DISPI_INDEX_ENABLE 10668 <1> ;out dx, ax 10669 <1> ;pop eax 10670 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10671 <1> ;;mov dl, 0CFh 10672 <1> ;inc dl 10673 <1> ;out dx, ax 10674 <1> ;pop edx 10675 <1> ;retn 10676 <1> 10677 <1> ; 25/11/2020 10678 <1> ; Modified registers: edx 10679 <1> ;;push edx 10680 <1> ;mov dx, 04h ; VBE_DISPI_INDEX_ENABLE 10681 <1> ; 03/08/2022 10682 00003E5E 28F6 <1> sub dh, dh 10683 00003E60 B204 <1> mov dl, 04h ; VBE_DISPI_INDEX_ENABLE 10684 <1> 10685 <1> ;;call dispi_set_parms 10686 <1> ;;pop edx 10687 <1> ;;retn 10688 <1> ;jmp short dispi_set_parms 10689 <1> 10690 <1> dispi_set_parms: 10691 <1> ; 03/08/2022 10692 <1> ; 25/11/2020 10693 <1> ; Input: 10694 <1> ; ax = data 10695 <1> ; dx = vbe dispi register index 10696 <1> ; 10697 <1> ; Modified registers: edx 10698 <1> 10699 00003E62 50 <1> push eax 10700 <1> ;mov ax, dx 10701 <1> ; 03/08/2022 10702 00003E63 89D0 <1> mov eax, edx 10703 00003E65 66BACE01 <1> mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10704 00003E69 66EF <1> out dx, ax 10705 00003E6B 58 <1> pop eax 10706 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10707 <1> ;mov dl, 0CFh 10708 00003E6C FEC2 <1> inc dl 10709 00003E6E 66EF <1> out dx, ax 10710 00003E70 C3 <1> retn 10711 <1> 10712 <1> dispi_set_bpp: 10713 <1> ; 03/08/2022 10714 <1> ; 25/11/2020 10715 <1> ; Input: 10716 <1> ; ax = Bits per pixel value 10717 <1> ; (8,16,24,32) 10718 <1> ; 10719 <1> ; Modified registers: none 10720 <1> 10721 <1> ;push edx 10722 <1> ;push eax 10723 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10724 <1> ;mov ax, 03h ; VBE_DISPI_INDEX_BPP 10725 <1> ;out dx, ax 10726 <1> ;pop eax 10727 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10728 <1> ;;mov dl, 0CFh 10729 <1> ;inc dl 10730 <1> ;out dx, ax 10731 <1> ;pop edx 10732 <1> ;retn 10733 <1> 10734 <1> ; 25/11/2020 10735 <1> ; Modified registers: edx 10736 <1> ;;push edx 10737 <1> ;mov dx, 03h ; VBE_DISPI_INDEX_BPP 10738 <1> ; 03/08/2022 10739 00003E71 28F6 <1> sub dh, dh 10740 00003E73 B203 <1> mov dl, 03h ; VBE_DISPI_INDEX_BPP 10741 <1> 10742 <1> ;;call dispi_set_parms 10743 <1> ;;pop edx 10744 <1> ;;retn 10745 00003E75 EBEB <1> jmp short dispi_set_parms 10746 <1> 10747 <1> dispi_set_xres: 10748 <1> ; 03/08/2022 10749 <1> ; 25/11/2020 10750 <1> ; Input: 10751 <1> ; ax = X resolution (screen witdh) 10752 <1> ; (320,640,800,1024,1280,1920) 10753 <1> ; 10754 <1> ; Modified registers: none 10755 <1> 10756 <1> ;push edx 10757 <1> ;push eax 10758 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10759 <1> ;mov ax, 01h ; VBE_DISPI_INDEX_XRES 10760 <1> ;out dx, ax 10761 <1> ;pop eax 10762 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10763 <1> ;;mov dl, 0CFh 10764 <1> ;inc dl 10765 <1> ;out dx, ax 10766 <1> ;pop edx 10767 <1> ;retn 10768 <1> 10769 <1> ; 25/11/2020 10770 <1> ; Modified registers: edx 10771 <1> ;;push edx 10772 <1> ;mov dx, 01h ; VBE_DISPI_INDEX_XRES 10773 <1> ; 03/08/2022 10774 00003E77 28F6 <1> sub dh, dh 10775 00003E79 B201 <1> mov dl, 01h ; VBE_DISPI_INDEX_XRES 10776 <1> ;;call dispi_set_parms 10777 <1> ;;pop edx 10778 <1> ;;retn 10779 00003E7B EBE5 <1> jmp short dispi_set_parms 10780 <1> 10781 <1> dispi_set_yres: 10782 <1> ; 03/08/2022 10783 <1> ; 25/11/2020 10784 <1> ; Input: 10785 <1> ; ax = Y resolution (screen height) 10786 <1> ; (200,400,600,720,768,1080) 10787 <1> ; 10788 <1> ; Modified registers: none 10789 <1> 10790 <1> ;push edx 10791 <1> ;push eax 10792 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10793 <1> ;mov ax, 02h ; VBE_DISPI_INDEX_YRES 10794 <1> ;out dx, ax 10795 <1> ;pop eax 10796 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10797 <1> ;;mov dl, 0CFh 10798 <1> ;inc dl 10799 <1> ;out dx, ax 10800 <1> ;pop edx 10801 <1> ;retn 10802 <1> 10803 <1> ; 25/11/2020 10804 <1> ; Modified registers: edx 10805 <1> ;;push edx 10806 <1> ;mov dx, 02h ; VBE_DISPI_INDEX_YRES 10807 <1> ; 03/08/2022 10808 00003E7D 28F6 <1> sub dh, dh 10809 00003E7F B202 <1> mov dl, 02h ; VBE_DISPI_INDEX_YRES 10810 <1> ;;call dispi_set_parms 10811 <1> ;;pop edx 10812 <1> ;;retn 10813 00003E81 EBDF <1> jmp short dispi_set_parms 10814 <1> 10815 <1> dispi_set_bank: 10816 <1> ; 03/08/2022 10817 <1> ; 25/11/2020 10818 <1> ; Input: 10819 <1> ; ax = video memory bank number 10820 <1> ; 10821 <1> ; Modified registers: none 10822 <1> 10823 <1> ;push edx 10824 <1> ;push eax 10825 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10826 <1> ;mov ax, 05h ; VBE_DISPI_INDEX_BANK 10827 <1> ;out dx, ax 10828 <1> ;pop eax 10829 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10830 <1> ;;mov dl, 0CFh 10831 <1> ;inc dl 10832 <1> ;out dx, ax 10833 <1> ;pop edx 10834 <1> ;retn 10835 <1> 10836 <1> ; 25/11/2020 10837 <1> ; Modified registers: edx 10838 <1> ;;push edx 10839 <1> ;mov dx, 05h ; VBE_DISPI_INDEX_BANK 10840 <1> ; 03/08/2022 10841 00003E83 28F6 <1> sub dh, dh 10842 00003E85 B205 <1> mov dl, 05h ; VBE_DISPI_INDEX_BANK 10843 <1> ;;call dispi_set_parms 10844 <1> ;;pop edx 10845 <1> ;;retn 10846 00003E87 EBD9 <1> jmp short dispi_set_parms 10847 <1> 10848 <1> dispi_get_enable: 10849 <1> ; 03/08/2022 10850 <1> ; 27/11/2020 10851 <1> ; Input: 10852 <1> ; none 10853 <1> ; Output: 10854 <1> ; ax = vbe dispi status 10855 <1> ; 10856 <1> ; Modified registers: eax 10857 <1> 10858 <1> ;push edx 10859 <1> ;mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10860 <1> ;mov ax, 04h ; VBE_DISPI_INDEX_ENABLE 10861 <1> ;out dx, ax 10862 <1> ;;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10863 <1> ;;mov dl, 0CFh 10864 <1> ;inc dl 10865 <1> ;in ax, dx 10866 <1> ;pop edx 10867 <1> ;retn 10868 <1> 10869 <1> ; 27/11/2020 10870 <1> ; Modified registers: eax, edx 10871 <1> ;;push edx 10872 <1> ;mov ax, 04h ; VBE_DISPI_INDEX_ENABLE 10873 <1> ; 03/08/2022 10874 00003E89 28E4 <1> sub ah, ah 10875 00003E8B B004 <1> mov al, 04h ; VBE_DISPI_INDEX_ENABLE 10876 <1> 10877 <1> ;;call dispi_get_parms 10878 <1> ;;pop edx 10879 <1> ;;retn 10880 <1> ;jmp short dispi_get_parms 10881 <1> 10882 <1> dispi_get_parms: 10883 <1> ; 25/11/2020 10884 <1> ; Input: 10885 <1> ; ax = vbe dispi register index 10886 <1> ; output: 10887 <1> ; ax = data 10888 <1> ; 10889 <1> ; Modified registers: eax, edx 10890 <1> 10891 00003E8D 66BACE01 <1> mov dx, 01CEh ; VBE_DISPI_IOPORT_INDEX 10892 00003E91 66EF <1> out dx, ax 10893 <1> ;mov dx, 01CFh ; VBE_DISPI_IOPORT_DATA 10894 <1> ;mov dl, 0CFh 10895 00003E93 FEC2 <1> inc dl 10896 00003E95 66ED <1> in ax, dx 10897 00003E97 C3 <1> retn 10898 <1> 10899 <1> vga_compat_setup: 10900 <1> ; 03/08/2022 10901 <1> ; 26/11/2020 10902 <1> ; 25/11/2020 10903 <1> ; VGA compatibility setup 10904 <1> ; (vbe.c, 02/01/2020, vruppert) 10905 <1> ; 10906 <1> ; Input: 10907 <1> ; none 10908 <1> ; 10909 <1> ; Modified registers: eax, edx 10910 <1> 10911 <1> ; 26/11/2020 10912 <1> ;push eax 10913 <1> ;push edx 10914 <1> 10915 <1> ; set CRT X resolution 10916 00003E98 66BACE01 <1> mov dx, 1CEh ; VBE_DISPI_IOPORT_INDEX 10917 <1> ;mov ax, 01h ; VBE_DISPI_INDEX_XRES 10918 <1> ; 03/08/2022 10919 00003E9C 31C0 <1> xor eax, eax 10920 00003E9E FEC0 <1> inc al 10921 <1> ; eax = 1 10922 00003EA0 66EF <1> out dx, ax 10923 <1> ;mov dx, 1CFh ; VBE_DISPI_IOPORT_DATA 10924 00003EA2 FEC2 <1> inc dl 10925 00003EA4 66ED <1> in ax, dx 10926 00003EA6 50 <1> push eax 10927 00003EA7 66BAD403 <1> mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 10928 00003EAB 66B81100 <1> mov ax, 0011h ; Vertical retrace end register 10929 00003EAF 66EF <1> out dx, ax 10930 <1> ;pop eax 10931 <1> ;push eax 10932 00003EB1 8B0424 <1> mov eax, [esp] 10933 <1> ;shr ax, 3 ; / 8 for pixel to character 10934 <1> ;dec ax ; - 1 (EGA or VGA?) 10935 <1> ; 03/08/2022 10936 00003EB4 C1E803 <1> shr eax, 3 10937 00003EB7 48 <1> dec eax 10938 00003EB8 88C4 <1> mov ah, al 10939 00003EBA B001 <1> mov al, 01h ; Horizontal display end register 10940 00003EBC 66EF <1> out dx, ax 10941 00003EBE 58 <1> pop eax 10942 <1> 10943 00003EBF E89C000000 <1> call vga_set_virt_width 10944 <1> 10945 <1> ; set CRT Y resolution 10946 <1> ; 03/08/2022 10947 00003EC4 66BACE01 <1> mov dx, 1CEh ; VBE_DISPI_IOPORT_INDEX 10948 00003EC8 66B80200 <1> mov ax, 02h ; VBE_DISPI_INDEX_YRES 10949 00003ECC 66EF <1> out dx, ax 10950 <1> ;mov dx, 1CFh ; VBE_DISPI_IOPORT_DATA 10951 <1> ; 03/08/2022 10952 00003ECE FEC2 <1> inc dl 10953 00003ED0 66ED <1> in ax, dx 10954 00003ED2 50 <1> push eax 10955 00003ED3 66BAD403 <1> mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 10956 00003ED7 88C4 <1> mov ah, al 10957 00003ED9 B012 <1> mov al, 12h ; Vertical display end register 10958 00003EDB 66EF <1> out dx, ax 10959 00003EDD 58 <1> pop eax 10960 00003EDE B007 <1> mov al, 07h ; Overflow register 10961 00003EE0 EE <1> out dx, al 10962 <1> ;inc dx 10963 <1> ; 03/08/2022 10964 00003EE1 FEC2 <1> inc dl 10965 00003EE3 EC <1> in al, dx ; read overflow register 10966 00003EE4 24BD <1> and al, 0BDh ; clear VDE 9th and 10th bits 10967 00003EE6 F6C401 <1> test ah, 01h 10968 00003EE9 7402 <1> jz short bit8_clear 10969 00003EEB 0C02 <1> or al, 02h ; VDE 9th bit (bit 8) in bit 1 10970 <1> bit8_clear: 10971 00003EED F6C402 <1> test ah, 02h 10972 00003EF0 7402 <1> jz short bit9_clear 10973 00003EF2 0C40 <1> or al, 40h ; VDE 10th bit (bit 9) in bit 6 10974 <1> bit9_clear: 10975 00003EF4 EE <1> out dx, al 10976 <1> 10977 <1> ; other settings 10978 <1> ;mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 10979 <1> ; 03/08/2022 10980 00003EF5 B2D4 <1> mov dl, 0D4h 10981 00003EF7 66B80900 <1> mov ax, 0009h ; Maximum scan line register 10982 00003EFB 66EF <1> out dx, ax ; Reset 10983 00003EFD B017 <1> mov al, 17h ; Mode control register 10984 00003EFF EE <1> out dx, al 10985 <1> ;mov dx, 3D5h ; VGAREG_VGA_CRTC_DATA 10986 00003F00 FEC2 <1> inc dl 10987 00003F02 EC <1> in al, dx ; Read mode control register 10988 00003F03 0C03 <1> or al, 03h ; Set SRS and CMS bits 10989 00003F05 EE <1> out dx, al 10990 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 10991 <1> ; 03/08/2022 10992 00003F06 B2DA <1> mov dl, 0DAh 10993 00003F08 EC <1> in al, dx ; clear flip-flop 10994 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 10995 <1> ; 03/08/2022 10996 00003F09 B2C0 <1> mov dl, 0C0h 10997 00003F0B B010 <1> mov al, 10h ; Mode control register 10998 00003F0D EE <1> out dx, al 10999 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 11000 00003F0E FEC2 <1> inc dl 11001 00003F10 EC <1> in al, dx 11002 00003F11 0C01 <1> or al, 01h ; select graphics mode 11003 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 11004 00003F13 FECA <1> dec dl 11005 00003F15 EE <1> out dx, al ; Write to mode control register 11006 00003F16 B020 <1> mov al, 20h ; Palette RAM <-> display memory 11007 00003F18 EE <1> out dx, al ; Write to attribute addr register 11008 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 11009 <1> ; 03/08/2022 11010 00003F19 B2CE <1> mov dl, 0CEh 11011 00003F1B 66B80605 <1> mov ax, 0506h ; Misc. register, graph, mm 1 11012 00003F1F 66EF <1> out dx, ax 11013 <1> ;mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 11014 <1> ; 03/08/2022 11015 00003F21 B2C4 <1> mov dl, 0C4h 11016 00003F23 66B8020F <1> mov ax, 0F02h ; Map mask register, all planes 11017 00003F27 66EF <1> out dx, ax 11018 <1> 11019 <1> ; settings for >= 8bpp 11020 <1> 11021 <1> ;mov dx, 1CEh ; VBE_DISPI_IOPORT_INDEX 11022 <1> ;mov ax, 03h ; VBE_DISPI_INDEX_BPP 11023 <1> ;out dx, ax 11024 <1> ;;mov dx, 1CFh ; VBE_DISPI_IOPORT_DATA 11025 <1> ;inc dl 11026 <1> ;in ax, dx 11027 <1> ;cmp al, 08h ; < 8 bits per pixel 11028 <1> ;jb short vga_compat_end 11029 <1> 11030 <1> ;mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 11031 <1> ; 03/08/2022 11032 00003F29 B2D4 <1> mov dl, 0D4h 11033 00003F2B B014 <1> mov al, 14h ; Underline location register 11034 00003F2D EE <1> out dx, al 11035 <1> ;mov dx, 3D5h ; VGAREG_VGA_CRTC_DATA 11036 00003F2E FEC2 <1> inc dl 11037 00003F30 EC <1> in al, dx 11038 00003F31 0C40 <1> or al, 40h ; enable double word mode 11039 00003F33 EE <1> out dx, al 11040 <1> ;mov dx, 3DAh ; VGAREG_ACTL_RESET 11041 <1> ; 03/08/2022 11042 00003F34 B2DA <1> mov dl, 0DAh 11043 00003F36 EC <1> in al, dx ; clear flip-flop 11044 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 11045 <1> ; 03/08/2022 11046 00003F37 B2C0 <1> mov dl, 0C0h 11047 00003F39 B010 <1> mov al, 10h ; Mode control register 11048 00003F3B EE <1> out dx, al 11049 <1> ;mov dx, 3C1h ; VGAREG_ACTL_READ_DATA 11050 00003F3C FEC2 <1> inc dl 11051 00003F3E EC <1> in al, dx 11052 00003F3F 0C40 <1> or al, 40h ; Pixel clock select is 1 11053 <1> ;mov dx, 3C0h ; VGAREG_ACTL_ADDRESS 11054 00003F41 FECA <1> dec dl 11055 00003F43 EE <1> out dx, al ; update mode control reggister 11056 00003F44 B020 <1> mov al, 20h ; select display memory as PAS 11057 00003F46 EE <1> out dx, al 11058 <1> ;mov dx, 3C4h ; VGAREG_SEQU_ADDRESS 11059 <1> ; 03/08/2022 11060 00003F47 B2C4 <1> mov dl, 0C4h 11061 00003F49 B004 <1> mov al, 04h ; Memory mode register 11062 00003F4B EE <1> out dx, al 11063 <1> ;mov dx, 3C5h ; VGAREG_SEQU_DATA 11064 00003F4C FEC2 <1> inc dl 11065 00003F4E EC <1> in al, dx 11066 00003F4F 0C08 <1> or al, 08h ; enable chain four 11067 00003F51 EE <1> out dx, al 11068 <1> ;mov dx, 3CEh ; VGAREG_GRDC_ADDRESS 11069 <1> ; 03/08/2022 11070 00003F52 B2CE <1> mov dl, 0CEh 11071 00003F54 B005 <1> mov al, 05h ; Mode register 11072 00003F56 EE <1> out dx, al 11073 <1> ;mov dx, 3CFh ; VGAREG_GRDC_DATA 11074 00003F57 FEC2 <1> inc dl 11075 00003F59 EC <1> in al, dx 11076 00003F5A 249F <1> and al, 9Fh ; clear shift register 11077 00003F5C 0C40 <1> or al, 40h ; set shift register to 2 11078 00003F5E EE <1> out dx, al 11079 <1> 11080 <1> vga_compat_end: 11081 <1> ;pop edx 11082 <1> ;pop eax 11083 00003F5F C3 <1> retn 11084 <1> 11085 <1> vga_set_virt_width: 11086 <1> ; 03/08/2022 11087 <1> ; 27/11/2020 11088 <1> ; 25/11/2020 11089 <1> ; (vbe.c, 02/01/2020, vruppert) 11090 <1> ; 11091 <1> ; Input: 11092 <1> ; AX = resolution (screen width) 11093 <1> ; 11094 <1> ; Modified registers: eax, edx 11095 <1> 11096 <1> ;;push ebx 11097 <1> ;push edx 11098 <1> ;push eax 11099 <1> ;mov ebx, eax 11100 <1> ;call dispi_get_bpp ; bits per pixel 11101 <1> ;cmp al, 4 11102 <1> ;ja short set_width_svga ; 8, 16, 24, 32 11103 <1> ;shr bx, 1 11104 <1> ;set_width_svga: 11105 <1> ;shr bx, 3 11106 <1> ;mov eax, [esp] 11107 <1> ;shr ax, 3 ; / 8, bytes per row 11108 <1> ; 03/08/2022 11109 00003F60 C1E803 <1> shr eax, 3 11110 00003F63 66BAD403 <1> mov dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS 11111 <1> ;mov ah, bl ; 11112 00003F67 88C4 <1> mov ah, al ; width in bytes 11113 00003F69 B013 <1> mov al, 13h ; offset register 11114 00003F6B 66EF <1> out dx, ax ; index (3D4h) and data (3D5h) 11115 <1> ;pop eax 11116 <1> ;pop edx 11117 <1> ;;pop ebx 11118 00003F6D C3 <1> retn 11119 <1> 11120 <1> ; 24/11/2020 11121 <1> 11122 <1> struc bmi ; BOCHS/PLEX86 MODE INFO structure/table 11123 00000000 ???? <1> .mode: resw 1 11124 00000002 ???? <1> .width: resw 1 11125 00000004 ???? <1> .height: resw 1 11126 00000006 ???? <1> .depth: resw 1 11127 <1> .size: 11128 <1> endstruc 11129 <1> 11130 <1> ; 24/11/2020 11131 <1> struc MODEINFO 11132 00000000 ???? <1> .mode: resw 1 ; 1XXh 11133 00000002 ???? <1> .ModeAttributes: resw 1 11134 00000004 ?? <1> .WinAAttributes: resb 1 11135 00000005 ?? <1> .WinBAttributes: resb 1 ; = 0 11136 00000006 ???? <1> .WinGranularity: resw 1 11137 00000008 ???? <1> .WinSize: resw 1 11138 0000000A ???? <1> .WinASegment: resw 1 11139 0000000C ???? <1> .WinBSegment: resw 1 ; = 0 11140 0000000E ???????? <1> .WinFuncPtr: resd 1 ; = 0 11141 00000012 ???? <1> .BytesPerScanLine: resw 1 11142 00000014 ???? <1> .XResolution: resw 1 11143 00000016 ???? <1> .YResolution: resw 1 11144 00000018 ?? <1> .XCharSize: resb 1 1