2021-11-09 22:36:47 +00:00
|
|
|
%import graphics
|
2022-04-12 21:58:19 +00:00
|
|
|
%import math
|
2023-09-05 17:48:22 +00:00
|
|
|
%import textio
|
|
|
|
%zeropage basicsafe
|
2022-04-12 21:58:19 +00:00
|
|
|
|
|
|
|
; Draw sine and cosine graphs. The sine and cosine functions are table lookups
|
|
|
|
; where the tables are generated by 64tass list functions.
|
2021-11-09 22:36:47 +00:00
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
; This uses the graphics library which works on multiple targets (C64, CX16)
|
2021-11-09 22:36:47 +00:00
|
|
|
|
|
|
|
main {
|
|
|
|
const uword width = 320
|
|
|
|
const ubyte height = 200
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
graphics.enable_bitmap_mode()
|
|
|
|
|
|
|
|
sincos255()
|
2023-09-05 17:48:22 +00:00
|
|
|
sys.wait(60)
|
2021-11-09 22:36:47 +00:00
|
|
|
|
|
|
|
graphics.clear_screen(1, 0)
|
|
|
|
|
|
|
|
sincos180()
|
2023-09-05 17:48:22 +00:00
|
|
|
sys.wait(60)
|
2021-11-09 22:36:47 +00:00
|
|
|
|
|
|
|
graphics.clear_screen(1, 0)
|
|
|
|
circles()
|
2023-09-05 17:48:22 +00:00
|
|
|
sys.wait(60)
|
2021-11-09 22:36:47 +00:00
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
graphics.disable_bitmap_mode()
|
|
|
|
txt.print("done\n")
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub sincos255() {
|
|
|
|
graphics.line(256,0,256,height-1)
|
|
|
|
|
|
|
|
ubyte pixelyb
|
|
|
|
ubyte pixelxb
|
2022-09-22 10:42:17 +00:00
|
|
|
byte pixelys
|
2021-11-09 22:36:47 +00:00
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
; unsigned
|
2021-11-09 22:36:47 +00:00
|
|
|
for pixelxb in 0 to 255 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.cos8u(pixelxb) / 2
|
2022-09-22 10:42:17 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb+20)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.sin8u(pixelxb) / 2
|
2022-09-22 10:42:17 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb+20)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
; signed
|
2021-11-09 22:36:47 +00:00
|
|
|
for pixelxb in 0 to 255 {
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelys = math.cos8(pixelxb) / 2
|
2023-09-05 17:48:22 +00:00
|
|
|
graphics.plot(pixelxb, pixelys as ubyte + 90)
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelys = math.sin8(pixelxb) / 2
|
2023-09-05 17:48:22 +00:00
|
|
|
graphics.plot(pixelxb, pixelys as ubyte + 90)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sincos180() {
|
|
|
|
graphics.line(180,0,180,height-1)
|
|
|
|
|
|
|
|
ubyte pixelyb
|
|
|
|
ubyte pixelxb
|
2022-09-22 10:42:17 +00:00
|
|
|
byte pixelys
|
2021-11-09 22:36:47 +00:00
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
; signed
|
2021-11-09 22:36:47 +00:00
|
|
|
for pixelxb in 0 to 179 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.cosr8u(pixelxb) / 2
|
2022-09-22 10:42:17 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb+20)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.sinr8u(pixelxb) / 2
|
2022-09-22 10:42:17 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb+20)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
|
2023-09-05 17:48:22 +00:00
|
|
|
; unsigned
|
2021-11-09 22:36:47 +00:00
|
|
|
for pixelxb in 0 to 179 {
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelys = math.cosr8(pixelxb) / 2
|
2023-09-05 17:48:22 +00:00
|
|
|
graphics.plot(pixelxb, pixelys as ubyte + 90)
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelys = math.sinr8(pixelxb) / 2
|
2023-09-05 17:48:22 +00:00
|
|
|
graphics.plot(pixelxb, pixelys as ubyte + 90)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub circles() {
|
|
|
|
ubyte pixelyb
|
|
|
|
uword pixelxw
|
|
|
|
ubyte r
|
|
|
|
|
2022-09-22 10:42:17 +00:00
|
|
|
; circle with "degrees" from 0 to 255
|
2021-11-09 22:36:47 +00:00
|
|
|
for r in 0 to 255 {
|
2023-03-18 13:42:15 +00:00
|
|
|
pixelxw = (math.sin8(r)/2 as word) + 80 as uword
|
2022-09-22 13:49:19 +00:00
|
|
|
pixelyb = (math.cos8(r)/2 as uword + height/2) as ubyte
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxw, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
for r in 0 to 255 {
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelxw = math.sin8u(r)/2
|
|
|
|
pixelyb = math.cos8u(r)/2
|
|
|
|
graphics.plot(pixelxw + 16, pixelyb+50)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
|
2022-09-22 10:42:17 +00:00
|
|
|
; circle with half-degrees from 0 to 179 (=full degrees 0..358 with steps of 2 degrees)
|
2021-11-09 22:36:47 +00:00
|
|
|
for r in 0 to 179 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelxw = (math.sinr8(r) as word /2 + 220) as uword
|
|
|
|
pixelyb = (math.cosr8(r)/2 + height/2) as ubyte
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxw, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
for r in 0 to 179 {
|
2022-09-22 10:42:17 +00:00
|
|
|
pixelxw = math.sinr8u(r)/2
|
|
|
|
pixelyb = math.cosr8u(r)/2
|
|
|
|
graphics.plot(pixelxw + 156, pixelyb+50)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|