From 3344178693c5de443120fae194837e434ac0d575 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 5 May 2019 11:01:58 +0300 Subject: [PATCH] stateload updates --- utilities/stateload/asm.S | 6 ++--- utilities/stateload/main.c | 45 ++++++++++++++++++++++++++-------- utilities/stateload/makefile | 2 +- utilities/stateload/readme.txt | 15 +++++++++++- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/utilities/stateload/asm.S b/utilities/stateload/asm.S index 3a0e7e75..874110f0 100644 --- a/utilities/stateload/asm.S +++ b/utilities/stateload/asm.S @@ -70,12 +70,12 @@ _runit: lsr.l #8,d0 and.w #511,d0 cmp.w #258,d0 - bne.s .wait1 + bne .wait1 .wait2: move.l 4(a6),d0 lsr.l #8,d0 and.w #511,d0 - bne.s .wait2 + bne .wait2 | restore possible side-effect causing | custom bits as late as possible @@ -112,7 +112,7 @@ _runit: movec d0,SFC move.l (a1)+,d0 movec d0,VBR - move.w #0x0020,-(sp) + move.w #0x0020,-(sp) | Format 0, Trap #0 .cpu68000 : move.l 4+4+60(a0),-(sp) | PC move.w 4+4+60+4+2+2+4+4(a0),-(sp) | SR diff --git a/utilities/stateload/main.c b/utilities/stateload/main.c index 8a364eda..c8363ee2 100644 --- a/utilities/stateload/main.c +++ b/utilities/stateload/main.c @@ -2,6 +2,8 @@ /* Real hardware UAE state file loader */ /* Copyright 2019 Toni Wilen */ +#define VER "0.2" + #include #include #include @@ -22,6 +24,8 @@ extern struct GfxBase *GfxBase; extern struct DosLibrary *DosBase; +static const UBYTE *const version = "$VER: uaestateload " VER " (" REVDATE ")"; + static const char *const chunknames[] = { "ASF ", @@ -37,7 +41,16 @@ static const char *const memchunknames[] = "CRAM", "BRAM", "FRAM", NULL }; - +static const char *const unsupportedchunknames[] = +{ + "FRA2", "FRA3", "FRA4", + "ZRA2", "ZRA3", "ZRA4", + "ZCRM", "PRAM", + "A3K1", "A3K2", + "BORO", "P96 ", + "FSYS", + NULL +}; static ULONG getlong(UBYTE *chunk, int offset) { @@ -68,10 +81,13 @@ static void set_agacolor(UBYTE *p) for (int k = 0; k < 2; k++) { c->bplcon3 = (i << 13) | (k ? (1 << 9) : 0); for (int j = 0; j < 32; j++) { - ULONG c32 = getlong(p, j * 4); - if (k) + ULONG c32 = getlong(p, (j + i * 32) * 4); + if (!k) c32 >>= 4; + // R1R2G1G2B1B2 -> R2G2B2 UWORD col = ((c32 & 0x00000f) << 0) | ((c32 & 0x000f00) >> 4) | ((c32 & 0x0f0000) >> 8); + if (!k && (c32 & 0x80000000)) + col |= 0x8000; // genlock transparency bit c->color[j] = col; } } @@ -101,7 +117,7 @@ static void step_floppy(void) // delay ciab->ciaprb &= ~CIAF_DSKSTEP; ciab->ciaprb |= CIAF_DSKSTEP; - wait_lines(300); + wait_lines(200); } static void set_floppy(UBYTE *p, ULONG num) @@ -291,7 +307,7 @@ void set_cia_final(UBYTE *p, ULONG num) UBYTE dummy = cia->ciaicr; cia->ciacra = p[14] & ~CIACRAF_LOAD; cia->ciacrb = p[15] & ~CIACRBF_LOAD; - cia->ciaicr = p[13] | CIAICRF_SETCLR; + cia->ciaicr = p[16] | CIAICRF_SETCLR; } static void free_allocations(struct uaestate *st) @@ -472,6 +488,14 @@ static UBYTE *read_chunk(FILE *f, UBYTE *cname, ULONG *sizep, ULONG *flagsp, str return NULL; ULONG maxsize = 0x7fffffff; + + for (int i = 0; unsupportedchunknames[i]; i++) { + if (!strcmp(cname, unsupportedchunknames[i])) { + printf("Unsupported chunk '%s', %lu bytes, flags %08x.\n", cname, size, flags); + return NULL; + } + } + int found = 0; for (int i = 0; chunknames[i]; i++) { if (!strcmp(cname, chunknames[i])) { @@ -627,8 +651,8 @@ static void check_rom(UBYTE *p, struct uaestate *st) while (*path++); printf("ROM %08lx-%08lx %d.%d (CRC=%08x).\n", start, start + len - 1, ver, rev, crc32); - printf("- '%s'\n", path); if (ver != rver || rev != rrev) { + printf("- '%s'\n", path); printf("WARNING: KS ROM version mismatch.\n"); } } @@ -731,8 +755,8 @@ static int parse_pass_1(FILE *f, struct uaestate *st) if (smodel != model) { printf("- WARNING: %lu CPU statefile.\n", model); } - if (model > 68020) { - printf("- ERROR: Only 68000/68010/68020 statefiles are supported.\n"); + if (model > 68030) { + printf("- ERROR: Only 68000/68010/68020/68030 statefiles are supported.\n"); st->errors++; } } else if (!strcmp(cname, "CHIP")) { @@ -745,7 +769,7 @@ static int parse_pass_1(FILE *f, struct uaestate *st) int saga = (svposr & 0x0f00) == 0x0300; int secs = (svposr & 0x2000) == 0x2000; int sntsc = (svposr & 0x1000) == 0x1000; - printf("Chipset: %s %s (%04X).\n", aga ? "AGA" : (ecs ? "ECS" : "OCS"), ntsc ? "NTSC" : "PAL", vposr); + printf("Chipset: %s %s (0x%04X).\n", aga ? "AGA" : (ecs ? "ECS" : "OCS"), ntsc ? "NTSC" : "PAL", vposr); if (aga && !saga) { printf("- WARNING: AGA statefile.\n"); } @@ -932,8 +956,9 @@ int main(int argc, char *argv[]) UBYTE cname[5]; struct uaestate *st; + printf("uaestateload v" VER " (" REVTIME " " REVDATE ")\n"); if (argc < 2) { - printf("Statefile parameter missing.\n"); + printf("Syntax: uaestateload .\n"); return 0; } diff --git a/utilities/stateload/makefile b/utilities/stateload/makefile index 8162c615..71a3d1db 100644 --- a/utilities/stateload/makefile +++ b/utilities/stateload/makefile @@ -5,7 +5,7 @@ NOWTIME := "\"$(shell date "+%T")\"" CC=/opt/amiga/bin/m68k-amigaos-gcc AS=/opt/amiga/bin/m68k-amigaos-as -CFLAGS = -mcrt=nix13 -Os -m68000 -fomit-frame-pointer -msmall-code +CFLAGS = -mcrt=nix13 -Os -m68000 -fomit-frame-pointer -msmall-code -DREVDATE=$(NOWDATE) -DREVTIME=$(NOWTIME) LINK_CFLAGS = -mcrt=nix13 -s OBJS = main.o asm.o inflate.o diff --git a/utilities/stateload/readme.txt b/utilities/stateload/readme.txt index a2dd7610..f8f11155 100644 --- a/utilities/stateload/readme.txt +++ b/utilities/stateload/readme.txt @@ -1,7 +1,10 @@ uaestateload: load UAE state files on real hardware. -Currently common 68000 A500 statefiles are supported. (512k chip only, 512k+512k etc..) +Supported hardware configurations: + +- Common 68000 A500 configurations. (chip ram, slow ram and fast ram supported) +- A1200 68020 configuration (fast ram is also supported) Information: @@ -20,3 +23,13 @@ RAM config examples: 512k+512k statefile: hardware must have 1M+512k or 512k+1M or 512k+512k+512k real fast. Note that uncompressed statefiles require at least 1M contiguous extra RAM because all statefile RAM address spaces need to fit in RAM before system take over. + +A1200 chip ram only statefiles require at least 1M fast ram. + +Background colors: + +- red = decompressing/copying chip ram state +- green = decompressing/copying slow ram state +- blue = decompressing/coping fast ram (0x00200000) state +- yellow = setting floppy drives (seek rw head) + -- 2.47.3