Changes

Jump to: navigation, search

PlayCity

2,910 bytes added, 14:33, 13 July 2014
'''Informations''': The rows without a CTC Val are not tested. It may be needed to configure the CTC channel 0 with "falling edge" instead of
"rising edges".
==More Coding Examples==
Interesting tricks using the board should be docummented 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 * (IY - 1) + 15
RET ; (3)
; Total Routine --> 64 * SCANLINES
; ---------------------------------------------------------------------------
playcity
DEFS 1
</pre>
==Downloads==
In [[File:playcity_examples.zip]], you will find more examples with full sources of using the CTC, a customized arkos player that let you play songs using an external YMZ and the ReSeT party demo disk that includes a CPC version of the PT3 Turbo Sound player (6 channels song format).
123
edits