3 ms·
C64 Basic: Game Map Overhead “Camera View”
- bonzini 5mo agoThere's a lot that can be improved in the code, such as just using FOR...TO...STEP would be much faster. In general, this is a routine that is super easy to write in 6502 assembly. Most magazine BASIC games had something like that, with a few such routines that were POKEd in memory at startup. Several were written in a relocatable fashion so that they could be copied easily from one game to the next.
- amiga386 5mo agoWhat you really need: http://1amstudios.com/2014/12/07/c64-smooth-scrolling/ http://1amstudios.com/2014/12/07/c64-smooth-scrolling/ https://www.c64-wiki.com/wiki/Scrolling https://www.c64-wiki.com/wiki/Scrolling * The top 4 bits of $D018 (VM10-VM13) control the base of graphics memory * The bottom 3 bits of $D011 (YSCROLL) and $D016 (XSCROLL) let you delay screen display by 0-7 pixels in either axis * The 4th bit of $D011 (RSEL) and $D016 (CSEL) let you shrink the screen viewport so it's visibly 304x192 pixels (in NTSC) even though the screen memory is still 320x200. VM10-13 lets you establish a double-buffer, you can switch instantly between a front and back buffer by changing $D018. While you are scrolling, you copy the front buffer to the back buffer, offset by 8 horizontal pixels (1 byte) or 4 vertical pixels, then add in new map data on the edge you're scrolling towards. On each frame, you update XSCROLL/YSCROLL by one pixel so the visible screen is moving towards your new screen, then once it's moved all 8/4 pixels, switch to the new buffer. The cost of copying all that graphics memory is expensive, so split it across the 8/4 frames.
- bluescrn 5mo agoExperimenting with C64 BASIC taught me a lot back in the day, but it quickly became clear that for any real game dev you need to be using assembly. But a few years later, the Amiga brought us DPaint and Blitz Basic, and suddenly it was very possible to make a pretty competent game in BASIC as a self-taught teenager with no Internet access. That’s probably a better choice for anyone wanting to experiment with retro game dev using the tools of the period without resorting to assembly language
- dspillett 5mo agoThat depends on what you mean by “real game dev”. I did a few game things of my own in BBC BASIC, eventually with a bit of 6502 assembly in key places, back in the day. On those machines you can still happily run a basic game loop in interpreted BASIC, the whole thing for text-based games, you just need to get down to the bare CPU for things like sprites, other rapid graphics drawing, and maybe some other number crunching (I did some basic compression in assembly for lots of text, though it wasn't really effective, if you are already doing graphics in assembly, then it probably makes sense to do collision detection and such there too, etc.).
- egypturnash 5mo agoC64 BASIC is kind of a mess, there's zero support for graphics and sound. Your code rapidly becomes a giant pile of POKEs and PEEKs, and all your operations become absurdly slow because all the math routines are floating point only, so there's a ton of integer/fp conversion overhead on something as simple as "peek a memory location, AND/OR it with a few values taken from variables stored as floating point, poke it back". Assembly becomes really attractive really quickly.
- Woansdei 5mo agoC64 Basic did have integers. A floating point A$ string A% int as you would expect ints are quicker.
- izacus 5mo agoErr, ints are internally stored as floats as well and that leads to some really interesting performance quirks where you'd not expect. There were BASIC compilers for C64 which generated significantly faster code just because they actually used ints for integer operations.
- RiverCrochet 5mo agoNot on C64 BASIC. C64 BASIC converted ints to floats internally and converted them back to ints when needed. What sidestepped part of that conversion was using variables instead of literal constants. So, doing something like N0=0, and using the variable N0 instead of 0 was faster. Additionally, C64 looked up variables in the order they were defined, so variables defined later were slower. If your program used 0 a lot, you'd want to have N0=0 as the first statement in your program. I typically had N0=0 and N1=1 as those were common to use. QBasic was so much faster and implemented differently. DEFINT A-Z at the top of the program typically sped it up significantly if you didn't use floating point. This might have worked on GW-BASIC as well.
- pugworthy 5mo agoMan does this bring back memories of my old Atari 800 and entering or writing games in BASIC for it. Something extremely nostalgic about that kind of development for some of us.