?login_element?

Subversion Repositories NedoOS

Rev

Rev 1200 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. DEBUGGER_MEMLINES=24
  2. DEBUGGER_DISASMLINES=24
  3. DEBUGGER_REGSLINES=14;13
  4. DEBUGGER_REGSY=0
  5. DEBUGGER_REGSX=0
  6. DEBUGGER_FLAGSY=DEBUGGER_REGSY+DEBUGGER_REGSLINES
  7. DEBUGGER_FLAGSX=DEBUGGER_REGSX
  8. DEBUGGER_DISASMY=0
  9. DEBUGGER_DISASMX=8
  10. DEBUGGER_MEMY=0
  11. DEBUGGER_MEMX=0x2b
  12.  
  13. DEBUGGER_COLORACTIVE=0x0f
  14. DEBUGGER_COLOR=0x07
  15. DEBUGGER_COLORCURSOR=0x38
  16.  
  17. Debugger
  18.         ld e,6+0x80 ;keep
  19.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  20.         ld e,0
  21.         OS_SETSCREEN
  22.         ld e,0 ;color byte
  23.         OS_CLS
  24.  
  25.         call Debugger_Redraw
  26. Debugger0
  27.         call Debugger_drawcursor
  28.         YIELDGETKEYLOOP
  29.         push af
  30.         call Debugger_undrawcursor
  31.         pop af
  32.         cp key_esc
  33.         jr z,DebuggerQuit
  34.  
  35.         ld hl,Debugger0
  36.         push hl
  37.         cp key_pgup
  38.         jr z,DebuggerPgUp
  39.         cp key_pgdown
  40.         jr z,DebuggerPgDown
  41.         cp key_up
  42.         jr z,DebuggerUp
  43.         cp key_down
  44.         jr z,DebuggerDown
  45.         cp key_left
  46.         jp z,DebuggerLeft
  47.         cp key_right
  48.         jp z,DebuggerRight
  49.         cp key_tab
  50.         jp z,DebuggerTab
  51.         cp key_enter
  52.         jp z,DebuggerEnter
  53.         call Debugger_edit
  54.         jp Debugger_Redraw
  55.  
  56. DebuggerQuit
  57. ;TODO wait key unpress
  58.         ret
  59.  
  60. DebuggerUp
  61.         call Debugger_decy ;m=overflow
  62.         ret p
  63. ;TODO scroll
  64.         call Debugger_getcuraddr16_de
  65.         ld hl,-8
  66.         add hl,de
  67.         call Debugger_putcuraddr16_hl
  68.         jp Debugger_Redraw
  69. DebuggerDown
  70.         call Debugger_incy ;z=overflow
  71.         ret nz
  72. ;TODO scroll (use nextaddr16)
  73.         call Debugger_getcuraddr16_de
  74.         ld hl,8
  75.         add hl,de
  76.         call Debugger_putcuraddr16_hl
  77.         jp Debugger_Redraw
  78.  
  79. DebuggerTab
  80.         call Debugger_inctab
  81.         jp Debugger_Redraw
  82.  
  83. DebuggerPgUp
  84.         call Debugger_getcuraddr16_de
  85.         ld a,(debugger_curtab)
  86.         dec a
  87.         ld hl,-(DEBUGGER_MEMLINES*8)
  88.         jr nz,$+5
  89.         ld hl,-DEBUGGER_MEMLINES
  90.         add hl,de
  91.         call Debugger_putcuraddr16_hl
  92.         jp Debugger_Redraw
  93.  
  94. DebuggerPgDown
  95.         call Debugger_getnextaddr16_de
  96.         ex de,hl
  97.         call Debugger_putcuraddr16_hl
  98.         jp Debugger_Redraw
  99.  
  100. DebuggerEnter_regs ;for change #fd
  101.         call Debugger_set7ffd
  102.         jp Debugger_Redraw
  103.  
  104. DebuggerEnter
  105.         ld a,(debugger_curtab)
  106.         dec a
  107.        jp m,DebuggerEnter_regs
  108.         ret nz
  109.         call Debugger_getcurxypos_de
  110.         ld a,e
  111.         cp 5
  112.         ret nz
  113.        
  114.         ld hl,(debugger_curdisasmaddr) ;TODO current line
  115.       push hl
  116.         call Debugger_GetCmd_to_disasmcmdbuf
  117.         call Debugger_Disasm_cmdbuf_to_textbuf
  118.        
  119.         ld e,DEBUGGER_COLORACTIVE
  120.         OS_SETCOLOR
  121.         call Debugger_getcurxy_de_widb
  122.         ld hl,disasmtextbuf
  123.         call EditLine_xyde_widb
  124.        
  125.         ld de,disasmtextbuf
  126.         ld hl,disasmcmdbuf
  127. ;de=cmd text
  128. ;hl=code generated ;out: after the code
  129. ;out: NZ=error
  130.         call asmcmd
  131.  
  132.         ld e,2
  133.         jr nz,DebuggerEnter_error
  134.         ld e,0
  135. DebuggerEnter_error
  136.        push hl
  137.         OS_SETBORDER
  138.        pop hl ;after the code
  139.         ld de,disasmcmdbuf
  140.         ld a,l
  141.         sub e
  142.      pop hl ;hl=(debugger_curdisasmaddr)+
  143.         jr z,DebuggerEnter_nocmd
  144.         ld b,a ;b=generated code len
  145.         ;de=disasmcmdbuf
  146. DebuggerEnter_writecmd0
  147.         push bc
  148.         ld a,(de)
  149.         inc de
  150.         call Debugger_PutMem_hl_a
  151.         inc hl
  152.         pop bc
  153.         djnz DebuggerEnter_writecmd0
  154. DebuggerEnter_nocmd
  155.         jp Debugger_Redraw
  156.  
  157. Debugger_undrawcursor
  158.         ld c,DEBUGGER_COLORACTIVE;0x0f;0x07
  159.         jr Debugger_drawcursor_colorc
  160. Debugger_drawcursor
  161.         ld c,DEBUGGER_COLORCURSOR;0x38
  162. Debugger_drawcursor_colorc
  163.         call Debugger_getcurxy_de_widb
  164.         ld l,c
  165. drawcursor_sizeb0
  166.         push bc
  167.         push de
  168.         push hl ;color
  169.         OS_SETXY
  170.         pop de ;color
  171.         push de ;color
  172.         OS_PRATTR
  173.         pop hl ;color
  174.         pop de
  175.         pop bc
  176.         inc e ;x
  177.         djnz drawcursor_sizeb0
  178.         ret
  179.  
  180. Debugger_editbyte_c_keya
  181.        if 1
  182.         sla c
  183.         sla c
  184.         sla c
  185.         sla c
  186.         or c
  187.         ld c,a
  188.        else
  189. hexeditor_half=$
  190.         or a ;/scf
  191.         jr c,hexeditor_symbol_right
  192.         add a,a
  193.         add a,a
  194.         add a,a
  195.         add a,a;a=XXXX0000
  196.         xor c
  197.         and 0xf0
  198.         jr hexeditor_symbol_rightq
  199. hexeditor_symbol_right
  200.         xor c
  201.         and 0x0f
  202. hexeditor_symbol_rightq
  203.         xor c
  204.         ld c,a
  205.         ld a,(hexeditor_half)
  206.         xor 0x80
  207.         ld (hexeditor_half),a
  208.        endif
  209.         ret
  210.  
  211. countdigit
  212. ;C=error
  213.         cp '0'
  214.         ret c
  215.         cp '9'+1
  216.         jr c,DebuggerDigit
  217.         cp 'a'
  218.         ret c
  219.         cp 'f'+1
  220.         ccf
  221.         ret c
  222.         sub 'a'-('9'+1)
  223. DebuggerDigit
  224.         sub '0'
  225.         ret
  226.  
  227. Debugger_edit
  228.        ld lx,a
  229.         call Debugger_getcurxypos_de
  230.         ld a,(debugger_curtab)
  231.         dec a
  232.         jr z,Debugger_edit_disasm
  233.         jp p,Debugger_edit_mem
  234. ;Debugger_edit_regs
  235.         ld hl,curregs
  236.         ld a,d
  237.         add a,a
  238.         add a,l
  239.         ld l,a
  240.         jr nc,$+3
  241.         inc h
  242.         dec e
  243.         jr z,$+3
  244.         inc hl
  245.        ld a,lx
  246.         call countdigit ;C=error
  247.         ret c
  248.         ld c,(hl) ;
  249.         call Debugger_editbyte_c_keya
  250.         ld (hl),c
  251.         ret
  252. Debugger_edit_disasm
  253.        ld a,e
  254.        or a
  255.        jr z,Debugger_edit_disasm_newaddr
  256.        dec e
  257.        cp 1+4
  258.        ret nc ;TODO edit asm
  259.         ld hl,(debugger_curdisasmaddr)
  260.        push de ;e=x
  261.         ld a,d ;y
  262.         or a
  263.         jr z,Debugger_edit_disasm0q
  264. Debugger_edit_disasm0
  265.         push de
  266.         push hl
  267.         call Debugger_GetCmd_to_disasmcmdbuf
  268.         ld hl,disasmcmdbuf
  269.         call Disasm_GetCmdLen_bc
  270.         pop hl
  271.         pop de
  272.         add hl,bc
  273.         dec d
  274.         jr nz,Debugger_edit_disasm0
  275. Debugger_edit_disasm0q
  276.        pop de ;e=x
  277.        ld d,0
  278.        add hl,de
  279. ;TODO проверить длину и не редактировать невидимые байты (которые e>=len)
  280.         jr Debugger_edit_inmem
  281. Debugger_edit_disasm_newaddr
  282.         xor a
  283.         ld (debugger_curdisasmy),a
  284.         ld hl,debugger_curdisasmaddr
  285.         jr Debugger_edit16bit
  286. Debugger_edit_mem
  287.        ld a,e
  288.        or a
  289.        jr z,Debugger_edit_mem_newaddr
  290.        dec e
  291.        sub 9
  292.        jr nc,Debugger_edit_mem_edittext
  293.         call Debugger_memaddr_from_de
  294. Debugger_edit_inmem
  295.         call Debugger_GetMem_hl_to_a
  296.         ld c,a
  297.        ld a,lx
  298.         call countdigit ;C=error
  299.         ret c
  300.         call Debugger_editbyte_c_keya
  301.         ld a,c
  302.         jp Debugger_PutMem_hl_a
  303. Debugger_edit_mem_newaddr
  304.         xor a
  305.         ld (debugger_curmemy),a
  306.         ld hl,debugger_curmemaddr
  307. Debugger_edit16bit
  308.         ld a,lx
  309.         call countdigit ;C=error
  310.         ret c
  311.         ld c,a
  312.         ld a,(hl)
  313.         inc hl
  314.        dup 4
  315.         add a,a
  316.         rl (hl)
  317.        edup
  318.         dec hl
  319.         or c
  320.         ld (hl),a
  321.         ret
  322. Debugger_edit_mem_edittext
  323.         ld e,a
  324.         call Debugger_memaddr_from_de
  325.         ld a,lx
  326.         ld (hl),a
  327.         ret
  328.  
  329. Debugger_memaddr_from_de
  330.         ld l,d
  331.         ld h,0
  332.         ld d,h;0
  333.         add hl,hl
  334.         add hl,hl
  335.         add hl,hl
  336.         add hl,de
  337.         ld de,(debugger_curmemaddr)
  338.         add hl,de
  339.         ret
  340.  
  341. Debugger_Redraw
  342.         ;ld de,0x0000
  343.         ;OS_SETXY
  344.         ;ld hl,tdebugger
  345.         ;call Debugger_PrText
  346.         xor a
  347.         call Debugger_setcolorz
  348.         ld de,DEBUGGER_REGSY*256+DEBUGGER_REGSX
  349.         call Debugger_PrRegs
  350.        
  351.         call Debugger_setcolor_normal
  352.         ld de,DEBUGGER_FLAGSY*256+DEBUGGER_FLAGSX
  353.         call Debugger_PrFlags
  354.  
  355.         ld a,1
  356.         call Debugger_setcolorz
  357.         ld hl,(debugger_curdisasmaddr)
  358.         ld de,DEBUGGER_DISASMY*256+DEBUGGER_DISASMX
  359.         call Debugger_Disasm_hl
  360.  
  361.         ld a,2
  362.         call Debugger_setcolorz
  363.         ld hl,(debugger_curmemaddr)
  364.         ld de,DEBUGGER_MEMY*256+DEBUGGER_MEMX
  365.         call Debugger_PrMem_hl
  366.  
  367.         jr Debugger_setcolor_normal
  368.  
  369. Debugger_setcolorz
  370.         ld hl,debugger_curtab
  371.         cp (hl)
  372.         ld e,DEBUGGER_COLORACTIVE;0x0f
  373.         jr z,$+4
  374. Debugger_setcolor_normal
  375.         ld e,DEBUGGER_COLOR;0x07
  376.         OS_SETCOLOR
  377.         ret
  378.  
  379. Debugger_PrRegs
  380.         ld bc,tregs
  381.         ld hl,curregs
  382. Debugger_PrRegs0
  383.         ld a,(bc)
  384.         or a
  385.         ret z
  386.       push de
  387.        push hl
  388.         push bc
  389.         OS_SETXY
  390.         pop bc
  391.         call Debugger_PrChar_bc
  392.         call Debugger_PrChar_bc
  393.         call Debugger_PrChar_bc
  394.        pop hl
  395.         ld e,(hl)
  396.         inc hl
  397.        ;push hl
  398.         ld d,(hl)
  399.         ;push bc
  400.         call Debugger_PrWord_de
  401.         ;pop bc
  402.        ;pop hl
  403.         inc hl
  404.       pop de
  405.         inc d
  406.         jr Debugger_PrRegs0
  407.  
  408. Debugger_PrFlags
  409.         OS_SETXY
  410.         ld a,(curaf) ;flags
  411.         ld c,a
  412.         ld hl,tflags
  413.         scf
  414. Debugger_PrFlags0
  415.         rl c
  416.         ret z
  417.         ld a,(hl)
  418.         inc hl
  419.         jr c,Debugger_PrFlags_nooff
  420.         add a,0x20
  421.         cp 'a'
  422.         jr nc,Debugger_PrFlags_nooff
  423.         ld a,'.'
  424. Debugger_PrFlags_nooff
  425.         call Debugger_PrChar
  426.         or a
  427.         jr Debugger_PrFlags0
  428. tflags
  429.         db "SZ5H3PNC"
  430.  
  431. Debugger_PrMem_hl
  432.         ld b,DEBUGGER_MEMLINES
  433. Debugger_PrMem0
  434.         push bc
  435.         push de
  436.         push hl
  437.         OS_SETXY
  438.         pop hl
  439.         call Debugger_PrMemLine_hl
  440.         pop de
  441.         inc d
  442.         pop bc
  443.         djnz Debugger_PrMem0
  444.         ld (debugger_nextmemaddr),hl
  445.         ret
  446.        
  447. Debugger_PrMemLine_hl ;return hl = hl+8
  448.         push hl
  449.         ex de,hl
  450.         call Debugger_PrWord_de
  451.         call Debugger_PrSpace
  452.         pop hl
  453.         push hl
  454.         ld b,8
  455. Debugger_PrMemLine0
  456.         push bc
  457.         call Debugger_GetMem_hl_to_a
  458.         inc hl
  459.         ;push hl
  460.         call Debugger_PrHex_a
  461.         call Debugger_PrSpace
  462.         ;pop hl
  463.         pop bc
  464.         djnz Debugger_PrMemLine0
  465.         pop hl
  466.         ld b,8
  467. Debugger_PrMemLine1
  468.         push bc
  469.         call Debugger_GetMem_hl_to_a
  470.         inc hl
  471.         ;push hl
  472.        ld bc,t866toatm+'?'
  473.        cp 0x0d
  474.        jr z,Debugger_PrMemLine_skipchar
  475.        cp 0x0a
  476.        jr z,Debugger_PrMemLine_skipchar
  477.        cp 0x08
  478.        jr z,Debugger_PrMemLine_skipchar
  479.        cp 0x09
  480.        jr z,Debugger_PrMemLine_skipchar
  481.        jr c,Debugger_PrMemLine_prchar ;неполная таблица
  482.        ld c,a
  483. Debugger_PrMemLine_skipchar
  484.        ld a,(bc)
  485. Debugger_PrMemLine_prchar
  486.         call Debugger_PrChar
  487.         ;pop hl
  488.         pop bc
  489.         djnz Debugger_PrMemLine1
  490.         ret
  491.  
  492. Debugger_Disasm_hl
  493.         ld b,DEBUGGER_DISASMLINES
  494. Debugger_Disasm0
  495.         push bc
  496.         push de
  497.         push hl
  498.         OS_SETXY
  499.         pop hl
  500.         call Debugger_DisasmLine_hl
  501.         pop de
  502.         inc d
  503.         pop bc
  504.         djnz Debugger_Disasm0
  505.         ld (debugger_nextdisasmaddr),hl
  506.         ret
  507.        
  508. Debugger_DisasmLine_hl ;return hl = next cmd
  509.        push hl
  510.         ld d,h
  511.         ld e,l
  512.         call Debugger_PrWord_de
  513.         call Debugger_PrSpace
  514.         call Debugger_GetCmd_to_disasmcmdbuf
  515.         ld hl,disasmcmdbuf
  516.         push hl
  517.         call Disasm_GetCmdLen_bc
  518.         pop hl
  519.        
  520.        push bc
  521.  
  522.        ;push hl
  523.         ld b,4
  524. Debugger_DisasmLine_hl0
  525. ;4-b = n = номер печатаемого байта
  526.        ld a,4
  527.        sub b
  528. ;n >= c печатать нельзя, вместо этого пробелы
  529.        cp c
  530.         ld a,(hl)
  531.         inc hl
  532.         jr c,Debugger_DisasmLine_hl_nospaces
  533.         call Debugger_PrSpace
  534.         call Debugger_PrSpace
  535.         or a
  536. Debugger_DisasmLine_hl_nospaces
  537.         call c,Debugger_PrHex_a
  538.         djnz Debugger_DisasmLine_hl0
  539.  
  540.         call Debugger_Disasm_cmdbuf_to_textbuf
  541.        
  542.         ld hl,disasmtextbuf
  543.         ld b,disasmtextbuf_sz
  544.         call Debugger_PrChars_hl_b
  545.        
  546.        pop bc
  547.        pop hl
  548.         add hl,bc
  549.         ret
  550.  
  551. Debugger_PrChars_hl_b
  552. Debugger_DisasmLine_pr0
  553.         ld a,(hl)
  554.         inc hl
  555.         call Debugger_PrChar
  556.         djnz Debugger_DisasmLine_pr0
  557.         ret
  558.  
  559. Debugger_Disasm_cmdbuf_to_textbuf
  560.         ld hl,disasmtextbuf
  561.        push hl
  562.         ld de,disasmtextbuf+1
  563.         ld bc,disasmtextbuf_sz-1
  564.         ld (hl),' '
  565.         ldir
  566.        pop ix
  567.         ld hl,disasmcmdbuf;pop hl ;cmdbuf      
  568.         jp Disasm_COMMAND
  569.  
  570. Debugger_GetCmd_to_disasmcmdbuf
  571.        ld (disasmcmdaddr),hl
  572.         ld de,disasmcmdbuf
  573. Debugger_CopyMem_hl_to_de_4bytes
  574.         call Debugger_CopyMem_hl_to_de_2bytes
  575. Debugger_CopyMem_hl_to_de_2bytes
  576.         call Debugger_CopyMem_hl_to_de
  577. Debugger_CopyMem_hl_to_de
  578.         call Debugger_GetMem_hl_to_a
  579.         inc hl
  580.         ld (de),a
  581.         inc de
  582.         ret
  583.  
  584. disasmcmdbuf
  585.         ds 4
  586. disasmtextbuf
  587.         ds 21
  588. disasmtextbuf_sz=$-disasmtextbuf
  589.  
  590. Debugger_PrText
  591.         ld a,(hl)
  592.         inc hl
  593.         or a
  594.         ret z
  595.         push hl
  596.         PRCHAR
  597.         pop hl
  598.         jr Debugger_PrText
  599.        
  600. Debugger_PrChar_bc
  601.         ld a,(bc)
  602.         inc bc
  603.         jr Debugger_PrChar
  604.  
  605. Debugger_PrWord_de
  606. ;de=word
  607.         ld a,d
  608.         call Debugger_PrHex_a
  609.         ld a,e
  610. Debugger_PrHex_a
  611.         push af
  612.         rra
  613.         rra
  614.         rra
  615.         rra
  616.         call Debugger_PrHexDig
  617.         pop af
  618. Debugger_PrHexDig
  619.         or 0xf0
  620.         daa
  621.         add a,0xa0
  622.         adc a,0x40
  623. Debugger_PrChar
  624.        push bc
  625.        push de
  626.        push hl
  627.         PRCHAR
  628.        pop hl
  629.        pop de
  630.        pop bc
  631.         ret
  632.  
  633. Debugger_PrSpace
  634.         ld a,' '
  635.         jr Debugger_PrChar
  636.        
  637. tregs
  638.         db "af:"
  639.         db "bc:"
  640.         db "de:"
  641.         db "hl:"
  642.         db "af'"
  643.         db "bc'"
  644.         db "de'"
  645.         db "hl'"
  646.         db "sp:"
  647.         db "pc:"
  648.         db "ix:"
  649.         db "iy:"
  650.         db "ir:"
  651.         db "FD:"
  652.         db 0
  653.        
  654. ;tdebugger
  655. ;        db "Debugger",0
  656.  
  657. Debugger_inctab
  658.         ld hl,debugger_curtab
  659.         inc (hl)
  660.         ld a,(hl)
  661.         sub 3
  662.         ret nz
  663.         ld (hl),a
  664.         ret
  665.  
  666. Debugger_getcuraddr16_de
  667.         call Debugger_getcurtab_hl_curaddr16_a_ys_d_y
  668.         ld e,(hl)
  669.         inc hl
  670.         ld d,(hl) ;curaddr16
  671.         ret
  672. Debugger_putcuraddr16_hl
  673.         push hl
  674.         call Debugger_getcurtab_hl_curaddr16_a_ys_d_y
  675.         pop de
  676.         ld (hl),e
  677.         inc hl
  678.         ld (hl),d ;curaddr16
  679.         ret
  680.  
  681. Debugger_getnextaddr16_de
  682.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  683.         dec hl
  684.         ld d,(hl)
  685.         dec hl
  686.         ld e,(hl) ;nextaddr16
  687.         ret
  688. Debugger_putnextaddr16_hl
  689.         push hl
  690.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  691.         pop de
  692.         dec hl
  693.         ld (hl),d
  694.         dec hl
  695.         ld (hl),e ;nextaddr16
  696.         ret
  697.  
  698. Debugger_getcurtab_hl_curaddr16_a_ys_d_y
  699.         ld a,(debugger_curtab)
  700. ;Debugger_getatab_hl_curaddr16_a_ys_d_y
  701.         add a,a
  702.         ld hl,tdebuggertabs
  703.         add a,l
  704.         ld l,a
  705.         jr nc,$+3
  706.         inc h
  707.         ld a,(hl)
  708.         inc hl
  709.         ld h,(hl)
  710.         ld l,a ;hl=tab
  711.         ld d,(hl) ;y
  712.         inc hl
  713.         ld a,(hl) ;ys
  714.         inc hl
  715.         ret
  716.  
  717. Debugger_getcurtab_hl_cury_a_ys_d_y
  718.         ;ld a,(debugger_curtab)
  719. ;Debugger_getatab_hl_cury_a_ys_d_y
  720.         ;call Debugger_getatab_hl_curaddr16_a_ys_d_y
  721.         call Debugger_getcurtab_hl_curaddr16_a_ys_d_y
  722.         inc hl ;
  723.         inc hl ;skip curaddr16
  724.         inc hl ;
  725.         inc hl ;skip nextaddr16
  726.         ret
  727.  
  728. Debugger_incy
  729. ;z=overflow
  730.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  731.         inc (hl) ;cury
  732.         cp (hl)
  733.         ret nz
  734.         dec (hl);ld (hl),0 ;TODO scroll
  735.         xor a ;z
  736.         ret
  737.  
  738. Debugger_decy
  739. ;m=overflow
  740.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  741.         ;dec a
  742.         dec (hl) ;cury
  743.         ret p
  744.         inc (hl);ld (hl),a ;TODO scroll
  745.         xor a
  746.         dec a ;m
  747.         ret
  748.  
  749. Debugger_incx
  750.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  751.         inc hl ;skip cury
  752.         ld a,(hl) ;xs
  753.         inc hl
  754.         inc (hl) ;curx
  755.         cp (hl)
  756.         ret nz
  757.         ld (hl),0
  758.         ret
  759.  
  760. Debugger_decx
  761.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  762.         inc hl ;skip cury
  763.         ld a,(hl) ;xs
  764.         inc hl
  765.         dec a
  766.         dec (hl) ;curx
  767.         ret p
  768.         ld (hl),a
  769.         ret
  770.  
  771. Debugger_getcurxy_de_widb
  772.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  773.         ld a,d
  774.         add a,(hl) ;cury
  775.         ld d,a
  776.         inc hl
  777.         inc hl ;skip xs
  778.         ld a,(hl) ;curx
  779.         inc hl
  780.         add a,a
  781.         add a,l
  782.         ld l,a
  783.         jr nc,$+3
  784.         inc h
  785.         ld e,(hl)
  786.         inc hl
  787.         ld b,(hl)
  788.         ret
  789.  
  790. Debugger_getcurxypos_de
  791.         call Debugger_getcurtab_hl_cury_a_ys_d_y
  792.         ld d,(hl) ;cury
  793.         inc hl
  794.         inc hl ;skip xs
  795.         ld e,(hl) ;curx
  796.         ret
  797.  
  798. debugger_curtab ;regs, disasm, mem
  799.         db 1
  800. tdebuggertabs
  801.         dw tdebuggertab_regs
  802.         dw tdebuggertab_disasm
  803.         dw tdebuggertab_mem
  804. ;y,ys
  805. ;curaddr16
  806. ;nextaddr16
  807. ;cury
  808. ;xs
  809. ;curx
  810. ;x0,x0wid,x1,x1wid,...
  811. tdebuggertab_regs
  812.         db DEBUGGER_REGSY,DEBUGGER_REGSLINES
  813.         dw 0,0
  814.         db 0
  815.         db 2
  816.         db 0
  817.         db DEBUGGER_REGSX+3,2
  818.         db DEBUGGER_REGSX+5,2
  819. tdebuggertab_disasm
  820.         db DEBUGGER_DISASMY,DEBUGGER_DISASMLINES
  821. debugger_curdisasmaddr
  822.         dw 0
  823. debugger_nextdisasmaddr
  824.         dw 0
  825. debugger_curdisasmy
  826.         db 0
  827.         db 6
  828.         db 0
  829.         db DEBUGGER_DISASMX,4
  830.         db DEBUGGER_DISASMX+5,2
  831.         db DEBUGGER_DISASMX+7,2
  832.         db DEBUGGER_DISASMX+9,2
  833.         db DEBUGGER_DISASMX+11,2
  834.         db DEBUGGER_DISASMX+13,disasmtextbuf_sz
  835. tdebuggertab_mem
  836.         db DEBUGGER_MEMY,DEBUGGER_MEMLINES
  837. debugger_curmemaddr
  838.         dw 0
  839. debugger_nextmemaddr
  840.         dw 0
  841. debugger_curmemy
  842.         db 0
  843.         db 1+8+8;3
  844.         db 0
  845.         db DEBUGGER_MEMX,4
  846.         ;db DEBUGGER_MEMX+5,8*3-1
  847.         ;db DEBUGGER_MEMX+5+(8*3),8
  848. _=DEBUGGER_MEMX+5
  849.        dup 8
  850.         db _,2
  851. _=_+3
  852.        edup
  853.        dup 8
  854.         db _,1
  855. _=_+1
  856.        edup
  857.  
  858. DebuggerLeft=Debugger_decx
  859. DebuggerRight=Debugger_incx
  860.