Skip to content

Commit

Permalink
Getting ready for release of new version...
Browse files Browse the repository at this point in the history
  • Loading branch information
PluMGMK committed Apr 22, 2022
1 parent 79e72f8 commit 4837953
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 2,946 deletions.
68 changes: 0 additions & 68 deletions INSTALL.BAT

This file was deleted.

45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ However, it also means that unlike the other implementations, a custom CD image
|Includes extra MIDI tracks from PS1 | Yes | Yes | No |
|Can be used with custom Dosbox builds | No (unless you search for pointers and [compile TPLS yourself](https://github.com/Snaggly/Rayman1Dos-TPLS/blob/master/OffsetList.h)) | No (unless you apply the [patch](https://raymanpc.com/forum/viewtopic.php?f=89&t=28341) and compile Dosbox yourself) | Yes, no recompilation needed! |
|Can be used on Windows 3.x / 9x | No | No | Yes |
|Can be used on pure DOS | No | No | Yes, with a DPMI host|
|Can be used on pure DOS | No | No | Yes |
|Rayman versions supported | All versions mentioned [here](https://github.com/RayCarrot/RayCarrot.RCP.Metro/blob/2e5ace35ba8d064dc7a592d9700aa311853b6deb/RayCarrot.RCP.Metro/Utilities/Games/Rayman%201/TPLS/TPLSRaymanVersion.cs) | All versions mentioned [here](https://github.com/RayCarrot/RayCarrot.RCP.Metro/blob/2e5ace35ba8d064dc7a592d9700aa311853b6deb/RayCarrot.RCP.Metro/Utilities/Games/Rayman%201/TPLS/TPLSRaymanVersion.cs) | v1.12 US and EU, v1.20 German and IT-SP-DU, v1.21 US – if you need another version added, please get in touch!|

## Installation and usage
Expand All @@ -29,44 +29,35 @@ However, it also means that unlike the other implementations, a custom CD image
* Make sure your Rayman version is supported (see above table) – if not, please let me know and I'll see what I can do!
* Download and extract a release from the [releases page](https://github.com/PluMGMK/rayman-tpls-tsr/releases).
* Change the `IMGMOUNT` command in the `autoexec` section of your config file to mount the `tplstsr3.cue` file, rather than the game's original CD image.
* Replace the invocation of `RAYMAN.EXE` in the `autoexec` section with `TPLSWRAP.EXE`.
* Copy `TPLSTSR3.EXE` and `TPLSWRAP.EXE` from the release into the same folder as your `RAYMAN.EXE`.
* You will probably also need a DPMI host – download [CWSDPMI](http://sandmann.dotster.com/cwsdpmi/csdpmi7b.zip) and extract `CWSDPMI.EXE` into the same folder as the other two files.
* Before the invocation of `RAYMAN.EXE` in the `autoexec` section, add `D:\TPLSTSR4.EXE` (where `D` is your CD drive letter).
* Run Dosbox with your new config file and enjoy TPLS!

### If on native DOS or Windows 3.x / 9x (having used Ubi Soft's installer to install _Rayman_)

* Make sure your Rayman version is supported (see above table) – if not, please let me know and I'll see what I can do!
* Download and extract a release from the [releases page](https://github.com/PluMGMK/rayman-tpls-tsr/releases).
* Use the `tplstsr3.cue` (or `tplstsr3.toc`) and `tplstsr3.bin` files to burn a CD-R – it should be possible to do this with `cdrdao` on Linux, or perhaps [ImgBurn](https://www.imgburn.com/) on Windows.
* Insert the new CD into your PC running DOS or Windows, and run `INSTALL.BAT`.
* If you're running pure DOS (no Windows 3.x / 9x or OS/2), and don't have a DPMI host (or don't know what that is), you will again probably need to download [CWSDPMI](http://sandmann.dotster.com/cwsdpmi/csdpmi7b.zip) and extract `CWSDPMI.EXE` into the same folder as `RAYMAN.EXE`.
* Use the `tplstsr4.cue` (or `tplstsr4.toc`) and `tplstsr4.bin` files to burn a CD-R – it should be possible to do this with `cdrdao` on Linux, or perhaps [ImgBurn](https://www.imgburn.com/) on Windows.
* Insert the new CD into your PC running DOS or Windows.
* Before running Rayman, run `D:\TPLSTSR4.EXE` (where `D` is your CD drive letter).
* Run `C:\RAYMAN.BAT` and enjoy TPLS!

## Compilation

Linking the TSR requires DOS, so I've included a `BUILD.BAT` script that can do the whole job on DOS itself.
`TPLSTSR4` (unlike the previous version) is a plain old `MZ` executable, so you can assemble it with MASM, JWASM, UASM, etc.

Prerequisites:
* A DOS build of JWasm. You can get this from [here](https://www.japheth.de/Download/JWasm/JWasm211bd.zip) (from [japheth.de](https://www.japheth.de/JWasm.html)).
* The `DLINK` command for the DOS32 DOS Extender by Adam Seychell. This is hard to come by, but I got it from [here](https://hornet.org/cgi-bin/scene-search.cgi?search=AM).
* Look for "/code/pmode/dos32b35.zip" on that page.
```
uasm -mz TPLSTSR4.ASM
```

## Why DOS32?
It will warn about no stack being defined, but it should still produce a working `TPLSTSR4.EXE` in DOS `MZ` format.

One might wonder why I'm using an obscure DOS extender whose author has disappeared, and which is so hard to find.
Well, the reason is that it's the only __documented__ and __working__ way I could find to make a Protected-Mode TSR.
## How does it work?

In fact, this is why the source file is called `TPLSTSR3.ASM` – my _third_ attempt to make this settled on DOS32. The previous two attempts had been:
Unlike the old version (using the DOS32 extender), this is a normal Real Mode TSR.
However, it still manages to inject 32-bit Protected Mode code into Rayman.
It does this by attaching a payload to whichever `HMIDRV.386` sound driver Rayman is using (this is why it won't work if Rayman's sound isn't configured), and saving it into a temporary file.
Rayman is then directed to open this temporary file instead of the original file when looking for its sound driver.

1. Create a standard Real-Mode TSR hooking `int 2Fh` directly.
2. Use the well-documented [DPMI Resident Service interface](http://www.delorie.com/djgpp/doc/dpmi/ch4.8.html) to create a Protected-Mode TSR, hooking `int 31h AX=0300h`.

The first attempt was quickly abandoned, since I realized there would be no good way to switch back to Protected Mode and find Rayman's data in memory.

The second attempt showed more promise, until I realized that despite the extensive _documentation_, nobody has actually _implemented_ this lovely Resident Service interface! Yes, really!
At least, I haven't been able to find any implementations, and I found a forum post somewhere, where someone else in my situation wondered if these functions were just theoretical…

So, I went with DOS32, since it has a documented and working TSR function, `int 31h AX=EE30h`.
In fact, with the experience gained writing this thing, I've come to realize that a normal DPMI client with plain old `int 21h AH=31h`
would probably work just as well, but we are where we are…
When Rayman loads the sound driver, it initially transfers control to the payload, which is able to communicate with the TSR's Real Mode stub.
The payload first sets up code and data segments for the actual sound driver, and then it sets up the hooks and overrides needed for TPLS itself.
It then transfers control to the real sound driver, which is able to operate normally.
5 changes: 0 additions & 5 deletions SED16BIN/FILE_ID.DIZ

This file was deleted.

21 changes: 0 additions & 21 deletions SED16BIN/README.16X

This file was deleted.

Binary file removed SED16BIN/SED.COM
Binary file not shown.
Loading

0 comments on commit 4837953

Please sign in to comment.