[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New feature coming: Thunderclock Pro support



On Wednesday, December 12, 2012 7:53:49 PM UTC-6, BLuRry wrote:
> I have successfully implemented Thunderclock Pro support for Jace.  The sourceforge build doesn't have this yet, but I have checked in the source code for the impatient armed with java compilers.
> 
> 
> 
> Just clock support wasn't sufficient (I'm really picky), I have also written a patcher for that darn Prodos year issue that everyone always complains about:
> 
> 
> 
>     private void performProdosPatch() {
> 
>         PagedMemory ram = Computer.getComputer().getMemory().activeRead;
> 
>         if (patchLoc > 0) {
> 
>             // We've already patched, just validate
> 
>             if (ram.readByte(patchLoc) == (byte) MOS65C02.OPCODE.LDA_IMM.getCode()) {
> 
>                 return;
> 
>             }
> 
>         }
> 
>         int match = 0;
> 
>         int matchStart = 0;
> 
>         for (int addr = 0x08000; addr < 0x010000; addr++) {
> 
>             if (ram.readByte(addr) == DRIVER_PATTERN[match]) {
> 
>                 match++;
> 
>                 if (match == DRIVER_PATTERN.length) break;
> 
>             } else {
> 
>                 match = 0;
> 
>                 matchStart = addr;
> 
>             }            
> 
>         }
> 
>         if (match != DRIVER_PATTERN.length) {
> 
>             return;
> 
>         }
> 
>         patchLoc = matchStart + DRIVER_OFFSET;
> 
>         ram.writeByte(patchLoc, (byte) MOS65C02.OPCODE.LDA_IMM.getCode());
> 
>         int year = Calendar.getInstance().get(Calendar.YEAR) % 100;
> 
>         ram.writeByte(patchLoc+1, (byte) year);
> 
>         ram.writeByte(patchLoc+2, (byte) MOS65C02.OPCODE.NOP.getCode());
> 
>         ram.writeByte(patchLoc+3, (byte) MOS65C02.OPCODE.NOP.getCode());
> 
>     }
> 
> 
> 
> This patch scans the active memory of the emulator for a very obvious signature of data found in the prodos clock driver which has never changed.  The driver itself moves around in the prodos kernel, so scanning for a signature seemed the most prudent way to find it.  Once I find the driver code, I patch the part that loads the year from a lookup table with:
> 
>   LDA #year%100
> 
>   NOP
> 
>   NOP
> 
> 
> 
> This will work until the end of time.  Or at least for the next 9 days.  At least the Apple calendar won't run out of time anymore (silly Mayans.)  
> 
> 
> 
> -B

Correction: Thunderclock PLUS -- not PRO.  Sorry about the confusion there.  I also forgot to mention I did not implement the interrupt part of the card -- if that's even a hardware feature.  Does anything important use that feature?

-B