Word TStringStack::popw(){ Word _RetWord=0; if (!String) return (Word)0; _RetWord=(Word)popb(); _RetWord+=(Word)popb()<<8; return _RetWord; }
void game_logic(void ) { int i,xx,yy,dir[2][4] = {{0,1,0,-1},{-1,0,1,0}}; void (*act)(int); get_status(); if (st.stench) gmap[player_x][player_y][1]=1; if (st.breeze) gmap[player_x][player_y][2]=1; if (st.glitter) continue_game=0; if (st.grim_reaper) continue_game=0; if (ai) {/* do magic */ if (st.stench || st.breeze) {act=&pushb; } else {act=&push;} if (continue_game==0) return; for (i=0;i<4;i++) { xx = player_x+dir[0][i]; yy = player_y+dir[1][i]; if (xx >= 0 && xx < world_x && yy >= 0 && yy < world_y) { if (aiw[xx][yy]==0) { act(xx);act(yy); aiw[xx][yy]=1; } } } player_y = pop(); player_x = pop(); if (player_x<0 || player_y<0) { player_y = popb(); player_x = popb(); } if (player_x<0 || player_y<0) continue_game=0; gmap[player_x][player_y][0]=1; } }
void maxfilt_centered_double_inplace( double *a, int len, int support ) { static double **U = NULL; static size_t maxUbytes = 0; size_t maxU,maxR; unsigned int iUf,iUb,iRf,iRb; static double *R = NULL; static size_t maxRbytes = 0; double *e; int off = support; int c = support/2+1; double this,last; assert(support > 2); U = request_storage_pow2items(U,&maxUbytes,sizeof(double*), 2*support , "maxfilt_centered_double_inplace"); maxU = maxUbytes / sizeof(double*) - 1; iUf = maxU/2-1; iUb = maxU/2; R = request_storage_pow2items(R,&maxRbytes,sizeof(double), 2*(off-c), "maxfilt_centered_double_inplace"); maxR = maxRbytes / sizeof(double) - 1; iRf=-1; iRb=0; //The middle (support entirely in interval) last = *a; for( e=a+1; e < a+len; e++ ) { this = *e; if( e-a >= c ) pushf(R) = isempty(U) ? last : *peekf(U); if( e-a >= off ) e[-off] = popb(R); //progress("iRf:%5d\tiUf:%5d\tiUb:%5d\tsz:%5d\n",iRf,iUf,iUb,iUf-iUb+1); if( this > last ) { while( !isempty(U) ) { if( this <= *peekb(U) ) { if( e-off == peekf(U) ) popf_noassign(U); break; } if( !isempty(U) ) popb_noassign(U); } } else { pushb(U) = e-1; if( (e-off) == peekf(U) ) popf_noassign(U); } last = this; } //The end for( ; e <= a+len+c; e++ ) { pushf(R) = isempty(U) ? e[-1] : *peekf(U); e[-off] = popb(R); pushb(U) = e-1; if( (e-off) == peekf(U) ) popf_noassign(U); } }
Byte TStringStack::pop(){ return popb(); }
void handle_v86_fault( Virtual86Regs_s * regs, uint32 nErrorCode ) { unsigned char *csp, *ssp; unsigned long ip, sp; int nInst; // if ( 0xffff == (regs->eip & 0xffff) && 0xffff == regs->cs ) { // return_to_32bit( regs, 0 ); // return; // } csp = ( unsigned char * )( regs->cs << 4 ); ssp = ( unsigned char * )( regs->ss << 4 ); sp = regs->esp & 0xffff; ip = regs->eip & 0xffff; nInst = popb( csp, ip ); switch ( nInst ) { /* Operand size override */ case 0x66: printk( "WARNING : 32 bit code run in v86 mode! Flags are not handled properly!\n" ); nInst = popb( csp, ip ); switch ( nInst ) { /* pushfd */ case 0x9c: regs->esp = ( regs->esp - 4 ) & 0xffff; regs->eip = ( regs->eip + 2 ) & 0xffff; pushl( ssp, sp, regs->eflags ); return; /* popfd */ case 0x9d: regs->esp = ( regs->esp + 4 ) & 0xffff; regs->eip = ( regs->eip + 2 ) & 0xffff; regs->eflags = popl( ssp, sp ); return; /* iretd */ case 0xcf: regs->esp = ( regs->esp + 12 ) & 0xffff; regs->eip = ( uint16 )( popl( ssp, sp ) & 0xffff ); regs->cs = ( uint16 )popl( ssp, sp ); return; /* need this to avoid a fallthrough */ default: printk( "ERROR : unknown v86 32 bit instruction %x\n", nInst ); return_to_32bit( regs, -EFAULT ); } /* pushf */ case 0x9c: regs->esp = ( regs->esp - 2 ) & 0xffff; regs->eip = ( regs->eip + 1 ) & 0xffff; pushw( ssp, sp, regs->eflags & 0xffff ); return; /* popf */ case 0x9d: regs->esp = ( regs->esp + 2 ) & 0xffff; regs->eip = ( regs->eip + 1 ) & 0xffff; regs->eflags = ( regs->eflags & 0xffff0000 ) | ( popw( ssp, sp ) & 0xffff ); return; /* int xx */ case 0xcd: { int intno = popb( csp, ip ); regs->eip = ( regs->eip + 2 ) & 0xffff; do_int( regs, intno, ssp, sp ); return; } /* iret */ case 0xcf: regs->esp = ( regs->esp + 6 ) & 0xffff; regs->eip = popw( ssp, sp ) & 0xffff; regs->cs = popw( ssp, sp ); regs->eflags = ( regs->eflags & 0xffff0000 ) | ( popw( ssp, sp ) & 0xffff ); if ( 0xffff == ( regs->eip & 0xffff ) && 0xffff == regs->cs ) { return_to_32bit( regs, 0 ); } return; /* cli */ case 0xfa: regs->eip = ( regs->eip + 1 ) & 0xffff; regs->eflags &= ~EFLG_IF; return; /* sti */ case 0xfb: /* The interrupts should actually be restored after the NEXT instruction! * Hope this works. As long as no DOS/BIOS code swaps the stack, * nothing bad should happen. */ regs->eip = ( regs->eip + 1 ) & 0xffff; regs->eflags |= EFLG_IF; return; default: printk( "ERROR : unknown v86 16 bit instruction %x\n", nInst ); return_to_32bit( regs, -EFAULT ); } }