@nataliapc/mcp-openmsx 1.1.5 → 1.1.8

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 (48) hide show
  1. package/README.md +38 -0
  2. package/dist/server.js +110 -23
  3. package/dist/utils.js +17 -0
  4. package/package.json +4 -1
  5. package/resources/audio/toc.json +31 -0
  6. package/resources/bios/Calling_BIOS_from_MSX-DOS.md +75 -0
  7. package/resources/bios/MSX2_SUBROM_BIOS_calls.md +734 -0
  8. package/resources/bios/MSX_BIOS_calls.md +1046 -0
  9. package/resources/bios/toc.json +24 -0
  10. package/resources/book--msx2-technical-handbook/Appendix1__BIOS_Listing.md +1464 -0
  11. package/resources/book--msx2-technical-handbook/Appendix2__Math-Pack.md +427 -0
  12. package/resources/book--msx2-technical-handbook/Appendix3__Bit_Block_Transfer.md +182 -0
  13. package/resources/book--msx2-technical-handbook/Appendix4__Work_Area_Listing.md +1637 -0
  14. package/resources/book--msx2-technical-handbook/Appendix5__VRAM_Map.md +145 -0
  15. package/resources/book--msx2-technical-handbook/Appendix6__IO_Map.md +128 -0
  16. package/resources/book--msx2-technical-handbook/Appendix8_10__Control_Codes_and_Escape_Sequences.md +76 -0
  17. package/resources/book--msx2-technical-handbook/Chapter1__MSX_System_Overview.md +402 -0
  18. package/resources/book--msx2-technical-handbook/Chapter2__BASIC.md +2148 -0
  19. package/resources/book--msx2-technical-handbook/Chapter3__MSX-DOS.md +2577 -0
  20. package/resources/book--msx2-technical-handbook/Chapter4a__VDP_and_Display_Screen.md +2052 -0
  21. package/resources/book--msx2-technical-handbook/Chapter4b__VDP_and_Display_Screen.md +3311 -0
  22. package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md +2714 -0
  23. package/resources/book--msx2-technical-handbook/Chapter5b__Access_to_Peripherals_through_BIOS.md +1263 -0
  24. package/resources/book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler.md +220 -0
  25. package/resources/book--msx2-technical-handbook/toc.json +82 -0
  26. package/resources/book--the-msx-red-book/the_msx_red_book.md +10349 -0
  27. package/resources/book--the-msx-red-book/toc.json +12 -0
  28. package/resources/msx-dos/MSX-DOS_2_Function_Specifications.md +1366 -0
  29. package/resources/msx-dos/MSX-DOS_2_Program_Interface_Specification.md +963 -0
  30. package/resources/msx-dos/toc.json +18 -0
  31. package/resources/msx-unapi/Ethernet_UNAPI_specification_1.1.md +369 -0
  32. package/resources/msx-unapi/Introduction_to_MSX-UNAPI.md +132 -0
  33. package/resources/msx-unapi/MSX_UNAPI_specification_1.1.md +679 -0
  34. package/resources/msx-unapi/TCP-IP_UNAPI_specification.md +2361 -0
  35. package/resources/msx-unapi/toc.json +27 -0
  36. package/resources/others/toc.json +11 -0
  37. package/resources/processors/Z80_R800_instruction_set.md +482 -0
  38. package/resources/processors/toc.json +24 -0
  39. package/resources/processors/z80-undocumented.tex +5617 -0
  40. package/resources/processors/z80_detailed_instruction_set.md +2025 -0
  41. package/resources/programming/toc.json +121 -0
  42. package/resources/system/MSX_IO_ports_overview.md +554 -0
  43. package/resources/system/toc.json +18 -0
  44. package/resources/video/V9938_Technical_Data_Book.md +3623 -0
  45. package/resources/video/V9958_Technical_Data_Book.md +417 -0
  46. package/resources/video/V9990_Programmers_Manual_Banzai.html +1582 -0
  47. package/resources/video/VDP_TMS9918A.txt +709 -0
  48. package/resources/video/toc.json +28 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "title": "More MSX Technical Info from http://bifi.msxnet.org/msxnet/tech/",
3
+ "description": "MSX Technical Info from http://bifi.msxnet.org/msxnet/tech/",
4
+ "toc": [
5
+ {
6
+ "title": "MSX-DOS 2 Program Interface Specification",
7
+ "uri": "msxdocs://msx-dos/MSX-DOS_2_Program_Interface_Specification",
8
+ "external_url": "https://map.grauw.nl/resources/dos2_environment.php",
9
+ "description": "This comprehensive specification document serves as the definitive technical reference for MSX-DOS 2, the advanced disk operating system for MSX2 computers. It details the complete programming interface for developing transient programs, covering the evolution from CP/M and MSX-DOS 1 to the enhanced MSX-DOS 2 system with full backward compatibility. The document encompasses everything from basic program execution environment to advanced memory management, including transient program environment setup, complete MSX-DOS function call specifications, modern file handle systems, File Info Blocks (FIBs) for directory manipulation, environment strings for dynamic configuration, mapper support for extended memory management beyond 64K, VT-52 compatible screen control codes, and comprehensive error handling mechanisms."
10
+ },
11
+ {
12
+ "title": "MSX-DOS 2 Function Specifications",
13
+ "uri": "msxdocs://msx-dos/MSX-DOS_2_Function_Specifications",
14
+ "external_url": "https://map.grauw.nl/resources/dos2_functioncalls.php",
15
+ "description": "This document provides a comprehensive specification of MSX-DOS 2 function calls (version 2.20), detailing over 90 system functions accessible via two calling methods: CALL 00005h for MSX-DOS environment programs and CALL 0F37Dh for disk BASIC programs. The functions are categorized by compatibility level (CPM for CP/M 2.2 compatibility, MSX1 for MSX-DOS version 1 compatibility, and NEW for MSX-DOS 2 exclusive features) and cover essential system operations including file management (FCB and file handle based), directory operations, disk I/O, console I/O, memory management, process control, and device handling. Each function is thoroughly documented with parameters, return values, error conditions, and implementation details, making this an indispensable reference for MSX software development, system programming, and understanding the MSX-DOS operating system interface for both legacy compatibility and modern MSX development workflows."
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,369 @@
1
+ # The Ethernet UNAPI specification
2
+
3
+ This document describes an UNAPI compliant API specification for Ethernet hardware for MSX computers.
4
+
5
+ ## Index
6
+
7
+ [1. Introduction](#1-introduction)
8
+
9
+ [2. API identifier and version](#2-api-identifier-and-version)
10
+
11
+ [3. API routines](#3-api-routines)
12
+
13
+ [3.1. ETH_GETINFO: Obtain the implementation name and version](#31-eth_getinfo-obtain-the-implementation-name-and-version)
14
+
15
+ [3.2. ETH_RESET: Reset hardware](#32-eth_reset-reset-hardware)
16
+
17
+ [3.3. ETH_GET_HWADD: Obtain the Ethernet address](#33-eth_get_hwadd-obtain-the-ethernet-address)
18
+
19
+ [3.5. ETH_NET_ONOFF: Enable or disable networking](#35-eth_net_onoff-enable-or-disable-networking)
20
+
21
+ [3.6. ETH_DUPLEX: Configure duplex mode](#36-eth_duplex-configure-duplex-mode)
22
+
23
+ [3.7. ETH_FILTERS: Configure frame reception filters](#37-eth_filters-configure-frame-reception-filters)
24
+
25
+ [3.8. ETH_IN_STATUS: Check for received frames availability](#38-eth_in_status-check-for-received-frames-availability)
26
+
27
+ [3.9. ETH_GET_FRAME: Retrieve the oldest received frame](#39-eth_get_frame-retrieve-the-oldest-received-frame)
28
+
29
+ [3.10. ETH_SEND_FRAME: Send a frame](#310-eth_send_frame-send-a-frame)
30
+
31
+ [3.11. ETH_OUT_STATUS: Check frame transmission status](#311-eth_out_status-check-frame-transmission-status)
32
+
33
+ [3.12. ETH_SET_HWADD: Set the Ethernet address](#312-eth_set_hwadd-set-the-ethernet-address)
34
+
35
+ [Appendix A. Ethernet frame formats](#appendix-a-ethernet-frame-formats)
36
+
37
+ [Appendix B. Acknowledgements](#appendix-b-acknowledgements)
38
+
39
+ [Appendix C. Version history](#appendix-c-version-history)
40
+
41
+ ## 1. Introduction
42
+
43
+ MSX-UNAPI is a standard procedure for defining, discovering and using new APIs (Application Program Interfaces) for MSX computers. The MSX-UNAPI specification is described [in a separate document](MSX%20UNAPI%20specification%201.1.md).
44
+
45
+ This document describes an UNAPI compliant API intended for hardware that implements Ethernet networking capabilities. The functionality provided by this API covers the link layer of a network communications stack; as such, it mainly provides routines to send and receiving raw Ethernet frames to and from an Ethernet network. There are also auxiliary routines to check for network availability, to obtain the local Ethernet address, or to configure reception filters.
46
+
47
+ The intended client software applications for this API are implementations of the higher level layers of the communications stack, typically, TCP/IP stacks. Anyway it can be useful for other types of software as well, for example network traffic monitors.
48
+
49
+ Note that it is not mandatory to have actual underlying Ethernet hardware in order to implement this API. As long as the routine signatures and behaviors are preserved, the implementation will ve valid, even if it acts on a completely different type of hardware, or on no harwdare at all (for example, an Ethernet emulation API over a serial or JoyNet cable could be developed).
50
+
51
+ ## 2. API identifier and version
52
+
53
+ The API identifier for the specification described in this document is: "ETHERNET" (without the quotes). Remember that per the UNAPI specification, API identifiers are case-insensitive.
54
+
55
+ The Ethernet API version described in this document is 1.1. This is the API specification version that the mandatory implementation information routine must return in DE (see [Section 3.1](#31-eth_getinfo-obtain-the-implementation-name-and-version)).
56
+
57
+ ## 3. API routines
58
+
59
+ This version of the Ethernet API consists of 11 mandatory routines, which are described below. API implementations may define their own additional implementation-specific routines, as described in the MSX- UNAPI specification.
60
+
61
+ ### 3.1. ETH_GETINFO: Obtain the implementation name and version
62
+
63
+ * Input:
64
+ * A = 0
65
+
66
+ * Output:
67
+ * HL = Address of the implementation name string
68
+ * DE = API specification version supported. D=primary, E=secondary.
69
+ * BC = API implementation version. B=primary, C=secondary.
70
+
71
+ This routine is mandatory for all implementations of all UNAPI compliant APIs. It returns basic information about the implementation itself: the implementation version, the supported API version, and a pointer to the implementation description string.
72
+
73
+ The implementation name string must be placed in the same slot or segment of the implementation code (or in page 3), must be zero terminated, must consist of printable characters, and must be at most 63 characters long (not including the terminating zero). Refer to the MSX-UNAPI specification for more details.
74
+
75
+ ### 3.2. ETH_RESET: Reset hardware
76
+
77
+ * Input:
78
+ * A = 1
79
+
80
+ This routine resets the underlying hardware and/or the API implementation state variables to its initial state. After executing this routine, the hardware (if present) and the implementation must remain in the same state as after a computer reset or after the implementation is installed (whatever applies). More precisely, the state after the reset must be as follows:
81
+
82
+ * The Ethernet address is appropriately set to its default value (it is optional to allow changing this address, see [Section 3.3](#33-eth_get_hwadd-obtain-the-ethernet-address)).
83
+ * Networking is enabled. (See [Section 3.5](#35-eth_net_onoff-enable-or-disable-networking)).
84
+ * Received frames, if any, are discarded. Any frame transmission in process when the routine was called is aborted.
85
+ * Duplex mode is set to half-duplex, when it is possible (see [Section 3.6](#36-eth_duplex-configure-duplex-mode)).
86
+ * Reception filters are set to accept broadcast and small frames. Promiscuous mode is disabled. (See [Section 3.7](#37-eth_filters-configure-frame-reception-filters)).
87
+
88
+ ### 3.3. ETH_GET_HWADD: Obtain the Ethernet address
89
+
90
+ * Input:
91
+ * A = 2
92
+
93
+ * Output:
94
+ * L-H-E-D-C-B = Current Ethernet address
95
+
96
+ This routine obtains the current Ethernet address of the implementation. The address is mapped to registers HL, DE and BC in a way that makes it easy to store and retrieve it for Z80, which stores 16 bit values int little-endian format. For example, the address returned by this routine can be stored at address X with these instructions: LD (X),HL - LD (X+2),DE - LD (X+4),BC.
97
+
98
+ Ethernet addresses (also called MAC addresses) are unique for each physical card and are intended to never be changed after the card is manufactured. See [Appendix A](#appendix-a-ethernet-frame-formats).
99
+
100
+ If the implementation supports it, the hardware address can be changed by using the ETH_SET_HWADD routine (see [Section 3.12](#312-eth_set_hwadd-set-the-ethernet-address)).
101
+
102
+ ### 3.4. ETH_GET_NETSTAT: Obtain network connection status
103
+
104
+ * Input:
105
+ * A = 3
106
+
107
+ * Output:
108
+ * A = current network status
109
+ * 0 NOT connected to an active network
110
+ * 1 connected to an active network
111
+
112
+ This routine checks whether the underlying hardware is connected to an active network or not (in other words, if the Ethernet cable is appropriately plugged and there is carrier).
113
+
114
+ It is allowed to use loopback methods (that is, to send a frame and check if it is received back) to check the network connection status. Therefore, it may take a while to execute, so it is not advisable to invoke it too often.
115
+
116
+ ### 3.5. ETH_NET_ONOFF: Enable or disable networking
117
+
118
+ * Input:
119
+ * A = 4
120
+ * B = Action to perform:
121
+ * 0: Obtain current state only
122
+ * 1: Enable networking
123
+ * 2: Disable networking
124
+
125
+ * Output:
126
+ * A = State after routine execution:
127
+ * 1: Networking is enabled
128
+ * 2: Networking is disabled
129
+
130
+ This routine logically enables or disables networking activity. When disabled, no frames will be recevied (or received frames will be automatically discarded); the behavior when trying to send a frame with networking disabled is undefined.
131
+
132
+ When the underlying hardware offers ways to phisically disable networking (such as entering in low power mode or similar), these must be used. Otherwise, disabling must be done by software.
133
+
134
+ ### 3.6. ETH_DUPLEX: Configure duplex mode
135
+
136
+ * Input:
137
+ * A = 5
138
+ * B = action to perform:
139
+ * 0: Obtain current mode only
140
+ * 1: Set half-duplex mode
141
+ * 2: Set full-duplex mode
142
+
143
+ * Output:
144
+ * A = Mode after routine execution:
145
+ * 1: Currently half-duplex mode set
146
+ * 2: Currently full-duplex mode set
147
+ * 3: Current mode unknown or duplex mode does not apply
148
+
149
+ Offering the ability to change the duplex mode is optional. When not possible (because only one mode is supported, or because it is not possible to change the current mode by software), the routine must simply return the current mode, as if it were called with B=0.
150
+
151
+ When it is possible to change the duplex mode by software, the default mode (after a reset, see [Section 3.2](#32-eth_reset-reset-hardware)) should be the half- duplex mode.
152
+
153
+ The "Unknown or does not apply" mode is primarily intended for implementations that do not act on real Ethernet hardware. For these implementations, the concept of "duplex mode" may not make sense.
154
+
155
+ ### 3.7. ETH_FILTERS: Configure frame reception filters
156
+
157
+ * Input:
158
+ * A = 6
159
+ * B = Filter bitmask:
160
+ * Bit 7: Set to return current configuration only
161
+ * Bit 6: Reserved
162
+ * Bit 5: Reserved
163
+ * Bit 4: Set to enable promiscuous mode, reset do disable it
164
+ * Bit 3: Reserved
165
+ * Bit 2: Set to accept broadcast frames, reset to reject them
166
+ * Bit 1: Set to accept small frames (smaller than 64 bytes), reset to reject them
167
+ * Bit 0: Reserved
168
+
169
+ * Output:
170
+ * A = Filter configuration after execution (bitmask with same format as B at input)
171
+
172
+ This routine allows to set or to check the current frame reception filters. Frames whose destination Ethernet address matches the current address of the underlying hardware must always be accepted; these filters decide what to do with special frames.
173
+
174
+ When bit 7 of B is set, all other bits will be ignored, and the routine will simply return a bitmask with the current configuration, without modifying anything.
175
+
176
+ When bit 4 is set, promiscuous mode is enabled. In this mode, all received frames are enabled, regardless of their destination address. This mode is usually never enabled, except for special purposes such as network analysis.
177
+
178
+ When bit 2 is set, broadcast frames are accepted. These frames have a destination address of FF-FF-FF-FF-FF-FF, and are intended to be received by all hosts in the network. Broadcats frames are usually always accepted.
179
+
180
+ When bit 1 is set, small frames (frames smaller than 64 bytes) are accepted. These frames violate the Ethernet specification but may anyway contain useful information.
181
+
182
+ Reserved bits must be set to zero at input, and are always returned as zero at output. These bits may be used in future versions of the Ethernet API specification.
183
+
184
+ ### 3.8. ETH_IN_STATUS: Check for received frames availability
185
+
186
+ * Input:
187
+ * A = 7
188
+
189
+ * Output:
190
+ * A = availability of incoming frames:
191
+ * 0: No received frames available
192
+ * 1: At least one received frame is available
193
+ * BC = Size of the oldest available frame (only if A=1)
194
+ * HL = Bytes 12 and 13 of the oldest available frame (only if A=1)
195
+
196
+ This routine checks whether there are received frames available to be retrieved or not. When A=1 is returned, it means that there is at least one received frame available to be retrieved; there is no way to know how many frames are available.
197
+
198
+ When at least one frame is available, BC returns the total size of the oldest frame. This size includes the Ethernet header and data; it corresponds to the frame format outlined in Appendix A, which does not include the frame preamble nor the checksum.
199
+
200
+ When at least one frame is available, BC returns bytes 12 and 13 of the oldest frame. These bytes contain ether the frame size or the ether-type, depending of the frame type (Ethernet II or IEEE802.3). Since the frame data starts at a different boundary on each frame type, client software may use this information to decide where to retrieve the frame, so that the data boundary is always at the same memory address. This may ease frame data manipulation.
201
+
202
+ The oldest received frame can be retrieved using ETH_GET_FRAME, see [Section 3.9](#39-eth_get_frame-retrieve-the-oldest-received-frame).
203
+
204
+ ### 3.9. ETH_GET_FRAME: Retrieve the oldest received frame
205
+
206
+ * Input:
207
+ * A = 8
208
+ * HL = Destination address for the frame, or 0 to discard the frame
209
+
210
+ * Output:
211
+ * A = operation result:
212
+ * 0: frame has been retrieved or discarded
213
+ * 1: no received frames are available
214
+ * BC = Size of the retrieved frame (if A = 0)
215
+
216
+ This routine retrieves the oldest received frame (copies it to the specified memory address), and removes it from the implementation internal buffer (usually belonging to the underlying harwdare), so that when the routine is called again, the next received frame is obtained. Successive calls to this routine must return the received frames in the same order as they are received from the network.
217
+
218
+ The received frame will include the Ethernet header and data, it will not include the frame preamble nor checksum. The frame format will be one of the two formats outlined in Appendix A.
219
+
220
+ Implementations may not allow the destination address to be a page 1 address (in the range 4000h-7FFFh). Client software should not use this range as destination address when invoking this routine, in order to correctly interoperate with such implementations.
221
+
222
+ When the specified destination address is zero, the frame is not retrieved but just discarded. That is, it is removed from the implementation internal buffer but not copied to memory.
223
+
224
+ This specification does not impose a minimum size for the internal reception buffer, other than being big enough to hold one complete frame. But of course, the bigger the better, so that it can hold enough frames, thus minimizing the probability of losing frames. When this buffer is full, new frames must be discarded so that the oldest ones are preserved.
225
+
226
+ ### 3.10. ETH_SEND_FRAME: Send a frame
227
+
228
+ * Input:
229
+ * A = 9
230
+ * HL = Frame address in memory
231
+ * BC = Frame length
232
+ * D = Routine execution mode:
233
+ * 0: Synchronous
234
+ * 1: Asynchronous
235
+
236
+ * Output:
237
+ * A = operation result:
238
+ * 0: Frame sent, or transmission started
239
+ * 1: Invalid frame length
240
+ * 3: Carrier lost
241
+ * 4: Excessive collisions
242
+ * 5: Asyncrhonous mode not supported
243
+
244
+ This routine sends to the network the frame that the client software has composed in memory, at the address specified in HL. The frame format must be one of the two outlined in Appendix A; that is, the frame must be composed of Ethernet header (including the local Ethernet address, see [Section 3.3](#33-eth_get_hwadd-obtain-the-ethernet-address)) and data only, with no preamble nor checksum. (When there is real underlying Ethernet hardware, it is expected that the hardware itself will generate the checksum; otherwise, the implementation must generate it prior to sending the frame.)
245
+
246
+ Implementations may not allow the frame source address to be a page 1 address (in the range 4000h-7FFFh). Client software should not use this range as source address when invoking this routine, in order to correctly interoperate with such implementations.
247
+
248
+ Allowed frame lengths are 16 to 1514. If the frame is smaller than 64 bytes, the implementation must pad it with zeros up to 64 bytes (usually the underlying hardware will do it automatically).
249
+
250
+ All implementations must support the syncrhonous execution mode. In this mode, the routine will start the frame transmission; then will wait until transmission has finished (successfully or not) and will return the appropriate success or error code (in this mode, error code zero means "frame successfully sent").
251
+
252
+ Implementations may optionally support the asyncrhonous execution mode, and should indeed support it when there is real Ethernet hardware that handles the transmission independently of the Z80 code execution. In this mode, the routine initiates the transmission (unless frame length is invalid, in which case A=1 must be returned) and returns immediately with A=0 (meaning "frame transmission started"). Frame transmission status can then be ckeched by using ETH_OUT_STATUS (see [Section 3.11](#311-eth_out_status-check-frame-transmission-status)).
253
+
254
+ To check whether asynchronous mode is supported or not, try to send a dummy 16 byte frame (12 zero bytes for source and detination address and then FFFFh for the ether-type) in asyncrhonous mode, and check the return code: it will be 0 if asyncrhonous execution is supported, 5 otherwise.
255
+
256
+ ### 3.11. ETH_OUT_STATUS: Check frame transmission status
257
+
258
+ * Input: A = 10
259
+
260
+ * Output:
261
+ * A = operation result:
262
+ * 0: No frames were sent since last reset
263
+ * 1: Now transmitting
264
+ * 2: Transmission finished successfully
265
+ * 3: Carrier lost
266
+ * 4: Excessive collisions
267
+
268
+ This routine returns the state of the last frame send operation initiated by ETH_SEND_FRAME (see [Section 3.10](#310-eth_send_frame-send-a-frame)). It is intended for being used after an asyncronous execution of that routine, but will return valid information for syncrhonous executions as well.
269
+
270
+ In case of syncrhonous execution, this routine will return the same error code that ETH_SEND_FRAME returned, except that code 0 is converted to 2, and code 1 (invalid length) is not considered a failed transmission (since the routine returns without attempting the transmission).
271
+
272
+ The obtained information is persistent: successive executions of this routine will always return the same value until another frame is sent (or attempted to be sent) or the reset routine (see [Section 3.2](#32-eth_reset-reset-hardware)) is invoked.
273
+
274
+ ### 3.12. ETH_SET_HWADD: Set the Ethernet address
275
+
276
+ * Input:
277
+ * A = 11
278
+ * L-H-E-D-C-B = Ethernet address to set
279
+
280
+ * Output:
281
+ * L-H-E-D-C-B = Ethernet address after the routine execution
282
+
283
+ This routine sets the hardware address if the implementation supports it. When changing the address is not supported, the routine must do nothing and return the current address as if the ETH_GET_ADDRESS routine were called (see [Section 3.3](#33-eth_get_hwadd-obtain-the-ethernet-address)). Setting the address should not be allowed unless there is a good reason for it (for example, when it is not possible to store the address in non-volatile memory).
284
+
285
+ Ethernet addresses (also called MAC addresses) are unique for each physical card and are intended to never be changed after the card is manufactured. See [Appendix A](#appendix-a-ethernet-frame-formats).
286
+
287
+ ## Appendix A. Ethernet frame formats
288
+
289
+ In this appendix the Ethernet frame formats are described. This information is provided for reference only, and it is not exhaustive. More detailed information can be found on Internet.
290
+
291
+ There are two types of Ethernet frame: Ethernet II, and IEEE802.3 with SNAP extension (IEEE in short).
292
+
293
+ The Ethernet II frame format is as follows (one line is 32 bits):
294
+
295
+ ```
296
+ 0 1 2 3
297
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
298
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
299
+ | Ethernet address of receiver |
300
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
301
+ | E. Add. of receiver (cont.) | E. Add. of sender |
302
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303
+ | Ethernet address of sender (continues) |
304
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305
+ | Ether-Type | |
306
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
307
+ . .
308
+ . Ethernet frame data .
309
+ . .
310
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311
+ ```
312
+
313
+ The IEEE frame format is as follows:
314
+
315
+ ```
316
+ 0 1 2 3
317
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
318
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
319
+ | Ethernet address of receiver |
320
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
321
+ | E. Add. of receiver (cont.) | E. Add. of sender |
322
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
323
+ | Ethernet address of sender (continues) |
324
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
325
+ | Frame length | 170 | 170 |
326
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
327
+ | 3 | 0 | 0 | 0 |
328
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
329
+ | Ether-Type | |
330
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
331
+ . .
332
+ . Ethernet frame data .
333
+ . .
334
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
335
+ ```
336
+
337
+ The Ethernet addresses (also called MAC address), six bytes long, are unique for each card and are assigned in the factory. The address composed by all ones (six FFh bytes) is special: it is the broadcast address, and when it appears on the destination address field, it indicates that the frame is addressed to all the machines on the network, rather than to a given machine only.
338
+
339
+ Normal Ethernet addresses have the lowest bit of the first byte set to zero. When it is one, it is a multicast address (the frame is addressed to a group of computers).
340
+
341
+ The minimum size of an Ethernet frame (including all the headers) is 64 bytes. The maximum size is 1514 bytes.
342
+
343
+ The "Frame length" of IEEE frames counts from the first byte with value 170. That is, it equals the frame data part plus eight.
344
+
345
+ The "Ether-Type" field indicates the type of the frame being transported on the frame data part. The two most commonly used types are:
346
+
347
+ * 0800h: IP datagram
348
+ * 0806h: ARP frame
349
+
350
+ Both frame types, Ethernet II and IEEE, can exist mixed in the same network. To know whether an incoming frame is Ehternet II type or IEEE type, the 16 byte number placed at positions 12 and 13 of the frame must be checked:
351
+
352
+ * If the number is less than or equal to 1500, it is an IEEE frame (the number is the frame length).
353
+
354
+ * If the number is greater than 1500, it is an IEEE frame (the number is the frame Ether-Type). All the Ether-Type codes are greater than 1500.
355
+
356
+ When sending frames, they must be sent in Ethernet II type frames unless we know for sure that the machines on the network work exclusively with the IEEE format.
357
+
358
+ Note that the frame length and Ether-Type fields are stored in Big- Endian format, that is with the high byte first; contrarywise to MSX, that stores the 16 bit numbers in Little-Endian format, with the low byte first.
359
+
360
+ ## Appendix B. Acknowledgements
361
+
362
+ The original text version of this document was produced using xml2rfc v1.34 (of http://xml.resource.org/) from a source in RFC-2629 XML format.
363
+
364
+ ## Appendix C. Version history
365
+
366
+ * Version 1.1:
367
+
368
+ * The ETH_GET_HWADD routine now only gets the hardware address (see [Section 3.3](#33-eth_get_hwadd-obtain-the-ethernet-address))
369
+ * Added the ETH_SET_HWADD routine (see [Section 3.12](#312-eth_set_hwadd-set-the-ethernet-address))
@@ -0,0 +1,132 @@
1
+ # Introduction to MSX-UNAPI
2
+
3
+ This document introduces MSX-UNAPI, a standard procedure for defining, discovering and using new APIs (Application Program Interfaces) for MSX computers. For the detailed specification, please read [the MSX-UNAPI specification document](MSX%20UNAPI%20specification%201.1.md).
4
+
5
+ ## 1. Motivation
6
+
7
+ In the last years, several MSX hobbyists have developed various kinds of amateur hardware for MSX computers. Usually, each of these pieces of hardware comes with a ROM containing an API (Application Program Interface), which consists of a series of routines that allow developers to interact with the hardware.
8
+
9
+ As each device has its own API, devices are not interchangeable from the software point of view. For example, InterNestor Lite works only with the ethernet card ObsoNET, and it will not work with any other card developed in the future.
10
+
11
+ The MSX-UNAPI specification aims to solve this problem, by defining a set of rules for creating interchangeable API implementations.
12
+
13
+ ## 2. Key concepts
14
+
15
+ The complete MSX-UNAPI specification may seem complicated at first glance, but it relies on just a few key concepts, which are enumerated below.
16
+
17
+ **Note:** In the following text, the terms "API specification" and "API implementation" refer to API specifications and implementations that obey the rules of the MSX-UNAPI specification.
18
+
19
+ * An **API specification** is a set of routines for performing a set of concrete tasks. Each specification has a short alphanumeric identifier that serves as a signature to uniquely distinguish it from other specifications.
20
+
21
+ For example, an API specification for ethernet cards could have the identifier ETHERNET and be composed of three routines: send packet, receive packet and check network state.
22
+
23
+ * An **API implementation** is the realization in code of an API specification. There may be several implementation of the same API specification, and since all of them implement the same set of routines, they are interchangeable. Each implementation has a short name that serves to distinguish it from other implementations.
24
+
25
+ For example, "ObsoNET BIOS" and "DenyoNet BIOS" could be the names of two implementations of the API whose identifier is ETHERNET. A TCP/IP stack prepared to deal with the ETHERNET API could work with both implementations.
26
+
27
+ * The MSX-UNAPI specification provides a set of minimal rules that must be followed by all compliant API specifications and implementations. This is done to ease the development of software that make use of API implementations.
28
+
29
+ The main rules are: API implementation code must be placed in ROM, in mapped RAM or in page 3 RAM; there must be one single call point for all the API routines (routine number is passed in register A); and there must be one routine that informs about the API name and version. All of this is detailed in the MSX-UNAPI specification document.
30
+
31
+ * More than one implementation of a given API specification may be installed at the same time. The MSX extended BIOS mechanism is used to discover and locate the available implementations.
32
+
33
+ Usually, when more than one implementation is found, it does not matter which one is used to perform the tasks offered by the API specification. However, if necessary, implementations can be distinguished thanks to their names.
34
+
35
+ ## 3. Example
36
+
37
+ This example provides pseudo-code for an hypothetical TCP/IP stack that relies on the ETHERNET API to send and receive data. In the code, the names A, B, C, HL and DE refer to Z80 registers; other names refer to routines or variables. Semicolons (;) indicate that the rest of the line is a comment.
38
+
39
+ Please refer to [the MSX-UNAPI specification document](MSX%20UNAPI%20specification%201.1.md) for details about how to call API routines and extended BIOS, as well as Z80 registers usage.
40
+
41
+ PRINT "Welcome to this wonderful ETHERNET API aware TCP/IP stack!"
42
+ PRINT "Now I'm going to search for ETHERNET API implementations...
43
+
44
+ POKE &HF847,"ETHERNET"+0
45
+ A=0
46
+ B=0
47
+ DE=&H2222
48
+ CALL &HFFCA ; The EXTBIO hook
49
+
50
+ IF B=0 THEN
51
+ PRINT "Ooops!"
52
+ PRINT "I haven't found any ETHERNET API implementation!"
53
+ END
54
+ ENDIF
55
+
56
+ PRINT "I've found "+B+" implementations of the ETHERNET API!"
57
+ PRINT "I'll use implementation with index 1"
58
+
59
+ ; Obtain implementation location (address, slot and/or segment)
60
+ ; and as the first task, obtain its name and version
61
+
62
+ POKE &HF847,"ETHERNET"+0 ; Not necessary if memory not modified
63
+ A=1 ; The implementation index
64
+ DE=&H2222
65
+ CALL &HFFCA ; The EXTBIO hook
66
+ ApiSlot=A
67
+ ApiSegment=B
68
+ ApiEntry=HL
69
+
70
+ A=0 ; 0 is the index for the API information routine
71
+ CALL EXE_UNAPI
72
+ PRINT "The API name is: "+READ_UNAPI(HL)
73
+ PRINT "The API version is: "+B+"."+C
74
+
75
+ ; Now assume that per the ETHERNET API specification,
76
+ ; routine 3 returns A=1 if network is available or 0 otherwise
77
+
78
+ A=3
79
+ CALL EXE_UNAPI
80
+ IF A=0 THEN
81
+ PRINT "Ooops! No network!"
82
+ END
83
+ ENDIF
84
+
85
+ PRINT "Network OK! Let's internetwork!"
86
+ ; etc etc...
87
+
88
+
89
+ ;--- This routine calls the API routine whose index is passed in A
90
+
91
+ EXE_UNAPI:
92
+ IF ApiEntry>=&HC000 THEN
93
+ CALL ApiEntry
94
+ ELSE IF ApiSegment=&HFF THEN
95
+ CALL ApiEntry AT SLOT ApiSlot
96
+ ELSE
97
+ CALL ApiEntry AT SEGMENT ApiSegment AT SLOT ApiSlot
98
+ RETURN
99
+
100
+
101
+ ;--- This routine reads the API memory whose address
102
+ ;--- is passed as parameter, until a zero is found
103
+
104
+ READ_UNAPI(Address):
105
+ HL=Address
106
+ String=""
107
+ LOOP:
108
+ IF Address>=&HC000 THEN
109
+ A=PEEK(HL)
110
+ ELSE IF ApiSegment=&HFF THEN
111
+ A=READ (HL) AT SLOT ApiSlot
112
+ ELSE
113
+ A=READ (HL) AT SEGMENT ApiSegment AT SLOT ApiSlot
114
+ ENDIF
115
+ IF A<>0 THEN
116
+ String=String+A
117
+ HL=HL+1
118
+ GOTO LOOP
119
+ RETURN String
120
+
121
+ ## Appendix A. Acknowledgements
122
+
123
+ The original text version of this document was produced using xml2rfc v1.34 (of http://xml.resource.org/) from a source in RFC-2629 XML format.
124
+
125
+ ## Appendix B. Document version history
126
+
127
+ * Version 0.2: Done some minor changes proposed by Tanni, in order to clarify the text.
128
+
129
+
130
+
131
+
132
+