Jump to content
  • 0

SPOKE Command


Edmond D
 Share

Question

The screen ram on the X16 has to be accessed via a VPOKE command in BASIC. While that works, it isn't rather intuitive, unlike the old Commodore system where the screen was a grid with a fixed starting address and byte wise characters and a separate colour area, again byte wise with a fixed address. 

While the VERA is an amazing piece of hardware, programming for it isn't as straight forward as the old machines, most likely given its power and the fact that it's access through I/O space. In addition the character and colour grid are 'interwoven' where  it's character location 1 (top left of screen), colour location 1, character location 2, colour, ... Another factor is the between the top line and the next line are addresses that aren't contagious. I meant to type contiguous 😜

The VPOKE command  is  VPOKE <bank>, <address>, <value>  which makes sense to those who know both the screen layout and the VERA memory map. In my programming I've got lines like VPOKE 0,(Y+5)*256+(X-2)*2, 002  which isn't extremely readable. Without typing it in can anyone easily tell whats' being set and where - character data or colour? 

What I propose is a different command to put characters on the screen that would make sense for a very novice programmer in BASIC:

SPOKE <X>, <Y>, <"CHAR">,<FG Colour>,<BG Colour>

Here the X and Y positions are very clear; the topmost left location has a value of 1 and 1 respectively. The character to set would be the first (hopefully only) character of string variable, since all theses don't have any control codes. The colour for foreground and background would be integers. A command like:

SPOKE 12, 5, "A", 4,6

Would put a red A with a blue background on the fifth line,  twelve charters from the left of the screen. It would be just that simple!

Beyond being understandable, the math for calculating exactly where the bytes (char, plus colours) need to be stored isn't in the realm of BASIC math (and its slowness.)

I've kept this simple, avoiding the two layers, since it's meant to be a very basic BASIC command aimed at the beginner programmer. Once they've mastered it, if they need to move into VPOKE and VERA they can do so.

 

 

 

Edited by Edmond D
typos :-)
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
  • Super Administrators
On 1/22/2022 at 6:53 PM, Edmond D said:

The screen ram on the X16 has to be accessed via a VPOKE command in BASIC. While that works, it isn't rather intuitive, unlike the old Commodore system where the screen was a grid with a fixed starting address and byte wise characters and a separate colour area, again byte wise with a fixed address. 

While the VERA is an amazing piece of hardware, programming for it isn't as straight forward as the old machines, most likely given its power and the fact that it's access through I/O space. In addition the character and colour grid are 'interwoven' where  it's character location 1 (top left of screen), colour location 1, character location 2, colour, ... Another factor is the between the top line and the next line are addresses that aren't contagious. I meant to type contiguous 😜

The VPOKE command  is  VPOKE <bank>, <address>, <value>  which makes sense to those who know both the screen layout and the VERA memory map. In my programming I've got lines like VPOKE 0,(Y+5)*256+(X-2)*2, 002  which isn't extremely readable. Without typing it in can anyone easily tell whats' being set and where - character data or colour? 

What I propose is a different command to put characters on the screen that would make sense for a very novice programmer in BASIC:

SPOKE <X>, <Y>, <"CHAR">,<FG Colour>,<BG Colour>

Here the X and Y positions are very clear; the topmost left location has a value of 1 and 1 respectively. The character to set would be the first (hopefully only) character of string variable, since all theses don't have any control codes. The colour for foreground and background would be integers. A command like:

SPOKE 12, 5, "A", 4,6

Would put a red A with a blue background on the fifth line,  twelve charters from the left of the screen. It would be just that simple!

Beyond being understandable, the math for calculating exactly where the bytes (char, plus colours) need to be stored isn't in the realm of BASIC math (and its slowness.)

I've kept this simple, avoiding the two layers, since it's meant to be a very basic BASIC command aimed at the beginner programmer. Once they've mastered it, if they need to move into VPOKE and VERA they can do so.

Yes, cursor positioning is sorely needed. The ideal implementation would be LOCATE, similar to Advanced BASIC and BASIC 7. 

I have added a feature request on the ROM git repo at https://github.com/commanderx16/x16-rom/issues/227

 

 

  • Thanks 1
Link to comment
Share on other sites

  • 0
On 1/22/2022 at 8:31 PM, Ed Minchau said:

That should be 0,0.

That would be fine if one was counting like a machine, but the first location for a human would be 1,1. 
 I feel going for a zero based origin wouldn't be the ideal solution for a beginner (or anyone else for that matter.) Off by one errors have probably been the BIGEST source of programming bugs, and by going with a natural numbering system just seems like the right thing to do. 

If these aren't enough fighting words, we could go in on a debate on little and big endian; culminating  in a 0 - 1 loss for one side, depending on the order 😜 

Edited by Edmond D
  • Like 1
Link to comment
Share on other sites

  • 0
On 1/22/2022 at 7:39 PM, TomXP411 said:

Yes, cursor positioning is sorely needed. The ideal implementation would be LOCATE, similar to Advanced BASIC and BASIC 7. 

I have added a feature request on the ROM git repo at https://github.com/commanderx16/x16-rom/issues/227

 

 

I hadn't seen it as a locate command that positioned a screen cursor, rather a write a character on the display command. The SPoke just hides a lot of the mental math and calculations that one needs to do with a VPoke. Weren't computers suppose to ride of those types of minimal tasks? 

However,  perhaps my suggestion might be put on the pile of nice but unimplemented, since it suggest making BASIC better than BASIC V2. The forum here is full of requests to make what ships on the X16 better than what did ship back in the 1980s on the Vic 20/C64.  

Link to comment
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.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use