Videopac / Odyssey2 forum
September 21, 2020, 05:15:58 AM *
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]   Go Down
  Print  
Author Topic: Videopac to mbed connection, first steps  (Read 8102 times)
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #15 on: March 30, 2011, 09:55:30 PM »

The original keyboard data routine caused problems so I replaced the Z80 routine to read the joystick and keyboard data (function $01) by a 'true mbed' replacement.
It mimics every z80 instruction of the original code by true mbed code and voila: it works flawless, no more missed bytes.

Since the whole Z80 rom is just a static array in my code I could easily replace the first instruction of the original routine by an unused/illegal Z80 code and  make it execute my own keyboard routine. It even makes it possible to inject keys from the USB side (debug host).

It is almost time to move this thread to 'programming'  Cheesy

// substitute for the original Z80 get keyboard routine
// This one emulates the function at original address 0x0255

void do_get_keydata()   // executed on instruction/opcode ED55
{
    unsigned int n;

    while (!myT0);        // wait until 8048 is ready
    out(0x7f,rdmem(0x87b0));    // send sound number

    while (!myT0);        // wait until 8048 is ready
    
    for (n=0x87b1; n<0x87bb; n++)      // 10 bytes to read
    {
        out(0x7f,0x01);                          // dummy write
        while (!myT0);                            // wait until 8048 is ready
        wrmem(n,in(0x7f));                    // save the byte from the 8048 to memory
    }
    
    wrmem(0x87b0,rdmem(0x87b0)&0x7f); // clear top bit of sound number
    while(!myT0);                                       // wait until 8048 is ready
    out(0x7f,0x00);                                   // send 0x00 to 8048
    pc=0x0286;                                        // now continue at 0x0286
}
« Last Edit: April 02, 2011, 05:12:26 PM by gertk » Logged

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



gertk64
WWW
« Reply #16 on: March 30, 2011, 10:55:34 PM »

whoa... I can just dump the ascii codes of the host's keyboard into the keyboard buffer.
Only have have to set bit 7 and I can type away at my PC keyboard in the terminal and the characters show up on the Videopac...

This program was typed in at the PC (debug terminal connected over USB to the mbed)
« Last Edit: March 30, 2011, 11:17:17 PM 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 #17 on: March 31, 2011, 09:32:07 AM »

Very nice!
Logged
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #18 on: April 02, 2011, 12:18:59 AM »

Got the microSD card, mini USB and ethernet connector today for the Hitex protoboard I used and put them on the prototype board.
So far I tested the SD card and it works! (included a Fat file system library already available for the mbed) now the basic emulation has 2 GB of storage space  Cheesy
Now I have to find out how the CSAVE and CLOAD routines work...

There is some very strange code in there:
At the code starting at $21A6 (is this the start of CLOAD?) there are several JR instructions jumping into the middle of other instructions...
For instance at $21B3 JR Z,$21BA but $21BA is the second byte of the LD A,$23 instruction at $21B9  Huh?

I need to find out the start of the CSAVE and CLOAD routines and the name which was given after those commands to connect them to the mbed SD card routines.



« Last Edit: April 02, 2011, 05:09:07 PM by gertk » Logged

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



gertk64
WWW
« Reply #19 on: April 03, 2011, 05:47:22 PM »

Well.. CSAVE is working, it writes the header and programdata in a file on the SD card.
Now the next challenge is to get CLOAD working  Grin

Logged

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



gertk64
WWW
« Reply #20 on: April 04, 2011, 11:03:47 PM »

With some very ugly coding but alas  Smiley

CLOAD <programname> gets a program back from the micro SD card!

The filename can only be 6 characters (it is coded by Micro$oft you know...)

My CSAVE routine adds ".bas" as extension so on the filesystem it shows as (in this example picture) tables.bas
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1138



« Reply #21 on: April 04, 2011, 11:50:49 PM »

amazing ... so you can actually put Basic-programs on SD card on your PC and load them to the C7420?
Logged

sex, lies, and videopac
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #22 on: April 05, 2011, 12:44:32 AM »

amazing ... so you can actually put Basic-programs on SD card on your PC and load them to the C7420?

Almost.. For now I can save a program typed in at the Videopac with a name on the SD card.
Just for fun I let the host PC 'type' in the helicopter.bas program (character by character through the debug terminal), and saved that to the sdcard with CSAVE "heli" which ended up on the SD card as "heli.bas"
Theoretically it should be possible to write a Basic program on a PC and translate it to the binary form of the C7420

It is now in 'native' C7420 format (24 bytes header data followed by the program data) so it is in binary form, I just skipped all the leader and filler bytes which are of no use on an SD card filesystem.

My CLOAD substitute does still have some flaws: it seems some pointers to 'variable space' and such are not setup correctly after loading so the program is 'destroying' itself after executing 'RUN'
I guess it is writing variable data across the program space. Will figure that one out too... The function ?FRE(0) should return the amount of free space after the program loaded but it stays at 14075 bytes as if no program is in memory.

http://www.ifs.tuwien.ac.at/dp/hc_audio_migration/programs/helicopter.bas

But: I have seen the helicopter already on screen! Unfortunately as soon as it picks up the 'poster' the program 'crashes'  Grin
« Last Edit: April 05, 2011, 07:46:17 AM by gertk » Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1138



« Reply #23 on: April 05, 2011, 03:11:32 PM »

cool ... btw: here's a program I had a few students write:

http://www.ifs.tuwien.ac.at/dp/hc_audio_migration/

I'm pretty sure it can not only output wave-files, but also raw-C7420 format (of course including the header and everything), so maybe its useful for you ...
Logged

sex, lies, and videopac
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #24 on: April 09, 2011, 11:10:16 PM »

Did some minor updates on the mbed CLOAD and CSAVE routines and the program now seems to load correctly.

PRINT FRE(0)  gives the correct amount of memory in use but still the helicopter program manages to mangle a few bytes at the end of the program when run resulting in a SYNTAX ERROR IN 11520
I removed a bunch of REM statements from the subroutines to make te program a bit smaller and it runs ok now.
Not sure what causes this memory corruption..

Anyway, here are some screenshots and a video can be seen on http://www.youtube.com/watch?v=jLy48ESrzco
Logged

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



gertk64
WWW
« Reply #25 on: April 14, 2011, 09:33:48 AM »

So, this is for now the final step. I mounted the mbed protoboard on the backside of the cartridge to make it an all-in-one solution. Theoretically it can all be mounted inside a cartridge.
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
manopac
Game & App Development
Give this man a Jopac!
*
Posts: 1138



« Reply #26 on: April 14, 2011, 05:05:10 PM »

and it even got a cool lable :-)
Logged

sex, lies, and videopac
Seob
Give this man a Jopac!
******
Posts: 1385



« Reply #27 on: April 15, 2011, 01:50:59 AM »

You work at nxp Nijmegen?
Logged

8 bits of fun
gertk
Post Axe Pete!
*****
Posts: 859



gertk64
WWW
« Reply #28 on: April 15, 2011, 05:16:54 PM »

 Cheesy no..
Logged

>>G7000 G7200(P+S) G7400 N60 JET27 VG5000 ZX80 ZX81 ORIC-1 COMX35 Aquarius<<
Pages: 1 [2]   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!