diff --git a/ChaseHQ.ctl b/ChaseHQ.ctl index 6d46d29..6a056d2 100644 --- a/ChaseHQ.ctl +++ b/ChaseHQ.ctl @@ -282,13 +282,13 @@ W $5BD1,4,2 Start game at entrypt_128k @ $5BD5 label=loader_scratch B $5BD5,2,2 #R$5B31 loads two bytes to here. -- unsure what uses them u $5BD7 Padding bytes -D $5BD7 These bytes do get touched by e.g. #R$C861. +D $5BD7 Bytes to pad this section out to $5C00. These bytes do get touched by e.g. #R$C861. S $5BD7,31,$1F B $5BF6,10,10 b $5C00 [Stage 1] Horizon graphic D $5C00 #HTML[#CALL:graphic($5C00,80,24,0,1)] @ $5C00 label=bitmap_horizon -B $5C00,240,8 Horizon backdrop (80x24) inverted. Varies per stage +B $5C00,240,8 Horizon backdrop (80x24). Non-masked, inverted, bitmap data. Varies per stage. b $5CF0 [Stage 1] Per-stage data @ $5CF0 label=addrof_perp_mugshot_attributes W $5CF0,2,2 Address of Ralph's mugshot attributes @@ -300,17 +300,17 @@ W $5CF4,2,2 Screen attributes used for the ground colour (a pair of matching byt W $5CF6,2,2 Loaded by #R$AC1F. Address of table of LODs for tumbleweeds, barriers. @ $5CF8 label=addrof_right_hand_handlers @ $5CF8 ssub=DEFW right_hand_handlers - 7 -W $5CF8,2,2 Loaded by #R$900F. Address of an array of 7 byte entries. Points 7 bytes earlier. +W $5CF8,2,2 Loaded by #R$900F. Address of an array of 7 byte entries. Points 7 bytes earlier to permit 1-indexing. @ $5CFA label=addrof_right_hand_objects @ $5CFA ssub=DEFW right_hand_graphics_defs - 7 -W $5CFA,2,2 Loaded by #R$A465. Address of graphics entry 1. 1-indexed: it points 7 bytes earlier. +W $5CFA,2,2 Loaded by #R$A465. Address of graphics entry 1. Points 7 bytes earlier to permit 1-indexing. @ $5CFC label=addrof_right_hand_short_pole_object W $5CFC,2,2 Loaded by #R$A53F. Address of graphics entry 3. @ $5CFE label=addrof_turn_sign_handlers W $5CFE,2,2 Address of turn sign arg and handler address. @ $5D00 label=addrof_left_hand_objects @ $5D00 ssub=DEFW left_hand_graphics_defs - 7 -W $5D00,2,2 Loaded by #R$A490. Address of graphics entry 10. 1-indexed: it points 7 bytes earlier. +W $5D00,2,2 Loaded by #R$A490. Address of graphics entry 10. Points 7 bytes earlier to permit 1-indexing. @ $5D02 label=addrof_left_hand_short_pole_object W $5D02,2,2 Loaded by #R$A55C. Address of graphics entry 12. @ $5D04 label=addrof_perp_description @@ -1656,11 +1656,208 @@ B $77CD,1,1 flags? attrs? text is white W $77CE,2,2 Back buffer address W $77D0,2,2 Attributes address T $77D2,6,5:n1 "SIGNAL" -b $77D8 [Pre-game] Data +b $77D8 [Pre-game] Data Commands to draw the pre-game screen. RLE'd tile references etc. $00+ => draw N tiles $1F+ => draw single tile (N - $1F) $E0+ => set draw direction $F0+ => set backbuffer address @ $77D8 label=pregame_data -B $77D8,207,8*25,7 Commands to draw the pre-game screen. RLE'd tile references etc. +B $77D8,1,1 Set colour 12 (bright green) +B $77D9,1,1 Draw horizontally +N $77DA Row 0 +W $77DA,2,2 Set address to (0,1) +B $77DC,1,1 Draw tile 0 (stored as +$1F) +B $77DD,1,1 Repeat next tile 28 times across +B $77DE,1,1 Draw tile 6 (stored as +$1F) +B $77DF,1,1 Draw tile 1 +N $77E0 Row 2 +W $77E0,2,2 Set address to (1,2) +B $77E2,1,1 Draw tile 2 +B $77E3,1,1 Repeat 28 +B $77E4,1,1 Draw tile 5 +B $77E5,1,1 Draw tile 3 +N $77E6 Row 1 +W $77E6,2,2 Set address to $F801 (1,1) +B $77E8,1,1 Draw tile 4 +N $77E9 Row 1 +W $77E9,2,2 Set address to $F81E (30,1) +B $77EB,1,1 Draw tile 7 +N $77EC Row 4 +B $77EC,1,1 Set colour 13 (bright cyan) +W $77ED,2,2 Set address to $F041 (1,4) +B $77EF,1,1 Draw tile 0 +B $77F0,1,1 Repeat 28 +B $77F1,1,1 Draw tile 6 +B $77F2,1,1 Draw tile 1 +N $77F3 Row 15 +W $77F3,2,2 Set address to $F8E1 (1,15) +B $77F5,1,1 Draw tile 2 +B $77F6,1,1 Repeat 28 +B $77F7,1,1 Draw tile 5 +B $77F8,1,1 Draw tile 3 +N $77F9 Row 5 +B $77F9,1,1 Draw vertically +W $77FA,2,2 Set address to $F841 (1,5) +B $77FC,1,1 Repeat 10 +B $77FD,1,1 Draw tile 4 +N $77FE Row 5 +W $77FE,2,2 Set address to $F85E (30,5) must be? +B $7800,1,1 Repeat 10 +B $7801,1,1 Draw tile 7 +N $7802 Row 8. Signal top bar +B $7802,1,1 Set colour 0 (black) +B $7803,1,1 Draw horizontally +W $7804,2,2 Set address to $F097 (23,8) +B $7806,1,1 Repeat 7 +B $7807,1,1 Draw tile 8 +N $7808 Row 10. Signal bottom bar +W $7808,2,2 Set address to $F0B7 (23,10) +B $780A,1,1 Repeat 7 +B $780B,1,1 Draw tile 8 +N $780C Row 5. Top bezel of screen +W $780C,2,2 Set address to $F849 (9,5) +B $780E,1,1 Set colour 15 (bright white) +B $780F,1,1 Draw tile 11 +B $7810,1,1 Draw tile 12 +B $7811,1,1 Repeat 9 +B $7812,1,1 Draw tile 13 +B $7813,1,1 Draw tile 14 +B $7814,1,1 Draw tile 15 +B $7815,1,1 Draw tile 16 +N $7816 Row 6. Top inner bezel of screen +W $7816,2,2 Set address to $F069 (9,6) +B $7818,1,1 Set colour 15 (bright white) +B $7819,1,1 Draw tile 22 +B $781A,1,1 Set colour 13 (bright cyan) +B $781B,1,1 Draw tile 23 +B $781C,1,1 Repeat 9 +B $781D,1,1 Draw tile 24 +B $781E,1,1 Draw tile 25 +B $781F,1,1 Draw tile 26 +B $7820,1,1 Set colour 15 (bright white) +B $7821,1,1 Draw tile 27 +N $7822 Row 7. Top row of screen +W $7822,2,2 Set address to $F86B (9,7) +B $7824,1,1 Set colour 6 (yellow) +B $7825,1,1 Draw tile 35 +B $7826,1,1 Draw tile 17 +B $7827,1,1 Draw tile 17 +B $7828,1,1 Repeat 4 +B $7829,1,1 Draw tile 18 +B $782A,1,1 Draw tile 17 +B $782B,1,1 Draw tile 17 +B $782C,1,1 Draw tile 36 +N $782D Row 8. +W $782D,2,2 Set address to $F08B () +B $782F,1,1 Set colour 14 (bright yellow) +B $7830,1,1 Repeat 10 +B $7831,1,1 Draw tile 44 +N $7832 Row 9. +W $7832,2,2 Set address to $F8B8 +B $7834,1,1 Repeat 10 +B $7835,1,1 Draw tile 44 +N $7836 Row 10. +W $7836,2,2 Set address to $F0AB +B $7838,1,1 Repeat 10 +B $7839,1,1 Draw tile 44 +N $783A Row 11. +W $783A,2,2 Set address to $F8AB +B $783C,1,1 Repeat 10 +B $783D,1,1 Draw tile 44 +N $783E Row 12. +W $783E,2,2 Set address to $F0CB +B $7840,1,1 Repeat 10 +B $7841,1,1 Draw tile 44 +N $7842 Row 7? Left bezel of screen. +B $7842,1,1 Draw vertically +W $7843,2,2 Set address to $F869 (9,15?) +B $7845,1,1 Set colour 7 (white) +B $7846,1,1 Draw tile 33 +B $7847,1,1 Set colour 13 (bright cyan) +B $7848,1,1 Draw tile 33 +B $7849,1,1 Set colour 5 (cyan) +B $784A,1,1 Repeat 6 +B $784B,1,1 Draw tile 33 +N $784C Right bezel of screen. +W $784C,2,2 Set address to $F876 (21,15?) +B $784E,1,1 Set colour 7 (white) +B $784F,1,1 Draw tile 38 +B $7850,1,1 Set colour 13 (bright cyan) +B $7851,1,1 Draw tile 38 +B $7852,1,1 Set colour 5 (cyan) +B $7853,1,1 Repeat 6 +B $7854,1,1 Draw tile 38 +W $7855,2,2 Set address to $F86A +B $7857,1,1 Repeat 3 +B $7858,1,1 Draw tile 34 +W $7859,2,2 Set address to $F875 +B $785B,1,1 Repeat 3 +B $785C,1,1 Draw tile 37 +N $785D Bottom row of screen. +B $785D,1,1 Draw horizontally +W $785E,2,2 Set address to $F8CA +B $7860,1,1 Set colour 13 (bright cyan) +B $7861,1,1 Draw tile 28 +B $7862,1,1 Set colour 14 (bright yellow) +B $7863,1,1 Draw tile 29 +B $7864,1,1 Repeat 8 +B $7865,1,1 Draw tile 30 +B $7866,1,1 Draw tile 31 +B $7867,1,1 Set colour 13 (bright cyan) +B $7868,1,1 Draw tile 32 +W $7869,2,2 Set address to $F0EA +B $786B,1,1 Draw tile 39 +B $786C,1,1 Draw tile 40 +B $786D,1,1 Repeat 8 +B $786E,1,1 Draw tile 41 +B $786F,1,1 Draw tile 42 +B $7870,1,1 Draw tile 43 +N $7871 Bottom bezel of screen. +W $7871,2,2 Set address to $F8EA +B $7873,1,1 Set colour 13 (bright cyan) +B $7874,1,1 Repeat 12 +B $7875,1,1 Draw tile 19 +N $7876 TUNE button top. +W $7876,2,2 Set address to $F084 (4,8) +B $7878,1,1 Set colour 15 (bright white) +B $7879,1,1 Draw tile 9 +B $787A,1,1 Set colour 13 (bright cyan) +B $787B,1,1 Draw tile 10 +N $787C TUNE button bottom. +W $787C,2,2 Set address to $F884 (4,9). +B $787E,1,1 Set colour 14 (bright yellow) +B $787F,1,1 Draw tile 20 +B $7880,1,1 Set colour 5 (cyan) +B $7881,1,1 Draw tile 21 +W $7882,2,2 Set address to $F0C4 +B $7884,1,1 Set colour 15 (bright white) +B $7885,1,1 Draw tile 9 +B $7886,1,1 Set colour 13 (bright cyan) +B $7887,1,1 Draw tile 10 +W $7888,2,2 Set address to $F8C4 +B $788A,1,1 Set colour 14 (bright yellow) +B $788B,1,1 Draw tile 20 +B $788C,1,1 Set colour 5 (cyan) +B $788D,1,1 Draw tile 21 +W $788E,2,2 Set address to $F0D8 +B $7890,1,1 Set colour 15 (bright white) +B $7891,1,1 Draw tile 9 +B $7892,1,1 Set colour 13 (bright cyan) +B $7893,1,1 Draw tile 10 +W $7894,2,2 Set address to $F8D8 +B $7896,1,1 Set colour 14 (bright yellow) +B $7897,1,1 Draw tile 20 +B $7898,1,1 Set colour 5 (cyan) +B $7899,1,1 Draw tile 21 +W $789A,2,2 Set address to $F0DB +B $789C,1,1 Set colour 15 (bright white) +B $789D,1,1 Draw tile 9 +B $789E,1,1 Set colour 13 (bright cyan) +B $789F,1,1 Draw tile 10 +W $78A0,2,2 Set address to $F8DB +B $78A2,1,1 Set colour 14 (bright yellow) +B $78A3,1,1 Draw tile 20 +B $78A4,1,1 Set colour 5 (cyan) +B $78A5,1,1 Draw tile 21 +B $78A6,1,1 Stop @ $78A7 label=pregame_tiles -B $78A7,360,8 Tiles used to draw the pre-game screen #HTML[#CALL:graphic($78A7,8,45*8,0,0)] +B $78A7,360,8 45 tiles used to draw the pre-game screen #HTML[#CALL:graphic($78A7,8,45*8,0,0)] b $7A0F [Graphics] Smoke and fire graphics @ $7A0F label=bitmap_smoke1 B $7A0F,52,8*6,4 16x13 pixels, masked #HTML[#CALL:graphic($7A0F,16,13,1,1)] @@ -2520,67 +2717,79 @@ C $8659,1 Return c $865A Draw the pre-game screen D $865A Used by the routine at #R$858C. @ $865A label=draw_pregame -C $865A,3 Address of data +C $865A,3 Address of pre-game screen data @ $865D label=dp_loop -C $865D,1 A = *HL +C $865D,1 Read a byte C $865E,1 Set flags C $865F,3 Jump to rendering messages only, if zero -C $8662,1 HL++ +C $8662,1 Advance to next byte C $8663,4 Jump if < $D0 -C $8667,4 Jump if < $E0 -- $D0..DF +C $8667,4 Jump if < $D0..DF C $866B,4 Jump if >= $F0 N $866F Otherwise handle $E0..$EF. This just seems to set a value. -C $866F,2 A -= $E0 -C $8671,3 Self modify #R$86C8 with A -C $8674,2 Loop +@ $866F label=dp_cmd_e0_to_ef +C $866F,5 Self modify #R$86C8 with (#REGa - $E0) +C $8674,2 Loop dp_loop N $8676 Handle $D0..DF. -C $8676,2 A -= $D0 -C $8678,6 Self modify #R$86C2 with A * 8 -C $867E,2 Loop +@ $8676 label=dp_cmd_d0_to_df +C $8676,8 Self modify #R$86C2 with (#REGa - $D0) * 8 +C $867E,2 Loop dp_loop N $8680 Handle $F0..FF. +@ $8680 label=dp_cmd_f0_to_ff C $8680,1 D = A C $8681,2 E = *HL++ -C $8683,2 Loop +C $8683,2 Loop dp_loop N $8685 Handle $00..$CF. -C $8687,2 B = 1 single tile? +@ $8685 label=dp_cmd_00_cf +C $8687,2 B = 1 -- single tile? C $8689,2 Jump if >= $1F -C $868B,1 B = A run of tiles? +C $868B,1 B = A -- run of tiles? C $868C,2 A = *HL++ N $868E Handle $1F..? -C $868F,2 A -= $1F A is now a tile index -C $8691,1 multiply by 8 - size of tile -C $8693,1 why the different rotates? -C $8695,3 BC = A -C $8698,2 shift in carry flag? -C $869A,3 Address of base of tiles -C $869D,1 Point at tile we need -N $86A0 label=loop_86a0 +@ $868E label=dp_cmd_1f +C $868E,1 Preserve HL +C $868F,2 A -= $1F -- A is now a tile index +C $8691,3 Multiply by 8 - size of tile - Why the different rotates? +C $8694,1 Preserve BC (tile count?) +C $8695,3 BC = A -- tile index +C $8698,2 Shift in carry flag? +C $869A,4 HL = &pregame_tiles[A] +C $869E,1 Restore BC +C $869F,1 DE = tile ptr, HL = backbuffer ptr +@ $86A0 label=dp_loop_86a0 +C $86A0,1 Count +C $86A1,1 Tile ptr +C $86A2,1 Backbuffer ptr N $86A3 Plot a tile. C $86A3,2 B = 8 +@ $86A5 label=dp_tile_loop C $86A5,3 *HL = *DE++ -C $86A8,1 H++ -C $86A9,2 Loop -C $86AC,6 D = (B << 2) & $20 +C $86A8,1 HL += 256 +C $86A9,2 Loop dp_tile_loop +C $86AB,1 Pop backbuffer ptr +N $86AC Seems to be building an attribute address? +C $86AC,6 D = (B << 2) & 32 C $86B2,5 E = (C & $1F) + D C $86B7,4 A = (C & $E0) << 1 C $86BB,2 D = $59 -C $86BF,1 D++ +C $86BF,1 D = $5A C $86C0,1 A += E C $86C1,1 E = A -C $86C2,2 A = xx Self modified +C $86C2,2 A = by $Dx commands C $86C4,1 Set flags C $86C5,2 Jump if zero -C $86C7,1 *DE = A -C $86C8,2 A = xx Self modified -C $86CA,1 A-- +C $86C7,1 Load an attribute byte? +C $86C8,3 by $Ex commands C $86CB,2 Jump if zero C $86CD,3 A = H & $0F C $86D0,2 Jump if non-zero -C $86D2,4 H -= $10 +C $86D2,4 H -= $10 scanliney stuff C $86D6,4 L += $20 C $86DC,2 HL = BC C $86DE,1 L++ -C $86E1,2 Loop loop_86a0 while B +C $86DF,1 Restore tile ptr +C $86E0,1 Restore count +C $86E1,2 Loop dp_loop_86a0 while B C $86E5,3 Loop C $86E8,2 4 messages to print C $86EA,3 Address of pre_game_messages diff --git a/ChaseHQ.py b/ChaseHQ.py index c3f66c8..0cf2ccb 100755 --- a/ChaseHQ.py +++ b/ChaseHQ.py @@ -12,7 +12,55 @@ ZX_ATTRIBUTE_BLACK_OVER_YELLOW = 48 +COLOUR_NAMES = [ + "Black", + "Blue", + "Red", + "Magenta", + "Green", + "Cyan", + "Yellow", + "White", + "Bright Black", + "Bright Blue", + "Bright Red", + "Bright Magenta", + "Bright Green", + "Bright Cyan", + "Bright Yellow", + "Bright White" +] + class ChaseHQWriter: + def decode_pregame_screen(self, cwd, base): + output = "" + basep = base + while 1: + b = self.snapshot[basep] + basep = basep + 1 + if b == 0x00: + output += "Stop\n" + return output + elif b >= 0x01 and b <= 0x1E: + output += "Repeat %d\n" % (b) + elif b >= 0x1F and b <= 0x1F+45: + output += "Plot tile %d\n" % (b - 0x1F) + elif b >= 0xD0 and b <= 0xDF: + c = b - 0xD0 + output += "Set colour %d (%s)\n" % (c, COLOUR_NAMES[c]) + elif b == 0xE1: + output += "Draw horizontally\n" + elif b == 0xE2: + output += "Draw vertically\n" + elif b >= 0xF0 and b <= 0xFF: + b = (b << 8) | self.snapshot[basep] + basep = basep + 1 + x = b & 0x1F + y = ((b & 0x00D0) | ((b & 0x0F00) >> 7)) >> 4 + output += "Set address to (%d,%d)\n" % (x,y) + else: + output += "Unknown %X\n" % (b) + def decode_nibble_rle(self, cwd, base, typename, names, showlength, follow): output = "Start of %s data at $%X (nibble counted)
" % (typename, base) runlength = 0