Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor Fixed in SuperCalc 1.0 #1055

Merged
merged 4 commits into from
Jun 24, 2024
Merged

Conversation

vip-delete
Copy link
Contributor

@vip-delete vip-delete commented May 30, 2024

The following issues are fixed:

If a DOS program sets the cursor out of the screen then it should be hidden, but v86 shows it.

You can reproduce it by running VC.com (Volkov Commander) and "View" (F3) any file.
The cursor will be at position (0,24), but VC sets it to (0,127) to hide

The following program can reproduce a bug:

org 100h

mov dl, 0  ; cursor column
mov dh, 25 ; cursor row (out of the screen)
mov ah, 2  ; move cursor function
mov bh, 0  ; display page
int 10h

xor ah, ah ; press any key to continue
int 16h

int 20h    ; exit

v86 shows cursor at 0,24
expected: cursor is hidden

Solution: Remove range checks in VGAScreen.update_cursor in vga.js

If a DOS program sets the "Cursor Scan Line End" less than "Cursor Scan Line Start" then cursor also should be hidden.

v86 is trying to set a negative height:

cursor_element.style.height = Math.min(15, end - start) + "px";

Solution: Hide cursor if end <= start, see "update_cursor_scanline" function in screen.js

SuperCalc 1.0 is writing a word to I/O Port 3D5h.
v86 doesn't have a w16 handler and ignores such writes (and throws an assert error in debug.html).
As as result, cursor position is invalid or hidden.

Writing a word to the second consecutive register is allowed, so we can use w8 handler and treat the data (a word) as a byte, see io.js

The following program reproduces the bug:

org 100h

mov bx, 79   ; cursor column (X)
mov ax, 24   ; cursor row (Y)
mov dl, 80   ; number of columns (width)
mul dl       ; ax = ax * dl = rows * width
add bx, ax   ; bx = ax * dl + bx = rows * width + cols = cursor location

mov dx, 3D4h ; crtc index
mov al, 0x0F ; cursor location low
out dx, al
inc dl       ; crtc data
mov ax, bx   ; al = cursor location low
out dx, ax   ; <- assert error in v86 but works in dosbox-x
;out dx, al  ; v86 supports a byte write only

dec dl       ; crtc inex
mov al, 0x0E ; cursor location high
out dx, al
inc dl       ; crtc data
mov al, bh   ; al = cursor location high
out dx, ax   ; <- assert error in v86 but works in dosbox-x
;out dx, al  ; v86 supports a byte write only

xor ah, ah   ; press any key to continue
int 16h

int 20h      ; exit

After the fix, the cursor location is correct:

image

The cursor color and blinking is fixed in another PR.

Copy link
Owner

@copy copy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've left a few comments

If possible, could you send me a disk image with the programs to reproduce the issues?

src/browser/dummy_screen.js Outdated Show resolved Hide resolved
src/browser/screen.js Outdated Show resolved Hide resolved
src/vga.js Outdated Show resolved Hide resolved
src/io.js Outdated Show resolved Hide resolved
@vip-delete
Copy link
Contributor Author

vip-delete commented May 31, 2024

@copy floppy image attached image+asm.zip
"asm" and "com" files are in A:\GITHUB folder
SuperCalc is in A:\SC folder, <- just start typing and you will see tha jumping cursor, to exit the program delete everything (backspace), then press "/", then "Q", then "Y"

bug.com <- cursor position is not changed, but should go to (79,24)

@vip-delete vip-delete requested a review from copy June 20, 2024 13:19
@copy copy merged commit bf20314 into copy:master Jun 24, 2024
2 of 3 checks passed
@copy
Copy link
Owner

copy commented Jun 24, 2024

Thanks!

@vip-delete vip-delete deleted the supercalc-cursor-fix branch July 2, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants