Skip to content

Instantly share code, notes, and snippets.

@djmips
djmips / 6502umul_8x8_16.s
Created April 10, 2017 10:21
6502 unwound unsigned 8x8->16 multiply
mul1 * mul2 + A/2 -> A:mul1 (mul2 is unchanged)
; inner loop credit Supercat
MUL:
dec mul2 ;5 ; decrement mul2 because we will be adding with carry set for speed (an extra one)
ror mul1 ;5 \
bcc b1 ;2/3 \ Best case 8 Worst case 10
adc mul2 ;3 /
b1: ror ;2 \
@djmips
djmips / 6502_ATAN2.s
Created April 10, 2017 10:23
Cordic ATAN2 in 6502 (for fun)
; DASM assembler
processor 6502
seg.u zpage
ORG $0080
theta ds 2
x ds 2
@djmips
djmips / line.cpp
Last active June 13, 2020 17:53
Line Draw into SAM3x8e DMA buffer (Arduino DUE)
// Assume there is a currX and currY global state which is the current x,y position
// Assume that currBuffer points to a valid properly sized buffer in RAM for DMA
//
// Buffer size can be calculated as n * 4 bytes where n is max(xdelta, ydelta)
// where xdelta and ydelta are the extents of the line to be drawn
//
// xd and yd is the destination point
//
// The output DACs are 12 bit but for speed this outputs in steps of 4 to cut the point generation by 4 times
// Effective resolution is 1024 points in X and Y