;
;	Disassembled by:
;		DASMx object code disassembler
;		(c) Copyright 1996-1999   Conquest Consultants
;		Version 1.30 (Oct  6 1999)
;
;       File:           nibble.bin
;       CPU:            Signetics 2650 (2650 family)
;
;$VER: 10.11.2008
;Disassembled by Amigan Software in January 2003, September 2006 and
; November 2008.
;URL:   http://www.deadwoodinc.net/amigan/
;EMail: jrj76@optusnet.com.au
;
;2650 Equates-------------------------------------------------------------
z     equ  0
eq    equ  z
p     equ  1
gt    equ  p
n     equ  2
lt    equ  n
un    equ  3
;-------------------------------------------------------------------------
	org	00000H
;
	eorz	r0
	bctr,un	L0004
;
	db	017H
;
L0004:
	lpsu
	lpsl
	ppsu	060H
	ppsl	002H
	strz	r1
        stra,r0 18FAh
        stra,r1 18FCh
L0011:
	tpsu	080H
	bcfr,eq	L0011
L0015:
	tpsu	080H
	bctr,eq	L0015
L0019:
        stra,r0 17FFh,r1
        stra,r0 19FFh,r1
        stra,r0 18FFh,r1
	bdrr,r1	L0019
	bsta,un	L009D

        lodi,r0 090H

	lodi,r1	006H
L002B:
        stra,r0 1808h,r1
	bdrr,r1	L002B
L0030:
	bsta,un	L0B5A
        loda,r0 1908h
	strz	r1
	strz	r2
	andi,r0	001H
	bcfa,eq	L004A
	andi,r1	002H
	bcfa,eq	L0080
	andi,r2	004H
	bcfa,eq	L008B
	bcta,un	L0064
;
L004A:
	bsta,un	L009D
	bsta,un	L00CB
	lodi,r0	001H
        stra,r0 18FAh
L0055:
	tpsu	080H
	bcfr,eq	L0055
	lodi,r0	0FFH
        stra,r0 1AFAh
        stra,r0 1AFBh
	bsta,un	L00B8
L0064:
        loda,r0 18FBh
	addi,r0	001H

        iori,r0 0D0H

        stra,r0 1814h
        lodr,r0 *008Ch       ;r0 = *(*(8C));
                             ;r0 = *(1AF5);
	addi,r0	001H

        iori,r0 0D0H

        stra,r0 181Dh
        loda,r0 18FAh
	bcta,eq	L07D9
	bcta,un	L0104
;
L0080:
        lodr,r0 *0065h       ;r0 = *(*(65));
                             ;r0 = *(18FB);
	addi,r0	001H
	andi,r0	003H
        strr,r0 *0065h       ;*(*(65)) = r0;
                             ;*(18FB) = r0;
	eorz	r0
	bctr,un	L0092
;
L008B:
        loda,r0 1AF5h
	addi,r0	001H
	andi,r0	007H
L0092:
        strr,r0 *008Ch        ;*(*(8C)) = r0;
                              ;*(1AF5) = r0;
	bstr,un	L009D
	eorz	r0
        stra,r0 18FAh
	bcta,un	L0055
;
L009D:
	bsta,un	L0A98
L00A0:
        lodr,r1 *008Ch       ;*(*(8C)) = r0;
                             ;*(1AF5) = r0;
	eorz	r0
	tmi,r1	001H
	bctr,eq	L00AD
        stra,r0 1A90h
        stra,r0 1A9Eh
L00AD:
	tmi,r1	002H
	bctr,eq	L00B7
        stra,r0 18A0h
        stra,r0 18AEh
L00B7:
	retc,un
;
L00B8:
	lodi,r2	0DCH
	lodi,r0	00FH
        stra,r0 18FEh
L00BF:
	bdrr,r1	L00BF
	lodz	r2
	rrr,r0
	andi,r0	07FH
        stra,r0 18FDh
	bdrr,r2	L00BF
	retc,un
;
L00CB:
	lodi,r2	0DCH
	lodi,r1	00FH
        strr,r1 *00BDh       ;*(*(BD)) = r1;
                             ;*(18FE) = r1;
L00D1:
	lodi,r3	006H
L00D3:
	bdrr,r1	L00D3
	bdrr,r3	L00D3
	lodz	r2
	andi,r0	007H
	bcfr,eq	L00E8
	lodz	r2
	rrr,r0
	rrr,r0
	rrr,r0
	andi,r0	01FH
        loda,r0 0CF0h,r0
        stra,r0 18FDh
L00E8:
	bdrr,r2	L00D1
        stra,r0 18FEh
	retc,un
;
L00EE:
	lodi,r1	008H
L00F0:
        loda,r0 0FEBh,r1
        stra,r0 18EFh,r1
	bdrr,r1	L00F0
	retc,un
;
L00F9:
	lodi,r0	001H
	lodi,r3	017H
L00FD:
        stra,r0 18E1h
        stra,r3 18E2h
	retc,un
;
L0104:
        loda,r0 1ADBh
        iora,r0 1AE0h
        iora,r0 1AE1h
        iora,r0 1AE1h
	bcfa,eq	L01BF
        loda,r3 18FBh
	tmi,r3	001H
	bctr,eq	L0130
        loda,r0 1900h
	andi,r0	00FH
	bsfa,eq	L09F7
        loda,r0 1902h
	andi,r0	00FH
	bsfa,eq	L09FB
        loda,r0 1AD9h
	bsfa,eq	L09FB
L0130:
        lodr,r3 *0114h
	tmi,r3	002H
	bcta,eq	L01BF
        lodr,r0 *013Eh
	bctr,eq	L014E
	addi,r0	0FFH
        stra,r0 1AEEh
	bctr,eq	L0173
	andi,r0	0AAH
        stra,r0 18FDh
	lodi,r0	00FH
        stra,r0 18FEh
	bctr,un	L0170
;
L014E:
        loda,r0 1901h
	andi,r0	00FH
	bcta,eq	L01BF
        loda,r0 1ADDh
	addi,r0	001H
	comi,r0	006H
	bcta,eq	L01BF
        stra,r0 1ADDh
	strz	r1
	eorz	r0
        stra,r0 1829h,r1
	lodi,r0	07FH
        strr,r0 *013Eh       ;*(*(13E)) = r0 [$7F];
                             ;*(1AEE) = r0;
	rrl,r0
        stra,r0 18F1h
L0170:
	bcta,un	L07D9
;
L0173:
        loda,r1 18F8h
L0176:
        loda,r0 0200h,r1+
	comi,r0	030H
	bctr,lt	L0176
	comi,r0	0CDH
	bctr,gt	L0176
	strz	r2
	andi,r2	00FH
	comi,r2	00FH
	bctr,eq	L0176
	strz	r2
	tmi,r2	080H
	bctr,eq	L0198
        loda,r0 1800h,r2
	bctr,eq	L01AA

        comi,r0 0FCH

	bctr,eq	L01AA
	bctr,un	L0176
;
L0198:
        loda,r0 1A00h,r2
	bctr,eq	L01A1

        comi,r0 0FCH

	bcfr,eq	L0176
L01A1:
	lodz	r2
	lodi,r2	07AH
	strz	r1
	bsta,un	L0A5A
	bctr,un	L01B1
;
L01AA:
	lodz	r2
	lodi,r2	012H
	strz	r1
	bsta,un	L0A5A
L01B1:
	andi,r0	0F8H
	iori,r0	007H
        stra,r0 18F0h
	andi,r1	0F8H
	iori,r1	003H
        stra,r1 18F1h
L01BF:
        loda,r0 18E0h
	bctr,eq	L01CA
	addi,r0	0FFH
        strr,r0 *01C0h
	bctr,un	L01DA
;
L01CA:
	lodi,r1	002H
L01CC:
        loda,r0 18E0h,r1
        stra,r0 18FCh,r1
	bdrr,r1	L01CC
        stra,r1 18E2h
        stra,r1 18E1h
L01DA:
        loda,r0 1AD9h
	bcta,eq	L022F
	comi,r0	002H
	bcta,gt	L022F
        loda,r0 18F8h
	strz	r1
	andi,r0	01FH
	bcfa,eq	L022F
	andi,r1	020H
	bcfr,eq	L0225
        loda,r0 1AE3h
	bcfr,eq	L0203
        loda,r0 18E7h
	bctr,eq	L0203
        lodr,r0 *0201h       ;r0 = *(*(201));
                             ;r0 = *(1AF7);

        iori,r0 007H         ;r0 |= %00000111;

L0200:
        stra,r0 1AF7h
L0203:
        loda,r0 1AE4h
	bcfr,eq	L0213
        loda,r0 18E8h
	bctr,eq	L0213

;The code below handles flashing of pursued ghosts

        lodr,r0 *0228h       ;r0 = *(*(228));
                             ;r0 = *(1AF6);

        iori,r0 038H         ;r0 |= %00111000;

        strr,r0 *0228h       ;*(*(228)) = r0;
                             ;*(1AF6) = r0;
L0213:
        loda,r0 1AE5h
	bcfr,eq	L0223
        loda,r0 18E9h
	bctr,eq	L0223

        lodr,r0 *0228h       ;r0 = *(*(228));
                             ;r0 = *(1AF6);

        iori,r0 007H         ;r0 |= %00000111;

        strr,r0 *0228h       ;*(*(228)) = r0;
                             ;*(1AF6) = r0;
L0223:
	bctr,un	L022F
;
L0225:

        lodi,r0 0F3H         ;r0 = %11110011;

        stra,r0 1AF6h

        lodi,r0 0E2H         ;r0 = %11100010;

        stra,r0 1AF7h
L022F:
        loda,r0 1ADBh
	bcta,eq	L02F5
	addi,r0	0FFH
        strr,r0 *0230h
	bcta,eq	L027D
	andi,r0	007H
	comi,r0	004H
	bcfr,eq	L026A
        lodr,r0 *0230h
	rrr,r0
	rrr,r0
	rrr,r0
	rrr,r0
	andi,r0	00FH
	strz	r2
        loda,r0 026Dh,r2
	bsta,un	L0ED0
	rrr,r2
	andi,r2	007H
	lodz	r2
	strz	r1
	bsta,un	L03B0
	bctr,un	L026A
;
	db	004H, 028H, 0CCH, 018H
	db	0FDH, 004H, 017H, 0CCH
	db	018H, 0FEH, 004H, 007H
	db	0CCH, 018H, 0E0H
;
L026A:
	bcta,un	L05CC
;
X026D:
	db	0A0H, 0A0H, 098H, 0A0H
	db	098H, 090H, 098H, 090H
	db	098H, 090H, 090H, 088H
	db	090H, 088H, 090H, 088H
;
L027D:
        loda,r0 1ADAh
	addi,r0	001H
        strr,r0 *027Eh
	strz	r1
        eorz    r0           ;r0 = 0;
        stra,r0 1815h,r1     ;*(1815 + r1) = r0 [0];
        comi,r1 003H
;check whether game over
	bctr,eq	L02A4
	bsta,un	L0AC7
	bsta,un	L0B5A
	bsta,un	L00B8
	bsta,un	L0B5A
	bctr,un	L02C3
;
	db	00CH, 01AH, 0DCH, 084H
	db	01EH, 0C8H, 0FAH, 01BH
	db	069H
;
L02A4:
        eorz    r0           ;r0 = 0;
        stra,r0 18FAh        ;*(18FA) = r0 [0];
        bsta,un L0FD8        ;gosub L0FD8;
        lodi,r1 000H         ;r1 = 0;
L02AD:
        loda,r0 1809h,r1
	andi,r0	03FH
	strz	r3
        loda,r0 1800h,r1
	andi,r0	03FH
	comz	r3
	bctr,gt	L02C6
	bctr,lt	L02C3
	addi,r1	001H
	comi,r1	005H
	bcfr,eq	L02AD
L02C3:
	bcta,un	L07D9
;
L02C6:
	lodi,r1	006H
L02C8:
        loda,r0 17FFh,r1
	andi,r0	03FH

        iori,r0 080H

	lodi,r2	00FH
        stra,r2 18FEh
	lodi,r3	07FH
L02D6:
	bdrr,r2	L02D6
        strr,r3 *02E0h       ;*(*(2E0)) = r3;
                             ;*(1AFE) = r3;
	andi,r3	055H
        stra,r3 18FDh
        loda,r3 1AFEh
	bdrr,r3	L02D6
        stra,r0 1808h,r1     ;*(1808 + r1) = r0;
        bdrr,r1 L02C8        ;if (--r1 != 0) goto L02C8;
        stra,r1 18FDh
	bctr,un	L02C3
;
L02EE:
        loda,r0 1AE3h,r1
        iora,r0 1AE0h,r1
	retc,un
;
L02F5:
        loda,r3 1AFBh
	andi,r3	007H
	comi,r3	007H
	bcta,eq	L038E
	tmi,r3	004H
	bctr,eq	L0313
	lodi,r1	002H
	bstr,un	L02EE
	bcfr,eq	L0313
        loda,r0 18E9h
	bcfa,eq	L037F
	lodi,r2	004H
	bctr,un	L0339
;
L0313:
	tmi,r3	002H
	bctr,eq	L0327
	lodi,r1	001H
	bstr,un	L02EE
	bcfr,eq	L0327
        loda,r0 18E8h
	bcfa,eq	L037B
	lodi,r2	002H
	bctr,un	L0339
;
L0327:
	tmi,r3	001H
	bcta,eq	L038E
	lodi,r1	000H
	bsta,un	L02EE
	bcfr,eq	L035B
        loda,r0 18E7h
	bcta,un	L0C30
;
L0339:
        loda,r0 18F3h,r2
	strz	r1
        loda,r0 18F2h,r2
        stra,r0 18ECh
        stra,r1 18EDh
	bsta,un	L0A71
        stra,r1 18EEh
        stra,r2 18EFh
        loda,r0 18F0h
        loda,r1 18F1h
	bsta,un	L0A71
        coma,r1 18EEh
L035B:
	bcfr,eq	L0375
        coma,r2 18EFh
	bcfr,eq	L0375
        loda,r0 18ECh
        loda,r1 18EDh
        stra,r1 18F1h
	addi,r0	0FBH
        stra,r0 18F0h
	lodi,r0	0FFH
        stra,r0 1ADBh
L0375:
	bctr,un	L038E
;
L0377:
	lodi,r1	000H
	bctr,un	L0381
;
L037B:
	lodi,r1	001H
	bctr,un	L0381
;
L037F:
	lodi,r1	002H
L0381:
	lodi,r0	008H
        stra,r0 1AE0h,r1
        loda,r0 1ADCh
	addi,r0	014H
        stra,r0 1ADCh
L038E:
        loda,r1 18F8h
	andi,r1	007H
	bcfa,eq	L042B
        loda,r1 1AE0h
	bcta,eq	L03C6
	addi,r1	0FFH
        strr,r1 *0397h
	bctr,eq	L03A9
	bstr,un	L03B0
	bsta,un	L0ED4
	bctr,un	L03C6
;
L03A9:
	lodi,r0	0FFH
        stra,r0 1AE3h
	bctr,un	L03C6
;
L03B0:
        loda,r0 0400h,r1
        stra,r0 18FDh
        loda,r0 0409h,r1
        stra,r0 18FEh
        loda,r0 03F7h,r1
        stra,r0 18E0h
        loda,r0 0412h,r1
	retc,un
;
L03C6:
        loda,r1 1AE1h
	bctr,eq	L03DF
	addi,r1	0FFH
        strr,r1 *03C7h
	bctr,eq	L03D8
	bstr,un	L03B0
	bsta,un	L0ED8
	bctr,un	L03DF
;
L03D8:
	lodi,r0	0FFH
        stra,r0 1AE4h
	bctr,un	L03DF
;
L03DF:
        loda,r1 1AE2h
	bctr,eq	L03EF
	addi,r1	0FFH
        strr,r1 *03E0h
	bctr,eq	L03F1
	bstr,un	L03B0
	bsta,un	L0EDC
L03EF:
	bctr,un	L042B
;
L03F1:
	lodi,r0	0FFH
        stra,r0 1AE5h
	bctr,un	L042B
;
	db	002H, 003H, 003H, 004H
	db	005H, 006H, 006H, 004H
X0400:
	db	005H, 000H, 003H, 005H
	db	00AH, 001H, 00AH, 003H
	db	002H
X0409:
	db	000H, 000H, 00FH, 00FH
	db	01FH, 01FH, 01FH, 00FH
	db	00FH
X0412:
	db	00FH, 048H, 050H, 050H
	db	058H, 058H, 060H, 060H
	db	060H
X041B:
	db	008H, 010H, 018H, 020H
	db	068H, 070H, 078H, 080H
	db	048H, 050H, 058H, 060H
	db	028H, 030H, 038H, 040H
;
L042B:
	bsta,un	L0A1D
	bcta,eq	L0473
        loda,r0 1AFCh
	lodi,r2	000H
	comi,r0	028H
	bctr,lt	L0451
	lodi,r2	004H
	comi,r0	0C0H
	bctr,gt	L0451
        loda,r0 1AFDh
	lodi,r2	006H
	comi,r0	028H
	bctr,lt	L0451
	lodi,r2	002H
	comi,r0	0C0H
	bctr,gt	L0451
	lodi,r2	008H
L0451:
	lodz	r2
	comi,r0	008H
	bctr,eq	L0465
        lodr,r1 *0466h
	comz	r1
	bctr,eq	L0468
	bsta,un	L0A34
	bctr,eq	L0465
	lodz	r3
        strr,r3 *0466h
	bctr,un	L0473
;
L0465:
        loda,r0 18EAh
L0468:
	bsta,un	L0A34
	bctr,eq	L046F
	bctr,un	L0473
;
L046F:
	lodi,r0	008H
        strr,r0 *0466h
L0473:
	eorz	r0
        lodr,r1 *0466h
	comi,r1	008H
	bctr,eq	L049D
        loda,r0 18F8h
        loda,r1 1AD9h
	bctr,eq	L048A
	andi,r0	003H
	bcfr,eq	L04C2
        lodr,r0 *047Bh
	bctr,un	L0491
;
L048A:
	andi,r0	007H
	bcfr,eq	L04C2
        lodr,r0 *047Bh
	rrr,r0
L0491:
	rrr,r0
	rrr,r0
	andi,r0	003H
        lodr,r1 *0466h
	andi,r1	006H
	rrl,r1
	iorz	r1
	andi,r0	00FH
L049D:
        loda,r0 041Bh,r0
	bsta,un	L0ED0
        loda,r0 18F8h
        loda,r1 1AD9h
	bctr,eq	L04AF
	andi,r0	003H
	bctr,un	L04B1
;
L04AF:
	andi,r0	007H
L04B1:
	bcfr,eq	L04C2
        loda,r0 18EAh
	comi,r0	008H
	bcta,eq	L0514
	lodi,r0	028H
	lodi,r3	017H
	bsta,un	L00FD
L04C2:
        loda,r0 1ADBh
	bcfa,eq	L05CC
        loda,r0 1ADEh
	addi,r0	001H
        strr,r0 *04C9h
        loda,r1 1AD9h
	bctr,eq	L04D9
        coma,r0 1AD4h
	bctr,un	L04DC
;
L04D9:
        coma,r0 1AD5h
L04DC:
	bcfa,eq	L0514
	eorz	r0
        strr,r0 *04C9h
        loda,r1 18EAh
        loda,r0 18F0h
        adda,r0 050Bh,r1
        stra,r0 18F0h
        loda,r0 18F1h
        adda,r0 0509h,r1

;check against boundaries
        comi,r0 02AH
	bctr,lt	L0505
	comi,r0	09BH
	bctr,gt	L0501
L04FC:
        stra,r0 18F1h
	bctr,un	L0514
;
L0501:
	lodi,r0	02BH
	bctr,un	L04FC
;
L0505:
	lodi,r0	09BH
	bctr,un	L04FC
;
X0509:
	db	000H, 000H
X050B:
	db	001H, 001H, 000H, 000H
	db	0FFH, 0FFH, 000H, 000H
	db	000H
;
L0514:
	bsta,un	L0A1D
	bcta,eq	L05CC
        loda,r0 18F0h
        loda,r1 18F1h
	bsta,un	L0A71
	comi,r0	0FFH
	bcta,eq	L05CC
	comi,r1	0FFH
	bcfr,eq	L0539
        loda,r0 1800h,r2
	bctr,eq	L0555
	strz	r3
	eorz	r0
        stra,r0 1800h,r2
	lodz	r3
	bctr,un	L0544
;
L0539:
        loda,r0 1A00h,r1
	bctr,eq	L0555
        strz    r3           ;r3 = r0;
        eorz    r0           ;r0 = 0;
        stra,r0 1A00h,r1     ;*(1A00 + r1) = r0 [0]; // lower screen
        lodz    r3           ;r0 = r3;
L0544:

        comi,r0 0FCH

	bctr,eq	L0558

        comi,r0 0FDH

	bcta,eq	L0593

        comi,r0 07FH

	bctr,eq	L0571

        comi,r0 0BEH

	bctr,eq	L0581
L0555:
	bcta,un	L05CC
;
L0558:
        loda,r0 18E5h
	addi,r0	001H
        strr,r0 *0559h
	lodi,r0	028H
	lodi,r3	015H
	bsta,un	L00FD
	lodi,r1	002H
L0568:
        loda,r0 1ADCh
	addz	r1
        strr,r0 *0569h
	bcta,un	L05CC
;
L0571:
	lodi,r0	01EH
	lodi,r3	00FH
	bsta,un	L00FD
	lodi,r0	006H
        stra,r0 18E0h
	lodi,r1	032H
	bctr,un	L0568
;
L0581:
	lodi,r0	014H
	lodi,r3	00FH
	bsta,un	L00FD
	lodi,r0	007H
        stra,r0 18E0h
	lodi,r1	064H
	bctr,un	L0568
;
	db	01BH, 07EH
;
L0593:
	lodi,r0	0FFH
	lodi,r1	003H
L0597:
        stra,r0 18E6h,r1
	bdrr,r1	L0597
	lodi,r0	005H
        suba,r0 1AEFh
        stra,r0 1AD9h
	lodi,r0	001H
	lodi,r3	00FH
	bsta,un	L00FD

;The code below handles whitening of pursued ghosts

        lodi,r0 0FFH         ;r0 = %11111111;

        stra,r0 1AF6h

        lodi,r0 0E7H         ;r0 = %11100111;

        stra,r0 1AF7h
	lodi,r1	014H
	bcta,un	L0568
;
X05BA:
	db	068H, 070H, 078H, 080H
X05BE:
	db	088H, 090H, 098H, 0A0H
;
L05C2:
        loda,r0 18E7h,r2
        iora,r0 1AE0h,r2
        iora,r0 1AE3h,r2
	retc,un
;
L05CC:
        loda,r1 18F8h
	rrr,r1
	rrr,r1
	rrr,r1
	andi,r1	003H
        stra,r1 18EBh
	lodi,r2	000H
	bstr,un	L05C2
	bcfr,eq	L05E3
        loda,r0 05BEh,r1
	bsta,un	L0ED4
L05E3:
	lodi,r2	001H
	bstr,un	L05C2
	bcfr,eq	L05F2
        loda,r1 18EBh
        loda,r0 05BAh,r1
	bsta,un	L0ED8
L05F2:
	lodi,r2	002H
	bstr,un	L05C2
	bcfr,eq	L0601
        loda,r1 18EBh
        loda,r0 05BAh,r1
	bsta,un	L0EDC
L0601:
        loda,r0 1ADBh
	bcfa,eq	L0743
	bstr,un	L060C
	bcta,un	L068C
;
L060C:
        loda,r0 18F8h
	strz	r1
	andi,r0	003H
	comi,r0	003H
	bcfr,eq	L062D
	rrr,r1
	andi,r1	01FH
	lodz	r1
        loda,r1 1AD9h
        adda,r0 0FF4h,r1
        stra,r0 18FDh
	lodi,r0	00FH
        stra,r0 18FEh
	lodi,r0	001H
        stra,r0 18E0h
L062D:
	retc,un
;
L062E:
        loda,r0 1AE4h
	bctr,eq	L065F
        loda,r0 18F4h
        comi,r0 07FH
	bcfr,eq	L0659
        loda,r0 18F5h
	comi,r0	063H
	bcfr,eq	L0659
	lodi,r0	0C8H
	bsta,un	L0ED8
	eorz	r0
        stra,r0 1AE4h
        stra,r0 18E8h

;r0 becomes %xx110xxx, where x are unchanged
        loda,r0 1AF6h        ;r0 = *(1AF6);
        andi,r0 0C7H         ;r0 &= %11000111;

        iori,r0 030H         ;r0 |= %00110000;

        stra,r0 1AF6h        ;*(1AF6) = r0;
	bctr,un	L065C
;
L0659:
	bsta,un	L095A
L065C:
	bcta,un	L0689
;
L065F:
        loda,r0 18E8h
	bctr,eq	L0677
        lodr,r0 *0678h
	addi,r0	001H
        coma,r0 1AD6h
        strr,r0 *0678h
	bctr,lt	L065C
	eorz	r0
        strr,r0 *0678h
	bsta,un	L095A
	bctr,un	L065C
;
L0677:
        loda,r0 1AEAh
	addi,r0	001H
        coma,r0 1AD7h
        strr,r0 *0678h
	bctr,lt	L0689
	eorz	r0
        strr,r0 *0678h
	bsta,un	L095E
L0689:
	bcta,un	L06E9
;
L068C:
        loda,r0 1AE3h
	bctr,eq	L06BC
        loda,r0 18F2h
        comi,r0 07FH
	bcfr,eq	L06B7
        loda,r0 18F3h
	comi,r0	063H
	bcfr,eq	L06B7
	lodi,r0	0C0H
	bsta,un	L0ED4
	eorz	r0
        stra,r0 1AE3h
        stra,r0 18E7h

        loda,r0 1AF7h        ;r0 = *(1AF7);
        andi,r0 0F8H         ;r0 &= %11111000;

        iori,r0 002H         ;r0 |= %00000010;

        stra,r0 1AF7h        ;*(1AF7) = r0;

	bctr,un	L06E6
;
L06B7:
	bsta,un	L09C2
	bctr,un	L06E6
;
L06BC:
        loda,r0 18E7h
	bctr,eq	L06D4
        lodr,r0 *06D5h
	addi,r0	001H
        coma,r0 1AD6h
        strr,r0 *06D5h
	bctr,lt	L06E6
	eorz	r0
        strr,r0 *06D5h
	bsta,un	L09C2
	bctr,un	L06E6
;
L06D4:
        loda,r0 1AE9h
	addi,r0	001H
        coma,r0 1AD7h
        strr,r0 *06D5h
	bctr,lt	L06E6
	eorz	r0
        strr,r0 *06D5h
	bsta,un	L09C7
L06E6:
	bcta,un	L062E
;
L06E9:
        loda,r0 1AE5h
	bctr,eq	L0719
        loda,r0 18F6h
        comi,r0 07FH
	bcfr,eq	L0714
        loda,r0 18F7h
	comi,r0	063H
	bcfr,eq	L0714
	lodi,r0	0C8H
	bsta,un	L0EDC
	eorz	r0
        stra,r0 1AE5h
        stra,r0 18E9h

;r0 becomes %xxxxx011, where x are unchanged
        loda,r0 1AF6h        ;r0 = *(1AF6);
        andi,r0 0F8H         ;r0 &= %11111000;

        iori,r0 003H         ;r0 |= %00000011;

        stra,r0 1AF6h        ;*(1AF6) = r0;
	bctr,un	L0743
;
L0714:
	bsta,un	L098D
	bctr,un	L0743
;
L0719:
        loda,r0 18E9h
	bctr,eq	L0731
        lodr,r0 *0732h
	addi,r0	001H
        coma,r0 1AD6h
        strr,r0 *0732h
	bctr,lt	L0743
	eorz	r0
        strr,r0 *0732h
	bsta,un	L098D
	bctr,un	L0743
;
L0731:
        loda,r0 1AEBh
	addi,r0	001H
        coma,r0 1AD7h
        strr,r0 *0732h
	bctr,lt	L0743
	eorz	r0
        strr,r0 *0732h
	bsta,un	L0992
L0743:
        loda,r0 1ADCh
	bcta,eq	L0766
	addi,r0	0FFH
        stra,r0 1ADCh
	bsta,un	L00F9
	lodi,r1	005H
L0753:
        loda,r0 17FFh,r1
	addi,r0	001H
        stra,r0 17FFh,r1

        comi,r0 0DAH

	bcfr,eq	L0766

        lodi,r0 0D0H

        stra,r0 17FFh,r1
	bdrr,r1	L0753
L0766:
        loda,r0 18E5h
	comi,r0	09AH
	bcfr,eq	L077C
	bsta,eq	L0B29
        loda,r0 1AEFh
	addi,r0	001H
	comi,r0	004H
	bctr,eq	L077C
        stra,r0 1AEFh
L077C:
        loda,r0 18F8h
	bcfa,eq	L07D9
        loda,r0 18F9h
	andi,r0	00FH
	comi,r0	002H
	bcfr,eq	L07A3
        loda,r0 1ADFh
	addi,r0	001H
	comi,r0	006H
	bctr,eq	L07AB
        stra,r0 1ADFh
	strz	r1
	eorz	r0
        stra,r0 181Fh,r1

        lodi,r0 07FH

        stra,r0 18B7h
	bctr,un	L07D9
;
L07A3:
	comi,r0	006H
	bcfr,eq	L07AE
	eorz	r0
        stra,r0 18B7h
L07AB:
	bcta,un	L07D9
;
L07AE:
        loda,r1 18FBh
	tmi,r1	002H
	bcfr,eq	L07D9
	comi,r0	009H
	bcfr,eq	L07D1
        loda,r0 1ADDh
	addi,r0	001H
	comi,r0	006H
	bctr,eq	L07D9
        stra,r0 1ADDh
	strz	r1
	eorz	r0
        stra,r0 1829h,r1
	lodi,r0	0BEH
        stra,r0 1A37h
	bctr,un	L07D9
;
L07D1:
	comi,r0	00EH
	bcfr,eq	L07D9
	eorz	r0
        stra,r0 1A37h
L07D9:
	tpsu	080H
	bctr,eq	L07D9
	bcta,un	L0030
;
L07E0:
        loda,r0 1AF8h
	andi,r0	001H
	bcfr,eq	L07EE
        loda,r0 1AF9h
	andi,r0	003H
	bctr,un	L07FA
;
L07EE:
        loda,r0 1AF9h
	andi,r0	002H
	bctr,un	L07FA
;
L07F5:
        loda,r0 1AF9h
	andi,r0	003H
L07FA:
        stra,r0 1AECh
L07FD:
	bsta,un	L08A7
	bctr,eq	L0808
        loda,r0 1AECh
	bcta,un	L0882
;
L0808:
        loda,r0 1AECh
	addi,r0	001H
	andi,r0	003H
        stra,r0 1AECh
	bctr,un	L07FD
;
L0814:
        loda,r0 1AE3h
	bcfr,eq	L0850
        loda,r0 18F9h
	andi,r0	003H
	comi,r0	000H
	bcfr,eq	L0850
	bctr,un	L07F5
;
L0824:
        loda,r0 1AE4h
	bcfr,eq	L0850
        loda,r0 18F9h
	andi,r0	003H
	comi,r0	002H
	bcfr,eq	L0850
	bctr,un	L07F5
;
L0834:
        loda,r0 1AE5h
	bcfr,eq	L0850
        loda,r0 18F9h
	andi,r0	003H
	comi,r0	003H
	bcfr,eq	L0850
	bcta,un	L07F5
;
X0845:
	db	000H, 000H
X0847:
	db	008H, 008H, 000H, 000H
	db	0F8H, 0F8H, 000H, 000H
	db	000H
;
L0850:
        loda,r1 1AF8h
	andi,r1	001H
	bcfr,eq	L0886
        loda,r0 18EDh
        suba,r0 18EFh
	bcfr,lt	L086D
	bcta,eq	L0877
	lodi,r0	001H
	bsta,un	L08A7
	bctr,eq	L0877
	lodi,r0	001H
	bctr,un	L0882
;
L086D:
	lodi,r0	003H
	bstr,un	L08A7
	bctr,eq	L0877
	lodi,r0	003H
	bctr,un	L0882
;
L0877:
        loda,r0 1AF8h
	bstr,un	L08A7
	bcta,eq	L07E0
        loda,r0 1AF8h
L0882:
        stra,r0 1AF8h
	retc,un
;
L0886:
        loda,r0 18ECh
	strz	r2
        coma,r0 18EEh
	bctr,gt	L089C
	bcta,eq	L0877
	lodi,r0	000H
	bstr,un	L08A7
	bctr,eq	L0877
	lodi,r0	000H
	bctr,un	L0882
;
L089C:
	lodi,r0	002H
	bstr,un	L08A7
	bcta,eq	L0877
	lodi,r0	002H
	bctr,un	L0882
;
L08A7:
	strz	r3
        loda,r0 18EDh
        adda,r0 08DFh,r3
	comi,r0	09BH
	bctr,gt	L08D7
	comi,r0	02AH
	bctr,lt	L08DB
L08B6:
	strz	r1
        loda,r0 18ECh
        adda,r0 08E0h,r3
	bsta,un	L0A71
	comi,r0	0FFH
	bctr,eq	L08D5
	comi,r1	0FFH
	bcfr,eq	L08CD
        loda,r0 1800h,r2
	bctr,un	L08D0
;
L08CD:
        loda,r0 1A00h,r1
L08D0:

        comi,r0 003H

	bctr,eq	L08D5
	retc,un
;
L08D5:
	eorz	r0
	retc,un
;
L08D7:
	lodi,r0	02BH
	bctr,un	L08B6
;
L08DB:
	lodi,r0	09BH
	bctr,un	L08B6
;
X08DF:
	db	000H
X08E0:
	db	008H, 000H, 0F8H, 000H
	db	000H
;
L08E5:
	comi,r0	02AH
	bctr,lt	L08EE
	comi,r0	09BH
	bctr,gt	L08F1
	retc,un
;
L08EE:
	lodi,r0	09BH
	retc,un
;
L08F1:
	lodi,r0	02AH
L08F3:
	retc,un
;
L08F4:
        loda,r1 1AE8h
	comi,r1	004H
	bcfr,lt	L08F3
	lodi,r2	002H
	bctr,un	L0908
;
L08FF:
        loda,r1 1AE7h
	comi,r1	004H
	bcfr,lt	L0943
	lodi,r2	000H
L0908:
        loda,r0 18F5h,r2
        adda,r0 0FFAh,r1
	bstr,un	L08E5
        stra,r0 18F5h,r2
        loda,r0 18F4h,r2
        adda,r0 0FFBh,r1
        stra,r0 18F4h,r2
	retc,un
;
L091D:
        loda,r1 1AE6h
	comi,r1	004H
	bcfr,lt	L0943
        loda,r0 18F3h
        adda,r0 0FFAh,r1
	bsta,un	L08E5
        stra,r0 18F3h
        loda,r0 18F2h
        adda,r0 0FFBh,r1
        loda,r2 1AF5h
	andi,r2	004H
	bctr,eq	L0940
        adda,r0 0FFBh,r1
L0940:
        stra,r0 18F2h
L0943:
	retc,un
;
L0944:
        lodi,r0 07fh
        stra,r0 18eeh
        lodi,r0 063h
        stra,r0 18efh
	retc,un
;
L094F:
        loda,r0 18F0h
        strr,r0 *0947h
        loda,r0 18F1h
        strr,r0 *094Ch
	retc,un
;
L095A:
	bstr,un	L0944
	bctr,un	L0960
;
L095E:
	bstr,un	L094F
L0960:
        loda,r0 18F4h
	andi,r0	007H
	comi,r0	007H
	bcfr,eq	L098A
        loda,r0 18F5h
	andi,r0	007H
	comi,r0	003H
	bcfr,eq	L098A
        loda,r0 18F4h
        stra,r0 18ECh
        loda,r0 18F5h
        stra,r0 18EDh
        loda,r0 1AE7h
        stra,r0 1AF8h
	bsta,un	L0824
        stra,r0 1AE7h
L098A:
	bcta,un	L08FF
;
L098D:
	bsta,un	L0944
	bctr,un	L0995
;
L0992:
	bsta,un	L094F
L0995:
        loda,r0 18F6h
	andi,r0	007H
	comi,r0	007H
	bcfr,eq	L09BF
        loda,r0 18F7h
	andi,r0	007H
	comi,r0	003H
	bcfr,eq	L09BF
        loda,r0 18F6h
        stra,r0 18ECh
        loda,r0 18F7h
        stra,r0 18EDh
        loda,r0 1AE8h
        stra,r0 1AF8h
	bsta,un	L0834
        stra,r0 1AE8h
L09BF:
	bcta,un	L08F4
;
L09C2:
	bsta,un	L0944
	bctr,un	L09CA
;
L09C7:
	bsta,un	L094F
L09CA:
        loda,r0 18F2h
	andi,r0	007H
	comi,r0	007H
	bcfr,eq	L09F4
        loda,r0 18F3h
	andi,r0	007H
	comi,r0	003H
	bcfr,eq	L09F4
        loda,r0 18F2h
        stra,r0 18ECh
        loda,r0 18F3h
        stra,r0 18EDh
        loda,r0 1AE6h
        stra,r0 1AF8h
	bsta,un	L0814
        stra,r0 1AE6h
L09F4:
	bcta,un	L091D
;
L09F7:

        lodi,r1 003H

	bctr,un	L09FD
;
L09FB:
        lodi,r1 000H         ;r1 = 0;
L09FD:
        lodi,r2 000H         ;r2 = 0; // loop iterator
L09FF:
        loda,r0 0A13h,r2     ;r0 = *(A13 + r2);
        retc,eq              ;if (==) return;
        strz    r3           ;r3 = r0;
        lodz    r1           ;r0 = r1;
        stra,r0 1800h,r3     ;*(1800 + r3) = r0; // upper screen
        loda,r0 0A18h,r2     ;r0 = *(A18 + r2);
        retc,eq              ;if (==) return;
        strz    r3           ;r3 = r0;
        lodz    r1           ;r0 = r1;
        stra,r0 1A00h,r3     ;*(1A00 + r3) = r0; // lower screen
        birr,r2 L09FF        ;if (++r2 != 0) goto L09FF;
;end of loop
;Data---------------------------------------------------------------------
X0A13:
        db      09BH, 093H, 09BH, 093H, 000H
X0A18:
        db      044H, 04AH, 002H, 00CH, 000H
;Code---------------------------------------------------------------------
L0A1D:
        loda,r0 18F0h
        loda,r1 18F1h
	andi,r0	007H
	comi,r0	007H
	bcfr,eq	L0A32
	andi,r1	007H
	comi,r1	003H
	bcfr,eq	L0A32
	lodi,r0	0FFH
	retc,un
;
L0A32:
	eorz	r0
	retc,un
;
L0A34:
	strz	r3
        loda,r0 18F1h
        adda,r0 0845h,r3
	strz	r1
        loda,r0 18F0h
        adda,r0 0847h,r3
	bsta,un	L0A71
	comi,r0	0FFH
	bcta,eq	L05CC
	comi,r1	0FFH
	bcfr,eq	L0A54
        loda,r0 1800h,r2

        comi,r0 003H

	retc,un
;
L0A54:
        loda,r0 1A00h,r1

        comi,r0 003H

	retc,un
;
L0A5A:
	lodz	r1
	rrl,r0
	rrl,r0
	rrl,r0
	andi,r0	078H
	subi,r0	0D5H
	strz	r3
	lodz	r1
	andi,r0	0F0H
	rrr,r0
	addz	r2
	eori,r0	0FFH
	addi,r0	002H
	strz	r2
	lodz	r3
	strz	r1
	lodz	r2
	retc,un
;
L0A71:
	addi,r1	0D7H
	rrr,r1
	rrr,r1
	rrr,r1
	andi,r1	00FH
	eori,r0	0FFH
        adda,r0 18FCh
	comi,r0	062H
	bctr,gt	L0A8B
	addi,r0	005H
	rrl,r0
	andi,r0	0F0H
	iorz	r1
	strz	r2
	lodi,r1	0FFH
	retc,un
;
L0A8B:
	addi,r0	09EH
	rrl,r0
	andi,r0	0F0H
	iorz	r1
	strz	r1
	lodi,r2	0FFH
	retc,un
;
	db	004H, 0FFH, 017H
;
L0A98:
        lodi,r1 005H         ;r1 = 5; // loop iterator
L0A9A:
        loda,r0 1808h,r1     ;r0 = *(1808 + r1);
        stra,r0 1AEFh,r1     ;*(1AEF + r1) = r0;
        bdrr,r1 L0A9A        ;if (--r1 != 0) goto L0A9A;
;end of loop

	lodi,r1	0D0H
L0AA4:
        loda,r0 0DFFh,r1
        stra,r0 17FFh,r1
        loda,r0 0EFFh,r1
        stra,r0 19FFh,r1
	bdrr,r1	L0AA4
	lodi,r1	020H
L0AB4:
	eorz	r0
        stra,r0 1ACFh,r1
        stra,r0 18CFh,r1
	bdrr,r1	L0AB4
	lodi,r1	005H
L0ABF:
        loda,r0 1AEFh,r1
        stra,r0 1808h,r1
	bdrr,r1	L0ABF
L0AC7:
	lodi,r1	003H
	eorz	r0
L0ACA:
        stra,r0 18E6h,r1
        stra,r0 1ADFh,r1
        stra,r0 1AE2h,r1
	bdrr,r1	L0ACA
        stra,r0 1AD9h
        stra,r0 18FCh
L0ADB:
	tpsu	080H
	bctr,eq	L0ADB
L0ADF:
	tpsu	080H
	bcfr,eq	L0ADF
	eorz	r0
L0AE4:
	addi,r0	001H
	tpsu	080H
	bctr,eq	L0AE4
	lodi,r1	004H
	strz	r3
L0AED:
	comi,r3	046H
	bctr,lt	L0AF6
        loda,r0 0B24h,r1
	bctr,un	L0AF9
;
L0AF6:
        loda,r0 0B20h,r1
L0AF9:
        stra,r0 1AD3h,r1
	bdrr,r1	L0AED
        lodi,r1 080H         ;r1 = $80; // loop iterator
L0B00:
        loda,r0 0D7Fh,r1
        stra,r0 197Fh,r1
        bdrr,r1 L0B00
;end of loop

        bsta,un L00EE
        loda,r0 0DF9h
        stra,r0 18E3h
        lodi,r0 0EEH
        stra,r0 18FCh

;The code below affects the colours of the magenta and yellow ghosts
        lodi,r0 $F3          ;r0 = %11110011;
        stra,r0 $1AF6

;The code below affects the colours of the red ghost and the green player
        lodi,r0 $E2          ;r0 = %11100010;
        stra,r0 $1AF7

X0B20:
        retc,un
;
	db	002H, 003H, 003H
X0B24:
	db	003H, 002H, 002H, 003H
	db	002H
;
L0B29:
	lodi,r1	0D0H
L0B2B:
        loda,r0 0EFFh,r1
        stra,r0 19FFh,r1
	bdrr,r1	L0B2B
	lodi,r1	090H
L0B35:
        loda,r0 0E3Fh,r1
        stra,r0 183Fh,r1
	bdrr,r1	L0B35
	bsta,un	L00A0
	eorz	r0
        stra,r0 18E5h
	lodi,r0	004H
L0B46:
        stra,r0 1AFEh
	spsu
	eori,r0	040H
	lpsu
	bstr,un	L0B5A
	bsta,un	L00B8
        loda,r0 1AFEh
	bdrr,r0	L0B46
	bcta,un	L0AC7
;
L0B5A:
	tpsu	080H
	bcfr,eq	L0B5A

;*(1AF6) and *(1AF7) hold the desired sprite colours.
        loda,r0 1AF6h
        stra,r0 19FAh
        loda,r0 1AF7h
        stra,r0 19FBh
	lodi,r1	002H
L0B6C:
        loda,r0 19FBh,r1
        stra,r0 1AF9h,r1
	bdrr,r1	L0B6C
        loda,r1 18F8h
	addi,r1	001H
        strr,r1 *0B75h       ;*(*(B75)) = r1;
                             ;*(18F8) = r1;
	andi,r1	001H
        loda,r0 19FFh
        stra,r0 1AFCh,r1
        loda,r0 18E3h

        andi,r0 0BFH         ;r0 &= %10111111;

        iora,r0 0EFBh,r1
        stra,r0 18E3h
        stra,r0 19F9h
        loda,r3 1AD8h
	tmi,r3	001H
	bcfr,eq	L0BA7
	andi,r3	0FEH
	lodi,r1	008H
        loda,r2 1AD0h
L0B9F:
        loda,r0 0C50h,r2-
        stra,r0 197Fh,r1
	bdrr,r1	L0B9F
L0BA7:
	tmi,r3	002H
	bcfr,eq	L0BBA
	andi,r3	0FDH
        loda,r2 1AD1h
	lodi,r1	008H
L0BB2:
        loda,r0 0CD0h,r2-
        stra,r0 1987h,r1
	bdrr,r1	L0BB2
L0BBA:
	tmi,r3	008H
	bcfr,eq	L0BCD
	andi,r3	0F7H
        loda,r2 1AD3h
	lodi,r1	008H
L0BC5:
        loda,r0 0CD0h,r2-
        stra,r0 1997h,r1
	bdrr,r1	L0BC5
L0BCD:
	tmi,r3	004H
	bcfr,eq	L0BE0
	andi,r3	0FBH
        loda,r2 1AD2h
	lodi,r1	008H
L0BD8:
        loda,r0 0CD0h,r2-
        stra,r0 198Fh,r1
	bdrr,r1	L0BD8
L0BE0:
        stra,r3 1AD8h
        loda,r0 18F8h
	bcfr,eq	L0C0E
        loda,r0 18F9h
	addi,r0	001H
        stra,r0 18F9h
        loda,r0 1AD9h
	retc,eq
	addi,r0	0FFH
        stra,r0 1AD9h
	bcfr,eq	L0C0D

        lodi,r0 0F3H         ;r0 = %11110011;

        stra,r0 1AF6h

        lodi,r0 0E2H         ;r0 = %11100010;

        stra,r0 1AF7h
	eorz	r0
	lodi,r1	003H
L0C08:
        stra,r0 18E6h,r1
	bdrr,r1	L0C08
L0C0D:
	retc,un
;
L0C0E:
	strz	r1
	andi,r0	07FH
	bcfr,eq	L0C1B
        loda,r0 1AF9h
	addi,r0	001H
        stra,r0 1AF9h
L0C1B:
	andi,r1	001H
	bcfr,eq	L0C0D
        loda,r0 1AEDh
	addi,r0	001H
        stra,r0 1AEDh
	retc,un
;
	db	008H, 085H, 000H, 0CCH
	db	003H, 0A2H, 0CDH, 003H
;
L0C30:
	bcfa,eq	L0377
	lodi,r2	000H
	bcta,un	L0339
;
	db	098H, 005H, 004H, 082H
	db	0CCH, 083H, 0A1H, 01BH
	db	003H, 01FH, 01DH, 052H
	db	00CH, 002H, 0A5H, 044H
	db	001H, 018H, 005H, 004H
	db	002H, 03FH, 007H, 0CFH
X0C50:
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	042H, 042H, 066H, 066H
	db	07EH, 07EH, 07EH, 03CH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	042H, 042H, 066H, 066H
	db	07EH, 07EH, 07EH, 03CH
	db	07CH, 03EH, 00EH, 006H
	db	006H, 00EH, 03EH, 07CH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	07CH, 03EH, 00EH, 006H
	db	006H, 00EH, 03EH, 07CH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	03CH, 07EH, 07EH, 066H
	db	066H, 042H, 042H, 042H
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	03CH, 07EH, 07EH, 066H
	db	066H, 042H, 042H, 042H
	db	03EH, 07CH, 070H, 060H
	db	060H, 070H, 07CH, 03EH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
	db	03EH, 07CH, 070H, 060H
	db	060H, 070H, 07CH, 03EH
	db	03CH, 07EH, 07EH, 07EH
	db	07EH, 07EH, 07EH, 03CH
X0CD0:
	db	018H, 03CH, 07EH, 07EH
	db	04EH, 07EH, 03CH, 018H
	db	018H, 03CH, 03CH, 07EH
	db	07EH, 066H, 024H, 024H
	db	010H, 038H, 038H, 038H
	db	028H, 06CH, 044H, 000H
	db	000H, 010H, 010H, 038H
	db	038H, 028H, 000H, 000H
X0CF0:
	db	000H, 000H, 000H, 000H
	db	013H, 016H, 017H, 01AH
	db	01DH, 017H, 017H, 016H
	db	013H, 013H, 017H, 013H
	db	01DH, 017H, 017H, 016H
	db	013H, 013H, 017H, 013H
	db	000H, 000H, 000H, 000H
	db	000H, 000H, 000H, 000H
	db	000H, 077H, 055H, 077H
	db	000H, 008H, 036H, 000H
	db	000H, 077H, 055H, 077H
	db	077H, 008H, 036H, 036H
	db	077H, 077H, 055H, 077H
	db	077H, 008H, 036H, 036H
	db	077H, 077H, 055H, 077H
	db	077H, 008H, 008H, 036H
	db	018H, 03CH, 05AH, 05AH
	db	03CH, 03CH, 03CH, 0A5H
	db	018H, 03CH, 05AH, 07EH
	db	07EH, 024H, 03CH, 05AH
	db	018H, 03CH, 05AH, 07EH
	db	066H, 042H, 07EH, 0A5H
	db	018H, 03CH, 05AH, 07EH
	db	07EH, 024H, 03CH, 05AH
	db	042H, 066H, 05AH, 05AH
	db	03CH, 03CH, 018H, 055H
	db	042H, 066H, 05AH, 07EH
	db	07EH, 024H, 03CH, 0AAH
	db	042H, 066H, 05AH, 07EH
	db	024H, 024H, 03CH, 055H
	db	042H, 066H, 05AH, 07EH
	db	03CH, 024H, 03CH, 0AAH
	db	00CH, 083H, 0A1H, 0CCH
	db	002H, 0B0H, 00DH, 000H
	db	067H, 00CH, 000H, 068H
	db	0CCH, 002H, 09CH
X0D7F:
        db      0CDH ;##..##.#

        db      038H ;..###...
        db      07CH ;.#####..
        db      0FEH ;#######.
        db      0FEH ;#######.
        db      0FEH ;#######.
        db      0FEH ;#######.
        db      07CH ;.#####..
        db      038H ;..###...

        db      042H ;.#....#.
        db      066H ;.##..##.
        db      05AH ;.#.##.#.
        db      07EH ;.######.
        db      03CH ;..####..
        db      024H ;..#..#..
        db      03CH ;..####..
        db      055H ;.#.#.#.#

        db      018H ;...##...
        db      03CH ;..####..
        db      05AH ;.#.##.#.
        db      07EH ;.######.
        db      066H ;.##..##.
        db      07EH ;.######.
        db      0A5H ;#.#..#.#
        db      000H ;........

        db      018H ;...##...
        db      03CH ;..####..
        db      05AH ;.#.##.#.
        db      07EH ;.######.
        db      066H ;.##..##.
        db      07EH ;.######.
        db      0A5H ;#.#..#.#
        db      000H ;........

        db      000H ;........
        db      000H ;........
        db      000H ;........
        db      000H ;........
        db      010H ;...#....
        db      010H ;...#....
        db      000H ;........
        db      000H ;........

        db      000H ;........
        db      018H ;...##...
        db      03CH ;..####..
        db      03CH ;..####..
        db      03CH ;..####..
        db      03CH ;..####..
        db      018H ;...##...
        db      000H ;........

        db      010H ;...#....
        db      02CH ;..#.##..
        db      052H ;.#.#..#.
        db      038H ;..###...
        db      07CH ;.#####..
        db      05CH ;.#.###..
        db      05CH ;.#.###..
        db      038H ;..###...

        db      010H ;...#....
        db      028H ;..#.#...
        db      044H ;.#...#..
        db      0E6H ;###..##.
        db      0EFH ;###.####
        db      0EDH ;###.##.#
        db      04FH ;.#..####
        db      006H ;.....##.

        db      000H ;........
        db      0CCH ;##..##..
        db      003H ;......##
        db      0A2H ;#.#...#.
        db      0CDH ;##..##.#
        db      003H ;..##....
        db      0A1H ;#.#....#
        db      00CH ;....##..

        db      001H, 0EDH, 075H
	db	008H, 08CH, 083H, 0A1H
	db	0CCH, 002H, 0B0H, 00DH
	db	001H, 0EAH, 00CH, 001H
	db	0EBH, 0CCH, 002H, 0B1H
	db	00DH, 000H, 067H, 00CH
	db	000H, 068H, 0CCH, 002H
	db	09CH, 0CDH, 002H, 09BH
	db	00DH, 000H, 067H, 00CH
	db	000H, 068H, 084H, 002H
	db	077H, 008H, 085H, 000H
	db	0CCH, 000H, 068H, 0CDH
	db	000H, 04FH
X0DF9:

        db      0C8H, 0F3H, 0E2H

        db      00CH, 001H, 0EBH
X0DFF:
	db	03FH

;screen data (top half)

        db      0D0H, 0D0H, 0D0H, 0D0H, 0D0H, 0D0H, 000H, 000H ;"000000   000000 "
        db      000H, 090H, 090H, 090H, 090H, 090H, 090H, 000H
        db      0A0H, 09AH, 0A6H, 09EH, 000H, 000H, 0F8H, 0F8H ;"GAME  !!! OPT   "
        db      0F8H, 000H, 068H, 069H, 06DH, 000H, 000H, 000H
        db      07FH, 07FH, 07FH, 07FH, 07FH, 000H, 000H, 000H ;"!!!!!     !!!!! "
        db      000H, 000H, 0BEH, 0BEH, 0BEH, 0BEH, 0BEH, 000H
        db      003H, 003H, 003H, 003H, 003H, 003H, 003H, 003H ;"############### "
        db      003H, 003H, 003H, 003H, 003H, 003H, 003H

X0E3F:
        db      000H

;the unpatched game expects these colour assignments:
;$00..$3F: blue
;$40..$7F: magenta (purple)
;$80..$BF: cyan
;$C0..$FF: white

;ghosts are intended to be: magenta, red,  yellow

        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H ;"#......#......# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 0FDH, 003H, 003H, 0FCH, 003H, 0FCH, 0FCH ;"#!##.#...#.##!# "
        db      0FCH, 003H, 0FCH, 003H, 003H, 0FDH, 003H, 000H
        db      003H, 0FCH, 003H, 003H, 0FCH, 0FCH, 0FCH, 003H ;"#.##...#...##.# "
        db      0FCH, 0FCH, 0FCH, 003H, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 003H, 003H, 0FCH, 003H, 003H, 003H ;"#.##.#####.##.# "
        db      003H, 003H, 0FCH, 003H, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H ;"#......#......# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 003H, 003H, 000H, 003H, 003H, 0FCH, 003H ;"### ##.#.## ### "
        db      0FCH, 003H, 003H, 000H, 003H, 003H, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH ;"#.............# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 0FCH, 003H, 003H, 003H, 0FCH, 003H, 000H ;"#.###.# #.###.# "
        db      003H, 0FCH, 003H, 003H, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H ;"#.....# #.....# "
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H

L0ED0:
	lodi,r1	001H
	bctr,un	L0EEE
;
L0ED4:
	lodi,r1	002H
	bctr,un	L0EEE
;
L0ED8:
	lodi,r1	003H
	bctr,un	L0EEE
;
L0EDC:
	lodi,r1	004H
	bctr,un	L0EEE
;
	db	005H, 005H, 01BH, 00AH
	db	005H, 006H, 01BH, 006H
	db	005H, 007H, 01BH, 002H
	db	005H, 008H
;
L0EEE:
        stra,r0 1ACFh,r1
        loda,r0 0FCFh,r1
        iora,r0 1AD8h
        stra,r0 1AD8h
	retc,un
;
X0EFB:

        db      040H, 000H

        db      000H, 000H
X0EFF:
        db      000H

;screen data (bottom half)

        db      003H, 003H, 000H, 003H, 0FCh, 003H, 003H, 000H ;"## #.## ##.# ## "
        db      003H, 003H, 0FCH, 003H, 000H, 003H, 003H, 000H
        db      0FCH, 0FCH, 0FCH, 003H, 0FCH, 000H, 000H, 000H ;"...#.     .#... "
        db      000H, 000H, 0FCH, 003H, 0FCH, 0FCH, 0FCH, 000H
        db      003H, 003H, 0FCH, 003H, 0FCH, 003H, 003H, 000H ;"##.#.## ##.#.## "
        db      003H, 003H, 0FCH, 003H, 0FCH, 003H, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 000H ;"#...... ......# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 0FCH, 003H, 003H, 000H, 003H, 003H, 003H ;"#.## ##### ##.# "
        db      003H, 003H, 000H, 003H, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH ;"#.#.........#.# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 003H, 0FCH, 003H, 003H, 0FCH, 003H ;"#.#.##.#.##.#.# "
        db      0FCH, 003H, 003H, 0FCH, 003H, 0FCH, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H ;"#......#......# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 003H, 0FCH, 003H, 0FCH, 003H, 003H, 003H ;"##.#.#####.#.## "
        db      003H, 003H, 0FCH, 003H, 0FCH, 003H, 003H, 000H
        db      003H, 0FCH, 0FCH, 003H, 0FCH, 0FCH, 0FCH, 003H ;"#..#...#...#..# "
        db      0FCH, 0FCH, 0FCH, 003H, 0FCH, 0FCH, 003H, 000H
        db      003H, 0FDH, 003H, 003H, 003H, 003H, 000H, 003H ;"#!#### # ####!# "
        db      000H, 003H, 003H, 003H, 003H, 0FDH, 003H, 000H
        db      003H, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH ;"#.............# "
        db      0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 0FCH, 003H, 000H
        db      003H, 003H, 003H, 003H, 003H, 003H, 003H, 003H ;"############### "
        db      003H, 003H, 003H, 003H, 003H, 003H, 003H

X0FCF:
	db	000H

        db      001H, 002H, 004H, 008H, 010H, 020H, 040H, 080H
;Subroutine---------------------------------------------------------------
L0FD8:
        lodi,r1 009H         ;r1 = 9; // loop iterator
;print "GAME OVER"
L0FDA:
        loda,r0 0FE2h,r1     ;r0 = *(FE2 + r1);
        stra,r0 1A02h,r1     ;*(1A02 + r1) = r0;
        bdrr,r1 L0FDA        ;if (--r1 != 0) goto L0FDA;
;end of loop

X0FE2:
	retc,un
;Data---------------------------------------------------------------------

        db      020H, 01AH, 026H, 01EH, 000H, 028H, 02FH, 01EH ;"GAME OVER"

X0FEB:

        db      02BH

        db      05FH, 063H, 07FH
	db	063H, 07FH, 06BH, 07FH
	db	05BH
X0FF4:
	db	039H, 030H, 028H, 020H
	db	018H, 010H
X0FFA:
	db	000H
X0FFB:
	db	001H, 000H, 0FFH, 000H
	db	000H

        end

