Close

Joystick

A project log for The PCW Project

Doing things with an Amstrad PCW

james-otsJames Ots 10/10/2017 at 20:510 Comments

Today I was looking up how the PCW's memory management works, when I came across information about PCW joystick ports in John Elliott's very useful PCW Hardware document. And I remembered that I have a joystick which someone gave me, which I've never used. It seemed like it would be the perfect thing to add to my PCW to test out some really basic CPLD code.

A PCW joystick is very simple — it's pretty much just a bunch of microswitches which connect one of the output pins to ground when the joystick moves in the appropriate direction, or the fire button is pressed. So you just need to add pull-up resistors to each of the outputs and feed them into the CPLD. In the CPLD this code is sufficient to implement a Kempston joystick interface:

if clk4'event and clk4 = '1' then
   if iorq_n = '0' and rd_n = '0' and a(7 downto 0) = "10011111" then
      d(7 downto 0) <= "000" & (not joy_fire) & (not joy_down)
         & (not joy_up) & (not joy_left) & (not joy_right);
   else
      d(7 downto 0) <= "ZZZZZZZZ";
   end if;
end if;

And it works. I just played Head over Heels with a joystick for the first time. To be honest, I think I prefer using the keyboard though!

As you can see, the setup I have so far isn't pretty. The CPLD board is sitting on a plastic bag to make sure I don't short it out on anything. The video circuit is at the top right, with the red and black wires jammed into the S-Video socket on the Video Converter. I also had to improvise a socket for the joystick connector. But hey, it all works for now, and I can make a PCB later (or put it on stripboard).

Discussions