Autor
| stupid newbe question about INT
|
wur msx friend Mensajes: 8 | Publicado: Julio 24 2005, 07:50   |
Hello,
As far as I'm aware, the INT runs 60 times per second.
Here I've made a program that attempts to put an "a" on the screen once per second, using the int hook. The trouble is that it puts a bunch of a's on the screen, and then halts. What stupid obvious mistake am I making?
thanks!
--------------------------------------------------------------
db $fe
dw start
dw eof
dw exec
org $8800
timi: equ $fd9f ; timer interrupt hook
vidoffset: equ $98
start:
testing: db "testing interrupt... ", 0
count: db 60 ; variable to print a when it reaches zero... starts at 60, resets at 0
exec:
ld bc, &testing
call &puts
; initialize screen
ld a, $02
out (vidoffset + 1), a
ld a, $8F
out (vidoffset + 1), a
in a, (vidoffset + 1)
push af
and a, $7F
sra a
sra a
sra a
sra a
ld a, 0
out (vidoffset + 1), a
ld a, $8E
out (vidoffset + 1), a
ld a, 0
out (vidoffset + 1), a
pop af
sla a
sla a
and a, $3F
or a, $40
ld a, $40
out (vidoffset + 1), a
di
ld hl, &inter
ld de, &timi
ld bc, 5
ldir
;ld e, 20
ei
.loop: jp &.loop
.end: ret
inter:
call &print
ret
.end: ret
print:
ld a, (&count)
dec a
;ld a, d
;cp 0
jp z, &.now
ld (&count), a
ret
.now:
ld a, 'a'
out (vidoffset), a
ld a, 60
ld (&count), a
.end: ret
puts:
ld a, (bc)
cp 0
ret z
call $a2
inc bc
jp puts
.end: ret
eof:
|
|
cax
 msx master Mensajes: 1051 | Publicado: Julio 24 2005, 07:54   |
maybe you have to wait some cycles between writing to VDP port and reading from it ?
|
|
AuroraMSX
 msx master Mensajes: 1277 | Publicado: Julio 24 2005, 11:51   |
Quote:
| Hello,
As far as I'm aware, the INT runs 60 times per second.
|
That depends on a VDP setting. Register 9 holds the interrupt timing in bit 1.
If the bit is set to 0, interrupt timing is set to 60Hz (NTSC), if the bit is 1, interrrupt timing is 50Hz (PAL)
No suggestions regarding the bug, tho. Sorry  |
|
wur msx friend Mensajes: 8 | Publicado: Julio 25 2005, 00:26   |
ah well, I'll figure it out. thanks though. ^_^
|
|
dvik msx master Mensajes: 1376 | Publicado: Julio 25 2005, 01:07   |
The bug has nothing to do with the ints. Its when you set up for the vdp write. Try to put this code right before the first di:
ld a, $00
out (vidoffset + 1), a
ld a, $59
out (vidoffset + 1), a
Its something in the code between the line
; initialize screen
and
di
that is the problem.
|
|
ro msx guru Mensajes: 2353 | Publicado: Julio 25 2005, 07:31   |
setting VPD in write mode is best done just BEFORE the actual writing. And better ORG before ANYTHING
like this pseudo code:
set screen
store old int pointer
set new int pointer
main loop (wait for key to exit)
exit
:end:
new int:
check counter
when counter=0:
set vdp in write mode
write "a" to VPD
call old int
:end:
good luck
|
|
dvik msx master Mensajes: 1376 | Publicado: Julio 25 2005, 07:55   |
It is indeed much better to set the vdp in write mode before you do the actual write, not only in the beginning. For handling the ints better you can use the following code (this one for tniASM so you may need to modify it to fit your assembler):
HTMI: equ $fd9f
INTVEC_SET:
; Save current int vector
di
ld hl,HTMI
ld de,INT_RET
ld bc,5
ldir
; Add the new int vector
ld a,$c3
ld [HTMI],a
ld hl,INT_HANDLER
ld [HTMI+1],hl
ei
ret
INTVEC_RELEASE:
; Restore the old vector
di
ld hl,INT_RET
ld de,HTMI
ld bc,5
ldir
ei
INT_RET:
db 0
db 0
db 0
db 0
db 0
INT_HANDLER:
; Insert your interrupt handling here
; Call old int
jp INT_RET
So in the beginning of your program you call INTVEC_SET to insert your interrupt handler and before you terminate your program you call INTVEC_RELEASE to remove it.
|
|
ro msx guru Mensajes: 2353 | Publicado: Julio 25 2005, 08:29   |
When you do a key check in the main loop (to exit) using the keyboard buffer you HAVE to call the old (stored) interrupt on your new interrupt since the BIOS interrupt (that's the "stored" one originating for #FD9F) handelse keyboard input! else you'll 'ave a dead machine
OR use direct keyboard matrix reading (using ports) |
|
NYYRIKKI msx master Mensajes: 1533 | Publicado: Julio 25 2005, 13:48   |
No, keyboard input is not hooked to #FD9F. Usually there is just RET in #FD9F, but sometimes there might be routine to stop diskdrive or something similar. It is recommended leave 5 bytes space to end of your code (instead of RET instruction) and move the original hook to there, so that it is executed as well.
|
|
ro msx guru Mensajes: 2353 | Publicado: Julio 25 2005, 14:09   |
ah, sorry you're right. I mean LEAVE the int's on (no DI) or else #38 will not be called. FD9F is simply a HOOK which is called through the bios (#38) and usually contacins a drivestop routine indeed. thanx nyyrikki.
|
|
Sonic_aka_T
 msx guru Mensajes: 2269 | Publicado: Julio 25 2005, 20:26   |
Quick question: why don't you use the respective BIOS variables and calls?
|
|
Edwin msx professional Mensajes: 635 | Publicado: Julio 25 2005, 20:30   |
The whaaaat!?  |
|
|
|
|