@nataliapc/mcp-openmsx 1.1.15 → 1.2.2

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.
Files changed (190) hide show
  1. package/README.md +25 -14
  2. package/dist/server.js +73 -24
  3. package/dist/utils.js +10 -2
  4. package/dist/vectordb.js +60 -0
  5. package/package.json +8 -3
  6. package/resources/audio/msx-midi.md +872 -0
  7. package/resources/audio/psg_registers.md +281 -0
  8. package/resources/audio/sound_cartridge_scc.md +123 -0
  9. package/resources/audio/sound_cartridge_scci.md +250 -0
  10. package/resources/audio/toc.json +8 -4
  11. package/resources/book--msx2-technical-handbook/toc.json +1 -1
  12. package/resources/msx-unapi/toc.json +2 -2
  13. package/resources/programming/basic_wiki/ABS().md +36 -0
  14. package/resources/programming/basic_wiki/AND.md +71 -0
  15. package/resources/programming/basic_wiki/ASC().md +38 -0
  16. package/resources/programming/basic_wiki/ATN().md +36 -0
  17. package/resources/programming/basic_wiki/AUTO.md +39 -0
  18. package/resources/programming/basic_wiki/BASE().md +147 -0
  19. package/resources/programming/basic_wiki/BEEP.md +27 -0
  20. package/resources/programming/basic_wiki/BIN$().md +36 -0
  21. package/resources/programming/basic_wiki/BLOAD.md +63 -0
  22. package/resources/programming/basic_wiki/BSAVE.md +61 -0
  23. package/resources/programming/basic_wiki/CALL.md +391 -0
  24. package/resources/programming/basic_wiki/CALL_ADJUST.md +40 -0
  25. package/resources/programming/basic_wiki/CALL_IMPOSE.md +28 -0
  26. package/resources/programming/basic_wiki/CALL_OPTIONS.md +26 -0
  27. package/resources/programming/basic_wiki/CALL_PAUSE.md +119 -0
  28. package/resources/programming/basic_wiki/CALL_PCMPLAY.md +60 -0
  29. package/resources/programming/basic_wiki/CALL_PCMREC.md +70 -0
  30. package/resources/programming/basic_wiki/CDBL().md +36 -0
  31. package/resources/programming/basic_wiki/CHR$().md +51 -0
  32. package/resources/programming/basic_wiki/CINT().md +36 -0
  33. package/resources/programming/basic_wiki/CIRCLE.md +51 -0
  34. package/resources/programming/basic_wiki/CLEAR.md +39 -0
  35. package/resources/programming/basic_wiki/CLOAD.md +27 -0
  36. package/resources/programming/basic_wiki/CLOAD?.md +31 -0
  37. package/resources/programming/basic_wiki/CLOSE.md +44 -0
  38. package/resources/programming/basic_wiki/CLS.md +51 -0
  39. package/resources/programming/basic_wiki/COLOR.md +143 -0
  40. package/resources/programming/basic_wiki/COLOR=.md +93 -0
  41. package/resources/programming/basic_wiki/COLOR_SPRITE$().md +83 -0
  42. package/resources/programming/basic_wiki/COLOR_SPRITE().md +85 -0
  43. package/resources/programming/basic_wiki/CONT.md +23 -0
  44. package/resources/programming/basic_wiki/COPY.md +215 -0
  45. package/resources/programming/basic_wiki/COPY_SCREEN.md +61 -0
  46. package/resources/programming/basic_wiki/COS().md +37 -0
  47. package/resources/programming/basic_wiki/CSAVE.md +35 -0
  48. package/resources/programming/basic_wiki/CSNG().md +36 -0
  49. package/resources/programming/basic_wiki/CSRLIN.md +33 -0
  50. package/resources/programming/basic_wiki/DATA.md +47 -0
  51. package/resources/programming/basic_wiki/DEFDBL.md +40 -0
  52. package/resources/programming/basic_wiki/DEFINT.md +40 -0
  53. package/resources/programming/basic_wiki/DEFSNG.md +40 -0
  54. package/resources/programming/basic_wiki/DEFSTR.md +40 -0
  55. package/resources/programming/basic_wiki/DEF_FN.md +49 -0
  56. package/resources/programming/basic_wiki/DEF_USR.md +33 -0
  57. package/resources/programming/basic_wiki/DELETE.md +49 -0
  58. package/resources/programming/basic_wiki/DIM.md +59 -0
  59. package/resources/programming/basic_wiki/DRAW.md +77 -0
  60. package/resources/programming/basic_wiki/ELSE.md +45 -0
  61. package/resources/programming/basic_wiki/END.md +32 -0
  62. package/resources/programming/basic_wiki/EOF().md +36 -0
  63. package/resources/programming/basic_wiki/EQV.md +76 -0
  64. package/resources/programming/basic_wiki/ERASE.md +35 -0
  65. package/resources/programming/basic_wiki/ERL.md +34 -0
  66. package/resources/programming/basic_wiki/ERR.md +143 -0
  67. package/resources/programming/basic_wiki/ERROR.md +145 -0
  68. package/resources/programming/basic_wiki/EXP().md +38 -0
  69. package/resources/programming/basic_wiki/FIELD.md +48 -0
  70. package/resources/programming/basic_wiki/FIX().md +44 -0
  71. package/resources/programming/basic_wiki/FN.md +61 -0
  72. package/resources/programming/basic_wiki/FOR...NEXT.md +80 -0
  73. package/resources/programming/basic_wiki/FRE().md +66 -0
  74. package/resources/programming/basic_wiki/GET_DATE.md +60 -0
  75. package/resources/programming/basic_wiki/GET_TIME.md +34 -0
  76. package/resources/programming/basic_wiki/GOSUB.md +41 -0
  77. package/resources/programming/basic_wiki/GOTO.md +41 -0
  78. package/resources/programming/basic_wiki/HEX$().md +36 -0
  79. package/resources/programming/basic_wiki/IF...GOTO...ELSE.md +55 -0
  80. package/resources/programming/basic_wiki/IF...THEN...ELSE.md +50 -0
  81. package/resources/programming/basic_wiki/IMP.md +83 -0
  82. package/resources/programming/basic_wiki/INKEY$.md +65 -0
  83. package/resources/programming/basic_wiki/INP().md +33 -0
  84. package/resources/programming/basic_wiki/INPUT$().md +51 -0
  85. package/resources/programming/basic_wiki/INPUT.md +93 -0
  86. package/resources/programming/basic_wiki/INSTR().md +44 -0
  87. package/resources/programming/basic_wiki/INT().md +44 -0
  88. package/resources/programming/basic_wiki/INTERVAL.md +57 -0
  89. package/resources/programming/basic_wiki/KEY().md +51 -0
  90. package/resources/programming/basic_wiki/KEY.md +254 -0
  91. package/resources/programming/basic_wiki/LEFT$().md +39 -0
  92. package/resources/programming/basic_wiki/LEN().md +36 -0
  93. package/resources/programming/basic_wiki/LET.md +68 -0
  94. package/resources/programming/basic_wiki/LINE.md +74 -0
  95. package/resources/programming/basic_wiki/LINE_INPUT.md +79 -0
  96. package/resources/programming/basic_wiki/LIST.md +58 -0
  97. package/resources/programming/basic_wiki/LLIST.md +43 -0
  98. package/resources/programming/basic_wiki/LOAD.md +56 -0
  99. package/resources/programming/basic_wiki/LOCATE.md +67 -0
  100. package/resources/programming/basic_wiki/LOG().md +36 -0
  101. package/resources/programming/basic_wiki/LPOS().md +31 -0
  102. package/resources/programming/basic_wiki/LPRINT.md +46 -0
  103. package/resources/programming/basic_wiki/MAXFILES.md +39 -0
  104. package/resources/programming/basic_wiki/MERGE.md +54 -0
  105. package/resources/programming/basic_wiki/MID$().md +72 -0
  106. package/resources/programming/basic_wiki/MOD.md +39 -0
  107. package/resources/programming/basic_wiki/MOTOR.md +46 -0
  108. package/resources/programming/basic_wiki/NEW.md +27 -0
  109. package/resources/programming/basic_wiki/NOT.md +61 -0
  110. package/resources/programming/basic_wiki/OCT$().md +36 -0
  111. package/resources/programming/basic_wiki/ON...GOSUB.md +45 -0
  112. package/resources/programming/basic_wiki/ON...GOTO.md +42 -0
  113. package/resources/programming/basic_wiki/ON_ERROR_GOTO.md +61 -0
  114. package/resources/programming/basic_wiki/ON_INTERVAL_GOSUB.md +54 -0
  115. package/resources/programming/basic_wiki/ON_KEY_GOSUB.md +56 -0
  116. package/resources/programming/basic_wiki/ON_SPRITE_GOSUB.md +41 -0
  117. package/resources/programming/basic_wiki/ON_STOP_GOSUB.md +56 -0
  118. package/resources/programming/basic_wiki/ON_STRIG_GOSUB.md +70 -0
  119. package/resources/programming/basic_wiki/OPEN.md +103 -0
  120. package/resources/programming/basic_wiki/OR.md +75 -0
  121. package/resources/programming/basic_wiki/OUT.md +35 -0
  122. package/resources/programming/basic_wiki/PAD().md +110 -0
  123. package/resources/programming/basic_wiki/PAINT.md +66 -0
  124. package/resources/programming/basic_wiki/PDL().md +53 -0
  125. package/resources/programming/basic_wiki/PEEK().md +44 -0
  126. package/resources/programming/basic_wiki/PLAY().md +58 -0
  127. package/resources/programming/basic_wiki/PLAY.md +196 -0
  128. package/resources/programming/basic_wiki/POINT.md +52 -0
  129. package/resources/programming/basic_wiki/POKE.md +51 -0
  130. package/resources/programming/basic_wiki/POS().md +36 -0
  131. package/resources/programming/basic_wiki/PRESET.md +61 -0
  132. package/resources/programming/basic_wiki/PRINT.md +179 -0
  133. package/resources/programming/basic_wiki/PSET.md +82 -0
  134. package/resources/programming/basic_wiki/PUT_KANJI.md +93 -0
  135. package/resources/programming/basic_wiki/PUT_SPRITE.md +143 -0
  136. package/resources/programming/basic_wiki/READ.md +45 -0
  137. package/resources/programming/basic_wiki/REM.md +42 -0
  138. package/resources/programming/basic_wiki/RENUM.md +78 -0
  139. package/resources/programming/basic_wiki/RESTORE.md +52 -0
  140. package/resources/programming/basic_wiki/RESUME.md +45 -0
  141. package/resources/programming/basic_wiki/RETURN.md +47 -0
  142. package/resources/programming/basic_wiki/RIGHT$().md +39 -0
  143. package/resources/programming/basic_wiki/RND().md +51 -0
  144. package/resources/programming/basic_wiki/RUN.md +56 -0
  145. package/resources/programming/basic_wiki/SAVE.md +65 -0
  146. package/resources/programming/basic_wiki/SCREEN.md +164 -0
  147. package/resources/programming/basic_wiki/SET_ADJUST.md +66 -0
  148. package/resources/programming/basic_wiki/SET_BEEP.md +76 -0
  149. package/resources/programming/basic_wiki/SET_DATE.md +103 -0
  150. package/resources/programming/basic_wiki/SET_PAGE.md +52 -0
  151. package/resources/programming/basic_wiki/SET_PASSWORD.md +75 -0
  152. package/resources/programming/basic_wiki/SET_PROMPT.md +61 -0
  153. package/resources/programming/basic_wiki/SET_SCREEN.md +100 -0
  154. package/resources/programming/basic_wiki/SET_SCROLL.md +55 -0
  155. package/resources/programming/basic_wiki/SET_TIME.md +83 -0
  156. package/resources/programming/basic_wiki/SET_TITLE.md +87 -0
  157. package/resources/programming/basic_wiki/SET_VIDEO.md +49 -0
  158. package/resources/programming/basic_wiki/SGN().md +38 -0
  159. package/resources/programming/basic_wiki/SIN().md +36 -0
  160. package/resources/programming/basic_wiki/SOUND.md +188 -0
  161. package/resources/programming/basic_wiki/SPACE$().md +38 -0
  162. package/resources/programming/basic_wiki/SPC().md +34 -0
  163. package/resources/programming/basic_wiki/SPRITE$().md +50 -0
  164. package/resources/programming/basic_wiki/SPRITE.md +31 -0
  165. package/resources/programming/basic_wiki/SQR().md +32 -0
  166. package/resources/programming/basic_wiki/STICK().md +70 -0
  167. package/resources/programming/basic_wiki/STOP.md +70 -0
  168. package/resources/programming/basic_wiki/STR$().md +37 -0
  169. package/resources/programming/basic_wiki/STRIG().md +82 -0
  170. package/resources/programming/basic_wiki/STRING$().md +42 -0
  171. package/resources/programming/basic_wiki/SWAP.md +62 -0
  172. package/resources/programming/basic_wiki/TAB().md +38 -0
  173. package/resources/programming/basic_wiki/TAN().md +36 -0
  174. package/resources/programming/basic_wiki/TIME.md +59 -0
  175. package/resources/programming/basic_wiki/TROFF.md +21 -0
  176. package/resources/programming/basic_wiki/TRON.md +39 -0
  177. package/resources/programming/basic_wiki/USR().md +66 -0
  178. package/resources/programming/basic_wiki/VAL().md +36 -0
  179. package/resources/programming/basic_wiki/VARPTR().md +50 -0
  180. package/resources/programming/basic_wiki/VDP().md +103 -0
  181. package/resources/programming/basic_wiki/VPEEK().md +46 -0
  182. package/resources/programming/basic_wiki/VPOKE.md +48 -0
  183. package/resources/programming/basic_wiki/WAIT.md +38 -0
  184. package/resources/programming/basic_wiki/WIDTH.md +76 -0
  185. package/resources/programming/basic_wiki/XOR.md +72 -0
  186. package/resources/programming/basic_wiki/_toc.json +871 -0
  187. package/resources/sdcc/toc.json +1 -1
  188. package/vector-db/index.json +1 -0
  189. /package/resources/msx-unapi/{Ethernet_UNAPI_specification_1.1.md → Ethernet_UNAPI_specification_1_1.md} +0 -0
  190. /package/resources/msx-unapi/{MSX_UNAPI_specification_1.1.md → MSX_UNAPI_specification_1_1.md} +0 -0
@@ -0,0 +1,281 @@
1
+ # PSG Registers
2
+
3
+ ## Index
4
+
5
+ - [PSG Registers overview](#psg-registers-overview)
6
+ - [Frequency control registers](#)
7
+ - [White noise frequency control register](#)
8
+ - [PSG voice and I/O port control register](#)
9
+ - [Amplitude and volume control registers](#)
10
+ - [Envelope Form and Period Control Registers](#)
11
+ - [PSG I/O Parallel Port Registers](#)
12
+
13
+
14
+ ## PSG Registers overview
15
+
16
+ The PSG has 16 registers in which the content can be read and written except for register 14 which can only be read. To access the PSG registers, Bios in Main-ROM has two routines. The first is WRTPSG (00093h) which allows you to configure the PSG. The second, RDPSG (00096h), is used to read contents of a register.
17
+
18
+ There is also a routine in Bios of the Main-ROM called GICINI (00090h), which is used to initialize the PSG and the data of the instruction PLAY. Once initialized, all registers from 0 to 13 will be set to zero except register 0 which will have the value 01010101b (55h), register 7 which will have 10111000b (B8h) and register 11 which will have 1011b (0BH) for the period of the envelope.
19
+
20
+ PSG registers are also directly accessible through the I/O ports: 0A0h, 0A1h and 0A2h.
21
+ To write in a register directly via the I/O ports, you must write the register number to port 0A0h then the value to be written to port 0A1h. Take care to cut interrupts while writing register number and value. To read a register via the I/O ports, write the register number to read to port 0A0h then read the value from port 0A2h.
22
+
23
+ ## Frequency control registers
24
+
25
+ The first six registers are used to set the frequency to be generated to produce a sound.
26
+
27
+ ```
28
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
29
+ +-------+-------+-------+-------+-------+-------+-------+-------+
30
+ Register 0 | 8 least significant bits of voice frequency 1 |
31
+ +-------+-------+-------+-------+-------+-------+-------+-------+
32
+ Register 1 | - | - | - | - | 4 MSB of voice frequency 1 |
33
+ +-------+-------+-------+-------+-------+-------+-------+-------+
34
+ Register 2 | 8 least significant bits of voice frequency 2 |
35
+ +-------+-------+-------+-------+-------+-------+-------+-------+
36
+ Register 3 | - | - | - | - | 4 MSB of voice frequency 2 |
37
+ +-------+-------+-------+-------+-------+-------+-------+-------+
38
+ Register 4 | 8 least significant bits of voice frequency 3 |
39
+ +-------+-------+-------+-------+-------+-------+-------+-------+
40
+ Register 5 | - | - | - | - | 4 MSB of voice frequency 3 |
41
+ +-------+-------+-------+-------+-------+-------+-------+-------+
42
+ ```
43
+
44
+ Value indicating the frequency of the white noise generator is 5 bits. The value to be written is obtained using the following formula:
45
+ ```
46
+ Value = Fi / (16 x Fb)
47
+ ```
48
+
49
+ - Fi = Internal frequency of PSG (1789772.5 Hz on MSX)
50
+ - Fb = Tone frequency master to be produced (varies between between 27 and 111.860 Hz)
51
+
52
+ For simplicity, here is a table of musical notes by octave obtained according to the value indicated in registers 0-1, 2-3 or 4-5.
53
+
54
+ | Note | Octave 1 | Octave 2 | Octave 3 | Octave 4 | Octave 5 | Octave 6 | Octave 7 | Octave 8 |
55
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
56
+ |C|D5Dh|6AFh|357h|1ACh|0D6h|06Bh|035h|01Bh|
57
+ |C#|C9Ch|64Eh|327h|194h|0CAh|065h|032h|019h|
58
+ |D|BE7h|5F4h|2FAh|17Dh|0BEh|05Fh|030h|018h|
59
+ |D#|B3Ch|59Eh|2CFh|168h|0B4h|05Ah|02Dh|016h|
60
+ |E|A9Bh|54Eh|2A7h|153h|0AAh|055h|02Ah|015h|
61
+ |F|A02h|501h|281h|140h|0A0h|050h|028h|014h|
62
+ |F#|973h|4BAh|25Dh|12Eh|097h|04Ch|026h|013h|
63
+ |G|8EBh|476h|23Bh|11Dh|08Fh|047h|024h|012h|
64
+ |G#|86Bh|436h|21Bh|10Dh|087h|043h|022h|011h|
65
+ |A|7F2h|3F9h|1FDh|0FEh<sup>*</sup>|07Fh|040h|020h|010h|
66
+ |A#|780h|3C0h|1E0h|0F0h|078h|03Ch|01Eh|00Fh|
67
+ |B|714h|38Ah|1C5h|0E3h|071h|039h|01Ch|00Eh|
68
+
69
+ <sup>(*)</sup> 0FEh is the note produced by a tuning fork.
70
+ For example, to produce the note Do in octave 4 by voice 1, we would write 1h in register 1 and ACh in register 0. In practice, this looks like below.
71
+ In assembler:
72
+
73
+ ```
74
+ WRTPSG equ 00093h
75
+
76
+ ; --&gt; File header
77
+ db 0feh ; Binary code file
78
+ dw START ; Program destination address
79
+ dw END ; Program end address
80
+ dw START ; Program execution address
81
+ ; ---
82
+ org 0c000h
83
+ START:
84
+ ld b,13
85
+ PSGini: ld a,b ;
86
+ ld e,0 ; 8 least significant bits
87
+ cp 7
88
+ jr nz,NoR7 ; Jump if register different from 7
89
+ ld e,10111111b ; Bit 7 to 1 and bit 6 to 0
90
+ NoR7: call WRTPSG
91
+ djnz PSGini ; Loop to initialize registers
92
+
93
+ ld a,0 ; Register 0
94
+ ld e,0ach ; 8 least significant bits
95
+ call WRTPSG
96
+ ld a,1 ; Register 1
97
+ ld e,1 ; 4 most signifiant bits
98
+ call WRTPSG
99
+ ld a,8 ; Register 8
100
+ ld e,1100b ; Voice volume 1 to 12
101
+ call WRTPSG
102
+ ld a,7 ; Register 7
103
+ ld e,10111110b ; Enable voice 1
104
+ call WRTPSG
105
+ ret
106
+ END:
107
+ ```
108
+
109
+ Once assembled and saved as "V15O1C.BIN", run the routine with the following instruction.
110
+ ```
111
+ BLOAD"V15O1C.BIN",R
112
+ ```
113
+ In BASIC:
114
+ ```
115
+ 5 ' Initializes the sound registers of the PSG
116
+ 10 FOR R=0 TO 13
117
+ 20 IF R=7 THEN SOUND R,&amp;B10111111 ELSE SOUND R,0
118
+ 30 NEXT
119
+ 40 ' Play the note C on voice 1 with a volume of 12
120
+ 50 SOUND 0,&amp;hAC ' 8 least significant bits in register 0
121
+ 60 SOUND 1,1 ' 4 most significant bits in register 1
122
+ 70 SOUND 8,&amp;b1100 ' Adjusting the volume of voice 1 to 12
123
+ 80 SOUND 7,&amp;b10111110 ' Enables the sound generator on voice 1
124
+ ```
125
+
126
+ ## White noise frequency control register
127
+
128
+ This register is used to enable or disable the sound generator as well as the noise generator.
129
+
130
+ ```
131
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
132
+ +-------+-------+-------+-------+-------+-------+-------+-------+
133
+ Register 6 | - - - | White noise generator frequency |
134
+ +-------+-------+-------+-------+-------+-------+-------+-------+
135
+ ```
136
+
137
+ Value indicating the frequency of the white noise generator takes up 5 bits. The value to be written is obtained using the following formula. Only the 5 bits of the value are to be written in register 6.
138
+ ```
139
+ Value = Fi / 16 x Fb
140
+ ```
141
+ - Fi = PSG internal frequency (1789772.5 Hz)
142
+ - Fb = Base frequency of the noise to be produced (varies between 3.608 and 111.860 Hz)
143
+
144
+ ## PSG voice and I/O port control register
145
+
146
+ This register is used to enable or disable the sound generator as well as the noise generator. It is also used to adjust the direction of the PSG I/O ports.
147
+
148
+ ```
149
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
150
+ | PSG I/O Ports | Make the noise mute | Make the tone mute |
151
+ +-------+-------+-------+-------+-------+-------+-------+-------+
152
+ Register 7 | B=1 : A=0 |voice3 :voice2 :voice1 |voice3 :voice2 :voice1 |
153
+ +-------+-------+-------+-------+-------+-------+-------+-------+
154
+ ```
155
+
156
+ Notes:
157
+ - To make mute the sound on a voice, you can set the volume of the voice to 0 (registers 8 to 10) or deactivate the tone and noise generator of this voice by setting the corresponding bits of register 7 to 1.
158
+ - In order to guarantee the proper functioning of the PSG I/O ports, bit 7 of register 7 must always remain at 1 (port B in output mode) and bit 6 at 0 (port A in input mode).
159
+ - It is therefore possible to enable the sound generator and the noise generator at the same time on each voice. That is to say, mix the two.
160
+
161
+ ## Amplitude and volume control registers
162
+
163
+ ```
164
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
165
+ +-------+-------+-------+-------+-------+-------+-------+-------+
166
+ Register 8 | - - - | V/A | Voice Volume / Amplitude 1 |
167
+ +-------+-------+-------+-------+-------+-------+-------+-------+
168
+ Register 9 | - - - | V/A | Voice Volume / Amplitude 2 |
169
+ +-------+-------+-------+-------+-------+-------+-------+-------+
170
+ Register 10 | - - - | V/A | Voice Volume / Amplitude 3 |
171
+ +-------+-------+-------+-------+-------+-------+-------+-------+
172
+ ```
173
+
174
+ Reset bit 4 (V/A) to adjust the sound volume of the corresponding voice.
175
+ When bit 4 (V/A) is set, the volume will vary in proportion to the shape of the envelope defined by register 13.
176
+
177
+ ## Envelope Form and Period Control Registers
178
+
179
+ ```
180
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
181
+ +-------+-------+-------+-------+-------+-------+-------+-------+
182
+ Register 11 | 8 LSB of the value that determines the envelope period (T) |
183
+ +-------+-------+-------+-------+-------+-------+-------+-------+
184
+ Register 12 | 8 MSB of the value that determines the envelope period (T) |
185
+ +-------+-------+-------+-------+-------+-------+-------+-------+
186
+ Register 13 | - - - - | Envelope shape |
187
+ +-------+-------+-------+-------+-------+-------+-------+-------+
188
+ ```
189
+
190
+ Registers 11 and 12 control the envelope period. The value is on 16 bits (0~65535). It is calculated with the following expression:
191
+ ```
192
+ Value = Fi / (256 x T)
193
+ ```
194
+ - Fi = Internal frequency of PSG (1789772.5 Hz on MSX)
195
+ - T = Period of the envelope (in μs)
196
+
197
+ The register 13 defines the envelope shape. Here are the possible shapes:
198
+ ```
199
+ 00xx = _|\______ 01xx = _/|_____
200
+
201
+ 1000 = _|\|\|\|\ 1001 = _|\_____
202
+ ____
203
+ 1010 = _|\/\/\/\ 1011 = _|\|
204
+ ______
205
+ 1100 = _/|/|/|/| 1101 = _/
206
+
207
+ 1110 = _/\/\/\/\ 1111 = _/|_____
208
+ T T
209
+ ```
210
+
211
+ Bits detail:
212
+ - Bit 0 (Hold) specifies whether the period should be repetitive or not.
213
+ - Bit 1 (Alternate) specifies whether or not the shape of the envelope should be inverted on each repetition.
214
+ - Bit 2 (Attack) specifies whether or not to invert the shape of the envelope.
215
+ - Bit 3 (Continue) specifies that the shape of the envelope should remain at the same level at the end of the period.
216
+
217
+ ## PSG I/O Parallel Port Registers
218
+
219
+ Registers 14 and 15 are used to access and control the parallel ports of the PSG. On MSX, Port A is connected as an entry and B at the output to read general ports 1 or 2 (joystick ports) as well as two other signals to know the type of Japanese keyboard used, as well as the signal read by the cassette interface. Register 15 is used to control the general ports, as well as the LED of the "Code" or "Kana" keys.
220
+
221
+ ```
222
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
223
+ +--------+--------+--------+--------+-------+-------+-------+-------+
224
+ Register 14 | Port parallel A of E/S of PSG (Always set as input with R#7 bit6) |
225
+ +--------+--------+--------+--------+-------+-------+-------+-------+
226
+ ```
227
+
228
+ This register allows to read the state of the pins for the selected general port, the Japanese keyboard type (JIS or JP50on), and the signal read from the cassette interface.
229
+
230
+ - Bit 0 = Pin 1 state of the selected general port (Up if joystick)
231
+ - Bit 1 = Pin 2 state of the selected general port (Down if joystick)
232
+ - Bit 2 = Pin 3 state of the selected general port (Left if joystick)
233
+ - Bit 3 = Pin 4 state of the selected general port (Right if joystick)
234
+ - Bit 4 = Pin 6 state of the selected general port (Trigger A if joystick)
235
+ - Bit 5 = Pin 7 state of the selected general port (Trigger B if joystick)
236
+ - Bit 6 = 1 for JIS keyboard, 0 for JP50on (only valid for Japanese MSX)
237
+ - Bit 7 = CASRD (signal read from the cassette interface)
238
+
239
+ ```
240
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
241
+ +--------+--------+--------+--------+--------+-------+-------+-------+
242
+ Register 15 | Port parallel B of E/S of PSG (Always set as output with R#7 bit7) |
243
+ +--------+--------+--------+--------+--------+-------+-------+-------+
244
+ ```
245
+
246
+ This register allows to control the direction of the signals of the general port, which can be read via register 14. It allows also to set or read the state of the LED of the "code" or "kana" keys, depending on the keyboard.
247
+
248
+ - Bit 0 = pin control 6 of the general port 1<sup>*</sup>
249
+ - Bit 1 = pin control 7 of the general port 1<sup>*</sup>
250
+ - Bit 2 = pin control 6 of the general port 2<sup>*</sup>
251
+ - Bit 3 = pin control 7 of the general port 2<sup>*</sup>
252
+ - Bit 4 = pin control 8 of the general port 1 (0 for standard joystick mode)
253
+ - Bit 5 = pin control 8 of the general port 2 (0 for standard joystick mode)
254
+ - Bit 6 = selection of the general port readable via register 14 (1 for port 2)
255
+ - Bit 7 = LED control of the "Code" or "Kana" key. (1 to turn off)
256
+
257
+ <sup>(*)</sup> Put to 1 if the general port is used as a starter (reading).
258
+
259
+ The general port pins are connected as follows.
260
+
261
+ ```
262
+ General port 1 General port 2
263
+ ┌───────────────────┐ ┌───────────────────┐
264
+ │ 1 2 3 4 5 ──── +5V │ 1 2 3 4 5 ──── +5V
265
+ \ / \ /
266
+ \ 6 7 8 9 ────── GND \ 6 7 8 9 ────── GND
267
+ └───────────────┘ └───────────────┘
268
+ 1│6│2│7│3│8│4│ 1│6│2│7│3│8│4│
269
+ │ │ │ │ │ │ │ │ │ │ │ │ │ │
270
+ └─└─└─└─└─|─│1-4,6-7 1-4,6-7│─┘─┘─┘─┘─│─┘
271
+ 8| ▼ ▼ 8│
272
+ To bit 4 of <─┘ ┌────────────────────┐ └─> To bit 5 of
273
+ PSG port B │Commutation circuit │ PSG port B
274
+ │ ┼──────┐
275
+ └──┼──┼──┼──┼──┼──┼──┘ ▼
276
+ 1│ 2│ 3│ 4│ 6│ 7│ To bit 6 of PSG port B
277
+ ▼ ▼ ▼ ▼ ▼ ▼ (General port select signal)
278
+ To bits 0-5 of PSG port A
279
+ ```
280
+
281
+ © 1996-2025 Microcomputer & Related Culture Foundation. MSX is a trademark of MSX Licensing Corporation.
@@ -0,0 +1,123 @@
1
+ # Konami SCC Sound Chip
2
+
3
+
4
+ The SCC is a wavetable sound chip, just like the Gravis Ultra Sound, Sound Blaster (AWE)32 and Moonsound. They all have memory (tables), in which samples (waves) are stored. The samples are played back looped. The speed with which the samples are played, determines the frequency of the tone. A modern wavetable sound module usually has over a megabyte of memory, while the SCC has 128 bytes of memory.
5
+
6
+ List of what the SCC ICs says:
7
+ - My Salamander SCC IC: `KONAMI 051649 2212P003 JAPAN 8750AAA`.
8
+ - F1 Spirit: `KONAMI 051649 2212P003 JAPAN 8723AAA`.
9
+ - King's Valley 2 (MSX1): `KONAMI 051649 2212P003 JAPAN 8836EAI`.
10
+ - My Haunted Castle (Arcade PCB): `KONAMI 051649 2212P003 JAPAN 8802EAI`.
11
+
12
+
13
+ Clay Cowgill explains: the last digits aren't really a serial number, but rather a date code and fabrication location/lot numbers. The format is Year, Week, Info, so 8740AAA is:
14
+
15
+ 1987, 40th week (probably early November), AAA code (that would be manufacturer specific, but it probably tells what factory made it, what wafer batch it was from, what process line it was on, etc.)
16
+
17
+ You'll notice that the first two digits stay between 87-88 (they seem to have made all the chips between 1987 and 1988) and the next two digits are between 01-52 (only 52 weeks in a year).
18
+
19
+ Otherwise, all the chips you listed should be identical. (You could swap them and they'd still work the same in theory-- they were just made at different times.)
20
+
21
+ This SCC was also used in several arcade games made by Konami. As far as I know they are: Haunted Castle, City Bomber, Hexion, Nyan Nyan Panic. All of these are emulated by mame. Apart from the SCC (known as K051649 in MAME) they also use an YM3812 (OPL3) for music and another chip for samples.
22
+
23
+ I've got the Haunted Castle PCB, [Levien van Zon](http://maleb.scum.org/) has made an [excellent scan](http://bifi.msxnet.org/msxnet/tech/Konami_GX768.jpg) of it. To the left of the SCC (which is at the top-left) you can see the resistors packed into one device (which is for D/A conversion). You can also see the YM3812 (OPL3) and the Z80A.
24
+
25
+ The SCC has five channels. There are four functions for each channel:
26
+ - 32 bytes waveform.
27
+ - 12 bits frequency.
28
+ - 4 bits volume.
29
+ - 1 bit on/off switch.
30
+
31
+ Just like the bank select registers, the SCC is accessed through memory mapped I/O, and not through I/O ports. If you write xx111111b (3Fh, bits 7 and 6 are ignored) to bank select register 3 (memory area 9000h to 97FFh, see megaROM mappers for more information), the SCC can be accessed through memory area from 9800h to 9FFFh.
32
+
33
+ The register structure is similar to the PSG.
34
+
35
+ | Address | Function |
36
+ | 9800h-981Fh | waveform channel 1 |
37
+ | 9820h-983Fh | waveform channel 2 |
38
+ | 9840h-985Fh | waveform channel 3 |
39
+ | 9860h-987Fh | waveform channel 4 and 5 |
40
+ | 9880h-9881h | frequency channel 1 |
41
+ | 9882h-9883h | frequency channel 2 |
42
+ | 9884h-9885h | frequency channel 3 |
43
+ | 9886h-9887h | frequency channel 4 |
44
+ | 9888h-9889h | frequency channel 5 |
45
+ | 988Ah | volume channel 1 |
46
+ | 988Bh | volume channel 2 |
47
+ | 988Ch | volume channel 3 |
48
+ | 988Dh | volume channel 4 |
49
+ | 988Eh | volume channel 5 |
50
+ | 988Fh | on/off switch channel 1 to 5 |
51
+ | 9890h-989Fh | same as 9880h to 988Fh |
52
+ | 98A0h-98DFh | no function |
53
+ | 98E0h-98FFh | test register |
54
+
55
+ As you may have noticed, channel 4 shares its waveform with channel 5. The SCC+ has five waveforms so each channel has it's own waveform. See SCC+ Sound Cartridge for more information.
56
+
57
+ The waveform is made up of 32, signed (two's complement) bytes. The waveform represents the actual form of the tone the sound chip produces. It's played back from byte 0 to 31, and then again from 0 to 31, etc. A value of 0 means no amplitude. From 1 to 127 results in an increasingly higher amplitude. From -1 to -128 (FFh to 80h) results in an increasingly higher negative amplitude.
58
+
59
+ The frequency is stored the same way as in the PSG. The first byte contains bits 0 to 7 from the frequency. Bits 0 to 3 of the second byte contain bits 8 to 11 of the frequency. Bits 4 to 7 of the second byte are ignored. Remember that the value you enter is a period: a higher value gives a lower frequency.
60
+
61
+ The formula for calculating the frequency of the tone is the same as from the PSG:
62
+ ```
63
+ fclock
64
+ ftone = -------------
65
+ 32 * (TP + 1)
66
+ ```
67
+ - fclock: is the clock frequency of the computer. 3,579,545 Hz
68
+ - ftone: is the frequency of the channel
69
+ - TP: is the value in the frequency registers
70
+
71
+ The volume is stored in the same way as in the PSG, though it does not support envelopes. Bits 0 to 3 contain a volume of 0 to 15, and bits 7 to 4 are ignored. A volume of 0 is silent, and a volume of 15 is maximum volume.
72
+
73
+ The on/off switch register switches the different channels on or off. Set the associated bit high for a channel to activate it. It has the following structure:
74
+
75
+ | **Bit** | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
76
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
77
+ | **Channel** | none | none | none | 5 | 4 | 3 | 2 | 1 |
78
+
79
+
80
+ ### Test Register - 98E0h
81
+
82
+ This register is not used by Konami. All the addresses in the memory area (98E0h - 98FFh) refer to the same register. It is set a different memory area in the SCC+ (Sound Cartridge).
83
+
84
+ I haven't ever seen a description of this register, but by sampling the SCC on my PC, I've tried figuring out it's function.
85
+
86
+ | **Bit** | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
87
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
88
+ | **Function** | noise | noise | ? | ? | ? | ? | pitch | pitch |
89
+
90
+ The default value seems to be 0.
91
+
92
+ The pitch bits change the frequency of all the channels. If they are set to 11B or 10B, all the frequencies are multiplied by 16. If they are set to 01B, all the frequencies are multiplied by 256. (Most frequencies are shifted out of hearing range, except if you set the frequency to minimum (TP = FFFh), then you'll hear something.)
93
+
94
+ If the noise bits are set to 01B, channel 4 and 5 produce noise (=random frequencies near TP), and if the bits are set to 11B, channel 4 and 5 produce noise with envelopes.
95
+
96
+ This is as much as I've figured out so far. It probably isn't (completely) correct, but I'll continue to try and figure it out. If you think you can help me in any way, please do so.
97
+
98
+ ## Memory Behaviour
99
+
100
+ The memory area from 9800h to 987Fh behaves as RAM. The memory area from 9880h to 98FFh is write only; if you read it, it'll always return FFh.
101
+
102
+ The memory area from 9900h to 99FFh has exactly the same function as from 9800h to 98FFh. The same accounts for the area from 9A00h to 9AFFh, and so on to the area from 9F00h to 9FFFh. This behaviour can be easily be explained: the SCC/Mapper does not process address line A8 - A10, thus it cannot distinguish 9900h from 9800h, or 9F00h from 9800h. See [pinouts.txt](http://bifi.msxnet.org/msxnet/tech/pinouts.txt) for more info.
103
+
104
+ The memory area from 8000h to 97FFh is a part of the ROM as you would expect it to be.
105
+
106
+ ## Locating the SCC
107
+
108
+ How do you in which slot the SCC is? One way is to search the slots for cartridge with the 'AB' code that can be removed by writing a value other than 0 to the bank select register. However, in some cartridges the ROM is disabled; you won't find the 'AB' code. A better why is to search for a slot that contains ROM, and contains RAM at 9800h - 987Fh after writing 3Fh to 9000h. This will also work on the SCC+.
109
+
110
+ However, not all MSX emulators emulate the RAM behaviour; it's not used by any Konami game. To use the SCC on a emulator, assume that it is in slot 1 - 0, and write 3Fh to 9000h, and write your data to 9800h - 988Fh.
111
+
112
+ ## Weird Behaviour
113
+
114
+ I have a disassembler/monitor called monMSX, and if I view the SCC wave memory with it, it starts behaving very erratic. Every time its memory is read, it returns different values. Writing values does not seem to have any effect either.
115
+
116
+ If I then exit monMSX and start a game that uses the SCC, it sounds very weird. The waveforms seem to be wrong up. (volume and frequencies seem to be correct.)
117
+
118
+ ---
119
+
120
+ (c)BiFi <<bifi@msxnet.org>>
121
+
122
+
123
+
@@ -0,0 +1,250 @@
1
+ # Konami's Sound Cartridge SCC+ (SCCI)) for the MSX
2
+
3
+ ## Index
4
+
5
+ - [Features](#features)
6
+ - [Hardware Properties](#hardware-properties)
7
+ - [Expanding RAM memory](#expanding-ram-memory)
8
+ - [Connecting the Memory Banks](#connecting-the-memory-banks)
9
+ - [Using SCC+](#using-scc)
10
+ - [Loading ROM files into Sound Cartridge](#loading-rom-files-into-sound-cartridge)
11
+ - [Programming](#programming)
12
+ - [Memory](#memory)
13
+ - [Mode Register](#mode-register)
14
+ - [Writing to the Mode Register](#writing-to-the-mode-register)
15
+ - [Using the Sound Chip - SCC mode](#using-the-sound-chip---scc-mode)
16
+ - [Using the Sound Chip - SCC+ mode](#using-the-sound-chip---scc-mode-1)
17
+
18
+
19
+ ## Features
20
+
21
+ The Konami games Snatcher and SD Snatcher are both games on disks that operate with a cartridge, a Sound Cartridge. The cartridge is supplied with the original games.
22
+
23
+ This Sound Cartridge contains 64Kb RAM and a SCC (a sound chip designed by Konami). The RAM is not standard, so it can't be used with MemMan or any other standard program. The SCC is slightly better than the one in Konami megabit ROM cartridges. That is probably how the cartridge got the nickname "SCC+", to my knowledge Konami never used this name.
24
+
25
+ There were some rumours that the RAM in the cartridges was SRAM and the SCC was a 16 channel sound chip. As most rumours, this is not true. The RAM is just the usual DRAM (volatile) and the SCC is a 5 channel SCC. There also isn't a SCC+ in any megaROM. Several people on the MSX mailinglist have checked Solid Snake, Space Manbow, Quarth amongst others.
26
+
27
+ The two Sound Cartridges are different and incompatible. They are identical in capabilities, only the memory layout is different. So the sound chip itself is identical.
28
+
29
+ I assume Konami changed the layout so the cartridges are incompatible; if one owned Snatcher (lucky sod, nowadays) you would have to buy SD Snatcher, not just copy the disks of SD Snatcher (of course, anyone who knew Z80 assembly could `fix` that problem).
30
+
31
+ The sound chip is normal SCC (= the SCC in Konami megabit ROM cartridges) compatible. This means it can be used with cracked Konami megabit ROM cartridges for the music. Also, there is no game in the Sound Cartridge, so it doesn't need to be modified to be used (or inserted after startup).
32
+
33
+ The improvement of SCC is compared to the normal SCC that the Sound Cartridge has a extra waveform. Now channel 4 doesn't have to share its waveform with channel 5 (thus all five channels have a private waveform).
34
+
35
+ ## Hardware Properties
36
+
37
+ The number written on the large IC is "KONAMI 052539 SCC-I2312P001 JAPAN", which is the same number written on the Snatcher SCC+ of Klaas de Wind (I haven't opened my own Snatcher SCC+ ^^;). This shows that the sound chip of SD Snatcher and Snatcher are identical.
38
+
39
+ The sound IC is very large compared to the normal megaROM SCC IC. There are some very obvious reasons for this. First of all, to recoqnise the address BFFEh indepentently of all other addresses, all 16 address lines must be connected to it. Not all address lines are connected to a megaROM SCC IC (difference : 3 lines). The RAM is DRAM, so the address lines are multiplexed. So a seperate connect is necessary for the DRAM and the refresh signal is necessary (difference : about 11).
40
+
41
+ On the picture there are four postions for DRAM ICs. As you can see only two are used. Now there'll all filled! In the Snatcher SCC+, the other two postions are filled, that's the difference.
42
+
43
+ ## Expanding RAM Memory
44
+
45
+ It's possible to add another 64Kb RAM to both cartridges. There are two open places on the print for it (see the picture above.). They're four bits wide, and have a 64K range. That's RAM IC type 4464. Note that on the RAM ICs already on-board do not have standard types printed on them.
46
+
47
+ If you've added the RAM, you can load Konami MegaROMs of 128Kb in it. It's very nice because the cartridge behaves exactly as a real SCC cartridge when it's loaded. Until you turn the power off. :) See below for the program to load unmodified .rom files.
48
+
49
+ Now all SD/The Snatchers and game collections work with your cartridge.
50
+
51
+ If you're going to do this and don't have much experience soldering: I had some trouble getting the ICs onto the PCB, because Konami was nice enough to put solder in the holes where the pins have to go in. Someone told me to use a soldering pump (also called solder sucker, tinzuigertje in Dutch) to get the solder out. Using that device it was a piece of cake.
52
+
53
+ ### Connecting the Memory Banks
54
+
55
+ It is possible to connect the two 64Kb memory banks so they both seems to exist (mirrored). Now values 0-7 selects the same memory area as values 8-15. This works for both cartridges.
56
+
57
+ Now all Konami games work with your cartridge, but it is not possible to load megaROMs into it.
58
+
59
+ To do this, connect the CAS (pin 16) of one of the RAM ICs with the CAS of the places where you can put a RAM IC. Easy as can be. Konami used the CAS (Collumn Address Strobe) as a sort of Output Enable.
60
+
61
+ ## Using SCC+
62
+
63
+ The Snatcher Sound Cartridge can be used with the Konami Games Collections, since most games in these collections have been improved to use the Snatcher Sound Cartridge sound chip.
64
+
65
+ There are cracks around of SD Snatcher, The Snatcher and the Games Collections which operate with a standard megaROM SCC. Mostly the music sounds the same, but because the megaROM SCC has one wave form less, it sometimes will sound differently.
66
+
67
+ The Konami Games Collections and The Snatcher cannot be used with the standard SD Snatcher cartridge, but they can with the Snatcher cartridge. This is because they use values 0-7 for the bank select registers, which select the non-existing memory in the SD Snatcher cartridge so it does not seem to exist.
68
+
69
+ There are several solutions to this problem:
70
+ - Modify the games. Add 8 to every value that this written to a bank select register.
71
+ - You can also add another 64Kb RAM to your cartridge (see above).
72
+ - Or you can connect the two 64Kb memory areas so they seem one (see above).
73
+
74
+ SD Snatcher works only with the SD cartridge. Values 8-15 select the memory.
75
+
76
+ ### Loading ROM Files into Sound Cartridge
77
+
78
+ Since the Sound Cartridge contains RAM, it is possible to load ROM files into it. The standard Sound Cartridge (SD or The Snatcher) can only hold ROM files up to 64Kb (that's the amount of RAM) or 128Kb if it is expanded.
79
+
80
+ If you've expanded the RAM of your Sound Cartridge, you can also load one megabit (128Kb) ROM files into your Sound Cartridge. Note that the Sound Cartridge will be behave exactly as an Konami SCC 1 megabit ROM. (until 2 ms after you turned the power off. ^_^) These ROM files can be loaded without problem, but the Konami 1 megabit ROM without SCC can also using SCROM.
81
+
82
+ SCROM can convert them to use the correct mapper addresses, that's not 4000h/6000h/8000h/A000h, but 5000h/7000h/9000h/B000h). Documentation is in the zip file.
83
+
84
+ [scrom.zip](http://bifi.msxnet.org/msxnet/tech/scrom.zip) (Sound Cartridge ROM loader)
85
+
86
+ The fact that this is possible makes me think that this cartridge was used for testing Konami ROMs while they were in development. Of course, this is only speculation.
87
+
88
+ ## Programming
89
+
90
+ In this section I'll atempt to explain how the SCC+ can be used from assembly. It is much like a normal SCC, but now with RAM and an extra wave form.
91
+
92
+ ### Memory
93
+
94
+ As with Konami megaROMs, the memory is divided into four memory banks:
95
+ ```
96
+ Bank 1: 4000h-5FFFh
97
+ Bank 2: 6000h-7FFFh
98
+ Bank 3: 8000h-9FFFh
99
+ Bank 4: A000h-BFFFh
100
+ ```
101
+
102
+ And, to access the bank select registers, write to any address of the following memory areas:
103
+ ```
104
+ Bank 1: 5000h-57FFh
105
+ Bank 2: 7000h-77FFh
106
+ Bank 3: 9000h-97FFh
107
+ Bank 4: B000h-B7FFh
108
+ ```
109
+
110
+ As you can see this much like the megaROM SCC. See megaROM mappers for more information on memory banks and bank select registers.
111
+
112
+ Both cartridges have a (physical) memory bank of 128Kb RAM while there is only 64Kb installed on it. Thus there are 16 memory areas of each 8Kb. Bits 7 to 4 are ignored, thus 16 (10000b) selects the first memory area (0).
113
+
114
+ Here's the difference between The Snatcher cartridge and SD Snatcher cartridge:
115
+ - On the Snatcher cartridge, the RAM is installed in the lower part of the 128Kb
116
+ (values 0-7 select installed RAM, 8-F select nothing (if you read it you'll get FFh)).
117
+ - And on the SD Snatcher cartridge the RAM is installed in the higher part of the 128Kb: values 0-7 select nothing, 8-F select installed RAM).
118
+
119
+ It is possible to add the other 64Kb RAM to both cartridges. This has several interesting advantages, see somewhere above for more information.
120
+
121
+ By default, the bank select registers have the following values:
122
+ ```
123
+ Bank 1: 0
124
+ Bank 2: 1
125
+ Bank 3: 2
126
+ Bank 4: 3
127
+ ```
128
+
129
+ (As, of course, a megaROM cartridge.) This select the first 32Kb RAM in the The Snatcher cartridge, and nothing in the SD Snatcher cartridge (unless expanded). This is important for memory residant programs, because the 'AB' code must be there. In the standard SD Snatcher cartridge memory resident programs disappear (get deselected) after a hard reset.
130
+
131
+ In its initial state, you can only read from the memory. But, it wouldn't be very useful if you couldn't write to it. That's why you can change to RAM mode. In this mode, you can't change memory areas, but you can read and write to the memory (where existing). I've called the mode in which you can change memory areas "bank select mode".
132
+
133
+ To change modes, use the:
134
+
135
+ ### Mode Register
136
+
137
+ Using the mode register, you can switch between normal SCC and SCC+ mode and between RAM and bank select mode.
138
+
139
+ | Bit | Function |
140
+ |:-:|---|
141
+ | 7 | none |
142
+ | 6 | none |
143
+ | 5 | Sound Mode (1 = SCC+, 0 = SCC) |
144
+ | 4 | Memory Mode (1 = RAM, 0 = bank select) |
145
+ | 3 | none |
146
+ | 2 | Bank 3 Mode (1 = RAM, 0 = bank select) |
147
+ | 1 | Bank 2 Mode (1 = RAM, 0 = bank select) |
148
+ | 0 | Bank 1 Mode (1 = RAM, 0 = bank select) |
149
+
150
+ The Memory Mode bit sets all memory banks to either RAM or bank select, but the Bank x Mode bits are for setting the memory banks individually back to RAM mode when the cartridge is in bank select mode. They sort of "override" the bank select mode. The Bank x Mode bits have no effect in RAM mode.
151
+
152
+ When the cartridge is in bank select mode (bit 4 low), banks 1, 2 and 3 can be set back into RAM individually using bits 0, 1 and 2.
153
+
154
+ If Bank 1 Mode is high, and the cartridge is in bank select mode (bit 4 is low), Bank 1 is put into RAM mode. The same applies to Bank 2 mode.
155
+
156
+ For the Bank 3 Mode, there is another requirement: the cartridge must be in SCC+ mode, and not SCC mode. Thus, if bit 4 is low, bit 5 high and bit 2 high, bank 3 is in RAM mode. (Mode Register value 24h for example)
157
+
158
+ So for some examples:
159
+ ```
160
+ Value: Bank 1 2 3 4
161
+ 10h RAM RAM RAM RAM
162
+ 01h RAM ROM ROM ROM
163
+ 27h RAM RAM RAM ROM
164
+ 07h RAM RAM ROM ROM
165
+ ```
166
+
167
+ The Mode Register has the initial value 0: by default, it is in SCC compatibility mode and bank select mode (thus operating exactly like a megaROM cartridge).
168
+
169
+ Here are some useful values for the Mode Register (Konami uses some of these; they're holy & very logical). Note that the lower Fh could just as well be any other value, they're just there to make it obvious you want RAM mode.
170
+
171
+ | Value | Memory Mode | Sound Mode |
172
+ |:-:|:-:|:-:|
173
+ | 00h | bankselect | SCC |
174
+ | 1Fh | RAM | SCC |
175
+ | 20h | bankselect | SCC+ |
176
+ | 3Fh | RAM | SCC+ |
177
+
178
+ #### Writing to the Mode Register
179
+
180
+ The mode register can be written to via memory mapped I/O address BFFEh and BFFFh. It can't be read; if you try to read one of these addresses, you'll get a byte from the memory bank as you would have expected. It does not matter whether you use address BFFEh or BFFFh.
181
+
182
+ This, of course, has an annoying consequence: RAM at address BFFEh and BFFFh cannot be changed. Note that if you use the same RAM in a different bank, these restrictions do not apply.
183
+
184
+ ### Using the Sound Chip - SCC mode
185
+
186
+ When bank 3 is in bank select mode and in SCC mode, you can use the SCC in more or less the same way as the SCC in a megaROM. You must write xx11111b (3Fh, bits 6/7 do not matter) to bank select register 3. Now you can access the SCC in memory area 9800h-9FDFh. If bank 3 is in RAM mode, you can read from the SCC but you can't write to it.
187
+
188
+ | Address | Function |
189
+ |:-:|---|
190
+ | 9800h-981Fh | waveform channel 1 |
191
+ | 9820h-983Fh | waveform channel 2 |
192
+ | 9840h-985Fh | waveform channel 3 |
193
+ | 9860h-987Fh | read: waveform channel 4<br>write: waveform channel 4 and 5 |
194
+ | 9880h-9881h | frequency channel 1 |
195
+ | 9882h-9883h | frequency channel 2 |
196
+ | 9884h-9885h | frequency channel 3 |
197
+ | 9886h-9887h | frequency channel 4 |
198
+ | 9888h-9889h | frequency channel 5 |
199
+ | 988Ah | volume channel 1 |
200
+ | 988Bh | volume channel 2 |
201
+ | 988Ch | volume channel 3 |
202
+ | 988Dh | volume channel 4 |
203
+ | 988Eh | volume channel 5 |
204
+ | 988Fh | on/off switch channel 1 to 5 |
205
+ | 9890h-989Fh | same as 9880h-988Fh |
206
+ | 98A0h-98BFh | read: waveform channel 5 (no write) |
207
+ | 98C0h-98DFh | test register |
208
+ | 98E0h-98FFh | no function |
209
+
210
+ The test register is a different memory area, and the waveform of channel 5 can be read separately. Whatever you write to waveform channel 4 (9860h-987Fh), also gets written to waveform channel 5. In this way it is fully megaROM SCC compatible (except for the test register which is at 98E0h-98FFh in the megaROM SCC.
211
+
212
+ In this mode, waveform from channel 4 and 5 can only differ if they have just been changed in SCC+ mode.
213
+
214
+ See SCC Sound Chip for more information.
215
+
216
+ ### Using the Sound Chip - SCC+ mode
217
+
218
+ When bank 4 is in bank select mode and in SCC+ mode, you can active the SCC by writing 1xxxxxxxb (80h, bits 0 to 6 are not important) to bank select register 4. The SCC+ appears at memory area B800h to BFDFh (last two bytes are for mode register). It has the following structure, which is much like the SCC. If bank 4 is in RAM mode you can read from the SCC but you can't write to it.
219
+
220
+ | Address | Function |
221
+ |:-:|---|
222
+ | B800h-B81Fh | waveform channel 1 |
223
+ | B820h-B83Fh | waveform channel 2 |
224
+ | B840h-B85Fh | waveform channel 3 |
225
+ | B860h-B87Fh | waveform channel 4 |
226
+ | B880h-B89Fh | waveform channel 5 |
227
+ | B8A0h-B8A1h | frequency channel 1 |
228
+ | B8A2h-B8A3h | frequency channel 2 |
229
+ | B8A4h-B8A5h | frequency channel 3 |
230
+ | B8A6h-B8A7h | frequency channel 4 |
231
+ | B8A8h-B8A9h | frequency channel 5 |
232
+ | B8AAh | volume channel 1 |
233
+ | B8ABh | volume channel 2 |
234
+ | B8ACh | volume channel 3 |
235
+ | B8ADh | volume channel 4 |
236
+ | B8AEh | volume channel 5 |
237
+ | B8AFh | on/off switch channel 1 to 5 |
238
+ | B8B0h-B8BFh | same as B8A0h-B8AFh |
239
+ | B8C0h-B8DFh | test register |
240
+ | B8E0h-B8FFh | no function |
241
+
242
+ The difference is that now channel 5 has a private waveform. For more information about the operation of the SCC, see SCC Sound Chip.
243
+
244
+ The fact that SCC may be addressed in two modes, this does not mean that the SCC+ has twice the channels of normal SCC. If you change Sound Mode, the different addresses refer to the same registers.
245
+
246
+ If the SCC control areas (these things above) are active, and you put the SCC+ into RAM mode and then start writing to the control areas, some really weird things happen in the RAM. The SCC is unaffected but whole areas of the RAM are messed up.
247
+
248
+ ---
249
+
250
+ (c)BiFi <<bifi@msxnet.org>>