spectnetide
spectnetide copied to clipboard
Stepping through code in debug mode does not update the current code line indicator
I've set a breakpoint in my code, and when it's hit use F10 to step through the code, but the highlight remains at the breakpoint line, and doesn't follow the PC. The window DOES attempt to scroll though.
Version: 2.0.6
@nww02, could you sent me a few concrete steps to reproduce this issue, please?
I wrote some code.
Placed it at .org 8000
Started the emulator
Injected the code
Inserted some breakpoints in the code.
Pressed "run" in the emulator
typed RANDOMIZE USR 32768
Code stopped at the breakpoint
clicked the "Step Over" button in the emulator (sadly pressing F10 in the code doesn't work).
The code window scrolled down a line, (like what would happen if you had the SCROLL LOCK on and pressed the down arrow). but the orange "here" line remained pointing at the breakpoint
Pressing "debug Run>" will make the code repeat, and go to the next breakpoint, which may (or may not) update the orange "here" line.
Scrolling the line out of view, and then scrolling it back into view DOES update the orange "here" line. It's as if the code window hasn't updated that paint area. (this last step I discovered last night through experimenting, cos debugging was hard without the current line haha).
@nww2, Thanks for the repro steps!
The more I think about it, the scrolling out of view and back making it update correctly makes me think it's a Visual Studio bug. I've started a new project, and the stepping is working okay (so far), although VS has crashed a few times when I hit breakpoints :-/
Nonetheless, I try to test it using your repro steps. It's not unusual for me to cope with such issues :-)
It started happening again with the new project. I'm happy to send you the code I'm working on if you can't reproduce it.
I'm coping by counting lines and scrolling, so there's no massive rush to fix. :)
@nww02, that would be a great help! Please attach the code to this issue thread.
To run the code, INK3: PAPER 5: PRINT AT 5,5;"Hello" : RANDOMIZE USR 32832. If there's any colourful graphics/text on the screen, it should move the colour attributes down a line. It should breakpoint early on, and then if I try to step through (I was debugging byte placement of the parameters), it doesn't update the current execution line.. (There's a lot of spare code in here, but just in case it's a length thing, I've dropped it all in).
; Put your Z80 assembly code into code files Start: .model Spectrum48
// for Attribute scrolling. // w1 = top left (mem address (w1) = top line, (w1+1) = left col (or in byte terms msb << col, lsb >> line). // w2 = bot right (mem address (w2) = bot line, (w2+1) = right col (or in byte terms msb << col, lsb >> line). // b1 = action where 0 = leave the last line, 1=roll the shifted line to the last line, 2=fill the // last line with a pattern // b2 = pattern to fill the last line with when b1==2
// scr_att_scroll_l : Scroll the screen's attributes left (b1=action, b2=fill)
// scr_att_scroll_r : Scroll the screen's attributes right (b1=action, b2=fill)
// scr_att_inv : Invert pen/paper attributes across the screen
// scr_att_scroll_d : Scroll screen attributes down (b1 = action, b2=fill)
// scr_att_scroll_u : Scroll screen attributes up (b1 = action, b2=fill)
// rect_att_scroll_l : Scroll attribute rectangle left (w1 = topleft, w2 = botright, b1=action, b2=fill)
// rect_att_scroll_r : Scroll attribute rectangle right (w1 = topleft, w2 = botright, b1=action, b2=fill)
// rect_att_inv : Invert pen/paper attributes in a rectangle (w1 = topleft, w2 = bottomright)
// rect_att_scroll_d : Scroll attribute rectangle down (w1 = topleft, w2 = botright, b1 = action, b2=fill)
// rect_att_scroll_u : Scroll attribute rectangle up (w1 = topleft, w2 = botright, b1 = action, b2=fill)
//rect_pix_scroll_l: Scroll pixel data rectangle left (w1 = topleft, w2 = botright, b1=action, b2=fill pattern)
//rect_pix_scroll_r: Scroll pixel data rectangle right (w1 = topleft, w2 = botright, b1=action, b2=fill pattern
//32768
.org #8000
ld a,5
ld (paramw1),a
ld (paramw1+1),a
ld a,0fh
ld (paramw2),a
ld (paramw2+1),a
call rect_att_inv
ret
//32800
.org #8020
ld a,2h
ld (paramw1),a
ld (paramw1+1),a
ld a,17h
ld (paramw2),a
ld (paramw2+1),a
ld a,0
ld (paramb1),a
ld a,55
ld (paramb2),a
call rect_att_scroll_d
call rect_att_scroll_d
call rect_att_scroll_d
ret
.org #8040 //32832
ld a,1h
ld (paramw1),a
ld a,8h
ld (paramw1+1),a
ld a,17h
ld (paramw2),a
ld (paramw2+1),a
ld a,2
ld (paramb1),a
ld a,55
ld (paramb2),a
call rect_att_scroll_d
call rect_att_scroll_d
call rect_att_scroll_d
ret
ret
////////////////////////////// // Parameters to functions //////////////////////////////
paramw1: defw 0,0
paramw2: defw 0,0
paramb1: defb 0
paramb2: defb 0
paramb3: defb 0
paramb4: defb 0
paramb5: defb 0
//Switch the ink and paper in a rectangle //paramw1 = top left X, Y //paramw2 = bottom right X, Y rect_att_inv: ld bc,(paramw1) ld hl,(paramw2) ld a,l cp 18h ret nc sub c ret c ld e,a ld a,h cp 20h ret nc sub b ret c ld d,a inc d inc e push de ld hl,5800h xor a cp c ld de,20h jr z,ri_hop1 ri_nxt1: add hl,de dec c jr nz,ri_nxt1 ri_hop1: cp b jr z,ri_hop2 ri_nxt2: inc hl djnz ri_nxt2 ri_hop2: pop bc ri_nxtline: push de push hl push bc ri_nxt3: ld a,7 and (hl) rrca rrca ld c,a ld a,38h and (hl) add a,c rrca rrca rrca ld c,a ld a,0c0h and (hl) add a,c ld (hl),a inc hl djnz ri_nxt3 pop bc pop hl pop de dec c add hl,de jr nz,ri_nxtline ret halt // guard byte
//Switch the ink and paper for the whole screen //No params scr_att_inv: ld hl,5800h ; beginning of attributes si_nxtatt: ld a,7 and (hl) ; take ink rrca rrca ld d,a ; store it ld a,3bh and (hl) ; take paper add a,d ; put in front of paper rrca ; ink and paper reversed rrca ld d,a ; store them ld a,0c0h ; take bright and flash and (hl) add a,d ; combine ld (hl),a ; store new attribs inc hl ld a,h ; check at end of screen cp 5bh jr c,si_nxtatt ; loop or ret ret halt // guard byte
// Scroll the attributes LEFT //paramw1 = top left X, Y //paramw2 = bottom right X, Y //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' attribs 1=b,2=r,4=g,8=B,16=R,32=G,Br=64,Fl=128 rect_att_scroll_l: ld a,(rs_swap1) cp 0 jr z,rectscrlr ld a,00h ld (rs_swap1),a ld a,23h ld (rs_swap2),a ld a,0b0h ld (rs_swap3+1),a jr rectscrlr
// Scroll the attributes RIGHT //paramw1 = top left X, Y //paramw2 = bottom right X, Y //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' attribs 1=b,2=r,4=g,8=B,16=R,32=G,Br=64,Fl=128 rect_att_scroll_r: ld a,(rs_swap1) cp 0 jr nz,rectscrlr ld a,44h ld (rs_swap1),a ld a,2bh ld (rs_swap2),a ld a,0b8h ld (rs_swap3+1),a
// Scroll the attributes in the last direction scrolled (default right) rectscrlr: ld bc,(paramw1) ; c = l1, b = c1 ld hl,(paramw2) ; l = l2, h = c2 ld a,l ; check for legality of cp 18h ;l1 & l2; return if ret nc ; illegal coords sub c ret c ld d,a ld a,h ; check for validity of c1 cp 20h ; and c2, return if illegal ret nc ; coords sub b ret c ld e,a ; e = width - 1 inc d ; d = height push de rs_swap1: ld b,h ; switches between l & r ld hl,5800h ; find the top line of the xor a ; 'scroll' rectangle ld de,20h cp c jr z,rs_hop1 rs_nxt1: add hl,de dec c jr nz,rs_nxt1 rs_hop1: cp b ; find topleft (l-scroll) jr z,rs_hop2 ; or topright (r-scroll) rs_nxt2: inc hl ; corner of rectangle djnz rs_nxt2 rs_hop2: pop bc ; bc=width of rect - 1 rs_nxtline: push bc ld b,a ; set up variables de push de ; and hl, ready to scroll ld d,h ; the top line of the ld e,l ; rectangle push de cp c ld a,(de) jr z,rs_hop3 rs_swap2: dec hl ; switches between l & r rs_swap3: lddr ; switches between l & r rs_hop3: ld bc,(paramb1) ; having scrolled ld h,a ; decide whether to ld a,c cp 1 jr c,rs_leavit ld a,h jr z,rs_roll rs_fill: ld a,b ; fill it rs_roll: ld (de),a ; roll it rs_leavit: pop hl ; leave it pop de ; pre[are for the next line pop bc add hl,de xor a djnz rs_nxtline ; repeat until bottom of rect ret halt ; guard byte
// Scroll the screen RIGHT //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' attribs 1=b,2=r,4=g,8=B,16=R,32=G,Br=64,Fl=128 scr_att_scroll_r: ld de,5affh ; bottom right corner ssr_nxtline: ld bc,001fh ld h,d ld l,e dec hl ld a,(de) lddr ; scroll the bottom line ld bc,(paramb1) ; Will pick up Paramb1 and Paramb2 because they're adjacent in RAM ld h,a ld a,c cp 1 jr c,ssr_leavit ; if c=0 then 'leave' ld a,h jr z,ssr_roll ; if c=1 then 'roll' ssr_fill: ld a,b ; else 'fill' ssr_roll: ld (de),a ssr_leavit: dec de ; up a line ld a,d ; finished? cp 57h jr nz,ssr_nxtline ; > nope ret ; > yep halt // guard byte
// Scroll the screen LEFT //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' attribs 1=b,2=r,4=g,8=B,16=R,32=G,Br=64,Fl=128 scr_att_scroll_l: ld de,5800h ; top left corner ssl_nxtline: ld bc,001fh ld h,d ld l,e inc hl ld a,(de) ldir ; scroll top line ld bc,(paramb1) ; Will pick up Paramb1 and Paramb2 because they're adjacent in RAM ld h,a ld a,c cp 1 jr c,ssl_leavit ; if c=0 then 'leave' ld a,h jr z,ssl_roll ; if c=1 then 'roll' ssl_fill: ld a,b ; else 'fill' ssl_roll: ld (de),a ssl_leavit: inc de ; up a line ld a,d ; finished? cp 5bh jr nz,ssl_nxtline ; > nope ret ; > yep halt // guard byte
// Scroll a rectangle of attributes down. //paramw1 = c1 / l1 //paramw2 = c2 / l2 // paramb1 = action 0-> leave the last line, // 1-> roll the bottom line to the top // 2-> fill the top line with the pattern in paramb2 // paramb2 = fill colours used when paramb1 == 2 // 128 - flash, 64 - bright, 32 - green paper, 16 - red paper, // 8 - blue paper, 4 - green ink, 2 - red ink, 1 - blue ink rect_att_scroll_d: ld a,(rasud_swap1) cp 0 jr nz,rect_att_scroll_ud ld a,04dh ld (rasud_swap1),a ld a,0e0h ld (rasud_swap2),a ld a,0ffh ld (rasud_swap2+1),a rasd_exec: jp rect_att_scroll_ud
rect_att_scroll_u: ld a,(rasud_swap1) cp 0 jr z,rect_att_scroll_ud xor a ld (rasud_swap1),a ; ld (rasud_swap2+2),a ; add 32, rather than sub 32 ld a,020h ld (rasud_swap2+1),a rasu_exec: jp rect_att_scroll_ud
//paramw1 = c1 / l1 //paramw2 = c2 / l2 // paramb1 = action 0-> leave the last line, // 1-> roll the bottom line to the top // 2-> fill the top line with the pattern in paramb2 // paramb2 = fill colours used when paramb1 == 2 // 128 - flash, 64 - bright, 32 - green paper, 16 - red paper, // 8 - blue paper, 4 - green ink, 2 - red ink, 1 - blue ink rect_att_scroll_ud: ld bc,(paramw1) ld hl,(paramw2) ld a,l ; check for legality of l and l2 cp 18h ; return if illegal ret nc sub c ret c ld d,a ; d = height ld a,h ; check for legality of c1 and c2 cp 20h ; return if illegal coords ret nc sub b ret c ld e,a inc e ; e = width rasud_swap1: ld c,l push de ; find the top (upscroll) ld hl,5800h ; or bottom (downscroll) xor a ; line of rect cp c jr z,rasud_hop1 ld de,20h rasud_nxt1: add hl,de dec c jr nz,rasud_nxt1 rasud_hop1: cp b ; adv to top-left or jr z,rasud_hop2 ; bottom-left corner rasud_nxt2: inc hl djnz rasud_nxt2 rasud_hop2: pop bc push bc ld b,a ; bc = width of rect push hl ; store the line of the ld de,5be0h ldir pop de pop bc cp b jr z,rasud_done rasud_nxtline: push bc ld b,a rasud_swap2: ld hl,0ffe0h add hl,de push hl ldir pop de pop bc djnz rasud_nxtline ; one line at a time rasud_done: push bc ; until the rect is done ld a,(paramb1) ; decide whether to ; ld a,l ; leave,roll or fill cp 1 jr c,rasud_cleanup jr nz,rasud_fill rasud_roll: ld hl,5be0h ; 'roll' by returning the ldir ; stored line and putting it jr rasud_cleanup ; in the appropriate place. rasud_fill: ex de,hl rasud_nxt3: ld (hl),d inc hl dec c jr nz,rasud_nxt3 rasud_cleanup: pop bc ; clean up the printer buffer ld hl,5be0h rasud_nxt4: ld (hl),b dec c inc hl jr nz,rasud_nxt4 ret
// SCROLL all of the screen attributes down. // paramb1 = action 0-> leave the last line, // 1-> roll the bottom line to the top // 2-> fill the top line with the pattern in paramb2 // paramb1 = action 0-> leave the last line, // 1-> roll the bottom line to the top // 2-> fill the top line with the pattern in paramb2 // paramb2 = fill colours used when paramb1 == 2 // 128 - flash, 64 - bright, 32 - green paper, 16 - red paper, // 8 - blue paper, 4 - green ink, 2 - red ink, 1 - blue ink scr_att_scroll_d: ld bc,20h ;move the bottom line ld hl,5affh ;into the print buffer ld de,5bffh push de push hl lddr pop de ;Now move the rest of the attributes down a line ld bc,02E0h lddr ld a,(paramb1) ;leave,roll or fill cp 1 ; decide... ld bc,20h jr c,sasd_cleanup ; paramb1 -> 0 jr nz,sasd_fill ; paramb1 -> 2 sasd_roll: pop hl ; paramb1 -> 1 roll the bottom line up push hl ; to the top lddr jr sasd_cleanup sasd_fill: ld a,(paramb2) ; fill with the pattern in paramb2 sasd_nxt: ld (de),a ; fill the top line with a dec de dec c jr nz,sasd_nxt sasd_cleanup: ld b,20h ;clean up the print buffer xor a pop hl sasd_nxt2: ld (hl),a dec hl djnz sasd_nxt2 ret
// SCROLL all of the screen attributes up. // paramb1 = action 0-> leave the last line, // 1-> roll the bottom line to the top // 2-> fill the top line with the pattern in paramb2 // paramb2 = fill colours used when paramb1 == 2 // 128 - flash, 64 - bright, 32 - green paper, 16 - red paper, // 8 - blue paper, 4 - green ink, 2 - red ink, 1 - blue ink scr_att_scroll_u: ld hl,5800h ;move the top line into the print buffer ld de,5be0h ;into the print buffer push de push hl ld bc,0020h ldir pop de ;Now move the rest of the attributes down a line ld bc,02E0h ldir ld a,(paramb1) ;leave,roll or fill cp 1 ; decide... ld bc,20h jr c,sasu_cleanup ; paramb1 -> 0 jr nz,sasu_fill ; paramb1 -> 2 sasu_roll: pop hl ; paramb1 -> 1 roll the bottom line up push hl ; to the top ldir jr sasu_cleanup sasu_fill: ld a,(paramb2) ; fill with the pattern in paramb2 sasu_nxt: ld (de),a ; fill the top line with a inc e jr nz,sasd_nxt sasu_cleanup: pop hl sasu_nxt2: ld (hl),b ; clean up the print buffer inc l jr nz,sasu_nxt2 ret
// Scroll the pixel data LEFT //paramw1 = top left X, Y //paramw2 = bottom right X, Y //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' pixel pattern. bin 10101010 = pinstripe exxample rect_pix_scroll_l: ld a,(rpcslr_swap1) cp 0 jr z,rect_pix_scroll_lr ld a,00h ld (rpcslr_swap1),a ld a,23h ld (rpcslr_swap2),a ld a,0b0h ld (rpcslr_swap3+1),a jp rect_pix_scroll_lr
// Scroll the pixel data RIGHT //paramw1 = top left X, Y //paramw2 = bottom right X, Y //paramb1 = 0 = leave, 1= roll, 2= fill //paramb2 = 'fill' pixel pattern. bin 10101010 = pinstripe exxample rect_pix_scroll_r: ld a,(rpcslr_swap1) cp 0 jr nz,rect_pix_scroll_lr ld a,44h ld (rpcslr_swap1),a ld a,2bh ld (rpcslr_swap2),a ld a,0b8h ld (rpcslr_swap3+1),a
; SCROLL PIXEL DATA rect_pix_scroll_lr: ld bc,(paramw1) ; c=l1, b=c1 ld hl,(paramw2) ; l=l2, h=c2 ld a,l ; check for illegal cp 18h ; coordinates ret nc sub c ret c ld d,a ld a,h cp 20h ret nc sub b ret c ld e,a ; e=width o f rectangle-1 inc d ; d=no of lines push de ; store them! rpcslr_swap1: ld b,h ; find the address of (l1,c2), the top-right ld a,c ; corner. First find which and 18h ; third of the screen it is in. add a,40h ld h,a ld a,c add a,a ; now which line is it... add a,a add a,a add a,a add a,a add a,b ld l,a ; and finally which column rpcslr_nxtrows: pop bc rpcslr_nxtline: push bc push hl ld d,h ld e,l ld a,(hl) ; store right-most col rpcslr_swap2: dec hl ex af,af' xor a ld b,a ; bc=width-1 cp c ; if width=1 then don't jr z,rpcslr_hop1 ; scroll rpcslr_swap3: lddr ; scroll the line rpcslr_hop1: ld hl,(paramb1) ; decide whether to... ld a,l cp 1 jr c,rpcslr_leavit ; leave it. ld a,h jr nz,rpcslr_fill ; fill, or else... roll. rpcslr_roll: ex af,af' ; right-most col into left-most rpcslr_fill: ld (de),a ; fill with specified pattern rpcslr_leavit: pop hl ; onto the next row of character inc h ld a,h and 7 jr nz,rpcslr_nxtrows ld de,0f820h ; then find the next add hl,de ; line of the rectangle ld a,l cp 20h jr nc,rpcslr_notthrd ld b,7 add hl,bc rpcslr_notthrd: pop bc djnz rpcslr_nxtline ; repeat until last line has been ret ; scrolled, then return.
@Dotneteer I've uploaded a video which demonstrates this happening:-
https://youtu.be/nwCp2LG4-bA
:)
btw... I'm just trying it now.... It might just be happening when the code enters a file other than the main file (Code.z80asm)...
Thanks, I managed to reproduce the issue!
I managed to identify the a bug, unfortunately it is in VS 2019 :-(. I try to find a workaround.
When you said this, I tried a few things.... One workaround seems to be to move the code file to be in a different panel. If the main code window is open, and the STEP INTO takes the cursor to the OTHER open panel, the highlighting seems to work. However, if code and secondary file are in the same panel, but different tabs, then when the STEP INTO flips tab, the highlighting seems to break.
Any time the tab flips, the highlighting breaks more, until it stops working altogether in any file.... :(
Guys, can you test something? Since I upgraded to version16.8 of VS it seems that the highlight of the lines work ok. Can someone else test it to confirm?
I'm not sure it's quite working yet. I just put a breakpoint in the sample code, and hit "debug". As you can see from the screenshot, the execution did pause at 8000, but there's no debug line in the editor....
I re-tested, but with the emulator in the same "pane" in Visual Studio, and I got different results... The breakpoint line was highlighted this time, but it was the wrong line, and stepping through the code didn't move it.