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

📄 msdos.c

📁 ESS3890+SL原代码(1*16内存)
💻 C
字号:
/* Copyright 2001, ESS Technology, Inc.     *//* SCCSID @(#)msdos.c	1.12 04/12/05 *//* Based on msdos.c	1.24 02/11/02 *//* * $Log$ *//** VGB: portable GameBoy emulator ***************************//**                                                         **//**                        MSDOS.c                          **//**                                                         **//** This file contains MSDOS-dependent subroutines and      **//** drivers. It includes common drivers from Common.h.      **//**                                                         **//** Copyright (C) Marat Fayzullin 1994-2001                 **//**     You are not allowed to distribute this software     **//**     commercially. Please, notify me, if you make any    **//**     changes to this file.                               **//*************************************************************/#ifndef ROM_IN_CD#ifndef CD_GAME#include "../common.h"#include "../ioport.h"#include "../util.h"#include "../config.h"#include "../servo.h"#endif#include "../keydef.h"#ifdef INES#include "regcom.h"#include "nes.h"#endif#include "gb.h"#include "libmsdos.h"#ifdef SOUND#include "gbsnd.h"#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#ifndef GAMEBOY#include <dos.h>#include <i86.h>#else#define outp#define inp#define puts#endif#ifndef CD_GAMEextern unsigned short codeIR;volatile int GB_ir_key;extern int GmScnScale;#endif#ifndef CD_GAMEint gameboy_width = 276;#endifint GMScaleYesNo  = 1;#define USE_STATIC_COLOR#define WIDTH  256                        /* Buffer width    */#define HEIGHT 224                        /* Buffer height   */#ifdef INES#if 0#define NES_WIDTH  272#define NES_HEIGHT 240#else#define NES_WIDTH  264#define NES_HEIGHT 224#endif#endifpixel *XBuf;                              /* From Common.h   */#ifdef GAMEBOY#ifndef CD_GAME#if ( (!defined VGB_CD) && (!defined INES_CD) )void GM_init_pad();unsigned int GM_key_process();void GM_init_pad(){    CLEAR_GM_LATCH0;    SET_GM_CLK0;    SET_GM_DATA0;    TRI_GM_DATA0;#ifdef GB_TWO_PAD    SET_GM_DATA1;    TRI_GM_DATA1;#endif}unsigned int  GM_key_process(){    int ii, i;    unsigned int tt, ret;        ret = tt = 0 ;    #ifdef IR_GAMEPAD    if(GB_ir_key) {	ret = GB_ir_key ;	return (ret);    }#endif    /*For HQ, we will define ESS_NEW_PAD */#ifdef ESS_NEW_PAD    /*Below is just for one pad connected physically             */    if(!(tt&0xFF)) {        SET_GM_LATCH0;        risc_sleep_a_bit(60);        CLEAR_GM_LATCH0;        risc_sleep_a_bit(20);        TRI_GM_DATA0;        for(ii=1; ii<=8; ii++){            tt <<= 1;            CLEAR_GM_CLK0;            if(!GM_DATA0_HIGH) tt |= 1;            risc_sleep_a_bit(40);            SET_GM_CLK0;            risc_sleep_a_bit(40);	}        /* The bit0-bit3 is the direction, since we cannot press */        /* 4 dirctions at the same time.  i just use it to make  */        /* the joypad not go crazy.                              */        if((tt&0xF) == 0xF) tt = 0;    }    #ifdef GB_TWO_PAD    /* I just check two pad connection, i think it is because we  */    /* just share the same clock pin for two pad, so that the 2nd */    /* pad is connected or not will affect the 1st pad's clock,   */    /* for this case i just use two kinds of clock for pad        */     /*Below is for TWO pads connected physically                  */    if(! tt){	SET_GM_LATCH0;	risc_sleep_a_bit(300);	CLEAR_GM_LATCH0;	risc_sleep_a_bit(300);	TRI_GM_DATA0;	TRI_GM_DATA1;	for(ii=1; ii<=8; ii++){	    tt <<= 1;	    CLEAR_GM_CLK0;	    if(!GM_DATA0_HIGH) tt |= 1;	    if(!GM_DATA1_HIGH) tt |= 0x100;	    risc_sleep_a_bit(100);	    SET_GM_CLK0;	    risc_sleep_a_bit(100);	}	if( (tt&0xF) == 0xF ) tt &=0xFF00;	if( (tt&0x0F00) == 0x0F00) tt &= 0xFF;    }#endif#else /*ESS_HK_PAD, no define ESS_NEW_PAD, by default*//*For custmer, we use the old pad codes. but it seems we should *//*Change to different clock setting for different kind of pad   */    SET_GM_LATCH0;    risc_sleep_a_bit(262);    CLEAR_GM_LATCH0;    risc_sleep_a_bit(262);    TRI_GM_DATA0;#ifdef GB_TWO_PAD    TRI_GM_DATA1;#endif    for(ii=1; ii<=8; ii++){        tt <<= 1;        CLEAR_GM_CLK0;        if(!GM_DATA0_HIGH) tt |= 1;#ifdef GB_TWO_PAD        if(!GM_DATA1_HIGH) tt |= 0x100;#endif        risc_sleep_a_bit(262);        SET_GM_CLK0;        risc_sleep_a_bit(262);    }#endif /*ESS_HK_PAD*/        if ( tt ) {#if 0        /*1st start key should not pressed when function keys are pressed*/        /*Just make sure there is no pause action when playing game      */        if((tt&0xFF) != 0x10 && (tt&0xFF) != 0x30) tt &= 0xEFEF;#else        if ( (tt&0x1010) == 0x1000 ) tt |= 0x10;        if ( (tt&0x2020) == 0x2000 ) tt |= 0x20;#endif	        ret |= (tt&0x0101)<<7; /* L */        ret |= (tt&0x0202)<<5; /*R */        ret |= (tt&0x0404)<<3; /*UP*/        ret |= (tt&0x0808)<<1; /*DOWN*/        ret |= (tt&0x1010)>>1; /*START*/        ret |= (tt&0x2020)>>3; /*SELECT*/        ret |= (tt&0xC0C0)>>6; /*AB*/    }#ifdef MARANELLO_A9B8           for(i=0;i<5;i++) VFD_game_scankey() ;#endif           if(key0==STOP_KEY || key0==EJECT_KEY) ret = 0x0C;    if (ret == 0x0c){	/* transition from game back to menu has garbage */	DISP_do_blank(); 	/* do DISP_END_DO_BLANK to bring back screen in play?.c */    }    	if(((ret&0x0404)==0x0404)||((ret&0x0808)==0x0808))		//去掉付手柄    ret = 0;	return ( ret );}#endif /*!INES_CD && VGB_CD*/void NES_SetColor(byte *xpal, byte N,byte R,byte G,byte B, int *pallete){  VGASetColor(xpal[N]=N+1,R,G,B,pallete);}#endifint NES_InitMachine(void){  int I,J;  GM_init_pad();  GM_init_disp();/*=======================================*//*  Try to init horizontal scale module  *//*=======================================*/  if(GMScaleYesNo)	  GM_hscale(gameboy_width);#ifdef SOUND  J=InitSound(1);#endif  VGANewImage(&Img,NES_WIDTH,NES_HEIGHT);  XBuf=Img.Data;  /* Check if joysticks are present */  return(1);}void NES_TrashMachine(void){#ifdef SOUND  TrashSound();#endif  if(GMScaleYesNo)       GM_hscale_recover();}#include "nescom.h"#endif#endif /*ROM_IN_CD*/

⌨️ 快捷键说明

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