?login_element?

Subversion Repositories NedoOS

Rev

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

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