English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 19 June 2018, 20:27   #1
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Problems with startup, setting correct interrupts and protracker cia

I'm trying to set a correct startup basing on asm-one example code.


I've succesfully customized the NonSystemStartup example with a simple demo with sprites, however when including protracker_cia routine my system crashes


This is the first lines code snippet:


Code:
OldOpenLibrary    = -408
CloseLibrary    = -414

;096
DMADIS= %0110010111110000
DMASET= %1000000110101111
;       -FEDCBA9876543210

;   F    SET/CLR    0=clear, 1=set bits that are set to 1 below
;   E    BBUSY    Blitter busy status bit (read only)
;   D    BZERO    Blitter logic zero status bit. (read only)
;   C    -    Reserved/Unused
;   B    -    Reserved/Unused
;   A    BLTPRI    Blitter priority, 0=give every 4th cycle to CPU
;   9    DMAEN    Enable all DMA below
;   8    BPLEN    Bit plane DMA
;   7    COPEN    Copper DMA
;   6    BLTEN    Blitter DMA
;   5    SPREN    Sprite DMA
;   4    DSKEN    Disk DMA
;   3    AUD3EN    Audio channel 3 DMA
;   2    AUD2EN    Audio channel 2 DMA
;   1    AUD1EN    Audio channel 1 DMA
;   0    AUD0EN    Audio channel 0 DMA

;09a
INTENADIS=  %0101111111110111
INTENA=     %1100000000101000
;           -FEDCBA9876543210

;    F    SET/CLR    0=clear, 1=set bits that are set to 1 below
;    E    INTEN    Enable interrupts below (master toggle)
;    D    EXTER    Level 6 External interrupt
;    C    DSKSYN    Level 5 Disk Sync value found
;    B    RBF    Level 5 Receive Buffer Full (serial port)
;    A    AUD3    Level 4 Audio Interrupt channel 3
;    9    AUD2    Level 4 Audio Interrupt channel 2
;    8    AUD1    Level 4 Audio Interrupt channel 1
;    7    AUD0    Level 4 Audio Interrupt channel 0
;    6    BLIT    Level 3 Blitter Interrupt
;    5    VERTB    Level 3 Vertical Blank Interrupt
;    4    COPER    Level 3 Copper Interrupt
;    3    PORTS    Level 2 CIA Interrupt (I/O ports and timers)
;    2    SOFT    Level 1 Software Interrupt
;    1    DSKBLK    Level 1 Disk Block Finished Interuppt
;    0    TBE    Level 1 Transmit Buffer Empty Interrupt (serial port)


START:
    MOVEM.L    D0-D7/A0-A6,-(A7)    ; Put registers on stack

;***********************************
;*   CLOSE ALL SYSTEM INTERRUPTS   *
;*                                 *
;*      START DEMO INTERRUPTS      *
;***********************************

    MOVE.L    $4.W,A6            ; Exec pointer to A6
    LEA.L    GfxName(PC),A1        ; Set library pointer
    MOVEQ    #0,D0
    JSR    OldOpenLibrary(A6)    ; Open graphics.library
    MOVE.L    D0,A1            ; Use Base-pointer
    MOVE.L    $26(A1),OLDCOP1        ; Store copper1 start addr
    MOVE.L    $32(A1),OLDCOP2        ; Store copper1 start addr
    JSR    CloseLibrary(A6)    ; Close graphics library

    move.l    #SCREEN,d0    ; let D0 point to PIC
    lea    BPLPOINTERS,A1    ; let A1 point to BPLPOINTERS
    move.w    d0,6(a1)    ; copy low word of pic address to plane
    swap    d0        ; swap the the two words
    move.w    d0,2(a1)        ; copy the high word of pic address to plane

    move.l    #SPRITE,d0        ; SPRITE_1 address
    lea    SPRITEPOINTERS,a1    ; SPRITE pointer
    move.w    d0,6(a1)    ; copy L word of sprite address to pointer
    swap    d0              ; swap the the two words
    move.w    d0,2(a1)        ; copy the H word of sprite address to pointer

    
    BSR.W    SetCIAInt
    BSR    mt_init
    ST    mt_Enable
    MOVE.L    4.W,A6
    LEA    DOSname(PC),A1
    MOVEQ    #0,D0
    JSR    LVOOpenLibrary(A6)
    TST.L    D0
    BEQ.W    EXIT
    MOVE.L    D0,DosBase    
    
    
    LEA    $DFF000,A6
    MOVE.W    $1C(A6),OldInt        ; Store old INTENA
    MOVE.W    $2(A6),OldDma        ; Store old DMACON
    MOVE.W    $10(A6),OldAdk        ; Store old ADKCON

    MOVE.W    #INTENADIS,$9A(A6)    ; Disable Intena
    
    BSR.L    Wait_Vert_Blank

    MOVE.W    #DMADIS,$96(A6)        ; Clear DMA channels
    MOVE.L    #COPLIST,$80(A6)    ; Copper1 start address
    MOVE.W    #DMASET!$8200,$96(A6)    ; DMA kontrol data
    MOVE.L    $6C.W,OldInter        ; Store old inter pointer
    MOVE.L    #INTER,$6C.W        ; Set interrupt pointer

    MOVE.W    #$7FFF,$9C(A6)        ; Clear request
    CLR.W    $88(A6)            ; Start copper1
    MOVE.W    #INTENA,$9A(A6)        ; Interrupt enable

;****       Your main routine      ****


;**** Main Loop  Test mouse button ****

LOOP:
    BTST    #6,$BFE001        ; Test left mouse button
    BNE.S    LOOP

;*****************************************
;*                     *
;*   RESTORE SYSTEM INTERRUPTS ECT ECT   *
;*                     *
;*****************************************

EXIT:
    LEA    $DFF000,A6

    MOVE.W    #$7FFF,$9A(A6)        ; Disable interrupts

    BSR.S    Wait_Vert_Blank

    MOVE.W    #$7FFF,$96(A6)
    MOVE.L    OldCop1(PC),$80(A6)    ; Restore old copper1
    MOVE.L    OldCop2(PC),$84(A6)    ; Restore old copper1
    MOVE.L    OldInter(PC),$6C.W    ; Restore inter pointer
    MOVE.W    OldDma,D0        ; Restore old DMACON
    OR.W    #$8000,D0
    MOVE.W    D0,$96(A6)        
    MOVE.W    OldAdk,D0        ; Restore old ADKCON
    OR.W    #$8000,D0
    MOVE.W    D0,$9E(A6)
    MOVE.W    OldInt,D0        ; Restore inter data
    OR.W    #$C000,D0
    MOVE.W    #$7FFF,$9C(A6)
    MOVE.W    D0,$9A(A6)
    CLR.W    $88(A6)            ; Restart old copper1
    MOVEM.L    (A7)+,D0-D7/A0-A6    ; Get registers from stack
    
    RTS

;*** WAIT VERTICAL BLANK ***

Wait_Vert_Blank:
    BTST    #0,$5(A6)
    BEQ.S    Wait_Vert_Blank
.loop    BTST    #0,$5(A6)
    BNE.S    .loop
    RTS

;*** DATA AREA ***

DosBase        DC.L    0
OldInter    DC.L    0
OldCop1        DC.L    0
OldCop2        DC.L    0
OldInt        DC.W    0
OldDma        DC.W    0
OldAdk        DC.W    0


    incdir  "dh1:own/demo/my_demo/"
    include    "pt_cia_v2.3a.s"

mt_data:
    incdir  "dh1:own/mod/"
    incbin    "mod.towards"

;**********************************
;*                  *
;*    INTERRUPT ROUTINE. LEVEL 3  *
;*                  *
;**********************************

INTER:
    MOVEM.L    D0-D7/A0-A6,-(A7)    ; Put registers on stack
    LEA.L    $DFF000,A6
    MOVE.L    #SCREEN,$E0(A6)

;---  Place your interrupt routine here  ---

    bsr.s    move_stars

    MOVE.W    #$4020,$9C(A6)        ; Clear interrupt request
    MOVEM.L    (A7)+,D0-D7/A0-A6    ; Get registers from stack
    RTE

;   ..it continues

Basically I can see the first call to vblank routine but it crashes with no sound . Tried to debugging, the music starts on mt_enable but I can't go over because of copper strobe.


Can you give me some hints?
I guess I'm doing something wrong with INTENA / DMA, but I'm not sure about that..
fstarred is offline  
Old 19 June 2018, 21:36   #2
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
You need to pass the module location in A0 before you mt_init I would have thought.

So LEA mt_data,a0 before bsr mt_init

Give that a whirl, because I can't see where you're telling the Protracker routine where the module is.
Galahad/FLT is offline  
Old 19 June 2018, 21:44   #3
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
If he's using the original PT2.3 replay routine the "lea mt_data,a0" is done in mt_init. I can't see that the module is in chip memory though which explains why you don't hear anything.
StingRay is offline  
Old 20 June 2018, 10:37   #4
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Quote:
Originally Posted by StingRay View Post
If he's using the original PT2.3 replay routine the "lea mt_data,a0" is done in mt_init. I can't see that the module is in chip memory though which explains why you don't hear anything.

Such a mistake!


situation is surely improved, however I still have an issue, it's a bit odd and I want to share it with you:



There are 2 cases, starting from zero:


1. Turn on amiga with asm-one, I enable bit EXTER (D) of INTENA of the code below, assemble and run: Music starts but it looks like the VBlank is called twice or more because demo goes faster... and even worst it hangs because I'm not able to return back by clicking left mouse, so I need to restart Amiga.



2. Turn on amiga with asm-one, assemble and run code below with no changes: Demo starts but I can't hear any music. I then enable bit EXTER like above, assemble, run and it goes all ok!

Basically I'm a bit confused now , it looks like I need to run the first time with EXTER disabled before running it.



This is the updated code:


Code:
;*****************
;*   Constants   *
;*****************

OldOpenLibrary    = -408
CloseLibrary    = -414

;096
DMADIS= %0111111111111111
DMASET= %1000000110101111
;       -FEDCBA9876543210

;   F    SET/CLR    0=clear, 1=set bits that are set to 1 below
;   E    BBUSY    Blitter busy status bit (read only)
;   D    BZERO    Blitter logic zero status bit. (read only)
;   C    -    Reserved/Unused
;   B    -    Reserved/Unused
;   A    BLTPRI    Blitter priority, 0=give every 4th cycle to CPU
;   9    DMAEN    Enable all DMA below
;   8    BPLEN    Bit plane DMA
;   7    COPEN    Copper DMA
;   6    BLTEN    Blitter DMA
;   5    SPREN    Sprite DMA
;   4    DSKEN    Disk DMA
;   3    AUD3EN    Audio channel 3 DMA
;   2    AUD2EN    Audio channel 2 DMA
;   1    AUD1EN    Audio channel 1 DMA
;   0    AUD0EN    Audio channel 0 DMA

;09a
INTENADIS=  %0111100001110111
INTENA=     %1100000000101000
;           -FEDCBA9876543210

;    F    SET/CLR    0=clear, 1=set bits that are set to 1 below
;    E    INTEN    Enable interrupts below (master toggle)
;    D    EXTER    Level 6 External interrupt
;    C    DSKSYN    Level 5 Disk Sync value found
;    B    RBF    Level 5 Receive Buffer Full (serial port)
;    A    AUD3    Level 4 Audio Interrupt channel 3
;    9    AUD2    Level 4 Audio Interrupt channel 2
;    8    AUD1    Level 4 Audio Interrupt channel 1
;    7    AUD0    Level 4 Audio Interrupt channel 0
;    6    BLIT    Level 3 Blitter Interrupt
;    5    VERTB    Level 3 Vertical Blank Interrupt
;    4    COPER    Level 3 Copper Interrupt
;    3    PORTS    Level 2 CIA Interrupt (I/O ports and timers)
;    2    SOFT    Level 1 Software Interrupt
;    1    DSKBLK    Level 1 Disk Block Finished Interuppt
;    0    TBE    Level 1 Transmit Buffer Empty Interrupt (serial port)


START:
    MOVEM.L    D0-D7/A0-A6,-(A7)    ; Put registers on stack

;***********************************
;*   CLOSE ALL SYSTEM INTERRUPTS   *
;*                                 *
;*      START DEMO INTERRUPTS      *
;***********************************

    MOVE.L    $4.W,A6            ; Exec pointer to A6
    LEA.L    GfxName(PC),A1        ; Set library pointer
    MOVEQ    #0,D0
    JSR    OldOpenLibrary(A6)    ; Open graphics.library
    MOVE.L    D0,A1            ; Use Base-pointer
    MOVE.L    $26(A1),OLDCOP1        ; Store copper1 start addr
    MOVE.L    $32(A1),OLDCOP2        ; Store copper1 start addr
    JSR    CloseLibrary(A6)    ; Close graphics library

    move.l    #SCREEN,d0    ; let D0 point to PIC
    lea    BPLPOINTERS,A1    ; let A1 point to BPLPOINTERS
    move.w    d0,6(a1)    ; copy low word of pic address to plane
    swap    d0        ; swap the the two words
    move.w    d0,2(a1)        ; copy the high word of pic address to plane

    move.l    #SPRITE,d0        ; SPRITE_1 address
    lea    SPRITEPOINTERS,a1    ; SPRITE pointer
    move.w    d0,6(a1)    ; copy L word of sprite address to pointer
    swap    d0              ; swap the the two words
    move.w    d0,2(a1)        ; copy the H word of sprite address to pointer
    
    LEA    $DFF000,A6
    MOVE.W    $1C(A6),OldInt        ; Store old INTENA
    MOVE.W    $2(A6),OldDma        ; Store old DMACON
    MOVE.W    $10(A6),OldAdk        ; Store old ADKCON

    MOVE.W    #INTENADIS,$9A(A6)    ; Disable Intena
    
    BSR.L    Wait_Vert_Blank

    MOVE.W    #DMADIS,$96(A6)        ; Clear DMA channels
    MOVE.L    #COPLIST,$80(A6)    ; Copper1 start address
    MOVE.W    #DMASET!$8200,$96(A6)    ; DMA kontrol data
    MOVE.L    $6C.W,OldInter        ; Store old inter pointer
    MOVE.L    #INTER,$6C.W        ; Set interrupt pointer

    MOVE.W    #$7FFF,$9C(A6)        ; Clear request
    CLR.W    $88(A6)            ; Start copper1
    MOVE.W    #INTENA,$9A(A6)        ; Interrupt enable

    BSR.W    SetCIAInt
    BSR    mt_init
    ST    mt_Enable
    MOVE.L    4.W,A6
    LEA    DOSname(PC),A1
    MOVEQ    #0,D0
    JSR    LVOOpenLibrary(A6)
    TST.L    D0
    BEQ.W    EXIT
    MOVE.L    D0,DosBase    

;****       Your main routine      ****


;**** Main Loop  Test mouse button ****

LOOP:
    BTST    #6,$BFE001        ; Test left mouse button
    BNE.S    LOOP

;*****************************************
;*                     *
;*   RESTORE SYSTEM INTERRUPTS ECT ECT   *
;*                     *
;*****************************************

EXIT:

    move.l    4.w,a6
    move.l    dosbase(PC),a1    ; move to base library
    jsr    CloseLibrary(a6)    ; close lib library
    
    BSR    mt_end
    BSR    ResetCIAInt

    LEA    $DFF000,A6

    MOVE.W    #$7FFF,$9A(A6)        ; Disable interrupts

    BSR.S    Wait_Vert_Blank

    MOVE.W    #$7FFF,$96(A6)
    MOVE.L    OldCop1(PC),$80(A6)    ; Restore old copper1
    MOVE.L    OldCop2(PC),$84(A6)    ; Restore old copper1
    MOVE.L    OldInter(PC),$6C.W    ; Restore inter pointer
    MOVE.W    OldDma,D0        ; Restore old DMACON
    OR.W    #$8000,D0
    MOVE.W    D0,$96(A6)        
    MOVE.W    OldAdk,D0        ; Restore old ADKCON
    OR.W    #$8000,D0
    MOVE.W    D0,$9E(A6)
    MOVE.W    OldInt,D0        ; Restore inter data
    OR.W    #$C000,D0
    MOVE.W    #$7FFF,$9C(A6)
    MOVE.W    D0,$9A(A6)
    CLR.W    $88(A6)            ; Restart old copper1
    MOVEM.L    (A7)+,D0-D7/A0-A6    ; Get registers from stack
    
    RTS

;*** WAIT VERTICAL BLANK ***

Wait_Vert_Blank:
    BTST    #0,$5(A6)
    BEQ.S    Wait_Vert_Blank
.loop    BTST    #0,$5(A6)
    BNE.S    .loop
    RTS

;*** DATA AREA ***

DosBase        DC.L    0
OldInter    DC.L    0
OldCop1        DC.L    0
OldCop2        DC.L    0
OldInt        DC.W    0
OldDma        DC.W    0
OldAdk        DC.W    0


    incdir  "dh1:own/demo/my_demo/"
    include    "pt_cia_v2.3a.s"

;**********************************
;*                  *
;*    INTERRUPT ROUTINE. LEVEL 3  *
;*                  *
;**********************************

INTER:
    MOVEM.L    D0-D7/A0-A6,-(A7)    ; Put registers on stack
    LEA.L    $DFF000,A6
    MOVE.L    #SCREEN,$E0(A6)

;---  Place your interrupt routine here  ---

    bsr.s    move_stars

    MOVE.W    #$4020,$9C(A6)        ; Clear interrupt request
    MOVEM.L    (A7)+,D0-D7/A0-A6    ; Get registers from stack
    RTE



; ...
; some code

; ...


    SECTION    Music,DATA_C


mt_data:
    incdir  "dh1:own/mod/"
    incbin    "mod.towards"
fstarred is offline  
Old 20 June 2018, 10:49   #5
Galahad/FLT
Going nowhere
 
Galahad/FLT's Avatar
 
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 8,986
The end of your level 3 interrupt where you clear interrupt request looks wrong.

value usually is $20,$dff09c not $4020.

Might even be an idea to completely disable (i.e. don't install) your level 3 ($6c) interrupt until you fix the music problem.

Your INTENADIS value looks wrong as well. Your binary value in hex is $7877, to disable INTENA completely most use $7fff

Your INTENA value to reactivate interrupts converts from binary to hex as $c028. I'd try $c020, as it looks like its triggering other interrupts you don't want.

If in doubt, poke all interrupts you're not using with
move.w #$20,$dff09c
rte

That way if your INTENA value is wrong and it is activating other interrupts you don't need, then they will be handled, just remember to preserve and restore them as you've done to level 3 ($6c)

Last edited by Galahad/FLT; 20 June 2018 at 10:56.
Galahad/FLT is offline  
Old 20 June 2018, 14:40   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Galahad/FLT View Post
The end of your level 3 interrupt where you clear interrupt request looks wrong.

value usually is $20,$dff09c not $4020.

$4020 is OK too, just sets the master bit in INTENA which doesn't do any harm.



Quote:
Originally Posted by Galahad
Might even be an idea to completely disable (i.e. don't install) your level 3 ($6c) interrupt until you fix the music problem.

Yes, that's a good hint indeed. As the level 3 interrupt is not needed to replay the tune disabling it may help to spot (not so) subtle errors in the code.





Quote:
Originally Posted by Galahad
If in doubt, poke all interrupts you're not using with
move.w #$20,$dff09c
rte

That would only acknowledge the VBI. To acknowledge all interrupts move.w #$7fff,$dff09c should be used.






Quote:
Originally Posted by fstarred View Post
There are 2 cases, starting from zero:


1. Turn on amiga with asm-one, I enable bit EXTER (D) of INTENA of the code below, assemble and run: Music starts but it looks like the VBlank is called twice or more because demo goes faster... and even worst it hangs because I'm not able to return back by clicking left mouse, so I need to restart Amiga.



2. Turn on amiga with asm-one, assemble and run code below with no changes: Demo starts but I can't hear any music. I then enable bit EXTER like above, assemble, run and it goes all ok!

Basically I'm a bit confused now , it looks like I need to run the first time with EXTER disabled before running it.



You're calling SetCIAInt after the system has been killed and this will not work as the Protracker routine uses OS functions, i.e. it's system-friendly (hence you need to enable level 6 interrupts). Either call it before the OS has been disabled or recode it using the hardware.
StingRay is offline  
Old 21 June 2018, 09:56   #7
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Quote:
Might even be an idea to completely disable (i.e. don't install) your level 3 ($6c) interrupt until you fix the music problem.
Yes, the level 3 interrupt is giving me problem indeed



Quote:
Originally Posted by StingRay View Post
Yes, that's a good hint indeed. As the level 3 interrupt is not needed to replay the tune disabling it may help to spot (not so) subtle errors in the code.


You're calling SetCIAInt after the system has been killed and this will not work as the Protracker routine uses OS functions, i.e. it's system-friendly (hence you need to enable level 6 interrupts). Either call it before the OS has been disabled or recode it using the hardware.
EDIT

I tried a startup code used by bourchen , indeed it works perfectly if I disable all but level 6 interrupt before calling setCiaInt;
however it doesn't make use of level 3 interrupt which I'd like to use as a personal challenge.


Give it a look


Code:

;*****************
;*   Constants   *
;*****************

OldOpenLibrary    = -408
CloseLibrary    = -414

DMASET=       %1000001110100000
;           -----axbcdefghij ($83A0)

;    a: Blitter Nasty
;    x: DMA below on
;    b: Bitplane DMA (if this isn't set, sprites disappear!)
;    c: Copper DMA
;    d: Blitter DMA
;    e: Sprite DMA
;    f: Disk DMA
;    g-j: Audio 3-0 DMA

INTENA=        %0001111111111111
;           -FEDCBA9876543210 (1FFF)

;    F    SET/CLR    0=clear, 1=set bits that are set to 1 below
;    E    INTEN    Enable interrupts below (master toggle)
;    D    EXTER    Level 6 External interrupt
;    C    DSKSYN    Level 5 Disk Sync value found
;    B    RBF    Level 5 Receive Buffer Full (serial port)
;    A    AUD3    Level 4 Audio Interrupt channel 3
;    9    AUD2    Level 4 Audio Interrupt channel 2
;    8    AUD1    Level 4 Audio Interrupt channel 1
;    7    AUD0    Level 4 Audio Interrupt channel 0
;    6    BLIT    Level 3 Blitter Interrupt
;    5    VERTB    Level 3 Vertical Blank Interrupt
;    4    COPER    Level 3 Copper Interrupt
;    3    PORTS    Level 2 CIA Interrupt (I/O ports and timers)
;    2    SOFT    Level 1 Software Interrupt
;    1    DSKBLK    Level 1 Disk Block Finished Interuppt
;    0    TBE    Level 1 Transmit Buffer Empty Interrupt (serial port)



    SECTION    CODESECTION,CODE    ; This command will run the below code
                    ; on FAST RAM (if enough) or CHIP RAM

START:

    MOVE.L    $4.W,A6            ; Exec pointer to A6
    LEA.L    GfxName(PC),A1        ; Set library pointer to A1
    MOVEQ    #0,D0
    JSR    OldOpenLibrary(A6)    ; Open graphics.library
                    ; write to D0 the offset
    MOVE.L    D0,A1            ; Use Base-pointer
    MOVE.L    $26(A1),oldcop        ; Store copperlist system address,
                    ; retrieved $26 from glib offset
    JSR    CloseLibrary(A6)    ; Close graphics library    
    
    move.l    #SCREEN,d0    ; let D0 point to PIC
    lea    BPLPOINTERS,A1    ; let A1 point to BPLPOINTERS
    move.w    d0,6(a1)    ; copy low word of pic address to plane
    swap    d0        ; swap the the two words
    move.w    d0,2(a1)        ; copy the high word of pic address to plane

    move.l    #SPRITE,d0        ; SPRITE_1 address
    lea    SPRITEPOINTERS,a1    ; SPRITE pointer
    move.w    d0,6(a1)    ; copy L word of sprite address to pointer
    swap    d0              ; swap the the two words
    move.w    d0,2(a1)        ; copy the H word of sprite address to pointer

    move.w    $dff01c,oldint        ; save INTENAR
    move.w    $dff002,olddma        ; save DMACONR

    move.w    #INTENA,$dff09a        ; disable INTENA = turn off OS
    move.w    #$7fff,$dff09c        ; disable INTREQ
    move.w    #$7fff,$dff09c        ; twice -> amiga4000 hw bug!
    move.w    #$7fff,$dff096        ; disable DMACON

    BSR.W    SetCIAInt
    BSR    mt_init
    ST    mt_Enable
    MOVE.L    4.W,A6
    LEA    DOSname(PC),A1
    MOVEQ    #0,D0
    JSR    LVOOpenLibrary(A6)
    TST.L    D0
    BEQ.W    end
    MOVE.L    D0,DosBase

    move.w    #DMASET,$dff096        ; enable necessary bits in DMACON
    move.l    #COPPERLIST,$dff080    ; COP1LC - Point to #COPPERLIST
    move.w    d0,$dff088        ; COPJMP1 - Start COP
    
Main:
    move.l    $dff004,d0        ; wait
    and.l    #$0001ff00,d0        ; for
    cmp.l    #303<<8,d0        ; rasterline 303
    bne.s    Main
    
    bsr.w    move_stars

.pause:
    btst    #10,$dff016        ; check for right mouse button
    beq.s    .pause            ; pressed? pause!

    btst    #6,$bfe001        ; check for left mouse button
    bne.s    Main            ; if not, repeat the above line

;*****************************************
;*                     *
;*   RESTORE SYSTEM INTERRUPTS ECT ECT   *
;*                     *
;*****************************************

end:

    move.l    4.w,a6
    move.l    dosbase(PC),a1    ; move to base library
    jsr    CloseLibrary(a6)    ; close lib library
    
    BSR    mt_end
    BSR    ResetCIAInt
    
    move.w    #$7fff,$dff096        ; clear DMACON

    move.w    olddma,d0
    or.w    #$8200,d0        ; set bits of DMACON state
    move.w    d0,$dff096        ; restore original DMACON

    move.l    oldcop,$dff080        ; restore original copperlist
    move.w    #0,$dff088        ; and activate it

    move.w    oldint,d0
    or.w    #$c000,d0        ; set bits of INTENAR state
    move.w    d0,$dff09a        ; restore INTENA state = turn on OS

    moveq    #0,d0            ; nice clean
    rts                ; exit

    
    
GfxBase    dc.l    0    ; Dedicated to offset "graphics.library"
DosBase    dc.l    0    ; Dedicated to offset "dos.library"
OldCop    dc.l    0    ; Dedicated to system COP address    
oldint    dc.w    0    ; Dedicated to INTENA(R)    
olddma    dc.w    0    ; Dedicated to DMA

    incdir  "dh1:own/demo/my_demo/"
    include    "pt_cia_v2.3a.s"
EDIT x 2
Basically, to correctly use Level 3 interrupt, I have to disable level 6 (which is used by protracker cia). gosh

Last edited by fstarred; 21 June 2018 at 10:12.
fstarred is offline  
Old 21 June 2018, 10:31   #8
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
I've told you what to do already. You are mixing system-friendly code with hardware banging code which is never a good idea (unless you really know what you are doing). You have 2 choices:

1. use 100% system-friendly code
2. code your own hardware banging level 6 interrupt handler
StingRay is offline  
Old 21 June 2018, 10:52   #9
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Quote:
Originally Posted by StingRay View Post
I've told you what to do already. You are mixing system-friendly code with hardware banging code which is never a good idea (unless you really know what you are doing). You have 2 choices:

1. use 100% system-friendly code
2. code your own hardware banging level 6 interrupt handler

Uh ok, I go straight for the last posted code that fits with solution 1 I guess
fstarred is offline  
Old 21 June 2018, 10:58   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by fstarred View Post
Uh ok, I go straight for the last posted code that fits with solution 1 I guess

It doesn't.
StingRay is offline  
Old 22 June 2018, 07:55   #11
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
Quote:
Originally Posted by StingRay View Post
You are mixing system-friendly code with hardware banging code which is never a good idea (unless you really know what you are doing).
Regardless turning off DMA and Intena, why so you say I m mixing hardware with friendly code?
I m actually using protracker cia because vblank seems to play module only at a fixed speed .
The rest of code is only just software I guess.
(I m just asking because I'm in doubt)
fstarred is offline  
Old 22 June 2018, 08:29   #12
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Stingray has already replied (twice..) that the problem is mixing HW banging and system code.
If you are using routines from the external source "pt_cia_v2.3a.s", that sure try to use system friendly INT6 approach, and you kill the system, you are mixing

You have to write your CIA IRQ handler if you do not want to stay SO friendly.
ross is offline  
Old 22 June 2018, 09:19   #13
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by fstarred View Post
Regardless turning off DMA and Intena, why so you say I m mixing hardware with friendly code?

Because that is what you do! Load the Protracker replay source into your assembler of choice and check what SetCIAInt does.



Quote:
Originally Posted by fstarred View Post
(I m just asking because I'm in doubt)

If in doubt just check the source to see what's happening. The Protracker replayer uses cia.resource and this will only work if the system is not disabled.

Last edited by StingRay; 22 June 2018 at 09:28. Reason: typo
StingRay is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
CIA interrupts... bloodline Coders. System 6 18 January 2018 10:33
Button to generate a correct integer scale setting for the current screen display Leandro Jardim support.WinUAE 2 25 September 2017 10:25
CIA Interrupts and Timers and Ports nocash Coders. Asm / Hardware 7 13 April 2016 12:09
Can't get my head around setting correct aspect? BarryB support.WinUAE 12 09 December 2011 21:40
Trouble with ProTracker CIA routine?! h0ffman Coders. General 2 27 November 2010 15:03

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:51.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08858 seconds with 15 queries