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.
2009-02-19 05:59
Majikeyric

Registered: Sep 2002
Posts: 83
I don't get the meaning of your post...

Use AND #$0 instead of LDA #$0 ?!!
What's the interest ? they all use 2 bytes.
If there was any interest in doing so everybody would do like this since ages.
You come from 80x86-land where you do : XOR reg,reg to clear a register ? :D

I don't think relying on internal rom calculations is a good coding practice, really...
2009-02-19 06:41
null
Account closed

Registered: Jun 2006
Posts: 645
you say you code for optimization, but isn't 'jsr $e544' a kernel routine, meaning you don't optimize all that well, seeing as you don't turn off the kernel?

------------------------------------
http://zomgwtfbbq.info
2009-02-19 07:44
JackAsser

Registered: Jun 2002
Posts:
Quote: you say you code for optimization, but isn't 'jsr $e544' a kernel routine, meaning you don't optimize all that well, seeing as you don't turn off the kernel?

------------------------------------
http://zomgwtfbbq.info


I usually switch all RTI:s to JSR:s and I favour LSR instead of CLD. I've found that those pack better with pucrunch, however if you use Exomizer you might want to use the STA,ADC and ROL instead of JMP,PHP and TAX.

I always also optimize Warlock! However I prefer using EOR when I try to be NTSC compatible.
2009-02-19 07:58
Britelite

Registered: Dec 2001
Posts: 51
Quote: I usually switch all RTI:s to JSR:s and I favour LSR instead of CLD. I've found that those pack better with pucrunch, however if you use Exomizer you might want to use the STA,ADC and ROL instead of JMP,PHP and TAX.

I always also optimize Warlock! However I prefer using EOR when I try to be NTSC compatible.


Btw, ever tried to use SBC instead of ADC? SBC actually decreases bits while ADC gives more bloated results when crunching!

And thanks for the tip on using EOR for NTSC compatibility, it really solved a lot of problems for me.
2009-02-19 08:24
Mace

Registered: May 2002
Posts: 1799
AND #$00 instead of LDA #$00 is interesting, just because of the weird way that it just works.

The fact that you save one bit is not at all interesting, this can hardly make a difference IMHO. If you say it does, I need evidence.

Also, my time is more valuable than online bytes or even floppy space, so I wouldn't want to spend time deciphering my unreadable code to save some bits.

Using presumed register values after calling a ROM routine is, like others already said, not at all good coding practice.

On top of it all, it is also important to think of what you are trying to optimise: speed or length?

In all, you are not making much sense, but I think the cynical replies of my fellow sceners already implied that ;)
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:
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 ;)
 
... 5 posts hidden. Click here to view all posts....
 
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
B.A./QUANTUM
HCL/Booze Design
aNdy/AL/Cosine
BYB/Hokuto Force
Raf/Vulture Design
REBEL 1/HF
Acidchild/Padua
DJ Space
rexbeng
deetsay
heavymett
Guests online: 145
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 Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

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