⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 microvfd.c

📁 一个两碟控制的VCD的代码,两碟之间的转动及连续播放,已大量生产的CODE.
💻 C
📖 第 1 页 / 共 3 页
字号:
/* Copyright 1997, ESS Technology, Inc.					*/
/* SCCSID @(#)microvfd.c	1.72 12/7/98 */

/*
 * $Log$
 */
#include <stdio.h>
#include "common.h"
#include "mvd.h"
#include "constvar.h"
#include "const.h"
#include "timedef.h"
#include "ioport.h"
#include "util.h"
#include "sysinfo.h"
#include "micro.h"
#include "play.h"
#include "panel.h"
#include "ir.h"
#include "dsa.h"
#include "dsc.h"
#include "panelcmd.h"
#include "config.h"
#include "vfdshare.h"
#include "keydef.h"

#ifdef SGAME
#include "sgame.h"
#endif


#ifdef DVD_VCD
#include "debug.h"
#include "talk.h"
#endif

/************************************************************************
 * Shodows are for VFD icons.						*
 * 									*
 * Size if determined by the number of grids (G). By default, we'll 	*
 * handle up to VFD with 9 G's. 					*
 *									*
 * The number is G*2 because we handle up to 16 segments (P)		*
 ************************************************************************/
#define SHADOW_LENGTH           18

/************************************************************************
 * Macros specific to different VFD drivers.				*
 ************************************************************************/
#ifdef D16312

/* VFD_MODE is set according to the target VFD's grid/segment		*/
#ifdef VFD_FUTABA
#define VFD_MODE                0x02	/* 6G, 16P			*/
#else
#define VFD_MODE                0x05	/* 9G, 13P			*/
#endif /* VFD_FUTABA */

#ifdef VFD_EXPEND
#define KEY_LENGTH              7
#define KEY_LED                 4
#else
#define KEY_LENGTH              3
#endif

#define VFD_DUTY_CYCLE          0x8c
#define VFD_ADDRESS_INC         0x40
#define VFD_ADDRESS_FIX         0x44
#define VFD_ADDRESS_MASK        0xc0
#define VFD_READ_KEY            0x42
#define VFD_READ_SW             0x43
#define VFD_WRITE_LED           0x41

#ifdef  VFD_EXPEND
#define VFD_WRITE_LED           0x41
PRIVATE char WRITE_LED[4]={0x07,0x0b,0x0d,0x0e};
unsigned char Data_LED;
int DataLED;
#endif


#endif /* D16312 */

#ifdef MN12510
/* By Liang Weihua */

#define KEY_LENGTH              12   

#define VFD_ADDRESS_MASK        0x40
#define VFD_READ_KEY            0x80

#ifdef  AIQING
#define FLPCNT                  0x01   
#define DGTCNT                  0x7e       
#define SEGCNT                  0x0f
#define P01CNT                  0x0f
#define P2DIR                   0x0f
#define P2CNT                   0x0f
#define P3DIR                   0x00   
#define P3CNT                   0x00   
#define KEYCNT                  0x1b   
#define P01DATA                 0x0f
#define P2DATA                  0x0f
#define P3DATA                  0x00

#else
#define FLPCNT                  0x01   
#define DGTCNT                  0x5e   
#define SEGCNT                  0x0f
#define P01CNT                  0x0f
#define P2DIR                   0x0f
#define P2CNT                   0x0f
#define P3DIR                   0x00   
#define P3CNT                   0x00   
#define KEYCNT                  0x1b   
#define P01DATA                 0x0f
#define P2DATA                  0x0f
#define P3DATA                  0x00
#endif  /*AIQING*/
#endif /* MN12510 */

#ifdef BU2872
/* By Liang Weihua */
#ifdef VFD_FUTABA
#define VFD_MODE                0x3a	/* 6 G, 16P			*/
#else
#define VFD_MODE                0x3f	/* 11G, 11P			*/
#endif /* VFD_FUTABA */

#define KEY_LENGTH              3

#define VFD_ADDRESS_MASK        0x80
#define VFD_READ_KEY            0xa0

#endif /* BU2872 */

/* the shaowram address of track, min and second. */

#ifdef VFD_FUTABA
#ifdef  FU271
#ifdef  A300

#ifndef CHANGE_271

#define TRACK_LOW               0x00    /*0x0e*/
#define TRACK_HIGH              0x01    /*0x0c*/
#define SECOND_LOW              0x06    /*0x0a*/
#define SECOND_HIGH             0x07    /*0x08*/
#define MINUTE_LOW              0x04    /*0x06*/
#define MINUTE_HIGH             0x05    /*0x04*/

#else

#define TRACK_LOW               0x0a    /*0x0e*/
#define TRACK_HIGH              0x0b    /*0x0c*/
#define SECOND_LOW              0x04    /*0x0a*/
#define SECOND_HIGH             0x05    /*0x08*/
#define MINUTE_LOW              0x06    /*0x06*/
#define MINUTE_HIGH             0x07    /*0x04*/

#endif

#else
#define TRACK_LOW               0x0b    /*0x0e*/
#define TRACK_HIGH              0x0a    /*0x0c*/
#define SECOND_LOW              0x05    /*0x0a*/
#define SECOND_HIGH             0x04    /*0x08*/
#define MINUTE_LOW              0x07    /*0x06*/
#define MINUTE_HIGH             0x06    /*0x04*/
#endif

#else
#ifdef FU265
#define TRACK_LOW               0x00    /*0x0e*/
#define TRACK_HIGH              0x01    /*0x0c*/
#define SECOND_LOW              0x06    /*0x0a*/
#define SECOND_HIGH             0x07    /*0x08*/
#define MINUTE_LOW              0x04    /*0x06*/
#define MINUTE_HIGH             0x05    /*0x04*/
#else
#ifdef SVA_06MM
#define TRACK_LOW               0x00    /*0x0e*/
#define TRACK_HIGH              0x01    /*0x0c*/
#define SECOND_LOW              0x06    /*0x0a*/
#define SECOND_HIGH             0x07    /*0x08*/
#define MINUTE_LOW              0x04    /*0x06*/
#define MINUTE_HIGH             0x05    /*0x04*/
#else


#ifdef FU239
#define TRACK_LOW               0x00    /*0x0e*/
#define TRACK_HIGH              0x01    /*0x0c*/
#define SECOND_LOW              0x06    /*0x0a*/
#define SECOND_HIGH             0x07    /*0x08*/
#define MINUTE_LOW              0x04    /*0x06*/
#define MINUTE_HIGH             0x05    /*0x04*/
#else

#ifdef   FU_KANGHUI30
#define TRACK_LOW               ANODE_G6L
#define TRACK_HIGH              ANODE_G6H
#define SECOND_LOW              ANODE_G3L
#define SECOND_HIGH             ANODE_G4L
#define MINUTE_LOW              ANODE_G4H
#define MINUTE_HIGH             ANODE_G5L
#else
#ifdef  FU_HUASHENG
#define TRACK_LOW               0x00    /*0x0e*/
#define TRACK_HIGH              0x01    /*0x0c*/
#define SECOND_LOW              0x06    /*0x0a*/
#define SECOND_HIGH             0x07    /*0x08*/
#define MINUTE_LOW              0x04    /*0x06*/
#define MINUTE_HIGH             0x05    /*0x04*/
#else
#define TRACK_LOW               0x06
#define TRACK_HIGH		0x07
#define SECOND_LOW		0x08
#define SECOND_HIGH		0x09
#define MINUTE_LOW		0x0a
#define MINUTE_HIGH		0x0b

#endif
#endif
#endif
#endif    /* SVA_06MM */
#endif    /*fu_huasheng */
#endif    /*kanghui*/

#else
#define TRACK_HIGH              0x0e
#define TRACK_LOW               0x0c
#define MINUTE_HIGH             0x0a
#define MINUTE_LOW              0x08
#define SECOND_HIGH             0x06
#define SECOND_LOW              0x04
#endif /* VFD_FUTABA */


void put_keycode(int key);

#if 0
#ifndef MASTER /* for vcd slave and stand alone vcd */
#define put_keycode(key)	(key0 = key) 
#endif
#endif

#ifdef MASTER /* DVD master and VCD master */
extern unsigned short codeIR ;
extern int user_input_key;

#if defined(DVD_VCD)  /*VCD master have no chance to process key */ 
#define put_keycode(key)
#else /* for DVD master */
#define put_keycode(key) user_input_key = key
#endif

#endif /* MASTER */
 
/************************************************************************
 * Macros relate to VFD communication.					*
 ************************************************************************/
#ifndef SET_VFD_CLK		/* We'll get rid of this via config.h	*/
#define SET_VFD_CLK		SET_AUX7
#define SET_VFD_DATA		SET_AUX2
#define SET_VFD_STROBE		SET_AUX6

#define CLEAR_VFD_CLK		CLEAR_AUX7
#define CLEAR_VFD_DATA		CLEAR_AUX2
#define CLEAR_VFD_STROBE	CLEAR_AUX6

#define TRISTATE_VFD_DATA	TRISTATE_AUX2
#define VFD_DATA_HIGH           AUX2_HIGH

#ifdef VFD_STB_ACTIVE_HIGH
/* E.g. BU2872 */
#define	VFD_STROBE_ACTIVE	SET_VFD_STROBE
#define	VFD_STROBE_INACTIVE	CLEAR_VFD_STROBE
#else
/* E.g. D16312, MN12510 */
#define	VFD_STROBE_ACTIVE	CLEAR_VFD_STROBE
#define	VFD_STROBE_INACTIVE	SET_VFD_STROBE
#endif /* else of VFD_STB_ACTIVE_HIGH */
#endif /* SET_VFD_CLK */

#define TRIGGER_HOST_PORT       reg0 = *(int *)x1c060000

/************************************************************************
 * Macros relate to remote control ASSIGN_SYSCODE moved to ir.c
 ************************************************************************/

#define CLEAR_REMOTE            (codeIR &= ~0x100)

#ifdef IR_PHILIPS
/* Philips IR only has 6 bits */
#define REMOTE_KEY              (char)(codeIR & 0x3f)
#endif /* IR_PHILIPS */

#if (IR_NEC || IR_SANYO)
/* NEC/SANYO IR have 8 bits */
#define REMOTE_KEY              (char)(codeIR & 0xff)
#endif /* IR_NEC || IR_SANYO */

/************************************************************************
 * Global functions.							*
 ************************************************************************/
void	initMicroObject(void);
int	get_keycode();
void	microEngine(void);

/************************************************************************
 * Private functions.							*
 ************************************************************************/
PRIVATE	void	VFD_clearSegment(int, unsigned short *);
PRIVATE	void	VFD_flashCalendar(void);
PRIVATE	void	VFD_objectReadByte(void);
PRIVATE	void	VFD_objectSendByte(int);
PRIVATE	void	VFD_parseKey(void);
PRIVATE	void	VFD_process7Segments(int, int, unsigned char, int);
PRIVATE	void	VFD_processBlank(int);
PRIVATE	void	VFD_processIndicator(int type,char indicator);
PRIVATE	void	VFD_processMessage(int);
PRIVATE	void	VFD_push(int);
PRIVATE	void	VFD_searchKey(void);
PRIVATE	void	VFD_strobeSendByte(int);

#ifdef VFD_LED
PRIVATE int vfdsw;
PRIVATE void    VFD_state_read_sw_0(void);
PRIVATE void    VFD_state_read_sw_1(void);
PRIVATE void    VFD_state_write_led_0(void);
PRIVATE void    VFD_state_write_led_1(void);
#endif

PRIVATE	void	VFD_state_init(void);
PRIVATE	void	VFD_state_scan_key_0(void);
PRIVATE	void	VFD_state_scan_key_1(void);
PRIVATE	void	VFD_state_scan_key_2(void);
PRIVATE	void	VFD_state_scan_key_3(void);
PRIVATE	void	VFD_state_scan_key_4(void);
PRIVATE	void	VFD_state_scan_key_5(void);
PRIVATE	void	VFD_state_refresh_0(void);
PRIVATE	void	VFD_state_refresh_1(void);
PRIVATE	void	VFD_state_refresh_2(void);
PRIVATE	void	VFD_state_refresh_3(void);
PRIVATE	void	VFD_state_refresh_4(void);
PRIVATE	void	VFD_state_refresh_5(void);

#ifdef VFD_EXPEND
PRIVATE void    VFD_state_scan_keys_0(void);
PRIVATE void    VFD_state_scan_keys_1(void);
PRIVATE void    VFD_state_scan_keys_2(void);
PRIVATE void    VFD_state_scan_keys_3(void);
PRIVATE void    VFD_state_scan_keys_4(void);
#endif

/************************************************************************
 * Local variables							*
 ************************************************************************/
PRIVATE struct {
    unsigned int     FlashTime;
} ObjectTime;

PRIVATE struct {
    char    KeyBuffer[KEY_LENGTH];
    char    FireKey;
    char    Digit10Key;
} ObjectKey;
 
/*
 * There is a stack to keep track which "G/P" byte needs to be updated.
 * G/P combinations are defined as ANODE_G1L, ANODE_G1H etc in vfdshare.h.
 */
PRIVATE	int		VFDptr;
PRIVATE	char		VFD_refresh_stack[SHADOW_LENGTH]; 
#define POPVFD          VFD_refresh_stack[--VFDptr]

/*
 * ShadowRam keeps track of the value that needs to be set for the
 * corresponding G/P combination.
 */
PRIVATE	unsigned char	ShadowRam[SHADOW_LENGTH];

PRIVATE	int		RefreshCounter;
PRIVATE	int		EnableFlashing, FlashingCalendar;
PRIVATE	char		DataLength;
PRIVATE	int		key0 = NO_KEY;


PRIVATE	PFV		VFD_next_state = VFD_state_init;

/*add*/
#ifdef  SGAME
unsigned char  av_game_flag =0;
#endif


/************************************************************************
 * Global variables							*
 ************************************************************************/
int last_voice_clock;

int microKeyPending()
{
    if ((REMOTE_VALID) || (key0 != NO_KEY))
	return (1);

    return (0);
}

void initMicroObject(void)
{
    int i;

#ifdef DVD_VCD /* VCD slave and master */
    return;
#endif

    ObjectTime.FlashTime = glbTimer + HALF_SECOND;
    VFD_STROBE_INACTIVE;
    SET_VFD_CLK;
    SET_VFD_DATA;
    VFD_processBlank(BLANK_ALL);
}

void put_keycode(int key)
{
	key0 = key;
}

int get_keycode()
{
    int return_key;

    return_key = key0;
    key0 = NO_KEY;
    return return_key;
}

volatile int KeySearchLock;
/*===========================================================================*/
PRIVATE void VFD_searchKey(void)
{
    int bitCounter,keyLength,keyCounter,keyInCounter,keyCode;
    char *p,tmp;

    p = ObjectKey.KeyBuffer;
    keyLength = KEY_LENGTH;
    keyCounter = keyInCounter = keyCode = 0;

    do {
        for (bitCounter = 0, tmp = *p; bitCounter < 8; bitCounter++) {
            if (tmp & 0x01) {
                keyInCounter++;
                keyCode = keyCounter;
            }
            keyCounter++;
            tmp >>= 1;
        }
        *p++;
    } while (--keyLength);

    if (keyInCounter) {
        if (keyInCounter == 1 && !KeySearchLock) {
	    unsigned char * key_tbl = T_VFD_key_tbl;
	    KeySearchLock = 1;
#ifdef DEBUG_OSD
           debug_osd("VFDKEY",keyCode,10);
#endif
            ObjectKey.FireKey = key_tbl[keyCode];
	} else {
	    ObjectKey.FireKey = NO_KEY;
	}
    }
    else {
	    KeySearchLock = 0;
        ObjectKey.FireKey = NO_KEY;
    }
}

/*===========================================================================*/
PRIVATE void VFD_parseKey(void)
{
    int ignore_key, key;

#ifdef VCDROM
    if (VCD_30) {
	if (ObjectKey.FireKey != NO_KEY) {
	    key = ObjectKey.FireKey ;    
	    ObjectKey.FireKey = NO_KEY;
	    if (key == EJECT_KEY)
		put_keycode(NO_KEY);	/* Clear possible key left in queue */
	    vcd30_key_preprocess(key);
    
	    put_keycode(key);
	}
#ifdef IR_PHILIPS
            key = NO_KEY;                           /* starts at 0xffxx.*/
#endif /* IR_PHILIPS */

	    return ;
    }

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -