Questions, aren't they the fuel that drives us humans?
----
I don't know from where to start, because I must return to some facts that I explained on the first commentary of this thread.
I think that the Midi interface that has arrived to our hands after so long time was made for the cartridge port for one very good reason. It was always an underused expansion port, out of being the place to put the necessary Basic Rom cartridge.
Probably the main reason for the unknown Jefrey(the name of the Rom writer and probably real developer) was to offer an interface that could be connected to all Enterprises, independently of the other expansions connected at the right side of the computer. The same objective than guided Szörg to put the SD reader there.
But it is a very limited port to put devices, because the signals that arrive to it are oriented only to manage memory. This problem has been excellently solved in the case of the SD reader, using a memory zone as the interchange gate to the SD content.
On the Midi interface they did some similar, the two necessary ports where paginated on memory positions BFF8 and BFF9, on segment 7 put on page 03. The Rom is 32KB wide, and is placed on the 06 and 07 segments, allowing the cartridge to still hold copies of the language Rom on 04 and Basic Rom on 05 segments.
I have found that almost all Midi interfaces of that era made for MSX, BBC, CPC, PCW, Spectrum, used the same UART chip, the
MC68B50. This chip doesn't have internally a lot of baud-rates to select, only 3 but related to the external oscillator used(1:1, 1:16, and 1:64). The 3 variants of the chip are the 1, 1.5 and 2Mhz versions, and the several Midi interface makers always selected the MC68B50 because its 2MH oscillator frequency, on the third selection, gives exactly the Midi baud-rate: 2.000.000/64=31250. Then only remains to select the serial protocol, 8bit and 1 stop bit and the chip has been configured.
It has 4 x 8 bit registers, Control(write), Status(read), Transmit Data(write) and Receive Data(read), and usually the interface makers joint all on only 2 ports, Control/Status and Data. Control is only used for initialisation, and is where we define the baud-rate and serial protocol.
[ Guests cannot view attachments ]
Bits 5, 6 and 7 are used for interrupts, not applicable on the Cartridge Bus. They will go as Zeros.
Then you can see that the initialisation is well defined, first we reset the chip writing 03h(00000011b) on the Control register, and then we write 16h(00010110d, 22d), this is, select 1:64 frequency and 8bit word with 1 stop bit.
Now, let's see what happens on the ScoreTrack Rom( I know the position because it was where IstvanV modified the Rom to work on the emulator):
*C146 32 F8 BF LD (BFF8), A ; A arrives here with 00000111, perfect to reset the chip
C149 3E 16 LD A, 16h ; 00010110 sets 1:64 frequency, 8 bit, 1 stop bit
C14B 32 F8 BF LD (BFF8), A
Not needing any control except erasing the emulator Midi buffers, IstvanV modified it as this:
*C146 00 NOP
C147 00 NOP
C148 00 NOP
C149 00 NOP
C14A 00 NOP
C14B AF XOR A
C14C D3 F6 OUT (F6), A ; a Zero clears out buffer
To transmit data, the chip has the Status register, that has to be watched by the processor to know when there is data to receive or when it can send. The Receive register is the bit 0, and the Send register is bit 1. The rest of bits are not important here.
On the ScoreTrack Rom there is only Midi OUT because the program is unfinished:
*DCB6 3A F8 BF LD A, (BFF8)
DCB9 CB 4F BIT 1, A ; bit 1 marks if the data has been send
DCBB 28 F9 JR Z, DCB6
DCBD F1 POP AF
DCBE 32 F9 BF LD (BFF9), A ;write the Midi OUT buffer
IstvanV modified it as this:
*DCB6 00 NOP
DCB7 DB F6 IN A, (F6)
DCB9 CB 77 BIT 6, A ; Send bit
DCBB 20 FA JR NZ, DCB7
DCBD F1 POP AF
DCBE D3 F7 OUT (F7), A ;Midi OUT
DCC0 00 NOP
And then, here come my questions:
Why has made IstvanV so drastic changes to the code? Where they necessary? Some of you can contact him?
Because, we have to decide NOW if we must follow his changes, and remain compatible with the EP emulator and the Midi utilities, or on the contrary, emulate correctly the MC68B50, that will allow further development of the ScoreTrack program, share the chip emulation on the other computers that are supported by the SF3, and probably we will have the opportunity to see easier sequencer conversions from other platforms that use the same chip, like CPC, even MSX.
Edit: if not evident, I want to mark the things that have been changed and apply or not apply to a good MC68B50 emulation:
-He has substituted the memory paginated ports for real unused ports. Good.
-Instead of the sequence 03h,16h written on the Control register for the chip initialisation he has opted to only write a Zero. Bad.
-On the Status byte, the Receive and Transmit bits have been changed from 0 and 1 bits to the 7 and 6 bits. Bad.
-The values of the bits inside the status byte has been negated, as you can see on the conditional jump. Bad.