BMP2P - wilf rigter 

 

BMP2P conversion

 

You too can view your favorite BMP file in glorious black and white on a ZX81

or on the XT2 and ZX81 EMULATORS. With some experience, it will just take

a few minutes to convert the BMP file into a ZX81 compatible P file. All you

need to do is to import your image file into the WINDOWS paint program

(better yet Paint Shop Pro). Then, with a few keystrokes:

 

1. adjust brightness and contrast

2. resize to 256x192 resolution

3. reduce color depth to 2

4. dither to pseudo grey scale using the "weighted, grey values, error

   diffusion, Stucki method".

5. next FLIP the image

6. then NEGATIVE image

7. Finally, rename the IMAGE.BMP file to IMAGE.C

 

Of course you should use a particular file name instead of the generic IMAGE in

this example. At this point the image file is compatible with the ZX true hires

program. In order to make a self executing ZX hires display we must merge the

image file with the WRX16K driver and add a few lines of BASIS to autorun the

file. The simplest way to do this is with Carlo Delhez's XTender emulator.

 

 

1. Download " BMP2P" , the ZX81 hires driver program.( BMP2P.P )

2. Run EightyOne and LOAD “BMP2P”

3. Ask yourself, "Who is that handsome guy?"

4. press N/L (space) to break the spell

5. run XTenders

5. change the file name in line 20

6. load your own IMAGE.C file into the HFILE of BMP2P using LOAD "*LOAD:C:NAME:16610:"

7. then RUN to save the file to disk.

 

You have just created a self-executing ZX81 hires display file with your

favorite image which you can share with other ZX81 fans.

 

XTenders cannot be used to view this true hires file but EightyOne certainly can as can  

Xtender2 and many other ZX81 emulators.  Alternately, the hires P file can be

loaded to a ZX81 using ZXTAPE if it is equipped with a modified 16K RAMPACK as

shown below.

 

BMP2P.P file template

 

The BMP2P.P file consists of the standard format P file with the WRX16K

hires driver in a 0 REM line and a hires image file of the author in a

second 0 REM line.  A new IMAGE.C file, is prepared using the previous

described method, and merged with the BMP2P.P file by replacing the author

with the contents of the your IMAGE.C file (ouch!).

Note that the hires HFILE consists of a 62 byte header starting at 16610,

containing the BMP file format, color depth, etc information.

This header information is not used in WRX16K but is reserved for future use.

The header is followed by 6144 bytes of hires data starting at 16672 (4120).

 

WRX16K program

 

WRX16K is a very compact hires driver which displays a 256x192 bit mapped

hires screen on a ZX81/TS1000 with a modified 16K RAMPACK (see below),

32K SRAM, or on the XT2 and ZX81 emulators. The hires driver must be located

in a specific memory location in the first 0 REM basic line  and the hires

image must be located in the second 0 REM basic line.  The source code

for WRX16K is located in the 2 REM line for information only. It can be

removed to decrease the file size or replaced with your own machine code.

The hires is started with RAND USR 16516 and the BREAK (SPACE) key returns

the program to normal SINCLAIR video.

 

Create your own hires image or programs

 

Some of you may want to write your own BASIC for games or to create or modify

the 6144 byte hires image (HFILE) which starts at location 16672.

To do this, just add the additional BASIC lines as required. The hires mode is

started with RAND USR 16516 and then your BASIC program can PEEK and POKE

data into the HFILE.

Machine code programs, which will run much faster than BASIC, can be easily

created in emulators with the ARCTIC assembler. The origin of

your MC program should be set for 5928h and after assembling your source

code, the 1 REM line containing the Z80 machine code will be automatically

positioned after the two 0 REM lines. Your source code in the 2 REM line can

be removed or left for others to admire. The first byte of executable code of

your MC program will be at address 22824.

 

BMP2P.P MEMORY MAP

 

In order to control hires data from BASIC or machine code, the following

listing shows the memory location of the various parts of BMP2.P :

 

16509  407D     00 LINE NUMBER MSB - 0 REM with WRX16K code

16510  40FE     00 LINE NUMBER LSB

16511  407F     5A LINE LENGTH LSB

16512  4080     00 LINE LENGTH MSB

16513  4081     EA REM

16514  4082     76

16515  4083     76

16516  4084     DD START OF WRX16K CODE SHOWN BELOW

16517  40d7     76 END OF LINE

 

16603  40DB     00 LINE NUMBER MSB - 0 REM with HFILE

16604  40DC     00 LINE NUMBER LSB

16605  40DD     42 LINE LENGTH LSB

16606  40DE     18 LINE LENGTH MSB

16607  40DF     EA REM

16608  40E0     76

16609  40E1     76

16610  40E2     3E LENGTH OF 62 BYTES FOR HFILE HEADER

16672  4120     xx HFILE DATA - FIRST OF 32x192 BYTES

22815  591F     xx HFILE DATA - LAST BYTE

22816  5920     76 END OF LINE 

 

22817  5921     00 user MC program - 1 REM line

22818  5922     01

22819  5923     xx length

22820  5924     xx

22821  5925     EA REM

22822  5926     76

22823  5927     76

22824  5928     xx start of user machine code program

 

 

WRX16K LISTING

 

It should be an eye opener to read through the WRX16K source code because you

will see just how simple the hires video driver routine is.

What a pity that Sir Clive did not know the about the ZX81 hires capability

since it would have simplified the ZX81 and 16K rampack circuit design saving

him money and giving us hires graphics. With hires video, the ZX81 would have

given early Apple MACs a run for the money. So much for 20/20 hindsight :)

 

                                                             

                         ;WRX16K - revised June 1998

                        :original WRX16 - 1984

                        ;w.rigter

 

ORG=4084

 

HMODE LD IX,HR          ;starts the hires mode when JP (IX) is made

      RET

 

HLINE LD R,A            ;load LSB to R register which is RFSH address LSB

      0 0 0 0           ;32 NOPs = 32x8 bits = 256 pixels each HLINE

      0 0 0 0

      0 0 0 0

      0 0 0 0

      0 0 0 0

      0 0 0 0

      0 0 0 0

      0 0 0 0

      RET NZ            ;always returns because Z flag=0

 

HR   

      LD B,7            ;delay sets the left edge of the screen

HR0   DJNZ HR0          ;delay loop

      DEC B             ;make Z flag=0

      LD HL,4120        ;HL is the HFILE address pointer for each hline

      LD DE,20          ;32 bytes offset is added to HL for next hline

      LD B,C0           ;192 lines per hires screen

 

HR1   LD A,H            ;get HFILE address MSB from HL

      LD I,A            ;load MSB into I register which is RFSH address MSB

      LD A,L            ;get HFILE address LSB from HL

      CALL C089         ;CALL HLINE + 8000

      ADD HL,DE         ;add 32 to HL to point to next hline

      DEC B             ;decrement line counter

      JP NZ HR1         ;test for last line

HR2   CALL 292          ;return to application program

 

      CALL 220          ;first PUSH register, then do VSYNC and get KEYBD

      CALL F46          ;check break (space) key

      LD A,1E           ;the I register is restored with the MSB address of

      LD I,A            ;of the ROM pattern table in case of BREAK key down

 

      CALL C HMODE      ;reload HRMODE vector if no BREAK or else SINCLAIR video

HR3   JP 2A4            ;now return to BASIC and other application programs

      NOP               ;filler byte to align with HFILE start which must fall

      NOP               ;on a 32 bit boundary ie 4120h

    

             ----------------- end of listing ------------------

 

ZX81 16K RAMPACK HIRES MODIFICATION

 

The RAMPACK is modified to enable the data output at RFSH time by cutting the

RD and RFSH lines at the edge connector and installing 2 only 1N34A Ge (not Si)

diodes and a 4.7K pull-up resistor. This mod disables several chips in the 16K

RAMPACK which could have been tossed out to save manufacturing cost.

 

As always, you modify your equipment at your own risk!

 

                               +5V

                                |

                              [4.7K]

                                |

ZX connector   RD _______|/|____|_____________ RD OF RAMPACK

                         |\|    |

                                |

ZX connector RFSH _______|/|____|     +5V_____ RFSH of RAMPACK

                         |\|

 

 

 

enjoy

 

wilf