mirror of
https://github.com/risingPhil/libpokemegb.git
synced 2026-09-15 04:17:51 -05:00
Initial import
This commit is contained in:
committed by
Philippe Symons
parent
2b1041b560
commit
5954a2a036
48
examples/encodeText_gen2/Makefile
Normal file
48
examples/encodeText_gen2/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
# # Compiler flags
|
||||
CXXFLAGS := -std=c++11 -fno-rtti -fno-exceptions -fno-unwind-tables -Wall -Wextra -I $(CURDIR) -I $(CURDIR)/../../include -g -Os
|
||||
|
||||
# Source files directory
|
||||
SRC_DIR := .
|
||||
# Build directory
|
||||
BUILD_DIR := build
|
||||
|
||||
# Source files (add more as needed)
|
||||
SRCS := $(shell find $(SRC_DIR) -type f -name '*.cpp')
|
||||
# Object files
|
||||
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
|
||||
|
||||
LIBS := -lpokemegb
|
||||
ifeq ($(PNG_SUPPORT),1)
|
||||
LIBS += -lpng
|
||||
endif
|
||||
|
||||
# Ensure necessary directories exist
|
||||
# This function ensures the directory for the target exists
|
||||
define make_directory
|
||||
@mkdir -p $(dir $@)
|
||||
endef
|
||||
|
||||
# Target executable
|
||||
TARGET := ../../encodeText_gen2
|
||||
|
||||
# Phony targets
|
||||
.PHONY: all clean
|
||||
|
||||
# Default target
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $^ -o $@ $(LIBS) -L ../../
|
||||
|
||||
# Rule to compile source files
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR)
|
||||
$(make_directory)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
# Create the build directory if it doesn't exist
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
# Clean rule
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(TARGET)
|
||||
27
examples/encodeText_gen2/main.cpp
Normal file
27
examples/encodeText_gen2/main.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "gen2/Gen2Common.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
static void print_hex(const unsigned char* buffer, size_t length)
|
||||
{
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
printf("%02X ", buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if(argc < 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: encodeText_gen2 <textToEncode>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t outputBuffer[4096];
|
||||
|
||||
const uint16_t size = gen2_encodePokeText(argv[1], strlen(argv[1]), outputBuffer, sizeof(outputBuffer), 0x50);
|
||||
print_hex(outputBuffer, size);
|
||||
}
|
||||
Reference in New Issue
Block a user