Vera Layers in Assembly

Jestin

New Member
Jan 25, 2020
11
8
3
I've been trying to use the vera's two layers from assembly. I've been able to write data to veradat2 just as easily as veradat1, however they seem to behave differently. Namely, I cannot seem to set the address properly on layer 2, despite selecting it with veractrl. Running the same code on layer 1 vs layer 2 produces the following results:

1581241208022.png

Layer one appears just fine (the petscii x16 in the center), but layer 2 draws from 0,0, and also ignores my code that should take it to the next line. I was ready to assume that there was a bug in my code, and I'm simply not setting things right, when I decided to compare what I was doing to the BASIC layer demo code the x16-demo repo. I know that I've ran this just find sometime in the past, however now I get the following result:

layer_demo_error.gif

This looks suspiciously like what I'm seeing in my own code, making me suspect that the problem is with the current version of the emulator or rom. I'm using r36 for the rom and r36 for the emulator, which otherwise seems to work. Without knowing if the bug is in my own code, I don't want to spend too much time trying to find it.

Am I alone in seeing this error in the layer demo?
 
  • Like
Reactions: JustinBaldock

Jestin

New Member
Jan 25, 2020
11
8
3
After getting some sleep, I decided to wake up and see if I could find the version of the rom/emulator where the layer demo works. At r33 for both projects, things seem to work:

layer_demo_r33.gif

During these tests, I left the x16-demo repo checked out to the latest master (commit b5c4717). There are only 3 commits to the layer demo in the repository, and the most recent was was fix on October 2nd. Meanwhile, r33 of the rom and emulator came out on October 12th, so the layer demo hasn't been updated since r32 was the latest. It looks like something broke during r34. I'm going to keep looking into this, as I'd really like to understand the vera's layers.
 
  • Like
Reactions: JustinBaldock

StephenH

New Member
Feb 4, 2020
2
1
3
The last breaking change I can recall in the emulator was the addition of the VSYNC interrupt, but that shouldn't impact a program written in BASIC, and from a first-glance I'm not immediately seeing what broke it. I can't make "promises", but I'm trying to dive back into X16 programming so maybe I can check this more carefully over the weekend.

If the unofficial VERA documentation I wrote has fallen out-of-date (other than emulator release number), maybe I'll even be motivated to fix it. :p
 
  • Like
Reactions: Jestin

SlithyMatt

New Member
Sep 14, 2019
7
9
3
It sounds like you are confusing the VERA graphics layers with the memory channels. There are two of each, but there is no correlation. You can read and write from either layer with either channel.
 

StephenH

New Member
Feb 4, 2020
2
1
3
Well, as for the layer demo in BASIC, the problem seems to be the call to SYS $9000, and REM'ing it out seemed to make the demo work for me. I'm not sure why, because BASIC's not my jam. I'm about the 6502 assembly. But my guess is that SYS $9000 is attempting to execute kernal code that has been moved or otherwise doesn't exist anymore (or doesn't exist there).

Edit: In short, make the following change:
440 SYS $9000
440 REM SYS $9000
 

Jestin

New Member
Jan 25, 2020
11
8
3
@SlithyMatt, yep, I was confusing that. This explains how the FB_move_pixels function in the kernal is using veradat2. I was referencing that because it was one of the only examples of use I could find. I'll have to re-read those docs with fresh eyes, now that I realize they are talking about different things. Thanks for the tip!
 
  • Like
Reactions: StephenH