Main > Driving & Racing Cabinets

Mame hacks that make driving games play better with mouse/spinner/360wheel

<< < (18/22) > >>

Yolo_Swaggins:


Pretty sure it's just that 04 00 probobly don't need to copy the whole block. Look at the address on the side. File starts at 00000000 and ends at 00000fff and has 16 rows on the right. It's right above the first set of high score names that get saved in the nvram.

geecab:
Hm, I've checked what my script is writing and all looks good to me in HxD... I'm still not ruling out me doing something silly though lol!

So in those 6 bytes you've highlighted, I reckon if you change just that 04 byte to an 02 (Which should change cntsptrn from 1024 to 512), then the nvram won't load, change it back to 04 and it will.

Maybe because you were copying a few extra bytes other than the ones specifically for cntsptrn and patcen then this why its working for you?

:)

Yolo_Swaggins:
Yeah your right for some reason the other couple of bytes are needed for it to load up properly, i never properly tested it yesterday because i was messing around trying to get the stuff from the other prototype rom to load up in the one that works properly and it did work but the roads are missing collision detection so you fall through the track and cant drive up any hills and it acts like your offroad all the time. I had to make cheats to disable the timers so i could drive around and have a look. I'd like to be able to get the stuff from that non-working rom lol. I noticed you don't need to load the data into the  ds3xdsp chip the game still works fine without it i was trying to see if i removed it if the emulation would speed up to the same speed as street drivin' but i think it's all the extra special effects like the weather changing and the fog that makes it lag.

Yolo_Swaggins:
Look what i got working. https://www.youtube.com/live/ZP5o0ZImS5U?si=x7Y-mTMkayKls8r7

I was messing around swapping rom files around thought i had it working but the collision detection didn't work in the extra level that is "under construction"

Had another look today and notice discrepencies in how the 2 systems roms are loaded into the arcade machine. Changed hdrivairp to load up the roms correctly in the right format and in the right chip and now the levels work with collision detection in all the levels without having to do any rom hacking. Got sidetracked on this hoping you could maybe figure out the steering wheel bug. It could actually be a similar problem causing that when i think about it.......might need the right roms loaded to the correct chip that handles that stuff? :dunno

geecab:
Really good work Yolo!

I must admit I haven't made much progress on the airborne front. I've been doing some tidying of the steering changes for hard/race and street drivin'. I think I'm going to start a thread on the bannister mame forum ( https://forums.bannister.org/ubbthreads.php?ubb=postlist&Board=1 ) and ask the mame team for a bit of guidance on how to add a few options that I think we need.

Some interesting-ish things:

- I've noticed the IPT_POSITIONAL control option seems like a good compromise for both mouse and joystick. For mouse it acts like the IPT_DIAL does, and for joystick it acts like an IPT_PADDLE does...

--- Code: --- PORT_START("mainpcb:12BADC.0")       /* 400000 - steering wheel */
PORT_BIT( 0xfff, 0x800, IPT_POSITIONAL ) PORT_POSITIONS(0xfff) PORT_WRAPS PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_NAME("Steering Wheel")

--- End code ---

- Regarding editing the nvram, and the 6 bytes that seem to change when you calibrate your wheel (2 bytes for CNTSPTRN, 2 bytes for PATCEN and finally 2 weird bytes). I think I've worked out those weird bytes are a combination of the CNTSPTRN and PATCEN, added to a strange number. I've posted the latest version of the script below, I've called the weird 2 bytes the 'Edge', and the strange number the  CNTSPTRN and PATCEN are added to I've called the 'Edge base'. I don't really know what they are used for. Anyways, this is handy, because for strreet drivin we are now able to edit the nvram and change the default -98 patcen to 0. I can't seem to change street drivin' CNTSPTRN from 512 to 1024. I can change the nvram, and it gets loaded/accepted by the game ok, but I can tell when I play the game the CNTSPTRN is still fixed to 512.

- Finally, I might take another look at those strange numbers I was reading from another register a while ago (That seemed to change based on steering). I'm wondering if they have something to do with force feedback... maybe...

:)


--- Code: ---import sys

BYTES_EXPECTED = 2048
EDGE_BASE_HARDDRIV = 0x2C1D
EDGE_BASE_STRTDRIV = 0x295D


def load_byte_array(filename):

    global BYTES_EXPECTED

    with open(filename, mode='rb') as file: # b is important -> binary
        fileContent = file.read().hex()

    data = []
    byte_count = 0
    this_byte = ""
    for c in fileContent:
        this_byte += c
        if len(this_byte) == 2:
            data.append(int(this_byte, 16))
            this_byte = ""
            byte_count += 1

    if byte_count != BYTES_EXPECTED:
        print("Error! Unexpected number of bytes in {}. Expecting={}, actual={} ".format(filename, BYTES_EXPECTED, byte_count))
        exit(1)

    #print("{}".format((fileContent)))
    return data


def save_byte_array(filename, byte_array):
    # make file
    newFile = open(filename, "wb")
    # write to file
    newFileByteArray = bytearray(byte_array)
    newFile.write(newFileByteArray)


def load_nvram(nvram_path):

    global BYTES_EXPECTED

    mainpcb_200e = load_byte_array(nvram_path + "mainpcb_200e")
    mainpcb_210e = load_byte_array(nvram_path + "mainpcb_210e")

    # Combine the data...
    nvram = []
    for i in range(0, BYTES_EXPECTED):
        nvram.append((mainpcb_200e[i] << 8) | mainpcb_210e[i])

    return nvram

def save_nvram(nvram_path, nvram):

    global BYTES_EXPECTED

    mainpcb_200e = []
    mainpcb_210e = []

    # split the data...
    for i in range(0, BYTES_EXPECTED):
        mainpcb_200e.append((nvram[i] >> 8)&0xff)
        mainpcb_210e.append(nvram[i]&0xff)

    save_byte_array(nvram_path + "mainpcb_200e", mainpcb_200e)
    save_byte_array(nvram_path + "mainpcb_210e", mainpcb_210e)


def patcen_to_int(patcen):
    if (patcen&0xf000) == 0xf000:
        return -1 * (0x1000 - patcen&0x0fff)
    else:
        return patcen


def int_to_patcen(i_patcen):

    if i_patcen < 0:
        return 0xf000 | (0x1000 + i_patcen)
    else:
        return i_patcen


def get_edge(cntsptrn, patcen, start_edge, undo=False):

    edge = start_edge
    i_patcen = patcen_to_int(patcen)

    # Leave the sign 'as is' when undoing, flip the sign when redoing...
    cntsptrn *= 1 if undo else -1
    i_patcen *= 1 if undo else -1

    edge += cntsptrn
    edge += i_patcen

    return edge


def validate_edge_base(edge_base, exit_on_error=True):

    if edge_base == EDGE_BASE_HARDDRIV:
        print("Hard/Race Drivin' style edge detected - OK".format(hex(edge_base)))
    elif edge_base == EDGE_BASE_STRTDRIV:
        print("Street Drivin' style edge detected - OK".format(hex(edge_base)))
    else:
        print("Error! Unexpected edge base {} detected. Expecting either Hard/Race Drivin' edge base {} or Street Drivin' edge base {})".format(hex(edge_base),hex(EDGE_BASE_HARDDRIV), hex(EDGE_BASE_HARDDRIV)))
        if exit_on_error:
            if input('Continue anyway?') != 'y':
                exit(0)


def do_read(nvram_path):

    nvram = load_nvram(nvram_path)
    cntsptrn = "?"
    patcen = "?"
    edge = "?"

    for i in range(0, BYTES_EXPECTED):
    #for i in range(0x210, 0x218):
        temp = "ADDR:0x{:04X} - 0x{:04X} {:<8}".format(i, nvram[i], f"({nvram[i]})")
        if i == 0x212:
            temp = temp + " CNTSPTRN"
            cntsptrn = nvram[i]
        elif i == 0x213:
            temp = temp + " PATCEN"
            patcen = nvram[i]
        elif i == 0x214:
            temp = temp + " EDGE"
            edge = nvram[i]

        print(temp)

    i_patcen = patcen_to_int(patcen)
    print(f"Read complete. CNTSPTRN:{hex(cntsptrn)} ({cntsptrn})     PATCEN:{hex(patcen)} ({i_patcen})  EDGE:{hex(edge)}")

    # Check the edge looks right...
    edge_base = get_edge(cntsptrn, patcen, edge, undo=True)
    validate_edge_base(edge_base, exit_on_error=False)


def do_diff(nvram_path_a, nvram_path_b):

    global BYTES_EXPECTED

    a = load_nvram(nvram_path_a)
    b = load_nvram(nvram_path_b)

    diff_count = 0
    for i in range(0, BYTES_EXPECTED):
        if a[i] != b[i]:
            temp = "ADDR:0x{:04X} - A:0x{:04X} {:<8} DIFF B:0x{:04X} {:<8}".format(i, a[i], f"({a[i]})", b[i], f"({b[i]})")
            if i == 0x212:
                temp = temp + " CNTSPTRN"
            elif i == 0x213:
                temp = temp + " PATCEN"
            diff_count += 1
            print(temp)

    print(f"{diff_count} differences detected.")


def do_reset(nvram_path, cntsptrn, i_patcen):

    nvram = load_nvram(nvram_path);

    # Check the edge looks right and if it doesn't, ask user if they want to continue...
    edge_base = get_edge(nvram[0x212], nvram[0x213], nvram[0x214], undo=True)
    validate_edge_base(edge_base, exit_on_error=True)

    cntsptrn = cntsptrn
    patcen = int_to_patcen(i_patcen)
    edge = get_edge(cntsptrn, patcen, edge_base, undo=False)

    nvram[0x212] = cntsptrn
    nvram[0x213] = int_to_patcen(i_patcen)
    nvram[0x214] = edge

    save_nvram(nvram_path, nvram)

    print(f"CNTSPTRN reset to {cntsptrn}, PATCEN reset to {i_patcen}. OK")

def clean_path(my_path):
    if not my_path.endswith('/'):
        my_path = my_path + '/'
    return my_path

def show_usage():
    print("Nvram Helper")
    print("------------")
    print("")
    print("Usage:")
    print("    python3 nvram_helper.py read  <nvram_directory>")
    print("    python3 nvram_helper.py diff  <nvram_directory_a> <nvram_directory_b>")
    print("    python3 nvram_helper.py reset <nvram_directory> <cntsptrn> <patcen>")

    print("Examples:")
    print("    python3 nvram_helper.py read nvram/harddrivcb")
    print("    python3 nvram_helper.py diff nvram/harddrivcb nvram/strtdriv")
    print("    python3 nvram_helper.py reset nvram/harddrivcb 1024 0")
    print("    python3 nvram_helper.py reset nvram/racedrivcb 1024 0")
    print("    python3 nvram_helper.py reset nvram/strtdriv 512 0")
    exit(0)


#print("{}".format(sys.argv))

if len(sys.argv) < 2:
    show_usage()

cmd = sys.argv[1]
if cmd == 'read':
    if len(sys.argv) < 3:
        print(f"Not enough arguments.")
        exit(1)
    do_read(clean_path(sys.argv[2]))

elif cmd == 'diff':
    if len(sys.argv) < 4:
        print(f"Not enough arguments.")
        exit(1)
    do_diff(clean_path(sys.argv[2]), clean_path(sys.argv[3]))

elif cmd == 'reset':
    if len(sys.argv) < 5:
        print(f"Not enough arguments.")
        exit(1)
    do_reset(clean_path(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]))

elif cmd.lower() in ["h", "-h", "help", "/help", "/h", "?", "--h"]:
    show_usage()

else:
    print(f"Unknown command '{cmd}'.")
    show_usage()

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version