News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

JavaCPC Desktop available as BETA!

Started by Devilmarkus, 22:46, 25 December 09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

#100
Grrrrrr this snp format makes me mad!
Recording works about 95% accurate...
Playback is about 89% accurate!

Grrrrrrrrrrr!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Executioner

Quote from: Devilmarkus on 18:55, 28 May 10
Grrrrrr this snp format makes me mad!
Recording works about 95% accurate...
Playback is about 89% accurate!

That's why I created the much more complex SNR format. Starts with a V3 snapshot and has various cycle level checks.

Devilmarkus

Quote from: Executioner on 01:27, 29 May 10
That's why I created the much more complex SNR format. Starts with a V3 snapshot and has various cycle level checks.

Any docs about this format?
Would be cool to know how it works... ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Executioner

#103
Quote from: Devilmarkus on 16:34, 30 May 10
Any docs about this format?
Would be cool to know how it works... ;)

Err... Not really complete. There is a document on the initial SNA Version 3 format here

And then the format is very similar to the SNP format but with some extras. I'll have to hunt for any documentation, or failing that analyse the source code to create it.

Here's the headers from WinAPE which define the SNA V3 format:


  { TODO: Save Disc Image names, active ROMs, CPC Plus Raster Int flag }
  { TODO: PS2 Mouse X/Y and Button states in SNR }

const
  HeaderSNA: String = 'MV - SNA';
  HeaderSNP: String = 'MV - SNP';
  HeaderSNR: String = 'RW - SNR';

  CRTC_FLAG_VSYNC_ACTIVE    = $01;
  CRTC_FLAG_HSYNC_ACTIVE    = $02;
  CRTC_FLAG_HDISP_INACTIVE  = $04;
  CRTC_FLAG_VDISP_INACTIVE  = $08;
  CRTC_FLAG_HTOT_REACHED    = $10;
  CRTC_FLAG_VTOT_REACHED    = $20;
  CRTC_FLAG_MAXIMUM_RASTER_COUNT_REACHED = $40;
  CRTC_FLAG_REG8_BLANKING   = $80;

  CRTC_FLAG_VTA_ACTIVE   = $100;
  CRTC_FLAG_WINAPE_ICSR  = $8000;

  SFormatInvalid: String = 'Snapshot format invalid';
 
type
  TSnapshotType = (SNA, SNR, SNP);

  TBankFlag = (c0, c4c7, cccf, d4d7, dcdf, e4e7, ecef, f4f7, fcff);
  TBankFlags = set of TBankFlag;

  TChunkFlag = ( cfROMs, cfDSCA, cfDSCB, cfBreaks, cfDataAreas );
  TChunkFlags = set of TChunkFlag;

  TSnapshotHeader = packed record
    SnapshotID: packed array[0..7] of char;
    pad0            : packed array[0..7] of char;

    Version: Byte;

    {Registers}
    REG_AF,REG_BC,REG_DE,REG_HL: word;
    REG_R,REG_I,REG_IFF0,REG_IFF1: byte;
    REG_IX,REG_IY,REG_SP,REG_PC: word;
    REG_IM: byte;
    REG_AF1,REG_BC1,REG_DE1,REG_HL1: word;

    GA_Pen: byte;
    GA_Inks: packed array[0..16] of byte;
    GA_ROM, GA_RAM: byte;

    CRTC_Reg: byte;
    CRTC_Regs: packed array [0..17] of byte;

    UpperRom: byte;

    PIO_A,PIO_B,PIO_C,PIO_Control: byte;

    PSG_Reg: byte;
    PSG_Regs: packed array[0..15] of byte;

    MemSize: word;

    CPCType: byte;

    InterruptNo: byte;                     // CPCEMU only
    MultiMode: packed array[0..5] of byte; // CPCEMU only

    // Version 3 only
    Empty1: packed array[$75..$9a] of byte;

    FDD_Fast: Boolean;
    FDD_Motor: Boolean;
    FDD_Cyl: packed array[0..3] of byte;

    Printer_Data: byte;

    Monitor_Line: SmallInt;

    CRTC_Type: byte;

    Empty3: packed array [$a5..$a8] of byte;

    CRTC_HCC: byte;

    Empty4: byte;

    CRTC_VCC: byte;
    CRTC_VLC: byte;
    CRTC_VTAC: byte;
    CRTC_HSYNC: byte;
    CRTC_VSYNC: byte;
    CRTC_Flags: word;

    GA_DelayCount: byte;
    GA_ScanCount: byte;
    Z80_IntStat: byte;
    Z80_ICSR: byte;

    DisablePlus: Boolean;
    PlusPPI: Boolean;
    Empty5: packed array [$b8..$df] of byte;

    EmulatorID: packed array [$e0..$ff] of char;
  end;

  TDMARegs = packed record
    Loop: Word;
    Addr: Word;
    Pause: Word;
    PreScale: byte;
  end;

  TPlusChunk = packed record
    SpriteData: packed array [0..$7ff] of byte;
    SpriteAtts: packed array [0..$7f] of byte;
    Palette: packed array [0..$3f] of byte;
    Regs: packed array [0..5] of byte;
    SecROM: Word;
    Analogue: packed array [$08..$0f] of byte;
    DMA: packed array [0..$f] of byte;
    DMARegs: packed array [0..2] of TDMARegs;
    GA_Last: byte;
    GA_UnLocked: byte;
    GA_Sequence: byte;
  end;


The SNR file can contain RIFF sections defining the Disk images and ROM   images active at the time of recording.
The SNR file ends with an SNR RIFF chunk (ID: 'SNR '). This contains all the keystrokes and timing information as well as Symbiface Mouse and RTC information. The following constants are used to define the ID's of these:


  { Mouse Bits for SNR recording }
  SNR_MOUSE = $80;
  SNR_MB    = $01;
  SNR_MX    = $60;
  SNR_MX_B  = $20;
  SNR_MX_W  = $40;
  SNR_MY    = $18;
  SNR_MY_B  = $08;
  SNR_MY_W  = $10;
  SNR_MW    = $06;
  SNR_MW_B  = $02;
  SNR_MW_W  = $04;

  { Real-Time Clock IDs }
  SNR_RTC   = $E0;
  SNR_MIN   = $E1;
  SNR_HR    = $E2;
  SNR_DAY   = $E3;
  SNR_MTH   = $E4;
  SNR_YR    = $E5;
  SNR_MIL   = $E6;


The actual SNR format is quite complicated due to limitations of the original SNP format and the work-arounds to get it accurate.  This is by no means complete, but I think it's something along the lines of:

Count (Byte) - Number of frames until next change or 00. If 00, then a further word is used to indicate the number of frames. For example:

05 = 5 frames.
00 01 02 = 513 frames.

After that number of frames has passed, the next byte is read (the block length specifier (BLS)). Bit 7 (and #80) determines if there is a synchronisation block. If this is set, the following data (bytes) are contained in the synch block:

+0: Least significant byte of current Z80 PC (Program Counter)
+1: Vertical Line Count of CRTC.
+2: Horizontal Character Count of CRTC.
+3: Least significant byte of the TotalCycles counter (always reset to zero at the start of the SNR file snapshot).

The following 7 bits of the BLS define the number of bytes that follow unless they are all 1 (ie. BLS and #7f == #7f). This has a special meaning, which is to repeat the same changes as the last frame.

Each byte following for (BLS and #7f bytes) represents either a key number or a Mouse or RTC update.

If the byte (call it CHG) is E0..FF it is treated as an RTC update. The number of following bytes is (CHG and #1F) + 1, so, if CHG is SNR_RTC (#E0) only the RTC second is updated (1 following byte), if CHG is SNR_DAY (#E4), the RTC second, minute, hour, day and day of week is updated. The Day of Week is the fourth byte and #07, the Day (1..31) is the same byte SHL 3 (div 8) .

If the CHG is #80 .. #df it is treated as a Mouse Update.
- If (CHG and SNR_MB) <> 0 the Mouse Button byte is read.
- If (CHG and SNR_MX) <> 0 the Mouse X position is updated (if (CHG and SNR_MX_W) then it's a word else a byte).
- If (CHG and SNR_MY) <> 0 the Mouse Y position is updated (if (CHG and SNR_MY_W) then it's a word else a byte).
- If (CHG and SNR_MW) <> 0 the Mouse Wheel position is updated. (if (CHG and SNR_MW_W) then it's a word else a byte).

...

And that's all there is to it. Really simple eh !

Cheers,
Richard

P.S. I would make a Wiki page about the SNR format from this post but I'm useless at Wiki code and I don't have much time. Anyone else feel free to do so.

Executioner

If you're really astute, you may have noticed that the Mouse and RTC messages overlap. ie. If the SNR_MOUSE (#80), SNR_MX_W (#40) and SNR_MX_B (#20) were all set, then the value would be #E0..#FF. Fortunately, the Mouse X can only be either a Byte (SNR_MX_B) or a Word (SNR_MX_W) so this will never happen, but the SNR processing code MUST ALWAYS check for SNR_RTC first, then not process it as a Mouse change if this is the case.

Devilmarkus

Working on lightgun emulation:
http://cpc-live.com/lightgun

If someone could help me to improve that, please contact me.
It's done checking x,y RGB value, then comparing them to some further frames painted and if they are different and not black:
Fire!

But need more accuracy here...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor


Devilmarkus

The technic is quite simple:
When you trigger fire on lightgun:
Joy-Fire is send to CPC.
The screen turns black for about 1 frame.
Next frame a bright square is painted where a target has been.
When lightgun sensor detects this bright colour, it sends Joy-Fire and Joy-Down signal to CPC.
When your lightgun was over a 2nd target:
Bright square is removed in next frame and a 2nd is painted where the 2nd target has been.
When lightgun detects this frame now it sends Joy-Fire and Joy-Down signal to CPC.

Really simple technic in theory.
But not simple to handle (actually)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

No - you're explaining how the light gun works, but I knew this. What I'm asking is, how do you use it in an emulator? What's the use?

Devilmarkus

To play games which were designed for lightgun? ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Cpcmaniaco


Gryzor

Quote from: Devilmarkus on 08:32, 22 June 10
To play games which were designed for lightgun? ;)

Yes, but how?? You'd need a light gun. A CPC light gun or a PC one? And then, you'd need a CRT screen. So, I'm still a bit skeptical about the practical use of it!

Devilmarkus

Quote from: Gryzor on 07:59, 23 June 10
Yes, but how?? You'd need a light gun. A CPC light gun or a PC one? And then, you'd need a CRT screen. So, I'm still a bit skeptical about the practical use of it!

Well in JavaCPC the lightgun is replaced by a crossfade mouse cursor. You can use your mouse to aim and shoot. That's it.

In theoretical the lightgun should also work on a CRT screen!
It uses a light sensor to detect targets.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

Ah! So you use the mouse. Ok then, now it's clear, though it'll make light gun games extremely easy I guess??

Devilmarkus

#114
Well, yes.
But it's easier to install Windows XP on a CPC 464...
This has all drivers (incl. lightgun plug & pray)


When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Bryce

The drivers are on Cassettes 241 to 318 as far as I recall :D

Bryce.

arnoldemu

Quote from: Bryce on 15:17, 23 June 10
The drivers are on Cassettes 241 to 318 as far as I recall :D

Bryce.
Please upload cassette 400 I am missing that one ;)
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Leonie

Quote from: arnoldemu on 15:47, 23 June 10
Please upload cassette 400 I am missing that one ;)

Just play cassette 200 with Double-Speed backwards.
The resulting data is the same as on cassette 400.



Devilmarkus

Quote from: Leonie on 17:54, 23 June 10

Just play cassette 200 with Double-Speed backwards.
The resulting data is the same as on cassette 400.

Good idea!

In co-operation with Loic Daneels I added command-line arguments.
This will be the syntax:

Possible arguments:
-amsdos <yes/no>
-autotype <"text">
-boot <drive>
-cpctype <cpctype>
-crtc <1 or 0>
-desktop <yes/no>
-drivea <"file">
-driveb <"file">
-tape <"file">

Example for Windows:
JavaCPC.exe -desktop yes -cpctype SYMBOS -drivea "SymbOS.DSK" -driveb "Sym-Apps.DSK" -autotype "|SYM" -amsdos yes
Example for other OS:
java -jar JavaCPC.jar -desktop no -cpctype SYMBOS -drivea "G:\CPC\SymbOS.DSK" -driveb "G:\CPC\Sym-Apps.DSK" -autotype "|SYM" -amsdos yes

Valid cpctypes:
CPC464        CPC464
CPC664        CPC664
CPC6128        CPC6128
SYMBOS        CPC6128 with SymbOS
FUTUREOS    CPC6128 with Future OS
KCCOMPACT    KC COMPACT
CPC464PARA    CPC464 with PARADOS rom
PARADOS        CPC6128 with PARADOS rom
CPC6128fr    CPC6128 with french roms
CPC6128es    CPC6128 with spanish roms
COMCPC        ;-)

Example for "-boot" argument:
-boot df0
-boot tape


If someone is interested in testing this, please contact me for new beta version...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Latest beta is here:
http://retropower.eu/cpc/download.php?type=-emu&fichier=2010_06_28_JavaCPC_Desktop_BETA.zip

Much fun with it!
(Tested under Windows and Mac OS!)
Windows 7 user must run it with administrator rights! 32bit Java is appreciated.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

It managed to crash my work PC this morning :D Tho it's probably not its fault but the PC's or Java's...

Devilmarkus

So you can be happy that it causes serious crashes to your PC ;)

Check here for updates:
http://retropower.eu/cpc/index.php?dir=-emu

You will see my updated zips on top.
Check the creation date and so you can always try the latest beta.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Working on an "Effectmixer" for JavaCPC-Paint.
It will help you to get the best possible results from converting a photo or an image to CPC.

Example:
Not optimized:


The Effectmixer in action:


Optimized result:
 
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

#123
Demonstration:
[youtube=9I1fdpej2SM]demo[/youtube]
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Best: Combine the filters + use the MovieMaker:
[youtube=Vv1DG1TN1eg]video[/youtube]
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Powered by SMFPacks Menu Editor Mod