Skip to content

Instantly share code, notes, and snippets.

@nurpax
nurpax / lfsr.c
Last active April 29, 2018 19:19
#define POLYMASK_32 0xb4bcd35c
#define POLYMASK_31 0x7a5bc2e3
#include <stdio.h>
#include <stdint.h>
uint32_t lfsr32;
uint32_t lfsr31;

Generate

prng: .byte 0,0,0,0 rngtest: lda #<prng ldx #>prng jsr rnd_seed ldy #$80 sty $61 lp1:

@nurpax
nurpax / snapshot.c
Created April 25, 2018 07:49
vice 3.1 snapshot.c copy
/*
* snapshot.c - Implementation of machine snapshot files.
*
* Written by
* Ettore Perazzoli <[email protected]>
* Marco van den Heuvel <[email protected]>
*
* This file is part of VICE, the Versatile Commodore Emulator.
* See README for copyright notice.
*
sprite0_widthmask:
// bitwidth 0
.byte 0, 0, 0, 0
// bitwidth 1
.byte %11111111, 0, 0, 0
// bitwidth 2
.byte %11111111, %11111111, 0, 0
// bitwidth 3
.byte %11111111, %11111111, %11111111, 0
// bitwidth 4
lda colora+0
sta $d020
lda colora+1
sta $d021
lda #$00
sta $d020
sta $d021
// multicolor gfx mode
//----------------------------------------------------------
.macro drawboard(screen,colorbuf) {
.const tsetbits = $62
.const tbits = $63
.const col = $64
lda #BLACK
sta col
lda #WHITE
sta col+1
// "container" for Kcal input forms (sets up formik with validation for the kcal fields).
export const KcalForm = ({ initialValues, onSubmit, render }) => {
return (
<Formik
initialValues={initialValues}
validateOnChange
validate={values => {
let errors = {}
if (values.amount === '') {
renderSaveCancel = () => {
return (
<Fragment>
<button onClick={this.handleSave}
style={{width: '50%'}}
disabled={!this.state.amount}
className='button is-primary'>
Save
</button>
<button onClick={this.handleCancel}
// Diary action creators
export class Diary {
static RECEIVE = 'DIARY_RECEIVE'
static actions = {
fetchByDate: (date) => {
return function (dispatch, getState) {
const urls = [
'/api/food',
'/api/recipe',
@nurpax
nurpax / bits.js
Created February 18, 2018 21:05
jsx
// NOTE only up to 5 bit numbers are supported
function makeFormula (bits) {
const superscripts = ['\u2070', '\u00B9', '\u00B2', '\u00B3', '\u2074']
const nbits = bits.length
const parts = bits.map((b,idx) => {
const boffs = nbits - idx - 1
return b.toString() + '\u22C5' + '2' + superscripts[boffs]
})
return parts.join(' + ')
}