Jump to content
  • entries
    650
  • comments
    2,592
  • views
    867,865

CollectMini source code

SpiceWare

1,456 views

Here's the source code for CollectMini.


CollectMini.zip


It's a little different from the source available on my site as I've made some minor changes to the comments.

The presentation was received well; though going over the code, even simple as it is, caused me to run short on time. So I'll need to come up with a new plan of action for next time.

 

COLLECT TUTORIAL NAVIGATION
<PREVIOUS> <INDEX> <NEXT>



5 Comments


Recommended Comments

Good Morning!

 

sta.wx HMP0,X ; 5 19 -

 

 

(.wx)- Is this storing a 16 bit word into an 8 bit register? Is this indexing the accumulator?

Share this comment


Link to comment

If you check the opcode chart you'll see there's 7 different addressing modes for the STA command. Normally we let dasm decide the proper addressing mode and for:

 sta HMP0,x


it would pick Zero Page, X because HMP0 is a zero page address. Of crucial importance for 2600 coding, we know that'll take 4 cycles of processing time.

 

Dasm has a feature known as .FORCE (or Force Extension) which allows you to override the compiler and force a specific addressing mode. The code

 sta.wx HMP0,x


tells dasm to compile the instruction using the Absolute, X addressing mode, which takes 5 cycles of processing time.

 

It was done because the following command:

 sta RESP0,x


needed to finish at exactly cycle 23, but the routine was 1 cycle short on time. There's no version of NOP that takes only 1 cycle, so by forcing a different addressing mode we can make an instruction use an extra cycle.

 

That bit of code could also have been written like this to get the same results:

        sta HMP0,X     ; 4 18 - store fine tuning of X
        sta.wx RESP0,X ; 5 23 - set coarse X position of object
 

Share this comment


Link to comment

Ah... so .wx is forcing a 16 bit address, not a 16 bit word.. And in this case, the page will be zero, your just specifying it to waste time.. Thanks!

Share this comment


Link to comment
Guest
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.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...