Changes

Jump to: navigation, search

PlayCity

4,092 bytes added, 21:48, 22 August 2023
/* Technical description */
[[File:PlayCity.jpg|thumb|320px|]]
==Introduction==
The PlayCity is a CPC expansion previously known as the CTC-AY.It has been released on April 2014 with these features:
* 6 audio channels sound with programmable frequency (stereo line out and speaker mono mix in).
* 4 counter/timer channels for programmable interrupt (including NMI).
* CRTC hardware CURSOR interrupt support.
* The LIGHT PEN/GUN connector.
 
==Technical description==
The board main feature is the Zilog Z80 Counter Timer Circuit, the best friend of the Zilog Z80 CPU.
The CTC is linked to the CPU to allow it to manage vectorized interrupt (IM2) and handling triggered events.
Programmers can only get benefit of that to save CPU time and make complex programs more easy to achieve.
I can only invite them to read the Zilog CTC data-sheet for more informations. (it's really easy to use)
 
Because the CPC expansion port have some interesting signals on it, it had been a shame to not use them.
* CTC channel 0 is a programable audio clock generator. i.e. allow to replay ST or ZX sound on a CPC using AUDIO pin.
* CTC channel 1 is linked to the CURSOR pin and triggered by the NMI pin. Allow accurate hi priority rasters effects.
* CTC channel 2 and 3 are linked together and offers 2x8bit or 1x16bit user purpose timer or counter.
 
ADDER is the ADDress decodER part of the board. It manage all the ICs.
Because ports are direct access to the hardware, it's really fast.
* CTC channels: #F880, 81, 82, 83
* Audio right: #F884, #F984
* Audio left: #F888, #F988
* Soft reset: #F8FF
 
At end, the LIGHTPEN pin is rooted to a 4 pins connector for plugging compatible hardware through an adapter.
==Hardware Installation==
== Light Pen/Gun connector ==
For making it easier to adapt Light Pens/Guns from other systems or new ones, we added a 4 pins -pin connector to the board. The connections are labeled in the board as VCC (+5V), TR (Trigger or D7), LS (Light Sensor) and GND. Trigger (TR) = Request via output to port &FBFE. Light Sensor (LS) = CRTC Light Pen input.
Making the system compatible with [[Amstrad_Magnum_Phaser|Amstrad Magnum Phaser]] games, the most accuracy light gun system for CPC.
==PlayCity coding tips==
Interesting tips or "magic tricks" using the board should be documented here. If the code is long, you must put in other wiki page and link it here.
 
===PlayCity detection===
We are going to use the NMI interrupt generator to check if our program is running in a CPC with a PlayCity board.
<pre>
; ---------------------------------------------------------------------------
; PlayCity check
; (c) 2013 SyX
; ---------------------------------------------------------------------------
 
; Constantes
CTC_TIM1 EQU $F881 ; Channel 1 (I: Cursor CRTC | O: NMI)
CTC_START_TIMER256 EQU %00110111
CTC_STOP_CHANNEL EQU %00000011
 
; ---------------------------------------------------------------------------
; NOTE: The lower ROM must be disabled before to run this code.
check_playcity
; Disable interrupts
DI
; Install NMI handler
LD A,$C3 ; JP $xxxx
LD HL,nmi_interrupt
LD ($0066),A
LD ($0067),HL
 
; Initialize playcity variable to 0
XOR A
LD (playcity),A
 
; Wait VBlank
LD B,$F5
.wait_vbl
IN A,(C)
RRA
JR NC,.wait_vbl
; Initialize CTC timer 1 (NMI generator)
LD HL,32 ; 32 scanlines
LD BC,CTC_TIM1
LD A,CTC_START_TIMER256
OUT (C),A ; Enable Timer
OUT (C),L ; Set new time constant
 
; Extra delay
LD IX,33 * 4 - 1 ; Wait 33 scanlines
CALL wait_scanlines_ix
LD A,(playcity)
OR A
JR NZ,.playcity_detected
; No PlayCity detected
.
.
.
 
.playcity_detected
.
.
.
 
; ---------------------------------------------------------------------------
nmi_interrupt
PUSH BC
PUSH AF
 
; Change playcity variable
LD A,$FF
LD (playcity),A
 
; Disable CTC timer 1 (NMI generator)
LD BC,CTC_TIM1
LD A,CTC_STOP_CHANNEL
OUT (C),A ; Disable Timer
 
POP AF
POP BC
EI
RETN
 
; ---------------------------------------------------------------------------
; Wait scanlines
; INPUT:
; IX: Scanlines to wait * 4 - 1
; ---------------------------------------------------------------------------
wait_scanlines_ix
DEFS 5,0 ; (5)
 
.loop_wait_scanlines_ix
DEFS 6 ; (6)
DEC IX ; (3)
LD A,IXH ; (2)
OR IXL ; (2)
JR NZ,.loop_wait_scanlines_ix ; (2/3)
; Total loop --> 16 * (IX - 1) + 15
RET ; (3)
; Total Routine --> 64 * SCANLINES
; ---------------------------------------------------------------------------
playcity
DEFS 1
</pre>
 
===PlayCity detection (alternative)===
Faster and shorter, but untested or not working on all CPC.
<pre>
;=========================
5,003
edits