diff --git a/README.md b/README.md index 2806055..c543969 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,16 @@ With the advent of fujinet (https://fujinet.online/) we are thinking about makin ## Changes: +###### Build 143 +2022-06-05 +Rewrite build. We redone several important parts of the game to allow for bug fixes and requested features. Generally it was a great success, but some new bugs appeared. This build is nice for the eye, but beware, no mercy for testers again :) +Only visible changes listed, because you are possibly not as excited as we are for the new Flight routine and ground collisions by @Pecusx. +- https://github.com/pkali/scorch_src/issues/84, https://github.com/pkali/scorch_src/issues/63 - tanks now say good bye properly! +- https://github.com/pkali/scorch_src/issues/74 - Press [ESC] to quit the game at any point, with a confirmation when the round has already started. Please note the keyboard is not checked all the time, so press it for a while, especially when AI tanks are ru(i/n)ning the show. +- https://github.com/pkali/scorch_src/issues/56 - there should be no occurrences of frivolous weapon purchases. Please report all tanks getting their munitions from uncertified sources! +- https://github.com/pkali/scorch_src/issues/47 - It seems that the bad sequence of turns has been ameliorated. Fix is trivial, finding the culprit - far from it. Please pay special attention to fairness of shooting in case the fix is still longing for the fjords. +- ATTRACT mode works how it should - screensaver saves screen only when HUMAN should input something. + ###### Build 142 2022-05-30 Late build. The bugs we tried to squelch turned out to be more difficult than usual. Some progress has been made though even if it is not yet visible. diff --git a/constants.asm b/constants.asm index 859ceb6..99c6f47 100644 --- a/constants.asm +++ b/constants.asm @@ -23,7 +23,6 @@ RoundsTable .by 10,20,30,40,50 flyDelayTable .by 255,150,75,35,1 seppukuTable .by 255, 45,25,15,9 ;------------------------------------------------ - LevelNameBeginL ; begins of level names .by TanksWeapon1,>TanksWeapon2,>TanksWeapon3,>TanksWeapon4,>TanksWeapon5,>TanksWeapon6 -;-----4x4 texts----- +;-----4x4 texts----- LineTop - dta d"(%%%%%%%%%%%%)" - .byte $ff + dta d"(%%%%%%%%%%%%)", $ff ;# - vertical, () * +, % - horizontal LineBottom - dta d"*%%%%%%%%%%%%+" - .byte $ff + dta d"*%%%%%%%%%%%%+", $ff LineEmpty - dta d"# #" - .byte $ff + dta d"# #", $ff LineHeader2 - dta d"# RESULTS #" - .byte $ff + dta d"# RESULTS #", $ff LineGameOver - dta d"# GAME OVER #" - .byte $ff + dta d"# GAME OVER #", $ff seppukuText - dta d"# SEPPUKU! #" - .byte $ff + dta d"# SEPPUKU! #", $ff +areYouSureText + dta d"# SURE? Y/N #", $ff lineClear - dta d" " - .byte $ff - + dta d" ", $ff ;----------- pmtableL ; addressess of the P/M memory for 5 tanks (6th is without P/M background) @@ -541,8 +534,8 @@ EndOfTheBarrelY .by 7,7,7,7,7,7,7,7,7 .by 7,7,7,7,7,7,7,7,7,7 .by 7,7,7,7,7,7,7,7,7,7,7 -;------------------------------------------------- +;------------------------------------------------- TanksNamesDefault dta d"1st.Tank" dta d"2nd.Tank" @@ -551,7 +544,6 @@ TanksNamesDefault dta d"5th.Tank" dta d"6th.Tank" - WeaponPriceH ; weapons prices (tables with prices of weapons) .by >price_Baby_Missile___ .by >price_Missile________ @@ -889,7 +881,7 @@ NamesOfWeapons ;the comment is an index in the tables dta d"White Flag " ; 63 weaponsOfDeath dta 1,2,3,7,15,16,17,18,19,20,21,22,23,24,25,26,27 -weaponsOfDeathEnd +weaponsOfDeathEnd joyToKeyTable ; .by 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15 .by $ff,$ff,$ff,$ff,$ff,$ff,$ff,$07,$ff,$ff,$ff,$06,$ff,$0f,$0e,$ff diff --git a/grafproc.asm b/grafproc.asm index 6144171..edc67a1 100644 --- a/grafproc.asm +++ b/grafproc.asm @@ -4,7 +4,7 @@ ;-------------------------------------------------- -draw .proc ;;fuxxing good draw :) +.proc draw ;;fuxxing good draw :) ;-------------------------------------------------- ;creditz to Dr Jankowski / MIM U.W. ; (xi,yi)-----(xk,yk) @@ -43,9 +43,9 @@ draw .proc ;;fuxxing good draw :) ;cpw ybyte #screenheight ;bcc DrawOnTheScreen lda ydraw+1 - bne DrawOutOfTheScreen + bmi DrawOutOfTheScreen lda ybyte+1 - beq DrawOnTheScreen + bpl DrawOnTheScreen DrawOutOfTheScreen ;jsr DrawJumpPad rts @@ -230,20 +230,26 @@ yestrace jsr plot notrace ;aftertrace + ;key lda HitFlag bne StopHitChecking CheckCollisionDraw ; checking collision! lda ydraw+1 - bne StopHitChecking + bmi StopHitChecking jsr CheckCollisionWithTank lda HitFlag bne StopHitChecking - mwa xdraw temp - adw temp #mountaintable + clc + lda xdraw + adc #mountaintable + sta temp+1 ldy #0 lda ydraw @@ -255,7 +261,7 @@ CheckCollisionDraw sec sbc #1 sta YHit - mva #0 YHit+1 + sty YHit+1 ;mwa ydraw YHit mva #1 HitFlag StopHitChecking @@ -272,7 +278,7 @@ ContinueDraw EndOfDraw mwa xtempDRAW xdraw - mva ytempDRAW ydraw + mwa ytempDRAW ydraw rts .endp @@ -298,7 +304,7 @@ EndOfDraw ; splot8 mwa xdraw xcircle - mva ydraw ycircle + mwa ydraw ycircle mwa #0 xc mva radius yc @@ -354,7 +360,7 @@ endcircleloop jsr splot8 mwa xcircle xdraw - mva ycircle ydraw + mwa ycircle ydraw rts .endp ;---- @@ -381,12 +387,19 @@ splot8 .proc adc YC sta ydraw sta tempcir + lda ycircle+1 + adc #$00 + sta ydraw+1 + sta tempcir+1 jsr plot sec lda ycircle sbc YC sta ydraw + lda ycircle+1 + sbc #$00 + sta ydraw+1 jsr plot sec @@ -400,6 +413,8 @@ splot8 .proc lda tempcir sta ydraw + lda tempcir+1 + sta ydraw+1 jsr plot ;--- clc @@ -414,12 +429,19 @@ splot8 .proc adc xC sta ydraw sta tempcir + lda ycircle+1 + adc #$00 + sta ydraw+1 + sta tempcir+1 jsr plot sec lda ycircle sbc xC sta ydraw + lda ycircle+1 + sbc #$00 + sta ydraw+1 jsr plot sec @@ -433,6 +455,8 @@ splot8 .proc lda tempcir sta ydraw + lda tempcir+1 + sta ydraw+1 jsr plot RTS @@ -583,7 +607,7 @@ DrawNextTank .endp ;--------- .proc DrawTankNr - ldx tanknr + ldx tankNr ; let's check the energy lda eXistenZ,x bne SkipRemovigPM ; if energy=0 then no tank @@ -672,6 +696,28 @@ DoNotDrawTankNr rts .endp +; ------------------------------------- +.proc FlashTank +; ------------------------------------- +; number of blinking tank in TankNr + mva #18 fs ; temp, how many times flash the tank +tankflash_loop + lda CONSOL ; turbo mode + cmp #6 ; START + sne:mva #1 fs ; finish it + mva #1 Erase + ldx TankNr + jsr DrawTankNr.SkipRemovigPM ; it's necessary becouse DrawTankNr skips tanks with no energy ! + PAUSE 2 + mva #0 Erase + ldx TankNr + jsr DrawTankNr.SkipRemovigPM + PAUSE 2 + dec fs + jne tankflash_loop + rts +.endp + ;-------------------------------------------------- .proc drawmountains ;-------------------------------------------------- @@ -685,6 +731,7 @@ drawmountainsloop cmp #screenheight beq NoMountain sta ydraw + sty ydraw+1 jsr DrawLine NoMountain inw modify @@ -703,6 +750,7 @@ drawmountainspixelloop ldy #0 lda (modify),y sta ydraw + sty ydraw+1 jsr plot inw modify inw xdraw @@ -749,7 +797,7 @@ drawmountainspixelloop adw RangeLeft #mountaintable2 tempor2 NextColumn1 - mva #0 ydraw + mwa #0 ydraw NextPoint1 jsr point beq StillNothing @@ -1260,9 +1308,9 @@ MakeMask00 lsr mask1+# ror mask2+# .endr - .rept 8 sec - ror char1+# + .rept 8 + ror char1+# ; in second (and next) lines we have C=1 - one SEC enough ror char2+# .endr dex @@ -1383,9 +1431,9 @@ MakeMask01 lsr mask1+# ror mask2+# .endr - .rept 4 sec - ror char1+# + .rept 4 + ror char1+# ; in second (and next) lines we have C=1 - one SEC enough ror char2+# .endr dex diff --git a/lib/atari.hea b/lib/atari.hea index 2d5e17b..36e9cfb 100755 --- a/lib/atari.hea +++ b/lib/atari.hea @@ -147,6 +147,7 @@ NMIST = $D40F ; rejestr statusu przerwa� NMI ;------------------------------------- ;additional system variables ;------------------------------------- +ATRACT = $004D COLPM0S = $02C0 ;- - shadow register COLPM0 COLPM1S = $02C1 ;- - shadow register COLPM1 COLPM2S = $02C2 ;- - shadow register COLPM2 diff --git a/scorch.asm b/scorch.asm index d35a891..b472b0c 100644 --- a/scorch.asm +++ b/scorch.asm @@ -36,7 +36,7 @@ ;we decided it must go in 'English' to let other people work on it .macro build - dta d"142" ; number of this build (3 bytes) + dta d"143" ; number of this build (3 bytes) .endm icl 'definitions.asm' @@ -98,6 +98,7 @@ icl 'lib/atari.hea' icl 'lib/macro.hea' + ;splash screen and musix icl 'artwork/HIMARS14.asm' ;Game loading address ORG $3000 @@ -117,13 +118,14 @@ START ; Startup sequence jsr Initialize - - jsr Options ;startup screen lda escFlag bne START jsr EnterPlayerNames + lda escFlag + bne START + jsr RandomizeSequence ; for the round #1 shooting sequence is random @@ -144,6 +146,9 @@ MainGameLoop jsr RoundInit jsr MainRoundLoop + lda escFlag + bne START + mva #0 TankNr ; jsr SortSequence @@ -248,51 +253,46 @@ skipzeroing ; the shooting angle is randomized ; of course gains an looses are zeroed - ;jsr StatusDisplay lda #0 tax -@ - sta singleRoundVars,x - inx - cpx #(singleRoundVarsEnd-singleRoundVars) +@ sta singleRoundVars,x + inx + cpx #(singleRoundVarsEnd-singleRoundVars) bne @- ldx #(MaxPlayers-1) SettingEnergies - lda #$00 - sta gainL,x - sta gainH,x - sta looseL,x - sta looseH,x - lda #99 - sta Energy,x - sta eXistenZ,x - sta LASTeXistenZ,x - ; anything in eXistenZ table means that this tank exist - ; in the given round - lda #<1000 - sta MaxForceTableL,x - lda #>1000 - sta MaxForceTableH,x - lda #<350 - sta ForceTableL,x - lda #>350 - sta ForceTableH,x - - ;lda #(255-45) - ;it does not look good when all tanks have - ;barrels pointing the same direction - ;so it would be nice to have more or less random - ;angles - jsr RandomizeAngle - sta AngleTable,x - - - dex + lda #$00 + sta gainL,x + sta gainH,x + sta looseL,x + sta looseH,x + lda #99 + sta Energy,x + sta eXistenZ,x + sta LASTeXistenZ,x + ; anything in eXistenZ table means that this tank exist + ; in the given round + lda #<1000 + sta MaxForceTableL,x + lda #>1000 + sta MaxForceTableH,x + lda #<350 + sta ForceTableL,x + lda #>350 + sta ForceTableH,x + + ;lda #(255-45) + ;it does not look good when all tanks have + ;barrels pointing the same direction + ;so it would be nice to have more or less random + ;angles + jsr RandomizeAngle + sta AngleTable,x + + dex bpl SettingEnergies - mva #0 CurrentResult - ;generating the new landscape jsr PMoutofScreen ;let P/M disappear jsr clearscreen ;let the screen be clean @@ -322,6 +322,7 @@ SettingEnergies ; tank with energy greater than 0 left ldy #0 ; in Y - number of tanks with energy greater than zero + sty ATRACT ; reset atract mode ldx NumberOfPlayers dex CheckingIfRoundIsFinished @@ -343,8 +344,7 @@ WhichTankWonLoop bne ThisOneWon dex bpl WhichTankWonLoop - ;error here!!! - ;stop + ;error was here!!! ; somehow I believed program will be never here ; but it was a bad assumption ; god knows when there is such a situation @@ -354,7 +354,6 @@ WhichTankWonLoop ; second tank explodes and kills the first one. ; and code lands here... ; looks like no one won! - rts ThisOneWon @@ -376,7 +375,6 @@ DoNotFinishTheRound jsr DisplaySeppuku jmp Seppuku - ;ldx TankNr @ ldx TankSequencePointer lda TankSequence,x @@ -394,12 +392,20 @@ DoNotFinishTheRound lda SkillTable,x beq ManualShooting -RoboTanks +RoboTanks ; robotanks shoot here jsr ArtificialIntelligence jsr MoveBarrelToNewPosition - jsr StatusDisplay ;all digital values like force, angle, wind, etc. + jsr DisplayStatus ;all digital values like force, angle, wind, etc. jsr PutTankNameOnScreen + lda kbcode + cmp #28 ; ESC + bne @+ + jsr AreYouSure + lda escFlag + seq:rts +@ + ; let's move the tank's barrel so it points the right ; direction jmp AfterManualShooting @@ -408,12 +414,14 @@ ManualShooting jsr WaitForKeyRelease jsr BeforeFire + lda escFlag + seq:rts AfterManualShooting inc noDeathCounter jsr DecreaseWeaponBeforeShoot - jsr StatusDisplay + jsr DisplayStatus ldx TankNr dec Energy,x ; lower energy to eventually let tanks commit suicide @@ -437,6 +445,7 @@ continueMainRoundLoopAfterSeppuku AfterExplode + ; TODO: IS IT OK??? possibly a fix here needed for #56 ldy WeaponDepleted bne @+ ldx TankNr @@ -474,11 +483,8 @@ missed jsr DisplayOffensiveTextNr NextPlayerShoots - ;mva #1 Erase - ;jsr drawtanks - - ;before it shoots, the eXistenZ table must be - ;updated accordingly to actual energy (was forgotten, sorry to ourselves) + ;before it shoots, the eXistenZ table must be updated + ;accordingly to actual energy (was forgotten, sorry to ourselves) ldx #(MaxPlayers-1) SeteXistenZ @@ -489,7 +495,7 @@ SeteXistenZ ;DATA L1,L2 ;Multiplication 8bit*8bit, ;result 16bit - ;this algiorithm is a little longer than in Ruszczyc 6502 book + ;this algiorithm is a little longer than one in Ruszczyc 6502 book ;but it is faster LDy #8 @@ -514,13 +520,6 @@ B0 DEY ;was setup of maximum energy for players - ;mva #0 Erase - ;jsr drawtanks - - inc:lda TankSequencePointer - cmp NumberOfPlayers - bne PlayersAgain - mva #0 TankSequencePointer PlayersAgain @@ -552,27 +551,14 @@ NoPlayerNoDeath dex bpl CheckingPlayersDeath ; if processor is here it means there are no more explosions + + inc:lda TankSequencePointer + cmp NumberOfPlayers + sne:mva #0 TankSequencePointer + jmp MainRoundLoop .endp -;--------------------------------- -.proc Seppuku - lda #0 - sta FallDown1 - sta FallDown2 - sta ydraw+1 - ; get position of the tank - ldx TankNr - lda xtankstableL,x - sta xdraw - lda xtankstableH,x - sta xdraw+1 - lda yTanksTable,x - sta ydraw - lda #1 ; Missile - jsr ExplosionDirect - jmp MainRoundLoop.continueMainRoundLoopAfterSeppuku -.endp ;--------------------------------- .proc PlayerXdeath @@ -605,8 +591,13 @@ NoPlayerNoDeath ldy TankTempY mva #1 plot4x4color jsr DisplayOffensiveTextNr + ; tank flash + ldy TankTempY + mva TankNr temp2 ; not elegant, and probably unnecessary + sty TankNr + jsr FlashTank ; blinking and pausing (like PAUSE 72 - 18x(2+2) ) + mva temp2 TankNr - PAUSE 75 ;Deffensive text cleanup ;here we clear Deffensive text (after a shoot) ldy TankTempY @@ -627,7 +618,7 @@ NoPlayerNoDeath sbc #4 sta ydraw lda #0 - sta ydraw+1 ; there is 0 left in A, so... TODO: bad code above. revisit when transitioning ydraw to byte + sta ydraw+1 ; there is 0 left in A, so... TODO: bad code above. revisit ;cleanup of the soil fall down ranges (left and right) sta RangeRight @@ -636,12 +627,9 @@ NoPlayerNoDeath sta FallDown2 mwa #screenwidth RangeLeft - - ; We are randomizing the weapon now. ; jumping into the middle of the explosion ; routine - MetodOfDeath lda random and #%00011111 ; range 0-31 @@ -652,13 +640,10 @@ MetodOfDeath jsr ExplosionDirect mva #sfx_silencer sfx_effect - ; jump to after explosion routines (soil fallout, etc.) ; After going through these routines we are back ; to checking if a tank exploded and maybe we have ; a deadly shot here again. - - jmp MainRoundLoop.AfterExplode .endp @@ -702,20 +687,52 @@ NotNegativeEnergy rts .endp +;--------------------------------- +.proc Seppuku + lda #0 + sta FallDown1 + sta FallDown2 + sta ydraw+1 + ; get position of the tank + ldx TankNr + lda xtankstableL,x + sta xdraw + lda xtankstableH,x + sta xdraw+1 + lda yTanksTable,x + sta ydraw + lda #1 ; Missile + jsr ExplosionDirect + jmp MainRoundLoop.continueMainRoundLoopAfterSeppuku +.endp + ;-------------------------------------------------- GetRandomWind .proc +;in: MaxWind (byte) +;out: Wind (word) +;uses: _ ;-------------------------------------------------- lda random cmp MaxWind bcs GetRandomWind ; if more than MaxWind then randomize again sta Wind mva #$00 Wind+1 - ; multiply Wind by 16 and take it as a decimal part (0.Wind) + sta Wind+2 + sta Wind+3 + ; multiply Wind by 16 + ; two bytes of Wind are treated as a decimal part of vx variable :4 aslw Wind + ; decide the direction lda random and #$01 - sta WindOrientation - rts + beq @+ + sec ; Wind = -Wind + .rept 4 + lda #$00 + sbc Wind+# + sta Wind+# + .endr +@ rts .endp ;-------------------------------------------------- @@ -733,34 +750,28 @@ PMoutofScreen .proc ;-------------------------------------------------- ldx #$3f lda #$0 -loop05 - sta TanksWeapon1,x - sta TanksWeapon2,x - sta TanksWeapon3,x - sta TanksWeapon4,x - sta TanksWeapon5,x - sta TanksWeapon6,x - dex - bne @+ - lda #99 - bne loop05 -@ bpl loop05 +@ + sta TanksWeapon1,x + sta TanksWeapon2,x + sta TanksWeapon3,x + sta TanksWeapon4,x + sta TanksWeapon5,x + sta TanksWeapon6,x + dex + sne:lda #99 + bpl @- rts .endp ;-------------------------------------------------- .proc Initialize ;Initialization sequence +;uses: temp, ... ;-------------------------------------------------- deletePtr = temp - lda #0 - sta Erase - sta tracerflag - sta GameIsOver - sta escFlag - ; clean variables + lda #0 tay mwa #variablesStart deletePtr @ tya @@ -1168,7 +1179,8 @@ nextishigher .endp ;-------------------------------------------------- -.proc getkey ; waits for pressing a key and returns pressed value in A +.proc GetKey ; waits for pressing a key and returns pressed value in A +; when [ESC] is pressed, escFlag is set to 1 ;-------------------------------------------------- jsr WaitForKeyRelease @ diff --git a/scorch.xex b/scorch.xex index a172763..bfbe522 100644 Binary files a/scorch.xex and b/scorch.xex differ diff --git a/textproc.asm b/textproc.asm index 46d8ae3..f48bd10 100644 --- a/textproc.asm +++ b/textproc.asm @@ -218,6 +218,8 @@ OptionsYLoop ManualPurchase jsr Purchase + ldx escFlag + seq:rts AfterManualPurchase inc:lda TankNr @@ -556,6 +558,8 @@ ChoosingItemForPurchase ;-------------------------------------------------- jsr PutLitteChar ; Places pointer at the right position jsr getkey + ldx escFlag + seq:rts cmp #$2c ; Tab jeq ListChange cmp #$0c ; Return @@ -838,7 +842,7 @@ NoArrowDown sta colpf2s ; set color of player name line jsr EnterPlayerName lda escFlag - jne START + seq:rts inc TankNr lda TankNr cmp NumberOfPlayers @@ -1342,11 +1346,9 @@ DOTNcharloop ldy #0 sty LineCharNr - TypeLine4x4Loop ldy LineCharNr - mwa LineAddress4x4 temp lda (temp),y cmp #$ff @@ -1366,6 +1368,63 @@ EndOfTypeLine4x4 .endp +;-------------------------------- +.proc AreYouSure +;using 4x4 font + + ;save vars (messed in TypeLine4x4) + mwa Xdraw xk + mva Ydraw yc + + mva #4 ResultY ; where seppuku text starts Y-wise on the screen + + ;top frame + mva ResultY LineYdraw + jsr TL4x4_top + adb ResultY #4 ;next line + + ;seppuku + mwa #areYouSureText LineAddress4x4 + mwa #((ScreenWidth/2)-(8*4)) LineXdraw ; centering + mva ResultY LineYdraw + jsr TypeLine4x4 + adb ResultY #4 ;next line + + ;bottom frame + mva ResultY LineYdraw + jsr TL4x4_bottom + + + jsr GetKey + cmp #$2b ; "Y" + bne @+ + mva #1 escFlag + bne skip01 +@ mva #0 escFlag + jsr WaitForKeyRelease +skip01 + + ;clean + mva #3 dx + mva #4 ResultY +@ + mva #1 plot4x4color + mwa #lineClear LineAddress4x4 + mwa #((ScreenWidth/2)-(8*4)) LineXdraw ; centering + mva ResultY LineYdraw + jsr TypeLine4x4 + adb ResultY #4 ;next line + + dec dx + bne @- + + +quit_areyousure + ;restore vars + mva yc Ydraw + mwa xk Xdraw + rts +.endp ;-------------------------------- .proc DisplaySeppuku ;using 4x4 font @@ -1383,10 +1442,8 @@ seppuku_loop mva #4 ResultY ; where seppuku text starts Y-wise on the screen ;top frame - mwa #LineTop LineAddress4x4 - mwa #((ScreenWidth/2)-(8*4)) LineXdraw ; centering mva ResultY LineYdraw - jsr TypeLine4x4 + jsr TL4x4_top adb ResultY #4 ;next line ;seppuku @@ -1397,17 +1454,14 @@ seppuku_loop adb ResultY #4 ;next line ;bottom frame - mwa #LineBottom LineAddress4x4 - mwa #((ScreenWidth/2)-(8*4)) LineXdraw ; centering mva ResultY LineYdraw - jsr TypeLine4x4 + jsr TL4x4_bottom ; just go ;clean seppuku mva #3 dx mva #4 ResultY @ - mva #1 plot4x4color mwa #lineClear LineAddress4x4 mwa #((ScreenWidth/2)-(8*4)) LineXdraw ; centering mva ResultY LineYdraw @@ -1432,18 +1486,15 @@ quit_seppuku ;using 4x4 font mva #sfx_smoke_cloud sfx_effect - + mva #1 plot4x4color + ;centering the result screen - mwa #((ScreenWidth/2)-(8*4)) ResultX mva #((ScreenHeight/2)-(8*4)) ResultY ;upper frame - mwa #LineTop LineAddress4x4 - mwa ResultX LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color - jsr TypeLine4x4 + jsr TL4x4_top adb ResultY #4 ;next line @@ -1458,17 +1509,15 @@ quit_seppuku jsr displaybyte ;decimal (byte), displayposition (word) mwa #LineHeader1 LineAddress4x4 - mwa ResultX LineXdraw + mwa #((ScreenWidth/2)-(8*4)) LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color jsr TypeLine4x4 beq @+ ;unconditional jump, because TypeLine4x4 ends with beq GameOver4x4 mwa #LineGameOver LineAddress4x4 - mwa ResultX LineXdraw + mwa #((ScreenWidth/2)-(8*4)) LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color jsr TypeLine4x4 mva #1 GameIsOver @@ -1476,30 +1525,23 @@ GameOver4x4 adb ResultY #4 ;next line ;Empty line - mwa #LineEmpty LineAddress4x4 - mwa ResultX LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color - jsr TypeLine4x4 + jsr TL4x4_empty adb ResultY #2 ;next line ;Header2 mwa #LineHeader2 LineAddress4x4 - mwa ResultX LineXdraw + mwa #((ScreenWidth/2)-(8*4)) LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color jsr TypeLine4x4 adb ResultY #4 ;next line ;Empty line - mwa #LineEmpty LineAddress4x4 - mwa ResultX LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color - jsr TypeLine4x4 + jsr TL4x4_empty sbb ResultY #2 ;next line (was empty) @@ -1564,24 +1606,17 @@ TankNameCopyLoop ;result line display mwa #ResultLineBuffer LineAddress4x4 - mwa ResultX LineXdraw + mwa #((ScreenWidth/2)-(8*4)) LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color jsr TypeLine4x4 adb ResultY #4 ;next line ;Empty line - mwa #LineEmpty LineAddress4x4 - mwa ResultX LineXdraw mva ResultY LineYdraw - mva #1 plot4x4color - jsr TypeLine4x4 - - + jsr TL4x4_empty dec ResultOfTankNr - bmi FinishResultDisplay sbb ResultY #2 ;distance between lines is smaller @@ -1589,25 +1624,35 @@ TankNameCopyLoop jmp ResultOfTheNextPlayer FinishResultDisplay + mva ResultY LineYdraw + ;jmp TL4x4_bottom ; just go +.endp +.proc TL4x4_bottom ;bottom of the frame mwa #LineBottom LineAddress4x4 - mwa ResultX LineXdraw - mva ResultY LineYdraw - mva #1 plot4x4color - jsr TypeLine4x4 - rts + mwa #((ScreenWidth/2)-(8*4)) LineXdraw + jmp TypeLine4x4 ; jsr:rts +.endp + +.proc TL4x4_top + ;bottom of the frame + mwa #LineTop LineAddress4x4 + mwa #((ScreenWidth/2)-(8*4)) LineXdraw + jmp TypeLine4x4 ; jsr:rts +.endp + +.proc TL4x4_empty + ;empty frame + mwa #LineEmpty LineAddress4x4 + mwa #((ScreenWidth/2)-(8*4)) LineXdraw + jmp TypeLine4x4 ; jsr:rts .endp ;------------------------------------------------- -.proc StatusDisplay +.proc DisplayStatus ;------------------------------------------------- - ;lda noDeathCounter - ;sta decimal - ;mwa #textbuffer+80+37 displayposition - ;jsr displaybyte - ;--------------------- ;displaying symbol of the weapon ;--------------------- @@ -1711,35 +1756,39 @@ AngleDisplay mwa #textbuffer+40+21 displayposition jsr displaybyte - ;========================= ;display Wind ;========================= - lda WindOrientation - bne DisplayLeftWind + mwa Wind temp + lda Wind+3 ; highest byte of 4 byte wind + bmi DisplayLeftWind lda #$7f ; (tab) char sta textbuffer+80+28 lda #0 ;space sta textbuffer+80+25 beq DisplayWindValue DisplayLeftWind + sec ; Wind = -Wind + lda #$00 + sbc temp + sta temp + lda #$00 + sbc temp+1 + sta temp+1 lda #$7e ;(del) char sta textbuffer+80+25 lda #0 ;space sta textbuffer+80+28 DisplayWindValue - mwa Wind temp - lsrw temp ;divide by 16 to have - lsrw temp ;a nice view on a screen - lsrw temp - lsrw temp + :4 lsrw temp ;divide by 16 to have a nice value on a screen lda temp sta decimal mwa #textbuffer+80+26 displayposition jsr displaybyte - + ;========================= ;display round number + ;========================= lda CurrentRoundNr sta decimal mwa #textbuffer+80+14 displayposition diff --git a/variables.asm b/variables.asm index 4247ef3..47c1ce9 100644 --- a/variables.asm +++ b/variables.asm @@ -8,35 +8,30 @@ ; compilation to e.g. cartridge ; zero page variables are declared in program.s65 module ;===================================================== -;-------------------------------------------------- -;Variables -;-------------- TanksNames ; DO NOT ZERO - ticket #24 :6 dta d" " -;---------------------------- +;---------------------------------------------------- ;Options DO NOT ZERO - ticket #27 OptionsTable .by 0,0,2,2,0,1,3 RoundsInTheGame .by 10 ;how many rounds in the current game seppukuVal .by 75 -;-------------------------------------------------- +;---------------------------------------------------- skilltable ; computer controlled players' skills (1-8), 0 - human (no cleaning, ticket #30) .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- ; 4x4 text buffer ResultLineBuffer - dta d" " - .byte $ff + dta d" ", $ff LineHeader1 dta d"# ROUND: " RoundNrDisplay - dta d" #" - .byte $ff + dta d" #", $ff +;===================================================== variablesStart ; zeroing starts here +;===================================================== drawFunction .ds 1 ; 0 - plot, %10000000 - LineLength (N), %01000000 - DrawCheck (V) ;-------------- -escFlag .ds 1 -;-------------- sfx_effect .ds 1 ;-------------- noDeathCounter .ds 1 @@ -47,28 +42,28 @@ flyDelay .ds 1 NumberOfPlayers .DS 1 ;current number of players (counted from 1) TankSequence .DS [MaxPlayers] ;sequence of shooting during the Round GameIsOver .DS 1 ; 1 means it was the last round in the game -;----------------------------------- +;---------------------------------------------------- moneyH ;we place zero at the end of prices and money ;and have range from 0 to 99990 (not too much) ;money players have (maybe one more byte is needed?) .DS [MaxPlayers] moneyL .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- gainH ;how much money player gets after the round ;it is gathered during the round basing on energy ;opponents loose after player's shoots .DS [MaxPlayers] gainL .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- looseH ;how much player looses after the round ;calculated from REAL energy loss ;(not only to zero energy) .DS [MaxPlayers] looseL .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- Energy .DS [MaxPlayers] EnergyDecrease .DS 1 @@ -81,9 +76,7 @@ ResultsTable ;the results in the gameeeeee .DS [MaxPlayers] TempResults .DS [MaxPlayers] -CurrentResult - .DS 1 -;----------------------------------- +;---------------------------------------------------- ForceTableL ;shooting Force of the tank during the round .DS [MaxPlayers] ForceTableH @@ -93,35 +86,36 @@ MaxForceTableL ;Energy of the tank during the round .DS [MaxPlayers] ;1000 is the default MaxForceTableH .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- AngleTable ;Angle of the barrel of each tank during the round .DS [MaxPlayers] NewAngle .DS 1 -;----------------------------------- +;---------------------------------------------------- ActiveWeapon ;number of the selected weapon .DS [MaxPlayers] WeaponDepleted .DS 1 ; if 0 deactivate the weapon and switch to Baby Missile -;----------------------------------- +;---------------------------------------------------- ;format of the 3-byte static point number used in the game ; 20203.5 => 128 : <20203 : >20203 -;----------------------------------- +;---------------------------------------------------- L1 .DS 1 ; variable used in multiplications (by 10:) gravity .DS 1 ;only the decimal part (1/10 = 25) -;----------------------------------- +;---------------------------------------------------- -Wind .ds 2 ;walue displayed on the screen - ;multiplied by 16 (decimal part only) -;----------------------------------- +Wind .ds 4 ;format: 0000.hhll + ;walue displayed on the screen is + ;decimal portion divided by 16 (>>4) +;---------------------------------------------------- MaxWind .ds 1 ; WindOrientation .DS 1 ;(0-right,1-left) -;----------------------------------- +;---------------------------------------------------- Counter .DS 1 ;temporary Counter for outside loops HitFlag .DS 1 ;1 when missile hit anything -;----------------------------------- +;---------------------------------------------------- xtankstableL ;X positions of tanks (lower left point) .DS [MaxPlayers] xtankstableH @@ -130,17 +124,17 @@ ytankstable ;Y positions of tanks (lower left point) .DS [MaxPlayers] LowResDistances ; coarse tank positions divided by 4 (to be in just one byte) .DS [MaxPlayers] -;----------------------------------- +;---------------------------------------------------- Erase .DS 1 ; if 1 only mask of the character is printed ; on the graphics screen. if 0 character is printed normally -;----------------------------------- +;---------------------------------------------------- RangeLeft .DS 2 ;range of the soil to be fallen down RangeRight .DS 2 ;it is being set by all Explosions -;----------------------------------- +;---------------------------------------------------- WeaponRangeLeft .DS 2 ;Range of the Explosion of the given weapon WeaponRangeRight .DS 2 -;-------------------------------------------------- +;---------------------------------------------------- ;xroller HowMuchToFall .ds 1 HeightRol .DS 1 @@ -173,14 +167,14 @@ LineLength .DS 2 ;circle radius .DS 1 xcircle .DS 2 -ycircle .DS 1 +ycircle .DS 2 tempcir .DS 2 ;TankFalls IfFallDown .DS 1 PreviousFall .DS 1 EndOfTheFallFlag .DS 1 ; in case of the infinite fall Parachute .DS 1 ; are you insured with parachute? -; ------------------------------------------------- +;---------------------------------------------------- ;Flight ;variables for 5 missiles (used for mirv) xtraj00 .DS [5] ; 3 bytes of xtraj times 5. Lowest byte @@ -193,7 +187,9 @@ vx03 .DS [5] MirvDown .DS [5] ; is given missile down? MirvMissileCounter .DS 1 ; missile Counter (mainly for X) SmokeTracerFlag .DS 1 ; if Smoketracer -; ------------------------------------------------- +XposFlag .DS 1 ; bullet positon X (0 - on screen , %1000000 - off-screen) +YposFlag .DS 1 ; bullet positon Y (0 - on screen , %1000000 - over the screen , %0100000 - under the screen) +;---------------------------------------------------- ;CheckCollisionWithTank vx .ds 4 ; 0,0,0,0 ;two decimal bytes, two whole bytes (DC.BA) vy .ds 4 ;0,0,0,0 @@ -205,12 +201,11 @@ Angle .DS 1 Force .ds 3 ; 0,0,0 Multiplier .ds 3 ; 0,0,0 Multiplee .ds 2 ; 0,0 -Result .ds 3 ; 0,0,0 goleft .DS 1 ;if 1 then flights left -;-------------------------------------------------- +;---------------------------------------------------- ;SoilDown2 IsEndOfTheFallFlag .DS 1 -; ------------------------------------------------- +;---------------------------------------------------- ;unPlot WhichUnPlot .DS 1 ; max 5 concurrent unPlots @@ -224,7 +219,7 @@ xtrajfb .DS 2 ytrajfb .DS 2 ; tracerflag .DS 1 -; ------------------------------------------------- +;---------------------------------------------------- ;TypeChar mask1 .DS [8] mask2 .DS [8] @@ -242,7 +237,7 @@ UpNdown .DS 1 temptankX .DS 2 temptankNr .DS 1 -; ------------------------------------------------- +;---------------------------------------------------- ;Variables from textproc.s65 ; tables with numbers of weapons on the right lists ; to be honest - I do not know at the moment what the above @@ -252,7 +247,7 @@ NubersOfWeaponsL1 .ds 8*5 ; :(8*5) .by $ff NubersOfWeaponsL2 .ds 8*2 ; :(8*2) .by $ff -; ------------------------------------------------- +;---------------------------------------------------- ; variables storing amount of weapons on the first and second ; list and pointer position @@ -275,14 +270,14 @@ WhichList ; list currently on the screen OffsetDL1 ; offset of the list screen (how many lines).... .DS 1 -; ------------------------------------------------- +;---------------------------------------------------- ;mark the level PositionInName ; cursor position in name of the player when name input .DS 1 DifficultyLevel ; Difficulty Level (human/cpu) .DS 1 -;------------------------------------------------- +;---------------------------------------------------- ;displaydecimal decimal .DS 2 decimalresult .DS 4 @@ -297,7 +292,7 @@ FallDown2 .DS 1 LeapFrogAngle .DS 1 ;laser LaserCoordinate .DS 8 ; 2,2,2,2 -; ------------------------------------------------- +;---------------------------------------------------- ; Here go tables with weapons possesed by a given tank ; Index in the table means weapon type ; number entered means ammo for given weapon possessed (max 99) @@ -324,7 +319,7 @@ mountaintable2 ;table of mountains (size=screenwidth) .DS [screenwidth] .DS 1 ; additional byte for fallout (sometimes 1 pixel) MountaintableEnd ;good for table clearing -;---------------------------------------------- +;---------------------------------------------------- TextPositionX .DS 2 TextPositionY .DS 1 TextAddress .DS 2 @@ -333,8 +328,16 @@ TextNumberOff .DS 1 ;-------------- TankTempY .DS 1 +;---------------------------------------------------- ;-------------- single round variables -------------- +;---------------------------------------------------- singleRoundVars +;-------------- +escFlag .ds 1 +;-------------- +CurrentResult + .DS 1 +;-------------- previousAngle .DS [MaxPlayers] previousEnergyL @@ -352,9 +355,9 @@ RandBoundaryHigh AngleTablePointer .DS 1 singleRoundVarsEnd -;---------------------------------------------- +;---------------------------------------------------- ; 4x4 texts -;---------------------------------------------- +;---------------------------------------------------- LineAddress4x4 .DS 2 LineCharNr @@ -372,8 +375,9 @@ ResultY ResultOfTankNr .DS 1 -;---------------------------- +;---------------------------------------------------- ;PutChar4x4 +;---------------------------------------------------- LoopCounter4x4 .DS 1 y4x4 .DS 1 StoreA4x4 .DS 1 @@ -385,6 +389,6 @@ plot4x4color .DS 1 ;1-white, 0-background variablesEnd -;---------------------------- +;---------------------------------------------------- .endif diff --git a/weapons.asm b/weapons.asm index fa3bcbd..ba6da9e 100644 --- a/weapons.asm +++ b/weapons.asm @@ -262,7 +262,7 @@ NoExplosionInFunkyBomb mva #sfx_nuke sfx_effect jsr xmissile NoUpperCircle - adb ydraw #70 + adw ydraw #70 ;jsr CalculateExplosionRange cpw ydraw #screenHeight bcs NoLowerCircle @@ -529,21 +529,25 @@ DiggerCharacter .endp ; ------------------------ .proc laser +; but where are xdraw and ydraw ???? !!!! +; ------------------------ ldx TankNr lda AngleTable,x tay clc lda xtankstableL,x - adc EndOfTheBarrelX,y ; correction of the end of the barrel point + adc EndOfTheBarrelX,y ; correction of the end of the barrel point (X) sta xbyte lda xtankstableH,x adc #0 sta xbyte+1 sec lda ytankstable,x - sbc EndOfTheBarrelY,y + sbc EndOfTheBarrelY,y ; correction of the end of the barrel point (Y) sta ybyte - mva #0 ybyte+1 + lda #$00 + sbc #$00 + sta ybyte+1 mva #0 drawFunction mwa xdraw LaserCoordinate mwa ydraw LaserCoordinate+2 @@ -677,9 +681,9 @@ EndOfDistanceCheckLoop sta color dirtLoop jsr circle - inc ydraw + inw ydraw jsr circle - dec ydraw +.nowarn dew ydraw inc radius lda radius cmp ExplosionRadius @@ -725,6 +729,7 @@ RollinContinues ldy #0 lda (tempXROLLER),y sta ydraw + sty ydraw+1 beq ExplodeNow cmp HeightRol beq UpNotYet @@ -737,8 +742,6 @@ UpNotYet ;check tank collision prior to PLOT sty HitFlag - mwa xdraw xtraj+1 - mwa ydraw ytraj+1 jsr CheckCollisionWithTank lda HitFlag @@ -760,12 +763,12 @@ HowMuchToFallRight2 jne RollinContinues ExplodeNow mwa xdraw xcircle ; we must store somewhere (BAD) - mva ydraw ycircle ; xdraw and ydraw (BAD) + mwa ydraw ycircle ; xdraw and ydraw (BAD) mwa #0 xdraw - mva #screenheight-1 ydraw + mwa #screenheight-1 ydraw jsr unPlot mwa xcircle xdraw ;(bad) - mva ycircle ydraw ;(bad) + mwa ycircle ydraw ;(bad) ; finally a little explosion jsr CalculateExplosionRange @@ -782,6 +785,7 @@ ExplodeNow adw tempXROLLER xdraw lda (tempXROLLER),y sta ydraw + sty ydraw+1 lda vx+3 ; if horizontal velocity is negative then change the direction @@ -852,7 +856,7 @@ DirectionChecked mva #1 color NoColor ; jump here with color=0 to clean dirt mwa xdraw xcircle - mva ydraw ycircle + mwa ydraw ycircle lda #1 ; current dirt width sta magic @@ -890,14 +894,14 @@ DoNotPlot bne NextRow EndOfTheDirt mwa xcircle xdraw - mva ycircle ydraw + mwa ycircle ydraw rts .endp ; ---------------- .proc xliquiddirt ; - mva xdraw TempXfill + mwa xdraw TempXfill RepeatFill - mva TempXfill xdraw + mwa TempXfill xdraw jsr checkRollDirection ; HowMuchToFall - direction ; $FF - we are in a hole (flying in missile direction) @@ -987,7 +991,7 @@ ContinueToCheckMaxForce2 lda MaxForceTableL,x sta ForceTableL,x @ - jsr StatusDisplay ;all digital values like force, angle, wind, etc. + jsr DisplayStatus ;all digital values like force, angle, wind, etc. jsr PutTankNameOnScreen jsr DrawTankNr @@ -1012,7 +1016,17 @@ notpressed beq checkJoy lda kbcode - and #$Bf + and #%10111111 ; SHIFT elimination + + cmp #28 ; ESC + bne @+ + jsr AreYouSure + lda escFlag + beq notpressed + ;---esc pressed-quit game--- + rts + +@ cmp #$8e jeq CTRLPressedUp cmp #$8f @@ -1100,9 +1114,9 @@ pressedDown dec ForceTableH,x bpl @+ ForceGoesZero - lda #0 - sta ForceTableH,x - sta ForceTableL,x + lda #0 + sta ForceTableH,x + sta ForceTableL,x @ jmp BeforeFire @@ -1235,33 +1249,24 @@ AfterStrongShoot mva #sfx_shoot sfx_effect ; Shoots tank nr X !!! :) - ;ldx TankNr - lda xtankstableL,x - sta xtraj+1 - lda xtankstableH,x - sta xtraj+2 - lda ytankstable,x - sta ytraj+1 - lda #$00 - sta ytraj+2 - - ; correction of the starting coordinates of bullet + ; set the starting coordinates of bullet with correction ; to start where the tank's barrel ends ; (without it bullet would go from the left lower corner of the tank) - ldy Angle - clc - lda xtraj+1 - adc EndOfTheBarrelX,y ; correction of X + ;ldx TankNr + ldy Angle + clc + lda xtankstableL,x + adc EndOfTheBarrelX,y ; correction of X sta xtraj+1 - lda xtraj+2 - adc #0 + lda xtankstableH,x + adc #$00 sta xtraj+2 - sec - lda ytraj+1 - sbc EndOfTheBarrelY,y ; correction of Y + sec + lda ytankstable,x + sbc EndOfTheBarrelY,y ; correction of Y sta ytraj+1 - lda ytraj+2 - sbc #0 + lda #$00 + sbc #$00 sta ytraj+2 jsr Flight @@ -1506,7 +1511,8 @@ ThereWasNoParachute .endp ;-------------------------------------------------- -.proc Flight ; Force(byte.byte), Angle(byte), Wind(.byte) 128=0, 255=maxright, 0=maxleft +.proc Flight ; Force(byte.byte), Wind(0.word) +; Angle(byte) 128=0, 255=maxright, 0=maxleft ;-------------------------------------------------- ;g=-0.1 ;vx=Force*sin(Angle) @@ -1536,9 +1542,9 @@ RepeatIfSmokeTracer mva #%01000000 drawFunction lda #0 - sta Result - sta Result+1 - sta Result+2 + sta vx + sta vx+1 + sta vx+2 sta HitFlag sta xdraw sta xdraw+1 @@ -1559,7 +1565,7 @@ RepeatIfSmokeTracer ;255-90 (165) horizontally left bpl FlightRight - + ;and if the highest bit is set then ;Flight to LEFT ;calculate Angle with this formula: @@ -1568,24 +1574,23 @@ RepeatIfSmokeTracer sec txa sbc #165 ;(Angle-165) - sta temp ;dirty trick with selfmodifying code (REMOVED) - lda #90 ; + sta temp + lda #90 sbc temp ;90-(Angle-165) ;and we have rady angle here ... and we go LEFT! tax sta Angle - mva #1 goleft + ; and now we contine as if nothing happened ; (but we have goleft set to 1!!!) - bne dontzerogoleft + mva #1 goleft + bne @+ FlightRight mva #0 goleft - -dontzerogoleft - +@ lda sintable,x ;sin(Angle) - sta Multiplee ;sin(Angle)*Force + sta Multiplee ;sin(Angle)*Force mwa Force Multiplier lda #$0 sta Multiplier+2 @@ -1595,14 +1600,14 @@ MultiplyLoop bcc DoNotAdd clc lda Multiplier - adc Result - sta Result + adc vx + sta vx lda Multiplier+1 - adc Result+1 - sta Result+1 + adc vx+1 + sta vx+1 lda Multiplier+2 - adc Result+2 - sta Result+2 + adc vx+2 + sta vx+2 DoNotAdd ;clc ;carry always cleared here (anyway we hope so :) rol Multiplier @@ -1610,21 +1615,24 @@ DoNotAdd rol Multiplier+2 dex bne MultiplyLoop - ; here in Result there is a number xxxx.yyy = sin(Angle)*Force - - lda Result ;vx=sin(Angle)*Force - sta vx - lda Result+1 - sta vx+1 - lda Result+2 - sta vx+2 + mva #0 vx+3 - + ; here in vx there is a number + ; xxxx.xx00 = sin(Angle)*Force + ; negate it if going left + lda goleft + beq @+ + .rept 4 + lda #$00 + sbc vx+# + sta vx+# + .endr +@ ;======vy lda #0 ;cos(Angle) - sta Result - sta Result+1 - sta Result+2 + sta vy + sta vy+1 + sta vy+2 ;-- lda #90 sec @@ -1642,14 +1650,14 @@ MultiplyLoopY bcc DoNotAddY clc lda Multiplier - adc Result - sta Result + adc vy + sta vy lda Multiplier+1 - adc Result+1 - sta Result+1 + adc vy+1 + sta vy+1 lda Multiplier+2 - adc Result+2 - sta Result+2 + adc vy+2 + sta vy+2 DoNotAddY ;clc ;carry always cleared here (anyway we hope so :) rol Multiplier @@ -1657,15 +1665,10 @@ DoNotAddY rol Multiplier+2 dex bne MultiplyLoopY - ; here in Result there is a number xxxx.yyy=cos(Angle)*Force + ; here in vy there is a number + ; yyyy.yy=cos(Angle)*Force - lda Result ;vy=cos(Angle)*Force - sta vy - lda Result+1 - sta vy+1 - lda Result+2 - sta vy+2 - mva #0 vy+3 + mva #0 vy+3 ;vy=cos(Angle)*Force Loopi ;ytraj=ytraj-vy (skipping least significant byte of vy) @@ -1699,8 +1702,7 @@ Loopi cmp #6 ; MIRV jeq MIRVdownLoop StillUp - lda goleft - bne FlightLeft + clc ;xtraj=xtraj+vx (skipping least significant byte of vx) lda xtraj ;here of course Fight to right @@ -1712,66 +1714,13 @@ StillUp lda xtraj+2 adc vx+3 sta xtraj+2 - jmp @+ ;skipping substracting for Flight to left -FlightLeft - sec ;xtraj=xtraj-vx (skipping least significant byte of vx) - lda xtraj ;here of course Fight to left - sbc vx+1 - sta xtraj - lda xtraj+1 - sbc vx+2 - sta xtraj+1 - lda xtraj+2 - sbc vx+3 - sta xtraj+2 - -@ - ;vx=vx-Wind (also without least significan byte of vx) - lda goleft - bne FlightsLeft ;blow on bullet flighting left - lda WindOrientation - bne LWindToRight - beq LWindToLeft -FlightsLeft - lda WindOrientation - beq LWindToRight - -LWindToLeft - ; here Wind to right, bullet goes right as well, so vx=vx+Wind - ; here Wind to left, bullet goes left as well, so vx=vx+Wind clc - lda vx - adc Wind - sta vx - lda vx+1 - adc Wind+1 - sta vx+1 - lda vx+2 - adc #0 - sta vx+2 - lda vx+3 - adc #0 - sta vx+3 - jmp @+ - -LWindToRight - ;Wind to left, bullet right, so vx=vx-Wind - ;Wind to right, bullet left, so vx=vx-Wind - sec - lda vx - sbc Wind - sta vx - lda vx+1 - sbc Wind+1 - sta vx+1 - lda vx+2 - sbc #0 - sta vx+2 - lda vx+3 - sbc #0 - sta vx+3 -@ + .rept 4 + lda vx+# + adc Wind+# + sta vx+# + .endr mwa xtrajold+1 xdraw mwa ytrajold+1 ydraw mwa xtraj+1 xbyte @@ -1792,7 +1741,7 @@ nowait lda HitFlag bne Hit - cpw ytraj+1 #screenheight + cpw ytraj+1 #screenheight+1 bcc YTrayLowerThanScreenHeight lda ytraj+2 bpl EndOfFlight @@ -1820,12 +1769,12 @@ Hit jsr unPlot EndOfFlight mwa xdraw xcircle ; we must store for a little while - mva ydraw ycircle ; xdraw and ydraw .... but this values are in YHit and XHit !!! + mwa ydraw ycircle ; xdraw and ydraw .... but this values are in YHit and XHit !!! mwa #0 xdraw - mva #screenheight-1 ydraw + mwa #screenheight-1 ydraw jsr unPlot mwa xcircle xdraw - mva ycircle ydraw + mwa ycircle ydraw ; mwa XHit xdraw ; mva YHit ydraw @@ -1839,7 +1788,7 @@ EndOfFlight2 rts .endp -SecondFlight .proc +.proc SecondFlight ; ---------------- copied code fragment from before firing. not too elegant. ; ---------------- get fire parameters again ldx TankNr @@ -1890,7 +1839,7 @@ SecondFlight .proc .endp ; ------------------------------------------------- -MIRVdownLoop .proc +.proc MIRVdownLoop ; MIRV loop - here mirv bullets fall down ; ------------------------------------------------- ; copy Flight parameters to the table @@ -2011,8 +1960,6 @@ MIRVdoNotChangeY lda MirvDown,x ; if bullet is already down we go with the next one jne MIRVnextBullet - lda goleft - bne mrFlightLeft clc ;xtraj=xtraj+vx (skipping the least significant byte of vx) lda xtraj00,x ;and here of course Flight to the right @@ -2024,104 +1971,90 @@ MIRVdoNotChangeY lda xtraj02,x adc vx03,x sta xtraj02,x - jmp mrskip07 ;skip substracting for Flight to the left -mrFlightLeft - sec ;xtraj=xtraj-vx (skipping the least significant byte of vx) - lda xtraj00,x ;here of course Flight to the left - sbc vx01,x - sta xtraj00,x - lda xtraj01,x - sbc vx02,x - sta xtraj01,x - lda xtraj02,x - sbc vx03,x - sta xtraj02,x + ;vx=vx+Wind - -mrskip07 - ;vx=vx-Wind (also without least significan byte of vx) - - lda goleft - bne mrFlightsLeft ;blow on bullet flighting left - lda WindOrientation - bne mrWindToLeft - beq mrLWindToLeft -mrFlightsLeft - lda WindOrientation - beq mrLWindToRight -mrLWindToLeft - ; here Wind to right, bullet goes right as well, so vx=vx+Wind - ; here Wind to left, bullet goes left as well, so vx=vx+Wind clc - lda vx00,x - adc Wind - sta vx00,x - lda vx01,x - adc Wind+1 - sta vx01,x - lda vx02,x - adc #0 - sta vx02,x - lda vx03,x - adc #0 - sta vx03,x - Jmp mrskip08 -mrWindToLeft -mrLWindToRight - ;Wind to left, bullet right, so vx=vx-Wind - ;Wind to right, bullet left, so vx=vx-Wind - sec - lda vx00,x - sbc Wind - sta vx00,x - lda vx01,x - sbc Wind+1 - sta vx01,x - lda vx02,x - sbc #0 - sta vx02,x - lda vx03,x - sbc #0 - sta vx03,x -mrskip08 + .rept 4 + lda vx+# + adc Wind+# + sta vx+# + .endr - ; isn't it over the screen???? - lda ytraj+2 ;attention! this checks getting out of the screen through bottom - bmi MIRVcheckX ;but not that accurately.... - lda ytraj+1 - cmp #screenheight - jcs mrEndOfFlight ; if smaller than screenheight then continue (and it will always fall down...) -MIRVcheckX - lda xtraj02,x + ; rules for a falling MIRV bulets. + ; if Y is negative and any X (bullet over the screen) - continue flying + ; if (Y>=0 and Y<=screenhight) and X>screenwidth (bullet off-screen on the left or right side) - continue flying + ; if (Y>=0 and Y<=screenhight) and X<=screenwidth (bullet on the screen) - check collision + ; if Y>screenhight and X>screenwidth (bullet under the screen on the left or right side) - stop flying without hit + ; if Y>screenhight and X<=screenwidth (bullet under the screen) - check collision (allways hit) + + ; check bullet position and set flags: + ; XposFlag - bullet positon X (0 - on screen , %1000000 - off-screen) + ; YposFlag - bullet positon Y (0 - on screen , %1000000 - over the screen , %0100000 - under the screen) + lda #$00 + sta XposFlag + sta YposFlag + lda ytraj+2 ; Y high byte + bpl @+ + mva #%10000000 YposFlag ; bullet over the screen (Y) + bmi MIRVsetXflag +@ + lda ytraj+1 ; Y low byte + cmp #screenheight + bcc MIRVsetXflag ; bullet on screen (Y) + mva #%01000000 YposFlag ; bullet under the screen (Y) +MIRVsetXflag + lda xtraj02,x ; X high byte cmp #>screenwidth - beq MIRVcheckLowerX - bcc MIRVcheckCollision - ; it's over the screen horizontally (to the left or right) - mwa #0 xdraw - mva #screenheight-1 ydraw - jsr unPlot.unPlotAfterX - jmp mrLoopi -MIRVcheckLowerX - lda xtraj01,x + bne @+ + lda xtraj01,x ; X low byte cmp #