USBhost-64 example loader application

As I was extending one of the USBhost-64 software APIs for file access in assembly, I thought to publish an example loader application that takes advantage of the API.

This is what end users would have to write by themselves (or just modify it now that I have published it 🙂 )  in order to load a PRG file into the C64’s RAM:

; $Id: loader.asm,v 1.1 2014/02/11 12:59:39 luigidifraia Exp $
;       $RCSfile: loader.asm,v $
;         $State: Exp $
;      $Revision: 1.1 $
;          $Date: 2014/02/11 12:59:39 $
;        $Author: luigidifraia $
; $Log: loader.asm,v $
; Revision 1.1  2014/02/11 12:59:39  luigidifraia
; Initial revision

; Example loader application for USBhost-64
; (C) 2014 Luigi Di Fraia. All Rights Reserved

; ----
; Boot
; ----

*=$cc00 ; Make sure the loaded file won't get past this address

	; --------------
	; Initialize I/O
	; --------------

	jsr ioinit

	; ---------
	; Load file
	; ---------

	lda #fnamesz	; Prepare filename info
	sta $b7
	lda #<fname
	sta $bb
	lda #>fname
	sta $bc

	jsr fsize	; Retrieve file size
	bcc _loadfile

	lda #<errfsize
	ldy #>errfsize
	jmp $ab1e	; Error getting file size

	jsr floadprg	; Load PRG file
	bcc _done

	lda #<errreadd
	ldy #>errreadd
	jmp $ab1e	; Error reading data from file


; ---------------
; String messages
; ---------------

	.byte $0d,$00

	.byte $0d,$00

; Constants

fname	.asc "DELI.PRG"
fnamesz = * - fname
	.byte $00	; Terminator for screen output purposes (debug mode only)

; ----------
; Inclusions
; ----------

.include fileio.asm

I keep thinking that it is incredible how USBhost-64 has made cross-development and testing on the C64 so much faster for me: I just assemble/compile on a PC, put the PRG on a USB flash drive and feed it into the C64 via USB-BASIC that runs on a cartridge.
I’ve been using this method even for testing new versions of USB-BASIC itself, the new API and my example applications for USBhost-64.

No overhead and no hassle, just plain fast USB disk access 🙂

This entry was posted in Retrocomputing, Technical and tagged , , , , , , , . Bookmark the permalink.

2 Responses to USBhost-64 example loader application

  1. I have ordered an ATmega32u4 that I plan on testing some data transfers directly from PC to the C64. Have you tried parallel transfers to the C64 either through the user port parallel pins or the two joystick ports (which combined can do a full byte)? I am thinking this would be a very quick way of testing code on a real machine but ofc requires some sort of program (perhaps on a cartridge ROM) that can be called to listen for a transfer. I might contact you for some help on wiring as I need to be sure I dont fry the ports of the C64 in my attempts. 🙂

    • luigidifraia says:

      USBhost-64 “parallel” uses the C64 User port in parallel mode in order to achieve a more than decent transfer rate. On the C64 side, a loader burned into an Easy-Flash cartridge is responsible for transferring the data itself. In theory, if your device were to implement the same interface as USBhost-64 towards the C64, then it could re-use my program running on the C64: your device would therefore read/write files from/to a PC instead of using a USB drive. However, if you are going to connect 2 “active” devices together (PC and C64), there’s a whole lot more you can do rather than just read/write files: you could come up with a set of commands to have feature-rich connectivity, e.g. a command to read a sector from the 1541 and send it through to the PC that would enable you to write D64 images on the PC (OK, there are better ways to do that e.g. using ZoomFloppy and the Open CBM tools, but that’s just an example).
      In my case I do that sort of things through my USBhost-64 field applications that run on the C64 and are managed by users directly on the C64 itself as I like that nostalgic feeling 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s