?login_element?

Subversion Repositories NedoOS

Rev

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

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