@@ -605,7 +605,7 @@ static int pico8_print(lua_State* L)
605605
606606 uint8_t w , h ;
607607 blit_char_to_screen (text [i ], cursor_x , cursor_y , color , & w , & h );
608- cursor_x += (w == 3 ) ? w + 1 : w - 1 ;
608+ cursor_x += (w + 1 ) ;
609609 }
610610
611611 cursor_y += 6 ;
@@ -1027,11 +1027,46 @@ static int pico8_add(lua_State* L)
10271027 return 1 ;
10281028}
10291029
1030+ static int pico8_all_iter (lua_State * L )
1031+ {
1032+ luaL_checktype (L , lua_upvalueindex (1 ), LUA_TTABLE );
1033+
1034+ lua_settop (L , 0 );
1035+ lua_pushvalue (L , lua_upvalueindex (1 ));
1036+ unsigned int index = fix32_to_uint32 (lua_tointeger (L , lua_upvalueindex (2 )));
1037+
1038+ while (1 )
1039+ {
1040+ index ++ ;
1041+ lua_pushinteger (L , index );
1042+ lua_replace (L , lua_upvalueindex (2 ));
1043+
1044+ lua_rawgeti (L , 1 , index );
1045+ if (!lua_isnil (L , -1 ))
1046+ {
1047+ return 1 ;
1048+ }
1049+ lua_pop (L , 1 );
1050+
1051+ if (index > lua_rawlen (L , 1 ))
1052+ {
1053+ return 0 ;
1054+ }
1055+ }
1056+ }
1057+
10301058static int pico8_all (lua_State * L )
10311059{
1032- TO_BE_DONE ;
1060+ luaL_checktype (L , 1 , LUA_TTABLE );
1061+
1062+ lua_pushvalue (L , 1 );
1063+ lua_pushinteger (L , 0 );
1064+ lua_pushcclosure (L , pico8_all_iter , 2 );
1065+
1066+ return 1 ;
10331067}
10341068
1069+
10351070static int pico8_count (lua_State * L )
10361071{
10371072 TO_BE_DONE ;
@@ -1075,7 +1110,6 @@ static int pico8_del(lua_State* L)
10751110 return 1 ;
10761111}
10771112
1078-
10791113static int pico8_foreach (lua_State * L )
10801114{
10811115 luaL_checktype (L , 1 , LUA_TTABLE );
0 commit comments