16k Oric-1

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.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

I think I narrowed down the problem in the stniccc 2000 to this particular code:

Code: Select all

	lda tmp0 
	cmp #<(200) 
	lda tmp0+1 
	sbc #>(200) 
	bvc *+4 
	eor #$80 
	bpl *+5 
	jmp Lmain190 
(That's the generated assembler for for (i=0;i<200;i++))

At the end of the first iteration, it executed the BVC, the EOR, and the BPL bypassed the jmp to the start of loop.

Possibly SBC did not correcty set one of the flags.

That would explain why some of your sedoric stuff is partly loaded, depending on how loop tests are done, they will or will not fail.

Time to go to bed for me :)
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Post by Xeron »

I've fixed the STNICCC2000 demo, and the record player in barbitoric. The overflow bit was miscalculated in ADC and SBC.

Sedoric disks still end up in a sea of BRKs, though.

Download SVNr42 for this fix..

Edit: DBug seems i figured this out at the same time as you!
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Cool, version 42 also solved the problem with the rotating cube (now working fine), and the "toxic cloud effect" is correctly displayed).

Now remains as far as I can see:
- The emulator vanishes at the end of the toxic cloud effect of barbitoric
- The music get totally wrong at some point, like if one of the channels was not playing, or was playing the wrong note. (I guess the easiest is to compare with the youtube video here http://www.youtube.com/watch?v=slHKp9eeosE)

I signal this stuff with the music, because it may be possible that the loading issue is related to something else than the obvious, so by finding the causes of other emulation problems, we may find that one in particular.

Sound problems can be caused by two things:
- basic problems in the soundchip emulation (volume tables, frequence converters, bad latching of register control/data, something wrong on the handling of Port A and B, etc...)
- problems in the irq/via handling, that we use for the music player sequencing, but that is sometimes used to generate samples of advanced music effect.
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Post by Xeron »

Just checked in some significant changes to the monitor/debugger. I'll take a look at the sedoric bug this lunch time.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Ok, since we seem to have identified that the loading problem happens only with Sedoric 3 (always) and Sedoric 2 (sometimes), while the Defence Force demos load fine, I'll share the source code of the boot sectors of our demos:

Code: Select all

#define FINAL_ADRESS $a000+50*40
;c000

_Reloc
;BreakPointjmp BreakPoint

     sei               ; No interruptions

     lda #$60     ; RTS Opcode
     sta $00          ; Write in $00 Page => take one less byte
LABEL=*+2
     jsr $0000     ; JSR on the RTS immediately return.
_BEGIN_COPY_
     tsx               ; Get stack offset
     dex
     clc
     lda $0100,x     ; Get LOW adress byte
     adc #<(_END_COPY_-_BEGIN_COPY_+1)
     sta $00
     lda $0101,x     ; Get HIGH adress byte
     adc #>(_END_COPY_-_BEGIN_COPY_+1)
     sta $01

     ; Now $00 and $01 contain the adress of LABEL
     ; We can now copy the whole code to it's new
     ; location
     ldy #0
copy_loop
     lda ($00),y
     sta FINAL_ADRESS,y
     iny
     cpy _END_-_BEGIN_
     bne copy_loop

     jmp FINAL_ADRESS
_END_COPY_


; Here is some code compiled at a fixed
; adress in memory.

     *=FINAL_ADRESS

_BEGIN_

/*                                  ICI loading du loader en RAM VIA le Boot sector      */

#include<vip4.h>


#define FDC_command	$0310
#define FDC_status	$0310
#define FDC_track	$0311
#define FDC_sector	$0312
#define FDC_data	$0313
#define MICRODISC	$0314

#define first_sect		17	; number of sectors before the progs on side 1
#define track_loader 0
#define sector_loader 5

;*=$b902
;Boot sector !!!
Initialize
;	sei ; IRQ déjà annulée en haut

_init_disk

	ldy #<(irq_handler)
	lda #>(irq_handler)
	sty $fffe
	sta $ffff

	lda #$7F
	sta $030D ; Lock VIA IRQ
/*VIP4 Boot sector !*/

load_prog
	lda #sector_loader ; First sector for the loader
	sta FDC_sector ; on set le secteur
	sta sect_low ; for count


loader
	lda #nb_sectors_loader ; nb of page à charger
	sta pages ; Fpor count
start_read
	jsr sectread
load_prog_ok
	sei
	lda #%10000001 ; Read finished stop FDC
	sta $0314
	jmp location_loader ; execute the prgm


/*Lecture************************************************************/

readlinsect


	ldx #track_loader ; We get the track of the loader
	cpx FDC_track ; Is it the current track ?

	beq set_sector ; Yes we set sector now !
	stx FDC_data ; On  force la track à changer

wait_drive2
	lda $318 ; We are waiting for the drive maybe not useful if drive is ready after the eprom boot
	bmi wait_drive2

	lda #$1F ; ordre de chgt de track
	sta FDC_command
	jsr wait_completion ; We are waiting for FDC


set_sector

	lda sect_low
	sta FDC_sector ; on set le secteur

	; Interdire les IRQ du fdc ICI !
	lda #%10000101 ; on force les le Microdisk en side0, drive A ... Set le bit de données !!!
	sta MICRODISC



	lda #$80 ; Demande de lecture #80

command
	sta FDC_command

waitcommand_again
	ldy #wait_status_floppy
waitcommand
	nop ; Not useful but for old Floppy drive maybe
	nop ; Not useful but for old Floppy drive maybe
	dey

	bne waitcommand

readwrite_data

read_sector
	ldy #0
microdisc_read_data
	lda $0318
	bmi microdisc_read_data
	lda $0313
page_to_load
	sta location_loader,y
page_to_load2

	iny
	bne microdisc_read_data
	lda FDC_status
	and #$1C

	rts


/*Lecture du secteur !*/
sectread
	ldy #4
	sta retry
sectreadloop

readretryloop
	jsr readlinsect ; on lit le secteur
	beq sector_OK
	dec retry
	bne readretryloop
sector_OK
	inc sect_low ; on avance le ptr de secteur
	inc page_to_load+2
	dec pages
	bne sectreadloop

	rts

wait_completion
	ldy #4
r_wait_completion
	dey
	bne r_wait_completion
r2_wait_completion
	lda $0310
	lsr
	bcs r2_wait_completion
	asl
	rts

irq_handler
	pla		; get rid of IRQ context
	pla
	pla
	lda #%10000001
	sta $0314	; disables disk irq
	lda $0310	; gets status and resets irq
	and #$7c
	rts


sect_low
	.byt  0
pages
	.byt  0
retry
	.byt  0

_END_
This code loads by polling, does not use the IRQ handler to load the data.

Sedoric uses (I believe) the IRQ method, perhaps by comparing the code we could find out what happens.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Found a bug (I think).
When executing the BRK instruction, the B flag is not set.
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Post by Xeron »

You're quite right, which is a bit embarrassing since the sole purpose of that flag is to be turned on by BRK :-)

Fixed and in the SVN.
Dirk
Private
Posts: 3
Joined: Fri Dec 11, 2009 7:47 pm

Post by Dirk »

Xeron wrote:You're quite right, which is a bit embarrassing since the sole purpose of that flag is to be turned on by BRK :-)

Fixed and in the SVN.
Hi,

Would you write down how to compile the Emulator in Windows
and which additional libraries are needed ?

Thanks in advance.

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

Post by Xeron »

I compile it with the mingw gcc that comes with Dev-C++ (although I use the command line rather than the IDE).

Here is a step-by-step guide to compiling it with Dev-C++ in the IDE:

1) Download and install Dev-C++.

2) Once it is installed, install the SDL add-on (if Dev-C++ installed correctly, you should be able to just download the ".devpak" file and then run it).

3) Run Dev-C++, and select "File->New->Project".

4) Select "Multimedia" and make sure "SDL" is highlighted. Make it a C project, and name it "Oriculator".

5) Click "OK" and save the ".dev" file in an empty dir somewhere.

6) It'll give you a filled-in "main.c". Right click on the main.c tab and select "Close". It'll ask you if you want to save the changes to main.c, select "No".

7) Copy all the ".c" and ".h" files from oriculator into your new project directory (the same location as you selected for the Oriculator.dev project file). You don't need the makefile, just the source files.

8) Back in Dev-C++, right click on "Oriculator" in the project tab, and select "Add to project". Select all the source files and click "Open".

9) Go to Project->Project Options

10) Click on the "Parameters" tab

11) On the end of the compiler parameters (after "-Dmain=SDL_main"), put "-D__SPECIFY_SDL_DIR__", so that the compiler parameter contains:

-Dmain=SDL_main -D__SPECIFY_SDL_DIR__

12) Click "OK"

13) Go to File->Save All

14) Go to Execute->Compile

You're done!


How to compile it using GCC from the commandline (how I do it myself)

1) Install Dev-C++ and the SDL devpak as described in steps 1 & 2 above

2) Check out the Oriculator sources

3) Edit the makefile, and make sure "PLATFORM ?= os4" is commented out, and "PLATFORM = win32" is not commented out.

3) Open a new command prompt, and CD to the place you checked out the sources

4) Type:

PATH c:\dev-cpp\bin;%PATH%

(replace "c:\dev-cpp" with where you installed Dev-C++)

5) Type "make"
Dirk
Private
Posts: 3
Joined: Fri Dec 11, 2009 7:47 pm

Post by Dirk »

Nice. It works.
Thank you very much for this tutorial.

A little bit offtopic.
There is an issue with tape loading.
Most tapes are loading correctly with turbo mode but The Hobit gives a tape error. Normal speed works but it takes very long.


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

Post by Xeron »

If the hobbit has a custom loader, it would likely cause problems with the turbo mode, since turbo mode patches the ROM functions for reading from tape.

If the hobbit only uses ROM loaders, it is a bug in oriculator that should be fixed.

Edit: BTW, do you plan to help debug problems with oriculator? or add featuers? or just want to have a play with the sources? I'm just interested to know :-)
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Just for the sake of discussion, I noticed you mentionned DevC++, is it still developped ? Last time I checked, it seemed that most people using mingw had moved to Code::Blocks instead.
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Post by Xeron »

I don't know. I primarily develop on Amiga. I just happened to already have Dev-C++ installed on my PC, and used it for the windows build.
User avatar
Xeron
Emulation expert
Posts: 426
Joined: Sat Mar 07, 2009 5:18 pm
Contact:

Post by Xeron »

Interestingly, I just compiled Oriculator in Code::Blocks, and it doesn't crash after the toxic cloud in barbitoric for me any more :?
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Thats... interesting... and scary at the same time.
Code generation error?

In theory both are using mingw, possibly the version that comes with DevC++ is a buggy version?
Post Reply