[ Etch-O-Sketch - a drawing program for the Edsac. You can draw a picture on long tank by moving a 'cursor' horizontally, vertically or diagonally. The cursor is moved by dialling numbers on the rotary dial. The screen can also be cleared if you decide that your creation isn't as artistically perfect as you had hoped. ] T 56K [M3] PFGKIFAFRDLFUFOFE@A6FG@E8FEZPF *&&!!!!!!!!!!!ETCH#A*O#A*SKETCH&& !!!!!!!BY!CHRIS!JENKINS#N!WPPQ*&& !!!!!!!!SELECT!LONG!TANK!#P*&& DIAL!THESE!NUMBERS!TO!MOVE& # !7!8!9!& !4!!!6!!!T*!TO!CLEAR!THE!SCREEN#& !1!2!3!& ..PK T 56K [ PLOT_POINT. This subroutine plots a point on long tank 0. The coordinate origin is located at the bottom right hand corner of the tank, with the y axis pointing upwards and the x axis pointing to the left. The X coordinate is placed in location L + 50 and the Y coordinate in L + 51, where L is the location into which PLOT_POINT is loaded. ] GK [ set @ parameter ] T 47K [ set M parameter - local variables and parameters live here ] P 50@ TZ [ 0 ] A 16M [ plant return link ] T 44@ [ 2 ] XF [ first, shift the pattern by x steps to get the right bit pattern to draw onto the screen ] [ 3 ] T 10#M [ pattern = INITIAL_PATTERN ] A 8#M T 2#M XF [ 7 ] A 0M [ i = x - 1 ] S 8M U 4M XF [ if i = 0 then don't execute the loop body at all ] G 20@ [ loop ] [ 12 ] T 10#M A 2#M [ left shift pattern by one ] L 0D T 2#M [ 16 ] A 4M [ decrement i ] S 8M U 4M [ 19 ] E 12@ [ loop while i is not -ve ] [ 20 ] XF [ now, check if there is already a point in the place that we want to draw to ] [ if there is one, then we don't need to draw another one ] [ 21 ] T 10#M [ take the inital SMC instruction opcode and add y*4 to it ] A 1M L 1F [ acc = y*4 ] U 15M A 12M T 27@ [ 27 ] H 0D [ SMC point 1 - masked_target = the target memory ANDed with pattern ] C 2#M U 6#M [ 30 ] G 43@ [ if masked_target is -ve then we don't need to do anything, so jump to the ] [ end of the subroutine ] [ 31 ] S 8#M [ if masked_target > 0 then jump to the end of the subroutine ] E 43@ [ now draw the pattern onto long tank 0 by adding pattern onto the appropriate memory [ location ] [ 33 ] T 10#M [ take SMC point 2 and add y*4 to its inital value ] A 15M A 13M T 40@ [ 37 ] A 15M [ take SMC point 3 and add y*4 to its initial value ] A 14M T 42@ [ 40 ] [ target = target + pattern ] A 0D [ SMC point 2 ] A 2#M [ 42 ] T 0D [ SMC point 3 ] [ 43 ] T 10#M [ clear the accumulator so that we jump back to the caller ] EF XF [ padding ] XF XF XF XF [ 50 ] [ M ] [00] P 0F [ x - the caller should set this ] [01] P 0F [ y - the caller should set this ] [02] P 0F [ pattern (long int) - variable used to manaipulate the pattern that will ] [03] P 0F [ be added to the screen ] [04] P 0F [ i - used as a counter ] [05] P 0F [ filler ] [06] P 0F [ masked_target (long int ) - used to store the result of masking off all bits ] [07] P 0F [ other than the one that we are about to set to see if that bit is already set] [08] P 0D [ INITIAL_PATTERN (long int constant) = 1. This pattern is left-shifted to ] [09] P 0F [ get the pattern that we draw onto long tank 0 ] [10] P 0F [ two words to clear the acc into when we want to clear it ] [11] P 0F [12] H 0D [ the inital value of SMC point 1 ] [13] A 0D [ the inital value of SMC point 2 ] [14] T 0D [ the inital value of SMC point 3 ] [15] P 0F [ y*4 kept here ] [16] U 2F [ to help in planting return link ] ..PZ T 128K [ CLS - clear long tank 0 ] GK [ 0 ] A 19@ [ plant return link ] [ 1 ] T 18@ [ 2 ] T D [ 3 ] T 2D [ 4 ] T 4D [ 5 ] T 6D [ 6 ] T 8D [ 7 ] T 10D [ 8 ] T 12D [ 9 ] T 14D [ 10 ] T 16D [ 11 ] T 18D [ 12 ] T 20D [ 13 ] T 22D [ 14 ] T 24D [ 15 ] T 26D [ 16 ] T 28D [ 17 ] T 30D [ 18 ] E F [ return link ] [ 19 ] U 2F [ constant to help planting return link thang ] ..PZ T 160K [ master routine ] GK T 47K [ set M parameter ] P 119@ TZ T 45K [ set H parameter - this points to PLOT_POINT ] P 56F TZ [ 0 ] XF [ 1 ] A 1@ [ clear long tank 0 using CLS ] G 128F [ main_loop ] [ 3 ] T 2M [ clear acc ] [ 4 ] A 0M [ plot a point at (x, y) ] T 50H A 1M T 51H [ 8 ] A 8@ G 0H [ 10 ] T 2M [ clear acc and wait for input ] ZF U 3M [ store the input ] XF R 0D [ divide by two to get the value entered ] S 4M G 10@ [ input = 0 => no user input so re-read the input ] S 4M G 37@ [ input = 1 => move down and to the left ] S 4M G 45@ [ input = 2 => move down ] S 4M G 50@ [ input = 3 => move down and to the right ] S 4M G 58@ [ input = 4 => move left ] S 4M G 63@ [ input = 5 => clear screen ] S 4M G 67@ [ input = 6 => move right ] S 4M G 72@ [ input = 7 => move up and left] S 4M G 80@ [ input = 8 => move up ] S 4M G 85@ [ input = 9 => move up and to the right ] S 4M G 10@ [ input = 10 => user pressed 0, which isn't allowed => re-enter input ] [ 37 ] T 2M [ move down and to the left ] A 0M [ increment x (remember, the x axis points to the left) ] A 4M T 0M A 1M [ decerement y ] S 4M T 1M E 93@ [ break out of this block ] [ 45 ] T 2M [ move down ] A 1M [ decerement y ] S 4M T 1M E 93@ [ break ] [ 50 ] T 2M [ move down and to the right ] A 0M [ decrement x ] S 4M T 0M A 1M [ decrement y ] S 4M T 1M E 93@ [ break ] [ 58 ] T 2M [ move to the left ] A 0M [ increment x (remember, the x axis points to the left) ] A 4M T 0M E 93@ [ break ] [ 63 ] T 2M [ clear the screen ] [ 64 ] A 64@ [ clear long tank 0 using CLS ] G 128F E 93@ [ break ] [ 67 ] T 2M [ move to the right ] A 0M [ decrement x ] S 4M T 0M E 93@ [ break ] [ 72 ] T 2M [ move up and to the left ] A 0M [ increment x (remember, the x axis points to the left) ] A 4M T 0M A 1M [ incremement y ] A 4M T 1M E 93@ [ break ] [ 80 ] T 2M [ move up ] A 1M [ incremement y ] A 4M T 1M E 93@ [ break ] [ 85 ] T 2M [ move up and to the right ] A 0M [ decrement x ] S 4M T 0M A 1M [ incremement y ] A 4M T 1M E 93@ [ break ] [ check that x and y are still within the bounds of our 'screen' ] [ 93 ] T 2M [ if x >= 35 then x = 34 ] A 0M S 5M G 100@ T 2M A 7M T 0M [ 100 ] T 2M [ if x < 0 then x = 0 ] A 0M E 105@ T 2M T 0M [ 105 ] T 2M [ if y >= 16 then y = 15 ] A 1M S 6M G 112@ T 2M A 8M T 1M [ 112 ] T 2M [ if y < 0 then y = 0 ] A 1M E 117@ T 2M T 1M [ 117 ] [ loop to main_loop ] T 2M E 3@ [ 119 ] [ M ] [00] P 8F [ x = 16 ] [01] P 4F [ y = 8 ] [02] P 0F [ dump accumulator here ] [03] P 0F [ user input stored here ] [04] P 0D [ =1 ] [05] P 17D [ =35 ] [06] P 8F [ =16 ] [07] P 17F [ =34 ] [08] P 7D [ =15 ] EZPF