[DISCUSSION] MS-DOS memory optimisation tricks

Support and general discussion.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

[DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

You know, it can be very frustrating to find which drivers for sound cards, network cards, memory managers, mice and CD-ROM devices that uses less memory. I've been running this experience on the two machines that I'm about to mention:

1.AMI 486 clone machine: Tseng Labs Int'l ET4000AX graphics card with 1 MB video RAM, Intel 80486 @ 33 MHz, no dynamic compiler, 64 KB cache (some cache), Sound Blaster 16 sound card, 16 MB RAM.

This machine listed above has two 504 MB hard disk images (which is the maximum that the AMI 486 BIOS can handle), MS-DOS 5.0 and Windows 3.0a.

When it comes to loading all of the appropriate drivers for the AMI 486 clone machine, I end up with a peak of 564.5 KB of base memory. The biggest problem with the Tseng ET4000 graphics card is that if you want to use certain software that will emulate the 8514/A video mode capability, I have no choice, but load the RIXAI8 TSR. Unfortunately, RIXAI8 is a huge memory hog as it takes up 43.6 KB of base memory.

I'll bet that it would be too difficult to get the RIXAI8 TSR into upper memory, because of the erratic behaviour of anything loading into UMB address segments B000 to B7FF and to play things safe. I also had to exclude UBM address segments B800 to DFFF in a attempt to improve stability.

I've been switching back and forth between the EMM386 and QEMM386 memory managers, especially because so many games and apps are not 100% compatible and may not work correctly when run in a MS-DOS session under Windows 3.x.

Can anyone provide comment on this issue?

2. AMI WinBIOS 486 clone machine: Trident TVGA 8900D graphics card with 1 MB video RAM, Intel 80486DX2 @ 66 MHz, no dynamic compiler, 256 KB cache (infinite cache), Sound Blaster 16 sound card, 64 MB RAM.

The machine listed above has two 2 GB hard disk images, MS-DOS 6.22 and Windows 3.11.

With MS-DOS 6.22, I had better success for loading most of the drivers into upper memory. The MS-DOS operating system (9.42 KB), QEMM386 driver (912 bytes), LOADHI utility (112 bytes), COMMAND interpreter (2.02 KB) and HIDE87 utility (592 bytes) have been left out of upper memory.

Unlike the first machine, up to as much as 627 KB of base memory is available with 7 KB free within the UMB.

The only problem that I still have to face is that adding further tweaking of the CONFIG.SYS and AUTOEXEC.BAT files can have an adverse effect on how much base and upper memory availability. Most MS-DOS based games require anywhere between 550 KB to as much as 600 KB of base memory, so I want to be careful how memory is managed.

The contents of the CONFIG.SYS and AUTOEXEC.BAT for both machines can be seen on my previous thread, "r328: OS/2 Warp 3 format error; CD access crashes PCem".


A couple of notes regarding the Tseng ET4000 and Trident TVGA 8900D graphics cards.

1. The Tseng ET4000 is fixed to 1 MB display memory, looking at the contents of the ET4000.BIN video binary, what I'm missing is that 256 KB and 512 KB display memory sizes are available as an option. The PCem configuration currently doesn't have the ability to select 256 KB or 512 KB VRAM options for the Tseng ET4000. I'm wondering if that can be added in.

2. The Trident TVGA 8900D can address up to as much as 2 MB of display memory, not 1 MB. The contents in the beginning of the trident.bin file have the option to select 256 KB, 512 KB, 768K, 1 MB or even 2 MB of display memory (with bugs corrected) and Bus DRAM options of 8-bit, 16-bit or 32-bit. Although it would be pointless to add support for 768 KB memory, I'm wondering if it would be possible to add support for up to 2 MB display memory options on the TVGA8900D emulated display card.


Getting back to DOS memory tricks, is there a better way to optimise the memory usage without having to run into stability problems associated with the UMB address segment usage in the CONFIG.SYS file?

Post your thoughts about this issue.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by SA1988 »

Well, 2mb drivers for the TVGA8900D are usually buggy in Windows and others, so that's why it's not supported on PCem at the moment and, as for the et4000ax, yes, it would be configurable in the future :)
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

SA1988 wrote:Well, 2mb drivers for the TVGA8900D are usually buggy in Windows and others, so that's why it's not supported on PCem at the moment and, as for the et4000ax, yes, it would be configurable in the future :)
That's true. Wikipedia has started that on the Trident Microsystems article, the TVGA 8900D graphics card with 2 MB display RAM is the same as its predecessor, the TVGAL 8900CL, but with bugs corrected.

As 2 MB display memory is not tested and if it was, what bugs can you encounter if you try to enable 2 MB display RAM for the Trident TVGA 8900D emulated graphics card under the latest revision of PCem right now?
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by SA1988 »

well, I think I had tested 2mb once on the tvga8900d on pcem, and they showed no problems, although probably the drivers I had can only address up to 1mb and that's why they work fine, probably those that expect 2mb display memory can have bugs.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

SA1988 wrote:well, I think I had tested 2mb once on the tvga8900d on pcem, and they showed no problems, although probably the drivers I had can only address up to 1mb and that's why they work fine, probably those that expect 2mb display memory can have bugs.
It would be obvious to do more research on how much video memory that the TVGA8900D can address. I can only find very limited info regarding a TVGA 8900D ISA graphics card with 2 MB display RAM.

Obviously, to support up to 2 MB of display memory on the TVGA 8900D, you'd probably need to use a generic VESA driver. Software, such as NeoPaint for DOS can support up to 2 MB of display memory if the generic VESA driver is selected.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by SarahWalker »

With 2 MB, the build-in VESA drivers allow modes that the 8900D can't display. The chip doesn't have the bandwidth to take advantage of 2 MB anyway, I'm fairly certain no boards were sold with more than 1 MB.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

looking through the memory dump...

Code: Select all


a0000	top of DOS ram (640kb)

b8000	text space (CGA/EGA/VGA)

c0000	video rom
c5b80	video end

c6800	something
c8000	endthing

f0000	bios
ffffe	biosend
so I tried emm386 from MS-DOS 6.22 something like this
device=emm386.exe x=a000-afff i=b000-b7ff x=b800-bbef x=c000-c7fff i=c800-cfff i=d000-dfff i=e000-efff noems
It loads Windows 3.0 up ok.

And for fun, you can disable the VGA graphics memory for 753kb of conventional ram (732kb usable)
device=emm386.exe i=a000-afff i=b000-b7ff x=b800-bbef x=c000-c7fff i=c800-cfff i=d000-dfff i=e000-efff noems
In Windows 3.0 I get 615568kb of conventional ram, although I don't have much loaded....

Ok here is my config.sys:
DEVICE=C:\DOS\HIMEM.SYS
rem text mode
rem DEVICE=C:\emm386.exe i=a000-afff i=b000-b7ff x=b800-bbef X=C000-C7ff i=c800-cfff i=d000-dfff i=e000-efff noems
rem graphics mode
DEVICE=C:\emm386.exe x=a000-afff i=b000-b7ff x=b800-bbef X=C000-C7ff i=c800-cfff i=d000-dfff i=e000-efff noems
DEVICEHIGH=C:\DOS\SETVER.EXE
devicehigh=c:\dos\cd1.sys /d:cdrom01
DOS=HIGH,umb
FILES=30
autoexec.bat
@ECHO OFF
PROMPT $p$g
PATH C:\DOS
SET TEMP=C:\temp
lh doskey
lh mscdex /d:cdrom01
lh \smartdrv
mem /d in MS-DOS 5
Address Name Size Type
------- -------- ------ ------
000000 000400 Interrupt Vector
000400 000100 ROM Communication Area
000500 000200 DOS Communication Area

000700 IO 000A60 System Data
CON System Device Driver
AUX System Device Driver
PRN System Device Driver
CLOCK$ System Device Driver
A: - C: System Device Driver
COM1 System Device Driver
LPT1 System Device Driver
LPT2 System Device Driver
LPT3 System Device Driver
COM2 System Device Driver
COM3 System Device Driver
COM4 System Device Driver

001160 MSDOS 0013D0 System Data

002530 IO 002300 System Data
HIMEM 0004A0 DEVICE=
XMSXXXX0 Installed Device Driver
EMM386 000C20 DEVICE=
EMMQXXX0 Installed Device Driver
0005D0 FILES=
000100 FCBS=
000200 BUFFERS=
0001C0 LASTDRIVE=
000740 STACKS=
004840 MSDOS 000040 System Program

004890 COMMAND 000940 Program
0051E0 MSDOS 000040 -- Free --
005230 COMMAND 000100 Environment
005340 MEM 000050 Environment
0053A0 MEM 0176F0 Program
01CAA0 MSDOS 083540 -- Free --
09FFF0 SYSTEM 0114A0 System Program

0B14A0 MSDOS 000050 -- Free --
0B1500 MSDOS 006AD0 -- Free --
0B7FE0 SYSTEM 010020 System Program

0C8010 IO 007270 System Data
SETVER 000190 DEVICE=
SETVERXX Installed Device Driver
CD1 0070C0 DEVICE=
CDROM01 Installed Device Driver
0CF290 DOSKEY 001020 Program
0D02C0 MSCDEX 006D20 Program
0D6FF0 SMARTDRV 007690 Program
0DE690 MSDOS 011960 -- Free --


655360 bytes total conventional memory
655360 bytes available to MS-DOS
633920 largest executable program size

65011712 bytes total contiguous extended memory
0 bytes available contiguous extended memory
13201408 bytes available XMS memory
MS-DOS resident in High Memory Area
mem /d in Windows 3.0
Address Name Size Type
------- -------- ------ ------
000000 000400 Interrupt Vector
000400 000100 ROM Communication Area
000500 000200 DOS Communication Area

000700 IO 000A60 System Data
CON System Device Driver
AUX System Device Driver
PRN System Device Driver
CLOCK$ System Device Driver
A: - C: System Device Driver
COM1 System Device Driver
LPT1 System Device Driver
LPT2 System Device Driver
LPT3 System Device Driver
COM2 System Device Driver
COM3 System Device Driver
COM4 System Device Driver

001160 MSDOS 0013D0 System Data

002530 IO 002300 System Data
HIMEM 0004A0 DEVICE=
XMSXXXX0 Installed Device Driver
EMM386 000C20 DEVICE=
$MMXXXX0 Installed Device Driver
0005D0 FILES=
000100 FCBS=
000200 BUFFERS=
0001C0 LASTDRIVE=
000740 STACKS=
004840 MSDOS 000040 System Program

004890 COMMAND 000940 Program
0051E0 win386 000040 Data
005230 COMMAND 000100 Environment
005340 WIN 000060 Environment
0053B0 WIN 0002A0 Program
005660 win386 000070 Environment
0056E0 win386 002910 Program
008000 COMMAND 000070 Data
008080 COMMAND 000940 Program
0089D0 COMMAND 000100 Environment
008AE0 MEM 000060 Environment
008B50 MEM 0176F0 Program
020250 MSDOS 07EDA0 -- Free --


651264 bytes total conventional memory
651264 bytes available to MS-DOS
615584 largest executable program size

Handle EMS Name Size
------- -------- ------
0 060000

1671168 bytes total EMS memory
442368 bytes free EMS memory

65011712 bytes total contiguous extended memory
0 bytes available contiguous extended memory
1048576 bytes available XMS memory
MS-DOS resident in High Memory Area
Last edited by neozeed on Fri 04 Sep, 2015 2:07 pm, edited 1 time in total.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

Yes, Windows 3.0 loads OK, because Windows 3.0 does not use those segments by default. Windows 3.0 doesn't care what parameters are used with EMM386. It uses its own parameters in SYSTEM.INI. Try adding B000-B7FF and most probably it'll start behaving erratically.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Battler wrote:Yes, Windows 3.0 loads OK, because Windows 3.0 does not use those segments by default. Windows 3.0 doesn't care what parameters are used with EMM386. It uses its own parameters in SYSTEM.INI. Try adding B000-B7FF and most probably it'll start behaving erratically.
I thought the goal was maximum ram in MS-DOS, no?

Anyways including anything with emminclude and emmexclude just has windows refuse to load. So I comment out emm386, and put in the same blocks as I had above, and windows loads just fine.
Last edited by neozeed on Fri 04 Sep, 2015 2:25 pm, edited 1 time in total.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

Yes, it is. I am just saying, saying there's no bug because Windows 3.0 still loads OK (when it even ignores EMM386 parameters) is jumping to conclusions. :p You need to try to load *DOS* stuff (or even Windows itself) loaded into those segments to reproduce the erratical behavior, which makes us unable to maximize available memory.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Battler wrote:Yes, it is. I am just saying, saying there's no bug because Windows 3.0 still loads OK (when it even ignores EMM386 parameters) is jumping to conclusions. :p You need to try to load *DOS* stuff (or even Windows itself) loaded into those segments to reproduce the erratical behavior, which makes us unable to maximize available memory.
well it seems ok so far. I'll leave windows doing a dir/s and a bunch of applets overnight and see how that goes.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

TomWalker wrote:With 2 MB, the build-in VESA drivers allow modes that the 8900D can't display. The chip doesn't have the bandwidth to take advantage of 2 MB anyway, I'm fairly certain no boards were sold with more than 1 MB.
Thank you for your information. 768 KB and 2 MB display modes for the TVGA 8900D were just stubs. I'm also fairly certain that there were no TVGA 8900D graphics cards with 768 KB video RAM either.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

neozeed wrote:looking through the memory dump...

Code: Select all


a0000	top of DOS ram (640kb)

b8000	text space (CGA/EGA/VGA)

c0000	video rom
c5b80	video end

c6800	something
c8000	endthing

f0000	bios
ffffe	biosend
so I tried emm386 from MS-DOS 6.22 something like this
device=emm386.exe x=a000-afff i=b000-b7ff x=b800-bbef x=c000-c7fff i=c800-cfff i=d000-dfff i=e000-efff noems
It loads Windows 3.0 up ok.

And for fun, you can disable the VGA graphics memory for 753kb of conventional ram (732kb usable)
device=emm386.exe i=a000-afff i=b000-b7ff x=b800-bbef x=c000-c7fff i=c800-cfff i=d000-dfff i=e000-efff noems
In Windows 3.0 I get 615568kb of conventional ram, although I don't have much loaded....

Ok here is my config.sys:
DEVICE=C:\DOS\HIMEM.SYS
rem text mode
rem DEVICE=C:\emm386.exe i=a000-afff i=b000-b7ff x=b800-bbef X=C000-C7ff i=c800-cfff i=d000-dfff i=e000-efff noems
rem graphics mode
DEVICE=C:\emm386.exe x=a000-afff i=b000-b7ff x=b800-bbef X=C000-C7ff i=c800-cfff i=d000-dfff i=e000-efff noems
DEVICEHIGH=C:\DOS\SETVER.EXE
devicehigh=c:\dos\cd1.sys /d:cdrom01
DOS=HIGH,umb
FILES=30
autoexec.bat
@ECHO OFF
PROMPT $p$g
PATH C:\DOS
SET TEMP=C:\temp
lh doskey
lh mscdex /d:cdrom01
lh \smartdrv
mem /d in MS-DOS 5
Address Name Size Type
------- -------- ------ ------
000000 000400 Interrupt Vector
000400 000100 ROM Communication Area
000500 000200 DOS Communication Area

000700 IO 000A60 System Data
CON System Device Driver
AUX System Device Driver
PRN System Device Driver
CLOCK$ System Device Driver
A: - C: System Device Driver
COM1 System Device Driver
LPT1 System Device Driver
LPT2 System Device Driver
LPT3 System Device Driver
COM2 System Device Driver
COM3 System Device Driver
COM4 System Device Driver

001160 MSDOS 0013D0 System Data

002530 IO 002300 System Data
HIMEM 0004A0 DEVICE=
XMSXXXX0 Installed Device Driver
EMM386 000C20 DEVICE=
EMMQXXX0 Installed Device Driver
0005D0 FILES=
000100 FCBS=
000200 BUFFERS=
0001C0 LASTDRIVE=
000740 STACKS=
004840 MSDOS 000040 System Program

004890 COMMAND 000940 Program
0051E0 MSDOS 000040 -- Free --
005230 COMMAND 000100 Environment
005340 MEM 000050 Environment
0053A0 MEM 0176F0 Program
01CAA0 MSDOS 083540 -- Free --
09FFF0 SYSTEM 0114A0 System Program

0B14A0 MSDOS 000050 -- Free --
0B1500 MSDOS 006AD0 -- Free --
0B7FE0 SYSTEM 010020 System Program

0C8010 IO 007270 System Data
SETVER 000190 DEVICE=
SETVERXX Installed Device Driver
CD1 0070C0 DEVICE=
CDROM01 Installed Device Driver
0CF290 DOSKEY 001020 Program
0D02C0 MSCDEX 006D20 Program
0D6FF0 SMARTDRV 007690 Program
0DE690 MSDOS 011960 -- Free --


655360 bytes total conventional memory
655360 bytes available to MS-DOS
633920 largest executable program size

65011712 bytes total contiguous extended memory
0 bytes available contiguous extended memory
13201408 bytes available XMS memory
MS-DOS resident in High Memory Area
mem /d in Windows 3.0
Address Name Size Type
------- -------- ------ ------
000000 000400 Interrupt Vector
000400 000100 ROM Communication Area
000500 000200 DOS Communication Area

000700 IO 000A60 System Data
CON System Device Driver
AUX System Device Driver
PRN System Device Driver
CLOCK$ System Device Driver
A: - C: System Device Driver
COM1 System Device Driver
LPT1 System Device Driver
LPT2 System Device Driver
LPT3 System Device Driver
COM2 System Device Driver
COM3 System Device Driver
COM4 System Device Driver

001160 MSDOS 0013D0 System Data

002530 IO 002300 System Data
HIMEM 0004A0 DEVICE=
XMSXXXX0 Installed Device Driver
EMM386 000C20 DEVICE=
$MMXXXX0 Installed Device Driver
0005D0 FILES=
000100 FCBS=
000200 BUFFERS=
0001C0 LASTDRIVE=
000740 STACKS=
004840 MSDOS 000040 System Program

004890 COMMAND 000940 Program
0051E0 win386 000040 Data
005230 COMMAND 000100 Environment
005340 WIN 000060 Environment
0053B0 WIN 0002A0 Program
005660 win386 000070 Environment
0056E0 win386 002910 Program
008000 COMMAND 000070 Data
008080 COMMAND 000940 Program
0089D0 COMMAND 000100 Environment
008AE0 MEM 000060 Environment
008B50 MEM 0176F0 Program
020250 MSDOS 07EDA0 -- Free --


651264 bytes total conventional memory
651264 bytes available to MS-DOS
615584 largest executable program size

Handle EMS Name Size
------- -------- ------
0 060000

1671168 bytes total EMS memory
442368 bytes free EMS memory

65011712 bytes total contiguous extended memory
0 bytes available contiguous extended memory
1048576 bytes available XMS memory
MS-DOS resident in High Memory Area
Good memory configuration so far!

The big problem is that when I try to access the MS-DOS prompt while running Windows 3.0, the MS-DOS prompt crashes and Windows 3.0 displays a message complaining that , "This application has violated system integrity due to execution of an invalid instruction and will be terminated." I ran into that issue when I was using the Tseng Labs ET4000 graphics card with the VGA478S.DRV, the Windows 3.1 driver that displays 1024 x 768 in 256 colours with small fonts.

The Windows 3.0 drivers do not have the ability to display anything higher than 800 x 600 @ 256 colours with small fonts. The trade off is that by running with the VGA478S.DRV Windows 3.1 driver under Windows 3.0, I cannot run MS-DOS programmes in Windows 3.0 correctly without having to exclude UMB address segments B800 through DFFF.

The challenge is that I also have installed games that require the use of expanded memory such as Flight Simulator 5.1.
Last edited by ppgrainbow on Fri 04 Sep, 2015 9:52 pm, edited 1 time in total.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

- neozeed: Did you specifically add B000-B7FF into SYSTEM.INI? Otherwise, Windows will ignore those segments.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Battler wrote:- neozeed: Did you specifically add B000-B7FF into SYSTEM.INI? Otherwise, Windows will ignore those segments.
if you have emm386 running itll try to do the same thing, i was under the impression that it was for configs that didnt se emm38.6.

If both are doing the same layout wont they conflict with eachother??
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

I managed to load the CuteMouse driver instead of the Logitech mouse driver, which uses only 6 KB of memory. I managed to get up to 585 KB of memory usable for applications. However, as I'm using the VGA478S.DRV driver from Windows 3.1 on Windows 3.0, Windows complains about the DOS Prompt violating system integrity and closes!:
System Integrity Violation.png
System Integrity Violation.png (79.26 KiB) Viewed 24719 times
It turns out that using a buggy Tseng Labs ET4000 1024 x 768, 256 colour small font driver that was designed for Windows 3.1 caused the crash under Windows 3.0. I could be wrong, but I've been thinking that it can't handle largest executable memory greater than 576 KB...so, I had to revert to the Logitech mouse driver.
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by SA1988 »

strange, I'm using the same extract driver but that crash doesn't happen, and I'm using the same video mode, small fonts.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

neozeed wrote:if you have emm386 running itll try to do the same thing, i was under the impression that it was for configs that didnt se emm38.6.
No, Windows 3.0 *ALWAYS* looks in SYSTEM.INI and never at EMM386's parameters. Windows 3.1 seems to also look at EMM386. It's also why Windows 3.0 locks up in Virtual PC 2007 because it tries to allocate segments C800-CBFF even if EMM386.EXE is loaded with X=C800-CBFF, and Virtual PC 2007's Video BIOS is larger than 32 kB so it ends up overwriting part of it.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Battler wrote:
neozeed wrote:if you have emm386 running itll try to do the same thing, i was under the impression that it was for configs that didnt se emm38.6.
No, Windows 3.0 *ALWAYS* looks in SYSTEM.INI and never at EMM386's parameters. Windows 3.1 seems to also look at EMM386. It's also why Windows 3.0 locks up in Virtual PC 2007 because it tries to allocate segments C800-CBFF even if EMM386.EXE is loaded with X=C800-CBFF, and Virtual PC 2007's Video BIOS is larger than 32 kB so it ends up overwriting part of it.
Have a tsr you can force load at memory locations?

Otherwise is all feels like its working fine.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

ppgrainbow wrote:
,I've been thinking that it can't handle largest executable memory greater than 576 KB...so, I had to revert to the Logitech mouse driver.
Using the stock vga driver, i get 615kb usable dos ram on 3.0 with ms-dos 5.00 using emm386 from 6.22.

Ill write some malloc stress programs for dos and windows 3.0 and see how they perform.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

neozeed wrote:
ppgrainbow wrote:
,I've been thinking that it can't handle largest executable memory greater than 576 KB...so, I had to revert to the Logitech mouse driver.
Using the stock vga driver, i get 615kb usable dos ram on 3.0 with ms-dos 5.00 using emm386 from 6.22.

Ill write some malloc stress programs for dos and windows 3.0 and see how they perform.
I used the QEMM386 8.03 driver.

With the stock HIMEM driver from MS-DOS 5.0, you won't be able to access more than 16 MB of extended memory. The EMM386 driver from MS-DOS 5.0 will only use the existing amount of extended memory for expanded memory. EMM386 supports a maximum of 32 MB of EMS memory while QEMM386 supports a maximum of 256 MB of EMS memory.

It would be a good idea to write Malloc stress programmes for MS-DOS 5.0 and Windows 3.0 to see if any errors or other erratic behaviour popups up.

By the way, have you ever considered writing a generic VESA-compatible SVGA 256 colour driver that displays resolutions of 640 x 480, 800 x 600 and 1024 x 768 for Windows 3.0? I'm wondering how difficult would it be to do it...
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

I've never written or even patched a windows 3.x driver so I really don't know.

I manually copied in the Windows 3.1 driver for the OAK OTI-067. The 256 colour modes don't work (havent tried on Windows 3.1, but the 800x600x8bit looks like it's not paging to the correct video page. as always I tested *WITHOUT* any emm386 first) I got the drivers from here:

http://cd.textfiles.com/cica/cica9603/d ... oakdrv.zip

The 800x600x16 colour one works. Even with emm386.
Image

I'm digging around to find my old QuickC window Windows so I can malloc some crap.
User avatar
ppgrainbow
Posts: 479
Joined: Thu 04 Sep, 2014 7:03 am
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by ppgrainbow »

I doubt it anyone has time anymore to write a generic SVGA driver for Windows 3.0 citing compatibility and stability issues as the OS was never very well supported on graphics cards with more than 1 MB of display memory.

On the AMI 386 clone, I'm currently running the OAK OTI-067 graphics card with 512 KB VRAM, running Windows 3.0 in Norton Desktop 2.2 in 800 x 600 resolution at 256 colours. Unlike the Tseng ET4000 graphics card, the OTI-067 graphics card runs pretty well on Windows 3.0 without any problems. The machine has MS-DOS 4.01 with 4 MB memory.
AMI 386 clone screenshot.png
AMI 386 clone screenshot.png (194.66 KiB) Viewed 24675 times
I got the drivers from this page: http://www.vogonsdrivers.com/getfile.ph ... menustate=

It's called the Oak VGA supplement drivers which includes video display driver support for Windows 2.11 (286 and 386 versions), Windows 3.0 and Windows 3.1 as well as drivers for other MS-DOS based software. The Windows 3.1 version has the OEMSETUP.INF file and the Windows 3.0 version as the SETUP.INF file.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

found some UMB allocation stuff here:

https://courses.engr.illinois.edu/ece39 ... H13-5.html

and put together this amateur hour special... :lol:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <dos.h>

#define ELEMENTS 4096
#define BLOCK 4096

void torture(void);
void memstat(int input);
void getstrat(void);
int  getlink(void);

int main()
{   union REGS reg;
	struct SREGS seg;
	int err;

	printf("testing conventional memory..\n");
	torture();

	reg.h.ah=0x58;
	reg.h.al=0;	/*get allocation strategy*/
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	/*printf("err %X, AX is %X\n",err,reg.x.ax);*/
	if(err==0){
	memstat(reg.x.ax);

	if(reg.x.ax!=0x41)
		{
		memset(&reg,0x0,sizeof(reg));
		memset(&seg,0x0,sizeof(seg));

		printf("set memory strategy best fit high\n");
		reg.h.ah=0x58;
		reg.h.al=0x1;
		reg.x.bx=0x41;	/*best fit high only*/
		err=int86x(0x21,&reg,&reg,&seg);
		/*err=(err>>8);
		printf("err %X, AX is %X\n",err,reg.x.ax);
		memstat(reg.x.ax);*/
		getstrat();
		}

	printf("get upper memory link\n");
	memset(&reg,0x0,sizeof(reg));
	memset(&seg,0x0,sizeof(seg));
	reg.h.ah=0x58;
	reg.h.al=0x2;	/* get UMB link in AL*/
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	printf("We want the AL register to be a 0, it is: %X\n",reg.h.al);
	}
	memset(&reg,0x0,sizeof(reg));
	memset(&seg,0x0,sizeof(seg));

	printf("turing on UMB, I think\n");
	reg.h.ah=0x58;
	reg.h.al=0x3;
	reg.x.bx=0x1;
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	/*printf("err %X, Al is %X\n",err,reg.h.al);*/
	err=getlink();

	if(err==1) {
    	printf("testing UMB\n");
		torture();
		}

	printf("turing off UMB, I think\n");
	memset(&reg,0x0,sizeof(reg));
	memset(&seg,0x0,sizeof(seg));
	reg.h.ah=0x58;
	reg.h.al=0x3;	/*set umb link*/
	reg.x.bx=0x0;	/*0 if off*/
	err=int86x(0x21,&reg,&reg,&seg);
	/*err=(err>>8);
	printf("err %X, Al is %X\n",err,reg.h.al);*/

	printf("set memory strategy back to normal\n");
	memset(&reg,0x0,sizeof(reg));
	memset(&seg,0x0,sizeof(seg));
    reg.h.ah=0x58;
	reg.h.al=0x1;
	reg.x.bx=0x0;	/*best fit high only*/
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	/*printf("err %X, AX is %X\n",err,reg.x.ax);
	memstat(reg.x.ax);*/
	getstrat();

	exit(0);
}

void torture()
{
int count;
int ecount;
int loop;
unsigned long countkb;
int *array[ELEMENTS];

countkb=0;
count=0;
memset(array,0x0,ELEMENTS);
for(ecount=0;ecount<ELEMENTS;ecount++)
	{
	array[ecount]=malloc(BLOCK);
	if(array[ecount]==0x0) {
		ecount=ELEMENTS;
		ecount++;}
	else
		{
		for(loop=0;loop<26;loop++)
			{
			int iloop;
			memset(&array[ecount],65+loop,BLOCK);
			for(iloop=0;iloop<BLOCK;iloop++) {
				if(!memcmp(&array[ecount]+iloop,65+loop))
					printf("E");
				}
			}
		count++;
		printf("%d\t\r",count);
		}
	}
countkb=(long)count*(long)BLOCK;
printf("\t\t\r%d * %d blocks! or %ldbytes (%ldkb)\n",count,BLOCK,countkb,countkb/1024L);
for(ecount=0;ecount<ELEMENTS;ecount++)
	{
	if(array[ecount]!=0x0)
		free(&array[ecount]);
		array[ecount]=0x0;
	}

fflush(stdout);
}

void memstat(int input)
{
switch (input) {
	case 0x0:
		printf("first fit low");
		break;
	case 0x1:
		printf("best fit low");
		break;
	case 0x2:
		printf("last fit low");
		break;
	case 0x80:
		printf("first fit high");
		break;
	case 0x81:
		printf("best fit high");
		break;
	case 0x82:
		printf("last fit high");
		break;
	case 0x40:
		printf("first fit high only");
		break;
	case 0x41:
		printf("best fit high only");
		break;
	case 0x42:
		printf("last fit high only");
		break;
	default:
		printf("%x unknown!",input);
		break;
	}
	printf("\n");
}

void getstrat()
{
	union REGS reg;
	struct SREGS seg;
	int err;

	reg.h.ah=0x58;
	reg.h.al=0;
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	/*printf("err %X, AX is %X\n",err,reg.x.ax);*/
	if(err==0)
		memstat(reg.x.ax);
}

int getlink()
{
	union REGS reg;
	struct SREGS seg;
	int err;

	printf("get upper memory link status in AL\t");
	memset(&reg,0x0,sizeof(reg));
	memset(&seg,0x0,sizeof(seg));
	reg.h.ah=0x58;
	reg.h.al=0x2;
	err=int86x(0x21,&reg,&reg,&seg);
	err=(err>>8);
	printf("%X\n",reg.h.al);
	return(reg.h.al);
}
REMEMBER that DOS must be HIGH,UMB ... otherwise this won't allocate UMB's.

Code: Select all

DEVICE=C:\emm386.exe x=a000-afff i=b000-b7ff x=b800-bbef X=C000-C7ff i=c800-cfff i=d000-dfff i=e000-efff noems
4kb blocks gives me 512kb conventional, and 172kb of UMB
1kb blocks gives me 538kb conventional, and 183kb of UMB

Code: Select all

device=emm386.exe i=a000-afff i=b000-b7ff x=b800-bbef x=c000-c7fff i=c800-cfff i=d000-dfff i=e000-efff noems
4kb blocks gives me 600kb conventional, and 144kb of UMB
1kb blocks gives me 632kb conventional, and 152kb of UMB
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

And using a QuickWin variation of torture, I can allocate 22MB of ram, (VM has 16MB of ram, and 16MB of swap) with QuickC, Word 2.0 and Excel 3.0 running.

It didn't crash... I'll leave it running some dir/s and dos mem torture for the heck of it. I don't think you can open HMA's to DOS BOXes in Windows 3.0 .. I checked "Uses High Memory Area" but that doesn't seem to do anything. Maybe because of emm386...? Let me try that! No it won't let me turn on the allocate UMB strategy.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

neozeed wrote:Have a tsr you can force load at memory locations?
You can do that with the /L: switch that both DEVICEHIGH and LH/LOADHIGH support. If you assign B000-B7FF to UMB's, that region will be /L:0 or /L:1, I forgot whether it's zero-based or one-based. But try both and see what MEM /D /P says (it lists everything loaded into mememory, and the location it's loaded at). Try loading a CD-ROM driver there and then accessed a drive. Then move the CD-ROM driver to C800-EFFF and repeat the process.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Image

My lh can't specify segments... so I loaded MSD into high memory. It's working fine. I need some more TSR's to load that I can verify work... I guess sidekick and some other crap.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

- neozeed: Install MS-DOS 6.0. I think that's the first version that introduced the /L: parameter.

Edit: I just did what I did the last time I experienced a problem and... I somehow experience no problems now. Maybe that segment-related commit from Tom (http://retrosoftware.co.uk/hg/pcem/rev/1578e375679d) fixed the problem.
neozeed
Posts: 176
Joined: Tue 08 Jul, 2014 4:41 am
Location: Hong Kong SAR
Contact:

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by neozeed »

Battler wrote:- neozeed: Install MS-DOS 6.0. I think that's the first version that introduced the /L: parameter.

Edit: I just did what I did the last time I experienced a problem and... I somehow experience no problems now. Maybe that segment-related commit from Tom (http://retrosoftware.co.uk/hg/pcem/rev/1578e375679d) fixed the problem.
Try the latest snaps.. I can alloc UMB's memset them, and check the contents, and deallocate them without anything freaking out. Windows 3.0 loads without making any system.ini changes..
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [DISCUSSION] MS-DOS memory optimisation tricks

Post by Battler »

- neozeed: As I said, I just repeated in the latest revision the actions that some time ago made everything behave erratically, and everything behaves fine now. I even mentioned which revision I think fixed the problem. :p

Edit: Just noticed this happening:
1. Start LBA 1.
2. Get to the main menu.
3. Quit LBA 1.
4. Start LBA 1 again. It will freeze after it's done playing the MIDI and the only thing that will remove the freeze is quitting the emulator and relaunching it.

Edit: It happens regardless of where the CD-ROM driver is loaded. And yes, the CD-ROM driver has to do with it because at that point the game checks if the CD is present.

Edit #2: This might be the CD Audio thread bug striking. Because at the main menu, the game starts playing audio from the CD (the background music), and most probably the thread gets stuck, causing any further CD reads to get stuck, hence the game freezing when it's restarted and does the CD check again.

Edit #3: For some reason, it only happens when I boot DOS from a floppy, but not when I boot it from hard disk.

Edit #4: Found why. The DOS on hard disk used OAKCDROM.SYS. The DOS on the floppy used VIDE-CDD.SYS version 2.15. So it seems there's a bug in PCem that causes VIDE-CDD.SYS to misbehave (regardless of where in the memory it's loaded).

Edit #5: Did some tests. Only OAKCDROM.SYS works (and it's ironically the one that consumes the most memory). VIDE-CDD.SYS has the above-mentioned problem. GSCDROM.SYS makes LBA 1 freeze when transferring speech files. MTMCDAI.SYS makes LBA 1 freeze at CD check on the first run. I would try XCDROM.SYS but I remember it not supporting mixed mode CD's.

This IMHO clearly points me at there being a severe bug in the CD emulation.
Post Reply