Using IX, IY.

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Using IX, IY.

Post by bobs »

Thanks for the info Siggi - I have never looked at the Z88DK as had no interest in writing for the Zeddy using C - but might take a look after this project.

I've decided that SirMorris' solution suits me the best, and that is up and running and has removed a large amount of duplicated code. :)
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Using IX, IY.

Post by PokeMon »

Sure - as the display driver of Z88dk will take additional code space. ;)
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Using IX, IY.

Post by bobs »

PokeMon wrote:Sure - as the display driver of Z88dk will take additional code space. ;)
And that is a very precious commodity - i.e. I've just ran out, again! :cry:

This'll teach me to try and fit a 48K Spectrum game into a 16k ZX81. :lol:
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Using IX, IY.

Post by bobs »

PokeMon wrote:Sure - as the display driver of Z88dk will take additional code space. ;)
Do you have the code for the display driver and setup at hand Pokemon? (Not sure if it's available to me in the Z88DK download?) Only I'm suffering an unpredictable crash from the IY usage, and so would like to try your display driver to see if it cures the problem (managed to free up some more memory so might have space for it)
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Using IX, IY.

Post by PokeMon »

No I do not have a complete driver by now as I do not use Z88dk. I plan to develop this driver in future to activate it with my ZX-IDE but it's not finished by now.
User avatar
siggi
Posts: 1043
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Using IX, IY.

Post by siggi »

bobs wrote:
PokeMon wrote:Sure - as the display driver of Z88dk will take additional code space. ;)
Do you have the code for the display driver and setup at hand Pokemon? (Not sure if it's available to me in the Z88DK download?) Only I'm suffering an unpredictable crash from the IY usage, and so would like to try your display driver to see if it cures the problem (managed to free up some more memory so might have space for it)
The source of the display driver is of course included in the Z88DK files and could be found in
C:\z88dk\lib\zx81_altint_core.def

Here it is:

Code: Select all

; ----------------------------------------------------------------------------------------
;       Modified display handler to preserve IY
;	Note: a swap between IX and IY happens "on the fly" during assembly !
; ----------------------------------------------------------------------------------------
;
;       $Id: zx81_altint_core.def,v 1.4 2011/12/28 14:04:54 stefano Exp $
;
; - - - - - - -

XDEF	MTCH_P1
XDEF	MTCH_P2

;--------------------------------------------------------------
;--------------------------------------------------------------


;; DISPLAY-1
L0229:
        LD      HL,($4034)      ; fetch two-byte system variable FRAMES.
        DEC     HL              ; decrement frames counter.

;; DISPLAY-P
L022D:  LD      A,$7F           ;
        AND     H               ;
        OR      L               ;
        LD      A,H             ;
        JR      NZ,L0237        ; to ANOTHER

        RLA                     ;
        JR      L0239           ; to OVER-NC

; ---

;; ANOTHER
L0237:  LD      B,(HL)          ;
        SCF                     ; Set Carry Flag

;; OVER-NC
L0239:  LD      H,A             ;
        LD      ($4034),HL      ; sv FRAMES_lo
        RET     NC              ;

;; DISPLAY-2
L023E:
	; push	ix          ; Siggi - No point to preserve iy here !! 
	; ld	ix,16384
	CALL    $2BB           ; routine KEYBOARD
	; pop	ix
        LD      BC,($4025)      ; sv LAST_K
        LD      ($4025),HL      ; sv LAST_K
        LD      A,B             ;
        ADD     A,$02           ;
        SBC     HL,BC           ;
        LD      A,($4027)       ; sv DEBOUNCE
        OR      H               ;
        OR      L               ;
        LD      E,B             ;
        LD      B,$0B           ;
        LD      HL,$403B        ; system variable CDFLAG
        RES     0,(HL)          ;
        JR      NZ,L0264        ; to NO-KEY

        BIT     7,(HL)          ;
        SET     0,(HL)          ;
        RET     Z               ;

        DEC     B               ;
        NOP                     ;
        SCF                     ; Set Carry Flag

;; NO-KEY
L0264:  LD      HL,$4027        ; sv DEBOUNCE
        CCF                     ; Complement Carry Flag
        RL      B               ;

;; LOOP-B
L026A:  DJNZ    L026A           ; to LOOP-B

        LD      B,(HL)          ;
        LD      A,E             ;
        CP      $FE             ;
        SBC     A,A             ;
        LD      B,$1F           ;
        OR      (HL)            ;
        AND     B               ;
        RRA                     ;
        LD      (HL),A          ;
        OUT     ($FF),A         ;
MTCH_P1:
        LD      HL,($400C)      ; sv D_FILE_lo
        SET     7,H             ;

        CALL    L0292           ; routine DISPLAY-3

; ---

;; R-IX-1
L0281:  LD      A,R             ;
MTCH_P2:
        LD      BC,$1901        ;
        LD      A,$F5           ;
        CALL    $2B5           ; routine DISPLAY-5
        DEC     HL              ;

        CALL    L0292           ; routine DISPLAY-3

; ---

;; R-IX-2
L028F:  JP      L0229           ; to DISPLAY-1

; ---

;; DISPLAY-3
L0292:  POP     IY              ; return address to IX register (-IXIY swap).
                                ; will be either L0281 or L028F - see above.
; Modified here to keep IY unchanged

	ld	a,(16424)      ; load C with MARGIN
	ld	c,a

        ld	a,(16443)      ; test CDFLAG
        and	128            ; is in FAST mode ?
        jp	z,$2a9         ; if so, jp to DISPLAY-4

        ld 	a,c
        neg
        inc	a
        ex 	af,af
        out 	($FE),a

	jp	$2A4

HTH Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Using IX, IY.

Post by bobs »

Thanks Siggi - I'd downloaded it last night and found it.

I'm pretty sure now though that my crash-issue is located elsewhere.
User avatar
stefano
Posts: 597
Joined: Tue Dec 11, 2012 9:24 am
Contact:

Re: Using IX, IY.

Post by stefano »

Note that, if you're using that code with a different assembler then you need to edit it and hand-swap IX and IY.
The reason for that is that a lot z88dk libs depend on IX which is highlt critical on the zx81. Thus created the z80asm tweak parameter "-IXIY" which is always active when the 'kit' does zx81 stuff.. so everything, including the startup code gets the IX and IY related instructions inverted. This is not necessary with the ZX80 (did someone ever post a feedback on the ZX80 port ? ;) )
User avatar
bobs
Posts: 325
Joined: Thu Aug 27, 2009 10:49 pm
Location: UK
Contact:

Re: Using IX, IY.

Post by bobs »

Ended up using SirMorris' solution in the end - works a treat! :)
Post Reply