#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA375_G14ED_G20E_G21E_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_F31E_F31J_X31J_P31J
#ifdef MEDIA351_G14ED_G20E_G21E
segment "interrupts"
#endif

void F0696_UpdateMessageArea(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA351_G14ED_G20E_G21E
        unsigned char* L6246_;
        unsigned char* L6247_;
        int16_t L6248_;
        unsigned int16_t L6249_;


        HideCursor();
        L6248_ = GetIRQEnable();
        IntSource(13);
        L6246_ = GetVector(10);
        L6247_ = (unsigned char*)F2176_;
        SetVector(10, L6247_);
        SetSCB(199, GetSCB(199) | 0x40);
        IntSource(12);
        for (L6249_ = 0; L6249_ < 7; L6249_++) {
                G3972_i_ = C1_TRUE;
                while (G3972_i_);
                F2171_();
        }
        IntSource(13);
        SetSCB(199, GetSCB(199) & ~0x40);
        SetVector(10, L6246_);
        if (L6248_ & 2) {
                IntSource(12);
        }
        ShowCursor();
#endif
#ifdef MEDIA496_F20E_F20J_P20JA_P20JB_I34E_I34M_F31E_F31J_P31J
#ifdef MEDIA709_I34E_I34M_P31J
        int16_t L3502_ai_XYZ[4];
#endif
        int16_t L3503_ai_Box[4];


        F0077_MOUSE_EnableScreenUpdate_CPSE();
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        EGB_writePage(G4105_WORK, G4103_WRITE_PAGE);
#endif
#ifdef MEDIA492_F20E_F20J_P20JA_P20JB_F31E_F31J
        F0638_GetZone(C015_ZONE_MESSAGE_AREA, L3503_ai_Box);
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        WORD(G4106_EGBPARA + 0) = M704_ZONE_LEFT(L3503_ai_Box);
        WORD(G4106_EGBPARA + 2) = M706_ZONE_TOP(L3503_ai_Box);
        WORD(G4106_EGBPARA + 4) = M705_ZONE_RIGHT(L3503_ai_Box);
        WORD(G4106_EGBPARA + 6) = M707_ZONE_BOTTOM(L3503_ai_Box);
        EGB_viewport(G4105_WORK, G4106_EGBPARA);
#endif
#ifdef MEDIA559_F20E_F31E
        EGB_partScroll(G4105_WORK, 0, 0, -G2088_C7_TextLineHeight, G4106_EGBPARA);
#endif
#ifdef MEDIA576_F20J_F31J
        EGB_partScroll(G4105_WORK, 0, 0, -G2342_C17_JapaneseTextLineHeight, G4106_EGBPARA);
#endif
#ifdef MEDIA709_I34E_I34M_P31J
        F0638_GetZone(C015_ZONE_MESSAGE_AREA, L3502_ai_XYZ);
        M768_BOX_LEFT(L3503_ai_Box) = M704_ZONE_LEFT(L3502_ai_XYZ);
        M769_BOX_RIGHT(L3503_ai_Box) = M705_ZONE_RIGHT(L3502_ai_XYZ);
        M770_BOX_TOP(L3503_ai_Box) = M706_ZONE_TOP(L3502_ai_XYZ);
        M771_BOX_BOTTOM(L3503_ai_Box) = M707_ZONE_BOTTOM(L3502_ai_XYZ);
#endif
#ifdef MEDIA459_P20JA_P20JB_P31J
        (*(G2156_VideoDriver->VIDRV_10_ScrollMessageAreaUp))(L3503_ai_Box, G2342_C17_JapaneseTextLineHeight);
#endif
#ifdef MEDIA487_F20E
        M706_ZONE_TOP(L3503_ai_Box) = M707_ZONE_BOTTOM(L3503_ai_Box) - G2083_C6_ + 1;
#endif
#ifdef MEDIA669_F31E
        M706_ZONE_TOP(L3503_ai_Box) = M707_ZONE_BOTTOM(L3503_ai_Box) - G2083_C6_ + 1;
        M709_ZONE_HEIGHT(L3503_ai_Box) = G2083_C6_;
#endif
#ifdef MEDIA564_F20J
        M706_ZONE_TOP(L3503_ai_Box) = M707_ZONE_BOTTOM(L3503_ai_Box) - G2338_i_JapaneseCharacterMaximumHeight + 1;
#endif
#ifdef MEDIA686_F31J
        M706_ZONE_TOP(L3503_ai_Box) = M707_ZONE_BOTTOM(L3503_ai_Box) - G2338_i_JapaneseCharacterMaximumHeight + 1;
        M709_ZONE_HEIGHT(L3503_ai_Box) = G2338_i_JapaneseCharacterMaximumHeight;
#endif
#ifdef MEDIA458_P20JA_P20JB
        M770_BOX_TOP(L3503_ai_Box) = M771_BOX_BOTTOM(L3503_ai_Box) - G2338_i_JapaneseCharacterMaximumHeight + 1;
#endif
#ifdef MEDIA667_P31J
        M706_ZONE_TOP(L3502_ai_XYZ) = M707_ZONE_BOTTOM(L3502_ai_XYZ) - G2338_i_JapaneseCharacterMaximumHeight + 1;
        M709_ZONE_HEIGHT(L3502_ai_XYZ) = G2338_i_JapaneseCharacterMaximumHeight;
#endif
#ifdef MEDIA707_I34E_I34M
        (*(G2156_VideoDriver->VIDRV_10_ScrollMessageAreaUp))(L3503_ai_Box, G2088_C7_TextLineHeight);
        M706_ZONE_TOP(L3502_ai_XYZ) = M707_ZONE_BOTTOM(L3502_ai_XYZ) - G2083_C6_ + 1;
        M709_ZONE_HEIGHT(L3502_ai_XYZ) = G2083_C6_;
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
        F0132_VIDEO_Blit(G0356_puc_Bitmap_MessageAreaNewRow, NULL, L3503_ai_Box, 0, 0, G2092_MessageAreaWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY);
#endif
#ifdef MEDIA458_P20JA_P20JB
        F0132_VIDEO_Blit(G0356_puc_Bitmap_MessageAreaNewRow, NULL, L3503_ai_Box, 0, 0, G2092_MessageAreaWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY, MASK0x0000_NO_FLIP);
#endif
#ifdef MEDIA709_I34E_I34M_P31J
        F0132_VIDEO_Blit(G0356_puc_Bitmap_MessageAreaNewRow, NULL, L3502_ai_XYZ, 0, 0, G2092_MessageAreaWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY, MASK0x0000_NO_FLIP);
#endif
        F0078_MOUSE_DisableScreenUpdate();
#endif
#ifdef MEDIA607_X30J_X31J
        register int16_t L3504_i_;
        register unsigned long L3505_ul_;
        register long L3506_l_;
        register int16_t L3507_i_;
        register int16_t L3508_i_;
        register unsigned char* L3509_puc_;
        register unsigned char* L3510_puc_;
        long L3511_l_SupervisorStack;
        int16_t L3502_ai_XYZ[4];


        L3505_ul_ = G3089_;
        F0638_GetZone(C015_ZONE_MESSAGE_AREA, L3502_ai_XYZ);
        L3510_puc_ = G3090_X68000VideoMemoryAddress + (L3505_ul_ * (M706_ZONE_TOP(L3502_ai_XYZ) + 1)) + (M704_ZONE_LEFT(L3502_ai_XYZ) * 2);
        L3506_l_ = G2092_MessageAreaWidth * 2;
#ifdef MEDIA577_X30J
        L3507_i_ = M709_ZONE_HEIGHT(L3502_ai_XYZ) - 1;
        M706_ZONE_TOP(L3502_ai_XYZ) = M707_ZONE_BOTTOM(L3502_ai_XYZ);
#endif
#ifdef MEDIA692_X31J
        L3507_i_ = M709_ZONE_HEIGHT(L3502_ai_XYZ);
        M706_ZONE_TOP(L3502_ai_XYZ) += L3507_i_ - 1;
        M709_ZONE_HEIGHT(L3502_ai_XYZ) = 1;
#endif
        for (L3508_i_ = 0; L3508_i_ < G2342_C17_JapaneseTextLineHeight; L3508_i_++) {
                L3509_puc_ = L3510_puc_;
#ifdef MEDIA577_X30J
                L3511_l_SupervisorStack = F1027_Supervisor(0L);
#endif
#ifdef MEDIA692_X31J
                asm {
                        clr.l   -(sp)
                        dc.w    0xFF20  /* DOS CALL SUPER */
                        addq.l  #4,sp
                        move.l  d0,L3511_l_SupervisorStack(a6)
                }
#endif
#ifdef MEDIA577_X30J
                for (L3504_i_ = 0; L3504_i_ < L3507_i_; L3504_i_++) {
#endif
#ifdef MEDIA692_X31J
                for (L3504_i_ = 0; L3504_i_ <= L3507_i_; L3504_i_++) {
#endif
                        F0007_MAIN_CopyBytes(L3509_puc_, L3509_puc_ - L3505_ul_, L3506_l_);
                        L3509_puc_ += L3505_ul_;
                }
                if (L3508_i_ == 0) {
                        F0008_MAIN_ClearBytes(L3509_puc_ - L3505_ul_, L3506_l_);
                }
#ifdef MEDIA577_X30J
                F1027_Supervisor(L3511_l_SupervisorStack);
#endif
#ifdef MEDIA692_X31J
                asm {
                        move.l  L3511_l_SupervisorStack(a6),-(sp)
                        dc.w    0xFF20  /* DOS CALL SUPER */
                        addq.l  #4,sp
                }
#endif
                if (L3508_i_ > 0) {
                        F0132_VIDEO_Blit(G0356_puc_Bitmap_MessageAreaNewRow, G0348_Bitmap_Screen, L3502_ai_XYZ, 0, L3508_i_ - 1, G2092_MessageAreaWidth, G2071_C320_ScreenPixelWidth, CM1_COLOR_NO_TRANSPARENCY);
                }
                M526_WaitVerticalBlank();
        }
        G0355_B_ScrollMessageArea = C0_FALSE;
#endif
}

#ifdef MEDIA351_G14ED_G20E_G21E
int16_t F2171_(
)
{
        asm {
                        LDY        #0x1b                /* 27 lines to copy */
                        LDX        #0x00
                L090788:
                        LDA        0xe18c20,X           /* Copy 160 bytes (1 line) = 80 word copy operations */
                        STA        0xe18b80,X           /* Addresses should reference the screen address 0xe12000 with offsets (patched during startup by F2164_PatchAddresses) */
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        LDA        0xe18c20,X
                        STA        0xe18b80,X
                        CLC
                        TXA
                        ADC        #C160_BYTE_WIDTH_SCREEN
                        TAX
                        DEY
                        BEQ        L090A14
                        BRL        L090788
                L090A14:
                        LDX        #158
                L090A17:
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow,X
                        STA        0xe19c60,X   /* Last line on the bottom of the screen */
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+160,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow,X
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+320,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow+160,X
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+480,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow+320,X
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+640,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow+480,X
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+800,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow+640,X
                        LDA        >G3971_auc_Bitmap_MessageAreaNewRow+960,X
                        STA        >G3971_auc_Bitmap_MessageAreaNewRow+800,X
                        DEX
                        DEX
                        BPL        L090A17
        }
}
#endif
#endif
