I think a few more broad-line rules should be discussed
My "ruless... well guidelines" are
Don't use magic numbers, make constants.
Make sure all constants start k(uppercase letter) this way my tools can catch when I forget to do a #
Make blocks for groupings, and put "classes" i.e code that is grouped together in its own block and section
If maths is repeated make a function that does it, i.e convert X,Y to a screen locations is
Code: Select all
fCalcScreenAddrChar .function base,x,y
.endf base+(y*40)+x
variables and data should be inlined wherever possible, or near by as much as possible.
Code: Select all
.section ZP
myVar .byte ?
.send ZP
myFunc
lda myVar
bpl _skip
ldx #size(myData)-1
- lda myData,x
.section Bank0Data
myData .byte VIC.Colours.(black,red,green,yellow)
.send Bank0Data
sta VIC.Sprite.Colour0
dex
bpl -
_skip
rts
If a branch targets an rts name it EXIT
If a branch targets a jmp name it bJ<place it jumps to>
After each code stop there is a blank line. So rts, rti, an always taken branch, or opposing branch pair
functions lowerCaseStart
Data UpperCaseStart
IF_DEFS all caps
Each bank should be in its own block so you have to enter BANK_XX.func if you call it from outside of the bank