Tearing while scrolling attributes

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
Lethargeek
Manic Miner
Posts: 734
Joined: Wed Dec 11, 2019 6:47 am

Re: Tearing while scrolling attributes

Post by Lethargeek »

I can't even imagine how a code for such a simple task could be so slow. Even a straightforward single ldir of 256 bytes + a few separate byte transfers to correct the right column will eat less than half of the top border time. And calling a simple subroutine (consisting of "get left; ldi x31; put right") 24 times should scroll the entire attribute area without any tearing (and likely still finishing ahead of the top border).
dfzx
Manic Miner
Posts: 673
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Tearing while scrolling attributes

Post by dfzx »

Lethargeek wrote: Wed May 20, 2020 2:32 am I can't even imagine how a code for such a simple task could be so slow.
4-way scrolling based on inputs and events means rebuilding the 32x24 display each frame. At least at the moment.

It looks like some sort of "scroll the attributes in one of the 4 directions, then fill in the appearing row/column" approach is going to be required.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Turtle_Quality
Manic Miner
Posts: 502
Joined: Fri Dec 07, 2018 10:19 pm

Re: Tearing while scrolling attributes

Post by Turtle_Quality »

If it's just the attributes moving, regardless of the direction, most of the work can be completed by one LDIR that should not take long.

Scrolling the graphics around is more complex and time consuming because of the screen layout and the 8 fold increase in data per character square.
Can you show the code ?
Definition of loop : see loop
User avatar
Lethargeek
Manic Miner
Posts: 734
Joined: Wed Dec 11, 2019 6:47 am

Re: Tearing while scrolling attributes

Post by Lethargeek »

dfzx wrote: Wed May 20, 2020 8:58 am 4-way scrolling based on inputs and events means rebuilding the 32x24 display each frame. At least at the moment.
still a very simple task if it's just attributes
dfzx wrote: Wed May 20, 2020 8:58 am It looks like some sort of "scroll the attributes in one of the 4 directions, then fill in the appearing row/column" approach is going to be required.
for horizontal scrolling it will be easier to wrap each row separately, like

Code: Select all

ld a,(de)
ldi	x31
ld (de),a
inc de
inc hl
(this scrolls a row left and goes to the next one)
Post Reply