Skip to content

Commit 438bc1d

Browse files
HBeluscadisean
authored andcommitted
[FREELDR:PC98] Don't do the HighRes check everytime a character is written with writechr (reactos#4359)
And bring similar simplifications to the PC98 FAT12 bootsector. Co-authored-by: Dmitry Borisov <[email protected]>
1 parent 11cd52f commit 438bc1d

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

boot/freeldr/bootsect/pc98/fat12fdd.S

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ relocated:
145145
mov ds, ax
146146

147147
test byte ptr ds:[HEX(501)], HEX(08) // High-resolution mode check
148-
jz VideoTestNormalMode
149-
mov ax, HEX(0E000)
150-
jmp short VideoTestDone
151-
VideoTestNormalMode:
152-
mov ax, HEX(0A000)
148+
mov ax, HEX(0A000) // Suppose normal mode
149+
jz short VideoTestDone
150+
mov ah, HEX(E0) // Change 0xA000 to 0xE000, use hi-res mode
153151
VideoTestDone:
154152
mov word ptr BP_REL(VramSegment), ax
155153

@@ -358,14 +356,11 @@ PutChar:
358356
push di
359357
push es
360358

361-
push word ptr BP_REL(VramSegment)
362-
pop es
363-
mov di, word ptr BP_REL(VramOffset) // ES:DI = VramSegment:VramOffset
359+
les di, dword ptr BP_REL(VramSegOff) // Load the VRAM segment and offset (ES:DI)
364360
.PutCharWrite:
365-
xor ah, ah
366-
stosw // Write ASCII directly to the VRAM
367-
368-
mov word ptr BP_REL(VramOffset), di
361+
xor ah, ah // Write ASCII directly to the VRAM
362+
stosw // (two bytes per character)
363+
mov word ptr BP_REL(VramOffset), di // Update the start position
369364
pop es
370365
pop di
371366

@@ -468,10 +463,12 @@ Reboot:
468463
Halt:
469464
jmp short Halt // Spin
470465

471-
VramSegment:
472-
.word 0
466+
VramSegOff:
473467
VramOffset:
474468
.word 0
469+
VramSegment:
470+
.word 0
471+
475472
msgDiskError:
476473
.ascii "ERR", CR, LF, NUL
477474
msgNotFoundError:

boot/freeldr/freeldr/arch/realmode/helpers_pc98.inc

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ writestr:
5656
jmp short .writestr_loop
5757

5858
.writestr_cr:
59-
mov ax, word ptr VramOffset
59+
mov ax, word ptr ds:[VramOffset]
6060
mov dl, 80 * 2
6161
div dl
6262
inc ax
6363
mul dl
64-
mov word ptr VramOffset, ax
64+
mov word ptr ds:[VramOffset], ax
6565

6666
/* Skip the next LF character */
6767
inc si
@@ -80,27 +80,39 @@ writechr:
8080
pushf
8181
pusha
8282

83+
/* Check if the VRAM segment was initialized */
84+
mov dx, word ptr ds:[VramSegment]
85+
test dx, dx
86+
jnz short .writechr_write
87+
8388
/* High-resolution mode check */
8489
test byte ptr ds:[HEX(501)], HEX(08)
85-
jz .writechr_normal
86-
push HEX(0E000)
87-
jmp short .writechr_test_done
88-
.writechr_normal:
89-
push HEX(0A000)
90-
90+
mov dx, HEX(0A000) // Suppose normal mode
91+
jz short .writechr_test_done
92+
mov dh, HEX(E0) // Change 0xA000 to 0xE000, use hi-res mode
9193
.writechr_test_done:
92-
pop es
93-
mov di, word ptr VramOffset
94+
mov word ptr ds:[VramSegment], dx
95+
96+
.writechr_write:
97+
/* Load the VRAM segment and offset (ES:DI) */
98+
les di, dword ptr ds:[VramSegOff]
99+
100+
/* Write ASCII directly to the VRAM (two bytes per character) */
94101
xor ah, ah
95102
stosw
96-
mov word ptr VramOffset, di
103+
104+
/* Update the start position */
105+
mov word ptr ds:[VramOffset], di
97106

98107
popa
99108
popf
100109
ret
101110

111+
VramSegOff:
102112
VramOffset:
103113
.word 0
114+
VramSegment:
115+
.word 0
104116

105117
/*
106118
* Writes a hex number in (AL, AX, EAX) to the console

0 commit comments

Comments
 (0)