GAMELEGEND 2020-04-26 23:09
What is the W in POKEW stand for
When would you use POKEW instead of POKEL do you do this when you dont have that much memory to store and or change or is there some other question
was8bit 2020-04-27 04:51
Plain PEEK POKE is one byte, ...W is 2bytes ...L is 4 bytes
I just use COPY so i can do 16 at a time, great for copying pasting character data around...
was8bit 2020-04-27 04:53 (Edited)
I use PEEK so code can respond to when a voice is finished making sounds...
There are registers for 4 voices:
$FF40 - Voice 0
$FF4C - Voice 1
$FF58 - Voice 2
$FF64 - Voice 3
Each voice occupies 12 bytes:
- Frequency low-byte
- Frequency high-byte
4 Mix to left
5 Mix to right
- Peak meter (read only)
IF PEEK($FF43)=0 THEN
... code responds when voice #0 goes quiet...
was8bit 2020-04-27 04:55
IF PEEK($FF43)>0 THEN
This code responds when voice #0 is sounding... great for sound repsonsive visual effects...
was8bit 2020-04-27 04:59
Here i use PEEK to respond to frequency and volumn of each sound :)
GAMELEGEND 2020-04-27 05:01
So this code
IF PEEK($FF43)=0 THEN
So is this when there is no sound coming from voice 0 or when voice 0 has stopped
GAMELEGEND 2020-04-27 05:02
Oh i have seen that program it is pretty cool i just never looked at the code
GAMELEGEND 2020-04-27 05:05
So is this the part that checks to see if the music is going and checks the how loud it is
FOR I=0 TO 3
IF P(I)>0 THEN
IF P(I)>0 AND SPR=0 THEN SPR=1
IF SPR>5 THEN SPR=5
FOR II=(I*10+1) TO (I*10+9)
FOR II=I*10+1 TO I*10+9
was8bit 2020-04-27 05:05
HELP shows that $FF40 is the start of data for voice#0, and lists its bytes in,order..
PEEK($FF40) and PEEK($FF41) combined is the note frequency
PEEK($FF42) is a combination of settings, tricky to parse out though
PEEK($FF43) is the current volume of the note being played on voice#0
... i have a program for this.. give me a minute to find it :)
was8bit 2020-04-27 05:07
The code you copied,,,
Actually gets the FREQUENCY, calculates it, and adjusts it for output to the visual effects, in real time...
GAMELEGEND 2020-04-27 05:08
Oops i also meant to type checks the frequency but i kind of forgot
was8bit 2020-04-27 05:09 (Edited)
Here is one of them... i will look for the others....
This one monitors VOLUME
GAMELEGEND 2020-04-27 05:10 (Edited)
So if i wanted to create one of those rhythm games i would be using PEEK and POKE and a subprogram that calculates the frequency right
But is there a way for it to know what kind of note was played mi sure there is a way right
Oh i did not realize how late it was
was8bit 2020-04-27 05:12
Oh, that one also shows frequency in the middle...
was8bit 2020-04-27 05:14
Take a really good look at the code for "SOUND MONITORING"... it should help :)
GAMELEGEND 2020-04-27 05:14 (Edited)
In about 1 or 2 days i will upload that program to this HOW TO with comments of what i think a line of code or subprogram etc does
was8bit 2020-04-27 06:51
was8bit 2020-04-27 11:21
You helped inspire a new creation :)
GAMELEGEND 2020-04-27 19:49
Alright here it is
GAMELEGEND 2020-04-28 01:09 (Edited)
When you see this in the comments
'IM GUESSING THIS IS HERE SO WHEN THE PEAK = 0 THE MUSIC STOPS BECAUSE
'BECAUSE IS MAKES FREQUENCY = 0
Just ignore it what i want to really type is
It checks to see if the peak = 0 because if the peak = 0 the frequency should also = 0
was8bit 2020-04-28 01:35 (Edited)
For "WHAT IS THE *256+PEEK FOR"
Think of it in our number system, and lets say a computer memory could only hold 3 digits, so if you had a big number like $150,500 for the price of a house, you would store in mem1=150 and in mem2=500... but the total=M1*1000+M2 or 150*1000+500 or 150,500
In real computer memory, the biggest# is 255, or 0-255, so any number bigger would require taking the big number portion and multiply it by 256 and add the smaller number portion...
was8bit 2020-04-28 01:41 (Edited)
You are correct, NX "computer" keeps the frequency # even when the volume reaches 0... i decided thwt logically at volume 0 there is no longer any frequency so i use code manually change the frequency value to 0, even though NX doesn't care, volume 0 of any fruequency is still silent...
GAMELEGEND 2020-04-28 02:04
And what is the +0 at the end for
was8bit 2020-04-28 03:23
EACH VOICE OCCUPIES 12 BYTES:
'- FREQUENCY LOW-BYTE
'- FREQUENCY HIGH-BYTE
'4 MIX TO LEFT
'5 MIX TO RIGHT
'- PEAK METER (READ ONLY)
BIT +0 = low byte frequency
BIT +1 = high byte frequency
BIT +2 = status
BIT +3 = peak
Mathematically speaking, i could have dropped the +0 has it has no mathematical significance...
But also note this line..
So, i thought of +0, +1, +2, +3 not only in terms of math, but also a mental reminder of which bit position i was referencing.... so these became "code names" for what they represented..
+3 reminded me of PEAK
+1 reminded me of HIGH BYTE
so +0 reminded me of LOW BYTE
was8bit 2020-04-28 03:28 (Edited)
I also could have rendered the math into their actual memory addresses..
But i felt showing the math would be more useful to show what i was doing, and perhaps why i was doing it, so when others explore other NX memory map addresses they could work with those as my math shows how to do it :)
Timo 2020-04-28 17:25 (Edited)
The W is for WORD, the L for LONG. These names were sometimes used for 16 and 32 bit values.
Usually you decide depending on the maximum values you can have. For example you want to store the level number: Usually it's a value always smaller than 255, so 8 bits are enough (PEEK/POKE). A score might be much higher: If your expected max value is smaller than 32000, you can use 16 bits (W), or if it's higher you should use 32 bits (L).
GAMELEGEND 2020-04-28 17:33