forked from bruddog/Tecmo_Super_Bowl_NES_Disassembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bank26_misc.asm
2014 lines (1679 loc) · 86.8 KB
/
Bank26_misc.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 $8000
BANK_JUMP_DRAW_SCHEDULE:
JMP DRAW_SCHEDULE
BANK_JUMP_FLASH_CURRENT_GAME_IN_SCHEDULE:
JMP FLASH_CURRENT_GAME_IN_SCHEDULE
BANK_JUMP_RESET_SCHEDULE_RANDOMIZE_ORDER:
JMP RESET_SCHEDULE_RANDOMIZE_ORDER
BANK_JUMP_GET_NUMBER_OF_GAMES_IN_WEEK:
JMP GET_NUMBER_OF_GAMES_IN_WEEK
BANK_JUMP_CLEAR_SEASON_INFO:
JMP CLEAR_SEASON_INFO
BANK_JUMP_RESET_TEAM_PLAYBOOK_TO_DEFAULT_SAVE_CHECKSUM:
JMP RESET_TEAM_PLAYBOOK_TO_DEFAULT_SAVE_CHECKSUM
BANK_JUMP_RESET_AFC_STARTERS
JMP RESET_AFC_STARTERS
BANK_JUMP_RESET_NFC_STARTERS
JMP RESET_NFC_STARTERS
BANK_JUMP_DRAW_ROSTER_SCREEN
JMP DRAW_ROSTER_SCREEN ; *** change bank name to roster screen
BANK_JUMP_DRAW_DEFENSIVE_STARTERS_SCREEN
JMP DRAW_DEFENSIVE_STARTERS_SCREEN
BANK_JUMP_DRAW_TEAM_CONTROL_TYPE_SCREEN
JMP DRAW_TEAM_CONTROL_TYPE_SCREEN
BANK_JUMP_SAVE_DEFAULT_AFC_PLAYERS_W_CHECKSUM
JMP SAVE_DEFAULT_AFC_PLAYERS_W_CHECKSUM ; SET AFC STARTER DEFAULTS (NOT USED)
BANK_JUMP_SAVE_DEFAULT_NFC_PLAYERS_W_CHECKSUM
JMP SAVE_DEFAULT_NFC_PLAYERS_W_CHECKSUM ; SET NFC STARTER DEFAULTS (NOT USED)
BANK_JUMP_CHECK_FUMBLE_RECOVERY_TYPE:
JMP CHECK_FUMBLE_RECOVERY_TYPE
BANK_JUMP_GET_TEAM_1_RUSHING_YARDS
JMP GET_TEAM_1_RUSHING_YARDS
BANK_JUMP_GET_TEAM_2_RUSHING_YARDS
JMP GET_TEAM_2_RUSHING_YARDS
BANK_JUMP_GET_TEAM_1_PASSING_YARDS
JMP GET_TEAM_1_PASSING_YARDS
BANK_JUMP_GET_TEAM_2_PASSING_YARDS
JMP GET_TEAM_2_PASSING_YARDS
BANK_JUMP_ADJUST_PLAYER_FINAL_LOCATION_PASS:
JMP ADJUST_PLAYER_FINAL_LOCATION_PASS
BANK_26_UNUSED:
JMP BANK_26_UNUSED
_F{_DRAW_SCHEDULE ; DONE
schedule_addr = SEGMENT_VAR_8E
current_week = SEGMENT_VAR_90
current_game_in_week = SEGMENT_VAR_91
number_of_weeks_on_page_drawn = SEGMENT_VAR_92
games_per_week = SEGMENT_VAR_93
current_row_of_week = SEGMENT_VAR_94
current_schedule_page = SEGMENT_VAR_96
WEEKS_PER_PAGE = $04
data_addr_temp = LOCAL_1
ppu_addr_temp = LOCAL_3
num_rows = LOCAL_2
num_tiles = LOCAL_1
home_team = LOCAL_8
away_team = LOCAL_7
OFFSET_TO_DIVIDING_LINE = $17 ; number of tiles
NUMBER_OF_ROWS_TO_CLEAR_SHOW_SINGLE_WEEK = $12 ; 18 rows
DRAW_SCHEDULE: ; DRAW SCHEDULE START
LDX #DRAW_SCHEDULE_SCRIPT_BANK ; SET BANK = BANK 16
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
LDA #$00 ;
STA number_of_weeks_on_page_drawn ; SET CURRENT WEEKLY MATCHUP = FIRST MATCHUP
STA current_row_of_week ; SET NUMBER OF WEEKS DRAWN = ZERO
@draw_4_weeks_of_schedule_loop: ; DRAW 4 WEEKS OF SCHEDULE LOOP
LDA current_week ; DOES WEEK INDEX = CURRENT SEASON WEEK
CMP CURRENT_WEEK_IN_SEASON ;
BEQ @set_schedule_loc_sram ; YES->SET CURRENT WEEK MATCHUPS SRAM LOCATION
ASL ; SET INDEX INTO SCHEDULE POINTER TABLE
TAX ;
LDA WEEKLY_SCHEDULE_PTR_TABLE,X ; SET SCHEDULE LOCATION FROM WEEKLY SCHEDULE POINTER TABLE
STA schedule_addr ;
LDA WEEKLY_SCHEDULE_PTR_TABLE+1,X ;
STA schedule_addr+1 ;
JMP @draw_dates_dividing_lines ; JUMP->DRAW WEEK DATES AND DIVIDING LINES
@set_schedule_loc_sram:: ; SET CURRENT WEEK MATCHUPS SRAM LOCATION
LDA #<WEEKLY_MATCHUPS_START ; SET SCHEDULE LOCATION = SRAM CURRENT WEEK MATCHUPS
STA schedule_addr ;
LDA #>WEEKLY_MATCHUPS_START ;
STA schedule_addr +1 ;
@draw_dates_dividing_lines: ; DRAW WEEK DATES AND DIVIDING LINES
LDA number_of_weeks_on_page_drawn ; LOAD CURRENT WEEKLY MATCHUP
ASL ;
TAX ;
LDY SCHEDULE_DATE_PPU_ADDR_TABLE,X ; LOAD WEEK/DATE PPU LOCATIONS FROM SCHEDULE DATE PPU LOCATIONS
LDA SCHEDULE_DATE_PPU_ADDR_TABLE+1,X ;
TAX ;
LDA current_week ; LOAD WEEK INDEX
JSR DRAW_DATE_HEADERS_AND_DIVIDING_LINES ; DRAW WEEK DATES AND DIVIDING LINES()
LDX current_week ; SET NUMBER OF GAMES TO DRAW = GAMES IN CURRENT WEEK
LDA GAMES_PER_WEEK_ARRAY,X ;
STA games_per_week ;
LDA #$00 ; SET CURRENT WEEKLY MATCHUP INDEX = FIRST MATCHUP
STA current_game_in_week ;
@draw_next_matchup_in_week: ; DRAW NEXT WEEKLY MATCHUP
LDA current_game_in_week ; LOAD CURRENT WEEKLY MATCHUP INDEX
ASL ; SHIFT SINCE EACH MATCHUP IS TWO BYTES
TAY ;
LDA (schedule_addr),Y ; LOAD HOME TEAM
STA home_team ;
INY ; DATA INDEX++
LDA (schedule_addr),Y ; LOAD AWAY TEAM
STA away_team ;
LDA current_row_of_week ; LOAD WEEK INDEX
ASL ;
TAY ;
LDA SCHEDULE_PPU_ADDR_TABLE,Y ; LOAD WEEKLY MATCHUP PPU LOCATION FROM WEEKLY SCHEDULE PPU LOCATIONS
LDX SCHEDULE_PPU_ADDR_TABLE+1,Y ;
TAY ;
LDA current_game_in_week ; IS CURRENT WEEKLY MATCHUP INDEX > # OF GAMES IN WEEK?
CMP games_per_week ;
BCS @clear_dividing_line ; YES-> CLEAR DIVIDING ROW WITH WEEK AND DATE
JSR DRAW_WEEKLY_MATCHUPS ; DRAW WEEKLY MATCHUPS(X,Y = PPU ADDR, $45= HM TEAM, $44= AWAY TEAM)
JMP @go_to_next_matchup ; JUMP -> GO TO NEXT MATCHUP CHECK IF DONE
@clear_dividing_line: ; CLEAR DIVIDING ROW WITH WEEK AND DATE
LDA #$01 ; SET ROWS = 1
STA num_rows ;
LDA #$07 ; SET LENGTH = 7
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
@go_to_next_matchup: ; GO TO NEXT MATCHUP CHECK IF DONE
INC current_row_of_week ;
INC current_game_in_week ; CURRENT WEEKLY MATCHUP++
@check_done_with_week:
LDA current_game_in_week ; IS CURRENT WEEKLY MATCHUP > MAX GAMES PER WEEK
CMP #MAX_GAMES_PER_WEEK ;
BCC @draw_next_matchup_in_week ; NO-> DRAW NEXT WEEKLY MATCHUP
@set_week_to_next_week:
INC current_week ; CURRENT WEEK INDEX++
INC number_of_weeks_on_page_drawn ; NUMBER OF WEEKS DRAWN++
LDA current_week ; IS CURRENT WEEK INDEX >17
CMP #FIRST_WEEK_OF_PLAYOFFS ;
BCS @clear_last_three_week_area ; YES->CLEAR BOTTOM PART OF SCHEDULE TO ONLY SHOW WEEK 17
LDA number_of_weeks_on_page_drawn ; DOES NUMBER OF WEEKS DRAWN = 4 WEEKS
CMP #WEEKS_PER_PAGE ;
BCS @exit_jump ; ***could branch exit draw YES->DRAW SCHEDULE RETURN
JMP @draw_4_weeks_of_schedule_loop ; NO->DRAW 4 WEEKS OF SCHEDULE LOOP
@exit_jump: ; WASTE OF CODE
JMP @exit_draw_schedule ;
@clear_last_three_week_area: ; CLEAR BOTTOM PART OF SCHEDULE TO ONLY SHOW WEEK 17
LDY #<SECOND_WEEK_SCHEDULE_START ; SET PPU ADDRESS TO CLEAR = $2140
LDX #>SECOND_WEEK_SCHEDULE_START ;
LDA #NUMBER_OF_ROWS_TO_CLEAR_SHOW_SINGLE_WEEK ; SET ROWS = 18
STA num_rows ;
LDA #LENGTH_OF_ONE_ROW ; SET LENGTH = 32
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
@exit_draw_schedule: ; DRAW SCHEDULE RETURN
LDX #MAIN_GAME_BANK_2 ; LOAD BANK 18
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
RTS ; RETURN
DRAW_DATE_HEADERS_AND_DIVIDING_LINES: ; DRAW WEEK DATES AND DIVIDING LINES(X,Y =PPU ADDRESS, A= WEEK)
week_num_bcd = LOCAL_7
current_week = LOCAL_6
STY ppu_addr_temp ; SAVE PPU ADDRESS
STX ppu_addr_temp+1 ;
STA current_week ; SAVE WEEK NUMBER
LDA #<WEEK_AND_DIVIDING_LINE_DATA ; SET DRAW COMMAND DATA ADDRESS = WEEK AND MOST OF DIVIDING LINE = $WEEK_AND_DIVIDING_LINE_DATA
STA data_addr_temp ;
LDA #>WEEK_AND_DIVIDING_LINE_DATA ;
STA data_addr_temp +1 ;
JSR TRANSFER_TO_PPU_OR_PPUBUFF_WITH_COMMANDS ; TRANSFER DATA TO PPU VIA BUFFER OR DIRECT DEPENDING ON PALLETE FADE (X,Y=PPU ADDR, 3E,3F DRAW COMMAND ADDR)
LDA current_week ; LOAD WEEK NUMBER
ASL ;
ASL ;
ASL ;
CLC ;
ADC #<SCHEDULE_DATE_HEADERS_TABLE ; SET DRAW COMMAND DATA ADDRESS = DATE AND REST OF DIVIDING LINE= $8743
STA data_addr_temp ;
LDA #$00 ;
ADC #>SCHEDULE_DATE_HEADERS_TABLE ;
STA data_addr_temp+1 ;
LDA_ABS_A_ZP ppu_addr_temp ; SET PPU ADDRESS = PPU ADDRESS + OFFSET TO REST OF DIVIDING LINE *** doesn't use ZP instruction can fix
CLC ;
ADC #OFFSET_TO_DIVIDING_LINE ;
TAY ;
LDX ppu_addr_temp+1 ;
JSR TRANSFER_TO_PPU_OR_PPUBUFF_WITH_COMMANDS ; TRANSFER DATA TO PPU VIA BUFFER OR DIRECT DEPENDING ON PALLETE FADE (X,Y=PPU ADDR, 3E,3F DRAW COMMAND ADDR)
LDA current_week ; WEEK NUMBER++
CLC ;
ADC #$01 ;
JSR HEX_TO_2_DIGIT_DEC ; CONVERT HEX NUMBER TO DECIMAL()
LDY ppu_addr_temp ;
LDX ppu_addr_temp+1 ;
INY ; PPU ADDRESS++
LDA week_num_bcd ; IS WEEK NUMBER < 1 DIGIT?
CMP #$0A ;
BCC @draw_week_number ; YES->TRANSFER WEEK NUMBER BUFFER INFO TO BUFFER INFO
JMP CONVERT_2_DIG_NUM_TILES ; CONVERT 2 DIGIT NUMBER TO TILES AND SAVE IN BUFFER(A=NUMBER)
@draw_week_number: ; TRANSFER WEEK NUMBER BUFFER INFO TO BUFFER INFO
INY ; PPU ADDRESS++
LDA #$01 ; SET LENGTH
JSR WAIT_FOR_BUFFER_FREE_ENOUGH_SPACE ; WAIT FOR BUFFER READY AND SAVE BUFFER_INFO (X,Y= PPU ADDRESS TO UPDATE, A= LENGTH)
LDA week_num_bcd ; CONVERT SECOND DIGIT TO TILE
CLC ;
ADC #OFFSET_TO_NUMBER_TILES ;
STA CURRENT_BG_BUFFER_LOC,X ; SAVE SECOND DIGIT TILE IN BUFFER
INX ; BUFFER INDEX++
JMP SET_END_BUF_SEGMENT_BUF_LEN_BUF_READY ; JUMP->SET CURRENT BUFFER LOCATION AS END AND SET BUFFER TO READY()
_F}_DRAW_SCHEDULE
_F{_DRAW_WEEKLY_MATCHUP_TEXT ; DONE
matchup_text_length = $07
team_abrev_addr = LOCAL_1
home_team = LOCAL_8
away_team = LOCAL_7
abbrev_length = $03
DRAW_WEEKLY_MATCHUPS: ; DRAW WEEKLY MATCHUPS(X,Y = PPU ADDR, $45= HM TEAM, $44= AWAY TEAM))
LDA #matchup_text_length ; SET DATA LENGTH
JSR WAIT_FOR_BUFFER_FREE_ENOUGH_SPACE ; WAIT FOR BUFFER READY AND SAVE BUFFER_INFO (X,Y= PPU ADDRESS TO UPDATE, A= LENGTH)
LDA home_team ; LOAD HOME TEAM
JSR CONVERT_TEAM_ID_TO_TEXT_ABBREV ; CONVERT TEAM ID TO TEXT AND SAVE IN BUFFER(A= TEAM ID)
LDA #MATCHUP_X_TILE_ID ; SET TILE BETWEEN TEAMS = STAR TILE
STA CURRENT_BG_BUFFER_LOC,X ;
INX ; BUFFER INDEX ++
LDA away_team ;
JSR CONVERT_TEAM_ID_TO_TEXT_ABBREV ;
JMP SET_END_BUF_SEGMENT_BUF_LEN_BUF_READY ; JUMP TO SET CURRENT BUFFER LOCATION AS END AND SET BUFFER TO READY()
CONVERT_TEAM_ID_TO_TEXT_ABBREV: ; SAVE 3 LETTER TEAM ABBREVIATION IN TEXT BUFFER (A= TEAM ID)
ASL ; SHIFT TEAM ID TO GET OFFFSET INTO TABLE
TAY ;
LDA TEAM_ABBREVIATION_POINTERS,Y ; SET TEAM ABBR ADRR = TEAM ABBREVIATION TABLE + TEAM OFFSET = $BC00 IN BANK 16
STA team_abrev_addr ;
LDA TEAM_ABBREVIATION_POINTERS+1,Y ;
STA team_abrev_addr+1 ;
LDY #$00 ; SET DATA INDEX TO START
@copy_letters_to_buffer
_WHILE CC
LDA (team_abrev_addr),Y ; SAVE LETTER IN BUFFER
STA CURRENT_BG_BUFFER_LOC,X ;
INY ; DATA ADDR++
INX ; BUFFER INDEX ++
CPY #abbrev_length ; ALL 3 LETTERS SAVED?
_END_WHILE
RTS ; RETURN
_F}_DRAW_WEEKLY_MATCHUP_TEXT
_F{_BLINK_CURRENT_GAME_IN_WEEK ; DONE
WEEKS_PER_PAGE = $04
ROWS_PER_MATCHUP_BLINK = $01
TILES_PER_MATCHUP_BLINK = $07
schedule_page_bitmask = $FC
num_tiles = LOCAL_1
num_rows = LOCAL_2
offset_to_game_in_week = LOCAL_7
ppu_addr_temp = LOCAL_1
home_team = LOCAL_8
away_team = LOCAL_7
FLASH_CURRENT_GAME_IN_SCHEDULE: ; BLINK CURRENT GAME IN SCHEDULE
@check_for_playoffs:
LDA CURRENT_WEEK_IN_SEASON ; LOAD CURRENT SEASON WEEK
CMP #FIRST_WEEK_OF_PLAYOFFS ; IS CURRENT SEASON WEEK > 17
BCS @exit ; YES-> EXIT WITHOUT BLINKING
@check_if_on_right_schedule_page:
AND #schedule_page_bitmask ;
CMP current_schedule_page ;
BNE @exit
@get_matchup_ppu_addr:
LDA CURRENT_WEEK_IN_SEASON ; LOAD CURRENT SEASON WEEK
AND #(WEEKS_PER_PAGE -1) ; SET WEEKS = MULTIPLE OF 4 WEEKS
LDX #NUMBER_OF_TEAMS_IN_LEAGUE ; SET TEAMS = 28
JSR MULTIPLY_A_TIMES_X ; MULTIPLY (A * X) RESULT IN $44,45
LDA CURRENT_GAME_IN_WEEK ; LOAD CURRENT SEASON GAME INDEX
ASL ; SHIFT SINCE TWO BYTES FOR MATCHUP
CLC ;
ADC offset_to_game_in_week ; ADD OFFSET TO CURRENT GAME
TAX ;
LDA SCHEDULE_PPU_ADDR_TABLE,X ; SET PPU ADDR = WEEKLY MATCHUP PPU LOCATION TABLE + GAME OFFSET + WEEK OFFSET
STA ppu_addr_temp ;
LDA SCHEDULE_PPU_ADDR_TABLE+1,X ;
STA ppu_addr_temp+1 ;
@blink_delay_every_eight_frames:
LDA FRAME_COUNTER ; IS FRAME = NOT DRAW FRAME = 7 FRAMES
AND #$07 ;
BNE @exit ; BRANCH-> EXIT WITHOUT BLINKING
LDA FRAME_COUNTER ;
AND #$08 ; IS FRAME = DRAW FRAME = 8 FRAMES
BEQ @draw_text_for_blinking_effect ; YES-> DRAW MATCHUP TILES FOR BLINKING
@clear_text_for_blinking_effect:
LDY ppu_addr_temp ; SET PPU ADDR = MATCHUP TO DRAW BLANK TILES INTO
LDX ppu_addr_temp +1 ;
LDA #ROWS_PER_MATCHUP_BLINK ; SET NUM ROWS =1
STA num_rows ;
LDA #TILES_PER_MATCHUP_BLINK ; SET LENGTH =7
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
RTS ; RETURN
@draw_text_for_blinking_effect: ; DRAW MATCHUP TILES FOR BLINKING
LDX #DRAW_SCHEDULE_SCRIPT_BANK ; LOAD BANK 16
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
LDA CURRENT_GAME_IN_WEEK ; LOAD SEASON WEEKLY GAME INDEX
ASL ;
TAX ;
LDA WEEKLY_MATCHUPS_START,X ; LOAD HOME TEAM FROM CURRENT WEEK MATCHUPS SRAM
STA home_team ;
LDA WEEKLY_MATCHUPS_START+1,X ; LOAD AWAY TEAM FROM CURRENT WEEK MATCHUPS SRAM
STA away_team ;
LDY ppu_addr_temp ;
LDX ppu_addr_temp+1 ;
JSR DRAW_WEEKLY_MATCHUPS ; DRAW WEEKLY MATCHUPS(X,Y = PPU ADDR, $45= HM TEAM, $44= AWAY TEAM)
LDX #MAIN_GAME_BANK_2 ; LOAD BANK 18
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
@exit: ; DISPLAY MATCHUP RETURN
RTS ; RETURN
_F}_BLINK_CURRENT_GAME_IN_WEEK
_F{_RESET_RANOMIZE_SCHED ; DONE
games_per_week_temp = LOCAL_1
num_times_schuff_sched = LOCAL_2
current_week_sched_addr = LOCAL_7
RESET_SCHEDULE_RANDOMIZE_ORDER: ; RESET SCHEDULE AND RANDOMIZE GAME ORDER
MMC3_SRAM_WRITE_ENABLE
LDA CURRENT_WEEK_IN_SEASON ; LOAD CURRENT SEASON WEEK
ASL ;
TAX ;
LDA WEEKLY_SCHEDULE_PTR_TABLE,X ; SET SCHEDULE LOCATION = SCHEDULE START + WEEK OFFSET
STA current_week_sched_addr ;
LDA WEEKLY_SCHEDULE_PTR_TABLE+1,X ;
STA current_week_sched_addr +1 ;
LDX CURRENT_WEEK_IN_SEASON ; LOAD CURRENT SEASON WEEK
LDA GAMES_PER_WEEK_ARRAY,X ; LOAD GAMES IN CURRENT WEEK FROM GAMES IN WEEK TABLE
STA games_per_week_temp ; SAVE GAMES IN CURRENT WEEK
ASL ; MULTPLY BY 2 SINCE TWO TEAMS PER GAME
TAX ; TEAMS TO TRANSFER
@save_weeks_matchups_in_sram:
LDY #$00 ; SET TO FIRST MATCHUP
@save_matchups: ; SAVE GAME MATCHUPS IN SRAM GAME MATCHUPS
LDA (current_week_sched_addr),Y ;
STA WEEKLY_MATCHUPS_START,Y ;
INY ; WEEKLY MATCHUP DATA ADDR++
DEX ; TEAMS TO TRANSFER--
BNE @save_matchups ; DONE TRANSFERRING MATCHUPS? NO-> SAVE GAME MATCHUPS IN SRAM GAME MATCHUPS
@set_number_of_times_to_shuffle
JSR HEAVIER_RANDOMIZE ; UPDATE RANDOM NUMBER VALUES AND MAKE VALUE RETURNED MORE RANDOM
AND #$0F ; MAKE RANDOM = 11-26
CLC ;
ADC #$0B ;
STA num_times_schuff_sched ;
_WHILE NOT_EQUAL
rand_matchup_index = LOCAL_5
games_per_week_temp_two = LOCAL_7
rand_value = LOCAL_8
JSR HEAVIER_RANDOMIZE ; UPDATE RANDOM NUMBER VALUES AND MAKE VALUE RETURNED MORE RANDOM
STA rand_value ;
LDA games_per_week_temp ; LOAD NUMBER OF GAMES IN WEEK
STA games_per_week_temp_two ;
JSR DIVIDE_8_BIT ; 8 BIT DIVIDE ($45/$44) QUOTIENT $45 REMAINDER $42
LDA rand_matchup_index ; SET MATCHUP INDEX
ASL ;
TAX ;
LDY WEEKLY_MATCHUPS_START,X ; SWAP RANDOM MATCHUP WITH FIRST MATCHUP
LDA WEEKLY_MATCHUPS_START ;
STY WEEKLY_MATCHUPS_START ;
STA WEEKLY_MATCHUPS_START,X ;
LDY WEEKLY_MATCHUPS_START + 1,X ;
LDA WEEKLY_MATCHUPS_START + 1 ;
STY WEEKLY_MATCHUPS_START + 1 ;
STA WEEKLY_MATCHUPS_START + 1,X ;
DEC num_times_schuff_sched ; NUMBER OF TIMES TO SHUFFLE--
_END_WHILE
@save_checksum_exit:
JSR GET_SAVE_CHECKSUM ; CALCULATE AND STORE SRAM CHECKSUM
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
_F}_RESET_RANOMIZE_SCHED
_F{_GET_GAMES_IN_WEEK ; DONE
games_in_week = LOCAL_8
GET_NUMBER_OF_GAMES_IN_WEEK: ; GET GAMES IN WEEK() RET $45= NUM GAMES
LDA CURRENT_GAME_IN_WEEK ; POINTLESS CODE
LDX CURRENT_WEEK_IN_SEASON ; LOAD SEASON CURRENT WEEK INDEX FROM SRAM
LDA GAMES_PER_WEEK_ARRAY,X ; LOAD GAMES IN CURRENT WEEK
STA games_in_week ; SAVE IN $45
RTS ; RETURN
_F}_GET_GAMES_IN_WEEK ; DONE
_F{_CLEAR_SEASON_INFO ; DONE
data_addr_low = LOCAL_7
current_team = LOCAL_6 ; 0 indexed
SKP_TEAM_CTRL = $03
CLEAR_SEASON_INFO: ; CLEAR SEASON STATS/WINNERS,SET DEFAULT PLAYBOOKS, STARTERS, CONDITIONS, INJURIES
MMC3_SRAM_WRITE_ENABLE
LDA #<SIZE_OF_SEASON_INFO ; SET SIZE TO CLEAR = $18B2 -1
LDX #>SIZE_OF_SEASON_INFO ;
LDY #<SEASON_INFO_START ; SET SRAM DATA ADDR = $66C0
STY data_addr_low ;
LDY #>SEASON_INFO_START ;
JSR CLEAR_RAM ; CLEAR RAM (X * 0x100 + A , $44,Y= DATA ADDR)
LDA #$00 ; SET CURRENT TEAM = FIRST TEAM
STA current_team ;
_WHILE CC ; RESET TO DEFAULT TEAM INFO (STARTERS, CONDITIONS, PLAYBOOKS, INJURIES) LOOP
LDA current_team ; LOAD CURRENT TEAM
JSR RESET_STARTERS_INJURIES_CONDITIONS ; RELOAD STARTERS, CONDITIONS, INJURIES(A= TEAM ID)
LDA current_team ;
JSR RESET_TEAM_PLAYBOOK_TO_DEFAULT ; RELOAD DEFAULT PLAYBOOKS(A= TEAM ID)
INC current_team ; CURRENT TEAM ++
LDA current_team ;
CMP #NUMBER_OF_TEAMS_IN_LEAGUE ; ALL 28 TEAMS DONE?
_END_WHILE
@set_playoff_teams_to_none:
SET_RAM_Y_INDEX[start_length_value] PLAYOFF_TEAMS[], NUM_OF_PLAYOFF_TEAMS, $FF
@set_all_team_ctrl_to_skip:
SET_RAM_Y_INDEX[start_length_value] TEAM_TYPE_SEASON, NUMBER_OF_TEAMS_IN_LEAGUE , SKP_TEAM_CTRL
JSR SAVE_DEFAULT_AFC_PLAYERS_SRAM ; SAVE DEFAULT AFC PRO BOWL PLAYERS INTO SRAM()
JSR SAVE_DEFAULT_AFC_STARTERS_SRAM ;
JSR SAVE_DEFAULT_NFC_PLAYERS_SRAM ; SAVE DEFAULT NFC PRO BOWL PLAYERS INTO SRAM()
JSR SAVE_DEFAULT_NFC_STARTERS_SRAM ;
; RESET PROBOWL PLAYBOOKS
LDA #AFC_TEAM_ID ; SET CURRENT TEAM = AFC
STA current_team ;
JSR RESET_TEAM_PLAYBOOK_TO_DEFAULT ; RELOAD DEFAULT PLAYBOOKS(A= TEAM ID)
LDA #NFC_TEAM_ID ; SET CURRENT TEAM = NFC
STA current_team ;
JSR RESET_TEAM_PLAYBOOK_TO_DEFAULT ; RELOAD DEFAULT PLAYBOOKS(A= TEAM ID)
JSR GET_SAVE_CHECKSUM ;
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
team_sram_addr_temp = LOCAL_1
offset_to_kr_pr_starter = $03
QB1_RB1_starter_byte = $02
RB1_WR1_starter_byte = $36
WR2_TE1_starter_byte = $7A
RESET_STARTERS_INJURIES_CONDITIONS: ; LOAD DEFAULT STARTERS, CONDITIONS, INJURIES INTO SRAM(A= TEAM ID)
TAX ; SET INDEX = SHIFT TEAM ID SINCE EACH TABLE ENTRY TWO BYTES
ASL ;
TAY ;
LDA TEAM_STAT_SRAM_ADDR,Y ; LOAD TEAM SRAM START LOCATION FROM TEAM SRAM START LOCATIONS
STA team_sram_addr_temp ;
LDA TEAM_STAT_SRAM_ADDR+1,Y ;
STA team_sram_addr_temp +1 ;
@set_default_kr_and_pr
LDA DEFAULT_KR_PR_TABLE,X ; LOAD KR/PR STARTERS FROM DEFAULT KR/PR TABLE
LDY #STARTERS_SEASON_STATS_OFFSET + offset_to_kr_pr_starter
STA (team_sram_addr_temp),Y ;
@set_defuault_skill_season_starters:
LDY #STARTERS_SEASON_STATS_OFFSET ; SET QB1, RB1 AS DEFAULT STARTERS
LDA #QB1_RB1_starter_byte ;
STA (team_sram_addr_temp),Y ;
INY ; DATA ADDR++
LDA #RB1_WR1_starter_byte ; SET RB2, WR1 AS DEFAULT STARTERS
STA (team_sram_addr_temp),Y ;
INY ; DATA ADDR++
LDA #WR2_TE1_starter_byte ; SET WR2, TE1 AS DEFAULT STARTERS
STA (team_sram_addr_temp),Y ;
@set_all_players_not_inured: ; only skill players can be injured
LDY #INJURIES_SEASON_STATS_OFFSET ;
LDA #$00 ; SET PLAYER INJURIES = NOT INJURED
STA (team_sram_addr_temp),Y ;
INY ;
STA (team_sram_addr_temp),Y ;
INY ;
STA (team_sram_addr_temp),Y ;
LDY #CONDITIONS_SEASON_STATS_OFFSET ; *** could use different loop SET CONDITION VALUE = AVERAGE CONDITION
LDA #ALL_AVERAGE_CONDITION ;
@set_conditions: ; SET ALL PLAYERS CONDITIONS LOOP
STA (team_sram_addr_temp),Y ;
INY ; CONDITION BYTE INDEX++
CPY #$D0 ;
BCC @set_conditions ; DONE? NO-> SET ALL PLAYERS CONDITIONS LOOP
RTS ; RETURN
_F}_CLEAR_SEASON_INFO
_F{_RESET_SINGLE_TEAM_PLAYBOOK ; DONE
RESET_TEAM_PLAYBOOK_TO_DEFAULT_SAVE_CHECKSUM: ; LOAD DEFAULT PLAYBOOKS INTO SEASON SRAM AND CALCULATE CHECKSUM($43= TEAM)
MMC3_SRAM_WRITE_ENABLE
JSR RESET_TEAM_PLAYBOOK_TO_DEFAULT ;
JSR GET_SAVE_CHECKSUM ; CALCULATE AND STORE SRAM CHECKSUM()
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
team_sram_addr = LOCAL_1
team_id = LOCAL_6
RESET_TEAM_PLAYBOOK_TO_DEFAULT: ; LOAD DEFAULT PLAYBOOKS INTO SEASON SRAM($43 = TEAM)
LDX #TEAM_DEFAULT_PLAYBOOKS_BANK ; LOAD BANK 15
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
LDA team_id ; LOAD TEAM ID
CMP #AFC_TEAM_ID ; IS TEAM ID = PROBOWL TEAM
BCS @check_afc_or_nfc_probowl_team ; SET INDEX = SHIFT TEAM ID SINCE EACH TABLE ENTRY TWO BYTES
@set_regular_team_sram_addr:
TAX ;
ASL ;
TAY ;
LDA TEAM_STAT_SRAM_ADDR,Y ; SET TEAM SRAM START LOCATION FROM TEAM SRAM START LOCATIONS + TEAM INDEX
STA team_sram_addr ;
LDA TEAM_STAT_SRAM_ADDR+1,Y ;
STA team_sram_addr+1 ;
TXA ; LOAD TEAM ID = SHIFT BY 4 SINCE EACH PLAYBOOK ENTRY = 4 BYTES = 8 PLAYS
SHIFT_LEFT_2 ;
TAX ;
@save_default_playbook_into_sram:
LDY #PLAYBOOK_SEASON_STATS_OFFSET ; = OFFSET TO TEAM PLAYBOOKS
LDA TEAM_PLAYBOOKS,X ; SET FIRST PLAYBOOK BYTE = DEFAULT PLAYBOOK TABLE (0X1D310)+ TEAM OFFSET
STA (team_sram_addr),Y ;
INY ;
LDA TEAM_PLAYBOOKS+1,X ; SET SECOND PLAYBOOK BYTE
STA (team_sram_addr),Y ;
INY ;
LDA TEAM_PLAYBOOKS+2,X ; SET THIRD PLAYBOOK BYTE
STA (team_sram_addr),Y ;
INY ;
LDA TEAM_PLAYBOOKS+3,X ; SET FOURTH PLAYBOOK BYTE
STA (team_sram_addr),Y ;
JMP @exit ; JUMP-> SET $A000 BANK = BANK 18 AND RETURN
@check_afc_or_nfc_probowl_team: ; CHECK PROBOWL TEAM PLAYBOOK TO RESET
CMP #NFC_TEAM_ID ; IS TEAM = AFC PROBOWL
BEQ @set_nfc_default_playbook ; NO-> RESET NFC PROBOWL PLAYBOOK
@set_afc_default_playbook:
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] AFC_PLAYBOOK_PLAY_IDS_DATA, SRAM_AFC_PLAYBOOK, SIZE_OF_EACH_PLAYBOOK
JMP @exit ; JUMP-> SET $A000 BANK = BANK 18 AND RETURN
@set_nfc_default_playbook: ; RESET NFC PROBOWL PLAYBOOK
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] NFC_PLAYBOOK_PLAY_IDS_DATA, SRAM_NFC_PLAYBOOK, SIZE_OF_EACH_PLAYBOOK
@exit: ; SET $A000 BANK = BANK 18 AND RETURN
LDX #MAIN_GAME_BANK_2 ; LOAD BANK 18
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
RTS ; RETURN
_F}_RESET_SINGLE_TEAM_PLAYBOOK
_F{_RESET_PROBOWL_PLAYERS_STARTERS ; DONE
RESET_AFC_STARTERS: ; RESET AFC PROBOWL STARTERS
MMC3_SRAM_WRITE_ENABLE
JSR SAVE_DEFAULT_AFC_PLAYERS_SRAM ; SAVE DEFAULT AFC STARTERS INTO SRAM()
JSR SAVE_DEFAULT_AFC_STARTERS_SRAM ;
JSR GET_SAVE_CHECKSUM ;
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
RESET_NFC_STARTERS: ; RESET NFC PROBOWL STARTERS
MMC3_SRAM_WRITE_ENABLE
JSR SAVE_DEFAULT_NFC_PLAYERS_SRAM ;
JSR SAVE_DEFAULT_NFC_STARTERS_SRAM ;
JSR GET_SAVE_CHECKSUM ;
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
SAVE_DEFAULT_AFC_PLAYERS_SRAM: ; SAVE DEFAULT AFC PRO BOWL PLAYERS INTO SRAM()
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] DEFAULT_AFC_PB_PLAYERS, AFC_PLAYER_INFO, SIZE_OF_PRO_BOWL_PLAYER_INFO
RTS ; RETURN
SAVE_DEFAULT_NFC_PLAYERS_SRAM: ; SAVE DEFAULT NFC PRO BOWL PLAYERS INTO SRAM()
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] DEFAULT_NFC_PB_PLAYERS, NFC_PLAYER_INFO, SIZE_OF_PRO_BOWL_PLAYER_INFO
RTS ; RETURN
SAVE_DEFAULT_AFC_PLAYERS_W_CHECKSUM: ; SAVE DEFAULT AFC PRO BOWL OFFENSIVE STARTERS INTO SRAM AND UPDATE CHECKSUM()
MMC3_SRAM_WRITE_ENABLE
JSR SAVE_DEFAULT_AFC_STARTERS_SRAM ; SAVE DEFAULT AFC PRO BOWL OFFENSIVE STARTERS INTO SRAM()
JSR GET_SAVE_CHECKSUM ; UPDATE SRAM CHECKSUM()
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
SAVE_DEFAULT_NFC_PLAYERS_W_CHECKSUM: ; SAVE DEFAULT NFC PRO BOWL OFFENSIVE STARTERS INTO SRAM AND UPDATE CHECKSUM()
MMC3_SRAM_WRITE_ENABLE
JSR SAVE_DEFAULT_NFC_STARTERS_SRAM ; SAVE DEFAULT NFC PRO BOWL OFFENSIVE STARTERS INTO SRAM()
JSR GET_SAVE_CHECKSUM ; UPDATE SRAM CHECKSUM()
MMC3_SRAM_WRITE_DISABLE
RTS ; RETURN
SAVE_DEFAULT_AFC_STARTERS_SRAM: ; SAVE DEFAULT AFC PRO BOWL OFFENSIVE STARTERS INTO SRAM()
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] DEFAULT_PB_STARTERS, SRAM_AFC_STARTERS, SIZE_OF_PRO_BOWL_STARTERS
RTS ; RETURN
SAVE_DEFAULT_NFC_STARTERS_SRAM: ; SAVE DEFAULT NFC PRO BOWL OFFENSIVE STARTERS INTO SRAM()
COPY_SOURCE_TO_DEST_Y_INDEX[source_dest_length] DEFAULT_PB_STARTERS, SRAM_NFC_STARTERS, SIZE_OF_PRO_BOWL_STARTERS
RTS ; RETURN
_F}_RESET_PROBOWL_PLAYERS_STARTERS
_F{_DRAW_ROSTER_SCREEN_BACKGROUND ; DONE
team_stats_sram_addr = LOCAL_1
DRAW_ROSTER_SCREEN: ; DRAW TEAM DATA SCREEN AND WINS,LOSSES, TIES
@draw_screen_background:
LDA #ROSTER_SCREEN_ID ; LOAD TEAM DATA SCREEN DRAW EVENT INDEX
LDX #DRAW_ROSTER_SCRIPT_BANK ; SET DRAW BANK = BANK 16
JSR DRAW_SCENE_UNTIL_ENDED ; START DRAWING TASK AND DO UNTIL THREAD DESTROYED (A= DRAW EVENT INDEX, X = BANK)
@get_stats_sram_addr
LDA CURRENT_TEAM ; LOAD CURRENT TEAM
JSR GET_TEAM_SEASON_SRAM_ADDR ; LOAD TEAM SEASON SRAM LOCATION IN 3E 3F()
@draw_wins:
LDY #WINS_SEASON_STATS_OFFSET ; LOAD TEAM WINS FROM SRAM
LDA (team_stats_sram_addr),Y ;
JSR HEX_TO_2_DIGIT_DEC ; CONVERT HEX NUMBER TO DECIMAL()
LOAD_ADDR_XY[mem_loc] TEAM_DATA_WINS_PPU_ADDR
JSR CONVERT_2_DIG_NUM_TILES ; CONVERT 2 DIGIT NUMBER TO TILES AND SAVE IN BUFFER(A=NUMBER)
@draw_losses:
LDY #LOSSES_SEASON_STATS_OFFSET ; LOAD TEAM LOSSES FROM SRAM
LDA (team_stats_sram_addr),Y ;
JSR HEX_TO_2_DIGIT_DEC ; CONVERT HEX NUMBER TO DECIMAL()
LOAD_ADDR_XY[mem_loc] TEAM_DATA_LOSSES_PPU_ADDR
JSR CONVERT_2_DIG_NUM_TILES ; CONVERT 2 DIGIT NUMBER TO TILES AND SAVE IN BUFFER(A=NUMBER)
@draw_ties:
LDY #TIES_SEASON_STATS_OFFSET ; LOAD TEAM TIES FROM SRAM
LDA (team_stats_sram_addr),Y ;
JSR HEX_TO_2_DIGIT_DEC ; CONVERT HEX NUMBER TO DECIMAL()
LOAD_ADDR_XY[mem_loc] TEAM_DATA_TIES_PPU_ADDR
JSR CONVERT_2_DIG_NUM_TILES ; CONVERT 2 DIGIT NUMBER TO TILES AND SAVE IN BUFFER(A=NUMBER)
RTS ; RETURN
_F}__DRAW_ROSTER_SCREEN_BACKGROUND
_F{_DRAW_DEF_STARTERS_SCREEN ; DONE
num_tiles = LOCAL_1
num_rows = LOCAL_2
current_roster_id_temp = LOCAL_7
current_temp_temp = LOCAL_8
player_jersey_number = LOCAL_8
current_def_starter = SEGMENT_VAR_8E
empty_def_starter = SEGMENT_VAR_8F
current_team = SEGMENT_VAR_90
current_roster_id = SEGMENT_VAR_91
SIZE_OF_DEF_STARTER_SPRITE_TABLE_ENTRY = $08
SIZE_OF_DEF_STARTER_SPRITE_TABLE = SIZE_OF_DEF_STARTER_SPRITE_TABLE_ENTRY * NUM_DEFENDERS_ON_FIELD
DRAW_DEFENSIVE_STARTERS_SCREEN: ; DRAW DEFENSIVE STARTERS SCREEN
LDA #$00 ; CLEAR IRQ_SPLIT1 COUNTER
STA IRQ_0_COUNTER ;
LDA #DEFENSIVE_STARTERS_SCREEN_ID ; LOAD TEAM DEFENSIVE STARTER DRAW EVENT INDEX
LDX #MENU_DRAW_SCRIPT_BANK ; SET DRAW BANK = BANK 16
JSR DRAW_SCENE_UNTIL_ENDED ; START DRAWING TASK AND DO UNTIL THREAD DESTROYED (A= DRAW EVENT INDEX, X = BANK)
LDA CURRENT_TEAM ; LOAD CURRENT TEAM
CLC ;
ADC #OFFSET_TO_TEAM_NAME ; + OFFSET TO TEAM NAME
LDY #<TEAM_NAME_DEF_STARTER_PPU_ADDR ; SET PPU ADDRESS = $2054
LDX #>TEAM_NAME_DEF_STARTER_PPU_ADDR ;
JSR DRAW_TEAM_NAME_CITY_CONF_TEXT ; DRAW TEAM NAME((X,Y =PPUADDRESS, A= TEAM ID + OFFSET)
@set_jersey_sprite_locations:
LDY #$00 ; SET TABLE INDEX = FIRST LOCATION
LDX #$00 ; SET SPRITE INDEX = FIRST SPRITE
_WHILE CC ; SET DEFENSIVE NUMBERS OVER ARROWS LOCATIONS
@set_sprites_y_location:
LDA DEFENSIVE_STARTER_NUM_SPR_Y_X_TABLE,Y ; LOAD PLAYER JERSEY NUMBER Y LOCATION FROM DEFENSIVE STARTER NUMBER ON TRIANGLE TABLE
STA CUR_JERSEY_NUM_FIRST_DIG_SPR_Y,X ; SET FIRST DIGIT Y LOCATION
STA CUR_JERSEY_NUM_SECOND_DIG_SPR_Y,X ; SET SECOND DIGIT Y LOCATION
LDA DEFENSIVE_STARTER_NUM_SPR_Y_X_TABLE+1,Y ; LOAD PLAYER JERSEY NUMBER X LOCATION FROM DEFENSIVE STARTER NUMBER ON TRIANGLE TABLE
@set_sprites_x_location:
STA CUR_JERSEY_NUM_FIRST_DIG_SPR_X,X ; SET FIRST DIGIT X LOCATION
CLC ;
ADC #SIZE_OF_TILE ; SET SECOND DIGIT X LOCATION = FIRST + ONE TILE
STA CUR_JERSEY_NUM_SECOND_DIG_SPR_X,X ;
@set_sprites_attributes:
LDA #$00 ; SET MIRRORING AND PALLETE
STA CUR_JERSEY_NUM_FIRST_DIG_SPR_ATTR,X ;
STA CUR_JERSEY_NUM_SECOND_DIG_SPR_ATTR,X ;
INY ; TABLE INDEX++
INY ;
@set_to_next_table_entry:
TXA ; SPRITE INDEX = SPRITE INDEX + LENGTH OF TWO SPRITES
CLC ;
ADC #SIZE_OF_DEF_STARTER_SPRITE_TABLE_ENTRY ;
@check_if_done:
TAX ;
CPX #SIZE_OF_DEF_STARTER_SPRITE_TABLE ; ALL 11 PLAYERS NUMBERS DONE?
_END_WHILE ; NO-> DRAW DEFENSIVE NUMBERS OVER ARROWS LOOP
LDA #$00 ; CLEAR IRQ_SPLIT1 COUNTER
STA IRQ_0_COUNTER ;
STA current_def_starter ; SET CURRENT DEFENSIVE STARTER = FIRST STARTER = RE
_WHILE CC ; DRAW DEFENSIVE STARTER NUMBERS ON TRIANGLE AND NUMBER AND NAME LOOP
LDA current_def_starter ;
CLC ;
ADC #OFFSET_TO_FIRST_DEFENDER ;
ASL ;
TAX ;
LDA DEF_STARTER_PLAYERS,X ; LOAD PLAYER TEAM
STA current_team ;
STA current_temp_temp ;
LDA DEF_STARTER_PLAYERS+1,X ; LOAD ROSTER ID
STA current_roster_id_temp ;
STA current_roster_id ;
LDA current_def_starter ;
ASL ;
TAX ; SET PLAYER NUMBER AND NAME PPU LOCATION FROM DEFENSIVE STARTER NUMBER/NAME LOCATION TABLE
LDY DEFENSIVE_STARTER_PPU_ADDR_TABLE,X ;
LDA DEFENSIVE_STARTER_PPU_ADDR_TABLE+1,X ;
TAX ;
JSR DRAW_NUMBER_LAST_NAME_11_CHAR ; TRANSFER NUMBERS AND NAMES TO BUFFER DEFENSIVE STARTERS()
LDA current_team ; LOAD TEAM
LDX current_roster_id ; LOAD STARTER
JSR GET_PLAYER_NUMBER ; GET NEXT PLAYER NUMBER FOR STARTERS(A=TEAM, X=PLAYER) RET A= NUMBER
STA player_jersey_number ; SAVE PLAYER JERSEY NUMBER
LDA current_def_starter ; SHIFT BY EIGHT SINCE EACH SPRITE IS
ASL ;
ASL ;
ASL ;
TAX ; SAVE STARTER INDEX
LDA player_jersey_number ; LOAD PLAYER JERSEY NUMBER
LOG_SHIFT_RIGHT_4
ORA #OFFSET_TO_NUMBER_TILES ; = ADD OFFSET TO NUMBER TILES
BNE @save_player_jersey_numer_sprite ; IF DIGIT IS ZERO SKIP
@if_zero_dont_draw:
LDA #SPRITE_OFFSCREEN ; SET Y LOCATION = OFFSCREEN
STA CUR_JERSEY_NUM_FIRST_DIG_SPR_Y,X
@save_player_jersey_numer_sprite:
STA CUR_JERSEY_NUM_FIRST_DIG_SPR_TILE,X
LDA player_jersey_number ; LOAD PLAYER JERSEY NUMBER
AND #$0F ; MASK OUT FIRST DIGIT
ORA #OFFSET_TO_NUMBER_TILES
STA CUR_JERSEY_NUM_SECOND_DIG_SPR_TILE,X
INC current_def_starter ; CURRENT STARTER ++
LDA current_def_starter ;
CMP #NUM_DEFENDERS_ON_FIELD ; ALL 11 DEFENDERS DONE?
_END_WHILE
LDX #MAIN_GAME_BANK_2 ; LOAD BANK 18
JSR SWAP_A000_BANK ; SWAP $A000 BANK(A= $A000 BANK TO SWAP)
LDA #$02 ; LOAD 2 FRAMES
JSR DELAY_TASK ; SWITCH TASKS (A= NUMBER OF FRAMES BEFORE RETURNING)
@clear_dashes_between_num_name_dl: ; CLEAR DASHES BETWEEN NUMBER AND NAME
LDY #<DL_DASH_DEF_STARTER_PPU_ADDR ; SET PPU LOCATION = $21B4
LDX #>DL_DASH_DEF_STARTER_PPU_ADDR ;
LDA #NUMBER_OF_DL ; SET ROWS = 3 = NUMBER OF DEFENSIVE LINEMAN
STA num_rows ;
LDA #$01 ; SET LENGTH =1
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
@clear_dashes_between_num_name_lb:
LDY #<LB_DASH_DEF_STARTER_PPU_ADDR ; SET PPU LOCATION = $222A
LDX #>LB_DASH_DEF_STARTER_PPU_ADDR ;
LDA #NUMBER_OF_LB ; SET ROWS = 4 = NUMBER OF LINEBACKERS
STA num_rows ;
LDA #$01 ; SET LENGTH =1
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
@clear_dashes_between_num_name_db:
LDY #<DB_DASH_DEF_STARTER_PPU_ADDR ; SET PPU LOCATION = $2310
LDX #>DB_DASH_DEF_STARTER_PPU_ADDR ;
LDA ##NUMBER_OF_DB ; SET ROWS = 4 = NUMBER OF DEFENSIVE BACKS
STA num_rows ;
LDA #$01 ; SET LENGTH =1
STA num_tiles ;
JSR FILL_SCREEN_BLANK_TILE_AREA ; SET BUFFER TO BLANK TILE(X,Y= PPU ADDR, 3F= NUM ROWS, 3E= length)
; UPDATE TILE BANKS TO USE
@upate_chr_banks_and_set_pallete:
LDA #NUMBERS_CHR_BANK_ID ; SET SOFT CHR BANK $1000 = BANK 32
STA SOFT_CHR_1000_BANK ;
LDA #LETTERS_CHR_BANK_ID ; SET SOFT CHR BANK $1400 = BANK 33
STA SOFT_CHR_1400_BANK ;
LDA #DEF_STARTERS_BG_PAL_INDEX ; LOAD BACKGROUND PALLETE INDEX
LDX #DEF_STARTERS_SPR_PAL_INDEX ; LOAD SPRITE PALLETE INDEX
JSR SET_BG_SPR_PAL_SET_FULLY_FADED_IN ; UPDATE PALLETES,SOFT PALLETE IDS AND SET PALLETE FADES TO FULLY FADED IN(A= BACKGROUND, X = SPRITE)
_WHILE EQUAL ; CHECK FOR A OR B PRESS TO EXIT
RETURN_1_FRAME
LDA JOY_PRESS_BOTH ; IS P1/P2 PRESS = A OR B
AND #(A_BUTTON + B_BUTTON) ;
_END_WHILE
RTS ; RETURN
DEFENSIVE_STARTER_PPU_ADDR_TABLE: ; DEFENSIVE STARTER NUMBER/NAME LOCATION TABLE
.WORD RE_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD NT_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD LE_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD ROLB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD RILB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD LILB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD LOLB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD RCB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD LCB_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD FS_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
.WORD SS_NUMBER_BOT_SCRN_DEF_STARTER_PPU_ADDR
DEFENSIVE_STARTER_NUM_SPR_Y_X_TABLE: ; DEFENSIVE STARTER NUMBER ON TRIANGLE LOCATION
; Y,X
.DB LE_DEF_STARTER_TRIANGLE_SPR_Y, LE_DEF_STARTER_TRIANGLE_SPR_X
.DB NT_DEF_STARTER_TRIANGLE_SPR_Y, NT_DEF_STARTER_TRIANGLE_SPR_X
.DB RE_DEF_STARTER_TRIANGLE_SPR_Y, RE_DEF_STARTER_TRIANGLE_SPR_X
.DB LOLB_DEF_STARTER_TRIANGLE_SPR_Y, LOLB_DEF_STARTER_TRIANGLE_SPR_X
.DB LILB_DEF_STARTER_TRIANGLE_SPR_Y, LILB_DEF_STARTER_TRIANGLE_SPR_X
.DB RILB_DEF_STARTER_TRIANGLE_SPR_Y, RILB_DEF_STARTER_TRIANGLE_SPR_X
.DB ROLB_DEF_STARTER_TRIANGLE_SPR_Y, ROLB_DEF_STARTER_TRIANGLE_SPR_X
.DB LCB_DEF_STARTER_TRIANGLE_SPR_Y, LCB_DEF_STARTER_TRIANGLE_SPR_X
.DB RCB_DEF_STARTER_TRIANGLE_SPR_Y, RCB_DEF_STARTER_TRIANGLE_SPR_X
.DB FS_DEF_STARTER_TRIANGLE_SPR_Y, FS_DEF_STARTER_TRIANGLE_SPR_X
.DB SS_DEF_STARTER_TRIANGLE_SPR_Y, SS_DEF_STARTER_TRIANGLE_SPR_X
_F}_DRAW_DEF_STARTERS_SCREEN
_F{_DRAW_TEAM_CONTROL_SCREEN ; DONE
current_team_index = LOCAL_8
current_team_ctrl = LOCAL_7
team_control_bitmask = $03 ; 00 =man, 01=coa, 02=com, 03= skp
temp_arrow_attr = LOCAL_8
DRAW_TEAM_CONTROL_TYPE_SCREEN: ; MAN,COM,COA,SKP CONTROL MODE SCREEN()
LDA #$00 ; SET TEAMS DRAWN = 0
STA current_team_index ;
_WHILE NOT_EQUAL ; DRAW ALL TEAMS CONTROL TYPE LOOP
LDX current_team_index ;
LDA TEAM_TYPE_SEASON,X ; SET TEAM TYPE = SRAM SEASON TEAM TYPES + TEAM INDEX
STA current_team_ctrl ;
JSR DRAW_MAN_SKP_COA_COM_TEXT ; DRAW MAN,SKP COA, COM TEXT (X=TEAM ID, $44 = TEAM TYPE)
INC current_team_index ; TEAMS DRAWN++
LDA current_team_index ;
CMP #NUMBER_OF_TEAMS_IN_LEAGUE ; ALL TEAMS DONE?
_END_WHILE
LDA #TEAM_CONTROL_BG_PAL_INDEX ; SET BACKGROUND PALLETE INDEX = 0X14
LDX #TEAM_CONTROL_SPR_PAL_INDEX ; SET SPRITE PALLETE INDEX = 0X23
JSR SET_BG_SPR_PAL_SET_FULLY_FADED_IN ; UPDATE PALLETES,SOFT PALLETE AND SET PALLETE FADE TO FADED IN(A= BACKGROUND, X = SPRITE)
RETURN_IN_NUM_FRAMES 2
LDA #$00 ;
STA MENU_Y ; SET MENU Y INDEX = FIRST OPTION
STA MENU_X ; SET MENU X INDEX = FIRST OPTION
LDY #<TEAM_CONTROL_MENU_OPTIONS_MAP ; SET MAN,SKP,COA,COM MENU OPTIONS DATA ADDRESS
LDX #>TEAM_CONTROL_MENU_OPTIONS_MAP ;
LDA #BOTH_JOYPADS ; SET PLAYER JOY = BOTH
JSR INIT_MENU_OPTIONS ; INITIALIZE MENU X,Y OPTIONS (X,Y= ADDRESS, A= PLAYER JOY)
TEAM_CTRL_CHANGE_LOOP: ;
RETURN_1_FRAME
JSR CHECK_INPUT_MENU ; CHECK FOR MOVE ARROW ON MENU X OR Y()
@cycle_between_four_colors
LDA MENU_ARROW_SPR_ATTR ; SWITCH ARROW PALLETE BETWEEN 4 COLORS FOR FLASHING EFFECT
AND #$FC ;
STA temp_arrow_attr ;
LDA FRAME_COUNTER ;
LSR ;
AND #$03 ;
ORA temp_arrow_attr ;
STA MENU_ARROW_SPR_ATTR ;
JSR SET_MENU_ARROW_X_Y ;
IF_NEITHER_JOY_PRESSED_B[ADDR] CHECK_CHANGE_TEAM_CTRL_TYPE ; *** could jump to exit direct
@else_exit:
JMP TEAM_CTRL_TYPE_EXIT ; YES->EXIT
CHECK_CHANGE_TEAM_CTRL_TYPE: ; CHECK FOR UPDATE SEASON TEAM TYPE
BPL TEAM_CTRL_CHANGE_LOOP ; IS A PRESSED?
JSR GET_MENU_INDEX_X_Y ; GET INDEX INTO MENU ARROW MAP (RET=A)
JSR GET_TEAM_ID_FOR_TEAM_CONTROL ; LOAD TEAM CONTROL TEAM ID (A= MENU INDEX)
TAX ; SAVE TEAM ID
@change_team_control_type_sram:
MMC3_SRAM_WRITE_ENABLE
LDA TEAM_TYPE_SEASON,X ; LOAD SEASON TEAM TYPE FROM SEASON TEAM TYPE + TEAM ID
CLC ;
ADC #$01 ; SEASON TEAM TYPE = NEXT TEAM TYPE
AND #team_control_bitmask ;
STA TEAM_TYPE_SEASON,X ; SAVE SEASON TEAM TYPE
STA current_team_ctrl ;