Pushing the tool to its limits, gathering a good portion of the functions we have on z88dk.
Here's the extended function set:
Code: Select all
; USR 16514 must be always invoked at the beginning of your program, followed by CLS.
clg = 16514 Init new interrupt handler, clear screen and reset graphics pointers. (0,0) = top-left.
_zx_fast = 16591
_zx_slow = 16597
; graphics commands
_zx_setpos = 17905 x,y
_zx_plot = 16796 x,y
_zx_unplot = 16842 x,y
_zx_xorplot = 16888 x,y
_zx_draw = 16934 +/- x,y (relative coordinate)
_zx_undraw = 16998 +/- x,y (relative coordinate)
_zx_xordraw = 17062 +/- x,y (relative coordinate)
_zx_drawto = 17126 x,y
_zx_undrawto = 17172 x,y
_zx_xordrawto = 17218 x,y
_zx_circle = 17264 x,y,radius
_zx_uncircle = 17320 x,y,radius
_zx_xorcircle = 17376 x,y,radius
_zx_fill = 17432 x,y flood fill starting at the given position
_zx_clga = 17673 clear screen area: x,y,x2,y2
_zx_fillb = 17741 fill screen area x,y,x2,y2
_zx_miniprint = 17480 "text[]" ..MUST have GRAPHICS+SPACE (inverted SPACE) as string terminator
x_4x6 = 21535 x miniprint coordinate (use POKE)
y_4x6 = 21537 y miniprint coordinate (use POKE)
; text/video effects
_zx_invtxt = 17553 inverts the picture in text mode
_zx_mirrortxt = 17568 mirrors the text horizontally (font is not flipped)
_zx_filltxt = 17583 arg: the numeric code of the character used to fill the screen, e.g. CODE "A", or 8
_zx_rollchr = 17615 tweaks the video generator to roll the text display, '0'= normal position
_zx_scrolluptxt = 17643 scroll up
_zx_scrolldowntxt = 17658 scroll down
; turtle graphics
_zx_pen_up = 17809 the next "zx_fwd" will trace a line
_zx_pen_down = 17824 the next "zx_fwd" will move without drawing
_zx_move = 17839 x,y
_zx_set_direction = 17951 clockwise progression, e.g EAST=0, SOUTH=90, WEST=180, NORTH=270
_zx_fwd = 17979 make your turtle walk, n steps
_zx_turn_left = 18007 arg: degrees
_zx_turn_right = 18035 arg: degrees
; picture blitting
_zx_putsprite = 18063 x,y,sprite data: e.g. CHR$ 8 + CHR$ 8 + "AAAAAAAA"
_zx_andsprite = 18120
_zx_xorsprite = 18178
_zx_getsprite = 18235 x,y,sprite data. The sprite data must be pre-initialized with expected size and a default content.
..if you wish to rebuild/personalize the tool, here's the source.
Code: Select all
/*
Example on how to use the ZX specific macros
to extend the Sinclair BASIC.
zcc +zx -m -create-app -pragma-define:CLIB_CONIO_NATIVE_COLOUR=1 -zorg=50000 basiclib.c
zcc +zx81 -m -create-app basiclib.c
*/
#include <stdio.h>
#include <graphics.h>
#include <games.h>
#include <lib3d.h>
//#include <zx81.h>
#ifdef __SPECTRUM__
void zx_ink(int c)
{
ARG_UINT;
ARG_END;
zx_setink(c);
STMT_RET;
}
#endif
void zx_plot(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
plot(x,y);
STMT_RET;
}
void zx_unplot(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
unplot(x,y);
STMT_RET;
}
void zx_xorplot(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
xorplot(x,y);
STMT_RET;
}
void zx_draw(int x, int y)
{
ARG_INT;
ARG_INT;
ARG_END;
drawr(x,y);
STMT_RET;
}
void zx_undraw(int x, int y)
{
ARG_INT;
ARG_INT;
ARG_END;
undrawr(x,y);
STMT_RET;
}
void zx_xordraw(int x, int y)
{
ARG_INT;
ARG_INT;
ARG_END;
xordrawr(x,y);
STMT_RET;
}
void zx_drawto(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
drawto(x,y);
STMT_RET;
}
void zx_undrawto(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
undrawto(x,y);
STMT_RET;
}
void zx_xordrawto(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
xordrawto(x,y);
STMT_RET;
}
void zx_circle(int x, int y, int r)
{
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_END;
circle(x,y,r,1);
STMT_RET;
}
void zx_uncircle(int x, int y, int r)
{
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_END;
uncircle(x,y,r,1);
STMT_RET;
}
void zx_xorcircle(int x, int y, int r)
{
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_END;
xorcircle(x,y,r,1);
STMT_RET;
}
void zx_fill(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
fill(x,y);
STMT_RET;
}
#ifdef __SPECTRUM__
void zx_print(char *t)
{
ARG_STR;
ARG_END;
puts_cons(t);
STMT_RET;
}
int cnt;
void zx_miniprint(char *t)
{
ARG_STR;
ARG_END;
cnt=0;
while (t[cnt]!=0)
putc4x6(t[cnt++]);
STMT_RET;
}
#else
int cnt;
void zx_miniprint(char *t)
{
ARG_PTR;
ARG_END;
cnt=0;
while (t[cnt]!=128) //text end: GRAPHICS+SPACE (inverted blank)
putc4x6(zx_ascii(t[cnt++]));
STMT_RET;
}
#ifdef UDGMODE
zx_text()
{
zx_cls();
STMT_RET;
}
#else
// Invert screen in text mode
zx_invtxt()
{
invtxt();
STMT_RET;
}
// Mirror screen in text mode
zx_mirrortxt()
{
mirrortxt();
STMT_RET;
}
// Fill text screen in text mode with specified character code
// and position text cursor at (0;0)
zx_filltxt(int a)
{
ARG_UINT;
ARG_END;
filltxt(a);
STMT_RET;
}
// Special effect: uses the new interrupts to roll all displayed text characters vertically
// argument: 0..7, where '0' is the 'correct' adjustment
zx_rollchr(int a)
{
ARG_UINT;
ARG_END;
rollchr(a);
STMT_RET;
}
zx_scrolluptxt()
{
scrolluptxt();
STMT_RET;
}
zx_scrolldowntxt()
{
scrolldowntxt();
STMT_RET;
}
void zx_clga(int x1, int y1, int x2, int y2)
{
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_END;
clga(x1,y1,x2,y2);
STMT_RET;
}
void zx_fillb(int x1, int y1, int x2, int y2)
{
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_UINT;
ARG_END;
fillb(x1,y1,x2,y2);
STMT_RET;
}
zx_pen_up()
{
pen_up();
STMT_RET;
}
zx_pen_down()
{
pen_down();
STMT_RET;
}
void zx_move(int x, int y)
{
ARG_INT;
ARG_INT;
ARG_END;
move(x,y);
STMT_RET;
}
void zx_setpos(int x, int y)
{
ARG_UINT;
ARG_UINT;
ARG_END;
setpos(x,y);
STMT_RET;
}
zx_set_direction(int a)
{
ARG_UINT;
ARG_END;
set_direction(a);
STMT_RET;
}
zx_fwd(int a)
{
ARG_UINT;
ARG_END;
fwd(a);
STMT_RET;
}
zx_turn_left(int a)
{
ARG_UINT;
ARG_END;
turn_left(a);
STMT_RET;
}
zx_turn_right(int a)
{
ARG_UINT;
ARG_END;
turn_right(a);
STMT_RET;
}
void zx_putsprite(int x, int y, char *spr)
{
ARG_UINT;
ARG_UINT;
ARG_PTR;
ARG_END;
putsprite(spr_or, x, y, spr);
STMT_RET;
}
void zx_andsprite(int x, int y, char *spr)
{
ARG_UINT;
ARG_UINT;
ARG_PTR;
ARG_END;
putsprite(spr_and, x, y, spr);
STMT_RET;
}
void zx_xorsprite(int x, int y, char *spr)
{
ARG_UINT;
ARG_UINT;
ARG_PTR;
ARG_END;
putsprite(spr_xor, x, y, spr);
STMT_RET;
}
void zx_getsprite(int x, int y, char *spr)
{
ARG_UINT;
ARG_UINT;
ARG_PTR;
ARG_END;
getsprite(x, y, spr);
STMT_RET;
}
#endif
#endif
main()
{
clg();
STMT_RET;
}
Obviously all this stuff was available in the cross-compiler kit, but the possibility to do magic stuff in BASIC is intriguing
Now it is up to your creativity !
..with a single page of code..
- gfx_list.png (13.63 KiB) Viewed 1735 times
..you can get this:
- gfx_run.png (10.26 KiB) Viewed 1735 times