Von: sean rigter [rigter@cafe.net]
Gesendet: Sonntag, 21. Juni 1998 08:51
An: Multiple recipients of The ZX81 mailing list
Betreff: Re: HIRES FOR THE ZX81 and EMULATORS

Correction!

Hello everyone,

The following  is a manual method of transfering various graphics files to the

ZX compatible hires format. In this example, a BMP file was used but any other

source  file format can be converted with programs like Paint Shop Pro. So
while this is not the promised ZX Paint Shop, it is a conversion method
available now and a good outline for the requirements of a more sophisticated
automated conversion program.

           BMP2P - June 1998 by wilf rigter  <rigter@cafe.net>


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 a BMP file into a ZX81 compatible P file. All you
need to do is to import your image file into the WINDOWS paint program
or as in this example into 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  (UPSIDE DOWN)
6. and INVERT the image (NEGATIVE)
7  SAVE image in BMP format
7. and finally, rename 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. run XTenders
2. LOAD " BMP2P" , the hires driver program.
3. Ask yourself, "Who is that guy anyway?"
4. press N/L (space) to break the spell
5. change the file name in line 10
<corrected
6. load your own IMAGE.C file into HFILE using LOAD "*LOAD:C:NAME:16610:"
<corrected
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 the new version XT2
or ZX81 emulators most certainly can. 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 format

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 with XTENDER by Carlo Delhez and 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 SUPPRESSES DISPLAY OF REM CONTENTS
16515  4083     76               "
16516  4084     DD START OF WRX16K CODE SHOWN BELOW
16517  40D7     76 END OF FIRST BASIC 0 REM 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 SUPPRESSED DISPLAY OF REM CONTENTS
16609  40E1     76               "
16610  40E2     xx 62 BYTES OF HFILE HEADER - NOT USED
16672  4120     xx HFILE DATA - FIRST OF 32x192 BYTES
22815  591F     xx HFILE DATA - LAST BYTE
22816  5920     76 END OF SECOND BASIC 0 REM LINE

22817  5921     00 LINE NUMBER  - 1 REM EXAMPLE
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

WRX16K LISTING

It could be an eye opener to read through the WRX16K source code and to
appreciate just how simple the hires video driver routine is.
What a pity that Sinclair 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  - SOURCE CODE LISTING


                        ;WRX16K - revised June 1998
                        ;from the 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        ;HFILE data address
      LD DE,20          ;32 bytes offset is added to HL for each 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 pullup 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]
                             |
connector   RD _______|/|____|_____________ RD OF RAMPACK
                      |\|    |
                             |
connector RFSH _______|/|____|     +5V_____ RFSH of RAMPACK
                      |\|

enjoy

wilf

