C64 Graphics and CX16 versions

Made the old C64 version C64.chr and created a new graphical interface version for the C64 and the Commander X16.  Also changed the Oric to be called the atmos since that works better with the build system.
This commit is contained in:
StewBC 2020-05-25 18:20:37 -07:00
parent 78187953ff
commit c08a759404
26 changed files with 3041 additions and 70 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.vscode/
/obj/
/Makefile.options
/cc65-chess.*

View File

@ -9,7 +9,7 @@
# Space or comma separated list of cc65 supported target platforms to build for.
# Default: c64 (lowercase!)
TARGETS := c64 apple2 oric
TARGETS := apple2 atmos c64 c64.chr cx16
# Name of the final, single-file executable.
# Default: name of the current dir with target name appended
@ -52,18 +52,21 @@ EMUCMD :=
# Optional commands used before starting the emulation process, and after finishing it.
# Default: none
#PREEMUCMD := osascript -e "tell application \"System Events\" to set isRunning to (name of processes) contains \"X11.bin\"" -e "if isRunning is true then tell application \"X11\" to activate"
#PREEMUCMD := osascript -e "tell application \"X11\" to activate"
#POSTEMUCMD := osascript -e "tell application \"System Events\" to tell process \"X11\" to set visible to false"
#POSTEMUCMD := osascript -e "tell application \"Terminal\" to activate"
#PREEMUCMD := osascript -e "tell application /"System Events/" to set isRunning to (name of processes) contains /"X11.bin/"" -e "if isRunning is true then tell application /"X11/" to activate"
#PREEMUCMD := osascript -e "tell application /"X11/" to activate"
#POSTEMUCMD := osascript -e "tell application /"System Events/" to tell process /"X11/" to set visible to false"
#POSTEMUCMD := osascript -e "tell application /"Terminal/" to activate"
PREEMUCMD :=
POSTEMUCMD :=
# On Windows machines VICE emulators may not be available in the PATH by default.
# In such case, please set the variable below to point to directory containing
# VICE emulators.
#VICE_HOME := "C:\Program Files\WinVICE-2.2-x86\"
VICE_HOME :=
#VICE_HOME := "C:/Program Files/WinVICE-2.2-x86/"
VICE_HOME :=
CX16_HOME :=
AWIN_HOME :=
ORIC_HOME :=
# Options state file name. You should not need to change this, but for those
# rare cases when you feel you really need to name it differently - here you are
@ -143,17 +146,9 @@ ifeq ($(OBJDIR),)
endif
TARGETOBJDIR := $(OBJDIR)/$(TARGETS)
# On Windows it is mandatory to have CC65_HOME set. So do not unnecessarily
# rely on cl65 being added to the PATH in this scenario.
ifdef CC65_HOME
CC := $(CC65_HOME)/bin/cl65
else
CC := cl65
endif
# Default emulator commands and options for particular targets.
# Set EMUCMD to override.
c64_EMUCMD := $(VICE_HOME)x64 -kernal kernal -VICIIdsize -autoload
c64_EMUCMD := $(VICE_HOME)x64 -kernal kernal -VICIIdsize -autostart
c128_EMUCMD := $(VICE_HOME)x128 -kernal kernal -VICIIdsize -autoload
vic20_EMUCMD := $(VICE_HOME)xvic -kernal kernal -VICdsize -autoload
pet_EMUCMD := $(VICE_HOME)xpet -Crtcdsize -autoload
@ -163,7 +158,9 @@ c16_EMUCMD := $(VICE_HOME)xplus4 -ramsize 16 -TEDdsize -autoload
cbm510_EMUCMD := $(VICE_HOME)xcbm2 -model 510 -VICIIdsize -autoload
cbm610_EMUCMD := $(VICE_HOME)xcbm2 -model 610 -Crtcdsize -autoload
atari_EMUCMD := atari800 -windowed -xl -pal -nopatchall -run
apple2_EMUCMD :=
cx16_EMUCMD := $(CX16_HOME)x16emu -run -prg
apple2_EMUCMD := $(AWIN_HOME)AppleWin.exe -d1
atmos_EMUCMD := $(ORIC_HOME)Oricutron.exe -t
ifeq ($(EMUCMD),)
EMUCMD = $($(CC65TARGET)_EMUCMD)
@ -175,10 +172,10 @@ endif
# The "Native Win32" GNU Make contains quite some workarounds to get along with
# cmd.exe as shell. However it does not provide means to determine that it does
# actually activate those workarounds. Especially does $(SHELL) NOT contain the
# actually activate those workarounds. Especially $(SHELL) does NOT contain the
# value 'cmd.exe'. So the usual way to determine if cmd.exe is being used is to
# execute the command 'echo' without any parameters. Only cmd.exe will return a
# non-empy string - saying 'ECHO is on/off'.
# non-empty string - saying 'ECHO is on/off'.
#
# Many "Native Win32" programs accept '/' as directory delimiter just fine. How-
# ever the internal commands of cmd.exe generally require '\' to be used.
@ -291,25 +288,25 @@ $(TARGETOBJDIR):
vpath %.c $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.c | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $<
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(CFLAGS) -o $@ $<
vpath %.s $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.s | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
vpath %.asm $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.asm | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
vpath %.a65 $(SRCDIR)/$(TARGETLIST) $(SRCDIR)
$(TARGETOBJDIR)/%.o: %.a65 | $(TARGETOBJDIR)
$(CC) -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
cl65 -t $(CC65TARGET) -c --create-dep $(@:.o=.d) $(ASFLAGS) -o $@ $<
$(PROGRAM): $(CONFIG) $(OBJECTS) $(LIBS)
$(CC) -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^)
cl65 -t $(CC65TARGET) $(LDFLAGS) -o $@ $(patsubst %.cfg,-C %.cfg,$^)
test: $(PROGRAM)
$(PREEMUCMD)

16
Makefile-cprg.mk Normal file
View File

@ -0,0 +1,16 @@
CPRG = cc65-Chess-chr.prg
# Unix or Windows
ifeq ($(shell echo),)
CP = cp $1
else
CP = copy $(subst /,\,$1)
endif
REMOVES += $(CPRG)
.PHONY: cprg
cprg: $(CPRG)
$(CPRG): cc65-chess.c64.chr
$(call CP, $< $@)

16
Makefile-cxprg.mk Normal file
View File

@ -0,0 +1,16 @@
CXPRG = cc65-Chess-cx16.prg
# Unix or Windows
ifeq ($(shell echo),)
CP = cp $1
else
CP = copy $(subst /,\,$1)
endif
REMOVES += $(CXPRG)
.PHONY: cxprg
cxprg: $(CXPRG)
$(CXPRG): cc65-chess.cx16
$(call CP, $< $@)

16
Makefile-prg.mk Normal file
View File

@ -0,0 +1,16 @@
PRG = cc65-Chess-c64.prg
# Unix or Windows
ifeq ($(shell echo),)
CP = cp $1
else
CP = copy $(subst /,\,$1)
endif
REMOVES += $(PRG)
.PHONY: prg
prg: $(PRG)
$(PRG): cc65-chess.c64
$(call CP, $< $@)

View File

@ -12,5 +12,5 @@ REMOVES += $(TAP)
.PHONY: tap
tap: $(TAP)
$(TAP): cc65-chess.oric
$(TAP): cc65-chess.atmos
$(call CP, $< $@)

View File

@ -1,10 +1,11 @@
0. Updates
May 2020 - [raxiss] created a nice Oric-1/Atmos/Telestrat port. See X below.
Jan 2020 - Oliver Schmidt created a beautiful Apple II port. See IX below.
There is a Commodore 64 .PRG and an Apple II .DSK file in the release tab.
* May 2020 - Advanced Build instructions at XI.
* May 2020 - I created a version for the Commander X16 (R37).
* May 2020 - I created a graphics version for the C64.
* May 2020 - [raxiss] created a nice Oric-1/Atmos/Telestrat port.
* Jan 2020 - Oliver Schmidt created a beautiful Apple II port. See IX below.
* There are images for all platforms in the releases tab.
I. Introduction (Feb 14, 2014)
@ -252,45 +253,78 @@ Oliver Schmidt
Jan 19, 2020
X. Apple II Build Instructions
XI. Build Instructions
To build the Apple II version use the make command line:
make TARGETS=apple2 OPTIONS=optspeed
The OPTIONS=optspeed will be remembered and need only be given once.
All of the 8-Bit versions of cc65 Chess can be built using make.
To make the disc image, set an environment variable to point at apple commander
(see notes) and then use the command:
make TARGETS=apple2 dsk
I recommend the game be built for speed, which also results in smaller file and
is essential for all targets. This is done by using the OPTIONS=optspeed
command line to make. See examples below.
If you want to edit the code and get into some iterative development/testing,
you can edit the Makefile and fill in the commands commands neccesary to launch
an emulator as well. Look for apple2_EMUCMD and set that as neccesary. The
simplest is to call test.sh or test.bat and fill in a complete command in the
batch file or shell script. However you choose to do this, once done, you can
do everything with the command:
make TARGETS=apple2 dsk test
When you type make (using GNU Make) the default behaviour is to make all of the
versions. Currently, that means the following (cc65 target name in brackets):
You could also edit the Makefile and change the line TARGETS := c64 apple2 to
include only the apple2 in which case you can omit the TARGETS=apple2 part form
all make commands.
* Commodore 64 HiRes (c64)
* Commodore 64 Multicolor Text (c64.chr)
* Apple 2 (apple2)
* Oric-1/Atmos/Telestrat (atmos)
* Commander X16 (cx16)
NOTES:
1) Find AppleCommander here (I used Version 1.5.0):
https://github.com/AppleCommander/AppleCommander/releases
2) Set the environment variable (or change the Makefile-dsk.md) to point at the
apple commander jar file. Here's how it's done for different shell's:
Powershell:
$env:AC = "path to apple commander.jar"
cmd.exe
set AC="path to apple commander.jar"
bash (Unix or macOS terminal):
export AC="path to apple commander.jar"
Most platforms have an additional step that can be performed, which is to make a
program (prg), disk (dsk) or tape (tap) file. Do make again, but with dsk
(Apple 2 dsk), tap (Oric tape), prg (C64 prg), cprg (c64.chr prg) or cxprg (cX16
prg) on the command line.
XI. Oric Build Instructions
To build the Oric-1/Atmos/Telestrat version set the environment variable CC65_HOME
with the path to the base cc65 directory i.e: export CC65_HOME=${HOME}/cc65
The two steps can be combined into a single make command, by using "all" as the
first target, i.e:
make OPTIONS=optspeed all dsk tap prg cprg cxprg
and use the make command line:
make TARGETS=oric CC65TARGET=atmos OPTIONS=optspeed tap
Makeing a terminal version (using curses) - See IV (b) above.
This will create a ready to run TAP file: cc65-Chess.tap
Examples:
1) Make everything, and then make the dsk and tap files for the Apple and Oric.
make OPTIONS=optspeed
This will make the following files:
cc65-Chess.apple2
cc65-Chess.atmos
cc65-Chess.c64
cc65-Chess.c64.chr
cc65-Chess.cx16
make dsk tap prg cprg cxprg
This will make the following files:
cc65-Chess.tap
cc65-Chess.dsk
cc65-Chess-c64.prg
cc65-Chess-chr.prg
cc65-Chess-cx16.prg
Once you have used the OPTIONS=optspeed on the command-line, you do not have to
use it again since the options are saved in a file called Makefile.options.
2) Build just one version (let's say the Oric)
make OPTIONS=optspeed TARGETS=atmos tap
This will create a ready to run TAP file named cc65-Chess.tap
3) You can also start an emulator directly from make with the test command-line.
make OPTIONS=optspeed atmos test
This last command example is a good way of callimg make to build and test any of
the targets by itself, provided you have configured an emulator in the Makefile.
In this case, it will call the emulator with cc65-Chess.atmos but Oricutron
doesn't mind that the exytension isn't .tap.
Look for _EMUCMD in the Makefile. You may have to specify a full path to the
emulator, and in some cases you may need to change the test: command itself. For
example, to run AppleWin I removed the $< from $(EMUCMD) $< in the test:
section, because AppleWin did not like the extra (cc64-Chess.apple2) file being
passed, and I had to give it the full path to cc64-Chess.dsk as part of apple2_EMUCMD.
Lastly - the CX16 and C64 versions use the same piece defenitions that Oliver
Schmidt added for the Apple II, and kindly agreed to let me use for these
versions as well. See genPieces.cpp in the specific src folder for more details.

View File

@ -1,5 +1,5 @@
/*
* data.c
* dataC64CHR.c
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.
@ -7,7 +7,7 @@
*/
#include "../types.h"
#include "data.h"
#include "dataC64CHR.h"
/*-----------------------------------------------------------------------*/
// C64 specific graphics for the chess pieces

View File

@ -1,5 +1,5 @@
/*
* data.h
* dataC64CHR.h
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.

View File

@ -1,5 +1,5 @@
/*
* plat64.c
* platC64CHR.c
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.
@ -14,7 +14,7 @@
#include "../undo.h"
#include "../frontend.h"
#include "../plat.h"
#include "data.h"
#include "dataC64CHR.h"
/*-----------------------------------------------------------------------*/
// System locations

44
src/c64/chessC64.cfg Normal file
View File

@ -0,0 +1,44 @@
FEATURES {
STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
__EXEHDR__: type = import;
__STACKSIZE__: type = weak, value = $0800; # 2k stack
__HIMEM__: type = weak, value = $C000;
}
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__;
BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = HEADER, type = ro;
STARTUP: load = MAIN, type = ro;
LOWCODE: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = ro;
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
ONCE: load = MAIN, type = ro, define = yes;
BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
label = __CONSTRUCTOR_TABLE__,
count = __CONSTRUCTOR_COUNT__,
segment = ONCE;
CONDES: type = destructor,
label = __DESTRUCTOR_TABLE__,
count = __DESTRUCTOR_COUNT__,
segment = RODATA;
CONDES: type = interruptor,
label = __INTERRUPTOR_TABLE__,
count = __INTERRUPTOR_COUNT__,
segment = RODATA,
import = __CALLIRQ__;
}

202
src/c64/dataC64.c Normal file
View File

@ -0,0 +1,202 @@
/*
* dataC64.c
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.
*
*/
#include "../types.h"
#include "dataC64.h"
/*-----------------------------------------------------------------------*/
// C64 specific graphics for the chess pieces
// The comment shows an icon 16x24
// The data is 24 chars & 24 chars (2 * 8x24). The second set of 24
// is the right-hand side 8-bits of the icon
// 96 = 4 cols * 3 rows * 8 byte / col
const char gfxTiles[PAWN][2][96] =
{
{
{
0x00, 0x00, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02,
0x00, 0x00, 0x00, 0xC7, 0x44, 0x44, 0x7C, 0x00,
0x00, 0x00, 0x00, 0xC7, 0x44, 0x44, 0x7C, 0x00,
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x5F, 0x60, 0x20, 0x20, 0x20, 0x20,
0x01, 0x02, 0xF4, 0x0C, 0x08, 0x08, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00,
0x20, 0x40, 0x80, 0xBF, 0x00, 0xFF, 0xFF, 0x00,
0x08, 0x04, 0x02, 0xFA, 0x01, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00,
},
{
0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03,
0x00, 0x00, 0x00, 0xC7, 0xC7, 0xC7, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0xC7, 0xC7, 0xC7, 0xFF, 0xFF,
0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0x7F, 0x40, 0x3F, 0x3F, 0x3F, 0x3F,
0xFF, 0xFE, 0xFC, 0x04, 0xF8, 0xF8, 0xF8, 0xF8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x00,
0x3F, 0x7F, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0xF8, 0xFC, 0xFE, 0xFE, 0x01, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00,
},
},
{
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x15, 0x21, 0x20, 0x40,
0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00,
0x44, 0x40, 0x80, 0x00, 0x00, 0x1E, 0x21, 0xC2,
0x28, 0x28, 0x34, 0x14, 0x04, 0x04, 0x16, 0x1A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x08, 0x10, 0x20, 0x5F, 0x40, 0x7F, 0x00,
0x09, 0x05, 0x01, 0x00, 0xFE, 0x00, 0xFF, 0x00,
0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x15, 0x3E, 0x3F, 0x7F,
0x00, 0x00, 0x00, 0x80, 0x40, 0xE0, 0xF0, 0xF8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00,
0x7B, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0xC3,
0xD8, 0xD8, 0xCC, 0xEC, 0xFC, 0xFC, 0xEE, 0xE6,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x0F, 0x1F, 0x3F, 0x40, 0x7F, 0x7F, 0x00,
0xF7, 0xFB, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
},
},
{
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x08, 0x11,
0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x2F, 0x41, 0x41, 0x41, 0x21, 0x20, 0x10,
0x08, 0xE8, 0x04, 0x04, 0x04, 0x08, 0x08, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x0F, 0x08, 0x08, 0x07, 0x20, 0xFF, 0xFF, 0x00,
0xE0, 0x20, 0x20, 0xC0, 0x08, 0xFE, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0F, 0x1E,
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x3E, 0x30, 0x7E, 0x7E, 0x7E, 0x3E, 0x3F, 0x1F,
0xF8, 0x18, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x08, 0x0F, 0x0F, 0x07, 0x3F, 0x80, 0xFF, 0x00,
0x20, 0xE0, 0xE0, 0xC0, 0xF8, 0x02, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
{
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0xE4, 0x12,
0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x4E, 0x91,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00,
0x14, 0x28, 0x00, 0x21, 0x33, 0x1F, 0x0F, 0x80,
0x50, 0x28, 0x00, 0x08, 0x98, 0xF1, 0xE1, 0x02,
0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0xBF, 0x40, 0x40, 0x40, 0x60, 0x3F, 0x00,
0x02, 0xFA, 0x04, 0x04, 0x04, 0x0C, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0xE7, 0xF3,
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xCE, 0x9F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00,
0xF7, 0xEF, 0xFF, 0xDE, 0xCC, 0xE0, 0xF0, 0xFF,
0xDF, 0xEF, 0xFF, 0xF7, 0x67, 0x0F, 0x1F, 0xFE,
0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xC0, 0x7F, 0x7F, 0x7F, 0x7F, 0x3F, 0x00,
0xFE, 0x06, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
{
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x02, 0x0E, 0x0C, 0x32,
0x00, 0x00, 0x00, 0x80, 0x80, 0xE0, 0x60, 0x98,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01,
0x4A, 0x86, 0x02, 0x24, 0x42, 0x41, 0x21, 0x10,
0xA4, 0xC2, 0x81, 0x49, 0x84, 0x04, 0x08, 0x11,
0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x80, 0x9F, 0x40, 0x40, 0x60, 0x3F, 0x00,
0x21, 0x02, 0xF2, 0x04, 0x04, 0x0C, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x02, 0x0E, 0x0C, 0x32,
0x00, 0x00, 0x00, 0x80, 0x80, 0xE0, 0x60, 0x98,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01,
0x7A, 0xFE, 0xFC, 0xDA, 0xBC, 0xBE, 0xDF, 0xEF,
0xBC, 0xFE, 0x7F, 0xB7, 0x7B, 0xFB, 0xF7, 0xEF,
0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF7, 0xFF, 0xC0, 0x7F, 0x7F, 0x7F, 0x3F, 0x00,
0xDF, 0xFE, 0x06, 0xFC, 0xFC, 0xFC, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
{
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x08, 0x08, 0x08, 0x04, 0x03, 0x04, 0x04,
0x40, 0x20, 0x20, 0x20, 0x40, 0x80, 0x40, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x04, 0x04, 0x0F, 0x10, 0x3F, 0x3F, 0x00,
0x60, 0x40, 0x40, 0xE0, 0x10, 0xF8, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x07, 0x07,
0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0xC0, 0xC0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0F, 0x07, 0x07, 0x0F, 0x10, 0x3F, 0x3F, 0x00,
0xE0, 0xC0, 0xC0, 0xE0, 0x10, 0xF8, 0xF8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
},
};

14
src/c64/dataC64.h Normal file
View File

@ -0,0 +1,14 @@
/*
* dataC64.h
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.
*
*/
#ifndef _DATA_H_
#define _DATA_H_
extern const char gfxTiles[PAWN][2][96];
#endif //_DATA_H_

360
src/c64/genpieces.cpp Normal file
View File

@ -0,0 +1,360 @@
/*
* genPieces.cpp
* cc65 Chess
*
* Created by Oliver Schmidt, January 2020.
* Pieces designed by Frank Gebhart, 1980s.
* Modified for C64 by S. Wessels, May 2020.
*
*/
#include <fcntl.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include <memory.h>
char pieces[]=
" "
" "
" **** ***** **** "
" * * * * * * "
" * * * * * * "
" * ***** ***** * "
" * * "
" * * "
" * * "
" * ********* * "
" ** ** "
" * * "
" * * "
" * * "
" * * "
" * * "
" * * "
" * * "
" * *********** * "
" * * "
" ******************* "
" ******************* "
" "
" "
" "
" "
" **** ***** **** "
" **** ***** **** "
" **** ***** **** "
" ******************* "
" ******************* "
" ***************** "
" *************** "
" ************* "
" * * "
" *********** "
" *********** "
" *********** "
" *********** "
" *********** "
" ************* "
" *************** "
" *************** "
" * * "
" ******************* "
" ******************* "
" "
" "
" "
" "
" * * "
" * * * * "
" * * * "
" * * "
" * * "
" * * * * "
" * * * "
" * ** * "
" * * * "
" * * "
" * **** * "
" * * * * ** "
" ** * ** * "
" * * * "
" * * * "
" * ** "
" * * "
" * ************ * "
" * * "
" **************** "
" "
" "
" "
" "
" * * "
" * * * * "
" ***** *** "
" ********** "
" ************ "
" **** **** ** "
" ********* ** "
" ********** ** "
" ************ ** "
" **************** "
" **************** "
" **** **** *** "
" ** ***** ** "
" ******* *** "
" ********* ** "
" ************** "
" *************** "
" * * "
" **************** "
" **************** "
" "
" "
" "
" "
" "
" *** "
" * * "
" * * "
" * * * "
" * * * "
" * ******* * "
" * * * "
" * * * "
" * * * "
" * * * "
" * * "
" * * "
" ******* "
" * * "
" * * "
" ***** "
" * * "
" *************** "
" ***************** "
" "
" "
" "
" "
" "
" *** "
" ***** "
" ******* "
" **** **** "
" ***** ***** "
" ** ** "
" ****** ****** "
" ****** ****** "
" ****** ****** "
" ***** ***** "
" *********** "
" ********* "
" * * "
" ******* "
" ******* "
" ***** "
" *********** "
" * * "
" ***************** "
" "
" "
" "
" "
" "
" *** "
" * * "
" *** * * *** "
" * * * * * * "
" * * * * * * "
" * * * * * * "
" * * "
" * * * * * "
" * ** *** ** * "
" * ********* * "
" * ******* * "
" * * "
" * * "
" * *********** * "
" * * "
" * * "
" * * "
" ** ** "
" *********** "
" "
" "
" "
" "
" "
" *** "
" ***** "
" *** ***** *** "
" ***** *** ***** "
" ****** ***** ****** "
" ***** ******* ***** "
" ******************* "
" **** **** **** **** "
" **** ** ** **** "
" **** **** "
" ***** ***** "
" *************** "
" *************** "
" ** ** "
" ************* "
" ************* "
" ************* "
" ************* "
" *********** "
" "
" "
" "
" "
" *** "
" * * "
" *** *** "
" ** ** "
" ** * * ** "
" * * * * * * "
" * ** ** * "
" * * * * "
" * * * * * * "
" * * * * * * "
" * * * * * "
" * * * * * "
" * * * * "
" * * * * "
" * * "
" * ********* * "
" * * "
" * * "
" ** ** "
" *********** "
" "
" "
" "
" "
" *** "
" * * "
" *** *** "
" ** ** "
" ** * * ** "
" **** * * **** "
" ******* ******* "
" ******* ******* "
" *** ** * * ** *** "
" *** **** **** *** "
" *** ***** ***** *** "
" **** ********* **** "
" **** ******* **** "
" ***** ***** ***** "
" *************** "
" ** ** "
" ************* "
" ************* "
" ************* "
" *********** "
" "
" "
" "
" "
" "
" "
" "
" "
" *** "
" * * "
" * * "
" * * "
" * * "
" * * "
" *** "
" * * "
" * * "
" ** ** "
" * * "
" * * "
" ******* "
" * * "
" *********** "
" *********** "
" "
" "
" "
" "
" "
" "
" "
" "
" *** "
" ***** "
" ******* "
" ******* "
" ******* "
" ***** "
" *** "
" ***** "
" ***** "
" ******* "
" ***** "
" ***** "
" ******* "
" * * "
" *********** "
" *********** "
" "
" "
;
int main(void)
{
int i, j, k;
unsigned int c[8] ;
memset(c,0,sizeof(c));
j = k = 0;
printf("const char gfxTiles[PAWN][2][96] = \n{\n");
for(i=0; i<sizeof(pieces); ++i)
{
c[j] |= (pieces[i] == '*') << (26-(i%21));
if (!(i%21))
{
++j;
if(!(j%8))
{
if(!k)
printf("\t{\n");
k++;
printf("\t\t{");
int x, y;
for(x=0;x<4;x++)
{
printf("\n\t\t\t");
unsigned char v;
for(y=0;y<8;y++)
{
v = (c[y] >> (8*(3-x))) & 0xff;
printf("0x%02X, ", v);
}
}
printf("\n\t\t},\n");
if(2==k)
{
printf("\t},\n");
k = 0;
}
j = 0;
for(y=0;y<8;y++)
{
c[y] = 0;
}
}
}
}
printf("};\n");
return 0;
}

394
src/c64/hiresC64.s Normal file
View File

@ -0,0 +1,394 @@
; hiresC64.s
; cc65 Chess
;
; Created by Stefan Wessels, May 2020.
;
;-----------------------------------------------------------------------
.include "zeropage.inc"
;-----------------------------------------------------------------------
.export _plat_gfxFill, _plat_showStrXY, _plat_showPiece, _plat_colorStringXY, _plat_colorFill
.import popa
;-----------------------------------------------------------------------
.define VIC_BASE_RAM $C000
.define SCREEN_RAM VIC_BASE_RAM + $2000
.define CHARMAP_RAM VIC_BASE_RAM + $2800
;-----------------------------------------------------------------------
.code
;-----------------------------------------------------------------------
; Utility - Turn tmp2 (y) and tmp3 (x) into a pointer in ptr2 that points
; in VIC_BASE_RAM with x, y being col and row with col and row being
; 8 pixels
.proc plat_ptr2AtHgrXY
lda tmp2 ; load y
asl ; ptr2 points at start with 320 = 256 + 64 so
asl ; y in hi + 64 * y in lo/hi + SCREEN_RAM hi = address
asl
asl
rol ptr2 + 1
asl
rol ptr2 + 1
asl
rol ptr2 + 1
sta ptr2
lda tmp2 ; add y in hi
adc ptr2 + 1
adc #>(VIC_BASE_RAM) ; and vic ram in hi (vic ram aligned, lo = 0)
sta ptr2 + 1 ; ptr2 now points at the correct row
stx tmp2 ; re-use tmp2, clear for possible carry
lda tmp3 ; x * 8 is offset into row where this col starts
asl
asl
asl
rol tmp2
adc ptr2
sta ptr2
lda tmp2
adc ptr2 + 1
sta ptr2 + 1 ; ptr2 now points at the start address on-screen, incl. x
rts
.endproc
;-----------------------------------------------------------------------
; Utility - Turn tmp2 (y) and ptr1 (x) into a pointer in ptr1 that points
; at SCREEN_RAM[x+y*40]
.proc plat_ptr2AtScrXY
lda tmp2 ; load y
asl ; * 32
asl
asl
asl
rol ptr1 + 1
asl
rol ptr1 + 1
adc ptr1 ; add x in
sta ptr1
bcc :+
inc ptr1 + 1
:
lda tmp2 ; start with y
asl ; 8 * + 32 * = 40 *
asl
asl
adc ptr1
sta ptr1
lda ptr1 + 1
adc #>(SCREEN_RAM) ; add screen ram hi as lo is $0 (aligned)
sta ptr1 + 1
rts
.endproc
;-----------------------------------------------------------------------
; void plat_gfxFill(char fill, char x, char y, char w, char h)
; where y & h are multiples of 8 and x and w are in columns (i.e.
; bytes not pixels). Fill the 8x8 aligned rectangle with fill.
.proc _plat_gfxFill
sta tmp1 ; h
ldx #0
stx ptr1 + 1 ; prep ptr1 hi for possible carry
stx ptr2 + 1 ; prep ptr2 hi for possible carry
jsr popa ; w
asl ; w * 8 - w in cols and 8 bytes per col till next col
asl
asl
rol ptr1 + 1 ; ptr1 now contains number of bytes to fill per row
sta ptr1
jsr popa
sta tmp2 ; y in tmp2
jsr popa
sta tmp3 ; x in tmp3
jsr plat_ptr2AtHgrXY
sec ; calculate (320 - width) as the "stride"
lda #$40
sbc ptr1
sta tmp2
lda #1
sbc ptr1 + 1
sta tmp3
jsr popa ; fill
sta tmp4
sei ; stop interrupts
lda 1 ; kernel out
and #$FD
sta 1
loop:
lda tmp4
ldy ptr1 + 1 ; check hi byte of width to fill
beq low ; width totals less than 256 bytes, no hi copy
ldy #0 ; fill 256 bytes
:
sta (ptr2), y
dey
bne :-
inc ptr2 + 1 ; adjust the write pointer by 256 bytes
low:
ldy ptr1 ; get the low bytes top copy
beq rowdone ; if none left to copy then row is done
:
dey
sta (ptr2), y ; write the block of bytes < 256
bne :-
rowdone:
dec tmp1 ; one more row done
beq done ; when wrap all rows are done
clc
lda ptr1
adc ptr2
bcc :+
inc ptr2 + 1
clc
:
adc tmp2 ; add stride to get to next row
sta ptr2
lda tmp3
adc ptr2 + 1
sta ptr2 + 1
bne loop ; bra
done:
lda 1 ; kernel in
ora #$02
sta 1
cli ; resume interrupts
rts
.endproc
;-----------------------------------------------------------------------
; void plat_colorFill(char color, char x, char y, char w, char h)
; Fills a rectangle in SCREEN_RAM with color.
.proc _plat_colorFill
sta tmp1 ; h
lda #0
sta ptr1 + 1 ; prep ptr2 hi for possible carry
jsr popa ; w
sta tmp3
jsr popa
sta tmp2 ; y in tmp2
jsr popa
sta ptr1 ; x in tmp3
jsr plat_ptr2AtScrXY
jsr popa ; color
sta tmp2
loop:
lda tmp2
ldy tmp3 ; get the low bytes top copy
beq rowdone ; if none left to copy then row is done
:
dey
sta (ptr1), y ; write the color
bne :-
rowdone:
dec tmp1 ; one more row done
beq done ; when wrap all rows are done
lda ptr1
adc #$28
sta ptr1
bcc loop
inc ptr1 + 1
clc
bne loop ; bra
done:
rts
.endproc
;-----------------------------------------------------------------------
; void plat_showStrXY(char x, char Y, char *str)
; Display the string pointed at by str in hires using the character set
; which must be located at CHARACTER_RAM. This must be Set 2 which
; includes lower case characters
.proc _plat_showStrXY
sta ptr1
stx ptr1 + 1
ldx #0
stx ptr2 + 1 ; init hi value for possibly shifting carry into
jsr popa
sta tmp2 ; y in tmp2
jsr popa
sta tmp3 ; x in tmp3
jsr plat_ptr2AtHgrXY
sei ; stop interrupts
lda 1 ; kernel out
and #$FD
sta 1
ldy #0
sty tmp2
loop:
ldy tmp2
lda (ptr1), y ; character
beq done
cmp #'z'
bpl :+
and #63
:
and #127
ldy #7
ldx #0
stx read + 2
asl ; *8 for bytes
rol read + 2
asl
rol read + 2
asl
rol read + 2
sta read + 1
lda #>(CHARMAP_RAM)
adc read + 2
sta read + 2
read:
lda $ffff, y
sta (ptr2), y
dey
bpl read
lda ptr2
adc #8
sta ptr2
bcc :+
inc ptr2 + 1
clc
:
inc tmp2
bne loop
done:
lda 1 ; kernel in
ora #$02
sta 1
cli ; resume interrupts
rts
.endproc
;-----------------------------------------------------------------------
; void plat_colorStringXY(char color, char x, char y, char *str)
; Uses str only for length. Writes color into SCREEN_RAM at
; SCREEN_RAM[i+x+y*40] where i iterates the string [while(str[i]) i++].
.proc _plat_colorStringXY
sta ptr2 ; store the str pointer in ptr2
stx ptr2 + 1
lda #0 ; clear ptr1 hi for carry
sta ptr1 + 1
jsr popa ; y
sta tmp2 ; save y in tmp 2
jsr popa ; x
sta ptr1 ; save x in ptr1 lo
jsr plat_ptr2AtScrXY
jsr popa ; get the color
tax ; save it in x
ldy #0 ; start at 0
:
lda (ptr2), y
beq done ; as long as string has a valid character
txa ; put color in a
sta (ptr1), y ; and write to SCREEN_RAM
iny
bne :-
done:
rts
.endproc
;-----------------------------------------------------------------------
; void plat_showPiece(char x, char Y, const char *src)
; copies 3 * 32 consecutive bytes from src to a rectangle in VIC RAM at x, y
; The rect is 4 bytes by 24 bytes (rows) so 96 bytes total
.proc _plat_showPiece
sta ptr1 ; store the pointer to the piece
stx ptr1 + 1
ldx #0 ; plat_ptr2AtHgrXY assumes x = 0
stx ptr2 + 1 ; init hi value for possibly shifting carry into
jsr popa
sta tmp2 ; y in tmp2
jsr popa
sta tmp3 ; x in tmp3
jsr plat_ptr2AtHgrXY ; calculate offset into ptr2
sei ; stop interrupts
lda 1 ; kernel out
and #$FD
sta 1
lda #3 ; need to do 3 loops for a whole piece
sta tmp1
loop:
ldy #31 ; 32 bytes to copy
:
lda (ptr1), y ; load src
eor (ptr2), y ; merge with dest
sta (ptr2), y ; save at dest
dey
bpl :- ; do all 32
dec tmp1 ; another 3rd done
beq done ; all done?
lda ptr1 ; more to do - move src data ptr along by 32
adc #32
sta ptr1
bcc :+
clc
inc ptr1 + 1
:
lda ptr2 ; move graphics pointer along by 320 (row down)
adc #<320
sta ptr2
lda ptr2 + 1
adc #>320
sta ptr2 + 1
bne loop ; bra
done:
lda 1 ; kernel in
ora #$02
sta 1
cli ; resume interrupts
rts
.endproc

550
src/c64/platC64.c Normal file
View File

@ -0,0 +1,550 @@
/*
* platC64.c
* cc65 Chess
*
* Created by Stefan Wessels, February 2014.
*
*/
#include <c64.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "../types.h"
#include "../globals.h"
#include "../undo.h"
#include "../frontend.h"
#include "../plat.h"
#include "dataC64.h"
/*-----------------------------------------------------------------------*/
// System locations
#define VIC_BASE_RAM (0xC000)
#define BITMAP_OFFSET (0x0000)
#define CHARMAP_ROM (0xD000)
#define SCREEN_RAM ((char*)VIC_BASE_RAM + 0x2000)
#define CHARMAP_RAM ((char*)VIC_BASE_RAM + 0x2800)
/*-----------------------------------------------------------------------*/
#define BOARD_PIECE_WIDTH 4
#define BOARD_PIECE_HEIGHT 3
#define SCREEN_WIDTH 40
#define SCREEN_HEIGHT 25
#define COLOR_OFFSET 0
#define SCROLL_SPEED 0xf5
/*-----------------------------------------------------------------------*/
// Internal function Prototype
char plat_TimeExpired(unsigned int aTime, char *timerInit);
/*-----------------------------------------------------------------------*/
// Function Prototype for functions in hires.s
void plat_gfxFill(char fill, char x, char y, char w, char h);
void plat_colorFill(char color, char x, char y, char w, char h);
void plat_showStrXY(char x, char y, char *str);
void plat_colorStringXY(char color, char x, char y, char *str);
void plat_showPiece(char x, char Y, const char *src);
/*-----------------------------------------------------------------------*/
// Local storage
static char sc_pra, sc_vad, sc_ct1, sc_ct2, sc_vbc;
char textStr[41];
static char subMenu;
/*-----------------------------------------------------------------------*/
// Called one-time to set up the platform (or computer or whatever)
void plat_Init()
{
// Setting this to 0 will not show the "Quit" option in the main menu
gReturnToOS = 1;
if(gReturnToOS)
{
// Save these values so they can be restored