On 01/01/2014 15:37, Andrew Park wrote:
Hi all
Happy new year lets hope we can see some more sam stuff this year.
Any idea how i can set up a line interrupt routine between 32768 and
65535? I want to change the palette twice once at line 0 and then
again on line 128.
Many thanks
Andy
Hi Andy
Happy new year. Here are some examples that work for me. Easy way is
the polling version:
StatusReg: equ 249
LineIntBit: equ 0
WaitLine:
out (StatusReg),a
Loop:
in a,(StatusReg)
bit LineIntBit,a
ret z
jp nz,Loop
Test:
ld a,0
call WaitLine
;...
ld a,128
call WaitLine
;...
ret
This works fine if you have full control over the computer. But it's
not a fully automatic interrupt mode, so has a bunch of waiting around.
Interrupt Mode 1 will jump to 00056 - no good for you. IM0 is designed
for an external device interrupt request, usually an RST, which is in
the 00000-32767 range). So IM2 is your other option. If you haven't
worked with it before it's worth reading Steve Taylor's assembly
language tutorial (16 on this page: http://sam.speccy.cz/coding.html).
Here's an example where the interrupt is called every line.
org 32768
dump 1,0
SetupIM2:
di ; Disable interrupts
im 2 ; Set mode
ld a,129 ; Set I register between
128-254 (not 255 as this will wrap onto 00000-32767 page)
ld i,a
; Write jump table (257 bytes of byte x at I*256)
ld h,a
ld l,0
ld (hl),130
ld d,h
ld e,1
ld bc,256
ldir
ei ; Enable interrupts
xor a ; Set initial line interrupt
value
out (StatusReg),a
Loop:
;... rest of your program
halt
jp Loop
; Put your interrupt routine at x*256+x
org 33410
dump 1,33410-32768
IntRout:
di
ld a,(Line+1)
and 127
ld bc,248
out (c),a
Line: ld a,0
out (StatusReg),a
inc a
cp 192
jp nz,SkipReset
xor a
SkipReset:
ld (Line+1),a
ei
reti
In your routine you will want to be more careful with saving registers
so returning to normal program flow won't corrupt registers. Also, I
didn't check the interrupt type (by doing in a,(249); bit 0,a), so this
will mess up if the mouse is installed, or MIDI data is being transferred.
I notice the MIDI support in SimCoupé is missing.... have I missed an
update maybe? Or is there any schedule for this? I only ask because
I've been tinkering with SAM music lately and I'm convinced the quality
of the standard chip music on the SAM would vastly improve with better UI...
Hope this helps
Howard
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com