Some final fixes to handle the fact that the header is not there consistently. So, we need to validate that the first two bytes in the binary is the expected start address and if so, then there is a header which needs to be stripped.

This commit is contained in:
Jeremy Rand 2014-09-10 01:28:12 -04:00
parent 4c9e6ca755
commit f79de893c9
8 changed files with 28 additions and 52 deletions

View File

@ -8,10 +8,7 @@
/* Begin PBXFileReference section */
70E84C2E19B10B3100159159 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
70E84C2F19B10B3100159159 /* exampleAsm.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = exampleAsm.s; sourceTree = "<group>"; };
9D084B2119B6AC2F0070589C /* head.mk */ = {isa = PBXFileReference; lastKnownFileType = text; name = head.mk; path = make/head.mk; sourceTree = "<group>"; };
9D084B2219B6AC540070589C /* tail.mk */ = {isa = PBXFileReference; lastKnownFileType = text; name = tail.mk; path = make/tail.mk; sourceTree = "<group>"; };
9DE27AEA19BBF98700727AFA /* exampleC.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = exampleC.c; sourceTree = "<group>"; };
70E84C2F19B10B3100159159 /* x.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = x.s; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
@ -19,21 +16,10 @@
isa = PBXGroup;
children = (
70E84C2E19B10B3100159159 /* Makefile */,
70E84C2F19B10B3100159159 /* exampleAsm.s */,
9DE27AEA19BBF98700727AFA /* exampleC.c */,
9D084B1F19B6ABE40070589C /* make */,
70E84C2F19B10B3100159159 /* x.s */,
);
sourceTree = "<group>";
};
9D084B1F19B6ABE40070589C /* make */ = {
isa = PBXGroup;
children = (
9D084B2119B6AC2F0070589C /* head.mk */,
9D084B2219B6AC540070589C /* tail.mk */,
);
name = make;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXLegacyTarget section */
@ -114,7 +100,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
@ -149,7 +135,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};

View File

@ -33,7 +33,6 @@ PGM=example
# MACHINE = apple2enh-system
# MACHINE = apple2enh-loader
# MACHINE = apple2enh-reboot
MACHINE = apple2enh-system
# Uncomment and set this to your starting address in Apple ][ memory
# if necessary:

View File

@ -1,23 +0,0 @@
//
// exampleC.c
// Apple2BuildPipelineSample
//
// Created by Jeremy Rand on 9/6/14.
// Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
//
#include <conio.h>
#include <stdio.h>
extern void asmFunc(void);
int main(void)
{
printf("\n\nHello, world!\n");
cgetc();
//asmFunc();
return 0;
}

Binary file not shown.

View File

@ -1,6 +1,6 @@
#!/bin/sh
if [ $# -lt 4 ]
if [ $# -lt 5 ]
then
echo USAGE: $0 '<AppleCommander> <machine> <diskimage> <binary>'
exit 1
@ -11,6 +11,7 @@ APPLECOMMANDER=$1
MACHINE=$2
DISKIMAGE=$3
PROGRAM=$4
STARTADDR=`echo $5 | sed 's/^0*//'`
if [ ! -f "$PROGRAM" ]
then
@ -151,8 +152,13 @@ fi
if [ $HASHEADER -eq 1 ]
then
STARTADDR=`od -t x2 -N 2 < "$PROGRAM" | head -1 | awk '{print $2}'`
dd if="$PROGRAM" bs=4 skip=1 | java -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE 0x$STARTADDR
HDR_STARTADDR=`od -t x2 -N 2 < "$PROGRAM" | head -1 | awk '{print $2}' | sed 's/^0*//'`
if [ "$HDR_STARTADDR" = "$STARTADDR" ]
then
dd if="$PROGRAM" bs=4 skip=1 | java -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE 0x$STARTADDR
else
java -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE 0x$STARTADDR < "$PROGRAM"
fi
else
java -jar "$APPLECOMMANDER" -p "$DISKIMAGE" "$TARGETFILE" $FILETYPE < "$PROGRAM"
fi

View File

@ -31,8 +31,18 @@ ifneq ($(START_ADDR),)
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
$(error You cannot change start address with this machine type)
endif
LDFLAGS += --start-addr 0x$(START_ADDR)
else
ifneq ($(filter $(MACHINE), apple2 apple2-dos33 apple2enh apple2enh-dos33),)
START_ADDR=803
endif
ifneq ($(filter $(MACHINE), apple2-system apple2enh-system),)
START_ADDR=2000
endif
ifneq ($(filter $(MACHINE), apple2-loader apple2-reboot apple2enh-loader apple2enh-reboot),)
START_ADDR=800
endif
endif
LDFLAGS += --start-addr 0x$(START_ADDR)
ifneq ($(filter $(MACHINE), apple2 apple2enh apple2-dos33 apple2enh-dos33),)
EXECCMD=$(shell echo brun $(PGM) | tr '[a-z]' '[A-Z]')
@ -64,10 +74,10 @@ $(PGM): $(OBJS)
$(CL65) $(MACHCONFIG) --mapfile $(MAPFILE) $(LDFLAGS) -o $(PGM) $(OBJS)
$(DISKIMAGE): $(PGM)
make/createDiskImage $(AC) $(MACHINE) $(DISKIMAGE) $(PGM)
make/createDiskImage $(AC) $(MACHINE) $(DISKIMAGE) $(PGM) "$(START_ADDR)"
execute: $(DISKIMAGE)
osascript make/V2Make.scpt $(PROJECT_DIR) $(PGM) $(PROJECT_DIR)/DevApple.vii "$(EXECCMD)"
osascript make/V2Make.scpt $(PROJECT_DIR) $(PGM) $(PROJECT_DIR)/make/DevApple.vii "$(EXECCMD)"
%.o: %.c
$(CL65) $(MACHCONFIG) $(CFLAGS) --create-dep -c -o $@ $<

View File

@ -10,8 +10,6 @@
; http://www.quinndunki.com/blondihacks
;
.export _asmFunc
; Reserved locations
INVERSE = $32
@ -30,9 +28,9 @@ COUT = $fded
; _asmFunc
; Main
_asmFunc:
main:
lda #CHAR_FLASH
sta INVERSE