Пример #1
0
/* preamble to all sector read / write commands, returns 1 if found */
int mc6843_device::address_search( chrn_id* id )
{
	legacy_floppy_image_device* img = floppy_image( );
	int r = 0;

	while ( 1 )
	{
		if ( ( ! img->floppy_drive_get_next_id( m_side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
		{
			/* read address error */
			LOG(( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() ));
			m_STRB |= 0x0a; /* set CRC error & Sector Address Undetected */
			cmd_end( );
			return 0;
		}

		if ( id->C != m_LTAR )
		{
			/* track mismatch */
			LOG(( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", machine().time().as_double(), m_LTAR, id->C ));
			m_data[0] = id->C; /* make the track number available to the CPU */
			m_STRA |= 0x20;    /* set Track Not Equal */
			cmd_end( );
			return 0;
		}

		if ( id->R == m_SAR )
		{
			/* found! */
			LOG(( "%f mc6843_address_search: sector %i found on track %i\n", machine().time().as_double(), id->R, id->C ));
			if ( ! (m_CMR & 0x20) )
			{
				m_ISR |= 0x04; /* if no DMA, set Status Sense */
			}
			return 1;
		}

		if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
		{
			r++;
			if ( r >= 4 )
			{
				/* time-out after 3 full revolutions */
				LOG(( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", machine().time().as_double(), m_SAR ));
				m_STRB |= 0x08; /* set Sector Address Undetected */
				cmd_end( );
				return 0;
			}
		}
	}

	//return 0; /* unreachable */
}
Пример #2
0
/* Read CRC bottom half */
void mc6843_device::finish_RCR( )
{
	chrn_id id;
	if ( ! address_search_read( &id ) )
		return;
	cmd_end( );
}
Пример #3
0
static void cmd_info_in ( char *pb, int count )
{
int   result;
char  read;


        /* read info */
        /* LOC_182 */
        #ifdef GSCD_DEBUG
         printk ("LOC_182 ");				              
        #endif
       
        do
        {
           read = inb (GSCDPORT(2)); 
           if ( count > 0 )
           {
              *pb = read;
              pb++;
              count--;
           }
                         
           /* LOC_183 */
           do
           {
              result = wait_drv_ready ();
           } while ( result == 0x0E );
        } while ( result == 6 );                     

        cmd_end ();
        return;
}
Пример #4
0
static void cmd_read_b ( char *pb, int count, int size )
{
int  result;
int  i;
                     
                     
       /* LOC_188 */
       /* LOC_189 */
       #ifdef GSCD_DEBUG
        printk ("LOC_189 ");			              
       #endif

       do 
       {
          do
          {
             result = wait_drv_ready ();
          } while ( result != 6 || result == 0x0E );
                         
          if ( result != 6 )
          {
             cmd_end ();
             return;
          }                       
          
          #ifdef GSCD_DEBUG
           printk ("LOC_191 ");       
          #endif

          for ( i=0 ; i< size ; i++ )
          {
             *pb = inb (GSCDPORT(2));
             pb++;
          }
          count--;
       } while ( count > 0 );
       
       cmd_end ();
       return;
}
Пример #5
0
/* Seek bottom half */
void mc6843_device::finish_SEK( )
{
	legacy_floppy_image_device* img = floppy_image( );

	/* seek to track */
	// TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now
	img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) );

	LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() ));

	/* update state */
	m_CTAR = m_GCR;
	m_SAR = 0;
	cmd_end( );
}
Пример #6
0
static void cmd_read_w ( char *pb, int count, int size )
{
int  result;
int  i;


    #ifdef GSCD_DEBUG
     printk ("LOC_185 ");			              
    #endif
 
    do 
    {
       /* LOC_185 */
       do
       {
          result = wait_drv_ready ();
       } while ( result != 6 || result == 0x0E );
                         
       if ( result != 6 )
       {
          cmd_end ();
          return;
       }                       
                         
       for ( i=0 ; i<size ; i++ )
       {
           /* na, hier muss ich noch mal drueber nachdenken */
           *pb = inw(GSCDPORT(2));
           pb++;
        }
        count--;
     } while ( count > 0 );
                    
     cmd_end ();
     return;
}
Пример #7
0
/* preamble specific to read commands (adds extra checks) */
int mc6843_device::address_search_read( chrn_id* id )
{
	if ( ! address_search( id ) )
		return 0;

	if ( id->flags & ID_FLAG_CRC_ERROR_IN_DATA_FIELD )
	{
		LOG(( "%f mc6843_address_search_read: data CRC error\n", machine().time().as_double() ));
		m_STRB |= 0x06; /* set CRC error & Data Mark Undetected */
		cmd_end( );
		return 0;
	}

	if ( id->flags & ID_FLAG_DELETED_DATA )
	{
		LOG(( "%f mc6843_address_search_read: deleted data\n", machine().time().as_double() ));
		m_STRA |= 0x02; /* set Delete Data Mark Detected */
	}

	return 1;
}
Пример #8
0
/**
 * @brief       read data through register port, one of the two 
    ports to transfer data. the other one is l2 port
 * @author      Yang Yiming
 * @date        2012-12-25
 * @param       [in]pBuf
 * @param       [in]nBufLen
 * @return      T_U32
 */
static T_U32 reg_read(T_U8 *pBuf, T_U8 nBufLen)
{
    T_U8 i;
    T_U32 nRet = 0;
    
    clear_interface_status();
    REG32(NFC_CMD_REG) = ((nBufLen - 1) << NFC_CMD_REG_INFO_POS) | NFC_CMD_REG_REG_IN_CONF | NFC_CMD_REG_LAST_BIT;
    cmd_start();

    if (AK_FALSE == cmd_end())
        return NAND_FAIL_NFC_TIMEOUT;
    
    for (i = 0; i < nBufLen; i++)
    {
        if (i < 4)
        {
            pBuf[i] = (T_U8)(0xFF & (REG32(NFC_DAT_REG1) >> (i << 3))) ;
            //akerror("Reg_\n",pBuf[i],1);
        }
        else
        {
Пример #9
0
/* Seek Track Zero bottom half */
void mc6843_device::finish_STZ( )
{
	legacy_floppy_image_device* img = floppy_image( );
	int i;

	/* seek to track zero */
	for ( i=0; i<83; i++ )
	{
		if (img->floppy_tk00_r() == CLEAR_LINE)
			break;
		img->floppy_drive_seek( -1 );
	}

	LOG(( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() ));

	/* update state */
	m_CTAR = 0;
	m_GCR = 0;
	m_SAR = 0;
	m_STRB |= img->floppy_tk00_r() << 4;

	cmd_end( );
}
Пример #10
0
// runs a script
// returns -1 is esc was pressed, 0 o/w
int run_script(char *script, DATAFILE *d) {
    char buf[512];
    Ttoken *token;
	int i;

	// set datafile
	data = d;

	clear_keybuf();

	// init sound memory
	for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) active_sounds[i] = -1;

	// create gfx buffers
    swap_buffer = create_bitmap(160, 120);
	buffer = create_bitmap(160, 120);

    script_done = FALSE;
    
    while(!script_done) {
      
		// get commands from script string
		script = get_line(buf, script);
		
		if (buf[0] != '#' && buf[0] != '\n' && buf[0] != '\r' && buf[0] != '-') {
			token = tokenize(buf);	
			if (token != NULL) {
				if      (!stricmp(token->word, "load_map"))		cmd_loadmap(get_next_word(token));
				else if (!stricmp(token->word, "draw_map"))		cmd_drawmap();
				else if (!stricmp(token->word, "set"))			cmd_set((Ttoken *)token->next);
				else if (!stricmp(token->word, "move"))			cmd_move((Ttoken *)token->next);
				else if (!stricmp(token->word, "delete"))		cmd_del((Ttoken *)token->next);
				else if (!stricmp(token->word, "run"))			cmd_run((Ttoken *)token->next);
				else if (!stricmp(token->word, "speak"))		cmd_speak((Ttoken *)token->next, 1);
				else if (!stricmp(token->word, "text"))			cmd_speak((Ttoken *)token->next, 0);
				else if (!stricmp(token->word, "save_buffer"))	cmd_savebmp();
				else if (!stricmp(token->word, "show_bmp"))		cmd_showbmp(get_next_word(token));
				else if (!stricmp(token->word, "blit"))			cmd_blit();
				else if (!stricmp(token->word, "fade_in"))		cmd_fadein();
				else if (!stricmp(token->word, "fade_out"))		cmd_fadeout();
				else if (!stricmp(token->word, "wait"))			cmd_wait(atoi(get_next_word(token)));
				else if (!stricmp(token->word, "play_sample"))  cmd_play_sample((Ttoken *)token->next);
				else if (!stricmp(token->word, "stop_sample"))  cmd_stop_sample((Ttoken *)token->next);
				else if (!stricmp(token->word, "end_script"))	cmd_end();
				else {
					char msg[256];
					sprintf(msg, "unknown: %s", token->word);
					msg_box(msg);
				}
				
				flush_tokens(token);
			}
		}
    }

	// destroy buffers
	delete_all_objects();
	destroy_bitmap(buffer);
	destroy_bitmap(swap_buffer);

	// stop old sounds
	for(i = 0; i < MAX_SCRIPT_SOUNDS; i ++) {
		if (active_sounds[i] != -1) {
			stop_sound_id(active_sounds[i]);
			forget_sound(active_sounds[i]);
		}
	}

	return (script_done == -1 ? -1 : 0);
}
Пример #11
0
/**
 * @brief       issue nand cycles including command cycle, address cycle, RB cycle etc.
 * @author      Yang Yiming
 * @date        2012-12-25
 * @param       [in]nCmdSeq the cycle sequence
 * @return      T_BOOL
 */
T_BOOL nfc_cycle(T_U32 nCmdSeq,...)
{
    volatile T_U32 *pCmdReg = (T_U32 *)NFC_CMD_REG;
    T_VOID *pArg = (T_VOID *)&nCmdSeq;
    T_U32   nCycleVal;
    T_U16   nCycle;
    T_U8    nCycleType;
    T_BOOL  bArr = AK_FALSE;
    T_U8    nDataCnt = 0;
    T_U8    aWdata[10];
    
    clear_interface_status();

    //this block is added in purpose of saving device code text compiled.
    //course pushing every parameter in stack take more instruction than 
    //just pushing an array and a flag in.
    if (nCmdSeq == NAND_CYCLE_ARR_FLAG)
    {
        pArg = (T_VOID *)((T_U32)pArg + 4);
        pArg = (T_VOID *)(*(T_U32 *)pArg);
        bArr = AK_TRUE;
    }

    while (1)
    {
        nCycle = *(T_U16 *)pArg;
        
        if (AK_TRUE == bArr)
        {
            pArg = (T_VOID *)((T_U32)pArg + 2);
        }
        else
        {
            pArg = (T_VOID *)((T_U32)pArg + 4);
        }
        
        nCycleType = GET_NAND_CYCLY_TYPE(nCycle);
        nCycleVal = (nCycle & NAND_CYCLE_VALUE_MASK) << NFC_CMD_REG_INFO_POS;

        switch (nCycleType)
        {
            case COMMAND_C://command cycle
            {
                nCycleVal |= NFC_CMD_REG_CMD_CONF;
            }
            break;
            case ADDRESS_C://address cycle
            {
                nCycleVal |= NFC_CMD_REG_ADD_CONF;
            }
            break;
            case DELAY_C://delay several k asic. will it be used?
            {
                 nCycleVal |= NFC_CMD_REG_DELAY_BIT;
            }
            break;
            case WDATA_C://output data cycle
            {
                nCycleVal = (0 << NFC_CMD_REG_INFO_POS) | NFC_CMD_REG_WDATA_CONF;
                aWdata[nDataCnt] = nCycle & NAND_CYCLE_VALUE_MASK;//get the data value
                nDataCnt++;
            }
            break;
            case READYB_C://wait for the RB signal
            {
                nCycleVal = NFC_CMD_REG_WAIT_JUMP_BIT;
            }
            break;
            case NULL_C://do nothing
            {
                continue;
            }
            break;
            case END_C://ending flag , way to exit
            {
                pCmdReg[-1] |=  NFC_CMD_REG_LAST_BIT;
                
                if (nDataCnt > 0)//we use ecc sub module to deliver the data
                {
                    //config and enable the ECC sub-Module
                    REG32(ECC_CTRL_REG1) = ECC_CTRL_REG1_WRITE_BIT | ECC_CTRL_REG1_NFC_EN_BIT | ECC_CTRL_REG1_ADDR_CLR_BIT | ECC_CTRL_REG1_RESULT_NO_OK_BIT | ECC_CTRL_REG1_NO_ERR_BIT | ECC_CTRL_REG1_END_BIT;
                    REG32(ECC_CTRL_REG2) = (nDataCnt << ECC_CTRL_REG2_SECTSIZE_POS) | (1 << ECC_CTRL_REG2_SECTCNT_POS);
                    REG32(ECC_CTRL_REG3) = MMU_Vaddr2Paddr((T_U32)aWdata) & 0x3FFFF;
                    REG32(ECC_CTRL_REG1) = ECC_CTRL_REG1_WRITE_BIT | ECC_CTRL_REG1_NFC_EN_BIT | ECC_CTRL_REG1_ADDR_CLR_BIT | ECC_CTRL_REG1_RESULT_NO_OK_BIT | ECC_CTRL_REG1_NO_ERR_BIT | ECC_CTRL_REG1_END_BIT | ECC_CTRL_REG1_START_BIT;
                } 

                cmd_start();
                
                return cmd_end();
            }

        }
        
        *pCmdReg = nCycleVal;
        pCmdReg++;
    }

}
Пример #12
0
void gera(FILE *f, void **code, funcp *entry){
    int c, i,j;
    int line = 1, 
        idx = 0, 
        funcIdx = -1;
    unsigned char * func[MAX_FUNCS];
    int declaredVars[MAX_FUNCS][MAX_VARS];
    unsigned char *codigo = (unsigned char *) malloc (TAM_COD);
    *code = codigo;

    for(i=0;i<MAX_FUNCS;i++)
         for(j=0;j<MAX_VARS;j++)
            declaredVars[i][j]=0;

    while ((c = fgetc(f)) != EOF) {
    	switch (c){
        	case 'f': {  /* function */
            	char c0;
                if (fscanf(f, "unction%c", &c0) != 1) 
                        error("comando invalido", line);
                printf("function\n");
                cmd_func(func,&funcIdx,codigo,&idx);
                break;
    		}
            case 'e': {  /* end */
                fscanf(f, "nd");
                printf("end\n");
                cmd_end(codigo,&idx);
                break;
            }
            case 'v': 
            case 'p': {  /* atribuicao */
                int i0;
                char v0 = c, c0;

                if (fscanf(f, "%d = %c", &i0, &c0) != 2)
                        error("comando invalido", line);

                if (c0 == 'c') { /* call */
                	int fc, i1;
                    char v1;
                    if (fscanf(f, "all %d %c%d", &fc, &v1, &i1) != 3) 
                        error("comando invalido", line);
                    printf("%c%d = call %d %c%d\n", v0, i0, fc, v1, i1);
                    cmd_call(fc,v1,i1,func,codigo,&idx);
                }
                else { /* operacao aritmetica */
              		int i1, i2;
                    char v1 = c0, v2, op;
                    if (fscanf(f, "%d %c %c%d", &i1, &op, &v2, &i2) != 4)
                        error("comando invalido", line);
                    printf("%c%d = %c%d %c %c%d\n", v0, i0, v1, i1, op, v2, i2);
                    cmd_op(v1,i1,op,v2,i2,codigo,&idx,declaredVars,line,funcIdx);
                }
                cmd_atr(v0,i0,codigo,&idx,declaredVars,funcIdx);
                break;
            }
            case 'r': {  /* ret */
                int i0, i1;
                char v0, v1;
                if (fscanf(f, "et? %c%d %c%d", &v0, &i0, &v1, &i1) != 4)
                    error("comando invalido", line);
                printf("ret? %c%d %c%d\n", v0, i0, v1, i1);
                cmd_ret(v0,i0,v1,i1,codigo,&idx,line);
                break;
            }
            default: 
                error("comando desconhecido", line);
        }
        line++;        
        fscanf(f, " ");
    }

    (*entry) = (funcp) func[funcIdx];
}