ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Discussions about Sinclair ZX80 and ZX81 Hardware
tdg8934
Posts: 304
Joined: Mon Sep 23, 2013 6:10 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by tdg8934 »

I think what I'm going to do next is to take my working output LEDs and try them on the Port A tonight and see if they work that would tell me if the port register address of $CF is correct as it was on Port B.
tdg8934
Posts: 304
Joined: Mon Sep 23, 2013 6:10 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by tdg8934 »

I found this information online here:http://nocash.emubase.de/zxdocs.htm

ZX80/ZX81 I/O Map
I/O Ports xx0Fh.W PSG data (Bi-Pak ZON-X81 Sound)


Accidently Used I/O Port Mirrors
CFh.W PSG index (Bi-Pak ZON-X81 Sound) (used accidently in Bi-Pak manual)
CFh.W PSG index (Bi-Pak ZON-X81 Sound) (used by Lunar 10)


ZON-X81 Sound (Bi-Pak)Contains a PSG sound chip, built-in speaker with manual volume control. There seems to be no user I/O port.
F = 1625000 Hz / 16 / nnn

Parameters are poke'd to RAM, and then forwarded via USR call.
Uses "1 REM YYPEEK TO YYPEEK ?TAN"
OUT (CFh or DFh),A ;index
OUT (0Fh),A ;data (w)

The manual is unclear about the "index" port:
BASIC example suggests "TO" token = port DFh.
But ASM example suggests port CFh.

Maybe both are working. Anyways, the recommended address would be DFh (assuming that the manual was mainly addressed to BASIC programmers, and the ASM example being only a confused side note). The technical specs in the french "Interface Sonore" manual uses DFh, too).
Note: The Spectrum version uses ports FFh and 7Fh, maybe these do work on ZX81, too (though under BASIC, 7Fh cannot be entered via keyboard, which may explain why the manual used other values)
Supported by
Cosmic (brazilian magazine Revista Micro Sistemas, Oct/1986)
Lunar 10 (brazilian magazine Revista Micro Sistemas, Nov/1986)

I/O Ports of known PSG devices
Model Index.W Data.W Data.R Chip Year
Bi-Pak ZON X81 Soundbox (ZX81) xxDFh xx0Fh N/A? 891x 198x




0Eh = I/O port A (with external pinouts on AY-3-8910 and AY-3-8912)
0Fh = I/O port B (with external pinouts on AY-3-8910 only)
These are two general purpose 8bit I/O ports (direction can be set via register 7). Port A exists on both AY-3-8910 and AY-3-8912 chips. Port B exists on AY-3-8910 only (or actually, it does internally exist even on the smaller AY-3-8912, but it doesn't have external pinouts).


Seems to have inconsistencys about what to use somewhat.

Tim
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by sirmorris »

$0f/$1f and $cf/$df are valid port access addresses for ZXpand-AY. The hardware recognises both. This is because there are a number of other sound boards out there which used that port assignment. This means we can remain compatible.

HTH!
C
tdg8934
Posts: 304
Joined: Mon Sep 23, 2013 6:10 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by tdg8934 »

I have been able to get both Port A and B (Registers 14 and 15) to work on writing to the "output" trying both $0F or $1F and $CF or $DF. I am still at a loss for reading the "input" on either Port A or B.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by sirmorris »

If you can post your code I'll be happy to take a look.

C
tdg8934
Posts: 304
Joined: Mon Sep 23, 2013 6:10 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by tdg8934 »

Thank you Sir Morris.

In gathering and testing these files again this morning it was noted that register 7 must have both Ports A & B set for output (i.e. $FF only so $7F or $BF doesn't work when looking at registers 14 and 15).

Code: Select all

LD A,07 //Register 07 is selected
OUT ($CF),A //Selected register is sent OUT to port address $CF
//OUT ($DF),A //Selected register is sent OUT to port address $DF

LD A,$FF //1111 1111 Output port  B, Output port A, All noise and tones off
// DOES NOT WORK - LD A,$7F //0111 1111 Input port  B, Output port A, All noise and tones off

OUT ($0F),A //Contents of selected register is sent OUT to port address $0F
//OUT ($1F),A //Contents of selected register is sent OUT to port address $1F

LD A,14 //Register 14 is selected for Output port A with LEDS / resistors
//LD A,15 //Register 15 is selected for Output port B
OUT ($CF),A //Selected register is sent OUT to port address $CF
//OUT ($DF),A //Selected register is sent OUT to port address $DF

LD A,$FF //1111 1111 Output port all ON
OUT ($0F),A //Contents of selected register is sent OUT to port address $0F
//OUT ($1F),A //Contents of selected register is sent OUT to port address $1F
RET                   
2013-10-31_06-46-52-AM.jpg
2013-10-31_06-46-52-AM.jpg (21.99 KiB) Viewed 3116 times
I'm running late for work now. I will try to post some non working INPUT code tonight or tomorrow.

But for this code...why do I have to select both Ports B AND A as Outputs (i.e. $FF) to get the program to work?

Keep in mind that changing the code to allow for Port B output on Register 15 also works (uncomment LD A,15 line and comment LD A,14 line).
Last edited by tdg8934 on Thu Oct 31, 2013 5:05 pm, edited 1 time in total.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by sirmorris »

Oh yes, I now remember something quite important. The register index values on the AY data sheet are expressed in octal. :? This rarely helps anyone. So. When you see register 10 on the data sheet, it means register 8 decimal.

Another thing about the data sheet - many of the control bits are expressed as negative logic. Negative logic tends to scramble peoples' brains. The top 2 bits of register 7 are effectively the _direction_ bits for the IO ports. Bit 7 for port A and bit 6 for port B. They are designated as out/not in, meaning that you write 1 to make the relevant port an output port. It helps to think of it as the 'output enable' bits, rather than 'not input enable' as the data sheet puts it. Ditto think of the remaining bits as disable bits for tone and noise.

%00111111 to AY register 7 will silence the chip, and make both ports A and B inputs.
%10111111 ... will silence the chip, and make A output, B input.
%01111111 ... " " , and make A input, B output.
%11111111 ... " " , and make both outputs.

IO port addresses $CF and $DF both control register select. $0F/$1F are the data write ports. Now this is where things get interesting. The ZonX board didn't enable reading back from the ports so there's no prior art around how to get the data back from the chip when in input mode. At least none that I could find. The emulator EightyOne was generally my go-to source for all information zeddy, and this didn't list any support for input so I made it up :D I guess that makes me a de-facto standard bearer :lol:

Due to the way that the AY chip is driven on the bus - and my GAL logic implementation - it meant that I couldn't use the data IO port addresses for the IN(). So I went for port address $ef instead.

So to set up port A as input and read its content you do the following:

Code: Select all

  ld  a,$07
  out ($cf),a    ; select register 7 to receive data
  ld  a,$7f
  out ($0f),a    ; set port A as an input

  ; now to read the port - result in A

  ld  a,$0e      ; 14 decimal, 16 *octal* ;)
  out ($cf),a    ; select register 14
  in  a,($ef)    ; read from it
And for port B:

Code: Select all

  ld  a,$07
  out ($cf),a    ; select register 7 to receive data
  ld  a,$bf
  out ($0f),a    ; set port B as an input

  ; now to read the port - result in A

  ld  a,$0f      ; 15 decimal, 17 *octal* ;)
  out ($cf),a    ; select register 15
  in  a,($ef)    ; read from it

I hope this helps!

C
tdg8934
Posts: 304
Joined: Mon Sep 23, 2013 6:10 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by tdg8934 »

Thank you Sir Morris!

I have attached the datasheet I have and it says under the Register table that they are in Hexidecimal notation. I saw nothing about octal. Perhaps you have a different one.

I also see in your INPUT code examples that you are using LD A,$7F for setting the I/O direction having output A and are using LD A,$BF for setting the I/O direction having output B. My previous posting stated it did not work for outputs and assuming as much for inputs as I had to use LD A,$FF for setting the I/O direction having BOTH ouput A and output B. However, I will try again tonight or most likely tomorrow.
Due to the way that the AY chip is driven on the bus - and my GAL logic implementation - it meant that I couldn't use the data IO port addresses for the IN(). So I went for port address $ef instead.
Now we know where the $EF came from. Thanks! The Mr.X Sound Board used $CF for input so this is where I saw inconsistency.

I'll try again with the outputs first to make sure I can use $7F and $BF before I move onto inputs using the same.

Thanks,

Tim



The
Attachments
YM2149.pdf
(766.19 KiB) Downloaded 137 times
User avatar
1024MAK
Posts: 5131
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by 1024MAK »

sirmorris wrote:IO port addresses $CF and $DF both control register select. $0F/$1F are the data write ports. Now this is where things get interesting. The ZonX board didn't enable reading back from the ports so there's no prior art around how to get the data back from the chip when in input mode. At least none that I could find. The emulator EightyOne was generally my go-to source for all information zeddy, and this didn't list any support for input so I made it up :D I guess that makes me a de-facto standard bearer :lol:

Due to the way that the AY chip is driven on the bus - and my GAL logic implementation - it meant that I couldn't use the data IO port addresses for the IN(). So I went for port address $ef instead.
Ahh, in most other computer systems (for example, the ZX Spectrum 128), the control port address is used for reads.

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

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: ZXpand-AY Sound Module (Two 8 bit I/O ports control)

Post by sirmorris »

I made a slight error when I was planning ZXpand and this meant that the AY board was slightly more complex than it needed to be, and that the logic limitations in the GAL dictated the input address :oops:

Ah well, it still works eh :D
Post Reply