Skip to content

Commit 1eec27d

Browse files
authored
Create cobol_c_glue.c
1 parent f2f44cf commit 1eec27d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

extensions/cobol_c_glue.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <stdint.h>
2+
#include <stdarg.h>
3+
#include <stddef.h>
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
#include <string.h>
7+
#include "pluto.h"
8+
9+
void pl_init(void) {
10+
pluto_init_window();
11+
pluto_save_screen();
12+
}
13+
14+
typedef uint32_t cob_u32_t;
15+
typedef uint8_t cob_u8_t;
16+
17+
#define COBOL_X_TO_C(buf, v, r, s)\
18+
memcpy(buf, v, s);\
19+
buf[s] = '\0';\
20+
r = atoi(buf);\
21+
22+
void pl_cpix(cob_u8_t *x, cob_u8_t *y, cob_u8_t *r, cob_u8_t *g, cob_u8_t *b) {
23+
uint32_t x8, y8, r8, g8, b8;
24+
char *tmpbuf;
25+
26+
tmpbuf = malloc(255);
27+
COBOL_X_TO_C(tmpbuf, x, x8, 3);
28+
COBOL_X_TO_C(tmpbuf, y, y8, 3);
29+
COBOL_X_TO_C(tmpbuf, r, r8, 3);
30+
COBOL_X_TO_C(tmpbuf, g, g8, 3);
31+
COBOL_X_TO_C(tmpbuf, b, b8, 3);
32+
free(tmpbuf);
33+
34+
pluto_set_cpix(x8, y8, r8, g8, b8);
35+
}
36+
37+
void pl_render(void) {
38+
pluto_write_out();
39+
pluto_render();
40+
}
41+
42+
void pl_deinit(void) {
43+
pluto_deinit();
44+
}

0 commit comments

Comments
 (0)