Example #1
0
static void core_render(struct graphics *g, float delta_time)
{
	/* Game specific render. */
	if(core_global->render_callback != NULL) {
		core_global->render_callback(g, delta_time);
	}

	/* Render the console. */
	if(core_global->console.focused) {
		console_render(&core_global->console, core_global->console_shader, g);
	}
}
Example #2
0
int main(void)
{
    /* enable interrupts (on the CPU) */
    init_interrupts();

    /* Initialize peripherals */
    display_init( res, bit, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE );
    console_init();
    controller_init();

    console_set_render_mode(RENDER_MANUAL);

    /* Main loop test */
    while(1) 
    {
        console_clear();

        /* To do initialize routines */
        controller_scan();

        int controllers = get_controllers_present();

        if( controllers & CONTROLLER_1_INSERTED )
        {
            int accessories = get_accessories_present();

            if( (accessories & CONTROLLER_4_INSERTED) && identify_accessory( 3 ) == ACCESSORY_VRU )
            {
                uint8_t out[64];
                uint8_t in[64];

                // Initial sequence
                out[0] = 0x00;
                out[1] = 0x00;
                print_request( 2, out );
                execute_raw_command( 3, 0xB, 2, 3, out, in );
                print_result( 3, in );

                // LODS OF 0x0B
                out[0] = 0x1E;
                out[1] = 0x0C;
                print_request( 2, out );
                execute_raw_command( 3, 0xD, 2, 1, out, in );
                print_result( 1, in );

                out[0] = 0x6E;
                out[1] = 0x07;
                print_request( 2, out );
                execute_raw_command( 3, 0xD, 2, 1, out, in );
                print_result( 1, in );

                out[0] = 0x08;
                out[1] = 0x0E;
                print_request( 2, out );
                execute_raw_command( 3, 0xD, 2, 1, out, in );
                print_result( 1, in );

                out[0] = 0x56;
                out[1] = 0x18;
                print_request( 2, out );
                execute_raw_command( 3, 0xD, 2, 1, out, in );
                print_result( 1, in );

                out[0] = 0x03;
                out[1] = 0x0F;
                print_request( 2, out );
                execute_raw_command( 3, 0xD, 2, 1, out, in );
                print_result( 1, in );

                // Some C's and B's
                out[0] = 0x00;
                out[1] = 0x00;
                out[2] = 0x00;
                out[3] = 0x00;
                out[4] = 0x01;
                out[5] = 0x00;
                print_request( 6, out );
                execute_raw_command( 3, 0xC, 6, 1, out, in );
                print_result( 1, in );

                out[0] = 0x00;
                out[1] = 0x00;
                print_request( 2, out );
                execute_raw_command( 3, 0xB, 2, 3, out, in );
                print_result( 3, in );
                
                out[0] = 0x00;
                out[1] = 0x00;
                out[2] = 0x02;
                out[3] = 0x00;
                out[4] = 0x3B;
                out[5] = 0x00;
                print_request( 6, out );
                execute_raw_command( 3, 0xC, 6, 1, out, in );
                print_result( 1, in );

                out[0] = 0x00;
                out[1] = 0x00;
                print_request( 2, out );
                execute_raw_command( 3, 0xB, 2, 3, out, in );
                print_result( 3, in );

                // Give that A a try
                memset( out, 0, sizeof( out ) );
                print_request( 22, out );
                execute_raw_command( 3, 0xA, 22, 1, out, in );
                print_result( 1, in );

                memset( out, 0, sizeof( out ) );
                print_request( 22, out );
                execute_raw_command( 3, 0xA, 22, 1, out, in );
                print_result( 1, in );

                memset( out, 0, sizeof( out ) );
                out[14] = 0x03;
                out[18] = 0x12;
                out[20] = 0x08;
                print_request( 22, out );
                execute_raw_command( 3, 0xA, 22, 1, out, in );
                print_result( 1, in );

                // Render it!
                console_render();
                while(1){;}
            }
            else
            {
                printf( "Please insert a VRU into slot 4.\n" );
            }
        }
        else
        {
            printf( "Please insert a standard\ncontroller into slot 1.\n" );
        }

        console_render();
    }
}
Example #3
0
int main(void)
{
    /* enable interrupts (on the CPU) */
    init_interrupts();

    /* Initialize audio and video */
    audio_init(44100,2);
    console_init();

    /* Initialize key detection */
    controller_init();

    MikMod_RegisterAllDrivers();
    MikMod_RegisterAllLoaders();

    md_mode |= DMODE_16BITS;
    md_mode |= DMODE_SOFT_MUSIC;
    md_mode |= DMODE_SOFT_SNDFX;
    //md_mode |= DMODE_STEREO;
                                            
    md_mixfreq = audio_get_frequency();

    MikMod_Init("");

    if(dfs_init( DFS_DEFAULT_LOCATION ) != DFS_ESUCCESS)
    {
        printf("Filesystem failed to start!\n");
    }
    else
    {
        direntry_t *list;
        int count = 0;
        int page = 0;
        int cursor = 0; 

        console_set_render_mode(RENDER_MANUAL);
        console_clear();

        list = populate_dir(&count);

        while(1)
        {
            console_clear();
            display_dir(list, cursor, page, MAX_LIST, count);
            console_render();

            controller_scan();
            struct controller_data keys = get_keys_down();

            if(keys.c[0].up)
            {
                cursor--;
                new_scroll_pos(&cursor, &page, MAX_LIST, count);
            }

            if(keys.c[0].down)
            {
                cursor++;
                new_scroll_pos(&cursor, &page, MAX_LIST, count);
            }

            if(keys.c[0].C_right && list[cursor].type == DT_REG)
            {
                /* Module playing loop */
                MODULE *module = NULL;

                /* Concatenate to make file */
                char path[512];

                strcpy( path, dir );
                strcat( path, list[cursor].filename );

                module = Player_Load(path, 256, 0);
                
                /* Ensure that first part of module doesn't get cut off */
                audio_write_silence();
                audio_write_silence();

                if(module)
                {
                    char c = '-';
                    int sw = 0;

                    Player_Start(module);

                    while(1)
                    {
                        if(sw == 5)
                        {
                            console_clear();
                            display_dir(list, cursor, page, MAX_LIST, count);

                            sw = 0;
                            switch(c)
                            {
                                case '-':
                                    c = '\\';
                                    break;
                                case '\\':
                                    c = '|';
                                    break;
                                case '|':
                                    c = '/';
                                    break;
                                case '/':
                                    c = '-';
                                    break;
                            }
    
                            printf("\n\n\n%c Playing module", c);                        
                            console_render();
                        }
                        else
                        {
                            sw++;
                        }

                        MikMod_Update();

                        controller_scan();
                        struct controller_data keys = get_keys_down();

                        if(keys.c[0].C_left || !Player_Active())
                        {
                            /* End playback */
                            audio_write_silence();
                            audio_write_silence();
                            audio_write_silence();
                            audio_write_silence();

                            break;
                        }
                    }
                
                    Player_Stop();
                    Player_Free(module);
                }
            }

            if(keys.c[0].L)
            {
                /* Open the SD card */
                strcpy( dir, "sd://" );

                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].R)
            {
                /* Open the ROM FS card */
                strcpy( dir, "rom://" );

                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].A && list[cursor].type == DT_DIR)
            {
                /* Change directories */
                chdir(list[cursor].filename);
       
                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }

            if(keys.c[0].B)
            {
                /* Up! */
                chdir("..");
       
                /* Populate new directory */
                free_dir(list);
                list = populate_dir(&count);

                page = 0;
                cursor = 0;
            }
        }
    }

    while(1);

    return 0;
}
Example #4
0
// ------------------------------------------------------------- on_display ---
void on_display (void) {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    console_render( console );
    glutSwapBuffers();
}
Example #5
0
int main(void)
{
    /* enable interrupts (on the CPU) */
    init_interrupts();

    /* Initialize peripherals */
    display_init( res, bit, 2, GAMMA_NONE, ANTIALIAS_RESAMPLE );
    console_init();
    controller_init();

    console_set_render_mode(RENDER_MANUAL);

    int testv = 0;
    int press = 0;
    uint8_t data[32];
    memset( data, 0, 32 );

    /* Main loop test */
    while(1) 
    {
        console_clear();

        /* To do initialize routines */
        controller_scan();

        struct controller_data keys = get_keys_down();

        for( int i = 0; i < 4; i++ )
        {
            if( keys.c[i].A )
            {
                rumble_start( i );
            }

            if( keys.c[i].B )
            {
                rumble_stop( i );
            }

            if( keys.c[i].Z )
            {
                press = read_mempak_address( i, 0x0000, data );
            }
        }

        int controllers = get_controllers_present();

        printf( "Controller 1 %spresent\n", (controllers & CONTROLLER_1_INSERTED) ? "" : "not " );
        printf( "Controller 2 %spresent\n", (controllers & CONTROLLER_2_INSERTED) ? "" : "not " );
        printf( "Controller 3 %spresent\n", (controllers & CONTROLLER_3_INSERTED) ? "" : "not " );
        printf( "Controller 4 %spresent\n", (controllers & CONTROLLER_4_INSERTED) ? "" : "not " );

        int accessories = get_accessories_present();

        printf( "Accessory 1 %spresent %s\n", (accessories & CONTROLLER_1_INSERTED) ? "" : "not ", 
                                              (accessories & CONTROLLER_1_INSERTED) ? format_type( identify_accessory( 0 ) ) : "" );
        printf( "Accessory 2 %spresent %s\n", (accessories & CONTROLLER_2_INSERTED) ? "" : "not ",
                                              (accessories & CONTROLLER_2_INSERTED) ? format_type( identify_accessory( 1 ) ) : "" );
        printf( "Accessory 3 %spresent %s\n", (accessories & CONTROLLER_3_INSERTED) ? "" : "not ",
                                              (accessories & CONTROLLER_3_INSERTED) ? format_type( identify_accessory( 2 ) ) : "" );
        printf( "Accessory 4 %spresent %s\n", (accessories & CONTROLLER_4_INSERTED) ? "" : "not ",
                                              (accessories & CONTROLLER_4_INSERTED) ? format_type( identify_accessory( 3 ) ) : "" );

        printf("\n%d\n\n", testv++ );

        for( int i = 0; i < 32; i++ )
        {
            printf( "%02X", data[i] );
        }

        printf( "\n\n" );
        printf( "Operation returned: %d\n", press );

        console_render();
    }
}
Example #6
0
// ---------------------------------------------------------------- display ---
void display( GLFWwindow* window )
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    console_render( console );
    glfwSwapBuffers( window );
}
Example #7
0
int main(void)
{
    /* enable interrupts (on the CPU) */
    init_interrupts();

    /* Initialize peripherals */
    console_init();
    controller_init();

    console_set_render_mode(RENDER_MANUAL);

    console_clear();

    printf( "Press A on a controller\n"
                    "to read that controller's\n"
                    "mempak.\n\n"
                    "Press B to format mempak.\n\n"
                    "Press Z to corrupt mempak.\n\n"
                    "Press L to copy mempak.\n\n"
                    "Press R to paste mempak." );
    
    console_render();

    /* Main loop test */
    while(1) 
    {
        /* To do initialize routines */
        controller_scan();

        struct controller_data keys = get_keys_down();

        for( int i = 0; i < 4; i++ )
        {
            if( keys.c[i].err == ERROR_NONE )
            {
                if( keys.c[i].A )
                {
                    console_clear();

                    /* Read accessories present, throwing away return.  If we don't do this, then
                       initialization routines in the identify_accessory() call will fail once we
                       remove and insert a new accessory while running */
                    struct controller_data output;
                    get_accessories_present( &output );

                    /* Make sure they don't have a rumble pak inserted instead */
                    switch( identify_accessory( i ) )
                    {
                        case ACCESSORY_NONE:
                            printf( "No accessory inserted!" );
                            break;
                        case ACCESSORY_MEMPAK:
                        {
                            int err;
                            if( (err = validate_mempak( i )) )
                            {
                                if( err == -3 )
                                {
                                    printf( "Mempak is not formatted!" );
                                }
                                else
                                {
                                    printf( "Mempak bad or removed during read!" );
                                }
                            }
                            else
                            {
                                for( int j = 0; j < 16; j++ )
                                {
                                    entry_structure_t entry;

                                    get_mempak_entry( i, j, &entry );

                                    if( entry.valid )
                                    {
                                        printf( "%s - %d blocks\n", entry.name, entry.blocks );
                                    }
                                    else
                                    {
                                        printf( "(EMPTY)\n" );
                                    }
                                }

                                printf( "\nFree space: %d blocks", get_mempak_free_space( i ) );
                            }

                            break;
                        }
                        case ACCESSORY_RUMBLEPAK:
                            printf( "Cannot read data off of rumblepak!" );
                            break;
                    }

                    console_render();
                }
                else if( keys.c[i].B )
                {
                    console_clear();

                    /* Make sure they don't have a rumble pak inserted instead */
                    switch( identify_accessory( i ) )
                    {
                        case ACCESSORY_NONE:
                            printf( "No accessory inserted!" );
                            break;
                        case ACCESSORY_MEMPAK:
                            if( format_mempak( i ) )
                            {
                                printf( "Error formatting mempak!" );
                            }
                            else
                            {
                                printf( "Memory card formatted!" );
                            }

                            break;
                        case ACCESSORY_RUMBLEPAK:
                            printf( "Cannot format rumblepak!" );
                            break;
                    }

                    console_render();
                }
                else if( keys.c[i].Z )
                {
                    console_clear();

                    /* Make sure they don't have a rumble pak inserted instead */
                    switch( identify_accessory( i ) )
                    {
                        case ACCESSORY_NONE:
                            printf( "No accessory inserted!" );
                            break;
                        case ACCESSORY_MEMPAK:
                        {
                            uint8_t sector[256];
                            int err = 0;

                            memset( sector, 0xFF, 256 );

                            err |= write_mempak_sector( i, 0, sector );
                            err |= write_mempak_sector( i, 1, sector );
                            err |= write_mempak_sector( i, 2, sector );
                            err |= write_mempak_sector( i, 3, sector );
                            err |= write_mempak_sector( i, 4, sector );

                            if( err )
                            {
                                printf( "Error corrupting data!" );
                            }
                            else
                            {
                                printf( "Data corrupted on memory card!" );
                            }

                            break;
                        }
                        case ACCESSORY_RUMBLEPAK:
                            printf( "Cannot erase data off of rumblepak!" );
                            break;
                    }

                    console_render();
                }
                else if( keys.c[i].L )
                {
                    console_clear();

                    /* Make sure they don't have a rumble pak inserted instead */
                    switch( identify_accessory( i ) )
                    {
                        case ACCESSORY_NONE:
                            printf( "No accessory inserted!" );
                            break;
                        case ACCESSORY_MEMPAK:
                        {
                            int err = 0;

                            for( int j = 0; j < 128; j++ )
                            {
                                err |= read_mempak_sector( i, j, &mempak_data[j * MEMPAK_BLOCK_SIZE]  );
                            }

                            if( err )
                            {
                                printf( "Error loading data!" );
                            }
                            else
                            {
                                printf( "Data loaded into RAM!" );
                            }

                            break;
                        }
                        case ACCESSORY_RUMBLEPAK:
                            printf( "Cannot erase data off of rumblepak!" );
                            break;
                    }

                    console_render();
                }
                else if( keys.c[i].R )
                {
                    console_clear();

                    /* Make sure they don't have a rumble pak inserted instead */
                    switch( identify_accessory( i ) )
                    {
                        case ACCESSORY_NONE:
                            printf( "No accessory inserted!" );
                            break;
                        case ACCESSORY_MEMPAK:
                        {
                            int err = 0;

                            for( int j = 0; j < 128; j++ )
                            {
                                err |= write_mempak_sector( i, j, &mempak_data[j * MEMPAK_BLOCK_SIZE]  );
                            }

                            if( err )
                            {
                                printf( "Error saving data!" );
                            }
                            else
                            {
                                printf( "Data saved into mempak!" );
                            }

                            break;
                        }
                        case ACCESSORY_RUMBLEPAK:
                            printf( "Cannot erase data off of rumblepak!" );
                            break;
                    }

                    console_render();
                }
            }
        }
    }
}