Hi all!!
There's a routine to patch FD9A hook and save some extra raster lines in our games (sorry, commentaries in Spanish):
di ; Desactivamos las interrupciones
call FD9APATCHON ; Parcheamos la interrupcion
IM 1 ; Modo de interrupcion 1
ei ; Reactivamos las interrupciones
ld hl,$0303 ; COLOR ,3,3
ld [$F3EA],hl ; actualizamos las variables RAM
call INIGRP ; SCREEN 2
test: halt ; Sincronizamos con la interrupcion
ld bc,$0407 ; Color azul...
call WRTVDP ; ...de borde
ld b,8 ; 8 loops completos
waitext: ld c,b ; Guardamos el contador exterior
ld b,0 ; 256 loops internos
waitint: djnz waitint ; cerramos el bucle interior
ld b,c ; Recuperamos el contador exterior
djnz waitext ; cerramos el bucle exterior
ld bc,$0F07 ; Color blanco...
call WRTVDP ; ...de borde
jp test ; Cerramos el test
FD9APATCHON: ; --- PARCHEO DE LA INTERRUPCION ---
ld hl,FD9APATCHCODE ; Direccion del codigo del path
ld [$FD9C],hl ; Puesta en FD9C
ld hl,$C3F1 ; HL = Pop AF; JP xxxx
ld [$FD9A],hl ; Puesto en FD9A
ret ; Volvemos
FD9APATCHOFF: ; --- DESACTIVAMOS EL PARCHEO ---
ld a,$C9 ; A = Ret
ld [$FD9A],a ; Colocamos un RET en FD9A
ret ; Volvemos
FD9APATCHCODE: ; --- RUTINA DE RESTAURACION RAPIDA DE INTERRUPCION ---
in a,[$99] ; Reseteamos el bit de interrupcion
pop IX ; Restauramos IX
pop IY ; Restauramos IY
pop af ; Restauramos AF'
pop bc ; Restauramos BC'
pop de ; Restauramos DE'
pop hl ; Restauramos HL'
ex af,af' ; Cambiamos a los registros normales
exx ; Cambiamos a los registros normales
pop af ; Restauramos AF
pop bc ; Restauramos BC
pop de ; Restauramos DE
pop hl ; Restauramos HL
ei ; Reactivamos las interrupciones
ret ; Volvemos
Explanation:
On every VDP interruption the RST#38 routine first pushes all registers and after that calls to FD9A. If the path is on, before call FD9APATCHCODE, we pop the return address stored in stak. The first line of the routine clears interrupt bit. After that, pops all registers (in the correct order), and finally enables interrupts again and returns. I've tested this routine in several MSX configurations and it works perfectly, also with C-Bios.
There' also an example code to visualize the effect of the path (copy the code and test it with and without the second line). I've made two screenshoots of the result:
First image: path is off
Second image: path is on
Image explanation:
Green: screen area
Blue: time used by our code
White: time used by BIOS
Red (hand-added): interrupt free time
As you can see, there are around 16 extra free lines when path is on.
I also made an additional test: patch the BIOS to avoid the PUSH's and POP's. The minimum code needed is:
push af ; Guardamos AF
in a,[$99] ; Reseteamos el bit de interrupcion
pop af ; Restauramos AF
ei ; Reactivamos las interrupciones
ret ; Volvemos
This code gives us two additional extra lines when compared to the proposed one, but you need to have (and find) RAM on page 0 to copy and patch the BIOS.
Regards
--
SapphiRe