English Amiga Board


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

 
 
Thread Tools
Old 20 March 2024, 12:06   #1
REAKTOR BEAR
Registered User
 
Join Date: Mar 2021
Location: SWEDEN
Posts: 40
Shift bitplanes 1 pixel

We would like to move bitplanes left and right on the screen, 1 pixel per frame... but if we shift the memory pointer to the bitplanes, they move 8 pixels on the screen, because memory is organised in bytes (8bits/8pixels).

What if we want to move bitplanes 1 pixel?
REAKTOR BEAR is offline  
Old 20 March 2024, 12:56   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
x = scroll offset (-N, ..., -1, 0, 1, ..., N)
bits = x&15
set $dff102 to (bits<<4)|bits
set $dff0ex (bitplane pointers) to bitplane_ptr+(x>>4)*2

Docs: http://amigadev.elowar.com/read/ADCD.../node0022.html

Last edited by a/b; 20 March 2024 at 13:17. Reason: forgot to convert back to bytes ><
a/b is online now  
Old 20 March 2024, 14:31   #3
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Do NOT poke the hardware directly, even more so as this is a graphics primitive that is easily available from the operating system. The corresponding function is called ScrollRaster() in the graphics.library.
Thomas Richter is offline  
Old 20 March 2024, 17:44   #4
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by Thomas Richter View Post
Do NOT poke the hardware directly, even more so as this is a graphics primitive that is easily available from the operating system. The corresponding function is called ScrollRaster() in the graphics.library.
Zero harm whatsoever.

If the returning copperlist is properly written, hardware scroll values will instantly be reset in any case.

A nothing "problem"
Galahad/FLT is online now  
Old 20 March 2024, 17:55   #5
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Quote:
Originally Posted by Galahad/FLT View Post
Zero harm whatsoever.
Does not clip on window or screen boundaries. Does not work ideally on interleaved bitmaps. Does not work on RTG graphics. Does not reserve the blitter, so does not work with multitasking. That's >>0 harm that is done here.



Quote:
Originally Posted by Galahad/FLT View Post
If the returning copperlist is properly written, hardware scroll values will instantly be reset in any case.
Moving a bitplane is something different than panning, and this problem is not related to the copper at all.
Thomas Richter is offline  
Old 20 March 2024, 18:04   #6
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
He didn't explicitely specify whether he's using OS or hw banging, so based on his previous enquiries I'm assuming it's hw banging (also, hw forum ).
a/b is online now  
Old 20 March 2024, 23:41   #7
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
Quote:
Originally Posted by a/b View Post
He didn't explicitely specify whether he's using OS or hw banging, so based on his previous enquiries I'm assuming it's hw banging (also, hw forum ).
Exactly, that's the inference I got.

So to repeat, zero harm
Galahad/FLT is online now  
Old 21 March 2024, 01:42   #8
Bruce Abbott
Registered User
 
Bruce Abbott's Avatar
 
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,543
Quote:
Originally Posted by Thomas Richter View Post
Do NOT poke the hardware directly, even more so as this is a graphics primitive that is easily available from the operating system. The corresponding function is called ScrollRaster() in the graphics.library.
It might be 'easy', but ScrollRaster() is very expensive. In this case it will blit the entire screen (less a one pixel vertical strip) and then fill the 'gap' left behind with solid color (that will probably have to be overwritten with new image data). Very inefficient!

This is the kind of advice that gives neophytes the impression that the Amiga's hardware is underpowered.

Quote:
Does not work on RTG graphics.
RTG is 3rd party stuff that only works through proprietary libraries and drivers. Not appropriate for this subforum.
Bruce Abbott is online now  
Old 21 March 2024, 07:41   #9
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
Quote:
Originally Posted by Thomas Richter View Post
Does not clip on window or screen boundaries. Does not work ideally on interleaved bitmaps. Does not work on RTG graphics.
The sub-topic is "coders asm/hardware", that is perfectly clear what OP wants. It's probably for a game, not an application.

Quote:
Does not reserve the blitter, so does not work with multitasking. That's >>0 harm that is done here.
Are you sure the blitter is involved in hardware scrolling by changing shifting and screen pointers?
jotd is offline  
Old 21 March 2024, 10:12   #10
modrobert
old bearded fool
 
modrobert's Avatar
 
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 775
Quote:
Originally Posted by Bruce Abbott View Post
This is the kind of advice that gives neophytes the impression that the Amiga's hardware is underpowered.
I remember a friend a who bought Obliterator (Psygnosis) for the A500 back in the day, supposedly it was made system friendly (using library calls), it had abysmal frame rate (think unintended flickering slow motion) and horrible controls. In my mind, assuming Obliterator is system friendly as rumored, it is a perfect example of what to expect regarding limitations when not banging the hardware (using registers).
modrobert is offline  
Old 21 March 2024, 14:31   #11
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
Quote:
Originally Posted by Bruce Abbott View Post
It might be 'easy', but ScrollRaster() is very expensive. In this case it will blit the entire screen (less a one pixel vertical strip) and then fill the 'gap' left behind with solid color (that will probably have to be overwritten with new image data). Very inefficient!
it depends on what you want to do. Panning or scrolling. For panning,we have ScrollVPort() or MoveScreen().
Quote:
Originally Posted by Bruce Abbott View Post
This is the kind of advice that gives neophytes the impression that the Amiga's hardware is underpowered.
The type of answer banging the hardware gives people the impression AmigaOs is underpowered. Everything you want is there in the system.
Quote:
Originally Posted by Bruce Abbott View Post
RTG is 3rd party stuff that only works through proprietary libraries and drivers. Not appropriate for this subforum.
Banging the hardware is not apropriate because it does not work on every graphics mode. AmigaOs and its hardware is as proprietary as these drivers.
Thomas Richter is offline  
Old 21 March 2024, 15:36   #12
Rotareneg
Registered User
 
Rotareneg's Avatar
 
Join Date: Sep 2017
Location: Kansas, USA
Posts: 324
Quote:
Originally Posted by Thomas Richter View Post
The type of answer banging the hardware gives people the impression AmigaOs is underpowered. Everything you want is there in the system.
Everything except performance.
Rotareneg is offline  
Old 21 March 2024, 16:33   #13
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by Thomas Richter View Post
Do NOT poke the hardware directly, even more so as this is a graphics primitive that is easily available from the operating system. The corresponding function is called ScrollRaster() in the graphics.library.
Hm... ScrollRaster() needs a RastPort (as the name implies), which is fine in most cases. You can even call it on the RastPort of a Screen, if there are no Windows open on it whose contents would be affected. No clipping is performed, which should make it reasonably fast.

If there is no need for clipping via the RastPort or the Layer it is a part of, then BltBitMap() might just do the minimum required, and nothing more. Could be worth a try. You may have to call BltBitMap() on the column of pixels which the blit operation did not copy. ScrollRaster() would have filled that column with the current background colour.
Olaf Barthel is offline  
Old 21 March 2024, 16:45   #14
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by Rotareneg View Post
Everything except performance.
First determine what the budget for the operation is. The budget not only includes how much time is spent for the operation to complete, but also for learning how to perform it, debug it and measure the actual performance attainable. You can always reconsider the approach if you know your numbers.

Assuming that the operating system's toolbox, as available to you, will let you down is a shortcut. Not all shortcuts will be to your benefit or advantage It's also possible that just by giving it a shot you might stumble upon something that you did not expect to find and which adds to your own "bag of tricks".

And, no, I never felt the acute urge to make use of the Blitter on its own terms. I'm much too lazy for that, especially considering how much can go wrong if you do not know exactly what is called for and lack the patience to debug the smoking ruins. Laziness can be a superpower. Let somebody else solve that problem for you.
Olaf Barthel is offline  
Old 24 March 2024, 19:38   #15
REAKTOR BEAR
Registered User
 
Join Date: Mar 2021
Location: SWEDEN
Posts: 40
Yes, direct hardware banging if possible... we are trying to make a depth of field parallax effect, where the bitplanes in the background move slowly, and the foreground move fast:

Playfield 1 (foreground) move bitplanes(1,3,5) 6 pixels per frame.

Playfield 2 (background)
move bitplane6, 1 pixels per frame
move bitplane4, 2 pixels per frame
move bitplane2, 3 pixels per frame

Graphics.lib is loaded but used only to setup a View since we have zero experience with graphics.lib. The game is designed for OCS A500, but should also work on other amigas like A1200.

Last edited by REAKTOR BEAR; 24 March 2024 at 19:54.
REAKTOR BEAR is offline  
Old 24 March 2024, 19:41   #16
REAKTOR BEAR
Registered User
 
Join Date: Mar 2021
Location: SWEDEN
Posts: 40
Quote:
Originally Posted by a/b View Post
x = scroll offset (-N, ..., -1, 0, 1, ..., N)
bits = x&15
set $dff102 to (bits<<4)|bits
set $dff0ex (bitplane pointers) to bitplane_ptr+(x>>4)*2

Docs: http://amigadev.elowar.com/read/ADCD.../node0022.html
So you are talking about these (BPLCON1) ?
PF2H=Playfield 2 horizontal scroll code
PF1H=Playfield 1 horizontal scroll code

How do we set it to 1pixel scroll?
REAKTOR BEAR is offline  
Old 24 March 2024, 21:03   #17
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,038
Yeah, BPLCON1 ($dff102).
1px scroll? Change x by +/-1.
x=-17 => $102 = $000f, $0e0/$0e2 = bpl_ptr1-4, $0e8/$0ea = bpl_ptr3-4, $0f0/$0f2 = bpl_ptr5-4
x=-16 => $102 = $0000, $0e0/$0e2 = bpl_ptr1-2, $0e8/$0ea = bpl_ptr3-2, $0f0/$0f2 = bpl_ptr5-2
...
x=-2 => $102 = $000e, $0e0/$0e2 = bpl_ptr1-2, $0e8/$0ea = bpl_ptr3-2, $0f0/$0f2 = bpl_ptr5-2
x=-1 => $102 = $000f, $0e0/$0e2 = bpl_ptr1-2, $0e8/$0ea = bpl_ptr3-2, $0f0/$0f2 = bpl_ptr5-2
x=0 => $102 = $0000, $0e0/$0e2 = bpl_ptr1+0, $0e8/$0ea = bpl_ptr3+0, $0f0/$0f2 = bpl_ptr5+0
x=1 => $102 = $0001, $0e0/$0e2 = bpl_ptr1+0, $0e8/$0ea = bpl_ptr3+0, $0f0/$0f2 = bpl_ptr5+0
...
x=15 => $102 = $000f, $0e0/$0e2 = bpl_ptr1+0, $0e8/$0ea = bpl_ptr3+0, $0f0/$0f2 = bpl_ptr5+0
x=16 => $102 = $0000, $0e0/$0e2 = bpl_ptr1+2, $0e8/$0ea = bpl_ptr3+2, $0f0/$0f2 = bpl_ptr5+2
... etc.

2px scroll => change x by +/-2, use the same calcs..
Since you are only scrolling playfield1 you only set $dff102 bits 0-3 and leave bits 4-7 at 0. To scroll everything you also set bits 4-7 (e.g. $0011, $0022, ... $00ff), this is a difference from my first post.
a/b is online now  
Old 25 March 2024, 08:58   #18
REAKTOR BEAR
Registered User
 
Join Date: Mar 2021
Location: SWEDEN
Posts: 40
Awesome, thanks a/b, as a sidenote why was this information not in the Commodore Amiga hardware reference manual (playfields section) .. strange
REAKTOR BEAR is offline  
Old 25 March 2024, 11:19   #19
chb
Registered User
 
Join Date: Dec 2014
Location: germany
Posts: 439
Quote:
Originally Posted by REAKTOR BEAR View Post
Yes, direct hardware banging if possible... we are trying to make a depth of field parallax effect, where the bitplanes in the background move slowly, and the foreground move fast:

Playfield 1 (foreground) move bitplanes(1,3,5) 6 pixels per frame.

Playfield 2 (background)
move bitplane6, 1 pixels per frame
move bitplane4, 2 pixels per frame
move bitplane2, 3 pixels per frame
It is not possible to have a different x-scroll value for every bitplane of playfield 2; scroll registers work per playfield. You'd need to either shift two bitplanes with the blitter, have 16 copies of them in memory (shifted by 1,2,3... pixels) or use some other trick.
chb is offline  
Old 06 April 2024, 14:46   #20
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Quote:
Originally Posted by Thomas Richter View Post
Do NOT poke the hardware directly, even more so as this is a graphics primitive that is easily available from the operating system. The corresponding function is called ScrollRaster() in the graphics.library.
I created the different sub-forums from a poll a long while back to allow experts to subscribe to the forums matching their interest and area of expertise, help make threads more on-topic, and to avoid giving conflicting advice.

This forum is specifically for banging the hardware, algorithms, or writing in Assembly in general (although if you're writing a utility, language or driver in Assembly which uses the OS extensively, coders should ask in Coders.System to get the best advice).

I would say that there are a few cases when OS programming advice is very useful in this HW programming forum, such as switching the OS off, on, and semi-on safely, supporting CPU, RAM, and other expansion cards and peripherals in a compatible way, file formats, early boot, media boot, and reset.

But generally, this is not the place to say "do it with the OS instead".
Photon 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
5 bitplanes ... chadderack Coders. Asm / Hardware 63 25 September 2022 00:02
Waiting 300 microseconds on a shift/load change or button shift on a CD32 gamepad? BeamCoder Coders. Asm / Hardware 48 04 September 2021 18:07
Alien Breed II title pixel by pixel logo removal dex project.Sprites 17 06 May 2020 15:23
bitplanes format jarre Coders. General 3 19 January 2019 17:38
Using the Copper to mangle the bitplanes. Andy_C Coders. General 7 16 March 2011 12:58

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 11:43.

Top

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