By Joseph Norman
LAKABAJO is a poor developer man's real-hardware cheap uploader tool for the Sega Genesis (yeah, I really didn't know how to order these adjetives). FYI Also: This uploader will not allow you to upload ROMs or pirated games onto your Genesis to play!
>> AboutIn a world where every girl wants to become a model, there is LAKABAJO. LAKABAJO is the name for a system that Devster devised to load executable 68k code onto a Sega Genesis console without using a flash cartridge, or any kind of cartridge with programmable memory.
In the past, rich developers had to pay thousands of dollars for official licensed development kits to develop Sega Genesis games. In the last decade, poor hobbyists had to pay $50 for an unnofficial flash cartridge from Hong Kong suppliers to run tiny chunks of code on the Genesis. Today, poor developers won't need to pay a dime (joking, at least $20) to get their code running on the real hardware.
Basically, this uploading system works by using a controller exploit in games, in combination with a Game Genie game enhancer. The Game Genie codes are automatically entered for you using the uploader program. The exploit running on the console loads a data from the controller port, into the Genesis work RAM. The exploit then starts execution from work RAM.
>> The HardwareYou need to build a parallel port to controller interface. The interface only requires two logic IC's: 74LS74 Dual D-Flip Flop, and the 74LS157 Data Selector. The 74LS157 can be ripped out of an official Sega Genesis 3-Button controller (if you go that route, you can also use the controller cord). You may use something other than a 74LS74 Flip Flop. The Flip Flop is only used to make a 2-bit counter. For the counter, the second bit needs to be inverted, and brought out to the parallel port though.
Build this hardware with care! I am not responsible for anything you mess up on your computer, or on your Sega Genesis, or any other devices! Just remember to never cross the GND and VCC rails, or short anything that's not suppose to be shorted, and you'll do fine.
Currently, there may be timing problems when used with different computers. This is because the PS has to send data out the parallel port at very precise timing (which is why a 1GHz computer is recomended).
Below is a link to the schematic of the circuit:
Remember to place the 0.1uF decoupling caps close to the IC VCC's. It is recommended to test the hardware before doing any real uploading. The command line utility has a hardware test option (-t) inside. The software tests the joypad buttons, and the function of the flip flop. Just load up a game on the Genesis, and test the joypad. The flip flops are working when good-syncs are produced. If the software shows many bad-syncs, or no syncs at all, then something is wrong with the flip flop hardware. Also check that the software is able to detect whether the console is powered ON or OFF. Make sure that you plug your cable into Controller Port 2!
Do not connect an external power supply to this circuit to power it up. Power is provided from the Sega Genesis +5V rail.
I printed and etched my own board. Here are pictures of my hardware:
Two sided, and no vias :-)!
>> Using with BasiEgaXorzOnly BasiEgaXorz versions 1.37 and above support RAM game compiling, so make sure to update your version.
To compile a RAM game, select Tools -> Options -> Target -> Compile as a RAM Game. A file with the extension of .RAM will be produced, and this is the file that is sent to the Genesis. An upload utility is already built into BasiEgaXorz, so there shouldn't be any need to use the command line utility. Just select the parallel port address, and the target game (Sonic 1, Sonic 2, or Animaniacs) from the Options dialog. The game is automatically compiled, and uploaded to the Genesis by selecting the Game Genie icon from the toolbar.
Compile and upload
Follow the directions on the console
' Will display a smiley face in the middle of the screen. ' Notice that we don't have to do a LOADTILES command. ' This is because the VRAM will already be initialized ' during upload, thanks to the VIDATALONG command. drawtile 256, 19, 10 tileorg 256 vidatalong $00111100 vidatalong $01000010 vidatalong $10100101 vidatalong $10000001 vidatalong $10100101 vidatalong $10011001 vidatalong $10000001 vidatalong $01111110While a RAM game is running, and you try to upload again, you will not need to power down the console and enter in the Game Genie codes. This is because a routine runs periodically on the Genesis checking if we want to upload anything. The routine also checks when the program has ended (using END), or if the controller is checked using the JOYPAD command. If your program gets stuck in an infinite loop, then the routine will not be able to run, and you will have to cycle the power on the console.
>> Using with Assembly or C
RAM Game File Format:
Interrupts:When a horizontal interrupt occurs, then execution of the handler will begin at 0xFFFFAC. Vertical interrupts cannot be used in RAM games (if a veritcal interrupt is used, then the interrupt handler of the game cartridge inserted will be branched to instead). This is the same for any other 68k exception vector: only the h-int vector is usable.
VRAM Initializing:VRAM is initialized from the RAM game. VRAM data is sent from the uploader immediately after code data is sent. Include the below assembly code inside your program at 0xFF0000 to download the VRAM initialize data from the host:
move.w #$7FFF,d1 lea ($C00004),a0 move.w #$8F02,(a0) move.l #$40000000,(a0) lea ($FFFFFFEE.w),a2 @__vram_init_loop: jsr (a2) move.b d0,d7 jsr (a2) lsl.w #4,d0 lsr.b #3,d0 lsr.w #2,d0 or.b d0,d7 lsl.w #8,d7 jsr (a2) move.b d0,d7 jsr (a2) lsl.w #4,d0 lsr.b #3,d0 lsr.w #2,d0 or.b d0,d7 move.w d7,-4.w(a0) dbra d1,@__vram_init_loopThis assembly listing compiles to 62 bytes of code:
0x32, 0x3C, 0x7F, 0xFF, 0x41, 0xF9, 0x00, 0xC0, 0x00, 0x04, 0x30, 0xBC, 0x8F, 0x02, 0x20, 0xBC, 0x40, 0x00, 0x00, 0x00, 0x45, 0xF8, 0xFF, 0xEE, 0x4E, 0x92, 0x1E, 0x00, 0x4E, 0x92, 0xE9, 0x48, 0xE6, 0x08, 0xE4, 0x48, 0x8E, 0x00, 0xE1, 0x4F, 0x4E, 0x92, 0x1E, 0x00, 0x4E, 0x92, 0xE9, 0x48, 0xE6, 0x08, 0xE4, 0x48, 0x8E, 0x00, 0x31, 0x47, 0xFF, 0xFC, 0x51, 0xC9, 0xFF, 0xDCThe code is position independent, but it's best to place it at the beginning of execution (the uploader times out after 3 seconds of no activity after sending data to work RAM). The code also depends on a subroutine located at 0xFFFFEE to operate. The subroutine after 0xFFFFEE can be overwritten after the VRAM has been initialized.
>> The Command Line UtilityThe command line uploader utility LAKABAJO is the heart of the entire exploit. Moreover, the utility is very verbose, so pay attention to what gets printed to the screen. It takes in these arguments:
-p <LPT Port Address>Chooses the parallel port address (default is 0x378). LPT Port addresses are 0x378 for LPT1, 0x278 for LPT2, and 0x3BC for LPT3. E.g. to use port 2, specify -p 278.
-g <Game number>Chooses the game to use (default is SONIC 1). Currently these are the supported exploit games for now:
-vForces the program to not send any initial VRAM data. Insert this argument if you do not want the uploader to send VRAM data (if you don't have the VRAM initializer code inside your program. For BasiEgaXorz programs, never use this option. This does not prevent the VRAM initializer program on the Genesis from completing (as in, the Genesis will lock-up).
-i <Input File Name>Specifies which file you want to upload to the Genesis. E.g. -i c:\sega\myprog.ram.
-cUse 100% CPU usage. Use this option if you have trouble uploading files because of timing/syncing issues. The Game Genie code enterer is twice as slow though. Use the default option (no -c argument) whenever possible.
-oDisables power detection. The program will no longer prompt you to turn off the Genesis, or turn it on. When the program executes, you will need to be at the Game Genie prompt before running the program.
-tUse this option to test your hardware/circuit. Press the following keyboard keys to stimulate presses on the Genesis controller port:
Upload TEST.RAMOkay, now that you have your hardware manufactured, and you've verified the basic functions of the device using the hardware test - now it's time to actually upload a program to the Sega Genesis :-).
Just enter lakabajo -g1 -i test.ram into the command line (make sure to change the -g1 option to your game, it is set to Sonic 2 in this example). Follow the on screen prompts. You should be able to see the Sega Genesis working:
>> TroubleshootingYes, this list is very long, but I want to make it as frienly as possible, so that everyone any hobbyist with a soldering iron + some PCB is able to figure out what's wrong. Believe me, this also beats troubleshooting a failing homemade flash cartridge and programmer! Note that I don't warrant anything here :-). If you burn up your computer or whatever device by following or not follownig my diections (anywhere on this page) correctly, then I'm not responsible.
I have a PAL machine and..............PAL consoles will now work with a LAKABAJO uploader version 0.1.2 or above! The game Animaniacs will not currently work with LAKABAJO.
In the hardware-test utility: Nothing happens when I push the arrow keys.Check that your circuit is receiving +5V power from the Genesis using a multimeter.
In the hardware-test utility: When I push the up key, my character moves left, and when I push the left key, my character moves up.You have some problems in the 74LS157 circuit. Recheck the connections from the parallel port to the 74LS157 first, and correct. Then recheck the connections from the 74LS157 to the Genesis seconds.
In the hardware-test utility: The program always says my console is powered OFF when it is really on. How do I fix this?Check the 74LS74 circuit. Specifically check GND, VCC, pin 9 (Q), and pin 8 (!Q).
In the hardware-test utility: The total-syncs counter is 0, the console is powered on, and everything is connected. Is my circuit really working?Nope. If your circuit is really working, then you should see the counter moving. This means that the 74LS74 circuit is not working. Recheck the connections for the 74LS74, and make sure the inverted Q output from the D-Flip Flop feeds back into the D-Input. Moreover, check the connections on the first-level D-Flip Flop first, then read on the next troubleshooting point when the connections are verified.
In the hardware-test utility: The total-syncs counter is increasing. The bad-syncs counter is increasing equally as well. Am I tripping out?This means that your connections are still wrong. Check the second-level D-Flip Flop now.
In the hardware-test utility: I got some good-syncs, but I got bad-syncs. Is this okay?A small number of bad-syncs is tolerable, but if the number of bad-syncs is increasing linearly, then there's a problem. You might still have a problem with connections, or in rare cases, your computer may be too slow to sync with the Genesis. If you believe your computer is too slugish to keep up, then check the task manager for programs that are hogging CPU time, and close those.
When uploading TEST.RAM: The program keeps telling my that a "Timing Error Occured"Keep on retrying. It may not always work the first time. If it continuously gets timing errors at the same spots, then report this to the forums, or check the -c option. Also if possible, try another game. Ideally, Sonic 1 is the best game to try. Then Animaniacs. Then Sonic 2 (Sonic 2 is known to be problematic).
When uploading TEST.RAM: The program hangs after the Game Genie code is entered inDouble check that you're using Controller Port 2 as the interface port! Also, make sure that your exploit game is working also. For instance, start the exploit game without any Game Genie codes, and see if it runs. Most of the time, the connectors collect dust or oxidize, and you need to blow on the connectors to get the game working again :-). Also make sure that the Game Genie is enabled by flipping the slide switch on the Game Genie to the upright position (the green LED should be on). If it is, then read onto the next troubleshooting point.
When uploading TEST.RAM: I'm using Sonic 2, and the program just hangs after inserting the Game Genie codeTry another game. Sonic 2 is known to have problems. The problem is not intermittent, but it's still luck :-)
When using the uploader in BasiEgaXorz: I'm getting uploading problemsSorry, but try the command-line utility. Also check that you're using controller port 2 as the interface to the host, and check the options in the Options -> Target Dialog.
When compiling a RAM game in BasiEgaXorz: It keeps telling me my program is too big!Your program is too big :). Reduce it, or if you are using tile graphics: try to optimize tile graphics by placing it in VRAM Initialization data space using the VIDATA, VIDATAINT, VIDATALONG, or VIDATAFILE commands. Big variables also take up RAM space as well! You can reduce the default size for strings by using the OPTION STRING SIZE,<SDefault ize> option.
When compiling a RAM game in BasiEgaXorz: My program acts differently compared to using an emulatorThat's the reality of running programs on real hardware :-). BasiEgaXorz was developed for the real hardware, but there may be 1 or 2 bugs still lurking around.
Sometimes the quick uploader for BEX doesn't always workRead the joypad (doesn't matter which one) from time to time. It is best to keep a joypad reading instruction inside a verticle interrupter routine.
You said that vertical interrupters are not possible to handle because the 68k is using the vector table for the exploited game! How does it work on BasiEgaXorz?BasiEgaXorz invisible uses the horizontal interrupt as the source for the vertical interrupt. The HCount register has to be set to the number of scan lines on the screen to function as a vertical interrupt.
What code do I have to enter into the Game Genie screen?You do not need to enter any codes into the screen. The automated program will do this for you (And is much quicker. I had to enter in the codes manually during development, and my fastest time to enter in all 5 codes manually is 55 seconds for Sonic 1).
Will Sonic 3 be supported as an exploit game? How about......No Sonic 3. Many of the subroutines are the same from Sonic 1, but the opening title screen has changed, which has prevented the exploit. List of games that I have personally dissasembled and investigated:
For Assembly or C: My program crashes and burns whenever I enable horizontal interruptsMake sure you copy your routine, or branch instruction to 0xFFFFAC. Also make sure that you didn't set the stack pointer to 0x000000, and then the stack overwrote the interrupt handler :). In my opinion, it is best to place the stack at 0xFFFFA0.
For Assembly or C: If the program code is using up RAM space, then where do I place all my variables?Make some more room and set your BSS to the RAM space as well :-).
For Assembly or C: Give me an example header for assembly language!
.org $00FEFFC8 ; 56-Byte Dummy Header. You can put your title here or whatever dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0 ; Program starts here! Will be ORG'ed at 0xFF0000 automatically. ; This is the VRAM Initializer routine. Don't include this if you don't ; want to initialize VRAM in the future (routine only takes up 50 bytes) move.w #$7FFF,d1 lea ($00C00004),a0 move.w #$8F02,(a0) move.l #$40000000,(a0) @__vram_init_loop: jsr ($FFFFFFEE.w) move.b d0,d7 jsr ($FFFFFFEE.w) lsl.w #4,d0 lsr.b #3,d0 lsr.w #2,d0 or.b d0,d7 lsl.w #8,d7 jsr ($FFFFFFEE.w) move.b d0,d7 jsr ($FFFFFFEE.w) lsl.w #4,d0 lsr.b #3,d0 lsr.w #2,d0 or.b d0,d7 move.w d7,-4.w(a0) dbra d1,@__vram_init_loop ; Now your code here lea ($FFFFFF70.w),a7 .end
I get a red screen when using Sonic 1 after the Game Genie code is enteredThis means that the Game Genie code wasn't entered in properly. This could either be a hardware problem, or a timing issue. The codes that the program is suppose to enter are as follows:
BasiEgaXorz? RappaSquirx? ImaGenesis? Now LAKABAJO? Where do you get these crazy names?The name LAKABAJO was just pure luck :-). This project would have never finished without LAKABAJO :-). LAKABAJO means to "transfer one's address indirectly" in Motorolanese.
My parallel port cable was working yesterday. Now when I started my computer this morning with it plugged in, it doesn't work!The 74LS157 might have went into latch-up mode (I dunno, it's possible with some families). Disconnect the cable from the parallel port, and disconnect it form the Sega Genesis. It's important that both sides are disconnected. Now reconnect as usual.
>> DownloadsPlease do not redistribute any files from here on another downloads site without my permission! I am not responsible for anything you mess up on your computer as well.
LAKABAJO Command-Line Utility:
Get BasiEgaXorz > 1.37 version from here
>> More SupportNeed more assistance?
Want to talk to a friendly non-arrogant developer community?
Say what? A USB cable?
Register for the forums at devster.proboards22.com
>> Thanks ToSega - For a great console and for the Sonic series
Galoob - For a great game "enhancer" tool
Whitesnake - Brought up the idea of super cheap Sega tools, circa 2001 on IRC
Mask of Destiny - The Sega CD upload tool is kind of based on this
Kaneda+Fonzie - Big supporters of making it easy for newcomers to start programming for the Sega Genesis
Shiru - I used his FM driver and his music in the test program
That socram8888 guy on the forums - Reminded me to revisit the Game Genie idea after 2 years of abandoning it
The person that made the Gens Tracer mod - Made it very easy to locate jump-in routines
disasm.exe - I dissasembled a total of 30 games with this :-)
My 500Mhz development computer - Used this to originally program BasiEgaXorz. Re-used it to develop LAKABAJO :-). Also gives me good reason to develop such a 1990's webpage.
The development community - Yea, whoever I forgot to mention :-)
>> Release History