Forum.ArchosFans.com

Unofficial Archos Support Forum
It is currently Thu Dec 12, 2019 3:46 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 18 posts ] 
Author Message
PostPosted: Thu Mar 18, 2010 2:55 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
OK, quite a big update to the NES emulator here, everything fixed now except audio :)
See the old thread for history and tech info on porting sdl apps, cross-compilers etc. I'm starting a new one since I've redesigned the installer with the aim to running general "homebrew" apps. In subsqequent posts I will explain how to install and run your own apps (it's fiddly because the pdf viewer dosen't run as root)

The installer now creates a directory 'homebrew' and creates pdf files in the Info directory to launch the emulator (and other apps) - bonus "super scribble" app included!

Download homebrew.tar.gz unzip and copy the entire homebrew directory to the top directory of the archos (A605 or /mnt/data), then replace /mnt/data/hack.sh with the new version in homebrew/hack.sh. To install/enable the homebrew apps, run the GFT3 hack by renaming jspluginsx to jsplugins and opening 'dohack.html' (Moldy Cheese folks who know what they're doing don't have to use GFT3, instead copy over /opt/usr/bin/pdf with homebrew/pdf and repack the rootfs).

Open the relevant pdf file in the Info directory to start the emulator:

NES.pdf - normal emulator mode
NES_90.pdf - screen rotated 90 degrees (a little slower)
NES_scanlines.pdf - scanlines effect, (runs closest to full speed)
NES_TV.pdf - TV Mode, switch to TV mode before opening this (requires a minidock or similar of course)
Scribble.pdf - Super scribble app - see below for details

It runs super mario brothers by default, to run any other game, open the homebrew directory, rename game.nes to smb.nes, and copy/rename the other game to 'game.nes' (can be a zip file, but must be renamed to 'game.nes')

NB: If you want to run the GFT3 plugins unlock, then rename homebrew to homebrewx (You can rename back afterwards and then rerun the GFT3 hack to enable the emulator, but don't do it the other way round, it won't work)

This update includes the improved controls and battery power fix (so it doesn't shut off, but make sure you select "Never" off under Battery power in the archos options screen, otherwise the unit may suspend suddenly after exiting a game)

1. Improved speed! most games now run full speed at frameskip 2 (~20fps), the scanlines mode is the fastest.

2. Screen rotate 90 degrees option! This is slightly slower since I can't optimise the screen blit so much as for the normal view. The direction keys are remapped accordingly.

Image

3. USB playstation joysticks work with the appropriate adapter! (I used Super Joy Box 3 which I've had for years but is probably the same as this)

Image

this is especially useful for ...

4. TV Mode, for playing with all the family on the big screen!

Image

The controls are (NB I moved the A and B buttons from the original)

X = exit
OK = select
Cursor keys = direction movement
right Menu = B button
Volume Up = A button
Volume Down = Tab (use on menu selection screens)
left Menu = screen snapshot (saved in homebrew/.fceultra/snaps/)

For two handed control use the touchscreen option for A/B buttons:

Upper touchscreen = B button
Lower touchscreen = A button

On playstation joystick, triangle = A, circle = B, X = select, square = Tab, direction buttons or analogue stick can be used (but not both at the same time)

The code for usb joysticks is not too hard, and I could probably adapt for others, but you would need to run some test code to see the output values produced. Here is some basic code I used to read my joystick

Code:
// gcc -lusb -o usbtest usbtest.c
#include <stdio.h>
#include <usb.h>

int main()
{
struct usb_bus *busses,*bus;
struct usb_device *dev;
int found = 0;
int protocol = 0; // 0 works for playstation joybox3 adapter
usb_dev_handle *fdev;

usb_set_debug(0);
usb_init(); //initilize the usb library
usb_find_busses();
usb_find_devices();
busses=usb_get_busses();

for (bus=busses;bus && !found;bus=bus->next){
  for (dev=bus->devices;dev;dev=dev->next){
    if (dev->config->interface->altsetting->bInterfaceProtocol==protocol) { found=1; break; }
  }
}
if (!found) { printf("Unable to find a device.\nExiting\n"); exit(1); }
   
if (fdev=usb_open(dev)) printf("Device opened successfully.\n");
else { printf("usb_open operation failed.\n"); exit(1);}

//usb_detach_kernel_driver_np(fdev,0);

usb_claim_interface(fdev,0);

int i, n=6;
char buf[6] = { 0, 0, 0, 0, 0, 0 };
while (buf[0]!=3){ //simple test to enable exit (usually two buttons must be pressed to get code 3)
  for (i=0;i<n;i++) buf[i]=0;
  //read n bytes using bulk_read, with a 0ms timeout
  if (usb_bulk_read(fdev, 0x81, buf, n, 0)) {
    for (i=0;i<n;i++) printf("%d ", buf[i]);
    printf("\n");
  }
  else printf("nothing\n");
  //usb_clear_halt(fdev, 0x81); // reset the device node
}

usb_release_interface(fdev, 0);
usb_close(fdev);

return 0;
}


If anyone is interested or wants to work on their own hacks, all the code hacks I added to the fceultra emulator are in 3 files in src/drivers/pc/: input.c (keys, touchscreen and usb read), sdl-video.c (custom screen blits and screen rotation) and main.c (initialise usb and add -tv and -rotate command line parameters)

The bonus Scribble app isn't quite finished yet (palette selection, airbrush/speckle paint and load from png still to do), when it is I want to post a general "Homebrew" guide for the archos605, so anyone who has time/interest can contribute other apps. I think the archos605 isn't gonna run any other OS well enough (avos is very good anyway), but there's plenty of possibilities with individual apps. SDL apps are quite common, but require quite a bit of tweaking to port, the scribble app demonstrates direct access to the framebuffer, touchscreen and keys. (sourcecode link soon)

Image Image

Scribble has quite a few features already:

X - exit and save screen
OK - save as png (takes 4-5 secs)
left UP - (unlimited) REDO
right UP - change paint colour
LEFT/RIGHT - UNDO/REDO in smaller increments
left DOWN - (unlimited) UNDO (even after clear screen)
right DOWN - change paint colour
left Menu - full palette selection toggle (not finished)
right Menu - change brush shape
Vol Up/Down - brush size

Touch the screen icons for similar functions, and the white square in the top rhs is Clear Screen (which can be undone). The first time you run scribble you have to calibrate by touching the red lines, if the calibration is bad, delete /mnt/data/scrib_calibration.txt and restart scribble.

(A slight annoyance is that the archos image viewer doesn't display pngs in full colour, even though the browser does, check by viewing the palette above from both)

Enjoy :)

OUTSTANDING ISSUES:
1. Audio (may be too slow, and requires avos killed, so need to prevent power off somehow while on battery)
2. backlight stays on permanently afterwards until power off or suspend (something to do with the touchscreen/key access method I'm using, I'll post an update to fix this soon)


Last edited by sideways on Fri Mar 19, 2010 9:19 pm, edited 1 time in total.

Top
   
PostPosted: Thu Mar 18, 2010 3:42 pm 
Offline
Archos Guru
Archos Guru

Joined: Thu Dec 10, 2009 12:10 pm
Posts: 6598
Wonderful! Dude, we seriously need to take up a collection and get you an A5 IT to work some magic there too! :D

Michael


Top
   
PostPosted: Thu Mar 18, 2010 4:44 pm 
Offline
Archos User
Archos User

Joined: Mon Nov 19, 2007 5:51 pm
Posts: 53
Cool, will try to check this out this weekend!


Top
   
PostPosted: Thu Mar 18, 2010 4:50 pm 
Offline
Archos Novice
Archos Novice

Joined: Fri Feb 19, 2010 11:32 am
Posts: 1
very good, thank u very mutch
we need more from this


Top
   
PostPosted: Thu Mar 18, 2010 7:08 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
cheers all, an A5 IT would be nice, anyone want to lend me one? :)

Just some explanation for running your own homebrew apps from pdf launchers:

Recall that GFT3 is an exploit for running a root script from the avos interface on all the archos x05 devices. (For hard disk 605 models it also enables a plugins unlock, but that's a side issue)

Now, a couple of years back (around the time of the original GFT hack by fiat) we worked out how to hijack the /opt/usr/bin/pdf script to launch an application. But we still need a root hack to overwrite /opt/usr/bin/pdf each time we boot (unless you have installed the Moldy Cheese flashrom hack, in which case you can repack a custom rootfs with your modified pdf script).

This is not too bad with GFT3, since, provided you have opera, you don't need wifi access to run the root script (/mnt/data/hack.sh) and it only takes a quick rename of jspluginsx to jsplugins followed by opening opera.

If you look at the hack.sh script you'll see that it creates a bind mount on /opt/usr/bin to our custom version in /mnt/system/opt/usr/bin.

BUT, avos runs the pdf script as user 'nobody', and we need root permissions. To get this we create a setuid binary in /mnt/system which runs as user root, BUT you can't launch scripts as root from a setuid (since only euid is set to root), so we must set our real uid as root (0) and then launch any script.

The NES emulator runs the script /mnt/data/hombrew/nes.sh from setuid /mnt/system/nes, the latter is a simple app compiled from this code below:

Code:
// nes.c - setuid binary to run nes.sh

#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
  int i;
  char cmdline[512] = "/mnt/data/homebrew/nes.sh ";

  setuid(0);

  for (i = 1; i < argc; i++) {
    strcat(cmdline, argv[i]);
    strcat(cmdline," ");
  }

  system(cmdline);
 
  return 0;
}



(scribble doesn't need a script,so it runs as a standalone setuid /mnt/system/scribble, but I still setuid(0); in the code for full access to /dev)

Any parameters are passed to the nes.sh script by the strcat code, and in the custom pdf script (which is in the homebrew directory) you can see how I call nes:

Code:
~ # cat /mnt/data/homebrew/pdf  

#!/bin/sh

IS_NES=$( echo [email protected] | sed -n '/NES/p' )
IS_SCRIBBLE=$( echo [email protected] | sed -n '/Scribble/p' )

if [ -z "$IS_NES$IS_SCRIBBLE" ]; then
   # open pdf file normally

   export LD_LIBRARY_PATH=/opt/usr/lib
   export QTDIR=/opt/usr
   export QWS_MOUSE_PROTO=QVFbMouse
   export QWS_DISPLAY=:/dev/fb4:

   exec /opt/usr/bin/apdf -qws -noswcursor "[email protected]"

else

   cp /mnt/data/homebrew/transparency77 /dev/fb2
     
   if [ -n "$IS_NES" ]; then

     IS_90=$( echo [email protected] | sed -n '/NES_90/p')
     if [ -n "$IS_90" ]; then /mnt/system/nes -rotate 1 -xres 800 -frameskip 2  >/dev/null 2>&1; exit 0; fi

     IS_TV=$( echo [email protected] | sed -n '/NES_TV/p')
     if [ -n "$IS_TV" ]; then /mnt/system/nes -tv 1 -xres 640 -frameskip 2  >/dev/null 2>&1; exit 0; fi

     IS_SCANLINES=$( echo [email protected] | sed -n '/NES_scanlines/p')
     if [ -n "$IS_SCANLINES" ]; then /mnt/system/nes -scanlines 1 -xres 800 -frameskip 2 >/dev/null 2>&1; exit 0; fi

     # else run normal NES command
     /mnt/system/nes -xres 800 -frameskip 2 >/dev/null 2>&1

   elif [ -n "$IS_SCRIBBLE" ]; then

     /mnt/system/scribble >/dev/null 2>&1

   fi

fi


One further complication, for SDL apps, is that avos seems to block access to the keys, so I have to temporarily stop the parent avos process with

Code:
kill -SIGSTOP `pidof -s avos`


and then run a little stopstart.sh script which sends a SIGSTOP followed by a SIGCONT to the sdl app:

Code:
~ # cat /mnt/data/homebrew/nes.sh

export LD_LIBRARY_PATH=/mnt/data/homebrew
export SDL_NOMOUSE=1
export HOME=/mnt/data/homebrew
kill -SIGSTOP `pidof -s avos`
/mnt/data/homebrew/stopstart.sh fceu &
/mnt/data/homebrew/fceu -sound 0 -no8lim 1 -fs 1 -bpp 16 -yres 480 -nofs 1 "[email protected]" /mnt/data/homebrew/game.nes >/dev/null 2>&1
kill -SIGCONT `pidof -s avos`


Code:
~ # cat /mnt/data/homebrew/stopstart.sh 

#!/bin/sh
# helper script to enable tty events for SDL apps
sleep 2
killall -SIGSTOP $1
sleep 1
killall -SIGCONT $1



So as you can see, it's a little fiddly under the surface, but seems to work reliably for all the SDL emulators I played with.

Something else I want to get working is sopcast streams, since the webtv plugin should be hackable to make it play local streams, since that allows access to live sports ;)
update: shame, sopcast is closed-source and no arm binaries exist.


Top
   
PostPosted: Sat Mar 20, 2010 11:40 am 
Offline
Archos Novice
Archos Novice

Joined: Sat Mar 13, 2010 2:07 pm
Posts: 8
Wonderful work! haha
Sideways, is it possible to create a program to direct search and stream videos from sites like youtube? Something like the program minitube for linux but not limited only to youtube?


Top
   
PostPosted: Tue Mar 23, 2010 2:28 am 
Offline
Archos Novice
Archos Novice

Joined: Mon Nov 30, 2009 10:39 pm
Posts: 23
amazing job. Looking forward to the emulator having sound. Is that going to be coming int he future or for some reason is it not possible?


Top
   
PostPosted: Tue Mar 23, 2010 1:59 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
Bauer wrote:
Wonderful work! haha
Sideways, is it possible to create a program to direct search and stream videos from sites like youtube? Something like the program minitube for linux but not limited only to youtube?


Problem with creating any media apps is we don't have a known way to access the hardware decoders, in theory we could disassemble avos and see how the DaVinci chip (the codec chip in the x05 series) is utilised, but it's not something I envisage doing. You can however download high quality h264 videos from you tube and play them locally with the podcast plugin , see http://tinyurl.com/ydqeclf


Top
   
PostPosted: Tue Mar 23, 2010 2:11 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
twizted25 wrote:
amazing job. Looking forward to the emulator having sound. Is that going to be coming int he future or for some reason is it not possible?


It's tricky because the main avos process "owns" /dev/dsp which is required for audio. So to play audio I have to kill avos. That then introduces problems with power handling - I don't know how to prevent the unit powering off after a couple of minutes on battery power when avos is killed, and if you are on mains power there is a risk of damaging the battery by overcharging, since that is regulated by avos.

Those problems should be solvable, but also, audio may make the emulator too slow, If that's the case then I'll let you know that it won't be possible.

The NES emulator is a nice target since it gives access to hundreds of games, and some of them are quite good for that era (I like Super Mario series, Kirby, Galaga, Gradius, Donkey Kong series, Gauntlet, Bubble bobble etc), certainly better than the rubbish flash and widget stiff we've had previously.

Ideally, I'd also like to get some decent qtopia apps running too, stuff like the ebook reader FBreader for example. But that will take time, and anything more advanced requires tweaking the virtual keyboard, fixing the mouse cursor and calibrating the touchscreen properly in qtopia, so again, requires time.

The scribble app will have an icon mode too, so it will actually be a useful icon editer/designer (It does currently have square pixels option, but I need to snap them to a grid for the icon designer)


Top
   
PostPosted: Tue Mar 23, 2010 5:41 pm 
Offline
Archos Novice
Archos Novice

Joined: Sat Mar 13, 2010 2:07 pm
Posts: 8
Thank you very much sideways. I was not thinking about just having the work of playing videos done. I was thinking about developing a special program for this purpose. Maybe if we look into the DaVinci Chipset SDK from Texas Instruments website, we can discover how call the codecs.
http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_2_00/latest/index_FDS.html

I would do that had i the necessary expertise for it. Sorry.
Maybe someone could do that. Who knows.


Top
   
PostPosted: Thu Mar 25, 2010 10:39 pm 
Offline
Archos Novice
Archos Novice

Joined: Thu Mar 25, 2010 10:23 pm
Posts: 1
I appreciate all the hard work by sideways that has gone into this but unfortunately I'm one of those folks that are running moldy cheese that don't know what they are doing :). I was wondering if anyone has installed this package with modly cheese and if so could they document the steps? Especially on how to re-compile AVOS or providing us with this already done. I'm sure there are a lot of us out there that could benefit from such instructions.

I had been mulling about posting this question for a while but decided to take the plunge since I'm eager to try this out and breeth new life into my dying 605 :)

Thanks in advance.


Top
   
PostPosted: Thu Mar 25, 2010 11:30 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
You can install GFT3 on a moldy cheese hacked device, just rename restartavos.sh to restartavos.shx since you don't need that (and it won't enable the plugins if your firmware isn't 2.1.04 anyway).

GFT3 enables a root script (hack.sh) to be run from the default avos interface, there is no simple alternative to this

If you have reflashed the device with the moldy cheese hack you can (in theory) create your own optfs.cramfs.secure which contains a modified /opt/usr/bin/pdf script rather than requiring GFT3 to create it on the fly after each reboot.

If you don't know how to do that then you will have to use GFT3.

(I have 2.1.04 firmware so can't use moldy cheese)


Top
   
PostPosted: Sun Mar 28, 2010 11:38 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
Unfortunately it doesn't look like sound will be possible with the NES emulator, I had a play with it but could only get crackles.

The issue with the backlight staying on seems to be a bug in the archos 2.1.04 firmware, since the same thing happens after I open an ordinary pdf file without any hack applied, so I can't fix that one.

I have made a small fix to the direction key controls, since I had forgotten to map both left and right sides of the up/down keys, with the new fix you can do proper 8 way direction control, which makes games like gradius a lot easier to play (since you can reverse diagonally up or down by pressing back + up/down keys at the same time)

I also realised the TV/LCD button could be used, I want to map it to save/load state, but it's not so easy so for now I've set it to power cycle the NES (for quick reset when stuck in a game)

I also added the TV/LCD key control to scribble to allow the background to be set to the current brush colour (requires you to clear the screen at the start), this allows for drawing on a black background for instance, which looks very cool!

And I also made the sideways rotated NES option a bit faster by using vertical scanlines.

The updated code is in this pack homebrew_29032010.tar.gz , just copy over the current homebrew directory.

Also, the updated scribble source code is here , it's a pretty simple c app demonstrating the basics of writing to the screen and reading input, which you can modify/adapt for your own purposes.

Found a good site for roms such as authentic arcade versions of pacman, galaxians (cool!), space invaders, joust etc and a pretty good chess game The_Chessmaster (use the tab key (Vol down) to go to menu, set level to at least 3 (60 moves in 10 mins). Also another entertaining selection of the top 100 games http://www.sydlexia.com/nes100/nes100.htm )


Top
   
PostPosted: Tue Mar 30, 2010 10:54 pm 
Offline
Archos Novice
Archos Novice

Joined: Tue Mar 23, 2010 1:28 am
Posts: 8
Thank you sideway, great changes.
I am looking forward for the sound on NES


Top
   
PostPosted: Fri Apr 16, 2010 5:33 pm 
Offline
Archos Guru
Archos Guru

Joined: Tue Dec 04, 2007 9:48 pm
Posts: 595
Great work sideways, I finally will get some time this weekend to try out the new homebrew. :D

Maurice 8)


Top
   
PostPosted: Fri Apr 16, 2010 7:01 pm 
Offline
Archos Guru
Archos Guru

Joined: Wed Nov 21, 2007 6:41 pm
Posts: 448
divx118 wrote:
Great work sideways, I finally will get some time this weekend to try out the new homebrew. :D

Maurice 8)


cheers, make sure you get the latest version homebrew_29032010.tar.gz , and check out this site for some pretty good games, including an excellent Chess program (The ChessMaster) and improved 2nd versions of bubble bobble and bomberman amongst some arcade classics and even a sonic the hedgehog hack (sonic mario!).

I did get sound working partially but it clips a lot and isn't good enough to use yet, but I have been investigating the docs on the davinci dsp and framebuffer and I think I can get improved video performance using hardware scaling, which may then help get the audio more smooth. I'll post what I can in any case, even if it's not much of an improvement since the modified code may be of use to people working on the later gen units (I've managed to get it working without SDL using the 0.75 version source-code of fceu, and hacking the svga code, which makes the code hacks a bit simpler, and the audio is done with direct writes to /dev/dsp using the standard linux dsp audio functions)

If I had more time to play I'm pretty sure I could get a working version of a genesis/megadrive emulator working, since they did it on the gp32 which has a similar spec arm processor, but time is limited and my main aim is to get the NES emulator as perfect as possible.

NOTE: I've had issues with battery calibration after running the emulator for long periods, since avos is stopped it seems to misrecord the battery level afterwards, and avos then shuts down too quickly on battery power. To fix it I had to recharge and then unplug the mains and wait until avos reaches one power bar level, then immediately start the emulator, it will usually run for a couple of hours before the unit shuts off, then you can recharge as normal and avos calibrates correctly and the unit runs as normal (I replaced battery a few months ago, but have really abused it for a couple of months, but still get ~4 hours use)


Top
   
PostPosted: Sun Apr 18, 2010 6:40 pm 
Offline
Archos Guru
Archos Guru

Joined: Tue Dec 04, 2007 9:48 pm
Posts: 595
Works great. The speed is very good now. If I have some time left I will try to get the DVR remote to work, before I go on holiday :D .

The battery on my unit is again dead. I get max 5 minutes from it. I have now bought an external battery for on the go from philips the sce4430. It gives me around 3 hours and 15 minutes video playtime on my archos and I can also use it for my sons DSi.
The battery gets overcharged in the DVR dock and that is what kills it everytime. I use mine mainly for watching videos from my network in the bedroom, so most of the time it is in the dock.

Thanks for your work, so I can enjoy some old NES games on my holiday :) .

Maurice 8)


Top
   
PostPosted: Sat Oct 12, 2013 5:52 am 
Offline
Archos Novice
Archos Novice

Joined: Thu Mar 14, 2013 2:41 pm
Posts: 48
Thanks for informing about an overcharging technology using DVR. I think my 504 gets overcharged from DVR too. I tried to run this game emulator on TV+, but after it runs I see an all-time-blinking screen with a running game. In this case TV+ hangs on. The game is running but the player doesn't react on pressing buttons


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 18 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited