int main(void) { // Video setup lcdMainOnBottom(); irqEnable(IRQ_VBLANK); vramSetBankC(VRAM_C_SUB_BG); // Text console videoSetModeSub(MODE_5_2D); PrintConsole *pc = consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true); BG_PALETTE_SUB[255] = RGB15(31,15,0); bgSetPriority(pc->bgId, 0); // DSMI Logo int bg2 = bgInitSub(2, BgType_Bmp16, BgSize_B16_256x256, 2, 0); bgSetPriority(bg2, 1); u16 *bg2vram = bgGetGfxPtr(bg2); dmaCopy(dsmi_logo_dsBitmap, bg2vram, 256*192); iprintf("\x1b[12;12HPulse DS\n"); // Connect int res = dsmi_connect(); while(res == 0) { iprintf("\x1b[15;0H\x1b[KCould not connect. We apologize for the inconvecience.\n"); while(1); } iprintf("\x1b[15;0H\x1b[KRunning.\n"); u8 message, data1, data2; while(1) { // We query every 60th of a second (notice the swiWaitForVBlank). // For lower latency you should query more frequently. // Query and play until there are no more new messages while(dsmi_read(&message, &data1, &data2)) { printf("0x%x 0x%x 0x%x\n", message, data1, data2); midiToArm7(message, data1, data2); } swiWaitForVBlank(); } return 0; }
void MidiModule::midi_connect() { PA_Clear8bitBg(BOTTOM_SCREEN); PA_8bitText(BOTTOM_SCREEN, 3, 3, 255, 40,"Searching for WIFI-MIDI...",1,1,0,100); dsmi_setup_wifi_support(); int res = dsmi_connect(); if (res == 0) { PA_8bitText(BOTTOM_SCREEN, 3, 15, 255, 40,"No WIFI-MIDI detected.",1,1,0,100); this->status = MIDI_STATUS_DISCONNECTED; } else { PA_8bitText(0, 3, 15, 255, 40,"Connected to WIFI-MIDI!",1,1,0,100); this->status = MIDI_STATUS_CONNECTED; } }
int main(void) { lcdMainOnBottom(); // Set modes videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG2_ACTIVE); // Set banks vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000 , VRAM_D_LCD); // Gfx on main REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_PRIORITY(0); REG_BG3PA = 1 << 8; REG_BG3PB = 0; REG_BG3PC = 0; REG_BG3PD = 1 << 8; // Text bg on sub REG_BG0CNT_SUB = BG_MAP_BASE(4) | BG_TILE_BASE(0) | BG_PRIORITY(0); BG_PALETTE_SUB[255] = RGB15(31,15,0); consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true); // Gfx on sub REG_BG2CNT_SUB = BG_BMP16_256x256 | BG_MAP_BASE(2) | BG_PRIORITY(1); REG_BG2PA_SUB = 1 << 8; REG_BG2PB_SUB = 0; REG_BG2PC_SUB = 0; REG_BG2PD_SUB = 1 << 8; u16 i; for(i=0; i<256*192; ++i) sub_vram[i] = dsmi_logo_ds[i]; drawKaos(); drawSlider1(); drawSlider2(); drawSlider3(); iprintf("\x1b[12;12HOSC Demo\n"); iprintf("\x1b[15;0H\x1b[KConnecting\n"); int res = dsmi_connect(); if(res == 1) { iprintf("\x1b[15;0H\x1b[KOK\n"); } else { iprintf("\x1b[15;0H\x1b[KOh no, could not connect!\n"); while(1); } while(1) { int ret, i; char data[32]; size_t size = sizeof(data); char type; VblankHandler(); while( dsmi_osc_read() ){ iprintf("\x1b[17;0H\x1b[K%s\n", dsmi_osc_getaddr()); while( ret = dsmi_osc_getnextarg( data, &size, &type)){ if( ret == -1) break; //buffer too small error switch(type){ case 'i': case 'f': iprintf("%c : 0x%x%x%x%x\n", type, data[0], data[1], data[2], data[3]); break; case 's': iprintf("%c : %s\n", type, data); break; default: break; } } } swiWaitForVBlank(); } }
int main(void) { lcdMainOnBottom(); // Register vblank IRQ irqEnable(IRQ_VBLANK); // Set banks vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000 , VRAM_D_LCD); // Set modes videoSetMode(MODE_5_2D); videoSetModeSub(MODE_5_2D); // sub display int sub_bg3 = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 2, 0); bgSetPriority(sub_bg3, 1); #ifdef DEBUG // Text bg on sub PrintConsole *pc = consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false); bgSetPriority(pc->bgId, 0); BG_PALETTE_SUB[255] = RGB15(31,0,31); #endif // The main display is for graphics. // Set up an extended rotation background for background gfx int main_bg2 = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 2, 0); bgSetPriority(main_bg2, 1); // Set up tile mode for the keyboard int main_bg0 = bgInit(0, BgType_Text4bpp, BgSize_T_256x256, 8, 0); bgSetPriority(main_bg0, 0); // Clear tile mem u16 *tile_ram = (u16*)bgGetGfxPtr(main_bg0); u32 i; for(i=0; i<(32*1024); ++i) { tile_ram[i] = 0; } // Copy tiles and palettes dmaCopy((uint16*)keyboard_Palette, (uint16*)BG_PALETTE, 32); dmaCopy((uint16*)keyboard_fullnotehighlight_Palette, (uint16*)BG_PALETTE+16, 32); dmaCopy((uint16*)keyboard_halfnotehighlight_Palette, (uint16*)BG_PALETTE+32, 32); dmaCopy((uint16*)keyboard_Tiles, (uint16*)CHAR_BASE_BLOCK(0), 736); // Fill screen with empty tiles u16 *map = (u16*)bgGetMapPtr(main_bg0); for(i=0;i<768;++i) { map[i] = 28; } // Draw the backgrounds main_vram = (u16*)bgGetGfxPtr(main_bg2); for(i=0; i<192*256; ++i) { main_vram[i] = ((uint16*)bg_main)[i]; } u16 *sub_vram = (u16*)bgGetGfxPtr(sub_bg3); for(i=0; i<192*256; ++i) { sub_vram[i] = ((uint16*)bg_sub)[i]; } displayChannel(channel); displayOctave(baseOctave); drawString("connecting ...", 89, 96); iprintf("Connecting\n"); int res = dsmi_connect(); if(res == 1) { iprintf("OK\n"); } else { iprintf("Oh no! Could not connect\n"); drawString("failed!", 180, 96); while(1); } iprintf("Ready.\n"); // Copy the keyboard to the screen kb_map = (u16*)bgGetMapPtr(main_bg0); u8 x, y; for(y=0; y<5; ++y) { for(x=0; x<28; ++x) { kb_map[32*(y+keyb_ypos)+(x+keyb_xpos)] = keyboard_Map[29*y+x+1]; } } while(1) { VblankHandler(); swiWaitForVBlank(); } return 0; }