• Please review our updated Terms and Rules here

Wolf3D hacked for 8086/8088 CPUs

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
this is something i wanted to attempt for a while, and last night i did it. i took the original (now public domain) source code for Wolfenstein 3D and went through it all (ASM and C) modifying it to play on an 8086 or 8088 system.

if you try it on that kind of CPU, the game will say sorry you need a 286 or better. what i did was bypass the CPU check, and change a lot of SHR/SHL instructions that had a value greater than 1 to multiple SHR/SHL _,1 instructions. also had to totally remove XMS detection code, as that caused a lock up on my 8088. a few other modifications had to be made as well.

i also had to disable all sound (edit: it works with sound now) to get it to work for some reason, i'll be trying to get that working as well but i do have a working 8086 compatible wolf3d exe that anybody who wants to get can have:

http://www.rubbermallet.org/wolf8086.exe

just put it in the same folder on your machine as the wolf3d.exe of course. it SHOULD work with both registered and shareware data files, but i've only tested registered.

all you need is a VGA card and it'll go. believe it or not, it's actually quite playable at 4.77 MHz especially if you make the view window smaller. i was expecting much worse performance. makes me wonder why they made it require a 286 in the first place.

have fun! :D

EDIT: UPDATE!! i fixed the sound issue. i re-uploaded the new EXE to the same URL. if you got the version with disabled sound, redownload the WOLF8086.EXE file. everything works 100% perfectly now. it didn't make the game any slower that i can notice. it's really cool hearing that classic "AH! STOP!" and "MEIN LEBEN!" from the guards on an 8088. :)

and a second update.. that same EXE at that URL now has a cheat menu right in the main menu that i added in addition to the 8086 hack. all cheats tested and working perfectly:

wolf3dhack2.png


plus i changed multiple lines of SHL/SHR _,1 of SHL/SHR _,CL but i haven't noticed a performance increase at all on my 4.77 MHz boxes.
 
Last edited:

gerrydoire

Veteran Member
Joined
Aug 25, 2008
Messages
1,145
I wish I had your smarts for this kind of thing...

I will be trying your modified version :):):):)
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
it was actually simpler than it sounds. i've never actually written a program other than hello world in either C or ASM, but i still managed to get this working. :)

this gave me some courage to play around more with C though, i really need to abandon quickbasic lol. it really isn't THAT different from BASIC. mostly just syntax.

also thanks to mike brutman who mailed me a spare borland turbo C++ 3.0 for DOS copy he had about a year-and-a-half-ish ago. thats what i used to edit and compile this. :p
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
also, for kicks i think i'm gonna haxx0r up a cheat menu for the game. :cool:

oh, and as far as performance of wolf3d on an 8088 YMMV becuase i have a diamond speedstar w/ tseng ET4000 chipset in the 8088 i'm playing it on, which is like ridiculously fast compared to just about any other 8-bit compatible VGA card out there. i would think most cards would not be quite as fast playing this game. i'd love to hear results.
 

southbird

Experienced Member
Joined
Sep 11, 2009
Messages
316
That's fantastic. Keep it up and see if you can get the sound to work (though that might put additional load on it, so it's hard to say whether or not it's even worth the endeavor.) Guess I might have to get myself a VGA powered XT now... :) I was kind of thinking of getting one of those luggables again anyway. Heheh...
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
hey, big update! the sound problem much easier than i thought to take care of. it was because the ASM routines that handled sound management for the game has pusha/popa instructions. i simply changed them to indivisual push/pop instructions in the right order, and it worked great on my 8088. i can hear everything through my SB Pro v2.0.

re-download it from the same URL i gave earlier and overwrite the old one if you had downloaded that.

http://www.rubbermallet.org/wolf8088.exe

:biggrin:
 

Anonymous Coward

Veteran Member
Joined
Aug 11, 2004
Messages
1,540
Location
Shandong, China
I'm glad there's an 808x verion available now. "JoJo Reloaded" released a V20 version of Wolf3D a few years back. I have it on my 10MHz V30 system. I don't know if I'd describe it as enjoyable, but it is somewhat playable. I'll have to try your recommendation on the ET4000 card. I'm running a VGA wonder at the moment. I never considered it to be slow, but if et4000 is that much faster then I need to try it.
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
I'm glad there's an 808x verion available now. "JoJo Reloaded" released a V20 version of Wolf3D a few years back. I have it on my 10MHz V30 system. I don't know if I'd describe it as enjoyable, but it is somewhat playable. I'll have to try your recommendation on the ET4000 card. I'm running a VGA wonder at the moment. I never considered it to be slow, but if et4000 is that much faster then I need to try it.

i didn't know that was out. wouldn't V20 code work on an 8088, or does it have instructions an 8088 doesn't? on my 4.77 MHz, if i shink the view window to about half of full size it's more or less playable. it can get hard to aim well sometimes though. i might try looking at the code a little more in depth and maybe make some modifications to speed up. i'd like to try it with the horizontal resolution cut in half, and just duplicate each slice of the picture and see how it is.
 

barythrin

Veteran Member
Joined
Oct 5, 2005
Messages
6,256
Location
Texas
I wonder what optimizations could be applied? The interesting but painful part of post-assembly editing is different commands that have the same result but 1 or two less ticks to them (for extreme resource editing).

Also it might be interesting to see what limitations there could be in general, as in some code may just take the time it takes no matter the resources (how's it run in dosbox or a ((2/3)86)?

Either way, pretty sweet project Mike.
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
I wonder what optimizations could be applied? The interesting but painful part of post-assembly editing is different commands that have the same result but 1 or two less ticks to them (for extreme resource editing).

Also it might be interesting to see what limitations there could be in general, as in some code may just take the time it takes no matter the resources (how's it run in dosbox or a ((2/3)86)?

Either way, pretty sweet project Mike.

yeah good thinking. there probably are a few bits of code that could be changed to take a few less clock cycles that didn't really matter when using a 286+.

i'm no expert on that part though. i would need a larger brain like the one Trixter has. he's obviously great with ASM optimization. maybe he'll want to take a look at my modified source files if he sees this thread.
 

barythrin

Veteran Member
Joined
Oct 5, 2005
Messages
6,256
Location
Texas
So on a bit crazier level, how easy was the tweaking? Find/Replace easy or a bit more logic to it? .. think it could be automated? ;-)

8088patch game.exe and get Ultima and other goodies to be compatible? heh.. probably WAY less than possible but hey if you're bored and got time, it may be an interesting project to see if you could write a patcher with knowledge you and others know on compatible opcodes.

Even a compiled binary you've got all the ML right there. I can see lots of things that might get in the way (memory allocation, need to replace opcodes with same size commands or modify jmps accordingly).
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
So on a bit crazier level, how easy was the tweaking? Find/Replace easy or a bit more logic to it? .. think it could be automated? ;-)

8088patch game.exe and get Ultima and other goodies to be compatible? heh.. probably WAY less than possible but hey if you're bored and got time, it may be an interesting project to see if you could write a patcher with knowledge you and others know on compatible opcodes.

Even a compiled binary you've got all the ML right there. I can see lots of things that might get in the way (memory allocation, need to replace opcodes with same size commands or modify jmps accordingly).

i'm not an ASM expert, but that would probably be impossible to make a universal patcher if i had to guess. it would be cool though. :)

as far as what i had to modify, it was a bit more complicated than find/replace. i had to completely cut out XMS detection routines like i said, because it locked my 8088s up. i commented out the ASM code that tests for less than a 286, and made it always JMP to the "@@Has286" subroutine.

i also had to remove the code for fast palette changes. it changed the whole 768 bytes of palette data for the video at once with an OUTSB instruction, which an 8088 can't understand. i made it always change it one palette value at a time, looped 768 times.

it also had the occasional pusha/popa that i had to remove and replace with lists of single push/pop instructions. there were also a bunch of SHL/SHR instructions that specified more than 1 place shift at a time. i had to split them all into multiple SHL/SHR _,1 instructions. i might be forgetting something.
 

Fallo

Experienced Member
Joined
Jan 2, 2009
Messages
432
i didn't know that was out. wouldn't V20 code work on an 8088, or does it have instructions an 8088 doesn't? on my 4.77 MHz, if i shink the view window to about half of full size it's more or less playable. it can get hard to aim well sometimes though. i might try looking at the code a little more in depth and maybe make some modifications to speed up. i'd like to try it with the horizontal resolution cut in half, and just duplicate each slice of the picture and see how it is.

The V20 has the 286's real mode instructions: PUSHA, POPA, shift and rotate instructions with values greater than 1, INS, OUTS, INSB, OUTSB, INSW, OUTSW, ENTER, BOUND, and LEAVE.
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
What about CGA or EGA support? I'm waiting for a Video-7 VEGA I bought off EBang but its maximum is 752x410 enhanced EGA.

that would actually take some pretty extreme modification, would be interesting though. CGA Wolf3D.

*shudders*
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
The V20 has the 286's real mode instructions: PUSHA, POPA, shift and rotate instructions with values greater than 1, INS, OUTS, INSB, OUTSB, INSW, OUTSW, ENTER, BOUND, and LEAVE.

if that's the case then it sounds like the only thing that would have been required for him to make it work is bypass the 286 detection code. comment out one line and modify another.
 

Jorg

Veteran Member
Joined
Aug 31, 2003
Messages
1,322
Location
Switzerland
also, for kicks i think i'm gonna haxx0r up a cheat menu for the game. :cool:

LOL.. now I have to install a VGA card...

"Wolf.exe -goobers" should give you the cheats.

I'd have to try and see what happened to my skills. At one time, I was able to play the first three levels blindfolded.
 

Mike Chambers

Veteran Member
Joined
Sep 2, 2006
Messages
2,621
LOL.. now I have to install a VGA card...

"Wolf.exe -goobers" should give you the cheats.

I'd have to try and see what happened to my skills. At one time, I was able to play the first three levels blindfolded.

lol yeah goober is always there. i decided to add a cheat menu anyway. i've spent the last hour adding it. you can get to it right from the main menu.

wolf3dhack.png


:evilsmile:

i'll probably post a second EXE tonight or tomorrow that includes the 8086 hack as well as this cheat menu. i'm actually starting to pick up C at this point after all this hackin'.
 

JoJo_ReloadeD

Experienced Member
Joined
May 12, 2007
Messages
120
Nice work :)

it also had the occasional pusha/popa that i had to remove and replace with lists of single push/pop instructions. there were also a bunch of SHL/SHR instructions that specified more than 1 place shift at a time. i had to split them all into multiple SHL/SHR _,1 instructions. i might be forgetting something.

That's why I choose to make the port to the v20/v30's.. they handle SHL with multiple shifts a time.. Those bunch of shr xx,1 ... would overkill a 8088...
 
Top