News:

Welcome to RetroCoders Community

Main Menu

Just a tiny fun bit of code

Started by CharlieJV, Jun 15, 2023, 02:09 AM

Previous topic - Next topic

CharlieJV

Give it a spin in BAM or in your goto BASIC implementation:

(from page 422, Handbook of BASIC: for the IBM PC, XT, AT, PS/2, and compatibles)

SCREEN 0
PRINT "ABCDEFG"
FOR J = 0 TO 7
LOCATE 2 + J, 1
FOR K = 0 TO 55
IF POINT(K,J) = 0 THEN PRINT " "; ELSE PRINT "*";
NEXT K
PRINT
NEXT J

You cannot view this attachment.

johnno56

Cool... Thanks for sharing...
May your journey be free of incident.  Live long and prosper.

CharlieJV

In that book, just a page or two later, similar code is used to rotate the letters.


ZXDunny

Ok, I'm gonna add another cool one that's related to this. The ZX Spectrum, way back in like '82 or so, had a bit of an odd character set - it had block graphics inside it at positions 128 onwards in the ASCII set. I added them to SpecBAS as you can see here:



In SpecBAS, all characters can be redefined, but those from 128 onwards are classed as UDGs (User Definable Graphics) like the original machine. Now the great thing about those block graphics is that they're stored in a logical sequence that follows a bit pattern so...

I can do this:

10 REM 4x4 Pixel magnifier
20 PAPER 0: INK 6: CLS
30 INPUT "Characters to render: ";a$
50 PRINT AT 0,0; INK 1;a$
60 FOR x=0 TO LEN (a$)*8-1 STEP 2
70    FOR y=0 TO 8 STEP 2
90      PRINT AT 16+y/2,x/2;CHR$ (128+8*POINT(x,y+1)+4*POINT(x+1,y+1)+2*POINT(x,y)+POINT(x+1,y))
100    NEXT y
110 NEXT x
120 WAIT KEYDOWN
130 GO TO 20

As with yours, it reads the pixels in clumps of 2x2, and makes a block character from them by combining their bit values (1, 2, 4 and 8). It gives this:



Which I think is quite neat :)

CharlieJV

Quote from: ZXDunny on Jun 15, 2023, 01:57 PMOk, I'm gonna add another cool one that's related to this. The ZX Spectrum, way back in like '82 or so, had a bit of an odd character set - it had block graphics inside it at positions 128 onwards in the ASCII set. I added them to SpecBAS as you can see here:



In SpecBAS, all characters can be redefined, but those from 128 onwards are classed as UDGs (User Definable Graphics) like the original machine. Now the great thing about those block graphics is that they're stored in a logical sequence that follows a bit pattern so...

I can do this:

10 REM 4x4 Pixel magnifier
20 PAPER 0: INK 6: CLS
30 INPUT "Characters to render: ";a$
50 PRINT AT 0,0; INK 1;a$
60 FOR x=0 TO LEN (a$)*8-1 STEP 2
70    FOR y=0 TO 8 STEP 2
90      PRINT AT 16+y/2,x/2;CHR$ (128+8*POINT(x,y+1)+4*POINT(x+1,y+1)+2*POINT(x,y)+POINT(x+1,y))
100    NEXT y
110 NEXT x
120 WAIT KEYDOWN
130 GO TO 20

As with yours, it reads the pixels in clumps of 2x2, and makes a block character from them by combining their bit values (1, 2, 4 and 8). It gives this:



Which I think is quite neat :)

That is very neat!