Smooth horizontal scrolling

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Smooth horizontal scrolling

Post by bru65pag » Sat Dec 29, 2018 12:21 pm

Good morning,

I'm trying to do a smooth horizontal scrolling while developping a small game. The image is low-res graphic chars, and I want to shift line 16 to 24 from right to left smoothly. As can be seen in the attached file (zipped avi), this is far from smooth.
UnsmoothHorizontalScrolling.zip
(2.12 MiB) Downloaded 36 times
Could I achieve smoothness without using some "special technique" ?

I read in the multi-scroller demo explanation that 'It has long been know that we can do a smooth horizontal scroller 2 pixels at a time ( 1 cpu clock cycle = 2 pixels ) by manipulating the number of clock cycles used before *executing* video bytes: so we might add 3 cycles = a shift to the right of 6 pixels, then on the next frame add 2 cycles = a shift to the right of 4 pixels and so on, horizontal smooth scrolling made easy...'.

After reading this, I believe that some "special technique" is needed? Could somebody explain, or point me to the explanation?

Thanks. Bruno.
Last edited by bru65pag on Sat Dec 29, 2018 2:12 pm, edited 1 time in total.

Lardo Boffin
Posts: 936
Joined: Sat Nov 26, 2016 2:42 am

Re: Smooth horizontal scrolling

Post by Lardo Boffin » Sat Dec 29, 2018 1:58 pm

Hi Bruno

I can’t see an attached file?

You could always try very simple double buffering:-

viewtopic.php?f=6&t=2372&p=25375&hilit= ... ing#p26810
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
Iss 3 ZXVid
TS 1000 iss 3, ZXPand AY, ZX8-CCB, ZX-KDLX & ChromaSCART
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Various Spectrum 48ks plus a DIVMMC future and SPECTRA

bru65pag
Posts: 20
Joined: Sun Dec 20, 2015 12:09 pm

Re: Smooth horizontal scrolling

Post by bru65pag » Sun Dec 30, 2018 11:58 am

Hi Lardo,

Thanks a bunch for your suggestion. I started to play around with your program, and wanted to get back to BASIC, so I made the following change:
- jr mainLoop
+ ld a, 0
+ in a, (254)
+ cpl
+ and %00011111
+ jp z, mainLoop
+ ret
so that I could get back to BASIC when a key is hit (keyboard testing code adapted from Bob's 8 bit blog).
I also modified the BASIC program to look like:
10 RAND USR #START
20 PRINT "BACK TO BASIC"
But never get back to the BASIC prompt after. D_FILE and DF_CC seem to be OK though, since line 20 is correctly printed at the top left corner of the screen. So what is missing to get me back to the BASIC prompt ?

One additionnal comment: it is not that important to come back nicely to BASIC, but I'm puzzled about the ZX able to work out any location for the DISPLAY FILE as long as the address is properly stored in D_FILE system variable. I even went as far as to save the original DISPLAY FILE address and restore it when existing the assembly part, but the result is the same.

For info, I'm using ZX-IDE as my compiler and EightyOne as my simulator.

User avatar
1024MAK
Posts: 2320
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Smooth horizontal scrolling

Post by 1024MAK » Sun Dec 30, 2018 4:16 pm

The area of RAM used for the display is not fixed in a ZX81, hence the ROM code has to keep a note of its current location in a system variable - D_FILE. As the CPU is used to generate the addresses used to get the data for the ULA to convert to a video signal, the rest of the hardware does not care where in RAM the display file is (the one restriction being that there must be an echo of this memory in the top of memory with address line A15 being 1).

Mark

Lardo Boffin
Posts: 936
Joined: Sat Nov 26, 2016 2:42 am

Re: Smooth horizontal scrolling

Post by Lardo Boffin » Sun Dec 30, 2018 9:19 pm

I must admit I have not tried dropping back to BASIC with the double buffering code. It may be that the code upsets some BASIC system variables.
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
Iss 3 ZXVid
TS 1000 iss 3, ZXPand AY, ZX8-CCB, ZX-KDLX & ChromaSCART
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Various Spectrum 48ks plus a DIVMMC future and SPECTRA

dr beep
Posts: 1178
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Smooth horizontal scrolling

Post by dr beep » Tue Jan 01, 2019 1:18 pm

bru65pag wrote:
Sat Dec 29, 2018 12:21 pm
Good morning,

I'm trying to do a smooth horizontal scrolling while developping a small game. The image is low-res graphic chars, and I want to shift line 16 to 24 from right to left smoothly. As can be seen in the attached file (zipped avi), this is far from smooth.

UnsmoothHorizontalScrolling.zip

Could I achieve smoothness without using some "special technique" ?

I read in the multi-scroller demo explanation that 'It has long been know that we can do a smooth horizontal scroller 2 pixels at a time ( 1 cpu clock cycle = 2 pixels ) by manipulating the number of clock cycles used before *executing* video bytes: so we might add 3 cycles = a shift to the right of 6 pixels, then on the next frame add 2 cycles = a shift to the right of 4 pixels and so on, horizontal smooth scrolling made easy...'.

After reading this, I believe that some "special technique" is needed? Could somebody explain, or point me to the explanation?

Thanks. Bruno.
You can keep the lowres but you need to split the screen in 2 halfs with an intruptroutine. I can make such a setup easily.
Inclusive scrolling.

Bukster
Posts: 35
Joined: Wed Sep 12, 2018 9:44 am

Re: Smooth horizontal scrolling

Post by Bukster » Tue Jan 01, 2019 8:49 pm

I've just uploaded a version of the game Berzerk where the screen scrolls when you exit so I have already written scroll up, down, right and left scroll routines. They are for the entire screen, but could be easily modified. Have a look at the video if you like and see if the scrolling is smooth enough for you.

Here's the source code for scrolling left the entire screen. Just add the number of lines you want to the start positions and reduce the number of lines it scrolls and it should work

SCROLL_LEFT:
;SCROLL PLAYING AREA ONE COLUMN LEFT
LD A,23
LD HL,($400C)
INC HL
INC HL
LD DE,($400C)
INC DE

SCROLL_LOOP_LEFT:
LD BC,31
LDIR
DEC HL
LD (HL),$00
INC HL
INC HL
INC HL
INC DE
INC DE
DEC A
JR NZ,SCROLL_LOOP_LEFT

RET ;SCROLL_LEFT

Post Reply