Just a little head-scratcher

Show us what you're working on, (preferably with screenshots).
Post Reply
User avatar
stupidget
Dynamite Dan
Posts: 1611
Joined: Wed Jan 24, 2018 2:09 pm
Location: Sunny Wolverhampton

Re: Just a little head-scratcher

Post by stupidget »

dfzx wrote: Thu Jan 10, 2019 2:52 pm Clearly the clever people can see how it works, but can someone post a dumbed down explanation of how it's doing it for the rest of us? :?
Yep +1 vote from me for this info as well please. I'm as thick as a plank me is :lol:
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Just a little head-scratcher

Post by Ast A. Moore »

dfzx wrote: Thu Jan 10, 2019 2:52 pm Clearly the clever people can see how it works, but can someone post a dumbed down explanation of how it's doing it for the rest of us? :?
Just a note that each 8x8 cell still contains no more that one INK and one PAPER color at any one time; so no ULA timing tomfoolery here.

It’s kind of easier to draw on a piece of paper than to put into writing, but I’ll try.

Imagine the following pattern:

Code: Select all

xxxxxxxo|ooooooox|xxxxxxxo| . . .
Here, xs represent the set screen bits (or pixels) and os the reset bits.

Now, let’s shift the whole thing one pixel to the left:

Code: Select all

xxxxxxoo|ooooooxx|xxxxxxoo| . . .
The attribute pattern looks something like this:

Code: Select all

BLUE/YELLOW|YELLOW/MAGENTA|MAGENTA/RED| . . .
At a pixel level, the colors will be as follows:

Code: Select all

BBBBBBYY|YYYYYYMM|MMMMMMRR| . . .
And so on.

Once we’ve shifted our pixel pattern eight times, we need to shift our attributes one cell to the left, and start shifting the pixels again.

The vertical shifting is done in a similar manner.

Hope this clears things up a bit.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
dfzx
Manic Miner
Posts: 673
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Just a little head-scratcher

Post by dfzx »

Ast A. Moore wrote: Thu Jan 10, 2019 3:25 pm Hope this clears things up a bit.
Yes, thanks! Kind of obvious when you put it like that, but I wouldn't have worked it out from looking at the code. :)
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Joefish
Rick Dangerous
Posts: 2042
Joined: Tue Nov 14, 2017 10:26 am

Re: Just a little head-scratcher

Post by Joefish »

Each character cell starts off empty of pixels so it's showing its PAPER colour. What you can't see (because it's empty) is that the INK of that square is set to the colour of its neighbour.

So then you start filling in pixels on the right-hand-side of that character cell, and it looks like it's neighbouring character square is moving into it one pixel at a time.

As I say, knowing this you can paint a big 'PlaySchool' style (child's drawing) house and road using only PAPER attributes, then make the whole thing pixel-scroll to the left.
Bizzley
Microbot
Posts: 124
Joined: Thu Nov 16, 2017 10:47 am

Re: Just a little head-scratcher

Post by Bizzley »

If you start the code from 32771 instead of 32768 (or zero out the first three bytes) you'll remove the Call to the routine that initially draws the attributes, then you can see the raw pixel data being redrawn behind the scenes every loop.
"He made eloquent speeches to an audience consisting of a few depressed daffodil roots, and sometimes the cat from next door."
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: Just a little head-scratcher

Post by R-Tape »

Bizzley wrote: Thu Jan 10, 2019 9:29 pm ...then you can see the raw pixel data being redrawn behind the scenes every loop.
Image
:)
Post Reply