Skip to content

Instantly share code, notes, and snippets.

@podstawek
podstawek / compile.sh
Created February 12, 2023 12:46
Cross-compile assembly code on a Mac so that it is executable on an old PC XT
filename=$1
filename="${filename%.*}"
echo "Filename without extension is ${filename}"
echo -n "Compiling $1 with vasm... " &&\
vasmx86_std -m8086 $1 -Faout -o ${filename}.obj &&\
echo "done."
echo -n "Linking $1 with vlink... " &&\
;-----------------------------------------
; Adapted from the original Lisa ROM listing
; https://www.apple.asimov.net/documentation/applelisa/AppleLisa-BootROMListing.pdf
; D0 = desired frequency ($00 - $AA)
; D1 = duration (0 = .5 msec)
; D2 = volume (0,2,4,...,E)
; D3 = pulse train shape as a string of 8 bits
;-----------------------------------------
ORG $800
@podstawek
podstawek / concurrency.pp
Created April 11, 2022 13:33
BEEP call in Apple Lisa's Pascal is non-blocking. Which is very different from e.g. ZX Spectrum implementation. This program illustrates how a loop can run while sound is playing.
PROGRAM sound;
USES HWINT;
var i:integer;
begin
SetVolume(2);
noise(3000);
for i:= 1 to 600 do
begin
PROGRAM sound;
USES HWINT;
PROCEDURE Delay(milli: MilliSeconds);
VAR old: MilliSeconds;
BEGIN
old := Timer;
repeat
begin
@podstawek
podstawek / beep.pp
Created April 4, 2022 13:53
Pascal program to emit sound on Apple Lisa
PROGRAM sound;
USES HWINT;
BEGIN
Beep(3000, 5000);
END.
@podstawek
podstawek / set_digital_pins_for_ladder.ino
Last active April 4, 2022 13:36
Resistor ladder control (fragment only)
void loop() {
digitalWrite(D0, LOW);
digitalWrite(D1, LOW);
digitalWrite(D2, LOW);
delay(2);
digitalWrite(D0, LOW);
digitalWrite(D1, LOW);
digitalWrite(D2, HIGH);
delay(2);
; (...end so on...)
@podstawek
podstawek / pulseTrainShape.ino
Created April 4, 2022 07:15
6522 control code, pulse train shape fragment only
// send a pattern to Shift Register (e.g. 01100101)
digitalWrite(D7, LOW);
digitalWrite(D6, HIGH);
digitalWrite(D5, HIGH);
digitalWrite(D4, LOW);
digitalWrite(D3, LOW);
digitalWrite(D2, HIGH);
digitalWrite(D1, LOW);
digitalWrite(D0, HIGH);
@podstawek
podstawek / ladder.ino
Created April 3, 2022 20:26
Simple sketch to drive the resistor ladder circuit.
const byte D0 = 44; // Digital Line 0
const byte D1 = 45; // Digital Line 1
const byte D2 = 46; // Digital Line 2
void setup() {
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
}
@podstawek
podstawek / mos6522_shiftout.ino
Last active April 2, 2022 11:59
Primitive but working code to enable Shift Out operation on MOS 6522 VIA from Arduino.
// Define Arduino pin constants to correspond with MOS6522 pins
const byte CS1 = 24; // Chip Select 1
const byte CS2 = 23; // Chip Select 2
const byte RS0 = 38; // Register Select 0
const byte RS1 = 37; // Register Select 1
const byte RS2 = 36; // Register Select 2
const byte RS3 = 35; // Register Select 3
const byte RW = 22; // Read-Write Line
const byte D0 = 33; // Data Bus 0
const byte D1 = 32; // Data Bus 1
// Define Arduino pin constants to correspond with MOS6522 pins
const byte CS1 = 24; // Chip Select 1
const byte CS2 = 23; // Chip Select 2
const byte RS0 = 38; // Register Select 0
const byte RS1 = 37; // Register Select 1
const byte RS2 = 36; // Register Select 2
const byte RS3 = 35; // Register Select 3
const byte RW = 22; // Read-Write Line
const byte D0 = 33; // Data Bus 0
const byte D1 = 32; // Data Bus 1