Skip to content

Commit

Permalink
Removed dependency of Cygwin from hexameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
matsutsuka committed Jul 20, 2008
1 parent f822ac9 commit 6c9291f
Show file tree
Hide file tree
Showing 23 changed files with 439 additions and 181 deletions.
19 changes: 10 additions & 9 deletions platform/pc-6001/Makefile.pc-6001
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for PC-6001 using z80/SDCC
# @author Takahide Matsutsuka <[email protected]>
#
# $Id: Makefile.pc-6001,v 1.9 2008/07/02 15:04:07 matsutsuka Exp $
# $Id: Makefile.pc-6001,v 1.10 2008/07/20 07:44:39 matsutsuka Exp $
#

ifndef CONTIKI
Expand Down Expand Up @@ -48,7 +48,8 @@ endif

### setup default values
ifndef HEX2BIN
HEX2BIN = ../../tools/z80/hex2bin/hexameter
HEX2BINDIR = ../../tools/z80/hex2bin/
HEX2BIN = $(HEX2BINDIR)/hexameter
endif

### setup flags to be used in compiler, assembler, and HEX2BIN
Expand All @@ -59,16 +60,16 @@ CFLAGS += -DMEMORY_$(MEMORY) -DARCH_$(ARCH) -DCTK_$(CTKCONF)

ifeq ($(MEMORY),16K)
LDFLAGS += --code-loc 0xc40f --data-loc 0
HEX2BINFLAGS = -p mode1 -s suffix -o contiki.p6
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode1.ihx -o contiki.p6
else ifeq ($(MEMORY),ROM)
LDFLAGS += --code-loc 0x4004 --data-loc 0xf000
HEX2BINFLAGS = -p rom60 -o contiki.rom
HEX2BINFLAGS = -d ROMEXEC=4004 $(HEX2BINDIR)/ihx/rom60.ihx -b 4000 -o contiki.rom
else ifeq ($(ARCH),PC6001MK2)
LDFLAGS += --code-loc 0x800f --data-loc 0
HEX2BINFLAGS = -p mode5 -s suffix -o contiki2.p6
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode5.ihx -o contiki2.p6
else
LDFLAGS += --code-loc 0x840f --data-loc 0
HEX2BINFLAGS = -p mode2 -s suffix -o contiki.p6
HEX2BINFLAGS = -d TAPE=contki $(HEX2BINDIR)/ihx/mode2.ihx -o contiki.p6
endif

ifeq ($(LOADER),1)
Expand Down Expand Up @@ -108,12 +109,12 @@ contiki: $(HEX2BIN) contiki.p6
.SUFFIXES:

%.p6: %.ihx
$(HEX2BIN) $(HEX2BINFLAGS) $<
$(HEX2BIN) $(HEX2BINFLAGS) $< $(HEX2BINDIR)/ihx/suffix.ihx
%.rom: %.ihx
$(HEX2BIN) $(HEX2BIN) $(HEX2BINFLAGS) $<
$(HEX2BIN) $(HEX2BINFLAGS) $<

$(HEX2BIN):
cd ../../tools/z80/hex2bin/; make
cd $(HEX2BINDIR); make

remove-ctk:
rm -f obj_$(TARGET)/ctk*;
Expand Down
4 changes: 2 additions & 2 deletions platform/pc-6001/contiki-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: contiki-main.c,v 1.2 2008/07/02 15:03:44 matsutsuka Exp $
* $Id: contiki-main.c,v 1.3 2008/07/20 07:44:39 matsutsuka Exp $
*
*/

Expand Down Expand Up @@ -71,7 +71,7 @@ main(void)
#else
program_handler_add(&processes_dsc, "Processes", 1);
program_handler_add(&mttest_dsc, "Multithread", 1);
// program_handler_add(&calc_dsc, "Calculator", 1);
program_handler_add(&calc_dsc, "Calculator", 1);
program_handler_add(&about_dsc, "About", 1);
// program_handler_add(&shell_dsc, "Command shell", 1);
#endif
Expand Down
26 changes: 26 additions & 0 deletions tools/z80/hex2bin/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2008, Takahide Matsutsuka.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
26 changes: 20 additions & 6 deletions tools/z80/hex2bin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@
# Makefile for hexameter
# @author Takahide Matsutsuka <[email protected]>
#
# $Id: Makefile,v 1.1 2008/07/02 07:17:14 matsutsuka Exp $
# $Id: Makefile,v 1.2 2008/07/20 07:44:39 matsutsuka Exp $
#

CFLAGS =
SOURCEDIR = src
TARGET = hexameter.o ihx2bin.o
CFLAGS = -std=c99 -g -mno-cygwin -Wall
#CFLAGS = -std=c99 -g -Wall
SOURCEDIR = src
SOURCES = hexameter.c ihx2bin.c
OBJECTDIR = bin
OBJECTS = ${addprefix $(OBJECTDIR)/,$(SOURCES:.c=.o)}

vpath %.c $(SOURCEDIR)

hexameter: $(TARGET)
ifeq (${wildcard $(OBJECTDIR)},)
DUMMY := ${shell mkdir $(OBJECTDIR)}
endif

hexameter: $(OBJECTS)
$(CC) $(CFLAGS) -o $@ $(OBJECTS)

clean:
rm -f *.o *~ hexameter.exe
rm -rf bin
rm -f *~ *.stackdump
rm -f *~ hexameter.exe

$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

97 changes: 64 additions & 33 deletions tools/z80/hex2bin/README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
hexameter : Convert Intel hex files to a binary file
version 2.0.0
version 2.1.0
Copyright (c) 2003-2008, Takahide Matsutsuka.

1/ What is it?
Expand All @@ -13,15 +13,15 @@ other old computers.

2/ Installation

Installation can be done in following steps.
Installation can be done in the following steps.

a) Download and install SDCC from http://sdcc.sf.net/
Version 2.8.0 is tested.
Version 2.8.0 has been tested.
SDCC is a cross-compiler for Z80 and other 8bit CPUs.
Extract an archive on your disk, say "c:/sdcc".

b) Copy hexameter.exe to any path-available directory. for exmaple
"c:/sdcc/bin".
b) Place hexameter.exe and prefix/suffix files to any path-available
directory.


3/ Use
Expand Down Expand Up @@ -60,38 +60,30 @@ b) Compile your code using SDCC.

c) Convert ihx file to cas file using hex2cas.

hexameter YOUR_CODE.ihx [YOUR_CODE2.ihx ...]
hexameter <ihx_file|binary_file> [ihx_file|binary_file ...]
The ihx files are just attached in the specified order.

Here you can take some options:
-p <filename> specify prefix file name.
-s <filename> specify suffix file name.
-n <name> specify PC-6001 cassette file name,
must be 6 characters or less.
-v verbose output
-o <filename> specify output file name
-b <size> size of the output file in hexadecimal bytes.
only if the size of the output is less than the size
specified, the trailing bytes will filled by zeroes.
note that it doesn't mean the size of output is
restricted by the given size.
-h displays simple usage

Prefixes and suffixes are provided by files, which should be in the same
directory as hexameter.exe.
mode1
mode2
mode5
n88
rom60
rom62
suffix
-o <filename> specify output file name
-d <name>=<value> define ihx-specific value replacement
-v verbose output
-b <size> size of the output file in hexadecimal bytes.
only if the size of the output is less than the size
specified, the trailing bytes will filled by zeroes.
note that it doesn't mean the size of output is
restricted by the given size.
-h displays simple usage

You can find various predefined library file in "lib" directory.
Each of them may take its own optional value, which you can specify
with -d option.

d) Example

The following is a typical example to convert from ihx files to
PC-6001 loadable cassette format.
% hexameter -p mode2 -s suffix mycode1.ihx mycode2.ihx -o myapp.p6
% hexameter -v TAPE=myfile mode2.ihx mycode2.ihx -o myapp.p6
Note that TAPE value is defined in mode2.ihx, defines cassette file name.

e) Load your cas file into your 6001 emulator.

Expand All @@ -105,15 +97,52 @@ e) Load your cas file into your 6001 emulator.
http://bernie.hp.infoseek.co.jp/develop/pc6001vw.html


4/ Note
4/ IHX extentions

- While I've tested the tool on Cigwin on Win32, I think it works
on other environments with a little work.
To support run-time user specified values in ihx files, Hexameter supports
extended ihx files. Examples are located in ihx directory.

For example, mode2.ihx has the following line.

:06000a02TAPE

As in normal ihx format, the first 9 characters conform to the following
format:

:AABBBBCC
AA bytes encoded in this line
BBBB start address of this line
CC type of this line

The normal ihx file, which sdcc emits, has the type 00 (data) and 01 (end of
file). In addition to this, Hexameter supports the following types.

02 string
03 byte
04 word (encoded in little endian)

The rest of line defines a name of the definition. In the example above,
the name TAPE is assigned to this line. You can use latin alphabets,
numbers, and underscore (_) for the name. Letters are case-sensitive.

When you run Hexameter, you can specify a value for this definition like:
hexameter -d TAPE=xxxx

Since this example defines 06 in the bytes field, TAPE can have up to
six characters. This string will override the memory location 000a
specified in the second field.

For type 03 (byte) and 04 (word), bytes field has no effect.


5/ Note

- Cygwin dependency has been removed.

- SDCC has many isuues regarding compilation. Don't blame me about them! :)


5/ History
6/ History

3/29/2003 1.0.0 First version
4/20/2003 1.0.1 Mode option has been added
Expand All @@ -123,6 +152,8 @@ e) Load your cas file into your 6001 emulator.
4/28/2008 1.4.0 Header file option introduced

5/17/2008 2.0.0 Migrated to hexameter, to support more flexible configurations
7/16/2008 2.1.0 Support arguments in ihx file, remove prefix/suffix instead
7/18/2008 2.1.1 Cygwin dependency has been removed


Enjoy!
Expand Down
3 changes: 3 additions & 0 deletions tools/z80/hex2bin/ihx/mode1.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:10000000d3d3d3d3d3d3d3d3d3d3000000000000
:0e0010000dc40a00a5264843343046000000
:06000a02TAPE
3 changes: 3 additions & 0 deletions tools/z80/hex2bin/ihx/mode2.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:10000000d3d3d3d3d3d3d3d3d3d3000000000000
:0e0010000d840a00a5264838343046000000
:06000a02TAPE
3 changes: 3 additions & 0 deletions tools/z80/hex2bin/ihx/mode5.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:10000000d3d3d3d3d3d3d3d3d3d3000000000000
:0e0010000d800a00a5264838303046000000
:06000a02TAPE
3 changes: 3 additions & 0 deletions tools/z80/hex2bin/ihx/mp6.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:10000000544d6767676767676767000000000000
:02000c04MP6LOAD
:02000e04MP6EXEC
18 changes: 18 additions & 0 deletions tools/z80/hex2bin/ihx/n88.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
:10000000d3d3d3d3d3d3d3d3d3d3202020202020
:100010000d000a009720e0f10c00010018001400
:1000200041f1e028112900000020202020202020
:1000300020202020202020202020202020202020
:1000400020202020202020202020202020202020
:1000500020202020202020202020202020202020
:1000600020202020202020202020202020202020
:1000700020202020202020202020202020202020
:1000800020202020202020202020202020202020
:1000900020202020202020202020202020202020
:1000a00020202020202020202020202020202020
:1000b00020202020202020202020202020202020
:1000c00020202020202020202020202020202020
:1000d00020202020202020202020202020202020
:1000e00020202020202020202020202020202020
:1000f00020202020202020202020202020202020
:0f010000202020202020202020202020202020
:06000a02TAPE
2 changes: 2 additions & 0 deletions tools/z80/hex2bin/ihx/rom60.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:0400000041420440
:02000204ROMEXEC
2 changes: 2 additions & 0 deletions tools/z80/hex2bin/ihx/rom62.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:0400000043440440
:02000204ROMEXEC
1 change: 1 addition & 0 deletions tools/z80/hex2bin/ihx/suffix.ihx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:0c000000000000000000000000000000
Binary file removed tools/z80/hex2bin/mode1
Binary file not shown.
Binary file removed tools/z80/hex2bin/mode2
Binary file not shown.
Binary file removed tools/z80/hex2bin/mode5
Binary file not shown.
Binary file removed tools/z80/hex2bin/n88
Binary file not shown.
1 change: 0 additions & 1 deletion tools/z80/hex2bin/rom60

This file was deleted.

1 change: 0 additions & 1 deletion tools/z80/hex2bin/rom62

This file was deleted.

Loading

0 comments on commit 6c9291f

Please sign in to comment.