mirror of
https://github.com/irmen/prog8.git
synced 2024-10-07 15:57:03 +00:00
70 lines
1.6 KiB
Lua
70 lines
1.6 KiB
Lua
%import textio
|
|
;%import test_stack
|
|
%zeropage basicsafe
|
|
|
|
; NOTE: meant to test to virtual machine output target (use -target vitual)
|
|
|
|
main {
|
|
|
|
; 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
|
|
; }
|
|
|
|
; 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()
|
|
; }
|
|
|
|
|
|
sub func1(ubyte a1, ubyte a2) -> ubyte {
|
|
return a1+a2+42
|
|
}
|
|
|
|
sub func2(ubyte a1, ubyte a2) -> ubyte {
|
|
return 200-a1-a2
|
|
}
|
|
|
|
sub start() {
|
|
; mcCarthy()
|
|
|
|
; 9+10+42 = 61
|
|
; 200-61-2 = 137
|
|
; ubyte result = 9 |> func1(10) |> func2(2)
|
|
; $090a $0a02
|
|
uword resultw = 9 |> mkword(10) |> lsb() |> mkword(2)
|
|
txt.print_uw(resultw)
|
|
txt.nl()
|
|
|
|
; a "pixelshader":
|
|
; 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
|
|
; }
|
|
}
|
|
}
|