Monday, May 1, 2023

Lil Evel Knievel Code Complete

A tribute to the greatest daredevil! Lil Evel Knievel is a continuous side-scrolling skateboard platformer video game set in the original Wonderboy aquazone. Lil EK is also an SMS Power! 2023 coding competition entry.

Let's check it out!

Note: all Lil Evel Knievel development is based on devkitSMS Programming Setup and Programming Sample.
Download source code here.


Instructions
Lil Evel Knievel V1.0 game play is very open and simple due to the aggressive coding competition deadline: jump over varying platform gaps and pull off cool skateboard flips and trick combos to complete each level.

There are four jump categories on ground: Skip, Jump, Leap, Hurl. Once airborne, Lil EK can swap direction or flip somersault. Move opposite direction while airborne inverts somersault and down to accelerate land.
 Jump Categories On Ground
 SKIP Smallest Left + Fire1 
 JUMP Standard Left + Fire2 OR Fire1
 LEAP Sizeable Right + Fire1 OR Fire2
 HURL Colossal Right + Fire2 
 Jump Activities Airborne!
 SWAP Direction Fire1 
 FLIP Somersault Fire2 

Tools
Here is a list of Tools and frameworks that were used in the development of this project:
 KEY  VALUE
 Programming  devkitSMS
 Compiler  sdcc 4.1.0
 Assembler  WLA-DX
 IDE  Visual Studio 2015 / Visual Studio Code
 Languages  C / Z80
 Graphics  BMP2Tile 0.43 / GIMP 2 / paint.net
 Music  pcmenc / vgm2psg
 Emulators  Emulicious / Fusion / Meka
 Debugger  Emulicious Debugger

ROM Hacking
You can hack this ROM! Download and dump Lil Evel Knievel into Hex Editor, e.g. HxD, and modify bytes:
 ADDRESS  VARIABLE  DESCRIPTION
 0x004F  Delay  Used to speed through any game delay.
 0x0050  Invincible  Non-zero value enables invincibility.
 0x0051  Gravity Jump  Jump once while falling from gravity.
 0x0052  HarderLands  Tougher platform collision detection.
 0x0053  Music Off  Set 0=Music to play otherwise silent.
 0x0054  Sound Off  Set 0=Sound to play otherwise silent.
 0x0055  Riffs Off  Set 0=Riffs to play otherwise silent.

Hints
  • Four difficulty options: Easier, Normal, Harder, Insane. Difficulty increase = Visibility descreases
  • Watch out for repetitive single turtles mixed in platforms as this can indicate large Leap or Hurl
  • Favour Hurl for medium sized gap with opposite move direction to land inverted somersault OK
  • Leverage down action on descent to land especially if you start to overshoot the target platform

Audio
Lil Evel Knievel includes digitized sound extensively by leveraging the pcmenc tool and uses development techniques outlined in devkitSMS Programming Sample under PCM Samples section. Some riffs you may have missed include: AC/DC, Austin Powers, Gn'R, Simpsons, Van Halen, Wayne's World, WWF Wrestling.

Music is often easy to neglect in a time pressure coding competition but Lil EK has been quoted as having "perhaps the single most impressive audo soundtrack the little PSG has ever seen".

Commands
The Command design pattern encapsulates a command request as an object. In game code, an example of a command request could be a move command: e.g. move sprite left, right or jump command flip, swap etc.

Coindentally, Lil EK uses 8x commands therefore each command stored as single bit mask; all 8x commands stored within a single byte. This way, combos can be bitwised detected rather than flattened out individually.
 #define COMMAND_LEFT_MASK 0b00000001
 #define COMMAND_MIDD_MASK 0b00000010
 #define COMMAND_RGHT_MASK 0b00000100
 #define COMMAND_HIGH_MASK 0b00001000
 #define COMMAND_DOWN_MASK 0b00010000
 #define COMMAND_JUMP_MASK 0b00100000
 #define COMMAND_SWAP_MASK 0b01000000
 #define COMMAND_FLIP_MASK 0b10000000

Critical to the development process, streams commands can be issued to the game engine for debugging all possible game play scenarios. Plus commands can be recorded for playback to show case instructional demo!


Physics
Game physics are aptly based on the "The Motorcycle Daredevil" projectile motion practice problem. Here are player angle / speed combinations to produce four jump types nicknamed Skip, Jump, Leap and Hurl.
 Type  Angle  Speed  Horizontal  Vertical  Max Frames
 SKIP 45 30 92 23 53
 JUMP 45 40 163 41 81
 LEAP 45 55 309 77 133
 HURL 40 65 425 89 177

Sprites
The Title screen uses Zoom sprites in which the 24x32 player sprite is magnified as a 48x64 sprite. However, SMS I has a bug in how the VDP processes zoomed sprites. Therefore, to circumvent the VDP bug you have to draw 4x additional sprites on the same Y coordinates of the original sprites as seen in title_screen.c file.

YouTube
YouTube videos showcasing all SMS Power! 2023 coding competition entries including some with long play:

 TITLE  AUTHOR
 New Master System Games for 2023  Dudley of Yesterzine
 The Ultimate SMS Coding Showdown  CrossGenGameplay
 Présentation SMS Power Competition  Révo SEGA 8-bit
 Master System Game Lil Evel Knievel  Genesis 8:14

Summary
There has been progressive interest in Sega Master System Homebrew as coding competition entries become more impressive. Unfortunately due to time constraints, the game mechanics and level design were not able to be fully developed at this time. However the foundation for potential future development did receive some incredible feedback from the community and Sega 8-bit preservation and fanaticism fans. That is awesome!