Friday, May 25, 2018

Simpsons Trivia Code Complete

I am a big fan of The Simpsons; particularly the early seasons of the show. The Simpsons appeared in comic books, film, music and video games. However, The Simpsons had not appeared on the Sega Master System!
Enter Simpsons Trivia Quiz.

Inspired from previous posts on Sega Console Programming and devkitSMS Programming Setup, Simpsons Trivia is my third 8-bit video game written in C / Z80 assembler to target the Sega Master System (SMS). Let's check it out!

Note: my two previous titles published for the Sega Master System were 3D City and Candy Kid Demo.
Download source code here.

Sega Retro Gaming post documents how to play video games like Simpsons Trivia using a Fusion emulator.
devkitSMS Programming Setup post documents development environment required to build C / Z80 source.
Instructions
Simple: move joystick Up and Down to select a multi-choice answer: A, B, C, D.
Press Button1 to select an answer or progress forward through any prompts.
Note: Press Button2 to always go back. Joystick Left and Right are not used.

ROM Hacking
You can hack this ROM! Download + dump SimpsonsTrivia.sms into Hex Editor, e.g. HxD, and modify bytes:
 ADDRESS  VARIABLE  DESCRIPTION
 0x004F  Debug  Used in development => debugging.
 0x0050  Cheat  Non-zero value will show answers.
 0x0051  Random  Ask random questions during quiz.
 0x0052  Music  0=music play otherwise off.
 0x0053  Sound  0=sound on otherwise off.
 0x0054  Extra  Set visibility on all extra info.
#ifndef _HACK_MANAGER_H_
#define _HACK_MANAGER_H_

#define PEEK(addr)   (*(unsigned char *)(addr))
#define POKE(addr, data) (*(unsigned char *)(addr) = (data))

#define HACKER_START  0x0050

extern unsigned char hacker_debug, hacker_cheat, hacker_random;
extern unsigned char hacker_music, hacker_sound, hacker_extra;

void engine_hack_manager_init()
{
  hacker_debug = PEEK( HACKER_START - 1 );  // 0x004F
  hacker_cheat = PEEK( HACKER_START + 0 );  // 0x0050
  hacker_random= PEEK( HACKER_START + 1 );  // 0x0051
  hacker_music = PEEK( HACKER_START + 2 );  // 0x0052
  hacker_sound = PEEK( HACKER_START + 3 );  // 0x0053
  hacker_extra = PEEK( HACKER_START + 4 );  // 0x0054
}
#endif//_HACK_MANAGER_H_
Cheat
Some of the questions may be tough so you can cheat if necessary! Either hack the ROM as above to show the answers or alternatively press Button2 five times on the Title screen when prompted to "Press Start".

Credits
StevePro Studios would like to thank the following, esp. at SMS Power, for making this project possible:
 sverx  devkitSMS  Sega Master System development kit + libraries
 Maxim  BMP2Tile  Converts BMP images into 8x8 SMS tile data
 vhelin  WLA-DX  Z80 multi platform cross Assembler package
 Martin  SMS Examine  Z80 disassembler recompilable by WLA-DX
 Calindro  Emulicious  SMS emulator (excellent debugging features)
 Bock  Meka  SMS emulator (excellent debugging features)
 Steve Snake  Fusion  SMS emulator used for general play testing
Note: music used from Bart vs. the Space Mutants + Flicky and sound FX from Baluba Balok + Super Uwol! Reference to original Simpsons Trivia questions can be found here.

Homebrew
The Homebrew community at SMS Power celebrates Sega 8-bit preservation and fanaticism each year with its annual competitions. Therefore, this is always an opportunity to participate by entering these games!

However, during the past 3 years, I haven't seen as much interest in SMS Homebrew games than in 2018:
 Atari Age  SMS Power! Coding competition 2018
 Indie Retro News  SMS Power! Competition 2018
 Vlog retrogaming  6 nouveaux jeux Master System grâce au SMS Power 2018 !!
 Marianne Vote *aka Révo*  Présentation SMS Power Competition #21 2018 SEGA Master System
 ROMhacking.Ru  ????? SMS Power! Competition 2018
Here are some cool Simpsons Trivia links from PD ROMS, DC EMU UK, idpixel.ru + Tsar Evgeniy [YouTube]

Popularity
Arguably, recent interest for Sega Master System games has grown in popularity could be due to the high quality work of Indie game developer eruiz00 with titles Astro Force, Silver Valley and Galactic Revenge.

Not only do these awesome games keep the console alive but the fact that the community shares source code and assets; this certainly does help other developers improve their skills + contribute more games!

Summary
To summarize, the 2018 coding competition featured the fewest entries [6] compared to 2017 [8] and 2016 [16]. However, for each entry in 2018, there seemed to be more accompanying box art and/or instructions.

In fact, some Homebrew productions come complete with box art, case, cover and physical ROM cartridge e.g. Duke Nukem. Again, community members helping transform this fun past time into a serious hobby!

Retrospective
In 2013, an initial ambitious goal was to build a retro game in pure Z80 assembler to target the Sega Master System. During the past 5 years, it seemed more feasible to code in C using either the z88dk or devkitSMS.

However, the 2018 competition entry Astroswab by hang-on was written in pure Z80 assembler. By sharing the source code, this project has given some solid ideas on how it could be possible to achieve this goal J