Jump to content
  • 0
pshdev

Why bank >= 2 in VPOKE ?

Question

Posted (edited)

I'm learning VERA hardware programming, mainly in assembler but via BASIC where investigation may help.

In BASIC the VPOKE command pokes video ram. But I'm unsure about the bank parameter. Experimenting with

      VPOKE bank, address, 1

it looks like valid values are: 

      0 <= bank <= 255

      0 <= address <= 65535

But VERA only has 128k RAM, right? So are banks 0 and 1 only used at present ? Are bank values >= 2 superfluous ?

I'm just trying to understand how the hardware works and the fact that BASIC doesn't complain if bank >= 2 made me wonder if more than 128k was available somehow...

 

Edited by pshdev

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

There used to be a bank $F (15) where the registers used to be mapped, before they got mapped to CPU RAM. But now only 0 and 1 are valid now, as the VRAM addressing is now only 17-bit.

  • Like 2

Share this post


Link to post
Share on other sites
  • 0

One thing to note, the upper 4 bits of the value you pass for the bank is used as the increment value for the VERA.  So the upper 4 bits can be any value 0-15, and the only valid value for the lower 4 bits are 0 and 1.

Also, it looks like the behavior when you try to set the lower 4 bits higher than 1 is that it simply uses the lowest bit of whatever value you set.  So if you were to set it to 2, it would make the bank 0, 3 would make it 1, etc.

  • Like 2

Share this post


Link to post
Share on other sites
  • 0
59 minutes ago, Ender said:

One thing to note, the upper 4 bits of the value you pass for the bank is used as the increment value for the VERA.  So the upper 4 bits can be any value 0-15, and the only valid value for the lower 4 bits are 0 and 1.

Also, it looks like the behavior when you try to set the lower 4 bits higher than 1 is that it simply uses the lowest bit of whatever value you set.  So if you were to set it to 2, it would make the bank 0, 3 would make it 1, etc.

This only applies when you are POKE-ing the address register at $9F22, not when using VPOKE. You can't take advantage of strides when using VPOKE - you have to specify an address every time.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
4 minutes ago, SlithyMatt said:

This only applies when you are POKE-ing the address register at $9F22, not when using VPOKE. You can't take advantage of strides when using VPOKE - you have to specify an address every time.

It's true you couldn't take advantage of the increment with continuous VPOKE's.  The only way you could is if you did one VPOKE, and then POKE'd to $9f23/4 after that.  I just thought I should point out that when you use VPOKE, the first argument is indeed changing the increment and that that's what's happening when you set something in the upper nibble, since all it's doing is storing the first argument to $9f22.

  • Like 2

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Ender said:

It's true you couldn't take advantage of the increment with continuous VPOKE's.  The only way you could is if you did one VPOKE, and then POKE'd to $9f23/4 after that.  I just thought I should point out that when you use VPOKE, the first argument is indeed changing the increment and that that's what's happening when you set something in the upper nibble, since all it's doing is storing the first argument to $9f22.

Can confirm. This works. 

10 N1=1:N2=256*60:P1=$9F23
20 C1=$32
30 VPOKE $20,N1,C1
40 FOR N=N1 TO N2 STEP 2
50 POKE P1,C1
60 NEXT

Back when the emulator first came out, we did some speed comparisons between POKE and VPOKE. The end result was that VPOKE is a little bit slower, but most of BASIC's time is spent parsing values, so replacing all numeric literals like 40739 or $9F23 with variables speeds up the loop. We also determined that hex values parse faster than decimal numbers, but it's still faster to store values in a variable. 

For example, I ran this loop 3 different ways:
50 POKE P1,C1 : 240 ticks (4 seconds)
50 POKE $9F23,C1 : 367 ticks (6.1 seconds)
50 POKE 40739,C1 : 477 ticks (7.95 seconds)

So, using a variable instead of a numeric literal can double the speed of a tight loop like this. 

Anyway, how does this compare to VPOKE?

50 VPOKE B,N,C1 :  312 (5.2 seconds)

So POKEing with an auto increment is faster, by a good 30 percent. I obviously wouln't worry about this with a small number of writes, but for situations where you need to populate the entire screen, POKEing with an increment is definitely faster. 

 

 

  • Like 5

Share this post


Link to post
Share on other sites
  • 0

I wanna say I used this functionality a while back when I was first dinking around with the system in BASIC, but I can't remember where I might've seen it specified that the bank argument also set the stride. Maybe I just discovered it playing around as I was want to do then.

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, Ender said:

One thing to note, the upper 4 bits of the value you pass for the bank is used as the increment value for the VERA.  So the upper 4 bits can be any value 0-15, and the only valid value for the lower 4 bits are 0 and 1.

Don't forget that bit 3 (value $08) is used to make the address stride decrement instead of increment.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
On 5/21/2021 at 2:27 PM, ZeroByte said:

I wanna say I used this functionality a while back when I was first dinking around with the system in BASIC, but I can't remember where I might've seen it specified that the bank argument also set the stride. Maybe I just discovered it playing around as I was want to do then.

Back when we first tested this, we just directly poked the address registers. Being able to use VPOKE as a shortcut to set the stride makes things  a lot simpler.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use