          * Milton game from Milton Bradley
          
          * MC6805P2 
          * $000=PORTA, $001=PORTB, $002(low 4 bits)=PORTC, $003 not used
          * $004=DDRA,  $005=DDRB,  $006(low 4 bits)=DDRC,  $007 not used (DDRs read as $FF)
          * $008=Timer Data Reg, $009=Timer Control Reg
          * $00A-$03F not used
          * $040-$07F=RAM (stack starts at $07F)
          * $080-$0FF=Page Zero User ROM
          * $100-$3BF not used
          * $3C0-$783 Main User ROM
          * $784-$7F7 Self-Check ROM
          * $7F8-$7F9 Timer Interrupt Vector
          * $7FA-$7FB External Interrupt Vector
          * $7FC-$7FD SWI Vector
          * $7FE-$7FF Reset Vector

          *ZERO-PAGE USER ROM
          ORG $80

00000080: 23 05 06           FCB $23,$05,$06
00000083: 23 05 06           FCB $23,$05,$06
00000086: 23 05 21           FCB $23,$05,$21
00000089: 00 00 08 08        FCB $00,$00,$08,$08
0000008D: 06 06 75 75 84     FCB $06,$06,$75,$75,$84
00000092: 23 53 06           FCB $23,$53,$06
00000095: 23 53 06           FCB $23,$53,$06
00000098: 23 53 21           FCB $23,$53,$21
0000009A: 00 00 75 75        FCB $00,$00,$75,$75
0000009F: 35 35 75 75 84     FCB $35,$35,$75,$75,$84

000000A4: A6 07              lda   #$07
000000A6: B7 5F              sta   $5F
000000A8: B6 08              lda   $08
000000AA: 2A 04              bpl   $0B0
000000AC: B0 5F              suba  $5F
000000AE: 2B FC              bmi   $0AC
000000B0: 97                 tax   
000000B1: B0 5F              suba  $5F
000000B3: 2A FB              bpl   $0B0
000000B5: 81                 rts   

000000B6: B6 53              lda   $53
000000B8: AE 01              ldx   #$01
000000BA: 20 22              bra   $0DE

000000BC: B6 54              lda   $54
000000BE: AB 12              adda  #$12
000000C0: 20 1A              bra   $0DC

000000C2: B6 55              lda   $55
000000C4: AB 2E              adda  #$2E
000000C6: AD F0              bsr   $0B8
000000C8: 05 50 08           brclr 2,$50,$0D3
000000CB: A6 2C              lda   #$2C
000000CD: 0F 50 01           brclr 7,$50,$0D1
000000D0: 4C                 inca  
000000D1: AD E5              bsr   $0B8
000000D3: B6 08              lda   $08
000000D5: A4 01              anda  #$01
000000D7: AB 34              adda  #$34
000000D9: 5F                 clrx  
000000DA: 20 02              bra   $0DE

000000DC: AE 04              ldx   #$04
000000DE: BF 69              stx   $69
000000E0: CC 06 51           jmp   $0651

000000E3: B7 00              sta   $00
000000E5: A6 98              lda   #$98
000000E7: B7 01              sta   $01
000000E9: A6 FF              lda   #$FF
000000EB: B7 04              sta   $04
000000ED: 1F 01              bclr  7,$001
000000EF: 4D                 tsta  
000000F0: 1E 01              bset  7,$001
000000F2: BF 00              stx   $00
000000F4: 1F 01              bclr  7,$001
000000F6: 4D                 tsta  
000000F7: 1E 01              bset  7,$001
000000F9: 81                 rts   


000000FA: 00 00 00           FCB $00,$00,$00
000000FD: 00 00 00           FCB $00,$00,$00

          *USER ROM
          ORG $3C0

000003C0: A6 BF              lda   #$BF
000003C2: B7 05              sta   $05
000003C4: A6 9F              lda   #$9F
000003C6: B7 01              sta   $01
000003C8: CD 06 21           jsr   $0621
000003CB: A6 59              lda   #$59
000003CD: BD DC              jsr   $DC
000003CF: 9C                 rsp   
000003D0: A6 24              lda   #$24
000003D2: BD D9              jsr   $D9
000003D4: 20 04              bra   $3DA

000003D6: A6 25              lda   #$25
000003D8: BD D9              jsr   $D9
000003DA: A6 F6              lda   #$F6
000003DC: CD 05 FB           jsr   $05FB
000003DF: 25 F5              bcs   $3D6
000003E1: B6 56              lda   $56
000003E3: AB F9              adda  #$F9
000003E5: 24 F3              bcc   $3DA
000003E7: B7 50              sta   $50
000003E9: AB 26              adda  #$26
000003EB: BD D9              jsr   $D9
000003ED: 20 04              bra   $3F3

000003EF: A6 29              lda   #$29
000003F1: BD D9              jsr   $D9
000003F3: A6 F7              lda   #$F7
000003F5: CD 05 FB           jsr   $05FB
000003F8: 25 F5              bcs   $3EF
000003FA: B6 56              lda   $56
000003FC: AB F9              adda  #$F9
000003FE: 24 F3              bcc   $3F3
00000400: 27 02              beq   $404
00000402: 14 50              bset  2,$050
00000404: AB 2A              adda  #$2A
00000406: BD DC              jsr   $DC
00000408: A6 FF              lda   #$FF
0000040A: AE 0F              ldx   #$0F
0000040C: E7 3F              sta   (x+$3F)
0000040E: 5A                 decx  
0000040F: 26 FB              bne   $40C
00000411: BF 55              stx   $55
00000413: A6 12              lda   #$12
00000415: BD A6              jsr   $A6
00000417: BF 53              stx   $53
00000419: AE 07              ldx   #$07
0000041B: E6 46              lda   (x+$46)
0000041D: B1 53              cmpa  $53
0000041F: 27 F2              beq   $413
00000421: 5A                 decx  
00000422: 26 F7              bne   $41B
00000424: 03 50 0C           brclr 1,$50,$433
00000427: BE 55              ldx   $55
00000429: B6 53              lda   $53
0000042B: E7 47              sta   (x+$47)
0000042D: E7 40              sta   (x+$40)
0000042F: 3F 4E              clr   $4E
00000431: 20 1F              bra   $452

00000433: BD A4              jsr   $A4
00000435: E6 40              lda   (x+$40)
00000437: 4C                 inca  
00000438: 26 F9              bne   $433
0000043A: B6 53              lda   $53
0000043C: E7 40              sta   (x+$40)
0000043E: BE 08              ldx   $08
00000440: D6 04 00           lda   (x+$0400)
00000443: BB 08              adda  $08
00000445: B7 08              sta   $08
00000447: BD A4              jsr   $A4
00000449: E6 47              lda   (x+$47)
0000044B: 4C                 inca  
0000044C: 26 F9              bne   $447
0000044E: B6 53              lda   $53
00000450: E7 47              sta   (x+$47)
00000452: BD B6              jsr   $B6
00000454: B6 53              lda   $53
00000456: BD BE              jsr   $BE
00000458: 3C 55              inc   $55
0000045A: A6 07              lda   #$07
0000045C: B1 55              cmpa  $55
0000045E: 26 B3              bne   $413
00000460: 3F 51              clr   $51
00000462: 3F 52              clr   $52
00000464: 02 50 04           brset 1,$50,$46B
00000467: A6 30              lda   #$30
00000469: BD DC              jsr   $DC
0000046B: 01 50 12           brclr 0,$50,$480
0000046E: AE 07              ldx   #$07
00000470: E6 3F              lda   (x+$3F)
00000472: A4 1F              anda  #$1F
00000474: E7 3F              sta   (x+$3F)
00000476: 5A                 decx  
00000477: 26 F7              bne   $470
00000479: 3F 51              clr   $51
0000047B: 05 50 02           brclr 2,$50,$480
0000047E: 3F 52              clr   $52
00000480: 01 4E 23           brclr 0,$4E,$4A6
00000483: CD 05 D0           jsr   $05D0
00000486: AB F9              adda  #$F9
00000488: 24 02              bcc   $48C
0000048A: BD C8              jsr   $C8
0000048C: 3F 55              clr   $55
0000048E: 03 50 20           brclr 1,$50,$4B1
00000491: 3D 55              tst   $55
00000493: 26 11              bne   $4A6
00000495: CD 06 30           jsr   $0630
00000498: BD A4              jsr   $A4
0000049A: E6 40              lda   (x+$40)
0000049C: 2B FA              bmi   $498
0000049E: B7 53              sta   $53
000004A0: BD B8              jsr   $B8
000004A2: 3C 55              inc   $55
000004A4: 20 E8              bra   $48E

000004A6: A6 BF              lda   #$BF
000004A8: B7 73              sta   $73
000004AA: A6 EB              lda   #$EB
000004AC: CD 05 F7           jsr   $05F7
000004AF: 20 05              bra   $4B6

000004B1: A6 EB              lda   #$EB
000004B3: CD 05 FB           jsr   $05FB
000004B6: 24 03              bcc   $4BB
000004B8: CC 05 54           jmp   $0554

000004BB: 9F                 txa   
000004BC: AB F9              adda  #$F9
000004BE: 25 15              bcs   $4D5
000004C0: 02 50 E7           brset 1,$50,$4AA
000004C3: 3D 55              tst   $55
000004C5: 26 E3              bne   $4AA
000004C7: E6 40              lda   (x+$40)
000004C9: B7 53              sta   $53
000004CB: 0F 53 D2           brclr 7,$53,$4A0
000004CE: A6 55              lda   #$55
000004D0: BD DC              jsr   $DC
000004D2: CC 05 64           jmp   $0564

000004D5: 98                 clc   
000004D6: AB FA              adda  #$FA
000004D8: 24 30              bcc   $50A
000004DA: 97                 tax   
000004DB: 01 4E 04           brclr 0,$4E,$4E2
000004DE: 3D 55              tst   $55
000004E0: 27 C8              beq   $4AA
000004E2: E6 47              lda   (x+$47)
000004E4: B7 54              sta   $54
000004E6: 02 50 08           brset 1,$50,$4F1
000004E9: B6 73              lda   $73
000004EB: AB 6B              adda  #$6B
000004ED: 24 02              bcc   $4F1
000004EF: BD B6              jsr   $B6
000004F1: BD BC              jsr   $BC
000004F3: 01 4E B4           brclr 0,$4E,$4AA
000004F6: B6 53              lda   $53
000004F8: B1 54              cmpa  $54
000004FA: 26 03              bne   $4FF
000004FC: CC 05 77           jmp   $0577

000004FF: A6 10              lda   #$10
00000501: BD A6              jsr   $A6
00000503: 9F                 txa   
00000504: AB 45              adda  #$45
00000506: BD DC              jsr   $DC
00000508: 20 5A              bra   $564

0000050A: A1 FE              cmpa  #$FE
0000050C: 26 35              bne   $543
0000050E: 3F 54              clr   $54
00000510: B6 54              lda   $54
00000512: AB 31              adda  #$31
00000514: BD B8              jsr   $B8
00000516: BE 54              ldx   $54
00000518: E6 51              lda   (x+$51)
0000051A: AB 36              adda  #$36
0000051C: BD B8              jsr   $B8
0000051E: 4F                 clra  
0000051F: 05 50 01           brclr 2,$50,$523
00000522: 4C                 inca  
00000523: B1 54              cmpa  $54
00000525: 27 04              beq   $52B
00000527: 3C 54              inc   $54
00000529: 20 E5              bra   $510

0000052B: CD 06 30           jsr   $0630
0000052E: 3D 55              tst   $55
00000530: 27 1F              beq   $551
00000532: 01 4E 19           brclr 0,$4E,$54E
00000535: BD C2              jsr   $C2
00000537: 02 50 14           brset 1,$50,$54E
0000053A: 3D 55              tst   $55
0000053C: 27 02              beq   $540
0000053E: BD B6              jsr   $B6
00000540: CC 04 8E           jmp   $048E

00000543: A1 FD              cmpa  #$FD
00000545: 26 07              bne   $54E
00000547: 00 4E 04           brset 0,$4E,$54E
0000054A: 3C 4E              inc   $4E
0000054C: 20 1F              bra   $56D

0000054E: CC 04 AA           jmp   $04AA

00000551: CC 04 80           jmp   $0480

00000554: 00 4E 06           brset 0,$4E,$55D
00000557: A6 33              lda   #$33
00000559: BD D9              jsr   $D9
0000055B: 20 17              bra   $574

0000055D: 03 50 D5           brclr 1,$50,$535
00000560: A6 3F              lda   #$3F
00000562: BD DC              jsr   $DC
00000564: 05 50 09           brclr 2,$50,$570
00000567: B6 50              lda   $50
00000569: A8 80              eora  #$80
0000056B: B7 50              sta   $50
0000056D: CC 04 6B           jmp   $046B

00000570: 3C 52              inc   $52
00000572: 20 F9              bra   $56D

00000574: CC 04 B1           jmp   $04B1

00000577: AE 06              ldx   #$06
00000579: E6 40              lda   (x+$40)
0000057B: B1 53              cmpa  $53
0000057D: 27 04              beq   $583
0000057F: 5A                 decx  
00000580: 2A F7              bpl   $579
00000582: 5C                 incx  
00000583: AA 80              ora   #$80
00000585: E7 40              sta   (x+$40)
00000587: 5F                 clrx  
00000588: 0F 50 01           brclr 7,$50,$58C
0000058B: 5C                 incx  
0000058C: BF 4F              stx   $4F
0000058E: 9F                 txa   
0000058F: AB 3D              adda  #$3D
00000591: BD DC              jsr   $DC
00000593: BE 4F              ldx   $4F
00000595: 6C 51              inc   (x+$51)
00000597: 00 50 15           brset 0,$50,$5AF
0000059A: 05 50 12           brclr 2,$50,$5AF
0000059D: A6 04              lda   #$04
0000059F: E1 51              cmpa  (x+$51)
000005A1: 26 C1              bne   $564
000005A3: 9F                 txa   
000005A4: AB 56              adda  #$56
000005A6: BD B8              jsr   $B8
000005A8: A6 EB              lda   #$EB
000005AA: AD 4F              bsr   $5FB
000005AC: CC 03 CF           jmp   $03CF

000005AF: A6 07              lda   #$07
000005B1: E1 51              cmpa  (x+$51)
000005B3: 27 03              beq   $5B8
000005B5: CC 04 80           jmp   $0480

000005B8: 04 50 E8           brset 2,$50,$5A3
000005BB: A6 58              lda   #$58
000005BD: BD B8              jsr   $B8
000005BF: B6 52              lda   $52
000005C1: AE 05              ldx   #$05
000005C3: 48                 asla  
000005C4: 25 03              bcs   $5C9
000005C6: 5A                 decx  
000005C7: 26 FA              bne   $5C3
000005C9: 9F                 txa   
000005CA: AB 40              adda  #$40
000005CC: BD DC              jsr   $DC
000005CE: 20 D8              bra   $5A8

000005D0: AE 04              ldx   #$04
000005D2: A6 EF              lda   #$EF
000005D4: B7 65              sta   $65
000005D6: A4 9F              anda  #$9F
000005D8: B7 01              sta   $01
000005DA: B6 02              lda   $02
000005DC: 43                 coma  
000005DD: A4 0F              anda  #$0F
000005DF: 26 08              bne   $5E9
000005E1: B6 65              lda   $65
000005E3: 47                 asra  
000005E4: 24 0B              bcc   $5F1
000005E6: 5A                 decx  
000005E7: 20 EB              bra   $5D4

000005E9: 58                 aslx  
000005EA: 58                 aslx  
000005EB: 47                 asra  
000005EC: 25 05              bcs   $5F3
000005EE: 5C                 incx  
000005EF: 20 FA              bra   $5EB

000005F1: AE FF              ldx   #$FF
000005F3: 9F                 txa   
000005F4: B7 56              sta   $56
000005F6: 81                 rts   

000005F7: B7 62              sta   $62
000005F9: 20 06              bra   $601

000005FB: B7 62              sta   $62
000005FD: A6 60              lda   #$60
000005FF: B7 73              sta   $73
00000601: AD CD              bsr   $5D0
00000603: 4C                 inca  
00000604: 27 10              beq   $616
00000606: A6 0C              lda   #$0C
00000608: B1 56              cmpa  $56
0000060A: 26 03              bne   $60F
0000060C: CC 03 CF           jmp   $03CF

0000060F: 98                 clc   
00000610: B6 56              lda   $56
00000612: BB 62              adda  $62
00000614: 24 0A              bcc   $620
00000616: 0F 09 E8           brclr 7,$09,$601
00000619: 1F 09              bclr  7,$009
0000061B: 3C 73              inc   $73
0000061D: 26 E2              bne   $601
0000061F: 99                 sec   
00000620: 81                 rts   

00000621: 5F                 clrx  
00000622: BF 04              stx   $04
00000624: AE 87              ldx   #$87
00000626: BF 01              stx   $01
00000628: 1F 01              bclr  7,$001
0000062A: 4D                 tsta  
0000062B: BE 00              ldx   $00
0000062D: 1E 01              bset  7,$001
0000062F: 81                 rts   

00000630: AE 04              ldx   #$04
00000632: 20 04              bra   $638

00000634: BE 69              ldx   $69
00000636: 27 18              beq   $650
00000638: B6 08              lda   $08
0000063A: B7 71              sta   $71
0000063C: A6 F8              lda   #$F8
0000063E: B7 68              sta   $68
00000640: 0F 09 FD           brclr 7,$09,$640
00000643: 1F 09              bclr  7,$009
00000645: 3C 68              inc   $68
00000647: 26 F7              bne   $640
00000649: 5A                 decx  
0000064A: 26 F0              bne   $63C
0000064C: B6 71              lda   $71
0000064E: B7 08              sta   $08
00000650: 81                 rts   

00000651: 48                 asla  
00000652: 97                 tax   
00000653: 4F                 clra  
00000654: B7 70              sta   $70
00000656: BD E3              jsr   $E3
00000658: AD C7              bsr   $621
0000065A: BF 6A              stx   $6A
0000065C: AD C3              bsr   $621
0000065E: BF 6B              stx   $6B
00000660: 0A 70 23           brset 5,$70,$686
00000663: 08 70 CE           brset 4,$70,$634
00000666: B6 6A              lda   $6A
00000668: BE 6B              ldx   $6B
0000066A: 3C 6B              inc   $6B
0000066C: 3C 6B              inc   $6B
0000066E: 26 02              bne   $672
00000670: 3C 6A              inc   $6A
00000672: BD E3              jsr   $E3
00000674: AD AB              bsr   $621
00000676: 9F                 txa   
00000677: A4 C0              anda  #$C0
00000679: B7 70              sta   $70
0000067B: 1A 70              bset  5,$070
0000067D: 9F                 txa   
0000067E: A4 3F              anda  #$3F
00000680: AD 9F              bsr   $621
00000682: BD E3              jsr   $E3
00000684: 3F 6C              clr   $6C
00000686: A6 02              lda   #$02
00000688: B7 6E              sta   $6E
0000068A: 4F                 clra  
0000068B: B7 04              sta   $04
0000068D: AD 40              bsr   $6CF
0000068F: B7 71              sta   $71
00000691: 2B 5C              bmi   $6EF
00000693: AE 0E              ldx   #$0E
00000695: 4F                 clra  
00000696: E7 5A              sta   (x+$5A)
00000698: 5A                 decx  
00000699: 2A FB              bpl   $696
0000069B: B6 71              lda   $71
0000069D: 27 1B              beq   $6BA
0000069F: 1B 70              bclr  5,$070
000006A1: 0E 70 0F           brset 7,$70,$6B3
000006A4: 0C 70 04           brset 6,$70,$6AB
000006A7: A6 02              lda   #$02
000006A9: 20 02              bra   $6AD

000006AB: A6 0C              lda   #$0C
000006AD: AE F9              ldx   #$F9
000006AF: BF 63              stx   $63
000006B1: 20 13              bra   $6C6

000006B3: 0D 70 AA           brclr 6,$70,$660
000006B6: 18 70              bset  4,$070
000006B8: 20 ED              bra   $6A7

000006BA: A6 3F              lda   #$3F
000006BC: B7 63              sta   $63
000006BE: A6 06              lda   #$06
000006C0: B7 6E              sta   $6E
000006C2: AD 0B              bsr   $6CF
000006C4: 44                 lsra  
000006C5: 44                 lsra  
000006C6: B7 60              sta   $60
000006C8: A6 01              lda   #$01
000006CA: B7 57              sta   $57
000006CC: CC 07 35           jmp   $0735

000006CF: 4F                 clra  
000006D0: 3A 6E              dec   $6E
000006D2: 2A 01              bpl   $6D5
000006D4: 81                 rts   

000006D5: 3A 6C              dec   $6C
000006D7: 2A 11              bpl   $6EA
000006D9: AE 07              ldx   #$07
000006DB: BF 6C              stx   $6C
000006DD: AE 87              ldx   #$87
000006DF: BF 01              stx   $01
000006E1: 1F 01              bclr  7,$001
000006E3: 4D                 tsta  
000006E4: BE 00              ldx   $00
000006E6: 1E 01              bset  7,$001
000006E8: BF 6D              stx   $6D
000006EA: 39 6D              rol   $6D
000006EC: 46                 rora  
000006ED: 20 E1              bra   $6D0

000006EF: 38 71              asl   $71
000006F1: 2A 04              bpl   $6F7
000006F3: AE 80              ldx   #$80
000006F5: 20 02              bra   $6F9

000006F7: AE 92              ldx   #$92
000006F9: A6 11              lda   #$11
000006FB: B7 6F              sta   $6F
000006FD: 4F                 clra  
000006FE: B7 59              sta   $59
00000700: B7 58              sta   $58
00000702: F6                 lda   (x)
00000703: A4 0F              anda  #$0F
00000705: B7 6E              sta   $6E
00000707: F6                 lda   (x)
00000708: 44                 lsra  
00000709: 44                 lsra  
0000070A: 44                 lsra  
0000070B: 44                 lsra  
0000070C: B7 72              sta   $72
0000070E: BF 71              stx   $71
00000710: AD BD              bsr   $6CF
00000712: BE 6F              ldx   $6F
00000714: 34 72              lsr   $72
00000716: 25 0A              bcs   $722
00000718: 20 01              bra   $71B

0000071A: 44                 lsra  
0000071B: 3A 72              dec   $72
0000071D: 2A FB              bpl   $71A
0000071F: 20 07              bra   $728

00000721: 47                 asra  
00000722: 3A 72              dec   $72
00000724: 2A FB              bpl   $721
00000726: EB 57              adda  (x+$57)
00000728: E7 57              sta   (x+$57)
0000072A: BF 6F              stx   $6F
0000072C: BE 71              ldx   $71
0000072E: 5C                 incx  
0000072F: 3A 6F              dec   $6F
00000731: 2A CF              bpl   $702
00000733: 3C 60              inc   $60
00000735: 3A 57              dec   $57
00000737: A6 FF              lda   #$FF
00000739: B7 04              sta   $04
0000073B: 0D 01 FD           brclr 6,$01,$73B
0000073E: AE 0E              ldx   #$0E
00000740: E6 5A              lda   (x+$5A)
00000742: A3 0C              cpx   #$0C
00000744: 26 18              bne   $75E
00000746: A4 F0              anda  #$F0
00000748: 27 08              beq   $752
0000074A: A0 10              suba  #$10
0000074C: 98                 clc   
0000074D: 48                 asla  
0000074E: 25 0C              bcs   $75C
00000750: AB 10              adda  #$10
00000752: B7 71              sta   $71
00000754: E6 5A              lda   (x+$5A)
00000756: A4 0F              anda  #$0F
00000758: BA 71              ora   $71
0000075A: 20 02              bra   $75E

0000075C: A6 FF              lda   #$FF
0000075E: B7 00              sta   $00
00000760: 1A 01              bset  5,$001
00000762: 1B 01              bclr  5,$001
00000764: 5A                 decx  
00000765: 2A D9              bpl   $740
00000767: 3A 57              dec   $57
00000769: 2A 03              bpl   $76E
0000076B: CC 06 60           jmp   $0660

0000076E: B6 59              lda   $59
00000770: BB 66              adda  $66
00000772: B7 66              sta   $66
00000774: B6 58              lda   $58
00000776: BB 63              adda  $63
00000778: B7 63              sta   $63
0000077A: 20 BF              bra   $73B

0000077C: 00 00 00           FCB $00,$00,$00
0000077F: 00 00 00           FCB $00,$00,$00
00000782: 00 00              FCB $00,$00

          *SELF-TEST ROM
          *putting 9V on TIMER input shifts vectors up 8 bytes
          *for self-test, loop high bits (7-4) to low bits (3-0) of ports A and B, connect PA7 to \INT
          *results are output on port C - data sheet just says that LEDs should flash, no specific error codes
          *self-test reset jumps here
00000784: 9C                 rsp               ;set stack pointer to $07F; not needed on reset???
00000785: 33 02              com   $02         ;complement port C
00000787: 26 FE              bne   $787        ;stop here if not 0 - port C must read $FF at start
00000789: 10 06              bset  0,$006      ;set DDRC<0>
0000078B: 3F 09              clr   $09         ;clear timer control reg - code jumps back here to loop
0000078D: 83                 swi               ;SWI jumps to $7E7, incs $02 and returns (port C=1)      
0000078E: AE 01              ldx   #$01        ;port test
00000790: A6 F0              lda   #$F0
00000792: AD 47              bsr   $7DB        ;store $F0 in (X+4) (DDRs), and store $55 and $AA in (X) (ports) and verify
00000794: A9 BA              adca  #$BA
00000796: AD 43              bsr   $7DB        ;store $0F in (X+4), and store $55 and $AA in (X) and verify
00000798: 5A                 decx              ;x=0
00000799: 27 F5              beq   $790
0000079B: 4F                 clra  
0000079C: 83                 swi               ;SWI jumps to $7E7, incs $02 and returns (port C=2)         
0000079D: AE 40              ldx   #$40        ;test RAM from $040-$07F (C is set on entry)
0000079F: F7                 sta   (x)
000007A0: 46                 rora  
000007A1: 5C                 incx  
000007A2: 2A FB              bpl   $79F
000007A4: 49                 rola  
000007A5: AE 40              ldx   #$40
000007A7: F8                 eora  (x)
000007A8: 26 FE              bne   $7A8        ;hang if comparison fails
000007AA: F6                 lda   (x)
000007AB: 46                 rora  
000007AC: 5C                 incx  
000007AD: 2A F8              bpl   $7A7
000007AF: 24 EC              bcc   $79D
000007B1: 83                 swi               ;SWI jumps to $7E7, incs $02 and returns (port C=3)         
000007B2: AE C8              ldx   #$C8        ;self-modifying code - EOR $0080-$07FF
000007B4: BF 40              stx   $40         ;C8=EOR extended
000007B6: 39 43              rol   $43         ;makes $43=#$81=RTS
000007B8: BD 40              jsr   $40
000007BA: 3C 42              inc   $42
000007BC: 22 FA              bhi   $7B8
000007BE: 3C 41              inc   $41
000007C0: 07 41 F5           brclr 3,$41,$7B8
000007C3: 40                 nega  
000007C4: A2 00              sbca  #$00
000007C6: 26 FE              bne   $7C6        ;hang if checksum doesn't match
000007C8: 83                 swi               ;SWI jumps to $7E7, incs $02 and returns (port C=4)         
000007C9: 9A                 cli   
000007CA: 9B                 sei   
000007CB: 2C FE              bmc   $7CB        ;hang if interrupt mask clear
000007CD: B0 7C              suba  $7C
000007CF: 26 FE              bne   $7CF        ;hang if not zero	
000007D1: B3 7D              cpx   $7D
000007D3: 26 FE              bne   $7D3        ;hang if different
000007D5: 0B 4B FD           brclr 5,$4B,$7D5  ;hang if $4B<5>=0 - changed in timer and ext interrupts
000007D8: DC 06 C3           jmp   (x+$06C3)   ;x=0xc8 here so this jumps to $78B to restart

000007DB: E7 04              sta   (x+$04)
000007DD: A6 55              lda   #$55
000007DF: F7                 sta   (x)
000007E0: F1                 cmpa  (x)
000007E1: 26 FE              bne   $7E1        ;hang if comparison fails
000007E3: 48                 asla              ;now try $AA      
000007E4: 2B F9              bmi   $7DF
000007E6: 81                 rts   

000007E7: 3C 02              inc   $02         ;self-test SWI vector
000007E9: 80                 rti   

000007EA: 1F 09              bclr  7,$009      ;self-test timer int vector
000007EC: 37 4B              asr   $4B         ;self-test ext int vector
000007EE: 80                 rti   

000007EF: B3                 FCB $B3           ;this must be the ROM checksum

000007F0: 07 EA              FCB $07,$EA       ;self-test timer int vector
000007F2: 07 EC              FCB $07,$EC       ;self-test ext int vector
000007F4: 07 E7              FCB $07,$E7       ;self-test SWI vector
000007F6: 07 84              FCB $07,$84       ;self-test reset vector

000007F8: 03 C0              FCB $03,$C0       ;timer int vector
000007FA: 03 C0              FCB $03,$C0       ;ext int vector
000007FC: 03 C0              FCB $03,$C0       ;SWI vector
000007FE: 03 C0              FCB $03,$C0       ;reset vector
