Skip to content

Instantly share code, notes, and snippets.

@LightningStalker
LightningStalker / div.s
Last active August 21, 2026 08:31
6502 16-bit division routine from Apple II integer BASIC
; Divide routine from Apple II integer BASIC ROM
ACC equ $ca ; Dividend/Quotient/Accumulator
DVI equ $cc ; Divisor
R equ $ce ; Remainder
org $300 ; Apple II small program area
start: ; load memory registers
lda #12 ; dividend
@LightningStalker
LightningStalker / m.sh
Last active August 20, 2026 10:23
vasm make script
#/bin/bash
# assemble, image, emulate
NAME=mysource_basename
ASMFILE=${NAME}.s
LISTING=list
BINPREFIX=${NAME}#060
DSKIMG="/usr/myhome/mydir/work.dsk"
EMUSTATE=$(realpath SaveState.aws.yaml)
GREP=grep
@LightningStalker
LightningStalker / readhex.s
Last active August 6, 2026 08:17
read ASCII hexidecimal
; read hex value from ASCII
ASC equ $fa ; ASCII char passed in
RESULT equ $fb ; result location
org $300 ; Apple II small program area
start:
lda ASC ; mov char -> accumulator
cmp #$3a ; >= ':'?
@LightningStalker
LightningStalker / DEC2HEX.BAS
Last active August 6, 2026 08:37
Applesoft Basic convert decimal to hex
0 REM Convert Decimal to Hexa-decimal
10 TBL$ = "0123456789abcdef"
20 DIM R%(8)
30 HOME : PRINT CHR$ (13)" Enter 0 to quit"
40 PRINT
50 INPUT " Decimal# ?";N
60 IF N = 0 THEN PRINT CHR$(4)"BYE"
70 IF N > 4294967295 GOTO 2000
80 IF N < 0 GOTO 3000
@LightningStalker
LightningStalker / test.py
Last active April 23, 2026 19:18
Solenoid calc test
#!/usr/bin/python
# Nagaoka-Rosa solenoid inductance calculation
# Project Crew™ 4/19/2026
from math import pi, tau, log, sqrt, exp
f = 144 # frequency in MHz
N = 9.2 # turns count
dw = 0.0045 # coax shield/braid diameter
jw = 0.0061 # coax outer diam. incl. jacket
Df = 0.0223 # form diameter
@LightningStalker
LightningStalker / f2wl.cpp
Last active March 22, 2026 10:06
Convert frequency <-> wavelength ham radio
/* frequency <-> wavelengths
* Project Crew™ 3/18/2026
*/
#define PROGNAME "f2wl"
#include <iostream>
#include <iomanip>
#include <cmath>
#include "cxxopts.hpp"
@LightningStalker
LightningStalker / woofbox.cpp
Last active March 16, 2026 01:40
Thiele\/Small Box Alignment
/* the "Thiele/Small Box Alignment"
* subwoofer box calculator
* Project Crew™ 3/11/2026
*/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
@LightningStalker
LightningStalker / !Press any key to reboot.asm
Created February 23, 2026 18:30
Press any key to reboot OS for PC
;******************************
; Press any key to reboot v2.1
; For flat assembler
; Project Crew™ 2/29/2008
;******************************
version equ '2.1'
format binary as 'ima'
include 'Ata_Atapi.inc' ; Use Craig Bamford's library
; for CD Eject functions
Load_Segment equ 7C00h
@LightningStalker
LightningStalker / wa.sh
Last active March 29, 2026 04:02
wa.sh : remove the trailing whitespace
#!/bin/bash
# wa.sh - rinse away the sin of trailing whitespace <- Project Crew™ 2/23/2026
PROGNAME=$(basename ${0})
if test -n "${1}"
then
if test -f "${1}"
then
echo ${PROGNAME}: Looking at file: ${1}
NL=$(egrep -ch ' +$' ${1})
echo ${PROGNAME}: Found ${NL} line\(s\) ending in whitespace.
@LightningStalker
LightningStalker / helloa2.s
Last active February 23, 2026 17:59
vasm hello world for Apple 2
; vasm hello world for Apple ][
; address for call of the ROM BIOS function routines
COUT equ $fded ; character output
CROUT equ $fd8e ; start new line
WRST equ $3d0 ; warm reset, return to system
; symbols to get rid of the "magic numbers"
ABM equ $80 ; abyte modifier (chars + $80)
CR equ 13 ; carriage return char