2019-01-05 21:16:08 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <dos.h>
|
2019-04-26 01:55:23 +00:00
|
|
|
#include <alloc.h>
|
2019-01-05 21:16:08 +00:00
|
|
|
|
2019-01-25 02:36:42 +00:00
|
|
|
#include "video.h"
|
|
|
|
#include "kbd.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "tiff.h"
|
|
|
|
#include "tiles.h"
|
2019-01-30 00:35:48 +00:00
|
|
|
#include "serial.h"
|
2019-02-09 16:48:40 +00:00
|
|
|
#include "timer.h"
|
|
|
|
#include "jorth.h"
|
2019-02-26 03:19:08 +00:00
|
|
|
#include "egamap.h"
|
2019-03-26 02:05:23 +00:00
|
|
|
#include "adlib.h"
|
2019-01-19 04:02:50 +00:00
|
|
|
|
2019-02-16 00:39:50 +00:00
|
|
|
/*** T E X T ***/
|
|
|
|
char far *font = NULL;
|
|
|
|
|
|
|
|
void text_init() {
|
|
|
|
unsigned int fontSeg, fontOff;
|
|
|
|
asm {
|
|
|
|
push es
|
|
|
|
push bp
|
|
|
|
mov ah, 11h
|
|
|
|
mov al, 30h
|
|
|
|
mov bh, 3
|
|
|
|
int 10h
|
|
|
|
mov ax, bp
|
|
|
|
pop bp
|
|
|
|
mov fontSeg, es
|
|
|
|
mov fontOff, ax
|
|
|
|
pop es
|
|
|
|
}
|
|
|
|
font = MK_FP(fontSeg, fontOff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void text_draw_char(unsigned int vidOffset, unsigned char c) {
|
|
|
|
unsigned int fontOffset = c << 3;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i ++) {
|
|
|
|
VID[vidOffset] = font[fontOffset++];
|
|
|
|
vidOffset += PAGE_STRIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void text_draw(unsigned int vidOffset, unsigned char *s) {
|
|
|
|
while (*s) {
|
|
|
|
text_draw_char(vidOffset++, *s++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-28 18:48:19 +00:00
|
|
|
/*** I / O ***/
|
|
|
|
size_t fwritefar(FILE *fp, void far *buf, size_t length) {
|
|
|
|
char nearbuf[32];
|
|
|
|
size_t written = 0;
|
|
|
|
size_t towrite;
|
|
|
|
|
|
|
|
for (; towrite = min(32, length), length > 0; length -= towrite) {
|
|
|
|
movedata(FP_SEG(buf), FP_OFF(buf) + written, _SS, nearbuf, towrite);
|
|
|
|
if (!fwrite(nearbuf, towrite, 1, fp)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
written += towrite;
|
|
|
|
}
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t freadfar(FILE *fp, void far *buf, size_t length) {
|
|
|
|
char nearbuf[32];
|
|
|
|
size_t totalread = 0;
|
|
|
|
size_t toread;
|
|
|
|
|
|
|
|
for (; toread = min(32, length), length > 0; length -= toread) {
|
|
|
|
size_t bytesread = fread(nearbuf, 1, toread, fp);
|
|
|
|
movedata(_SS, nearbuf, FP_SEG(buf), FP_OFF(buf) + totalread, bytesread);
|
|
|
|
totalread += bytesread;
|
|
|
|
if (bytesread != toread) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return totalread;
|
|
|
|
}
|
|
|
|
|
2019-01-19 04:02:50 +00:00
|
|
|
/*** S C R A T C H ***/
|
2019-01-25 02:36:42 +00:00
|
|
|
|
2019-01-19 04:03:02 +00:00
|
|
|
#define NUM_SPRITES 64
|
2019-01-19 20:50:50 +00:00
|
|
|
#define TILE_STRIDE 64
|
|
|
|
#define SPRITE_STRIDE 80
|
2019-04-26 01:55:23 +00:00
|
|
|
unsigned int far *tiles;
|
|
|
|
unsigned int far *sprites;
|
2019-01-19 04:02:56 +00:00
|
|
|
unsigned char map[10000];
|
2019-01-19 04:02:50 +00:00
|
|
|
|
2019-06-26 01:58:52 +00:00
|
|
|
|
|
|
|
void deallocate_gfx() {
|
|
|
|
if (tiles) farfree(tiles);
|
|
|
|
if (sprites) farfree(sprites);
|
|
|
|
}
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
void allocate_gfx() {
|
|
|
|
unsigned long memleft = farcoreleft();
|
2019-06-26 01:58:52 +00:00
|
|
|
tiles = farmalloc(NUM_TILES * TILE_STRIDE * 2);
|
|
|
|
sprites = farmalloc(NUM_SPRITES * SPRITE_STRIDE * 2);
|
|
|
|
atexit(deallocate_gfx);
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
if (!tiles || !sprites) {
|
|
|
|
printf("%lu bytes free - need %lu\n", memleft,
|
|
|
|
(unsigned long)
|
|
|
|
((NUM_TILES * TILE_STRIDE) +
|
|
|
|
(NUM_SPRITES * SPRITE_STRIDE)));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-19 04:02:56 +00:00
|
|
|
void fillMap() {
|
2019-01-19 04:02:50 +00:00
|
|
|
unsigned int x, y, z;
|
|
|
|
z = 0;
|
|
|
|
|
|
|
|
for (y = 0; y < 100; y ++) {
|
|
|
|
for (x = 0; x < 100; x ++) {
|
2019-01-19 20:50:50 +00:00
|
|
|
map[x + (y * 100)] = ((x + y + z) >> 2) % 4;
|
2019-01-19 04:02:50 +00:00
|
|
|
}
|
2019-01-05 21:16:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:35:37 +00:00
|
|
|
void readTiles(char *filename) {
|
|
|
|
FILE *f;
|
|
|
|
TifImageMeta_t meta;
|
|
|
|
|
|
|
|
f = fopen(filename, "rb");
|
|
|
|
meta = tifLoadMeta(f);
|
|
|
|
tifLoad(f, meta, tiles, NUM_TILES * 16, 16, 4);
|
|
|
|
tifLoadEGA(f, meta, OFF_TILES, NUM_TILES * 16, 16);
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
loadTiles(OFF_TILES, tiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
void f_loadtiles() {
|
|
|
|
readTiles(TOP().s);
|
|
|
|
DROP(1);
|
|
|
|
}
|
|
|
|
|
2019-07-28 18:48:19 +00:00
|
|
|
#define SPRITE_GFX
|
|
|
|
|
2019-01-19 04:02:56 +00:00
|
|
|
void game_init() {
|
2019-01-05 21:16:08 +00:00
|
|
|
FILE *f;
|
|
|
|
TifImageMeta_t meta;
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
allocate_gfx();
|
|
|
|
|
2019-02-18 01:14:56 +00:00
|
|
|
mouse_init();
|
|
|
|
|
2019-01-05 21:16:08 +00:00
|
|
|
setEGAMode();
|
2019-01-07 02:29:20 +00:00
|
|
|
atexit(vid_cleanup);
|
|
|
|
|
2019-01-25 02:36:42 +00:00
|
|
|
kbd_init();
|
2019-02-09 16:48:40 +00:00
|
|
|
timer_init(TIMER_30HZ);
|
2019-02-16 00:39:50 +00:00
|
|
|
text_init();
|
2019-01-25 02:36:42 +00:00
|
|
|
|
2019-01-19 04:02:56 +00:00
|
|
|
tile_init();
|
|
|
|
fillMap();
|
|
|
|
|
2019-01-07 02:29:20 +00:00
|
|
|
f = fopen("FOOTER.TIF", "rb");
|
|
|
|
meta = tifLoadMeta(f);
|
2019-02-26 03:19:08 +00:00
|
|
|
tifLoadEGA(f, meta, 0, 48, 336);
|
2019-01-07 02:29:20 +00:00
|
|
|
fclose(f);
|
2019-01-05 21:16:08 +00:00
|
|
|
|
2019-07-28 18:48:19 +00:00
|
|
|
#ifdef SPRITE_GFX
|
|
|
|
f = fopen("sprite.gfx", "rb");
|
|
|
|
freadfar(f, sprites, NUM_SPRITES * SPRITE_STRIDE * 2);
|
|
|
|
fclose(f);
|
|
|
|
#else
|
2019-01-19 04:03:02 +00:00
|
|
|
f = fopen("SPRITE.TIF", "rb");
|
|
|
|
meta = tifLoadMeta(f);
|
|
|
|
tifLoad(f, meta, sprites, NUM_SPRITES * 16, 16, 5);
|
2019-01-05 21:16:08 +00:00
|
|
|
fclose(f);
|
2019-07-28 18:48:19 +00:00
|
|
|
#endif
|
2019-01-05 21:16:08 +00:00
|
|
|
|
2019-02-26 03:19:08 +00:00
|
|
|
f = fopen("PORTRAIT.TIF", "rb");
|
|
|
|
meta = tifLoadMeta(f);
|
|
|
|
tifLoadEGA(f, meta, OFF_PORTRAITS, NUM_PORTRAITS * 32, 32);
|
|
|
|
fclose(f);
|
|
|
|
|
2019-06-02 03:35:37 +00:00
|
|
|
readTiles("TILES.TIF");
|
|
|
|
|
2019-01-19 04:02:56 +00:00
|
|
|
loadMap(map, 100, 100);
|
|
|
|
scroll(0, 0);
|
|
|
|
}
|
|
|
|
|
2019-02-06 02:07:30 +00:00
|
|
|
void f_seremit() {
|
|
|
|
ser_write_byte(TOP().i);
|
|
|
|
if (TOP().i == '\n') {
|
|
|
|
ser_write_byte('\r');
|
|
|
|
}
|
|
|
|
DROP(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void f_keyWasPressed() {
|
2019-02-17 00:21:02 +00:00
|
|
|
int k = TOP().i;
|
|
|
|
TOP().i = keyWasPressed(k);
|
|
|
|
consumeKey(k);
|
2019-02-06 02:07:30 +00:00
|
|
|
}
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-02-06 02:07:30 +00:00
|
|
|
void f_keyIsDown() {
|
|
|
|
TOP().i = keyIsDown(TOP().i);
|
|
|
|
}
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-02-06 02:07:30 +00:00
|
|
|
void f_drawSprite() { // ( x y sprite -- )
|
|
|
|
drawSprite(&sprites[TOP().i * SPRITE_STRIDE], ST2().i, ST1().i);
|
|
|
|
DROP(3);
|
|
|
|
}
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-02-06 02:07:30 +00:00
|
|
|
void f_scroll() { // ( x y -- )
|
|
|
|
scroll(ST1().i, TOP().i);
|
2019-02-11 00:17:58 +00:00
|
|
|
DROP(2);
|
2019-02-06 02:07:30 +00:00
|
|
|
}
|
2019-02-18 01:14:56 +00:00
|
|
|
|
|
|
|
void f_scrollpos() { // ( -- x y )
|
|
|
|
PUSHI(screen.scrollX);
|
|
|
|
PUSHI(screen.scrollY);
|
|
|
|
}
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-02-09 16:48:40 +00:00
|
|
|
void f_ticks() {
|
|
|
|
PUSHU(timer_counter);
|
|
|
|
}
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-02-12 04:23:00 +00:00
|
|
|
void f_splitscreen() {
|
|
|
|
setSplitScreen(399 - (TOP().i << 1));
|
|
|
|
DROP(1);
|
|
|
|
}
|
2019-02-16 00:39:50 +00:00
|
|
|
|
2019-03-05 22:35:50 +00:00
|
|
|
void f_textc() { // ( col line c color -- )
|
|
|
|
setWriteMode(0);
|
|
|
|
setPlaneColor(TOP().u);
|
|
|
|
DROP(1);
|
|
|
|
text_draw_char(ST2().u + (ST1().u * PAGE_STRIDE), TOP().i);
|
|
|
|
DROP(3);
|
|
|
|
}
|
2019-02-26 03:19:08 +00:00
|
|
|
|
|
|
|
void f_text() { // ( col line s color -- )
|
|
|
|
setWriteMode(0);
|
|
|
|
setPlaneColor(TOP().u);
|
|
|
|
DROP(1);
|
2019-02-16 00:39:50 +00:00
|
|
|
text_draw(ST2().u + (ST1().u * PAGE_STRIDE), TOP().s);
|
|
|
|
DROP(3);
|
|
|
|
}
|
2019-02-18 01:14:56 +00:00
|
|
|
|
|
|
|
void f_map() {
|
|
|
|
PUSHP(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
void f_mapsize() { // ( -- w h )
|
|
|
|
PUSHI(screen.w);
|
|
|
|
PUSHI(screen.h);
|
|
|
|
}
|
|
|
|
|
2019-02-24 17:18:34 +00:00
|
|
|
void f_mapsize_set() { // ( w h -- )
|
|
|
|
loadMap(map, ST1().i, TOP().i);
|
|
|
|
DROP(2);
|
|
|
|
}
|
|
|
|
|
2019-02-18 01:14:56 +00:00
|
|
|
void f_mousepos() { // ( -- x y )
|
|
|
|
PUSHI(MOUSE.x);
|
|
|
|
PUSHI(MOUSE.y);
|
|
|
|
}
|
|
|
|
void f_mousebuttons() {
|
|
|
|
PUSHI(MOUSE.buttons);
|
|
|
|
}
|
|
|
|
|
2019-02-26 03:19:08 +00:00
|
|
|
void f_drawportrait() {
|
|
|
|
setAllPlanes();
|
|
|
|
setWriteMode(1);
|
|
|
|
blit32x32(OFF_PORTRAITS + (TOP().u << 7), (PAGE_STRIDE << 3) + 1);
|
|
|
|
DROP(1);
|
|
|
|
}
|
|
|
|
|
2019-03-26 02:05:23 +00:00
|
|
|
void f_adlib() {
|
2019-03-31 23:29:16 +00:00
|
|
|
adlib_write(TOP().u, ST1().u);
|
2019-03-26 02:05:23 +00:00
|
|
|
DROP(2);
|
|
|
|
}
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
cell f_atexit;
|
|
|
|
void f_cleanup() {
|
|
|
|
f_execcp(f_atexit);
|
|
|
|
}
|
|
|
|
|
2019-06-26 01:58:52 +00:00
|
|
|
void f_glitch() {
|
|
|
|
int count = TOP().u;
|
|
|
|
int i, x, y;
|
|
|
|
DROP(1);
|
|
|
|
for (i = 0; i < count; i ++) {
|
|
|
|
x = screen.scrollX + (rand() % 352) - 16;
|
|
|
|
y = screen.scrollY + (rand() % 232) - 16;
|
|
|
|
switch(rand()%2) {
|
|
|
|
case 0:
|
|
|
|
drawSprite(sprites + (rand() % (NUM_SPRITES * SPRITE_STRIDE)), x, y);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
drawSprite(mem + (rand() % MEM_SIZE), x, y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-24 02:39:56 +00:00
|
|
|
/* JILES */
|
2019-07-26 02:32:31 +00:00
|
|
|
#define SCREEN_STRIDE 40
|
2019-07-24 02:39:56 +00:00
|
|
|
|
2019-07-27 01:37:47 +00:00
|
|
|
int getsprpixel(int x, int y, unsigned int far *spr) {
|
2019-07-26 02:32:31 +00:00
|
|
|
int shift = (15 - x);
|
|
|
|
int b = (spr[y + 0] & (1 << shift)) >> shift;
|
|
|
|
int g = (spr[y + 16] & (1 << shift)) >> shift;
|
|
|
|
int r = (spr[y + 32] & (1 << shift)) >> shift;
|
|
|
|
int i = (spr[y + 48] & (1 << shift)) >> shift;
|
2019-07-27 01:37:47 +00:00
|
|
|
int v = (spr[y + 64] & (1 << shift)) ? 0 : 1;
|
|
|
|
return b | (g << 1) | (r << 2) | (i << 3) | (v << 4);
|
|
|
|
}
|
|
|
|
int resetEnabledCache = 0;
|
|
|
|
|
|
|
|
#define setResetEnabledCached(m) \
|
|
|
|
if (resetEnabledCache != m) { \
|
|
|
|
resetEnabledCache = m; \
|
|
|
|
setResetEnabled(m); \
|
|
|
|
}
|
|
|
|
|
|
|
|
void drawFatBox(int x, int y, int color) {
|
|
|
|
int faty;
|
|
|
|
int fill1 = color <= 0x0f ? 0xff : 0x55;
|
|
|
|
int fill2 = fill1 == 0xff ? 0xff : 0xaa;
|
|
|
|
unsigned int dst = SCREEN_STRIDE * y;
|
|
|
|
|
|
|
|
if (color > 0x0f) {
|
|
|
|
setResetEnabledCached(0);
|
|
|
|
} else {
|
|
|
|
setResetEnabledCached(0x0f);
|
|
|
|
setResetMask(color);
|
|
|
|
}
|
|
|
|
for ( faty = 0; faty < 8; faty ++) {
|
|
|
|
VID[dst + x + (SCREEN_STRIDE * faty)] = (faty % 2) ? fill1 : fill2;
|
|
|
|
}
|
2019-07-26 02:32:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 02:39:56 +00:00
|
|
|
void f_drawfatsprite() {
|
|
|
|
int isprite = TOP().i;
|
|
|
|
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
|
2019-07-27 01:37:47 +00:00
|
|
|
int x, y;
|
2019-07-24 02:39:56 +00:00
|
|
|
|
|
|
|
DROP(1);
|
|
|
|
for ( y = 0; y < 16; y ++ ) {
|
|
|
|
for ( x = 0; x < 16; x ++ ) {
|
2019-07-27 01:37:47 +00:00
|
|
|
int color = getsprpixel(x, y, spr);
|
|
|
|
drawFatBox(x, y << 3, color);
|
2019-07-24 02:39:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:37:47 +00:00
|
|
|
void f_drawfatbox() {
|
|
|
|
drawFatBox(ST1().i, TOP().i, ST2().i);
|
|
|
|
DROP(3);
|
|
|
|
}
|
|
|
|
|
2019-07-28 18:48:19 +00:00
|
|
|
void f_savegfx() {
|
|
|
|
FILE *fp;
|
|
|
|
fp = fopen("sprite.gfx", "wb");
|
|
|
|
fwritefar(fp, sprites, NUM_SPRITES * SPRITE_STRIDE * 2);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
|
2019-07-27 01:37:47 +00:00
|
|
|
void f_mousehide() {
|
|
|
|
mouse_hide();
|
|
|
|
}
|
|
|
|
void f_mouseshow() {
|
|
|
|
setLogicalWidth(SCREEN_STRIDE >> 1);
|
|
|
|
setResetEnabledCached(0);
|
|
|
|
setWriteMode(0);
|
|
|
|
setAllPlanes();
|
|
|
|
mouse_show();
|
|
|
|
}
|
|
|
|
|
2019-07-24 02:39:56 +00:00
|
|
|
void f_putpixel() {
|
|
|
|
int isprite = TOP().i;
|
|
|
|
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
|
|
|
|
int x = ST2().i;
|
|
|
|
int y = ST1().i;
|
|
|
|
int color, shift, b, g, r, i, v;
|
|
|
|
|
|
|
|
DROP(3);
|
|
|
|
color = TOP().i;
|
|
|
|
DROP(1);
|
|
|
|
|
|
|
|
shift = (15 - x);
|
|
|
|
b = (color & 0x01);
|
|
|
|
g = (color & 0x02) >> 1;
|
|
|
|
r = (color & 0x04) >> 2;
|
|
|
|
i = (color & 0x08) >> 3;
|
|
|
|
v = ((color & 0x10) >> 4) ^ 1;
|
|
|
|
|
|
|
|
spr[y + 0] = (spr[y + 0] & ~(1 << shift)) | (b << shift);
|
|
|
|
spr[y + 16] = (spr[y + 16] & ~(1 << shift)) | (g << shift);
|
|
|
|
spr[y + 32] = (spr[y + 32] & ~(1 << shift)) | (r << shift);
|
|
|
|
spr[y + 48] = (spr[y + 48] & ~(1 << shift)) | (i << shift);
|
|
|
|
spr[y + 64] = (spr[y + 64] & ~(1 << shift)) | (v << shift);
|
|
|
|
}
|
|
|
|
|
2019-07-26 02:32:31 +00:00
|
|
|
void f_getpixel() {
|
|
|
|
int isprite = TOP().i;
|
|
|
|
unsigned int far *spr = &sprites[isprite * SPRITE_STRIDE];
|
|
|
|
int x = ST2().i;
|
|
|
|
int y = ST1().i;
|
|
|
|
DROP(2);
|
|
|
|
|
2019-07-27 01:37:47 +00:00
|
|
|
TOP().i = getsprpixel(x, y, spr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void f_spritecount() {
|
|
|
|
PUSHI(NUM_SPRITES);
|
2019-07-26 02:32:31 +00:00
|
|
|
}
|
|
|
|
|
2019-07-24 02:39:56 +00:00
|
|
|
/* INIT */
|
2019-07-20 02:29:32 +00:00
|
|
|
void game_f_init(char *exe, char *bootjor) {
|
2019-04-10 02:00:32 +00:00
|
|
|
f_init(exe);
|
2019-02-06 02:07:30 +00:00
|
|
|
CDEF("seremit", f_seremit);
|
|
|
|
CDEF("key-pressed", f_keyWasPressed);
|
|
|
|
CDEF("key-down", f_keyIsDown);
|
2019-04-26 01:55:23 +00:00
|
|
|
CDEF("key-start", kbd_init);
|
|
|
|
CDEF("key-end", kbd_cleanup);
|
2019-02-11 00:17:58 +00:00
|
|
|
CDEF("draw-sprite", f_drawSprite);
|
2019-02-26 03:19:08 +00:00
|
|
|
CDEF("draw-portrait", f_drawportrait);
|
2019-02-06 02:07:30 +00:00
|
|
|
CDEF("scroll", f_scroll);
|
2019-02-18 01:14:56 +00:00
|
|
|
CDEF("scrollpos", f_scrollpos);
|
2019-02-11 00:17:58 +00:00
|
|
|
CDEF("draw-screen", drawScreen);
|
2019-02-12 04:23:00 +00:00
|
|
|
CDEF("split-screen", f_splitscreen);
|
2019-02-09 16:48:40 +00:00
|
|
|
CDEF("ticks", f_ticks);
|
2019-02-16 00:39:50 +00:00
|
|
|
CDEF("text", f_text);
|
2019-03-05 22:35:50 +00:00
|
|
|
CDEF("textc", f_textc);
|
2019-02-18 01:14:56 +00:00
|
|
|
CDEF("map", f_map);
|
|
|
|
CDEF("mapsize", f_mapsize);
|
2019-02-24 17:18:34 +00:00
|
|
|
CDEF("mapsize!", f_mapsize_set);
|
2019-02-18 01:14:56 +00:00
|
|
|
CDEF("mousepos", f_mousepos);
|
|
|
|
CDEF("mousebuttons", f_mousebuttons);
|
2019-06-02 03:35:37 +00:00
|
|
|
CDEF("loadtiles", f_loadtiles);
|
2019-06-26 01:58:52 +00:00
|
|
|
CDEF("glitch", f_glitch);
|
2019-02-26 03:19:08 +00:00
|
|
|
CDEF("unfuck", tile_init);
|
2019-04-26 01:55:23 +00:00
|
|
|
|
2019-07-24 02:39:56 +00:00
|
|
|
CDEF("mouseshow", f_mouseshow);
|
2019-07-26 02:32:31 +00:00
|
|
|
CDEF("mousehide", f_mousehide);
|
2019-07-24 02:39:56 +00:00
|
|
|
CDEF("drawfatsprite", f_drawfatsprite);
|
2019-07-27 01:37:47 +00:00
|
|
|
CDEF("drawfatbox", f_drawfatbox);
|
2019-07-24 02:39:56 +00:00
|
|
|
CDEF("putpixel", f_putpixel);
|
2019-07-26 02:32:31 +00:00
|
|
|
CDEF("getpixel", f_getpixel);
|
2019-07-27 01:37:47 +00:00
|
|
|
CDEF("spritecount", f_spritecount);
|
2019-07-28 18:48:19 +00:00
|
|
|
CDEF("savegfx", f_savegfx);
|
2019-07-24 02:39:56 +00:00
|
|
|
|
2019-07-20 02:29:32 +00:00
|
|
|
f_loadjor(bootjor);
|
2019-04-26 01:55:23 +00:00
|
|
|
|
|
|
|
f_atexit = f_lookupcp("atexit");
|
|
|
|
atexit(f_cleanup);
|
|
|
|
|
2019-02-04 02:04:02 +00:00
|
|
|
}
|
2019-02-06 02:07:30 +00:00
|
|
|
|
|
|
|
void f_poll() {
|
2019-03-26 02:05:23 +00:00
|
|
|
static char line[128] = { 0 };
|
2019-02-06 02:07:30 +00:00
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
while (ser_getline(line)) {
|
|
|
|
PUSHS(line);
|
|
|
|
f_runstring("REPL send");
|
|
|
|
f_taskloop();
|
|
|
|
line[0] = '\0';
|
2019-02-06 02:07:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-24 15:14:56 +00:00
|
|
|
int DONE = 0;
|
|
|
|
static void f_quit() {
|
|
|
|
DONE = 1;
|
|
|
|
}
|
2019-04-10 02:00:32 +00:00
|
|
|
void do_repl(char *exe) {
|
2019-03-26 02:05:23 +00:00
|
|
|
char buf[128];
|
2019-02-24 15:14:56 +00:00
|
|
|
|
2019-04-10 02:00:32 +00:00
|
|
|
f_init(exe);
|
2019-02-24 15:14:56 +00:00
|
|
|
CDEF("quit", f_quit);
|
2019-03-26 02:05:23 +00:00
|
|
|
CDEF("adlib", f_adlib);
|
2019-02-24 15:14:56 +00:00
|
|
|
|
|
|
|
f_loadfile("repl.jor");
|
|
|
|
f_taskloop();
|
|
|
|
|
|
|
|
while (!DONE) {
|
|
|
|
PUSHS(gets(buf));
|
|
|
|
f_runstring("REPL send");
|
|
|
|
f_taskloop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-10 02:00:32 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2019-04-08 02:13:32 +00:00
|
|
|
cell tick, draw;
|
2019-07-20 02:29:32 +00:00
|
|
|
char *bootjor = "gameboot.jor";
|
2019-02-24 15:14:56 +00:00
|
|
|
if (argc > 1) {
|
2019-07-20 02:29:32 +00:00
|
|
|
bootjor = argv[1];
|
2019-02-24 15:14:56 +00:00
|
|
|
}
|
2019-02-09 16:48:40 +00:00
|
|
|
ser_init(SER_COM2, BAUD_19200, SER_8N1);
|
2019-01-19 04:02:56 +00:00
|
|
|
game_init();
|
2019-07-20 02:29:32 +00:00
|
|
|
game_f_init(argv[0], bootjor);
|
2019-04-08 02:13:32 +00:00
|
|
|
tick = f_lookupcp("tick");
|
|
|
|
draw = f_lookupcp("draw");
|
2019-02-06 02:07:30 +00:00
|
|
|
|
2019-01-25 02:36:42 +00:00
|
|
|
while (!keyIsDown(K_ESC)) {
|
|
|
|
kbd_debounce();
|
2019-02-06 02:07:30 +00:00
|
|
|
f_poll();
|
2019-02-11 00:17:58 +00:00
|
|
|
f_taskloop();
|
2019-04-08 02:13:32 +00:00
|
|
|
f_execcp(tick);
|
2019-02-11 00:17:58 +00:00
|
|
|
f_taskloop();
|
2019-04-08 02:13:32 +00:00
|
|
|
f_execcp(draw);
|
2019-01-05 21:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|