forked from bruddog/Tecmo_Super_Bowl_NES_Disassembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bank12_13_sim_update_stats.asm
6417 lines (5122 loc) · 416 KB
/
Bank12_13_sim_update_stats.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.BASE $9000
_F{_SKIP_MODE_CONSTANTS
FUMBLE_CHANCE_SIM = $00 ; injuryy chance 1/256
INJURY_CHANCE_SIM_MULT_ONE = $11 ; chance is the multiplication of 10/256 * 17/256 = 0.25%
INJURY_CHANCE_SIM_MULT_TWO = $0A
MAX_SCORE_LIMIT_SIM = $99
YARDS_FOR_FIRST_SIM = $0A
SECONDS_PER_QUARTER_SIM = $00
MINUTES_PER_QUARTER_SIM = $06
LENGTH_OF_FIELD_YARDS_SIM = $64 ; in yards $64 = 100 decimal
XP_KICK_DISTANCE_SIM = $02 ; in yards
PASS_SIM_PLAY_TYPE = $00
NORMAL_RUN_SIM_PLAY_TYPE = $01
QB_SCRAMBLE_SIM_PLAY_TYPE = $02
QB_SACKED_SIM_PLAY_TYPE = $03
; ADD $62A = P1 CONDITIONS .DSB 8
SIM_GAME_STATUS_GAME_OVER_BITFLAG = $80
SIM_GAME_STATUS_OVERTIME_BITFLAG = $40
_F}_SKIP_MODE_CONSTANTS
_F{_SKIP_MODE_MACROS
.MACRO SET_SIM_PLAY_TIME[min_max_rand] MIN, MAX, RAND
LDA RAND ;
LDX #(MAX - MIN)
JSR GET_RAND_VAL_FROM_ZERO_TO_MAX ; SET VALUE TO (0 TO X-1)
CLC ;
ADC #MIN ; + SECONDS
STA SIM_TIME_PLAY_USED ; SET TIME TO SUBTRACT FROM CLOCK
.ENDM
.MACRO SET_ADJUSTED_SKILL_VALUE[min_max_rand] MIN, MAX, RAND
player_sim_value = LOCAL_8
adjusted_sim_val = LOCAL_1
LDA RAND ;
LDX #(MAX - MIN) ;
JSR GET_RAND_VAL_FROM_ZERO_TO_MAX
CLC ;
ADC #MIN ;
LDX player_sim_value ; LOAD PLAYER SIM VALUE
JSR SIM_A_TIMES_X_SAVE_IN_LOCAL_1 ; MULTIPLY( A * X) RESULT $3E,3F
LDA #$64 ; LOAD 100
LDX adjusted_sim_val ; LOAD RESULT
LDY adjusted_sim_val +1 ;
JSR DIVIDE_ADJUSTED_SIM_VAL ; DIVIDE (3F,3E / A) RESULT $3E,3F
.ENDM
_F}_SKIP_MODE_MACROS
BANK_JUMP_COM_PLAY_CALL_LOGIC_START:
JMP COM_PLAY_CALL_LOGIC_START ; CPU PLAY LOGIC($9E)
BANK_JUMP_CHECK_FOR_COM_ONSIDES_KICK:
JMP CHECK_FOR_COM_ONSIDES_KICK ; CPU ONSIDE KICK LOGIC()
BANK_JUMP_GET_PLAYER_SEASON_STAT:
JMP GET_PLAYER_SEASON_STAT ; GET SEASON STATS
BANK_JUMP_GET_CURRENT_GAME_STATS:
JMP GET_CURRENT_GAME_STATS ; GET CURRENT GAME STATS()
BANK_JUMP_ADD_STAT_TO_SEASON_STAT:
JMP ADD_STAT_TO_SEASON_STAT[stat_function_index] ; ADD CURRENT STATS TO SEASON STATS()
BANK_JUMP_UPDATE_IN_GAME_STATS_WITH_ERROR_CHECK
JMP UPDATE_IN_GAME_STATS_WITH_ERROR_CHECK ; UPDATE PLAYER STATS IF VALID(A= PLAYER ID, 6F= P1/P2, X= STAT TO UPDATE)
BANK_JUMP_ADD_ALL_GAME_STATS_TO_SEASON_STATS
JMP ADD_ALL_GAME_STATS_TO_SEASON_STATS ; ADD ALL CURRENT GAME STATS TO SEASON STATS
_F{_CLEAR_AND_INIT_SIM_MEMORY ; DONE
SIMULATION_SKIP_MODE_SEASON_START: ; SKP VS SKP MODE SIMULATION START()
@clear_sim_memory:
LDA #$00 ; SET VALUE TO WRITE INTO RAM
TAX ;
_WHILE NOT_EQUAL
STA START_OF_SIM_RAM[],X ;
INX
_END_WHILE
JSR LOAD_SIM_VALUES_FROM_ROM_TO_RAM ; TRANSFER SIM VALUES TO RAM()
@init_vars:
LDA #$00 ;
STA QUARTER ; SET QUARTER = FIRST QUARTER
STA CLOCK_SECONDS ; SET SECONDS = 00
STA TEAM_ON_OFFENSE ; SET CURRENT TEAM INDEX = PLAYER 1
STA DOWN ; SET DOWN? =0
LDA #MINUTES_PER_QUARTER_SIM ; SET MINUTES =6
STA CLOCK_MINUTES ;
LDA #YARDS_FOR_FIRST_SIM ; SET YARDS NEEDED FOR FIRST DOWN = 10
STA SIM_YARDS_LEFT_FOR_FIRST_DOWN ;
_F}_CLEAR_AND_INIT_SIM_MEMORY
_F{_DO_INITIAL_SIM_KICKOFF ; DONE
@do_kickoff:
JSR DO_SIM_KICKOFF ; DO SIM KICK-OFF()
LDA #YARDS_FOR_FIRST_SIM ; SET YARDS NEEDED FOR FIRST DOWN = 10
STA SIM_YARDS_LEFT_FOR_FIRST_DOWN ;
LDA SIM_CURRENT_TEAM_WITH_BALL ; WAS THERE A TURNOVER
EOR SIM_LAST_TEAM_WITH_BALL ;
BEQ @set_injury_false ; NO-> SET POSSIBLE PLAYER INJURY = FALSE AND DO END OF PLAY
@swap_possesion:
LDA SIM_CURRENT_TEAM_WITH_BALL ; SET CURRENT TEAM WITH POSSESSION = OTHER TEAM
EOR #$80 ;
STA SIM_CURRENT_TEAM_WITH_BALL ;
LDA TEAM_ON_OFFENSE ; SET CURRENT TEAM INDEX TO OTHER TEAM = SWAP POSSESSION
EOR #$01 ;
STA TEAM_ON_OFFENSE ;
LDA #LENGTH_OF_FIELD_YARDS_SIM ; SET DISTANCE FROM ENDZONE = 100 YARDS - DISTANCE FROM ENDZONE
SEC ;
SBC SIM_DISTANCE_FROM_ENDZONE ;
STA SIM_DISTANCE_FROM_ENDZONE ;
@set_injury_false: ; SET POSSIBLE PLAYER INJURY = FALSE AND DO END OF PLAY
LDA #$00 ; SET PLAYER INJURY STATUS = FALSE
STA SIM_INJURY_BOOL ;
; END OF PLAY START
_F}_DO_INITIAL_SIM_KICKOFF
_F{_MAIN_SIM_LOOP ; DONE
MAIN_SIM_LOOP:
current_team_id = LOCAL_7
current_position_id = LOCAL_8
TEAM_SCORES_FOR_CPU_LOGIC[] = SEGMENT_VAR_9F
_WHILE ALWAYS
LDA SIM_INJURY_BOOL ; DOES PLAYER INJURED = TRUE
BEQ @clear_play_variables ; NO-> CLEAR PLAY VARIABLES, CHECK FOR GAME OVER
@do_player_injured_skp_mode:
LDA TEAM_ON_OFFENSE ; SAVE CURRENT TEAM
PHA ;
LDA SIM_CURRENT_POSITION_ID ; SAVE POSITION ID
STA current_position_id ;
LDA SIM_CURRENT_TEAM ; SAVE P1/P2 TEAM INDEX
STA current_team_id ;
JSR SWAP_AND_DO_SKP_MODE_INJURY ; SIM MODE INJURY CHECK() IN $9EB8 BANK 19
JSR LOAD_SIM_VALUES_FROM_ROM_TO_RAM ; TRANSFER SIM VALUES TO RAM()
PLA ;
STA TEAM_ON_OFFENSE ; RESTORE CURRENT TEAM
@clear_play_variables: ; CLEAR PLAY VARIABLES, CHECK FOR GAME OVER
LDA #$00 ; SET PLAYER TACKLED = FALSE
STA SIM_PLAYER_TACKLED_BOOL ;
STA SIM_PLAY_YARDAGE ; SET PLAY YARDAGE = 0
STA SIM_TIME_PLAY_USED ; SET TIME TO SUBTRACT FROM CLOCK = ZERO
STA SIM_INJURY_BOOL ; SET POSSBILE PLAYER INJURY = FALSE
LDA SIM_CURRENT_TEAM_WITH_BALL ;
STA SIM_LAST_TEAM_WITH_BALL ; SET LAST TEAM WITH POSSESSION = P1 = CURRENT TEAM WITH POSESSION
LDA SIM_GAME_STATUS ; DOES GAME STATUS = GAME OVER
BPL @check_for_kickoff_or_play ; NO-> CHECK FOR KICKOFF OR NORMAL PLAY
@game_over:
RTS ; RETURN
@check_for_kickoff_or_play: ; CHECK FOR KICKOFF OR NORMAL PLAY
LDA SIM_DO_KICKOFF_BOOL ; IS DO KICKOFF = TRUE
BEQ SIM_DO_NORMAL_PLAY ; NO-> NORMAL PLAY START
LDA #$00 ; SET DO KICKOFF = FALSE
STA SIM_DO_KICKOFF_BOOL ;
LDA SIM_CURRENT_TEAM_WITH_BALL ; SET CURRENT TEAM WITH POSESSION = OTHER TEAM
EOR #$80 ;
STA SIM_CURRENT_TEAM_WITH_BALL ;
STA SIM_LAST_TEAM_WITH_BALL ; SET LAST TEAM WITH POSSESION = OTHER TEAM
LDA TEAM_ON_OFFENSE ; SET CURRENT TEAM INDEX = OTHER TEAM = SWAP POSESSION
EOR #$01 ;
STA TEAM_ON_OFFENSE ;
LDA #FIRST_DOWN ; SET DOWN = FIRST DOWN
STA DOWN ;
LDA #YARDS_FOR_FIRST_SIM ; SET YARDS NEEDED FOR FIRST DOWN = 10
STA SIM_YARDS_LEFT_FOR_FIRST_DOWN ;
LDX TEAM_ON_OFFENSE ;
LDA P2_TOTAL_SCORE ; SET KICKING TEAM SCORE AND OPPOSING TEAM SCORE
@set_team_scores_for_cpu_kick_logic: ;
onside_boolean = LOCAL_3
STA TEAM_SCORES_FOR_CPU_LOGIC[],X ;
TXA ;
EOR #$01 ;
TAX ;
LDA P1_TOTAL_SCORE ;
STA TEAM_SCORES_FOR_CPU_LOGIC[],X ;
JSR CHECK_FOR_COM_ONSIDES_KICK ; DO CPU ONSIDE KICK LOGIC()
BIT onside_boolean ; DO ONSIDE KICK?
BMI @do_onsides_kick ; YES->DO ONSIDE KICK START
JSR DO_SIM_KICKOFF ; DO SIM KICKOFF
JMP @kickoff_over ; JUMP-> KICKOFF COMPLETED
@do_onsides_kick: ; DO ONSIDE KICK START
JSR DO_SIM_ONSIDES_KICK ; DO SIM ONSIDE KICK()
@kickoff_over: ; KICKOFF COMPLETED
LDA SIM_DO_KICKOFF_BOOL ; IS DO KICKOFF = TRUE
BNE @exit_to_sim_loop ; YES-> END OF PLAY START
LDA #YARDS_FOR_FIRST_SIM ; SET YARDS NEEDED FOR FIRST DOWN = 10
STA SIM_YARDS_LEFT_FOR_FIRST_DOWN ;
LDA SIM_CURRENT_TEAM_WITH_BALL ; DOES CURRENT TEAM WITH POSSESSION = LAST TEAM WITH POSESSION
EOR SIM_LAST_TEAM_WITH_BALL ;
BNE @swap_possession_of_ball ; NO->NEW TEAM HAS POSESSION OF BALL
_END_WHILE ; YES->SIM LOOP
@swap_possession_of_ball: ; NEW TEAM HAS POSESSION OF BALL
LDA SIM_CURRENT_TEAM_WITH_BALL ; SET CURRENT TEAM WITH POSSESSION = OTHER TEAM
EOR #$80 ;
STA SIM_CURRENT_TEAM_WITH_BALL ;
LDA TEAM_ON_OFFENSE ; SET CURRENT TEAM = OTHER TEAM = SWAP POSESSION
EOR #$01 ;
STA TEAM_ON_OFFENSE ;
LDA #LENGTH_OF_FIELD_YARDS_SIM ; SET DISTANCE FROM ENDZONE = 100 - DISTANCE FROM ENDZONE
SEC ;
SBC SIM_DISTANCE_FROM_ENDZONE ;
STA SIM_DISTANCE_FROM_ENDZONE ;
@exit_to_sim_loop: ;
JMP MAIN_SIM_LOOP ; JUMP-> SIM LOOP
_F}_MAIN_SIM_LOOP
_F{_GET_AND_DO_SIM_PLAY_TYPE ; DONE
SIM_DO_NORMAL_PLAY: ; NORMAL PLAY START
IN_GAME_KICKER_ROSTER_ID = P1_K_STARTER + 1
LDX TEAM_ON_OFFENSE ; IS CURRENT TEAM = P1
BEQ @save_qb_id ; YES->CHECK FOR PLAY CALL
LDX #P2_GAME_PLAYERS_OFFSET ; ADD OFFSET TO PLAYER 2 STARTERS
@save_qb_id: ; CHECK FOR PLAY CALL
LDA GAME_PLAYERS[]+1,X ; LOAD CURRENT TEAM QB ID
STA SIM_QB_ID ;
JSR GET_SIM_PLAY_CALLS ; GET P1 AND P2 PLAY CALL()
LDX TEAM_ON_OFFENSE ;
LDA SIM_PLAY_CALLS[],X ; IS OFFENSE PLAY CALL >= PASS PLAY CALL
CMP #PASS_CALL_ID ;
BCS @check_for_fg_or_punt ; YES->CHECK FOR PASS PLAY, FG, PUNT
@do_sim_run_play
LDA #NORMAL_RUN_SIM_PLAY_TYPE ; SET PLAY TYPE = RUN
STA SIM_PLAY_TYPE ;
JSR DO_SIM_RUN_PLAY ; DO RUN PLAY()
JMP @do_end_of_play ;
@check_for_fg_or_punt: ; CHECK FOR PASS PLAY, FG, PUNT
CMP #PUNT_PLAY_CALL_ID ; IS OFFENSE PLAY CALL = PUNT OR FG?
BCS @check_for_punt ; YES-> HECK FOR PUNT = 0X08
@do_sim_pass:
LDA #PASS_SIM_PLAY_TYPE ; SET PLAY TYPE = PASS
STA SIM_PLAY_TYPE ;
JSR DO_SIM_PASS_PLAY ; DO PASS PLAY ()
JMP @do_end_of_play
@check_for_punt: ; CHECK FOR PUNT = 0X08
CMP #FG_PLAY_CALL_ID ; IS PLAY CALL >= FG
BCS @check_for_fg ;
@do_sim_punt:
JSR DO_SIM_PUNT ; DO PUNT()
JMP @do_end_of_play ; JUMP->DO END OF PLAY
@check_for_fg: ; CHECK FOR FG = 0X09
CMP #FG_PLAY_CALL_ID +1 ; IS PLAY CALL = ?
BEQ @do_sim_fake_fg_unused ;
@do_sim_field_goal:
LDX TEAM_ON_OFFENSE ; LOAD CURRENT TEAM INDEX
BEQ @save_kicker_id ;
LDX #P2_GAME_PLAYERS_OFFSET ; ADD OFFSET TO PLAYER 2 STARTERS
@save_kicker_id:
LDA IN_GAME_KICKER_ROSTER_ID,X ; SET TEMP PLAYER ID = KICKER ID
STA SIM_CURRENT_STARTER_ID ;
LDX #UPDATE_FG_ATT_IN_GAME_INDEX ; SET STAT TO UPDATE = FG ATT
JSR SAVE_SIM_PLAY_STATS_TO_IN_GAME_PLAYER_STATS ; UPDATE PLAYER STATS IF VALID(A= PLAYER ID, 6F= P1/P2, X= STAT TO UPDATE), BUFFER TEMP VARIABLES
JSR CHECK_FOR_XP_FG_MAKE_OR_MISS ; CHECK FOR XP/FG MAKE OR MISS()
BCS @sim_fg_missed ;
@sim_fg_made:
LDA SIM_CURRENT_STARTER_ID ; LOAD KICKER ID
LDX #UPDATE_FG_MADE_IN_GAME_INDEX ; SET STAT TO UPDATE = FG MADE
JSR SAVE_SIM_PLAY_STATS_TO_IN_GAME_PLAYER_STATS ; UPDATE PLAYER STATS IF VALID(A= PLAYER ID, 6F= P1/P2, X= STAT TO UPDATE), BUFFER TEMP VARIABLES
LDA #FG_POINTS ; SET PTS TO ADD TO QUARTER SCORE = FG POINTS
STA SIM_PTS_TO_ADD_TO_SCORE ;
JSR SIM_UPDATE_QTR_TOTAL_SCORE ; UPDATE TEAM QTR AND TOTAL SCORE($6F= P1 OR P2 TEAM INDEX)
JSR SIM_UPDATE_TIME_QTR_CHECK_GAME_OVER ; TIME AND QUARTER UPDATE, END OF GAME CHECK()
JMP @do_end_of_play ; JUMP->DO END OF PLAY
@sim_fg_missed: ; FG MISS
LDA #$00 ; SET DO KICKOFF = FALSE
STA SIM_DO_KICKOFF_BOOL ;
LDA SIM_CURRENT_TEAM_WITH_BALL ; SET LAST TEAM WITH POSSESION = OTHER TEAM
EOR #$80 ;
STA SIM_LAST_TEAM_WITH_BALL ;
JSR SIM_UPDATE_TIME_QTR_CHECK_GAME_OVER ; TIME AND QUARTER UPDATE, END OF GAME CHECK()
JMP @do_end_of_play ; JUMP->DO END OF PLAY
@do_sim_fake_fg_unused: ; PLAY CALL IS FAKE FG/ PUNT? NOT USED
LDA #PASS_SIM_PLAY_TYPE ; SET PLAY TYPE = PASS
STA SIM_PLAY_TYPE ;
JSR DO_SIM_FAKE_PUNT_FG_PASS_NOT_USED ; FAKE/FG PUNT PASS() NOT USED
@do_end_of_play: ; DO END OF PLAY
LDA SIM_DO_KICKOFF_BOOL ; IS DO KICKOFF = TRUE
BNE @exit_to_sim_loop ; NO->GO TO START OF SIM LOOP
LDA SIM_CURRENT_TEAM_WITH_BALL ; IS CURRENT TEAM WITH POSSESSION = LAST TEAM WITH POSSESSION
CMP SIM_LAST_TEAM_WITH_BALL ;
BNE @sim_stop_on_downs_or_turnover ; NO->STOP ON DOWNS OR TURNOVER
INC DOWN ; DOWN ++
LDX DOWN ;
CPX #FOURTH_DOWN +1 ; IS DOWN = DOWN 5
BEQ @sim_stop_on_downs_or_turnover ; YES->STOP ON DOWNS OR TURNOVER
@exit_to_sim_loop: ; GO TO START OF SIM LOOP
JMP MAIN_SIM_LOOP ; JUMP->SIM GAME LOOP
@sim_stop_on_downs_or_turnover: ; STOP ON DOWNS OR TURNOVER
LDA SIM_CURRENT_TEAM_WITH_BALL ; SET TEAM WITH CURRENT POSESSION = OTHER TEAM
EOR #$80 ;
STA SIM_CURRENT_TEAM_WITH_BALL ;
LDA TEAM_ON_OFFENSE ; SET TEAM INDEX = OTHER TEAM
EOR #$01 ;
STA TEAM_ON_OFFENSE ;
LDA #LENGTH_OF_FIELD_YARDS_SIM ; SET DISTANCE FROM ENDZONE = 100 - DISTANCE FROM ENDZONE
SEC ;
SBC SIM_DISTANCE_FROM_ENDZONE ;
STA SIM_DISTANCE_FROM_ENDZONE ;
LDA #$00 ; SET DOWN = FIRST DOWN
STA DOWN ;
LDA #YARDS_FOR_FIRST_SIM ; SET YARDS NEED FOR FIRST DOWN = 10
STA SIM_YARDS_LEFT_FOR_FIRST_DOWN ;
JMP MAIN_SIM_LOOP ; JUMP->SIM GAME LOOP
_F}_GET_AND_DO_SIM_PLAY_TYPE
_F{_LOAD_SIM_DATA ; DONE
team_side_index = LOCAL_1
current_data_index = LOCAL_2
temp_sim_data_value_one = LOCAL_3
temp_sim_data_value_two = LOCAL_4
in_game_starter_index = LOCAL_5
team_sim_data_addr = LOCAL_7
QB_STARTER_ROSTER_IDS[] = GAME_PLAYERS[] + 1
SKILL_STARTER_ROSTER_IDS[] = GAME_PLAYERS[] + 3
SIZE_OF_QB_SIM_DATA_VALUES = $04
SIZE_OF_SKILL_PLAYER_SIM_DATA_VALUES = $14
SIZE_OF_DEFENDER_SIM_DATA_VALUES = $16
OFFSET_TO_P2_SIM_MEMORY_VALUES = $05
LOAD_SIM_VALUES_FROM_ROM_TO_RAM: ; TRANSFER SIM VALUES FROM ROM TO RAM()
LDA #$00 ;
STA in_game_starter_index ; SET PLAYER INDEX = FIRST PLAYER
STA team_side_index ; SET TEAM INDEX = PLAYER 1
LOAD_SIM_VALUES_FROM_ROM_TO_RAM_LOOP:
LDX team_side_index ; LOAD CURRENT TEAM
LDA TEAM_IDS_IN_GAME[],X ;
ASL ; SHIFT SINCE EACH POINTER IS TWO BYTES
TAX ;
@load_team_sim_data_addr:
LDA TEAM_SIM_DATA_POINTER_TABLE,X ; SAVE CURRENT TEAM SIM ADDRESS FROM TEAMS SIM ADDR TABLE
STA team_sim_data_addr ;
LDA TEAM_SIM_DATA_POINTER_TABLE+1,X ;
STA team_sim_data_addr + 1 ;
LDX in_game_starter_index ; LOAD QB STARTER ID
LDA QB_STARTER_ROSTER_IDS[],X ;
STA SIM_TEMP_VARIABLE_ONE ; SAVE IN $3BC
ASL ; SHIFT FOR TWO BYTE INDEX TO TEAM SIM DATA
TAY ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
@load_first_two_sim_bytes:
LDA (team_sim_data_addr),Y ; SAVE NEXT TWO TEAM SIM BYTES IN $40,$41
STA temp_sim_data_value_one ;
INY ;
LDA (team_sim_data_addr),Y ;
STA temp_sim_data_value_two ;
LDX team_side_index ; LOAD CURRENT TEAM INDEX
@load_qb_rushing_sim_value:
LDA temp_sim_data_value_one ; LOAD SIM BYTE
LOG_SHIFT_RIGHT_4 ; SHIFT OUT SECOND NIBBLE
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_YARDAGE_VALUES,Y ; SAVE QB SIM RUSHING VALUE IN QBS SIM RUSHING VALUES
STA SIM_QB_RUSHING_SIM_VALUE[],X ;
@load_qb_passing_sim_value:
LDA temp_sim_data_value_one ; MASK OUT FIRST NIBBLE
AND #$0F ;
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_PASS_REC_VALUES,Y ; SAVE SIM PASSING VALUE IN QBS SIM PASSING VALUES
STA SIM_QB_PASS_SIM_VALUE[],X ;
@load_qb_scramble_sim_value:
LDY temp_sim_data_value_two ;
LDA SIM_POCKET_VALUES,Y ; SAVE SIM POCKET VALUE IN QBS SIM POCKET VALUES
AND #$03 ; bitmask to keep sim scramble values from 0-3
STA SIM_QB_SCRAMBLE_SIM_VALUE[],X ;
LDA #$00 ; SET SKILL PLAYER INDEX = FIRST SKILL PLAYER STARTER
STA current_data_index ;
LDA team_sim_data_addr ; = CURRENT TEAM SEAM VALUE ADDRESS + 4 BYTES =
CLC ; GO TO START OF SKILL SIM PLAYER SIM VALUES
ADC #SIZE_OF_QB_SIM_DATA_VALUES ;
STA team_sim_data_addr ;
BCC @transfer_skill_player_values ;
INC team_sim_data_addr + 1 ;
@transfer_skill_player_values: ; TRANSFER SKILL PLAYER SIM VALUES TO RAM LOOP
_WHILE NOT_EQUAL
LDA current_data_index ;
ASL ;
CLC ;
ADC in_game_starter_index ;
TAX ;
LDA SKILL_STARTER_ROSTER_IDS[],X ; SAVE SKILL PLAYER STARTER ID
STA SIM_TEMP_VARIABLE_ONE ;
SEC ;
SBC #$02 ;
ASL ;
TAY ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDA team_side_index ; IS CURRENT TEAM = P1
BEQ @get_next_two_sim_bytes ; YES BRANCH TO
LDA #OFFSET_TO_P2_SIM_MEMORY_VALUES ; ADD OFFSET TO PLAYER 2
@get_next_two_sim_bytes: ;
CLC ;
ADC_ABS_ZP current_data_index ;
TAX ;
LDA (team_sim_data_addr),Y ; SAVE NEXT TWO TEAM SIM BYTES IN $40,$41
STA temp_sim_data_value_one ;
INY ;
LDA (team_sim_data_addr),Y ;
STA temp_sim_data_value_two ;
LDA temp_sim_data_value_one ;
LOG_SHIFT_RIGHT_4
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_YARDAGE_VALUES,Y ; SAVE PLAYER SIM RUSHING VALUE IN PLAYERS SIM RUSH YD VALUES
STA SIM_SKILL_RUSHING_SIM_VALUE[],X ;
LDA temp_sim_data_value_one ; LOAD PLAYER RECEIVING SKILL
AND #$0F ; MASK OUT UPPER NIBBLE
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_PASS_REC_VALUES,Y ; SAVE PLAYER SIM RECEIVING VALUE IN PLAYERS SIM RECEiv VALUES
STA SIM_SKILL_REC_SIM_VALUE[] ,X ;
LDA temp_sim_data_value_two ;
LOG_SHIFT_RIGHT_4
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_YARDAGE_VALUES,Y ; SAVE PLAYER SIM YARDAGE VALUE IN PLAYERS SIM RECEIVING VALUES
STA SIM_SKILL_REC_YARD_SIM_VALUE[],X ;
LDA temp_sim_data_value_two ;
AND #$0F ; MASK OUT UPPER NIBBLE
TAY ;
LDA SIM_TARGET_VALUES,Y ; SAVE PLAYER SIM TARGET CHANCE FROM SIM TARGET CHANCE TABLE
STA SIM_TARGET_CHANCE_SIM_VALUE[],X ;
INC current_data_index ; PLAYER INDEX++
LDA current_data_index ; IS PLAYER INDEX > LAST SKILL PLAYER STARTER
CMP #NUMBER_OF_NON_QB_SKILL_STARTERS ;
_END_WHILE ; NO ->TRANSFER SKILL PLAYER SIM VALUES TO RAM LOOP
@load_kick_returner_sim_values:
LDX in_game_starter_index ;
LDA CURRENT_IN_GAME_KR_ID,X ; LOAD KICK RETURNER STARTER ID
STA SIM_TEMP_VARIABLE_ONE ;
ASL ;
TAY ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDX team_side_index ;
LDA (team_sim_data_addr),Y ;
LOG_SHIFT_RIGHT_4
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_YARDAGE_VALUES,Y ; SAVE SIM KICK RETURN VALUE IN SIM KICK RETURN VALUES
STA SIM_KR_SIM_VALUE[],X ;
@load_punt_returner_sim_values:
LDX in_game_starter_index ;
LDA CURRENT_IN_GAME_PR_ID,X ; LOAD PUNT RETURNER STARTER ID
STA SIM_TEMP_VARIABLE_ONE ;
ASL ;
TAY ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDX team_side_index ;
LDA (team_sim_data_addr),Y ;
LOG_SHIFT_RIGHT_4
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_YARDAGE_VALUES,Y ;
STA SIM_PR_SIM_VALUE[],X ;
LDA team_sim_data_addr ; SIM STATS ADDRESS = SIM STATS ADDRESS + LENGTH OF SKILL PLAYERS SIM VALUES
CLC ;
ADC #SIZE_OF_SKILL_PLAYER_SIM_DATA_VALUES ;
STA team_sim_data_addr ;
BCC @check_team_side_for_defenders ;
INC team_sim_data_addr + 1 ;
@check_team_side_for_defenders:
LDX team_side_index ; IS CURRENT TEAM = P1
BEQ @load_sim_def_sack_values ; YES->LOAD DEFENSIVE PLAYER SIM SACK VALUES ($410 -$41A, $41B-425)
LDX #NUM_DEFENDERS_ON_FIELD ; ADD OFFSET TO PLAYER 2 DEFENSIVE SIM VALUES
@load_sim_def_sack_values: ; LOAD DEFENSIVE PLAYER SIM SACK VALUES ($410 -$41A, $41B-425)
LDY #$00 ; SET PLAYER INDEX = FIRST DEFENDER
_WHILE NOT_EQUAL ;
LDA (team_sim_data_addr),Y ;
STA SIM_DEF_SACK_SIM_VALUE[],X ; SAVE SIM SACK VALUE IN PLAYER SIM SACK VALUES
INX ; SIM DATA ADDRESS++
INY ; PLAYER INDEX++
CPY #NUM_DEFENDERS_ON_FIELD ; HAVE WE LOADED ALL DEFENDERS? NO -> LOOP BACK TO LOAD DEFENSIVE PLAYER SIM SACK VALUES
_END_WHILE ;
LDX team_side_index ; IS CURRENT TEAM = P1
BEQ @load_sim_def_int_values: ;
LDX #NUM_DEFENDERS_ON_FIELD ;
@load_sim_def_int_values:
_WHILE NOT_EQUAL ; LOAD DEFENSIVE PLAYER SIM INT VALUES ($426 -$430, $431-$43B)
LDA (team_sim_data_addr),Y ;
STA SIM_DEF_INT_SIM_VALUE[],X ; SAVE SIM INT VALUE IN PLAYER SIM INT VALUES
INX ; SIM DATA ADDRESS++
INY ; PLAYER INDEX++
CPY #(NUM_DEFENDERS_ON_FIELD * 2 ) ;
_END_WHILE ; HAVE WE LOADED ALL DEFENDERS? NO -> LOOP BACK TO LOAD DEFENSIVE PLAYER SIM INT VALUES
@update_sim_data_addr_after_defenders
LDA team_sim_data_addr ;
CLC ;
ADC #SIZE_OF_DEFENDER_SIM_DATA_VALUES ;
STA team_sim_data_addr ; SIM STATS ADDRESS = SIM STATS ADDRESS + LENGTH OF DEFENSIVE PLAYERS SIM VALUES
BCC @load_sim_fg_xp_values ;
INC team_sim_data_addr + 1 ;
@load_sim_fg_xp_values: ; LOAD SIM KICKING PUNTING AND DEFENSE VALUES ()
LDX in_game_starter_index ; LOAD CURRENT PLAYER INDEX
LDA CURRENT_IN_GAME_KICKER_ID,X ; LOAD KICKER ID
STA SIM_TEMP_VARIABLE_ONE ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDX team_side_index ;
LDY #$00 ;
LDA (team_sim_data_addr),Y ; LOAD KICKING SIM VALUE
STA temp_sim_data_value_one ;
LOG_SHIFT_RIGHT_4 ;
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_KICKING_VALUES,Y ; SAVE SIM KICKING VALUE IN PLAYERS SIM KICKING VALUES FROM SIM KICKING TABLE
STA SIM_FG_XP_SIM_VALUE[],X ;
@load_sim_punting_values
LDX in_game_starter_index ;
LDA CURRENT_IN_GAME_PUNTER_ID,X ; LOAD PUNTER ID
STA SIM_TEMP_VARIABLE_ONE ;
JSR SIM_GET_CONDITION_MODIFIER_VALUE ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDX team_side_index ;
LDA temp_sim_data_value_one ;
AND #$0F ;
JSR SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
TAY ;
LDA SIM_PUNTING_VALUES,Y ; SAVE SIM PUNTING VALUE IN PLAYERS SIM PUNTING VALUES FROM SIM PUNTING TABLE
STA SIM_PUNT_YARD_SIM_VALUE[],X ;
@load_sim_team_defense_values
LDY #$01 ; LOAD DEFENSE/DEFENSE SIM VALUE
LDA (team_sim_data_addr),Y ;
STA temp_sim_data_value_one ;
LOG_SHIFT_RIGHT_4 ;
TAY ;
LDA SIM_RUN_DEFENSE_VALUES,Y ; SAVE SIM RUSH DEFENSE VALUE IN SIM RUSH DEFENSE VALUES FROM SIM DEFENSE TABLE
STA SIM_RUN_DEFENSE_SIM_VALUE[],X ;
LDA temp_sim_data_value_one ;
AND #$0F ; MASK OUT DEFENSE BIT
TAY ;
LDA SIM_PASS_DEFENSE_VALUES,Y ; SAVE SIM PASS DEFENSE VALUE IN SIM PASS DEFENSE VALUESFROM SIM DEFENSE TABLE
STA SIM_PASS_DEFENSE_SIM_VALUE[],X ;
number_of_run_plays_left = LOCAL_3
LDA #NUM_RUN_PLAYS ;
STA number_of_run_plays_left ;
LDX team_side_index ; IS CURRENT TEAM = P1
BEQ @save_player_id_run_play ;
LDX #$04 ; SET NUMBER OF RUN PLAYS = 4
@save_player_id_run_play: ; SAVE PLAYER IDS FOR RUN PLAYS
_WHILE NOT_EQUAL
LDA SIM_RUN_PLAY_POSITION_IDS[],X ; LOAD POSITIONAL ID FOR RUN PLAY
ASL ;
CLC ;
ADC in_game_starter_index ;
TAY ;
LDA CURRENT_IN_GAME_RUNNER_ID[],Y ; SAVE PLAYER ID IN RUN PLAYS PLAYER IDS
STA SIM_RUN_PLAY_STARTER_IDS[],X ;
INX ; RUN PLAY INDEX++
DEC number_of_run_plays_left ; RUN PLAYS LEFT--
_END_WHILE ; ALL RUN PLAY PLAYERS TRANSFERED? NO-> LOOP BACK TO SAVE PLAYER IDS FOR RUN PLAYS
LDA #P2_GAME_PLAYERS_OFFSET ; SET OFFSET TO P2 TEAM STARTERS
STA in_game_starter_index ;
INC team_side_index ; TEAM INDEX++
LDA team_side_index ;
CMP #$02 ;
BEQ @exit_load_sim_data ; BOTH TEAMS SIM VALUES TRANSFERRED
JMP LOAD_SIM_VALUES_FROM_ROM_TO_RAM_LOOP
; NO-> LOOP BACK TO TRANSFER SIM VALUES FROM ROM TO RAM()
@exit_load_sim_data:
RTS ; RETURN
_F}_LOAD_SIM_DATA
_F{_GET_SIM_CONDITION_MODIFIER ; DONE
team_side_index = LOCAL_1
P2_SIDE_SIM_CONDITION_INDEX = $08
SIM_GET_CONDITION_MODIFIER_VALUE: ; SAVE CONDITION VALUE MODIFIER -2 TO 4 IN $3BC BASED ON CONDITION()
LDX team_side_index ; DOES TEAM INDEX = PLAYER 1 INDEX
BEQ @get_condition ; YES->GET CONDITION
@set_p2_side_index
LDX #P2_SIDE_SIM_CONDITION_INDEX ; = SET OFFSET = PLAYER 2 OFFSET
@get_condition: ; GET CONDITION
STX SIM_TEMP_VARIABLE_TWO ; SET INDEX INTO PLAYER SIM DATA LENGTH
LDA SIM_TEMP_VARIABLE_ONE ; LOAD PLAYER ID
LOG_SHIFT_RIGHT_2
CLC ;
ADC SIM_TEMP_VARIABLE_TWO ;
TAX ;
LDA SIM_CONDITIONS[],X ; LOAD CONDITION BYTE
STA SIM_TEMP_VARIABLE_TWO ;
LDA SIM_TEMP_VARIABLE_ONE ; LOAD PLAYER ID
AND #$03 ;
TAX ;
LDA SIM_TEMP_VARIABLE_TWO ;
_WHILE NOT_EQUAL ;
CPX #$03 ;
BEQ @add_condition_modifier ;
LOG_SHIFT_RIGHT_2 ;
INX ;
_END_WHILE ;
@add_condition_modifier: ;
AND #$03 ;
ASL ; SHIFT FOR INDEX INTO TABLE
STA SIM_TEMP_VARIABLE_TWO ;
LDA RANDOM_1 ; LOAD RANDOM 3B()
AND #$01 ;
CLC ;
ADC SIM_TEMP_VARIABLE_TWO ;
TAX ;
LDA SIM_CONDITION_MODIFIER_TABLE,X ; SET VALUE BETWEEN -2 AND 4
STA SIM_TEMP_VARIABLE_ONE ;
JMP SIM_RANDOMIZE_MORE ; MORE EXTENSIVE RANDOM NUMBER UPDATE ()
_F}_GET_SIM_CONDITION_MODIFIER
_F{_ADD_SIM_CONDITION_MODIFIER_TO_SKILL_INDEX ; DONE
SIM_ADD_CONDITION_MODIFIER_TO_SKILL_INDEX: ; ADD CONDITION MODIFIER TO SKILL INDEX WITH MAX AND MIN(A= SKILL INDEX, $3BC= COND MODIFIER)
CLC ;
ADC SIM_TEMP_VARIABLE_ONE ; = SIM VALUE SKILL INDEX + CONDITION MODIFIER
BPL @check_if_exceeds_max ;
LDA #$00 ; SET MINIMUM SKILL INDEX = 0
RTS ;
@check_if_exceeds_max: ;
CMP #MAX_SKILL ; SET MAXIMUM SKILL INDEX = MAX SKILL
BCC @exit ;
LDA #MAX_SKILL ;
@exit: ;
RTS ; RETURN
_F}_ADD_SIM_CONDITION_MODIFIER_TO_SKILL_INDEX
_F{_GET_SIM_PLAY_CALL ; DONE
cpu_play_call = LOCAL_3
temp_field_yards = LOCAL_7
temp_yards_for_first = LOCAL_5
GET_SIM_PLAY_CALLS: ; GET P1 AND P2 PLAY CALL()
@convert_sim_yards_to_field_yards:
LDA SIM_DISTANCE_FROM_ENDZONE ; LOAD DISTANCE FROM ENDZONE
STA temp_field_yards ;
LDA #$00 ;
@yards_times_eight:
ASL temp_field_yards ;
ROL ;
ASL temp_field_yards ;
ROL ;
ASL temp_field_yards ;
ROL ;
STA temp_field_yards +1 ;
LDA SIM_YARDS_LEFT_FOR_FIRST_DOWN ; LOAD YARDS NEEDED FOR A FIRST DOWN
STA temp_yards_for_first ;
LDA #$00 ;
ASL temp_yards_for_first ;
ROL ;
ASL temp_yards_for_first ;
ROL ;
ASL temp_yards_for_first ;
ROL ;
STA temp_yards_for_first+1 ;
LDA SIM_CURRENT_TEAM_WITH_BALL ; SAVE TEAM WITH POSESSION IN 9E
STA CPU_SIDE_SAME_AS_OFF_BOOL
LDA P1_TOTAL_SCORE ; SAVE P1 TOTAL SCORE IN $9F
STA CPU_OFF_SCORE ;
LDA P2_TOTAL_SCORE ; SAVE P2 TOTAL SCORE IN $A0
STA CPU_OPP_SCORE ;
LDA P1_TEAM_OFFENSIVE_STYLE ; LOAD P1 OFFENSIVE PREFERENCE
STA OFFENSIVE_STYLE ;
JSR COM_PLAY_CALL_LOGIC_START ; DO COM PLAY CALL LOGIC ()
LDA cpu_play_call ; SAVE OFFENSE PLAY CALL DECISION IN $3B3
STA SIM_PLAY_CALLS[] ; SAVE OFFENSE PLAY CALL
@swap_to_get_defense_play_call
LDA CPU_SIDE_SAME_AS_OFF_BOOL ; SWAP TEAM WITH POSESSION()
EOR #$80 ;
STA CPU_SIDE_SAME_AS_OFF_BOOL ;
LDA CPU_OFF_SCORE ;
TAX ;
LDA CPU_OPP_SCORE ;
STA CPU_OFF_SCORE ;
STX CPU_OPP_SCORE ;
LDA P2_TEAM_OFFENSIVE_STYLE ; LOAD P2 OFFENSIVE PREFERENCE
STA OFFENSIVE_STYLE ;
JSR COM_PLAY_CALL_LOGIC_START ; DO COM PLAY CALL LOGIC ()
LDA cpu_play_call ;
STA SIM_PLAY_CALLS[] +1 ; SAVE DEFENSE PLAY CALL
RTS ; RETURN
_F}_GET_SIM_PLAY_CALL
_F{_DO_SIM_RUN_PLAY ; DONE
; EACH RUSH SIM VALUE OF 0X05 ADDS ~0.5 YARD PER CARRY
; EACH DEF RUSH SIM VALUE OF 0X10 SUBTRACTS ~0.25 YARDS PER CARRY
cond_adjust_sim_value = LOCAL_1
sim_run_play_call = LOCAL_7
sim_rush_value = LOCAL_8
sim_run_def_value = LOCAL_8
final_sim_run_compare_value = LOCAL_1
OFFSET_TO_P2_RUNNER_IDS = $04
OFFSET_TO_P2_SIM_RUSH_VALUES = $05
DO_SIM_RUN_PLAY: ; DO RUN PLAY()
LDX TEAM_ON_OFFENSE ; LOAD CURRENT TEAM INDEX
LDA SIM_PLAY_CALLS[],X ; SAVE PLAY CALL
STA sim_run_play_call ;
LDA TEAM_ON_OFFENSE ; SAVE P1 OR P2 TEAM INDEX
STA SIM_CURRENT_TEAM ;
BEQ @get_runner_starter_id ;
@set_to_side_two_runners:
LDA #OFFSET_TO_P2_RUNNER_IDS ; SET OFFSET TO PLAYER 2 RUN PLAY STARTER IDS
@get_runner_starter_id:
CLC ;
ADC sim_run_play_call ;
TAX ;
LDA SIM_RUN_PLAY_STARTER_IDS[],X ; LOAD RUN PLAY STARTER ID
STA SIM_CURRENT_STARTER_ID ; SAVE PLAYER ID
CMP SIM_QB_ID ; IS RUNNER = QB
BNE @skill_player_run ; NO-> RUNNER IS NOT QB
@qb_run:
LDX #UPDATE_QB_RUSH_ATT_IN_GAME_INDEX ; LOAD INCREASE QB RUSHING ATTEMPT COMMAND
JSR SAVE_SIM_PLAY_STATS_TO_IN_GAME_PLAYER_STATS ; UPDATE IN GAME PLAYER STATS IF VALID(A= PLAYER ID, 6F= P1/P2, X= STAT TO UPDATE), BUFFER TEMP VARIABLES
LDX TEAM_ON_OFFENSE ;
LDA SIM_QB_RUSHING_SIM_VALUE[],X ; LOAD QB SIM RUSHING VALUE
STA sim_rush_value ;
LDA #QB_SCRAMBLE_SIM_PLAY_TYPE ; SET PLAY TYPE = QB RUN
STA SIM_PLAY_TYPE ;
BNE DO_SIM_RUN_OR_QB_SCRAMBLE_PLAY ; BRANCH->SET TIME TAKEN AND RUSHING YARDS GAINED ON THE SIM RUN PLAY
@skill_player_run: ; RUNNER IS NOT QB
LDA SIM_RUN_PLAY_POSITION_IDS[],X ; SAVE RUN PLAY POSITION ID IN POSITION ID
STA SIM_CURRENT_POSITION_ID ;
LDX TEAM_ON_OFFENSE ; DOES CURRENT TEAM INDEX = P1
BEQ @get_sim_rush_value ; YES- LOAD SIM RUSHING VALUE AND ADD RUSHING ATTEMPT
@add_offset_to_player_2_sim_values
CLC ;
ADC #OFFSET_TO_P2_SIM_RUSH_VALUES ; ADD OFFSET TO P2 RUSH SIM VALUE
@get_sim_rush_value: ; LOAD SIM RUSHING VALUE AND ADD RUSHING ATTEMPT
TAX ; LOAD CURRENT TEAM INDEX
DEX ;
LDA SIM_SKILL_RUSHING_SIM_VALUE[],X ; LOAD PLAYER SIM RUSHING VALUE
STA sim_rush_value ;
@add_rushing_attempt_to_in_game_stat:
LDX #UPDATE_RUN_ATT_IN_GAME_INDEX ; LOAD INCREASE SKILL PLAYER RUSHING ATTEMPT COMMAND
LDA SIM_CURRENT_STARTER_ID ; LOAD PLAYER ID
JSR SAVE_SIM_PLAY_STATS_TO_IN_GAME_PLAYER_STATS ; UPDATE IN GAME PLAYER STATS IF VALID(A= PLAYER ID, 6F= P1/P2, X= STAT TO UPDATE), BUFFER TEMP VARIABLES
DO_SIM_RUN_OR_QB_SCRAMBLE_PLAY: ; SET TIME TAKEN AND RUSHING YARDS GAINED ON THE SIM RUN PLAY
INC SIM_PLAYER_TACKLED_BOOL ; SET PLAYER TACKLED = TRUE
LDX TEAM_ON_OFFENSE ; LOAD CURRENT TEAM INDEX
INC SIM_TEAM_RUSHING_ATT[],X ; TEAM RUSHING ATTEMPT++
; SET RUSH PLAY TIME = 10 TO 40 SECONDS
SET_SIM_PLAY_TIME[min_max_rand] 10,40,RANDOM_1
SET_ADJUSTED_SKILL_VALUE[min_max_rand] 80,100,RANDOM_2
LDA cond_adjust_sim_value ; SAVE SIM VALUE
STA SIM_TEMP_VARIABLE_ONE ;
LDA TEAM_ON_OFFENSE ;
EOR #$01 ;
TAX ;
LDA SIM_RUN_DEFENSE_SIM_VALUE[],X ; LOAD TEAM SIM RUN DEFENSE VALUE
STA sim_run_def_value ;
JSR SET_DEFENSE_SIM_VALUE_BASED_ON_PLAY_CALL ; SET FINAL VALUE BASED ON PLAY CALL ($45= RUN OR PASS DEFENSE SIM VALUE)
LDA final_sim_run_compare_value+1 ;
BNE @set_to_minimum_run_outcome ;
LDA SIM_TEMP_VARIABLE_ONE ; = OFFENSE VALUE - DEFENSE VALUE
SEC ;
SBC final_sim_run_compare_value ;
BCS @check_for_run_range_one ;
LDA #$00 ;
; CHECK VALUE TO SET POSSIBLE OUTCOME FOR THE SIM RUN
@check_for_run_range_one: ;
CMP #$34 ;
BCS @check_for_run_range_two ;
@set_to_minimum_run_outcome: ; SET YARDAGE = -3 TO 1
LDY #$FD ; SET MIN YARDAGE = -3
LDX #$04 ; SET MAX ADDITIONAL RANGE = 4
BNE @calculate_run_yardage ;
@check_for_run_range_two: ;
CMP #$67
BCS @check_for_run_range_three
@set_to_run_outcome_two: ; SET RUN YARDAGE = 1 TO 6
LDY #$01 ; SET MIN YARDAGE = 1
LDX #$05 ; SET MAX ADDITIONAL RANGE = 5
BNE @calculate_run_yardage
@check_for_run_range_three:
CMP #$9A
BCS @check_for_run_range_four
@set_to_run_outcome_three: ; SET RUN YARDAGE = 4 TO 12
LDY #$04 ; SET MIN YARDAGE = 4
LDX #$08 ; SET MAX ADDITIONAL RANGE = 8
BNE @calculate_run_yardage
@check_for_run_range_four:
CMP #$CD
BCS @check_for_run_range_five
@set_to_run_outcome_four: ; SET RUN YARDAGE = 7 TO 25
LDY #$07 ; SET MIN YARDAGE = 7
LDX #$12 ; SET MAX ADDITIONAL RANGE = 18
BNE @calculate_run_yardage
@check_for_run_range_five:
LDA RANDOM_1 ;
CMP #$10 ; = 6.2% CHANCE BRANCH TO SET RUN YARDAGE = 10 TO 100
BCC @set_to_run_outcome_six ;
@set_to_run_outcome_five: ; SET RUN YARDAGE = 10 TO 45
LDY #$0A ; SET MIN YARDAGE = 10
LDX #$23 ; SET MAX ADDITIONAL RANGE = 35
BNE @calculate_run_yardage
@set_to_run_outcome_six: ; SET RUN YARDAGE = 10 TO 100
LDY #$0A ; SET MIN YARDAGE = 10
LDX #$5A ; SET MAX ADDITIONAL RANGE = 90
@calculate_run_yardage: ; CALULATE RUN YARDAGE (X= MAX ADDITIONAL YARDS, Y= MIN)
min_yardage = LOCAL_7
abs_of_lost_yardage = LOCAL_7
STY min_yardage ; SAVE MIN VALUE
LDA RANDOM_2 ;
JSR GET_RAND_VAL_FROM_ZERO_TO_MAX ; SET VALUE TO (0 TO X-1)
CLC ; = (RAND % * X)
ADC min_yardage ; + MIN YARDAGE
STA SIM_PLAY_YARDAGE ; SAVE RUN YARDAGE IN PLAY YARDS
LDA TEAM_ON_OFFENSE ; SET INDEX INTO TEAMS RUSH YARDS
ASL ;
TAX ;
@check_for_loss:
LDA SIM_PLAY_YARDAGE ; IS RUN YARDAGE NEGATIVE?
BMI @sim_run_goes_for_loss ; YES-> SIM RUN PLAY GOES FOR LOSS
CMP SIM_DISTANCE_FROM_ENDZONE ; IS RUN YARDAGE < DISTANCE FROM ENDZONE
BCC @save_rush_yards ; YES->SIM RUN PLAY GOES FOR GAIN
LDA SIM_DISTANCE_FROM_ENDZONE ; PLAY YARDAGE = DISTANCE FROM ENDZONE
@save_rush_yards: ; SIM RUN PLAY GOES FOR GAIN
CLC ;
ADC SIM_TEAM_RUSHING_YDS[],X ; = TEAM RUN YARDS+ PLAY YARDAGE
STA SIM_TEAM_RUSHING_YDS[],X ;
BCC @exit_save_rush ;
INC SIM_TEAM_RUSHING_YDS[]+1,X ;
@exit_save_rush
JMP @update_game_state ; JUMP -> END OF RUN