SWAT: Special Weapons and Tactics Enemy OOB Fix by GAFF Translations (pluvius3 @ gmail.com) v1.00 (Created August 5, 2018) -------------------------------------------------------------------------------- *TABLE OF CONTENTS* ----------------- I. VERSION HISTORY II. INTRODUCTION III. INSTRUCTIONS FOR USE IV. KNOWN BUGS V. CREDITS VI. TECHNICAL NOTES VII. ACKNOWLEDGEMENTS AND CLOSING WORDS ******************** I. VERSION HISTORY ******************** v1.00 (08-05-18): First release. ****************** II. INTRODUCTION ****************** SWAT: Special Weapons and Tactics is a Famicom first-person RPG-like game published by Toei Animation in 1987. In it, you search through eight floors of a building occupied by terrorists; your object is to kill them all and rescue their hostages. SWAT is a notorious in Japan as a buggy and unfinished game, filled with crashes, strange behaviors, and signs of failed attempts at complexity. The most rage-inducing feature of SWAT is the frequent inability to complete a level due to missing enemies. This patch fixes two bugs related to this problem, one of which appears to be the cause of most of the issue, and the other being specific to an enemy on Floor 6. It works with the translated version of the game by Psyklax and filler, and is assumed to work with the original Japanese game as well. The patch will not make SWAT remotely good, but at least it will be mostly playable. *************************** III. INSTRUCTIONS FOR USE *************************** 1. Download and install Lunar IPS or a similar IPS patcher if you haven't already. 2. Get a copy of the SWAT: Special Weapons and Tactics ROM. No, I don't know where. The correct ROM is identified by GoodNES 3.23b as the verified good dump. 3. Apply this patch to the ROM using the aforementioned patcher to fix it. You can then apply the translation patch if desired. It doesn't really matter which order you use the patches, since they affect totally different areas of the ROM. **************** IV. KNOWN BUGS **************** None at this time. I played through the entire game in one run without running into any problems related to inaccessible enemy positions except for the aforementioned enemy on Floor 6. I did not test the Floor 6 fix thoroughly but it was very specific to that one enemy so any knock-on effects are doubtful. This patch fixes no other bugs original to the game, most notably the waves of enemies that show up on the southwest corner of nearly every floor (I'm not entirely convinced this isn't at least partly intentional anyway) and the password display bug (which I never encountered). This patch may not completely fix the disappearing enemies, but it should greatly reduce their incidence. (Incidentally, despite playing through the entire game without any passwords, I did not get a perfect score at the end due to somehow being 15 enemies short. What a game! At least I rescued all of the hostages.) *********** V. CREDITS *********** Rob "Pluvius" Browning: Hacker, tester ******************** VI. TECHNICAL NOTES ******************** Each of SWAT's eight floors is a 20x15 map that contains a number of enemies, some of which are in a fixed position and some of which wander around on patrols. Each floor must be completely cleared of enemies, but often players will be stuck on a level due to enemies that can't be found. The primary cause of this gamekilling obstacle is a single-byte mistake in a piece of the subroutine that keeps patroling enemies in a defined area of the map. Each wandering enemy has an array starting at RAM address $0524 that defines its position and facing, with the first byte marking the X-position and the second marking the Y-position. Every 10 seconds, the enemy will change its position and/or facing. The buggy code in question looks like this: 00:8433:BD 24 05 LDA $0524,X @ $0524 = #$00 00:8436:C9 0A CMP #$0A 00:8438:B0 6C BCS $84A6 ... 00:84A6:DE 25 05 DEC $0525,X @ $0525 = #$00 00:84A9:60 RTS The problem with this code is fairly clear--it checks the enemy's X-position to make sure it's not above a certain value, but it changes the enemy's Y-position instead. The enemy will keep moving south until an underflow happens and he teleports out of bounds to Y-position 255. Since the highest in-bounds Y-position is 14, you'll be waiting a very long time for him to show up again. The fix was pretty simple and obvious--just change ROM offset $0449 (the endpoint of the BCS jump) from #6C to #48, which points to the code that decreases the X-position as intended. The disappearing enemy on Floor 6 is the result of another bug, this time an off-by-one error. This enemy uses a specific set of instructions found between ROM offsets $069F and $06AF to determine its patrol pattern. The error in the code that interprets these instructions increases the patrol's radius, causing it to go out of bounds on its south leg. For whatever reason, the enemy stopped coming back in bounds for me, so I decided to fix the problem by decreasing $06A3 and $06A7 by 2 each, dragging the leg back in. I could've easily fixed the main off-by-one error, but this game is so buggy that I was afraid that fixing it would cause problems with all of the other enemies, some of which might actually be expecting this behavior. And even if fixing the error had only positive effects, considering how deranged enemy movement and detection is in this game, I don't think it would even be noticeable like keeping the enemies in bounds is. **************************************** VII. ACKNOWLEDGEMENTS AND CLOSING WORDS **************************************** Thanks to: Shouei, for developing this game. Toei Animation, for publishing this game. Nintendo, for making the system this game runs on. Psyklax and filler, for creating the translation patch. The developers of FCEUX, the very useful debugging emulator which I used to test the image. Romhacking.net, for hosting this hack and many others like it, as well as providing useful hacking information. And, of course, you for reading and playing. Questions, comments, criticisms, and bug reports can be sent to pluvius3 @ gmail.com (without the spaces obviously). Please put "SWAT: Special Weapons and Tactics" or something similar in the subject line so I will know what the email is about. If you alert me to a bug, I will fix it in a future update and give you credit. Copyright 2018 GAFF Translations, all rights reserved.