
Сообщение от
Alcoholics Anonymous
Я отправлю еще один пример того, что может быть сделано с библиотеками позже, что демонстрирует пропорциональных шрифтов в текстовых окнах.
https://drive.google.com/file/d/0B6X...ew?usp=sharing
Два fzx выходные клеммы создаются, один с шрифтом "префект", а другой с шрифта "RoundelSerif". Существует один входной терминал прикреплен к выходной клемме с меньшим шрифтом.
То же случайный текст напечатан на обоих выходных клемм и через случайные интервалы, текст с клавиатуры и записывается в другой выходной клемме.
Чтобы сделать это демо, я создал новый ЭЛТ с двумя выходными клеммами и один вход. Мы создаем ЭЛТ с помощью винтов M4 макросов.Шаблон я использовал:
http://z88dk.cvs.sourceforge.net/vie....1&view=markup
который является шаблоном для 48k барана ZX. Я заменил строки 73-84 с моими собственными экземпляров драйверов:
Скрытый текст
Two fzx output terminals are created, one with font "Prefect" and another with font "RoundelSerif". There is one input terminal attached to the output terminal with the smaller font.
The same random text is printed to both output terminals and at random intervals, text is read from the keyboard and written to the other output terminal.
To make this demo, I created a new crt with two output terminals and one input terminal. We create crts using m4 macros. The template I used is:
http://z88dk.cvs.sourceforge.net/vie....1&view=markup
which is a template for the 48k ram zx. I replaced lines 73-84 with my own driver instantiations:
[свернуть]
Код:
include(../../clib_instantiate_begin.m4)
include(../driver/terminal/zx_01_input_kbd_inkey.m4)dnl
m4_zx_01_input_kbd_inkey(_stdin, __i_fcntl_fdstruct_1, 0x03b0, 64, 1, 500, 15)dnl
include(../driver/terminal/zx_01_output_fzx.m4)dnl
m4_zx_01_output_fzx(_window_1, 0x2330, 0, 0, 1, 14, 1, 19, 0, _ff_ao_Prefect, 14, 0, 14, 8, 112, 8, 152, 1, 0, 3, 0)dnl
include(../driver/terminal/zx_01_output_fzx.m4)dnl
m4_zx_01_output_fzx(_window_2, 0x2330, 0, 0, 16, 14, 3, 19, 0, _ff_ao_RoundelSerif, 26, 0, 26, 128, 112, 24, 152, 1, 0, 3, 0)dnl
include(../../clib_instantiate_end.m4)
Эти драйверы относятся к файловым дескрипторам 0, 1, 2 и данного файла * по имени стандартного устройства ввода, window_1 и window_2. Аргументы двумя выходными клеммами определить окно, цвет, шрифт и указать, что окно будет прокручиваться, не останавливаясь.
После определения того, что водители экземпляра, я сделал ЭЛТ, запустив m4 на него и создания ЭЛТ с уникальным именем:
Скрытый текст
These drivers are assigned to file descriptors 0, 1, 2 and are given FILE* named stdin, window_1 and window_2. The arguments to the two output terminals define the window, colour, font and indicate that the window will scroll without pausing.
After defining what drivers are instantiated, I made the crt by running m4 on it and creating the crt with a unique name:
[свернуть]
m4 zx_crt_ram.m4 > zx_crt_200.asm
Затем я добавил zx_crt_200 к файлу zx_crt.asm используемой серии ZX цели:
http://z88dk.cvs.sourceforge.net/vie...13&view=markup
путем вставки этого в файле:
Код:
IF startup = 200
; three terminal windows on screen
;
; stdin = zx_01_input_kbd_inkey (connected to window_1)
; window_1 = fzx terminal (font = Prefect)
; window_2 = fzx terminal (font = RoundelSerif)
INCLUDE "startup/zx_crt_200.asm"
ENDIF
Имея это в месте, где я могу выбрать, что ЭЛТ с "-startup = 200" на линии компиляции.
Программа C прост:
Скрытый текст
With that in place I can select that crt with "-startup=200" on the compile line.
The C program is simple:
[свернуть]
Код:
// sccz80
// zcc +zx -vn -startup=200 -clib=new fzx_term2.c -o fzx_term2
//
// sdcc
// zcc +zx -vn -startup=200 -clib=sdcc_ix --reserve-regs-iy --max-allocs-per-node200000 fzx_term2.c -o fzx_term2
#include <stdio.h>
#include <stropts.h>
#include <arch/spectrum.h>
#include <stdlib.h>
#include <string.h>
extern FILE *window_1;
extern FILE *window_2;
main()
{
static int i;
static char buffer[100];
zx_border(INK_BLACK);
zx_cls(INK_GREEN | PAPER_GREEN);
ioctl(1, IOCTL_OTERM_CLS);
ioctl(2, IOCTL_OTERM_CLS);
while (1)
{
// fill buffer with random letters
memset(buffer, 0, 100);
for (i = rand() % 100; i >= 0; --i)
buffer[i] = (char)((rand() % ('z' - ' ')) + ' ');
// print to both windows
fprintf(window_1, "%s\n", buffer);
fprintf(window_2, "%s\n", buffer);
// gather input
if (rand() > 32200)
{
fprintf(window_1, "\nEnter some text: ");
fflush(stdin);
scanf("%99[^\n]", buffer);
i = ioctl(2, IOCTL_OTERM_FCOLOR, INK_YELLOW | PAPER_BLUE);
fprintf(window_2, "\n%s\n\n", buffer);
ioctl(2, IOCTL_OTERM_FCOLOR, i);
}
}
}
Вы можете видеть, что вы можете печатать на клеммах определенных ЭЛТ, и вы можете настроить терминалов во время выполнения с помощью IOCTL ().
Я вижу ошибку в терминальной кода, что атрибуты подвергаются воздействию ниже текстовых окон. Это может быть ошибка в шрифтах или в fzx водителя, который я должен буду смотреть.
Я не ожидал, что кто следуют за этим, это просто указание на различие между минимальным едва функциональной библиотеки (SDCC) или простой зависит от операционной системы (HiTech) и одной, которая пытается быть полным (z88dk).
При сравнении размеров кода, вы также должны иметь в виду, компилятор, как ВЫСОКОТЕХНОЛОГИЧНЫЙ полагается на операционную систему для обеспечения функциональности. Таким образом, ее бинарные может занять определенный размер, но это также делает использование кода операционной системы, которые могут быть 8k или более в размере, который скрыт от выходного двоичного файла. бинарные z88dk являются полностью независимыми и могут существовать отдельно от любой операционной системы. У вас есть возможность писать драйверы, использующие программное обеспечение системы, но мы не сделали, что еще для новой библиотеки.
В ZIP Вы также можете сравнить выход АНМ, порожденную SDCC и sccz80 по исследуются файлы "fzx_term2_sdcc.asm" и "fzx_term2_sccz80.opt". В этом случае SDCC скомпилированные бинарные файлы 13514 байт и sccz80 скомпилированные бинарные файлы 13185 байт. При использовании статических переменных, я сделал sccz80 произвели код лучше. Другие различия связаны с SDCC необходимости IX сохранились и конвенций призвание sccz80 быть гораздо лучше.
Далее ~ 5k может быть сбрил, делая то же рода вещей, которые я сделал в прошлом посте.
Скрытый текст
You can see that you can print to the terminals defined by the crt and you can configure the terminals at runtime via ioctl().
I can see a bug in the terminal code in that attributes are being affected below the text windows. It may be an error in the fonts or in the fzx driver that I will have to look into.
I don't expect anyone to follow this, it's just an indication of the difference between a minimal barely functional library (sdcc) or a simple one reliant on the operating system (hitech) and one that tries to be complete (z88dk).
When comparing code sizes, you also have to keep in mind a compiler like hitech is relying on the operating system to provide functionality. So its binaries may occupy a certain size but it's also making use of operating system code that might be 8k or more in size that is hidden from the output binary. z88dk's binaries are completely independent and can exist apart from any operating system. You do have the option to write drivers that use the system software but we haven't done that yet for the new library.
In the zip you can also compare the asm output generated by sdcc and sccz80 by examing the files "fzx_term2_sdcc.asm" and "fzx_term2_sccz80.opt". In this case the sdcc-compiled binary is 13514 bytes and the sccz80-compiled binary is 13185 bytes. By using static variables, I've made sccz80's produced code better. The other differences have to do with sdcc needing ix preserved and the calling conventions of sccz80 being much better.
A further ~5k can be shaved off by doing the same sorts of things I did in the last post.
[свернуть]