Skip to content

Instantly share code, notes, and snippets.

View emoon's full-sized avatar
:octocat:
Hacking on stuff!

Daniel Collin emoon

:octocat:
Hacking on stuff!
View GitHub Profile
@emoon
emoon / api_poindering.md
Last active March 21, 2023 10:13
API pondering

Figuring out backwards compatible APIs

Introduction

For some of the applications I'm doing I want there to be a plugin API that people can use to expand them and it's also something I'm using myself for proper dog fooding. The issue is that I really can't settle on how to do it.

Talking about APIs here it's all about native code which has to be C compatible.

If we are talking strictly about C APIs one way to do this is to have everything passed as versioned structs to the plugin. Let me give an example.

use bgfx::*;
use bgfx_rs::bgfx;
use core::ffi::c_void;
use glfw::{ffi::glfwTerminate, Action, Key, Window};
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use std::vec;
fn get_platform_data(window: &Window) -> PlatformData {
let mut pd = PlatformData::new();
match window.raw_window_handle() {
Linux arika 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
AMD Ryzen Threadripper 2950X 16-Core Processor
  482 - record_replay_subject (Failed)
	483 - record_replay_subject-no-syscallbuf (Failed)
	555 - setuid-no-syscallbuf (Failed)
	692 - thread_yield (Failed)
@emoon
emoon / extract_ixa_music.c
Created June 8, 2019 20:19
Extract music from iXalance files (only seems to work for Astral blur right now)
// Code mostly extracted from https://www.libsdl.org/projects/ixalance/ but fixed a bunch of 64-bit issues with the code
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define INDEX_BIT_COUNT 10 // This is a total window of 4Kb
#define LENGTH_BIT_COUNT 4
#define WINDOW_SIZE ( 1 << INDEX_BIT_COUNT )
➜ fx68x_verilator git:(master) ✗ verilator --clk clk --debug --cc -Wno-fatal fx68k.v fx68k_MicroRom.v fx68k_NanoRom.v --exe sim_main.cpp
/usr/local/bin/verilator_bin_dbg --clk clk --debug --cc -Wno-fatal fx68k.v fx68k_MicroRom.v fx68k_NanoRom.v --exe sim_main.cpp
Starting Verilator 4.015 devel rev UNKNOWN_REV
- V3Os.cpp:57: export SYSTEMC_ARCH=linux # From sysname 'linux'
- V3File.cpp:218: --check-times failed: different command line
- V3GraphTest.cpp:358:selfTest:
- V3ParseImp.cpp:114: parseFile: fx68k
Preprocessing fx68k.v
- V3PreShell.cpp:151: Reading fx68k.v
- V3ParseImp.cpp:160: Lexing fx68k.v
-V{t0,98335}+++++TOP Evaluate Vfx68k::eval
-V{t0,98336}+ Vfx68k::_eval_debug_assertions
-V{t0,98337}+ Clock loop
-V{t0,98338}+ Vfx68k::_eval
-V{t0,98339}+ Vfx68k::_combo__TOP__10
-V{t0,98340}+ Vfx68k::_sequent__TOP__11
-V{t0,98341}+ Vfx68k_fx68k_bmux_1882::_settle__TOP__fx68k__DOT__excUnit__DOT__mux_1399_12__1
-V{t0,98342}+ Vfx68k_fx68k_bmux_1882::_settle__TOP__fx68k__DOT__excUnit__DOT__mux_1413_12__2
-V{t0,98343}+ Vfx68k_fx68k_bmux_1967::_settle__TOP__fx68k__DOT__excUnit__DOT__mux_regs68L__05BactualRx__05D_1348_24__6
-V{t0,98344}+ Vfx68k_fx68k_bmux_1967::_settle__TOP__fx68k__DOT__excUnit__DOT__mux_regs68H__05BactualRx__05D_1330_29__2

68000 instructions timings

When I started to write some pure 68000 I didn't find a nice doc that would cover all the op codes I used which a nice diagram for the cycle counts so I made one. This info has been assembled / hacked up using this tool https://github.com/emoon/68k_documentation_gen with a bunch of manual work and some automation for generating the cycle tables. If you find any errors in this (I'm sure there are plenty but it has been useful for me) please contact me or even better do a PR :)

ABCD

Operation: Source10 + Destination10 + X → Destination

@emoon
emoon / na test.md
Last active November 30, 2018 08:10
extern crate nalgebra as na;
use na::{Matrix4};

pub fn mul(m0: &Matrix4<f32>, m1: &Matrix4<f32>) -> Matrix4<f32> {
    m0 * m1
}

-> output

#[macro_use]
extern crate wrui;
use wrui::{SharedLibUi, Ui};
#[cfg(target_os="windows")]
fn get_wrui_path() -> &'static str {
"t2-output/win64-msvc-debug-default/wrui_qt.dll"
}

Notice that this is early, things may or may not work at all.

  1. Clone https://github.com/emoon/fs-uae and build according to instructions. (Mac tested in my case)
  2. Clone ProDBG to this commit https://github.com/emoon/ProDBG/commit/a4a5c264a57b15d0325c585ff7995c31bb9216d4 and build according to instructions.
  3. Configure ProDBG Amiga UAE Settings so it looks something like this https://www.dropbox.com/s/a87dpxdf273bi6i/config.png?dl=0 (Config can be left empty)
  4. Make a test program and build it with vasm (or some other tool that can produce linedebug info)

Compile with these options (make sure to keep paths absolute) for vasm