amiga_imgv

view src/main.c @ 3:663471a80c21

broken + sdl emu
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Oct 2017 15:49:56 +0300
parents a4788c959918
children 4c36d0f44aa6
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <assert.h>
5 #include "gfx.h"
6 #include "image.h"
7 #include "logger.h"
10 static int proc_event(union gfx_event *ev);
12 int main(int argc, char **argv)
13 {
14 struct ham_image *img;
16 if(argv[1]) {
17 if(!(img = load_ham_image(argv[1]))) {
18 fprintf(stderr, "failed to load image: %s\n", argv[1]);
19 return 1;
20 }
21 } else {
22 printf("generating test image ...\n");
23 if(!(img = gen_ham_image(320, 256, 6))) {
24 fprintf(stderr, "failed to generate image\n");
25 return 1;
26 }
27 }
29 if(gfx_init(6, GFX_HAM) == -1) {
30 return 1;
31 }
32 gfx_wait_vblank();
33 gfx_show_image(img);
35 for(;;) {
36 union gfx_event ev;
37 if(gfx_next_event(&ev, GFX_EVLOOP_BLOCK)) {
38 if(proc_event(&ev) == -1) {
39 break;
40 }
41 }
42 }
44 gfx_shutdown();
45 return 0;
46 }
48 static int proc_event(union gfx_event *ev)
49 {
50 switch(ev->type) {
51 case GFX_EV_QUIT:
52 return -1;
54 case GFX_EV_KEY:
55 switch(ev->key.key) {
56 case 27:
57 return -1;
58 default:
59 break;
60 }
61 break;
63 default:
64 break;
65 }
66 return 0;
67 }