Skip to content

Commit

Permalink
add: rename tilesmap as assembly file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Le Saux committed Apr 9, 2024
1 parent 1837c08 commit 5f35e97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ This option allows to create allow tiles and tile map from the input image. If f

By this command line, martine will analyse the image to find all tiles 16 pixels high and 16 pixels wide. It will keep in memory the tile position to produce the tile map.
![samples/mario-level1/tilesmap_schema.png](samples/mario-level1/tilesmap_schema.png)
A csv ot the same tile map is also created (tilesmap.map).
A csv ot the same tile map is also created (tilesmap.asm).
Martine will also generate all tiles found.
- ![samples/mario-level1/00.png](samples/mario-level1/00.png) tile 00
- ![samples/mario-level1/01.png](samples/mario-level1/01.png) tile 01
Expand Down
10 changes: 5 additions & 5 deletions gfx/tilemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func AnalyzeTilemap(mode uint8, isCpcPlus bool, filename, picturePath string, in
log.GetLogger().Error("Cannot save tilemap schema error :%v\n", err)
return err
}
if err := choosenBoard.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.map")); err != nil {
if err := choosenBoard.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.asm")); err != nil {
log.GetLogger().Error("Cannot save tilemap csv file error :%v\n", err)
return err
}
Expand Down Expand Up @@ -219,7 +219,7 @@ func ExportTilemapClassical(m image.Image, filename string, board *transformatio
log.GetLogger().Error("Cannot save tilemap schema error :%v\n", err)
return err
}
if err := board.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.map")); err != nil {
if err := board.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.asm")); err != nil {
log.GetLogger().Error("Cannot save tilemap csv file error :%v\n", err)
return err
}
Expand Down Expand Up @@ -382,7 +382,7 @@ func Tilemap(mode uint8, filename, picturePath string, size constants.Size, in i
log.GetLogger().Error("Cannot save tilemap schema error :%v\n", err)
return err
}
if err := analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.map")); err != nil {
if err := analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.asm")); err != nil {
log.GetLogger().Error("Cannot save tilemap csv file error :%v\n", err)
return err
}
Expand Down Expand Up @@ -581,7 +581,7 @@ func ExportTilemap(analyze *transformation.AnalyzeBoard, filename string, palett
log.GetLogger().Error("Cannot save tilemap schema error :%v\n", err)
return err
}
if err = analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.map")); err != nil {
if err = analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.asm")); err != nil {
log.GetLogger().Error("Cannot save tilemap csv file error :%v\n", err)
return err
}
Expand Down Expand Up @@ -675,7 +675,7 @@ func ExportImpdrawTilemap(analyze *transformation.AnalyzeBoard, filename string,
log.GetLogger().Error("Cannot save tilemap schema error :%v\n", err)
return err
}
if err = analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.map")); err != nil {
if err = analyze.SaveTilemap(filepath.Join(cfg.OutputPath, "tilesmap.asm")); err != nil {
log.GetLogger().Error("Cannot save tilemap csv file error :%v\n", err)
return err
}
Expand Down
14 changes: 9 additions & 5 deletions gfx/transformation/tile_analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ func (a *AnalyzeBoard) SaveSprites(folderpath string, palette color.Palette, mod
return err
}

filename := filepath.Join(spriteFolder, fmt.Sprintf("%.4d.png", index))
err = sprite.ToSpriteAndExport(im, palette, v.Size, mode, filename, true, cfg)
if err != nil {
return err
}
// filename := filepath.Join(spriteFolder, fmt.Sprintf("%.4d.png", index))
// err = sprite.ToSpriteAndExport(im, palette, v.Size, mode, filename, true, cfg)
// if err != nil {
// return err
// }
d, _, _, err := sprite.ToSprite(im, palette, a.TileSize, mode, cfg)
if err != nil {
return err
Expand Down Expand Up @@ -530,6 +530,10 @@ func (a *AnalyzeBoard) SaveTilemap(filePath string) error {
return err
}
defer f.Close()
_, err = f.WriteString("tilemap\n")
if err != nil {
return err
}
for _, v := range a.TileMap {
for _, val := range v {
_, err := f.WriteString(fmt.Sprintf("%.2d", val) + ",")
Expand Down

0 comments on commit 5f35e97

Please sign in to comment.