Add vbuCodeSize()
This commit is contained in:
		
							parent
							
								
									f45636a491
								
							
						
					
					
						commit
						18b2c589e6
					
				|  | @ -1085,11 +1085,13 @@ static void vipDrawAffine(VB *sim, World *world) { | ||||||
|                 pixel = cell->pixels[(py & 7) << 3 | (px & 7)]; |                 pixel = cell->pixels[(py & 7) << 3 | (px & 7)]; | ||||||
|                 if (pixel != 0) |                 if (pixel != 0) | ||||||
|                     *col = cell->palette[pixel]; |                     *col = cell->palette[pixel]; | ||||||
|             } |  | ||||||
| 
 | 
 | ||||||
|         } |             } /* x */ | ||||||
|  | 
 | ||||||
|  |         } /* y */ | ||||||
|  | 
 | ||||||
|  |     } /* i */ | ||||||
| 
 | 
 | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Draw an object group into shadow memory */ | /* Draw an object group into shadow memory */ | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| /* This file is included into vb.c and cannot be compiled on its own. */ | /* This file is included into vbu.c and cannot be compiled on its own. */ | ||||||
| #ifdef VBUAPI | #ifdef VBUAPI | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -449,12 +449,6 @@ static VBU_DasmLine* dasmGrow( | ||||||
|     return *lines == NULL ? NULL : &(*lines)[index]; |     return *lines == NULL ? NULL : &(*lines)[index]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Determine the size of an instruction */ |  | ||||||
| static uint32_t dasmInstSize(VB *sim, uint32_t address) { |  | ||||||
|     unsigned opcode = vbRead(sim, address, VB_U16) >> 10 & 63; |  | ||||||
|     return opcode < 0x20 || opcode == 0x32 || opcode == 0x36 ? 2 : 4; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* Format an operand */ | /* Format an operand */ | ||||||
| static void dasmOperand(char *dest, VBU_DasmConfig *config, | static void dasmOperand(char *dest, VBU_DasmConfig *config, | ||||||
|     VBU_DasmLine *line, uint8_t type) { |     VBU_DasmLine *line, uint8_t type) { | ||||||
|  | @ -515,7 +509,7 @@ static int dasmLine(VB *sim, uint32_t *address, uint32_t pc, | ||||||
|     /* Process non-text members */ |     /* Process non-text members */ | ||||||
|     line = &(*lines)[index]; |     line = &(*lines)[index]; | ||||||
|     line->address    = *address; |     line->address    = *address; | ||||||
|     line->codeLength = dasmInstSize(sim, *address); |     line->codeLength = vbuCodeSize(sim, *address); | ||||||
|     line->isPC       = *address == pc; |     line->isPC       = *address == pc; | ||||||
|     for (x = 0; x < line->codeLength; x++) |     for (x = 0; x < line->codeLength; x++) | ||||||
|         line->code[x] = vbRead(sim, *address + x, VB_U8); |         line->code[x] = vbRead(sim, *address + x, VB_U8); | ||||||
|  | @ -660,7 +654,7 @@ static VBU_DasmLine* dasmDisassemble(VB *sim, uint32_t address, | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /* Check if the instruction contains the reference address */ |         /* Check if the instruction contains the reference address */ | ||||||
|         size = dasmInstSize(sim, addr); |         size = vbuCodeSize(sim, addr); | ||||||
|         if (address - addr < size) |         if (address - addr < size) | ||||||
|             break; |             break; | ||||||
|         addr += addr != pc && pc - addr < size ? pc - addr : size; |         addr += addr != pc && pc - addr < size ? pc - addr : size; | ||||||
|  | @ -674,7 +668,7 @@ static VBU_DasmLine* dasmDisassemble(VB *sim, uint32_t address, | ||||||
| 
 | 
 | ||||||
|     /* Keep decoding until the first line of output */ |     /* Keep decoding until the first line of output */ | ||||||
|     else for (; line < 0; line++) |     else for (; line < 0; line++) | ||||||
|         addr += dasmInstSize(sim, addr); |         addr += vbuCodeSize(sim, addr); | ||||||
| 
 | 
 | ||||||
|     /* Working variables */ |     /* Working variables */ | ||||||
|     size   = length * sizeof (VBU_DasmLine); |     size   = length * sizeof (VBU_DasmLine); | ||||||
|  |  | ||||||
|  | @ -38,6 +38,12 @@ static int32_t SignExtend(int32_t value, int32_t bits) { | ||||||
| 
 | 
 | ||||||
| /******************************* API Commands ********************************/ | /******************************* API Commands ********************************/ | ||||||
| 
 | 
 | ||||||
|  | /* Determine the size in bytes of an instruction */ | ||||||
|  | VBUAPI int vbuCodeSize(VB *sim, uint32_t address) { | ||||||
|  |     int opcode = vbRead(sim, address, VB_U16) >> 10 & 63; | ||||||
|  |     return opcode < 0x20 || opcode == 0x32 || opcode == 0x36 ? 2 : 4; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* Initialize disassembler options with default settings */ | /* Initialize disassembler options with default settings */ | ||||||
| VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) { | VBUAPI VBU_DasmConfig* vbuDasmInit(VBU_DasmConfig *config) { | ||||||
|     config->bcondNotation     = VBU_JOINED; |     config->bcondNotation     = VBU_JOINED; | ||||||
|  |  | ||||||
|  | @ -85,6 +85,7 @@ typedef struct { | ||||||
| 
 | 
 | ||||||
| /******************************* API Commands ********************************/ | /******************************* API Commands ********************************/ | ||||||
| 
 | 
 | ||||||
|  | VBUAPI int             vbuCodeSize   (VB *sim, uint32_t address); | ||||||
| VBUAPI VBU_DasmConfig* vbuDasmInit   (VBU_DasmConfig *config); | VBUAPI VBU_DasmConfig* vbuDasmInit   (VBU_DasmConfig *config); | ||||||
| VBUAPI VBU_DasmLine*   vbuDisassemble(VB *sim, uint32_t address, VBU_DasmConfig *config, unsigned length, int line); | VBUAPI VBU_DasmLine*   vbuDisassemble(VB *sim, uint32_t address, VBU_DasmConfig *config, unsigned length, int line); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue