jchase1970, on Sat Aug 14, 2010 10:04 PM, said:
How are you scrolling the clouds? I assume some kind of bit operation on the characters. I have been trying to work something like this out but haven't had it working right and now time is tied up with work for a couple of month so have to spend what time I have on stuff I need to finish for the TI, new problem solving will have to wait.
John
Overall I personally went through 4 stages.
1)
I never programmed this.
Take a byte from VDP RAM, shift one bit to the left, save that byte to VDP RAM.
Realising I have to get the bytes from the right side of the screen. Any bits shifted out of the byte (a register) into the Carry (status register) would be set for the next shift, moving from right to left, which might then be subtracting 8 to go to the same line in the next characters.
If this does not make sense, I'll try and do some sketches later, and finally I should be able to polish some code and publish.
2)
Take a byte from CPU ROM, shift a number of bits to the left, save that byte to VDP RAM.
Same principle as in first version. The number of bits to shift is a register counting from 0 through 7. I'm basically still wanting to scroll the screen left one bit at a time. I guess the graphical inspiration was Parsec. I used this in my Hellraiser demo.
Also I was thinking that full speed is moving left one pixel every frame update. If I wanted the scroll to be slower I just call the routine every 2nd or 3rd frame etc.
3)
This method was not fully optimized, but it's working and running nicely.
Take 2 bytes from CPU ROM, shift a number of bits, save a byte to VDP RAM.
I want to like stamp the entire cloud wherever I want. I use one major scroll register. If the cloud is like 512 pixels wide (of course only showing like 256 pixels on screen), this register is going to hold a value between 0 and 511. The 2 bytes to be taken are arranged side by side in CPU ROM. The source is like strips, destination has to be character oriented. Just going from left to right through the characters fixed on screen that make up the cloud and manipulating the patterns. Utilizing auto increment with VDP.
The scroll register is actually fixed point. The upper bits containing the value to use in the scroll routine, the lower bits being like decimals or numbers after the decimal point, though this is binary calculations. The point is not between the bytes in the word (making up the register). Let's say that the position between the bytes are 7 (counting from 0 through 15 right to left). The position I'm using then is 6. I only have to modify and decipher the scroll register once or every second frame update to get good overall scrolling.
If the scroll register is the same (ignoring the bits after the point) as before (last update), then no scroll is done.
4)
Since scrolling relatively takes a lot of time, I thought about only doing parts of the scroll every frame. What I found important to get realistic clouds or actually emulating the Parsec scroll, was to do this in a vertically manner instead of my first approach, which was horizontal. The latter made the graphics split in half often (horizontal stripes). Vertically approach make clouds shrink and expand like one pixel horizontally. Almost like viewing higher detailed clouds through a matrix (if we're being very, very nice about it and it's moving slowly and steadily (it doesn't have to)).
This is working, but still it's draft and needs optimizing and polish. As I said I will be trying to do some nice sketches to illustrate.
I'll refactor and do VDP writes using register indirect. I should be able to keep all game control in Scratchpad, so I won't move inner scroll routine to that area. I don't see any "roll out" tweaks(/tricks) yet. I'm still not sure how much any of this will help on the real hardware (and I don't even have any to test on). But I'm guessing between 10 and 200 percent increase in performance (I think Paul Urbanus said 20 percent increase for Parsec).
Movement of the subs (not sprites) is a completely different story - though it is "scrolling" also. It hasn't been fully explored yet. And there's a dark shadow of collision detection lurking here.
Edited by sometimes99er, Sun Aug 15, 2010 1:42 AM.