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
|
||||
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
@@ -5,69 +5,69 @@
|
||||
; void reset_brk (void);
|
||||
;
|
||||
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
.importzp ptr1
|
||||
.export _set_brk, _reset_brk
|
||||
.destructor _reset_brk
|
||||
.export _brk_a, _brk_x, _brk_y, _brk_sr, _brk_pc
|
||||
.importzp ptr1
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.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
|
||||
|
||||
.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 brk_old+1
|
||||
ora brk_old+2 ; Did we save the vector already?
|
||||
bne @L1 ; Jump if we installed the handler already
|
||||
lda brk_old+1
|
||||
ora brk_old+2 ; Did we save the vector already?
|
||||
bne @L1 ; Jump if we installed the handler already
|
||||
|
||||
lda BRKVec ; Save the old vector
|
||||
sta brk_old+1
|
||||
lda BRKVec+1
|
||||
sta brk_old+2
|
||||
lda BRKVec ; Save the old vector
|
||||
sta brk_old+1
|
||||
lda BRKVec+1
|
||||
sta brk_old+2
|
||||
|
||||
lda #<brk_stub ; Set the break vector to our stub
|
||||
ldx #>brk_stub
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
lda #<brk_stub ; Set the break vector to our stub
|
||||
ldx #>brk_stub
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
|
||||
lda #<brk_handler ; Set the indirect vector to our handler
|
||||
ldx #>brk_handler
|
||||
sta brk_ind+1
|
||||
stx brk_ind+2
|
||||
lda #<brk_handler ; Set the indirect vector to our handler
|
||||
ldx #>brk_handler
|
||||
sta brk_ind+1
|
||||
stx brk_ind+2
|
||||
|
||||
@L1: rts
|
||||
@L1: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
; Reset the break vector
|
||||
.proc _reset_brk
|
||||
.proc _reset_brk
|
||||
|
||||
lda brk_old+1
|
||||
ldx brk_old+2
|
||||
beq @L9 ; Jump if vector not installed
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
lda #$00
|
||||
sta brk_old+1 ; Clear the saved vector
|
||||
sta brk_old+2
|
||||
@L9: rts
|
||||
lda brk_old+1
|
||||
ldx brk_old+2
|
||||
beq @L9 ; Jump if vector not installed
|
||||
sta BRKVec
|
||||
stx BRKVec+1
|
||||
lda #$00
|
||||
sta brk_old+1 ; Clear the saved vector
|
||||
sta brk_old+2
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -75,37 +75,37 @@ uservec: jmp $FFFF ; Patched at runtime
|
||||
|
||||
; 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
|
||||
|
||||
@@ -115,9 +115,9 @@ uservec: jmp $FFFF ; Patched at runtime
|
||||
.segment "LOWCODE"
|
||||
|
||||
.proc brk_stub
|
||||
pla ; Get original MMU_CR value
|
||||
sta MMU_CR ; And set it
|
||||
jmp brk_ind ; Jump indirect to break
|
||||
pla ; Get original MMU_CR value
|
||||
sta MMU_CR ; And set it
|
||||
jmp brk_ind ; Jump indirect to break
|
||||
.endproc
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
; /* Switch the C128 into C64 mode. Note: This function will not return! */
|
||||
;
|
||||
|
||||
.export _c64mode
|
||||
.export _c64mode
|
||||
.import C64MODE
|
||||
|
||||
_c64mode = C64MODE
|
||||
_c64mode = C64MODE
|
||||
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
; char cgetc (void);
|
||||
;
|
||||
|
||||
.export _cgetc
|
||||
.export _cgetc
|
||||
.constructor initcgetc
|
||||
.destructor donecgetc
|
||||
|
||||
.import cursor
|
||||
.import cursor
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L2 ; Jump if there are already chars waiting
|
||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||
bne L2 ; Jump if there are already chars waiting
|
||||
|
||||
; Switch on the cursor if needed. We MUST always switch the cursor on,
|
||||
; before switching it off, because switching it off will restore the
|
||||
@@ -23,50 +23,50 @@ _cgetc: lda KEY_COUNT ; Get number of characters
|
||||
; it off will restore the wrong character attribute.
|
||||
|
||||
jsr CURS_SET ; Set cursor to current position
|
||||
jsr CURS_ON
|
||||
lda cursor
|
||||
bne L1
|
||||
lda #$01
|
||||
jsr CURS_OFF
|
||||
L1: lda KEY_COUNT ; Check characters again
|
||||
beq L1
|
||||
jsr CURS_OFF ; Switch cursor off, if characters available
|
||||
jsr CURS_ON
|
||||
lda cursor
|
||||
bne L1
|
||||
lda #$01
|
||||
jsr CURS_OFF
|
||||
L1: lda KEY_COUNT ; Check characters again
|
||||
beq L1
|
||||
jsr CURS_OFF ; Switch cursor off, if characters available
|
||||
|
||||
L2: jsr KBDREAD ; Read char and return in A
|
||||
L2: jsr KBDREAD ; Read char and return in A
|
||||
ldx #0
|
||||
rts
|
||||
rts
|
||||
|
||||
;--------------------------------------------------------------------------
|
||||
; Module constructor/destructor
|
||||
|
||||
.bss
|
||||
keyvec: .res 2
|
||||
keyvec: .res 2
|
||||
|
||||
.segment "INIT"
|
||||
initcgetc:
|
||||
|
||||
; Save the old vector
|
||||
|
||||
lda KeyStoreVec
|
||||
sta keyvec
|
||||
lda KeyStoreVec+1
|
||||
sta keyvec+1
|
||||
lda KeyStoreVec
|
||||
sta keyvec
|
||||
lda KeyStoreVec+1
|
||||
sta keyvec+1
|
||||
|
||||
; Set the new vector. I can only hope that this works for other C128
|
||||
; versions...
|
||||
|
||||
lda #<$C6B7
|
||||
ldx #>$C6B7
|
||||
lda #<$C6B7
|
||||
ldx #>$C6B7
|
||||
jmp SetVec
|
||||
|
||||
.code
|
||||
donecgetc:
|
||||
lda keyvec
|
||||
ldx keyvec+1
|
||||
SetVec: sei
|
||||
sta KeyStoreVec
|
||||
stx KeyStoreVec+1
|
||||
cli
|
||||
rts
|
||||
lda keyvec
|
||||
ldx keyvec+1
|
||||
SetVec: sei
|
||||
sta KeyStoreVec
|
||||
stx KeyStoreVec+1
|
||||
cli
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
; void clrscr (void);
|
||||
;
|
||||
|
||||
.export _clrscr
|
||||
.export _clrscr
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
_clrscr = CLRSCR
|
||||
_clrscr = CLRSCR
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
||||
;
|
||||
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.export _textcolor, _bgcolor, _bordercolor
|
||||
.import return0
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
_textcolor:
|
||||
bit MODE ; Check 80/40 column mode
|
||||
bmi @L1 ; Jump if 80 columns
|
||||
bit MODE ; Check 80/40 column mode
|
||||
bmi @L1 ; Jump if 80 columns
|
||||
|
||||
; 40 column mode
|
||||
|
||||
@@ -29,7 +29,7 @@ _textcolor:
|
||||
@L1: tax ; Move new color to X
|
||||
lda CHARCOLOR ; Get old color + attributes
|
||||
and #$F0 ; Keep old attributes
|
||||
ora $CE5C,x ; Translate VIC color -> VDC color
|
||||
ora $CE5C,x ; Translate VIC color -> VDC color
|
||||
ldx CHARCOLOR ; Get the old color
|
||||
sta CHARCOLOR ; Set the new color + old attributes
|
||||
txa ; Old color -> A
|
||||
@@ -39,13 +39,13 @@ _textcolor:
|
||||
; translate vdc->vic colour
|
||||
|
||||
vdctovic:
|
||||
ldy #16
|
||||
@L2: cmp $CE5C-1,y
|
||||
beq @L3
|
||||
ldy #16
|
||||
@L2: cmp $CE5C-1,y
|
||||
beq @L3
|
||||
dey
|
||||
bne @L2
|
||||
@L3: tya
|
||||
rts
|
||||
@L3: tya
|
||||
rts
|
||||
|
||||
|
||||
_bgcolor:
|
||||
@@ -54,27 +54,27 @@ _bgcolor:
|
||||
|
||||
; 40 column mode
|
||||
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
ldx VIC_BG_COLOR0 ; get old value
|
||||
sta VIC_BG_COLOR0 ; set new value
|
||||
txa
|
||||
ldx #$00
|
||||
rts
|
||||
rts
|
||||
|
||||
; 80 column mode
|
||||
|
||||
@L1: tax ; Move new color to X
|
||||
lda $CE5C,x ; Translate VIC color -> VDC color
|
||||
pha
|
||||
ldx #26
|
||||
jsr $CDDA ; Read vdc register 26
|
||||
jsr vdctovic
|
||||
tay
|
||||
pla
|
||||
ldx #26
|
||||
jsr $CDCC ; Write vdc register 26
|
||||
tya
|
||||
lda $CE5C,x ; Translate VIC color -> VDC color
|
||||
pha
|
||||
ldx #26
|
||||
jsr $CDDA ; Read vdc register 26
|
||||
jsr vdctovic
|
||||
tay
|
||||
pla
|
||||
ldx #26
|
||||
jsr $CDCC ; Write vdc register 26
|
||||
tya
|
||||
ldx #$00
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
_bordercolor:
|
||||
@@ -83,11 +83,11 @@ _bordercolor:
|
||||
|
||||
; 40 column mode
|
||||
|
||||
ldx VIC_BORDERCOLOR ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
ldx VIC_BORDERCOLOR ; get old value
|
||||
sta VIC_BORDERCOLOR ; set new value
|
||||
txa
|
||||
ldx #$00
|
||||
rts
|
||||
rts
|
||||
|
||||
; 80 column mode
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
; Low level stuff for screen output/console input
|
||||
;
|
||||
|
||||
.exportzp CURS_X, CURS_Y
|
||||
.exportzp CURS_X, CURS_Y
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
; void 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 "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
newline = NEWLINE
|
||||
|
||||
@@ -20,31 +20,31 @@ newline = NEWLINE
|
||||
.code
|
||||
|
||||
_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?
|
||||
beq cr ; Output a cr
|
||||
_cputc: cmp #$0A ; CR?
|
||||
beq cr ; Output a cr
|
||||
|
||||
cmp #$0D ; LF?
|
||||
bne L2
|
||||
jmp NEWLINE ; Update cursor position
|
||||
cmp #$0D ; LF?
|
||||
bne L2
|
||||
jmp NEWLINE ; Update cursor position
|
||||
|
||||
; Printable char of some sort
|
||||
|
||||
L2: cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L5
|
||||
cmp #$60
|
||||
bcc L3
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L3: and #$3F
|
||||
L2: cmp #' '
|
||||
bcc cputdirect ; Other control char
|
||||
tay
|
||||
bmi L5
|
||||
cmp #$60
|
||||
bcc L3
|
||||
and #$DF
|
||||
bne cputdirect ; Branch always
|
||||
L3: and #$3F
|
||||
|
||||
; Output one character to the screen. We will disable scrolling while doing so
|
||||
|
||||
@@ -62,28 +62,28 @@ cputdirect:
|
||||
|
||||
; Handle character if high bit set
|
||||
|
||||
L5: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L6
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L6: ora #$40
|
||||
bne cputdirect ; Branch always
|
||||
L5: and #$7F
|
||||
cmp #$7E ; PI?
|
||||
bne L6
|
||||
lda #$5E ; Load screen code for PI
|
||||
bne cputdirect
|
||||
L6: ora #$40
|
||||
bne cputdirect ; Branch always
|
||||
|
||||
; Carriage return
|
||||
|
||||
cr: lda #0
|
||||
sta CURS_X
|
||||
cr: lda #0
|
||||
sta CURS_X
|
||||
|
||||
; 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
|
||||
|
||||
; Write one character to the screen without doing anything else, return X
|
||||
; position in Y
|
||||
|
||||
putchar = $CC2F
|
||||
putchar = $CC2F
|
||||
|
||||
|
||||
@@ -2,119 +2,119 @@
|
||||
; Startup code for cc65 (C128 version)
|
||||
;
|
||||
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss
|
||||
.import push0, callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
|
||||
.importzp ST
|
||||
.export _exit
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
.import initlib, donelib
|
||||
.import zerobss
|
||||
.import push0, callmain
|
||||
.import RESTOR, BSOUT, CLRCH
|
||||
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
|
||||
.importzp ST
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "c128.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Startup code
|
||||
|
||||
.segment "STARTUP"
|
||||
.segment "STARTUP"
|
||||
|
||||
Start:
|
||||
|
||||
; Switch to the second charset
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Before doing anything else, we have to setup our banking configuration.
|
||||
; Otherwise just the lowest 16K are actually RAM. Writing through the ROM
|
||||
; to the underlying RAM works, but it is bad style.
|
||||
|
||||
lda MMU_CR ; Get current memory configuration...
|
||||
pha ; ...and save it for later
|
||||
lda #MMU_CFG_CC65 ; Bank0 with kernal ROM
|
||||
sta MMU_CR
|
||||
lda MMU_CR ; Get current memory configuration...
|
||||
pha ; ...and save it for later
|
||||
lda #MMU_CFG_CC65 ; Bank0 with kernal ROM
|
||||
sta MMU_CR
|
||||
|
||||
; 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
|
||||
|
||||
; Clear the BSS data
|
||||
|
||||
jsr zerobss
|
||||
jsr zerobss
|
||||
|
||||
; Save system stuff and setup the stack
|
||||
|
||||
pla ; Get MMU setting
|
||||
sta mmusave
|
||||
pla ; Get MMU setting
|
||||
sta mmusave
|
||||
|
||||
tsx
|
||||
stx spsave ; Save the system stack pointer
|
||||
tsx
|
||||
stx spsave ; Save the system stack pointer
|
||||
|
||||
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
|
||||
|
||||
; Set the bank for the file name to our execution bank. We must do this,
|
||||
; *after* calling constructors, because some of them may depend on the
|
||||
; original value of this register.
|
||||
|
||||
lda #0
|
||||
sta FNAM_BANK
|
||||
lda #0
|
||||
sta FNAM_BANK
|
||||
|
||||
; 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
|
||||
|
||||
; Reset the stack and the memory configuration
|
||||
|
||||
ldx spsave
|
||||
txs
|
||||
ldx mmusave
|
||||
stx MMU_CR
|
||||
ldx spsave
|
||||
txs
|
||||
ldx mmusave
|
||||
stx MMU_CR
|
||||
|
||||
; Done, return 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
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
; unsigned DbgSetBreakVec (unsigned Addr);
|
||||
;
|
||||
|
||||
.export _DbgSetBreakVec
|
||||
.import popax, utstax
|
||||
|
||||
.include "../cbm/cbm.inc"
|
||||
.export _DbgSetBreakVec
|
||||
.import popax, utstax
|
||||
|
||||
.include "../cbm/cbm.inc"
|
||||
|
||||
_DbgSetBreakVec:
|
||||
jsr popax ; Get the new address
|
||||
ldy BRKVec
|
||||
sta BRKVec
|
||||
lda BRKVec+1
|
||||
stx BRKVec+1
|
||||
tax
|
||||
tya
|
||||
jmp utstax
|
||||
jsr popax ; Get the new address
|
||||
ldy BRKVec
|
||||
sta BRKVec
|
||||
lda BRKVec+1
|
||||
stx BRKVec+1
|
||||
tax
|
||||
tya
|
||||
jmp utstax
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
; Oliver Schmidt, 2010-02-14
|
||||
;
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.exportzp devnum := DEVNUM
|
||||
.exportzp devnum := DEVNUM
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
; Ullrich von Bassewitz, 2002-12-04
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
@@ -23,7 +23,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,15 +33,15 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
BASE = $400
|
||||
BASE = $400
|
||||
TOPMEM = $FF00
|
||||
PAGES = (TOPMEM - BASE) / 256
|
||||
PAGES = (TOPMEM - BASE) / 256
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
@@ -96,10 +96,10 @@ MAP: sta curpage
|
||||
stx curpage+1 ; Remember the new page
|
||||
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
|
||||
lda #<ptr1
|
||||
sta FETVEC
|
||||
@@ -130,15 +130,15 @@ USE: sta curpage
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
ldx curpage+1
|
||||
bmi done ; Jump if no page mapped
|
||||
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
|
||||
lda #<ptr1
|
||||
sta STAVEC
|
||||
@@ -212,7 +212,7 @@ COPYFROM:
|
||||
ldy #$00
|
||||
@L3: ldx #MMU_CFG_RAM1
|
||||
jsr FETCH
|
||||
sta (ptr2),y
|
||||
sta (ptr2),y
|
||||
iny
|
||||
dec tmp1
|
||||
bne @L3
|
||||
|
||||
@@ -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"
|
||||
.include "c128.inc"
|
||||
|
||||
@@ -26,7 +26,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.
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
BASE = $400
|
||||
BASE = $400
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
@@ -103,9 +103,9 @@ INSTALL:
|
||||
ldx #$FF
|
||||
stx curpage
|
||||
stx curpage+1 ; Invalidate the current page
|
||||
inx
|
||||
txa ; A = X = EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
inx
|
||||
txa ; A = X = EM_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -175,7 +175,7 @@ USE: sta curpage
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: sei
|
||||
lda curpage ; Get the current page
|
||||
lda curpage ; Get the current page
|
||||
ldx curpage+1
|
||||
bmi done ; Jump if no page mapped
|
||||
|
||||
@@ -183,9 +183,9 @@ COMMIT: sei
|
||||
stx curbank
|
||||
|
||||
clc
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
adc #>BASE
|
||||
sta ptr1+1
|
||||
ldy #$00
|
||||
sty ptr1
|
||||
|
||||
lda #<ptr1
|
||||
|
||||
@@ -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 pages available
|
||||
;
|
||||
|
||||
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,11 +5,11 @@
|
||||
; Ullrich von Bassewitz, 2002-11-29
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
@@ -23,7 +23,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,7 +33,7 @@
|
||||
.word MAP
|
||||
.word USE
|
||||
.word COMMIT
|
||||
.word COPYFROM
|
||||
.word COPYFROM
|
||||
.word COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -61,12 +61,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
|
||||
|
||||
@@ -221,14 +221,14 @@ transfer1:
|
||||
; Transfer subroutine for the REU. Expects command in Y.
|
||||
|
||||
transfer:
|
||||
sty REU_COMMAND ; Issue command
|
||||
sty REU_COMMAND ; Issue command
|
||||
|
||||
ldy MMU_CR ; Save the current MMU settings
|
||||
lda #MMU_CFG_RAM0 ;
|
||||
sei ;
|
||||
sta MMU_CR ; Enable RAM in bank #0
|
||||
ldy MMU_CR ; Save the current MMU settings
|
||||
lda #MMU_CFG_RAM0 ;
|
||||
sei ;
|
||||
sta MMU_CR ; Enable RAM in bank #0
|
||||
lda REU_TRIGGER ; Don't change $FF00
|
||||
sta REU_TRIGGER ; Start the transfer...
|
||||
sta REU_TRIGGER ; Start the transfer...
|
||||
|
||||
sty MMU_CR ; Restore the old configuration
|
||||
cli
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
; Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl>
|
||||
; 06,20.12.2002
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
@@ -21,7 +21,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.
|
||||
|
||||
@@ -29,33 +29,33 @@
|
||||
.word DEINSTALL
|
||||
.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
|
||||
|
||||
@@ -67,78 +67,78 @@ window: .res 256 ; memory window
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
; do test for VDC presence here???
|
||||
; do test for VDC presence here???
|
||||
|
||||
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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; DEINSTALL routine. Is called before the driver is removed from memory.
|
||||
@@ -146,7 +146,7 @@ settestadr2:
|
||||
;
|
||||
|
||||
DEINSTALL:
|
||||
;on C128 restore font and clear the screen?
|
||||
;on C128 restore font and clear the screen?
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -164,42 +164,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.
|
||||
@@ -214,36 +214,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
|
||||
@@ -252,8 +252,8 @@ transferout:
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
|
||||
; Copy full pages
|
||||
|
||||
@@ -268,18 +268,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
|
||||
@@ -288,8 +288,8 @@ COPYFROM:
|
||||
;
|
||||
|
||||
COPYTO:
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
jsr setup
|
||||
beq @L2 ; Skip if no full pages
|
||||
|
||||
; Copy full pages
|
||||
|
||||
@@ -304,52 +304,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
|
||||
@@ -357,7 +357,7 @@ vdcputreg:
|
||||
;
|
||||
|
||||
setup:
|
||||
sta ptr3
|
||||
sta ptr3
|
||||
stx ptr3+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::OFFS
|
||||
@@ -374,8 +374,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
|
||||
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
; */
|
||||
;
|
||||
|
||||
.export _fast
|
||||
.export _fast
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.proc _fast
|
||||
.proc _fast
|
||||
|
||||
lda #$01
|
||||
sta VIC_CLK_128
|
||||
rts
|
||||
lda #$01
|
||||
sta VIC_CLK_128
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; /* Return the video mode the machine is using */
|
||||
;
|
||||
|
||||
.include "get_tv.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
.proc _get_tv
|
||||
|
||||
ldx #TV::PAL ; Assume PAL
|
||||
ldx #TV::PAL ; Assume PAL
|
||||
lda PALFLAG
|
||||
bne pal
|
||||
dex ; NTSC
|
||||
|
||||
@@ -2,38 +2,38 @@
|
||||
; IRQ handling (C128 version)
|
||||
;
|
||||
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
.export initirq, doneirq
|
||||
.import callirq
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
IRQInd = $2FD ; JMP $0000 - used as indirect IRQ vector
|
||||
IRQInd = $2FD ; JMP $0000 - used as indirect IRQ vector
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; The C128 has ROM parallel to the RAM starting from $4000. The startup code
|
||||
@@ -45,15 +45,15 @@ setvec: sei
|
||||
; placed just above the startup code, so it goes into a RAM area that is
|
||||
; not banked.
|
||||
|
||||
.segment "LOWCODE"
|
||||
.segment "LOWCODE"
|
||||
|
||||
IRQStub:
|
||||
cld ; Just to be sure
|
||||
lda MMU_CR ; Get old register value
|
||||
pha ; And save on stack
|
||||
lda #MMU_CFG_CC65 ; Bank 0 with kernal ROM
|
||||
sta MMU_CR
|
||||
jsr callirq ; Call the functions
|
||||
pla ; Get old register value
|
||||
sta MMU_CR
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
cld ; Just to be sure
|
||||
lda MMU_CR ; Get old register value
|
||||
pha ; And save on stack
|
||||
lda #MMU_CFG_CC65 ; Bank 0 with kernal ROM
|
||||
sta MMU_CR
|
||||
jsr callirq ; Call the functions
|
||||
pla ; Get old register value
|
||||
sta MMU_CR
|
||||
jmp IRQInd ; Jump to the saved IRQ vector
|
||||
|
||||
@@ -61,7 +61,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.
|
||||
@@ -85,18 +85,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
|
||||
@@ -104,15 +104,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
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
; Ullrich von Bassewitz, 2002-12-21
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
@@ -22,8 +22,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 @@ JOY_COUNT = 2 ; 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.
|
||||
@@ -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 _c128_stdjoy_joy
|
||||
.export _joy_static_stddrv
|
||||
.import _c128_stdjoy_joy
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
; const char joy_stddrv[];
|
||||
;
|
||||
|
||||
.export _joy_stddrv
|
||||
.export _joy_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_joy_stddrv: .asciiz "c128-stdjoy.joy"
|
||||
_joy_stddrv: .asciiz "c128-stdjoy.joy"
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
; unsigned char kbhit (void);
|
||||
;
|
||||
|
||||
.export _kbhit
|
||||
.export _kbhit
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.proc _kbhit
|
||||
|
||||
ldx #0 ; High byte of return is always zero
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
; ora FKEY_COUNT ; Or with number of chars from function keys
|
||||
lda KEY_COUNT ; Get number of characters
|
||||
; ora FKEY_COUNT ; Or with number of chars from function keys
|
||||
beq L9
|
||||
lda #1
|
||||
L9: rts
|
||||
|
||||
@@ -53,48 +53,48 @@
|
||||
; All functions are available in the kernal jump table
|
||||
|
||||
; Extended jump table
|
||||
C64MODE = $FF4D
|
||||
SWAPPER = $FF5F
|
||||
C64MODE = $FF4D
|
||||
SWAPPER = $FF5F
|
||||
SETBNK = $FF68
|
||||
|
||||
;
|
||||
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
|
||||
PLOT = $FFF0
|
||||
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
|
||||
PLOT = $FFF0
|
||||
IOBASE = $FFF3
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
; - 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 "c128.inc"
|
||||
.include "c128.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,
|
||||
@@ -45,27 +45,27 @@ 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
|
||||
ldy FNAM_LEN
|
||||
cpy #NAME_LEN + 1
|
||||
bcc L1
|
||||
ldy #NAME_LEN - 1 ; limit the length
|
||||
L0: lda #FNAM ; Load vector address for FETCH routine
|
||||
ldx FNAM_BANK ; Load bank for FETCH routine
|
||||
jsr INDFET ; Load byte from (FETVEC),y
|
||||
sta name,y ; Save byte from filename
|
||||
L1: dey
|
||||
bpl L0
|
||||
inc __argc ; argc always is equal to, at least, 1
|
||||
sta name,y ; Save byte from filename
|
||||
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
|
||||
|
||||
@@ -91,11 +91,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
|
||||
@@ -122,21 +122,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
|
||||
|
||||
@@ -86,11 +86,11 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
ldx PALFLAG
|
||||
bne @L1
|
||||
adc #50 ; FIXME: Should be NTSC, is PAL value
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
rts
|
||||
|
||||
@L1: adc #50 ; Add PAL correction
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
sta VIC_SPR_Y ; Set Y position
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -64,18 +64,18 @@ SCREEN_WIDTH = 320
|
||||
.bss
|
||||
|
||||
Vars:
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -177,7 +177,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -195,7 +195,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -219,47 +219,47 @@ 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 #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
cli
|
||||
lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
cli
|
||||
ldx #0
|
||||
and #$1F
|
||||
eor #$1F
|
||||
and #$1F
|
||||
eor #$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
|
||||
@@ -270,15 +270,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
|
||||
@@ -297,10 +297,10 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
; MUST return carry clear.
|
||||
;
|
||||
|
||||
IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
sty OldPotX
|
||||
IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
sty OldPotX
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
@@ -308,29 +308,29 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; 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
|
||||
|
||||
@@ -339,10 +339,10 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; Calculate the Y movement vector
|
||||
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
sty OldPotY
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
sty OldPotY
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
@@ -350,32 +350,32 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; 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 X pos
|
||||
|
||||
@@ -391,38 +391,38 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
;
|
||||
; 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
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -73,11 +73,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
|
||||
|
||||
@@ -94,7 +94,7 @@ Temp: .res 1
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.byte 0 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -183,7 +183,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -201,7 +201,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -225,41 +225,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
|
||||
@@ -270,15 +270,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
|
||||
@@ -297,11 +297,11 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
; MUST return carry clear.
|
||||
;
|
||||
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
and #$1F
|
||||
eor #$1F ; Make all bits active high
|
||||
eor #$1F ; Make all bits active high
|
||||
sta Temp
|
||||
|
||||
; Check for a pressed button and place the result into Buttons
|
||||
@@ -315,45 +315,45 @@ IRQ: lda #$7F
|
||||
; 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
|
||||
|
||||
@@ -363,45 +363,45 @@ IRQ: lda #$7F
|
||||
; 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 "c128.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.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 _c128_1351_mou
|
||||
.export _mouse_static_stddrv
|
||||
.import _c128_1351_mou
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
; const char mouse_stddrv[];
|
||||
;
|
||||
|
||||
.export _mouse_stddrv
|
||||
.export _mouse_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_mouse_stddrv: .asciiz "c128-1351.mou"
|
||||
_mouse_stddrv: .asciiz "c128-1351.mou"
|
||||
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; /* Initialize the random number generator */
|
||||
;
|
||||
|
||||
.export __randomize
|
||||
.import _srand
|
||||
.export __randomize
|
||||
.import _srand
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.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 "c128.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 "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -47,12 +47,12 @@
|
||||
.word PUT
|
||||
.word STATUS
|
||||
.word IOCTL
|
||||
.word IRQ
|
||||
.word IRQ
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; 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
|
||||
@@ -137,11 +137,11 @@ NmiStubOrig := *
|
||||
.org $1150 ; BASIC graphics area
|
||||
.proc NmiStub
|
||||
|
||||
lda #MMU_CFG_CC65 ; Bank 0 with kernal ROM...
|
||||
sta MMU_CR ; ...enable
|
||||
lda #MMU_CFG_CC65 ; Bank 0 with kernal ROM...
|
||||
sta MMU_CR ; ...enable
|
||||
jsr NmiHandler ; Call the actual NMI handler
|
||||
lda #$00 ; Get ROM config...
|
||||
sta MMU_CR ; ...and enable it
|
||||
lda #$00 ; Get ROM config...
|
||||
sta MMU_CR ; ...and enable it
|
||||
Vector := *+1
|
||||
.byte $4C ; Jump to the saved IRQ vector
|
||||
|
||||
@@ -157,8 +157,8 @@ INSTALL:
|
||||
|
||||
; Deactivate DTR and disable 6551 interrupts
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Copy the NMI stub into low memory
|
||||
|
||||
@@ -170,20 +170,20 @@ INSTALL:
|
||||
|
||||
; Set up the nmi vector
|
||||
|
||||
lda NMIVec
|
||||
ldy NMIVec+1
|
||||
sta NmiStub::Vector+0
|
||||
sty NmiStub::Vector+1
|
||||
lda #<NmiStub
|
||||
ldy #>NmiStub
|
||||
SetNMI: sta NMIVec
|
||||
sty NMIVec+1
|
||||
lda NMIVec
|
||||
ldy NMIVec+1
|
||||
sta NmiStub::Vector+0
|
||||
sty NmiStub::Vector+1
|
||||
lda #<NmiStub
|
||||
ldy #>NmiStub
|
||||
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.
|
||||
@@ -193,14 +193,14 @@ UNINSTALL:
|
||||
|
||||
; Stop interrupts, drop DTR
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Restore NMI vector and return OK
|
||||
|
||||
lda NmiStub::Vector+0
|
||||
ldy NmiStub::Vector+1
|
||||
jmp SetNMI
|
||||
lda NmiStub::Vector+0
|
||||
ldy NmiStub::Vector+1
|
||||
jmp SetNMI
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; PARAMS routine. A pointer to a ser_params structure is passed in ptr1.
|
||||
@@ -210,10 +210,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
|
||||
|
||||
@@ -226,48 +226,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
|
||||
|
||||
@@ -285,8 +285,8 @@ CLOSE:
|
||||
|
||||
; Stop interrupts, drop DTR
|
||||
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
lda #%00001010
|
||||
sta ACIA_CMD
|
||||
|
||||
; Initalize buffers. Returns zero in a
|
||||
|
||||
@@ -296,7 +296,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
|
||||
@@ -304,43 +304,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.
|
||||
@@ -351,40 +351,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
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -422,26 +422,26 @@ IRQ = $0000
|
||||
; saved by the ROM code.
|
||||
|
||||
NmiHandler:
|
||||
lda ACIA_STATUS ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq @L9 ;(2*)
|
||||
cld
|
||||
lda ACIA_DATA ;(4) data ;get byte and put into receive buffer
|
||||
ldy RecvTail ;(4)
|
||||
ldx RecvFreeCnt ;(4)
|
||||
beq @L9 ;(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*)
|
||||
rts
|
||||
lda ACIA_STATUS ;(4) ;status ;check for byte received
|
||||
and #$08 ;(2)
|
||||
beq @L9 ;(2*)
|
||||
cld
|
||||
lda ACIA_DATA ;(4) data ;get byte and put into receive buffer
|
||||
ldy RecvTail ;(4)
|
||||
ldx RecvFreeCnt ;(4)
|
||||
beq @L9 ;(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*)
|
||||
rts
|
||||
|
||||
; Assert flow control
|
||||
|
||||
@L2: lda RtsOff ;(3) assert flow control if buffer space too low
|
||||
sta ACIA_CMD ;(4) command
|
||||
sta Stopped ;(3)
|
||||
@L2: lda RtsOff ;(3) assert flow control if buffer space too low
|
||||
sta ACIA_CMD ;(4) command
|
||||
sta Stopped ;(3)
|
||||
@L9: rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -449,33 +449,33 @@ NmiHandler:
|
||||
|
||||
.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
|
||||
|
||||
@@ -484,15 +484,15 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
; */
|
||||
;
|
||||
|
||||
.export _slow
|
||||
.export _slow
|
||||
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
|
||||
.proc _slow
|
||||
.proc _slow
|
||||
|
||||
lda #$00
|
||||
sta VIC_CLK_128
|
||||
rts
|
||||
lda #$00
|
||||
sta VIC_CLK_128
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -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 "c128.inc"
|
||||
.include "get_tv.inc"
|
||||
.include "get_tv.inc"
|
||||
|
||||
.constructor initsystime
|
||||
.importzp tmp1, tmp2
|
||||
.import _get_tv
|
||||
.importzp tmp1, tmp2
|
||||
.import _get_tv
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
.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,13 +68,13 @@ BCD2dec:tax
|
||||
|
||||
lda CIA1_TOD10
|
||||
sta CIA1_TOD10
|
||||
jsr _get_tv
|
||||
cmp #TV::PAL
|
||||
bne @60Hz
|
||||
lda CIA1_CRA
|
||||
ora #$80
|
||||
sta CIA1_CRA
|
||||
@60Hz: rts
|
||||
jsr _get_tv
|
||||
cmp #TV::PAL
|
||||
bne @60Hz
|
||||
lda CIA1_CRA
|
||||
ora #$80
|
||||
sta CIA1_CRA
|
||||
@60Hz: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -83,7 +83,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
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
; Register 25 ($19) is said to require different value for VDC v1, but I
|
||||
; couldn't find what it should be.
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
|
||||
|
||||
@@ -31,19 +31,19 @@
|
||||
; ------------------------------------------------------------------------
|
||||
; 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_DSP_HI = 12 ; registers used
|
||||
VDC_DSP_LO = 13
|
||||
VDC_DATA_HI = 18
|
||||
VDC_DATA_LO = 19
|
||||
VDC_VSCROLL = 24
|
||||
VDC_HSCROLL = 25
|
||||
VDC_COLORS = 26
|
||||
VDC_CSET = 28
|
||||
VDC_COUNT = 30
|
||||
VDC_DATA = 31
|
||||
VDC_DSP_HI = 12 ; registers used
|
||||
VDC_DSP_LO = 13
|
||||
VDC_DATA_HI = 18
|
||||
VDC_DATA_LO = 19
|
||||
VDC_VSCROLL = 24
|
||||
VDC_HSCROLL = 25
|
||||
VDC_COLORS = 26
|
||||
VDC_CSET = 28
|
||||
VDC_COUNT = 30
|
||||
VDC_DATA = 31
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table and constants.
|
||||
@@ -58,7 +58,7 @@ VDC_DATA = 31
|
||||
xres: .word 640 ; X resolution
|
||||
yres: .word 200 ; Y resolution
|
||||
.byte 2 ; Number of drawing colors
|
||||
pages: .byte 1 ; Number of screens available
|
||||
pages: .byte 1 ; Number of screens available
|
||||
.byte 8 ; System font X size
|
||||
.byte 8 ; System font Y size
|
||||
.word $006A ; Aspect ratio (based on 4/3 display)
|
||||
@@ -71,7 +71,7 @@ pages: .byte 1 ; Number of screens available
|
||||
.addr UNINSTALL
|
||||
.addr INIT
|
||||
.addr DONE
|
||||
.addr GETERROR
|
||||
.addr GETERROR
|
||||
.addr CONTROL
|
||||
.addr CLEAR
|
||||
.addr SETVIEWPAGE
|
||||
@@ -99,23 +99,23 @@ Y1 = ptr2
|
||||
X2 = ptr3
|
||||
Y2 = ptr4
|
||||
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4 ; HORLINE
|
||||
TEMP3 = sreg ; HORLINE
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4 ; HORLINE
|
||||
TEMP3 = sreg ; HORLINE
|
||||
|
||||
; Absolute variables used in the code
|
||||
|
||||
.bss
|
||||
|
||||
SCRBASE: .res 1 ; High byte of screen base
|
||||
SCRBASE: .res 1 ; High byte of screen base
|
||||
|
||||
ERROR: .res 1 ; Error code
|
||||
ERROR: .res 1 ; Error code
|
||||
PALETTE: .res 2 ; The current palette
|
||||
|
||||
BITMASK: .res 1 ; $00 = clear, $FF = set pixels
|
||||
|
||||
OLDCOLOR: .res 1 ; colors before entering gfx mode
|
||||
OLDCOLOR: .res 1 ; colors before entering gfx mode
|
||||
|
||||
; Text output stuff
|
||||
TEXTMAGX: .res 1
|
||||
@@ -131,25 +131,25 @@ PALETTESIZE = * - DEFPALETTE
|
||||
|
||||
BITTAB: .byte $80,$40,$20,$10,$08,$04,$02,$01
|
||||
|
||||
BITMASKL: .byte %11111111, %01111111, %00111111, %00011111
|
||||
.byte %00001111, %00000111, %00000011, %00000001
|
||||
BITMASKL: .byte %11111111, %01111111, %00111111, %00011111
|
||||
.byte %00001111, %00000111, %00000011, %00000001
|
||||
|
||||
BITMASKR: .byte %10000000, %11000000, %11100000, %11110000
|
||||
.byte %11111000, %11111100, %11111110, %11111111
|
||||
BITMASKR: .byte %10000000, %11000000, %11100000, %11110000
|
||||
.byte %11111000, %11111100, %11111110, %11111111
|
||||
|
||||
; color translation table (indexed by VIC color)
|
||||
COLTRANS: .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
|
||||
.byte $0d, $0b, $09, $01, $0e, $05, $03, $07
|
||||
; colors BROWN and GRAY3 are wrong
|
||||
COLTRANS: .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
|
||||
.byte $0d, $0b, $09, $01, $0e, $05, $03, $07
|
||||
; colors BROWN and GRAY3 are wrong
|
||||
|
||||
; VDC initialization table (reg),(val),...,$ff
|
||||
InitVDCTab:
|
||||
.byte VDC_DSP_HI, 0 ; viewpage 0 as default
|
||||
.byte VDC_DSP_LO, 0
|
||||
.byte VDC_HSCROLL, $87
|
||||
.byte $ff
|
||||
.byte VDC_DSP_HI, 0 ; viewpage 0 as default
|
||||
.byte VDC_DSP_LO, 0
|
||||
.byte VDC_HSCROLL, $87
|
||||
.byte $ff
|
||||
|
||||
SCN80CLR: .byte 27,88,147,27,88,0
|
||||
SCN80CLR: .byte 27,88,147,27,88,0
|
||||
|
||||
.code
|
||||
|
||||
@@ -162,78 +162,78 @@ SCN80CLR: .byte 27,88,147,27,88,0
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
; check for VDC version and update register $19 value
|
||||
; check for VDC version and update register $19 value
|
||||
|
||||
; check for VDC ram size and update number of available screens
|
||||
; check for VDC ram size and update number of available screens
|
||||
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr VDCReadReg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr VDCWriteReg ; turn on 64k
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr VDCReadReg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr VDCWriteReg ; turn on 64k
|
||||
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr VDCReadByte
|
||||
sta tmp2
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr VDCReadByte
|
||||
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 VDCWriteByte ; restore original value of test byte
|
||||
jsr settestadr1
|
||||
lda tmp2
|
||||
jsr VDCWriteByte ; 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 VDCWriteReg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
ldx #VDC_CSET
|
||||
lda tmp1
|
||||
jsr VDCWriteReg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
|
||||
@have64k:
|
||||
lda #4
|
||||
sta pages
|
||||
lda #4
|
||||
sta pages
|
||||
@endok:
|
||||
lda #0
|
||||
sta SCRBASE ; draw page 0 as default
|
||||
lda #0
|
||||
sta SCRBASE ; draw page 0 as default
|
||||
rts
|
||||
|
||||
test64k:
|
||||
sta tmp1
|
||||
sty ptr3
|
||||
lda #0
|
||||
sta ptr3+1
|
||||
jsr settestadr1
|
||||
lda tmp1
|
||||
jsr VDCWriteByte ; write $55
|
||||
jsr settestadr1
|
||||
jsr VDCReadByte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr VDCReadByte ; 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 VDCWriteByte ; write $55
|
||||
jsr settestadr1
|
||||
jsr VDCReadByte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr VDCReadByte ; 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 VDCSetSourceAddr
|
||||
ldy #$42 ; or page 64+2 (there)
|
||||
lda #0
|
||||
jmp VDCSetSourceAddr
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory. May
|
||||
@@ -268,20 +268,20 @@ INIT:
|
||||
stx BITMASK
|
||||
|
||||
; Remeber current color value
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCReadReg
|
||||
sta OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCReadReg
|
||||
sta OLDCOLOR
|
||||
|
||||
; Switch into graphics mode (set view page 0)
|
||||
|
||||
ldy #0
|
||||
@L2: ldx InitVDCTab,y
|
||||
bmi @L3
|
||||
iny
|
||||
lda InitVDCTab,y
|
||||
jsr VDCWriteReg
|
||||
iny
|
||||
bne @L2
|
||||
ldy #0
|
||||
@L2: ldx InitVDCTab,y
|
||||
bmi @L3
|
||||
iny
|
||||
lda InitVDCTab,y
|
||||
jsr VDCWriteReg
|
||||
iny
|
||||
bne @L2
|
||||
@L3:
|
||||
|
||||
; Done, reset the error code
|
||||
@@ -299,35 +299,35 @@ INIT:
|
||||
;
|
||||
|
||||
DONE:
|
||||
; This part is C128-mode specific
|
||||
jsr $e179 ; reload character set and setup VDC
|
||||
jsr $ff62
|
||||
lda $d7 ; in 80-columns?
|
||||
bne @L01
|
||||
@L0: lda SCN80CLR,y
|
||||
beq @L1
|
||||
jsr $ffd2 ; print \xe,clr,\xe
|
||||
iny
|
||||
bne @L0
|
||||
@L01: lda #147
|
||||
jsr $ffd2 ; print clr
|
||||
@L1: lda #0 ; restore view page
|
||||
ldx #VDC_DSP_HI
|
||||
jsr VDCWriteReg
|
||||
lda OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg ; restore color (background)
|
||||
lda #$47
|
||||
ldx #VDC_HSCROLL
|
||||
jmp VDCWriteReg ; switch to text screen
|
||||
; This part is C128-mode specific
|
||||
jsr $e179 ; reload character set and setup VDC
|
||||
jsr $ff62
|
||||
lda $d7 ; in 80-columns?
|
||||
bne @L01
|
||||
@L0: lda SCN80CLR,y
|
||||
beq @L1
|
||||
jsr $ffd2 ; print \xe,clr,\xe
|
||||
iny
|
||||
bne @L0
|
||||
@L01: lda #147
|
||||
jsr $ffd2 ; print clr
|
||||
@L1: lda #0 ; restore view page
|
||||
ldx #VDC_DSP_HI
|
||||
jsr VDCWriteReg
|
||||
lda OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg ; restore color (background)
|
||||
lda #$47
|
||||
ldx #VDC_HSCROLL
|
||||
jmp VDCWriteReg ; switch to text screen
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; 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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -337,8 +337,8 @@ GETERROR:
|
||||
;
|
||||
|
||||
CONTROL:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -348,22 +348,22 @@ CONTROL:
|
||||
;
|
||||
|
||||
CLEAR:
|
||||
lda #0
|
||||
ldy SCRBASE
|
||||
jsr VDCSetSourceAddr
|
||||
lda #0
|
||||
ldx #VDC_VSCROLL
|
||||
jsr VDCWriteReg ; set fill mode
|
||||
lda #0
|
||||
jsr VDCWriteByte ; put 1rst byte (fill value)
|
||||
ldy #62 ; 62 times
|
||||
lda #0 ; 256 bytes
|
||||
ldx #VDC_COUNT
|
||||
@L1: jsr VDCWriteReg
|
||||
dey
|
||||
bne @L1
|
||||
lda #127
|
||||
jmp VDCWriteReg ; 1+62*256+127=16000=(640*256)/8
|
||||
lda #0
|
||||
ldy SCRBASE
|
||||
jsr VDCSetSourceAddr
|
||||
lda #0
|
||||
ldx #VDC_VSCROLL
|
||||
jsr VDCWriteReg ; set fill mode
|
||||
lda #0
|
||||
jsr VDCWriteByte ; put 1rst byte (fill value)
|
||||
ldy #62 ; 62 times
|
||||
lda #0 ; 256 bytes
|
||||
ldx #VDC_COUNT
|
||||
@L1: jsr VDCWriteReg
|
||||
dey
|
||||
bne @L1
|
||||
lda #127
|
||||
jmp VDCWriteReg ; 1+62*256+127=16000=(640*256)/8
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
|
||||
@@ -373,12 +373,12 @@ CLEAR:
|
||||
;
|
||||
|
||||
SETVIEWPAGE:
|
||||
clc
|
||||
ror
|
||||
ror
|
||||
ror
|
||||
ldx #VDC_DSP_HI
|
||||
jmp VDCWriteReg
|
||||
clc
|
||||
ror
|
||||
ror
|
||||
ror
|
||||
ldx #VDC_DSP_HI
|
||||
jmp VDCWriteReg
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
|
||||
@@ -388,12 +388,12 @@ SETVIEWPAGE:
|
||||
;
|
||||
|
||||
SETDRAWPAGE:
|
||||
clc
|
||||
ror
|
||||
ror
|
||||
ror
|
||||
sta SCRBASE
|
||||
rts
|
||||
clc
|
||||
ror
|
||||
ror
|
||||
ror
|
||||
sta SCRBASE
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETCOLOR: Set the drawing color (in A). The new color is already checked
|
||||
@@ -428,16 +428,16 @@ SETPALETTE:
|
||||
; Get the color entries from the palette
|
||||
|
||||
ldy PALETTE+1 ; Foreground color
|
||||
lda COLTRANS,y
|
||||
lda COLTRANS,y
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
ldy PALETTE ; Background color
|
||||
ora COLTRANS,y
|
||||
ora COLTRANS,y
|
||||
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg
|
||||
lda #TGI_ERR_OK ; Clear error code
|
||||
sta ERROR
|
||||
rts
|
||||
@@ -480,23 +480,23 @@ GETDEFPALETTE:
|
||||
SETPIXEL:
|
||||
jsr CALC ; Calculate coordinates
|
||||
|
||||
stx TEMP
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
stx TEMP
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
|
||||
sta TEMP
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and BITTAB,X
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
|
||||
@L9: rts
|
||||
|
||||
@@ -509,12 +509,12 @@ SETPIXEL:
|
||||
GETPIXEL:
|
||||
jsr CALC ; Calculate coordinates
|
||||
|
||||
stx TEMP ; preserve X
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
stx TEMP ; preserve X
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
|
||||
ldy #$00
|
||||
and BITTAB,X
|
||||
@@ -542,127 +542,127 @@ GETPIXEL:
|
||||
;
|
||||
|
||||
BAR:
|
||||
inc Y2
|
||||
bne HORLINE
|
||||
inc Y2+1
|
||||
inc Y2
|
||||
bne HORLINE
|
||||
inc Y2+1
|
||||
|
||||
; Original code for a horizontal line
|
||||
|
||||
HORLINE:
|
||||
lda X1
|
||||
pha
|
||||
lda X1+1
|
||||
pha
|
||||
jsr CALC ; get data for LEFT
|
||||
lda BITMASKL,x ; remember left address and bitmask
|
||||
pha
|
||||
lda ADDR
|
||||
pha
|
||||
lda ADDR+1
|
||||
pha
|
||||
lda X1
|
||||
pha
|
||||
lda X1+1
|
||||
pha
|
||||
jsr CALC ; get data for LEFT
|
||||
lda BITMASKL,x ; remember left address and bitmask
|
||||
pha
|
||||
lda ADDR
|
||||
pha
|
||||
lda ADDR+1
|
||||
pha
|
||||
|
||||
lda X2
|
||||
sta X1
|
||||
lda X2+1
|
||||
sta X1+1
|
||||
jsr CALC ; get data for RIGHT
|
||||
lda BITMASKR,x
|
||||
sta TEMP3
|
||||
lda X2
|
||||
sta X1
|
||||
lda X2+1
|
||||
sta X1+1
|
||||
jsr CALC ; get data for RIGHT
|
||||
lda BITMASKR,x
|
||||
sta TEMP3
|
||||
|
||||
pla ; recall data for LEFT
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1 ; put left address into X1
|
||||
pla
|
||||
pla ; recall data for LEFT
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1 ; put left address into X1
|
||||
pla
|
||||
|
||||
cmp #%11111111 ; if left bit <> 0
|
||||
beq @L1
|
||||
sta TEMP2 ; do left byte only...
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP2
|
||||
eor TEMP
|
||||
pha
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
inc X1 ; ... and proceed
|
||||
bne @L1
|
||||
inc X1+1
|
||||
cmp #%11111111 ; if left bit <> 0
|
||||
beq @L1
|
||||
sta TEMP2 ; do left byte only...
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP2
|
||||
eor TEMP
|
||||
pha
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
inc X1 ; ... and proceed
|
||||
bne @L1
|
||||
inc X1+1
|
||||
|
||||
; do right byte (if Y2=0 ++ADDR and skip)
|
||||
@L1: lda TEMP3
|
||||
cmp #%11111111 ; if right bit <> 7
|
||||
bne @L11
|
||||
inc ADDR ; right bit = 7 - the next one is the last
|
||||
bne @L10
|
||||
inc ADDR+1
|
||||
@L10: bne @L2
|
||||
; do right byte (if Y2=0 ++ADDR and skip)
|
||||
@L1: lda TEMP3
|
||||
cmp #%11111111 ; if right bit <> 7
|
||||
bne @L11
|
||||
inc ADDR ; right bit = 7 - the next one is the last
|
||||
bne @L10
|
||||
inc ADDR+1
|
||||
@L10: bne @L2
|
||||
|
||||
@L11: lda ADDR ; do right byte only...
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP3
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
@L11: lda ADDR ; do right byte only...
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP3
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
|
||||
@L2: ; do the fill in the middle
|
||||
lda ADDR ; calculate offset in full bytes
|
||||
sec
|
||||
sbc X1
|
||||
beq @L3 ; if equal - there are no more bytes
|
||||
sta ADDR
|
||||
@L2: ; do the fill in the middle
|
||||
lda ADDR ; calculate offset in full bytes
|
||||
sec
|
||||
sbc X1
|
||||
beq @L3 ; if equal - there are no more bytes
|
||||
sta ADDR
|
||||
|
||||
lda X1 ; setup for the left side
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
lda BITMASK ; get color
|
||||
jsr VDCWriteByte ; put 1st value
|
||||
ldx ADDR
|
||||
dex
|
||||
beq @L3 ; 1 byte already written
|
||||
lda X1 ; setup for the left side
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
lda BITMASK ; get color
|
||||
jsr VDCWriteByte ; put 1st value
|
||||
ldx ADDR
|
||||
dex
|
||||
beq @L3 ; 1 byte already written
|
||||
|
||||
stx ADDR ; if there are more bytes - fill them...
|
||||
ldx #VDC_VSCROLL
|
||||
lda #0
|
||||
jsr VDCWriteReg ; setup for fill
|
||||
ldx #VDC_COUNT
|
||||
lda ADDR
|
||||
jsr VDCWriteReg ; ... fill them NOW!
|
||||
stx ADDR ; if there are more bytes - fill them...
|
||||
ldx #VDC_VSCROLL
|
||||
lda #0
|
||||
jsr VDCWriteReg ; setup for fill
|
||||
ldx #VDC_COUNT
|
||||
lda ADDR
|
||||
jsr VDCWriteReg ; ... fill them NOW!
|
||||
|
||||
@L3: pla
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1
|
||||
@L3: pla
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1
|
||||
|
||||
; End of horizontal line code
|
||||
|
||||
inc Y1
|
||||
bne @L4
|
||||
inc Y1+1
|
||||
@L4: lda Y1
|
||||
cmp Y2
|
||||
bne @L5
|
||||
lda Y1+1
|
||||
cmp Y2+1
|
||||
bne @L5
|
||||
rts
|
||||
inc Y1
|
||||
bne @L4
|
||||
inc Y1+1
|
||||
@L4: lda Y1
|
||||
cmp Y2
|
||||
bne @L5
|
||||
lda Y1+1
|
||||
cmp Y2+1
|
||||
bne @L5
|
||||
rts
|
||||
|
||||
@L5: jmp HORLINE
|
||||
@L5: jmp HORLINE
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -697,82 +697,82 @@ OUTTEXT:
|
||||
;> ADDR - address of card
|
||||
;> X - bit number (X1 & 7)
|
||||
CALC:
|
||||
lda Y1+1
|
||||
sta ADDR+1
|
||||
lda Y1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1 ; Y*4
|
||||
clc
|
||||
adc Y1
|
||||
sta ADDR
|
||||
lda Y1+1
|
||||
adc ADDR+1
|
||||
sta ADDR+1 ; Y*4+Y=Y*5
|
||||
lda ADDR
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
sta ADDR ; Y*5*16=Y*80
|
||||
lda X1+1
|
||||
sta TEMP
|
||||
lda X1
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
clc
|
||||
adc ADDR
|
||||
sta ADDR
|
||||
lda ADDR+1 ; ADDR = Y*80+x/8
|
||||
adc TEMP
|
||||
sta ADDR+1
|
||||
lda ADDR+1
|
||||
adc SCRBASE
|
||||
sta ADDR+1
|
||||
lda X1
|
||||
and #7
|
||||
tax
|
||||
rts
|
||||
lda Y1+1
|
||||
sta ADDR+1
|
||||
lda Y1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1 ; Y*4
|
||||
clc
|
||||
adc Y1
|
||||
sta ADDR
|
||||
lda Y1+1
|
||||
adc ADDR+1
|
||||
sta ADDR+1 ; Y*4+Y=Y*5
|
||||
lda ADDR
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
sta ADDR ; Y*5*16=Y*80
|
||||
lda X1+1
|
||||
sta TEMP
|
||||
lda X1
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
clc
|
||||
adc ADDR
|
||||
sta ADDR
|
||||
lda ADDR+1 ; ADDR = Y*80+x/8
|
||||
adc TEMP
|
||||
sta ADDR+1
|
||||
lda ADDR+1
|
||||
adc SCRBASE
|
||||
sta ADDR+1
|
||||
lda X1
|
||||
and #7
|
||||
tax
|
||||
rts
|
||||
|
||||
;-------------
|
||||
; VDC helpers
|
||||
|
||||
VDCSetSourceAddr:
|
||||
pha
|
||||
tya
|
||||
ldx #VDC_DATA_HI
|
||||
jsr VDCWriteReg
|
||||
pla
|
||||
ldx #VDC_DATA_LO
|
||||
bne VDCWriteReg
|
||||
pha
|
||||
tya
|
||||
ldx #VDC_DATA_HI
|
||||
jsr VDCWriteReg
|
||||
pla
|
||||
ldx #VDC_DATA_LO
|
||||
bne VDCWriteReg
|
||||
|
||||
VDCReadByte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
VDCReadReg:
|
||||
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
|
||||
|
||||
VDCWriteByte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
VDCWriteReg:
|
||||
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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
; Register 25 ($19) is said to require different value for VDC v1, but I
|
||||
; couldn't find what it should be.
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-kernel.inc"
|
||||
.include "tgi-error.inc"
|
||||
|
||||
|
||||
@@ -32,19 +32,19 @@
|
||||
; ------------------------------------------------------------------------
|
||||
; 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_DSP_HI = 12 ; registers used
|
||||
VDC_DSP_LO = 13
|
||||
VDC_DATA_HI = 18
|
||||
VDC_DATA_LO = 19
|
||||
VDC_VSCROLL = 24
|
||||
VDC_HSCROLL = 25
|
||||
VDC_COLORS = 26
|
||||
VDC_CSET = 28
|
||||
VDC_COUNT = 30
|
||||
VDC_DATA = 31
|
||||
VDC_DSP_HI = 12 ; registers used
|
||||
VDC_DSP_LO = 13
|
||||
VDC_DATA_HI = 18
|
||||
VDC_DATA_LO = 19
|
||||
VDC_VSCROLL = 24
|
||||
VDC_HSCROLL = 25
|
||||
VDC_COLORS = 26
|
||||
VDC_CSET = 28
|
||||
VDC_COUNT = 30
|
||||
VDC_DATA = 31
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table and constants.
|
||||
@@ -59,7 +59,7 @@ VDC_DATA = 31
|
||||
xres: .word 640 ; X resolution
|
||||
yres: .word 480 ; Y resolution
|
||||
.byte 2 ; Number of drawing colors
|
||||
pages: .byte 0 ; Number of screens available
|
||||
pages: .byte 0 ; Number of screens available
|
||||
.byte 8 ; System font X size
|
||||
.byte 8 ; System font Y size
|
||||
.word $0100 ; Aspect ratio (based on 4/3 display)
|
||||
@@ -72,7 +72,7 @@ pages: .byte 0 ; Number of screens available
|
||||
.addr UNINSTALL
|
||||
.addr INIT
|
||||
.addr DONE
|
||||
.addr GETERROR
|
||||
.addr GETERROR
|
||||
.addr CONTROL
|
||||
.addr CLEAR
|
||||
.addr SETVIEWPAGE
|
||||
@@ -100,21 +100,21 @@ Y1 = ptr2
|
||||
X2 = ptr3
|
||||
Y2 = ptr4
|
||||
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4 ; HORLINE
|
||||
TEMP3 = sreg ; HORLINE
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4 ; HORLINE
|
||||
TEMP3 = sreg ; HORLINE
|
||||
|
||||
; Absolute variables used in the code
|
||||
|
||||
.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
|
||||
|
||||
OLDCOLOR: .res 1 ; colors before entering gfx mode
|
||||
OLDCOLOR: .res 1 ; colors before entering gfx mode
|
||||
|
||||
; Text output stuff
|
||||
TEXTMAGX: .res 1
|
||||
@@ -130,33 +130,33 @@ PALETTESIZE = * - DEFPALETTE
|
||||
|
||||
BITTAB: .byte $80,$40,$20,$10,$08,$04,$02,$01
|
||||
|
||||
BITMASKL: .byte %11111111, %01111111, %00111111, %00011111
|
||||
.byte %00001111, %00000111, %00000011, %00000001
|
||||
BITMASKL: .byte %11111111, %01111111, %00111111, %00011111
|
||||
.byte %00001111, %00000111, %00000011, %00000001
|
||||
|
||||
BITMASKR: .byte %10000000, %11000000, %11100000, %11110000
|
||||
.byte %11111000, %11111100, %11111110, %11111111
|
||||
BITMASKR: .byte %10000000, %11000000, %11100000, %11110000
|
||||
.byte %11111000, %11111100, %11111110, %11111111
|
||||
|
||||
; color translation table (indexed by VIC color)
|
||||
COLTRANS: .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
|
||||
.byte $0d, $0b, $09, $01, $0e, $05, $03, $07
|
||||
; colors BROWN and GRAY3 are wrong
|
||||
COLTRANS: .byte $00, $0f, $08, $06, $0a, $04, $02, $0c
|
||||
.byte $0d, $0b, $09, $01, $0e, $05, $03, $07
|
||||
; colors BROWN and GRAY3 are wrong
|
||||
|
||||
; VDC initialization table (reg),(val),...,$ff
|
||||
InitVDCTab:
|
||||
.byte VDC_DSP_HI, 0 ; viewpage 0 as default
|
||||
.byte VDC_DSP_LO, 0
|
||||
.byte VDC_HSCROLL, $87
|
||||
.byte 2, $66
|
||||
.byte 4, $4c
|
||||
.byte 5, $06
|
||||
.byte 6, $4c
|
||||
.byte 7, $47
|
||||
.byte 8, $03
|
||||
.byte 9, $06
|
||||
.byte 27, $00
|
||||
.byte $ff
|
||||
.byte VDC_DSP_HI, 0 ; viewpage 0 as default
|
||||
.byte VDC_DSP_LO, 0
|
||||
.byte VDC_HSCROLL, $87
|
||||
.byte 2, $66
|
||||
.byte 4, $4c
|
||||
.byte 5, $06
|
||||
.byte 6, $4c
|
||||
.byte 7, $47
|
||||
.byte 8, $03
|
||||
.byte 9, $06
|
||||
.byte 27, $00
|
||||
.byte $ff
|
||||
|
||||
SCN80CLR: .byte 27,88,147,27,88,0
|
||||
SCN80CLR: .byte 27,88,147,27,88,0
|
||||
|
||||
.code
|
||||
|
||||
@@ -169,76 +169,76 @@ SCN80CLR: .byte 27,88,147,27,88,0
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
; check for VDC version and update register $19 value
|
||||
; check for VDC version and update register $19 value
|
||||
|
||||
; check for VDC ram size and update number of available screens
|
||||
; check for VDC ram size and update number of available screens
|
||||
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr VDCReadReg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr VDCWriteReg ; turn on 64k
|
||||
ldx #VDC_CSET ; determine size of RAM...
|
||||
jsr VDCReadReg
|
||||
sta tmp1
|
||||
ora #%00010000
|
||||
jsr VDCWriteReg ; turn on 64k
|
||||
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr VDCReadByte
|
||||
sta tmp2
|
||||
jsr settestadr1 ; save original value of test byte
|
||||
jsr VDCReadByte
|
||||
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 VDCWriteByte ; restore original value of test byte
|
||||
jsr settestadr1
|
||||
lda tmp2
|
||||
jsr VDCWriteByte ; 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 VDCWriteReg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
ldx #VDC_CSET
|
||||
lda tmp1
|
||||
jsr VDCWriteReg ; restore 16/64k flag
|
||||
jmp @endok ; and leave default values for 16k
|
||||
|
||||
@have64k:
|
||||
lda #1
|
||||
sta pages
|
||||
lda #1
|
||||
sta pages
|
||||
@endok:
|
||||
rts
|
||||
|
||||
test64k:
|
||||
sta tmp1
|
||||
sty ptr3
|
||||
lda #0
|
||||
sta ptr3+1
|
||||
jsr settestadr1
|
||||
lda tmp1
|
||||
jsr VDCWriteByte ; write $55
|
||||
jsr settestadr1
|
||||
jsr VDCReadByte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr VDCReadByte ; 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 VDCWriteByte ; write $55
|
||||
jsr settestadr1
|
||||
jsr VDCReadByte ; read here
|
||||
pha
|
||||
jsr settestadr2
|
||||
jsr VDCReadByte ; 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 VDCSetSourceAddr
|
||||
ldy #$42 ; or page 64+2 (there)
|
||||
lda #0
|
||||
jmp VDCSetSourceAddr
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory. May
|
||||
@@ -266,10 +266,10 @@ UNINSTALL:
|
||||
;
|
||||
|
||||
INIT:
|
||||
lda pages ; is there enough memory?
|
||||
bne @L1 ; Jump if there is one screen
|
||||
lda #TGI_ERR_INV_MODE ; Error
|
||||
bne @L9
|
||||
lda pages ; is there enough memory?
|
||||
bne @L1 ; Jump if there is one screen
|
||||
lda #TGI_ERR_INV_MODE ; Error
|
||||
bne @L9
|
||||
|
||||
; Initialize variables
|
||||
|
||||
@@ -277,20 +277,20 @@ INIT:
|
||||
stx BITMASK
|
||||
|
||||
; Remeber current color value
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCReadReg
|
||||
sta OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCReadReg
|
||||
sta OLDCOLOR
|
||||
|
||||
; Switch into graphics mode (set view page 0)
|
||||
|
||||
ldy #0
|
||||
@L2: ldx InitVDCTab,y
|
||||
bmi @L3
|
||||
iny
|
||||
lda InitVDCTab,y
|
||||
jsr VDCWriteReg
|
||||
iny
|
||||
bne @L2
|
||||
ldy #0
|
||||
@L2: ldx InitVDCTab,y
|
||||
bmi @L3
|
||||
iny
|
||||
lda InitVDCTab,y
|
||||
jsr VDCWriteReg
|
||||
iny
|
||||
bne @L2
|
||||
@L3:
|
||||
|
||||
; Done, reset the error code
|
||||
@@ -308,35 +308,35 @@ INIT:
|
||||
;
|
||||
|
||||
DONE:
|
||||
; This part is C128-mode specific
|
||||
jsr $e179 ; reload character set and setup VDC
|
||||
jsr $ff62
|
||||
lda $d7 ; in 80-columns?
|
||||
bne @L01
|
||||
@L0: lda SCN80CLR,y
|
||||
beq @L1
|
||||
jsr $ffd2 ; print \xe,clr,\xe
|
||||
iny
|
||||
bne @L0
|
||||
@L01: lda #147
|
||||
jsr $ffd2 ; print clr
|
||||
@L1: lda #0 ; restore view page
|
||||
ldx #VDC_DSP_HI
|
||||
jsr VDCWriteReg
|
||||
lda OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg ; restore color (background)
|
||||
lda #$47
|
||||
ldx #VDC_HSCROLL
|
||||
jmp VDCWriteReg ; switch to text screen
|
||||
; This part is C128-mode specific
|
||||
jsr $e179 ; reload character set and setup VDC
|
||||
jsr $ff62
|
||||
lda $d7 ; in 80-columns?
|
||||
bne @L01
|
||||
@L0: lda SCN80CLR,y
|
||||
beq @L1
|
||||
jsr $ffd2 ; print \xe,clr,\xe
|
||||
iny
|
||||
bne @L0
|
||||
@L01: lda #147
|
||||
jsr $ffd2 ; print clr
|
||||
@L1: lda #0 ; restore view page
|
||||
ldx #VDC_DSP_HI
|
||||
jsr VDCWriteReg
|
||||
lda OLDCOLOR
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg ; restore color (background)
|
||||
lda #$47
|
||||
ldx #VDC_HSCROLL
|
||||
jmp VDCWriteReg ; switch to text screen
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; 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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -346,8 +346,8 @@ GETERROR:
|
||||
;
|
||||
|
||||
CONTROL:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -357,21 +357,21 @@ CONTROL:
|
||||
;
|
||||
|
||||
CLEAR:
|
||||
lda #0
|
||||
tay
|
||||
jsr VDCSetSourceAddr
|
||||
lda #0
|
||||
ldx #VDC_VSCROLL
|
||||
jsr VDCWriteReg ; set fill mode
|
||||
lda #0
|
||||
jsr VDCWriteByte ; put 1rst byte (fill value)
|
||||
ldy #159 ; 159 times
|
||||
lda #0 ; 256 bytes
|
||||
ldx #VDC_COUNT
|
||||
@L1: jsr VDCWriteReg
|
||||
dey
|
||||
bne @L1
|
||||
rts
|
||||
lda #0
|
||||
tay
|
||||
jsr VDCSetSourceAddr
|
||||
lda #0
|
||||
ldx #VDC_VSCROLL
|
||||
jsr VDCWriteReg ; set fill mode
|
||||
lda #0
|
||||
jsr VDCWriteByte ; put 1rst byte (fill value)
|
||||
ldy #159 ; 159 times
|
||||
lda #0 ; 256 bytes
|
||||
ldx #VDC_COUNT
|
||||
@L1: jsr VDCWriteReg
|
||||
dey
|
||||
bne @L1
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
|
||||
@@ -381,7 +381,7 @@ CLEAR:
|
||||
;
|
||||
|
||||
SETVIEWPAGE:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
|
||||
@@ -391,7 +391,7 @@ SETVIEWPAGE:
|
||||
;
|
||||
|
||||
SETDRAWPAGE:
|
||||
rts
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETCOLOR: Set the drawing color (in A). The new color is already checked
|
||||
@@ -426,16 +426,16 @@ SETPALETTE:
|
||||
; Get the color entries from the palette
|
||||
|
||||
ldy PALETTE+1 ; Foreground color
|
||||
lda COLTRANS,y
|
||||
lda COLTRANS,y
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
ldy PALETTE ; Background color
|
||||
ora COLTRANS,y
|
||||
ora COLTRANS,y
|
||||
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg
|
||||
ldx #VDC_COLORS
|
||||
jsr VDCWriteReg
|
||||
lda #TGI_ERR_OK ; Clear error code
|
||||
sta ERROR
|
||||
rts
|
||||
@@ -478,23 +478,23 @@ GETDEFPALETTE:
|
||||
SETPIXEL:
|
||||
jsr CALC ; Calculate coordinates
|
||||
|
||||
stx TEMP
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
stx TEMP
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
|
||||
sta TEMP
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and BITTAB,X
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
|
||||
@L9: rts
|
||||
|
||||
@@ -507,12 +507,12 @@ SETPIXEL:
|
||||
GETPIXEL:
|
||||
jsr CALC ; Calculate coordinates
|
||||
|
||||
stx TEMP ; preserve X
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
stx TEMP ; preserve X
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
ldx TEMP
|
||||
|
||||
ldy #$00
|
||||
and BITTAB,X
|
||||
@@ -540,127 +540,127 @@ GETPIXEL:
|
||||
;
|
||||
|
||||
BAR:
|
||||
inc Y2
|
||||
bne HORLINE
|
||||
inc Y2+1
|
||||
inc Y2
|
||||
bne HORLINE
|
||||
inc Y2+1
|
||||
|
||||
; Original code for a horizontal line
|
||||
|
||||
HORLINE:
|
||||
lda X1
|
||||
pha
|
||||
lda X1+1
|
||||
pha
|
||||
jsr CALC ; get data for LEFT
|
||||
lda BITMASKL,x ; remember left address and bitmask
|
||||
pha
|
||||
lda ADDR
|
||||
pha
|
||||
lda ADDR+1
|
||||
pha
|
||||
lda X1
|
||||
pha
|
||||
lda X1+1
|
||||
pha
|
||||
jsr CALC ; get data for LEFT
|
||||
lda BITMASKL,x ; remember left address and bitmask
|
||||
pha
|
||||
lda ADDR
|
||||
pha
|
||||
lda ADDR+1
|
||||
pha
|
||||
|
||||
lda X2
|
||||
sta X1
|
||||
lda X2+1
|
||||
sta X1+1
|
||||
jsr CALC ; get data for RIGHT
|
||||
lda BITMASKR,x
|
||||
sta TEMP3
|
||||
lda X2
|
||||
sta X1
|
||||
lda X2+1
|
||||
sta X1+1
|
||||
jsr CALC ; get data for RIGHT
|
||||
lda BITMASKR,x
|
||||
sta TEMP3
|
||||
|
||||
pla ; recall data for LEFT
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1 ; put left address into X1
|
||||
pla
|
||||
pla ; recall data for LEFT
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1 ; put left address into X1
|
||||
pla
|
||||
|
||||
cmp #%11111111 ; if left bit <> 0
|
||||
beq @L1
|
||||
sta TEMP2 ; do left byte only...
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP2
|
||||
eor TEMP
|
||||
pha
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
inc X1 ; ... and proceed
|
||||
bne @L1
|
||||
inc X1+1
|
||||
cmp #%11111111 ; if left bit <> 0
|
||||
beq @L1
|
||||
sta TEMP2 ; do left byte only...
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP2
|
||||
eor TEMP
|
||||
pha
|
||||
lda X1
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
inc X1 ; ... and proceed
|
||||
bne @L1
|
||||
inc X1+1
|
||||
|
||||
; do right byte (if Y2=0 ++ADDR and skip)
|
||||
@L1: lda TEMP3
|
||||
cmp #%11111111 ; if right bit <> 7
|
||||
bne @L11
|
||||
inc ADDR ; right bit = 7 - the next one is the last
|
||||
bne @L10
|
||||
inc ADDR+1
|
||||
@L10: bne @L2
|
||||
; do right byte (if Y2=0 ++ADDR and skip)
|
||||
@L1: lda TEMP3
|
||||
cmp #%11111111 ; if right bit <> 7
|
||||
bne @L11
|
||||
inc ADDR ; right bit = 7 - the next one is the last
|
||||
bne @L10
|
||||
inc ADDR+1
|
||||
@L10: bne @L2
|
||||
|
||||
@L11: lda ADDR ; do right byte only...
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP3
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
@L11: lda ADDR ; do right byte only...
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
jsr VDCReadByte
|
||||
sta TEMP
|
||||
eor BITMASK
|
||||
and TEMP3
|
||||
eor TEMP
|
||||
pha
|
||||
lda ADDR
|
||||
ldy ADDR+1
|
||||
jsr VDCSetSourceAddr
|
||||
pla
|
||||
jsr VDCWriteByte
|
||||
|
||||
@L2: ; do the fill in the middle
|
||||
lda ADDR ; calculate offset in full bytes
|
||||
sec
|
||||
sbc X1
|
||||
beq @L3 ; if equal - there are no more bytes
|
||||
sta ADDR
|
||||
@L2: ; do the fill in the middle
|
||||
lda ADDR ; calculate offset in full bytes
|
||||
sec
|
||||
sbc X1
|
||||
beq @L3 ; if equal - there are no more bytes
|
||||
sta ADDR
|
||||
|
||||
lda X1 ; setup for the left side
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
lda BITMASK ; get color
|
||||
jsr VDCWriteByte ; put 1st value
|
||||
ldx ADDR
|
||||
dex
|
||||
beq @L3 ; 1 byte already written
|
||||
lda X1 ; setup for the left side
|
||||
ldy X1+1
|
||||
jsr VDCSetSourceAddr
|
||||
lda BITMASK ; get color
|
||||
jsr VDCWriteByte ; put 1st value
|
||||
ldx ADDR
|
||||
dex
|
||||
beq @L3 ; 1 byte already written
|
||||
|
||||
stx ADDR ; if there are more bytes - fill them...
|
||||
ldx #VDC_VSCROLL
|
||||
lda #0
|
||||
jsr VDCWriteReg ; setup for fill
|
||||
ldx #VDC_COUNT
|
||||
lda ADDR
|
||||
jsr VDCWriteReg ; ... fill them NOW!
|
||||
stx ADDR ; if there are more bytes - fill them...
|
||||
ldx #VDC_VSCROLL
|
||||
lda #0
|
||||
jsr VDCWriteReg ; setup for fill
|
||||
ldx #VDC_COUNT
|
||||
lda ADDR
|
||||
jsr VDCWriteReg ; ... fill them NOW!
|
||||
|
||||
@L3: pla
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1
|
||||
@L3: pla
|
||||
sta X1+1
|
||||
pla
|
||||
sta X1
|
||||
|
||||
; End of horizontal line code
|
||||
|
||||
inc Y1
|
||||
bne @L4
|
||||
inc Y1+1
|
||||
@L4: lda Y1
|
||||
cmp Y2
|
||||
bne @L5
|
||||
lda Y1+1
|
||||
cmp Y2+1
|
||||
bne @L5
|
||||
rts
|
||||
inc Y1
|
||||
bne @L4
|
||||
inc Y1+1
|
||||
@L4: lda Y1
|
||||
cmp Y2
|
||||
bne @L5
|
||||
lda Y1+1
|
||||
cmp Y2+1
|
||||
bne @L5
|
||||
rts
|
||||
|
||||
@L5: jmp HORLINE
|
||||
@L5: jmp HORLINE
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -695,98 +695,98 @@ OUTTEXT:
|
||||
;> ADDR - address of card
|
||||
;> X - bit number (X1 & 7)
|
||||
CALC:
|
||||
lda Y1
|
||||
pha
|
||||
lda Y1+1
|
||||
pha
|
||||
lsr
|
||||
ror Y1 ; Y=Y/2
|
||||
sta Y1+1
|
||||
sta ADDR+1
|
||||
lda Y1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1 ; Y*4
|
||||
clc
|
||||
adc Y1
|
||||
sta ADDR
|
||||
lda Y1+1
|
||||
adc ADDR+1
|
||||
sta ADDR+1 ; Y*4+Y=Y*5
|
||||
lda ADDR
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
sta ADDR ; Y*5*16=Y*80
|
||||
lda X1+1
|
||||
sta TEMP
|
||||
lda X1
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
clc
|
||||
adc ADDR
|
||||
sta ADDR
|
||||
lda ADDR+1 ; ADDR = Y*80+x/8
|
||||
adc TEMP
|
||||
sta ADDR+1
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1
|
||||
and #1
|
||||
beq @even ; even line - no offset
|
||||
lda ADDR
|
||||
clc
|
||||
adc #<21360
|
||||
sta ADDR
|
||||
lda ADDR+1
|
||||
adc #>21360
|
||||
sta ADDR+1 ; odd lines are 21360 bytes farther
|
||||
@even: lda X1
|
||||
and #7
|
||||
tax
|
||||
rts
|
||||
lda Y1
|
||||
pha
|
||||
lda Y1+1
|
||||
pha
|
||||
lsr
|
||||
ror Y1 ; Y=Y/2
|
||||
sta Y1+1
|
||||
sta ADDR+1
|
||||
lda Y1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1 ; Y*4
|
||||
clc
|
||||
adc Y1
|
||||
sta ADDR
|
||||
lda Y1+1
|
||||
adc ADDR+1
|
||||
sta ADDR+1 ; Y*4+Y=Y*5
|
||||
lda ADDR
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
asl
|
||||
rol ADDR+1
|
||||
sta ADDR ; Y*5*16=Y*80
|
||||
lda X1+1
|
||||
sta TEMP
|
||||
lda X1
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
lsr TEMP
|
||||
ror
|
||||
clc
|
||||
adc ADDR
|
||||
sta ADDR
|
||||
lda ADDR+1 ; ADDR = Y*80+x/8
|
||||
adc TEMP
|
||||
sta ADDR+1
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1
|
||||
and #1
|
||||
beq @even ; even line - no offset
|
||||
lda ADDR
|
||||
clc
|
||||
adc #<21360
|
||||
sta ADDR
|
||||
lda ADDR+1
|
||||
adc #>21360
|
||||
sta ADDR+1 ; odd lines are 21360 bytes farther
|
||||
@even: lda X1
|
||||
and #7
|
||||
tax
|
||||
rts
|
||||
|
||||
;-------------
|
||||
; VDC helpers
|
||||
|
||||
VDCSetSourceAddr:
|
||||
pha
|
||||
tya
|
||||
ldx #VDC_DATA_HI
|
||||
jsr VDCWriteReg
|
||||
pla
|
||||
ldx #VDC_DATA_LO
|
||||
bne VDCWriteReg
|
||||
pha
|
||||
tya
|
||||
ldx #VDC_DATA_HI
|
||||
jsr VDCWriteReg
|
||||
pla
|
||||
ldx #VDC_DATA_LO
|
||||
bne VDCWriteReg
|
||||
|
||||
VDCReadByte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
VDCReadReg:
|
||||
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
|
||||
|
||||
VDCWriteByte:
|
||||
ldx #VDC_DATA
|
||||
ldx #VDC_DATA
|
||||
VDCWriteReg:
|
||||
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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
.include "../../tgi/tgidrv_line.inc"
|
||||
|
||||
@@ -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 _c128_vdc_tgi
|
||||
.export _tgi_static_stddrv
|
||||
.import _c128_vdc_tgi
|
||||
|
||||
.rodata
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
; const char tgi_stddrv[];
|
||||
;
|
||||
|
||||
.export _tgi_stddrv
|
||||
.export _tgi_stddrv
|
||||
|
||||
.rodata
|
||||
|
||||
_tgi_stddrv: .asciiz "c128-vdc.tgi"
|
||||
_tgi_stddrv: .asciiz "c128-vdc.tgi"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; /* Toggle the video mode between 40 and 80 chars (calls SWAPPER) */
|
||||
;
|
||||
|
||||
.export _toggle_videomode
|
||||
.export _toggle_videomode
|
||||
.import SWAPPER, BSOUT
|
||||
|
||||
; This function is deprecated
|
||||
@@ -16,8 +16,8 @@
|
||||
.proc _toggle_videomode
|
||||
|
||||
jsr SWAPPER ; Toggle the mode
|
||||
lda #14
|
||||
jmp BSOUT ; Switch to lower case chars
|
||||
lda #14
|
||||
jmp BSOUT ; Switch to lower case chars
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; /* Set the video mode, return the old mode */
|
||||
;
|
||||
|
||||
.export _videomode
|
||||
.export _videomode
|
||||
.import SWAPPER, BSOUT
|
||||
|
||||
.include "c128.inc"
|
||||
@@ -20,8 +20,8 @@
|
||||
pha ; ... and save it
|
||||
|
||||
jsr SWAPPER ; Toggle the mode
|
||||
lda #14
|
||||
jsr BSOUT ; Switch to lower case chars
|
||||
lda #14
|
||||
jsr BSOUT ; Switch to lower case chars
|
||||
|
||||
pla ; Get old mode into A
|
||||
|
||||
|
||||
Reference in New Issue
Block a user