1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-11-17 16:05:31 +00:00

Preliminary EasyFlash support

This commit is contained in:
Karol Stasiak 2019-08-16 17:55:01 +02:00
parent 2159fc345f
commit e1c32c2e31
2 changed files with 253 additions and 0 deletions

133
include/c64_easyflash.mfk Normal file
View File

@ -0,0 +1,133 @@
import err
inline asm void switch_hirom(byte a) {
? and #$3F
! sta $DE01
? rts
}
#if EAPI_ADDR
#if EAPI_ADDR & $ff != 0
#warn EAPI_ADDR should be page-aligned
#endif
#if EAPI_ADDR < $200
#error EAPI_ADDR cannot be less than $200
#endif
#use EAPI_ADDR
array __eapi_copy[$300] @ EAPI_ADDR
#else
array __eapi_copy[$300] align(256)
#endif
// address, value, returns true if ok
asm clear_carry eapi_write_flash(pointer xy, byte a) @ $DF80 extern
// bank, page ($80, $A0 or $E0), returns true if ok
asm clear_carry eapi_erase_sector(byte a, byte y) @ $DF83 extern
// bank
asm void eapi_set_bank(byte a) @ $DF86 extern
// returns bank
asm byte eapi_get_bank() @ $DF89 extern
// bank mode, address
asm void eapi_set_ptr(byte a, pointer xy) @ $DF8C extern
// length.b2, length.loword
asm void eapi_set_len(byte a, word xy) @ $DF8F extern
asm byte eapi_read_flash_inc() @ $DF92 extern
asm clear_carry eapi_write_flash_inc(byte a) @ $DF95 extern
asm void eapi_set_slot(byte a) @ $DF98 extern
asm void eapi_init_again() @ __eapi_copy.addr+20 extern
segment(hirom0) {
// this code will actually be located at $FFC0, as EasyFlash boots in the Ultimax mode
asm void __coldStart() @$BFD8 {
sei
ldx #$ff
txs
cld
lda #8
sta $d016
__coldStart_wait_for_ram:
sta $0100, x
dex
bne __coldStart_wait_for_ram
ldx #$40
__coldStart_l1:
lda __startUpCode+$4000, x
sta $0100, x
dex
bpl __coldStart_l1
jmp $0100
}
// this will be copied to the stack anyway
asm void __startUpCode() @$BF98 {
lda #$87
sta $de02
lda #$7f
sta $dc00
ldx #$ff
stx $dc02
inx
stx $dc03
lda $dc01
stx $dc02
stx $dc00
and #$e0
cmp #$e0
bne __startUpCode_kill
ldx #0
stx $d016
jsr $ff84
jsr $ff87
jsr $ff8a
jsr $ff81
jmp $8000
__startUpCode_kill:
lda #4
sta $de02
jmp ($fffc)
__startUpCode_end:
}
// sets errno
// if errno==err_ok, then returns the number of slots (<64) or the number of banks + 64 (>=64)
// if errno!=err_ok, then returns EAPI error code
asm byte eapi_init() @$BB00 {
? ldx #0
__eapi_init_loop:
lda $B800,x
sta __eapi_copy,x
lda $B900,x
sta __eapi_copy+$100,x
lda $BA00,x
sta __eapi_copy+$200,x
dex
bne __eapi_init_loop
jsr __eapi_copy+20
bcc __eapi_init_success
ldx #err_fail
bne __eapi_init_end
__eapi_init_success:
ldx #err_ok
sta errno
? tya
__eapi_init_end:
stx errno
? rts
}
const array(pointer) __vectors @$BFFA = [
$FFFE,
__coldStart.addr + $4000,
$4040
]
}

120
include/c64_ef_small.ini Normal file
View File

@ -0,0 +1,120 @@
; Commodore 64
; 128K EasyFlash cartridge
; the $8000-$9FFF bank is mirrored 8 times
; the $A000-$BFFF bank is swappable
; actual total code size: 72 KB
[compilation]
arch=nmos
encoding=petscii
screen_encoding=petscr
modules=c64_hardware,c64_easyflash,c64_kernal,c64_panic,stdlib
[allocation]
zp_pointers=$FB,$FD,$43,$45,$47,$4B,$F7,$F9,$9E,$9B,$3D
segments=default,lorom,hirom0,hirom1,hirom2,hirom3,hirom4,hirom5,hirom6,hirom7
default_code_segment=lorom
ram_init_segment=hirom0
segment_default_start=$800
segment_default_end=$7FFF
segment_ram_bank=$ff
segment_lorom_start=$8000
segment_lorom_end=$9FFF
segment_lorom_bank=0
segment_lorom_fill=$ff
segment_hirom0_start=$A000
segment_hirom0_end=$BFFF
segment_hirom0_bank=0
segment_hirom0_fill=$f0
segment_hirom1_start=$A000
segment_hirom1_end=$BFFF
segment_hirom1_bank=1
segment_hirom1_fill=$f1
segment_hirom2_start=$A000
segment_hirom2_end=$BFFF
segment_hirom2_bank=2
segment_hirom2_fill=$f2
segment_hirom3_start=$A000
segment_hirom3_end=$BFFF
segment_hirom3_bank=3
segment_hirom3_fill=$f3
segment_hirom4_start=$A000
segment_hirom4_end=$BFFF
segment_hirom4_bank=4
segment_hirom4_fill=$f4
segment_hirom5_start=$A000
segment_hirom5_end=$BFFF
segment_hirom5_bank=5
segment_hirom5_fill=$f5
segment_hirom6_start=$A000
segment_hirom6_end=$BFFF
segment_hirom6_bank=6
segment_hirom6_fill=$f6
segment_hirom7_start=$A000
segment_hirom7_end=$BFFF
segment_hirom7_bank=7
segment_hirom7_fill=$f7
[define]
CBM=1
CBM_64=1
MOS_6510=1
WIDESCREEN=1
KEYBOARD=1
JOYSTICKS=2
HAS_BITMAP_MODE=1
CBM_64_CRT=1
[output]
style=single
format= $43,$36,$34,$20,$43,$41,$52,$54,$52,$49,$44,$47,$45,$20,$20,$20, \
0,0,0,$40, 1,0, 0,32, 1, 0, 0,0,0,0,0,0, \
$4d,$49,$4c,$4c, $46,$4f,$52,$4b, $20,$31,$36,$4b, $20,$50,$52,$4f, \
$47,$52,$41,$4d, 0,0,0,0, 0,0,0,0, 0,0,0,0, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,0, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,0, $A0,$00, $20,$00, \
hirom0:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,1, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,1, $A0,$00, $20,$00, \
hirom1:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,2, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,2, $A0,$00, $20,$00, \
hirom2:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,3, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,3, $A0,$00, $20,$00, \
hirom3:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,4, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,4, $A0,$00, $20,$00, \
hirom4:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,5, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,5, $A0,$00, $20,$00, \
hirom5:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,6, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,6, $A0,$00, $20,$00, \
hirom6:$A000:$BFFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,7, $80,$00, $20,$00, \
lorom:$8000:$9FFF, \
$43,$48,$49,$50, 0,0,$20,$10, 0,2, 0,7, $A0,$00, $20,$00, \
hirom7:$A000:$BFFF
extension=crt
labels=vice