//-------------------------------------------------------------- void ofApp::keyPressed(int key){ if (key == ' '){ if (is_play){ is_play = false; midi_reset(); }else{ is_play = true; } } if (key == OF_KEY_RETURN){ midi_reset(); if (is_setting){ for (int x=0; x<300; x++) { for (int y=0; y<300; y++) { image.setting_image[x][y] = 0; } } board.set_map(boad_x, boad_y, 1); board.set_sequence(boad_x, boad_y, image, 1); } } }
//-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ if (is_setting){ int image_x = x - setting_image_x ; int image_y = y - setting_image_y; before_mouse_x = image_x; before_mouse_y = image_y; } //通常画面の場合 if(!is_setting){ midi_reset(); boad_x = (int) x / (piece_size_x +5); boad_y = (int) y / (piece_size_y +5); tmp_current = current; current = boad_x; for (int y = 0; y< PIECE_NUM_MAX_Y; y++){ board.map_unselect(tmp_current, y); board.map_select(current, y); } image = board.get_sequence(boad_x, boad_y); board.set_map(boad_x, boad_y, select_color + 1); board.set_sequence(boad_x, boad_y, image, boad_y*16 + select_color); midi_reset(); is_setting=true; } //設定画面の場合 if(is_setting){ //closeボタンが押された時 if(btn_close_position_x < x && x < btn_close_position_x + 50 && btn_close_position_y < y && y < btn_close_position_y + 50){ midi_reset(); for (int y = 0; y< PIECE_NUM_MAX_Y; y++){ board.map_unselect(current, y); board.map_select(tmp_current, y); } current = tmp_current; is_setting = false; } //色の選択 for(int i = 0; i < 16; i++){ if (color_position_x + (i*30) < x && x < color_position_x + (i*30) +30 && color_position_y < y && y < color_position_y + 30) { select_color = i; draw_color.set(main_color[i]); board.set_map(boad_x, boad_y, i+1); board.set_sequence(boad_x, boad_y, i+1); } } } }
/* VIC20-specific reset sequence. */ void machine_specific_reset(void) { serial_traps_reset(); viacore_reset(machine_context.via1); viacore_reset(machine_context.via2); vic_reset(); sid_reset(); viacore_reset(machine_context.ieeevia1); viacore_reset(machine_context.ieeevia2); rs232drv_reset(); rsuser_reset(); #ifdef HAVE_MIDI midi_reset(); #endif printer_reset(); cartridge_reset(); drive_reset(); datasette_reset(); sampler_reset(); }
void midi_store(WORD a, BYTE b) { #ifdef DEBUG log_message(midi_log, "store(%x,%02x)", a, b); #endif if (maincpu_rmw_flag) { maincpu_clk--; maincpu_rmw_flag = 0; midi_store(a, midi_last_read); maincpu_clk++; } a &= midi_interface[midi_mode].mask; if (a == midi_interface[midi_mode].ctrl_addr) { #ifdef DEBUG log_message(midi_log, "store ctrl: %02x", b); #endif ctrl = b; midi_ticks = get_midi_ticks(); if (MIDI_CTRL_CD(ctrl) == midi_interface[midi_mode].midi_cd) { /* TODO check WS */ midi_activate(); } else if (MIDI_CTRL_CD(ctrl) == MIDI_CTRL_RESET) { midi_reset(); } else { midi_suspend(); } } else if (a == midi_interface[midi_mode].tx_addr) { status &= ~MIDI_STATUS_IRQ; #ifdef DEBUG log_message(midi_log, "store tx: %02x", b); #endif if ((status & MIDI_STATUS_TDRE) && !(MIDI_CTRL_CD(ctrl) == MIDI_CTRL_RESET)) { status &= ~MIDI_STATUS_TDRE; txdata = b; if (!intx) { midi_alarm_clk = maincpu_clk + 1; alarm_set(midi_alarm, midi_alarm_clk); alarm_active = 1; intx = 2; } else { if (intx == 1) { intx++; } } } } }
void midi_init(void) { midi_int_num = interrupt_cpu_status_int_new(maincpu_int_status, "MIDI"); midi_alarm = alarm_new(maincpu_alarm_context, "MIDI", int_midi, NULL); clk_guard_add_callback(maincpu_clk_guard, clk_overflow_callback, NULL); if (midi_log == LOG_ERR) { midi_log = log_open("MIDI"); } mididrv_init(); midi_reset(); }
//-------------------------------------------------------------- void ofApp::exit() { // clean up midi_reset(); for(int i=0;i<10;i++){ for (int channel=1; channel<=16; channel++) { for(int i=1; i<126; i++){ midiOut.sendNoteOff(channel, i); } for(int i=1; i<126; i++){ midiOut.sendNoteOff(channel, i); ofSleepMillis(1); midiOut.sendNoteOn(channel, i, 0); ofSleepMillis(1); midiOut.sendNoteOff(channel, i); } } } midiOut.closePort(); }