Skip to content

Commit

Permalink
Disk2EasyFlash integration
Browse files Browse the repository at this point in the history
  • Loading branch information
frntc authored Nov 15, 2020
1 parent 08041ad commit 416b19e
Show file tree
Hide file tree
Showing 32 changed files with 4,702 additions and 0 deletions.
34 changes: 34 additions & 0 deletions D2EF/C64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

all: binaries.c

kapi: kapi_hi.prg kapi_lo.prg kapi_nm.prg
launcher: launcher_hi.bin

DEPDIR = .
df = $(DEPDIR)/$(*F)

SRCS = kapi_hi.asm kapi_lo.asm kapi_nm.asm

N = "\\033[0m"
B = "\\033[1m"

copyright.bin: copyright.php
@echo "$(B)Assembling $@$(N)"
php copyright.php

%.prg: %.asm
@echo "$(B)Assembling $<$(N)"
php mkdep.php $< > $(df).P
java -jar KickAss2.25/KickAss.jar -showmem -vicesymbols -o $@ $<

launcher_hi.bin: launcher_hi.asm
@echo "$(B)Assembling $<$(N)"
java -jar KickAss3.42/KickAss.jar -binfile -showmem launcher_hi.asm -o launcher_hi.bin

binaries.c: kapi launcher
@echo "$(B)Assembling $@$(N)"
php binaries.php

# autodep

-include $(SRCS:%.asm=$(DEPDIR)/%.P)
32 changes: 32 additions & 0 deletions D2EF/C64/binaries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

$fc = fopen("binaries.c", "w");
fwrite($fc, "#include <stdint.h>\n");

$fh = fopen("binaries.h", "w");
fwrite($fh, "#ifndef BINARIES_H
#define BINARIES_H
#include <stdint.h>
");

foreach (array(
'kapi_hi.prg' => 2,
'kapi_nm.prg' => 2,
'kapi_lo.prg' => 2,
'launcher_hi.bin' => 0,
'startup.bin' => 0,
'sprites.bin' => 0,
) AS $file => $offset) {
$bin = substr(file_get_contents($file), $offset);
fwrite($fc, 'uint8_t '.substr($file, 0, -4).'[] = {');
for ($i = 0; $i < strlen($bin); $i++) {
fwrite($fc, ord($bin[$i]).', ');
}
fwrite($fc, "};\n");

fwrite($fh, 'extern uint8_t '.substr($file, 0, -4)."[];\n");
fwrite($fh, '#define '.substr($file, 0, -4).'_size '.strlen($bin)."\n");
}

fwrite($fh, "#endif\n");
11 changes: 11 additions & 0 deletions D2EF/C64/copyright.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$text = ' ALEX\'S DISK2EASYFLASH - "LOAD" V0.92 ';

for ($i = 0; $i < strlen($text); $i++) {
if (ord($text[$i]) >= 0x41 && ord($text[$i]) <= 0x5A) {
$text[$i] = chr(ord($text[$i]) - 0x40);
}
}

file_put_contents("copyright.bin", $text);
60 changes: 60 additions & 0 deletions D2EF/C64/emu_chrin.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.pc = * "CHRIN"
DO_CHRIN:

// in: -
// used: A
// out: A, C

// setup exit
:mov #$4c ; RETURN_COMMAND
:mov16 REAL_CHRIN ; RETURN_ADDR

// check active device
lda $99
bne !just_rts+ // other device = just the orig. routine

!keyboard:
lda $d0
bne !just_rts+

sty TEMP1

jmp get_out
lda AUTOTYPE_STATUS
bne !line1+
!line2:
ldy #[autotype_line2 - autotype_line1]
.byte $2c
!line1:
ldy #0

!loop:
lda autotype_line1, y
beq !new_line+
jsr $e716 // print char
inc $c8
iny
bne !loop-

!new_line:
sta $0292
sta $d3
sta $d4
inc $d0

!exit_chrin:
ldy TEMP1
dec AUTOTYPE_STATUS
bpl !just_rts+

get_out:
// disable CHRIN
:mov16 REAL_CHRIN ; $0324

!just_rts:
jmp DISABLE_CRT

autotype_line1:
.byte $4c, $4f, $41, $44, $22, $2a, $22, $2c, $38, $2c, $31, 0
autotype_line2:
.byte $52, $55, $4e, 0
82 changes: 82 additions & 0 deletions D2EF/C64/emu_helper.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.pc = * "Helpers"

.if(!fast_load){
READ_BYTE: // TRASHES X!!
:if SMC_ADDR+2 ; EQ ; #[[BANK_START + BANK_SIZE] >> 8] ; ENDIF ; !endif+
// go to next bank
:mov #BANK_START>>8 ; SMC_ADDR+2
inc SMC_BANK+1
!endif:
ldx SMC_OUR_BANK+1
jsr RAM_READ_BYTE
:inc16 SMC_ADDR+1
:dec16 OPEN_SIZE_TODO ; X
rts
}

// temporary variables
.const FILENAME_LEN = $bf

FIND_FILE:
// requires that the filename is copied to FILENAME
// return C=error

// y=len of filename
ldy $b7

// check for empty filename
beq file_not_found

// if len > 16 chars: fail
:if Y ; GT ; #16 ; use_real_load

// find last non-space char
!loop:
dey
lda FILENAME, y
cmp #$20
beq !loop-
// remember length
iny
sty FILENAME_LEN

// find the entry
:mov16 #DIR-24 ; ENTRY_PTR
find_loop:
:add16_8 ENTRY_PTR ; #24
ldy #0
lda (ENTRY_PTR), y
beq file_not_found // EOF = file not found

!loop:
lda FILENAME, y
cmp #$2a // '*'
beq file_found // match (due to a *) -> found file
cmp (ENTRY_PTR), y
bne find_loop // mismatch -> next line

iny // next char
cpy FILENAME_LEN
bne !loop- // not at enf of name -> next char

cpy #16
beq !skip+
// found a file whith <16 chars -> check for \0 as next char in name
lda (ENTRY_PTR), y
bne find_loop // filenamelen mismatch
!skip:

file_found:
clc
rts

file_not_found:
sec
rts



RETURN_SUCCESS:
clc
:mov #$60 ; RETURN_COMMAND
jmp DISABLE_CRT
164 changes: 164 additions & 0 deletions D2EF/C64/emu_load.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
.pc = * "LOAD"
DO_LOAD:

// check weather load is active
lda $93
bne use_real_load // we do'nt support verify -> use real load

// check drive#
lda $ba
cmp #$08
beq find_file // if drive is not 8 -> use real load

use_real_load:

// failure+return
:mov #$4c ; RETURN_COMMAND
:mov16 REAL_LOAD ; RETURN_ADDR

lda $93
ldx $c3
ldy $c4

jmp DISABLE_CRT


// search file - exit if not found
find_file:
jsr FIND_FILE
bcs use_real_load

// print SEARCHING
:mov16 #$f5af ; SMC_PRINT_SEARCH_LOADING+1
jsr PRINT_SEARCH_LOADING
// wait, if it's the first time
lda AUTOTYPE_STATUS
bmi !skip+
ldx #0
ldy #0
!loop:
lda ($00, x)
lda ($00, x)
lda ($00, x)
lda ($00, x)
inx
bne !loop-
iny
bne !loop-
!skip:
// print LOADING
:mov16 #$f5d2 ; SMC_PRINT_SEARCH_LOADING+1
jsr PRINT_SEARCH_LOADING


ldy #16
// copy bank
lda (ENTRY_PTR), y
clc
adc $df00
.if(!fast_load){
sta SMC_BANK+1
}else{
sta ZP_BANK
}
iny
iny // upper bank-register
// copy offset
lda (ENTRY_PTR), y
.if(!fast_load){
sta SMC_ADDR+1
}else{
sta SRC_PTR+0
}
iny
lda (ENTRY_PTR), y
.if(!fast_load){
sta SMC_ADDR+2
}else{
sta SRC_PTR+1
}
iny
// copy load-address
lda (ENTRY_PTR), y
sta DEST_PTR+0
iny
lda (ENTRY_PTR), y
sta DEST_PTR+1
iny
// copy size
lda (ENTRY_PTR), y
pha
iny
lda (ENTRY_PTR), y
sta SIZE+1
//iny
pla
sta SIZE+0

// load-address
lda $b9
bne copy_file

use_own_la:
// use the laodaddress specified
:mov $c3 ; DEST_PTR+0
:mov $c4 ; DEST_PTR+1

copy_file:
.if(!fast_load){
// dec 1, because we count to underflow
:dec16 SIZE

ldy #0
!loop:
jsr READ_BYTE
sta (DEST_PTR), y
:inc16 DEST_PTR
lda SIZE+0
bne nodecupper
lda SIZE+1
beq !exit+
dec SIZE+1
nodecupper:
dec SIZE+0
jmp !loop-

!exit:
// success+return
ldx DEST_PTR+0
ldy DEST_PTR+1
clc
:mov #$60 ; RETURN_COMMAND

jmp DISABLE_CRT


}else{


// update size (for faked start < 0)
:add16_8 SIZE ; SRC_PTR

// lower source -> y ; copy always block-wise
:sub16_8 DEST_PTR ; SRC_PTR
ldy SRC_PTR
:mov #0 ; SRC_PTR
sta smc_limit+1

:if SIZE+1 ; NE ; #$00 ; JMP ; COPY_FILE
sty smc_limit+1
jmp COPY_FILE_LESS_THEN_ONE_PAGE

}

/*

fast:
ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC
.;dfc6 60 00 3a f7 2f 37 00110100 000 004

slow:
ADDR AC XR YR SP 00 01 NV-BDIZC LIN CYC
.;82db 60 00 3a f7 2f 37 00110100 000 004

*/
Loading

0 comments on commit 416b19e

Please sign in to comment.