|
@@ -0,0 +1,90 @@
|
|
|
+// Creates the following sample input for y2019d13
|
|
|
+// ####
|
|
|
+// # #
|
|
|
+// # o#
|
|
|
+// #_ #
|
|
|
+// ####
|
|
|
+
|
|
|
+ld 0d95, 0 // general register
|
|
|
+ld 0d96, 0 // general register
|
|
|
+ld 0d97, 0 // general register
|
|
|
+ld 0d98, 0 // general register
|
|
|
+ld 0d99, 0 // jpt, jpf, eq, lt result register
|
|
|
+
|
|
|
+ld 0d100, 0 // cursor y
|
|
|
+ld 0d101, 0 // cursor x
|
|
|
+
|
|
|
+ld 0d102, 5 // max height
|
|
|
+ld 0d103, 4 // max width
|
|
|
+
|
|
|
+ld 0d110, 0 // empty
|
|
|
+ld 0d111, 1 // wall
|
|
|
+ld 0d112, 2 // block
|
|
|
+ld 0d113, 3 // paddle
|
|
|
+ld 0d114, 4 // ball
|
|
|
+
|
|
|
+ld 0d120, 2 // ball y
|
|
|
+ld 0d121, 2 // ball x
|
|
|
+
|
|
|
+ld 0d130, 3 // paddle y
|
|
|
+ld 0d131, 1 // paddle x
|
|
|
+
|
|
|
+// print ceiling
|
|
|
+PrintCeil:
|
|
|
+out 0d101 // output x coord
|
|
|
+out 0d100 // output y coord
|
|
|
+out 0d111 // output wall tile
|
|
|
+add 0d101, 1, 0d101 // add 1 to x coord
|
|
|
+lt 0d101, 0d103, 0d99 // check if x is at boundary
|
|
|
+jpt 0d99, PrintCeil // loop function if not
|
|
|
+
|
|
|
+PrintFloor:
|
|
|
+ld 0d100, 0d102 // load the max height into the height
|
|
|
+ld 0d101, 0 // set the width to 0
|
|
|
+add 0d100, -1, 0d100 // subtract 1 from the height to get it within bounds
|
|
|
+out 0d101 // output the x coord
|
|
|
+out 0d100 // output the y coord
|
|
|
+out 0d111 // output wall tile
|
|
|
+add 0d101, 1, 0d101 // add 1 to the width
|
|
|
+lt 0d101, 0d103, 0d99 // check if x is at the boundary
|
|
|
+jpt 0d99, PrintFloor + 4 // loop function if not
|
|
|
+
|
|
|
+PrintMiddle:
|
|
|
+ld 0d100, 1 // set y to 1
|
|
|
+ld 0d101, 0 // set x to x
|
|
|
+ld 0d95, 0d103 // set reg. a to the max width
|
|
|
+add 0d95, -1, 0d95 // subtract 1 from reg. a
|
|
|
+ld 0d96, 0d102 // set reg. b to max height
|
|
|
+add 0d96, -1, 0d96 // subtract 1 from reg. b
|
|
|
+out 0d101 // output current x
|
|
|
+out 0d100 // output current y
|
|
|
+eq 0d101, 0, 0d99 // Check if x is equal to 0
|
|
|
+jpf 0d99, CURR + 3 // jump ahead 2 if not
|
|
|
+out 0d111 // output a wall tile
|
|
|
+jpt 1, CursorInc // loop function
|
|
|
+eq 0d101, 0d95, 0d99 // check if x is the boundary
|
|
|
+jpf 0d99, CURR + 3 // jump ahead 3 if not
|
|
|
+out 0d111 // output an wall tile
|
|
|
+jpt 1, CursorInc // jump to increment loop
|
|
|
+eq 0d101, 0d121, 0d99 // check if the cursor x matches the ball x
|
|
|
+jpf 0d99, CURR + 5 // skip this section if not
|
|
|
+eq 0d100, 0d120, 0d99 // check if the cursor y matches the ball y
|
|
|
+jpf 0d99, CURR + 3 // skip this section if not
|
|
|
+out 0d114 // if both checks passed, output the ball tile
|
|
|
+jpt 1, CursorInc // jump to cursor increment
|
|
|
+eq 0d101, 0d131, 0d99 // check if the cursor x matches the paddle x
|
|
|
+jpf 0d99, CursorInc // skip this section if not
|
|
|
+eq 0d100, 0d130, 0d99 // check if the cursor y matches the paddle y
|
|
|
+jpf 0d99, CursorInc // skip this section if not
|
|
|
+out 0d113 // if both checks passed, output the paddle tile
|
|
|
+CursorInc:
|
|
|
+add 0d101, 1, 0d101 // add 1 to the x
|
|
|
+eq 0d101, 0d95, 0d99 // compare cursor x max width of the board
|
|
|
+jpf 0d99, CURR + ? // skip this section if not
|
|
|
+ld 0d101, 0 // reset cursor x to 0
|
|
|
+add 0d100, 1, 0d100 // add 1 to the cursor y
|
|
|
+eq 0d100, 0d96, 0d99 // compare cursor y to max height of the board
|
|
|
+jpt 0d99, Halt // if they're equal, the whole board has been printed. exit
|
|
|
+jpf 0d99, PrintMiddle + 7 // else, loop the function
|
|
|
+Halt:
|
|
|
+ext // exit
|