MSXDISK 0.9 BETA: Virtual Floppy Disk Driver over JOYSTICK2 of MSX

Страница 8/11
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11

By NYYRIKKI

Enlighted (5741)

Аватар пользователя NYYRIKKI

30-03-2021, 05:11

Hi,

I took a bit closer look at this communication routine and I think I found an error from the 57600bps TXBITLOOP... You have accidentally calculated last DJNZ one clock short, so in total the loop is 2 clocks too long. This can be fixed by replacing the NOP/NOP by ie. CP (HL)

This part also made me wonder:

            INC HL              ;(7)  |
            DEC BC              ;(7)  |
            LD A,B              ;(5)  | (40)
            OR C                ;(5)  |
            JP NZ,RXSTARTBIT    ;(11) |

I think it should be slow enough even if reduced to:

            CPI                 ;(18)
            JP PE,RXSTARTBIT    ;(11)

By ocitygate

Expert (67)

Аватар пользователя ocitygate

30-03-2021, 15:57

Are you referring to this code?

        TXBITLOOP:

            NOP                 ;(5) ALIGNMENT  |
            NOP                 ;(5) ALIGNMENT  |
                                ;               |
            RRC C               ;(10)           |
                                ;               |
            LD A,E              ;(5) SET 0      |
            JR NC,TXBIT         ;(13/8)         |
            LD A,D              ;(5) SET 1      | (63)
                                ;               |
        TXBIT:                  ;               |
                                ;               |
            OUT (0xA1),A        ;(12)           |* -4 -3 -2 -1 0 +1 +2 +3
            DJNZ TXBITLOOP      ;(13/8)         |

I know its 1 clock cycle too long
At line:
OUT (0xA1),A ;(12) |* -4 -3 -2 -1 0 +1 +2 +3
-4 -3 -2 -1 0 +1 +2 +3 denote how many clock cycles advanced/delayed is the start of the bit

By NYYRIKKI

Enlighted (5741)

Аватар пользователя NYYRIKKI

30-03-2021, 16:49

ocitygate wrote:

Are you referring to this code?
I know its 1 clock cycle too long

Yes, but it is not 1 clock cycle too long, but 2 clock cycles too long due to fact that DJNZ is 14/9 cycles long, not 13/8 cycles long.

By ocitygate

Expert (67)

Аватар пользователя ocitygate

30-03-2021, 17:14

did you fix it?

By NYYRIKKI

Enlighted (5741)

Аватар пользователя NYYRIKKI

30-03-2021, 17:17

ocitygate wrote:

did you fix it?

Well, this is pure theory that NOP, NOP -> CP (HL) should fix the timing to exactly 62 cycles... Tested: No

By ocitygate

Expert (67)

Аватар пользователя ocitygate

30-03-2021, 17:21

Alright, thanks for pointing it out.
I'll revise the code and post it.

By RvS

Resident (49)

Аватар пользователя RvS

30-03-2021, 17:43

Ok, that is a detailed look.
I will check the routine. Nice catch!

By ocitygate

Expert (67)

Аватар пользователя ocitygate

30-03-2021, 17:50

RvS wrote:

Ok, that is a detailed look.
I will check the routine. Nice catch!

He's not talking about your routine.
I modified it a bit.

By NYYRIKKI

Enlighted (5741)

Аватар пользователя NYYRIKKI

30-03-2021, 18:58

@ocitygate

I was wondering, would you be interested to compile your server software to SVI-328 as well?
It is very close to MSX, but this computer does not have any reasonable transfer method ATM. The good thing is that this computer does not really have a disk ROM. The whole Disk BASIC & I/O routines are loaded from disk at boot, so modification is very easy and compatible with existing software. (I can handle that part)

It should be pretty straight forward modification to your code, but to give good idea of the task...
I would need two routines from server:
1) Send "*.BIN" (to load Disk BASIC or a game)

- Send 6-bytes from beginning of file (DW BEGIN, END, START)
- (Give me 0.1 ms)
- Send rest of the file

2) Send sectors

- Receive Track (byte)
- Receive Sector (byte)
- (Give me 0.1 ms)
- If track = 0 THEN
	- Send 128 bytes from file offset sector(=0-17) * 128
  ELSE
	- Send 256 bytes from file offset sector(=0-16) * 256 + track(=1-79) * 4352 - 2048
  Endif
- Repeat

By NYYRIKKI

Enlighted (5741)

Аватар пользователя NYYRIKKI

30-03-2021, 22:15

BTW this fixed timing seems pretty tight: (off by 0.45 cycles / byte)

TXSTARTBIT:

    PUSH BC             ;(12)     |
    LD C,(HL)           ;(8)      |
    LD B,8              ;(8)      |
                        ;         | (18+45=63)
    LD A,E              ;(5)      |
    OUT (094H),A        ;(12)* 0  |       |
                        ;                 |
    BIT 0,(HL)          ;(14)             |
                        ;                 |
TXBITLOOP:              ;                 |
                        ;                 | (62)
    CP (HL)             ;(8) ALIGNMENT  | |
                        ;               | |
    RRC C               ;(10)           | |
                        ;               | |
    LD A,E              ;(5) SET 0      | |
    JR NC,TXBIT         ;(13/8)         | |
    LD A,D              ;(5) SET 1      | |
                        ;               | 
TXBIT:                  ;               | (62)
                        ;               |
    OUT (094H),A        ;(12)           |
    DJNZ TXBITLOOP      ;(14/9)       | |
                        ;             |
TXENDBITLOOP:           ;             |
                        ;             |
    POP BC		;(11)         | (62)
    CP (HL)		;(8)          |
    DEC BC              ;(7)          |
                        ;             |
TXSTOPBIT:              ;             |
                        ;             |
    LD A,B              ;(5)          |
    OR C                ;(5)          |
    LD A,D              ;(5)          |
    OUT (094H),A        ;(12)* 0      |

TXNEXTBYTE:

    INC HL              ;(7)   |
    JP NZ,TXSTARTBIT    ;(11)  | (18+)
Страница 8/11
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11