1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00
8bitworkshop/presets/nes/vrambuf.h

52 lines
1.2 KiB
C
Raw Normal View History

#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)
// index to end of buffer
extern byte updptr;
2019-03-10 16:17:12 +00:00
// macro to set a single byte in buffer
#define VRAMBUF_SET(b)\
2019-03-06 20:54:37 +00:00
__A__ = (b);\
asm("ldy %v", updptr);\
2019-03-10 16:17:12 +00:00
asm("sta $100,y");
// macro to set a single byte to buffer, then increment
#define VRAMBUF_ADD(b)\
VRAMBUF_SET(b)\
2019-03-06 20:54:37 +00:00
asm("inc %v", updptr);
2019-03-16 00:34:17 +00:00
// C versions of macros
2019-03-15 01:55:16 +00:00
//#define VRAMBUF_SET(b) updbuf[updptr] = (b);
//#define VRAMBUF_ADD(b) VRAMBUF_SET(b); ++updptr
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-03-06 20:54:37 +00:00
// add EOF marker to buffer (but don't increment pointer)
void cendbuf(void);
2019-03-06 20:54:37 +00:00
// clear vram buffer and place EOF marker
void cclearbuf(void);
2019-03-06 20:54:37 +00:00
// wait for next frame, then clear buffer
// this assumes the NMI will call flush_vram_update()
void cflushnow(void);
// add multiple characters to update buffer
// using horizontal increment
2019-02-26 15:56:51 +00:00
void putbytes(word addr, const char* str, byte len);
#endif // vrambuf.h