Add secondary joystick hard drop and deliver build 05
This commit is contained in:
1 parent
a07c41555a
commit
49bc78158a
21 files changed
+230
-35
No files matched your search
+59
-19
@@ -15,20 +15,33 @@ byte isKeyPressed(byte probe,byte bit)
|
||||
if((bit&15)&~raw_buttons)return 1;
|
||||
return probe==contact_probe&&(bit&contact_bit)!=0;
|
||||
}
|
||||
/* Existing keyboard-only fixtures leave joystick mapping disabled. */
|
||||
static Q16 read_keys(Q8 mode){return keyboard_read(&raw_buttons,mode,2);}
|
||||
static QActions port_poll(QInput *in,Q8 port,Q16 ms,Q8 playing)
|
||||
{
|
||||
Q16 held=keyboard_read(&raw_buttons,playing?KEYBOARD_PLAY:0,port);
|
||||
Q8 primary=port<2&&!(raw_buttons&(port==1?2:1));
|
||||
return q_input_step(in,held,primary,31,31,31,31,port<2,ms,playing,0);
|
||||
}
|
||||
static Q8 occupied(const QGame *g)
|
||||
{
|
||||
Q8 x,y,n=0;for(y=0;y<20;++y)for(x=0;x<10;++x)if(g->board.cells[y][x])++n;
|
||||
return n;
|
||||
}
|
||||
static QActions poll(QInput *in,Q8 button,Q16 ms)
|
||||
{
|
||||
return q_input_step(in,keyboard_read(&raw_buttons,KEYBOARD_PLAY),button,31,31,31,31,1,ms,1,0);
|
||||
return q_input_step(in,read_keys(KEYBOARD_PLAY),button,31,31,31,31,1,ms,1,0);
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
QInput in;QActions a;QGame game;QOptions options={0,Q_MODERN,0,1};Q8 pressed;
|
||||
/* CoCo right fire grounds A/D/E. It must not masquerade as left/right/CW. */
|
||||
raw_buttons=14;assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==0);
|
||||
raw_buttons=14;assert(read_keys(KEYBOARD_PLAY)==0);
|
||||
for(pressed=0;pressed<4;++pressed){
|
||||
raw_buttons=(Q8)(15&~(1<<pressed));
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==0);
|
||||
assert(read_keys(KEYBOARD_PLAY)==0);
|
||||
contact_probe=KEY_PROBE_BREAK;contact_bit=KEY_BIT_BREAK;
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_BACK);
|
||||
assert(read_keys(KEYBOARD_PLAY)==Q_BACK);
|
||||
contact_bit=0;
|
||||
}
|
||||
raw_buttons=15;q_input_reset(&in);poll(&in,0,0);
|
||||
@@ -41,27 +54,27 @@ int main(void)
|
||||
a=poll(&in,0,1);assert(!(a.pressed&(Q_CW|Q_CCW))&&game.active.rotation==1);
|
||||
/* Fire held while steering must not add opposing A/D or E actions. */
|
||||
q_input_reset(&in);poll(&in,0,0);raw_buttons=14;
|
||||
a=q_input_step(&in,keyboard_read(&raw_buttons,KEYBOARD_PLAY),1,0,31,31,31,1,1,1,0);
|
||||
a=q_input_step(&in,read_keys(KEYBOARD_PLAY),1,0,31,31,31,1,1,1,0);
|
||||
assert(a.move==-1&&a.repeats==1&&!(a.pressed&Q_CW));
|
||||
a=q_input_step(&in,keyboard_read(&raw_buttons,KEYBOARD_PLAY),1,63,31,31,31,1,1,1,0);
|
||||
a=q_input_step(&in,read_keys(KEYBOARD_PLAY),1,63,31,31,31,1,1,1,0);
|
||||
assert(a.move==1&&a.repeats==1&&!(a.pressed&Q_CW));
|
||||
/* Clockwise preference also yields one edge on release, not on press. */
|
||||
raw_buttons=15;q_input_reset(&in);poll(&in,0,0);raw_buttons=14;
|
||||
a=q_input_step(&in,keyboard_read(&raw_buttons,KEYBOARD_PLAY|KEYBOARD_CLOCKWISE),1,31,31,31,31,1,100,1,1);
|
||||
a=q_input_step(&in,read_keys(KEYBOARD_PLAY|KEYBOARD_CLOCKWISE),1,31,31,31,31,1,100,1,1);
|
||||
assert(!(a.pressed&(Q_CW|Q_CCW)));raw_buttons=15;
|
||||
a=q_input_step(&in,keyboard_read(&raw_buttons,KEYBOARD_PLAY|KEYBOARD_CLOCKWISE),0,31,31,31,31,1,1,1,1);
|
||||
a=q_input_step(&in,read_keys(KEYBOARD_PLAY|KEYBOARD_CLOCKWISE),0,31,31,31,31,1,1,1,1);
|
||||
assert((a.pressed&Q_CW)&&!(a.pressed&Q_CCW));
|
||||
/* Real keyboard aliases still work when their shared row is available. */
|
||||
contact_probe=KEY_PROBE_E;contact_bit=KEY_BIT_E;assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_CW);
|
||||
contact_probe=KEY_PROBE_A;contact_bit=KEY_BIT_A;assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_LEFT);
|
||||
contact_probe=KEY_PROBE_D;contact_bit=KEY_BIT_D;assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_RIGHT);
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_INITIALS)==0);
|
||||
contact_probe=KEY_PROBE_E;contact_bit=KEY_BIT_E;assert(read_keys(KEYBOARD_PLAY)==Q_CW);
|
||||
contact_probe=KEY_PROBE_A;contact_bit=KEY_BIT_A;assert(read_keys(KEYBOARD_PLAY)==Q_LEFT);
|
||||
contact_probe=KEY_PROBE_D;contact_bit=KEY_BIT_D;assert(read_keys(KEYBOARD_PLAY)==Q_RIGHT);
|
||||
assert(read_keys(KEYBOARD_INITIALS)==0);
|
||||
contact_probe=KEY_PROBE_UP;contact_bit=KEY_BIT_UP;
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_CCW);
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY|KEYBOARD_CLOCKWISE)==Q_CW);
|
||||
assert(read_keys(KEYBOARD_PLAY)==Q_CCW);
|
||||
assert(read_keys(KEYBOARD_PLAY|KEYBOARD_CLOCKWISE)==Q_CW);
|
||||
contact_probe=KEY_PROBE_SPACE;contact_bit=KEY_BIT_SPACE;
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==Q_HARD);
|
||||
assert(keyboard_read(&raw_buttons,0)==Q_CONFIRM);
|
||||
assert(read_keys(KEYBOARD_PLAY)==Q_HARD);
|
||||
assert(read_keys(0)==Q_CONFIRM);
|
||||
/* A fire press arriving after the opening sample must cause a rescan.
|
||||
* Every reachable scan boundary is checked, including held/released edges. */
|
||||
contact_bit=0;
|
||||
@@ -70,11 +83,11 @@ int main(void)
|
||||
for(line=0;line<4;++line){
|
||||
for(pressed=1;pressed<=15;++pressed){
|
||||
raw_buttons=15;probes=0;edge_at=pressed;edge_buttons=(Q8)(15&~(1<<line));
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==0&&!edge_at);
|
||||
assert(read_keys(KEYBOARD_PLAY)==0&&!edge_at);
|
||||
}
|
||||
for(pressed=1;pressed<=15-ambiguous[line];++pressed){
|
||||
raw_buttons=(Q8)(15&~(1<<line));probes=0;edge_at=pressed;edge_buttons=15;
|
||||
assert(keyboard_read(&raw_buttons,KEYBOARD_PLAY)==0&&!edge_at);
|
||||
assert(read_keys(KEYBOARD_PLAY)==0&&!edge_at);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +101,33 @@ int main(void)
|
||||
a=poll(&in,0,1);assert(!(a.pressed&(Q_CW|Q_CCW)));
|
||||
assert(game.active.rotation==(pressed+1)%4);
|
||||
}
|
||||
puts("PASS: shared fire/keyboard rows, one lasting fire-release rotation, unaffected keyboard rows and gameplay/menu aliases");
|
||||
/* Both physical secondary lines use the real adapter and edge handler.
|
||||
* Held fire drops one piece, without alias rotations or repeated drops. */
|
||||
for(pressed=0;pressed<2;++pressed){
|
||||
Q8 held_sample,secondary=(Q8)(pressed?8:4);
|
||||
raw_buttons=15;q_input_reset(&in);port_poll(&in,pressed,0,1);
|
||||
q_start(&game,&options);
|
||||
raw_buttons=(Q8)(15&~secondary);a=port_poll(&in,pressed,1,1);
|
||||
assert(a.pressed==Q_HARD);assert(q_drop(&game)&&occupied(&game)==4);
|
||||
for(held_sample=0;held_sample<8;++held_sample){
|
||||
a=port_poll(&in,pressed,500,1);assert(!a.pressed);
|
||||
if(a.pressed&Q_HARD)q_drop(&game);
|
||||
}
|
||||
assert(occupied(&game)==4);
|
||||
raw_buttons=15;a=port_poll(&in,pressed,1,1);assert(!a.pressed);
|
||||
raw_buttons=(Q8)(15&~secondary);a=port_poll(&in,pressed,1,1);
|
||||
assert(a.pressed==Q_HARD);assert(q_drop(&game)&&occupied(&game)==8);
|
||||
/* Wrong port and Off cannot turn this secondary into a hard drop. */
|
||||
assert(!(keyboard_read(&raw_buttons,KEYBOARD_PLAY,(Q8)(1-pressed))&Q_HARD));
|
||||
assert(!(keyboard_read(&raw_buttons,KEYBOARD_PLAY,2)&Q_HARD));
|
||||
assert(!keyboard_read(&raw_buttons,0,pressed));
|
||||
/* A held secondary across a menu/resume requires release first. */
|
||||
q_input_release(&in);a=port_poll(&in,pressed,1,1);assert(!a.pressed);
|
||||
a=port_poll(&in,pressed,1000,1);assert(!a.pressed);
|
||||
raw_buttons=15;port_poll(&in,pressed,1,1);
|
||||
raw_buttons=(Q8)(15&~secondary);a=port_poll(&in,pressed,1,1);
|
||||
assert(a.pressed==Q_HARD);
|
||||
}
|
||||
puts("PASS: shared fire/keyboard rows, one lasting fire-release rotation, unaffected keyboard rows, both secondary hard-drop buttons, held/transition guards and port selection");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user