                   // 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; 
