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


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

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)

clc
tya
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
chatGPZ

Registered: Dec 2001
Posts: 11108
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
lA-sTYLe

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


sei
lda #$37
sta $01
LDX #$FF
TXS
CLD

sei
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
cli

;Transfer filedata

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


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

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


LDA #$04
STA $DE02
CLI

jmp $1000
2020-03-25 11:43
Krill

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

Registered: Sep 2003
Posts: 1714
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
Advanced
Users Online
Viti/Hokuto Force
Krill/Plush
Frostbyte/Artline De..
Apollyon/ALD
Linus/MSL
kbs/Pht/Lxt
St0rmfr0nt/Quantum
andym00
psych
Mr. SID
Guests online: 182
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (10)
2 Facet  (9.7)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.046 sec.