Esempio n. 1
0
static void
divide_from_snapshot( libspectrum_snap *snap )
{
  size_t i;

  if( !libspectrum_snap_divide_active( snap ) ) return;

  settings_current.divide_wp =
    libspectrum_snap_divide_eprom_writeprotect( snap );
  divide_control_write_internal( libspectrum_snap_divide_control( snap ) );

  if( libspectrum_snap_divide_eprom( snap, 0 ) ) {
    memcpy( divide_eprom,
	    libspectrum_snap_divide_eprom( snap, 0 ), DIVIDE_PAGE_LENGTH );
  }

  for( i = 0; i < libspectrum_snap_divide_pages( snap ); i++ )
    if( libspectrum_snap_divide_ram( snap, i ) )
      memcpy( divide_ram[ i ], libspectrum_snap_divide_ram( snap, i ),
	      DIVIDE_PAGE_LENGTH );

  if( libspectrum_snap_divide_paged( snap ) ) {
    divide_page();
  } else {
    divide_unpage();
  }
}
Esempio n. 2
0
void
divide_refresh_page_state( void )
{
  if( divide_control & DIVIDE_CONTROL_CONMEM ) {
    /* always paged in if conmem enabled */
    divide_page();
  } else if( settings_current.divide_wp
    || ( divide_control & DIVIDE_CONTROL_MAPRAM ) ) {
    /* automap in effect */
    if( divide_automap ) {
      divide_page();
    } else {
      divide_unpage();
    }
  } else {
    divide_unpage();
  }
}
Esempio n. 3
0
File: main.c Progetto: ExAcler/Prizm
void Confirm_AllDivide(const char* fn)
{
    /*
	    尝试全部分页(界面绘制)
		参数说明:
		    fn: 当前打开文件的文件名
	*/

	beg:
	font16 = open_font("\\\\fls0\\24PX.hzk");
	select_font(font16);
	
	ClearArea(35,45,349,166);
	print_chs_2(38,47,0,"尝试全部分页可能需要");
	print_chs_2(38,71,0,"很长时间。");
	print_chs_2(38,95,0,"确定继续?");
	
	locate_OS(6,5);
	Print_OS("[F1]:",0,0);print_chs_2(181,119,0,"是");
	locate_OS(6,6);
	Print_OS("[F6]:",0,0);print_chs_2(181,143,0,"否");
	close_font(font16);
	
	while (1)
	{
	    int key;
	    GetKey(&key);
	    switch (key)
		{
		    case KEY_CTRL_F1:
			    divide_page(fn,9999-cached,0);    // 尝试分到 9999 页
				return;break;
			case KEY_CTRL_F6:
				return;break;
	    }
	}
}
Esempio n. 4
0
File: main.c Progetto: ExAcler/Prizm
void iRead_main(const char* filename)
{
    /*
	    阅读界面主函数
		参数说明:
		    filename: 打开的文件名 (从文件浏览器得到)
	*/

    int key,handle;
	char* buf=(char*)malloc(461);
	FONTCHARACTER fname[64];
	
	char tip[64], tmp[64];
	
	page=0;cached=0;
	
	memset(bytes,0,sizeof(bytes));
	memset(bookmark,0,sizeof(bookmark));bookmark[3]=0;
	
	Read_Config(filename,&cached);    //  读取书签及分页配置
	
	//  如果分的页数不满 500 的整数倍,补分页满
	if (cached==0) divide_page(filename,500-cached,1);
	else
	    if (cached%500!=0) divide_page(filename,500-cached%500,1);   // 补至 500 的整数倍
	totbytes=0;
	
	/*  设置状态栏显示文字
		0x0001:显示电量
		0x0100:显示文字
	*/
	DefineStatusAreaFlags(3, 0x01 | 0x02 | 0x100, 0, 0);
	
	beg:
	font16=open_font("\\\\fls0\\24PX.hzk");
	select_font(font16);
	
	Bdisp_AllClr_VRAM();
    draw_pic(0,192,124,22,0,Menu_Read);
	draw_pic(126,192,61,22,0,Menu_Sub_Jump);
	
	//  若翻下一页时超出已缓存页面范围
	if (cached<=page)
	{
	    //  如果分的页数不满 500 的整数倍,补分页满
	    if (!divide_page(filename,1,0)) page=cached-1;
	    else if (cached%500!=0) divide_page(filename,500-cached%500,0);
		
		close_font(font16);
		goto beg;
	}
	totbytes=bytes[page];    //  修正读取字节指针位置
	
	char_to_font(filename,fname);
	handle=Bfile_OpenFile_OS(fname,0);    //  打开文件
	
	Bfile_ReadFile_OS(handle,buf,400,totbytes);
	Bfile_CloseFile_OS(handle);
	
	print_chs_page(0,24,totbytes,(unsigned char*)buf);    //  绘制一页
    close_font(font16);
	
	//  准备显示浏览进度
	char fn_ptr[64];
	memset(fn_ptr, 0, sizeof(fn_ptr));
	GetDisplayFileName(filename, fn_ptr);
	
	memset(tip, 0, sizeof(tip));
	memset(tmp, 0, sizeof(tmp));
	strcat(tip, fn_ptr); strcat(tip, " ");
	itoa(page + 1, tmp, 10); strcat(tip, tmp);
    strcat(tip, "/"); memset(tmp, 0, sizeof(tmp));
	itoa(cached, tmp, 10);strcat(tip, tmp);
	
	//  状态栏显示文件名及进度
	DefineStatusMessage(tip, 0, 0, 0);
	
	while (1)
	{
	    GetKey(&key);
	    switch (key)
		{
		    case KEY_CTRL_UP:    //  跳到上一页
			    if (page>0)
				{
			        --page;
				    goto beg;
				}
				break;
				
		    case KEY_CTRL_DOWN:    //  跳到下一页
			    ++page;
			    goto beg;
				break;
				
			case KEY_CTRL_EXIT:    //  离开,返回文件浏览器
			    Save_Config(filename,cached+1);
				DefineStatusAreaFlags(3, 0x01 | 0x02 | 0x100, 0, 0);
			    return;break;
				
			case KEY_CTRL_F2:    //  打开存储书签对话框
			    Save_Bookmark(filename,page,cached+1);
				goto beg;break;
				
			case KEY_CTRL_F1:    //  打开读取书签对话框
			    Read_Bookmark(filename,&page,&cached);
				goto beg;break;
				
			case KEY_CTRL_F3:    //  打开跳页对话框
			    Page_Jump(filename);
				goto beg;break;
		}
 	}
}
Esempio n. 5
0
File: main.c Progetto: ExAcler/Prizm
void Page_Jump(const char* fn)
{
    /*
	    跳页(界面绘制)
		参数说明:
		    fn: 当前打开文件的文件名
	*/

	FONTCHARACTER fname[64];
	char tip[64],tmp[64];
	char keybuff[32];    //  接受页码的字符缓冲区
	int inspos=0,target;
	
	memset(keybuff, 0, sizeof(keybuff));
	MsgBoxPush(5);
	
	beg:
	font16 = open_font("\\\\fls0\\24PX.hzk");
	select_font(font16);
	
	ClearArea(0,192,384,216);
	draw_pic(0,192,61,22,0,Menu_Sub_Jump);
	draw_pic(63,192,61,22,0,Menu_Jump);
	
	ClearArea(35,45,349,166);
	
	print_chs_2(38,47,0,"当前页/已缓存页数:");
	
	locate_OS(3,3);
	memset(tmp,0,sizeof(tmp));memset(tip,0,sizeof(tip));
	itoa(page+1,tmp,10);strcat(tip,tmp);
    strcat(tip,"/");memset(tmp,0,sizeof(tmp));
	itoa(cached,tmp,10);strcat(tip,tmp);
	Print_OS(tip,0,0);
	
	print_chs_2(38,119,0,"输入目标页码:");
	locate_OS(3,6);
	Print_OS("[    ]",0,0);
	locate_OS(4,6);
	Print_OS(keybuff,0,0);
	
	close_font(font16);
	
	while (1)
	{
	    int key;
	    GetKey(&key);
	    switch (key)
		{
			case KEY_CTRL_EXIT:
				MsgBoxPop();
			    return;break;
			
			case KEY_CTRL_F2:
			    Confirm_AllDivide(fn);    // 尝试全部分页
				goto beg;break;
			
			case KEY_CTRL_DEL:
			    if (inspos>0)
				{
					keybuff[--inspos]=0;    // 最后一个字节置为 NULL,标识已删除
					goto beg;
				}
			    break;
			
			case KEY_CTRL_F1:
			case KEY_CTRL_EXE:
			    if (inspos==0) break;
				target=atoi(keybuff);
				if (target>cached)    // 如果目标位置超出已缓存页面数,尝试分页
				{
				    if (!divide_page(fn, target-cached, 1)) page = cached - 1;    // 若分页已达文件末尾,则将当前页面修正到最后一页
					else page=target-1;    // 否则修正当前页面为输入的目标位置
			    }
				else
				    page=target-1;    // 修正当前页面为输入的目标位置
				MsgBoxPop();
				return;break;
			
			default:
			    if (key>=0x30&&key<=0x39)    // 输入数字 0~9
				{
				    if (inspos<=3)
					{
					    if (key==0x30&&inspos==0) break;    // 尝试第一位输入 0 时跳出
						keybuff[inspos++]=key;    // 最后一个字节添加输入
						goto beg;
					}
				}
		}
	}
}