Poking to screen memory

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
AJW
Posts: 906
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Poking to screen memory

Post by AJW » Fri May 01, 2020 6:28 pm

I'm trying to invent pixels in mode 1 using the following where C% is the x-coord counter, but it seems wrong as though the EOR numbers are incorrect. Does this seem right:

331offx%=(C%DIV4)
332offx2%=C%MOD4
333bts%=?pltsc%+((offx%*8))
340IFoffx2%=0bts%=bts%EOR136
350IFoffx2%=1bts%=bts%EOR68
360IFoffx2%=2bts%=bts%EOR34
370IFoffx2%=3bts%=bts%EOR17
390pltsc%?((offx%*8))=bts%

User avatar
MartinB
Posts: 5340
Joined: Mon Mar 31, 2008 10:04 pm
Location: Obscurity
Contact:

Re: Poking to screen memory

Post by MartinB » Fri May 01, 2020 6:51 pm

I'm guessing after a cursory look but in line 333, you've got double brackets....

333bts%=?pltsc%+((offx%*8))

...which don't do anything above single brackets. So, bts% becomes equal to the contents of pltsc% with offx% x 8 subsequently added to those contents.

Did you actually want....

333bts%=?(pltsc%+(offx%*8))

...such that bts% becomes equal to the contents of the memory location given by the result of (pltsc% + ( offx% x 8 )) which aligns better with line 390 ?

(Though line 390, whilst functionally correct, also has superfluous double brackets.)

AJW
Posts: 906
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Poking to screen memory

Post by AJW » Sat May 02, 2020 1:40 pm

Yes that's right thanks.

User avatar
SimonSideburns
Posts: 564
Joined: Mon Aug 26, 2013 9:09 pm
Location: Purbrook, Hampshire
Contact:

Re: Poking to screen memory

Post by SimonSideburns » Sat May 02, 2020 8:14 pm

AJW wrote:
Fri May 01, 2020 6:28 pm
I'm trying to invent pixels in mode 1 using the following where C% is the x-coord counter, but it seems wrong as though the EOR numbers are incorrect.
Did you manage to make some?
Just remember kids, Beeb spelled backwards is Beeb!

AJW
Posts: 906
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Poking to screen memory

Post by AJW » Wed May 06, 2020 4:28 pm

Now I have a question about preserving and setting bits of a byte of screen memory.

depending on colour selected I attempt to set masks for the 4bits per pixel:
670IFc%=0 msk1%=0
680IFc%=0 msk2%=0
690IFc%=0 msk3%=0
700IFc%=0 msk4%=0
710IFc%=1msk1%=8
720IFc%=1msk2%=4
730IFc%=1msk3%=2
740IFc%=1msk4%=1
750IFc%=2msk1%=128
760IFc%=2msk2%=64
770IFc%=2msk3%=32
780IFc%=2msk4%=16
790IFc%=3msk1%=136
800IFc%=3msk2%=68
810IFc%=3msk3%=34
820IFc%=3msk4%=17

Then I try to force them onto the byte that I plot to screen depending on the particular byte in question (offx2%):

910IFoffx2%=0bts%=bts%ORmsk1%
920IFoffx2%=1bts%=bts%ORmsk2%
930IFoffx2%=2bts%=bts%ORmsk3%
940IFoffx2%=3bts%=bts%ORmsk4%

Obviously something is wrong but what is missing - maybe a lot?

User avatar
tricky
Posts: 4667
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Poking to screen memory

Post by tricky » Wed May 06, 2020 5:10 pm

I'm not quite sure what you are doing (its been a long day), but remember you need to AND the bits of for the pixel you are replacing before ORing the bits in for the new colour.

AJW
Posts: 906
Joined: Sun Feb 15, 2004 2:01 pm
Contact:

Re: Poking to screen memory

Post by AJW » Wed May 06, 2020 6:26 pm

I had tried that with then following but not sure if I'm preserving the bits ok. Will keep thinking about it.

821IF msk1%=0 bts%=bts%AND119
822IFmsk2%=0 bts%=bts%AND187
823IF msk3%=0 bts%=bts%AND221
824IF msk4%=0 bts%=bts%AND238
830IF msk1%=8 bts%=bts%AND247
840IFmsk2%=4 bts%=bts%AND251
850IF msk3%=2 bts%=bts%AND253
860IF msk4%=1 bts%=bts%AND254
870IF msk1%=128 bts%=bts%AND127
880IF msk2%=64 bts%=bts%AND191
890IF msk3%=32 bts%=bts%AND223
900IF msk4%=16 bts%=bts%AND239
901IF msk1%=136 bts%=bts%AND119
902IF msk2%=68 bts%=bts%AND187
903IF msk3%=34 bts%=bts%AND221
904IF msk4%=17 bts%=bts%AND238

Post Reply

Return to “programming”