Exemplo n.º 1
0
void
smpc_init(void)
{
        irq_mux_t *vbo;
        uint32_t mask;

        /* Set both ports to "SMPC" control mode. */
        MEMORY_WRITE(8, SMPC(EXLE1), 0x00);
        MEMORY_WRITE(8, SMPC(IOSEL1), 0x00);
        MEMORY_WRITE(8, SMPC(DDR1), 0x00);
        MEMORY_WRITE(8, SMPC(PDR1), 0x00);

        /* Disable interrupts */
        cpu_intc_disable();

        mask = IC_MASK_SYSTEM_MANAGER | IC_MASK_TIMER_0;
        scu_ic_mask_chg(IC_MASK_ALL, mask);

        scu_ic_interrupt_set(IC_INTERRUPT_TIMER_0,
            &smpc_peripheral_data);
        scu_ic_interrupt_set(IC_INTERRUPT_SYSTEM_MANAGER,
            &smpc_peripheral_system_manager);
        scu_ic_mask_chg(IC_MASK_ALL & ~mask, IC_MASK_NONE);

        scu_timer_0_set(5);
        scu_timer_1_set(0);
        scu_timer_1_mode_set(/* sp_line = */ true);

        /* Add to VDP2 VBLANK-OUT mux */
        vbo = vdp2_tvmd_vblank_out_irq_get();
        irq_mux_handle_add(vbo, smpc_peripheral_parse, NULL);

        /* Enable interrupts */
        cpu_intc_enable();
}
Exemplo n.º 2
0
void
smpc_peripheral_init(void)
{
        memb_init(&peripherals);

        smpc_peripheral_port_1.peripheral = peripheral_alloc();
        TAILQ_INIT(&smpc_peripheral_port_1.peripherals);

        smpc_peripheral_port_2.peripheral = peripheral_alloc();
        TAILQ_INIT(&smpc_peripheral_port_2.peripherals);

        /* Disablo interrupts */
        cpu_intc_disable();

        /* Set both ports to "SMPC" control mode */
        MEMORY_WRITE(8, SMPC(EXLE1), 0x00);
        MEMORY_WRITE(8, SMPC(IOSEL1), 0x00);
        MEMORY_WRITE(8, SMPC(DDR1), 0x00);
        MEMORY_WRITE(8, SMPC(PDR1), 0x00);

        /* Send INTBACK at start of VBLANK-IN */
        irq_mux_t *vblank_in;

        vblank_in = vdp2_tvmd_vblank_in_irq_get();
        irq_mux_handle_add(vblank_in, irq_mux_vblank_in, NULL);

        /* Parse at start of VBLANK-OUT */
        irq_mux_t *vblank_out;

        vblank_out = vdp2_tvmd_vblank_out_irq_get();
        irq_mux_handle_add(vblank_out, irq_mux_vblank_out, NULL);

        uint32_t mask;

        mask = IC_MASK_SYSTEM_MANAGER;
        scu_ic_mask_chg(IC_MASK_ALL, mask);

        scu_ic_interrupt_set(IC_INTERRUPT_SYSTEM_MANAGER,
            &handler_system_manager);
        scu_ic_mask_chg(IC_MASK_ALL & ~mask, IC_MASK_NONE);

        /* Enable interrupts */
        cpu_intc_enable();
}
int main(void)
{
        irq_mux_t *vblank_in;
        irq_mux_t *vblank_out;
        
        static uint16_t back_screen_color = { COLOR_RGB_DATA | COLOR_RGB555(0, 0, 0) };

        vdp2_init();
		
        vdp1_init();

        smpc_init();
		
        smpc_peripheral_init();
        
        scu_dma_cpu_init();

        cpu_intc_disable();
        vblank_in = vdp2_tvmd_vblank_in_irq_get();
        irq_mux_handle_add(vblank_in, vblank_in_handler, NULL);
        vblank_out = vdp2_tvmd_vblank_out_irq_get();
        irq_mux_handle_add(vblank_out, vblank_out_handler, NULL);
        cpu_intc_enable();

		init();

        vdp2_tvmd_display_set(TVMD_INTERLACE_NONE, TVMD_HORZ_NORMAL_A, TVMD_VERT_240);  
        
        vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(3, 0x1FFFE), back_screen_color);    

        while (true) 
        {
                vdp2_tvmd_vblank_in_wait();
            
				read_digital_pad();
                
                vdp2_tvmd_vblank_out_wait();
							
        }
        return 0;
}
Exemplo n.º 4
0
int main(void)
{
        uint16_t mask;
        int level = DMA_LEVEL_0;
        irq_mux_t *vblank_in;
        irq_mux_t *vblank_out;
        irq_mux_t *hblank_out;
        
        unsigned int joyR = 0, oldjoyR = 0, joyL = 0,  oldjoyL = 0, joyA = 0, oldjoyA = 0, joyB = 0, oldjoyB = 0, joyC = 0, oldjoyC = 0;
        unsigned int joyLeft = 0, oldjoyLeft = 0, joyRight = 0, oldjoyRight = 0, joyStart = 0, oldjoyStart = 0, joyUp = 0, oldjoyUp = 0, joyDown = 0, oldjoyDown = 0;    

        static uint16_t back_screen_color = { COLOR_RGB_DATA | COLOR_RGB555(0, 7, 7) };

        vdp2_init();
        vdp1_init();

        smpc_init();
        smpc_peripheral_init();
        
        scu_dma_cpu_init();

        cons_init(CONS_DRIVER_VDP2);  
        consbuf = (char *)malloc(1024); 

        mask = IC_MASK_LEVEL_0_DMA_END | IC_MASK_LEVEL_1_DMA_END | IC_MASK_LEVEL_2_DMA_END | IC_MASK_DMA_ILLEGAL;

        cpu_intc_disable();
        vblank_in = vdp2_tvmd_vblank_in_irq_get();
        irq_mux_handle_add(vblank_in, vblank_in_handler, NULL);
        vblank_out = vdp2_tvmd_vblank_out_irq_get();
        irq_mux_handle_add(vblank_out, vblank_out_handler, NULL);
        hblank_out = vdp2_tvmd_hblank_in_irq_get();
        irq_mux_handle_add(hblank_out, hblank_out_handler, NULL);        
 
        scu_ic_mask_chg(IC_MASK_ALL, mask);
        scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_0_DMA_END, scu_dma_level_0_end);
        scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_1_DMA_END, scu_dma_level_1_end);
        scu_ic_interrupt_set(IC_INTERRUPT_LEVEL_2_DMA_END, scu_dma_level_2_end);
        scu_ic_interrupt_set(IC_INTERRUPT_DMA_ILLEGAL, scu_dma_illegal);
        scu_ic_mask_chg(IC_MASK_ALL & ~mask, IC_MASK_NONE);
        cpu_intc_enable();

        vdp2_tvmd_display_set(); 
        
        vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(3, 0x1FFFE), back_screen_color);    

        while (true) 
        {
            
                (void)sprintf(  consbuf, "**** SCU DMA from H-RAM to VDP1 ****Release Start to run, Z to quitTo configure press:A/B/C: SCU DMA Level 0/1/2L/R: Mode Direct/IndirectDown/Up/Left/Right: VBO/VBI/HBL/BitLevel %d State %d Mode %s Trig %dLast exec time: %08lu HBL", 
                level, state.st_status, (state.st_level[level].level_mode==DMA_MODE_DIRECT)?"DIR":"IND", state.st_level[level].level_sf, g_dma_counter);   
                cons_buffer(consbuf);               
            
                vdp2_tvmd_vblank_in_wait();
            
                cons_flush();
                
                vdp2_tvmd_vblank_out_wait();
                    
                switch (state.st_status) 
                {
                    case ST_STATUS_WAIT:
                            cons_buffer("Status wait        "); 
                            break;
                    case ST_STATUS_ILLEGAL:
                            state.st_begin = false;
                            cons_buffer("Status illegal     "); 
                            break;
                    case ST_STATUS_END:
                            state.st_begin = false;
                            cons_buffer("Status end        "); 
                            state.st_status = ST_STATUS_WAIT;
                            break;
                }
        
                if (!state.st_begin) 
                {
                        if (g_digital.connected == 1)
                        {
                            joyL = g_digital.pressed.button.l;
                            joyR = g_digital.pressed.button.r;
                            joyStart = g_digital.released.button.start;
                            joyA = g_digital.pressed.button.a;
                            joyB = g_digital.pressed.button.b;
                            joyC = g_digital.pressed.button.c;
                
                            joyUp = g_digital.pressed.button.up;
                            joyDown = g_digital.pressed.button.down;
                            joyRight = g_digital.pressed.button.right;                            
                            joyLeft = g_digital.pressed.button.left;
                            
                            if(joyA & !oldjoyA)
                                    level = DMA_LEVEL_0;
                            else if (joyB & !oldjoyB)
                                    level = DMA_LEVEL_1;
                            else if (joyC & !oldjoyC)
                                    level = DMA_LEVEL_2;      
                            else if (joyL & !oldjoyL)
                                    state.st_level[level].level_mode = DMA_MODE_DIRECT;
                            else if (joyR & !oldjoyR)
                                    state.st_level[level].level_mode = DMA_MODE_INDIRECT;
                            else if (joyUp & !oldjoyUp)
                                    state.st_level[level].level_sf = DMA_MODE_START_FACTOR_VBLANK_IN;
                            else if (joyDown & !oldjoyDown)
                                    state.st_level[level].level_sf = DMA_MODE_START_FACTOR_VBLANK_OUT;
                            else if (joyLeft & !oldjoyLeft)
                                    state.st_level[level].level_sf = DMA_MODE_START_FACTOR_HBLANK_IN;
                            else if (joyRight & !oldjoyRight)
                                    state.st_level[level].level_sf = DMA_MODE_START_FACTOR_ENABLE;       

                            if (joyStart & !oldjoyStart) 
                            {
                                    cons_buffer("Started     "); 
                                    scu_dma_level(level);
                            }
                            else 
                            {
                                    cons_buffer("Not Started "); 
                            }
                            
                            
                            oldjoyR = joyR;
                            oldjoyL = joyL;
                            oldjoyA = joyA;
                            oldjoyB = joyB;
                            oldjoyC = joyC;
                            oldjoyUp = joyUp;
                            oldjoyDown = joyDown;
                            oldjoyLeft = joyLeft;
                            oldjoyRight = joyRight; 
                            oldjoyStart = joyStart;
                        }                  
                }
                
                // exit
                if(g_digital.pressed.button.z) abort();
        }
        return 0;
}