SPOKE Command

If you have feature requests, this is the place to post them. Please note your idea may already be something we have already discussed and decided against, or something we are working on privately, and we cannot be held responsible for any similarities in such instance. Whilst we cannot respond to every suggestion, your idea will be read and responded to where possible. Thank you for your input!
Post Reply
Edmond D
Posts: 489
Joined: Thu Aug 19, 2021 1:42 am

SPOKE Command

Post by Edmond D »


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.

 

 

 

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

SPOKE Command

Post by TomXP411 »



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

 

 

Ed Minchau
Posts: 503
Joined: Sat Jul 11, 2020 3:30 pm

SPOKE Command

Post by Ed Minchau »



On 1/22/2022 at 7:53 PM, Edmond D said:




Here the X and Y positions are very clear; the topmost left location has a value of 1 and 1 respectively.



That should be 0,0.

Edmond D
Posts: 489
Joined: Thu Aug 19, 2021 1:42 am

SPOKE Command

Post by Edmond D »



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 ? 

Edmond D
Posts: 489
Joined: Thu Aug 19, 2021 1:42 am

SPOKE Command

Post by Edmond D »



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.  

kelli217
Posts: 531
Joined: Sun Jul 05, 2020 11:27 pm

SPOKE Command

Post by kelli217 »


Until and unless this is implemented, I'd recommend using the PLOT routine in the KERNAL. It isn't that difficult to call it from BASIC.

I wrote a comment about this quite some time ago. 


 

Post Reply