-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
426 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,14 +51,15 @@ Windows/MinGW: | |
|
||
``` | ||
usage: c2d [-vh?] | ||
c2d [-mu] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk | ||
c2d [-bum] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk | ||
-h|? this help | ||
-m jump to monitor after booting | ||
-s XXXX jump to XXXX after booting | ||
-t filename, where filename is a 1K $400-$7FF text page splash screen | ||
The splash screen will display while the binary is loading | ||
-u do not patch screen holes | ||
-b animated loading bar (experimental) | ||
-v print version number and exit | ||
Input without a .mon extension is assumed to be a binary with a 4 byte header. | ||
|
@@ -104,7 +105,7 @@ Yes. No input checking. Big Endian untested. | |
|
||
### The Ugly Stuff | ||
|
||
c2d, Code to Disk, Version 0.53 | ||
c2d, Code to Disk, Version 0.54 | ||
|
||
(c) 2012,2017 All Rights Reserved, Egan Ford ([email protected]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
;bar.s | ||
; | ||
; moves itself to another page memory, | ||
; then reads binary from disk using params at end, | ||
; then jumps to binary | ||
; | ||
|
||
; apple params/vectors | ||
|
||
warm = $FF69 ; back to monitor | ||
bell = $FBDD ; ding | ||
preg = $48 ; mon p reg | ||
ch = $24 ; cursor horizontal | ||
movecur = $FB5B ; move cursor to ch,a | ||
cout = $FDED ; character out sub | ||
|
||
; dos params/vectors | ||
|
||
rwtsprm = $B7E8 ; looked at dos 3.3 disk, not using $3E3 to find | ||
rwts = $B7B5 ; rwts jsr | ||
|
||
; vars | ||
|
||
stage1 = $800 | ||
stage2 = $300 ; $300 looks open | ||
invsp = $20 ; inverse space for draw | ||
;;;run time | ||
trkcnt = $00 ; track counter | ||
segcnt = $01 ; loop var | ||
buffer = $02 ; MSB of RWTS buffer | ||
secnum = $03 ; loop var | ||
trknum = $04 ; loop var | ||
barcnt = $05 ; bar counter | ||
barptr = $06 ; bar pointer | ||
|
||
|
||
.org stage1 | ||
init: | ||
lda #0 ; reset pointer and counter | ||
sta barcnt | ||
sta barptr | ||
|
||
lda #1 ; read(1)/write(2) command | ||
ldy #$0C ; offset in RWTS | ||
sta rwtsprm,y ; write it to RWTS | ||
|
||
lda #0 ; buffer LSB | ||
ldy #8 ; offset in RWTS | ||
sta rwtsprm,y ; write it to RWTS | ||
|
||
lda #2 | ||
sta trknum ; start with track 2 | ||
|
||
start: | ||
ldx #0 ; move code to stage2 | ||
move: | ||
lda moved,x | ||
sta loader,x | ||
inx | ||
cpx #$D0 | ||
bne move ; move 208 bytes | ||
jmp loader | ||
|
||
moved: | ||
.org stage2 | ||
|
||
loader: | ||
lda loadpage ; where to dump the tracks | ||
sta buffer | ||
|
||
ldx lasttrack | ||
dex ; because data starts at track 2 | ||
dex | ||
stx trkcnt ; number of complete and partial tracks | ||
|
||
;;;begin track loop | ||
trkloop: | ||
lda trknum ; track number | ||
ldy #4 ; offset in RWTS | ||
sta rwtsprm,y ; write it to RWTS | ||
|
||
;;;begin sector loop (16), backwards is faster, much faster | ||
lda trkcnt ; check if last track | ||
bne fulltrack ; if not then full track | ||
lda lastsector ; if so, get last sector number | ||
bpl subtrack | ||
fulltrack: | ||
lda #$F | ||
subtrack: | ||
sta secnum | ||
secloop: | ||
lda secnum ; sector number | ||
ldy #5 ; offset in RWTS | ||
sta rwtsprm,y ; write it to RWTS | ||
|
||
lda buffer ; buffer MSB | ||
clc | ||
adc secnum ; compute page load address | ||
ldy #9 ; offset in RWTS | ||
sta rwtsprm,y ; write it to RWTS | ||
|
||
ldy #<rwtsprm ; load rwts paramlist B7E8 | ||
lda #>rwtsprm | ||
jsr rwts ; do it! | ||
bcs diskerror | ||
lda #0 | ||
sta preg ; fix p reg so mon is happy | ||
|
||
;;;draw code | ||
inc barcnt ; sectors read | ||
ldx barptr ; get current pointer value | ||
lda bar,x | ||
cmp barcnt ; is bar,x = barcnt? | ||
bne nodraw ; if bar,x = barcnt draw bar | ||
lda barptr ; get position | ||
;clc | ||
;adc #5 ; intend | ||
sta ch | ||
lda #19 ; row 19 | ||
jsr movecur | ||
lda #invsp | ||
jsr cout | ||
inc barptr ; move pointer to next bar position | ||
nodraw: | ||
;;;end draw code | ||
|
||
dec secnum | ||
bpl secloop | ||
;;;end sector loop | ||
|
||
lda buffer ; buffer += $10 | ||
clc | ||
adc #$10 | ||
sta buffer | ||
|
||
inc trknum ; next track | ||
dec trkcnt ; | ||
bpl trkloop ; 0, all done with tracks | ||
;;;end track loop | ||
|
||
done: | ||
jmp (nextjump) ; down with load, run it | ||
|
||
diskerror: | ||
jmp warm | ||
|
||
lasttrack: | ||
.org *+1 | ||
lastsector: | ||
.org *+1 | ||
loadpage: | ||
.org *+1 | ||
nextjump: | ||
.org *+2 | ||
bar: | ||
.org *+40 | ||
;;; used for debug | ||
;trkcnt: | ||
; .org *+1 | ||
;segcnt: | ||
; .org *+1 | ||
;buffer: | ||
; .org *+1 | ||
;secnum: | ||
; .org *+1 | ||
;trknum: | ||
; .org *+1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
c2d, Code to Disk, Version 0.53 | ||
c2d, Code to Disk, Version 0.54 | ||
(c) 2012,2017 All Rights Reserved, Egan Ford ([email protected]) | ||
|
@@ -43,7 +43,7 @@ Based on work by: | |
#include "c2d.h" | ||
#include "holes.h" | ||
|
||
#define VERSION "Version 0.53" | ||
#define VERSION "Version 0.54" | ||
#define INFILE argv[argc-2] | ||
#define OUTFILE argv[argc-1] | ||
#define BINARY 0 | ||
|
@@ -57,13 +57,13 @@ int main(int argc, char **argv) | |
{ | ||
FILE *ifp, *ofp; | ||
int c, i, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0, unpatch = 0; | ||
int loaderstart, loader = 0, loadersize = 0, textpagesize = 0; | ||
int loaderstart, loader = 0, loadersize = 0, loaderbasesize = 0, textpagesize = 0, bar = 0; | ||
struct stat st; | ||
char *filetypes[] = { "BINARY", "MONITOR" }; | ||
char *ext, filename[256], load_address[10], *textpage = NULL; | ||
|
||
opterr = 1; | ||
while ((c = getopt(argc, argv, "t:vmh?s:u")) != -1) | ||
while ((c = getopt(argc, argv, "t:vmh?s:ub")) != -1) | ||
switch (c) { | ||
case 't': // load a splash page while loading binary | ||
loader = 1; | ||
|
@@ -83,6 +83,9 @@ int main(int argc, char **argv) | |
case 'u': | ||
unpatch = 1; | ||
break; | ||
case 'b': | ||
bar = 1; | ||
break; | ||
case 'h': // help | ||
case '?': | ||
usage(); | ||
|
@@ -218,8 +221,7 @@ int main(int argc, char **argv) | |
fclose(ifp); | ||
|
||
// patch holes | ||
if(!unpatch) | ||
{ | ||
if(!unpatch) { | ||
uint64_t *p = (uint64_t *)&blank.track[1].sector[0].byte[0]; // set to start of splash page | ||
uint64_t *h = (uint64_t *)&holes; // holes are 64-bits | ||
int i; | ||
|
@@ -232,13 +234,26 @@ int main(int argc, char **argv) | |
} | ||
} | ||
|
||
if ((loadersize = sizeof(loadercode)) > 256) { | ||
fprintf(stderr, "Loader code size %d > 256\n\n", loadersize); | ||
return 1; | ||
if(!bar) { | ||
loaderbasesize = sizeof(loadercode); | ||
if ((loadersize = sizeof(loadercode)) > 256) { | ||
fprintf(stderr, "Loader code size %d > 256\n\n", loadersize); | ||
return 1; | ||
} | ||
|
||
for (i = 0; i < loadersize; i++) | ||
blank.track[1].sector[4].byte[i] = loadercode[i]; | ||
} | ||
else { | ||
loaderbasesize = sizeof(barcode); | ||
if ((loadersize = sizeof(barcode)) > 256) { | ||
fprintf(stderr, "Loader code size %d > 256\n\n", loadersize); | ||
return 1; | ||
} | ||
|
||
for (i = 0; i < loadersize; i++) | ||
blank.track[1].sector[4].byte[i] = loadercode[i]; | ||
for (i = 0; i < loadersize; i++) | ||
blank.track[1].sector[4].byte[i] = barcode[i]; | ||
} | ||
|
||
// loader args | ||
// lasttrack | ||
|
@@ -252,6 +267,16 @@ int main(int argc, char **argv) | |
// program start MSB | ||
blank.track[1].sector[4].byte[loadersize + 4] = start >> 8; | ||
|
||
//bar code, pre compute status bar table | ||
if(bar) { | ||
int num_sectors = (int) ceil((filesize + (loadaddress & 0xFF)) / 256.0); | ||
int bar_length = 40; | ||
int i; | ||
|
||
for(i = 1; i <= bar_length; i++) | ||
blank.track[1].sector[4].byte[loadersize + 4 + i] = i * num_sectors / bar_length; | ||
} | ||
|
||
loaderstart = 0x400; | ||
|
||
// temp hack to effect the sound of the drive, i.e. to make consistent | ||
|
@@ -278,7 +303,7 @@ int main(int argc, char **argv) | |
|
||
fprintf(stderr, "After boot, jump to: $%04X\n", loaderstart); | ||
fprintf(stderr, "\n"); | ||
fprintf(stderr, "Writing %s to T:02/S:00 - T:%02d/S:%02d on %s\n\n", filename, blank.track[1].sector[4].byte[sizeof(loadercode)], blank.track[1].sector[4].byte[sizeof(loadercode) + 1], OUTFILE); | ||
fprintf(stderr, "Writing %s to T:02/S:00 - T:%02d/S:%02d on %s\n\n", filename, blank.track[1].sector[4].byte[sizeof(loadercode)], blank.track[1].sector[4].byte[loaderbasesize + 1], OUTFILE); | ||
} | ||
|
||
if ((ofp = fopen(OUTFILE, "wb")) == NULL) { | ||
|
Oops, something went wrong.