; FOOTBALL -- CARTRIDGE 3002     (C) 1979, BALLY MFG.
; 
; "BALLY FOOTBALL" for Bally Arcade / Astrocade
;
; Retyped by Adam Trionfo from original assembly listing.
;
; See end of source file for details.

        INCLUDE "HVGLIB.H"      ; Home Video Game Library

;   MISC. EQUATES
;
;   RESTART VECTORS PSEUDO NAMES
;
QORF     EQU    $08       ; RST08 - RETURNS CHECK FOR QTRBACK/FOOTBALL VECTOR
CMAG     EQU    $10       ; RST10 - CURRENT LINE OF SCRIMMAGE MAGIC REGISTER
PBOX     EQU    $18       ; RST18 - PAINT A RECTANGLE
NDXW     EQU    $20       ; RST20 - INDEX A WORD TABLE
NUMP     EQU    $28       ; RST28 - NUMBER OF PLAYERS (Z=2-PLYR, NZ=4-PLYR)
;
VECTSZ   EQU    19        ; VECTOR BLOCK SIZE

;**********
;*
;*   R A M   A L L O C A T I O N S
;*
;
;        ORG    4E73H
;
L4E73     EQU   $4E73     ; BLOCK 12
MUSICWRK  EQU   $4E7F     ; BLOCK 2
NUMPLAYR  EQU   $4E81     ; NUMBER OF PLAYERS (VERSION 2-PLYR OR 4-PLYR) - BLOCK 1
L4E82     EQU   $4E82     ; BLOCK 1
QOLDPATR  EQU   $4E83     ; OLD QUARTERBACK PATTERN ADDRESS - BLOCK 2
QPOSOLDX  EQU   $4E85     ; OLD QUARTERBACK VECTOR X COORDINATE - BLOCK 1
QPOSOLDY  EQU   $4E86     ; OLD QUARTERBACK VECTOR Y COORDINATE - BLOCK 1
CURVECT   EQU   $4E87     ; CURRENT VECTOR TABLE INDEX (FOR ANIMATION) - BLOCK 1


;
;**********
;*
;*   VECTOR DEFINITIONS
;*
;
;      FOOTBALL USES 16 VECTORS FOR ANIMATION OF THE FIGURES REQUIRED TO
;   PLAY "FOOTBALL".  THE VECTORS ARE ASSIGNED AS FOLLOWS:
;
;       VECTOR NAME          FIGURE
;       -----------   ----------------------------------------------
;        VCTEND1       TOP OFFENSIVE END
;        VCTEND2       BOTTOM OFFENSIVE END
;        VCTEND3       BOTTOM DEFENSIVE END
;        VCTEND4       TOP DEFENSIVE END
;        VCTOQTRB      OFFENSIVE QUARTERBACK : THE FOOTBALL
;                        SPECIAL BITS:  VBSTAT (5) - WE HAVE THE BALL
;                                              (4) -
;                                              (3) - 
;                                              (2) -
;                                              (1) 0 - DO NOT CATCH BALL
;                                                  1 - CATCH BALL
;                                              (0) -
;
;                                       VBXCHK (4) 0=QUARTERBACK
;                                                  1=FOOTBALL
;
;        VCTLIN01      OFFENSIVE LINEMAN 1 : PLAYER SELECTION CURSOR
;                        IF CURSOR: VBYCHK (6) - CURSOR CYCLE COMPLETE
;                                          (5) - CURSOR CYCLE ENABLE
;
;        VCTLIN02        "           "   2
;        VCTLIN03        "           "   3
;        VCTLIN04        "           "   4
;        VCTLIN05        "           "   5
;
;        VCTDQTRB      DEFENSIVE CENTER
;        VCTLIND1      DEFENSIVE LINEMAN 1
;        VCTLIND2        "           "   2
;        VCTLIND3        "           "   3
;        VCTLIND4        "           "   4
;        VCTLIND5        "           "   5
;
;
;
;     SPECIAL VECTOR BLOCK DEFINITION
;
;        THE VECTOR BLOCK HAS BEEN EXTENDED AS FOLLOWS:
;
;             --------------------------------------
;             :                                    :
;         +15 :  Low addr. of graphics pattern     :
;             :                                    :
;             --------------------------------------
;             :                                    :
;         +16 :  High addr. of graphics pattern    :
;             :                                    :
;             --------------------------------------
;             :                                    :
;         +17 :  Play pattern time base            :
;             :                                    :
;             --------------------------------------
;
VCTEND1  EQU    $4E88     ; BLOCK VECTSZ
VCTEND2  EQU    $4E9B     ; BLOCK VECTSZ
VCTEND3  EQU    $4EAE     ; BLOCK VECTSZ
VCTEND4  EQU    $4EC1     ; BLOCK VECTSZ
VCTOQTRB EQU    $4ED4     ; BLOCK VECTSZ
VCTLINO1 EQU    $4EE7     ; BLOCK VECTSZ
VCTLINO2 EQU    $4EFA     ; BLOCK VECTSZ
VCTLINO3 EQU    $4F0D     ; BLOCK VECTSZ
VCTLINO4 EQU    $4F20     ; BLOCK VECTSZ
VCTLINO5 EQU    $4F33     ; BLOCK VECTSZ
VCTDQTRB EQU    $4F46     ; BLOCK VECTSZ
VCTLIND1 EQU    $4F59     ; BLOCK VECTSZ
VCTLIND2 EQU    $4F6C     ; BLOCK VECTSZ
VCTLIND3 EQU    $4F7F     ; BLOCK VECTSZ
VCTLIND4 EQU    $4F92     ; BLOCK VECTSZ
VCTLIND5 EQU    $4FA5     ; BLOCK VECTSZ
;
CRNTPGRP EQU    $4FB8     ; CURRENT PLAY GROUP POINTER - BLOCK 2
SELPLAY  EQU    $4FBA     ; PLAY SELECTED FROM PLAY OPTIONS - BLOCK 1
L4FBB    EQU    $4FBB     ; BLOCK 1
LINEBALL EQU    $4FBC     ; LINE OF SCRIMMAGE (IN BCD) - BLOCK 1
SCRIMLIN EQU    $4FBD     ; CURRENT LINE OF SCRIMMAGE (X COORD.) - BLOCK 1
L4FBE    EQU    $4FBE     ; BLOCK 1
HALF     EQU    $4FBF     ; HALF COUNTER - BLOCK 1
L4FC0    EQU    $4FC0     ; BIT    7 - IF SET: BUMP PLAY GROUP PTR TO 2ND ENTRY - BLOCK 1
;                         ;        6 -
;                         ;      5,4 - 00 = NORMAL PLAY DISPLAY
;                         ;            10 = "PUNT" DISPLAY
;                         ;            11 = "SCREEN PASS" DISPLAY
;                         ;        3 - 
;
LSMAGIC  EQU    $4FC1     ; CURRENT LINE OF SCRIMMAGE MAGIC REGISTER - BLOCK 1
DOWNNO   EQU    $4FC2     ; DOWN NUMBER (COUNTER) - BLOCK 1
CURQPAT  EQU    $4FC3     ; CURRENT QUARTERBACK PATTERN - BLOCK 3
L4FC6    EQU    $4FC6     ; BLOCK 1
SCOREA   EQU    $4FC7     ; SCORE FOR PLAYER A - BLOCK 1
SCOREB   EQU    $4FC8     ; SCORE FOR PLAYER B - BLOCK 1
YDSTOGO  EQU    $4FC9     ; YARDS TO GO - BLOCK 1
CURSRPOS EQU    $4FCA     ; CURRENT CURSOR POSITION (DURING PLAY SELECTION) - BLOCK 2
YDTABPTR EQU    $4FCC     ; YARD TABLE POINTER (SCALED POINTER FOR SCREEN) - BLOCK 2

;
;
;
         ORG    FIRSTC    ; ESTABLISH CARTRIDGE ORIGIN
;
;
         BYTE   "U"       ; USER CARTRIDGE SENTINEL
;
;   LINKED MENU LIST
;
         DW     MENU2,L_2PLAYR,GAME1          ; 2-PLAYER
;
;
;   RESTART VECTORS
;
         JP     RST08     ; RST 08
         JP     RST10     ; RST 10
         JP     RST18     ; RST 18
         JP     RST20     ; RST 20
         JP     RST28     ; RST 28
         JP     RST30     ; RST 30

;
MENU2:   DW     MENUST,L_4PLAYR,GAME2         ; 4 PLAYER
;
L201F:   DB     0

;
;  INTERRUPT VECTOR TABLE
;
INTTAB:  DW     L29F0     ; INTERRUPT ROUTINE
         DW     L24D9     ; INTERRUPT ROUTINE
;
L2024:   PUSH   IX

;
         SYSSUK BMUSIC    ; BLOW REFEREE WHISTLE
         DW     MUSICWRK  ; STACK WORK AREA
         DB     11111110B ; 3 VOICE A,B,C, : VIBRATO
         DW     WHISTLE
;
         POP    IX
         LD     HL,INTTAB
         LD     A,L
         OUT    (INFBK),A
         LD     HL,L4E73
         LD     SP,HL
         EI
;
         SYSSUK PAWS      ; PAUSE A SECOND
         DB     60        ; 1 SECOND

;
         BIT    7,(IX+VBYCHK)
         JR     NZ,L204A
         RST    $08
         JP     Z,TIMECHK
         AND    A
         JR     L204E
;
L204A:   BIT    0,(IX+VBSTAT)
;
L204E:   EX     AF,AF'
         LD     A,(IX+VBXH)
         INC    A
         INC    A

         LD     (SCRIMLIN),A
         LD     HL,L4FC0
         BIT    6,(IX+VBXCHK)
         PUSH   AF
         JR     Z,L2075
         PUSH   HL
;
         SYSSUK BMUSIC    ; PLAY VICTORY SONG
         DW     MUSICWRK  ; MUSIC STACK
         DB     00001100B ; 1-VOICE, C ONLY
         DW     VICTORY   ; SCORE

;
         SYSSUK STRDIS    ; DISPLAY "TOUCHDOWN"
         DB     8,40      ; X,Y
         DB     $44       ; *2, COLOR 1 ON 0
         DW     L_TCHDWN  ; STRING
;
         LD     C,7       ; BUMP SCORE BY 7
         POP    HL
         JR     L20BE
;
L2075:   LD     D,$7D
         LD     A,(L4FBB)
         CP     $70
         JR     C,L208A
         JR     NZ,L2082
         LD     D,$9B
;
L2082:   LD     A,(SCRIMLIN)
         CP     D
         JR     C,L20BE
         JR     L20BC
;
L208A:   LD     D,$07
         CP     $20
         JR     Z,L2094
         JR     NC,L20BE
         LD     D,$25
;
L2094:   LD     A,(SCRIMLIN)
         CP     D
         JR     NC,L20BE
         PUSH   HL
         CALL   APPLAUSE  ; START THE CROWD CHEERING
;
         SYSSUK STRDIS    ; DISPLAY "SAFETY"
         DB     40,40     ; X,Y
         DB     $44       ; *2, COLOR 1 ON 0
         DW     L_SAFETY  ; STRING
;
         POP    HL
         SET    3,(HL)
         LD     C,2       ; BUMP SCORE BY 2
         LD     A,$60
         LD     (L4FBB),A
         RST    $10
         JR     Z,L20B7
         CALL   SETOFFA
         JR     L20E7
;
L20B7:   CALL   SETOFFB
         JR     L20DA
;
L20BC:   SET    2,(HL)
;
L20BE:   RST    010H
         JR     NZ,L20D0
         POP    AF
         JR     Z,L20CA
         EX     AF,AF'
         JP     NZ,L20D7
         JR     L20E4
;
L20CA:   EX     AF,AF'
         CALL   NZ,SETOFFB
         JR     L20F8
;
L20D0:   POP    AF
         JR     Z,L20F4
         EX     AF,AF'
         JP     NZ,L20E4
;
L20D7:   CALL   SETOFFA
;
L20DA:   LD     A,(SCOREB)  ; GET CURRENT SCORE
         ADD    A,C         ; AND # OF POINTS
         DAA                ; MAKE IT DECIMAL
         LD     (SCOREB),A  ; AND SAVE THE NEW SCORE
         JR     L20EF
;
L20E4:   CALL   SETOFFB
;
L20E7:   LD     A,(SCOREA)  ; GET CURRENT SCORE
         ADD    A,C         ; AND # OF POINTS
         DAA                ; MAKE IT DECIMAL
         LD     (SCOREA),A  ; AND SAVE THE NEW SCORE
;
L20EF:   CALL   RDTRIG
         JR     L2146
;
L20F4:   EX     AF,AF'
         CALL   NZ,SETOFFA
;
L20F8:   CALL   RDTRIG
         BIT    2,(HL)
         JR     NZ,L2146
         JR     TIMECHK
;
;   2-PLAYER ENTRY POINT
;
GAME1:   XOR    A         ; FLAG = 0
;
         DB     $21       ; FAKE A 'LD  HL,NNNN' INSTRUCTION
;
;
;   4-PLAYER ENTRY POINT
;
GAME2:   LD     A,-1      ; FLAG = -1
         LD     (NUMPLAYR),A       ; SAVE THE NUMPLAYR FLAG
         LD     HL,L4E73
         LD     SP,HL
;
         SYSSUK FILL      ; CLEAR GAME RAM WORK AREA
         DW     L4E82     ; START OF SCRATCH
         DW     332       ; LENGTH
         DB     0         ; FILL CHAR.
;
         SYSSUK BMUSIC    ; START THE NATIONAL ANTHEM
         DW     MUSICWRK  ; MUSIC STACK
         DB     11111100B ; 3-VOICE (A,B,C)
         DW     ANTHEM    ; SCORE
;
;
HALFTIME: LD     HL,L4FC0
          CALL   SETOFFA   ; SET PLAYER A AS OFFENSE
          DEC    HL        ; BUMP PTR. TO HALF COUNTER
          INC    (HL)      ; INC. IT
          LD     A,(HL)    ; NOW GET IT
          CP     $02       ; 2ND HALF?
          JR     NZ,L2130  ; NO, CONTINUE
          INC    HL        ; ELSE, BUMP TO FLAGS
          CALL   SETOFFB   ; AND SET PLAYER B AS OFFENSE
          CALL   APPLAUSE  ; CHEER FOR THE HALF-TIME SHOW
          JR     L2134     ; AND CONTINUE
;
L2130:    DEC    (HL)      ; SEE IF 3'RD HALF
          JR     NC,L215F  ; YES, CONTINUE TO PUT UP SCOREBOARD
          INC    (HL)      ; ELSE, RESET COUNTER
;
L2134:    LD     HL,$0400  ; GAME TIME (4:00 MINUTES)
          LD     (GTSECS),HL  ; SET UP HALF TIME,HL
          LD     HL,INTTAB ; INTERRUPT TABLE
          LD     A,H
          LD     I,A       ; SET INTERRUPT RFG
          LD     A,L
          OUT    (INFBK),A ; AND THE FEEDBACK REGISTER
          IM     2
          EI               ; START THE ACTION
;
L2146:    LD     HL,SCRIMLIN         ; HL--> LINE OF SCRIMMAGE X COORD.
          LD     (HL),35   ; INIT. IT TO 35 (20 YARD LINE)
          LD     A,(L4FC0)
          BIT    3,A
          JR     NZ,TIMECHK
          LD     A,144     ; 20 YARD LINE ON RIGHT SIDE
          LD     (L4FBB),A
;
;   NOW, SEE IF THIS HALF IS OVER (TIME REMAINING)
;
TIMECHK:  LD     HL,GTSECS ; HL--> TIME
          LD     A,(HL)    ; GET MINUTES
          INC    HL
          ADD    A,(HL)    ; AND SECONDS
          JR     Z,HALFTIME          ; TIME OVER, START NEXT HALF
;
L215F:    LD     B,16      ; # OF VECTORS
          LD     DE,VCTLIND5+18      ; LAST BYTE OF LAST VECTOR
;

L2164:   PUSH   BC
         LD     HL,VECTSKEL+18      ; HL--> END OF SKELETON VECTOR
         LD     BC,VECTSZ
         LDDR             ; MOVE SKELETON VECTOR TO REAL VECTOR
         PUSH   HL
         LD     HL,LSMAGIC          ; HL--> MAGIC REG. FOR LINE OF SCRIMMAGE
         INC    DE        ; BUMP TO MAGIC REG. (SHIFT VALUE???)
         LD     A,(DE)    ; GET IT
         OR     (HL)      ; MASK IN THE MAGIC REG.
         LD     (DE),A    ; AND PUT BACK IN THE VECTOR
         DEC    DE
         POP    HL
         POP    BC
         DJNZ   L2164
;
         LD     HL,VCTOQTRB         ; STARTING VECTOR
         LD     (MUSICWRK),HL
         LD     HL,G_QTR06          ; HL--> STARTING FIGURE FOR QUARTERBACK
         LD     (CURQPAT),HL        ; SAVE THE POINTER
         LD     DE,VECTSZ
         LD     HL,VCTEND1+VBSTAT   ; HL --> STATUS (OFFENSIVE END 1)
         SET    2,(HL)
         ADD    HL,DE               ; BUMP TO NEXT END'S VECTOR
         SET    2,(HL)              ; AND HIM TOO!
         ADD    HL,DE               ; DEFENSIVE END VECTOR NOW (BOTTOM)
         LD     (HL),$87
         LD     IX,VCTEND3          ; IX --> DEF. BOTTOM END
         RES    VBCREV,(IX+VBYCHK)  ; ENSURE REV. DELTA RESET
         ADD    HL,DE               ; NO TO TOP DEF. END
         LD     (HL),$87
         ADD    IX,DE               ; BUMP TO TOP DEF. END
         RES    VBCREV,(IX+VBYCHK)  ; ENSURE NO DELTA REV.
         ADD    HL,DE               ; BUMP TO QTRBACK/FOOTBALL VECTOR
         LD     (HL),$A6           ; SET ACTIVE, ...
         ADD    IX,DE               ; IX TO QTRBACK VECTOR TOO
         SET    7,(IX+VBYCHK)
         LD     HL,VCTLIND4+VBSTAT ; HL --> STATUS BYTE
         SET    2,(HL)
         LD     HL,VCTDQTRB+VBSTAT  ; HL --> QTRBACK VECTOR STATUS
         LD     B,6     ; SET COUNTER TO CATCH HIM & 5 LINEMEN
;
L21B8:   SET    0,(HL)  ; DOES BIT 0 OF VBSTAT = 1 MEAN VECTOR IS OFFENSE?
         ADD    HL,DE   ; BUMP TO NEXT VECTOR
         DJNZ   L21B8   ; UNTIL ALL DONE
         LD     A,(SCRIMLIN)        ; GET THE LONE OF SCRIMMAGE
         CALL   L280A   ; CONVERT TO SCALLED BCD VALUE
         LD     (LINEBALL),A        ; AND SAVE IT
         LD     B,A
         LD     HL,L4FC0
         XOR    A
         BIT    6,(HL)
         LD     (HL),A
         JR     Z,L21D8
         SUB    B
         DAA
         LD     B,A
         LD     (LINEBALL),A
         JR     L21E7
;
L21D8:   LD     A,(L4FBE)
         SUB    B
         PUSH   AF
         DAA
         LD     (YDSTOGO),A         ; SAVE AS YARDS TO 1ST DOWN
         POP    AF
         JR     Z,L21E7
         JP     P,L21F3
;
L21E7:   LD     A,$10               ; SET YARDS TO FIRST DOWN
         LD     (YDSTOGO),A         ; IN BUFFER
         ADD    A,B
         LD     (L4FBE),A
         XOR    A
         JR     L21F6
;
L21F3:   LD     A,(DOWNNO)      ; GET DOWN
;
L21F6:   INC    A               ; INC. IT
         LD     (DOWNNO),A      ; AND SAVE IT
         CP     5               ; 5TH DOWN?
         JR     NC,L2208        ; NO, SELECT PROPER PLAY GROUP
         DEC    A               ; USE DOWN # AS INDEX
         LD     HL,L2E3D        ; HL --> TABLE PLAY GROUP SELECTIONS
         RST    NDXW            ; INDEX WORD TABLE
         EX     DE,HL
         LD     A,(YDSTOGO)     ; GET YARDS TO GO FOR FIRST DOWN
         JP     (HL)            ; BRANCH TO PLAY SECTION
;
        
L2208:   RST    CMAG            ; GET LINE OF SCRIMMAGE MAGIC REG.
         JP     NZ,L2211        ; PLAYER B HAS THE BALL, GIVE TO A
         CALL   SETOFFB         ; SET PLAYER B AS OFFENSE
         JR     L2214
;
L2211:   CALL   SETOFFA         ; SET PLAYER A AS OFFENSE
;
L2214:   JP     L215F
;
DOWN1:   LD     HL,PGROUP1
         JR     DOWN5
;
DOWN2:   LD     HL,PGROUP2
         CP     $11
         JR     NC,L223C
         LD     HL,PGROUP1
         JR     DOWN5
;
DOWN3:   LD     HL,PGROUP2
         JR     DOWN5
;
DOWN4:   LD     HL,L4FC0
         SET    5,(HL)
         LD     HL,PGROUP2
;
DOWN5:   CP     $06
         JR     NC,L223C
         LD     HL,PGROUP3
;
L223C:   LD     (CRNTPGRP),HL   ; SAVE AS CURRENT PLAY GROUP POINTER
         CALL   L2852     ; GET THE CURRENT YARD LINE (SCRIMMAGE LINE)
         LD     (L4FBB),A
         LD     A,C
         LD     HL,YARDSTAB     ; HL --> TABLE OF YARDS IN BCD
         SYSTEM INDEXB          ; GET AN INDEX ENTRY
         LD     (YDTABPTR),HL   ; HL --> SPAN OF YARDS TO FILL THE SCREEN
         LD     A,(LINEBALL)    ; GET BALL YARD LINE
         CALL   L27D7
         LD     (SCRIMLIN),A
         EX     AF,AF'
         LD     HL,L4FC0
         PUSH   AF
         LD     B,A
         XOR    A
         SUB    B
         DAA
         CP     $25
         JR     NC,L2268
         SET    5,(HL)
         SET    4,(HL)
;
L2268:   LD     C,A
         CP     $10
         JR     NC,L2273
         LD     HL,PGROUP3
         LD     (CRNTPGRP),HL
;
L2273:   LD     A,(YDSTOGO)     ; GET YARDS TO GO
         SUB    C
         DAA
         CP     $10
         JR     NC,L2280
         LD     A,C
         LD     (YDSTOGO),A
;
L2280    EQU    $
         POP    AF
         CALL   L2846
         LD     (LINEBALL),A
         XOR    A
         LD     (SELPLAY),A
;
;
;   SCOREBRD -- DRAW THE SCOREBOARD NOW
;
SCOREBRD SYSSUK COLSET    ; SET THE COLORS
         DW     COLIST6   ; COLOR LIST
;
         SYSSUK SETOUT    ; AND NEW SCREEN PARAMETERS
         DB     90*2      ; BOTTOM LINE NO. *2
         DB     $C0+44    ; FRAME COLOR, COLOR BOUNDARY
         DB     8         ; LINE INTERRUPTS ONLY
;
         SYSSUK FILL      ; BLANK SCREEN
         DW     NORMEM    ; START
         DW     90*BYTEPL ; LENGTH
         BYTE   11111111B ; COLOR 3
;
         RST    CMAG  ; GET LINE OF SCRIMMAGE MAGIC REG.  ; WHO HAS THE BALL?
         JR     NZ,L22A7  ; PLAYER B DOES, DRAW ON RIGHT SIDE
;
         SYSSUK WRITP     ; DRAW PLAYER WITH BALL  ; ON THE LEFT
         DB     24,15     ; X,Y
         DB     $20       ; XOR
         DW     G_QTR06   ; PATTERN
;
         JR     L22AE     ; SKIP OVER
;
;
L22A7:   SYSSUK WRITP     ; DRAW PLAYER WITH BALL ON THE RIGHT
         DB     24,15     ; X,Y
         DB     $60       ; FLOP, XOR
         DW     G_QTR01   ; RIGHT PLAYER
;
L22AE:   LD     IX,FNTSML ; USE 3X5 CHARACTER SET
;
         SYSTEM INTPC
;
         DO     DISNUM    ; SCORE A
         DB     14,28     ; X,Y
         DB     01100100B ; *2, XOR, COLOR 1 ON 0
         DB     $82       ; 2 DIGITS
         DW     SCOREA    ; NUMBER
;
         DO     DISNUM    ; SCORE B
         DB     120,28    ; X,Y
         DB     01101000B ; *2, XOR, COLOR 2 ON 0
         DB     $82       ; 2 DIGITS
         DW     SCOREB    ; NUMBER
;
         DO     DISNUM    ; DISPLAY WHICH HALF
         DB     68,28     ; X,Y
         DB     01100100B ; *2, XOR, COLOR 1 ON 0
         DB     $C2     ; 2 DIGITS
         DW     HALF
;
         DO     DISTIM    ; DISPLAY TIME
         DB     60,10     ; X,Y
         DB     11000111B ; MIN:SEC, *2, OR, COLOR 1 ON 3
;
         DO     STRDIS    ; DISPLAY "TIME"
         DB     64,0      ; X,Y
         DB     00100100B ; XOR, COLOR 1 ON 2
         DW     L_TIME    ; STRING
;         
         DO     DISNUM    ; DISPLAY DOWN LINE
         DB     48,48     ; X,Y
         DB     00101000B ; XOR, COLOR 2 ON 0
         DB     $82       ; 2 DIGITS
         DW     DOWNNO
;
         DO     DISNUM    ; DISPLAY YARDS TO GO
         DB     28,64     ; X,Y
         DB     00101000B ; XOR, COLOR 2 ON 0
         DB     $82       ; 2 DIGITS
         DW     YDSTOGO
;
         DO     STRDIS    ; DISPLAY "DOWN"
         DB     68,48     ; X,Y
         DB     00100100B ; XOR, COLOR 1 ON 0
         DW     L_DOWN    ; STRING
;
         DO     DISNUM    ; DISPLAY THE BALL YARD LINE
         DB     102,80    ; X,Y
         DB     00101000B ; XOR, COLOR 2 ON 0
         DB     $82       ; 2 DIGITS
         DW     LINEBALL
;
         DO     STRDIS    ; DISPLAY "YARDS TO GO"
         DB     48,64     ; X,Y
         DB     00100100B ; XOR, COLOR 1 ON 0
         DW     L_YARDGO  ; STRING
;
         DO     STRDIS    ; DISPLAY "BALL ON"
         DB     42,80     ; X,Y
         DB     00100100B ; XOR, COLOR 1 ON 0
         DW     L_BALLON  ; STRING
;
         DONT   XINTC     ; STOP INTERPRETING
;
         LD     HL,GTSECS ; GET GAME TIME
         LD     A,(HL)    ; MINUTES
         INC    HL
         ADD    A,(HL)    ; AND SECONDS TO SEE IF GAME IS OVER
         JR     NZ,L230F  ; NO, CONTINUE
         CALL   APPLAUSE
;
         SYSSUK STRDIS    ; DISPLAY "END"
         DB     56,43     ; X,Y
         DB     01000111B ; *2, OR, COLOR 1 ON 3
         DW     L_END     ; STRING
;
HANG:    JR     HANG      ; HANG UP SO EVERYONE CAN SEE THE FINAL SCORE
;
L230F:   CALL   RDTRIG    ; HANG ON SCOREBOARD UNTIL TRIGGER PULLED.
;
         SYSSUK FILL      ; BLANK THE SCREEN
         DW     NORMEM
         DW     90*BYTEPL ; LENGTH
         DB     11111111B ; COLOR 3
;
         SYSSUK STRDIS    ; DISPLAY "PLAYS"
         BYTE   58,5
         DB     00101000B ; XOR, COLOR 2 ON 0
         DW     L_PLAYS   ; STRING
;
         LD     BC,$0524  ; D=5, C=24H (STRING PARAMETERS)
         LD     DE,16*256+12  ; X=12, Y=16
;
L2326:   LD     A,(L4FC0)
         BIT    5,A
         JR     Z,L234A
         LD     HL,L_PUNT ; HL --> "PUNT"
         BIT    4,A
         JR     Z,L2337
         LD     HL,L_SCREEN  ; HL --> "SCREEN PASS"
;
L2337:   DEC    B            ; # OF LINES TO DISPLAY -1
         BIT    7,A
         JR     NZ,L2343
         PUSH   HL
         LD     HL,CRNTPGRP  ; GET CURRENT PLAY GROUP
         INC    (HL)         ; BUMP PAST 1ST PLAY
         INC    (HL)         ; OF THAT GROUP
         POP    HL
;
L2343:   LD     DE,26*256+12 ; X=12, Y=26
         SYSTEM STRDIS       ; DISPLAY A STRING
;
         LD     E,12         ; RESET X COORD. TO 12
;
L234A:   PUSH   DE
         XOR    A            ; ZERO INDEX
;
L234C:   LD     HL,(CRNTPGRP) ; HL --> CURRENT PLAY GROUP TABLE
         RST    NDXW      ; INDEX WORD TABLE
         EX     DE,HL     ; PUT ENTRY IN HL
         POP    DE        ; RESTORE HORIZONTAL LINE POSITION
         EX     AF,AF'
         LD     A,10      ; INCREMENT VALUE (TO NEXT LINE)
         ADD    A,D       ; ADD TO CURRENT Y COORD.
         LD     D,A       ; BACK TO D
         PUSH   DE        ; SAVE POS.
         EX     AF,AF'
;
         SYSTEM STRDIS    ; DISPLAY A STRING (HL --> STRING, DE=X,Y)
;
         INC    A         ; BUMP INDEX
         DJNZ   L234C     ; AND OUTPUT REMAINING PLAYS
         POP    DE
         LD     HL,L4FC0
         SET    7,(HL)
         XOR    A
         LD     (VCTLINO1+VBYL),A  ; SET CURSOR HOR. POSITION
         LD     C,A
         LD     B,A
         EXX
         LD     HL,NORMEM+33*BYTEPL ; START ON LINE 33
         LD     (CURSRPOS),HL       ; SAVE AS CURRENT CURSOR POS.
         LD     HL,VCTLINO1+VBYCHK  ; HL --> CHECKS FLAG
         RES    6,(HL)    ; ENSURE PLAY CYCLE COMPLETE FLAG RESET
;
         SYSSUK RECTAN    ; DRAW THE "CURSOR"
         DB     2,26      ; X,Y
         DB     6,6       ; 6 x 6 PIXELS
         DB     01010101B ; COLOR PATTERN
;
         SET    5,(HL)    ; OK, TURN ON THE CURSOR MOVEMENT FLAG
;
L237F:   BIT    6,(HL)    ; SEE IF CURSOR CYCLE COMPLETE
         JR     Z,L237F   ; NO, LOOP UNTIL COMPLETE
         RES    5,(HL)    ; TURN OFF THE CURSOR MOVEMENT FLAG
         LD     A,(SELPLAY)  ; GET THE SELECTED PLAY
         AND    A            ; SEE IF ANY PLAY SELECTED
         JP     Z,SCOREBRD   ; NO, PUT UP THE SCOREBOARD AGAIN
;
         CP     4
         PUSH   AF           ; SAVE FLAGS
         LD     HL,L4FC0
         BIT    5,(HL)
         LD     HL,(CRNTPGRP)  ; HL--> CURRENT PLAY GROUP
         JR     Z,L23B0        ; NOT SPECIAL PLAY
         DEC    HL
         DEC    HL
         CP     1
         JR     NZ,L23B0
         LD     HL,PLAYTAB     ; HL--> TABLE OF PLAY PATTERNS
         LD     A,(L4FC0)
         BIT    4,A
         JR     NZ,L23B7
         PUSH   HL
         RST    QORF      ; SET THE QTRBACK/FOOTBALL VECTOR TO THE BALL
         SET    7,(HL)    ; SET "BALL" FLAG IN VBXCHK
         POP    HL        ; RESTORE HL
         JR     L23B7
;
L23B0:   DEC    A
         LD     BC,10     ; OFFSET TO PLAY TABLE POINTERS
         ADD    HL,BC     ; HL--> CURRENT PLAY GROUP PATTERN POINTERS
         RST    NDXW      ; INDEX WORD TABLE
         EX     DE,HL     ; PUT PLAY PATTERN POINTER IN HL
;
L23B7:   LD     DE,POSTAB1 ; NORMAL END POSITION TABLE 
         PUSH   HL        ; SAVE PLAY PTR.
         LD     A,16      ; # OF TABLE ENTRIES (& VECTORS)
         LD     HL,VCTEND1+VBXL  ; HL--> X COORDINATE
         CALL   INITVECT  ; INIT. VECTORS WITH POSITIONS FROM TABLE
         POP    HL        ; RESTORE PTR.
         LD     DE,VCTEND1+15  ; DE--> OFFENSIVE ENDS (2 VECTORS)
         LD     A,2       ; 2 VECTORS
         CALL   INITPLAY  ; INIT. THE ENDS WITH THEIR PATTERN POINTERS
         POP    AF
         JR     NC,FLANKERS
         LD     HL,OFFPAT1   ; HL--> OFFENSIVE PATTERN 1 TABLE
         JR     L23E2
;
;   FLANKERS -- REPOSITIONS THE OFFENSIVE ENDS AS FLANKERS
;
FLANKERS:  LD     A,2              ; 2 VECTORS
         LD     DE,POSTAB5       ; FLANKER POSITION TABLE
         LD     HL,VCTEND1+VBXL  ; HL--> X COORD.
         CALL   INITVECT         ; POSITION OFFENSIVE ENDS FLANKERS
         LD     HL,OFFPAT2
;
L23E2:   LD     DE,VCTOQTRB+15
         LD     A,6       ; 6 VECTORS FOR OFFENSE
         CALL   INITPLAY  ; SET THEM UP WITH THEIR PLAY PATTERNS
         LD     A,6       ; 6 FOR DEFENSE
         LD     HL,DEFNSPAT ; HL--> DEFENSIVE PLAY PATTERN TABLE
         CALL   INITPLAY  ; SET UP DEFENSIVE SIDE TOO
         LD     HL,(YDTABPTR)  ; HL--> YARD TABLE PTR (SCALED FOR SCREEN)
         CALL   DRWFIELD  ; DRAW THE PLAYFIELD
         CALL   DRWTEAM   ; DRAW THE MEN ON THE FIELD
         CALL   DRWSBALL  ; DRAW THE BALL (IN START POSITION)
;
;   RANDOM SONG SELECTION FOR SOME VARIETY
;
         LD     HL,CHANT  ; DEFAULT SCORE FOR CHANT
;
         SYSSUK RANGED    ; GET A RANDOM #
         DB     0         ; ACCEPT ANY
;
         BIT    0,A       ; SEE WHICH CHEER TO USE
         JR     Z,L240B
         LD     HL,VICTORY  ; OTHERWISE, USE THE SONG
;
L240B    EQU    $
         LD     A,00001100B   ; 3-VOICE (LOAD C ONLY, INT PC)
         LD     IX,MUSICWRK
;
         SYSTEM BMUSIC        ; PLAY EITHER THE SONG OR CHANT
;
         LD     A,(L4FBE)
         CALL   L27D7
         LD     D,04H
         LD     E,A
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         JR     Z,L2423
         LD     A,0BDH
         SUB    E
         LD     E,A
;
L2423    EQU    $
         CALL   DRWDOWNM  ; DRAW A DOWN MARKER
         LD     A,E
         SBC    A,29      ; 29 PIXELS DOWN
         LD     E,A
         CALL   DRWDOWNM  ; DRAW A DOWN MARKER
;
L242D:   RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         IN     A,(SW0)   ; HAND CONTROLLER 0
         JR     Z,L2434
         IN     A,(SW1)   ; HAND CONTROLLER 1
;
L2434:   AND    $0F
         JR     Z,L242D
         XOR    A
         RST    QORF      ; SET HL--> BALL VECTOR         
         CALL   DRWSBALL  ; DRAW THE BALL
         LD     A,70*2    ; NEW LINE INTERRUPT VALUE
         OUT    (INLIN),A        

         XOR    A
         LD     (L4E82),A
         LD     A,80
L2447:   RST    QORF      ; IS VECTOR QUARTERBACK OR FOOTBALL?
         JR     NZ,L2450
;
         SYSSUK RANGED    ; GET RANDOM #
         DB     32        ; RANGE
;
         RLCA
         ADD    A,32
;
L2450:   LD     (CT7),A
         RST    NUMP      ; GET # OF PLAYERS (2 OR 4)
         JR     Z,L245B
         LD     HL,VCTEND2+VBSTAT 
         SET    1,(HL)
;
L245B:   DI
         LD     HL,INTTAB+2
         LD     A,L
         OUT    (INFBK),A
         RST    QORF         ; IS VECTOR QUARTERBACK OR FOOTBALL?
         JR     Z,L2480
         LD     B,16         ; 16 VECTORS
         LD     HL,VCTEND1+VBSTAT
         LD     DE,VECTSZ
;
L246D:   RES    VBSACT,(HL)  ; RESET VECTOR ACTIVE STATUS
         ADD    HL,DE        ; BUMP TO NEXT VECTOR
         DJNZ   L246D
         LD     HL,VCTOQTRB+VBSTAT  ; HL--> STATUS
         SET    VBSACT,(HL)         ; ACTIVATE THE BALL
         LD     HL,PLAYPUNT         ; HL--> PUNT PATTERN
         LD     (VCTOQTRB+15),HL    ; MAKE IT THE CURRENT PLAY PATTERN
         CALL   DOTRIGS
;
L2480:   SYSSUK FILL
         DW     OSW0      ; ZERO THE POT TRACKING BYTES
         DW     4         ; LENGTH
         DB     0         ; FILL CHAR.
;
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         IN     A,(POT0)
         JR     Z,L248F
         IN     A,(POT1)
         CPL
;
L248F:   AND    $E0
         LD     HL,L4FC6
         LD     (HL),A
         DEC    HL
         LD     (HL),$02
         EI
;
;   PLAYLOOP -- HERE IS THE MAIN PLAYER TRANSITION LOOP
;
PLAYLOOP: SYSSUK SENTRY    ; SENSE PLAYER INPUT
          DW     ALKEYS    ; CALC. KEYPAD MASK
;
          SYSSUK DOIT      ; DO IT!!!
          DW     DOTABLE   ; TRANSITION TABLE
;
          JR     PLAYLOOP
;
;   DRWSBALL -- DRAWS THE BALL IN THE INITIAL START POSITION
;
;       DRAWS THE BALL ON PIXEL LINE 47 ON THE CURRENT LINE OF SCRIMMAGE
;
DRWSBALL: LD     A,(SCRIMLIN)  ; GET THE CURRENT LINE OF SCIMMAGE (X COORD.)
          LD     E,A       ; X COORDINATE
          LD     D,47      ; Y COORDINATE
          RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
          OR     20H
          LD     HL,G_FTBALL  ; HL--> FOOTBALL PATTERN
;
          SYSTEM WRITP     ; WRITE PATTERN WITH SIZE LOOKUP
          RET
;
;   DRWDOWNM -- DRAWS A DOWN MARKER ON THE SIDE LINE
;
;       UPON ENTRANCE:  D,E = Y,X COORDINATE FOR A MARKER
;
DRWDOWNM: LD     A,E       ; CHECK X COORD.
          CP     159       ; FOR OUT OF SCREEN BOUNDS
          RET    NC        ; TOO FAR, DO NOT DRAW IT
          LD     BC,$0402  ; 2 WIDE x 4 HIGH SIZE
          XOR    A         ; COLOR MASK
          RST    PBOX      ; PAINT A BOX
;
          LD     BC,$0204  ; 4 WIDE x 2 HIGH SIZE NOW
          XOR    A         ; COLOR MASK
          DEC    E         ; ONE PIXEL BACKWARDS
          RST    PBOX      ; PAINT A BOX
          RET
;
;   DRWTEAM -- DRAWS THE TEAM ON THE PLAYFIELD
;
DRWTEAM:  LD     IX,VCTEND1          ; START OF VECTORS
          LD     B,16                ; FOR ALL OF THEM
;
DRWTEAM0  BIT    VBSACT,(IX+VBSTAT)  ; CHECK ACTIVE BIT
          JR     Z,DRWTEAM1          ; NOT ACTIVE, SKIP TO NEXT VECTOR
          CALL   DRWVECT             ; DRAW A VECTOR PATTERN
          LD     DE,VECTSZ
;
DRWTEAM1: ADD    IX,DE     ; BUMP TO NEXT VECTOR
          DJNZ   DRWTEAM0  ; AND LOOP
          RET
;
;
;   INTERRUPT PROCESSOR
;
L24D9:   PUSH   AF
         PUSH   BC
         PUSH   DE
         PUSH   HL
         PUSH   IX
         PUSH   IY
         LD     B,3       ; 3 VECTORS
;
L24E3:   LD     HL,CURVECT  ; HL--> CURRENT VECTOR POINTER (1-BYTE INDEX)
         PUSH   BC
         DEC    (HL)      ; DECREMENT INDEX
         JP     P,L24ED   ; NOT ALL YET
         LD     (HL),21   ; RESET # OF VECTOR POINTERS
;
L24ED:   LD     C,(HL)    ; GET CURRENT INDEX
         LD     HL,VECTAB1  ; HL--> START OF VECTOR POINTERS TABLE
         LD     B,00H
         ADD    HL,BC
         ADD    HL,BC     ; OFFSET * 2
         LD     A,(HL)    ; PICK UP LOW ADDR.
         INC    HL        ; BUMP TO
         LD     H,(HL)    ; GET HIGH ADDR
         LD     L,A       ; HL--> A VECTOR
         PUSH   HL        ; PUT IT
         POP    IX        ; IN THE IX
         INC    HL        ; BUMP TO STATUS OF A VECTOR
         BIT    VBSACT,(HL)  ; IS IT ACTIVE?
         CALL   NZ,L2515  ; YES, ANIMATE IT
         POP    BC        ; RESTORE COUNTER
         DJNZ   L24E3     ; AND DO THE REST
;
         SYSSUK DECCTS    ; DECREMENT CUSTOM TIMERS
         BYTE   11000000B ; CT7, CT6
;
         CALL   STIMER    ; AND SERVICE SYSTEM TIMERS
         POP    IY
         POP    IX
         POP    HL
         POP    DE
         POP    BC
         POP    AF
         EI
         RET
;
;
;   UPON ENTRANCE:  HL--> STATUS OF THE VECTOR
;
L2515:   PUSH   HL
         CALL   DRWVECT   ; DRAW THE VECTOR'S PATTERN
         POP    HL        ; RESTORE STATUS POINTER
         PUSH   HL        ; SAVE IT
         BIT    1,(HL)
         INC    HL        ; BUMP TO TIMEBASE
         LD     (HL),1    ; PUT A 1 IN TIME BASE
         JR     NZ,L2545
         LD     DE,15     ; BUMP HL SO
         ADD    HL,DE     ; HL--> VB + 17
         DEC    (HL)      ; DECREMENT THE TIME BASE
         JR     NZ,L2545  ; NOT ZERO, VECTOR IT
         DEC    HL        ; ELSE, BACK UP PTR.
         LD     A,(HL)    ; TO GET HIGH PATTERN ADDRESS
         DEC    HL        ; AND THEN
         LD     L,(HL)    ; GET LOW PATTERN ADDRESS
         LD     H,A       ; HL--> PATTERN FOR VECTOR
         INC    HL        ; BUMPT TO
         INC    HL        ; NEXT
         INC    HL        ; PLAY
         LD     (IX+15),L ; SAVE ADDR. OF NEXT
         LD     (IX+16),H ; PLAY
         LD     A,(HL)    ; GET TIMER FOR PLAY
         LD     (IX+17),A ; PUT IN VECTOR
         INC    HL        ; BUMP TO X DELTA
         LD     A,(HL)    ; GET IT
         LD     (IX+VBDXH),A  ; AND PUT IN DELTA X
         INC    HL        ; BUMP TO Y DELTA
         LD     A,(HL)    ; GET IT
         LD     (IX+VBDYH),A  ; AND PUT IN VECTOR
;
L2545:   LD     HL,LIMIT2 ; HL--> LIMITS TABLE
         BIT    3,(IX+VBSTAT)
         JR     NZ,L2557
         BIT    7,(IX+VBYCHK)
         JR     NZ,L2557
         LD     HL,LIMIT1 ; HL--> LIMITS TABLE
;
L2557:   SYSTEM VECT      ; VECTOR COORDINATE PAIR
;
         POP    HL        ; RESTORE HL--> STATUS
         BIT    3,(IX+VBSTAT)
         JR     Z,L256E
         BIT    VBCLAT,(IX+VBXCHK)  ; HIT X LIMIT?
         JP     NZ,L2024
         BIT    VBCLAT,(IX+VBYCHK)  ; OR Y LIMIT?
         JP     NZ,L2024
;
L256E:   BIT    4,(HL)
         JR     Z,L2592
         RES    4,(HL)
         LD     A,R
         BIT    0,A
         LD     A,$01
         JR     NZ,L257E
         NEG
;
L257E:   ADD    A,(IX+VBYH)
         LD     (IX+VBYH),A
         BIT    0,(HL)
         LD     A,$01
         JR     NZ,L258C
         NEG
;
L258C:   ADD    A,(IX+VBXH)
         LD     (IX+VBXH),A
;
L2592:   BIT    2,(HL)
         JR     Z,L25E4
         LD     DE,8
         BIT    5,(HL)
         JP     Z,L25AF
         LD     A,(SCRIMLIN)
         SUB    03H
         CP     (IX+VBXH)
         JR     C,L25AF
         LD     HL,(CURQPAT)
         LD     E,10H
         JR     L25D4
;
L25AF:   BIT    5,(HL)
         RES    5,(HL)
         CALL   NZ,APPLAUSE
         BIT    0,(HL)
         JR     Z,L25C8
         LD     HL,G_END03
         BIT    7,(IX+VBYCHK)
         JR     Z,L25D4
         LD     HL,G_END07
         JR     L25D4
;
L25C8:   LD     HL,G_END01
         BIT    7,(IX+VBYCHK)
         JR     Z,L25D4
         LD     HL,G_END05
;
L25D4:   INC    (IX+18)
         BIT    1,(IX+18)
         JR     Z,L25DE
         ADD    HL,DE
;
L25DE:   LD     (IX+VBOAL),L
         LD     (IX+VBOAH),H
;
L25E4:   IN     A,(INTST) ; RESET INTERCEPT STATUS
         CALL   DRWVECT
         BIT    7,(IX+VBYCHK)
         CALL   NZ,L26B2
         IN     A,(INTST) ; NOW, TEST INTERCEPT
         OR     A
         RET    Z         ; NO INTERCEPT, EXIT
         BIT    7,(IX+VBYCHK)
         JP     NZ,L2607
         BIT    3,(IX+VBSTAT)
         JP     NZ,L260F
         SET    4,(IX+VBSTAT)
         RET
;
L2607:   BIT    7,(IX+VBYCHK)
         JP     NZ,L2024
         RET
;
L260F:   LD     B,$04
;
L2611:   PUSH   BC
         LD     HL,VECTAB2
         LD     E,B
         LD     D,$00
         ADD    HL,DE
         ADD    HL,DE
         LD     E,(HL)
         INC    HL
         LD     D,(HL)
         PUSH   DE
         POP    IY
         LD     A,(IY+VBXH)
         SUB    $02
         SUB    (IX+VBXH)
         JR     NC,L2692
         NEG
         CP     $07
         JR     NC,L2692
         LD     A,(IY+VBYH)
         DEC    A
         SUB    (IX+VBYH)
         JR     NC,L2692
         NEG
         CP     $07
         JR     NC,L2692
         POP    BC
         RES    VBSACT,(IX+VBSTAT)
         LD     HL,G_FTBALL
         CALL   DRWVECTA
         LD     (MUSICWRK),IY
         SET    7,(IY+12)
         BIT    7,(IX+VBXCHK)
         JR     Z,L265F
         BIT    0,(IY+1)
         JP     Z,L2024
;
L265F    EQU    $
         BIT    0,(IY+1)
         JR     Z,L2698
         RES    7,(IX+VBYCHK)
         LD     A,86H
         LD     (IX+VBSTAT),A
         LD     (L4E82),A
         LD     A,(QPOSOLDX)
         LD     (IX+VBXH),A
         LD     A,(QPOSOLDY)
         LD     (IX+VBYH),A
         LD     HL,(QOLDPATR)
         CALL   DRWVECTA
         XOR    A
         LD     (VCTOQTRB+VBDXH),A
         LD     (VCTOQTRB+VBDYH),A
;
         SYSSUK BMUSIC    ; START PLAYING - VICTORY SONG ONCE ONLY
         DW     MUSICWRK  ; STACK
         DB     00001100B ; 1-VOICE (c)
         DW     L2FC6     ; SCORE
;
         RET
;
L2692:   POP    BC
         DEC    B
         JP     NZ,L2611
         RET
;
L2698:   RST    NUMP      ; GET # OF PLAYERS (2 OR 4)
         RET    NZ
         LD     (VCTEND1+VBSTAT),A
         LD     (VCTEND2+VBSTAT),A
         LD     (IY+1),86H
;
;
;   APPLAUSE -- STARTS THE CROWD CHEERING, APPLAUSE, ETC...
;
APPLAUSE: PUSH   IX
          PUSH   HL
;
          SYSSUK BMUSIC    ; PLAY
          DW     MUSICWRK  ; STACK
          DB     11111100B ; 3-VOICES (A,B,C)
          DW     CHEERS    ; SCORE
;
          POP    HL
          POP    IX
          RET
;
L26B2:   LD     A,(L4FBB)
         BIT    0,(IX+VBSTAT)
         JR     NZ,L26D2
         CP     $70
         JR     C,L26E4
         LD     A,(IX+VBXH)
         LD     B,$99
         JR     Z,L26C8
         LD     B,$7B
;
L26C8:   CP     B
         JR     C,L26E4
;
L26CB:   SET    6,(IX+VBXCHK)
         JP     L2024
;
L26D2:   CP     $21
         JR     NC,L26E4
         CP     $20
         LD     A,(IX+VBXH)
         LD     B,$05
         JR     Z,L26E1
         LD     B,$23
;
L26E1:   CP     B
         JR     C,L26CB
;
L26E4:   BIT    VBCLAT,(IX+VBXCHK)  ; HIT LIMIT YET?
         RET    Z
         LD     A,(IX+VBXH)
         OR     A
         LD     A,(L4FBB)
         PUSH   AF
         EX     AF,AF'
         POP    AF
         JR     Z,L26FE
         BIT    0,(IX+VBSTAT)
         RET    NZ
         ADD    A,$28
         JR     L2711
;
L26FE:   BIT    0,(IX+VBSTAT)
         RET    Z
         CP     48
         JR     NZ,L270F
         EX     AF,AF'
         PUSH   AF
         LD     A,$10
         LD     C,$00
         JR     L271A
;
L270F:   SUB    $38
;
L2711:   DAA
         LD     (LINEBALL),A
         EX     AF,AF'
         PUSH   AF
         CALL   L2852
;
L271A:   LD     (L4FBB),A
         LD     A,C       ; US A AS AN INDEX
         LD     HL,YARDSTAB  ; HL--> TABLE
         SYSTEM INDEXB    ; INDEX BYTE
;
         PUSH   IX
         CALL   DRWFIELD
         POP    IX
         LD     B,$10
         LD     DE,VECTSZ
         LD     IY,VCTEND1
         POP    HL
;
L2734:   LD     A,(IY+VBXH)
         LD     C,D
         RES    VBSACT,(IY+VBSTAT)  ; DE-ACTIVATE THIS VECTOR
         BIT    0,(IX+VBSTAT)
         JR     Z,L2752
         CP     $40
         JR     NC,L2767
         ADD    A,90
         PUSH   AF
         LD     A,H
         CP     48
         JR     NZ,L275E
         LD     C,-30
         JR     L275E
;
L2752:   SUB    90
         JR     C,L2767
         PUSH   AF
         LD     A,H
         CP     96
         JR     NZ,L275E
         LD     C,30
;
L275E:   POP    AF
         ADD    A,C
         LD     (IY+VBXH),A
         SET    VBSACT,(IY+VBSTAT)  ; ACTIVATE THIS VECTOR
;
L2767:   ADD    IY,DE
         BIT    3,(IY+VBSTAT)
         JR     NZ,L2767
         BIT    VBSACT,(IY+VBSTAT)  ; IS THIS VECTOR ACTIVE?
         JR     Z,L2767
         DJNZ   L2734     ; LOOP UNTIL ALL DONE
         POP    HL
         JP     DRWTEAM   ; NOW DRAW THE TEAM
;
;   DRWVECT -- DRAWS A VECTOR FROM (IX)
;
DRWVECT:  LD     H,(IX+VBOAH)        ; GET PATTERN ADDRESS HIGH
          LD     L,(IX+VBOAL)        ; AND LOW
;
DRWVECTA: LD     D,(IX+VBYH)        ; GET Y HIGH
          LD     E,(IX+VBXH)        ; NOW X HIGH
          LD     A,(IX+VBMR)        ; AND MAGIC REG.
          SYSTEM WRITP     ; WRITE PATTERN WITH SIZE LOOK-UP
;
RET
;
;
;    LIMITS TABLE
;
LIMIT1:  DB     4,150     ; X UPPER, X LOWER
         DB     8,82      ; Y UPPER, Y LOWER
;
;   LIMITS TABLE
;
LIMIT2:  DB     0,155     ; X UPPER, X LOWER
         DB     4,91      ; Y UPPER, Y LOWER
;
;
;   INITPLAY -- INTIALIZES VECTORS WITH PLAYS FROM TABLES
;
;     UPON ENTRANCE: HL --> TABLE OF WORD PTRS TO PLAY PATTERNS
;                    DE --> VECTOR + 15
;                     A --> NUMBER OF VECTORS
;
;
INITPLAY: LD     B,A       ; SAVE # OF VECTORS
;
INITPLA0: LD     A,(HL)    ; GET LOW ADDR
          INC    HL        ; BUMP TO HIGH
          LD     (DE),A    ; SAVE IN VECTOR + 15
          INC    DE        ; BUMP TO NECT BYTE IN VECTOR
          LD     A,(HL)    ; GET HIGH ADDR
          INC    HL        ; BUMP TO NEXT TABLE ENTRY
          LD     (DE),A    ; PUT HIGH ADDR IN VECTOR + 16
          LD     A,18      ; OFFSET TO NEXT (VECTOR+15)
          ADD    A,E
          LD     E,A
          LD     A,$00
          ADC    A,A
          ADD    A,D
          LD     D,A       ; DE--> NEXT VECTOR
          DJNZ   INITPLA0
          RET
;
;
;   INITVECT -- INITIALIZES A VECTOR WITH X,Y COORDINATES FROM POSITION TABLE
;
;     UPON ENTRANCE:  HL --> VBXL IN VECTOR
;                     DE --> POSITION TABLE (X,Y ADDR(PATTERN))
;                      A  =  # OF VECTORS
;
;
INITVECT: LD     B,A       ; SAV NUMBER OF VECTORS
;
INITVEC0: XOR    A         ; ZERO A
          LD     (HL),A    ; VBXL = 0
          INC    HL        ; HL--> VBXH
          LD     A,(DE)    ; GET THE X COORD. FROM THE TABLE
          LD     C,A       ; SAVE IT
          PUSH   HL        ; SAVE VECTOR PTR
          LD     HL,SCRIMLIN  ; HL--> LINE OF SCRIMMAGE VALUE (X COORD.)
          LD     A,(HL)    ; GET THE CURRENT LINE OF SCIMMAGE X COORD.
          POP    HL        ; RESTORE VECTOR PTR.
          ADD    A,C       ; ADD POSITION OFFSET FROM TABLE
          LD     (HL),A    ; AND PUT IN VBXH
          INC    DE        ; BUMP TO U COORD. IN TABLE
          INC    HL        ; BUMP
          INC    HL        ; PTR
          INC    HL        ; TO
          INC    HL        ; HL--> VBYL
          XOR    A         ; ZERO LOW Y COORD
          LD     (HL),A    ; VBYL
          LD     A,(DE)    ; GET Y COORD. OFFSET FROM TABLE
          INC    HL        ; HL --> VBYH
          LD     (HL),A    ; PUT THE Y POS. IN THE VECTOR
          INC    DE        ; BUMP TABLE PTR TO PATTERN ADDRESS(LOW)
          INC    HL        ; BUMP VECTOR POINTER
          INC    HL        ; TO HL--> VB0AL
          LD     A,(DE)    ; GET PATTERN ADDR(LOW)
          LD     (HL),A    ; PUT IN VECTOR VB0AL
          INC    DE        ; BUMP
          INC    HL        ; PTRS
          LD     A,(DE)    ; GET PATTERN ADDR(HIGH)
          LD     (HL),A    ; PUT IN VECTOR VB0AH
          INC    DE        ; BUMP TABLE PTR TO NEXT TABLE ENTRY
          LD     A,10      ; OFFSET TO VBXL OF NEXT VECTOR
          ADD    A,L
          LD     L,A
          LD     A,$00
          ADC    A,A
          ADD    A,H
          LD     H,A       ; HL--> NEXT VECTOR VBXL
          DJNZ   INITVEC0
          RET
;
L27D7:   PUSH   AF
         LD     A,(L4FBB)
         LD     D,A
         POP    AF
         SUB    D
         JR     Z,L2807
         JP     P,L27ED
         ADD    A,D
         LD     E,A
         LD     A,D
         SUB    E
         DAA
         CALL   L27F3
         SUB    B
         RET
;
L27ED:   DAA
         CALL   L27F3
         ADD    A,B
         RET
;
L27F3:   LD     B,$FF
;
L27F5:   INC    B
         SUB    $10
         JR     NC,L27F5
         ADD    A,$10
;         
L27FC:   ADD    A,$0A
         DJNZ   L27FC
         LD     B,A
         XOR    A
;
L2802:   ADD    A,$03
         DJNZ   L2802
         LD     B,A
;
L2807:   LD     A,$41
         RET
;
L280A:   SUB    65
         JR     Z,L2842
         JP     P,L281D   ; RIGHT SIDE OF THE SCREEN?
         NEG              ; NO, MAKE DIFFERENCE POSITIVE
         CALL   DIV3
         SUB    B
         DAA
         CP     $00
         RET    NZ
         INC    A
         RET
;
L281D:   CALL   DIV3
         ADD    A,B
         DAA
         CP     $00
         RET    NZ
         LD     A,$99
         RET
;
;   DIV3 -- DIVIDE 'A' BY 3 (BCD)
;
;        UPON EXIT:  B = RESULT
;                    A = ???
;
DIV3:    LD     B,-1      ; START RESULT
;
L282A:   INC    B
         SUB    3
         JR     NC,L282A  ; KEEP DIVIDING
         LD     A,B       ; SAVE RESULT IN A
         LD     B,0
;
L2832:   CP     10        ; IS RESULT < 10?
         JR     C,L2840   ; YES
         SBC    A,$0A
         PUSH   AF
         LD     A,$10     ; BUMP B BY 10 (BCD)
         ADD    A,B
         LD     B,A       ; SAVE IN B
         POP    AF
         JR     L2832     ; CHECK AGAIN
;
L2840:   ADD    A,B       ; ADD TO REMAINDER
         LD     B,A       ; RESULT IN B
;
L2842:   LD     A,(L4FBB) ; GET ???  (BCD VALUE)
         RET
;
L2846:   CP     $51
         RET    C
         SUB    $50
         DAA
         LD     B,A
         LD     A,$50
         SUB    B
         DAA
         RET
;
L2852:   LD     A,(LINEBALL)  ; GET THE BALL'S YARD LINE
         LD     C,$07
         LD     D,A
         EX     AF,AF'
         LD     A,$80
         CP     D
         RET    Z
         RET    C
         LD     C,$00
         LD     A,$10
L2862:   CP     D
         JR     Z,L2866
         RET    NC
;
L2866:   INC    C
         ADD    A,$10
         JR     L2862
;
;
;   DRWFIELD -- DRAWS THE PLAY FIELD (BASED ON CONDITIONS)
;
;     UPON ENTRANCE:  HL--> SOMEWHERE WITHIN THE YARD TABLE POINTER
;                               (SCALED TO FIT ON THE SCREEN)
;
;
DRWFIELD: PUSH   HL        ; SAVE YARD TABLE POINTER
          LD     HL,L4FC0
          LD     A,(L4FBB)
          CP     $70
          PUSH   AF
          LD     A,$27
          JR     Z,L2892
          JR     C,L2881
          SET    1,(HL)
          LD     A,$1F
          JR     L2892
;
L2881:   POP    AF
         PUSH   AF
         CP     $20
         LD     A,$01
         JR     Z,L2892
         JR     NC,L2891
         SET    0,(HL)
         LD     A,$09
         JR     L2892
;
L2891:   XOR    A
;
L2892:   LD     B,A
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         LD     A,B
         JR     Z,L28A5
         LD     A,$03
         AND    (HL)
         JR     Z,L28A0
         LD     A,$03
         XOR    (HL)
         LD     (HL),A
;
L28A0:   LD     A,B
         SBC    A,40
         NEG
;
L28A5:   ADD    A,11000000B  ; FORCE BACKGROUND FRAME TO COLOR 3
         OUT    (HORCB),A    ; SET NEW COLOR BOUNDARY
;
         SYSSUK FILL      ; BLANK SCREEN
         DW     NORMEM    ; START
         DW     90*BYTEPL ; LENGTH
         DB     0         ; FILL CHAR
;
         NOP
;
         SYSSUK FILL      ; DRAW TOP SIDELINE
         DW     NORMEM    ; START
         DW     6*BYTEPL  ; 6 PIXEL LINES
         DB     11111111B ; COLOR 3
;
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         JR     Z,L28D0
         LD     A,-38
         EX     AF,AF'
         LD     DE,151
         LD     C,$28
         LD     HL,COLIST5  ; HL--> NEW COLOR LIST
         POP    AF
         LD     A,$AA
         JR     NC,L28E3
         LD     HL,COLIST4  ; HL--> NEW COLOR LIST
         JR     L28E3
;
L28D0:   LD     A,$16
         EX     AF,AF'
         LD     DE,2
         LD     C,$24
         LD     HL,COLIST1  ; HL--> NEW COLOR LIST
         POP    AF
         LD     A,$55  ; COLOR PATTERN FOR YARD LINE
         JR     NC,L28E3
         LD     HL,COLIST2  ; HL--> NEW COLOR LIST
;
L28E3:   SYSTEM COLSET    ; SET NEW COLORS
         PUSH   BC
         LD     BC,2*BYTEPL  ; 2 PIXELS WIDE
         PUSH   DE
         LD     DE,NORMEM+(6*BYTEPL)  ; OFFSET TO DRAW YARDLINE
;
         SYSTEM FILL      ; DRAW THE YARD LINE
;
         LD     DE,NORMEM+(88*BYTEPL)  ; OFFSET TO DRAW BOTTOM YARDLINE
;
         SYSTEM FILL      ; DRAW THE BOTTOM ONE
;
         POP    DE
         POP    BC
         EX     AF,AF'
         POP    HL
         LD     B,6       ; DISPLAY 6 10-YARD MARKERS
         LD     IX,FNTSML ; IX = SMALL CHARACTER FONT POINTER
;
L28FE:   PUSH   BC
         PUSH   AF
         PUSH   DE
         INC    E
         INC    E
         INC    E
         LD     D,6       ; Y COORD = PIXEL LINE 6
         LD     BC,$0201  ; 2 HIGH x 1 WIDE
         LD     A,11111111B  ; PIXEL PATTERN (COLOR 3)
         RST    PBOX      ; PAINT A BOX
         LD     D,88      ; AND ON LINE 88, TOO!
         RST    PBOX      ; PAINT A BOX
         POP    DE
         POP    AF
         POP    BC
         PUSH   BC
         LD     B,$C2     ; ZERO SUPPRESS, ALT. FONT, 2 DIGITS
;
         SYSTEM DISNUM    ; DISPLAY A NUMBER (YARDLINE)
;
         INC    HL        ; BUMP YARDLINE TABLE POINTER
         PUSH   AF
         ADD    A,E
         LD     E,A
         POP    AF
         POP    BC
         DJNZ   L28FE
         LD     HL,L4FC0
         LD     A,(HL)
         AND    $03
         RET    Z
         BIT    1,A
         JR     NZ,L2937
         LD     DE,0
         PUSH   DE
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         LD     A,$AA
         JR     NZ,L2944
         LD     A,55H
         JR     L2944
;
L2937:   LD     DE,150
         PUSH   DE
         RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         LD     A,$55
         JR     Z,L2942
         LD     A,$AA
;
L2942:   LD     E,154     ; X COORD.
;
;   DRAW END ZONE
;
L2944:   LD     D,6       ; UPPER YARD LINE COORD.
         LD     BC,84*256+6  ; Y=84, X=6 (BOX 84 HIGH x 6 WIDE)
         RST    PBOX      ; PAINT A BOX
         LD     A,$FF
         POP    DE        ; AT OPPOSITE SIDE NOW
         LD     BC,5*256+10  ; Y=5, X=10 (5 HIGH x 10 WIDE)
         RST    PBOX      ; PAINT A BOX
         LD     A,$FC
         AND    (HL)
         LD     (HL),A
         RET
;
; **********
; *
; *   PLAYER INPUT TRANSITION PROCESSING ROUTINES
; *
; **********
;
;   DOKNOB1 -- KNOB 1 TRANSITION PROCESSOR
;
DOKNOB1: RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         RET    Z         ; NOT OFFENSE, EXIT
         LD     A,B       ; ELSE, COMPLEMENT
         CPL
         JR     DOKNOBS   ; COMMON
;
;   DOKNOB0  -- KNOB 0 TRANSITION PROCESSOR
;
DOKNOB0: RST    CMAG      ; GET LINE OF SCRIMMAGE MAGIC REG.
         RET    NZ
         LD     A,B
;
;   DOKNOBS -- COMMON PROCESSING FOR KNOBS
;
DOKNOBS:  AND    $E0
          RST    QORF      ; IS VECTOR QUARTERBACK OR FOOTBALL?
          RET    NZ        ; FOOTBALL, EXIT
          LD     HL,L4FC6
          LD     C,(HL)
          LD     (HL),A
          DEC    HL
          CP     0
          JR     Z,DOKNOBSA
          CP     $E0
          JR     Z,DOKNOBSB
          CP     C
          RET    Z
          JR     C,DOKNOBSC
          LD     A,$04
          CP     (HL)
          RET    Z
          INC    (HL)
          JR     DOKNOBSX
;
DOKNOBSA: LD     (HL),$00
          JR     DOKNOBSX
;
DOKNOBSB: LD     (HL),$04
          JR     DOKNOBSX
;
DOKNOBSC: XOR    A
          CP     (HL)
          RET    Z
          DEC    (HL)
;
DOKNOBSX: DI
          LD     A,(HL)
          RLCA
          LD     HL,QPATERNS       ; HL--> Quarterback Pattern Pointer Table
          RST    NDXW              ; Index Word Table
          LD     (CURQPAT),DE      ; Save Pattern Address
          LD     A,1               ; Index 2nd Entry (N?X1 Pattern to Draw)
          RST    NDXW              ; Index Word Table
          LD     (VCTOQTRB+15),DE  ; Save Addr. of Next Pattern to Draw
          EI
          RET
;
;   DOTRIG1 -- Trigger 1 Transition Processor
;
DOTRIG1:  RST    CMAG        ; Get Line of Scrimmage Magic Reg.
          JR     NZ,DOTRIGS            ; OK, We Have the Ball
          RET  
;
;   DOTRIG0 -- Trigger 0 Transition Processor
;
DOTRIG0:  RST    CMAG        ; Get Line of Scrimmage Magic Reg.
          RET    NZ          ; We Do Not Have the Ball, Return  
;
;   Common Trigger Processing
;
DOTRIGS:  LD     HL,VCTOQTRB+VBSTAT  ; HL--> Status
          BIT    5,(HL)      ; Do we have the ball?
          RET    Z           ; No, Return
          LD     A,$88       ; Init, New Status (Active & XXX)   
          DI
          LD     (HL),A      ; Save in Status Byte
          LD     HL,VCTOQTRB+VBYCHK

L29AF:    RES    7,(HL)
          INC    HL          ; BUMP PTR. TO VBOAL
          LD     DE,G_FTBALL           ; DE--> FOOTBALL PATTERN
          LD     C,(HL)      ; GET OLD PATTERN
          LD     (HL),E      ; PUT NEW
          INC    HL          ; BUMP TO
          LD     B,(HL)      ; GET OLD PATTERN HIGH
          LD     (HL),D      ; AND PUT NEW ONE
          LD     (QOLDPATR),BC        ; SAVE OLD PATTERN ADDRESS
          EI
          LD     HL,VCTEND1+VBSTAT
          SET    1,(HL)      ; INDICATE TO CATCH THE BALL
          LD     HL,VCTEND2+VBSTAT
          SET    1,(HL)      ; INDICATE TO CATCH THE BALL
          LD     HL,QPOSOLDX            ; HL--> QUARTERBACK OLD X,Y COORDINATE BUFFER
          LD     A,(VCTOQTRB+VBXH)
          LD     (HL),A
          INC    HL
          LD     A,(VCTOQTRB+VBYH)
          LD     (HL),A
          RET
;
;   READTRID -- Reads the Triggers for the Proper Player
;
;
RDTRIG:   LD     BC,$6410
          RST    CMAG       ; GET LINE OF SCRIMMAGE MAGIC REG.
          JR     Z,RDTRIG0
          INC    C             
;
RDTRIG0:  IN     A,(C)
          BIT    4,A
          JR     NZ,RDTRIG
          DJNZ   RDTRIG0  
;
RDTRIG1:  LD     B,$64 
;
RDTRIG2:  IN     A,(C)
          BIT    4,A
          JR     Z,RDTRIG1
          DJNZ   RDTRIG2
          RET
;
;   Background Interrupt Handler
;                        
L29F0:    PUSH   AF
          PUSH   BC
          PUSH   DE
          PUSH   HL
          PUSH   IX
          PUSH   IY  
          LD     A,$04
          LD     (TMR60),A
          XOR    A
          LD     HL,VCTLINO1+VBYCHK    ; (CURSOR VECTOR)
          BIT    5,(HL)
          JR     Z,L2A58
          DEC    HL          ; BUMP
          DEC    HL          ; TO VBYL
          CP     (HL)
          EX     AF,AF'
          INC    HL          ; NOW TO VBYH
          XOR    A           ; A=0
          CP     (HL)        ; SEE IF ZERO
          JR     Z,L2A27
          LD     C,$10
          RST    CMAG        ; GET LINE OF SCRIMMAGE MUSIC REG.
          JR     Z,L2A14
          INC C
;          
L2A14:    IN     A,(C)
          EXX
          AND    $0F
          JR     Z,L2A23
          LD     HL,SELPLAY
          XOR    A
          OR     (HL)
          JR     NZ,L2A23
          LD     (HL),C    
;
L2A23:    EXX
          DEC    (HL)
          JR     L2A58  
L2A27:    EX      AF,AF'
          JR      Z,L2A4E
          EXX
          INC     B
          LD      A,$29
          CP      B
          EXX
          JR      NZ,L2A38
          INC     HL
          SET     6,(HL)
          DEC     HL
          JR      L2A4E     
;
;   Scroll the Cursor Down
;
L2A38:    DEC     HL
          DEC     (HL)
          LD      BC,$0A02   ; B=# OF LINES TO SCROLL, C=# OF BYTES ON LINE TO SCROLL
          LD      DE,-BYTEPL           ; LINE INCREMENT (SCROLL DOWN IF NEGATIVE)
          LD      HL,(CURSRPOS)        ; HL= ADDR. 0: 1ST BYTE OF SCROLL
;
          SYSTEM  SCROLL     ; SCROLL AREA OF SCREEN
;          
          LD      DE,BYTEPL
;
L2A48:    ADD     HL,DE      ; SKIP ONE LINE
          LD      (CURSRPOS),HL        ; SAVE NEW CURSOR POSITION
          JR      L2A58      ; AND EXIT          
;
L2A4E:    LD      A,$75
          EXX
          INC     C
          EXX
          LD      (HL),A
          DEC     HL
          LD      A,10
          LD      (HL),A  
;
L2A58:    CALL    STIMER     ; SERVICE SYSTEM COUNTER, ETC.
          POP     IY
          POP     IX
          POP     HL
          POP     DE
          POP     BC
          POP     AF
          EI
          RET  
;
;   DOJOY0 -- Joystick 0 Transition Processor
;
DOJOY0:  RST     CMAG        ; GET LINE OF SCRIMMAGE MAGIC REG.
         JR      NZ,DOJOYSA
;          
DOJOY0A: LD      DE,$0100
         RST     $30
         JR      Z,DOJOY0B
         LD      E,$40
;
DOJOY0B: CALL    DOJOYMOV
         LD      IX,VCTOQTRB
         CALL    DOJOYSAV
         LD      IX,VCTEND1
         CALL    DOJOYSAV
         RST     NUMP        ; GET # OF PLAYER (2 OR 4)
         RET     NZ
         LD      IX,VCTEND2
;         
DOJOYSAV: BIT    1,(IX+VBSTAT)
          RET    Z
          LD     (IX+VBDXH),D
          LD     (IX+VBDXL),E
          LD     (IX+VBDYL),L
          LD     (IX+VBDYH),H
          RET
;
;   DOJOY1 -- Joystick 1 Transistion Processor
;
DOJOY1:   RST    CMAG        ; GET LINE OF SCRIMMAGE MAGIC REG.
          JR     NZ,DOJOY0A   
;
DOJOYSA:  LD     DE,$0100
          RST    $30
          JR     NZ,DOJOYSA2
          RST    NUMP        ; GET # OF PLAYERS (2 OR 4)
          JR     Z,DOJOYSA1
          LD     HL,(MUSICWRK)             
          INC    HL
          BIT    5,(HL)
          JR     NZ,DOJOYSA2
          BIT    3,(HL)
          JR     NZ,DOJOYSA2
;          
DOJOYSA1: LD     E,$40
;
DOJOYSA2: CALL   DOJOYMOV
          LD     IX,VCTEND4
          CALL   DOJOYSAV
          RST    NUMP        ; GET # OF PLAYERS (2 OR 4)
          RET    NZ
          LD     IX,VCTEND3
          JR     DOJOYSAV
;
;   DOJOY2 -- Joystick 2 Transition Processor
;
DOJOY2:  RST     NUMP        ; GET # OF PLAYERS (2 OR 4)
         RET     Z
         RST     CMAG        ; GET LINE OF SCRIMMAGE MAGIC REG.
         JR      NZ,L2AE0 
;
L2ACA:   LD      DE,$0100
         RST     $30
         JR      Z,L2AD2
         LD      E,$40
;
L2AD2:   CALL    DOJOYMOV
         LD      IX,VCTEND2
         JR      DOJOYSAV  
;
;   DOYJOY3 -- Joystick 3 Transition Handler
;
DOJOY3:  RST     NUMP        ; GET # OF PLAYERS (2 OR 4)
         RET     Z
         RST     CMAG        ; GET LINE OF SCRIMMAGE MAGIC REG.
         JR      NZ,L2ACA
;
L2AE0:   LD      DE,$0100
         RST     $30
         JR      NZ,L2AF4
         LD      HL,(MUSICWRK)
         INC     HL
         BIT     5,(HL)
         JR      NZ,L2AF4
         BIT     3,(HL)
         JR      NZ,L2AF4
         LD      E,$40   
;
L2AF4:   CALL    DOJOYMOV
         LD      IX,VCTEND3
         JR      DOJOYSAV
;
;   DOJOYMOV -- Converts Mask to Deltas
;
;        Upon Entrance:   A = MR (Flop Flag)
;                         B = Joystick Mask 
;                        DE = Postitive X Delta
;                        HL = Positive Y Delta
;
DOJOYMOV:  RST    CMAG       ; GET LINE OF SCRIMMAGE MAGIC REG.
;
NEWDELTA:  LD     C,A        ; MR
           LD     H,D        ; SET Y = X DELTA
           LD     L,E
; 
           SYSTEM MSKTD      ; CONVERT MASK TO DELTAS
           RET
;             
SETOFFA:   SET    6,(HL)
           RES    7,(HL)     ; RESET SPECIAL PLAY GROUP FLAG
           INC    HL         ; BUMP PTR. TO MR FOR LINE OF SCRIMMAGE
           XOR    A          ; A=0
           LD     (HL),A     ; ZERO MR (ALSO, OFFENSIVE)
           DEC    HL         ; BACK TO ORIGINAL
           RET 
;
;   SETOFFB -- Sets Flags to Indicate Player B is Offensive
;
SETOFFB:   SET    6,(HL)
           SET    7,(HL)     ; INDICATE SPECIAL PLAY GROUP
           INC    HL         ; BUMP TO LINE OF SCRIMMAGE MR 
           LD     A,$40      ; MR = FLOP (INICATES OFFENSE)
           LD     (HL),A     
           DEC    HL         
           RET 
;
;**********
;*
;*   Restart Processors
;*
;
;
;   RST 10 Processor -- Returns Magic Reg. for Current Line of Scrimmage
;                              (MRFLOP - Who has the ball...)
;
;                       Z = Player A
;                      NZ = Player B
;
;
RST10:     LD     A,(LSMAGIC)
           OR     A
           RET      
;
;   RST 18 Processor -- Paints a Rectangle
;
RST18:     SYSTEM RECTAN     ; PAINT RECTANGLE
           RET  
;
;   RST 20 Processor -- Index a Word 
;
RST20:     SYSTEM INDEXW     ; INDEX WORD 
           RET
;
;   RST 28 Processor -- Returns No. of Players 
;
;              Z Flag = 2-Player Version 
;             NZ Flag = 4-Player Version
;
RST28:     LD     A,(NUMPLAYR)
           OR     A
           RET
;
;   RST 30 Processor --  
;
RST30:     LD     A,(L4E82)
           OR     A
           RET  
;
;   DOCT7 -- Counter-Timer 7 Transition Processor
;
DOCT7:     LD     HL,CT7
           LD     (HL),32    ; RESET CT7
           LD     HL,VCTLIND4+VBSTAT
           SET    1,(HL)
           RST    QORF       ; IS VECTOR QUARTERBACK OR FOOTBALL?
           JR     Z,DOCT7C   ; QUARTERBACK 
;
;   It is the Ball, Start Everyone Moving
;
           LD     HL,VCTEND1+VBSTAT
           LD     B,16       ; 16 VECTORS
           LD     A,12
           LD     DE,VECTSZ
;           
DOCT7A:    CP     B
           JR     Z,DOCT7B
           SET    VBSACT,(HL)
;
DOCT7B:    ADD    HL,DE
           DJNZ   DOCT7A
           RET
;
DOCT7C:    LD     IX,(MUSICWRK)
           BIT    0,(IX+VBSTAT)
           RET    NZ
           LD     H,(IX+VBXH)
           LD     L,(IX+VBYH)
           LD     IX,VCTLIND4
           LD     B,0        ; SET JOYSTICK MASK TO NO EVENT
           LD     A,(IX+VBXH)
           CP     H
           JR     C,DOCT7D
           SET    2,B        ; SET "LEFT" BIT
           JR     DOCT7E 
;
DOCT7D:    SET    3,B        ; SET "RIGHT" BIT
;
DOCT7E:    LD     A,(IX+VBYH)
           CP     L
           JR     C,DOCT7F
           SET    0,B        ; SET "UP" BIT
           JR     DOCT7G
;           
DOCT7F:    SET    1,B        ; SET "DOWN" BIT
;
DOCT7G:    LD     DE,$0100   ; DELTA OF 1.00
           XOR    A          ; MR
           CALL   NEWDELTA   ; SET NEW DELTAS
           JP     DOJOYSAV   ; AND SAVE IT
;
;   RST 08 Processor -- Returns Status of QTRBACK/FOOTBALL Vector
;
;      Upon Return: HL--> QTRBACK/FOOTBALL Vector + VBXCHK
;                    Z =  Quarterback
;                   NZ =  Football
;
RST08:     LD     HL,VCTOQTRB+VBXCHK
           BIT    7,(HL)
           RET
;
PGROUP1:   DW     L_SCREEN   ; 1. SCREEN PASS
           DW     L_SLANT    ; 2. SLANT IN PASS
           DW     L_LMIDPS   ; 3. LONG MIDDLE PASS
           DW     L_CROSS    ; 4. CROSSING PASS
           DW     L_SIDELN   ; 5. SIDELINE PASS                      
;
PGGROUP1P: DW     PLAYTAB    ; 1
           DW     L2BCB      ; 2
           DW     L2BCF      ; 3
           DW     L2BD1      ; 4
           DW     L2BC7      ; 5    
;
;   Play Group 2
;
PGROUP2:   DW     L_LONGBM   ; 1. LONG BOMB 
           DW     L_LMIDPS   ; 2. LONG MIDDLE PASS
           DW     L_CROSS    ; 3. CROSSING PASS
           DW     L_RAZZLE   ; 4. RAZZLE DAZZLE
           DW     L_SIDELN   ; 5. SIDELINE PASS                      
;
PGROUP2P:  DW     L2BD9      ; 1
           DW     L2BCF      ; 2
           DW     L2BD1      ; 3
           DW     L2BDD      ; 4
           DW     L2BC7      ; 5           
;
;   Play Group 3
;
PGROUP3:   DW     L_SCREEN   ; SCREEN PASS
           DW     L_SMIDPS   ; SHORT MIDDLE PASS
           DW     L_SLANT    ; SLANT PASS
           DW     L_SIDELN   ; SIDELINE PASS
           DW     L_AROUND   ; AROUND END RUN   
;
PGROUP3P:  DW     PLAYTAB    ; 1
           DW     L2BCD      ; 2
           DW     L2BCB      ; 3
           DW     L2BC7      ; 4
           DW     L2BD5      ; 5           
;
PLAYTAB:   DW     L2C7D      ; SCREEN PASS
L2BC7:     DW     L2C77      ; SIDELINESS PASS
L2BC9:     DW     L2C6B      ;
L2BCB:     DW     L2C74      ; SLANT IN PASS
L2BCD:     DW     L2C5F      ; SHORT MIDDLE PASS
L2BCF:     DW     L2C5C      ; LONG MIDDLE PASS
L2BD1:     DW     L2C71      ; CROSSING PASS
L2BD3:     DW     L2C6B      ;
L2BD5:     DW     L2C65      ; AROUND END RUN
L2BD7:     DW     L2C6E      ;
L2BD9:     DW     L2C68      ; LONG BOMB
L2BDB:     DW     L2C68      ; LONG BOMB
L2BDD      DW     L2C86      ; RAZZLE DAZZLE
           DW     L2C6B      ;
;
;   Linemen & Quarterback Play Pointers
;
OFFPAT1:                     ; OFFENSIVE PATTERN 1
           DW     PLAY02     ; QTRBACK     
           DW     L2C8F      ; BOTTOM END      
           DW     L2C92      ; TOP      
           DW     L2C92      ; BOTTOM      
           DW     L2C92      ; TOP      
           DW     L2C8F      ; BOTTOM                                            
;
OFFPAT2:   DW     PLAY02
           DW     L2C68 
           DW     L2C68
           DW     L2C68
           DW     L2C68
           DW     L2C68                                            
;
DEFNSPAT:                    ; DEFENSIVE PATTERNS
           DW     L2C59
           DW     L2C59
           DW     L2C59
           DW     L2C59
           DW     L2C95
           DW     L2C59                                              
;
;   Scrimmage Pattern Position Tables
;   
POSTAB1:   DB     -6,18      ; OFFENSIVE TOP END
           DW     G_END02    ; PATTERN 2  
;
           DB     -6,64      ; OFFENSIVE BOTTOM END
           DW     G_END02    ; PATTERN 2
;
           DB     18,64      ; DEFENSIVE BOTTOM END
           DW     G_END03    ; PATTERN 3
;
           DB     18,20      ; DEFENSIVE TOP END
           DW     G_END03    ; PATTERN 3
;
POSTAB2:   DB     -20,45     
           DW     G_QTRSNP   ; PATTERN  
POSTAB3:   DB     -5,34
           DW     G_OLINEM   ; LINE PATTERN    
;
           DB     -5,40
           DW     G_OLINEM   ; LINE PATTERN
;
           DB     -5,46
           DW     G_OLINEM   ; LINE PATTERN
;
           DB     -5,52
           DW     G_OLINEM   ; LINE PATTERN
;
           DB     -5,58
           DW     G_OLINEM   ; LINE PATTERN
;
;   Defensive Linemen Positions
;
           DB     3,34
           DW     G_DLINEM   ; LINEMAN 
;
           DB     3,40
           DW     G_DLINEM 
;
           DB     3,52
           DW     G_DLINEM 
;
           DB     3,58
           DW     G_DLINEM 
;
           DB     11,45
           DW     G_END03    ; DEFENSIVE END 
;          
           DB     3,46
           DW     G_DLINEM
;
;
POSTAB5:                     ; FLANKER POSITIONS
           DB     -11,23
           DW      G_END02
;
           DB     -6,64
           DW      G_END02
;
;
;   Play Movement Patterns Table
;
;      Each 3-Byte Entry is in the following format:
;
;    ----------------------------
;    :  Time  : Delta  : Delta  :
;    :  Base  :   X    :   Y    :
;    ----------------------------
;
;       Move of a figure is directed by entries from the table until
;   an entry with a time base of 0 is encountered.  Joystick control
;   takes over then.
;
;
PLAY01:  DB     0,3,-3 
PLAY02:  DB     0,4,-2 
PLAY03:  DB     0,4,0
PLAY04:  DB     0,4,2
L2C59:   DB     0,3,3
L2C5C:   DB     0,-1,0
L2C5F:   DB     20,1,0
L2C62:   DB     20,1,0
L2C65:   DB     0,0,1
L2C68:   DB     40,0,1
L2C6B:   DB     0,1,0    
L2C6E:   DB     20,1,0        
L2C71:   DB     0,1,-1        
L2C74:   DB     20,1,0        
L2C77:   DB     0,1,1        
L2C7A:   DB     20,1,0        
L2C7D:   DB     0,0,-1        
L2C80:   DB     5,-1,0        
L2C83:   DB     10,0,0        
L2C86:   DB     0,1,0        
L2C89:   DB     5,1,-1
L2C8C:   DB     10,1,1
L2C8F:   DB     0,1,-1
L2C92:   DB     2,-1,0
L2C95:   DB     2,-1,0      
PLAYPUNT: DB    0,0,0
L2C9B:    DB    4,3,-3
          DB    11,3,-2
          DB    5,4,0
          DB    11,3,2
          DB    4,3,3
          DB    0,0,0

;**********
;*
;*   Graphic Patterns
;*
;
;
;   Football in Motion
;
G_FTBALL: DB    1,1
          DB    11110000B ; @ @ . .
;
;   Lineman Facing Right
;
G_OLINEM  DB    1,3
          DB    01000100B ; @ . @ .
          DB    00010101B ; . @ @ @
          DB    01000100B ; @ . @ .    
;
;   Lineman Facing Left
;
G_DLINEM: DB    1,3
          DB    00100010B ; . @ . @
          DB    10101000B ; @ @ @ .
          DB    00100010B ; . @ . @
; 
;   End Pattern 1
;
G_END01:  DB    1,6
          DB    00010000B ; . @ . .         
          DB    01010100B ; @ @ @ .
          DB    01010000B ; @ @ . .
          DB    01010100B ; @ @ @ .
          DB    01000101B ; @ . @ @                              
          DB    01000000B ; @ . . .          
; 
;   End Pattern 2
;
G_END02:  DB    1,6        
          DB    00000100B ; . . @ .
          DB    00010100B ; . @ @ .
          DB    00010101B ; . @ @ @
          DB    01010100B ; @ @ @ .
          DB    01000100B ; @ . @ .
          DB    00000100B ; . . @ .                                        
; 
;   End Pattern 3
;
G_END03:  DB    1,6
          DB    00001000B ; . . @ .
          DB    00101010B ; . @ @ @
          DB    00001010B ; . . @ @                    
          DB    00101010B ; . @ @ @
          DB    10100010B ; @ @ . @          
          DB    00000010B ; . . . @                   
; 
;   End Pattern 4
;
G_END04:  DB    1,6
          DB    00100000B ; . @ . .
          DB    00101000B ; . @ @ .
          DB    10101000B ; @ @ @ .
          DB    00101010B ; . @ @ @
          DB    00100010B ; . @ . .
          DB    00100000B ; . @ . .          
; 
;   End Pattern 5
;
G_END05:  DB    1,6
          DB    00010000B ; . @ . .
          DB    01010100B ; @ @ @ .
          DB    01011111B ; @ @ @ @                    
          DB    01010100B ; @ @ @ .
          DB    01000101B ; @ . @ @
          DB    01000000B ; @ . . .                              
; 
;   End Pattern 6
;
G_END06:  DB    1,6
          DB    00000100B ; . . @ .
          DB    00010100B ; . @ @ .
          DB    00010101B ; . @ @ @
          DB    01011111B ; @ @ @ @
          DB    01000100B ; @ . @ .
          DB    00000100B ; . . @ .
; 
;   End Pattern 7
;
G_END07:  DB    1,6
          DB    00001000B ; . . @ .
          DB    00101010B ; . @ @ @
          DB    11111010B ; @ @ @ @
          DB    00101010B ; . @ @ @
          DB    10100010B ; @ @ . @                              
          DB    00000010B ; . . . @          
; 
;   End Pattern 8
;
G_END08:  DB    1,6
          DB    00100000B ; . @ . .
          DB    00101000B ; . @ @ .          
          DB    10101000B ; @ @ @ .
          DB    11111010B ; @ @ @ @
          DB    00100010B ; . @ . @
          DB    00100000B ; . @ . .                    
;
;**********
;*
;*   Strings for Plays, Titles, Etc...
;*
;
L_TCHDWN: DB    "TOUCHDOWN",$00 
L_SAFETY: DB    "SAFETY",$00
L_PLAYS:  DB    "PLAYS",$00        
L_AROUND: DB    "AROUND END RUN",$00        
L_SMIDPS: DB    "SHORT MIDDLE PASS",$00
L_LONGBM: DB    "LONG BOMB",$00
L_SIDELN: DB    "SIDE LINE PASS",$00
L_LMIDPS: DB    "LONG MIDDLE PASS",$00
L_SLANT:  DB    "SLANT IN PASS",$00  
L_SCREEN: DB    "SCREEN PASS",$00  
L_CROSS:  DB    "CROSSING PASS",00
L_RAZZLE: DB    "RAZZLE DAZZLE",$00

;
;   Misc. Strings
;
L_FOOTBL: DB    "FOOTBALL",$00
L_PUNT:   DB    "PUNT",$00
L_TIME:   DB    "TIME",$00
L_2PLAYR: DB    "FOOTBALL 2-PLYR",$00 
L_4PLAYR: DB    "FOOTBALL 4-PLYR",$00 
L_YARDGO: DB    "YARDS TO GO",$00
L_DOWN:   DB    "DOWN",$00
L_END:    DB    "END",$00
L_BALLON: DB    "BALL ON",$00
;**********
;*
;*   Vector Initialization Skeleton
;*
;
;
;
VECTSKEL: DB    $20       ;  0 - VBMR   - Magic Register ($20 = XOR)
          DB    $80       ;  1 - VBSTAT - Status Register (Active)
          DB    $00       ;  2 - VBTIMB - Time Base 
          DB    $00       ;  3 - VBDXL  - Delta X Lo 
          DB    $00       ;  4 - VBDXH  - Delta X Hi  
          DB    $00       ;  5 - VBXL   - X Coordinate Lo 
          DB    $00       ;  6 - VBXH   - X Coordinate Hi
          DB    $01       ;  7 - VBXCHK - X Checks Flag (Limit Check)
          DB    $00       ;  8 - VBDHI  - Delta Y Lo 
          DB    $00       ;  9 - VBDYH  - Delta Y Hi 
          DB    $00       ; 10 - VBYL   - Y Coordinate Lo 
          DB    $00       ; 11 - VBYH   - Y Coordinate Hi  
          DB    $03       ; 12 - VBYCHK - Y Checks Flag (Limit Check, Reverse Delta) 
          DB    $00       ; 13 - VBOAL  - Old Addr. Lo 
          DB    $00       ; 14 - VBOAL  - Old Addr. Hi 
          DB    $00       ; 15 -  
          DB    $00       ; 16 - 
          DB    $01       ; 17 - 
          DB    $00       ; 18 - 
;
;
;   Color Lists (Used when screen changed needed)
;
COLIST1:  DB    248,119,247,163  ; Color List
COLIST2:  DB    248,119,247,161  ; Color List          
COLIST3:  DB    248,119,247,163  ; Color List
COLIST4:  DB    248,247,119,163  ; Color List
COLIST5:  DB    248,247,119,161  ; Color List
COLIST6:  DB    248,247,119,163  ; Color List
COLIST7:  DB    248,119,247,163  ; Color List
;
;   Table of Player Vectors
;
VECTAB1:  DW    VCTLINO5,VCTLINO4,VCTLIND4,VCTLIND2
          DW    VCTEND2,VCTEND4,VCTEND1,VCTLINO3
          DW    VCTLIND1,VCTEND3,VCTOQTRB,VCTLINO2
          DW    VCTLIND3,VCTLIND5    
;
VECTAB2:  DW    VCTLIND4,VCTEND4        
          DW    VCTEND3,VCTEND2,VCTEND1,VCTDQTRB
          DW    VCTLINO1,VCTOQTRB
;
;   Table of play group selection handler (Based on Down #)
;
L2E3D:  DW      DOWN1,DOWN2,DOWN3,DOWN4
;
;
;   YARDSTAB -- Table of BCD Values for the Play Field (10-Yard Inc.)
;
YARDSTAB: DB    0,0
          DB    $10,$20,$30,$40
          DB    $50,$40,$30,$20
          DB    $10,0,0
;
;**********
;*
;*    Quarterback Pattern Pointer Table
;*
;
;
QPATERNS: DW    G_QTR10,PLAY04
          DW    G_QTR08,PLAY03    
          DW    G_QTR06,PLAY02 
          DW    G_QTR04,PLAY01
;          DW    G_QTR02,POSTAB5  ; (this line was in the source, but I had to)
          DW    G_QTR02,$2C4A     ; "fudge" this to make it work. ???
;
;
;**********
;*
;*   Quarterback Graphic Patterns
;*
;
G_QTR01:  DB    2,7
          DB    11110000B,00000000B     ; @ @ . . . . . .
          DB    10001000B,00000000B     ; @ . @ . . . . .
          DB    10101010B,10100000B     ; @ @ @ @ @ @ . .
          DB    00101000B,00000000B     ; . @ @ . . . . .
          DB    00101000B,00000000B     ; . @ @ . . . . .
          DB    00101010B,00000000B     ; . @ @ @ . . . .
          DB    00100010B,10000000B     ; . @ . @ @ . . .            
;
G_QTR02:  DB    2,7
          DB    11110000B,00010000B     ; @ @ . . . @ . . 
          DB    01000100B,01000000B     ; @ . @ . @ . . . 
          DB    01010101B,00000000B     ; @ @ @ @ . . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    00010101B,00000000B     ; . @ @ @ . . . . 
          DB    00010001B,01000000B     ; . @ . @ @ . . .  
;
G_QTR03:  DB    2,7
          DB    11110000B,00010000B     ; @ @ . . . @ . .
          DB    01000100B,01000000B     ; @ . @ . @ . . .
          DB    01010101B,00000000B     ; @ @ @ @ . . . .
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    01010100B,00000000B     ; @ @ @ . . . . .
          DB    01000100B,00000000B     ; @ . @ . . . . .                              
;
G_QTR04:  DB    2,7
          DB    11110000B,00000000B     ; @ @ . . . . . .
          DB    01000100B,00010000B     ; @ . @ . . @ . .
          DB    01010101B,01000000B     ; @ @ @ @ @ @ . .
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    00010101B,00000000B     ; . @ @ @ . . . .
          DB    00010001B,01000000B     ; . @ . @ @ . . .
;
G_QTR05:  DB    2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00010000B     ; @ . @ . . @ . . 
          DB    01010101B,01000000B     ; @ @ @ @ @ . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    01010100B,00000000B     ; @ @ @ . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . .                                                                   
;
G_QTR06:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . . 
          DB    01010101B,01010000B     ; @ @ @ @ @ @ . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    00010101B,00000000B     ; . @ @ @ . . . . 
          DB    00010001B,01000000B     ; . @ . @ @ . . .                                                                   
;
G_QTR07:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . . 
          DB    01010101B,01010000B     ; @ @ @ @ @ @ . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    00010100B,00000000B     ; . @ @ . . . . . 
          DB    01010100B,00000000B     ; @ @ @ . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . .                                                                   
;
G_QTR08:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . .
          DB    01010101B,01000000B     ; @ @ @ @ @ . . .
          DB    00010100B,00010000B     ; . @ @ . . @ . .
          DB    00010100B,00000000B     ; . @ @ . . . . .
          DB    00010101B,00000000B     ; . @ @ @ . . . .
          DB    00010001B,01000000B     ; . @ . @ @ . . .                                                                
;
G_QTR09:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . . 
          DB    01010101B,01000000B     ; @ @ @ @ @ . . . 
          DB    00010100B,00010000B     ; .@. @ . . @ . . 
          DB    00010100B,00000000B     ; .@. @ . . . . . 
          DB    01010100B,00000000B     ; @ @ @ . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . .                                                             
;
G_QTR10:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . . 
          DB    01010101B,00000000B     ; @ @ @ @ . . . . 
          DB    00010100B,01000000B     ; . @ @ . @ . . . 
          DB    00010100B,00010000B     ; . @ @ . . @ . . 
          DB    00010101B,00000000B     ; . @ @ @ . . . . 
          DB    00010001B,01000000B     ; . @ . @ @ . . .                                                             
;
G_QTR11:  DB      2,7
          DB    11110000B,00000000B     ; @ @ . . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . . 
          DB    01010101B,00000000B     ; @ @ @ @ . . . . 
          DB    00010100B,01000000B     ; . @ @ . @ . . . 
          DB    00010100B,00010000B     ; . @ @ . . @ . . 
          DB    01010100B,00000000B     ; @ @ @ . . . . . 
          DB    01000100B,00000000B     ; @ . @ . . . . .                                                             
;
G_QTRSNP: DB      2,6
          DB    00000001B,00000000B     ; . . . @ . . . .
          DB    00010101B,00000000B     ; . @ @ @ . . . . 
          DB    01010101B,00000000B     ; @ @ @ @ . . . . 
          DB    01010000B,01000000B     ; @ @ . . @ . . . 
          DB    01000000B,00000000B     ; @ . . . . . . . 
          DB    01010000B,00000000B     ; @ @ . . . . . . 
;
;**********
;*
;*   Player Input Transition Table
;*
;
DOTABLE:  RC    SCT7,DOCT7,0   ; CT7
          RC    ST0,DOTRIG0,0  ; TRIGGER 0       
          RC    ST1,DOTRIG1,0  ; TRIGGER 1
          RC    SP0,DOKNOB0,0  ; Pot. 0
          RC    SP1,DOKNOB1,0  ; Pot. 1
          RC    SJ0,DOJOY0,0   ; Joystick 0   
          RC    SJ2,DOJOY2,0   ; Joystick 2
          RC    SJ3,DOJOY3,0   ; Joystick 3
          RC    SJ1,DOJOY1,ENDx  ; Joystick 1
;
;**********
;*
;*   Music Scores
;*
;
;   National Anthem
;
ANTHEM:  MASTER 32
         VOLUME $CC,$0F   ; A,B=12, C=15 
         NOTE3  12,G1,0,0        ; G1, 0, 0
         NOTE3  12,G1,0,0        ; G1, 0, 0
         NOTE3  36,C2,G1,E1      ; C2, G1, E1         
         NOTE3  12,D2,B1,G1      ; D2, B1, G1
         NOTE3  14,E2,C2,G1      ; E2, C2, G1
         NOTE3  16,F2,D2,G1      ; F2, D2, G1
         NOTE3  72,G2,E2,C2      ; G2, E2, C2
;
         NOTE3  14,C2,F1,A1      ; C2, F1, A1   
         NOTE3  16,D2,F1,A1      ; D2, F1, A1
         NOTE3  54,E2,C2,A1      ; E2, C2, A1
         NOTE3  18,F2,D2,G1
         NOTE3  36,D2,B1,G1      ; D2, B1, G1
         NOTE3  72,C2,E1,G1      ; C2, E1, G1
;
CHEERS:  CALL   $2FDF     ; Now for some cheering           
         QUIET
;
CHANT:   MASTER 96
         LEGSTA
         OUTPUT 7,97      ; Noise
         PUSHN  5
;
L2F83:    OUTPUT 1,32     ; A  
          OUTPUT 2,16     ; B
          CALL   L2FA6    
          OUTPUT 1,48     ; A
          OUTPUT 2,32     ; B
          CALL   L2FA6
          OUTPUT 1,64     ; A
          OUTPUT 2,37     ; B
          CALL   L2FA6
          VOLUME $43,$13
          PUSHN  7
;
L2F9C:    CALL   L2FBD    
          DSJNZ  L2F9C 
          DSJNZ  L2F83
          QUIET

L2FA6:    VOLUME $CE,$1D  
          CALL   L2FBD
          VOLUME $FF,$1F
          CREL   $DD     ; Call Relative $2FBD
          VOLUME $AB,$1A
          CREL   $D9     ; Call Relative $2FBD        
          VOLUME $88,$18
          CREL   $D5     ; Call Relative $2FBD        
          VOLUME $55,$15          
          CREL   $D1     ; Call Relative $2FBD
          RET

L2FBD:    NOTE1  5,G5  
          RET

VICTORY: OUTPUT 0,32
         CREL   $D7       ; Call Relative to L2FCA    
         OUTPUT 0,24
         CREL   $D4       ; Play the Song  (Call Relative to L2FCA)
;
;   Plays Victory song once
;
L2FC6:   OUTPUT  0,20
         CREL    $D1      ; Call Relative to L2FCA
         QUIET
;
L2FCA:   VOLUME  0,$0F    ; Plays the Victory song
         OUTPUT  2,0
         OUTPUT  7,0
         VOICEM  00001100B ; C-INC PC        
         NOTE1   8,C1
         NOTE1   8,F1
         NOTE1   8,A1
         NOTE1   16,C2
         NOTE1   8,A1
         NOTE1   32,C2
;
L2FDF:   LEGSTA           ; Cheers
         MASTER  24    
         VOICEM  11111101B ; A,B,C & Noise
         VOLUME  $FF,$1F  ; Max. Volume   
;
         PUSHN  5
L2FE8:   DB     30        ; Noise      
         NOTE3  25,G6,60,80
         DSJNZ  L2FE8
         LEGSTA
         RET
;
;
;   Referee Whistle
;
WHISTLE: MASTER 12 
         VOLUME $FF,$0F   ; Volume Max.
         DB      $40,$04,$28,$2A,$2C
         QUIET
;
; Source Listing Ends at $2FFD
; Three More bytes are used on the Cartridge ROM as Released
        DB      $00,$00,$FF


; *********************************************
; ** Retying Revisions and Misc. Information **
; *********************************************
;
; Revisions:
;              Version .04 (December 7, 2011)
;                           - Source code matches byte-for-byte with Football
;                             cartridge ROM when a "fudge factor" is used.
;                           - First public release.  Considered complete
;                             unless a way to avoid the "fix" for the fudge
;                             factor is found. 
;              Version .03 (November 29, 2011)
;                           - Converted quarterback graphics to binary 
;                             to match assembly listing.
;                           - Assembles and matches to Football ROM but much of
;                             the original retyped source code still needs to
;                             be merged with source code.                              
;              Version .02 (November 28, 2011)
;                           - Revisited source-code for first time in 7 years.
;                           - Created a new version of the source file
;                             that is only data bytes (DB $XX).
;                           - Data-Only version assembles to EXACT copy
;                             of 4K Football cart.
;                           - Began the process of combining source-code
;                             from the old text file to the assembly version. 
;                           - Started typing some more source-code from ML listing.
;              Version .01 (February 11, 2004)
;                           - Typed 42 Pages of source-code as plain-text file
;                             from original Football assembly listing.
;                           - Does NOT Assemble at all.
;           
;
;  To assemble this Z-80 source code using ZMAC:
;  
;  zmac -d -o <outfile> -x <listfile> <filename>
;  
;  For example, assemble this Astrocade Z-80 ROM file:
;     
;  zmac -i -m -o football.bin -x football.lst football.asm
