Merge branch 'master' into kbrepeat
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
.export _cputcxy, _cputc, cputdirect, putchar
|
||||
.export newline, plot
|
||||
.import popa, _gotoxy
|
||||
.import gotoxy
|
||||
.import PLOT
|
||||
|
||||
.include "c64.inc"
|
||||
@@ -15,8 +15,7 @@
|
||||
|
||||
_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
jsr gotoxy ; Set cursor, drop x and y
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||
|
||||
.import initlib, donelib
|
||||
.import moveinit, zerobss, callmain
|
||||
.import zerobss, callmain
|
||||
.import BSOUT
|
||||
.import __MAIN_START__, __MAIN_SIZE__ ; Linker generated
|
||||
.import __STACKSIZE__ ; from configure file
|
||||
@@ -23,11 +23,6 @@
|
||||
|
||||
Start:
|
||||
|
||||
; Switch to the second charset.
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Switch off the BASIC ROM.
|
||||
|
||||
lda $01
|
||||
@@ -39,22 +34,10 @@ Start:
|
||||
tsx
|
||||
stx spsave ; Save the system stack ptr
|
||||
|
||||
; Allow some re-entrancy by skipping the next task if it already was done.
|
||||
; This sometimes can let us rerun the program without reloading it.
|
||||
|
||||
ldx move_init
|
||||
beq L0
|
||||
|
||||
; Move the INIT segment from where it was loaded (over the bss segments)
|
||||
; into where it must be run (over the BSS segment).
|
||||
|
||||
jsr moveinit
|
||||
dec move_init ; Set to false
|
||||
|
||||
; Save space by putting some of the start-up code in the INIT segment,
|
||||
; Save space by putting some of the start-up code in the ONCE segment,
|
||||
; which can be re-used by the BSS segment, the heap and the C stack.
|
||||
|
||||
L0: jsr runinit
|
||||
jsr init
|
||||
|
||||
; Clear the BSS data.
|
||||
|
||||
@@ -96,9 +79,9 @@ L2: lda zpsave,x
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
runinit:
|
||||
init:
|
||||
|
||||
; Save the zero-page locations that we need.
|
||||
|
||||
@@ -110,11 +93,16 @@ L1: lda sp,x
|
||||
|
||||
; Set up the stack.
|
||||
|
||||
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||
sta sp
|
||||
stx sp+1 ; Set argument stack ptr
|
||||
|
||||
; Switch to the second charset.
|
||||
|
||||
lda #14
|
||||
jsr BSOUT
|
||||
|
||||
; Call the module constructors.
|
||||
|
||||
jmp initlib
|
||||
@@ -123,17 +111,8 @@ L1: lda sp,x
|
||||
; ------------------------------------------------------------------------
|
||||
; Data
|
||||
|
||||
.data
|
||||
|
||||
; These two variables were moved out of the BSS segment, and into DATA, because
|
||||
; we need to use them before INIT is moved off of BSS, and before BSS is zeroed.
|
||||
.segment "INIT"
|
||||
|
||||
mmusave:.res 1
|
||||
spsave: .res 1
|
||||
|
||||
move_init:
|
||||
.byte 1
|
||||
|
||||
.segment "INITBSS"
|
||||
|
||||
zpsave: .res zpspace
|
||||
|
||||
@@ -1,376 +1,376 @@
|
||||
;
|
||||
; Extended memory driver for 65816 based extra RAM. Driver works without
|
||||
; problems when statically linked.
|
||||
;
|
||||
; Marco van den Heuvel, 2015-12-01
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack module
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _c64_65816_emd
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Library reference
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr PAGECOUNT
|
||||
.addr MAP
|
||||
.addr USE
|
||||
.addr COMMIT
|
||||
.addr COPYFROM
|
||||
.addr COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.bss
|
||||
isnotscpu: .res 1 ; SuperCPU not present
|
||||
curpage: .res 1 ; Current page number
|
||||
curbank: .res 1 ; Current bank number (+1)
|
||||
bankcount: .res 1 ; Number of available banks (pages = banks * 256)
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present and determine the amount of
|
||||
; memory available.
|
||||
; Must return an EM_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
sei
|
||||
clc
|
||||
sed
|
||||
lda #$99
|
||||
adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
|
||||
cld
|
||||
bne @not_present
|
||||
clc
|
||||
.P816
|
||||
sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
|
||||
.P02
|
||||
bcc @not_present
|
||||
lda $d0bc
|
||||
and #$80
|
||||
sta isnotscpu
|
||||
lda $07e8
|
||||
pha ; save value incase it was used somewhere else
|
||||
ldx #$ff
|
||||
@fillloop: ; fill from top (bank 255) to bottom
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb ; pull dbr
|
||||
.P02
|
||||
stx $07e8
|
||||
dex
|
||||
cpx #$ff
|
||||
bne @fillloop
|
||||
inx
|
||||
@compareloop: ; check from bottom to top
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
sta $07e8
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
inx
|
||||
bne @compareloop
|
||||
@found_pages:
|
||||
dex
|
||||
lda #$00
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
pla
|
||||
sta $07e8
|
||||
cli
|
||||
lda isnotscpu
|
||||
bne @noextradex
|
||||
dex
|
||||
@noextradex:
|
||||
stx bankcount
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
@not_present:
|
||||
cli
|
||||
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.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; PAGECOUNT: Return the total number of available pages in a/x.
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #$00 ; a whole bank is either usable or not
|
||||
ldx bankcount
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; MAP: Map the page in a/x into memory and return a pointer to the page in
|
||||
; a/x. The contents of the currently mapped page (if any) may be discarded
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage ; Remember the new page
|
||||
stx curbank ; Remember the new bank
|
||||
|
||||
sta ptr2+1 ; src address low
|
||||
lda #$00
|
||||
sta ptr2 ; src address high
|
||||
inx
|
||||
ldy isnotscpu ; check if not scpu
|
||||
bne @notscpu
|
||||
inx
|
||||
@notscpu:
|
||||
stx tmp2 ; src bank
|
||||
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
sta ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
lda #<window
|
||||
sta ptr1 ; dst address low
|
||||
ldx #>window
|
||||
stx ptr1+1 ; dst address high
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curbank ; Remember the bank
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
sta ptr1+1 ; dst high
|
||||
ldx #$00
|
||||
stx ptr1 ; dst low
|
||||
|
||||
lda #<window
|
||||
sta ptr2 ; src low
|
||||
lda #>window
|
||||
sta ptr2+1 ; src high
|
||||
|
||||
stx ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
stx tmp2 ; src bank
|
||||
ldy curbank ; Get the current bank
|
||||
iny
|
||||
ldx isnotscpu
|
||||
bne @notascpu
|
||||
iny
|
||||
@notascpu:
|
||||
sty tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex
|
||||
dex
|
||||
@nodex:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
stx ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notscpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notscpu64:
|
||||
sta tmp2 ; src bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr2+1 ; src high
|
||||
dey
|
||||
lda (ptr4),y ; get offset in page
|
||||
sta ptr2 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr1 ; dst low
|
||||
lda #$00
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYTO: sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex2
|
||||
dex
|
||||
@nodex2:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
txa
|
||||
sta ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notascpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notascpu64:
|
||||
sta tmp1 ; dst bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get page offset
|
||||
sta ptr1 ; dst low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr2+1 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr2 ; src high
|
||||
lda #$00
|
||||
sta tmp2 ; src bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for moving a block, the following is used:
|
||||
; ptr1: dst
|
||||
; ptr2: src
|
||||
; ptr3: length
|
||||
; tmp1: dst bank
|
||||
; tmp2: src bank
|
||||
|
||||
transfer:
|
||||
.P816
|
||||
.A8
|
||||
.I8
|
||||
sei
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
ldx tmp1 ; load srcbank
|
||||
stx @move+1 ; store srcbank in move + 1
|
||||
ldy tmp2 ; load dstbank
|
||||
sty @move+2 ; store dstbank in move + 2
|
||||
clc ; switch to native mode
|
||||
xce
|
||||
php ; save status bits
|
||||
rep #%00110000 ; set A and index to 16bit
|
||||
.A16
|
||||
.I16
|
||||
ldy ptr1
|
||||
ldx ptr2
|
||||
lda ptr3
|
||||
@move:
|
||||
mvn 0,0
|
||||
plp ; restore status bits
|
||||
.A8
|
||||
.I8
|
||||
lda #$00
|
||||
pha
|
||||
plb ; restore dbr
|
||||
sec
|
||||
xce ; switch to emul mode
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
cli
|
||||
rts
|
||||
.P02
|
||||
;
|
||||
; Extended memory driver for 65816 based extra RAM. Driver works without
|
||||
; problems when statically linked.
|
||||
;
|
||||
; Marco van den Heuvel, 2015-12-01
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "em-kernel.inc"
|
||||
.include "em-error.inc"
|
||||
|
||||
|
||||
.macpack generic
|
||||
.macpack module
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _c64_65816_emd
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $65, $6d, $64 ; "emd"
|
||||
.byte EMD_API_VERSION ; EM API version number
|
||||
|
||||
; Library reference
|
||||
|
||||
.addr $0000
|
||||
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr PAGECOUNT
|
||||
.addr MAP
|
||||
.addr USE
|
||||
.addr COMMIT
|
||||
.addr COPYFROM
|
||||
.addr COPYTO
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
.bss
|
||||
isnotscpu: .res 1 ; SuperCPU not present
|
||||
curpage: .res 1 ; Current page number
|
||||
curbank: .res 1 ; Current bank number (+1)
|
||||
bankcount: .res 1 ; Number of available banks (pages = banks * 256)
|
||||
window: .res 256 ; Memory "window"
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present and determine the amount of
|
||||
; memory available.
|
||||
; Must return an EM_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
sei
|
||||
clc
|
||||
sed
|
||||
lda #$99
|
||||
adc #$01 ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
|
||||
cld
|
||||
bne @not_present
|
||||
clc
|
||||
.P816
|
||||
sep #$01 ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
|
||||
.P02
|
||||
bcc @not_present
|
||||
lda $d0bc
|
||||
and #$80
|
||||
sta isnotscpu
|
||||
lda $07e8
|
||||
pha ; save value incase it was used somewhere else
|
||||
ldx #$ff
|
||||
@fillloop: ; fill from top (bank 255) to bottom
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb ; pull dbr
|
||||
.P02
|
||||
stx $07e8
|
||||
dex
|
||||
cpx #$ff
|
||||
bne @fillloop
|
||||
inx
|
||||
@compareloop: ; check from bottom to top
|
||||
txa
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
sta $07e8
|
||||
cmp $07e8
|
||||
bne @found_pages
|
||||
inx
|
||||
bne @compareloop
|
||||
@found_pages:
|
||||
dex
|
||||
lda #$00
|
||||
pha
|
||||
.P816
|
||||
plb
|
||||
.P02
|
||||
pla
|
||||
sta $07e8
|
||||
cli
|
||||
lda isnotscpu
|
||||
bne @noextradex
|
||||
dex
|
||||
@noextradex:
|
||||
stx bankcount
|
||||
lda #<EM_ERR_OK
|
||||
ldx #>EM_ERR_OK
|
||||
rts
|
||||
@not_present:
|
||||
cli
|
||||
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.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; PAGECOUNT: Return the total number of available pages in a/x.
|
||||
;
|
||||
|
||||
PAGECOUNT:
|
||||
lda #$00 ; a whole bank is either usable or not
|
||||
ldx bankcount
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; MAP: Map the page in a/x into memory and return a pointer to the page in
|
||||
; a/x. The contents of the currently mapped page (if any) may be discarded
|
||||
; by the driver.
|
||||
;
|
||||
|
||||
MAP: sta curpage ; Remember the new page
|
||||
stx curbank ; Remember the new bank
|
||||
|
||||
sta ptr2+1 ; src address low
|
||||
lda #$00
|
||||
sta ptr2 ; src address high
|
||||
inx
|
||||
ldy isnotscpu ; check if not scpu
|
||||
bne @notscpu
|
||||
inx
|
||||
@notscpu:
|
||||
stx tmp2 ; src bank
|
||||
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
sta ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
lda #<window
|
||||
sta ptr1 ; dst address low
|
||||
ldx #>window
|
||||
stx ptr1+1 ; dst address high
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; USE: Tell the driver that the window is now associated with a given page.
|
||||
|
||||
USE: sta curpage ; Remember the page
|
||||
stx curbank ; Remember the bank
|
||||
lda #<window
|
||||
ldx #>window ; Return the window
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COMMIT: Commit changes in the memory window to extended storage.
|
||||
|
||||
COMMIT: lda curpage ; Get the current page
|
||||
sta ptr1+1 ; dst high
|
||||
ldx #$00
|
||||
stx ptr1 ; dst low
|
||||
|
||||
lda #<window
|
||||
sta ptr2 ; src low
|
||||
lda #>window
|
||||
sta ptr2+1 ; src high
|
||||
|
||||
stx ptr3+1 ; length high
|
||||
lda #$ff
|
||||
sta ptr3 ; length low
|
||||
|
||||
stx tmp2 ; src bank
|
||||
ldy curbank ; Get the current bank
|
||||
iny
|
||||
ldx isnotscpu
|
||||
bne @notascpu
|
||||
iny
|
||||
@notascpu:
|
||||
sty tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYFROM: Copy from extended into linear memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYFROM:
|
||||
sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex
|
||||
dex
|
||||
@nodex:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
stx ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notscpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notscpu64:
|
||||
sta tmp2 ; src bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr2+1 ; src high
|
||||
dey
|
||||
lda (ptr4),y ; get offset in page
|
||||
sta ptr2 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr1 ; dst low
|
||||
lda #$00
|
||||
sta tmp1 ; dst bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COPYTO: Copy from linear into extended memory. A pointer to a structure
|
||||
; describing the request is passed in a/x.
|
||||
; The function must not return anything.
|
||||
;
|
||||
|
||||
COPYTO: sta ptr4
|
||||
stx ptr4+1 ; Save the passed em_copy pointer
|
||||
|
||||
ldy #EM_COPY::COUNT+1 ; start at the end of the struct
|
||||
lda (ptr4),y ; get high byte of count
|
||||
tax
|
||||
dey
|
||||
lda (ptr4),y ; get low byte of count
|
||||
bne @nodex2
|
||||
dex
|
||||
@nodex2:
|
||||
.P816
|
||||
dec
|
||||
.P02
|
||||
sta ptr3 ; length low
|
||||
txa
|
||||
sta ptr3+1 ; length high
|
||||
dey
|
||||
lda (ptr4),y ; get bank
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
ldx isnotscpu
|
||||
bne @notascpu64
|
||||
.P816
|
||||
inc
|
||||
.P02
|
||||
@notascpu64:
|
||||
sta tmp1 ; dst bank
|
||||
dey
|
||||
lda (ptr4),y ; get page
|
||||
sta ptr1+1 ; dst high
|
||||
dey
|
||||
lda (ptr4),y ; get page offset
|
||||
sta ptr1 ; dst low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer high
|
||||
sta ptr2+1 ; src low
|
||||
dey
|
||||
lda (ptr4),y ; get memory buffer low
|
||||
sta ptr2 ; src high
|
||||
lda #$00
|
||||
sta tmp2 ; src bank
|
||||
|
||||
jsr transfer
|
||||
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Helper function for moving a block, the following is used:
|
||||
; ptr1: dst
|
||||
; ptr2: src
|
||||
; ptr3: length
|
||||
; tmp1: dst bank
|
||||
; tmp2: src bank
|
||||
|
||||
transfer:
|
||||
.P816
|
||||
.A8
|
||||
.I8
|
||||
sei
|
||||
pha
|
||||
phx
|
||||
phy
|
||||
ldx tmp1 ; load srcbank
|
||||
stx @move+1 ; store srcbank in move + 1
|
||||
ldy tmp2 ; load dstbank
|
||||
sty @move+2 ; store dstbank in move + 2
|
||||
clc ; switch to native mode
|
||||
xce
|
||||
php ; save status bits
|
||||
rep #%00110000 ; set A and index to 16bit
|
||||
.A16
|
||||
.I16
|
||||
ldy ptr1
|
||||
ldx ptr2
|
||||
lda ptr3
|
||||
@move:
|
||||
mvn 0,0
|
||||
plp ; restore status bits
|
||||
.A8
|
||||
.I8
|
||||
lda #$00
|
||||
pha
|
||||
plb ; restore dbr
|
||||
sec
|
||||
xce ; switch to emul mode
|
||||
ply
|
||||
plx
|
||||
pla
|
||||
cli
|
||||
rts
|
||||
.P02
|
||||
|
||||
21
libsrc/c64/extra/tgimousedata.s
Normal file
21
libsrc/c64/extra/tgimousedata.s
Normal file
@@ -0,0 +1,21 @@
|
||||
; C64 sprite addresses for the TGI mouse pointer
|
||||
;
|
||||
; 2017-01-13, Greg King
|
||||
|
||||
; In order to provide a visible mouse pointer during TGI's graphics mode,
|
||||
; the object file "c64-tgimousedata.o" must be linked explicitly into
|
||||
; a program file. Example:
|
||||
;
|
||||
; cl65 -t c64 -o program-file main-code.c subroutines.s c64-tgimousedata.o
|
||||
;
|
||||
; Note: Currently, a program cannot have default
|
||||
; pointers for both text and graphic modes.
|
||||
|
||||
; The TGI graphics mode uses VIC-II's 16K bank number three.
|
||||
;
|
||||
; Address of the TGI bitmap's color RAM
|
||||
|
||||
COLORMAP := $D000
|
||||
|
||||
.export mcb_spritepointer := COLORMAP + $03F8
|
||||
.export mcb_spritememory := COLORMAP + $0400
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
initirq:
|
||||
lda IRQVec
|
||||
|
||||
@@ -32,10 +32,10 @@ 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,
|
||||
; Get possible command-line arguments. Goes into the special ONCE segment,
|
||||
; which may be reused after the startup code is run
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
initmainargs:
|
||||
|
||||
@@ -125,7 +125,7 @@ done: lda #<argv
|
||||
stx __argv + 1
|
||||
rts
|
||||
|
||||
.segment "INITBSS"
|
||||
.segment "INIT"
|
||||
|
||||
term: .res 1
|
||||
name: .res NAME_LEN + 1
|
||||
|
||||
@@ -30,7 +30,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
|
||||
; --------------------------------------------------------------------------
|
||||
; Initialize the mouse sprite.
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
initmcb:
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
.export soft80_charset
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
soft80_charset:
|
||||
.byte $0f,$03,$0f,$00,$0f,$07,$05,$0e
|
||||
.byte $0f,$05,$0e,$0b,$0f,$0b,$0f,$0f
|
||||
|
||||
@@ -56,7 +56,7 @@ soft80_shutdown:
|
||||
sta CIA2_PRA
|
||||
jmp $FF5B ; Initialize video I/O
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
firstinit:
|
||||
; copy charset to RAM under I/O
|
||||
sei
|
||||
@@ -146,7 +146,7 @@ soft80_bitmapyhi_data:
|
||||
soft80_tables_data_end:
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
.segment "INITBSS"
|
||||
.segment "INIT"
|
||||
soft80_internal_cellcolor:
|
||||
.res 1
|
||||
soft80_internal_bgcolor:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
.export soft80_newline, soft80_plot
|
||||
.export soft80_checkchar
|
||||
|
||||
.import popa, _gotoxy
|
||||
.import gotoxy
|
||||
|
||||
.import soft80_kplot
|
||||
.import soft80_internal_bgcolor, soft80_internal_cellcolor
|
||||
@@ -25,8 +25,7 @@
|
||||
|
||||
soft80_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
jsr gotoxy ; Set cursor, drop x and y
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
@@ -60,7 +60,7 @@ soft80mono_shutdown:
|
||||
sta VIC_VIDEO_ADR
|
||||
rts
|
||||
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
firstinit:
|
||||
; copy charset to RAM under I/O
|
||||
sei
|
||||
@@ -150,7 +150,7 @@ soft80_bitmapyhi_data:
|
||||
soft80_tables_data_end:
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
.segment "INITBSS"
|
||||
.segment "INIT"
|
||||
soft80mono_internal_cellcolor:
|
||||
.res 1
|
||||
soft80mono_internal_bgcolor:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
.export soft80mono_cputdirect, soft80mono_putchar
|
||||
.export soft80mono_newline, soft80mono_plot
|
||||
|
||||
.import popa, _gotoxy
|
||||
.import gotoxy
|
||||
|
||||
.import soft80mono_kplot
|
||||
.import soft80mono_internal_bgcolor, soft80mono_internal_cellcolor
|
||||
@@ -24,8 +24,7 @@
|
||||
|
||||
soft80mono_cputcxy:
|
||||
pha ; Save C
|
||||
jsr popa ; Get Y
|
||||
jsr _gotoxy ; Set cursor, drop x
|
||||
jsr gotoxy ; Set cursor, drop x and y
|
||||
pla ; Restore C
|
||||
|
||||
; Plot a character - also used as internal function
|
||||
|
||||
@@ -63,7 +63,7 @@ BCD2dec:tax
|
||||
; Constructor that writes to the 1/10 sec register of the TOD to kick it
|
||||
; into action. If this is not done, the clock hangs. We will read the register
|
||||
; and write it again, ignoring a possible change in between.
|
||||
.segment "INIT"
|
||||
.segment "ONCE"
|
||||
|
||||
.proc initsystime
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
;
|
||||
; Graphics driver for the 320x200x2 mode on the C64.
|
||||
;
|
||||
; Based on Stephen L. Judds GRLIB code
|
||||
; Based on Stephen L. Judd's GRLIB code.
|
||||
;
|
||||
; 2017-01-13, Greg King
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
@@ -351,7 +353,7 @@ SETPALETTE:
|
||||
@L2: sta CBASE+$0000,y
|
||||
sta CBASE+$0100,y
|
||||
sta CBASE+$0200,y
|
||||
sta CBASE+$0300,y
|
||||
sta CBASE+$02e8,y
|
||||
iny
|
||||
bne @L2
|
||||
pla
|
||||
@@ -872,7 +874,7 @@ TEXTSTYLE:
|
||||
OUTTEXT:
|
||||
|
||||
; Calculate a pointer to the representation of the character in the
|
||||
; character ROM
|
||||
; character ROM
|
||||
|
||||
ldx #((>(CHARROM + $0800)) >> 3)
|
||||
ldy #0
|
||||
@@ -957,5 +959,3 @@ CALC: lda Y1
|
||||
lda #00
|
||||
@L9: sta INRANGE
|
||||
rts
|
||||
|
||||
|
||||
|
||||
18
libsrc/c64/waitvsync.s
Normal file
18
libsrc/c64/waitvsync.s
Normal file
@@ -0,0 +1,18 @@
|
||||
;
|
||||
; Written by Groepaz <groepaz@gmx.net>
|
||||
;
|
||||
; void waitvsync (void);
|
||||
;
|
||||
|
||||
.export _waitvsync
|
||||
|
||||
.include "c64.inc"
|
||||
|
||||
_waitvsync:
|
||||
@l1:
|
||||
bit VIC_CTRL1
|
||||
bpl @l1
|
||||
@l2:
|
||||
bit VIC_CTRL1
|
||||
bmi @l2
|
||||
rts
|
||||
Reference in New Issue
Block a user