I've got following configuration (Timex2048 and esxdos), wrote code:
Code: Select all
#pragma printf = "%c"
#pragma output CLIB_EXIT_STACK_SIZE = 3
/* /snap/bin/z88dk.zcc +zx -vn -subtype=dot -startup=5 -clib=sdcc_iy -SO3 --max-allocs-per-node200000 --opt-code-size more64.c -o more64 -create-app */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <input.h>
#include <z80.h>
#if __ZXNEXT
#include <arch/zxn/esxdos.h>
#else
#include <arch/zx/esxdos.h>
#endif
#define WIDTH 64
int count;
unsigned char f;
char *buf = (char *)32768;
unsigned long start = 0;
int
draw_screen(char *bufor2)
{
char y;
char *buf = bufor2;
for (y = 1; y < 25; y++) {
printf("%c%c%c", 22, 1, y);
int was_enter = 0;
int x;
for (x = 0; x < WIDTH; x++) {
if (was_enter) {
putchar(' ');
} else {
if (!*buf) {
putchar(' ');
continue;
}
if (*buf == '\n') {
was_enter = 1;
putchar(' ');
buf++;
} else {
putchar(*buf++);
}
}
}
}
return buf - bufor2;
}
int
main(int argc, char **argv)
{
__asm
ld a,6
out (255),a
__endasm;
if (argc > 1) {
f = esxdos_f_open(argv[1], ESXDOS_MODE_OPEN_EXIST | ESXDOS_MODE_R);
if (errno) {
goto wypad;
}
while (1) {
esxdos_f_seek(f, start, SEEK_SET);
count = esxdos_f_read(f, buf, 2048);
buf[count] = '\0';
if (!count) {
esxdos_f_close(f);
goto wypad;
}
start += draw_screen(buf);
in_wait_key();
}
}
wypad:
__asm
ld a,0
out (255),a
__endasm;
return 0;
}