Overview
DevCPC automatically converts PNG images to Z80 assembly sprite data that can be used directly in your games. The conversion handles:- Color palette mapping to CPC colors
- Multiple sprite images from different PNG files
- Automatic width/height encoding
- Palette information for each sprite
Quick Start
1. Create Sprite PNG
Create sprites in your image editor:- Mode 0: Any width (even pixels), any height, max 16 colors
- Mode 1: Width divisible by 4, any height, max 4 colors
- Mode 2: Width divisible by 8, any height, max 2 colors
2. Configure Project
3. Place PNG Files
4. Build
CPC Screen Modes
Mode 0: 160x200, 16 Colors
Best for: Colorful sprites, detailed graphics, most games- Width: Must be even (2, 4, 6, 8, 10, 12, 14, 16, …)
- Height: Any value (typically 8, 16, 24, 32)
- Colors: Maximum 16 from CPC palette
- Memory: 1 byte = 2 pixels
- 16x16 sprite = 8 bytes wide × 16 lines = 128 bytes
- 32x32 sprite = 16 bytes wide × 32 lines = 512 bytes
Mode 1: 320x200, 4 Colors
Best for: Sharp graphics, text, retro aesthetic- Width: Divisible by 4 (4, 8, 12, 16, 20, …)
- Height: Any value
- Colors: Maximum 4 from CPC palette
- Memory: 1 byte = 4 pixels
- 16x16 sprite = 4 bytes wide × 16 lines = 64 bytes
- 32x32 sprite = 8 bytes wide × 32 lines = 256 bytes
Mode 2: 640x200, 2 Colors
Best for: High-res graphics, monochrome art- Width: Divisible by 8 (8, 16, 24, 32, …)
- Height: Any value
- Colors: Maximum 2 from CPC palette
- Memory: 1 byte = 8 pixels
PNG to ASM Conversion
Basic Conversion
Generated ASM File
Configuration Options
Tolerance
Controls how closely PNG colors must match CPC palette:Transparency
Set which INK represents transparent pixels:Complete Configuration
Using Sprites in 8BP
Setup Sprite
Position and Draw
Animation
Using Sprites in Pure ASM
CPCRSLIB-Style Sprite Routine
Using the Sprite
Creating Animation Sequences
Frame-by-Frame Animation
Create multiple PNG files:Animation in BASIC
Animation Table in ASM
Sprite Sheet Conversion
For multiple frames in one PNG:Create Sprite Sheet
Manual Extraction
After conversion, sprite sheet becomes one image. You need to:- Option A: Create separate PNG files (recommended)
- Option B: Extract frames in code:
Masked Sprites (Transparency)
Creating Mask
For true transparency, create a mask sprite:Drawing Masked Sprite
Optimizing Sprite Performance
1. Pre-shift Sprites
For smooth horizontal scrolling:2. Unrolled Drawing
For fixed-size sprites:3. Screen Address Lookup Table
Color Considerations
CPC Palette
Always use these exact RGB values:Dithering
For gradient effects:Palette Cycling
Animate without redrawing:Troubleshooting
”Width not divisible by X”
Problem: PNG width doesn’t match mode requirements Solution:- Mode 0: Make width even (2, 4, 6, 8, …)
- Mode 1: Make width divisible by 4
- Mode 2: Make width divisible by 8
”Too many colors”
Problem: PNG uses more colors than mode allows Solution:- Reduce colors in image editor
- Convert to indexed color mode
- Use only CPC palette colors
- Change to Mode 0 (16 colors)
“Color not in CPC palette”
Problem: Color doesn’t match CPC palette Solution:Sprite Flickers
Problem: Sprite flickers when moving Solution:Best Practices
1. Consistent Sizes
2. Power-of-2 Frames
3. Organize by Purpose
4. Name with Frame Numbers
Complete Example
See 8BP Game Example for a full project with animated sprites.Related
- 8BP Game Example - Complete game with sprites
- ASM Project Example - Pure ASM sprites
- Loading Screens - Full-screen images
- Multi-File Projects - Organizing assets