Shop OBEX P1 Docs P2 Docs Learn Events
Console Emulation - Page 15 — Parallax Forums

Console Emulation

1121315171852

Comments

  • pik33pik33 Posts: 2,350

    I managed to run the emulator!

    I tried Sonic3 - the video seems to be OK, audio works, but has (strange) distortions.

  • @pik33 said:
    I managed to run the emulator!

    I tried Sonic3 - the video seems to be OK, audio works, but has (strange) distortions.

    Can I get a recording of that? Note that the sample playback in that game just is distorted (bad sound code)

  • evanhevanh Posts: 15,184

    Ada has some weird monitor. Change it from MODE_VGA3X default to MODE_VGA2X.

  • Oh, yeah. That sounds like the Z80 has issues reading from PSRAM

  • evanhevanh Posts: 15,184

    Oops, I read that as video distortions.

  • Try putting some NOPs between the acquisition of ROM_LOCK and assertion of PSRAM_SELECT (line 5465). Otherwise, really no idea how the Z80 could have read issues when the 68000 isn't.

  • pik33pik33 Posts: 2,350
    edited 2022-03-11 11:35

    @evanh said:
    Oops, I read that as video distortions.

    The video was good (and still is). The audio is not suitable for hearing. I switched it to VGA2x but I didn't notice any important changes. The video now signals 640x480x60 Hz,

  • Wuerfel_21Wuerfel_21 Posts: 4,458
    edited 2022-03-11 12:48

    @Wuerfel_21 said:
    Try putting some NOPs between the acquisition of ROM_LOCK and assertion of PSRAM_SELECT (line 5465). Otherwise, really no idea how the Z80 could have read issues when the 68000 isn't.

    Other thing to try maybe is go to line 2745 and add P_SYNC_IO to the clock pins mode (and then fiddle with PSRAM_DELAY)

  • pik33pik33 Posts: 2,350

    Otherwise, really no idea how the Z80 could have read issues when the 68000 isn't.

    I didn't yet try to apply these suggestions, but the waveform shape suggests that there may be also endianness/nibbles order problem. After I will finish the paperwork I have to do now, I will look at this code once again

  • @pik33 said:

    Otherwise, really no idea how the Z80 could have read issues when the 68000 isn't.

    I didn't yet try to apply these suggestions, but the waveform shape suggests that there may be also endianness/nibbles order problem. After I will finish the paperwork I have to do now, I will look at this code once again

    Certainly not, it works fine here. Must be a hardware/timing problem.

  • pik33pik33 Posts: 2,350

    This helped:

    At line 51

    PSRAM_DELAY = PSRAM_WAIT*2+4

    instead of 3

  • @pik33 said:
    This helped:

    At line 51

    PSRAM_DELAY = PSRAM_WAIT*2+4

    instead of 3

    Good to hear that only delay needs tweaking

  • pik33pik33 Posts: 2,350

    This is a thin border. Add 5 and it doesn't work at all. PSRAM_WAIT=11 doesn't work at all too. It's good that it works. This 4-bit stuff is cheapest and simplest RAM solution for a P2 as it can be, a good amount of working external RAM for $3 - a chip, a breakout board, a 12-pin connector and some PLA for the case.

  • Wuerfel_21Wuerfel_21 Posts: 4,458
    edited 2022-03-11 17:53

    @pik33 said:
    This is a thin border. Add 5 and it doesn't work at all. PSRAM_WAIT=11 doesn't work at all too. It's good that it works. This 4-bit stuff is cheapest and simplest RAM solution for a P2 as it can be, a good amount of working external RAM for $3 - a chip, a breakout board, a 12-pin connector and some PLA for the case.

    Yeah. The data is on the bus for two cycles, so there's exactly one delay setting that samples it on the right cycle (= closest to the center of the eye pattern coming down the bus).

  • pik33pik33 Posts: 2,350

    I am at home now, with the second Eval+PSRAM set - this is slightly (works up to 350 MHz instead of 340) better PSRAM, but the delay add value has still to be 4. I got some more "roms", some of them with .smd" extension - they don't work here (at least the one I tried).

    I don't know this Megadrive console at all. In 1994 I was already a PC user... after an Atari 8bit and Atari ST.

  • @pik33 said:
    I am at home now, with the second Eval+PSRAM set - this is slightly (works up to 350 MHz instead of 340) better PSRAM, but the delay add value has still to be 4. I got some more "roms", some of them with .smd" extension - they don't work here (at least the one I tried).

    SMD format files are from an old dumper device that copied cartridges onto floppies. It's got all the bytes scrambled around... Will be supported when I add the ability to load from SD card, but is unsuitable for directly loading into memory... maybe I can also adjust the loader script to handle in the meantime.

    I don't know this Megadrive console at all. In 1994 I was already a PC user... after an Atari 8bit and Atari ST.

    Wow, it really did come out in 1994 in Poland. That's 6 years late (compared to 1988 japanese launch), lol. Really passed eastern europe by, I guess.

  • pik33pik33 Posts: 2,350
    edited 2022-03-11 19:20

    I am thinking about a SD loader right now - I have already learned how to use the filesystem while writing the player.

    But the first thing I want to do is to connect my RPi keyboard interface, the PC keyboard is way too big.

    In Poland home computing started with the Spectrum, and then 8bit Ataris. A8 was my first computer in 1986. 8-bit Atari scene is still strong here ( https://sillyventure.eu/en/ )

    Then, after 1989, teenagers switched to Amigas. I was no more teenager then, I graduated in 1989 and then I had to have a "real computer" to work, so I had to sell my Atari ST and bought a tin can called PC AT.

  • @pik33 said:
    I am thinking about a SD loader right now - I have already learned how to use the filesystem while writing the player.

    In theory it's easy, I just avoided it until now to make debugging easier. The real pickle is save memory, since that has to be written back to storage at some point, which will tie up the Spin cog for a bit. So I'll have to move control mapping into the USB code itself (which will also be lower latency in the end).

  • So, input handling is now moved entirely to the USB driver.
    The interface for inputs is pretty simple. There's just two words at $40 that the button states need to be written.

  • New preview for the SPCcog (will get own thread when done).
    Now without the crashes and less annoying clicks.
    Still doesn't really work with squaresoft game soundtracks. Love myself some inscrutable CPU core bugs.

  • Wuerfel_21Wuerfel_21 Posts: 4,458
    edited 2022-03-26 21:13

    Working on megayume menu system.

    Works:

    • accessing flexspin's cog-less filesystem from Spin (despite the documentation claiming that it only works in C and BASIC)

      • directory enumerates in FAT order, will have to bring out the ol' reliable filesort algorithm from VentilatorOS
    • setting up the virtual VDP for menu usage

    • rendering ShiftJIS text (have to dynamically render to a buffer so the full (well, it's JIS level 1 only...) font can stay 1bpp)

      • this is needed to display game titles embedded in the ROMs
    • still booting into a game afterwards

  • Well, got a vaguely functioning filechooser put together, now for the hard part, actually getting data into memory

  • Wuerfel_21Wuerfel_21 Posts: 4,458
    edited 2022-03-27 20:10

    While I was at it, I figured out how those silly .SMD rom files work.

    Brought to you by this funny bit of code:

    if smdrom
      i := $3FFF
      org
      .lp
          mov j,i
      .adj
          shr j,#1 wc
          bitnc j,#13
          cmp i,j wc
      if_b jmp #.adj
          add i,dest
          add j,dest
          rdbyte tmp1,i
          rdbyte tmp2,j
          wrbyte tmp2,i
          wrbyte tmp1,j
          sub i,dest
          djnf i,#.lp
      end
    

  • Loading bar... isn't actually loading anywhere, BUT LOOK the bar looks like a lot of tiny ROMs, isn't that cute?

    Also, ROM info display, yay.

    ...

    ...

    I'm procrastinating messing with the memory stuff, aren't I?

  • @Wuerfel_21 said:
    I'm procrastinating messing with the memory stuff, aren't I?

    Maybe you are. Do you have a free COG you can dynamically load my PSRAM or HyperRAM driver into at this time (just for writing the ROM to external RAM from SD), so you don't have to expend more effort to write another set of drivers that can write to all the different memory types?

  • @rogloh said:

    @Wuerfel_21 said:
    I'm procrastinating messing with the memory stuff, aren't I?

    Maybe you are. Do you have a free COG you can dynamically load my PSRAM or HyperRAM driver into at this time (just for writing the ROM to external RAM from SD), so you don't have to expend more effort to write another set of drivers that can write to all the different memory types?

    Now that you say it.. yes, I could likely just do that.

  • roglohrogloh Posts: 5,157
    edited 2022-03-28 01:31

    It would probably be the fastest way to make progress on it. You could potentially just use the driver's raw PASM2 component and just pass its HW setup variables correctly at COG startup time if memory is tight. The outer SPIN2 API can be always be removed/reduced to free space. Then you copy the memory, kill the driver COG once copied, and start your own emulator program.

  • So, uhh, memory amiright.
    @rogloh
    Uhm, is this right? It seems to start up correctly, but all the data gets garbled (I'm trying with PSRAM4 right now).

    PRI exmem_start() | tmp,cogs,banks
    
    tmp := __builtin_alloca(8*4)
    cogs := __builtin_alloca(8*4)
    banks := __builtin_alloca(32*4)
    
    if exmem_cog
      exmem_stop()
    
    long[tmp][0] := clkfreq
    long[tmp][1] := 1<<exmem.UNREGCLK_BIT
    #ifdef USE_HYPER
    long[tmp][2] := HYPER_RESET < 32 ? 1<<HYPER_RESET : 0
    long[tmp][3] := HYPER_RESET >= 32 ? 1<<HYPER_RESET : 0
    #else
    long[tmp][2] := 0
    long[tmp][3] := 0 
    #endif
    
    #ifdef USE_PSRAM16
    long[tmp][4] := PSRAM_BASE
    #elseifdef USE_PSRAM4
    long[tmp][4] := PSRAM_BASE
    #elseifdef USE_HYPER
    long[tmp][4] := HYPER_BASE
    #endif
    long[tmp][5] := banks
    long[tmp][6] := cogs
    long[tmp][7] := @exmem_mailbox[0]
    
    long[cogs][0]:=-1<<16 + %1_111<<12
    longfill(cogs+4,-1<<16,7)
    longfill(banks,negx,32)
    
    #ifdef USE_PSRAM16
    long[banks][0] := 512<<16 + PSRAM_DELAY<<13 + 1<<12 + 22
    long[banks][16] := PSRAM_SELECT + PSRAM_CLK<<8
    #elseifdef USE_PSRAM4
    long[banks][0] := 128<<16 + PSRAM_DELAY<<13 + 1<<12 + 22
    long[banks][16] := PSRAM_SELECT + PSRAM_CLK<<8
    #elseifdef USE_HYPER
    long[banks][0] := 128<<16 + HYPER_DELAY<<13 + 1<<12 + 22
    long[banks][16] := HYPER_SELECT + HYPER_CLK<<8 + HYPER_RWDS<<16 + 6<<25 ' Latency????
    #endif
    
    exmem_mailbox[0] := -1
    cogs := exmem.getDriverAddr()
    exmem_cog := coginit(COGEXEC_NEW,cogs,tmp)
    repeat while exmem_mailbox[0] ' wait for init so data structures can go dead
    
    PRI exmem_stop()
    if exmem_cog
      exmem_sync()
      cogstop(exmem_cog)
    
    PRI exmem_sync()
    repeat while exmem_mailbox[0]
    
    PRI exmem_write(dst,src,length,async)
    exmem_sync()
    exmem_mailbox[2] := length
    exmem_mailbox[1] := src
    exmem_mailbox[0] := exmem.R_WRITEBURST + (dst & $fffffff)
    ifnot async
      exmem_sync()
    
    PRI exmem_fill(dst,val,length,async)
    exmem_sync()
    exmem_mailbox[2] := length
    exmem_mailbox[1] := val
    exmem_mailbox[0] := exmem.R_WRITEBYTE + (dst & $fffffff)
    ifnot async
      exmem_sync()
    
    PRI exmem_read(dst,src,length,async)
    exmem_sync()
    exmem_mailbox[2] := length
    exmem_mailbox[1] := dst
    exmem_mailbox[0] := exmem.R_READBURST + (src & $fffffff)
    ifnot async
      exmem_sync()
    
    
  • Wuerfel_21Wuerfel_21 Posts: 4,458
    edited 2022-03-29 00:00

    Hmm, if I increment the delay value by one, it seems to work. Weird, but ok I'll take it.

    EDIT: Wait no it still doesn't

    EDIT 2: Wait no it actually does work I just didn't offset the addresses right

    EDIT 3: Still doesn't seem right, only boots to red screen of death (SEGA's init code detects checksum error)

Sign In or Register to comment.