Videopac / Odyssey2 forum
September 22, 2018, 09:33:54 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: If you have some news and you want it to be shown here, pm Janzl!
 
   Home   arcade Help Login Register links videopac.nl  
Pages: [1] 2 3 4   Go Down
  Print  
Author Topic: mbed emulating a ROM cartridge  (Read 11771 times)
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« on: December 07, 2011, 12:09:25 AM »

Whoa, it works !

The mbed is emulating a rom cartridge without any extra hardware.
I am running out of address/bank select pins though. The LPCxpresso has extra IO so that will be the better (and cheaper) candidate But still... It works..

On the two (crappy) photo's you can see the mbed connected directly to the cartridge port of a G7000 board and it starts up with the select game screen and Omega Race is running (second photo).
I did fell into the trap of the swapped A6 and A7 lines (A5=M, A6=P and A7=N )

The mbed is running in a rather tight loop just checking if PSEN drops, then reads out the G7000 addressbus and emits a byte from the stored rom image onto the data bus, then waits for PSEN to go high again and releases the databus again. Because of the pin connections on the mbed I have to 'connect' the bits of three IO ports into a single address.

This means it is possible to store a bunch of cartridges on the 2 MB flash of the mbed (or maybe USB stick as the second USB port is still available on the mbed) and create some sort of menu.  
« Last Edit: May 22, 2012, 07:37:40 AM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #1 on: December 07, 2011, 12:09:56 AM »

second photo

The mbed is sitting on the LPCxpresso breadboard and is powered by the cartridge port, the only hardware added is a bunch of 100 ohm resistors in series with all the Videopacs address and datalines (just to be safe).
« Last Edit: May 22, 2012, 07:38:09 AM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #2 on: December 07, 2011, 09:54:32 PM »

This is the timing of the mbed responding to the 8048 PSEN line (top line is PSEN, bottom line is a data bit).

On the left is a 'zero' bit returned to the 8048 on the rising edge of PSEN, on the right a 'one' bit.

The interrupt latency of the standard mbed routines is what I have to improve, found already some ideas to make that better. If I can get the mbed to handle the rom emulation from within a high priority interrupt it should free the rest of the cycles to do other things like emulating the Voice or the Chess/Basic box...


« Last Edit: May 26, 2012, 11:05:39 PM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #3 on: December 12, 2011, 10:07:44 PM »

Shuffled some port pins around and got interrupts on PSEN working with sufficient little overhead.
Here is Smithereens running, a 4k cart image with bankswitching (I dropped the A10 line as it seems no cartridge uses it)

The blue led at the front is in fact blinking at approx. 10 kHz which I will use as sampling frequency for the voice.
Unfortunately it is not very stable as the interrupts that the PSEN line causes are quite heavy  Smiley Still it seems I now have enough cycles left to do other things.

Next step is to split out the PSEN and WR interrupt lines to get the voice emulation going. For this I needed Smithereens (NTSC Voice version) and had to implement the bankswitching part.
« Last Edit: May 22, 2012, 07:38:43 AM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #4 on: December 13, 2011, 12:14:03 AM »

(I dropped the A10 line as it seems no cartridge uses it)

Videopac 31 and 40 use A10, and KTAA too.
Logged
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #5 on: December 13, 2011, 07:47:06 AM »

Videopac 31 and 40 use A10, and KTAA too.

Thanks Rene,

In a final design or with the LPCxpresso I can put back A10 quite easily but now I am running out of port pins. The LPC1768 CPU on the mbed has more than enough port pins, but to keep the mbed module within 40 pins some compromises had to be made.  Smiley
I wanted to use P10 and P11 so I could test the bankswitching and get Smithereens going (although Smithereens would work without P11)

All in all it is quite 'weird' to see the Videopac running without a real ROM  Smiley

If I can manage to generate an interrupt on the falling and one on the rising edge of PSEN some more cycles could be won. Now the interruptroutine has to wait until the pin goes high again wasting cycles.

Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #6 on: December 13, 2011, 01:08:27 PM »

This is the ARM assembler code for the interrupt routine, for any one interested  Smiley

Code:
my_irq
   
    LDR     R1,=0x2009c040      ; port2
    LDR     R2,[R1,#0x14]       ; get byte value from port
    AND     R2,#0x0000003F      ; save bits for A0-A5
   
    LDR     R1,=0x2009c000;     ; port0
    LDR     R3,[R1,#0x14]       ; get port0 value   
    AND     R3,#0x00078000      ; and of A6-A9
    LSR     R3,#9               ; shift down
    ORR     R2,R3               ; or in bits A6-A9

    LDR     R3,[R1,#0x14]       ; get port0 value
    AND     R3,#0x03800000      ; and off bits A11, P10 and P11
    EOR     R3,#0x03000000      ; invert P10 and P11
    LSR     R3,#13              ; shift to A10,A11 and A12
    ORR     R2,R3               ; or in the bits as A10, A11 and A12
   
    ; insert test for PSEN or WR here
   
    LDR     R3,=testrom         ; address of our rom
    LDRB    R2,[R3,R2]          ; get a byte with calculated offset
    LSL     R2,#4               ; shift up 4 bits (data bus is P0.4-P0.11)
    STR     R2,[R1,#0x14]       ; output the byte

    MOV     R3,#0x00000FF0;     ; output mask
    STR     R3,[R1]             ; set port to output
       
wait_for_psen_high   
    LDR     R3,[R1,#0x14]       ; get port0 value
    TST     R3, #0x00000002     ; and test psen (P0.1)
    BEQ     wait_for_psen_high  ; wait for PSEN to rise again
       
    MOV     R3,#0x00000000      ; input mask
    STR     R3,[R1];            ; set port to input again

    MOV     R3,#0x7fffffff      ;  clear mask
    LDR     R1, =0x4002808C     ;  IO0INTCLR   
    STR     R3,[R1]             ;  clear interrupt flag

    BX      LR                  ; return to caller
    ALIGN                       ; make compiler happy
    END

All these instructions are single cycle (a little bit over 10 ns each)
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #7 on: December 13, 2011, 01:14:31 PM »

Are there any cartridges which use external RAM (in the cartridge I mean) ?
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #8 on: December 13, 2011, 01:52:20 PM »

Are there any cartridges which use external RAM (in the cartridge I mean) ?

No. The PCB's of Videopac 31 and 40 are suitable for an extra 6810 chip, but it's not used.
Logged
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #9 on: December 13, 2011, 06:51:13 PM »

No. The PCB's of Videopac 31 and 40 are suitable for an extra 6810 chip, but it's not used.

Ok, so that will make the emulation part a bit simpler Smiley
The only 'write' things for now will be the Voice and the latches of the Chess and Basic box then.

Thanks again
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #10 on: December 14, 2011, 10:05:41 AM »

The only 'write' things for now will be the Voice and the latches of the Chess and Basic box then.

And the latches of Videopac 55, 58, 59 and 60 and the Service Testcart.
Logged
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #11 on: December 14, 2011, 01:35:59 PM »

And the latches of Videopac 55, 58, 59 and 60 and the Service Testcart.

Do you have address mappings or circuit diagrams of these ?

Yesterday evening I got the write part working, now I must try and create a reasonable sampling frequency or another low priority interrupt to push out the samples created by the sp0256 emulator. I could not find exact timing info of the internals of the sp0256, only know that it runs from an external 3.12 MHz xtal

All of the 'standard' interrupt functions of the mbed IDE are way too slow for this kind of tricks. I also found out some more port pins are available if I omit the second USB port function. The mbed itself has 2 MByte of local storage which should be more than enough for some multicart experiments, the CPU itself has 512k of flash and 64k ram.


I considered doing the Basic module emulation first but then I have to connect the mbed board to a G7400.. The 'naked' G7000 board I use now is easier to access with a scope probe  Smiley 

The Chess box should be easier as it does not need 'plus' functions and is fully asynchronous to the Videopac (AFAIK it will wait indefinetely until the box answers) and generates no realtime output.
(Thinking of this: it would be nice to make a 'plus frontend' with better graphics for the chess module..)


Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Rene_G7400
Pedit5
I take the Videopac and leave the Canoli!
*
Posts: 2519



WWW
« Reply #12 on: December 15, 2011, 11:59:29 AM »

Do you have address mappings or circuit diagrams of these ?

This is the circuit of Videopac 55, 58, 59 and 60.
Logged
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #13 on: December 15, 2011, 01:15:25 PM »

Thanks Rene,

I already notice that the memory mapping must be 'dynamic' for different cartridge emulations but that is no problem.
As you can see the interrupt routines are very small so I can create several routines for different types of cartridges and make some function to recognize the cartridge rom image, by size, checksum or name.

Another thing I must think about is how to select a rom image, load it up into the internal ram of the mbed and get the Videopac to execute it (other than pressing 'reset') During the load from the flash storage the interrupts are disabled so the 8048 will crash if it is executing code from the emulator, maybe I can force the 8048 to keep executing NOP's until the mbed is ready again.

 
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
gertk
Post Axe Pete!
*****
Posts: 853



gertk64
WWW
« Reply #14 on: December 19, 2011, 12:58:20 AM »

First sounds came out with Smithereens: "Action", "Come On You Turkey" and such, hilarious!
Alas it crashes the rom emulator but still, progress...
I guess I have a IO port conflict as I am writing/reading from the IO ports from both outside and inside the interrupts.

I used a TDA2822(M) as an amplifier (in bridge mode for simplicity) to drive a small speaker from a defunct TomTom but it makes a hell of a lot of noise  Cheesy  It also picks up GSM interference from over 2 m away...
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Pages: [1] 2 3 4   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!