Skip to content

Instantly share code, notes, and snippets.

@lucasw
Last active October 28, 2020 00:23
Show Gist options
  • Save lucasw/8f1ea9e80d74c99bd3d49a7759b16bc6 to your computer and use it in GitHub Desktop.
Save lucasw/8f1ea9e80d74c99bd3d49a7759b16bc6 to your computer and use it in GitHub Desktop.
Linux Commodore 64

Use cc65 just like for NES https://gist.github.com/lucasw/53ece8eed3b99beb6215b42cc686d1a7

Emulator

vice emulator- not in ubuntu repo, need to build from source- on sourceforge:

Need some old autoconf tools (and xa65 cross assembler) to build it:

sudo apt-get install autoconf byacc flex libreadline-dev libxaw7-dev texinfo xa65

(If no libreadline-dev will get configure: error: The Xaw port needs Readline error out of configure.

svn checkout https://svn.code.sf.net/p/vice-emu/code/trunk vice-emu-code
cd vice-emu-code/vice
./autogen.sh   # can only run in-source
./configure --prefix=$HOME/other/install
make
make install

USB Joystick support

This reports no usb joystick support:

INPUT
-----
Joystick support            : yes
Mouse support               : yes
Lightpen support            : yes
Linux style joystick support: yes
BSD style joystick support  : no 
Digital joystick support    : no 
USB joystick support        : no 

In configure.ac I see

  AC_CHECK_HEADER(libusb.h,
                      [AC_DEFINE(HAVE_LIBUSB_H,1,
                        [Define to 1 if you have the <libusb.h> header file.])
                      usb_header=yes])
      if test x"$usb_header" = "xyes" ; then
        AC_DEFINE(HAS_USB_JOYSTICK,,[Enable emulation for USB joysticks.])
        JOY_LIBS="-lusb"
        HAS_USB_JOYSTICK_SUPPORT="yes"

But it isn't getting triggered. I do have libusb.h in /usr/include/libusb-1.0/libusb.h, libusbhid.h or usbhid.h aren't available.

http://retrocomputing.stackexchange.com/questions/2606/usb-joystick-support-building-vice-from-source

Ignoring that for now and continuing on:

Build packages missing

make
...
/bin/bash: xa: command not found
Makefile:1268: recipe for target 'psiddrv.h' failed
make[3]: *** [psiddrv.h] Error 127
Makefile:2103: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
Makefile:1862: recipe for target 'all' failed
make[1]: *** [all] Error 2
Makefile:606: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
sudo apt-get install xa65
make
...
Making all in c64
Warning: zero segment ($0004) start address doesn't align to 256!
Making all in cart
...
/home/lucasw/other/vice-emu-code/vice/missing: line 81: makeinfo: command not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
         <http://www.gnu.org/software/texinfo/>
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
         <http://www.gnu.org/software/make/>

sudo apt-get install texinfo

Out of source build

cd ..
mkdir build_vice
cd build_vice
../vice/configure --prefix=$HOME/other/install
make
...
Making all in c64

Run cc65 examples

cd cc65/samples
make
x64

vice_x64

left click smart-attach disk/tape...

vice_x64_smart-attach

Select plasma (no file extension). Then the emulator should have keyboard focus, type 'run'- it will appear all capitals but don't hold down shift.

vice_x64_mandelbrot1_ready

plasma1

plasma

@lucasw
Copy link
Author

lucasw commented Apr 4, 2017

mandelbrot produces a cannot load driver error:

vice_cannot_load_driver

@lucasw
Copy link
Author

lucasw commented Apr 4, 2017

With .tap files can select autostart and it will load.

@lucasw
Copy link
Author

lucasw commented Feb 7, 2018

ca65 assembly for the c64


https://www.reddit.com/r/c64/comments/5zcaa3/learning_c64_assembler_with_vice_on_ubuntu_where/?st=jdd7t22z&sh=2f0c2f71#bottom-comments

This is meant for ACME, does it work in ca65?

* = $801
; this is a sample BASIC program required to start our code
!byte $0c,$08,$0a,$00
!byte $9e ; sys
!text "2068 :-)"
!byte $00,$00,$00,$00

*=$0814

; our code starts here
lda #$00
sta $d020
sta $d021
rts
export PATH=$PATH:~/other/cc65/bin
ca65 -t c64 test.s

It doesn't like the ! lines

http://www.lemon64.com/forum/viewtopic.php?t=54221&sid=3393e1629d9a21e54c9adb8564d79b6f

.byte $01,$08
.org $0801
   .byte $0c,$08,$d0,$07,$9e,$20,$32,$30,$36,$34,$00,$00,$00,$00,$00   ; Basic "SYS 2064"

; our code starts here
lda #$00
sta $d020
sta $d021
rts
cl65 -O -t c64 -o test2 test2.s
ld65: Warning: /home/lucasw/other/cc65/cfg/c64.cfg(45): Segment `STARTUP' does not exist
ld65: Warning: /home/lucasw/other/cc65/cfg/c64.cfg(45): Segment `INIT' does not exist
ld65: Warning: /home/lucasw/other/cc65/cfg/c64.cfg(45): Segment `ONCE' does not exist
ld65: Error: /home/lucasw/other/cc65/cfg/c64.cfg(15): Start address of memory area `BSS' is not constant

@lucasw
Copy link
Author

lucasw commented Feb 7, 2018

ACME

svn checkout https://svn.code.sf.net/p/acme-crossass/code-0/trunk acme-crossass-code-0
cd acme-crossass-code-0/src
make
cp acme ~/other/install/bin/
acme 
ACME - the ACME Crossassembler for Multiple Environments
  Copyright (C) 1998-2017 Marco Baye
This is ACME, release 0.96.4 ("Fenchurch"), 22 Dec 2017
  Platform independent version.
ACME comes with ABSOLUTELY NO WARRANTY; for details read the help file.
  This is free software, and you are welcome to redistribute it under
  certain conditions; as outlined in the GNU General Public License.
Dedicated to the wisest being I ever had the pleasure of reading
  books of (currently spending some time dead for tax reasons).
The newest version can be found at the ACME homepage:
  http://sourceforge.net/p/acme-crossass/

Usage:
acme [OPTION...] [FILE]...

Options:
  -h, --help             show this help and exit
  -f, --format FORMAT    set output file format
  -o, --outfile FILE     set output file name
  -r, --report FILE      set report file name
  -l, --symbollist FILE  set symbol list file name
      --labeldump        (old name for --symbollist)
      --vicelabels FILE  set file name for label dump in VICE format
      --setpc NUMBER     set program counter
      --cpu CPU          set target processor
      --initmem NUMBER   define 'empty' memory
      --maxerrors NUMBER set number of errors before exiting
      --maxdepth NUMBER  set recursion depth for macro calls and !src
  -vDIGIT                set verbosity level
  -DSYMBOL=VALUE         define global symbol
  -I PATH/TO/DIR         add search path for input files
  -Wno-label-indent      suppress warnings about indented labels
  -Wno-old-for           suppress warnings about old "!for" syntax
  -Wtype-mismatch        enable type checking (warn about type mismatch)
      --use-stdout       fix for 'Relaunch64' IDE (see docs)
      --msvc             output errors in MS VS format
      --color            uses ANSI color codes for error output
      --fullstop         use '.' as pseudo opcode prefix
  -V, --version          show version and exit

Now try the example from reddit again

acme -f cbm -o test.prg test.s
x64 test.prg

It successfully turns the the background black.

Cycle the border and background colors rapidly:

ldy #$0a
ldx #$00
start:
sty $d020  ; border color
stx $d021  ; bg color around text
inx
dey
jmp start
rts
hexdump -C test.prg
00000000  01 08 0c 08 0a 00 9e 32  30 36 38 20 3a 2d 29 00  |.......2068 :-).|
00000010  00 00 00 00 00 a0 0a a2  00 8c 20 d0 8e 21 d0 e8  |.......... ..!..|
00000020  88 4c 18 08 60                                    |.L..`|
00000025

how to recompile and reload within x64 without restarting it completely (though it is plenty fast to restart completely).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment