Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- #include <string.h>
- #include <stdint.h>
- #include <libdragon.h>
- static resolution_t res = RESOLUTION_320x240;
- static bitdepth_t bit = DEPTH_32_BPP;
- uint32_t io_read_abs(uint32_t pi_address)
- {
- //replacement for io_read to not use cart space
- volatile uint32_t *uncached_address = (uint32_t *)pi_address;
- uint32_t retval = 0;
- disable_interrupts();
- /* Wait until there isn't a DMA transfer and grab a word */
- while (dma_busy()) ;
- MEMORY_BARRIER();
- retval = *uncached_address;
- MEMORY_BARRIER();
- enable_interrupts();
- return retval;
- }
- int detect64dd_ipl(void)
- {
- //Look at 0x9FF00 from the IPL.
- uint32_t test = io_read_abs(0x0609FF00);
- //Check if the highest byte is 0xC3
- test &= 0xFF000000;
- if (test == 0xC3000000)
- return 1; //if yes, then retail 64DD is present
- else
- return 0; //if not, then there are no 64DD connected.
- }
- 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);
- //64DD IPL test
- int dd_present = detect64dd_ipl();
- /* Main loop test */
- while(1)
- {
- console_clear();
- /* To do initialize routines */
- controller_scan();
- printf("64dd_test by LuigiBlood\n\n");
- if(dd_present == 1)
- printf("Retail 64DD has been found (IPL)\n\n");
- else
- printf("Retail 64DD has NOT been found (IPL)\n\n");
- struct controller_data keys = get_keys_down();
- int controllers = get_controllers_present();
- printf( "Controller 1 %spresent\n", (controllers & CONTROLLER_1_INSERTED) ? "" : "not " );
- if( keys.c[0].A )
- {
- printf("YOU PRESSED A");
- }
- console_render();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement