Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1210 > unrolled thread

ca65 on the Mac, AppleScript to launch Virtual ][

Started byChris Torrence <gorthmog@gmail.com>
First post2014-04-08 21:04 -0700
Last post2014-04-09 00:51 -0400
Articles 2 — 2 participants

Back to article view | Back to comp.sys.apple2.programmer


Contents

  ca65 on the Mac, AppleScript to launch Virtual ][ Chris Torrence <gorthmog@gmail.com> - 2014-04-08 21:04 -0700
    Re: ca65 on the Mac, AppleScript to launch Virtual ][ Egan Ford <datajerk@gmail.com> - 2014-04-09 00:51 -0400

#1210 — ca65 on the Mac, AppleScript to launch Virtual ][

FromChris Torrence <gorthmog@gmail.com>
Date2014-04-08 21:04 -0700
Subjectca65 on the Mac, AppleScript to launch Virtual ][
Message-ID<15407afd-e998-4006-9a39-a549967d0820@googlegroups.com>
So I've been doing some assembly language programming using ca65 on the Mac. After stumbling along on my own, I "re-discovered" the same solution as described in the post below:
https://groups.google.com/d/topic/comp.sys.apple2.programmer/qLExwic6UOs/discussion

Anyway, I wrote an AppleScript script to automatically launch my newly-created disk image, and thought others might find it useful.

I have a gnu makefile that contains the following:

-------------------------------
CA=ca65
LD=ld65
TARGET=apple2
DISK=../disks/NEW.DSK
AC=/Applications/AppleCommander.app/Contents/Resources/Java/AppleCommander.jar
# Delete the default suffixes. Otherwise .o gets compiled with Mac's "cc".
.SUFFIXES:

# *.sbin is just for pure assembly code. No apple2.lib is included.
%.sbin: %.s
	$(CA) $<
	$(LD) -t $(TARGET) --start-addr 0x0803 -o $@ $*.o
	java -jar $(AC) -d $(DISK) $*
	java -jar $(AC) -cc65 $(DISK) $* BIN < $@
	osascript RunProgram.scpt -$*

helloworld: helloworld.sbin
-------------------------------

The name of my program is "helloworld.s", and contains more-or-less the same code as in the previous post. Typing "make helloworld" compiles the .s into a .o and then a .sbin (just my own suffix so I can keep track). This .sbin then gets copied to an existing ProDOS disk. Finally, the RunProgram applescript gets run.

The RunProgram.scpt looks like this:

-------------------------------
-- Applescript to launch the Virtual ][ emulator, insert a particular disk,
-- and then run a command in basic. The command is given by an argument:
-- terminal> osascript RunProgram.scpt "BRUN RUNMYPROGRAM"
-- This will fire up the disk and execute the command "BRUN RUNMYPROGRAM"
on run argv
	tell application "Virtual ]["
		activate
		set theDisk to disk folder & "NEW.DSK"
		tell front machine
			-- set monochrome screen to false
			set speed to maximum
			insert theDisk into device "S6D1"
			-- give time for disk to boot before switching back to reg speed
			delay 2.0
			set speed to regular
			type line item 1 of argv
		end tell
		activate
	end tell
end run
-------------------------------

The "delay 2.0" is just a hack to give ProDOS time to boot. Otherwise the script just sails on through and immediately sets the disk speed back to regular before Virtual ][ even starts booting.

Anyway, just thought I would post this here in case it might be helpful to someone. Or if anyone has a better workflow, I would love to hear about it.

Cheers,
Chris

[toc] | [next] | [standalone]


#1211

FromEgan Ford <datajerk@gmail.com>
Date2014-04-09 00:51 -0400
Message-ID<li2jkn$1c8$1@news.xmission.com>
In reply to#1210
On 4/9/14, 12:04 AM, Chris Torrence wrote:
> So I've been doing some assembly language programming using ca65 on the Mac.

A possible quicker alternative if you do not need DOS or PRODOS:

1.  make
2.  c2t -p -l prog,start_address | pbcopy
3.  cmd-v into monitor prompt
4.  start_addressG

c2t -p -l prog,start will produce something like this to stdout:

0800: 20 A9 0E 20 A9 0E A9 8F A0 02 20 96 0E F0 15 31 30 30 30 20 44 49 
47 49 54 53 20 4F 46 20 50 49
0820: 20 3D 20 00 8D 01 E1 20 C0 02 8D 01 E2 8D 1B E1 A9 80 A0 11 20 DC 
0D 8D 1B E2 20 A9 0E 4C 1F FF
0840: 8D 1A E1 A9 80 A0 11 A2 05 20 38 03 8D 1A E2 8D 15 E1 A9 80 A0 11 
20 E3 04 8D 15 E2 8D 15 E1 A9
....

I just put this in my Makefiles:

%.mon: %
     $(C2T) -l $<,$(STARTADDR) $@

That will create a .mon file, e.g.:  c2t -l milltest2,800 milltest2.mon

Then (cat milltest2.mon; echo 800G) | pbcopy

Then CMD-V into Virtual ][

I say its faster because if I do not crash the IIe I can quickly test 
code over and over again without a reboot.

BTW, thanks for the AppleScript.  Something that I need to spend more 
time learning.

P.S. Virtual ][ install registers .DSK files as a Virtual ][ filetype. 
So, if I want to boot a .DSK I just type "open filename.dsk", and 
Virtual ][ boots a IIe and loads the disk.  After testing it's CMD-Q, 
CMD-D, return to shutdown.  Then edit, make, open filename.dsk, etc... 
all over again.  No mouse needed.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.apple2.programmer


csiph-web