Compare commits

...

80 Commits
v0.4 ... master

Author SHA1 Message Date
Egan Ford 9af2b2d8fd new bins from tests, hack to dwine to sleep 1 sec before test 2023-10-26 14:57:08 -06:00
datajerk f3991f4cd1
Merge pull request #3 from ryandesign/ryandesign-cc
Allow Makefile compiler to be set with CC variable
2023-10-26 14:54:07 -06:00
datajerk d74542dd56
Merge pull request #2 from ryandesign/ryandesign-strict-prototypes
Fix issues found with -Wstrict-prototypes
2023-10-26 14:53:26 -06:00
Ryan Schmidt 11281905bd Allow Makefile compiler to be set with CC variable 2023-10-25 23:03:40 -05:00
Ryan Schmidt a54024f82a Fix issues found with -Wstrict-prototypes 2023-10-25 22:43:55 -05:00
Egan Ford e4815fe220 updated README.md 2023-05-10 17:37:01 -06:00
Egan Ford 9b1b8c423c updated README.md links, cleaned up testing docs 2023-05-10 17:24:58 -06:00
Egan Ford 6105800884 readded binaries 2023-05-09 14:25:36 -06:00
Egan Ford a64e5a176b readded binaries 2023-05-09 14:04:22 -06:00
Egan Ford ced20889ab docker wine32 support added 2023-05-09 14:02:04 -06:00
Egan Ford e6e2c9b15a fixed virtual ii 11.1 testing 2023-05-09 13:37:58 -06:00
Egan Ford 51933f3223 fixed windows testing, docker required now 2023-05-09 12:32:10 -06:00
Egan Ford 163d8a9661 updated README for cc65 version 2023-05-09 12:10:22 -06:00
Egan Ford e0d9e2a3ca included cc65 build, macos universal builds, refactored 2023-05-09 12:04:21 -06:00
Egan Ford e690a1c022 spelling error 2019-06-23 09:54:29 -06:00
Egan Ford ecd49dd0bf updated gameserverclient example binary 2017-05-31 20:15:19 -06:00
Egan Ford 0a4199ed9c updated README 2017-05-11 16:11:02 -06:00
Egan Ford 6db80b8ae5 minor readme and comment and formatting updates 2017-05-06 12:24:37 -06:00
Egan Ford ebf2cfc94d minor readme and comment and formatting updates 2017-05-06 12:22:59 -06:00
Egan Ford 5e85697fe4 readme clean 2017-05-05 07:41:02 -06:00
Egan Ford 7e03db4b42 readme clean 2017-05-05 07:40:00 -06:00
Egan Ford e3a17ab29b completely removed all hacks for scratchpad ram, loader and bar asm only write to text RAM, no scratchpad ram. 2017-05-03 11:43:15 -06:00
Egan Ford a3721ecb54 completely removed all hacks for scratchpad ram, loader and bar asm only write to text RAM, no scratchpad ram. 2017-05-03 11:37:16 -06:00
Egan Ford 8498a0ef05 completely removed all hacks for scratchpad ram, loader and bar asm only write to text RAM, no scratchpad ram. 2017-05-03 10:39:36 -06:00
Egan Ford 249e6c2600 completely removed all hacks for scratchpad ram, loader and bar asm only write to text RAM, no scratchpad ram. 2017-05-03 10:38:56 -06:00
Egan Ford a191c5cd81 new loader that does not load splash screen directly to 0x400, but to 0x800 and then moves it to 0x400 to avoid overwriting scratchpad ram 2017-05-03 06:58:55 -06:00
Egan Ford 4c9315f2ef added end tag for listing 2017-04-30 11:39:41 -06:00
Egan Ford 0c5f9bdae0 color changes, optimized for 39 rows 2017-04-27 17:37:51 -06:00
Egan Ford 7b7ab6627d added -g option for LGR mixed gr/text splash screen 2017-04-24 23:11:51 -06:00
Egan Ford 0e25155cf6 readme update 2017-04-23 11:13:10 -06:00
Egan Ford 7f0c603000 minor non-code changes 2017-04-22 20:45:43 -06:00
Egan Ford f72e99fd34 -r option to override default bar row 2017-04-22 20:37:59 -06:00
Egan Ford 3731f93a92 -r option to override default bar row 2017-04-22 20:36:47 -06:00
Egan Ford 62fc5ab66b animated loading bar -b option 2017-04-22 20:16:01 -06:00
Egan Ford cc8d40c802 animated loading bar -b option 2017-04-22 20:14:29 -06:00
Egan Ford 695afe66cc animated loading bar -b option 2017-04-22 20:13:22 -06:00
Egan Ford 5e83553858 changed test splash page, no code changes 2017-04-22 12:12:40 -06:00
Egan Ford d00cb0a0ef changed test splash page, no code changes 2017-04-22 12:08:02 -06:00
Egan Ford 081a78b10f screen hole patching directly in c2d, more test options 2017-04-22 10:33:53 -06:00
Egan Ford f56cd484e6 grammar 2017-04-21 17:40:15 -06:00
Egan Ford 7e5d0c1a23 fix ramdom applescript crash on test, updated version number 2017-04-21 17:34:50 -06:00
Egan Ford 080865007d updated watermark 2017-04-21 17:31:10 -06:00
Egan Ford 186b015657 version change, release 2017-04-21 17:15:54 -06:00
Egan Ford b12fa7e132 version change, release 2017-04-21 17:15:34 -06:00
Egan Ford 63be2912f3 version change, release 2017-04-21 17:14:13 -06:00
Egan Ford 72e8d00b8b minor update 2017-04-21 17:13:00 -06:00
Egan Ford d06d05565c minor timing changes, comment cleanup 2017-04-19 19:48:37 -06:00
Egan Ford 12ea7313bd added emulated tests 2017-04-18 09:15:30 -06:00
Egan Ford aea92e1415 minor not improvements 2017-04-16 14:41:32 -06:00
Egan Ford ae3876a8f7 minor not improvements 2017-04-16 14:40:25 -06:00
Egan Ford e841deb38e minor README update 2017-04-16 14:13:53 -06:00
Egan Ford faaebeca7c added c2d.h to allow contrib without needed to assemble loader.s 2017-04-16 14:08:06 -06:00
Egan Ford 7675e83b82 updated comments 2017-04-16 14:02:54 -06:00
Egan Ford 458dc9c6ff more minor refactoring 2017-04-16 13:57:43 -06:00
Egan Ford b5b24d2486 more minor refactoring 2017-04-16 13:57:04 -06:00
Egan Ford 52db29a758 minor refactoring 2017-04-16 13:16:36 -06:00
Egan Ford baedd4edd8 more cleanup 2017-04-16 12:04:32 -06:00
Egan Ford 373c4ea6c6 source cleanup, gnuindent 2017-04-16 10:38:06 -06:00
Egan Ford f3b1afb67b comment cleanup 2017-04-15 22:03:18 -06:00
Egan Ford 459acf0fb7 nitpicking 2017-04-15 21:58:58 -06:00
Egan Ford 64c48974d4 added page2text, fixed 40 col bug in text2page 2017-04-15 21:56:58 -06:00
Egan Ford 6f38a3d75f added page2text, fixed 40 col bug in text2page 2017-04-15 21:55:14 -06:00
Egan Ford 2bc0752f9d added page2text, fixed 40 col bug in text2page 2017-04-15 21:52:52 -06:00
Egan Ford b41676bab8 added page2text, fixed 40 col bug in text2page 2017-04-15 21:50:13 -06:00
Egan Ford 68a976c7e6 added page2text, fixed 40 col bug in text2page 2017-04-15 21:48:38 -06:00
Egan Ford 412c1d2c74 added page2text, fixed 40 col bug in text2page 2017-04-15 21:39:00 -06:00
Egan Ford 2cd4829302 added page2text, fixed 40 col bug in text2page 2017-04-15 21:36:28 -06:00
Egan Ford 8e2ed42e0d added page2text, fixed 40 col bug in text2page 2017-04-15 21:24:44 -06:00
Egan Ford bf8d9d465e updated rev number 2017-04-15 20:42:30 -06:00
Egan Ford 9a39b98b35 loader to run from 00 now 2017-04-15 19:41:29 -06:00
Egan Ford 169fa95e50 added .mon testing 2017-04-15 13:48:21 -06:00
Egan Ford ee289c7d79 changed output message order 2017-04-12 19:13:58 -06:00
Egan Ford e1a469cf72 more c2d.c cleanup 2017-04-12 17:52:33 -06:00
Egan Ford 368161abc7 minor c2d.c cleanup, ran indent -kr -ts4, unwrapped lines 2017-04-12 17:44:02 -06:00
Egan Ford 617d504af5 loader.s cleanup, comments 2017-04-12 17:31:25 -06:00
Egan Ford 5a246f205b move loader to B600 2017-04-12 17:22:48 -06:00
Egan Ford 90a86105a7 text2page minor non-functional update 2017-04-09 14:47:26 -06:00
Egan Ford 00609d4106 minor optimizations 2017-04-09 09:17:09 -06:00
Egan Ford 35da6e5d99 minor bug 2017-04-08 22:04:07 -06:00
Egan Ford 686ac49d04 test cleanup 2017-04-08 21:56:22 -06:00
30 changed files with 5150 additions and 339 deletions

12
Dockerfile.wine32 Normal file
View File

@ -0,0 +1,12 @@
# docker build --no-cache -t wine32 -f Dockerfile.wine32 .
FROM ubuntu:19.10
ENV LC_CTYPE C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get -qy install wine32
WORKDIR /root
RUN wine foobar || true

116
Makefile
View File

@ -1,34 +1,124 @@
WIN32GCC = /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin/i586-mingw32-gcc
C2T = c2t
all: bin/c2d bin/text2page
all: bin/c2d bin/text2page bin/page2text
windows: bin/c2d.exe bin/text2page.exe
windows: bin/c2d.exe bin/text2page.exe bin/page2text.exe
dist: all windows
c2d.h: c2d.h.0 asm/loader.s makeheader
cc65-sources-2.13.3.tar.bz2:
curl -sLO https://github.com/mrdudz/cc65-old/raw/master/cc65-sources-2.13.3.tar.bz2
cc65-2.13.3/bin/cl65: cc65-sources-2.13.3.tar.bz2
tar zxf cc65-sources-2.13.3.tar.bz2
(cd cc65-2.13.3; /usr/bin/sed 's!/usr/local!'${PWD}'/cc65-2.13.3!' <make/gcc.mak >Makefile; make -j4 bins || make bins && make install || true)
c2d.h: c2d.h.0 asm/loader.s asm/bar.s makeheader cc65-2.13.3/bin/cl65
./makeheader
bin/c2d: c2d.c c2d.h
gcc -Wall -Wno-missing-braces -I. -O3 -o $@ $< -lm
bin/c2d_arm: c2d.c c2d.h
$(CC) -Wall -Wno-missing-braces -I. -O3 -target arm64-apple-macos11 -o $@ $< -lm
bin/text2page_arm: text2page.c
$(CC) -Wall -O3 -target arm64-apple-macos11 -o $@ $< -lm
bin/page2text_arm: page2text.c
$(CC) -Wall -O3 -target arm64-apple-macos11 -o $@ $< -lm
bin/mandelbrotgr_arm: mandelbrotgr.c
$(CC) -Wall -O3 -target arm64-apple-macos11 -o $@ $< -lm
bin/c2d_x86: c2d.c c2d.h
$(CC) -Wall -Wno-missing-braces -I. -O3 -target x86_64-apple-macos10.12 -o $@ $< -lm
bin/text2page_x86: text2page.c
$(CC) -Wall -O3 -target -x86_64-apple-macos10.12 -o $@ $< -lm
bin/page2text_x86: page2text.c
$(CC) -Wall -O3 -target x86_64-apple-macos10.12 -o $@ $< -lm
bin/mandelbrotgr_x86: mandelbrotgr.c
$(CC) -Wall -O3 -target x86_64-apple-macos10.12 -o $@ $< -lm
bin/c2d: bin/c2d_x86 bin/c2d_arm
lipo -create -output $@ $<
bin/text2page: bin/text2page_x86 bin/text2page_arm
lipo -create -output $@ $<
bin/page2text: bin/page2text_x86 bin/page2text_arm
lipo -create -output $@ $<
bin/mandelbrotgr: bin/mandelbrotgr_x86 bin/mandelbrotgr_arm
lipo -create -output $@ $<
bin/c2d.exe: c2d.c c2d.h
$(WIN32GCC) -Wall -Wno-missing-braces -I. -O3 -o $@ $<
bin/text2page: text2page.c
gcc -Wall -O3 -o $@ $< -lm
bin/text2page.exe: text2page.c
$(WIN32GCC) -Wall -O3 -o $@ $<
bin/page2text.exe: page2text.c
$(WIN32GCC) -Wall -O3 -o $@ $<
clean:
rm -f bin/* *.dsk c2d.h c2d.h.1
rm -rf bin/* *.dsk c2d.h c2d.h.1 cc65-sources-2.13.3.tar.bz2 cc65-2.13.3
(cd asm; make clean)
gameserverclient.text:
figlet -c -w 40 -f slant "Game Server Client Online" >$@
gameserverclient.text: Makefile
( \
figlet -c -w 40 -f slant "Apple ][ Game Server Online!" | \
perl -p -e 's/^ +\n$$//' | \
sed '1,6s/^/ /'; \
echo; \
text="THE APPLE ][ AE WARESHOLE IS BACK!"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
text="CASSETTE PORT FTW! ---- ASCIIEXPRESS.NET"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
) | tail -24 >$@
test: gameserverclient gameserverclient.text dist
./test.sh
barloader.text: Makefile
( \
echo; \
figlet -c -w 40 -f poison "c2d"; \
echo; \
text="C2D (CODE TO DISK) BUILT-IN LOADER"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
echo; \
text="LOADING GAME SERVER CLIENT ..."; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
echo; \
text="________________________________________"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
text="________________________________________"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
echo; \
echo; \
text="HTTP://GITHUB.COM/DATAJERK/C2D"; printf "%*s\n" $$((($${#text}+40)/2)) "$$text"; \
) | tail -24 >$@
barloader.textpage: barloader.text bin/text2page
bin/text2page <$< >$@
gameserverclientbar.dsk: barloader.textpage gameserverclient bin/c2d Makefile
bin/c2d -b -t $< gameserverclient,800 $@
bargrloader.textpage: bin/mandelbrotgr
bin/mandelbrotgr >$@
gameserverclientbargr.dsk: bargrloader.textpage gameserverclient bin/c2d Makefile
bin/c2d -b -g -r 23 -t $< gameserverclient,800 $@
gameserverclient.dsk: gameserverclient bin/c2d Makefile
bin/c2d gameserverclient,800 $@
dsk: gameserverclient.dsk gameserverclientbar.dsk gameserverclientbargr.dsk
gameserverclient.mon: gameserverclient
$(C2T) gameserverclient,800 gameserverclient.mon
fulltest: gameserverclient gameserverclient.mon gameserverclient.text gameserverclient.tiff gameserverclientsplash.tiff test.sh test.scrp dist
EMU=1 WIN=1 ./test.sh
disttest: gameserverclient gameserverclient.mon gameserverclient.text test.sh dist
EMU=0 WIN=1 ./test.sh
test: gameserverclient gameserverclient.mon gameserverclient.text test.sh all
EMU=0 WIN=0 ./test.sh

111
README.md
View File

@ -4,36 +4,20 @@
> Based on work by:
>
> Weishaar, Tom. *Running without filenames*. Open-Apple Jan. 1985 Vol. 1, No. 0: p. 7 (<http://apple2online.com/web_documents/Open%20Apple%20Vol1No00.pdf>)
> Weishaar, Tom. *Running without filenames*. Open-Apple Jan. 1985 Vol. 1, No. 0: p. 7 (<https://web.archive.org/web/20150325102420/http://apple2online.com/web_documents/Open%20Apple%20Vol1No00.pdf>)
`c2d` early history: http://macgui.com/usenet/?group=1&id=254902#msg
### Features
* `$800-$B6FF` available for binary code.
* `$B700-$BFFF` free after load.
* Platforms tested:
* 32-bit/64-bit x86 OS/X.
* 32-bit/64-bit x86 MacOS|OS/X.
* 32-bit x86 Windows/MinGW.
### Distribution Files
| Filename | Description |
|-------------------|----------------------|
| README.md | This File |
| c2d.c | Source File |
| c2d.h.0 | Source File |
| makeheader | c2d.h build script |
| text2page.c | Source File |
| Makefile | c2d Makefile |
| asm/loader.s | c2d loader source |
| asm/Makefile | c2d loader Makefile |
| bin/c2d | OS/X x86 Binary |
| bin/c2d.exe | Windows Binary |
| bin/text2page | OS/X x86 Binary |
| bin/text2page.exe | Windows Binary |
| gameserverclient* | Test Apple II Binary |
| test.sh | test script |
### Download
```
@ -45,6 +29,11 @@ git clone https://github.com/datajerk/c2d.git
Download <https://github.com/datajerk/c2d/archive/master.zip> and extract.
### No Build Notes
Just get the files from [`bin`](https://github.com/datajerk/c2d/tree/master/bin). 32-bit Windows and MacOS (universal x86_64/arm64) included.
### Build Notes
Unix/Linux:
@ -53,29 +42,34 @@ Unix/Linux:
*or*
OS/X, Linux, Cygwin:
MacOS|OS/X, Linux, Cygwin:
gcc -Wall -Wno-missing-braces -I. -O3 -o c2d c2d.c -lm
gcc -Wall -O3 -o bin/text2page text2page.c -lm
gcc -Wall -O3 -o bin/page2text page2text.c -lm
Windows/MinGW:
PATH=C:\MinGW\bin;%PATH%
gcc -Wall -Wno-missing-braces -static -I. -O3 -o c2d c2d.c -lm
gcc -Wall -O3 --static -o bin/text2page text2page.c -lm
gcc -Wall -O3 --static -o bin/page2text page2text.c -lm
### c2d Usage/Examples
```
usage: c2d [-vh?]
c2d [-m] [-s start address override] input[.mon],[load_address] output.dsk
c2d [-bgm] [-r row] [-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.
-t filename, where filename is a 1K $400-$7FF text page splash screen
The splash screen will display while the binary is loading
-b animated loading bar
-g splash page is mixed mode GR
-r override row default of 19 with 'row'
-v print version number and exit
Input without a .mon extension is assumed to be a binary with a 4 byte header.
@ -97,14 +91,75 @@ Examples:
c2d -t gameserverclient.textpage gameserverclient,800 gameserverclient.dsk
```
### Splash Page Examples
*Click on image to see video.*
> Splash pages are the exact bytes the Apple II expects in memory range $400-$7FF. Your splash screen should be exactly 1024 bytes (do not worry, the `c2d` loader will not overwrite the Peripheral Slot Scratchpad RAM).
```
c2d -t gameserverclient.textpage gameserverclient,800 gameserverclient.dsk
```
`-t gameserverclient.textpage` instructs `c2d` to put up a text splash page while the binary is loading.
[![splash](https://img.youtube.com/vi/9EPy0JnnJyA/0.jpg)](https://www.youtube.com/watch?v=9EPy0JnnJyA "splash")
-----
```
c2d -b -t barloader.textpage gameserverclient,800 gameserverclientbar.dsk
```
`-b` adds an animated bar on line 19.
[![splash](https://img.youtube.com/vi/D3SaHlw4fgM/0.jpg)](https://www.youtube.com/watch?v=D3SaHlw4fgM "splashbar")
-----
```
c2d -b -g -r 23 -t bargrloader.textpage gameserverclient,800 gameserverclientbargr.dsk
```
`-r 23` moves the animated bar to line 23, and `-g` indicates the splash page is mixed mode text/gr.
[![splashbargr](https://img.youtube.com/vi/4Ik1eraAM6c/0.jpg)](https://www.youtube.com/watch?v=4Ik1eraAM6c "splashbargr")
### text2page Example
Input is expected to be ASCII text. Only the first 40 characters/line and the first 24 lines are read. See `gameserverclient.text` example.
Input is expected to be ASCII text (LF or CRLF line terminated). Only the first 40 characters/line and the first 24 lines are read. See `gameserverclient.text` and `barloader.text` examples.
```
text2page <gameserverclient.text >gameserverclient.textpage
```
### page2text Example
Input is expected to be an Apple II binary from $400-$7FF. Exactly 1024 bytes. See `gameserverclient.textpage` example.
> Text output lines are newline (LF) terminated. Windows users may need to convert LF to CRLF (editor dependent).
```
page2text <gameserverclient.textpage >gameserverclient.text
```
### Testing
Automated testing is only supported on MacOS|OS/X and requires the following:
* Virtual ][ (<http://http://www.virtualii.com/>)
* Windows cross-compiling tools <https://web.archive.org/web/20151009134313/http://crossgcc.rts-software.org/download/gcc-4.8.0-qt-4.8.4-win32/gcc-4.8.0-qt-4.8.4-for-mingw32.dmg>
* Docker required for Windows binary testing; run this once first `docker build --no-cache -t wine32 -f Dockerfile.wine32 .`
NOTE: Windows binary testing only supported on MacOS x86_64 machines.
To test, type:
```
make test # MacOS|OS/X only
make disttest # MacOS|OS/X and Windows
make fulltest # MacOS|OS/X, Windows, and Virtual ][
```
### Bugs
Yes. No input checking. Big Endian untested.
@ -112,7 +167,7 @@ Yes. No input checking. Big Endian untested.
### The Ugly Stuff
c2d, Code to Disk, Version 0.4, Sun Apr 9 03:16:22 UTC 2017
c2d, Code to Disk, Version 0.57
(c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net)

View File

@ -1,9 +1,6 @@
CL = cl65
CL_FLAGS = -t none --listing --list-bytes 100
#CL_FLAGS = -t apple1 -C apple1-16k.cfg --listing --list-bytes 100
CC = cl65
CC_FLAGS = --static-locals -t apple1 -C apple1-16k.cfg
C2T = c2t
ASRC = $(shell echo *.s)
AOBJ = $(ASRC:%.s=%.o)
@ -17,11 +14,4 @@ clean:
-rm -f $(ABIN) $(AOBJ) $(ALST) $(AMON)
%: %.s
$(CL) $(CL_FLAGS) $<
%: %.c
$(CC) $(CC_FLAGS) $<
%.mon: %
$(C2T) $< $@
$(CL) $(CL_FLAGS) $<

206
asm/bar.s Normal file
View File

@ -0,0 +1,206 @@
;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 = $C00
stage2 = $300 ; $300 looks open
invsp = $20 ; inverse space for draw
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
grcheck:
lda *+(gr-loader)+(moved-grcheck)
beq movetext
lda #0 ; GR mode
sta $C050
sta $C053
movetext:
ldx #0
movetx:
lda $800,x
sta $400,x
lda $880,x
sta $480,x
lda $900,x
sta $500,x
lda $980,x
sta $580,x
lda $A00,x
sta $600,x
lda $A80,x
sta $680,x
lda $B00,x
sta $700,x
lda $B80,x
sta $780,x
inx
cpx #120
bne movetx ; move 120 bytes
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 ; indent
; new version, no rom calls, just poke to screen
clc ; clear carry
adc rowlsb ; add the text page row lsb
sta screen+1 ; store that in self mod code
lda rowmsb ; get text page row msb
sta screen+2 ; store that in self mod code
lda #invsp ; load block char
screen:
sta $400 ; write out char
; old version, rom calls, cout will scroll windows on 40x24
;sta ch
;lda row ; 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
gr:
.org *+1
row:
.org *+1
rowlsb:
.org *+1
rowmsb:
.org *+1
bar:
.org *+40
end:

View File

@ -1,39 +1,65 @@
;diskload2.s
;loader.s
;
; moves itself to another page memory,
; then reads binary from disk using params at end,
; then jumps to binary
;
; apple vectors
; apple params/vectors
warm = $FF69 ; back to monitor
bell = $FBDD ; ding
preg = $48 ; mon p reg
; dos params/vectors
rwtsprm = $B7E8 ; looked at dos 3.3 disk, not using $3E3 to find
rwts = $B7B5 ; rwts jsr
; vars
lopage = $0800
hipage = $B500
rwtsprm = $B7E8 ; looked at dos 3.3 disk, not using $3E3 to find
rwts = $B7B5
preg = $48 ; mon p reg
;trkcnt = $00 ; track counter
;segcnt = $01 ; loop var
;buffer = $02 ; MSB of RWTS buffer
;secnum = $03 ; loop var
;trknum = $04 ; loop var
stage1 = $C00
stage2 = $300 ; $300 looks open
;;;run time
trkcnt = $00 ; track counter
segcnt = $01 ; loop var
buffer = $02 ; MSB of RWTS buffer
secnum = $03 ; loop var
trknum = $04 ; loop var
start:
.org lopage
.org stage1
ldx #0 ; move code to hi memory
move:
lda moved,x
sta loader,x
grcheck:
lda *+(gr-loader)+(moved-grcheck)
beq movetext
lda #0 ; GR mode
sta $C050
sta $C053
movetext:
ldx #0
movetx:
lda $800,x
sta $400,x
lda $880,x
sta $480,x
lda $900,x
sta $500,x
lda $980,x
sta $580,x
lda $A00,x
sta $600,x
lda $A80,x
sta $680,x
lda $B00,x
sta $700,x
lda $B80,x
sta $780,x
inx
bne move ; move 256 bytes
jmp loader
moved:
.org hipage
loader:
cpx #120
bne movetx ; move 120 bytes
init:
lda #1 ; read(1)/write(2) command
ldy #$0C ; offset in RWTS
sta rwtsprm,y ; write it to RWTS
@ -45,6 +71,19 @@ loader:
lda #2
sta trknum ; start with track 2
ldx #0 ; move code to stage2
move:
lda moved,x
sta loader,x
inx
;bne move ; move 256 bytes
bpl move ; move 128 bytes
jmp loader
moved:
.org stage2
loader:
lda loadpage ; where to dump the tracks
sta buffer
@ -60,10 +99,10 @@ trkloop:
sta rwtsprm,y ; write it to RWTS
;;;begin sector loop (16), backwards is faster, much faster
lda trkcnt
bne fulltrack
lda lastsector
jmp subtrack
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:
@ -75,7 +114,7 @@ secloop:
lda buffer ; buffer MSB
clc
adc secnum
adc secnum ; compute page load address
ldy #9 ; offset in RWTS
sta rwtsprm,y ; write it to RWTS
@ -101,7 +140,7 @@ secloop:
;;;end track loop
done:
jmp (nextjump)
jmp (nextjump) ; down with load, run it
diskerror:
jmp warm
@ -114,13 +153,6 @@ loadpage:
.org *+1
nextjump:
.org *+2
trkcnt:
.org *+1
segcnt:
.org *+1
buffer:
.org *+1
secnum:
.org *+1
trknum:
gr:
.org *+1
end:

BIN
bargrloader.textpage Normal file

Binary file not shown.

23
barloader.text Normal file
View File

@ -0,0 +1,23 @@
@@@@@@@ @@@@@@ @@@@@@@
@@@@@@@@ @@@@@@@@ @@@@@@@@
!@@ @@@ @@! @@@
!@! @!@ !@! @!@
!@! !!@ @!@ !@!
!!! !!: !@! !!!
:!! !:! !!: !!!
:!: :!: :!: !:!
::: ::: :: ::::: :::: ::
:: :: : :: : ::: :: : :
C2D (CODE TO DISK) BUILT-IN LOADER
LOADING GAME SERVER CLIENT ...
________________________________________
________________________________________
HTTP://GITHUB.COM/DATAJERK/C2D

BIN
barloader.textpage Normal file

Binary file not shown.

BIN
bin/c2d

Binary file not shown.

Binary file not shown.

BIN
bin/page2text Executable file

Binary file not shown.

BIN
bin/page2text.exe Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

284
c2d.c
View File

@ -1,6 +1,6 @@
/*
c2d, Code to Disk, Version 0.4, Sun Apr 9 03:16:22 UTC 2017
c2d, Code to Disk, Version 0.57
(c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net)
@ -18,7 +18,7 @@ License:
Description:
This small utility will read Apple II binary and monitor text files and
output a DOS ordered dsk image that will boot your code quickly.
output a DOS ordered dsk image that will boot your code quickly.
Features:
* Apple II+, IIe support.
@ -28,19 +28,8 @@ Features:
o 32-bit/64-bit x86 OS/X.
o 32-bit x86 Windows/MinGW.
Compile:
OS/X:
gcc -Wall -O -o c2d c2d.c
Linux:
gcc -Wall -O -o c2d c2d.c -lm
Windows/Cygwin:
gcc -Wall -O -o c2d c2d.c
Windows/MinGW:
PATH=C:\MinGW\bin;%PATH%
gcc -Wall -O -static -o c2d c2d.c
Bugs:
* Probably
* Yes (input checking)
*/
@ -53,93 +42,106 @@ Bugs:
#include <sys/stat.h>
#include "c2d.h"
#define VERSION "Version 0.4"
#define VERSION "Version 0.57"
#define INFILE argv[argc-2]
#define OUTFILE argv[argc-1]
#define BINARY 0
#define MONITOR 1
#define LOADER "loader"
void usage();
void usage(void);
char *getext(char *filename);
int main(int argc, char **argv)
{
FILE *ifp, *ofp;
int c, i, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0;
int loaderstart, loader = 0, loadersize = 0, textpagesize = 0;
int loaderstart, loader = 0, loadersize = 0, loaderbasesize = 0, textpagesize = 0;
int bar = 0, row = 19, gr = 0;
struct stat st;
char *filetypes[] = {"BINARY","MONITOR"};
char *ext, filename[256], load_address[10], *textpage=NULL;
char *filetypes[] = { "BINARY", "MONITOR" };
char *ext, filename[256], load_address[10], *textpage = NULL;
opterr = 1;
while((c = getopt(argc, argv, "t:vmh?s:")) != -1)
switch(c) {
case 't':
loader=1;
textpage=optarg;
break;
case 'm':
warm = 1;
break;
case 'v': // version
fprintf(stderr,"\n%s\n\n",VERSION);
return 1;
break;
case 's': // override rate for -1/-2 only
warm = 0;
start = (int)strtol(optarg, (char **)NULL, 16); // todo: input check
break;
case 'h': // help
case '?':
usage();
return 1;
while ((c = getopt(argc, argv, "gr:t:vmh?s:b")) != -1)
switch (c) {
case 't': // load a splash page while loading binary
loader = 1;
textpage = optarg;
break;
case 'm': // boot to monitor
warm = 1;
break;
case 'v': // version
fprintf(stderr, "\n%s\n\n", VERSION);
return 1;
break;
case 's': // start here instead of load address
warm = 0;
start = (int) strtol(optarg, (char **) NULL, 16); // todo: input check
break;
case 'r': // bar row
row = (int) strtol(optarg, (char **) NULL, 10); // todo: input check
if (row > 23)
row = 23;
break;
case 'b':
bar = 1;
break;
case 'g':
gr = 1;
break;
case 'h': // help
case '?':
usage();
return 1;
}
if(argc - optind < 2) {
if (argc - optind < 2) {
usage();
return 1;
}
fprintf(stderr,"\n");
fprintf(stderr, "\n");
inputtype=BINARY;
inputtype = BINARY;
k=0;
for(j=0;j<strlen(INFILE);j++) {
if(INFILE[j] == ',')
k = 0;
for (j = 0; j < strlen(INFILE); j++) {
if (INFILE[j] == ',')
break;
filename[k++]=INFILE[j];
filename[k++] = INFILE[j];
}
filename[k] = '\0';
k=0;j++;
for(;j<strlen(INFILE);j++)
load_address[k++]=INFILE[j];
k = 0;
j++;
for (; j < strlen(INFILE); j++)
load_address[k++] = INFILE[j];
load_address[k] = '\0';
if(k == 0)
if (k == 0)
loadaddress = -1;
else
loadaddress = (int)strtol(load_address, (char **)NULL, 16); // todo: input check
loadaddress = (int) strtol(load_address, (char **) NULL, 16); // todo: input check
if((ext = getext(filename)) != NULL)
if(strcmp(ext,"mon") == 0 || strcmp(ext,"MON") == 0)
if ((ext = getext(filename)) != NULL)
if (strcmp(ext, "mon") == 0 || strcmp(ext, "MON") == 0)
inputtype = MONITOR;
if ((ifp = fopen(filename, "rb")) == NULL) {
fprintf(stderr,"Cannot read: %s\n\n",filename);
fprintf(stderr, "Cannot read: %s\n\n", filename);
return 1;
}
fprintf(stderr,"Reading %s, type %s, load address: $",filename,filetypes[inputtype]);
fprintf(stderr, "Reading %s, type %s, load address: $", filename, filetypes[inputtype]);
if(inputtype == BINARY) {
if (inputtype == BINARY) {
unsigned char b;
stat(filename,&st);
stat(filename, &st);
filesize = st.st_size;
if(loadaddress == - 1) {
if (loadaddress == -1) {
fread(&b, 1, 1, ifp);
loadaddress = b;
fread(&b, 1, 1, ifp);
@ -149,13 +151,12 @@ int main(int argc, char **argv)
fread(&b, 1, 1, ifp);
filesize |= b << 8;
}
//check for errors
fread(&blank.track[1+loader].sector[0].byte[loadaddress & 0xFF], filesize, 1, ifp);
fread(&blank.track[1 + loader].sector[0].byte[loadaddress & 0xFF], filesize, 1, ifp);
}
// todo: lots of input checking
if(inputtype == MONITOR) {
if (inputtype == MONITOR) {
int byte, naddr;
char addrs[8], s;
unsigned char *p = NULL;
@ -163,13 +164,13 @@ int main(int argc, char **argv)
loadaddress = -1;
filesize = 0;
while(fscanf(ifp,"%s ",addrs) != EOF) {
naddr = (int)strtol(addrs, (char **)NULL, 16);
if(loadaddress == -1) {
while (fscanf(ifp, "%s ", addrs) != EOF) {
naddr = (int) strtol(addrs, (char **) NULL, 16);
if (loadaddress == -1) {
loadaddress = naddr;
p = &blank.track[1+loader].sector[0].byte[loadaddress & 0xFF];
p = &blank.track[1 + loader].sector[0].byte[loadaddress & 0xFF];
}
while (fscanf(ifp, "%x%c", &byte, &s) != EOF) {
*p++ = byte;
filesize++;
@ -182,100 +183,136 @@ int main(int argc, char **argv)
fclose(ifp);
fprintf(stderr,"%04X, length: %d\n",loadaddress,filesize);
fprintf(stderr,"\n");
fprintf(stderr, "%04X, length: %d\n", loadaddress, filesize);
fprintf(stderr, "\n");
if(!start)
if (!start)
start = loadaddress;
if(warm)
if (warm)
start = 0xFF69;
if(!loader) {
if (!loader) {
blank.track[0].sector[1].byte[0xE0] = ceil((filesize + (loadaddress & 0xFF)) / 256.0);
blank.track[0].sector[1].byte[0xE7] = ((loadaddress + filesize - 1) >> 8) + 1;
blank.track[0].sector[1].byte[0x15] = ceil((filesize + (loadaddress & 0xFF))/ 4096.0);
blank.track[0].sector[1].byte[0x1A] = ceil((filesize + (loadaddress & 0xFF))/ 256.0) - 16*(ceil((filesize + (loadaddress & 0xFF)) / 4096.0) - 1) - 1;
blank.track[0].sector[1].byte[0x15] = ceil((filesize + (loadaddress & 0xFF)) / 4096.0);
blank.track[0].sector[1].byte[0x1A] = ceil((filesize + (loadaddress & 0xFF)) / 256.0) - 16 * (ceil((filesize + (loadaddress & 0xFF)) / 4096.0) - 1) - 1;
fprintf(stderr,"Number of sectors: %d\n",(int)ceil((filesize + (loadaddress & 0xFF)) / 256.0));
fprintf(stderr,"Memory page range: $%02X - $%02X\n",loadaddress >> 8,(loadaddress + filesize - 1) >> 8);
fprintf(stderr, "Number of sectors: %d\n", (int) ceil((filesize + (loadaddress & 0xFF)) / 256.0));
fprintf(stderr, "Memory page range: $%02X - $%02X\n", loadaddress >> 8, (loadaddress + filesize - 1) >> 8);
blank.track[0].sector[1].byte[0x3B] = 0x4C;
blank.track[0].sector[1].byte[0x3C] = start & 0xFF;
blank.track[0].sector[1].byte[0x3D] = start >> 8;
fprintf(stderr,"After boot, jump to: $%04X\n\n",start);
fprintf(stderr, "After boot, jump to: $%04X\n\n", start);
fprintf(stderr,"Writing %s to T:01/S:00 - T:%02d/S:%02d on %s\n\n",filename,blank.track[0].sector[1].byte[0x15],blank.track[0].sector[1].byte[0x1A],OUTFILE);
}
else {
fprintf(stderr, "Writing %s to T:01/S:00 - T:%02d/S:%02d on %s\n\n", filename, blank.track[0].sector[1].byte[0x15], blank.track[0].sector[1].byte[0x1A], OUTFILE);
} else {
if ((ifp = fopen(textpage, "rb")) == NULL) {
fprintf(stderr,"Cannot read: %s\n\n",textpage);
fprintf(stderr, "Cannot read: %s\n\n", textpage);
return 1;
}
stat(textpage,&st);
stat(textpage, &st);
textpagesize = st.st_size;
if(textpagesize != 1024) {
fprintf(stderr,"textpage %s size %d != 1024\n\n",textpage,textpagesize);
if (textpagesize != 1024) {
fprintf(stderr, "textpage %s size %d != 1024\n\n", textpage, textpagesize);
return 1;
}
// check for errors
fread(&blank.track[1].sector[0].byte[0], textpagesize, 1, ifp);
fclose(ifp);
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];
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] = barcode[i];
}
// loader args
// lasttrack
blank.track[1].sector[4].byte[loadersize]=1 + (int)ceil(filesize / 4096.0);
// lastsector (unused)
blank.track[1].sector[4].byte[loadersize+1]= ceil((filesize % 4096) / 256.0) - 1;
blank.track[1].sector[4].byte[loadersize] = 1 + (int) ceil(filesize / 4096.0);
// lastsector
blank.track[1].sector[4].byte[loadersize + 1] = ceil((filesize % 4096) / 256.0) - 1;
// loadpage
blank.track[1].sector[4].byte[loadersize+2]= loadaddress >> 8;
blank.track[1].sector[4].byte[loadersize + 2] = loadaddress >> 8;
// program start LSB
blank.track[1].sector[4].byte[loadersize+3]= start & 0xFF;
blank.track[1].sector[4].byte[loadersize + 3] = start & 0xFF;
// program start MSB
blank.track[1].sector[4].byte[loadersize+4]= start >> 8;
blank.track[1].sector[4].byte[loadersize + 4] = start >> 8;
// gr mode
blank.track[1].sector[4].byte[loadersize + 5] = gr;
loaderstart=0x400;
loadersize += (1024 + 5); // textpage + loader + loader args
//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, rowaddr;
// bar row
blank.track[1].sector[4].byte[loadersize + 6] = row;
rowaddr = 0x400+(row/8)*0x28+((row%8)*0x80);
// program start LSB
blank.track[1].sector[4].byte[loadersize + 7] = rowaddr & 0xFF;
// program start MSB
blank.track[1].sector[4].byte[loadersize + 8] = rowaddr >> 8;
for(i = 1; i <= bar_length; i++)
blank.track[1].sector[4].byte[loadersize + 8 + i] = i * num_sectors / bar_length;
}
loaderstart = 0x800;
// temp hack to effect the sound of the drive, i.e. to make consistent
// longer term put binary payload at end of loader
// loadersize += (1024 + 5); // textpage + loader + loader args
loadersize = 4096;
blank.track[0].sector[1].byte[0xE0] = ceil((loadersize + (loaderstart & 0xFF)) / 256.0);
blank.track[0].sector[1].byte[0xE7] = ((loaderstart + loadersize - 1) >> 8) + 1;
blank.track[0].sector[1].byte[0x15] = ceil((loadersize + (loaderstart & 0xFF))/ 4096.0);
blank.track[0].sector[1].byte[0x1A] = ceil((loadersize + (loaderstart & 0xFF))/ 256.0) - 16*(ceil((loadersize + (loaderstart & 0xFF)) / 4096.0) - 1) - 1;
blank.track[0].sector[1].byte[0x15] = ceil((loadersize + (loaderstart & 0xFF)) / 4096.0);
blank.track[0].sector[1].byte[0x1A] = ceil((loadersize + (loaderstart & 0xFF)) / 256.0) - 16 * (ceil((loadersize + (loaderstart & 0xFF)) / 4096.0) - 1) - 1;
fprintf(stderr,"Loader number of sectors: %d\n",(int)ceil((loadersize + (loaderstart & 0xFF)) / 256.0));
fprintf(stderr,"Loader memory page range: $%02X - $%02X\n",loaderstart >> 8,(loaderstart + loadersize - 1) >> 8);
fprintf(stderr,"Binary Number of sectors: %d\n",(int)ceil((filesize + (loadaddress & 0xFF)) / 256.0));
fprintf(stderr,"Binary Memory page range: $%02X - $%02X\n",loadaddress >> 8,(loadaddress + filesize - 1) >> 8);
fprintf(stderr, "Loader number of sectors: %d\n", (int) ceil((loadersize + (loaderstart & 0xFF)) / 256.0));
fprintf(stderr, "Loader memory page range: $%02X - $%02X\n", loaderstart >> 8, (loaderstart + loadersize - 1) >> 8);
fprintf(stderr, "After loader, jump to: $%04X\n", start);
fprintf(stderr, "Binary Number of sectors: %d\n", (int) ceil((filesize + (loadaddress & 0xFF)) / 256.0));
fprintf(stderr, "Binary Memory page range: $%02X - $%02X\n", loadaddress >> 8, (loadaddress + filesize - 1) >> 8);
loaderstart = 0x800;
//if(warm)
// loaderstart = 0xFF69;
loaderstart = 0xC00;
blank.track[0].sector[1].byte[0x3B] = 0x4C;
blank.track[0].sector[1].byte[0x3C] = loaderstart & 0xFF;
blank.track[0].sector[1].byte[0x3D] = loaderstart >> 8;
fprintf(stderr,"After boot, jump to: $%04X\n",loaderstart);
fprintf(stderr,"After loader, jump to: $%04X\n",start);
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, "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[loaderbasesize + 1], OUTFILE);
}
if ((ofp = fopen(OUTFILE, "wb")) == NULL) {
fprintf(stderr,"Cannot write: %s\n\n",OUTFILE);
fprintf(stderr, "Cannot write: %s\n\n", OUTFILE);
return 1;
}
// check for errors
fwrite(&blank, 143360, 1, ofp);
@ -289,28 +326,27 @@ char *getext(char *filename)
char stack[256], *rval;
int i, sp = 0;
for(i=strlen(filename)-1;i>=0;i--) {
if(filename[i] == '.')
for (i = strlen(filename) - 1; i >= 0; i--) {
if (filename[i] == '.')
break;
stack[sp++] = filename[i];
}
stack[sp] = '\0';
if(sp == strlen(filename) || sp == 0)
return(NULL);
if (sp == strlen(filename) || sp == 0)
return (NULL);
if((rval = (char *)malloc(sp * sizeof(char))) == NULL)
; //do error code
if ((rval = (char *) malloc(sp * sizeof(char))) == NULL)
; //do error code
rval[sp] = '\0';
for(i=0;i<sp+i;i++)
for (i = 0; i < sp + i; i++)
rval[i] = stack[--sp];
return(rval);
return (rval);
}
void usage()
void usage(void)
{
fprintf(stderr,"%s",usagetext);
fprintf(stderr, "%s", usagetext);
}

13
c2d.h.0
View File

@ -13,13 +13,16 @@ typedef struct d {
const char *usagetext="\n\
usage: c2d [-vh?]\n\
c2d [-m] [-s start address override] input[.mon],[load_address] output.dsk\n\
c2d [-bgm] [-r row] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk\n\
\n\
-h|? this help\n\
-m jump to monitor after booting\n\
-s XXXX jump to XXXX after booting\n\
-t filename where filename is a 1K $400-$7FF text page splash screen.\n\
The splash screen will display while the binary is loading.\n\
-t filename, where filename is a 1K $400-$7FF text page splash screen\n\
The splash screen will display while the binary is loading\n\
-b animated loading bar\n\
-g splash page is mixed mode GR\n\
-r override row default of 19 with 'row'\n\
-v print version number and exit\n\
\n\
Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\
@ -9002,8 +9005,8 @@ disk blank = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x68,0x74,0x74,0x70,0x73,0x3a,0x2f,0x2f,0x67,0x69,0x74,0x68,0x75,0x62,0x2e,0x63,
0x6f,0x6d,0x2f,0x64,0x61,0x74,0x61,0x6a,0x65,0x72,0x6b,0x2f,0x63,0x32,0x64,0x2f
};

4
dwine Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -x
docker run --rm -it -v $PWD:/pwd wine32 bash -c "cd /pwd && sleep 1 && wine $*"

Binary file not shown.

4104
gameserverclient.mon Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,24 @@
___ __ ______
/ | ____ ____ / /__ / / _/
/ /| | / __ \/ __ \/ / _ \ / / /
/ ___ |/ /_/ / /_/ / / __/ / / /
/_/ |_/ .___/ .___/_/\___/ _/ / /
/_/ /_/ /__/__/
______
/ ____/___ _____ ___ ___
/ / __/ __ `/ __ `__ \/ _ \
/ /_/ / /_/ / / / / / / __/
\____/\__,_/_/ /_/ /_/\___/
_____
/ ___/___ ______ _____ _____
\__ \/ _ \/ ___/ | / / _ \/ ___/
___/ / __/ / | |/ / __/ /
/____/\___/_/ |___/\___/_/
_________ __
/ ____/ (_)__ ____ / /_
/ / / / / _ \/ __ \/ __/
/ /___/ / / __/ / / / /_
\____/_/_/\___/_/ /_/\__/
____ ___
/ __ \____ / (_)___ ___
/ / / / __ \/ / / __ \/ _ \
/ /_/ / / / / / / / / / __/
\____/_/ /_/_/_/_/ /_/\___/
____ ___ __
/ __ \____ / (_)___ ___ / /
/ / / / __ \/ / / __ \/ _ \/ /
/ /_/ / / / / / / / / / __/_/
\____/_/ /_/_/_/_/ /_/\___(_)
THE APPLE ][ AE WARESHOLE IS BACK!
CASSETTE PORT FTW! ---- ASCIIEXPRESS.NET

Binary file not shown.

BIN
gameserverclient.tiff Normal file

Binary file not shown.

BIN
gameserverclientsplash.tiff Normal file

Binary file not shown.

View File

@ -1,43 +1,19 @@
#!/bin/bash
header()
{
FILE=$1
VAR=$2
EOL=$3
BYTES=$(hexdump -v $FILE | sed 's/^.......//' | wc -w | awk '{print $1}');
echo "/*"
expand ${FILE}.s
echo "*/"
printf "unsigned char $VAR[] = {\n\t"
for i in $(hexdump -v $FILE | sed 's/^.......//');
do
printf "0x%02X" 0x$i
BYTES=$((BYTES - 1))
if ((BYTES != 0))
then
printf ","
fi
EOL=$((EOL - 1))
if ((EOL == 0))
then
EOL=8
printf "\n\t"
fi
done
printf "\n};\n"
}
cd asm
make clean
make
PATH=../cc65-2.13.3/bin:$PATH make
(
header loader loadercode 8
echo "/*"
expand loader.s
echo "*/"
/usr/bin/xxd -i loader | sed 's/loader/loadercode/'
echo "/*"
expand bar.s
echo "*/"
/usr/bin/xxd -i bar | sed 's/bar/barcode/'
) > ../c2d.h.1
cd ..

94
mandelbrotgr.c Normal file
View File

@ -0,0 +1,94 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <strings.h>
#define MAX 15
#define NORMAL 0x80
// unsigned char colors[16] = { 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0 };
// chanage order and number of colors for different output
// default palette
// unsigned char colors[15] = { 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0 };
// redish
// unsigned char colors[15] = { 0xB, 0x3, 0x1, 0x9, 0xD, 0xE, 0xB, 0x4, 0x7, 0x6, 0x2, 0xA, 0x5, 0x8, 0x0 };
// blueish
unsigned char colors[15] = { 0x2, 0x6, 0x7, 0xE, 0xC, 0x4, 0xD, 0x9, 0xB, 0x3, 0x1, 0xA, 0x5, 0x8, 0x0 };
const char text[4][41] = {
"EXAMPLE GR/TEXT SPLASH SCREEN",
"LOADING GAME SERVER CLIENT...",
"________________________________________",
"________________________________________",
};
int main(int argc, char **argv)
{
int c, r, i, j, k, line = 0;
double xd, yd, x0, y0, x, y, xt;
unsigned char screen[24][40];
// clear screen to zeros
for (i = 0; i < 24; i++)
for (j = 0; j < 40; j++)
screen[i][j] = 0x00;
c = 40;
r = 40;
xd = (1.0 - -2.5) / (double) c; // size of x pixel
yd = (1.0 - -1.0) / (double) r; // size of y pixel
// 39 rows, set i = 1
for (i = 1; i < r; i++) {
// gr text page translation
// 40 row
// line = 3 * ((i / 2) % 8) + i / 16;
// 39 row
line = 3 * (((i - 1) / 2) % 8) + (i - 1) / 16;
y0 = 1 - i * yd;
for (j = 0; j < c; j++) {
x0 = -2.5 + j * xd;
k = x = y = 0;
while (x * x + y * y <= 4 && k < MAX) {
xt = x * x - y * y + x0;
y = 2 * x * y + y0;
x = xt;
k++;
}
// 39 row
screen[line][j] |= (colors[(k - 1) / (MAX / sizeof(colors))] << 4 * (i % 2 == 0));
// 40 row
//screen[line][j] |= (colors[(k - 1) / (MAX / sizeof(colors))] << 4 * (i % 2));
}
}
// clear text lines with spaces
for (i = 20; i < 24; i++) {
line = 3 * (i % 8) + i / 8;
for (j = 0; j < 40; j++)
screen[line][j] = ' ' | NORMAL;
}
for (i = 0; i < 4; i++) {
line = 3 * ((i + 20) % 8) + (i + 20) / 8;
for (j = 0; j < 20 - strlen(text[i]) / 2; j++)
screen[line][j] = ' ' | NORMAL; // text rows
for (k = 0; k < strlen(text[i]); k++)
screen[line][j++] = text[i][k] | NORMAL;
}
// dump to stdout
for (i = 0; i < 24; i++) {
for (j = 0; j < 40; j++)
putchar(screen[i][j]);
if (i % 3 == 2)
for (k = 0; k < 8; k++)
putchar(0x0);
}
return 0;
}

32
page2text.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#define MASK 0x7F
int main(int argc, char **argv)
{
int i, j, k, line;
char screen[24][40];
// clear screen (just in case partial dump)
for (i = 0; i < 24; i++)
for (j = 0; j < 40; j++)
screen[i][j] = ' ';
for (i = 0; i < 24; i++) {
line = 8 * (i % 3) + i / 3;
for (j = 0; j < 40; j++)
screen[line][j] = getchar() & MASK;
if (i % 3 == 2)
for (k = 0; k < 8; k++)
getchar();
}
// dump to stdout
for (i = 0; i < 24; i++) {
for (j = 0; j < 40; j++)
putchar(screen[i][j]);
printf("\n");
}
return 0;
}

47
test.scrp Normal file
View File

@ -0,0 +1,47 @@
on run argv
set my_path to (system attribute "PWD") & "/"
set my_disk to item 1 of argv
set my_done1 to item 2 of argv
set my_done2 to item 3 of argv
set my_timeout1 to item 4 of argv
set my_timeout2 to item 5 of argv
tell application "Virtual ]["
activate
-- may need delay for this error: execution error: Virtual ][ got an error: Connection is invalid. (-609)
delay 1.5
-- Close all open machines
close every machine saving no
-- Create a new (AppleIIe)
set theMachine to (make new AppleIIe)
tell theMachine
-- Change to a color screen
set monochrome screen to false
set scanlines to true
set speaker volume to 0.25
insert my_path & my_disk into device "S6D1"
try
with timeout of my_timeout1 seconds
waiting until screen equals imagefile POSIX path of (my_path & my_done1)
end timeout
on error
return "ERROR: TIMEOUT: Virtual ][ screen != " & my_done1
end try
try
with timeout of my_timeout2 seconds
waiting until screen equals imagefile POSIX path of (my_path & my_done2)
end timeout
on error
return "ERROR: TIMEOUT: Virtual ][ screen != " & my_done2
end try
end tell
delay 0.5
close every machine saving no
quit
end tell
end run

180
test.sh
View File

@ -2,74 +2,196 @@
set -e
PATH=bin:$PATH
BIN=gameserverclient
ADDR=800
SUM=898ebb103fdda6fffe62394c1b915d1d
SUM=3226e0aa8f35ee23a9de9b8f05abf688
rm -f ${BIN}.dsk
echo
echo "Testing OS/X c2d..."
echo
echo "bin/c2d ${BIN},${ADDR} ${BIN}.dsk"
bin/c2d ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
echo "c2d ${BIN},${ADDR} ${BIN}.dsk"
c2d ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo FAILED
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d..."
echo
PATH=$HOME/wine/bin:$PATH
echo "wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk"
wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
if ((EMU == 1))
then
echo
echo -n "Emulator Test..."
if ! OUTPUT=$(osascript test.scrp gameserverclient.dsk gameserverclient.tiff gameserverclient.tiff 15 15)
then
echo FAILED
exit 1
fi
if echo $OUTPUT | grep ERROR >/dev/null 2>&1
then
echo FAILED
echo $OUTPUT
echo
exit 1
fi
echo PASSED
else
echo FAILED
exit 1
fi
SUM=aaed7ee47fde72a69435d146f01301f4
if ((WIN == 1))
then
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d..."
echo
echo "./dwine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk"
./dwine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
fi
SUM=56a52e40a2351ff39669efa3fbdd0f19
rm -f ${BIN}.dsk
echo
echo "Testing OS/X c2d textpage..."
echo
echo "bin/text2page <${BIN}.text >${BIN}.textpage"
bin/text2page <${BIN}.text >${BIN}.textpage
echo "bin/c2d -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
bin/c2d -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
echo "text2page <${BIN}.text | page2text | text2page >${BIN}.textpage"
text2page <${BIN}.text | page2text | text2page >${BIN}.textpage
echo "c2d -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
c2d -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo FAILED
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
if ((EMU == 1))
then
echo
echo -n "Emulator Test..."
if ! OUTPUT=$(osascript test.scrp gameserverclient.dsk gameserverclientsplash.tiff gameserverclient.tiff 15 15)
then
echo FAILED
exit 1
fi
if echo $OUTPUT | grep ERROR >/dev/null 2>&1
then
echo FAILED
echo $OUTPUT
echo
exit 1
fi
echo PASSED
fi
if ((WIN == 1))
then
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d textpage..."
echo
echo "./dwine bin/text2page.exe <${BIN}.text >${BIN}.textpage"
./dwine bin/text2page.exe '<'${BIN}.text '>'${BIN}.textpage
echo "./dwine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
./dwine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
fi
BIN=gameserverclient
MON=gameserverclient.mon
ADDR=800
SUM=3226e0aa8f35ee23a9de9b8f05abf688
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d textpage..."
echo "Testing OS/X c2d..."
echo
PATH=$HOME/wine/bin:$PATH
echo "wine bin/text2page.exe <${BIN}.text >${BIN}.textpage"
wine bin/text2page.exe <${BIN}.text >${BIN}.textpage
echo "wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
echo "c2d ${MON} ${BIN}.dsk"
c2d ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo FAILED
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
if ((WIN == 1))
then
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d..."
echo
echo "./dwine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk"
./dwine bin/c2d.exe ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
fi
SUM=56a52e40a2351ff39669efa3fbdd0f19
rm -f ${BIN}.dsk
echo
echo "Testing OS/X c2d textpage..."
echo
echo "text2page <${BIN}.text >${BIN}.textpage"
text2page <${BIN}.text >${BIN}.textpage
echo "c2d -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
c2d -t ${BIN}.textpage ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
if ((WIN == 1))
then
rm -f ${BIN}.dsk
echo
echo "Testing Windows c2d textpage..."
echo
echo "./dwine bin/text2page.exe <${BIN}.text >${BIN}.textpage"
./dwine bin/text2page.exe '<'${BIN}.text '>'${BIN}.textpage
echo "./dwine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk"
./dwine bin/c2d.exe -t ${BIN}.textpage ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /'
CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}')
if [ "$CHECK" = "$SUM" ]
then
echo PASSED
else
echo "FAILED $CHECK != $SUM (expected)"
exit 1
fi
fi
echo

View File

@ -1,59 +1,44 @@
#include <stdio.h>
unsigned char holes[] = {
0x37,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0xff,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0x17,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
0xff,0xff,0x00,0xd0,0xff,0xff,0x00,0x00,
0xc6,0xff,0x00,0x07,0xff,0xff,0x00,0x00
};
#define NORMAL 0x80
#define BLINK 0x40
int main()
int main(int argc, char **argv)
{
char c, highbit = 0x80;
int i, j, k, columns = 0, lines = 0, linemap[24];
char c;
int i, j, k, line = 0;
unsigned char screen[24][40];
// build table
for(j=0,i=0;i<8;i++) {
linemap[ 0 + j]=0+3*j;
linemap[ 8 + j]=1+3*j;
linemap[16 + j]=2+3*j;
j++;
}
// clear screen (just in case < 40x24)
for (i = 0; i < 24; i++)
for (j = 0; j < 40; j++)
screen[i][j] = ' ' | NORMAL;
// clear screen
for(i=0;i<24;i++)
for(j=0;j<40;j++)
screen[linemap[i]][j] = ' ' | highbit;
while((c = getchar()) != EOF) {
if(c == '\r') // windows trash
i = j = 0;
while ((c = getchar()) != EOF) {
if (c == '\r') // windows trash
continue;
if(columns > 40) // user didn't read the docs
continue;
if(lines > 24) // ditto
break;
if(c == '\n') { // end of line
columns=0;
lines++;
if (c == '\n') { // end of line
j = 0;
i++;
line = 3 * (i % 8) + i / 8;
continue;
}
if (j > 39) // user didn't read the docs
continue;
if (i > 23) // ditto
break;
screen[linemap[lines]][columns] = c | highbit;
columns++;
screen[line][j++] = c | NORMAL;
}
// dump to stdout
for(i=0;i<24;i++) {
for(j=0;j<40;j++)
for (i = 0; i < 24; i++) {
for (j = 0; j < 40; j++)
putchar(screen[i][j]);
if((i + 1) % 3 == 0)
for(k=0;k<8;k++)
putchar(holes[(i/3)*8+k]);
if (i % 3 == 2)
for (k = 0; k < 8; k++)
putchar(0x0);
}
return 0;