Skip to content

Instantly share code, notes, and snippets.

View main.asm
!use "./text" as text
!byte text("testing 123")
@nurpax
nurpax / romfont_to_64c.py
Created Nov 29, 2020
64c from C64 ROM font binary with some chars X'd out
View romfont_to_64c.py
import numpy as np
import sys
# C64 ROM font:
# https://github.com/nurpax/petmate/raw/master/assets/system-charset.bin
unallowed_pattern = np.array([
[1, 0, 0, 0, 0, 0, 1, 0],
[1, 1, 0, 0, 0, 1, 1, 0],
@nurpax
nurpax / customop.py
Last active Nov 27, 2020
nvcc problem
View customop.py
import torch
import torch.utils.cpp_extension
def compile():
ext_name = 'ext1'
torch.utils.cpp_extension.load(name=ext_name, sources=['ext1.cpp', 'ext1cuda.cu'], with_cuda=True, verbose=True)
def main():
compile()
View sokol-microui.c
#include "sokol_gfx.h"
#include <assert.h>
#include "mui_renderer.h"
#include "mui_atlas.inl"
#include "HandmadeMath.h"
#include <string.h>
#define BUFFER_SIZE 16384
View BigGAN.py
import numpy as np
import math
import functools
import torch
import torch.nn as nn
from torch.nn import init
import torch.optim as optim
import torch.nn.functional as F
from torch.nn import Parameter as P
View c64.asm
!filescope c64
!macro basic_start(addr) {
* = $801
!byte $0c, $08, $00, $00, $9e
!for d in [10000, 1000, 100, 10, 1] {
!if (addr >= d) {
!byte $30 + (addr/d)%10
}
}
@nurpax
nurpax / context.js
Last active Aug 10, 2019
zero page allocation context example for c64jasm
View context.js
module.exports = {
create: ({}, initial) => {
const stack = [initial];
return {
push: (elt) => {
stack.push(elt)
},
pop: () => stack.pop(),
top: () => {
return stack[stack.length-1];
@nurpax
nurpax / README.md
Last active Oct 25, 2019
c64 size optimization -- lines
View README.md

C64 "lines" size optimization contents

Deadline: midnight Finnish time on Monday, Aug 12, 2019.

Problem: make a PRG file that draws two crossing lines in C64 text mode in as few bytes as possible. The output should look exactly like this:

reference_output.png

(Note: the reference includes the black border. See the reference code for details.)

@nurpax
nurpax / main.asm
Last active Aug 3, 2019
6502 lines size optimization
View main.asm
!include "c64.asm"
+c64::basic_start(entry)
entry: {
lda #0
sta $d020
sta $d021
@nurpax
nurpax / Load_Line.sid
Last active Jul 29, 2019
c64jasm content example in a gist