Why bank >= 2 in VPOKE ?

Get help from the community & developers with the X16 hardware if you can't find the solution elsewhere
Post Reply
pshdev
Posts: 5
Joined: Wed Aug 26, 2020 11:12 am

Why bank >= 2 in VPOKE ?

Post by pshdev »


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...

 

SlithyMatt
Posts: 913
Joined: Tue Apr 28, 2020 2:45 am

Why bank >= 2 in VPOKE ?

Post by SlithyMatt »


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.

Ender
Posts: 220
Joined: Sat May 09, 2020 9:32 pm

Why bank >= 2 in VPOKE ?

Post by Ender »


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.

SlithyMatt
Posts: 913
Joined: Tue Apr 28, 2020 2:45 am

Why bank >= 2 in VPOKE ?

Post by SlithyMatt »



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.

Ender
Posts: 220
Joined: Sat May 09, 2020 9:32 pm

Why bank >= 2 in VPOKE ?

Post by Ender »



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.

TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Why bank >= 2 in VPOKE ?

Post by TomXP411 »



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. 

 

 

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

Why bank >= 2 in VPOKE ?

Post by ZeroByte »


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.

StinkerB06
Posts: 74
Joined: Tue Jun 30, 2020 12:32 am

Why bank >= 2 in VPOKE ?

Post by StinkerB06 »



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.

TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Why bank >= 2 in VPOKE ?

Post by TomXP411 »



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.

 

Post Reply