Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Code indenting
2017-09-11 07:40
oziphantom

Registered: Oct 2014
Posts: 478
Code indenting

I've always been a strict
label code comment
kinda guy but of late I've been experimenting with code readability and speed boosts. Indenting does seem to improve things
updateMovement
	ldx Ents.movementPtr
-	lda YXDeltas,x
	cmp #$AA
	bne +
	ldx Ents.movementPtrBase
	stx Ents.movementPtr
	jmp -
+	clc
	adc Ents.y
	sta Ents.y
	inx	
	lda YXDeltas,x
	beq _endAdd
	bmi _sub
	clc
	adc Ents.x
	sta Ents.x
	bcc _endAdd
	inc Ents.xMSB
	jmp _endAdd
_sub
	clc
	adc Ents.x
	sta Ents.x
	lda Ents.xMSB
	adc #$ff
	sta Ents.xMSB
_endAdd
	inx
	stx Ents.movementPtr
	rts
vs
updateMovement
	ldx Ents.movementPtr
-	lda YXDeltas,x
	cmp #$AA
	bne +
	    ldx Ents.movementPtrBase
	    stx Ents.movementPtr
	jmp -
+	clc
	adc Ents.y
	sta Ents.y
	inx	
	lda YXDeltas,x
	beq _endAdd
	    bmi _sub
                clc
                adc Ents.x
                sta Ents.x
                bcc _endAdd
                    inc Ents.xMSB
                    jmp _endAdd
       _sub
            clc
            adc Ents.x
            sta Ents.x
            lda Ents.xMSB
            adc #$ff
            sta Ents.xMSB
_endAdd
	inx
	stx Ents.movementPtr
	rts
this kind of falls apart when you get the to the leap frog code. I.e something like
bmi C
beq B
A
A
A
bne C
A
A
jmp D
B
B
B
B
beq D
C
C
C
C
D
D
D
So I was wondering if anybody else had tumbled down this rabbit hole or had other things to do to help?
 
... 22 posts hidden. Click here to view all posts....
 
2017-09-22 00:10
Cruzer

Registered: Dec 2001
Posts: 1048
Quoting Compyx
asm doesn't have block-level scope. And if there are assemblers that support that, those are retarded.
I dunno. If it's used for keeping the code organized, I beg to differ. For instance I like to keep each subroutine in braces, so I can have local labels like "loop" and "done" that would otherwise have to be either global (I remember the days of turbo-ass and having to come up with meaningless labels like "loop43") or multi-labels referenced by label+ or label-, which have the disadvantage that if you forget to add the label, it usually ends up referring to a label in another subroutine. But even when using multi-labels you avoid this if the subroutines are in different blocks, since it will just give a compile time error.

Are for-loops and other scripting retarded? Certainly if it's used for generating speedcode or data that could be generated quicker at runtime than it would take to load. But for importing gfx or generating small chunks of data or code such as setting the y-position of 8 sprites it makes a lot of sense to me.
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
Mike
Mason/Unicess
K-reator/CMS/F4CG
kbs/Pht/Lxt
Didi/Laxity
iAN CooG/HVSC
Guests online: 120
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Graphicians
1 Sulevi  (10)
2 Mirage  (9.8)
3 Lobo  (9.7)
4 Mikael  (9.7)
5 Archmage  (9.7)

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