Merge remote-tracking branch 'upstream/master' into cassette

ecessary,
This commit is contained in:
Christian Groessler
2014-02-18 21:36:53 +01:00
4 changed files with 105 additions and 34 deletions

View File

@@ -11,6 +11,13 @@
; is being built. ; is being built.
; ;
;DEBUG = 1
DISABLE_TIMEOUT = 30 ; # of vertical blank interrupts after which, if
; no mouse motion occurred, the polling IRQ gets
; disabled.
; VBI frequency is 50Hz for PAL and 60Hz for NTSC
.include "zeropage.inc" .include "zeropage.inc"
.include "mouse-kernel.inc" .include "mouse-kernel.inc"
.include "atari.inc" .include "atari.inc"
@@ -98,6 +105,10 @@ Buttons: .res 1 ; Button mask
XPosWrk: .res 2 XPosWrk: .res 2
YPosWrk: .res 2 YPosWrk: .res 2
irq_enabled: .res 1 ; flag indicating that the high frequency polling interrupt is enabled
old_porta_vbi: .res 1 ; previous PORTA value of the VBI interrupt (IRQ)
how_long: .res 1 ; counter for how many VBI interrupts the mouse hasn't been moved
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE) .if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
dumx: .res 1 dumx: .res 1
dumy: .res 1 dumy: .res 1
@@ -226,10 +237,17 @@ INSTALL:
sta AUDF1 sta AUDF1
sta STIMER sta STIMER
.if 0 ; the IRQ will now be dynamically enabled when the mouse is moved
lda POKMSK lda POKMSK
ora #%00000001 ; timer 1 enable ora #%00000001 ; timer 1 enable
sta POKMSK sta POKMSK
sta IRQEN sta IRQEN
sta irq_enabled
.endif
lda PORTA
and #$0f
sta old_porta_vbi
; Done, return zero (= MOUSE_ERR_OK) ; Done, return zero (= MOUSE_ERR_OK)
@@ -444,23 +462,60 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: IRQ: lda PORTA ; mouse port contents
and #$0f ; check port 1 only
ldx irq_enabled
bne @L1
; Turn mouse polling IRQ back on in case it disabled itself due to CRITIC ; IRQ is disabled, check for mouse motion and enable IRQ if mouse motion detected
; flag being set.
cmp old_porta_vbi
beq @L3 ; no motion
; Turn mouse polling IRQ back on
lda POKMSK lda POKMSK
ora #%00000001 ; timer 1 enable ora #%00000001 ; timer 1 enable
sta POKMSK sta POKMSK
sta IRQEN sta IRQEN
sta irq_enabled
bne @L3
; not reached
; IRQ is enabled
@L1: cmp old_porta_vbi ; mouse motion since last VBI?
sta old_porta_vbi
beq @L2 ; no, increment timeout to disable IRQ
lda #0
sta how_long ; yes, reinitialize wait counter
beq @L3
; not reached
@L2: inc how_long ; no motion, increment wait counter
lda how_long
cmp #DISABLE_TIMEOUT ; timeout?
bcc @L3 ; no
lda #0 ; yes, turn off IRQ
sta how_long
; no mouse input -- turn IRQ off
sta irq_enabled
lda POKMSK
and #%11111110 ; timer 1 disable
sta IRQEN
sta POKMSK
; Check for a pressed button and place the result into Buttons ; Check for a pressed button and place the result into Buttons
ldx #0 @L3: ldx #0
lda TRIG0 ; joystick #0 trigger lda TRIG0 ; joystick #0 trigger
bne @L0 ; not pressed bne @L4 ; not pressed
ldx #MOUSE_BTN_LEFT ldx #MOUSE_BTN_LEFT
@L0: stx Buttons @L4: stx Buttons
jsr CPREP jsr CPREP
@@ -471,20 +526,19 @@ IRQ:
tax tax
cpy XMin cpy XMin
sbc XMin+1 sbc XMin+1
bpl @L2 bpl @L5
ldy XMin ldy XMin
ldx XMin+1 ldx XMin+1
jmp @L3 jmp @L6
@L2: txa
@L5: txa
cpy XMax cpy XMax
sbc XMax+1 sbc XMax+1
bmi @L3 bmi @L6
ldy XMax ldy XMax
ldx XMax+1 ldx XMax+1
@L3: sty XPos @L6: sty XPos
stx XPos+1 stx XPos+1
tya tya
jsr CMOVEX jsr CMOVEX
@@ -495,25 +549,35 @@ IRQ:
tax tax
cpy YMin cpy YMin
sbc YMin+1 sbc YMin+1
bpl @L4 bpl @L7
ldy YMin ldy YMin
ldx YMin+1 ldx YMin+1
jmp @L5 jmp @L8
@L4: txa
@L7: txa
cpy YMax cpy YMax
sbc YMax+1 sbc YMax+1
bmi @L5 bmi @L8
ldy YMax ldy YMax
ldx YMax+1 ldx YMax+1
@L5: sty YPos @L8: sty YPos
stx YPos+1 stx YPos+1
tya tya
jsr CMOVEY jsr CMOVEY
jsr CDRAW jsr CDRAW
.ifdef DEBUG
; print on upper right corner 'E' or 'D', indicating the IRQ is enabled or disabled
ldy irq_enabled
beq @L9
lda #37 ; screen code for 'E'
.byte $2c ; bit opcode, eats next 2 bytes
@L9: lda #36 ; screen code for 'D'
ldy #39
sta (SAVMSC),y
.endif
clc clc
rts rts
@@ -721,6 +785,11 @@ disable_me:
and #%11111110 ; timer 1 disable and #%11111110 ; timer 1 disable
sta IRQEN sta IRQEN
sta POKMSK sta POKMSK
lda #0
sta irq_enabled
lda PORTA
and #$0f
sta old_porta_vbi
.ifdef __ATARIXL__ .ifdef __ATARIXL__
rts rts
.else .else

View File

@@ -110,7 +110,7 @@ void GetEA (EffAddr* A)
A->AddrModeSet = AM65_DIR_IND_LONG_Y; A->AddrModeSet = AM65_DIR_IND_LONG_Y;
} else { } else {
/* [dir] */ /* [dir] */
A->AddrModeSet = AM65_DIR_IND_LONG; A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG;
} }
} else if (CurTok.Tok == TOK_LPAREN) { } else if (CurTok.Tok == TOK_LPAREN) {

View File

@@ -516,8 +516,8 @@ static const struct {
{ "INC", 0x000006F, 0x00, 4, PutAll }, { "INC", 0x000006F, 0x00, 4, PutAll },
{ "INX", 0x0000001, 0xe8, 0, PutAll }, { "INX", 0x0000001, 0xe8, 0, PutAll },
{ "INY", 0x0000001, 0xc8, 0, PutAll }, { "INY", 0x0000001, 0xc8, 0, PutAll },
{ "JML", 0x0000810, 0x5c, 1, PutAll }, { "JML", 0x4000010, 0x5c, 1, PutAll },
{ "JMP", 0x0010818, 0x4c, 6, PutAll }, { "JMP", 0x4010818, 0x4c, 6, PutAll },
{ "JSL", 0x0000010, 0x20, 7, PutAll }, { "JSL", 0x0000010, 0x20, 7, PutAll },
{ "JSR", 0x0010018, 0x20, 7, PutAll }, { "JSR", 0x0010018, 0x20, 7, PutAll },
{ "LDA", 0x0b8f6fc, 0xa0, 0, PutAll }, { "LDA", 0x0b8f6fc, 0xa0, 0, PutAll },
@@ -790,61 +790,61 @@ static unsigned char EATab[10][AM65I_COUNT] = {
0x00, 0x00, 0x05, 0x0D, 0x0F, 0x15, 0x1D, 0x1F, 0x00, 0x00, 0x05, 0x0D, 0x0F, 0x15, 0x1D, 0x1F,
0x00, 0x19, 0x12, 0x00, 0x07, 0x11, 0x17, 0x01, 0x00, 0x19, 0x12, 0x00, 0x07, 0x11, 0x17, 0x01,
0x00, 0x00, 0x00, 0x03, 0x13, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x13, 0x09, 0x00, 0x09,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 1 */ { /* Table 1 */
0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00, 0x08, 0x08, 0x04, 0x0C, 0x00, 0x14, 0x1C, 0x00,
0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x70
}, },
{ /* Table 2 */ { /* Table 2 */
0x00, 0x00, 0x24, 0x2C, 0x0F, 0x34, 0x3C, 0x00, 0x00, 0x00, 0x24, 0x2C, 0x0F, 0x34, 0x3C, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 3 */ { /* Table 3 */
0x3A, 0x3A, 0xC6, 0xCE, 0x00, 0xD6, 0xDE, 0x00, 0x3A, 0x3A, 0xC6, 0xCE, 0x00, 0xD6, 0xDE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 4 */ { /* Table 4 */
0x1A, 0x1A, 0xE6, 0xEE, 0x00, 0xF6, 0xFE, 0x00, 0x1A, 0x1A, 0xE6, 0xEE, 0x00, 0xF6, 0xFE, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 5 */ { /* Table 5 */
0x00, 0x00, 0x60, 0x98, 0x00, 0x70, 0x9E, 0x00, 0x00, 0x00, 0x60, 0x98, 0x00, 0x70, 0x9E, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 6 */ { /* Table 6 */
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x30, 0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x90
}, },
{ /* Table 7 */ { /* Table 7 */
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 8 */ { /* Table 8 */
0x00, 0x40, 0x01, 0x41, 0x00, 0x09, 0x49, 0x00, 0x00, 0x40, 0x01, 0x41, 0x00, 0x09, 0x49, 0x00,
0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
{ /* Table 9 */ { /* Table 9 */
0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x30, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x30, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00 0x00, 0x00, 0x00
}, },
}; };
@@ -888,6 +888,7 @@ unsigned char ExtBytes[AM65I_COUNT] = {
1, /* Immidiate byte */ 1, /* Immidiate byte */
2, /* Blockmove (65816) */ 2, /* Blockmove (65816) */
7, /* Block transfer (HuC6280) */ 7, /* Block transfer (HuC6280) */
2, /* Absolute Indirect long */
}; };
/* Table that encodes the additional bytes for each SWEET16 instruction */ /* Table that encodes the additional bytes for each SWEET16 instruction */

View File

@@ -84,6 +84,7 @@
#define AM65_IMM_IMPLICIT 0x00800000UL #define AM65_IMM_IMPLICIT 0x00800000UL
#define AM65_BLOCKMOVE 0x01000000UL #define AM65_BLOCKMOVE 0x01000000UL
#define AM65_BLOCKXFER 0x02000000UL #define AM65_BLOCKXFER 0x02000000UL
#define AM65_ABS_IND_LONG 0x04000000UL
/* Bitmask for all ZP operations that have correspondent ABS ops */ /* Bitmask for all ZP operations that have correspondent ABS ops */
#define AM65_SET_ZP (AM65_DIR | AM65_DIR_X | AM65_DIR_Y | AM65_DIR_IND | AM65_DIR_X_IND) #define AM65_SET_ZP (AM65_DIR | AM65_DIR_X | AM65_DIR_Y | AM65_DIR_IND | AM65_DIR_X_IND)
@@ -107,7 +108,7 @@
#define AM65I_IMM_ACCU 21 #define AM65I_IMM_ACCU 21
#define AM65I_IMM_INDEX 22 #define AM65I_IMM_INDEX 22
#define AM65I_IMM_IMPLICIT 23 #define AM65I_IMM_IMPLICIT 23
#define AM65I_COUNT 26 #define AM65I_COUNT 27