ZX4PAINT

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
Forthretro.new.fr
Posts: 32
Joined: Thu Nov 19, 2009 9:34 pm

ZX4PAINT

Post by Forthretro.new.fr »

ZX4PAINT
http://forthretro.new.fr/download/ZX4PAINT.zip

Bonjour to all,

I would like first to wish every one a happy new year.

For this project, my first Idea was :
1 – To show how powerful FORTH could be with ZX81
2 – To test a ‘Filling Algorithm’ I found in Forth-Dimension magazine.
A ) THE PROJECT
This Graphic program permit :
- Draw a 2bitx2bit dot in a HRG screen of 32 * 4 x 24*4 = 128x96
- Draw a line with the ‘elastic effect’ similar to the Window paint.
- Draw a rectangular form with similar effect
- Draw a circle – Ellipse ( to come soon)
- To FILL a CLOSED FORM .
- 2 screens : 1 HGR – 1 low resolution with usefull information as : Position/edition of the position of the Dot etc..( to come soon)
- More if possible.
- Full compatibility ( ?) with the real ZX81: ZX81 – 48 K - 2K SRAM
B) LANGAGE
Compilateur : FORTH compiler, brazilian origin - http://forthretro.new.fr/
C) EMULATOR :
EO – 48 K (Setting : Hi-Res disabled - All advanced setting unchecked )
VB81 with its excellent interface Windows –Forth Editor (Thanks Xavier)
D) PROGRAMME » ZX4PAINT ».
1- EO et VB81 , ‘Load Snapshot’ -> ZX4PAINT
2- For to launch, just hit <New Line>
3 - Commands :
- Color : key ‘0’ ( white) – Key ‘1’ (Black) – Key ‘T’ (Transparent)
- Shift 5 6 7 8 for Up Left Right Down.
- Lines : Key ‘L’ – Up Left Right Down – Key ‘L’ (again) for ‘validation’.
- Rectangle : key ‘R’ – Up Left Right Down – Key ‘R’ (again) for ‘validation’.
- Circle : key ‘C’ – Up Left Right Down – Key ‘C’ (again) for ‘validation’.
- Ellipse : key ‘E’ – Up Left Right Down – Key ‘E’ (again) for ‘validation’.
- Fill : The Dot anywhere INTO a CLOSED Form – Key ‘F’
- Paste : key ‘P’ – Up Left Right Down - key ‘Shift C’ - Move the shape - key ‘Shift V’
..............................................key ‘Shift X’ - Move the shape - key ‘Shift V’
- Glass : key ‘G’ - key ‘G’ again
- CLS : key ‘K’
- Undo : Undo all the above command – Key ‘U’
- Quit – Key ‘Q’. (return to the PROMPT of FORTH )
- In order to launch it again : write: ZX4PAINT<NewLine>
E – LISTING
The listing forth is avaible for the interested one.
2 files you can edit with the Pad.

F FIGFORTH COMPATIBILITY
The grogram is FIGFORTH compatible.
Some ASCII FORTH Key/ command don’t exist on the ZX as we know, so :

@ -> £ ( Shift Space)
! -> $ (Shift U)
‘ (Til) -> ( ?)

G - MEMORY
50D0 – 5F2C –Forth Compiler
5F38 – 7807 – Hi-Res Screen
7859, 788B, 78B2 – The well know HRG Routine
78BD – 9480 - Main Program
9C00 – A407 - Forth editor
A57E – D560 – Copy of the 12 SCR

H – SOURCE :
Hrg Routines :
http://www.user.dccnet.com/wrigter/inde ... torial.htm
(Thanks Wilf)

Drawing Line and FILL Algorithm :
The Bresenham Line-Drawing Algorithm by Philip Koopman - Forth Dimention Vol 8 N° 6 Page 12
Filling Algorithms by Zbigniew Szkaradnik – Forth Dimension - Vol 11 n° 2 Page 10
Forth Dimension disponible at :
http://www.forth.org/fd/contents.html
(even if I could not access it today)

Circle and Ellipse algorithm :
John Kennedy -
http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
http://homepage.smc.edu/kennedy_john/BCIRCLE.PDF

Friends, any feedback, critic, suggestion will be welcome, in order to improve my ZX4PAINT
Sorry for my English
Dominique

ZX4PAINT
http://forthretro.new.fr/download/ZX4PAINT.zip
Last edited by Forthretro.new.fr on Wed Jan 20, 2010 11:38 pm, edited 8 times in total.
RWAP
Posts: 1348
Joined: Thu May 08, 2008 8:42 am
Location: Stoke-on-Trent, UK
Contact:

Re: ZX4PAINT

Post by RWAP »

That sounds great - when I get chance I will have a look at it - well done for your first project!
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: ZX4PAINT

Post by Moggy »

WOW what a fantastic program 10-10 for your first project Dominique, spent some time playing with this. Can't wait for the circle and ellipse routine and perhaps an "unfill" routine to reverse a mistaken fill. I did find that if You use fill outside of a closed form the screen would fill upwards one line at a time till it reached the top then lock up prompting a reset.
These are the only comments I can think of for now, but once again a fantastic program!!

Regards Moggy
User avatar
Forthretro.new.fr
Posts: 32
Joined: Thu Nov 19, 2009 9:34 pm

Re: ZX4PAINT

Post by Forthretro.new.fr »

Moggy wrote:WOW what a fantastic program 10-10 for your first project Dominique, spent some time playing with this. Can't wait for the circle and ellipse routine and perhaps an "unfill" routine to reverse a mistaken fill. I did find that if You use fill outside of a closed form the screen would fill upwards one line at a time till it reached the top then lock up prompting a reset.
These are the only comments I can think of for now, but once again a fantastic program!!

Regards Moggy
Thank you Moggy :

- For the Fill problem I am thinking to something. On the left and the right, the FILL routine works because the byte 96 at the end of each line. I can fool the FILL routine with Lines full of 96, one at the top and one at the end of the HGR screen. Another possibility would be a test of the Y coordinate, but I am afraid it will turn the routine very slow.
- For the Ellipse I found an excellent algorithm with integers.
http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
- The unfill idea is excellent ... but how to do it? (to have a copy of the HGR screen ? humm..) :cry: But thanks for the challenge and your message
Dominique
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: ZX4PAINT

Post by XavSnap »

Hi all,

Many Thanks to Dominique.

Vb81 XuR is ready and updated !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
Forthretro.new.fr
Posts: 32
Joined: Thu Nov 19, 2009 9:34 pm

Re: ZX4PAINT

Post by Forthretro.new.fr »

Hello friends,

This is the V2-beta of ZX4PAINT.

IMPROVEMENT
- The RECTANGLE routine – It seems now better and faster.
- INKEY – With a ‘OR –‘test ‘ I could include two INKEY in the same routine for CIRCLE and RECTANGLE : -> routine1 INKEY1 …routine2 …. INKEY2 …routine3.. IF INKEY1 OR INKEY2 = XX THEN ….
- Better and faster test ‘OUT OF SCREEN’ for all the X and Y . However I have a bug in the new routine CIRLE when part of the circle is out of the screen on the left side

NEX COMMAND
- KEY ‘C’ for Circle. The BCIRCLE algorithm worked fine. http://homepage.smc.edu/kennedy_john/BCIRCLE.PDF
The R of the circle is given by the deltaX of the cursor.
- KEY ‘E’ for Ellipse – It is the UNFINISHED routine. The algorithm is not very easy to write in FORTH. The result is not very nice because too slow.

NEXT STEP
- To Finish ELLIPSE (Improvement – faster)
- To check a bug (?) with Circle
- The UNDO routine
- The crash with FILL of the full SCREEN
- COPY/PASTE of part of the Screen into a rectangle…. Yeah ! I have my idea.

ZX4PAINTV2BETA
DOWLOAD :

http://forthretro.new.fr/download/ZX4PAINT.zip
User avatar
Forthretro.new.fr
Posts: 32
Joined: Thu Nov 19, 2009 9:34 pm

Re: ZX4PAINT

Post by Forthretro.new.fr »

Hello friends,

This is the V3 of ZX4PAINT.

IMPROVEMENT
- The ELLIPSE routine.
- FILL problem fixed ( don’t crash anymore)
NEW COMMAND
- The UNDO command – Key ‘U’ : After FILL CIRCLE LINE RECTANGLE or ELLIPSE key ‘U’ undo the last command. I am a little bit lost with the problem of FILL UNDO !!!!!

ZX4PAINTV3
DOWLOAD :

http://forthretro.new.fr/download/ZX4PAINT.zip
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: ZX4PAINT

Post by Moggy »

Great work Dominique can't wait for final version !!
User avatar
Forthretro.new.fr
Posts: 32
Joined: Thu Nov 19, 2009 9:34 pm

Re: ZX4PAINT

Post by Forthretro.new.fr »

Bonjour to all :

I lost a lot of time trying to fix a problem with the UNDO after FILL . Now it is OK.
The Copy/Paste routine was much more complex than I first believed. The idea is to use the key ‘P’ ( for mode COPY/PASTE). You will have the same Shape as in the RECTANGLE routine. Use the arrow, then SHIFT C ( for copy) – Use the arrow for the movement of the rectangular shape, then SHIFT V (for paste ). Very soon the SHIFT X for CUT.
I also did another change : The ‘Q’ key for QUIT.

FIXED :
Problem with the FILL routine
NEW COMMAND
Key ‘P’ – COPY/PASTE mode
CHANGE
Key ‘Q’ for QUIT
NEXT STEP
Key ‘Shift X’ – to improve the Keyboard reading – The ‘G’ (Glass) command to magnify 2X (or 3X).
Presentation of the program (I will need some help for the English text…)
Any suggestion are welcome.

ZX4PAINTV4
DOWLOAD :

http://forthretro.new.fr/download/ZX4PAINT.zip
Thanks
Dominique
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: ZX4PAINT

Post by Moggy »

Great stuff Dominique!!
I'm sure I/we can help with English text.
Post Reply