Jump to content
IGNORED

How do you keep in sync?


Recommended Posts

Note: If you're testing with Stella you'll have to "plug in paddles" as it defaults to Joysticks.

 

Press TAB on your keyboard to access the in-game menu

post-3056-0-84563600-1388506589_thumb.png

 

Click the Game Properties button

post-3056-0-52167200-1388506594_thumb.png

 

Click the Controller tab

post-3056-0-78934700-1388506599_thumb.png

 

Change controllers to Paddles.

post-3056-0-35877100-1388506604_thumb.png

 

Stella remembers the settings for each ROM (it uses the MD5 hash, which you can see in the 2nd screenshot, as the lookup value for the settings), so if you run the exact same ROM again it'll already be set for paddles. If you make changes and recompile the MD5 value will change, so you'll have to "plug in paddles" again.

  • Like 1
Link to comment
Share on other sites

There's a cycle count chart? May I have a link? I had no idea that such a thing existed.

When writing a kernel it's typical (for me anyway) to put a comment on each line with the cycle count of the instruction, so you can keep track of where you are in the line. It may also be useful to write the total cycle count for the line every few lines of code, especially where you store to TIA registers. This link shows the cycle counts for each instruciton:

 

http://www.masswerk.at/6502/6502_instruction_set.html

 

It takes some time to used to telling how many cycles a particular instruction takes with all the different addressing modes and exceptions (like crossing a page boundary), especially for a beginner. But if you stick with it, you may not even have to look at the chart anymore.

 

Something important to consider is that when you hit WSYNC in your kernel (ie STA WSYNC), the 3 cycles from the STA (zeropage) count for the previous line, and the processor is halted until the beginning of the next line, cycle 0. As you probably know, you have 76 cycles per line to draw the screen.

 

I've added cycle counts to the first few lines of your kernel for your reference.

 

                ; ...

ScanLoop
		STA WSYNC               ;3
		LDA PlayerBuffer        ;3
		STA GRP0                ;3
		LDA EnemyBuffer         ;3
		STA GRP1                ;3
CheckActivatePlayer
		CPY BottomDelay         ;2
		BNE SkipActivatePlayer  ;2  **
		LDA #12                 ;2
		STA PlayerLine          ;3

SkipActivatePlayer
		LDA #0                  ;2

                ; ...

BNE and all branching instructions are one example where you will need to add a cycle if a page boundary is crossed. A page is just a name for a 256 byte chunk of address space. So for the 2600, the upper byte of the address is the page number. Below is an example where the bne would actually take 3 cycles. I've put addresses in the left column.

 

13fc         ldy #5
13fe    loop:
13fe         sta WSYNC
1400         dey
1401         bne loop

Since the label loop is in page 13 of memory, and the bne instruction is in page 14, a page boundary was crossed. Thus the processor must take an extra cycle to properly alter the program counter register. If the same code were executed in a slightly different address range as below, bne will only take 2 cycles.

 

1400         ldy #5
1402    loop:
1402         sta WSYNC
1404         dey
1405         bne loop

As you can see, the loop label and BNE instruction are both in page 14. To avoid page boundary crosses in a kernel, one might put the kernel in it's own page of memory, and jump or jsr to it in the program. You can do this various ways, with an org $xxxx statement for example.

 

Something unrelated you may or may not know about branch instructions is that you can only branch to a label that is +/- 128 bytes away from the instruction.

 

I haven't given your code a serious look, so I can't tell you for sure what's the matter with it. But anyway, hope this helps you understand cycle counts a bit more.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...