1

Guys,

can you have a look:

http://www.atariage.com/forums/index.ph … p;id=91812

I have implemented own IRQ but it now crashes when DLI + Key is pressed. I know that it will jump directly to $cxxx as the vectors are still set to that adress space but maybe you can help me what i am doing wrong

;switch off OS rom routine by Hiassoft        
switch_off_os_rom: 
            sei 
            ldy #0 
            sty $d400 
            sty $d40e 
            sty si 
            lda #$c0 
            sta si+1 
ROMMV       lda (si),Y 
            dec $d301 
            sta (si),Y 
            inc $d301 
            iny 
            bne ROMMV 
            inc si+1 
            lda si+1 
            beq ROMOK 
            cmp #$d0 
            bne ROMMV 
            lda #$d8 
            sta si+1 
            bne ROMMV 
ROMOK       dec $d301;switch off ROM 
            lda #<nmi
            sta $fffa
            lda #>nmi
            sta $fffb
            lda #<null_irq
            sta $fffc
            lda #>null_irq
            sta $fffd
;            inc $d301;exit with ROM/OS on
            lda #$40 
            sta $d40e 
            cli 
            rts
                    
;NMI routine
;^4f==#$5f if VBLKI
;^4f==#$9f if DLI
nmi:    bit    $d40f
        bpl    sys_vbl
;DLI routine, e.g.
        jmp (dliv)

;VBL routine, e.g.
sys_vbl:    pha
            txa:pha
            tya:pha
            dec 540        ;just a simple counter
            lda 559
            sta $d400
            lda 560
            sta $d402
            lda 561
            sta $d403
            lda 756
            sta $d409
            lda $d409
            sta 764
            lda 704
            sta $d012
            lda 705
            sta $d013
            lda 706
            sta $d014
            lda 707
            sta $d015
            lda 708
            sta $d016
            lda 709
            sta $d017
            lda 710
            sta $d018
            lda 711
            sta $d019
            lda 712
            sta $d01a
            lda $d300           ;prepare joystick
            and #$0f
            sta stick0
            jsr vbl
            pla:tay
            pla:tax
            pla
null_irq:    rti

2 Ostatnio edytowany przez tebe (2007-12-29 00:16:12)

nie brakuje tam STA $D40F? czy są wogóle jakieś przykre skutki braku resetowania statusu przerwania NMI?

p.s.
VKEYBD $208..$209 ($FC19) - program obsługi przerwania klawiatury

VKEYBD Tastatur-IRQ-Vektor. Das Drücken einer Taste, ausgenommen der (BREAK)-Taste, verursacht diesen IRQ. Der VKEYBD-Vektor kann zum Vorarbeiten des Tastencodes benutzt werden, bevor er durch das OS in ATASCII-Code umgewandelt wird. Dieser Vektor zeigt normalerweise auf die Tastatur-Routine des OS.

*- TeBe/Madteam
3x Atari 130XE, SDX, CPU 65816, 2x VBXE, 2x IDE Plus rev. C

3

Tebe, I am using Fox' IRQ-routine but i am not sure if he implemented proper keyboard irq handling?

4

advice: synchronize IRQ with $D40F, synchronize DLI with IRQ

irq bit $d40f
     spl
     rti
...
...  irq program

  rti

example:

    org $2000

dlist    dta d'ppp'
    dta $42+$80,a($bc40)
    :22 dta 2+$80
    dta 2
    dta $41,a(dlist)

main    lda:cmp:req 20

    sei
    mva #0 $d40e
    sta $d20e

    mva #$fe $d301

    mwa #nmi $fffa

    mwa #irq $fffe

    mva #$40 $d20e   ; only keyboard
    mva #$c0 $d40e
    cli

    jmp *


dli    pha
    lda $d40b
    sta $d01a
    pla

    cli

    rti


nmi    bit $d40f
    bpl vbl

    sei

    jmp dli
vdli    equ *-2

vbl    phr
    sta $d40f

    mwa #dlist $d402
    mva 559 $d400

    plr
    rti

irq    bit $d40f
    spl
    rti

    phr

    ldy $d209
    lda keyCode,y
    sta 764

    sta $d01a

    plr
    rti


keyCode    .array 255 .byte = $ff

    [63]:[127] = "A"
    [21]:[85]  = "B"
    [18]:[82]  = "C"
    [58]:[122] = "D"
    [42]:[106] = "E"
    [56]:[120] = "F"
    [61]:[125] = "G"
    [57]:[121] = "H"
    [13]:[77]  = "I"
    [1] :[65]  = "J"
    [5] :[69]  = "K"
    [0] :[64]  = "L"
    [37]:[101] = "M"
    [35]:[99]  = "N"
    [8] :[72]  = "O"
    [10]:[74]  = "P"
    [47]:[111] = "Q"
    [40]:[104] = "R"
    [62]:[126] = "S"
    [45]:[109] = "T"
    [11]:[75]  = "U"
    [16]:[80]  = "V"
    [46]:[110] = "W"
    [22]:[86]  = "X"
    [43]:[107] = "Y"
    [23]:[87]  = "Z"
    [33]:[97]  = " "
    [52]:[180] = $7e
    [12]:[76]  = $9b

    .enda

    run main
*- TeBe/Madteam
3x Atari 130XE, SDX, CPU 65816, 2x VBXE, 2x IDE Plus rev. C

5

Tebe...am i stupid? look...this code hangs after pressing a key (see flashing $d018) but it is 99% your code? and your one works?

stick0    = 632
        
        org $4000
        
init    jsr switch_off_os_rom

kk        lda 540
        sta $d01a
        jmp kk
        
        switch_off_os_rom: 
        lda:cmp:req 20

        sei
        mva #0 $d40e
        sta $d20e

        mva #$fe $d301

        mwa #nmi $fffa

        mwa #irq $fffe

        mva #$40 $d20e   ; only keyboard
        mva #$40 $d40e
        cli
        rts
        
;NMI routine
;^4f==#$5f if VBLKI
;^4f==#$9f if DLI
nmi:    bit $d40f
        bpl vbi

        sei
        jmp dliv
dliv    equ *-2

vbi:           phr
            sta $d40f
            dec 540            ;just a simple counter
            lda 559
            sta $d400
;            sta $d40f        ;reset IRQs
            lda 560
            sta $d402
            lda 561
            sta $d403
            lda 756
            sta $d409
            lda 704
            sta $d012
            lda 705
            sta $d013
            lda 706
            sta $d014
            lda 707
            sta $d015
            lda 708
            sta $d016
            lda 709
            sta $d017
            lda 710
            sta $d018
            lda 711
            sta $d019
            lda 712
            sta $d01a
            lda $d300            ;prepare joystick
            and #$0f
            sta stick0
;            jsr vbl
            plr
            rti

irq:    bit $d40f
        spl ;skip + BPL
        rti
        phr
        lda $d209
        sta 764
        lda 53770
        sta $d018
        plr
        rti

6 Ostatnio edytowany przez heaven (2007-12-29 20:23:25)

ah...thats happening in your code as well... the main stuff "kk" will not be executed anymore after pressing one key...why?

in your example code the "JMP *" is not executed anymore after pressing one key... it's only the DLI/VBL/IRQ but not the "interrupted code".

any ideas whats wrong?

7 Ostatnio edytowany przez tebe (2007-12-29 23:19:44)

ok, works fine

begining irq program: mva #0 $d20e

end irq program: mva #$40 $d20e

and this is it (remove SEI, CLI from VBL, DLI)


    org $2000

dlist    dta d'ppp'
    dta $42+$80,a($bc40)
    :22 dta 2+$80
    dta 2
    dta $41,a(dlist)

main
    lda:cmp:req 20

    sei
    mva #0 $d40e
    sta $d20e

    mva #$fe $d301

    mwa #nmi $fffa

    mwa #irq $fffe

    mva #$40 $d20e   ; only keyboard
    mva #$c0 $d40e
    cli

    jmp *


dli    pha
    lda $d40b
    sta $d01a
    pla
    rti


nmi    bit $d40f
    bpl vbl

    jmp dli
vdli    equ *-2

vbl    phr
    sta $d40f

    mwa #dlist $d402
    mva 559 $d400

    plr
    rti


irq    phr

    mva #0 $d20e

    ldy $d209
    lda keyCode,y
    sta 764

    sta $d01a

    mva #$40 $d20e

    plr
    rti


keyCode    .array 255 .byte = $ff

    [63]:[127] = "A"
    [21]:[85]  = "B"
    [18]:[82]  = "C"
    [58]:[122] = "D"
    [42]:[106] = "E"
    [56]:[120] = "F"
    [61]:[125] = "G"
    [57]:[121] = "H"
    [13]:[77]  = "I"
    [1] :[65]  = "J"
    [5] :[69]  = "K"
    [0] :[64]  = "L"
    [37]:[101] = "M"
    [35]:[99]  = "N"
    [8] :[72]  = "O"
    [10]:[74]  = "P"
    [47]:[111] = "Q"
    [40]:[104] = "R"
    [62]:[126] = "S"
    [45]:[109] = "T"
    [11]:[75]  = "U"
    [16]:[80]  = "V"
    [46]:[110] = "W"
    [22]:[86]  = "X"
    [43]:[107] = "Y"
    [23]:[87]  = "Z"
    [33]:[97]  = " "
    [52]:[180] = $7e
    [12]:[76]  = $9b

    .enda

    run main
*- TeBe/Madteam
3x Atari 130XE, SDX, CPU 65816, 2x VBXE, 2x IDE Plus rev. C

8

yes. seems to work...

why did you a CLI in each DLI?

9 Ostatnio edytowany przez heaven (2007-12-29 23:46:24)

ah. ;) you just gave me the answer... ;)

DANKE! :D

10

heaven napisał/a:
            lda #<null_irq
            sta $fffc
            lda #>null_irq
            sta $fffd

Eh, Heaven, Heaven. I wonder how did you wrote all this codes :)
not knowing that it's RESET not IRQ vector!!!

IRQ is FFFE-FFFF

---==<<Sc0rpi0>>==---

11

scorpio... pfff... :D i am playing around now for 2 days with this irq stuff... ;) so i even tried stupid things to get it run... (but i haven't here my ATARI Intern book so i mixed up the vectors... ;))