Skip to content

Instantly share code, notes, and snippets.

org $300
clc
xce
rep #$30 ; full 16 bit registers
pea #$000B ; push literal "000B" on stack
ldx #$2303 ; set toolcall
jsl E10000 ; call tool "03" = Misc. Tools, function "23" = IntSource
* We have just made a call to the IIgs toolbox routine called IntSource.
* IntSource enables or disables interrupts based on the bit pattern we
@digarok
digarok / svg_to_line.php
Created April 16, 2018 13:10
PHP script that can parse just enough of an SVG to get line coordinates and scale them to integer values for use on 320x200 Apple IIgs screen.
<?php
// hi plamen ;)
class Line
{
public $internal_x1 = 0;
public $internal_y1 = 0;
public $internal_x2 = 0;
public $internal_y2 = 0;
public function svgStrParse($s) {
@digarok
digarok / FRIDAY.BAS
Created May 25, 2018 14:56
Applesoft BASIC one-liner for fans of Friday
GR:COLOR=15:HLIN 12,28 AT 9:FOR I=10 TO 35:HLIN 10,30 AT I:NEXT I:HLIN 12,28 AT 36: HLIN 16,24 AT 37:HLIN 30,34 AT 14:HLIN 14,34 AT 30:VLIN 15,29 AT 35:COLOR=8:HLIN 14,26 AT 12:HOME:VTAB 22:?"HAPPY FRIDAY"
@digarok
digarok / rpi_gsplus_build.sh
Created August 24, 2018 21:02
Build GSplus with hardware acceleration on Jessie/Retropie from scratch
git clone https://github.com/RetroPie/RetroPie-Setup
cd RetroPie-Setup
sudo ./retropie_packages.sh sdl2
sudo apt-get update -y
sudo apt-get install -y libpcap0.8-dev libsdl2-image-dev
git clone https://github.com/digarok/gsplus.git
cd gsplus/src
ln -s vars_rpilinux_sdl2 vars
@digarok
digarok / dl_clear.s
Last active October 4, 2018 14:20
Code to clear an Apple II Double-Lo Resolution Screen in 6502 Assembly
** A = lo-res color byte
DL_Clear sta TXTPAGE1
ldx #40
:loop dex
sta Lo01,x
sta Lo02,x
sta Lo03,x
sta Lo04,x
sta Lo05,x
sta Lo06,x
@digarok
digarok / lz4.s
Created October 29, 2018 15:35
LZ4 65816 decompress special format
* Format is : 2-byte length word followed by compressed stream
MX %00
*-------------------------------------------------------------------------------
LZ4_Unpack STY LZ4_DestOffset+1 ; Y = Destination offset
STX LZ4_HeaderLenByte+1 ; X = Src offset (with 2 byte len header)
STX LZ4_HeaderAddr+1 ; and the address of the offset
STA LZ4_Literal_3+1 ; Uncompress a LZ4 Packed Data buffer (64 KB max)
SEP #$20 ; A = Bank Src,Bank Dst
STA LZ4_Match_5+1 ; X = SRC Byte offset
@digarok
digarok / genc1.py
Created October 31, 2018 02:27
Convert (320x200) RGB image to an Apple IIgs $C1 (Uncompressed SHR) file
# Invoke like:
# $ python genc1.py mypic.png output.shr
from PIL import Image
from math import sqrt
from sys import argv
img = Image.open(argv[1])
rgb_img = img.convert("RGB") # create the pixel map
@digarok
digarok / grconv.py
Created November 9, 2018 21:20
Convert images to Apple II lores bytes to write directly to memory.
# Take some image and convert to LoRes bytes
# You should already have it in 16 Apple II colors
# but this will do a nearest color match if not.
from PIL import Image
from math import sqrt
img = Image.open("saved_Preview.BMP")
def distance3d((x1, y1, z1), (x2, y2, z2)):
return sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
@digarok
digarok / copytolores.s
Created December 10, 2018 19:10
Copy from some buffer (ReadBuf) to the GR/Text Screen
CopyToGR lda #ReadBuf
sta 0
ldx #0
:nextline lda LoLineTable,x
sta 2
ldy #38
:doline lda (0),y
sta (2),y
dey
@digarok
digarok / swell.py
Created February 6, 2019 16:36
This will find EC2 resources across multiple accounts and regions (see CONFIG section). Use like, "python swell.py --find myserver"
import boto3, argparse, prettytable
# CONFIG START - PUT YOUR PROFILE NAMES AND REGIONS TO SCAN HERE
account_profiles=['abc-prod-account', 'abc-staging-account', 'abc-dev-account']
regions=['us-east-1','us-west-2']
# CONFIG END
def match_in_keys(o, keys, match):
m = False
for k in keys: