This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...) |