[A83] Re: Interrupt troubles [83, Ion]


[Prev][Next][Index][Thread]

[A83] Re: Interrupt troubles [83, Ion]




It doesn't look like this grayscale routine will work on the 83+ Silver
Edition if the speed boost is enabled. I would think that with C programs
you would definitely want the speed boost to be enabled.

Do you turn the interrupt off when you're done with it? That could be a very
potential problem. A few other notes:

	ld	h,a			; HL = $8787
	ld	l,a			;
	ld	(hl),$C3		; Put a JP IntProcStart at $8787

ld h,a isn't necessary. It's set from the ldir.

Be sure that you never ever make any ROM calls in your program or it will
crash. Normally you would copy the whole interrupt routine into a RAM area
to avoid this.

DI isn't necessary at the beginning of the interrupt (interrupts already
disabled), and RETI can be changed to RET at the end.

-----Original Message-----
From: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Henk Poley
Sent: Friday, July 06, 2001 4:39 AM
To: assembly-83@lists.ticalc.org
Subject: [A83] Interrupt troubles [83, Ion]



Could somebody tell me why this code interrupt code has this strange
side-effect? When you run a program with it, everything works allright, you
return back to ion, you can run other ion programs. But when you exit the
shell, you can't come back, without reinstalling Ion.

The strange thing is, I don't have this problem under Venus, everything
works correct there. And it isn't an error in the startupcode of the
program, other (non-greyscale) z88dk ion-programs run without this problem.

The code is included just a little after the ion-header, the z88dk uses a
different assembler than TASM, but you should understand the code btw.

-------
defc statvars    = $858F	; 531 bytes free $858F / $87A2
defc plotSScreen = $8E29	; 768 bytes free (normal screen buffer)
defc saveSScreen = $8265        ; 768 bytes free (APD buffer) $8265 / $8566
defc intcount    = $878A        ; 1 byte needed

; Memory usage in statvars:
;
; $858F / $85FF - 113 bytes - free
; $8600 / $8700 - 256 bytes - IV table
; $8701 / $8786 - 134 bytes - free
; $8787 / $8789 -   3 bytes - JP IntProcStart
; $878A         -   1 byte  - intcount
; $878B / $87A2 -  24 bytes - free

	im	1			;
	res	6,(iy+9)		; stats not valid
	ld	a,$86			; locate vector table at $8600-$8700
	ld	i,a			;
	ld	bc,$0100		; vector table is 256 bytes
	ld	h,a			;
	ld	l,c			; HL = $8600
	ld	d,a			;
	ld	e,b			; DE = $8601
	inc	a			; A  = $87
	ld	(hl),a			; interrupt "program" located at 8787h
	ldir				;
					;
	ld	h,a			; HL = $8787
	ld	l,a			;
	ld	(hl),$C3		; Put a JP IntProcStart at $8787
	inc	hl			;
	ld	(hl),IntProcStart&$FF	;
	inc	hl			;
	ld	(hl),IntProcStart/256	;
					;
	xor	a			;
	ld	(intcount),a		;
	jp	jump_over		; Jump over the interrupt code

;-----------------
; Actual interrupt
;-----------------
.IntProcStart
	di				;
	push	af			;
	push	hl			;
	push	de			;
	push	bc			;
					;
	in	a,(3)			; check vbl int
	and	@00000010		;
	jr	z,exit_interrupt	;
	ld	hl,intcount		; inc counter
	inc	(hl)			;
	ld	a,(hl)			;
	dec	a			; 1
	jr	z,Display_pic1		;
	dec	a			; 2
	jr	z,Display_pic2		;
	ld	(hl),0			; reset counter
.exit_interrupt				;
	in	a,(3)			; check on interrupt status
	rra				;
	ld	a,0			;
	adc	a,9			;
	out	(3),a			;
	ld	a,$0B			;
	out	(3),a			;
					;
	pop	bc			;
	pop	de			;
	pop	hl			;
	pop	af			;
	ei				;
	reti				;

.Display_pic1				;
	ld	hl,(graybit1)		;
	jr	DisplayPicture		;
.Display_pic2				;
	ld	hl,(graybit2)		;
.DisplayPicture				;
	ld	a,$80			; fastCopy routine
	out	($10),a			; (Joe Wingbermuehle)
	ld	a,$20			;
	ld	c,a			;
	ld	de,755			;
	add	hl,de			;
.fastCopyAgain				;
	ld	b,64			;
	inc	c			;
	ld	de,-(12*64)+1		;
	out	($10),a			;
	add	hl,de			;
	ld	de,10			;
.fastCopyLoop				;
	add	hl,de			;
	inc	hl			;
	inc	hl			;
	inc	de			;
	ld	a,(hl)			;
	out	($11),a			;
	dec	de			;
	djnz	fastCopyLoop		;
	ld	a,c			;
	cp	$2B+1			;
	jr	nz,fastCopyAgain	;
	jr	exit_interrupt		;

	XDEF	graybit1
	XDEF	graybit2

.graybit1	defw	plotSScreen
IF DEFINED_DontUseApdRam
.graybit2	defw	gbuf2
.gbuf2		DEFS	768
ELSE
.graybit2	defw	saveSScreen
ENDIF

.jump_over





References: