News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

VSync help! (Sharp MZ-80A !)

Started by kelp7, 09:49, 06 February 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arnoldemu

Ok it seems you have two character sets, 1 bit in the "colour" ram chooses this.
The other bits choose the foreground and background colour.

There are some "semi-graphics". The chunky graphics Xifos is talking about.

Potentially you could re-write the colour ram each line if you wanted to achieve some interesting effects.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

Hmm, my understanding of the machine (which is only capable of displaying green & black, it's a green-screen display) is that there is an inverse video memory mapped I/O feature. This usually affects the entire screen in one go, so the whole screen goes black on green or green on black depending which I/O address you access. There is also a VGate address which allows you to turn the entire screen OFF but still keep drawing to it, then you can turn the entire screen ON again to see what was drawn (instantly). I think maybe if I can harness this VSync then I can burn NOPS to wait 8 scanlines and swap between inverse video modes, that's definitely something I want to try. Anyway, I won't take up any more of you guys' time on here with this, I know it's not very relevant :-) Thanks again so much for the help. I think I might go off and and start a blog or diary somewhere of my achievements as I go with this machine.

kelp7

Lastly, to quote from a really good book I have on the machine:


INVERSE VIDEO FACILITY (MZ80A)


The serial video train in the MZ80A is presented to the screen in exactly the same way as in the MZ80K except that the serial video train is gated with a signal (1 or 0) from a 7474 toggle. The toggle uses CS E014 and A0 to switch its output from zero to one and from one to zero. This inverts the video train and so gives the facility to have the screen display as


1. Light characters on a dark background
2. Dark characters on a light background


(Light on dark being standard)


Reading address E014H gives standard video e.g. A=PEEK($E014)
Reading address E015H gives inverse video. e.g A=PEEK($E015)


(the $E014 & $E015 are memory mapped I/O address - kelp7)

arnoldemu

it's not based on mz-700??

mz-800 seems better than the one you describe.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

It came out before the MZ-700. It's a really basic machine but it was the 2nd computer I ever owned (after the ZX81), I think I may have given myself quite a challenge with it! :-) It's this one:


http://www.old-computers.com/museum/computer.asp?st=1&c=172


I love its design but wow is it ever not geared up for games. Hence the reason I'm trying to get used to how to synchronise CRT with game code because I think some things are actually possible with this machine, they've just never been attempted. (It doesn't really have much love as a computer, very small user-base too which doesn't help)

kelp7

Also the 'graphic display' they mention on that site is wrong. It is only capable of a 'pseudo-graphic mode' of dimensions 80x50, that's only because of the special character set in the ROM which contains little squares, curves and lines etc (a bit like the default graphic characters you get on the keys on a commodore keyboard). One last word on the machine, if anyone is interested in any more about the computer, i have the manual on my mediafire account here:


http://www.mediafire.com/view/7fxd48ujn9t64ia/mz80amanual.pdf




arnoldemu

Ok looking at this you could play with the cursor, both resetting the timer, and also to set a different cursor rate?

You could perhaps generate sound using tape out (if the tape makes sound you can hear that is)

You mentioned normal/reverse so you could try and play with that too.

What is roll up/down?

What is VGATE?
May be interesting to poke that with values.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

ok, you can double buffer by using roll? or does it always move down or is it instant?

You could potentially split the screen using roll too.

perhaps changing roll mid-line?



I think you'll need to try on your machine and write crazy programs that poke various values into different places at different times to see what you can achieve.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Potentially you could do 1 bit sampled sound? by changing the timer and outputting to the sound?

Ok, quite a few things to explore...
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

Yep, thanks arnoldemu for your help and enthusiasm with my questions. I shall have to just try things out. Funnily enough with the screen roll, I've been wondering that myself very recently. It's not something I've played with before but I had just the same question as you (is it an instant flick to the new screen memory area or does it actually roll the display). 1-bit sampled sound, very interesting, not something i've ever mucked about with (sound sampling). I'm not sure I'd know where to start but perhaps you have something on your source code site, I shall take a look.


The VGATE, by the way, is quite interesting. You can switch the entire display off and keep drawing to it, then turn the display on again once drawing is complete. I've seen this used in a BASIC example but not ML. It's something else I've been wondering about, perhaps it's not synchronised with the display hardware so you could switch the display off and on at different scanlines (if code is quick enough) to create interesting effects.


Anyway, you're absolutely right, I just need to write some crazy programs to just POKE all sorts of places and try out different things. Think I'll start a proper blog or website for all this development. One day I should come back to this thread with hopefully some results if anyone's interested :-)

arnoldemu

#35
Yes, with VGATE I was thinking, what if you turned this off for a few scanlines, would the display be moved?

If yes, then you could create pixel by pixel vertical scroll.

For basic 1-bit sound. Take a sound from PC, then decide what will be "1" and what will be "0" for each sample. Then store this, 1 bit per byte. In addition, you'll need to downsample so you can play it within the restrictions of the slower hardware.

Now you have a choice, you can either program an interrupt to trigger at a fixed rate (using the 8253) or you can do the cpc way, which is to write a sample to sound hardware, wait some time using nops and repeat. CPC has to do it this way because it's interrupts are not so flexible.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

I don't know enough about playing sampled sound to even know where to start. I could convert someone else's code but i'm not sure I could start from scratch. I'm not sure I even understand the theory. I have to admit I'm no expert programmer anyway, I'm trying things out and learning as I go.


As for the interrupts on the MZ-80A, it's my current understanding that there aren't any (except for one interrupt that occurs at a 12 hour interval regarding the clock : The MZ has a proper realtime clock that you can set and presumably there is perhaps an AM/PM shift at 12 hours or something). I'd very happily be proven wrong on that though!


I am going to start playing around properly with the machine itself next week and will start writing up my experiments onto my existing website (sharpgames.atspace.com - very out of date now!). I'll let you know how I get on! Quite exciting really to be forging a new, possibly undiscovered, path on some old 8-bit hardware :-)

kelp7

Actually, I am really interested in how sampled sound works, especially when there is only a speaker that can, i think, only create square waves over three octaves. When I got my first ever PC it was about 1987 and it was an Amstrad PC1512, this had no soundcard, it just had the PC speaker for beep sounds. Now, despite how basic that was, I had a copy of Wizball for this DOS machine and I distinctly remember the title screen having digitised / sampled music playing, I remember it very well because it was so impressive... to this day I wonder how they did that but I guess a speaker is a speaker, it just pushes it's cone outwards or inwards if you give it the right voltages (presuming here). The speaker in the MZ is just an average speaker too but i wonder just how much control you could possibly have over it really... obviously you can't affect amplitude as you couldn't on the PC speaker, no idea therefore how digitised music could occur without variations in amplitude !?

arnoldemu

Quote from: kelp7 on 22:33, 07 March 14
Actually, I am really interested in how sampled sound works, especially when there is only a speaker that can, i think, only create square waves over three octaves. When I got my first ever PC it was about 1987 and it was an Amstrad PC1512, this had no soundcard, it just had the PC speaker for beep sounds. Now, despite how basic that was, I had a copy of Wizball for this DOS machine and I distinctly remember the title screen having digitised / sampled music playing, I remember it very well because it was so impressive... to this day I wonder how they did that but I guess a speaker is a speaker, it just pushes it's cone outwards or inwards if you give it the right voltages (presuming here). The speaker in the MZ is just an average speaker too but i wonder just how much control you could possibly have over it really... obviously you can't affect amplitude as you couldn't on the PC speaker, no idea therefore how digitised music could occur without variations in amplitude !?
The response of the speaker is not digital, i.e. it's not on or off, it takes time for it to move in/out.

Think that a 1 would move it in one direction, a 0 in the other.

If you played 1,0,1,0,1,0 what is the effect? Perhaps 1,1,0,0,1,1,0,0 gives a different effect.

You use this fact to make the sampled sound.

On the cpc, you can send the 1,0 to the sound chip (by using full volume or no volume), or you can send it to the cassette write (the reason is the cassette sound is mixed with the sound chip sound and sent to the internal speaker - this is why that also works).

So you need to both send the values at a specific rate AND decide what values to send.

The basic principle of sampling is that you capture the volume at a fixed rate (e.g. 40000 times per second), then you replay this back at that fixed rate.
Faster or slower will make it sound different.

Now on CPC you can do 4-bit quality samples because it has 16 volume levels in the sound chip. You can do 1 bit quality through the cassette.

If you take the speaker into account and it's response then you can make it sound higher quality.

I think there is an example of how to play 4-bit samples on my website. I don't think there is an example for 1-bit sound.

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

Wow, excellent. Thanks! So basically I have to decide what the 1 represents and what the 0 represents in the 1-bit sampling example? Do I basically pick a particular frequency for the 1 and another for the 0 ? I think on the MZ machine I can only tell it what frequency to produce from the speaker. Do I then just play the frequencies I've chosen at very small fractions of a second each? (obviously depending on the pattern of bits)

andycadley

If you want to know more about making impressive sounding 1-bit music, you could do a lot worse than check out the World Of Spectrum forums, as there are quite a lot of very knowledgeable chaps there who are very used to doing the same on the Spectrum's beeper.

kelp7

Good call! I should have thought of that! I guess because the Spectrum was one of the few popular machines I didn't really get to play around on much in my youth it didn't immediately spring to mind! Thanks for the tip!

fano

"NOP" is the perfect program : short , fast and (known) bug free

Follow Easter Egg products on Facebook !

kelp7

Quote from: arnoldemu on 09:48, 07 March 14
Yes, with VGATE I was thinking, what if you turned this off for a few scanlines, would the display be moved?

If yes, then you could create pixel by pixel vertical scroll.


You might be interested to know I have managed to get the machine up and running this evening and after a brief juddery start (the vertical hold on the CRT seemed to be jiggling about a bit, maybe because it hadn't been switched on for nigh on five years or so) I have taken the shortcut route and loaded up BASIC (rather than spend the evening getting back into using Avalon's ZEN assembler), ran a quick routine that poked a one followed by a zero into the VGate memory mapped address and, rather pleasingly, it doesn't seem to be synced at all with the display, there was quite a bit of flicker and tearing etc. So I would imagine this might mean I can turn the display on, burn some NOPs, and then turn it off to get partial displays etc :-) not sure if, like you say, the display would be shifted, rather i think it would be static and just a portion might be missing. Lots more to experiment with but am going to start up a diary on my website of my experiments and developments :-)

arnoldemu

Quote from: kelp7 on 22:16, 14 March 14

You might be interested to know I have managed to get the machine up and running this evening and after a brief juddery start (the vertical hold on the CRT seemed to be jiggling about a bit, maybe because it hadn't been switched on for nigh on five years or so) I have taken the shortcut route and loaded up BASIC (rather than spend the evening getting back into using Avalon's ZEN assembler), ran a quick routine that poked a one followed by a zero into the VGate memory mapped address and, rather pleasingly, it doesn't seem to be synced at all with the display, there was quite a bit of flicker and tearing etc. So I would imagine this might mean I can turn the display on, burn some NOPs, and then turn it off to get partial displays etc :-) not sure if, like you say, the display would be shifted, rather i think it would be static and just a portion might be missing. Lots more to experiment with but am going to start up a diary on my website of my experiments and developments :-)
Good. Try changing it many times each line and many times on the screen and at different times on the same line, gives you maximum chance to see all potential effects.
Try the same with the other hardware registers.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

#45

Had a quick go last night at trying to detect Vsync, now would you say the following code I used is okay:





LOOP:
LD A,($E002)
AND 128
JP NZ,LOOP





Does that look correct? I was umm'ing and ahh'ing over the JP NZ or whether it should be JP Z.


As background : the MZ Vsync is detectable at bit 7 (MSB) of address $E002


Would it be better to use the method at the start of this discussion? Using a Rotate Left With Carry? (instead of rotate right as it's the MSB not the LSB on the Sharp). Is the rotate method the fastest code for this task? I was just writing the program off the top of my head partly to get used to the Zen assembler I have again and also get back into Z80 (after about 5 or so years away from it).

EDIT : Obviously I realise I should have used JR rather than JP anyway!!

Thanks
kelp

arnoldemu

That code is fine.

Yes the rotate method would be slightly faster, but waiting for vsync is unlikely to be the bit of code that takes the longest.

As to if it's nz or z, depends on what the bit shows when vsync is active.

if you're not sure do this:


ld hl,buffer
ld bc,count
loop: ld a,(&e002)
and 128
ld (hl),a
inc hl
dec bc
ld a,b
or c
jr nz,loop


this will "sample"/collect the values into a buffer. you can then view the buffer. The most common value will be when vsync is not active, the least common when vsync is active.


if it's 1 when active, then you need to use JP Z to wait until it becomes 1, or if it's 0 when active, use JP NZ to wait until it becomes 0.

On CPC, it's 1/high/bit set when active. so when active, carry is set, when not active carry clear.
so JR NC, is waiting until carry becomes set and this means vsync is active.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

kelp7

That's an excellent idea, thanks, I will definitely be trying that out. Just out of interest, how does the "LD A,B" and "OR C" work? Is that part of detecting if the count's finished? Just trying to get my head 'round that bit. Loading A with the high order bits of BC and then OR'ing A with C. Perhaps I'll just dry run it myself and see how it works...

kelp7

Okay, i understand the OR C part now. heh, sorry about that small moment of idiocy. You're basically checking that both B and C have reached zero...

kelp7

Quote from: arnoldemu on 10:32, 20 March 14
this will "sample"/collect the values into a buffer. you can then view the buffer. The most common value will be when vsync is not active, the least common when vsync is active.

Well, thanks again arnoldemu. I've run that code just now on the machine and have some very interesting results in the buffer. I only have two values (as you would expect). It is either 00 hex or 80 hex. The 80 hex is the more common value! I counted around 434 recordings of 80H in the buffer with around 131 recordings of value 00H in the buffer. So I guess this means that the VSync is a little backward on this machine compared to the CPC! Thanks again for all the help. Much more to play around with now...

Powered by SMFPacks Menu Editor Mod