CPCWiki forum

General Category => Emulators => Topic started by: Devilmarkus on 18:28, 20 December 10

Title: Hi-Speed Autotype-test
Post by: Devilmarkus on 18:28, 20 December 10
Hello together,
I just had the idea to POKE autotype strings into CPC's keyboard buffer and so send it to CPC screen.

The positive aspect is:
- The autotype speed is enormous!

The negative aspect is:
- Works only in BASIC / when BASIC's keyboard buffer is used
- Different addresses for 464 and 6128 roms

Perhaps someone knows a all-in-one solution for that?

I split the string into an array splitted by ENTER char.
This array I send line-by-line into the keyboard buffer and when sent, I press the "Enter" key.
I release the enter key a few VSYNCs later and continue with the next line.

Example: (I just used JEMU but it's possible in every emulator!)
(http://retropower.eu/typetext.gif)
Title: Re: Hi-Speed Autotype-test
Post by: Devilmarkus on 19:39, 20 December 10
BTW.: I had no turbo function enabled!
With a turbo (300% speed) it works like this:
(http://retropower.eu/turbotype.gif)

Here's the code I added to JEMU:

    public void vSync() {
        if (basictypelength != -1) {
            basicchecktype++;
            if (basicchecktype == 1) {
                BasicAutoType();
            }
            if (basicchecktype == 2) {
                keyboard.keyReleased(KeyEvent.VK_ENTER);
            }
            if (memory.readByte(BUFFER_START) == 0) {
                basicchecktype = 0;
            }
        }
        if (frameSkip == 0) {
            display.updateImage(true);
        }
        syncProcessor(psg.getSoundPlayer());
    }
    String[] basictypetext;
    int basictypelength = -1;
    int basicchecktype = 0;
    int basictypepos = 0;
    protected int BUFFER_START = 0xac8a;
    protected int BUFFER_START_6128 = 0xac8a;
    protected int BUFFER_START_464 = 0xaca4;

    public void BasicAutoType(String input) {
        input = input.replace("" + (char) 0x0d, "");
        basictypetext = input.split("" + (char) 10);
        basictypelength = basictypetext.length - 1;
        basictypepos = 0;
    }

    public void BasicAutoType() {
        if (basictypetext == null) {
            basictypelength = -1;
            return;
        }
        if (basictypepos > basictypelength) {
            basictypepos = 0;
            basictypelength = -1;
            basictypetext = null;
            return;
        }
        BasicPutText(basictypetext[basictypepos++]);
    }

    public void BasicPutText(String input) {
        if (input.length() > 255) {
            return;
        }
        for (int i = 0; i < 255; i++) {
            memory.writeByte(BUFFER_START + i, 0);
        }
        for (int i = 0; i < input.length(); i++) {
            memory.writeByte(BUFFER_START + i, (int) input.charAt(i));
        }
        keyboard.keyPressed(KeyEvent.VK_ENTER);
        basicchecktype = 1;
    }
Title: Re: Hi-Speed Autotype-test
Post by: Gryzor on 09:48, 23 December 10
Turbo is cheating :D But it's really fast indeed. The method is clever too - what's the mem limit?
Title: Re: Hi-Speed Autotype-test
Post by: Devilmarkus on 18:46, 23 December 10
Quote from: Gryzor on 09:48, 23 December 10
Turbo is cheating :D But it's really fast indeed. The method is clever too - what's the mem limit?

Logically the basic memory incl. linenumbers...
And each line of text can only have 255 chars max.
(Like CPC text input from basic interpreter)
Powered by SMFPacks Menu Editor Mod