Changes

PlayCity

1,711 bytes removed, 22:33, 19 November 2020
Changed the code for Playcity detection. It's now faster and shorter
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 SyXIf it's present, A=1; Otherwise, A=0; ---------------------------------------------------------------------------;;=========================macro PlaycityDetection ; Code for NMI management ld a,#3c ; inc a ld (#66),a ld hl,#45ed ; (inverted) opcodes for retn ld (#67),hl
; ConstantesIf a Playcity is present, the code generates a NMI then stops the counter.CTC_TIM1 EQU $ ld bc,#F881 ; Channel 3 NOPs CTC channel 1 (I: Cursor CRTC | O: NMI) CTC_START_TIMER256 EQU ld hl,%0011011100010111*256 + 2 ; 3 NOPs A NMI every 8 NOPsCTC_STOP_CHANNEL EQU %00000011 out (c),h ; 4 NOPs out (c),l ; 4 NOPs
; ---------------------------------------------------------------------------; NOTE: The lower ROM must be disabled before to run this code.check_playcity ; Disable interrupts DI ; Install NMI handler LD Ald a,$C3 0 ; JP $xxxx LD HL,nmi_interrupt LD ($0066),2 NOPs A LD ($0067),HL  ; Initialize playcity variable is set to 0 XOR A LD (playcity),A  ; Wait VBlank LD B,$F5.wait_vbl IN A,(C) RRA JR NC,.wait_vbl ; Initialize If a CTC timer 1 (NMI generator) LD HLis present,32 ; 32 scanlinesit will be INCed by the INTerruption code LD BC,CTC_TIM1 LD A,CTC_START_TIMER256 OUT (C),A inc hl ; Enable Timer OUT (C),2 NOPs L ; Set new time constant=3 => Stop CTC channel nop ; Extra delay LD IX,33 * 4 - 1 ; Wait 33 scanlinesNOPs CALL wait_scanlines_ix LD A,out (playcityc) OR A JR NZ,.playcity_detected ; No PlayCity detected . . . .playcity_detected . . . l ; 4 NOPs <---------------------------------------------------------------------------nmi_interrupt PUSH BC PUSH AF  ; Change playcity variable LD AIf a Playcity is plugged,$FF LD (playcity),A  ; Disable CTC timer 1 (a NMI generator)should be raised during this opcode 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 1mend
</pre>