Jump to content
IGNORED

Ok, Apparently I'm a bit rusty... Need help with scrolling issue please. :P


Recommended Posts

Hello all!

 

So I'm working on a vertical scroller, where the scrolling is constant, and not controlled by the player.

 

I'm using the same scrolling engine that I used for ReZolve, which worked well at 16 scanlines per zone.

However, this game is 8 scanlines per zone, and I'm getting corruption of the bottom zone (same reason why the bottom zone in PMC 40th doesn't bother with adapting the zone size).

 

I think I'm running out of CPU time somewhere, but I'm not even taking into account background color yet (which I need to do eventually).  The DLIs just change the origin of the Character Base address to match the size of the zone.

 

Here are the zone definitions:

;	THIS IS THE DISPLAY LIST LIST FOR THE VIDEO GAME PORTION.  THIS WILL BE DROPPED INTO RAM.
DLLISTPAL
	.byte $0F,>(NULDLST),<(NULDLST)				;25 ADDITIONAL BLANK LINES FOR PAL
	.byte $08,>(NULDLST),<(NULDLST)
DLLISTNTSC
	.byte $09,>(NULDLST),<(NULDLST)				;10 BLANK LINES
	.byte $05,>(NULDLST),<(NULDLST)				;6 BLANK LINES			NTSC/PAL

	.byte $47,>(DLIST00),<(DLIST00)				;PF ZONE 00 - 8 LINES	$06/$0C SCORE LINE
	.byte $01,>(NULDLST),<(NULDLST)				;2 BLANK LINES			$09/$0F SEPARATOR
	.byte $40,>(DLIST01),<(DLIST01)				;PF ZONE 01 - 1 LINE	$0C/$12 (FOR SCROLLING)
	.byte $47,>(DLIST02),<(DLIST02)				;PF ZONE 02 - 8 LINES	$0F/$15
	.byte $47,>(DLIST03),<(DLIST03)				;PF ZONE 03 - 8 LINES	$12/$18
	.byte $47,>(DLIST04),<(DLIST04)				;PF ZONE 04 - 8 LINES	$15/$1B
	.byte $47,>(DLIST05),<(DLIST05)				;PF ZONE 05 - 8 LINES	$18/$1E
	.byte $47,>(DLIST06),<(DLIST06)				;PF ZONE 06 - 8 LINES	$1B/$21
	.byte $47,>(DLIST07),<(DLIST07)				;PF ZONE 07 - 8 LINES	$1E/$24
	.byte $47,>(DLIST08),<(DLIST08)				;PF ZONE 08 - 8 LINES	$21/$27
	.byte $47,>(DLIST09),<(DLIST09)				;PF ZONE 09 - 8 LINES	$24/$2A
	.byte $47,>(DLIST10),<(DLIST10)				;PF ZONE 10 - 8 LINES	$27/$2D
	.byte $47,>(DLIST11),<(DLIST11)				;PF ZONE 11 - 8 LINES	$2A/$30
	.byte $47,>(DLIST12),<(DLIST12)				;PF ZONE 12 - 8 LINES	$2D/$33
	.byte $47,>(DLIST13),<(DLIST13)				;PF ZONE 13 - 8 LINES	$30/$36
	.byte $47,>(DLIST14),<(DLIST14)				;PF ZONE 14 - 8 LINES	$33/$39
	.byte $47,>(DLIST15),<(DLIST15)				;PF ZONE 15 - 8 LINES	$36/$3C
	.byte $47,>(DLIST16),<(DLIST16)				;PF ZONE 16 - 8 LINES	$39/$3F
	.byte $47,>(DLIST17),<(DLIST17)				;PF ZONE 17 - 8 LINES	$3C/$42
	.byte $47,>(DLIST18),<(DLIST18)				;PF ZONE 18 - 8 LINES	$3F/$45
	.byte $47,>(DLIST19),<(DLIST19)				;PF ZONE 19 - 8 LINES	$42/$48
	.byte $47,>(DLIST20),<(DLIST20)				;PF ZONE 20 - 8 LINES	$45/$4B
	.byte $47,>(DLIST21),<(DLIST21)				;PF ZONE 21 - 8 LINES	$48/$4E
	.byte $47,>(DLIST22),<(DLIST22)				;PF ZONE 22 - 8 LINES	$4B/$51
	.byte $47,>(DLIST23),<(DLIST23)				;PF ZONE 23 - 8 LINES	$4E/$54
	.byte $47,>(DLIST24),<(DLIST24)				;PF ZONE 24 - 8 LINES	$51/$57
	.byte $47,>(DLIST25),<(DLIST25)				;PF ZONE 25 - 8 LINES	$54/$5A
	.byte $C7,>(DLIST26),<(DLIST26)				;PF ZONE 26 - 8 LINES	$57/$5D (FOR SCROLLING) (INTERRUPT)

	.byte $09,>(NULDLST),<(NULDLST)				;10 BLANK LINES
	.byte $85,>(NULDLST),<(NULDLST)				;6 BLANK LINES (INTERRUPT)
DLLENDNTSC
	.byte $0F,>(NULDLST),<(NULDLST)				;25 ADDITIONAL BLANK LINES FOR PAL
	.byte $08,>(NULDLST),<(NULDLST)
DLLENDPAL

 

 

Here is the DLI routine:

;	KERNAL - MAINTAIN THE ON-SCREEN DISPLAY
DLI
	PHA											;STACK REGISTERS
	CLD
	LDA DLIFLG
	BMI DLITOP
	JMP DLIBOT
DLITOP
	LDA MODCHBASE								;ONLY SHOW THE CORRECT NUMBER OF SCANLINES IN THE BOTTOM ZONE
	STA CHRBASE									;INSTALL THE DIFFERENCE IN THE ZONE HEIGHT
	INC DLIFLG
	PLA
	RTI
DLIBOT
	LDA #>(GAMEFONT)
	STA CHRBASE									;INSTALL THE CHARACTERS BACK TO NORMAL
	LDA #$FF
	STA DLIFLG									;RESET DLI FLAG TO GO BACK TO THE TOP
	INC RTLOCAL+1								;INCREMENT CLOCK
	BNE DLIBOTROUTINES
	INC RTLOCAL
DLIBOTROUTINES
	TXA
	PHA
	TYA
	PHA
	JSR LOADER									;LOAD UP NEXT FRAME
	JSR TUNER									;DO TUNES
	JSR RAND									;UPDATE RANDOM NUMBER
	PLA											;UNSTACK AND LEAVE
	TAY
	PLA
	TAX
	PLA											;THIS IS WHERE MOST DLI'S LEAVE
NULLRTI
	RTI

 

Here is the scroll routine - PLEASE NOTE - I'm not even moving the screen addresses down once the 8 scanline limit is reached yet...  Just trying to do this one step at a time...

;	SCROLLSCRN - DOES THE ACTUAL UPDATING OF THE DL TO SCROLL THE SCREEN
;	INPUT: LEVEL (0-5), 6 FOR TITLE SCREEN, 7 FOR 'GAME OVER' SCREEN
;	OUTPUT: NONE
;	USES: A, X, Y, LDRTEMP2, LDRTEMP3, LDRTEMP4, LDRTEMP5
SCROLLSCRN
	LDA NOSCROLL
	BNE SSSTART								;THIS IS FOR TITLE SCREENS AND ANIMATION SCREENS
	LDA RTLOCAL+1;;;;;;;;;;;;;;;;;;;;;;;
	AND #$0F	;;;;;;;;;;;;;;;;;;;;;;;;  I'M DOING THIS TO SLOW DOWN THE SCROLL SO I CAN WATCH WHAT'S HAPPENING...
	BNE SSSTART;;;;;;;;;;;;;;;;;;;;;;;;;
	INC WINDOWOFFSET
SSSTART
	LDA WINDOWOFFSET
	CMP #$08
	BNE SSUPDATEZONES
	LDA #$00
	STA WINDOWOFFSET
	JMP SSUPDATEZONES;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SSMOVEZONES

	;THIS IS WHERE THE SCREEN ADDRESSES FOR EACH ZONE WILL GET MOVED (AND THE 'JMP' ABOVE WILL GET REMOVED)

SSUPDATEZONES
	LDY TVTYPE									;GET THE INDEX INTO THE DL BY TV TYPE
	LDA TOPDL,Y
	TAX											;X = DL INDEX OF TOP OF WINDOW ZONE SIZE
	LDA DLL,X
	AND #$F8
	ORA WINDOWOFFSET
	STA DLL,X
	SEC											;COMPUTE BOTTOM DIFFERENCE ZONE SIZE FOR WINDOW
	LDA #$07
	SBC WINDOWOFFSET
	STA LDRTEMP0
	CLC
	LDA BOTDL,Y
	TAX											;X = DL INDEX OF BOTTOM OF WINDOW ZONE SIZE
	LDA DLL,X
	AND #$F8
	ORA LDRTEMP0
	STA DLL,X

	LDA #>(GAMEFONT)							;'MODCHBASE' GETS USED IN THE DLI (TOP WINDOW)
	CLC											; IT TELLS WHAT PAGE TO START THE CHARACTER GRAPHIC
	ADC WINDOWOFFSET							; DEFINITIONS SO WE MAKE SURE WE ONLY SHOW THE CORRECT
	STA MODCHBASE								; PORTION
	
	RTS

;	THE DISPLAY LISTS TO USE WHEN SCROLLING (FIRST BYTE = NTSC, SECOND = PAL)
TOPDL
	.BYTE $0C,$12
BOTDL
	.BYTE $57,$5D

 

So this is what I'm seeing at the bottom...

image.thumb.png.348dfc5fccc4e3ed6746ed97740baad9.png

Those are supposed to be readable characters, albeit 4 scanlines high.

 

Again, this seems to work fine in ReZolve, which is 16 scanline zones instead of 8 here.

Any ideas?

 

Thanks guys!

Bob

Link to comment
Share on other sites

7 minutes ago, PacManPlus said:
.byte $47,>(DLIST23),<(DLIST23)				;PF ZONE 23 - 8 LINES	$4E/$54
	.byte $47,>(DLIST24),<(DLIST24)				;PF ZONE 24 - 8 LINES	$51/$57
	.byte $47,>(DLIST25),<(DLIST25)				;PF ZONE 25 - 8 LINES	$54/$5A
	.byte $C7,>(DLIST26),<(DLIST26)				;PF ZONE 26 - 8 LINES	$57/$5D (FOR SCROLLING) (INTERRUPT)

 

Should be .byte $27

 

image.thumb.png.b6d54a305dc35726240d9eba0b4ca4e3.png

  • Like 1
Link to comment
Share on other sites

6 hours ago, playsoft said:

It looks good to me. I built a quick test program and it is working correctly. I don't think I made any changes (other than to adapt it to ca65) although I hardcoded it for NTSC only.

Thank you!  I'll take a look at this as well, and see if I'm doing anything different :)

 

2 hours ago, RevEng said:

Are you sure the object in that last zone is in the right mode, and has a proper terminator?

Thank you :) the game copies the DL to all zones the same (and then updated the screen zone addresses for each zone), and I double-checked the ending bytes (it's the same routine I've used in most of my games)...  and it looks fine.  Thanks for making take another look to confirm; every suggestion helps and removes possibilities.

 

Link to comment
Share on other sites

Ok, so I know what I was doing wrong, and it actually didn't have anything to do with what I had set up (I had set it up correctly - and thank you @Eagle, @playsoft, and @RevEng for giving insight).

 

I had too many objects in each DL.  This is what I had for each DL:

DLIST
	.byte <(SCRZN00),$60,>(SCRZN00),$80+$0C,#LEFTSIDE 	;SCREEN TILES
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 1 / PLAYER 1 SHOT
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 2 / PLAYER 2 SHOT
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 3
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 4
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 5
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 6 
	.byte <(STAMPS),$00+$1F,>(STAMPS),#OFFSCRN			;ENEMY SHOT 7
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 1 / PLAYER 1
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 2 / PLAYER 2
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 3
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 4
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 5
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 6
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 7
	.byte <(STAMPS),$00+$1C,>(STAMPS),#OFFSCRN			;ENEMY 8
	.byte $00,$00
DLISTEND

Once I removed everything but the Screen Tiles line (the first line), it scrolled correctly.  It seems I ran out of 'time' in each zone.

 

So now I just need to see how many objects I can get in each zone before it all goes haywire. :)

 

Thanks again!

  • Like 1
Link to comment
Share on other sites

Oof.  

 

Three '$1C'-Wide objects and two '$1F'-Wide shots are all there's time for before the scrolling starts to screw up.  That's not enough for what will be going on in this screen. 😕

I need to figure something out here.

Link to comment
Share on other sites

Omg looks like at least 427 cycles for DL (maria limit is 400 per line)

Fixed DL it’s not the best idea. I will try to convert my latest sprites procedure to plain asm (no MADS) and share here tomorrow. 

Edited by Eagle
  • Like 1
Link to comment
Share on other sites

Thanks guys!

 

Yeah, that was just a 'starting point' for me; I took an existing game and made it scroll, as I knew that would be the first thing that needed to be done.  

 

I'll take a look at the DMA masking as well; I need to get back up to speed with everything. It's so true: if you don't use it, you lose it. 

  • Like 1
Link to comment
Share on other sites

I tried my best. You will get idea ;) 

If I find more time I will do working example double buffered Display List.

 

FirstDL 	equ $4000
x_player	equ $70
y_player	equ $71
nr_sprite	equ $72
colorwidth 	equ $73 
Sprite_zone	equ $80		;13*2bytes

;****************************************************
;First Display List List line should point FirstDL=$4000 for first DL and increasing 128 bytes for every next DL
; but if you need more sprites than you can do 256 bytes step
; 128 bytes DL will give you up to 31 sprites for each line
; 
;DLL	$4F,>FirstLine,<FirstLine
;  		$4F,>[FirstLine+128],<[FirstLine+128]
;  		$4F,>[FirstLine+256],<[FirstLine+256]
;		etc......
;****************************************************
Start

;main loop will looks like this
Main
		jsr waitVBlank
		jsr set_first_dl_sprite_zone		;I'm using name First beacuse this was double buffered sprite procedure
;terminates DL on the start
		jsr clear_dl_first

		;bullet1 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;bullet2 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;bullet3 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;etc....

		;enemie1 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;enemie2 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;enemie3 - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite
		;etc....

		;maincharacter - pass in x_player y_player nr_sprite colorwidth
		jsr fast_sprite

;terminate DL's
		jsr add_endDl
		jmp Main


;****************************************************

fast_sprite	
	ldy y_player		 		;zero page
	ldx Y_tab_new,y		
	lda nr_sprite  				;zero page - addres in Maria bank - sprite number
	sta (sprite_zone,x)			;LSB
	inc sprite_zone,x 	
	lda colorwidth				;zero page - color + width  
	sta (sprite_zone,x) 	
	inc sprite_zone,x 	
	lda tab_y_16,y			;adjust Y in Zone
	sta (sprite_zone,x)		;MSB
	inc sprite_zone,x 	
	lda x_player			;zero page - x position
	sta (sprite_zone,x)	
	inc sprite_zone,x	
; bottom of the sprite 
	ldx Y_tab_new+16,y		;add 16 because 16 line sprite height
	lda nr_sprite 			;sprite number
	sta (sprite_zone,x)		;LSB
	inc sprite_zone,x	
	lda colorwidth			;color + width
	sta (sprite_zone,x)	  
	inc sprite_zone,x 	
	lda tab_y_16_Holey,y 	;Holey DMA
	sta (sprite_zone,x)		;MSB
	inc sprite_zone,x 	 
	lda x_player			;x position
	sta (sprite_zone,x) 
	inc sprite_zone,x 	
	rts

;put second zero on end for all Display Lists
add_endDl
	ldx #$00
	lda #$00
loopenddl
	inc sprite_zone,x	;skip to second byte of double zero for DL (terminate DL)
	sta (sprite_zone,x)
	inx
	inx
	cpx #13*2
	bne loopenddl
	rts

set_first_dl_sprite_zone
; :13 means Repat 13 times this line
; MWA is MADS macro - move word, # - is counter, starting from zero and increase every repaert 

	:13	mwa #[FirstDL+[#*128]] sprite_zone+[#*2]	

;you can use +5 after FirstDL if you need put extra 5 byte header for the background
;	:13	mwa #[FirstDL+5+[#*128]] sprite_zone+[#*2]	


; this looks like this
;	lda #<$4000
;	sta sprite_zone
;	lda #>$4000
;	sta sprite_zone+1
;	lda #<[$4000+128*1]
;	sta sprite_zone+2
;	lda #[>$4000+128*1]
;	sta sprite_zone+3
;	lda #<[$4000+128*2]
;	sta sprite_zone+4
;	lda #[>$4000+128*2]
;	sta sprite_zone+5
;	etc....
; 13 times (LSB and MSB), but entry 13 is dummy - for anything outside line zone 0 to 11
; address willby FirstDL+[128*12] but you can set anywher you need (but the best will be on the beginning memory page
; because I'm using only INC (sprite_zone,x) - increasing only LSB - making faster
	rts

clear_dl_first
;zero all sprites at begining
	lda #$00
	:13 sta FirstDL+[[#*128]+1]	;plus 1 on end because second zero teminate DL

;you can use +5 after FirstDL if you need put extra 5 byte header for the background
;		:13 sta FirstDL+5+[[#*128]+1]	

;looks like this
;	sta $4000
;	sta $4000+128
;	sta $4000+128*2
;	etc....
	rts

Y_tab_new		;address on zero page for INDIRECT,X
	:16 .byte 0
;looks like 
;  :16 - means repeat 16 times
; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	:16 .byte 2
	:16 .byte 4
	:16 .byte 6
	:16 .byte 8
	:16 .byte 10
	:16 .byte 12
	:16 .byte 14
	:16 .byte 16
	:16 .byte 18
	:16 .byte 20
	:16 .byte 22
	:16 .byte 24	;empty - this is dummy line, anything outside zones 0-11 will be written to (indirect+24),x
					;but never put on screen, it's easier to put sprite in dummy DL than checking every sprite leaving screen in Y axis
					;addres for Dummy DL you can put wherewer you want (page align)
	:16 .byte 24	;empty
	:16 .byte 24	;empty
	:16 .byte 24	;empty
	:16 .byte 24	

 
sprbank equ $E0		;MSB of $E000 bank maria
holbank	equ $D0		;MSB of $D000 HoleyDMA bank

Tab_Y_16		 
;every line looks like this
; .byte sprbank+0,sprbank+1,sprbank+2,sprbank+3,sprbank+4,sprbank+5,sprbank+6,sprbank+7,.........., sprbank+15
; lines are 16 times repeated  - for speedcode reason (256 bytes table)
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+#
	:16 .byte sprbank+# 
	:16 .byte sprbank+#
	:16 .byte sprbank+#
Tab_Y_16_Holey 		 
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#
	:16 .byte holbank+#

 

Edited by Eagle
  • Thanks 2
Link to comment
Share on other sites

Nice!

 

I used Dynamic DL creation in ReZolve (I promise to finish that at some point)...

But I will look this over.

 

Always open to new suggestions... to learning a more efficient way of doing things. ;)

 

Thank you!

Edited by PacManPlus
  • Like 3
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...