Printing standard UDGs to screen

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
redballoon
Manic Miner
Posts: 390
Joined: Sun Nov 12, 2017 3:54 pm

Printing standard UDGs to screen

Post by redballoon »

Hello

How easy is it to print out the standard Spectrum UDGs in BASIC?
Image

It'd display a picture, say a logo, made up of the the UDGs (on the bottom line, above) and using DATA commands to control the UDGs.

Thanks.
User avatar
PeterJ
Site Admin
Posts: 6873
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: Printing standard UDGs to screen

Post by PeterJ »

Morning [mention]redballoon[/mention],

Assuming that you are referring to the 21 User Defined Graphics, it's easy. Please see this link to an example. Feel free to ask any questions.

viewtopic.php?p=48001#p48001

Edit. Just read your post again, to print those bottom characters just go into graphics mode, and print them as you normally would in a print statement.

Image

You can also do print chr$(Number). You could store the numbers to print your artwork in an array and loop through it.

Sorry if I have the wrong end of the stick!
hikoki
Manic Miner
Posts: 576
Joined: Thu Nov 16, 2017 10:54 am

Re: Printing standard UDGs to screen

Post by hikoki »

Do you mean an ascii art editor like playascii or rexpaint?
I begun a basic program which is meant to use kempston mouse from Basinc.

10 PRINT a$ : REM a$=one single string containing your asciiart made up of chr$ and custom font
redballoon
Manic Miner
Posts: 390
Joined: Sun Nov 12, 2017 3:54 pm

Re: Printing standard UDGs to screen

Post by redballoon »

PeterJ wrote: Tue Oct 13, 2020 8:36 am Morning [mention]redballoon[/mention],

Assuming that you are referring to the 21 User Defined Graphics, it's easy. Please see this link to an example. Feel free to ask any questions.

viewtopic.php?p=48001#p48001

Edit. Just read your post again, to print those bottom characters just go into graphics mode, and print them as you normally would in a print statement.

You can also do print chr$(Number). You could store the numbers to print your artwork in an array and loop through it.

Sorry if I have the wrong end of the stick!
Yeah, I think that's what I'm looking for.
Here's an example.
Image

The type-in is like an Easter egg in that you've got this ZX basic and that above image is made up from the DATA, so you've no idea what you'll see until you type RUN. Obvs, the real image i'd like created is not the above example.
User avatar
Joefish
Rick Dangerous
Posts: 2058
Joined: Tue Nov 14, 2017 10:26 am

Re: Printing standard UDGs to screen

Post by Joefish »

Yep, those aren't 'UDGs'', they're just fixed graphics characters. The UDGs are the ones you can redefine.

On a real Spectrum (or in an emulator), just start your PRINT AT Y , X ; " statement then press CAPS SHIFT+9 for 'Graphics Mode' (the cursor turns into a flashing G) then press the number keys 1..8 for the graphics blocks marked on those keys, or SHIFT+1..8 for the opposite versions. Note that the empty graphics block on key 8 is a different character code to a SPACE. You can also type A..U in Graphics Mode to get one of the 21 redefinable UDGs. press CAPS SHIFT+9 to go back to normal typing mode to finish off your PRINT statement with another ".

To do a coloured graphic like the one you've shown though, you'll have to change the PAPER colour every few characters.

(Actually, I think the number keys are marked wrong; they look like they show the opposite graphics character you only get with SHIFT).
hikoki
Manic Miner
Posts: 576
Joined: Thu Nov 16, 2017 10:54 am

Re: Printing standard UDGs to screen

Post by hikoki »

The Mojon Twins made a tool for that called BLOCKYGRAPHS
Take a look at this tutorial https://arcadespain.info/Foro/index.php?topic=7180.0
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Re: Printing standard UDGs to screen

Post by MonkZy »

Code: Select all

10 READ row,col,ink,paper
20 PRINT AT row,col;
30 INK ink: PAPER paper
30 READ a
40 IF a=0 THEN GO TO 10
50 IF a=1 THEN STOP
60 PRINT CHR$ a;
70 GO TO 30
80 DATA 6,6,2,7,139,135,0
90 DATA 7,6,2,7,142,141,1
This listing will print a red square from the standard symbols. Each data line has the column and row integers as the first two numbers. The next two numbers are the INK and PAPER, followed by each symbol you want printed. The data line is terminated with a 0 to read another data line (move the cursor and change ink/paper) or a 1 to end the program with an abrupt STOP statement.
redballoon
Manic Miner
Posts: 390
Joined: Sun Nov 12, 2017 3:54 pm

Re: Printing standard UDGs to screen

Post by redballoon »

Thanks [mention]MonkZy[/mention] that looks just what I’m look for! Il give that a try later and let you know how I got in! Thanks again.
Post Reply