Re: [cc65-devel] c64 - getting seemingly random chars on screen
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Michael P. <mp...@bl...> - 2021-03-03 19:15:22
|
On Wed, 3 Mar 2021, gr...@gm... wrote: > Am Mittwoch, 3. März 2021, 17:59:35 CET schrieb Michael Parson: >> OK, put together a stripped down version. No score keeping, no stdio.h >> calls, no filesystem access, just the basic gameplay. All screen >> manipulation should be going through conio. Since this is a C-64 >> test, I even removed the asm bits and used a POKE to kick back into >> uppercase/PETSCII mode. I'd still prefer a cross-platform 'safe' way to >> do that. >> >> https://github.com/mparson/gridgame/blob/main/c64/minimal.c >> >> Still getting the same behavior. >> >> For grins, I compiled it for C-128, also got the errant chars. > > it happens in the inner loop > > gotoxy (mx,my); > c = cpeekc (); > textcolor (COLOR_RED); > cputcxy (c,mx,my); // BUG, should be mx,my,c > textcolor (COLOR_WHITE); > > :) And that sound you just heard was my head banging on my keyboard. I guess the next question is... why doesn't the X-16 behave the same way? > here is what i did: > > first compile and generate a VICE label file: > > cl65 -Ln minimal.lbl -o minimal.prg minimal.c > > start in VICE: > > x64sc -autostartprgmode 1 -moncommands minimal.lbl minimal.prg > > break into the monitor (alt-h) > > use "sc" to find out where the screen under the playfield starts > > watch 06d0 07e7 > > x to go on > > now press fire, it will break when the bug happens > > chis to show the cpu history > > now you can see its in cputc, and scrolling up a bit reveals that it comes > after a "textcolor(2)", which is that textcolor (COLOR_RED) in the main loop > > now i replaced the cputcxy call by gotoxy/cputc ... and that worked. obviously > the cputcxy must be going wrong. Looked again, AHA! argument order :) Thank you very much for digging into this! Also, thanks for additional info on how to debug. I've used gdb on *nix hosts to debug C, but most of what I know about poking around in ML monitors I've learned from watching various 8-bit Youtubers. I figured it was in that loop, since that was where I saw it happening, but I didn't know enough about how to examine what was going on with the monitor to pin it down. > so there :) (i almost hoped for another compiler bug being triggered, but no - > its just an ordinary bug in this code :)) As far as compiler/language bugs go, is what I'm seeing with 'cscanf()' expected behavior? #include <conio.h> int main() { unsigned char name[16]; clrscr (); cprintf ("what is your name? "); cscanf ("%s", &name); cprintf ("hello, %s\n", name); return 0; } Start typing something at the prompt, hit backspace and it treats it like a return instead? -- Michael Parson Pflugerville, TX |