Jump to content





CollectMini source code

Posted by SpiceWare, in Collect 07 December 2015 · 1,210 views

Here's the source code for CollectMini.
 
Attached File  CollectMini.zip (31.37KB)
downloads: 181
 
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.






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?
 

  • Report

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
 
  • Report

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!

  • Report

Great code, I'm learning a lot :)

  • Report

Great code, I'm learning a lot :)


Thanks!
  • Report

Search My Blog

Recent Entries

Recent Comments

Latest Visitors

1 user(s) viewing

0 members, 1 guests, 0 anonymous users