
Сообщение от
andrews
желателен простой пример с окружностью и/или Helloword.
пример Helloworld есть на Github
Код:
// compile with
// java -jar millfork.jar -I ${PATH}/include -t ${platform} ${PATH}/examples/hello_world/hello_world.mfk
import stdio
array hello_world = "Hello world"
void main() {
ensure_mixedcase()
#if CBM_64 || CBM_264
set_bg_color(white)
#endif
#if CBM_64 || CBM_264 || ZX_SPECTRUM
set_border(red)
#endif
putstr(hello_world, hello_world.length)
new_line()
putstrz("Hello world again"z)
#if not(CPM)
while(true){}
#endif
}
Окружность по Брезенхему написана, но есть один нюанс, пока выясняется
Код:
//Bresenham circle
//http://members.chello.at/easyfilter/bresenham.html
array(word) sa[192]
array(byte) bw = [$80,$40,$20,$10,8,4,2,1]
pointer sd
asm word call_22b0(byte a,byte c) @ $22b0 extern
void pp(ubyte x0,ubyte y0)
{
sd=sa[y0]+(x0>>3)
sd[0] |= bw[x0&7]
}
void inits()
{
ubyte i
for i,0,to,191
{
sa[word(i)]=call_22b0(i,0)
}
}
void cls()
{
asm
{
// xor a
// ld b,$18
// call 3652
ld hl,$4000
ld de,$4001
ld bc,6144
ld (hl),l
ldir
ld (hl),$38
ld bc,767
ldir
}
}
void circle(ubyte xm,ubyte ym,ubyte r)
{
sbyte x,y
unsigned16 err,rr
x=0-r// error with x=-r
y=0
err=2-r-r//2-2*r
do
{
pp(xm-x,ym+y)
pp(xm-y,ym-x)
pp(xm+x,ym-y)
pp(xm+y,ym+x)
rr=err
if (rr<=y) {
y=y+1
err=err+y+y+1//err+y*2+1
}
if (rr>x || err>y) {
x=x+1
err=err+x+x+1//err+x*2+1
}
} while (x<0)
}
void main() {
inits()//precalc screen lines adresses
cls()
circle(128,96,80)
while true {}
}