--- title: "Reading the Joysticks" type: "article" slug: "reading-the-joysticks" url: "http://localhost/article/reading-the-joysticks/" markdown_url: "http://localhost/article/reading-the-joysticks.md" published_at: "2022-10-07T12:22:34+00:00" modified_at: "2026-07-30T21:45:48+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "The two joysticks are controlled via Register 14 (I/O Port A) of the Programmable Sound Generator Chip (see Sections 2.1.6 and 2.1.7 of the TS2068 Technical Manual). Address and data are passed via Ports 0F5H and 0F6H respectively. The joysticks are read by first addressing Register l4 in the PSG by writing a 14 (0EH)…" category: - name: "CATS Newsletter" slug: "cats-newsletter" taxonomy: "category" url: "http://localhost/category/periodicals/cats-newsletter/" post_tag: - name: "Best of Timex/Sinclair 2068 Articles and Documents" slug: "ts2068best" taxonomy: "post_tag" url: "http://localhost/tag/ts2068best/" - name: "Reference" slug: "reference" taxonomy: "post_tag" url: "http://localhost/tag/reference/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" - name: "Tutorial" slug: "tutorial" taxonomy: "post_tag" url: "http://localhost/tag/tutorial/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" publication_r: id: 35941 title: "CATS Newsletter" type: "periodical" url: "http://localhost/periodical/cats-newsletter/" volume: "2" issue: "10" issues_articles: - id: 39598 title: "CATS v2 n10" type: "issue" url: "http://localhost/issue/cats-v2-n10/" pages: "13" pubdate: "January - February 1985" archive_link: false gallery: - url: "http://localhost/wp-content/uploads/2022/10/CATS-v2-n10-Jan-Feb-1985_0012.jpg" --- # Reading the Joysticks The two joysticks are controlled via Register 14 (I/O Port A) of the Programmable Sound Generator Chip (see Sections 2.1.6 and 2.1.7 of the [TS2068 Technical Manual](http://localhost/book/timex-2068-technical-manual/)). Address and data are passed via Ports 0F5H and 0F6H respectively. The joysticks are read by first addressing Register l4 in the PSG by writing a 14 (0EH) to Port OFSH. The data is then read by executing an IN from Port 0F6H, having the port address in Z80 Register C and the joystick (player) number in Register B (number = 1 or 2). Note that PSG Register 7, Bit 6 is assumed to be zero, enabling I/O Port A for input. If you ever use I/O Port A for output (R7,B6=1), you will want to clear Bit 6 prior to any input operation. #### Sample routine ``` GETJOY LD A,0E Load A=14 OUT A,(0F5) Address the joystick port LD B,playerno LD C,0F6 Data port address to C IN A,(C) Joystick data to A CPL Complement to High Active AND 8F Get significant bits ``` The data read is LOW ACTIVE, i.e. all bits = 1 (byte=FFH) when the stick is at center and the button is not depressed. The figure below shows the interpretation of the data byte.