Skip to content

Latest commit

 

History

History
136 lines (115 loc) · 5.07 KB

CONTRIBUTING.md

File metadata and controls

136 lines (115 loc) · 5.07 KB

Welcome to contributing guide

TBD

Guide to contributing code

Declaration case type

Labels must use the Snake Case with all capital letters.

.label PAGE0_PAGE_POINTER   = $D507

Macro must use the Pascal Case.

.macro BasicUpstart128() { }

Functions must use the Camel Case.

.function incArgument() { }

Argument check

If a macro or function has arguments that can only take on certain values, it is advisable to insert checks to ensure correct use. You can use the .errorif keyword to raise an error.

.macro FillMemory(address, length, value) {
  .errorif (length < 5 || length > 255), "length must be from 5 to 255"
...
}

It is also a good idea to add assertions at the end of the macro body to check that the error is raised correctly.

.asserterror "FillMemory($A000, 4, 10)", { FillMemory($A000, 4, 10) }
.asserterror "FillMemory($A000, 256, 10)", { FillMemory($A000, 256, 10) }

Static test

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.

.macro SetCommonRAM(config) {
    lda #config
    sta Mmu.RAM_CONFIG
}
.assert "SetCommonRAM(COMMON_RAM_16K | COMMON_RAM_BOTH) sets accumulator to 0f", { SetCommonRAM(Mmu.COMMON_RAM_16K | Mmu.COMMON_RAM_BOTH) }, {
  lda #%00001111; sta $d506
}

Static testing is very important especially where the code can vary depending on the arguments with which a macro is called.

Hex values

Hex values should be written with two or four characters as needed. The letters should be capitalized.

.label CONFIGURATION        = $D500

Guide to contributing documentation

File header

Every file should have an header like this:

/**
 * @file math.asm
 * @brief Math module
 * @details Simple macros for math operations.
 *
 * @author Raffaele Intorcia @intoinside raffaele.intorcia@gmail.com
 *
 * @copyright MIT License
 * Copyright (c) 2024 c128lib - https://github.com/c128lib
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * @date 2024
 */
  • a @brief keyword with a short description (typically one or two line)
  • a @details keyword (optional) with a longer description, with some hint about code used and comparison with similar code
  • one or more @author keyword with name, Github profile link and email
  • a @date keyword indicating year of creating file

Subroutine and macro header

Every subroutine and macro should have an header like this:

/**
 * @brief This macro copies a block of memory from one location to another using page relocation.
 * 
 * @details This macro also handles the page relocation of the memory block during the copy operation.
 * It's slower than @sa copyFast but it uses much less memory, especially for large memory blocks copy.
 *
 * @param[in] source The starting address of the memory block to be copied.
 * @param[in] destination The starting address of the location where the memory block will be copied to.
 * @param[in] count The number of bytes to be copied.
 *
 * @note Usage: copyWithRelocation($C000, $C100, 256)  // Copies 256 bytes from memory location $C000 to $C100 with relocation
 * @note Use c128lib_copyWithRelocation in mem-global.asm
 *
 * @since 0.6.0
 */
  • a @brief keyword with a short description (typically one or two line)
  • a @details keyword (optional) with a longer description, with some hint about code used and comparison with similar code
  • a @param keyword for every parameter, with [in], [out] or [in,out] attribute to specify if parameter is an input or output value
  • a @remark keyword for indicating if registers or flags are affrected
  • a @note keyword for "non-global" macros to suggest to use global macro definition
  • a @since keyword to specify from which version this code is available

Other keywords under evaluation

  • a @example keyword (optional) for pointing to other source code where method is used
  • a @note keyword (optional) for a simple usage code