2020-09-20 23:49:36 +02:00
|
|
|
%import floats
|
|
|
|
%import graphics
|
2020-09-22 01:05:07 +02:00
|
|
|
%zeropage floatsafe
|
2020-03-28 14:17:35 +01:00
|
|
|
|
2020-12-22 04:52:46 +01:00
|
|
|
|
2020-03-28 14:17:35 +01:00
|
|
|
main {
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
graphics.enable_bitmap_mode()
|
|
|
|
turtle.init()
|
2023-09-05 19:48:22 +02:00
|
|
|
|
|
|
|
turtle.pu()
|
|
|
|
turtle.pos(150, 110)
|
|
|
|
turtle.pd()
|
2020-03-28 14:17:35 +01:00
|
|
|
|
2020-07-25 22:54:50 +02:00
|
|
|
ubyte i
|
2020-03-28 14:17:35 +01:00
|
|
|
for i in 0 to 100 {
|
|
|
|
turtle.fd(i+20)
|
|
|
|
turtle.rt(94)
|
|
|
|
}
|
|
|
|
|
2020-07-25 16:25:02 +02:00
|
|
|
repeat {
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
turtle {
|
|
|
|
float xpos
|
|
|
|
float ypos
|
|
|
|
float angle
|
2022-07-08 21:50:32 +02:00
|
|
|
bool pendown
|
2020-03-28 14:17:35 +01:00
|
|
|
|
2023-09-08 21:27:38 +02:00
|
|
|
const uword SPRITE_MEMORY = $5800
|
|
|
|
|
2020-03-28 14:17:35 +01:00
|
|
|
sub init() {
|
|
|
|
xpos = 160.0
|
|
|
|
ypos = 100.0
|
|
|
|
angle = 0.0
|
|
|
|
pendown = true
|
|
|
|
|
2023-09-08 21:27:38 +02:00
|
|
|
sys.memcopy(&turtlesprite, SPRITE_MEMORY, len(turtlesprite)) ; copy the sprite pixel data
|
|
|
|
c64.set_sprite_ptr(0, SPRITE_MEMORY) ; use dynamic setter because of changed vic memory layout
|
|
|
|
c64.SPENA = 1 ; sprites on
|
|
|
|
c64.SP0COL = 5 ; green sprite
|
2020-03-28 14:17:35 +01:00
|
|
|
|
2020-07-04 01:02:36 +02:00
|
|
|
update_turtle_sprite()
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
|
2020-07-04 01:02:36 +02:00
|
|
|
sub update_turtle_sprite() {
|
2020-03-28 14:17:35 +01:00
|
|
|
uword xx = xpos as uword
|
|
|
|
c64.SPXY[0] = lsb(xx) + 12
|
2020-07-04 01:02:36 +02:00
|
|
|
c64.MSIGX = msb(xx) > 0
|
2020-11-24 01:09:24 +01:00
|
|
|
c64.SPXY[1] = ypos as ubyte + 40
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
|
2020-07-04 01:02:36 +02:00
|
|
|
sub pos(float x, float y) {
|
|
|
|
if pendown {
|
|
|
|
graphics.line(xpos as uword, ypos as ubyte, x as uword, y as ubyte)
|
|
|
|
}
|
|
|
|
xpos = x
|
|
|
|
ypos = y
|
|
|
|
update_turtle_sprite()
|
|
|
|
}
|
|
|
|
|
2020-03-28 14:17:35 +01:00
|
|
|
sub fd(uword length) {
|
|
|
|
float flen = length as float
|
|
|
|
float sx = xpos
|
|
|
|
float sy = ypos
|
2022-04-22 00:45:54 +02:00
|
|
|
xpos += flen * floats.sin(angle)
|
|
|
|
ypos -= flen * floats.cos(angle)
|
2020-07-04 01:02:36 +02:00
|
|
|
update_turtle_sprite()
|
2020-03-28 14:17:35 +01:00
|
|
|
if pendown {
|
2020-08-21 18:02:01 +02:00
|
|
|
graphics.line(sx as uword, sy as ubyte, xpos as uword, ypos as ubyte)
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub rt(uword degrees) {
|
2022-04-22 00:45:54 +02:00
|
|
|
angle += floats.rad(degrees as float)
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub lt(uword degrees) {
|
2022-04-22 00:45:54 +02:00
|
|
|
angle -= floats.rad(degrees as float)
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub pu() {
|
|
|
|
pendown = false
|
|
|
|
}
|
|
|
|
|
|
|
|
sub pd() {
|
|
|
|
pendown = true
|
|
|
|
}
|
|
|
|
|
2023-09-05 19:48:22 +02:00
|
|
|
ubyte[] turtlesprite = [ %00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%01111110,%00000000,
|
|
|
|
%00000000,%11000011,%00000000,
|
|
|
|
%00000000,%11000011,%00000000,
|
|
|
|
%00000000,%11000011,%00000000,
|
|
|
|
%00000000,%01111110,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000,
|
|
|
|
%00000000,%00000000,%00000000 ]
|
2020-03-28 14:17:35 +01:00
|
|
|
}
|