X-Git-Url: http://git.squeep.com/?p=dcpu16;a=blobdiff_plain;f=dcpu16.h;h=b5710789028f6356484382246a27588dbd2a11b3;hp=94e70a3fc02cf901c064ab622ecb2a57a561553e;hb=HEAD;hpb=8ff3b508f7306154413888901dc3af4fe3ef0cbf diff --git a/dcpu16.h b/dcpu16.h index 94e70a3..b571078 100644 --- a/dcpu16.h +++ b/dcpu16.h @@ -27,10 +27,25 @@ enum dcpu16_register_indexes { DCPU16_REG__NUM }; +/* we call this sort of function for emitting a readable message */ +typedef void (dcpu16_msg_cb_t)(unsigned int, char *, ...); + +/* we may emit any of these types of messages */ +enum dcpu16_msg_type { + DCPU16_MSG_ERROR = 0, + DCPU16_MSG_INFO, + DCPU16_MSG_DEBUG +}; + +/* update the default message handler */ +dcpu16_msg_cb_t *dcpu16_msg_set_default(dcpu16_msg_cb_t *); + +/* hardware devices may want to call this directly, without a core context */ +extern dcpu16_msg_cb_t *dcpu16_msg_; + /* a self-contained dcpu16 core */ struct dcpu16 { - void (*warn_cb_)(char *fmt, ...); - void (*trace_cb_)(char *fmt, ...); + dcpu16_msg_cb_t *msg_cb_; /* callback to invoke for messages */ struct dcpu16_acct_cb *cb_table_; /* list of callbacks to invoke for certain events */ size_t cb_table_entries_; /* callback list maintenance */ @@ -109,6 +124,9 @@ struct dcpu16_hw_module { struct dcpu16_hw_ctl_cmd *ctl_cmd; }; +/* update a message handler */ +dcpu16_msg_cb_t *dcpu16_msg_set(struct dcpu16 *, dcpu16_msg_cb_t *); + /* instantiate a new core */ struct dcpu16 *dcpu16_new(void); @@ -146,8 +164,4 @@ int dcpu16_interrupt(struct dcpu16 *, DCPU16_WORD); /* consume a cycle */ void dcpu16_cycle_inc(struct dcpu16 *, unsigned int); -/* register callbacks to handle warning and debug messages, default is writing to stderr, may be set to null */ -void dcpu16_warn_cb_set(void (*)(char *, ...)); -void dcpu16_trace_cb_set(void (*)(char *, ...)); - #endif /* DCPU16_H_3XXIQQG2 */