Jump to content
IGNORED

Losing a scanline when using the controls


Kiwi

Recommended Posts

I got inspired and started working on a new kernel on 8bitworkshop. The main one thing that I'm having trouble with is when you use the controls like press up for example, you lose a scan line. I had the same problem with RockCutter where I lose scanline when using the controls. I did test every lines I could in Rockcutter until it hit the overscan. I'm not sure if Carry supposed to affect the Overscan timer or not. But, I need help finding a solution to the problem so the scanline count can stay at 262.

Thanks.

Gif:

post-24767-0-86309100-1520524890.gif

Source: ShipTestGame.asm

ROM: TestShipGame.bin

  • Like 1
Link to comment
Share on other sites

I looked at the code you provided and played with the bin and stella debugger. Since you're using the timer for all 3 portions that seems to rule out any possibility of variable length code putting you over/under by a scanline.

 

I suspect the problem is in the TIMER_WAIT macro. My guess is that it needs to do a "sta WSYNC" between each poll of the timer to compensate for the course resolution of the timer register that's being checked.

  • Like 1
Link to comment
Share on other sites

Always use a STA WSYNC after the two timer loops, I use 43 in both STA TIM64T.

 

And do all your housekeeping (handling controls, enemy movement, etc) just before the timer loops, this way the timer only counts the remaining "free" time. It's easy to overlook things and exceed some cycles and then all your WSYNC goes nuts.

  • Like 1
Link to comment
Share on other sites

I added sta WSYNC right after TIMER_SETUP

and added sta WSYNC after MoveUD after it store the variable into ShipY. It's now a stable 262 scanlines.

	TIMER_SETUP 30
	sta WSYNC
	lda #3
	sta VBLANK

	ldy cd
        bne DontMove

	;Move Up
	sta WSYNC 
        ldx ShipY
	lda #%00100000 ;Up?
        bit SWCHA
        bne SkipMoveUp
        cpx #9
        beq SkipMoveUp        
        inx
        ldy #7
	sty cd
;	JMP MoveUD
SkipMoveUp
	lda #%00010000;Down?
        bit SWCHA
        bne SkipMoveDown
        cpx #0
	beq SkipMoveDown
        dex
        ldy #7
	sty cd
SkipMoveDown
	stx ShipY
        jmp MoveUD
DontMove
	dey
	sty cd
MoveUD
	;Move left or right
	ldx ShipX
	sta WSYNC	
	lda #%01000000 ;left?
	bit SWCHA
	bne SkipMoveLeft
	cpx #1
	bcc SkipMoveLeft
        dex
SkipMoveLeft
	lda #%10000000 ;Right?
        bit SWCHA
        bne SkipMoveRight
        cpx #153
        bcs SkipMoveRight
        inx
SkipMoveRight
;	clc
	stx ShipX
;	check firebutton to fire lazer

	lda ShotOn
	cmp #0
	bne SkipButton
	bit INPT4	; test button 
        bpl StartShooting
	jmp SkipButton
StartShooting
	lda #1
	sta ShotOn
        lda ShipY
	sta ShotY
	lda ShipX  
	sta ShotX
SkipButton
In overscan portion I'll have to use WSYNC every 76 cycle. 8bitworkshop have a feature that calculates how much cycles is used between WSYNC by clicking on the clock icon so that will help me determine where to put WSYNC at.

 

Thanks everyone.

  • Like 1
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...