What do you mean by "the Palette"?
Reading your post is slightly confusing, because at first you seem to be talking about the screen palette when you mention that screen 13 has 256 attributes, but then it seems like you switch to the actual screen pixel colors when you talk about saving the individual RGB colors of the pixels that make up the screen picture. That said, I'm not entirely sure what you're asking, so this will be a long post. Sorry. Since you said you're already familiar with OUT, hex addreses, etc., I'll just post relevant code.
BTW, take a look at Pete's collection of Palette and Colors tutorials at
http://www.petesqbsite.com/sections/tut ... cs.shtml#3 for more info.
Capturing the current palette
Code: Select all
SCREEN 13
DIM pal(255, 2) AS INTEGER
DIM attribute AS INTEGER
FOR attribute = 0 TO 255
OUT &H3C7, attribute
pal(attribute, 0) = INP(&H3C9)
pal(attribute, 1) = INP(&H3C9)
pal(attribute, 2) = INP(&H3C9)
NEXT attribute
Saving a palette to a file
Code: Select all
DIM f AS INTEGER
f = FREEFILE
OPEN "palFile" FOR BINARY AS #f
FOR attribute = 0 TO 255
PUT #f, , pal(attribute, 0)
PUT #f, , pal(attribute, 1)
PUT #f, , pal(attribute, 2)
NEXT attribute
CLOSE #f
Loading the current palette from a file
Code: Select all
f = FREEFILE
OPEN "palFile" FOR BINARY AS #f
FOR attribute = 0 TO 255
GET #f, , pal(attribute, 0)
GET #f, , pal(attribute, 1)
GET #f, , pal(attribute, 2)
NEXT attribute
CLOSE #f
Clearing the current palette
Code: Select all
FOR attribute = 0 TO 255
OUT &H3C8, attribute
OUT &H3C9, 0
OUT &H3C9, 0
OUT &H3C9, 0
NEXT attribute
Setting the current palette
Code: Select all
FOR attribute = 0 TO 255
OUT &H3C8, attribute
OUT &H3C9, pal(attribute, 0)
OUT &H3C9, pal(attribute, 1)
OUT &H3C9, pal(attribute, 2)
NEXT attribute
Changing the color of a specific palette attribute
Code: Select all
DIM red AS INTEGER, green AS INTEGER, blue AS INTEGER
attribute = 15 ' change the default white palette color
red = 63 ' use the maximum amount of red
green = 0 ' use the minimum amount of green
blue = 50 ' use a decent amount of blue
'change attribute 15 to a purplish color
OUT &H3C8, attribute
OUT &H3C9, red
OUT &H3C9, green
OUT &H3C9, blue
Getting the "color"/attribute of a particular screen pixel
Code: Select all
DIM screenPosX AS INTEGER, screenPosY AS INTEGER, screenWidth AS LONG
screenWidth = 320
screenPosX = 150
screenPosY = 100
DEF SEG = &HA000
attribute = PEEK((screenPosX - 1) + ((screenPosY - 1) * screenWidth)
DEF SEG
Setting the "color"/attribute of a particular screen pixel
Code: Select all
REDIM screenWidth AS LONG
attribute = 14 'Yellow by default
DEF SEG = &HA000
POKE((screenPosx - 1) + ((screenPosY - 1) * screenWidth), attribute)
DEF SEG
Saving the current screen to a file
Code: Select all
DIM pixelsToSave AS INTEGER, screenHeight AS LONG
screenWidth = 320
screenHeight =200
pixelsToSave = screenHeight * screenWidth
DEF SEG = &HA000
BSAVE "scrnshot.pic", 0, pixelsToSave
DEF SEG
Loading a screenshot from a file to the screen
Code: Select all
DEF SEG = &HA000
BLOAD "scrnshot.pic"
DEF SEG