Skip to content

Commit cf3d933

Browse files
committed
Merge branch 'master' into intoinside/issue1
2 parents 95f2262 + c728967 commit cf3d933

1 file changed

Lines changed: 58 additions & 17 deletions

File tree

CONTRIBUTING.md

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,64 @@
11
# Welcome to contributing guide
22
TBD
3+
34
## Guide to contributing code
4-
TBD
5+
6+
### Declaration case type
7+
Labels must use the **Snake Case with all capital letters**.
8+
<pre>
9+
.label PAGE0_PAGE_POINTER = $D507
10+
</pre>
11+
12+
Macro must use the **Pascal Case**.
13+
<pre>
14+
.macro BasicUpstart128() { }
15+
</pre>
16+
17+
Functions must use the **Camel Case**.
18+
<pre>
19+
.function incArgument() { }
20+
</pre>
21+
22+
### Argument check
23+
If a macro or function has arguments that can only take on certain values, it is advisable to insert checks to ensure correct use.
24+
You can use the .errorif keyword to raise an error.
25+
26+
``` Assembly
27+
.macro FillMemory(address, length, value) {
28+
.errorif (length < 5 || length > 255), "length must be from 5 to 255"
29+
...
30+
}
31+
```
32+
33+
It is also a good idea to add assertions at the end of the macro body to check that the error is raised correctly.
34+
35+
``` Assembly
36+
.asserterror "FillMemory($A000, 4, 10)", { FillMemory($A000, 4, 10) }
37+
.asserterror "FillMemory($A000, 256, 10)", { FillMemory($A000, 256, 10) }
38+
```
39+
40+
### Static test
41+
Static testing should be performed to verify that the correct code is produced. At the end of each macro, add one or more assertions to compare the code generated by the macro with the expected code.
42+
43+
``` Assembly
44+
.macro SetCommonRAM(config) {
45+
lda #config
46+
sta Mmu.RAM_CONFIG
47+
}
48+
.assert "SetCommonRAM(COMMON_RAM_16K | COMMON_RAM_BOTH) sets accumulator to 0f", { SetCommonRAM(Mmu.COMMON_RAM_16K | Mmu.COMMON_RAM_BOTH) }, {
49+
lda #%00001111; sta $d506
50+
}
51+
```
52+
53+
Static testing is very important especially where the code can vary depending on the arguments with which a macro is called.
54+
55+
### Hex values
56+
57+
Hex values should be written with two or four characters as needed. The letters should be capitalized.
58+
59+
``` Assembly
60+
.label CONFIGURATION = $D500
61+
```
562

663
## Guide to contributing documentation
764
### File header
@@ -77,19 +134,3 @@ or output value
77134
#### Other keywords under evaluation
78135
* a @example keyword (optional) for pointing to other source code where method is used
79136
* a @note keyword (optional) for a simple usage code
80-
81-
### Declaration case type
82-
Labels must use the **Snake Case with all capital letters**.
83-
<pre>
84-
.label PAGE0_PAGE_POINTER = $D507
85-
</pre>
86-
87-
Macro must use the **Pascal Case**.
88-
<pre>
89-
.macro BasicUpstart128() { }
90-
</pre>
91-
92-
Functions must use the **Camel Case**.
93-
<pre>
94-
.function incArgument() { }
95-
</pre>

0 commit comments

Comments
 (0)