#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA774_SU1E_AU1E_AU2E
void F1949_(int16_t P5894_, HINT_BUTTON* P5810_, MOUSE2_INPUT* P5811_) {
        register MOUSE2_INPUT* L5684_;
        register HINT_BUTTON* L5685_;
        STRUCT22B* L5686_;


        L5685_ = P5810_;
        L5684_ = P5811_;
        if ((L5685_->_pc_0x0E_String) && (L5685_->_i_0x12 != 2)) {
                L5686_ = F1884_Text(5, C16_ALLOCATE_AND_INITIALIZE, 0L);
                L5686_->_ai_XYZ_0x06[0] = L5685_->_ai_XYZ_0x04[0];
                L5686_->_ai_XYZ_0x06[1] = L5685_->_ai_XYZ_0x04[1];
                L5686_->_ai_XYZ_0x06[2] = L5685_->_ai_XYZ_0x04[2];
                L5686_->_ai_XYZ_0x06[3] = L5685_->_ai_XYZ_0x04[3];
                L5686_->_pc_0x02_String = L5685_->_pc_0x0E_String;
                F1884_Text(5, C06_PRINT, L5686_);
#ifdef MEDIA763_AU1E_AU2E
                F1886_Memory(-1, C20_FREE, L5686_);
#endif
#ifdef MEDIA772_SU1E
                F1886_Memory(5, C20_FREE, L5686_);
#endif
        }
}

#ifdef MEDIA772_SU1E
#ifndef NOCOPYPROTECTION
void F1950_Pre_F1952_CheckCopyProtectionSector_CPSX(
)
{
#include "FAKE4.C"
}

int16_t F1952_CheckCopyProtectionSector_CPSX(
)
{
        register int16_t L5687_;
        char* L5688_;
        char* L5689_;
        char* L5742_;


        L5688_ = (char*)F1886_Memory(14, C14_ALLOCATE, 576L);
        L5742_ = &G3601_l_VerticalBlankCount;
        L5687_ = 0;
        do {
                asm {
                                movem.l d4/a2,-(sp)
                                move.w  #1,-(sp)
                                clr.l   -(sp)
                                move.w  #6,-(sp)
                                clr.w   -(sp)
                                clr.l   -(sp)
                                move.l  L5688_(a6),-(sp)
                                move.w  #8,-(sp)
                                trap    #0xE            /* Call XBIOS */
                                lea     0x14(sp),sp
                                clr.l   -(sp)
                                move.w  #0x20,-(sp)
                                trap    #1
                                move.l  d0,2(sp)
                                tst.w   (0x43E).w
                                bne.w   @Tloc_8BF4
                                move.w  #1,(0x43E).w
                                bsr.w   @Tloc_8B22
                                bsr.w   @Tloc_8BC6
                                bsr.w   @Tloc_8ADE
                                bsr.w   @Tloc_8B22
                                bsr.w   @Tloc_8BC6
                                bsr.w   @Tloc_8ADE
                                bra.w   @Tloc_8BF4
                        @Tloc_8ADE:
                                movea.l L5688_(a6),a0
                                lea     0x14(a0),a0
                                lea     0x1EC(a0),a1
                                move.w  #0x1E9,d0
                                moveq   #0x10,d4
                                moveq   #0,d7
                        @Tloc_8AF2:
                                moveq   #0,d1
                                moveq   #0,d2
                        @Tloc_8AF6:
                                move.b  (a0)+,d3
                                bpl.s   @Tloc_8B00
                                bset    d1,d2
                                andi.b  #0x7F,d3
                        @Tloc_8B00:
                                cmpi.b  #0x68,d3
                                beq.s   @Tloc_8B0A
                                moveq   #0,d7
                                rts
                        @Tloc_8B0A:
                                addq.w  #1,d1
                                subq.w  #1,d0
                                beq.s   @Tloc_8B14
                                cmp.w   d4,d1
                                bne.s   @Tloc_8AF6
                        @Tloc_8B14:
                                cmp.w   (a1),d2
                                beq.s   @Tloc_8B1A
                                addq.w  #1,d7
                        @Tloc_8B1A:
                                move.w  d2,(a1)+
                                tst.w   d0
                                bne.s   @Tloc_8AF2
                                rts
                        @Tloc_8B22:
                                movea.l #0xFFFF8800,a1
                                move.w  #0xF8,d2
                                move    sr,d0
                                ori     #0x700,sr
                                move.b  #0xE,(a1)
                                and.b   (a1),d2
                                ori.b   #5,d2
                                move.b  d2,2(a1)
                                move    d0,sr
                                movea.l L5742_(a6),a2
                                move.l  (a2),d3
                                addi.l  #0x103,d3
                                movea.w #0x8606,a1
                                move.w  #0x80,(a1)
                                moveq   #7,d1
                                bsr.s   @Tloc_8BB8
                        @Tloc_8B5A:
                                move.w  #0x80,(a1)
                                bsr.s   @Tloc_8BBE
                                moveq   #2,d1
                                and.w   -2(a1),d1
                                bsr.s   @Tloc_8BBE
                                tst.w   d1
                                beq.s   @Tloc_8B5A
                                move.w  #0x80,(a1)
                                moveq   #0,d1
                                bsr.s   @Tloc_8BB8
                                move.w  #0x80,(a1)
                        @Tloc_8B78:
                                moveq   #0x2C,d0
                        @Tloc_8B7A:
                                subq.w  #1,d0
                                bne.s   @Tloc_8B7A
                                moveq   #1,d0
                                and.w   -2(a1),d0
                                bne.s   @Tloc_8B78
                                move.w  #0x84,(a1)
                                moveq   #8,d1
                                bsr.s   @Tloc_8BB8
                                move.b  L5688_+3(a6),(0xFFFF860D).w
                                move.b  L5688_+2(a6),(0xFFFF860B).w
                                move.b  L5688_+1(a6),(0xFFFF8609).w
                                move.w  #0x90,(a1)
                                move.w  #0x190,(a1)
                                move.w  #0x90,(a1)
                                move.w  #1,-2(a1)
                                move.w  #0x80,d1
                                move.w  d1,(a1)
                        @Tloc_8BB8:
                                bsr.s   @Tloc_8BBE
                                move.w  d1,-2(a1)
                        @Tloc_8BBE:
                                moveq   #0x2E,d2
                        @Tloc_8BC0:
                                subq.w  #1,d2
                                bne.s   @Tloc_8BC0
                                rts
                        @Tloc_8BC6:
                                cmp.l   (a2),d3
                                bmi.s   @Tloc_8BF2
                                move.l  (a2),d2
                                btst    #5,(0xFFFFFA01).w
                                bne.s   @Tloc_8BC6
                                move.w  #0x90,(a1)
                                moveq   #1,d0
                                and.w   (a1),d0
                                beq.s   @Tloc_8BF2
                                move.w  #0x80,(a1)
                                moveq   #0x2C,d0
                        @Tloc_8BE4:
                                subq.w  #1,d0
                                bne.s   @Tloc_8BE4
                                moveq   #0x10,d0
                                and.w   -2(a1),d0
                                bne.s   @Tloc_8BF2
                                rts
                        @Tloc_8BF2:
                                addq.l  #4,sp
                        @Tloc_8BF4:
                                clr.w   (0x43E).w
                                trap    #1
                                addq.l  #6,sp
                                movem.l (sp)+,d4/a2
                }
        } while (L5687_ == 0);
        F1886_Memory(14, C20_FREE, L5688_);
        return 1;
}

void F1953_Post_F1952_CheckCopyProtectionSector_CPSX(
)
{
#include "FAKE1.C"
}
#endif
#endif
#endif
