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.

And that is a very precious commodity - i.e. I've just ran out, again!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)PokeMon wrote:Sure - as the display driver of Z88dk will take additional code space.
The source of the display driver is of course included in the Z88DK files and could be found inbobs wrote: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)PokeMon wrote:Sure - as the display driver of Z88dk will take additional code space.
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