Stipple ATTR Art Tool

Show us what you're working on, (preferably with screenshots).
Post Reply
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Stipple ATTR Art Tool

Post by uglifruit »

Presenting: Stipple ATTR Art Tool

Image

...It is a *very* specific BASIC program I've written (with a handful of m/c routines to throw stuff around the memory). I thought I'd like to do something where I was just drawing with the ATTRibutes, in a 32x24 grid, but each cell being a checkerboard, so - at a distance - there'd be blending of the colours. (very much inspired by the art in Bob's SplATTR).


Anyway, I got a bit TOO into it, and rather than making a simple tool, I've ended up making a full-on BASIC and m/c editor for this kind of picture. I'm not sure what my end game is here, but this tool allows drawing and storing of 10 pics in memory (there's still loads of memory spare, if needed, and it'd be a simple hack to change this).

It has full instructions included, but briefly it's Q,A,O,P to move the cursor.
The numbers 1-8 (with 8 being transparent) set the INK colour, and when pressed with SYM SHIFT set the PAPER colour.
B and F cycle BRIGHT and FLASH through 0,1 and 8.
Then use M or SPACE to set a cell, or C turns the 'pen' on/off.

Z locates the cursor, if you've lost it, and N turns off the status display.

Using CAPS SHIFT + QAOP scrolls the whole screen around,
CAPS V is used to clear the screen
CAPS Z is used to store/retrieve images from the memory
CAPS I bring up the instructions (non destructively) for when you can't remember what you're doing.

There's 104 bytes of machine code at the end (including Steve Wetherill's 16 byte routine to fill the screen with a checkerboard!) which allow this programme to run at a reasonable pace, and the make the copy and pasting of the screen to a buffer work.

https://drive.google.com/drive/folders/ ... p=sharing
Link to googledrive with .bas file, asm, and .tzx file for anyone who wants to have a play.
I used zmakebas to make this on the Mac (apologies to bas2tap users, as the syntax is slightly different)


Incidentally THIS was why I was pleased to be able to PRINT AT the whole screen from BASIC including the bottom two lines (with some tricksy use of #1).
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

This is great! You know, if you move the keyboard polling routine from BASIC to machine code (at least for the painting tool controls), you can easily handle simultaneous keypresses for diagonal movement and continuous drawing.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Ast A. Moore wrote: Sat Jan 04, 2020 11:53 pm ... move the keyboard polling routine from BASIC to machine code (at least for the painting tool controls), you can easily handle simultaneous keypresses for diagonal movement and continuous drawing.
That does make sense. I wonder how much time I'll spend making the tool, before I actually start using the tool!
CLEAR 23855
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: Stipple ATTR Art Tool

Post by Lethargeek »

uglifruit wrote: Sun Jan 05, 2020 12:14 am
Ast A. Moore wrote: Sat Jan 04, 2020 11:53 pm ... move the keyboard polling routine from BASIC to machine code (at least for the painting tool controls), you can easily handle simultaneous keypresses for diagonal movement and continuous drawing.
That does make sense. I wonder how much time I'll spend making the tool, before I actually start using the tool!
in the mean time you can always use these online tools: ;)
https://events.retroscene.org/53c
http://53c.verve.space

btw what palette is closer to the real thing you think?
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Lethargeek wrote: Sun Jan 05, 2020 2:47 am in the mean time you can always use these online tools: ;)
https://events.retroscene.org/53c
http://53c.verve.space

btw what palette is closer to the real thing you think?
Oh my goodness - they makes my efforts almost entirely redundant!
I'd suggest that the Pulsar Palette of verve.space wins.

How did I miss the existence of those?
Was if for an art competition?
CLEAR 23855
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: Stipple ATTR Art Tool

Post by Lethargeek »

uglifruit wrote: Sun Jan 05, 2020 9:38 am Oh my goodness - they makes my efforts almost entirely redundant!
Don't despair, some people prefer doing everything on the real Spectrum whenever possible. And you can use this project to hone your skills.
uglifruit wrote: Sun Jan 05, 2020 9:38 am How did I miss the existence of those?
Was if for an art competition?
yes, it was made specifically for realtime compos
the first link even tells there will be another one in 2 days 8-)

more info here https://events.retroscene.org/dhl2020?lang=English
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Ast A. Moore wrote: Sat Jan 04, 2020 11:53 pm This is great! You know, if you move the keyboard polling routine from BASIC to machine code (at least for the painting tool controls), you can easily handle simultaneous keypresses for diagonal movement and continuous drawing.
Okay- you bullied me into it.
I've m/c-ified up a relocatable keyboard reading

6 addresses are written to with the 'results' of keypresses; which I think should help take the strain off the BASIC IF statements:

[UP/DOWN]= 1=UP. 2=DOWN. 0=no keys pressed OR both keys pressed [See NOTE]
[LEFT/RIGHT] 1=LEFT. 2=RIGHT. 0=no keys pressed / both keys pressed.
[FIRE (space/M) 0=notpressed, 1/4/5 if either/both pressed]
[SYM/CAPS] 0=notpressed, 1,2,3 if either/both pressed]
[1,2,3,4,5,6,7,8,0] 255=not pressed, 1,2,3,4,5,6,7,8,0 if that key pressed respectively]

BC set to FIRE status for return to BASIC. let fire=USR org

Clocks in at 150 bytes, which isn't too bad, given it's not the most efficient code.


Just need to shuffle the BASIC around, and change it to use it, then diagonals will be mine!


[ NOTE- I'm considering if I should make this; 1 = LEFT, 2 = NO/BOTH KEYPRESSES, 3 = RIGHT] so I can use LET x=x+PEEK (address)-2 ]
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

uglifruit wrote: Sun Jan 05, 2020 5:40 pm Okay- you bullied me into it.
I've m/c-ified up a relocatable keyboard reading
Great. Now, give me your lunch money. :D
uglifruit wrote: Sun Jan 05, 2020 5:40 pm6 addresses are written to with the 'results' of keypresses; which I think should help take the strain off the BASIC IF statements
Before I decided to rewrite Yankee in assembly, I actually did something similar—rewrote parts of it. I started with the menu (including the animations and redefine keys routine), then added the keyboard polling routine. However, to simplify things, I also handled coordinate changes in assembly. It’s trivial, fast, and makes short work of detecting simultaneous keypresses. That way, all I had to do in BASIC was read the resulting coordinates (LET X=PEEK xxxxx: LET Y=PEEK yyyyy).
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Ast A. Moore wrote: Sun Jan 05, 2020 6:46 pm Great. Now, give me your lunch money. :D
I'm telling on you!

And thanks to you, I've spent far too long hacking away at this, and what started as a few assembly language tools to augment my BASIC has got waaaay out of hand (It's all in assembly now).


Here it is in it's current state ( https://drive.google.com/open?id=13D30 ... 35iPbssqZ )

Keys are:
Q,A,O,P - And yes, you can of course use diagonals now!
M, or SPACE to draw as you move. (Or use ENTER to toggle the PEN on/off)


1,2,3,4,5,6,7,8,0 - Set Ink Colour (with 8 being 'Transparent')
1,2,3,4,5,6,7,8,0 + CAPS - Set Paper Colour
B and F - Set the Bright and Paper attribute (0,1, or 8 for transparent)
G - Gets the attributes from under the current cursor, which is handy when use with ...
H - Brings up a Colour Swatch, (that can't be written on, but can have the colours 'G'd from)

1,2,3,4,5,6,7,8,0 + SYM - Swaps the current screen with one of 9 'workspaces' in memory. (in this .tap file workspaces 0 and 1 start with something in them)

The status bar at the top shows the current colour values for INK,PAPER,BRIGHT,FLASH and the current PEN Status (0=off)


To do list:
1. Screen scrolling (It'll be CAPS + QAOP) - already wriiten, just need dropping in
2. Toggle/remove status bar (maybe move it to the bottom when cursor is near the top)
3. A 'key debounce' routine.
3. Slow it down a bit, I think.
4. Instructions/help
5. Stop the meddling user swapping out the colour swatch using SYM 1,2,3, etc when the swatch is displayed. That shouldn't be allowed.
6. Some way of saving/exporting.


edit: I've realised I've stopped BRIGHT working somehow. Eugh. Hopefully it'll be a straightforward bugfix.
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

uglifruit wrote: Tue Jan 07, 2020 12:37 am And thanks to you, I've spent far too long hacking away at this, and what started as a few assembly language tools to augment my BASIC has got waaaay out of hand (It's all in assembly now).
And just like that—you’re hooked. (PM me if you need a phone number of a good rehab.)

This is looking swell, man. Feels like the user has control over the program, rather than the other way around (which is often the case with BASIC). Keep adding features and optimizing the code as you go along.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Well, I've done it! Here it is - the fully machine code version.

HINT: When you run it, press SYMBOL SHIFT + Numbers to see what it does. Also press and hold I for Instructions. Otherwise it's a bit boring (being just a blank screen)


Keys:

Q,A,O,P: M, or SPACE to draw as you move. (ENTER to toggle the PEN on/off)

1,2,3,4,5,6,7,8,0 - Set Ink Colour (with 8 being 'Transparent') and 1,2,3,4,5,6,7,8,0 + CAPS - Set Paper Colour

B and F - Set the Bright and Paper attribute (0,1, or 8 for transparent)

G - Gets the attributes from under the current cursor, which is handy when use with..

H - Brings up a Colour Swatch, (that can't be written on, but can have the colours 'G'd from). There's a panel at the bottom showing the colour of the square you're currently on, for comparison.

L - makes the status bar appear/move to different corners/disappear. This was a pain in the arse to get working. Especially when I swapped workspace, I carried on having attributes left behind from it. Grr.

T - chooses between three cursors - multicoloured, flashing tranparent and completely invisible (hold T for about a second get the last 'hidden' one)

CAPS + QAOP scroll the screen display.

Hold 'I' (the letter) for Information/keys

Hold CAPS and SYMBOLSHIFT for a short while to clear the screen of the current workspace (filled with the current colour).

1,2,3,4,5,6,7,8,0 + SYM - Chooses the current screen with one of 9 'workspaces' in memory.

[Workspaces 1,2,3,4,5,6,7,8 come preloaded with some art for 'enjoy']



I'm ever so proud of this, even the .asm is a bit of a mess!


https://drive.google.com/open?id=1U1Cn2 ... U7Koqf7NY



Image

Image

Image

Image

Image
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

Brilliant! A bit of debouncing could help here and there:

Code: Select all

1$	call $28e	;poll keyboard
	inc e		;if E=FFh (no key is pressed), INC E will result in 0
	jr nz,1$
Usability could benefit from the cursor changing color/shape to indicate a particular action, as well. But overall, I’m loving it! Very refreshing to use and look at.

Next, you might want to start optimizing it. At 10K, it seems the code could hit the gym.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

Ast A. Moore wrote: Wed Jan 08, 2020 1:07 am

Code: Select all

1$	call $28e	;poll keyboard
	inc e		;if E=FFh (no key is pressed), INC E will result in 0
	jr nz,1$
Thanks for that. I could have done with that many hours ago!
Ast A. Moore wrote: Wed Jan 08, 2020 1:07 am Next, you might want to start optimizing it. At 10K, it seems the code could hit the gym.
Oh definitely. There is lots of repeated bits, and some very ungainly sections just to "get it working" rather than be elegant. That became my mantra at some point.
To be fair *most* of the size is taken up with the 8 included pieces of "art" already loaded into the workspaces. (that accounts for 8 x 768 bytes). And the colour swatch board (key H) is also stored as an uncompressed attr screen (another 768 bytes, that could definitely be "built", rather than just copied to the screen with far less data). Actually, I'm using that space anyway, as somewhere to store the screen when you call you the swatch, so it's space that's needed anyway. Though if I was loading from tape I'd be a bit pissed off at having to load 6.5K of pictures just to use it.

(I'm not defending the rest of it. The coding really is shockingly inefficient).
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

uglifruit wrote: Wed Jan 08, 2020 1:52 am To be fair *most* of the size is taken up with the 8 included pieces of "art" already loaded into the workspaces.
Right. Sorry, my bad. However obvious, it’d totally slipped my mind.

Could be an interesting opportunity to code a simple custom compressor/decompressor just for that purpose.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Stipple ATTR Art Tool

Post by uglifruit »

There was a bug in my Flash/Bright handling (one was affecting the other, in some combinations).
I worked out it was a bitwise rotation I'd buggered up.
AND I've saved 10 bytes. (Next stop, 3D chess!)

New link, to updated version. This is now a proper finished thing, I think, and I'm using it happily.

https://drive.google.com/file/d/1fSuDUy ... sp=sharing
CLEAR 23855
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Stipple ATTR Art Tool

Post by Ast A. Moore »

uglifruit wrote: Wed Jan 08, 2020 7:39 pm AND I've saved 10 bytes. (Next stop, 3D chess!)
I don’t know if that’s wise. I once speculated that if arkannoyed optimized his code any more, the Universe would implode on itself. :D
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Post Reply