Skip to content

Instantly share code, notes, and snippets.

View kion-dgl's full-sized avatar

Kion kion-dgl

View GitHub Profile
@kion-dgl
kion-dgl / psx-extract-mem.js
Created July 17, 2023 06:35
Decompresses a pcsxr save state, pulls out the memory into it's own file, and any time that memory file is edited, the save ste is updated with new memory.
// Imports
const { readFileSync, writeFileSync, watchFile } = require('fs')
const { gunzipSync, gzipSync } = require('zlib')
// Constants
const dir = "/home/benjamin/.pcsxr/sstates"
const src = "MEGAMAN_LEGENDS2-SLUS01140.002"
const dst = "MEGAMAN_LEGENDS2-SLUS01140.004"
const memPath = "./mem.bin"
@kion-dgl
kion-dgl / read_verts.js
Created July 5, 2019 02:33
A short script that takes an xpdata struct as an argument and attempts to read the fixed float vec3 format for sega saturn
"use strict";
const fs = require("fs");
const fp = fs.readFileSync("hwram.bin");
const xpdata = {
offset: 0x056424,
vlist_offset: 0x60561cc,
vlist_count: 0x000010,
plist_offset: 0x605628c,
@kion-dgl
kion-dgl / find_xpdata.js
Created July 5, 2019 02:32
A short script that looks through the high work memory for sega saturn to look for possible xp data structs
"use strict";
const fs = require("fs");
const fp = fs.readFileSync("hwram.bin");
const ptr_keys = [
"vlist_offset",
"plist_offset",
"attr_offset",
"vntbl"
@kion-dgl
kion-dgl / compare.js
Created July 5, 2019 02:30
Using nodejs to compare two files, and logging the differences with more than 100 consequtive bytes
"use strict";
const fs = require("fs");
const src = fs.readFileSync("hwram.bin");
const dst = fs.readFileSync("hwram_sho.bin");
let key;
let chain = 0;
let changes = {};
@kion-dgl
kion-dgl / export_support.c
Created January 12, 2018 14:22
Short C code for exporting an embedded model from archive into an OBJ file
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
struct MeshHeader {
uint8_t tri_count;
uint8_t quad_count;
uint8_t vertex_count;
uint8_t nop;
@kion-dgl
kion-dgl / gtk_save_file_dialog.c
Created December 12, 2017 17:49
Setting default name of an image using the GTK file chooser
static void open_export(GApplication *app, gpointer user_data) {
GtkWidget *dialog;
gint res;
dialog = gtk_file_chooser_dialog_new (
"Save Texture (.png)",
GTK_WINDOW(user_data),
GTK_FILE_CHOOSER_ACTION_SAVE,
"Cancel",
@kion-dgl
kion-dgl / dashgl_version_01.c
Created November 7, 2017 12:50
Saving previous version of DashGL for use later
/*
This file is part of Dash Graphics Library
Copyright 2017 Benjamin Collins
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions: