Jump to content
IGNORED

PF scrolling but I am not sure why.


arkleyjoe

Recommended Posts

Hi

 

This is a bit of a strange question. I am attempting to make a vertical scrolling play field and I have managed to get something very similar to what I need but I am not 100% sure how I have done it. :)

 

In my code below I can not work out why the play field is scrolling. I would expect it to be static, the same in every frame based on my current understanding.

 

Can anyone tell me why this is rolling and point me in the direction as to how I may control the speed of this scrolling.

 

Maybe I have miss understood the cycle count and so I am on multiple scan lines? I do see a little glitch in the debugger.

 

Here is my sample code:


	processor 6502
	include "vcs.h"
	include "macro.h"
	
PATTERN1 = #%00110000
PATTERN2 = #%01111000

StartCount = 0
CURRPF = 1

	SEG
	ORG $F000

Reset

	ldx #0
	lda #0

Clear

	sta 0,x
	inx
	bne Clear

;one time set up
	lda CURRPF ;set up the PF to mirror
	sta CTRLPF ;set up the PF to mirror
	ldy StartCount ; set to 0
	lda PATTERN1 ;load part one of the patern.
	sta PF0 ;load part one of the patern.
	lda #$55 ;set the colour
	sta COLUPF ; set the colour

		
StartOfFrame
	
	lda #0		;2
	sta VBLANK 	;3
	lda #2		;2
	sta VSYNC	;3

	sta WSYNC	;3
	sta WSYNC	;3
	sta WSYNC	;3
	ldx #0		;2
	
VerticalBlank

	sta WSYNC	;3
	inx		;2
	cpx #37		;3
	bne VerticalBlank ;3
	
Picture

	sta WSYNC		;3 3
	cpy #20			;3 8 
	bcc ShowPathern2	;2 10
	lda PATTERN1		;3 13
	sta PF0			;3 16
	cpy #40			;3 19
	beq ResetPFDraw		;2 21
	iny
	inx			;2 23
	cpx #192		;2 25
	bne Picture		;2 26
	sta VBLANK 		;3 29
	ldx #0			;2 31
	ldy #0			;2 33

	
ShowPathern2
	iny
	lda PATTERN2		;3 3 
	sta PF0			;3 6
	inx			;3 9
	cpx #192		;2 11
	bne Picture		;2 13 
	sta VBLANK 		;3
	ldx #0			;2
	ldy #0			;2

ResetPFDraw
	ldy StartCount		;3 3
	inx			;2 5
	nop			;2 7
	cpx #192		;2 9
	bne Picture		;2 12
	sta VBLANK 		;3
	ldx #0			;2
	ldy #0			;2

Overscan
	sta WSYNC
	inx
	cpx #30
	bne Overscan
	jmp StartOfFrame
	
	ORG $FFFA
	
InterruptVectors

	.word Reset
	.word Reset
	.word Reset
	
END 

I have attached the bin file also.

pftest.asm.bin

Link to comment
Share on other sites

It's better to attach your source file rather than post it like that.

You definitely have a problem - do the following:

  • Load your ROM into Stella
  • hit ` (left of 1, above TAB) to enter the debugger
  • scroll to StartOfFrame (F017) and click just to the left of it, this sets the breakpoint which is denoted by the red dot (see photo below)
  • hit ` again to exit the debugger

if your code gets to F017 then Stella will automatically go back into the debugger. It doesn't. To figure out why you'll need to single step through your code in the debugger - to single step hit the Step button in the top-right corner. To help you narrow it down, set a breakpoint at ShowPathern2 (F048) and start your single stepping from there.

I also notice another problem - look at your source for the one time set up and compare it with what you see in Stella's disassembly - specifically lda PATTERN1. The # for immediate mode instruction belongs with the LDA/LDX/LDY instruction, not with the constant defined at the top.

PATTERN1 = %00110000
...
lda #PATTERN1 ;load part one of the patern.#



post-3056-0-98043800-1514575518_thumb.png
Link to comment
Share on other sites

Hey, thank you for coming back so quickly. Hugely appreciated.

 

Ok that was REALLY helpful. Using that technique, I realised that I was falling through my subroutines rather than jumping strait to Overscan once I had reached the 192 lines. This meant that I was adding a few additional scan lines. Thanks for pointing me in the right direction and thanks for the additional hint on the way I was attempting to address the play field pattern values. That has cleared up something else that was confusing me.

 

Now I have it stable I would like to understand how to make it scroll again in a controlled way.

 

If you could help me understand how to approach the scrolling I would really appreciate it.

 

I have attached the fixed pftest.asm

 

Many thanks

 

Joe

 

 

 

pftest.asm

Link to comment
Share on other sites

Hi I now have a piece of code that is scrolling as I want. (attached)

 

My approach to getting the scrolling is to have a counter that increments / decrements each frame and I use that o push the PF along. Could anyone let me know if this is the right basic approach?

 

I appreciate the code is a mess right now, I just want to know I have the basic concept in place before I continue.

 

Your input is greatly appreciated.

 

 

 

 

 

 

pftest.asm

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