|
Post by Golan Klinger on Jun 16, 2006 20:38:14 GMT -5
A question was asked on another message board and I answered it and after doing so, I thought it might be useful to post it here. It's very simple stuff but you never know, it might come in handy for someone just starting out. The person wanted to know how to put a coloured character onto the screen so here is what I wrote:
Try this:
POKE 1024,1 POKE 55296,1
You'll end up with a white "A" in the upper left corner of the screen. The 64's screen is made up of 40 characters per line and 25 lines for a total of 1000 possible locations. 1024 is the upper left corner of the screen, 2023 is the bottom right corner. The second number is the character that will appear on the screen and that number can be between 0 and 255.
55296 is the upper left corner of colour memory, 56295 is the bottom right corner. The second number is the actual colour and that can be a number between 0 and 15. Remember that if you use the same colour as the background, you won't see anything.
To figure out what the numbers are for the various characters and colours, do some experimenting. Here's another example:
POKE 1524,26 POKE 55796,5
That will put a green Z in the middle of the screen.
|
|
|
Post by Robin Harbron on Jun 16, 2006 22:20:15 GMT -5
You'll end up with a white "A" in the upper right corner of the screen. Just so nobody is confused, the A will appear in the upper left corner. When experimenting with this, it's handy to note that the default screen and colour memory are exactly 54272 locations apart. Rather than calculating the locations twice, you can just do something like this (following from Golan's example) X=20 : Y= 12 : REM CO-ORDINATES OF MIDDLE OF SCREEN S=1024 + Y*40 + X : REM CALCULATE LOCATION TO POKE POKE S,26 POKE S+54272,5
|
|
|
Post by Golan Klinger on Jun 16, 2006 23:04:11 GMT -5
You'll end up with a white "A" in the upper right corner of the screen. Just so nobody is confused, the A will appear in the upper left corner. Thanks for catching that mistake. I'm going to correct the error in my first post lest it cause confusion. I need to proofread more carefully.
|
|
|
Post by Jeff Ledger on Jun 17, 2006 9:14:33 GMT -5
1=A .. Seemed like a silly place to stick A, then I realized that 65 was an Uppercase A and it all started to make sense. Why Commodore choose to be out of step with the rest of the world with PETSCII I'll never know.. Jeff
|
|
|
Post by metalfoot on Jun 17, 2006 9:31:50 GMT -5
Even more odd is 0=@
|
|
|
Post by Golan Klinger on Jun 17, 2006 11:35:19 GMT -5
1=A .. Seemed like a silly place to stick A, then I realized that 65 was an Uppercase A and it all started to make sense. That reminds me of something that might be worth mentioning. The 64 defaults to uppercase/graphic mode so POKE 1024,1 results in an "A" and POKE 1024,65 results in a graphic of a spade (think playing cards). If you're in lowercase/uppercase mode the 1 results in an "a" and 65 results in an "A". So, how do you get into lowercase/uppercase mode easily? POKE 53272,23 will switch to lowercase mode and poke 53272,21 will switch back to uppercase mode. It's even more inexplicable because Commodore could have used ASCII for free and if there was one thing Jack Tramiel loved more than anything, it's free stuff. Jeff: I know you know this stuff. I posted it on the off chance it might be new to someone.
|
|
|
Post by Golan Klinger on Jun 17, 2006 11:37:48 GMT -5
Given the importance of the @ symbol these days, the decision seems oddly prescient.
|
|
|
Post by mrloadstar on Feb 2, 2007 3:29:27 GMT -5
1=A .. Seemed like a silly place to stick A, then I realized that 65 was an Uppercase A and it all started to make sense. Why Commodore choose to be out of step with the rest of the world with PETSCII I'll never know.. Jeff I believe it had to do with maximizing the efficiency of the VIC II. Screen Code is sort of like ML -- the instructions the chip needs to do its stuff. I was doing just raw calculations of what the VIC II had to accomplish 60 times a second. It is incredible. Does anyone know if the VIC II ran at 1 Mhz? That seems nigh on impossible, if I remember my numbers correctly. Dave
|
|
|
Post by tlr on Feb 4, 2007 5:26:11 GMT -5
1=A .. Seemed like a silly place to stick A, then I realized that 65 was an Uppercase A and it all started to make sense. Why Commodore choose to be out of step with the rest of the world with PETSCII I'll never know.. This is what is commonly refered to as screen codes. They pack as many printable characters as possible into 256 different symbols. It wouldn't make sense to have non-printable ones mapped, and what to do about reverse chars? AFAIK PETSCII is the commonly used name of Commodores ASCII-variant, which is a different thing.
|
|
|
Post by expertsetup on Feb 4, 2007 10:31:46 GMT -5
1=A .. Seemed like a silly place to stick A, then I realized that 65 was an Uppercase A and it all started to make sense. Why Commodore choose to be out of step with the rest of the world with PETSCII I'll never know.. Jeff I believe it had to do with maximizing the efficiency of the VIC II. Screen Code is sort of like ML -- the instructions the chip needs to do its stuff. I was doing just raw calculations of what the VIC II had to accomplish 60 times a second. It is incredible. Does anyone know if the VIC II ran at 1 MHz? That seems nigh on impossible, if I remember my numbers correctly. Dave I belive the VIC II is running at 8x the CPU. for about 8MHz. Apparently Tramiel's son designed the char set for the PET and was instructed that card suits would need to be included as card gaming was going to be facilitated. I have heard speculation that the extensive graphic chars and non compliant ASCII were to provide some relief for the lack of the PETs bitmap capabilities. I have seen some impressive char graphic images from the C64 so I guess it was a good idea. Also the chars with variable grid sizes are great on the PET for adding depth or a gray scale.
|
|
|
Post by Wonder-Boy on Mar 11, 2007 8:54:54 GMT -5
Thanks for the tip, Golan, that's really useful. I'm doing what I can with it.
PS My first post on this board
|
|
|
Post by Robin Harbron on Mar 11, 2007 12:31:46 GMT -5
PS My first post on this board Welcome phlegming! If you want, let us know more about yourself, like what kind of stuff you like coding, or whatever.
|
|
|
Post by Wonder-Boy on Mar 11, 2007 15:34:25 GMT -5
OK I will do that, but I put it in the Introduction thread
|
|
|
Post by Wonder-Boy on Mar 17, 2007 8:51:48 GMT -5
Hello, using the above information I have programmed this amazing program:
10 FOR A = 1 TO 1000 20 LET S = INT(1000*RND(1))+1 30 K=PEEK(1023+S) 40 IF K=160 THEN 90 50 POKE 1023+S,160 60 POKE 55295+S,0 70 NEXT A 80 GOTO 110 90 A=A-1 100 NEXT A 110 END
It puts a black square in a random position on the screen until the screen is all black. But when there are only few spots left it takes a very long time to fill them. This is because the program tries randomly until it finds an unfilled spot, so when there is only one spot left the probability of the program finding it with each random number is 0.001. It would be much faster to fill the screen if the program drew the 1000 positions in a random order, but never the same position twice. Does anybody have an idea about how to write such a program?
|
|
|
Post by tlr on Mar 17, 2007 9:03:23 GMT -5
It puts a black square in a random position on the screen until the screen is all black. But when there are only few spots left it takes a very long time to fill them. This is because the program tries randomly until it finds an unfilled spot, so when there is only one spot left the probability of the program finding it with each random number is 0.001. It would be much faster to fill the screen if the program drew the 1000 positions in a random order, but never the same position twice. Does anybody have an idea about how to write such a program? For this you should look up LFSR. Using this you can make a 10 bit construct that produces every number from 1-1023 in seemingly random order.
|
|