Closed
Description
Here's a simple program to reproduce the issue:
#include <conio.h>
int main(void) {
while(1) {
gotoxy(0,0);
cputs("Hello world!");
}
return 0;
}
The problem is that ppubuf_flush
is trying to write too much to the screen during the vblank period. To fix this, the max amount of buffered data in ppubuf_wait
can be reduced:
--- a/libsrc/nes/ppubuf.s
+++ b/libsrc/nes/ppubuf.s
@@ -32,7 +32,7 @@
.proc ppubuf_wait
- lda #$ff ; (($0100/3)*1)
+ lda #$44 ; (($0100/3)*1)
@wait: cmp ringcount
beq @wait
rts
$45
is the largest number I tried that didn't cause glitches, but that still makes it finish just around the end of vblank. So $44
gives a bit more breathing room.
(I have no idea what ; (($0100/3)*1)
is supposed to mean, but it should probably be updated or removed too.)
Alternatively, you can adjust ppubuf_flush
itself, to limit how many iterations of ringbuf
writes it does. Currently, it does a maximum of $0e * 5 = $46
, which is too many.