Skip to content

Instantly share code, notes, and snippets.

View reidrac's full-sized avatar

Juan J. Martínez reidrac

View GitHub Profile
void pad_numbers8(uint8_t *s, uint8_t limit, uint8_t number)
{
/*
s += limit;
*s = 0;
do
{
limit--;
deep in the shady sadness of a vale
far sunken from the healthy breath of morn,
far from the fiery noon, and eve's one star,
sat gray-hair'd saturn, quiet as a stone,
still as the silence round about his lair;
forest on forest hung about his head
like cloud on cloud. no stir of air was there,
not so much life as on a summer's day
robs not one light seed from the feather'd grass,
but where the dead leaf fell, there did it rest.
; output of gcc -O2 -s -S main.c
.file "main.c"
.text
.p2align 4,,15
.globl abs
.type abs, @function
abs:
.LFB0:
.cfi_startproc
movl %edi, %edx
@reidrac
reidrac / cpr.py
Created November 15, 2016 19:35
Python script to create a GX4000 CPR file
#!/usr/bin/env python
__version__ = "1.0"
import sys
from argparse import ArgumentParser
import struct
ROM_SIZE = 32 * 1024 * 16
// using 4-bit per tile
// map compressed (UCL/2B)
const unsigned char map[66] = {
0x92, 0x33, 0x72, 0x30, 0x00, 0x0d, 0x03, 0x80, 0x09, 0x7d,
0x33, 0x55, 0x53, 0xfb, 0x07, 0x35, 0x55, 0x27, 0x08, 0x6d,
0x33, 0x01, 0x73, 0x02, 0x3b, 0x23, 0xd9, 0x30, 0x03, 0x09,
0x1b, 0x67, 0xb6, 0x03, 0x33, 0x27, 0x2c, 0x29, 0x6c, 0x03,
0x09, 0x23, 0x66, 0x93, 0xc0, 0x8b, 0xb6, 0x41, 0xb6, 0x8b,
0x35, 0xeb, 0x02, 0x30, 0xa9, 0x02, 0xd9, 0x00, 0x20, 0x00,
@reidrac
reidrac / cpcre
Created August 28, 2016 15:19
CPCE + WINE wrapper for Linux
#!/bin/bash
CPCPATH=/home/user/apps/cpce
REALPATH=`realpath "$1"`
FILE=`winepath -w "$REALPATH"`
echo auto-booting $FILE...
cd $CPCPATH && exec wine CPCE95.EXE /a+ "$FILE
FPS = 1.0/60
UFPS = 1.0/80
dt = 0
....
def update(last_dt):
if paused:
return
/*
Esto es, por ejemplo, del Ninjajar.
En lugar de usar una variable para acceder a los parámetros,
podéis usar __CALLEE__ call convention de Z88DK.
(esto es de memoria, pero igual hasta va!)
*/
@reidrac
reidrac / lambda.py
Created June 8, 2015 14:44
lambda fun (& closures)
def func(text):
print(text)
text = "hello"
l = lambda : func(text)
l()
# correct!
text = "uh?"
l()
#include "d64.h"
int
main()
{
uint8_t r;
clrscr();
while(1)