In this picture we can see a normal execution. Lines are drawn during nmi. [Linked Image]

In this one all lines are correctly drawn.[Linked Image].

The only difference is that the second one is drawn using the debugger by pressing F11 after every instructions. I'm maybe wrong, but i'm thinking of a wrong timing in normal run.

Code
	; Header d'une cartouche Pencil II
	org $8000
	; COPYRIGHT SOUNDIC
	defb "COPYRIGHT SOUNDIC"	; 8000 - 8010
	; 8011 - 8034
	;
	; 8011 - START
	; 8014 - NMI
	; 8029 - INT
	; Point d'entrée du lancement du programme sur la cartouche
	jp start			; 8011 - 8013

	;defs 32,0
        ; NMI
        jp inthandler           	; 8014 - 8016
	;defs 10,0
	defs 6,0
	; RST 18
	ret
	nop
	defs 13,0
	;jp inthandler			; 8029 - 802B
	reti
	nop
        ;defs 32,0
        defs 27,0 

	; VERSION!TITRE!DATE (C)
	defb "BETA!** VDP TESTS **!2019"
	defs 10,0


; VARIABLES

dataVDP:	EQU $BE ; VDP Data port
cmdVDP:		EQU $BF ; VDP Command port
ramtop:         equ $7050
        include "tms.asm"

inthandler:
        in      a, (tmsreg)             ; clear interrupt flag
        call    rasters 
        ei
        reti
        
rasters:
	; Register 7 = $2 => 0000 0010 (BGC)
	ld c, $02
lp_b:
	ld a, c
	out ($bf), a
	ld a, $87
	out ($bf), a

        inc c
        ld a, $15
lp_a:
	dec a
	jp nz, lp_a
	nop
	nop
	add a, 1
	add a, 1
	add a, 1
	ld a, c
	sub a, $50
	jp nz, lp_b

	xor a, a
	out ($bf), a
	ld a, $87
	out ($bf), a

	ret


start:
	ld	($7000),sp			; save old stack poitner
        ld      sp, ramtop                      ; set up stack

	call    tmsbitmap
        call	$505 ; TURN_OFF_SOUND
	call	tmsintenable

mainLoop:
	jr mainLoop



Code is compiled with z80asm on Linux.

What do you think about ?