From bb1aa5958d1b67707dcf0f6b08bfaf0b408bd46e Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Fri, 19 Sep 2025 13:17:14 +1200 Subject: Massive rewrite This commit rewrites the emulator halfway from scratch to make it easier to change and maintain in the future. The emulator core was rewritten to adhere to the released Bedrock specification (earlier versions implemented an older prototype specification, which is no longer relevant). This commit also adds proper support for running multiple concurrent Bedrock instances. This was previously supported in a limited manner for the on-screen keyboard, but now works for any regular program as well, with switching being performed by pressing the L or R bumper buttons. This is disabled by default, as programs will still need to be baked into the emulator and hand-loaded. --- arm9/source/types/circbuf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'arm9/source/types/circbuf.c') diff --git a/arm9/source/types/circbuf.c b/arm9/source/types/circbuf.c index 532a5a0..0398254 100644 --- a/arm9/source/types/circbuf.c +++ b/arm9/source/types/circbuf.c @@ -1,6 +1,8 @@ #include "circbuf.h" -u8 cb_read_byte(CircBuf *buf) { + +// Read a byte from a circular buffer, or zero if the buffer is empty. +u8 circbuf_read(CircBuf *buf) { if (buf->front != buf->back) { return buf->mem[buf->front++]; } else { @@ -8,13 +10,15 @@ u8 cb_read_byte(CircBuf *buf) { } } -void cb_write_byte(CircBuf *buf, u8 byte) { +// Write a byte to a circular buffer if the buffer is not full. +void circbuf_write(CircBuf *buf, u8 byte) { if (((buf->back+1)&0xff) != buf->front) { buf->mem[buf->back++] = byte; } } -void cb_clear(CircBuf *buf) { +// Clear a circular buffer. +void circbuf_clear(CircBuf *buf) { buf->front = 0; buf->back = 0; } -- cgit v1.2.3-70-g09d2