Saving 360x480 Images

 BBS: Inland Empire Archive
Date: 05-20-92 (01:53)             Number: 188
From: RICH GELDREICH               Refer#: NONE
  To: MARTIN BOUCHARD               Recvd: NO  
Subj: Saving 360x480 Images          Conf: (2) Quik_Bas
Here you go! The following two subroutines will save & load 360x480
images. I made it so it would be a simple task to merge it into my GIF

'Procedures to read & write a 360x480x256 image to disk.
'By Rich Geldreich
DECLARE SUB Load360x480 ()
DECLARE SUB Save360x480 ()

SUB Load360x480
    DIM R(255), G(255), B(255)
    FOR A = 0 TO 255
         OUT &H3C7, A: OUT &H3C8, A
         OUT &H3C9, 0: OUT &H3C9, 0: OUT &H3C9, 0

    DEF SEG = &HA000

    OUT &H3C4, 2: A = INP(&H3C5)    'Save state of write mask.

    OUT &H3C4, 2: OUT &H3C5, 1      'CPU writes to first plane.
    BLOAD "plane1.bin"
    OUT &H3C4, 2: OUT &H3C5, 2      'CPU writes to second plane.
    BLOAD "plane2.bin"
    OUT &H3C4, 2: OUT &H3C5, 4      'CPU writes to third plane.
    BLOAD "plane3.bin"
    OUT &H3C4, 2: OUT &H3C5, 8      'CPU writes to fourth plane.
    BLOAD "plane4.bin"

    OUT &H3C4, 2: OUT &H3C5, A      'Restore state of write mask.


    OPEN "palette.bin" FOR BINARY AS #1
    FOR A = 0 TO 255
         GET #1, , R(A): GET #1, , G(A): GET #1, , B(A)
    CLOSE #1
    FOR A = 0 TO 255
         OUT &H3C7, A: OUT &H3C8, A
         OUT &H3C9, R(A): OUT &H3C9, G(A): OUT &H3C9, B(A)

SUB Save360x480

    DEF SEG = &HA000

    OUT &H3CE, 4: A = INP(&H3CF)    'Save state of read mask.

    OUT &H3CE, 4: OUT &H3CF, 0      'CPU reads from first plane.
    BSAVE "plane1.bin", 0, 43200    'Output (360/4)*90 bytes.
    OUT &H3CE, 4: OUT &H3CF, 1      'CPU reads from second plane.
    BSAVE "plane2.bin", 0, 43200
    OUT &H3CE, 4: OUT &H3CF, 2      'CPU reads from third plane.
    BSAVE "plane3.bin", 0, 43200
    OUT &H3CE, 4: OUT &H3CF, 3      'CPU reads from fourth plane.
    BSAVE "plane4.bin", 0, 43200

    OUT &H3CE, 4: OUT &H3CF, A      'Restore state of read mask.


    OPEN "palette.bin" FOR BINARY AS #1 'save palette now
    FOR A = 0 TO 255
         OUT &H3C7, A: OUT &H3C8, A
         R = INP(&H3C9): G = INP(&H3C9): B = INP(&H3C9)
         PUT #1, , R: PUT #1, , G: PUT #1, , B
    CLOSE #1


That's all! There are two things two note about these procedures-
they're "hardwired" for one filename and they automatically save & load
the palette for you.

The first thing you'll notice when you load in a 360x480 image with the
Load360x480 procedure is that you don't actually see the loading! I HATE
when programs let you see the image when there loading it off disk. (If
you would like to see how the loading process actually looks, just get
rid of the first four lines after the dim statement in the Load360x480
Have fun!

Rich Geldreich

--- RBBSMAIL 17.2A
 * Origin: Computer Co-Op RBBS HST, 609-784-9404 Voorhees
NJ (RBBS-PC 1:266/29)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET