start varaible size row length

master
Avril 4 years ago
parent 7788284b9e
commit b3dd6c608b
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,8 +1,9 @@
SRC:=src/*.cpp
INCLUDE:=include/
BUILD:=build
CFLAGS:=-Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto
LFLAGS:=-O2 -flto -ltickit -lfmt
FEATURES?=-DFIXED_ROW_SIZE=24
CFLAGS:= $(FEATURES) -Wall -pedantic -O3 -march=native --std=gnu++20 -fgraphite -flto
LFLAGS:=-O3 -flto -lfmt
hexview:
g++ $(SRC) $(CFLAGS) -I$(INCLUDE) -o $(BUILD)/$@ $(LFLAGS)

@ -1,15 +0,0 @@
#pragma once
#include <memory>
namespace gr
{
struct Context
{
Context();
~Context();
private:
struct _impl;
std::unique_ptr<_impl> impl;
};
}

@ -1,33 +0,0 @@
#include <tickit.h>
#include <graphics.hpp>
static int on_geomchange(TickitWindow* win, TickitEventFlags flags, void* info, void* data)
{
tickit_window_expose(win, NULL);
gr::Context* ctx = (gr::Context*)data;
}
namespace gr
{
struct Context::_impl
{
Tickit* context;
TickitWindow* root;
};
Context::Context()
: impl(std::make_unique<_impl>())
{
impl->context = tickit_new_stdtty();
impl->root = tickit_get_rootwin(impl->context);
if(!impl->root) throw "couldn't create window.";
}
Context::~Context()
{
tickit_unref(impl->context);
}
}

@ -20,18 +20,30 @@ const static constexpr char ascii_map[255] = {
'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
};
const constexpr int ROW_SZ = 24;
#ifndef FIXED_ROW_SIZE
#include <alloca.h>
#endif
#ifdef FIXED_ROW_SIZE
constexpr int ROW_SZ = FIXED_ROW_SIZE;
#endif
namespace hv {
void print_screen(const span<unsigned char> memory, unsigned long offset)
{
#ifndef FIXED_ROW_SIZE
#define S (const char*)
int ROW_SZ = 24;
#else
#define S
#endif
fmt::print("0x{:016x} ", offset);
char ascii[1 + ROW_SZ];
ascii[ROW_SZ] = 0;
std::size_t i=0;
for(;i<memory.size();i++) {
if (i && i % ROW_SZ == 0) {
fmt::print(" {}", ascii);
fmt::print(" {}", S ascii);
fmt::print("\n0x{:016x} ", i+offset);
}
fmt::print("{:02x} ", memory[i]);
@ -45,6 +57,6 @@ namespace hv {
fmt::print(" ");
}
fmt::print(" {}", ascii);
fmt::print(" {}", S ascii);
}
}

@ -2,7 +2,6 @@
#include <fstream>
#include <memory-map.hpp>
#include <hex.hpp>
#include <graphics.hpp>
std::ifstream::pos_type filesize(const char* filename)
{

Loading…
Cancel
Save