Scrambled numbers

IvanSiG

New member
Jan 3, 2025
3
0
1
Hey experts,

I am running 6.5.22 on Mame emulated Indy. With a fast CPU, several hacks and rebuilds of Mame and using Xming, it's getting close to a decent experience.

Anyway, I have one issue I can't seem to be able to resolve. Most applications render numbers wrong. I know. It's weird. Here is Software Manager showing disk space:

1766175634526.png


The osview output - see System Memory section:

Osview 2.1 : One Second Average indy-r5000 12:11:00 12/19/25 #1 int=5s
Load Average runq 0
1 Min 0.708 swapq 0
5 Min 0.176 switch 750
15 Min 0.059 kswitch 725
CPU Usage preempt 25
%user 100.00 Wait Ratio
%sys 0.00 %IO 0.0
%intr 0.00 %Swap 0.0
%gfxc 0.00 %Physio 0.0
%gfxf 0.00
%sxbrk 0.00
%idle 0.00
System Activity
syscall 2.9K
read 450
write 825
fork 0
exec 0
readch 3.2M
writech 3.1M
iget 0
System Memory
Phys 3,,.0M
kernel 14.4M
heap ,.4M
mbufs 2/..0K
stream 52.0K
ptbl 1.2M
fs ctl -40.0K
fs data 0..1M
delwri 40.0M
free /4.4M
data /4.4M
empty 4.0K
userdata 5..4M
reserved 0
pgallocs 3.3K
Scheduler

Any idea why this is happening / how to fix?
 
I'm not an expert in MAME. Just starting to reactivate my SGI collection after nearly 20 years.
Tried MAME to run an emulated Indy to get familiar with IRIX again and noticed the problems you described, too.

I do not have a solution to the scrambled number output, but found out, where it comes from.
Running the following simple C program:
C:
#include "stdio.h"

int main() {
    int i;
    for (i=1; i <= 10; i++) {
        printf("%f\n", (float)i);
    }
    return 0;
}

gives the following output:
1.000000
2.000000
3.000000
4.000000
5.000000
,.000000
-.000000
..000000
/.000000
10.000000

So there seems to be a bug in the printf/sprintf implementation.

Did you install IRIX in MAME yourself or are you using a ready-made version?
I'm using the version as described in https://forums.irixnet.org/thread-4081.html.
 
  • Wow
Reactions: flexion
Did some more tests and found out, that the problem comes from MAME.
When using version 0240, there are no scrambled numbers.
With Version 0250 Irix does not boot.
Versions 0260 till lastest 0283 show the scrambled number problem.

Unfortunately version 0240 only runs at ~40% speed, while version 0283 has ~65%.
 
Hey that's a good clue. I'll have a look at revision history, perhaps we can track this down.

To your question - I did a clean Irix install - because chd images that are in circulation have a lot of stuff I don't want - mostly old nekoware and a bunch of software I don't use. Just like that new computer feeling :) , just my preference.

I was able to accelerate mame with a bunch of optimisations that make sense for Irix but perhaps not so much for 100s of other (for me irrelevant) emulated systems. My first set of patches I've posted here (from a different machine as user o2o2o2 - don't ask!), were picked up by somebody in Mamedev and to their credit they included at least a few changes.

I've also implemented a disk cache (attached the patch if it's of interest) if you want to try it out. It definitely helps in my setup.

But the first thing to know is that you are unlikely to get anywhere close to real machine speed on present CPUs. Mame is woefully inefficient, by design, as the preference is for accuracy rather than performance. It also runs all machine emulation on a single thread (some blitting and housekeeping are done on separate threads though). In the case of mips3 emulation my hunch from profiling mame is that memory emulation slows everything down rather than CPU emulation on it's own, perhaps consuming as much as 40% of host CPU.

In any event, it's really a tradeoff between emulated CPU /memory (profiler shows this eats about 75% of host CPU) and I/O (~2-%). Consequently, performance gains you can get with Mame depend on what you want to do with the machine - if it's CPU, I think emulated R4400 (indy_) are probably a better bet, and you can bump up CPU clock in indy_indigo2.cpp:

// Note - this will probably mess up with the emulated real time clock.
// If you experience this, run ntp regularly via cron to correct time.
void ip24_state::indy_4020(machine_config &config)
{
constexpr uint32_t system_clock = 50'000'000; // you can change this down to 25'000'000
ip24(config, system_clock);
R4000BE(config, m_maincpu, 4 * system_clock); // Then change this up to 8 * system_clock
m_maincpu->set_system_clock(system_clock);
m_maincpu->set_icache_size(0x4000);
m_maincpu->set_dcache_size(0x4000);
m_maincpu->set_addrmap(AS_PROGRAM, &ip24_state::ip24_map);
}

If however you care more about disk i/o, you can bump up the wd33c93 (emulated scsi controller) clock from 10'000'000 to perhaps 20'000'000. I set it up like this as I use indies for CPU intensive things and indigo2 for disk (of course your mileage may vary depending on what you are hosting this on):

#define MY_FAST_SCSI_CLOCK 20'000'000
#define MY_SLOW_SCSI_CLOCK 5'000'000

// used for all indy variants - e.g. indy_4415, indy_5015
void ip24_state::wd33c93(device_t *device)
{
device->set_clock(MY_SLOW_SCSI_CLOCK);
downcast<wd33c93b_device *>(device)->irq_cb().set(m_ioc2, FUNC(ioc2_device::scsi0_int_w));
downcast<wd33c93b_device *>(device)->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi0_drq));
}

// used for indigo2_4415
void ip22_state::wd33c93_2(device_t *device)
{
device->set_clock(MY_FAST_SCSI_CLOCK);
downcast<wd33c93b_device *>(device)->irq_cb().set(m_ioc2, FUNC(ioc2_device::scsi1_int_w));
downcast<wd33c93b_device *>(device)->drq_cb().set(m_hpc3, FUNC(hpc3_device::scsi1_drq));
}

Unfortunately CHD created for indy_* wont run on indigo2_* - at least for me. Perhaps it's a difference in roms, don't know.

Another tip, once I got network going, I ditched mame gui altogether. It's really bad with mouse emulation. Instead, I connect via ssh and Xming (from windows machines) or Xnest from linux (if connecting from Windows, ake sure you spend a few bucks for Xming 7.7 "website release" - well worth it as it supports OpenGL and also encourages Colin to continue development!!). EGL and some demos won't work, but to me that's not important. My command line (my executable is indy_indigo2_fast.exe, rest is standard mame options):

.\indy_indigo2_fast.exe indy_5015 -nodrc -nojoy -numprocessors 6 -video none -frameskip 10 -throttle -sleep -sound none -window -networkprovider taptun -hard1 irix65_5015.chd -gio64_gfx xl24

Note the -video none instead of usual -video bgfx . Not a huge difference, but it helps a little. I've found -video opengl useful when running mame on a linux host and connecting to the linux host via RDP.

Another interesting topic for acceleration is DRC (dynamic recompiler). The DRC for mips is unfortunately messed up and has been for a good while. It crashes some halfway through the boot process on a windows host, and while it doesn't crash as readily on linux and at first seems promising, ultimately slows right down to 7-9% emulation speed and evetually crashes. It's just not stable. It's also a bit of a dark art programming-wise so few people have the knowledge / familiarity with the code to fix it.

Anyway I'll see if I can track down the printf bug this weekend.
 

Attachments

  • harddisk.patch
    3.4 KB · Views: 35
Last edited:
I started trying MAME with a read-made chd, but also switched to a clean IRIX install afterwards.

Besides the printf float error, I detected another bug in MAME versions newer than 0240.
When executing a configure script (in my case I tried to compile Tcl 9.0.3), only the first
two @X@ variables in a Makefile.in line get substituted (configure uses sed for text substitutions).
Example line from Makefile.in:
OBJS = @DTRACE_OBJ@ @ZLIB_OBJS@ @TOMMATH_OBJS@
will become the following in the generated Makefile:
OBJS = trace.o zlib.o @TOMMATH_OBJS@
which leads to a build error.
When reformatting the Makefile.in line like below, substitution works:
OBJS = @DTRACE_OBJ@ @ZLIB_OBJS@ \
@TOMMATH_OBJS@

I did not investigate further, but switched to MAME 0240 resp. real SGI hardware.
 

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu