Android emulator

Comments, problems, suggestions about Oric emulators (Euphoric, Mess, Amoric, etc...) it's the right place to ask. And don't hesitate to give your tips and tricks that help using these emulations in the best possible way on your favorite operating system.
OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Android emulator

Post by OulanB » Wed Jan 08, 2014 10:54 am

I am writing an oric 1/atmos emulator for android from scratch (after writting other emulators, see : http://sites.google.com/site/olivier2smet2/)

It is almost finished, but I have still one problem with it.
- oric 1 / oric atmos rom 1.0, 1.1 and even 1.22
- ULA is ok display is good, all effects are done
- sound is quite good (within android limits)
- keyboard is ok, even bluetooth and usb keyboard works (I use an AZERTY bluetooth keyboard mapped on the QWERTY oric matrix)
- tape are ok, in native bit/bit mode (no patch in rom needed, but at real speed) or in byte mode (with 3 op patched in rom)
you use directly .tap files (with rewind/forward) and auto-insert for csave)
- discs are ok (I emulated microdisc with 1793 support for 4 drives even for non 256 byte/sector format, needed for pinforic)
you can use directly .dsk files, 'format track is supported to allow more format 3" or 3"1/2)

See http://sites.google.com/site/olivier2sm ... jects/oric

Actually I don't implemented illegal 6502 opocodes at all (but I monitor them just in case)

My problem is with 1337 game: intro is ok, but when I launch the game:
- Y for tutorial -> ok
- 1 for launch -> ok BUT I got some illegals opcodes :

01-08 04:47:55.946: E/jni(4082): 6BBA 62 I00 A00 X0A Y05 SEC Z1 C0 4000 0 kil ILL
01-08 04:47:55.946: E/jni(4082): 6BBA 62 I00 A00 X0A Y05 SEC Z1 C0 4000 0 kil ILL
01-08 04:47:55.946: E/jni(4082): 6BBB 1C 20 E3 I00 A00 X0A Y05 SEC Z1 C0 4000 0 nop $E320,X
01-08 04:47:55.946: E/jni(4082): 6BBE 34 AD I00 A00 X0A Y05 SEC Z1 C0 4000 0 nop $AD,X
01-08 04:47:55.946: E/jni(4082): 6BFF 62 I00 AFF X00 Y0D SEC Z0 C0 4000 0 kil ILL
01-08 04:47:55.946: E/jni(4082): 6BFF 62 I00 AFF X00 Y0D SEC Z0 C0 4000 0 kil ILL

- 'space' -> ok
- 'space' -> ok
- 'space' -> crash more illegal opcodes and the game crash

01-08 04:49:24.467: E/jni(4082): 6AB9 64 AC I00 A09 X05 YC3 SF1 Z0 C1 4000 0 nop $AC
01-08 04:49:24.467: E/jni(4082): 6ABC FB B9 8A I00 A05 X05 YC3 SF1 Z0 C1 4000 0 isc $8AB9,Y
01-08 04:49:24.467: E/jni(4082): 6ABF FB AA BD I00 A05 X05 YC3 SF1 Z0 C1 4000 0 isc $BDAA,Y
01-08 04:49:24.467: E/jni(4082): 6AB9 64 AC I00 A08 X05 YA8 SF1 Z0 C0 4000 0 nop $AC
01-08 04:49:24.467: E/jni(4082): 6ABC FB B9 8A I00 A05 X05 YA8 SF1 Z0 C0 4000 0 isc $8AB9,Y
01-08 04:49:24.467: E/jni(4082): 6ABF FB AA BD I00 A05 X05 YA8 SF1 Z0 C0 4000 0 isc $BDAA,Y
01-08 04:49:24.467: E/jni(4082): 6AB9 64 AC I00 A09 X05 YC3 SF0 Z0 C1 4000 0 nop $AC
01-08 04:49:24.467: E/jni(4082): 6ABC FB B9 8A I00 A05 X05 YC3 SF0 Z0 C1 4000 0 isc $8AB9,Y
01-08 04:49:24.467: E/jni(4082): 6ABF FB AA BD I00 A05 X05 YC3 SF0 Z0 C1 4000 0 isc $BDAA,Y
01-08 04:49:24.467: E/jni(4082): 6AB9 64 AC I00 A08 X05 YA8 SF0 Z0 C0 4000 0 nop $AC

So can somebody help me about that ?

As I code on a mac I don't tried euphoric, sorry my only test emulator is Oric from Richard Bannister (v1.7.8)

(I lost my own oric atmos ages ago ... :( that's why I code an emulator)

User avatar
Chema
Game master
Posts: 1918
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Android emulator

Post by Chema » Wed Jan 08, 2014 11:46 am

Hi OulanB!

First of all welcome to Defence Force and congratulations for your emulator!

I am the author of 1337. Not sure if I would be able to help, but at least I will have a look at the code and see what should be there. I guess that your dumps show the PC address and the first few bytes of memory starting there?

I don't think there should be anything strange at those locations. Nothing really different from what is done in Pinforic is actually done here, so can't imagine what could be wrong. As soon as I can get to a copy of the sources, I will try to give more information.

In the meantime, did you try Space:1999? The code is more similar to what is done in 1337...

Cheers

dolarfred
Private
Posts: 3
Joined: Sat Nov 23, 2013 10:37 pm

Re: Android emulator

Post by dolarfred » Wed Jan 08, 2014 12:24 pm

Hi !
i've no direct answer to your problem

But you can use euphoric on macintosh using DOSBOX
and it works great, even with disk image
see my old post at :

http://www.oricgames.com/forum,fr,66,67,0.html
(dolarfred)
i wrote it 2 years ago

Thank you for your oric Android development
i hope it'll be avalaible soon

Dolarfred

User avatar
Chema
Game master
Posts: 1918
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Android emulator

Post by Chema » Wed Jan 08, 2014 12:50 pm

I took a look at the code. Don't know what could be wrong. At $6bba is where the CreateEnvironment routine starts, with the following code:

Code: Select all

CreateEnvironment
.(
    ; Make sure Obj3D is empty
    jsr _EmptyObj3D
    ; Create the radar object (number 0)
    jsr CreateRadar
    ; Add our ship, which is  object number 1 at initial position (fixed)
    ; This is different depending on whether we are launched from planet,
    ; or exit hyperspace. This depends on the _docked variable

    lda _docked
    beq hyper
...
$6ab9 is inside the routine which handles laser fire drawing, which starts at $6ab5

Code: Select all

_Lasers
.(
    ldx _numlasers
    beq end
    
loop
              ldy _numlasers
	lda _laser_source-1,y
	tax
	lda _vertexXLO,x
	ora _vertexXHI,x
	ora _vertexYLO,x
	ora _vertexYHI,x
	pha
	lda _laser_target-1,y
...
So nothing strange here. There must be some data corruption somewhere... Or am I misinterpreting your dumps?

Anyway my guess is that the error could be due to the load of the mission code from disk (tutorial if you selected it or the first mission in the mission pack otherwise) into $9a00. However this uses the same basic routines that load overlay ram with the 3D engine (for instance). Any error there would mean that the intro or the rotating ship in the init screen would not work properly.

OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Re: Android emulator

Post by OulanB » Wed Jan 08, 2014 1:16 pm

Hi, thanks for the info Chema,

The intro works perfectly, even the sound works.

Yes, the dump is the address of the faulty instruction, data here plus regs of cpu and finally disassemble of the opcode

Perhaps it has something to do with the overlay code. I got only some info about overlay ram and microdisc rom : here is what I do

I/O of microdisc interface : 0x314 write :
bit0 : enable intRq
bit1 : romDis (inverse logic)
bit7 : ovlEnable (inverse logic)

Code: Select all

		case 2:				// system rom		 C000-DFFF
			if (__romDis) {
				return __ram[addr];
			}
			return __romsys[addr - 0xC000];
		case 3: 			// system / extended rom	?	 E000-FFFF
			if (__romDis) {
				if (__ovlEnable) {
					return __romext[addr - 0xC000];
				}
				return __ram[addr];
			}
			return __romsys[addr - 0xC000];
Space:1999 crash also, the intro is ok then the main screen load then the app crash (illegal opcodes ...)
Last edited by OulanB on Wed Jan 08, 2014 2:02 pm, edited 2 times in total.

User avatar
Xeron
Emulation expert
Posts: 382
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Re: Android emulator

Post by Xeron » Wed Jan 08, 2014 1:21 pm

have you tried oricutron? There is a mac build and it should be better than oric.

also, would you be interested in porting oricutron to android as well as your own emulator? I know it builds quite easily for android, but nobody has made touch controls for it.

User avatar
Chema
Game master
Posts: 1918
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Android emulator

Post by Chema » Wed Jan 08, 2014 2:29 pm

Mmmm... don't really know. In 1337 (and I think in Space:1999 too) overlay is activated and rom is not selected anymore. This is done through code with this routine (which switches overlay in/out at each call):

Code: Select all

diskcntrl .byt $86
_switch_ovl 
    php
    pha
	sei
 	lda diskcntrl
	eor #2
	sta diskcntrl
    sta $0314
    lda #0
    sta $032F
    pla
    plp
    rts
So basically it gets the initial status byte 10000110 and inverts the value of bit 1. We could assume that this works, as well as all the code related to loading data into overlay. Else the intro would not work (and many other things both in 1337 and Space:1999 which do work in your tests, such as the printing of text strings).

Everything seems to be fine until you start the game, which implies loading the missions. In Space:1999 I don't remember exactly but should not do anything else with overlay and disk if you don't press CTRL at the beginning trying to load a saved game. It could help to have some info about where you get your illegal opcodes in Space:1999 too.

In the case that anything else is loaded first of all the disk is re-initialized using this code:

Code: Select all

_init_disk 
   php 
   sei 
   lda #LOW(irq_handler) 
   sta $fffe 
   lda #HIGH(irq_handler) 
   sta $ffff 
   jsr restore_track0 
   plp 
   rts 

wait_completion 
   lda $0314 
   bmi wait_completion 
   lda $0310
   rts 

restore_track0 
   lda #$0C 
   sta $0310
   jsr wait_completion 
   and #$10   ; seek error ? 
   bne restore_track0 
   rts 
The init_disk routine is also called the first time it loads data into overlay, but I see no other difference here. After this then data (with a saved game or mission code) is read.

More clues: in pinforic (I understand it works in your emulator) a slightly different code was used (it was older and was supposed to support other controllers). It is interesting to note the difference in wait_completion (the rest of the above routines are basically the same):

Code: Select all

wait_completion
        ldy #4
        dey
        bne *-1
        lda $0300,x
        lsr a
        bcs *-4
        asl a
	rts
where instead of reading $0314 and check for bit 7 set to 0 it makes just a small pause before entering a loop checking address $0310 (the value of reg x is $10).

However I don't see how this could corrupt memory where data is not loaded, but who knows...

We could also be looking in the wrong direction anyway. A possibility would be to modify your emulator to check for the contents in $6bba and track down when they change whatever the reason (should be a jsr opcode $20 once the game is loaded)...

OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Re: Android emulator

Post by OulanB » Wed Jan 08, 2014 2:35 pm

Oricutron does not works on my mac (mac os 10.9.1 even with sdl1 & sdl2 frameworks loaded) :twisted:

Anyway I prefer to write my own code it is part of the fun :?

Btw I get the 1337.dsk from the 1337.defence-force.org website a few days ago, can someone test if this archive still works and on which hardware (emulated or not), I am curious to know ...

Another problem, the barbitoric demo (taken now from the website does not boot ...). The disk seems to be a sedoric 3.006 one, but I just got the 'fake oric screen' and after read of sectors :

Code: Select all

01-08 08:31:58.329: D/oric-disc(31641): read sector 0/0/1 256
01-08 08:31:58.349: D/oric-disc(31641): read sector 0/0/1 256
01-08 08:31:58.349: D/oric-disc(31641): read sector 0/0/3 256
01-08 08:31:58.349: D/oric-disc(31641): read sector 0/0/3 256
01-08 08:31:58.349: D/oric-disc(31641): read sector 0/0/2 256
01-08 08:31:58.419: D/oric-disc(31641): read sector 0/0/1 256
01-08 08:31:58.419: D/oric-disc(31641): read sector 0/0/3 256
01-08 08:31:58.419: D/oric-disc(31641): read sector 0/0/3 256
01-08 08:31:58.489: D/oric-disc(31641): read sector 0/0/5 256
Then the oric locks. Did this disk use a special loader ? (sedoric 3 disk usually boot without troubles)

User avatar
Chema
Game master
Posts: 1918
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Android emulator

Post by Chema » Wed Jan 08, 2014 2:48 pm

OulanB wrote:Btw I get the 1337.dsk from the 1337.defence-force.org website a few days ago, can someone test if this archive still works and on which hardware (emulated or not), I am curious to know ...
You have the correct disk image. It works on an Atmos with a Microdisc. It was also tested on a Telestrat with the Stratoric cartridge. All the emulators supporting disk run the program nicely (at least Euphoric and Oricutron surely do).

User avatar
Xeron
Emulation expert
Posts: 382
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Re: Android emulator

Post by Xeron » Wed Jan 08, 2014 2:50 pm

yep, I didn't have to do anything special or different for 1337 or barbitoric to work in oricutron...

OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Re: Android emulator

Post by OulanB » Wed Jan 08, 2014 3:09 pm

Here is the dump of the page 0x6B just after the loading of the main screen (with the display of Tutorial Y/N)

Code: Select all

AA BD 01 FB 85 8C BD 21 FB 85 8D BD 41 FB 85 8E
BD 61 FB 85 8F 20 7F 17 CE 8A FB D0 9C 60 68 AD
4F 2E 09 01 AE 51 2E E8 8D 62 FB 8E 22 FB 4C E6
6A 8E 67 6B 20 2E 3A 29 7F C9 21 90 04 AE 67 6B
60 C9 02 F0 6B 8D 8D 6B 0A AA BD AF 2F 18 6D 26
04 8D 26 04 BD B0 2F 6D 27 04 8D 27 04 90 06 EE
28 04 EE FE 04 A0 00 B9 61 FA 29 40 F0 1D B9 E1
FA 29 08 D0 04 A9 01 D0 08 A9 80 4A 2C 25 04 D0
FA 18 6D 25 04 B0 03 8D 25 04 60 A2 00 BD 13 30
85 18 1D 34 30 F0 19 BD 34 30 85 19 A5 18 18 6D
98 59 8D 98 59 A5 19 6D 99 59 8D 99 59 4C CC 51
60 A9 05 8D 39 F9 4C 97 5D 20 62 1C 20 E3 34 AD
91 30 F0 0F 20 C3 6C AD EC 04 38 E9 07 8D EC 04
4C EC 6B A9 00 8D E7 04 8D E8 04 8D E9 04 8D EA
04 A9 58 8D EB 04 A9 DB 8D EC 04 A9 E7 85 06 A9
04 85 07 AD 2C 04 20 74 39 8E 13 7D AD 91 30 62
What I see is that I have an offset of 1 byte for the data so I will look at the read disk code ... or more closely at the disk to see if
this offset is already here ...

Ok it seems that the dsk image is not quite the same format as all the other dsk I used. I will look at that.

So to conclude it seem that it is my fault ;) I need to have a more robust code to deal with dsk files ;)

Thanks anyway, I will inform you of progress

OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Re: Android emulator

Post by OulanB » Wed Jan 08, 2014 3:30 pm

Ok,

Bug corrected, it was due to a bad .dsk parser when a sector started with 0xFB first byte as data ;)

Now 1337 and Space 1999 works, but barbitoric still locks ... but it is not the same bug ... more works to do

Thanks for all your help

User avatar
Chema
Game master
Posts: 1918
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Android emulator

Post by Chema » Wed Jan 08, 2014 6:13 pm

Ah, glad to hear. Congratulations.

About barbitoric, I guess you'll have to look for an answer from Dbug :)

OulanB
1st Star Corporal
Posts: 12
Joined: Wed Jan 08, 2014 9:49 am

Re: Android emulator

Post by OulanB » Wed Jan 08, 2014 7:20 pm

For barbitoric, it is done.

In fact the code in barbitoric don't wait the real end of the read sector command, it just make the assumption that it is ended after reading 256 bytes, and then it send the next command :shock:

I corrected my code to deal with this behavior and now barbitoric works :D

User avatar
Dbug
Site Admin
Posts: 2299
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Android emulator

Post by Dbug » Wed Jan 08, 2014 10:44 pm

OulanB wrote:For barbitoric, it is done.

In fact the code in barbitoric don't wait the real end of the read sector command, it just make the assumption that it is ended after reading 256 bytes, and then it send the next command :shock:

I corrected my code to deal with this behavior and now barbitoric works :D
The loaders we used in the previous demos were full of bugs, but they did work on the real hardware :)

You will have the joy to test my new loader soon, which is based on the one used in Barbitoric, but it's probably even more evil :D

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests