{
char ch;
int nread;
+
if (peek != -1)
return 1;
+
newtio.c_cc[VMIN] = 0;
tcsetattr(0, TCSANOW, &newtio);
nread = read(0, &ch, 1);
newtio.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &newtio);
+
if (nread == 1) {
peek = ch;
return 1;
}
+
return 0;
}
getch(void)
{
char ch;
+
if (peek != -1) {
ch = peek;
peek = -1;
return ch;
}
+
read(0, &ch, 1);
+
return ch;
}
void
-InitUnixKB(void)
+keyboard_init(void)
{
tcgetattr(0, &orig);
newtio = orig;
}
void
-ResetUnixKB(void)
+keyboard_reset(void)
{
tcsetattr(0, TCSANOW, &orig);
}
getch(void);
void
-InitUnixKB(void);
+keyboard_init(void);
void
-ResetUnixKB(void);
+keyboard_reset(void);
#endif /* _KEYBOARD_H_ */
cpu8051_init();
if (options.filename != NULL) {
- rc = LoadHexFile(options.filename);
+ rc = hexfile_load(options.filename);
if (rc == false)
exit(1);
}
int
menu_get_input(char *buf, ssize_t size)
{
- char *line;
+ char *line;
int max_len;
max_len = size - 2;
- if (feof(yyin))
- return YY_NULL;
+ if (feof(yyin))
+ return YY_NULL;
#ifdef HAVE_LIBREADLINE
/* Get the input line, and if non-empty, place it in the history. */
line = readline(MENU_PROMPT);
- if (!line)
- return YY_NULL;
+ if (!line)
+ return YY_NULL;
if (line && *line)
add_history(line);
- if ((int) strlen(line) > max_len) {
- printf("input line too long");
- return YY_NULL;
- }
+ if ((int) strlen(line) > max_len) {
+ printf("input line too long");
+ return YY_NULL;
+ }
- strcpy(buf, line);
+ strcpy(buf, line);
/* Readline never gives you the last '\n', so add it back for Lex. */
- strcat(buf, "\n");
+ strcat(buf, "\n");
- free(line);
+ free(line);
#else
/* It's okay to print a prompt if we are redirecting stdout,
* as long as stdin is still a tty. Otherwise, don't print
return YY_NULL;
#endif
- return strlen(buf);
+ return strlen(buf);
}
void
/* Disassemble NumberInst instructions at Address */
void
-DisasmN(unsigned int Address, int NumberInst)
+disassemble_num(unsigned int address, int num)
{
- char TextTmp[255];
- int Row;
+ char str[255];
+ int row;
- for (Row = 0; Row < NumberInst ; Row++) {
- Address += cpu8051_Disasm(Address, TextTmp);
- printf("%s\n", TextTmp);
+ for (row = 0; row < num; row++) {
+ address += cpu8051_disasm(address, str);
+ printf("%s\n", str);
- if (Address > 0xFFFF)
+ if (address > 0xFFFF)
return;
}
}
/* Capitalize all letters in buffer */
static void
-Capitalize(char *buffer)
+uppercase(char *buffer)
{
size_t k;
/* Set NewValue to Register */
void
-SetRegister(char *register_name, int new)
+register_set(char *name, int value)
{
struct regwin_infos_t *regwin_infos;
- Capitalize(register_name);
+ uppercase(name);
- log_debug(" Modify register %s to $%04X", register_name, new);
+ log_debug(" Modify register %s to $%04X", name, value);
- regwin_infos = sfr_get_infos(register_name);
+ regwin_infos = sfr_get_infos(name);
if (regwin_infos == NULL) {
printf("Invalid register name\n");
return;
}
- regwin_write(regwin_infos, new);
+ regwin_write(regwin_infos, value);
}
/* CPU reset and Console UI update */
console_reset(void)
{
log_info("Resetting...");
- cpu8051_Reset();
+ cpu8051_reset();
log_info("Done");
}
/*
* CPU exec and Console UI update
- * NbInst = -1: run to infinity
+ * num = number of instructions to execute.
+ * set to -1: run to infinity
*/
void
-console_exec(int NbInst)
+console_exec(int num)
{
- InitUnixKB();
+ keyboard_init();
log_info("Program executing...");
- cpu8051_run(NbInst, kbhit);
+ cpu8051_run(num, kbhit);
if (kbhit()) {
(void) getch(); /* Flush key */
log_info("Caught break signal!");
}
- ResetUnixKB();
+ keyboard_reset();
console_show_registers();
- DisasmN(cpu8051.pc, 1);
+ disassemble_num(cpu8051.pc, 1);
}
/* CPU trace and Console UI update */
void
console_trace(void)
{
- cpu8051_Exec();
+ cpu8051_exec();
console_show_registers();
- DisasmN(cpu8051.pc, 1);
+ disassemble_num(cpu8051.pc, 1);
}
/* Show CPU registers, one per line */
{
int id;
unsigned char PSW = cpu8051_ReadD(_PSW_);
- int BankSelect = (PSW & 0x18);
+ int bank_sel = (PSW & 0x18);
- printf("---------------------------------------------------------------"
- "-------\n");
- printf("| PC | SP | DPTR | ACC | B | PSW: CY AC F0 RS1 RS0 OV"
- " - P |\n");
+ printf("----------------------------------------------------------------------\n");
+ printf("| PC | SP | DPTR | ACC | B | PSW: CY AC F0 RS1 RS0 OV - P |\n");
printf("| %.4X | %.2X | %.4X | %.2X | %.2X |", cpu8051.pc,
- cpu8051_ReadD(_SP_),
- memory_sfr_read_dptr(),
+ cpu8051_ReadD(_SP_), memory_sfr_read_dptr(),
cpu8051_ReadD(_ACC_), cpu8051_ReadD(_B_));
printf(" %d %d %d %d %d %d %d %d |",
(PSW >> 7) & 1, (PSW >> 6) & 1, (PSW >> 5) & 1, (PSW >> 4) & 1,
(PSW >> 3) & 1, (PSW >> 2) & 1, (PSW >> 1) & 1, PSW & 1);
printf("\n");
- printf("---------------------------------------------------------------"
- "-------\n");
+ printf("----------------------------------------------------------------------\n");
- printf("| TCON | TMOD | IE | IP | R0 | R1 | R2 | R3 | R4 | R5 | R6 | R7"
- " | |\n");
+ printf("| TCON | TMOD | IE | IP | R0 | R1 | R2 | R3 | R4 | R5 | R6 | R7 | |\n");
printf("| %.2X | %.2X | %.2X | %.2X ", cpu8051_ReadD(_TCON_),
cpu8051_ReadD(_TMOD_), cpu8051_ReadD(_IE_), cpu8051_ReadD(_IP_));
printf("| %.2X | %.2X | %.2X | %.2X ",
- cpu8051_ReadD(BankSelect + _R0_),
- cpu8051_ReadD(BankSelect + _R1_),
- cpu8051_ReadD(BankSelect + _R2_),
- cpu8051_ReadD(BankSelect + _R3_));
+ cpu8051_ReadD(bank_sel + _R0_),
+ cpu8051_ReadD(bank_sel + _R1_),
+ cpu8051_ReadD(bank_sel + _R2_),
+ cpu8051_ReadD(bank_sel + _R3_));
printf("| %.2X | %.2X | %.2X | %.2X ",
- cpu8051_ReadD(BankSelect + _R4_),
- cpu8051_ReadD(BankSelect + _R5_),
- cpu8051_ReadD(BankSelect + _R6_),
- cpu8051_ReadD(BankSelect + _R7_));
+ cpu8051_ReadD(bank_sel + _R4_),
+ cpu8051_ReadD(bank_sel + _R5_),
+ cpu8051_ReadD(bank_sel + _R6_),
+ cpu8051_ReadD(bank_sel + _R7_));
printf("| |\n");
- printf("---------------------------------------------------------------"
- "-------\n");
+ printf("----------------------------------------------------------------------\n");
for (id = 0; id < GP_TIMERS_COUNT; id++)
printf("| Emulator timer %c: %08d |\n", 'A' + id, gp_timer_read(id));
printf("------------------------------\n");
-
-
}
/* Show CPU registers */
console_show_registers(void);
void
-SetRegister(char *Register, int NewValue);
+register_set(char *name, int value);
void
console_reset(void);
void
-console_exec(int NbInst);
+console_exec(int num);
void
console_trace(void);
void
-DisasmN(unsigned int Address, int NumberInst);
+disassemble_num(unsigned int address, int num);
#endif /* _MENU_H_ */
TOK_RB NUMBER TOK_ENTER
{
log_debug(" Remove breakpoint at $%04X", $2);
- ClearBreakpoint($2);
+ breakpoint_clr($2);
}
|
TOK_RB TOK_ENTER
{
log_debug(" Remove breakpoint at PC");
- ClearBreakpoint(cpu8051.pc);
+ breakpoint_clr(cpu8051.pc);
}
|
TOK_RB TOK_ALL TOK_ENTER
{
log_debug(" Remove all breakpoints");
- ClearAllBreakpoints();
+ breakpoints_clr_all();
}
;
TOK_SB TOK_ENTER
{
log_debug(" Set breakpoint at PC");
- SetBreakpoint(cpu8051.pc);
+ breakpoint_set(cpu8051.pc);
}
|
TOK_SB NUMBER TOK_ENTER
{
log_debug(" Set breakpoint at $%04X", $2);
- SetBreakpoint($2);
+ breakpoint_set($2);
}
;
TOK_DB TOK_ENTER
{
log_debug(" Display breakpoints");
- ShowBreakpoints();
+ breakpoints_show();
}
;
|
TOK_MOD_REG WORD NUMBER TOK_ENTER
{
- SetRegister($2, $3);
+ register_set($2, $3);
}
;
reset:
TOK_RST TOK_ENTER
{
- cpu8051_Reset();
+ cpu8051_reset();
}
|
TOK_RST_TIMER TOK_A TOK_ENTER
unasm:
TOK_UNASM NUMBER NUMBER TOK_ENTER
{
- DisasmN($2, $3);
+ disassemble_num($2, $3);
}
|
TOK_UNASM NUMBER TOK_ENTER
{
- DisasmN(cpu8051.pc, $2);
+ disassemble_num(cpu8051.pc, $2);
}
;
|
TOK_UNASM TOK_ENTER
{
- DisasmN(cpu8051.pc, 16);
+ disassemble_num(cpu8051.pc, 16);
}
;
/* Returns TRUE if the first 'c' characters of strings 'a' and 'b' are equal. */
#define STREQ_LEN(a, b, c) (strncasecmp((a), (b), (c)) == 0)
-
-inline void
-ErrorLocation(const char *file, int line);
-
void *
xmalloc(size_t size, const char *filename, int line_number);
/* Check if the address is a breakpoint */
int
-IsBreakpoint(unsigned int address)
+breakpoint_is_defined(unsigned int address)
{
int k;
return false;
}
-/* Check if the address is a stop point */
-int
-IsStoppoint(unsigned int address)
-{
- if ((options.stop_address != 0) && (options.stop_address == address))
- return true;
- else
- return false;
-}
-
/* Show Breakpoints list */
void
-ShowBreakpoints(void)
+breakpoints_show(void)
{
int k;
printf("Breakpoints:\n");
for (k = 0; k < cpu8051.bp_count; k++)
printf(" $%.4X\n", cpu8051.bp[k]);
- } else
+ } else {
printf("No breakpoints defined\n");
+ }
}
/* Set Breakpoint at address at the end of the breakpoint list */
void
-SetBreakpoint(unsigned int address)
+breakpoint_set(unsigned int address)
{
int rc;
rc = memory_check_address(PGM_MEM_ID, address, DISPLAY_ERROR_YES);
- if (rc == false)
+ if (!rc)
return; /* Error */
/* Check if breakpoint is already defined. */
- if ((IsBreakpoint(address) == false) &&
+ if ((breakpoint_is_defined(address) == false) &&
(cpu8051.bp_count < MAXBP))
cpu8051.bp[cpu8051.bp_count++] = address;
}
/* Clear Breakpoint at Address from list */
void
-ClearBreakpoint(unsigned int address)
+breakpoint_clr(unsigned int address)
{
int k;
int rc;
rc = memory_check_address(PGM_MEM_ID, address, DISPLAY_ERROR_YES);
- if (rc == false)
+ if (!rc)
return; /* Error */
/* Check if breakpoint is defined. */
- if (IsBreakpoint(address) == false) {
+ if (breakpoint_is_defined(address) == false) {
log_err("No breakpoint defined at address $%X", address);
return;
}
/* Clear all breakpoints */
void
-ClearAllBreakpoints(void)
+breakpoints_clr_all(void)
{
cpu8051.bp_count = 0;
}
/* Toggle the breakpoint at Address. */
void
-ToggleBreakpoint(unsigned int address)
+breakpoint_toggle(unsigned int address)
{
- if (IsBreakpoint(address))
- ClearBreakpoint(address);
+ if (breakpoint_is_defined(address))
+ breakpoint_clr(address);
else
- SetBreakpoint(address);
+ breakpoint_set(address);
+}
+
+/* Check if the address is a stop point */
+static int
+stop_point_is_defined(unsigned int address)
+{
+ if ((options.stop_address != 0) && (options.stop_address == address))
+ return true;
+ else
+ return false;
}
void
/* Reset the registers and CPU state */
void
-cpu8051_Reset(void)
+cpu8051_reset(void)
{
cpu8051.pc = 0;
cpu8051.clock = 0;
/* Write with a direct addressing mode at Address the new Value */
void
-cpu8051_WriteD(unsigned int Address, unsigned char Value)
+cpu8051_WriteD(unsigned int address, unsigned char value)
{
- memory_write8(INT_MEM_ID, Address, Value);
+ memory_write8(INT_MEM_ID, address, value);
}
/* Write with an indirect addressing mode at Address the new Value */
void
-cpu8051_WriteI(unsigned int Address, unsigned char Value)
+cpu8051_WriteI(unsigned int address, unsigned char value)
{
- if (Address > 0x7F) {
- memory_write8(EXT_MEM_ID, Address, Value);
+ if (address > 0x7F) {
+ memory_write8(EXT_MEM_ID, address, value);
return;
}
- memory_write8(INT_MEM_ID, Address, Value);
+ memory_write8(INT_MEM_ID, address, value);
}
/* Write with a bit addressing mode at BitAddress the new Value */
{
uint8_t byte_address;
uint8_t bit_number;
- unsigned char ByteValue, ByteMask;
+ unsigned char byte_val, byte_mask;
cpu8051_convert_bit_address(bit_address, &byte_address, &bit_number);
- ByteMask = ((1 << bit_number) ^ 0xFF);
- ByteValue = cpu8051_ReadD(byte_address) & ByteMask;
- ByteValue += value << bit_number;
- cpu8051_WriteD(byte_address, ByteValue);
+ byte_mask = ((1 << bit_number) ^ 0xFF);
+ byte_val = cpu8051_ReadD(byte_address) & byte_mask;
+ byte_val += value << bit_number;
+ cpu8051_WriteD(byte_address, byte_val);
}
/* Read with a direct addressing mode at Address */
unsigned char
-cpu8051_ReadD(unsigned int Address)
+cpu8051_ReadD(unsigned int address)
{
- if (Address > 0xFF)
- return memory_read8(EXT_MEM_ID, Address);
+ if (address > 0xFF)
+ return memory_read8(EXT_MEM_ID, address);
else
- return memory_read8(INT_MEM_ID, Address);
+ return memory_read8(INT_MEM_ID, address);
}
/* Read with a indirect addressing mode at Address */
unsigned char
-cpu8051_ReadI(unsigned int Address)
+cpu8051_ReadI(unsigned int address)
{
- if (Address > 0x7F)
- return memory_read8(EXT_MEM_ID, Address);
+ if (address > 0x7F)
+ return memory_read8(EXT_MEM_ID, address);
else
- return memory_read8(INT_MEM_ID, Address);
+ return memory_read8(INT_MEM_ID, address);
}
/* Read with a bit addressing mode at BitAddress */
{
uint8_t byte_address;
uint8_t bit_number;
- unsigned char BitValue;
+ unsigned char bit_value;
cpu8051_convert_bit_address(bit_address, &byte_address, &bit_number);
- BitValue = (cpu8051_ReadD(byte_address) >> bit_number);
- BitValue &= 1;
- return BitValue;
+ bit_value = (cpu8051_ReadD(byte_address) >> bit_number);
+ bit_value &= 1;
+ return bit_value;
}
static int
/* Check interrupts state and process them as needed */
static void
-cpu8051_CheckInterrupts(void)
+cpu8051_check_interrupts(void)
{
int i;
/* Interrupt timer 0 */
if (cpu8051_interrupt_enabled(INTERRUPT_1) &&
cpu8051_interrupt_fire(INTERRUPT_1, i) &&
- (cpu8051_ReadD(_TCON_) & 0x20)) {
+ (cpu8051_ReadD(_TCON_) & 0x20)) {
cpu8051_WriteD(_TCON_,
cpu8051_ReadD(_TCON_) & 0xDF);
cpu8051_process_interrupt(0x0B, i);
/* Execute at address cpu8051.pc from PGMMem */
int
-cpu8051_Exec(void)
+cpu8051_exec(void)
{
int i;
int rc;
/* Basic address check (may fail later if opcode has operands). */
rc = memory_check_address(PGM_MEM_ID, cpu8051.pc, DISPLAY_ERROR_NO);
- if (rc == false) {
+ if (!rc) {
log_err("Trying to run past program memory limit");
return false; /* Error */
}
gp_timers_increment(insttiming);
for (i = 0; i < insttiming; i++) {
- cpu8051_CheckInterrupts();
+ cpu8051_check_interrupts();
timers_check();
cpu8051.clock++;
}
cpu8051_run(int instr_count, int (*interface_stop)(void))
{
int rc;
- int stop = false;
+ int run = true;
int breakpoint_hit = false;
- while (stop == false) {
- rc = cpu8051_Exec();
- if (rc == false)
- stop = true;
- else {
+ while (run) {
+ rc = cpu8051_exec();
+ if (!rc) {
+ run = false;
+ } else {
if (instr_count > 0)
instr_count--;
if (instr_count == 0) {
- stop = true;
+ run = false;
log_info("Number of instructions reached");
}
- if (IsBreakpoint(cpu8051.pc)) {
- stop = true;
+ if (breakpoint_is_defined(cpu8051.pc)) {
+ run = false;
breakpoint_hit = true;
log_info("Breakpoint hit at %.4X", cpu8051.pc);
}
- if (IsStoppoint(cpu8051.pc)) {
- stop = true;
+ if (stop_point_is_defined(cpu8051.pc)) {
+ run = false;
log_info("Stoppoint hit at %.4X", cpu8051.pc);
}
if (interface_stop != NULL) {
if (interface_stop()) {
- stop = true;
+ run = false;
log_info("Caught break signal");
}
}
/* Return as Text the name of the SFR register at Address if any */
static int
-cpu8051_SFRMemInfo(unsigned int Address, char *Text)
+cpu8051_sfr_mem_info(unsigned int address, char *text)
{
- switch (Address) {
- case 0x80: return sprintf(Text, "P0");
- case 0x81: return sprintf(Text, "SP");
- case 0x82: return sprintf(Text, "DPL");
- case 0x83: return sprintf(Text, "DPH");
- case 0x87: return sprintf(Text, "PCON");
- case 0x88: return sprintf(Text, "TCON");
- case 0x89: return sprintf(Text, "TMOD");
- case 0x8A: return sprintf(Text, "TL0");
- case 0x8B: return sprintf(Text, "TL1");
- case 0x8C: return sprintf(Text, "TH0");
- case 0x8D: return sprintf(Text, "TH1");
- case 0x90: return sprintf(Text, "P1");
- case 0x98: return sprintf(Text, "SCON");
- case 0x99: return sprintf(Text, "SBUF");
- case 0xA0: return sprintf(Text, "P2");
- case 0xA8: return sprintf(Text, "IE");
- case 0xB0: return sprintf(Text, "P3");
- case 0xB8: return sprintf(Text, "IP");
- case 0xC8: return sprintf(Text, "T2CON");
- case 0xCA: return sprintf(Text, "RCAP2L");
- case 0xCB: return sprintf(Text, "RCAP2H");
- case 0xCC: return sprintf(Text, "TL2");
- case 0xCD: return sprintf(Text, "TH2");
- case 0xD0: return sprintf(Text, "PSW");
- case 0xE0: return sprintf(Text, "ACC");
- case 0xF0: return sprintf(Text, "B");
- default: return sprintf(Text, "%.2XH", Address);
+ switch (address) {
+ case 0x80: return sprintf(text, "P0");
+ case 0x81: return sprintf(text, "SP");
+ case 0x82: return sprintf(text, "DPL");
+ case 0x83: return sprintf(text, "DPH");
+ case 0x87: return sprintf(text, "PCON");
+ case 0x88: return sprintf(text, "TCON");
+ case 0x89: return sprintf(text, "TMOD");
+ case 0x8A: return sprintf(text, "TL0");
+ case 0x8B: return sprintf(text, "TL1");
+ case 0x8C: return sprintf(text, "TH0");
+ case 0x8D: return sprintf(text, "TH1");
+ case 0x90: return sprintf(text, "P1");
+ case 0x98: return sprintf(text, "SCON");
+ case 0x99: return sprintf(text, "SBUF");
+ case 0xA0: return sprintf(text, "P2");
+ case 0xA8: return sprintf(text, "IE");
+ case 0xB0: return sprintf(text, "P3");
+ case 0xB8: return sprintf(text, "IP");
+ case 0xC8: return sprintf(text, "T2CON");
+ case 0xCA: return sprintf(text, "RCAP2L");
+ case 0xCB: return sprintf(text, "RCAP2H");
+ case 0xCC: return sprintf(text, "TL2");
+ case 0xCD: return sprintf(text, "TH2");
+ case 0xD0: return sprintf(text, "PSW");
+ case 0xE0: return sprintf(text, "ACC");
+ case 0xF0: return sprintf(text, "B");
+ default: return sprintf(text, "%.2XH", address);
}
}
-/* Return as Text the decoded BitAddress */
+/* Return as text the decoded bit address */
static void
-cpu8051_IntMemBitInfo(uint8_t bit_address, char *text)
+cpu8051_int_mem_bit_info(uint8_t bit_address, char *text)
{
uint8_t byte_address;
uint8_t bit_number;
cpu8051_convert_bit_address(bit_address, &byte_address, &bit_number);
- len = cpu8051_SFRMemInfo(byte_address, text);
+ len = cpu8051_sfr_mem_info(byte_address, text);
sprintf(&text[len], ".%X", bit_address);
}
/* Display instruction mnemonic. */
void
-cpu8051_disasm_mnemonic(unsigned char OpCode, char *buf)
+cpu8051_disasm_mnemonic(unsigned char opcode, char *buf)
{
- sprintf(buf, "%s", InstTextTbl[InstTypesTbl[OpCode]]);
+ sprintf(buf, "%s", InstTextTbl[InstTypesTbl[opcode]]);
}
/* Disasm instruction arguments starting at address into a text string */
cpu8051_disasm_args(unsigned int address, char *buf)
{
int len = 0;
- char TextTmp[20];
- unsigned char OpCode;
+ char str[20];
+ unsigned char opcode;
int ArgTblOfs;
int i;
- OpCode = memory_read8(PGM_MEM_ID, address);
- ArgTblOfs = OpCode << 2;
+ opcode = memory_read8(PGM_MEM_ID, address);
+ ArgTblOfs = opcode << 2;
address++;
/*
- * MOV direct, direct (OpCode 85h) is peculiar, the operands
+ * MOV direct, direct (opcode 85h) is peculiar, the operands
* are inverted
*/
- if (OpCode == 0x85) {
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, address + 1),
- TextTmp);
- len += sprintf(&buf[len], "%s,", TextTmp);
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, address),
- TextTmp);
- len += sprintf(&buf[len], "%s", TextTmp);
+ if (opcode == 0x85) {
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address + 1),
+ str);
+ len += sprintf(&buf[len], "%s,", str);
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address),
+ str);
+ len += sprintf(&buf[len], "%s", str);
address += 2;
return;
}
switch (InstArgTbl[ArgTblOfs + i]) {
case ADDR11: {
len += sprintf(&buf[len],
- "%.4XH", ((OpCode << 3) & 0xF00) +
+ "%.4XH", ((opcode << 3) & 0xF00) +
(memory_read8(PGM_MEM_ID, address)));
address++;
break;
break;
}
case DIRECT: {
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, address),
- TextTmp);
- len += sprintf(&buf[len], "%s", TextTmp);
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address),
+ str);
+ len += sprintf(&buf[len], "%s", str);
address++;
break;
}
case BITADDR: {
- cpu8051_IntMemBitInfo(
+ cpu8051_int_mem_bit_info(
(memory_read8(PGM_MEM_ID, address) & 0xF8),
- TextTmp);
- len += sprintf(&buf[len], "%s.%X" , TextTmp,
+ str);
+ len += sprintf(&buf[len], "%s.%X" , str,
(memory_read8(PGM_MEM_ID, address) & 7));
address++;
break;
break;
}
case CBITADDR: {
- cpu8051_IntMemBitInfo((memory_read8(PGM_MEM_ID,
- address) & 0xF8),
- TextTmp);
- len += sprintf(&buf[len], "/%s.%X", TextTmp,
+ cpu8051_int_mem_bit_info((memory_read8(PGM_MEM_ID,
+ address) & 0xF8),
+ str);
+ len += sprintf(&buf[len], "/%s.%X", str,
(memory_read8(PGM_MEM_ID, address) & 7));
address++;
break;
}
}
-/* Disasm one instruction at Address into a Text string */
+/* Disasm one instruction at address into a Text string */
int
-cpu8051_Disasm(unsigned int Address, char *Text)
+cpu8051_disasm(unsigned int address, char *text)
{
int len = 0;
- char TextTmp[20];
- unsigned char OpCode;
+ char str[20];
+ unsigned char opcode;
int ArgTblOfs;
- int InstSize;
+ int inst_size;
int i;
/* Display address. */
- len += sprintf(Text, " %.4X ", Address);
+ len += sprintf(text, " %.4X ", address);
- OpCode = memory_read8(PGM_MEM_ID, Address);
- InstSize = InstSizesTbl[OpCode];
+ opcode = memory_read8(PGM_MEM_ID, address);
+ inst_size = InstSizesTbl[opcode];
/* Display hex bytes. */
- for (i = 0; i < InstSize; i++)
- len += sprintf(&Text[len], " %.2X",
- memory_read8(PGM_MEM_ID, Address + i));
+ for (i = 0; i < inst_size; i++)
+ len += sprintf(&text[len], " %.2X",
+ memory_read8(PGM_MEM_ID, address + i));
- Address++;
+ address++;
/* Padd remaining area with spaces. */
for (; len < 17;)
- len += sprintf(&Text[len], " ");
+ len += sprintf(&text[len], " ");
/* Display instruction mnemonic. */
- len += sprintf(&Text[len], "%s ",
- InstTextTbl[InstTypesTbl[OpCode]]);
- ArgTblOfs = OpCode << 2;
+ len += sprintf(&text[len], "%s ",
+ InstTextTbl[InstTypesTbl[opcode]]);
+ ArgTblOfs = opcode << 2;
/* Padd remaining area with spaces. */
for (; len < 25;)
- len += sprintf(&Text[len], " ");
+ len += sprintf(&text[len], " ");
/* Display instruction arguments. */
/*
- * MOV direct, direct (OpCode 85h) is peculiar, the operands
+ * MOV direct, direct (opcode 85h) is peculiar, the operands
* are inverted
*/
- if (OpCode == 0x85) {
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, Address + 1),
- TextTmp);
- len += sprintf(&Text[len], "%s,", TextTmp);
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, Address),
- TextTmp);
- len += sprintf(&Text[len], "%s", TextTmp);
- Address += 2;
- return InstSize;
+ if (opcode == 0x85) {
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address + 1),
+ str);
+ len += sprintf(&text[len], "%s,", str);
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address),
+ str);
+ len += sprintf(&text[len], "%s", str);
+ address += 2;
+ return inst_size;
}
for (i = 1; i <= InstArgTbl[ArgTblOfs]; i++) {
switch (InstArgTbl[ArgTblOfs + i]) {
case ADDR11: {
- len += sprintf(&Text[len],
- "%.4XH", ((OpCode << 3) & 0xF00) +
- (memory_read8(PGM_MEM_ID, Address)));
- Address++;
+ len += sprintf(&text[len],
+ "%.4XH", ((opcode << 3) & 0xF00) +
+ (memory_read8(PGM_MEM_ID, address)));
+ address++;
break;
}
case ADDR16: {
len += sprintf(
- &Text[len], "%.4XH",
- ((memory_read8(PGM_MEM_ID, Address) << 8) +
- memory_read8(PGM_MEM_ID, Address + 1)));
- Address += 2;
+ &text[len], "%.4XH",
+ ((memory_read8(PGM_MEM_ID, address) << 8) +
+ memory_read8(PGM_MEM_ID, address + 1)));
+ address += 2;
break;
}
case DIRECT: {
- cpu8051_SFRMemInfo(memory_read8(PGM_MEM_ID, Address),
- TextTmp);
- len += sprintf(&Text[len], "%s", TextTmp);
- Address++;
+ cpu8051_sfr_mem_info(memory_read8(PGM_MEM_ID, address),
+ str);
+ len += sprintf(&text[len], "%s", str);
+ address++;
break;
}
case BITADDR: {
- cpu8051_IntMemBitInfo(
- (memory_read8(PGM_MEM_ID, Address) & 0xF8),
- TextTmp);
- len += sprintf(&Text[len], "%s.%X" , TextTmp,
- (memory_read8(PGM_MEM_ID, Address) & 7));
- Address++;
+ cpu8051_int_mem_bit_info(
+ (memory_read8(PGM_MEM_ID, address) & 0xF8),
+ str);
+ len += sprintf(&text[len], "%s.%X" , str,
+ (memory_read8(PGM_MEM_ID, address) & 7));
+ address++;
break;
}
case RELADDR: {
- Address++;
- len += sprintf(&Text[len], "%.4XH", (Address & 0xFF00) +
- (((Address & 0xFF) +
+ address++;
+ len += sprintf(&text[len], "%.4XH", (address & 0xFF00) +
+ (((address & 0xFF) +
memory_read8(PGM_MEM_ID,
- Address - 1)) & 0xFF));
+ address - 1)) & 0xFF));
break;
}
case DATAIMM: {
- len += sprintf(&Text[len], "#%.2XH",
- memory_read8(PGM_MEM_ID, Address));
- Address++;
+ len += sprintf(&text[len], "#%.2XH",
+ memory_read8(PGM_MEM_ID, address));
+ address++;
break;
}
case DATA16: {
- len += sprintf(&Text[len], "#%.4XH",
+ len += sprintf(&text[len], "#%.4XH",
((memory_read8(PGM_MEM_ID,
- Address) << 8) +
- memory_read8(PGM_MEM_ID, Address+1)));
- Address += 2;
+ address) << 8) +
+ memory_read8(PGM_MEM_ID, address+1)));
+ address += 2;
break;
}
case CBITADDR: {
- cpu8051_IntMemBitInfo((memory_read8(PGM_MEM_ID,
- Address) & 0xF8),
- TextTmp);
- len += sprintf(&Text[len], "/%s.%X", TextTmp,
- (memory_read8(PGM_MEM_ID, Address) & 7));
- Address++;
+ cpu8051_int_mem_bit_info((memory_read8(PGM_MEM_ID,
+ address) & 0xF8),
+ str);
+ len += sprintf(&text[len], "/%s.%X", str,
+ (memory_read8(PGM_MEM_ID, address) & 7));
+ address++;
break;
}
default: {
- len += sprintf(&Text[len], "%s",
+ len += sprintf(&text[len], "%s",
ArgsTextTbl[InstArgTbl[ArgTblOfs + i]]);
}
}
if (i < InstArgTbl[ArgTblOfs])
- len += sprintf(&Text[len], ",");
+ len += sprintf(&text[len], ",");
}
- return InstSize;
+ return inst_size;
}
_SCOPE_ struct cpu8051_t cpu8051;
int
-IsBreakpoint(unsigned int Address);
-
-int
-IsStoppoint(unsigned int address);
+breakpoint_is_defined(unsigned int address);
void
-ShowBreakpoints(void);
+breakpoints_show(void);
void
-SetBreakpoint(unsigned int Address);
+breakpoint_set(unsigned int address);
void
-ClearBreakpoint(unsigned int Address);
+breakpoint_clr(unsigned int address);
void
-ClearAllBreakpoints(void);
+breakpoints_clr_all(void);
void
-ToggleBreakpoint(unsigned int Address);
+breakpoint_toggle(unsigned int address);
void
cpu8051_init(void);
int
-cpu8051_Exec(void);
+cpu8051_exec(void);
int
cpu8051_run(int instr_count, int (*interface_stop)(void));
void
-cpu8051_Reset(void);
+cpu8051_reset(void);
void
-cpu8051_WriteD(unsigned int Address, unsigned char Value);
+cpu8051_WriteD(unsigned int address, unsigned char value);
void
-cpu8051_WriteI(unsigned int Address, unsigned char Value);
+cpu8051_WriteI(unsigned int address, unsigned char value);
void
cpu8051_WriteB(uint8_t bit_address, uint8_t value);
unsigned char
-cpu8051_ReadD(unsigned int Address);
+cpu8051_ReadD(unsigned int address);
unsigned char
-cpu8051_ReadI(unsigned int Address);
+cpu8051_ReadI(unsigned int address);
unsigned char
cpu8051_ReadB(uint8_t bit_address);
cpu8051_get_instruction_size(unsigned char opcode);
void
-cpu8051_disasm_mnemonic(unsigned char OpCode, char *buf);
+cpu8051_disasm_mnemonic(unsigned char opcode, char *buf);
void
cpu8051_disasm_args(unsigned int address, char *buf);
int
-cpu8051_Disasm(unsigned int Address, char *Text);
+cpu8051_disasm(unsigned int address, char *text);
#endif /* CPU8051_H */
/* Maximum of 75 digits with 32-bytes data records. */
#define HEXFILE_LINE_BUFFER_LEN 128
+static int asciihex2int_error;
+
/* Convert integer to ASCII hex string. */
void
int2asciihex(int val, char *str, int width)
asciihex2int(char *str)
{
int val;
+ int rc;
+
+ rc = sscanf(str, "%X", &val);
- sscanf(str, "%X", &val);
+ if (rc == 0) {
+ log_err("ASCII to hex conversion failure");
+ asciihex2int_error = true;
+ }
return val;
}
/* Convert an ascii string to an hexadecimal number. */
-unsigned int
-Ascii2Hex(char *istring, int length)
+static unsigned int
+asciihex2int_len(char *istring, int length)
{
unsigned int result = 0;
int i, ascii_code;
ascii_code &= 0xDF;
if ((ascii_code >= 0x30 && ascii_code <= 0x39) ||
- (ascii_code >= 0x41 && ascii_code <= 0x46)) {
+ (ascii_code >= 0x41 && ascii_code <= 0x46)) {
ascii_code -= 0x30;
if (ascii_code > 9)
ascii_code -= 7;
result <<= 4;
result += ascii_code;
} else {
- log_fail("Error converting ASCII string <%s> to hex"
- " (len=%d)", istring, length);
+ log_err("ASCII to hex conversion failure");
+ asciihex2int_error = true;
}
}
return result;
* false: failure
*/
int
-LoadHexFile(const char *filename)
+hexfile_load(const char *filename)
{
- int i, j, RecLength, LoadOffset, RecType, Data, Checksum;
+ int i, j, rec_len, load_offset, rec_type, data, checksum;
FILE *fp;
int status;
char line[HEXFILE_LINE_BUFFER_LEN];
int valid = false;
+ int line_num = 1;
log_debug("LoadHexFile");
*/
while (fgets(line, HEXFILE_LINE_BUFFER_LEN, fp) != NULL) {
i = 0;
- Checksum = 0;
+ checksum = 0;
if (line[i++] != ':') {
log_err("hexfile line not beginning with \":\"");
goto close_file;
}
- RecLength = Ascii2Hex(&line[i], 2);
+ rec_len = asciihex2int_len(&line[i], 2);
i += 2;
- Checksum += RecLength;
+ checksum += rec_len;
- LoadOffset = Ascii2Hex(&line[i], 4);
- Checksum += LoadOffset / 256;
- Checksum += LoadOffset % 256;
+ load_offset = asciihex2int_len(&line[i], 4);
+ checksum += load_offset / 256;
+ checksum += load_offset % 256;
i += 4;
- RecType = Ascii2Hex(&line[i], 2);
+ rec_type = asciihex2int_len(&line[i], 2);
i += 2;
- Checksum += RecType;
+ checksum += rec_type;
- if (RecType == 0) {
- for (j = 0; j < RecLength; j++) {
- Data = Ascii2Hex(&line[i], 2);
+ if (rec_type == 0) {
+ for (j = 0; j < rec_len; j++) {
+ data = asciihex2int_len(&line[i], 2);
memory_write8(PGM_MEM_ID,
- (unsigned int)(LoadOffset + j),
- (unsigned char)Data);
+ (unsigned int) (load_offset + j),
+ (unsigned char) data);
i += 2;
- Checksum += Data;
+ checksum += data;
}
}
/* Read and add checksum value */
- Checksum += Ascii2Hex(&line[i], 2);
- Checksum &= 0x000000FF;
+ checksum += asciihex2int_len(&line[i], 2);
+ checksum &= 0x000000FF;
- /* Make sure line checksum is valid */
- if (Checksum) {
+ if (asciihex2int_error) {
+ log_err("hexfile parse error at line %d", line_num);
+ goto close_file;
+ } else if (checksum) {
log_err("hexfile checksum mismatch");
goto close_file;
}
- if (RecType == 0) {
+ if (rec_type == 0) {
log_debug("hex record: data");
- } else if (RecType == 1) {
+ } else if (rec_type == 1) {
log_debug("hex record: End Of File");
valid = true;
goto close_file;
} else {
- log_warn("hex record: Unsupported ($%02X)", RecType);
+ log_warn("hex record: Unsupported ($%02X)", rec_type);
}
+
+ line_num++;
}
close_file:
if (status != EXIT_SUCCESS)
log_fail("Error closing hex file");
- if (valid == false) {
+ if (!valid)
log_err("Error parsing hex file");
- }
return valid;
}
int
asciihex2int(char *str);
-unsigned int
-Ascii2Hex(char *istring, int length);
-
int
-LoadHexFile(const char *filename);
+hexfile_load(const char *filename);
#endif /* HEXFILE_H */
log_err("Address out of range ($%X >= $%X", address,
mem_infos[id].max_size - 1);
return false;
- }
- else
+ } else {
return true;
+ }
}
u_int8_t *
" Address (%lu) greater than maximum memory size",
id, address);
return;
- } else
+ } else {
mem_infos[id].buf[address] = value;
+ }
}
void
" Address (%lu) greater than maximum memory size",
id, address);
return 0;
- } else
+ } else {
return mem_infos[id].buf[address];
+ }
}
u_int8_t
memory_dump(unsigned int address, int size, int memory_id)
{
int rc;
- int Offset, Column;
+ int offset, col;
if (size == 0) {
log_err("invalid size: 0");
/* Validate start address. */
rc = memory_check_address(memory_id, address, DISPLAY_ERROR_YES);
- if (rc != false) {
+ if (!rc) {
/* Validate end address. */
rc = memory_check_address(memory_id, address + (size - 1),
DISPLAY_ERROR_NO);
- if (rc == false)
+ if (!rc)
log_err("Trying to read beyond memory limit");
}
- if (rc == false)
+ if (!rc)
return;
- for (Offset = 0; Offset < size; Offset += 16) {
+ for (offset = 0; offset < size; offset += 16) {
unsigned char data[16];
- printf("%.4X ", address + Offset);
+ printf("%.4X ", address + offset);
- for (Column = 0; Column < 16; Column++) {
- data[Column] = memory_read8(memory_id, address +
- Offset + Column);
- printf(" %.2X", (int) data[Column]);
+ for (col = 0; col < 16; col++) {
+ data[col] = memory_read8(memory_id, address +
+ offset + col);
+ printf(" %.2X", (int) data[col]);
}
printf(" ");
/* Display any ASCII characters */
- for (Column = 0; Column < 16; Column++) {
- if ((int) data[Column] >= 32 &&
- (int) data[Column] <= 126) {
- printf("%c", data[Column]);
- } else
+ for (col = 0; col < 16; col++) {
+ if ((int) data[col] >= 32 &&
+ (int) data[col] <= 126)
+ printf("%c", data[col]);
+ else
printf(".");
}
printf("\n");
memory_init(void);
int
-memory_check_address(enum mem_id_t id, unsigned long address, int display_error);
+memory_check_address(enum mem_id_t id, unsigned long address,
+ int display_error);
u_int8_t *
memory_getbuf(enum mem_id_t id, unsigned long address);
print $fd " * Copyright (C) 1999 Jonathan St-André\n";
print $fd " * Copyright (C) 1999 Hugo Villeneuve <hugo@hugovil.com>\n";
print $fd " *\n";
- print $fd " * This program is free software; you can redistribute it and/or modify\n";
- print $fd " * it under the terms of the GNU General Public License as published by\n";
- print $fd " * the Free Software Foundation; either version 2 of the License, or\n";
- print $fd " * (at your option) any later version.\n";
- print $fd " *\n";
- print $fd " * This program is distributed in the hope that it will be useful,\n";
- print $fd " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
- print $fd " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
- print $fd " * GNU General Public License for more details.\n";
+ print $fd " * This file is released under the GPLv2\n";
print $fd " */\n\n";
}
static void
regwin_write_timer(int timer_low_addr, int val)
{
- memory_sfr_write8(timer_low_addr + 2, (u_int8_t) ((val & 0x0000FFFF) >> 8));
+ memory_sfr_write8(timer_low_addr + 2,
+ (u_int8_t) ((val & 0x0000FFFF) >> 8));
memory_sfr_write8(timer_low_addr, (u_int8_t) val);
}
static void
regwin_write_rx(int offset, int val)
{
- memory_write8(INT_MEM_ID, regwin_read_bank_offset() + offset, (u_int8_t) val);
+ memory_write8(INT_MEM_ID, regwin_read_bank_offset() + offset,
+ (u_int8_t) val);
}
/* This array defines how to read value for each register. */
static unsigned int
regwin_read_generic(int addr, int width)
{
- if (width == 2)
+ if (width == 2) {
return memory_sfr_read8(addr);
- else if (width == 4) {
+ } else if (width == 4) {
/* Address is low address. */
return (memory_sfr_read8(addr + 1) << 8) |
memory_sfr_read8(addr);
- } else
+ } else {
return 0xFFFFFFFF;
+ }
}
static void
regwin_write_generic(int addr, int val, int width)
{
- if (width == 2)
+ if (width == 2) {
memory_sfr_write8(addr, (u_int8_t) val);
- else if (width == 4) {
+ } else if (width == 4) {
/* Address is low address. */
- memory_sfr_write8(addr + 1, (u_int8_t) ((val & 0x0000FFFF) >> 8));
+ memory_sfr_write8(addr + 1,
+ (u_int8_t) ((val & 0x0000FFFF) >> 8));
memory_sfr_write8(addr, (u_int8_t) val);
}
-};
+}
int
regwin_read(int row)
}
static void
-timer_with_prescaler(uint8_t tl, uint8_t th, uint8_t tf_mask, int prescaler_width)
+timer_with_prescaler(uint8_t tl, uint8_t th, uint8_t tf_mask,
+ int prescaler_width)
{
unsigned int prescaler;
static void
process_timer(uint8_t tl, uint8_t th, uint8_t tf_mask, uint8_t TR, uint8_t mode,
- uint8_t GATE, uint32_t TimerCounter)
+ uint8_t gate, uint32_t timer_counter)
{
unsigned int tmp;
/* If overflow -> reload and set TF0 */
cpu8051_WriteD(_TCON_, cpu8051_ReadD(_TCON_) | tf_mask);
cpu8051_WriteD(tl, cpu8051_ReadD(th));
- } else
+ } else {
cpu8051_WriteD(tl, tmp);
+ }
break;
case 3:
/*
if (tl == _TL1_)
break;
- if (TR && !GATE && !TimerCounter)
+ if (TR && !gate && !timer_counter)
timer_increment_check_overflow(tl, tf_mask);
/* TH0 uses TR1 et TF1. */
void
timers_check(void)
{
- unsigned int TR;
- unsigned int MODE;
- unsigned int GATE;
- unsigned int TimerCounter;
+ unsigned int tr;
+ unsigned int mode;
+ unsigned int gate;
+ unsigned int timer_counter;
/* Timer 0 */
- TR = cpu8051_ReadD(_TCON_) & 0x10;
- MODE = cpu8051_ReadD(_TMOD_) & 0x03;
- GATE = cpu8051_ReadD(_TMOD_) & 0x08;
- TimerCounter = cpu8051_ReadD(_TMOD_) & 0x04;
+ tr = cpu8051_ReadD(_TCON_) & 0x10;
+ mode = cpu8051_ReadD(_TMOD_) & 0x03;
+ gate = cpu8051_ReadD(_TMOD_) & 0x08;
+ timer_counter = cpu8051_ReadD(_TMOD_) & 0x04;
- if ((TR && !GATE && !TimerCounter) || (MODE == 3))
- process_timer(_TL0_, _TH0_, 0x20, TR, MODE, GATE, TimerCounter);
+ if ((tr && !gate && !timer_counter) || (mode == 3))
+ process_timer(_TL0_, _TH0_, 0x20, tr, mode, gate,
+ timer_counter);
/* Timer 1 */
- TR = cpu8051_ReadD(_TCON_) & 0x40;
- MODE = (cpu8051_ReadD(_TMOD_) & 0x30) >> 4 ;
- GATE = cpu8051_ReadD(_TMOD_) & 0x80;
- TimerCounter = cpu8051_ReadD(_TMOD_) & 0x40;
-
- if (TR && !GATE && !TimerCounter)
- process_timer(_TL1_, _TH1_, 0x80, TR, MODE, GATE, TimerCounter);
+ tr = cpu8051_ReadD(_TCON_) & 0x40;
+ mode = (cpu8051_ReadD(_TMOD_) & 0x30) >> 4 ;
+ gate = cpu8051_ReadD(_TMOD_) & 0x80;
+ timer_counter = cpu8051_ReadD(_TMOD_) & 0x40;
+
+ if (tr && !gate && !timer_counter)
+ process_timer(_TL1_, _TH1_, 0x80, tr, mode, gate,
+ timer_counter);
}
}
static int
-app_config_key_file_get_int(GKeyFile *kf, const char *grp, const char *key, int *value)
+app_config_key_file_get_int(GKeyFile *kf, const char *grp, const char *key,
+ int *value)
{
- char *str = g_key_file_get_value(kf, grp, key, NULL);
+ char *str = g_key_file_get_value(kf, grp, key, NULL);
- log_debug("key: %s", key);
+ log_debug("key: %s", key);
- if (G_LIKELY(str)) {
- *value = atoi(str);
- log_debug(" value = %d", *value);
- g_free(str);
- }
+ if (G_LIKELY(str)) {
+ *value = atoi(str);
+ log_debug(" value = %d", *value);
+ g_free(str);
+ }
- return str != NULL;
+ return str != NULL;
}
static void
dir_path = app_config_get_dir_path();
- if (g_mkdir_with_parents(dir_path, 0700) != -1)
- {
+ if (g_mkdir_with_parents(dir_path, 0700) != -1) {
char *file_path;
- GString* buf = g_string_sized_new(1024);
+ GString *buf = g_string_sized_new(1024);
g_string_append(buf, "\n[emulation]\n");
UI_LAYOUT2,
};
-struct app_config_t
-{
+struct app_config_t {
/* Emulation options */
int clear_ram_on_file_load;
}
}
-void
-FileOpenEvent(GtkObject *object, gpointer data)
+static void
+file_open_event(GtkObject *object, gpointer data)
{
GtkWidget *file_dialog;
char *dir;
(void) object;
(void) data;
- log_info("FileOpenEvent()");
+ log_info("file_open_event()");
/* Create a new file selection widget. */
file_dialog = gtk_file_chooser_dialog_new(
}
static void
-FileQuitEvent(gchar *string)
+file_quit_event(gchar *string)
{
/* Remove compiler warning about unused variables. */
(void) string;
}
void
-FileAddMenu(GtkWidget *menu_bar)
+file_add_menu(GtkWidget *menu_bar)
{
GtkWidget *item;
GtkWidget *menu;
item = gtk_menu_item_new_with_label(FILENAME_DESCRIPTION);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
/* Attach the callback functions to the activate signal. */
- g_signal_connect(item, "activate", G_CALLBACK(FileOpenEvent), NULL);
+ g_signal_connect(item, "activate", G_CALLBACK(file_open_event), NULL);
- AddMenuSeparator(menu);
+ add_menu_separator(menu);
item = gtk_menu_item_new_with_label("Exit");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
/* We can attach the Quit menu item to our exit function */
- g_signal_connect(item, "activate", G_CALLBACK(FileQuitEvent),
+ g_signal_connect(item, "activate", G_CALLBACK(file_quit_event),
(gpointer) "file.quit");
/* Adding submenu title. */
#include <gtk/gtk.h>
void
-FileOpenEvent(GtkObject *object, gpointer data);
-
-void
-FileResetEvent(GtkObject *object, gpointer data);
-
-void
-FileAddMenu(GtkWidget *menu_bar);
+file_add_menu(GtkWidget *menu_bar);
#endif /* FILEMENU_H */
#include "helpmenu.h"
static void
-HelpAboutEvent(GtkWidget *widget, gpointer data)
+help_about_event(GtkWidget *widget, gpointer data)
{
/* Remove compiler warning about unused variables. */
(void) widget;
}
void
-HelpAddMenu(GtkWidget *menu_bar)
+help_add_menu(GtkWidget *menu_bar)
{
GtkWidget *item;
GtkWidget *menu;
item = gtk_menu_item_new_with_label("About " PACKAGE);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
/* Attach the callback functions to the activate signal. */
- g_signal_connect(item, "activate", G_CALLBACK(HelpAboutEvent), NULL);
+ g_signal_connect(item, "activate", G_CALLBACK(help_about_event), NULL);
/* Adding submenu title. */
item = gtk_menu_item_new_with_label("Help");
#include <gtk/gtk.h>
void
-HelpAddMenu(GtkWidget *menu_bar);
+help_add_menu(GtkWidget *menu_bar);
#endif /* HELPMENU_H */
extern struct options_t options;
void
-emugtk_UpdateDisplay(void)
+emugtk_update_display(void)
{
- log_debug("UpdateDisplay()");
+ log_debug("update display");
regwin_refresh();
pgmwin_refresh();
pswwin_refresh();
emugtk_stop_running()
{
if (running) {
- log_info("StopRunning()");
+ log_info("stop running");
g_source_remove(running_function_tag);
running = 0;
- emugtk_UpdateDisplay();
+ emugtk_update_display();
}
}
emugtk_start_running(void)
{
if (!running) {
- log_info("StartRunning()");
+ log_info("start running");
running_function_tag = g_idle_add(emugtk_running, 0);
running = 1;
}
/* CPU reset and Gtk UI update */
static void
-emugtk_Reset(void)
+emugtk_reset(void)
{
- cpu8051_Reset();
- emugtk_UpdateDisplay();
+ cpu8051_reset();
+ emugtk_update_display();
}
/* Signal ResetEvent (ResetButton) */
static void
-emugtk_ResetEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
+emugtk_reset_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* Remove compiler warning about unused variables. */
(void) widget;
log_info("ResetEvent()");
emugtk_stop_running();
- emugtk_Reset();
+ emugtk_reset();
}
/* CPU Step and Gtk UI update */
static void
-emugtk_Step(void)
+emugtk_step(void)
{
- cpu8051_Exec();
- emugtk_UpdateDisplay();
+ cpu8051_exec();
+ emugtk_update_display();
}
/* Signal RunEvent (RunButton) */
static void
-emugtk_RunEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
+emugtk_run_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* Remove compiler warning about unused variables. */
(void) widget;
/* Signal StopEvent (StopButton) */
static void
-emugtk_StopEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
+emugtk_stop_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* Remove compiler warning about unused variables. */
(void) widget;
/* Signal StepEvent (StepButton) */
static void
-emugtk_StepEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
+emugtk_step_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* Remove compiler warning about unused variables. */
(void) widget;
log_info("StepEvent()");
emugtk_stop_running();
- emugtk_Step();
+ emugtk_step();
}
/* Creates the Reset, Run, Stop and Step buttons. */
static GtkWidget *
-AddButtons(void)
+add_buttons(void)
{
GtkWidget *button_hbox;
GtkWidget *button;
/* Creating the RESET button. */
button = button_add_pix(button_hbox, reset_xpm);
g_signal_connect(button, "clicked",
- G_CALLBACK(emugtk_ResetEvent),
+ G_CALLBACK(emugtk_reset_event),
NULL);
/* Creating the RUN button. */
button = button_add_pix(button_hbox, run_xpm);
g_signal_connect(button, "clicked",
- G_CALLBACK(emugtk_RunEvent),
+ G_CALLBACK(emugtk_run_event),
NULL);
/* Creating STOP button. */
button = button_add_pix(button_hbox, stop_xpm);
g_signal_connect(GTK_OBJECT(button), "clicked",
- G_CALLBACK(emugtk_StopEvent),
+ G_CALLBACK(emugtk_stop_event),
NULL);
/* Creating STEP button. */
button = button_add_pix(button_hbox, step_xpm);
g_signal_connect(GTK_OBJECT(button), "clicked",
- G_CALLBACK(emugtk_StepEvent),
+ G_CALLBACK(emugtk_step_event),
NULL);
return button_hbox;
}
static GtkWidget *
-AddMenu(void)
+add_menu(void)
{
GtkWidget *menu_bar;
menu_bar = gtk_menu_bar_new();
/* Adding the 'File' submenu */
- FileAddMenu(menu_bar);
+ file_add_menu(menu_bar);
/* Adding the 'View' submenu */
- ViewAddMenu(menu_bar);
+ view_add_menu(menu_bar);
/* Adding the 'Help' submenu */
- HelpAddMenu(menu_bar);
+ help_add_menu(menu_bar);
return menu_bar;
}
emugtk_show_memory_paned(void)
{
gtk_widget_show_all(mainwin);
- emugtk_UpdateDisplay();
+ emugtk_update_display();
}
void
INT_MEM_ID);
gtk_paned_pack1(GTK_PANED(vpaned1), scrollwin_int,
FALSE, FALSE);
- if (emugtk_window_init_complete == true)
+ if (emugtk_window_init_complete)
emugtk_show_memory_paned();
}
gtk_paned_pack2(GTK_PANED(vpaned1), scrollwin_ext,
TRUE, FALSE);
- if (emugtk_window_init_complete == true)
+ if (emugtk_window_init_complete)
emugtk_show_memory_paned();
}
emugtk_create_ext_memory_paned();
}
- if (emugtk_window_init_complete == true)
+ if (emugtk_window_init_complete)
emugtk_show_memory_paned();
}
emugtk_recreate_memory_paned();
return vpaned1;
- } else
+ } else {
return NULL;
+ }
}
/*
G_CALLBACK(mainwin_configure_event), NULL);
/* Creating the menu bar. */
- menu_bar = AddMenu();
+ menu_bar = add_menu();
/* Creating the buttons bar. */
- buttons_bar = AddButtons();
+ buttons_bar = add_buttons();
scrollwin = pswwin_init();
gtk_box_pack_start(GTK_BOX(buttons_bar), scrollwin, FALSE, FALSE, 50);
for (id = 0; id < GP_TIMERS_COUNT; id++) {
scrollwin = timerwin_init(id);
- gtk_box_pack_start(GTK_BOX(buttons_bar), scrollwin, FALSE, FALSE, 15);
+ gtk_box_pack_start(GTK_BOX(buttons_bar), scrollwin,
+ FALSE, FALSE, 15);
}
/* hpaned will contain registers and disassembly windows. */
}
void
-AddMenuSeparator(GtkWidget *menu)
+add_menu_separator(GtkWidget *menu)
{
GtkWidget *item;
emugtk_stop_running();
- rc = LoadHexFile(file);
- if (rc == false) {
+ rc = hexfile_load(file);
+ if (!rc) {
message_show_error("Error parsing hex file");
} else {
if (cfg->clear_ram_on_file_load)
- emugtk_Reset();
+ emugtk_reset();
- emugtk_UpdateDisplay();
+ emugtk_update_display();
}
}
gtk_init(&argc, &argv);
if (options.filename != NULL)
- rc_load_hexfile = LoadHexFile(options.filename);
+ rc_load_hexfile = hexfile_load(options.filename);
- cpu8051_Reset();
+ cpu8051_reset();
log_info("Init GUI");
emugtk_window_init();
- emugtk_UpdateDisplay();
+ emugtk_update_display();
- if (rc_load_hexfile == false)
+ if (!rc_load_hexfile)
message_show_error("Error parsing hex file");
gtk_main();
#include <gtk/gtk.h>
void
-AddMenuSeparator(GtkWidget *menu);
+add_menu_separator(GtkWidget *menu);
void
emugtk_new_file(char *file);
void
-emugtk_UpdateDisplay(void);
+emugtk_update_display(void);
void
emugtk_quit_gui(void);
#include "memwin.h"
#include "main.h"
#include "options.h"
+#include "log.h"
#include "app-config.h"
extern struct app_config_t *cfg;
static int COL_ASCII;
static int N_COLUMNS;
-enum
-{
+enum {
COL_ADDRESS = 0,
COL_DATA0,
};
int new;
char *str;
- if (!model) {
- g_error("Unable to get model from cell renderer");
- }
+ if (!model)
+ log_err("Unable to get model from cell renderer");
/* Column number is passed as renderer object data */
- columnptr = g_object_get_data(G_OBJECT(cell), "column");
- column = GPOINTER_TO_UINT(columnptr);
+ columnptr = g_object_get_data(G_OBJECT(cell), "column");
+ column = GPOINTER_TO_UINT(columnptr);
/* Memory ID is passed as renderer object data */
memory_id_ptr = g_object_get_data(G_OBJECT(cell), "memory_id");
memory_id = GPOINTER_TO_UINT(memory_id_ptr);
/* Get the iterator */
- gtk_tree_model_get_iter_from_string(model, &iter, path_string);
+ gtk_tree_model_get_iter_from_string(model, &iter, path_string);
/* Get base address. */
gtk_tree_model_get(model, &iter, COL_ADDRESS, &str, -1);
int2asciihex(new, str, 2);
/* Store new value in gtk model. */
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, str, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, str, -1);
/*
* Make sure to update all registers and memory.
* For example, BANKed registers depends on internal memory.
*/
- emugtk_UpdateDisplay();
+ emugtk_update_display();
};
static void
gtk_tree_view_get_model(
GTK_TREE_VIEW(listview)));
- /* Add column index and memory_id, used when editing the cell. */
+ /* Add column index and memory_id, used when editing the cell */
g_object_set_data(G_OBJECT(renderer), "column",
GUINT_TO_POINTER(i));
g_object_set_data(G_OBJECT(renderer), "memory_id",
static void
compute_data_rows(int memory_id)
{
- if (memory_id == INT_MEM_ID) {
- memwin_infos->data_rows = options.iram_size / cfg->bytes_per_row;
- } else if (memory_id == EXT_MEM_ID) {
- memwin_infos->data_rows = options.xram_size / cfg->bytes_per_row;
- }
+ if (memory_id == INT_MEM_ID)
+ memwin_infos->data_rows = options.iram_size /
+ cfg->bytes_per_row;
+ else if (memory_id == EXT_MEM_ID)
+ memwin_infos->data_rows = options.xram_size /
+ cfg->bytes_per_row;
if (memwin_infos->crc)
free(memwin_infos->crc);
store = memwin_init_store(memwin_infos->data_rows);
/* Creating the view component */
- memwin_infos->memlist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(memwin_infos->memlist), TRUE);
+ memwin_infos->memlist = gtk_tree_view_new_with_model(
+ GTK_TREE_MODEL(store));
+ gtk_tree_view_set_headers_visible(
+ GTK_TREE_VIEW(memwin_infos->memlist), TRUE);
gtk_container_add(GTK_CONTAINER(scrollwin), memwin_infos->memlist);
memwin_init_columns(memwin_infos->memlist, memory_id);
crc_new = crc32(0L, Z_NULL, 0);
crc_new = crc32(crc_new, buf8, cfg->bytes_per_row);
- if ((memwin_infos->crc_init != false) &&
+ if ((memwin_infos->crc_init) &&
(crc_new == memwin_infos->crc[row])) {
row_changed = false;
} else {
memwin_refresh(int memory_id)
{
int row;
- unsigned int Address = 0;
+ unsigned int address = 0;
GtkListStore *store;
log_debug("memwin_refresh");
GTK_TREE_VIEW(memwin_infos->memlist)));
for (row = 0; row < memwin_infos->data_rows;
- row++, Address += cfg->bytes_per_row) {
+ row++, address += cfg->bytes_per_row) {
int valid;
GtkTreeIter iter;
- char str[4+1]; /* Maximum str len is for address column (4 digits) */
+ char str[4+1]; /* Max. str len for address column (4 digits) */
char ascii_str[16+1]; /* Maximum 16 data columns. */
int col;
}
/* Only update row if it has been modified. */
- if (memwin_row_changed(memory_id, row, Address)) {
+ if (memwin_row_changed(memory_id, row, address)) {
/* Display base address. */
- int2asciihex(Address, str, 4);
+ int2asciihex(address, str, 4);
gtk_list_store_set(store, &iter, COL_ADDRESS, str, -1);
for (col = 0; col < cfg->bytes_per_row; col++) {
u_int8_t data;
- data = memory_read8(memory_id, Address + col);
+ data = memory_read8(memory_id, address + col);
/* Display hex data */
int2asciihex(data, str, 2);
- gtk_list_store_set(store, &iter, col + 1, str, -1);
+ gtk_list_store_set(store, &iter, col + 1, str,
+ -1);
/* Append to ASCII string (if applicable). */
if (!isprint(data))
}
/* Display ASCII characters. */
- gtk_list_store_set(store, &iter, COL_ASCII, ascii_str, -1);
+ gtk_list_store_set(store, &iter, COL_ASCII, ascii_str,
+ -1);
}
}
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
message, NULL);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
void
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
message, NULL);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
}
#define LIST_VIEW_NAME "Program"
#define DATA_ROWS 100
-enum
-{
+enum {
COL_BREAKPT = 0,
COL_ADDR,
COL_B0,
if (row == 0)
gtk_list_store_set(store, &iter, COL_COLOR, "red", -1);
else
- gtk_list_store_set(store, &iter, COL_COLOR, "black", -1);
+ gtk_list_store_set(store, &iter, COL_COLOR, "black",
+ -1);
}
return store;
log_debug(" row address is: $%04X", val);
- ToggleBreakpoint(val);
+ breakpoint_toggle(val);
pgmwin_refresh();
g_free(str_addr);
gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
g_signal_connect(selection, "changed",
- G_CALLBACK(pgmwin_sel_changed_event), NULL);
+ G_CALLBACK(pgmwin_sel_changed_event), NULL);
pgmwin_init_columns();
{
int row;
GtkListStore *store;
- unsigned int Address;
+ unsigned int address;
- Address = cpu8051.pc;
+ address = cpu8051.pc;
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pgmlist)));
char str[128];
int k;
int col_id;
- int InstSize;
- unsigned char OpCode;
+ int inst_size;
+ unsigned char opcode;
if (row == 0) {
/* Get first row in list store */
return;
}
- if (Address > 0xFFFF) {
+ if (address > 0xFFFF) {
/*
* Not the most elegant solution, but it works to not
* display instructions past last address, 0xFFFF.
-1);
} else {
/* Display breakpoints. */
- if (IsBreakpoint(Address))
+ if (breakpoint_is_defined(address))
sprintf(str, "*");
else
str[0] = '\0';
gtk_list_store_set(store, &iter, COL_BREAKPT, str, -1);
/* Display base address. */
- int2asciihex(Address, str, 4);
+ int2asciihex(address, str, 4);
gtk_list_store_set(store, &iter, COL_ADDR, str, -1);
- OpCode = memory_read8(PGM_MEM_ID, Address);
- InstSize = cpu8051_get_instruction_size(OpCode);
+ opcode = memory_read8(PGM_MEM_ID, address);
+ inst_size = cpu8051_get_instruction_size(opcode);
/* Display instruction hex bytes. */
for (k = 0, col_id = COL_B0; k < 3; k++, col_id++) {
- if (k < InstSize)
+ if (k < inst_size)
int2asciihex(memory_read8(PGM_MEM_ID,
- Address + k),
+ address + k),
str, 2);
else
str[0] = '\0';
- gtk_list_store_set(store, &iter, col_id, str, -1);
+ gtk_list_store_set(store, &iter, col_id, str,
+ -1);
}
/* Display instruction menmonic. */
- cpu8051_disasm_mnemonic(OpCode, str);
+ cpu8051_disasm_mnemonic(opcode, str);
gtk_list_store_set(store, &iter, COL_INST, str, -1);
/* Display instruction arguments (if applicable). */
str[0] = '\0';
- cpu8051_disasm_args(Address, str);
+ cpu8051_disasm_args(address, str);
gtk_list_store_set(store, &iter, COL_ARGS, str, -1);
- Address += InstSize;
+ address += inst_size;
}
}
}
void
pgmwin_refresh(void);
-int
-pgmwin_IsBreakpoint(unsigned int address);
-
#endif /* PGMWIN_H */
#define DATA_ROWS 1
#define LIST_VIEW_NAME "PSW"
-enum
-{
+
+enum {
COL_CY = 0,
COL_AC,
COL_F0,
char str[10];
int bit_index;
- if (!model) {
- g_error("Unable to get model from cell renderer");
- }
+ if (!model)
+ log_err("Unable to get model from cell renderer");
/* Column number is passed as renderer object data */
- columnptr = g_object_get_data(G_OBJECT(cell), "column");
- column = GPOINTER_TO_UINT(columnptr);
+ columnptr = g_object_get_data(G_OBJECT(cell), "column");
+ column = GPOINTER_TO_UINT(columnptr);
log_info("column = $%02X", column);
/* Get the iterator */
- gtk_tree_model_get_iter_from_string(model, &iter, path_string);
+ gtk_tree_model_get_iter_from_string(model, &iter, path_string);
bit_index = 7 - column;
int2asciihex(new, str, 1);
/* Store new value in gtk model. */
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, str, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, str, -1);
/*
* Make sure to update all registers and memory.
* For example, BANKed registers depends on internal memory.
*/
- emugtk_UpdateDisplay();
+ emugtk_update_display();
};
static void
g_signal_connect(renderer, "edited",
G_CALLBACK(pswwin_cell_edited),
- gtk_tree_view_get_model(GTK_TREE_VIEW(pswlist)));
+ gtk_tree_view_get_model(
+ GTK_TREE_VIEW(pswlist)));
/* Add column index, used when editing the cell. */
g_object_set_data(G_OBJECT(renderer), "column",
g_object_set(column, "alignment", 0.5, NULL);
/* Hardcoded width... */
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_sizing(column,
+ GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width(column, 35);
gtk_tree_view_append_column(GTK_TREE_VIEW(pswlist), column);
/* Creating the view component */
pswlist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
- gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(pswlist), GTK_TREE_VIEW_GRID_LINES_BOTH);
+ gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(pswlist),
+ GTK_TREE_VIEW_GRID_LINES_BOTH);
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pswlist), TRUE);
gtk_container_add(GTK_CONTAINER(frame), pswlist);
#define LIST_VIEW_NAME "Registers"
#define DATA_ROWS SFR_REGS
-enum
-{
+enum {
COL_NAME = 0,
COL_VAL,
N_COLUMNS,
(void) cell; /* Remove compiler warning about unused variables. */
- if (!model) {
- g_error("Unable to get model from cell renderer");
- }
+ if (!model)
+ log_err("Unable to get model from cell renderer");
/* Get the iterator */
- gtk_tree_model_get_iter_from_string(model, &iter, path_string);
+ gtk_tree_model_get_iter_from_string(model, &iter, path_string);
/* Get register name. */
gtk_tree_model_get(model, &iter, COL_NAME, &str, -1);
if (rc == 0) {
/* Store new value in gtk model. */
int2asciihex(new, str, regwin_infos->w);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_VAL, str, -1);
+ gtk_list_store_set(GTK_LIST_STORE(model), &iter, COL_VAL, str,
+ -1);
/*
* Make sure to update all windows.
* For example, R0-R7 values depends on internal memory values.
*/
- emugtk_UpdateDisplay();
+ emugtk_update_display();
}
};
GtkWidget *button;
/* Create the button. */
- if (display_label != false)
+ if (display_label) {
+ /* By default, a label is appended to stock buttons. */
button = gtk_button_new_from_stock(stock_id);
- else {
+ } else {
GtkWidget *icon;
button = gtk_button_new();
for (id = 0; id < GP_TIMERS_COUNT; id++) {
/* Display textin bold, with big font size. */
- sprintf(buf , "<b><big>%08d</big></b> cycles", gp_timer_read(id));
+ sprintf(buf , "<b><big>%08d</big></b> cycles",
+ gp_timer_read(id));
gtk_label_set_markup(GTK_LABEL(label[id]), buf);
}
{
int id;
- id = GPOINTER_TO_UINT(data);
+ id = GPOINTER_TO_UINT(data);
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
log_info(" Switching to layout %d", id);
{
int bytes_per_row;
- bytes_per_row = GPOINTER_TO_UINT(data);
+ bytes_per_row = GPOINTER_TO_UINT(data);
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
log_info(" Bytes per row = %d", bytes_per_row);
layout2 = gtk_radio_menu_item_new_with_label(group, "Layout2");
if (cfg->layout == UI_LAYOUT1)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout1), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout1),
+ TRUE);
else
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout2), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout2),
+ TRUE);
g_signal_connect(G_OBJECT(layout1), "activate",
G_CALLBACK(toggle_layout), (gpointer) UI_LAYOUT1);
item2 = gtk_radio_menu_item_new_with_label(group, "16");
if (cfg->bytes_per_row == 8)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item1), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item1),
+ TRUE);
else
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item2), TRUE);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item2),
+ TRUE);
g_signal_connect(G_OBJECT(item1), "activate",
G_CALLBACK(toggle_bytes_per_row), (gpointer) 8);
}
void
-ViewAddMenu(GtkWidget *menu_bar)
+view_add_menu(GtkWidget *menu_bar)
{
GtkWidget *item;
GtkWidget *menu;
g_signal_connect(G_OBJECT(item), "activate",
G_CALLBACK(toggle_ext_memory), NULL);
- AddMenuSeparator(menu);
+ add_menu_separator(menu);
/* Add layout submenu */
view_add_layout_submenu(menu);
- AddMenuSeparator(menu);
+ add_menu_separator(menu);
/* Add bytes per row submenu */
view_add_bytes_per_row_submenu(menu);
#include <gtk/gtk.h>
void
-ViewAddMenu(GtkWidget *menu_bar);
+view_add_menu(GtkWidget *menu_bar);
#endif /* VIEWMENU_H */