Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums

Forums > C64 Coding > Start Basic Programm with easyflash
2020-03-25 01:00

Registered: Sep 2003
Posts: 63
Start Basic Programm with easyflash

I tried to put some Basic Coode into an Easyflash cartridge but after transfering the Basic Prg back to $0801 i it wont start.

To call it i am using the following code at $1000 which is an unnew that works just fine when i load it to C64, reset and execute. But when called from ef crt it crashes.

My basic File ends at 0cxx so overlapping isnt the Problem here.

;acme source start

lda #<2049
sta $fc

lda #>2049
sta $fd ;$fc refers to the standard start of BASIC

ldy #$04 ;scan BASIC program area from the first byte
;of the first line content (skip the two bytes with the
;address of the second BASIC line, and skip the
;two bytes with the first line number).

loop1 lda ($fc), y
beq exit_loop1 ;if a zero has been found, exit loop1

iny ;else, scan another byte

jmp loop1

exit_loop1 iny ;a zero has been found - end of first program line
;inc y so that we reach the address of second program line
;(before inc y, we are on the last byte of the first basic line)

adc $fc
sta $fc ;$fc = y + $fc

skip1 lda $fc
sta 2049
lda $fd
sta 2050 ;restore the second line address that has been cleared by NEW

ldy #$00 ;y will stay zero, we don't need it

scan_loop lda ($fc), y ;scans the remaining part of BASIC program
beq zero_found ;if it founds a zero, it jumps to "zero_found"
lda #$00
sta zero_flag ;if a value different than 0 has been found, zero_flag
;counter must be reset

return inc $fc ;prepare to scan next byte
lda $fc
bne scan_loop ;if low byte of address is not zero, no need to increment
;the high byte of address

inc $fd
jmp scan_loop ;we've crossed a memory page, so increment high byte of address

zero_found inc zero_flag ;we've found a zero, so zero_flag must be incremented by 1
lda zero_flag
cmp #3 ;three consecutive zeroes have been found?
;three zeroes = one byte (end of last line) + two bytes (end of program)

bne return ;if not, keep on scanning the program

inc $fc ;three zeroes have been reached, so we've reached program end
;now we need to store the final address + one on pointers
;on 45, 47, and 49 decimal
lda $fc
bne skip2 ;increment low byte of address by one, then check if it is 0

inc $fd ;low byte has wrapped to 0, so we need to increment the high byte
;of address

skip2 lda $fc ;set pointers to required value, according to where the program ends
sta 45
sta 47
sta 49

lda $fd
sta 46
sta 48
sta 50
JSR $A659
JSR $A533 ; Rechain Lines
JMP $A7AE ; Basic Warm Start rts ;we are done

;acme source end

Anybody who already did this and probably may help out ?
2020-03-25 10:42

Registered: Dec 2001
Posts: 9645
how does your cartridge startup code look like? to make basic work, you must do all the init stuff the kernal would normally do, just setting up a couple zp things wont work :)
2020-03-25 11:37

Registered: Sep 2003
Posts: 63
Init routine before calling transfered data from ef to c64mem is

lda #$37
sta $01

stx $d016
jsr $fda3 ;Prepare IRQ
jsr $fd50 ;Init memory. Rewrite this routine to speed up boot process.
jsr $fd15 ;Init I/O
jsr $ff5b ;Init video

;Transfer filedata

LDX #$00
ld1 LDA loader,X
STA $0340,X
LDA loader+$ff,X
STA $0340+$ff,X
BNE ld1
JMP $0340

loader SEI
LDA #$37
STA $01
LDA #$00
STA $D011 ;VIC Control Register 1
LDA #$07
LDA #$01 ; sel Bank 1
LDY #$40
page1 LDX #$00
load1 LDA $8000,X
stor1 STA $07ff,X
BNE load1
INC $035a
INC $035d
BNE page1

LDA #$02 ; Bank 2
LDY #$40
page2 LDX #$00
load2 LDA $8000,X
stor2 STA $47ff,X
BNE load2
INC $035a+27
INC $035d+27
BNE page2

LDA #$04

jmp $1000
2020-03-25 11:43

Registered: Apr 2002
Posts: 1630
http://unusedino.de/ec64/technical/aay/c64/rome394.htm might have a few hints.
2020-03-25 11:47

Registered: Sep 2003
Posts: 1422
I think what you are missing is the BASIC init code:
	JSR $E453				; Init BASIC RAM vectors
	JSR $E3BF				; Main BASIC RAM Init routine
and possibly setting the stack pointer to $FB.

There's some stuff here: https://codebase64.org/doku.php?id=base:assembling_your_own_car..

You can also look at the boot code I wrote for the 1541U2: https://github.com/GideonZ/1541ultimate/blob/master/software/65..
that code is interleaved with a lot of handling stuff but you can get the essence of it.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Users Online
Black Beard/Abyss, A..
Guests online: 101
Top Demos
1 Coma Light 13  (9.6)
2 Uncensored  (9.6)
3 Memento Mori  (9.6)
4 Edge of Disgrace  (9.6)
5 Unboxed  (9.6)
6 Comaland 100%  (9.6)
7 Lunatico  (9.6)
8 The Shores of Reflec..  (9.5)
9 Rivalry  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Copper Booze  (9.9)
2 Hedge of Disgrace - ..  (9.8)
3 Quadrants  (9.6)
4 Elite Code Mechanics  (9.6)
5 Square Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Smile to the Sky  (9.5)
8 Daah, Those Acid Pil..  (9.5)
9 Crystal Gazer  (9.4)
10 Instinct  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 Oxyron  (9.3)
4 PriorArt  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 Irata  (9.8)
4 Taper  (9.8)
5 hedning  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.051 sec.