Landover BBS - Commodore 128 & PET - since 1987
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Caps lock is activated.
Home
Forum
Help
Search
Calendar
Banlist
Downloads
Links
Login
Register
Landover BBS - Commodore 128 & PET - since 1987
»
Commodore 128 Alive!
»
128 programmers
»
BASIC
»
Topic:
PEEKing Bitmap Color?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: PEEKing Bitmap Color? (Read 866 times)
0 Members and 1 Guest are viewing this topic.
mikeebean
Guest
PEEKing Bitmap Color?
«
on:
January 10, 2009, 04:02 PM »
I'm trying to write a simple program in BASIC which plots squares on the Bitmap screen, and I've run into a snag which I haven't found an answer for.
My program uses GRAPHIC2,1 to set up a split screen, and CHAR1,X,Y," ",1 to place squares on the screen.
I want to use the PEEK command to discover the color of a square before I plot a new square over it. Locations 7168-8167 are supposed to be the bitmap color memory, but PEEKing them after a screen clear doesn't give me my expected result. I typically get a result of 16 (white bitmap on a black background) or 32 (red bitmap on a black background), when what I hoped for was 0 (black bitmap on black background).
Any thoughts would be greatly appreciated!
Michael
«
Last Edit: January 11, 2009, 07:44 AM by mikeebean
»
Logged
mikeebean
Guest
Re: PEEKing Bitmap Color?
«
Reply #1 on:
January 10, 2009, 06:28 PM »
I figured out how to do it, almost by chance;
COLOR0,1 : COLOR1,1 : GRAPHIC2,1 : COLOR1,2
I set the background and foreground colors to black, clear the text/graphics split screen, then set foreground color back to white so my text is visible.
Michael
«
Last Edit: January 11, 2009, 07:49 AM by mikeebean
»
Logged
SmallCleverDinosaur
C64 user
Posts: 310
Age: 43
Location: Stockholm
Activity:
0%
Reputation: 19
Gender:
With us since: 11/12/2008
Re: PEEKing Bitmap Color?
«
Reply #2 on:
January 10, 2009, 08:42 PM »
I think you are understanding it more or less correctly. Only a few details that you've missed
As follows:
When you do a GRAPHIC 2,1, the 2 is for setting a standard bitmap with split screen and the one is for clearing the screen. The color memory is cleared at the same time. But what does "cleared" mean in this situation? The bitmap data is cleared, i.e filled with zeroes. The colordata are also cleared but the computer has to know what a "cleared" color is supposed to be.
And that's decided by the previously issued COLOR command. If no COLOR command has been issued the clearing of the color memory uses the default colors of the C128 screen which is a grey background (or dark grey, as opposed to medium grey and light grey which also exist) with light green characters.
The color information at 7168 ($1C00) is stored like this; the first 4 bits of each byte contains the foreground color of each pixel and the last 4 bits contains the background color. So, if no COLOR command has been issued, the color memory is being cleared with the value 219 ($DB). In binary this is 11011011. So the foreground will be set to 1101 (13) and the background to 1011 (11). 13 and 11 are light green and dark grey respectively.
Mapping the C128
is one of the greatest books for the C128 ever. It explains all this in detail. Have a look at page 345, there are the bitmap modes described. (Note that the pagenumbers in the original scan of the book doesn't correspond to the pages in the pdf-file).
Logged
Ignorance is a precious thing. Once lost, it can never be regained.
mikeebean
Guest
Re: PEEKing Bitmap Color?
«
Reply #3 on:
January 11, 2009, 07:53 AM »
SmallCleverDinosaur,
Thanks, that makes sense. The System Guide just doesn't explain some things very well in my opinion. Sometimes the forums are the best place to get answers!
Michael
Logged
Edwing
Guest
Re: PEEKing Bitmap Color?
«
Reply #4 on:
May 01, 2009, 06:42 AM »
...maybe I'm thick, but you surely have a reason to use the bitmap screen for your color cards rather than using the same CHAR command in text mode?
Regards,
Edwing
Logged
mikeebean
Guest
Re: PEEKing Bitmap Color?
«
Reply #5 on:
March 07, 2010, 05:28 AM »
Edwing- The reason was I was trying to convert an Apple II PLOTting program. I wanted to use the split screen mode, so the user could type PLOT commands in the bottom section while the top section would use CHAR to place colored blocks at specified areas. -Michael
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
Landover BBS - Commodore 128 & PET - since 1987
»
Commodore 128 Alive!
»
128 programmers
»
BASIC
»
Topic:
PEEKing Bitmap Color?