// --------------------- Opcodes 0x4880+ --------------------- // Emit an Ext opcode, 01001000 1x000nnn int OpExt(int op) { int ea=0; int size=0,use=0; int shift=0; ea=op&0x0007; size=(op>>6)&1; shift=32-(8<<size); use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op); Cycles=4; EaCalc (11,0x0007,ea,size+1,0,0); EaRead (11, 0,ea,size+1,0x0007,0,0); ot(" mov r0,r0,asl #%d\n",shift); ot(" adds r0,r0,#0 ;@ Defines NZ, clears CV\n"); ot(" mrs r10,cpsr ;@ r10=flags\n"); ot(" mov r1,r0,asr #%d\n",shift); ot("\n"); EaWrite(11, 1,ea,size+1,0x0007,0,0); OpEnd(); return 0; }
// --------------------- Opcodes 0x4880+ --------------------- // Emit an Ext opcode, 01001000 1x000nnn int OpExt(int op) { int ea=0; int size=0,use=0; int shift=0; ea=op&0x0007; size=(op>>6)&1; shift=32-(8<<size); use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op); Cycles=4; EaCalc (11,0x0007,ea,size+1,earwt_msb_dont_care); EaRead (11, 0,ea,size+1,0x0007,earwt_msb_dont_care); ot(" movs r0,r0,asl #%d\n",shift); OpGetFlagsNZ(0); ot(" mov r1,r0,asr #%d\n",shift); ot("\n"); EaWrite(11, 1,ea,size+1,0x0007,earwt_msb_dont_care); OpEnd(); return 0; }
/* * report errors */ void errorsummary (void) { if (ncmp) error("missing closing bracket"); nl(); comment(); outdec(errcnt); if (errcnt) errfile = YES; outstr(" error(s) in compilation"); nl(); comment(); ot("literal pool:"); outdec(litptr); nl(); comment(); ot("constant pool:"); outdec(const_size); nl(); comment(); ot("global pool:"); outdec(glbptr - rglbptr); nl(); comment(); ot("Macro pool:"); outdec(macptr); nl(); pl(errcnt ? "Error(s)" : "No errors"); }
// --------------------- Opcodes 0x4a00+ --------------------- // Emit a Tst opcode, 01001010 xxeeeeee int OpTst(int op) { int sea=0; int size=0,use=0; sea=op&0x003f; size=(op>>6)&3; if (size>=3) return 1; // See if we can do this opcode: if (EaCanWrite(sea)==0||EaAn(sea)) return 1; use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,sea); Cycles=4; EaCalc ( 0,0x003f,sea,size,1); EaRead ( 0, 0,sea,size,0x003f,1); ot(" adds r0,r0,#0 ;@ Defines NZ, clears CV\n"); ot(" mrs r10,cpsr ;@ r10=flags\n"); ot("\n"); OpEnd(sea); return 0; }
int DamPut8(char *From,int r,int Ext) { // Put register r from From (must be dl for reg 6) if (r==6) { ot(" DAM_WRITE8\n"); return 0; } ot(" mov %s,%s\n",DamLoc8(r,Ext),From); return 0; }
int DamGet8(char *To ,int r,int Ext) { // Get register r into To (must be dl for reg 6) if (r==6) { ot(" DAM_READ8\n"); return 0; } ot(" mov %s,%s\n",To,DamLoc8(r,Ext)); return 0; }
// sets ZN for reg in *reg static void SetZN16(char *reg) { ot(" and spc_p,spc_p,#0xff\n"); ot(" orr spc_p,spc_p,%s,lsl #16\n", reg); ot(" tst %s,#0xff\n", reg); ot(" orrne spc_p,spc_p,#0x01000000\n"); }
// Trashes r0-r3 static void MemHandler(int set, int z, int save) { if(set) ot(" bl S9xAPUSetByte%s\n", z ? "Z" : ""); else ot(" bl S9xAPUGetByte%s\n", z ? "Z" : ""); if(save) ot(" ldr spc_ram,[context,#iapu_ram]\n"); }
static void SetClr1() { ot(" ldrb r0,[spc_pc]\n"); MemHandler(0, 1, 0); ot(" %s r0,r0,#0x%02x\n", opcode & 0x10 ? "bic" : "orr", 1<<(opcode>>5)); ot(" ldrb r1,[spc_pc],#1\n"); MemHandler(1, 1, 1); }
static void TCall() { ot(" sub r0,spc_pc,spc_ram\n"); PushW(); ot(" ldr r0,[context,#iapu_extraram]\n"); ot(" ldrh r0,[r0,#0x%x]\n", (15-(opcode>>4))<<1); ot(" add spc_pc,spc_ram,r0\n"); }
// does LSR on r0, sets flags static void Lsr() { ot(" tst r0,#0x01\n"); ot(" orrne spc_p,spc_p,#flag_c\n"); ot(" biceq spc_p,spc_p,#flag_c\n"); ot(" mov r0,r0,lsr #1\n"); SetZN8("r0"); }
// does ASL on r0, sets flags but doesn't cut the shifted bits static void Asl() { ot(" tst r0,#0x80\n"); ot(" orrne spc_p,spc_p,#flag_c\n"); ot(" biceq spc_p,spc_p,#flag_c\n"); ot(" mov r0,r0,lsl #1\n"); SetZN8("r0"); }
// pops to r0, trashes r1 static void PopW() { ot(" add spc_s,spc_s,#2\n"); ot(" add r1,spc_ram,spc_s\n"); ot(" ldrb r0,[r1,#0xff]\n"); ot(" ldrb r1,[r1,#0x100]\n"); ot(" orr r0,r0,r1,lsl #8\n"); }
// pushes r0, trashes r0,r1 static void PushW() { ot(" add r1,spc_ram,spc_s\n"); ot(" strb r0,[r1,#0xff]\n"); ot(" mov r0,r0,lsr #8\n"); ot(" strb r0,[r1,#0x100]\n"); ot(" sub spc_s,spc_s,#2\n"); }
// does ROR on r0, sets flags static void Ror() { ot(" tst spc_p,#flag_c\n"); ot(" orrne r0,r0,#0x100\n"); ot(" movs r0,r0,lsr #1\n"); ot(" orrcs spc_p,spc_p,#flag_c\n"); ot(" biccc spc_p,spc_p,#flag_c\n"); SetZN8("r0"); }
// Get X Bit into carry - trashes r2 int GetXBit(int subtract) { ot(";@ Get X bit:\n"); ot(" ldr r2,[r7,#0x4c]\n"); if (subtract) ot(" mvn r2,r2 ;@ Invert it\n"); ot(" msr cpsr_flg,r2 ;@ Get into Carry\n"); ot("\n"); return 0; }
int DamAddPc(int n) { // Increase the PC by n if (n== 1) ot(" inc %s\n",DamPc); else if (n==-1) ot(" dec %s\n",DamPc); else if (n > 0) ot(" add %s,%d\n",DamPc, n); else if (n < 0) ot(" sub %s,%d\n",DamPc,-n); return 0; }
void DamIxIyOffset(int nRel) { // Get IX/IY offset from PC+nRel ot(" ; Get IX/IY offset into di\n"); DamFetch(nRel,1); ot(" xor dh,dh\n"); ot(" xor dl,0x80\n"); ot(" sub dx,0x80\n"); ot(" mov di,dx\n"); }
// CMP rr0,rr1; trashes r12 static void Cmp(char *r0, char *r1, int and_r0) { char *lop = r0; if(and_r0) { ot(" and r12,%s,#0xff\n", r0); lop = "r12"; } ot(" subs r12,%s,%s\n", lop, r1); ot(" orrge spc_p,spc_p,#flag_c\n"); ot(" biclt spc_p,spc_p,#flag_c\n"); SetZN8("r12"); }
static void BssBbc() { ot(" ldrb r0,[spc_pc],#1\n"); MemHandler(0, 1, 1); ot(" tst r0,#0x%02x\n", 1<<(opcode>>5)); ot(" add%s spc_pc,spc_pc,#1\n", opcode & 0x10 ? "ne" : "eq"); ot(" ldr%ssb r0,[spc_pc],#1\n", opcode & 0x10 ? "eq" : "ne"); ot(" add%s spc_pc,spc_pc,r0\n", opcode & 0x10 ? "eq" : "ne"); ot(" sub%s cycles,cycles,#%i\n",opcode & 0x10 ? "eq" : "ne", ONE_APU_CYCLE*2); }
int OpTas(int op, int gen_special) { int ea=0; int use=0; ea=op&0x003f; // See if we can do this opcode: if (EaCanWrite(ea)==0 || EaAn(ea)) return 1; use=OpBase(op,0); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler if (!gen_special) OpStart(op,ea); else ot("Op%.4x_%s\n", op, ms?"":":"); Cycles=4; if(ea>=8) Cycles+=10; EaCalc (11,0x003f,ea,0,1); EaRead (11, 1,ea,0,0x003f,1); ot(" adds r1,r1,#0 ;@ Defines NZ, clears CV\n"); OpGetFlags(0,0); ot("\n"); #if CYCLONE_FOR_GENESIS // the original Sega hardware ignores write-back phase (to memory only) if (ea < 0x10 || gen_special) { #endif ot(" orr r1,r1,#0x80000000 ;@ set bit7\n"); EaWrite(11, 1,ea,0,0x003f,1); #if CYCLONE_FOR_GENESIS } #endif OpEnd(ea); #if (CYCLONE_FOR_GENESIS == 2) if (!gen_special && ea >= 0x10) { OpTas(op, 1); } #endif return 0; }
/* Put out assembler info before any code is generated */ header() { comment(); outstr(Banner); nl(); comment(); outstr(Author); nl(); comment(); outstr(Version); nl(); comment(); nl(); if ( trace ) { ol("global ccregis"); /* declare these */ ol("global ccleavi"); /* tracing routine */ } if ( mainflg ) { /* do stuff needed for first */ ol("LD HL,(6)"); /* set up stack */ ol("LD SP,HL"); callrts("ccgo"); /* set default drive for CP/M */ zcall("main"); /* call code generated by small-c */ zcall("exit"); } else { /* not main program, output module name */ ot("module "); if ( Filename[1] == ':' ) outstr(&Filename[2]); else outstr(Filename) ; nl(); } }
void DamGetHL(int Ext) { // Get the HL pointer, or if extended the IX/IY pointer if (Ext!=0xdd && Ext!=0xfd) Ext=0; if (Ext==0) DamGet16("di",2,Ext); else ot(" add di,%s\n",DamLoc16(2,Ext)); }
bool MProject::tryOpenTargetFile( long version, bool try_checkout, MComponent* comp ) { WObjectFile ot( version ); if( !ot.open( comp->filename(), OStyleWriteB ) ) { if( _checkout && try_checkout ) { if( sayf( SayInfo, SayOkCancel, "Target file '%s' is read-only. checkout? ", (const char*)comp->filename() ) == RetOk ) { if( (_RCSCli->*_checkout)( &(comp->filename()), _filename, comp->filename() ) ) { return( tryOpenTargetFile( version, false, comp ) ); } } } sayf( SayWarning, SayOk, "IDE Error: Unable to write target file '%s'", (const char*)comp->filename() ); return( false ); } else { _recursing = true; ot.writeObject( _targetIdent ); ot.writeObject( this ); ot.writeObject( comp ); _recursing = false; ot.close(); return( true ); } }
// Get flags, trashes r2 int OpGetFlags(int subtract,int xbit,int specialz) { if (specialz) ot(" orr r2,r10,#0xb0000000 ;@ for old Z\n"); ot(" mrs r10,cpsr ;@ r10=flags\n"); if (specialz) ot(" andeq r10,r10,r2 ;@ fix Z\n"); if (subtract) ot(" eor r10,r10,#0x20000000 ;@ Invert carry\n"); if (xbit) { ot(" str r10,[r7,#0x4c] ;@ Save X bit\n"); } return 0; }
void Selection3DDisplayCustom::queryContext( int x, int y ) { float win_width = render_panel_->width(); float win_height = render_panel_->height(); //then send a raycast straight out from the camera at the mouse's position Ogre::Ray mouseRay = this->render_panel_->getCamera()->getCameraToViewportRay((float)x/win_width, (float)y/win_height); Ogre::Vector3 position; Ogre::Vector3 pt(0,0,0); Ogre::Quaternion ot(1,0,0,0); transform(pt,ot,"/world",fixed_frame_.toUtf8().constData()); int type = -1; std::string name; if(raycast_utils_->RayCastFromPoint(mouseRay,pt,ot,position,type,name)) { //ROS_ERROR("COLLIDED WITH %s %d",name.c_str(), type); // type 0 -> UNKNOWN ENTITY // type 1 -> POINT CLOUD // type 2 -> WAYPOINT // type 3 -> TEMPLATE Q_EMIT setContext(type,name); } else { Q_EMIT setContext(-1,""); // NO_HIT } }
// --------------------- Opcodes 0x4a00+ --------------------- // Emit a Tst opcode, 01001010 xxeeeeee int OpTst(int op) { int sea=0; int size=0,use=0; sea=op&0x003f; size=(op>>6)&3; if (size>=3) return 1; // See if we can do this opcode: if (EaCanWrite(sea)==0||EaAn(sea)) return 1; use=OpBase(op,size); if (op!=use) { OpUse(op,use); return 0; } // Use existing handler OpStart(op,sea); Cycles=4; EaCalc (0,0x003f,sea,size,earwt_shifted_up); EaRead (0, 0,sea,size,0x003f,earwt_shifted_up,1); OpGetFlagsNZ(0); ot("\n"); OpEnd(sea); return 0; }
void doload_backgroundstatement(void) { /* syntax is name of the beginning of the data pattern : identifier name of the 16 palettes : identifier name of the bat : identifier width (in tiles [8x8] ) : integer height (in tiles [8x8] ) : integer */ flush_ins(); /* David, optimize.c related */ ot("_load_background\t"); if (outnameunderline()) return; if (outcomma()) return; if (outnameunderline()) return; if (outcomma()) return; if (outnameunderline()) return; if (outcomma()) return; if (outconst()) return; if (outcomma()) return; if (outconst()) return; newl(); needbrack(")"); }
void doload_spritesstatement(void) { /* syntax is offset in vram to load data at : integer name of the data to transfert : identifier number of sprites (of size 32x64) to load : integer */ flush_ins(); /* David, optimize.c related */ ot("load_sprites\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }
void doset_sprpalstatement(void) { /* syntax is number of the first palette to alter : integer name of the data for loading palettes : identifier [ number of palette to load : integer ] if last argument is missing, 1 is assumed */ flush_ins(); /* David, optimize.c related */ ot("_set_sprpal\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }