aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-09-14 18:57:05 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-09-14 18:57:05 +0900
commit1ff3793322585443909d11284457811c461f8de4 (patch)
tree2ae703afca718f12137ec0a59ec67cfc2383bb2f
parent3e9da829c4ea58363a41f0e4e04124d4090ed6f3 (diff)
pacc: add viewport
-rw-r--r--pacc/pacc-gl-procs.inc1
-rw-r--r--pacc/pacc-gl.c5
-rw-r--r--pacc/pacc.h1
-rw-r--r--sdl/main.c16
4 files changed, 21 insertions, 2 deletions
diff --git a/pacc/pacc-gl-procs.inc b/pacc/pacc-gl-procs.inc
index cd991e0..1984273 100644
--- a/pacc/pacc-gl-procs.inc
+++ b/pacc/pacc-gl-procs.inc
@@ -9,6 +9,7 @@ PROC(GENTEXTURES, GenTextures)
PROC(TEXPARAMETERI, TexParameteri)
PROC(PIXELSTOREI, PixelStorei)
PROC(DRAWARRAYS, DrawArrays)
+PROC(VIEWPORT, Viewport)
#endif // PROC_NO_GL_1_1
PROC(ACTIVETEXTURE, ActiveTexture)
#endif // PROC_NO_GL_1_3
diff --git a/pacc/pacc-gl.c b/pacc/pacc-gl.c
index e1463b8..ada045e 100644
--- a/pacc/pacc-gl.c
+++ b/pacc/pacc-gl.c
@@ -468,6 +468,10 @@ err:
return 0;
}
+static void pacc_viewport_scale(struct pacc_ctx *pc, int scale) {
+ glViewport(0, 0, pc->w*scale, pc->h*scale);
+}
+
static struct pacc_vtable pacc_gl_vtable = {
.pacc_delete = pacc_delete,
.gen_buf = pacc_gen_buf,
@@ -485,6 +489,7 @@ static struct pacc_vtable pacc_gl_vtable = {
.color = pacc_color,
.begin_clear = pacc_begin_clear,
.draw = pacc_draw,
+ .viewport_scale = pacc_viewport_scale,
};
struct pacc_ctx *pacc_init_gl(int w, int h, struct pacc_vtable *vt) {
diff --git a/pacc/pacc.h b/pacc/pacc.h
index b3387ac..30e7ab2 100644
--- a/pacc/pacc.h
+++ b/pacc/pacc.h
@@ -46,6 +46,7 @@ struct pacc_vtable {
void (*color)(struct pacc_ctx *ctx, uint8_t pal);
void (*begin_clear)(struct pacc_ctx *ctx);
void (*draw)(struct pacc_ctx *ctx, struct pacc_buf *buf, enum pacc_mode mode);
+ void (*viewport_scale)(struct pacc_ctx *ctx, int scale);
};
struct pacc_ctx *pacc_init_gl(int w, int h, struct pacc_vtable *vt);
diff --git a/sdl/main.c b/sdl/main.c
index 39ead1b..e46a660 100644
--- a/sdl/main.c
+++ b/sdl/main.c
@@ -31,8 +31,10 @@ static struct {
char adpcmram[OPNA_ADPCM_RAM_SIZE];
struct fmdsp_pacc *fp;
atomic_flag fftdata_flag;
+ int scale;
} g = {
.fftdata_flag = ATOMIC_FLAG_INIT,
+ .scale = 1,
};
static void audiocb(void *ptr, Uint8 *bufptr, int len) {
@@ -116,7 +118,7 @@ int main(int argc, char **argv) {
g.win = SDL_CreateWindow(
"FMPlayer SDL",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
- 640*2, 400*2,
+ PC98_W, PC98_H,
SDL_WINDOW_OPENGL);
if (!g.win) {
SDL_Log("Cannot create window\n");
@@ -170,7 +172,8 @@ int main(int argc, char **argv) {
SDL_free(e.drop.file);
break;
case SDL_KEYDOWN:
- if (e.key.keysym.scancode == SDL_SCANCODE_F11) {
+ switch (e.key.keysym.scancode) {
+ case SDL_SCANCODE_F11:
if (e.key.keysym.mod & KMOD_SHIFT) {
fmdsp_pacc_set_right_mode(
g.fp,
@@ -180,6 +183,15 @@ int main(int argc, char **argv) {
g.fp,
(fmdsp_pacc_left_mode(g.fp) + 1) % FMDSP_LEFT_MODE_CNT);
}
+ break;
+ case SDL_SCANCODE_F12:
+ g.scale++;
+ if (g.scale > 3) g.scale = 1;
+ SDL_SetWindowSize(g.win, PC98_W*g.scale, PC98_H*g.scale);
+ pacc.viewport_scale(pc, g.scale);
+ break;
+ default:
+ break;
}
if (e.key.keysym.mod & KMOD_CTRL) {
switch (e.key.keysym.scancode) {