int test_line(unsigned short xi, unsigned short yi, unsigned short xf, unsigned short yf, unsigned long color) { if (vg_init(VBE_VIDEO_MODE) == NULL) return 1; if(xi > xf && yi > yf){ unsigned short tmp = xf; xf = xi; xi = tmp; tmp = yf; yf = yi; yi = tmp; } if (vg_draw_line(xi, yi, xf, yf, color) != 0) { vg_exit(); return 1; } vg_update_screen(); kbd_test_scan(0); return vg_exit(); }
int test_xpm(unsigned short xi, unsigned short yi, char *xpm[]) { if (vg_init(VBE_VIDEO_MODE) == NULL) return 1; if (vg_draw_xpm(xi, yi, xpm) != 0) { vg_exit(); return 1; } vg_update_screen(); kbd_test_scan(0); return vg_exit(); }
int main(int argc, char **argv) { sef_startup(); vg_exit();//TODO ELIMINAR start(); leave(); return 0; }
int test_square(unsigned short x, unsigned short y, unsigned short size, unsigned long color) { vg_init(GRAPHIC_MODE); int ipc_status; message msg; int request; int irq_set; irq_set = subscribe_kbd(); while (scanCode != EXIT_MAKE_CODE) { request = driver_receive(ANY, &msg, &ipc_status); if (request != 0) { printf("driver_receive failed with: %d", request); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { kbd_handler(); } vg_draw_rectangle(x,y,size,size,color); break; default: break; } } else { } } unsubscribe_kbd(); vg_exit(); return 0; }
int test_square(unsigned short x, unsigned short y, unsigned short size, unsigned long color) { if (vg_init(VBE_VIDEO_MODE) == NULL) return 1; if (vg_draw_frame(x, y, size, size, color) != 0) { vg_exit(); return 1; } vg_update_screen(); kbd_test_scan(0); return vg_exit(); }
int game() { int menu = 0; load_cards(); load_menu(); if ((irq_set = keyboard_subscribe_int()) == 1) { vg_exit(); return 1; } while (menu == 0) { if (keyboard_int_handler(irq_set) == 0) { if (scancode == 0x82) { menu = 1; vg_fill(0xff); vg_draw("/usr/src/drivers/proj/images/image_nivel3.mg", 64, 167, 428, 36); vg_draw_all(&d1, 134, 180); vg_draw("/usr/src/drivers/proj/images/image_selected.mg", d1.cards[0]->height, d1.cards[0]->width, d1.posx[0], d1.posy[0]); } else { if (scancode == 0x83) { vg_exit(); return 0; } } } } while (game_over == 0) { if (keyboard_int_handler(irq_set) == 0) { game_handling(&d1); } } if (keyboard_unsubscribe_int() != 0) { return 1; } sleep(5); vg_exit(); return 0; }
void leave(){ timer_unsubscribe_int(); kb_unsubscribe_int(); mouse_unsubscribe_int(); empty_out_buf(); vg_exit(); highscore_save(); options_save(); exit(0); }
int test_line(unsigned short xi, unsigned short yi, unsigned short xf, unsigned short yf, unsigned long color) { char* video_mem = NULL; int failure =0; if((video_mem=(char *)vg_init(VBE_MODE_RES_1024x768)) == NULL) { printf("test_line(): vg_init() failed"); return 1; } draw_line(video_mem,xi,yi, xf,yf,color); int kbd_irq_set = 0; if((kbd_irq_set = kbd_subscribe_int(0)) < 0){//subscribe kbd interrupts printf("test_line(): kbd_subscribe_int() failed \n"); failure = 1; } int ipc_status; message msg; int r; if(!failure){ do{ /* Get a request message. */ if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & kbd_irq_set) { /* subscribed kbd interrupt */ if(kbd_int_handler()) failure = 1; } break; default: break; /* no other notifications expected: do nothing */ } } else {/* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } while(get_scancode() != ESC_BREAK && !failure); } if(kbd_unsubscribe_int()){//unsubscribe interrupts printf("test_square(): kbd_unsubscribe_int() failed\n"); failure = 1; } printf("Done\n"); if(vg_exit()){ printf("test_line(): vg_exit() failed"); return 1; } return failure; }
int main(int argc, char** argv) { sef_startup(); vg_init(GRAPHIC_MODE); MouseMaze* maze = (MouseMaze*)startMouseMaze(); while(!maze->validation){ updateMouseMaze(maze); } stopMouseMaze(maze); vg_exit(); return 0; }
int main(int argc, char **argv) { srand(time(NULL)); sef_startup(); Whack* whack = startWhack(); vg_init(0x114); int done = 0; //whack->done; //Bitmap* board = loadBitmap("/home/lcom/lcom1415-t3g15/projeto/res/board.bmp"); //Bitmap* bt = loadBitmap("/home/lcom/lcom1415-t3g15/projeto/res/exit-button.bmp"); //drawBitmapWithoutBg(board, 0, 0, ALIGN_LEFT); //drawBitmapWithoutBg(bt, 200, 120, ALIGN_LEFT); //MainMenu* teste = createMainMenu(); //drawMainMenu(teste); //deleteMainMenu(teste); /*Game* teste = createGame(); //OptionsMenu* teste = createOptionsMenu(0, 0); drawGame(teste); flipMouse(); drawMouse(); flipDisplay(); sleep(10); deleteGame(teste);*/ while (!whack->done) { updateWhack(whack); if (get_counter(whack->timer) % 4 == 0){ if (!whack->done && whack->draw) { drawWhack(whack); } if (getMouse()->draw) { flipMouse(); drawMouse(); flipDisplay(); } } } stopWhack(whack); vg_exit(); printf("\nTerminated\n"); return 0; }
int racinix_exit() { race_delete(race); bitmap_delete(bitmap_background); bitmap_delete(bitmap_mouse_cursor); bitmap_delete(bitmap_red_car); bitmap_delete(bitmap_blue_car); bitmap_delete(bitmap_speedometer); bitmap_delete(bitmap_credits); font_delete(font_impact); ad_delete(ad); return vg_exit(); }
void *test_init(unsigned short mode, unsigned short delay) { void* video_mem = NULL; if((video_mem=vg_init(mode)) == NULL) { printf("test_init(): vg_init() failed"); return NULL; } int failure=0; int timer_irq_set=0; if((timer_irq_set = timer_subscribe_int()) < 0){//subscribe timer 0 interrupts printf("test_move(): timer_subscribe_int() failed \n"); failure = 1; } int ipc_status; message msg; int r; //unsigned long ticks=0; if(!failure){ do{ /* Get a request message. */ if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if(msg.NOTIFY_ARG & timer_irq_set){ timer_int_handler(); } break; default: break; /* no other notifications expected: do nothing */ } } else {/* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } while(get_ticks() < delay * 60); } if(timer_unsubscribe_int()){//unsubscribe interrupts printf("test_move(): timer_unsubscribe_int() failed\n"); failure = 1; } if(vg_exit()){ printf("test_init(): vg_exit() failed"); return NULL; } printf("Physical Address of VRAM: 0x%X\n", get_vram_phys_addr()); return (void*)get_video_mem(); }
int exit_on_ESC() { int ipc_status, r, exit = 0; unsigned long irq_set, data; message msg; irq_set = keyboard_subscribe_int(); if (irq_set == -1) return 1; // check if subscribe_int failed do { r = driver_receive(ANY, &msg, &ipc_status); if (r != 0) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { data = readFromKBC(); if (data == ESC) { exit = 1; if (vg_exit() != 0) { printf("\texit_on_ESC(): vg_exit() failed\n"); return 1; } } } break; default: break; } } } while (exit == 0); keyboard_unsubscribe_int(); return 0; }
void *vg_init(unsigned short mode) { vbe_mode_info_t config; if ( vbe_set_mode(VBE_MODE, mode) == 1) //set graphic mode return NULL; if (vbe_get_mode_info(mode, &config) != 0) //get vbe info { return NULL; } h_res = config.XResolution; //store X Resolution v_res = config.YResolution; //store Y Resolution bits_per_pixel = config.BitsPerPixel; //store Bits Per Pixel vram_size = (config.XResolution * config.YResolution * config.BitsPerPixel) / 8; //store the size of the vram int r; struct mem_range mr; /* Allow memory mapping */ mr.mr_base = (config.PhysBasePtr); mr.mr_limit = mr.mr_base + (config.XResolution * config.YResolution * config.BitsPerPixel) / 8; if( OK != (r = sys_privctl(SELF, SYS_PRIV_ADD_MEM, &mr))) panic("video_txt: sys_privctl (ADD_MEM) failed: %d\n", r); /* Map memory */ video_mem = vm_map_phys(SELF, (void *)mr.mr_base, (config.XResolution * config.YResolution * config.BitsPerPixel) / 8); if(video_mem == MAP_FAILED) panic("video_txt couldn't map video memory"); if (video_mem == NULL) { printf("vg_init: Error!\n"); vg_exit(); return NULL; } return config.PhysBasePtr; }
void *test_init(unsigned short mode, unsigned short delay) { char *video_mem; vbe_mode_info_t vbe; video_mem = vg_init(mode); if (vbe_get_mode_info(mode, &vbe) == 1) { printf("Failed vbe_get_mode_info().\n"); return; } timer_test_int(delay); if (vg_exit() == 1) { printf("Failed vg_exit().\n"); return; } printf("Physical Adress VRAM: 0x%x",vbe.PhysBasePtr); return video_mem; }
int window_destroy(window_t* window) { LOG int error, i; /* remove mouse */ error = window_uninstall_mouse(window); if (error) { printf("window_destroy: window_uninstall_mouse failed with error code %d.\n", error); return error; } /* remove keyboard */ error = keyboard_destroy(); if (error) { printf("window_destroy: keyboard_destroy failed with error code %d.\n", error); return error; } /* remove tabs */ for (i = 0; i < TAB_COUNT; ++i) { if (window->tabs[i]) { error = tab_destroy(window->tabs[i]); if (error) { printf("window_destroy: tab_destroy(%d) failed with error code %d.\n", i, error); return error; } } } /* exit video mode */ if (window->draw) { error = vg_exit(); if (error) { printf("window_destroy: vg_exit failed with error code %d.\n", error); return error; } } return 0; }
void *test_init(unsigned short mode, unsigned short delay) { void *ret; vbe_mode_info_t vmi_p; if ((ret = vg_init(mode)) == NULL) return NULL; timer_test_int(delay); if (vbe_get_mode_info(mode, &vmi_p) != 0) return NULL; if (vg_exit() != 0) return NULL; //test to see if vbe_get_mode_info is working printf("X res: %d\nY res: %d\nBits per pixel: %d\nPhysical Address: %x", vmi_p.XResolution, vmi_p.YResolution, vmi_p.BitsPerPixel, vmi_p.PhysBasePtr); return ret; }
int main() { //permite ao programa usar a memoria sef_startup(); /* Change to video mode */ vg_init(0x105); vg_fill(0x16); //quadrados ftw int a=100,b=100,c=200,d=200; vg_draw_square(100,100,200,200, 0x14); scan_kb(&a,&b,&c,&d, 0x14); sleep(5); /* for WAIT_TIME_S (5) seconds */ vg_exit(); return 0; }
int main(int argc, char **argv) { /* Initialize service */ sef_startup(); char *video_mem; video_mem = vg_init(VBE_105_MODE); while (1) { if (menu(video_mem) == -1) { break; } int n_seconds_player1 = game(video_mem, 1, -1); if (n_seconds_player1 == -1) { break; } int n_seconds_player2 = game(video_mem, 2, n_seconds_player1); if (n_seconds_player2 == -1) { break; } if (n_seconds_player1 > n_seconds_player2) { player_wins(video_mem, 2); } else { player_wins(video_mem, 1); } } vg_exit(); return 0; }
int test_line(unsigned short xi, unsigned short yi, unsigned short xf, unsigned short yf, unsigned long color) { if(vg_init(MODE_105)==NULL) { printf("Failed vg_init().\n"); return 1; } if(print_line(xi,yi,xf,yf,color)==1) { if(vg_exit()==1) { printf("Failed vg_exit().\n"); } printf("Wrong coordinates.\n"); return 1; } if (wait_for_ESC() ==1) { printf("Failed wait_for_ESC().\n"); return 1; } return 0; }
int test_move(unsigned short xi, unsigned short yi, char *xpm[], unsigned short hor, short delta, unsigned short time) { if (vg_init(MODE_105) == NULL) { printf("Failed vg_init().\n"); return 1; } if (move_xpm(xi, yi, xpm, hor, delta, time) == 1) { if (vg_exit() == 1) { printf("Failed vg_exit().\n"); } printf("Wrong coordinates.\n"); return 1; } if (wait_for_ESC() == 1) { printf("Failed wait_for_ESC().\n"); return 1; } return 0; }
void *test_init(unsigned short mode, unsigned short delay) { vg_init(mode); int ipc_status; message msg; int request; int irq_set; counter = 0; irq_set = subscribe_timer(); while (counter < delay*60) { request = driver_receive(ANY, &msg, &ipc_status); if (request != 0) { printf("driver_receive failed with: %d", request); continue; } if (is_ipc_notify(ipc_status)) { switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: if (msg.NOTIFY_ARG & irq_set) { timer_handler(); } break; default: break; } } else { } } unsubscribe_timer(); vg_exit(); printf("VRAM physical address: 0x%x\n",vram_phisical_address); return 0; }
int test_xpm(unsigned short xi, unsigned short yi, char *xpm[]) { if(vg_init(MODE_105)==NULL) { printf("Failed vg_init().\n"); return 1; } if(print_xpm(xi,yi,xpm)==1) { if(vg_exit()==1) { printf("Failed vg_exit().\n"); } printf("Wrong coordinates.\n"); return 1; } if (wait_for_ESC() ==1) { printf("Failed wait_for_ESC().\n"); return 1; } return 0; }
int test_square(unsigned short x, unsigned short y, unsigned short size, unsigned long color) { if (vg_init(MODE_105) == NULL) { printf("Failed vg_init().\n"); return 1; } if(print_square(x, y, size, color)==1) { if(vg_exit()==1) { printf("Failed vg_exit().\n"); } printf("Wrong coordinates.\n"); return 1; } if (wait_for_ESC() ==1) { printf("Failed wait_for_ESC().\n"); return 1; } return 0; }
void m3_set_types(M3_UNIT *unit, const int *atype, int n) { printf("** m3_set_types is called **\n"); vg_exit(1); }
void m3_set_charges(M3_UNIT *unit, const double *q, int n) { printf("** m3_set_charges is called **\n"); vg_exit(1); }
void m3_set_cells(M3_UNIT *unit, M3_CELL *cell, int ncell) { printf("** m3_set_cells is called **\n"); vg_exit(1); }
void m3_calculate_forces(M3_UNIT *unit, double (*xi)[3], int ni, double (*force)[3]) { printf("** m3_calculate_forces is called **\n"); vg_exit(1); }
void m3_calculate_potentials(M3_UNIT *unit, double (*xi)[3], int ni, double *eng) { printf("** m3_calculate_potentials is called **\n"); vg_exit(1); }
int test_move(unsigned short xi, unsigned short yi, char *xpm[], unsigned short hor, short delta, unsigned short time) { int width, height; char* pixmap; int ipc_status; message msg; int irq_set_timer = timer_subscribe_int(); int irq_set_keyboard = kb_subscribe_int(); int r; unsigned short counter = 0; long character; float pixmap_speed, next_position; if (vg_init(VBE_VIDEO_MODE) == NULL) return 1; if ((pixmap = (char*) read_xpm(xpm, &width, &height)) == NULL) return 1; pixmap_speed = (float) (delta) / (time * 60); //TODO encontrar TICKS_PER_SEC; nao existe if (irq_set_timer >= 0) irq_set_timer = BIT(irq_set_timer); else irq_set_timer = 0; if (irq_set_keyboard >= 0) irq_set_keyboard = BIT(irq_set_keyboard); else irq_set_keyboard = 0; next_position = 0; while (counter < time && character != ESC_BREAKCODE) { /* You may want to use a different condition */ /* Get a request message. */ if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & irq_set_timer) { /* subscribed interrupt */ timed_scan_int_handler(&counter); vg_move_pixmap(xi, yi, width, height, pixmap, hor, next_position); vg_update_screen(); next_position += pixmap_speed; } if (msg.NOTIFY_ARG & irq_set_keyboard) { /* subscribed interrupt */ character = kb_int_handler(); } break; default: break; /* no other notifications expected: do nothing */ } } else { /* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } } free(pixmap); return vg_exit(); }