Documentation
¶
Index ¶
- Variables
- func AddFileToTar(tarWriter *tar.Writer, filePath string) error
- func CSVToIntSlice(csv string) []int
- func CalcImageOffSet(Index, startIndex uint8, columns, size int) (int, int)
- func CalcImageSize(startIndex, endIndex uint8, columns, size int) (int, int)
- func CopyFile(src, dst string) error
- func CreateProjectFromTemplate(projectFile string, templateName string) error
- func GetBlockTypeByTypeID(id uint8) string
- func GetBlockTypeIDByType(blockType string) uint8
- func IsESCKeyPressed() bool
- func LogMessage(element, message, level string, noColor bool)
- func SpectrumAttrToColors(attr uint8) (fg color.Color, bg color.Color)
- type APJData
- type APJFile
- func (apj *APJFile) ASMPathInit()
- func (apj *APJFile) BackupProjectFile(code bool) error
- func (apj *APJFile) BlockDefault()
- func (apj *APJFile) BlockInit(overwrite bool)
- func (apj *APJFile) BlockTo2DArray(data []uint8) ([][]uint8, error)
- func (apj *APJFile) CalcOffset()
- func (apj *APJFile) CompareData(other *APJFile) map[string]interface{}
- func (apj *APJFile) CreateBlank()
- func (apj *APJFile) CreateState() State
- func (apj *APJFile) DeleteObject(objectID int)
- func (apj *APJFile) DeleteObjects()
- func (apj *APJFile) Display()
- func (apj *APJFile) DisplayStats()
- func (apj *APJFile) FontDefault()
- func (apj *APJFile) FontInit(overwrite bool)
- func (apj *APJFile) GetReorderedBlocks(order []int, offset int) ([]Block, error)
- func (apj *APJFile) GetReorderedSprites(order []int, offset int) ([]Sprite, error)
- func (apj *APJFile) HeaderInit()
- func (apj *APJFile) ImportAGD(agdFilePath string, options ImportOptions) error
- func (apj *APJFile) ImportBlocks(lines []string) error
- func (apj *APJFile) ImportFont(lines []string) error
- func (apj *APJFile) ImportMap(lines []string) error
- func (apj *APJFile) ImportObjects(lines []string) error
- func (apj *APJFile) ImportScreens(lines []string) error
- func (apj *APJFile) ImportSpritePos(screenId uint8, lines []string) error
- func (apj *APJFile) ImportSprites(lines []string) error
- func (apj *APJFile) ImportULAPalette(lines []string) error
- func (apj *APJFile) KeysInit(overwrite bool)
- func (apj *APJFile) ListBackupProjectFiles(backupDir string) ([]string, error)
- func (apj *APJFile) LivesScoreInit(overwrite bool)
- func (apj *APJFile) LoadYAML(filePath string) error
- func (apj *APJFile) LoadYAMLFromString(yamlString []byte) error
- func (apj *APJFile) MapDefault()
- func (apj *APJFile) MapInit(overwrite bool)
- func (apj *APJFile) MonitorFileChanges(code bool)
- func (apj *APJFile) ObjectDefault()
- func (apj *APJFile) ObjectInit(overwrite bool)
- func (apj *APJFile) PurgeBackupFiles(backupDir string) error
- func (apj *APJFile) ReadAPJ() error
- func (apj *APJFile) RemapScreens(screenIndex uint8, BlockOffSet uint8)
- func (apj *APJFile) RenderBlockToBitmap(startIndex, endIndex uint8, filePath string, reorder []int, offset int) error
- func (apj *APJFile) RenderBlockToTerminal(start, end int, reorder []int) error
- func (apj *APJFile) RenderScreenToBitmap(screenIndex uint8, filePath string) error
- func (apj *APJFile) RenderSpriteToBitmap(startIndex, endIndex uint8, filePath string, reorder []int, offset int) error
- func (apj *APJFile) RenderSpriteToTerminal(startIndex, endIndex uint8, reorder []int, offset int) error
- func (apj *APJFile) ReorderBlocks(order []int, offset int) error
- func (apj *APJFile) ReorderScreens(order []int) error
- func (apj *APJFile) ReorderSprites(order []int, offset int) error
- func (apj *APJFile) ResetState()
- func (apj *APJFile) RestoreLastBackup(backupDir string, code bool) (string, error)
- func (apj *APJFile) RotateBlock(blockIndex uint8, ccw bool, retain bool) (uint8, error)
- func (apj *APJFile) RotateSprite(spriteIndex uint8, ccw bool, retain bool) (uint8, error)
- func (apj *APJFile) SaveAsYAML(filePath string) error
- func (apj *APJFile) ScreensDefault()
- func (apj *APJFile) ScreensInit(force bool)
- func (apj *APJFile) SetFrameDefaults(sprite *Sprite)
- func (apj *APJFile) SetNoColorOutput(noColor bool)
- func (apj *APJFile) SpriteDefault()
- func (apj *APJFile) SpriteInfoInit(overwrite bool)
- func (apj *APJFile) SpriteInit(overwrite bool)
- func (apj *APJFile) SpriteTo2DArray(data []uint8) ([][]uint8, error)
- func (apj *APJFile) ULAPaletteInit(overwrite bool)
- func (apj *APJFile) WriteAPJ(outputFilePath string) error
- type Block
- type Font
- type ImportOptions
- func (o *ImportOptions) SetIgnoreOptions(ignoreWindow, ignoreKeys, ignoreBlocks, ignoreSprites, ignoreObjects, ... bool)
- func (o *ImportOptions) SetIgnoreOptionsFalse()
- func (o *ImportOptions) SetIgnoreOptionsTrue()
- func (o *ImportOptions) SetOwOptions(...)
- func (o *ImportOptions) SetOwOptionsFalse()
- func (o *ImportOptions) SetOwOptionsTrue()
- type LivesScore
- type Map
- type Object
- type Screen
- type Sprite
- type SpriteFrame
- type SpriteInfo
- type State
- type Template
- type ULAPalette
Constants ¶
This section is empty.
Variables ¶
var BlockTypeToId = map[string]uint8{
"EMPTYBLOCK": 0,
"PLATFORMBLOCK": 1,
"WALLBLOCK": 2,
"LADDERBLOCK": 3,
"FODDERBLOCK": 4,
"DEADLYBLOCK": 5,
}
BlockTypeToId maps block type names to their corresponding block IDs.
var GetKeyState = user32_dll.NewProc("GetKeyState")
var IdToBlockType = map[uint8]string{
0: "EMPTYBLOCK",
1: "PLATFORMBLOCK",
2: "WALLBLOCK",
3: "LADDERBLOCK",
4: "FODDERBLOCK",
5: "DEADLYBLOCK",
}
IdToBlockType maps block IDs to their corresponding block type names.
Functions ¶
func AddFileToTar ¶ added in v0.1.3
addFileToTar adds a file to the tar archive
func CSVToIntSlice ¶
CSVToIntSlice converts a CSV string to a slice of integers. csv: string - the input CSV string. Returns a slice of integers.
func CalcImageOffSet ¶
CalcImageOffSet calculates the offset of a sprite in the image layout. Index: uint8 - the index of the sprite. startIndex: uint8 - the starting index of the sprites. columns: int - the number of columns in the layout. size: int - the size of each sprite. Returns the x and y offsets of the sprite.
func CalcImageSize ¶
CalcImageSize calculates the dimensions of an image based on sprite layout. startIndex: uint8 - the starting index of the sprites. endIndex: uint8 - the ending index of the sprites. columns: int - the number of columns in the layout. size: int - the size of each sprite. Returns the width and height of the image.
func CopyFile ¶
CopyFile copies a file from the source path to the destination filepath. src: string - the source file filepath. dst: string - the destination file filepath. Returns an error if the operation fails.
func CreateProjectFromTemplate ¶
CreateProjectFromTemplate creates a new project file from a specified template.
func GetBlockTypeByTypeID ¶ added in v0.1.6
GetBlockTypeByID returns the block type name for a given block ID. If the ID does not exist, it returns "UNKNOWN".
func GetBlockTypeIDByType ¶ added in v0.1.6
GetBlockIDByType returns the block ID for a given block type name. If the block type does not exist, it returns 0 as the default value.
func IsESCKeyPressed ¶ added in v0.1.3
func IsESCKeyPressed() bool
IsKeyPressed checks if a specific key is pressed.
func LogMessage ¶
LogMessage displays a log message with a specific format and color-coded output. element: string - the element being logged. message: string - the log message. level: string - the log level ("ok", "warning", "error").
Types ¶
type APJData ¶
type APJData struct {
EnterpriseBias uint8 // EnterpriseBias is a single-byte value representing the enterprise bias setting.
}
APJData represents the data structure for APJ files, including the EnterpriseBias setting.
type APJFile ¶
type APJFile struct {
FilePath string
Description string
Windows Windows
Header []uint8
Version uint32
AsmPath []uint8
Blocks []Block
NrOfBlocks uint8
Screens []Screen
NrOfScreens uint8
EnterpriseBias uint8
LivesScore LivesScore
Map Map
State State
Fonts []Font
Keys []uint8
Objects []Object
NrOfObjects uint8
SpriteInfo []SpriteInfo
Sprites []Sprite
NrOfSprites uint8
ULAPalette ULAPalette
// contains filtered or unexported fields
}
APJFile represents the structure of an APJ file with all its components.
func NewAPJFile ¶
NewAPJFile creates a new APJFile instance with default values.
func (*APJFile) ASMPathInit ¶
func (apj *APJFile) ASMPathInit()
ASMPathInit initializes the ASM path as an empty slice.
func (*APJFile) BackupProjectFile ¶
Backup creates a backup of the APJ file in the same directory as the original file
func (*APJFile) BlockDefault ¶
func (apj *APJFile) BlockDefault()
BlockDefault sets up default blocks if none exist. It initializes one block with default values.
func (*APJFile) BlockInit ¶
BlockInit initializes the Blocks slice. If overwrite is true, it resets the Blocks and NrOfBlocks.
func (*APJFile) BlockTo2DArray ¶
BlockTo2DArray converts block data to a 2D array.
func (*APJFile) CalcOffset ¶
func (apj *APJFile) CalcOffset()
CalcImageSize calculates the image size based on the number of sprites and layout
func (*APJFile) CompareData ¶
CompareData compares the data in the current APJFile with another APJFile and returns a map of differences.
func (*APJFile) CreateBlank ¶
func (apj *APJFile) CreateBlank()
CreateBlank initializes a blank APJ file with default values.
func (*APJFile) CreateState ¶
CreateState initializes and returns a default State object.
func (*APJFile) DeleteObject ¶
DeleteObject removes a specific object by its ID.
func (*APJFile) DeleteObjects ¶
func (apj *APJFile) DeleteObjects()
DeleteObjects clears all objects from the APJFile.
func (*APJFile) Display ¶
func (apj *APJFile) Display()
Display prints the details of the APJFile instance in a structured format.
func (*APJFile) DisplayStats ¶
func (apj *APJFile) DisplayStats()
GetStats returns statistics about the project.
func (*APJFile) GetReorderedBlocks ¶
GetReorderedBlocks returns a new slice of blocks reordered based on the provided order.
func (*APJFile) GetReorderedSprites ¶
GetReorderedSprites returns a reordered list of sprites based on the provided order and offset
func (*APJFile) HeaderInit ¶
func (apj *APJFile) HeaderInit()
HeaderInit initializes the APJFile with default header and version values.
func (*APJFile) ImportAGD ¶
func (apj *APJFile) ImportAGD(agdFilePath string, options ImportOptions) error
ImportAGD imports data from an AGD file into the APJ file.
func (*APJFile) ImportBlocks ¶
ImportBlocks imports block data from a slice of strings.
func (*APJFile) ImportFont ¶
ImportFont imports font data from lines and populates apj.Data["Font"]
func (*APJFile) ImportObjects ¶
ImportObjects parses object definitions and data from a list of strings.
func (*APJFile) ImportScreens ¶
func (*APJFile) ImportSpritePos ¶
ImportSpritePos parses sprite position data from a list of strings and associates it with a specific screen ID.
func (*APJFile) ImportSprites ¶
ImportSprites imports sprite data from a list of strings
func (*APJFile) ImportULAPalette ¶
ImportULAPalette imports ULAPlus palette data from a slice of strings. Each string represents a line of palette data, and the function parses and updates the palette colors.
func (*APJFile) KeysInit ¶
KeysInit initializes the Keys field with default values if it is empty or if overwrite is true.
func (*APJFile) ListBackupProjectFiles ¶
List the backup files in the backup directory
func (*APJFile) LivesScoreInit ¶
LivesScoreInit initializes the LivesScore struct with default values. If overwrite is true, it resets the values to defaults.
func (*APJFile) LoadYAMLFromString ¶
func (*APJFile) MapDefault ¶
func (apj *APJFile) MapDefault()
func (*APJFile) MonitorFileChanges ¶
MonitorFileChanges monitors the specified file for changes and creates a backup when changes are detected. It uses a polling mechanism to check the file's last modified time every 5 seconds.
func (*APJFile) ObjectDefault ¶
func (apj *APJFile) ObjectDefault()
ObjectDefault initializes the Objects slice with a single default object if it is empty.
func (*APJFile) ObjectInit ¶
ObjectInit initializes or resets the Objects slice based on the overwrite flag.
func (*APJFile) PurgeBackupFiles ¶
PurgeBackupFiles purges the backup files in the backup directory
func (*APJFile) ReadAPJ ¶
ReadAPJ reads the entire APJ file and processes its components sequentially.
func (*APJFile) RemapScreens ¶
make a copy of the screen data then remap the blocks
func (*APJFile) RenderBlockToBitmap ¶
func (apj *APJFile) RenderBlockToBitmap(startIndex, endIndex uint8, filePath string, reorder []int, offset int) error
RenderBlockToBitmap renders blocks to a bitmap file.
func (*APJFile) RenderBlockToTerminal ¶
renderBlockToTerminal renders blocks to the terminal.
func (*APJFile) RenderScreenToBitmap ¶
RenderScreenToBitmap renders the specified screen to a bitmap and saves it as a PNG file.
func (*APJFile) RenderSpriteToBitmap ¶
func (apj *APJFile) RenderSpriteToBitmap(startIndex, endIndex uint8, filePath string, reorder []int, offset int) error
RenderSpriteToBitmap renders a range of sprites to a bitmap file
func (*APJFile) RenderSpriteToTerminal ¶
func (apj *APJFile) RenderSpriteToTerminal(startIndex, endIndex uint8, reorder []int, offset int) error
RenderSpriteToTerminal renders a range of sprites to the terminal using tcg This function assumes that the terminal supports 2x3 pixel characters
func (*APJFile) ReorderBlocks ¶
ReorderBlocks reorders the blocks based on the provided order.
func (*APJFile) ReorderScreens ¶ added in v0.1.4
ReorderScreens reorders the screens based on the provided order slice. The order slice should contain the new indices for the screens.
func (*APJFile) ReorderSprites ¶ added in v0.1.4
ReorderSprites reorders the sprites based on the provided order and offset It updates the sprite IDs in the SpriteInfo array accordingly
func (*APJFile) ResetState ¶
func (apj *APJFile) ResetState()
ResetState resets the APJ file's state to its default values.
func (*APJFile) RestoreLastBackup ¶
Restore the last backup file
func (*APJFile) RotateBlock ¶
RotateBlock rotates a block's Spectrum data 90 degrees counter-clockwise or clockwise.
func (*APJFile) RotateSprite ¶
RotateSprite rotates a sprite by 90 degrees clockwise or counter-clockwise
func (*APJFile) SaveAsYAML ¶
add a function to save the APJ file as a yaml file
func (*APJFile) ScreensDefault ¶
func (apj *APJFile) ScreensDefault()
func (*APJFile) ScreensInit ¶
func (*APJFile) SetFrameDefaults ¶
SetFrameDefaults initializes the frame data for a sprite
func (*APJFile) SetNoColorOutput ¶ added in v0.1.4
func (*APJFile) SpriteDefault ¶
func (apj *APJFile) SpriteDefault()
SpriteDefault initializes the default sprite data structure
func (*APJFile) SpriteInfoInit ¶
SpriteInfoInit initializes the SpriteInfo slice. If `overwrite` is true, it clears the existing data.
func (*APJFile) SpriteInit ¶
SpriteInit initializes the sprite data structure
func (*APJFile) SpriteTo2DArray ¶
SpriteTo2DArray converts a sprite's image data into a 2D array representation It assumes the sprite is 16x16 pixels and each pixel is represented by a bit in the byte array.
func (*APJFile) ULAPaletteInit ¶
ULAPaletteInit initializes the ULAPlus palette with default values. If the overwrite flag is true, it will reset the palette even if it already contains data.
type Block ¶
type Block struct {
ID uint8 // Unique identifier for the block
Type uint8 // Unique identifier for the block
Spectrum []uint8 // Spectrum platform data
Timex []uint8 // Timex platform data
CPC []uint8 // CPC platform data
Atom []uint8 // Atom platform data
MSX []uint8 // MSX platform data
AtomColour []uint8 // Atom color data
}
Block represents a game block with various platform-specific data.
type ImportOptions ¶
type ImportOptions struct {
// contains filtered or unexported fields
}
ImportOptions defines options for importing various components. Each field represents whether to overwrite or ignore a specific component during import.
func CreateImportOptions ¶
func CreateImportOptions() ImportOptions
CreateImportOptions initializes an ImportOptions instance with default values (all false).
func (*ImportOptions) SetIgnoreOptions ¶
func (o *ImportOptions) SetIgnoreOptions(ignoreWindow, ignoreKeys, ignoreBlocks, ignoreSprites, ignoreObjects, ignoreScreens, ignoreMaps, ignoreFonts, ignoreULAPalette bool)
SetIgnoreOptions sets the ignore options for all components.
func (*ImportOptions) SetIgnoreOptionsFalse ¶
func (o *ImportOptions) SetIgnoreOptionsFalse()
SetIgnoreOptionsFalse disables ignore for all components.
func (*ImportOptions) SetIgnoreOptionsTrue ¶
func (o *ImportOptions) SetIgnoreOptionsTrue()
SetIgnoreOptionsTrue enables ignore for all components.
func (*ImportOptions) SetOwOptions ¶
func (o *ImportOptions) SetOwOptions(owWindow, owKeys, owBlocks, owSprites, owObjects, owScreens, owMaps, owFonts, owULAPalette bool)
SetOwOptions sets the overwrite options for all components.
func (*ImportOptions) SetOwOptionsFalse ¶
func (o *ImportOptions) SetOwOptionsFalse()
SetOwOptionsFalse disables overwrite for all components.
func (*ImportOptions) SetOwOptionsTrue ¶
func (o *ImportOptions) SetOwOptionsTrue()
SetOwOptionsTrue enables overwrite for all components.
type LivesScore ¶
type LivesScore struct {
ScoreTop uint8
ScoreLeft uint8
LivesTop uint8
LivesLeft uint8
HighTop uint8
HighLeft uint8
TimeTop uint8
TimeLeft uint8
EnergyTop uint8
EnergyLeft uint8
}
LivesScore holds the positions of various game elements like score, lives, etc.
type Map ¶
type Map struct {
Height uint8
Width uint8
StartRow uint8
StartColumn uint8
StartScreen uint8
Map [][]uint8
}
MapData holds map-related data
type Object ¶
type Object struct {
ID uint8 // Unique identifier for the object
Spectrum []uint8 // Data specific to the Spectrum platform
Timex []uint8 // Data specific to the Timex platform
CPC []uint8 // Data specific to the CPC platform
Atom []uint8 // Data specific to the Atom platform
MSX []uint8 // Data specific to the MSX platform
AtomColour []uint8 // Colour data for the Atom platform
VZColour []uint8 // Colour data for the VZ platform
}
Object represents the structure of an object with various platform-specific data.
type Sprite ¶
type Sprite struct {
SpriteID uint8
OffSet uint8
Frames uint8
Spectrum []SpriteFrame
Timex []SpriteFrame
CPC []SpriteFrame
Atom []SpriteFrame
AtomColour []SpriteFrame
VZColour []SpriteFrame
}
Sprite represents the structure of a sprite
type SpriteFrame ¶
SpriteFrame represents a single frame of sprite data
type SpriteInfo ¶
type SpriteInfo struct {
Type uint8 // Type of the sprite
Image uint8 // Image ID associated with the sprite
Unknown uint8 // Placeholder for unknown data
Screen uint8 // Screen ID where the sprite is located
X uint8 // X-coordinate of the sprite
Y uint8 // Y-coordinate of the sprite
}
SpriteInfo represents the structure of a sprite's position data.
type State ¶
type State struct {
FilePath bool
Windows bool
Header bool
Version bool
AsmPath bool
Blocks bool
Screens bool
EnterpriseBias bool
LivesScore bool
Map bool
Fonts bool
Keys bool
Objects bool
SpriteInfo bool
Sprites bool
ULAPalette bool
BlocksOffSet uint8
}
State represents the state of an APJ file with various flags and settings.
type Template ¶
Template represents a template with metadata such as name, file name, type, and description.
func CreateTemplate ¶
CreateTemplate creates a new Template instance by extracting the name from the file name.
func ListTemplates ¶
ListTemplates lists all available templates in the embedded templates directory.
type ULAPalette ¶
type ULAPalette struct {
Colors []uint8
}
ULAPalette represents the ULAPlus palette data. The ULAPlus palette is a 16-color palette used in the ULAPlus graphics system. The palette is represented as a slice of uint8 values, where each value corresponds to a color index.
Source Files
¶
- mpagd_asm_path.go
- mpagd_block_types.go
- mpagd_blocks.go
- mpagd_compare.go
- mpagd_enterprise_bias.go
- mpagd_file_manager.go
- mpagd_fonts.go
- mpagd_header.go
- mpagd_helper.go
- mpagd_keys.go
- mpagd_lives_scores.go
- mpagd_maps.go
- mpagd_objects.go
- mpagd_options.go
- mpagd_project.go
- mpagd_read.go
- mpagd_screens.go
- mpagd_sprite.go
- mpagd_sprite_pos.go
- mpagd_type.go
- mpagd_ula_pallet.go
- mpagd_write.go