SVI-328 serial port (SVI-805) code snippet inside

Post Reply
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

SVI-328 serial port (SVI-805) code snippet inside

Post by tschak909 »

Hey guys,

I had somebody give me a chunk of code that works with the 8250 based SVI-805 serial card for the SVI-3x8 systems:

Code: Select all

TTDATA        equ        28h                ; Data port of WD8250
TTIER        equ        TTDATA+1        ; Interrupt enable register
TTIDENT        equ        TTDATA+2        ; Interrupt ident register
TTLCR        equ        TTDATA+3        ; Line control register
TTMCR        equ        TTDATA+4        ; Modem control register
TTSTAT        equ        TTDATA+5        ; Line status register
TTMODST        equ        TTDATA+6        ; Modem status register
DLL        equ        TTDATA                ; Divisor latch low
DLH        equ        TTDATA+1        ; Divisor latch high
;
NIT232:
        xor        a                ; Burp 8250
        out        (TTSTAT), a
        ld        a, 0fh                ; Activate all modem control lines
        out        (TTMCR), a
        xor        a                ; Disable all interrupts
        out        (TTIER), a
        ld        a, 83h                ; Enable divisor latch
        out        (TTLCR), a
        ld        hl,(UPARMS+7)        ; Get baud rate
        ld        a, l                ; Send low first
        out        (DLL), a
        ld        a, h                ; And then high
        out        (DLH), a
        ld        a, 3                ; Select 8 data bits, 1 stop bit, no parity
        out        (TTLCR), a
        xor        a                ; Burp it again
        out        (TTSTAT), a

TTYSTI:
        in        a, (TTSTAT)        ; get status byte
        and        1                ; is RxRdy set?
        ret        z                ; nope, exit
        xor        a                ; yes, set FF and exit 
        dec        a
        ret
;
TTYIN:
        call        TTYSTI                ; get status
        jr        z, TTYIN        ; if not there yet
        in        a, (TTDATA)        ; else get data
        and        7fh                ; mask parity
        ret                        ; and return
;
TTYSTO:
        in        a, (TTSTAT)        ; get status byte
        and        20h                ; is TxRdy set?
        ret        z                ; nope, exit
        ld        a, (UPARMS+9)        ; is H/W H/S enabled?
        or        a
        jr        z, SETRDY        ; nope, go signal ready state
        in        a, (TTMODST)        ; else get modem status
        and        10h                ; look at CTS pin
        ret        z                ; exit if not ready
SETRDY:
        xor        a                ; else set FF and exit
        dec        a
        ret
;
TTYOUT:
        call        TTYSTO                ; get status
        jr        z, TTYOUT        ; if not ready yet
        ld        a, c                ; get character to send
        out        (TTDATA), a        ; send it out
        ret                        ; and exit

Code: Select all

TTYSTI - Get status
TTYIN - get byte
TTYSTO - for flow control
TTYOUT - send byte
-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

the baud rate divisors are on page 15 of the SVI-805 manual:
http://samdal.com/SVIDOCS/SVI805UsersManual.pdf

-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

That looks like it will works quite nicely. How do you hook up to the serial port in mame so that the code can be verified?
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

There isn't one...yet. I'm asking questions over in MAME to see what I would need to do to...hook one up. :) It's an 8250 hanging off the IO bus, so hopefully it shouldn't be too bad to add to the machine driver.

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Ah, actually, I'm blind as hell.

"The RS232 card is already implemented as a slot device, though you'll need to add it through a SV-60x expander. Adding "-exp sv601 -exp:sv601:0 sv805" to the command line is one way to do it."

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

and once set up, you can then add -ser null_modem -bitb localhost.25232 to e.g. hook up to a tcpser running on port 25232 with e.g.

tcpser -v 25232 -i "&K0" -s 2400 -t sSiI

(my fork of tcpser is here: http://github.com/tschak909/tcpser)

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

uparms is a user parameters variable that was used by the surrounding terminal program. How best to deal with this here?

-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

It's late so I won't be able to test it myself tonight.

However, I've pushed the above code mapped into the z88dk rs232 API. I've assumed that hardware flow control is always enabled which seems like a safer thing to do in anywise.
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Awesome! I'll see what I can test. :)

Meanwhile, I just received RS232 code from the Microbee people, for...the Microbee. ;) that'll be another thread.

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Yeah, something isn't quite right, putting or getting from serial device causes a hang.

Called mame with:

Code: Select all

./mame64.exe -window -resolution 1920x1080 svi328 -exp sv601 -exp:sv601:0 sv801 -exp:sv601:1 sv805 -exp:sv601:1:sv805:rs232 terminal -flop1 plato.svi
Image
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

It's probably put; it loops waiting for RTS. Hopefully I'll get a chance to try it out tonight.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Yes, it's the send. I think it's probably right though if there's nothing hooked up to the other end.

I can't get the options you gave above to work for me, here's my base line can you add the extra bits?

mame64 svi328 -exp sv601 -exp:sv601:1 sv801 -exp:sv601:2 sv805 -flop1 a.svi
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Try:

Code: Select all

mame64 svi328 -exp sv601 -exp:sv601:1 sv801 -exp:sv601:2 sv805 -exp:sv601:2:sv805:rs232 null_modem -bitb socket.localhost:25232 -flop1 a.svi
-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Thanks, yup, still not working!

Have you got a copy of the terminal program this code was taken from? It's almost like something isn't wired up properly somewhere. It looks like we fill up the the single byte buffer on the device but that byte just sits there so no further sending can be done.

If you've got it then at least we can verify that the mame options we're using are right.
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

I've run this by Roger, will see what comes back.

-Thom
rzs
New member
Posts: 3
Joined: Thu Nov 01, 2018 9:17 pm

Post by rzs »

The code is from the CPM BIOS for the 328 version 2.25

https://paste.ubuntu.com/p/3gGqBXTZcY/

Init is on line 153
com funtions start on line 695
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Ah great, thank you.

So weirdly, the code works under CP/M but doesn't when booted directly but I can't spot any code in the CP/M source that would affect that.

An interesting curiosity is that the 8080 source doesn't match up with the translated z80 code - the interrupt routine is different (z80 uses ex af,af, 8080 uses push af).
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

All sorted, the initialisation code was missing an out. Apologies for going round the houses.
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

All good, I'm just glad that this code is being folded in for the benefit of everyone. I'll continue to get RS232 code for every interface I can find...

-Thom
rzs
New member
Posts: 3
Joined: Thu Nov 01, 2018 9:17 pm

Post by rzs »

Where was the out missing from?
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I omitted the out (TTLCR),a so the baud rate wasn't being setup correctly.
Post Reply