Jump to content

The Southsider

  • entries
  • comments
  • views

Running to Stand Still

Sign in to follow this  


There are some times in programming, particularly on the 2600, that you have to expend a lot of effort to achieve relatively little. The last few days working on the PoP kernel have been like this for me. Having now become convinced of the safety and benefits of the undocumented 6502 instructions, I decided to use them to improve the efficiency of my code. In particular, I wasn't happy with the self-modifying code used in the kernel. Although this code was working fine, it was taking 14 cycles per write, and there were 44 of these writes in the kernel, which adds up to a lot of cycles (616)! Also, these write instructions will only work on the Supercharger and this would make the code difficult to port to other cartridge formats. To remove the self-modifying code, it was necessary to use indirect addressing. I had previously tried this and failed, but this was before using undocumented instructions. I figured that the LAX instruction might help things out, since it allows the X register to be loaded in the indirect mode without costing any cycles. To cut a long story short, after several days of effort I was able to make it work. The result is a very convoluted kernel (always the best kind!) which uses indirect addressing and has no spare cycles in the main loop. This kernel will now work on a regular 2600 without Supercharger, and should be easy to port. However, from an external perspective, the kernel just looks exactly the same on the screen! I therefore made a few cosmetic changes, just to convince myself that I had actually achieved something. I have attached the new version (and code) to this entry. The main changes this time are:

  1. The doors are now drawn using PF graphics (instead of sprites). Although this means that they don't look so good, it will allow multiple doors on the same horizontal line, which I think will be important later. Also, it will simplify the collision detection process.
  2. The player now walks in front of the pillars. I was initially trying to copy the original, but this doesn't look good on the 2600 as the player was showing through the pillar in places.
  3. I have added a colour gradient to the platforms.

post-4913-1105909771_thumb.jpgThe cleanup process is not yet complete. I have removed the self-modifying code from the kernel, but have just replaced it with SLEEP instructions for now. I am not entirely sure what to put in place of this code yet, and I don't want to shrink the size of the platforms. I think the next step is to try and reduce the usage of the precious zero page memory in the kernel, but for now I am going to take a break!Chris

Sign in to follow this  


Recommended Comments

I think it was a good decision to change the kernel, though self-modifying code is pretty cool! :)


Thanks - I like the idea that it could run on a regular Atari, as it still feels a bit like cheating with the extra RAM. I have just posted a new version which contains another improved kernel, and I think this kernel is essentially complete now.



Share this comment

Link to comment
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...