ZX81 I/O Ports

Discussions about Sinclair ZX80 and ZX81 Hardware
Post Reply
User avatar
1024MAK
Posts: 5534
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

ZX81 I/O Ports

Post by 1024MAK »

Okay, in the hunt for information on which (Z80) input/output ports are used by the ZX81 I have found these threads:
ts1000 I/O - Ports and http://www.sinclairzxworld.com/viewtopic.php?p=3714

But is there a list of the ports used by peripherals and add-ons?

EDIT:
Here is draft list as a spreadsheet file:
ZX81 IO Ports draft 01.xls.zip
(4.51 KiB) Downloaded 568 times
and here is the same file but with the hex and binary numbers as text (instead of using DEC2HEX and DEC2BIN functions):
ZX81 IO Ports draft 01 static.xls.zip
(4.23 KiB) Downloaded 487 times
Mark

Tags: input output port addresses
Last edited by 1024MAK on Thu May 24, 2012 12:07 pm, edited 3 times in total.
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
sirmorris
Posts: 2812
Joined: Thu May 08, 2008 5:45 pm

Re: ZX81 I/O Ports

Post by sirmorris »

I generally use the EO code as a reference ... but even just this morning I found it was missing things :)

Code: Select all

void zx81_writeport(int Address, int Data, int *tstates)
{
        if ((spectrum.HDType==HDPITERSCF) && ((Address&0x3b)==0x2b))
                ATA_WriteRegister(((Address>>2)&1) | ((Address>>5)&6), Data);

        switch(Address&255)
        {
        case 0x01:
                configbyte=Data;
                break;

        case 0x07:
                ZXpand_IO_Write(zxpand, Address>>8, Data);
                break;

        case 0x0f:
        case 0x1f:
                if (zx81.aytype==AY_TYPE_ZONX)
                        sound_ay_write(SelectAYReg, Data);
                break;

        case 0x3f:
                if (zx81.aytype==AY_TYPE_FULLER)
                        SelectAYReg=Data&15;

        case 0x5f:
                if (zx81.aytype==AY_TYPE_FULLER)
                        sound_ay_write(SelectAYReg, Data);
                break;

        case 0x73:
                if (zx81.ts2050) d8251writeDATA(Data);
                break;

        case 0x77:
                if (zx81.ts2050) d8251writeCTRL(Data);
                break;

        case 0xbf:
                if (spectrum.floppytype==FLOPPYZX1541)
                        ZX1541PORT=Data;

                        Data>>=2;

                        if (Data&1) IECAssertReset(0); else IECReleaseReset(0);
                        if (Data&2) IECAssertATN(0); else IECReleaseATN(0);
                        if (Data&4) IECAssertClock(0); else IECReleaseClock(0);
                        if (Data&8) IECAssertData(0); else IECReleaseData(0);
                break;

        case 0xc7:
                d8255_write(D8255PRTA,Data);
                break;

        case 0xcf:
                if (zx81.aytype==AY_TYPE_ZONX) SelectAYReg=Data&15;
                else d8255_write(D8255PRTB,Data);
                break;

        case 0xd7:
                d8255_write(D8255PRTC,Data);
                break;

        case 0xdf:
                if (zx81.aytype==AY_TYPE_ACE) sound_ay_write(SelectAYReg, Data);
                if (zx81.aytype==AY_TYPE_ZONX) SelectAYReg=Data&15;
                break;

        case 0xdd:
                if (zx81.aytype==AY_TYPE_ACE) SelectAYReg=Data;
                break;

        case 0xfb:
                if (zx81.zxprinter) ZXPrinterWritePort(Data);
                break;

        case 0xfd:
                if (zx81.machine==MACHINEZX80) break;
                LastInstruction = LASTINSTOUTFD;
                break;

        case 0xfe:
                if (zx81.machine==MACHINEZX80) break;
                LastInstruction = LASTINSTOUTFE;
                break;
        default:
                break;
        }

        if (!LastInstruction) LastInstruction=LASTINSTOUTFF;
        if ((zx81.machine != MACHINELAMBDA) && zx81.vsyncsound)
                sound_beeper(1);
}

BYTE zx81_readport(int Address, int *tstates)
{
        static int beeper;

        setborder=1;

        if (!(Address&1))
        {
                BYTE keyb, data=0;
                int i;
                if ((zx81.machine!=MACHINELAMBDA) && zx81.vsyncsound)
                        sound_beeper(0);
                if (zx81.NTSC) data|=64;
                if (!GetEarState()) data |= 128;

                if (z80.pc.w > 0x2000)
                {
                        int n = 0;
                        ++n;
                }

                LastInstruction=LASTINSTINFE;
                keyb=Address/256;
                for(i=0; i<8; i++)
                {
                        if (! (keyb & (1<<i)) ) data |= ZXKeyboard[i];
                }

                return(~data);
        }
        else
        {
                if ((spectrum.HDType==HDPITERSCF || spectrum.HDType==HDPITERS8B) && ((Address&0x3b)==0x2b))
                        return(ATA_ReadRegister(((Address>>2)&1) | ((Address>>5)&6)));

                switch(Address&255)
                {
                case 0x01:
                {
                        char *config;

                        config=(char *)(&zx81);
                        return(config[configbyte]);
                }

                case 0x7:
                        if (zxpand)
                        {
                                return ZXpand_IO_Read(zxpand, Address>>8);
                        }
                        else return 255;

                case 0x41:
                        if (spectrum.floppytype==FLOPPYLARKEN81) return(0xfe);
                        break;

                case 0x43:
                        if (spectrum.floppytype==FLOPPYLARKEN81) return(0x1e);
                        break;

                case 0x45:
                        if (spectrum.floppytype==FLOPPYLARKEN81) return(0x26);
                        break;

                case 0x5f:
                        if (zx81.truehires==HIRESMEMOTECH) MemotechMode=(Address>>8);
                        return(255);

                case 0x73:
                        if (zx81.ts2050) return(d8251readDATA());

                case 0x77:
                        if (zx81.ts2050) return(d8251readCTRL());

                case 0xbf:
                        if (spectrum.floppytype==FLOPPYZX1541)
                        {
                                int a = ZX1541PORT & 3;

                                if (!IECIsReset()) a |= 16;
                                if (!IECIsATN()) a |= 32;
                                if (!IECIsClock()) a |= 64;
                                if (!IECIsData()) a |= 128;
                                return(a);
                        }

                case 0xdd:
                        if (zx81.aytype==AY_TYPE_ACE)
                                return(sound_ay_read(SelectAYReg));

                case 0xcf:
                case 0xdf:
                        if (zx81.aytype==AY_TYPE_ZONX)
                                return(sound_ay_read(SelectAYReg));

                case 0xf5:
                        beeper = 1-beeper;
                        if ((zx81.machine==MACHINELAMBDA) && zx81.vsyncsound)
                                sound_beeper(beeper);
                        return(255);
                case 0xfb:
                        if (zx81.zxprinter) return(ZXPrinterReadPort());
                default:
                        break;
                }
        }
        return(255);
}

sascha2000
Posts: 57
Joined: Fri Jul 22, 2011 2:13 pm

Re: ZX81 I/O Ports

Post by sascha2000 »

Hello,

from Siggi I got this:

Code: Select all

   
 IO-MAP

    CS0:
    $07   ZXPAND
    $17   
    $0F   MMC-IF Card Select,  ZON-X81 (Data-Write)
    $1F   MMC-IF PIPO,  ZON-X81-Clone (Data-Write)

    CS1:
    $27   8255 Port A
    $37   8255 Port C
    $2F   8255 Port B
    $3F   8255 Command (WO!)

    CS2:   ("PIO2")
    $47   PIO Port A
    $57   PIO Command A
    $4F   PIO Port B
    $5F   PIO Command B

    CS3:
    $67   (Centronics-Printerport)
    $77   RAMDISK Latch (48k)
    $6F   Centronics-Printerport
    $7F   EEPROM-Latch (8k)

    CS4:
    $87   SIO Port A
    $97   SIO Command A
    $8F   SIO Port B
    $9F   SIO Command B

    CS5:
    $A7   CTC 0
    $B7   CTC 1
    $AF   CTC 2
    $BF   CTC 3

    CS6:   ("PIO3")
    $C7   (PIO Port A)
    $D7   (PIO Command A)
    $CF   (PIO Port B), ZON-X81 (Latch, Data-Read)
    $DF   (PIO Command B), ZON-X81-Clone (Latch, Data-Read)

    CS7:
    $E7   
    $F7   
    $EF   
    $FF   ROM: Zeilensync


And this Link:

http://www.fischerkai.de/zxteam/multi_d.htm

Regards
Sascha
User avatar
1024MAK
Posts: 5534
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: ZX81 I/O Ports

Post by 1024MAK »

Thank you Sascha and sirmorris :D

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
1024MAK
Posts: 5534
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: ZX81 I/O Ports

Post by 1024MAK »

I have added a draft list as a spreadsheet file to the first post :D viewtopic.php?f=7&t=861#p8529

If (when) you have any additions or amendments, just poke me and I will update it :mrgreen:

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX81 I/O Ports

Post by PokeMon »

Unfortunately your formulas DEC2HEX and DEC2BIN are not working in my Excel Sheet.
Can not find them in "Functions".
I use MS Excel 2003.
8-)
User avatar
1024MAK
Posts: 5534
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: ZX81 I/O Ports

Post by 1024MAK »

PokeMon wrote:Unfortunately your formulas DEC2HEX and DEC2BIN are not working in my Excel Sheet.
Can not find them in "Functions".
I use MS Excel 2003.
8-)
That's not good :(
The file was generated using OpenOffice.org Spreadsheet and then saved as a XP Excel file.
OpenOffice.org is available for Windows and Linux systems and is free :D
I have just tried generating an older format Excel file and indeed the conversion functions are not present :evil:

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX81 I/O Ports

Post by PokeMon »

You could copy the values (not function) inside the table in other columns and copy back.
That would be compatible because then it's only TEXT.
So not just paste, use paste "content" without formula.
;)
User avatar
1024MAK
Posts: 5534
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: ZX81 I/O Ports

Post by 1024MAK »

PokeMon wrote:You could copy the values (not function) inside the table in other columns and copy back.
That would be compatible because then it's only TEXT.
So not just paste, use paste "content" without formula.
;)
Done!
See extra file in the first post :D

Also don't know if this helps: http://office.microsoft.com/en-us/excel ... 09054.aspx

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: ZX81 I/O Ports

Post by PokeMon »

1024MAK wrote: Done!
See extra file in the first post :D
Perfect ! 8-)

1024MAK wrote: Also don't know if this helps: http://office.microsoft.com/en-us/excel ... 09054.aspx
I think this would help as well but is extra work. As list is static, I found it better to have the static values in Excel sheet. ;)
Post Reply