### Complete assets2banks Configuration Example Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md A comprehensive example showcasing various attributes for asset grouping, formatting, modification, and manipulation. ```config # assets2banks.cfg example file # this is a comment # next line starts an asset group: { asset1 (tiles).bin asset1 (tilemap).bin :format unsigned int # 'asset1 (tilemap).bin' will be a const unsigned int array } # asset group complete # other assets (ungrouped) asset2 (palette).bin :overwrite 0 0x00 :alias BGpalette # the zero-indexed element of the array will be set to 0x00, and the array will be called BGpalette instead of asset2__palette__bin asset2 (tiles).psgcompr asset3 (tilemap).bin :format unsigned int :modify OR 0 16 0x1000 # 'asset3 (tilemap).bin' first 16 elements (starting from 0) will be ORed with 0x1000 bit mask my_notes.txt # I keep track of some important information in here! :ignore # 'my_notes.txt' will be ignored asset4.bin :format unsigned int :overwrite 32 128 0x010a 0x01FF 0x0123 # 'asset4.bin' 128 elements starting from array[32] will be set to the values listed # (values list will be reitered until 128 array elements are replaced) some_LUT.csv :text # this is a CSV file that will be parsed into an array :discard 0 32 :discard 200 0 # the first 32 elements of the array will be discarded, and the same to all the elements from the 200th onward :replace 0 0xFF # any element in the array equal to 0 will become 0xFF somedata.bin :segment skip 32 :modify AND 0xFE :header 0xF5 0xC9 :append 0x00 # takes 'somedata.bin' skipping the first 32 bytes from it, clears the last bit of each element, prepends a 2 bytes header 0xF5 0xC9 and then appends one 0x00 byte to it ``` -------------------------------- ### Example: Prepend Header Values Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Shows how to prepend multiple hexadecimal values to a headerless data file. ```Assembly headerless_data.bin :header 0x38 0x21 0x00 0x11 ``` -------------------------------- ### Start PSG Music Playback with Loops Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune and loops it for a specified number of times. The tune will stop after the requested loops are completed. ```c void PSGPlayLoops (void *song, unsigned char loops); ``` -------------------------------- ### Example: Importing Segments with Skipping Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Demonstrates importing specific byte ranges from binary files, including skipping initial bytes. ```config blob1.bin :segment 1024 blob2.bin :segment 128 skip 256 blob3.bin :segment skip 32 ``` -------------------------------- ### Start SFX Playback Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a Sound Effect (SFX) on the specified channels. Ensure the SFX data is correctly formatted. ```c void PSGSFXPlay (unsigned char *sfx, unsigned char channels); ``` -------------------------------- ### Example: Overwrite Single Element Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Demonstrates replacing the first value in a binary file with 0x00. ```Assembly sprite_palette.bin :overwrite 0 0x00 ``` -------------------------------- ### Example: Replace Value 0 with 192 Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Demonstrates replacing all instances of the value 0 with 192 in a tilemap binary file. ```Assembly my_tilemap.bin :format unsigned int :replace 0 192 ``` -------------------------------- ### Example: Text File Data Parsing Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Illustrates the flexible parsing of a text file containing mixed number formats, comments, and separators into an array. ```Assembly # this is some data in text form -6 -5 -0x0004 ( -0x03 -0x2 -1 # hex and/or negative is also supported {0, 1, 2, 3, 4} [5 6 7 8 9] # note that no specific separators or brakets are needed 10,,,11,,,12,,,13 [14] 15 [16] 17 ]] 018; 019; {020}; (021); 0x16, 0x17, 0x18 0x19 ``` -------------------------------- ### Start PSG Music Playback Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune indefinitely. Ensure the song data is correctly formatted and accessible. ```c void PSGPlay (void *song); ``` -------------------------------- ### Example: Modify Elements using OR Operation Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Shows how to apply a bitwise OR operation to a range of elements in a tilemap binary file. ```Assembly my_tilemap.bin :format unsigned int :modify OR 20 4 0x1000 ``` -------------------------------- ### Play MoonBlaster Module Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Starts playing a MoonBlaster module. If the module defines a loop, it will play indefinitely. ```c void MBMPlay (void *module) ``` -------------------------------- ### Start Looping SFX Playback Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a Sound Effect (SFX) that will loop indefinitely on the specified channels. Use PSGSFXCancelLoop to stop it. ```c void PSGSFXPlayLoop (unsigned char *sfx, unsigned char channels); ``` -------------------------------- ### Example: Alias Asset Name Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Demonstrates renaming the array generated from 'sprites_final_Final_FINAL.bin' to 'sprites'. ```Assembly sprites_final_Final_FINAL.bin :alias sprites ``` -------------------------------- ### Example: Exclude Debug Data File Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Shows how to prevent the 'debug_data_test.bin' file from being imported and processed. ```Assembly debug_data_test.bin :ignore ``` -------------------------------- ### Load PSGaiden Compressed Tiles Source: https://github.com/sverx/devkitsms/wiki/Home Loads tiles compressed using the PSGaiden format into VRAM. Specify the source data and the starting tile index in VRAM. ```c SMS_loadPSGaidencompressedTiles (void *src, unsigned int tilefrom) ``` -------------------------------- ### Configure Text Renderer Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Set the offset for ASCII to tile mapping or use a default setup for the text renderer. Functions for printing characters and strings are also provided. ```c void SMS_configureTextRenderer (signed int ascii_to_tile_offset) /* set the value you should add to ASCII value to get the tile number */ void SMS_autoSetUpTextRenderer (void) /* load a standard font character set into tiles 0-95, set BG palette to B/W and turn on the screen */ void SMS_putchar (char c) /* faster than plain putchar() */ void SMS_print(const char *str) /* faster than printf() for unformatted strings */ ``` -------------------------------- ### Specify Starting Bank Number Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Allows the bank numbering to start from a specified number, useful for allocating other code banks before data banks. ```bash assets2banks assets --firstbank=6 ``` -------------------------------- ### Start PSG Music Playback without Repeat Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune and stops it at the loop point. This is useful for tunes that should play only once or up to a specific point. ```c void PSGPlayNoRepeat (void *song); ``` -------------------------------- ### Multibank PSG Music Playback with Loops Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune from a specific bank and loops it for a specified number of times. Requires PSGLIB_MULTIBANK to be defined. ```c void PSGPlayLoops (void *song, unsigned char bank, unsigned char loops); ``` -------------------------------- ### Play Module Without Repeating Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Starts playing a MoonBlaster module and ensures it stops at the end, even if the module is defined with a loop. ```c void MBMPlayNoRepeat (void *module) ``` -------------------------------- ### Example: Discarding Elements from CSV Data Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Shows how to discard the first 16 elements from a CSV file's imported array. ```config mapdata.csv :text :discard 0 16 ``` -------------------------------- ### Load STM Compressed Tilemap Source: https://github.com/sverx/devkitsms/wiki/Home Loads a tilemap compressed using the STM format. Requires the source data and the starting X, Y coordinates on the screen. ```c SMS_loadSTMcompressedTileMap (unsigned char x, unsigned char y, unsigned char *src) ``` -------------------------------- ### Tilemap Loading and Handling Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Functions for loading tilemaps into specific areas of the screen and manipulating individual tiles. Includes functions to set and get tile data at specific coordinates. ```c void SG_loadTileMap (unsigned char x, unsigned char y, void *src, unsigned int size) void SG_loadTileMapArea (unsigned char x, unsigned char y, void *src, unsigned char width, unsigned char height) void SG_setNextTileatXY (unsigned char x, unsigned char y) void SG_setTile (unsigned char tile) SG_setTileatXY(x,y,tile) void SG_getNextTileatXY (unsigned char x, unsigned char y) unsigned char SG_getTile (void) SG_getTileatXY(x,y) ``` -------------------------------- ### Combined Options for Asset Generation Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Combines multiple options to generate compiled REL files, a single header file, and start bank numbering from a specific value. ```bash assets2banks assets --firstbank=6 --singleheader=assets.h --compile ``` -------------------------------- ### Load Tiles into VRAM Source: https://github.com/sverx/devkitsms/wiki/Home Use this function to load tile data into VRAM. Specify the source data, the starting tile index in VRAM, and the number of tiles to load. ```c SMS_loadTiles (void *src, unsigned int Tilefrom, unsigned int len) ``` -------------------------------- ### VRAM Tile Pattern and Color Loading Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Functions to load tile patterns and their associated colors into VRAM. Specify the source data, the starting tile index, and the size of the data to load. ```c void SG_loadTilePatterns (void *src, unsigned int tilefrom, unsigned int size) void SG_loadTileColours (void *src, unsigned int tilefrom, unsigned int size) void SG_loadSpritePatterns (void *src, unsigned int tilefrom, unsigned int size) ``` -------------------------------- ### Create Static Libraries (Default) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Archives the compiled object files into a static library using the 'sdar' utility for the default configuration. ```bash sdar r PSGlib.lib PSGlib.rel PSGAttenuation.rel PSGPlayLoops.rel PSGRestoreVolumes.rel PSGResume.rel ``` -------------------------------- ### Create Static Libraries (Multibank) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Archives the compiled object files into a static library using the 'sdar' utility for the multibank configuration. ```bash sdar r PSGlib_MB.lib PSGlib_MB.rel PSGAttenuation_MB.rel PSGPlayLoops_MB.rel PSGRestoreVolumes_MB.rel PSGResume_MB.rel ``` -------------------------------- ### Create Static Libraries (No SFX) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Archives the compiled object files into a static library using the 'sdar' utility for the no-SFX configuration. ```bash sdar r PSGlib_NOSFX.lib PSGlib_NOSFX.rel PSGAttenuation_NOSFX.rel PSGPlayLoops_NOSFX.rel PSGRestoreVolumes_NOSFX.rel PSGResume_NOSFX.rel ``` -------------------------------- ### Turn On Screen Display Source: https://github.com/sverx/devkitsms/wiki/Home Enables the screen display. This macro should be called after all graphics and palettes have been loaded. ```c SMS_displayOn() ``` -------------------------------- ### Compile Master System/Game Gear Program with devkitSMS Source: https://github.com/sverx/devkitsms/blob/master/README.md Compile your C source file for Master System or Game Gear. Ensure 'peep-rules.txt' is available if used. ```bash sdcc -c -mz80 --peep-file peep-rules.txt your_program.c ``` -------------------------------- ### Basic VDP Handling Functions Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Functions for initializing the VDP, controlling display features, setting colors, and managing sprite modes. SG_init is optional if using devkitSMS crt0_sg. ```c void SG_init (void) void SG_VDPturnOnFeature (unsigned int feature) void SG_VDPturnOffFeature (unsigned int feature) SG_displayOn() SG_displayOff() void SG_setSpriteMode (unsigned char mode) void SG_setBackdropColor (unsigned char entry) void SG_waitForVBlank (void) ``` -------------------------------- ### Bitmap Mode Initialization Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Function to initialize the system in Bitmap Mode with specified foreground and background colors. ```APIDOC ## SG_initBitmapMode ### Description Initializes the system to use Bitmap Mode, setting the foreground and background colors. ### Method `void SG_initBitmapMode (unsigned char foreground_color, unsigned char background_color)` ### Parameters - **foreground_color** (unsigned char) - The palette entry for the foreground color. - **background_color** (unsigned char) - The palette entry for the background color. ``` -------------------------------- ### Play Sound Effect in Loop Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Starts playing a sound effect in an auto-retrigger mode, causing it to loop automatically. ```c void MBMSFXPlayLoop (void *sound_effect) ``` -------------------------------- ### Keyboard Keycode Retrieval Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Function to get keycodes from the keyboard input. Specify the maximum number of keys to retrieve. ```c unsigned char SG_getKeycodes (unsigned int *keys, unsigned char max_keys) ``` -------------------------------- ### Create Static Libraries (ColecoVision) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Archives the compiled object files into a static library using the 'sdar' utility for the ColecoVision configuration. ```bash sdar r PSGlib_CV.lib PSGlib_CV.rel PSGAttenuation_CV.rel PSGPlayLoops_CV.rel PSGRestoreVolumes_CV.rel PSGResume_CV.rel ``` -------------------------------- ### Get Sound Effect Status Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Retrieves the current status of a sound effect. Possible return values are MBMSFX_STOPPED or MBMSFX_PLAYING. ```c unsigned char MBMSFXGetStatus (void) ``` -------------------------------- ### Link ColecoVision Program with SGlib and PSGlib Source: https://github.com/sverx/devkitsms/blob/master/README.md Link your compiled program with the ColecoVision runtime, SGlib, and PSGlib libraries. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --code-loc 0x8080 --data-loc 0x6000 crt0_cv.rel your_program.rel SGlib_CV.lib PSGlib_CV.lib ``` -------------------------------- ### Link SG-1000/SC-3000 Program with devkitSMS Source: https://github.com/sverx/devkitsms/blob/master/README.md Link the compiled object file with crt0_sg.rel and SGlib.lib. Place crt0_sg.rel first and the library last. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sg.rel your_program.rel SGlib.lib ``` -------------------------------- ### Create ColecoVision SGlib Library Archive Source: https://github.com/sverx/devkitsms/blob/master/SGlib/how to build this.txt Creates a static library archive for the ColecoVision target using the previously compiled object files. Note that not all original modules are included, suggesting a tailored library for CV. ```shell sdar r SGlib_CV.lib SGlib_CV.rel SGlib_spriteClip.rel SGlib_zx7.rel SGlib_zx7_VRAM_CV.rel SGlib_bitmap_CV.rel SGlib_putPixel_CV.rel SGlib_setPixel_CV.rel SGlib_debug.rel ``` -------------------------------- ### Get Module Playback Status Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Retrieves the current playback status of a music module. Possible return values are MBM_STOPPED or MBM_PLAYING. ```c unsigned char MBMGetStatus (void) ``` -------------------------------- ### Link Master System/Game Gear Program with devkitSMS Source: https://github.com/sverx/devkitsms/blob/master/README.md Link the compiled object file with the crt0_sms.rel and SMSlib.lib. Place crt0_sms.rel first and the library last. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sms.rel your_program.rel SMSlib.lib ``` -------------------------------- ### Discarding Array Elements Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md The :discard attribute removes elements from an imported array. Specify the starting index and optionally the number of elements to discard. ```config :discard [] ``` -------------------------------- ### Music Playback Functions Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Functions for controlling the playback of MoonBlaster music modules. These functions allow starting, stopping, looping, and fading music. ```APIDOC ## MBMPlay ### Description Starts playing a MoonBlaster module. If a loop is defined in the module, it will loop infinitely. ### Function Signature `void MBMPlay (void *module)` ### Parameters - **module** (void *) - Pointer to the MoonBlaster module data. ``` ```APIDOC ## MBMCancelLoop ### Description Instructs the library to stop the current tune at the next loop point, overriding any infinite looping defined in the module. ### Function Signature `void MBMCancelLoop (void)` ``` ```APIDOC ## MBMPlayNoRepeat ### Description Starts playing a MoonBlaster module and ensures it stops at the end, even if the module has a loop defined. ### Function Signature `void MBMPlayNoRepeat (void *module)` ### Parameters - **module** (void *) - Pointer to the MoonBlaster module data. ``` ```APIDOC ## MBMStop ### Description Stops (pauses) the currently playing module. ### Function Signature `void MBMStop (void)` ``` ```APIDOC ## MBMResume ### Description Resumes playback of a module that was previously stopped (paused). ### Function Signature `void MBMResume (void)` ``` ```APIDOC ## MBMGetStatus ### Description Retrieves the current playback status of the music module. ### Function Signature `unsigned char MBMGetStatus (void)` ### Return Values - **MBM_STOPPED** (0): No module is currently playing. - **MBM_PLAYING**: A module is currently playing. ``` ```APIDOC ## MBMFadeOut ### Description Fades out the currently playing tune until the volume reaches zero and then stops the tune. ### Function Signature `void MBMFadeOut (unsigned char fade_fraction)` ### Parameters - **fade_fraction** (unsigned char) - A fraction denominator determining the fade speed. 0 is invalid, 1 results in an immediate fade, and 255 is the slowest possible fade. ``` ```APIDOC ## MBMFrame ### Description This function should be called once per frame to ensure the tune is replayed correctly. ### Function Signature `void MBMFrame (void)` ``` -------------------------------- ### Compile SG-1000/SC-3000 Program with devkitSMS Source: https://github.com/sverx/devkitsms/blob/master/README.md Compile your C source file for SG-1000 or SC-3000. No special peep-file is required. ```bash sdcc -c -mz80 your_program.c ``` -------------------------------- ### Build crt0 for SG-1000 Source: https://github.com/sverx/devkitsms/blob/master/crt0/README.md Use this command to build the crt0 file for the SG-1000 console. ```bash sdasz80 -g -o crt0_sg.s ``` -------------------------------- ### Copy Sprites to SAT Source: https://github.com/sverx/devkitsms/wiki/Home Copies the temporary sprite list to the Sprite Attribute Table (SAT) for rendering in the next frame. Call this after VBlank starts. ```c SMS_copySpritestoSAT (void) ``` -------------------------------- ### Sound Effect Playback Functions Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Functions for playing and controlling sound effects. These include starting, stopping, looping, and checking the status of sound effects. ```APIDOC ## MBMSFXPlay ### Description Plays a sound effect. ### Function Signature `void MBMSFXPlay (void *sound_effect)` ### Parameters - **sound_effect** (void *) - Pointer to the sound effect data. ``` ```APIDOC ## MBMSFXPlayLoop ### Description Starts playing a sound effect in auto-retrigger (looping) mode. ### Function Signature `void MBMSFXPlayLoop (void *sound_effect)` ### Parameters - **sound_effect** (void *) - Pointer to the sound effect data. ``` ```APIDOC ## MBMSFXCancelLoop ### Description Cancels the auto-retriggering (looping) on the currently playing sound effect. ### Function Signature `void MBMSFXCancelLoop (void)` ``` ```APIDOC ## MBMSFXStop ### Description Stops the currently playing sound effect immediately. ### Function Signature `void MBMSFXStop (void)` ``` ```APIDOC ## MBMSFXGetStatus ### Description Retrieves the current playback status of the sound effect. ### Function Signature `unsigned char MBMSFXGetStatus (void)` ### Return Values - **MBMSFX_STOPPED** (0): No sound effect is currently playing. - **MBMSFX_PLAYING**: A sound effect is currently playing. ``` ```APIDOC ## MBMSFXFrame ### Description This function should be called once per frame to ensure the sound effect is replayed correctly. ### Function Signature `void MBMSFXFrame (void)` ``` -------------------------------- ### Basic VDP Handling Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Provides essential functions for initializing and controlling the Video Display Processor (VDP), including screen display, VBlank synchronization, and background scrolling. ```APIDOC ## SMS_init ### Description Initializes the SMSlib. This is typically not needed if using the devkitSMS crt0. ### Method `void SMS_init(void)` ## SMS_VDPturnOnFeature ### Description Enables a specific VDP feature. Refer to SMSlib.h for a list of available features. ### Method `void SMS_VDPturnOnFeature(unsigned int feature)` ## SMS_VDPturnOffFeature ### Description Disables a specific VDP feature. Refer to SMSlib.h for a list of available features. ### Method `void SMS_VDPturnOffFeature(unsigned int feature)` ## SMS_displayOn ### Description Turns the screen display on. ### Method `SMS_displayOn()` ## SMS_displayOff ### Description Turns the screen display off. ### Method `SMS_displayOff()` ## SMS_waitForVBlank ### Description Waits until the next VBlank period begins. ### Method `void SMS_waitForVBlank(void)` ## SMS_setBGScrollX ### Description Sets the horizontal scroll position for the background. ### Method `void SMS_setBGScrollX(unsigned char scrollX)` ## SMS_setBGScrollY ### Description Sets the vertical scroll position for the background. ### Method `void SMS_setBGScrollY(unsigned char scrollY)` ## SMS_setBackdropColor ### Description Sets the backdrop color using a sprite palette entry. ### Method `void SMS_setBackdropColor(unsigned char entry)` ## SMS_setSpriteMode ### Description Sets the sprite mode. Refer to SMSlib.h for a list of available modes. ### Method `void SMS_setSpriteMode(unsigned char mode)` ## SMS_useFirstHalfTilesforSprites ### Description Determines whether to use the first half (tiles 0-255) or the second half (tiles 256-511) of tiles for sprites. ### Method `void SMS_useFirstHalfTilesforSprites(_Bool usefirsthalf)` ``` -------------------------------- ### Link ColecoVision Program with SGlib Source: https://github.com/sverx/devkitsms/blob/master/README.md Link your compiled program with the ColecoVision runtime and SGlib library. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --code-loc 0x8080 --data-loc 0x6000 crt0_cv.rel your_program.rel SGlib_CV.lib ``` -------------------------------- ### Create SGlib Library Archive Source: https://github.com/sverx/devkitsms/blob/master/SGlib/how to build this.txt Creates a static library archive from the compiled object files. This consolidates multiple object files into a single library file. ```shell sdar r SGlib.lib SGlib.rel SGlib_spriteClip.rel SGlib_zx7.rel SGlib_zx7_VRAM.rel SGlib_bitmap.rel SGlib_putPixel.rel SGlib_setPixel.rel SGlib_debug.rel SGlib_keyboard.rel ``` -------------------------------- ### Get SFX Playback Status Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Retrieves the current status of the SFX playback. The return value indicates whether an SFX is currently playing or has stopped. ```c unsigned char PSGSFXGetStatus (void); ``` -------------------------------- ### Add Two Adjoining Sprites Source: https://github.com/sverx/devkitsms/wiki/Home A fast function to add two sprites side-by-side. Specify the starting X, Y coordinates and the tile index for the first sprite. ```c SMS_addTwoAdjoiningSprites (unsigned char x, unsigned char y, unsigned char tile) ``` -------------------------------- ### Bitmap Mode Initialization Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Function to initialize the Bitmap Mode with specified foreground and background colors. This prepares the VDP for bitmap rendering. ```c void SG_initBitmapMode (unsigned char foreground_color, unsigned char background_color) ``` -------------------------------- ### Linker Instruction for 32 KiB ROM with BANK1 Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md This linker command is used for creating a 32 KiB ROM when BANK1 is explicitly defined and allocated by assets2banks. ```bash sdcc -o output.ihx -mz80 --data-loc 0xC000 -Wl-b_BANK1=0x0000 --no-std-crt0 crt0_sms.rel main.rel SMSlib.lib bank1.rel ``` -------------------------------- ### Multibank PSG Music Playback without Repeat Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune from a specific bank and stops it at the loop point. This variant is for use with PSGLIB_MULTIBANK. ```c void PSGPlayNoRepeat (void *song, unsigned char bank); ``` -------------------------------- ### Multibank PSG Music Playback Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Starts playing a PSG tune from a specific bank. This is only available if PSGlib is compiled with PSGLIB_MULTIBANK. The bank is automatically switched by PSGFrame(). ```c void PSGPlay (void *song, unsigned char bank); ``` -------------------------------- ### Basic assets2banks Usage Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Generates C source and header files for assets in the specified folder. Arrays are named from filenames, replacing invalid characters with underscores. Size and bank placement defines are included. ```bash assets2banks assets ``` -------------------------------- ### Compile main.c to .rel object Source: https://github.com/sverx/devkitsms/blob/master/examples/first_test/README.md Compiles the main C source file into a relocatable object file using sdcc. Ensure SMSlib headers are included and peep rules are specified. ```bash sdcc -mz80 -I../../SMSlib/src --peep-file ../../SMSlib/src/peep-rules.txt -c main.c ``` -------------------------------- ### Set Next Palette Color Index Source: https://github.com/sverx/devkitsms/wiki/Advanced Sets the starting index for updating colors in the background or sprite palette. The index increments automatically after each color write. ```c SMS_setNextBGColoratIndex(i); ``` ```c SMS_setNextSpriteColoratIndex(i); ``` -------------------------------- ### Archive SMSlib_GG.lib for Game Gear Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/src/how to build this.txt Creates the static library SMSlib_GG.lib by archiving multiple object files using the sdar utility. This library is intended for the Game Gear target. ```batch sdar r SMSlib_GG.lib SMSlib_GG.rel SMSlib_sprite.rel SMSlib_twosprites.rel SMSlib_threesprites.rel SMSlib_foursprites.rel SMSlib_metasprite.rel SMSlib_paletteAdv_GG.rel SMSlib_paletteAdd_GG.rel SMSlib_paletteSub_GG.rel SMSlib_paletteZero_GG.rel SMSlib_spriteAdv.rel SMSlib_spriteClip_GG.rel SMSlib_STC0comp.rel SMSlib_STC4comp.rel SMSlib_PSGaiden.rel SMSlib_STMcomp.rel SMSlib_loadTileMapArea.rel SMSlib_loadTileMapColumn.rel SMSlib_load1bppTiles.rel SMSlib_VRAMmemcpy.rel SMSlib_VRAMmemcpy_brief.rel SMSlib_VRAMmemset.rel SMSlib_UNSAFE.rel SMSlib_UNSAFE_SAT.rel SMSlib_UNSAFE_memcpy.rel SMSlib_textrenderer.rel SMSlib_string.rel SMSlib_getTile.rel SMSlib_readVRAM.rel SMSlib_autotext_GG.rel SMSlib_zx7.rel SMSlib_zx7_VRAM.rel SMSlib_aPLib.rel SMSlib_UNSAFE_aPLib.rel SMSlib_debug.rel SMSlib_deprecated.rel @if %errorlevel% NEQ 0 goto :EOF ``` -------------------------------- ### Get PSG Playback Status Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/README.md Retrieves the current status of the PSG tune playback. The return value indicates whether the tune is playing, stopped, or paused. ```c unsigned char PSGGetStatus (void); ``` -------------------------------- ### Overwrite Specific Elements in an Asset Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Replaces array elements from a start index with specified values. Useful for correcting or updating specific data points within an asset. ```Assembly :overwrite [[...]] ``` ```Assembly :overwrite ``` -------------------------------- ### Load Background Palette Source: https://github.com/sverx/devkitsms/wiki/Home Loads a palette for the background. The 'palette' parameter should point to the palette data. ```c SMS_loadBGPalette (void *palette) ``` -------------------------------- ### Unsafe Tile Loading Macros Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Macros for efficiently loading tiles into VRAM. These are unsafe and should only be used during VBlank or when the screen is off. ```APIDOC ## UNSAFE_SMS_load1Tile ### Description Copies a single tile to VRAM. ### Method `macro` ### Parameters - **src** - Source of the tile data. - **theTile** - Destination tile index in VRAM. ## UNSAFE_SMS_load2Tiles ### Description Copies two tiles to VRAM. ### Method `macro` ### Parameters - **src** - Source of the tile data. - **tilefrom** - Starting destination tile index in VRAM. ## UNSAFE_SMS_load4Tiles ### Description Copies four tiles to VRAM. ### Method `macro` ### Parameters - **src** - Source of the tile data. - **tilefrom** - Starting destination tile index in VRAM. ## UNSAFE_SMS_loadNTiles ### Description Copies a specified number of tiles to VRAM. ### Method `macro` ### Parameters - **src** - Source of the tile data. - **tilefrom** - Starting destination tile index in VRAM. - **tilecount** - The number of tiles to copy. ## UNSAFE_SMS_loadTiles ### Description Copies a specified number of bytes of tile data to VRAM. ### Method `macro` ### Parameters - **src** - Source of the tile data. - **tilefrom** - Starting destination tile index in VRAM. - **size** - The number of bytes to copy. ``` -------------------------------- ### Basic VDP Handling Functions Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Core functions for initializing and controlling the Video Display Processor (VDP), including screen display, VBlank synchronization, and background scrolling. ```c void SMS_init (void) /* you don't need to call this if you're using devkitSMS crt0 */ ``` ```c void SMS_VDPturnOnFeature (unsigned int feature) /* check feature list in SMSlib.h */ ``` ```c void SMS_VDPturnOffFeature (unsigned int feature) ``` ```c SMS_displayOn() /* macro - turns on screen */ ``` ```c SMS_displayOff() /* macro - turns off screen */ ``` ```c void SMS_waitForVBlank (void) /* wait until next vBlank starts */ ``` ```c void SMS_setBGScrollX (unsigned char scrollX) /* scroll the background horizontally */ ``` ```c void SMS_setBGScrollY (unsigned char scrollY) /* scroll the background vertically */ ``` ```c void SMS_setBackdropColor (unsigned char entry) /* set which sprite palette entry will be used for backdrop */ ``` ```c void SMS_setSpriteMode (unsigned char mode) /* check modes list in SMSlib.h */ ``` ```c void SMS_useFirstHalfTilesforSprites (_Bool usefirsthalf) /* use tiles 0-255 for sprites if true, 256-511 if false */ ``` -------------------------------- ### Get VDP Registers Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Read the current values of the Vertical Count (VCount) and Horizontal Count (HCount) registers. Also includes a function to determine the VDP type. ```c unsigned char SMS_getVCount (void) /* Get Vertical count register */ unsigned char SMS_getHCount (void) /* Get Horizontal count register */ unsigned char SMS_VDPType (void) /* VDPType handling (SMS only) */ ``` -------------------------------- ### Get Key Status Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Retrieve the current status of controller keys, including pressed, held, and released states. Supports both standard and Mega Drive (MD) controllers. ```c unsigned int SMS_getKeysStatus (void) /* the current status of the keys */ unsigned int SMS_getKeysPressed (void) /* the keys that were up last frame and down now */ unsigned int SMS_getKeysHeld (void) /* the keys that were down last frame and still down now */ unsigned int SMS_getKeysReleased (void) /* the keys that were down last frame and up now */ /* MD pad handling (SMS only) */ unsigned int SMS_getMDKeysStatus (void) /* the current status of the extended keys on a MD controller */ unsigned int SMS_getMDKeysPressed (void) /* the extended keys that were up last frame and down now on a MD controller */ unsigned int SMS_getMDKeysHeld (void) /* the extended keys that were down last frame and still down now on a MD controller */ unsigned int SMS_getMDKeysReleased (void) /* the extended keys that were down last frame and up now on a MD controller */ ``` -------------------------------- ### Build crt0 for ColecoVision Source: https://github.com/sverx/devkitsms/blob/master/crt0/README.md Use this command to build the crt0 file for the ColecoVision console. ```bash sdasz80 -g -o crt0_cv.s ``` -------------------------------- ### Link SMS/GG/SG/SC Program with PSGlib Source: https://github.com/sverx/devkitsms/blob/master/README.md Link your compiled program with the SMS runtime, SMSlib, and PSGlib library. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --data-loc 0xC000 crt0_sms.rel your_program.rel SMSlib.lib PSGlib.lib ``` -------------------------------- ### Create ColecoVision .col ROM File Source: https://github.com/sverx/devkitsms/blob/master/README.md Use sdobjcopy to convert an Intel HEX file into a binary format, padding it to a specific size to create a ColecoVision .col ROM file. ```bash sdobjcopy --input-target=ihex --output-target=binary --pad-to 0x10000 your_program.ihx your_program.col ``` -------------------------------- ### Compile PSGlib Source Files (No SFX) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Compiles individual PSGlib C source files with the PSGLIB_NOSFXCODE definition enabled, excluding SFX code. Output files are suffixed with _NOSFX.rel. ```bash sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_NOSFXCODE -o PSGlib_NOSFX.rel PSGlib.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_NOSFXCODE -o PSGAttenuation_NOSFX.rel PSGAttenuation.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_NOSFXCODE -o PSGPlayLoops_NOSFX.rel PSGPlayLoops.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_NOSFXCODE -o PSGRestoreVolumes_NOSFX.rel PSGRestoreVolumes.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_NOSFXCODE -o PSGResume_NOSFX.rel PSGResume.c ``` -------------------------------- ### Process Text File as Asset Data Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Parses a text file as asset data, accepting decimal or hex values, negative numbers, and various separators. Supports comments starting with '#'. ```Assembly :text ``` -------------------------------- ### Compile SMSlib_paddle.c Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/src/how to build this.txt Compiles the SMSlib_paddle.c source file into an object file using sdcc for the Z80 architecture. Checks for compilation errors. ```batch sdcc -o SMSlib_paddle.rel -c -mz80 %OPT% SMSlib_paddle.c @if %errorlevel% NEQ 0 goto :EOF ``` -------------------------------- ### Compile ColecoVision Program with SGlib Source: https://github.com/sverx/devkitsms/blob/master/README.md Compile your C source file for ColecoVision using the TARGET_CV define. ```bash sdcc -c -mz80 -D TARGET_CV your_program.c ``` -------------------------------- ### Generate Single Header File Source: https://github.com/sverx/devkitsms/blob/master/assets2banks/README.md Creates a single header file for all asset banks instead of individual headers for each bank. This simplifies header management in projects. ```bash assets2banks assets --singleheader ``` -------------------------------- ### Initialize and Add Sprites Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Initialize sprite declaration and add individual sprites with their position and tile. Returns a handle for the sprite or -1 if no sprites are available. ```c void SMS_initSprites (void) /* we're going to start declaring sprites, in front-to-back order */ signed char SMS_addSprite (unsigned char x, unsigned char y, unsigned char tile) /* declare a sprite - returns handle or -1 if no more sprites are available */ ``` -------------------------------- ### Create SMS/GG/SG ROM File Source: https://github.com/sverx/devkitsms/blob/master/README.md Use makesms utility to convert an SDCC-linked IHX file into a final SMS/GG/SG ROM file. ```bash makesms your_program.ihx your_program.sms ``` -------------------------------- ### Load Tilemap to Screen Source: https://github.com/sverx/devkitsms/wiki/Home Loads a tilemap to a specified position on the screen. Use the 'len' parameter for the total size of the tilemap data. ```c SMS_loadTileMap (unsigned char x, unsigned char y, void *src, unsigned int len) ``` -------------------------------- ### Compile PSGlib Source Files (Default) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Compiles individual PSGlib C source files into Z80 object files using sdcc. This is the standard compilation process. ```bash sdcc -c -mz80 --max-allocs-per-node 100000 PSGlib.c sdcc -c -mz80 --max-allocs-per-node 100000 PSGAttenuation.c sdcc -c -mz80 --max-allocs-per-node 100000 PSGPlayLoops.c sdcc -c -mz80 --max-allocs-per-node 100000 PSGRestoreVolumes.c sdcc -c -mz80 --max-allocs-per-node 100000 PSGResume.c ``` -------------------------------- ### Peephole Rule 1b: Restart with DI and direct load Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/src/peep-rules.txt Loads %2 directly into %3 instead of going through %1 when interrupts are disabled (DI). ```assembly replace restart { ld %1, %2 di ld %3, %1 } by { ; peephole rule 1b-with_DI loaded %2 into %3 directly instead of going through %1. ld %3, %2 di } if canAssign(%3 %2), notVolatile(%1), notUsed(%1) ``` -------------------------------- ### Basic makecvmc Usage Source: https://github.com/sverx/devkitsms/blob/master/makecvmc/README.md Convert an IHX input file to a MegaCart ROM output file. ```bash makecvmc [options] infile.ihx outfile.rom ``` -------------------------------- ### Convert Hex Output to Binary Source: https://github.com/sverx/devkitsms/blob/master/README.md Convert the compiler's hex output file to a binary file format using objcopy. ```bash objcopy -Iihex -Obinary your_program.ihx your_program.bin ``` -------------------------------- ### Basic Conversion Source: https://github.com/sverx/devkitsms/blob/master/makesms/README.md Converts an input IHX file to an output SMS/GG ROM file. The ROM size will be a multiple of 16 KiB. ```bash makesms [options] infile.ihx outfile.sms ``` -------------------------------- ### Resume Module Playback Source: https://github.com/sverx/devkitsms/blob/master/MBMlib/README.md Resumes playback of a music module that was previously stopped or paused. ```c void MBMResume (void) ``` -------------------------------- ### Compile PSGlib Source Files (ColecoVision) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Compiles individual PSGlib C source files with the TARGET_CV definition enabled, specifically for ColecoVision. Output files are suffixed with _CV.rel. ```bash sdcc -c -mz80 --max-allocs-per-node 100000 -D TARGET_CV -o PSGlib_CV.rel PSGlib.c sdcc -c -mz80 --max-allocs-per-node 100000 -D TARGET_CV -o PSGAttenuation_CV.rel PSGAttenuation.c sdcc -c -mz80 --max-allocs-per-node 100000 -D TARGET_CV -o PSGPlayLoops_CV.rel PSGPlayLoops.c sdcc -c -mz80 --max-allocs-per-node 100000 -D TARGET_CV -o PSGRestoreVolumes_CV.rel PSGRestoreVolumes.c sdcc -c -mz80 --max-allocs-per-node 100000 -D TARGET_CV -o PSGResume_CV.rel PSGResume.c ``` -------------------------------- ### Link Multiple ROM Banks with Paging Source: https://github.com/sverx/devkitsms/blob/master/README.md Link the main program with multiple ROM bank object files, specifying memory locations for each bank segment. ```bash sdcc -o your_program.ihx -mz80 --no-std-crt0 --data-loc 0xC000 -Wl-b_BANK2=0x28000 -Wl-b_BANK3=0x38000 crt0_sms.rel your_program.rel SMSlib.lib bank2.rel bank3.rel ``` -------------------------------- ### Build crt0 for SMS/GG Source: https://github.com/sverx/devkitsms/blob/master/crt0/README.md Use this command to build the crt0 file for the Sega Master System and Game Gear. ```bash sdasz80 -g -o crt0_sms.s ``` -------------------------------- ### Padding to Power of 2 Source: https://github.com/sverx/devkitsms/blob/master/makesms/README.md Pads the output ROM file to a size that is an exact power of 2 (e.g., 16 KiB, 32 KiB, 64 KiB). ```bash makesms -pp infile.ihx outfile.sms ``` -------------------------------- ### Compile SMSlib_aPLib.c Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/src/how to build this.txt Compiles the SMSlib_aPLib.c source file into an object file using sdcc for the Z80 architecture. Checks for compilation errors. ```batch sdcc -o SMSlib_aPLib.rel -c -mz80 %OPT% SMSlib_aPLib.c @if %errorlevel% NEQ 0 goto :EOF ``` -------------------------------- ### Compile PSGlib Source Files (Multibank) Source: https://github.com/sverx/devkitsms/blob/master/PSGlib/how to build this.txt Compiles individual PSGlib C source files with the PSGLIB_MULTIBANK definition enabled, producing object files for multibank compilation. The output files are suffixed with _MB.rel. ```bash sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_MULTIBANK -o PSGlib_MB.rel PSGlib.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_MULTIBANK -o PSGAttenuation_MB.rel PSGAttenuation.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_MULTIBANK -o PSGPlayLoops_MB.rel PSGPlayLoops.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_MULTIBANK -o PSGRestoreVolumes_MB.rel PSGRestoreVolumes.c sdcc -c -mz80 --max-allocs-per-node 100000 -D PSGLIB_MULTIBANK -o PSGResume_MB.rel PSGResume.c ``` -------------------------------- ### ihx2sms Padding to 64KB Multiples Source: https://github.com/sverx/devkitsms/blob/master/ihx2sms/README.md Pads the output ROM file to a size that is a multiple of 64KB. ```bash ihx2sms -pm infile.ihx outfile.sms ``` -------------------------------- ### Compile SGlib Modules Source: https://github.com/sverx/devkitsms/blob/master/SGlib/how to build this.txt Compiles individual C source files into relocatable object files for the Z80 architecture. Ensure sdcc is in your PATH. ```shell sdcc -o SGlib.rel -c -mz80 --max-allocs-per-node 100000 SGlib.c sdcc -o SGlib_spriteClip.rel -c -mz80 --max-allocs-per-node 100000 SGlib_spriteClip.c sdcc -o SGlib_zx7.rel -c -mz80 --max-allocs-per-node 100000 SGlib_zx7.c sdcc -o SGlib_zx7_VRAM.rel -c -mz80 --max-allocs-per-node 100000 SGlib_zx7_VRAM.c sdcc -o SGlib_bitmap.rel -c -mz80 --max-allocs-per-node 100000 SGlib_bitmap.c sdcc -o SGlib_putPixel.rel -c -mz80 --max-allocs-per-node 100000 SGlib_putPixel.c sdcc -o SGlib_setPixel.rel -c -mz80 --max-allocs-per-node 100000 SGlib_setPixel.c sdcc -o SGlib_debug.rel -c -mz80 --max-allocs-per-node 100000 SGlib_debug.c sdcc -o SGlib_keyboard.rel -c -mz80 --max-allocs-per-node 100000 SGlib_keyboard.c ``` -------------------------------- ### Link .rel files and libraries to .ihx Source: https://github.com/sverx/devkitsms/blob/master/examples/hello_sms/README.md Links the compiled object files and SMSlib library to create an Intel HEX file. The crt0_sms.rel must be first, followed by the library and object files. ```makefile sdcc -o hello.ihx --no-std-crt0 --data-loc 0xC000 ../../crt0/crt0_sms.rel ../../SMSlib/src/SMSlib.lib main.rel ``` -------------------------------- ### Tilemap Handling Functions Source: https://github.com/sverx/devkitsms/blob/master/SMSlib/README.md Functions and macros for setting individual tiles within the tilemap at specified XY coordinates. ```c void SMS_setNextTileatXY (unsigned char x, unsigned char y) ``` ```c void SMS_setTile (unsigned int tile) ``` ```c SMS_setTileatXY (unsigned char x, unsigned char y, unsigned int tile) /* macro - puts a tile at X,Y */ ``` -------------------------------- ### Link .rel files and libraries to .ihx Source: https://github.com/sverx/devkitsms/blob/master/examples/first_test/README.md Links compiled object files and SMSlib libraries to create an Intel HEX file. The crt0_sms.rel must be first, followed by libraries and then object files. Standard C runtime is disabled. ```bash sdcc -o first.ihx --no-std-crt0 --data-loc 0xC000 ../../crt0/crt0_sms.rel ../../SMSlib/src/SMSlib.lib main.rel ``` -------------------------------- ### Sprite Handling Functions Source: https://github.com/sverx/devkitsms/blob/master/SGlib/README.md Functions for initializing, adding, and managing sprites on the screen. Includes clipping and copying sprites to the SAT. Returns false if no sprites are available. ```c void SG_initSprites (void) _Bool SG_addSprite (unsigned char x, unsigned char y, unsigned char tile, unsigned char attr) void SG_setClippingWindow (unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1) _Bool SG_addSpriteClipping (int x, int y, unsigned char tile, unsigned char attr) void SG_finalizeSprites (void) void SG_copySpritestoSAT (void) ``` -------------------------------- ### Compile ROM Bank with Custom Segment Source: https://github.com/sverx/devkitsms/blob/master/README.md Compile a C file for a specific ROM bank, assigning it to a custom constant segment (e.g., BANK2). ```bash sdcc -c -mz80 --constseg BANK2 bank2.c ``` -------------------------------- ### Load Sprite Palette Source: https://github.com/sverx/devkitsms/wiki/Home Loads a palette for sprites. The 'palette' parameter should point to the palette data. ```c SMS_loadSpritePalette (void *palette) ```