Hi,
After learning how to put pixels in the screen, I want to write an small example of double buffering and how to do an smooth scrolling.
I'm using the MODE 4, 256x192, and two pages for the screen data. The first one from $0200 to $19FF, the second one from $1A00 to $31FF.
My idea is to put some basic tiles in the same row and then move down and up. It writes to the page which isn't been displayed and then switch to it, so I can get an smooth scrolling.
However, I think that sometimes it flickers because I'm not doing anything related to vertical sync. I haven't found info about that, so any help will be appreciated. I think I have to check the register at $FF03, but I'm not sure.
I attach the source code (and the .cas file) so you can take a look at it.
Regards
Smooth scrolling
Smooth scrolling
- Attachments
-
- simplescroll.zip
- (2 KiB) Downloaded 392 times
Re: Smooth scrolling
Hi kan.
Try adding the SYNC instruction just before switching your display's base address.
This should cause processing to wait until an interrupt is encountered, keeping you in sync with the vertical refresh.
Try adding the SYNC instruction just before switching your display's base address.
This should cause processing to wait until an interrupt is encountered, keeping you in sync with the vertical refresh.
Re: Smooth scrolling
Hi kan, great to see you've figured out the double buffering!
As Bosco said, the sync instruction will wait for the vertical retrace.
I think there may also be a small bug. You have in a couple of places the instruction cmpa $00, where I think you may have intended cmpa #$00. If you change these then it fixes the flickering.
As Bosco said, the sync instruction will wait for the vertical retrace.
I think there may also be a small bug. You have in a couple of places the instruction cmpa $00, where I think you may have intended cmpa #$00. If you change these then it fixes the flickering.
Stew
Re: Smooth scrolling
Hi,
Regards!
I think the SYNC instruction waits until any interrupt is encountered, but I think I need something more to know if it was the vertical refresh.Try adding the SYNC instruction just before switching your display's base address.
This should cause processing to wait until an interrupt is encountered, keeping you in sync with the vertical refresh.
Yes, you're right. I fix it, altough it's still flickering.I think there may also be a small bug. You have in a couple of places the instruction cmpa $00, where I think you may have intended cmpa #$00. If you change these then it fixes the flickering.
Regards!
Re: Smooth scrolling
There's a lot of truth in that statement but generally you use SYNC when you know which interrupt is coming next and in the specific case of the Dragon, the frame sync irq is usually the only active interrupt.kan wrote:I think the SYNC instruction waits until any interrupt is encountered, but I think I need something more to know if it was the vertical refresh.
The other interrupt sources are: horizontal retrace (usually disabled); printer ack (usually disabled); cartridge (enabled but nothing happens without a cartridge); NMI (also comes from external hardware)
I added a sync instruction and corrected the cmpa instructions in the attached file. It doesn't flicker when I try it.
- Attachments
-
- simplescroll.zip
- (1.11 KiB) Downloaded 392 times
Stew
Re: Smooth scrolling
Hey there,
looks pretty good....
you can do away with your cmpa #0's you know ?
/Simon
looks pretty good....
you can do away with your cmpa #0's you know ?
/Simon
Re: Smooth scrolling
Hi,
However, I write a new version of the simple scroll program. I remove all the "cmpa #0" as Simon suggested... The 6809 is a great CPU when you learn well their instructions
Also, I tried something that I read elsewhere. I reduce the loops of cleaning the screen and putting the tiles, repeating the same instructions, such as:
It has less opcodes so it's faster, altough the code looks worse
Regards
Ok, thanks for the info. So SYNC should work in a controlled but the most common case.There's a lot of truth in that statement but generally you use SYNC when you know which interrupt is coming next and in the specific case of the Dragon, the frame sync irq is usually the only active interrupt.
The other interrupt sources are: horizontal retrace (usually disabled); printer ack (usually disabled); cartridge (enabled but nothing happens without a cartridge); NMI (also comes from external hardware)
I tried your version, using XRoar, and I'm still getting the flicker when the tiles are in the beginning of the screen. Have you used the emu or running directly in a Dragon computer? Maybe I have anything pre-configured in my XRoar which makes other interrupts active.I added a sync instruction and corrected the cmpa instructions in the attached file. It doesn't flicker when I try it.
However, I write a new version of the simple scroll program. I remove all the "cmpa #0" as Simon suggested... The 6809 is a great CPU when you learn well their instructions
Also, I tried something that I read elsewhere. I reduce the loops of cleaning the screen and putting the tiles, repeating the same instructions, such as:
Code: Select all
; *********************************************
; PCLS: Clear screen
; *********************************************
PCLS PSHS X
LDY #TEMPTY
LDA #192
LDU ,Y
PCLSLOP STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
STU ,X++
DECA
BNE PCLSLOP
PULS X,PC
Regards
- Attachments
-
- simplescroll_v2.zip
- (2.03 KiB) Downloaded 376 times
Re: Smooth scrolling
check if xroar is configured for PAL or NTSC !
SPEED IS NOT ABOUT NICE LOOKING CODE !
/Simon
SPEED IS NOT ABOUT NICE LOOKING CODE !
/Simon
Re: Smooth scrolling
Hi Simon,
Yes! I chose "PAL 60 Hz" and then there isn't any flickering. Thanks guys for your help.
Next post will be an (again) enhanced version for the simple scroll example.
Regards
Yes! I chose "PAL 60 Hz" and then there isn't any flickering. Thanks guys for your help.
Next post will be an (again) enhanced version for the simple scroll example.
Regards