Example

ATTRIBUTES values reader

3

was8bit 2022-04-18 08:41 (Edited)

ATTRIBUTES READER for both character cells and sprites

*note* size attribute for cells is not used

To use in your code, you will need to copy the GLOBAL variables line, and also copy the SUB code...

... study the code to see examples of how to use


GAMELEGEND 2022-04-18 18:00 (Edited)

i know why the attribute variables are divided by 64 but what i want to know is why is that number 64


was8bit 2022-04-18 19:55 (Edited)

Its 2bit binary math...

The digits are read backwards, starting on the right and ending on the left...

So...
%00000001 = 1 (2^0)
%00000010 = 2 (2^1)
%00000100 = 4 (2^2)
%00001000 = 8 (2^3)
%00010000 = 16 (2^4)
%00100000 = 32 (2^5)
%01000000 = 64 (2^6)
%10000000 = 128 (2^7)

%1111111111 = 255


was8bit 2022-04-18 20:01 (Edited)

It would be similar in our tens system... if in a number COORD=1703 represented x,y coordinates... then x= COORD\100 and y=COORD-(x*100)

In binary math, ATR_VAL AND %11000000

The AND will copy any digit where the 1's are, and where the 0's are it forces a 0... effectively this chops up a binary number into only looking at digits WHERE you want to look, and ignores the rest of the digits..


was8bit 2022-04-18 20:03

You can rewrite as

ATR_VAL AND %YYxxxxxx)

Just to understand what its doing... keep each Y digit, ignore all x digits


was8bit 2022-04-18 20:04

Binary math can be very confusing... it takes me while to get it right, and many times i still get confused ;)


was8bit 2022-04-18 20:08 (Edited)

Or look at it this way, data is being stored as bits, combinations of either 0 or 1

SSIXYPPP

Where bits SS = size, bit I=priority, bit X= xflip, bit Y=yflip, and bits PPP= palette#


was8bit 2022-04-18 20:14

When you read .A directly, it is a number that is a combination of ALL bits together... as if you were looking at size 3, x,y both flipped, and palette 7, all bits set to 1, then .A reads as a total value of 255... which as is tells us nothing... and NX doesnt automatically break it down for you, so we have to do that manually...

.. it isnt that common to need this info, so therefore no NX commands for this data...


was8bit 2022-04-18 20:16

Alternatively, you can use a SPRSIZE(63) variable, and then as you assign a sprite, set this variable... then in code all you have to do is read this variable... this may be easier.... :)


GAMELEGEND 2022-04-18 20:48

wow

i have so much to learn


was8bit 2022-04-18 20:50 (Edited)

Stay cool :)


was8bit 2022-04-18 20:51

Bit math can mostly be avoided, unless you just really want to get into it....


was8bit 2022-04-19 02:10

You might find this interesting :)

https://lowresnx.inutilis.com/topic.php?id=118


Log in to reply.