True interlaced hires graphics

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
stefano
Posts: 568
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: True interlaced hires graphics

Post by stefano »

>However some retro computers that use a 6845 CRTC can produce a true interlaced display.

..it was my thought too, you could have an ATT 6300 super-CGA with colours and good BIOS support but a tweaked Hercules board could get up to almost the same results..
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: True interlaced hires graphics

Post by user@lab1 »

Hi, nollkolltroll.
I tried it with another image, but with poor results (The image is divided into two :shock: ).
Besides being 256x480 two-color (b/w), what other features should it have?

Mic.
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: True interlaced hires graphics

Post by nollkolltroll »

User@lab1: could you make a screenshot of the pic so I could try to understand what is happening?
Time files... but my memories of it is that you need to have it as a bmp with a 62-byte header, up-side-down and color-inverted. All of this could be handled in software of course, but this was just a proof-of-concept, not an example of a good bmp-reader.
I encourage anyone to use this as a starting point for a proper picture viewer :D
/Adam
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: True interlaced hires graphics

Post by user@lab1 »

Hi, nollkolltroll.
Here's the screenshot.
ioki.gif
ioki.gif (5.61 KiB) Viewed 5121 times
And here the .BMP image, your code and the .P executable for ZX81 emulator
ioki.zip
(19.12 KiB) Downloaded 160 times
but my memories of it is that you need to have it as a bmp with a 62-byte header, up-side-down and color-inverted.
Upside down and inverted colors is ok, as appears in lena.bmp. But is not clear how to get a 62 byte header... :?
Can you be more specific? Thanks.
Mic.
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: True interlaced hires graphics

Post by nollkolltroll »

The bmp-file has a header, which can be a different size depending on what program saved it. The picture I used had a 146-byte header, your picture uses 62 bytes. This means the picture starts in the wrong place, is shifted sideways a number of bytes.

Try changing the line: file 'oki.bmp':146
to: file 'oki.bmp':62

I haven't tried this, it's just a quick thought. Hope it works for you, let us know!
/Adam
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: True interlaced hires graphics

Post by user@lab1 »

It Works !!! :D :mrgreen:
One question: how do I know how many bytes is the header of an image?

Thanks.
Mic.
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: True interlaced hires graphics

Post by PokeMon »

Hi Mic,

you can get the size from the bitmap file header at offset 10h:
http://en.wikipedia.org/wiki/BMP_file_f ... ile_header

Karl
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: True interlaced hires graphics

Post by user@lab1 »

Thanks, Karl.
But I'm afraid of having ideas even more confused than before... :?
How do I calculate :?: the length of the header? Can you give me a practical example?

Mic.
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: True interlaced hires graphics

Post by PokeMon »

Okay - I changed the code for you to automatically detect the offset. ;)

Code: Select all

format zx81
;labelusenumeric
;LISTOFF

        // hardware options to be set and change defaults in ZX81DEF.INC
        MEMAVL     =       MEM_16K         // can be MEM_1K, MEM_2K, MEM_4K, MEM_8K, MEM_16K, MEM_32K, MEM_48K
                                           // default value is MEM_16K
        STARTMODE  EQU     SLOW_MODE       // SLOW or FAST
        DFILETYPE  EQU     COLLAPSED       // COLLAPSED or EXPANDED or AUTO
;        STARTUPMSG EQU    'ADAMS TEST'     // any message will be shown on screen after loading, max. 32 chars

        include 'SINCL-ZX\ZX81.INC'        // definitions of constants
;LISTON
AUTORUN:
        RAND USR #ENABLE_HIRES
        REM _hide _asm
scr_x_res       equ     32      ;resolution in bytes
scr_y_res       equ     240     ;nr of lines per field (because of interlace)
PAL             equ     312
NTSC            equ     262
tv_std          equ     PAL
vsync_lines     equ     3
top_blank_lines equ     (tv_std - scr_y_res - vsync_lines)/2
bottom_blank_lines      equ     tv_std - scr_y_res - vsync_lines - top_blank_lines
frame_counter   equ     $4034;scr_start
field           db      0

ENABLE_HIRES:
        LD      HL,(fileoffs)
        LD      DE,picture
        ADD     HL,DE
        LD      (scr_start),HL
        LD      IX,WRX16I       ;simple start of the hires mode
        RET

        align 32
scr_start dw 0
fileoffs:
        file 'c:\oki.bmp':10,4
picture:
        file 'c:\oki.bmp'

lbuf:   ld      a,h
        ld      i,a
        ld      a,l
        ld      r,a             ;load hfile address lsb
        repeat 32
            nop
        end repeat
        ret     nz

WRX16I:
gen_vsync0:
        repeat 33
            nop
        end repeat              ;syncronize the VSYNC-start
        in      a,($fe)         ;VSYNC on, also HSYNC off
vsync_delay0:
        repeat 130
            nop
        end repeat              ;130 NOPS=2.5 lines
prepare_top_border0:
        ld      a,top_blank_lines
        neg
        inc     a
        ex      af,af'
        ld      ix,gen_hires0
        out     ($fe),a         ;NMI-generator on
        pop     hl
        pop     de
        pop     bc
        pop     af
        ret                     ;return to do some useful work, and generate bottom blank lines

gen_vsync1:
        repeat 6
            nop
        end repeat              ;syncronize the VSYNC-start
        in      a,($fe)         ;VSYNC on, also HSYNC off
vsync_delay1:
        repeat 130
            nop
        end repeat              ;130 NOPS=2.5 lines
prepare_top_border1:
        ld      a,top_blank_lines
        neg
        inc     a
        ex      af,af'
        ld      ix,gen_hires1
        out     ($fe),a         ;NMI-generator on
        pop     hl
        pop     de
        pop     bc
        pop     af
        ret                     ;return to do some useful work, and generate bottom blank lines

gen_hires0:
        nop
        nop
        ld      b,7
hr_delay0:
        djnz    hr_delay0       ;delay to synchronize picture-start
        dec     b               ;reset Z-flag
        ld      hl,(scr_start)    ;start of hires-screen
        ld      de,scr_x_res*2
        ld      b,scr_y_res
hr10:
        call    lbuf+$8000      ;start generating the hires-screen
        add     hl,de           ;point to next hires-line
        dec     b
        jp      nz,hr10         ;repeat until last line is done
prepare_bottom_border0:
        ld      ix,gen_vsync1
field_set0:
        ld      a,bottom_blank_lines
        neg
        inc     a
        ex      af,af'
        out     ($fe),a         ;NMI-generator on
        pop     hl
        pop     de
        pop     bc
        pop     af
        ret                     ;return to do some useful work, and generate bottom blank lines

gen_hires1:
        LD      A,A
        LD      A,I
        ld      b,5
hr_delay1:
        djnz    hr_delay1       ;delay to synchronize picture-start
        dec     b               ;reset Z-flag
        ld      hl,(scr_start)    ;start of hires-screen
        ld      de,scr_x_res
        add     hl,de
        ld      de,scr_x_res*2
        ld      b,scr_y_res
hr11:
        call    lbuf+$8000      ;start generating the hires-screen
        add     hl,de           ;point to next hires-line
        dec     b
        jp      nz,hr11         ;repeat until last line is done
frame_counter_update1:
        ld      hl,(frame_counter)
        inc     hl
        ld      (frame_counter),hl
prepare_bottom_border1:
        ld      ix,gen_vsync0
field_set1:
        ld      a,bottom_blank_lines
        neg
        inc     a
        ex      af,af'
        out     ($fe),a         ;NMI-generator on
        pop     hl
        pop     de
        pop     bc
        pop     af
        ret                     ;return to do some useful work, and generate bottom blank lines
        END _asm

        include 'SINCL-ZX\ZX81POST.INC'          ; include D_FILE and needed memory areas

assert ($-MEMST)<MEMAVL
// end of program
User avatar
user@lab1
Posts: 60
Joined: Thu Apr 14, 2011 6:20 pm

Re: True interlaced hires graphics

Post by user@lab1 »

Hi Karl.
Was enough for me to know more on the header, but so it is even better. :mrgreen:
A function such as BREAK or SHIFT+BREAK to return to the cursor, would have been the icing on the cake. :D
Thanks Karl, great piece of code... 8-)
Post Reply