10 ;EFT VERSION 1.8C (COMBAT) 11/30/81 COPYRIGHT CHRIS CRAWFORD 1981›20 ;›30 ;Page zero RAM›40 ;›50 ;These locations are for the mainline routines›60 ;›70 CHUNKX=$BE›80 CHUNKY=$BF›90 CORPS=$B4›0100 *=$C0›0110 MAPPTR *=*+2›0120 ARMY *=*+1›0130 UNITNO *=*+1›0140 DEFNDR *=*+1›0150 TEMPR *=*+1›0160 TEMPZ *=*+1›0170 ACCLO *=*+1›0180 ACCHI *=*+1›0190 TURN *=*+1›0200 LAT *=*+1›0210 LONG *=*+1›0220 RFR *=*+1›0230 TRNTYP *=*+1›0240 SQVAL *=*+1›0250 ;›0260 ;›0270 CONSOL=$D01F›0280 AUDF1=$D200›0290 AUDC1=$D201›0300 RANDOM=$D20A›0310 NMIEN=$D40E›0320 ;›0330 ;THESE VALUES ARE USED BY MAINLINE ROUTINE ONLY›0340 ;›0350 EARTH=$606›0360 TRNCOD=$62B›0370 *=$636›0380 SQX *=*+1 adjacent square›0390 SQY *=*+1›0400 *=$68E›0410 DELAY *=*+1›0420 HANDCP *=*+1›0430 TOTGS *=*+1›0440 TOTRS *=*+1›0450 OFR *=*+1›0460 HOMEDR *=*+1›0470 ZOC *=*+1›0480 TEMPQ *=*+1›0490 LLIM *=*+1›0500 VICTRY *=*+1›0510 ;›0520 ;declarations of routines in other modules›0530 ;›0540 INVERT=$4D26›0550 STALL=$7200›0560 TERR=$7240›0570 TERRB=$7246›0580 Y00=$72DE›0590 TERRTY=$7369›0600 DNUMBR=$7BB2›0610 JSTP=$799C›0620 DWORDS=$79C0›0630 SWITCH=$79EF›0640 DEFNC=$79B4›0650 OFFNC=$7BF6›0660 XINC=$7BF2›0670 YINC=$7BF1›0680 ;›0690 *=$5400›0700 CORPSX *=*+159 x-coords of all units (pixel frame)›0710 CORPSY *=*+159 y-coords of all units (pixel frame)›0720 MSTRNG *=*+159 muster strengths›0730 CSTRNG *=*+159 combat strengths›0740 SWAP *=*+159 terrain code underneath unit›0750 ARRIVE *=*+159 turn of arrival›0760 WORDS *=*+272 various words for messages›0770 CORPT *=*+159 codes for unit types›0780 CORPNO *=*+159 ID numbers of units›0790 HDIGIT *=*+256 tables for displaying numbers (hundreds)›0800 TDIGIT *=*+256 tens tables›0810 ODIGIT *=*+256 ones tables›0820 TXTTBL *=*+96 more text›0830 MONLEN *=*+13 table of month lengths›0840 HMORDS *=*+159 how many orders each unit has in queue›0850 WHORDS *=*+159 what the orders are›0860 WHORDH *=*+159›0870 BEEPTB *=*+4 table of beep tones›0880 ERRMSG *=*+128 table of error messages›0890 XOFF *=*+4 offsets for moving maltakreuze›0900 YOFF *=*+4›0910 MASKO *=*+4 mask values for decoding orders›0920 XADD *=*+4 offsets for moving arrow›0930 YADD *=*+4›0940 TRTAB *=*+13 tree color table›0950 MLTKRZ *=*+8 maltese cross shape›0960 ;›0970 ;RAM from $6000 to $6430 is taken up by›0980 ;character sets and the display list›0990 ;›1000 *=$6431›1010 ARRTAB *=*+32 arrow shapes›1020 *=$6450›1030 TXTWDW *=$6CB1›1040 STKTAB *=*+16 a joystick decoding table›1050 SSNCOD *=*+12 season codes›1060 TRNTAB *=*+60 terrain cost tables›1070 BHX1 *=*+22 intraversible square pair coordinates›1080 BHY1 *=*+22›1090 BHX2 *=*+22›1100 BHY2 *=*+22›1110 EXEC *=*+159 execution times›1120 ;›1130 *=$4ED8›1140 ;›1150 ;combat routine›1160 ;›1170 LDA #$00›1180 STA VICTRY clear victory flag›1190 LDX ARMY›1200 CPX #$2A Finns can't attack›1210 BEQ A10›1220 CPX #$2B›1230 BNE A11›1240 A10 RTS›1250 A11 LDY UNITNO›1260 STY DEFNDR›1270 LDX DEFNDR make combat graphics›1280 LDA SWAP,X›1290 PHA›1300 LDA #$FF solid red square›1310 CPX #$37 Russian unit?›1320 BCS B1›1330 LDA #$7F make it white for Germans›1340 B1 STA SWAP,X›1350 STX CORPS›1360 LDA CORPSX,X›1370 STA CHUNKX›1380 LDA CORPSY,X›1390 STA CHUNKY›1400 JSR SWITCH›1410 LDY #$08›1420 LDX #$8F›1430 LOOP78 STX AUDC1›1440 STY AUDF1›1450 JSR STALL›1460 TYA›1470 CLC›1480 ADC #$08›1490 TAY›1500 DEX›1510 CPX #$7F›1520 BNE LOOP78›1530 ;›1540 ;now replace original unit character›1550 ;›1560 JSR SWITCH›1570 LDX DEFNDR›1580 PLA›1590 STA SWAP,X›1600 ;›1610 ;›1620 JSR TERRTY terrain in defender's square›1630 LDX DEFNC,Y defensive bonus factor›1640 LDA CSTRNG,Y defender's strength›1650 LSR A›1660 Y15 DEX adjust for terrain›1670 BEQ Y16›1680 ROL A›1690 BCC Y15›1700 LDA #$FF›1710 ;›1720 ;now adjust for defender's motion›1730 ;›1740 Y16 LDX HMORDS,Y›1750 BEQ DOBATL›1760 LSR A›1770 ;›1780 ;evaluate defender's strike›1790 ;›1800 DOBATL CMP RANDOM›1810 BCC ATAKR›1820 LDX ARMY›1830 DEC MSTRNG,X›1840 LDA CSTRNG,X›1850 SBC #$05›1860 STA CSTRNG,X›1870 BEQ Z28›1880 BCS Y24›1890 Z28 JMP DEAD attacker dies›1900 Y24 JSR BRKCHK attacker lives; does he break?›1910 ;›1920 ;evaluate attacker's strike›1930 ;›1940 ATAKR LDX ARMY›1950 LDA CORPSX,X›1960 STA LONG›1970 LDA CORPSY,X›1980 STA LAT›1990 JSR TERR›2000 JSR TERRTY›2010 LDA OFFNC,Y›2020 TAY›2030 LDX ARMY›2040 LDA CSTRNG,X›2050 DEY›2060 BEQ Y19›2070 LSR A river attack penalty›2080 Y19 CMP RANDOM›2090 BCC A20›2100 LDX DEFNDR attacker strikes defender›2110 DEC MSTRNG,X›2120 LDA CSTRNG,X›2130 SBC #$05›2140 STA CSTRNG,X›2150 BEQ Z29›2160 BCS Y25›2170 Z29 JSR DEAD defender dies›2180 A20 JMP ENDCOM›2190 Y25 JSR BRKCHK does defender break?›2200 BCC A20›2210 LDY ARMY›2220 LDA WHORDS,Y›2230 AND #$03›2240 TAY first retreat priority : away from attacker›2250 JSR RETRET›2260 BCC VICCOM defender died›2270 BEQ Y27 defender may retreat›2280 LDY #$01 second priority: east/west›2290 CPX #$37›2300 BCS Y28›2310 LDY #$03›2320 Y28 JSR RETRET›2330 BCC VICCOM›2340 BEQ Y27›2350 LDY #$02 third priority: north›2360 JSR RETRET›2370 BCC VICCOM›2380 BEQ Y27›2390 LDY #$00 fourth priority: south›2400 JSR RETRET›2410 BCC VICCOM›2420 BEQ Y27›2430 LDY #$03 last priority: west/east›2440 CPX #$37›2450 BCS Y26›2460 LDY #$01›2470 Y26 JSR RETRET›2480 BCC VICCOM›2490 BNE ENDCOM›2500 Y27 STX CORPS retreat the defender›2510 LDA CORPSX,X›2520 STA CHUNKX›2530 LDA CORPSY,X›2540 STA CHUNKY›2550 JSR SWITCH›2560 LDX CORPS›2570 LDA LAT›2580 STA CORPSY,X›2590 STA CHUNKY›2600 LDA LONG›2610 STA CORPSX,X›2620 STA CHUNKX›2630 JSR SWITCH›2640 VICCOM LDX ARMY›2650 STX CORPS›2660 LDA CORPSX,X›2670 STA CHUNKX›2680 LDA CORPSY,X›2690 STA CHUNKY›2700 LDA ACCLO defender's coordinates›2710 STA LONG›2720 LDA ACCHI›2730 STA LAT›2740 LDA #$FF›2750 STA VICTRY›2760 ENDCOM LDX ARMY›2770 INC EXEC,X›2780 RTS›2790 ;›2800 ;Subroutines for combat›2810 ;input: X = ID # of defender. Y = proposed DIR of retreat›2820 ;output: C bit set if defender lives, clear if dies›2830 ;Z bit set if retreat open, clear if blocked›2840 ;›2850 RETRET LDA CORPSX,X›2860 CLC›2870 ADC XINC,Y›2880 STA LONG›2890 LDA CORPSY,X›2900 CLC›2910 ADC YINC,Y›2920 STA LAT›2930 JSR TERR examine terrain›2940 JSR TERRTY›2950 LDX DEFNDR›2960 LDA UNITNO anybody in this square?›2970 BNE Y22›2980 LDA TRNTYP no›2990 ;›3000 ;check for bad ocean crossings›3010 ;›3020 CMP #$07 coastline?›3030 BCC Y41›3040 CMP #$09›3050 BEQ Y22›3060 LDY #$15›3070 LOOP42 LDA LAT›3080 CMP BHY1,Y›3090 BNE Y43›3100 LDA LONG›3110 CMP BHX1,Y›3120 BNE Y43›3130 LDA CORPSX,X›3140 CMP BHX2,Y›3150 BNE Y43›3160 LDA CORPSY,X›3170 CMP BHY2,Y›3180 BEQ Y22›3190 Y43 DEY›3200 BPL LOOP42›3210 ;›3220 ;any blocking ZOC's?›3230 ;›3240 Y41 JSR CHKZOC›3250 LDX DEFNDR›3260 LDA ZOC›3270 CMP #$02›3280 BCS Y22 no retreat into ZOC›3290 LDA #$00 retreat is possible›3300 SEC›3310 RTS›3320 Y22 LDA CSTRNG,X retreat not possible,extract penalty›3330 SEC›3340 SBC #$05›3350 STA CSTRNG,X›3360 BEQ Z27›3370 BCS Y23›3380 Z27 JSR DEAD›3390 CLC›3400 Y23 LDA #$FF›3410 RTS›3420 ;›3430 ;supply evaluation routine›3440 ;›3450 LDA ARRIVE,X›3460 CMP TURN›3470 BEQ Z86›3480 BCC Z86›3490 RTS›3500 Z86 LDA #$18›3510 CPX #$37›3520 BCS A13›3530 LDA #$18›3540 LDY EARTH›3550 CPY #$02 mud?›3560 BEQ A12›3570 CPY #$0A snow?›3580 BNE A13›3590 LDA CORPSX,X this discourages gung-ho corps›3600 ASL A double distance›3610 ASL A›3620 ADC #$4A›3630 CMP RANDOM›3640 BCC A12›3650 LDA #$10 harder to get supplies in winter›3660 A13 STA ACCLO›3670 LDY #$01 Russians go east›3680 CPX #$37›3690 BCS Z80›3700 LDY #$03 Germans go west›3710 Z80 STY HOMEDR›3720 LDA CORPSX,X›3730 STA LONG›3740 LDA CORPSY,X›3750 STA LAT›3760 LDA #$00›3770 STA RFR›3780 LOOP91 LDA LONG›3790 STA SQX›3800 LDA LAT›3810 STA SQY›3820 LOOP90 LDA SQX›3830 CLC›3840 ADC XINC,Y›3850 STA LONG›3860 LDA SQY›3870 CLC›3880 ADC YINC,Y›3890 STA LAT›3900 JSR CHKZOC›3910 CPX #$37›3920 BCC A80›3930 JSR TERRB›3940 LDA TRNCOD›3950 CMP #$BF›3960 BEQ A77›3970 A80 LDA ZOC›3980 CMP #$02›3990 BCC Z81›4000 INC RFR›4010 A77 INC RFR›4020 LDA RFR›4030 CMP ACCLO›4040 BCC Z84›4050 A12 LSR CSTRNG,X›4060 BNE A50›4070 JMP DEAD›4080 A50 RTS›4090 Z84 LDA RANDOM›4100 AND #$02›4110 TAY›4120 JMP LOOP90›4130 Z81 LDY HOMEDR›4140 LDA LONG›4150 CPY #$01›4160 BNE Z85›4170 CMP #$FF›4180 BNE LOOP91›4190 INC MSTRNG,X Russian replacements›4200 INC MSTRNG,X›4210 RTS›4220 Z85 CMP #$2E›4230 BNE LOOP91›4240 RTS›4250 ;›4260 ;routine to check for zone of control›4270 ;›4280 CHKZOC LDA #$00›4290 STA ZOC›4300 LDA #$40›4310 CPX #$37›4320 BCS A70›4330 LDA #$C0›4340 A70 STA TEMPR›4350 JSR TERRB›4360 BNE A74›4370 LDA TRNCOD›4380 AND #$C0›4390 CMP TEMPR›4400 BEQ A71›4410 LDA CORPSX,X›4420 CMP LONG›4430 BNE A79›4440 LDA CORPSY,X›4450 CMP LAT›4460 BEQ A74›4470 A79 RTS›4480 A71 LDA #$02›4490 STA ZOC›4500 RTS›4510 A74 LDX #$07›4520 LOOPQ LDY JSTP+16,X›4530 LDA LONG›4540 CLC›4550 ADC XINC,Y›4560 STA LONG›4570 LDA LAT›4580 CLC›4590 ADC YINC,Y›4600 STA LAT›4610 JSR TERRB›4620 BNE A75›4630 LDA TRNCOD›4640 AND #$C0›4650 CMP TEMPR›4660 BNE A75›4670 TXA›4680 AND #$01›4690 CLC›4700 ADC #$01›4710 ADC ZOC›4720 STA ZOC›4730 A75 DEX›4740 BPL LOOPQ›4750 DEC LAT›4760 DEC LONG›4770 LDX ARMY›4780 RTS›4790 ;›4800 ;›4810 DEAD LDA #$00›4820 STA MSTRNG,X›4830 STA CSTRNG,X›4840 STA HMORDS,X›4850 LDA #$FF›4860 STA EXEC,X›4870 STA ARRIVE,X›4880 STX CORPS›4890 LDA CORPSX,X›4900 STA CHUNKX›4910 LDA CORPSY,X›4920 STA CHUNKY›4930 JSR SWITCH›4940 RTS›4950 ;›4960 ;Subroutine BRKCHK evaluates whether a unit under attack breaks›4970 ;›4980 BRKCHK CPX #$37›4990 BCS WEAKLG›5000 LDA CORPT,X›5010 AND #$F0›5020 BNE WEAKLG›5030 LDA MSTRNG,X›5040 LSR A›5050 JMP Y40›5060 WEAKLG LDA MSTRNG,X›5070 LSR A›5080 LSR A›5090 LSR A›5100 STA TEMPR›5110 LDA MSTRNG,X›5120 SEC›5130 SBC TEMPR›5140 Y40 CMP CSTRNG,X›5150 BCC A30›5160 LDA #$FF›5170 STA EXEC,X›5180 LDA #$00›5190 STA HMORDS,X›5200 A30 RTS›5210 ;›5220 .END›