fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

6502: Rename op_* functions to hook_*

Hampa Hug 0b7ecd1f 4b66aec1

+85 -24
+5 -4
src/arch/sim6502/main.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/arch/sim6502/main.c * 7 7 * Created: 2004-05-25 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2009 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2010 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 338 338 339 339 340 340 static 341 - void s6502_log_undef (void *ext, unsigned char op) 341 + int s6502_hook_undef (void *ext, unsigned char op) 342 342 { 343 343 sim6502_t *sim; 344 344 ··· 350 350 ); 351 351 352 352 s6502_break (sim, PCE_BRK_STOP); 353 + 354 + return (0); 353 355 } 354 356 355 357 ··· 852 854 853 855 par_sim = s6502_new (sct); 854 856 855 - par_sim->cpu->op_ext = par_sim; 856 - par_sim->cpu->op_undef = &s6502_log_undef; 857 + e6502_set_hook_undef_fct (par_sim->cpu, par_sim, s6502_hook_undef); 857 858 858 859 signal (SIGINT, &sig_int); 859 860 signal (SIGSEGV, &sig_segv);
+55 -10
src/cpu/e6502/e6502.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e6502/e6502.c * 7 7 * Created: 2004-05-02 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2010 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2011 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 27 27 #include <stdio.h> 28 28 #include <string.h> 29 29 #include <stdarg.h> 30 + 31 + 32 + /* #define E6502_ENABLE_HOOK_ALL 1 */ 30 33 31 34 32 35 void e6502_init (e6502_t *c) ··· 54 57 c->mem_map_wr[i] = NULL; 55 58 } 56 59 57 - c->op_ext = NULL; 58 - c->op_hook = NULL; 59 - c->op_stat = NULL; 60 - c->op_undef = NULL; 60 + c->hook_ext = NULL; 61 + c->hook_all = NULL; 62 + c->hook_undef = NULL; 63 + c->hook_brk = NULL; 61 64 62 65 for (i = 0; i < 256; i++) { 63 66 c->op[i] = e6502_opcodes[i]; ··· 161 164 c->set_uint8 = set8; 162 165 } 163 166 167 + void e6502_set_hook_all_fct (e6502_t *c, void *ext, void *fct) 168 + { 169 + c->hook_ext = ext; 170 + c->hook_all = fct; 171 + } 172 + 173 + void e6502_set_hook_undef_fct (e6502_t *c, void *ext, void *fct) 174 + { 175 + c->hook_ext = ext; 176 + c->hook_undef = fct; 177 + } 178 + 179 + void e6502_set_hook_brk_fct (e6502_t *c, void *ext, void *fct) 180 + { 181 + c->hook_ext = ext; 182 + c->hook_brk = fct; 183 + } 184 + 164 185 void e6502_set_ioport_fct (e6502_t *c, void *ext, void *fct) 165 186 { 166 187 c->set_ioport_ext = ext; ··· 332 353 } 333 354 334 355 335 - void e6502_undefined (e6502_t *c) 356 + int e6502_hook_all (e6502_t *c) 357 + { 358 + if (c->hook_all != NULL) { 359 + return (c->hook_all (c->hook_ext, c->inst[0])); 360 + } 361 + 362 + return (0); 363 + } 364 + 365 + int e6502_hook_undefined (e6502_t *c) 336 366 { 337 - if (c->op_undef != NULL) { 338 - c->op_undef (c->op_ext, c->inst[0]); 367 + if (c->hook_undef != NULL) { 368 + return (c->hook_undef (c->hook_ext, c->inst[0])); 339 369 } 370 + 371 + return (0); 372 + } 373 + 374 + int e6502_hook_brk (e6502_t *c) 375 + { 376 + if (c->hook_brk != NULL) { 377 + return (c->hook_brk (c->hook_ext, c->inst[0])); 378 + } 379 + 380 + return (0); 340 381 } 341 382 342 383 void e6502_reset (e6502_t *c) ··· 367 408 368 409 c->inst[0] = e6502_get_mem8 (c, pc); 369 410 370 - if (c->op_stat != NULL) { 371 - c->op_stat (c->op_ext, c->inst[0]); 411 + #ifdef E6502_ENABLE_HOOK_ALL 412 + if (c->hook_all != NULL) { 413 + if (e6502_hook_all (c)) { 414 + return; 415 + } 372 416 } 417 + #endif 373 418 374 419 c->op[c->inst[0]] (c); 375 420
+9 -7
src/cpu/e6502/e6502.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e6502/e6502.h * 7 7 * Created: 2004-05-02 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2010 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2011 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 81 81 unsigned char *mem_map_rd[64]; 82 82 unsigned char *mem_map_wr[64]; 83 83 84 - void *op_ext; 85 - void (*op_hook) (void *ext, unsigned char op); 86 - void (*op_stat) (void *ext, unsigned char op); 87 - void (*op_undef) (void *ext, unsigned char op); 84 + void *hook_ext; 85 + int (*hook_all) (void *ext, unsigned char op); 86 + int (*hook_undef) (void *ext, unsigned char op); 87 + int (*hook_brk) (void *ext, unsigned char op); 88 88 89 89 unsigned char ioport[3]; 90 90 ··· 231 231 void e6502_set_mem_write_fct (e6502_t *c, void *ext, void *set8); 232 232 void e6502_set_mem_f (e6502_t *c, void *mem, void *get8, void *set8); 233 233 234 + void e6502_set_hook_all_fct (e6502_t *c, void *ext, void *fct); 235 + void e6502_set_hook_undef_fct (e6502_t *c, void *ext, void *fct); 236 + void e6502_set_hook_brk_fct (e6502_t *c, void *ext, void *fct); 237 + 234 238 /***************************************************************************** 235 239 * @short Set the I/O port function 236 240 *****************************************************************************/ ··· 262 266 *****************************************************************************/ 263 267 unsigned long e6502_get_delay (e6502_t *c); 264 268 265 - 266 - void e6502_undefined (e6502_t *c); 267 269 268 270 /***************************************************************************** 269 271 * @short Set the 6502 RST line
+7 -1
src/cpu/e6502/internal.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e6502/internal.h * 7 7 * Created: 2004-05-23 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2010 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2011 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 57 57 #define e6502_get_abs_y(c) e6502_get_mem8 (c, e6502_get_ea_abs_y (c)) 58 58 #define e6502_get_abs_x(c) e6502_get_mem8 (c, e6502_get_ea_abs_x (c)) 59 59 #define e6502_set_ea(c, v) e6502_set_mem8 ((c), (c)->ea, (v)) 60 + 61 + 62 + int e6502_hook_all (e6502_t *c); 63 + int e6502_hook_undefined (e6502_t *c); 64 + int e6502_hook_brk (e6502_t *c); 65 + 60 66 61 67 unsigned char e6502_get_imm (e6502_t *c); 62 68 unsigned short e6502_get_ea_idx_ind_x (e6502_t *c);
+9 -2
src/cpu/e6502/opcodes.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e6502/opcodes.c * 7 7 * Created: 2004-05-03 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2010 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2011 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 373 373 /* Handle an undefined opcode */ 374 374 static void op_ud (e6502_t *c) 375 375 { 376 - e6502_undefined (c); 376 + if (e6502_hook_undefined (c)) { 377 + return; 378 + } 379 + 377 380 e6502_set_clk (c, 1, 1); 378 381 } 379 382 380 383 /* OP 00: BRK */ 381 384 static void op_00 (e6502_t *c) 382 385 { 386 + if (e6502_hook_brk (c)) { 387 + return; 388 + } 389 + 383 390 e6502_push16 (c, e6502_get_pc (c) + 2); 384 391 e6502_push (c, e6502_get_p (c) | E6502_FLG_B); 385 392