Ver código fonte

add:nes增加api注释

Dozingfiretruck 2 anos atrás
pai
commit
9134e5634c
1 arquivos alterados com 26 adições e 2 exclusões
  1. 26 2
      components/nes/luat_lib_nes.c

+ 26 - 2
components/nes/luat_lib_nes.c

@@ -3,7 +3,7 @@
 @module  nes
 @summary nes模拟器
 @version 1.0
-@date    2023.2.17
+@date    2023.4.10
 */
 
 #include "luat_base.h"
@@ -36,6 +36,14 @@ void nes_task(void *param){
     nes_run(nes);
 }
 
+/*
+nes模拟器初始化
+@api nes.init(file_path)
+@string file_path 文件路径
+@return bool 成功返回true,否则返回false
+@usage
+nes.init("/luadb/super_mario.nes")
+*/
 static int l_nes_init(lua_State *L) {
     size_t nes_rom_len;
     const char* nes_rom = luaL_checklstring(L, 1, &nes_rom_len);
@@ -49,7 +57,15 @@ static int l_nes_init(lua_State *L) {
     lua_pushboolean(L, 1);
     return 1;
 }
-
+/*
+nes模拟器初始化
+@api nes.key(key,val)
+@number key 按键
+@number val 状态 1按下 0抬起
+@return bool 成功返回true,否则返回false
+@usage
+nes.init("/luadb/super_mario.nes")
+*/
 static int l_nes_key(lua_State *L) {
     int key = luaL_checkinteger(L, 1);
     int val = luaL_checkinteger(L, 2);
@@ -90,13 +106,21 @@ static const rotable_Reg_t reg_nes[] =
     {"init",    ROREG_FUNC(l_nes_init)  },
     {"key",     ROREG_FUNC(l_nes_key)   },
 
+    //@const Up 按键上
     { "Up",     ROREG_INT(Up)           },
+    //@const Down 按键下
     { "Down",   ROREG_INT(Down)         },
+    //@const Left 按键左
     { "Left",   ROREG_INT(Left)         },
+    //@const Right 按键右
     { "Right",  ROREG_INT(Right)        },
+    //@const A 按键A
     { "A",      ROREG_INT(A)            },
+    //@const B 按键B
     { "B",      ROREG_INT(B)            },
+    //@const Start 按键开始
     { "Start",  ROREG_INT(Start)        },
+    //@const Select 按键选择
     { "Select", ROREG_INT(Select)       },
 	{ NULL,     ROREG_INT(0)}
 };