2019-02-24 15:36:38 +00:00
|
|
|
|
|
|
|
#ifndef _VRAMBUF_H
|
|
|
|
#define _VRAMBUF_H
|
|
|
|
|
|
|
|
#include "neslib.h"
|
|
|
|
|
|
|
|
// VBUFSIZE = maximum update buffer bytes
|
|
|
|
#define VBUFSIZE 128
|
|
|
|
|
|
|
|
// update buffer starts at $100 (stack page)
|
2019-03-15 01:55:16 +00:00
|
|
|
#define updbuf ((byte*)0x100)
|
2019-02-24 15:36:38 +00:00
|
|
|
|
|
|
|
// index to end of buffer
|
|
|
|
extern byte updptr;
|
|
|
|
|
2019-03-16 00:34:17 +00:00
|
|
|
// C versions of macros
|
2019-04-05 12:58:26 +00:00
|
|
|
#define VRAMBUF_SET(b) updbuf[updptr] = (b);
|
|
|
|
#define VRAMBUF_ADD(b) VRAMBUF_SET(b); ++updptr
|
2019-03-15 01:55:16 +00:00
|
|
|
|
2019-03-16 00:34:17 +00:00
|
|
|
// macro to add a raw header (useful for single bytes)
|
|
|
|
#define VRAMBUF_PUT(addr,len,flags)\
|
|
|
|
VRAMBUF_ADD(((addr) >> 8) | (flags));\
|
|
|
|
VRAMBUF_ADD(addr);\
|
|
|
|
VRAMBUF_ADD(len);
|
|
|
|
|
2019-07-16 13:55:41 +00:00
|
|
|
// OR with address to put vertical run
|
|
|
|
#define VRAMBUF_VERT 0x8000
|
|
|
|
|
2019-03-06 20:54:37 +00:00
|
|
|
// add EOF marker to buffer (but don't increment pointer)
|
2019-04-07 16:33:01 +00:00
|
|
|
void vrambuf_end(void);
|
2019-02-24 15:36:38 +00:00
|
|
|
|
2019-03-06 20:54:37 +00:00
|
|
|
// clear vram buffer and place EOF marker
|
2019-04-07 16:33:01 +00:00
|
|
|
void vrambuf_clear(void);
|
2019-02-24 15:36:38 +00:00
|
|
|
|
2019-03-06 20:54:37 +00:00
|
|
|
// wait for next frame, then clear buffer
|
|
|
|
// this assumes the NMI will call flush_vram_update()
|
2019-04-07 16:33:01 +00:00
|
|
|
void vrambuf_flush(void);
|
2019-02-24 15:36:38 +00:00
|
|
|
|
|
|
|
// add multiple characters to update buffer
|
|
|
|
// using horizontal increment
|
2019-04-07 16:33:01 +00:00
|
|
|
void vrambuf_put(word addr, const char* str, byte len);
|
2019-02-24 15:36:38 +00:00
|
|
|
|
|
|
|
#endif // vrambuf.h
|