Skip to content

Instantly share code, notes, and snippets.

@CryZe
CryZe / lib.rs
Last active October 30, 2023 17:50
Protected memory
use std::{
marker::PhantomData,
mem,
ops::{Deref, DerefMut},
ptr::{self, NonNull},
};
use bytemuck::{AnyBitPattern, Zeroable};
mod utils;
@CryZe
CryZe / redfall.rs
Last active May 8, 2023 16:49
New abstraction for writing auto splitters
#![no_std]
use asr::{
future::{next_tick, retry},
signature::Signature,
timer, Process,
};
asr::panic_handler!();
@CryZe
CryZe / AutoSplittingRuntimeSupport.md
Last active June 14, 2023 08:42
A survey about programming language support for LiveSplit One's Auto Splitting Runtime

Auto Splitting Runtime Support

Supported languages

Rust

  • 👍 Modern language with really good WebAssembly support
  • 👍 Great ecosystem where most crates work perfectly fine in WebAssembly
  • 👍 Easy project setup
  • 👎 Ownership and borrowing make things a little harder
@CryZe
CryZe / asr.go
Created April 17, 2023 20:56
Bindings for LiveSplit One's Auto Splitting Runtime for TinyGo
package asr
import "time"
type TimerState = uint32
type ProcessId = uint64
type Address = uint64
func decodeString(text string) (*byte, uint) {
return decodeSlice(([]byte)(text))
@CryZe
CryZe / Monotonic.md
Last active June 14, 2023 08:42
Notes on Monotonic Clocks

Notes on Monotonic Clocks

We can't use std's Instant as it's insufficiently specified. It neither guarantees "real time" nor does it guarantee measuring "uptime" (the time the OS has been awake rather than suspended), meaning that you can't actually rely on it in practice. In livesplit-core we definitely want real time rather than uptime. Various operating systems are problematic:

Linux, BSD and other Unixes

Compiled Emblem Information

Drop Rates

  • Bronze: 88%
  • Silver: 10%
  • Gold: 2%

Type Stacking (when you have multiple of the same type)

@CryZe
CryZe / auto-splitter.c
Last active June 11, 2022 12:33
Auto Splitter written in C
#include "asr/asr_helpers.h"
#include "asr/mini_libc.h"
ProcessId process = 0;
Address unity = 0;
uint8_t old_run_active = 0;
uint8_t old_timer_paused = 0;
typedef struct {
@CryZe
CryZe / asr.d.ts
Last active June 2, 2022 18:42
TypeScript Definition file for the new Auto Splitting Runtime
/**
* Sets the tick rate of the runtime. This influences the amount of times the
* `update` function is called per second.
*/
declare function setTickRate(ticksPerSecond: number): void;
/** Prints a log message for debugging purposes. */
declare function printMessage(message: unknown): void;
declare type Address = BigInt;
pub trait PopulateString {
fn populate(self, buf: &mut String);
fn as_str(&self) -> &str;
fn into_string(self) -> String {
let mut buf = String::new();
self.populate(&mut buf);
buf
}
}
@CryZe
CryZe / asl_abstraction.rs
Last active January 9, 2022 18:13
Slight abstraction layer for the new Auto Splitting runtime.
struct Eversleep {
time_info: Watcher<TimeInfo>,
}
impl<'a> AutoSplitter<'a> for Eversleep {
type Data = &'a Pair<TimeInfo>;
fn unhooked(&mut self) {
self.time_info.update(None);
}