小霸王学习机的真实手柄,实测CPU 占用 80%

接线图:

手柄读时序:

joypad.c 驱动: 普通的字符设备驱动。

  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/fs.h>
  4. #include <linux/init.h>
  5. #include <linux/delay.h>
  6. #include <asm/uaccess.h>
  7. #include <asm/irq.h>
  8. #include <asm/io.h>
  9. #include <linux/device.h>
  10.  
  11. /**
  12. *手柄接线定义
  13. *VCC 3.3 来自 串口
  14. *GND 来自 串口
  15. *CLK 摄像头接口 1P IICSDA GPE15
  16. *LATCH 摄像头接口 2P IICSCL GPE14
  17. *DAT0 摄像头接口 5P CAMCLK GPJ11
  18. */
  19.  
  20. #define GPE_BASE 0x56000040
  21. #define GPJ_BASE 0x560000d0
  22.  
  23. //定义一个结构体用来保存 GPIO 信息
  24. typedef struct {
  25. unsigned int con;
  26. unsigned int dat;
  27. unsigned int up;
  28.  
  29. }T_GPIO_REG, *PT_GPIO_REG;
  30.  
  31. //禁止编译器优化
  32. static volatile PT_GPIO_REG pt_gpe_reg;
  33. static volatile PT_GPIO_REG pt_gpj_reg;
  34.  
  35. static struct class *joypad_drv_class;
  36.  
  37. static ssize_t joypad_drv_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
  38. {
  39. //利用 sszie_t 返回 手柄键值
  40. //buf 是有符号无法保存 8 bit
  41. int i;
  42. ssize_t val = ;
  43. pt_gpe_reg->dat |= <<;
  44. udelay();
  45. pt_gpe_reg->dat &= ~(<<);
  46. for(i=; i<; i++)
  47. {
  48. udelay();
  49. if(! (pt_gpj_reg->dat & <<))
  50. {
  51. val |= <<i;
  52. }
  53.  
  54. pt_gpe_reg->dat |= <<;
  55. udelay();
  56. pt_gpe_reg->dat &= ~(<<);
  57. }
  58. //最后输出低电平
  59. pt_gpe_reg->dat &= ~(<< | <<);
  60. return val;
  61. }
  62.  
  63. static struct file_operations joypad_drv_fops = {
  64. .owner = THIS_MODULE,
  65. .read = joypad_drv_read,
  66. };
  67.  
  68. int major;
  69. //注册驱动程序
  70. int joypad_drv_init(void)
  71. {
  72. major = register_chrdev(, "joypad_drv", &joypad_drv_fops);
  73.  
  74. //自动创建 dev 节点
  75. joypad_drv_class = class_create(THIS_MODULE, "joypad_drv");
  76. device_create(joypad_drv_class, NULL, MKDEV(major, ), NULL, "joypad");
  77.  
  78. //ioremap 地址映射
  79. pt_gpe_reg = ioremap(GPE_BASE, sizeof(T_GPIO_REG));
  80. pt_gpj_reg = ioremap(GPJ_BASE, sizeof(T_GPIO_REG));
  81.  
  82. //配置GPIO
  83. //GPE 14 15 配置为输出引脚
  84. pt_gpe_reg->con &= ~(<<(*));
  85. pt_gpe_reg->con &= ~(<<(*));
  86. pt_gpe_reg->con |= <<(*);
  87. pt_gpe_reg->con |= <<(*);
  88.  
  89. //默认输出低电平
  90. pt_gpe_reg->dat &= ~(<< | <<);
  91.  
  92. //GPJ 11 配置为输入引脚 禁用内部上拉
  93. pt_gpj_reg->con &= ~(<<(*));
  94. pt_gpj_reg->up |= <<;
  95. return ;
  96. }
  97.  
  98. //卸载驱动程序
  99. void joypad_drv_exit(void)
  100. {
  101. //取消 地址映射
  102. iounmap(pt_gpe_reg);
  103. iounmap(pt_gpj_reg);
  104.  
  105. unregister_chrdev(major, "joypad_drv");
  106. device_destroy(joypad_drv_class, MKDEV(major, ));
  107. class_destroy(joypad_drv_class);
  108. }
  109.  
  110. module_init(joypad_drv_init);
  111. module_exit(joypad_drv_exit);
  112. MODULE_LICENSE("GPL");

InfoNES  InfoNES_System_Linux.cpp:

  1. /*===================================================================*/
  2. /* */
  3. /* InfoNES_System_Linux.cpp : Linux specific File */
  4. /* */
  5. /* 2001/05/18 InfoNES Project ( Sound is based on DarcNES ) */
  6. /* */
  7. /*===================================================================*/
  8.  
  9. /*-------------------------------------------------------------------*/
  10. /* Include files */
  11. /*-------------------------------------------------------------------*/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <pthread.h>
  17.  
  18. #include <sys/types.h>
  19. #include <sys/stat.h>
  20. #include <fcntl.h>
  21. #include <sys/ioctl.h>
  22. #include <unistd.h>
  23. #include <sys/soundcard.h>
  24.  
  25. #include "../InfoNES.h"
  26. #include "../InfoNES_System.h"
  27. #include "../InfoNES_pAPU.h"
  28.  
  29. //bool define
  30. #define TRUE 1
  31. #define FALSE 0
  32.  
  33. /* lcd 操作相关 头文件 */
  34. #include <sys/types.h>
  35. #include <sys/stat.h>
  36. #include <fcntl.h>
  37. #include <linux/fb.h>
  38. #include <sys/ioctl.h>
  39. #include <unistd.h>
  40. #include <string.h>
  41. #include <sys/mman.h>
  42. #include <termios.h>
  43.  
  44. #include <fcntl.h>
  45.  
  46. #define JOYPAD_DEV "/dev/joypad"
  47. static int joypad_fd;
  48.  
  49. static int fb_fd;
  50. static unsigned char *fb_mem;
  51. static int px_width;
  52. static int line_width;
  53. static int screen_width;
  54. static struct fb_var_screeninfo var;
  55.  
  56. static int init_joypad()
  57. {
  58. joypad_fd = open(JOYPAD_DEV, O_RDONLY);
  59. if(- == joypad_fd)
  60. {
  61. printf("joypad dev not found \r\n");
  62. return -;
  63. }
  64. return ;
  65. }
  66.  
  67. static int lcd_fb_display_px(WORD color, int x, int y)
  68. {
  69. unsigned char *pen8;
  70. unsigned short *pen16;
  71.  
  72. pen8 = (unsigned char *)(fb_mem + y*line_width + x*px_width);
  73. pen16 = (unsigned short *)pen8;
  74. *pen16 = color;
  75.  
  76. return ;
  77. }
  78.  
  79. static int lcd_fb_init()
  80. {
  81. //如果使用 mmap 打开方式 必须是 读定方式
  82. fb_fd = open("/dev/fb0", O_RDWR);
  83. if(- == fb_fd)
  84. {
  85. printf("cat't open /dev/fb0 \n");
  86. return -;
  87. }
  88. //获取屏幕参数
  89. if(- == ioctl(fb_fd, FBIOGET_VSCREENINFO, &var))
  90. {
  91. close(fb_fd);
  92. printf("cat't ioctl /dev/fb0 \n");
  93. return -;
  94. }
  95.  
  96. //计算参数
  97. px_width = var.bits_per_pixel / ;
  98. line_width = var.xres * px_width;
  99. screen_width = var.yres * line_width;
  100.  
  101. fb_mem = (unsigned char *)mmap(NULL, screen_width, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, );
  102. if(fb_mem == (void *)-)
  103. {
  104. close(fb_fd);
  105. printf("cat't mmap /dev/fb0 \n");
  106. return -;
  107. }
  108. //清屏
  109. memset(fb_mem, , screen_width);
  110. return ;
  111. }
  112.  
  113. /*-------------------------------------------------------------------*/
  114. /* ROM image file information */
  115. /*-------------------------------------------------------------------*/
  116.  
  117. char szRomName[];
  118. char szSaveName[];
  119. int nSRAM_SaveFlag;
  120.  
  121. /*-------------------------------------------------------------------*/
  122. /* Constants ( Linux specific ) */
  123. /*-------------------------------------------------------------------*/
  124.  
  125. #define VBOX_SIZE 7
  126. #define SOUND_DEVICE "/dev/dsp"
  127. #define VERSION "InfoNES v0.91J"
  128.  
  129. /*-------------------------------------------------------------------*/
  130. /* Global Variables ( Linux specific ) */
  131. /*-------------------------------------------------------------------*/
  132.  
  133. /* Emulation thread */
  134. pthread_t emulation_tid;
  135. int bThread;
  136.  
  137. /* Pad state */
  138. DWORD dwKeyPad1;
  139. DWORD dwKeyPad2;
  140. DWORD dwKeySystem;
  141.  
  142. /* For Sound Emulation */
  143. BYTE final_wave[];
  144. int waveptr;
  145. int wavflag;
  146. int sound_fd;
  147.  
  148. /*-------------------------------------------------------------------*/
  149. /* Function prototypes ( Linux specific ) */
  150. /*-------------------------------------------------------------------*/
  151.  
  152. void *emulation_thread( void *args );
  153.  
  154. void start_application( char *filename );
  155.  
  156. int LoadSRAM();
  157.  
  158. int SaveSRAM();
  159.  
  160. /* Palette data */
  161. WORD NesPalette[] =
  162. {
  163. 0x39ce, 0x1071, 0x0015, 0x2013, 0x440e, 0x5402, 0x5000, 0x3c20,
  164. 0x20a0, 0x0100, 0x0140, 0x00e2, 0x0ceb, 0x0000, 0x0000, 0x0000,
  165. 0x5ef7, 0x01dd, 0x10fd, 0x401e, 0x5c17, 0x700b, 0x6ca0, 0x6521,
  166. 0x45c0, 0x0240, 0x02a0, 0x0247, 0x0211, 0x0000, 0x0000, 0x0000,
  167. 0x7fff, 0x1eff, 0x2e5f, 0x223f, 0x79ff, 0x7dd6, 0x7dcc, 0x7e67,
  168. 0x7ae7, 0x4342, 0x2769, 0x2ff3, 0x03bb, 0x0000, 0x0000, 0x0000,
  169. 0x7fff, 0x579f, 0x635f, 0x6b3f, 0x7f1f, 0x7f1b, 0x7ef6, 0x7f75,
  170. 0x7f94, 0x73f4, 0x57d7, 0x5bf9, 0x4ffe, 0x0000, 0x0000, 0x0000
  171. };
  172.  
  173. /*===================================================================*/
  174. /* */
  175. /* main() : Application main */
  176. /* */
  177. /*===================================================================*/
  178.  
  179. /* Application main */
  180. int main( int argc, char **argv )
  181. {
  182. char cmd;
  183.  
  184. /*-------------------------------------------------------------------*/
  185. /* Pad Control */
  186. /*-------------------------------------------------------------------*/
  187.  
  188. /* Initialize a pad state */
  189. dwKeyPad1 = ;
  190. dwKeyPad2 = ;
  191. dwKeySystem = ;
  192.  
  193. /*-------------------------------------------------------------------*/
  194. /* Load Cassette & Create Thread */
  195. /*-------------------------------------------------------------------*/
  196.  
  197. /* Initialize thread state */
  198. bThread = FALSE;
  199.  
  200. /* If a rom name specified, start it */
  201. if ( argc == )
  202. {
  203. start_application( argv[] );
  204. }
  205.  
  206. lcd_fb_init();
  207. init_joypad();
  208.  
  209. //主循环中处理输入事件
  210. while()
  211. {
  212. dwKeyPad1 = read(joypad_fd, , );
  213. }
  214. return();
  215. }
  216.  
  217. /*===================================================================*/
  218. /* */
  219. /* emulation_thread() : Thread Hooking Routine */
  220. /* */
  221. /*===================================================================*/
  222.  
  223. void *emulation_thread( void *args )
  224. {
  225. InfoNES_Main();
  226. }
  227.  
  228. /*===================================================================*/
  229. /* */
  230. /* start_application() : Start NES Hardware */
  231. /* */
  232. /*===================================================================*/
  233. void start_application( char *filename )
  234. {
  235. /* Set a ROM image name */
  236. strcpy( szRomName, filename );
  237.  
  238. /* Load cassette */
  239. if ( InfoNES_Load( szRomName ) == )
  240. {
  241. /* Load SRAM */
  242. LoadSRAM();
  243.  
  244. /* Create Emulation Thread */
  245. bThread = TRUE;
  246. pthread_create( &emulation_tid, NULL, emulation_thread, NULL );
  247. }
  248. }
  249.  
  250. /*===================================================================*/
  251. /* */
  252. /* LoadSRAM() : Load a SRAM */
  253. /* */
  254. /*===================================================================*/
  255. int LoadSRAM()
  256. {
  257. /*
  258. * Load a SRAM
  259. *
  260. * Return values
  261. * 0 : Normally
  262. * -1 : SRAM data couldn't be read
  263. */
  264.  
  265. FILE *fp;
  266. unsigned char pSrcBuf[SRAM_SIZE];
  267. unsigned char chData;
  268. unsigned char chTag;
  269. int nRunLen;
  270. int nDecoded;
  271. int nDecLen;
  272. int nIdx;
  273.  
  274. /* It doesn't need to save it */
  275. nSRAM_SaveFlag = ;
  276.  
  277. /* It is finished if the ROM doesn't have SRAM */
  278. if ( !ROM_SRAM )
  279. return();
  280.  
  281. /* There is necessity to save it */
  282. nSRAM_SaveFlag = ;
  283.  
  284. /* The preparation of the SRAM file name */
  285. strcpy( szSaveName, szRomName );
  286. strcpy( strrchr( szSaveName, '.' ) + , "srm" );
  287.  
  288. /*-------------------------------------------------------------------*/
  289. /* Read a SRAM data */
  290. /*-------------------------------------------------------------------*/
  291.  
  292. /* Open SRAM file */
  293. fp = fopen( szSaveName, "rb" );
  294. if ( fp == NULL )
  295. return(-);
  296.  
  297. /* Read SRAM data */
  298. fread( pSrcBuf, SRAM_SIZE, , fp );
  299.  
  300. /* Close SRAM file */
  301. fclose( fp );
  302.  
  303. /*-------------------------------------------------------------------*/
  304. /* Extract a SRAM data */
  305. /*-------------------------------------------------------------------*/
  306.  
  307. nDecoded = ;
  308. nDecLen = ;
  309.  
  310. chTag = pSrcBuf[nDecoded++];
  311.  
  312. while ( nDecLen < )
  313. {
  314. chData = pSrcBuf[nDecoded++];
  315.  
  316. if ( chData == chTag )
  317. {
  318. chData = pSrcBuf[nDecoded++];
  319. nRunLen = pSrcBuf[nDecoded++];
  320. for ( nIdx = ; nIdx < nRunLen + ; ++nIdx )
  321. {
  322. SRAM[nDecLen++] = chData;
  323. }
  324. }else {
  325. SRAM[nDecLen++] = chData;
  326. }
  327. }
  328.  
  329. /* Successful */
  330. return();
  331. }
  332.  
  333. /*===================================================================*/
  334. /* */
  335. /* SaveSRAM() : Save a SRAM */
  336. /* */
  337. /*===================================================================*/
  338. int SaveSRAM()
  339. {
  340. /*
  341. * Save a SRAM
  342. *
  343. * Return values
  344. * 0 : Normally
  345. * -1 : SRAM data couldn't be written
  346. */
  347.  
  348. FILE *fp;
  349. int nUsedTable[];
  350. unsigned char chData;
  351. unsigned char chPrevData;
  352. unsigned char chTag;
  353. int nIdx;
  354. int nEncoded;
  355. int nEncLen;
  356. int nRunLen;
  357. unsigned char pDstBuf[SRAM_SIZE];
  358.  
  359. if ( !nSRAM_SaveFlag )
  360. return(); /* It doesn't need to save it */
  361.  
  362. /*-------------------------------------------------------------------*/
  363. /* Compress a SRAM data */
  364. /*-------------------------------------------------------------------*/
  365.  
  366. memset( nUsedTable, , sizeof nUsedTable );
  367.  
  368. for ( nIdx = ; nIdx < SRAM_SIZE; ++nIdx )
  369. {
  370. ++nUsedTable[SRAM[nIdx++]];
  371. }
  372. for ( nIdx = , chTag = ; nIdx < ; ++nIdx )
  373. {
  374. if ( nUsedTable[nIdx] < nUsedTable[chTag] )
  375. chTag = nIdx;
  376. }
  377.  
  378. nEncoded = ;
  379. nEncLen = ;
  380. nRunLen = ;
  381.  
  382. pDstBuf[nEncLen++] = chTag;
  383.  
  384. chPrevData = SRAM[nEncoded++];
  385.  
  386. while ( nEncoded < SRAM_SIZE && nEncLen < SRAM_SIZE - )
  387. {
  388. chData = SRAM[nEncoded++];
  389.  
  390. if ( chPrevData == chData && nRunLen < )
  391. ++nRunLen;
  392. else{
  393. if ( nRunLen >= || chPrevData == chTag )
  394. {
  395. pDstBuf[nEncLen++] = chTag;
  396. pDstBuf[nEncLen++] = chPrevData;
  397. pDstBuf[nEncLen++] = nRunLen - ;
  398. }else {
  399. for ( nIdx = ; nIdx < nRunLen; ++nIdx )
  400. pDstBuf[nEncLen++] = chPrevData;
  401. }
  402.  
  403. chPrevData = chData;
  404. nRunLen = ;
  405. }
  406. }
  407. if ( nRunLen >= || chPrevData == chTag )
  408. {
  409. pDstBuf[nEncLen++] = chTag;
  410. pDstBuf[nEncLen++] = chPrevData;
  411. pDstBuf[nEncLen++] = nRunLen - ;
  412. }else {
  413. for ( nIdx = ; nIdx < nRunLen; ++nIdx )
  414. pDstBuf[nEncLen++] = chPrevData;
  415. }
  416.  
  417. /*-------------------------------------------------------------------*/
  418. /* Write a SRAM data */
  419. /*-------------------------------------------------------------------*/
  420.  
  421. /* Open SRAM file */
  422. fp = fopen( szSaveName, "wb" );
  423. if ( fp == NULL )
  424. return(-);
  425.  
  426. /* Write SRAM data */
  427. fwrite( pDstBuf, nEncLen, , fp );
  428.  
  429. /* Close SRAM file */
  430. fclose( fp );
  431.  
  432. /* Successful */
  433. return();
  434. }
  435.  
  436. /*===================================================================*/
  437. /* */
  438. /* InfoNES_Menu() : Menu screen */
  439. /* */
  440. /*===================================================================*/
  441. int InfoNES_Menu()
  442. {
  443. /*
  444. * Menu screen
  445. *
  446. * Return values
  447. * 0 : Normally
  448. * -1 : Exit InfoNES
  449. */
  450.  
  451. /* If terminated */
  452. if ( bThread == FALSE )
  453. {
  454. return(-);
  455. }
  456.  
  457. /* Nothing to do here */
  458. return();
  459. }
  460.  
  461. /*===================================================================*/
  462. /* */
  463. /* InfoNES_ReadRom() : Read ROM image file */
  464. /* */
  465. /*===================================================================*/
  466. int InfoNES_ReadRom( const char *pszFileName )
  467. {
  468. /*
  469. * Read ROM image file
  470. *
  471. * Parameters
  472. * const char *pszFileName (Read)
  473. *
  474. * Return values
  475. * 0 : Normally
  476. * -1 : Error
  477. */
  478.  
  479. FILE *fp;
  480.  
  481. /* Open ROM file */
  482. fp = fopen( pszFileName, "rb" );
  483. if ( fp == NULL )
  484. return(-);
  485.  
  486. /* Read ROM Header */
  487. fread( &NesHeader, sizeof NesHeader, , fp );
  488. if ( memcmp( NesHeader.byID, "NES\x1a", ) != )
  489. {
  490. /* not .nes file */
  491. fclose( fp );
  492. return(-);
  493. }
  494.  
  495. /* Clear SRAM */
  496. memset( SRAM, , SRAM_SIZE );
  497.  
  498. /* If trainer presents Read Triner at 0x7000-0x71ff */
  499. if ( NesHeader.byInfo1 & )
  500. {
  501. fread( &SRAM[0x1000], , , fp );
  502. }
  503.  
  504. /* Allocate Memory for ROM Image */
  505. ROM = (BYTE *) malloc( NesHeader.byRomSize * 0x4000 );
  506.  
  507. /* Read ROM Image */
  508. fread( ROM, 0x4000, NesHeader.byRomSize, fp );
  509.  
  510. if ( NesHeader.byVRomSize > )
  511. {
  512. /* Allocate Memory for VROM Image */
  513. VROM = (BYTE *) malloc( NesHeader.byVRomSize * 0x2000 );
  514.  
  515. /* Read VROM Image */
  516. fread( VROM, 0x2000, NesHeader.byVRomSize, fp );
  517. }
  518.  
  519. /* File close */
  520. fclose( fp );
  521.  
  522. /* Successful */
  523. return();
  524. }
  525.  
  526. /*===================================================================*/
  527. /* */
  528. /* InfoNES_ReleaseRom() : Release a memory for ROM */
  529. /* */
  530. /*===================================================================*/
  531. void InfoNES_ReleaseRom()
  532. {
  533. /*
  534. * Release a memory for ROM
  535. *
  536. */
  537.  
  538. if ( ROM )
  539. {
  540. free( ROM );
  541. ROM = NULL;
  542. }
  543.  
  544. if ( VROM )
  545. {
  546. free( VROM );
  547. VROM = NULL;
  548. }
  549. }
  550.  
  551. /*===================================================================*/
  552. /* */
  553. /* InfoNES_MemoryCopy() : memcpy */
  554. /* */
  555. /*===================================================================*/
  556. void *InfoNES_MemoryCopy( void *dest, const void *src, int count )
  557. {
  558. /*
  559. * memcpy
  560. *
  561. * Parameters
  562. * void *dest (Write)
  563. * Points to the starting address of the copied block's destination
  564. *
  565. * const void *src (Read)
  566. * Points to the starting address of the block of memory to copy
  567. *
  568. * int count (Read)
  569. * Specifies the size, in bytes, of the block of memory to copy
  570. *
  571. * Return values
  572. * Pointer of destination
  573. */
  574.  
  575. memcpy( dest, src, count );
  576. return(dest);
  577. }
  578.  
  579. /*===================================================================*/
  580. /* */
  581. /* InfoNES_MemorySet() : memset */
  582. /* */
  583. /*===================================================================*/
  584. void *InfoNES_MemorySet( void *dest, int c, int count )
  585. {
  586. /*
  587. * memset
  588. *
  589. * Parameters
  590. * void *dest (Write)
  591. * Points to the starting address of the block of memory to fill
  592. *
  593. * int c (Read)
  594. * Specifies the byte value with which to fill the memory block
  595. *
  596. * int count (Read)
  597. * Specifies the size, in bytes, of the block of memory to fill
  598. *
  599. * Return values
  600. * Pointer of destination
  601. */
  602.  
  603. memset( dest, c, count );
  604. return(dest);
  605. }
  606.  
  607. /*===================================================================*/
  608. /* */
  609. /* InfoNES_LoadFrame() : */
  610. /* Transfer the contents of work frame on the screen */
  611. /* */
  612. /*===================================================================*/
  613. void InfoNES_LoadFrame()
  614. {
  615. int x,y;
  616. WORD wColor;
  617. for (y = ; y < NES_DISP_HEIGHT; y++ )
  618. {
  619. for (x = ; x < NES_DISP_WIDTH; x++ )
  620. {
  621. wColor = WorkFrame[y * NES_DISP_WIDTH + x ];
  622. lcd_fb_display_px(wColor, x, y);
  623. }
  624. }
  625. }
  626.  
  627. /*===================================================================*/
  628. /* */
  629. /* InfoNES_PadState() : Get a joypad state */
  630. /* */
  631. /*===================================================================*/
  632. void InfoNES_PadState( DWORD *pdwPad1, DWORD *pdwPad2, DWORD *pdwSystem )
  633. {
  634. /*
  635. * Get a joypad state
  636. *
  637. * Parameters
  638. * DWORD *pdwPad1 (Write)
  639. * Joypad 1 State
  640. *
  641. * DWORD *pdwPad2 (Write)
  642. * Joypad 2 State
  643. *
  644. * DWORD *pdwSystem (Write)
  645. * Input for InfoNES
  646. *
  647. */
  648.  
  649. /* Transfer joypad state */
  650. *pdwPad1 = dwKeyPad1;
  651. *pdwPad2 = dwKeyPad2;
  652. *pdwSystem = dwKeySystem;
  653.  
  654. dwKeyPad1 = ;
  655. }
  656.  
  657. /*===================================================================*/
  658. /* */
  659. /* InfoNES_SoundInit() : Sound Emulation Initialize */
  660. /* */
  661. /*===================================================================*/
  662. void InfoNES_SoundInit( void )
  663. {
  664. sound_fd = ;
  665. }
  666.  
  667. /*===================================================================*/
  668. /* */
  669. /* InfoNES_SoundOpen() : Sound Open */
  670. /* */
  671. /*===================================================================*/
  672. int InfoNES_SoundOpen( int samples_per_sync, int sample_rate )
  673. {
  674. return ;
  675. }
  676.  
  677. /*===================================================================*/
  678. /* */
  679. /* InfoNES_SoundClose() : Sound Close */
  680. /* */
  681. /*===================================================================*/
  682. void InfoNES_SoundClose( void )
  683. {
  684. if ( sound_fd )
  685. {
  686. close( sound_fd );
  687. }
  688. }
  689.  
  690. /*===================================================================*/
  691. /* */
  692. /* InfoNES_SoundOutput() : Sound Output 5 Waves */
  693. /* */
  694. /*===================================================================*/
  695. void InfoNES_SoundOutput( int samples, BYTE *wave1, BYTE *wave2, BYTE *wave3, BYTE *wave4, BYTE *wave5 )
  696. {
  697.  
  698. }
  699.  
  700. /*===================================================================*/
  701. /* */
  702. /* InfoNES_Wait() : Wait Emulation if required */
  703. /* */
  704. /*===================================================================*/
  705. void InfoNES_Wait()
  706. {
  707. }
  708.  
  709. /*===================================================================*/
  710. /* */
  711. /* InfoNES_MessageBox() : Print System Message */
  712. /* */
  713. /*===================================================================*/
  714. void InfoNES_MessageBox( char *pszMsg, ... )
  715. {
  716. printf( "MessageBox: %s \n", pszMsg );
  717. }
  718.  
  719. /*
  720. * End of InfoNES_System_Linux.cpp
  721. */

arm 2440 linux 应用程序 nes 红白机模拟器 第4篇 linux 手柄驱动支持的更多相关文章

  1. arm 2440 linux 应用程序 nes 红白机模拟器 第2篇 InfoNES

    InfoNES 支持 map ,声音,代码比较少,方便 移值. 在上个 LiteNES  的基础上,其实不到半小时就移值好了这个,但问题是,一直是黑屏.InfoNES_LoadFrame ()  Wo ...

  2. arm 2440 linux 应用程序 nes 红白机模拟器 第1篇

    对比了很多种,开源的 NES 模拟器 VirtuaNES , nestopia , FakeNES , FCEUX , InfoNES , LiteNES 最后决定使用 LiteNES 进行移值,它是 ...

  3. nes 红白机模拟器 第4篇 linux 手柄驱动支持

    小霸王学习机的真实手柄,实测CPU 占用 80% 接线图: 手柄读时序: joypad.c 驱动: 普通的字符设备驱动. #include <linux/module.h> #includ ...

  4. nes 红白机模拟器 第8篇 USB 手柄支持

    买了一个支持 USB OTG, 蓝牙 连接的 安卓手柄. 接到 ubunto 上 dmesg 可以看到识别出来的信息,内核已经支持了. usb - using uhci_hcd usb - usb - ...

  5. nes 红白机模拟器 第7篇 编译使用方法

    模拟器,基于 InfoNES ,作者添加修改以下功能: 1, joypad 真实手柄驱动程序(字符型设备驱动) 2,原始图像只有256*240 ,添加 图像放大算法,这里实现了2种,a, 最近邻插值 ...

  6. nes 红白机模拟器 第6篇 声音支持

    InfoNES 源码中并没有包含 linux 的声音支持. 但提供 wince 和 win 的工程,文件,通过分析,win 的 DirectSound 发声,在使用 linux ALSA 实现. 先使 ...

  7. nes 红白机模拟器 第2篇 InfoNES

    InfoNES 支持 map ,声音,代码比较少,方便 移值. 在上个 LiteNES  的基础上,其实不到半小时就移值好了这个,但问题是,一直是黑屏.InfoNES_LoadFrame ()  Wo ...

  8. nes 红白机模拟器 第5篇 全屏显示

    先看一下效果图 放大的原理是使用最初级的算法,直接取对应像素法. /*================================================================= ...

  9. nes 红白机模拟器 第1篇

    对比了很多种,开源的 NES 模拟器 VirtuaNES , nestopia , FakeNES , FCEUX , InfoNES , LiteNES 最后决定使用 LiteNES 进行移值,它是 ...

随机推荐

  1. 【emWin】例程四:显示文本

    实验指导书及代码包下载: http://pan.baidu.com/s/1jHOYdqm

  2. windows2013 iis 配置 xcache

    本帖最后由 artsharp 于 2010-6-8 09:06 编辑XCache是一种新的php缓存器,经过测试,在Windows下效果比同类软件强很多.实际测试效果如下(非科学方法):原网页平均执行 ...

  3. javaScript代码执行顺序

    javaScript是一种描述型脚本语言,由浏览器进行动态的解析和执行. 页面加载过程中,浏览器会对页面上载入的每个js代码块进行扫描. JavaScript是一段一段的分析执行的,在分析执行同一段代 ...

  4. Android 学习路线图

  5. JQuery控制滚动条滚动到指定位置

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. J2SE核心开发实战

    原图链接:http://naotu.baidu.com/file/7e3fb5d333b8cb665038390617834559?token=3c3c9d183944dd8e 课程来源:https: ...

  7. win7 将所有 视图 改为 '详细信息'

    1.随便进入某个文件夹->(菜单栏中)查看->选'详细信息' 2.(菜单栏中)工具->文件夹选项->查看->'应用到文件夹'

  8. JAVA中去掉空格经典整理

    JAVA中去掉空格经典整理 JAVA中去掉空格          1. String.trim() --------------trim()是去掉首尾空格           2.str.replac ...

  9. laravel 在windows中使用一键安装包步骤

    安装 PHP 注意一:Laravel 5.0 开始对 PHP 版本的要求是 >=5.4,Laravel 5.1 要求 PHP 版本 >=5.5.9,所以,建议大家尽量安装 5.5.x 的最 ...

  10. AFNetworking 2.0指北

    AFNetworking 2.0 来了 SEP 30TH, 2013 前几天 Mattt 发布了 AFNetworking 2.0,我的一个最大感慨就是,他怎么那么高产? 关于 Mattt Mattt ...