Laydock-2 enhancement patch v1.0
--------------------------------
(c) 2019 by FRS

This patch does many enhancements in the game Laydock-2 for the MSX2+, focused
to improve the playability, performance and balance the difficulty of the game
between the one player and two player modes.

==============================
Background:

The Laydock franchise has three games: Laydock-1 (MSX2), Super Laydock (MSX1)
and Laydock-2 (MSX2+).

The first instalment was kinda of a proof of concept, and one of the very
early MSX2 titles. Super Laydock came later, and was a fantastic game. It
improved the original concept in every aspect.

But when Laydock-2 came out, it felt like a rushed release. Its gameplay wasn't
up to the same standard that Super Laydock had set. While it has great
graphics, big sprites, impressive cutscenes and a lovely soundtrack,
it felt that the game still needed a bit more polishing specifically on the
gameplay. Its weapons felt clunky, sluggish and way less powerful than they
were on Super Laydock. The difficulty was also poorly balanced between the
1-player and 2-player modes. And there was no good reward system in place,
to spice things up. Because of this, the gameplay felt plain and boring.

This patch tries to accomplish exactly that: to give this game that last
polishing touches it needed so much. These were the modifications that were
mare:


- New title screen. The original title screen was a hasty digitisation. The
  MSX2+ trump card was to have thousands simultaneous of colors, something
  just unseen at that price range in 1988, and even less on an 8-bit machine.
  But the title screen of this game was almost monochrome and was full of
  artefacts, leaving a not so great impression.
- Turbofixed the game. The turbo is automatically enabled on machines that have
  the CHGCPU routine on BIOS, and on Panasonic MSX2+ machines. Even the sample
  player will work at the correct rate, regardless of the CPU speed.
- Optimised many of the game routines, so it runs a quite faster now even at
  3.57MHz
- Modified the sample player to play the samples at the PPI instead of the
  PSG. The samples were 1bit anyway, and this saved space for the new routines
- Fixed a bug in the intro demo that caused the loading screen to be shown
  (and the respective sample to be played) only once every 256 loops of the demo
- Implemented Double-buffering on the SAT (Sprite Attribute Table)
- Fixed a bug that caused the shield meter to show an incorrect percentage
- Fixed a race condition in the vertical scroll code that caused the sprites
  to jump on certain CPU speeds
- Fixed a bug that made the Alpha weapon launch backwards in the horizontal
  stages
- Bugfix: Bulldog didn't clear its explosion last sprite frame from the screen 
- The shield energy is now refilled at the beginning of each planet. This was
  implemented since the game allows you to start with a full shield at any
  stage you already played anyway.

- Adjusted the power and speed of the weapons to match those of Super Laydock
- To compensate for the stronger weapons, the shield now works differently:
  - It holds 20% less initial power
  - As a reward for careful players, the undocked ships now can recharge up to
    8 units (50% of the max) per planet. It slowly recharges when the docking
    power is kept maxed for at least 4 seconds
  - There's a new dotted gauge just below you shield gauge, that show the
    amount of charging you still have left
- The docking power also plays a rule at the fire rate of your projectile
  weapons. At the minimal level, your weapons have the original Laydock2 fire
  rate. At the maximum docking power, your weapons will match the fire rate of
  Super Laydock.
- The docking power now discharges when taking hits even when the players are
  undocked. This will reflect in the ships fire rate (as explained before), and
  will also make docking harder, in a way to balance the difficulty between the
  single-player and dual-player modes.
- All the weapons you have available can be fired at any time now. Some weapons
  were blocked from firing under some conditions as a workaround for bugs they
  had. This caused a nightmare for the player since he selected weapons that
  sometime just wouldn't fire without any explanation. Those bugs were fixed, so
  the blocks could be removed. 
- The "Double" weapon now kills both airborne and ground enemies on vertical
  levels too
- Implemented 3 button joystick/keyboard support. They select the next/previous
  weapon respectively:
  - Changed the SHIFT to N and M for the keyboard 2nd and 3rd buttons
  - On the MSX joystick, press the trigger-2 to select the next weapon, and the
    triggers 1 and 2 simultaneously to select the previous weapon
- Added joyMega support: button-A = next weapon, button-C = previous weapon,
  START = pause
- Implemented support for quick weapon changes on single-player mode. This
  allows the secondary weapon to be changed while the older is still on screen.
  This will also solves the bug where the Condor missile got stuck on bosses
- Improved the Merry weapon: when no direction is selected, it will fire forward
  like Zanac's weapon-0
- Adjusted the launch point of the "Double" weapon on horizontal stages, to
  match the place on the ship were it is launched on vertical stages. This also
  makes it more effective.
- Replaced ESC with STOP to pause the game on the keyboard
- Fixed a bug that allowed line interrupts to happen during disk I/O (it was a
  miracle that it didn't freeze very often)
- Implemented frame skipping and dynamic vsync for a much smoother gaming
  experience. This also considerably reduced the tearing that happened in
  screen flashing and palette fading effects, and the glitches that happened on
  the sprites on the MSX Turbo-R at the top of the screen.
- Enhanced the shield gauge to show when the shield power is overboosted
- Bugfix: Corrected the player-2 energy bar position
- Fixed a bug that corrupted the fixed point damage under some occasions
- Fixed a glitch that caused spurious sprites to be shown when the boss ship
  stage was being loaded


Note: Only after I finished the patch that I noticed that there's a different
title screen if you boot the disk-2 of the game. I won't have time to remake
that screen too, so if someone feels compelled to do that, just send me the
finished image and I can include it on a newer version of the patch. 

TL;DR: Besides the bugfixes and new title screen, the difficulty isn't watered
down by this patch.
In fact, what it does now is to reward skilful players that know how/when to
balance the risks of playing offensive versus defensive, and that master the
sub-weapons available in the game. The docking power now has a very important
role in the game, so use it wisely. And yes, there's turbo and joyMega support
now.


==============================
How to apply the patch

The recipient DSKs images must be original dumps. You can check if they have
the following SHA1 checksums:

SHA1(LAYDO21.DSK)= c4217c7f0371e9c6f830d8a76f731123548c9719
SHA1(LAYDO22.DSK)= 63daaadce6ef18938788f3d1e4b08deff15fe5da


- You can use the following tools to verify the SHA1 checksum:
  - Windows:
    -MD5 & SHA-1 Checksum Utility 1.1
    - HashTab
  - Mac OS-X:
    - DropHash
    - HashTab
    - (or use the Linux solution below)
  - Linux:
    - Just type on a shell: openssl dgst -sha1 MYGAME.DSK

- To apply the patch, get an IPS patcher like IPSWin, LunarIPS or UIPS, and
  follow the instructions contained in the manual of that tool.


==============================
Special Thanks

- OpenMSX team, for their excellent emulator and debugger
- MRC crew, for the place where MSX hobbyists can meet and exchange ideas
- Sjoerd Mastijn and Aprisobal, for the SjASMPlus assembler
- FiXato, for compiling many development tools I use on Mac OS-X
- Sandro Sebastião Singer, for betatesting
- Paulo Peccin, for his help to find what caused the glitches on the opening
  cutscene when the turbo was enabled

==============================
FAQ
---

Q: Will the patched game run on non-turbo machines?
A: Yes, just as usual

Q: I applied the patch and the resulting DSKs don't work! What is wrong?
A: You're probably trying to apply the patch on DSKs with the incorrect
   checksum. Also, check if you're using the recommended patch tools


===========================================================================
	                     License
                           Terms of use
---------------------------------------------------------------------------

1) This patch is gratis for non-commercial purposes, and the author retains
   its copyright. You only can run and make backup copies of the patch
   while observing the non-commercial restriction.

2) You are only allowed redistribute the patch files (online or on a removable
   media) under the following conditions:
   2.1) No commercial transaction of any kind is involved
   2.2) All the included files are distributed together inside the same
   compressed file.
   2.3) This README must be included unmodified inside the same compressed file.

3) If you want to use this patch for commercial purposes you MUST contact me
   first to negotiate the terms and conditions. Send an e-mail to
   sdsnatcheralpha@gmail.com to contact me.

4) You cannot distribute games with this patch pre-applied.

5) This patch is provided ‘as-is’, without any express or implied warranty.
   In no event will the author be held liable for any damages resulting from the
   use of this patch or the software patched with it.

6) USE THIS SOFTWARE SOLELY AT YOUR OWN RISK.


===========================================================================
                          Donations
---------------------------------------------------------------------------
 If you like the enhancements and fixes here presented and want to show your
 appreciation by donating any amount, or MSX software/hardware, it will be very
 welcome and will help future developments.
 Donations can be done via PayPal to sdsnatcheralpha@gmail.com, and for MSX
 hardware, try contacting me on this e-mail address too.

 Have a look at my wishlist in the following link:
 http://frs.badcoffee.info/wishlist.html

