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.

8080: Clean up the hook functions

Every hook function now has its own opaque pointer.

Hampa Hug 4e168b7e 1fac5f3b

+44 -56
+8 -14
src/arch/cpm80/cmd.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/arch/cpm80/cmd.c * 7 7 * Created: 2012-11-28 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2012-2024 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2012-2025 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 385 385 386 386 387 387 static 388 - int c80_hook_undef (void *ext, unsigned char op) 388 + int c80_hook_undef (void *ext, unsigned op) 389 389 { 390 - cpm80_t *sim; 391 - 392 - sim = ext; 390 + cpm80_t *sim = ext; 393 391 394 392 pce_log (MSG_DEB, 395 393 "%04X: undefined operation [%02X %02X %02X %02X]\n", ··· 406 404 } 407 405 408 406 static 409 - int c80_hook_rst (void *ext, unsigned char op) 407 + int c80_hook_rst (void *ext, unsigned n) 410 408 { 411 - unsigned fct, ex; 412 - cpm80_t *sim; 413 - 414 - sim = ext; 415 - 416 - ex = (op >> 3) & 7; 409 + cpm80_t *sim = ext; 410 + unsigned fct; 417 411 418 - if (ex == 0) { 412 + if (n == 0) { 419 413 fct = e8080_get_pc (sim->cpu); 420 414 421 415 if (fct < sim->addr_bios) { ··· 428 422 429 423 return (1); 430 424 } 431 - else if (ex == 7) { 425 + else if (n == 7) { 432 426 if (mem_get_uint16_le (sim->mem, 56) == 0) { 433 427 c80_stop (sim); 434 428 return (1);
+3 -12
src/arch/spectrum/cmd.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/arch/spectrum/cmd.c * 7 7 * Created: 2022-02-02 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2022-2024 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2022-2025 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 439 439 440 440 441 441 static 442 - int spec_hook_undef (void *ext, unsigned char op) 442 + int spec_hook_undef (void *ext, unsigned op) 443 443 { 444 444 spectrum_t *sim; 445 445 ··· 460 460 } 461 461 462 462 static 463 - int spec_hook_rst (void *ext, unsigned char op) 463 + int spec_hook_rst (void *ext, unsigned n) 464 464 { 465 - #if 0 466 - unsigned fct, ex; 467 - spectrum_t *sim; 468 - 469 - sim = ext; 470 - 471 - ex = (op >> 3) & 7; 472 - #endif 473 - 474 465 return (0); 475 466 } 476 467
+21 -22
src/cpu/e8080/e8080.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e8080/e8080.c * 7 7 * Created: 2012-11-28 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2012-2024 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2012-2025 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 26 26 #include <stdlib.h> 27 27 #include <stdio.h> 28 28 #include <string.h> 29 - 30 - 31 - /* #define E8080_ENABLE_HOOK_ALL 1 */ 32 29 33 30 34 31 void e8080_init (e8080_t *c) ··· 61 58 c->get_port8 = NULL; 62 59 c->set_port8 = NULL; 63 60 64 - c->hook_ext = NULL; 65 - c->hook_all = NULL; 61 + c->hook_exec_ext = NULL; 62 + c->hook_exec = NULL; 63 + 64 + c->hook_undef_ext = NULL; 66 65 c->hook_undef = NULL; 66 + 67 + c->hook_rst_ext = NULL; 67 68 c->hook_rst = NULL; 68 69 69 70 c->delay = 0; ··· 208 209 c->set_port8 = set8; 209 210 } 210 211 211 - void e8080_set_hook_all_fct (e8080_t *c, void *ext, void *fct) 212 + void e8080_set_hook_exec_fct (e8080_t *c, void *ext, void *fct) 212 213 { 213 - c->hook_ext = ext; 214 - c->hook_all = fct; 214 + c->hook_exec_ext = ext; 215 + c->hook_exec = fct; 215 216 } 216 217 217 218 void e8080_set_hook_undef_fct (e8080_t *c, void *ext, void *fct) 218 219 { 219 - c->hook_ext = ext; 220 + c->hook_undef_ext = ext; 220 221 c->hook_undef = fct; 221 222 } 222 223 223 224 void e8080_set_hook_rst_fct (e8080_t *c, void *ext, void *fct) 224 225 { 225 - c->hook_ext = ext; 226 + c->hook_rst_ext = ext; 226 227 c->hook_rst = fct; 227 228 } 228 229 ··· 472 473 return (c->delay); 473 474 } 474 475 475 - int e8080_hook_all (e8080_t *c) 476 + int e8080_hook_exec (e8080_t *c) 476 477 { 477 - if (c->hook_all != NULL) { 478 - return (c->hook_all (c->hook_ext, c->inst[0])); 478 + if (c->hook_exec != NULL) { 479 + return (c->hook_exec (c->hook_exec_ext)); 479 480 } 480 481 481 482 return (0); ··· 484 485 int e8080_hook_undefined (e8080_t *c) 485 486 { 486 487 if (c->hook_undef != NULL) { 487 - return (c->hook_undef (c->hook_ext, c->inst[0])); 488 + return (c->hook_undef (c->hook_undef_ext, c->inst[0])); 488 489 } 489 490 490 491 return (0); ··· 493 494 int e8080_hook_rst (e8080_t *c) 494 495 { 495 496 if (c->hook_rst != NULL) { 496 - return (c->hook_rst (c->hook_ext, c->inst[0])); 497 + return (c->hook_rst (c->hook_rst_ext, (c->inst[0] >> 3) & 7)); 497 498 } 498 499 499 500 return (0); ··· 586 587 587 588 c->inst[0] = e8080_get_mem8 (c, pc); 588 589 589 - e8080_inc_r (c); 590 - 591 - #ifdef E8080_ENABLE_HOOK_ALL 592 - if (c->hook_all != NULL) { 593 - if (e8080_hook_all (c)) { 590 + if (c->hook_exec != NULL) { 591 + if (e8080_hook_exec (c)) { 594 592 return; 595 593 } 596 594 } 597 - #endif 595 + 596 + e8080_inc_r (c); 598 597 599 598 iff = c->iff; 600 599
+10 -6
src/cpu/e8080/e8080.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e8080/e8080.h * 7 7 * Created: 2012-11-28 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2012-2024 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2012-2025 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 90 90 unsigned char (*get_port8) (void *ext, unsigned long addr); 91 91 void (*set_port8) (void *ext, unsigned long addr, unsigned char val); 92 92 93 - void *hook_ext; 94 - int (*hook_all) (void *ext, unsigned char op); 95 - int (*hook_undef) (void *ext, unsigned char op); 96 - int (*hook_rst) (void *ext, unsigned char op); 93 + void *hook_exec_ext; 94 + int (*hook_exec) (void *ext); 95 + 96 + void *hook_undef_ext; 97 + int (*hook_undef) (void *ext, unsigned op); 98 + 99 + void *hook_rst_ext; 100 + int (*hook_rst) (void *ext, unsigned n); 97 101 98 102 unsigned char inst[4]; 99 103 ··· 305 309 void e8080_set_port_write_fct (e8080_t *c, void *ext, void *set8); 306 310 void e8080_set_port_fct (e8080_t *c, void *ext, void *get8, void *set8); 307 311 308 - void e8080_set_hook_all_fct (e8080_t *c, void *ext, void *fct); 312 + void e8080_set_hook_exec_fct (e8080_t *c, void *ext, void *fct); 309 313 void e8080_set_hook_undef_fct (e8080_t *c, void *ext, void *fct); 310 314 void e8080_set_hook_rst_fct (e8080_t *c, void *ext, void *fct); 311 315
+2 -2
src/cpu/e8080/internal.h
··· 5 5 /***************************************************************************** 6 6 * File name: src/cpu/e8080/internal.h * 7 7 * Created: 2012-11-28 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2012-2024 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2012-2025 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 90 90 } e8080_dop_t; 91 91 92 92 93 - int e8080_hook_all (e8080_t *c); 93 + int e8080_hook_exec (e8080_t *c); 94 94 int e8080_hook_undefined (e8080_t *c); 95 95 int e8080_hook_rst (e8080_t *c); 96 96