Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Saving Screen 12 as a .PCX ???
#1
Gentlemen:

I would like to save my Screen 12 as some sort of file; some have used .PCX files. I need to save and then reload the screen. The BLOAD seems too small. Is there someplace where I can find info about how to do this? Or is there a better way? .BMP? Whish would be a good way to go to and from a .BAS file?

Thank you,
Jack C.
Reply
#2
Well...you could do this:
[pseudocode]
open a file for output
open a for loop with the iterator called y, from 0 to 480
open another for loop, nested, iterator called x, from 0 to 640
scan color of pixel at current x,y
if x=480 then print the chr$(color of the pixel) to the file, including the newline character
else, print the chr$(color of the pixel) to the file, excluding the newline character (tag a ; at the end of the PRINT)
end for loop
end for loop
close the file
[/pseudocode]
And to load the screen back up:
[pseudocode]
open the file for input
open a for loop with iterator called y, from 0 to 480
INPUT one line of the file to a variable called line$
open another for loop with iterator called x, from 0 to 640
currPxVal=asc(mid$(line$,x,1)) 'read one pixel value
and (assuming you're using PSET) just PSET(x,y),currPxVal
end for loop
end for loop
close the file
[/pseudocode]
Note that I've never applied that, so I'm not positive it will work...but it should.
Also note that that comes from my scratchy knowledge of graphics programming, so there is almost certainly a much, much faster way to do that.
Good luck.
[EDIT]And not everybody around here are guys. :roll: :wink:
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
You can dump each plane to a file with BSAVE and then load them back with BLOAD...it's very fast, although you will need to use 4 separate files.

Code:
'Obviously this can be whatever you want...
Filename$ = "DEMO"

'Save a "screen 12" screen to 4 files (one for each plane) with BSAVE
DEF SEG = &HA000
FOR i = 0 TO 3
  OUT &H3CE, 4
  OUT &H3CF, i
  BSAVE Filename$ + ".SC" + LTRIM$(STR$(i)), 0, 38400
NEXT
OUT &H3CE, 4
OUT &H3CF, 0

'Load a "screen 12" screen from the 4 files with BLOAD
DEF SEG = &HA000
FOR i = 0 TO 3
  OUT &H3C4, 2
  OUT &H3C5, 2 ^ i
  BLOAD Filename$ + ".SC"+ LTRIM$(STR$(i)), 0
NEXT
OUT &H3C4, 2
OUT &H3C5, &HF
Reply
#4
Quote:if x=480 then print the chr$(color of the pixel) to the file, including the newline character

Shouldnt that be "IF x = 640"
Reply
#5
In order to store a file as PCX, it's necessary to know the RLE compression method it uses. I don't have time to outline it right now (heading out for class, yay) but I'll write something up later on for ya when I get the chance if you'd like. Smile
I'd knock on wood, but my desk is particle board.
Reply
#6
Quote:
Zack Wrote:if x=480 then print the chr$(color of the pixel) to the file, including the newline character

Shouldnt that be "IF x = 640"
Yeah, sorry about that. I'll edit it.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#7
Quote:Well...you could do this:
[pseudocode]
open a file for output
open a for loop with the iterator called y, from 0 to 480
open another for loop, nested, iterator called x, from 0 to 640
scan color of pixel at current x,y
if x=640 then print the chr$(color of the pixel) to the file, including the newline character
else, print the chr$(color of the pixel) to the file, excluding the newline character (tag a ; at the end of the PRINT)
end for loop
end for loop
close the file
[/pseudocode]
And to load the screen back up:
[pseudocode]
open the file for input
open a for loop with iterator called y, from 0 to 480
INPUT one line of the file to a variable called line$
open another for loop with iterator called x, from 0 to 640
currPxVal=asc(mid$(line$,x,1)) 'read one pixel value
and (assuming you're using PSET) just PSET(x,y),currPxVal
end for loop
end for loop
close the file
[/pseudocode]
Note that I've never applied that, so I'm not positive it will work...but it should.
Also note that that comes from my scratchy knowledge of graphics programming, so there is almost certainly a much, much faster way to do that.
Good luck.
[EDIT]And not everybody around here are guys. :roll: :wink:
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#8
"Ladies and Gentlemen":

Thanks for your answers. Plasma's solution was certainly fast; it took about 0.3 seconds to load! In contrast, a similarly complex screen 12 with .PCX required 9 seconds to load.

Unfortunately I have no formal training in Basic. The local colleges stopped offering it about the time I became interested. It would be good to know more about the various .BMP, .JPG, .PCX strengths and limitations in order to make a better informed choice. Isn't there a WOTSIT site which compares these?

Any comments on the reasons for choosing one of the styles?

Thanks for your comments and suggestions.

Regards,
Jack C.
Reply
#9
http://www.wotsit.org

if it's still up (I haven't been there lately), has a great number of technical documents on file formats and whatnot.

Umm...I still didn't do that PCX thingie. Maybe I should get offa my a$$. Smile

EDIT: Forgot to mention...few people here likely have formal training in BASIC. Most are self-taught. Smile Right now I'm taking my second "formal" class in BASIC (first one was in 9th grade high school, on C64's, something I had already used for many years), being a Visual BASIC class...I've been using VB in its many forms for many years, so it's merely for the degree. Smile
I'd knock on wood, but my desk is particle board.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)