I've read through most of two assembler books: "Mastering Assembler" and "Creative assembler for the BBc Micro".
In the Mastering assembler book, there is a chapter on sprite handling (Chapter 10) which demonstrates plotting a sprite in Mode 2. It explains that Mode 2 is the simplest mode to work with. I almost understand the reasoning - essentially amounting to being able to shuffle data around a byte per time. By moving at a byte per time, one can move a sprite two pixels at a time (to left or right), because in Mode 2, each byte in screen memory represents two pixels (correct??)
Code below is extract from the Mastering Assember book Chapter 10. It goes through plotting a sprite in BASIC (by poking bytes in screen memory) before turning this into assembly later.
My brain has melted in trying to understand how the hex values correlate to coloured pixels in the DATA statements. If each byte is two pixels, and first byte is top left of sprite.. how does 0C come to represent green pixel, green pixel???
I've looked through BBC advanced user guide which somewhat tersely describes logical and physical colours as per video ULA (again a bit of mind bender) which states each logical colour is to be EORed with 7. But applying this to the data statements still doesn't make sense.
Can anyone shed any light on how to poke pixels directly to the screen in mode 2, whilst explaining how to specify the colour I want each pixel to be????
I think understand the screen layout of mode 2 (which some of code below aludes to) .. ie where to plot pixels.. it's how to plot desired colours per pixel in a given byte that's blowing my mind.
Any help on this would be much appreciated.
Thanks.
jbnbeeb
Code:
10 MODE2
20 VDU23,1,0;0;0;0;
30 FOR A%=0 TO 1
40 FOR B%=0 TO 7
50 FOR C%=0 TO 3
60 READ D%
70 ?(&3000+A%*640+B%+C%*8)=D%
80 NEXT,,
90 GOTO90
20000 DATA&0C,&00,&00,&0C
20010 DATA&04,&08,&04,&08
20020 DATA&00,&0C,&0C,&00
20030 DATA&00,&09,&06,&00
20040 DATA&01,&03,&03,&02
20050 DATA&03,&03,&03,&03
20060 DATA&17,&2B,&17,&2B
20070 DATA&17,&21,&12,&2B
20080 DATA&17,&21,&12,&2B
20090 DATA&03,&03,&03,&03
20100 DATA&03,&03,&03,&03
20110 DATA&01,&03,&03,&02
20120 DATA&00,&21,&12,&00
20130 DATA&00,&20,&10,&00
20140 DATA&30,&20,&10,&30
20150 DATA&30,&20,&10,&30