                   // ORG   $8000
  case 0x8000:
                                                     mon("L8000    NEG   <$00                    ; 8000: 00 00         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x00); 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    wr_mem(DP|0x00, val); 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
                   // FCB   $05                     ; 8002:  ' ' 05             Invalid ; 
    // =============== S U B R O U T I N E =======================================
    // Entering trench
    PC = 0x8341; JUMP; // sstep
case 0x8341:
                                                     mon("L8341    LDA   #$00                    ; 8341: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8343; JUMP; // sstep
case 0x8343:
                                                     mon("         STA   <$44                    ; 8343: 97 44         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x44; 
    wr_mem(ea, val); 
    PC = 0x8345; JUMP; // sstep
case 0x8345:
                                                     mon("         STA   <$45                    ; 8345: 97 45         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x45; 
    wr_mem(ea, val); 
    PC = 0x8347; JUMP; // sstep
case 0x8347:
                                                     mon("         LDX   #$4989                  ; 8347: 8E 49 89      \n");
    clockticks = clockticks + 3; 
    X = 0x4989; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x834A; JUMP; // sstep
case 0x834A:
                                                     mon("         LDA   #$00                    ; 834A: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x834C; JUMP; // sstep
case 0x834C:
                                                     mon("L834C    STA   ,X+                     ; 834C: A7 80         \n");
    clockticks = clockticks + 6; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = X; 
    wr_mem(ea, val); 
    X = X + 1; 
    PC = 0x834E; JUMP; // sstep
case 0x834E:
                                                     mon("         CMPX  #$49A9                  ; 834E: 8C 49 A9      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x49a9; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8351; JUMP; // sstep
case 0x8351:
                                                     mon("         BCS   L834C                   ; 8351: 25 F9         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x834c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8353; JUMP; // sstep
case 0x8353:
                                                     mon("         LDB   $4B12                   ; 8353: F6 4B 12      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b12); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8356; JUMP; // sstep
case 0x8356:
                                                     mon("         ASLB                          ; 8356: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8357; JUMP; // sstep
case 0x8357:
                                                     mon("         LDX   #$7CC0                  ; 8357: 8E 7C C0      \n"); // Trench catwalk/turrets data?
    clockticks = clockticks + 3; 
    X = 0x7cc0; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x835A; JUMP; // sstep
case 0x835A:
                                                     mon("         ABX                           ; 835A: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0x835B; JUMP; // sstep
case 0x835B:
                                                     mon("         CMPX  #$7CD6                  ; 835B: 8C 7C D6      \n"); // Trench catwalk/turrets data?
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x7cd6; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x835E; JUMP; // sstep
case 0x835E:
                                                     mon("         BCS   L8365                   ; 835E: 25 05         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8365; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8360; JUMP; // sstep
case 0x8360:
                                                     mon("         LDU   #$4B3F                  ; 8360: CE 4B 3F      \n");
    clockticks = clockticks + 3; 
    U = 0x4b3f; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8363; JUMP; // sstep
case 0x8363:
                                                     mon("         BRA   L8367                   ; 8363: 20 02         \n");
    PC = 0x8367; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8365:
                                                     mon("L8365    LDU   ,X                      ; 8365: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8367; JUMP; // sstep
case 0x8367:
                                                     mon("L8367    STU   $49A9                   ; 8367: FF 49 A9      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49a9, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49aa, (UINT8)val); 
    PC = 0x836A; JUMP; // sstep
case 0x836A:
                                                     mon("         STU   $49AB                   ; 836A: FF 49 AB      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49ab, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49ac, (UINT8)val); 
    PC = 0x836D; JUMP; // sstep
case 0x836D:
                                                     mon("         LDU   ,U                      ; 836D: EE C4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x836F; JUMP; // sstep
case 0x836F:
                                                     mon("         LDD   #$00                    ; 836F: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8372; JUMP; // sstep
case 0x8372:
                                                     mon("         STA   $49C0                   ; 8372: B7 49 C0      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x49c0, val); 
    PC = 0x8375; JUMP; // sstep
case 0x8375:
                                                     mon("         STD   $49B1                   ; 8375: FD 49 B1      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b1, A); // Care needed with I/O space and word fetches
    wr_mem(0x49b2, B); 
    PC = 0x8378; JUMP; // sstep
case 0x8378:
                                                     mon("         STD   $49B5                   ; 8378: FD 49 B5      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b5, A); // Care needed with I/O space and word fetches
    wr_mem(0x49b6, B); 
    PC = 0x837B; JUMP; // sstep
case 0x837B:
                                                     mon("         STA   <$92                    ; 837B: 97 92         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x92; 
    wr_mem(ea, val); 
    PC = 0x837D; JUMP; // sstep
case 0x837D:
                                                     mon("         STA   <$95                    ; 837D: 97 95         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x95; 
    wr_mem(ea, val); 
    PC = 0x837F; JUMP; // sstep
case 0x837F:
                                                     mon("         STU   $49AF                   ; 837F: FF 49 AF      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49af, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49b0, (UINT8)val); 
    PC = 0x8382; JUMP; // sstep
case 0x8382:
                                                     mon("         STU   $49B3                   ; 8382: FF 49 B3      \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    wr_mem(0x49b3, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49b4, (UINT8)val); 
    PC = 0x8385; JUMP; // sstep
case 0x8385:
                                                     mon("         JSR   L8434                   ; 8385: BD 84 34      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x8434; 
    JUMP;
  case 0x8388:
                                                     mon("L8388    JSR   L8408                   ; 8388: BD 84 08      \n"); // Trench
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x8408; 
    JUMP;
  case 0x838B:
                                                     mon("L838B    JSR   L83CE                   ; 838B: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x8e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x838E:
                                                     mon("L838E    JSR   L83CE                   ; 838E: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x91); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x8391:
                                                     mon("L8391    JSR   L83CE                   ; 8391: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x94); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x8394:
                                                     mon("L8394    JSR   L83CE                   ; 8394: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x8397:
                                                     mon("L8397    JSR   L83CE                   ; 8397: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x9a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x839A:
                                                     mon("L839A    JSR   L83CE                   ; 839A: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x9d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x839D:
                                                     mon("L839D    JSR   L83CE                   ; 839D: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xa0); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x83A0:
                                                     mon("L83A0    JSR   L83CE                   ; 83A0: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x83); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
    // End of function sub_8341
  case 0x83A3:
                                                     mon("L83A3    RTS                           ; 83A3: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Called when starting trench
  case 0x83A4:
                                                     mon("L83A4    LDU   #$4B3F                  ; 83A4: CE 4B 3F      \n");
    clockticks = clockticks + 3; 
    U = 0x4b3f; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x83A7; JUMP; // sstep
case 0x83A7:
                                                     mon("         LDX   #$7C7E                  ; 83A7: 8E 7C 7E      \n"); // Copy pointers from ROM to RAM starting at word_4B3F
    clockticks = clockticks + 3; 
    X = 0x7c7e; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x83AA; JUMP; // sstep
case 0x83AA:
                                                     mon("L83AA    LDD   ,X++                    ; 83AA: EC 81         \n");
    clockticks = clockticks + 7; 
    A = rd_mem(X); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(X+1)); 
    X = X + 2; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x83AC; JUMP; // sstep
case 0x83AC:
                                                     mon("         STD   ,U++                    ; 83AC: ED C1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = U; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    U = U + 2; 
    PC = 0x83AE; JUMP; // sstep
case 0x83AE:
                                                     mon("         CMPU  #$4B5F                  ; 83AE: 11 83 4B 5F   \n");
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x4b5f; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x83B2; JUMP; // sstep
case 0x83B2:
                                                     mon("         BCS   L83AA                   ; 83B2: 25 F6         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x83aa; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x83B4; JUMP; // sstep
case 0x83B4:
                                                     mon("         LDU   #$4B43                  ; 83B4: CE 4B 43      \n");
    clockticks = clockticks + 3; 
    U = 0x4b43; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x83B7; JUMP; // sstep
case 0x83B7:
                                                     mon("         LDX   #$7C9E                  ; 83B7: 8E 7C 9E      \n");
    clockticks = clockticks + 3; 
    X = 0x7c9e; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x83BA; JUMP; // sstep
case 0x83BA:
                                                     mon("L83BA    LDA   #$11                    ; 83BA: 86 11         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x11; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x83BC; JUMP; // sstep
case 0x83BC:
                                                     mon("         LDB   $4703                   ; 83BC: F6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x83BF; JUMP; // sstep
case 0x83BF:
                                                     mon("         MUL                           ; 83BF: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x83C0; JUMP; // sstep
case 0x83C0:
                                                     mon("         ASLA                          ; 83C0: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x83C1; JUMP; // sstep
case 0x83C1:
                                                     mon("         LDD   A,X                     ; 83C1: EC 86         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)A); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x83C3; JUMP; // sstep
case 0x83C3:
                                                     mon("         STD   ,U                      ; 83C3: ED C4         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = U; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x83C5; JUMP; // sstep
case 0x83C5:
                                                     mon("         LEAU  $04,U                   ; 83C5: 33 44         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0004); 
    PC = 0x83C7; JUMP; // sstep
case 0x83C7:
                                                     mon("         CMPU  #$4B5F                  ; 83C7: 11 83 4B 5F   \n");
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x4b5f; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x83CB; JUMP; // sstep
case 0x83CB:
                                                     mon("         BCS   L83BA                   ; 83CB: 25 ED         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x83ba; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    // End of function sub_83A4
    PC = 0x83CD; JUMP; // sstep
case 0x83CD:
                                                     mon("         RTS                           ; 83CD: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x83CE:
                                                     mon("L83CE    LDA   <$92                    ; 83CE: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x83D0; JUMP; // sstep
case 0x83D0:
                                                     mon("         BNE   locret_8407             ; 83D0: 26 35         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8407; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x83D2; JUMP; // sstep
case 0x83D2:
                                                     mon("         LDU   $49B3                   ; 83D2: FE 49 B3      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b3)<<8; 
    ea = ea | rd_mem(0x49b4); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x83D5; JUMP; // sstep
case 0x83D5:
                                                     mon("         LEAU  $03,U                   ; 83D5: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x83D7; JUMP; // sstep
case 0x83D7:
                                                     mon("         LDA   ,U                      ; 83D7: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x83D9; JUMP; // sstep
case 0x83D9:
                                                     mon("         CMPA  #$05                    ; 83D9: 81 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x05; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x83DB; JUMP; // sstep
case 0x83DB:
                                                     mon("         BNE   L83E2                   ; 83DB: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x83e2; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x83DD; JUMP; // sstep
case 0x83DD:
                                                     mon("         LDU   $49AB                   ; 83DD: FE 49 AB      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49ab)<<8; 
    ea = ea | rd_mem(0x49ac); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x83E0; JUMP; // sstep
case 0x83E0:
                                                     mon("         LDU   $02,U                   ; 83E0: EE 42         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0002))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0002))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x83E2; JUMP; // sstep
case 0x83E2:
                                                     mon("L83E2    LDB   ,U                      ; 83E2: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x83E4; JUMP; // sstep
case 0x83E4:
                                                     mon("         CMPB  #$01                    ; 83E4: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x83E6; JUMP; // sstep
case 0x83E6:
                                                     mon("         BNE   L83ED                   ; 83E6: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x83ed; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x83E8; JUMP; // sstep
case 0x83E8:
                                                     mon("         LDD   #$0800                  ; 83E8: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x83EB; JUMP; // sstep
case 0x83EB:
                                                     mon("         BRA   L83F9                   ; 83EB: 20 0C         \n");
    PC = 0x83f9; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x83ED:
                                                     mon("L83ED    CMPB  #$03                    ; 83ED: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x83EF; JUMP; // sstep
case 0x83EF:
                                                     mon("         BNE   L83F6                   ; 83EF: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x83f6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x83F1; JUMP; // sstep
case 0x83F1:
                                                     mon("         LDD   #$00                    ; 83F1: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x83F4; JUMP; // sstep
case 0x83F4:
                                                     mon("         BRA   L83F9                   ; 83F4: 20 03         \n");
    PC = 0x83f9; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x83F6:
                                                     mon("L83F6    LDD   #$1000                  ; 83F6: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x83F9; JUMP; // sstep
case 0x83F9:
                                                     mon("L83F9    ADDD  $49B7                   ; 83F9: F3 49 B7      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b7)<<8; 
    ea = ea | rd_mem(0x49b8); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x83FC; JUMP; // sstep
case 0x83FC:
                                                     mon("         SUBD  $49B1                   ; 83FC: B3 49 B1      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b1)<<8; 
    ea = ea | rd_mem(0x49b2); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x83FF; JUMP; // sstep
case 0x83FF:
                                                     mon("         SUBD  #$6000                  ; 83FF: 83 60 00      \n");
    clockticks = clockticks + 4; 
    val = 0x6000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8402; JUMP; // sstep
case 0x8402:
                                                     mon("         BHI   locret_8407             ; 8402: 22 03         \n");
    // temp fix to ensure flags synched
    if (Z && (!C)) {
    PC = 0x8407; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8404; JUMP; // sstep
case 0x8404:
                                                     mon("         JSR   L8408                   ; 8404: BD 84 08      \n"); // Trench
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x07); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x84); 
    clockticks = clockticks + 1; 
    PC = 0x8408; 
    JUMP;
    // End of function sub_83CE
  case 0x8407:
                                                     mon("locret_8407 RTS                           ; 8407: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Trench
  case 0x8408:
                                                     mon("L8408    LDU   $49B3                   ; 8408: FE 49 B3      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b3)<<8; 
    ea = ea | rd_mem(0x49b4); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x840B; JUMP; // sstep
case 0x840B:
                                                     mon("         LDB   ,U                      ; 840B: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x840D; JUMP; // sstep
case 0x840D:
                                                     mon("         CMPB  #$01                    ; 840D: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x840F; JUMP; // sstep
case 0x840F:
                                                     mon("         BNE   L8416                   ; 840F: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8416; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8411; JUMP; // sstep
case 0x8411:
                                                     mon("         LDD   #$0800                  ; 8411: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8414; JUMP; // sstep
case 0x8414:
                                                     mon("         BRA   L8419                   ; 8414: 20 03         \n");
    PC = 0x8419; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8416:
                                                     mon("L8416    LDD   #$1000                  ; 8416: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8419; JUMP; // sstep
case 0x8419:
                                                     mon("L8419    ADDD  $49B5                   ; 8419: F3 49 B5      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b5)<<8; 
    ea = ea | rd_mem(0x49b6); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x841C; JUMP; // sstep
case 0x841C:
                                                     mon("         STD   $49B5                   ; 841C: FD 49 B5      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b5, A); // Care needed with I/O space and word fetches
    wr_mem(0x49b6, B); 
    PC = 0x841F; JUMP; // sstep
case 0x841F:
                                                     mon("         LEAU  $03,U                   ; 841F: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8421; JUMP; // sstep
case 0x8421:
                                                     mon("         LDB   ,U                      ; 8421: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8423; JUMP; // sstep
case 0x8423:
                                                     mon("         CMPB  #$05                    ; 8423: C1 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x05; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8425; JUMP; // sstep
case 0x8425:
                                                     mon("L8425    BNE   L8431                   ; 8425: 26 0A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8431; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8427; JUMP; // sstep
case 0x8427:
                                                     mon("         LDU   $49AB                   ; 8427: FE 49 AB      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49ab)<<8; 
    ea = ea | rd_mem(0x49ac); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x842A; JUMP; // sstep
case 0x842A:
                                                     mon("         LEAU  $02,U                   ; 842A: 33 42         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0002); 
    PC = 0x842C; JUMP; // sstep
case 0x842C:
                                                     mon("         STU   $49AB                   ; 842C: FF 49 AB      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49ab, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49ac, (UINT8)val); 
    PC = 0x842F; JUMP; // sstep
case 0x842F:
                                                     mon("         LDU   ,U                      ; 842F: EE C4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8431; JUMP; // sstep
case 0x8431:
                                                     mon("L8431    STU   $49B3                   ; 8431: FF 49 B3      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49b3, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49b4, (UINT8)val); 
    PC = 0x8434; JUMP; // sstep
case 0x8434:
                                                     mon("L8434    LDU   $49B3                   ; 8434: FE 49 B3      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b3)<<8; 
    ea = ea | rd_mem(0x49b4); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8437; JUMP; // sstep
case 0x8437:
                                                     mon("         LDB   ,U                      ; 8437: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8439; JUMP; // sstep
case 0x8439:
                                                     mon("         CMPB  #$03                    ; 8439: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x843B; JUMP; // sstep
case 0x843B:
                                                     mon("         BNE   L8447                   ; 843B: 26 0A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8447; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x843D; JUMP; // sstep
case 0x843D:
                                                     mon("         LDD   $49B5                   ; 843D: FC 49 B5      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49b5); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b6); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8440; JUMP; // sstep
case 0x8440:
                                                     mon("         STD   <$93                    ; 8440: DD 93         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0x93; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8442; JUMP; // sstep
case 0x8442:
                                                     mon("         LDA   #$FF                    ; 8442: 86 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xff; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8444; JUMP; // sstep
case 0x8444:
                                                     mon("         STA   <$92                    ; 8444: 97 92         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x92; 
    wr_mem(ea, val); 
    PC = 0x8446; JUMP; // sstep
case 0x8446:
                                                     mon("         RTS                           ; 8446: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8447:
                                                     mon("L8447    LDB   ,U                      ; 8447: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8449; JUMP; // sstep
case 0x8449:
                                                     mon("         CMPB  #$04                    ; 8449: C1 04         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x04; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x844B; JUMP; // sstep
case 0x844B:
                                                     mon("         BNE   L846A                   ; 844B: 26 1D         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x846a; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x844D; JUMP; // sstep
case 0x844D:
                                                     mon("         LDD   $49B5                   ; 844D: FC 49 B5      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49b5); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b6); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8450; JUMP; // sstep
case 0x8450:
                                                     mon("         STD   <$96                    ; 8450: DD 96         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0x96; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8452; JUMP; // sstep
case 0x8452:
                                                     mon("         LDA   #$FF                    ; 8452: 86 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xff; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8454; JUMP; // sstep
case 0x8454:
                                                     mon("         STA   <$95                    ; 8454: 97 95         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x95; 
    wr_mem(ea, val); 
    PC = 0x8456; JUMP; // sstep
case 0x8456:
                                                     mon("         LDA   #$00                    ; 8456: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8458; JUMP; // sstep
case 0x8458:
                                                     mon("         STA   <$44                    ; 8458: 97 44         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x44; 
    wr_mem(ea, val); 
    PC = 0x845A; JUMP; // sstep
case 0x845A:
                                                     mon("         STA   <$45                    ; 845A: 97 45         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x45; 
    wr_mem(ea, val); 
    PC = 0x845C; JUMP; // sstep
case 0x845C:
                                                     mon("         LDA   $4B36                   ; 845C: B6 4B 36      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b36); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x845F; JUMP; // sstep
case 0x845F:
                                                     mon("         BNE   L846A                   ; 845F: 26 09         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x846a; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8461; JUMP; // sstep
case 0x8461:
                                                     mon("         INC   $4B36                   ; 8461: 7C 4B 36      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b36); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(0x4b36, res); 
    clockticks = clockticks + 2; 
    PC = 0x8464; JUMP; // sstep
case 0x8464:
                                                     mon("         JSR   L97E3                   ; 8464: BD 97 E3      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x67); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x84); 
    clockticks = clockticks + 1; 
    PC = 0x97e3; 
    JUMP;
  case 0x8467:
                                                     mon("L8467    LDU   $49B3                   ; 8467: FE 49 B3      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b3)<<8; 
    ea = ea | rd_mem(0x49b4); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x846A; JUMP; // sstep
case 0x846A:
                                                     mon("L846A    LDB   ,U                      ; 846A: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x846C; JUMP; // sstep
case 0x846C:
                                                     mon("         CMPB  #$01                    ; 846C: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x846E; JUMP; // sstep
case 0x846E:
                                                     mon("         BNE   L8475                   ; 846E: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8475; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8470; JUMP; // sstep
case 0x8470:
                                                     mon("         LDD   #$0800                  ; 8470: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8473; JUMP; // sstep
case 0x8473:
                                                     mon("         BRA   L8478                   ; 8473: 20 03         \n");
    PC = 0x8478; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8475:
                                                     mon("L8475    LDD   #$1000                  ; 8475: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8478; JUMP; // sstep
case 0x8478:
                                                     mon("L8478    ADDD  $49B5                   ; 8478: F3 49 B5      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b5)<<8; 
    ea = ea | rd_mem(0x49b6); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x847B; JUMP; // sstep
case 0x847B:
                                                     mon("         STD   $49B7                   ; 847B: FD 49 B7      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b7, A); // Care needed with I/O space and word fetches
    wr_mem(0x49b8, B); 
    PC = 0x847E; JUMP; // sstep
case 0x847E:
                                                     mon("         LDB   $49B5                   ; 847E: F6 49 B5      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x49b5); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8481; JUMP; // sstep
case 0x8481:
                                                     mon("         LSRB                          ; 8481: 54            \n");
    val = (UINT8)B; 
/**/C = val & 1; 
    val = val >> 1; 
    B = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8482; JUMP; // sstep
case 0x8482:
                                                     mon("         LSRB                          ; 8482: 54            \n");
    val = (UINT8)B; 
/**/C = val & 1; 
    val = val >> 1; 
    B = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8483; JUMP; // sstep
case 0x8483:
                                                     mon("         LSRB                          ; 8483: 54            \n");
    val = (UINT8)B; 
    C = val & 1; 
    val = val >> 1; 
    B = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8484; JUMP; // sstep
case 0x8484:
                                                     mon("         ANDB  #$0F                    ; 8484: C4 0F         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    res = val & (SINT8)0x0f; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8486; JUMP; // sstep
case 0x8486:
                                                     mon("         LDX   #$4989                  ; 8486: 8E 49 89      \n");
    clockticks = clockticks + 3; 
    X = 0x4989; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8489; JUMP; // sstep
case 0x8489:
                                                     mon("         LDA   $01,U                   ; 8489: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x848B; JUMP; // sstep
case 0x848B:
                                                     mon("         STA   B,X                     ; 848B: A7 85         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)B); 
    wr_mem(ea, val); 
    PC = 0x848D; JUMP; // sstep
case 0x848D:
                                                     mon("         LDX   #$4999                  ; 848D: 8E 49 99      \n");
    clockticks = clockticks + 3; 
    X = 0x4999; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8490; JUMP; // sstep
case 0x8490:
                                                     mon("         LDA   $02,U                   ; 8490: A6 42         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0002)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8492; JUMP; // sstep
case 0x8492:
                                                     mon("         STA   B,X                     ; 8492: A7 85         \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + (SINT8)B); 
    wr_mem(ea, val); 
    // End of function sub_8408
    PC = 0x8494; JUMP; // sstep
case 0x8494:
                                                     mon("         RTS                           ; 8494: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8495:
                                                     mon("L8495    LDA   <$45                    ; 8495: 96 45         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x45); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8497; JUMP; // sstep
case 0x8497:
                                                     mon("         BNE   locret_84B5             ; 8497: 26 1C         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x84b5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8499; JUMP; // sstep
case 0x8499:
                                                     mon("         LDB   $4B19                   ; 8499: F6 4B 19      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b19); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x849C; JUMP; // sstep
case 0x849C:
                                                     mon("         CMPB  #$07                    ; 849C: C1 07         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x07; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x849E; JUMP; // sstep
case 0x849E:
                                                     mon("         BLS   L84A2                   ; 849E: 23 02         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x84a2; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x84A0; JUMP; // sstep
case 0x84A0:
                                                     mon("         LDB   #$07                    ; 84A0: C6 07         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x07; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84A2; JUMP; // sstep
case 0x84A2:
                                                     mon("L84A2    ASLB                          ; 84A2: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x84A3; JUMP; // sstep
case 0x84A3:
                                                     mon("         LDU   #byte_84B6              ; 84A3: CE 84 B6      \n");
    clockticks = clockticks + 3; 
    U = 0x84b6; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x84A6; JUMP; // sstep
case 0x84A6:
                                                     mon("         LEAU  B,U                     ; 84A6: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0x84A8; JUMP; // sstep
case 0x84A8:
                                                     mon("         LDA   <$43                    ; 84A8: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84AA; JUMP; // sstep
case 0x84AA:
                                                     mon("         ANDA  ,U                      ; 84AA: A4 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    res = val & rd_mem(U); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x84AC; JUMP; // sstep
case 0x84AC:
                                                     mon("         BNE   locret_84B5             ; 84AC: 26 07         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x84b5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x84AE; JUMP; // sstep
case 0x84AE:
                                                     mon("         LDA   $01,U                   ; 84AE: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84B0; JUMP; // sstep
case 0x84B0:
                                                     mon("         STA   <$9B                    ; 84B0: 97 9B         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x9b; 
    wr_mem(ea, val); 
    PC = 0x84B2; JUMP; // sstep
case 0x84B2:
                                                     mon("         JSR   L84C6                   ; 84B2: BD 84 C6      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xb5); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x84); 
    clockticks = clockticks + 1; 
    PC = 0x84c6; 
    JUMP;
    // End of function sub_8495
    // ---------------------------------------------------------------------------
  case 0x84B5:
                                                     mon("locret_84B5 RTS                           ; 84B5: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x84C6:
                                                     mon("L84C6    LDD   #$F800                  ; 84C6: CC F8 00      \n");
    clockticks = clockticks + 3; 
    A = 0xf8; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x84C9; JUMP; // sstep
case 0x84C9:
                                                     mon("         ANDA  $5098                   ; 84C9: B4 50 98      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    res = val & rd_mem(0x5098); 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x84CC; JUMP; // sstep
case 0x84CC:
                                                     mon("         ADDA  #$24                    ; 84CC: 8B 24         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x24; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x84CE; JUMP; // sstep
case 0x84CE:
                                                     mon("         STD   $5078                   ; 84CE: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x84D1; JUMP; // sstep
case 0x84D1:
                                                     mon("L84D1    LDA   $5078                   ; 84D1: B6 50 78      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5078); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84D4; JUMP; // sstep
case 0x84D4:
                                                     mon("         LSRA                          ; 84D4: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x84D5; JUMP; // sstep
case 0x84D5:
                                                     mon("         LSRA                          ; 84D5: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x84D6; JUMP; // sstep
case 0x84D6:
                                                     mon("         LSRA                          ; 84D6: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x84D7; JUMP; // sstep
case 0x84D7:
                                                     mon("         ANDA  #$0F                    ; 84D7: 84 0F         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x0f; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x84D9; JUMP; // sstep
case 0x84D9:
                                                     mon("         STA   <$99                    ; 84D9: 97 99         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x99; 
    wr_mem(ea, val); 
    PC = 0x84DB; JUMP; // sstep
case 0x84DB:
                                                     mon("         LDD   #$FE00                  ; 84DB: CC FE 00      \n");
    clockticks = clockticks + 3; 
    A = 0xfe; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x84DE; JUMP; // sstep
case 0x84DE:
                                                     mon("         STD   $507C                   ; 84DE: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x84E1; JUMP; // sstep
case 0x84E1:
                                                     mon("         LDD   #$FC80                  ; 84E1: CC FC 80      \n");
    clockticks = clockticks + 3; 
    A = 0xfc; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x84E4; JUMP; // sstep
case 0x84E4:
                                                     mon("         STD   $507A                   ; 84E4: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x84E7; JUMP; // sstep
case 0x84E7:
                                                     mon("         LDX   #$4989                  ; 84E7: 8E 49 89      \n");
    clockticks = clockticks + 3; 
    X = 0x4989; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x84EA; JUMP; // sstep
case 0x84EA:
                                                     mon("         LDB   <$99                    ; 84EA: D6 99         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x99); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84EC; JUMP; // sstep
case 0x84EC:
                                                     mon("         LDA   B,X                     ; 84EC: A6 85         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)B)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x84EE; JUMP; // sstep
case 0x84EE:
                                                     mon("L84EE    STA   <$9A                    ; 84EE: 97 9A         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x9a; 
    wr_mem(ea, val); 
    PC = 0x84F0; JUMP; // sstep
case 0x84F0:
                                                     mon("         ANDA  #$C0                    ; 84F0: 84 C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0xc0; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x84F2; JUMP; // sstep
case 0x84F2:
                                                     mon("         CMPA  #$C0                    ; 84F2: 81 C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xc0; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x84F4; JUMP; // sstep
case 0x84F4:
                                                     mon("         BNE   L8522                   ; 84F4: 26 2C         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8522; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x84F6; JUMP; // sstep
case 0x84F6:
                                                     mon("         LDD   $509C                   ; 84F6: FC 50 9C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x509c); // Care needed with I/O space and word fetches
    B = rd_mem(0x509d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x84F9; JUMP; // sstep
case 0x84F9:
                                                     mon("         SUBD  $507C                   ; 84F9: B3 50 7C      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x507c)<<8; 
    ea = ea | rd_mem(0x507d); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x84FC; JUMP; // sstep
case 0x84FC:
                                                     mon("         BLT   L8522                   ; 84FC: 2D 24         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8522; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x84FE; JUMP; // sstep
case 0x84FE:
                                                     mon("L84FE    SUBD  #$0400                  ; 84FE: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8501; JUMP; // sstep
case 0x8501:
                                                     mon("         BGE   L850F                   ; 8501: 2C 0C         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x850f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8503; JUMP; // sstep
case 0x8503:
                                                     mon("L8503    LDA   $4703                   ; 8503: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8506; JUMP; // sstep
case 0x8506:
                                                     mon("         CMPA  <$9B                    ; 8506: 91 9B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x9b); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8508; JUMP; // sstep
case 0x8508:
                                                     mon("         BCS   L850D                   ; 8508: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x850d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x850A; JUMP; // sstep
case 0x850A:
                                                     mon("         JSR   LA7F7                   ; 850A: BD A7 F7      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x0d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0xa7f7; 
    JUMP;
  case 0x850D:
                                                     mon("L850D    BRA   L8522                   ; 850D: 20 13         \n");
    PC = 0x8522; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x850F:
                                                     mon("L850F    SUBD  #$0400                  ; 850F: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8512; JUMP; // sstep
case 0x8512:
                                                     mon("         BGE   L8522                   ; 8512: 2C 0E         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x8522; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8514; JUMP; // sstep
case 0x8514:
                                                     mon("         LDA   $4703                   ; 8514: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8517; JUMP; // sstep
case 0x8517:
                                                     mon("         LDB   $4703                   ; 8517: F6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x851A; JUMP; // sstep
case 0x851A:
                                                     mon("         MUL                           ; 851A: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x851B; JUMP; // sstep
case 0x851B:
                                                     mon("         CMPA  <$9B                    ; 851B: 91 9B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x9b); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x851D; JUMP; // sstep
case 0x851D:
                                                     mon("         BCS   L8522                   ; 851D: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8522; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x851F; JUMP; // sstep
case 0x851F:
                                                     mon("         JSR   LA7F7                   ; 851F: BD A7 F7      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x22); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0xa7f7; 
    JUMP;
  case 0x8522:
                                                     mon("L8522    LDD   $507C                   ; 8522: FC 50 7C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x507c); // Care needed with I/O space and word fetches
    B = rd_mem(0x507d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8525; JUMP; // sstep
case 0x8525:
                                                     mon("         SUBD  #$0400                  ; 8525: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8528; JUMP; // sstep
case 0x8528:
                                                     mon("         STD   $507C                   ; 8528: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x852B; JUMP; // sstep
case 0x852B:
                                                     mon("         LDA   <$9A                    ; 852B: 96 9A         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x9a); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x852D; JUMP; // sstep
case 0x852D:
                                                     mon("         ASLA                          ; 852D: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x852E; JUMP; // sstep
case 0x852E:
                                                     mon("         ASLA                          ; 852E: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x852F; JUMP; // sstep
case 0x852F:
                                                     mon("         BNE   L84EE                   ; 852F: 26 BD         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x84ee; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8531; JUMP; // sstep
case 0x8531:
                                                     mon("         LDD   #$FE00                  ; 8531: CC FE 00      \n");
    clockticks = clockticks + 3; 
    A = 0xfe; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8534; JUMP; // sstep
case 0x8534:
                                                     mon("         STD   $507C                   ; 8534: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x8537; JUMP; // sstep
case 0x8537:
                                                     mon("         LDD   #$0380                  ; 8537: CC 03 80      \n");
    clockticks = clockticks + 3; 
    A = 0x03; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x853A; JUMP; // sstep
case 0x853A:
                                                     mon("         STD   $507A                   ; 853A: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x853D; JUMP; // sstep
case 0x853D:
                                                     mon("         LDX   #$4999                  ; 853D: 8E 49 99      \n");
    clockticks = clockticks + 3; 
    X = 0x4999; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8540; JUMP; // sstep
case 0x8540:
                                                     mon("         LDB   <$99                    ; 8540: D6 99         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x99); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8542; JUMP; // sstep
case 0x8542:
                                                     mon("         LDA   B,X                     ; 8542: A6 85         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)B)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8544; JUMP; // sstep
case 0x8544:
                                                     mon("L8544    STA   <$9A                    ; 8544: 97 9A         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x9a; 
    wr_mem(ea, val); 
    PC = 0x8546; JUMP; // sstep
case 0x8546:
                                                     mon("         ANDA  #$C0                    ; 8546: 84 C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0xc0; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8548; JUMP; // sstep
case 0x8548:
                                                     mon("         CMPA  #$C0                    ; 8548: 81 C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xc0; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x854A; JUMP; // sstep
case 0x854A:
                                                     mon("         BNE   L8578                   ; 854A: 26 2C         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8578; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x854C; JUMP; // sstep
case 0x854C:
                                                     mon("         LDD   $509C                   ; 854C: FC 50 9C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x509c); // Care needed with I/O space and word fetches
    B = rd_mem(0x509d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x854F; JUMP; // sstep
case 0x854F:
                                                     mon("         SUBD  $507C                   ; 854F: B3 50 7C      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x507c)<<8; 
    ea = ea | rd_mem(0x507d); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8552; JUMP; // sstep
case 0x8552:
                                                     mon("         BLT   L8578                   ; 8552: 2D 24         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8578; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8554; JUMP; // sstep
case 0x8554:
                                                     mon("         SUBD  #$0400                  ; 8554: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8557; JUMP; // sstep
case 0x8557:
                                                     mon("         BGE   L8565                   ; 8557: 2C 0C         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x8565; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8559; JUMP; // sstep
case 0x8559:
                                                     mon("         LDA   $4703                   ; 8559: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x855C; JUMP; // sstep
case 0x855C:
                                                     mon("         CMPA  <$9B                    ; 855C: 91 9B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x9b); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x855E; JUMP; // sstep
case 0x855E:
                                                     mon("         BCS   L8563                   ; 855E: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8563; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8560; JUMP; // sstep
case 0x8560:
                                                     mon("         JSR   LA80B                   ; 8560: BD A8 0B      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x63); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0xa80b; 
    JUMP;
  case 0x8563:
                                                     mon("L8563    BRA   L8578                   ; 8563: 20 13         \n");
    PC = 0x8578; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8565:
                                                     mon("L8565    SUBD  #$0400                  ; 8565: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8568; JUMP; // sstep
case 0x8568:
                                                     mon("         BGE   L8578                   ; 8568: 2C 0E         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x8578; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x856A; JUMP; // sstep
case 0x856A:
                                                     mon("         LDA   $4703                   ; 856A: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x856D; JUMP; // sstep
case 0x856D:
                                                     mon("         LDB   $4703                   ; 856D: F6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8570; JUMP; // sstep
case 0x8570:
                                                     mon("         MUL                           ; 8570: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x8571; JUMP; // sstep
case 0x8571:
                                                     mon("         CMPA  <$9B                    ; 8571: 91 9B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x9b); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8573; JUMP; // sstep
case 0x8573:
                                                     mon("         BCS   L8578                   ; 8573: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8578; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8575; JUMP; // sstep
case 0x8575:
                                                     mon("         JSR   LA80B                   ; 8575: BD A8 0B      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x78); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0xa80b; 
    JUMP;
  case 0x8578:
                                                     mon("L8578    LDD   $507C                   ; 8578: FC 50 7C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x507c); // Care needed with I/O space and word fetches
    B = rd_mem(0x507d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x857B; JUMP; // sstep
case 0x857B:
                                                     mon("         SUBD  #$0400                  ; 857B: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x857E; JUMP; // sstep
case 0x857E:
                                                     mon("         STD   $507C                   ; 857E: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x8581; JUMP; // sstep
case 0x8581:
                                                     mon("         LDA   <$9A                    ; 8581: 96 9A         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x9a); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8583; JUMP; // sstep
case 0x8583:
                                                     mon("         ASLA                          ; 8583: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x8584; JUMP; // sstep
case 0x8584:
                                                     mon("         ASLA                          ; 8584: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x8585; JUMP; // sstep
case 0x8585:
                                                     mon("         BNE   L8544                   ; 8585: 26 BD         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8544; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8587; JUMP; // sstep
case 0x8587:
                                                     mon("         LDD   $5078                   ; 8587: FC 50 78      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5078); // Care needed with I/O space and word fetches
    B = rd_mem(0x5079); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x858A; JUMP; // sstep
case 0x858A:
                                                     mon("         ADDD  #$0800                  ; 858A: C3 08 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0800; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x858D; JUMP; // sstep
case 0x858D:
                                                     mon("         STD   $5078                   ; 858D: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x8590; JUMP; // sstep
case 0x8590:
                                                     mon("         SUBD  $5098                   ; 8590: B3 50 98      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5098)<<8; 
    ea = ea | rd_mem(0x5099); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8593; JUMP; // sstep
case 0x8593:
                                                     mon("         SUBD  #$6000                  ; 8593: 83 60 00      \n");
    clockticks = clockticks + 4; 
    val = 0x6000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8596; JUMP; // sstep
case 0x8596:
                                                     mon("         LBCS  L84D1                   ; 8596: 10 25 FF 37   \n");
    clockticks = clockticks + 5; 
    if (C) {
    clockticks = clockticks + 1; 
    PC = 0x84d1; 
    JUMP;
    }
    // End of function sub_84C6
    PC = 0x859A; JUMP; // sstep
case 0x859A:
                                                     mon("         RTS                           ; 859A: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x859B:
                                                     mon("L859B    LDA   $5040                   ; 859B: B6 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5040); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x859E; JUMP; // sstep
case 0x859E:
                                                     mon("         LSRA                          ; 859E: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x859F; JUMP; // sstep
case 0x859F:
                                                     mon("         LSRA                          ; 859F: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x85A0; JUMP; // sstep
case 0x85A0:
                                                     mon("         LSRA                          ; 85A0: 44            \n");
    val = (UINT8)A; 
/**/C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x85A1; JUMP; // sstep
case 0x85A1:
                                                     mon("         ANDA  #$0F                    ; 85A1: 84 0F         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x0f; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x85A3; JUMP; // sstep
case 0x85A3:
                                                     mon("         CMPA  $49BF                   ; 85A3: B1 49 BF      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem(0x49bf); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x85A6; JUMP; // sstep
case 0x85A6:
                                                     mon("         BEQ   L85DE                   ; 85A6: 27 36         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x85de; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85A8; JUMP; // sstep
case 0x85A8:
                                                     mon("         LDB   $49BF                   ; 85A8: F6 49 BF      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x49bf); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x85AB; JUMP; // sstep
case 0x85AB:
                                                     mon("         STA   $49BF                   ; 85AB: B7 49 BF      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x49bf, val); 
    PC = 0x85AE; JUMP; // sstep
case 0x85AE:
                                                     mon("         LDX   #$4989                  ; 85AE: 8E 49 89      \n");
    clockticks = clockticks + 3; 
    X = 0x4989; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x85B1; JUMP; // sstep
case 0x85B1:
                                                     mon("         LDA   B,X                     ; 85B1: A6 85         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)B)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x85B3; JUMP; // sstep
case 0x85B3:
                                                     mon("L85B3    ASLA                          ; 85B3: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x85B4; JUMP; // sstep
case 0x85B4:
                                                     mon("         BCC   L85BD                   ; 85B4: 24 07         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x85bd; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85B6; JUMP; // sstep
case 0x85B6:
                                                     mon("         BMI   L85BD                   ; 85B6: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x85bd; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85B8; JUMP; // sstep
case 0x85B8:
                                                     mon("         INC   $49C0                   ; 85B8: 7C 49 C0      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x49c0); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(0x49c0, res); 
    clockticks = clockticks + 2; 
    PC = 0x85BB; JUMP; // sstep
case 0x85BB:
                                                     mon("L85BB    BRA   L85D2                   ; 85BB: 20 15         \n");
    PC = 0x85d2; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x85BD:
                                                     mon("L85BD    ASLA                          ; 85BD: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x85BE; JUMP; // sstep
case 0x85BE:
                                                     mon("         BNE   L85B3                   ; 85BE: 26 F3         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x85b3; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85C0; JUMP; // sstep
case 0x85C0:
                                                     mon("         LDX   #$4999                  ; 85C0: 8E 49 99      \n");
    clockticks = clockticks + 3; 
    X = 0x4999; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x85C3; JUMP; // sstep
case 0x85C3:
                                                     mon("         LDA   B,X                     ; 85C3: A6 85         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)B)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x85C5; JUMP; // sstep
case 0x85C5:
                                                     mon("L85C5    ASLA                          ; 85C5: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x85C6; JUMP; // sstep
case 0x85C6:
                                                     mon("         BCC   L85CF                   ; 85C6: 24 07         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x85cf; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85C8; JUMP; // sstep
case 0x85C8:
                                                     mon("         BMI   L85CF                   ; 85C8: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x85cf; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85CA; JUMP; // sstep
case 0x85CA:
                                                     mon("         INC   $49C0                   ; 85CA: 7C 49 C0      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x49c0); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(0x49c0, res); 
    clockticks = clockticks + 2; 
    PC = 0x85CD; JUMP; // sstep
case 0x85CD:
                                                     mon("         BRA   L85D2                   ; 85CD: 20 03         \n");
    PC = 0x85d2; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x85CF:
                                                     mon("L85CF    ASLA                          ; 85CF: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x85D0; JUMP; // sstep
case 0x85D0:
                                                     mon("         BNE   L85C5                   ; 85D0: 26 F3         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x85c5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85D2; JUMP; // sstep
case 0x85D2:
                                                     mon("L85D2    LDA   #$00                    ; 85D2: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x85D4; JUMP; // sstep
case 0x85D4:
                                                     mon("         LDX   #$4989                  ; 85D4: 8E 49 89      \n");
    clockticks = clockticks + 3; 
    X = 0x4989; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x85D7; JUMP; // sstep
case 0x85D7:
                                                     mon("         STA   B,X                     ; 85D7: A7 85         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)B); 
    wr_mem(ea, val); 
    PC = 0x85D9; JUMP; // sstep
case 0x85D9:
                                                     mon("         LDX   #$4999                  ; 85D9: 8E 49 99      \n");
    clockticks = clockticks + 3; 
    X = 0x4999; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x85DC; JUMP; // sstep
case 0x85DC:
                                                     mon("         STA   B,X                     ; 85DC: A7 85         \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + (SINT8)B); 
    wr_mem(ea, val); 
    PC = 0x85DE; JUMP; // sstep
case 0x85DE:
                                                     mon("L85DE    JSR   LB3E4                   ; 85DE: BD B3 E4      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0xb3e4; 
    JUMP;
  case 0x85E1:
                                                     mon("L85E1    JSR   L85F9                   ; 85E1: BD 85 F9      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe4); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0x85f9; 
    JUMP;
  case 0x85E4:
                                                     mon("L85E4    JSR   L8735                   ; 85E4: BD 87 35      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe7); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0x8735; 
    JUMP;
  case 0x85E7:
                                                     mon("L85E7    JSR   L86AE                   ; 85E7: BD 86 AE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xea); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0x86ae; 
    JUMP;
  case 0x85EA:
                                                     mon("L85EA    LDA   <$95                    ; 85EA: 96 95         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x95); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x85EC; JUMP; // sstep
case 0x85EC:
                                                     mon("         BEQ   L85F1                   ; 85EC: 27 03         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x85f1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85EE; JUMP; // sstep
case 0x85EE:
                                                     mon("         JSR   L889F                   ; 85EE: BD 88 9F      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0x889f; 
    JUMP;
  case 0x85F1:
                                                     mon("L85F1    LDA   <$92                    ; 85F1: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x85F3; JUMP; // sstep
case 0x85F3:
                                                     mon("         BEQ   locret_85F8             ; 85F3: 27 03         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x85f8; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x85F5; JUMP; // sstep
case 0x85F5:
                                                     mon("         JSR   L88F5                   ; 85F5: BD 88 F5      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x85); 
    clockticks = clockticks + 1; 
    PC = 0x88f5; 
    JUMP;
    // End of function sub_859B
  case 0x85F8:
                                                     mon("locret_85F8 RTS                           ; 85F8: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x85F9:
                                                     mon("L85F9    LDD   #$00                    ; 85F9: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x85FC; JUMP; // sstep
case 0x85FC:
                                                     mon("         STD   $5040                   ; 85FC: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    PC = 0x85FF; JUMP; // sstep
case 0x85FF:
                                                     mon("         LDD   #$6270                  ; 85FF: CC 62 70      \n");
    clockticks = clockticks + 3; 
    A = 0x62; 
    B = 0x70; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8602; JUMP; // sstep
case 0x8602:
                                                     mon("         STD   ,Y++                    ; 8602: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x8604; JUMP; // sstep
case 0x8604:
                                                     mon("         LDU   #word_8696              ; 8604: CE 86 96      \n");
    clockticks = clockticks + 3; 
    U = 0x8696; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8607; JUMP; // sstep
case 0x8607:
                                                     mon("L8607    LDA   <$92                    ; 8607: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8609; JUMP; // sstep
case 0x8609:
                                                     mon("         BEQ   L8618                   ; 8609: 27 0D         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8618; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x860B; JUMP; // sstep
case 0x860B:
                                                     mon("         LDD   <$93                    ; 860B: DC 93         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0x93); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0x94); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x860D; JUMP; // sstep
case 0x860D:
                                                     mon("         SUBD  $5098                   ; 860D: B3 50 98      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5098)<<8; 
    ea = ea | rd_mem(0x5099); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8610; JUMP; // sstep
case 0x8610:
                                                     mon("         CMPD  #$7000                  ; 8610: 10 83 70 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x7000; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8614; JUMP; // sstep
case 0x8614:
                                                     mon("         BHI   L8618                   ; 8614: 22 02         \n");
    // temp fix to ensure flags synched
    if (Z && (!C)) {
    PC = 0x8618; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8616; JUMP; // sstep
case 0x8616:
                                                     mon("         BRA   L861B                   ; 8616: 20 03         \n");
    PC = 0x861b; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8618:
                                                     mon("L8618    LDD   #$7000                  ; 8618: CC 70 00      \n");
    clockticks = clockticks + 3; 
    A = 0x70; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x861B; JUMP; // sstep
case 0x861B:
                                                     mon("L861B    STD   $5078                   ; 861B: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x861E; JUMP; // sstep
case 0x861E:
                                                     mon("         LDD   ,U                      ; 861E: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8620; JUMP; // sstep
case 0x8620:
                                                     mon("         STD   $507A                   ; 8620: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x8623; JUMP; // sstep
case 0x8623:
                                                     mon("L8623    LDD   $02,U                   ; 8623: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8625; JUMP; // sstep
case 0x8625:
                                                     mon("         STD   $507C                   ; 8625: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x8628; JUMP; // sstep
case 0x8628:
                                                     mon("         LDD   #$0F                    ; 8628: CC 00 0F      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x862B; JUMP; // sstep
case 0x862B:
                                                     mon("         STD   $4701                   ; 862B: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x862E; JUMP; // sstep
case 0x862E:
                                                     mon("         LDA   #$67                    ; 862E: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8630; JUMP; // sstep
case 0x8630:
                                                     mon("         JSR   LCDBA                   ; 8630: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x33); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8633:
                                                     mon("L8633    LDD   $5000                   ; 8633: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8636; JUMP; // sstep
case 0x8636:
                                                     mon("         STD   $4704                   ; 8636: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x8639; JUMP; // sstep
case 0x8639:
                                                     mon("         JSR   LCCE4                   ; 8639: BD CC E4      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x3c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xcce4; 
    JUMP;
  case 0x863C:
                                                     mon("L863C    LDD   #$0200                  ; 863C: CC 02 00      \n");
    clockticks = clockticks + 3; 
    A = 0x02; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x863F; JUMP; // sstep
case 0x863F:
                                                     mon("         STD   $5078                   ; 863F: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x8642; JUMP; // sstep
case 0x8642:
                                                     mon("         LDD   $507A                   ; 8642: FC 50 7A      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x507a); // Care needed with I/O space and word fetches
    B = rd_mem(0x507b); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8645; JUMP; // sstep
case 0x8645:
                                                     mon("         SUBD  $509A                   ; 8645: B3 50 9A      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x509a)<<8; 
    ea = ea | rd_mem(0x509b); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8648; JUMP; // sstep
case 0x8648:
                                                     mon("         BPL   L864E                   ; 8648: 2A 04         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x864e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x864A; JUMP; // sstep
case 0x864A:
                                                     mon("         COMA                          ; 864A: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0x864B; JUMP; // sstep
case 0x864B:
                                                     mon("         NEGB                          ; 864B: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x864C; JUMP; // sstep
case 0x864C:
                                                     mon("         SBCA  #$FF                    ; 864C: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0x864E; JUMP; // sstep
case 0x864E:
                                                     mon("L864E    CMPD  $5078                   ; 864E: 10 B3 50 78   \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5078)<<8; 
    ea = ea | rd_mem(0x5079); 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = ea; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    clockticks = clockticks + 1; 
    PC = 0x8652; JUMP; // sstep
case 0x8652:
                                                     mon("         BLE   L8657                   ; 8652: 2F 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) <  0) || (!Z)) {
    PC = 0x8657; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8654; JUMP; // sstep
case 0x8654:
                                                     mon("         STD   $5078                   ; 8654: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x8657; JUMP; // sstep
case 0x8657:
                                                     mon("L8657    LDD   $507C                   ; 8657: FC 50 7C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x507c); // Care needed with I/O space and word fetches
    B = rd_mem(0x507d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x865A; JUMP; // sstep
case 0x865A:
                                                     mon("         SUBD  $509C                   ; 865A: B3 50 9C      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x509c)<<8; 
    ea = ea | rd_mem(0x509d); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x865D; JUMP; // sstep
case 0x865D:
                                                     mon("         BPL   L8663                   ; 865D: 2A 04         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x8663; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x865F; JUMP; // sstep
case 0x865F:
                                                     mon("         COMA                          ; 865F: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0x8660; JUMP; // sstep
case 0x8660:
                                                     mon("         NEGB                          ; 8660: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x8661; JUMP; // sstep
case 0x8661:
                                                     mon("         SBCA  #$FF                    ; 8661: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0x8663; JUMP; // sstep
case 0x8663:
                                                     mon("L8663    CMPD  $5078                   ; 8663: 10 B3 50 78   \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5078)<<8; 
    ea = ea | rd_mem(0x5079); 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = ea; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    clockticks = clockticks + 1; 
    PC = 0x8667; JUMP; // sstep
case 0x8667:
                                                     mon("         BLE   L866C                   ; 8667: 2F 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) <  0) || (!Z)) {
    PC = 0x866c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8669; JUMP; // sstep
case 0x8669:
                                                     mon("         STD   $5078                   ; 8669: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x866C; JUMP; // sstep
case 0x866C:
                                                     mon("L866C    LDD   #$0F                    ; 866C: CC 00 0F      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x866F; JUMP; // sstep
case 0x866F:
                                                     mon("         STD   $4701                   ; 866F: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8672; JUMP; // sstep
case 0x8672:
                                                     mon("         LDA   #$67                    ; 8672: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8674; JUMP; // sstep
case 0x8674:
                                                     mon("         JSR   LCDBA                   ; 8674: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x77); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8677:
                                                     mon("L8677    LDD   $5000                   ; 8677: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x867A; JUMP; // sstep
case 0x867A:
                                                     mon("         STD   $4704                   ; 867A: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x867D; JUMP; // sstep
case 0x867D:
                                                     mon("         JSR   LCCFC                   ; 867D: BD CC FC      \n"); // Trench floor lines calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x80); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xccfc; 
    JUMP;
  case 0x8680:
                                                     mon("L8680    LDD   #$8040                  ; 8680: CC 80 40      \n");
    clockticks = clockticks + 3; 
    A = 0x80; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8683; JUMP; // sstep
case 0x8683:
                                                     mon("         STD   ,Y++                    ; 8683: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x8685; JUMP; // sstep
case 0x8685:
                                                     mon("         LEAU  $04,U                   ; 8685: 33 44         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0004); 
    PC = 0x8687; JUMP; // sstep
case 0x8687:
                                                     mon("         CMPU  #L86AE                  ; 8687: 11 83 86 AE   \n");
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x86ae; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x868B; JUMP; // sstep
case 0x868B:
                                                     mon("         LBCS  L8607                   ; 868B: 10 25 FF 78   \n");
    clockticks = clockticks + 5; 
    if (C) {
    clockticks = clockticks + 1; 
    PC = 0x8607; 
    JUMP;
    }
    PC = 0x868F; JUMP; // sstep
case 0x868F:
                                                     mon("         LDD   $5098                   ; 868F: FC 50 98      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5098); // Care needed with I/O space and word fetches
    B = rd_mem(0x5099); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8692; JUMP; // sstep
case 0x8692:
                                                     mon("         STD   $5040                   ; 8692: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    // End of function sub_85F9
    // ---------------------------------------------------------------------------
    PC = 0x8695; JUMP; // sstep
case 0x8695:
                                                     mon("         RTS                           ; 8695: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x86AE:
                                                     mon("L86AE    LDD   #$00                    ; 86AE: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86B1; JUMP; // sstep
case 0x86B1:
                                                     mon("         STD   $5040                   ; 86B1: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    PC = 0x86B4; JUMP; // sstep
case 0x86B4:
                                                     mon("         LDD   #$6250                  ; 86B4: CC 62 50      \n");
    clockticks = clockticks + 3; 
    A = 0x62; 
    B = 0x50; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86B7; JUMP; // sstep
case 0x86B7:
                                                     mon("         STD   ,Y++                    ; 86B7: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x86B9; JUMP; // sstep
case 0x86B9:
                                                     mon("         LDU   #word_8725              ; 86B9: CE 87 25      \n");
    clockticks = clockticks + 3; 
    U = 0x8725; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x86BC; JUMP; // sstep
case 0x86BC:
                                                     mon("         LDA   <$92                    ; 86BC: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x86BE; JUMP; // sstep
case 0x86BE:
                                                     mon("         BEQ   L86CD                   ; 86BE: 27 0D         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x86cd; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x86C0; JUMP; // sstep
case 0x86C0:
                                                     mon("         LDD   <$93                    ; 86C0: DC 93         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0x93); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0x94); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86C2; JUMP; // sstep
case 0x86C2:
                                                     mon("         SUBD  $5098                   ; 86C2: B3 50 98      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5098)<<8; 
    ea = ea | rd_mem(0x5099); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x86C5; JUMP; // sstep
case 0x86C5:
                                                     mon("         CMPD  #$7000                  ; 86C5: 10 83 70 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x7000; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x86C9; JUMP; // sstep
case 0x86C9:
                                                     mon("         BHI   L86CD                   ; 86C9: 22 02         \n");
    // temp fix to ensure flags synched
    if (Z && (!C)) {
    PC = 0x86cd; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x86CB; JUMP; // sstep
case 0x86CB:
                                                     mon("         BRA   L86D0                   ; 86CB: 20 03         \n");
    PC = 0x86d0; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x86CD:
                                                     mon("L86CD    LDD   #$7000                  ; 86CD: CC 70 00      \n");
    clockticks = clockticks + 3; 
    A = 0x70; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86D0; JUMP; // sstep
case 0x86D0:
                                                     mon("L86D0    STD   $5078                   ; 86D0: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x86D3; JUMP; // sstep
case 0x86D3:
                                                     mon("         LDD   ,U                      ; 86D3: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86D5; JUMP; // sstep
case 0x86D5:
                                                     mon("         STD   $507A                   ; 86D5: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x86D8; JUMP; // sstep
case 0x86D8:
                                                     mon("         LDD   $02,U                   ; 86D8: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86DA; JUMP; // sstep
case 0x86DA:
                                                     mon("         STD   $507C                   ; 86DA: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x86DD; JUMP; // sstep
case 0x86DD:
                                                     mon("         LDD   #$0F                    ; 86DD: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86E0; JUMP; // sstep
case 0x86E0:
                                                     mon("         STD   $4701                   ; 86E0: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x86E3; JUMP; // sstep
case 0x86E3:
                                                     mon("         LDA   #$67                    ; 86E3: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x86E5; JUMP; // sstep
case 0x86E5:
                                                     mon("         JSR   LCDBA                   ; 86E5: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x86E8:
                                                     mon("L86E8    LDD   $5000                   ; 86E8: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86EB; JUMP; // sstep
case 0x86EB:
                                                     mon("         STD   $4704                   ; 86EB: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x86EE; JUMP; // sstep
case 0x86EE:
                                                     mon("         JSR   LCCE4                   ; 86EE: BD CC E4      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    PC = 0xcce4; 
    JUMP;
  case 0x86F1:
                                                     mon("L86F1    BRA   L8711                   ; 86F1: 20 1E         \n");
    PC = 0x8711; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x86F3:
                                                     mon("L86F3    LDD   ,U                      ; 86F3: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86F5; JUMP; // sstep
case 0x86F5:
                                                     mon("         STD   $507A                   ; 86F5: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x86F8; JUMP; // sstep
case 0x86F8:
                                                     mon("         LDD   $02,U                   ; 86F8: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x86FA; JUMP; // sstep
case 0x86FA:
                                                     mon("         STD   $507C                   ; 86FA: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x86FD; JUMP; // sstep
case 0x86FD:
                                                     mon("         LDD   #$0F                    ; 86FD: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8700; JUMP; // sstep
case 0x8700:
                                                     mon("         STD   $4701                   ; 8700: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8703; JUMP; // sstep
case 0x8703:
                                                     mon("         LDA   #$67                    ; 8703: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8705; JUMP; // sstep
case 0x8705:
                                                     mon("         JSR   LCDBA                   ; 8705: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x08); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x87); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8708:
                                                     mon("L8708    LDD   $5000                   ; 8708: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x870B; JUMP; // sstep
case 0x870B:
                                                     mon("         STD   $4704                   ; 870B: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x870E; JUMP; // sstep
case 0x870E:
                                                     mon("         JSR   LCCFC                   ; 870E: BD CC FC      \n"); // Trench floor lines calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x11); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x87); 
    clockticks = clockticks + 1; 
    PC = 0xccfc; 
    JUMP;
  case 0x8711:
                                                     mon("L8711    LEAU  $04,U                   ; 8711: 33 44         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0004); 
    PC = 0x8713; JUMP; // sstep
case 0x8713:
                                                     mon("         CMPU  #L8735                  ; 8713: 11 83 87 35   \n");
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x8735; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8717; JUMP; // sstep
case 0x8717:
                                                     mon("         BCS   L86F3                   ; 8717: 25 DA         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x86f3; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8719; JUMP; // sstep
case 0x8719:
                                                     mon("         LDD   #$8040                  ; 8719: CC 80 40      \n");
    clockticks = clockticks + 3; 
    A = 0x80; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x871C; JUMP; // sstep
case 0x871C:
                                                     mon("         STD   ,Y++                    ; 871C: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x871E; JUMP; // sstep
case 0x871E:
                                                     mon("         LDD   $5098                   ; 871E: FC 50 98      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5098); // Care needed with I/O space and word fetches
    B = rd_mem(0x5099); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8721; JUMP; // sstep
case 0x8721:
                                                     mon("         STD   $5040                   ; 8721: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    // End of function sub_86AE
    // ---------------------------------------------------------------------------
    PC = 0x8724; JUMP; // sstep
case 0x8724:
                                                     mon("         RTS                           ; 8724: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8735:
                                                     mon("L8735    LDU   $49AF                   ; 8735: FE 49 AF      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49af)<<8; 
    ea = ea | rd_mem(0x49b0); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8738; JUMP; // sstep
case 0x8738:
                                                     mon("         LDB   ,U                      ; 8738: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x873A; JUMP; // sstep
case 0x873A:
                                                     mon("         CMPB  #$03                    ; 873A: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x873C; JUMP; // sstep
case 0x873C:
                                                     mon("         BNE   L873F                   ; 873C: 26 01         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x873f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x873E; JUMP; // sstep
case 0x873E:
                                                     mon("         RTS                           ; 873E: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x873F:
                                                     mon("L873F    CMPB  #$01                    ; 873F: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8741; JUMP; // sstep
case 0x8741:
                                                     mon("         BNE   L8748                   ; 8741: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8748; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8743; JUMP; // sstep
case 0x8743:
                                                     mon("         LDD   #$0800                  ; 8743: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8746; JUMP; // sstep
case 0x8746:
                                                     mon("         BRA   L874B                   ; 8746: 20 03         \n");
    PC = 0x874b; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8748:
                                                     mon("L8748    LDD   #$1000                  ; 8748: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x874B; JUMP; // sstep
case 0x874B:
                                                     mon("L874B    ADDD  $49B1                   ; 874B: F3 49 B1      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b1)<<8; 
    ea = ea | rd_mem(0x49b2); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x874E; JUMP; // sstep
case 0x874E:
                                                     mon("         SUBD  $5040                   ; 874E: B3 50 40      \n"); // XT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5040)<<8; 
    ea = ea | rd_mem(0x5041); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8751; JUMP; // sstep
case 0x8751:
                                                     mon("         BPL   L8786                   ; 8751: 2A 33         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x8786; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8753; JUMP; // sstep
case 0x8753:
                                                     mon("         LDB   ,U                      ; 8753: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8755; JUMP; // sstep
case 0x8755:
                                                     mon("L8755    CMPB  #$01                    ; 8755: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8757; JUMP; // sstep
case 0x8757:
                                                     mon("         BNE   L875E                   ; 8757: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x875e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8759; JUMP; // sstep
case 0x8759:
                                                     mon("         LDD   #$0800                  ; 8759: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x875C; JUMP; // sstep
case 0x875C:
                                                     mon("         BRA   L8761                   ; 875C: 20 03         \n");
    PC = 0x8761; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x875E:
                                                     mon("L875E    LDD   #$1000                  ; 875E: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8761; JUMP; // sstep
case 0x8761:
                                                     mon("L8761    ADDD  $49B1                   ; 8761: F3 49 B1      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b1)<<8; 
    ea = ea | rd_mem(0x49b2); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8764; JUMP; // sstep
case 0x8764:
                                                     mon("         STD   $49B1                   ; 8764: FD 49 B1      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b1, A); // Care needed with I/O space and word fetches
    wr_mem(0x49b2, B); 
    PC = 0x8767; JUMP; // sstep
case 0x8767:
                                                     mon("         LEAU  $03,U                   ; 8767: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8769; JUMP; // sstep
case 0x8769:
                                                     mon("         STU   $49AF                   ; 8769: FF 49 AF      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49af, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49b0, (UINT8)val); 
    PC = 0x876C; JUMP; // sstep
case 0x876C:
                                                     mon("         LDB   ,U                      ; 876C: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x876E; JUMP; // sstep
case 0x876E:
                                                     mon("         CMPB  #$03                    ; 876E: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8770; JUMP; // sstep
case 0x8770:
                                                     mon("         BNE   L8773                   ; 8770: 26 01         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8773; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8772; JUMP; // sstep
case 0x8772:
                                                     mon("         RTS                           ; 8772: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8773:
                                                     mon("L8773    LDB   ,U                      ; 8773: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8775; JUMP; // sstep
case 0x8775:
                                                     mon("         CMPB  #$05                    ; 8775: C1 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x05; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8777; JUMP; // sstep
case 0x8777:
                                                     mon("         BNE   L8783                   ; 8777: 26 0A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8783; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8779; JUMP; // sstep
case 0x8779:
                                                     mon("         LDU   $49A9                   ; 8779: FE 49 A9      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49a9)<<8; 
    ea = ea | rd_mem(0x49aa); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x877C; JUMP; // sstep
case 0x877C:
                                                     mon("         LEAU  $02,U                   ; 877C: 33 42         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0002); 
    PC = 0x877E; JUMP; // sstep
case 0x877E:
                                                     mon("         STU   $49A9                   ; 877E: FF 49 A9      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49a9, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49aa, (UINT8)val); 
    PC = 0x8781; JUMP; // sstep
case 0x8781:
                                                     mon("         LDU   ,U                      ; 8781: EE C4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8783; JUMP; // sstep
case 0x8783:
                                                     mon("L8783    STU   $49AF                   ; 8783: FF 49 AF      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49af, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49b0, (UINT8)val); 
    PC = 0x8786; JUMP; // sstep
case 0x8786:
                                                     mon("L8786    LDD   #$6260                  ; 8786: CC 62 60      \n");
    clockticks = clockticks + 3; 
    A = 0x62; 
    B = 0x60; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8789; JUMP; // sstep
case 0x8789:
                                                     mon("         STD   ,Y++                    ; 8789: ED A1         \n");
    clockticks = clockticks + 7; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x878B; JUMP; // sstep
case 0x878B:
                                                     mon("         JSR   L83CE                   ; 878B: BD 83 CE      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x8e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x87); 
    clockticks = clockticks + 1; 
    PC = 0x83ce; 
    JUMP;
  case 0x878E:
                                                     mon("L878E    LDD   $49A9                   ; 878E: FC 49 A9      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49a9); // Care needed with I/O space and word fetches
    B = rd_mem(0x49aa); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8791; JUMP; // sstep
case 0x8791:
                                                     mon("         STD   $49AD                   ; 8791: FD 49 AD      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49ad, A); // Care needed with I/O space and word fetches
    wr_mem(0x49ae, B); 
    PC = 0x8794; JUMP; // sstep
case 0x8794:
                                                     mon("         LDD   $49AF                   ; 8794: FC 49 AF      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49af); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b0); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8797; JUMP; // sstep
case 0x8797:
                                                     mon("         STD   $49B9                   ; 8797: FD 49 B9      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b9, A); // Care needed with I/O space and word fetches
    wr_mem(0x49ba, B); 
    PC = 0x879A; JUMP; // sstep
case 0x879A:
                                                     mon("         LDD   $49B1                   ; 879A: FC 49 B1      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49b1); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b2); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x879D; JUMP; // sstep
case 0x879D:
                                                     mon("         STD   $49BB                   ; 879D: FD 49 BB      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49bb, A); // Care needed with I/O space and word fetches
    wr_mem(0x49bc, B); 
    PC = 0x87A0; JUMP; // sstep
case 0x87A0:
                                                     mon("         STD   $5078                   ; 87A0: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x87A3; JUMP; // sstep
case 0x87A3:
                                                     mon("         LDD   #$FC00                  ; 87A3: CC FC 00      \n");
    clockticks = clockticks + 3; 
    A = 0xfc; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87A6; JUMP; // sstep
case 0x87A6:
                                                     mon("         STD   $507A                   ; 87A6: FD 50 7A      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x87A9; JUMP; // sstep
case 0x87A9:
                                                     mon("L87A9    JSR   L87CB                   ; 87A9: BD 87 CB      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xac); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x87); 
    clockticks = clockticks + 1; 
    PC = 0x87cb; 
    JUMP;
  case 0x87AC:
                                                     mon("L87AC    LDD   $49A9                   ; 87AC: FC 49 A9      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49a9); // Care needed with I/O space and word fetches
    B = rd_mem(0x49aa); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87AF; JUMP; // sstep
case 0x87AF:
                                                     mon("         STD   $49AD                   ; 87AF: FD 49 AD      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49ad, A); // Care needed with I/O space and word fetches
    wr_mem(0x49ae, B); 
    PC = 0x87B2; JUMP; // sstep
case 0x87B2:
                                                     mon("         LDD   $49AF                   ; 87B2: FC 49 AF      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49af); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b0); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87B5; JUMP; // sstep
case 0x87B5:
                                                     mon("         STD   $49B9                   ; 87B5: FD 49 B9      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49b9, A); // Care needed with I/O space and word fetches
    wr_mem(0x49ba, B); 
    PC = 0x87B8; JUMP; // sstep
case 0x87B8:
                                                     mon("         LDD   $49B1                   ; 87B8: FC 49 B1      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49b1); // Care needed with I/O space and word fetches
    B = rd_mem(0x49b2); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87BB; JUMP; // sstep
case 0x87BB:
                                                     mon("         STD   $49BB                   ; 87BB: FD 49 BB      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49bb, A); // Care needed with I/O space and word fetches
    wr_mem(0x49bc, B); 
    PC = 0x87BE; JUMP; // sstep
case 0x87BE:
                                                     mon("         STD   $5078                   ; 87BE: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x87C1; JUMP; // sstep
case 0x87C1:
                                                     mon("         LDD   #$0400                  ; 87C1: CC 04 00      \n");
    clockticks = clockticks + 3; 
    A = 0x04; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87C4; JUMP; // sstep
case 0x87C4:
                                                     mon("         STD   $507A                   ; 87C4: FD 50 7A      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x87C7; JUMP; // sstep
case 0x87C7:
                                                     mon("         JSR   L87CB                   ; 87C7: BD 87 CB      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xca); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x87); 
    clockticks = clockticks + 1; 
    PC = 0x87cb; 
    JUMP;
    // End of function sub_8735
  case 0x87CA:
                                                     mon("L87CA    RTS                           ; 87CA: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x87CB:
                                                     mon("L87CB    LDD   $49BB                   ; 87CB: FC 49 BB      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49bb); // Care needed with I/O space and word fetches
    B = rd_mem(0x49bc); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87CE; JUMP; // sstep
case 0x87CE:
                                                     mon("         STD   $5078                   ; 87CE: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x87D1; JUMP; // sstep
case 0x87D1:
                                                     mon("         SUBD  $5040                   ; 87D1: B3 50 40      \n"); // XT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5040)<<8; 
    ea = ea | rd_mem(0x5041); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x87D4; JUMP; // sstep
case 0x87D4:
                                                     mon("         LBMI  L8866                   ; 87D4: 10 2B 00 8E   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)N <  0) {
    clockticks = clockticks + 1; 
    PC = 0x8866; 
    JUMP;
    }
    PC = 0x87D8; JUMP; // sstep
case 0x87D8:
                                                     mon("         CMPD  #$0800                  ; 87D8: 10 83 08 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x0800; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x87DC; JUMP; // sstep
case 0x87DC:
                                                     mon("         BGE   L87F5                   ; 87DC: 2C 17         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x87f5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x87DE; JUMP; // sstep
case 0x87DE:
                                                     mon("         ASLB                          ; 87DE: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x87DF; JUMP; // sstep
case 0x87DF:
                                                     mon("         ROLA                          ; 87DF: 49            \n");
    val = (UINT8)A; 
    res = (val << 1) + (C != 0 ?1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)res ^ val; 
    A = (UINT8)res; 
    clockticks = clockticks + 2; 
    PC = 0x87E0; JUMP; // sstep
case 0x87E0:
                                                     mon("         COMA                          ; 87E0: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0x87E1; JUMP; // sstep
case 0x87E1:
                                                     mon("         NEGB                          ; 87E1: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x87E2; JUMP; // sstep
case 0x87E2:
                                                     mon("         SBCA  #$FF                    ; 87E2: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0x87E4; JUMP; // sstep
case 0x87E4:
                                                     mon("         ADDD  $5044                   ; 87E4: F3 50 44      \n"); // ZT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5044)<<8; 
    ea = ea | rd_mem(0x5045); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x87E7; JUMP; // sstep
case 0x87E7:
                                                     mon("         CMPD  #$F000                  ; 87E7: 10 83 F0 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0xf000; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x87EB; JUMP; // sstep
case 0x87EB:
                                                     mon("         BGE   L87F0                   ; 87EB: 2C 03         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x87f0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x87ED; JUMP; // sstep
case 0x87ED:
                                                     mon("         LDD   #$F000                  ; 87ED: CC F0 00      \n");
    clockticks = clockticks + 3; 
    A = 0xf0; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87F0; JUMP; // sstep
case 0x87F0:
                                                     mon("L87F0    STD   $507C                   ; 87F0: FD 50 7C      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x87F3; JUMP; // sstep
case 0x87F3:
                                                     mon("         BRA   L8801                   ; 87F3: 20 0C         \n");
    PC = 0x8801; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x87F5:
                                                     mon("L87F5    LDD   $49BB                   ; 87F5: FC 49 BB      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x49bb); // Care needed with I/O space and word fetches
    B = rd_mem(0x49bc); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87F8; JUMP; // sstep
case 0x87F8:
                                                     mon("         STD   $5078                   ; 87F8: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x87FB; JUMP; // sstep
case 0x87FB:
                                                     mon("         LDD   #$F000                  ; 87FB: CC F0 00      \n");
    clockticks = clockticks + 3; 
    A = 0xf0; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x87FE; JUMP; // sstep
case 0x87FE:
                                                     mon("         STD   $507C                   ; 87FE: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x8801; JUMP; // sstep
case 0x8801:
                                                     mon("L8801    LDA   <$92                    ; 8801: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8803; JUMP; // sstep
case 0x8803:
                                                     mon("         BEQ   L880E                   ; 8803: 27 09         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x880e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8805; JUMP; // sstep
case 0x8805:
                                                     mon("         LDD   $5078                   ; 8805: FC 50 78      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5078); // Care needed with I/O space and word fetches
    B = rd_mem(0x5079); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8808; JUMP; // sstep
case 0x8808:
                                                     mon("         SUBD  <$93                    ; 8808: 93 93         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x93)<<8; 
    ea = ea | rd_mem(DP|0x94); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x880A; JUMP; // sstep
case 0x880A:
                                                     mon("         LBPL  locret_889E             ; 880A: 10 2A 00 90   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)N >= 0) {
    clockticks = clockticks + 1; 
    PC = 0x889e; 
    JUMP;
    }
    PC = 0x880E; JUMP; // sstep
case 0x880E:
                                                     mon("L880E    LDD   $5078                   ; 880E: FC 50 78      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5078); // Care needed with I/O space and word fetches
    B = rd_mem(0x5079); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8811; JUMP; // sstep
case 0x8811:
                                                     mon("         SUBD  $5098                   ; 8811: B3 50 98      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5098)<<8; 
    ea = ea | rd_mem(0x5099); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8814; JUMP; // sstep
case 0x8814:
                                                     mon("         SUBD  #$7000                  ; 8814: 83 70 00      \n");
    clockticks = clockticks + 4; 
    val = 0x7000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8817; JUMP; // sstep
case 0x8817:
                                                     mon("         LBPL  locret_889E             ; 8817: 10 2A 00 83   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)N >= 0) {
    clockticks = clockticks + 1; 
    PC = 0x889e; 
    JUMP;
    }
    PC = 0x881B; JUMP; // sstep
case 0x881B:
                                                     mon("         LDD   #$0F                    ; 881B: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x881E; JUMP; // sstep
case 0x881E:
                                                     mon("         STD   $4701                   ; 881E: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8821; JUMP; // sstep
case 0x8821:
                                                     mon("         LDA   #$67                    ; 8821: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8823; JUMP; // sstep
case 0x8823:
                                                     mon("         JSR   LCDBA                   ; 8823: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x26); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8826:
                                                     mon("L8826    LDD   $5002                   ; 8826: FC 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    A = rd_mem(0x5002); // Care needed with I/O space and word fetches
    B = rd_mem(0x5003); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8829; JUMP; // sstep
case 0x8829:
                                                     mon("         BPL   L882F                   ; 8829: 2A 04         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x882f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x882B; JUMP; // sstep
case 0x882B:
                                                     mon("         COMA                          ; 882B: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0x882C; JUMP; // sstep
case 0x882C:
                                                     mon("         NEGB                          ; 882C: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x882D; JUMP; // sstep
case 0x882D:
                                                     mon("         SBCA  #$FF                    ; 882D: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0x882F; JUMP; // sstep
case 0x882F:
                                                     mon("L882F    SUBD  $5000                   ; 882F: B3 50 00      \n"); // Math result X
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5000)<<8; 
    ea = ea | rd_mem(0x5001); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8832; JUMP; // sstep
case 0x8832:
                                                     mon("         BGT   L8866                   ; 8832: 2E 32         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8866; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8834; JUMP; // sstep
case 0x8834:
                                                     mon("         LDD   $5000                   ; 8834: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8837; JUMP; // sstep
case 0x8837:
                                                     mon("         STD   $4704                   ; 8837: FD 47 04      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x883A; JUMP; // sstep
case 0x883A:
                                                     mon("         LDD   #$00                    ; 883A: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x883D; JUMP; // sstep
case 0x883D:
                                                     mon("         STD   <$D6                    ; 883D: DD D6         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xd6; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x883F; JUMP; // sstep
case 0x883F:
                                                     mon("         LDD   #$68                    ; 883F: CC 00 68      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x68; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8842; JUMP; // sstep
case 0x8842:
                                                     mon("         STD   <$D8                    ; 8842: DD D8         \n");
    clockticks = clockticks + 4; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = DP|0xd8; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8844; JUMP; // sstep
case 0x8844:
                                                     mon("         JSR   LCD08                   ; 8844: BD CD 08      \n"); // Trench side vertical lines calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x47); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcd08; 
    JUMP;
  case 0x8847:
                                                     mon("L8847    LDD   #$00                    ; 8847: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x884A; JUMP; // sstep
case 0x884A:
                                                     mon("         STD   $507C                   ; 884A: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x884D; JUMP; // sstep
case 0x884D:
                                                     mon("         LDD   #$0F                    ; 884D: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8850; JUMP; // sstep
case 0x8850:
                                                     mon("         STD   $4701                   ; 8850: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8853; JUMP; // sstep
case 0x8853:
                                                     mon("         LDA   #$67                    ; 8853: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8855; JUMP; // sstep
case 0x8855:
                                                     mon("         JSR   LCDBA                   ; 8855: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x58); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8858:
                                                     mon("L8858    LDD   $5000                   ; 8858: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x885B; JUMP; // sstep
case 0x885B:
                                                     mon("         STD   $4704                   ; 885B: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x885E; JUMP; // sstep
case 0x885E:
                                                     mon("         JSR   LCCFC                   ; 885E: BD CC FC      \n"); // Trench floor lines calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x61); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xccfc; 
    JUMP;
  case 0x8861:
                                                     mon("L8861    LDD   #$8040                  ; 8861: CC 80 40      \n");
    clockticks = clockticks + 3; 
    A = 0x80; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8864; JUMP; // sstep
case 0x8864:
                                                     mon("         STD   ,Y++                    ; 8864: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x8866; JUMP; // sstep
case 0x8866:
                                                     mon("L8866    LDU   $49B9                   ; 8866: FE 49 B9      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49b9)<<8; 
    ea = ea | rd_mem(0x49ba); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8869; JUMP; // sstep
case 0x8869:
                                                     mon("         LDB   ,U                      ; 8869: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x886B; JUMP; // sstep
case 0x886B:
                                                     mon("         CMPB  #$01                    ; 886B: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x886D; JUMP; // sstep
case 0x886D:
                                                     mon("         BNE   L8874                   ; 886D: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8874; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x886F; JUMP; // sstep
case 0x886F:
                                                     mon("         LDD   #$0800                  ; 886F: CC 08 00      \n");
    clockticks = clockticks + 3; 
    A = 0x08; 
    B = 0x00; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8872; JUMP; // sstep
case 0x8872:
                                                     mon("         BRA   L8877                   ; 8872: 20 03         \n");
    PC = 0x8877; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8874:
                                                     mon("L8874    LDD   #$1000                  ; 8874: CC 10 00      \n");
    clockticks = clockticks + 3; 
    A = 0x10; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8877; JUMP; // sstep
case 0x8877:
                                                     mon("L8877    ADDD  $49BB                   ; 8877: F3 49 BB      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49bb)<<8; 
    ea = ea | rd_mem(0x49bc); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x887A; JUMP; // sstep
case 0x887A:
                                                     mon("         STD   $49BB                   ; 887A: FD 49 BB      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x49bb, A); // Care needed with I/O space and word fetches
    wr_mem(0x49bc, B); 
    PC = 0x887D; JUMP; // sstep
case 0x887D:
                                                     mon("         SUBD  $5040                   ; 887D: B3 50 40      \n"); // XT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5040)<<8; 
    ea = ea | rd_mem(0x5041); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8880; JUMP; // sstep
case 0x8880:
                                                     mon("         BMI   locret_889E             ; 8880: 2B 1C         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x889e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8882; JUMP; // sstep
case 0x8882:
                                                     mon("         LEAU  $03,U                   ; 8882: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8884; JUMP; // sstep
case 0x8884:
                                                     mon("         LDB   ,U                      ; 8884: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8886; JUMP; // sstep
case 0x8886:
                                                     mon("         CMPB  #$03                    ; 8886: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8888; JUMP; // sstep
case 0x8888:
                                                     mon("L8888    BEQ   locret_889E             ; 8888: 27 14         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x889e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x888A; JUMP; // sstep
case 0x888A:
                                                     mon("         CMPB  #$05                    ; 888A: C1 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x05; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x888C; JUMP; // sstep
case 0x888C:
                                                     mon("         BNE   L8898                   ; 888C: 26 0A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8898; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x888E; JUMP; // sstep
case 0x888E:
                                                     mon("         LDU   $49AD                   ; 888E: FE 49 AD      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x49ad)<<8; 
    ea = ea | rd_mem(0x49ae); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8891; JUMP; // sstep
case 0x8891:
                                                     mon("         LEAU  $02,U                   ; 8891: 33 42         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0002); 
    PC = 0x8893; JUMP; // sstep
case 0x8893:
                                                     mon("         STU   $49AD                   ; 8893: FF 49 AD      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    wr_mem(0x49ad, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49ae, (UINT8)val); 
    PC = 0x8896; JUMP; // sstep
case 0x8896:
                                                     mon("         LDU   ,U                      ; 8896: EE C4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8898; JUMP; // sstep
case 0x8898:
                                                     mon("L8898    STU   $49B9                   ; 8898: FF 49 B9      \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    wr_mem(0x49b9, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem(0x49ba, (UINT8)val); 
    PC = 0x889B; JUMP; // sstep
case 0x889B:
                                                     mon("         JMP   L87F5                   ; 889B: 7E 87 F5      \n");
    clockticks = clockticks + 4; 
    PC = 0x87f5; 
    JUMP;
    
    // ---------------------------------------------------------------------------
    // End of function sub_87CB
  case 0x889E:
                                                     mon("locret_889E RTS                           ; 889E: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x889F:
                                                     mon("L889F    LDB   #$10                    ; 889F: C6 10         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x10; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x88A1; JUMP; // sstep
case 0x88A1:
                                                     mon("         STB   <$DC                    ; 88A1: D7 DC         \n");
    clockticks = clockticks + 4; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0xdc; 
    wr_mem(ea, val); 
    PC = 0x88A3; JUMP; // sstep
case 0x88A3:
                                                     mon("         JSR   LCD38                   ; 88A3: BD CD 38      \n"); // Trench left side turret calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xa6); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcd38; 
    JUMP;
  case 0x88A6:
                                                     mon("L88A6    LDD   #$F000                  ; 88A6: CC F0 00      \n");
    clockticks = clockticks + 3; 
    A = 0xf0; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88A9; JUMP; // sstep
case 0x88A9:
                                                     mon("         STD   $5E04                   ; 88A9: FD 5E 04      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e04, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e05, B); 
    PC = 0x88AC; JUMP; // sstep
case 0x88AC:
                                                     mon("         LDD   #$00                    ; 88AC: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88AF; JUMP; // sstep
case 0x88AF:
                                                     mon("         STD   $5E02                   ; 88AF: FD 5E 02      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e02, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e03, B); 
    PC = 0x88B2; JUMP; // sstep
case 0x88B2:
                                                     mon("         LDD   <$96                    ; 88B2: DC 96         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0x96); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0x97); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88B4; JUMP; // sstep
case 0x88B4:
                                                     mon("         STD   $5E00                   ; 88B4: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0x88B7; JUMP; // sstep
case 0x88B7:
                                                     mon("         LDD   #$01C0                  ; 88B7: CC 01 C0      \n"); // Point BIC to math $5E00
    clockticks = clockticks + 3; 
    A = 0x01; 
    B = 0xc0; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88BA; JUMP; // sstep
case 0x88BA:
                                                     mon("         STD   $4701                   ; 88BA: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x88BD; JUMP; // sstep
case 0x88BD:
                                                     mon("         LDA   #$67                    ; 88BD: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x88BF; JUMP; // sstep
case 0x88BF:
                                                     mon("         JSR   LCDBA                   ; 88BF: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xc2); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x88C2:
                                                     mon("L88C2    LDD   $5000                   ; 88C2: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88C5; JUMP; // sstep
case 0x88C5:
                                                     mon("         CMPD  #$FE00                  ; 88C5: 10 83 FE 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0xfe00; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x88C9; JUMP; // sstep
case 0x88C9:
                                                     mon("         BGT   L88D0                   ; 88C9: 2E 05         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x88d0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x88CB; JUMP; // sstep
case 0x88CB:
                                                     mon("         LDA   #$00                    ; 88CB: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x88CD; JUMP; // sstep
case 0x88CD:
                                                     mon("         STA   <$95                    ; 88CD: 97 95         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x95; 
    wr_mem(ea, val); 
    PC = 0x88CF; JUMP; // sstep
case 0x88CF:
                                                     mon("         RTS                           ; 88CF: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x88D0:
                                                     mon("L88D0    SUBD  #$7000                  ; 88D0: 83 70 00      \n");
    clockticks = clockticks + 4; 
    val = 0x7000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x88D3; JUMP; // sstep
case 0x88D3:
                                                     mon("         BGT   locret_88F4             ; 88D3: 2E 1F         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x88f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x88D5; JUMP; // sstep
case 0x88D5:
                                                     mon("         LDD   #$A018                  ; 88D5: CC A0 18      \n");
    clockticks = clockticks + 3; 
    A = 0xa0; 
    B = 0x18; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88D8; JUMP; // sstep
case 0x88D8:
                                                     mon("         STD   $5E00                   ; 88D8: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0x88DB; JUMP; // sstep
case 0x88DB:
                                                     mon("         LDD   #$7200                  ; 88DB: CC 72 00      \n");
    clockticks = clockticks + 3; 
    A = 0x72; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88DE; JUMP; // sstep
case 0x88DE:
                                                     mon("         STD   $5E04                   ; 88DE: FD 5E 04      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e04, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e05, B); 
    PC = 0x88E1; JUMP; // sstep
case 0x88E1:
                                                     mon("         LDD   $5000                   ; 88E1: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88E4; JUMP; // sstep
case 0x88E4:
                                                     mon("         SUBD  #$1000                  ; 88E4: 83 10 00      \n");
    clockticks = clockticks + 4; 
    val = 0x1000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x88E7; JUMP; // sstep
case 0x88E7:
                                                     mon("         BGE   L88EE                   ; 88E7: 2C 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x88ee; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x88E9; JUMP; // sstep
case 0x88E9:
                                                     mon("         JSR   LCD5C                   ; 88E9: BD CD 5C      \n"); // Trench calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xec); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcd5c; 
    JUMP;
  case 0x88EC:
                                                     mon("L88EC    BRA   L88F1                   ; 88EC: 20 03         \n");
    PC = 0x88f1; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x88EE:
                                                     mon("L88EE    JSR   LCD50                   ; 88EE: BD CD 50      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcd50; 
    JUMP;
  case 0x88F1:
                                                     mon("L88F1    JSR   LCD74                   ; 88F1: BD CD 74      \n"); // Function select for an object
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf4); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x88); 
    clockticks = clockticks + 1; 
    PC = 0xcd74; 
    JUMP;
    // End of function sub_889F
  case 0x88F4:
                                                     mon("locret_88F4 RTS                           ; 88F4: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x88F5:
                                                     mon("L88F5    LDD   #$6280                  ; 88F5: CC 62 80      \n");
    clockticks = clockticks + 3; 
    A = 0x62; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x88F8; JUMP; // sstep
case 0x88F8:
                                                     mon("         STD   ,Y++                    ; 88F8: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x88FA; JUMP; // sstep
case 0x88FA:
                                                     mon("         LDA   <$92                    ; 88FA: 96 92         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x92); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x88FC; JUMP; // sstep
case 0x88FC:
                                                     mon("         BEQ   locret_8950             ; 88FC: 27 52         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8950; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x88FE; JUMP; // sstep
case 0x88FE:
                                                     mon("         LDD   <$93                    ; 88FE: DC 93         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0x93); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0x94); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8900; JUMP; // sstep
case 0x8900:
                                                     mon("         STD   $5078                   ; 8900: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0x8903; JUMP; // sstep
case 0x8903:
                                                     mon("         SUBD  $5098                   ; 8903: B3 50 98      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5098)<<8; 
    ea = ea | rd_mem(0x5099); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8906; JUMP; // sstep
case 0x8906:
                                                     mon("         SUBD  #$7000                  ; 8906: 83 70 00      \n");
    clockticks = clockticks + 4; 
    val = 0x7000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8909; JUMP; // sstep
case 0x8909:
                                                     mon("         BMI   L8911                   ; 8909: 2B 06         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8911; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x890B; JUMP; // sstep
case 0x890B:
                                                     mon("         COMA                          ; 890B: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0x890C; JUMP; // sstep
case 0x890C:
                                                     mon("         NEGB                          ; 890C: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x890D; JUMP; // sstep
case 0x890D:
                                                     mon("         SBCA  #$FF                    ; 890D: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0x890F; JUMP; // sstep
case 0x890F:
                                                     mon("         BRA   L8914                   ; 890F: 20 03         \n");
    PC = 0x8914; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8911:
                                                     mon("L8911    LDD   #$00                    ; 8911: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8914; JUMP; // sstep
case 0x8914:
                                                     mon("L8914    STD   $507C                   ; 8914: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0x8917; JUMP; // sstep
case 0x8917:
                                                     mon("         LDD   #$FC00                  ; 8917: CC FC 00      \n");
    clockticks = clockticks + 3; 
    A = 0xfc; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x891A; JUMP; // sstep
case 0x891A:
                                                     mon("         STD   $507A                   ; 891A: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x891D; JUMP; // sstep
case 0x891D:
                                                     mon("         LDD   #$0F                    ; 891D: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8920; JUMP; // sstep
case 0x8920:
                                                     mon("         STD   $4701                   ; 8920: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8923; JUMP; // sstep
case 0x8923:
                                                     mon("         LDA   #$67                    ; 8923: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8925; JUMP; // sstep
case 0x8925:
                                                     mon("         JSR   LCDBA                   ; 8925: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x28); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8928:
                                                     mon("L8928    LDD   $5000                   ; 8928: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x892B; JUMP; // sstep
case 0x892B:
                                                     mon("         STD   $4704                   ; 892B: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x892E; JUMP; // sstep
case 0x892E:
                                                     mon("         JSR   LCCE4                   ; 892E: BD CC E4      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x31); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xcce4; 
    JUMP;
  case 0x8931:
                                                     mon("L8931    LDD   #$0400                  ; 8931: CC 04 00      \n");
    clockticks = clockticks + 3; 
    A = 0x04; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8934; JUMP; // sstep
case 0x8934:
                                                     mon("         STD   $507A                   ; 8934: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0x8937; JUMP; // sstep
case 0x8937:
                                                     mon("         LDD   #$0F                    ; 8937: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x893A; JUMP; // sstep
case 0x893A:
                                                     mon("         STD   $4701                   ; 893A: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x893D; JUMP; // sstep
case 0x893D:
                                                     mon("         LDA   #$67                    ; 893D: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x893F; JUMP; // sstep
case 0x893F:
                                                     mon("         JSR   LCDBA                   ; 893F: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x42); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8942:
                                                     mon("L8942    LDD   $5000                   ; 8942: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8945; JUMP; // sstep
case 0x8945:
                                                     mon("         STD   $4704                   ; 8945: FD 47 04      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0x8948; JUMP; // sstep
case 0x8948:
                                                     mon("         JSR   LCCFC                   ; 8948: BD CC FC      \n"); // Trench floor lines calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x4b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xccfc; 
    JUMP;
  case 0x894B:
                                                     mon("L894B    LDD   #$8040                  ; 894B: CC 80 40      \n");
    clockticks = clockticks + 3; 
    A = 0x80; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x894E; JUMP; // sstep
case 0x894E:
                                                     mon("         STD   ,Y++                    ; 894E: ED A1         \n");
    clockticks = clockticks + 7; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    // End of function sub_88F5
    PC = 0x8950; JUMP; // sstep
case 0x8950:
                                                     mon("locret_8950 RTS                           ; 8950: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8951:
                                                     mon("L8951    JSR   L8981                   ; 8951: BD 89 81      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x54); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8981; 
    JUMP;
  case 0x8954:
                                                     mon("L8954    INC   <$4D                    ; 8954: 0C 4D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4d); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x4d, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8951
    PC = 0x8956; JUMP; // sstep
case 0x8956:
                                                     mon("         JMP   L89D3                   ; 8956: 7E 89 D3      \n"); // Space wave pitch
    clockticks = clockticks + 4; 
    PC = 0x89d3; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8959:
                                                     mon("L8959    JSR   L8993                   ; 8959: BD 89 93      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x5c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8993; 
    JUMP;
  case 0x895C:
                                                     mon("L895C    DEC   <$4D                    ; 895C: 0A 4D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4d); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x4d, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8959
    PC = 0x895E; JUMP; // sstep
case 0x895E:
                                                     mon("         JMP   L89D3                   ; 895E: 7E 89 D3      \n"); // Space wave pitch
    clockticks = clockticks + 4; 
    PC = 0x89d3; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8961:
                                                     mon("L8961    JSR   L8993                   ; 8961: BD 89 93      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x64); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8993; 
    JUMP;
  case 0x8964:
                                                     mon("L8964    DEC   <$4E                    ; 8964: 0A 4E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4e); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x4e, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8961
    PC = 0x8966; JUMP; // sstep
case 0x8966:
                                                     mon("         JMP   L89C8                   ; 8966: 7E 89 C8      \n"); // Space wave roll
    clockticks = clockticks + 4; 
    PC = 0x89c8; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8969:
                                                     mon("L8969    JSR   L8981                   ; 8969: BD 89 81      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x6c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8981; 
    JUMP;
  case 0x896C:
                                                     mon("L896C    INC   <$4E                    ; 896C: 0C 4E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4e); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x4e, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8969
    PC = 0x896E; JUMP; // sstep
case 0x896E:
                                                     mon("         JMP   L89C8                   ; 896E: 7E 89 C8      \n"); // Space wave roll
    clockticks = clockticks + 4; 
    PC = 0x89c8; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8971:
                                                     mon("L8971    JSR   L8981                   ; 8971: BD 89 81      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x74); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8981; 
    JUMP;
  case 0x8974:
                                                     mon("L8974    DEC   <$4F                    ; 8974: 0A 4F         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4f); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x4f, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8971
    PC = 0x8976; JUMP; // sstep
case 0x8976:
                                                     mon("         JMP   L89DE                   ; 8976: 7E 89 DE      \n"); // Space wave yaw
    clockticks = clockticks + 4; 
    PC = 0x89de; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Attributes: noreturn
  case 0x8979:
                                                     mon("L8979    JSR   L8993                   ; 8979: BD 89 93      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x7c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0x8993; 
    JUMP;
  case 0x897C:
                                                     mon("L897C    INC   <$4F                    ; 897C: 0C 4F         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4f); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x4f, res); 
    clockticks = clockticks + 2; 
    // End of function sub_8979
    PC = 0x897E; JUMP; // sstep
case 0x897E:
                                                     mon("         JMP   L89DE                   ; 897E: 7E 89 DE      \n"); // Space wave yaw
    clockticks = clockticks + 4; 
    PC = 0x89de; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8981:
                                                     mon("L8981    LDA   #$14                    ; 8981: 86 14         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x14; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8983; JUMP; // sstep
case 0x8983:
                                                     mon("         LDU   #word_89A8              ; 8983: CE 89 A8      \n");
    clockticks = clockticks + 3; 
    U = 0x89a8; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8986; JUMP; // sstep
case 0x8986:
                                                     mon("         LEAU  A,U                     ; 8986: 33 C6         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)A); 
    PC = 0x8988; JUMP; // sstep
case 0x8988:
                                                     mon("         LDD   ,U                      ; 8988: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x898A; JUMP; // sstep
case 0x898A:
                                                     mon("         STD   $5022                   ; 898A: FD 50 22      \n"); // Sine for rotation
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5022, A); // Care needed with I/O space and word fetches
    wr_mem(0x5023, B); 
    PC = 0x898D; JUMP; // sstep
case 0x898D:
                                                     mon("         LDD   $02,U                   ; 898D: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x898F; JUMP; // sstep
case 0x898F:
                                                     mon("         STD   $5024                   ; 898F: FD 50 24      \n"); // Cosine for rotation
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5024, A); // Care needed with I/O space and word fetches
    wr_mem(0x5025, B); 
    // End of function sub_8981
    PC = 0x8992; JUMP; // sstep
case 0x8992:
                                                     mon("         RTS                           ; 8992: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8993:
                                                     mon("L8993    LDA   #$14                    ; 8993: 86 14         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x14; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8995; JUMP; // sstep
case 0x8995:
                                                     mon("         LDU   #word_89A8              ; 8995: CE 89 A8      \n");
    clockticks = clockticks + 3; 
    U = 0x89a8; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8998; JUMP; // sstep
case 0x8998:
                                                     mon("         LEAU  A,U                     ; 8998: 33 C6         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)A); 
    PC = 0x899A; JUMP; // sstep
case 0x899A:
                                                     mon("         LDD   #$00                    ; 899A: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x899D; JUMP; // sstep
case 0x899D:
                                                     mon("         SUBD  ,U                      ; 899D: A3 C4         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x899F; JUMP; // sstep
case 0x899F:
                                                     mon("         STD   $5022                   ; 899F: FD 50 22      \n"); // Sine for rotation
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5022, A); // Care needed with I/O space and word fetches
    wr_mem(0x5023, B); 
    PC = 0x89A2; JUMP; // sstep
case 0x89A2:
                                                     mon("         LDD   $02,U                   ; 89A2: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x89A4; JUMP; // sstep
case 0x89A4:
                                                     mon("         STD   $5024                   ; 89A4: FD 50 24      \n"); // Cosine for rotation
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5024, A); // Care needed with I/O space and word fetches
    wr_mem(0x5025, B); 
    // End of function sub_8993
    // ---------------------------------------------------------------------------
    PC = 0x89A7; JUMP; // sstep
case 0x89A7:
                                                     mon("         RTS                           ; 89A7: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Space wave roll
    // Attributes: noreturn
  case 0x89C8:
                                                     mon("L89C8    CLRA                          ; 89C8: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x89C9; JUMP; // sstep
case 0x89C9:
                                                     mon("         LDB   $02,X                   ; 89C9: E6 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0002)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x89CB; JUMP; // sstep
case 0x89CB:
                                                     mon("         STD   $4701                   ; 89CB: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x89CE; JUMP; // sstep
case 0x89CE:
                                                     mon("         LDA   #$00                    ; 89CE: 86 00         \n"); // Roll
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    // End of function sub_89C8
    PC = 0x89D0; JUMP; // sstep
case 0x89D0:
                                                     mon("         JMP   LCDBA                   ; 89D0: 7E CD BA      \n"); // Do math program run
    clockticks = clockticks + 4; 
    PC = 0xcdba; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Space wave pitch
  case 0x89D3:
                                                     mon("L89D3    CLRA                          ; 89D3: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x89D4; JUMP; // sstep
case 0x89D4:
                                                     mon("         LDB   $02,X                   ; 89D4: E6 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0002)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x89D6; JUMP; // sstep
case 0x89D6:
                                                     mon("         STD   $4701                   ; 89D6: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x89D9; JUMP; // sstep
case 0x89D9:
                                                     mon("         LDA   #$0E                    ; 89D9: 86 0E         \n"); // Pitch
    clockticks = clockticks + 2; 
    val = (UINT8)0x0e; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    // End of function sub_89D3
    PC = 0x89DB; JUMP; // sstep
case 0x89DB:
                                                     mon("         JMP   LCDBA                   ; 89DB: 7E CD BA      \n"); // Do math program run
    clockticks = clockticks + 4; 
    PC = 0xcdba; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Space wave yaw
  case 0x89DE:
                                                     mon("L89DE    CLRA                          ; 89DE: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x89DF; JUMP; // sstep
case 0x89DF:
                                                     mon("         LDB   $02,X                   ; 89DF: E6 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0002)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x89E1; JUMP; // sstep
case 0x89E1:
                                                     mon("         STD   $4701                   ; 89E1: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x89E4; JUMP; // sstep
case 0x89E4:
                                                     mon("         LDA   #$1C                    ; 89E4: 86 1C         \n"); // Yaw
    clockticks = clockticks + 2; 
    val = (UINT8)0x1c; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    // End of function sub_89DE
    PC = 0x89E6; JUMP; // sstep
case 0x89E6:
                                                     mon("         JMP   LCDBA                   ; 89E6: 7E CD BA      \n"); // Do math program run
    clockticks = clockticks + 4; 
    PC = 0xcdba; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x89E9:
                                                     mon("L89E9    LDD   -16,U                   ; 89E9: EC 50         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff0); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x89EB; JUMP; // sstep
case 0x89EB:
                                                     mon("         JSR   Shift_D_R_5             ; 89EB: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xee); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x89EE:
                                                     mon("L89EE    ADDD  -10,U                   ; 89EE: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x89F0; JUMP; // sstep
case 0x89F0:
                                                     mon("         STD   -10,U                   ; 89F0: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x89F2; JUMP; // sstep
case 0x89F2:
                                                     mon("         LDD   -8,U                    ; 89F2: EC 58         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff8); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x89F4; JUMP; // sstep
case 0x89F4:
                                                     mon("         JSR   Shift_D_R_5             ; 89F4: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xf7); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x89); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x89F7:
                                                     mon("L89F7    ADDD  -2,U                    ; 89F7: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x89F9; JUMP; // sstep
case 0x89F9:
                                                     mon("         STD   -2,U                    ; 89F9: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x89FB; JUMP; // sstep
case 0x89FB:
                                                     mon("         LDD   ,U                      ; 89FB: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x89FD; JUMP; // sstep
case 0x89FD:
                                                     mon("         JSR   Shift_D_R_5             ; 89FD: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x00); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A00:
                                                     mon("L8A00    ADDD  $06,U                   ; 8A00: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A02; JUMP; // sstep
case 0x8A02:
                                                     mon("         STD   $06,U                   ; 8A02: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_89E9
    PC = 0x8A04; JUMP; // sstep
case 0x8A04:
                                                     mon("         RTS                           ; 8A04: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8A05:
                                                     mon("L8A05    LDD   -16,U                   ; 8A05: EC 50         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff0); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A07; JUMP; // sstep
case 0x8A07:
                                                     mon("         JSR   Shift_D_R_6             ; 8A07: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x0a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A0A:
                                                     mon("L8A0A    ADDD  -10,U                   ; 8A0A: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A0C; JUMP; // sstep
case 0x8A0C:
                                                     mon("         STD   -10,U                   ; 8A0C: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A0E; JUMP; // sstep
case 0x8A0E:
                                                     mon("         LDD   -8,U                    ; 8A0E: EC 58         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff8); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A10; JUMP; // sstep
case 0x8A10:
                                                     mon("         JSR   Shift_D_R_6             ; 8A10: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x13); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A13:
                                                     mon("L8A13    ADDD  -2,U                    ; 8A13: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A15; JUMP; // sstep
case 0x8A15:
                                                     mon("         STD   -2,U                    ; 8A15: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A17; JUMP; // sstep
case 0x8A17:
                                                     mon("         LDD   ,U                      ; 8A17: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A19; JUMP; // sstep
case 0x8A19:
                                                     mon("         JSR   Shift_D_R_6             ; 8A19: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x1c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A1C:
                                                     mon("L8A1C    ADDD  $06,U                   ; 8A1C: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A1E; JUMP; // sstep
case 0x8A1E:
                                                     mon("         STD   $06,U                   ; 8A1E: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8A05
    PC = 0x8A20; JUMP; // sstep
case 0x8A20:
                                                     mon("         RTS                           ; 8A20: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8A21:
                                                     mon("L8A21    LDD   -12,U                   ; 8A21: EC 54         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff4); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A23; JUMP; // sstep
case 0x8A23:
                                                     mon("         JSR   Shift_D_R_6             ; 8A23: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x26); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A26:
                                                     mon("L8A26    ADDD  -10,U                   ; 8A26: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A28; JUMP; // sstep
case 0x8A28:
                                                     mon("         STD   -10,U                   ; 8A28: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A2A; JUMP; // sstep
case 0x8A2A:
                                                     mon("         LDD   -4,U                    ; 8A2A: EC 5C         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfffc); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A2C; JUMP; // sstep
case 0x8A2C:
                                                     mon("         JSR   Shift_D_R_6             ; 8A2C: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x2f); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A2F:
                                                     mon("L8A2F    ADDD  -2,U                    ; 8A2F: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A31; JUMP; // sstep
case 0x8A31:
                                                     mon("         STD   -2,U                    ; 8A31: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A33; JUMP; // sstep
case 0x8A33:
                                                     mon("         LDD   $04,U                   ; 8A33: EC 44         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A35; JUMP; // sstep
case 0x8A35:
                                                     mon("         JSR   Shift_D_R_6             ; 8A35: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x38); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A38:
                                                     mon("L8A38    ADDD  $06,U                   ; 8A38: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A3A; JUMP; // sstep
case 0x8A3A:
                                                     mon("         STD   $06,U                   ; 8A3A: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8A21
    PC = 0x8A3C; JUMP; // sstep
case 0x8A3C:
                                                     mon("         RTS                           ; 8A3C: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8A3D:
                                                     mon("L8A3D    LDD   -12,U                   ; 8A3D: EC 54         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff4); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A3F; JUMP; // sstep
case 0x8A3F:
                                                     mon("         JSR   Shift_D_R_5             ; 8A3F: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x42); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A42:
                                                     mon("L8A42    ADDD  -10,U                   ; 8A42: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A44; JUMP; // sstep
case 0x8A44:
                                                     mon("         STD   -10,U                   ; 8A44: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A46; JUMP; // sstep
case 0x8A46:
                                                     mon("         LDD   -4,U                    ; 8A46: EC 5C         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfffc); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A48; JUMP; // sstep
case 0x8A48:
                                                     mon("         JSR   Shift_D_R_5             ; 8A48: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x4b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A4B:
                                                     mon("L8A4B    ADDD  -2,U                    ; 8A4B: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A4D; JUMP; // sstep
case 0x8A4D:
                                                     mon("         STD   -2,U                    ; 8A4D: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A4F; JUMP; // sstep
case 0x8A4F:
                                                     mon("         LDD   $04,U                   ; 8A4F: EC 44         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8A51; JUMP; // sstep
case 0x8A51:
                                                     mon("         JSR   Shift_D_R_5             ; 8A51: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x54); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A54:
                                                     mon("L8A54    ADDD  $06,U                   ; 8A54: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A56; JUMP; // sstep
case 0x8A56:
                                                     mon("         STD   $06,U                   ; 8A56: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8A3D
    PC = 0x8A58; JUMP; // sstep
case 0x8A58:
                                                     mon("         RTS                           ; 8A58: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8A59:
                                                     mon("L8A59    LDD   #$00                    ; 8A59: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A5C; JUMP; // sstep
case 0x8A5C:
                                                     mon("         SUBD  -12,U                   ; 8A5C: A3 54         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff4))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff4))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A5E; JUMP; // sstep
case 0x8A5E:
                                                     mon("         JSR   Shift_D_R_6             ; 8A5E: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x61); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A61:
                                                     mon("L8A61    ADDD  -10,U                   ; 8A61: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A63; JUMP; // sstep
case 0x8A63:
                                                     mon("         STD   -10,U                   ; 8A63: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A65; JUMP; // sstep
case 0x8A65:
                                                     mon("         LDD   #$00                    ; 8A65: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A68; JUMP; // sstep
case 0x8A68:
                                                     mon("         SUBD  -4,U                    ; 8A68: A3 5C         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffc))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffc))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A6A; JUMP; // sstep
case 0x8A6A:
                                                     mon("         JSR   Shift_D_R_6             ; 8A6A: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x6d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A6D:
                                                     mon("L8A6D    ADDD  -2,U                    ; 8A6D: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A6F; JUMP; // sstep
case 0x8A6F:
                                                     mon("         STD   -2,U                    ; 8A6F: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A71; JUMP; // sstep
case 0x8A71:
                                                     mon("         LDD   #$00                    ; 8A71: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A74; JUMP; // sstep
case 0x8A74:
                                                     mon("         SUBD  $04,U                   ; 8A74: A3 44         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0004))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0004))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A76; JUMP; // sstep
case 0x8A76:
                                                     mon("         JSR   Shift_D_R_6             ; 8A76: BD CD 9C      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x79); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9c; 
    JUMP;
  case 0x8A79:
                                                     mon("L8A79    ADDD  $06,U                   ; 8A79: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A7B; JUMP; // sstep
case 0x8A7B:
                                                     mon("         STD   $06,U                   ; 8A7B: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8A59
    PC = 0x8A7D; JUMP; // sstep
case 0x8A7D:
                                                     mon("         RTS                           ; 8A7D: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8A7E:
                                                     mon("L8A7E    LDD   #$00                    ; 8A7E: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A81; JUMP; // sstep
case 0x8A81:
                                                     mon("         SUBD  -12,U                   ; 8A81: A3 54         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff4))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff4))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A83; JUMP; // sstep
case 0x8A83:
                                                     mon("         JSR   Shift_D_R_5             ; 8A83: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A86:
                                                     mon("L8A86    ADDD  -10,U                   ; 8A86: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A88; JUMP; // sstep
case 0x8A88:
                                                     mon("         STD   -10,U                   ; 8A88: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A8A; JUMP; // sstep
case 0x8A8A:
                                                     mon("         LDD   #$00                    ; 8A8A: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A8D; JUMP; // sstep
case 0x8A8D:
                                                     mon("         SUBD  -4,U                    ; 8A8D: A3 5C         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffc))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffc))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A8F; JUMP; // sstep
case 0x8A8F:
                                                     mon("         JSR   Shift_D_R_5             ; 8A8F: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x92); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A92:
                                                     mon("L8A92    ADDD  -2,U                    ; 8A92: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8A94; JUMP; // sstep
case 0x8A94:
                                                     mon("         STD   -2,U                    ; 8A94: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8A96; JUMP; // sstep
case 0x8A96:
                                                     mon("         LDD   #$00                    ; 8A96: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8A99; JUMP; // sstep
case 0x8A99:
                                                     mon("         SUBD  $04,U                   ; 8A99: A3 44         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0004))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0004))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8A9B; JUMP; // sstep
case 0x8A9B:
                                                     mon("         JSR   Shift_D_R_5             ; 8A9B: BD CD 9E      \n"); // Shift D register right
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x9e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xcd9e; 
    JUMP;
  case 0x8A9E:
                                                     mon("L8A9E    ADDD  $06,U                   ; 8A9E: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8AA0; JUMP; // sstep
case 0x8AA0:
                                                     mon("         STD   $06,U                   ; 8AA0: ED 46         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8A7E
    // ---------------------------------------------------------------------------
    PC = 0x8AA2; JUMP; // sstep
case 0x8AA2:
                                                     mon("         RTS                           ; 8AA2: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8AB6:
                                                     mon("L8AB6    LDD   -10,U                   ; 8AB6: EC 56         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfff6); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8AB8; JUMP; // sstep
case 0x8AB8:
                                                     mon("         ADDD  $08,U                   ; 8AB8: E3 48         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0008))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0008))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ res) & (val ^ res)) >> 8; 
    N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8ABA; JUMP; // sstep
case 0x8ABA:
                                                     mon("         BVS   L8ABE                   ; 8ABA: 29 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)V <  0) {
    PC = 0x8abe; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8ABC; JUMP; // sstep
case 0x8ABC:
                                                     mon("         STD   $08,U                   ; 8ABC: ED 48         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0008); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8ABE; JUMP; // sstep
case 0x8ABE:
                                                     mon("L8ABE    LDD   -2,U                    ; 8ABE: EC 5E         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0xfffe); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8AC0; JUMP; // sstep
case 0x8AC0:
                                                     mon("         ADDD  $0A,U                   ; 8AC0: E3 4A         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x000a))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x000a))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ res) & (val ^ res)) >> 8; 
    N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8AC2; JUMP; // sstep
case 0x8AC2:
                                                     mon("         BVS   L8AC6                   ; 8AC2: 29 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)V <  0) {
    PC = 0x8ac6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8AC4; JUMP; // sstep
case 0x8AC4:
                                                     mon("         STD   $0A,U                   ; 8AC4: ED 4A         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000a); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8AC6; JUMP; // sstep
case 0x8AC6:
                                                     mon("L8AC6    LDD   $0C,U                   ; 8AC6: EC 4C         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x000c); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8AC8; JUMP; // sstep
case 0x8AC8:
                                                     mon("         ADDD  $06,U                   ; 8AC8: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ res) & (val ^ res)) >> 8; 
    N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8ACA; JUMP; // sstep
case 0x8ACA:
                                                     mon("         BVS   locret_8ACE             ; 8ACA: 29 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)V <  0) {
    PC = 0x8ace; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8ACC; JUMP; // sstep
case 0x8ACC:
                                                     mon("         STD   $0C,U                   ; 8ACC: ED 4C         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x000c); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8AB6
    PC = 0x8ACE; JUMP; // sstep
case 0x8ACE:
                                                     mon("locret_8ACE RTS                           ; 8ACE: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
    // START OF FUNCTION CHUNK FOR sub_B32B
  case 0x8ACF:
                                                     mon("L8ACF    LDX   <$C2                    ; 8ACF: 9E C2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xc2)<<8; 
    ea = ea | rd_mem(DP|0xc3); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8AD1; JUMP; // sstep
case 0x8AD1:
                                                     mon("         LDA   $03,X                   ; 8AD1: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8AD3; JUMP; // sstep
case 0x8AD3:
                                                     mon("         CMPA  #$01                    ; 8AD3: 81 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8AD5; JUMP; // sstep
case 0x8AD5:
                                                     mon("         BNE   locret_8ADB             ; 8AD5: 26 04         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8adb; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8AD7; JUMP; // sstep
case 0x8AD7:
                                                     mon("         LDA   $06,X                   ; 8AD7: A6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8AD9; JUMP; // sstep
case 0x8AD9:
                                                     mon("         BEQ   L8ADC                   ; 8AD9: 27 01         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8adc; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8ADB; JUMP; // sstep
case 0x8ADB:
                                                     mon("locret_8ADB RTS                           ; 8ADB: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8ADC:
                                                     mon("L8ADC    JSR   Gen_Random              ; 8ADC: BD CE 45      \n"); // Update random numbers
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xdf); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0xce45; 
    JUMP;
  case 0x8ADF:
                                                     mon("L8ADF    LDA   $03,X                   ; 8ADF: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8AE1; JUMP; // sstep
case 0x8AE1:
                                                     mon("         CMPA  #$01                    ; 8AE1: 81 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8AE3; JUMP; // sstep
case 0x8AE3:
                                                     mon("         BNE   L8AED                   ; 8AE3: 26 08         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8aed; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8AE5; JUMP; // sstep
case 0x8AE5:
                                                     mon("         LDD   $15,X                   ; 8AE5: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8AE8; JUMP; // sstep
case 0x8AE8:
                                                     mon("         ORB   #$01                    ; 8AE8: CA 01         \n");
    clockticks = clockticks + 2; 
    res = B | (UINT8)0x01; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8AEA; JUMP; // sstep
case 0x8AEA:
                                                     mon("         STD   $15,X                   ; 8AEA: ED 88 15      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8AED; JUMP; // sstep
case 0x8AED:
                                                     mon("L8AED    LDX   <$C2                    ; 8AED: 9E C2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xc2)<<8; 
    ea = ea | rd_mem(DP|0xc3); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8AEF; JUMP; // sstep
case 0x8AEF:
                                                     mon("         INC   $08,X                   ; 8AEF: 6C 08         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0008)); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem((UINT16)(X + 0x0008), res); 
    clockticks = clockticks + 2; 
    PC = 0x8AF1; JUMP; // sstep
case 0x8AF1:
                                                     mon("         DEC   $07,X                   ; 8AF1: 6A 07         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0007)); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem((UINT16)(X + 0x0007), res); 
    clockticks = clockticks + 2; 
    PC = 0x8AF3; JUMP; // sstep
case 0x8AF3:
                                                     mon("         LBLE  L8B57                   ; 8AF3: 10 2F 00 60   \n");
    clockticks = clockticks + 5; 
    if (((SINT8)(N^V) <  0) || (!Z)) {
    clockticks = clockticks + 1; 
    PC = 0x8b57; 
    JUMP;
    }
    PC = 0x8AF7; JUMP; // sstep
case 0x8AF7:
                                                     mon("         LDA   #$05                    ; 8AF7: 86 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x05; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8AF9; JUMP; // sstep
case 0x8AF9:
                                                     mon("         STA   $07,X                   ; 8AF9: A7 07         \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + 0x0007); 
    wr_mem(ea, val); 
    PC = 0x8AFB; JUMP; // sstep
case 0x8AFB:
                                                     mon("         JSR   L97ED                   ; 8AFB: BD 97 ED      \n"); // Vaders tie score
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xfe); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8a); 
    clockticks = clockticks + 1; 
    PC = 0x97ed; 
    JUMP;
  case 0x8AFE:
                                                     mon("L8AFE    LDA   #$1F                    ; 8AFE: 86 1F         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x1f; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B00; JUMP; // sstep
case 0x8B00:
                                                     mon("         STA   $09,X                   ; 8B00: A7 09         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0009); 
    wr_mem(ea, val); 
    PC = 0x8B02; JUMP; // sstep
case 0x8B02:
                                                     mon("         STA   $06,X                   ; 8B02: A7 06         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0006); 
    wr_mem(ea, val); 
    PC = 0x8B04; JUMP; // sstep
case 0x8B04:
                                                     mon("         LDX   #$5090                  ; 8B04: 8E 50 90      \n");
    clockticks = clockticks + 3; 
    X = 0x5090; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8B07; JUMP; // sstep
case 0x8B07:
                                                     mon("         LDU   <$C2                    ; 8B07: DE C2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xc2)<<8; 
    ea = ea | rd_mem(DP|0xc3); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8B09; JUMP; // sstep
case 0x8B09:
                                                     mon("         LDU   ,U                      ; 8B09: EE C4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(U)<<8; 
    ea = ea | rd_mem((UINT16)((U)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8B0B; JUMP; // sstep
case 0x8B0B:
                                                     mon("         LDD   #$00                    ; 8B0B: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8B0E; JUMP; // sstep
case 0x8B0E:
                                                     mon("         STD   -10,U                   ; 8B0E: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B10; JUMP; // sstep
case 0x8B10:
                                                     mon("         STD   -2,U                    ; 8B10: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B12; JUMP; // sstep
case 0x8B12:
                                                     mon("         STD   $06,U                   ; 8B12: ED 46         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B14; JUMP; // sstep
case 0x8B14:
                                                     mon("         LDA   #$02                    ; 8B14: 86 02         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x02; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B16; JUMP; // sstep
case 0x8B16:
                                                     mon("         STA   <$01                    ; 8B16: 97 01         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x01; 
    wr_mem(ea, val); 
    PC = 0x8B18; JUMP; // sstep
case 0x8B18:
                                                     mon("L8B18    LDD   #$4000                  ; 8B18: CC 40 00      \n");
    clockticks = clockticks + 3; 
    A = 0x40; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8B1B; JUMP; // sstep
case 0x8B1B:
                                                     mon("         SUBD  <$C4                    ; 8B1B: 93 C4         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xc4)<<8; 
    ea = ea | rd_mem(DP|0xc5); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8B1D; JUMP; // sstep
case 0x8B1D:
                                                     mon("         LDB   -16,X                   ; 8B1D: E6 10         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0xfff0)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B1F; JUMP; // sstep
case 0x8B1F:
                                                     mon("         MUL                           ; 8B1F: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x8B20; JUMP; // sstep
case 0x8B20:
                                                     mon("         TFR   A,B                     ; 8B20: 1F 89         \n");
    B = (UINT8)A; 
    clockticks = clockticks + 6; 
    PC = 0x8B22; JUMP; // sstep
case 0x8B22:
                                                     mon("         ASLB                          ; 8B22: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8B23; JUMP; // sstep
case 0x8B23:
                                                     mon("         ROLA                          ; 8B23: 49            \n");
    val = (UINT8)A; 
    res = (val << 1) + (C != 0 ?1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)res ^ val; 
    A = (UINT8)res; 
    clockticks = clockticks + 2; 
    PC = 0x8B24; JUMP; // sstep
case 0x8B24:
                                                     mon("         SEX                           ; 8B24: 1D            \n");
/**/Z = B; 
/**/N = B; 
    A = ((SINT8)B < 0 ? 0xff : 0); 
    clockticks = clockticks + 2; 
    PC = 0x8B25; JUMP; // sstep
case 0x8B25:
                                                     mon("         ADDD  -10,U                   ; 8B25: E3 56         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfff6))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfff6))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8B27; JUMP; // sstep
case 0x8B27:
                                                     mon("         STD   -10,U                   ; 8B27: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B29; JUMP; // sstep
case 0x8B29:
                                                     mon("         LDA   <$53                    ; 8B29: 96 53         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x53); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B2B; JUMP; // sstep
case 0x8B2B:
                                                     mon("         ORA   #$80                    ; 8B2B: 8A 80         \n");
    clockticks = clockticks + 2; 
    res = A | (UINT8)0x80; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8B2D; JUMP; // sstep
case 0x8B2D:
                                                     mon("         LDB   -8,X                    ; 8B2D: E6 18         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0xfff8)); 
    B = val; 
    N = val; 
/**/Z = val; 
    V = 0; 
    PC = 0x8B2F; JUMP; // sstep
case 0x8B2F:
                                                     mon("         MUL                           ; 8B2F: 3D            \n");
    res = (UINT16)(A * B); 
    Z = res; 
    C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x8B30; JUMP; // sstep
case 0x8B30:
                                                     mon("         BCS   L8B33                   ; 8B30: 25 01         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8b33; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B32; JUMP; // sstep
case 0x8B32:
                                                     mon("         NEGA                          ; 8B32: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x8B33; JUMP; // sstep
case 0x8B33:
                                                     mon("L8B33    TFR   A,B                     ; 8B33: 1F 89         \n");
    B = (UINT8)A; 
    clockticks = clockticks + 6; 
    PC = 0x8B35; JUMP; // sstep
case 0x8B35:
                                                     mon("         NOP                           ; 8B35: 12            \n");
    clockticks = clockticks + 2; 
    PC = 0x8B36; JUMP; // sstep
case 0x8B36:
                                                     mon("         SEX                           ; 8B36: 1D            \n");
/**/Z = B; 
/**/N = B; 
    A = ((SINT8)B < 0 ? 0xff : 0); 
    clockticks = clockticks + 2; 
    PC = 0x8B37; JUMP; // sstep
case 0x8B37:
                                                     mon("         ADDD  -2,U                    ; 8B37: E3 5E         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8B39; JUMP; // sstep
case 0x8B39:
                                                     mon("         STD   -2,U                    ; 8B39: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B3B; JUMP; // sstep
case 0x8B3B:
                                                     mon("         LDA   <$54                    ; 8B3B: 96 54         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x54); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B3D; JUMP; // sstep
case 0x8B3D:
                                                     mon("         ORA   #$80                    ; 8B3D: 8A 80         \n");
    clockticks = clockticks + 2; 
    res = A | (UINT8)0x80; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8B3F; JUMP; // sstep
case 0x8B3F:
                                                     mon("         LDB   ,X                      ; 8B3F: E6 84         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(X); 
    B = val; 
    N = val; 
/**/Z = val; 
    V = 0; 
    PC = 0x8B41; JUMP; // sstep
case 0x8B41:
                                                     mon("         MUL                           ; 8B41: 3D            \n");
    res = (UINT16)(A * B); 
    Z = res; 
    C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0x8B42; JUMP; // sstep
case 0x8B42:
                                                     mon("         BCS   L8B45                   ; 8B42: 25 01         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8b45; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B44; JUMP; // sstep
case 0x8B44:
                                                     mon("         NEGA                          ; 8B44: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x8B45; JUMP; // sstep
case 0x8B45:
                                                     mon("L8B45    TFR   A,B                     ; 8B45: 1F 89         \n");
    B = (UINT8)A; 
    clockticks = clockticks + 6; 
    PC = 0x8B47; JUMP; // sstep
case 0x8B47:
                                                     mon("L8B47    NOP                           ; 8B47: 12            \n");
    clockticks = clockticks + 2; 
    PC = 0x8B48; JUMP; // sstep
case 0x8B48:
                                                     mon("         SEX                           ; 8B48: 1D            \n");
/**/Z = B; 
/**/N = B; 
    A = ((SINT8)B < 0 ? 0xff : 0); 
    clockticks = clockticks + 2; 
    PC = 0x8B49; JUMP; // sstep
case 0x8B49:
                                                     mon("         ADDD  $06,U                   ; 8B49: E3 46         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0006))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0006))+1)); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8B4B; JUMP; // sstep
case 0x8B4B:
                                                     mon("         STD   $06,U                   ; 8B4B: ED 46         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8B4D; JUMP; // sstep
case 0x8B4D:
                                                     mon("         LEAX  $02,X                   ; 8B4D: 30 02         \n");
    clockticks = clockticks + 5; 
    X = (X + 0x0002); 
/**/Z = X; 
    PC = 0x8B4F; JUMP; // sstep
case 0x8B4F:
                                                     mon("         DEC   <$01                    ; 8B4F: 0A 01         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x01); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x01, res); 
    clockticks = clockticks + 2; 
    PC = 0x8B51; JUMP; // sstep
case 0x8B51:
                                                     mon("         BPL   L8B18                   ; 8B51: 2A C5         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x8b18; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B53; JUMP; // sstep
case 0x8B53:
                                                     mon("         JSR   Sound_35                ; 8B53: BD BD FD      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x56); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0xbdfd; 
    JUMP;
  case 0x8B56:
                                                     mon("L8B56    RTS                           ; 8B56: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8B57:
                                                     mon("L8B57    LDX   <$C2                    ; 8B57: 9E C2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xc2)<<8; 
    ea = ea | rd_mem(DP|0xc3); 
    X = ea; 
    Z = X; 
    N = (X) >> 8; 
    V = 0; 
    PC = 0x8B59; JUMP; // sstep
case 0x8B59:
                                                     mon("         JSR   Sound_35                ; 8B59: BD BD FD      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x5c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0xbdfd; 
    JUMP;
  case 0x8B5C:
                                                     mon("L8B5C    LDA   $02,X                   ; 8B5C: A6 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0002)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B5E; JUMP; // sstep
case 0x8B5E:
                                                     mon("         CMPA  $4B38                   ; 8B5E: B1 4B 38      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem(0x4b38); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8B61; JUMP; // sstep
case 0x8B61:
                                                     mon("         BNE   L8B66                   ; 8B61: 26 03         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8b66; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B63; JUMP; // sstep
case 0x8B63:
                                                     mon("         JSR   Sound_2B                ; 8B63: BD BD CB      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x66); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0xbdcb; 
    JUMP;
  case 0x8B66:
                                                     mon("L8B66    JSR   LB739                   ; 8B66: BD B7 39      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x69); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0xb739; 
    JUMP;
  case 0x8B69:
                                                     mon("L8B69    JSR   L97E8                   ; 8B69: BD 97 E8      \n"); // Tie fighter score
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x6c); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0x97e8; 
    JUMP;
    // END OF FUNCTION CHUNK FOR sub_B32B
  case 0x8B6C:
                                                     mon("L8B6C    RTS                           ; 8B6C: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8B6D:
                                                     mon("L8B6D    LDX   #$4900                  ; 8B6D: 8E 49 00      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 3; 
    X = 0x4900; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8B70; JUMP; // sstep
case 0x8B70:
                                                     mon("L8B70    STX   <$5A                    ; 8B70: 9F 5A         \n");
    clockticks = clockticks + 4; 
    val = X; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0x5a; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8B72; JUMP; // sstep
case 0x8B72:
                                                     mon("         LDU   ,X                      ; 8B72: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8B74; JUMP; // sstep
case 0x8B74:
                                                     mon("         LDA   $03,X                   ; 8B74: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8B76; JUMP; // sstep
case 0x8B76:
                                                     mon("         BEQ   L8B7B                   ; 8B76: 27 03         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8b7b; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B78; JUMP; // sstep
case 0x8B78:
                                                     mon("         JSR   L8BE1                   ; 8B78: BD 8B E1      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x7b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0x8be1; 
    JUMP;
  case 0x8B7B:
                                                     mon("L8B7B    LDX   <$5A                    ; 8B7B: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8B7D; JUMP; // sstep
case 0x8B7D:
                                                     mon("         LEAX  $19,X                   ; 8B7D: 30 88 19      \n");
    clockticks = clockticks + 5; 
    X = (X + (SINT8)0x19); 
/**/Z = X; 
    PC = 0x8B80; JUMP; // sstep
case 0x8B80:
                                                     mon("         CMPX  #$494B                  ; 8B80: 8C 49 4B      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x494b; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8B83; JUMP; // sstep
case 0x8B83:
                                                     mon("         BCS   L8B70                   ; 8B83: 25 EB         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8b70; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    // End of function sub_8B6D
    PC = 0x8B85; JUMP; // sstep
case 0x8B85:
                                                     mon("         RTS                           ; 8B85: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8B86:
                                                     mon("L8B86    LDX   #$4900                  ; 8B86: 8E 49 00      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 3; 
    X = 0x4900; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8B89; JUMP; // sstep
case 0x8B89:
                                                     mon("L8B89    STX   <$5A                    ; 8B89: 9F 5A         \n");
    clockticks = clockticks + 4; 
    val = X; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0x5a; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8B8B; JUMP; // sstep
case 0x8B8B:
                                                     mon("         LDU   ,X                      ; 8B8B: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8B8D; JUMP; // sstep
case 0x8B8D:
                                                     mon("         LDA   $03,X                   ; 8B8D: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B8F; JUMP; // sstep
case 0x8B8F:
                                                     mon("         CMPA  #$01                    ; 8B8F: 81 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8B91; JUMP; // sstep
case 0x8B91:
                                                     mon("         BNE   L8BD6                   ; 8B91: 26 43         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8bd6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B93; JUMP; // sstep
case 0x8B93:
                                                     mon("         LDA   $0A,U                   ; 8B93: A6 4A         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x000a)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8B95; JUMP; // sstep
case 0x8B95:
                                                     mon("         CMPA  #$09                    ; 8B95: 81 09         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x09; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8B97; JUMP; // sstep
case 0x8B97:
                                                     mon("         BLT   L8B9B                   ; 8B97: 2D 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8b9b; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B99; JUMP; // sstep
case 0x8B99:
                                                     mon("         SUBA  #$02                    ; 8B99: 80 02         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x02; 
    res = val - (UINT8)arg; 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)(res); 
    PC = 0x8B9B; JUMP; // sstep
case 0x8B9B:
                                                     mon("L8B9B    CMPA  #$F7                    ; 8B9B: 81 F7         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xf7; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8B9D; JUMP; // sstep
case 0x8B9D:
                                                     mon("         BGT   L8BA1                   ; 8B9D: 2E 02         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8ba1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8B9F; JUMP; // sstep
case 0x8B9F:
                                                     mon("         ADDA  #$02                    ; 8B9F: 8B 02         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x02; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x8BA1; JUMP; // sstep
case 0x8BA1:
                                                     mon("L8BA1    STA   $0A,U                   ; 8BA1: A7 4A         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000a); 
    wr_mem(ea, val); 
    PC = 0x8BA3; JUMP; // sstep
case 0x8BA3:
                                                     mon("         LDA   $0C,U                   ; 8BA3: A6 4C         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x000c)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BA5; JUMP; // sstep
case 0x8BA5:
                                                     mon("         CMPA  #$09                    ; 8BA5: 81 09         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x09; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8BA7; JUMP; // sstep
case 0x8BA7:
                                                     mon("         BLT   L8BAB                   ; 8BA7: 2D 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8bab; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BA9; JUMP; // sstep
case 0x8BA9:
                                                     mon("         SUBA  #$03                    ; 8BA9: 80 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)(res); 
    PC = 0x8BAB; JUMP; // sstep
case 0x8BAB:
                                                     mon("L8BAB    CMPA  #$F7                    ; 8BAB: 81 F7         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xf7; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8BAD; JUMP; // sstep
case 0x8BAD:
                                                     mon("         BGT   L8BB1                   ; 8BAD: 2E 02         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8bb1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BAF; JUMP; // sstep
case 0x8BAF:
                                                     mon("         ADDA  #$03                    ; 8BAF: 8B 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x03; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x8BB1; JUMP; // sstep
case 0x8BB1:
                                                     mon("L8BB1    STA   $0C,U                   ; 8BB1: A7 4C         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000c); 
    wr_mem(ea, val); 
    PC = 0x8BB3; JUMP; // sstep
case 0x8BB3:
                                                     mon("         LDD   $08,U                   ; 8BB3: EC 48         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0008); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8BB5; JUMP; // sstep
case 0x8BB5:
                                                     mon("         ADDD  #$0400                  ; 8BB5: C3 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ res) & (val ^ res)) >> 8; 
    N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8BB8; JUMP; // sstep
case 0x8BB8:
                                                     mon("         BVS   L8BBE                   ; 8BB8: 29 04         \n");
    // temp fix to ensure flags synched
    if ((SINT8)V <  0) {
    PC = 0x8bbe; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BBA; JUMP; // sstep
case 0x8BBA:
                                                     mon("         STD   $08,U                   ; 8BBA: ED 48         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0008); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8BBC; JUMP; // sstep
case 0x8BBC:
                                                     mon("         BRA   L8BD6                   ; 8BBC: 20 18         \n");
    PC = 0x8bd6; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8BBE:
                                                     mon("L8BBE    LDA   $0A,U                   ; 8BBE: A6 4A         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x000a)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BC0; JUMP; // sstep
case 0x8BC0:
                                                     mon("         TSTA                          ; 8BC0: 4D            \n");
    val = (UINT8)A; 
    Z = val; 
    N = val; 
    V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8BC1; JUMP; // sstep
case 0x8BC1:
                                                     mon("         BPL   L8BC4                   ; 8BC1: 2A 01         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x8bc4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BC3; JUMP; // sstep
case 0x8BC3:
                                                     mon("         NEGA                          ; 8BC3: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x8BC4; JUMP; // sstep
case 0x8BC4:
                                                     mon("L8BC4    CMPA  #$08                    ; 8BC4: 81 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x08; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8BC6; JUMP; // sstep
case 0x8BC6:
                                                     mon("         BGT   L8BD6                   ; 8BC6: 2E 0E         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8bd6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BC8; JUMP; // sstep
case 0x8BC8:
                                                     mon("         LDA   $0C,U                   ; 8BC8: A6 4C         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x000c)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BCA; JUMP; // sstep
case 0x8BCA:
                                                     mon("         TSTA                          ; 8BCA: 4D            \n");
    val = (UINT8)A; 
    Z = val; 
    N = val; 
    V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8BCB; JUMP; // sstep
case 0x8BCB:
                                                     mon("         BPL   L8BCE                   ; 8BCB: 2A 01         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x8bce; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BCD; JUMP; // sstep
case 0x8BCD:
                                                     mon("         NEGA                          ; 8BCD: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0x8BCE; JUMP; // sstep
case 0x8BCE:
                                                     mon("L8BCE    CMPA  #$08                    ; 8BCE: 81 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x08; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8BD0; JUMP; // sstep
case 0x8BD0:
                                                     mon("         BGT   L8BD6                   ; 8BD0: 2E 04         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8bd6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8BD2; JUMP; // sstep
case 0x8BD2:
                                                     mon("         LDA   #$00                    ; 8BD2: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BD4; JUMP; // sstep
case 0x8BD4:
                                                     mon("         STA   $03,X                   ; 8BD4: A7 03         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0003); 
    wr_mem(ea, val); 
    PC = 0x8BD6; JUMP; // sstep
case 0x8BD6:
                                                     mon("L8BD6    LDX   <$5A                    ; 8BD6: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8BD8; JUMP; // sstep
case 0x8BD8:
                                                     mon("         LEAX  $19,X                   ; 8BD8: 30 88 19      \n");
    clockticks = clockticks + 5; 
    X = (X + (SINT8)0x19); 
/**/Z = X; 
    PC = 0x8BDB; JUMP; // sstep
case 0x8BDB:
                                                     mon("         CMPX  #$494B                  ; 8BDB: 8C 49 4B      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x494b; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8BDE; JUMP; // sstep
case 0x8BDE:
                                                     mon("         BCS   L8B89                   ; 8BDE: 25 A9         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8b89; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    // End of function sub_8B86
    PC = 0x8BE0; JUMP; // sstep
case 0x8BE0:
                                                     mon("         RTS                           ; 8BE0: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8BE1:
                                                     mon("L8BE1    JSR   L8E3A                   ; 8BE1: BD 8E 3A      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe4); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8b); 
    clockticks = clockticks + 1; 
    PC = 0x8e3a; 
    JUMP;
  case 0x8BE4:
                                                     mon("L8BE4    LDD   #$00                    ; 8BE4: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8BE7; JUMP; // sstep
case 0x8BE7:
                                                     mon("         STA   <$4C                    ; 8BE7: 97 4C         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x4c; 
    wr_mem(ea, val); 
    PC = 0x8BE9; JUMP; // sstep
case 0x8BE9:
                                                     mon("         STA   <$4E                    ; 8BE9: 97 4E         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x4e; 
    wr_mem(ea, val); 
    PC = 0x8BEB; JUMP; // sstep
case 0x8BEB:
                                                     mon("         STA   <$4D                    ; 8BEB: 97 4D         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x4d; 
    wr_mem(ea, val); 
    PC = 0x8BED; JUMP; // sstep
case 0x8BED:
                                                     mon("         STA   <$4F                    ; 8BED: 97 4F         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x4f; 
    wr_mem(ea, val); 
    PC = 0x8BEF; JUMP; // sstep
case 0x8BEF:
                                                     mon("         LDA   $15,X                   ; 8BEF: A6 88 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x15)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BF2; JUMP; // sstep
case 0x8BF2:
                                                     mon("         ANDA  #$10                    ; 8BF2: 84 10         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x10; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8BF4; JUMP; // sstep
case 0x8BF4:
                                                     mon("         LDB   $4703                   ; 8BF4: F6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BF7; JUMP; // sstep
case 0x8BF7:
                                                     mon("         ANDB  #$30                    ; 8BF7: C4 30         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    res = val & (SINT8)0x30; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8BF9; JUMP; // sstep
case 0x8BF9:
                                                     mon("         STD   $15,X                   ; 8BF9: ED 88 15      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8BFC; JUMP; // sstep
case 0x8BFC:
                                                     mon("         LDA   $09,X                   ; 8BFC: A6 09         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0009)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8BFE; JUMP; // sstep
case 0x8BFE:
                                                     mon("         DECA                          ; 8BFE: 4A            \n");
    val = (UINT8)A; 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x8BFF; JUMP; // sstep
case 0x8BFF:
                                                     mon("         BMI   L8C15                   ; 8BFF: 2B 14         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8c15; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C01; JUMP; // sstep
case 0x8C01:
                                                     mon("         STA   $09,X                   ; 8C01: A7 09         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0009); 
    wr_mem(ea, val); 
    PC = 0x8C03; JUMP; // sstep
case 0x8C03:
                                                     mon("         LDD   #$1640                  ; 8C03: CC 16 40      \n");
    clockticks = clockticks + 3; 
    A = 0x16; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C06; JUMP; // sstep
case 0x8C06:
                                                     mon("         STD   $5022                   ; 8C06: FD 50 22      \n"); // Sine for rotation
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5022, A); // Care needed with I/O space and word fetches
    wr_mem(0x5023, B); 
    PC = 0x8C09; JUMP; // sstep
case 0x8C09:
                                                     mon("         LDD   #$3C02                  ; 8C09: CC 3C 02      \n");
    clockticks = clockticks + 3; 
    A = 0x3c; 
    B = 0x02; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C0C; JUMP; // sstep
case 0x8C0C:
                                                     mon("         STD   $5024                   ; 8C0C: FD 50 24      \n"); // Cosine for rotation
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5024, A); // Care needed with I/O space and word fetches
    wr_mem(0x5025, B); 
    PC = 0x8C0F; JUMP; // sstep
case 0x8C0F:
                                                     mon("         JSR   L89C8                   ; 8C0F: BD 89 C8      \n"); // Space wave roll
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x12); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x89c8; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C12:
                                                     mon("L8C12    JMP   L8C44                   ; 8C12: 7E 8C 44      \n");
    clockticks = clockticks + 4; 
    PC = 0x8c44; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8C15:
                                                     mon("L8C15    LDB   $11,X                   ; 8C15: E6 88 11      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x11)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8C18; JUMP; // sstep
case 0x8C18:
                                                     mon("         STB   <$50                    ; 8C18: D7 50         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
    V = 0; 
    ea = DP|0x50; 
    wr_mem(ea, val); 
    PC = 0x8C1A; JUMP; // sstep
case 0x8C1A:
                                                     mon("         LSR   <$50                    ; 8C1A: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C1C; JUMP; // sstep
case 0x8C1C:
                                                     mon("         BCC   L8C21                   ; 8C1C: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c21; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C1E; JUMP; // sstep
case 0x8C1E:
                                                     mon("         JSR   L8961                   ; 8C1E: BD 89 61      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x21); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8961; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C21:
                                                     mon("L8C21    LSR   <$50                    ; 8C21: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C23; JUMP; // sstep
case 0x8C23:
                                                     mon("         BCC   L8C28                   ; 8C23: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c28; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C25; JUMP; // sstep
case 0x8C25:
                                                     mon("         JSR   L8969                   ; 8C25: BD 89 69      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x28); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8969; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C28:
                                                     mon("L8C28    LSR   <$50                    ; 8C28: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C2A; JUMP; // sstep
case 0x8C2A:
                                                     mon("         BCC   L8C2F                   ; 8C2A: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c2f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C2C; JUMP; // sstep
case 0x8C2C:
                                                     mon("         JSR   L8951                   ; 8C2C: BD 89 51      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x2f); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8951; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C2F:
                                                     mon("L8C2F    LSR   <$50                    ; 8C2F: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C31; JUMP; // sstep
case 0x8C31:
                                                     mon("         BCC   L8C36                   ; 8C31: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c36; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C33; JUMP; // sstep
case 0x8C33:
                                                     mon("         JSR   L8959                   ; 8C33: BD 89 59      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x36); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8959; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C36:
                                                     mon("L8C36    LSR   <$50                    ; 8C36: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C38; JUMP; // sstep
case 0x8C38:
                                                     mon("         BCC   L8C3D                   ; 8C38: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c3d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C3A; JUMP; // sstep
case 0x8C3A:
                                                     mon("         JSR   L8979                   ; 8C3A: BD 89 79      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x3d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8979; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C3D:
                                                     mon("L8C3D    LSR   <$50                    ; 8C3D: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8C3F; JUMP; // sstep
case 0x8C3F:
                                                     mon("         BCC   L8C44                   ; 8C3F: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8c44; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C41; JUMP; // sstep
case 0x8C41:
                                                     mon("         JSR   L8971                   ; 8C41: BD 89 71      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x44); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8971; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8C44:
                                                     mon("L8C44    JSR   L8D9D                   ; 8C44: BD 8D 9D      \n"); // Some tie fighters process
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x47); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8d9d; 
    JUMP;
  case 0x8C47:
                                                     mon("L8C47    JSR   L8DE3                   ; 8C47: BD 8D E3      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x4a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0x8de3; 
    JUMP;
  case 0x8C4A:
                                                     mon("L8C4A    LDA   $03,X                   ; 8C4A: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8C4C; JUMP; // sstep
case 0x8C4C:
                                                     mon("         CMPA  #$01                    ; 8C4C: 81 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8C4E; JUMP; // sstep
case 0x8C4E:
                                                     mon("         LBNE  L8D66                   ; 8C4E: 10 26 01 14   \n");
    clockticks = clockticks + 5; 
    if (Z) {
    clockticks = clockticks + 1; 
    PC = 0x8d66; 
    JUMP;
    }
    PC = 0x8C52; JUMP; // sstep
case 0x8C52:
                                                     mon("         LDA   $02,X                   ; 8C52: A6 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0002)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8C54; JUMP; // sstep
case 0x8C54:
                                                     mon("         JSR   LCE0C                   ; 8C54: BD CE 0C      \n"); // Copy transform data from [BIC] to matrix 2
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x57); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0xce0c; 
    JUMP;
  case 0x8C57:
                                                     mon("L8C57    LDX   <$5A                    ; 8C57: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8C59; JUMP; // sstep
case 0x8C59:
                                                     mon("         CLR   $0A,X                   ; 8C59: 6F 0A         \n");
    clockticks = clockticks + 5; 
    wr_mem((UINT16)(X + 0x000a), 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
/**/C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8C5B; JUMP; // sstep
case 0x8C5B:
                                                     mon("         CLRA                          ; 8C5B: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8C5C; JUMP; // sstep
case 0x8C5C:
                                                     mon("         LDB   #$13                    ; 8C5C: C6 13         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x13; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8C5E; JUMP; // sstep
case 0x8C5E:
                                                     mon("         STD   $4701                   ; 8C5E: FD 47 01      \n"); // Point BIC to $5098 MReg4C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0x8C61; JUMP; // sstep
case 0x8C61:
                                                     mon("         LDA   $11,X                   ; 8C61: A6 88 11      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x11)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8C64; JUMP; // sstep
case 0x8C64:
                                                     mon("         BITA  #$40                    ; 8C64: 85 40         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x40; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8C66; JUMP; // sstep
case 0x8C66:
                                                     mon("         BEQ   L8C81                   ; 8C66: 27 19         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8c81; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C68; JUMP; // sstep
case 0x8C68:
                                                     mon("         LDD   $5098                   ; 8C68: FC 50 98      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5098); // Care needed with I/O space and word fetches
    B = rd_mem(0x5099); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C6B; JUMP; // sstep
case 0x8C6B:
                                                     mon("         ADDD  #$1000                  ; 8C6B: C3 10 00      \n");
    clockticks = clockticks + 4; 
    val = 0x1000; 
    arg = (A << 8) | B; 
    res = arg + val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8C6E; JUMP; // sstep
case 0x8C6E:
                                                     mon("         STD   $5098                   ; 8C6E: FD 50 98      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5098, A); // Care needed with I/O space and word fetches
    wr_mem(0x5099, B); 
    PC = 0x8C71; JUMP; // sstep
case 0x8C71:
                                                     mon("         LDA   #$67                    ; 8C71: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8C73; JUMP; // sstep
case 0x8C73:
                                                     mon("         JSR   LCDBA                   ; 8C73: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x76); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8C76:
                                                     mon("L8C76    LDD   $5098                   ; 8C76: FC 50 98      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5098); // Care needed with I/O space and word fetches
    B = rd_mem(0x5099); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C79; JUMP; // sstep
case 0x8C79:
                                                     mon("         SUBD  #$1000                  ; 8C79: 83 10 00      \n");
    clockticks = clockticks + 4; 
    val = 0x1000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8C7C; JUMP; // sstep
case 0x8C7C:
                                                     mon("         STD   $5098                   ; 8C7C: FD 50 98      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5098, A); // Care needed with I/O space and word fetches
    wr_mem(0x5099, B); 
    PC = 0x8C7F; JUMP; // sstep
case 0x8C7F:
                                                     mon("         BRA   L8C86                   ; 8C7F: 20 05         \n");
    PC = 0x8c86; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8C81:
                                                     mon("L8C81    LDA   #$67                    ; 8C81: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8C83; JUMP; // sstep
case 0x8C83:
                                                     mon("         JSR   LCDBA                   ; 8C83: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x86); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0x8C86:
                                                     mon("L8C86    LDD   $5000                   ; 8C86: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8C89; JUMP; // sstep
case 0x8C89:
                                                     mon("         BMI   L8CAE                   ; 8C89: 2B 23         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8cae; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C8B; JUMP; // sstep
case 0x8C8B:
                                                     mon("         INC   $0A,X                   ; 8C8B: 6C 0A         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x000a)); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem((UINT16)(X + 0x000a), res); 
    clockticks = clockticks + 2; 
    PC = 0x8C8D; JUMP; // sstep
case 0x8C8D:
                                                     mon("         SUBD  #$4000                  ; 8C8D: 83 40 00      \n");
    clockticks = clockticks + 4; 
    val = 0x4000; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8C90; JUMP; // sstep
case 0x8C90:
                                                     mon("         BGE   L8CAE                   ; 8C90: 2C 1C         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x8cae; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8C92; JUMP; // sstep
case 0x8C92:
                                                     mon("         LDD   $15,X                   ; 8C92: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C95; JUMP; // sstep
case 0x8C95:
                                                     mon("         ORB   #$08                    ; 8C95: CA 08         \n");
    clockticks = clockticks + 2; 
    res = B | (UINT8)0x08; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8C97; JUMP; // sstep
case 0x8C97:
                                                     mon("         STD   $15,X                   ; 8C97: ED 88 15      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8C9A; JUMP; // sstep
case 0x8C9A:
                                                     mon("         LDD   $5072                   ; 8C9A: FC 50 72      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5072); // Care needed with I/O space and word fetches
    B = rd_mem(0x5073); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8C9D; JUMP; // sstep
case 0x8C9D:
                                                     mon("         ADDD  $5074                   ; 8C9D: F3 50 74      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5074)<<8; 
    ea = ea | rd_mem(0x5075); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0x8CA0; JUMP; // sstep
case 0x8CA0:
                                                     mon("         CMPD  #$20                    ; 8CA0: 10 83 00 20   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x0020; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8CA4; JUMP; // sstep
case 0x8CA4:
                                                     mon("         BHI   L8CAE                   ; 8CA4: 22 08         \n");
    // temp fix to ensure flags synched
    if (Z && (!C)) {
    PC = 0x8cae; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CA6; JUMP; // sstep
case 0x8CA6:
                                                     mon("         LDD   $15,X                   ; 8CA6: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8CA9; JUMP; // sstep
case 0x8CA9:
                                                     mon("         ORB   #$04                    ; 8CA9: CA 04         \n");
    clockticks = clockticks + 2; 
    res = B | (UINT8)0x04; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8CAB; JUMP; // sstep
case 0x8CAB:
                                                     mon("         STD   $15,X                   ; 8CAB: ED 88 15      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8CAE; JUMP; // sstep
case 0x8CAE:
                                                     mon("L8CAE    LDD   $15,X                   ; 8CAE: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8CB1; JUMP; // sstep
case 0x8CB1:
                                                     mon("         BITA  #$10                    ; 8CB1: 85 10         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x10; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8CB3; JUMP; // sstep
case 0x8CB3:
                                                     mon("         BEQ   L8D05                   ; 8CB3: 27 50         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CB5; JUMP; // sstep
case 0x8CB5:
                                                     mon("         LDD   $11,X                   ; 8CB5: EC 88 11      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x11); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8CB8; JUMP; // sstep
case 0x8CB8:
                                                     mon("         BITA  #$40                    ; 8CB8: 85 40         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x40; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8CBA; JUMP; // sstep
case 0x8CBA:
                                                     mon("         BNE   L8D05                   ; 8CBA: 26 49         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CBC; JUMP; // sstep
case 0x8CBC:
                                                     mon("         LDD   $5000                   ; 8CBC: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8CBF; JUMP; // sstep
case 0x8CBF:
                                                     mon("         SUBD  #$0800                  ; 8CBF: 83 08 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0800; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0x8CC2; JUMP; // sstep
case 0x8CC2:
                                                     mon("         BLE   L8D05                   ; 8CC2: 2F 41         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) <  0) || (!Z)) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CC4; JUMP; // sstep
case 0x8CC4:
                                                     mon("         LDA   $06,X                   ; 8CC4: A6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8CC6; JUMP; // sstep
case 0x8CC6:
                                                     mon("         BNE   L8D05                   ; 8CC6: 26 3D         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CC8; JUMP; // sstep
case 0x8CC8:
                                                     mon("         LDB   $4B19                   ; 8CC8: F6 4B 19      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b19); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8CCB; JUMP; // sstep
case 0x8CCB:
                                                     mon("         CMPB  #$0B                    ; 8CCB: C1 0B         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x0b; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8CCD; JUMP; // sstep
case 0x8CCD:
                                                     mon("         BCS   L8CD4                   ; 8CCD: 25 05         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8cd4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CCF; JUMP; // sstep
case 0x8CCF:
                                                     mon("         LDU   #byte_8D99              ; 8CCF: CE 8D 99      \n");
    clockticks = clockticks + 3; 
    U = 0x8d99; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8CD2; JUMP; // sstep
case 0x8CD2:
                                                     mon("         BRA   L8CDB                   ; 8CD2: 20 07         \n");
    PC = 0x8cdb; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8CD4:
                                                     mon("L8CD4    ASLB                          ; 8CD4: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8CD5; JUMP; // sstep
case 0x8CD5:
                                                     mon("         ASLB                          ; 8CD5: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8CD6; JUMP; // sstep
case 0x8CD6:
                                                     mon("         LDU   #byte_8D71              ; 8CD6: CE 8D 71      \n");
    clockticks = clockticks + 3; 
    U = 0x8d71; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8CD9; JUMP; // sstep
case 0x8CD9:
                                                     mon("         LEAU  B,U                     ; 8CD9: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0x8CDB; JUMP; // sstep
case 0x8CDB:
                                                     mon("L8CDB    LDA   <$43                    ; 8CDB: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8CDD; JUMP; // sstep
case 0x8CDD:
                                                     mon("         ANDA  ,U                      ; 8CDD: A4 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    res = val & rd_mem(U); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8CDF; JUMP; // sstep
case 0x8CDF:
                                                     mon("         BNE   L8D05                   ; 8CDF: 26 24         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CE1; JUMP; // sstep
case 0x8CE1:
                                                     mon("         LDA   $4703                   ; 8CE1: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8CE4; JUMP; // sstep
case 0x8CE4:
                                                     mon("         CMPA  $01,U                   ; 8CE4: A1 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem((UINT16)(U + 0x0001)); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8CE6; JUMP; // sstep
case 0x8CE6:
                                                     mon("         BLS   L8D05                   ; 8CE6: 23 1D         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x8d05; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CE8; JUMP; // sstep
case 0x8CE8:
                                                     mon("         LDU   $02,U                   ; 8CE8: EE 42         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0002))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0002))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8CEA; JUMP; // sstep
case 0x8CEA:
                                                     mon("L8CEA    LDA   $03,U                   ; 8CEA: A6 43         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0003)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8CEC; JUMP; // sstep
case 0x8CEC:
                                                     mon("         BNE   L8CFD                   ; 8CEC: 26 0F         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8cfd; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8CEE; JUMP; // sstep
case 0x8CEE:
                                                     mon("         LDX   <$5A                    ; 8CEE: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8CF0; JUMP; // sstep
case 0x8CF0:
                                                     mon("         LDD   $15,X                   ; 8CF0: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8CF3; JUMP; // sstep
case 0x8CF3:
                                                     mon("         ORB   #$40                    ; 8CF3: CA 40         \n");
    clockticks = clockticks + 2; 
    res = B | (UINT8)0x40; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8CF5; JUMP; // sstep
case 0x8CF5:
                                                     mon("         STD   $15,X                   ; 8CF5: ED 88 15      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8CF8; JUMP; // sstep
case 0x8CF8:
                                                     mon("         JSR   LA68B                   ; 8CF8: BD A6 8B      \n"); // Emit fireballs from tie fighters
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xfb); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8c); 
    clockticks = clockticks + 1; 
    PC = 0xa68b; 
    JUMP;
  case 0x8CFB:
                                                     mon("L8CFB    BRA   L8D05                   ; 8CFB: 20 08         \n");
    PC = 0x8d05; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8CFD:
                                                     mon("L8CFD    LEAU  $06,U                   ; 8CFD: 33 46         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0006); 
    PC = 0x8CFF; JUMP; // sstep
case 0x8CFF:
                                                     mon("         CMPU  #$496F                  ; 8CFF: 11 83 49 6F   \n"); // 6x Fireball data structure 2 ($6 bytes per fireball)
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x496f; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8D03; JUMP; // sstep
case 0x8D03:
                                                     mon("         BCS   L8CEA                   ; 8D03: 25 E5         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8cea; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D05; JUMP; // sstep
case 0x8D05:
                                                     mon("L8D05    LDX   <$5A                    ; 8D05: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8D07; JUMP; // sstep
case 0x8D07:
                                                     mon("         LDA   $11,X                   ; 8D07: A6 88 11      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x11)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8D0A; JUMP; // sstep
case 0x8D0A:
                                                     mon("         BITA  #$80                    ; 8D0A: 85 80         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x80; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8D0C; JUMP; // sstep
case 0x8D0C:
                                                     mon("         BEQ   L8D66                   ; 8D0C: 27 58         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8d66; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D0E; JUMP; // sstep
case 0x8D0E:
                                                     mon("         LDA   <$4F                    ; 8D0E: 96 4F         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4f); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D10; JUMP; // sstep
case 0x8D10:
                                                     mon("         BNE   L8D3A                   ; 8D10: 26 28         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d3a; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D12; JUMP; // sstep
case 0x8D12:
                                                     mon("         LDA   $5002                   ; 8D12: B6 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5002); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D15; JUMP; // sstep
case 0x8D15:
                                                     mon("         BMI   L8D1C                   ; 8D15: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8d1c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D17; JUMP; // sstep
case 0x8D17:
                                                     mon("         JSR   L8979                   ; 8D17: BD 89 79      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x1a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8979; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D1A:
                                                     mon("L8D1A    BRA   L8D1F                   ; 8D1A: 20 03         \n");
    PC = 0x8d1f; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8D1C:
                                                     mon("L8D1C    JSR   L8971                   ; 8D1C: BD 89 71      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x1f); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8971; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D1F:
                                                     mon("L8D1F    LDA   <$4E                    ; 8D1F: 96 4E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4e); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D21; JUMP; // sstep
case 0x8D21:
                                                     mon("         BNE   L8D3A                   ; 8D21: 26 17         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d3a; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D23; JUMP; // sstep
case 0x8D23:
                                                     mon("         LDB   $5004                   ; 8D23: F6 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5004); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8D26; JUMP; // sstep
case 0x8D26:
                                                     mon("         SEX                           ; 8D26: 1D            \n");
/**/Z = B; 
/**/N = B; 
    A = ((SINT8)B < 0 ? 0xff : 0); 
    clockticks = clockticks + 2; 
    PC = 0x8D27; JUMP; // sstep
case 0x8D27:
                                                     mon("         ADDB  #$01                    ; 8D27: CB 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    B = (UINT8)res; 
    PC = 0x8D29; JUMP; // sstep
case 0x8D29:
                                                     mon("         CMPB  #$01                    ; 8D29: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8D2B; JUMP; // sstep
case 0x8D2B:
                                                     mon("         BLS   L8D3A                   ; 8D2B: 23 0D         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x8d3a; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D2D; JUMP; // sstep
case 0x8D2D:
                                                     mon("         EORA  $5002                   ; 8D2D: B8 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    res = A ^ rd_mem(0x5002); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8D30; JUMP; // sstep
case 0x8D30:
                                                     mon("         BMI   L8D37                   ; 8D30: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8d37; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D32; JUMP; // sstep
case 0x8D32:
                                                     mon("         JSR   L8961                   ; 8D32: BD 89 61      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x35); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8961; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D35:
                                                     mon("L8D35    BRA   L8D3A                   ; 8D35: 20 03         \n");
    PC = 0x8d3a; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8D37:
                                                     mon("L8D37    JSR   L8969                   ; 8D37: BD 89 69      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x3a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8969; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D3A:
                                                     mon("L8D3A    LDA   <$4D                    ; 8D3A: 96 4D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4d); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D3C; JUMP; // sstep
case 0x8D3C:
                                                     mon("         BNE   L8D66                   ; 8D3C: 26 28         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d66; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D3E; JUMP; // sstep
case 0x8D3E:
                                                     mon("         LDA   $5004                   ; 8D3E: B6 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5004); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D41; JUMP; // sstep
case 0x8D41:
                                                     mon("         BMI   L8D48                   ; 8D41: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8d48; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D43; JUMP; // sstep
case 0x8D43:
                                                     mon("         JSR   L8951                   ; 8D43: BD 89 51      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x46); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8951; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D46:
                                                     mon("L8D46    BRA   L8D4B                   ; 8D46: 20 03         \n");
    PC = 0x8d4b; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8D48:
                                                     mon("L8D48    JSR   L8959                   ; 8D48: BD 89 59      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x4b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8959; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D4B:
                                                     mon("L8D4B    LDA   <$4E                    ; 8D4B: 96 4E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x4e); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8D4D; JUMP; // sstep
case 0x8D4D:
                                                     mon("         BNE   L8D66                   ; 8D4D: 26 17         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8d66; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D4F; JUMP; // sstep
case 0x8D4F:
                                                     mon("         LDB   $5002                   ; 8D4F: F6 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5002); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8D52; JUMP; // sstep
case 0x8D52:
                                                     mon("         SEX                           ; 8D52: 1D            \n");
/**/Z = B; 
/**/N = B; 
    A = ((SINT8)B < 0 ? 0xff : 0); 
    clockticks = clockticks + 2; 
    PC = 0x8D53; JUMP; // sstep
case 0x8D53:
                                                     mon("         ADDB  #$01                    ; 8D53: CB 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    B = (UINT8)res; 
    PC = 0x8D55; JUMP; // sstep
case 0x8D55:
                                                     mon("         CMPB  #$01                    ; 8D55: C1 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8D57; JUMP; // sstep
case 0x8D57:
                                                     mon("         BLS   L8D66                   ; 8D57: 23 0D         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x8d66; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D59; JUMP; // sstep
case 0x8D59:
                                                     mon("         EORA  $5004                   ; 8D59: B8 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    res = A ^ rd_mem(0x5004); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8D5C; JUMP; // sstep
case 0x8D5C:
                                                     mon("         BMI   L8D63                   ; 8D5C: 2B 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0x8d63; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8D5E; JUMP; // sstep
case 0x8D5E:
                                                     mon("         JSR   L8969                   ; 8D5E: BD 89 69      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x61); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8969; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D61:
                                                     mon("L8D61    BRA   L8D66                   ; 8D61: 20 03         \n");
    PC = 0x8d66; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8D63:
                                                     mon("L8D63    JSR   L8961                   ; 8D63: BD 89 61      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x66); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8961; 
    JUMP;
    // ---------------------------------------------------------------------------
  case 0x8D66:
                                                     mon("L8D66    LDX   <$5A                    ; 8D66: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8D68; JUMP; // sstep
case 0x8D68:
                                                     mon("         LDD   $15,X                   ; 8D68: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8D6B; JUMP; // sstep
case 0x8D6B:
                                                     mon("         ANDA  #$EF                    ; 8D6B: 84 EF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0xef; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8D6D; JUMP; // sstep
case 0x8D6D:
                                                     mon("         STD   $15,X                   ; 8D6D: ED 88 15      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8BE1
    // ---------------------------------------------------------------------------
    PC = 0x8D70; JUMP; // sstep
case 0x8D70:
                                                     mon("         RTS                           ; 8D70: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Some tie fighters process
  case 0x8D9D:
                                                     mon("L8D9D    LDX   <$5A                    ; 8D9D: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8D9F; JUMP; // sstep
case 0x8D9F:
                                                     mon("         LDU   ,X                      ; 8D9F: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8DA1; JUMP; // sstep
case 0x8DA1:
                                                     mon("         LDA   $06,X                   ; 8DA1: A6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8DA3; JUMP; // sstep
case 0x8DA3:
                                                     mon("         BNE   L8DDF                   ; 8DA3: 26 3A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8ddf; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DA5; JUMP; // sstep
case 0x8DA5:
                                                     mon("         LDB   $12,X                   ; 8DA5: E6 88 12      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x12)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8DA8; JUMP; // sstep
case 0x8DA8:
                                                     mon("         STB   <$50                    ; 8DA8: D7 50         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x50; 
    wr_mem(ea, val); 
    PC = 0x8DAA; JUMP; // sstep
case 0x8DAA:
                                                     mon("         LDU   ,X                      ; 8DAA: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8DAC; JUMP; // sstep
case 0x8DAC:
                                                     mon("         LDD   #$00                    ; 8DAC: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8DAF; JUMP; // sstep
case 0x8DAF:
                                                     mon("         STD   -10,U                   ; 8DAF: ED 56         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff6); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8DB1; JUMP; // sstep
case 0x8DB1:
                                                     mon("         STD   -2,U                    ; 8DB1: ED 5E         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffe); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8DB3; JUMP; // sstep
case 0x8DB3:
                                                     mon("         STD   $06,U                   ; 8DB3: ED 46         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x0006); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8DB5; JUMP; // sstep
case 0x8DB5:
                                                     mon("         LSR   <$50                    ; 8DB5: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DB7; JUMP; // sstep
case 0x8DB7:
                                                     mon("         BCC   L8DBC                   ; 8DB7: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8dbc; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DB9; JUMP; // sstep
case 0x8DB9:
                                                     mon("         JSR   L8A59                   ; 8DB9: BD 8A 59      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xbc); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8a59; 
    JUMP;
  case 0x8DBC:
                                                     mon("L8DBC    LSR   <$50                    ; 8DBC: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DBE; JUMP; // sstep
case 0x8DBE:
                                                     mon("         BCC   L8DC3                   ; 8DBE: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8dc3; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DC0; JUMP; // sstep
case 0x8DC0:
                                                     mon("         JSR   L8A7E                   ; 8DC0: BD 8A 7E      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xc3); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8a7e; 
    JUMP;
  case 0x8DC3:
                                                     mon("L8DC3    LSR   <$50                    ; 8DC3: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DC5; JUMP; // sstep
case 0x8DC5:
                                                     mon("         BCC   L8DCA                   ; 8DC5: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8dca; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DC7; JUMP; // sstep
case 0x8DC7:
                                                     mon("         JSR   L8A21                   ; 8DC7: BD 8A 21      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xca); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8a21; 
    JUMP;
  case 0x8DCA:
                                                     mon("L8DCA    LSR   <$50                    ; 8DCA: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DCC; JUMP; // sstep
case 0x8DCC:
                                                     mon("         BCC   L8DD1                   ; 8DCC: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8dd1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DCE; JUMP; // sstep
case 0x8DCE:
                                                     mon("         JSR   L8A3D                   ; 8DCE: BD 8A 3D      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8a3d; 
    JUMP;
  case 0x8DD1:
                                                     mon("L8DD1    LSR   <$50                    ; 8DD1: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DD3; JUMP; // sstep
case 0x8DD3:
                                                     mon("         BCC   L8DD8                   ; 8DD3: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8dd8; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DD5; JUMP; // sstep
case 0x8DD5:
                                                     mon("         JSR   L8A05                   ; 8DD5: BD 8A 05      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8a05; 
    JUMP;
  case 0x8DD8:
                                                     mon("L8DD8    LSR   <$50                    ; 8DD8: 04 50         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x50); 
    C = val & 1; 
    val = val >> 1; 
    wr_mem(DP|0x50, val); 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8DDA; JUMP; // sstep
case 0x8DDA:
                                                     mon("         BCC   L8DDF                   ; 8DDA: 24 03         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8ddf; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DDC; JUMP; // sstep
case 0x8DDC:
                                                     mon("         JSR   L89E9                   ; 8DDC: BD 89 E9      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xdf); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x89e9; 
    JUMP;
  case 0x8DDF:
                                                     mon("L8DDF    JSR   L8AB6                   ; 8DDF: BD 8A B6      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe2); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    PC = 0x8ab6; 
    JUMP;
    // End of function sub_8D9D
  case 0x8DE2:
                                                     mon("L8DE2    RTS                           ; 8DE2: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8DE3:
                                                     mon("L8DE3    LDU   ,X                      ; 8DE3: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8DE5; JUMP; // sstep
case 0x8DE5:
                                                     mon("         LDD   $08,U                   ; 8DE5: EC 48         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0008); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8DE7; JUMP; // sstep
case 0x8DE7:
                                                     mon("         CMPA  #$7D                    ; 8DE7: 81 7D         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x7d; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8DE9; JUMP; // sstep
case 0x8DE9:
                                                     mon("         BLT   L8DEE                   ; 8DE9: 2D 03         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8dee; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DEB; JUMP; // sstep
case 0x8DEB:
                                                     mon("         LDD   #$7CFF                  ; 8DEB: CC 7C FF      \n");
    clockticks = clockticks + 3; 
    A = 0x7c; 
    B = 0xff; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8DEE; JUMP; // sstep
case 0x8DEE:
                                                     mon("L8DEE    CMPA  #$82                    ; 8DEE: 81 82         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x82; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8DF0; JUMP; // sstep
case 0x8DF0:
                                                     mon("         BGT   L8DF5                   ; 8DF0: 2E 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8df5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DF2; JUMP; // sstep
case 0x8DF2:
                                                     mon("         LDD   #$8300                  ; 8DF2: CC 83 00      \n");
    clockticks = clockticks + 3; 
    A = 0x83; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8DF5; JUMP; // sstep
case 0x8DF5:
                                                     mon("L8DF5    STD   $08,U                   ; 8DF5: ED 48         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0008); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8DF7; JUMP; // sstep
case 0x8DF7:
                                                     mon("         LDD   $0A,U                   ; 8DF7: EC 4A         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x000a); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8DF9; JUMP; // sstep
case 0x8DF9:
                                                     mon("         CMPA  #$7D                    ; 8DF9: 81 7D         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x7d; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8DFB; JUMP; // sstep
case 0x8DFB:
                                                     mon("         BLT   L8E00                   ; 8DFB: 2D 03         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8e00; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8DFD; JUMP; // sstep
case 0x8DFD:
                                                     mon("         LDD   #$7CFF                  ; 8DFD: CC 7C FF      \n");
    clockticks = clockticks + 3; 
    A = 0x7c; 
    B = 0xff; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E00; JUMP; // sstep
case 0x8E00:
                                                     mon("L8E00    CMPA  #$82                    ; 8E00: 81 82         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x82; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8E02; JUMP; // sstep
case 0x8E02:
                                                     mon("         BGT   L8E07                   ; 8E02: 2E 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8e07; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E04; JUMP; // sstep
case 0x8E04:
                                                     mon("         LDD   #$8300                  ; 8E04: CC 83 00      \n");
    clockticks = clockticks + 3; 
    A = 0x83; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E07; JUMP; // sstep
case 0x8E07:
                                                     mon("L8E07    STD   $0A,U                   ; 8E07: ED 4A         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000a); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8E09; JUMP; // sstep
case 0x8E09:
                                                     mon("         LDD   $0C,U                   ; 8E09: EC 4C         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x000c); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E0B; JUMP; // sstep
case 0x8E0B:
                                                     mon("         CMPA  #$7D                    ; 8E0B: 81 7D         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x7d; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8E0D; JUMP; // sstep
case 0x8E0D:
                                                     mon("         BLT   L8E12                   ; 8E0D: 2D 03         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x8e12; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E0F; JUMP; // sstep
case 0x8E0F:
                                                     mon("         LDD   #$7CFF                  ; 8E0F: CC 7C FF      \n");
    clockticks = clockticks + 3; 
    A = 0x7c; 
    B = 0xff; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E12; JUMP; // sstep
case 0x8E12:
                                                     mon("L8E12    CMPA  #$82                    ; 8E12: 81 82         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x82; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x8E14; JUMP; // sstep
case 0x8E14:
                                                     mon("         BGT   L8E19                   ; 8E14: 2E 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8e19; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E16; JUMP; // sstep
case 0x8E16:
                                                     mon("         LDD   #$8300                  ; 8E16: CC 83 00      \n");
    clockticks = clockticks + 3; 
    A = 0x83; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E19; JUMP; // sstep
case 0x8E19:
                                                     mon("L8E19    STD   $0C,U                   ; 8E19: ED 4C         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(U + 0x000c); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    // End of function sub_8DE3
    PC = 0x8E1B; JUMP; // sstep
case 0x8E1B:
                                                     mon("         RTS                           ; 8E1B: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8E1C:
                                                     mon("L8E1C    DEC   <$E6                    ; 8E1C: 0A E6         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xe6); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0xe6, res); 
    clockticks = clockticks + 2; 
    PC = 0x8E1E; JUMP; // sstep
case 0x8E1E:
                                                     mon("         BGT   locret_8E22             ; 8E1E: 2E 02         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x8e22; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E20; JUMP; // sstep
case 0x8E20:
                                                     mon("         CLR   <$E6                    ; 8E20: 0F E6         \n");
    clockticks = clockticks + 4; 
    wr_mem(DP|0xe6, 0); 
    V = 0; 
    Z = 0; 
    N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    // End of function sub_8E1C
    PC = 0x8E22; JUMP; // sstep
case 0x8E22:
                                                     mon("locret_8E22 RTS                           ; 8E22: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8E23:
                                                     mon("L8E23    LDD   #$00                    ; 8E23: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E26; JUMP; // sstep
case 0x8E26:
                                                     mon("         STD   $11,X                   ; 8E26: ED 88 11      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x11); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8E29; JUMP; // sstep
case 0x8E29:
                                                     mon("         STA   $10,X                   ; 8E29: A7 88 10      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x10); 
    wr_mem(ea, val); 
    PC = 0x8E2C; JUMP; // sstep
case 0x8E2C:
                                                     mon("         STD   $13,X                   ; 8E2C: ED 88 13      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x13); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8E2F; JUMP; // sstep
case 0x8E2F:
                                                     mon("         STD   $15,X                   ; 8E2F: ED 88 15      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x15); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8E32; JUMP; // sstep
case 0x8E32:
                                                     mon("L8E32    LDU   $0D,X                   ; 8E32: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8E34; JUMP; // sstep
case 0x8E34:
                                                     mon("         LDA   ,U                      ; 8E34: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8E36; JUMP; // sstep
case 0x8E36:
                                                     mon("         STA   $0F,X                   ; 8E36: A7 0F         \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + 0x000f); 
    wr_mem(ea, val); 
    PC = 0x8E38; JUMP; // sstep
case 0x8E38:
                                                     mon("         BEQ   L8E51                   ; 8E38: 27 17         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8e51; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E3A; JUMP; // sstep
case 0x8E3A:
                                                     mon("L8E3A    LDD   $15,X                   ; 8E3A: EC 88 15      \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)0x15); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E3D; JUMP; // sstep
case 0x8E3D:
                                                     mon("         ANDA  $13,X                   ; 8E3D: A4 88 13      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    res = val & rd_mem((UINT16)(X + (SINT8)0x13)); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8E40; JUMP; // sstep
case 0x8E40:
                                                     mon("         BNE   L8E5C                   ; 8E40: 26 1A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8e5c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E42; JUMP; // sstep
case 0x8E42:
                                                     mon("         ANDB  $14,X                   ; 8E42: E4 88 14      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)B; 
    res = val & rd_mem((UINT16)(X + (SINT8)0x14)); 
    B = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8E45; JUMP; // sstep
case 0x8E45:
                                                     mon("         BNE   L8E5C                   ; 8E45: 26 15         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8e5c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E47; JUMP; // sstep
case 0x8E47:
                                                     mon("         LDA   $0F,X                   ; 8E47: A6 0F         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x000f)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8E49; JUMP; // sstep
case 0x8E49:
                                                     mon("         ANDA  #$07                    ; 8E49: 84 07         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x07; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x8E4B; JUMP; // sstep
case 0x8E4B:
                                                     mon("         ASLA                          ; 8E4B: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x8E4C; JUMP; // sstep
case 0x8E4C:
                                                     mon("         LDU   #JumpTable8E68          ; 8E4C: CE 8E 68      \n");
    clockticks = clockticks + 3; 
    U = 0x8e68; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8E4F; JUMP; // sstep
case 0x8E4F:
                                                     mon("         JMP   [A,U]                   ; 8E4F: 6E D6         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 2; 
    ea = rd_mem((UINT16)(U + (SINT8)A))<<8; 
    ea = ea | rd_mem((UINT16)((U + (SINT8)A) + 1)); 
    PC = ea; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x8E51:
                                                     mon("L8E51    LDD   $01,U                   ; 8E51: EC 41         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0001); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8E53; JUMP; // sstep
case 0x8E53:
                                                     mon("         STD   $13,X                   ; 8E53: ED 88 13      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x13); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8E56; JUMP; // sstep
case 0x8E56:
                                                     mon("         LEAU  $03,U                   ; 8E56: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8E58; JUMP; // sstep
case 0x8E58:
                                                     mon("         STU   $0D,X                   ; 8E58: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8E5A; JUMP; // sstep
case 0x8E5A:
                                                     mon("         BRA   L8E32                   ; 8E5A: 20 D6         \n");
    PC = 0x8e32; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8E5C:
                                                     mon("L8E5C    LDU   $0D,X                   ; 8E5C: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8E5E; JUMP; // sstep
case 0x8E5E:
                                                     mon("L8E5E    LDA   ,U                      ; 8E5E: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8E60; JUMP; // sstep
case 0x8E60:
                                                     mon("         BEQ   L8E32                   ; 8E60: 27 D0         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8e32; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E62; JUMP; // sstep
case 0x8E62:
                                                     mon("         LEAU  $03,U                   ; 8E62: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8E64; JUMP; // sstep
case 0x8E64:
                                                     mon("         STU   $0D,X                   ; 8E64: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    // End of function sub_8E23
    // ---------------------------------------------------------------------------
    PC = 0x8E66; JUMP; // sstep
case 0x8E66:
                                                     mon("         BRA   L8E5E                   ; 8E66: 20 F6         \n");
    PC = 0x8e5e; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // End of function sub_8E78
  case 0x8E78:
                                                     mon("L8E78    SWI                           ; 8E78: 3F            \n");
    clockticks = clockticks + 19; 
    S = S - 1; 
    wr_mem(S, 0x79); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, U); 
    S = S - 1; 
    wr_mem(S, U >> 8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, Y); 
    S = S - 1; 
    wr_mem(S, Y >> 8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, X); 
    S = S - 1; 
    wr_mem(S, X >> 8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, (DP >> 8)); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, B); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, A); 
    clockticks = clockticks + 1; 
    simplify_flags();
    CC = (((((((((((((E<<1) | F)<<1) | H)<<1) |I)<<1) | N)<<1) | Z)<<1) | V)<<1) | C; // Placeholder for now
    restore_flags();
    S = S - 1; 
    wr_mem(S, CC); 
    clockticks = clockticks + 1; 
    PC = (rd_mem(0xfffa)<<8)|rd_mem(0xfffb); 
    JUMP;
    // =============== S U B R O U T I N E =======================================
  case 0x8E79:
                                                     mon("L8E79    LDU   $0D,X                   ; 8E79: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8E7B; JUMP; // sstep
case 0x8E7B:
                                                     mon("L8E7B    LDD   $01,U                   ; 8E7B: EC 41         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0001); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0x8E7D; JUMP; // sstep
case 0x8E7D:
                                                     mon("         BEQ   L8E94                   ; 8E7D: 27 15         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8e94; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E7F; JUMP; // sstep
case 0x8E7F:
                                                     mon("         ANDA  $15,X                   ; 8E7F: A4 88 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    res = val & rd_mem((UINT16)(X + (SINT8)0x15)); 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8E82; JUMP; // sstep
case 0x8E82:
                                                     mon("         BNE   L8E94                   ; 8E82: 26 10         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8e94; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E84; JUMP; // sstep
case 0x8E84:
                                                     mon("         ANDB  $16,X                   ; 8E84: E4 88 16      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)B; 
    res = val & rd_mem((UINT16)(X + (SINT8)0x16)); 
    B = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x8E87; JUMP; // sstep
case 0x8E87:
                                                     mon("         BNE   L8E94                   ; 8E87: 26 0B         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8e94; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E89; JUMP; // sstep
case 0x8E89:
                                                     mon("L8E89    LEAU  $03,U                   ; 8E89: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8E8B; JUMP; // sstep
case 0x8E8B:
                                                     mon("         LDA   ,U                      ; 8E8B: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8E8D; JUMP; // sstep
case 0x8E8D:
                                                     mon("         ASLA                          ; 8E8D: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
    Z = res; 
    N = res; 
    V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0x8E8E; JUMP; // sstep
case 0x8E8E:
                                                     mon("         BNE   L8E89                   ; 8E8E: 26 F9         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8e89; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E90; JUMP; // sstep
case 0x8E90:
                                                     mon("         BCC   L8E89                   ; 8E90: 24 F7         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x8e89; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8E92; JUMP; // sstep
case 0x8E92:
                                                     mon("         BRA   L8E7B                   ; 8E92: 20 E7         \n");
    PC = 0x8e7b; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8E94:
                                                     mon("L8E94    LEAU  $03,U                   ; 8E94: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8E96; JUMP; // sstep
case 0x8E96:
                                                     mon("         STU   $0D,X                   ; 8E96: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    // End of function sub_8E79
    PC = 0x8E98; JUMP; // sstep
case 0x8E98:
                                                     mon("         JMP   L8E32                   ; 8E98: 7E 8E 32      \n");
    clockticks = clockticks + 4; 
    PC = 0x8e32; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8E9B:
                                                     mon("L8E9B    LDU   $0D,X                   ; 8E9B: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8E9D; JUMP; // sstep
case 0x8E9D:
                                                     mon("         LDU   $01,U                   ; 8E9D: EE 41         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0001))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0001))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8E9F; JUMP; // sstep
case 0x8E9F:
                                                     mon("         STU   $0D,X                   ; 8E9F: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    // End of function sub_8E9B
    PC = 0x8EA1; JUMP; // sstep
case 0x8EA1:
                                                     mon("         JMP   L8E32                   ; 8EA1: 7E 8E 32      \n");
    clockticks = clockticks + 4; 
    PC = 0x8e32; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8EA4:
                                                     mon("L8EA4    LDU   $0D,X                   ; 8EA4: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8EA6; JUMP; // sstep
case 0x8EA6:
                                                     mon("         LEAU  $03,U                   ; 8EA6: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8EA8; JUMP; // sstep
case 0x8EA8:
                                                     mon("         STU   $17,X                   ; 8EA8: EF 88 17      \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = (X + (SINT8)0x17); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8EAB; JUMP; // sstep
case 0x8EAB:
                                                     mon("         LDU   -2,U                    ; 8EAB: EE 5E         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0xfffe))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0xfffe))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8EAD; JUMP; // sstep
case 0x8EAD:
                                                     mon("         STU   $0D,X                   ; 8EAD: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    // End of function sub_8EA4
    PC = 0x8EAF; JUMP; // sstep
case 0x8EAF:
                                                     mon("         JMP   L8E32                   ; 8EAF: 7E 8E 32      \n");
    clockticks = clockticks + 4; 
    PC = 0x8e32; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8EB2:
                                                     mon("L8EB2    LDU   $17,X                   ; 8EB2: EE 88 17      \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)0x17))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)0x17))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8EB5; JUMP; // sstep
case 0x8EB5:
                                                     mon("         STU   $0D,X                   ; 8EB5: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    // End of function sub_8EB2
    PC = 0x8EB7; JUMP; // sstep
case 0x8EB7:
                                                     mon("         JMP   L8E32                   ; 8EB7: 7E 8E 32      \n");
    clockticks = clockticks + 4; 
    PC = 0x8e32; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8EBA:
                                                     mon("L8EBA    LDU   $0D,X                   ; 8EBA: EE 0D         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + 0x000d))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + 0x000d))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8EBC; JUMP; // sstep
case 0x8EBC:
                                                     mon("         LDB   ,U                      ; 8EBC: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8EBE; JUMP; // sstep
case 0x8EBE:
                                                     mon("         LSRB                          ; 8EBE: 54            \n");
    val = (UINT8)B; 
    C = val & 1; 
    val = val >> 1; 
    B = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8EBF; JUMP; // sstep
case 0x8EBF:
                                                     mon("         STB   $10,X                   ; 8EBF: E7 88 10      \n");
    clockticks = clockticks + 5; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x10); 
    wr_mem(ea, val); 
    PC = 0x8EC2; JUMP; // sstep
case 0x8EC2:
                                                     mon("         LDD   $01,U                   ; 8EC2: EC 41         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0001); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8EC4; JUMP; // sstep
case 0x8EC4:
                                                     mon("         STD   $11,X                   ; 8EC4: ED 88 11      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(X + (SINT8)0x11); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8EC7; JUMP; // sstep
case 0x8EC7:
                                                     mon("         LEAU  $03,U                   ; 8EC7: 33 43         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0003); 
    PC = 0x8EC9; JUMP; // sstep
case 0x8EC9:
                                                     mon("         STU   $0D,X                   ; 8EC9: EF 0D         \n");
    clockticks = clockticks + 5; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = (X + 0x000d); 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8ECB; JUMP; // sstep
case 0x8ECB:
                                                     mon("         INC   $0F,X                   ; 8ECB: 6C 0F         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x000f)); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem((UINT16)(X + 0x000f), res); 
    clockticks = clockticks + 2; 
    // End of function sub_8EBA
    PC = 0x8ECD; JUMP; // sstep
case 0x8ECD:
                                                     mon("         RTS                           ; 8ECD: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8ECE:
                                                     mon("L8ECE    DEC   $10,X                   ; 8ECE: 6A 88 10      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)0x10)); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem((UINT16)(X + (SINT8)0x10), res); 
    clockticks = clockticks + 2; 
    PC = 0x8ED1; JUMP; // sstep
case 0x8ED1:
                                                     mon("         LBMI  L8E32                   ; 8ED1: 10 2B FF 5D   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)N <  0) {
    clockticks = clockticks + 1; 
    PC = 0x8e32; 
    JUMP;
    }
    // End of function sub_8ECE
    PC = 0x8ED5; JUMP; // sstep
case 0x8ED5:
                                                     mon("         RTS                           ; 8ED5: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8ED6:
                                                     mon("L8ED6    JSR   LCCC0                   ; 8ED6: BD CC C0      \n"); // Initialise object?
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd9); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8e); 
    clockticks = clockticks + 1; 
    PC = 0xccc0; 
    JUMP;
  case 0x8ED9:
                                                     mon("L8ED9    LDB   $4B14                   ; 8ED9: F6 4B 14      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b14); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8EDC; JUMP; // sstep
case 0x8EDC:
                                                     mon("         ASLB                          ; 8EDC: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8EDD; JUMP; // sstep
case 0x8EDD:
                                                     mon("         LDX   #off_9070               ; 8EDD: 8E 90 70      \n");
    clockticks = clockticks + 3; 
    X = 0x9070; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8EE0; JUMP; // sstep
case 0x8EE0:
                                                     mon("         ABX                           ; 8EE0: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0x8EE1; JUMP; // sstep
case 0x8EE1:
                                                     mon("         CMPX  #byte_907C              ; 8EE1: 8C 90 7C      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x907c; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8EE4; JUMP; // sstep
case 0x8EE4:
                                                     mon("         BCS   L8EF4                   ; 8EE4: 25 0E         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8ef4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8EE6; JUMP; // sstep
case 0x8EE6:
                                                     mon("         LDA   $4B14                   ; 8EE6: B6 4B 14      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b14); 
    A = val; 
/**/N = val; 
/**/Z = val; 
    V = 0; 
    PC = 0x8EE9; JUMP; // sstep
case 0x8EE9:
                                                     mon("         LSRA                          ; 8EE9: 44            \n");
    val = (UINT8)A; 
    C = val & 1; 
    val = val >> 1; 
    A = val; 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8EEA; JUMP; // sstep
case 0x8EEA:
                                                     mon("         BCS   L8EF1                   ; 8EEA: 25 05         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8ef1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8EEC; JUMP; // sstep
case 0x8EEC:
                                                     mon("         LDX   #off_9078               ; 8EEC: 8E 90 78      \n");
    clockticks = clockticks + 3; 
    X = 0x9078; 
    Z = X; 
    N = (X) >> 8; 
    V = 0; 
    PC = 0x8EEF; JUMP; // sstep
case 0x8EEF:
                                                     mon("         BRA   L8EF4                   ; 8EEF: 20 03         \n");
    PC = 0x8ef4; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8EF1:
                                                     mon("L8EF1    LDX   #off_907A               ; 8EF1: 8E 90 7A      \n");
    clockticks = clockticks + 3; 
    X = 0x907a; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8EF4; JUMP; // sstep
case 0x8EF4:
                                                     mon("L8EF4    LDX   ,X                      ; 8EF4: AE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8EF6; JUMP; // sstep
case 0x8EF6:
                                                     mon("         LDB   <$DD                    ; 8EF6: D6 DD         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xdd); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8EF8; JUMP; // sstep
case 0x8EF8:
                                                     mon("         CMPB  ,X+                     ; 8EF8: E1 80         \n");
    clockticks = clockticks + 6; 
    val = (UINT8)B; 
    arg = rd_mem(X); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    X = X + 1; 
    PC = 0x8EFA; JUMP; // sstep
case 0x8EFA:
                                                     mon("         BLS   L8EFE                   ; 8EFA: 23 02         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x8efe; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8EFC; JUMP; // sstep
case 0x8EFC:
                                                     mon("         LDB   -1,X                    ; 8EFC: E6 1F         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0xffff)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8EFE; JUMP; // sstep
case 0x8EFE:
                                                     mon("L8EFE    ASLB                          ; 8EFE: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8EFF; JUMP; // sstep
case 0x8EFF:
                                                     mon("         LDD   B,X                     ; 8EFF: EC 85         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)B); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F01; JUMP; // sstep
case 0x8F01:
                                                     mon("         STD   <$E4                    ; 8F01: DD E4         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe4; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F03; JUMP; // sstep
case 0x8F03:
                                                     mon("         CLR   <$E6                    ; 8F03: 0F E6         \n");
    clockticks = clockticks + 4; 
    wr_mem(DP|0xe6, 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
/**/C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8F05; JUMP; // sstep
case 0x8F05:
                                                     mon("         LDX   #$4900                  ; 8F05: 8E 49 00      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 3; 
    X = 0x4900; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F08; JUMP; // sstep
case 0x8F08:
                                                     mon("L8F08    STX   <$5A                    ; 8F08: 9F 5A         \n");
    clockticks = clockticks + 4; 
    val = X; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0x5a; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8F0A; JUMP; // sstep
case 0x8F0A:
                                                     mon("         CLR   $03,X                   ; 8F0A: 6F 03         \n");
    clockticks = clockticks + 5; 
    wr_mem((UINT16)(X + 0x0003), 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8F0C; JUMP; // sstep
case 0x8F0C:
                                                     mon("         LDU   <$E4                    ; 8F0C: DE E4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe4)<<8; 
    ea = ea | rd_mem(DP|0xe5); 
    U = ea; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8F0E; JUMP; // sstep
case 0x8F0E:
                                                     mon("         BEQ   L8F29                   ; 8F0E: 27 19         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8f29; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F10; JUMP; // sstep
case 0x8F10:
                                                     mon("         LDA   ,U                      ; 8F10: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8F12; JUMP; // sstep
case 0x8F12:
                                                     mon("         BEQ   L8F29                   ; 8F12: 27 15         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8f29; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F14; JUMP; // sstep
case 0x8F14:
                                                     mon("         INC   <$E6                    ; 8F14: 0C E6         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xe6); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem(DP|0xe6, res); 
    clockticks = clockticks + 2; 
    PC = 0x8F16; JUMP; // sstep
case 0x8F16:
                                                     mon("         LDD   ,U                      ; 8F16: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F18; JUMP; // sstep
case 0x8F18:
                                                     mon("         STD   <$E0                    ; 8F18: DD E0         \n"); // Pointer to 3D object index
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe0; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F1A; JUMP; // sstep
case 0x8F1A:
                                                     mon("         LDD   $02,U                   ; 8F1A: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F1C; JUMP; // sstep
case 0x8F1C:
                                                     mon("         STD   <$DE                    ; 8F1C: DD DE         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xde; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F1E; JUMP; // sstep
case 0x8F1E:
                                                     mon("         LDD   $04,U                   ; 8F1E: EC 44         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F20; JUMP; // sstep
case 0x8F20:
                                                     mon("         STD   <$E2                    ; 8F20: DD E2         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe2; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F22; JUMP; // sstep
case 0x8F22:
                                                     mon("         LEAU  $06,U                   ; 8F22: 33 46         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0006); 
    PC = 0x8F24; JUMP; // sstep
case 0x8F24:
                                                     mon("         STU   <$E4                    ; 8F24: DF E4         \n");
    clockticks = clockticks + 4; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = DP|0xe4; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8F26; JUMP; // sstep
case 0x8F26:
                                                     mon("         JSR   L8F34                   ; 8F26: BD 8F 34      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x29); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8f); 
    clockticks = clockticks + 1; 
    PC = 0x8f34; 
    JUMP;
  case 0x8F29:
                                                     mon("L8F29    LDX   <$5A                    ; 8F29: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F2B; JUMP; // sstep
case 0x8F2B:
                                                     mon("         LEAX  $19,X                   ; 8F2B: 30 88 19      \n");
    clockticks = clockticks + 5; 
    X = (X + (SINT8)0x19); 
/**/Z = X; 
    PC = 0x8F2E; JUMP; // sstep
case 0x8F2E:
                                                     mon("         CMPX  #$494B                  ; 8F2E: 8C 49 4B      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x494b; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8F31; JUMP; // sstep
case 0x8F31:
                                                     mon("         BCS   L8F08                   ; 8F31: 25 D5         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8f08; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    // End of function sub_8ED6
    PC = 0x8F33; JUMP; // sstep
case 0x8F33:
                                                     mon("         RTS                           ; 8F33: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8F34:
                                                     mon("L8F34    LDA   #$01                    ; 8F34: 86 01         \n"); // Called 3 times at start of attract screen 1 and 2
    clockticks = clockticks + 2; 
    val = (UINT8)0x01; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8F36; JUMP; // sstep
case 0x8F36:
                                                     mon("         STA   $03,X                   ; 8F36: A7 03         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0003); 
    wr_mem(ea, val); 
    PC = 0x8F38; JUMP; // sstep
case 0x8F38:
                                                     mon("         LDU   ,X                      ; 8F38: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8F3A; JUMP; // sstep
case 0x8F3A:
                                                     mon("         JSR   LCDC3                   ; 8F3A: BD CD C3      \n"); // Initialise math registers matrix
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x3d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8f); 
    clockticks = clockticks + 1; 
    PC = 0xcdc3; 
    JUMP;
  case 0x8F3D:
                                                     mon("L8F3D    LDU   ,X                      ; 8F3D: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8F3F; JUMP; // sstep
case 0x8F3F:
                                                     mon("         LDA   #$C0                    ; 8F3F: 86 C0         \n"); // Matrix -1.000 constant
    clockticks = clockticks + 2; 
    val = (UINT8)0xc0; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8F41; JUMP; // sstep
case 0x8F41:
                                                     mon("         STA   -16,U                   ; 8F41: A7 50         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff0); 
    wr_mem(ea, val); 
    PC = 0x8F43; JUMP; // sstep
case 0x8F43:
                                                     mon("         STA   -6,U                    ; 8F43: A7 5A         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffa); 
    wr_mem(ea, val); 
    PC = 0x8F45; JUMP; // sstep
case 0x8F45:
                                                     mon("         CLRA                          ; 8F45: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8F46; JUMP; // sstep
case 0x8F46:
                                                     mon("         STA   $09,X                   ; 8F46: A7 09         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0009); 
    wr_mem(ea, val); 
    PC = 0x8F48; JUMP; // sstep
case 0x8F48:
                                                     mon("         STA   $08,X                   ; 8F48: A7 08         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0008); 
    wr_mem(ea, val); 
    PC = 0x8F4A; JUMP; // sstep
case 0x8F4A:
                                                     mon("         STA   $06,X                   ; 8F4A: A7 06         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0006); 
    wr_mem(ea, val); 
    PC = 0x8F4C; JUMP; // sstep
case 0x8F4C:
                                                     mon("         STA   $05,X                   ; 8F4C: A7 05         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0005); 
    wr_mem(ea, val); 
    PC = 0x8F4E; JUMP; // sstep
case 0x8F4E:
                                                     mon("         STA   $0B,X                   ; 8F4E: A7 0B         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x000b); 
    wr_mem(ea, val); 
    PC = 0x8F50; JUMP; // sstep
case 0x8F50:
                                                     mon("         LDU   <$E0                    ; 8F50: DE E0         \n"); // Pointer to 3D object index
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe0)<<8; 
    ea = ea | rd_mem(DP|0xe1); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8F52; JUMP; // sstep
case 0x8F52:
                                                     mon("         LDA   $01,U                   ; 8F52: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8F54; JUMP; // sstep
case 0x8F54:
                                                     mon("         STA   $07,X                   ; 8F54: A7 07         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0007); 
    wr_mem(ea, val); 
    PC = 0x8F56; JUMP; // sstep
case 0x8F56:
                                                     mon("         LDU   ,X                      ; 8F56: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8F58; JUMP; // sstep
case 0x8F58:
                                                     mon("         LDX   <$E2                    ; 8F58: 9E E2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe2)<<8; 
    ea = ea | rd_mem(DP|0xe3); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F5A; JUMP; // sstep
case 0x8F5A:
                                                     mon("         LDD   ,X                      ; 8F5A: EC 84         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(X); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(X+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F5C; JUMP; // sstep
case 0x8F5C:
                                                     mon("         STD   $08,U                   ; 8F5C: ED 48         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0008); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F5E; JUMP; // sstep
case 0x8F5E:
                                                     mon("         LDD   $02,X                   ; 8F5E: EC 02         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F60; JUMP; // sstep
case 0x8F60:
                                                     mon("         STD   $0A,U                   ; 8F60: ED 4A         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000a); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F62; JUMP; // sstep
case 0x8F62:
                                                     mon("         LDD   $04,X                   ; 8F62: EC 04         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F64; JUMP; // sstep
case 0x8F64:
                                                     mon("         STD   $0C,U                   ; 8F64: ED 4C         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000c); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F66; JUMP; // sstep
case 0x8F66:
                                                     mon("         LDX   <$5A                    ; 8F66: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F68; JUMP; // sstep
case 0x8F68:
                                                     mon("         LDD   <$DE                    ; 8F68: DC DE         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0xde); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0xdf); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8F6A; JUMP; // sstep
case 0x8F6A:
                                                     mon("         STD   $0D,X                   ; 8F6A: ED 0D         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(X + 0x000d); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8F6C; JUMP; // sstep
case 0x8F6C:
                                                     mon("         JSR   L8E23                   ; 8F6C: BD 8E 23      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x6f); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8f); 
    clockticks = clockticks + 1; 
    PC = 0x8e23; 
    JUMP;
  case 0x8F6F:
                                                     mon("L8F6F    LDX   <$5A                    ; 8F6F: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F71; JUMP; // sstep
case 0x8F71:
                                                     mon("         LDB   [$48E0]                 ; 8F71: E6 9F 48 E0   \n"); // Pointer to 3D object index
    clockticks = clockticks + 6; 
    clockticks = clockticks + 2; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x48e0)<<8; 
    ea = ea | rd_mem(0x48e1); 
    val = (UINT8)rd_mem(ea); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8F75; JUMP; // sstep
case 0x8F75:
                                                     mon("         STB   $04,X                   ; 8F75: E7 04         \n");
    clockticks = clockticks + 5; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + 0x0004); 
    wr_mem(ea, val); 
    PC = 0x8F77; JUMP; // sstep
case 0x8F77:
                                                     mon("         JSR   LCCCC                   ; 8F77: BD CC CC      \n"); // Copy XYZ data to math RAM
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x7a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8f); 
    clockticks = clockticks + 1; 
    PC = 0xcccc; 
    JUMP;
    // End of function sub_8F34
  case 0x8F7A:
                                                     mon("L8F7A    RTS                           ; 8F7A: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x8F7B:
                                                     mon("L8F7B    LDU   <$E4                    ; 8F7B: DE E4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe4)<<8; 
    ea = ea | rd_mem(DP|0xe5); 
    U = ea; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8F7D; JUMP; // sstep
case 0x8F7D:
                                                     mon("         BEQ   L8F83                   ; 8F7D: 27 04         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8f83; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F7F; JUMP; // sstep
case 0x8F7F:
                                                     mon("         LDA   ,U                      ; 8F7F: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8F81; JUMP; // sstep
case 0x8F81:
                                                     mon("         BNE   L8FB1                   ; 8F81: 26 2E         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x8fb1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F83; JUMP; // sstep
case 0x8F83:
                                                     mon("L8F83    INC   <$DD                    ; 8F83: 0C DD         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xdd); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem(DP|0xdd, res); 
    clockticks = clockticks + 2; 
    PC = 0x8F85; JUMP; // sstep
case 0x8F85:
                                                     mon("         LDB   $4B14                   ; 8F85: F6 4B 14      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b14); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8F88; JUMP; // sstep
case 0x8F88:
                                                     mon("         ASLB                          ; 8F88: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8F89; JUMP; // sstep
case 0x8F89:
                                                     mon("         LDX   #off_9070               ; 8F89: 8E 90 70      \n");
    clockticks = clockticks + 3; 
    X = 0x9070; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8F8C; JUMP; // sstep
case 0x8F8C:
                                                     mon("         ABX                           ; 8F8C: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0x8F8D; JUMP; // sstep
case 0x8F8D:
                                                     mon("         CMPX  #byte_907C              ; 8F8D: 8C 90 7C      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x907c; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8F90; JUMP; // sstep
case 0x8F90:
                                                     mon("         BCS   L8FA0                   ; 8F90: 25 0E         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8fa0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F92; JUMP; // sstep
case 0x8F92:
                                                     mon("         LDA   $4B14                   ; 8F92: B6 4B 14      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b14); 
    A = val; 
/**/N = val; 
/**/Z = val; 
    V = 0; 
    PC = 0x8F95; JUMP; // sstep
case 0x8F95:
                                                     mon("         LSRA                          ; 8F95: 44            \n");
    val = (UINT8)A; 
    C = val & 1; 
    val = val >> 1; 
    A = val; 
    N = 0; 
    Z = val; 
    clockticks = clockticks + 2; 
    PC = 0x8F96; JUMP; // sstep
case 0x8F96:
                                                     mon("         BCS   L8F9D                   ; 8F96: 25 05         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8f9d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8F98; JUMP; // sstep
case 0x8F98:
                                                     mon("         LDX   #off_9078               ; 8F98: 8E 90 78      \n");
    clockticks = clockticks + 3; 
    X = 0x9078; 
    Z = X; 
    N = (X) >> 8; 
    V = 0; 
    PC = 0x8F9B; JUMP; // sstep
case 0x8F9B:
                                                     mon("         BRA   L8FA0                   ; 8F9B: 20 03         \n");
    PC = 0x8fa0; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8F9D:
                                                     mon("L8F9D    LDX   #off_907A               ; 8F9D: 8E 90 7A      \n");
    clockticks = clockticks + 3; 
    X = 0x907a; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8FA0; JUMP; // sstep
case 0x8FA0:
                                                     mon("L8FA0    LDX   ,X                      ; 8FA0: AE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8FA2; JUMP; // sstep
case 0x8FA2:
                                                     mon("         LDB   <$DD                    ; 8FA2: D6 DD         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xdd); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8FA4; JUMP; // sstep
case 0x8FA4:
                                                     mon("         CMPB  ,X+                     ; 8FA4: E1 80         \n");
    clockticks = clockticks + 6; 
    val = (UINT8)B; 
    arg = rd_mem(X); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    X = X + 1; 
    PC = 0x8FA6; JUMP; // sstep
case 0x8FA6:
                                                     mon("         BLS   L8FAA                   ; 8FA6: 23 02         \n");
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x8faa; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8FA8; JUMP; // sstep
case 0x8FA8:
                                                     mon("         LDB   -1,X                    ; 8FA8: E6 1F         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0xffff)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8FAA; JUMP; // sstep
case 0x8FAA:
                                                     mon("L8FAA    STB   <$DD                    ; 8FAA: D7 DD         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0xdd; 
    wr_mem(ea, val); 
    PC = 0x8FAC; JUMP; // sstep
case 0x8FAC:
                                                     mon("         ASLB                          ; 8FAC: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x8FAD; JUMP; // sstep
case 0x8FAD:
                                                     mon("         LDD   B,X                     ; 8FAD: EC 85         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)B); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8FAF; JUMP; // sstep
case 0x8FAF:
                                                     mon("         STD   <$E4                    ; 8FAF: DD E4         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe4; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8FB1; JUMP; // sstep
case 0x8FB1:
                                                     mon("L8FB1    LDX   #$4900                  ; 8FB1: 8E 49 00      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 3; 
    X = 0x4900; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8FB4; JUMP; // sstep
case 0x8FB4:
                                                     mon("L8FB4    STX   <$5A                    ; 8FB4: 9F 5A         \n");
    clockticks = clockticks + 4; 
    val = X; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0x5a; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8FB6; JUMP; // sstep
case 0x8FB6:
                                                     mon("         LDA   $03,X                   ; 8FB6: A6 03         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0003)); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8FB8; JUMP; // sstep
case 0x8FB8:
                                                     mon("         BEQ   L8FC6                   ; 8FB8: 27 0C         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x8fc6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8FBA; JUMP; // sstep
case 0x8FBA:
                                                     mon("         LDX   <$5A                    ; 8FBA: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x8FBC; JUMP; // sstep
case 0x8FBC:
                                                     mon("         LEAX  $19,X                   ; 8FBC: 30 88 19      \n");
    clockticks = clockticks + 5; 
    X = (X + (SINT8)0x19); 
/**/Z = X; 
    PC = 0x8FBF; JUMP; // sstep
case 0x8FBF:
                                                     mon("         CMPX  #$494B                  ; 8FBF: 8C 49 4B      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x494b; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x8FC2; JUMP; // sstep
case 0x8FC2:
                                                     mon("         BCS   L8FB4                   ; 8FC2: 25 F0         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x8fb4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8FC4; JUMP; // sstep
case 0x8FC4:
                                                     mon("         BRA   locret_9023             ; 8FC4: 20 5D         \n");
    PC = 0x9023; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x8FC6:
                                                     mon("L8FC6    LDU   <$E4                    ; 8FC6: DE E4         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe4)<<8; 
    ea = ea | rd_mem(DP|0xe5); 
    U = ea; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8FC8; JUMP; // sstep
case 0x8FC8:
                                                     mon("         BEQ   locret_9023             ; 8FC8: 27 59         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9023; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8FCA; JUMP; // sstep
case 0x8FCA:
                                                     mon("         LDA   ,U                      ; 8FCA: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x8FCC; JUMP; // sstep
case 0x8FCC:
                                                     mon("         BEQ   locret_9023             ; 8FCC: 27 55         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9023; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x8FCE; JUMP; // sstep
case 0x8FCE:
                                                     mon("         INC   <$E6                    ; 8FCE: 0C E6         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xe6); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem(DP|0xe6, res); 
    clockticks = clockticks + 2; 
    PC = 0x8FD0; JUMP; // sstep
case 0x8FD0:
                                                     mon("         LDD   ,U                      ; 8FD0: EC C4         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(U); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(U+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8FD2; JUMP; // sstep
case 0x8FD2:
                                                     mon("         STD   <$E0                    ; 8FD2: DD E0         \n"); // Pointer to 3D object index
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe0; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8FD4; JUMP; // sstep
case 0x8FD4:
                                                     mon("         LDD   $02,U                   ; 8FD4: EC 42         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8FD6; JUMP; // sstep
case 0x8FD6:
                                                     mon("         STD   <$DE                    ; 8FD6: DD DE         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xde; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8FD8; JUMP; // sstep
case 0x8FD8:
                                                     mon("         LDD   $04,U                   ; 8FD8: EC 44         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(U + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x8FDA; JUMP; // sstep
case 0x8FDA:
                                                     mon("         STD   <$E2                    ; 8FDA: DD E2         \n");
    clockticks = clockticks + 4; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = DP|0xe2; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x8FDC; JUMP; // sstep
case 0x8FDC:
                                                     mon("         LEAU  $06,U                   ; 8FDC: 33 46         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0006); 
    PC = 0x8FDE; JUMP; // sstep
case 0x8FDE:
                                                     mon("         STU   <$E4                    ; 8FDE: DF E4         \n");
    clockticks = clockticks + 4; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0xe4; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0x8FE0; JUMP; // sstep
case 0x8FE0:
                                                     mon("         LDA   #$01                    ; 8FE0: 86 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x01; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8FE2; JUMP; // sstep
case 0x8FE2:
                                                     mon("         STA   $03,X                   ; 8FE2: A7 03         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0003); 
    wr_mem(ea, val); 
    PC = 0x8FE4; JUMP; // sstep
case 0x8FE4:
                                                     mon("         LDU   ,X                      ; 8FE4: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x8FE6; JUMP; // sstep
case 0x8FE6:
                                                     mon("         JSR   LCDC3                   ; 8FE6: BD CD C3      \n"); // Initialise math registers matrix
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe9); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x8f); 
    clockticks = clockticks + 1; 
    PC = 0xcdc3; 
    JUMP;
  case 0x8FE9:
                                                     mon("L8FE9    LDU   ,X                      ; 8FE9: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8FEB; JUMP; // sstep
case 0x8FEB:
                                                     mon("         LDA   #$C0                    ; 8FEB: 86 C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xc0; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x8FED; JUMP; // sstep
case 0x8FED:
                                                     mon("         STA   -16,U                   ; 8FED: A7 50         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfff0); 
    wr_mem(ea, val); 
    PC = 0x8FEF; JUMP; // sstep
case 0x8FEF:
                                                     mon("         STA   -6,U                    ; 8FEF: A7 5A         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(U + 0xfffa); 
    wr_mem(ea, val); 
    PC = 0x8FF1; JUMP; // sstep
case 0x8FF1:
                                                     mon("         CLRA                          ; 8FF1: 4F            \n");
    A = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x8FF2; JUMP; // sstep
case 0x8FF2:
                                                     mon("         STA   $09,X                   ; 8FF2: A7 09         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0009); 
    wr_mem(ea, val); 
    PC = 0x8FF4; JUMP; // sstep
case 0x8FF4:
                                                     mon("         STA   $08,X                   ; 8FF4: A7 08         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0008); 
    wr_mem(ea, val); 
    PC = 0x8FF6; JUMP; // sstep
case 0x8FF6:
                                                     mon("         STA   $06,X                   ; 8FF6: A7 06         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0006); 
    wr_mem(ea, val); 
    PC = 0x8FF8; JUMP; // sstep
case 0x8FF8:
                                                     mon("         STA   $05,X                   ; 8FF8: A7 05         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0005); 
    wr_mem(ea, val); 
    PC = 0x8FFA; JUMP; // sstep
case 0x8FFA:
                                                     mon("         STA   $0B,X                   ; 8FFA: A7 0B         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x000b); 
    wr_mem(ea, val); 
    PC = 0x8FFC; JUMP; // sstep
case 0x8FFC:
                                                     mon("         LDU   <$E0                    ; 8FFC: DE E0         \n"); // Pointer to 3D object index
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe0)<<8; 
    ea = ea | rd_mem(DP|0xe1); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x8FFE; JUMP; // sstep
case 0x8FFE:
                                                     mon("         LDA   $01,U                   ; 8FFE: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9000; JUMP; // sstep
case 0x9000:
                                                     mon("         STA   $07,X                   ; 9000: A7 07         \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = (UINT16)(X + 0x0007); 
    wr_mem(ea, val); 
    PC = 0x9002; JUMP; // sstep
case 0x9002:
                                                     mon("         LDU   ,X                      ; 9002: EE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x9004; JUMP; // sstep
case 0x9004:
                                                     mon("         LDX   <$E2                    ; 9004: 9E E2         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0xe2)<<8; 
    ea = ea | rd_mem(DP|0xe3); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9006; JUMP; // sstep
case 0x9006:
                                                     mon("         LDD   ,X                      ; 9006: EC 84         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(X); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(X+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9008; JUMP; // sstep
case 0x9008:
                                                     mon("         STD   $08,U                   ; 9008: ED 48         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x0008); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x900A; JUMP; // sstep
case 0x900A:
                                                     mon("         LDD   $02,X                   ; 900A: EC 02         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x900C; JUMP; // sstep
case 0x900C:
                                                     mon("         STD   $0A,U                   ; 900C: ED 4A         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000a); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x900E; JUMP; // sstep
case 0x900E:
                                                     mon("         LDD   $04,X                   ; 900E: EC 04         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0004); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9010; JUMP; // sstep
case 0x9010:
                                                     mon("         STD   $0C,U                   ; 9010: ED 4C         \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = (UINT16)(U + 0x000c); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x9012; JUMP; // sstep
case 0x9012:
                                                     mon("         LDX   <$5A                    ; 9012: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9014; JUMP; // sstep
case 0x9014:
                                                     mon("         LDD   <$DE                    ; 9014: DC DE         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0xde); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0xdf); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9016; JUMP; // sstep
case 0x9016:
                                                     mon("         STD   $0D,X                   ; 9016: ED 0D         \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = (UINT16)(X + 0x000d); 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    PC = 0x9018; JUMP; // sstep
case 0x9018:
                                                     mon("         JSR   L8E23                   ; 9018: BD 8E 23      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x1b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x90); 
    clockticks = clockticks + 1; 
    PC = 0x8e23; 
    JUMP;
  case 0x901B:
                                                     mon("L901B    LDX   <$5A                    ; 901B: 9E 5A         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x5a)<<8; 
    ea = ea | rd_mem(DP|0x5b); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x901D; JUMP; // sstep
case 0x901D:
                                                     mon("         LDB   [$48E0]                 ; 901D: E6 9F 48 E0   \n"); // Pointer to 3D object index
    clockticks = clockticks + 6; 
    clockticks = clockticks + 2; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x48e0)<<8; 
    ea = ea | rd_mem(0x48e1); 
    val = (UINT8)rd_mem(ea); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9021; JUMP; // sstep
case 0x9021:
                                                     mon("         STB   $04,X                   ; 9021: E7 04         \n");
    clockticks = clockticks + 5; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = (UINT16)(X + 0x0004); 
    wr_mem(ea, val); 
    // End of function sub_8F7B
    // ---------------------------------------------------------------------------
    PC = 0x9023; JUMP; // sstep
case 0x9023:
                                                     mon("locret_9023 RTS                           ; 9023: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x953B:
                                                     mon("L953B    LDA   $4592                   ; 953B: B6 45 92      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4592); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x953E; JUMP; // sstep
case 0x953E:
                                                     mon("         ANDA  #$03                    ; 953E: 84 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x03; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x9540; JUMP; // sstep
case 0x9540:
                                                     mon("         BEQ   locret_9557             ; 9540: 27 15         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9557; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9542; JUMP; // sstep
case 0x9542:
                                                     mon("         ADDA  <$60                    ; 9542: 9B 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x60); 
    res = val + (UINT8)arg; 
/**/C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x9544; JUMP; // sstep
case 0x9544:
                                                     mon("         STA   <$60                    ; 9544: 97 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x60; 
    wr_mem(ea, val); 
    PC = 0x9546; JUMP; // sstep
case 0x9546:
                                                     mon("         LDA   $4593                   ; 9546: B6 45 93      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4593); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9549; JUMP; // sstep
case 0x9549:
                                                     mon("         ANDA  #$03                    ; 9549: 84 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x03; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x954B; JUMP; // sstep
case 0x954B:
                                                     mon("         ADDA  #$06                    ; 954B: 8B 06         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x06; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x954D; JUMP; // sstep
case 0x954D:
                                                     mon("         CMPA  <$60                    ; 954D: 91 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x60); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x954F; JUMP; // sstep
case 0x954F:
                                                     mon("         BCC   L9553                   ; 954F: 24 02         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0x9553; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9551; JUMP; // sstep
case 0x9551:
                                                     mon("         STA   <$60                    ; 9551: 97 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x60; 
    wr_mem(ea, val); 
    PC = 0x9553; JUMP; // sstep
case 0x9553:
                                                     mon("L9553    LDA   #$14                    ; 9553: 86 14         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x14; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9555; JUMP; // sstep
case 0x9555:
                                                     mon("         STA   <$61                    ; 9555: 97 61         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x61; 
    wr_mem(ea, val); 
    // End of function sub_953B
    PC = 0x9557; JUMP; // sstep
case 0x9557:
                                                     mon("locret_9557 RTS                           ; 9557: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Process shields
  case 0x9558:
                                                     mon("L9558    LDA   <$8B                    ; 9558: 96 8B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8b); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x955A; JUMP; // sstep
case 0x955A:
                                                     mon("         BLE   L95A0                   ; 955A: 2F 44         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) <  0) || (!Z)) {
    PC = 0x95a0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x955C; JUMP; // sstep
case 0x955C:
                                                     mon("         LDA   <$8C                    ; 955C: 96 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8c); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x955E; JUMP; // sstep
case 0x955E:
                                                     mon("         BGT   L95A0                   ; 955E: 2E 40         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x95a0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9560; JUMP; // sstep
case 0x9560:
                                                     mon("         LDA   #$01                    ; 9560: 86 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x01; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9562; JUMP; // sstep
case 0x9562:
                                                     mon("         STA   <$8C                    ; 9562: 97 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8c; 
    wr_mem(ea, val); 
    PC = 0x9564; JUMP; // sstep
case 0x9564:
                                                     mon("         LDA   <$60                    ; 9564: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9566; JUMP; // sstep
case 0x9566:
                                                     mon("         STA   <$8E                    ; 9566: 97 8E         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8e; 
    wr_mem(ea, val); 
    PC = 0x9568; JUMP; // sstep
case 0x9568:
                                                     mon("         LDA   #$F6                    ; 9568: 86 F6         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xf6; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x956A; JUMP; // sstep
case 0x956A:
                                                     mon("         ADDA  <$60                    ; 956A: 9B 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x60); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x956C; JUMP; // sstep
case 0x956C:
                                                     mon("         STA   <$8D                    ; 956C: 97 8D         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8d; 
    wr_mem(ea, val); 
    PC = 0x956E; JUMP; // sstep
case 0x956E:
                                                     mon("L956E    DEC   <$60                    ; 956E: 0A 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x60, res); 
    clockticks = clockticks + 2; 
    PC = 0x9570; JUMP; // sstep
case 0x9570:
                                                     mon("         BGE   L9578                   ; 9570: 2C 06         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x9578; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9572; JUMP; // sstep
case 0x9572:
                                                     mon("         LDA   #$FF                    ; 9572: 86 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xff; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9574; JUMP; // sstep
case 0x9574:
                                                     mon("         STA   <$60                    ; 9574: 97 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x60; 
    wr_mem(ea, val); 
    PC = 0x9576; JUMP; // sstep
case 0x9576:
                                                     mon("         CLR   <$8C                    ; 9576: 0F 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    wr_mem(DP|0x8c, 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
/**/C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9578; JUMP; // sstep
case 0x9578:
                                                     mon("L9578    LDA   <$60                    ; 9578: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x957A; JUMP; // sstep
case 0x957A:
                                                     mon("         CMPA  #$00                    ; 957A: 81 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x00; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x957C; JUMP; // sstep
case 0x957C:
                                                     mon("         BNE   L9586                   ; 957C: 26 08         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9586; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x957E; JUMP; // sstep
case 0x957E:
                                                     mon("         JSR   Sound_D                 ; 957E: BD BD 35      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x81); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xbd35; 
    JUMP;
  case 0x9581:
                                                     mon("L9581    JSR   Sound_28                ; 9581: BD BD BC      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x84); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xbdbc; 
    JUMP;
  case 0x9584:
                                                     mon("L9584    BRA   L9599                   ; 9584: 20 13         \n");
    PC = 0x9599; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x9586:
                                                     mon("L9586    CMPA  #$01                    ; 9586: 81 01         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x01; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x9588; JUMP; // sstep
case 0x9588:
                                                     mon("         BNE   L958F                   ; 9588: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x958f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x958A; JUMP; // sstep
case 0x958A:
                                                     mon("         JSR   Sound_2F                ; 958A: BD BD DF      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x8d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xbddf; 
    JUMP;
  case 0x958D:
                                                     mon("L958D    BRA   L9599                   ; 958D: 20 0A         \n");
    PC = 0x9599; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x958F:
                                                     mon("L958F    CMPA  #$02                    ; 958F: 81 02         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x02; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x9591; JUMP; // sstep
case 0x9591:
                                                     mon("         BNE   L9599                   ; 9591: 26 06         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9599; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9593; JUMP; // sstep
case 0x9593:
                                                     mon("         JSR   Sound_F                 ; 9593: BD BD 3F      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x96); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xbd3f; 
    JUMP;
  case 0x9596:
                                                     mon("L9596    JSR   Sound_30                ; 9596: BD BD E4      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x99); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xbde4; 
    JUMP;
  case 0x9599:
                                                     mon("L9599    CLRB                          ; 9599: 5F            \n");
    B = 0; 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x959A; JUMP; // sstep
case 0x959A:
                                                     mon("         STB   <$91                    ; 959A: D7 91         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x91; 
    wr_mem(ea, val); 
    PC = 0x959C; JUMP; // sstep
case 0x959C:
                                                     mon("         STB   <$90                    ; 959C: D7 90         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x90; 
    wr_mem(ea, val); 
    PC = 0x959E; JUMP; // sstep
case 0x959E:
                                                     mon("         STB   <$8F                    ; 959E: D7 8F         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8f; 
    wr_mem(ea, val); 
    PC = 0x95A0; JUMP; // sstep
case 0x95A0:
                                                     mon("L95A0    LDA   <$61                    ; 95A0: 96 61         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x61); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95A2; JUMP; // sstep
case 0x95A2:
                                                     mon("         BEQ   locret_95A6             ; 95A2: 27 02         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x95a6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95A4; JUMP; // sstep
case 0x95A4:
                                                     mon("         DEC   <$61                    ; 95A4: 0A 61         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x61); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x61, res); 
    clockticks = clockticks + 2; 
    // End of function sub_9558
    PC = 0x95A6; JUMP; // sstep
case 0x95A6:
                                                     mon("locret_95A6 RTS                           ; 95A6: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Insert vector instructions for shields
  case 0x95A7:
                                                     mon("L95A7    LDA   <$8C                    ; 95A7: 96 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8c); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95A9; JUMP; // sstep
case 0x95A9:
                                                     mon("         BNE   L95B2                   ; 95A9: 26 07         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x95b2; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95AB; JUMP; // sstep
case 0x95AB:
                                                     mon("         LDA   <$60                    ; 95AB: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95AD; JUMP; // sstep
case 0x95AD:
                                                     mon("         BGT   L95B2                   ; 95AD: 2E 03         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x95b2; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95AF; JUMP; // sstep
case 0x95AF:
                                                     mon("         JMP   L9604                   ; 95AF: 7E 96 04      \n");
    clockticks = clockticks + 4; 
    PC = 0x9604; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x95B2:
                                                     mon("L95B2    LDB   <$60                    ; 95B2: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x95B4; JUMP; // sstep
case 0x95B4:
                                                     mon("         ASLB                          ; 95B4: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x95B5; JUMP; // sstep
case 0x95B5:
                                                     mon("         LDX   #word_96B6              ; 95B5: 8E 96 B6      \n"); // Shield colour table
    clockticks = clockticks + 3; 
    X = 0x96b6; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x95B8; JUMP; // sstep
case 0x95B8:
                                                     mon("         LDU   B,X                     ; 95B8: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x95BA; JUMP; // sstep
case 0x95BA:
                                                     mon("         STU   ,Y++                    ; 95BA: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x95BC; JUMP; // sstep
case 0x95BC:
                                                     mon("         LDD   #$BA03                  ; 95BC: CC BA 03      \n");
    clockticks = clockticks + 3; 
    A = 0xba; 
    B = 0x03; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x95BF; JUMP; // sstep
case 0x95BF:
                                                     mon("         STD   ,Y++                    ; 95BF: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x95C1; JUMP; // sstep
case 0x95C1:
                                                     mon("         LDD   #$0228                  ; 95C1: CC 02 28      \n");
    clockticks = clockticks + 3; 
    A = 0x02; 
    B = 0x28; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x95C4; JUMP; // sstep
case 0x95C4:
                                                     mon("         STD   ,Y++                    ; 95C4: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x95C6; JUMP; // sstep
case 0x95C6:
                                                     mon("         LDD   #$00                    ; 95C6: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x95C9; JUMP; // sstep
case 0x95C9:
                                                     mon("         STD   ,Y++                    ; 95C9: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x95CB; JUMP; // sstep
case 0x95CB:
                                                     mon("         LDA   <$8C                    ; 95CB: 96 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8c); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95CD; JUMP; // sstep
case 0x95CD:
                                                     mon("         BEQ   L95D4                   ; 95CD: 27 05         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x95d4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95CF; JUMP; // sstep
case 0x95CF:
                                                     mon("         JSR   L962A                   ; 95CF: BD 96 2A      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd2); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0x962a; 
    JUMP;
  case 0x95D2:
                                                     mon("L95D2    BRA   L95D7                   ; 95D2: 20 03         \n");
    PC = 0x95d7; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x95D4:
                                                     mon("L95D4    JSR   L960F                   ; 95D4: BD 96 0F      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd7); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0x960f; 
    JUMP;
  case 0x95D7:
                                                     mon("L95D7    LDD   #$1FD0                  ; 95D7: CC 1F D0      \n");
    clockticks = clockticks + 3; 
    A = 0x1f; 
    B = 0xd0; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x95DA; JUMP; // sstep
case 0x95DA:
                                                     mon("         STD   ,Y++                    ; 95DA: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x95DC; JUMP; // sstep
case 0x95DC:
                                                     mon("         LDD   #$1FF4                  ; 95DC: CC 1F F4      \n");
    clockticks = clockticks + 3; 
    A = 0x1f; 
    B = 0xf4; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x95DF; JUMP; // sstep
case 0x95DF:
                                                     mon("         STD   ,Y++                    ; 95DF: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x95E1; JUMP; // sstep
case 0x95E1:
                                                     mon("         LDA   <$8C                    ; 95E1: 96 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8c); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95E3; JUMP; // sstep
case 0x95E3:
                                                     mon("         BLE   L95EA                   ; 95E3: 2F 05         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) <  0) || (!Z)) {
    PC = 0x95ea; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95E5; JUMP; // sstep
case 0x95E5:
                                                     mon("         LDU   #$A018                  ; 95E5: CE A0 18      \n");
    clockticks = clockticks + 3; 
    U = 0xa018; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x95E8; JUMP; // sstep
case 0x95E8:
                                                     mon("         BRA   L95F2                   ; 95E8: 20 08         \n");
    PC = 0x95f2; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x95EA:
                                                     mon("L95EA    LDB   <$60                    ; 95EA: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x95EC; JUMP; // sstep
case 0x95EC:
                                                     mon("         ASLB                          ; 95EC: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x95ED; JUMP; // sstep
case 0x95ED:
                                                     mon("         LDX   #word_96B6              ; 95ED: 8E 96 B6      \n"); // Shield colour table
    clockticks = clockticks + 3; 
    X = 0x96b6; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x95F0; JUMP; // sstep
case 0x95F0:
                                                     mon("         LDU   B,X                     ; 95F0: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x95F2; JUMP; // sstep
case 0x95F2:
                                                     mon("L95F2    STU   ,Y++                    ; 95F2: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x95F4; JUMP; // sstep
case 0x95F4:
                                                     mon("         CLR   <$AD                    ; 95F4: 0F AD         \n");
    clockticks = clockticks + 4; 
    wr_mem(DP|0xad, 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x95F6; JUMP; // sstep
case 0x95F6:
                                                     mon("         LDA   <$60                    ; 95F6: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x95F8; JUMP; // sstep
case 0x95F8:
                                                     mon("         BGE   L95FB                   ; 95F8: 2C 01         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0x95fb; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x95FA; JUMP; // sstep
case 0x95FA:
                                                     mon("         CLRA                          ; 95FA: 4F            \n");
    A = 0; 
    V = 0; 
    Z = 0; 
    N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x95FB; JUMP; // sstep
case 0x95FB:
                                                     mon("L95FB    JSR   LE7AD                   ; 95FB: BD E7 AD      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xfe); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    PC = 0xe7ad; 
    JUMP;
  case 0x95FE:
                                                     mon("L95FE    LDD   #$8040                  ; 95FE: CC 80 40      \n");
    clockticks = clockticks + 3; 
    A = 0x80; 
    B = 0x40; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9601; JUMP; // sstep
case 0x9601:
                                                     mon("         STD   ,Y++                    ; 9601: ED A1         \n");
    clockticks = clockticks + 7; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x9603; JUMP; // sstep
case 0x9603:
                                                     mon("         RTS                           ; 9603: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // ---------------------------------------------------------------------------
  case 0x9604:
                                                     mon("L9604    LDD   #$7100                  ; 9604: CC 71 00      \n");
    clockticks = clockticks + 3; 
    A = 0x71; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9607; JUMP; // sstep
case 0x9607:
                                                     mon("         STD   ,Y++                    ; 9607: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x9609; JUMP; // sstep
case 0x9609:
                                                     mon("         LDB   #$0E                    ; 9609: C6 0E         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x0e; 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x960B; JUMP; // sstep
case 0x960B:
                                                     mon("         JSR   LE7C7                   ; 960B: BD E7 C7      \n"); // Print text string from pointer table
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x0e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x96); 
    clockticks = clockticks + 1; 
    PC = 0xe7c7; 
    JUMP;
    // End of function sub_95A7
  case 0x960E:
                                                     mon("L960E    RTS                           ; 960E: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x960F:
                                                     mon("L960F    LDB   <$60                    ; 960F: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9611; JUMP; // sstep
case 0x9611:
                                                     mon("         ASLB                          ; 9611: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x9612; JUMP; // sstep
case 0x9612:
                                                     mon("         LDX   #word_96B6              ; 9612: 8E 96 B6      \n"); // Shield colour table
    clockticks = clockticks + 3; 
    X = 0x96b6; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9615; JUMP; // sstep
case 0x9615:
                                                     mon("         LDD   B,X                     ; 9615: EC 85         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)B); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x9617; JUMP; // sstep
case 0x9617:
                                                     mon("         TST   <$61                    ; 9617: 0D 61         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x61); 
    Z = val; 
    N = val; 
    V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9619; JUMP; // sstep
case 0x9619:
                                                     mon("         BEQ   L961D                   ; 9619: 27 02         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x961d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x961B; JUMP; // sstep
case 0x961B:
                                                     mon("         ORB   #$FF                    ; 961B: CA FF         \n");
    clockticks = clockticks + 2; 
    res = B | (UINT8)0xff; 
    B = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x961D; JUMP; // sstep
case 0x961D:
                                                     mon("L961D    STD   ,Y++                    ; 961D: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x961F; JUMP; // sstep
case 0x961F:
                                                     mon("         LDB   <$60                    ; 961F: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9621; JUMP; // sstep
case 0x9621:
                                                     mon("         ASLB                          ; 9621: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x9622; JUMP; // sstep
case 0x9622:
                                                     mon("         LDX   #word_96CA              ; 9622: 8E 96 CA      \n"); // Shield vector table
    clockticks = clockticks + 3; 
    X = 0x96ca; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9625; JUMP; // sstep
case 0x9625:
                                                     mon("         LDU   B,X                     ; 9625: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x9627; JUMP; // sstep
case 0x9627:
                                                     mon("         STU   ,Y++                    ; 9627: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    // End of function sub_960F
    PC = 0x9629; JUMP; // sstep
case 0x9629:
                                                     mon("         RTS                           ; 9629: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x962A:
                                                     mon("L962A    LDA   <$91                    ; 962A: 96 91         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x91); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x962C; JUMP; // sstep
case 0x962C:
                                                     mon("         BNE   L964B                   ; 962C: 26 1D         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x964b; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x962E; JUMP; // sstep
case 0x962E:
                                                     mon("         LDU   #$A018                  ; 962E: CE A0 18      \n");
    clockticks = clockticks + 3; 
    U = 0xa018; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x9631; JUMP; // sstep
case 0x9631:
                                                     mon("         STU   ,Y++                    ; 9631: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x9633; JUMP; // sstep
case 0x9633:
                                                     mon("         LDB   <$8E                    ; 9633: D6 8E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8e); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9635; JUMP; // sstep
case 0x9635:
                                                     mon("         ASLB                          ; 9635: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x9636; JUMP; // sstep
case 0x9636:
                                                     mon("         LDX   #word_96CA              ; 9636: 8E 96 CA      \n"); // Shield vector table
    clockticks = clockticks + 3; 
    X = 0x96ca; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9639; JUMP; // sstep
case 0x9639:
                                                     mon("         LDU   B,X                     ; 9639: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x963B; JUMP; // sstep
case 0x963B:
                                                     mon("         STU   ,Y++                    ; 963B: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x963D; JUMP; // sstep
case 0x963D:
                                                     mon("         LDA   <$43                    ; 963D: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x963F; JUMP; // sstep
case 0x963F:
                                                     mon("         ANDA  #$00                    ; 963F: 84 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x00; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x9641; JUMP; // sstep
case 0x9641:
                                                     mon("         BNE   L9649                   ; 9641: 26 06         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9649; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9643; JUMP; // sstep
case 0x9643:
                                                     mon("L9643    INC   <$8D                    ; 9643: 0C 8D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8d); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x8d, res); 
    clockticks = clockticks + 2; 
    PC = 0x9645; JUMP; // sstep
case 0x9645:
                                                     mon("         BLT   L9649                   ; 9645: 2D 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0x9649; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9647; JUMP; // sstep
case 0x9647:
                                                     mon("         INC   <$91                    ; 9647: 0C 91         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x91); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x91, res); 
    clockticks = clockticks + 2; 
    PC = 0x9649; JUMP; // sstep
case 0x9649:
                                                     mon("L9649    BRA   locret_96A0             ; 9649: 20 55         \n");
    PC = 0x96a0; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x964B:
                                                     mon("L964B    JSR   L96A1                   ; 964B: BD 96 A1      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x4e); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x96); 
    clockticks = clockticks + 1; 
    PC = 0x96a1; 
    JUMP;
  case 0x964E:
                                                     mon("L964E    LDU   #$A018                  ; 964E: CE A0 18      \n");
    clockticks = clockticks + 3; 
    U = 0xa018; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x9651; JUMP; // sstep
case 0x9651:
                                                     mon("         STU   ,Y++                    ; 9651: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x9653; JUMP; // sstep
case 0x9653:
                                                     mon("         LDA   <$90                    ; 9653: 96 90         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x90); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9655; JUMP; // sstep
case 0x9655:
                                                     mon("         BNE   L9674                   ; 9655: 26 1D         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9674; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9657; JUMP; // sstep
case 0x9657:
                                                     mon("         LDB   <$8E                    ; 9657: D6 8E         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8e); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9659; JUMP; // sstep
case 0x9659:
                                                     mon("         ASLB                          ; 9659: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x965A; JUMP; // sstep
case 0x965A:
                                                     mon("         LDX   #word_96DE              ; 965A: 8E 96 DE      \n"); // Another copy of shield vector table??
    clockticks = clockticks + 3; 
    X = 0x96de; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x965D; JUMP; // sstep
case 0x965D:
                                                     mon("         LDU   B,X                     ; 965D: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x965F; JUMP; // sstep
case 0x965F:
                                                     mon("         STU   ,Y++                    ; 965F: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x9661; JUMP; // sstep
case 0x9661:
                                                     mon("         LDA   <$43                    ; 9661: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9663; JUMP; // sstep
case 0x9663:
                                                     mon("         ANDA  #$00                    ; 9663: 84 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x00; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x9665; JUMP; // sstep
case 0x9665:
                                                     mon("         BNE   L9672                   ; 9665: 26 0B         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9672; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9667; JUMP; // sstep
case 0x9667:
                                                     mon("         INC   <$90                    ; 9667: 0C 90         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x90); 
    res = (UINT8)(val + 1); 
/**/Z = res; 
/**/N = res; 
/**/V = res & ~val; 
    wr_mem(DP|0x90, res); 
    clockticks = clockticks + 2; 
    PC = 0x9669; JUMP; // sstep
case 0x9669:
                                                     mon("         LDB   <$60                    ; 9669: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x966B; JUMP; // sstep
case 0x966B:
                                                     mon("         LDX   #byte_9718              ; 966B: 8E 97 18      \n");
    clockticks = clockticks + 3; 
    X = 0x9718; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x966E; JUMP; // sstep
case 0x966E:
                                                     mon("         LDA   B,X                     ; 966E: A6 85         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + (SINT8)B)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9670; JUMP; // sstep
case 0x9670:
                                                     mon("         STA   <$8D                    ; 9670: 97 8D         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x8d; 
    wr_mem(ea, val); 
    PC = 0x9672; JUMP; // sstep
case 0x9672:
                                                     mon("L9672    BRA   locret_96A0             ; 9672: 20 2C         \n");
    PC = 0x96a0; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x9674:
                                                     mon("L9674    LDA   <$8F                    ; 9674: 96 8F         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8f); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9676; JUMP; // sstep
case 0x9676:
                                                     mon("         BNE   L9690                   ; 9676: 26 18         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9690; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9678; JUMP; // sstep
case 0x9678:
                                                     mon("         LDB   <$8D                    ; 9678: D6 8D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8d); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x967A; JUMP; // sstep
case 0x967A:
                                                     mon("         ASLB                          ; 967A: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x967B; JUMP; // sstep
case 0x967B:
                                                     mon("         LDX   #word_96F2              ; 967B: 8E 96 F2      \n");
    clockticks = clockticks + 3; 
    X = 0x96f2; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x967E; JUMP; // sstep
case 0x967E:
                                                     mon("         LDU   B,X                     ; 967E: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x9680; JUMP; // sstep
case 0x9680:
                                                     mon("         STU   ,Y++                    ; 9680: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    PC = 0x9682; JUMP; // sstep
case 0x9682:
                                                     mon("         LDA   <$43                    ; 9682: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9684; JUMP; // sstep
case 0x9684:
                                                     mon("         ANDA  #$00                    ; 9684: 84 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x00; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x9686; JUMP; // sstep
case 0x9686:
                                                     mon("         BNE   L968E                   ; 9686: 26 06         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x968e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9688; JUMP; // sstep
case 0x9688:
                                                     mon("         DEC   <$8D                    ; 9688: 0A 8D         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8d); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem(DP|0x8d, res); 
    clockticks = clockticks + 2; 
    PC = 0x968A; JUMP; // sstep
case 0x968A:
                                                     mon("         BGT   L968E                   ; 968A: 2E 02         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0x968e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x968C; JUMP; // sstep
case 0x968C:
                                                     mon("         INC   <$8F                    ; 968C: 0C 8F         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8f); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x8f, res); 
    clockticks = clockticks + 2; 
    PC = 0x968E; JUMP; // sstep
case 0x968E:
                                                     mon("L968E    BRA   locret_96A0             ; 968E: 20 10         \n");
    PC = 0x96a0; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x9690:
                                                     mon("L9690    LDA   <$43                    ; 9690: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9692; JUMP; // sstep
case 0x9692:
                                                     mon("         ANDA  #$00                    ; 9692: 84 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x00; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x9694; JUMP; // sstep
case 0x9694:
                                                     mon("         BNE   locret_96A0             ; 9694: 26 0A         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x96a0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9696; JUMP; // sstep
case 0x9696:
                                                     mon("         LDA   #$00                    ; 9696: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9698; JUMP; // sstep
case 0x9698:
                                                     mon("         STA   <$8C                    ; 9698: 97 8C         \n"); // Sheild being depleted
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8c; 
    wr_mem(ea, val); 
    PC = 0x969A; JUMP; // sstep
case 0x969A:
                                                     mon("         STA   <$8B                    ; 969A: 97 8B         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x8b; 
    wr_mem(ea, val); 
    PC = 0x969C; JUMP; // sstep
case 0x969C:
                                                     mon("         LDA   <$60                    ; 969C: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x969E; JUMP; // sstep
case 0x969E:
                                                     mon("         STA   <$8E                    ; 969E: 97 8E         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x8e; 
    wr_mem(ea, val); 
    // End of function sub_962A
    PC = 0x96A0; JUMP; // sstep
case 0x96A0:
                                                     mon("locret_96A0 RTS                           ; 96A0: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x96A1:
                                                     mon("L96A1    LDB   <$60                    ; 96A1: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x96A3; JUMP; // sstep
case 0x96A3:
                                                     mon("         ASLB                          ; 96A3: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x96A4; JUMP; // sstep
case 0x96A4:
                                                     mon("         LDX   #word_96B6              ; 96A4: 8E 96 B6      \n"); // Shield colour table
    clockticks = clockticks + 3; 
    X = 0x96b6; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x96A7; JUMP; // sstep
case 0x96A7:
                                                     mon("         LDD   B,X                     ; 96A7: EC 85         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + (SINT8)B); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x96A9; JUMP; // sstep
case 0x96A9:
                                                     mon("         STD   ,Y++                    ; 96A9: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x96AB; JUMP; // sstep
case 0x96AB:
                                                     mon("         LDB   <$60                    ; 96AB: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x96AD; JUMP; // sstep
case 0x96AD:
                                                     mon("         ASLB                          ; 96AD: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x96AE; JUMP; // sstep
case 0x96AE:
                                                     mon("         LDX   #word_96CA              ; 96AE: 8E 96 CA      \n"); // Shield vector table
    clockticks = clockticks + 3; 
    X = 0x96ca; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x96B1; JUMP; // sstep
case 0x96B1:
                                                     mon("         LDU   B,X                     ; 96B1: EE 85         \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(X + (SINT8)B))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(X + (SINT8)B))+1)); 
    U = ea; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x96B3; JUMP; // sstep
case 0x96B3:
                                                     mon("         STU   ,Y++                    ; 96B3: EF A1         \n");
    clockticks = clockticks + 7; 
    val = U; 
    Z = val; 
    N = (UINT8)(val >> 8); 
    V = 0; 
    ea = Y; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    Y = Y + 2; 
    // End of function sub_96A1
    // ---------------------------------------------------------------------------
    PC = 0x96B5; JUMP; // sstep
case 0x96B5:
                                                     mon("         RTS                           ; 96B5: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Death Star starting wave bonus score
  case 0x9722:
                                                     mon("L9722    LDA   $4B2D                   ; 9722: B6 4B 2D      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b2d); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9725; JUMP; // sstep
case 0x9725:
                                                     mon("         BNE   locret_9739             ; 9725: 26 12         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9739; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9727; JUMP; // sstep
case 0x9727:
                                                     mon("         LDB   $4B15                   ; 9727: F6 4B 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b15); 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x972A; JUMP; // sstep
case 0x972A:
                                                     mon("         BEQ   locret_9739             ; 972A: 27 0D         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9739; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x972C; JUMP; // sstep
case 0x972C:
                                                     mon("         ASLB                          ; 972C: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x972D; JUMP; // sstep
case 0x972D:
                                                     mon("         ADDB  $4B15                   ; 972D: FB 4B 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)B; 
    arg = rd_mem(0x4b15); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    B = (UINT8)res; 
    PC = 0x9730; JUMP; // sstep
case 0x9730:
                                                     mon("         LDX   #byte_9865              ; 9730: 8E 98 65      \n"); // Death Star destroyed  incrementing score value, Also has unused starting wave bonus scores of 200,000 and 600,000, for waves 2 and 4
    clockticks = clockticks + 3; 
    X = 0x9865; 
    Z = X; 
    N = (X) >> 8; 
    V = 0; 
    PC = 0x9733; JUMP; // sstep
case 0x9733:
                                                     mon("         ABX                           ; 9733: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0x9734; JUMP; // sstep
case 0x9734:
                                                     mon("         TFR   X,U                     ; 9734: 1F 13         \n");
    U = X; 
    clockticks = clockticks + 6; 
    PC = 0x9736; JUMP; // sstep
case 0x9736:
                                                     mon("         JSR   L9810                   ; 9736: BD 98 10      \n"); // Add to score total
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x39); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x9810; 
    JUMP;
    // End of function sub_9722
  case 0x9739:
                                                     mon("locret_9739 RTS                           ; 9739: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Towers incrementing score
  case 0x973A:
                                                     mon("L973A    LDU   #$4B2E                  ; 973A: CE 4B 2E      \n"); // Temporary score adder towers 1
    clockticks = clockticks + 3; 
    U = 0x4b2e; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x973D; JUMP; // sstep
case 0x973D:
                                                     mon("         JSR   L9810                   ; 973D: BD 98 10      \n"); // Add to score total
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x40); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x9810; 
    JUMP;
  case 0x9740:
                                                     mon("L9740    LDX   #word_9856              ; 9740: 8E 98 56      \n");
    clockticks = clockticks + 3; 
    X = 0x9856; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x9743; JUMP; // sstep
case 0x9743:
                                                     mon("         LDA   $4B30                   ; 9743: B6 4B 30      \n"); // Temporary score adder towers 3
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b30); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9746; JUMP; // sstep
case 0x9746:
                                                     mon("         ADDA  $02,X                   ; 9746: AB 02         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem((UINT16)(X + 0x0002)); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x9748; JUMP; // sstep
case 0x9748:
                                                     mon("         DAA                           ; 9748: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9749; JUMP; // sstep
case 0x9749:
                                                     mon("         STA   $4B30                   ; 9749: B7 4B 30      \n"); // Temporary score adder towers 3
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b30, val); 
    PC = 0x974C; JUMP; // sstep
case 0x974C:
                                                     mon("         LDA   $4B2F                   ; 974C: B6 4B 2F      \n"); // Temporary score adder towers 2
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b2f); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x974F; JUMP; // sstep
case 0x974F:
                                                     mon("         ADCA  $01,X                   ; 974F: A9 01         \n");
    clockticks = clockticks + 5; 
    arg = A; 
    val = rd_mem((UINT16)(X + 0x0001)); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x9751; JUMP; // sstep
case 0x9751:
                                                     mon("         DAA                           ; 9751: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9752; JUMP; // sstep
case 0x9752:
                                                     mon("         STA   $4B2F                   ; 9752: B7 4B 2F      \n"); // Temporary score adder towers 2
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2f, val); 
    PC = 0x9755; JUMP; // sstep
case 0x9755:
                                                     mon("         LDA   $4B2E                   ; 9755: B6 4B 2E      \n"); // Temporary score adder towers 1
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b2e); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9758; JUMP; // sstep
case 0x9758:
                                                     mon("         ADCA  ,X                      ; 9758: A9 84         \n");
    clockticks = clockticks + 4; 
    arg = A; 
    val = rd_mem(X); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x975A; JUMP; // sstep
case 0x975A:
                                                     mon("         DAA                           ; 975A: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x975B; JUMP; // sstep
case 0x975B:
                                                     mon("         STA   $4B2E                   ; 975B: B7 4B 2E      \n"); // Temporary score adder towers 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2e, val); 
    PC = 0x975E; JUMP; // sstep
case 0x975E:
                                                     mon("         LDA   $4B1A                   ; 975E: B6 4B 1A      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b1a); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9761; JUMP; // sstep
case 0x9761:
                                                     mon("         BEQ   locret_9774             ; 9761: 27 11         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9774; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9763; JUMP; // sstep
case 0x9763:
                                                     mon("         ADDA  #$99                    ; 9763: 8B 99         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x99; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x9765; JUMP; // sstep
case 0x9765:
                                                     mon("         DAA                           ; 9765: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9766; JUMP; // sstep
case 0x9766:
                                                     mon("         STA   $4B1A                   ; 9766: B7 4B 1A      \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    wr_mem(0x4b1a, val); 
    PC = 0x9769; JUMP; // sstep
case 0x9769:
                                                     mon("         BNE   locret_9774             ; 9769: 26 09         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9774; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x976B; JUMP; // sstep
case 0x976B:
                                                     mon("         LDU   #byte_9862              ; 976B: CE 98 62      \n"); // Cleared all towers score value
    clockticks = clockticks + 3; 
    U = 0x9862; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x976E; JUMP; // sstep
case 0x976E:
                                                     mon("         JSR   L9810                   ; 976E: BD 98 10      \n"); // Add to score total
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x71); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x9810; 
    JUMP;
  case 0x9771:
                                                     mon("L9771    INC   $4B35                   ; 9771: 7C 4B 35      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b35); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(0x4b35, res); 
    clockticks = clockticks + 2; 
    // End of function sub_973A
    PC = 0x9774; JUMP; // sstep
case 0x9774:
                                                     mon("locret_9774 RTS                           ; 9774: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Shield bonus score
  case 0x9775:
                                                     mon("L9775    LDB   <$60                    ; 9775: D6 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9777; JUMP; // sstep
case 0x9777:
                                                     mon("         BEQ   locret_97AB             ; 9777: 27 32         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x97ab; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9779; JUMP; // sstep
case 0x9779:
                                                     mon("         LDU   #byte_9865              ; 9779: CE 98 65      \n"); // Death Star destroyed  incrementing score value, Also has unused starting wave bonus scores of 200,000 and 600,000, for waves 2 and 4
    clockticks = clockticks + 3; 
    U = 0x9865; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0x977C; JUMP; // sstep
case 0x977C:
                                                     mon("         LDA   #$00                    ; 977C: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x977E; JUMP; // sstep
case 0x977E:
                                                     mon("         STA   $4B29                   ; 977E: B7 4B 29      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b29, val); 
    PC = 0x9781; JUMP; // sstep
case 0x9781:
                                                     mon("         STA   $4B2A                   ; 9781: B7 4B 2A      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2a, val); 
    PC = 0x9784; JUMP; // sstep
case 0x9784:
                                                     mon("         STA   $4B2B                   ; 9784: B7 4B 2B      \n"); // Temporary score adder 2
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2b, val); 
    PC = 0x9787; JUMP; // sstep
case 0x9787:
                                                     mon("L9787    LDA   $02,U                   ; 9787: A6 42         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0002)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9789; JUMP; // sstep
case 0x9789:
                                                     mon("         ADDA  $4B2B                   ; 9789: BB 4B 2B      \n"); // Temporary score adder 2
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem(0x4b2b); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x978C; JUMP; // sstep
case 0x978C:
                                                     mon("         DAA                           ; 978C: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x978D; JUMP; // sstep
case 0x978D:
                                                     mon("         STA   $4B2B                   ; 978D: B7 4B 2B      \n"); // Temporary score adder 2
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2b, val); 
    PC = 0x9790; JUMP; // sstep
case 0x9790:
                                                     mon("         LDA   $01,U                   ; 9790: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9792; JUMP; // sstep
case 0x9792:
                                                     mon("         ADCA  $4B2A                   ; 9792: B9 4B 2A      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    arg = A; 
    val = rd_mem(0x4b2a); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x9795; JUMP; // sstep
case 0x9795:
                                                     mon("         DAA                           ; 9795: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9796; JUMP; // sstep
case 0x9796:
                                                     mon("         STA   $4B2A                   ; 9796: B7 4B 2A      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2a, val); 
    PC = 0x9799; JUMP; // sstep
case 0x9799:
                                                     mon("         LDA   ,U                      ; 9799: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x979B; JUMP; // sstep
case 0x979B:
                                                     mon("         ADCA  $4B29                   ; 979B: B9 4B 29      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    arg = A; 
    val = rd_mem(0x4b29); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x979E; JUMP; // sstep
case 0x979E:
                                                     mon("         DAA                           ; 979E: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x979F; JUMP; // sstep
case 0x979F:
                                                     mon("         STA   $4B29                   ; 979F: B7 4B 29      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b29, val); 
    PC = 0x97A2; JUMP; // sstep
case 0x97A2:
                                                     mon("         DECB                          ; 97A2: 5A            \n");
    val = (UINT8)B; 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x97A3; JUMP; // sstep
case 0x97A3:
                                                     mon("         BNE   L9787                   ; 97A3: 26 E2         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x9787; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x97A5; JUMP; // sstep
case 0x97A5:
                                                     mon("         LDU   #$4B29                  ; 97A5: CE 4B 29      \n"); // Temporary score adder 1
    clockticks = clockticks + 3; 
    U = 0x4b29; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x97A8; JUMP; // sstep
case 0x97A8:
                                                     mon("         JSR   L9810                   ; 97A8: BD 98 10      \n"); // Add to score total
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xab); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x9810; 
    JUMP;
    // End of function sub_9775
  case 0x97AB:
                                                     mon("locret_97AB RTS                           ; 97AB: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Used the force score
  case 0x97AC:
                                                     mon("L97AC    LDB   $4B15                   ; 97AC: F6 4B 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b15); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x97AF; JUMP; // sstep
case 0x97AF:
                                                     mon("         CMPB  #$05                    ; 97AF: C1 05         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x05; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x97B1; JUMP; // sstep
case 0x97B1:
                                                     mon("         BCS   L97B8                   ; 97B1: 25 05         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x97b8; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x97B3; JUMP; // sstep
case 0x97B3:
                                                     mon("         LDU   #byte_9847              ; 97B3: CE 98 47      \n"); // Using Force score value
    clockticks = clockticks + 3; 
    U = 0x9847; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x97B6; JUMP; // sstep
case 0x97B6:
                                                     mon("         BRA   locret_97C1             ; 97B6: 20 09         \n");
    PC = 0x97c1; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x97B8:
                                                     mon("L97B8    ASLB                          ; 97B8: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x97B9; JUMP; // sstep
case 0x97B9:
                                                     mon("         ADDB  $4B15                   ; 97B9: FB 4B 15      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)B; 
    arg = rd_mem(0x4b15); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    B = (UINT8)res; 
    PC = 0x97BC; JUMP; // sstep
case 0x97BC:
                                                     mon("         LDU   #byte_983B              ; 97BC: CE 98 3B      \n");
    clockticks = clockticks + 3; 
    U = 0x983b; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x97BF; JUMP; // sstep
case 0x97BF:
                                                     mon("         LEAU  B,U                     ; 97BF: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    // End of function sub_97AC
    PC = 0x97C1; JUMP; // sstep
case 0x97C1:
                                                     mon("locret_97C1 RTS                           ; 97C1: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x97C2:
                                                     mon("L97C2    LDD   #$A01A                  ; 97C2: CC A0 1A      \n");
    clockticks = clockticks + 3; 
    A = 0xa0; 
    B = 0x1a; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x97C5; JUMP; // sstep
case 0x97C5:
                                                     mon("         STD   ,Y++                    ; 97C5: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x97C7; JUMP; // sstep
case 0x97C7:
                                                     mon("         LDD   #$0180                  ; 97C7: CC 01 80      \n");
    clockticks = clockticks + 3; 
    A = 0x01; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x97CA; JUMP; // sstep
case 0x97CA:
                                                     mon("         STD   ,Y++                    ; 97CA: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x97CC; JUMP; // sstep
case 0x97CC:
                                                     mon("         LDD   #$1EC0                  ; 97CC: CC 1E C0      \n");
    clockticks = clockticks + 3; 
    A = 0x1e; 
    B = 0xc0; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x97CF; JUMP; // sstep
case 0x97CF:
                                                     mon("         STD   ,Y++                    ; 97CF: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x97D1; JUMP; // sstep
case 0x97D1:
                                                     mon("         LDA   #$04                    ; 97D1: 86 04         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x04; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x97D3; JUMP; // sstep
case 0x97D3:
                                                     mon("         STA   <$AD                    ; 97D3: 97 AD         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0xad; 
    wr_mem(ea, val); 
    PC = 0x97D5; JUMP; // sstep
case 0x97D5:
                                                     mon("         JSR   L97AC                   ; 97D5: BD 97 AC      \n"); // Used the force score
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xd8); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x97ac; 
    JUMP;
  case 0x97D8:
                                                     mon("L97D8    LEAX  -1,U                    ; 97D8: 30 5F         \n");
    clockticks = clockticks + 5; 
    X = (U + 0xffff); 
    Z = X; 
    PC = 0x97DA; JUMP; // sstep
case 0x97DA:
                                                     mon("         JSR   LE772                   ; 97DA: BD E7 72      \n"); // Display BCD number text
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xdd); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0xe772; 
    JUMP;
  case 0x97DD:
                                                     mon("L97DD    LDB   #$50                    ; 97DD: C6 50         \n"); // 'For using the Force' text
    clockticks = clockticks + 2; 
    val = (UINT8)0x50; 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x97DF; JUMP; // sstep
case 0x97DF:
                                                     mon("         JSR   LE7C7                   ; 97DF: BD E7 C7      \n"); // Print text string from pointer table
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe2); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0xe7c7; 
    JUMP;
    // End of function sub_97C2
  case 0x97E2:
                                                     mon("L97E2    RTS                           ; 97E2: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x97E3:
                                                     mon("L97E3    JSR   L97AC                   ; 97E3: BD 97 AC      \n"); // Used the force score
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe6); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0x97); 
    clockticks = clockticks + 1; 
    PC = 0x97ac; 
    JUMP;
    // End of function sub_97E3
  case 0x97E6:
                                                     mon("L97E6    BRA   L9810                   ; 97E6: 20 28         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Tie fighter score
  case 0x97E8:
                                                     mon("L97E8    LDU   #byte_984A              ; 97E8: CE 98 4A      \n"); // Tie fighter score value
    clockticks = clockticks + 3; 
    U = 0x984a; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    // End of function sub_97E8
    PC = 0x97EB; JUMP; // sstep
case 0x97EB:
                                                     mon("         BRA   L9810                   ; 97EB: 20 23         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Vaders tie score
  case 0x97ED:
                                                     mon("L97ED    LDU   #byte_984D              ; 97ED: CE 98 4D      \n"); // Vaders tie score value
    clockticks = clockticks + 3; 
    U = 0x984d; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    // End of function sub_97ED
    PC = 0x97F0; JUMP; // sstep
case 0x97F0:
                                                     mon("         BRA   L9810                   ; 97F0: 20 1E         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Trench green squares score
  case 0x97F2:
                                                     mon("L97F2    LDU   #byte_9850              ; 97F2: CE 98 50      \n"); // Trench green squares score value
    clockticks = clockticks + 3; 
    U = 0x9850; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    // End of function sub_97F2
    PC = 0x97F5; JUMP; // sstep
case 0x97F5:
                                                     mon("         BRA   L9810                   ; 97F5: 20 19         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Laser tower score
  case 0x97F7:
                                                     mon("L97F7    LDU   #byte_9859              ; 97F7: CE 98 59      \n"); // Laser tower score value
    clockticks = clockticks + 3; 
    U = 0x9859; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    // End of function sub_97F7
    PC = 0x97FA; JUMP; // sstep
case 0x97FA:
                                                     mon("         BRA   L9810                   ; 97FA: 20 14         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Trench turrets score
  case 0x97FC:
                                                     mon("L97FC    LDU   #byte_9853              ; 97FC: CE 98 53      \n"); // Trench turrets score value
    clockticks = clockticks + 3; 
    U = 0x9853; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    // End of function sub_97FC
    PC = 0x97FF; JUMP; // sstep
case 0x97FF:
                                                     mon("         BRA   L9810                   ; 97FF: 20 0F         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // =============== S U B R O U T I N E =======================================
    // Fireball score
  case 0x9801:
                                                     mon("L9801    LDU   #byte_985C              ; 9801: CE 98 5C      \n"); // Fireball score value
    clockticks = clockticks + 3; 
    U = 0x985c; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x9804; JUMP; // sstep
case 0x9804:
                                                     mon("         BRA   L9810                   ; 9804: 20 0A         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0x9806:
                                                     mon("L9806    LDU   #byte_985F              ; 9806: CE 98 5F      \n"); // Exhaust port score
    clockticks = clockticks + 3; 
    U = 0x985f; 
    Z = U; 
    N = (U) >> 8; 
    V = 0; 
    PC = 0x9809; JUMP; // sstep
case 0x9809:
                                                     mon("         BRA   L9810                   ; 9809: 20 05         \n"); // Add to score total
    PC = 0x9810; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
                   // FCB   $CE                     ; 980B:  ' ' CE 98 62       LDU   #$9862 ; Cleared all towers score value
                   // FCB   $98                     ; 980C:  ' ' 98 62          EORA  <$62 ; 
                   // FCB   $62                     ; 980D:  'b' 62             Invalid ; 
                   // FCB   $20                     ; 980E:  ' ' 20 00          BRA   $9810 ; 
                   // FCB   $00                     ; 980F:  ' ' 00 A6          NEG   <$A6 ; 
  case 0x9810:
                                                     mon("L9810    LDA   $02,U                   ; 9810: A6 42         \n"); // Add to score total
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0002)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9812; JUMP; // sstep
case 0x9812:
                                                     mon("         STA   $4B2B                   ; 9812: B7 4B 2B      \n"); // Temporary score adder 2
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2b, val); 
    PC = 0x9815; JUMP; // sstep
case 0x9815:
                                                     mon("         ADDA  <$5F                    ; 9815: 9B 5F         \n"); // Score
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x5f); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0x9817; JUMP; // sstep
case 0x9817:
                                                     mon("         DAA                           ; 9817: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9818; JUMP; // sstep
case 0x9818:
                                                     mon("         STA   <$5F                    ; 9818: 97 5F         \n"); // Score
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x5f; 
    wr_mem(ea, val); 
    PC = 0x981A; JUMP; // sstep
case 0x981A:
                                                     mon("         LDA   $01,U                   ; 981A: A6 41         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(U + 0x0001)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x981C; JUMP; // sstep
case 0x981C:
                                                     mon("         STA   $4B2A                   ; 981C: B7 4B 2A      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b2a, val); 
    PC = 0x981F; JUMP; // sstep
case 0x981F:
                                                     mon("         ADCA  <$5E                    ; 981F: 99 5E         \n"); // Score thousands
    clockticks = clockticks + 4; 
    arg = A; 
    val = rd_mem(DP|0x5e); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x9821; JUMP; // sstep
case 0x9821:
                                                     mon("         DAA                           ; 9821: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9822; JUMP; // sstep
case 0x9822:
                                                     mon("         STA   <$5E                    ; 9822: 97 5E         \n"); // Score thousands
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x5e; 
    wr_mem(ea, val); 
    PC = 0x9824; JUMP; // sstep
case 0x9824:
                                                     mon("         LDA   ,U                      ; 9824: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9826; JUMP; // sstep
case 0x9826:
                                                     mon("         STA   $4B29                   ; 9826: B7 4B 29      \n"); // Temporary score adder 1
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b29, val); 
    PC = 0x9829; JUMP; // sstep
case 0x9829:
                                                     mon("         ADCA  <$5D                    ; 9829: 99 5D         \n"); // Score hundred thousands
    clockticks = clockticks + 4; 
    arg = A; 
    val = rd_mem(DP|0x5d); 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x982B; JUMP; // sstep
case 0x982B:
                                                     mon("         DAA                           ; 982B: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x982C; JUMP; // sstep
case 0x982C:
                                                     mon("         STA   <$5D                    ; 982C: 97 5D         \n"); // Score hundred thousands
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x5d; 
    wr_mem(ea, val); 
    PC = 0x982E; JUMP; // sstep
case 0x982E:
                                                     mon("         LDA   <$5C                    ; 982E: 96 5C         \n"); // Score millions
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x5c); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9830; JUMP; // sstep
case 0x9830:
                                                     mon("         ADCA  #$00                    ; 9830: 89 00         \n");
    clockticks = clockticks + 2; 
    arg = A; 
    val = (SINT8)0x00; 
    res = (arg + val) + (C != 0 ? 1:0); 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (arg ^ val) ^ ((UINT8)res ^ C); 
/**/V = (arg ^ val) ^ ((UINT8)res ^ C); 
    A = (UINT8)res; 
    PC = 0x9832; JUMP; // sstep
case 0x9832:
                                                     mon("         DAA                           ; 9832: 19            \n");
    res = A; 
    msn = res & 0xf0; 
    lsn = res & 0x0f; 
    res = res + (((lsn > 0x09) || (H & 0x10)) ? 0x06 : 0); 
    res = res + ((((UINT8)msn > 0x80U) && ((UINT8)lsn > 0x09U)) || (((UINT8)msn > 0x90U) || (C != 0)) ? 0x60 : 0); 
    C = C | (res & 0x100); 
    res = (UINT8)res; 
    A = res; 
/**/N = res; 
/**/Z = res; 
/**/V = 0; 
    clockticks = clockticks + 2; 
    PC = 0x9833; JUMP; // sstep
case 0x9833:
                                                     mon("         STA   <$5C                    ; 9833: 97 5C         \n"); // Score millions
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x5c; 
    wr_mem(ea, val); 
    PC = 0x9835; JUMP; // sstep
case 0x9835:
                                                     mon("         LDA   #$FF                    ; 9835: 86 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xff; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9837; JUMP; // sstep
case 0x9837:
                                                     mon("         STA   $4B2C                   ; 9837: B7 4B 2C      \n");
    clockticks = clockticks + 5; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    wr_mem(0x4b2c, val); 
    // End of function sub_9801
    // ---------------------------------------------------------------------------
    PC = 0x983A; JUMP; // sstep
case 0x983A:
                                                     mon("         RTS                           ; 983A: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x9874:
                                                     mon("L9874    LDA   <$8B                    ; 9874: 96 8B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8b); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9876; JUMP; // sstep
case 0x9876:
                                                     mon("         BNE   locret_987E             ; 9876: 26 06         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x987e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9878; JUMP; // sstep
case 0x9878:
                                                     mon("         LDA   #$10                    ; 9878: 86 10         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x10; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x987A; JUMP; // sstep
case 0x987A:
                                                     mon("         STA   <$62                    ; 987A: 97 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x62; 
    wr_mem(ea, val); 
    PC = 0x987C; JUMP; // sstep
case 0x987C:
                                                     mon("         INC   <$8B                    ; 987C: 0C 8B         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x8b); 
    res = (UINT8)(val + 1); 
    Z = res; 
    N = res; 
    V = res & ~val; 
    wr_mem(DP|0x8b, res); 
    clockticks = clockticks + 2; 
    // End of function sub_9874
    PC = 0x987E; JUMP; // sstep
case 0x987E:
                                                     mon("locret_987E RTS                           ; 987E: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Fireball timer
  case 0x987F:
                                                     mon("L987F    LDA   <$43                    ; 987F: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9881; JUMP; // sstep
case 0x9881:
                                                     mon("         ANDA  #$03                    ; 9881: 84 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x03; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0x9883; JUMP; // sstep
case 0x9883:
                                                     mon("         STA   <$62                    ; 9883: 97 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x62; 
    wr_mem(ea, val); 
    // End of function sub_987F
    PC = 0x9885; JUMP; // sstep
case 0x9885:
                                                     mon("         RTS                           ; 9885: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Fireball timer 2
  case 0x9886:
                                                     mon("L9886    LDB   <$62                    ; 9886: D6 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x62); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x9888; JUMP; // sstep
case 0x9888:
                                                     mon("         CMPB  #$08                    ; 9888: C1 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x08; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0x988A; JUMP; // sstep
case 0x988A:
                                                     mon("         BLS   L9890                   ; 988A: 23 04         \n"); // Fireball timer 3
    // temp fix to ensure flags synched
    if ((!Z) || C) {
    PC = 0x9890; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x988C; JUMP; // sstep
case 0x988C:
                                                     mon("         LDB   #$08                    ; 988C: C6 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x08; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    // End of function sub_9886
    PC = 0x988E; JUMP; // sstep
case 0x988E:
                                                     mon("         STB   <$62                    ; 988E: D7 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x62; 
    wr_mem(ea, val); 
    // =============== S U B R O U T I N E =======================================
    // Fireball timer 3
    PC = 0x9890; JUMP; // sstep
case 0x9890:
                                                     mon("L9890    LDB   <$62                    ; 9890: D6 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x62); 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0x9892; JUMP; // sstep
case 0x9892:
                                                     mon("         BEQ   locret_9897             ; 9892: 27 03         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x9897; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x9894; JUMP; // sstep
case 0x9894:
                                                     mon("         DECB                          ; 9894: 5A            \n");
    val = (UINT8)B; 
    res = (UINT8)(val - 1); 
/**/N = res; 
/**/Z = res; 
/**/V = val & ~res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0x9895; JUMP; // sstep
case 0x9895:
                                                     mon("         STB   <$62                    ; 9895: D7 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x62; 
    wr_mem(ea, val); 
    // End of function sub_9890
    PC = 0x9897; JUMP; // sstep
case 0x9897:
                                                     mon("locret_9897 RTS                           ; 9897: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0x9898:
                                                     mon("L9898    LDA   <$43                    ; 9898: 96 43         \n"); // Game over/insert coins timer
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x43); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x989A; JUMP; // sstep
case 0x989A:
                                                     mon("         ANDA  #$00                    ; 989A: 84 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x00; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x989C; JUMP; // sstep
case 0x989C:
                                                     mon("         BNE   locret_98AF             ; 989C: 26 11         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0x98af; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x989E; JUMP; // sstep
case 0x989E:
                                                     mon("         LDX   #$4900                  ; 989E: 8E 49 00      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 3; 
    X = 0x4900; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0x98A1; JUMP; // sstep
case 0x98A1:
                                                     mon("L98A1    DEC   $06,X                   ; 98A1: 6A 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    res = (UINT8)(val - 1); 
    N = res; 
    Z = res; 
    V = val & ~res; 
    wr_mem((UINT16)(X + 0x0006), res); 
    clockticks = clockticks + 2; 
    PC = 0x98A3; JUMP; // sstep
case 0x98A3:
                                                     mon("         BPL   L98A7                   ; 98A3: 2A 02         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0x98a7; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x98A5; JUMP; // sstep
case 0x98A5:
                                                     mon("         CLR   $06,X                   ; 98A5: 6F 06         \n");
    clockticks = clockticks + 5; 
    wr_mem((UINT16)(X + 0x0006), 0); 
/**/V = 0; 
/**/Z = 0; 
/**/N = 0; 
/**/C = 0; 
    clockticks = clockticks + 2; 
    PC = 0x98A7; JUMP; // sstep
case 0x98A7:
                                                     mon("L98A7    LEAX  $19,X                   ; 98A7: 30 88 19      \n");
    clockticks = clockticks + 5; 
    X = (X + (SINT8)0x19); 
/**/Z = X; 
    PC = 0x98AA; JUMP; // sstep
case 0x98AA:
                                                     mon("         CMPX  #$494B                  ; 98AA: 8C 49 4B      \n"); // 3x Tie fighter data structure ($19 bytes per Tie)
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x494b; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0x98AD; JUMP; // sstep
case 0x98AD:
                                                     mon("         BCS   L98A1                   ; 98AD: 25 F2         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0x98a1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    // End of function sub_9898
    PC = 0x98AF; JUMP; // sstep
case 0x98AF:
                                                     mon("locret_98AF RTS                           ; 98AF: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Insert vector laser explosion small circle
  case 0x98B0:
                                                     mon("L98B0    LDB   <$62                    ; 98B0: D6 62         \n"); // Timer for fireball hit?
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x62); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0x98B2; JUMP; // sstep
case 0x98B2:
                                                     mon("         ANDB  #$03                    ; 98B2: C4 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    res = val & (SINT8)0x03; 
    B = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0x98B4; JUMP; // sstep
case 0x98B4:
                                                     mon("         BEQ   locret_98CA             ; 98B4: 27 14         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0x98ca; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0x98B6; JUMP; // sstep
case 0x98B6:
                                                     mon("         LDD   #$7100                  ; 98B6: CC 71 00      \n");
    clockticks = clockticks + 3; 
    A = 0x71; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x98B9; JUMP; // sstep
case 0x98B9:
                                                     mon("         STD   ,Y++                    ; 98B9: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x98BB; JUMP; // sstep
case 0x98BB:
                                                     mon("         LDD   #$67FF                  ; 98BB: CC 67 FF      \n");
    clockticks = clockticks + 3; 
    A = 0x67; 
    B = 0xff; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x98BE; JUMP; // sstep
case 0x98BE:
                                                     mon("         STD   ,Y++                    ; 98BE: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x98C0; JUMP; // sstep
case 0x98C0:
                                                     mon("         LDD   #$B9B3                  ; 98C0: CC B9 B3      \n"); // Vector JSRL 19B3 Laser explosion small circle
    clockticks = clockticks + 3; 
    A = 0xb9; 
    B = 0xb3; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x98C3; JUMP; // sstep
case 0x98C3:
                                                     mon("         STD   ,Y++                    ; 98C3: ED A1         \n");
    clockticks = clockticks + 7; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    PC = 0x98C5; JUMP; // sstep
case 0x98C5:
                                                     mon("         LDD   #$7200                  ; 98C5: CC 72 00      \n");
    clockticks = clockticks + 3; 
    A = 0x72; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0x98C8; JUMP; // sstep
case 0x98C8:
                                                     mon("         STD   ,Y++                    ; 98C8: ED A1         \n");
    clockticks = clockticks + 7; 
    Z = A | B; 
    N = A; 
    V = 0; 
    ea = Y; 
    wr_mem(ea, A); // Care needed with I/O space and word fetches
    wr_mem(ea + 1, B); 
    Y = Y + 2; 
    // End of function sub_98B0
    // ---------------------------------------------------------------------------
    PC = 0x98CA; JUMP; // sstep
case 0x98CA:
                                                     mon("locret_98CA RTS                           ; 98CA: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0xA1CE:
                                                     mon("LA1CE    LDU   #$49C2                  ; A1CE: CE 49 C2      \n"); // Tie fighter data 1
    clockticks = clockticks + 3; 
    U = 0x49c2; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0xA1D1; JUMP; // sstep
case 0xA1D1:
                                                     mon("LA1D1    LDA   #$00                    ; A1D1: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA1D3; JUMP; // sstep
case 0xA1D3:
                                                     mon("         STA   ,U                      ; A1D3: A7 C4         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = U; 
    wr_mem(ea, val); 
    PC = 0xA1D5; JUMP; // sstep
case 0xA1D5:
                                                     mon("         LEAU  $01,U                   ; A1D5: 33 41         \n");
    clockticks = clockticks + 5; 
    U = (U + 0x0001); 
    PC = 0xA1D7; JUMP; // sstep
case 0xA1D7:
                                                     mon("         CMPU  #$49E2                  ; A1D7: 11 83 49 E2   \n"); // Tie fighter data 1
    clockticks = clockticks + 5; 
    val = U; 
    arg = 0x49e2; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA1DB; JUMP; // sstep
case 0xA1DB:
                                                     mon("         BCS   LA1D1                   ; A1DB: 25 F4         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0xa1d1; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA1DD; JUMP; // sstep
case 0xA1DD:
                                                     mon("         LDA   $4B13                   ; A1DD: B6 4B 13      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b13); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA1E0; JUMP; // sstep
case 0xA1E0:
                                                     mon("         CMPA  #$13                    ; A1E0: 81 13         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x13; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA1E2; JUMP; // sstep
case 0xA1E2:
                                                     mon("         BCS   LA1EF                   ; A1E2: 25 0B         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0xa1ef; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA1E4; JUMP; // sstep
case 0xA1E4:
                                                     mon("         LDB   #$06                    ; A1E4: C6 06         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x06; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA1E6; JUMP; // sstep
case 0xA1E6:
                                                     mon("         LDA   $4703                   ; A1E6: B6 47 03      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4703); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA1E9; JUMP; // sstep
case 0xA1E9:
                                                     mon("         MUL                           ; A1E9: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0xA1EA; JUMP; // sstep
case 0xA1EA:
                                                     mon("         ADDA  #$0D                    ; A1EA: 8B 0D         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x0d; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0xA1EC; JUMP; // sstep
case 0xA1EC:
                                                     mon("         STA   $4B13                   ; A1EC: B7 4B 13      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b13, val); 
    PC = 0xA1EF; JUMP; // sstep
case 0xA1EF:
                                                     mon("LA1EF    LDB   $4B13                   ; A1EF: F6 4B 13      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b13); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA1F2; JUMP; // sstep
case 0xA1F2:
                                                     mon("         LDX   #byte_98CB              ; A1F2: 8E 98 CB      \n");
    clockticks = clockticks + 3; 
    X = 0x98cb; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA1F5; JUMP; // sstep
case 0xA1F5:
                                                     mon("         ABX                           ; A1F5: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0xA1F6; JUMP; // sstep
case 0xA1F6:
                                                     mon("         CMPX  #byte_98DE              ; A1F6: 8C 98 DE      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0x98de; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA1F9; JUMP; // sstep
case 0xA1F9:
                                                     mon("         BCS   LA1FE                   ; A1F9: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0xa1fe; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA1FB; JUMP; // sstep
case 0xA1FB:
                                                     mon("         LDX   #byte_98DD              ; A1FB: 8E 98 DD      \n");
    clockticks = clockticks + 3; 
    X = 0x98dd; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA1FE; JUMP; // sstep
case 0xA1FE:
                                                     mon("LA1FE    LDA   ,X                      ; A1FE: A6 84         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(X); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA200; JUMP; // sstep
case 0xA200:
                                                     mon("         STA   $4B1A                   ; A200: B7 4B 1A      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b1a, val); 
    PC = 0xA203; JUMP; // sstep
case 0xA203:
                                                     mon("         LDD   word_9856               ; A203: FC 98 56      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x9856); // Care needed with I/O space and word fetches
    B = rd_mem(0x9857); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA206; JUMP; // sstep
case 0xA206:
                                                     mon("         STD   $4B2E                   ; A206: FD 4B 2E      \n"); // Temporary score adder towers 1
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4b2e, A); // Care needed with I/O space and word fetches
    wr_mem(0x4b2f, B); 
    PC = 0xA209; JUMP; // sstep
case 0xA209:
                                                     mon("         LDA   byte_9858               ; A209: B6 98 58      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x9858); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA20C; JUMP; // sstep
case 0xA20C:
                                                     mon("         STA   $4B30                   ; A20C: B7 4B 30      \n"); // Temporary score adder towers 3
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b30, val); 
    PC = 0xA20F; JUMP; // sstep
case 0xA20F:
                                                     mon("         LDA   #$00                    ; A20F: 86 00         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x00; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA211; JUMP; // sstep
case 0xA211:
                                                     mon("         STA   <$A7                    ; A211: 97 A7         \n");
    clockticks = clockticks + 4; 
    val = A; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0xa7; 
    wr_mem(ea, val); 
    // End of function sub_A1CE
    PC = 0xA213; JUMP; // sstep
case 0xA213:
                                                     mon("         RTS                           ; A213: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0xA214:
                                                     mon("LA214    LDB   #$07                    ; A214: C6 07         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x07; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA216; JUMP; // sstep
case 0xA216:
                                                     mon("         STB   <$DC                    ; A216: D7 DC         \n");
    clockticks = clockticks + 4; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0xdc; 
    wr_mem(ea, val); 
    PC = 0xA218; JUMP; // sstep
case 0xA218:
                                                     mon("         JSR   LCD38                   ; A218: BD CD 38      \n"); // Trench left side turret calcs
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x1b); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa2); 
    clockticks = clockticks + 1; 
    PC = 0xcd38; 
    JUMP;
  case 0xA21B:
                                                     mon("LA21B    LDD   #$00                    ; A21B: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA21E; JUMP; // sstep
case 0xA21E:
                                                     mon("         STD   $5040                   ; A21E: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    PC = 0xA221; JUMP; // sstep
case 0xA221:
                                                     mon("         STD   $5042                   ; A221: FD 50 42      \n"); // YT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5042, A); // Care needed with I/O space and word fetches
    wr_mem(0x5043, B); 
    PC = 0xA224; JUMP; // sstep
case 0xA224:
                                                     mon("         STD   $5044                   ; A224: FD 50 44      \n"); // ZT2
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x5044, A); // Care needed with I/O space and word fetches
    wr_mem(0x5045, B); 
    PC = 0xA227; JUMP; // sstep
case 0xA227:
                                                     mon("         JSR   LA40A                   ; A227: BD A4 0A      \n"); // Some Towers code
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x2a); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa2); 
    clockticks = clockticks + 1; 
    PC = 0xa40a; 
    JUMP;
  case 0xA22A:
                                                     mon("LA22A    LDD   $5098                   ; A22A: FC 50 98      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5098); // Care needed with I/O space and word fetches
    B = rd_mem(0x5099); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA22D; JUMP; // sstep
case 0xA22D:
                                                     mon("         STD   $5040                   ; A22D: FD 50 40      \n"); // XT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5040, A); // Care needed with I/O space and word fetches
    wr_mem(0x5041, B); 
    PC = 0xA230; JUMP; // sstep
case 0xA230:
                                                     mon("         LDD   $509A                   ; A230: FC 50 9A      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x509a); // Care needed with I/O space and word fetches
    B = rd_mem(0x509b); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA233; JUMP; // sstep
case 0xA233:
                                                     mon("         STD   $5042                   ; A233: FD 50 42      \n"); // YT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5042, A); // Care needed with I/O space and word fetches
    wr_mem(0x5043, B); 
    PC = 0xA236; JUMP; // sstep
case 0xA236:
                                                     mon("         LDD   $509C                   ; A236: FC 50 9C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x509c); // Care needed with I/O space and word fetches
    B = rd_mem(0x509d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA239; JUMP; // sstep
case 0xA239:
                                                     mon("         STD   $5044                   ; A239: FD 50 44      \n"); // ZT2
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5044, A); // Care needed with I/O space and word fetches
    wr_mem(0x5045, B); 
    PC = 0xA23C; JUMP; // sstep
case 0xA23C:
                                                     mon("         LDB   $4B13                   ; A23C: F6 4B 13      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b13); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA23F; JUMP; // sstep
case 0xA23F:
                                                     mon("         ASLB                          ; A23F: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA240; JUMP; // sstep
case 0xA240:
                                                     mon("         ASLB                          ; A240: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA241; JUMP; // sstep
case 0xA241:
                                                     mon("         LDX   #off_A182               ; A241: 8E A1 82      \n");
    clockticks = clockticks + 3; 
    X = 0xa182; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA244; JUMP; // sstep
case 0xA244:
                                                     mon("         ABX                           ; A244: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0xA245; JUMP; // sstep
case 0xA245:
                                                     mon("         CMPX  #LA1CE                  ; A245: 8C A1 CE      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0xa1ce; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA248; JUMP; // sstep
case 0xA248:
                                                     mon("         BCS   LA24D                   ; A248: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0xa24d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA24A; JUMP; // sstep
case 0xA24A:
                                                     mon("         LDX   #off_A1CA               ; A24A: 8E A1 CA      \n");
    clockticks = clockticks + 3; 
    X = 0xa1ca; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA24D; JUMP; // sstep
case 0xA24D:
                                                     mon("LA24D    LDX   ,X                      ; A24D: AE 84         \n");
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(X)<<8; 
    ea = ea | rd_mem((UINT16)((X)+1)); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA24F; JUMP; // sstep
case 0xA24F:
                                                     mon("LA24F    STX   <$64                    ; A24F: 9F 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    val = X; 
/**/Z = val; 
/**/N = (UINT8)(val >> 8); 
/**/V = 0; 
    ea = DP|0x64; 
    wr_mem(ea, (UINT8)(val >> 8)); // Care needed with I/O space and word fetches
    wr_mem((UINT16)(ea + 1), (UINT8)val); 
    PC = 0xA251; JUMP; // sstep
case 0xA251:
                                                     mon("         LDA   <$A7                    ; A251: 96 A7         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xa7); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA253; JUMP; // sstep
case 0xA253:
                                                     mon("         CMPA  $05,X                   ; A253: A1 05         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)A; 
    arg = rd_mem((UINT16)(X + 0x0005)); 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA255; JUMP; // sstep
case 0xA255:
                                                     mon("         LBLT  LA2DA                   ; A255: 10 2D 00 81   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)(N^V) <  0) {
    clockticks = clockticks + 1; 
    PC = 0xa2da; 
    JUMP;
    }
    PC = 0xA259; JUMP; // sstep
case 0xA259:
                                                     mon("         LDD   ,X                      ; A259: EC 84         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(X); // Care needed with I/O space and word fetches. Use 'ea' here?
    B = rd_mem((UINT16)(X+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA25B; JUMP; // sstep
case 0xA25B:
                                                     mon("         STD   $5E00                   ; A25B: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0xA25E; JUMP; // sstep
case 0xA25E:
                                                     mon("         LDD   $02,X                   ; A25E: EC 02         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA260; JUMP; // sstep
case 0xA260:
                                                     mon("         STD   $5E02                   ; A260: FD 5E 02      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e02, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e03, B); 
    PC = 0xA263; JUMP; // sstep
case 0xA263:
                                                     mon("         LDD   #$1E00                  ; A263: CC 1E 00      \n");
    clockticks = clockticks + 3; 
    A = 0x1e; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA266; JUMP; // sstep
case 0xA266:
                                                     mon("         STD   $5E04                   ; A266: FD 5E 04      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e04, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e05, B); 
    PC = 0xA269; JUMP; // sstep
case 0xA269:
                                                     mon("         LDD   #$01C0                  ; A269: CC 01 C0      \n");
    clockticks = clockticks + 3; 
    A = 0x01; 
    B = 0xc0; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA26C; JUMP; // sstep
case 0xA26C:
                                                     mon("         STD   $4701                   ; A26C: FD 47 01      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0xA26F; JUMP; // sstep
case 0xA26F:
                                                     mon("         LDA   #$67                    ; A26F: 86 67         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x67; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA271; JUMP; // sstep
case 0xA271:
                                                     mon("         JSR   LCDBA                   ; A271: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x74); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa2); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0xA274:
                                                     mon("LA274    LDD   $5000                   ; A274: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0xA277; JUMP; // sstep
case 0xA277:
                                                     mon("         BPL   LA27E                   ; A277: 2A 05         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0xa27e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA279; JUMP; // sstep
case 0xA279:
                                                     mon("         ANDA  #$3F                    ; A279: 84 3F         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0x3f; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0xA27B; JUMP; // sstep
case 0xA27B:
                                                     mon("         STD   $5000                   ; A27B: FD 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5000, A); // Care needed with I/O space and word fetches
    wr_mem(0x5001, B); 
    PC = 0xA27E; JUMP; // sstep
case 0xA27E:
                                                     mon("LA27E    STD   $507C                   ; A27E: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0xA281; JUMP; // sstep
case 0xA281:
                                                     mon("         CMPD  #$0100                  ; A281: 10 83 01 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x0100; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA285; JUMP; // sstep
case 0xA285:
                                                     mon("         BLT   LA2B0                   ; A285: 2D 29         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0xa2b0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA287; JUMP; // sstep
case 0xA287:
                                                     mon("         CMPD  #$3C00                  ; A287: 10 83 3C 00   \n");
    clockticks = clockticks + 5; 
    val = (((UINT8)A<<8)|(UINT8)B); 
    arg = 0x3c00; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA28B; JUMP; // sstep
case 0xA28B:
                                                     mon("         BCC   LA2B0                   ; A28B: 24 23         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0xa2b0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA28D; JUMP; // sstep
case 0xA28D:
                                                     mon("         LDD   $5002                   ; A28D: FC 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    A = rd_mem(0x5002); // Care needed with I/O space and word fetches
    B = rd_mem(0x5003); 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0xA290; JUMP; // sstep
case 0xA290:
                                                     mon("         BPL   LA296                   ; A290: 2A 04         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0xa296; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA292; JUMP; // sstep
case 0xA292:
                                                     mon("         COMA                          ; A292: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0xA293; JUMP; // sstep
case 0xA293:
                                                     mon("         NEGB                          ; A293: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0xA294; JUMP; // sstep
case 0xA294:
                                                     mon("         SBCA  #$FF                    ; A294: 82 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0xff; 
    res = (val - (UINT8)arg) - (C != 0 ? 1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)res; 
    PC = 0xA296; JUMP; // sstep
case 0xA296:
                                                     mon("LA296    SUBD  $5000                   ; A296: B3 50 00      \n"); // Math result X
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5000)<<8; 
    ea = ea | rd_mem(0x5001); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA299; JUMP; // sstep
case 0xA299:
                                                     mon("         BCC   LA2B0                   ; A299: 24 15         \n");
    // temp fix to ensure flags synched
    if (!C) {
    PC = 0xa2b0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA29B; JUMP; // sstep
case 0xA29B:
                                                     mon("         LDU   #$49C2                  ; A29B: CE 49 C2      \n"); // Tie fighter data 1
    clockticks = clockticks + 3; 
    U = 0x49c2; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0xA29E; JUMP; // sstep
case 0xA29E:
                                                     mon("         LDB   $06,X                   ; A29E: E6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2A0; JUMP; // sstep
case 0xA2A0:
                                                     mon("         LEAU  B,U                     ; A2A0: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0xA2A2; JUMP; // sstep
case 0xA2A2:
                                                     mon("         LDA   ,U                      ; A2A2: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2A4; JUMP; // sstep
case 0xA2A4:
                                                     mon("         BITA  #$02                    ; A2A4: 85 02         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x02; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA2A6; JUMP; // sstep
case 0xA2A6:
                                                     mon("         BEQ   LA2AE                   ; A2A6: 27 06         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa2ae; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA2A8; JUMP; // sstep
case 0xA2A8:
                                                     mon("         JSR   LA2F8                   ; A2A8: BD A2 F8      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xab); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa2); 
    clockticks = clockticks + 1; 
    PC = 0xa2f8; 
    JUMP;
  case 0xA2AB:
                                                     mon("LA2AB    JSR   LA591                   ; A2AB: BD A5 91      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xae); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa2); 
    clockticks = clockticks + 1; 
    PC = 0xa591; 
    JUMP;
  case 0xA2AE:
                                                     mon("LA2AE    BRA   LA2DA                   ; A2AE: 20 2A         \n");
    PC = 0xa2da; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA2B0:
                                                     mon("LA2B0    LDX   <$64                    ; A2B0: 9E 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x64)<<8; 
    ea = ea | rd_mem(DP|0x65); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA2B2; JUMP; // sstep
case 0xA2B2:
                                                     mon("         LDU   #$49C2                  ; A2B2: CE 49 C2      \n"); // Tie fighter data 1
    clockticks = clockticks + 3; 
    U = 0x49c2; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0xA2B5; JUMP; // sstep
case 0xA2B5:
                                                     mon("         LDB   $06,X                   ; A2B5: E6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2B7; JUMP; // sstep
case 0xA2B7:
                                                     mon("         LEAU  B,U                     ; A2B7: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0xA2B9; JUMP; // sstep
case 0xA2B9:
                                                     mon("         LDA   $4B3D                   ; A2B9: B6 4B 3D      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b3d); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA2BC; JUMP; // sstep
case 0xA2BC:
                                                     mon("         BEQ   LA2C2                   ; A2BC: 27 04         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa2c2; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA2BE; JUMP; // sstep
case 0xA2BE:
                                                     mon("         CLR   ,U                      ; A2BE: 6F C4         \n");
    clockticks = clockticks + 4; 
    wr_mem(U, 0); 
    V = 0; 
    Z = 0; 
    N = 0; 
    C = 0; 
    clockticks = clockticks + 2; 
    PC = 0xA2C0; JUMP; // sstep
case 0xA2C0:
                                                     mon("         BRA   LA2DA                   ; A2C0: 20 18         \n");
    PC = 0xa2da; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA2C2:
                                                     mon("LA2C2    LDA   #$0B                    ; A2C2: 86 0B         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x0b; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2C4; JUMP; // sstep
case 0xA2C4:
                                                     mon("         LDB   ,U                      ; A2C4: E6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2C6; JUMP; // sstep
case 0xA2C6:
                                                     mon("         BITB  #$04                    ; A2C6: C5 04         \n");
    clockticks = clockticks + 2; 
    res = B & (SINT8)0x04; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA2C8; JUMP; // sstep
case 0xA2C8:
                                                     mon("         BEQ   LA2D6                   ; A2C8: 27 0C         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa2d6; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA2CA; JUMP; // sstep
case 0xA2CA:
                                                     mon("         ORA   #$04                    ; A2CA: 8A 04         \n");
    clockticks = clockticks + 2; 
    res = A | (UINT8)0x04; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0xA2CC; JUMP; // sstep
case 0xA2CC:
                                                     mon("         LDB   $04,X                   ; A2CC: E6 04         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0004)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2CE; JUMP; // sstep
case 0xA2CE:
                                                     mon("         CMPB  #$03                    ; A2CE: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA2D0; JUMP; // sstep
case 0xA2D0:
                                                     mon("         BNE   LA2D4                   ; A2D0: 26 02         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa2d4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA2D2; JUMP; // sstep
case 0xA2D2:
                                                     mon("         ANDA  #$FD                    ; A2D2: 84 FD         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    res = val & (SINT8)0xfd; 
    A = res; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA2D4; JUMP; // sstep
case 0xA2D4:
                                                     mon("LA2D4    BRA   LA2D8                   ; A2D4: 20 02         \n");
    PC = 0xa2d8; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA2D6:
                                                     mon("LA2D6    ORA   #$10                    ; A2D6: 8A 10         \n");
    clockticks = clockticks + 2; 
    res = A | (UINT8)0x10; 
    A = res; 
/**/Z = res; 
/**/N = res; 
/**/V = 0; 
    PC = 0xA2D8; JUMP; // sstep
case 0xA2D8:
                                                     mon("LA2D8    STA   ,U                      ; A2D8: A7 C4         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = U; 
    wr_mem(ea, val); 
    PC = 0xA2DA; JUMP; // sstep
case 0xA2DA:
                                                     mon("LA2DA    LDB   $4B13                   ; A2DA: F6 4B 13      \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x4b13); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2DD; JUMP; // sstep
case 0xA2DD:
                                                     mon("         ASLB                          ; A2DD: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA2DE; JUMP; // sstep
case 0xA2DE:
                                                     mon("         ASLB                          ; A2DE: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA2DF; JUMP; // sstep
case 0xA2DF:
                                                     mon("         LDX   #off_A182               ; A2DF: 8E A1 82      \n");
    clockticks = clockticks + 3; 
    X = 0xa182; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA2E2; JUMP; // sstep
case 0xA2E2:
                                                     mon("         ABX                           ; A2E2: 3A            \n");
    X = X + B; 
    clockticks = clockticks + 3; 
    PC = 0xA2E3; JUMP; // sstep
case 0xA2E3:
                                                     mon("         CMPX  #LA1CE                  ; A2E3: 8C A1 CE      \n");
    clockticks = clockticks + 4; 
    val = X; 
    arg = 0xa1ce; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA2E6; JUMP; // sstep
case 0xA2E6:
                                                     mon("         BCS   LA2EB                   ; A2E6: 25 03         \n");
    // temp fix to ensure flags synched
    if (C) {
    PC = 0xa2eb; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA2E8; JUMP; // sstep
case 0xA2E8:
                                                     mon("         LDX   #off_A1CA               ; A2E8: 8E A1 CA      \n");
    clockticks = clockticks + 3; 
    X = 0xa1ca; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA2EB; JUMP; // sstep
case 0xA2EB:
                                                     mon("LA2EB    TFR   X,U                     ; A2EB: 1F 13         \n");
    U = X; 
    clockticks = clockticks + 6; 
    PC = 0xA2ED; JUMP; // sstep
case 0xA2ED:
                                                     mon("         LDX   <$64                    ; A2ED: 9E 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x64)<<8; 
    ea = ea | rd_mem(DP|0x65); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA2EF; JUMP; // sstep
case 0xA2EF:
                                                     mon("         LEAX  $07,X                   ; A2EF: 30 07         \n");
    clockticks = clockticks + 5; 
    X = (X + 0x0007); 
/**/Z = X; 
    PC = 0xA2F1; JUMP; // sstep
case 0xA2F1:
                                                     mon("         CPX   $02,U                   ; A2F1: AC 42         \n");
    clockticks = clockticks + 1; 
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    ea = rd_mem((UINT16)(U + 0x0002))<<8; 
    ea = ea | rd_mem((UINT16)(((UINT16)(U + 0x0002))+1)); 
    val = X; 
    arg = ea; 
    res = val - arg; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    N = res >> 8; 
    V = ((val ^ arg) & (val ^ res)) >> 8; 
    PC = 0xA2F3; JUMP; // sstep
case 0xA2F3:
                                                     mon("         LBCS  LA24F                   ; A2F3: 10 25 FF 58   \n");
    clockticks = clockticks + 5; 
    if (C) {
    clockticks = clockticks + 1; 
    PC = 0xa24f; 
    JUMP;
    }
    // End of function sub_A214
    PC = 0xA2F7; JUMP; // sstep
case 0xA2F7:
                                                     mon("         RTS                           ; A2F7: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
  case 0xA2F8:
                                                     mon("LA2F8    LDX   <$64                    ; A2F8: 9E 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x64)<<8; 
    ea = ea | rd_mem(DP|0x65); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA2FA; JUMP; // sstep
case 0xA2FA:
                                                     mon("         LDB   $04,X                   ; A2FA: E6 04         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0004)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA2FC; JUMP; // sstep
case 0xA2FC:
                                                     mon("         CMPB  #$03                    ; A2FC: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA2FE; JUMP; // sstep
case 0xA2FE:
                                                     mon("         BNE   LA304                   ; A2FE: 26 04         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa304; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA300; JUMP; // sstep
case 0xA300:
                                                     mon("         LDB   #$09                    ; A300: C6 09         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x09; 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA302; JUMP; // sstep
case 0xA302:
                                                     mon("         BRA   LA306                   ; A302: 20 02         \n");
    PC = 0xa306; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA304:
                                                     mon("LA304    LDB   #$08                    ; A304: C6 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x08; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA306; JUMP; // sstep
case 0xA306:
                                                     mon("LA306    STB   <$DC                    ; A306: D7 DC         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0xdc; 
    wr_mem(ea, val); 
    PC = 0xA308; JUMP; // sstep
case 0xA308:
                                                     mon("         LDD   #$6680                  ; A308: CC 66 80      \n");
    clockticks = clockticks + 3; 
    A = 0x66; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA30B; JUMP; // sstep
case 0xA30B:
                                                     mon("         STD   $5E02                   ; A30B: FD 5E 02      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e02, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e03, B); 
    PC = 0xA30E; JUMP; // sstep
case 0xA30E:
                                                     mon("         LDU   #$49C2                  ; A30E: CE 49 C2      \n"); // Tie fighter data 1
    clockticks = clockticks + 3; 
    U = 0x49c2; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0xA311; JUMP; // sstep
case 0xA311:
                                                     mon("         LDB   $06,X                   ; A311: E6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA313; JUMP; // sstep
case 0xA313:
                                                     mon("         LEAU  B,U                     ; A313: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0xA315; JUMP; // sstep
case 0xA315:
                                                     mon("         LDA   ,U                      ; A315: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA317; JUMP; // sstep
case 0xA317:
                                                     mon("         LDB   $04,X                   ; A317: E6 04         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0004)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA319; JUMP; // sstep
case 0xA319:
                                                     mon("         CMPB  #$03                    ; A319: C1 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA31B; JUMP; // sstep
case 0xA31B:
                                                     mon("         BEQ   LA333                   ; A31B: 27 16         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa333; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA31D; JUMP; // sstep
case 0xA31D:
                                                     mon("         BITA  #$04                    ; A31D: 85 04         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x04; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA31F; JUMP; // sstep
case 0xA31F:
                                                     mon("         BNE   LA325                   ; A31F: 26 04         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa325; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA321; JUMP; // sstep
case 0xA321:
                                                     mon("         BITA  #$10                    ; A321: 85 10         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x10; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA323; JUMP; // sstep
case 0xA323:
                                                     mon("         BNE   LA32E                   ; A323: 26 09         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa32e; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA325; JUMP; // sstep
case 0xA325:
                                                     mon("LA325    LDB   #$0A                    ; A325: C6 0A         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x0a; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA327; JUMP; // sstep
case 0xA327:
                                                     mon("         STB   <$DC                    ; A327: D7 DC         \n");
    clockticks = clockticks + 4; 
    val = B; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0xdc; 
    wr_mem(ea, val); 
    PC = 0xA329; JUMP; // sstep
case 0xA329:
                                                     mon("         LDD   #$6080                  ; A329: CC 60 80      \n");
    clockticks = clockticks + 3; 
    A = 0x60; 
    B = 0x80; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0xA32C; JUMP; // sstep
case 0xA32C:
                                                     mon("         BRA   LA331                   ; A32C: 20 03         \n");
    PC = 0xa331; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA32E:
                                                     mon("LA32E    LDD   #$6780                  ; A32E: CC 67 80      \n");
    clockticks = clockticks + 3; 
    A = 0x67; 
    B = 0x80; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0xA331; JUMP; // sstep
case 0xA331:
                                                     mon("LA331    BRA   LA33F                   ; A331: 20 0C         \n");
    PC = 0xa33f; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA333:
                                                     mon("LA333    BITA  #$04                    ; A333: 85 04         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x04; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA335; JUMP; // sstep
case 0xA335:
                                                     mon("         BNE   LA33C                   ; A335: 26 05         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa33c; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA337; JUMP; // sstep
case 0xA337:
                                                     mon("         LDD   #$6460                  ; A337: CC 64 60      \n");
    clockticks = clockticks + 3; 
    A = 0x64; 
    B = 0x60; 
    Z = A|B; 
    N = A; 
    V = 0; 
    PC = 0xA33A; JUMP; // sstep
case 0xA33A:
                                                     mon("         BRA   LA33F                   ; A33A: 20 03         \n");
    PC = 0xa33f; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA33C:
                                                     mon("LA33C    LDD   #$6080                  ; A33C: CC 60 80      \n");
    clockticks = clockticks + 3; 
    A = 0x60; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA33F; JUMP; // sstep
case 0xA33F:
                                                     mon("LA33F    STD   $5E00                   ; A33F: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0xA342; JUMP; // sstep
case 0xA342:
                                                     mon("         LDA   #$72                    ; A342: 86 72         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x72; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA344; JUMP; // sstep
case 0xA344:
                                                     mon("         STA   $5E04                   ; A344: B7 5E 04      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x5e04, val); 
    PC = 0xA347; JUMP; // sstep
case 0xA347:
                                                     mon("         LDA   $5000                   ; A347: B6 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5000); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA34A; JUMP; // sstep
case 0xA34A:
                                                     mon("         ASLA                          ; A34A: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0xA34B; JUMP; // sstep
case 0xA34B:
                                                     mon("         ASLA                          ; A34B: 48            \n");
    val = (UINT8)A; 
    res = val << 1; 
/**/C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    A = res; 
    clockticks = clockticks + 2; 
    PC = 0xA34C; JUMP; // sstep
case 0xA34C:
                                                     mon("         STA   $5E05                   ; A34C: B7 5E 05      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x5e05, val); 
    PC = 0xA34F; JUMP; // sstep
case 0xA34F:
                                                     mon("         LDB   #$40                    ; A34F: C6 40         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x40; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA351; JUMP; // sstep
case 0xA351:
                                                     mon("         COMA                          ; A351: 43            \n");
    val = (UINT8)A ^ 0xff; 
    A = val; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
/**/C = 1; 
    clockticks = clockticks + 2; 
    PC = 0xA352; JUMP; // sstep
case 0xA352:
                                                     mon("         MUL                           ; A352: 3D            \n");
    res = (UINT16)(A * B); 
/**/Z = res; 
/**/C = res & 0x80; 
    A = res >> 8; 
    B = (UINT8)res; 
    clockticks = clockticks + 11; 
    PC = 0xA353; JUMP; // sstep
case 0xA353:
                                                     mon("         ADDA  #$40                    ; A353: 8B 40         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x40; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0xA355; JUMP; // sstep
case 0xA355:
                                                     mon("         STA   $5E03                   ; A355: B7 5E 03      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x5e03, val); 
    PC = 0xA358; JUMP; // sstep
case 0xA358:
                                                     mon("         LDD   $5086                   ; A358: FC 50 86      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x5086); // Care needed with I/O space and word fetches
    B = rd_mem(0x5087); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA35B; JUMP; // sstep
case 0xA35B:
                                                     mon("         ASLB                          ; A35B: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA35C; JUMP; // sstep
case 0xA35C:
                                                     mon("         ROLA                          ; A35C: 49            \n");
    val = (UINT8)A; 
    res = (val << 1) + (C != 0 ?1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)res ^ val; 
    A = (UINT8)res; 
    clockticks = clockticks + 2; 
    PC = 0xA35D; JUMP; // sstep
case 0xA35D:
                                                     mon("         ADDD  #$0400                  ; A35D: C3 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg + val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ res) & (val ^ res)) >> 8; 
/**/N = res >> 8; 
    A = (UINT8)(res >> 8); 
    B = (UINT8)res; 
    PC = 0xA360; JUMP; // sstep
case 0xA360:
                                                     mon("         SUBD  $5000                   ; A360: B3 50 00      \n"); // Math result X
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5000)<<8; 
    ea = ea | rd_mem(0x5001); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA363; JUMP; // sstep
case 0xA363:
                                                     mon("         LBLT  LA3F4                   ; A363: 10 2D 00 8D   \n");
    clockticks = clockticks + 5; 
    if ((SINT8)(N^V) <  0) {
    clockticks = clockticks + 1; 
    PC = 0xa3f4; 
    JUMP;
    }
    PC = 0xA367; JUMP; // sstep
case 0xA367:
                                                     mon("         LDA   $04,X                   ; A367: A6 04         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0004)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA369; JUMP; // sstep
case 0xA369:
                                                     mon("         CMPA  #$03                    ; A369: 81 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA36B; JUMP; // sstep
case 0xA36B:
                                                     mon("         BEQ   LA3A7                   ; A36B: 27 3A         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa3a7; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA36D; JUMP; // sstep
case 0xA36D:
                                                     mon("         LDA   <$60                    ; A36D: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA36F; JUMP; // sstep
case 0xA36F:
                                                     mon("         BLT   LA374                   ; A36F: 2D 03         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0xa374; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA371; JUMP; // sstep
case 0xA371:
                                                     mon("         JSR   Sound_2C                ; A371: BD BD D0      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x74); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0xbdd0; 
    JUMP;
  case 0xA374:
                                                     mon("LA374    LDD   $5000                   ; A374: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA377; JUMP; // sstep
case 0xA377:
                                                     mon("         SUBD  #$0200                  ; A377: 83 02 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0200; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA37A; JUMP; // sstep
case 0xA37A:
                                                     mon("         SUBD  $5086                   ; A37A: B3 50 86      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5086)<<8; 
    ea = ea | rd_mem(0x5087); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA37D; JUMP; // sstep
case 0xA37D:
                                                     mon("         BGT   LA3A5                   ; A37D: 2E 26         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0xa3a5; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA37F; JUMP; // sstep
case 0xA37F:
                                                     mon("         LDD   #$A018                  ; A37F: CC A0 18      \n");
    clockticks = clockticks + 3; 
    A = 0xa0; 
    B = 0x18; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA382; JUMP; // sstep
case 0xA382:
                                                     mon("         STD   $5E02                   ; A382: FD 5E 02      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e02, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e03, B); 
    PC = 0xA385; JUMP; // sstep
case 0xA385:
                                                     mon("         LDD   #$6080                  ; A385: CC 60 80      \n");
    clockticks = clockticks + 3; 
    A = 0x60; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA388; JUMP; // sstep
case 0xA388:
                                                     mon("         STD   $5E00                   ; A388: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0xA38B; JUMP; // sstep
case 0xA38B:
                                                     mon("         LDA   <$60                    ; A38B: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA38D; JUMP; // sstep
case 0xA38D:
                                                     mon("         BLT   LA395                   ; A38D: 2D 06         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0xa395; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA38F; JUMP; // sstep
case 0xA38F:
                                                     mon("         JSR   L9874                   ; A38F: BD 98 74      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x92); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0x9874; 
    JUMP;
  case 0xA392:
                                                     mon("LA392    JSR   Sound_26                ; A392: BD BD B2      \n"); // Explosion
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x95); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0xbdb2; 
    JUMP;
  case 0xA395:
                                                     mon("LA395    LDA   <$63                    ; A395: 96 63         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x63); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA397; JUMP; // sstep
case 0xA397:
                                                     mon("         BNE   LA39D                   ; A397: 26 04         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa39d; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA399; JUMP; // sstep
case 0xA399:
                                                     mon("         LDA   $5002                   ; A399: B6 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5002); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA39C; JUMP; // sstep
case 0xA39C:
                                                     mon("         NEGA                          ; A39C: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0xA39D; JUMP; // sstep
case 0xA39D:
                                                     mon("LA39D    LDB   #$20                    ; A39D: C6 20         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x20; 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA39F; JUMP; // sstep
case 0xA39F:
                                                     mon("         TSTA                          ; A39F: 4D            \n");
    val = (UINT8)A; 
    Z = val; 
    N = val; 
    V = 0; 
    clockticks = clockticks + 2; 
    PC = 0xA3A0; JUMP; // sstep
case 0xA3A0:
                                                     mon("         BPL   LA3A3                   ; A3A0: 2A 01         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0xa3a3; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3A2; JUMP; // sstep
case 0xA3A2:
                                                     mon("         NEGB                          ; A3A2: 50            \n");
    val = (UINT8)B; 
    res = -val; 
/**/V = val & (UINT8)res; 
    C = res & 0x100; 
    val = (UINT8)res; 
    B = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0xA3A3; JUMP; // sstep
case 0xA3A3:
                                                     mon("LA3A3    STB   <$63                    ; A3A3: D7 63         \n");
    clockticks = clockticks + 4; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    ea = DP|0x63; 
    wr_mem(ea, val); 
    PC = 0xA3A5; JUMP; // sstep
case 0xA3A5:
                                                     mon("LA3A5    BRA   LA3F4                   ; A3A5: 20 4D         \n");
    PC = 0xa3f4; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA3A7:
                                                     mon("LA3A7    LDD   $5044                   ; A3A7: FC 50 44      \n"); // ZT2
    clockticks = clockticks + 5; 
    A = rd_mem(0x5044); // Care needed with I/O space and word fetches
    B = rd_mem(0x5045); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA3AA; JUMP; // sstep
case 0xA3AA:
                                                     mon("         SUBD  #$07A0                  ; A3AA: 83 07 A0      \n");
    clockticks = clockticks + 4; 
    val = 0x07a0; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA3AD; JUMP; // sstep
case 0xA3AD:
                                                     mon("         BGT   LA3F4                   ; A3AD: 2E 45         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0xa3f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3AF; JUMP; // sstep
case 0xA3AF:
                                                     mon("         JSR   Sound_2C                ; A3AF: BD BD D0      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xb2); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0xbdd0; 
    JUMP;
  case 0xA3B2:
                                                     mon("LA3B2    LDX   <$64                    ; A3B2: 9E 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x64)<<8; 
    ea = ea | rd_mem(DP|0x65); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA3B4; JUMP; // sstep
case 0xA3B4:
                                                     mon("         LDU   #$49C2                  ; A3B4: CE 49 C2      \n"); // Tie fighter data 1
    clockticks = clockticks + 3; 
    U = 0x49c2; 
/**/Z = U; 
/**/N = (U) >> 8; 
/**/V = 0; 
    PC = 0xA3B7; JUMP; // sstep
case 0xA3B7:
                                                     mon("         LDB   $06,X                   ; A3B7: E6 06         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0006)); 
    B = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA3B9; JUMP; // sstep
case 0xA3B9:
                                                     mon("         LEAU  B,U                     ; A3B9: 33 C5         \n");
    clockticks = clockticks + 5; 
    U = (U + (SINT8)B); 
    PC = 0xA3BB; JUMP; // sstep
case 0xA3BB:
                                                     mon("         LDA   ,U                      ; A3BB: A6 C4         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(U); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA3BD; JUMP; // sstep
case 0xA3BD:
                                                     mon("         BITA  #$04                    ; A3BD: 85 04         \n");
    clockticks = clockticks + 2; 
    res = A & (SINT8)0x04; 
    Z = res; 
    N = res; 
    V = 0; 
    PC = 0xA3BF; JUMP; // sstep
case 0xA3BF:
                                                     mon("         BNE   LA3F4                   ; A3BF: 26 33         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa3f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3C1; JUMP; // sstep
case 0xA3C1:
                                                     mon("         LDD   $5044                   ; A3C1: FC 50 44      \n"); // ZT2
    clockticks = clockticks + 5; 
    A = rd_mem(0x5044); // Care needed with I/O space and word fetches
    B = rd_mem(0x5045); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA3C4; JUMP; // sstep
case 0xA3C4:
                                                     mon("         SUBD  #$05A0                  ; A3C4: 83 05 A0      \n");
    clockticks = clockticks + 4; 
    val = 0x05a0; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA3C7; JUMP; // sstep
case 0xA3C7:
                                                     mon("         BGE   LA3F4                   ; A3C7: 2C 2B         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) >= 0) {
    PC = 0xa3f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3C9; JUMP; // sstep
case 0xA3C9:
                                                     mon("         LDD   $5000                   ; A3C9: FC 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    A = rd_mem(0x5000); // Care needed with I/O space and word fetches
    B = rd_mem(0x5001); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA3CC; JUMP; // sstep
case 0xA3CC:
                                                     mon("         SUBD  #$0400                  ; A3CC: 83 04 00      \n");
    clockticks = clockticks + 4; 
    val = 0x0400; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA3CF; JUMP; // sstep
case 0xA3CF:
                                                     mon("         SUBD  $5086                   ; A3CF: B3 50 86      \n");
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5086)<<8; 
    ea = ea | rd_mem(0x5087); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
    Z = res; 
    V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
    N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA3D2; JUMP; // sstep
case 0xA3D2:
                                                     mon("         BGT   LA3F4                   ; A3D2: 2E 20         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0xa3f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3D4; JUMP; // sstep
case 0xA3D4:
                                                     mon("         LDD   #$A018                  ; A3D4: CC A0 18      \n");
    clockticks = clockticks + 3; 
    A = 0xa0; 
    B = 0x18; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA3D7; JUMP; // sstep
case 0xA3D7:
                                                     mon("         STD   $5E00                   ; A3D7: FD 5E 00      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5e00, A); // Care needed with I/O space and word fetches
    wr_mem(0x5e01, B); 
    PC = 0xA3DA; JUMP; // sstep
case 0xA3DA:
                                                     mon("         LDA   <$60                    ; A3DA: 96 60         \n"); // Shield count
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x60); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA3DC; JUMP; // sstep
case 0xA3DC:
                                                     mon("         BLT   LA3E4                   ; A3DC: 2D 06         \n");
    // temp fix to ensure flags synched
    if ((SINT8)(N^V) <  0) {
    PC = 0xa3e4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3DE; JUMP; // sstep
case 0xA3DE:
                                                     mon("         JSR   L9874                   ; A3DE: BD 98 74      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe1); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0x9874; 
    JUMP;
  case 0xA3E1:
                                                     mon("LA3E1    JSR   Sound_26                ; A3E1: BD BD B2      \n"); // Explosion
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xe4); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0xbdb2; 
    JUMP;
  case 0xA3E4:
                                                     mon("LA3E4    LDA   <$63                    ; A3E4: 96 63         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0x63); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA3E6; JUMP; // sstep
case 0xA3E6:
                                                     mon("         BNE   LA3F4                   ; A3E6: 26 0C         \n");
    // temp fix to ensure flags synched
    if (Z) {
    PC = 0xa3f4; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3E8; JUMP; // sstep
case 0xA3E8:
                                                     mon("         LDA   #$13                    ; A3E8: 86 13         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x13; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA3EA; JUMP; // sstep
case 0xA3EA:
                                                     mon("         LDB   $5002                   ; A3EA: F6 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5002); 
    B = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA3ED; JUMP; // sstep
case 0xA3ED:
                                                     mon("         BMI   LA3F0                   ; A3ED: 2B 01         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N <  0) {
    PC = 0xa3f0; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3EF; JUMP; // sstep
case 0xA3EF:
                                                     mon("         NEGA                          ; A3EF: 40            \n");
    val = (UINT8)A; 
    res = -val; 
/**/V = val & (UINT8)res; 
/**/C = res & 0x100; 
    val = (UINT8)res; 
    A = val; 
/**/Z = val; 
/**/N = val; 
    clockticks = clockticks + 2; 
    PC = 0xA3F0; JUMP; // sstep
case 0xA3F0:
                                                     mon("LA3F0    ADDA  <$63                    ; A3F0: 9B 63         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)A; 
    arg = rd_mem(DP|0x63); 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    A = (UINT8)res; 
    PC = 0xA3F2; JUMP; // sstep
case 0xA3F2:
                                                     mon("         STA   <$63                    ; A3F2: 97 63         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0x63; 
    wr_mem(ea, val); 
    PC = 0xA3F4; JUMP; // sstep
case 0xA3F4:
                                                     mon("LA3F4    LDA   $5000                   ; A3F4: B6 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem(0x5000); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA3F7; JUMP; // sstep
case 0xA3F7:
                                                     mon("         SUBA  #$08                    ; A3F7: 80 08         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x08; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    A = (UINT8)(res); 
    PC = 0xA3F9; JUMP; // sstep
case 0xA3F9:
                                                     mon("         BGT   LA400                   ; A3F9: 2E 05         \n");
    // temp fix to ensure flags synched
    if (((SINT8)(N^V) >= 0) && Z) {
    PC = 0xa400; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA3FB; JUMP; // sstep
case 0xA3FB:
                                                     mon("         JSR   LCD68                   ; A3FB: BD CD 68      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0xfe); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa3); 
    clockticks = clockticks + 1; 
    PC = 0xcd68; 
    JUMP;
  case 0xA3FE:
                                                     mon("LA3FE    BRA   LA403                   ; A3FE: 20 03         \n");
    PC = 0xa403; 
    JUMP;
    clockticks = clockticks + 3; 
    
    // ---------------------------------------------------------------------------
  case 0xA400:
                                                     mon("LA400    JSR   LCD50                   ; A400: BD CD 50      \n");
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x03); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcd50; 
    JUMP;
  case 0xA403:
                                                     mon("LA403    JSR   LCD74                   ; A403: BD CD 74      \n"); // Function select for an object
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x06); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcd74; 
    JUMP;
  case 0xA406:
                                                     mon("LA406    JSR   LA459                   ; A406: BD A4 59      \n"); // Some Towers code
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x09); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xa459; 
    JUMP;
    // End of function sub_A2F8
  case 0xA409:
                                                     mon("LA409    RTS                           ; A409: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Some Towers code
  case 0xA40A:
                                                     mon("LA40A    JSR   LCDE7                   ; A40A: BD CD E7      \n"); // Swap Matrix 2  x, y, z to  x, y, z
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x0d); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcde7; 
    JUMP;
  case 0xA40D:
                                                     mon("LA40D    LDD   #$00                    ; A40D: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA410; JUMP; // sstep
case 0xA410:
                                                     mon("         STD   $5078                   ; A410: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0xA413; JUMP; // sstep
case 0xA413:
                                                     mon("         LDD   <$B3                    ; A413: DC B3         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0xb3); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0xb4); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA415; JUMP; // sstep
case 0xA415:
                                                     mon("         STD   $507A                   ; A415: FD 50 7A      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0xA418; JUMP; // sstep
case 0xA418:
                                                     mon("         LDD   <$B5                    ; A418: DC B5         \n");
    clockticks = clockticks + 4; 
    A = rd_mem(DP|0xb5); // Care needed with I/O space and word fetches
    B = rd_mem(DP|0xb6); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA41A; JUMP; // sstep
case 0xA41A:
                                                     mon("         STD   $507C                   ; A41A: FD 50 7C      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x507c, A); // Care needed with I/O space and word fetches
    wr_mem(0x507d, B); 
    PC = 0xA41D; JUMP; // sstep
case 0xA41D:
                                                     mon("         LDD   #$0F                    ; A41D: CC 00 0F      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x0f; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA420; JUMP; // sstep
case 0xA420:
                                                     mon("         STD   $4701                   ; A420: FD 47 01      \n"); // Point BIC to $5078 MReg3C
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4701, A); // Care needed with I/O space and word fetches
    wr_mem(0x4702, B); 
    PC = 0xA423; JUMP; // sstep
case 0xA423:
                                                     mon("         LDA   #$2A                    ; A423: 86 2A         \n"); // Reg00 = (([BIC,0] - XT) x Ax2)  +  (([BIC,1] - YT) x Bx2)  +  (([BIC,2] - ZT) x Cx2), Reg01 = (([BIC,0] - XT) x Ay2)  +  (([BIC,1] - YT) x By2)  +  (([BIC,2] - ZT) x Cy2), Reg02 = (([BIC,0] - XT) x Az2)  +  (([BIC,1] - YT) x Bz2)  +  (([BIC,2] - ZT) x Cz2), BIC++
    clockticks = clockticks + 2; 
    val = (UINT8)0x2a; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA425; JUMP; // sstep
case 0xA425:
                                                     mon("         JSR   LCDBA                   ; A425: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x28); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0xA428:
                                                     mon("LA428    LDD   $5002                   ; A428: FC 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    A = rd_mem(0x5002); // Care needed with I/O space and word fetches
    B = rd_mem(0x5003); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA42B; JUMP; // sstep
case 0xA42B:
                                                     mon("         STD   $5078                   ; A42B: FD 50 78      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5078, A); // Care needed with I/O space and word fetches
    wr_mem(0x5079, B); 
    PC = 0xA42E; JUMP; // sstep
case 0xA42E:
                                                     mon("         LDD   $5004                   ; A42E: FC 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    A = rd_mem(0x5004); // Care needed with I/O space and word fetches
    B = rd_mem(0x5005); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA431; JUMP; // sstep
case 0xA431:
                                                     mon("         STD   $507A                   ; A431: FD 50 7A      \n");
    clockticks = clockticks + 5; 
    Z = A | B; 
    N = A; 
    V = 0; 
    wr_mem(0x507a, A); // Care needed with I/O space and word fetches
    wr_mem(0x507b, B); 
    PC = 0xA434; JUMP; // sstep
case 0xA434:
                                                     mon("         BPL   LA455                   ; A434: 2A 1F         \n");
    // temp fix to ensure flags synched
    if ((SINT8)N >= 0) {
    PC = 0xa455; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA436; JUMP; // sstep
case 0xA436:
                                                     mon("         LDA   <$BC                    ; A436: 96 BC         \n");
    clockticks = clockticks + 4; 
    val = (UINT8)rd_mem(DP|0xbc); 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA438; JUMP; // sstep
case 0xA438:
                                                     mon("         BEQ   LA455                   ; A438: 27 1B         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa455; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA43A; JUMP; // sstep
case 0xA43A:
                                                     mon("         LDA   #$FF                    ; A43A: 86 FF         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0xff; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA43C; JUMP; // sstep
case 0xA43C:
                                                     mon("         STA   <$BD                    ; A43C: 97 BD         \n");
    clockticks = clockticks + 4; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    ea = DP|0xbd; 
    wr_mem(ea, val); 
    PC = 0xA43E; JUMP; // sstep
case 0xA43E:
                                                     mon("         LDA   #$03                    ; A43E: 86 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)0x03; 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA440; JUMP; // sstep
case 0xA440:
                                                     mon("         STA   $4B23                   ; A440: B7 4B 23      \n");
    clockticks = clockticks + 5; 
    val = A; 
/**/Z = val; 
/**/N = val; 
/**/V = 0; 
    wr_mem(0x4b23, val); 
    PC = 0xA443; JUMP; // sstep
case 0xA443:
                                                     mon("         LDD   #$6280                  ; A443: CC 62 80      \n");
    clockticks = clockticks + 3; 
    A = 0x62; 
    B = 0x80; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA446; JUMP; // sstep
case 0xA446:
                                                     mon("         STD   $4B20                   ; A446: FD 4B 20      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4b20, A); // Care needed with I/O space and word fetches
    wr_mem(0x4b21, B); 
    PC = 0xA449; JUMP; // sstep
case 0xA449:
                                                     mon("         LDD   $5004                   ; A449: FC 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    A = rd_mem(0x5004); // Care needed with I/O space and word fetches
    B = rd_mem(0x5005); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA44C; JUMP; // sstep
case 0xA44C:
                                                     mon("         LSRA                          ; A44C: 44            \n");
    val = (UINT8)A; 
    C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0xA44D; JUMP; // sstep
case 0xA44D:
                                                     mon("         RORB                          ; A44D: 56            \n");
    res = ((UINT8)B) | ((C != 0) ? 0x100 : 0); 
/**/C = res & 1; 
    res = (UINT8)(res >> 1); 
/**/Z = res; 
/**/N = res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA44E; JUMP; // sstep
case 0xA44E:
                                                     mon("         LSRA                          ; A44E: 44            \n");
    val = (UINT8)A; 
    C = val & 1; 
    val = val >> 1; 
    A = val; 
/**/N = 0; 
/**/Z = val; 
    clockticks = clockticks + 2; 
    PC = 0xA44F; JUMP; // sstep
case 0xA44F:
                                                     mon("         RORB                          ; A44F: 56            \n");
    res = ((UINT8)B) | ((C != 0) ? 0x100 : 0); 
/**/C = res & 1; 
    res = (UINT8)(res >> 1); 
/**/Z = res; 
/**/N = res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA450; JUMP; // sstep
case 0xA450:
                                                     mon("         ADDB  #$C0                    ; A450: CB C0         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)B; 
    arg = 0xc0; 
    res = val + (UINT8)arg; 
    C = (res >> 1) & 0x80; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
    H = (UINT8)((val ^ arg) ^ (res ^ C)); 
/**/V = (UINT8)((val ^ arg) ^ (res ^ C)); 
    B = (UINT8)res; 
    PC = 0xA452; JUMP; // sstep
case 0xA452:
                                                     mon("         STB   $4B22                   ; A452: F7 4B 22      \n");
    clockticks = clockticks + 5; 
    val = B; 
    Z = val; 
    N = val; 
    V = 0; 
    wr_mem(0x4b22, val); 
    PC = 0xA455; JUMP; // sstep
case 0xA455:
                                                     mon("LA455    JSR   LCDE7                   ; A455: BD CD E7      \n"); // Called during towers phase only
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x58); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcde7; 
    JUMP;
    // End of function sub_A40A
  case 0xA458:
                                                     mon("LA458    RTS                           ; A458: 39            \n");
    clockticks = clockticks + 5; 
    clockticks = clockticks + 1; 
    PC = rd_mem(S)<<8; 
    S = S + 1; 
    PC = PC | rd_mem(S); 
    S = S + 1; 
    JUMP;
    
    // =============== S U B R O U T I N E =======================================
    // Some Towers code
  case 0xA459:
                                                     mon("LA459    LDX   <$64                    ; A459: 9E 64         \n"); // Pointer to Tie fighter data
    clockticks = clockticks + 4; 
    clockticks = clockticks + 1; 
    ea = rd_mem(DP|0x64)<<8; 
    ea = ea | rd_mem(DP|0x65); 
    X = ea; 
/**/Z = X; 
/**/N = (X) >> 8; 
/**/V = 0; 
    PC = 0xA45B; JUMP; // sstep
case 0xA45B:
                                                     mon("         LDD   $507C                   ; A45B: FC 50 7C      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x507c); // Care needed with I/O space and word fetches
    B = rd_mem(0x507d); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA45E; JUMP; // sstep
case 0xA45E:
                                                     mon("         ASLB                          ; A45E: 58            \n");
    val = (UINT8)B; 
    res = val << 1; 
    C = res & 0x100; 
    res = (UINT8)res; 
/**/Z = res; 
/**/N = res; 
/**/V = val ^ res; 
    B = res; 
    clockticks = clockticks + 2; 
    PC = 0xA45F; JUMP; // sstep
case 0xA45F:
                                                     mon("         ROLA                          ; A45F: 49            \n");
    val = (UINT8)A; 
    res = (val << 1) + (C != 0 ?1:0); 
/**/C = res & 0x100; 
/**/Z = (UINT8)res; 
/**/N = (UINT8)res; 
/**/V = (UINT8)res ^ val; 
    A = (UINT8)res; 
    clockticks = clockticks + 2; 
    PC = 0xA460; JUMP; // sstep
case 0xA460:
                                                     mon("         STD   $4704                   ; A460: FD 47 04      \n");
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x4704, A); // Care needed with I/O space and word fetches
    wr_mem(0x4705, B); 
    PC = 0xA463; JUMP; // sstep
case 0xA463:
                                                     mon("         LDD   $02,X                   ; A463: EC 02         \n");
    clockticks = clockticks + 5; 
    ea = (UINT16)(X + 0x0002); 
    A = rd_mem(ea); // Care needed with I/O space and word fetches
    B = rd_mem((UINT16)(ea+1)); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA465; JUMP; // sstep
case 0xA465:
                                                     mon("         SUBD  $5042                   ; A465: B3 50 42      \n"); // YT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5042)<<8; 
    ea = ea | rd_mem(0x5043); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
/**/C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA468; JUMP; // sstep
case 0xA468:
                                                     mon("         STD   $5002                   ; A468: FD 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5002, A); // Care needed with I/O space and word fetches
    wr_mem(0x5003, B); 
    PC = 0xA46B; JUMP; // sstep
case 0xA46B:
                                                     mon("         LDD   #$00                    ; A46B: CC 00 00      \n");
    clockticks = clockticks + 3; 
    A = 0x00; 
    B = 0x00; 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA46E; JUMP; // sstep
case 0xA46E:
                                                     mon("         SUBD  $5044                   ; A46E: B3 50 44      \n"); // ZT2
    clockticks = clockticks + 6; 
    clockticks = clockticks + 1; 
    ea = rd_mem(0x5044)<<8; 
    ea = ea | rd_mem(0x5045); 
    val = ea; 
    arg = (A << 8) | B; 
    res = arg - val; 
    C = res & 0x10000; 
    res = (UINT16)res; 
/**/Z = res; 
/**/V = ((arg ^ val) & (arg ^ res)) >> 8; 
    A = (UINT8)(res >> 8); 
/**/N = res >> 8; 
    B = (UINT8)res; 
    PC = 0xA471; JUMP; // sstep
case 0xA471:
                                                     mon("         STD   $5004                   ; A471: FD 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5004, A); // Care needed with I/O space and word fetches
    wr_mem(0x5005, B); 
    PC = 0xA474; JUMP; // sstep
case 0xA474:
                                                     mon("         LDD   $4700                   ; A474: FC 47 00      \n");
    clockticks = clockticks + 5; 
    A = rd_mem(0x4700); // Care needed with I/O space and word fetches
    B = rd_mem(0x4701); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA477; JUMP; // sstep
case 0xA477:
                                                     mon("         STD   $5000                   ; A477: FD 50 00      \n"); // Math result X
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x5000, A); // Care needed with I/O space and word fetches
    wr_mem(0x5001, B); 
    PC = 0xA47A; JUMP; // sstep
case 0xA47A:
                                                     mon("         LDA   #$86                    ; A47A: 86 86         \n"); // MReg02 = MReg02 x MReg00
    clockticks = clockticks + 2; 
    val = (UINT8)0x86; 
    A = val; 
    N = val; 
    Z = val; 
    V = 0; 
    PC = 0xA47C; JUMP; // sstep
case 0xA47C:
                                                     mon("         JSR   LCDBA                   ; A47C: BD CD BA      \n"); // Do math program run
    clockticks = clockticks + 8; 
    S = S - 1; 
    wr_mem(S, 0x7f); 
    clockticks = clockticks + 1; 
    S = S - 1; 
    wr_mem(S, 0xa4); 
    clockticks = clockticks + 1; 
    PC = 0xcdba; 
    JUMP;
  case 0xA47F:
                                                     mon("LA47F    LDD   $5002                   ; A47F: FC 50 02      \n"); // Math result Y
    clockticks = clockticks + 5; 
    A = rd_mem(0x5002); // Care needed with I/O space and word fetches
    B = rd_mem(0x5003); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA482; JUMP; // sstep
case 0xA482:
                                                     mon("         STD   $501A                   ; A482: FD 50 1A      \n"); // YT
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x501a, A); // Care needed with I/O space and word fetches
    wr_mem(0x501b, B); 
    PC = 0xA485; JUMP; // sstep
case 0xA485:
                                                     mon("         LDD   $5004                   ; A485: FC 50 04      \n"); // Math result Z
    clockticks = clockticks + 5; 
    A = rd_mem(0x5004); // Care needed with I/O space and word fetches
    B = rd_mem(0x5005); 
/**/Z = A|B; 
/**/N = A; 
/**/V = 0; 
    PC = 0xA488; JUMP; // sstep
case 0xA488:
                                                     mon("         STD   $501C                   ; A488: FD 50 1C      \n"); // ZT
    clockticks = clockticks + 5; 
/**/Z = A | B; 
/**/N = A; 
/**/V = 0; 
    wr_mem(0x501c, A); // Care needed with I/O space and word fetches
    wr_mem(0x501d, B); 
    PC = 0xA48B; JUMP; // sstep
case 0xA48B:
                                                     mon("         LDA   $04,X                   ; A48B: A6 04         \n");
    clockticks = clockticks + 5; 
    val = (UINT8)rd_mem((UINT16)(X + 0x0004)); 
    A = val; 
/**/N = val; 
/**/Z = val; 
/**/V = 0; 
    PC = 0xA48D; JUMP; // sstep
case 0xA48D:
                                                     mon("         CMPA  #$03                    ; A48D: 81 03         \n");
    clockticks = clockticks + 2; 
    val = (UINT8)A; 
    arg = 0x03; 
    res = val - (UINT8)arg; 
    C = res & 0x100; 
    Z = (UINT8)res; 
    N = (UINT8)res; 
    V = (UINT8)((val ^ arg) & (val ^ res)); 
    PC = 0xA48F; JUMP; // sstep
case 0xA48F:
                                                     mon("         BEQ   LA49F                   ; A48F: 27 0E         \n");
    // temp fix to ensure flags synched
    if (!Z) {
    PC = 0xa49f; 
    JUMP;
    }
    clockticks = clockticks + 3; 
    PC = 0xA491; JUMP; // sstep
case 0xA491:
                                                     mon("         LDD   #$03C0                  ; A491: CC 03 C0      \n");
    clockticks = clockticks + 3; 
    A = 0x03; 
