Intro Post Part 2/2Present Time Counter
* From around this address controls the length of time left for presents
000158F0 3002 MOVE.W D2,D0
000158F2 48C0 EXT.L D0
000158F4 207C 00FFDE50 MOVE.L #$00FFDE50,A0
000158FA 4A30 0800 TST.B $08(A0,D0.W)
000158FE 588F ADDQ.L #$4,A7
00015900 6C4C BGE $0001594E
00015902 6048 BRA $0001594C
00015904 3002 MOVE.W D2,D0
00015906 48C0 EXT.L D0
00015908 D080 ADD.L D0,D0
0001590A 204A MOVE.L A2,A0
0001590C 5370 0800 SUBQ.W #$1,$08(A0,D0.W) *Subtracts 1 from the amount of time left on the present.
00015910 3030 0800 MOVE.W $08(A0,D0.W),D0
00015914 0C40 012C CMP.W #$012C,D0 *Checks if less than 300 cycles are left on present.
00015918 6302 BLS $0001591C
0001591A 6030 BRA $0001594C
0001591C 3002 MOVE.W D2,D0
0001591E 48C0 EXT.L D0
00015920 D080 ADD.L D0,D0
00015922 0C72 0064 0800 CMP.W #$0064,$08(A2,D0.W) *Checks if less than 100 cycles are left on present.
00015928 6314 BLS $0001593E
0001592A 3002 MOVE.W D2,D0
0001592C 48C0 EXT.L D0
0001592E D080 ADD.L D0,D0
00015930 7200 MOVEQ #$00,D1
00015932 3232 0800 MOVE.W $08(A2,D0.W),D1
00015936 700C MOVEQ #$0C,D0
00015938 C280 AND.L D0,D1
0001593A 6712 BEQ $0001594E
0001593C 600E BRA $0001594C
The results of the disassembly will be published to my own site at frequent, yet-to-be-determined intervals.
Check it out here: http://www.mybrillgamesite.com/projects/?id=86
It will always be a bit behind where I actually am in terms of progress but I try and keep it as current as feasibly possible.
As a courtesy I’d like to ask 2 things of anyone who uses the information I work out:
- Please don’t reproduce large sections of it on your own site or submit it to places like the RHDN database. When the time comes I will decide myself if and how I want to submit it, until then I’d prefer it to stay in one place that is easy to maintain (note my site is ad free so this isn’t a money making exercise, although I’d be lying if I said I don’t enjoy seeing the little visitor count go up!)
- Please give me a shout out if it helps you in your work or in one of the thousands of awesome Toejam and Earl hacks that I hope are produced as a result! This isn’t because I’m vain and want achieve world fame (honest!) but is because I’m curious and want to know just how helpful something like this is to the community and how much quality work is spawned as a result. If I see the project is successful, a lot of people like it and a lot of good things come of it I may turn my hand to other some games in the future (always wanted to know more about Mega-lo-Mania and Dune 2…).
Of course I have no way to enforce this and arguably no right to do so so I’m relying on your own sense of fairness and morals (god help me…).Toolchain, Process and References
This project is as much about learning as it is about disassembling. To this end here you will find link to all the specific items that I’ve used throughout the project from the emulators for exploring code, to the topics I’ve posted for help through to the sites and books I’ve used as reference. If you have any questions on any part of the project please, please ask. I love sharing knowledge almost as much as I love gaining it.ToolchainGENS r57shell Mod
– Used for exploring the ROM in real time, has a great 68K debugger with step by step instruction execution and breakpoints as well as a RAM watcher and editor. Before this I was using GENS KMod, GENS Tracer and GENS Hacking Version but have found this to be a suitable replacement for all 3. I also gave MAME a trial as I heard it had great debugging capabilities but r57shell’s more intuitive interface made it an easier option to get to grips with.Easy68K
– Used for assembling the disassembled sections of the ROM and testing different instructions and their changes. Very useful as it displays the opcodes of the instructions in hex meaning you can enter an existing instruction (such as DEC.b $#01, D0) and change it (eg ADD.b $#01, D0) and see what the new hex code is which you can then apply directly to the ROM without re-assembling.
Disasm.exe – This is the initial tool used to disassemble the Toejam and Earl rom. It was run over the entire file meaning all the graphics and data were also disassembled as code. Part of the process of this project is rooting out these sections and separating them.HxD
– Free and decent hex editor. Process
There are 2 ways I am disassembling the ROM, one is in execution order where I start from the entry point of the ROM (offset 00000202) and follow the code through separating and annotating routines in order as I go, and the other is jumping to areas of interest and following the code forwards and backwards from there.
The first way is good as it gives a good clear explanation of what the code is doing at any point and I can see exactly how it got there and what it has done so far. It is however, quite boring. As you can expect the initial parts of the program are just setting things up, firing up the Megadrive, testing the VDP and so on. They are interesting yes, essential – definitely, but they aren’t as exciting as working on present, map or enemy data!
The second way is what I do when I’m a bit fed up of looking at mundane code and counters. This lets me have fun with the game whilst also increasing my understanding and working towards a finished project. With this I can do things like change the length of time presents last, what presents you have to start with, how far tomatoes fly when you throw them and other fun things.
Both are achieved by firing up GENS and launching the 68K Debugger, finding the section of code I am interested in (in the first method it is wherever I left off, in the second method it is found by using known RAM addresses and breakpoints on them or by creating traces based on blindly logging code when the event of interest happens) and then reading, understanding and annotating the code into a separate file. Eventually I copy this information up to my website to display in a hopefully clear and useful way.References
For anyone wanting to learn how to do this sort of task here are the resources I recommend reading:RNDH Documentation
- Over the years I have read everything there is filed under Genesis and the vast majority of items under Assembly that aren’t processor specific (and even a few that are). Of particular interest are Tony Hedstrom’s documents on how to create Game Genie codes, anything by Fonzie and anything official.Tony Hedstrom’s Guides
- The Megadrive doesn’t have nearly as much documentation as it’s NES and SNES cousins but Tony has produced a considerable amount of Megadrive focused hacking documents and if you were only to read guides from one author on the subject (I strongly suggest you read more!) then I would make it him. He single handedly explains all you need to know about how to make real, hardware compatible GameGenie codes which in the process teaches you a huge amount about ROM hacking in general.BigEvilCorporation
- BEC focuses more on developing your own games for the Megadrive than it does disassembling others. In fact if you look at his more recent posts you’ll see he’s actually working on a rather polished looking game right as we speak. This doesn’t stop it being a great resource for disassembly though as all the information you gain on initialising the Megadrive, displaying sprites, performing loops and so on are all items you will encounter while reading through the disassembled code. DarkDust / Marc’s Domain
- Before BigEvilCorporation there was DarkDust. A lot of the information you see here centres around getting the Megadrive initialised and how the VDP works. The writing style is a bit more technical than BEC but don’t let that put you off, there is still really useful insight to be gained once you wrap your head round it.Sprite’s Mind (Main site and Forum)
- Home of Kaneda, creator and maintainer of GENS Kmod and all round Megadrive super Guru. Again, like DarkDust, documents here might get a little technical for some people’s liking (especially when reading through the forums) and because Kaneda’s native language is French a lot of the earlier documents can be a little disjointed but they are still brilliant and mandatory reading. I only add them below the others as you’ll want to be at least a little Megadrive savvy to get the full benefit from them.
His forums are also home to the Exodus, Regen and KMod emulators and the UMDK dev kit so there is a lot of Megadrive knowledge in the people who call Sprite’s Mind home.http://68k.hax.com/
- Quick reference for the 68K instruction set, actually pretty detailed as well.https://youtu.be/qztuEucrNBc
- Inspirational YouTube video.Forum Topics
Here are some specific topics I've made about issues or queries that have came up throughout the project:Code Skipping in GENS
– A topic about how the 2 tracing versions of GENS output their trace logs.Memory Map Visualising
– A topic about the best way to visualise a memory map.Which Emulator Should I Put My Efforts Into
– A discussion about the different hacking based emulators.Contribute!
Yes, you can contribute to the project. Please forward all cash donations to the following PO Box address… just kidding!
Contributions can come in 2 forms, neither of them money related!Technical Contributions
At this point I’m not really looking for any technical assistance. I want to complete the majority of the disassembly myself for my own learning and own satisfaction.
However, if you have the technical know-how and are so inclined then I would be grateful to have anything I publish double checked, even just at a passing glance, for any obvious errors or omissions. I will always strive to publish information that is complete and accurate but I am aware of my own limitations and as this is a learning process mistakes are sure to get through. Any effort to help reduce them not only helps me but anyone else who will be using my work and as a result is greatly appreciated.
Also, if you happen to know the ‘signature’ of any compression algorithms or tell-tale signs of their use then I’d be all ears to know about them!Non-Technical Contributions
This is the type on contributions I’m really looking for just now!
I want to see this project through whether there is call for it or not but I’d love to hear about some of the uses you can see coming out of having a full disassembly of Toejam and Earl at your disposal!
How would you change the game?
What kind of presents would you like to add? Would you add more characters? More players? How about changing the goal of the game so that Toejam starts on level 1, Earl start on level 25 with the aim to be to meet up with the game getting harder and harder the closer you get?
And to this end, what parts of the game do you need to know the details of to achieve it? This may sway the order in which I disassemble certain sections.End Note
So that is it! Well this ended up a bit of a goliath post didn’t it? Hopefully you’ve found it at least a little interesting and if you’ve skipped it all and came right here don’t worry, I’m still interested in your replies!
Now please, fill this topic up with suggestions like it is a Toejam and Earl specific Hack Ideas thread. I think I’ve got the skill but I know there will be people out there with better ideas of what to do with it than me. Seeing lots of awesome ideas will help keep my encouraged and hopefully make me progress a bit faster and get the project completed a little sooner.
Please also be sure to ask any questions you have about anything related, whether it is info on the game or more general questions about the hacking process.
Finally, please also be sure to call me a hero/fool as you see appropriate and post words of encouragement (such as this video over and over https://www.youtube.com/watch?v=qztuEucrNBc
) or anything else you think will help.
Thanks for reading.