English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 10 February 2020, 21:57   #1
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
BPLCON1 Scroll Left & Right

Good Evening!

I'm slowly getting there with my ASM, but something cropped up today that I can get my head around.

So I'm adjusting the scroll value in BPLCON1 to smoothly scroll my bitplanes around. I start with a value of $0000 and increate that by $11 until we get to a value of $00ff.

This seems to work, and it's scrolling just fine. However, that is only one way. The view slides off to the right, bringing in the hidden tiles on the left of the screen.

I have one column either side of 16 pixels, and my display window is 288 pixels wide, so my aim is to scroll left and right after blotting into those columns but I can't figure out how I would go about scrolling in the opposite direction.

Can you have negative values in BPLCON1? It doesn't sound right having signed words. Or does it?

Bit of a head scratcher this one.

Thanks again for any help, as you know by now I really appreciate it :-)
DanielAllsopp is offline  
Old 10 February 2020, 22:24   #2
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
So when you are scrolling right you are increasing BPLCON1 by $11. if BPLCON1= $11 then you plot a tile to the right border by multiplying the value you have by 16.

So if this is frame n+1, BPLCON1=$11 and you are scrolling right then you would have

Code:
TILE_ADDRESS=(SCREEN_ORIGIN+38)+(1*16)*SCANLINE_LENGTH.
If you are scrolling left and you decrease BPLCON1 and say it's value is 8 then...

Code:
TILE_ADDRESS=(SCREEN_ORIGIN)+81*16)*SCANLINE_LENGTH.
Don't forget to increase and decrease your bitplane pointers as you go from $f>0 and 0<$f when moving.

If you're still stuck then I can give you example code.
Geezer
mcgeezer is offline  
Old 11 February 2020, 00:22   #3
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
Thanks for the info Graeme. I think I'm gonna need some more info if you'd be so kind.

I've got my tiles plotting code sorted, I think, where I can just pass an X and Y grid position and it gets blitted in the correct location.

A picture may very well tell a thousand words though:



So here I've got tiles blitted into positions [0,0], [1,0] and [2,0] for the top row, and in position [17,13], [18,13] and [19,13] for the bottom row.

Now because of the display window, the tiles in position [0,0] and [19,13] are blitted into the left and right columns which aren't visible.

With BPLCON1 as $0000 then that all works out as a centered display.

If I have BPLCON1 as $00ff then quite rightly, the display is shifted from left to right and the tiles in the left hand column become visible.

What I don't understand, and probably because I don't fully understand how BPLCON1 works, at all, is how on earth do I scroll in the opposite direction (example C) so the display is shifted from right to left and the tiles in the right hand column are scrolled onto the display?

Any source code would be appreciated too, so many thanks for that.

----

So, I think I've figured something out. If I start BPLCON1 as $00ff and then decrement down to $00 then I get the scroll the other way. Just I'm offset by one block when I first start!

I'm getting there, just thinking out loud here. I'll probably end up dreaming about bitplanes and scrolling tonight and something will pop into my head in the morning.

Last edited by DanielAllsopp; 11 February 2020 at 00:33. Reason: Last minute thought...
DanielAllsopp is offline  
Old 11 February 2020, 09:04   #4
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
You can only scroll right with bplcon1 . If you are at bplcon1 as $0000 and you want to scroll left by 1 pixel you reduce your bitplane pointers by 1 word and then scroll right by 15 in bplcon1.
Antiriad_UK is offline  
Old 11 February 2020, 09:27   #5
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Here's some example routines of how I might do it.

This routine just takes a simple x coordinate and divides it by 16 with the remainder being used for BPLCON1.

Code:
; Updates a screen structure with an x/y value.
; d0 = screen structure
; d1 = xpos
; d2 = ypos
agdUpdateScreenPosition:
	movem.l	d0-d3/a0-a1,-(a7)
	move.l	d0,a0
	moveq	#0,d3
	move.w	d1,d3
	not.w	d1
	and.w	#$f,d1
	lsr.w	#3,d3
	move.w	d3,hScreenOffset(a0)
	move.w	d1,hScreenHScroll(a0)
	movem.l	(a7)+,d0-d3/a0-a1	
	rts
And this routine takes in the values from the previous routine and updates the bitplane pointers and BPLCON1.

Code:
; Update the selected screen parameters with a copper.
; d0 = screen structure
agdUpdateCopperParameters:
	movem.l	d0/d1/d3/d5/d7-a0,-(a7)
	move.l	d0,a0
	moveq	#0,d0
	move.w	hScreenHScroll(a0),d0
	move.w	d0,d1
	lsl.w	#4,d1
	or.w	d1,d0
	move.l	COPPTR_BPLCON1,a1
	move.w	d0,(a1)
	
	moveq	#0,d5
	move.w	hScreenOffset(a0),d5
	
	moveq	#0,d7
	move.w	hScreenPlanes(a0),d7			; d7 = Number of planes
	subq.w	#1,d7	
	lea	hScreenPointers(a0),a0
	
	move.l	COPPTR_BPL0PTH,a1
	move.l	#BPL0PTH<<16,d3
.bp:	move.l	(a0)+,d1
	add.l	d5,d1
	swap	d1
	move.w	d1,d3
	move.l	d3,(a1)+
	add.l	#$2<<16,d3
	swap	d1
	move.w	d1,d3
	move.l	d3,(a1)+
	add.l	#$2<<16,d3	
	dbf	d7,.bp
	
	movem.l	(a7)+,d0/d1/d3/d5/d7-a0
	rts
As said above, you need to adjust the bitplane pointers by 1 word, BPLCON1 can only have the smooth scroll values of 0-15.

Graeme
mcgeezer is offline  
Old 11 February 2020, 09:43   #6
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
Just to save you some potential trouble: my number one error in making in right-to-left scroller is forgetting to allocate space on the left side of the bitmap. Or rather: allocating it just fine, but forgetting to add some offset to the bitplane pointers before I start scrolling.

So don't make my mistakes and add enough of an offset to the bitplane pointers to actually be able to scroll to the left without overwriting all sorts of unallocated memory. Turns out doing overwriting random bits of memory 'may' crash the Amiga quite quickly
roondar is offline  
Old 13 February 2020, 15:01   #7
DanielAllsopp
Registered User
 
DanielAllsopp's Avatar
 
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
As always, thanks a lot for your help guys, I really appreciate it. I'm busy using all this knowledge right now to work things out.
DanielAllsopp is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Double Buffer & Hardware Scroll DanielAllsopp Coders. Asm / Hardware 13 29 January 2020 19:07
BPLCON1 scroll values in HiRes Yragael Coders. Asm / Hardware 5 28 September 2018 17:52
Tutorial about zooming with BPLCON1 (102) : Looking for examples Yragael Coders. Tutorials 16 26 September 2018 21:36
right/left amiga keys to right/left cmd on Apple keyboard ascp support.FS-UAE 1 23 April 2018 22:18
Zooming using BPLCON1 (horiz. shift) — am I doing it wrong? losso Coders. Asm / Hardware 10 14 January 2014 17:00

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 17:33.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.21448 seconds with 15 queries