Dunk Shot

Three-on-three basketball on a 56-column court seen through a 32-column window, players made of four sprites, computer teams generated by level and saved to tape as a BSAVE. All drawn from the ROM.

HAL Laboratory - (c) 1986 HAL Laboratory - A 32 KB cartridge - MSX - Dump a1891e03...

Not one capture here. Every picture is drawn from the bytes of the ROM with the cartridge's own tables: the logo, the title and its menus, the whole court in its three colours, the match, the team card, the players' 160 poses and their 32 looks. Six screens are checked against openMSX byte for byte in eight dumps, with 0 differences, and so are the 24 sprites of the six players at the tip-off. The listing and the numbers are reproducible with make, and reassembling gives back the ROM byte for byte.

The cartridge in numbers

100%of the binary explained
1,289named routines
43.2%of the listing commented
20,642bytes of code
12,126bytes of data
0bytes unidentified

What turned up when we took it apart

The court is 56 columns wide and is seen through a 32-column window

The whole court, with the stands and the SUPER PLAYERS DUNK SHOT * HAL LABORATORY banner, is a 56 × 24 map of patterns compressed at 0xB69E. There is no hardware scrolling: 0x5F33 copies into the name table, row by row, the 32 columns starting at the one in 0xE830 (0 to 24), and 0x5E7C moves it one column at a time when the ball crosses the centre. The 21 × 4 scoreboard (0x77AB) goes on top, at column 6.

Every player is four sprites, hence the flicker

Hair, upper skin, shirt and lower skin: four 16 × 16 sprites per player, six players, plus the net, the ball, its shadow and the arrow. The TMS9918 only draws four sprites per line, so 0x5E1B sorts the seven groups by depth, 0x5C0B builds them in that order, 0x5BAB copies them reversed as well, and the two orders go to two attribute tables (0x1B00 and 0x1F00) that register 5 alternates every frame (0x5B77): one frame the near players are in front, the next the far ones. The flicker is deliberate. On an MSX2, with eight sprites per line, a 164-byte patch brings it down from 66.7 sprites not drawn per frame to 1.7.

The 160 poses and the 32 looks

A pose is four pattern numbers (0xA4CE) and four offsets (0xA38E, one per group of four poses) that 0x5C40 subtracts from the position of the feet; the 196 patterns live in RAM, decompressed from 0x9725, 0x9B08, 0x9F80 and 0xA360. Each player's look is one of the 32 pairs at 0x80E4 (skin 0x0B, 0x0A or 0x01 and eleven hair colours) and the shirt is the team colour (0xEA2C/0xEA5C).

Pose, patterns and colours are checked on the six players of two openMSX dumps.

Computer teams are generated by level

ELM, JNR, HIG, COL, YUG, ESP, USA and PRO are not stored rosters: they are levels 1 to 8. When one is chosen, 0x72CA generates eight players with 30, 20 and 25 skill points plus 30 for each level above the first, and a random look taken from the Z80's R register. The name is copied from the list at 0x7CA1 and the level is kept in byte 3 of the team.

Teams are saved to tape as a BSAVE

SAVE DATA writes the team block (0xEC bytes: name, level, colour and eight 29-byte players) with the cassette BIOS, using the binary header, ten 0xD0 bytes, and a six-letter name: the team's three letters and three 0x7F (0x8C33). LOAD DATA finds and reads it (0x8C71) and VERIFY compares it byte for byte (0x8C87).

Three courts, one colour table each

COLOR OF COURT chooses between three compressed colour tables (0xABA8, 0xACB0 and 0xADB8: 264 bytes each, 2,000 when decompressed) for the same 250 patterns. Green, blue and red; the stands and the banner do not change.

The computer's plays

The 720-byte table at 0xAF5F is five formations with six variants each, and in every variant an eight-byte script per player: a delay and waypoints (Y, X, code) up to a 0x80. 0x6F48 picks the variant from the current formation and a random bit, and button 2 of the team with the ball in the opponent's half moves on to the next one.

What is never drawn and what nobody runs

Three court patterns (0x73, 0x85 and 0x86) and the E and S of an ESC in the logo's pattern set (0xFB, 0xFC) are never shown; the C (0xFD) is, in the title. One sprite pattern, number 195, is used by no pose. And seventeen pieces of code nobody reaches: alternative entries, a five-digit counter (0x7AAE) and a routine that writes a zero into the ROM itself (0x8B3C), from when the program ran in RAM.

At 0x4EEC, besides, everything points to a bug in the original: it loads ld hl,(0xE6DF) where the surrounding code suggests ld hl,0xE6DF, and compares and writes at the address formed by “who shot” and “left jumper”, which is 0xFFFF at start-up.

What the cartridge draws

Under each picture is where it comes from and what is on it.

The title: the 17 rows of the name table at 0xB0FE, the 80 logo patterns (0xB33E) with their colours (0xB491), the team names and the credits at 0x7D5A. Checked against openMSX at two instants: 0 differences.
The title: the 17 rows of the name table at 0xB0FE, the 80 logo patterns (0xB33E) with their colours (0xB491), the team names and the credits at 0x7D5A. Checked against openMSX at two instants: 0 differences.
The first menu over the title: the box from 0x7FC1, the four options at 0x7D32 and the cursor ball (0x8AC9). Checked: 0 differences.
The first menu over the title: the box from 0x7FC1, the four options at 0x7D32 and the cursor ball (0x8AC9). Checked: 0 differences.
SET-UP: the whole name table at 0xB22A, the names, the LENGTH OF HALF and COLOR OF COURT marks (0x81BB, 0x81DC) and the cursor. Checked: 0 differences.
SET-UP: the whole name table at 0xB22A, the names, the LENGTH OF HALF and COLOR OF COURT marks (0x81BB, 0x81DC) and the cursor. Checked: 0 differences.
The team screen with a computer team's card: the menu at 0x7CD3, the card box (0x7B75) with the colour bar and the name, and COMPUTER TEAM LEVEL 1 (0x8B81). Checked: 0 differences.
The team screen with a computer team's card: the menu at 0x7CD3, the card box (0x7B75) with the colour bar and the name, and COMPUTER TEAM LEVEL 1 (0x8B81). Checked: 0 differences.
LOAD DATA with no tape: SURE? and ERROR! over it (0x870F, 0x8740). Checked against both dumps: 0 differences.
LOAD DATA with no tape: SURE? and ERROR! over it (0x870F, 0x8740). Checked against both dumps: 0 differences.
The match at the tip-off with the window at column 12: the 24 rows of the map (0x5F33) and the scoreboard from 0x77AB filled in by 0x7A17. Checked against two dumps: 0 differences. The players are sprites and come separately.
The match at the tip-off with the window at column 12: the 24 rows of the map (0x5F33) and the scoreboard from 0x77AB filled in by 0x7A17. Checked against two dumps: 0 differences. The players are sprites and come separately.
The whole court, 56 columns, with the first colour table (0xABA8): the green one. The game shows 32 columns at a time.
The whole court, 56 columns, with the first colour table (0xABA8): the green one. The game shows 32 columns at a time.
The same court with the second colour table (0xACB0): the blue one.
The same court with the second colour table (0xACB0): the blue one.
And with the third (0xADB8): the red one. The stands and the banner do not change.
And with the third (0xADB8): the red one. The stands and the banner do not change.
The 160 poses (0xA4CE and 0xA38E), each assembled from its four sprites, with skin 0x0B, hair 0x01 and a red shirt.
The 160 poses (0xA4CE and 0xA38E), each assembled from its four sprites, with skin 0x0B, hair 0x01 and a red shirt.
The same with skin 0x01, hair 0x05 and the other team's shirt.
The same with skin 0x01, hair 0x05 and the other team's shirt.
The 32 looks at 0x80E4 (skin and hair) on the tip-off pose, with both shirts.
The 32 looks at 0x80E4 (skin and hair) on the tip-off pose, with both shirts.
The net in its three frames (0x9665), the ball, its shadow and the cursor arrow (0x96C5).
The net in its three frames (0x9665), the ball, its shadow and the cursor arrow (0x96C5).
The players' 196 sprite patterns as they sit in RAM (0xCC00-0xE47F).
The players' 196 sprite patterns as they sit in RAM (0xCC00-0xE47F).
The 250 patterns of the court, the menus and the font (0xA74E) with the green court's colours.
The 250 patterns of the court, the menus and the font (0xA74E) with the green court's colours.
The 80 logo patterns (0xB0-0xFF, 0xB33E) with their colours (0xB491).
The 80 logo patterns (0xB0-0xFF, 0xB33E) with their colours (0xB491).
What is never drawn: court patterns 0x73, 0x85 and 0x86 and the E and S of ESC; the C does appear in the title.
What is never drawn: court patterns 0x73, 0x85 and 0x86 and the E and S of ESC; the C does appear in the title.