aboutsummaryrefslogtreecommitdiff
path: root/arm9/source/types/readbuf.c
blob: 750ac4dbf4fcbe37f416fa853916aa05fbc7c1cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "readbuf.h"


// Populate a read buffer with a pointer to a string.
void readbuf_populate(ReadBuf *buf, u8 *string) {
    buf->mem = string;
    buf->p = 0;
}

// Read the next byte of a read buffer, or zero if all bytes have been read.
u8 readbuf_read(ReadBuf *buf) {
    u8 output = buf->mem[buf->p];
    if (output) buf->p++;
    return output;
}

// Move the pointer to the start of the buffer.
void readbuf_set_pointer(ReadBuf *buf) {
    buf->p = 0;
}