.386 locals include libs/master.lib/master.inc include th02/playfld.inc include th04/math/motion.inc include th04/hardware/input.inc include th04/player/player.inc VECTOR2_AT procdesc pascal far \ ret:ptr Point, origin_x:word, origin_y:word, length:word, angle:byte TILES_INVALIDATE_AROUND procdesc pascal near \ center:Point extrn _tile_invalidate_box:Point extrn _miss_time:byte extrn _miss_explosion_angle:byte extrn _miss_explosion_radius:word extrn _drawpoint:Point extrn _player_option_pos_prev:Point extrn _player_pos:motion_t extrn _playchar_speed_aligned:word extrn _playchar_speed_diagonal:word ; ---------------------------------------------------------------------------- main_01_TEXT segment word public 'CODE' use16 assume cs:main_01_TEXT ; void pascal near player_invalidate(void); public PLAYER_INVALIDATE player_invalidate proc pascal near mov _tile_invalidate_box.y, PLAYER_H cmp _miss_time, 0 jz short @@alive push di mov _tile_invalidate_box.x, MISS_EXPLOSION_W mov di, _miss_explosion_radius ; Go back a frame add di, -MISS_EXPLOSION_RADIUS_VELOCITY mov al, _miss_explosion_angle add al, -MISS_EXPLOSION_ANGLE_VELOCITY mov ah, MISS_EXPLOSION_COUNT @@loop: cmp ah, MISS_EXPLOSION_COUNT / 2 jnz short @@invalidate shr di, 1 neg al @@invalidate: push ax call vector2_at pascal, offset _drawpoint, _player_pos.cur.x, _player_pos.cur.y, di, ax MISS_EXPLOSION_CLIP @@next call tiles_invalidate_around pascal, large [_drawpoint] @@next: pop ax add al, 256 / (MISS_EXPLOSION_COUNT / 2) dec ah jnz short @@loop pop di jmp short @@ret ; --------------------------------------------------------------------------- @@alive: mov _tile_invalidate_box.x, PLAYER_W call tiles_invalidate_around pascal, large [_player_pos.prev] mov _tile_invalidate_box.x, PLAYER_OPTION_W + PLAYER_W + PLAYER_OPTION_W mov _tile_invalidate_box.y, PLAYER_OPTION_H call tiles_invalidate_around pascal, large [_player_option_pos_prev] @@ret: retn player_invalidate endp even ; move_ret_t pascal near player_move(int input); public PLAYER_MOVE player_move proc near @@input = word ptr ss:[bx+2] @@diagonal_x equ ax @@diagonal_y equ cx @@aligned equ dx mov bx, sp mov bx, @@input cmp bl, INPUT_RIGHT or INPUT_DOWN ja short @@invalid mov @@diagonal_y, _playchar_speed_diagonal mov @@diagonal_x, @@diagonal_y mov @@aligned, _playchar_speed_aligned and bh, low INPUT_MOVEMENT jz short @@switch or bl, bl jnz short @@invalid shr bx, 8 cmp bl, 8 ja short @@invalid add bl, 11 @@switch: add bx, bx jmp word ptr cs:@@switch_table[bx] @@up: neg @@aligned @@down: mov _player_pos.velocity.y, @@aligned jmp short @@moved ; --------------------------------------------------------------------------- @@left: neg @@aligned @@right: mov _player_pos.velocity.x, @@aligned jmp short @@moved ; --------------------------------------------------------------------------- @@up_right: neg @@diagonal_y jmp short @@down_right ; --------------------------------------------------------------------------- @@up_left: neg @@diagonal_y @@down_left: neg @@diagonal_x @@down_right: mov _player_pos.velocity.x, @@diagonal_x mov _player_pos.velocity.y, @@diagonal_y jmp short @@moved ; --------------------------------------------------------------------------- @@standing_still: mov al, MOVE_NOINPUT jmp short @@ret ; --------------------------------------------------------------------------- @@invalid: xor al, al jmp short @@ret ; --------------------------------------------------------------------------- @@moved: mov al, MOVE_VALID @@ret: retn 2 ; --------------------------------------------------------------------------- @@switch_table label word dw @@standing_still dw @@up dw @@down dw @@invalid dw @@left dw @@up_left dw @@down_left dw @@invalid dw @@right dw @@up_right dw @@down_right dw @@invalid dw @@up_left dw @@up_right dw @@invalid dw @@down_left dw @@invalid dw @@invalid dw @@invalid dw @@down_right player_move endp main_01_TEXT ends end