home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_15_1987_Transactor_Publishing.d64
/
ramcart.merlin
< prev
next >
Wrap
Text File
|
2023-02-26
|
4KB
|
161 lines
org $8000
*** equates ***
txttab = $2b ;start of basic text
vartab = $2d ;end of basic text
source = $5f ;start of source to copy
end = $5a ;end+1 of source to copy
dest = $58 ;end+1 of destination
ndx = $c6 ;no of characters in keyboard buffer
keyd = $0277 ;start of keyboard buffer
warm = $0302 ;basic warm start vector
copy = $a3bf ;copy memory
strout = $ab1e ;print string
vicctrl = $d016 ;vic control register
vectors = $e453 ;copy basic vectors to ram
init = $e3bf ; initialize basic interpreter
ioinit = $fda3 ;initialize i/o
ramtas = $fd50 ;initialize memory pointers
restor = $fd15 ;restore i/o vectors
cint = $ff5b ;init screen and keyboard
nmicont = $fe5e ;continue with nmi routine
*** auto-start basic program ***
;place start of code in cartridge vectors
dfb <start,>start
dfb <nmicont,>nmicont
;'cbm' with bit 7 set
dfb $c3,$c2,$cd
;'80'
dfb $38,$30
;'start' calls most of the routines
;which would be executed if a cartridge
;had not been detected. system vectors
;and basic are initialized.
start ldx #$05
stx vicctrl
jsr ioinit
jsr ramtas
jsr restor
jsr cint
cli
jsr vectors
jsr init
ldx #$fb
txs ;initialize stack pointer
;copy the basic program from
;the area under $a000 to the start-of-basic
;and set up the basic text and variables
;vectors. place 'run' in the keyboard buffer and
;enter basic through the warm start vector.
ldy txtt ;store start of basic
ldx txtt+1 ;saved with program
sty txttab ;at op system vector
stx txttab+1
ldy stsour ;store start of source
ldx stsour+1;at vector for copy routine
sty source
stx source+1
ldy vart ;store end of destination (+1)
ldx vart+1 ;at copy routine vector
sty dest
stx dest+1
dey ;subtract one from low byte
cpy #$ff
bne cont
dex ;subtract borrow
cont sty vartab ;store op system vector
stx vartab+1
lda #$a0 ;end of source (+1) = $a000
sta end+1
lda #$00
sta end
jsr copy
lda #'r'
sta keyd
lda #'u'
sta keyd+1
lda #'n'
sta keyd+2
lda #$0d ;<return>
sta keyd+3
lda #$04 ;number of characters
sta ndx
jmp (warm)
*** store basic program to cartridge ***
;calculate the size of the basic text, and
;print an error message if too large to fit
;in the cartridge. if okay, subtract the size
;from $9fff to get the location of the start
;of the copy to be saved to cartridge. save
;that vector, and the start and end of basic
;text for future use. set-up vectors for
;copy routine and copy program to cartridge.
store sec
lda vartab+1
sbc txttab+1;find size of basic program
tax
lda vartab
sbc txttab
tay
cpx #$1f ;max size allowed
bcs error ;print error message and quit
sty stsour ;store size temporarily
stx stsour+1
sec
lda #$9f ;subtract size from $9fff to find
sbc stsour+1;start of program in cartridge memory
sta stsour+1
lda #$ff
sbc stsour
sta stsour
lda txttab ;store start of basic for cartridge
sta txtt ;use and in vector for copy routine
sta source
lda txttab+1
sta txtt+1
sta source+1
ldy vartab ;store end of basic (+1) for cartridge
ldx vartab+1;use and vector for copy routine
iny
bne cont1
inx
cont1 sty vart
sty end
stx vart+1
stx end+1
lda #$a0 ;store $a000 (end of cartridge memory +1)
sta dest++1 ;in vector for copy routine
lda #$00
sta dest
jsr copy
rts
*** print error message ***
error lda #<message
ldy #>message
jsr strout
rts
message asc "PROGRAM TOO LARGE",0a,0d,00
*** system vector storage ***
txtt dfb $00,$00 ;start of program in ram
vart dfb $00,$00 ;end of program in ram
stsour dfb $00,$00 ;start of source in cartridge