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 > Good coding practices ?
2009-02-19 02:43
Warlock Arkhinos Ratazmus
Account closed

Registered: May 2004
Posts: 23
Good coding practices ?

A few little points.

-I almost always coded my programmes to CRASH on NTSC systems, so when people say my code's bugged - you know it's not at all :D

-I posted on Lemon64 a few years back about using a coding convention whereby you reduce the use of bits, eg: use AND #$00 instead of LDA #$00, and after a jsr $e544 (I think, clear screen) the X-reg always was set to 1 on any 64 box I used - so i'd use that to setup interrupts. Somebody said that using less bits in the opcodes does'nt make the programme pack better ... heh right - you might want to check that.

I'm still coding for optimising - old habit I guess.
 
... 5 posts hidden. Click here to view all posts....
 
2009-02-19 09:13
Frantic

Registered: Mar 2003
Posts: 1648
If you wanna size-optimize, you should use a well written forth compiler, which actually represents most stuff in a more compact way compared to asm... ;)
2009-02-19 09:19
chatGPZ

Registered: Dec 2001
Posts: 11386
the question remains: how can i squeeze bits out of my opcodes?
2009-02-19 09:46
Warlock Arkhinos Ratazmus
Account closed

Registered: May 2004
Posts: 23
My bad - curse of Apsergers (please look it up!), plus writing at some silly time in the morning does'nt help.

I tended to use the kernel vector to clear the screen before turning off the kernel as using that at the very beginning means I did'nt need to write the clear-screen loop.

eg; (off the top of my head, not done this for a decade)

sei
jsr $e544
stx $d019
dex
stx $01
stx $00 ;Used to check for Action Replay later
stx $d020
stx $d021
lda #$7f
sta $dc0d
and #$1b
sta $d011

etc.etc.etc.

Okay - I know the code is "less readable" this way, but I found that it compressed a lot better.

... proof you say ? Shazbar ! I'd need to code in 6502 again ! However, if you take it as read that the closer a file is to total entropy, the less it can be compressed - then checked the entropy of files using/not using bit-reduced code, then you'd see what I meant. Which is pretty much true :D

QUICK EDIT:
Normaly, 10 years ago before I knew I had Aspergers, i'd go off on one and start calling people names etc. But as I know i've got it - it gives me something to think about before replying and realise that nobody is really "having a go at me", just asking me to validate my claim.

Damned - where did all that anger go ? Or is it the pile of sedatives i'm on ? heh.

Oh, and if anyone wants an optimised PAQ8A variant for Intel CPU's - gimmie a shout ;)
2009-02-19 10:36
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: My bad - curse of Apsergers (please look it up!), plus writing at some silly time in the morning does'nt help.

I tended to use the kernel vector to clear the screen before turning off the kernel as using that at the very beginning means I did'nt need to write the clear-screen loop.

eg; (off the top of my head, not done this for a decade)

sei
jsr $e544
stx $d019
dex
stx $01
stx $00 ;Used to check for Action Replay later
stx $d020
stx $d021
lda #$7f
sta $dc0d
and #$1b
sta $d011

etc.etc.etc.

Okay - I know the code is "less readable" this way, but I found that it compressed a lot better.

... proof you say ? Shazbar ! I'd need to code in 6502 again ! However, if you take it as read that the closer a file is to total entropy, the less it can be compressed - then checked the entropy of files using/not using bit-reduced code, then you'd see what I meant. Which is pretty much true :D

QUICK EDIT:
Normaly, 10 years ago before I knew I had Aspergers, i'd go off on one and start calling people names etc. But as I know i've got it - it gives me something to think about before replying and realise that nobody is really "having a go at me", just asking me to validate my claim.

Damned - where did all that anger go ? Or is it the pile of sedatives i'm on ? heh.

Oh, and if anyone wants an optimised PAQ8A variant for Intel CPU's - gimmie a shout ;)


"Damned - where did all that anger go ? Or is it the pile of sedatives i'm on ? heh". Part of the growing up process, we all passes through those phases. :)
2009-02-19 18:34
Warlock Arkhinos Ratazmus
Account closed

Registered: May 2004
Posts: 23
I'm actually proud that I tried to think before posting.

Part of it is growing up I guess - when I see my daughter play up like today, I have to think "ah crap, Karma !". The daddy side of me was upset that she was throwing things at people in the street - and part of me was "YEAH - YOU GO GIRL !!!". She does'nt get to see that side - but I know EXACTLY what she's going through as she's autistic too. Yeah, Karma !

Hey - if you think i'm a bad then you should see the caterpillar Ironfist has on his head :P I mean mohawk ;)
2009-02-22 05:01
Martin Piper

Registered: Nov 2007
Posts: 722
Good coding/development practices? In no particular order...

Making code easier to read by commenting it and formatting it well.

Adding documentation, the goal being that if the coder fell under a bus then someone else could pickup the project.

Optimising code.

Revision control of all source and assets.

Maintain distinct reusable modules. This means writing something once, testing it then using it many times to avoid unnecessarily repeating work.

Unit tests. (Automatic preferred or manual result check if it's not possible or too time consuming.) For example a manual result check might looking at a closely packed sprite formation in a multiplexor to check all sprites are displayed. An automatic check would be something like a compression algorithm tested with lots of different data.
2009-02-22 21:10
Frantic

Registered: Mar 2003
Posts: 1648
The best coding practice of them all is to actually finish what you are coding, and release some pretty daaaaaaaaaaaaaamn nice stuff!
2009-02-23 06:48
Martin Piper

Registered: Nov 2007
Posts: 722
A work of art is never finished while the artist is alive. :)
2009-03-24 17:51
drcode
Account closed

Registered: Mar 2009
Posts: 1
I have to agree that what mattered in the demos, was the fact that it looked cool, the effect or a variation was first one released and it was fun to make. It took some time to learn away from these principles. I expect that many of the industry wide coding practices can be applied to demo coding, but those are conflicting with those mentioned. Some routines were reusable (copy & paste) and there i can see a place to refactor some uggly code with some good coding practices.
2009-03-25 04:05
Martin Piper

Registered: Nov 2007
Posts: 722
Of course, some bits of code can't really be reused because they're cycle accurate with each changing scan line and triggering multiple effects. So in effect you're merging the code of several different ideas to create one bigger bit of code.
For example I'd love to be able to come up with a nice reusable maintainable way to create VIC display code where it can automatically schedule what VIC registers need to be changed at one cycle on a scan. But to write such a tool while possible would probably eat up much more time than I spend coding several of the effects.
But a lot of other code, even in demos, can be made modular and reusable. Like loaders, decrunchers, setup routines, 3D maths stuff etc.
Previous - 1 | 2 - 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
Mike
Unicorn/TWA
E$G/HF ⭐ 7
Alakran_64
Guests online: 111
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 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.046 sec.