;  Brickyard / Clowns -  Videocade #2004
;  Programmed by Bob Ogdon,  Audio by Scot Norris
;  Bally Mfg. Corp.    -  Action/Skills Series  
;  Released 1978
;
;  Cartridge for Bally Arcade / Astrocade 
;
;  Dissassembly by Adam Trionfo
;
;  Versions:
;     .003 (Dec. 20, 2011)
;        - First Public Release
;        - To-Do: Rename these Brickyard and Clown Vectors for Ball and Paddle
;        - Assembly binary output matches 100% with "Brickyard/Clowns" cart
;     .002 (Dec. 9, 2011)
;        - Second day of disassembly
;        - Disassembled all 10 music/sound effect scores using 
;          using Richard Degler's "Music 1-note.LUA" script
;          for the DZ80 disassembler.  Handy and timesaving!
;        - Began commenting "Clowns"
;     .001 (Feb. 28, 2011)
;        - First Day of Disassembly
;        - Hand disassembled the setup the Menus
;        - Disassembled much of "Clowns" and "Brickyard" using DZ80
;          and "BallyHVG.LUA" script.  
;        - Program mostly not commented
;           
;
;  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 clowns.bin -x clowns.lst clowns.asm


AKEYS     EQU   $0214             ; ALKEYS: All KEYS mask
STACK     EQU   $4F45             ; Stack for "Brickyard" and "Clowns"

; NOTE: CLOWVECT and TEETVECT were disassembled when I was disassembling
; ----  the Clowns part of the ROM.  It turns out that Brickyard uses
;       the same areas of RAM for the Ball and the Paddle Vector.
;       Thus, in Brickyard:
;
;       CLOWVECT = BALLVECT ("Ball Vector")
;       TEETVECT - PADDVECT ("Paddle Vector")
;
;       TO-DO - Rename these Vectors to better suit Brickyard and Clowns.                        

;  CLOWVECT - CLOWn VECTor
CLOWVECT  EQU  $4F83              ; $4F83 Vector Magic Register
CLOWSTAT  EQU  CLOWVECT+VBSTAT    ; $4F84 Vector Status
CLOWTIMB  EQU  CLOWVECT+VBTIMB    ; $4F85 Vector Time Base
CLOWDXL   EQU  CLOWVECT+VBDXL     ; $4F86 Vector Delta X Lo
CLOWDXH   EQU  CLOWVECT+VBDXH     ; $4F87 Vector Delta X Hi
CLOWXPOS  EQU  CLOWVECT+VBXH      ; $4F89 Vector X Position
CLOWXCHK  EQU  CLOWVECT+VBXCHK    ; $4F8A Vector X Checks
CLOWDYL   EQU  CLOWVECT+VBDYL     ; $4F8B Vector Delta Y Lo
CLOWDYH   EQU  CLOWVECT+VBDYH     ; $4F8C Vector Delta Y Hi
CLOWYPOS  EQU  CLOWVECT+VBYH      ; $4F8E Vector Y Position
CLOWYCHK  EQU  CLOWVECT+VBYCHK    ; $4F8F Vector Y Checks

;  TEETVECT - TEETer-totter VECTor
TEETVECT  EQU  $4F92              ; $4F92 Vector Magic Register
TEETSTAT  EQU  TEETVECT+VBSTAT    ; $4F93 Vector Status
TEETTIMB  EQU  TEETVECT+VBTIMB    ; $4F94 Vector Time Base
TEETDXL   EQU  TEETVECT+VBDXL     ; $4F95 Vector Delta X Lo
TEETDXH   EQU  TEETVECT+VBDXH     ; $4F96 Vector Delta X Hi
TEETXPOS  EQU  TEETVECT+VBXH      ; $4F98 Vector X Position
TEETXCHK  EQU  TEETVECT+VBXCHK    ; $4F99 Vector X Checks
TEETDYL   EQU  TEETVECT+VBDYL     ; $4F9A Vector Delta Y Lo
TEETDYH   EQU  TEETVECT+VBDYH     ; $4F9B Vector Delta Y Hi
TEETYPOS  EQU  TEETVECT+VBYH      ; $4F9D Vector Y Position
TEETYCHK  EQU  TEETVECT+VBYCHK    ; $4F9E Vector Y Checks

NUMBAL    EQU   $4FCD             ; Number of Balls
NUMPLA    EQU   $4FF3             ; Number of Players (Brickyard and Clowns) 

        INCLUDE "HVGLIB.H"  ; Home Video Game Library
     
        ORG   FIRSTC
                                
        DB    "U"           ; User Cartridge Sentinel

;  On-Board ROM "SELECT GAME" Menu Data Structure
;
;     1. BRICKYARD
;     2. CLOWNS
;     3. GUNFIGHT
;     4. CHECKMATE
;     5. CALCULATOR
;     6. SCRIBBLING 
;
; Menu 1, Choice 1 - "Brickyard"
SELECT1:  DW    SELECT2       ; Link to Menu 1, Choice 2
          DW    L2DD5         ; Address of "BRICKYARD" menu text
          DW    BRICK         ; Jump here if BRICKYARD selected

; Menu 1, Choice 2 - "Clowns"
SELECT2:  DW    MENUST        ; Link to Head of "On-Board Menu"
          DW    L2DDF         ; Address of "CLOWNS" menu text
          DW    CLOWNS        ; Jump here if CLOWNS selected

;  "CHOOSE DIFFICULTY" Menu Data Structure for "Brickyard"
;  Note: "Clowns" does NOT use this menu
;
;     1. PROFESSIONAL 
;     2. ADVANCED
;     3. INTERMEDIATE
;     4. BEGINNER
;     5. CUSTOM
;       
L200D:  DW    L2013         ; Link to Menu 1, Choice 2
        DW    L2E0F         ; Address of "PROFESSIONAL" menu text
        DW    L2194         ; Jump here if PROFESSIONAL selected

L2013:  DW    L2019         ; Link to Menu 1, Choice 3
        DW    L2E1C         ; Address of "ADVANCED" menu text
        DW    L2199         ; Jump here if ADVANCED selected

L2019:  DW    L201F         ; Link to Menu 1, Choice 4
        DW    L2E25         ; Address of "INTERMEDIATE" menu text
        DW    L219E         ; Jump here if INTERMEDIATE selected

L201F:  DW    L2025         ; Link to Menu 1, Choice 5
        DW    L2E32         ; Address of "BEGINNER" menu text
        DW    L21A3         ; Jump here if BEGINNER selected

L2025:  DW    $0000         ; This is last link of "DIFFICULTY" Menu
        DW    L2E3B         ; Address of "CUSTOM" menu text
        DW    L21A8         ; Jump here if CUSTOM selected

;  "CHOOSE DIFFICULTY" Menu Data Structure
;  This is the menu that is presented to each player if "CUSTOM" is
;  selected.  This allows each player to choose a different difficulty
;  level. 
;
;     1. PROFESSIONAL 
;     2. ADVANCED
;     3. INTERMEDIATE
;     4. BEGINNER
;       
L202B:  DW    L2031         ; Link to Menu 1, Choice 2
        DW    L2E0F         ; Address of "PROFESSIONAL" menu text
        DW    L21AF         ; Jump here if PROFESSIONAL selected

L2031:  DW    L2037         ; Link to Menu 1, Choice 3
        DW    L2E1C         ; Address of "ADVANCED" menu text
        DW    L21BA         ; Jump here if ADVANCED selected
        
L2037:  DW    L203D         ; Link to Menu 1, Choice 4
        DW    L2E25         ; Address of "INTERMEDIATE" menu text
        DW    L21C5         ; Jump here if INTERMEDIATE selected

L203D:  DW    $0000         ; This is last link of Menu
        DW    L2E32         ; Address of "BEGINNER" menu text
        DW    L21D0         ; Jump here if BEGINNER selected


; Get "# of Players"
L2043:  SYSSUK  GETPAR      ;  UPI GET game parameter from user
        DW      $0228       ;  ... Prompt "# OF PLAYERS" (in System ROM)
        DB      $01         ;  ... Digits = 1
        DW      NUMPLA      ;  ... Parameter Address = 20467
;
        LD      A,(HL)
        OR      A
        JR      Z,L2043        ; Get "# of Players"
        LD      A,$04
        CP      (HL)
        JR      C,L2043        ; Get "# of Players"       
        LD      IX,CLOWVECT    ; CLOWn VECTor
        BIT     5,(IX+VBSTAT)  ; CLOWVECT+VBSTAT
        JR      NZ,L2099
        BIT     6,(IX+$07)
        JR      Z,L2090
        LD      A,(NUMPLA)     ; Number of Players
        LD      B,A
        LD      C,$00
L2069:  PUSH    HL
        LD      A,C
        INC     C
        PUSH    BC
        PUSH    AF
        LD      HL,L2D6F    ;  Base address of table 
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      HL,L202B
        POP     AF
        SYSTEM  MENU        ;  UPI display a MENU
;
L2079:  LD      BC,$0008
        LDDR    
        POP     BC
        POP     HL
        DJNZ    L2069
        LD      DE,$4FBA
        LD      HL,$4F4C
        LD      BC,$0008
        LDDR    
        LD      DE,L2E3B    ; Address of "CUSTOM" menu text
L2090:  SYSSUK  GETPAR      ;  UPI GET game PARameter from user
        DW      L2DE6       ;  ... Prompt Address "# OF BALLS"
        DB      $02         ;  ... Digits = 2
        DW      $4FCD       ;  ... Parameter Address = 20429
;
        JR      L20A0
L2099:  SYSSUK  GETPAR      ;  UPI GET game PARameter from user
        DW      L2DF1       ;  ... Prompt Address "# OF CLOWNS"
        DB      $02         ;  ... Digits = 2
        DW      $4FCD       ;  ... Parameter Address = 20429
;
;  Set-up Interrupt Vector for $2DD3
L20A0:  DI
        LD      A,$2D 
        LD      I,A          ; Load High byte of Interrupt Vector with $2D
        LD      A,$D3         
        OUT     (INFBK),A    ; Load Port $D (write INterrupt FeedBacK) with $D3
        
        IM      2
        BIT     5,(IX+$01)
        JR      NZ,L20B7
        SYSSUK  COLSET      ;  UPI COLors SET
        DW      L2D57       ;  ... Table Address = 11607
;
        JR      L20BB
L20B7:  SYSSUK  COLSET      ;  UPI COLors SET
        DW      L2D53       ;  ... Table Address = 11603
;
L20BB:  SYSTEM  INTPC       ;  UPI INTerPret with Context create
;
        DO      SETOUT      ;  UPI SET some OUTput ports
        DB      $BE         ;  ... VERBL*2 = 190
        DB      $AD         ;  ... HORCB/4 = 173
        DB      $08         ;  ... INMOD = 8
;
        DO      FILL        ;  UPI FILL memory with data
        DW      NORMEM      ;  ... Memory Address = 16384
        DW      $0ED8       ;  ... Byte Count = 3800
        DB      $00         ;  ... Data = 0
;
        DO      RECTAN      ;  UPI paint a RECTANgle
        DB      0           ;  ... X = 0
        DB      0           ;  ... Y = 0
        DB      160         ;  ... Width = 160
        DB      11          ;  ... Height = 11
        DB      $AA         ;  ... Color = 170
;
        DO      RECTAN      ;  UPI paint a RECTANgle
        DB      76          ;  ... X = 76
        DB      1           ;  ... Y = 1
        DB      9           ;  ... Width = 9
        DB      7           ;  ... Height = 7
        DB      $00         ;  ... Color = Black
;
        DONT    XINTC       ;  UPI eXit INTerpreter with Context
;
        CALL    L2912
        LD      HL,$4FDD
        LD      (HL),$15
        INC     HL
        LD      (HL),$00
        SET     2,(HL)
        LD      A,$AA
        LD      ($4FC8),A
        LD      A,$08
        OUT     (INLIN),A      ; &(15)= ; write INterrupt LINe
        LD      IX,CLOWVECT    ; CLOWn VECTor
        SET     7,(IX+VBYCHK)  ; CLOWn VECTor + VBYCHK
        LD      A,(NUMPLA)     ; Number of Players
        LD      B,A
L20F6:  PUSH    BC
        LD      HL,$4FCC
        LD      A,(HL)
        PUSH    AF
        INC     (HL)
        LD      HL,$2D22
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      BC,$0920
        LD      A,$00
        SYSTEM  RECTAN      ;  UPI paint a RECTANgle
;
        INC     D
        INC     E
        POP     AF
        LD      HL,$2D2A
        SYSTEM  INDEXB      ;  UPI INDEX Byte by A
;
        LD      C,$14
        SYSTEM  CHRDIS      ;  UPI CHaRacter DISplay
;
        POP     BC
        CALL    L2898
        DJNZ    L20F6
        LD      A,$03
        SET     1,(IX+$07)
        SET     0,(IX+$07)
        SET     5,(IX+$07)
        LD      (IX+$0C),A
        LD      B,$02
L212E:  SET     5,(IX+$00)
        SET     3,(IX+$00)
        SET     0,(IX+$01)
        INC     (IX+$02)
        LD      IX,TEETVECT   ;  TEETVECT Teeter-Totter Vector
        DJNZ    L212E
        SET     7,(IX+$01)
        RET

        
; ***************        
; *             *
; *  Brickyard  *
; *             *
; ***************

BRICK:   LD      SP,STACK
         LD      A,95*2     ; Vertinal Blank on line 95  
         OUT     (VERBL),A  ; (Port $0A) VERtical Blanking Line

;  Clear Stack
        SYSSUK  FILL        ;  UPI FILL MEMORY WITH DATA
        DW      STACK       ;  ... MEMORY ADDRESS = 20293
        DW      $0089       ;  ... BYTE COUNT = 137
        DB      $00         ;  ... DATA = 0
;
;  Get Difficulty Level from Player
        SYSSUK  MENU        ;  UPI DISPLAY A MENU
        DW      L2DFD       ;  ... TITLE ADDRESS = "CHOOSE DIFFICULTY"
        DW      L200D       ;  ... MENU LIST = 8205

;  Player has made a difficulty selection.  Depending on the
;  difficulty selected, HL holds a different value.  HL will be
;  used by LDDR as the source. 
L215C:  LD      BC,$0008    ; Counter for LDDR
        PUSH    DE          
        LD      DE,$4FBA    ; Destination
        LDDR    
        POP     DE
L2166:  CALL    L2043       ; Get "# of Players"
        LD      A,$59
        LD      (IX+$0B),A
        CALL    L2E8B
        LD      HL,L2C2D
        LD      ($4F81),HL
        LD      HL,$2D67
        LD      ($4FAC),HL
        LD      HL,$4F8F
        SET     4,(HL)
        SYSSUK  RECTAN      ;  UPI PAINT A RECTANGLE
        DB      $00         ;  ... X = 0
        DB      $0B         ;  ... Y = 11
        DB      $10         ;  ... WIDTH = 16
        DB      $55         ;  ... HEIGHT = 85
        DB      $AA         ;  ... COLOR = 170
;
        SYSSUK  RECTAN      ;  UPI PAINT A RECTANGLE
        DB      $90         ;  ... X = 144
        DB      $09         ;  ... Y = 9
        DB      $10         ;  ... WIDTH = 16
        DB      $57         ;  ... HEIGHT = 87
        DB      $AA         ;  ... COLOR = 170
;
        EI      
        JP      L2259

L2194:  LD      HL,L2D86    ; "Brickyard" Player selected "PROFESSIONAL"
        JR      L215C
L2199:  LD      HL,L2D8E    ; "Brickyard" Player selected "ADVANCED" 
        JR      L215C
L219E:  LD      HL,L2D96    ; "Brickyard" Player selected "INTERMEDIATE" 
        JR      L215C
L21A3:  LD      HL,L2D9E    ; "Brickyard" Player selected "BEGINNER" 
        JR      L215C
L21A8:  LD      HL,$4F8A    ; "Brickyard" Player selected "CUSTOM"    
        SET     6,(HL)
        JR      L2166

L21AF:  LD      HL,L2D77    ;  Base address of table
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      HL,$2D86
        JP      L2079
L21BA:  LD      HL,L2D77    ;  Base address of table
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      HL,$2D8E
        JP      L2079
L21C5:  LD      HL,L2D77    ;  Base address of table
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      HL,$2D96
        JP      L2079
L21D0:  LD      HL,L2D77    ;  Base address of table
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      HL,$2D9E
        JP      L2079


;  ***************        
;  *             *
;  *    Clowns   *
;  *             *
;  ***************

CLOWNS:  LD      SP,STACK
         LD      A,95*2     ; Vertinal Blank on line 95  
         OUT     (VERBL),A  ; (Port $0A) VERtical Blanking Line

;  Clear Stack
         SYSSUK  FILL       ;  UPI FILL MEMORY WITH DATA
         DW      STACK      ;  ... MEMORY ADDRESS = 20293
         DW      $0089      ;  ... BYTE COUNT = 137
         DB      $00        ;  ... DATA = 0

         LD      IX,CLOWVECT    ; CLOWn VECTor
         SET     5,(IX+VBSTAT)  ; CLOWn VECTor Block, STATus byte

         LD      DE,L2DDF    ; Menu Title Sting: "CLOWNS"
         CALL    L2043       ; Get "# of Players"

         LD      A,$57
         LD      (IX+VBYH),A    ; CLOWn VECTor Block, Y coord Hi
         SET     5,(IX+VBSTAT)  ; CLOWn VECTor Block, STATus byte
         LD      HL,L2DAF       ; Address of Teeter-Totter Pattern
         LD      ($4FB9),HL 
         LD      HL,L2C39
         LD      ($4F81),HL
         LD      ($4FA1),HL
         LD      HL,L2C54
         LD      ($4FA3),HL
         LD      ($4FA5),HL
         LD      HL,$2D6B
         LD      ($4FAC),HL
         LD      HL,$4FCB
         SET     5,(HL)
         LD      HL,STACK
         LD      ($4FC9),HL
         LD      HL,$2CE2
         LD      ($4FB3),HL
         LD      HL,$2CF6
         LD      ($4FB5),HL
         LD      A,$04
         LD      ($4FB7),A
         LD      A,$02
         LD      ($4FB8),A

;  Draw the Two Red Trampolines
;  ----------------------------
;  Both Trampolines are drawn at the same time.  First, a red line 
;  2 pixels high and 160 pixels across is drawn from the left to the
;  right edge of the screen.  Next a white line is drawn over the
;  middle of the red line which separates the lines into two pieces;
;  one piece is the left trampoline, the other is the right trampoline.    
;  
;  Draw a red line 160x2 across the width of the screen about 2/3 of
;  the way down the screen.
;
         SYSSUK  RECTAN     ;  UPI PAINT A RECTANGLE
         DB      0          ;  ... X = 0
         DB      72         ;  ... Y = 72
         DB      160        ;  ... WIDTH = 160
         DB      2          ;  ... HEIGHT = 2
         DB      $AA        ;  ... COLOR MASK
;
;   Draw a white line to separate the red line into two pieces.
;
         SYSSUK  RECTAN     ;  UPI PAINT A RECTANGLE
         DB      21         ;  ... X = 21
         DB      72         ;  ... Y = 72
         DB      117        ;  ... WIDTH = 117
         DB      2          ;  ... HEIGHT = 2
         DB      $00        ;  ... COLOR MASK
;
         LD      HL,$4FA9
         SET     6,(HL)     ; Set Bit 6 of $4FA9
         INC     HL
         SET     6,(HL)     ; Set Bit 6 of $4FAA
         INC     HL
         SET     6,(HL)     ; Set Bit 6 of $4FAB
         EI
               
L2259:   SYSSUK  SENTRY     ;  UPI SENSE TRANSITION
         DW      AKEYS      ;  ... KEYMASK ADDRESS = 532
;
         SYSSUK  DOIT       ;  UPI DOIT TABLE, BRANCH TO TRANSLATION HANDLER
         DW      $2D2E      ;  ... TABLE ADDRESS = 11566
;
         JR      L2259

;  Interrupt Service Routine #1
;  ----------------------------
;
ISR1:    PUSH    AF
         PUSH    BC
         PUSH    DE
         PUSH    HL
         PUSH    IX
         PUSH    IY
         LD      A,$8B
         LD      HL,$4FC8
         RLC     (HL)
         JR      C,L2276
         LD      A,$08
L2276:   OUT     (INLIN),A   ; Port $D, INterrupt LINe
         BIT     7,(HL)
         PUSH    AF
         JR      NZ,L22DF
         CALL    STIMER        ; Seconds and game TIMER, music
         LD      IX,TEETVECT   ; TEETer-totter VECTor
         BIT     5,(IX+VBSTAT) ; TEETer-Totter VECTor Block, STATus byte
         JR      NZ,L2290
         SET     0,(IX+$02)
         JR      L2296
L2290:   BIT     0,(IX+$02)
         JR      Z,L22AC
L2296:   CALL    L2B24
         LD      HL,($4FB9)
         CALL    L235D
         XOR     A
         LD      (IX+$04),A
         BIT     5,(IX+$01)
         JR      Z,L22AC
         JP      L2352
L22AC:   SET     0,(IX+$02)
L22B0:   LD      IX,CLOWVECT   ; CLOWn VECTor
         INC     (IX+VBTIMB)   ; CLOWn VECTor Block, TIMe Base
         POP     AF
         JR      NZ,L22C3
         LD      A,(IX+VBYH)   ; CLOWn VECTor Block, Y coord Hi
         CP      $45
         JR      C,L22DC
         JR      L22D6
L22C3:   BIT     6,(IX+VBYCHK) ; CLOWn VECTor Block, Y CHecK flags 
         JR      Z,L22CC
         SYSSUK  DECCTS     ;  UPI DECrement CT'S under mask
         DB      $18        ;  ... Counters = 24
;
L22CC:   LD      A,(IX+$0B)
         SET     7,(HL)
         CP      $45
         JP      NC,L2353
L22D6:   LD      HL,($4F81)
         CALL    L235D
L22DC:   JP      L2353
L22DF:   LD      HL,$4FCB
         BIT     5,(HL)
         JR      Z,L22B0
         BIT     7,(HL)
         JR      Z,L22B0
         RES     7,(HL)
         EX      DE,HL
         LD      HL,($4FC9)
         LD      A,L
         LD      B,$04
         CP      $59
         JR      C,L230F
         LD      B,$08
         CP      $6D
         JR      C,L230F
         LD      B,$0C
         CP      $81
         JR      C,L230F
         LD      B,$04
         JR      Z,L230C
         LD      HL,STACK
         JR      L230F
L230C:   LD      HL,$4F47
L230F:   LD      A,$A0
         EX      DE,HL
         AND     (HL)
         ADD     A,B
         LD      (HL),A
         NOP     
         LD      A,B
         PUSH    AF
         EX      DE,HL
         LD      B,$01
L231B:   POP     AF
         BIT     7,(HL)
         PUSH    AF
         LD      D,(HL)
         INC     HL
         JR      Z,L232D
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         LD      E,(HL)
         CALL    L293E
         POP     AF
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         PUSH    AF
L232D:   CP      $08
         JR      Z,L233B
         INC     (HL)
         LD      A,(HL)
         CP      $A0
         JR      C,L2343
         LD      (HL),$00
         JR      L2343
L233B:   DEC     (HL)
         LD      A,$00
         CP      (HL)
         JR      C,L2343
         LD      (HL),$9F
L2343:   LD      E,(HL)
         POP     AF
         PUSH    AF
         CALL    NZ,L293E
         INC     HL
         INC     HL
         INC     HL
         DJNZ    L231B
         LD      ($4FC9),HL
         POP     AF
L2352:   POP     AF
L2353:   POP     IY
         POP     IX
         POP     HL
         POP     DE
         POP     BC
         POP     AF
         EI      
         RET                 ; End of Interrupt Service Routine #1 ???     
        
L235D:   LD      A,(IX+$01)
         BIT     7,A
         RET     Z
        
         BIT     0,(IX+$0C)
         PUSH    AF
         BIT     0,A
         JR      NZ,L238F
         LD      A,$04
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         SYSTEM  VWRITR      ;  UPI Vector WRITe Relative [Teeter-Totter]
;
         POP     AF
         PUSH    AF
         BIT     5,A
         JR      Z,L238F
         POP     AF
         PUSH    AF
         PUSH    HL
         JR      Z,L238B
         LD      HL,($4FA3)
         LD      A,$04
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         SYSTEM  VWRITR     ;  UPI Vector WRITe Relative [Clown, Bottom Half]
;
         SYSSUK  DECCTS     ;  UPI DECrement CT'S under mask
         DB      $05        ;  ... Counters = 5
;
         JR      L238E
L238B:   CALL    L2548
L238E:   POP     HL
L238F:   RES     0,(IX+$01)
         EX      DE,HL
         LD      HL,($4FAC)
         SYSTEM  VECT       ;  UPI VECTor move coordinate pair
;
         POP     AF
         PUSH    AF
         PUSH    DE
         CALL    NZ,L23F1
         POP     HL
         IN      A,($08)
         LD      A,$04
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         POP     AF
         PUSH    AF
         BIT     2,A
         JR      Z,L23CF
         BIT     4,A
         JR      Z,L23C0
         LD      HL,($4FA1)
         LD      ($4F81),HL
         PUSH    HL
         LD      HL,($4FA5)
         LD      ($4FA3),HL
         XOR     A
         JR      L23C3
L23C0:   POP     AF
         PUSH    AF
         PUSH    HL
L23C3:   CALL    L2512
         RES     2,(IX+$01)
         RES     4,(IX+$01)
         POP     HL
L23CF:   SYSTEM  VWRITR     ;  UPI Vector WRITe Relative [Teeter-Totter]
;
         POP     AF
         JR      NZ,L23DA
         BIT     5,A
         CALL    NZ,L2548
         RET     


L23DA:   BIT     5,A
         JR      Z,L23E7
         LD      HL,($4FA3)
         LD      A,$04
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
         SYSTEM  VWRITR           ;  UPI Vector WRITe Relative [Clown, Upper Half]
;
L23E7:   IN      A,($08)
         OR      A
         RET     Z

         LD      HL,$4FDD
         SET     6,(HL)
         RET     

L23F1:   SYSSUK  DECCTS     ;  UPI DECrement CT'S under mask
         DB      $02        ;  ... Counters = 2
;
         LD      HL,$4FD6
         XOR     A
         CP      (HL)
         JR      NZ,L23FC
         INC     (HL)
L23FC:   LD      HL,$4F8C
         BIT     5,(IX+$01)
         JR      NZ,L2413
         CALL    L28DC
         BIT     3,(IX+$07)
         JR      Z,L2413
         LD      A,$07
         CALL    L2EA1
L2413:   BIT     3,(IX+$0C)
         RET     Z


         BIT     7,(HL)
         JP      Z,L24AF
         SET     6,(IX+$0C)
         LD      A,$60
         LD      ($4FD9),A
         XOR     A
         LD      ($4FD8),A
         LD      HL,$4F84
         SET     0,(HL)
         RES     7,(HL)
         CALL    L24BA
         LD      A,$03
         BIT     5,(HL)
         JR      NZ,L24A8
         LD      A,(NUMPLA)  ; Number of Players
         CP      $01
         JR      Z,L248A
         LD      B,A
         LD      HL,$4FCC
         LD      A,(HL)
         EX      AF,AF'
         LD      A,(HL)
         LD      C,$00
         DEC     A
         SLA     A
         LD      HL,$4FC0
         PUSH    HL
         ADD     A,L
         LD      L,A
         EX      DE,HL
         INC     DE
         POP     HL
L2456:   LD      A,(DE)
         INC     C
         INC     HL
         CP      (HL)
         JR      Z,L2480
         JR      C,L248A
L245E:   INC     HL
         DJNZ    L2456
         AND     A
         JR      Z,L248A
         LD      A,($4FBF)
         CP      $04
         JR      NC,L248A
         BIT     4,(IX+$0C)
         RES     4,(IX+$0C)
         JR      NZ,L248A
         LD      A,($4FB8)
         CP      $18
         JR      Z,L249E
L247C:   LD      A,$03
         JR      L24A8
L2480:   DEC     E
         LD      A,(DE)
         INC     E
         DEC     HL
         CP      (HL)
         INC     HL
         JR      Z,L24A2
         JR      NC,L245E
L248A:   LD      A,($4FBF)
         CP      $02
         JR      C,L247C
         BIT     7,(IX+$07)
         JR      Z,L247C
         LD      A,($4FAE)
         CP      $4F
         JR      Z,L247C
L249E:   LD      A,$05
         JR      L24A8
L24A2:   EX      AF,AF'
         CP      C
         JR      NZ,L248A
         JR      L245E
L24A8:   CALL    L2EA1
         POP     HL
         POP     HL
         POP     HL
         RET     


L24AF:   BIT     5,(IX+$01)
         RET     NZ

         LD      A,$07
         CALL    L2EA1
         RET     


L24BA:   PUSH    AF
         LD      A,($4FCD)
         CP      $01
         JR      C,L2507
         JR      NZ,L24F2
         LD      A,(NUMPLA)  ; Number of Players
         LD      B,A
         LD      A,($4FCC)
         INC     A
         CP      B
         JR      NZ,L24F2
         DEC     B
         DEC     A
         SLA     A
         LD      HL,$4FC0
         PUSH    HL
         ADD     A,L
         LD      L,A
         EX      DE,HL
         POP     HL
         INC     DE
L24DC:   LD      A,(DE)
         INC     HL
         CP      (HL)
         JR      Z,L24E8
         JR      C,L24F2
L24E3:   INC     HL
         DJNZ    L24DC
         JR      L24F4
L24E8:   DEC     DE
         DEC     HL
         LD      A,(DE)
         CP      (HL)
         INC     DE
         INC     HL
         JR      Z,L24F2
         JR      NC,L24E3
L24F2:   POP     AF
         RET     


L24F4:   LD      HL,$4FCC
         CALL    L2A8F
         SET     5,(IX+$07)
         INC     (HL)
         CALL    L2AAC
         LD      HL,$4FCD
         LD      (HL),$00
L2507:   POP     AF
         POP     AF
         POP     HL
         POP     HL
         POP     HL
         LD      A,$08
         CALL    L2EA1
         RET     


L2512:   LD      HL,$4FAE
         JR      NZ,L2539
         LD      A,(IX+$00)
         BIT     6,A
         JR      Z,L2522
         RES     6,A
         JR      L2524
L2522:   SET     6,A
L2524:   LD      (HL),A
         LD      (IX+$00),A
         CALL    L2979
         BIT     0,(IX+$0C)
         JR      NZ,L2533
         SUB     $1A
L2533:   LD      (IX+$06),A
         INC     HL
         LD      (HL),A
         RET     

        
L2539:   LD      A,(HL)
         LD      (IX+$00),A
         INC     HL
         LD      A,(HL)
         LD      (IX+$06),A
         LD      A,$4A
         LD      (IX+$0B),A
         RET  


L2548:  LD      A,$04
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
        LD      HL,L2C3B
        LD      D,$55
        LD      A,(IX+$06)
        ADD     A,$1B
        LD      E,A
        LD      A,(IX+$00)
        PUSH    AF
        PUSH    DE
;  Write Clown (Upper Half) (Is this the clown on the Teeter-Totter ???)
        SYSTEM  WRITP       ;  UPI WRITe with Pattern size lookup
;
        POP     DE
        LD      A,$04
        LD      ($0019),A
        POP     AF
        LD      HL,L2C56    ; Pattern Address
        LD      D,$5A       ; Y Coordinate
;  Write Clown (Bottom Half) (Is this the clown on the Teeter-Totter ???)
        SYSTEM  WRITP       ; UPI WRITe with Pattern size lookup
;
        RET     

        LD      IX,CLOWVECT  ; CLOWn VECTor
        DI      
        XOR     A
        BIT     5,(IX+VBSTAT)  ; CLOWn VECTor Block, STATus byte
        PUSH    AF
        PUSH    AF
        LD      D,(IX+VBYH)    ; CLOWn VECTor Block, Y coord Hi
        LD      A,$4B
        CP      D
        JR      C,L25B7
        POP     AF
        JP      Z,L266E
        BIT     7,(IX+$09)
        PUSH    AF
        LD      A,$3A
        CP      D
        JR      C,L259E
        POP     AF
        JR      NZ,L2598
        LD      HL,$0040
        LD      ($4F8B),HL
L2598:  CALL    L298C
        JP      L2683
L259E:  POP     AF
        JR      NZ,L25B4
        CALL    L298C
        LD      HL,$4FBF
        XOR     A
        CP      (HL)
        JR      Z,L25B4
        LD      HL,$4F8C
        SRA     (HL)
        DEC     HL
        LD      A,(HL)
        RRA     
        LD      (HL),A
L25B4:  POP     AF
        EI      
        RET     
       
        
L25B7:  LD      A,(IX+$06)
        LD      DE,($4F97)
        LD      E,A
        INC     D
        POP     AF
        POP     AF
        LD      HL,TEETVECT  ; Teeter-Totter Vector
        PUSH    HL
        JR      Z,L25F2
        BIT     6,(HL)
        PUSH    AF
        BIT     6,(IX+$00)
        JR      Z,L25D7
        POP     AF
        CALL    Z,L2979
        JR      L25DB
L25D7:  POP     AF
        CALL    NZ,L2979
L25DB:  LD      A,E
        INC     D
        SUB     D
        CP      $0F
        JR      C,L25EE
        CP      $E0
        JR      NC,L25EE
        LD      A,$40
        LD      (IX+$09),A
        POP     HL
        EI      
        RET     


L25EE:  SRA     A
        JR      L25FB
L25F2:  LD      A,E
        SUB     D
        INC     HL
        BIT     3,(HL)
        JR      Z,L25FB
        SRA     A
L25FB:  SRA     A
        JP      P,L2602
        LD      A,$04
L2602:  LD      HL,$4FBF
        INC     (HL)
        LD      D,A
        EX      AF,AF'
        LD      A,$02
        CP      (HL)
        PUSH    AF
        LD      HL,$4F84
        PUSH    HL
        LD      A,D
        CP      $01
        JR      NZ,L2625
        BIT     5,(HL)
        JR      NZ,L2625
        LD      DE,($4F8B)
        LD      BC,($4F86)
        POP     HL
        POP     AF
        JR      L2639
L2625:  CALL    L295E
        POP     HL
        POP     AF
        JR      NC,L2639
        EX      AF,AF'
        CALL    L2963
        LD      A,($4FB8)
        LD      ($4FA7),A
        LD      ($4FD6),A
L2639:  CALL    L2982
        CALL    L2970
        LD      HL,$4F84
        BIT     5,(HL)
        JR      NZ,L265E
        SET     0,(HL)
        CALL    L2777
        LD      HL,$4F8E
        LD      A,$57
        LD      (HL),A
        INC     HL
        BIT     5,(HL)
        RES     5,(HL)
        CALL    NZ,L2E8B
        POP     HL
        LD      A,$01
        JR      L2669
L265E:  SET     2,(HL)
        POP     HL
        INC     HL
        SET     2,(HL)
        CALL    L299B
        LD      A,$04
L2669:  CALL    L2EA1
        EI      
        RET      

        
L266E:  LD      C,$08
        LD      E,(IX+$06)
        INC     E
        LD      A,E
        AND     $F8
        CP      E
        JR      NZ,L267E
        SUB     $08
        LD      C,$10
L267E:  LD      E,A
        SET     7,(IX+$07)
L2683:  LD      HL,$2D08
        INC     D
        POP     AF
        PUSH    AF
        PUSH    BC
        PUSH    DE
        LD      B,A
        JR      Z,L2695
        INC     D
        INC     D
        INC     D
        DEC     HL
        DEC     HL
        LD      A,$04
L2695:  LD      E,A
        CALL    L28F3
        AND     A
        LD      C,$03
        JR      NZ,L26A0
        LD      C,$06
L26A0:  ADD     A,D
        SUB     $03
        POP     DE
        LD      D,A
        LD      A,B
        EX      AF,AF'
        LD      A,C
        POP     BC
        LD      B,A
        POP     AF
        PUSH    HL
        EXX     
        JR      Z,L2709
        EX      AF,AF'
        LD      B,A
        LD      C,A
        LD      HL,$4F30
        LD      DE,$4FA8
        PUSH    DE
        LD      DE,$0014
        XOR     A
L26BD:  ADD     HL,DE
        INC     A
        DJNZ    L26BD
        POP     DE
        ADD     A,E
        LD      E,A
        EX      DE,HL
        INC     (HL)
        LD      A,$09
        CP      (HL)
        JR      NC,L26DD
        LD      A,$40
        LD      (HL),A
        LD      A,$65
        LD      ($4FD7),A
        SET     6,(IX+$0C)
        LD      A,$20
        OR      C
        LD      ($4FB2),A
L26DD:  EX      DE,HL
        LD      A,(IX+$06)
        BIT     6,(IX+$00)
        CALL    NZ,L2979
        LD      D,A
        LD      E,$00
        CP      $04
        JR      NC,L26F1
        LD      C,$80
L26F1:  CALL    L28F3
        DEC     HL
        RES     7,(HL)
        ADD     A,D
        EXX     
        SUB     $03
        LD      E,A
        LD      A,D
        SUB     $04
        LD      D,A
        LD      BC,$0504
        EXX     
        CALL    L2777
        JR      L2715
L2709:  CALL    L2777
        EXX     
        CALL    L2799
        LD      (HL),$00
        EXX     
        LD      B,A
        LD      D,A
L2715:  POP     HL
        LD      A,$01
        SYSTEM  INDEXB      ;  UPI INDEX Byte by A
;
        LD      C,A
        BIT     5,(IX+$01)
        JR      NZ,L2743
        LD      A,$00
L2723:  ADD     A,C
        DAA     
        DJNZ    L2723
        LD      C,A
        LD      HL,$4FAE
        LD      A,D
        ADD     A,(HL)
        LD      (HL),A
        CP      $50
        JR      C,L2743
        SET     6,(IX+$0C)
        LD      A,$50
        OR      $03
        LD      ($4FB2),A
        SET     5,(IX+$0C)
        LD      (HL),$00
L2743:  CALL    L2898
        BIT     6,(IX+$0C)
        JR      Z,L275F
        RES     7,(IX+$01)
        CALL    L2777
        LD      A,$98
        LD      ($4FD8),A
        LD      A,$00
        CALL    L2EA1
        EI      
        RET     

        
L275F:  EXX     
        XOR     A
        SYSTEM  RECTAN      ;  UPI paint a RECTANgle
;
        LD      A,$01
        LD      ($4FD5),A
        LD      A,$02
        BIT     5,(IX+$01)
        JR      NZ,L2772
        LD      A,$06
L2772:  CALL    L2EA1
        EI      
        RET     
        
        
L2777:  LD      A,$04
        PUSH    DE
        PUSH    HL
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
        LD      HL,($4F81)
;  Write when Clown hits Balloon ???
        SYSTEM  VWRITR      ;  UPI Vector WRITe Relative [$2C4B]
;
        SET     0,(IX+$01)
        BIT     5,(IX+$01)
        JR      Z,L2796
        LD      A,$04
        LD      ($0019),A
        LD      HL,($4FA3)
        SYSTEM  VWRITR      ;  UPI Vector WRITe Relative
;
L2796:  POP     HL
        POP     DE
        RET     

        
L2799:  PUSH    BC
        PUSH    DE
        LD      HL,$4FCB
        XOR     A
        SYSTEM  RELAB1      ;  UPI RELative to non-magic ABSolute
;
        LD      A,(DE)
        AND     $FF
        JR      Z,L27A8
        SET     1,(HL)
L27A8:  INC     DE
        INC     DE
        LD      A,(DE)
        AND     $FF
        JR      Z,L27B1
        SET     2,(HL)
L27B1:  PUSH    HL
        EX      DE,HL
        LD      DE,$0078
        ADD     HL,DE
        EX      DE,HL
        POP     HL
        LD      A,(DE)
        AND     $FF
        JR      Z,L27C0
        SET     4,(HL)
L27C0:  DEC     DE
        DEC     DE
        LD      A,(DE)
        AND     $FF
        JR      Z,L27C9
        SET     3,(HL)
L27C9:  LD      A,$06
        CP      B
        PUSH    AF
        LD      A,$10
        CP      C
        JR      NZ,L282B
        POP     AF
        JR      NZ,L281D
        LD      C,$01
        LD      B,$04
        CALL    L288C
        LD      A,$03
        CP      D
        JR      NZ,$27E9
        CALL    L299B
        CALL    L298C
        JR      L27FF
        DEC     A
        CP      D
        JR      NZ,L2803
        LD      A,$18
        AND     (HL)
        JR      Z,L27F7
        LD      A,$06
        AND     (HL)
        JR      NZ,L27FC
L27F7:  CALL    L298C
        JR      L27FF
L27FC:  CALL    L299B
L27FF:  LD      A,D
        POP     DE
        POP     BC
        RET     
        
        
L2803:  BIT     7,(IX+$04)
        JR      NZ,L2813
        BIT     1,(HL)
        JR      NZ,L27F7
        BIT     3,(HL)
        JR      NZ,L27F7
        JR      L27FC
L2813:  BIT     1,(HL)
        JR      NZ,L27FC
        BIT     3,(HL)
        JR      NZ,L27FC
        JR      L27F7
L281D:  LD      C,$01
        LD      B,$02
        CALL    L288C
        LD      A,$02
        CP      D
        JR      Z,L27F7
        JR      L2803
L282B:  POP     AF
        JR      NZ,L284E
        BIT     1,(HL)
        JR      Z,L2844
        BIT     3,(HL)
        JR      Z,L283A
        LD      D,$02
        JR      L27FC
L283A:  LD      D,$01
        BIT     7,(IX+$09)
        JR      Z,L27FC
        JR      L27F7
L2844:  LD      D,$01
        BIT     7,(IX+$09)
        JR      NZ,L27FC
        JR      L27F7
L284E:  LD      D,$01
        POP     BC
        PUSH    BC
        INC     B
        LD      A,(IX+$0B)
        BIT     7,(IX+$09)
        JR      NZ,L2861
        CP      B
        JR      NC,L2864
        JR      L27F7
L2861:  CP      B
        JR      NC,L27F7
L2864:  LD      A,(IX+$06)
        INC     C
        INC     C
        BIT     7,(IX+$04)
        JR      NZ,L2874
        CP      C
        JR      C,L27FC
        JR      L287B
L2874:  INC     C
        INC     C
        INC     C
        CP      C
        JP      NC,L27FC
L287B:  LD      HL,($4F8B)
        XOR     A
        CP      H
        JP      NZ,L27F7
        LD      A,$50
        CP      L
        JP      C,L27F7
        JP      L27FC
L288C:  LD      D,$00
L288E:  SLA     C
        LD      A,(HL)
        AND     C
        JR      Z,L2895
        INC     D
L2895:  DJNZ    L288E
        RET     

        
L2898:  PUSH    IX
        PUSH    BC
        LD      A,($4FCC)
        LD      B,A
        LD      HL,$4FBE
L28A2:  INC     HL
        INC     HL
        DJNZ    L28A2
        PUSH    HL
        LD      HL,$2D1A
        DEC     A
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        POP     HL
        PUSH    DE
        LD      BC,$C428     ; 
        LD      IX,$020D     ; Small Font
        SYSTEM  DISNUM       ;  UPI DISplay NUMber
;
        POP     DE
        POP     BC
        POP     IX
        BIT     7,(IX+$0C)
        RET     NZ
        
        PUSH    BC
        PUSH    DE
        LD      E,(HL)
        INC     HL
        LD      D,(HL)
        CALL    L2908
        LD      (HL),D
        DEC     HL
        LD      (HL),E
        POP     DE
        LD      BC,$C428
        PUSH    IX
        LD      IX,$020D
        SYSTEM  DISNUM        ;  UPI DISplay NUMber
;
        POP     IX
        POP     BC
        RET     


L28DC:  BIT     7,(HL)
        JR      NZ,L28EB
        LD      A,$01
        LD      B,$00
        CP      (HL)
        RET     NC


L28E6:  LD      (HL),A
        DEC     HL
        LD      (HL),B
        INC     HL
        RET     


L28EB:  LD      A,$FE
        LD      B,$FF
        CP      (HL)
        JR      NC,L28E6
        RET     


L28F3:  LD      A,E
        INC     HL
        INC     HL
        INC     B
        SYSTEM  INDEXB      ;  UPI INDEX Byte by A
;
        SUB     D
        ADD     A,$03
        CP      $0C
        RET     C

     
        BIT     7,C
        JR      Z,L28F3
        CP      9BH
        JR      C,L28F3
        RET     


L2908:  LD      A,C
        ADD     A,E
        DAA     
        LD      E,A
        LD      A,$00
        ADC     A,D
        DAA     
        LD      D,A
        RET     
        
        
L2912:  PUSH    IX
        LD      HL,$4FCD
        LD      DE,$024D
        LD      BC,$C224
        LD      IX,$020D
        SYSTEM  DISNUM           ;  UPI DISplay NUMber
        ;
        POP     IX
        RET     
        
        
L2926:  PUSH    BC
        LD      E,$F2
        LD      B,$0A
L292B:  PUSH    AF
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
        LD      (HL),D
        INC     HL
        LD      A,$10
        ADD     A,E
        LD      (HL),A
        LD      E,A
        CALL    L293E
        INC     HL
        POP     AF
        DJNZ    L292B
        POP     BC
        RET     

        
L293E:  PUSH    DE
        PUSH    HL
        LD      A,D
        AND     $7F
        LD      D,A
        LD      A,$28
        LD      HL,L2C33    ; Balloon Pattern
        SYSTEM  WRITP       ; UPI WRITe with Pattern size lookup
;
        POP     HL
        POP     DE
        RET     


L294E:  LD      A,$04
        PUSH    HL
         OUT     (XPAND),A   ; &(25)= ; eXPANDer pixel definition port
        LD      HL,($4FB9)
        SYSTEM  VWRITR      ;  UPI Vector WRITe Relative
;
        SET     0,(IX+$01)
        POP     HL
        RET     
        
        
L295E:  LD      HL,($4FB3)
        JR      L2966
L2963:  LD      HL,($4FB5)
L2966:  SLA     A
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        INC     HL
        INC     HL
        LD      C,(HL)
        INC     HL
        LD      B,(HL)
        RET     


L2970:  LD      ($4F86),BC
        LD      ($4F8B),DE
        RET     

        
L2979:  LD      A,(IX+$06)
        SUB     $99
        NEG     
        LD      E,A
        RET     


L2982:  PUSH    AF
        LD      A,D
        CPL     
        LD      D,A
        LD      A,E
        CPL     
        LD      E,A
        INC     DE
        POP     AF
        RET     

        
L298C:  PUSH    DE
        LD      DE,($4F8B)
        CALL    L2982
        NOP     
        LD      ($4F8B),DE
        POP     DE
        RET     


L299B:  PUSH    DE
        LD      DE,($4F86)
        CALL    L2982
        LD      ($4F86),DE
        POP     DE
        RET     
        
        
        LD      IX,CLOWVECT  ; CLOWn VECTor
        DI      
        LD      HL,$4FCC
        LD      A,(NUMPLA)   ; Number of Players
        CP      $01
        JR      NZ,L29CB
        BIT     5,(IX+$07)
        CALL    NZ,L2AAC
        RES     5,(IX+$07)
        LD      A,($4FCD)
        OR      A
        JR      Z,L29E5
        JR      L29F1
L29CB:  BIT     5,(IX+$07)
        CALL    Z,L2A8F
        RES     5,(IX+$07)
        INC     (HL)
        LD      A,(NUMPLA)   ; Number of Players
        CP      (HL)
        JR      NC,L29EE
        LD      (HL),$01
        INC     HL
        LD      A,(HL)
        DEC     HL
        OR      A
        JR      NZ,L29EE
L29E5:  LD      HL,$4FDE
        SET     3,(HL)
        SYSSUK  PAWS        ;  UPI PAUSE
        DB      $35         ;  ... Interrupts = 53
;
        RET     
        
        
L29EE:  CALL    L2AAC
L29F1:  BIT     6,(IX+$07)
        LD      IX,TEETVECT  ; Teeter-Totter Vector
        JR      Z,L2A0D
        CALL    L294E
        LD      A,(HL)
        LD      HL,$2D75
        SYSTEM  INDEXW       ;  UPI INDEX Word by A
;
        LD      BC,$0008
        EX      DE,HL
        LD      DE,$4FBA
        LDDR    
L2A0D:  LD      HL,($4FB9)
        LD      BC,L2DA7
        LD      A,C
        CP      L
        RES     3,(IX+$01)
        JR      NZ,L2A1F
        SET     3,(IX+$01)
L2A1F:  BIT     5,(IX+$01)
        JR      NZ,L2A43
        LD      DE,$4C10
        EXX     
        LD      HL,($4FB7)
        LD      BC,$002A
        LD      A,C
        CP      L
        JR      Z,L2A3B
        LD      BC,$0025
        LD      DE,$FFB7
        JR      L2A4D
L2A3B:  LD      BC,$0030
        LD      DE,$FFAA
        JR      L2A4D
L2A43:  LD      DE,$3C00
        EXX     
        LD      BC,$0020
        LD      DE,$0005
L2A4D:  CALL    L2970
        LD      HL,$4FBF
        LD      (HL),$00
        EXX     
        LD      A,($4FB7)
        LD      ($4FA7),A
        LD      ($4FD6),A
        LD      IX,CLOWVECT    ; CLOWn VECTor
        SET     2,(IX+VBYCHK)  ; CLOWn VECTor Block, Y CHecK flags
        LD      A,D
        LD      (IX+VBYH),A    ; CLOWn VECTor Block, Y coord Hi
        LD      A,E
        LD      (IX+VBXH),A    ; CLOWn VECTor Block, X coord Hi
        RES     6,(IX+VBYCHK)  ; CLOWn VECTor Block, Y CHecK flags
        BIT     5,(IX+VBSTAT)  ; CLOWn VECTor Block, STATus byte
        JR      NZ,L2A8A
        BIT     5,(IX+$0C)
        RES     5,(IX+$0C)
        CALL    NZ,L2E8B
        RES     7,(IX+$07)
L2A88:  EI      
        RET     


L2A8A:  CALL    L2BAD
        JR      L2A88
L2A8F:  LD      A,(HL)
        PUSH    HL
        PUSH    AF
        LD      HL,$2D20
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      BC,$0907
        LD      A,$00
        SYSTEM  RECTAN      ;  UPI paint a RECTANgle
;
        POP     AF
        INC     D
        INC     E
        LD      HL,$2D29
        SYSTEM  INDEXB      ;  UPI INDEX Byte by A
;
        LD      C,$14
        SYSTEM  CHRDIS      ;  UPI CHaRacter DISplay
;
        POP     HL
        RET     

        
L2AAC:  LD      A,(HL)
        PUSH    HL
        PUSH    AF
        LD      HL,$2D20
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        LD      BC,$0907
        LD      A,$55
        SYSTEM  RECTAN      ;  UPI paint a RECTANgle
;
        POP     AF
        INC     D
        INC     E
        LD      HL,$2D29
        SYSTEM  INDEXB      ;  UPI INDEX Byte by A
;
        LD      C,$24
        SYSTEM  CHRDIS      ;  UPI CHaRacter DISplay
;
        LD      A,$FE
        ADD     A,E
        LD      E,A
        LD      BC,$0705
        XOR     A
        SYSTEM  RECTAN      ;  UPI paint a RECTANgle
;
        POP     HL
        RET     
        

        LD      A,$01
        JR      L2AE1
        LD      A,$02
        JR      L2AE1
        LD      A,$03
        JR      L2AE1
        LD      A,$04
L2AE1:  LD      HL,$4FCC
        CP      (HL)
        RET     NZ

        XOR     A
        CP      B
        RET     Z

        LD      IX,CLOWVECT    ; CLOWn VECTor
        BIT     2,(IX+VBYCHK)  ; CLOWn VECTor Block, Y CHecK flags
        RET     Z

        DI      
        LD      A,(NUMPLA)   ; Number of Players
        CP      (HL)
        JR      NZ,L2B05
        INC     HL
        LD      A,(HL)
        SUB     $01
        DAA     
        CALL    L2912
        LD      (HL),A
        CALL    L2912
L2B05:  SET     7,(IX+$01)
        RES     2,(IX+$0C)
        XOR     A
        LD      (IX+$02),A
        BIT     5,(IX+$01)
        JR      Z,L2B1C
        LD      A,$09
        CALL    L2EA1
L2B1C:  EI      
        RET     


        XOR     A
        CP      B
        RET     Z

        DI      
        SYSTEM  QUIT        ;  UPI QUIT cassette execution
;
L2B24:  LD      A,($4FCC)
        LD      C,$1B
        ADD     A,C
        LD      C,A
        IN      A,(C)
        LD      HL,$4FAF
        LD      E,(HL)
        SUB     E
        JR      C,L2B39
        SUB     $06
        JR      C,L2B5B
        INC     A
L2B39:  ADD     A,E
        LD      (HL),A
        BIT     6,(IX+$00)
        JR      NZ,L2B42
        CPL     
L2B42:  SRL     A
        BIT     5,(IX+$01)
        JR      NZ,L2B54
        ADD     A,$0C
        BIT     3,(IX+$01)
        JR      Z,L2B54
        SUB     $04
L2B54:  LD      D,(IX+$06)
        SUB     D
        LD      (IX+$04),A
L2B5B:  BIT     5,(IX+$01)
        RET     NZ

        LD      A,(IX+$06)
        CP      $50
        JR      NC,L2B70
        LD      A,$84
        OUT     (HORCB),A    ; &(9)= ; write HORizontal Color Boundary
        LD      HL,$2D5F
        JR      L2B77
L2B70:  LD      A,$A4
        OUT     (HORCB),A    ; &(9)= ; write HORizontal Color Boundary
        LD      HL,$2D57
L2B77:  LD      B,$08
        LD      C,$0B
        OTIR    
        RET     

        
        LD      A,$0A
        LD      ($4FD5),A
        LD      HL,$4F84
        BIT     5,(HL)
        RET     Z

        BIT     2,(HL)
        RET     NZ

        LD      HL,$2C30
        LD      DE,$0009
        CALL    L2BDA
        LD      ($4FA1),HL
        DEC     DE
        LD      HL,$2C4C
        CALL    L2BDA
        LD      ($4FA5),HL
        LD      HL,$4F84
        SET     4,(HL)
        SET     2,(HL)
        CALL    L299B
        RET     

        
L2BAD:  DI      
        LD      HL,$4FA9
        LD      B,$03
        LD      D,$81
        LD      C,D
        LD      DE,STACK
        XOR     A
L2BBA:  ADD     A,$04
        BIT     6,(HL)
        RES     6,(HL)
        EX      DE,HL
        PUSH    DE
        PUSH    AF
        JR      NZ,L2BC9
        LD      DE,$0014
        ADD     HL,DE
L2BC9:  LD      D,C
        LD      A,$0C
        ADD     A,D
        LD      D,A
        POP     AF
        CALL    NZ,L2926
        LD      C,D
        POP     DE
        EX      DE,HL
        INC     HL
        DJNZ    L2BBA
        EI      
        RET     
        

L2BDA:  SYSSUK  RANGED      ;  UPI RANGED random number
        DB      $03         ;  ... Cutoff = 3
;
        INC     A
        LD      B,A
L2BDF:  ADD     HL,DE
        DJNZ    L2BDF
        RET     


        LD      A,($4FA7)
        LD      ($4FD6),A
        LD      DE,$0020
        LD      HL,($4F8B)
        ADD     HL,DE
        LD      ($4F8B),HL
        RET     


        DB    $F3
        DB    $21
        DB    $B2
        DB    $4F
        DB    $7E
        DB    $E6
        DB    $FC
        DB    $4F
        DB    $96
        DB    $ED
        DB    $44
        DB    $06
        DB    $02
        DB    $B8
        DB    $28
        DB    $06
        DB    $30
        DB    $03
        DB    $04
        DB    $18
        DB    $01
        DB    $05
        DB    $CD
        DB    $98
        DB    $28
        DB    $10
        DB    $FB
        DB    $DD
        DB    $21
        DB    $83
        DB    $4F
        DB    $CD
        DB    $77
        DB    $27
        DB    $21
        DB    $00
        DB    $00
        DB    $22
        DB    $8B
        DB    $4F
        DB    $AF
        DB    $DD
        DB    $77
        DB    $02
        DB    $DD
        DB    $CB
        DB    $01
        DB    $FE
        DB    $DD
        DB    $CB
        DB    $0C
        DB    $B6
        DB    $C3
        DB    $5F
        DB    $27
        DB    $48
        DB    $08

;  Pattern (From Brickyard - Is it the Ball?)
L2C2D:  DB    0,0            ; X,Y Displacement
        DB    1,2            ; X,Y Size
;
        DB    11000000B ; $C0
        DB    11000000B ; $C0

;  Balloon Pattern
L2C33:  DB    1, 4           ; X, Y Size
;
        DB    01100000B ;   . X X . . . . .  
        DB    11110000B ;   X X X X . . . .  
        DB    11010000B ;   X X . X . . . .  
        DB    01100000B ;   . X X . . . . . 

; Clown Pattern (Upper Half)
; Left Arm Down, Right Arm Down
L2C39:  DB    0,0            ; X,Y Displacement
L2C3B:  DB    1,5            ; X,Y Size
;
        DB    00010000B ;   . . . X . . . .    
        DB    00000000B ;   . . . . . . . .  
        DB    01111100B ;   . X X X X X . .  
        DB    01010100B ;   . X . X . X . .  
        DB    01010100B ;   . X . X . X . .  

; Clown Pattern (Upper Half)
; Left Arm Up, Right Arm Down
L2C42:  DB    0,0            ; X,Y Displacement
        DB    1,5            ; X,Y Size
;
        DB    01010000B ;   . X . X . . . .
        DB    01000000B ;   . X . . . . . . 
        DB    01111100B ;   . X X X X X . . 
        DB    00010100B ;   . . . X . X . . 
        DB    00010100B ;   . . . X . X . . 

; Clown Pattern (Upper Half)
; Left Arm Up, Right Arm Up
L2C4B:  DB    0,0            ; X,Y Displacement
        DB    1,5            ; X,Y Size
;
        DB    01010100B ;   . X . X . X . . 
        DB    01000100B ;   . X . . . X . . 
        DB    01111100B ;   . X X X X X . . 
        DB    00010000B ;   . . . X . . . . 
        DB    00010000B ;   . . . X . . . .

; Clown Pattern (Bottom Half)
; Left Leg Down, Right Leg Down (Standing Position)
L2C54:  DB    0,5            ; X,Y Displacement
L2C56:  DB    1,4            ; X,Y Size
;
        DB    00010000B  ;  . . . X . . . .  
        DB    00111000B  ;  . . X X X . . .  
        DB    00101000B  ;  . . X . X . . .  
        DB    01101100B  ;  . X X . X X . .  
        
; Clown Pattern (Bottom Half)
; Left Leg Down, Right Leg Up
L2C5C:  DB    0,5            ; X,Y Displacement
        DB    1,4            ; X,Y Size
;        
        DB    00010010B  ;  . . . X . . X .  
        DB    00111110B  ;  . . X X X X X . 
        DB    00100000B  ;  . . X . . . . . 
        DB    01100000B  ;  . X X . . . . .

; Clown Pattern (Bottom Half)
; Left Leg Up, Right Leg Up
        DB    0,5            ; X,Y Displacement
        DB    1,2            ; X,Y Size
;
        DB    10010010B  ;  X . . X . . X . 
        DB    11111110B  ;  X X X X X X X .

        DB    $9A
        DB    $00
        DB    $AC
        DB    $FF
        DB    $00
        DB    $00
        DB    $1C
        DB    $00
        DB    $9A
        DB    $00
        DB    $54
        DB    $00
        DB    $9A
        DB    $00
        DB    $8C
        DB    $00
        DB    $9A
        DB    $00
        DB    $74
        DB    $FF
        DB    $13
        DB    $01
        DB    $83
        DB    $FF
        DB    $77
        DB    $01
        DB    $32
        DB    $00
        DB    $13
        DB    $01
        DB    $7D
        DB    $00
        DB    $13
        DB    $01
        DB    $E1
        DB    $00
        DB    $13
        DB    $01
        DB    $1F
        DB    $FF
        DB    $8C
        DB    $00
        DB    $BA
        DB    $FF
        DB    $96
        DB    $00
        DB    $14
        DB    $00
        DB    $8C
        DB    $00
        DB    $46
        DB    $00
        DB    $8C
        DB    $00
        DB    $64
        DB    $00
        DB    $8C
        DB    $00
        DB    $9C
        DB    $FF
        DB    $C0
        DB    $00
        DB    $90
        DB    $FF
        DB    $F0
        DB    $00
        DB    $20
        DB    $00
        DB    $C0
        DB    $00
        DB    $70
        DB    $00
        DB    $B0
        DB    $00
        DB    $90
        DB    $00
        DB    $B0
        DB    $00
        DB    $70
        DB    $FF
        DB    $A9
        DB    $00
        DB    $A5
        DB    $FF
        DB    $C3
        DB    $00
        DB    $1A
        DB    $00
        DB    $A9
        DB    $00
        DB    $5B
        DB    $00
        DB    $9C
        DB    $00
        DB    $82
        DB    $00
        DB    $9C
        DB    $00
        DB    $7E
        DB    $FF
        DB    $E7
        DB    $00
        DB    $6D
        DB    $FF
        DB    $3B
        DB    $01
        DB    $2A
        DB    $00
        DB    $E7
        DB    $00
        DB    $93
        DB    $00
        DB    $E7
        DB    $00
        DB    $BD
        DB    $00
        DB    $E7
        DB    $00
        DB    $43
        DB    $FF
        DB    $80
        DB    $01
        DB    $40
        DB    $FF
        DB    $80
        DB    $01
        DB    $20
        DB    $00
        DB    $80
        DB    $01
        DB    $C0
        DB    $00
        DB    $60
        DB    $01
        DB    $00
        DB    $01
        DB    $60
        DB    $01
        DB    $00
        DB    $FF
        DB    $58
        DB    $02
        DB    $D4
        DB    $FE
        DB    $58
        DB    $02
        DB    $32
        DB    $00
        DB    $58
        DB    $02
        DB    $2C
        DB    $01
        DB    $26
        DB    $02
        DB    $90
        DB    $01
        DB    $26
        DB    $02
        DB    $70
        DB    $FE
        DB    $0E
        DB    $05
        DB    $11
        DB    $05
        DB    $14
        DB    $05
        DB    $17
        DB    $05
        DB    $1D
        DB    $03
        DB    $20
        DB    $03
        DB    $23
        DB    $03
        DB    $29
        DB    $01
        DB    $34
        DB    $02
        DB    $66
        DB    $02
        DB    $0D
        DB    $02
        DB    $8D
        DB    $02
        DB    $27
        DB    $00
        DB    $59
        DB    $00
        DB    $00
        DB    $00
        DB    $80
        DB    $00
        DB    $31
        DB    $32
        DB    $33
        DB    $34
        DB    $41
        DB    $7E
        DB    $2B
        DB    $42
        DB    $E3
        DB    $2B
        DB    $43
        DB    $AD
        DB    $2B
        DB    $44
        DB    $F4
        DB    $2B
        DB    $45
        DB    $A9
        DB    $29
        DB    $47
        DB    $6D
        DB    $25
        DB    $4C
        DB    $1E
        DB    $2B
        DB    $54
        DB    $D3
        DB    $2A
        DB    $56
        DB    $D7
        DB    $2A
        DB    $58
        DB    $DB
        DB    $2A
        DB    $5A
        DB    $DF
        DB    $2A
        DB    $93
        DB    $2B
        DB    $2C
        DB    $C0
        
; Color Table
L2D53:  DB    $B5           ; COL3L - Green
        DB    $52           ; COL2L - Red
        DB    $F8           ; COL1L - Blue
        DB    $07           ; COL0L - White
; Color Table       
L2D57:  DB    $B5           ; COL3R - Green
        DB    $52           ; COL2R - Red
        DB    $F8           ; COL1R - Blue
        DB    $77           ; COL0R - Beige/Yellow
        
        DB    $52
        DB    $52
        DB    $F8
        DB    $77
        DB    $52
        DB    $52
        DB    $F8
        DB    $77
        DB    $B5
        DB    $52
        DB    $F8
        DB    $77
        DB    $10
        DB    $8E
        DB    $0B
        DB    $5D
        DB    $00
        DB    $98
        DB    $0B
        DB    $57

;  Base Address of Table
L2D6F:  DW    L2E4B     ; "PLAYER 1 CHOOSE"
        DW    L2E5B     ; "PLAYER 2 CHOOSE"
        DW    L2E6B     ; "PLAYER 3 CHOOSE"
        DW    $2E7B     ; "PLAYER 4 CHOOSE"

;  Base Address of Table
L2D77:  DW    $4F4C
        DW    $4F54
        DW    $4F5C
        DW    $4F64
        DB    $6A
        DB    $2C
        DB    $7E
        DB    $2C
        DB    $2A
        DB    $0F
        DB    $9F

L2D86:  DB    $2D
        DB    $BA
        DB    $2C
        DB    $CE
        DB    $2C
        DB    $2A
        DB    $10
        DB    $9F

L2D8E:  DB    $2D
        DB    $6A
        DB    $2C
        DB    $7E
        DB    $2C
        DB    $2A
        DB    $0F
        DB    $A7

L2D96:  DB    $2D
        DB    $92
        DB    $2C
        DB    $A6
        DB    $2C
        DB    $39
        DB    $18
        DB    $A7

L2D9E:  DB    $2D
        DB    $00
        DB    $00
        DB    $02
        DB    $02
        DB    $FF
        DB    $80
        DB    $FF

        DB    $80

;  Paddle Pattern (From Brickyard)
L2DA7   DB    $0,0              ; X,Y Displacement
        DB    2,2               ; X,Y Size   
        DB    $FF,$FE ; 11111111B,11111110B 
        DB    $FF,$FE ; 11111111B,11111110B 

;  Teeter-Totter Pattern
;  x x x x . . . . . . . . . . . . . . . . . . . . . . . . . . . .
;  . . . . x x x x . . . . . . . . . . . . . . . . . . . . . . . .
;  . . . . . . . . x x x x . . . . . . . . . . . . . . . . . . . .
;  . . . . . . . . . . . . x x x x . . . . . . . . . . . . . . . .
;  . . . . . . . . . . . . . . . . x x x x . . . . . . . . . . . .
;  . . . . . . . . . . . . . . . x x . . . x x x x . . . . . . . .
;  . . . . . . . . . . . . . . x x x x . . . . . . x x x x . . . .
;  . . . . . . . . . . . . . x x x x x x . . . . . . . . . x x x x
;
L2DAF:  DB    $0,0              ; X,Y Displacement
        DB    4,8               ; X,Y Size
;
        DB    $F0,$00,$00,$00
        DB    $0F,$00,$00,$00
        DB    $00,$F0,$00,$00
        DB    $00,$0F,$00,$00
        DB    $00,$00,$F0,$00
        DB    $00,$01,$8F,$00
        DB    $00,$03,$C0,$F0
        DB    $00,$07,$E0,$0F

;  Screen INTerrupt VECtor
L2DD3:  DW    ISR1           ; Pointer to Interrupt Service Routine #1 

; *******************
; *                 *
; *  Text Messages  *
; *                 *
; *******************

L2DD5:  DB    "BRICKYARD",0
L2DDF:  DB    "CLOWNS",0
L2DE6:  DB    "# OF BALLS",0
L2DF1:  DB    "# OF CLOWNS",0
L2DFD:  DB    "CHOOSE DIFFICULTY",0        
L2E0F:  DB    "PROFESSIONAL",0
L2E1C:  DB    "ADVANCED",0
L2E25:  DB    "INTERMEDIATE",0           
L2E32:  DB    "BEGINNER",0        
L2E3B:  DB    "CUSTOM",0
        DB    "HANDICAP",0
L2E4B:  DB    "PLAYER 1 CHOOSE",0        
L2E5B:  DB    "PLAYER 2 CHOOSE",0
L2E6B:  DB    "PLAYER 3 CHOOSE",0
L2E7B:  DB    "PLAYER 4 CHOOSE",0
        
L2E8B:  SYSSUK  RECTAN      ;  UPI paint a RECTANgle
        DB      $10         ;  ... X = 16
        DB      $11         ;  ... Y = 17
        DB      $80         ;  ... Width = 128
        DB      $09         ;  ... Height = 9
        DB      $55         ;  ... Color = 85
;
        SYSSUK  RECTAN      ;  UPI paint a RECTANgle
        DB      $10         ;  ... X = 16
        DB      $14         ;  ... Y = 20
        DB      $80         ;  ... Width = 128
        DB      $03         ;  ... Height = 3
        DB      $AA         ;  ... Color = 170
;
        SYSSUK  RECTAN      ;  UPI paint a RECTANgle
        DB      $10         ;  ... X = 16
        DB      $20         ;  ... Y = 32
        DB      $80         ;  ... Width = 128
        DB      $06         ;  ... Height = 6
        DB      $FF         ;  ... Color = 255
;
        RET

;  Play Sound Effects and/or Music
L2EA1:  PUSH    AF
        PUSH    BC
        PUSH    DE
        PUSH    HL
        PUSH    IX
        LD      HL,L2EBC    ;  Music Score Lookup Table 
        SYSTEM  INDEXW      ;  UPI INDEX Word by A
;
        EX      DE,HL       ; HL Holds Score Address
        LD      A,$C0       ; ... Voices = 11000000B (ON VOICE A)
        LD      IX,$4FBF    ; ... Music Stack
        SYSTEM  BMUSIC      ;  UPI Begin playing MUSIC
;
        POP     IX
        POP     HL
        POP     DE
        POP     BC
        POP     AF
        RET     

;  Music Score Lookup Table
L2EBC:  DW      SCORE0       ; Music Score 0
        DW      SCORE1       ; Music Score 1
        DW      SCORE2       ; Music Score 2
        DW      SCORE3       ; Music Score 3
        DW      SCORE4       ; Music Score 4
        DW      SCORE5       ; Music Score 5
        DW      SCORE6       ; Music Score 6
        DW      SCORE7       ; Music Score 7
        DW      SCORE8       ; Music Score 8
        DW      SCORE9        ; Music Score 9

;  All of these scores were disassembled using Richard Degler's 
;  "Music 1-note.LUA" script for the DZ80 disassembler. 

;  Music Score 0
SCORE0: MASTER  OA3          ;  SET TONMO TO $23
        VOLUME  $0F,$00      ;  VA = 15, VB = 0, VC= 0, NM = 0
        NOTE1   $10, E2
        NOTE1   $18, G2
        NOTE1   $08, E2
        NOTE1   $10, F2
        NOTE1   $20, G2
        REST    $10
        NOTE1   $10, E2
        NOTE1   $18, G2
        NOTE1   $08, E2
        NOTE1   $10, F2
        NOTE1   $20, G2
        QUIET   
 
;  Music Score 1
SCORE1: MASTER  OA3          ;  SET TONMO TO $23
        VOLUME  $0F,$00      ;  VA = 15, VB = 0, VC= 0, NM = 0
        NOTE1   $04, C3
        QUIET   

;  Music Score 2
SCORE2:  VOICEM  $01
        ; DURATION= VN=
        OUTPUT  SNDBX,$7A,$F5,$FD,$FF,$00,$FF,$3F,$EF
        LEGSTA               ;  TOGGLE TO LEGATO FROM STACCATO
        VOLUME  $FF,$3F      ;  VA = 15, VB = 15, VC= 15, NM = 3
        NOTE1   $02,$EF
        VOLUME  $EE,$3E      ;  VA = 14, VB = 14, VC= 14, NM = 3
        NOTE1   $02,$8F
        VOLUME  $88,$38      ;  VA = 8, VB = 8, VC= 8, NM = 3
        NOTE1   $02,$4E
        VOLUME  $44,$34      ;  VA = 4, VB = 4, VC= 4, NM = 3
        NOTE1   $02,$48
        QUIET   

;  Music Score 4
SCORE4: MASTER  OA4          ;  set TONMO to $11
        VOLUME  $09,$00      ;  VA = 9, VB = 0, VC= 0, NM = 0
        NOTE1   $01, C1
        NOTE1   $01, D1
        NOTE1   $01, E1
        NOTE1   $01, F1
        NOTE1   $01, G1
        NOTE1   $01, A1
        NOTE1   $01, B1
        NOTE1   $01, C2
        QUIET   

;  Music Score 5
SCORE5: MASTER  OA4          ;  set TONMO to $11
        VOLUME  $09,$00      ;  VA = 9, VB = 0, VC= 0, NM = 0
        NOTE1   $12, C1
        NOTE1   $06, C1
        NOTE1   $24, F1
        NOTE1   $12, C1
        NOTE1   $06, F1
        NOTE1   $24, A1
        QUIET   

;  Music Score 6
SCORE6: VOICEM  $01
        ; Duration= VN=
        OUTPUT  SNDBX,$7A,$F5,$FD,$FF,$00,$FF,$3F,$EF
        LEGSTA               ;  Toggle to LEGato from STAccato
        VOLUME  $FF,$3F      ;  VA = 15, VB = 15, VC= 15, NM = 3
        NOTE1   $01,$EF
        VOLUME  $EE,$3E      ;  VA = 14, VB = 14, VC= 14, NM = 3
        NOTE1   $01,$8F
        VOLUME  $88,$38      ;  VA = 8, VB = 8, VC= 8, NM = 3
        NOTE1   $01,$4E
        VOLUME  $44,$34      ;  VA = 4, VB = 4, VC= 4, NM = 3
        NOTE1   $01,$48
        QUIET

;  Music Score 7
SCORE7: MASTER  OA3          ;  set TONMO to $23
        VOLUME  $07,$00      ;  VA = 7, VB = 0, VC= 0, NM = 0
        NOTE1   $03, E3
        QUIET   

;  Music Score 3
SCORE3: MASTER  OA4          ;  set TONMO to $11
        VOLUME  $09,$00      ;  VA = 9, VB = 0, VC= 0, NM = 0
        NOTE1   $0C, C1
        NOTE1   $0C, C1
        NOTE1   $0C, A0
        NOTE1   $0C, D1
        NOTE1   $18, C1
        NOTE1   $0C, A0
        QUIET   

;  Music Score 8
SCORE8: MASTER  OA4          ;  set TONMO to $11
        VOLUME  $09,$00      ;  VA = 9, VB = 0, VC= 0, NM = 0
        NOTE1   $09, G0
        NOTE1   $09, C1
        NOTE1   $09, E1
        NOTE1   $12, G1
        NOTE1   $09, E1
        NOTE1   $1B, G1
        QUIET   

;  Music Score 9
SCORE9: MASTER  OA4          ;  set TONMO to $11
        VOLUME  $09,$00      ;  VA = 9, VB = 0, VC= 0, NM = 0
        NOTE1   $10,AS1
        NOTE1   $10, A1
        NOTE1   $08,GS1
        NOTE1   $08, A1
        NOTE1   $08,GS1
        NOTE1   $08, G1
        NOTE1   $10,FS1
        NOTE1   $10, F1
        NOTE1   $10, E1
        NOTE1   $10, F1
        NOTE1   $10, G1
        NOTE1   $10, F1
        NOTE1   $08, E1
        NOTE1   $08, F1
        NOTE1   $08, E1
        NOTE1   $08, F1
        NOTE1   $10,DS1
        NOTE1   $10, D1
        NOTE1   $10,CS1
        NOTE1   $10, D1
        QUIET   
        
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF
        DB     $FF, $FF, $FF, $FF,$FF, $FF, $FF, $FF                        

; End of File