Skip to content

Instantly share code, notes, and snippets.

@thentenaar
thentenaar / hbd.asm
Created April 26, 2024 15:07
Happy Birthday on a PIC16f (for my daughter)
; Happy Birthday on a PIC16f (for my daughter)
;
; Copyright (C) 2020 Tim Hentenaar.
; This code is licenced under the Simplified BSD License.
; https://opensource.org/license/bsd-2-clause
;
; Plays the classic tune on a piezoelectric buzzer (PWM), and blink some LEDs.
;
list p=16f628a
include <p16f628a.inc>
@thentenaar
thentenaar / lmc.bas
Last active March 27, 2024 14:54
Simple TI 99/4a XB Little Man Computer + Line Assembler
1 REM Simple XB Little Man Computer + Line Assembler
2 REM Copyright (C) 2021 Tim Hentenaar.
3 REM This code is licenced under the Simplified BSD License.
4 REM https://opensource.org/license/bsd-2-clause
10 DIM MEM(100) ! Mailboxes (memory)
20 DIM MPOS(100,2) ! Screen positions for mailbox values
30 PC,IR,AR,A,N,H,IN,OUT=0
40 GOTO 50 :: I :: K :: S :: OP :: L$ :: CALL CLEAR :: CALL HCHAR :: CALL VCHAR :: CALL KEY :: CALL COLOR :: !@P-
50 FOR I = 0 TO 99
@thentenaar
thentenaar / dn3dwt-eduke32.patch
Last active October 14, 2016 20:47
eDuke32 Patch for Duke Nukem 3D: World Tour
This patches the config files shipped with Duke Nukem World Tour so that
the levels should be playable with eduke32. There don't seem to be any
ogg sound effects for Duke's breathing, or the turret sounds, so I've
restored the original filename from Atomic Edition.
I've corrected the pathnames to use '/' as a separator, and altered the
case so that the filenames coincide with the actual filenames in the
sound directory.
I've removed the stuff specific to the 'playback' functionality as
@thentenaar
thentenaar / sunos-551-paging-bug-fix.c
Created July 24, 2015 18:30
Patch for the paging bug on Solaris 2.5.1 (SunOS 5.5.1) i386
/**
* Patch to fix the paging bug in the SunOS 5.5.1 (i386) kernel
* Copyright (C) 2015 Tim Hentenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
@thentenaar
thentenaar / echo-server-6.c
Created January 27, 2015 00:59
Simple echo server: Refactor #6: Move the work loop back out into its own function.
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*/
#include <stdio.h>
@thentenaar
thentenaar / echo-server-5.c
Created January 27, 2015 00:49
Simple echo server: Refactor #5: Reduce the depth of nesting in main().
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*/
#include <stdio.h>
@thentenaar
thentenaar / echo-server-4.c
Created January 27, 2015 00:23
Simple echo server: Refactor #4: Replace duplicate returns with goto
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*/
#include <stdio.h>
@thentenaar
thentenaar / echo-server-3.c
Created January 26, 2015 23:29
Simple echo server: Refactor #3: Change the work loop's while into a do { } while(), and make it smaller
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*/
#include <stdio.h>
@thentenaar
thentenaar / echo-server-2.c
Created January 26, 2015 22:04
Simple echo server: Refactor #2: Move the work loop into its own function.
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*/
#include <stdio.h>
@thentenaar
thentenaar / echo-server-1.c
Created January 26, 2015 20:59
Simple echo server: Refactor #1: Move the socket setup code into its own function.
/**
* Simple echo server
*
* This program listens for connections on the
* loopback interface, on port 9999. Upon connecting,
* The first line we read, of up to BUF_LEN bytes, is
* then sent back to the sender, and the connection
* is closed.
*
* Refactor #1 - Move socket creation code into its own