EvilSandwich wrote:
Much of the issues you're seeing for the lack of definitions is due to the limits of the javascript assembler I'm using.
...
I'm testing the code here, due to its dirt simple memory map.
http://skilldrick.github.io/easy6502/Right. Well, that's a perfectly reasonable place to start out and play a bit, but I think once your code grows to a few dozen instructions you may find it a bit awkward. (I guess it depends in part on whether or not you're a software engineer; for me Git and unit test frameworks are not something to be learned but an essential tool to reduce effort for even the tiniest projects.) I threw together a small unit test system for 6502 code (unit tests written in Python and code run in the py65 emulator) in my
8bitdev repo, if that helps with any ideas. (The current audience for that code is experienced developers who know and can program in Python, however; it's got a ways to go before some productization can be done.)
An easy place to start would be to put together a script that assembles your code, generates a binary file, and then starts an emulator on it.
VICE has a command line option that lets you just aim it at a binary file and it comes up running, which is pretty convenient. And the C64 is a pretty reasonable platform on which to play with this stuff: you can use the text screen as a very basic 40x24 "graphics" display, just writing the chars into screen RAM (and colours into color RAM if you like), more or less as you do now, and expand to doing bitmap graphics later. (Or even use the C64's sprites, if you like.) If you want a simpler machine, the VIC-20 or a PET are also options.
Quote:
And clearing the X register seems pointless in hindsight.
Ok. That particularly stood out to me because in a routine I was working on recently, I had `LDX #0` at the beginning for use as a constant value in various places throughout the routine (loading zero into A, storing 0 in memory locations, as the zero-offset for some indirect address references), so it's not like what you did never makes sense.
Quote:
Okay, instead of the delay being a fixed number, I set it to a value in zero page address $03.
So the more typical way of handling acceleration is to use a fixed delay and give each object a velocity. Games generally target a 60 Hz, 50 Hz or 30 Hz frame rate, and update each object on the screen once every 16.67, 20.00 or 33.33 ms. This typically requires you to keep the position with higher resolution than the screen so that four frame of an object moving at 0.7 pixels/frame turns into on-screen moves of [1, 0, 1, 1] (3 pixels over four frames) rather than 1 pixel per frame, which would make it move as fast as something with a velocity of 1.2 pixels/frame.
So you might want to start even now working on the basics of the typical game framework loop:
- Add new objects and remove dead objects from the list.
- Passes through the list updating any characteristics that need to be changed, e.g. a gravity pass that updates the velocity of any objects that are affected by gravity. Typically there are lots of separate little passes that each do a specific thing, operating only on the relevant objects. E.g., if the colours of players change based on health points remaining, there'd be a separate routine to do those updates.
- Wait until display of the previous frame has completed.
- The drawing pass which, for any object with a velocity > 0, removes the old image, updates the location, and draws the new image.
- Collision detection pass to see what's crashed into what, or should be bouncing off, or whatever. This might be before the drawing pass, depending.