**************************************************************************** **************************************************************************** ** ** Platinum (Enemies) ** ** This software is in the public domain. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated July 25, 2001 ** **************************************************************************** **************************************************************************** ******************************************** MOVE THE ENEMIES * * This enemy routine moves every enemy. It uses the enemy's type in each * enemy structure to select a routine from the table of actual enemy * routines. The table itself, as well as the routines, are in the file * ENEMIES2.ASM. * * Each enemy routine will be called with A4 pointing to that enemy's enemy * structure, and A3 pointing to the position in the coordinate table for * that enemy (the coordinate table has 4 bytes per enemy, and is mainly used * to specify locations for enemies that are in formation). The D7 register * is used as the loop counter; the order in which the enemies are processed * is reversed at each frame, so the low bit will be different at each frame * for a specific enemy. * * The enemy handling routines should preserve the A3, A4, and D7 registers. * Their purpose is to move the enemy by updating its coordinates, and make * other changes to the data as needed (e.g. changing the image if the enemy * is animated). It should NOT draw the enemy to the screen. * ******** Move_Enemies: btst #0,cycle_counter+3(a5) beq.s enemies_opposite lea xy_pointers(a5),a3 ;A3 -> standard coordinates lea enemies_data(a5),a4 ;A4 -> enemy structure moveq #num_en-1,d7 loop_move_enemies: move.w (a4),d0 beq.s me_no_enemy_here jsr Move_Enemies(pc,d0.w) me_no_enemy_here: lea e_size(a4),a4 addq.l #4,a3 dbra d7,loop_move_enemies rts enemies_opposite: lea xy_pointers(a5),a3 ;A3 -> standard coordinates add.l #4*num_en,a3 lea enemies_data_end(a5),a4 moveq #num_en-1,d7 _loop_move_enemies: lea -e_size(a4),a4 subq.l #4,a3 move.w (a4),d0 beq.s b_me_no_enemy_here jsr Move_Enemies(pc,d0.w) b_me_no_enemy_here: dbra d7,_loop_move_enemies rts ******************************************** ENEMY TABLE & CONTROL ROUTINES INCLUDE enemies2.asm INCLUDE enemies3.asm INCLUDE megaboss.asm ******************************************** DRAW/ERASE THE ENEMIES * * Quite simply, this runs through the enemy array, and draws each enemy on * the screen using the standard sprite display code. * ******** Draw_Enemies: lea enemies_data(a5),a6 moveq #num_en-1,d7 loop_draw_enemies: tst.w (a6) beq.s ed_no_enemy_here move.w e_y(a6),d1 ble.s ed_no_enemy_here move.w e_x(a6),d0 move.w e_image(a6),d2 bsr Xor_Sprite_D2 move.l a6,a4 lea player_ship(a5),a3 bsr Test_Collision beq.s ed_no_enemy_here moveq #1,d5 bsr Player_Damage subq.w #1,e_dmg(a6) bgt.s ed_no_enemy_here move.w e_dstry(a6),d0 lea Destroy_Base(pc),a2 move.l a6,a4 jsr 0(a2,d0.w) ed_no_enemy_here: lea e_size(a6),a6 dbra d7,loop_draw_enemies rts Destroy_Base: