void archimedes_init(running_machine *machine) { memc_pagesize = 0; vbl_timer = timer_alloc(machine, vidc_vblank, NULL); timer_adjust_oneshot(vbl_timer, attotime_never, 0); timer[0] = timer_alloc(machine, ioc_timer, NULL); timer[1] = timer_alloc(machine, ioc_timer, NULL); timer[2] = timer_alloc(machine, ioc_timer, NULL); timer[3] = timer_alloc(machine, ioc_timer, NULL); timer_adjust_oneshot(timer[0], attotime_never, 0); timer_adjust_oneshot(timer[1], attotime_never, 0); timer_adjust_oneshot(timer[2], attotime_never, 0); timer_adjust_oneshot(timer[3], attotime_never, 0); snd_timer = timer_alloc(machine, a310_audio_tick, NULL); timer_adjust_oneshot(snd_timer, attotime_never, 0); }
void crt9007_t::device_start() { // allocate timers m_hsync_timer = timer_alloc(TIMER_HSYNC); m_vsync_timer = timer_alloc(TIMER_VSYNC); m_vlt_timer = timer_alloc(TIMER_VLT); m_curs_timer = timer_alloc(TIMER_CURS); m_drb_timer = timer_alloc(TIMER_DRB); m_dma_timer = timer_alloc(TIMER_DMA); // resolve callbacks m_write_int.resolve_safe(); m_write_dmar.resolve_safe(); m_write_hs.resolve_safe(); m_write_vs.resolve_safe(); m_write_vlt.resolve_safe(); m_write_curs.resolve_safe(); m_write_drb.resolve_safe(); m_write_wben.resolve_safe(); m_write_cblank.resolve_safe(); m_write_slg.resolve_safe(); m_write_sld.resolve_safe(); }
void via6522_device::device_start() { m_in_a_handler.resolve(); m_in_b_handler.resolve(); m_out_a_handler.resolve_safe(); m_out_b_handler.resolve_safe(); m_cb1_handler.resolve_safe(); m_ca2_handler.resolve_safe(); m_cb2_handler.resolve_safe(); m_irq_handler.resolve_safe(); m_t1ll = 0xf3; /* via at 0x9110 in vic20 show these values */ m_t1lh = 0xb5; /* ports are not written by kernel! */ m_t2ll = 0xff; /* taken from vice */ m_t2lh = 0xff; m_sr = 0; m_time2 = m_time1 = machine().time(); m_t1 = timer_alloc(TIMER_T1); m_t2 = timer_alloc(TIMER_T2); m_ca2_timer = timer_alloc(TIMER_CA2); m_shift_timer = timer_alloc(TIMER_SHIFT); /* Default clock is from CPU1 */ if (clock() == 0) { set_unscaled_clock(machine().firstcpu->clock()); } /* save state register */ save_item(NAME(m_in_a)); save_item(NAME(m_in_ca1)); save_item(NAME(m_in_ca2)); save_item(NAME(m_out_a)); save_item(NAME(m_out_ca2)); save_item(NAME(m_ddr_a)); save_item(NAME(m_latch_a)); save_item(NAME(m_in_b)); save_item(NAME(m_in_cb1)); save_item(NAME(m_in_cb2)); save_item(NAME(m_out_b)); save_item(NAME(m_out_cb1)); save_item(NAME(m_out_cb2)); save_item(NAME(m_ddr_b)); save_item(NAME(m_latch_b)); save_item(NAME(m_t1cl)); save_item(NAME(m_t1ch)); save_item(NAME(m_t1ll)); save_item(NAME(m_t1lh)); save_item(NAME(m_t2cl)); save_item(NAME(m_t2ch)); save_item(NAME(m_t2ll)); save_item(NAME(m_t2lh)); save_item(NAME(m_sr)); save_item(NAME(m_pcr)); save_item(NAME(m_acr)); save_item(NAME(m_ier)); save_item(NAME(m_ifr)); save_item(NAME(m_time1)); save_item(NAME(m_t1_active)); save_item(NAME(m_t1_pb7)); save_item(NAME(m_time2)); save_item(NAME(m_t2_active)); save_item(NAME(m_shift_counter)); }
void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) 0x0ff0;//the boot info saved in asmhead char s[40]; int mx, my, i, cursor_x, cursor_c; unsigned int memtotal; struct MOUSE_DEC mdec; //内存管理结构地址 struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct SHTCTL *shtctl; static char keytable0[0x80] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0 }; static char keytable1[0x80] = { 0, 0, '!', 0x22, '#', '$', '%', '&', 0x27, '(', ')', '~', '=', '~', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '`', '{', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '*', 0, 0, '}', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0 }; unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_win_b, *buf_cons; struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_win_b[3], *sht_cons; struct TASK *task_a, *task_b[3], *task_cons; struct TIMER *timer; int key_to = 0, key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1; struct FIFO32 fifo, keycmd; int fifobuf[128], keycmd_buf[32]; init_gdtidt(); init_pic();//init the programed interrupt controller. io_sti(); // enable interrupt fifo32_init(&fifo, 128, fifobuf, 0);//初始化队列 init_pit();//初始化计时器; init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec);//鼠标中断 io_out8(PIC0_IMR, 0xf8); /* PIC1 允许 0(timer),1,2号中断,屏蔽其他(11111000) */ io_out8(PIC1_IMR, 0xef); /* 允许c号中断,屏蔽其他(11101111) */ fifo32_init(&keycmd, 32, keycmd_buf, 0); //内存管理初始化 memtotal = memtest(0x00400000, 0xbfffffff); memman_init(memman); memman_free(memman, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */ memman_free(memman, 0x00400000, memtotal - 0x00400000); init_palette(); //调色板 shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny);//对图层管理结构体的初始化 task_a = task_init(memman); fifo.task = task_a; task_run(task_a,1,0); *((int *) 0x0fe4) = (int) shtctl; /* sht_back */ sht_back = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 无透明色 */ /*桌面先显示到内存中*/ init_screen8(buf_back, binfo->scrnx, binfo->scrny); /* sht_cons */ sht_cons = sheet_alloc(shtctl); buf_cons = (unsigned char *) memman_alloc_4k(memman, 256 * 165); sheet_setbuf(sht_cons, buf_cons, 256, 165, -1); /* 摟柧怓側偟 */ make_window8(buf_cons, 256, 165, "console", 0); make_textbox8(sht_cons, 8, 28, 240, 128, COL8_000000); task_cons = task_alloc(); task_cons->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 12; task_cons->tss.eip = (int) &console_task; task_cons->tss.es = 1 * 8; task_cons->tss.cs = 2 * 8; task_cons->tss.ss = 1 * 8; task_cons->tss.ds = 1 * 8; task_cons->tss.fs = 1 * 8; task_cons->tss.gs = 1 * 8; *((int *) (task_cons->tss.esp + 4)) = (int) sht_cons; *((int *) (task_cons->tss.esp + 8)) = memtotal; task_run(task_cons, 2, 2); /* level=2, priority=2 */ /* sht_mouse */ sht_mouse = sheet_alloc(shtctl); sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /*鼠标显示到内存中*/ init_mouse_cursor8(buf_mouse, 99); mx = (binfo->scrnx - 16) / 2; /* 夋柺拞墰偵側傞傛偆偵嵗昗寁嶼 */ my = (binfo->scrny - 28 - 16) / 2; /* sht_win_b */ for (i = 0; i < 3; i++) { sht_win_b[i] = sheet_alloc(shtctl); buf_win_b = (unsigned char *) memman_alloc_4k(memman, 144 * 52); sheet_setbuf(sht_win_b[i], buf_win_b, 144, 52, -1); /* 无透明 */ sprintf(s, "task_b%d", i); make_window8(buf_win_b, 144, 52, s, 0); task_b[i] = task_alloc(); task_b[i]->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 8; task_b[i]->tss.eip = (int) &task_b_main; task_b[i]->tss.es = 1 * 8; task_b[i]->tss.cs = 2 * 8; task_b[i]->tss.ss = 1 * 8; task_b[i]->tss.ds = 1 * 8; task_b[i]->tss.fs = 1 * 8; task_b[i]->tss.gs = 1 * 8; *((int *) (task_b[i]->tss.esp + 4)) = (int) sht_win_b[i]; //task_run(task_b[i],2,i+1); } /* sht_win */ sht_win = sheet_alloc(shtctl); buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_win, buf_win, 144, 52, -1); /* 摟柧怓側偟 */ make_window8(buf_win, 144, 52, "task_a", 1); make_textbox8(sht_win, 8, 28, 128, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF;//白色 timer = timer_alloc(); timer_init(timer, &fifo, 1); timer_settime(timer, 50); sheet_slide(sht_back, 0, 0); sheet_slide(sht_win_b[0], 168, 56); sheet_slide(sht_win_b[1], 8, 116); sheet_slide(sht_win_b[2], 168, 116); sheet_slide(sht_win, 8, 56); sheet_slide(sht_mouse, mx, my); sheet_slide(sht_cons, 32, 4); /*设置图层高度,并显示*/ sheet_slide(sht_back, 0, 0); sheet_slide(sht_cons, 32, 4); sheet_slide(sht_win, 64, 56); sheet_slide(sht_mouse, mx, my); sheet_updown(sht_back, 0); sheet_updown(sht_cons, 1); sheet_updown(sht_win, 2); sheet_updown(sht_mouse, 3); //键盘指示灯 fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); for (;;) { if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) { /* 如果存在向键盘控制器发送的的数据,则发送 */ keycmd_wait = fifo32_get(&keycmd); wait_KBC_sendready(); io_out8(PORT_KEYDAT, keycmd_wait); } io_cli(); if (fifo32_status(&fifo) == 0) { task_sleep(task_a); io_sti(); } else{ i = fifo32_get(&fifo); io_sti(); if (256 <= i && i <= 511) { /*键盘数据 */ if (i < 0x80 + 256) { /* 将按键编码转换成字符编码 */ if (key_shift == 0) { s[0] = keytable0[i - 256]; } else { s[0] = keytable1[i - 256]; } } else { s[0] = 0; } if ('A' <= s[0] && s[0] <= 'Z') { /* 当输入的字符为英文字母时 */ if (((key_leds & 4) == 0 && key_shift == 0) || ((key_leds & 4) != 0 && key_shift != 0)) { s[0] += 0x20; /* 将大写字母转换时为小写字母 */ } } if (s[0] != 0) { /* 一般字符 */ if (key_to == 0) { /* 发送给任务A */ if (cursor_x < 128) { s[1] = 0; putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } else { /* 发送给命令行窗口 */ fifo32_put(&task_cons->fifo, s[0] + 256); } } if (i == 256 + 0x0e) { /* 退格键 */ if (key_to == 0) { /* 发送给任务A */ if (cursor_x > 8) { /* 用白色擦出光标后将光标前移移位*/ putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } } else { /* 发送给命令窗口 */ fifo32_put(&task_cons->fifo, 8 + 256); } } if (i == 256 + 0x3a) { /* CapsLock */ key_leds ^= 4; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x45) { /* NumLock */ key_leds ^= 2; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x46) { /* ScrollLock */ key_leds ^= 1; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x0f) { /* Tab */ if (key_to == 0) { key_to = 1; make_wtitle8(buf_win, sht_win->bxsize, "task_a", 0); make_wtitle8(buf_cons, sht_cons->bxsize, "console", 1); cursor_c = -1; /* 不显示光标 */ boxfill8(sht_win->buf, sht_win->bxsize, COL8_FFFFFF, cursor_x, 28, cursor_x + 7, 43); fifo32_put(&task_cons->fifo, 2); /* 令命令行窗口光标ON */ } else { key_to = 0; make_wtitle8(buf_win, sht_win->bxsize, "task_a", 1); make_wtitle8(buf_cons, sht_cons->bxsize, "console", 0); cursor_c = COL8_000000; /* 显示光标 */ fifo32_put(&task_cons->fifo, 3); /* 令命令行窗口光标OFF */ } sheet_refresh(sht_win, 0, 0, sht_win->bxsize, 21); sheet_refresh(sht_cons, 0, 0, sht_cons->bxsize, 21); } if (i == 256 + 0x2a) { /* ON */ key_shift |= 1; } if (i == 256 + 0x36) { /* ON */ key_shift |= 2; } if (i == 256 + 0xaa) { /* OFF */ key_shift &= ~1; } if (i == 256 + 0xb6) { /* OFF */ key_shift &= ~2; } if (i == 256 + 0xfa) { /* 键盘成功接收 */ keycmd_wait = -1; } if (i == 256 + 0xfe) { /* 键盘没有成功接收到数据 */ wait_KBC_sendready(); io_out8(PORT_KEYDAT, keycmd_wait); } if (i == 256 + 0x1c) { /* Enter */ if (key_to != 0) { /* 发送命令给窗口 */ fifo32_put(&task_cons->fifo, 10 + 256); } } //重新显示光标 if (cursor_c >= 0) { boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); } sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { /* 鼠标数据 */ if (mouse_decode(&mdec, i - 512) != 0) { /* 鼠标指针移动 */ mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (my < 0) { my = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } sheet_slide(sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { /* 始终定位鼠标的左上角 */ sheet_slide(sht_win, mx - 80, my - 8); } } }else if (i <= 1) { /* 光标定时器 */ if (i != 0) { timer_init(timer, &fifo, 0); /* 下次置0 */ if (cursor_c >= 0) { cursor_c = COL8_000000; } } else { timer_init(timer, &fifo, 1); /* 下次置1 */ if (cursor_c >= 0) { cursor_c = COL8_FFFFFF; } } timer_settime(timer, 50); if (cursor_c >= 0) { boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } } }
void sms_light_phaser_device::device_start() { save_item(NAME(m_sensor_last_state)); m_lphaser_timer = timer_alloc(TIMER_LPHASER); }
void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; struct SHTCTL *shtctl; char s[40]; struct FIFO32 fifo, keycmd; int fifobuf[128], keycmd_buf[32]; int mx, my, i, cursor_x, cursor_c; unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_cons; struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_cons; struct TASK *task_a, *task_cons; struct TIMER *timer; static char keytable0[0x80] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0 }; static char keytable1[0x80] = { 0, 0, '!', 0x22, '#', '$', '%', '&', 0x27, '(', ')', '~', '=', '~', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '`', '{', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '*', 0, 0, '}', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0 }; int key_to = 0, key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1; struct CONSOLE *cons; init_gdtidt(); init_pic(); io_sti(); /* IDT/PICの初期化が終わったのでCPUの割り込み禁止を解除 */ fifo32_init(&fifo, 128, fifobuf, 0); init_pit(); init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); /* PITとPIC1とキーボードを許可(11111000) */ io_out8(PIC1_IMR, 0xef); /* マウスを許可(11101111) */ fifo32_init(&keycmd, 32, keycmd_buf, 0); memtotal = memtest(0x00400000, 0xbfffffff); memman_init(memman); memman_free(memman, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */ memman_free(memman, 0x00400000, memtotal - 0x00400000); init_palette(); shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); task_a = task_init(memman); fifo.task = task_a; task_run(task_a, 1, 2); *((int *) 0x0fe4) = (int) shtctl; /* sht_back */ sht_back = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 透明色なし */ init_screen8(buf_back, binfo->scrnx, binfo->scrny); /* sht_cons */ sht_cons = sheet_alloc(shtctl); buf_cons = (unsigned char *) memman_alloc_4k(memman, 256 * 165); sheet_setbuf(sht_cons, buf_cons, 256, 165, -1); /* 透明色なし */ make_window8(buf_cons, 256, 165, "console", 0); make_textbox8(sht_cons, 8, 28, 240, 128, COL8_000000); task_cons = task_alloc(); task_cons->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 12; task_cons->tss.eip = (int) &console_task; task_cons->tss.es = 1 * 8; task_cons->tss.cs = 2 * 8; task_cons->tss.ss = 1 * 8; task_cons->tss.ds = 1 * 8; task_cons->tss.fs = 1 * 8; task_cons->tss.gs = 1 * 8; *((int *) (task_cons->tss.esp + 4)) = (int) sht_cons; *((int *) (task_cons->tss.esp + 8)) = memtotal; task_run(task_cons, 2, 2); /* level=2, priority=2 */ /* sht_win */ sht_win = sheet_alloc(shtctl); buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_win, buf_win, 144, 52, -1); /* 透明色なし */ make_window8(buf_win, 144, 52, "task_a", 1); make_textbox8(sht_win, 8, 28, 128, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF; timer = timer_alloc(); timer_init(timer, &fifo, 1); timer_settime(timer, 50); /* sht_mouse */ sht_mouse = sheet_alloc(shtctl); sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); init_mouse_cursor8(buf_mouse, 99); mx = (binfo->scrnx - 16) / 2; /* 画面中央になるように座標計算 */ my = (binfo->scrny - 28 - 16) / 2; sheet_slide(sht_back, 0, 0); sheet_slide(sht_cons, 32, 4); sheet_slide(sht_win, 64, 56); sheet_slide(sht_mouse, mx, my); sheet_updown(sht_back, 0); sheet_updown(sht_cons, 1); sheet_updown(sht_win, 2); sheet_updown(sht_mouse, 3); /* 最初にキーボード状態との食い違いがないように、設定しておくことにする */ fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); for (;;) { if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) { /* キーボードコントローラに送るデータがあれば、送る */ keycmd_wait = fifo32_get(&keycmd); wait_KBC_sendready(); io_out8(PORT_KEYDAT, keycmd_wait); } io_cli(); if (fifo32_status(&fifo) == 0) { task_sleep(task_a); io_sti(); } else { i = fifo32_get(&fifo); io_sti(); if (256 <= i && i <= 511) { /* キーボードデータ */ if (i < 0x80 + 256) { /* キーコードを文字コードに変換 */ if (key_shift == 0) { s[0] = keytable0[i - 256]; } else { s[0] = keytable1[i - 256]; } } else { s[0] = 0; } if ('A' <= s[0] && s[0] <= 'Z') { /* 入力文字がアルファベット */ if (((key_leds & 4) == 0 && key_shift == 0) || ((key_leds & 4) != 0 && key_shift != 0)) { s[0] += 0x20; /* 大文字を小文字に変換 */ } } if (s[0] != 0) { /* 通常文字 */ if (key_to == 0) { /* タスクAへ */ if (cursor_x < 128) { /* 一文字表示してから、カーソルを1つ進める */ s[1] = 0; putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } else { /* コンソールへ */ fifo32_put(&task_cons->fifo, s[0] + 256); } } if (i == 256 + 0x0e) { /* バックスペース */ if (key_to == 0) { /* タスクAへ */ if (cursor_x > 8) { /* カーソルをスペースで消してから、カーソルを1つ戻す */ putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } } else { /* コンソールへ */ fifo32_put(&task_cons->fifo, 8 + 256); } } if (i == 256 + 0x1c) { /* Enter */ if (key_to != 0) { /* コンソールへ */ fifo32_put(&task_cons->fifo, 10 + 256); } } if (i == 256 + 0x0f) { /* Tab */ if (key_to == 0) { key_to = 1; make_wtitle8(buf_win, sht_win->bxsize, "task_a", 0); make_wtitle8(buf_cons, sht_cons->bxsize, "console", 1); cursor_c = -1; /* カーソルを消す */ boxfill8(sht_win->buf, sht_win->bxsize, COL8_FFFFFF, cursor_x, 28, cursor_x + 7, 43); fifo32_put(&task_cons->fifo, 2); /* コンソールのカーソルON */ } else { key_to = 0; make_wtitle8(buf_win, sht_win->bxsize, "task_a", 1); make_wtitle8(buf_cons, sht_cons->bxsize, "console", 0); cursor_c = COL8_000000; /* カーソルを出す */ fifo32_put(&task_cons->fifo, 3); /* コンソールのカーソルOFF */ } sheet_refresh(sht_win, 0, 0, sht_win->bxsize, 21); sheet_refresh(sht_cons, 0, 0, sht_cons->bxsize, 21); } if (i == 256 + 0x2a) { /* 左シフト ON */ key_shift |= 1; } if (i == 256 + 0x36) { /* 右シフト ON */ key_shift |= 2; } if (i == 256 + 0xaa) { /* 左シフト OFF */ key_shift &= ~1; } if (i == 256 + 0xb6) { /* 右シフト OFF */ key_shift &= ~2; } if (i == 256 + 0x3a) { /* CapsLock */ key_leds ^= 4; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x45) { /* NumLock */ key_leds ^= 2; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x46) { /* ScrollLock */ key_leds ^= 1; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x3b && key_shift != 0 && task_cons->tss.ss0 != 0) { /* Shift+F1 */ cons = (struct CONSOLE *) *((int *) 0x0fec); cons_putstr0(cons, "\nBreak(key) :\n"); io_cli(); /* 強制終了処理中にタスクが変わると困るから */ task_cons->tss.eax = (int) &(task_cons->tss.esp0); task_cons->tss.eip = (int) asm_end_app; io_sti(); } if (i == 256 + 0x57 && shtctl->top > 2) { /* F11 */ sheet_updown(shtctl->sheets[1], shtctl->top - 1); } if (i == 256 + 0xfa) { /* キーボードがデータを無事に受け取った */ keycmd_wait = -1; } if (i == 256 + 0xfe) { /* キーボードがデータを無事に受け取れなかった */ wait_KBC_sendready(); io_out8(PORT_KEYDAT, keycmd_wait); } /* カーソルの再表示 */ if (cursor_c >= 0) { boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); } sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { /* マウスデータ */ if (mouse_decode(&mdec, i - 512) != 0) { /* マウスカーソルの移動 */ mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (my < 0) { my = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } sheet_slide(sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { /* 左ボタンを押していたら、sht_winを動かす */ sheet_slide(sht_win, mx - 80, my - 8); } } } else if (i <= 1) { /* カーソル用タイマ */ if (i != 0) { timer_init(timer, &fifo, 0); /* 次は0を */ if (cursor_c >= 0) { cursor_c = COL8_000000; } } else { timer_init(timer, &fifo, 1); /* 次は1を */ if (cursor_c >= 0) { cursor_c = COL8_FFFFFF; } } timer_settime(timer, 50); if (cursor_c >= 0) { boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } } }
DRIVER_INIT_MEMBER(ti990_4_state, ti990_4) { m_nmi_timer = timer_alloc(NMI_TIMER_ID); }
void a2bus_transwarp_device::device_start() { m_timer = timer_alloc(0); save_item(NAME(m_bEnabled)); }
void s6_state::init_s6() { m_irq_timer = timer_alloc(TIMER_IRQ); m_irq_timer->adjust(attotime::from_ticks(980,3580000/4),1); }
void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; struct FIFO32 fifo; char s[40]; int fifobuf[128]; struct TIMER *timer, *timer2, *timer3; int mx, my, i, cursor_x, cursor_c, task_b_esp; unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct SHTCTL *shtctl; struct SHEET *sht_back, *sht_mouse, *sht_win; unsigned char *buf_back, buf_mouse[256], *buf_win; static char keytable[0x54] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.' }; struct TSS32 tss_a, tss_b; struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT; init_gdtidt(); init_pic(); io_sti(); fifo32_init(&fifo, 128, fifobuf); init_pit(); init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); io_out8(PIC1_IMR, 0xef); timer = timer_alloc(); timer_init(timer, &fifo, 10); timer_settime(timer, 1000); timer2 = timer_alloc(); timer_init(timer2, &fifo, 3); timer_settime(timer2, 300); timer3 = timer_alloc(); timer_init(timer3, &fifo, 1); timer_settime(timer3, 50); memtotal = memtest(0x00400000, 0xbfffffff); memman_init(memman); memman_free(memman, 0x00001000, 0x0009e000); memman_free(memman, 0x00400000, memtotal - 0x00400000); init_palette(); shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); sht_back = sheet_alloc(shtctl); sht_mouse = sheet_alloc(shtctl); sht_win = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); sheet_setbuf(sht_win, buf_win, 160, 52, -1); init_screen8(buf_back, binfo->scrnx, binfo->scrny); init_mouse_cursor8(buf_mouse, 99); make_window8(buf_win, 160, 52, "window"); make_textbox8(sht_win, 8, 28, 144, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF; sheet_slide(sht_back, 0, 0); mx = (binfo->scrnx - 16) / 2; my = (binfo->scrny - 28 - 16) / 2; sheet_slide(sht_mouse, mx, my); sheet_slide(sht_win, 80, 72); sheet_updown(sht_back, 0); sheet_updown(sht_win, 1); sheet_updown(sht_mouse, 2); sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sprintf(s, "memory %dMB free : %dKB" , memtotal / (1024 * 1024), memman_total(memman) / 1024); putfonts8_asc_sht(sht_back, 0, 32, COL8_FFFFFF, COL8_008484, s, 40); tss_a.ldtr = 0; tss_a.iomap = 0x40000000; tss_b.ldtr = 0; tss_b.iomap = 0x40000000; set_segmdesc(gdt + 3, 103, (int) &tss_a, AR_TSS32); set_segmdesc(gdt + 4, 103, (int) &tss_b, AR_TSS32); load_tr(3 * 8); task_b_esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024; tss_b.eip = (int) &task_b_main; tss_b.eflags = 0x00000202; tss_b.eax = 0; tss_b.ecx = 0; tss_b.edx = 0; tss_b.ebx = 0; tss_b.esp = task_b_esp; tss_b.ebp = 0; tss_b.esi = 0; tss_b.edi = 0; tss_b.es = 1 * 8; tss_b.cs = 2 * 8; tss_b.ss = 1 * 8; tss_b.ds = 1 * 8; tss_b.fs = 1 * 8; tss_b.gs = 1 * 8; for (;;) { io_cli(); if (fifo32_status(&fifo) == 0) { io_stihlt(); } else { i = fifo32_get(&fifo); io_sti(); if (256 <=i && i <= 511) { sprintf(s, "%02X", i - 256); putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); if (i < 0x54 + 256) { if (keytable[i - 256] != 0 && cursor_x < 144) { s[0] = keytable[i - 256]; s[1] = 0; putfonts8_asc_sht(sht_win, cursor_x , 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } if (i == 256 + 0x0e && cursor_x > 8) { putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { if (mouse_decode(&mdec, i - 512) != 0) { sprintf(s, "[lcr %4d %4d]", mdec.x, mdec.y); if ((mdec.btn & 0x01) != 0) { s[1] = 'L'; } if ((mdec.btn & 0x02) != 0) { s[3] = 'R'; } if ((mdec.btn & 0x04) != 0) { s[2] = 'C'; } putfonts8_asc_sht(sht_back, 32, 16, COL8_FFFFFF, COL8_008484, s, 15); mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (my < 0) { my = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sheet_slide(sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { sheet_slide(sht_win, mx - 80, my - 8); } } } else if (i == 10) { putfonts8_asc_sht(sht_back, 0, 64, COL8_FFFFFF, COL8_008484, "10[sec]", 7); taskswitch4(); } else if (i == 3) { putfonts8_asc_sht(sht_back, 0, 80, COL8_FFFFFF, COL8_008484, "3[sec]", 6); } else if (i <= 1) { if (i != 0) { timer_init(timer3, &fifo, 0); cursor_c = COL8_000000; } else { timer_init(timer3, &fifo, 1); cursor_c = COL8_FFFFFF; } timer_settime(timer3, 50); boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } }
void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; struct FIFO32 fifo; char s[40]; int fifobuf[128]; int mx, my, i, cursor_x, cursor_c; unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct SHTCTL *shtctl; static char keytable[0x54] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.' }; unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_win_b; struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_win_b[3]; struct TASK *task_a, *task_b[3]; struct TIMER *timer; init_gdtidt(); init_pic(); io_sti(); /* IDT/PICの初期化が終わったのでCPUの割り込み禁止を解除 */ fifo32_init(&fifo, 128, fifobuf, 0); init_pit(); init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); /* PITとPIC1とキーボードを許可(11111000) */ io_out8(PIC1_IMR, 0xef); /* マウスを許可(11101111) */ memtotal = memtest(0x00400000, 0xbfffffff); memman_init(memman); memman_free(memman, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */ memman_free(memman, 0x00400000, memtotal - 0x00400000); init_palette(); shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); task_a = task_init(memman); fifo.task = task_a; /* sht_back */ sht_back = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 透明色なし */ init_screen8(buf_back, binfo->scrnx, binfo->scrny); /* sht_win_b */ for (i = 0; i < 3; i++) { sht_win_b[i] = sheet_alloc(shtctl); buf_win_b = (unsigned char *) memman_alloc_4k(memman, 144 * 52); sheet_setbuf(sht_win_b[i], buf_win_b, 144, 52, -1); /* 透明色なし */ sprintf(s, "task_b%d", i); make_window8(buf_win_b, 144, 52, s, 0); task_b[i] = task_alloc(); task_b[i]->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 8; task_b[i]->tss.eip = (int) &task_b_main; task_b[i]->tss.es = 1 * 8; task_b[i]->tss.cs = 2 * 8; task_b[i]->tss.ss = 1 * 8; task_b[i]->tss.ds = 1 * 8; task_b[i]->tss.fs = 1 * 8; task_b[i]->tss.gs = 1 * 8; *((int *) (task_b[i]->tss.esp + 4)) = (int) sht_win_b[i]; task_run(task_b[i]); } /* sht_win */ sht_win = sheet_alloc(shtctl); buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_win, buf_win, 144, 52, -1); /* 透明色なし */ make_window8(buf_win, 144, 52, "task_a", 1); make_textbox8(sht_win, 8, 28, 128, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF; timer = timer_alloc(); timer_init(timer, &fifo, 1); timer_settime(timer, 50); /* sht_mouse */ sht_mouse = sheet_alloc(shtctl); sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); init_mouse_cursor8(buf_mouse, 99); mx = (binfo->scrnx - 16) / 2; /* 画面中央になるように座標計算 */ my = (binfo->scrny - 28 - 16) / 2; sheet_slide(sht_back, 0, 0); sheet_slide(sht_win_b[0], 168, 56); sheet_slide(sht_win_b[1], 8, 116); sheet_slide(sht_win_b[2], 168, 116); sheet_slide(sht_win, 8, 56); sheet_slide(sht_mouse, mx, my); sheet_updown(sht_back, 0); sheet_updown(sht_win_b[0], 1); sheet_updown(sht_win_b[1], 2); sheet_updown(sht_win_b[2], 3); sheet_updown(sht_win, 4); sheet_updown(sht_mouse, 5); sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sprintf(s, "memory %dMB free : %dKB", memtotal / (1024 * 1024), memman_total(memman) / 1024); putfonts8_asc_sht(sht_back, 0, 32, COL8_FFFFFF, COL8_008484, s, 40); for (;;) { io_cli(); if (fifo32_status(&fifo) == 0) { task_sleep(task_a); io_sti(); } else { i = fifo32_get(&fifo); io_sti(); if (256 <= i && i <= 511) { /* キーボードデータ */ sprintf(s, "%02X", i - 256); putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); if (i < 0x54 + 256) { if (keytable[i - 256] != 0 && cursor_x < 128) { /* 通常文字 */ /* 一文字表示してから、カーソルを1つ進める */ s[0] = keytable[i - 256]; s[1] = 0; putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } if (i == 256 + 0x0e && cursor_x > 8) { /* バックスペース */ /* カーソルをスペースで消してから、カーソルを1つ戻す */ putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } /* カーソルの再表示 */ boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { /* マウスデータ */ if (mouse_decode(&mdec, i - 512) != 0) { /* データが3バイト揃ったので表示 */ sprintf(s, "[lcr %4d %4d]", mdec.x, mdec.y); if ((mdec.btn & 0x01) != 0) { s[1] = 'L'; } if ((mdec.btn & 0x02) != 0) { s[3] = 'R'; } if ((mdec.btn & 0x04) != 0) { s[2] = 'C'; } putfonts8_asc_sht(sht_back, 32, 16, COL8_FFFFFF, COL8_008484, s, 15); /* マウスカーソルの移動 */ mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (my < 0) { my = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sheet_slide(sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { /* 左ボタンを押していたら、sht_winを動かす */ sheet_slide(sht_win, mx - 80, my - 8); } } } else if (i <= 1) { /* カーソル用タイマ */ if (i != 0) { timer_init(timer, &fifo, 0); /* 次は0を */ cursor_c = COL8_000000; } else { timer_init(timer, &fifo, 1); /* 次は1を */ cursor_c = COL8_FFFFFF; } timer_settime(timer, 50); boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } }
void console_task(struct SHEET *sheet, unsigned int memtotal) { struct TIMER *timer; struct TASK *task = task_now(); struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; int i, fifobuf[128], *fat = (int *) memman_alloc_4k(memman, 4 * 2880); struct CONSOLE cons; char cmdline[30]; cons.sht = sheet; cons.cur_x = 8; cons.cur_y = 28; cons.cur_c = -1; *((int *) 0x0fec) = (int) &cons; fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); timer_init(timer, &task->fifo, 1); timer_settime(timer, 50); file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200)); /* プロンプト表示 */ cons_putchar(&cons, '>', 1); for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { task_sleep(task); io_sti(); } else { i = fifo32_get(&task->fifo); io_sti(); if (i <= 1) { /* カーソル用タイマ */ if (i != 0) { timer_init(timer, &task->fifo, 0); /* 次は0を */ if (cons.cur_c >= 0) { cons.cur_c = COL8_FFFFFF; } } else { timer_init(timer, &task->fifo, 1); /* 次は1を */ if (cons.cur_c >= 0) { cons.cur_c = COL8_000000; } } timer_settime(timer, 50); } if (i == 2) { /* カーソルON */ cons.cur_c = COL8_FFFFFF; } if (i == 3) { /* カーソルOFF */ boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15); cons.cur_c = -1; } if (256 <= i && i <= 511) { /* キーボードデータ(タスクA経由) */ if (i == 8 + 256) { /* バックスペース */ if (cons.cur_x > 16) { /* カーソルをスペースで消してから、カーソルを1つ戻す */ cons_putchar(&cons, ' ', 0); cons.cur_x -= 8; } } else if (i == 10 + 256) { /* Enter */ /* カーソルをスペースで消してから改行する */ cons_putchar(&cons, ' ', 0); cmdline[cons.cur_x / 8 - 2] = 0; cons_newline(&cons); cons_runcmd(cmdline, &cons, fat, memtotal); /* コマンド実行 */ /* プロンプト表示 */ cons_putchar(&cons, '>', 1); } else { /* 一般文字 */ if (cons.cur_x < 240) { /* 一文字表示してから、カーソルを1つ進める */ cmdline[cons.cur_x / 8 - 2] = i - 256; cons_putchar(&cons, i - 256, 1); } } } /* カーソル再表示 */ if (cons.cur_c >= 0) { boxfill8(sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15); } sheet_refresh(sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16); } } }
int sound_start(void) { #if 0 /* forQUASI88 */ int totalsound = 0; int i; /* Verify the order of entries in the sndintf[] array */ for (i = 0;i < SOUND_COUNT;i++) { if (sndintf[i].sound_num != i) { int j; logerror("Sound #%d wrong ID %d: check enum SOUND_... in src/sndintrf.h!\n",i,sndintf[i].sound_num); for (j = 0; j < i; j++) logerror("ID %2d: %s\n", j, sndintf[j].name); return 1; } } /* samples will be read later if needed */ Machine->samples = 0; refresh_period = TIME_IN_HZ(Machine->drv->frames_per_second); refresh_period_inv = 1.0 / refresh_period; sound_update_timer = timer_alloc(NULL); #endif /* forQUASI88 */ #if 1 /* forQUASI88 */ #ifndef USE_FMGEN if( use_fmgen ){ if(verbose_proc) printf("(cisc's Fmgen liblary not available)..."); use_fmgen = 0; } #endif /* set interface parameter ( volume, mono/stereo, and so on ) */ /* set interface parameter and set xmame interface function */ #ifdef USE_FMGEN if( use_fmgen ){ if( sound_board==SOUND_I ){ /* fmgen ym2203 */ fm_interface = pc88_fmgen_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_fmgen_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; }else{ /* fmgen ym2608 */ fm_interface = pc88_fmgen2_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_fmgen2_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; } }else #endif { if( sound_board==SOUND_I ){ /* xmame ym2203 */ fm_interface = pc88_sound_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_sound_func; Machine__drv__sound_attributes = 0; }else{ /* xmame ym2608 */ fm_interface = pc88_sound2_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_sound2_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; } } /* set volume ( fm, psg, beep ) */ if( sound_board==SOUND_I ){ if( Machine__drv__sound_attributes == 0) ym2203_interface.mixing_level[0] = YM2203_VOL(fmvol,psgvol); else ym2203_interface.mixing_level[0] = YM3012_VOL(fmvol,MIXER_PAN_LEFT,fmvol,MIXER_PAN_RIGHT); }else{ ym2608_interface.volumeSSG[0] = psgvol; ym2608_interface.volumeFM[0] = YM3012_VOL(fmvol,MIXER_PAN_LEFT,fmvol,MIXER_PAN_RIGHT); } beep88_interface.mixing_level[0] = beepvol; #endif /* forQUASI88 */ if (mixer_sh_start() != 0) return 1; if (streams_sh_start() != 0) return 1; #if 0 /* forQUASI88 */ while (Machine->drv->sound[totalsound].sound_type != 0 && totalsound < MAX_SOUND) { if ((*sndintf[Machine->drv->sound[totalsound].sound_type].start)(&Machine->drv->sound[totalsound]) != 0) goto getout; totalsound++; } #else /* forQUASI88 */ { if ((*sndintf[ fm_interface.sound_type ].start)(&fm_interface) != 0) goto getout; if ((*sndintf[ beep_interface.sound_type ].start)(&beep_interface) != 0) goto getout; } #endif /* forQUASI88 */ return 0; getout: /* TODO: should also free the resources allocated before */ return 1; }
static int my_YM2151_sh_start(const struct MachineSound *msound,int mode) { int i,j; int rate = Machine->sample_rate; char buf[YM2151_NUMBUF][40]; const char *name[YM2151_NUMBUF]; int mixed_vol,vol[YM2151_NUMBUF]; if( rate == 0 ) rate = 1000; /* kludge to prevent nasty crashes */ intf = msound->sound_interface; if( mode ) FMMode = CHIP_YM2151_ALT; else FMMode = CHIP_YM2151_DAC; switch(FMMode) { #if (HAS_YM2151) case CHIP_YM2151_DAC: /* Tatsuyuki's */ /* stream system initialize */ for (i = 0;i < intf->num;i++) { mixed_vol = intf->volume[i]; /* stream setup */ for (j = 0 ; j < YM2151_NUMBUF ; j++) { name[j]=buf[j]; vol[j] = mixed_vol & 0xffff; mixed_vol>>=16; sprintf(buf[j],"%s #%d Ch%d",sound_name(msound),i,j+1); } stream[i] = stream_init_multi(YM2151_NUMBUF, name,vol,rate,i,OPMUpdateOne); } /* Set Timer handler */ for (i = 0; i < intf->num; i++) { Timer[i][0] = timer_alloc(timer_callback_2151); Timer[i][1] = timer_alloc(timer_callback_2151); } if (OPMInit(intf->num,intf->baseclock,Machine->sample_rate,TimerHandler,IRQHandler) == 0) { /* set port handler */ for (i = 0; i < intf->num; i++) OPMSetPortHander(i,intf->portwritehandler[i]); return 0; } /* error */ return 1; #endif #if (HAS_YM2151_ALT) case CHIP_YM2151_ALT: /* Jarek's */ if (options.use_filter) rate = intf->baseclock/64; /* stream system initialize */ for (i = 0;i < intf->num;i++) { /* stream setup */ mixed_vol = intf->volume[i]; for (j = 0 ; j < YM2151_NUMBUF ; j++) { name[j]=buf[j]; vol[j] = mixed_vol & 0xffff; mixed_vol>>=16; sprintf(buf[j],"%s #%d Ch%d",sound_name(msound),i,j+1); } stream[i] = stream_init_multi(YM2151_NUMBUF, name,vol,rate,i,YM2151UpdateOne); } if (YM2151Init(intf->num,intf->baseclock,rate) == 0) { for (i = 0; i < intf->num; i++) { YM2151SetIrqHandler(i,intf->irqhandler[i]); YM2151SetPortWriteHandler(i,intf->portwritehandler[i]); } return 0; } return 1; #endif } return 1; }
void HariMain(void) { boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO; fifo32_t fifo, keycmd; int fifobuf[128], keycmd_buf[32]; char debug_info[64]; int mouse_x, mouse_y, cursor_x, cursor_c; int data; mouse_dec_t mdec; unsigned int memory_total; mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR; layer_mgr_t* layer_mgr; layer_t* back_layer; layer_t* mouse_layer; layer_t* win_layer; layer_t* cons_layer; unsigned char* back_buf; unsigned char mouse_buf[256]; unsigned char* win_buf; unsigned char* cons_buf; static char s_keytable[0x80] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'','`', 0, '\\','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static char s_keytable_shift[0x80] = { 0, 0, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '\"','~', 0, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; task_t* task_a; task_t* task_cons; timer_t* timer; int key_to = 0, key_shift = 0; int key_leds = (binfo->leds >> 4) & 7; /* CapsLock state */ int keycmd_wait = -1; console_t* console; int j, x, y; int movemode_x = -1, movemode_y = -1; layer_t* layer = 0; init_gdt_idt(); init_pic(); io_sti(); /* after initialize IDT/PIC, allow all CPU's interruptors */ fifo_init(&fifo, fifobuf, 128, 0); init_pit(); /* initialize programmable interval timer */ init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); /* set PIT/PIC1/keyboard permission 11111000 */ io_out8(PIC1_IMR, 0xef); /* set mouse permission 11101111 */ fifo_init(&keycmd, keycmd_buf, 32, 0); memory_total = memory_test(0x00400000, 0xbfffffff); mem_mgr_init(mem_mgr); mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000); /*0x00001000~0x0009e000*/ mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000); init_palette(); layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, binfo->screen_x, binfo->screen_y); task_a = task_init(mem_mgr); fifo.task = task_a; task_run(task_a, 1, 2); *((int*)0x0fe4) = (int)layer_mgr; /* back layer */ back_layer = layer_alloc(layer_mgr); back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, binfo->screen_x * binfo->screen_y); layer_setbuf(back_layer, back_buf, binfo->screen_x, binfo->screen_y, -1); init_screen(back_buf, binfo->screen_x, binfo->screen_y); /* console task */ cons_layer = layer_alloc(layer_mgr); cons_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 256 * 165); layer_setbuf(cons_layer, cons_buf, 256, 165, -1); /* transparent */ make_window8(cons_buf, 256, 165, "Console", 0); make_text8(cons_layer, 8, 28, 240, 128, COLOR8_000000); task_cons = task_alloc(); task_cons->tss.esp = mem_mgr_alloc_4k(mem_mgr, 64 * 1024) + 64 * 1024 - 12; task_cons->tss.eip = (int)&console_task; task_cons->tss.es = 1 * 8; task_cons->tss.cs = 2 * 8; task_cons->tss.ss = 1 * 8; task_cons->tss.ds = 1 * 8; task_cons->tss.fs = 1 * 8; task_cons->tss.gs = 1 * 8; *((int*)(task_cons->tss.esp + 4)) = (int)cons_layer; *((int*)(task_cons->tss.esp + 8)) = memory_total; task_run(task_cons, 2, 2); /* level = 2, priority = 2 */ /* window layer */ win_layer = layer_alloc(layer_mgr); win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52); layer_setbuf(win_layer, win_buf, 144, 52, -1); make_window8(win_buf, 144, 52, "TASK-A", 1); make_text8(win_layer, 8, 28, 128, 16, COLOR8_FFFFFF); cursor_x = 8; cursor_c = COLOR8_FFFFFF; timer = timer_alloc(); timer_init(timer, &fifo, 1); timer_settimer(timer, 50); /* mouse layer */ mouse_layer = layer_alloc(layer_mgr); layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99); init_mouse_cursor8(mouse_buf, 99); mouse_x = (binfo->screen_x - 16) / 2; mouse_y = (binfo->screen_y - 28 - 16) / 2; layer_slide(back_layer, 0, 0); layer_slide(cons_layer, 32, 4); layer_slide(win_layer, 64, 56); layer_slide(mouse_layer, mouse_x, mouse_y); layer_updown(back_layer, 0); layer_updown(cons_layer, 1); layer_updown(win_layer, 2); layer_updown(mouse_layer, 3); fifo_put(&keycmd, KEYCMD_LED); fifo_put(&keycmd, key_leds); for ( ; ; ) { if (fifo_size(&keycmd) > 0 && keycmd_wait < 0) { /* send it when send data to keyboard controller */ keycmd_wait = fifo_get(&keycmd); wait_kbc_sendready(); io_out8(PORT_KEYDATA, keycmd_wait); } io_cli(); if (0 == fifo_size(&fifo)) { task_sleep(task_a); io_sti(); } else { data = fifo_get(&fifo); io_sti(); if (256 <= data && data <= 511) { if (data < (256 + 0x80)) { /* translation character */ if (0 == key_shift) debug_info[0] = s_keytable[data - 256]; else debug_info[0] = s_keytable_shift[data - 256]; } else debug_info[0] = 0; if ('A' <= debug_info[0] && debug_info[0] <= 'Z') { /* it's an english character */ if ((0 == (key_leds & 4) && 0 == key_shift) || (0 != (key_leds & 4) && 0 != key_shift)) debug_info[0] += 0x20; /* character lower ('A' -> 'a') */ } if (0 != debug_info[0]) { /* general character */ if (0 == key_to) { /* send character data to TASK-A */ if (cursor_x < 128) { /* display one character and cursor move backward one */ debug_info[1] = 0; drawstring_and_refresh(win_layer, cursor_x, 28, COLOR8_000000, COLOR8_FFFFFF, debug_info, 1); cursor_x += 8; } } else /* send character data to console window */ fifo_put(&task_cons->fifo, debug_info[0] + 256); } if ((256 + 0x0e) == data) { /* backspace, recover cursor by sapce, move back cursor 1 time */ if (0 == key_to) { if (cursor_x > 8) { drawstring_and_refresh(win_layer, cursor_x, 28, COLOR8_000000, COLOR8_FFFFFF, " ", 1); cursor_x -= 8; } } else fifo_put(&task_cons->fifo, 8 + 256); } if ((256 + 0x1c) == data) { /* Enter Key */ if (0 != key_to) /* send to Console window */ fifo_put(&task_cons->fifo, 10 + 256); } if ((256 + 0x0f) == data) { /* TAB */ if (0 == key_to) { key_to = 1; make_title8(win_buf, win_layer->w_size, "TASK-A", 0); make_title8(cons_buf, cons_layer->w_size, "Console", 1); cursor_c = -1; /* don't show the cursor */ fill_box8(win_layer->buf, win_layer->w_size, COLOR8_FFFFFF, cursor_x, 28, cursor_x + 7, 43); fifo_put(&task_cons->fifo, 2); /* console cursor -> ON */ } else { key_to = 0; make_title8(win_buf, win_layer->w_size, "TASK-A", 1); make_title8(cons_buf, cons_layer->w_size, "Console", 0); cursor_c = COLOR8_000000; /* show the cursor */ fifo_put(&task_cons->fifo, 3); /* console cursor -> OFF */ } layers_refresh(win_layer, 0, 0, win_layer->w_size, 21); layers_refresh(cons_layer, 0, 0, cons_layer->w_size, 21); } if ((256 + 0x2a) == data) /* left shift down */ key_shift |= 1; if ((256 + 0x36) == data) /* right shift down */ key_shift |= 2; if ((256 + 0xaa) == data) /* left shift up */ key_shift &= ~1; if ((256 + 0xb6) == data) /* right shift up */ key_shift &= ~2; if ((256 + 0x3a) == data) { /* CapsLock */ key_leds ^= 4; fifo_put(&keycmd, KEYCMD_LED); fifo_put(&keycmd, key_leds); } if ((256 + 0x45) == data) { /* NumLock */ key_leds ^= 2; fifo_put(&keycmd, KEYCMD_LED); fifo_put(&keycmd, key_leds); } if ((256 + 0x46) == data) { /* ScrollLock */ key_leds ^= 1; fifo_put(&keycmd, KEYCMD_LED); fifo_put(&keycmd, key_leds); } if (((256 + 0x3e) == data) && (0 != key_shift) && (0 != task_cons->tss.ss0)) { /* Shift + F4 force to stop user application */ console = (console_t*)*((int*)0x0fec); console_putstr0(console, "\nbreak(key) :\n"); io_cli(); task_cons->tss.eax = (int)&(task_cons->tss.esp0); task_cons->tss.eip = (int)asm_stop_user_app; io_sti(); } if (((256 + 0x57) == data) && (layer_mgr->top > 2)) { /* F11 switch window */ layer_updown(layer_mgr->layers_addr[1], layer_mgr->top - 1); } if ((256 + 0xfa) == data) /* keyboard recevie data success */ keycmd_wait = -1; if ((256 + 0xfe) == data) { /* keyboard recevie data failed */ wait_kbc_sendready(); io_out8(PORT_KEYDATA, keycmd_wait); } /* show cursor again */ if (cursor_c >= 0) { fill_box8(win_layer->buf, win_layer->w_size, cursor_c, cursor_x, 28, cursor_x + 7, 43); } layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= data && data <= 767) { if (0 != mouse_decode(&mdec, data - 512)) { mouse_x += mdec.x; mouse_y += mdec.y; if (mouse_x < 0) mouse_x = 0; if (mouse_y < 0) mouse_y = 0; if (mouse_x > binfo->screen_x - 1) mouse_x = binfo->screen_x - 1; if (mouse_y > binfo->screen_y - 1) mouse_y = binfo->screen_y - 1; layer_slide(mouse_layer, mouse_x, mouse_y); if (0 != (mdec.state & 0x01)) { /* left click button down */ if (movemode_x < 0) { /* down left click, move window */ /* find the layer of mouse on */ for (j = layer_mgr->top - 1; j > 0; --j) { layer = layer_mgr->layers_addr[j]; x = mouse_x - layer->x; y = mouse_y - layer->y; if (0 <= x && x < layer->w_size && 0 <= y && y < layer->h_size) { if (layer->buf[y * layer->w_size + x] != layer->alpha) { layer_updown(layer, layer_mgr->top - 1); if (3 <= x && x < layer->w_size - 3 && 3 <= y && y < 21) { movemode_x = mouse_x; movemode_y = mouse_y; } if (layer->w_size - 21 <= x && x < layer->w_size - 5 && 5 <= y && y < 19) { /* click close button of the window */ if (0 != layer->task) { /* whether it's the window of application */ console = (console_t*)*((int*)0x0fec); console_putstr0(console, "\nbreak(mouse) : \n"); io_cli(); task_cons->tss.eax = (int)&task_cons->tss.esp0; task_cons->tss.eip = (int)asm_stop_user_app; io_sti(); } } break; } } } } else { /* on move mode */ x = mouse_x - movemode_x; y = mouse_y - movemode_y; layer_slide(layer, layer->x + x, layer->y + y); movemode_x = mouse_x; movemode_y = mouse_y; } } else movemode_x = -1; /* return to normal mode */ } } else if (data <= 1) { /* timer by cursor */ if (0 != data) { timer_init(timer, &fifo, 0); if (cursor_c >= 0) cursor_c = COLOR8_000000; } else { timer_init(timer, &fifo, 1); if (cursor_c >= 0) cursor_c = COLOR8_FFFFFF; } timer_settimer(timer, 50); if (cursor_c >= 0) { fill_box8(win_layer->buf, win_layer->w_size, cursor_c, cursor_x, 28, cursor_x + 7, 43); layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44); } } } } }
/* initialize ratelimit module */ static int mod_init(void) { if(rpc_register_array(rpc_methods)!=0) { LM_ERR("failed to register RPC commands\n"); return -1; } if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); return -1; } if(pl_hash_size<=0) { LM_ERR("invalid hash size parameter: %d\n", pl_hash_size); return -1; } if(pl_init_htable(1<<pl_hash_size)<0) { LM_ERR("could not allocate pipes htable\n"); return -1; } if(pl_init_db()<0) { LM_ERR("could not load pipes description\n"); return -1; } /* register timer to reset counters */ if ((pl_timer = timer_alloc()) == NULL) { LM_ERR("could not allocate timer\n"); return -1; } timer_init(pl_timer, pl_timer_handle, 0, F_TIMER_FAST); timer_add(pl_timer, MS_TO_TICKS(1000)); /* Start it after 1000ms */ /* bind the SL API */ if (sl_load_api(&slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } network_load_value = shm_malloc(sizeof(int)); if (network_load_value==NULL) { LM_ERR("oom for network_load_value\n"); return -1; } load_value = shm_malloc(sizeof(double)); if (load_value==NULL) { LM_ERR("oom for load_value\n"); return -1; } load_source = shm_malloc(sizeof(int)); if (load_source==NULL) { LM_ERR("oom for load_source\n"); return -1; } pid_kp = shm_malloc(sizeof(double)); if (pid_kp==NULL) { LM_ERR("oom for pid_kp\n"); return -1; } pid_ki = shm_malloc(sizeof(double)); if (pid_ki==NULL) { LM_ERR("oom for pid_ki\n"); return -1; } pid_kd = shm_malloc(sizeof(double)); if (pid_kd==NULL) { LM_ERR("oom for pid_kd\n"); return -1; } _pl_pid_setpoint = shm_malloc(sizeof(double)); if (_pl_pid_setpoint==NULL) { LM_ERR("oom for pid_setpoint\n"); return -1; } drop_rate = shm_malloc(sizeof(int)); if (drop_rate==NULL) { LM_ERR("oom for drop_rate\n"); return -1; } *network_load_value = 0; *load_value = 0.0; *load_source = load_source_mp; *pid_kp = 0.0; *pid_ki = -25.0; *pid_kd = 0.0; *_pl_pid_setpoint = 0.01 * (double)_pl_cfg_setpoint; *drop_rate = 0; return 0; }
int *hrb_api(int edi, int esi, int ebp, int esp, int ebx, int edx, int ecx, int eax) { struct TASK *task = task_now(); int ds_base = task->ds_base; struct CONSOLE *cons = task->cons; struct SHTCTL *shtctl = (struct SHTCTL *) *((int *) 0x0fe4); struct SHEET *sht; struct FIFO32 *sys_fifo = (struct FIFO32 *) *((int *) 0x0fec); int *reg = &eax + 1; /* 返し値 */ int i; struct FILEINFO *finfo; struct FILEHANDLE *fh; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; unsigned char *p; int *memtotal = (int *) *((int *) 0x0fe2); struct TASK *task2; struct FIFO32 *fifo; struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; int bpp = binfo->vmode; unsigned short *sp; unsigned int *ip; struct PICTURE *pic; if (edx == 1) { cons_putchar(cons, eax & 0xff, 1); } else if (edx == 2) { cons_putstr0(cons, (char *) ebx + ds_base); } else if (edx == 3) { cons_putstr1(cons, (char *) ebx + ds_base, ecx); } else if (edx == 4) { return &(task->tss.esp0); } else if (edx == 5) { sht = sheet_alloc(shtctl); sht->task = task; sht->flags |= 0x10; sheet_setbuf(sht, (char *) ebx + ds_base, esi, edi, eax); make_window((unsigned int *) ((char *) ebx + ds_base), esi, edi, (char *) ecx + ds_base, 0, 0); sht->windowname = (char *) ecx + ds_base; sheet_slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2); keywin_off(shtctl->sheets[shtctl->top - 2]); sheet_updown(sht, shtctl->top - 1); keywin_on(sht); fifo32_put(sys_fifo, 0x4000); /* key_win変更要求 */ reg[7] = (int) sht; } else if (edx == 6) { sht = (struct SHEET *) (ebx & 0xfffffffe); putfonts((unsigned int *) (sht->buf), sht->bxsize, esi, edi, get_color(1, eax), (char *) ebp + ds_base); if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + ecx * 8, edi + 16); } } else if (edx == 7) { sht = (struct SHEET *) (ebx & 0xfffffffe); boxfill((unsigned int *) (sht->buf), sht->bxsize, get_color(1, ebp), eax, ecx, esi, edi); if ((ebx & 1) == 0) { sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 8) { memman_init((struct MEMMAN *) (ebx + ds_base)); ecx &= 0xfffffff0; /* 16バイト単位にする */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 9) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ reg[7] = memman_alloc((struct MEMMAN *) (ebx + ds_base), ecx); } else if (edx == 10) { ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */ memman_free((struct MEMMAN *) (ebx + ds_base), eax, ecx); } else if (edx == 11) { sht = (struct SHEET *) (ebx & 0xfffffffe); i = get_color(1, eax); if (bpp == 8) { sht->buf[sht->bxsize * edi + esi] = get_color(bpp, i); } else if (bpp == 16) { sp = (unsigned short *) (sht->buf); sp[sht->bxsize * edi + esi] = get_color(bpp, i); } else if (bpp == 24) { ip = (unsigned int *) (sht->buf); ip[sht->bxsize * edi + esi] = get_color(bpp, i); } if ((ebx & 1) == 0) { sheet_refresh(sht, esi, edi, esi + 1, edi + 1); } } else if (edx == 12) { sht = (struct SHEET *) ebx; sheet_refresh(sht, eax, ecx, esi, edi); } else if (edx == 13) { sht = (struct SHEET *) (ebx & 0xfffffffe); hrb_api_linewin(sht, eax, ecx, esi, edi, get_color(1, ebp)); if ((ebx & 1) == 0) { if (eax > esi) { i = eax; eax = esi; esi = i; } if (ecx > edi) { i = ecx; ecx = edi; edi = i; } sheet_refresh(sht, eax, ecx, esi + 1, edi + 1); } } else if (edx == 14) { sheet_free((struct SHEET *) ebx); keywin_on(shtctl->sheets[shtctl->top - 2]); } else if (edx == 15) { for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { if (eax != 0) { /* fifoカラッポ */ task_sleep(task); /* 寝て待つ */ } else { io_sti(); reg[7] = -1; return 0; } } i = fifo32_get(&task->fifo); io_sti(); if (i <= 1) { /* カーソル用 */ /* アプリ実行中はカーソルが出ないので、いつも次は表示用の1を注文 */ timer_init(cons->timer, &task->fifo, 1); timer_settime(cons->timer, 50); } if (i == 2) { /* カーソルON */ cons->curcol = 0xffffff; } if (i == 3) { /* カーソルOFF */ cons->curcol = -1; } if (i == 4) { timer_cancel(cons->timer); io_cli(); fifo32_put(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024〜2279 */ cons->sht = 0; io_sti(); } if (i >= 256) { reg[7] = i - 256; return 0; } } } else if (edx == 16) { reg[7] = (int) timer_alloc(); ((struct TIMER *) reg[7])->flags2 = 1; /* 自動キャンセル有効 */ } else if (edx == 17) { timer_init((struct TIMER *) ebx, &task->fifo, eax + 256); } else if (edx == 18) { timer_settime((struct TIMER *) ebx, eax); } else if (edx == 19) { timer_free((struct TIMER *) ebx); } else if (edx == 20) { if (eax == 0) { /* 音を消す */ i = io_in8(0x61); io_out8(0x61, i & 0x0d); } else { i = 1193180000 / eax; io_out8(0x43, 0xb6); io_out8(0x42, i & 0xff); io_out8(0x42, i >> 8); i = io_in8(0x61); io_out8(0x61, (i | 0x03) & 0x0f); } } else if (edx == 21) {
void HariMain(void) { int i; struct BOOTINFO *binfo = (struct BOOTINFO *)0x0ff0; int xsize = (*binfo).scrnx; int ysize = (*binfo).scrny; int mx = xsize/2; int my = ysize/2; int fifobuf[128], keycmd_buf[32]; struct MOUSE_DEC mdec; unsigned char s[32]; unsigned int memtotal; struct MEMMAN *memman = (struct MEMMAN *)MEMMAN_ADDR; int cursor_x, cursor_c; int key_to = 0, key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1; struct SHTCTL *shtctl; struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_cons; unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_cons; struct TIMER *timer; struct FIFO32 fifo, keycmd; struct CONSOLE *cons; struct TASK *task_a, *task_cons; static char keytable0[0x80] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x5c, 0, 0 }; static char keytable1[0x80] = { 0, 0, '!', 0x22, '#', '$', '%', '&', 0x27, '(', ')', '~', '=', '~', 0x08, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '`', '{', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '*', 0, 0, '}', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0 }; init_gdtidt (); init_pic (); io_sti (); fifo32_init(&fifo, 32, fifobuf, 0); fifo32_init(&keycmd, 32, keycmd_buf, 0); init_pit(); io_out8(PIC0_IMR, 0xf8); /* Allow PIT and Keyboard (11111000) */ io_out8(PIC1_IMR, 0xef); /* Allow Mouse (11101111) */ init_keyboard (&fifo, 256); enable_mouse (&fifo, 512, &mdec); timer = timer_alloc(); timer_init(timer, &fifo, 1); timer_settime(timer, 50); memtotal = memtest(0x00400000, 0xbfffffff); memman_init (memman); memman_free (memman, 0x00001000, 0x009e000); /* 0x00001000 - 0x0009efff */ memman_free (memman, 0x00400000, memtotal - 0x00400000); init_pallete(); shtctl = shtctl_init (memman, binfo->vram, binfo->scrnx, binfo->scrny); sht_back = sheet_alloc(shtctl); sht_mouse = sheet_alloc(shtctl); sht_win = sheet_alloc(shtctl); buf_back = (unsigned char *)memman_alloc_4k (memman, binfo->scrnx * binfo->scrny); buf_win = (unsigned char *)memman_alloc_4k (memman, 160 * 52); sheet_setbuf (sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); sheet_setbuf (sht_mouse, buf_mouse, 16, 16, 99); sheet_setbuf (sht_win, buf_win, 160, 52, -1); init_screen (buf_back, xsize, ysize); init_mouse_cursor8 (buf_mouse, 99); make_window8(buf_win, 160, 52, "task_a", 1); // sprintf (s, "(%d, %d)", mx, my); // putfonts8_asc (buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s); // sprintf (s, "Memory %dMB, free : %dKB", // memtotal / (1024 * 1024), memman_total(memman) / 1024); // putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s); make_textbox8 (sht_win, 8, 28, 144, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF; //===================== // Task Settings //===================== task_a = task_init(memman); fifo.task = task_a; task_run (task_a, 1, 0); /* console sheet */ sht_cons = sheet_alloc(shtctl); buf_cons = (unsigned char *)memman_alloc_4k(memman, 256 * 165); sheet_setbuf (sht_cons, buf_cons, 256, 165, -1); make_window8 (buf_cons, 256, 165, "console", 0); make_textbox8 (sht_cons, 8, 28, 240, 128, COL8_000000); task_cons = task_alloc (); task_cons->tss.esp = memman_alloc_4k (memman, 64 * 1024) + 64 * 1024 - 12; task_cons->tss.eip = (int)&console_task; task_cons->tss.es = 1 * 8; task_cons->tss.cs = 2 * 8; task_cons->tss.ss = 1 * 8; task_cons->tss.ds = 1 * 8; task_cons->tss.fs = 1 * 8; task_cons->tss.gs = 1 * 8; *((int *) (task_cons->tss.esp + 4)) = (int) sht_cons; *((int *) (task_cons->tss.esp + 8)) = (int) memtotal; task_run (task_cons, 1, 0); /* level = 2, priority = 2 */ //======================= // Sheet Setting //======================= sheet_slide (sht_back, 0, 0); sheet_slide (sht_mouse, mx, my); sheet_slide (sht_cons, 32, 4); sheet_slide (sht_win, 64, 56); sheet_updown (sht_back, 0); sheet_updown (sht_cons, 1); sheet_updown (sht_win, 2); sheet_updown (sht_mouse, 3); sheet_refresh (sht_back, 0, 0, binfo->scrnx, 48); fifo32_put (&keycmd, KEYCMD_LED); fifo32_put (&keycmd, key_leds); for (;;) { if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) { keycmd_wait = fifo32_get(&keycmd); wait_KBC_sendready (); io_out8(PORT_KEYDAT, keycmd_wait); } io_cli(); if (fifo32_status(&fifo) == 0) { task_sleep(task_a); io_sti(); } else { i = fifo32_get(&fifo); io_sti(); if (256 <= i && i <= 511) { // Keyboard Data // sprintf (s, "%x", i - 256); // putfonts8_asc_sht (sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); if (i < 0x80 + 256) { if (key_shift == 0) { s[0] = keytable0[i - 256]; } else { s[0] = keytable1[i - 256]; } } else { s[0] = 0; } if ('A' <= s[0] && s[0] <= 'Z') { if (((key_leds & 4) == 0 && key_shift == 0) || ((key_leds & 4) != 0 && key_shift != 0)) { s[0] += 0x20; } } if (s[0] != 0) { if (key_to == 0) { if (cursor_x < 128) { s[1] = 0; putfonts8_asc_sht (sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } else { // To Console fifo32_put (&task_cons->fifo, s[0] + 256); } } if (i == 256 + 0x0e) { // Backspace if (key_to == 0) { // To Task-A if (cursor_x > 8) { putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } } else { fifo32_put(&task_cons->fifo, 8 + 256); } } if (i == 256 + 0x0f) { // Tab if (key_to == 0) { key_to = 1; make_wtitle8 (buf_win, sht_win->bxsize, "task_a", 0); make_wtitle8 (buf_cons, sht_cons->bxsize, "console", 1); cursor_c = -1; // Delete cursor boxfill8 (sht_win->buf, sht_win->bxsize, COL8_FFFFFF, cursor_x, 28, cursor_x + 7, 43); fifo32_put (&task_cons->fifo, 2); // cursor ON console } else { key_to = 0; make_wtitle8 (buf_win, sht_win->bxsize, "task_a", 1); make_wtitle8 (buf_cons, sht_cons->bxsize, "console", 0); cursor_c = COL8_000000; // Delete cursor fifo32_put (&task_cons->fifo, 3); // cursor OFF console } sheet_refresh (sht_win, 0, 0, sht_win->bxsize, 21); sheet_refresh (sht_cons, 0, 0, sht_cons->bxsize, 21); } if (i == 256 + 0x1c) { if (key_to != 0) { fifo32_put (&task_cons->fifo, 10 + 256); } } if (i == 256 + 0x2a) { // Left Shift ON key_shift |= 1; } if (i == 256 + 0x36) { // Right Shift ON key_shift |= 2; } if (i == 256 + 0xaa) { // Left Shift OFF key_shift &= ~1; } if (i == 256 + 0xb6) { // Right Shift ON key_shift &= ~2; } if (i == 256 + 0x3a) { // CapsLock key_leds ^= 4; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x45) { // NumLock key_leds ^= 2; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0x45) { // ScrollLock key_leds ^= 1; fifo32_put(&keycmd, KEYCMD_LED); fifo32_put(&keycmd, key_leds); } if (i == 256 + 0xfa) { // KeyBoard receive Data keycmd_wait = -1; } if (i == 256 + 0xfe) { // KeyBoard failed to receive Data wait_KBC_sendready (); io_out8(PORT_KEYDAT, keycmd_wait); } if (i == 256 + 0x3b && key_shift != 0 && task_cons->tss.ss0 != 0) { /* Shift+F1 */ cons = (struct CONSOLE *) *((int *) 0x0fec); cons_putstr0 (cons, "\nBreak(key) : \n"); io_cli (); task_cons->tss.eax = (int) &(task_cons->tss.esp0); task_cons->tss.eip = (int) asm_end_app; io_sti (); } // Redraw cursor if (cursor_c >= 0) { boxfill8 (sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); } sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { // Mouse Data if (mouse_decode(&mdec, i-512) != 0) { // sprintf (s, "[lcr %d %d]", mdec.x, mdec.y); // if ((mdec.btn & 0x01) != 0) { s[1] = 'L'; } // if ((mdec.btn & 0x02) != 0) { s[3] = 'R'; } // if ((mdec.btn & 0x04) != 0) { s[2] = 'C'; } // putfonts8_asc_sht (sht_back, 32, 16, COL8_FFFFFF, COL8_008484, s, 15); mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my < 0) { my = 0; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } // sprintf(s, "(%d, %d)", mx, my); // putfonts8_asc_sht (sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sheet_slide (sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { sheet_slide (sht_win, mx - 80, my - 8); } } } else if (i <= 1) { if (i != 0) { timer_init(timer, &fifo, 0); if (cursor_c >= 0) { cursor_c = COL8_000000; } } else { timer_init(timer, &fifo, 1); if (cursor_c >= 0) { cursor_c = COL8_FFFFFF; } } timer_settime(timer, 50); if (cursor_c >= 0) { boxfill8 (sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } } }
void intelflash_init(int chip, int type, void *data) { struct flash_chip *c; if( chip >= FLASH_CHIPS_MAX ) { logerror( "intelflash_init: invalid chip %d\n", chip ); return; } c = &chips[ chip ]; c->type = type; switch( c->type ) { case FLASH_INTEL_28F016S5: case FLASH_SHARP_LH28F016S: c->bits = 8; c->size = 0x200000; c->maker_id = 0x89; c->device_id = 0xaa; break; case FLASH_SHARP_LH28F400: c->bits = 16; c->size = 0x80000; c->maker_id = 0xb0; c->device_id = 0xed; break; case FLASH_FUJITSU_29F016A: c->bits = 8; c->size = 0x200000; c->maker_id = 0x04; c->device_id = 0xad; break; case FLASH_INTEL_E28F008SA: c->bits = 8; c->size = 0x100000; c->maker_id = 0x89; c->device_id = 0xa2; break; case FLASH_INTEL_TE28F160: c->bits = 16; c->size = 0x200000; c->maker_id = 0xb0; c->device_id = 0xd0; break; } if( data == NULL ) { data = auto_malloc( c->size ); memset( data, 0xff, c->size ); } c->status = 0x80; c->flash_mode = FM_NORMAL; c->flash_master_lock = 0; c->timer = timer_alloc( erase_finished ); c->flash_memory = data; state_save_register_item( "intelfsh", chip, c->status ); state_save_register_item( "intelfsh", chip, c->flash_mode ); state_save_register_item( "intelfsh", chip, c->flash_master_lock ); state_save_register_memory( "intelfsh", chip, "flash_memory", c->flash_memory, c->bits/8, c->size / (c->bits/8) ); }
void c2n_device::device_start() { // allocate timers m_read_timer = timer_alloc(); m_read_timer->adjust(attotime::from_hz(44100), 0, attotime::from_hz(44100)); }
void console_task(struct SHEET *sheet, unsigned int memtotal) { int fifobuf[128]; struct TASK *task = task_now(); struct TIMER *timer; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; int *fat = (int *) memman_alloc_4k(memman, 4 * 2880); struct CONSOLE cons = {sheet, 8, 28, -1}; int i; char cmdline[30]; *((int *) 0x0fec) = (int) &cons; fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); timer_init(timer, &task->fifo, 1); timer_settime(timer, 50); file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200)); // 将FAT展开到fat中 /* 显示提示符 */ cons_putchar(&cons, '>', 1); for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { task_sleep(task); io_sti(); } else { i = fifo32_get(&task->fifo); io_sti(); if (i <= 1) { /* 光标用定时器 */ if (i != 0) { timer_init(timer, &task->fifo, 0); /* 下次置0 */ if (cons.cur_c >= 0) { cons.cur_c = COL8_FFFFFF; } } else { timer_init(timer, &task->fifo, 1); /* 下次置1 */ if (cons.cur_c >= 0) { cons.cur_c = COL8_000000; } } timer_settime(timer, 50); } // 光标ON、OFF功能用于窗口切换时 if (i == 2) { /* 光标ON */ cons.cur_c = COL8_FFFFFF; } if (i == 3) { /* 光标OFF */ boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15); cons.cur_c = -1; } if (256 <= i && i <= 511) { /* 键盘数据(通过任务A) */ if (i == 8 + 256) { /* 退格键 */ if (cons.cur_x > 16) { /* 用空白擦除光标后将光标前移一位 */ cons_putchar(&cons, ' ', 0); cons.cur_x -= 8; } } else if (i == 10 + 256) { /* 回车键 */ /* 将光标用空格擦除后换行 */ cons_putchar(&cons, ' ', 0); cmdline[cons.cur_x / 8 - 2] = 0; cons_newline(&cons); cons_runcmd(cmdline, &cons, fat, memtotal); /* 运行命令 */ /* 显示提示符 */ cons_putchar(&cons, '>', 1); } else { /* 一般字符 */ if (cons.cur_x < 240) { /* 显示一个字符之后将光标后移一位 */ cmdline[cons.cur_x / 8 - 2] = i - 256; cons_putchar(&cons, i - 256, 1); } } } /* 重新显示光标 */ if (cons.cur_c >= 0) { boxfill8(sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15); } sheet_refresh(sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16); } } }
void spacefb_state::machine_start() { m_interrupt_timer = timer_alloc(TIMER_INTERRUPT); save_item(NAME(m_sound_latch)); }
void aicartc_device::device_start() { m_clock_timer = timer_alloc(); m_clock_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock())); }
void HariMain(void) { char *vram; int xsize; int ysize; unsigned int memtotal; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR ; struct BOOTINFO *binfo; struct SHTCTL *shtctl; struct SHEET *sht_back, *sht_mouse, *sht_win; unsigned char *buf_back, buf_mouse[256],*buf_win; int i; int fifobuf[128]; char s[40]; struct FIFO fifo; fifo_init(&fifo,128,fifobuf); static char keytable[0x54] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.' }; init_gdtidt(); init_pic(); io_sti(); init_pit(); // timer io_out8(PIC0_IMR, 0xf8); /* PIC1 (11111001) irq0 */ io_out8(PIC1_IMR, 0xef); //11101111 , allow irq12 struct TIMER *timer,*timer2,*timer3; timer = timer_alloc(); timer2 = timer_alloc(); timer3 = timer_alloc(); timer_set(timer,1000,&fifo,10); timer_set(timer2,300,&fifo,3); timer_set(timer3,50,&fifo,1); init_keyboard(&fifo,256); // memory test memtotal = memtest(0x00400000, 0xbfffffff); // available maxmium address memman_init(memman); memman_free(memman,0x00001000,0x0009e000); memman_free(memman,0x00400000,memtotal-0x00400000); init_palette(); binfo = (struct BOOTINFO *) 0x0ff0; xsize = binfo->scrnx; ysize = binfo->scrny; vram = binfo->vram; // sheet setting shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); sht_back = sheet_alloc(shtctl); sht_mouse = sheet_alloc(shtctl); sht_win = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); buf_win = (unsigned char *) memman_alloc_4k(memman,160 * 52); // window sheet buffer sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); // col_inv 99 sheet_setbuf(sht_win, buf_win,160,52,-1); /* initlize OS background */ init_screen(buf_back,xsize,ysize); int mx,my; // mouse position // mouse cursor struct MOUSE_DEC mdec; enable_mouse(&fifo,512,&mdec); init_mouse_cursor8(buf_mouse,99); make_window8(buf_win,160,52,"window"); mx = (binfo->scrnx - 16) / 2; my = (binfo->scrny - 28 - 16) / 2; sheet_move(sht_back,0,0);// move background sheet sheet_move(sht_mouse,mx,my); sheet_move(sht_win,80,72); sheet_updown(sht_back,0); // height 0, at the bottom sheet_updown(sht_win,1); sheet_updown(sht_mouse,2); // height 2,on the top sprintf(s,"%3d %3d",mx,my); putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s); sprintf(s, "memory %dMB free %dkb", memtotal/(1024*1024), memman_total(memman)/1024); putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s); sheet_refresh(sht_back,0,0,binfo->scrnx,48); int cursor_x,cursor_c; // cursor color make_textbox8(sht_win, 8,28,144,16,COL8_FFFFFF); // heigth is 16 cursor_x = 8; cursor_c = COL8_FFFFFF; for(;;) { //sprintf(s,"%010d",timerctl.count); //bps(sht_win,40,28, COL8_C6C6C6,COL8_000000,s,10); io_cli(); // forbid all interrupts if(fifo_status(&fifo) == 0) io_stihlt(); // read data until it's empty else { i=fifo_get(&fifo); io_sti(); // open interrupts if(255 < i && i < 512) {sprintf(s, "%02X", i-256); boxfill8(buf_back, binfo->scrnx, COL8_008400, 0, 16, 15, 31); putfonts8_asc(buf_back, binfo->scrnx, 0, 16, COL8_FFFFFF, s); sheet_refresh(sht_back,0,16,16,32); if(i<256 +0x54) { if(keytable[i-256] != 0 && cursor_x < 144) { s[0]= keytable[i-256]; s[1]= '\0'; bps(sht_win,cursor_x,28, COL8_FFFFFF,COL8_000000,s,1); // 4th parm is background color cursor_x +=8; // cursor move forward } } if(i == 256 + 0x0e && cursor_x > 8) { bps(sht_win,cursor_x,28,COL8_FFFFFF,COL8_000000," ",1); cursor_x -=8; } boxfill8(sht_win ->buf, sht_win->bxsize, cursor_c,cursor_x,28,cursor_x+7,43); sheet_refresh(sht_win,cursor_x,28,cursor_x+8,44); } else if(511 < i && i < 768) { if(mouse_decode(&mdec,i-512) != 0) { sprintf(s, "[lcr %4d %4d]", mdec.x,mdec.y); if((mdec.btn & 0x01) != 0) s[1]='L'; if((mdec.btn & 0x02) != 0) s[3]='R'; if((mdec.btn & 0x04) != 0) s[2]='C'; boxfill8(buf_back, binfo->scrnx, COL8_008484, 32, 16, 32+15*8-1, 31); // after filling,show ok putfonts8_asc(buf_back, binfo->scrnx, 32, 16, COL8_FFFFFF, s); sheet_refresh(sht_back,32,16,32+15*8,32); // the move of mouse mx +=mdec.x; my +=mdec.y; if(mx <0) mx = 0; if(my <0) my = 0; if(mx > binfo->scrnx -1 ) mx = binfo->scrnx -1; if(my > binfo->scrny -1 ) my = binfo->scrny -1; // control the mouse move area sprintf(s, "(%3d,%3d)", mx,my); boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 0,79, 15); putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s); sheet_refresh(sht_back,0,0,80,16); sheet_move(sht_mouse,mx,my); // move the window, vram -> sht -> move if(mdec.btn & 0x01 != 0) sheet_move(sht_win,mx-80,my-8); } } else if(i==10) {putfonts8_asc(buf_back, binfo->scrnx,0,64, COL8_FFFFFF,"10"); sheet_refresh(sht_back,0,0,100,100); } else if(i ==3) {putfonts8_asc(buf_back, binfo->scrnx,0,80, COL8_FFFFFF,"3s"); sheet_refresh(sht_back,0,0,100,100); } else if(i == 1) { timer_set(timer3,50,&fifo,0); boxfill8(sht_win->buf,sht_win->bxsize, COL8_000000, cursor_x, 28,cursor_x+7, 43); sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44); } else if(i==0) { timer_set(timer3,50,&fifo,1); // keep the data boxfill8(sht_win->buf,sht_win->bxsize, COL8_FFFFFF,cursor_x, 28,cursor_x + 7, 43); sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44); } } } }
/* * timer_device_alloc_event() * Allocate a timer device event. */ static int timer_device_alloc_event(const char *name, int cpuid, const cpumask_t *mask) { struct clock_event_device *dev; struct irqaction *action; /* * Are we out of configured timers? */ timer_device_lock_acquire(); if (timer_device_next_timer >= MAX_TIMERS) { timer_device_lock_release(); printk(KERN_WARNING "out of timer event entries\n"); return -1; } dev = &timer_device_devs[timer_device_next_timer]; action = &timer_device_irqs[timer_device_next_timer]; timer_device_next_timer++; timer_device_lock_release(); /* * Now allocate a timer to ourselves. */ dev->irq = timer_alloc(); if (dev->irq == -1) { timer_device_lock_acquire(); timer_device_next_timer--; timer_device_lock_release(); printk(KERN_WARNING "out of hardware timers\n"); return -1; } /* * Init the IRQ action structure. Make sure * this in place before you register the clock * event device. */ action->name = name; action->flags = IRQF_DISABLED | IRQF_TIMER; action->handler = timer_device_event; action->dev_id = dev; setup_irq(dev->irq, action); irq_set_affinity(dev->irq, mask); pic_disable_vector(dev->irq); /* * init clock dev structure. * * The max_delta_ns needs to be less than a full timer's * resolution to ensure that with overhead, we will be able to * service the timer. The usual approach is to use 31 bits * instead of 32 for a 32 bit timer. * * The min_delta_ns is chosen to ensure that setting next event * will never be requested with too small of value. */ dev->name = name; dev->rating = timer_device_clockbase.rating; dev->shift = timer_device_clockbase.shift; dev->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; dev->set_mode = timer_device_set_mode; dev->set_next_event = timer_device_set_next_event; dev->mult = div_sc(frequency, NSEC_PER_SEC, dev->shift); dev->max_delta_ns = clockevent_delta2ns(0x7fffffff, dev); dev->min_delta_ns = clockevent_delta2ns(0xf, dev); dev->cpumask = mask; printk(KERN_NOTICE "timer[%d]: %s - created\n", dev->irq, dev->name); /* * Now register the device. */ clockevents_register_device(dev); return dev->irq; }
/* 控制台任务 */ void console_task(struct SHEET *sheet, unsigned int memtotal) { struct TIMER *timer; struct TASK *task = task_now(); int i, fifobuf[128], cursor_x = 16, cursor_y = 28, cursor_c = -1; char s[30], cmdline[30], *p; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; int x, y; struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600); int *fat = (int *) memman_alloc_4k(memman, 4 * 2880); struct SEGMENT_DESCRIPTOR *gdt = (struct SEGMENT_DESCRIPTOR *) ADR_GDT; fifo32_init(&task->fifo, 128, fifobuf, task); timer = timer_alloc(); timer_init(timer, &task->fifo, 1); timer_settime(timer, 50); file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200)); /* 输出一个">" */ putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1); for (;;) { io_cli(); if (fifo32_status(&task->fifo) == 0) { /* 控制台任务自己的缓冲区中没有数据 */ task_sleep(task); /* 睡眠自己 */ io_sti(); } else { i = fifo32_get(&task->fifo); /* 读出数据 */ io_sti(); if (i <= 1) { /* 光标用定时器 */ if (i != 0) { timer_init(timer, &task->fifo, 0); /* 下面是设定0 */ if (cursor_c >= 0) { /* 如果需要显示光标 */ cursor_c = COL8_FFFFFF; } } else { timer_init(timer, &task->fifo, 1); /* 下面是设定1 */ if (cursor_c >= 0) { /* 如果需要显示光标 */ cursor_c = COL8_000000; } } timer_settime(timer, 50); /* 设置半秒 */ } if (i == 2) { /* 光标ON */ cursor_c = COL8_FFFFFF; } if (i == 3) { /* 光标OFF */ /* 直接用黑色将原来光标的位置消去 */ boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cursor_x, cursor_y, cursor_x + 7, cursor_y + 15); cursor_c = -1; } if (256 <= i && i <= 511) { /* 任务A传送过来的键盘的数据 */ if (i == 8 + 256) { /* 注意!在任务A中已经将键值转换成字符的ASCII码了 */ /* 退格键 */ if (cursor_x > 16) { /* 用空格把光标消去之后 光标向左移8个像素点 */ putfonts8_asc_sht(sheet, cursor_x, cursor_y, COL8_FFFFFF, COL8_000000, " ", 1); cursor_x -= 8; } } else if (i == 10 + 256) { /* 如果是回车 (10是换行符的ASCII码) */ /* Enter */ /* 用空格将光标擦除 */ putfonts8_asc_sht(sheet, cursor_x, cursor_y, COL8_FFFFFF, COL8_000000, " ", 1); cmdline[cursor_x / 8 - 2] = 0; /* 计算前面有几个字符 在字符的后面加上'\0' */ /* 加'\0'是因为C语言中字符串都是以它结尾的 */ /* 减2是减去'\0'的位置还有一个回车的位置 所*/ /* 以最后'\0'是刚好在最后一个字符后面 */ cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ /* 执行命令 */ if (strcmp(cmdline, "mem") == 0) { /* mem命令 */ /* 输出内存总大小和空闲内存大小 */ sprintf(s, "total %dMB", memtotal / (1024 * 1024)); putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30); cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ sprintf(s, "free %dKB", memman_total(memman) / 1024); putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30); cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ } else if (strcmp(cmdline, "cls") == 0) { /* cls命令 */ /* 最简单。。每个像素都设为黑色..... */ for (y = 28; y < 28 + 128; y++) { for (x = 8; x < 8 + 240; x++) { sheet->buf[x + y * sheet->bxsize] = COL8_000000; } } sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128); cursor_y = 28; } else if (strcmp(cmdline, "dir") == 0) { /* dir命令 */ for (x = 0; x < 224; x++) { /* 遍历所有的根目录条目 */ /* 这个224是在ipl10中定义的 */ if (finfo[x].name[0] == 0x00) { /* 该条目不包含任何文件信息 */ break; } if (finfo[x].name[0] != 0xe5) { /* 该条目包含文件信息 */ if ((finfo[x].type & 0x18) == 0) { /* 该条目记录的不是目录 也不是非文件信息 */ sprintf(s, "filename.ext %7d", finfo[x].size); for (y = 0; y < 8; y++) { /* 设置文件名 */ s[y] = finfo[x].name[y]; } s[ 9] = finfo[x].ext[0]; /* 设置扩展名 */ s[10] = finfo[x].ext[1]; s[11] = finfo[x].ext[2]; putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30); cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ } } } cursor_y = cons_newline(cursor_y, sheet); /* 换行 */ } else if (strncmp(cmdline, "type ", 5) == 0) { /* type命令 */ /* 准备文件名 */ for (y = 0; y < 11; y++) { s[y] = ' '; } y = 0; for (x = 5; y < 11 && cmdline[x] != 0; x++) { if (cmdline[x] == '.' && y <= 8) { y = 8; } else { s[y] = cmdline[x]; if ('a' <= s[y] && s[y] <= 'z') { /* 将小写字母转换成大写字母 */ s[y] -= 0x20; } y++; } } /* 寻找文件 */ for (x = 0; x < 224; ) { if (finfo[x].name[0] == 0x00) { /* 该条目不包含任何文件信息 */ break; } if ((finfo[x].type & 0x18) == 0) { /* 该条目记录的不是目录 也不是非文件信息 */ for (y = 0; y < 11; y++) { if (finfo[x].name[y] != s[y]) { goto type_next_file; } } break; /* 找到文件就退出循环 */ } type_next_file: x++; } if (x < 224 && finfo[x].name[0] != 0x00) { /* 找到文件的情况 */ /* 分配内存 这块内存用于存放文件的内容 */ p = (char *) memman_alloc_4k(memman, finfo[x].size); /* 将软盘中该文件的内容复制到p指向的内存中 */ file_loadfile(finfo[x].clustno, finfo[x].size, p, fat, (char *) (ADR_DISKIMG + 0x003e00)); cursor_x = 8; for (y = 0; y < finfo[x].size; y++) { /* 逐个输出文件中的内容 */ s[0] = p[y]; s[1] = 0; if (s[0] == 0x09) { /* 制表符 */ for (;;) { /* 这一小段就不注释了,偷下懒 书中解释的很详细 */ putfonts8_asc_sht(sheet, cursor_x, cursor_y, COL8_FFFFFF, COL8_000000, " ", 1); cursor_x += 8; if (cursor_x == 8 + 240) { cursor_x = 8; cursor_y = cons_newline(cursor_y, sheet); } if (((cursor_x - 8) & 0x1f) == 0) { break; /* 被32整除则break */ } } } else if (s[0] == 0x0a) { /* 换行 */ cursor_x = 8; cursor_y = cons_newline(cursor_y, sheet); } else if (s[0] == 0x0d) { /* 回车 */ /* 忽略 */ } else { /* 一般字符 */ putfonts8_asc_sht(sheet, cursor_x, cursor_y, COL8_FFFFFF, COL8_000000, s, 1); cursor_x += 8; if (cursor_x == 8 + 240) { cursor_x = 8; cursor_y = cons_newline(cursor_y, sheet); } } } /* 输出完毕 将刚申请的内存空间释放掉 */ memman_free_4k(memman, (int) p, finfo[x].size); } else { /* 文件没有找到 */ putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15); cursor_y = cons_newline(cursor_y, sheet); } cursor_y = cons_newline(cursor_y, sheet); } else if (strcmp(cmdline, "hlt") == 0) { /* 调用应用程序 */ for (y = 0; y < 11; y++) { s[y] = ' '; } /* 设置文件名 */ s[0] = 'H'; s[1] = 'L'; s[2] = 'T'; s[8] = 'H'; s[9] = 'R'; s[10] = 'B'; /* 查找文件 */ for (x = 0; x < 224; ) { if (finfo[x].name[0] == 0x00) { break; } if ((finfo[x].type & 0x18) == 0) { for (y = 0; y < 11; y++) { if (finfo[x].name[y] != s[y]) { goto hlt_next_file; } } break; /* 找到文件 */ } hlt_next_file: x++; } if (x < 224 && finfo[x].name[0] != 0x00) { /* 找到文件的情况 */ /* 分配一块内存 文件将被加载到这个并执行 */ p = (char *) memman_alloc_4k(memman, finfo[x].size); /* 将文件的内容复制到p指向的缓冲区 */ file_loadfile(finfo[x].clustno, finfo[x].size, p, fat, (char *) (ADR_DISKIMG + 0x003e00)); /* 为我们的应用程序创建一个描述符 */ set_segmdesc(gdt + 1003, finfo[x].size - 1, (int) p, AR_CODE32_ER); /* 跳转到应用程序执行 */ farjmp(0, 1003 * 8); /* 释放内存 */ memman_free_4k(memman, (int) p, finfo[x].size); } else { /* 文件没有找到 */ putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "File not found.", 15); cursor_y = cons_newline(cursor_y, sheet); } cursor_y = cons_newline(cursor_y, sheet); } else if (cmdline[0] != 0) { /* 控制台有输入但不是上面的命令 */ putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12); cursor_y = cons_newline(cursor_y, sheet); cursor_y = cons_newline(cursor_y, sheet); } /* 输出一个'>' */ putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, ">", 1); cursor_x = 16; } else { /* 一般字符 */ if (cursor_x < 240) { /* 显示一个字符后光标向右移8个像素点 */ s[0] = i - 256; s[1] = 0; cmdline[cursor_x / 8 - 2] = i - 256; putfonts8_asc_sht(sheet, cursor_x, cursor_y, COL8_FFFFFF, COL8_000000, s, 1); cursor_x += 8; } } } /* 如果需要显示光标 */ if (cursor_c >= 0) { boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, cursor_y, cursor_x + 7, cursor_y + 15); } sheet_refresh(sheet, cursor_x, cursor_y, cursor_x + 8, cursor_y + 16); } } }
void null_modem_device::device_start() { m_timer_poll = timer_alloc(TIMER_POLL); }
void iq151_staper_device::device_start() { m_printer_timer = timer_alloc(TIMER_PRINTER); m_printer_timer->reset(); }
void centronics_config(int nr, CENTRONICS_CONFIG *config) { CENTRONICS *This=cent+nr; This->config=config; This->timer = timer_alloc(centronics_timer_callback); }
void HariMain(void) { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; struct FIFO32 fifo; char s[40]; int fifobuf[128]; struct TIMER *timer, *timer2, *timer3; int mx, my, i, cursor_x, cursor_c; // cursor_x: 记录光标显示位置 unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct SHTCTL *shtctl; struct SHEET *sht_back, *sht_mouse, *sht_win; unsigned char *buf_back, buf_mouse[256], *buf_win; static char keytable[0x54] = { 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, '\\', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.' }; init_gdtidt(); init_pic(); io_sti(); /* IDT/PIC的初始化结束,开启CPU中断 */ fifo32_init(&fifo, 128, fifobuf); init_pit(); init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); /* 许可PIC1和键盘(11111000) */ io_out8(PIC1_IMR, 0xef); /* 许可鼠标(11101111) */ timer = timer_alloc(); timer_init(timer, &fifo, 10); timer_settime(timer, 1000); timer2 = timer_alloc(); timer_init(timer2, &fifo, 3); timer_settime(timer2, 300); timer3 = timer_alloc(); timer_init(timer3, &fifo, 1); timer_settime(timer3, 50); memtotal = memtest(0x00400000, 0xbfffffff); // 使用的内存空间,包含了0x00400000前已用的内存 memman_init(memman); memman_free(memman, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */ memman_free(memman, 0x00400000, memtotal - 0x00400000); init_palette(); shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny); sht_back = sheet_alloc(shtctl); sht_mouse = sheet_alloc(shtctl); sht_win = sheet_alloc(shtctl); buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny); buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52); sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 没有透明色 */ sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); // 透明色号99 sheet_setbuf(sht_win, buf_win, 160, 52, -1); /* 没有透明色 */ init_screen8(buf_back, binfo->scrnx, binfo->scrny); init_mouse_cursor8(buf_mouse, 99); make_window8(buf_win, 160, 52, "window"); make_textbox8(sht_win, 8, 28, 144, 16, COL8_FFFFFF); cursor_x = 8; cursor_c = COL8_FFFFFF; sheet_slide(sht_back, 0, 0); mx = (binfo->scrnx - 16) / 2; my = (binfo->scrny - 28 - 16) / 2; sheet_slide(sht_mouse, mx, my); sheet_slide(sht_win, 80, 72); sheet_updown(sht_back, 0); sheet_updown(sht_win, 1); sheet_updown(sht_mouse, 2); sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sprintf(s, "memory %dMB free : %dKB", memtotal / (1024 * 1024), memman_total(memman) / 1024); putfonts8_asc_sht(sht_back, 0, 32, COL8_FFFFFF, COL8_008484, s, 40); for (;;) { io_cli(); if (fifo32_status(&fifo) == 0) { /* J char ss[10]; sprintf(ss, "%c", "J"); putfonts8_asc(binfo->vram, binfo->scrnx, 100, 100, COL8_FFFFFF, ss); */ io_stihlt(); } else { i = fifo32_get(&fifo); io_sti(); if (256 <= i && i <= 511) { /* 键盘数据 */ sprintf(s, "%02X", i - 256); putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); if (i < 256 + 0x54) { if (keytable[i - 256] != 0 && cursor_x < 144) { /* 通常文字 */ /* 显示1个字符就前移1次光标 */ s[0] = keytable[i - 256]; s[1] = 0; putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1); cursor_x += 8; } } if (i == 256 + 0x0e && cursor_x > 8) { /* 退格键 */ /* 用空格键把光标消去后,后移1次光标 */ putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1); cursor_x -= 8; } /* カーソルの再表示 */ boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } else if (512 <= i && i <= 767) { /* マウスデータ */ if (mouse_decode(&mdec, i - 512) != 0) { /* 鼠标的3个字节都齐了,显示出来 */ sprintf(s, "[lcr %4d %4d]", mdec.x, mdec.y); if ((mdec.btn & 0x01) != 0) { s[1] = 'L'; } if ((mdec.btn & 0x02) != 0) { s[3] = 'R'; } if ((mdec.btn & 0x04) != 0) { s[2] = 'C'; } putfonts8_asc_sht(sht_back, 32, 16, COL8_FFFFFF, COL8_008484, s, 15); /* 移动鼠标 */ mx += mdec.x; my += mdec.y; if (mx < 0) { mx = 0; } if (my < 0) { my = 0; } if (mx > binfo->scrnx - 1) { mx = binfo->scrnx - 1; } if (my > binfo->scrny - 1) { my = binfo->scrny - 1; } sprintf(s, "(%3d, %3d)", mx, my); putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10); sheet_slide(sht_mouse, mx, my); if ((mdec.btn & 0x01) != 0) { /* 按下左键、移动sht_win */ sheet_slide(sht_win, mx - 80, my - 8); } } } else if (i == 10) { /* 10秒定时器 */ putfonts8_asc_sht(sht_back, 0, 64, COL8_FFFFFF, COL8_008484, "10[sec]", 7); } else if (i == 3) { /* 3秒定时器 */ putfonts8_asc_sht(sht_back, 0, 80, COL8_FFFFFF, COL8_008484, "3[sec]", 6); } else if (i <= 1) { /* 光标用定时器 */ if (i != 0) { timer_init(timer3, &fifo, 0); /* 下面设定0 */ cursor_c = COL8_000000; } else { timer_init(timer3, &fifo, 1); /* 下面设定1 */ cursor_c = COL8_FFFFFF; } timer_settime(timer3, 50); boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43); sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44); } } } }