don't click here

Porting 8-bit Sonic 2 to the TI-84+ CE

Discussion in 'Engineering & Reverse Engineering' started by grubbyplaya, Mar 17, 2024.

Tags:
  1. grubbyplaya

    grubbyplaya

    Member
    17
    29
    13
    About a year ago, I learned that most Texas Instruments graphing calculators use a Z80 CPU, the same one used in the Master System and Game Gear. This includes the newest models with color screens, which meant that it would be theoretically possible to port over the Sonic games made for those consoles to the calculator with relatively few changes to the engine. I decided to see how easy it would be by taking the disassembly of 8-bit Sonic 2 and trying my best to make it assemble for TI's newest and most powerful Z80-based graphing calculator, the TI-84+ CE.

    I ended up switching the assembler from WLA-DX to SPASM-ng, an assembler made specifically for TI graphing calculators. Before I could add any 84+ CE specific optimizations, I had to first port all the directives, macros, and local labels from WLA-DX to their SPASM counterparts. It ended up being the most time-consuming part of porting the game, but once it was done, I could finally start hooking all the I/O stuff in the code, like button presses and palettes, to their 84+ CE equivalents. After that was done, I added a software renderer to the game, as the 84+ CE doesn't have its own hardware-accelerated graphics.

    After all that, I could confidently say that the game was fully playable on the TI-84+ CE. Here's what it looks like:

    [​IMG]

    You might have noticed that the intro was a bit sluggish. That's because as far as I know, there's no good solution to emulating the game's memory mapper on the 84+ CE. The eZ80 CPU in the calculator just isn't fast enough to swap ROM banks in and out without any slowdown, especially with the calculator's high-latency flash memory pretty much halving the effective clock speed. Maybe a future hardware revision will stamp these problems out.

    Other than that, I'm very proud of what I've accomplished. Aside from the TI-Nspire line of calculators, which are powerful enough to emulate the Genesis and GBA games, this is the first time it's possible to play a full-fledged Sonic game on a graphing calculator.

    Here's the GitHub repo.
     
    Last edited: Mar 17, 2024
  2. Jayextee

    Jayextee

    Unpopular Opinions™ Member
    3,253
    63
    28
    Atro City
    I DONE MAKED GAMES.
    Move over DOOM, the hot new trend is "does it run Sonic?"
     
  3. nineko

    nineko

    I am the Holy Cat Tech Member
    6,312
    489
    63
    italy
    That's amazing, I was happy enough to play Tetris on my TI-89 instead of while I was studying to become an engineer, but this is a whole different level, nice work.
     
  4. Ravenfreak

    Ravenfreak

    2 Edgy 4 U Tech Member
    3,096
    195
    43
    O'Fallon Mo
    Sonic 1 Game Gear Disassembly
    Whoa this is amazing! I never had those graphing calculators but I remember everyone talking about adding emulators to their calculators back when I was in high school and I was jealous. xD
     
  5. Jeffery Mewtamer

    Jeffery Mewtamer

    Blind Bookworm Member
    1,893
    101
    43
    I remember playing a Mario knock off on the TI-83 Plus 20 years ago that made Super Mario Land in monochrome look high res and super sophisticated(granted, the TI-83 linehas a resolution of 64*96, I think even the original Game Boy was 160*192 and the TI-83 had more shades of gray than the GB, but only in the sense that there was a contrast setting, pixels could only be light or dark, not multiple levels of dark at the same time), but running a real 8-bit game on a TI, even if they finally upgraded from dot matrix displays, is quite impressive... Do have to wonder why they are still using z80 chips though, I mean, I would think it would be easier to throw a cheap ARM SoC into a modern calculator(granted, I've long thought a device with the power of a smartphone, the form factor of at TI-83, and a full Linux OS would be flipping amazing.
     
  6. grubbyplaya

    grubbyplaya

    Member
    17
    29
    13
    Hi, everyone.

    I made a more in-depth write-up on all the methods I used to get 8-bit Sonic 2 running on the CE about a week ago. It's the first time I've done something like this, so any feedback is appreciated.
    Thanks for all the support!
     
  7. Kroc

    Kroc

    Code is Art Tech Member
    38
    1
    8
    MaSS1VE: The Master System Sonic 1 Visual Editor
  8. grubbyplaya

    grubbyplaya

    Member
    17
    29
    13
    I forgot to include it in the write-up, but another reason why I chose Glitch's Sonic 2 disassembly is because its syntax, aside from directives and local labels, is identical to what SPASM-ng expects. If I went with one of the Sonic 1 disassemblies, there would have to be some pretty major changes just to get it building.