--- title: "UDG Generator" id: 72416 type: "computer_media" slug: "udg-generator" url: "http://localhost/computer_media/udg-generator/" markdown_url: "http://localhost/computer_media/udg-generator.md" published_at: "2026-10-23T07:47:08+00:00" modified_at: "2026-10-23T07:47:08+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/10/udggen-2.png" excerpt: "Draw a graphic on a large grid with the cursor keys and turn it into eight user-defined characters, shown at normal size with their byte values." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "David Elphick" slug: "david-elphick" taxonomy: "indiv" url: "http://localhost/indiv/david-elphick/" genre: - name: "User Defined Graphics" slug: "user-defined-graphics" taxonomy: "genre" url: "http://localhost/type/user-defined-graphics/" media_type: "Program" programmers: - name: "David Elphick" slug: "david-elphick" taxonomy: "indiv" url: "http://localhost/indiv/david-elphick/" download_url: "https://archive.org/download/timex-sinclair-software-archive/UDG%20Generator%20%281983%29%28Elphick%2C%20David%29%28TS2068%29%28US%29%28Program%29.zip" tsrun_member: "UDG Generator (1983)(Elphick, David)(TS2068)(US)(Program)/UDG Generator (1983)(Elphick, David)(TS2068)(US)(Program).tap" mediadate: "1983" images: - url: "http://localhost/wp-content/uploads/2026/10/udggen-2.png" - url: "http://localhost/wp-content/uploads/2026/10/udggen-3.png" - url: "http://localhost/wp-content/uploads/2026/10/udggen-4.png" related_content: - id: 10285 title: "ZX Computing" type: "periodical" url: "http://localhost/periodical/zx-computing/" media_type_tags: "User Defined Graphics" license: false --- # UDG Generator Designs user-defined graphics. The top of the screen is a 32-by-16 grid divided into four 8-by-16 columns, enough for eight UDGs. The cursor keys move a star around it, and CAPS SHIFT with a cursor key plots a block and moves on. Pressing `G` converts the drawing into bytes, POKEs them into UDGs A to H and prints them at normal size, arranged as A C E G over B D F H. You can then go back and change the pattern, list the 64 byte values to copy into your own program, or start again. REMs credit David Elphick and *ZX Computing*, June/July 1983. ## Program Analysis ### Structure - Lines 40–220: the drawing loop. The key code decides the action: codes 8–11 (the CAPS-shifted cursor keys) plot, and codes 53–56 (keys 5–8) only move. - Lines 230–310: build each byte from eight grid cells, weighted 128 down to 1, and `POKE USR "a"+c-1`. - Lines 320–480: the change, list and run-again options, and the normal-size display. ## Notable Techniques - Cursor movement is Boolean arithmetic on the key code, so the plain and shifted cursor keys share the same lines. - The plotted state is kept in `a(16,32)` as well as on screen, and the conversion works only from the array. ## Potential Issues - Line 210 clears the array cell at the cursor after every key, so moving the cursor over a plotted point removes it from the bytes while its block stays on screen. Returning to where you started drawing loses that point. This program came from an Oliger (JLO SAFE) disk, a copy of the SNUG library disk 17/18, and was converted to load from tape. No changes were needed. It was tested in ZEsarUX, drawing a square and listing its codes. ## Source Code ``` 10 REM >> UDG GENERATOR << ZX COMPUTING JUNE/JULY 1983 20 REM Use arrow keys to MOVE and pressCAPS + arrow key to PLOT a POINT 30 REM by David Elphick, Eng. 40 CLS 50 DIM a(16,32): DIM b(64) 60 LET x=0: LET y=X 70 PRINT AT 20,0,,"For normal size graphic, press G" 80 PRINT AT y,x;"*": PLOT 0,111: DRAW 255,0: FOR N=64 TO 192 STEP 64: PLOT N,175: DRAW 0,-126: NEXT N: PRINT AT y,x;" " 90 LET k=CODE INKEY$ 100 IF k=0 THEN GO TO 80 110 IF k>7 AND k<12 THEN PRINT AT y,x;"::": LET a(y+1,x+1)=1 120 IF INKEY$="g" THEN GO TO 230 130 LET x=x+(k=9)-(k=8) 140 LET y=y+(k=10)-(k=11) 150 LET x=x+(k=56)-(k=53) 160 LET y=y+(k=54)-(k=55) 170 IF x=-1 THEN LET x=0 180 IF x=32 THEN LET x=31 190 IF y=-1 THEN LET y=0 200 IF y=16 THEN LET y=15 210 LET a(y+1,x+1)=0 220 GO TO 80 230 FOR m=0 TO 3 240 FOR n=1 TO 16 250 LET c=16*m+n 260 LET d=8*m 270 LET b(c)=a(n,1+d)*128+a(n,2+d)*64+a(n,3+d)*32+a(n,4+d)*16+a(n,5+d)*8+a(n,6+d)*4+a(n,7+d)*2+a(n,8+d) 280 POKE USR "a"+c-1,b(c) 290 NEXT n: NEXT m 310 GO SUB 470 320 PRINT AT 20,0;"Change pattern? Press C. List codes?-L. Run again?-R " 330 IF INKEY$="c" THEN GO TO 70 340 IF INKEY$="l" THEN GO TO 370 350 IF INKEY$="r" THEN RUN 360 GO TO 330 370 CLS 380 PRINT "A: C: E: G:";AT 8,0;"B: D: F: H:" 390 FOR m=0 TO 3 400 FOR n=1 TO 16 410 PRINT AT n-1,2+8*m;b(n+16*m) 420 NEXT n: NEXT m 430 GO SUB 470 440 PRINT AT 21,0;"To re-run, press R" 450 IF INKEY$="r" THEN RUN 460 GO TO 450 470 PRINT AT 17,0;"User graphics ACEG = aceg";AT 18,14;"BDFH bdfh" 480 RETURN ```