diff --git a/asminc/mouse-kernel.inc b/asminc/mouse-kernel.inc index d3ec9b30f..3eebca244 100644 --- a/asminc/mouse-kernel.inc +++ b/asminc/mouse-kernel.inc @@ -78,6 +78,10 @@ .byte CSHOW .addr .byte + CPREP .addr + .byte + CDRAW .addr + .byte CMOVEX .addr .byte CMOVEY .addr @@ -90,14 +94,16 @@ .struct MOUSE_CALLBACKS HIDE .addr ; Hide the mouse cursor SHOW .addr ; Show the mouse cursor - MOVEX .addr ; Move the mouse cursor - MOVEY .addr ; Dito for Y + PREP .addr ; Prepare to move the mouse cursor + DRAW .addr ; Draw the mouse cursor + MOVEX .addr ; Move the mouse cursor to X coord + MOVEY .addr ; Move the mouse cursor to Y coord .endstruct ;------------------------------------------------------------------------------ ; The mouse API version, stored in MOUSE_HDR::VERSION -MOUSE_API_VERSION = $04 +MOUSE_API_VERSION = $05 ;------------------------------------------------------------------------------ ; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS. @@ -169,12 +175,10 @@ MOUSE_BTN_RIGHT = $01 .global mouse_uninstall .global mouse_hide .global mouse_show - .global mouse_setbox + .global mouse_setbox .global mouse_getbox .global mouse_move .global mouse_buttons .global mouse_pos .global mouse_info .global mouse_ioctl - - diff --git a/cfg/atari-cart.cfg b/cfg/atari-cart.cfg new file mode 100644 index 000000000..10674dc49 --- /dev/null +++ b/cfg/atari-cart.cfg @@ -0,0 +1,44 @@ +FEATURES { + STARTADDRESS: default = $2000; +} +SYMBOLS { + __CARTSIZE__: type = weak, value = $2000; # possible values: $2000 and $4000 + __CART_HEADER__: type = import; + __STACKSIZE__: type = weak, value = $0800; # 2k stack + __STARTADDRESS__: type = export, value = %S; + __RESERVED_MEMORY__: type = export, value = $0000; + __CARTFLAGS__: type = weak, value = $01; # see documentation for other possible values +} +MEMORY { + ZP: file = "", define = yes, start = $0082, size = $007E; + RAM: file = "", define = yes, start = %S, size = __CARTSIZE__; + ROM: file = %O, define = yes, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - 6, fill = yes, fillval = $FF; + CARTID: file = %O, start = $BFFA, size = $0006; +} +SEGMENTS { + STARTUP: load = ROM, type = ro, define = yes, optional = yes; + LOWCODE: load = ROM, type = ro, define = yes, optional = yes; + INIT: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, optional = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; + BSS: load = RAM, type = bss, define = yes, optional = yes; + CARTHDR: load = CARTID, type = ro; + ZEROPAGE: load = ZP, type = zp; + EXTZP: load = ZP, type = zp, optional = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/include/mouse.h b/include/mouse.h index 5e69c7ff6..64581eda7 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -88,7 +88,17 @@ struct mouse_callbacks { /* Hide the mouse cursor. */ void (*show) (void); - /* Show the mouse cursor */ + /* Show the mouse cursor. */ + + void (*prep) (void); + /* Prepare to move the mouse cursor. This function is called, + * even when the cursor is currently invisible. + */ + + void (*draw) (void); + /* Draw the mouse cursor. This function is called, + * even when the cursor is currently invisible. + */ void __fastcall__ (*movex) (int x); /* Move the mouse cursor to the new X coordinate. This function is called, diff --git a/libsrc/apple2/mcbdefault.s b/libsrc/apple2/mcbdefault.s index 2ade00aef..cada4173a 100644 --- a/libsrc/apple2/mcbdefault.s +++ b/libsrc/apple2/mcbdefault.s @@ -16,6 +16,7 @@ .bss backup: .res 1 +visible:.res 1 ; ------------------------------------------------------------------------ @@ -25,6 +26,8 @@ backup: .res 1 _mouse_def_callbacks: .addr hide .addr show + .addr prep + .addr draw .addr movex .addr movey @@ -65,10 +68,15 @@ done: .ifdef __APPLE2ENH__ bit LOWSCR ; Doesn't hurt in 40 column mode .endif - rts +return: rts ; Hide the mouse cursor. hide: + dec visible + ; Fall through + +; Prepare to move the mouse cursor. +prep: jsr getcursor ; Cursor visible at current position? bne done ; No, we're done lda backup ; Get character at cursor position @@ -76,6 +84,13 @@ hide: ; Show the mouse cursor. show: + inc visible + ; Fall through + +; Draw the mouse cursor. +draw: + lda visible + beq return jsr getcursor ; Cursor visible at current position? beq done ; Yes, we're done sta backup ; Save character at cursor position diff --git a/libsrc/apple2/mou/a2.stdmou.s b/libsrc/apple2/mou/a2.stdmou.s index 8414cde36..66869916a 100644 --- a/libsrc/apple2/mou/a2.stdmou.s +++ b/libsrc/apple2/mou/a2.stdmou.s @@ -57,6 +57,8 @@ status := $0778 ; Callback table, set by the kernel before INSTALL is called CHIDE: jmp $0000 ; Hide the cursor CSHOW: jmp $0000 ; Show the cursor +CPREP: jmp $0000 ; Prepare to move the cursor +CDRAW: jmp $0000 ; Draw the cursor CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEY: jmp $0000 ; Move the cursor to Y coord @@ -67,7 +69,6 @@ CMOVEY: jmp $0000 ; Move the cursor to Y coord box: .tag MOUSE_BOX info: .tag MOUSE_INFO slot: .res 1 -visible:.res 1 ; ------------------------------------------------------------------------ @@ -321,7 +322,6 @@ MOVE: ; no special action is required besides hiding the mouse cursor. ; No return code required. HIDE: - dec visible sei jsr CHIDE cli @@ -333,7 +333,9 @@ HIDE: ; no special action is required besides enabling the mouse cursor. ; No return code required. SHOW: - inc visible + sei + jsr CSHOW + cli rts ; BUTTONS: Return the button mask in A/X. @@ -409,7 +411,7 @@ done: rts beq :+ ; Remove the cursor at the old position -update: jsr CHIDE +update: jsr CPREP ; Get and set the new X position ldy slot @@ -427,11 +429,7 @@ update: jsr CHIDE stx info + MOUSE_POS::YCOORD+1 jsr CMOVEY - ; Check for visibility -: lda visible - beq :+ - ; Draw the cursor at the new position - jsr CSHOW -: sec ; Interrupt handled +: jsr CDRAW + sec ; Interrupt handled rts diff --git a/libsrc/atari/carthdr.s b/libsrc/atari/carthdr.s new file mode 100644 index 000000000..fedd36a1b --- /dev/null +++ b/libsrc/atari/carthdr.s @@ -0,0 +1,23 @@ +; Cartridge "header" +; (In fact, it's at the end of the cartridge, so more a "trailer".) +; +; Christian Groessler, 06-Jan-2014 + +.ifndef __ATARIXL__ + +.export __CART_HEADER__: absolute = 1 + +.import __CARTSIZE__, __CARTFLAGS__, cartinit, cartstart + +.include "atari.inc" + +.segment "CARTHDR" + + .word cartstart ; start routine + .byte 0 ; must be zero + .byte <__CARTFLAGS__ + .word cartinit ; init routine + +.assert (__CARTSIZE__ = $2000 || __CARTSIZE__ = $4000), error, "Cartridge size must either be $2000 or $4000" + +.endif ; .ifndef __ATARIXL__ diff --git a/libsrc/atari/cartinit.s b/libsrc/atari/cartinit.s new file mode 100644 index 000000000..d3035d60c --- /dev/null +++ b/libsrc/atari/cartinit.s @@ -0,0 +1,11 @@ +; Cartridge init routine +; +; Christian Groessler, 06-Jan-2014 + +.ifndef __ATARIXL__ + +.export cartinit + +cartinit: rts + +.endif ; .ifndef __ATARIXL__ diff --git a/libsrc/atari/cartstart.s b/libsrc/atari/cartstart.s new file mode 100644 index 000000000..a30ab79c8 --- /dev/null +++ b/libsrc/atari/cartstart.s @@ -0,0 +1,20 @@ +; Cartridge start routine +; +; Christian Groessler, 06-Jan-2014 + +.ifndef __ATARIXL__ + +.export cartstart + +.import start, copydata + +.include "atari.inc" + +; start routine of cartridge +; copy data segment to RAM and chain to entry point of crt0.s + +cartstart: jsr copydata + jsr start ; run program + jmp (DOSVEC) ; return to DOS + +.endif ; .ifndef __ATARIXL__ diff --git a/libsrc/c128/mcbdefault.s b/libsrc/c128/mcbdefault.s index cdedf4904..01c54efca 100644 --- a/libsrc/c128/mcbdefault.s +++ b/libsrc/c128/mcbdefault.s @@ -1,5 +1,5 @@ ; -; Default mouse callbacks for the C64 +; Default mouse callbacks for the C128 ; ; Ullrich von Bassewitz, 2004-03-20 ; @@ -22,37 +22,41 @@ MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK) ; Negative mask VIC_SPR_X = (VIC_SPR0_X + 2*MOUSE_SPR) ; Sprite X register VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register -.code - ; -------------------------------------------------------------------------- ; Hide the mouse pointer. Always called with interrupts disabled. -.proc hide - +hide: lda #MOUSE_SPR_NMASK and VIC_SPR_ENA sta VIC_SPR_ENA rts -.endproc - ; -------------------------------------------------------------------------- ; Show the mouse pointer. Always called with interrupts disabled. -.proc show - +show: lda #MOUSE_SPR_MASK ora VIC_SPR_ENA sta VIC_SPR_ENA - rts + ; Fall through -.endproc +; -------------------------------------------------------------------------- +; Prepare to move the mouse pointer. Always called with interrupts disabled. + +prep: + ; Fall through + +; -------------------------------------------------------------------------- +; Draw the mouse pointer. Always called with interrupts disabled. + +draw: + rts ; -------------------------------------------------------------------------- ; Move the mouse pointer X position to the value in a/x. Always called with ; interrupts disabled. -.proc movex +movex: ; Add the X correction and set the low byte. This frees A. @@ -74,27 +78,22 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register sta VIC_SPR_HI_X rts -.endproc - ; -------------------------------------------------------------------------- ; Move the mouse pointer Y position to the value in a/x. Always called with ; interrupts disabled. -.proc movey - +movey: clc ldx PALFLAG - bne @L1 + bne @L2 adc #50 ; FIXME: Should be NTSC, is PAL value sta VIC_SPR_Y ; Set Y position rts -@L1: adc #50 ; Add PAL correction +@L2: adc #50 ; Add PAL correction sta VIC_SPR_Y ; Set Y position rts -.endproc - ; -------------------------------------------------------------------------- ; Callback structure @@ -103,7 +102,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register _mouse_def_callbacks: .addr hide .addr show + .addr prep + .addr draw .addr movex .addr movey - - diff --git a/libsrc/c128/mou/c128-1351.s b/libsrc/c128/mou/c128-1351.s index f2a71647c..b4d950cda 100644 --- a/libsrc/c128/mou/c128-1351.s +++ b/libsrc/c128/mou/c128-1351.s @@ -50,6 +50,8 @@ HEADER: CHIDE: jmp $0000 ; Hide the cursor CSHOW: jmp $0000 ; Show the cursor +CPREP: jmp $0000 ; Prepare to move the cursor +CDRAW: jmp $0000 ; Draw the cursor CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEY: jmp $0000 ; Move the cursor to Y coord @@ -81,10 +83,11 @@ YMax: .res 2 ; Y2 value of bounding box OldValue: .res 1 ; Temp for MoveCheck routine NewValue: .res 1 ; Temp for MoveCheck routine -; Default values for above variables - .rodata +; Default values for above variables +; (We use ".proc" because we want to define both a label and a scope.) + .proc DefVars .byte 0, 0 ; OldPotX/OldPotY .word SCREEN_HEIGHT/2 ; YPos @@ -301,7 +304,8 @@ IOCTL: lda #