*
* Mancala
* (c) California Dreams
* (k) Brutal Deluxe Software
*

* Segment 5, kind $0000

	mx	%00
	rel

	use	ALGO.X.S

*-----------------------

L050000     ENT
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05000C     ENT
            DB    $00
L05000D     ENT
            DB    $00
L05000E     ENT
            DB    $00
L05000F     ENT
            DB    $00
L050010     ENT
            DB    $00
L050011     ENT
            DB    $00
L050012     ENT
            DB    $00
L050013     ENT
            DB    $00
L050014     DB    $00
L050015     DB    $00
L050016     DB    $00
L050017     DB    $00
L050018     DB    $00
L050019     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05001F     DB    $00
L050020     DB    $00
L050021     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L050027     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05002D     DB    $00
L05002E     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05003A     DB    $00
L05003B     DB    $00
L05003C     DB    $00
L05003D     DB    $00
L05003E     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05004A     DB    $00
L05004B     DB    $00
L05004C     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L050052     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L050058     DB    $00
L050059     DB    $00
L05005A     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L050066     DB    $00
L050067     DB    $00
L050068     DB    $00
L050069     DB    $00
L05006A     DB    $00
L05006B     DB    $00
L05006C     DB    $00
L05006D     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L050079     DB    $00
L05007A     DB    $00
L05007B     DB    $00
L05007C     DB    $00
L05007D     DB    $00
L05007E     DB    $00
L05007F     DB    $00
L050080     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05008C     DB    $00
L05008D     DB    $00
L05008E     DB    $00
L05008F     DB    $00
L050090     DB    $00
L050091     DB    $00
L050092     DB    $00
L050093     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L05009F     DB    $00
L0500A0     DB    $00
L0500A1     DB    $00
L0500A2     DB    $00
L0500A3     DB    $00
L0500A4     DB    $00
L0500A5     DB    $00
L0500A6     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L0500B2     DB    $00
L0500B3     DB    $00
L0500B4     DB    $00
L0500B5     DB    $00
L0500B6     DB    $00
L0500B7     DB    $00
L0500B8     DB    $00
L0500B9     DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
            DB    $00
L0500C5     DB    $00
L0500C6     DB    $00
L0500C7     DB    $00
L0500C8     DB    $00
L0500C9     DB    $00
L0500CA     ENT
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
            LDA   L05000F
            BNE   L0500EF
            LDX   #$0C
L0500D7     LDA   L050000,X
            STA   L05002E,X
            DEX
            BPL   L0500D7
            LDA   L05000D
            STA   L05003B
            LDA   L05000E
            STA   L05003C
            JMP   L05011D

L0500EF     LDY   #$0B
            LDX   #$05
L0500F3     LDA   L050000,Y
            STA   L05002E,X
            DEY
            DEX
            BPL   L0500F3
            LDX   #$05
            LDY   #$0B
L050101     LDA   L050000,X
            STA   L05002E,Y
            DEY
            DEX
            BPL   L050101
            LDA   L05000C
            STA   L05003A
            LDA   L05000D
            STA   L05003C
            LDA   L05000E
            STA   L05003B
L05011D     LDA   #$FF
            LDX   #$05
L050121     STA   L050027,X
            STA   L050019,X
            DEX
            BPL   L050121
            LDA   #$00
            LDX   #$0B
L05012E     CLC
            ADC   L050000,X
            DEX
            BPL   L05012E
            LDX   #$00
            CMP   #$23
            BCC   L05013D
            LDX   #$01
L05013D     STX   L05003D
            LDX   #$05
            STX   L050059
            LDA   #$80
L050147     STA   L05004C,X
            STA   L050052,X
            DEX
            BPL   L050147
            LDA   #$00
            STA   L05004B
            LDA   L050010
            BEQ   L05017A
            CMP   #$01
            BNE   L05016C
            LDX   #$0C
L050160     LDA   L05002E,X
            STA   L05005A,X
            DEX
            BPL   L050160
            JMP   L050384

L05016C     LDX   #$0C
L05016E     LDA   L05002E,X
            STA   L050080,X
            DEX
            BPL   L05016E
            JMP   L0505AD

L05017A     LDA   L050010
            CMP   #$00
            BNE   L05018D
            PLB
            PLP
            JSL   L012E63
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
L05018D     LDX   L050059
            LDA   L05002E,X
            BNE   L050198
            JMP   L050DB4

L050198     LDX   #$0C
L05019A     LDA   L05002E,X
            STA   L05003E,X
            DEX
            BNE   L05019A
            LDA   L05002E
            STA   L05003E
            LDX   L050059
            LDY   L05002E,X
            LDA   #$00
            STA   L05003E,X
            LDA   L05003A
            BNE   L0501CC
L0501B9     DEX
            BPL   L0501BE
            LDX   #$0B
L0501BE     CPX   L050059
            BEQ   L0501B9
            INC   L05003E,X
            DEY
            BNE   L0501B9
            JMP   L0501DE

L0501CC     INX
            CPX   #$0C
            BNE   L0501D3
            LDX   #$00
L0501D3     CPX   L050059
            BEQ   L0501CC
            INC   L05003E,X
            DEY
            BNE   L0501CC
L0501DE     CMP   #$00
            BEQ   L0501E7
            LDA   #$00
            JMP   L0501E9

L0501E7     LDA   #$01
L0501E9     STA   L050014
            LDY   #$00
            LDA   L050059
            CMP   #$06
            BMI   L05021F
            CPX   #$06
            BPL   L050248
L0501F9     LDA   L05003E,X
            CMP   #$02
            BEQ   L050205
            CMP   #$03
            BNE   L050248
            INY
L050205     INY
            INY
            LDA   #$00
            STA   L05003E,X
            LDA   L050014
            BNE   L050217
            DEX
            BPL   L0501F9
            JMP   L050248

L050217     INX
            CPX   #$06
            BMI   L0501F9
            JMP   L050248

L05021F     CPX   #$06
            BMI   L050248
L050223     LDA   L05003E,X
            CMP   #$02
            BEQ   L05022F
            CMP   #$03
            BNE   L050248
            INY
L05022F     INY
            INY
            LDA   #$00
            STA   L05003E,X
            LDA   L050014
            BNE   L050243
            DEX
            CPX   #$06
            BMI   L050248
            JMP   L050223

L050243     INX
            CPX   #$0C
            BNE   L050223
L050248     STY   L050058
            LDA   #$00
            CMP   L050011
            BEQ   L050268
            CPY   #$00
            BEQ   L050268
            LDA   L05004A
            BEQ   L050263
            LDA   #$00
            STA   L05004A
            JMP   L050268

L050263     LDA   #$01
            STA   L05004A
L050268     LDX   #$05
            LDY   #$00
L05026C     LDA   L05003E,X
            BEQ   L050272
            INY
L050272     DEX
            BPL   L05026C
            LDX   #$0B
L050277     LDA   L05003E,X
            BEQ   L05027D
            DEY
L05027D     DEX
            CPX   #$06
            BPL   L050277
            LDX   L050059
            TYA
            STA   L050027,X
            LDA   L050058
            STA   L050019,X
            LDA   #$80
            STA   L050068
            STA   L050069
            LDA   #$00
            STA   L050067
            LDA   #$0B
            STA   L05006A
            LDA   #$05
            STA   L05006B
L0502A6     LDX   L05006A
            LDA   L05003E,X
            BNE   L0502B4
            INC   L050067
            JMP   L050D68

L0502B4     LDX   #$0C
L0502B6     LDA   L05003E,X
            STA   L05005A,X
            DEX
            BNE   L0502B6
            LDA   L05003E
            STA   L05005A
            LDX   L05006A
            LDY   L05003E,X
            LDA   #$00
            STA   L05005A,X
            LDA   L05004A
            BNE   L0502E8
L0502D5     DEX
            BPL   L0502DA
            LDX   #$0B
L0502DA     CPX   L05006A
            BEQ   L0502D5
            INC   L05005A,X
            DEY
            BNE   L0502D5
            JMP   L0502FA

L0502E8     INX
            CPX   #$0C
            BNE   L0502EF
            LDX   #$00
L0502EF     CPX   L05006A
            BEQ   L0502E8
            INC   L05005A,X
            DEY
            BNE   L0502E8
L0502FA     CMP   #$00
            BEQ   L050303
            LDA   #$00
            JMP   L050305

L050303     LDA   #$01
L050305     STA   L050014
            LDY   #$00
            LDA   L05006A
            CMP   #$06
            BMI   L05033B
            CPX   #$06
            BPL   L050364
L050315     LDA   L05005A,X
            CMP   #$02
            BEQ   L050321
            CMP   #$03
            BNE   L050364
            INY
L050321     INY
            INY
            LDA   #$00
            STA   L05005A,X
            LDA   L050014
            BNE   L050333
            DEX
            BPL   L050315
            JMP   L050364

L050333     INX
            CPX   #$06
            BMI   L050315
            JMP   L050364

L05033B     CPX   #$06
            BMI   L050364
L05033F     LDA   L05005A,X
            CMP   #$02
            BEQ   L05034B
            CMP   #$03
            BNE   L050364
            INY
L05034B     INY
            INY
            LDA   #$00
            STA   L05005A,X
            LDA   L050014
            BNE   L05035F
            DEX
            CPX   #$06
            BMI   L050364
            JMP   L05033F

L05035F     INX
            CPX   #$0C
            BNE   L05033F
L050364     STY   L05006C
            LDA   #$00
            CMP   L050011
            BEQ   L050384
            CPY   #$00
            BEQ   L050384
            LDA   L050066
            BEQ   L05037F
            LDA   #$00
            STA   L050066
            JMP   L050384

L05037F     LDA   #$01
            STA   L050066
L050384     LDA   #$80
            STA   L05007C
            STA   L05007D
            LDA   #$00
            STA   L05007A
            STA   L05007B
            LDA   #$05
            STA   L05007E
L050399     LDA   L050010
            CMP   #$01
            BNE   L0503AC
            PLB
            PLP
            JSL   L012E63
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
L0503AC     LDX   L05007E
            LDA   L05005A,X
            BNE   L0503BA
            INC   L05007B
            JMP   L050C94

L0503BA     LDX   #$0C
L0503BC     LDA   L05005A,X
            STA   L05006D,X
            DEX
            BNE   L0503BC
            LDA   L05005A
            STA   L05006D
            LDX   L05007E
            LDY   L05005A,X
            LDA   #$00
            STA   L05006D,X
            LDA   L050066
            BNE   L0503EE
L0503DB     DEX
            BPL   L0503E0
            LDX   #$0B
L0503E0     CPX   L05007E
            BEQ   L0503DB
            INC   L05006D,X
            DEY
            BNE   L0503DB
            JMP   L050400

L0503EE     INX
            CPX   #$0C
            BNE   L0503F5
            LDX   #$00
L0503F5     CPX   L05007E
            BEQ   L0503EE
            INC   L05006D,X
            DEY
            BNE   L0503EE
L050400     CMP   #$00
            BEQ   L050409
            LDA   #$00
            JMP   L05040B

L050409     LDA   #$01
L05040B     STA   L050014
            LDY   #$00
            LDA   L05007E
            CMP   #$06
            BMI   L050441
            CPX   #$06
            BPL   L05046A
L05041B     LDA   L05006D,X
            CMP   #$02
            BEQ   L050427
            CMP   #$03
            BNE   L05046A
            INY
L050427     INY
            INY
            LDA   #$00
            STA   L05006D,X
            LDA   L050014
            BNE   L050439
            DEX
            BPL   L05041B
            JMP   L05046A

L050439     INX
            CPX   #$06
            BMI   L05041B
            JMP   L05046A

L050441     CPX   #$06
            BMI   L05046A
L050445     LDA   L05006D,X
            CMP   #$02
            BEQ   L050451
            CMP   #$03
            BNE   L05046A
            INY
L050451     INY
            INY
            LDA   #$00
            STA   L05006D,X
            LDA   L050014
            BNE   L050465
            DEX
            CPX   #$06
            BMI   L05046A
            JMP   L050445

L050465     INX
            CPX   #$0C
            BNE   L050445
L05046A     STY   L05007F
            LDA   #$00
            CMP   L050011
            BEQ   L05048A
            CPY   #$00
            BEQ   L05048A
            LDA   L050079
            BEQ   L050485
            LDA   #$00
            STA   L050079
            JMP   L05048A

L050485     LDA   #$01
            STA   L050079
L05048A     LDA   L050010
            CMP   #$01
            BNE   L0504B8
            LDX   #$05
            LDY   #$00
L050495     LDA   L05006D,X
            BEQ   L05049B
            INY
L05049B     DEX
            BPL   L050495
            LDX   #$0B
L0504A0     LDA   L05006D,X
            BEQ   L0504A6
            DEY
L0504A6     DEX
            CPX   #$06
            BPL   L0504A0
            LDX   L05007E
            TYA
            STA   L050027,X
            LDA   L05007F
            STA   L050019,X
L0504B8     LDA   #$80
            STA   L05008E
            STA   L05008F
            LDA   #$00
            STA   L05008D
            LDA   #$0B
            STA   L050090
            LDA   #$05
            STA   L050091
L0504CF     LDX   L050090
            LDA   L05006D,X
            BNE   L0504DD
            INC   L05008D
            JMP   L050B7E

L0504DD     LDX   #$0C
L0504DF     LDA   L05006D,X
            STA   L050080,X
            DEX
            BNE   L0504DF
            LDA   L05006D
            STA   L050080
            LDX   L050090
            LDY   L05006D,X
            LDA   #$00
            STA   L050080,X
            LDA   L050079
            BNE   L050511
L0504FE     DEX
            BPL   L050503
            LDX   #$0B
L050503     CPX   L050090
            BEQ   L0504FE
            INC   L050080,X
            DEY
            BNE   L0504FE
            JMP   L050523

L050511     INX
            CPX   #$0C
            BNE   L050518
            LDX   #$00
L050518     CPX   L050090
            BEQ   L050511
            INC   L050080,X
            DEY
            BNE   L050511
L050523     CMP   #$00
            BEQ   L05052C
            LDA   #$00
            JMP   L05052E

L05052C     LDA   #$01
L05052E     STA   L050014
            LDY   #$00
            LDA   L050090
            CMP   #$06
            BMI   L050564
            CPX   #$06
            BPL   L05058D
L05053E     LDA   L050080,X
            CMP   #$02
            BEQ   L05054A
            CMP   #$03
            BNE   L05058D
            INY
L05054A     INY
            INY
            LDA   #$00
            STA   L050080,X
            LDA   L050014
            BNE   L05055C
            DEX
            BPL   L05053E
            JMP   L05058D

L05055C     INX
            CPX   #$06
            BMI   L05053E
            JMP   L05058D

L050564     CPX   #$06
            BMI   L05058D
L050568     LDA   L050080,X
            CMP   #$02
            BEQ   L050574
            CMP   #$03
            BNE   L05058D
            INY
L050574     INY
            INY
            LDA   #$00
            STA   L050080,X
            LDA   L050014
            BNE   L050588
            DEX
            CPX   #$06
            BMI   L05058D
            JMP   L050568

L050588     INX
            CPX   #$0C
            BNE   L050568
L05058D     STY   L050092
            LDA   #$00
            CMP   L050011
            BEQ   L0505AD
            CPY   #$00
            BEQ   L0505AD
            LDA   L05008C
            BEQ   L0505A8
            LDA   #$00
            STA   L05008C
            JMP   L0505AD

L0505A8     LDA   #$01
            STA   L05008C
L0505AD     LDA   #$80
            STA   L0500A2
            STA   L0500A3
            LDA   #$00
            STA   L0500A0
            STA   L0500A1
            LDA   #$05
            STA   L0500A4
L0505C2     LDA   L050010
            CMP   #$02
            BNE   L0505D5
            PLB
            PLP
            JSL   L012E63
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
L0505D5     LDX   L0500A4
            LDA   L050080,X
            BNE   L0505E3
            INC   L0500A1
            JMP   L050AAA

L0505E3     LDX   #$0C
L0505E5     LDA   L050080,X
            STA   L050093,X
            DEX
            BNE   L0505E5
            LDA   L050080
            STA   L050093
            LDX   L0500A4
            LDY   L050080,X
            LDA   #$00
            STA   L050093,X
            LDA   L05008C
            BNE   L050617
L050604     DEX
            BPL   L050609
            LDX   #$0B
L050609     CPX   L0500A4
            BEQ   L050604
            INC   L050093,X
            DEY
            BNE   L050604
            JMP   L050629

L050617     INX
            CPX   #$0C
            BNE   L05061E
            LDX   #$00
L05061E     CPX   L0500A4
            BEQ   L050617
            INC   L050093,X
            DEY
            BNE   L050617
L050629     CMP   #$00
            BEQ   L050632
            LDA   #$00
            JMP   L050634

L050632     LDA   #$01
L050634     STA   L050014
            LDY   #$00
            LDA   L0500A4
            CMP   #$06
            BMI   L05066A
            CPX   #$06
            BPL   L050693
L050644     LDA   L050093,X
            CMP   #$02
            BEQ   L050650
            CMP   #$03
            BNE   L050693
            INY
L050650     INY
            INY
            LDA   #$00
            STA   L050093,X
            LDA   L050014
            BNE   L050662
            DEX
            BPL   L050644
            JMP   L050693

L050662     INX
            CPX   #$06
            BMI   L050644
            JMP   L050693

L05066A     CPX   #$06
            BMI   L050693
L05066E     LDA   L050093,X
            CMP   #$02
            BEQ   L05067A
            CMP   #$03
            BNE   L050693
            INY
L05067A     INY
            INY
            LDA   #$00
            STA   L050093,X
            LDA   L050014
            BNE   L05068E
            DEX
            CPX   #$06
            BMI   L050693
            JMP   L05066E

L05068E     INX
            CPX   #$0C
            BNE   L05066E
L050693     STY   L0500A5
            LDA   #$00
            CMP   L050011
            BEQ   L0506B3
            CPY   #$00
            BEQ   L0506B3
            LDA   L05009F
            BEQ   L0506AE
            LDA   #$00
            STA   L05009F
            JMP   L0506B3

L0506AE     LDA   #$01
            STA   L05009F
L0506B3     LDA   L050010
            CMP   #$02
            BNE   L0506E1
            LDX   #$05
            LDY   #$00
L0506BE     LDA   L050093,X
            BEQ   L0506C4
            INY
L0506C4     DEX
            BPL   L0506BE
            LDX   #$0B
L0506C9     LDA   L050093,X
            BEQ   L0506CF
            DEY
L0506CF     DEX
            CPX   #$06
            BPL   L0506C9
            LDX   L0500A4
            TYA
            STA   L050027,X
            LDA   L0500A5
            STA   L050019,X
L0506E1     LDA   #$80
            STA   L0500B3
            STA   L0500B5
            LDA   #$00
            STA   L0500B4
            LDA   #$0B
            STA   L0500B6
            LDA   #$05
            STA   L0500B7
L0506F8     LDX   L0500B6
            LDA   L050093,X
            BNE   L050706
            INC   L0500B4
            JMP   L050994

L050706     LDX   #$0C
L050708     LDA   L050093,X
            STA   L0500A6,X
            DEX
            BNE   L050708
            LDA   L050093
            STA   L0500A6
            LDX   L0500B6
            LDY   L050093,X
            LDA   #$00
            STA   L0500A6,X
            LDA   L05009F
            BNE   L05073A
L050727     DEX
            BPL   L05072C
            LDX   #$0B
L05072C     CPX   L0500B6
            BEQ   L050727
            INC   L0500A6,X
            DEY
            BNE   L050727
            JMP   L05074C

L05073A     INX
            CPX   #$0C
            BNE   L050741
            LDX   #$00
L050741     CPX   L0500B6
            BEQ   L05073A
            INC   L0500A6,X
            DEY
            BNE   L05073A
L05074C     CMP   #$00
            BEQ   L050755
            LDA   #$00
            JMP   L050757

L050755     LDA   #$01
L050757     STA   L050014
            LDY   #$00
            LDA   L0500B6
            CMP   #$06
            BMI   L05078D
            CPX   #$06
            BPL   L0507B6
L050767     LDA   L0500A6,X
            CMP   #$02
            BEQ   L050773
            CMP   #$03
            BNE   L0507B6
            INY
L050773     INY
            INY
            LDA   #$00
            STA   L0500A6,X
            LDA   L050014
            BNE   L050785
            DEX
            BPL   L050767
            JMP   L0507B6

L050785     INX
            CPX   #$06
            BMI   L050767
            JMP   L0507B6

L05078D     CPX   #$06
            BMI   L0507B6
L050791     LDA   L0500A6,X
            CMP   #$02
            BEQ   L05079D
            CMP   #$03
            BNE   L0507B6
            INY
L05079D     INY
            INY
            LDA   #$00
            STA   L0500A6,X
            LDA   L050014
            BNE   L0507B1
            DEX
            CPX   #$06
            BMI   L0507B6
            JMP   L050791

L0507B1     INX
            CPX   #$0C
            BNE   L050791
L0507B6     STY   L0500B8
            LDA   #$00
            CMP   L050011
            BEQ   L0507D6
            CPY   #$00
            BEQ   L0507D6
            LDA   L0500B2
            BEQ   L0507D1
            LDA   #$00
            STA   L0500B2
            JMP   L0507D6

L0507D1     LDA   #$01
            STA   L0500B2
L0507D6     LDA   L05003D
            BEQ   L050800
            LDA   L0500B8
            BMI   L0507F0
            LDX   L0500B3
            BMI   L0507EA
            CMP   L0500B3
            BCC   L0507FD
L0507EA     STA   L0500B3
            JMP   L0507FD

L0507F0     LDX   L0500B3
            BPL   L0507FD
            CMP   L0500B3
            BCC   L0507FD
            STA   L0500B3
L0507FD     JMP   L050994

L050800     LDA   #$80
            STA   L0500C6
            LDA   #$00
            STA   L0500C7
            LDA   #$05
            STA   L0500C8
L05080F     LDX   L0500C8
            LDA   L0500A6,X
            BNE   L05081D
            INC   L0500C7
            JMP   L05090F

L05081D     LDX   #$0C
L05081F     LDA   L0500A6,X
            STA   L0500B9,X
            DEX
            BNE   L05081F
            LDA   L0500A6
            STA   L0500B9
            LDX   L0500C8
            LDY   L0500A6,X
            LDA   #$00
            STA   L0500B9,X
            LDA   L0500B2
            BNE   L050851
L05083E     DEX
            BPL   L050843
            LDX   #$0B
L050843     CPX   L0500C8
            BEQ   L05083E
            INC   L0500B9,X
            DEY
            BNE   L05083E
            JMP   L050863

L050851     INX
            CPX   #$0C
            BNE   L050858
            LDX   #$00
L050858     CPX   L0500C8
            BEQ   L050851
            INC   L0500B9,X
            DEY
            BNE   L050851
L050863     CMP   #$00
            BEQ   L05086C
            LDA   #$00
            JMP   L05086E

L05086C     LDA   #$01
L05086E     STA   L050014
            LDY   #$00
            LDA   L0500C8
            CMP   #$06
            BMI   L0508A4
            CPX   #$06
            BPL   L0508CD
L05087E     LDA   L0500B9,X
            CMP   #$02
            BEQ   L05088A
            CMP   #$03
            BNE   L0508CD
            INY
L05088A     INY
            INY
            LDA   #$00
            STA   L0500B9,X
            LDA   L050014
            BNE   L05089C
            DEX
            BPL   L05087E
            JMP   L0508CD

L05089C     INX
            CPX   #$06
            BMI   L05087E
            JMP   L0508CD

L0508A4     CPX   #$06
            BMI   L0508CD
L0508A8     LDA   L0500B9,X
            CMP   #$02
            BEQ   L0508B4
            CMP   #$03
            BNE   L0508CD
            INY
L0508B4     INY
            INY
            LDA   #$00
            STA   L0500B9,X
            LDA   L050014
            BNE   L0508C8
            DEX
            CPX   #$06
            BMI   L0508CD
            JMP   L0508A8

L0508C8     INX
            CPX   #$0C
            BNE   L0508A8
L0508CD     STY   L0500C9
            LDA   #$00
            CMP   L050011
            BEQ   L0508ED
            CPY   #$00
            BEQ   L0508ED
            LDA   L0500C5
            BEQ   L0508E8
            LDA   #$00
            STA   L0500C5
            JMP   L0508ED

L0508E8     LDA   #$01
            STA   L0500C5
L0508ED     LDA   L0500C9
            BMI   L050902
            LDX   L0500C6
            BMI   L0508FC
            CMP   L0500C6
            BCC   L05090F
L0508FC     STA   L0500C6
            JMP   L05090F

L050902     LDX   L0500C6
            BPL   L05090F
            CMP   L0500C6
            BCC   L05090F
            STA   L0500C6
L05090F     DEC   L0500C8
            BMI   L050917
            JMP   L05080F

L050917     LDA   L0500C7
            CMP   #$06
            BNE   L050968
            INC   L0500B4
            LDA   L0500B8
            BMI   L050936
            LDX   L0500B5
            BMI   L050930
            CMP   L0500B5
            BCC   L050943
L050930     STA   L0500B5
            JMP   L050943

L050936     LDX   L0500B5
            BPL   L050943
            CMP   L0500B5
            BCC   L050943
            STA   L0500B5
L050943     LDA   L0500B8
            BMI   L050958
            LDX   L0500B3
            BMI   L050952
            CMP   L0500B3
            BCC   L050965
L050952     STA   L0500B3
            JMP   L050965

L050958     LDX   L0500B3
            BPL   L050965
            CMP   L0500B3
            BCC   L050965
            STA   L0500B3
L050965     JMP   L050994

L050968     LDA   L0500B8
            SEC
            SBC   L0500C6
            STA   L0500B8
            LDA   L0500B8
            BMI   L050987
            LDX   L0500B3
            BMI   L050981
            CMP   L0500B3
            BCC   L050994
L050981     STA   L0500B3
            JMP   L050994

L050987     LDX   L0500B3
            BPL   L050994
            CMP   L0500B3
            BCC   L050994
            STA   L0500B3
L050994     DEC   L0500B6
            DEC   L0500B7
            BMI   L05099F
            JMP   L0506F8

L05099F     LDA   L050010
            CMP   #$02
            BNE   L0509A9
            JMP   L050A69

L0509A9     LDA   L0500B4
            CMP   #$06
            BEQ   L0509B3
            JMP   L050A3A

L0509B3     INC   L0500A0
            LDA   L0500B5
            CMP   #$80
            BNE   L0509E2
            LDA   L0500A5
            BMI   L0509D2
            LDX   L0500A3
            BMI   L0509CC
            CMP   L0500A3
            BCC   L0509DF
L0509CC     STA   L0500A3
            JMP   L0509DF

L0509D2     LDX   L0500A3
            BPL   L0509DF
            CMP   L0500A3
            BCC   L0509DF
            STA   L0500A3
L0509DF     JMP   L050A0E

L0509E2     LDA   L0500A5
            SEC
            SBC   L0500B5
            STA   L05002D
            LDA   L05002D
            BMI   L050A01
            LDX   L0500A3
            BMI   L0509FB
            CMP   L0500A3
            BCC   L050A0E
L0509FB     STA   L0500A3
            JMP   L050A0E

L050A01     LDX   L0500A3
            BPL   L050A0E
            CMP   L0500A3
            BCC   L050A0E
            STA   L0500A3
L050A0E     LDA   L0500B3
            CMP   #$80
            BNE   L050A3A
            LDA   L0500A5
            BMI   L050A2A
            LDX   L0500A2
            BMI   L050A24
            CMP   L0500A2
            BCC   L050A37
L050A24     STA   L0500A2
            JMP   L050A37

L050A2A     LDX   L0500A2
            BPL   L050A37
            CMP   L0500A2
            BCC   L050A37
            STA   L0500A2
L050A37     JMP   L050AAA

L050A3A     LDA   L0500A5
            SEC
            SBC   L0500B3
            STA   L05002D
            LDA   L05002D
            BMI   L050A59
            LDX   L0500A2
            BMI   L050A53
            CMP   L0500A2
            BCC   L050A66
L050A53     STA   L0500A2
            JMP   L050A66

L050A59     LDX   L0500A2
            BPL   L050A66
            CMP   L0500A2
            BCC   L050A66
            STA   L0500A2
L050A66     JMP   L050AAA

L050A69     LDX   L0500A4
            LDA   L0500B4
            CMP   #$06
            BNE   L050AA0
            INC   L05004B
            LDA   L0500B5
            CMP   #$80
            BNE   L050A86
            LDA   L0500A5
            STA   L05004C,X
            JMP   L050A90

L050A86     LDA   L0500A5
            SEC
            SBC   L0500B5
            STA   L05004C,X
L050A90     LDA   L0500B3
            CMP   #$80
            BNE   L050AA0
            LDA   L0500A5
            STA   L050052,X
            JMP   L050AAA

L050AA0     LDA   L0500A5
            SEC
            SBC   L0500B3
            STA   L050052,X
L050AAA     DEC   L0500A4
            BMI   L050AB2
            JMP   L0505C2

L050AB2     LDA   L050010
            CMP   #$02
            BNE   L050ABC
            JMP   L050DBC

L050ABC     LDA   L0500A1
            CMP   #$06
            BEQ   L050ACB
            LDA   L0500A0
            BNE   L050ACB
            JMP   L050B52

L050ACB     INC   L05008D
            LDA   L0500A3
            CMP   #$80
            BEQ   L050B04
            LDA   L050092
            SEC
            SBC   L0500A3
            STA   L05002D
            LDA   L05002D
            BMI   L050AF4
            LDX   L05008F
            BMI   L050AEE
            CMP   L05008F
            BCC   L050B01
L050AEE     STA   L05008F
            JMP   L050B01

L050AF4     LDX   L05008F
            BPL   L050B01
            CMP   L05008F
            BCC   L050B01
            STA   L05008F
L050B01     JMP   L050B26

L050B04     LDA   L050092
            BMI   L050B19
            LDX   L05008F
            BMI   L050B13
            CMP   L05008F
            BCC   L050B26
L050B13     STA   L05008F
            JMP   L050B26

L050B19     LDX   L05008F
            BPL   L050B26
            CMP   L05008F
            BCC   L050B26
            STA   L05008F
L050B26     LDA   L0500A2
            CMP   #$80
            BNE   L050B52
            LDA   L050092
            BMI   L050B42
            LDX   L05008E
            BMI   L050B3C
            CMP   L05008E
            BCC   L050B4F
L050B3C     STA   L05008E
            JMP   L050B4F

L050B42     LDX   L05008E
            BPL   L050B4F
            CMP   L05008E
            BCC   L050B4F
            STA   L05008E
L050B4F     JMP   L050B7E

L050B52     LDA   L050092
            SEC
            SBC   L0500A2
            STA   L05002D
            LDA   L05002D
            BMI   L050B71
            LDX   L05008E
            BMI   L050B6B
            CMP   L05008E
            BCC   L050B7E
L050B6B     STA   L05008E
            JMP   L050B7E

L050B71     LDX   L05008E
            BPL   L050B7E
            CMP   L05008E
            BCC   L050B7E
            STA   L05008E
L050B7E     DEC   L050090
            DEC   L050091
            BMI   L050B89
            JMP   L0504CF

L050B89     LDA   L050010
            CMP   #$01
            BNE   L050B93
            JMP   L050C53

L050B93     LDA   L05008D
            CMP   #$06
            BEQ   L050B9D
            JMP   L050C24

L050B9D     INC   L05007A
            LDA   L05008F
            CMP   #$80
            BNE   L050BCC
            LDA   L05007F
            BMI   L050BBC
            LDX   L05007D
            BMI   L050BB6
            CMP   L05007D
            BCC   L050BC9
L050BB6     STA   L05007D
            JMP   L050BC9

L050BBC     LDX   L05007D
            BPL   L050BC9
            CMP   L05007D
            BCC   L050BC9
            STA   L05007D
L050BC9     JMP   L050BF8

L050BCC     LDA   L05007F
            SEC
            SBC   L05008F
            STA   L05002D
            LDA   L05002D
            BMI   L050BEB
            LDX   L05007D
            BMI   L050BE5
            CMP   L05007D
            BCC   L050BF8
L050BE5     STA   L05007D
            JMP   L050BF8

L050BEB     LDX   L05007D
            BPL   L050BF8
            CMP   L05007D
            BCC   L050BF8
            STA   L05007D
L050BF8     LDA   L05008E
            CMP   #$80
            BNE   L050C24
            LDA   L05007F
            BMI   L050C14
            LDX   L05007C
            BMI   L050C0E
            CMP   L05007C
            BCC   L050C21
L050C0E     STA   L05007C
            JMP   L050C21

L050C14     LDX   L05007C
            BPL   L050C21
            CMP   L05007C
            BCC   L050C21
            STA   L05007C
L050C21     JMP   L050C94

L050C24     LDA   L05007F
            SEC
            SBC   L05008E
            STA   L05002D
            LDA   L05002D
            BMI   L050C43
            LDX   L05007C
            BMI   L050C3D
            CMP   L05007C
            BCC   L050C50
L050C3D     STA   L05007C
            JMP   L050C50

L050C43     LDX   L05007C
            BPL   L050C50
            CMP   L05007C
            BCC   L050C50
            STA   L05007C
L050C50     JMP   L050C94

L050C53     LDX   L05007E
            LDA   L05008D
            CMP   #$06
            BNE   L050C8A
            INC   L05004B
            LDA   L05008F
            CMP   #$80
            BNE   L050C70
            LDA   L05007F
            STA   L05004C,X
            JMP   L050C7A

L050C70     LDA   L05007F
            SEC
            SBC   L05008F
            STA   L05004C,X
L050C7A     LDA   L05008E
            CMP   #$80
            BNE   L050C8A
            LDA   L05007F
            STA   L050052,X
            JMP   L050C94

L050C8A     LDA   L05007F
            SEC
            SBC   L05008E
            STA   L050052,X
L050C94     DEC   L05007E
            BMI   L050C9C
            JMP   L050399

L050C9C     LDA   L050010
            CMP   #$01
            BNE   L050CA6
            JMP   L050DBC

L050CA6     LDA   L05007B
            CMP   #$06
            BEQ   L050CB5
            LDA   L05007A
            BNE   L050CB5
            JMP   L050D3C

L050CB5     INC   L050067
            LDA   L05007D
            CMP   #$80
            BEQ   L050CEE
            LDA   L05006C
            SEC
            SBC   L05007D
            STA   L05002D
            LDA   L05002D
            BMI   L050CDE
            LDX   L050069
            BMI   L050CD8
            CMP   L050069
            BCC   L050CEB
L050CD8     STA   L050069
            JMP   L050CEB

L050CDE     LDX   L050069
            BPL   L050CEB
            CMP   L050069
            BCC   L050CEB
            STA   L050069
L050CEB     JMP   L050D10

L050CEE     LDA   L05006C
            BMI   L050D03
            LDX   L050069
            BMI   L050CFD
            CMP   L050069
            BCC   L050D10
L050CFD     STA   L050069
            JMP   L050D10

L050D03     LDX   L050069
            BPL   L050D10
            CMP   L050069
            BCC   L050D10
            STA   L050069
L050D10     LDA   L05007C
            CMP   #$80
            BNE   L050D3C
            LDA   L05006C
            BMI   L050D2C
            LDX   L050068
            BMI   L050D26
            CMP   L050068
            BCC   L050D39
L050D26     STA   L050068
            JMP   L050D39

L050D2C     LDX   L050068
            BPL   L050D39
            CMP   L050068
            BCC   L050D39
            STA   L050068
L050D39     JMP   L050D68

L050D3C     LDA   L05006C
            SEC
            SBC   L05007C
            STA   L05002D
            LDA   L05002D
            BMI   L050D5B
            LDX   L050068
            BMI   L050D55
            CMP   L050068
            BCC   L050D68
L050D55     STA   L050068
            JMP   L050D68

L050D5B     LDX   L050068
            BPL   L050D68
            CMP   L050068
            BCC   L050D68
            STA   L050068
L050D68     DEC   L05006A
            DEC   L05006B
            BMI   L050D73
            JMP   L0502A6

L050D73     LDX   L050059
            LDA   L050067
            CMP   #$06
            BNE   L050DAA
            INC   L05004B
            LDA   L050069
            CMP   #$80
            BNE   L050D90
            LDA   L050058
            STA   L05004C,X
            JMP   L050D9A

L050D90     LDA   L050058
            SEC
            SBC   L050069
            STA   L05004C,X
L050D9A     LDA   L050068
            CMP   #$80
            BNE   L050DAA
            LDA   L050058
            STA   L050052,X
            JMP   L050DB4

L050DAA     LDA   L050058
            SEC
            SBC   L050068
            STA   L050052,X
L050DB4     DEC   L050059
            BMI   L050DBC
            JMP   L05017A

L050DBC     LDA   #$80
            STA   L050017
            LDX   #$05
L050DC3     LDA   L050052,X
            STA   L05002D
            STX   L050015
            LDA   L05002D
            BMI   L050DE1
            LDX   L050017
            BMI   L050DDB
            CMP   L050017
            BCC   L050DEE
L050DDB     STA   L050017
            JMP   L050DEE

L050DE1     LDX   L050017
            BPL   L050DEE
            CMP   L050017
            BCC   L050DEE
            STA   L050017
L050DEE     LDX   L050015
            DEX
            BPL   L050DC3
            LDA   L05004B
            BNE   L050DFC
            JMP   L050ED6

L050DFC     LDX   #$05
            LDA   #$80
            STA   L050016
L050E03     LDA   L05004C,X
            STA   L05002D
            STX   L050015
            LDA   L05002D
            BMI   L050E21
            LDX   L050016
            BMI   L050E1B
            CMP   L050016
            BCC   L050E2E
L050E1B     STA   L050016
            JMP   L050E2E

L050E21     LDX   L050016
            BPL   L050E2E
            CMP   L050016
            BCC   L050E2E
            STA   L050016
L050E2E     LDX   L050015
            DEX
            BPL   L050E03
            LDX   #$05
            LDY   #$00
L050E38     LDA   L05004C,X
            CMP   L050016
            BNE   L050E41
            INY
L050E41     DEX
            BPL   L050E38
            LDA   #$00
            LDX   #$0B
L050E48     CLC
            ADC   L05002E,X
            DEX
            BPL   L050E48
            CMP   #$07
            BCC   L050E9E
            LDA   L050016
            BMI   L050E64
            CLC
            ADC   L05003B
            CMP   L05003C
            BCC   L050ED6
            JMP   L050E70

L050E64     LDA   L05003C
            SEC
            SBC   L050016
            CMP   L05003B
            BCS   L050ED6
L050E70     LDA   L050017
            BMI   L050E96
            LDX   L050016
            BMI   L050E85
            SEC
            SBC   L050016
            CMP   #$03
            BCS   L050ED6
            JMP   L050E9E

L050E85     LDA   #$00
            SEC
            SBC   L050016
            CLC
            ADC   L050017
            CMP   #$03
            BCS   L050ED6
            JMP   L050E9E

L050E96     SEC
            SBC   L050016
            CMP   #$03
            BCS   L050ED6
L050E9E     STY   L050018
            PLB
            PLP
            JSL   L0400BA
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
            LDA   L050013
            AND   #$0F
L050EB2     CMP   L050018
            BCC   L050EBE
            SEC
            SBC   L050018
            JMP   L050EB2

L050EBE     TAY
            INY
            LDX   #$05
L050EC2     LDA   L05004C,X
            CMP   L050016
            BNE   L050ECD
            DEY
            BEQ   L050ED0
L050ECD     DEX
            BPL   L050EC2
L050ED0     STX   L050012
            JMP   L05113F

L050ED6     LDX   #$05
            LDY   #$00
L050EDA     LDA   L050052,X
            CMP   L050017
            BNE   L050EE3
            INY
L050EE3     DEX
            BPL   L050EDA
            STY   L050018
            CPY   #$01
            BNE   L050F00
            LDX   #$05
L050EEF     LDA   L050052,X
            CMP   L050017
            BEQ   L050EFA
            DEX
            BPL   L050EEF
L050EFA     STX   L050012
            JMP   L05113F

L050F00     LDX   #$05
L050F02     LDA   L050052,X
            CMP   L050017
            BEQ   L050F0F
            LDA   #$00
            STA   L050019,X
L050F0F     DEX
            BPL   L050F02
            LDA   #$00
            STA   L05002D
            LDX   #$05
L050F19     LDA   L050019,X
            BEQ   L050F26
            CMP   L05002D
            BCC   L050F26
            STA   L05002D
L050F26     DEX
            BPL   L050F19
            LDA   L05002D
            BEQ   L050F76
            LDX   #$05
            LDY   #$00
L050F32     LDA   L050019,X
            CMP   L05002D
            BNE   L050F3B
            INY
L050F3B     DEX
            BPL   L050F32
            STY   L050018
            PLB
            PLP
            JSL   L0400BA
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
            LDA   L050013
            AND   #$0F
L050F52     CMP   L050018
            BCC   L050F5E
            SEC
            SBC   L050018
            JMP   L050F52

L050F5E     TAY
            INY
            LDX   #$05
L050F62     LDA   L050019,X
            CMP   L05002D
            BNE   L050F6D
            DEY
            BEQ   L050F70
L050F6D     DEX
            BPL   L050F62
L050F70     STX   L050012
            JMP   L05113F

L050F76     LDA   #$FF
            LDX   #$05
L050F7A     STA   L050019,X
            STA   L050021,X
            DEX
            BPL   L050F7A
            LDX   #$05
            LDY   #$00
L050F87     LDA   L050052,X
            CMP   L050017
            BNE   L050F94
            TXA
            STA   L050021,Y
            INY
L050F94     DEX
            BPL   L050F87
            DEY
            STY   L050018
            LDA   #$00
            STA   L05001F
            LDX   L050018
            LDA   L05003A
            BNE   L050FC5
L050FA8     LDY   L050021,X
            LDA   L05002E,Y
            CMP   L050021,X
            BEQ   L050FB5
            BCS   L050FBF
L050FB5     TYA
            LDY   L05001F
            STA   L050019,Y
            INC   L05001F
L050FBF     DEX
            BPL   L050FA8
            JMP   L050FE2

L050FC5     LDY   L050021,X
            LDA   L05002E,Y
            CLC
            ADC   L050021,X
            CMP   #$05
            BEQ   L050FD5
            BCS   L050FDF
L050FD5     TYA
            LDY   L05001F
            STA   L050019,Y
            INC   L05001F
L050FDF     DEX
            BPL   L050FC5
L050FE2     DEC   L05001F
            LDA   L05001F
            BEQ   L050FEF
            BPL   L050FF8
            JMP   L0510AD

L050FEF     LDA   L050019
            STA   L050012
            JMP   L05113F

L050FF8     LDA   #$FF
            LDX   #$05
L050FFC     STA   L050021,X
            DEX
            BPL   L050FFC
            LDA   #$00
            STA   L050018
            LDA   L05003A
            BNE   L051044
            LDX   #$00
            LDA   L050019,X
            STA   L050021
            INC   L050018
            STA   L050020
L05101A     INX
            LDA   L050019,X
            TAY
            SEC
            SBC   L050020
            CMP   L05002E,Y
            BCC   L051036
            BEQ   L051036
            LDA   L050019,X
            LDY   L050018
            STA   L050021,Y
            INC   L050018
L051036     LDA   L050019,X
            STA   L050020
            CPX   L05001F
            BNE   L05101A
            JMP   L051076

L051044     LDX   L05001F
            LDA   L050019,X
            STA   L050021
            INC   L050018
            STA   L050020
L051053     DEX
            LDA   L050019,X
            TAY
            CLC
            ADC   L05002E,Y
            CMP   L050020
            BCS   L05106D
            LDA   L050019,X
            LDY   L050018
            STA   L050021,Y
            INC   L050018
L05106D     LDA   L050019,X
            STA   L050020
            TXA
            BNE   L051053
L051076     LDA   L050018
            CMP   #$01
            BNE   L051086
            LDA   L050021
            STA   L050012
            JMP   L05113F

L051086     PLB
            PLP
            JSL   L0400BA
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
            LDA   L050013
            AND   #$0F
L051097     CMP   L050018
            BCC   L0510A3
            SEC
            SBC   L050018
            JMP   L051097

L0510A3     TAX
            LDA   L050021,X
            STA   L050012
            JMP   L05113F

L0510AD     LDX   L050018
L0510B0     LDY   L050021,X
            LDA   L050027,Y
            STA   L050019,X
            DEX
            BPL   L0510B0
            LDX   L050018
            LDA   #$80
            STA   L05001F
L0510C4     LDA   L050019,X
            STA   L050020
            STX   L050015
            LDA   L050020
            BMI   L0510E2
            LDX   L05001F
            BMI   L0510DC
            CMP   L05001F
            BCC   L0510EF
L0510DC     STA   L05001F
            JMP   L0510EF

L0510E2     LDX   L05001F
            BPL   L0510EF
            CMP   L05001F
            BCC   L0510EF
            STA   L05001F
L0510EF     LDX   L050015
            DEX
            BPL   L0510C4
            LDX   L050018
            LDY   #$00
L0510FA     LDA   L050019,X
            CMP   L05001F
            BNE   L051103
            INY
L051103     DEX
            BPL   L0510FA
            STY   L050020
            PLB
            PLP
            JSL   L0400BA
            PHP
            PHB
            PHK
            PLB
            SEP   #$30
            LDA   L050013
            AND   #$0F
L05111A     CMP   L050020
            BCC   L051126
            SEC
            SBC   L050020
            JMP   L05111A

L051126     TAY
            INY
            LDX   L050018
L05112B     LDA   L050019,X
            CMP   L05001F
            BNE   L051136
            DEY
            BEQ   L051139
L051136     DEX
            BPL   L05112B
L051139     LDA   L050021,X
            STA   L050012
L05113F     LDA   L05000F
            BEQ   L05114D
            LDA   L050012
            CLC
            ADC   #$06
            STA   L050012
L05114D     REP   #$30
            PLB
            PLP
            RTL


