Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Screen copy CPU intensive
2007-09-21 20:17
johncl

Registered: Aug 2007
Posts: 37
Screen copy CPU intensive

I am working on a little game for the C64 and have stumbled upon a slight problem. A smooth scroller is darn CPU intensive! Its a simple sidescroller where I want to scroll the upper 18 lines. The copy required to move the character and color ram is very expensive! I use kickassembler and at first I tried this:

.macro ScrollLines(screen,from,to) {
.var half = round([to-from]/2)
ldx #0
jmp !loop+
.align $100
!loop:
.for (var i=from;i<from+half;i++) {
lda screen+1+[i*40],x
sta screen+[i*40],x
lda SCREEN_COLOR+1+[i*40],x
sta SCREEN_COLOR+[i*40],x
}
inx
cpx #39
bne !loop-
ldx #0
jmp !loop+
.align $100
!loop:
.for (var i=from+half;i<=to;i++) {
lda screen+1+[i*40],x
sta screen+[i*40],x
lda SCREEN_COLOR+1+[i*40],x
sta SCREEN_COLOR+[i*40],x
}
inx
cpx #39
bne !loop-
}

So here I unroll a full column copy in two parts (because bne wont work if I unroll whole column). This even aligns the two loops so that the bne doesnt cross any page boundaries and end up costing another cycle. But still, this routine eats up my CPU big time.

I then tried a complete unroll of a pure copy:

.macro ScrollLines2(screen,from,to) {
.for (var i=from*40;i<=to*40;i++) {
lda screen+1+i
sta screen+i
lda SCREEN_COLOR+1+i
sta SCREEN_COLOR+i
}
}

This also copies the unecessary column too that I need to copy from my map data. But this complete unroll uses almost 2/3 of the screen raster time! Even with this I have to split up my copy so the top part is copied at the bottom redraw of the refresh and the bottom part on start of next screen refresh.

Am I doing something wrong here?
 
... 25 posts hidden. Click here to view all posts....
 
2007-09-22 21:22
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quote: I don't know how much you need leftover rastertime, but I just want to mention that games like Turrican I/II/III do up-to-4-pixels-per-frame scrolling without unrolling either the screen or color copy routine. An example:

frame 1: shift screen data in hidden buffer
frame 2: shift color data, split in two halves
frame 3: repeat above...


I'm amazed they had raster time left to do anything useful after that. Having to waste almost half the frame just on scrolling isn't exactly encouraging.

Of course they weren't full screen but still..
2007-09-22 21:55
raven
Account closed

Registered: Jan 2002
Posts: 137
I still havent seen any machine crash by running VSP, be it C64, C64C, C128 or SX64.

Is it verified that RAM refresh causes it?
2007-09-22 22:03
chatGPZ

Registered: Dec 2001
Posts: 11386
no, the actual cause is pretty much unknown. ram-refresh glitches is just the most popular guess :)
2007-09-22 22:20
cadaver

Registered: Feb 2002
Posts: 1160
Doynax: also notice the special "hell elevator" scene in Turrican II where you drop 8 pixels per frame :) *That* at least must consume all rastertime available..
2007-09-22 22:30
Hein

Registered: Apr 2004
Posts: 954
Quote: no, the actual cause is pretty much unknown. ram-refresh glitches is just the most popular guess :)

Guess??? wtf.. Graham guesses his way through life?
2007-09-23 00:31
TDJ

Registered: Dec 2001
Posts: 1879
Quote: Guess??? wtf.. Graham guesses his way through life?

Suddenly all those demos he did lose a lot of their meaning :(

"He never meant that effect to happen, he just typed some code and hoped for the best!"
2007-09-23 00:37
chatGPZ

Registered: Dec 2001
Posts: 11386
thats how a lot of demos were made probably =)
2007-09-23 07:05
AüMTRöN

Registered: Sep 2003
Posts: 44
Quoting doynax
Anyway, here's the proof-of-concept demo: http://www.minoan.ath.cx/~doynax/6502/Balls%20of%20the%20Scroll..
(I know it isn't all that fancy but I'm a novice when it comes to VIC hacking so I'd like to pretend I invented a new graphics mode ;)


Nice demo, I liked it a lot. I guess your enemy formations lend themselves to "simple" multiplexing, but I still like a lot of moving objects no matter how its done. Good work! :D
2007-09-23 08:41
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quoting cadaver
Doynax: also notice the special "hell elevator" scene in Turrican II where you drop 8 pixels per frame :) *That* at least must consume all rastertime available..
Meh.. It seems like that whole game is built around a huge number of special case hacks.

Quoting MTR1975
I guess your enemy formations lend themselves to "simple" multiplexing, but I still like a lot of moving objects no matter how its done.
To be honest that's more of a symptom of lazy level design than a special purpose multiplexer. There should be room for a few sprites left to play with actually, especially if you synchronize the players' bullet streams and allow the occasional glitch.
2007-09-23 11:28
johncl

Registered: Aug 2007
Posts: 37
Quote: I don't know how much you need leftover rastertime, but I just want to mention that games like Turrican I/II/III do up-to-4-pixels-per-frame scrolling without unrolling either the screen or color copy routine. An example:

frame 1: shift screen data in hidden buffer
frame 2: shift color data, split in two halves
frame 3: repeat above...


This is assuring to read. I see that unrolling the loops take a lot of memory which I really want to use for compressed level data instead. I'll probably unroll whole columns at least to free as much raster time as possible. Since I need a different loop per frame and one per direction a big unroll would have left me with scraps.

While I am at it (and sorry for the noobish questions here as I am quite new to the C64 after all these years): I have been able to turn off Basic ROM since that is not needed to free 8kb of memory. But is there more rom memory I can "get under"? I seem to recall that I should be able to write to char rom at $d000-$dfff but reading this I guess requires me to turn off that rom somehow? And the RAM under the kernal rom at $e000-$ffff - Is there any way I can use that? I guess I just need to avoid using kernal functions or will turning it off ruin stuff like raster interrupts etc? Again sorry for the noob questions.

Today I basically use the kernal for reading the keyboard to eg start the game or enter name in hiscore list. But maybe if I could store compressed level data there, turn it off, unpack to current level ram and turn it on again I will be ok? It would have been nice to use all the ram I can use.

Also one final question. Zero page addresses, which can I use for my own programs without messing anything up? I guess I can use any spot that is typically used by basic at least in addition to the end bytes that are reserved for apps?
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
morphfrog
Slator/Arsenic/Stone..
Thierry
Guests online: 127
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.05 sec.