Jump to content

Photo

PF scrolling but I am not sure why.

playfield

6 replies to this topic

#1 arkleyjoe OFFLINE  

arkleyjoe

    Combat Commando

  • 7 posts

Posted Fri Dec 29, 2017 12:06 PM

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.

Attached Files



#2 SpiceWare ONLINE  

SpiceWare

    Draconian

  • 11,800 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Fri Dec 29, 2017 1:34 PM

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

 
Screen Shot 2017-12-29 at 1.17.25 PM.png



#3 arkleyjoe OFFLINE  

arkleyjoe

    Combat Commando

  • Topic Starter
  • 7 posts

Posted Fri Dec 29, 2017 2:30 PM

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

 

 

 

Attached Files



#4 arkleyjoe OFFLINE  

arkleyjoe

    Combat Commando

  • Topic Starter
  • 7 posts

Posted Wed Jan 3, 2018 4:21 PM

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.

 

 

 

 

 

 

Attached Files



#5 arkleyjoe OFFLINE  

arkleyjoe

    Combat Commando

  • Topic Starter
  • 7 posts

Posted Wed Jan 3, 2018 4:26 PM

BTW to add further I am really referring to the lines of code around line 86 of the ASM file.



#6 SpiceWare ONLINE  

SpiceWare

    Draconian

  • 11,800 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Wed Jan 3, 2018 4:29 PM

Great!  
 
I've not attempted a vertically scrolling game before, so I'm not sure of the best way to approach it.  One thing that may be useful is head over to MiniDig and check out the source code for River Raid.



#7 arkleyjoe OFFLINE  

arkleyjoe

    Combat Commando

  • Topic Starter
  • 7 posts

Posted Thu Jan 4, 2018 10:29 AM

Ahh good call I will take a look. 







Also tagged with one or more of these keywords: playfield

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users