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: <sje...@sh...> - 2021-03-04 03:06:29
|
Hi Bill, Calling any C library functions in interrupts is likely not going to work out well, at least that used to be the case with cc65. You pretty much have to write these in assembly, or be very very careful about what C code you use and probably look at what it's doing, and whether or not your interrupt is going to stomp all over other things. -----Original Message----- From: Bill Kendrick <nb...@so...> Sent: March 3, 2021 1:56 PM To: cc65 Development <cc6...@li...> Subject: Re: [cc65-devel] c64 - getting seemingly random chars on screen To wrap up my interruption into this thread... I _believe_ I cleared up my option by making sure to use inline assembly (rather than C, where cc65 was doing a lot of jsr's to subroutines for doing math and comparisons) for a simple Vertical Blank Interrupt I wrote. I haven't seen any glitches (though it was nearly 2am, so I didn't do extensive gameplay testing.) It's only like a dozen lines of 6502 assembly, but it was quite a thrill to actually write some. Hard to get to sleep. I'm finally catching up with skills I should've had 30 years ago ;) I was spoiled by Action!, I guess, which compiled the same kind of code to much simpler machine language. -bill! On Tue, Mar 02, 2021 at 12:29:42PM -0800, Bill Kendrick wrote: > > Y'know, I had a similar problem with my cc65 port of my game "Gem > Drop" (originally written in Action! back in 1997, so it was > relatively easy to port to C). I never figured out what was up with > it. :-/ > > http://www.newbreedsoftware.com/gemdrop_deluxe/ > > And similarly, since the screen data basically _defines_ the game > board, any corruption there breaks the game. :-( > > -bill! > > On Tue, Mar 02, 2021 at 02:06:32PM -0600, Michael Parson wrote: > > I'm pretty new to C programming in general, but cc65 and being able > > to target the C-64 and Commander X-16 piqued my interest and gave me > > the motivation to actually jump into it. > > > > First few small projects went fine, but then I decided to write a > > C-64/X-16 version of an old Flash game I wasted a lot of time > > playing, "Grid Game". > > > > https://github.com/mparson/gridgame > > > > The X-16 version has been fine, the problems come in when I try to > > build it for the C-64. A few #ifdefs for system specific things, > > but most of the code is the same. > > > > On the C-64, when you hit the joystick button to start a move, I get > > a random (red) character printed to the screen. My first thought > > was that maybe I was bumping into screen ram somehow, so I #ifdef'ed > > out a bunch of stuff to make the C-64 version have fewer features, > > wrote a joystick interface instead of the mouse like the X-16 > > version uses (haven't actually verified that this generates smaller > > code yet, maybe I should), etc, but I'm still getting the random letters. > > > > Using Vice, I set up a few break points, tracked it down to just a > > few lines after the button is clicked: > > > > #1 (Stop on exec 094c) 296 034 > > .C:094c 20 2A 15 JSR ._processQ - A:86 X:2D Y:00 SP:f4 N.-..... 219124114 > > ^^^ no garbage chars yet > > > > (C:$094c) n > > .C:094f 4C 5F 09 JMP $095F - A:00 X:11 Y:02 SP:f4 N.-..... 219185007 > > ^^^ garbage appears, in this case, a red 'P' at col 26, row 16 > > (C:$094f) .C:095f AD 09 2C LDA ._global_editmode - A:00 X:11 > > Y:02 SP:f4 N.-..... 219185010 > > > > Digging around in memory with the Vice monitor, it looks like I > > should have plenty and don't see any reason for some random byte of > > screen RAM to be changed. > > > > The game seems to otherwise run fine, as long as the random char > > doesn't wind up on the playboard, messing up the matching. A board > > reset fixes it, until the next time one appears... > > > > I'm at a loss here, would appreciate any pointers. > > > > Thanks. > > > > -- > > Michael Parson > > Pflugerville, TX > > > > > > _______________________________________________________ > > cc6...@li... > > https://lists.sourceforge.net/lists/listinfo/cc65-devel > > > > -- > -bill! > Sent from my computer -- -bill! Sent from my computer _______________________________________________________ cc6...@li... https://lists.sourceforge.net/lists/listinfo/cc65-devel |