To implement the following functions through INT0 and INT1 external interrupts: use two external interrupts to realize emergency switching of traffic lights. Please modify the following code#include <reg51.h>

#define uchar unsigned char
#define uint unsigned int

uchar count, ge, shi;          
uchar currentDirection = 0;    
uchar status = 0;             
uint TimerCount = 0;          
uchar emergencyFlag = 0;        
uchar emergencyDirection = 0;  
uchar lastButtonState = 0;     
uchar displayUpdateFlag = 0;    

uchar code table[] = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0,
                      0xFE, 0xF6, 0xEE, 0x3E, 0x9C, 0x7A, 0x9E, 0x8E};

void Timer0_Init();
void DisplayTime(uchar time);
void ControlLights();
void CheckEmergency();
void putch(uchar n);
void Delay_ms(uint ms);        

void Delay_ms(uint ms) {
    uint i, j;
    for(i = 0; i < ms; i++)
        for(j = 0; j < 123; j++);  
}

void Timer0_Init() {
    TMOD = 0x21;     
    TH0 = 0xFC;      
    TL0 = 0x66;    
    TH1 = 0xFD;      
    TL1 = 0xFD;
    
    ET0 = 1;         
    EA = 1;          
    TR0 = 1;         
    TR1 = 1;         
    
    SCON = 0x50;      
}

void putch(uchar n) {
    TI = 0;         
    SBUF = n;        
    while(!TI);     
    TI = 0;           
}

void DisplayTime(uchar time) {
    ge = time % 10;      
    shi = time / 10;      
    

    P2 = 0x01;            
    putch(table[shi]);   
    Delay_ms(2);         
    
    P2 = 0x02;           
    putch(table[ge]);    
    Delay_ms(2);         
}

void ControlLights() {
    switch(status) {
        case 0:          
            P1 = 0x04;   
            count = 60; 
            break;
            
        case 1:         
            P1 = 0x08;   
            count = 2;   
            break;
            
        case 2:          
            P1 = 0x44;    
            count = 60;   
            break;
            
        case 3:          
            P1 = 0x84;    
            count = 2;    
            break;
    }
}


void CheckEmergency() {
    uchar currentButtonState = P3 & 0x03;  
    
    if((currentButtonState & 0x01) && !(lastButtonState & 0x01)) {
     
        emergencyFlag = 1;
        emergencyDirection = 0;
    }
    
    if((currentButtonState & 0x02) && !(lastButtonState & 0x02)) {
    
        emergencyFlag = 1;
        emergencyDirection = 1;
    }
    
    lastButtonState = currentButtonState;  
}

// ???
void main(void) {
    P1 = 0x00;        
    P2 = 0x00;        
    Timer0_Init();      
    
    status = 0;        
    ControlLights();   
    
    while(1) {
        CheckEmergency(); 
        
   
        if(displayUpdateFlag) {
            displayUpdateFlag = 0;  
            
            DisplayTime(count);    
            
            if(count > 0) {
                count--;            
            } else {
                if(!emergencyFlag) { 
                    status = (status + 1) % 4; 
                    ControlLights();        
                } else {
                    emergencyFlag = 0;      
                    ControlLights();          
                }
            }
        }

        DisplayTime(count);
    }
}

void Timer0_ISR() interrupt 1 {
    static uint msCount = 0;
    
    TH0 = 0xFC;      
    TL0 = 0x66;
    
    msCount++;      

    if(msCount >= 1000) {
        msCount = 0;
        displayUpdateFlag = 1;  
    }
}