sm64/data/p/pathqbox.p
2022-12-04 22:27:02 -05:00

285 lines
6.6 KiB
OpenEdge ABL

/********************************************************************************
-------------------------
Ultra 64 MARIO Brothers
-------------------------
File : pathqbox.s
Description :
Date : 1995.
Author : H.yajima
********************************************************************************/
#define ITEM_BOX_SCALE 2.0f
/*################*/
#ifdef ASSEMBLER
/*################*/
/*----------------------------------------------*/
/* */
/* itembox */
/* */
/*----------------------------------------------*/
e_qbox:
e_itembox:
p_initialize(moveBG)
p_setbit(flag,stf_moveON | stf_YangleSAME )
p_setshapeinfo(q_block_info)
p_setbit(flag,stf_moveON )
p_setf(movebg_checkdist,300)
p_save_nowpos
p_while
p_program(s_itembox)
p_loop
/*----------------------------------------------*/
/* */
/* qbox mark */
/* */
/*----------------------------------------------*/
e_qbox_mark:
p_initialize(option)
p_setbit(flag,stf_moveON | stf_YangleSAME )
p_set_scale(200)
p_while
p_program(s_qbox_mark)
p_addd(angleY,0x800)
p_loop
/*################*/
#else
/*################*/
#define qbox_scaleX (execstp->s[stw_work0].f)
#define qbox_scaleY (execstp->s[stw_work1].f)
#define qbox_work (execstp->s[stw_work2].d)
/********************************************************************************
item box data's
********************************************************************************/
static HitCheckRecord itembox_hit = {
OBJNAME_PUNCHITEM,
5,0,1,0, /* flag,ap,hp,coin */
40,30, /* player attack hitarea */
40,30, /* player attack hitarea */
};
extern Path e_itemhat_metal[];
extern Path e_itemhat_wing[];
extern Path e_itemhat_erase[];
MakeIDJMP itembox_table[] = {
{ ITEMCODE_HAT_WING ,0,0,S_itemhat_wing ,e_itemhat_wing },
{ ITEMCODE_HAT_METAL ,0,0,S_itemhat_metal ,e_itemhat_metal },
{ ITEMCODE_HAT_ERASE ,0,0,S_itemhat_hat ,e_itemhat_erase },
{ ITEMCODE_NOKO ,0,0,S_koura ,e_nokoboard },
{ ITEMCODE_COIN_1 ,0,0,S_coin ,e_player_coin },
{ ITEMCODE_COIN_3 ,0,0,S_NULL ,e_player_coin_3 },
{ ITEMCODE_COIN_10 ,0,0,S_NULL ,e_player_coin_10 },
{ ITEMCODE_1UP ,0,0,S_oneup_kinoko ,e_1up_kinoko },
{ ITEMCODE_GOALSTAR ,0,0,S_polystar ,e_enemystar2 },
{ ITEMCODE_1UP_ESCAPE ,0,0,S_oneup_kinoko ,e_1up_kinoko_escape },
{ ITEMCODE_GOALSTAR_1 ,0,1,S_polystar ,e_enemystar2 },
{ ITEMCODE_GOALSTAR_2 ,0,2,S_polystar ,e_enemystar2 },
{ ITEMCODE_GOALSTAR_3 ,0,3,S_polystar ,e_enemystar2 },
{ ITEMCODE_GOALSTAR_4 ,0,4,S_polystar ,e_enemystar2 },
{ ITEMCODE_GOALSTAR_5 ,0,5,S_polystar ,e_enemystar2 },
{ ITEMCODE_END ,0,0,0 ,NULL },
};
/********************************************************************************
item box program's
********************************************************************************/
extern void s_qbox_mark(void)
{
if ( execstp->motherobj->s[stw_mode].d != mode_itembox_disable ) s_remove_obj(execstp);
}
/*------------------------------------------*/
/* itembox initalize */
/*------------------------------------------*/
static void itembox_init(void)
{
/*==== backup read ====*/
if ( obj_programselect < 3 ){
obj_animecounter = obj_programselect;
if ( ( BuGetItemFlag() & backup_switchtable[obj_programselect] ) || obj_actor_high ) obj_mode = mode_itembox_enable;
else obj_mode = mode_itembox_disable;
} else {
obj_animecounter = 3;
obj_mode = mode_itembox_enable;
}
}
/*------------------------------------------*/
/* itembox disable */
/*------------------------------------------*/
static void itembox_disable(void)
{
s_hitOFF();
if ( obj_timer == 0 ){
s_makeobj_nowpos(execstp,S_qbox_mark,e_qbox_mark);
s_change_shape(S_qbox_box);
}
if ( ( BuGetItemFlag() & backup_switchtable[obj_programselect] ) || obj_actor_high ){
obj_mode = mode_itembox_enable;
s_change_shape(S_itembox);
}
}
/*------------------------------------------*/
/* wait program */
/*------------------------------------------*/
static void itembox_enable(void)
{
s_set_hitparam(execstp,&itembox_hit);
if ( obj_timer == 0 ){
s_shape_disp();
s_hitON();
obj_mail = 0;
obj_worldY = obj_attY;
obj_animepositionY = 0;
}
if ( s_block_hitcheck() ){
s_hitOFF();
qbox_work = 0x4000;
obj_speedY = 30;
obj_gravity = -8;
obj_groundY = obj_worldY;
obj_mode = mode_itembox_burn;
SendMotorEvent(5,80); /* MOTOR 1997.5.27 */
}
stMainMoveBG();
}
/*------------------------------------------*/
/* burn program */
/*------------------------------------------*/
static void itembox_burn(void)
{
StrategyRecord *stp;
s_optionmove_F();
if ( obj_speedY < 0 ){ obj_speedY = 0; obj_gravity = 0; }
qbox_scaleY = ((sin(qbox_work)+1.0) *0.3)+0,4;
qbox_scaleX = ((-sin(qbox_work)+1.0)*0.5)+1.0;
obj_animepositionY = (ITEM_BOX_SCALE*13)*(-sin(qbox_work)+1.0);
qbox_work += 0x1000;
execstp->map.scale[0] = ITEM_BOX_SCALE*qbox_scaleX;
execstp->map.scale[1] = ITEM_BOX_SCALE*qbox_scaleY;
execstp->map.scale[2] = ITEM_BOX_SCALE*qbox_scaleX;
if ( obj_timer == 0x7 ) obj_mode = mode_itembox_makeitem;
}
static void s_itembox_makeobj(MakeIDJMP *table,unsigned char code)
{
StrategyRecord *stp = NULL;
while( table->code != ITEMCODE_END ){
if ( code == table->code ){
stp = s_makeobj_nowpos(execstp,table->shape,table->path);
stp->s[stw_speedY].f = 20;
stp->s[stw_speedF].f = 3;
stp->s[stw_angleY].d = player1stp->s[stw_angleY].d;
execstp->s[stw_actorcode].d |= ( ( table->status ) << 24 );
if (table->shape == S_polystar ) Mbitset(obj_mainflag,stf_NOramsave);
break;
}
table++;
}
}
static void itembox_makeitem(void)
{
s_itembox_makeobj(itembox_table,obj_programselect);
s_burneffect(0,0,46);
s_boxeffect(20,S_polygon_hoshi,0.3,obj_animecounter);
obj_remove_sound(NA_SE2_BLOCK_BURST);
if ( obj_programselect < 3 ){
obj_mode = mode_itembox_return;
s_shape_hide();
} else {
s_remove_obj(execstp);
}
}
static void itembox_return(void)
{
if ( obj_timer >ITEMHAT_TIME ){
obj_mode = mode_itembox_enable;
}
}
/*------------------------------------------*/
/* itembox main */
/*------------------------------------------*/
static void *itembox_modejmp[] = {
itembox_init,
itembox_disable,
itembox_enable,
itembox_burn,
itembox_makeitem,
itembox_return
};
extern void s_itembox(void)
{
s_set_scale(ITEM_BOX_SCALE);
s_modejmp(itembox_modejmp);
}
/*################*/
#endif
/*################*/