Timing for flash attribute

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
zx64
Manic Miner
Posts: 211
Joined: Sat Jul 11, 2020 3:25 am
Location: Australia

Timing for flash attribute

Post by zx64 »

When flash attribute is set, ink and paper are swapped every 32 frames, but is it possible to find out after which frame it happens? Just curious
Alone Coder
Manic Miner
Posts: 401
Joined: Fri Jan 03, 2020 10:00 am

Re: Timing for flash attribute

Post by Alone Coder »

Using a light gun? :)
User avatar
evilpaul
Manic Miner
Posts: 244
Joined: Tue Jul 28, 2020 8:04 am
Location: Espoo, Finland
Contact:

Re: Timing for flash attribute

Post by evilpaul »

I don't know if it's technically possible to query this from the hardware in any way - someone else might know better. If you really want to know what frame it changes on then I guess you'd need to add a user-calibration step and then keep a count in your interrupt routine

I'm interested to know if you have something in mind or if this is just technical curiosity? :)
Matt_B
Manic Miner
Posts: 659
Joined: Sun Nov 01, 2020 8:47 am

Re: Timing for flash attribute

Post by Matt_B »

So far as I know, the frame counter is internal to the ULA and there's no way to read the value of it.

Obviously it can be inferred from the video output, but there's no way for the CPU to read that on an unmodified Spectrum either.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Timing for flash attribute

Post by 1024MAK »

zx64 wrote: Wed Nov 04, 2020 5:00 am When flash attribute is set, ink and paper are swapped every 32 frames, but is it possible to find out after which frame it happens? Just curious
Simple answer: no.

There is no provision for the Z80 to access the circuitry that performs this function. The video display system in the ULA is independent from the Z80 and the only readable ULA register is the one that has the keyboard and ear (tape) data bits.

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
p13z
Manic Miner
Posts: 611
Joined: Sun Feb 17, 2019 10:41 pm
Location: UK
Contact:

Re: Timing for flash attribute

Post by p13z »

1024MAK wrote: Wed Nov 04, 2020 4:10 pm Simple answer: no.
I seem to recall this question being asked a while back in the WoS forum, and many tantalisingly clever ideas getting comprehensively dismissed.
I agree, the answer is no - unless you get the user to calibrate it by eye/keypress, or more accurately with a lightgun or such, as suggested above.
zx64
Manic Miner
Posts: 211
Joined: Sat Jul 11, 2020 3:25 am
Location: Australia

Re: Timing for flash attribute

Post by zx64 »

evilpaul wrote: Wed Nov 04, 2020 10:01 am I'm interested to know if you have something in mind or if this is just technical curiosity? :)
Just curiosity :D
zx64
Manic Miner
Posts: 211
Joined: Sat Jul 11, 2020 3:25 am
Location: Australia

Re: Timing for flash attribute

Post by zx64 »

Light guns ... They probably don't work well on LCD?
User avatar
ZXDunny
Manic Miner
Posts: 498
Joined: Tue Nov 14, 2017 3:45 pm

Re: Timing for flash attribute

Post by ZXDunny »

zx64 wrote: Thu Nov 05, 2020 4:55 am Light guns ... They probably don't work well on LCD?
Some do, some don't. None of the Speccy compatible ones do.
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Timing for flash attribute

Post by uglifruit »

I quite like the idea of (someone) being able to set up a big chunky shape that flashes Black/Colour (which would feel like on/off if on a black background). Then some detailing round the edge being drawn/erased in sync with the flashes.

Maybe leaving more processing time for doing something else (rather than it all being used on drawing/undrawing a big shape).
(Maybe there's an idea for a game there somewhere)


If it's happening every 32 frames, then maybe it would be possible to hand tweak on which frame it does it.

Flash a block, redraw the block next to it every 32 frames, and move the offset adjustment til its right.
CLEAR 23855
User avatar
Guesser
Manic Miner
Posts: 641
Joined: Wed Nov 15, 2017 2:35 pm
Contact:

Re: Timing for flash attribute

Post by Guesser »

uglifruit wrote: Thu Nov 05, 2020 10:47 am Flash a block, redraw the block next to it every 32 frames, and move the offset adjustment til its right.
That's what's meant by "user calibration"

You could have a screen at the start of the game with something like a whole line of flashing attributes, and below that another line in the same colours which you swap the colours for each cell on each of the 32 frames, and ask the user to select which one is in sync or something like that.

but if you're going to write a bunch of code to swap attributes synced to frames etc you might as well just do that for the sprite in your game and have the flexibility of whatever colours you want instead of the usually hideous ink/paper invert flash :lol:
zx64
Manic Miner
Posts: 211
Joined: Sat Jul 11, 2020 3:25 am
Location: Australia

Re: Timing for flash attribute

Post by zx64 »

Should be easy to do calibration in hardware. Have black border and full screen flashing between black and white. Take the Y component of the video out and read it back on some port. Some simple voltage divider may be needed and of course address decoding.

When entire screen is black, you always get 1 (since Y is inverted). When screen changes to white, it will start flashing between 1 and 0, so you know it's the first white frame.

For models with RGB out, just read any one color instead of Y
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: Timing for flash attribute

Post by Lethargeek »

uglifruit wrote: Thu Nov 05, 2020 10:47 am If it's happening every 32 frames, then maybe it would be possible to hand tweak on which frame it does it.
the switch is happening every 16 frames (32 is the full cycle)
uglifruit wrote: Thu Nov 05, 2020 10:47 am Flash a block, redraw the block next to it every 32 frames, and move the offset adjustment til its right.
no need for that, start/end frame is immediately visible to naked eye
here's a simple visualizer: https://cloud.mail.ru/public/3Vuq/2oKexoL99
(i was too lazy to draw actual numbers, but a grid is sufficient to show it)
Post Reply