Skip to content

Replace ENEDAT dumper with dumper/compiler - #16

Open
christianazinn wants to merge 1 commit into
nmlgc:masterfrom
christianazinn:enedat
Open

Replace ENEDAT dumper with dumper/compiler#16
christianazinn wants to merge 1 commit into
nmlgc:masterfrom
christianazinn:enedat

Conversation

@christianazinn

Copy link
Copy Markdown

Updates enedat.com to compile TH03 enemy formation bytecode files as well as dump them, as per the contribution-idea in the enemy formations blogpost.

On 64-bit Windows, run it through the bundled DOS runner:

bin\msdos -e -x bin\Pipeline\enedat.com dump path\to\ENEDAT.DAT > ENEDAT.txt
bin\msdos -e -x bin\Pipeline\enedat.com compile ENEDAT.txt ENEDAT.DAT

dump may also be omitted:

bin\msdos -e -x bin\Pipeline\enedat.com path\to\ENEDAT.DAT > ENEDAT.txt

Recompiling an unmodified dump reproduces the original ENEDAT.DAT byte-for-byte, and I tested it with an enemy script I wrote myself.

The dumped text uses contiguous Formation N and Enemy N headings, followed by "functions" as outlined below. The compiler accepts both single-line and wrapped calls. For instance, dumping ENEDAT.DAT yields:

Formation 0
	Enemy 0
		spawn(
			center: (x: 80, y: -64),
			size: [64, 64, 64, 64],
			hp: [2, 2, 3, 3],
			clip_x: true,
			clip_bottom: false,
			unused: +0
		);
		move_linear(angle: +0x40, speed: 4.375, duration: 50);
		move_circular(
			angle_start: +0x40,
			speed: 5.0,
			angle_speed: -3,
			duration: 160
		);
		move(duration: 120);
		stop();
	Enemy 1
...

The "functions" map to the opcodes in the enemy formations blogpost as follows:

Opcode Function and parameters
0x00 stop()
0x01 move_linear(angle, speed, duration)
0x02 move_circular(angle_start, speed, angle_speed, duration)
0x03 wait(duration)
0x04 move_sine_x(speed_x, angle_speed, velocity_y, duration)
0x05 move_sine_y(speed_y, angle_speed, velocity_x, duration)
0x06 move(duration)
0x07 move_with_speed(speed, duration)
0x08 move_linear_stop_at_player_y(angle, speed, duration)
0x09 move_linear_stop_at_player_x(angle, speed, duration)
0x0A move_circular_plus(angle_start, speed, angle_speed, velocity_x_plus, velocity_y_plus, duration)
0x10 spawn(center_x/8, center_y/8, size_words[4], hp[4], clip_x, clip_bottom, unused
0x80 loop_abs(target, count)
0x81 loop_rel(disp, count)
0x82 clip_x()
0x83 clip_bottom()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant