tc2048 and esxdos

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
rkd77
Member
Posts: 50
Joined: Sun May 04, 2008 10:35 am

tc2048 and esxdos

Post by rkd77 »

Good morning,
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;
}
, but I want hires 64 column mode. Is a simple switch for compiler, or could you add it?
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: tc2048 and esxdos

Post by dom »

The +zx newlib target doesn't have any code to support the different screen modes for the Timex machines.

It might be best just to use the +zxn target since it's going to be broadly compatible for dot commands. There's a post with a bit more background here: https://z88dk.org/forum/viewtopic.php?p=16183#p16183
rkd77
Member
Posts: 50
Joined: Sun May 04, 2008 10:35 am

Re: tc2048 and esxdos

Post by rkd77 »

Thanks, added +zxn -startup=16 to zcc
and

Code: Select all

#pragma output NEXTOS_VERSION = 0
#pragma redirect CRT_OTERM_FONT_8X8 = _font_8x8_vga_rom
and something is shown.
Parameters are counted from 0, so argv[0] is the first filename.
Is it standard for zxn or bug?
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: tc2048 and esxdos

Post by dom »

I can see there's another pragma define: CRT_ENABLE_COMMANDLINE_EX which either takes 0x00 or 0x80 that affects whether argv[0] contains the program name.

I'm not sure why it's an option, but try setting it to 0x80, hopefully that will fix it.
rkd77
Member
Posts: 50
Joined: Sun May 04, 2008 10:35 am

Re: tc2048 and esxdos

Post by rkd77 »

There is also check for __NEXTOS_DOT_COMMAND or NEXTOS_VERSION. If they are set and non-zero there is error:
"Requires NextZXOS" or similar message.
Post Reply