Skip to content

Instantly share code, notes, and snippets.

org $8000
start: di ; disables interrupts
flip: xor %00010011
out (&fe), a
ld b, 100
freq: dec b
jr nz, freq
jr flip
ei ; re-enables interrupts
end start
org $8000
start: ld de, 500
flip: xor %00010111
out (&fe), a
ld bc, 500
freq: dec c
jr nz, freq
dec b
jr nz, freq
jr flip
; adapted from Pavel Lebedev (Мир звуков Спектрума, https://vtrd.in/book/ZXSWORLD.ZIP)
org $8000
chord: ex af,af' ; swap primary and alternative AF registers
ld b,d ; counter 2
ld c,e ; counter 1
beep: ex af,af' ; swap registers (swap the voice)
dec c ; decrement c
jr nz,cont ; if not zero, go to cont
ld c,e ; restore counter 1
xor 16 ; invert bit 4 of voice 1
org $8000
start: ld a,%00010000
ld c,%00010000
out (&fe),a
xor c ; this is faster than xor %00010000
out (&fe),a
end start
org $8000
start: ld a,%00010000 ; load accumulator with any value that sets the 4th bit
out (&fe),a ; send that value to port 254, i.e. hexadecimal FE
xor %00010000 ; flip the 4th bit to the opposite of what it was before
out (&fe),a ; send that value to port 254 again
end start
org $8000
start: ld a,%00010000 ; load accumulator with any value that sets the 4th bit
out (&fe),a ; send that value to port 254, i.e. hexadecimal FE
end start
* makes beeps
ORG $300
LDA #$FF
STA FREQ
LDA #$80
STA PLSWIDTH
PLAY LDA $C030
LDY PLSWIDTH
PULSE DEY
* makes beeps
ORG $300
LDA #$FF
STA FREQ
LDA #$80
STA PLSWIDTH
PLAY LDA $C030
LDY PLSWIDTH
PULSE DEY
import serial
import sys
ourSerial = serial.Serial()
ourSerial.port = '/dev/ttySC1'
ourSerial.baudrate = 4800
ourSerial.bytesize = serial.EIGHTBITS
ourSerial.parity = serial.PARITY_NONE
ourSerial.stopbits = serial.STOPBITS_ONE
ourSerial.xonxoff = False
import serial
import sys
from datetime import datetime, date
ourSerial = serial.Serial()
ourSerial.port = '/dev/ttySC1'
ourSerial.baudrate = 4800
ourSerial.bytesize = serial.EIGHTBITS
ourSerial.parity = serial.PARITY_NONE
ourSerial.stopbits = serial.STOPBITS_ONE