~rabbits/uxn-playdate

d130754a7ac2dac954af73fbebafff044e6ab7aa — Devine Lu Linvega 12 days ago e08423f
Moved macros to main.c
2 files changed, 13 insertions(+), 8 deletions(-)

M src/main.c
M src/uxn.h
M src/main.c => src/main.c +11 -6
@@ 3,8 3,13 @@
#include "devices/apu.h"
#include "devices/ppu.h"

/* clang-format off */

#define POKE16(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
#define PEEK16(d) ((d)[0] << 8 | (d)[1])

/* clang-format on */

#define RAM_PAGES 0x10
#define POLYPHONY 4
#define BOOT_ROM_FILENAME "boot.rom"


@@ 78,7 83,7 @@ system_deo(Uint8 *d, Uint8 port)
{
	switch(port) {
	case 0x3:
		system_cmd(u.ram, PEEK16(d+0x2));
		system_cmd(u.ram, PEEK16(d + 0x2));
		break;
	}
}


@@ 110,8 115,8 @@ screen_deo(Uint8 *d, Uint8 port)
		Uint16 x = PEEK16(d + 0x8), y = PEEK16(d + 0xa);
		Uint8 fg = !!(d[0xe] & 0x40);
		ppu_pixel(&ppu, fg, x, y, d[0xe] & 0x3);
		if(d[0x6] & 0x01) POKE16(d+0x8, x + 1); /* auto x+1 */
		if(d[0x6] & 0x02) POKE16(d+0xa, y + 1); /* auto y+1 */
		if(d[0x6] & 0x01) POKE16(d + 0x8, x + 1); /* auto x+1 */
		if(d[0x6] & 0x02) POKE16(d + 0xa, y + 1); /* auto y+1 */
		pd->graphics->markUpdatedRows(y, y);
		break;
	}


@@ 130,9 135,9 @@ screen_deo(Uint8 *d, Uint8 port)
				screen_blit(&ppu, fg, x + dy * i, y + dx * i, &u.ram[addr], d[0xf] & 0xf, d[0xf] & 0x10, d[0xf] & 0x20, twobpp);
			addr += (d[0x6] & 0x04) << (1 + twobpp);
		}
		POKE16(d+0xc, addr);   /* auto addr+length */
		POKE16(d+0x8, x + dx); /* auto x+8 */
		POKE16(d+0xa, y + dy); /* auto y+8 */
		POKE16(d + 0xc, addr);   /* auto addr+length */
		POKE16(d + 0x8, x + dx); /* auto x+8 */
		POKE16(d + 0xa, y + dy); /* auto y+8 */
		pd->graphics->markUpdatedRows(y, y + 7 + n * 8);
		break;
	}

M src/uxn.h => src/uxn.h +2 -2
@@ 9,14 9,14 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/

#define PAGE_PROGRAM 0x0100

typedef unsigned char Uint8;
typedef signed char Sint8;
typedef unsigned short Uint16;
typedef signed short Sint16;
typedef unsigned int Uint32;

#define PAGE_PROGRAM 0x0100

typedef struct {
	Uint8 dat[255], ptr;
} Stack;