VOGONS


Keen 4-5-6 choppy scrolling on EGA card

Topic actions

Reply 60 of 64, by TheFiend

User metadata
Rank Newbie
Rank
Newbie
K1n9_Duk3 wrote on 2021-03-11, 23:09:

That doesn't really make sense. With these patches applied, the basic frame timing in Dave 3 and 4 should be more or less the same as in Keen Dreams, and the code that updates the CRTC start and panning registers of the video card (i.e. what actually makes the scrolling happen) is exactly the same in Keen Dreams and Dave 3 and 4. It could still have something to do with the frame timing, but then you should also get to see some issues in Keen Dreams from time to time (while walking around on the world map, for example).

The only suggestion I can give is to make sure that you are actually using the patched executables and not the original files.

It might help if you could record some video footage that shows these issues in action. That could tell me whether the issue lies with the CRTC start and panning registers or the drawing code.

I'll try again and also try to possibly record footage. I'll also try this on another machine on which the game works perfectly fine in Windows 98SE with no issues whatsoever but the jerky motion still exists in real DOS mode using MS-DOS 6.22.

UPDATE: After some further testing on the HP t5720 and a Pentium 3 Gateway machine from 2000 that I have, it appears that the problem is related to having Legacy USB enabled in the BIOS. The hp t5720 does not have a Legacy USB option in the BIOS so I have to disable the entire USB controller in the BIOS just to play Keen 1-3 and the Dave games which can get fairly annoying. Upon disabling Legacy USB the problem is totally gone. I can even play the unpatched versions of the games with no jerky motion issues however I need to rely on using Setmul for Dave 3 and Dave 4 to detect my Yamaha 724 sound card which can be annoying. Aside from that everything is working fine now. Sucks that I can't use USB peripherals and have to keep PS/2 mouse and keyboard on hand for this computer but oh well.

Reply 61 of 64, by K1n9_Duk3

User metadata
Rank Member
Rank
Member

Glad to hear you found a workaround for the problems you were experiencing.

I still can't think of a good reason why Keen Dreams would run fine while Dave 3 and 4 (with the 35 fps patch) have issues on the same system. But now that you mention Setmul, is this how you've been running Dave 3 and 4 all this time? This additional slowdown could explain why Dave 3 and 4 behave differently, assuming you've been running Keen Dreams without slowdown.

Reply 62 of 64, by TheFiend

User metadata
Rank Newbie
Rank
Newbie
K1n9_Duk3 wrote on 2021-03-23, 22:16:

Glad to hear you found a workaround for the problems you were experiencing.

I still can't think of a good reason why Keen Dreams would run fine while Dave 3 and 4 (with the 35 fps patch) have issues on the same system. But now that you mention Setmul, is this how you've been running Dave 3 and 4 all this time? This additional slowdown could explain why Dave 3 and 4 behave differently, assuming you've been running Keen Dreams without slowdown.

I've been running all these games without Setmul by default. The only real reason for me to try out Setmul was to get sound in Dave 3 and 4 with a PCI Sound Card. I don't need it with my ISA Sound Card based computer build that I have and I really prefer to not use it. I find it quite weird that Keen Dreams, a very problematic game, runs perfectly fine by default while other games that don't generally exhibit problems are causing issues for me.

Reply 63 of 64, by K1n9_Duk3

User metadata
Rank Member
Rank
Member

Well, I decided to give this another try and replace the screen update code with the method that I used for the most recent version of my Keen 4-6 code.

patch scripts
#==========================================================
# Dangerous Dave 3 - Dave's Risky Rescue v1.00 (Rev 1.04):
#==========================================================

%exefile DAVE.EXE 207760

#-------------------------------------------------------
# fix CPU speed sensitivity in AdLib/SoundBlaster code:

%patch $1606F
$BA $0388w # mov dx, 388h
$B9 $0009w # mov cx, 9
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16083
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16376
$BA $0388w # mov dx, 388h
$B9 $0006w # mov cx, 6
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16387
$BA $0388w # mov dx, 388h
$B9 $0023w # mov cx, 35
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16A05
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

#-------------------------------------------------------


#-------------------------------------------------------
# Customized Screen Update Code

# add /JERK parameter check:
%patch $28686
$00E0w # "COMP"
$419Cw # "JERK"
$0000w
"JERK" $00

# replace old VW_SetScreen code (doesn't all fit, though!)
%patch $1295F
$55 # push bp
$8B $EC # mov bp, sp
$BA $03DAw # mov dx, 3DAh
$FA # cli
#@l1:
$EC # in al, dx
Show last 343 lines
	$A8 $01			#	test	al, 1
$74 $FB # jz @l1
#@l2:
$EC # in al, dx
$A8 $01 # test al, 1
$75 $FB # jnz @l2
$8B $4E $06 # mov cx, [bp+arg_start]
$BA $03D4w # mov dx, 3D4h
$B0 $0C # mov al, 0Ch
$EE # out dx, al
$42 # inc dx
$8A $C5 # mov al, ch
$EE # out dx, al
$4A # dec dx
$B0 $0D # mov al, 0Dh
$EE # out dx, al
$8A $C1 # mov al, cl
$42 # inc dx
$EE # out dx, al
$8B $0E $D022w # mov cx, fixjerky
$E3 $03 # jcxz @l3
$E8 $F054w # call WaitVBL
#@l3:
$BA $03C0w # mov dx, 3C0h
$B0 $33 # mov al, 33h
$EE # out dx, al
$EB $00 # jmp $
$8A $46 $08 # mov al, [bp+arg_pan]
$EE # out dx, al
$E9 $F060w # jmp rest_of_VW_SetScreen

# replace VW_Plot with new code (VW_Plot now uses VW_Vlin to plot one pixel)
%patch $119CC
$55 # push bp
$8B $EC # mov bp, sp
$FF $76 $0A # push [bp+10] ;color
$FF $76 $06 # push [bp+6] ;x
$8B $46 $08 # mov ax, [bp+8] ;y
$50 # push ax ;y
$50 # push ax ;y
$0E # push cs
$E8 $003Dw # call VW_Vlin
$8B $E5 # mov sp, bp
$5D # pop bp
$CB # retf

#WaitVBL:
$8B $1E $E3F2w # mov bx, word ptr TimeCount
$BA $03DAw # mov dx, 3DAh
#@wait:
$FB # sti
$EB $00 # jmp short $
$FA # cli
$EC # in al, dx
$A8 $08 # test al, 8
$75 $0A # jnz @done
$A1 $E3F2w # mov ax, word ptr TimeCount
$2B $C3 # sub ax, bx
$3D $0001w # cmp ax, 1
$76 $ED # jbe @wait
#@done:
$C3 # retn

#rest_of_VW_SetScreen:
$0B $C9 # or cx, cx
$75 $03 # jnz @l5
$E8 $FFDEw # call WaitVBL
#@l5:
$FB # sti
$5D # pop bp
$CB # retf

#-------------------------------------------------------



#=======================================================
# Dangerous Dave 3 - Dave's Risky Rescue v1.01 (Rev 3):
#=======================================================
%exefile DAVE.EXE 208432

#-------------------------------------------------------
# fix CPU speed sensitivity in AdLib/SoundBlaster code:
%patch $161F5
$BA $0388w # mov dx, 388h
$B9 $0009w # mov cx, 9
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16209
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $164FC
$BA $0388w # mov dx, 388h
$B9 $0006w # mov cx, 6
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $1650D
$BA $0388w # mov dx, 388h
$B9 $0023w # mov cx, 35
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16B8B
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

#-------------------------------------------------------


#-------------------------------------------------------
# Customized Screen Update Code

# add /JERK parameter check:
%patch $28930
$00E0w # "COMP"
$42B6w # "JERK"
$0000w
"JERK" $00

# replace old VW_SetScreen code (doesn't all fit, though!)
%patch $12AE5
$55 # push bp
$8B $EC # mov bp, sp
$BA $03DAw # mov dx, 3DAh
$FA # cli
#@l1:
$EC # in al, dx
$A8 $01 # test al, 1
$74 $FB # jz @l1
#@l2:
$EC # in al, dx
$A8 $01 # test al, 1
$75 $FB # jnz @l2
$8B $4E $06 # mov cx, [bp+arg_start]
$BA $03D4w # mov dx, 3D4h
$B0 $0C # mov al, 0Ch
$EE # out dx, al
$42 # inc dx
$8A $C5 # mov al, ch
$EE # out dx, al
$4A # dec dx
$B0 $0D # mov al, 0Dh
$EE # out dx, al
$8A $C1 # mov al, cl
$42 # inc dx
$EE # out dx, al
$8B $0E $D13Aw # mov cx, fixjerky
$E3 $03 # jcxz @l3
$E8 $F054w # call WaitVBL
#@l3:
$BA $03C0w # mov dx, 3C0h
$B0 $33 # mov al, 33h
$EE # out dx, al
$EB $00 # jmp $
$8A $46 $08 # mov al, [bp+arg_pan]
$EE # out dx, al
$E9 $F060w # jmp rest_of_VW_SetScreen

# replace VW_Plot with new code (VW_Plot now uses VW_Vlin to plot one pixel)
%patch $11B52
$55 # push bp
$8B $EC # mov bp, sp
$FF $76 $0A # push [bp+10] ;color
$FF $76 $06 # push [bp+6] ;x
$8B $46 $08 # mov ax, [bp+8] ;y
$50 # push ax ;y
$50 # push ax ;y
$0E # push cs
$E8 $003Dw # call VW_Vlin
$8B $E5 # mov sp, bp
$5D # pop bp
$CB # retf

#WaitVBL:
$8B $1E $E50Aw # mov bx, word ptr TimeCount
$BA $03DAw # mov dx, 3DAh
#@wait:
$FB # sti
$EB $00 # jmp short $
$FA # cli
$EC # in al, dx
$A8 $08 # test al, 8
$75 $0A # jnz @done
$A1 $E50Aw # mov ax, word ptr TimeCount
$2B $C3 # sub ax, bx
$3D $0001w # cmp ax, 1
$76 $ED # jbe @wait
#@done:
$C3 # retn

#rest_of_VW_SetScreen:
$0B $C9 # or cx, cx
$75 $03 # jnz @l5
$E8 $FFDEw # call WaitVBL
#@l5:
$FB # sti
$5D # pop bp
$CB # retf

#-------------------------------------------------------


#=======================================================
# Dangerous Dave 4 - Dave Goes Nutz! v1.01 (Rev 1):
#=======================================================

%exefile DAVEGAME.EXE 195136

#-------------------------------------------------------
# fix CPU speed sensitivity in AdLib/SoundBlaster code:
%patch $15B83
$BA $0388w # mov dx, 388h
$B9 $0009w # mov cx, 9
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $15B97
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $15E8A
$BA $0388w # mov dx, 388h
$B9 $0006w # mov cx, 6
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $15E9B
$BA $0388w # mov dx, 388h
$B9 $0023w # mov cx, 35
$EC #inl: in al, dx
$E2 $FD # loop inl

%patch $16519
$BA $0388w # mov dx, 388h
$B9 $0064w # mov cx, 100
$EC #inl: in al, dx
$E2 $FD # loop inl

#-------------------------------------------------------


#-------------------------------------------------------
# Customized Screen Update Code

# add /JERK parameter check:
%patch $26218
$00E0w # "COMP"
$420Ew # "JERK"
$0000w
"JERK" $00

# replace old VW_SetScreen code (doesn't all fit, though!)
%patch $12473
$55 # push bp
$8B $EC # mov bp, sp
$BA $03DAw # mov dx, 3DAh
$FA # cli
#@l1:
$EC # in al, dx
$A8 $01 # test al, 1
$74 $FB # jz @l1
#@l2:
$EC # in al, dx
$A8 $01 # test al, 1
$75 $FB # jnz @l2
$8B $4E $06 # mov cx, [bp+arg_start]
$BA $03D4w # mov dx, 3D4h
$B0 $0C # mov al, 0Ch
$EE # out dx, al
$42 # inc dx
$8A $C5 # mov al, ch
$EE # out dx, al
$4A # dec dx
$B0 $0D # mov al, 0Dh
$EE # out dx, al
$8A $C1 # mov al, cl
$42 # inc dx
$EE # out dx, al
$8B $0E $C56Cw # mov cx, fixjerky
$E3 $03 # jcxz @l3
$E8 $F054w # call WaitVBL
#@l3:
$BA $03C0w # mov dx, 3C0h
$B0 $33 # mov al, 33h
$EE # out dx, al
$EB $00 # jmp $
$8A $46 $08 # mov al, [bp+arg_pan]
$EE # out dx, al
$E9 $F060w # jmp rest_of_VW_SetScreen

# replace VW_Plot with new code (VW_Plot now uses VW_Vlin to plot one pixel)
%patch $114E0
$55 # push bp
$8B $EC # mov bp, sp
$FF $76 $0A # push [bp+10] ;color
$FF $76 $06 # push [bp+6] ;x
$8B $46 $08 # mov ax, [bp+8] ;y
$50 # push ax ;y
$50 # push ax ;y
$0E # push cs
$E8 $003Dw # call VW_Vlin
$8B $E5 # mov sp, bp
$5D # pop bp
$CB # retf

#WaitVBL:
$8B $1E $D78Cw # mov bx, word ptr TimeCount
$BA $03DAw # mov dx, 3DAh
#@wait:
$FB # sti
$EB $00 # jmp short $
$FA # cli
$EC # in al, dx
$A8 $08 # test al, 8
$75 $0A # jnz @done
$A1 $D78Cw # mov ax, word ptr TimeCount
$2B $C3 # sub ax, bx
$3D $0001w # cmp ax, 1
$76 $ED # jbe @wait
#@done:
$C3 # retn

#rest_of_VW_SetScreen:
$0B $C9 # or cx, cx
$75 $03 # jnz @l5
$E8 $FFDEw # call WaitVBL
#@l5:
$FB # sti
$5D # pop bp
$CB # retf

#-------------------------------------------------------

%end

I also included some patches that should make the AdLib and SoundBlaster detection routines more reliable on systems with a fast CPU.

Please note that the screen update code supports two different modes of operation. The default mode might be even more choppy than the original code on certain video cards. You would need to run the game with the parameter "/JERK" to switch to the second mode. The default mode should work fine on most systems, I only have one system that would need the /JERK parameter and that's a 486 SX laptop from 1994.

As I type this, I realize that actually getting Dave 4 to recognize this parameter is complicated, since you would normally have to run the wrapper program DAVE.EXE, which wouldn't pass the /JERK parameter on to the main executable DAVEGAME.EXE. You can bypass the wrapper by starting the game like this:

DAVEGAME.EXE ^(a@&r` 1 0 /JERK

The ` character at the end of the first parameter is an accent character (ASCII code 96), not an apostrophe ( ' ). The second parameter (1) is for starting a new game - replace it with a 0 to make the game show the loading menu right away. The third paramter selects the difficulty level: 0 is for "Stud Mode", 1 is for "Wimp Mode". The first three parameters must always be passed in this order, any additional parameters like "/JERK" or "/COMP" (for SVGA compatibilty) can be passed in any order after these first three parameters.