Check out isolinux + memdisk.
I have created fully bootable win9x 'installs' this way.
For win98, you need at least 384 mb to allocate for the 'ramdisk', and you need to make aggressive use of drivespace3 compression with ultrapack.
This means your P4 needs at least 1gb of RAM present.
In a nutshell:
1) create a 384mb flat disk image, and configure it for use in a pc emulator of your choice. (Bochs, qemu, virtual pc, vmware, whatever.)
2) use Dos 6.22's drivespace utility to compress it, empty.
3) install win9x, and be miserly. Avoid installing pointless and outdated stuff, like 'online services', but keep useful stuff like hyperterminal.
4) install the universal ata driver, and the universal vesa video driver. (Unless you are tailoring this for a single, known system, and have the drivers. Some VM software gives good enough configurability to properly set that up. Caveat emptor.)
5) once installed, convert to drivespace 3, then run the disk packer. You may be able to get IE6 and pals on after doing so, depending on the install options you picked.
6) once you have it 'the way you want it', gracefully down the VM, then copy off the raw flat disk image.
7) configure ISO linux's mkisofs process, to make a menu entry calling 'memdisk' as the kernel, and your flat hdd image as the initrd. Set it as the default boot option. (You can set up OTHER images this way as well, like 100mb dos 6.22 images, freedos images, etc... that have all the dos network stack whizbangs and useful utilities installed and ready to use also!)
😎 burn the resulting .iso image, boot it, and enjoy.
More:
Memdisk is a small int13 and int15 interception program, that allocates xms memory BEFORE the OS loads, then subtracts the size used from the reported size from an int15 call. It then responds to int13 calls, using this block of 'owned' memory.
It is sufficient to fully and completely boot dos and win9x entirely from the ramdisk it provides, with no additional drivers. (Though win9x will complain mightily about being in 'msdos compatability mode' under the performance system properties window. I guarantee you, though, it is far and away faster than any actual disk controller, even with jumping to realmode to do disk io.)
Boot time can be very protracted, however. Reading 384mb of data into RAM takes awhile from a CD drive.
I mention win9x, because of its small footprint, and the availability of old versions of things like winimage that will run on it just fine.