Subversion Repositories NedoOS

Rev

Rev 1148 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

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