22 November 2018, 22:28 | #1 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
rotating & colouring Icons on the fly?
Is there a way to rotate and/or re colour icons on the fly?
For instance I'm thinking of an arcade/adventure with lots of rooms, but the doorways are different colours and in different directions . so I have to have 4 definitions for each doorway(UDLR), then open/closed, then 6 different possible colours for each. This adds up to at least 16k of icons, The bloody map is a fraction of that!!! I know I could just use the same colour for all of them but that would detract from the colourful nature of the project. btw the Icons are only 2 colour and are only 16px X 16px, however the palette is 16 colours Any ideas guys? Last edited by volvo_0ne; 22 November 2018 at 22:36. |
23 November 2018, 14:25 | #2 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
The command Rev() can do 180°-rotations. Hence it's possible to have all four orientations with only two images; one facing U/D and one facing L/R.
There's no command that rotates images 90° on the fly. I believe one reason for this is that it would have been too slow to be very useful. I have a neat idea for the colours, although it puts some constraints on the palette. The point is that if you paste an icon with one bitplane in a screen with four bitplanes, only the first of these bitplanes is modified. However, the other three bitplanes are still used for determining the colour of the door. This means you can change those to any value you want (using Bar) before pasting the icon; this will change the colour of the door. If you use Bar with Ink 6 for instance, the door will be displayed with colour 6 and 7 when you paste it. (Generally: Ink 2*N => door gets colour 2*N and 2*N+1) |
26 November 2018, 21:47 | #3 | |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Quote:
Thanks for that, it made me wonder if I could do all that in one routine, and I found a workable (if slow) solution. I pasted the "UP" icon to a small backscreen, then rotated it and picked it up again as another icon, Although this takes 3 vbls (one when compiled) it is quick enough for what I'm doing, as the doors are only drawn once per room change and there are never more than four. The added advantage is the doors can be any colour I like as I re colour them when they are re-plotted. Once again thanks V1 Last edited by volvo_0ne; 27 November 2018 at 00:12. |
|
27 November 2018, 19:30 | #4 | |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
Quote:
I notice you must be using 16 colours (four bitplanes) for the icons as you say you can choose the colours freely when you rotate. This seems like a terrible waste of memory for icons that use only two colours; surely one bitplane must be sufficient when the goal is to be stingy with the bytes You can mix icons of any colour depth (i.e. number of bitplanes) in a single icon bank. To create icons with just one bitplane, simply grab them from a screen with two colours. |
|
27 November 2018, 21:24 | #5 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
The memory overhead isn't all that crucial, but 16k seemed very excessive for all the door definitions, I've got it down to 898 bytes now
Also as the routine is configurable, I may (with the help of your Icon size code Thanks again!) be able to use it with the other icons in the game thus saving loads more memory unless drawing speed of the room data is compromised. I am indeed using a 16 colour palette and if this idea works out, I'll probably do as you suggest re grabbing from a 2 colour screen. Thanks for your help V1 |
12 December 2018, 21:03 | #6 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Update......
I created a routine for re-colouring the main icons so that I only need 1 copy of each icon (instead of one for each colour). The speed is quite good but not instant for a redraw from memory (typically 6vbl's to recolour & draw 37 Icons to X,Y position) However that equates to a saving of 21324 of memory, which I think is a good tradeoff |
12 January 2019, 01:21 | #7 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Now I need a faster "rotate" of a 16*16 block which only manipulates 1 plane, but it must be a pure rotate (rather than the built in rev command)
I'm sure this must be possible as I would only be manipulating one plane so peek +poke would do it asymetrically (I hope).... looking into it now. |
28 January 2019, 22:11 | #8 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
The book "Hacker's Delight" presents a rather clever method for transposing "bit-matrices" of size 8x8 bits. Bit matrix transposition can be used for 90-degree rotations too if combined with a vertical reflection, so here's how they did it:
Code:
Original Step 1 Step 2 Step 3 abcdefgh aickemgo aiqyemuC aiqyGOW5 ijklmnop bjdlfnhp bjrzfnvD bjrzHPX6 qrstuvwx qysAuCwE cksAgowE cksAIQY7 yzABCDEF -> rztBvDxF -> dltBhpxF -> dltBJRZ8 GHIJKLMN GOIQKSMU GOW5KS19 emuCKS19 OPQRSTUV HPJRLTNV HPX6LT20 fnvDLT20 WXYZ1234 W5Y7193! IQY7MU3! gowEMU3! 567890!@ X6Z8204@ JRZ8NV4@ hpxFNV4@ Code:
'UPPERHALF/LOWERHALF contains the first/last 32 bits of the bit matrix T=(UPPERHALF/128 xor UPPERHALF) and %101010100000000010101010 UPPERHALF=UPPERHALF xor T xor (T*128) T=(LOWERHALF/128 xor LOWERHALF) and %101010100000000010101010 LOWERHALF=LOWERHALF xor T xor (T*128) It takes one argument which should be either Sprite Base(N) or Icon Base(N) where N is the number of the image you want to rotate. It rotates the first bit plane 90 degrees clockwise and leaves the others as they were. |
12 February 2019, 21:48 | #9 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Whoa, that is WAY over my head.
I don't even know what to do with the downloaded zip file :-O Thanks for your help though |
14 February 2019, 21:20 | #10 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
I didn't really explain anything so that's probably mostly my fault..
I'll now do the reasonable thing and add the missing explanation : Note first that each letter represents a bit in an 8x8 bitmap. In each step of the process some of the letters are swapped, where the moved letters are marked in red. After step 3 you see that the letters that first went left to right now go from top to bottom. The operations with UPPERHALF and LOWERHALF should just be verified on paper, I guess. They are 32-bit numbers, where UPPERHALF contains the first four rows of the 8x8 bitmap and LOWERHALF the last four rows. This is easier to explain Type the following in the editor: Code:
Procedure ROTATE[ADR] End Proc When the machine code procedure has been installed it seems to be stuck in the program however. If this bothers you it might be a better idea to use the alternative method provided by the Pload/Call instructions because that has no such side effects. |
15 February 2019, 03:41 | #11 |
Registered User
Join Date: Feb 2017
Location: Oslo
Posts: 90
|
Um, forgot to clarify the perhaps greatest source of confusion: the formulas for UPPERHALF and LOWERHALF will not make sense unless the computations are done in binary representation. Division by 128 on binary numbers is a simple shift to the right by seven positions. Example:
Code:
%00000000 %00000000 11111111 00000001 00000000 / 128 = 11111110 11111111 00000001 |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Demo name? - Talking fish/human faces in tank & rotating Coke can | Higgy | request.Demos | 0 | 08 May 2017 09:54 |
OS 3.5 icons on 3.1 & WHDLoad hangs when displaying icons | PoulpSquad | support.WinUAE | 22 | 14 September 2012 00:57 |
FIXED: Venus The Fly Trap (TRAP #0) & NOVBRMOVE INFO | Retro-Nerd | project.Killergorilla's WHD packs | 10 | 01 November 2007 23:42 |
educational/puzzle game involving colouring a robot/knight | tricky | Looking for a game name ? | 0 | 19 November 2004 23:17 |
Fly Harder & F1 floppy versions | turk182 | request.Old Rare Games | 6 | 11 November 2001 00:27 |
|
|