This commit is contained in:
olikraus 2017-07-16 10:49:20 +02:00
parent 897752b1ca
commit 3f53205943
4 changed files with 35 additions and 1 deletions

View File

@ -1,4 +1,4 @@
CFLAGS = -g -Wall -Wpointer-arith -I../../../csrc/. -I../../tga/mapgen/. -I ../../../tools/ugl/ `sdl-config --cflags`
CFLAGS = -g -Wall -Wpointer-arith -I. -I../../../csrc/. -I../../tga/mapgen/. -I../../../tools/ugl/ `sdl-config --cflags`
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) ../../tga/mapgen/map.c main.c item.c
SRC += ../../../tools/ugl/ugl_bc.c

View File

@ -171,6 +171,8 @@ endproc
map test 20 9
mapinit
setPos(3,2)
setItemPos(0)
endproc

View File

@ -371,6 +371,34 @@ void bc_fn_add(bc_t *bc)
bc_push_on_arg_stack(bc, v);
}
#ifndef UGL_TEST
pos_t bc_pos;
#endif
void bc_fn_setPos(bc_t *bc)
{
uint8_t x, y;
y = bc_pop_from_arg_stack(bc);
x = bc_pop_from_arg_stack(bc);
#ifndef UGL_TEST
bc_pos.x = x;
bc_pos.y = y;
#endif
bc_push_on_arg_stack(bc, 0);
}
void bc_fn_setItemPos(bc_t *bc)
{
uint8_t i;
i = bc_pop_from_arg_stack(bc);
#ifndef UGL_TEST
pool_GetItem(i)->pos = bc_pos;
printf("item %d new x=%d y=%d\n", i, bc_pos.x, bc_pos.y);
#endif
bc_push_on_arg_stack(bc, i);
}
/*======================================================*/
bc_buildin_fn bc_buildin_list[] =
{
@ -380,6 +408,8 @@ bc_buildin_fn bc_buildin_list[] =
/* 3 */ bc_fn_arg2, /* two arguments */
/* 4 */ bc_fn_add,
/* 5 */ bc_fn_print,
/* 6 */ bc_fn_setPos, /* two args: x & y*/
/* 7 */ bc_fn_setItemPos, /* one args: item */
};

View File

@ -56,6 +56,8 @@ struct ugl_buildin_cmd_struct ugl_buildin_cmd_list[] = {
{ /* code=*/ 3, /* name=*/ "a", /* args=*/ 2 }, /* reassign the value of the n-th argument of a user defined function */
{ /* code=*/ 4, /* name=*/ "add", /* args=*/ 2 },
{ /* code=*/ 5, /* name=*/ "print", /* args=*/ 1 },
{ /* code=*/ 6, /* name=*/ "setPos", /* args=*/ 2 },
{ /* code=*/ 7, /* name=*/ "setItemPos", /* args=*/ 1 },
};