@nataliapc/mcp-openmsx 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -2
- package/dist/chunker.js +187 -0
- package/dist/embedder.js +250 -0
- package/dist/server.js +6 -1
- package/dist/server_tools.js +6 -5
- package/dist/vectordb.js +94 -35
- package/package.json +4 -8
- package/resources/audio/chipsfmpacpr1_en.md +209 -0
- package/resources/audio/chipsfmpacpr2_en.md +170 -0
- package/resources/audio/toc.json +12 -0
- package/resources/book--msx-top-secret-3/MTS3-Appendix-English-Upd2.pdf +0 -0
- package/resources/book--msx-top-secret-3/MTS3-Complete-English.pdf +0 -0
- package/resources/book--msx2-technical-handbook/toc.json +1 -1
- package/resources/book--the-msx-red-book/Chapter1_Programmable_Peripheral_Interface.md +112 -0
- package/resources/book--the-msx-red-book/Chapter2_Video_Display_Processor.md +308 -0
- package/resources/book--the-msx-red-book/Chapter3_Programmable_Sound_Generator.md +168 -0
- package/resources/book--the-msx-red-book/Chapter4_ROM_BIOS.md +2528 -0
- package/resources/book--the-msx-red-book/Chapter5_ROM_BASIC_Interpreter.md +3975 -0
- package/resources/book--the-msx-red-book/Chapter6_Memory_Map.md +1963 -0
- package/resources/book--the-msx-red-book/Chapter7_Machine_Code_Programs.md +1238 -0
- package/resources/book--the-msx-red-book/Introduction.md +104 -0
- package/resources/book--the-msx-red-book/toc.json +38 -3
- package/resources/processors/toc.json +3 -3
- package/resources/processors/z80-undocumented.md +141 -0
- package/resources/sdcc/1_Introduction.md +199 -0
- package/resources/sdcc/2_Installing_SDCC.md +533 -0
- package/resources/sdcc/3_Using_SDCC.md +1758 -0
- package/resources/sdcc/4_Notes_on_supported_Processors.md +1638 -0
- package/resources/sdcc/5_Debugging.md +210 -0
- package/resources/sdcc/6_Tips_and_Support.md +258 -0
- package/resources/sdcc/7_SDCC_Technical_Data.md +489 -0
- package/resources/sdcc/8_Compiler_internals.md +477 -0
- package/resources/sdcc/toc.json +44 -2
- package/vector-db/msxdocs.lance/_indices/4d3bd360-e3c6-408d-b0ff-a4d6bd9580cb/metadata.lance +0 -0
- package/vector-db/msxdocs.lance/_indices/4d3bd360-e3c6-408d-b0ff-a4d6bd9580cb/part_0_docs.lance +0 -0
- package/vector-db/msxdocs.lance/_indices/4d3bd360-e3c6-408d-b0ff-a4d6bd9580cb/part_0_invert.lance +0 -0
- package/vector-db/msxdocs.lance/_indices/4d3bd360-e3c6-408d-b0ff-a4d6bd9580cb/part_0_tokens.lance +0 -0
- package/vector-db/msxdocs.lance/_transactions/0-6f47c9fc-3657-40f0-9dd4-c7226b2a4805.txn +0 -0
- package/vector-db/msxdocs.lance/_transactions/1-2bb7426e-a4b0-40ea-9a58-00c4985fc6a9.txn +0 -0
- package/vector-db/msxdocs.lance/_versions/18446744073709551613.manifest +0 -0
- package/vector-db/msxdocs.lance/_versions/18446744073709551614.manifest +0 -0
- package/vector-db/msxdocs.lance/_versions/latest_version_hint.json +1 -0
- package/vector-db/msxdocs.lance/data/110001110001011010001000876c134b8296fbc47762d1e1ab.lance +0 -0
- package/resources/book--the-msx-red-book/the_msx_red_book.md +0 -10349
- package/resources/processors/z80-undocumented.tex +0 -5617
- package/resources/sdcc/lyx2md.py +0 -745
- package/resources/sdcc/sdccman.lyx +0 -81574
- package/resources/sdcc/sdccman.md +0 -5557
- package/vector-db/index.json +0 -1
package/dist/vectordb.js
CHANGED
|
@@ -1,16 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vector Database wrapper class
|
|
2
|
+
* Vector Database wrapper class.
|
|
3
|
+
*
|
|
4
|
+
* Hybrid search over the MSX documentation corpus:
|
|
5
|
+
* - dense vector search (cosine over 384-d embeddings, see embedder.ts)
|
|
6
|
+
* - full-text search (BM25, LanceDB native FTS index)
|
|
7
|
+
* - fused with Reciprocal Rank Fusion (RRF)
|
|
8
|
+
*
|
|
9
|
+
* Storage: LanceDB (columnar `.lance` table), replacing the previous Vectra
|
|
10
|
+
* `index.json`.
|
|
3
11
|
*
|
|
4
12
|
* @author Natalia Pujol Cremades (@nataliapc)
|
|
5
13
|
* @license GPL2
|
|
6
14
|
*/
|
|
7
15
|
import path from 'path';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
16
|
+
import { pathToFileURL } from 'url';
|
|
17
|
+
import * as lancedb from '@lancedb/lancedb';
|
|
18
|
+
import { embedQuery } from './embedder.js';
|
|
19
|
+
const TABLE_NAME = 'msxdocs';
|
|
20
|
+
const TOP_K = 10; // final results returned
|
|
21
|
+
const CANDIDATES = 30; // candidates fetched per branch before fusion
|
|
22
|
+
const RRF_K = 60; // RRF constant
|
|
23
|
+
/**
|
|
24
|
+
* Fuse two ranked result lists with Reciprocal Rank Fusion.
|
|
25
|
+
* Each document scores Σ 1/(k + rank) over the lists it appears in
|
|
26
|
+
* (rank is 0-based, so the +1 makes the top item contribute 1/(k+1)).
|
|
27
|
+
*/
|
|
28
|
+
export function fuseRRF(vecRows, ftsRows, k = RRF_K, topK = TOP_K) {
|
|
29
|
+
const acc = new Map();
|
|
30
|
+
const add = (rows) => {
|
|
31
|
+
rows.forEach((row, rank) => {
|
|
32
|
+
const id = String(row.id);
|
|
33
|
+
const inc = 1 / (k + rank + 1);
|
|
34
|
+
const cur = acc.get(id);
|
|
35
|
+
if (cur) {
|
|
36
|
+
cur.score += inc;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
acc.set(id, { score: inc, row });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
add(vecRows);
|
|
44
|
+
add(ftsRows);
|
|
45
|
+
return [...acc.values()].sort((a, b) => b.score - a.score).slice(0, topK);
|
|
46
|
+
}
|
|
10
47
|
export class VectorDB {
|
|
11
|
-
static instance;
|
|
48
|
+
static instance = null;
|
|
12
49
|
static vectorDbDir = path.join('..', 'vector-db');
|
|
13
|
-
|
|
50
|
+
tablePromise = null;
|
|
14
51
|
static getInstance() {
|
|
15
52
|
if (!VectorDB.instance) {
|
|
16
53
|
VectorDB.instance = new VectorDB();
|
|
@@ -20,42 +57,64 @@ export class VectorDB {
|
|
|
20
57
|
static setIndexDirectory(dbDir) {
|
|
21
58
|
VectorDB.vectorDbDir = dbDir;
|
|
22
59
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the directory into a value LanceDB can open.
|
|
62
|
+
*
|
|
63
|
+
* On Windows, LanceDB 0.30 (lance-io 7.0) mishandles drive-letter paths: it
|
|
64
|
+
* builds a malformed `file://` URL that drops the drive
|
|
65
|
+
* (`file:///mcp-server/vector-db/...`) and then fails to convert it back to a
|
|
66
|
+
* filesystem path. Passing an explicit, well-formed `file://` URI built by Node
|
|
67
|
+
* (`file:///M:/mcp-server/vector-db`) bypasses that broken path→URL step. On
|
|
68
|
+
* POSIX a plain path works fine, so we leave it untouched.
|
|
69
|
+
*/
|
|
70
|
+
static resolveUri(dir) {
|
|
71
|
+
return process.platform === 'win32'
|
|
72
|
+
? pathToFileURL(path.resolve(dir)).href
|
|
73
|
+
: dir;
|
|
28
74
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
75
|
+
getTable() {
|
|
76
|
+
if (!this.tablePromise) {
|
|
77
|
+
this.tablePromise = (async () => {
|
|
78
|
+
const db = await lancedb.connect(VectorDB.resolveUri(VectorDB.vectorDbDir));
|
|
79
|
+
return db.openTable(TABLE_NAME);
|
|
80
|
+
})().catch((err) => {
|
|
81
|
+
this.tablePromise = null;
|
|
82
|
+
throw new Error(`Failed to open LanceDB table '${TABLE_NAME}' at '${VectorDB.vectorDbDir}'. ` +
|
|
83
|
+
`Has the index been generated? (${err instanceof Error ? err.message : err})`);
|
|
84
|
+
});
|
|
36
85
|
}
|
|
37
|
-
return
|
|
86
|
+
return this.tablePromise;
|
|
38
87
|
}
|
|
39
88
|
async query(text) {
|
|
40
|
-
const
|
|
41
|
-
|
|
89
|
+
const tbl = await this.getTable();
|
|
90
|
+
const vector = await embedQuery(text);
|
|
91
|
+
// Vector branch (always available). No `.select()`: scoring queries warn
|
|
92
|
+
// when output columns are projected without `_distance`/`_score`, and the
|
|
93
|
+
// candidate set is tiny so fetching full rows is negligible.
|
|
94
|
+
const vecRows = await tbl
|
|
95
|
+
.query()
|
|
96
|
+
.nearestTo(vector)
|
|
97
|
+
.limit(CANDIDATES)
|
|
98
|
+
.toArray();
|
|
99
|
+
// Full-text (BM25) branch. Degrade gracefully to vector-only if the FTS
|
|
100
|
+
// index is missing or the query cannot be parsed.
|
|
101
|
+
let ftsRows = [];
|
|
42
102
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
uri: result.item.metadata?.uri || 'unknown',
|
|
49
|
-
title: result.item.metadata?.title || 'unknown',
|
|
50
|
-
document: String(result.item.metadata?.document || ''),
|
|
51
|
-
id: result.item.metadata?.id || 'unknown',
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
}
|
|
103
|
+
ftsRows = await tbl
|
|
104
|
+
.query()
|
|
105
|
+
.nearestToText(text)
|
|
106
|
+
.limit(CANDIDATES)
|
|
107
|
+
.toArray();
|
|
55
108
|
}
|
|
56
|
-
catch
|
|
57
|
-
|
|
109
|
+
catch {
|
|
110
|
+
ftsRows = [];
|
|
58
111
|
}
|
|
59
|
-
return
|
|
112
|
+
return fuseRRF(vecRows, ftsRows).map((r) => ({
|
|
113
|
+
score: r.score.toFixed(4),
|
|
114
|
+
uri: r.row.uri ?? 'unknown',
|
|
115
|
+
title: r.row.title ?? 'unknown',
|
|
116
|
+
document: String(r.row.text ?? ''),
|
|
117
|
+
id: r.row.id ?? 'unknown',
|
|
118
|
+
}));
|
|
60
119
|
}
|
|
61
120
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nataliapc/mcp-openmsx",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"description": "Model context protocol server for openMSX automation and control",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"type": "module",
|
|
@@ -45,22 +45,18 @@
|
|
|
45
45
|
"optionalDependencies": {
|
|
46
46
|
"node-expose-sspi": "^0.1.60"
|
|
47
47
|
},
|
|
48
|
-
"overrides": {
|
|
49
|
-
"sharp": "^0.34.5"
|
|
50
|
-
},
|
|
51
48
|
"dependencies": {
|
|
49
|
+
"@anush008/tokenizers": "^0.6.0",
|
|
50
|
+
"@lancedb/lancedb": "^0.30.0",
|
|
52
51
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
53
|
-
"@themaximalist/embeddings.js": "^0.1.3",
|
|
54
52
|
"@types/express": "^5.0.6",
|
|
55
53
|
"@types/mime-types": "^3.0.1",
|
|
56
|
-
"@xenova/transformers": "^2.17.2",
|
|
57
54
|
"debug": "^4.4.3",
|
|
58
55
|
"express": "^5.2.1",
|
|
59
56
|
"mime-types": "^3.0.2",
|
|
57
|
+
"onnxruntime-node": "^1.27.0",
|
|
60
58
|
"sanitize-html": "^2.17.4",
|
|
61
|
-
"sharp": "^0.34.5",
|
|
62
59
|
"tsx": "^4.22.0",
|
|
63
|
-
"vectra": "^0.11.1",
|
|
64
60
|
"zod": "^3.25.76"
|
|
65
61
|
},
|
|
66
62
|
"devDependencies": {
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# FM-PAC / MSX-MUSIC (Yamaha YM-2413)
|
|
2
|
+
|
|
3
|
+
In this text, only the direct programming of the MSX-MUSIC will be discussed, not the FM-BASIC possibilities, because they finally use direct control.
|
|
4
|
+
|
|
5
|
+
The MSX-MUSIC or the FM-PAC uses two I/O ports for control. Unfortunately, these registers are only used to write from the computer to the FM-PAC, so reading registers from the FM-PAC/MSX-MUSIC is not possible.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
07Ch - Address port.
|
|
9
|
+
07Dh - Data Port.
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
To control these ports correctly in machine language, it is useful to use the following program:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
;Reg. D contains register number for FM-PAC.
|
|
16
|
+
;Reg. E contains data for selected register.
|
|
17
|
+
|
|
18
|
+
SET_FM: LD A,D
|
|
19
|
+
OUT (07CH),A
|
|
20
|
+
LD A,E
|
|
21
|
+
OUT (07DH),A
|
|
22
|
+
EX (SP),HL ;These 2 commands only serve as a short
|
|
23
|
+
EX (SP),HL ;pause for the PAC to process the data
|
|
24
|
+
RET ;before sending new data.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Registers
|
|
28
|
+
|
|
29
|
+
The FM-PAC contains 43 programmable registers for setting frequency, volume, instruments, drums and possibly samples. The latter is rather difficult, since the FM-PAC has no built-in hardware to play this independently like the MUSIC MODULE, a routine must be written in ML code for this, which sends the sample data in the FM-PAC via the necessary registers. so that it puts this sample on the sound output.
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
#0Fh FM.TST
|
|
33
|
+
|
|
34
|
+
7 6 5 4 3 2 1 0
|
|
35
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
36
|
+
│ - │ - │ - │ - │SND│ - │ - │SMP│
|
|
37
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
38
|
+
|
|
39
|
+
SND - 1=Sound output of the chip is out.
|
|
40
|
+
SAMP - 1=Sample mode on, a four bit sample can be written to register
|
|
41
|
+
#10h, the 4 highest bit.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
#10h - #18h LOWFRQ
|
|
46
|
+
|
|
47
|
+
7 6 5 4 3 2 1 0
|
|
48
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
49
|
+
│FQ7│FQ6│FQ5│FQ4│FQ3│FQ2│FQ1│FQ0│
|
|
50
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
#20h - #28h SELECT
|
|
55
|
+
|
|
56
|
+
7 6 5 4 3 2 1 0
|
|
57
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
58
|
+
│ - │ - │SUS│KEY│OC2│OC1│OC0│FQ8│
|
|
59
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
60
|
+
|
|
61
|
+
FQ 8/0 - Frequency from channel 1 to 9.
|
|
62
|
+
OC 2/0 - Octave from channel 1 to 9.
|
|
63
|
+
KEY - If a new tone has to be struck it must first be set to 0.
|
|
64
|
+
Then the new data can be loaded (Frequency, Instrument and
|
|
65
|
+
volume), then set this bit back to 1.
|
|
66
|
+
SUS - If this bit is set to 1, the tone will slowly fade after
|
|
67
|
+
the KEY bit is set to 0. If SUS is at 0, the tone will stop
|
|
68
|
+
immediately when the KEY bit is turned off.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
#30h - #38h VOLINS
|
|
73
|
+
|
|
74
|
+
7 6 5 4 3 2 1 0
|
|
75
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
76
|
+
│IN3│IN2│IN1│IN0│VL3│VL2│VL1│VL0│
|
|
77
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
78
|
+
|
|
79
|
+
VL 3/0 - Volume from channel 1 to 9. At binary 0000 the highest
|
|
80
|
+
volume is reached.
|
|
81
|
+
IN 3/0 - Instruments from channels 1 to 9. There are 16 instruments,
|
|
82
|
+
instrument number 0 of which can be programmed via registers
|
|
83
|
+
#00 to #07.
|
|
84
|
+
|
|
85
|
+
NR: Instrument:
|
|
86
|
+
|
|
87
|
+
00 Software Instrument
|
|
88
|
+
01 Violin
|
|
89
|
+
02 Guitar
|
|
90
|
+
03 Piano
|
|
91
|
+
04 Flute
|
|
92
|
+
05 Clarinet
|
|
93
|
+
06 Oboe
|
|
94
|
+
07 Trumpet
|
|
95
|
+
08 Organ
|
|
96
|
+
09 Tube
|
|
97
|
+
10 Synthesizer
|
|
98
|
+
11 Harpsicord
|
|
99
|
+
12 Vibraphone
|
|
100
|
+
13 Synthesizer Bass
|
|
101
|
+
14 Electric Piano 1
|
|
102
|
+
15 Electric Piano 2
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
#03h DRMSEL
|
|
107
|
+
|
|
108
|
+
7 6 5 4 3 2 1 0
|
|
109
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
110
|
+
│ - │ - │SEL│BD │SD │TOM│CIM│HH │
|
|
111
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
112
|
+
|
|
113
|
+
SEL - If this is bit 1, channels 7 to 9 will be used for drum
|
|
114
|
+
settings, and bits 4 to 0 can be used to control a drum.
|
|
115
|
+
BD - Bass Drum :1 = Activate, if SEL is set to 1.
|
|
116
|
+
SD - Snare Drum.
|
|
117
|
+
TOM - Tom-Tom.
|
|
118
|
+
CIM - Cimbal.
|
|
119
|
+
HH - Hi Hat.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The Drum's frequencies and volumes are divided as follows:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
Reg: Use:
|
|
126
|
+
#16h Frequency bit 7 to 0 for the BassDrum.
|
|
127
|
+
#17h Frequency bit 7 to 0 for the SnareDrum and the HiHat.
|
|
128
|
+
#18h Frequency bit 7 to 0 for the TomTom and the Cimbal.
|
|
129
|
+
#26h Octave bit 2 to 0 and Frequency bit 8 for BassDrum.
|
|
130
|
+
#27h Octave bit 2 to 0 and Frequency bit 8 for SnareDrum & the HiHat.
|
|
131
|
+
#28h Octave bit 2 to 0 and Frequency bit 8 for Tom-Tom & the Cimbal.
|
|
132
|
+
#36h Low nibble is volume of Bass Drum (0 is the highest volume).
|
|
133
|
+
#37h High nibble is volume from Hi Hat.
|
|
134
|
+
Low nibble is volume from Snare Drum.
|
|
135
|
+
#38h High nibble is volume from Cimbal.
|
|
136
|
+
Low nibble is volume from Tom-Tom.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Programming the Software Instrument.
|
|
140
|
+
|
|
141
|
+
The FM contains 2 operators for each instrument. The sound is generated via the FM synthesis, which stands for Frequency Modulation. The System works the same as that of the Music-module/MSX-Audio only the maximum values will not always match, but the theory is the same.
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
#00h/01h SET.B / SET.A.
|
|
145
|
+
|
|
146
|
+
7 6 5 4 3 2 1 0
|
|
147
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
148
|
+
│ AM│VBR│S/D│RKS│MS3│MS2│MS1│MS0│
|
|
149
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
150
|
+
|
|
151
|
+
#00h for operator B and # 01h for operator A.
|
|
152
|
+
|
|
153
|
+
AM - Amplitude Modulation.
|
|
154
|
+
VBR - Vibrato.
|
|
155
|
+
S/D - 0 = Decay; 1 = Sustain.
|
|
156
|
+
RKS - Rate Key Scale.
|
|
157
|
+
MS3/0 - Multi sample wave selection.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
#02h KSCMOD
|
|
162
|
+
|
|
163
|
+
7 6 5 4 3 2 1 0
|
|
164
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
165
|
+
│LK1│LK0│MD5│MD4│MD3│MD2│MD1│MD0│
|
|
166
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
167
|
+
|
|
168
|
+
LK1/0 - Level Key Scale.
|
|
169
|
+
MD5/0 - Modulation Control.
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
#03h FEED
|
|
174
|
+
|
|
175
|
+
7 6 5 4 3 2 1 0
|
|
176
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
177
|
+
│LK1│LK0│ - │DS2│DS1│FD2│FD1│FD0│
|
|
178
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
179
|
+
|
|
180
|
+
LK1/0 - Level Key Scale.
|
|
181
|
+
DS2/1 - Distorted Wave Form.
|
|
182
|
+
FD2/0 - FM-Feedback constant.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
#04h / #05h CTRL.B / CTRL.A
|
|
187
|
+
|
|
188
|
+
7 6 5 4 3 2 1 0
|
|
189
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
190
|
+
│AT3│AT2│AT1│AT0│DC3│DC2│DC1│DC0│
|
|
191
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
192
|
+
|
|
193
|
+
AT3/0 - Attack envelope rate.
|
|
194
|
+
DC3/0 - Decay envelope rate.
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
#06h / #07h IND.B / IND.A
|
|
199
|
+
|
|
200
|
+
7 6 5 4 3 2 1 0
|
|
201
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
202
|
+
│IN3│IN2│IN1│IN0│RL3│RL2│RL1│RL0│
|
|
203
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
204
|
+
|
|
205
|
+
IN3/0 - Indication Decay / Sustain level.
|
|
206
|
+
RL3/0 - Release envelope rate.
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The FM synthesis is quite complicated, especially for the beginner it is just a matter of trying. Fortunately, there are quite a few music programs on the market that handle this themselves.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# MSX-MUSIC REGISTERS
|
|
2
|
+
|
|
3
|
+
## WRITE ONLY
|
|
4
|
+
|
|
5
|
+
The registers of the MSX-MUSIC system, as found in: FM-Pac, FM-Stereo-Pak, MSX2+ and TurboR computers, are controlled via ports &H7C and &H7D. The control works according to the same principle as with MSX-AUDIO and the PSG. The register is specified in 7C and the data in 7D. Unfortunately, these are Write Only ports, so they cannot be read.
|
|
6
|
+
|
|
7
|
+
## SOUND SETTINGS
|
|
8
|
+
|
|
9
|
+
The OPLL data (original instrument) is specified in registers 0-7. This data corresponds to the data you can retrieve in the SynthSaurus Sound Editor, so you can easily retrieve a homemade instrument and write those values to registers 0-7.
|
|
10
|
+
|
|
11
|
+
The following is the structure of registers 0-7 (OPLL instr)
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Reg.nr. Bit: Function:
|
|
15
|
+
------------------------------------------------------------
|
|
16
|
+
0,1 0-3 Multi sample waves/harmonic relations
|
|
17
|
+
4 Rate key scale
|
|
18
|
+
5 Latching/sprouting (1=Latch 0=Latch)
|
|
19
|
+
6 Vibration on/off (1=on 0=off)
|
|
20
|
+
7 Amplitude modulation (1=on 0=off)
|
|
21
|
+
|
|
22
|
+
2 0-5 Modulation index
|
|
23
|
+
6-7 Level key scale
|
|
24
|
+
|
|
25
|
+
3 0-2 FM recoil
|
|
26
|
+
3-4 Load-bearing and modulated waveform
|
|
27
|
+
link (FM/AM)
|
|
28
|
+
6-7 Level key scale
|
|
29
|
+
|
|
30
|
+
4,5 0-3 Decay change
|
|
31
|
+
4-7 Attack change (swelling)
|
|
32
|
+
|
|
33
|
+
6,7 0-3 Opening the change control
|
|
34
|
+
4-7 Major of Attack/Decay
|
|
35
|
+
------------------------------------------------------------
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## INSTRUMENT CONTROL
|
|
39
|
+
|
|
40
|
+
The registers printed below are for the instrument selection/frequency/octave/volume and the so-called Sustain.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Reg.nr. Bit: Function:
|
|
44
|
+
------------------------------------------------------------
|
|
45
|
+
&H10-&H18 0-7 Note frequency LSB (8 bits)
|
|
46
|
+
|
|
47
|
+
&H20-&H28 0 Note frequency MSB (1 bit)
|
|
48
|
+
1-3 Octave nr. (0-7, 0=octave 1, 7=octave 8)
|
|
49
|
+
4 Key on/off (1=on, 0=off)
|
|
50
|
+
5 Sustain (hold, 1=on, 0=off)
|
|
51
|
+
|
|
52
|
+
&H30-&H38 0-3 Volume (0=vol.15, F=vol.0 !)
|
|
53
|
+
4-7 Instrument select (0=original, <>0=FM
|
|
54
|
+
instrument)
|
|
55
|
+
------------------------------------------------------------
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## FM INSTRUMENTS
|
|
59
|
+
|
|
60
|
+
The MSX-MUSIC system has 15 pre-programmed instruments that can be used independently of each other.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
0 = Original (custom instrument, see SOUND SETTINGS)
|
|
64
|
+
1 = Violin 9 = Horn
|
|
65
|
+
2 = Guitar A = Synthesizer
|
|
66
|
+
3 = Piano B = Harpsichord
|
|
67
|
+
4 = Flute C = Vibraphone
|
|
68
|
+
5 = Clarinet D = Synthesizer Bass
|
|
69
|
+
6 = Oboe E = ElectrPiano2/Acoust. Bass
|
|
70
|
+
7 = Trumpet F = ElectrPiano1/ElectrGuitar
|
|
71
|
+
8 = Organ
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## RHYTHM
|
|
75
|
+
|
|
76
|
+
Register &H0E contains the drum selection, however bit 5 must be written before a drum can be heard. The drums can also be slightly changed, but rather limited and a bit chaotic. Below is a table of the drum values that can be written in register &H0E:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
bit 0 = HiHat bit 3 = Snare drum/Field drum
|
|
80
|
+
bit 1 = Cymbal bit 4 = Bass drum
|
|
81
|
+
bit 2 = TomTom bit 5 = selector (1 = Rhythm, 0 = Instrument)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Of course, multiple drums can be controlled simultaneously.
|
|
85
|
+
The rhythm sound is structured as follows:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Drum type: Reg. Bit: Function:
|
|
89
|
+
------------------------------------------------------------
|
|
90
|
+
Bass drum &H16 0-7 Frequency LSB (8 bits)
|
|
91
|
+
&H26 0 Frequency MSB (1 bit)
|
|
92
|
+
1-3 Octave (0-7)
|
|
93
|
+
&H36 0-3 Volume Bass drum
|
|
94
|
+
|
|
95
|
+
Snare & &h17 0-7 Frequency LSB (8 bits)
|
|
96
|
+
HiHat &H27 0 Frequency MSB (1 bit)
|
|
97
|
+
1-3 Octave (0-7)
|
|
98
|
+
&H37 0-3 Volume Snare
|
|
99
|
+
4-7 Volume HiHat
|
|
100
|
+
|
|
101
|
+
Cymbal & &H18 0-7 Frequency LSB (8 bits)
|
|
102
|
+
TomTom &H28 0 Frequency MSB (1 bit)
|
|
103
|
+
1-3 Octave (0-7)
|
|
104
|
+
&H38 0-3 Volume Cymbal
|
|
105
|
+
4-7 Volume TomTom
|
|
106
|
+
------------------------------------------------------------
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## BASIC REGISTERS
|
|
110
|
+
|
|
111
|
+
The registers of the MSX-MUSIC system are, under BASIC!, maintained from address &HF9C0 to &HF9C0+&H38. The settings of these registers are filled with the following values after the command CALL MUSIC:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Reg.nr. Value:
|
|
115
|
+
------------------------------------------------------------
|
|
116
|
+
Register pair 1: Instruments &H10-&H15 &H56
|
|
117
|
+
Drums &H16 &H20
|
|
118
|
+
&H17 &H50
|
|
119
|
+
&H18 &HC0
|
|
120
|
+
|
|
121
|
+
Register pair 2: Instruments &H20-&H25 &H00
|
|
122
|
+
Drums &H26 &H05
|
|
123
|
+
&H27 &H05
|
|
124
|
+
&H28 &H01
|
|
125
|
+
|
|
126
|
+
Register pair 3: Instruments &H30-&H35 &H30
|
|
127
|
+
Drums &H36 &H01
|
|
128
|
+
&H37 &H11
|
|
129
|
+
&H38 &H11
|
|
130
|
+
------------------------------------------------------------
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## USAGE
|
|
134
|
+
|
|
135
|
+
When using this information in, for example, an interrupt-driven music piece, you must take the following things into account.
|
|
136
|
+
|
|
137
|
+
1) When a new frequency is specified for an instrument, bit 4 of the corresponding register must first be switched off. To clarify: if a new frequency needs to be entered in channel 1, bit 4 of register &H10 must be cleared. After that the frequency is written, and finally bit 4 is set again (reg. &H10). For other channels a different register is used accordingly.
|
|
138
|
+
|
|
139
|
+
2) When an instrument is played that 'fades out' (Release), a short delay is needed in machine code:
|
|
140
|
+
|
|
141
|
+
```z80
|
|
142
|
+
LD B,3 ;approximately 3!
|
|
143
|
+
LOOP: DJNZ LOOP
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
3) The note frequencies are:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
Note: LSB MSB (bit 0 of reg &H20-&H28)
|
|
150
|
+
---------------------------------------------------------
|
|
151
|
+
C &HAD 0
|
|
152
|
+
C# &HB7 0
|
|
153
|
+
D &HC2 0
|
|
154
|
+
D# &HCD 0
|
|
155
|
+
E &HD9 0
|
|
156
|
+
F &HE6 0
|
|
157
|
+
F# &HF4 0
|
|
158
|
+
G &H03 1
|
|
159
|
+
G# &H12 1
|
|
160
|
+
A &H22 1
|
|
161
|
+
A# &H34 1
|
|
162
|
+
B &H46 1
|
|
163
|
+
---------------------------------------------------------
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
With this information you should now be able to control the MSX-MUSIC system through these registers. Good luck!
|
|
167
|
+
|
|
168
|
+
by R.M.
|
|
169
|
+
|
|
170
|
+
(Just to be clear: I don't know who R.M. is, but it's not me! - RM-FCS)
|
package/resources/audio/toc.json
CHANGED
|
@@ -8,6 +8,18 @@
|
|
|
8
8
|
"external_url": "https://www.msx.org/wiki/PSG_Registers",
|
|
9
9
|
"description": "Complete reference for MSX PSG (Programmable Sound Generator) registers covering all 16 registers including frequency control, white noise control, voice and I/O port control, amplitude and volume control, envelope form and period control, and I/O parallel port registers. Includes BIOS routines WRTPSG, RDPSG, and GICINI for PSG access and initialization."
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
"title": "FM-PAC / MSX-MUSIC (Yamaha YM-2413)",
|
|
13
|
+
"uri": "msxdocs://audio/chipsfmpacpr1_en",
|
|
14
|
+
"external_url": "https://gitlab.com/moltsxalats/learning-fusion-c-programs/-/raw/9e9c4a754657db095a39cfdfc5659756cc8797e3/chipsfmpacpr1_en.txt",
|
|
15
|
+
"description": "Direct programming guide for the Yamaha YM-2413 (FM-PAC/MSX-MUSIC) chip via I/O ports 07Ch/07Dh. Covers all 43 write-only registers including frequency, octave, key control, volume, instrument selection, drum channels, and software instrument programming via FM synthesis operators."
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"title": "MSX-MUSIC Registers",
|
|
19
|
+
"uri": "msxdocs://audio/chipsfmpacpr2_en",
|
|
20
|
+
"external_url": "https://gitlab.com/moltsxalats/learning-fusion-c-programs/-/raw/9e9c4a754657db095a39cfdfc5659756cc8797e3/chipsfmpacpr2_en.txt",
|
|
21
|
+
"description": "Register reference for the MSX-MUSIC OPLL chip (FM-PAC, FM-Stereo-Pak, MSX2+, TurboR) accessed via write-only ports &H7C/&H7D. Details OPLL custom instrument registers 0–7, instrument/frequency/octave/volume control registers, 15 preset FM instruments, rhythm/drum register layout, BASIC register defaults, and note frequency tables."
|
|
22
|
+
},
|
|
11
23
|
{
|
|
12
24
|
"title": "Konami SCC Sound Chip",
|
|
13
25
|
"uri": "msxdocs://audio/sound_cartridge_scc",
|
|
Binary file
|
|
Binary file
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
"title": "MSX Kun Basic compiler",
|
|
78
|
-
"uri": "msxdocs://book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler
|
|
78
|
+
"uri": "msxdocs://book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler",
|
|
79
79
|
"description": "The document describes MSX-BASIC-KUN, a BASIC compiler for MSX computers that significantly accelerates program execution (15 to 100 times faster). It compiles most MSX-BASIC statements, supports strings and floating-point numbers, and introduces turbo blocks (_TURBO ON/OFF) for selective compilation. The compiler has limitations, such as unsupported commands (e.g., BLOAD, PRINT#) and restrictions on variable handling within turbo blocks. It adds new features like inline assembly (#I), clipping control (#C), and overflow checks (#N). The compiler operates within RAM and cannot save compiled programs independently. It is ideal for creating high-performance MSX applications without requiring Z80 assembly language expertise."
|
|
80
80
|
}
|
|
81
81
|
]
|