Exemplo n.º 1
0
int main(void) {
	// _delay_ms(1500);
	init();

	// uint8_t i = 0;
	while (1) {
		char c = getchar();
		if (c == '\r') putchar('\n');
		putchar(c);

		switch (c) {
		case 'R':
		case 'r': read(); 	break;

		case 'W':
		case 'w': write(); 	break;

		case 'C':
		case 'c': capacity(); break;

		case 'I':
		case 'i': init(); break;

		case 'S':
		case 's': change_sector();

		// case '?': print_help(); break;
		}

	}

	return 0;
}
Exemplo n.º 2
0
static INT_PTR CALLBACK win_sectorview_dialog_proc(HWND dialog, UINT message,
	WPARAM wparam, LPARAM lparam)
{
	imgtoolerr_t err;
	INT_PTR rc = 0;
	struct sectorview_info *info;
	RECT dialog_rect;

	switch(message)
	{
		case WM_INITDIALOG:
			info = (struct sectorview_info *) lparam;
			info->font = create_font();

			GetWindowRect(dialog, &dialog_rect);
			info->old_width = dialog_rect.right - dialog_rect.left;
			info->old_height = dialog_rect.bottom - dialog_rect.top;
			info->track = ~0;
			info->head = ~0;
			info->sector = ~0;

			SendMessage(GetDlgItem(dialog, IDC_HEXVIEW), WM_SETFONT, (WPARAM) info->font, (LPARAM) TRUE);
			SetWindowLongPtr(dialog, GWLP_USERDATA, lparam);

			setup_spin_control(dialog, IDC_TRACKSPIN, IDC_TRACKEDIT);
			setup_spin_control(dialog, IDC_HEADSPIN, IDC_HEADEDIT);
			setup_spin_control(dialog, IDC_SECTORSPIN, IDC_SECTOREDIT);

			err = read_sector_data(dialog, 0, 0, 0);
			if (err == IMGTOOLERR_SEEKERROR)
				err = read_sector_data(dialog, 0, 0, 1);
			if (!err)
				set_sector_text(dialog);
			break;

		case WM_DESTROY:
			info = get_sectorview_info(dialog);
			if (info->font)
			{
				DeleteObject(info->font);
				info->font = NULL;
			}
			break;

		case WM_SYSCOMMAND:
			if (wparam == SC_CLOSE)
				EndDialog(dialog, 0);
			break;

		case WM_COMMAND:
			switch(HIWORD(wparam))
			{
				case BN_CLICKED:
					switch(LOWORD(wparam))
					{
						case IDOK:
						case IDCANCEL:
							EndDialog(dialog, 0);
							break;
					}
					break;

				case EN_CHANGE:
					change_sector(dialog);
					break;
			}
			break;

		case WM_SIZE:
			info = get_sectorview_info(dialog);

			GetWindowRect(dialog, &dialog_rect);
			size_dialog(dialog, sectorview_anchor,
				(dialog_rect.right - dialog_rect.left) - info->old_width,
				(dialog_rect.bottom - dialog_rect.top) - info->old_height);

			info->old_width = dialog_rect.right - dialog_rect.left;
			info->old_height = dialog_rect.bottom - dialog_rect.top;
			break;

		case WM_MOUSEWHEEL:
			if (HIWORD(wparam) & 0x8000)
				SendMessage(GetDlgItem(dialog, IDC_HEXVIEW), WM_VSCROLL, SB_LINEDOWN, 0);
			else
				SendMessage(GetDlgItem(dialog, IDC_HEXVIEW), WM_VSCROLL, SB_LINEUP, 0);
			break;
	}

	return rc;
}