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 > Requests > Help with coding newschool routines.
2007-01-14 01:44
Conrad

Registered: Nov 2006
Posts: 849
Help with coding newschool routines.

Hi there.

Recently I have joined the c64 scene and I would like to start to learn how these new type of routines work.

As a coder, I can only manage to do old school routines such as raster bars, side border, FLD and various others. As for new routines like 3D, checkerboards, plasmas, etc... I am completely baffled with how they work, but am very eager to learn how they work.

I have in the past read various articles about demo coding, but they don't really provide the info I need.

Any volunteers to help me will be much appreciated!
Thanks, CRD.
2007-01-14 06:58
Style

Registered: Jun 2004
Posts: 498
Best idea is to jump on ircnet, channel #c-64, and corner some of the coders. They wont give you source, but they will talk about the basic theory of these effects.

That being said, wouldnt it be more fun to figure it out for yourself? Ive been coding c64 for 18 years now, and still suck because I like to figure everything out for myself.
2007-01-14 07:12
Oswald

Registered: Apr 2002
Posts: 5094
lol. he certainly wouldnt open a topic if he'd like to learn stuff by himself.

crd, you have to be more specific if you need help. tell us you want to do effect X, and you will be flooded will help.
2007-01-14 08:40
Krill

Registered: Apr 2002
Posts: 2980
Style: Why won't those coders give out sources? I give the sources of stuff i released to anybody asking. Artefacts (Artefacts) was released including source.

CRD: I learned lots and lots by just using my AR6 and peeking around the memory of various demo parts. And yes, just go to #c-64 on IRCnet and ask people. :)
2007-01-14 09:33
Radiant

Registered: Sep 2004
Posts: 639
Edit: Disregard, I should read better.
2007-01-14 09:38
Radiant

Registered: Sep 2004
Posts: 639
CRD: For 3D, there are some nice articles in C= Hacking. Also 3DICA is a nice resource for the more theoretical side of things.
2007-01-14 13:29
Oswald

Registered: Apr 2002
Posts: 5094
took a peek at 3dica, and I must say its for ppl who already have years of experience.
2007-01-14 14:40
Radiant

Registered: Sep 2004
Posts: 639
Oswald: Not really; it starts with the basic vector/matrix algebra and then works upwards from there. No knowledge is prerequisite except for a basic understanding of trigonometry and maths in general. I find it a nice complement to the more hands-on articles in for example C= Hacking.
2007-01-14 15:54
Conrad

Registered: Nov 2006
Posts: 849
Great. Thanks for all your advices guys, I'll see if this will improve my coding skills in years to come ;)

@Krill:
I myself do use AR6 to look at demo code, but this is mainly with old-school stuff at the moment.
2007-01-14 17:08
JackAsser

Registered: Jun 2002
Posts: 2014
@CRD: Good luck man. Personally I started with learning how to code a stable raster then I read the VIC-article and started bugging Krill, WVL, Graham, Oswald, Pernod and the other "established" coders. My opinion is that you code, code and code all the time. Theory won't make you a coder, u'll need practice aswell.
2007-01-14 21:18
Oswald

Registered: Apr 2002
Posts: 5094
radiantx, anyone who can do a piece of working 3d code on c64 out of that, without any serious previous knowledge in math and coding should be awarded with a nobel prize.
2007-01-15 12:31
Cruzer

Registered: Dec 2001
Posts: 1048
I think the major difference between oldskool and newskool effects is that with oldskool fx you basically just need to understand how the C64 works, and with newskool fx you also have to understand an underlying algorithm.

E.g. FLD vs RotoZoom. For FLD the algorithm is pretty simple: Move gfx up/down. Nothing to understand there, so you just need to understand how the computer (i.e. CPU and gfx chip) works.

For RotoZoom you also have to understand the algorithm of rotozooming, i.e. that you have a texture source that you look up in based on traversing some vectors, before you can start coding it. And to make a good looking rotozoomer on C64, it's also necessary to know something about some optimization techniques like loop unrolling, look-up tables etc.

So to summarize, you should learn something about:

1. How the C64 works
2. The algorithms of newskool fx
3. Optimization tricks
2007-01-15 13:13
Conrad

Registered: Nov 2006
Posts: 849
Apart from "real-time" routines, are newschool effects usually done outside the IRQ? In other words, i mean....


Set up the IRQ first...

sei
lda #$<irq
ldx #$irq>
sta $0315
stx $0314
lda #$01
sta $d01a
lda #$7f
sta $dc0d
lda #$30
sta $d012
lda #$1b
sta $d011
cli

... Then from this point location, do a loop for a typical newschool routine (e.g. 3D effect) instead of a JMP to itself?
2007-01-15 15:41
JackAsser

Registered: Jun 2002
Posts: 2014
@CRD: That's a bit generalized. :D But yes, some effects are like that for sure. To get the most performance out of a so called new school routine you really want to interleave your math code with your raster code and thus avoid IRQs and the overhead completly etc...

Use interrupts wisely, not because everyone else uses it. For example use timers where appropriate, use raster interruptes where appropritate and use busy waits where appropriate. See all the HW-goodies as your toolbox and use each and every tool where it fits best. Many people for example uses raster IRQs to do a simple scroll + logo + music which really complicates matters IMO. In those cases for the beginner it's much easier to just busy wait for the correct raster positions and do whatever you need to do.

I.e wait for the logo line and set $d011+$d018+$dd00+$d016 appropriate. Then wait for the scroll line and set $d011+$d018+$dd00+$d016 correct and then wait some more and call the music routine + do the scrolling etc..

Yeah well, you'll see what I mean once you start experiment and stop hanging on the forums (hint hint!).. :D
2007-01-15 17:14
Graham
Account closed

Registered: Dec 2002
Posts: 990
@Cruzer: What algorithms are you talking about? 90% of all newschool effects are simple movelists which are less algorithm than moving a rasterbar over a rasterbar background.
2007-01-15 21:01
Cruzer

Registered: Dec 2001
Posts: 1048
@Graham: By algorithm I mean how the effect works. Yes, lots of effects can be implemented with simple stuff like lda lut,x / sta screen, but there is still some underlying math and stuff needed for generating the LUT's and the routine.

Also for stuff that's not necessarily very hardcore mathematical, like plasma, it takes a little understanding of the nuts'n'bolts of the routine before you're able to make a nice looking plasma on the C64. I guess the best way for a newbie to get this kind of understanding is to play around with some of these effects in a high level language on a modern machine.
2007-01-15 21:17
Scout

Registered: Dec 2002
Posts: 1570
Quote:
I guess the best way for a newbie to get this kind of understanding is to play around with some of these effects in a high level language on a modern machine.


True dat.
I learned that stuff back in the days on the pc coding it in Pascal and C.
(A cpu with MUL's and DIV's in the assembler opcodeset also helped a lot ;-P)

Also a lot of the magic in (newskool) effects happens in precalced tables.
2007-01-17 09:49
Oswald

Registered: Apr 2002
Posts: 5094
Quote: I think the major difference between oldskool and newskool effects is that with oldskool fx you basically just need to understand how the C64 works, and with newskool fx you also have to understand an underlying algorithm.

E.g. FLD vs RotoZoom. For FLD the algorithm is pretty simple: Move gfx up/down. Nothing to understand there, so you just need to understand how the computer (i.e. CPU and gfx chip) works.

For RotoZoom you also have to understand the algorithm of rotozooming, i.e. that you have a texture source that you look up in based on traversing some vectors, before you can start coding it. And to make a good looking rotozoomer on C64, it's also necessary to know something about some optimization techniques like loop unrolling, look-up tables etc.

So to summarize, you should learn something about:

1. How the C64 works
2. The algorithms of newskool fx
3. Optimization tricks


the philosophical difference between oldskool and newskool, is that oldskool aims to show stuff that looks hardware wise impossible, while newskool is wannabee pc/amiga copies :D
2007-01-17 10:24
JackAsser

Registered: Jun 2002
Posts: 2014
@CRD: I must appologize... I have misread your question all the time. I though you asked how to code OLDSCHOOL routines, not new school. :D We can ofcourse help you with coding new school routines aswell. But the definitions of new school and old school varies from person to person so it would be more simple if you simply tell us what particular routine you do not understand and then we simply help you by explaing how that particular routine works.
2007-01-17 11:13
Conrad

Registered: Nov 2006
Posts: 849
Quote: @CRD: I must appologize... I have misread your question all the time. I though you asked how to code OLDSCHOOL routines, not new school. :D We can ofcourse help you with coding new school routines aswell. But the definitions of new school and old school varies from person to person so it would be more simple if you simply tell us what particular routine you do not understand and then we simply help you by explaing how that particular routine works.

@Jackasser: No harm done :-)
Well, if you insist of helping a bit, I was wondering how bitmap stretchers/zoomers and colour effects such as raster-benders would work.
BTW, if you don't like discussing raw code or algorithms on the forum, I'll go on IRC instead, as mentioned.
2007-01-17 14:13
Graham
Account closed

Registered: Dec 2002
Posts: 990
Quote: the philosophical difference between oldskool and newskool, is that oldskool aims to show stuff that looks hardware wise impossible, while newskool is wannabee pc/amiga copies :D

But how does this fit with DYCPs, Plotroutines, Linevectors being counted to oldschool?
2007-01-17 14:39
Oswald

Registered: Apr 2002
Posts: 5094
dycps, plotters, liners are middleskool :P ;)
2007-01-17 15:00
Cruzer

Registered: Dec 2001
Posts: 1048
Oldskool/newskool is definitely too simple. In my view there has been 4 major "skools" in the C64 scene history:
- CracktroSkool: The first demos were clearly very inspired by cracktros with scrolls, swinging logos and rasterbars. With time these effects progressed into more complex versions, e.g. DYCPs instead of normal scrollers, tech-tech instead of a swinging logo, rastersplits instead of a normal rasterbar, etc.
- AmigaSkool: The next step was trying to convert effects known from Amiga, such as filled vector, vectorballs and plasma to C64.
- PCskool: RotoZoomers, bumpmapping, texturemapping, etc.
- ArtSkool: Who cares about routines, it's the message/story of the demo that counts.
2007-01-17 15:07
Scout

Registered: Dec 2002
Posts: 1570
Quote:
- ArtSkool: Who cares about routines, it's the message/story of the demo that counts.


But also the use of *skool effects in a creative/other way.
2007-01-17 15:37
Oswald

Registered: Apr 2002
Posts: 5094
cruzer, I'd stick a crest/dutchbreezeskool between crackskool and amigaskool ;)
2007-01-17 15:44
Cruzer

Registered: Dec 2001
Posts: 1048
@Scout: True, just trying to simplify it :)

@Oswald: True, especially DutchBreezeSkool. Maybe you could call it early artskool though, since artskool is also about "slideshows are demos too". CrestSkool I don't know about. Basically Crests demos have always been CracktroSkool and then later evolving into ArtSkool.
2007-01-17 20:01
Optimus

Registered: Jan 2002
Posts: 122

* You just need to start a PC compiler with some nice and easy to use library that gives you a software buffer to experiment and learn how effects work (I suggest DevC++ with either SDL or TinyPTC(Maybe you can get both from devpaks especially packaged for DevC. If you don't know C, there is Freebasic which is rather fast for a basic compiler and has SDL/TinyPTC or it's own gfx lib integrated (search for FBide to get the whole package)).

* Then get some tutorials. The most easy concepts to understand and start with is Plasma or Fire effects I think. Then, sine image distortion. Then, maybe zoom and rotate. Then, the other stuff (bump, tunnel, floor, sphere mapping, water, radial blur, blobs, etc.).

* Still, you won't be able to make the effects run fast enough on the C64 without getting some insight in what clever speedcodes (aka unrolled code, movelists, etc.) to generate. But that's for later. First get a grip on how some things works..

p.s. It's ironic to me that I went on through the opposite way than most people do. When I started with democoding on 8bits (CPC and later C64), I remember I was scared of oldschool stuff because of the excessive timing and hardware tricks involved, thus I had to learn a lot new stuff. I was more experienced before in mid/newschool pixel effects (because of trying to meme PC demoeffects in Quickbasic ;) and I just needed a software buffer to do stuff, so my first demo on the CPC was displaying fires and plasmas which was unique though for the CPC scene who was doing mostly hardware fx demos :P
2007-01-17 20:39
Optimus

Registered: Jan 2002
Posts: 122
Mmm,. I can hardly find some central site with tutorials on demo effects atm.

More help and thoughts:

I once tried to devide the effects on some diferrent categories according to the way pixel manipulation is happening. In most of them you need to move serially through the pixel buffer and follow a simple and the same logic for each pixel, so it's quite simple at the end and you don't even need to wipe out the background because the next frame does this.

I'll write the diferrent logics in brief here for inspiration of the basic ideas:

1) Color = F(x,y) or Color = F(angle, radius)

For each pixel, the color is a function of it's coordinates. In cartesian coordinates (X,Y) if the function has sines/cosines in it, you will get plasmas (Nice tutorial to get the visual mathematician connection of it). If the function is based in polar coordinates (Angle and radius of a pixel from the center of the effect) you get polar plasmas (swirls, radial stuff, check my tutorial with screenshots and functions here). And many more you can get if you try strange stuff..

2) Color = Bitmap[U,V]
where U = F(x,y) and V = G(x,y)

For each pixel, the color is taken from a Bitmap and from it's pixel with coordinates (U,V), which are being calculated from functions of the actual X,Y pixel on the effect screen. It's like for each pixel you render corresponds a pixel from the bitmap. Rotozoomers, tunnels, sphere mapping, floors, etc. In some of them, you can create huge speedcodes for every pixel, with precalculated correspondance to another side of the memory where the texture is. All you just need is to make it work on the compiler and know which maths generate what you want to show, then how to generate from those data the unrolled codes later on the C64. Then either by scrolling the texture or increasing some pointers (depending on the unrolled codes or size of the texture), you can have some cool effects going on (I once called this, static mapping). Rotozoomer is a bit diferrent than tunnels/sphere/floor in this aspect, but similar in the rendering concept.

3) Filters. For fire effects and other stuff. In short, you have a gradient pallete (where 255 is some bright color, and it fades to some dark color till zero). If you have bright values in your fire buffer and for each pixel you take the average of the around pixels: Pixel(x,y) = (Pixel(x-1,y) + Pixel(x+1,y) + Pixel(x,y-1) + Pixel(x,y+1)) / 4, you can easilly imagine what will happen (but test it in the compiler). The bright colors blur to the black background. Water is also happening via some filter, unlike it didn't seemed like this.

4) Other effects I haven't categorized. Fractals, blobs, bump, etc.

5) 3D is a whole new world and I can hardly think how to optimize stuff for 8bits atm (And that low precission of bits ;P). Maybe something I'll still have to research a lot. But you can check some nice tutorials just to get an idea of how things works on the PC compiler.

Also:
Nice whirlpool tutorial specifically for C64 (Features speedcode generation)

Old page with lot's of good tutorials, check the 2d effects for a start
2007-01-18 00:06
Conrad

Registered: Nov 2006
Posts: 849
@Optimus:
Well, that is CERTAINLY a huge amount of info you have provided (probably too much ;) but it sure is useful! Thanks for helping :-)

Oh and as for C/C++ ...I'm quite an expert with that language, although I haven't used it for effects which involve advanced mathematics.

Anyway, thanks again.
2007-01-18 09:18
Oswald

Registered: Apr 2002
Posts: 5094
CRD, I advise you to read all that stuff including the links, _very_good_ infos to understand the basic ideas behind the newschool effects. On how to optimise them on c64 ask us here or at #c-64.
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
Mike
Peacemaker/CENSOR/Hi..
MWR/Visdom
DeMOSic/MS^LSD^ONS
Magic/Nah-Kolor
rambo/Therapy/ Resou..
Raf/Vulture Design
icon/The Silents, Sp..
Ax!s/Onslaught - TND
iAN CooG/HVSC
Chesser/Blazon
Guests online: 96
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 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (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 Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

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