Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
775 changes: 775 additions & 0 deletions presets/pce/chase.c

Large diffs are not rendered by default.

526 changes: 526 additions & 0 deletions presets/pce/chase_gfx.h

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions presets/pce/gfxtest.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* PC Engine graphics smoke test — BG tiles + bouncing sprites.
*
* Proves the pcegfx SDK (not conio). Pad moves the ship; ball/alien bounce.
*/
//#resource "pcegfx.h"
//#resource "gfxtest_gfx.h"
//#link "pcegfx.c"
//#link "pcegfx_tia.s"

#include <joystick.h>
#include "pcegfx.h"
#include "gfxtest_gfx.h"

#define TILE0 PCE_TILE_BASE
#define SPR0 PCE_SPR_BASE

static word ship_x, ship_y;
static word ball_x, ball_y;
static sbyte ball_dx, ball_dy;
static word alien_x, alien_y;
static sbyte alien_dx;

static void draw_playfield(void) {
byte x, y;

/* sky */
pce_fill_bat(0, 0, 32, 28, PCE_BAT(TILE0 + 1, 0));

/* checker floor */
for (y = 24; y < 28; ++y)
for (x = 0; x < 32; ++x)
pce_put_tile(x, y, PCE_BAT(TILE0 + 2, 0));

/* brick border */
pce_fill_bat(0, 0, 32, 1, PCE_BAT(TILE0 + 3, 0));
pce_fill_bat(0, 23, 32, 1, PCE_BAT(TILE0 + 3, 0));
for (y = 1; y < 23; ++y) {
pce_put_tile(0, y, PCE_BAT(TILE0 + 3, 0));
pce_put_tile(31, y, PCE_BAT(TILE0 + 3, 0));
}

/* stars */
pce_put_tile(4, 3, PCE_BAT(TILE0 + 4, 0));
pce_put_tile(12, 5, PCE_BAT(TILE0 + 4, 0));
pce_put_tile(20, 2, PCE_BAT(TILE0 + 4, 0));
pce_put_tile(27, 6, PCE_BAT(TILE0 + 4, 0));
pce_put_tile(8, 10, PCE_BAT(TILE0 + 4, 0));
pce_put_tile(22, 12, PCE_BAT(TILE0 + 4, 0));
}

static void setup_gfx(void) {
pce_gfx_init();
pce_disp_off();

pce_load_palette(0, gfxtest_bg_pal, 16);
pce_load_palette(256, gfxtest_spr_pal, 16);

pce_load_tiles_planar(TILE0, gfxtest_tiles, GFXTEST_NTILE);
pce_load_sprites(SPR0, gfxtest_sprites, GFXTEST_NSPR);

draw_playfield();

ship_x = PCE_SPR_X0 + 120;
ship_y = PCE_SPR_Y0 + 180;
ball_x = PCE_SPR_X0 + 80;
ball_y = PCE_SPR_Y0 + 40;
ball_dx = 2;
ball_dy = 1;
alien_x = PCE_SPR_X0 + 40;
alien_y = PCE_SPR_Y0 + 60;
alien_dx = 1;

pce_satb_clear();
pce_spr_set(0, ship_x, ship_y, PCE_SPR_PATTERN(0), PCE_SPR_PRI | PCE_SPR_PAL(0));
pce_spr_set(1, ball_x, ball_y, PCE_SPR_PATTERN(1), PCE_SPR_PRI | PCE_SPR_PAL(0));
pce_spr_set(2, alien_x, alien_y, PCE_SPR_PATTERN(2), PCE_SPR_PRI | PCE_SPR_PAL(0));
pce_satb_update();
pce_disp_on();
}

static void update_sprites(void) {
unsigned char pad = joy_read(JOY_1);

if (JOY_LEFT(pad) && ship_x > PCE_SPR_X0 + 8)
ship_x -= 2;
if (JOY_RIGHT(pad) && ship_x < PCE_SPR_X0 + 256 - 24)
ship_x += 2;
if (JOY_UP(pad) && ship_y > PCE_SPR_Y0 + 8)
ship_y -= 2;
if (JOY_DOWN(pad) && ship_y < PCE_SPR_Y0 + 224 - 24)
ship_y += 2;

ball_x += ball_dx;
ball_y += ball_dy;
if (ball_x <= PCE_SPR_X0 + 8 || ball_x >= PCE_SPR_X0 + 256 - 24)
ball_dx = -ball_dx;
if (ball_y <= PCE_SPR_Y0 + 8 || ball_y >= PCE_SPR_Y0 + 224 - 40)
ball_dy = -ball_dy;

alien_x += alien_dx;
if (alien_x <= PCE_SPR_X0 + 8 || alien_x >= PCE_SPR_X0 + 256 - 24)
alien_dx = -alien_dx;

{
word attr = PCE_SPR_PRI | PCE_SPR_PAL(0);
PCE_SPR_SET(0, ship_x, ship_y, PCE_SPR_PATTERN(0), attr);
PCE_SPR_SET(1, ball_x, ball_y, PCE_SPR_PATTERN(1), attr);
PCE_SPR_SET(2, alien_x, alien_y, PCE_SPR_PATTERN(2), attr);
}
pce_satb_update_n(3);
}

int main(void) {
joy_install(joy_static_stddrv);
setup_gfx();

for (;;) {
pce_wait_vsync();
update_sprites();
}
return 0;
}
52 changes: 52 additions & 0 deletions presets/pce/gfxtest_gfx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Auto-generated by scripts/gen_pce_gfxtest_gfx.py — do not edit */
#ifndef GFXTEST_GFX_H
#define GFXTEST_GFX_H

#define GFXTEST_NTILE 5
#define GFXTEST_NSPR 3

/* BG tiles: SMS planar in ROM; pce_load_tiles_planar() → VDC format */
const unsigned char gfxtest_tiles[160] = /*{w:8,h:8,bpp:1,count:5,brev:1,np:4,pofs:1,sl:4}*/ {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
0x55, 0xAA, 0x00, 0x00, 0xAA, 0x55, 0x00, 0x00, 0x55, 0xAA, 0x00, 0x00, 0xAA, 0x55, 0x00, 0x00,
0x55, 0xAA, 0x00, 0x00, 0xAA, 0x55, 0x00, 0x00, 0x55, 0xAA, 0x00, 0x00, 0xAA, 0x55, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0x88, 0xFF, 0x00, 0x00, 0x88, 0xFF, 0x00, 0x00, 0x88, 0xFF, 0x00, 0x00,
0xFF, 0xFF, 0x00, 0x00, 0xA0, 0xFF, 0x00, 0x00, 0xA0, 0xFF, 0x00, 0x00, 0xA0, 0xFF, 0x00, 0x00,
0xEF, 0x00, 0x10, 0x00, 0xEF, 0x00, 0x10, 0x00, 0xC7, 0x00, 0x38, 0x00, 0x83, 0x00, 0x7C, 0x00,
0xC7, 0x00, 0x38, 0x00, 0xEF, 0x00, 0x10, 0x00, 0xEF, 0x00, 0x10, 0x00, 0xFF, 0x00, 0x00, 0x00,
};

const unsigned short gfxtest_sprites[192] = /*{w:16,h:16,bpp:1,count:3,brev:1,np:4,pofs:16,sl:1,bpw:16,wpimg:64}*/ {
0x0180, 0x03C0, 0x03C0, 0x07E0, 0x0660, 0x0FF0, 0x0FF0, 0x1E78,
0x1E78, 0x3FFC, 0x3BDC, 0x718E, 0x6186, 0x0180, 0x0240, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180,
0x0180, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, 0x0240, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x03C0, 0x0FF0, 0x1FF8, 0x381C, 0x300C, 0x700E, 0x700E,
0x700E, 0x700E, 0x300C, 0x381C, 0x1FF8, 0x0FF0, 0x03C0, 0x0000,
0x0000, 0x03C0, 0x0C30, 0x1008, 0x27E4, 0x29F4, 0x4BF2, 0x4FF2,
0x4FF2, 0x4FF2, 0x2FF4, 0x27E4, 0x1008, 0x0C30, 0x03C0, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0600, 0x0400, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0810, 0x0810, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0C30, 0x0660, 0x0FF0, 0x1FF8, 0x37EC, 0x37EC, 0x3FFC,
0x3FFC, 0x0C30, 0x1818, 0x300C, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};

const unsigned short gfxtest_bg_pal[16] = /*{pal:"pce",n:16,bpw:16}*/ { 0x000, 0x049, 0x12E, 0x0B4, 0x1FF, 0x038, 0x1C0, 0x0FF, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000 };
const unsigned short gfxtest_spr_pal[16] = /*{pal:"pce",n:16,bpw:16}*/ { 0x000, 0x1FF, 0x038, 0x0E8, 0x1FF, 0x1C0, 0x049, 0x092, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000 };

#endif
Loading
Loading