From da6b856dc58fd921427f98bcf12e3cc8e7036ab3 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 19 Apr 2020 19:38:09 +0200 Subject: [PATCH] [Reverse-engineering] [th04/th05] Stage enemy structure Last one of the shared entity types! The TH05 version of the .STD enemy VM would now be ready for decompilation in one single future push. Completes P0088, funded by -Tom-. --- th02/sprites/cels.h | 1 + th02/sprites/cels.inc | 1 + th04/main/enemy/enemies[bss].asm | 15 + th04/main/enemy/enemy.hpp | 90 ++++ th04/main/enemy/enemy.inc | 33 ++ th04/main/enemy/inv.asm | 24 + th04/main/enemy/render.asm | 98 ++++ th04/main/item/items.hpp | 4 + th04/main/item/items[bss].asm | 4 + th04/sprites/cels.h | 2 + th04/sprites/cels.inc | 2 + th04/sprites/main_pat.h | 2 + th04/sprites/main_pat.inc | 1 + th04_main.asm | 853 +++++++++++++------------------ th05/main/enemy/enemy.hpp | 47 ++ th05/main/enemy/enemy.inc | 33 ++ th05/sprites/main_pat.h | 4 +- th05/sprites/main_pat.inc | 1 + th05_main.asm | 783 ++++++++++++---------------- 19 files changed, 1048 insertions(+), 950 deletions(-) create mode 100644 th02/sprites/cels.h create mode 100644 th02/sprites/cels.inc create mode 100644 th04/main/enemy/enemies[bss].asm create mode 100644 th04/main/enemy/enemy.hpp create mode 100644 th04/main/enemy/enemy.inc create mode 100644 th04/main/enemy/inv.asm create mode 100644 th04/main/enemy/render.asm create mode 100644 th05/main/enemy/enemy.hpp create mode 100644 th05/main/enemy/enemy.inc diff --git a/th02/sprites/cels.h b/th02/sprites/cels.h new file mode 100644 index 00000000..25dc71e6 --- /dev/null +++ b/th02/sprites/cels.h @@ -0,0 +1 @@ +#define ENEMY_KILL_CELS 8 diff --git a/th02/sprites/cels.inc b/th02/sprites/cels.inc new file mode 100644 index 00000000..8d120128 --- /dev/null +++ b/th02/sprites/cels.inc @@ -0,0 +1 @@ +ENEMY_KILL_CELS = 8 diff --git a/th04/main/enemy/enemies[bss].asm b/th04/main/enemy/enemies[bss].asm new file mode 100644 index 00000000..5c097a42 --- /dev/null +++ b/th04/main/enemy/enemies[bss].asm @@ -0,0 +1,15 @@ +ENEMY_W = 32 +ENEMY_H = 32 + +EF_FREE = 0 +EF_ALIVE = 1 +EF_KILLED = 2 +EF_ALIVE_FIRST_FRAME = 3 +EF_KILL_ANIM = 80h + +ENEMY_COUNT = 32 + +ENEMY_POS_RANDOM = (999 shl 4) + +public _enemies +_enemies enemy_t ENEMY_COUNT dup () diff --git a/th04/main/enemy/enemy.hpp b/th04/main/enemy/enemy.hpp new file mode 100644 index 00000000..1eccce57 --- /dev/null +++ b/th04/main/enemy/enemy.hpp @@ -0,0 +1,90 @@ +#define ENEMY_W 32 +#define ENEMY_H 32 + +enum enemy_flag_t { + EF_FREE = 0, + EF_ALIVE = 1, + EF_KILLED = 2, + EF_ALIVE_FIRST_FRAME = 3, + + // Yes, the kill animation doesn't use the perfectly suitable animation + // system, but is implemented in terms of the [flag]. + EF_KILL_ANIM = 0x80, + EF_KILL_ANIM_last = (EF_KILL_ANIM + PAT_ENEMY_KILL - 1) +}; + +#if GAME == 4 +struct enemy_t { + unsigned char flag; + unsigned char age; + motion_t pos; + unsigned char patnum_base; + int8_t unused_1; + int hp; + int16_t unused_2; + int score; + unsigned char near *script; + int script_ip; + + // Certain instructions are executed once per frame, up to a number of + // frames given in some parameter of the instruction, before [script_ip] + // is pointed to the next one. This member tracks the current frame of + // this enemy's currently running blocking multi-frame instruction. + unsigned char cur_instr_frame; + + // Current loop counter for the LOOP instruction. Resets to 0 once the + // amount of loops given in the instruction's parameter has been reached, + // allowing a new loop to run. Since there's only one such counter, LOOP + // instructions can't be nested. + unsigned char loop_i; + + Subpixel speed; + unsigned char angle; + + // Certain instructions add this to [angle] for every frame they are + // executed. + unsigned char angle_delta; + + // Clips the enemy once it leaves the playfield. If not clipped along the + // X or Y axis, the [script] will continue to run if the enemy has left + // the playfield on that axis, and it will continue to take up a slot in + // [enemies]. + bool clip_x; + bool clip_y; + + int8_t unused_3; + item_type_t item; + bool damaged_this_frame; + + // Animation parameters. Final patnum is + // [patnum_base] + (([age] / [anim_frames_per_cel]) % [anim_cels] + unsigned char anim_cels; + unsigned char anim_frames_per_cel; + unsigned char anim_cur_cel; // technically unnecessary + + bool can_be_damaged; + bool autofire; + bool kills_player_on_collision; + + // Not updated to reflect the current playfield half the enemy is in! + bool spawned_in_left_half; + + bullet_template_t bullet_template; + + // If [autofire] is true, the enemy fires bullets, according to its + // template, every [autofire_interval] number of frames, with + // [autofire_cur_frame] tracking the current one. + unsigned char autofire_cur_frame; + unsigned char autofire_interval; +}; +#endif + +#define ENEMY_COUNT 32 + +extern enemy_t enemies[ENEMY_COUNT]; +extern enemy_t near *enemy_cur; + +#define ENEMY_POS_RANDOM 999.0f + +void pascal near enemies_invalidate(void); +void pascal near enemies_render(void); diff --git a/th04/main/enemy/enemy.inc b/th04/main/enemy/enemy.inc new file mode 100644 index 00000000..b8678834 --- /dev/null +++ b/th04/main/enemy/enemy.inc @@ -0,0 +1,33 @@ +enemy_t struc + flag db ? + age db ? + pos motion_t + E_patnum_base db ? + db ? + E_hp dw ? + db ? + db ? + E_score dw ? + E_script dw ? + E_script_ip dw ? + E_cur_instr_frame db ? + E_loop_i db ? + E_speed dw ? + E_angle db ? + E_angle_delta db ? + E_clip_x db ? + E_clip_y db ? + db ? + E_item db ? + E_damaged_this_frame db ? + E_anim_cels db ? + E_anim_frames_per_cel db ? + E_anim_cur_cel db ? + E_can_be_damaged db ? + E_autofire db ? + E_kills_player_on_collision db ? + E_spawned_in_left_half db ? + E_bullet_template bullet_template_t + E_autofire_cur_frame db ? + E_autofire_interval db ? +enemy_t ends diff --git a/th04/main/enemy/inv.asm b/th04/main/enemy/inv.asm new file mode 100644 index 00000000..3f69139e --- /dev/null +++ b/th04/main/enemy/inv.asm @@ -0,0 +1,24 @@ +public ENEMIES_INVALIDATE +enemies_invalidate proc near + push si + push di + mov _tile_invalidate_box, (ENEMY_W shl 16) or ENEMY_H + mov si, offset _enemies + mov di, ENEMY_COUNT + +@@loop: + cmp [si+enemy_t.flag], EF_FREE + jz short @@next + cmp [si+enemy_t.flag], EF_ALIVE_FIRST_FRAME + jz short @@next + call tiles_invalidate_around pascal, large dword ptr [si+enemy_t.pos.prev] + +@@next: + add si, size enemy_t + dec di + jnz short @@loop + pop di + pop si + retn +enemies_invalidate endp + even diff --git a/th04/main/enemy/render.asm b/th04/main/enemy/render.asm new file mode 100644 index 00000000..f674c7bb --- /dev/null +++ b/th04/main/enemy/render.asm @@ -0,0 +1,98 @@ +public ENEMIES_RENDER +enemies_render proc near + +@@patnum = byte ptr -5 +@@top = word ptr -4 +@@i = word ptr -2 + + enter 6, 0 + push si + push di + mov si, offset _enemies + mov [bp+@@i], 0 + jmp @@more? +; --------------------------------------------------------------------------- + +@@loop: + cmp byte ptr [si+enemy_t.flag], EF_ALIVE + jz short @@outside_playfield? + cmp byte ptr [si+enemy_t.flag], EF_KILL_ANIM + jb @@next + +@@outside_playfield?: + cmp [si+enemy_t.pos.prev.y], (-(ENEMY_H / 2) shl 4) + jle @@next + cmp [si+enemy_t.pos.prev.y], ((PLAYFIELD_H + (ENEMY_H / 2)) shl 4) + jge @@next + mov al, [si+enemy_t.E_patnum_base] + mov [bp+@@patnum], al + cmp [si+enemy_t.E_anim_cels], 1 + jbe short @@put + mov al, [si+enemy_t.age] + mov ah, 0 + mov dl, [si+enemy_t.E_anim_frames_per_cel] + mov dh, 0 + push dx + cwd + pop bx + idiv bx + or dx, dx + jnz short @@still_same_cel + inc [si+enemy_t.E_anim_cur_cel] + mov al, [si+enemy_t.E_anim_cur_cel] + cmp al, [si+enemy_t.E_anim_cels] + jb short @@still_same_cel + mov [si+enemy_t.E_anim_cur_cel], 0 + +@@still_same_cel: + mov al, [si+enemy_t.E_anim_cur_cel] + add [bp+@@patnum], al + +@@put: + mov ax, [si+enemy_t.cur.pos.x] + sar ax, 4 + add ax, (PLAYFIELD_X - (ENEMY_W / 2)) + mov di, ax + call scroll_subpixel_y_to_vram_seg1 pascal, [si+enemy_t.pos.cur.y] + mov [bp+@@top], ax + or di, di + jle short @@next + cmp di, PLAYFIELD_RIGHT + jge short @@next + cmp [si+enemy_t.pos.cur.y], (-(ENEMY_H / 2) shl 4) + jle short @@next + cmp [si+enemy_t.pos.cur.y], ((PLAYFIELD_H + (ENEMY_H / 2)) shl 4) + jge short @@next + cmp [si+enemy_t.E_damaged_this_frame], 0 + jnz short @@damaged + push di + push ax + mov al, [bp+@@patnum] + mov ah, 0 + push ax + call super_roll_put + jmp short @@next +; --------------------------------------------------------------------------- + +@@damaged: + push di + push [bp+@@top] + mov al, [bp+@@patnum] + mov ah, 0 + push ax + pushd PLANE_PUT or GC_BRGI + call super_roll_put_1plane + mov [si+enemy_t.E_damaged_this_frame], 0 + +@@next: + inc [bp+@@i] + add si, size enemy_t + +@@more?: + cmp [bp+@@i], ENEMY_COUNT + jl @@loop + pop di + pop si + leave + retn +enemies_render endp diff --git a/th04/main/item/items.hpp b/th04/main/item/items.hpp index 75dea3b8..7004c917 100644 --- a/th04/main/item/items.hpp +++ b/th04/main/item/items.hpp @@ -1,4 +1,8 @@ enum item_type_t { +#if GAME == 5 + IT_NONE = -2, +#endif + IT_ENEMY_DROP_NEXT = -1, IT_POWER = 0, IT_POINT = 1, IT_DREAM = 2, diff --git a/th04/main/item/items[bss].asm b/th04/main/item/items[bss].asm index 01c9fb57..f7c44412 100644 --- a/th04/main/item/items[bss].asm +++ b/th04/main/item/items[bss].asm @@ -1,4 +1,8 @@ ; item_type_t +if GAME eq 5 + IT_NONE = -2 +endif +IT_ENEMY_DROP_NEXT = -1 IT_POWER = 0 IT_POINT = 1 IT_DREAM = 2 diff --git a/th04/sprites/cels.h b/th04/sprites/cels.h index 3d5f6be0..71ce748b 100644 --- a/th04/sprites/cels.h +++ b/th04/sprites/cels.h @@ -1,5 +1,7 @@ /// Animation frame counts /// ---------------------- +#include "th02/sprites/cels.h" + #define HITSHOT_CELS 4 #define BULLET_CLOUD_CELS 4 #define BULLET_DECAY_CELS 4 diff --git a/th04/sprites/cels.inc b/th04/sprites/cels.inc index 764a4106..99d4818a 100644 --- a/th04/sprites/cels.inc +++ b/th04/sprites/cels.inc @@ -1,3 +1,5 @@ +include th02/sprites/cels.inc + HITSHOT_CELS = 4 BULLET_CLOUD_CELS = 4 BULLET_DECAY_CELS = 4 diff --git a/th04/sprites/main_pat.h b/th04/sprites/main_pat.h index b1b8e619..0315c0a7 100644 --- a/th04/sprites/main_pat.h +++ b/th04/sprites/main_pat.h @@ -7,6 +7,8 @@ typedef enum { // miko32.bft // ---------- + PAT_ENEMY_KILL = 4, + PAT_ENEMY_KILL_last = (PAT_ENEMY_KILL + ENEMY_KILL_CELS - 1), PAT_CLOUD_BULLET16_BLUE = 20, PAT_CLOUD_BULLET16_BLUE_last = (PAT_CLOUD_BULLET16_BLUE + BULLET_CLOUD_CELS - 1), PAT_CLOUD_BULLET16_RED, diff --git a/th04/sprites/main_pat.inc b/th04/sprites/main_pat.inc index 40c54faf..b3086beb 100644 --- a/th04/sprites/main_pat.inc +++ b/th04/sprites/main_pat.inc @@ -1,5 +1,6 @@ include th04/sprites/cels.inc +PAT_ENEMY_KILL = 4 PAT_CLOUD_BULLET16_BLUE = 20 PAT_CLOUD_BULLET16_RED = 24 PAT_OPTION_REIMU = 38 diff --git a/th04_main.asm b/th04_main.asm index 4b152027..1f304efe 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -381,7 +381,7 @@ loc_ABD8: call main_01:sub_10ABF call main_01:sub_104B6 call bullets_update - call sub_17E59 + call enemies_update call _midboss_update call _boss_update call items_update @@ -390,7 +390,7 @@ loc_ABD8: call main_01:sub_1020A call _boss_fg_render call _midboss_render - call main_01:sub_10713 + call main_01:enemies_render call main_01:shots_render call main_01:player_render call main_01:grcg_setmode_rmw_1 @@ -2160,35 +2160,7 @@ include th04/formats/scoredat_code_asm.asm include th04/formats/z_super_roll_put_tiny.asm include th04/main/circles.asm db 0 - -; =============== S U B R O U T I N E ======================================= - - -sub_C74C proc near - push si - push di - mov _tile_invalidate_box, (32 shl 16) or 32 - mov si, 8A92h - mov di, 20h ; ' ' - -loc_C75D: - cmp byte ptr [si], 0 - jz short loc_C76E - cmp byte ptr [si], 3 - jz short loc_C76E - call main_01:tiles_invalidate_around pascal, large dword ptr [si+6] - -loc_C76E: - add si, 40h - dec di - jnz short loc_C75D - pop di - pop si - retn -sub_C74C endp - -; --------------------------------------------------------------------------- - nop +include th04/main/enemy/inv.asm ; =============== S U B R O U T I N E ======================================= @@ -2455,7 +2427,7 @@ sub_CB58 proc near call main_01:sub_10EED call main_01:player_invalidate call main_01:sub_10444 - call main_01:sub_C74C + call main_01:enemies_invalidate call main_01:bullets_gather_invalidate call items_invalidate call sparks_invalidate @@ -9771,109 +9743,7 @@ loc_10704: retf sub_105B9 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10713 proc near - -@@patnum = byte ptr -5 -var_4 = word ptr -4 -var_2 = word ptr -2 - - enter 6, 0 - push si - push di - mov si, 8A92h - mov [bp+var_2], 0 - jmp loc_107D6 -; --------------------------------------------------------------------------- - -loc_10724: - cmp byte ptr [si], 1 - jz short loc_10730 - cmp byte ptr [si], 80h - jb loc_107D0 - -loc_10730: - cmp word ptr [si+8], 0FF00h - jle loc_107D0 - cmp word ptr [si+8], 1800h - jge loc_107D0 - mov al, [si+0Eh] - mov [bp+@@patnum], al - cmp byte ptr [si+25h], 1 - jbe short loc_10776 - mov al, [si+1] - mov ah, 0 - mov dl, [si+26h] - mov dh, 0 - push dx - cwd - pop bx - idiv bx - or dx, dx - jnz short loc_10770 - inc byte ptr [si+27h] - mov al, [si+27h] - cmp al, [si+25h] - jb short loc_10770 - mov byte ptr [si+27h], 0 - -loc_10770: - mov al, [si+27h] - add [bp+@@patnum], al - -loc_10776: - mov ax, [si+2] - sar ax, 4 - add ax, 10h - mov di, ax - call main_01:scroll_subpixel_y_to_vram_seg1 pascal, word ptr [si+4] - mov [bp+var_4], ax - or di, di - jle short loc_107D0 - cmp di, 1A0h - jge short loc_107D0 - cmp word ptr [si+4], 0FF00h - jle short loc_107D0 - cmp word ptr [si+4], 1800h - jge short loc_107D0 - cmp byte ptr [si+24h], 0 - jnz short loc_107B7 - push di - push ax - mov al, [bp+@@patnum] - mov ah, 0 - push ax - call super_roll_put - jmp short loc_107D0 -; --------------------------------------------------------------------------- - -loc_107B7: - push di - push [bp+var_4] - mov al, [bp+@@patnum] - mov ah, 0 - push ax - pushd PLANE_PUT or GC_BRGI - call super_roll_put_1plane - mov byte ptr [si+24h], 0 - -loc_107D0: - inc [bp+var_2] - add si, 40h - -loc_107D6: - cmp [bp+var_2], 20h ; ' ' - jl loc_10724 - pop di - pop si - leave - retn -sub_10713 endp - +include th04/main/enemy/render.asm include th04/main/player/invalidate.asm include th04/main/player/move.asm include th04/main/player/pos_update_and_clamp.asm @@ -11758,8 +11628,8 @@ sub_11ECB proc near push offset _shots push size _shots / 4 call main_01:sub_C34E - push 8A92h - push 200h + push offset _enemies + push size _enemies / 4 call main_01:sub_C34E push offset _sparks push size _sparks / 4 @@ -16414,66 +16284,66 @@ word_1553B dw 0, 1, 2, 3 ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public ENEMY_POS_UPDATE +enemy_pos_update proc near -sub_1554F proc near - -var_2 = word ptr -2 +@@enemy = word ptr -2 enter 2, 0 push si - mov ax, word_2598A - mov [bp+var_2], ax - add ax, 2 + mov ax, _enemy_cur + mov [bp+@@enemy], ax + add ax, enemy_t.pos call _motion_update_2 pascal, ax - mov si, [bp+var_2] - cmp byte ptr [si+20h], 0 - jz short loc_15572 - add ax, (16 shl 4) - cmp ax, ((PLAYFIELD_W + 32) shl 4) - jnb short loc_15586 + mov si, [bp+@@enemy] + cmp [si+enemy_t.E_clip_x], 0 + jz short @@clip_y? -loc_15572: - cmp byte ptr [si+21h], 0 - jz short loc_15582 - add dx, (16 shl 4) - cmp dx, ((PLAYFIELD_H + 32) shl 4) - jnb short loc_15586 + ; Note that these comparisons abuse underflow to implicitly handle the + ; negative direction as well. + add ax, ((ENEMY_W / 2) shl 4) + cmp ax, ((PLAYFIELD_W + ENEMY_W) shl 4) + jnb short @@clip -loc_15582: +@@clip_y?: + cmp [si+enemy_t.E_clip_y], 0 + jz short @@on_playfield + add dx, ((ENEMY_H / 2) shl 4) + cmp dx, ((PLAYFIELD_H + ENEMY_H) shl 4) + jnb short @@clip + +@@on_playfield: mov al, 0 - jmp short loc_1558F + jmp short @@ret ; --------------------------------------------------------------------------- -loc_15586: +@@clip: inc _enemies_gone - mov byte ptr [si], 2 + mov [si+enemy_t.flag], EF_KILLED mov al, 1 -loc_1558F: +@@ret: pop si leave retn -sub_1554F endp +enemy_pos_update endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame - -sub_15592 proc near +public ENEMY_VELOCITY_SET +enemy_velocity_set proc near push bp mov bp, sp push si - mov si, word_2598A - lea ax, [si+0Ah] - push ax - push word ptr [si+1Eh] - push word ptr [si+1Ch] - call vector2_near + mov si, _enemy_cur + lea ax, [si+enemy_t.pos.velocity] + call vector2_near pascal, ax, word ptr [si+enemy_t.E_angle], [si+enemy_t.E_speed] pop si pop bp retn -sub_15592 endp +enemy_velocity_set endp ; =============== S U B R O U T I N E ======================================= @@ -16484,22 +16354,19 @@ sub_155AA proc near push bp mov bp, sp push si - mov si, word_2598A + mov si, _enemy_cur push es mov ax, _player_pos.cur.y - sub ax, [si+4] + sub ax, [si+enemy_t.pos.cur.y] push ax mov ax, _player_pos.cur.x - sub ax, [si+2] + sub ax, [si+enemy_t.pos.cur.x] push ax call iatan2 - add al, [si+1Eh] - mov [si+1Eh], al - lea ax, [si+0Ah] - push ax - push word ptr [si+1Eh] - push word ptr [si+1Ch] - call vector2_near + add al, [si+enemy_t.E_angle] + mov [si+enemy_t.E_angle], al + lea ax, [si+enemy_t.pos.velocity] + call vector2_near pascal, ax, word ptr [si+enemy_t.E_angle], [si+enemy_t.E_speed] pop es assume es:nothing pop si @@ -16521,12 +16388,12 @@ var_1 = byte ptr -1 enter 4, 0 push si push di - mov si, word_2598A + mov si, _enemy_cur mov es, _std_seg loc_155EB: - mov di, [si+16h] - add di, [si+18h] + mov di, [si+enemy_t.E_script] + add di, [si+enemy_t.E_script_ip] loc_155F1: mov al, es:[di] @@ -16538,17 +16405,17 @@ loc_155F1: jmp cs:off_15B4D[bx] loc_15607: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_15620 mov al, es:[di+2] mov ah, 0 - mov [si+1Ch], ax + mov [si+enemy_t.E_speed], ax mov al, es:[di+1] - mov [si+1Eh], al - call sub_15592 + mov [si+enemy_t.E_angle], al + call enemy_velocity_set loc_15620: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 mov al, es:[di+3] @@ -16558,27 +16425,27 @@ loc_15620: ; --------------------------------------------------------------------------- loc_15637: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_15640 - call sub_15592 + call enemy_velocity_set loc_15640: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 jmp loc_1573B ; --------------------------------------------------------------------------- loc_1564C: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_1565E mov al, es:[di+1] mov ah, 0 - mov [si+1Ch], ax - call sub_15592 + mov [si+enemy_t.E_speed], ax + call enemy_velocity_set loc_1565E: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 mov al, es:[di+2] @@ -16588,26 +16455,26 @@ loc_1565E: ; --------------------------------------------------------------------------- loc_15675: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_15692 mov al, es:[di+1] - mov [si+1Eh], al + mov [si+enemy_t.E_angle], al mov al, es:[di+3] - mov [si+1Fh], al + mov [si+enemy_t.E_angle_delta], al mov al, es:[di+2] mov ah, 0 - mov [si+1Ch], ax + mov [si+enemy_t.E_speed], ax loc_15692: - call sub_15592 + call enemy_velocity_set cmp byte ptr es:[di], 5 jnz short loc_156B8 mov al, es:[di+4] cbw - add [si+0Ah], ax + add [si+enemy_t.pos.velocity.x], ax mov al, es:[di+5] cbw - add [si+0Ch], ax + add [si+enemy_t.pos.velocity.y], ax mov al, es:[di+6] mov [bp+var_1], al mov [bp+var_2], 7 @@ -16620,22 +16487,22 @@ loc_156B8: mov [bp+var_2], 5 loc_156C3: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 jmp short loc_15708 ; --------------------------------------------------------------------------- loc_156CE: - call sub_15592 + call enemy_velocity_set cmp byte ptr es:[di], 0Eh jnz short loc_156F4 mov al, es:[di+1] cbw - add [si+0Ah], ax + add [si+enemy_t.pos.velocity.x], ax mov al, es:[di+2] cbw - add [si+0Ch], ax + add [si+enemy_t.pos.velocity.y], ax mov al, es:[di+3] mov [bp+var_1], al mov [bp+var_2], 4 @@ -16648,33 +16515,33 @@ loc_156F4: mov [bp+var_2], 2 loc_156FF: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 loc_15708: - mov al, [si+1Fh] - add [si+1Eh], al + mov al, [si+enemy_t.E_angle_delta] + add [si+enemy_t.E_angle], al jmp loc_15B1A ; --------------------------------------------------------------------------- loc_15711: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_1573B - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax jmp short loc_1573B ; --------------------------------------------------------------------------- loc_15721: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_1572C - mov word ptr [si+0Ah], 0 + mov [si+enemy_t.pos.velocity.x], 0 loc_1572C: mov ax, _scroll_last_delta - mov [si+0Ch], ax - call sub_1554F + mov [si+enemy_t.pos.velocity.y], ax + call enemy_pos_update or al, al jnz loc_159A4 @@ -16686,40 +16553,40 @@ loc_1573B: ; --------------------------------------------------------------------------- loc_15749: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_1575A - mov byte ptr [si+1Eh], 0 + mov [si+enemy_t.E_angle], 0 mov al, es:[di+2] - mov [si+1Fh], al + mov [si+enemy_t.E_angle_delta], al loc_1575A: movzx eax, byte ptr es:[di+1] - mov dl, [si+1Eh] + mov dl, [si+enemy_t.E_angle] mov dh, 0 add dx, dx mov bx, dx movsx edx, _CosTable8[bx] imul eax, edx sar eax, 8 - mov [si+0Ah], ax + mov [si++enemy_t.pos.velocity.x], ax mov al, es:[di+3] cbw - mov [si+0Ch], ax + mov [si++enemy_t.pos.velocity.y], ax cmp byte ptr es:[di], 8 jnz short loc_1579A - mov ax, [si+0Ah] + mov ax, [si++enemy_t.pos.velocity.x] mov [bp+var_4], ax - mov ax, [si+0Ch] - mov [si+0Ah], ax + mov ax, [si+enemy_t.pos.velocity.y] + mov [si+enemy_t.pos.velocity.x], ax mov ax, [bp+var_4] - mov [si+0Ch], ax + mov [si+enemy_t.pos.velocity.y], ax loc_1579A: - call sub_1554F + call enemy_pos_update or al, al jnz loc_159A4 - mov al, [si+1Fh] - add [si+1Eh], al + mov al, [si+enemy_t.E_angle_delta] + add [si+enemy_t.E_angle], al mov al, es:[di+4] mov [bp+var_1], al mov [bp+var_2], 5 @@ -16728,53 +16595,53 @@ loc_1579A: loc_157B7: mov al, es:[di+1] - mov [si+1Eh], al + mov [si+enemy_t.E_angle], al mov al, es:[di+2] mov ah, 0 - mov [si+1Ch], ax + mov [si+enemy_t.E_speed], ax call sub_155AA jmp loc_15A9D ; --------------------------------------------------------------------------- loc_157CD: mov al, es:[di+1] - add [si+1Eh], al + add [si+enemy_t.E_angle], al jmp loc_15ACD ; --------------------------------------------------------------------------- loc_157D7: mov al, es:[di+1] cbw - add [si+1Ch], ax + add [si+enemy_t.E_speed], ax jmp loc_15ACD ; --------------------------------------------------------------------------- loc_157E2: call randring2_next16 - mov [si+1Eh], al + mov [si+enemy_t.E_angle], al jmp loc_158BE ; --------------------------------------------------------------------------- loc_157EB: - mov al, [si+2Ch] + mov al, [si+enemy_t.E_bullet_template.spawn_type] mov _bullet_template.spawn_type, al - mov al, [si+2Dh] + mov al, [si+enemy_t.E_bullet_template.patnum] mov _bullet_template.patnum, al - mov ax, [si+2Eh] - add ax, [si+2] + mov ax, [si+enemy_t.E_bullet_template.BT_origin.x] + add ax, [si+enemy_t.pos.cur.x] mov _bullet_template.BT_origin.x, ax - mov ax, [si+30h] - add ax, [si+4] + mov ax, [si+enemy_t.E_bullet_template.BT_origin.y] + add ax, [si+enemy_t.pos.cur.y] mov _bullet_template.BT_origin.y, ax - mov al, [si+36h] + mov al, [si+enemy_t.E_bullet_template.pattern] mov _bullet_template.pattern, al - mov al, [si+37h] + mov al, [si+enemy_t.E_bullet_template.BT_angle] mov _bullet_template.BT_angle, al - mov al, [si+38h] + mov al, [si+enemy_t.E_bullet_template.speed] mov _bullet_template.speed, al - mov al, [si+39h] + mov al, [si+enemy_t.E_bullet_template.count] mov _bullet_template.count, al - mov al, [si+3Ah] + mov al, byte ptr [si+enemy_t.E_bullet_template.BT_delta] mov _bullet_template.BT_delta, al push es call fp_2D004 @@ -16784,63 +16651,63 @@ loc_157EB: ; --------------------------------------------------------------------------- loc_15834: - mov byte ptr [si+29h], 0 + mov [si+enemy_t.E_autofire], 0 mov al, es:[di+1] - mov [si+2Ch], al + mov [si+enemy_t.E_bullet_template.spawn_type], al mov ax, es:[di+2] - mov [si+2Eh], ax + mov [si+enemy_t.E_bullet_template.BT_origin.x], ax mov ax, es:[di+4] - mov [si+30h], ax + mov [si+enemy_t.E_bullet_template.BT_origin.y], ax mov al, es:[di+6] - mov [si+36h], al + mov [si+enemy_t.E_bullet_template.pattern], al mov al, es:[di+7] - mov [si+37h], al + mov [si+enemy_t.E_bullet_template.BT_angle], al mov al, es:[di+8] - mov [si+38h], al + mov [si+enemy_t.E_bullet_template.speed], al mov al, es:[di+9] - mov [si+2Dh], al + mov [si+enemy_t.E_bullet_template.patnum], al mov al, es:[di+0Ah] - mov [si+39h], al + mov [si+enemy_t.E_bullet_template.count], al mov [bp+var_2], 0Bh jmp loc_15B37 ; --------------------------------------------------------------------------- loc_15877: mov al, es:[di+1] - mov [si+2Ch], al + mov [si+enemy_t.E_bullet_template.spawn_type], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_15881: - cmp byte ptr [si+1Ah], 0 + cmp [si+enemy_t.E_cur_instr_frame], 0 jnz short loc_1588F - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax loc_1588F: mov ax, es:[di+1] - mov [si+2Eh], ax + mov [si+enemy_t.E_bullet_template.BT_origin.x], ax mov ax, es:[di+3] - mov [si+30h], ax + mov [si+enemy_t.E_bullet_template.BT_origin.y], ax mov [bp+var_2], 5 jmp loc_15B37 ; --------------------------------------------------------------------------- loc_158A4: mov al, es:[di+1] - mov [si+37h], al + mov [si+enemy_t.E_bullet_template.BT_angle], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158AE: mov al, es:[di+1] - add [si+37h], al + add [si+enemy_t.E_bullet_template.BT_angle], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158B8: call randring2_next16 - mov [si+37h], al + mov [si+enemy_t.E_bullet_template.BT_angle], al loc_158BE: mov [bp+var_2], 1 @@ -16849,31 +16716,31 @@ loc_158BE: loc_158C5: mov al, es:[di+1] - mov [si+2Dh], al + mov [si+enemy_t.E_bullet_template.patnum], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158CF: mov al, es:[di+1] - mov [si+39h], al + mov [si+enemy_t.E_bullet_template.count], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158D9: mov al, es:[di+1] - mov [si+38h], al + mov [si+enemy_t.E_bullet_template.speed], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158E3: mov al, es:[di+1] - add [si+38h], al + add [si+enemy_t.E_bullet_template.speed], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_158ED: mov al, es:[di+1] - mov [si+36h], al + mov [si+enemy_t.E_bullet_template.pattern], al jmp loc_15AE4 ; --------------------------------------------------------------------------- @@ -16923,34 +16790,34 @@ loc_1593A: mov ah, 0 add ax, [bp+var_4] mov [bp+var_4], ax - cmp [bp+var_4], 100h + cmp [bp+var_4], 256 jl short loc_15977 - mov [bp+var_4], 0FFh + mov [bp+var_4], 255 loc_15977: cmp _rank, RANK_EASY jnz short loc_15983 - mov [bp+var_4], 0FFh + mov [bp+var_4], 255 loc_15983: mov al, byte ptr [bp+var_4] - mov [si+3Fh], al + mov [si+enemy_t.E_autofire_interval], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_1598C: - mov byte ptr [si+29h], 1 + mov [si+enemy_t.E_autofire], 1 jmp loc_158BE ; --------------------------------------------------------------------------- loc_15993: - mov byte ptr [si+29h], 0 + mov [si+enemy_t.E_autofire], 0 jmp loc_158BE ; --------------------------------------------------------------------------- loc_1599A: mov al, es:[di+1] - mov [si+3Ah], al + mov byte ptr [si+enemy_t.E_bullet_template.BT_delta], al jmp loc_15AE4 ; --------------------------------------------------------------------------- @@ -16963,35 +16830,35 @@ loc_159A4: loc_159AC: mov byte ptr [si], 1 mov al, es:[di+1] - mov [si+0Eh], al + mov [si+enemy_t.E_patnum_base], al mov ax, es:[di+2] - mov [si+10h], ax + mov [si+enemy_t.E_hp], ax mov ax, es:[di+4] - mov [si+14h], ax - mov byte ptr [si+28h], 1 - mov byte ptr [si+2Ah], 1 + mov [si+enemy_t.E_score], ax + mov [si+enemy_t.E_can_be_damaged], 1 + mov [si+enemy_t.E_kills_player_on_collision], 1 mov [bp+var_2], 6 jmp loc_15B37 ; --------------------------------------------------------------------------- loc_159D3: - mov byte ptr [si+20h], 1 + mov [si+enemy_t.E_clip_x], 1 jmp loc_158BE ; --------------------------------------------------------------------------- loc_159DA: - mov byte ptr [si+20h], 1 + mov [si+enemy_t.E_clip_x], 1 loc_159DE: - mov byte ptr [si+21h], 1 + mov [si+enemy_t.E_clip_y], 1 jmp loc_158BE ; --------------------------------------------------------------------------- loc_159E5: mov al, es:[di+1] - mov [si+25h], al + mov [si+enemy_t.E_anim_cels], al mov al, es:[di+2] - mov [si+26h], al + mov [si+enemy_t.E_anim_frames_per_cel], al jmp loc_15A9D ; --------------------------------------------------------------------------- @@ -17004,19 +16871,19 @@ loc_159F6: loc_15A05: mov al, es:[di+1] - mov [si+0Eh], al + mov [si+enemy_t.E_patnum_base], al jmp loc_15AE4 ; --------------------------------------------------------------------------- loc_15A0F: - mov byte ptr [si+28h], 0 + mov [si+enemy_t.E_can_be_damaged], 0 mov [bp+var_2], 1 - mov byte ptr [si+29h], 0 + mov [si+enemy_t.E_autofire], 0 jmp loc_15B37 ; --------------------------------------------------------------------------- loc_15A1E: - mov byte ptr [si+28h], 1 + mov [si+enemy_t.E_can_be_damaged], 1 mov [bp+var_2], 1 cmp _rank, RANK_LUNATIC jnz short loc_15A32 @@ -17028,37 +16895,37 @@ loc_15A32: xor ax, ax loc_15A34: - mov [si+29h], al + mov [si+enemy_t.E_autofire], al jmp loc_15B37 ; --------------------------------------------------------------------------- loc_15A3A: - mov byte ptr [si+2Ah], 0 + mov [si+enemy_t.E_kills_player_on_collision], 0 jmp loc_158BE ; --------------------------------------------------------------------------- loc_15A41: - mov byte ptr [si+2Ah], 1 + mov [si+enemy_t.E_kills_player_on_collision], 1 jmp loc_158BE ; --------------------------------------------------------------------------- loc_15A48: - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax mov ax, es:[di+1] - mov [si+2], ax + mov [si+enemy_t.cur.pos.x], ax mov ax, es:[di+3] - mov [si+4], ax + mov [si+enemy_t.pos.cur.y], ax jmp short loc_15A76 ; --------------------------------------------------------------------------- loc_15A60: - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax mov ax, es:[di+1] - add [si+2], ax + add [si+enemy_t.cur.pos.x], ax mov ax, es:[di+3] - add [si+4], ax + add [si+enemy_t.pos.cur.y], ax loc_15A76: mov [bp+var_2], 5 @@ -17068,19 +16935,19 @@ loc_15A76: loc_15A81: mov al, es:[di+1] - add [si+0Eh], al + add [si+enemy_t.E_patnum_base], al jmp short loc_15AE4 ; --------------------------------------------------------------------------- loc_15A8A: mov al, es:[di+1] - mov [si+1Eh], al + mov [si+enemy_t.E_angle], al mov al, es:[di+2] - mov ah, 0 ; jumptable 0001C46F case 60 - mov [si+1Ch], ax + mov ah, 0 + mov [si+enemy_t.E_speed], ax loc_15A9A: - call sub_15592 + call enemy_velocity_set loc_15A9D: mov [bp+var_2], 3 @@ -17089,31 +16956,31 @@ loc_15A9D: loc_15AA4: mov al, es:[di+1] - mov [si+1Eh], al + mov [si+enemy_t.E_angle], al mov al, es:[di+2] mov ah, 0 - mov [si+1Ch], ax - cmp byte ptr [si+2Bh], 0 + mov [si+enemy_t.E_speed], ax + cmp [si+enemy_t.E_spawned_in_left_half], 0 jnz short loc_15A9A mov al, 80h - sub al, [si+1Eh] - mov [si+1Eh], al + sub al, [si+enemy_t.E_angle] + mov [si+enemy_t.E_angle], al jmp short loc_15A9A ; --------------------------------------------------------------------------- loc_15AC4: mov al, es:[di+1] mov ah, 0 - mov [si+1Ch], ax + mov [si+enemy_t.E_speed], ax loc_15ACD: - call sub_15592 + call enemy_velocity_set jmp short loc_15AE4 ; --------------------------------------------------------------------------- loc_15AD2: - push word ptr [si+2] - push word ptr [si+4] + push [si+enemy_t.cur.pos.x] + push [si+enemy_t.cur.pos.y] mov al, es:[di+1] mov ah, 0 push ax @@ -17125,43 +16992,43 @@ loc_15AE4: ; --------------------------------------------------------------------------- loc_15AEA: - mov al, [si+1Bh] + mov al, [si+enemy_t.E_loop_i] cmp al, es:[di+2] jb short loc_15AF9 - mov byte ptr [si+1Bh], 0 + mov [si+enemy_t.E_loop_i], 0 jmp short loc_15A9D ; --------------------------------------------------------------------------- loc_15AF9: - inc byte ptr [si+1Bh] + inc [si+enemy_t.E_loop_i] cmp byte ptr es:[di], 80h jnz short loc_15B0E mov al, es:[di+1] mov ah, 0 - mov [si+18h], ax + mov [si+enemy_t.E_script_ip], ax jmp loc_155EB ; --------------------------------------------------------------------------- loc_15B0E: mov al, es:[di+1] mov ah, 0 - sub [si+18h], ax + sub [si+enemy_t.E_script_ip], ax jmp loc_155EB ; --------------------------------------------------------------------------- loc_15B1A: - mov al, [si+1Ah] + mov al, [si+enemy_t.E_cur_instr_frame] cmp al, [bp+var_1] jb short loc_15B30 - mov byte ptr [si+1Ah], 0 + mov [si+enemy_t.E_cur_instr_frame], 0 mov al, [bp+var_2] mov ah, 0 - add [si+18h], ax + add [si+enemy_t.E_script_ip], ax jmp short loc_15B33 ; --------------------------------------------------------------------------- loc_15B30: - inc byte ptr [si+1Ah] + inc [si+enemy_t.E_cur_instr_frame] loc_15B33: mov al, 0 @@ -17171,7 +17038,7 @@ loc_15B33: loc_15B37: mov al, [bp+var_2] mov ah, 0 - add [si+18h], ax + add [si+enemy_t.E_script_ip], ax mov al, [bp+var_2] mov ah, 0 add di, ax @@ -20899,58 +20766,54 @@ off_17CEB dw offset loc_17A1F ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public ENEMIES_ADD +enemies_add proc near -sub_17CF3 proc near - -var_2 = word ptr -2 +@@i = word ptr -2 arg_0 = byte ptr 4 -arg_2 = word ptr 6 -arg_4 = word ptr 8 +@@center_y = word ptr 6 +@@center_x = word ptr 8 arg_6 = word ptr 0Ah enter 2, 0 push si push di - mov di, [bp+arg_4] - mov si, 8A92h - mov [bp+var_2], 0 - jmp loc_17DC3 + mov di, [bp+@@center_x] + mov si, offset _enemies + mov [bp+@@i], 0 + jmp @@more? ; --------------------------------------------------------------------------- -loc_17D07: - cmp byte ptr [si], 0 - jnz loc_17DBD - -loc_17D0E: - mov byte ptr [si], 3 ; jumptable 0001CCD9 case 30465 - mov byte ptr [si+1Ah], 0 - mov byte ptr [si+1Bh], 0 - mov byte ptr [si+1], 0 - mov word ptr [si+18h], 0 +@@loop: + cmp [si+enemy_t.flag], EF_FREE + jnz @@next + mov [si+enemy_t.flag], EF_ALIVE_FIRST_FRAME + mov [si+enemy_t.E_cur_instr_frame], 0 + mov [si+enemy_t.E_loop_i], 0 + mov [si+enemy_t.age], 0 + mov [si+enemy_t.E_script_ip], 0 mov bx, [bp+arg_6] add bx, bx mov ax, _enemy_script_ptrs[bx] - mov [si+16h], ax - cmp di, 3E70h + mov [si+enemy_t.E_script], ax + cmp di, ENEMY_POS_RANDOM jnz short loc_17D3C - push 1800h - call randring2_next16_mod + call randring2_next16_mod pascal, (PLAYFIELD_W shl 4) mov di, ax loc_17D3C: - cmp [bp+arg_2], 3E70h + cmp [bp+@@center_y], ENEMY_POS_RANDOM jnz short loc_17D4C - push 1700h - call randring2_next16_mod - mov [bp+arg_2], ax + call randring2_next16_mod pascal, ((PLAYFIELD_H) shl 4) + mov [bp+@@center_y], ax loc_17D4C: - mov [si+2], di - mov ax, [bp+arg_2] - mov [si+4], ax + mov [si+enemy_t.pos.cur.x], di + mov ax, [bp+@@center_y] + mov [si+enemy_t.pos.cur.y], ax mov al, [bp+arg_0] - mov [si+23h], al - mov byte ptr [si+24h], 0 + mov [si+enemy_t.E_item], al + mov [si+enemy_t.E_damaged_this_frame], 0 cmp _rank, RANK_LUNATIC jnz short loc_17D6B mov ax, 1 @@ -20961,52 +20824,50 @@ loc_17D6B: xor ax, ax loc_17D6D: - mov [si+29h], al - mov byte ptr [si+20h], 0 - mov byte ptr [si+21h], 0 - mov byte ptr [si+25h], 1 - mov byte ptr [si+26h], 4 - mov byte ptr [si+27h], 0 - mov byte ptr [si+28h], 0 - mov byte ptr [si+2Ah], 0 - cmp di, 0C00h - jge short loc_17D96 + mov [si+enemy_t.E_autofire], al + mov [si+enemy_t.E_clip_x], 0 + mov [si+enemy_t.E_clip_y], 0 + mov [si+enemy_t.E_anim_cels], 1 + mov [si+enemy_t.E_anim_frames_per_cel], 4 + mov [si+enemy_t.E_anim_cur_cel], 0 + mov [si+enemy_t.E_can_be_damaged], 0 + mov [si+enemy_t.E_kills_player_on_collision], 0 + cmp di, ((PLAYFIELD_W / 2) shl 4) + jge short @@spawned_in_right_half mov al, 1 jmp short loc_17D98 ; --------------------------------------------------------------------------- -loc_17D96: +@@spawned_in_right_half: mov al, 0 loc_17D98: - mov [si+2Bh], al + mov [si+enemy_t.E_spawned_in_left_half], al call randring2_next16 - mov [si+3Eh], al - mov byte ptr [si+3Fh], 80h - mov byte ptr [si+36h], 41h ; 'A' - mov byte ptr [si+2Ch], 1 - mov byte ptr [si+38h], 2Ah ; '*' - mov word ptr [si+2Eh], 0 - mov word ptr [si+30h], 0 - jmp short loc_17DCB + mov [si+enemy_t.E_autofire_cur_frame], al + mov [si+enemy_t.E_autofire_interval], 128 + mov [si+enemy_t.E_bullet_template.pattern], BP_FORCESINGLE_AIMED + mov [si+enemy_t.E_bullet_template.spawn_type], BST_PELLET + mov [si+enemy_t.E_bullet_template.speed], (2 shl 4) + 10 + mov [si+enemy_t.E_bullet_template.BT_origin.x], 0 + mov [si+enemy_t.E_bullet_template.BT_origin.y], 0 + jmp short @@ret ; --------------------------------------------------------------------------- -loc_17DBD: - inc [bp+var_2] - add si, 40h +@@next: + inc [bp+@@i] + add si, size enemy_t -loc_17DC3: - cmp [bp+var_2], 20h ; ' ' +@@more?: + cmp [bp+@@i], ENEMY_COUNT + jl @@loop -loc_17DC7: - jl loc_17D07 - -loc_17DCB: +@@ret: pop di pop si leave retn 8 -sub_17CF3 endp +enemies_add endp ; =============== S U B R O U T I N E ======================================= @@ -21041,7 +20902,7 @@ loc_17DF5: mov al, es:[bx+5] mov ah, 0 push ax - call sub_17CF3 + call enemies_add loc_17E18: add word ptr _std_ip, 8 @@ -21062,18 +20923,18 @@ std_run endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public ENEMY_BULLET_TEMPLATE_PUSH +enemy_bullet_template_push proc near -sub_17E3E proc near - -arg_0 = word ptr 4 +@@enemy = word ptr 4 push bp mov bp, sp push si push di mov cx, size _bullet_template / 2 - mov si, [bp+arg_0] - add si, 2Ch ; ',' + mov si, [bp+@@enemy] + add si, offset enemy_t.E_bullet_template mov di, offset _bullet_template push ds pop es @@ -21083,14 +20944,14 @@ arg_0 = word ptr 4 pop si pop bp retn 2 -sub_17E3E endp +enemy_bullet_template_push endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame - -sub_17E59 proc far +public ENEMIES_UPDATE +enemies_update proc far var_1 = byte ptr -1 @@ -21101,178 +20962,176 @@ var_1 = byte ptr -1 mov _homing_target.y, HOMING_TARGET_NONE mov word_257E2, 100h mov word_257E4, 0C0h - mov si, 8A92h + mov si, offset _enemies xor di, di - jmp loc_18024 + jmp @@more? ; --------------------------------------------------------------------------- -loc_17E7F: - cmp byte ptr [si], 0 - jz loc_18020 - cmp byte ptr [si], 2 - jnz short loc_17E91 - mov byte ptr [si], 0 - jmp loc_18020 +@@loop: + cmp [si+enemy_t.flag], EF_FREE + jz @@next + cmp [si+enemy_t.flag], EF_KILLED + jnz short @@alive + mov [si+enemy_t.flag], EF_FREE + jmp @@next ; --------------------------------------------------------------------------- -loc_17E91: - mov word_2598A, si - cmp byte ptr [si], 80h +@@alive: + mov _enemy_cur, si + cmp [si+enemy_t.flag], EF_KILL_ANIM jnb loc_17FF4 call sub_155DD - cmp byte ptr [si+2Ah], 0 + cmp [si+enemy_t.E_kills_player_on_collision], 0 jz short loc_17ECA - mov ax, [si+2] + mov ax, [si+enemy_t.pos.cur.x] sub ax, _player_pos.cur.x - add ax, 0C0h - cmp ax, 180h + add ax, (12 shl 4) + cmp ax, (24 shl 4) jnb short loc_17ECA - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] sub ax, _player_pos.cur.y - add ax, 0C0h - cmp ax, 180h + add ax, (12 shl 4) + cmp ax, (24 shl 4) jnb short loc_17ECA mov byte_259A9, 1 jmp short loc_17F3C ; --------------------------------------------------------------------------- loc_17ECA: - cmp byte ptr [si+28h], 0 - jz loc_17F9B - cmp word ptr [si+10h], 0FFFFh - jz loc_17F9B - mov ax, [si+2] - add ax, 100h - cmp ax, 1A00h - jnb loc_17F9B - mov ax, [si+4] - add ax, 100h - cmp ax, 1800h - jnb loc_17F9B - mov ax, [si+4] + cmp [si+enemy_t.E_can_be_damaged], 0 + jz @@autofire? + cmp [si+enemy_t.E_hp], -1 + jz @@autofire? + mov ax, [si+enemy_t.pos.cur.x] + add ax, ((ENEMY_W / 2) shl 4) + cmp ax, (PLAYFIELD_RIGHT shl 4) + jnb @@autofire? + mov ax, [si+enemy_t.pos.cur.y] + add ax, ((ENEMY_H / 2) shl 4) + cmp ax, (PLAYFIELD_BOTTOM shl 4) + jnb @@autofire? + mov ax, [si+enemy_t.pos.cur.y] cmp ax, _homing_target.y jle short loc_17F0F cmp ax, _player_pos.cur.y jg short loc_17F0F - mov ax, [si+2] + mov ax, [si+enemy_t.pos.cur.x] mov _homing_target.x, ax - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] mov _homing_target.y, ax loc_17F0F: - mov eax, [si+2] + mov eax, dword ptr [si+enemy_t.pos.cur] mov dword_257DE, eax call sub_105B9 mov [bp+var_1], al cmp [bp+var_1], 0 - jz short loc_17F9B - cmp word ptr [si+10h], 0FFFEh + jz short @@autofire? + cmp [si+enemy_t.E_hp], -2 jz short loc_17F94 mov ah, 0 - cmp ax, [si+10h] + cmp ax, [si+enemy_t.E_hp] jge short loc_17F3C mov al, [bp+var_1] mov ah, 0 - sub [si+10h], ax + sub [si+enemy_t.E_hp], ax jmp short loc_17F8E ; --------------------------------------------------------------------------- loc_17F3C: - mov byte ptr [si], 80h - mov byte ptr [si+25h], 1 - mov byte ptr [si+28h], 0 - mov byte ptr [si+2Ah], 0 - mov word ptr [si+0Ah], 0 - mov word ptr [si+0Ch], 0 - call items_add pascal, word ptr [si+2], word ptr [si+4], word ptr [si+23h] + mov [si+enemy_t.flag], EF_KILL_ANIM + mov [si+enemy_t.E_anim_cels], 1 + mov [si+enemy_t.E_can_be_damaged], 0 + mov [si+enemy_t.E_kills_player_on_collision], 0 + mov [si+enemy_t.pos.velocity.x], 0 + mov [si+enemy_t.pos.velocity.y], 0 + call items_add pascal, [si+enemy_t.pos.cur.x], [si+enemy_t.pos.cur.y], word ptr [si+enemy_t.E_item] call snd_se_play pascal, 3 - movzx eax, word ptr [si+14h] + movzx eax, [si+enemy_t.E_score] add _score_delta, eax - push word ptr [si+2] - push word ptr [si+4] + push [si+enemy_t.pos.cur.x] + push [si+enemy_t.pos.cur.y] push large (((4 shl 4) shl 16) or 8) nopcall sparks_add_random inc _enemies_gone inc _enemies_killed - jmp loc_18020 + jmp @@next ; --------------------------------------------------------------------------- loc_17F8E: - mov byte ptr [si+24h], 1 - jmp short loc_17F9B + mov [si+enemy_t.E_damaged_this_frame], 1 + jmp short @@autofire? ; --------------------------------------------------------------------------- loc_17F94: call snd_se_play pascal, 10 -loc_17F9B: - cmp byte ptr [si+29h], 0 - jz short loc_17FEF - inc byte ptr [si+3Eh] - mov al, [si+3Eh] - cmp al, [si+3Fh] - jb short loc_17FEF - cmp word ptr [si+4], 1300h - jge short loc_17FEF - mov ax, [si+2] +@@autofire?: + cmp [si+enemy_t.E_autofire], 0 + jz short @@no_autofire + inc [si+enemy_t.E_autofire_cur_frame] + mov al, [si+enemy_t.E_autofire_cur_frame] + cmp al, [si+enemy_t.E_autofire_interval] + jb short @@no_autofire + cmp [si+enemy_t.pos.cur.y], (304 shl 4) + jge short @@no_autofire + mov ax, [si+enemy_t.pos.cur.x] sub ax, _player_pos.cur.x - add ax, 300h - cmp ax, 600h - jnb short loc_17FD1 - mov ax, [si+4] + add ax, (48 shl 4) + cmp ax, (96 shl 4) + jnb short @@fire + mov ax, [si+enemy_t.pos.cur.y] sub ax, _player_pos.cur.y - add ax, 300h - cmp ax, 600h - jb short loc_17FEF + add ax, (48 shl 4) + cmp ax, (96 shl 4) + jb short @@no_autofire -loc_17FD1: - mov byte ptr [si+3Eh], 0 - push si - call sub_17E3E - mov ax, [si+2] +@@fire: + mov [si+enemy_t.E_autofire_cur_frame], 0 + call enemy_bullet_template_push pascal, si + mov ax, [si+enemy_t.pos.cur.x] add _bullet_template.BT_origin.x, ax - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] add _bullet_template.BT_origin.y, ax call fp_2D004 call fp_2D000 -loc_17FEF: - inc byte ptr [si+1] - jmp short loc_18020 +@@no_autofire: + inc [si+enemy_t.age] + jmp short @@next ; --------------------------------------------------------------------------- loc_17FF4: - lea ax, [si+2] - push ax - call _motion_update_2 - mov al, [si] + lea ax, [si+enemy_t.pos] + call _motion_update_2 pascal, ax + mov al, [si+enemy_t.flag] inc al - mov [si], al + mov [si+enemy_t.flag], al mov [bp+var_1], al mov ah, 0 - add ax, 0FF80h + add ax, -EF_KILL_ANIM mov bx, 4 cwd idiv bx - add al, 4 + add al, PAT_ENEMY_KILL mov [bp+var_1], al - mov [si+0Eh], al - cmp [bp+var_1], 0Ch - jb short loc_18020 - mov byte ptr [si], 2 + mov [si+enemy_t.E_patnum_base], al + cmp [bp+var_1], (PAT_ENEMY_KILL + ENEMY_KILL_CELS) + jb short @@next + mov [si+enemy_t.flag], EF_KILLED -loc_18020: +@@next: inc di - add si, 40h + add si, size enemy_t -loc_18024: - cmp di, 20h ; ' ' - jl loc_17E7F +@@more?: + cmp di, ENEMY_COUNT + jl @@loop pop di pop si leave retf -sub_17E59 endp +enemies_update endp ; =============== S U B R O U T I N E ======================================= @@ -36966,9 +36825,9 @@ include th04/main/player/shots_alive[bss].asm byte_25980 db ? db ? include th04/main/homing_target[bss].asm -public _stage_vm +public _stage_vm, _enemy_cur _stage_vm dd ? -word_2598A dw ? +_enemy_cur dw ? word_2598C dw ? include th04/main/player/pos[bss].asm word_2599A dw ? @@ -37055,13 +36914,17 @@ include th04/main/ems[bss].asm _turbo_mode db ? db ? include th04/main/bullet/template[bss].asm + +; Needs to be here because it contains a bullet_template_t, which is only +; declared in template[bss].asm. Moving it before that declaration results in +; an illegal forward reference. +include th04/main/enemy/enemy.inc + include th04/main/midboss/vars[bss].asm include th04/main/boss/vars[bss].asm include th04/main/sparks[bss].asm include th04/main/bullet/bullets[bss].asm - db 924 dup(?) -byte_2A16E db ? - db 1123 dup(?) +include th04/main/enemy/enemies[bss].asm include th04/main/gather[bss].asm include th04/main/circles[bss].asm include th04/main/pointnum/pointnum[bss].asm diff --git a/th05/main/enemy/enemy.hpp b/th05/main/enemy/enemy.hpp new file mode 100644 index 00000000..33caf05c --- /dev/null +++ b/th05/main/enemy/enemy.hpp @@ -0,0 +1,47 @@ +#define ENEMY_CLIP_NONE 0x00 +#define ENEMY_CLIP_X 0x01 +#define ENEMY_CLIP_Y 0x10 + +// See TH04's version for documentation on the fields that originated in that +// game. +struct enemy_t { + unsigned char flag; + unsigned char age; + motion_t pos; + int hp; + int score; + unsigned char near *script; + int script_ip; + SubpixelLength8 speed; + unsigned char patnum_base; + unsigned char cur_instr_frame; + unsigned char loop_i; + unsigned char angle; + unsigned char angle_delta; + unsigned char anim_cels; + unsigned char anim_frames_per_cel; + unsigned char anim_cur_cel; // still technically unnecessary + + char clip; + + item_type_t item; + bool damaged_this_frame; + bool can_be_damaged; + bool autofire; + bool kills_player_on_collision; + bool spawned_in_left_half; + unsigned char autofire_cur_frame; + unsigned char autofire_interval; + bullet_template_t bullet_template; + + // Custom type ID, set in the spawn parameters. Can be used to parametrize + // scripts via conditional jumps based on this value. + unsigned char subtype; + + int8_t unused_1; + int16_t unused_2; + int8_t unused_3; + int8_t padding[5]; +}; + +#include "th04/main/enemy/enemy.hpp" diff --git a/th05/main/enemy/enemy.inc b/th05/main/enemy/enemy.inc new file mode 100644 index 00000000..f41cbfa1 --- /dev/null +++ b/th05/main/enemy/enemy.inc @@ -0,0 +1,33 @@ +ENEMY_CLIP_X = 01h +ENEMY_CLIP_Y = 10h + +enemy_t struc + flag db ? + age db ? + pos motion_t + E_hp dw ? + E_score dw ? + E_script dw ? + E_script_ip dw ? + E_speed db ? + E_patnum_base db ? + E_cur_instr_frame db ? + E_loop_i db ? + E_angle db ? + E_angle_delta db ? + E_anim_cels db ? + E_anim_frames_per_cel db ? + E_anim_cur_cel db ? + E_clip db ? + E_item db ? + E_damaged_this_frame db ? + E_can_be_damaged db ? + E_autofire db ? + E_kills_player_on_collision db ? + E_spawned_in_left_half db ? + E_autofire_cur_frame db ? + E_autofire_interval db ? + E_bullet_template bullet_template_t + E_subtype db ? + db 9 dup(?) +enemy_t ends diff --git a/th05/sprites/main_pat.h b/th05/sprites/main_pat.h index 212ff499..370de775 100644 --- a/th05/sprites/main_pat.h +++ b/th05/sprites/main_pat.h @@ -10,7 +10,9 @@ typedef enum { // miko32.bft // ---------- - PAT_CLOUD_BULLET16_BLUE = 12, + PAT_ENEMY_KILL = 4, + PAT_ENEMY_KILL_last = (PAT_ENEMY_KILL + ENEMY_KILL_CELS - 1), + PAT_CLOUD_BULLET16_BLUE, PAT_CLOUD_BULLET16_BLUE_last = (PAT_CLOUD_BULLET16_BLUE + BULLET_CLOUD_CELS - 1), PAT_CLOUD_BULLET16_RED, // ---------- diff --git a/th05/sprites/main_pat.inc b/th05/sprites/main_pat.inc index e555c1b5..ac96e452 100644 --- a/th05/sprites/main_pat.inc +++ b/th05/sprites/main_pat.inc @@ -3,6 +3,7 @@ include th04/sprites/cels.inc PARTICLE_CELS = 4 B4BALL_CELS = 4 +PAT_ENEMY_KILL = 4 PAT_CLOUD_BULLET16_BLUE = 12 PAT_CLOUD_BULLET16_RED = 16 PAT_SHOT_SUB = 22 diff --git a/th05_main.asm b/th05_main.asm index ff249943..722b081b 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -422,7 +422,7 @@ loc_AEF0: call sub_1240B call lasers_update call sub_17C04 - call sub_1607D + call enemies_update call _midboss_update call _boss_update call items_update @@ -435,7 +435,7 @@ loc_AEF0: loc_AF2D: call _boss_fg_render call _midboss_render - call sub_EBB7 + call enemies_render call shots_render call player_render call grcg_setmode_rmw_1 @@ -1875,7 +1875,7 @@ sub_BEE6 proc near call sub_11A65 call player_invalidate call sub_123AD - call sub_E41C + call enemies_invalidate call bullets_gather_invalidate call items_invalidate call sparks_invalidate @@ -5385,35 +5385,7 @@ playfield_fillm_0_0_384_192__2 endp include th04/formats/z_super_roll_put_tiny.asm include th04/main/tiles_invalidate.asm include th05/formats/super_roll_put_16x16_m.asm - -; =============== S U B R O U T I N E ======================================= - - -sub_E41C proc near - push si - push di - mov _tile_invalidate_box, (32 shl 16) or 32 - mov si, 9296h - mov di, 20h ; ' ' - -loc_E42D: - cmp byte ptr [si], 0 - jz short loc_E43E - cmp byte ptr [si], 3 - jz short loc_E43E - call tiles_invalidate_around pascal, large dword ptr [si+6] - -loc_E43E: - add si, 40h - dec di - jnz short loc_E42D - pop di - pop si - retn -sub_E41C endp - -; --------------------------------------------------------------------------- - nop +include th04/main/enemy/inv.asm ; =============== S U B R O U T I N E ======================================= @@ -5888,8 +5860,8 @@ sub_EACE proc near push offset _shots push size _shots / 4 call sub_E708 - push 9296h - push 200h + push offset _enemies + push size _enemies / 4 call sub_E708 push offset _sparks push size _sparks / 4 @@ -5922,109 +5894,7 @@ sub_EACE proc near retn sub_EACE endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_EBB7 proc near - -@@patnum = byte ptr -5 -var_4 = word ptr -4 -var_2 = word ptr -2 - - enter 6, 0 - push si - push di - mov si, 9296h - mov [bp+var_2], 0 - jmp loc_EC7A -; --------------------------------------------------------------------------- - -loc_EBC8: - cmp byte ptr [si], 1 - jz short loc_EBD4 - cmp byte ptr [si], 80h - jb loc_EC74 - -loc_EBD4: - cmp word ptr [si+8], 0FF00h - jle loc_EC74 - cmp word ptr [si+8], 1800h - jge loc_EC74 - mov al, [si+17h] - mov [bp+@@patnum], al - cmp byte ptr [si+1Ch], 1 - jbe short loc_EC1A - mov al, [si+1] - mov ah, 0 - mov dl, [si+1Dh] - mov dh, 0 - push dx - cwd - pop bx - idiv bx - or dx, dx - jnz short loc_EC14 - inc byte ptr [si+1Eh] - mov al, [si+1Eh] - cmp al, [si+1Ch] - jb short loc_EC14 - mov byte ptr [si+1Eh], 0 - -loc_EC14: - mov al, [si+1Eh] - add [bp+@@patnum], al - -loc_EC1A: - mov ax, [si+2] - sar ax, 4 - add ax, 10h - mov di, ax - call scroll_subpixel_y_to_vram_seg1 pascal, word ptr [si+4] - mov [bp+var_4], ax - or di, di - jle short loc_EC74 - cmp di, 1A0h - jge short loc_EC74 - cmp word ptr [si+4], 0FF00h - jle short loc_EC74 - cmp word ptr [si+4], 1800h - jge short loc_EC74 - cmp byte ptr [si+21h], 0 - jnz short loc_EC5B - push di - push ax - mov al, [bp+@@patnum] - mov ah, 0 - push ax - call super_roll_put - jmp short loc_EC74 -; --------------------------------------------------------------------------- - -loc_EC5B: - push di - push [bp+var_4] - mov al, [bp+@@patnum] - mov ah, 0 - push ax - pushd PLANE_PUT or GC_BRGI - call super_roll_put_1plane - mov byte ptr [si+21h], 0 - -loc_EC74: - inc [bp+var_2] - add si, 40h - -loc_EC7A: - cmp [bp+var_2], 20h ; ' ' - jl loc_EBC8 - pop di - pop si - leave - retn -sub_EBB7 endp - +include th04/main/enemy/render.asm include th04/main/circles.asm ; =============== S U B R O U T I N E ======================================= @@ -11834,48 +11704,51 @@ MOTION_UPDATE_DEF 2 ; =============== S U B R O U T I N E ======================================= - -sub_152F2 proc near - lea ax, [si+2] +public ENEMY_POS_UPDATE +enemy_pos_update proc near + lea ax, [si+enemy_t.pos] call _motion_update_2 pascal, ax - test byte ptr [si+1Fh], 1 - jz short loc_15307 - add ax, (16 shl 4) - cmp ax, (416 shl 4) - jnb short loc_15319 + test [si+enemy_t.E_clip], ENEMY_CLIP_X + jz short @@clip_y? -loc_15307: - test byte ptr [si+1Fh], 10h - jz short loc_15317 - add dx, (16 shl 4) - cmp dx, (400 shl 4) - jnb short loc_15319 + ; Note that these comparisons abuse underflow to implicitly handle the + ; negative direction as well. + add ax, ((ENEMY_W / 2) shl 4) + cmp ax, ((PLAYFIELD_W + ENEMY_W) shl 4) + jnb short @@clip -loc_15317: +@@clip_y?: + test [si+enemy_t.E_clip], ENEMY_CLIP_Y + jz short @@on_playfield + add dx, ((ENEMY_H / 2) shl 4) + cmp dx, ((PLAYFIELD_H + ENEMY_H) shl 4) + jnb short @@clip + +@@on_playfield: clc retn ; --------------------------------------------------------------------------- -loc_15319: +@@clip: inc _enemies_gone stc retn -sub_152F2 endp +enemy_pos_update endp ; =============== S U B R O U T I N E ======================================= - -sub_1531F proc near - lea ax, [si+0Ah] +public ENEMY_VELOCITY_SET +enemy_velocity_set proc near + lea ax, [si+enemy_t.pos.velocity.x] push ax - push word ptr [si+1Ah] + push word ptr [si+enemy_t.E_angle] xor ah, ah - mov al, [si+16h] + mov al, [si+enemy_t.E_speed] push ax call vector2_near retn -sub_1531F endp +enemy_velocity_set endp ; =============== S U B R O U T I N E ======================================= @@ -11883,10 +11756,10 @@ sub_1531F endp sub_15330 proc near push es - call player_angle_from pascal, word ptr [si+2], word ptr [si+4], word ptr [si+1Ah] - mov [si+1Ah], al + call player_angle_from pascal, [si+enemy_t.pos.cur.x], [si+enemy_t.pos.cur.y], word ptr [si+enemy_t.E_angle] + mov [si+enemy_t.E_angle], al pop es - call sub_1531F + call enemy_velocity_set retn sub_15330 endp @@ -11921,17 +11794,17 @@ sub_15345 endp sub_1535A proc near push si push di - mov si, word_2C92A + mov si, _enemy_cur mov es, _std_seg loc_15364: - mov di, [si+12h] - add di, [si+14h] + mov di, [si+enemy_t.E_script] + add di, [si+enemy_t.E_script_ip] mov bl, es:[di] mov bh, 0 cmp bx, 3Ah ; ':' ja loc_1575C - mov cl, [si+18h] + mov cl, [si+enemy_t.E_cur_instr_frame] mov al, 1 mov ah, es:[di+1] xor dx, dx @@ -11948,12 +11821,12 @@ loc_15390: or cl, cl jnz short loc_153A1 mov ax, es:[di+1] - mov [si+16h], ah - mov [si+1Ah], al - call sub_1531F + mov [si+enemy_t.E_speed], ah + mov [si+enemy_t.E_angle], al + call enemy_velocity_set loc_153A1: - call sub_152F2 + call enemy_pos_update jb short loc_15388 mov ah, es:[di+3] mov al, 4 @@ -11963,10 +11836,10 @@ loc_153A1: loc_153AF: or cl, cl jnz short loc_153B6 - call sub_1531F + call enemy_velocity_set loc_153B6: - call sub_152F2 + call enemy_pos_update jb short loc_15388 mov ah, es:[di+1] mov al, 2 @@ -11977,11 +11850,11 @@ loc_153C4: or cl, cl jnz short loc_153D2 mov al, es:[di+1] - mov [si+16h], al - call sub_1531F + mov [si+enemy_t.E_speed], al + call enemy_velocity_set loc_153D2: - call sub_152F2 + call enemy_pos_update jb short loc_15388 mov ah, es:[di+2] mov al, 3 @@ -11995,23 +11868,23 @@ loc_153E2: or cl, cl jnz short loc_153F7 mov ax, es:[di+1] - mov [si+16h], ah - mov [si+1Ah], al + mov [si+enemy_t.E_speed], ah + mov [si+enemy_t.E_angle], al mov al, es:[di+3] - mov [si+1Bh], al + mov [si+enemy_t.E_angle_delta], al loc_153F7: push dx - call sub_1531F + call enemy_velocity_set pop dx or dl, dl jz short loc_15418 mov al, es:[di+4] cbw - add [si+0Ah], ax + add [si+enemy_t.pos.velocity.x], ax mov al, es:[di+5] cbw - add [si+0Ch], ax + add [si+enemy_t.pos.velocity.y], ax mov ah, es:[di+6] mov al, 7 jmp short loc_1541E @@ -12029,15 +11902,15 @@ loc_15420: inc dl loc_15422: - call sub_1531F + call enemy_velocity_set or dl, dl jz short loc_15441 mov al, es:[di+1] cbw - add [si+0Ah], ax + add [si+enemy_t.pos.velocity.x], ax mov al, es:[di+2] cbw - add [si+0Ch], ax + add [si+enemy_t.pos.velocity.y], ax mov ah, es:[di+3] mov al, 4 jmp short loc_15447 @@ -12049,31 +11922,31 @@ loc_15441: loc_15447: push ax - call sub_152F2 + call enemy_pos_update pop ax jb loc_15388 - mov dl, [si+1Bh] - add [si+1Ah], dl + mov dl, [si+enemy_t.E_angle_delta] + add [si+enemy_t.E_angle], dl jmp loc_15748 ; --------------------------------------------------------------------------- loc_15459: or cl, cl jnz short loc_1547D - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax jmp short loc_1547D ; --------------------------------------------------------------------------- loc_15467: or cl, cl jnz short loc_15470 - mov word ptr [si+0Ah], 0 + mov [si+enemy_t.pos.velocity.x], 0 loc_15470: mov ax, _scroll_last_delta - mov [si+0Ch], ax - call sub_152F2 + mov [si+enemy_t.pos.velocity.y], ax + call enemy_pos_update jb loc_15388 loc_1547D: @@ -12088,35 +11961,35 @@ loc_15486: loc_15488: or cl, cl jnz short loc_15497 - mov byte ptr [si+1Ah], 0 + mov [si+enemy_t.E_angle], 0 mov al, es:[di+2] - mov [si+1Bh], al + mov [si+enemy_t.E_angle_delta], al loc_15497: mov cl, dl movzx eax, byte ptr es:[di+1] - mov bl, [si+1Ah] + mov bl, [si+enemy_t.E_angle] mov bh, 0 add bx, bx movsx edx, _CosTable8[bx] imul eax, edx sar eax, 8 - mov [si+0Ah], ax + mov [si+enemy_t.pos.velocity.x], ax mov al, es:[di+3] cbw - mov [si+0Ch], ax + mov [si+enemy_t.pos.velocity.y], ax or cl, cl jnz short loc_154CF - mov dx, [si+0Ah] - mov ax, [si+0Ch] - mov [si+0Ah], ax - mov [si+0Ch], dx + mov dx, [si+enemy_t.pos.velocity.x] + mov ax, [si+enemy_t.pos.velocity.y] + mov [si+enemy_t.pos.velocity.x], ax + mov [si+enemy_t.pos.velocity.y], dx loc_154CF: - call sub_152F2 + call enemy_pos_update jb loc_15388 - mov al, [si+1Bh] - add [si+1Ah], al + mov al, [si+enemy_t.E_angle_delta] + add [si+enemy_t.E_angle], al mov ah, es:[di+4] mov al, 5 jmp loc_15748 @@ -12124,30 +11997,30 @@ loc_154CF: loc_154E5: mov ax, es:[di+1] - mov [si+1Ah], al - mov [si+16h], ah + mov [si+enemy_t.E_angle], al + mov [si+enemy_t.E_speed], ah call sub_15330 mov al, 3 jmp loc_15740 ; --------------------------------------------------------------------------- loc_154F7: - add [si+1Ah], ah + add [si+enemy_t.E_angle], ah jmp short loc_154FF ; --------------------------------------------------------------------------- loc_154FC: - add [si+16h], ah + add [si+enemy_t.E_speed], ah loc_154FF: - call sub_1531F + call enemy_velocity_set mov al, 2 jmp loc_15740 ; --------------------------------------------------------------------------- loc_15507: call randring2_next16 - mov [si+1Ah], al + mov [si+enemy_t.E_angle], al mov al, 1 jmp loc_15740 ; --------------------------------------------------------------------------- @@ -12163,9 +12036,9 @@ loc_15516: loc_15518: mov word_23F60, dx call sub_15345 - mov ax, [si+2] + mov ax, [si+enemy_t.pos.cur.x] add _bullet_template.BT_origin.x, ax - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] add _bullet_template.BT_origin.y, ax push es call fp_25344 @@ -12178,64 +12051,64 @@ loc_15518: ; --------------------------------------------------------------------------- loc_15542: - mov byte ptr [si+23h], 0 - mov [si+28h], ah + mov [si+enemy_t.E_autofire], 0 + mov [si+enemy_t.E_bullet_template.spawn_type], ah mov ax, es:[di+2] - mov [si+2Eh], al - mov [si+34h], ah + mov [si+enemy_t.E_bullet_template.pattern], al + mov [si+enemy_t.E_bullet_template.BT_angle], ah mov ax, es:[di+4] - mov [si+35h], al - mov [si+29h], ah + mov [si+enemy_t.E_bullet_template.speed], al + mov [si+enemy_t.E_bullet_template.patnum], ah mov al, 6 jmp loc_15740 ; --------------------------------------------------------------------------- loc_15562: - mov [si+28h], ah + mov [si+enemy_t.E_bullet_template.spawn_type], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_15567: mov eax, es:[di+1] - mov [si+2Ah], eax + mov dword ptr [si+enemy_t.E_bullet_template.BT_origin], eax mov al, 5 jmp loc_15740 ; --------------------------------------------------------------------------- loc_15575: - mov [si+34h], ah + mov [si+enemy_t.E_bullet_template.BT_angle], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_1557A: - add [si+34h], ah + add [si+enemy_t.E_bullet_template.BT_angle], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_1557F: call randring2_next16 - mov [si+34h], al + mov [si+enemy_t.E_bullet_template.BT_angle], al mov al, 1 jmp loc_15740 ; --------------------------------------------------------------------------- loc_1558A: - mov [si+29h], ah + mov [si+enemy_t.E_bullet_template.patnum], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_1558F: - mov [si+35h], ah + mov [si+enemy_t.E_bullet_template.speed], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_15594: - add [si+35h], ah + add [si+enemy_t.E_bullet_template.speed], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_15599: - mov [si+2Eh], ah + mov [si+enemy_t.E_bullet_template.pattern], ah loc_1559C: mov al, 2 @@ -12261,24 +12134,24 @@ loc_155A1: ; --------------------------------------------------------------------------- loc_155C7: - mov cl, 20h ; ' ' + mov cl, 32 sub cl, dl mul cl shr ax, 6 xor dh, dh mov dl, es:[di+1] add dx, ax - cmp dx, 100h + cmp dx, 256 jb short loc_155E0 - mov dl, 0FFh + mov dl, 255 loc_155E0: cmp _rank, RANK_EASY jnz short loc_155E9 - mov dl, 0FFh + mov dl, 255 loc_155E9: - mov [si+27h], dl + mov [si+enemy_t.E_autofire_interval], dl jmp short loc_1559C ; --------------------------------------------------------------------------- @@ -12286,14 +12159,14 @@ loc_155EE: inc dl loc_155F0: - mov [si+23h], dl + mov [si+enemy_t.E_autofire], dl jmp loc_15740 ; --------------------------------------------------------------------------- loc_155F6: - mov [si+30h], ah + mov [si+enemy_t.E_bullet_template.spread], ah mov al, es:[di+2] - mov [si+31h], al + mov [si+enemy_t.E_bullet_template.spread_angle_delta], al loc_15600: mov al, 3 @@ -12301,32 +12174,32 @@ loc_15600: ; --------------------------------------------------------------------------- loc_15605: - mov [si+32h], ah + mov [si+enemy_t.E_bullet_template.BT_stack], ah mov al, es:[di+2] loc_1560C: - mov [si+33h], al + mov [si+enemy_t.E_bullet_template.stack_speed_delta], al loc_1560F: jmp short loc_15600 ; --------------------------------------------------------------------------- loc_15611: - mov [si+2Fh], ah + mov [si+enemy_t.E_bullet_template.BT_special_motion], ah jmp short loc_1559C ; --------------------------------------------------------------------------- loc_15616: push es - mov ax, [si+2] - add ax, [si+2Ah] + mov ax, [si+enemy_t.pos.cur.x] + add ax, [si+enemy_t.E_bullet_template.BT_origin.x] push ax - mov ax, [si+4] - add ax, [si+2Ch] + mov ax, [si+enemy_t.pos.cur.y] + add ax, [si+enemy_t.E_bullet_template.BT_origin.y] push ax push word ptr es:[di+1] call player_angle_from - mov [si+34h], al + mov [si+enemy_t.E_bullet_template.BT_angle], al pop es loc_15630: @@ -12335,37 +12208,37 @@ loc_15630: loc_15633: inc dl - mov [si], dl - mov [si+17h], ah + mov [si+enemy_t.flag], dl + mov [si+enemy_t.E_patnum_base], ah mov ax, es:[di+2] - mov [si+0Eh], ax + mov [si+enemy_t.E_hp], ax mov ax, es:[di+4] - mov [si+10h], ax - mov [si+22h], dl - mov [si+24h], dl + mov [si+enemy_t.E_score], ax + mov [si+enemy_t.E_can_be_damaged], dl + mov [si+enemy_t.E_kills_player_on_collision], dl mov al, 6 jmp loc_15740 ; --------------------------------------------------------------------------- loc_15653: - mov byte ptr [si+1Fh], 11h + mov [si+enemy_t.E_clip], (ENEMY_CLIP_X or ENEMY_CLIP_Y) jmp loc_15740 ; --------------------------------------------------------------------------- loc_1565A: - or byte ptr [si+1Fh], 1 + or [si+enemy_t.E_clip], ENEMY_CLIP_X jmp loc_15740 ; --------------------------------------------------------------------------- loc_15661: - or byte ptr [si+1Fh], 10h + or [si+enemy_t.E_clip], ENEMY_CLIP_Y jmp loc_15740 ; --------------------------------------------------------------------------- loc_15668: - mov [si+1Ch], ah + mov [si+enemy_t.E_anim_cels], ah mov al, es:[di+2] - mov [si+1Dh], al + mov [si+enemy_t.E_anim_frames_per_cel], al mov al, 3 jmp loc_15740 ; --------------------------------------------------------------------------- @@ -12381,20 +12254,20 @@ loc_15681: ; --------------------------------------------------------------------------- loc_15686: - mov [si+17h], ah + mov [si+enemy_t.E_patnum_base], ah jmp short loc_15681 ; --------------------------------------------------------------------------- loc_1568B: - mov [si+22h], dl + mov [si+enemy_t.E_can_be_damaged], dl loc_1568E: - mov [si+23h], dl + mov [si+enemy_t.E_autofire], dl jmp loc_15740 ; --------------------------------------------------------------------------- loc_15694: - mov byte ptr [si+22h], 1 + mov [si+enemy_t.E_can_be_damaged], 1 cmp _rank, RANK_LUNATIC jnz short loc_1568E inc dl @@ -12405,25 +12278,25 @@ loc_156A3: inc dl loc_156A5: - mov [si+24h], dl + mov [si+enemy_t.E_kills_player_on_collision], dl jmp loc_15740 ; --------------------------------------------------------------------------- loc_156AB: - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax mov eax, es:[di+1] - mov [si+2], eax + mov dword ptr [si+enemy_t.pos.cur], eax jmp short loc_156D4 ; --------------------------------------------------------------------------- loc_156BE: - mov eax, [si+2] - mov [si+6], eax + mov eax, dword ptr [si+enemy_t.pos.cur] + mov dword ptr [si+enemy_t.pos.prev], eax mov ax, es:[di+1] - add [si+2], ax + add [si+enemy_t.pos.cur.x], ax mov ax, es:[di+3] - add [si+4], ax + add [si+enemy_t.pos.cur.y], ax loc_156D4: mov ah, 0 @@ -12432,86 +12305,86 @@ loc_156D4: ; --------------------------------------------------------------------------- loc_156DA: - add [si+17h], ah + add [si+enemy_t.E_patnum_base], ah mov al, 2 jmp short loc_15740 ; --------------------------------------------------------------------------- loc_156E1: - mov [si+1Ah], ah + mov [si+enemy_t.E_angle], ah mov al, es:[di+2] - mov [si+16h], al + mov [si+enemy_t.E_speed], al loc_156EB: - call sub_1531F + call enemy_velocity_set mov al, 3 jmp short loc_15740 ; --------------------------------------------------------------------------- loc_156F2: - mov [si+1Ah], ah + mov [si+enemy_t.E_angle], ah mov al, es:[di+2] - mov [si+16h], al - cmp byte ptr [si+25h], 0 + mov [si+enemy_t.E_speed], al + cmp [si+enemy_t.E_spawned_in_left_half], 0 jnz short loc_156EB - mov al, 80h ; '€' + mov al, 80h sub al, ah - mov [si+1Ah], al + mov [si+enemy_t.E_angle], al jmp short loc_156EB ; --------------------------------------------------------------------------- loc_1570B: - mov [si+16h], ah - call sub_1531F + mov [si+enemy_t.E_speed], ah + call enemy_velocity_set mov al, 2 jmp short loc_15740 ; --------------------------------------------------------------------------- loc_15715: - mov al, [si+19h] + mov al, [si+enemy_t.E_loop_i] cmp al, es:[di+2] jb short loc_15726 - mov byte ptr [si+19h], 0 + mov [si+enemy_t.E_loop_i], 0 mov al, 3 jmp short loc_15740 ; --------------------------------------------------------------------------- loc_15726: - inc byte ptr [si+19h] + inc [si+enemy_t.E_loop_i] loc_15729: mov al, ah mov ah, 0 loc_1572D: - sub [si+14h], ax + sub [si+enemy_t.E_script_ip], ax jmp loc_15364 ; --------------------------------------------------------------------------- loc_15733: mov al, 3 - cmp ah, [si+36h] + cmp ah, [si+enemy_t.E_subtype] jz short loc_15740 add al, es:[di+2] jz short $+2 loc_15740: mov ah, 0 - add [si+14h], ax + add [si+enemy_t.E_script_ip], ax jmp loc_15364 ; --------------------------------------------------------------------------- loc_15748: - cmp ah, [si+18h] + cmp ah, [si+enemy_t.E_cur_instr_frame] ja short loc_15757 mov ah, 0 - mov [si+18h], ah - add [si+14h], ax + mov [si+enemy_t.E_cur_instr_frame], ah + add [si+enemy_t.E_script_ip], ax jmp short loc_1575A ; --------------------------------------------------------------------------- loc_15757: - inc byte ptr [si+18h] + inc [si+enemy_t.E_cur_instr_frame] loc_1575A: xor ax, ax @@ -13339,11 +13212,11 @@ sub_15F08 endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public ENEMIES_ADD +enemies_add proc near -sub_15F10 proc near - -var_4 = word ptr -4 -var_2 = word ptr -2 +@@center_y = word ptr -4 +@@i = word ptr -2 enter 4, 0 push si @@ -13351,61 +13224,59 @@ var_2 = word ptr -2 les bx, _std_ip mov di, es:[bx+1] mov ax, es:[bx+3] - mov [bp+var_4], ax - mov si, 9296h - mov [bp+var_2], 0 - jmp loc_16000 + mov [bp+@@center_y], ax + mov si, offset _enemies + mov [bp+@@i], 0 + jmp @@more? ; --------------------------------------------------------------------------- -loc_15F30: - cmp byte ptr [si], 0 - jnz loc_15FFA - mov byte ptr [si], 3 - mov byte ptr [si+1], 0 - mov byte ptr [si+18h], 0 - mov byte ptr [si+19h], 0 - mov word ptr [si+14h], 0 +@@loop: + cmp [si+enemy_t.flag], EF_FREE + jnz @@next + mov [si+enemy_t.flag], EF_ALIVE_FIRST_FRAME + mov [si+enemy_t.age], 0 + mov [si+enemy_t.E_cur_instr_frame], 0 + mov [si+enemy_t.E_loop_i], 0 + mov [si+enemy_t.E_script_ip], 0 les bx, _std_ip mov al, es:[bx] mov ah, 0 add ax, ax mov bx, ax mov ax, _enemy_script_ptrs[bx] - mov [si+12h], ax - cmp di, 3E70h + mov [si+enemy_t.E_script], ax + cmp di, ENEMY_POS_RANDOM jnz short loc_15F6D - push 1800h - call randring2_next16_mod + call randring2_next16_mod pascal, (PLAYFIELD_W shl 4) mov di, ax loc_15F6D: - mov [si+2], di - cmp di, 0C00h - jge short loc_15F7A + mov [si+enemy_t.cur.pos.x], di + cmp di, ((PLAYFIELD_W / 2) shl 4) + jge short @@spawned_in_right_half mov al, 1 jmp short loc_15F7C ; --------------------------------------------------------------------------- -loc_15F7A: +@@spawned_in_right_half: mov al, 0 loc_15F7C: - mov [si+25h], al - cmp [bp+var_4], 3E70h + mov [si+enemy_t.E_spawned_in_left_half], al + cmp [bp+@@center_y], ENEMY_POS_RANDOM jnz short loc_15F8F - push 1700h - call randring2_next16_mod - mov [bp+var_4], ax + call randring2_next16_mod pascal, ((PLAYFIELD_H) shl 4) + mov [bp+@@center_y], ax loc_15F8F: - mov ax, [bp+var_4] - mov [si+4], ax + mov ax, [bp+@@center_y] + mov [si+enemy_t.cur.pos.y], ax les bx, _std_ip mov al, es:[bx+5] - mov [si+20h], al + mov [si+enemy_t.E_item], al mov al, es:[bx+6] - mov [si+36h], al - mov byte ptr [si+21h], 0 + mov [si+enemy_t.E_subtype], al + mov [si+enemy_t.E_damaged_this_frame], 0 cmp _rank, RANK_LUNATIC jnz short loc_15FB7 mov ax, 1 @@ -13416,39 +13287,39 @@ loc_15FB7: xor ax, ax loc_15FB9: - mov [si+23h], al - mov byte ptr [si+1Fh], 0 - mov byte ptr [si+1Ch], 1 - mov byte ptr [si+1Dh], 4 - mov byte ptr [si+1Eh], 0 - mov byte ptr [si+22h], 0 - mov byte ptr [si+24h], 0 + mov [si+enemy_t.E_autofire], al + mov [si+enemy_t.E_clip], 0 + mov [si+enemy_t.E_anim_cels], 1 + mov [si+enemy_t.E_anim_frames_per_cel], 4 + mov [si+enemy_t.E_anim_cur_cel], 0 + mov [si+enemy_t.E_can_be_damaged], 0 + mov [si+enemy_t.E_kills_player_on_collision], 0 call randring2_next16 - mov [si+26h], al - mov byte ptr [si+27h], 80h - mov byte ptr [si+2Eh], 0Fh - mov byte ptr [si+28h], 0 - mov byte ptr [si+35h], 2Ah ; '*' - mov word ptr [si+2Ah], 0 - mov word ptr [si+2Ch], 0 - mov byte ptr [si+29h], 0 - jmp short loc_16008 + mov [si+enemy_t.E_autofire_cur_frame], al + mov [si+enemy_t.E_autofire_interval], 128 + mov [si+enemy_t.E_bullet_template.pattern], BP_FORCESINGLE_AIMED + mov [si+enemy_t.E_bullet_template.spawn_type], BST_NORMAL + mov [si+enemy_t.E_bullet_template.speed], (2 shl 4) + 10 + mov [si+enemy_t.E_bullet_template.BT_origin.x], 0 + mov [si+enemy_t.E_bullet_template.BT_origin.y], 0 + mov [si+enemy_t.E_bullet_template.patnum], 0 + jmp short @@ret ; --------------------------------------------------------------------------- -loc_15FFA: - inc [bp+var_2] - add si, 40h ; '@' +@@next: + inc [bp+@@i] + add si, size enemy_t -loc_16000: - cmp [bp+var_2], 20h ; ' ' - jl loc_15F30 +@@more?: + cmp [bp+@@i], ENEMY_COUNT + jl @@loop -loc_16008: +@@ret: pop di pop si leave retn -sub_15F10 endp +enemies_add endp ; =============== S U B R O U T I N E ======================================= @@ -13476,7 +13347,7 @@ var_1 = byte ptr -1 loc_16035: cmp _midboss_active, 0 jnz short loc_1603F - call sub_15F10 + call enemies_add loc_1603F: add word ptr _std_ip, 8 @@ -13497,17 +13368,17 @@ std_run endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame +public ENEMY_BULLET_TEMPLATE_PUSH +enemy_bullet_template_push proc near -sub_16065 proc near - -arg_0 = word ptr 4 +@@template = word ptr 4 push bp mov bp, sp push si push di mov cx, size _bullet_template / 2 - mov si, [bp+arg_0] + mov si, [bp+@@template] mov di, offset _bullet_template push ds pop es @@ -13517,14 +13388,14 @@ arg_0 = word ptr 4 pop si pop bp retn 2 -sub_16065 endp +enemy_bullet_template_push endp ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame - -sub_1607D proc far +public ENEMIES_UPDATE +enemies_update proc far var_2 = byte ptr -2 var_1 = byte ptr -1 @@ -13537,177 +13408,175 @@ var_1 = byte ptr -1 mov word_2CED6, 100h mov word_2CED8, 0C0h mov [bp+var_2], 0 - mov si, 9296h + mov si, offset _enemies xor di, di - jmp loc_16251 + jmp @@more? ; --------------------------------------------------------------------------- -loc_160A7: - cmp byte ptr [si], 0 - jz loc_1624D - cmp byte ptr [si], 2 - jnz short loc_160B9 - mov byte ptr [si], 0 - jmp loc_1624D +@@loop: + cmp [si+enemy_t.flag], EF_FREE + jz @@next + cmp [si+enemy_t.flag], EF_KILLED + jnz short @@alive + mov [si+enemy_t.flag], EF_FREE + jmp @@next ; --------------------------------------------------------------------------- -loc_160B9: - mov word_2C92A, si - cmp byte ptr [si], 80h +@@alive: + mov _enemy_cur, si + cmp [si+enemy_t.flag], EF_KILL_ANIM jnb loc_16221 call sub_1535A - cmp byte ptr [si+24h], 0 + cmp [si+enemy_t.E_kills_player_on_collision], 0 jz short loc_160F2 - mov ax, [si+2] + mov ax, [si+enemy_t.pos.cur.x] sub ax, _player_pos.cur.x - add ax, 12 * 16 - cmp ax, 24 * 16 + add ax, (12 shl 4) + cmp ax, (24 shl 4) jnb short loc_160F2 - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] sub ax, _player_pos.cur.y - add ax, 12 * 16 - cmp ax, 24 * 16 + add ax, (12 shl 4) + cmp ax, (24 shl 4) jnb short loc_160F2 mov _player_is_hit, 1 jmp short loc_16161 ; --------------------------------------------------------------------------- loc_160F2: - cmp byte ptr [si+22h], 0 - jz loc_161C6 - cmp word ptr [si+0Eh], 0FFFFh - jz loc_161C6 - mov ax, [si+2] - add ax, 100h - cmp ax, 1A00h - jnb loc_161C6 - mov ax, [si+4] - add ax, 100h - cmp ax, 1800h - jnb loc_161C6 + cmp [si+enemy_t.E_can_be_damaged], 0 + jz @@autofire? + cmp [si+enemy_t.E_hp], -1 + jz @@autofire? + mov ax, [si+enemy_t.pos.cur.x] + add ax, ((ENEMY_W / 2) shl 4) + cmp ax, (PLAYFIELD_RIGHT shl 4) + jnb @@autofire? + mov ax, [si+enemy_t.pos.cur.y] + add ax, ((ENEMY_H / 2) shl 4) + cmp ax, (PLAYFIELD_BOTTOM shl 4) + jnb @@autofire? inc [bp+var_2] - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] cmp ax, _homing_target.y jle short loc_16134 - mov ax, [si+2] + mov ax, [si+enemy_t.pos.cur.x] mov _homing_target.x, ax - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] mov _homing_target.y, ax loc_16134: - mov eax, [si+2] + mov eax, dword ptr [si+enemy_t.pos.cur] mov dword_2CED2, eax call sub_126B3 mov [bp+var_1], al cmp [bp+var_1], 0 - jz short loc_161C6 - cmp word ptr [si+0Eh], 0FFFEh + jz short @@autofire? + cmp [si+enemy_t.E_hp], -2 jz short loc_161BF mov ah, 0 - cmp ax, [si+0Eh] + cmp ax, [si+enemy_t.E_hp] jge short loc_16161 mov al, [bp+var_1] mov ah, 0 - sub [si+0Eh], ax + sub [si+enemy_t.E_hp], ax jmp short loc_161B9 ; --------------------------------------------------------------------------- loc_16161: - mov byte ptr [si], 80h - mov byte ptr [si+1Ch], 1 - mov byte ptr [si+22h], 0 - mov byte ptr [si+24h], 0 - mov word ptr [si+0Ah], 0 - mov word ptr [si+0Ch], 0 - cmp byte ptr [si+20h], 0FEh + mov [si+enemy_t.flag], EF_KILL_ANIM + mov [si+enemy_t.E_anim_cels], 1 + mov [si+enemy_t.E_can_be_damaged], 0 + mov [si+enemy_t.E_kills_player_on_collision], 0 + mov [si+enemy_t.pos.velocity.x], 0 + mov [si+enemy_t.pos.velocity.y], 0 + cmp [si+enemy_t.E_item], IT_NONE jz short loc_1618C - call items_add pascal, word ptr [si+2], word ptr [si+4], word ptr [si+20h] + call items_add pascal, [si+enemy_t.pos.cur.x], [si+enemy_t.pos.cur.y], word ptr [si+enemy_t.E_item] loc_1618C: call snd_se_play pascal, 3 - movzx eax, word ptr [si+10h] + movzx eax, word ptr [si+enemy_t.E_score] add _score_delta, eax - push word ptr [si+2] - push word ptr [si+4] + push [si+enemy_t.pos.cur.x] + push [si+enemy_t.pos.cur.y] push large (((4 shl 4) shl 16) or 7) nopcall sparks_add_random inc _enemies_gone inc _enemies_killed - jmp loc_1624D + jmp @@next ; --------------------------------------------------------------------------- loc_161B9: - mov byte ptr [si+21h], 1 - jmp short loc_161C6 + mov [si+enemy_t.E_damaged_this_frame], 1 + jmp short @@autofire? ; --------------------------------------------------------------------------- loc_161BF: call snd_se_play pascal, 10 -loc_161C6: - cmp byte ptr [si+23h], 0 - jz short loc_1621C - inc byte ptr [si+26h] - mov al, [si+26h] - cmp al, [si+27h] - jb short loc_1621C - cmp word ptr [si+4], 1300h - jge short loc_1621C - mov ax, [si+2] +@@autofire?: + cmp [si+enemy_t.E_autofire], 0 + jz short @@no_autofire + inc [si+enemy_t.E_autofire_cur_frame] + mov al, [si+enemy_t.E_autofire_cur_frame] + cmp al, [si+enemy_t.E_autofire_interval] + jb short @@no_autofire + cmp [si+enemy_t.pos.cur.y], (304 shl 4) + jge short @@no_autofire + mov ax, [si+enemy_t.pos.cur.x] sub ax, _player_pos.cur.x - add ax, 48 * 16 - cmp ax, 96 * 16 - jnb short loc_161FC - mov ax, [si+4] + add ax, (48 shl 4) + cmp ax, (96 shl 4) + jnb short @@fire + mov ax, [si+enemy_t.pos.cur.y] sub ax, _player_pos.cur.y - add ax, 48 * 16 - cmp ax, 96 * 16 - jb short loc_1621C + add ax, (48 shl 4) + cmp ax, (96 shl 4) + jb short @@no_autofire -loc_161FC: - mov byte ptr [si+26h], 0 - lea ax, [si+28h] - push ax - call sub_16065 - mov ax, [si+2] +@@fire: + mov [si+enemy_t.E_autofire_cur_frame], 0 + lea ax, [si+enemy_t.E_bullet_template] + call enemy_bullet_template_push pascal, ax + mov ax, [si+enemy_t.pos.cur.x] add _bullet_template.BT_origin.x, ax - mov ax, [si+4] + mov ax, [si+enemy_t.pos.cur.y] add _bullet_template.BT_origin.y, ax call fp_25344 call sub_15A5C -loc_1621C: - inc byte ptr [si+1] - jmp short loc_1624D +@@no_autofire: + inc [si+enemy_t.age] + jmp short @@next ; --------------------------------------------------------------------------- loc_16221: - lea ax, [si+2] - push ax - call _motion_update_2 - mov al, [si] + lea ax, [si+enemy_t.pos] + call _motion_update_2 pascal, ax + mov al, [si+enemy_t.flag] inc al - mov [si], al + mov [si+enemy_t.flag], al mov [bp+var_1], al mov ah, 0 - add ax, 0FF80h + add ax, -EF_KILL_ANIM mov bx, 4 cwd idiv bx - add al, 4 + add al, PAT_ENEMY_KILL mov [bp+var_1], al - mov [si+17h], al - cmp [bp+var_1], 0Ch - jb short loc_1624D - mov byte ptr [si], 2 + mov [si+enemy_t.E_patnum_base], al + cmp [bp+var_1], (PAT_ENEMY_KILL + ENEMY_KILL_CELS) + jb short @@next + mov [si+enemy_t.flag], EF_KILLED -loc_1624D: +@@next: inc di - add si, 40h + add si, size enemy_t -loc_16251: - cmp di, 20h ; ' ' - jl loc_160A7 +@@more?: + cmp di, ENEMY_COUNT + jl @@loop cmp _homing_target.x, HOMING_TARGET_NONE jz short loc_162B9 cmp [bp+var_2], 8 @@ -13757,7 +13626,7 @@ loc_162B9: pop si leave retf -sub_1607D endp +enemies_update endp include th04/main/boss/explosions_reset.asm include th04/main/boss/explode_small.asm @@ -30113,13 +29982,19 @@ include th02/main/demo[bss].asm byte_25FF8 db ? db ? include th04/main/bullet/template[bss].asm + +; Needs to be here because it contains a bullet_template_t, which is only +; declared in template[bss].asm. Moving it before that declaration results in +; an illegal forward reference. +include th05/main/enemy/enemy.inc + include th05/main/lasers[bss].asm include th04/main/midboss/vars[bss].asm include th04/main/boss/vars[bss].asm include th05/main/boss/vars2[bss].asm include th04/main/sparks[bss].asm include th04/main/bullet/bullets[bss].asm - db 2048 dup(?) +include th04/main/enemy/enemies[bss].asm include th04/main/gather[bss].asm include th04/main/circles[bss].asm include th04/main/pointnum/pointnum[bss].asm @@ -30129,9 +30004,9 @@ include th04/main/player/shots[bss].asm db 72 dup(?) include th05/main/player/hitshots[bss].asm include th04/main/homing_target[bss].asm -public _stage_vm +public _stage_vm, _enemy_cur _stage_vm dd ? -word_2C92A dw ? +_enemy_cur dw ? include th04/main/circles_color[bss].asm fp_2C92E dw ? dword_2C930 dd ?