Schrijver
| horizontal scrolling
|
norakomi msx professional Berichten: 861 | Geplaatst: 03 April 2005, 05:29   |
What way of smooth horizontal scrolling is used a lot? (games like gradius/spacemanbow?)
horizontal scrolling, from register 26 (H8-0 - Scroll screen horizontal)
.....is this often used?
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 03 April 2005, 05:30   |
BASIC
VDP() reg 7 6 5 4 3 2 1 0
0 0 0 DG IE0 IE1 M5 M4 M3 D
1 1 0 BLK IE2 M1 M2 0 SZ MAG
IE0 - Vertical Retrace Interrupt Enable
IE1 - Horizontal Retrace Interrupt Enable
and what are these interrupts for????
I experimented a bit and it seems that if you disable them to long the computer crashes
???????????????????????????????????????????????????????????????????????
|
|
Grauw msx professional Berichten: 1006 | Geplaatst: 03 April 2005, 12:33   |
On MSX2+ (v9958 chip) registers 26 and 27 are used for horizontal scrolling.
On MSX2 (v9938 chip), the adjust register (18) is used for scrolling small bits to the left and right (similar to register 27), and the scrolling of the large bits is done by copying. In the case of Space Manbow e.g. it is using screen 4 to scroll in 8 pixel units, and register 18 to scroll in pixel units - EXCEPT on MSX2+, where it uses register 27 to get a slightly better-looking scroll (no clipping borders).
~Grauw
p.s. note that in MSX-Basic, register numbers above register 7 need to incremented by 1. Register 18 is VDP(19), etc.
|
|
Grauw msx professional Berichten: 1006 | Geplaatst: 03 April 2005, 12:35   |
IE0 is the standard interrupt, which occurs 50 or 60 times/second, depending on the refresh frequency. Disabling it temporarily will do nothing really harmful, but stuff like reading the keyboard won’t be updated, so once you do something that is depending on the standard interrupt, it won’t work (and could potentially crash). It is a nice means however to disable and re-enable the VDP interrupts in Basic, where you don’t have easy access to the assembly DI and EI instructions.
IE1 is the line interrupt, used to make screensplits. If you enable it, but don’t have a handler for it in place, it will cause an infinite loop and crash your computer. You cannot make a handler using Basic.
~Grauw
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 04 April 2005, 20:28   |
Can I use this interrupt to disable screen output, so I can scroll horizontaly 1 pixel to the left (register (18)) and then replace my characters(1 pix to the right), and thén enable screen output again?
why this question: when I scroll one pixel to the left using register 18, all my characters have to be placed one pixel to the right at the same time.
however doing those 2 actions at the same time is not possible, meaning that I can make a nice backgroundscroll, but all my characters will be rapidly moving 1 pixel left and 1 pixel right every time the background scrolls.
this looks ugly..... is there a way to prevent this.
For instance:
is it possible to scroll page 0 in screen 5 horizontaly with r18 while I am in page 1, and then switch to page 0, and scroll in page 1
in other words... is it possible to independantly scroll different pages in screen 5?
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 04 April 2005, 20:33   |
Quote:
| In the case of Space Manbow e.g. it is using screen 4 to scroll in 8 pixel units, and register 18 to scroll in pixel units -
.
|
how can I scroll with 8 pixels at the same time on a V9938 in screen 4??
and how is it possible that you don´t see the scrolling at the edges of the screen (you do see them however in Rumsx emulator !!)
|
|
Grauw msx professional Berichten: 1006 | Geplaatst: 04 April 2005, 22:03   |
Screen 4 is a pattern mode with 8x8 tiles, so moving the entire screen 8 pixels to any direction is a matter of moving 832 bytes (as opposed to 27136 bytes in e.g. screen 5), and therefore feasible.
Not noticing the scrolling at the edges of the screen (I guess what you mean here is that there are no flipping borders?) is as I said most likely due to the MSX having a v9958 VDP which can automatically mask the flipping edge by simply setting a bit in one of its registers. It is also possible to mask the flipping with sprites, but Space Manbow doesn’t use that and it is also questionable whether that would be worth the effort.
~Grauw
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 05 April 2005, 18:33   |
What about this:
I have 5 characters in screen 5 page 0 and a background.
I want to scroll the background (but not the characters, they are not moving) one pixel to the left.
What if I first paste all the characters in 1 pixel to the right in page 1.
Can I then switch to page one and scroll the screen 1 pixel to the left,
without making visible that the characters move?
|
|
Edwin msx professional Berichten: 626 | Geplaatst: 05 April 2005, 21:33   |
It's possible, but not feasable. It's a waste of valuable time. If you want to do something like that, do it with sprites.
|
|
Grauw msx professional Berichten: 1006 | Geplaatst: 05 April 2005, 22:42   |
That’s possible. Software sprites are just as slow as usual though, and although that often is not a problem, when you scroll per-pixel it needs to be smooth (=fast enough to reach 60 or perhaps 30 frames per second) for it to look good. So because of that it might be a little problematic, as software sprites need to first restore the background, then copy them to the new location with a (slow) LMMM copy.
Though on MSX2+ using the scroll registers it wouldn’t be a big problem, it is fast enough for that (as long as the characters aren’t too big). But when using Basic, it probably will be difficult...
As Edwin said, sprites are easier, all you need to do for those is update their coordinates.
~Grauw
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 08 April 2005, 23:53   |
Another question:
Lets take this example.
there is a background in page 0, screen 5
the same background is in page 1
there is a software sprite at (100,100)
now i want to scroll the screen 1 one pixel to the left (hor.scr. reg).
However I do not want to scroll the softwaresprite on pixel to the left.
If I scroll the screen 1 pixel to the left and then place the softwaresprite 1 pixel to the right this will look messy..... how can this be prevented???
and I have the same question for normal sprites.
|
|
Edwin msx professional Berichten: 626 | Geplaatst: 09 April 2005, 00:38   |
Place the sprite one pixel to the right when you scroll the screen 1 pixel to the left. And time it well so it won't show.
|
|
Grauw msx professional Berichten: 1006 | Geplaatst: 09 April 2005, 12:19   |
You have to swap to the other page and scroll both at the same time, within the same frame display.
This should really be done in the vertical blank period for it to look good, that is, after the VDP finished drawing line 211 and before it starts drawing line 0. Note that the VDP generates the regular interrupt when it finishes drawing line 211, so it's easiest to just change it on the interrupt.
I dunno how fast ON INTERVAL is in Basic, but you might be able to use that - if it's too slow, you might want to use a small assembly interrupt routine instead which takes the page no. and scroll offset from a certain memory address, and changes both registers when the page no. changes (so in Basic, set the scroll offset first, then the page no, and only then will they both be updated the next time the VDP is in its blanking period).
~Grauw
|
|
norakomi msx professional Berichten: 861 | Geplaatst: 11 April 2005, 21:25   |
Quote:
| This should really be done in the vertical blank period for it to look good, that is, after the VDP finished drawing line 211 and before it starts drawing line 0. Note that the VDP generates the regular interrupt when it finishes drawing line 211, so it's easiest to just change it on the interrupt.
|
Are you talking about the V-Blank Interrupt in register 1 (bit 5)?
does this mean the IE0 bit wil be set?
so I should make a little routine in assemble which waits until this bit is set,
and then switch page ánd immediately after that scroll the screen?????
or are you talking about register 0 bit 4 H-Blank Interrupt ?
|
|
Edwin msx professional Berichten: 626 | Geplaatst: 11 April 2005, 22:53   |
Ok, back to basics.
When VDP generates the picture on the screen, it does that line by line. After the end of a line is reached, there is a small delay before the next line is started. This is the horizontal retrace period. During this period, the HR flag in status register 2 is set.
This goes on for all displayed lines. If at some point the screen reaches the line number set in R#19, then FH flag in status reg 1 gets set as well. Also, if IE1 is set, at interrupt is generated in the z80 (which causes the interrupt handler to be started if interrupts are enabled).
When the last line of the screen is finished, there is a long delay before the the process starts again at the top of the screen. This is the vertical retrace period. During the period the VR flag in status register 2 is set. Also, if IE0 is enabled, the F flag in status register 0 is set and an interrupt is generated.
This is basically what makes all the magic possible. But remember that because this stuff is all tied to the screen output, everything is realtime. Meaning that screen output continues while you are processing everything. However, this is exactly the reason why you can use it for practically everything.
I hope this clears things up a bit.
|
|
|
|
|