shrub/gen164/6/ut_conk.c

95 lines
2.5 KiB
C
Raw Normal View History

2013-12-18 05:47:20 +04:00
/* j/6/ut_conk.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* logic
*/
u2_bean // transfer
2014-08-21 01:18:34 +04:00
j2_mcx(Pt6, ut, conk)(
2013-12-18 05:47:20 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun got) // retain
{
if ( u2_yes == u2ud(got) ) {
2014-08-21 01:18:34 +04:00
return j2_mby(Pt6, face)(got, sut);
}
else switch ( u2h(got) ) {
default: return u2_cm_bail(c3__fail);
case 0: {
return u2k(sut);
}
case 1: {
return j2_mby(Pt6, face)
2014-08-21 01:18:34 +04:00
(u2h(u2t(got)),
j2_mcx(Pt6, ut, conk)(van, sut, u2t(u2t(got))));
}
case 2: {
2014-08-21 01:18:34 +04:00
u2_bean vet = u2_cr_at(j2_ut_van_vet, van);
u2_noun hed, tal, ret;
if ( u2_yes == vet ) {
u2_noun cel = u2nt(c3__cell, c3__noun, c3__noun);
2014-08-21 01:18:34 +04:00
if ( u2_no == j2_mcy(Pt6, ut, nest)(van, cel, u2_yes, sut) ) {
return u2_cm_bail(c3__fail);
}
u2z(cel);
}
2014-08-21 01:18:34 +04:00
hed = j2_mcy(Pt6, ut, peek)(van, sut, c3__both, 2);
tal = j2_mcy(Pt6, ut, peek)(van, sut, c3__both, 3);
ret = j2_mby(Pt6, cell)
2014-08-21 01:18:34 +04:00
(
j2_mcx(Pt6, ut, conk)(van, hed, u2h(u2t(got))),
j2_mcx(Pt6, ut, conk)(van, tal, u2t(u2t(got))));
u2z(hed);
u2z(tal);
return ret;
}
}
}
2013-12-18 05:47:20 +04:00
/* boilerplate
*/
u2_ho_jet
2013-12-18 05:47:20 +04:00
j2_mcj(Pt6, ut, conk)[];
u2_noun // transfer
2014-08-28 23:40:40 +04:00
j2_mc(Pt6, ut, conk)(u2_noun cor) // retain
2013-12-18 05:47:20 +04:00
{
u2_noun sut, got, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &got,
u2_cv_con, &van,
2013-12-18 05:47:20 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-12-18 05:47:20 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-12-18 05:47:20 +04:00
} else {
2014-08-21 01:18:34 +04:00
return j2_mcx(Pt6, ut, conk)(van, sut, got);
2013-12-18 05:47:20 +04:00
}
}
u2_noun // transfer
2014-08-28 23:40:40 +04:00
j2_mcy(Pt6, ut, conk)(u2_noun van, // retain
2013-12-18 05:47:20 +04:00
u2_noun sut, // retain
u2_noun got) // retain
{
2014-08-28 23:40:40 +04:00
return j2_mcx(Pt6, ut, conk)(van, sut, got);
2013-12-18 05:47:20 +04:00
}
/* structures
*/
u2_ho_jet
2013-12-18 05:47:20 +04:00
j2_mcj(Pt6, ut, conk)[] = {
{ ".2", c3__hevy, j2_mc(Pt6, ut, conk), Tier6_b, u2_none, u2_none },
{ }
};