diff --git a/ai.asm b/ai.asm index c49e467..9c5be12 100644 --- a/ai.asm +++ b/ai.asm @@ -44,6 +44,7 @@ loop ; common values used in AI routines ; address of weapons table (for future use) +WepTableToTemp lda TanksWeaponsTableL,x sta temp lda TanksWeaponsTableH,x @@ -210,6 +211,19 @@ AngleTable ; 16 bytes ;ba w $348b L$3350 .endp ;---------------------------------------------- .proc UseBatteryOrFlag + jsr UseBattery ; as subroutine for reuse in AutoDefense + ; if very low energy and no battery then use White Flag + lda Energy,x + cmp #5 + bcs EnoughEnergy + ; lower than 5 units - white flag + lda #ind_White_Flag_____ + sta ActiveDefenceWeapon,x +EnoughEnergy + rts +.endp +; +.proc UseBattery ; if low energy ten use battery lda Energy,x cmp #30 @@ -219,20 +233,13 @@ AngleTable ; 16 bytes ;ba w $348b L$3350 lda (temp),y ; has address of TanksWeaponsTable beq NoBatteries ; we have batteries - use one - clc + sec sbc #1 sta (temp),y lda #99 sta Energy,x -NoBatteries - ; if very low energy and no battery then use White Flag - lda Energy,x - cmp #5 - bcs EnoughEnergy - ; lower than 5 units - white flag - lda #ind_White_Flag_____ - sta ActiveDefenceWeapon,x EnoughEnergy +NoBatteries rts .endp ;---------------------------------------------- @@ -245,7 +252,7 @@ EnoughEnergy ; first check check if any is in use lda ActiveDefenceWeapon,x bne DefensiveInUse - ldy #last_defensive_____+1 ;the last defensive weapon + ldy #last_real_defensive+1 ;the last defensive weapon @ dey cpy #ind_Battery________ ;first defensive weapon (White Flag and Battery - never use) @@ -253,7 +260,7 @@ EnoughEnergy lda (temp),y ; has address of TanksWeaponsTable beq @- ; decrease in inventory - clc + sec sbc #1 sta (temp),y ; has address of TanksWeaponsTable ; activate defensive weapon @@ -280,7 +287,7 @@ DefensiveInUse ; first check check if any is in use lda ActiveDefenceWeapon,x bne DefensiveInUse - ldy #last_defensive_____+1 ;the last defensive weapon + ldy #last_real_defensive+1 ;the last defensive weapon @ dey cpy #ind_Battery________ ;first defensive weapon (White Flag and Battery - never use) @@ -288,7 +295,7 @@ DefensiveInUse lda (temp),y ; has address of TanksWeaponsTable beq @- ; decrease in inventory - clc + sec sbc #1 sta (temp),y ; has address of TanksWeaponsTable ; activate defensive weapon @@ -575,7 +582,7 @@ skipThisPlayer asl tay ; force correction - lower tank Y position - higher possible force - clc + sec lda #screenheight sbc Ytankstable,x sta temp2 diff --git a/constants.asm b/constants.asm index cbe9515..33d3fec 100644 --- a/constants.asm +++ b/constants.asm @@ -276,6 +276,7 @@ WeaponPriceH ; weapons prices (tables with prices of weapons) .by >price_Nuclear_Winter_ .by >price_Lazy_Boy_______ .by >price_Lazy_Darwin____ + .by >price_Auto_Defense___ WeaponPriceL .by $7f - activated + .DS MaxPlayers WeaponDepleted .DS 1 ; if 0 deactivate the weapon and switch to Baby Missile ;---------------------------------------------------- diff --git a/weapons.asm b/weapons.asm index 8e12e4c..8130d48 100644 --- a/weapons.asm +++ b/weapons.asm @@ -2418,7 +2418,17 @@ InverseScreenByte sta (temp),y rts .endp - +; ------------------------------------------------- +.proc AutoDefense +; ------------------------------------------------- +; This routine is run from inside of the main loop +; X - index of tank +; ------------------------------------------------- + jsr PrepareAIShoot.WepTableToTemp + jsr UseBattery + jsr TosserDefensives + rts +.endp ; ------------------------------------------------- .proc TankFlying ; -------------------------------------------------