Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
; Screen size variables
|
||||
;
|
||||
|
||||
.export screensize
|
||||
.export screensize
|
||||
.import SCREEN
|
||||
|
||||
screensize = SCREEN
|
||||
|
||||
@@ -5,65 +5,65 @@
|
||||
; void reset_brk (void);
|
||||
;
|
||||
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
.bss
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
_brk_a: .res 1
|
||||
_brk_x: .res 1
|
||||
_brk_y: .res 1
|
||||
_brk_sr: .res 1
|
||||
_brk_pc: .res 2
|
||||
|
||||
oldvec: .res 2 ; Old vector
|
||||
oldvec: .res 2 ; Old vector
|
||||
|
||||
|
||||
.data
|
||||
uservec: jmp $FFFF ; Patched at runtime
|
||||
uservec: jmp $FFFF ; Patched at runtime
|
||||
|
||||
|
||||
.code
|
||||
|
||||
; Set the break vector
|
||||
.proc _set_brk
|
||||
.proc _set_brk
|
||||
|
||||
sta uservec+1
|
||||
stx uservec+2 ; Set the user vector
|
||||
sta uservec+1
|
||||
stx uservec+2 ; Set the user vector
|
||||
|
||||
lda oldvec
|
||||
ora oldvec+1 ; Did we save the vector already?
|
||||
bne L1 ; Jump if we installed the handler already
|
||||
lda oldvec
|
||||
ora oldvec+1 ; Did we save the vector already?
|
||||
bne L1 ; Jump if we installed the handler already
|
||||
|
||||
lda BRKVec
|
||||
sta oldvec
|
||||
lda BRKVec+1
|
||||
sta oldvec+1 ; Save the old vector
|
||||
lda BRKVec
|
||||
sta oldvec
|
||||
lda BRKVec+1
|
||||
sta oldvec+1 ; Save the old vector
|
||||
|
||||
L1: lda #<brk_handler ; Set the break vector to our routine
|
||||
ldx #>brk_handler
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
rts
|
||||
L1: lda #<brk_handler ; Set the break vector to our routine
|
||||
ldx #>brk_handler
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; Reset the break vector
|
||||
.proc _reset_brk
|
||||
.proc _reset_brk
|
||||
|
||||
lda oldvec
|
||||
ldx oldvec+1
|
||||
beq @L9 ; Jump if vector not installed
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
lda #$00
|
||||
sta oldvec ; Clear the old vector
|
||||
stx oldvec+1
|
||||
@L9: rts
|
||||
lda oldvec
|
||||
ldx oldvec+1
|
||||
beq @L9 ; Jump if vector not installed
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
lda #$00
|
||||
sta oldvec ; Clear the old vector
|
||||
stx oldvec+1
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -71,37 +71,37 @@ L1: lda #<brk_handler ; Set the break vector to our routine
|
||||
|
||||
; Break handler, called if a break occurs
|
||||
|
||||
.proc brk_handler
|
||||
.proc brk_handler
|
||||
|
||||
pla
|
||||
sta _brk_y
|
||||
pla
|
||||
sta _brk_x
|
||||
pla
|
||||
sta _brk_a
|
||||
pla
|
||||
and #$EF ; Clear break bit
|
||||
sta _brk_sr
|
||||
pla ; PC low
|
||||
sec
|
||||
sbc #2 ; Point to start of brk
|
||||
sta _brk_pc
|
||||
pla ; PC high
|
||||
sbc #0
|
||||
sta _brk_pc+1
|
||||
pla
|
||||
sta _brk_y
|
||||
pla
|
||||
sta _brk_x
|
||||
pla
|
||||
sta _brk_a
|
||||
pla
|
||||
and #$EF ; Clear break bit
|
||||
sta _brk_sr
|
||||
pla ; PC low
|
||||
sec
|
||||
sbc #2 ; Point to start of brk
|
||||
sta _brk_pc
|
||||
pla ; PC high
|
||||
sbc #0
|
||||
sta _brk_pc+1
|
||||
|
||||
jsr uservec ; Call the user's routine
|
||||
jsr uservec ; Call the user's routine
|
||||
|
||||
lda _brk_pc+1
|
||||
pha
|
||||
lda _brk_pc
|
||||
pha
|
||||
lda _brk_sr
|
||||
pha
|
||||
ldx _brk_x
|
||||
ldy _brk_y
|
||||
lda _brk_a
|
||||
rti ; Jump back...
|
||||
lda _brk_pc+1
|
||||
pha
|
||||
lda _brk_pc
|
||||
pha
|
||||
lda _brk_sr
|
||||
pha
|
||||
ldx _brk_x
|
||||
ldy _brk_y
|
||||
lda _brk_a
|
||||
rti ; Jump back...
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,58 +4,58 @@
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
.export _cgetc
|
||||
.import cursor
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L3 ; Jump if there are already chars waiting
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L3 ; Jump if there are already chars waiting
|
||||
|
||||
; Switch on the cursor if needed
|
||||
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda KEY_COUNT
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
lda CURS_FLAG
|
||||
pha
|
||||
lda cursor
|
||||
jsr setcursor
|
||||
L1: lda KEY_COUNT
|
||||
beq L1
|
||||
ldx #0
|
||||
pla
|
||||
bne L2
|
||||
inx
|
||||
L2: txa
|
||||
jsr setcursor
|
||||
|
||||
L3: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
L3: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
; Switch the cursor on or off
|
||||
|
||||
.proc setcursor
|
||||
.proc setcursor
|
||||
|
||||
tax ; On or off?
|
||||
bne seton ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne crs9 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
beq crs8 ; Jump if no
|
||||
ldy CURS_X ; Get the character column
|
||||
lda (SCREEN_PTR),y ; Get character
|
||||
eor #$80
|
||||
sta (SCREEN_PTR),y ; Store character back
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store color back
|
||||
crs8: lda #0
|
||||
sta CURS_STATE ; Cursor not displayed
|
||||
crs9: rts
|
||||
tax ; On or off?
|
||||
bne seton ; Go set it on
|
||||
lda CURS_FLAG ; Is the cursor currently off?
|
||||
bne crs9 ; Jump if yes
|
||||
lda #1
|
||||
sta CURS_FLAG ; Mark it as off
|
||||
lda CURS_STATE ; Cursor currently displayed?
|
||||
beq crs8 ; Jump if no
|
||||
ldy CURS_X ; Get the character column
|
||||
lda (SCREEN_PTR),y ; Get character
|
||||
eor #$80
|
||||
sta (SCREEN_PTR),y ; Store character back
|
||||
lda CURS_COLOR
|
||||
sta (CRAM_PTR),y ; Store color back
|
||||
crs8: lda #0
|
||||
sta CURS_STATE ; Cursor not displayed
|
||||
crs9: rts
|
||||
|
||||
seton: lda #0
|
||||
sta CURS_FLAG
|
||||
rts
|
||||
seton: lda #0
|
||||
sta CURS_FLAG
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.export _clrscr
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
_clrscr = CLRSCR
|
||||
|
||||
|
||||
@@ -7,27 +7,27 @@
|
||||
;
|
||||
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
_textcolor:
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
ldx CHARCOLOR ; get old value
|
||||
sta CHARCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bgcolor:
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
rts
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
ldx VIC_BORDERCOLOR ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
ldx VIC_BORDERCOLOR ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.exportzp CURS_X, CURS_Y
|
||||
.exportzp CURS_X, CURS_Y
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
@@ -5,91 +5,91 @@
|
||||
; void __fastcall__ cputc (char c);
|
||||
;
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.import popa, _gotoxy
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.import popa, _gotoxy
|
||||
.import PLOT
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
_cputc: cmp #$0A ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
_cputc: cmp #$0A ; CR?
|
||||
bne L1
|
||||
lda #0
|
||||
sta CURS_X
|
||||
beq plot ; Recalculate pointers
|
||||
|
||||
L1: cmp #$0D ; LF?
|
||||
beq newline ; Recalculate pointers
|
||||
L1: cmp #$0D ; LF?
|
||||
beq newline ; Recalculate pointers
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L10
|
||||
cmp #$60
|
||||
bcc L2
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L2: and #$3F
|
||||
cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L10
|
||||
cmp #$60
|
||||
bcc L2
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L2: and #$3F
|
||||
|
||||
cputdirect:
|
||||
jsr putchar ; Write the character to the screen
|
||||
jsr putchar ; Write the character to the screen
|
||||
|
||||
; Advance cursor position
|
||||
|
||||
advance:
|
||||
iny
|
||||
cpy #XSIZE
|
||||
bne L3
|
||||
jsr newline ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
rts
|
||||
iny
|
||||
cpy #XSIZE
|
||||
bne L3
|
||||
jsr newline ; new line
|
||||
ldy #0 ; + cr
|
||||
L3: sty CURS_X
|
||||
rts
|
||||
|
||||
newline:
|
||||
clc
|
||||
lda #XSIZE
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
clc
|
||||
L4: lda #XSIZE
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: inc CURS_Y
|
||||
rts
|
||||
clc
|
||||
lda #XSIZE
|
||||
adc SCREEN_PTR
|
||||
sta SCREEN_PTR
|
||||
bcc L4
|
||||
inc SCREEN_PTR+1
|
||||
clc
|
||||
L4: lda #XSIZE
|
||||
adc CRAM_PTR
|
||||
sta CRAM_PTR
|
||||
bcc L5
|
||||
inc CRAM_PTR+1
|
||||
L5: inc CURS_Y
|
||||
rts
|
||||
|
||||
; Handle character if high bit set
|
||||
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect
|
||||
L10: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L11
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L11: ora #$40
|
||||
bne cputdirect
|
||||
|
||||
|
||||
|
||||
; Set cursor position, calculate RAM pointers.
|
||||
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
plot: ldy CURS_X
|
||||
ldx CURS_Y
|
||||
clc
|
||||
jmp PLOT ; Set the new cursor
|
||||
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ plot: ldy CURS_X
|
||||
; position in Y
|
||||
|
||||
putchar:
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
ora RVS ; Set revers bit
|
||||
ldy CURS_X
|
||||
sta (SCREEN_PTR),y ; Set char
|
||||
lda CHARCOLOR
|
||||
sta (CRAM_PTR),y ; Set color
|
||||
rts
|
||||
|
||||
@@ -2,110 +2,110 @@
|
||||
; Startup code for cc65 (C64 version)
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss
|
||||
.import callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; Linker generated
|
||||
.importzp ST
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss
|
||||
.import callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; Linker generated
|
||||
.importzp ST
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "c64.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Startup code
|
||||
|
||||
.segment "STARTUP"
|
||||
.segment "STARTUP"
|
||||
|
||||
Start:
|
||||
|
||||
; Save the zero page locations we need
|
||||
|
||||
ldx #zpspace-1
|
||||
L1: lda sp,x
|
||||
sta zpsave,x
|
||||
dex
|
||||
bpl L1
|
||||
ldx #zpspace-1
|
||||
L1: lda sp,x
|
||||
sta zpsave,x
|
||||
dex
|
||||
bpl L1
|
||||
|
||||
; Switch to second charset
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Switch off the BASIC ROM
|
||||
|
||||
lda $01
|
||||
pha ; Remember the value
|
||||
and #$F8
|
||||
ora #$06 ; Enable kernal+I/O, disable basic
|
||||
sta $01
|
||||
lda $01
|
||||
pha ; Remember the value
|
||||
and #$F8
|
||||
ora #$06 ; Enable kernal+I/O, disable basic
|
||||
sta $01
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
jsr zerobss
|
||||
|
||||
; Save system settings and setup the stack
|
||||
|
||||
pla
|
||||
sta mmusave ; Save the memory configuration
|
||||
pla
|
||||
sta mmusave ; Save the memory configuration
|
||||
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
|
||||
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp
|
||||
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp
|
||||
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
|
||||
; Call module constructors
|
||||
|
||||
jsr initlib
|
||||
jsr initlib
|
||||
|
||||
; Push arguments and call main
|
||||
|
||||
jsr callmain
|
||||
jsr callmain
|
||||
|
||||
; Back from main (This is also the _exit entry). Run module destructors
|
||||
|
||||
_exit: pha ; Save the return code on stack
|
||||
jsr donelib
|
||||
_exit: pha ; Save the return code on stack
|
||||
jsr donelib
|
||||
|
||||
; Copy back the zero page stuff
|
||||
|
||||
ldx #zpspace-1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
bpl L2
|
||||
ldx #zpspace-1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
bpl L2
|
||||
|
||||
; Place the program return code into ST
|
||||
|
||||
pla
|
||||
sta ST
|
||||
pla
|
||||
sta ST
|
||||
|
||||
; Restore system stuff
|
||||
|
||||
ldx spsave
|
||||
txs ; Restore stack pointer
|
||||
ldx mmusave
|
||||
stx $01 ; Restore memory configuration
|
||||
ldx spsave
|
||||
txs ; Restore stack pointer
|
||||
ldx mmusave
|
||||
stx $01 ; Restore memory configuration
|
||||
|
||||
; Back to basic
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data
|
||||
|
||||
.segment "ZPSAVE"
|
||||
.segment "ZPSAVE"
|
||||
|
||||
zpsave: .res zpspace
|
||||
zpsave: .res zpspace
|
||||
|
||||
.bss
|
||||
|
||||
spsave: .res 1
|
||||
mmusave:.res 1
|
||||
spsave: .res 1
|
||||
mmusave:.res 1
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
; Oliver Schmidt, 2010-02-14
|
||||
;
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.exportzp devnum := DEVNUM
|
||||
.exportzp devnum := DEVNUM
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
; Marco van den Heuvel, 2010-01-27
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -19,19 +19,19 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
@@ -96,13 +96,13 @@ done: stx $01
|
||||
|
||||
.bss
|
||||
|
||||
curpage: .res 2 ; Current page number
|
||||
curbank: .res 1 ; Current bank
|
||||
window: .res 256 ; Memory "window"
|
||||
curpage: .res 2 ; Current page number
|
||||
curbank: .res 1 ; Current bank
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
; Since the functions above are copied to $200, the current contents of this
|
||||
; memory area must be saved into backup storage. Allocate enough space.
|
||||
backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
|
||||
|
||||
|
||||
@@ -115,52 +115,52 @@ backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda PIA+1 ; Select Peripheral Registers
|
||||
ora #4
|
||||
sta PIA+1
|
||||
lda PIA+1 ; Select Peripheral Registers
|
||||
ora #4
|
||||
sta PIA+1
|
||||
tax
|
||||
lda PIA+3
|
||||
ora #4
|
||||
sta PIA+3
|
||||
lda PIA+3
|
||||
ora #4
|
||||
sta PIA+3
|
||||
tay
|
||||
|
||||
lda #$DC ; Set the default memory bank data
|
||||
sta PIA
|
||||
lda #$FE
|
||||
sta PIA+2
|
||||
lda #$DC ; Set the default memory bank data
|
||||
sta PIA
|
||||
lda #$FE
|
||||
sta PIA+2
|
||||
|
||||
txa ; Select Data Direction Registers
|
||||
and #$FB
|
||||
sta PIA+1
|
||||
txa ; Select Data Direction Registers
|
||||
and #$FB
|
||||
sta PIA+1
|
||||
tya
|
||||
and #$FB
|
||||
sta PIA+3
|
||||
and #$FB
|
||||
sta PIA+3
|
||||
|
||||
lda #$FF ; Set the ports to output
|
||||
sta PIA
|
||||
sta PIA+2
|
||||
lda #$FF ; Set the ports to output
|
||||
sta PIA
|
||||
sta PIA+2
|
||||
|
||||
txa
|
||||
and #$C7
|
||||
ora #$30 ; Set CA1 and
|
||||
sta PIA+1 ; select Peripheral Registers
|
||||
sty PIA+3
|
||||
and #$C7
|
||||
ora #$30 ; Set CA1 and
|
||||
sta PIA+1 ; select Peripheral Registers
|
||||
sty PIA+3
|
||||
|
||||
jsr backup_and_setup_check_routine
|
||||
jsr check::entry
|
||||
jsr backup_and_setup_check_routine
|
||||
jsr check::entry
|
||||
cli
|
||||
ldx #.sizeof (check) - 1
|
||||
jsr restore_data
|
||||
cpy #$01
|
||||
beq @present
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
ldx #.sizeof (check) - 1
|
||||
jsr restore_data
|
||||
cpy #$01
|
||||
beq @present
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
|
||||
@present:
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -176,8 +176,8 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -188,41 +188,41 @@ PAGECOUNT:
|
||||
|
||||
MAP:
|
||||
sei
|
||||
sta curpage ; Remember the new page
|
||||
stx curpage+1
|
||||
jsr adjust_page_and_bank
|
||||
stx curbank
|
||||
sta curpage ; Remember the new page
|
||||
stx curpage+1
|
||||
jsr adjust_page_and_bank
|
||||
stx curbank
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
stx copy::address
|
||||
@L1:
|
||||
ldx curbank
|
||||
jsr copy::entry
|
||||
ldx ptr1
|
||||
sta window,x
|
||||
inc ptr1
|
||||
bne @L1
|
||||
ldx curbank
|
||||
jsr copy::entry
|
||||
ldx ptr1
|
||||
sta window,x
|
||||
inc ptr1
|
||||
bne @L1
|
||||
|
||||
; Return the memory window
|
||||
|
||||
jsr restore_copy_routine
|
||||
lda #<window
|
||||
ldx #>window ; Return the window address
|
||||
jsr restore_copy_routine
|
||||
lda #<window
|
||||
ldx #>window ; Return the window address
|
||||
cli
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curpage+1
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curpage+1
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -230,32 +230,32 @@ USE: sta curpage ; Remember the page
|
||||
|
||||
COMMIT:
|
||||
sei
|
||||
lda curpage ; Get the current page
|
||||
ldx curpage+1
|
||||
lda curpage ; Get the current page
|
||||
ldx curpage+1
|
||||
|
||||
jsr adjust_page_and_bank
|
||||
stx curbank
|
||||
jsr adjust_page_and_bank
|
||||
stx curbank
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
stx copy::address
|
||||
ldx #<copy::stashop
|
||||
stx copy::operation
|
||||
ldx #<copy::stashop
|
||||
stx copy::operation
|
||||
@L1:
|
||||
ldx ptr1
|
||||
lda window,x
|
||||
ldx curbank
|
||||
jsr copy::entry
|
||||
inc ptr1
|
||||
bne @L1
|
||||
ldx ptr1
|
||||
lda window,x
|
||||
ldx curbank
|
||||
jsr copy::entry
|
||||
inc ptr1
|
||||
bne @L1
|
||||
|
||||
; Return the memory window
|
||||
|
||||
jsr restore_copy_routine
|
||||
jsr restore_copy_routine
|
||||
done:
|
||||
cli
|
||||
rts
|
||||
@@ -269,8 +269,8 @@ done:
|
||||
|
||||
COPYFROM:
|
||||
sei
|
||||
jsr setup
|
||||
jsr backup_and_setup_copy_routine
|
||||
jsr setup
|
||||
jsr backup_and_setup_copy_routine
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -281,48 +281,48 @@ COPYFROM:
|
||||
; - tmp1 contains zero (to be used for linear memory buffer offset)
|
||||
; - tmp2 contains the bank value
|
||||
|
||||
lda #<ptr4
|
||||
lda #<ptr4
|
||||
sta copy::address
|
||||
jmp @L3
|
||||
jmp @L3
|
||||
|
||||
@L1:
|
||||
ldx tmp2
|
||||
ldy #0
|
||||
jsr copy::entry
|
||||
ldy tmp1
|
||||
sta (ptr2),y
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
ldx tmp2
|
||||
ldy #0
|
||||
jsr copy::entry
|
||||
ldy tmp1
|
||||
sta (ptr2),y
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inc ptr4
|
||||
beq @L4
|
||||
inc ptr4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
cli
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc ptr4+1
|
||||
lda ptr4+1
|
||||
cmp #$80
|
||||
bne @L3
|
||||
lda #>BASE
|
||||
sta ptr4+1
|
||||
lda tmp2
|
||||
inc ptr4+1
|
||||
lda ptr4+1
|
||||
cmp #$80
|
||||
bne @L3
|
||||
lda #>BASE
|
||||
sta ptr4+1
|
||||
lda tmp2
|
||||
clc
|
||||
adc #$10
|
||||
sta tmp2
|
||||
jmp @L3
|
||||
adc #$10
|
||||
sta tmp2
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
@@ -332,8 +332,8 @@ COPYFROM:
|
||||
|
||||
COPYTO:
|
||||
sei
|
||||
jsr setup
|
||||
jsr backup_and_setup_copy_routine
|
||||
jsr setup
|
||||
jsr backup_and_setup_copy_routine
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -344,101 +344,101 @@ COPYTO:
|
||||
; - tmp1 contains zero (to be used for linear memory buffer offset)
|
||||
; - tmp2 contains the bank value
|
||||
|
||||
lda #<ptr4
|
||||
lda #<ptr4
|
||||
sta copy::address
|
||||
lda #<copy::stashop
|
||||
sta copy::operation
|
||||
jmp @L3
|
||||
lda #<copy::stashop
|
||||
sta copy::operation
|
||||
jmp @L3
|
||||
|
||||
@L1:
|
||||
ldy tmp1
|
||||
lda (ptr2),y
|
||||
ldx tmp2
|
||||
ldy #0
|
||||
jsr copy::entry
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
ldy tmp1
|
||||
lda (ptr2),y
|
||||
ldx tmp2
|
||||
ldy #0
|
||||
jsr copy::entry
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inc ptr4
|
||||
beq @L4
|
||||
inc ptr4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
cli
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc ptr4+1
|
||||
lda ptr4+1
|
||||
inc ptr4+1
|
||||
lda ptr4+1
|
||||
cmp #$80
|
||||
bne @L3
|
||||
lda #>BASE
|
||||
sta ptr4+1
|
||||
lda tmp2
|
||||
bne @L3
|
||||
lda #>BASE
|
||||
sta ptr4+1
|
||||
lda tmp2
|
||||
clc
|
||||
adc #$10
|
||||
sta tmp2
|
||||
jmp @L3
|
||||
adc #$10
|
||||
sta tmp2
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for COPYFROM and COPYTO: Store the pointer to the request
|
||||
; structure and prepare data for the copy
|
||||
|
||||
setup:
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
|
||||
; Get the page number from the struct and adjust it so that it may be used
|
||||
; with the hardware. That is: ptr4 has the page address and page offset
|
||||
; tmp2 will hold the bank value
|
||||
|
||||
ldy #EM_COPY::PAGE+1
|
||||
lda (ptr1),y
|
||||
ldy #EM_COPY::PAGE+1
|
||||
lda (ptr1),y
|
||||
tax
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
jsr adjust_page_and_bank
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
jsr adjust_page_and_bank
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr4+1
|
||||
stx tmp2
|
||||
adc #>BASE
|
||||
sta ptr4+1
|
||||
stx tmp2
|
||||
|
||||
; Get the buffer pointer into ptr2
|
||||
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
iny
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
|
||||
; Get the count, calculate -(count-1) and store it into ptr3
|
||||
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
iny
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
|
||||
; Get the page offset into ptr4 and clear tmp1
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
sta ptr4
|
||||
lda #0
|
||||
sta tmp1
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
sta ptr4
|
||||
lda #0
|
||||
sta tmp1
|
||||
|
||||
; Done
|
||||
|
||||
@@ -447,47 +447,47 @@ setup:
|
||||
; Helper routines for copying to and from the +256k ram
|
||||
|
||||
backup_and_setup_copy_routine:
|
||||
ldx #.sizeof (copy) - 1
|
||||
ldx #.sizeof (copy) - 1
|
||||
@L1:
|
||||
lda copy::entry,x
|
||||
sta backup,x
|
||||
lda copy::template,x
|
||||
sta copy::entry,x
|
||||
lda copy::entry,x
|
||||
sta backup,x
|
||||
lda copy::template,x
|
||||
sta copy::entry,x
|
||||
dex
|
||||
bpl @L1
|
||||
bpl @L1
|
||||
rts
|
||||
|
||||
backup_and_setup_check_routine:
|
||||
ldx #.sizeof (check) - 1
|
||||
ldx #.sizeof (check) - 1
|
||||
@L1:
|
||||
lda check::entry,x
|
||||
sta backup,x
|
||||
lda check::template,x
|
||||
sta check::entry,x
|
||||
lda check::entry,x
|
||||
sta backup,x
|
||||
lda check::template,x
|
||||
sta check::entry,x
|
||||
dex
|
||||
bpl @L1
|
||||
bpl @L1
|
||||
rts
|
||||
|
||||
restore_copy_routine:
|
||||
ldx #.sizeof (copy) - 1
|
||||
ldx #.sizeof (copy) - 1
|
||||
restore_data:
|
||||
lda backup,x
|
||||
sta TARGETLOC,x
|
||||
lda backup,x
|
||||
sta TARGETLOC,x
|
||||
dex
|
||||
bpl restore_data
|
||||
bpl restore_data
|
||||
rts
|
||||
|
||||
; Helper routine to correct for the bank and page
|
||||
adjust_page_and_bank:
|
||||
sta tmp4
|
||||
lda #$0C
|
||||
sta tmp4
|
||||
lda #$0C
|
||||
sta tmp3
|
||||
lda tmp4
|
||||
and #$c0
|
||||
lda tmp4
|
||||
and #$c0
|
||||
lsr
|
||||
lsr
|
||||
ora tmp3
|
||||
sta tmp3
|
||||
ora tmp3
|
||||
sta tmp3
|
||||
txa
|
||||
asl
|
||||
asl
|
||||
@@ -495,8 +495,8 @@ adjust_page_and_bank:
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
ora tmp3
|
||||
ora tmp3
|
||||
tax
|
||||
lda tmp4
|
||||
and #$3f
|
||||
lda tmp4
|
||||
and #$3f
|
||||
rts
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
; Marco van den Heuvel, 2010-01-27
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -19,19 +19,19 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
@@ -115,12 +115,12 @@ address := *+1 ; Patched at runtime
|
||||
|
||||
.bss
|
||||
|
||||
curpage: .res 1 ; Current page number
|
||||
window: .res 256 ; Memory "window"
|
||||
curpage: .res 1 ; Current page number
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
; Since the functions above are copied to $200, the current contents of this
|
||||
; memory area must be saved into backup storage. Allocate enough space.
|
||||
backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
|
||||
|
||||
|
||||
@@ -135,21 +135,21 @@ backup: .res .max (.sizeof (copy), .sizeof (check))
|
||||
|
||||
INSTALL:
|
||||
sei
|
||||
jsr backup_and_setup_check_routine
|
||||
jsr check::entry
|
||||
jsr backup_and_setup_check_routine
|
||||
jsr check::entry
|
||||
cli
|
||||
ldx #.sizeof (check) - 1
|
||||
jsr restore_data
|
||||
cpy #$01
|
||||
beq @present
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
ldx #.sizeof (check) - 1
|
||||
jsr restore_data
|
||||
cpy #$01
|
||||
beq @present
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
|
||||
@present:
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -165,8 +165,8 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -177,37 +177,37 @@ PAGECOUNT:
|
||||
|
||||
MAP:
|
||||
sei
|
||||
sta curpage ; Remember the new page
|
||||
sta curpage ; Remember the new page
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
stx copy::fetch::address
|
||||
@L1:
|
||||
ldx #$14
|
||||
jsr copy::fetch
|
||||
ldx ptr1
|
||||
sta window,x
|
||||
inc ptr1
|
||||
bne @L1
|
||||
ldx #$14
|
||||
jsr copy::fetch
|
||||
ldx ptr1
|
||||
sta window,x
|
||||
inc ptr1
|
||||
bne @L1
|
||||
|
||||
; Return the memory window
|
||||
|
||||
jsr restore_copy_routine
|
||||
lda #<window
|
||||
ldx #>window ; Return the window address
|
||||
jsr restore_copy_routine
|
||||
lda #<window
|
||||
ldx #>window ; Return the window address
|
||||
cli
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
USE: sta curpage ; Remember the page
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -215,26 +215,26 @@ USE: sta curpage ; Remember the page
|
||||
|
||||
COMMIT:
|
||||
sei
|
||||
lda curpage ; Get the current page
|
||||
lda curpage ; Get the current page
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
jsr backup_and_setup_copy_routine
|
||||
ldx #<ptr1
|
||||
stx copy::stash::address
|
||||
@L1:
|
||||
ldx ptr1
|
||||
lda window,x
|
||||
ldx #$14
|
||||
jsr copy::stash
|
||||
inc ptr1
|
||||
bne @L1
|
||||
ldx ptr1
|
||||
lda window,x
|
||||
ldx #$14
|
||||
jsr copy::stash
|
||||
inc ptr1
|
||||
bne @L1
|
||||
|
||||
; Return the memory window
|
||||
|
||||
jsr restore_copy_routine
|
||||
jsr restore_copy_routine
|
||||
cli
|
||||
rts
|
||||
|
||||
@@ -250,11 +250,11 @@ COPYFROM:
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
jsr backup_and_setup_copy_routine
|
||||
jsr backup_and_setup_copy_routine
|
||||
pla
|
||||
tax
|
||||
pla
|
||||
jsr setup
|
||||
jsr setup
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -264,39 +264,39 @@ COPYFROM:
|
||||
; - ptr4 contains the page memory buffer plus offset
|
||||
; - tmp1 contains zero (to be used for linear memory buffer offset)
|
||||
|
||||
lda #<ptr4
|
||||
lda #<ptr4
|
||||
sta copy::fetch::address
|
||||
jmp @L3
|
||||
jmp @L3
|
||||
|
||||
@L1:
|
||||
ldx #$14
|
||||
ldy #0
|
||||
jsr copy::fetch
|
||||
ldy tmp1
|
||||
sta (ptr2),y
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
ldx #$14
|
||||
ldy #0
|
||||
jsr copy::fetch
|
||||
ldy tmp1
|
||||
sta (ptr2),y
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inc ptr4
|
||||
beq @L4
|
||||
inc ptr4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
cli
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc ptr4+1
|
||||
jmp @L3
|
||||
inc ptr4+1
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
@@ -309,11 +309,11 @@ COPYTO:
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
jsr backup_and_setup_copy_routine
|
||||
jsr backup_and_setup_copy_routine
|
||||
pla
|
||||
tax
|
||||
pla
|
||||
jsr setup
|
||||
jsr setup
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -323,85 +323,85 @@ COPYTO:
|
||||
; - ptr4 contains the page memory buffer plus offset
|
||||
; - tmp1 contains zero (to be used for linear memory buffer offset)
|
||||
|
||||
lda #<ptr4
|
||||
lda #<ptr4
|
||||
sta copy::stash::address
|
||||
jmp @L3
|
||||
jmp @L3
|
||||
|
||||
@L1:
|
||||
ldy tmp1
|
||||
lda (ptr2),y
|
||||
ldx #$14
|
||||
ldy #0
|
||||
jsr copy::stash
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
ldy tmp1
|
||||
lda (ptr2),y
|
||||
ldx #$14
|
||||
ldy #0
|
||||
jsr copy::stash
|
||||
inc tmp1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inc ptr4
|
||||
beq @L4
|
||||
inc ptr4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
jsr restore_copy_routine
|
||||
cli
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc ptr4+1
|
||||
jmp @L3
|
||||
inc ptr4+1
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for COPYFROM and COPYTO: Store the pointer to the request
|
||||
; structure and prepare data for the copy
|
||||
|
||||
setup:
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
|
||||
; Get the page number from the struct and adjust it so that it may be used
|
||||
; with the hardware. That is: ptr4 has the page address and page offset
|
||||
; tmp2 will hold the bank value
|
||||
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr4+1
|
||||
adc #>BASE
|
||||
sta ptr4+1
|
||||
|
||||
; Get the buffer pointer into ptr2
|
||||
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
iny
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
|
||||
; Get the count, calculate -(count-1) and store it into ptr3
|
||||
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
iny
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
|
||||
; Get the page offset into ptr4 and clear tmp1
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
sta ptr4
|
||||
lda #0
|
||||
sta tmp1
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
sta ptr4
|
||||
lda #0
|
||||
sta tmp1
|
||||
|
||||
; Done
|
||||
|
||||
@@ -410,32 +410,32 @@ setup:
|
||||
; Helper routines for copying to and from the +256k ram
|
||||
|
||||
backup_and_setup_copy_routine:
|
||||
ldx #.sizeof (copy) - 1
|
||||
ldx #.sizeof (copy) - 1
|
||||
@L1:
|
||||
lda copy::entry,x
|
||||
sta backup,x
|
||||
lda copy::template,x
|
||||
sta copy::entry,x
|
||||
lda copy::entry,x
|
||||
sta backup,x
|
||||
lda copy::template,x
|
||||
sta copy::entry,x
|
||||
dex
|
||||
bpl @L1
|
||||
bpl @L1
|
||||
rts
|
||||
|
||||
backup_and_setup_check_routine:
|
||||
ldx #.sizeof (check) - 1
|
||||
ldx #.sizeof (check) - 1
|
||||
@L1:
|
||||
lda check::entry,x
|
||||
sta backup,x
|
||||
lda check::template,x
|
||||
sta check::entry,x
|
||||
lda check::entry,x
|
||||
sta backup,x
|
||||
lda check::template,x
|
||||
sta check::entry,x
|
||||
dex
|
||||
bpl @L1
|
||||
bpl @L1
|
||||
rts
|
||||
|
||||
restore_copy_routine:
|
||||
ldx #.sizeof (copy) - 1
|
||||
ldx #.sizeof (copy) - 1
|
||||
restore_data:
|
||||
lda backup,x
|
||||
sta TARGETLOC,x
|
||||
lda backup,x
|
||||
sta TARGETLOC,x
|
||||
dex
|
||||
bpl restore_data
|
||||
bpl restore_data
|
||||
rts
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
; Marco van den Heuvel, 2010-01-21
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -62,83 +62,83 @@ pagecount: .res 2 ; Number of available pages
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
ldx GR_WINDOW
|
||||
ldx GR_WINDOW
|
||||
cpx GR_WINDOW
|
||||
bne @notpresent
|
||||
inc GR_WINDOW
|
||||
cpx GR_WINDOW
|
||||
beq @notpresent
|
||||
cpx GR_WINDOW
|
||||
beq @notpresent
|
||||
|
||||
lda #4
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has64k
|
||||
lda #8
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has128k
|
||||
lda #16
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has256k
|
||||
lda #32
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has512k
|
||||
lda #64
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has1024k
|
||||
lda #128
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has2048k
|
||||
ldx #>16384
|
||||
lda #4
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has64k
|
||||
lda #8
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has128k
|
||||
lda #16
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has256k
|
||||
lda #32
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has512k
|
||||
lda #64
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has1024k
|
||||
lda #128
|
||||
jsr check
|
||||
cpy GR_WINDOW
|
||||
beq @has2048k
|
||||
ldx #>16384
|
||||
bne @setok
|
||||
|
||||
@has64k:
|
||||
ldx #>256
|
||||
bne @setok
|
||||
ldx #>256
|
||||
bne @setok
|
||||
@has128k:
|
||||
ldx #>512
|
||||
bne @setok
|
||||
ldx #>512
|
||||
bne @setok
|
||||
@has256k:
|
||||
ldx #>1024
|
||||
bne @setok
|
||||
ldx #>1024
|
||||
bne @setok
|
||||
@has512k:
|
||||
ldx #>2048
|
||||
bne @setok
|
||||
ldx #>2048
|
||||
bne @setok
|
||||
@has1024k:
|
||||
ldx #>4096
|
||||
bne @setok
|
||||
ldx #>4096
|
||||
bne @setok
|
||||
@has2048k:
|
||||
ldx #>8192
|
||||
bne @setok
|
||||
ldx #>8192
|
||||
bne @setok
|
||||
|
||||
@notpresent:
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
|
||||
@setok:
|
||||
lda #0
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
lda #0
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
|
||||
check:
|
||||
ldx #0
|
||||
stx GR_PAGE_LO
|
||||
stx GR_PAGE_HI
|
||||
ldy GR_WINDOW
|
||||
iny
|
||||
sta GR_PAGE_HI
|
||||
sty GR_WINDOW
|
||||
ldx #0
|
||||
stx GR_PAGE_HI
|
||||
; rts ; Run into UNINSTALL instead
|
||||
ldx #0
|
||||
stx GR_PAGE_LO
|
||||
stx GR_PAGE_HI
|
||||
ldy GR_WINDOW
|
||||
iny
|
||||
sta GR_PAGE_HI
|
||||
sty GR_WINDOW
|
||||
ldx #0
|
||||
stx GR_PAGE_HI
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
; Marco van den Heuvel, 2010-01-24
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -19,24 +19,24 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
.word INSTALL
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
IP_WINDOW = $DF00 ; Address of ISEPIC window
|
||||
IP_WINDOW = $DF00 ; Address of ISEPIC window
|
||||
IP_CTRL_BASE = $DE00
|
||||
PAGES = 8
|
||||
|
||||
@@ -53,32 +53,32 @@ PAGES = 8
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda #0
|
||||
sta IP_CTRL_BASE
|
||||
ldx IP_WINDOW
|
||||
cpx IP_WINDOW
|
||||
bne @notpresent
|
||||
inc IP_WINDOW
|
||||
cpx IP_WINDOW
|
||||
beq @notpresent
|
||||
ldx IP_WINDOW
|
||||
sta IP_CTRL_BASE+1
|
||||
lda #0
|
||||
sta IP_CTRL_BASE
|
||||
ldx IP_WINDOW
|
||||
cpx IP_WINDOW
|
||||
bne @notpresent
|
||||
inc IP_WINDOW
|
||||
cpx IP_WINDOW
|
||||
beq @notpresent
|
||||
ldx IP_WINDOW
|
||||
sta IP_CTRL_BASE+1
|
||||
inx
|
||||
stx IP_WINDOW
|
||||
stx IP_WINDOW
|
||||
dex
|
||||
sta IP_CTRL_BASE
|
||||
cpx IP_WINDOW
|
||||
beq @setok
|
||||
sta IP_CTRL_BASE
|
||||
cpx IP_WINDOW
|
||||
beq @setok
|
||||
|
||||
@notpresent:
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
|
||||
@setok:
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -93,8 +93,8 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
lda #<PAGES
|
||||
ldx #>PAGES
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -112,9 +112,9 @@ USE := MAP
|
||||
|
||||
MAP:
|
||||
tax
|
||||
sta IP_CTRL_BASE,x
|
||||
lda #<IP_WINDOW
|
||||
ldx #>IP_WINDOW
|
||||
sta IP_CTRL_BASE,x
|
||||
lda #<IP_WINDOW
|
||||
ldx #>IP_WINDOW
|
||||
|
||||
; Use the RTS from COMMIT below to save a precious byte of storage
|
||||
|
||||
@@ -131,7 +131,7 @@ COMMIT:
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
jsr setup
|
||||
jsr setup
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -142,37 +142,37 @@ COPYFROM:
|
||||
; - X contains the page offset
|
||||
; - Y contains zero
|
||||
|
||||
jmp @L5
|
||||
jmp @L5
|
||||
|
||||
@L1:
|
||||
lda IP_WINDOW,x
|
||||
sta (ptr2),y
|
||||
lda IP_WINDOW,x
|
||||
sta (ptr2),y
|
||||
iny
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inx
|
||||
beq @L4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc tmp1 ; Bump low page register
|
||||
inc tmp1 ; Bump low page register
|
||||
@L5:
|
||||
stx tmp2
|
||||
ldx tmp1
|
||||
sta IP_CTRL_BASE,x
|
||||
ldx tmp2
|
||||
jmp @L3
|
||||
stx tmp2
|
||||
ldx tmp1
|
||||
sta IP_CTRL_BASE,x
|
||||
ldx tmp2
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
@@ -181,7 +181,7 @@ COPYFROM:
|
||||
;
|
||||
|
||||
COPYTO:
|
||||
jsr setup
|
||||
jsr setup
|
||||
|
||||
; Setup is:
|
||||
;
|
||||
@@ -192,78 +192,78 @@ COPYTO:
|
||||
; - X contains the page offset
|
||||
; - Y contains zero
|
||||
|
||||
jmp @L5
|
||||
jmp @L5
|
||||
|
||||
@L1:
|
||||
lda (ptr2),y
|
||||
sta IP_WINDOW,x
|
||||
lda (ptr2),y
|
||||
sta IP_WINDOW,x
|
||||
iny
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
bne @L2
|
||||
inc ptr2+1
|
||||
@L2:
|
||||
inx
|
||||
beq @L4
|
||||
beq @L4
|
||||
|
||||
; Bump count and repeat
|
||||
|
||||
@L3:
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
inc ptr3
|
||||
bne @L1
|
||||
inc ptr3+1
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4:
|
||||
inc tmp1 ; Bump page register
|
||||
inc tmp1 ; Bump page register
|
||||
@L5:
|
||||
stx tmp2
|
||||
ldx tmp1
|
||||
sta IP_CTRL_BASE,x
|
||||
ldx tmp2
|
||||
jmp @L3
|
||||
stx tmp2
|
||||
ldx tmp1
|
||||
sta IP_CTRL_BASE,x
|
||||
ldx tmp2
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for COPYFROM and COPYTO: Store the pointer to the request
|
||||
; structure and prepare data for the copy
|
||||
|
||||
setup:
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
sta ptr1
|
||||
stx ptr1+1 ; Save passed pointer
|
||||
|
||||
; Get the page number from the struct and remember it.
|
||||
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
sta tmp1
|
||||
ldy #EM_COPY::PAGE
|
||||
lda (ptr1),y
|
||||
sta tmp1
|
||||
|
||||
; Get the buffer pointer into ptr2
|
||||
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
ldy #EM_COPY::BUF
|
||||
lda (ptr1),y
|
||||
sta ptr2
|
||||
iny
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
lda (ptr1),y
|
||||
sta ptr2+1
|
||||
|
||||
; Get the count, calculate -(count-1) and store it into ptr3
|
||||
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
ldy #EM_COPY::COUNT
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3
|
||||
iny
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
lda (ptr1),y
|
||||
eor #$FF
|
||||
sta ptr3+1
|
||||
|
||||
; Get the page offset into X and clear Y
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr1),y
|
||||
tax
|
||||
ldy #0
|
||||
ldy #0
|
||||
|
||||
; Done
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; Ullrich von Bassewitz, 2002-12-02
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -32,14 +32,14 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
BASE = $D000
|
||||
PAGES = ($10000 - BASE) / 256
|
||||
BASE = $D000
|
||||
PAGES = ($10000 - BASE) / 256
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
@@ -88,18 +88,18 @@ PAGECOUNT:
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage ; Remember the new page
|
||||
MAP: sta curpage ; Remember the new page
|
||||
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
|
||||
; Transfer one page
|
||||
|
||||
@@ -122,36 +122,36 @@ USE: sta curpage ; Remember the page
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
bmi done ; Jump if no page mapped
|
||||
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr2+1
|
||||
ldy #$00
|
||||
sty ptr2
|
||||
adc #>BASE
|
||||
sta ptr2+1
|
||||
ldy #$00
|
||||
sty ptr2
|
||||
|
||||
lda #<window
|
||||
sta ptr1
|
||||
lda #>window
|
||||
sta ptr1+1
|
||||
lda #<window
|
||||
sta ptr1
|
||||
lda #>window
|
||||
sta ptr1+1
|
||||
|
||||
; Transfer one page. Y must be zero on entry
|
||||
|
||||
transfer:
|
||||
ldx $01 ; Remember c64 control port
|
||||
ldx $01 ; Remember c64 control port
|
||||
txa
|
||||
and #$F8 ; Bank out ROMs, I/O
|
||||
and #$F8 ; Bank out ROMs, I/O
|
||||
sei
|
||||
sta $01
|
||||
sta $01
|
||||
|
||||
; Unroll the following loop
|
||||
|
||||
loop: .repeat 8
|
||||
lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
loop: .repeat 8
|
||||
lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
iny
|
||||
.endrepeat
|
||||
.endrepeat
|
||||
|
||||
bne loop
|
||||
|
||||
@@ -162,7 +162,7 @@ loop: .repeat 8
|
||||
|
||||
; Done
|
||||
|
||||
done: rts
|
||||
done: rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
@@ -173,7 +173,7 @@ done: rts
|
||||
COPYFROM:
|
||||
sta ptr3
|
||||
stx ptr3+1 ; Save the passed em_copy pointer
|
||||
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
lda (ptr3),y
|
||||
sta ptr1
|
||||
@@ -213,15 +213,15 @@ common: ldy #EM_COPY::COUNT+1
|
||||
|
||||
lda $01 ; Remember c64 control port
|
||||
pha
|
||||
and #$F8 ; Bank out ROMs, I/O
|
||||
and #$F8 ; Bank out ROMs, I/O
|
||||
sei
|
||||
sta $01
|
||||
sta $01
|
||||
|
||||
; Transfer the bytes in the last page
|
||||
|
||||
ldy #$00
|
||||
@L3: lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
@L3: lda (ptr1),y
|
||||
sta (ptr2),y
|
||||
iny
|
||||
dex
|
||||
bne @L3
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
;
|
||||
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
@@ -24,7 +24,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -61,46 +61,46 @@ pagecount: .res 2 ; Number of available pages
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
ldx RAMC_WINDOW
|
||||
cpx RAMC_WINDOW
|
||||
bne @notpresent
|
||||
ldx RAMC_WINDOW
|
||||
cpx RAMC_WINDOW
|
||||
bne @notpresent
|
||||
|
||||
lda #0
|
||||
sta RAMC_PAGE_LO
|
||||
sta RAMC_PAGE_HI
|
||||
ldx RAMC_WINDOW
|
||||
cpx RAMC_WINDOW
|
||||
bne @notpresent
|
||||
lda #2
|
||||
sta RAMC_WINDOW
|
||||
cmp RAMC_WINDOW
|
||||
beq @cont
|
||||
cpx RAMC_WINDOW
|
||||
beq @readonly
|
||||
@cont: ldy #1
|
||||
sty RAMC_PAGE_HI
|
||||
sty RAMC_WINDOW
|
||||
dey
|
||||
sty RAMC_PAGE_HI
|
||||
iny
|
||||
cpy RAMC_WINDOW
|
||||
beq @rc64
|
||||
; we're on rc128
|
||||
ldx #>512
|
||||
bne @setsize
|
||||
@rc64: ldx #>256
|
||||
lda #0
|
||||
sta RAMC_PAGE_LO
|
||||
sta RAMC_PAGE_HI
|
||||
ldx RAMC_WINDOW
|
||||
cpx RAMC_WINDOW
|
||||
bne @notpresent
|
||||
lda #2
|
||||
sta RAMC_WINDOW
|
||||
cmp RAMC_WINDOW
|
||||
beq @cont
|
||||
cpx RAMC_WINDOW
|
||||
beq @readonly
|
||||
@cont: ldy #1
|
||||
sty RAMC_PAGE_HI
|
||||
sty RAMC_WINDOW
|
||||
dey
|
||||
sty RAMC_PAGE_HI
|
||||
iny
|
||||
cpy RAMC_WINDOW
|
||||
beq @rc64
|
||||
; we're on rc128
|
||||
ldx #>512
|
||||
bne @setsize
|
||||
@rc64: ldx #>256
|
||||
@setsize:
|
||||
lda #0
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
lda #0
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
@notpresent:
|
||||
@readonly:
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
; rts ; Run into UNINSTALL instead
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -134,8 +134,8 @@ USE = MAP
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta RAMC_PAGE_LO
|
||||
stx RAMC_PAGE_HI
|
||||
MAP: sta RAMC_PAGE_LO
|
||||
stx RAMC_PAGE_HI
|
||||
lda #<RAMC_WINDOW
|
||||
ldx #>RAMC_WINDOW
|
||||
|
||||
@@ -185,14 +185,14 @@ COPYFROM:
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4: inc tmp1
|
||||
bne @L5
|
||||
inc tmp2
|
||||
@L5: lda tmp1
|
||||
sta RAMC_PAGE_LO
|
||||
lda tmp2
|
||||
sta RAMC_PAGE_HI
|
||||
jmp @L3
|
||||
@L4: inc tmp1
|
||||
bne @L5
|
||||
inc tmp2
|
||||
@L5: lda tmp1
|
||||
sta RAMC_PAGE_LO
|
||||
lda tmp2
|
||||
sta RAMC_PAGE_HI
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
@@ -233,14 +233,14 @@ COPYTO:
|
||||
|
||||
; Bump page register
|
||||
|
||||
@L4: inc tmp1
|
||||
bne @L5
|
||||
inc tmp2
|
||||
@L5: lda tmp1
|
||||
sta RAMC_PAGE_LO
|
||||
lda tmp2
|
||||
sta RAMC_PAGE_HI
|
||||
jmp @L3
|
||||
@L4: inc tmp1
|
||||
bne @L5
|
||||
inc tmp2
|
||||
@L5: lda tmp1
|
||||
sta RAMC_PAGE_LO
|
||||
lda tmp2
|
||||
sta RAMC_PAGE_HI
|
||||
jmp @L3
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for COPYFROM and COPYTO: Store the pointer to the request
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; Ullrich von Bassewitz, 2002-11-29
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -60,12 +60,12 @@ curpage: .res 2 ; Current page number
|
||||
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
reu_params: .word $0000 ; Host address, lo, hi
|
||||
.word $0000 ; Exp address, lo, hi
|
||||
.byte $00 ; Expansion bank no.
|
||||
.word $0000 ; # bytes to move, lo, hi
|
||||
.byte $00 ; Interrupt mask reg.
|
||||
.byte $00 ; Adress control reg.
|
||||
reu_params: .word $0000 ; Host address, lo, hi
|
||||
.word $0000 ; Exp address, lo, hi
|
||||
.byte $00 ; Expansion bank no.
|
||||
.word $0000 ; # bytes to move, lo, hi
|
||||
.byte $00 ; Interrupt mask reg.
|
||||
.byte $00 ; Adress control reg.
|
||||
|
||||
.code
|
||||
|
||||
@@ -142,7 +142,7 @@ done: rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
|
||||
USE: sta curpage
|
||||
stx curpage+1 ; Remember the page
|
||||
lda #<window
|
||||
@@ -220,15 +220,15 @@ transfer1:
|
||||
; Transfer subroutine for the REU. Expects command in Y.
|
||||
|
||||
transfer:
|
||||
sty REU_COMMAND ; Issue command
|
||||
sty REU_COMMAND ; Issue command
|
||||
|
||||
ldy $01 ; Save the value of the c64 control port...
|
||||
tya ;
|
||||
ldy $01 ; Save the value of the c64 control port...
|
||||
tya ;
|
||||
and #$F8 ; Disable ROMs and I/O.
|
||||
sei ;
|
||||
sta $01
|
||||
sei ;
|
||||
sta $01
|
||||
lda REU_TRIGGER ; Don't change $FF00
|
||||
sta REU_TRIGGER ; Start the transfer...
|
||||
sta REU_TRIGGER ; Start the transfer...
|
||||
|
||||
sty $01 ; Restore the old configuration
|
||||
cli
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
; Marco van den Heuvel, 2010-01-22
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
@@ -25,7 +25,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -33,33 +33,33 @@
|
||||
.word UNINSTALL
|
||||
.word PAGECOUNT
|
||||
.word MAP
|
||||
.word USE
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
VDC_ADDR_REG = $D600 ; VDC address
|
||||
VDC_DATA_REG = $D601 ; VDC data
|
||||
VDC_ADDR_REG = $D600 ; VDC address
|
||||
VDC_DATA_REG = $D601 ; VDC data
|
||||
|
||||
VDC_DATA_HI = 18 ; used registers
|
||||
VDC_DATA_LO = 19
|
||||
VDC_CSET = 28
|
||||
VDC_DATA = 31
|
||||
VDC_DATA_HI = 18 ; used registers
|
||||
VDC_DATA_LO = 19
|
||||
VDC_CSET = 28
|
||||
VDC_DATA = 31
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.data
|
||||
|
||||
pagecount: .word 64 ; $0000-$3fff as 16k default
|
||||
curpage: .word $ffff ; currently mapped-in page (invalid)
|
||||
pagecount: .word 64 ; $0000-$3fff as 16k default
|
||||
curpage: .word $ffff ; currently mapped-in page (invalid)
|
||||
|
||||
.bss
|
||||
|
||||
window: .res 256 ; memory window
|
||||
window: .res 256 ; memory window
|
||||
|
||||
.code
|
||||
|
||||
@@ -73,8 +73,8 @@ window: .res 256 ; memory window
|
||||
INSTALL:
|
||||
ldx #0
|
||||
ldy #0
|
||||
lda #VDC_CSET ; determine size of RAM...
|
||||
sta VDC_ADDR_REG
|
||||
lda #VDC_CSET ; determine size of RAM...
|
||||
sta VDC_ADDR_REG
|
||||
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bmi @present
|
||||
@@ -82,81 +82,81 @@ INSTALL:
|
||||
bne @L0
|
||||
iny
|
||||
bne @L0
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
lda #<EM_ERR_NO_DEVICE
|
||||
ldx #>EM_ERR_NO_DEVICE
|
||||
rts
|
||||
|
||||
@present:
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr vdcgetreg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr vdcputreg ; turn on 64k
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr vdcgetreg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr vdcputreg ; turn on 64k
|
||||
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr vdcgetbyte
|
||||
sta tmp2
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr vdcgetbyte
|
||||
sta tmp2
|
||||
|
||||
lda #$55 ; write $55 here
|
||||
ldy #ptr1
|
||||
jsr test64k ; read it here and there
|
||||
lda #$aa ; write $aa here
|
||||
ldy #ptr2
|
||||
jsr test64k ; read it here and there
|
||||
lda #$55 ; write $55 here
|
||||
ldy #ptr1
|
||||
jsr test64k ; read it here and there
|
||||
lda #$aa ; write $aa here
|
||||
ldy #ptr2
|
||||
jsr test64k ; read it here and there
|
||||
|
||||
jsr settestadr1
|
||||
lda tmp2
|
||||
jsr vdcputbyte ; restore original value of test byte
|
||||
jsr settestadr1
|
||||
lda tmp2
|
||||
jsr vdcputbyte ; restore original value of test byte
|
||||
|
||||
lda ptr1 ; do bytes match?
|
||||
cmp ptr1+1
|
||||
bne @have64k
|
||||
lda ptr2
|
||||
cmp ptr2+1
|
||||
bne @have64k
|
||||
lda ptr1 ; do bytes match?
|
||||
cmp ptr1+1
|
||||
bne @have64k
|
||||
lda ptr2
|
||||
cmp ptr2+1
|
||||
bne @have64k
|
||||
|
||||
ldx #VDC_CSET
|
||||
lda tmp1
|
||||
jsr vdcputreg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
ldx #VDC_CSET
|
||||
lda tmp1
|
||||
jsr vdcputreg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
|
||||
@have64k:
|
||||
lda #<256
|
||||
ldx #>256
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
lda #<256
|
||||
ldx #>256
|
||||
sta pagecount
|
||||
stx pagecount+1
|
||||
@endok:
|
||||
lda #<EM_ERR_OK
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
|
||||
test64k:
|
||||
sta tmp1
|
||||
sty ptr3
|
||||
lda #0
|
||||
sta ptr3+1
|
||||
jsr settestadr1
|
||||
lda tmp1
|
||||
jsr vdcputbyte ; write $55
|
||||
jsr settestadr1
|
||||
jsr vdcgetbyte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr vdcgetbyte ; and there
|
||||
ldy #1
|
||||
sta (ptr3),y
|
||||
pla
|
||||
dey
|
||||
sta (ptr3),y
|
||||
rts
|
||||
sta tmp1
|
||||
sty ptr3
|
||||
lda #0
|
||||
sta ptr3+1
|
||||
jsr settestadr1
|
||||
lda tmp1
|
||||
jsr vdcputbyte ; write $55
|
||||
jsr settestadr1
|
||||
jsr vdcgetbyte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr vdcgetbyte ; and there
|
||||
ldy #1
|
||||
sta (ptr3),y
|
||||
pla
|
||||
dey
|
||||
sta (ptr3),y
|
||||
rts
|
||||
|
||||
settestadr1:
|
||||
ldy #$02 ; test page 2 (here)
|
||||
.byte $2c
|
||||
ldy #$02 ; test page 2 (here)
|
||||
.byte $2c
|
||||
settestadr2:
|
||||
ldy #$42 ; or page 64+2 (there)
|
||||
lda #0
|
||||
jmp vdcsetsrcaddr
|
||||
ldy #$42 ; or page 64+2 (there)
|
||||
lda #0
|
||||
jmp vdcsetsrcaddr
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -164,7 +164,7 @@ settestadr2:
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
;on C128 restore font and clear the screen?
|
||||
;on C128 restore font and clear the screen?
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -182,42 +182,42 @@ PAGECOUNT:
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage
|
||||
stx curpage+1
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
MAP: sta curpage
|
||||
stx curpage+1
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
|
||||
jsr transferin
|
||||
jsr transferin
|
||||
|
||||
lda #<window
|
||||
ldx #>window
|
||||
rts
|
||||
rts
|
||||
|
||||
; copy a single page from (ptr1):VDCRAM to (ptr2):RAM
|
||||
|
||||
transferin:
|
||||
lda ptr1
|
||||
ldy ptr1+1
|
||||
jsr vdcsetsrcaddr ; set source address in VDC
|
||||
ldy #0
|
||||
ldx #VDC_DATA
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda VDC_DATA_REG ; get 2 bytes at a time to speed-up
|
||||
sta (ptr2),y ; (in fact up to 8 bytes could be fetched with special VDC config)
|
||||
iny
|
||||
lda VDC_DATA_REG
|
||||
sta (ptr2),y
|
||||
iny
|
||||
bne @L0
|
||||
rts
|
||||
lda ptr1
|
||||
ldy ptr1+1
|
||||
jsr vdcsetsrcaddr ; set source address in VDC
|
||||
ldy #0
|
||||
ldx #VDC_DATA
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda VDC_DATA_REG ; get 2 bytes at a time to speed-up
|
||||
sta (ptr2),y ; (in fact up to 8 bytes could be fetched with special VDC config)
|
||||
iny
|
||||
lda VDC_DATA_REG
|
||||
sta (ptr2),y
|
||||
iny
|
||||
bne @L0
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
@@ -232,36 +232,36 @@ done: rts
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT:
|
||||
lda curpage ; jump if no page mapped
|
||||
ldx curpage+1
|
||||
bmi done
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
lda curpage ; jump if no page mapped
|
||||
ldx curpage+1
|
||||
bmi done
|
||||
sta ptr1+1
|
||||
ldy #0
|
||||
sty ptr1
|
||||
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
lda #<window
|
||||
sta ptr2
|
||||
lda #>window
|
||||
sta ptr2+1
|
||||
|
||||
; fall through to transferout
|
||||
|
||||
; copy a single page from (ptr2):RAM to (ptr1):VDCRAM
|
||||
|
||||
transferout:
|
||||
lda ptr1
|
||||
ldy ptr1+1
|
||||
jsr vdcsetsrcaddr ; set source address in VDC
|
||||
ldy #0
|
||||
ldx #VDC_DATA
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda (ptr2),y ; speedup does not work for writing
|
||||
sta VDC_DATA_REG
|
||||
iny
|
||||
bne @L0
|
||||
rts
|
||||
lda ptr1
|
||||
ldy ptr1+1
|
||||
jsr vdcsetsrcaddr ; set source address in VDC
|
||||
ldy #0
|
||||
ldx #VDC_DATA
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda (ptr2),y ; speedup does not work for writing
|
||||
sta VDC_DATA_REG
|
||||
iny
|
||||
bne @L0
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
@@ -270,8 +270,8 @@ transferout:
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
|
||||
; Copy full pages
|
||||
|
||||
@@ -286,18 +286,18 @@ COPYFROM:
|
||||
@L2: ldy #EM_COPY::COUNT
|
||||
lda (ptr3),y ; Get bytes in last page
|
||||
beq @L4
|
||||
sta tmp1
|
||||
sta tmp1
|
||||
|
||||
; Transfer the bytes in the last page
|
||||
|
||||
ldy #0
|
||||
@L3: jsr vdcgetbyte
|
||||
sta (ptr2),y
|
||||
iny
|
||||
dec tmp1
|
||||
lda tmp1
|
||||
bne @L3
|
||||
@L4: rts
|
||||
ldy #0
|
||||
@L3: jsr vdcgetbyte
|
||||
sta (ptr2),y
|
||||
iny
|
||||
dec tmp1
|
||||
lda tmp1
|
||||
bne @L3
|
||||
@L4: rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
@@ -306,8 +306,8 @@ COPYFROM:
|
||||
;
|
||||
|
||||
COPYTO:
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
|
||||
; Copy full pages
|
||||
|
||||
@@ -322,52 +322,52 @@ COPYTO:
|
||||
@L2: ldy #EM_COPY::COUNT
|
||||
lda (ptr3),y ; Get bytes in last page
|
||||
beq @L4
|
||||
sta tmp1
|
||||
sta tmp1
|
||||
|
||||
; Transfer the bytes in the last page
|
||||
|
||||
ldy #0
|
||||
@L3: lda (ptr2),y
|
||||
jsr vdcputbyte
|
||||
iny
|
||||
dec tmp1
|
||||
lda tmp1
|
||||
bne @L3
|
||||
@L4: rts
|
||||
ldy #0
|
||||
@L3: lda (ptr2),y
|
||||
jsr vdcputbyte
|
||||
iny
|
||||
dec tmp1
|
||||
lda tmp1
|
||||
bne @L3
|
||||
@L4: rts
|
||||
|
||||
;-------------------------------------------------------------------------
|
||||
; Helper functions to handle VDC ram
|
||||
;
|
||||
|
||||
vdcsetsrcaddr:
|
||||
ldx #VDC_DATA_LO
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
sta VDC_DATA_REG
|
||||
dex
|
||||
tya
|
||||
stx VDC_ADDR_REG
|
||||
sta VDC_DATA_REG
|
||||
rts
|
||||
ldx #VDC_DATA_LO
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
sta VDC_DATA_REG
|
||||
dex
|
||||
tya
|
||||
stx VDC_ADDR_REG
|
||||
sta VDC_DATA_REG
|
||||
rts
|
||||
|
||||
vdcgetbyte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
vdcgetreg:
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda VDC_DATA_REG
|
||||
rts
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
lda VDC_DATA_REG
|
||||
rts
|
||||
|
||||
vdcputbyte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
vdcputreg:
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
sta VDC_DATA_REG
|
||||
rts
|
||||
stx VDC_ADDR_REG
|
||||
@L0: bit VDC_ADDR_REG
|
||||
bpl @L0
|
||||
sta VDC_DATA_REG
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for COPYFROM and COPYTO: Store the pointer to the request
|
||||
@@ -375,7 +375,7 @@ vdcputreg:
|
||||
;
|
||||
|
||||
setup:
|
||||
sta ptr3
|
||||
sta ptr3
|
||||
stx ptr3+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
@@ -392,8 +392,8 @@ setup:
|
||||
lda (ptr3),y
|
||||
sta ptr2+1 ; To
|
||||
|
||||
ldy #EM_COPY::COUNT+1
|
||||
ldy #EM_COPY::COUNT+1
|
||||
lda (ptr3),y ; Get number of pages
|
||||
sta tmp1
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
;
|
||||
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.import _get_ostype
|
||||
.import _get_ostype
|
||||
|
||||
|
||||
.macpack generic
|
||||
@@ -24,7 +24,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -58,10 +58,10 @@ window: .res 256 ; Memory "window"
|
||||
; The MAP and COMMIT entries will actually call COPYFROM/COPYTO with
|
||||
; a pointer to the following data structure:
|
||||
|
||||
dma_params: .word window ; Host address
|
||||
dma_params: .word window ; Host address
|
||||
.byte 0 ; Offset in page
|
||||
curpage: .word $0000 ; Page
|
||||
.word .sizeof (window); # bytes to move, lo, hi
|
||||
curpage: .word $0000 ; Page
|
||||
.word .sizeof (window); # bytes to move, lo, hi
|
||||
|
||||
.code
|
||||
|
||||
|
||||
@@ -14,30 +14,30 @@
|
||||
; $FF C64DTV
|
||||
;
|
||||
|
||||
.export _get_ostype
|
||||
.export _get_ostype
|
||||
|
||||
.proc _get_ostype
|
||||
.proc _get_ostype
|
||||
|
||||
ldx #0 ; Clear high byte
|
||||
ldx #0 ; Clear high byte
|
||||
|
||||
ldy #1
|
||||
sty $d03f
|
||||
ldy $d040
|
||||
cpy $d000
|
||||
bne @c64dtv
|
||||
inc $d000
|
||||
cpy $d040
|
||||
beq @c64dtv
|
||||
ldy #1
|
||||
sty $d03f
|
||||
ldy $d040
|
||||
cpy $d000
|
||||
bne @c64dtv
|
||||
inc $d000
|
||||
cpy $d040
|
||||
beq @c64dtv
|
||||
|
||||
; Normal C64
|
||||
|
||||
lda $ff80
|
||||
rts
|
||||
lda $ff80
|
||||
rts
|
||||
|
||||
; C64 DTV
|
||||
|
||||
@c64dtv:
|
||||
stx $d03f
|
||||
lda #$ff
|
||||
rts
|
||||
stx $d03f
|
||||
lda #$ff
|
||||
rts
|
||||
.endproc
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
;
|
||||
|
||||
.include "c64.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "get_tv.inc"
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; _get_tv
|
||||
|
||||
@@ -2,48 +2,48 @@
|
||||
; IRQ handling (C64 version)
|
||||
;
|
||||
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "INIT"
|
||||
.segment "INIT"
|
||||
|
||||
initirq:
|
||||
lda IRQVec
|
||||
ldx IRQVec+1
|
||||
sta IRQInd+1
|
||||
stx IRQInd+2
|
||||
lda #<IRQStub
|
||||
ldx #>IRQStub
|
||||
jmp setvec
|
||||
lda IRQVec
|
||||
ldx IRQVec+1
|
||||
sta IRQInd+1
|
||||
stx IRQInd+2
|
||||
lda #<IRQStub
|
||||
ldx #>IRQStub
|
||||
jmp setvec
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
doneirq:
|
||||
lda IRQInd+1
|
||||
ldx IRQInd+2
|
||||
setvec: sei
|
||||
sta IRQVec
|
||||
stx IRQVec+1
|
||||
cli
|
||||
rts
|
||||
lda IRQInd+1
|
||||
ldx IRQInd+2
|
||||
setvec: sei
|
||||
sta IRQVec
|
||||
stx IRQVec+1
|
||||
cli
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "LOWCODE"
|
||||
.segment "LOWCODE"
|
||||
|
||||
IRQStub:
|
||||
cld ; Just to be sure
|
||||
jsr callirq ; Call the functions
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
cld ; Just to be sure
|
||||
jsr callirq ; Call the functions
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.data
|
||||
|
||||
IRQInd: jmp $0000
|
||||
IRQInd: jmp $0000
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
@@ -52,8 +52,8 @@ JOY_COUNT = 4 ; Number of joysticks we support
|
||||
|
||||
.bss
|
||||
|
||||
temp3: .byte 0
|
||||
temp4: .byte 0
|
||||
temp3: .byte 0
|
||||
temp4: .byte 0
|
||||
|
||||
.code
|
||||
|
||||
@@ -193,16 +193,16 @@ joy1: lda #$7F
|
||||
joy2: dex
|
||||
bne joy3
|
||||
|
||||
; ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
; ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sei
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 3
|
||||
@@ -211,13 +211,13 @@ joy3: dex
|
||||
bne joy4
|
||||
|
||||
lda temp3
|
||||
eor #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 4
|
||||
|
||||
joy4: lda temp4
|
||||
eor #$1F
|
||||
eor #$1F
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
|
||||
@@ -6,48 +6,48 @@
|
||||
; Based on Ullrich von Bassewitz, 2002-12-20
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "c64.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $02 ; JOY_UP "8"
|
||||
.byte $10 ; JOY_DOWN "2"
|
||||
.byte $20 ; JOY_LEFT "4"
|
||||
.byte $08 ; JOY_RIGHT "6"
|
||||
.byte $04 ; JOY_FIRE "5" ENTER
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
.byte $02 ; JOY_UP "8"
|
||||
.byte $10 ; JOY_DOWN "2"
|
||||
.byte $20 ; JOY_LEFT "4"
|
||||
.byte $08 ; JOY_RIGHT "6"
|
||||
.byte $04 ; JOY_FIRE "5" ENTER
|
||||
.byte $00 ; JOY_FIRE2 unavailable
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READ
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READ
|
||||
.addr 0 ; IRQ entry unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
JOY_COUNT = 1 ; Number of joysticks we support
|
||||
JOY_COUNT = 1 ; Number of joysticks we support
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -71,7 +71,7 @@ INSTALL:
|
||||
lda #JOY_ERR_NO_DEVICE ; No C128 -> no numpad
|
||||
@C128: ldx #0 ; Set high byte
|
||||
|
||||
; rts ; Run into UNINSTALL instead
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -79,37 +79,37 @@ INSTALL:
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COUNT: Return the total number of available joysticks in a/x.
|
||||
;
|
||||
|
||||
COUNT: lda #JOY_COUNT
|
||||
ldx #0
|
||||
rts
|
||||
COUNT: lda #JOY_COUNT
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READ: tax ; Clear high byte
|
||||
lda #$FD
|
||||
ldy #$FE
|
||||
sei
|
||||
sta VIC_KBD_128
|
||||
lda CIA1_PRB
|
||||
and #%00110000
|
||||
eor #%00110000
|
||||
lsr
|
||||
lsr
|
||||
sty VIC_KBD_128
|
||||
eor CIA1_PRB
|
||||
iny
|
||||
sty VIC_KBD_128 ; Reset to $FF
|
||||
cli
|
||||
and #%11111110
|
||||
eor #%11111110
|
||||
rts
|
||||
READ: tax ; Clear high byte
|
||||
lda #$FD
|
||||
ldy #$FE
|
||||
sei
|
||||
sta VIC_KBD_128
|
||||
lda CIA1_PRB
|
||||
and #%00110000
|
||||
eor #%00110000
|
||||
lsr
|
||||
lsr
|
||||
sty VIC_KBD_128
|
||||
eor CIA1_PRB
|
||||
iny
|
||||
sty VIC_KBD_128 ; Reset to $FF
|
||||
cli
|
||||
and #%11111110
|
||||
eor #%11111110
|
||||
rts
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
@@ -60,7 +60,7 @@ JOY_COUNT = 4 ; Number of joysticks we support
|
||||
INSTALL:
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -84,18 +84,18 @@ COUNT:
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READ: tax ; Joystick number into X
|
||||
READ: tax ; Joystick number into X
|
||||
bne joy2
|
||||
|
||||
; Read joystick 1
|
||||
|
||||
joy1: lda #$7F
|
||||
joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 2
|
||||
@@ -103,15 +103,15 @@ joy1: lda #$7F
|
||||
joy2: dex
|
||||
bne joy3
|
||||
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sei
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 3
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; Ullrich von Bassewitz, 2002-12-20
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
@@ -66,7 +66,7 @@ INSTALL:
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
|
||||
; rts ; Run into UNINSTALL instead
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -90,32 +90,32 @@ COUNT:
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READ: tax ; Joystick number into X
|
||||
bne joy2
|
||||
READ: tax ; Joystick number into X
|
||||
bne joy2
|
||||
|
||||
; Read joystick 1
|
||||
|
||||
joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
joy1: lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
; Read joystick 2
|
||||
|
||||
joy2: ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sei
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
joy2: ldx #0
|
||||
lda #$E0
|
||||
ldy #$FF
|
||||
sei
|
||||
sta CIA1_DDRA
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void joy_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_static_stddrv
|
||||
.import _c64_stdjoy_joy
|
||||
.export _joy_static_stddrv
|
||||
.import _c64_stdjoy_joy
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
; const char joy_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_stddrv
|
||||
.export _joy_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_joy_stddrv: .asciiz "c64-stdjoy.joy"
|
||||
_joy_stddrv: .asciiz "c64-stdjoy.joy"
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; unsigned char kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.export _kbhit
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
.proc _kbhit
|
||||
|
||||
ldx #0 ; High byte of return is always zero
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
beq L9
|
||||
lda #1
|
||||
L9: rts
|
||||
|
||||
@@ -47,42 +47,42 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
; All functions are available in the kernal jump table
|
||||
|
||||
CINT = $FF81
|
||||
IOINIT = $FF84
|
||||
RAMTAS = $FF87
|
||||
RESTOR = $FF8A
|
||||
VECTOR = $FF8D
|
||||
SETMSG = $FF90
|
||||
SECOND = $FF93
|
||||
TKSA = $FF96
|
||||
MEMTOP = $FF99
|
||||
MEMBOT = $FF9C
|
||||
SCNKEY = $FF9F
|
||||
SETTMO = $FFA2
|
||||
ACPTR = $FFA5
|
||||
CIOUT = $FFA8
|
||||
UNTLK = $FFAB
|
||||
UNLSN = $FFAE
|
||||
LISTEN = $FFB1
|
||||
TALK = $FFB4
|
||||
READST = $FFB7
|
||||
SETLFS = $FFBA
|
||||
SETNAM = $FFBD
|
||||
OPEN = $FFC0
|
||||
CLOSE = $FFC3
|
||||
CHKIN = $FFC6
|
||||
CKOUT = $FFC9
|
||||
CLRCH = $FFCC
|
||||
BASIN = $FFCF
|
||||
BSOUT = $FFD2
|
||||
LOAD = $FFD5
|
||||
SAVE = $FFD8
|
||||
SETTIM = $FFDB
|
||||
RDTIM = $FFDE
|
||||
STOP = $FFE1
|
||||
GETIN = $FFE4
|
||||
CLALL = $FFE7
|
||||
UDTIM = $FFEA
|
||||
SCREEN = $FFED
|
||||
IOBASE = $FFF3
|
||||
CINT = $FF81
|
||||
IOINIT = $FF84
|
||||
RAMTAS = $FF87
|
||||
RESTOR = $FF8A
|
||||
VECTOR = $FF8D
|
||||
SETMSG = $FF90
|
||||
SECOND = $FF93
|
||||
TKSA = $FF96
|
||||
MEMTOP = $FF99
|
||||
MEMBOT = $FF9C
|
||||
SCNKEY = $FF9F
|
||||
SETTMO = $FFA2
|
||||
ACPTR = $FFA5
|
||||
CIOUT = $FFA8
|
||||
UNTLK = $FFAB
|
||||
UNLSN = $FFAE
|
||||
LISTEN = $FFB1
|
||||
TALK = $FFB4
|
||||
READST = $FFB7
|
||||
SETLFS = $FFBA
|
||||
SETNAM = $FFBD
|
||||
OPEN = $FFC0
|
||||
CLOSE = $FFC3
|
||||
CHKIN = $FFC6
|
||||
CKOUT = $FFC9
|
||||
CLRCH = $FFCC
|
||||
BASIN = $FFCF
|
||||
BSOUT = $FFD2
|
||||
LOAD = $FFD5
|
||||
SAVE = $FFD8
|
||||
SETTIM = $FFDB
|
||||
RDTIM = $FFDE
|
||||
STOP = $FFE1
|
||||
GETIN = $FFE4
|
||||
CLALL = $FFE7
|
||||
UDTIM = $FFEA
|
||||
SCREEN = $FFED
|
||||
IOBASE = $FFF3
|
||||
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
; - The "file-name" might be a path-name; don't copy the directory-components.
|
||||
; - Add a control-character quoting mechanism.
|
||||
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
.constructor initmainargs, 24
|
||||
.import __argc, __argv
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
MAXARGS = 10 ; Maximum number of arguments allowed
|
||||
REM = $8f ; BASIC token-code
|
||||
NAME_LEN = 16 ; maximum length of command-name
|
||||
|
||||
; Get possible command-line arguments. Goes into the special INIT segment,
|
||||
; which may be reused after the startup code is run
|
||||
@@ -45,25 +45,25 @@ initmainargs:
|
||||
; Because the buffer, that we're copying into, was zeroed out,
|
||||
; we don't need to add a NUL character.
|
||||
;
|
||||
ldy FNAM_LEN
|
||||
cpy #NAME_LEN + 1
|
||||
bcc L1
|
||||
ldy #NAME_LEN - 1 ; limit the length
|
||||
L0: lda (FNAM),y
|
||||
sta name,y
|
||||
L1: dey
|
||||
bpl L0
|
||||
inc __argc ; argc always is equal to, at least, 1
|
||||
ldy FNAM_LEN
|
||||
cpy #NAME_LEN + 1
|
||||
bcc L1
|
||||
ldy #NAME_LEN - 1 ; limit the length
|
||||
L0: lda (FNAM),y
|
||||
sta name,y
|
||||
L1: dey
|
||||
bpl L0
|
||||
inc __argc ; argc always is equal to, at least, 1
|
||||
|
||||
; Find the "rem" token.
|
||||
;
|
||||
ldx #0
|
||||
L2: lda BASIC_BUF,x
|
||||
beq done ; no "rem," no args.
|
||||
inx
|
||||
cmp #REM
|
||||
bne L2
|
||||
ldy #1 * 2
|
||||
ldx #0
|
||||
L2: lda BASIC_BUF,x
|
||||
beq done ; no "rem," no args.
|
||||
inx
|
||||
cmp #REM
|
||||
bne L2
|
||||
ldy #1 * 2
|
||||
|
||||
; Find the next argument
|
||||
|
||||
@@ -89,11 +89,11 @@ setterm:sta term ; Set end of argument marker
|
||||
; necessary.
|
||||
|
||||
txa ; Get low byte
|
||||
sta argv,y ; argv[y]= &arg
|
||||
iny
|
||||
lda #>BASIC_BUF
|
||||
sta argv,y
|
||||
iny
|
||||
sta argv,y ; argv[y]= &arg
|
||||
iny
|
||||
lda #>BASIC_BUF
|
||||
sta argv,y
|
||||
iny
|
||||
inc __argc ; Found another arg
|
||||
|
||||
; Search for the end of the argument
|
||||
@@ -120,21 +120,21 @@ argloop:lda BASIC_BUF,x
|
||||
|
||||
; (The last vector in argv[] already is NULL.)
|
||||
|
||||
done: lda #<argv
|
||||
ldx #>argv
|
||||
sta __argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
done: lda #<argv
|
||||
ldx #>argv
|
||||
sta __argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
|
||||
; These arrays are zeroed before initmainargs is called.
|
||||
; char name[16+1];
|
||||
; char name[16+1];
|
||||
; char* argv[MAXARGS+1]={name};
|
||||
;
|
||||
.bss
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
|
||||
.data
|
||||
argv: .addr name
|
||||
.res MAXARGS * 2
|
||||
.res MAXARGS * 2
|
||||
|
||||
|
||||
@@ -64,13 +64,13 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
txa
|
||||
adc #0
|
||||
bne @L1 ; Branch if high byte not zero
|
||||
lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
||||
and #MOUSE_SPR_NMASK ; Clear high bit for sprite
|
||||
lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
||||
and #MOUSE_SPR_NMASK ; Clear high bit for sprite
|
||||
sta VIC_SPR_HI_X
|
||||
rts
|
||||
|
||||
@L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
||||
ora #MOUSE_SPR_MASK ; Set high bit for sprite
|
||||
@L1: lda VIC_SPR_HI_X ; Get high X bits of all sprites
|
||||
ora #MOUSE_SPR_MASK ; Set high bit for sprite
|
||||
sta VIC_SPR_HI_X
|
||||
rts
|
||||
|
||||
@@ -83,7 +83,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
.proc movey
|
||||
|
||||
add #50 ; Y correction (first visible line)
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -72,7 +72,7 @@ CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||
;----------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
SCREEN_HEIGHT = YSIZE * 8 - 1 ; (origin is zero)
|
||||
SCREEN_HEIGHT = YSIZE * 8 - 1 ; (origin is zero)
|
||||
SCREEN_WIDTH = XSIZE * 8 - 1
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -83,19 +83,19 @@ SCREEN_WIDTH = XSIZE * 8 - 1
|
||||
.bss
|
||||
|
||||
Vars:
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; button status bits
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; button status bits
|
||||
|
||||
OldValue: .res 1 ; Temp for MoveCheck routine
|
||||
NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
OldValue: .res 1 ; Temp for MoveCheck routine
|
||||
NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
|
||||
; Default values for above variables
|
||||
|
||||
@@ -111,7 +111,7 @@ NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte %00000000 ; Buttons
|
||||
.byte %00000000 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -200,7 +200,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -214,7 +214,7 @@ GETBOX: sta ptr1
|
||||
sta (ptr1),y
|
||||
dey
|
||||
bpl @L1
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -238,42 +238,42 @@ MOVE: sei ; No interrupts
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda Buttons
|
||||
lda Buttons
|
||||
ldx #0
|
||||
and #$1F
|
||||
and #$1F
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -284,15 +284,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
jsr BUTTONS ; Will not touch ptr1
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
jsr BUTTONS ; Will not touch ptr1
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -316,51 +316,51 @@ IRQ:
|
||||
; Record the state of the buttons.
|
||||
; Avoid crosstalk between the keyboard and the mouse.
|
||||
|
||||
ldy #%00000000 ; Set ports A and B to input
|
||||
sty CIA1_DDRB
|
||||
sty CIA1_DDRA ; Keyboard won't look like mouse
|
||||
lda CIA1_PRB ; Read Control-Port 1
|
||||
dec CIA1_DDRA ; Set port A back to output
|
||||
eor #%11111111 ; Bit goes up when button goes down
|
||||
sta Buttons
|
||||
beq @L0 ;(bze)
|
||||
dec CIA1_DDRB ; Mouse won't look like keyboard
|
||||
sty CIA1_PRB ; Set "all keys pushed"
|
||||
ldy #%00000000 ; Set ports A and B to input
|
||||
sty CIA1_DDRB
|
||||
sty CIA1_DDRA ; Keyboard won't look like mouse
|
||||
lda CIA1_PRB ; Read Control-Port 1
|
||||
dec CIA1_DDRA ; Set port A back to output
|
||||
eor #%11111111 ; Bit goes up when button goes down
|
||||
sta Buttons
|
||||
beq @L0 ;(bze)
|
||||
dec CIA1_DDRB ; Mouse won't look like keyboard
|
||||
sty CIA1_PRB ; Set "all keys pushed"
|
||||
|
||||
@L0: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
@L0: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
bcc @SkipX
|
||||
sty OldPotX
|
||||
sty OldPotX
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
@@ -369,43 +369,43 @@ IRQ:
|
||||
|
||||
; Calculate the Y movement vector
|
||||
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
bcc @SkipY
|
||||
sty OldPotY
|
||||
sty OldPotY
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
sta OldValue
|
||||
lda YPos
|
||||
sub OldValue
|
||||
tay
|
||||
stx OldValue
|
||||
lda YPos+1
|
||||
sbc OldValue
|
||||
tax
|
||||
sta OldValue
|
||||
lda YPos
|
||||
sub OldValue
|
||||
tay
|
||||
stx OldValue
|
||||
lda YPos+1
|
||||
sbc OldValue
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new Y pos
|
||||
|
||||
@@ -421,38 +421,38 @@ IRQ:
|
||||
;
|
||||
; Move check routine, called for both coordinates.
|
||||
;
|
||||
; Entry: y = old value of pot register
|
||||
; a = current value of pot register
|
||||
; Exit: y = value to use for old value
|
||||
; x/a = delta value for position
|
||||
; Entry: y = old value of pot register
|
||||
; a = current value of pot register
|
||||
; Exit: y = value to use for old value
|
||||
; x/a = delta value for position
|
||||
;
|
||||
|
||||
MoveCheck:
|
||||
sty OldValue
|
||||
sta NewValue
|
||||
ldx #$00
|
||||
sty OldValue
|
||||
sta NewValue
|
||||
ldx #$00
|
||||
|
||||
sub OldValue ; a = mod64 (new - old)
|
||||
and #%01111111
|
||||
cmp #%01000000 ; if (a > 0)
|
||||
bcs @L1 ;
|
||||
lsr a ; a /= 2;
|
||||
beq @L2 ; if (a != 0)
|
||||
ldy NewValue ; y = NewValue
|
||||
sub OldValue ; a = mod64 (new - old)
|
||||
and #%01111111
|
||||
cmp #%01000000 ; if (a > 0)
|
||||
bcs @L1 ;
|
||||
lsr a ; a /= 2;
|
||||
beq @L2 ; if (a != 0)
|
||||
ldy NewValue ; y = NewValue
|
||||
sec
|
||||
rts ; return
|
||||
rts ; return
|
||||
|
||||
@L1: ora #%11000000 ; else, "or" in high-order bits
|
||||
cmp #$FF ; if (a != -1)
|
||||
beq @L2
|
||||
sec
|
||||
ror a ; a /= 2
|
||||
dex ; high byte = -1 (X = $FF)
|
||||
ldy NewValue
|
||||
@L1: ora #%11000000 ; else, "or" in high-order bits
|
||||
cmp #$FF ; if (a != -1)
|
||||
beq @L2
|
||||
sec
|
||||
rts
|
||||
ror a ; a /= 2
|
||||
dex ; high byte = -1 (X = $FF)
|
||||
ldy NewValue
|
||||
sec
|
||||
rts
|
||||
|
||||
@L2: txa ; A = $00
|
||||
@L2: txa ; A = $00
|
||||
clc
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -92,11 +92,11 @@ SCREEN_WIDTH = 320
|
||||
Vars:
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
|
||||
; Temporary value used in the int handler
|
||||
|
||||
@@ -113,7 +113,7 @@ Temp: .res 1
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.byte 0 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -202,7 +202,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -218,7 +218,7 @@ GETBOX: sta ptr1
|
||||
dey
|
||||
bpl @L1
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -242,41 +242,41 @@ MOVE: sei ; No interrupts
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -287,15 +287,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -316,15 +316,15 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
|
||||
; Avoid crosstalk between the keyboard and a joystick.
|
||||
|
||||
IRQ: ldy #%00000000 ; Set ports A and B to input
|
||||
sty CIA1_DDRB
|
||||
sty CIA1_DDRA ; Keyboard won't look like joystick
|
||||
lda CIA1_PRB ; Read Control-Port 1
|
||||
dec CIA1_DDRA ; Set port A back to output
|
||||
eor #%11111111 ; Bit goes up when switch goes down
|
||||
beq @Save ;(bze)
|
||||
dec CIA1_DDRB ; Joystick won't look like keyboard
|
||||
sty CIA1_PRB ; Set "all keys pushed"
|
||||
IRQ: ldy #%00000000 ; Set ports A and B to input
|
||||
sty CIA1_DDRB
|
||||
sty CIA1_DDRA ; Keyboard won't look like joystick
|
||||
lda CIA1_PRB ; Read Control-Port 1
|
||||
dec CIA1_DDRA ; Set port A back to output
|
||||
eor #%11111111 ; Bit goes up when switch goes down
|
||||
beq @Save ;(bze)
|
||||
dec CIA1_DDRB ; Joystick won't look like keyboard
|
||||
sty CIA1_PRB ; Set "all keys pushed"
|
||||
@Save: sta Temp
|
||||
|
||||
; Check for a pressed button and place the result into Buttons
|
||||
@@ -338,45 +338,45 @@ IRQ: ldy #%00000000 ; Set ports A and B to input
|
||||
; Check left/right
|
||||
|
||||
lda Temp ; Read joystick #0
|
||||
and #(JOY::LEFT | JOY::RIGHT)
|
||||
beq @SkipX ;
|
||||
and #(JOY::LEFT | JOY::RIGHT)
|
||||
beq @SkipX ;
|
||||
|
||||
; We will cheat here and rely on the fact that either the left, OR the right
|
||||
; bit can be active
|
||||
|
||||
and #JOY::RIGHT ; Check RIGHT bit
|
||||
bne @Right
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
@Right: lda #$01
|
||||
ldx #$00
|
||||
and #JOY::RIGHT ; Check RIGHT bit
|
||||
bne @Right
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
@Right: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
@@ -386,45 +386,45 @@ IRQ: ldy #%00000000 ; Set ports A and B to input
|
||||
; Calculate the Y movement vector
|
||||
|
||||
@SkipX: lda Temp ; Read joystick #0
|
||||
and #(JOY::UP | JOY::DOWN) ; Check up/down
|
||||
beq @SkipY ;
|
||||
and #(JOY::UP | JOY::DOWN) ; Check up/down
|
||||
beq @SkipY ;
|
||||
|
||||
; We will cheat here and rely on the fact that either the up, OR the down
|
||||
; bit can be active
|
||||
|
||||
lsr a ; Check UP bit
|
||||
bcc @Down
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
lsr a ; Check UP bit
|
||||
bcc @Down
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
|
||||
@@ -5,59 +5,59 @@
|
||||
; Stefan Haubenthal, 2006-08-20
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c64.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
HEADER:
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6d, $6f, $75 ; "mou"
|
||||
.byte MOUSE_API_VERSION ; Mouse driver API version number
|
||||
.byte $6d, $6f, $75 ; "mou"
|
||||
.byte MOUSE_API_VERSION ; Mouse driver API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr HIDE
|
||||
.addr SHOW
|
||||
.addr SETBOX
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr HIDE
|
||||
.addr SHOW
|
||||
.addr SETBOX
|
||||
.addr GETBOX
|
||||
.addr MOVE
|
||||
.addr BUTTONS
|
||||
.addr POS
|
||||
.addr INFO
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
.addr MOVE
|
||||
.addr BUTTONS
|
||||
.addr POS
|
||||
.addr INFO
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
CSHOW: jmp $0000 ; Show the cursor
|
||||
CMOVEX: jmp $0000 ; Move the cursor to X coord
|
||||
CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
CSHOW: jmp $0000 ; Show the cursor
|
||||
CMOVEX: jmp $0000 ; Move the cursor to X coord
|
||||
CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
SCREEN_HEIGHT = 200
|
||||
SCREEN_WIDTH = 320
|
||||
SCREEN_HEIGHT = 200
|
||||
SCREEN_WIDTH = 320
|
||||
|
||||
.enum JOY
|
||||
UP = $01
|
||||
DOWN = $02
|
||||
LEFT = $04
|
||||
RIGHT = $08
|
||||
FIRE = $10
|
||||
.enum JOY
|
||||
UP = $01
|
||||
DOWN = $02
|
||||
LEFT = $04
|
||||
RIGHT = $08
|
||||
FIRE = $10
|
||||
.endenum
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -68,30 +68,30 @@ SCREEN_WIDTH = 320
|
||||
.bss
|
||||
|
||||
Vars:
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
|
||||
; Temporary value used in the int handler
|
||||
|
||||
Temp: .res 1
|
||||
Temp: .res 1
|
||||
|
||||
; Default values for above variables
|
||||
|
||||
.rodata
|
||||
|
||||
.proc DefVars
|
||||
.word SCREEN_HEIGHT/2 ; YPos
|
||||
.word SCREEN_WIDTH/2 ; XPos
|
||||
.word 0 ; XMin
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.proc DefVars
|
||||
.word SCREEN_HEIGHT/2 ; YPos
|
||||
.word SCREEN_WIDTH/2 ; XPos
|
||||
.word 0 ; XMin
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -105,37 +105,37 @@ INSTALL:
|
||||
|
||||
; Initialize variables. Just copy the default stuff over
|
||||
|
||||
ldx #.sizeof(DefVars)-1
|
||||
@L1: lda DefVars,x
|
||||
sta Vars,x
|
||||
dex
|
||||
bpl @L1
|
||||
ldx #.sizeof(DefVars)-1
|
||||
@L1: lda DefVars,x
|
||||
sta Vars,x
|
||||
dex
|
||||
bpl @L1
|
||||
|
||||
; Be sure the mouse cursor is invisible and at the default location. We
|
||||
; need to do that here, because our mouse interrupt handler doesn't set the
|
||||
; mouse position if it hasn't changed.
|
||||
|
||||
sei
|
||||
jsr CHIDE
|
||||
lda XPos
|
||||
ldx XPos+1
|
||||
jsr CMOVEX
|
||||
lda YPos
|
||||
ldx YPos+1
|
||||
jsr CMOVEY
|
||||
cli
|
||||
sei
|
||||
jsr CHIDE
|
||||
lda XPos
|
||||
ldx XPos+1
|
||||
jsr CMOVEX
|
||||
lda YPos
|
||||
ldx YPos+1
|
||||
jsr CMOVEY
|
||||
cli
|
||||
|
||||
; Done, return zero (= MOUSE_ERR_OK)
|
||||
|
||||
ldx #$00
|
||||
txa
|
||||
rts
|
||||
ldx #$00
|
||||
txa
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; No return code required (the driver is removed from memory on return).
|
||||
|
||||
UNINSTALL = HIDE ; Hide cursor on exit
|
||||
UNINSTALL = HIDE ; Hide cursor on exit
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; HIDE routine. Is called to hide the mouse pointer. The mouse kernel manages
|
||||
@@ -144,10 +144,10 @@ UNINSTALL = HIDE ; Hide cursor on exit
|
||||
; no special action is required besides hiding the mouse cursor.
|
||||
; No return code required.
|
||||
|
||||
HIDE: sei
|
||||
jsr CHIDE
|
||||
cli
|
||||
rts
|
||||
HIDE: sei
|
||||
jsr CHIDE
|
||||
cli
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; SHOW routine. Is called to show the mouse pointer. The mouse kernel manages
|
||||
@@ -156,10 +156,10 @@ HIDE: sei
|
||||
; no special action is required besides enabling the mouse cursor.
|
||||
; No return code required.
|
||||
|
||||
SHOW: sei
|
||||
jsr CSHOW
|
||||
cli
|
||||
rts
|
||||
SHOW: sei
|
||||
jsr CSHOW
|
||||
cli
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; SETBOX: Set the mouse bounding box. The parameters are passed as they come
|
||||
@@ -180,7 +180,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -198,7 +198,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -208,55 +208,55 @@ GETBOX: sta ptr1
|
||||
; the screen). No return code required.
|
||||
;
|
||||
|
||||
MOVE: sei ; No interrupts
|
||||
MOVE: sei ; No interrupts
|
||||
|
||||
sta YPos
|
||||
stx YPos+1 ; New Y position
|
||||
jsr CMOVEY ; Set it
|
||||
sta YPos
|
||||
stx YPos+1 ; New Y position
|
||||
jsr CMOVEY ; Set it
|
||||
|
||||
ldy #$01
|
||||
lda (sp),y
|
||||
sta XPos+1
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
ldy #$01
|
||||
lda (sp),y
|
||||
sta XPos+1
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -267,15 +267,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -283,108 +283,108 @@ INFO: jsr POS
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
ldx #>MOUSE_ERR_INV_IOCTL
|
||||
rts
|
||||
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
ldx #>MOUSE_ERR_INV_IOCTL
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IRQ: Irq handler entry point. Called as a subroutine but in IRQ context
|
||||
; (so be careful).
|
||||
;
|
||||
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read port #1
|
||||
and #%00001100
|
||||
eor #%00001100 ; Make all bits active high
|
||||
asl
|
||||
sta Buttons
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
and #%00000001
|
||||
ora Buttons
|
||||
sta Buttons
|
||||
ldx #%01000000
|
||||
stx CIA1_PRA
|
||||
ldy #0
|
||||
: dey
|
||||
bne :-
|
||||
ldx SID_ADConv1
|
||||
stx XPos
|
||||
ldx SID_ADConv2
|
||||
stx YPos
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read port #1
|
||||
and #%00001100
|
||||
eor #%00001100 ; Make all bits active high
|
||||
asl
|
||||
sta Buttons
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
and #%00000001
|
||||
ora Buttons
|
||||
sta Buttons
|
||||
ldx #%01000000
|
||||
stx CIA1_PRA
|
||||
ldy #0
|
||||
: dey
|
||||
bne :-
|
||||
ldx SID_ADConv1
|
||||
stx XPos
|
||||
ldx SID_ADConv2
|
||||
stx YPos
|
||||
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
lda #$01
|
||||
ldx #$00
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
tya
|
||||
jsr CMOVEX
|
||||
tya
|
||||
jsr CMOVEX
|
||||
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
tya
|
||||
jmp CMOVEY
|
||||
tya
|
||||
jmp CMOVEY
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void mouse_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _mouse_static_stddrv
|
||||
.import _c64_1351_mou
|
||||
.export _mouse_static_stddrv
|
||||
.import _c64_1351_mou
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
; const char mouse_stddrv[];
|
||||
;
|
||||
|
||||
.export _mouse_stddrv
|
||||
.export _mouse_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_mouse_stddrv: .asciiz "c64-1351.mou"
|
||||
_mouse_stddrv: .asciiz "c64-1351.mou"
|
||||
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; /* Initialize the random number generator */
|
||||
;
|
||||
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.export __randomize
|
||||
.import _srand
|
||||
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
__randomize:
|
||||
ldx VIC_HLINE ; Use VIC rasterline as high byte
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
; unsigned char revers (unsigned char onoff);
|
||||
;
|
||||
|
||||
.export _revers
|
||||
.export _revers
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
.proc _revers
|
||||
|
||||
ldx #$00 ; Assume revers off
|
||||
tay ; Test onoff
|
||||
beq L1 ; Jump if off
|
||||
ldx #$80 ; Load on value
|
||||
ldy #$00 ; Assume old value is zero
|
||||
L1: lda RVS ; Load old value
|
||||
stx RVS ; Set new value
|
||||
beq L2 ; Jump if old value zero
|
||||
iny ; Make old value = 1
|
||||
L2: ldx #$00 ; Load high byte of result
|
||||
tya ; Load low byte, set CC
|
||||
rts
|
||||
ldx #$00 ; Assume revers off
|
||||
tay ; Test onoff
|
||||
beq L1 ; Jump if off
|
||||
ldx #$80 ; Load on value
|
||||
ldy #$00 ; Assume old value is zero
|
||||
L1: lda RVS ; Load old value
|
||||
stx RVS ; Set new value
|
||||
beq L2 ; Jump if old value zero
|
||||
iny ; Make old value = 1
|
||||
L2: ldx #$00 ; Load high byte of result
|
||||
tya ; Load low byte, set CC
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
.include "zeropage.inc"
|
||||
.include "ser-kernel.inc"
|
||||
.include "ser-error.inc"
|
||||
.include "c64.inc"
|
||||
.include "c64.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -52,7 +52,7 @@
|
||||
;----------------------------------------------------------------------------
|
||||
; I/O definitions
|
||||
|
||||
ACIA = $DE00
|
||||
ACIA = $DE00
|
||||
ACIA_DATA = ACIA+0 ; Data register
|
||||
ACIA_STATUS = ACIA+1 ; Status register
|
||||
ACIA_CMD = ACIA+2 ; Command register
|
||||
@@ -73,16 +73,16 @@ SendTail = $F9 ; Tail of send buffer
|
||||
SendFreeCnt = $FA ; Number of bytes free in send buffer
|
||||
|
||||
.bss
|
||||
Stopped: .res 1 ; Flow-stopped flag
|
||||
RtsOff: .res 1 ;
|
||||
Stopped: .res 1 ; Flow-stopped flag
|
||||
RtsOff: .res 1 ;
|
||||
|
||||
; Send and receive buffers: 256 bytes each
|
||||
RecvBuf: .res 256
|
||||
SendBuf: .res 256
|
||||
RecvBuf: .res 256
|
||||
SendBuf: .res 256
|
||||
|
||||
.data
|
||||
NmiContinue: .byte $4c ; JMP instruction for NMI save -- continue
|
||||
NmiSave: .res 2 ; normal NMI handler
|
||||
NmiContinue: .byte $4c ; JMP instruction for NMI save -- continue
|
||||
NmiSave: .res 2 ; normal NMI handler
|
||||
|
||||
.rodata
|
||||
|
||||
@@ -138,25 +138,25 @@ INSTALL:
|
||||
|
||||
; Deactivate DTR and disable 6551 interrupts
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Set up the nmi vector
|
||||
|
||||
lda NMIVec
|
||||
ldy NMIVec+1
|
||||
sta NmiSave+0
|
||||
sty NmiSave+1
|
||||
lda #<NmiHandler
|
||||
ldy #>NmiHandler
|
||||
SetNMI: sta NMIVec
|
||||
sty NMIVec+1
|
||||
lda NMIVec
|
||||
ldy NMIVec+1
|
||||
sta NmiSave+0
|
||||
sty NmiSave+1
|
||||
lda #<NmiHandler
|
||||
ldy #>NmiHandler
|
||||
SetNMI: sta NMIVec
|
||||
sty NMIVec+1
|
||||
|
||||
; Done, return an error code
|
||||
|
||||
lda #<SER_ERR_OK
|
||||
tax ; A is zero
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -166,14 +166,14 @@ UNINSTALL:
|
||||
|
||||
; Stop interrupts, drop DTR
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Restore NMI vector and return OK
|
||||
|
||||
lda NmiSave+0
|
||||
ldy NmiSave+1
|
||||
jmp SetNMI
|
||||
lda NmiSave+0
|
||||
ldy NmiSave+1
|
||||
jmp SetNMI
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; PARAMS routine. A pointer to a ser_params structure is passed in ptr1.
|
||||
@@ -183,10 +183,10 @@ OPEN:
|
||||
|
||||
; Check if the handshake setting is valid
|
||||
|
||||
ldy #SER_PARAMS::HANDSHAKE ; Handshake
|
||||
ldy #SER_PARAMS::HANDSHAKE ; Handshake
|
||||
lda (ptr1),y
|
||||
cmp #SER_HS_HW ; This is all we support
|
||||
bne InvParam
|
||||
cmp #SER_HS_HW ; This is all we support
|
||||
bne InvParam
|
||||
|
||||
; Initialize buffers
|
||||
|
||||
@@ -199,48 +199,48 @@ OPEN:
|
||||
lda (ptr1),y ; Baudrate index
|
||||
tay
|
||||
lda BaudTable,y ; Get 6551 value
|
||||
bmi InvBaud ; Branch if rate not supported
|
||||
bmi InvBaud ; Branch if rate not supported
|
||||
sta tmp1
|
||||
|
||||
ldy #SER_PARAMS::DATABITS ; Databits
|
||||
ldy #SER_PARAMS::DATABITS ; Databits
|
||||
lda (ptr1),y
|
||||
tay
|
||||
lda BitTable,y
|
||||
ora tmp1
|
||||
sta tmp1
|
||||
|
||||
ldy #SER_PARAMS::STOPBITS ; Stopbits
|
||||
ldy #SER_PARAMS::STOPBITS ; Stopbits
|
||||
lda (ptr1),y
|
||||
tay
|
||||
lda StopTable,y
|
||||
ora tmp1
|
||||
ora #%00010000 ; Receiver clock source = baudrate
|
||||
sta ACIA_CTRL
|
||||
ora #%00010000 ; Receiver clock source = baudrate
|
||||
sta ACIA_CTRL
|
||||
|
||||
; Set the value for the command register. We remember the base value in
|
||||
; RtsOff, since we will have to manipulate ACIA_CMD often.
|
||||
|
||||
ldy #SER_PARAMS::PARITY ; Parity
|
||||
ldy #SER_PARAMS::PARITY ; Parity
|
||||
lda (ptr1),y
|
||||
tay
|
||||
lda ParityTable,y
|
||||
ora #%00000001 ; DTR active
|
||||
sta RtsOff
|
||||
ora #%00001000 ; Enable receive interrupts
|
||||
sta ACIA_CMD
|
||||
ora #%00000001 ; DTR active
|
||||
sta RtsOff
|
||||
ora #%00001000 ; Enable receive interrupts
|
||||
sta ACIA_CMD
|
||||
|
||||
; Done
|
||||
|
||||
lda #<SER_ERR_OK
|
||||
tax ; A is zero
|
||||
rts
|
||||
rts
|
||||
|
||||
; Invalid parameter
|
||||
|
||||
InvParam:
|
||||
lda #<SER_ERR_INIT_FAILED
|
||||
ldx #>SER_ERR_INIT_FAILED
|
||||
rts
|
||||
lda #<SER_ERR_INIT_FAILED
|
||||
ldx #>SER_ERR_INIT_FAILED
|
||||
rts
|
||||
|
||||
; Baud rate not available
|
||||
|
||||
@@ -258,8 +258,8 @@ CLOSE:
|
||||
|
||||
; Stop interrupts, drop DTR
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Initalize buffers. Returns zero in a
|
||||
|
||||
@@ -269,7 +269,7 @@ CLOSE:
|
||||
|
||||
lda #<SER_ERR_OK
|
||||
tax ; A is zero
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GET: Will fetch a character from the receive buffer and store it into the
|
||||
@@ -277,43 +277,43 @@ CLOSE:
|
||||
; return.
|
||||
;
|
||||
|
||||
GET: ldx SendFreeCnt ; Send data if necessary
|
||||
inx ; X == $FF?
|
||||
beq @L1
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
GET: ldx SendFreeCnt ; Send data if necessary
|
||||
inx ; X == $FF?
|
||||
beq @L1
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
|
||||
; Check for buffer empty
|
||||
|
||||
@L1: lda RecvFreeCnt ; (25)
|
||||
cmp #$ff
|
||||
bne @L2
|
||||
lda #<SER_ERR_NO_DATA
|
||||
ldx #>SER_ERR_NO_DATA
|
||||
rts
|
||||
@L1: lda RecvFreeCnt ; (25)
|
||||
cmp #$ff
|
||||
bne @L2
|
||||
lda #<SER_ERR_NO_DATA
|
||||
ldx #>SER_ERR_NO_DATA
|
||||
rts
|
||||
|
||||
; Check for flow stopped & enough free: release flow control
|
||||
|
||||
@L2: ldx Stopped ; (34)
|
||||
beq @L3
|
||||
cmp #63
|
||||
bcc @L3
|
||||
lda #$00
|
||||
sta Stopped
|
||||
lda RtsOff
|
||||
ora #%00001000
|
||||
sta ACIA_CMD
|
||||
@L2: ldx Stopped ; (34)
|
||||
beq @L3
|
||||
cmp #63
|
||||
bcc @L3
|
||||
lda #$00
|
||||
sta Stopped
|
||||
lda RtsOff
|
||||
ora #%00001000
|
||||
sta ACIA_CMD
|
||||
|
||||
; Get byte from buffer
|
||||
|
||||
@L3: ldx RecvHead ; (41)
|
||||
lda RecvBuf,x
|
||||
inc RecvHead
|
||||
inc RecvFreeCnt
|
||||
ldx #$00 ; (59)
|
||||
sta (ptr1,x)
|
||||
txa ; Return code = 0
|
||||
rts
|
||||
@L3: ldx RecvHead ; (41)
|
||||
lda RecvBuf,x
|
||||
inc RecvHead
|
||||
inc RecvFreeCnt
|
||||
ldx #$00 ; (59)
|
||||
sta (ptr1,x)
|
||||
txa ; Return code = 0
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; PUT: Output character in A.
|
||||
@@ -324,40 +324,40 @@ PUT:
|
||||
|
||||
; Try to send
|
||||
|
||||
ldx SendFreeCnt
|
||||
inx ; X = $ff?
|
||||
beq @L2
|
||||
pha
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
pla
|
||||
ldx SendFreeCnt
|
||||
inx ; X = $ff?
|
||||
beq @L2
|
||||
pha
|
||||
lda #$00
|
||||
jsr TryToSend
|
||||
pla
|
||||
|
||||
; Put byte into send buffer & send
|
||||
|
||||
@L2: ldx SendFreeCnt
|
||||
bne @L3
|
||||
lda #<SER_ERR_OVERFLOW ; X is already zero
|
||||
rts
|
||||
@L2: ldx SendFreeCnt
|
||||
bne @L3
|
||||
lda #<SER_ERR_OVERFLOW ; X is already zero
|
||||
rts
|
||||
|
||||
@L3: ldx SendTail
|
||||
sta SendBuf,x
|
||||
inc SendTail
|
||||
dec SendFreeCnt
|
||||
lda #$ff
|
||||
jsr TryToSend
|
||||
lda #<SER_ERR_OK
|
||||
tax
|
||||
rts
|
||||
@L3: ldx SendTail
|
||||
sta SendBuf,x
|
||||
inc SendTail
|
||||
dec SendFreeCnt
|
||||
lda #$ff
|
||||
jsr TryToSend
|
||||
lda #<SER_ERR_OK
|
||||
tax
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; STATUS: Return the status in the variable pointed to by ptr1.
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
STATUS: lda ACIA_STATUS
|
||||
ldx #0
|
||||
sta (ptr1,x)
|
||||
txa ; SER_ERR_OK
|
||||
STATUS: lda ACIA_STATUS
|
||||
ldx #0
|
||||
sta (ptr1,x)
|
||||
txa ; SER_ERR_OK
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -390,68 +390,68 @@ IRQ = $0000
|
||||
;
|
||||
|
||||
NmiHandler:
|
||||
pha
|
||||
lda ACIA_STATUS ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq @L9 ;(2*)
|
||||
cld
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
@L1: lda ACIA_DATA ;(4) data ;get byte and put into receive buffer
|
||||
ldy RecvTail ;(4)
|
||||
ldx RecvFreeCnt ;(4)
|
||||
beq @L3 ;(2*) Jump if no space in receive buffer
|
||||
sta RecvBuf,y ;(5)
|
||||
inc RecvTail ;(6)
|
||||
dec RecvFreeCnt ;(6)
|
||||
cpx #33 ;(2) check for buffer space low
|
||||
bcc @L2 ;(2*)
|
||||
jmp NMIEXIT ;(3)
|
||||
pha
|
||||
lda ACIA_STATUS ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq @L9 ;(2*)
|
||||
cld
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
@L1: lda ACIA_DATA ;(4) data ;get byte and put into receive buffer
|
||||
ldy RecvTail ;(4)
|
||||
ldx RecvFreeCnt ;(4)
|
||||
beq @L3 ;(2*) Jump if no space in receive buffer
|
||||
sta RecvBuf,y ;(5)
|
||||
inc RecvTail ;(6)
|
||||
dec RecvFreeCnt ;(6)
|
||||
cpx #33 ;(2) check for buffer space low
|
||||
bcc @L2 ;(2*)
|
||||
jmp NMIEXIT ;(3)
|
||||
|
||||
; Assert flow control
|
||||
|
||||
@L2: lda RtsOff ;(3) assert flow control if buffer space too low
|
||||
sta ACIA_CMD ;(4) command
|
||||
sta Stopped ;(3)
|
||||
@L3: jmp NMIEXIT ;(3)
|
||||
@L2: lda RtsOff ;(3) assert flow control if buffer space too low
|
||||
sta ACIA_CMD ;(4) command
|
||||
sta Stopped ;(3)
|
||||
@L3: jmp NMIEXIT ;(3)
|
||||
|
||||
@L9: pla
|
||||
jmp NmiContinue
|
||||
@L9: pla
|
||||
jmp NmiContinue
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Try to send a byte. Internal routine. A = TryHard
|
||||
|
||||
.proc TryToSend
|
||||
|
||||
sta tmp1 ; Remember tryHard flag
|
||||
@L0: lda SendFreeCnt
|
||||
cmp #$ff
|
||||
beq @L3 ; Bail out
|
||||
sta tmp1 ; Remember tryHard flag
|
||||
@L0: lda SendFreeCnt
|
||||
cmp #$ff
|
||||
beq @L3 ; Bail out
|
||||
|
||||
; Check for flow stopped
|
||||
|
||||
@L1: lda Stopped
|
||||
bne @L3 ; Bail out
|
||||
@L1: lda Stopped
|
||||
bne @L3 ; Bail out
|
||||
|
||||
; Check that swiftlink is ready to send
|
||||
|
||||
@L2: lda ACIA_STATUS
|
||||
and #$10
|
||||
bne @L4
|
||||
bit tmp1 ;keep trying if must try hard
|
||||
bmi @L0
|
||||
@L3: rts
|
||||
@L2: lda ACIA_STATUS
|
||||
and #$10
|
||||
bne @L4
|
||||
bit tmp1 ;keep trying if must try hard
|
||||
bmi @L0
|
||||
@L3: rts
|
||||
|
||||
; Send byte and try again
|
||||
|
||||
@L4: ldx SendHead
|
||||
lda SendBuf,x
|
||||
sta ACIA_DATA
|
||||
inc SendHead
|
||||
inc SendFreeCnt
|
||||
jmp @L0
|
||||
@L4: ldx SendHead
|
||||
lda SendBuf,x
|
||||
sta ACIA_DATA
|
||||
inc SendHead
|
||||
inc SendFreeCnt
|
||||
jmp @L0
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -460,14 +460,14 @@ NmiHandler:
|
||||
; Initialize buffers
|
||||
|
||||
InitBuffers:
|
||||
ldx #0
|
||||
ldx #0
|
||||
stx Stopped
|
||||
stx RecvHead
|
||||
stx RecvTail
|
||||
stx SendHead
|
||||
stx SendTail
|
||||
stx RecvHead
|
||||
stx RecvTail
|
||||
stx SendHead
|
||||
stx SendTail
|
||||
dex ; X = 255
|
||||
stx RecvFreeCnt
|
||||
stx SendFreeCnt
|
||||
stx RecvFreeCnt
|
||||
stx SendFreeCnt
|
||||
rts
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
; Oliver Schmidt, 2012-09-30
|
||||
;
|
||||
|
||||
.exportzp ST := $90 ; IEC status byte
|
||||
.exportzp ST := $90 ; IEC status byte
|
||||
|
||||
@@ -11,43 +11,43 @@
|
||||
|
||||
.include "time.inc"
|
||||
.include "c64.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "get_tv.inc"
|
||||
|
||||
.constructor initsystime
|
||||
.importzp tmp1, tmp2
|
||||
.import _get_tv, _get_ostype
|
||||
.importzp tmp1, tmp2
|
||||
.import _get_tv, _get_ostype
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
.code
|
||||
|
||||
.proc __systime
|
||||
.proc __systime
|
||||
|
||||
lda CIA1_TODHR
|
||||
bpl AM
|
||||
and #%01111111
|
||||
sed
|
||||
clc
|
||||
adc #$12
|
||||
cld
|
||||
AM: jsr BCD2dec
|
||||
sta TM + tm::tm_hour
|
||||
lda CIA1_TODMIN
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_min
|
||||
lda CIA1_TODSEC
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_sec
|
||||
lda CIA1_TOD10 ; Dummy read to unfreeze
|
||||
lda #<TM
|
||||
ldx #>TM
|
||||
jmp _mktime
|
||||
lda CIA1_TODHR
|
||||
bpl AM
|
||||
and #%01111111
|
||||
sed
|
||||
clc
|
||||
adc #$12
|
||||
cld
|
||||
AM: jsr BCD2dec
|
||||
sta TM + tm::tm_hour
|
||||
lda CIA1_TODMIN
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_min
|
||||
lda CIA1_TODSEC
|
||||
jsr BCD2dec
|
||||
sta TM + tm::tm_sec
|
||||
lda CIA1_TOD10 ; Dummy read to unfreeze
|
||||
lda #<TM
|
||||
ldx #>TM
|
||||
jmp _mktime
|
||||
|
||||
; dec = (((BCD>>4)*10) + (BCD&0xf))
|
||||
BCD2dec:tax
|
||||
and #%00001111
|
||||
sta tmp1
|
||||
txa
|
||||
and #%00001111
|
||||
sta tmp1
|
||||
txa
|
||||
and #%11110000 ; *16
|
||||
lsr ; *8
|
||||
sta tmp2
|
||||
@@ -68,16 +68,16 @@ BCD2dec:tax
|
||||
|
||||
lda CIA1_TOD10
|
||||
sta CIA1_TOD10
|
||||
jsr _get_tv
|
||||
cmp #TV::PAL
|
||||
bne @60Hz
|
||||
jsr _get_ostype
|
||||
cmp #$43
|
||||
beq @60Hz
|
||||
lda CIA1_CRA
|
||||
ora #$80
|
||||
sta CIA1_CRA
|
||||
@60Hz: rts
|
||||
jsr _get_tv
|
||||
cmp #TV::PAL
|
||||
bne @60Hz
|
||||
jsr _get_ostype
|
||||
cmp #$43
|
||||
beq @60Hz
|
||||
lda CIA1_CRA
|
||||
ora #$80
|
||||
sta CIA1_CRA
|
||||
@60Hz: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -86,7 +86,7 @@ BCD2dec:tax
|
||||
; TM struct with date set to 1970-01-01
|
||||
.data
|
||||
|
||||
TM: .word 0 ; tm_sec
|
||||
TM: .word 0 ; tm_sec
|
||||
.word 0 ; tm_min
|
||||
.word 0 ; tm_hour
|
||||
.word 1 ; tm_mday
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
; Based on Stephen L. Judds GRLIB code
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
.addr UNINSTALL
|
||||
.addr INIT
|
||||
.addr DONE
|
||||
.addr GETERROR
|
||||
.addr GETERROR
|
||||
.addr CONTROL
|
||||
.addr CLEAR
|
||||
.addr SETVIEWPAGE
|
||||
@@ -82,7 +82,7 @@ OLDCHUNK := X2+1 ; Dito
|
||||
|
||||
.bss
|
||||
|
||||
ERROR: .res 1 ; Error code
|
||||
ERROR: .res 1 ; Error code
|
||||
PALETTE: .res 2 ; The current palette
|
||||
|
||||
BITMASK: .res 1 ; $00 = clear, $FF = set pixels
|
||||
@@ -117,7 +117,7 @@ BITCHUNK: .byte $FF,$7F,$3F,$1F,$0F,$07,$03,$01
|
||||
|
||||
CHARROM := $D000 ; Character rom base address
|
||||
CBASE := $D000 ; Color memory base address
|
||||
VBASE := $E000 ; Video memory base address
|
||||
VBASE := $E000 ; Video memory base address
|
||||
|
||||
|
||||
.code
|
||||
@@ -177,10 +177,10 @@ INIT:
|
||||
|
||||
lda $D018
|
||||
sta OLDD018
|
||||
lda #$48 ; Set color map to $D000, screen to $E000
|
||||
lda #$48 ; Set color map to $D000, screen to $E000
|
||||
sta $D018
|
||||
|
||||
lda $D011 ; And turn on bitmap
|
||||
lda $D011 ; And turn on bitmap
|
||||
ora #$20
|
||||
DONE1: sta $D011
|
||||
|
||||
@@ -217,9 +217,9 @@ DONE: lda $DD02 ; Set the data direction regs
|
||||
; GETERROR: Return the error code in A and clear it.
|
||||
|
||||
GETERROR:
|
||||
ldx #TGI_ERR_OK
|
||||
lda ERROR
|
||||
stx ERROR
|
||||
ldx #TGI_ERR_OK
|
||||
lda ERROR
|
||||
stx ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -229,8 +229,8 @@ GETERROR:
|
||||
;
|
||||
|
||||
CONTROL:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -340,22 +340,22 @@ SETPALETTE:
|
||||
; Initialize the color map with the new color settings (it is below the
|
||||
; I/O area)
|
||||
|
||||
ldy #$00
|
||||
sei
|
||||
lda $01 ; Get ROM config
|
||||
pha ; Save it
|
||||
and #%11111100 ; Clear bit 0 and 1
|
||||
sta $01
|
||||
txa ; Load color code
|
||||
@L2: sta CBASE+$0000,y
|
||||
sta CBASE+$0100,y
|
||||
sta CBASE+$0200,y
|
||||
sta CBASE+$0300,y
|
||||
iny
|
||||
bne @L2
|
||||
pla
|
||||
sta $01
|
||||
cli
|
||||
ldy #$00
|
||||
sei
|
||||
lda $01 ; Get ROM config
|
||||
pha ; Save it
|
||||
and #%11111100 ; Clear bit 0 and 1
|
||||
sta $01
|
||||
txa ; Load color code
|
||||
@L2: sta CBASE+$0000,y
|
||||
sta CBASE+$0100,y
|
||||
sta CBASE+$0200,y
|
||||
sta CBASE+$0300,y
|
||||
iny
|
||||
bne @L2
|
||||
pla
|
||||
sta $01
|
||||
cli
|
||||
|
||||
; Done, reset the error code
|
||||
|
||||
@@ -664,7 +664,7 @@ XFIXC: sta TEMP
|
||||
bmi @C1 ;Skip if column is negative
|
||||
cmp #39 ;End if move past end of screen
|
||||
bcs EXIT
|
||||
@C1: lda POINT
|
||||
@C1: lda POINT
|
||||
adc #8
|
||||
sta POINT
|
||||
bcc @CONT
|
||||
@@ -734,7 +734,7 @@ FIXY: cpy #255 ;Y=255 or Y=8
|
||||
bmi @C1 ;If negative, then don't update
|
||||
cmp #24
|
||||
bcs @TOAST ;If at bottom of screen then quit
|
||||
@C1: lda POINT
|
||||
@C1: lda POINT
|
||||
adc #<320
|
||||
sta POINT
|
||||
lda POINT+1
|
||||
@@ -790,7 +790,7 @@ FIXY: cpy #255 ;Y=255 or Y=8
|
||||
; the original C wrapper and could be written much smaller (besides that,
|
||||
; calling LINE is not a good idea either).
|
||||
|
||||
BAR: lda Y2
|
||||
BAR: lda Y2
|
||||
sta Y2SAVE
|
||||
lda Y2+1
|
||||
sta Y2SAVE+1
|
||||
@@ -810,11 +810,11 @@ BAR: lda Y2
|
||||
lda X1+1
|
||||
sta X1SAVE+1
|
||||
|
||||
@L1: lda Y1
|
||||
@L1: lda Y1
|
||||
sta Y2
|
||||
lda Y1+1
|
||||
sta Y2+1
|
||||
jsr LINE
|
||||
jsr LINE
|
||||
|
||||
lda Y1SAVE
|
||||
cmp Y2SAVE
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
; Target-specific black & white values for use by the target-shared TGI kernel
|
||||
;
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-kernel.inc"
|
||||
|
||||
.export tgi_color_black:zp = $00
|
||||
.export tgi_color_white:zp = $01
|
||||
.export tgi_color_black:zp = $00
|
||||
.export tgi_color_white:zp = $01
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const void tgi_static_stddrv[];
|
||||
;
|
||||
|
||||
.export _tgi_static_stddrv
|
||||
.import _c64_hi_tgi
|
||||
.export _tgi_static_stddrv
|
||||
.import _c64_hi_tgi
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const char tgi_stddrv[];
|
||||
;
|
||||
|
||||
.export _tgi_stddrv
|
||||
.export _tgi_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_tgi_stddrv: .asciiz "c64-hi.tgi"
|
||||
_tgi_stddrv: .asciiz "c64-hi.tgi"
|
||||
|
||||
Reference in New Issue
Block a user