Image Map Image Map
Results 1 to 2 of 2

Thread: Moving ASCII asm source onto an Apple II disk image

  1. #1

    Default Moving ASCII asm source onto an Apple II disk image

    Hello,

    I am learning Apple II programming and I was wondering what the best way is to move an asm source file from a computer onto a disk image that I can load in GSPort. In my case the source is a PowerBook G4 running OS X 10.5, but also have access to Intel x64 running Windows 7 and Windows 10.

    The specific issue is that on modern computers, characters in ASCII text files seem to have a MSB of 0, where the Apple II is expecting a MSB of 1. On the Mac, a comment '*' is 2Ah, but on the IIGS it is AAh.

    How do I perform this conversion? I have used AppleCommander (Mac) and CiderPress (Windows), and it converts from "high ascii" to the standard format, but I can't find how to convert the other way.

    Thanks in advance!

  2. #2

    Default

    Well, I went ahead and wrote a quick java converter that seems to work if it helps anyone else. Turns out the line breaks were the biggest deal, and I had to leave the tabs/spaces alone. I'd be interested in seeing how others solved this...

    Code:
    package your.package.here;
    
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    class ToAII {
    
        public static void main(String[] args) {
    
            if(args == null || args.length < 2) {
                System.out.println("Usage: ToAII [input] [output]");
                return;
            }
    
            FileInputStream fis = null;
            FileOutputStream fos = null;
    
            try {
    
                File inFile = new File(args[0]);
    
                if(!inFile.exists()) {
                    System.out.println(
                        String.format("File %s not found.",args[0]));
                    
                    return;
                }
    
                File outFile = new File(args[1]);
    
                if(outFile.exists()) {
                    outFile.delete();
                }
    
                outFile.createNewFile();
    
                fis = new FileInputStream(inFile);
                fos = new FileOutputStream(outFile);
    
                int value;
    
                while((value = fis.read()) > -1) {
    
                    if(value == 0x09
                           || value == 0x89) {
                        value = 0xA0;
                    } else if(value == 0x20) {
                        value = 0x20;
                    } else if(value == 0xA0) {
                        value = 0xA0;
                    } else if(value == 0x8A
                           || value == 0x0A) {
                        value = 0x8D;
                    } else if(value < 0x80) {
                        value += 0x80;
                    }
                 
                    fos.write(value);
                }
    
    	} catch(Exception e) {
                e.printStackTrace();
            } finally {
                if(fis != null) {
                    try {fis.close();} catch(IOException e1) {}
                }
    
                if(fos != null) {
                    try {fos.close();} catch(IOException e2) {}
                }
            }
        }
    
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •