2021-11-09 22:36:47 +00:00
|
|
|
%import graphics
|
2022-04-12 21:58:19 +00:00
|
|
|
%import math
|
|
|
|
|
|
|
|
; 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
|
|
|
|
|
|
|
; Note: this program is compatible with CX16 only.
|
|
|
|
; it doesn't work correctly on C64 because the bitmap screen data overlaps
|
|
|
|
; the program itself in memory $2000-...
|
|
|
|
|
|
|
|
|
|
|
|
main {
|
|
|
|
const uword width = 320
|
|
|
|
const ubyte height = 200
|
|
|
|
|
|
|
|
sub start() {
|
|
|
|
graphics.enable_bitmap_mode()
|
|
|
|
|
|
|
|
sincos255()
|
|
|
|
sys.wait(120)
|
|
|
|
|
|
|
|
graphics.clear_screen(1, 0)
|
|
|
|
|
|
|
|
sincos180()
|
|
|
|
sys.wait(120)
|
|
|
|
|
|
|
|
graphics.clear_screen(1, 0)
|
|
|
|
circles()
|
|
|
|
|
|
|
|
repeat {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sincos255() {
|
|
|
|
graphics.line(256,0,256,height-1)
|
|
|
|
|
|
|
|
ubyte pixelyb
|
|
|
|
uword pixelyw
|
|
|
|
ubyte pixelxb
|
|
|
|
|
|
|
|
for pixelxb in 0 to 255 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.cos8u(pixelxb) / 2
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.sin8u(pixelxb) / 2
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
for pixelxb in 0 to 255 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyw = math.cos16u(pixelxb) / 1024 + 120
|
2022-01-27 17:05:25 +00:00
|
|
|
graphics.plot(pixelxb, pixelyw)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyw = math.sin16u(pixelxb) / 1024 + 120
|
2022-01-27 17:05:25 +00:00
|
|
|
graphics.plot(pixelxb, pixelyw)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sincos180() {
|
|
|
|
graphics.line(180,0,180,height-1)
|
|
|
|
|
|
|
|
ubyte pixelyb
|
|
|
|
uword pixelyw
|
|
|
|
ubyte pixelxb
|
|
|
|
|
|
|
|
for pixelxb in 0 to 179 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.cosr8u(pixelxb) / 2
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyb = math.sinr8u(pixelxb) / 2
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxb, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
for pixelxb in 0 to 179 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyw = math.cosr16u(pixelxb) / 1024 + 120
|
2022-01-27 17:05:25 +00:00
|
|
|
graphics.plot(pixelxb, pixelyw)
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelyw = math.sinr16u(pixelxb) / 1024 + 120
|
2022-01-27 17:05:25 +00:00
|
|
|
graphics.plot(pixelxb, pixelyw)
|
2021-11-09 22:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub circles() {
|
|
|
|
ubyte pixelyb
|
|
|
|
uword pixelxw
|
|
|
|
ubyte r
|
|
|
|
|
|
|
|
; circles with "degrees" from 0 to 255
|
|
|
|
for r in 0 to 255 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelxw = ((math.sin8(r)/2 as word) + 80) as uword
|
|
|
|
pixelyb = (math.cos8(r)/2 + height/2) as ubyte
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxw, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
for r in 0 to 255 {
|
2022-04-12 21:58:19 +00:00
|
|
|
pixelxw = (math.sin16(r)/1024 + 80) as uword
|
|
|
|
pixelyb = (math.cos16(r)/1024 + height/2) as ubyte
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxw, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
; circles with half-degrees from 0 to 179 (=full degrees 0..358 with steps of 2 degrees)
|
|
|
|
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-04-12 21:58:19 +00:00
|
|
|
pixelxw = (math.sinr16(r) as word /1024 + 220) as uword
|
|
|
|
pixelyb = (math.cosr16(r)/1024 + height/2) as ubyte
|
2021-11-09 22:36:47 +00:00
|
|
|
graphics.plot(pixelxw, pixelyb)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|