-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZX 128K MIDI port emulation (but no output).
- Loading branch information
Showing
11 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
#define CLOCK_H | ||
|
||
#define Z80_CLOCK 3500000L | ||
#define MIDI_BAUD 31250 | ||
|
||
#endif |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* GZX - George's ZX Spectrum Emulator | ||
* ZX Spectrum 128K MIDI port emulation | ||
*/ | ||
#include <stdio.h> | ||
#include "midi.h" | ||
|
||
void midi_port_init(midi_port_t *mp) | ||
{ | ||
} | ||
|
||
void midi_port_write(midi_port_t *mp, uint8_t val) | ||
{ | ||
printf("MIDI port write: 0x%02x\n", val); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* GZX - George's ZX Spectrum Emulator | ||
* ZX Spectrum 128K MIDI port emulation | ||
*/ | ||
#ifndef MIDI_PORT_H | ||
#define MIDI_PORT_H | ||
|
||
#include <stdint.h> | ||
|
||
typedef struct { | ||
} midi_port_t; | ||
|
||
extern void midi_port_init(midi_port_t *); | ||
extern void midi_port_write(midi_port_t *, uint8_t); | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* GZX - George's ZX Spectrum Emulator | ||
* ZX Spectrum 128K RS-232 port emulation | ||
*/ | ||
#include <stdio.h> | ||
#include "rs232.h" | ||
|
||
void rs232_init(rs232_t *rs, uint32_t d_clocks) | ||
{ | ||
rs->d_clocks = d_clocks; | ||
rs->state = rs232_idle; | ||
} | ||
|
||
void rs232_write(rs232_t *rs, uint8_t val) | ||
{ | ||
uint8_t b; | ||
|
||
b = (val >> rs232_txd) & 0x1; | ||
|
||
if (rs->state == rs232_idle && (b == 0x0)) { | ||
rs->state = rs232_sending; | ||
rs->bit_no = 0; | ||
rs->buf = 0x0; | ||
} else if (rs->state == rs232_sending) { | ||
rs->buf = (rs->buf >> 1) | (b << 7); | ||
if (++rs->bit_no >= 8) { | ||
rs->state = rs232_idle; | ||
if (rs->sendchar != NULL) | ||
rs->sendchar(rs->sendchar_arg, rs->buf); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* GZX - George's ZX Spectrum Emulator | ||
* ZX Spectrum 128K RS-232 port emulation | ||
*/ | ||
#ifndef RS232_H | ||
#define RS232_H | ||
|
||
#include <stdint.h> | ||
|
||
/* Bits within the RS232 register */ | ||
enum { | ||
rs232_txd = 2 | ||
}; | ||
|
||
typedef enum { | ||
rs232_idle, | ||
rs232_sending | ||
} rs232_state_t; | ||
|
||
typedef struct { | ||
/** Z80 T states between successive bits (rel. to baud rate) */ | ||
uint32_t d_clocks; | ||
/** State */ | ||
rs232_state_t state; | ||
/** Bit number */ | ||
uint8_t bit_no; | ||
/** Transfer buffer */ | ||
uint8_t buf; | ||
/** A symbol was sent */ | ||
void (*sendchar)(void *, uint8_t); | ||
/** Argument to sendchar callback */ | ||
void *sendchar_arg; | ||
} rs232_t; | ||
|
||
extern void rs232_init(rs232_t *, uint32_t); | ||
extern void rs232_write(rs232_t *, uint8_t); | ||
|
||
#endif |
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
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