Skip to content

Commit a0c8990

Browse files
Merge pull request #211 from idlechild/demo
Demo Improvements
2 parents 836f44b + f54e367 commit a0c8990

File tree

5 files changed

+2537
-2902
lines changed

5 files changed

+2537
-2902
lines changed

Diff for: resources/bk2_demo_to_input_log.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python
2+
import io
3+
import os
4+
import sys
5+
6+
if len(sys.argv) != 3:
7+
print("bk2_demo_to_input_log.py <asm_file> <output_log_file>")
8+
sys.exit()
9+
else:
10+
asm_name = sys.argv[1]
11+
output_name = sys.argv[2]
12+
13+
asm_file = io.open(os.path.join(os.path.dirname(os.path.realpath(__file__)), asm_name), "r")
14+
asm_lines = asm_file.readlines()
15+
asm_file.close()
16+
17+
output_file = io.open(os.path.join(os.path.dirname(os.path.realpath(__file__)), output_name), "w", newline='\n')
18+
output_file.write("\n; ---------------")
19+
output_file.write("\n; Log Export")
20+
output_file.write("\n; (autogenerated)")
21+
output_file.write("\n; ---------------\n\n")
22+
23+
demo_input_started = False
24+
for line in asm_lines:
25+
if line.startswith("DemoInputInstructionLists"):
26+
demo_input_started = True
27+
if demo_input_started:
28+
if len(line) < 20 or not line.startswith(" dw $"):
29+
output_file.write(line)
30+
else:
31+
count = int(line[8:12], 16)
32+
keys = int(line[15:19], 16)
33+
output_line = bytearray("|..|............|\n", "ascii")
34+
if keys >= 0x8000:
35+
keys -= 0x8000
36+
output_line[11] = ord('B')
37+
if keys >= 0x4000:
38+
keys -= 0x4000
39+
output_line[10] = ord('Y')
40+
if keys >= 0x2000:
41+
keys -= 0x2000
42+
output_line[8] = ord('s')
43+
if keys >= 0x1000:
44+
keys -= 0x1000
45+
output_line[9] = ord('S')
46+
if keys >= 0x800:
47+
keys -= 0x800
48+
output_line[4] = ord('U')
49+
if keys >= 0x400:
50+
keys -= 0x400
51+
output_line[5] = ord('D')
52+
if keys >= 0x200:
53+
keys -= 0x200
54+
output_line[6] = ord('L')
55+
if keys >= 0x100:
56+
keys -= 0x100
57+
output_line[7] = ord('R')
58+
if keys >= 0x80:
59+
keys -= 0x80
60+
output_line[13] = ord('A')
61+
if keys >= 0x40:
62+
keys -= 0x40
63+
output_line[12] = ord('X')
64+
if keys >= 0x20:
65+
keys -= 0x20
66+
output_line[14] = ord('l')
67+
if keys >= 0x10:
68+
keys -= 0x10
69+
output_line[15] = ord('r')
70+
finished_line = output_line.decode()
71+
while count > 0:
72+
output_file.write(finished_line)
73+
count -= 1
74+
75+
output_file.close()
76+

Diff for: resources/bk2_input_log_to_demo.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env python
2+
import io
3+
import os
4+
import sys
5+
6+
if len(sys.argv) != 3:
7+
print("bk2_input_log_to_demo.py <input_log_file> <demo_output_file>")
8+
sys.exit()
9+
else:
10+
input_name = sys.argv[1]
11+
demo_name = sys.argv[2]
12+
13+
input_file = io.open(os.path.join(os.path.dirname(os.path.realpath(__file__)), input_name), "r")
14+
input_lines = input_file.readlines()
15+
input_file.close()
16+
17+
demo_file = io.open(os.path.join(os.path.dirname(os.path.realpath(__file__)), demo_name), "w", newline='\n')
18+
demo_file.write("\n; ---------------")
19+
demo_file.write("\n; Demo Export")
20+
demo_file.write("\n; (autogenerated)")
21+
demo_file.write("\n; ---------------\n\n")
22+
23+
current_input = 0
24+
previous_line = None
25+
previous_count = 0
26+
for line in input_lines:
27+
if len(line) < 17 or '|' != line[0] or '|' != line[3] or '|' != line[16]:
28+
if previous_count > 0:
29+
demo_file.write(f' dw ${previous_count:04X}, ${current_input:04X} ; {previous_line[4:16]}\n')
30+
previous_line = None
31+
previous_count = 0
32+
demo_file.write(line)
33+
else:
34+
if previous_count > 0 and previous_line != line:
35+
demo_file.write(f' dw ${previous_count:04X}, ${current_input:04X} ; {previous_line[4:16]}\n')
36+
previous_line = None
37+
previous_count = 0
38+
if previous_line is None:
39+
previous_line = line
40+
current_input = 0
41+
if 'U' == line[4]:
42+
current_input += 0x800
43+
if 'D' == line[5]:
44+
current_input += 0x400
45+
if 'L' == line[6]:
46+
current_input += 0x200
47+
if 'R' == line[7]:
48+
current_input += 0x100
49+
if 's' == line[8]:
50+
current_input += 0x2000
51+
if 'S' == line[9]:
52+
current_input += 0x1000
53+
if 'Y' == line[10]:
54+
current_input += 0x4000
55+
if 'B' == line[11]:
56+
current_input += 0x8000
57+
if 'X' == line[12]:
58+
current_input += 0x40
59+
if 'A' == line[13]:
60+
current_input += 0x80
61+
if 'l' == line[14]:
62+
current_input += 0x20
63+
if 'r' == line[15]:
64+
current_input += 0x10
65+
previous_count = previous_count + 1
66+
if previous_count > 0:
67+
demo_file.write(f' dw ${previous_count:04X}, ${current_input:04X} ; {previous_line[4:16]}\n\n')
68+
69+
demo_file.close()
70+

Diff for: src/defines.asm

+17
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@
514514
!DEBUG_MODE = $05D1
515515
!CACHED_RANDOM_NUMBER = $05E5
516516
!DISABLE_SOUNDS = $05F5
517+
!DISABLE_MINIMAP = $05F7
517518
!SOUND_TIMER = $0686
518519
!LOAD_STATION_INDEX = $078B
519520
!DOOR_ID = $078D
@@ -532,6 +533,8 @@
532533
!LAYER1_Y = $0915
533534
!LAYER2_X = $0917
534535
!LAYER2_Y = $0919
536+
!BG1_X_OFFSET = $091D
537+
!BG1_Y_OFFSET = $091F
535538
!BG2_X_SCROLL = $0921
536539
!BG2_Y_SCROLL = $0923
537540
!SAMUS_DOOR_SUBSPEED = $092B
@@ -559,6 +562,7 @@
559562
!IGT_SECONDS = $09DC
560563
!IGT_MINUTES = $09DE
561564
!IGT_HOURS = $09E0
565+
!SAMUS_MOONWALK = $09E4
562566
!PAL_DEBUG_MOVEMENT = $09E6
563567
!SAMUS_AUTO_CANCEL = $0A04
564568
!SAMUS_LAST_HP = $0A06
@@ -578,12 +582,20 @@
578582
!SAMUS_MOVEMENT_HANDLER = $0A44
579583
!SAMUS_SUBUNIT_ENERGY = $0A4C
580584
!SAMUS_NORMAL_MOVEMENT_HANDLER = $0A58
585+
!SAMUS_DRAW_HANDLER = $0A5C
581586
!SAMUS_CONTROLLER_HANDLER = $0A60
582587
!SAMUS_SHINE_TIMER = $0A68
583588
!SAMUS_HEALTH_WARNING = $0A6A
584589
!SAMUS_CONTACT_DAMAGE_INDEX = $0A6E
585590
!SAMUS_WATER_PHYSICS = $0A70 ; Not used in vanilla
586591
!SAMUS_HYPER_BEAM = $0A76
592+
!DEMO_PREINSTRUCTION_POINTER = $0A7A
593+
!DEMO_INSTRUCTION_TIMER = $0A7C
594+
!DEMO_INSTRUCTION_POINTER = $0A7E
595+
!DEMO_CONTROLLER_PRI = $0A84
596+
!DEMO_INPUT_ENABLED = $0A88
597+
!DEMO_PREVIOUS_CONTROLLER_PRI = $0A8C
598+
!DEMO_PREVIOUS_CONTROLLER_PRI_NEW = $0A8E
587599
!SAMUS_ANIMATION_FRAME_TIMER = $0A94
588600
!SAMUS_ANIMATION_FRAME = $0A96
589601
!SAMUS_LAVA_DAMAGE_SUITS = $0A98 ; Not used in vanilla
@@ -625,6 +637,8 @@
625637
!SAMUS_BOMB_SPREAD_CHARGE_TIMER = $0CD4
626638
!SAMUS_POWER_BOMB_X = $0CE2
627639
!SAMUS_POWER_BOMB_Y = $0CE4
640+
!PREVIOUS_CONTROLLER_PRI = $0DFE
641+
!PREVIOUS_CONTROLLER_PRI_NEW = $0E00
628642
!ELEVATOR_PROPERTIES = $0E16
629643
!ELEVATOR_STATUS = $0E18
630644
!HEALTH_BOMB_FLAG = $0E1A
@@ -652,6 +666,9 @@
652666
!ENEMY_PROJ_RADIUS = $1BB3
653667
!ENEMY_PROJ_PROPERTIES = $1BD7
654668
!MESSAGE_BOX_INDEX = $1C1F
669+
!DEMO_TIMER = $1F53
670+
!DEMO_CURRENT_SET = $1F55
671+
!DEMO_CURRENT_SCENE = $1F57
655672

656673
!PLM_DELETE = $AAE3
657674

0 commit comments

Comments
 (0)