Revue de sujet
Huntil Posté le 06 Déc 2009 à 14:19
Avatar de Huntil
Messages : 1012
Bonjour à tous,
j'ai un problème pour gérer les interruptions de la souris en assembleur. J'utilise le simulateur EASy68k qui propose un exemple: http://www.easy68k.com/easy68kexamples.htm
(tout en bas, "mouseWindowSize").

J'ai supprimé une partie du code:

Spoiler - Cliquez pour afficher
Code :
* Description   : Mouse read and Output Window size demo
*		  Displays mouse coordinates, mouse button states,
*                 double click and keyboard keys Shift, Alt and Ctrl.
*                 Draws a green crosshair at mouse position.
*                 Pressing '1', '2', or '3' changes screen size.
*
*   Trap #15 Task 60 Enable/Disable mouse IRQ
*      An IRQ is created when a mouse button is pressed,
* released or moved in the output window.
*      D1.W High Byte = IRQ level (1-7), 0 to turn off
*      D1.W Low Byte = Mouse event that triggers IRQ:
*                      Bit2 = Move, Bit1 = Button Up, Bit0 = Button Down
*      (Example D1.W = $0103, Enable mouse IRQ level 1 for Move, Button Up and Button Down)
*      (Example D1.W - $0002, Disable mouse IRQ for Button Up)
*
*   Trap #15 Task 61 reads mouse 
*      D1.B = 00 to read current state of mouse
*           = 01 to read mouse up state
*           = 02 to read mouse down state
*      The mouse data is contained in the following registers
*      D0 as bits = Ctrl, Alt, Shift, Double, Middle, Right, Left
*           Left is Bit0, Right is Bit 1 etc.
*           1 = true, 0 = false
*           Shift, Alt, Ctrl represent the state of the corresponding keys.
*      D1.L = 16 bits Y, 16 bits X in pixel coordinates. (0,0 is top left)
*
*   Trap #15 Task 33 - Get/Set Output Window Size
*       D1.L High 16 bits = Width in pixels, min = 640
*            Low 16 bits  = Height in pixels, min = 480
*       D1.L = 0, get current window size as
*            High 16 bits = Width
*            Low 16 bits  = Height
*
*----------------------------------------------------------- 
   ORG   $1000 

start 

; Initialize IRQ vectors 
	move.l	#mouseDownIRQ,$64		; IRQ1
	move.l	#mouseUpIRQ,$68			; IRQ2
	move.l	#mouseMoveIRQ,$6C		; IRQ3
	andi.w	#$00,SR					; put CPU in User mode 

	move.w	#$0101,d1				; IRQ1 for mouse down
	jsr MOUSE_IRQ
	
	move.w	#$0202,d1				; IRQ2 for mouse up
	jsr MOUSE_IRQ

	move.w	#$0304,d1				; IRQ3 for mouse move
	jsr MOUSE_IRQ
	
	move.l	#(800<<16+600),d1		; 800 x 600
	jsr RESOLUTION
	
	jsr	heading

*---- main program loop ----
loop	nop 
	move.b	#7,d0					; check for pending key press
	trap	#15
	if.b d1 <ne> #0 then.s			; if key is ready
	  jsr SAISCAR					; read key
	  if.b d1 <eq> #'1' then.s		; if '1' pressed			
	    move.l	#(640<<16+480),d1	; 640 x 480
	  	jsr RESOLUTION
	  endi
	  if.b d1 <eq> #'2' then.s		; if '2' pressed
	    move.l	#(800<<16+600),d1	; 800 x 600
	    jsr RESOLUTION
	  endi
	  if.b d1 <eq> #'3' then.s		; if '3' pressed
	    move.l	#(1024<<16+768),d1	; 1024 x 768
	    jsr RESOLUTION
	  endi
	endi
	nop
	bra	loop 
	
* IRQ handlers

; mouse down handler 
mouseDownIRQ
	movem.l	d0-d1,-(a7)
	jsr	heading
	move.b	#61,d0					; read mouse
	move.b	#2,d1					; mouse down state
	trap	#15
	jsr	showMouseData
	movem.l	(a7)+,d0-d1
	rte

; mouse up handler
mouseUpIRQ
	movem.l	d0-d1,-(a7)
	jsr	heading
	move.b  #61,d0					; read mouse
	move.b  #1,d1					; mouse up state
	trap	#15
	jsr	showMouseData
	movem.l	(a7)+,d0-d1
	rte 

; mouse move handler
mouseMoveIRQ
	movem.l	d0-d1,-(a7)
	jsr	heading
	move.b  #61,d0					; read mouse
	move.b  #0,d1					; current mouse state
	trap	#15
	jsr	showMouseData
	movem.l	(a7)+,d0-d1
	rte

MOUSE_IRQ
        MOVE.B #60,D0
        TRAP    #15       
        RTS


Si j'ai bien compris, quand on modifie l'état d'un clic une irq est créée. On assigne à chaque touche une priorité (0 pour que l'évènement soit ignoré). Donc quand on clic dans la fenêtre d'execution la sous-routine associée au clic sera exécutée.
Ce que je ne comprends pas se sont les trois premières lignes. On stock l'adresse des sous-routines en mémoire, mais à aucun moment on n'accède (en tout cas explicitement) à ces adresses par la suite. Est-ce que $64 est une adresse utilisée par défaut ? Si oui comment ?

Si quelqu'un peut m'expliquer ça, sinon je suis quitte pour un post sur le site du log.

EDIT: problème résolu






Nouveau message

Large sourire Sourire Veut Langue Absurde Choqué Clin d'oeil Innocent Cool Fier rougissant confus Neutre Etonné Content Triste Douloureux Pathétique Etrange Agacé Colère Tordu Flèche Question Exclamation Rigole Gêné Amoureux Oui No Fou Pleure Pleure de joie Mignon Coup de coeur Hystérique Blasé Ninja Pouffe Stun Suspicieux Incompréhensible
Gras
Italique
Souligné
Barré
Gauche
Centré
Droite
Justifié
Flottant à gauche
Flottant à droite
Lien
Citation
Puce
Spoiler
Wiki
Image
Flash
Youtube


Prévisualisation
GameCorp - Site d'apprentissage et d'entraide à la création de jeux vidéo.
XHTML Valid 1.1 - Page générée en 0.0221 secondes