https://retrocomputing.stackexchange.com/questions/1514/how-exactly-does-sonic-knuckles-lock-on-technology-work Stack Exchange Network Stack Exchange network consists of 182 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange [ ] Loading... 1. + Tour Start here for a quick overview of the site + Help Center Detailed answers to any questions you might have + Meta Discuss the workings and policies of this site + About Us Learn more about Stack Overflow the company, and our products. 2. 3. current community + Retrocomputing help chat + Retrocomputing Meta your communities Sign up or log in to customize your list. more stack exchange communities company blog 4. 5. Log in 6. Sign up Retrocomputing Stack Exchange is a question and answer site for vintage-computer hobbyists interested in restoring, preserving, and using the classic computer and gaming systems of yesteryear. It only takes a minute to sign up. Sign up to join this community [ano] Anybody can ask a question [ano] Anybody can answer [an] The best answers are voted up and rise to the top Retrocomputing 1. Home 2. 1. Public 2. Questions 3. Tags 4. Users 5. Companies 6. Unanswered 3. Teams Stack Overflow for Teams - Start collaborating and sharing organizational knowledge. [teams-illo-free-si] Create a free Team Why Teams? 4. Teams 5. Create free Team Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams How exactly does Sonic & Knuckles' 'Lock-On Technology' work? Ask Question Asked 6 years, 9 months ago Modified today Viewed 53k times 76 The cartridge of Sonic & Knuckles is a little special: S&K Cartridge It flips open to allow you to connect another Sega Mega Drive (Genesis in US) cartridge to the top of it like so: Sonic 3 connected to S&K I know why the Sega developers did this: the time constraints of developing Sonic 3 coupled with the large size of the game files meant that they chose to split 'Sonic 3' into the two separate game parts (Sonic 3, and Sonic & Knuckles). However, they also wanted the full game to be playable as one complete package: Sonic 3 & Knuckles, so they invented what they called 'Lock-On Technology' to allow the games to connect. (There's also the ability to connect to Sonic 2 (to play as Knuckles), as well as a hidden section of minigames if you connect with Sonic 1). My question is, how exactly does the Lock-On Technology work? Are the game ROMs merged in some way when connected? How does the Sonic & Knuckles cart detect another cartridge? * gaming * game-cartridge * sega-genesis Share Improve this question Follow edited Sep 26, 2016 at 14:15 JAL's user avatar JAL 9,3921313 gold badges5555 silver badges117117 bronze badges asked Sep 26, 2016 at 13:38 Robotnik's user avatar RobotnikRobotnik 93011 gold badge66 silver badges1717 bronze badges 3 * 4 I know how I'd do it (put the program on Sonic & Knuckles, and treat the extra cartridge as a data file), but I've got no idea if that's how they did it. - Mark Sep 26, 2016 at 17:14 * 3 I posted this question on /r/programming and hacker news (hence the extreme number of views on this post). - JAL Sep 29, 2016 at 1:43 * 3 @Mark, it appears that's precisely how they did it. Sonic & Knuckles runs with Sonic the Hedgehog 3's ROM mapped to its address space. So the program really is part of Sonic & Knuckles and it does make use of the locked-on cartridge's data. - Matheus Moreira Sep 29, 2016 at 23:53 Add a comment | 1 Answer 1 Sorted by: Reset to default [Highest score (default) ] 105 +50 How does the Sonic & Knuckles cart detect another cartridge? It checks the serial numbers of games; they can be found in the ROM's header. It probably detects all preceding Sonic the Hedgehog games since they all result in specific effects when locked-on. Are the game ROMs merged in some way when connected? It seems both games are simply mapped onto memory. This way, the executing game code gets access to the contents of both games. To better understand what this means, imagine a Sonic & Knuckles ROM with the complete contents of the Sonic the Hedgehog 3 ROM concatenated onto it. Sonic & Knuckles and Sonic the Hedgehog 3 The address space represents memory the game code can access. The contents of the read-only memory chips get mapped onto the Mega Drive's 68k processor's 24-bit address space. The Mega Drive just sees two games, one after another. Incidentally, that's what a good dump of Sonic 3 & Knuckles looks like. This explains why the game works even in emulators that don't support any of the custom hardware inside the Sonic & Knuckles cartridge. Any game locked onto Sonic & Knuckles will probably have its ROM mapped onto the game's address space the same way. This means game's data is made available for use by the Sonic & Knuckles game code; it does not necessarily mean the data will be used. Since Sonic & Knuckles was programmed to work with Sonic the Hedgehog 3, it makes extensive use of the data in the locked-on cartridge. Its handling of other games is far less sophisticated; apparently, it just uses the metadata found in the ROM's header to generate a unique Blue Spheres stage. If it detects that it's the first Sonic the Hedgehog game, it simply unlocks the full version of the bonus game. The connection to Sonic the Hedgehog 2 works similarly: Sonic & Knuckles and Sonic the Hedgehog 3 There are two ROM chips in the Sonic & Knuckles cartridge: one has the main game and the other has a patch for Sonic the Hedgehog 2. The patch ROM contains the complete Knuckles the Echidna in Sonic the Hedgehog 2 game code; this is the full code for the original game but modified with the necessary game mechanics for Knuckles: lower speed, lower jump height, flight, wall climbing, etc. The ROM also contains new graphics data for Knuckles as well as new map data with places and items for Knuckles to reach with his abilities. When Sonic & Knuckles detects that Sonic the Hedgehog 2 is locked on, it passes control of the processor to the code inside the patch ROM, thereby launching Knuckles the Echidna in Sonic the Hedgehog 2. The new game can reuse much of the data from the original game: level graphics, enemy data, bosses, etc. The only code from the locked-on cartridge that executes is the sound driver. My question is, how exactly does the Lock-On Technology work? Let's delve into the details. According to Lock-on Technology Hacking Guide, there are some chips on the Sonic & Knuckles cartridge: * 74HC74 Dual D-type Flip-Flop * 74AC139 1-of-4 decoder/demultiplexer * 74AC08 Quad 2-input AND Gate Along with the two ROM chips and the cartridge slot, they implement the Lock-On functionality. Rizzo's photographs show what the cartridge's printed circuit board looks like: Sonic & Knuckles cartridge printed circuit board, front Sonic & Knuckles cartridge printed circuit board, front The Mega Drive's cartridge I/O is meant for only one cartridge. However, a cartridge locked onto Sonic & Knuckles forms a system that contains three ROM chips: * Sonic & Knuckles cartridge + Sonic & Knuckles ROM [2 MB] + Sonic the Hedgehog 2 patch ROM [512 kB] o Responsible for Knuckles the Echidna in Sonic the Hedgehog 2 * Locked-on cartridge + Game ROM Apparently, the key functionality behind Lock-On Technology is choosing one of those ROM chips and connecting it to the appropriate addressing lines of the Mega Drive which is none the wiser. This memory bank switching is apparently achieved via the chip enable lines. They are active when logically 0 and if inactive will cause all memory addressing operations to be ignored and nothing to be returned on the data bus, effectively "disabling" the chip. If one of the ROMs is disabled, the other will be mapped in its place. The Mega Drive just sees a big cartridge with a big address space. Rizzo also made a schematic of the electronics: Sonic & Knuckles Lock-On schematics, full Even though I'm not an electronics expert, I was able to figure some things out by studying the schematics and reading the notes on the website. Here's what I learned. The 74HC74 Flip-Flop The purpose of this chip is to hold a single bit of information: is Sonic the Hedgehog 2 locked on? Much of the circuit's operation depends on this single bit. It is denoted by the red node on the schematic, corresponding to the 74HC74's Q output. When Sonic & Knuckles boots, it checks its cartridge slot. If there is a game locked on, it tests if its serial number matches that of earlier Sonic games. If it detects Sonic the Hedgehog 2, a signal is generated on the ROM's D0 line, setting the Q bit of the 74HC74. On Hacker News, Dylan16807 provides additional information about the workings of this bit: This is missing some important information. One input to the flip flop is D0 on the ROM, yes, but it only sets when there is a clock signal. Otherwise there would be some very interesting coding constraints. The clock of the flip flop is connected to cartridge pin B31. Here's the best explanation I can find of that pin: /TIME is the schematic label given to pin B31 on the cartridge slot. It is essentially a chip enable for the I/O port range $A130Fx, and is used for programming on-cart memory mappers. The only games I know of that use it are Beyond Oasis, Phantasy Star 4 (both for switching between ROM and SRAM at $200000-3FFFFF) and Super Street Fighter 2 (for a full-blown ROM banking chip). I don't know why it's called / TIME; perhaps they expected to connect an RTC chip to it. So if you write to certain addresses, the genesis will flicker that pin, which is great for controlling an extra chip like this. (I mean, it's meant to control an extra chip, but it seems like the plan is a significantly smarter one than a flip flop.) The 74AC139 decoder/demultiplexer There are two independent decoders M and N, each with three inputs E, SA and SB as well as four outputs Y0, Y1, Y2 and Y3. If E is 1, all outputs are also forced to 1. The Y outputs obey the following truth table: E SA SB Y0 Y1 Y2 Y3 1 -- -- 1 1 1 1 0 0 0 0 1 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 The I/O arrangement of each decoder M is connected to to address line 20 and the output of the 74HC74 through SA and SB respectively; E is connected to the Y3 output of N. The chip enable line of the Sonic the Hedgehog 2 patch ROM is connected to Y3, while Y0, Y1 and Y2 are all inputs to the 74AC08. N is connected to address line 21 through both SA and SB. The chip enable signal from Mega Drive is connected to E. The chip enable line of the Sonic & Knuckles ROM is connected to Y0 but Y1 and Y2 are not connected to anything at all. Y3 is connected to M's E input. Putting it all together Decoder M controls the activation of both the Sonic the Hedgehog 2 patch ROM and the locked-on cartridge's ROM. Decoder N controls the activation of the Sonic & Knuckles ROM. The A21 line addresses memory that is beyond the bounds of the game's 2 megabytes ROM. If this memory is accessed, the result is that the Sonic & Knuckles ROM is disabled. Otherwise, it is enabled and M's E is set. The A20 line addresses memory that is within bounds; if that memory is accessed and the 74HC74 is also set, the Sonic the Hedgehog 2 patch ROM is enabled and the outputs to the 74AC08 are all 1. If M's E is set, the 74AC08 also receives all 1s, but the patch ROM is not enabled. The 74AC08 AND Gates The 74AC08 has three inputs Y0, Y1 and Y2 as well as a single output that equals Y0 [?] Y1 [?] Y2 and is connected to the locked-on cartridge's chip enable line. Therefore, the second cartridge's ROM will only be mapped when all its inputs are 1: * Locked-on cartridge is Sonic the Hedgehog 2 * Sonic & Knuckles ROM is enabled + M's E is set Share Improve this answer Follow edited 7 hours ago answered Sep 28, 2016 at 8:25 Matheus Moreira's user avatar Matheus MoreiraMatheus Moreira 1,67822 gold badges1313 silver badges1515 bronze badges 6 * 4 Nice find with the "Lock-on Technology Hacking Guide!" - Aaron Oct 5, 2016 at 17:53 * 2 You are some kind of hero - LateralTerminal Feb 1, 2018 at 18:11 * 1 I wish I could upvote you more than once, thanks for the additions to do with Sonic 2, it makes it so much clearer :) - Robotnik Feb 5, 2018 at 23:41 * 3 Thanks for your kind words. Every time I read the pages I linked, I end up learning something new and editing this answer. The guys who figured all this out are the real heroes. I wish a professional would comment on my analysis of the circuit; if there are errors, I would like to fix them and learn more. - Matheus Moreira Feb 6, 2018 at 0:17 * 1 Wow, that blogpost brings back memories! I wrote a blog post for some time ago titled "How I built my own Sega Mega Drive hardware dev kit from scratch at nestenius.se/2022/01/18/... - Tore Nestenius 13 hours ago | Show 1 more comment You must log in to answer this question. Not the answer you're looking for? Browse other questions tagged * gaming * game-cartridge * sega-genesis . * The Overflow Blog * How terrifying is giving a conference talk? (Ep. 589) * The Overflow #186: Do large language models know what they're talking about? * Featured on Meta * Starting the Prompt Design Site: A New Home in our Stack Exchange Neighborhood * Colors update: A more detailed look Linked 3 "Genesis Lock-On Technology" to change the language of a Famicom game Related 7 What does "Expanded Memory" mean on a Philips Videopac G7000 game? 32 How did Elite on the NES work? 11 How did Satoru Iwata compress Pokemon GS to fit two regions on a single cartridge? 3 "Genesis Lock-On Technology" to change the language of a Famicom game 3 How does the "backwards bump method" of SMB work? 11 How does Master System backwards compatibility work on the Megadrive? 7 How did Mega-Lo-Mania's save state system work? 29 How did the X-Men game for Sega Genesis have its state survive a console reset? Hot Network Questions * Evolutionary path of action/anime humans * How "wide" are absorption and emission lines? * A conditional block with unconditional intermediate code * Are high yield savings accounts as secure as money market checking accounts? * Multiplication implemented in c++ with constant time * Geometric, arithmetic, and harmonic mean ratio proof. * Should I include high school teaching activities in an academic CV? * numerical integration - Numerical integration converging too slowly * Lilypond tuplets * What are the "19 Sections" of the Book of Psalms in the Biblia Hebraica Stuttgartensia? * What is the coil for in these cheap tweeters? * Are captives allowed to attempt escape? * What's the significance of a C function declaration in parentheses apparently forever calling itself? * Employee has ruined my reputation * How many witnesses' testimony constitutes or transcends reasonable doubt? * Is this gap under my patio sidelights okay? * Where do 1-wire device (such as DS18B20) manufacturers obtain their addresses? * sci-fi novel from the 60s 70s or 80s about two civilizations in conflict that are from the same world * What is Catholic Church position regarding alcohol? * Find out all the different files from two different paths efficiently in Windows (with Python) * Can't update or install app with new Google Account * MSE of a regression obtianed from Least Squares * Passport "Issued in" vs. "Issuing Country" & "Issuing Authority" * What are the effects of magical sleep for a long rest? more hot questions Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. [https://retrocomputi] * Retrocomputing * Tour * Help * Chat * Contact * Feedback Company * Stack Overflow * Teams * Advertising * Collectives * Talent * About * Press * Legal * Privacy Policy * Terms of Service * Cookie Settings * Cookie Policy Stack Exchange Network * Technology * Culture & recreation * Life & arts * Science * Professional * Business * API * Data * Blog * Facebook * Twitter * LinkedIn * Instagram Site design / logo (c) 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2023.7.14.43533 Your privacy By clicking "Accept all cookies", you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Accept all cookies Necessary cookies only Customize settings