Thursday, March 1, 2018

Now studying M68K programming

"The Ultimate M68K Cheat Sheet" is a document heavily influenced by MarkeyJester's work, who used a real Genesis to determine cycle counts for all M68K instructions with every source and destination operand possible.

My ultimate cheat sheet attempts to do the same, but ultra-compacts the information into as few tables as possible (31 tables to be exact, covering 9 pages) and incorporates notes from the famous "68000.pdf" (author unknown) floating around, making the beginner's difficult journey to mastering the M68K a whole lot easier.

By studying this document, you also learn what combinations of operands are possible for each instruction, and the cycle cost/availability as a byte, a word, or a long word operation. (For instance, "–/8/8" means that a byte version is not available, but a word and a longword is available at 8 cycles.)

To download my "ultimate" M68K cheat sheet, click here.


I've also taking a similar approach to programming the Genesis's VDP, by documenting different registers and techniques (such as DMA operations) into small, compact tables that take no more than 4 pages.

To download my "ultimate" Genesis VDP cheat sheet, click here.


Also, for practicing M68K assembly, I have been rewriting/improving existing decompression code found in Sonic the Hedgehog 1 (and apparently used by many other games such as Golden Axe), whose source is freely available.

  • "Nemesis" is compression is used for compressing sprite and tile graphics. It does so by creating a library of "brushes", essentially color indices paired with repeat counts. The more common these occur, the shorter the opcode used to indicate them. Opcodes are packed together, making for little waste. You can read more about it here .

    To download my improved Nemesis decompression code for use with Sonic 1: click here.

  • Kosinski decompression can be read about here.

    To download my improved Kosinski decompression code for use with Sonic 1: click here.

  • "Enigma" is used to compress backgrounds (collections of nametable attribute words). The entries are mainly compacted by encoding only those bits that the compression cares about (like declining to code for priority or x- or y-mirror bits, or just making the tile index use fewer bits than its maximum of 11). As usual, data is presented as a stream of bits, so there is little waste.

    To download my improved Enigma decompression code for use with Sonic 1: click here