Skip to content

Commit

Permalink
switch to using fmt because gcc sucks
Browse files Browse the repository at this point in the history
  • Loading branch information
beardypig committed Oct 19, 2024
1 parent 9082731 commit 0604aa2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"name": "nix-x64-release",
"configurePreset": "nix-x64-release",
"description": "Build for *nix x64 Release",
"jobs": 4,
"verbose": true
}
],
Expand Down
3 changes: 2 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"dependencies": [
"catch2",
"cxxopts",
"trompeloeil",
"cxxopts"
"fmt"
]
}
2 changes: 2 additions & 0 deletions vectgif/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
find_package(cxxopts CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)

add_executable(vectgif main.cpp)

Expand All @@ -12,3 +13,4 @@ endif()

target_link_libraries(vectgif PRIVATE ${LIBRETRO_SRC})
target_link_libraries(vectgif PRIVATE cxxopts::cxxopts)
target_link_libraries(vectgif PRIVATE fmt::fmt)
13 changes: 7 additions & 6 deletions vectgif/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include <iostream>
#include <fstream>
#include <string_view>
#include <format>
#include <optional>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <vectrexia.h>
#include "gif.h"
#include <cxxopts.hpp>
Expand Down Expand Up @@ -47,22 +48,22 @@ int main(int argc, char *argv[])
if (result.count("gif") && !result["gif"].as<std::string>().empty()) {
giffilename = result["gif"].as<std::string>();
} else {
giffilename = std::format("{}.gif", rom_filename);
giffilename = fmt::format("{}.gif", rom_filename);
}

// Load the ROM file
std::ifstream romfile(rom_filename, std::ios::binary);
if (!romfile) {
std::cerr << "[ROM]: Failed to open ROM file " << rom_filename << "\n";
std::cerr << fmt::format("[ROM]: Failed to open ROM file {}\n", rom_filename);
return 1;
}

std::cout << std::format("[ROM]: loading ROM \"{}\"\n", rom_filename);
std::cout << fmt::format("[ROM]: loading ROM \"{}\"\n", rom_filename);
romfile.read(reinterpret_cast<char*>(rombuffer.data()), ROM_SIZE);
auto r = static_cast<size_t>(romfile.gcount());
romfile.close();

std::cout << std::format("[ROM]: size = {}\n", r);
std::cout << fmt::format("[ROM]: size = {}\n", r);

if (!vectrex->LoadCartridge(rombuffer.data(), r)) {
std::cerr << "Failed to load the ROM file\n";
Expand Down Expand Up @@ -92,7 +93,7 @@ int main(int argc, char *argv[])
}
GifWriteFrame(&gw, gif_buffer.data(), FRAME_WIDTH, FRAME_HEIGHT, 2);
if (frame % 100 == 0) {
std::cout << std::format("[VECTREX] frame = {}\n", frame);
std::cout << fmt::format("[VECTREX] frame = {}\n", frame);
}
}

Expand Down

0 comments on commit 0604aa2

Please sign in to comment.