Screen set 1 character 32 and 96 are both space.

Basic and Machine Language

Moderator: Moderators

User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Screen set 1 character 32 and 96 are both space.

Post by Witzo »

Screen set 1 character 32 and 96 are both space.
This is probably not news for many of you, but for those rare stragglers out in the mud like me, it was an important realisation, after 25 years.
For an hour I wondered why my PEEKS for a space and inverted space somewhere on the screen came up empty.
Well, they weren't 96 or 224! They were 32 and 160!

I am amused to see someone at Commodore, long ago, made up all these funny symbols, but ran out of imagination just one short of a full set.
FD22
Vic 20 Hobbyist
Posts: 148
Joined: Mon Feb 15, 2010 12:31 pm

Post by FD22 »

Hmm, not quite getting your point on this - 32 is the standard ASCII code for a space, which is reflected accurately in PETSCII. 160 is a 'shifted' space (also known as an inverse space) and 224 is a 'Commodore' space (i.e. space pressed whilst holding the C= key). These two are PETSCII-specific.

I'm actually curious as to what code 96 or 224 looks like now. ;)

What were you trying to do which necessitated PEEKing the screen for spaces? I'm desperately trying to recall anything where code 96 or 224 might have been used to good effect that you might need to test for. Do tell!
RJBowman
Vic 20 Enthusiast
Posts: 198
Joined: Tue Oct 25, 2011 7:50 pm

Post by RJBowman »

I little secret: the codes poked to the screen to display a character are not the same as the PETSCII codes.
User avatar
eslapion
ultimate expander
Posts: 5458
Joined: Fri Jun 23, 2006 7:50 pm
Location: Canada
Occupation: 8bit addict

Re: Screen set 1 character 32 and 96 are both space.

Post by eslapion »

Witzo wrote:Well, they weren't 96 or 224! They were 32 and 160!
Just for the fun of it I started VICE and poked these values to 7680 on an unexpanded config.

32: blank space
160: reversed space
96: blank space
224: reversed space

However, pages 268 and 269 of the VIC-20's Programmer's reference guide does indicate both of these codes are spaces so I'm not exactly sure what is the big discovery here.
Be normal.
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Post by Witzo »

The discovery was just for me. And maybe others that hadn't noticed this either.
Only after 25 years I noticed that 'space' was mentioned twice in the screen poke list in the VIC user manual.
And I found out the hard way, looking for 96 in memory and then finding out eventually that it was stored as 32.
FD22
Vic 20 Hobbyist
Posts: 148
Joined: Mon Feb 15, 2010 12:31 pm

Post by FD22 »

Are you saying that you store 96 into a screen RAM location, but when you read it back it's 32? This actually sounds like a memory chip fault.

What happens if you store 64 there? Do you get 64 back, or zero? And if you store 128, do you get that back or something else?

EDIT: oh wait - are you saying you were looking for a space using code 96 as the search code, but didn't find any because they were actually stored as 32? In which case, this all makes sense - you mis-apprehended what the standard ASCII code for a space was because the PETSCII set on the VIC has '4' values for a space (32, plus three more non-standard ones).
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Post by Witzo »

FD22 wrote:Are you saying that you store 96 into a screen RAM location, but when you read it back it's 32? This actually sounds like a memory chip fault.

What happens if you store 64 there? Do you get 64 back, or zero? And if you store 128, do you get that back or something else?

EDIT: oh wait - are you saying you were looking for a space using code 96 as the search code, but didn't find any because they were actually stored as 32? In which case, this all makes sense - you mis-apprehended what the standard ASCII code for a space was because the PETSCII set on the VIC has '4' values for a space (32, plus three more non-standard ones).
Indeed it was as in your 'edit'. I first printed a hex grid to screen, and then went looking for spaces by peeking for 96, because that was the first 'space' entry in the manual that caught my eye.
Of course it drew blanks, or more exactly, 32s, because that's what the VIC uses for a printed space.
In the mean time I read up in the ref guide, the 96 space is the shifted space.

Sorry to stir up so much; I was just being confusing to myself. And then to the forum...
FD22
Vic 20 Hobbyist
Posts: 148
Joined: Mon Feb 15, 2010 12:31 pm

Post by FD22 »

Hey, it's all good - nobody gets born knowing the ASCII character set.

There will be a test at the end of the thread, however. ;)
User avatar
freshlamb
Vic 20 Dabbler
Posts: 76
Joined: Sun Apr 04, 2004 5:38 pm
Website: http://www.rufnoiz.com
Location: Prince Albert SK Can

Post by freshlamb »

Not that it makes much difference but 96 is a Shifted space. If you clear the screen press shift and space and peek(7680) (for unexpanded) it should return a 96.

The only thing that I can think of, that makes this useful, is that in ML 96 is the number for the mnemonic RTS. Some games used this for copy protection by printing a shifted space to the screen and then later JMPing to it or SYSing to it.

OH NO I've said too much ...
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Post by Witzo »

Freshlamb has informed me of the use of 96. I can now be tested.
Dusty
Vic 20 Amateur
Posts: 51
Joined: Sun Feb 13, 2011 7:43 am

Post by Dusty »

freshlamb wrote:The only thing that I can think of, that makes this useful, is that in ML 96 is the number for the mnemonic RTS. Some games used this for copy protection by printing a shifted space to the screen and then later JMPing to it or SYSing to it.
I really like the idea, although I can't spontaniously figure out, how to use it for copy protection purposes. How does the software decide to print (or not to print) a shift space to the screen (in order to JMP/JSR/SYS) there?
tlr
Vic 20 Nerd
Posts: 567
Joined: Mon Oct 04, 2004 10:53 am

Post by tlr »

Dusty wrote:I really like the idea, although I can't spontaniously figure out, how to use it for copy protection purposes. How does the software decide to print (or not to print) a shift space to the screen (in order to JMP/JSR/SYS) there?
Tape file name perhaps?
User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Post by GreyGhost »

I have used char 96 as a marker before. If I were randomly filling the screen with a certain character but didn't want parts of the screen to have that character, I would put 96's in that location. Then as the vic was choosing random locations, it would check if location had a 32 or a 96. The program would then get a new random location if a 96 was peeked.

Also works well with an invisible maze type situation. Use char 96 to draw maze walls.
Rob
User avatar
freshlamb
Vic 20 Dabbler
Posts: 76
Joined: Sun Apr 04, 2004 5:38 pm
Website: http://www.rufnoiz.com
Location: Prince Albert SK Can

Post by freshlamb »

Here's an example:

A loader pokes all the graphics in, and loads the next program. It also prints a shifted space to say the first screen location. When the second program loads, the first thing it does is a SYS7680 (for unexpanded). If that shifted space is there it does a RTS and continues with the program. If it is something else, it will try to run it as an ML program, and nothing good will happen. Again for example if the screen has 3 spaces right at the top it will read it as JSR 8224 then try to run the ML @ 8224 (where there probably isn't any memory, we're unexpanded right?) read a zero and perform a BRK. The program not run properly until there is a 96 @ 7680 or you get rid of the SYS7680.
Dusty
Vic 20 Amateur
Posts: 51
Joined: Sun Feb 13, 2011 7:43 am

Post by Dusty »

The general idea is obvious, but when you copy both the main program and the loader, the 96 will still be there. Of course you can put any characters into the screen memory that build a valid ML program, the question (to me) is how to distinguish between a legal and an illegal copy.

The idea with the shift-space in the filename is a first step in my eyes, not very effective though, if I copy the whole tape or disk.
Post Reply