STE 16 Pixel Trick

All about ST/STE demos

Moderators: Mug UK, lotek_style, Moderator Team

elliot
Atari User
Atari User
Posts: 30
Joined: Tue Mar 17, 2009 2:00 pm

STE 16 Pixel Trick

Postby elliot » Thu May 24, 2012 9:25 am

I have seen lots of comments about this STE trick to gain an extra 16 pixels on the left border. I assume it is to do with tricking the hardware scrolling into think it still has to draw some pixels, however, I was hoping that someone could post a better description or better still example code.

Many thanks

Elliot...

User avatar
alexh
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2595
Joined: Wed Oct 20, 2004 1:52 pm
Location: UK - Oxford
Contact:

Re: STE 16 Pixel Trick

Postby alexh » Thu May 24, 2012 10:30 am

/*-----------------------------------------------------------------------*/
/**
* Handle horizontal scrolling to the left.
* On STE, there're 2 registers that can scroll the line :
* - $ff8264 : scroll without prefetch
* - $ff8265 : scroll with prefetch
* Both registers will scroll the line to the left by skipping the amount
* of pixels in $ff8264 or $ff8265 (from 0 to 15).
* As some pixels will be skipped, this means the shifter needs to read
* 16 other pixels in advance in some internal registers to have an uninterrupted flow of pixels.
*
* These 16 pixels can be prefetched before the display starts (on cycle 56 for example) when using
* $ff8265 to scroll the line. In that case 8 more bytes per line (low res) will be read. Most programs
* are using $ff8265 to scroll the line.
*
* When using $ff8264, the next 16 pixels will not be prefetched before the display
* starts, they will be read when the display normally starts (cycle 56). While
* reading these 16 pixels, the shifter won't be able to display anything, which will
* result in 16 pixels having the color 0. So, reading the 16 pixels will in fact delay
* the real start of the line, which will look as if it started 16 pixels later. As the
* shifter will stop the display at cycle 56+320 anyway, this means the last 16 pixels
* of each line won't be displayed and you get the equivalent of a shorter 304 pixels line.
* As a consequence, this register is rarely used to scroll the line.
*
* By writing a value > 0 in $ff8265 (to start prefetching) and immediatly after a value of 0
* in $ff8264 (no scroll and no prefetch), it's possible to fill the internal registers used
* for the scrolling even if scrolling is set to 0. In that case, the shifter will start displaying
* each line 16 pixels earlier (as the data are already available in the internal registers).
* This allows to have 336 pixels per line (instead of 320) for all the remaining lines on the screen.
*
* Although some programs are using this sequence :
* move.w #1,$ffff8264 ; Word access!
* clr.b $ffff8264 ; Byte access!
* It is also possible to add 16 pixels by doing :
* move.b #X,$ff8265 ; with X > 0
* move.b #0,$ff8264
* Some games (Obsession, Skulls) and demos (Pacemaker by Paradox) use this
* feature to increase the resolution, so we have to emulate this bug, too!
*
* So considering a low res line of 320 pixels (160 bytes) :
* - if both $ff8264/65 are 0, no scrolling happens, the shifter reads 160 bytes and displays 320 pixels (same as STF)
* - if $ff8265 > 0, line is scrolled, the shifter reads 168 bytes and displays 320 pixels.
* - if $ff8264 > 0, line is scrolled, the shifter reads 160 bytes and displays 304 pixels,
* the display starts 16 pixels later.
* - if $ff8265 > 0 and then $ff8264 = 0, there's no scrolling, the shifter reads 168 bytes and displays 336 pixels,
* the display starts 16 pixels earlier.
*/

elliot
Atari User
Atari User
Posts: 30
Joined: Tue Mar 17, 2009 2:00 pm

Re: STE 16 Pixel Trick

Postby elliot » Thu May 24, 2012 11:25 am

Thanks for the quick response!

That seems much easier than I thought it would be - that is an extra 3200 pixels for very little work.

Great.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: STE 16 Pixel Trick

Postby simonsunnyboy » Thu May 24, 2012 3:32 pm

Is this trigger one shot (VBL) or necessary for each scanline?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
alexh
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2595
Joined: Wed Oct 20, 2004 1:52 pm
Location: UK - Oxford
Contact:

Re: STE 16 Pixel Trick

Postby alexh » Thu May 24, 2012 4:09 pm

I don't know. I just googled it and found that comment section in the STeEM code base.

I would imagine that it is 1-shot, maybe not even per VBL. But I'm not an Atari ST programmer.

User avatar
npomarede
Atari God
Atari God
Posts: 1178
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: STE 16 Pixel Trick

Postby npomarede » Thu May 24, 2012 9:23 pm

alexh wrote:I don't know. I just googled it and found that comment section in the STeEM code base.

I would imagine that it is 1-shot, maybe not even per VBL. But I'm not an Atari ST programmer.


That's unfortunate :( As I'm the one who wrote the above code and documentation, I'd like to say this comes from Hatari, not from Steem (Steem includes some parts of Hatari's code).

As for the effect, you need to do it on each VBL, but it's not necessary to do it on each scanline. Once started, it will continue on the rest of the screen for the current VBL.

Nicolas

User avatar
alexh
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2595
Joined: Wed Oct 20, 2004 1:52 pm
Location: UK - Oxford
Contact:

Re: STE 16 Pixel Trick

Postby alexh » Fri May 25, 2012 8:29 am

That's unfortunate :( As I'm the one who wrote the above code and documentation, I'd like to say this comes from Hatari

ImageI did put Hatari at first... but then edited my post

evil
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 139
Joined: Sun Nov 12, 2006 8:03 pm

Re: STE 16 Pixel Trick

Postby evil » Fri May 25, 2012 3:21 pm

npomarede wrote:As for the effect, you need to do it on each VBL, but it's not necessary to do it on each scanline. Once started, it will continue on the rest of the screen for the current VBL.


In fact, you only need to do it once and it will stay.
The drawback is of course that the hscroll won't be avilable to use.

First used in the Tyranny intro screen, and invented by Bellman / DHS back in '92 :)

Just try this little thing:

Code: Select all

      pea   remove_16px
      move.w   #$26,-(sp)
      trap   #14
      addq.l   #6,sp

      clr.w   -(sp)
      trap   #1

remove_16px:
      move.w   #1,$ffff8264.w
      move.b   #0,$ffff8264.w
      rts

User avatar
npomarede
Atari God
Atari God
Posts: 1178
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: STE 16 Pixel Trick

Postby npomarede » Fri May 25, 2012 3:40 pm

By the way, regarding the timings involved, did you try :
    - to change $ff8264/$ff8265 anywhere, including while display is ON in the middle of the line ? Are the next lines modified in that case
    - to check the delay allowed between the 2 writes to $ff8264/$ff8265 ? Do they need to be close enough so that the shifter didn't display more than 16 pixels ? Or does it work if there e.g 60 cycles between the 2 moves ?
Nicolas

evil
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 139
Joined: Sun Nov 12, 2006 8:03 pm

Re: STE 16 Pixel Trick

Postby evil » Fri May 25, 2012 4:24 pm

npomarede wrote:
    - to change $ff8264/$ff8265 anywhere, including while display is ON in the middle of the line ? Are the next lines modified in that case
    - to check the delay allowed between the 2 writes to $ff8264/$ff8265 ? Do they need to be close enough so that the shifter didn't display more than 16 pixels ? Or does it work if there e.g 60 cycles between the 2 moves ?


Hi,

no I've not made any such tests. Pretty happy it works as it is :) Don't have the time either to make extensive testing on a real machine, at least not for another month. Have some stuff to prepare in time for a certain demo party :-)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4875
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: STE 16 Pixel Trick

Postby simonsunnyboy » Fri May 25, 2012 4:44 pm

Thanks for sharing, it might be useful someday, esp. as it looks easy to implement!
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

elliot
Atari User
Atari User
Posts: 30
Joined: Tue Mar 17, 2009 2:00 pm

Re: STE 16 Pixel Trick

Postby elliot » Fri Jun 08, 2012 3:56 pm

As for the hardware scrolling I never managed to get it to work anyway. It is so much easier to get hold of tech info now but looking back I think I may have gotten caught out by the bug, from memory it would jump a couple of pixels every so often (or maybe jump 16 pixels, I forget now).

User avatar
MiggyMog
Atari Super Hero
Atari Super Hero
Posts: 802
Joined: Sun Oct 30, 2005 4:43 pm
Location: Scotland

Re: STE 16 Pixel Trick

Postby MiggyMog » Sat Jun 16, 2012 9:59 pm

I am surprised it does not need to be called on each scanline. This is pretty neat & I was impressed with this when I first seen it in Octalyser. I think the STE FAQ should be updated with this info.
('< o o o o |''| STM,2xSTFM,2xSTE+HD,C-Lab Falcon MK2+HD,Satandisk,Ultrasatandisk,Ethernat.

User avatar
Steven Seagal
Atari God
Atari God
Posts: 1993
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: STE 16 Pixel Trick

Postby Steven Seagal » Sun Jul 01, 2012 10:09 am

The doc is in Steem repository simply because the file video.c from Hatari has been included there for my cool hack, and we know that google outrageously favours its content over the rest.
When I do searches about generic ST stuff in google, I often get links to the repository,

The STE 16 Pixel Trick was already handled in Steem anyway.

User avatar
MasterOfGizmo
Atari God
Atari God
Posts: 1026
Joined: Fri Feb 08, 2013 12:15 pm
Contact:

Re: STE 16 Pixel Trick

Postby MasterOfGizmo » Wed Oct 09, 2013 10:49 am

I found this routine that is supposed to trigger the same effect.

http://files.dhs.nu/files_coding/leftb.s

The first sets 64+65 using one word access and then clears 64. This is not what you explained here as well ...
MIST board, FPGA based Atari STE and more: https://github.com/mist-devel/mist-board/wiki

User avatar
npomarede
Atari God
Atari God
Posts: 1178
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: STE 16 Pixel Trick

Postby npomarede » Wed Oct 09, 2013 10:54 am

MasterOfGizmo wrote:I found this routine that is supposed to trigger the same effect.

http://files.dhs.nu/files_coding/leftb.s

The first sets 64+65 using one word access and then clears 64. This is not what you explained here as well ...

Hello,
who is "you" ? What you described is exactly what is described in the Hatari's source comments and what Evil posted above in this thread. I don't see any difference.

Nicolas

User avatar
MasterOfGizmo
Atari God
Atari God
Posts: 1026
Joined: Fri Feb 08, 2013 12:15 pm
Contact:

Re: STE 16 Pixel Trick

Postby MasterOfGizmo » Wed Oct 09, 2013 2:25 pm

npomarede wrote:who is "you" ? What you described is exactly what is described in the Hatari's source comments and what Evil posted above in this thread. I don't see any difference.

Nicolas


Argh ... stupid me, i misread one of the previous postings ... sorry ....
MIST board, FPGA based Atari STE and more: https://github.com/mist-devel/mist-board/wiki

User avatar
Zorro 2
Administrator
Administrator
Posts: 2191
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Re: STE 16 Pixel Trick

Postby Zorro 2 » Wed Oct 09, 2013 8:24 pm

We used this trick on Atari STE on the screen EXTRAVAGANCE (http://www.youtube.com/watch?v=IRJAa0AiF0I) and it works fine on Atari ST emulators :D
Member of NoExtra Team

elliot
Atari User
Atari User
Posts: 30
Joined: Tue Mar 17, 2009 2:00 pm

Re: STE 16 Pixel Trick

Postby elliot » Thu Feb 20, 2014 1:37 pm

Does it work in medium res?

User avatar
Steven Seagal
Atari God
Atari God
Posts: 1993
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: STE 16 Pixel Trick

Postby Steven Seagal » Thu Nov 23, 2017 7:21 pm

Here's an explanation for the trick.
When writing on address $FF8264, the HSCROLL register in the Shifter is modified.
When writing on address $FF8265, the HSCROLL register in the Shifter is modified, and the "prefetch" flag in the Glue is changed (set if value<>0, cleared otherwise).
Timing doesn't matter, there are two registers.
The net effect of writing <>0 on $FF8265 then 0 on $FF8264 is that only the "prefetch" flag in the Glue stays set, so the line (DE) starts 16 pixels before. The Shifter does its job without any scrolling, STF-like, and we gain 16 pixels. This is a Glue effect.
When the HSCROLL register in the Shifter is <>0, it will do some preshift on the prefetched words, and start outputting 16 cycles later. So if you have "prefetch" = 0 in the Glue, and HSCROLL<>0 in the Shifter, you will have a larger left border. This is a Shifter effect.


Social Media

     

Return to “Demos - General”

Who is online

Users browsing this forum: No registered users and 2 guests