ROTATING IMAGES PMODE3

A place to discuss everything Dragon related that doesn't fall into the other categories.
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

ROTATING IMAGES PMODE3

Post by pser1 »

Hello,
I am sure that most of us do know the incredible "rotozoom" created by Simon Jonassen for different computers.
When I saw it, I contacted him and he kindly showed me how it worked, great master!
I wanted to rotate an actual Pmode3 image, so he pointed me to a web where one can find all of the needed maths to do that (it is in french language)
http://www.alrj.org/docs/2D/rotozoom/rotozoom.html

Immediately I began to program something with those equations just to prove the concept.
When it finally worked, it was really slower than a snail :-(

I contacted Simon again and we began a chain of modifications / optimizations in order to make it run faster and faster, since Nov, 8th it has lasted a bit more than a month.
The very first version needed about 5 seconds to draw a single frame, say one step!
Now the time varies upon the machine
for 32k machines ... 19,5 seconds to perform a 360 degrees (full turn in 64 steps)
for 64k machines ... 16,5 seconds (in MAP1)
This means that now a single frame (step) is done in about 0,3 sec or 0,26 sec (64k). The program runs 16-19 times faster than the first version!
This is the result of a lot of really 'mad' changes and lots of optimizations, for instance creating tables to reduce the calculations. Right now only additions and subtractions!

I upload here two VDK and two DSK files for Dragon and CoCo users, so anybody can try it!
37 - ROTOPM3 V33 for Dragon 32.zip
(14.4 KiB) Downloaded 190 times
37 - ROTOPM3 V33 for Dragon 64.zip
(10.12 KiB) Downloaded 189 times
37 - ROTOPM3 V33 for CoCo2 32k.zip
(7.49 KiB) Downloaded 183 times
37 - ROTOPM3 V33 for CoCo2 64k.zip
(8.12 KiB) Downloaded 179 times
The versions for 64k machines won't work on 32k machines (if not expanded), as they
switch to MAP1 and use the full 64k of RAM, no Interpreter, no DOS
In next post, I will add some notes about the program
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: ROTATING IMAGES PMODE3

Post by pser1 »

Some notes about the program:
We rotate a viewport of 80x80 pixels (square) and so when it moves 45 degrees, the vertical or horizontal lines are able to show: 80 pix / cos 45º = 114 pixels

You can 'cook' any drawing in Pmode3 ensuring that the image to be rotated remains centered.
As we use an area of 128x128 pixels, this means that we leave out of sight both the first 32 rows and the last 32 rows too, just because 192-32-32 = 128
The image can use the whole width of Pmode3 (128 pixels) remember we'll see 114 only!

Despite the image in Pmode3 is 128x128 pixels, it shows on screen as a rectangle that has exactly double width than height (factor 2:1)
In order to 'show' a rotating square, we use Pmode1 wich compensates size because the resolution in that mode is 128x96, so each Pmode1 row is double height than Pmode3
When working on a drawing to be rotated, keep in mind this detail, it will show double height than seen in Pmode3.

Once you have an image ready and saved to disk, to create the texture, use the program
- GENPIX.BAS for 32k machines. This will create a filename finished in 'X'
- CRT2FIL.BAS for 64k machines. This creates 2 files finished in 1 and 2
Once created the texture file(s), you can verify the resulting files running
- RDPIX.BAS for 32k machines. Reads the texture and recreates the PM3 image
- VERIFIER.BAS for 64k machines. Reads the two files and recreates the PM3 image
Finally, to see the image rotating, you run, in all machines
- EXEROT.BAS
To quit you will have to press the Reset button

In these virtual disk files you will find two images.
- SQUARE.BIN that is an image 128x128 pixels that I used to verify the program in the first steps.
- QBERT.BIN is a screen capture of the Cuthbert character from the loading screen of some Microdeal games. I cut it to center it in the middle, but it is too big and shows partially.
cheers
pere
SQUARE-rot.jpg
SQUARE-rot.jpg (14.81 KiB) Viewed 4265 times
QBERT-rot.jpg
QBERT-rot.jpg (29.19 KiB) Viewed 4265 times
sorchard
Posts: 530
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: ROTATING IMAGES PMODE3

Post by sorchard »

That's really impressive! Nicely done!
Stew
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: ROTATING IMAGES PMODE3

Post by Bosco »

Very clever! :D

Well done Pere/Simon.
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: ROTATING IMAGES PMODE3

Post by pser1 »

Hi,
Thanks for your kind words!
It is always fun to try to push these old beasts beyond their limits ...
or what we think their limits are.

cheers
pere
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: ROTATING IMAGES PMODE3

Post by pser1 »

Hello,
another step I wanted to try before closing the project was performing the needed changes
to make it run in machines with an Hitachi 63x09 instead of the standard MC6809
Just using the faster CPU native mode and using the new registers E and F,
the time is reduced from 16,5 seconds (for a D64 MAP1) down to 13,8 seconds, so about 16% faster
I am adding here the four disks now in v34 that contain both versions.
- RUN"EXEROT " will still execute it for 6809
- RUN"EXEROT3" will execute the new version for 6309 native mode

cheers
pere
37 - ROTOPM3 v34 for Dragon 32.zip
(14.53 KiB) Downloaded 170 times
37 - ROTOPM3 v34 for Dragon 64.zip
(10.34 KiB) Downloaded 182 times
37 - ROTOPM3 v34 for CoCo2 32k.zip
(8.17 KiB) Downloaded 168 times
37 - ROTOPM3 v34 for CoCo2 64k.zip
(9.12 KiB) Downloaded 175 times
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: ROTATING IMAGES PMODE3

Post by simon »

Limits....

what limits.... all in your mind :D
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: ROTATING IMAGES PMODE3

Post by pser1 »

Hi,
this is my first try with an screen capture program ... don't shoot me!
It is an mp4 file that shows two full turns

cheers
pere
Roto6309.zip
(3.63 MiB) Downloaded 172 times
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: ROTATING IMAGES PMODE3

Post by pser1 »

this is the url where I have posted the video of the ROTATOR on a 6309

https://www.facebook.com/10001019490918 ... 669153727/

Is there any way to uplad here a video (might be some 4Mb)?
cheers
pere
User avatar
robcfg
Posts: 1529
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden
Contact:

Re: ROTATING IMAGES PMODE3

Post by robcfg »

I think you can upload videos in FLV format, but I'm not sure that you can embed them in forum posts.

Would be a nice feature though.

By the way, nice effect! Would it be possible to do for example a maze game based on rotating the screen itself?

Keep up the good work!
Post Reply