2022-05-22 15:34:08 +00:00
|
|
|
%import textio
|
2022-06-04 15:18:24 +00:00
|
|
|
%zeropage basicsafe
|
2022-03-13 11:52:12 +00:00
|
|
|
|
2022-05-22 15:34:08 +00:00
|
|
|
|
2022-03-24 23:17:41 +00:00
|
|
|
; NOTE: meant to test to virtual machine output target (use -target vitual)
|
|
|
|
|
2022-05-22 18:22:09 +00:00
|
|
|
main {
|
2022-05-22 15:34:08 +00:00
|
|
|
|
2022-05-22 21:38:46 +00:00
|
|
|
; sub ands(ubyte arg, ubyte b1, ubyte b2, ubyte b3, ubyte b4) -> ubyte {
|
|
|
|
; return arg>b1 and arg>b2 and arg>b3 and arg>b4
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; sub ors(ubyte arg, ubyte b1, ubyte b2, ubyte b3, ubyte b4) -> ubyte {
|
|
|
|
; return arg==b1 or arg==b2 or arg==b3 or arg==b4
|
|
|
|
; }
|
2022-05-22 21:11:22 +00:00
|
|
|
|
2022-05-22 21:38:46 +00:00
|
|
|
; sub mcCarthy() {
|
|
|
|
; ubyte @shared a
|
|
|
|
; ubyte @shared b
|
|
|
|
;
|
|
|
|
; txt.print_ub(ands(10, 2,3,4,5))
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(ands(10, 20,3,4,5))
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(ors(10, 2,3,40,5))
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(ors(10, 1,10,40,5))
|
|
|
|
; txt.spc()
|
|
|
|
; }
|
2022-05-22 15:34:08 +00:00
|
|
|
|
2022-05-17 16:53:18 +00:00
|
|
|
sub start() {
|
2022-05-22 21:38:46 +00:00
|
|
|
; mcCarthy()
|
|
|
|
|
2022-06-03 21:13:35 +00:00
|
|
|
ubyte value = 0
|
|
|
|
ubyte size = 9
|
|
|
|
ubyte[10] data = [11,22,33,4,5,6,7,8,9,10]
|
|
|
|
uword bitmapbuf = &data
|
2022-06-04 13:05:01 +00:00
|
|
|
value = bitmapbuf[2]
|
|
|
|
txt.print_ub(value) ;; 33
|
|
|
|
txt.nl()
|
2022-05-24 16:26:07 +00:00
|
|
|
|
2022-06-03 21:13:35 +00:00
|
|
|
; ; 11 22 33
|
|
|
|
; txt.print_ub(bitmapbuf[0])
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(bitmapbuf[1])
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(bitmapbuf[2])
|
|
|
|
; txt.nl()
|
|
|
|
; rol(bitmapbuf[0])
|
|
|
|
; rol(bitmapbuf[0])
|
|
|
|
; txt.print_ub(bitmapbuf[0]) ; 44
|
|
|
|
; txt.spc()
|
|
|
|
; ror(bitmapbuf[0])
|
|
|
|
; ror(bitmapbuf[0])
|
|
|
|
; txt.print_ub(bitmapbuf[0]) ; 11
|
|
|
|
; txt.nl()
|
|
|
|
;
|
|
|
|
; ; 22 44 66
|
|
|
|
; txt.print_ub(bitmapbuf[0]*2)
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(bitmapbuf[1]*2)
|
|
|
|
; txt.spc()
|
|
|
|
; txt.print_ub(bitmapbuf[2]*2)
|
|
|
|
; txt.nl()
|
|
|
|
|
|
|
|
ubyte one = 1
|
|
|
|
|
|
|
|
bitmapbuf[0] = one
|
|
|
|
bitmapbuf[1] = one+one
|
|
|
|
bitmapbuf[2] = one+one+one
|
|
|
|
bitmapbuf[2] += 4
|
|
|
|
bitmapbuf[2] -= 2
|
|
|
|
bitmapbuf[2] -= 2
|
|
|
|
swap(bitmapbuf[0], bitmapbuf[1])
|
|
|
|
|
|
|
|
; 1 2 3
|
|
|
|
txt.print_ub(bitmapbuf[0])
|
|
|
|
txt.spc()
|
|
|
|
txt.print_ub(bitmapbuf[1])
|
|
|
|
txt.spc()
|
|
|
|
txt.print_ub(bitmapbuf[2])
|
|
|
|
txt.nl()
|
|
|
|
|
|
|
|
for value in data {
|
|
|
|
txt.print_ub(value)
|
2022-05-23 19:01:02 +00:00
|
|
|
txt.spc()
|
|
|
|
}
|
2022-05-23 18:10:37 +00:00
|
|
|
txt.nl()
|
2022-05-22 15:34:08 +00:00
|
|
|
|
2022-06-03 21:13:35 +00:00
|
|
|
; TODO why is this loop much larger in code than the one below.
|
|
|
|
value = 0
|
|
|
|
ubyte xx
|
|
|
|
for xx in 0 to size-1 {
|
|
|
|
value += bitmapbuf[xx]
|
|
|
|
}
|
|
|
|
txt.print_ub(value) ; 45
|
|
|
|
txt.nl()
|
|
|
|
|
|
|
|
; TODO this one is much more compact
|
|
|
|
value = 0
|
|
|
|
uword srcptr = bitmapbuf
|
|
|
|
repeat size {
|
|
|
|
value += @(srcptr)
|
|
|
|
srcptr++
|
|
|
|
}
|
|
|
|
txt.print_ub(value) ; 45
|
|
|
|
txt.nl()
|
|
|
|
|
2022-05-22 15:34:08 +00:00
|
|
|
; ; a "pixelshader":
|
2022-05-23 18:10:37 +00:00
|
|
|
; sys.gfx_enable(0) ; enable lo res screen
|
|
|
|
; ubyte shifter
|
|
|
|
;
|
|
|
|
; repeat {
|
|
|
|
; uword xx
|
|
|
|
; uword yy = 0
|
|
|
|
; repeat 240 {
|
|
|
|
; xx = 0
|
|
|
|
; repeat 320 {
|
|
|
|
; sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
|
|
|
; xx++
|
|
|
|
; }
|
|
|
|
; yy++
|
|
|
|
; }
|
|
|
|
; shifter+=4
|
|
|
|
; }
|
2022-03-04 21:26:46 +00:00
|
|
|
}
|
2022-02-17 23:40:31 +00:00
|
|
|
}
|