77
88/*
99cmake -B build2 -A x64 -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_STATIC=On -DBUILD_WITH_ALL=Off -DBUILD_WITH_PYTHON=On
10+ cmake -B build2 -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_STATIC=On -DBUILD_WITH_ALL=Off -DBUILD_WITH_PYTHON=On
1011cmake --build build2 --parallel 8 --config MinSizeRel
1112*/
1213extern bool parse_note (const char * noteStr , s32 * note , s32 * octave );
@@ -149,14 +150,18 @@ static bool py_spr(int argc, py_Ref argv)
149150// s32 (*print)(tic_mem*, const char*, s32, s32, u8, bool, s32, bool)
150151static bool py_print (int argc , py_Ref argv )
151152{
152- PY_CHECK_ARG_TYPE (0 , tp_str );
153153 PY_CHECK_ARG_TYPE (1 , tp_int );
154154 PY_CHECK_ARG_TYPE (2 , tp_int );
155155 PY_CHECK_ARG_TYPE (3 , tp_int );
156156 PY_CHECK_ARG_TYPE (4 , tp_bool );
157157 PY_CHECK_ARG_TYPE (5 , tp_int );
158158 PY_CHECK_ARG_TYPE (6 , tp_bool );
159- const char * text = py_tostr (py_arg (0 ));
159+
160+ // convert arg0 to string
161+ if (!py_str (py_arg (0 ))) return false;
162+ py_assign (py_pushtmp (), py_retval ());
163+ const char * text = py_tostr (py_peek (-1 ));
164+
160165 s32 x = py_toint (py_arg (1 ));
161166 s32 y = py_toint (py_arg (2 ));
162167 u8 color = py_toint (py_arg (3 ));
@@ -166,6 +171,8 @@ static bool py_print(int argc, py_Ref argv)
166171
167172 tic_core * core = get_core ();
168173 s32 ps = core -> api .print ((tic_mem * )core , text , x , y , color , fixed , scale , alt );
174+
175+ py_pop ();
169176 py_newint (py_retval (), ps );
170177 return true;
171178}
@@ -683,7 +690,7 @@ static bool py_pmem(int argc, py_Ref argv)
683690 PY_CHECK_ARG_TYPE (0 , tp_int );
684691 s32 index = py_toint (py_arg (0 ));
685692
686- if (index >= TIC_PERSISTENT_SIZE )
693+ if (index < 0 || index >= TIC_PERSISTENT_SIZE )
687694 {
688695 return ValueError ("invalid tic persistent index" );
689696 }
@@ -693,14 +700,14 @@ static bool py_pmem(int argc, py_Ref argv)
693700 {
694701 // set persistent memory
695702 PY_CHECK_ARG_TYPE (1 , tp_int );
696- s32 value = py_toint (py_arg (1 ));
697- core -> api .pmem ((tic_mem * )core , index , value , false );
703+ u32 value = py_toint (py_arg (1 ));
704+ core -> api .pmem ((tic_mem * )core , index , value , true );
698705 py_newnone (py_retval ());
699706 }
700707 else
701708 {
702709 // get persistent memory
703- u32 res = core -> api .pmem ((tic_mem * )core , index , 0 , true );
710+ u32 res = core -> api .pmem ((tic_mem * )core , index , 0 , false );
704711 py_newint (py_retval (), res );
705712 }
706713 return true;
@@ -1093,6 +1100,44 @@ void close_pkpy_v2(tic_mem* tic)
10931100 }
10941101}
10951102
1103+ static void patch_easing_module () {
1104+ py_GlobalRef mod = py_getmodule ("easing" );
1105+ assert (mod != NULL );
1106+ #define DEF_EASE (x ) py_setdict(mod, py_name("Ease" #x), py_getdict(mod, py_name(#x)));
1107+ DEF_EASE (Linear )
1108+ DEF_EASE (InSine )
1109+ DEF_EASE (OutSine )
1110+ DEF_EASE (InOutSine )
1111+ DEF_EASE (InQuad )
1112+ DEF_EASE (OutQuad )
1113+ DEF_EASE (InOutQuad )
1114+ DEF_EASE (InCubic )
1115+ DEF_EASE (OutCubic )
1116+ DEF_EASE (InOutCubic )
1117+ DEF_EASE (InQuart )
1118+ DEF_EASE (OutQuart )
1119+ DEF_EASE (InOutQuart )
1120+ DEF_EASE (InQuint )
1121+ DEF_EASE (OutQuint )
1122+ DEF_EASE (InOutQuint )
1123+ DEF_EASE (InExpo )
1124+ DEF_EASE (OutExpo )
1125+ DEF_EASE (InOutExpo )
1126+ DEF_EASE (InCirc )
1127+ DEF_EASE (OutCirc )
1128+ DEF_EASE (InOutCirc )
1129+ DEF_EASE (InBack )
1130+ DEF_EASE (OutBack )
1131+ DEF_EASE (InOutBack )
1132+ DEF_EASE (InElastic )
1133+ DEF_EASE (OutElastic )
1134+ DEF_EASE (InOutElastic )
1135+ DEF_EASE (InBounce )
1136+ DEF_EASE (OutBounce )
1137+ DEF_EASE (InOutBounce )
1138+ #undef DEF_EASE
1139+ }
1140+
10961141static bool init_pkpy_v2 (tic_mem * tic , const char * code )
10971142{
10981143 py_initialize ();
@@ -1109,6 +1154,9 @@ static bool init_pkpy_v2(tic_mem* tic, const char* code)
11091154 core -> currentVM = (void * )py_retval ();
11101155 bind_pkpy_v2 ();
11111156
1157+ // https://github.com/nesbox/TIC-80/issues/2841
1158+ patch_easing_module ();
1159+
11121160 py_StackRef p0 = py_peek (0 );
11131161 if (!py_exec (code , "main.py" , EXEC_MODE , NULL ))
11141162 {
0 commit comments