Embedded Masked Graphics

The Oric video chip is not an easy beast to master, so any trick or method that allows to achieve nice visual results is welcome. Don't hesitate to comment (nicely) other people tricks and pictures :)
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Embedded Masked Graphics

Post by Twilighte »

Masking is a technique used on most computer graphic engines to highlight certain objects from other objects they may overlap especially when dealing with few colours.
Like showing a monochrome hero sprite over of a complex monochrome background.
Unless the sprite is perfectly square, a mask cannot be designed through the bitmap of the graphic but must be a separate graphic.
When a mask is placed over any graphic image, it should allow the graphic to show through but should hide the background so it does not obscure it.
Therefore the mask may also contain an outline, creating a more defined border between graphic and background.
Unfortunately because a sprite is usually composed of many frames (To define running, jumping and in different directions) the same amount of memory used for these frames must also be used for each frames mask.
This really consumes alot of memory, (especially when sprites move smoothly and need shift frames).
However, the Oric graphic scheme does have one trick up its sleave if (and only if) a less detailed mask can be used).
Since all this masking is based on a simple black and white (Monochrome) image, it can be assumed that the top two bits of the graphic can be ignored for the time being and we can store the mask in those bits.
This means that the mask will now mask either left 3 pixels, right 3 pixels, no pixels or all 4 pixels of graphic.
This technique was used in the unreleased Times of Lore game and my new project.
the actual code required to extract this mask is quite simple, and may be optimised if the whole routine is placed in zero page. However, for simplicity, i have kept the listing below in main memory

lda (Graphic),y
tax
lda (background),y
and mask_table,x
ora bitmap_table,x
sta (background),y

this is for one byte.
More later on this subject
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

mask_table and bitmap_table are two 256 byte tables used to optimise the plot routine. Code may be adjusted not to use these tables if memory is tight.
The existing routine was...

lda (Graphic),y
tax
lda (background),y
and mask_table,x
ora bitmap_table,x
sta (background),y


with no bitmap table...

lda (Graphic),y
tax
and #63
sta temp_01
lda (background),y
and mask_table,x
ora temp_01
sta (background),y


the bitmap table holds a sequence of incrementing numbers from 0 to 63 but each one adds 64. This is repeated 4 times.
Post Reply