Skip to content

Instantly share code, notes, and snippets.

ferris yupferris

Block or report user

Report or block yupferris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reset_synchronizer.sv
// Note that the asynchronous reset input, reset_n, should be unconstrained, eg:
// set_false_path -from [get_ports {reset_n}] -to [get_clocks {*}]
`default_nettype none
module reset_synchronizer(
input reset_n,
input clk,
output reset_n_sync);
@yupferris
yupferris / led_test.sdc
Last active Sep 5, 2019
Simplest possible .sdc for future reference
View led_test.sdc
create_clock -name max10_clk_50 -period 20 [get_ports {max10_clk_50}]
# Note - can use `derive_pll_clocks -create_base_clocks` without specifying input clocks to derive everything when PLL's are used for all clocks
derive_pll_clocks
derive_clock_uncertainty
# Don't constrain async reset signal
set_false_path -from [get_ports {reset_n}] -to [all_registers]
# Don't constrain LED output
@yupferris
yupferris / i-win.md
Last active Feb 11, 2019
I beat exomizer by how much?
View i-win.md

tl;dr

  • original released intro size: 4095 bytes
  • final size with new packer: 3892 bytes (203 bytes reduction, 4.9% better than released version)
  • best possible size w/ smallest exomizer decoder: 4001 bytes
  • best possible size w/ largest exomizer decoder: 4024 bytes
  • new packer gain over smallest exomizer size: 109 bytes (2.7% reduction)
  • new packer gain over largest exomizer size: 132 bytes (3.3% reduction)

========================================

@yupferris
yupferris / ends_with_case_insensitive.rs
Last active Nov 4, 2017
ffs windows, ruining my file watching with your case-insensitivity..
View ends_with_case_insensitive.rs
// This is kindof a crazy way to compare paths, and in certain unicode corner cases will not be entirely correct,
// but it's a workaround for file name case insensitivity on Windows and should be good enough for most cases.
// The general idea (matching path component suffixes) mimicks Rust's Path::ends_with.
fn ends_with_case_insensitive(path: &PathBuf, suffix: &PathBuf) -> bool {
let path_comps = path.components().map(|x| String::from(x.as_os_str().to_string_lossy()).to_lowercase()).rev();
let suffix_comps = suffix.components().map(|x| String::from(x.as_os_str().to_string_lossy()).to_lowercase()).rev();
let matching_suffix_pairs = path_comps.zip(suffix_comps).filter(|&(ref x, ref y)| x == y);
matching_suffix_pairs.count() == suffix.components().count()
}
@yupferris
yupferris / vic.txt
Created Sep 10, 2017
VIC pseudocode (not necessarily accurate/rigorous, but useful enough to explain stuff)
View vic.txt
// Sometime outside of display area..
VCBASE := 0
VIDEO_COLOR_BUFFER := 0
for RASTER in 0..312 {
for line_cycle in 0..63 {
badline_condition := (RASTER & 0x07) == (YSCROLL & 0x07)
if (badline_condition) {
MODE = MODE_DISPLAY
}
View stuff.rs
extern crate minifb;
extern crate time;
use minifb::{Key, Scale, WindowOptions, Window};
use std::f64::consts::PI;
fn circle(x: f64, y: f64, x_offset: f64, y_offset: f64, rad: f64) -> bool {
let x_distance = x - x_offset;
let y_distance = y - y_offset;
@yupferris
yupferris / bowling.asm
Last active Mar 9, 2017
Virtual Bowling sample playback routine reversing notes
View bowling.asm
// Super high-level playroutine overview:
// Timer reload set to 12, 13, 5 (depending on sample)
// Timer int fires every ??us (sample rate of ??hz)
// Store 0x1d in timer control (small interval, zero interrupt enable, clear zero status, timer enable)
// Output volume to VOICE_1_ENVELOPE_DATA
// Sample value -> register value lookup table:
0xffffd258 00 10 20 30 40 50 60 70 80 90 a0 b0 c0 d0 e0 f0
// Sample playback routine (only thing the timer is used for in this game)
@yupferris
yupferris / tesoft.asm
Created Mar 2, 2017
Sample playback routine info for T&E soft logo in Red Alarm
View tesoft.asm
// Super high-level playroutine overview:
// Timer reload set to 0x0004
// Timer int fires every 120us (sample rate of ~8333.3hz)
// Store 0x15 in timer control (small interval, zero interrupt disable, clear zero status, timer enable)
// Output volumes to VOICE_1_VOLUME - VOICE_5_VOLUME
// Store 0x19 in timer control (small interval, zero interrupt enable, timer enable)
* 0xfffffe10 7c44 add 28, r3
0xfffffe12 23dc0000 st.w r1, 0[r3]
0xfffffe16 20bc0207 movhi 0x702, r0, r1
@yupferris
yupferris / pinball.rs
Last active Feb 25, 2017
Sample extraction for Galactic Pinball
View pinball.rs
use std::io::{self, Write, Read, BufWriter};
use std::fs::File;
use std::path::Path;
const NUM_CHANNELS: usize = 1;
const BITS_PER_SAMPLE: usize = 16;
fn main() {
let rom_file_name = "C:\\msys64\\home\\ferris\\dev\\projects\\vb-rs-corpus\\Galactic Pinball (Japan, USA).vb";
let buf = load(rom_file_name).unwrap();
@yupferris
yupferris / tennis.rs
Created Feb 23, 2017
You know the drill
View tennis.rs
use std::io::{self, Read};
use std::fs::File;
use std::path::Path;
fn main() {
let rom_file_name = "C:\\msys64\\home\\ferris\\dev\\projects\\vb-rs-corpus\\Mario's Tennis (Japan, USA).vb";
let buf = load(rom_file_name).unwrap();
let src = 0xfff9fb4c;
let dst = 0x00078000;
You can’t perform that action at this time.