Skip to content

Instantly share code, notes, and snippets.

View drdnar's full-sized avatar

R. S. Bartgis drdnar

View GitHub Profile
@drdnar
drdnar / inlineldir.h
Created October 8, 2021 19:47
Use clang's inline assembly support to wrap eZ80 LDIR directly
/**
* Wraps eZ80 LDIR instruction.
* @param destination Target address, e.g. &somearr[i - 2]
* @param source Source address, e.g. &somearr[i]
* @param count Number of bytes to move
* @example #define VRAM ((uint16_t*)0xD40000)
* *VRAM = 12345; // Set first word of VRAM
* _ldir(VRAM+1, VRAM, LCD_WIDTH * LCD_HEIGHT - 1); // Copy remaining pixels with LDIR
*/
static inline void _ldir(void* destination, const void* source, size_t count)
@drdnar
drdnar / comparedigest.src
Last active June 29, 2021 21:48
eZ80 constant-time compare function
; bool CompareDigest(uint8_t* buffer1, uint8_t* buffer2, size_t count);
; This optimized implementation is guaranteed to run in constant time for any given specific count.
; It's untested but it looks right to me.
hashlib_CompareDigest:
call ti._frameset0
ld iy, (ix + 6)
ld de, (ix + 12)
ld ix, (ix + 9)
; BC is constant zero
; DE is number of bytes to compare
@drdnar
drdnar / myfont.asm
Last active June 23, 2021 17:25
FontLibC font in a .asm file
section .text
assume adl = 1
; Exposes the _myfont symbol for other source code files to see.
public _myfont
; Note the underscore prefix on the name. This is required for linking with C
; code.
_myfont:
; FONT METADATA
; Code Page = ASCII
@drdnar
drdnar / graphx.cpp
Created June 6, 2021 02:49
Magically initialize GraphX
#include <graphx.h>
#include "style.h"
#include "gfx/gfx.h"
class GraphX
{
public:
GraphX(void)
{
gfx_Begin();
@drdnar
drdnar / cedevportable.bat
Last active May 7, 2021 23:41
CE SDK portable batch file
@echo off
rem Check if we're running Windows 10 or newer.
rem Early versions of Windows 10 didn't support ANSI, but since MS is very aggressive
rem about forcing updates, they're probably not likely to appear.
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i
echo.
if %VERSION% gtr 9 echo 
echo ================================================================================
echo TI-84 PLUS CE DEVELOPER'S TOOLKIT, PORTABLE
@drdnar
drdnar / cache2.c
Created April 16, 2020 20:58
Cache thrash test 2
/*
*--------------------------------------
* Program Name:
* Author:
* License:
* Description:
*--------------------------------------
*/
/* Keep these headers */
@drdnar
drdnar / cache1.c
Last active April 16, 2020 20:58
Cache thrash test
/*
*--------------------------------------
* Program Name:
* Author:
* License:
* Description:
*--------------------------------------
*/
/* Keep these headers */
@drdnar
drdnar / myhostapd.conf
Last active January 5, 2020 05:29
Quick temporary Wi-Fi AP for Raspberry Pi 4B
interface=wlan0
driver=nl80211
ssid=linksys
hw_mode=a
ieee80211ac=1
channel=149
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
@drdnar
drdnar / calc1252stringroutines.asm
Created July 9, 2019 07:58
Custom string routines for use with my non-standard variant of Windows 1252
; This has some custom string routines for use with my non-standard variant of
; Windows 1252.
.assume adl=1
.def _strupper
.def _strlower
.def _isgreek
if defined GREEK_CASE_CHANGABLE
.def _disable_greek_case_change
.def _enable_greek_case_change