Gens4All with Z80 Emulation

Place for discussing homebrew games, development, new releases and emulation.

Moderators: pcwzrd13, deluxux, VasiliyRS

TapamN
letterbomb
Posts: 149

Re: Gens4All with Z80 Emulation

Post#141 » Wed Dec 08, 2021 1:30 am

So here's how to make a game list file:

First, compile glc. To do this, run "make" in "src/glparse". You don't need a Dreamcast compiler, just regular PC GCC/Clang.

A binary game list file is generated from a text game list source. You could make the source list from scratch, but the compiler has a feature to generate a template list source from a listing of ROMs when you run it with the -g (generate) parameter.

You would run something like, "glc -g list.txt ROMDIR/*.bin" to create the template file list.txt containing the ROMs in ROMDIR. Here's an example generated list:

Code: Select all

#ROMs loaded file this directory:
Dir: /cd/

Letter: #
#File /home/user/roms/ristar.gen
Game: * Ristar *
Rom: ristar.gen
Savename: oHe
Savetitle: * Ristar *
Savevmu: * Ristar *
Savetype: auto
Savesize: 0


##############################
Letter: F
#File /home/user/roms/f15strike.gen
Game: F-15 Strike Eagle Ii
Rom: f15strike.gen
Savename: uAW
Savetitle: F-15 Strike Eagle Ii
Savevmu: F-15 Strike Eagl
Savetype: auto
Savesize: 0


#File /home/user/roms/flashback.gen
Game: Flashback Version On 01/20/1993
Rom: flashback.gen
Savename: bMi
Savetitle: Flashback Version On 01/20/1993
Savevmu: Flashback Versio
Savetype: auto
Savesize: 0

##############################
Letter: L
#File /home/user/roms/vikings.gen
Game: The Lost Vikings
Rom: vikings.gen
Savename: Ayb
Savetitle: The Lost Vikings
Savevmu: The Lost Vikings
Savetype: auto
Savesize: 0



##############################
Letter: S
#File /home/user/roms/s3&k.gen
#Has save
Game: Sonic 3 & Knuckles
Rom: s3&k.gen
Savename: FYG
Savetitle: Sonic 3 & Knuckles
Savevmu: Sonic 3 & Knuckl
Savetype: odd
Savesize: 512


#File /home/user/roms/ssf2.gen
Game: Super Street Fighter2 The New Challengers
Rom: ssf2.gen
Savename: tFD
Savetitle: Super Street Fighter2 The New Ch
Savevmu: Super Street Fig
Savetype: auto
Savesize: 0


#File /home/user/roms/gaxe1.gen
Game: ‚f‚n‚k‚c‚d‚m@‚`‚w‚d@@@@@@
Rom: gaxe1.gen
Savename: Yuf
Savetitle: ‚f‚n‚k‚c‚d‚m@‚`‚w‚d@@@@@@
Savevmu: ‚f‚n‚k‚c‚d‚m@‚`
Savetype: auto
Savesize: 0


Several games have issues with their titles and need fix ups and repositioning. Golden Axe apparently had Shift-JIS as the title, which resulted in garbage for the title. For Lost Vikings and SSF2, we would want the controls to default to a 6 button controller setting. glc tries to do a few corrections on it's own (Like changing the title "Sonic & Knuckles" to "Sonic 3 & Knuckles" and adding the correct save size if the ROM if 4MB), but it's not much.

The savename, savetitle, and savevmu values default to what would be used automatically by the emulator if the game was started from the file browser.
These would be accessed hundreds of times each frame.
Savesize is the minimum size of the save file. When the game is loaded from the file browser, and not the game list viewer, the emulator will try to guess the save file size based on what was written to SRAM. But in something like Phantasy Star 4, only saving to the first slot will cause the calculated SRAM size to be smaller than the SRAM actually is. If the user tries to save in slot 3, the save file will grow. Correctly setting the savesize setting prevents someone from finding out that their save file has grown and that they're out of space.

If more is written to SRAM the savesize specifies, the save file will grow anyways.

Most games with saves uses 8-bit SRAM, where only odd numbered addresses are used. Most other emulators seem to save the unused bytes, but this one will try to remove them to reduce the save size. The savesize value is how large the save is AFTER the unused bytes are removed, so this is probably smaller than the size of SRAM from the PC version of Gens. Whether the SRAM uses odd, even, or both is controlled with the savetype value.

The default savename is generated by the serial number in the ROM header. It's also possible for two games to end up with the same savename by chance. If a ROM hack doesn't change the serial number, it will definitely end up having the same savename as the original game. (I should probably modify the list template generator to identify games with matching save names...)

Comment lines are lines that start with a #. You can't put a comment at the end of a line, the whole line has to be a comment. Nothing in a comment ends up in gamelist.bin.

Here's a list of all currently supported game parameters (everything is case sensitive):

  • Dir: Directory to read ROMs from. Usually you would want this to be "/cd/" (don't include the quotes), but you could change it to a sub-directory or use it to load over dcload.
  • Letter: Marks a jump-to point for the index. The index will jump to the next game in the list.
  • Game: Title listed on the game list. All of the modifiers listed below affect the current game.
  • Rom: File name of ROM file, relative to the file's Dir value.
  • Savename: The extension of the SRAM save file. The first 8 characters of the save are always GENS4ALL. With a savename of "ABC", the save file would be GENS4ALL_ABC. If omitted, the filename will be generated from the serial number.
  • Savetitle: The long description seen in the console's file manager. If omitted, the title will be blank.
  • Savevmu: The short description seen in the VMU's file manager. If omitted, the title will be blank.
  • Savesize: The minimum save file size that gets created. Can be 0, or from 512 to 64k in powers of twos. Most games use an 8KB SRAM.
  • Savetype: Controls type of save file, can be "none", "auto", "odd", "even", or "all". "none" disables creating saves, but SRAM will still be emulated while running if the game tries to use it. If you don't know what it should be, leave it on auto. In the future, it will be possible to specify EEPROM here for games like Wily Wars or Monster World IV.
  • Emu: Controls emulator settings and hacks. You can specify more than one. If you use more than one, separate them with spaces and put them all on one line.The supported hacks in v4 are:
    • sonic_smps_z80_hack: A hack to fix sound problems with the sound driver used for Sonic 2, Sonic 3, S&K, and Sonic 3D Blast. Use this if you want to run ROM hacks using the original sound driver for these games!
    • ristar_hack: A hack to partially fix Ristar freezing at boot. Ristar still has sound problems.
    • sonic2_auto_render_hack: This hack modifies the rendering code to look at Sonic 2's game mode variable, and changes how it renders depending on whether the game is in a special stage or not. Generally, you would want detailed scrolling for the background, and basic scrolling for the foreground, but to get the special stage pipe to display at full resolution, you need to switch this around. You can change which tilemap gets higher quality scrolling with the in-game menu's video options, but this hack does switches automatically. Useful for Sonic 2 hacks that don't move the game mode variable.
    • screen_off_render_hack: Instead of rendering the frame at the start of vblank, the frame is rendered when the screen is first blanked. Used to fix animation glitches in Landstalker. During gameplay, Landstalker would turn off the screen to letterbox the display, and load new frames before vblank occurred. Without this hack, Landstalker would render the current frame with the next frame's tiles.
  • Controls: Changes the default controller settings. The supported settings are:
    • 3button (A->Y, B->X&B, C->A)
    • 6button (A->B, C->A, B->X, X->L, Y->Y, Z->R, Mode->Analog Down)
    • lostv6 (A->X, B->A, C->B, X->L, Y->Y, Z->R, Mode->Analog Down)
    • sf26 (A->A, B->B, C->R, X->X, Y->Y, Z->L, Mode->Analog Down)
    The in-game menu has settings that currently can't be set here. I forgot to add them to the game list compiler after I added them to the emulator...
In the source file for glc, there are some reserved settings that aren't supported yet, like configuring multitap or setting a per-game sound sample rate.

A fixed up game list source for the previous example might look like this:

Code: Select all

#ROMs loaded file this directory:
Dir: /cd/


##############################
Letter: F
#File /home/user/roms/f15strike.gen
Game: F-15 Strike Eagle II
Rom: f15strike.gen
Savename: uAW
Savetitle: F-15 Strike Eagle Ii
Savevmu: F-15 Strike Eagl
Savetype: auto
Savesize: 0


#File /home/user/roms/flashback.gen
Game: Flashback
Rom: flashback.gen
Savename: bMi
Savetitle: Flashback
Savevmu: Flashback
Savetype: auto
Savesize: 0

##############################
Letter: G
#File /home/user/roms/gaxe1.gen
Game: Golden Axe
Rom: gaxe1.gen
Savename: Yuf
Savetitle: Golden Axe
Savevmu: Golden Axe
Savetype: auto
Savesize: 0

##############################
Letter: L
#File/home/user/roms/vikings.gen
Game: The Lost Vikings
Rom: vikings.gen
Savename: Ayb
Savetitle: The Lost Vikings
Savevmu: The Lost Vikings
Savetype: auto
Savesize: 0
Controls: lostv6


Letter: R
#File /home/user/roms/ristar.gen
Game: Ristar
Rom: ristar.gen
Savename: oHe
Savetitle: * Ristar *
Savevmu: * Ristar *
Savetype: auto
Savesize: 0


##############################
Letter: S
#File /home/user/roms/s3&k.gen
#Has save
Game: Sonic 3 & Knuckles
Rom: s3&k.gen
Savename: FYG
Savetitle: Sonic 3 & Knuckles
Savevmu: Sonic3&Knuckles
Savetype: odd
Savesize: 512


#File /home/user/roms/ssf2.gen
Game: Super Street Fighter 2: The New Challengers
Rom: ssf2.gen
Savename: tFD
Savetitle: Super Street Fighter2 The New Ch
Savevmu: Super Street Fig
Savetype: auto
Savesize: 0
Controls: sf26



When the game list source is finished, you can compile it into a gamelist.bin file with the command:

glc -c list.txt

This always overwrites any existing gamelist.bin file in the current directory. Add gamelist.bin to the disc and it will be loaded automatically.

Some other things I wanted to mention about the last release:

Most of the optimizations were to the rendering code, but the biggest optimization I made to the original Gens4All code was moving four variables into a struct. These variables were use to keep track of now many cycles the 68K and Z80 need to be run for. These would be accessed hundreds of times each frame.

The SH4 would have to load the addresses of each variable, load each variable's value, then write back the results. With the variables placed in a struct, the SH4 would only need to the address of the struct once, and could read and update each variable's value with a single pointer, cutting down on the number of memory accesses, instructions, and registers required. This saved about 0.6 ms each frame.

Also, I had an problem creating the 1ST_READ.BIN file. Other people also had trouble doing it with the previous version of Gens4All. I was able to do it with bincnv on the last version (even though it crashed on exit), but that wasn't working with the newer one at all. I ended up using sh-elf-objcopy to create the 1ST_READ. ("sh-elf-objcopy -o binary gens4all.elf 1ST_READ.BIN") It looks like the crash is from bincnv reading past the end of an array? If anyone else has problems creating 1ST_READs, objcopy is a good workaround.

User avatar
Ian Micheal
Developer
Posts: 6005
Contact:

Re: Gens4All with Z80 Emulation

Post#142 » Wed Dec 08, 2021 9:24 am

Thank you for this tip

Code: Select all

```but the biggest optimization I made to the original Gens4All code was moving four variables into a struct. These variables were use to keep track of now many cycles the 68K and Z80 need to be run for. These would be accessed hundreds of times each frame.```


Sega also talked about using structs like this ..

User avatar
JasonBlueX
noob
Posts: 3

Re: Gens4All with Z80 Emulation

Post#143 » Wed Dec 08, 2021 7:09 pm

Is amazing how can play Mega Drive games with correct sound, thanks :)

User avatar
CrashMidnick
blackout!
Posts: 140

Re: Gens4All with Z80 Emulation

Post#144 » Thu Dec 09, 2021 4:46 am

JasonBlueX wrote:Is amazing how can play Mega Drive games with correct sound, thanks :)


Yes, this emulator is a pure gem.

MastaG
Quad Damage
Posts: 204

Re: Gens4All with Z80 Emulation

Post#145 » Thu Dec 09, 2021 12:30 pm

So is there somebody who created a nice release with the proper hacks in place, in ISO or GDI format for playing on Dreamshell/RetroDream from IDE?

TapamN
letterbomb
Posts: 149

Re: Gens4All with Z80 Emulation

Post#146 » Tue Dec 14, 2021 10:32 pm

For the unmodified, original games, the hacks are automatically turned on when launched from the file system browser. Manually specifying hacks with a game list is mainly useful for hacks, which might not get autodetected.

MastaG
Quad Damage
Posts: 204

Re: Gens4All with Z80 Emulation

Post#147 » Fri Dec 17, 2021 8:48 am

I've created an ISO file for Dreamshell/Retrodream here: viewtopic.php?f=51&t=14933&p=158971#p158971

Roz
photon blast
Posts: 110

Re: Gens4All with Z80 Emulation

Post#148 » Fri Dec 17, 2021 8:52 am

MastaG wrote:I've created an ISO file for Dreamshell/Retrodream here: viewtopic.php?f=51&t=14933&p=158971#p158971

I waited for this! Thank you very much!

User avatar
mistamontiel
Shark Patrol
Posts: 1955
Contact:

Re: Gens4All with Z80 Emulation

Post#149 » Sat Jan 01, 2022 4:53 pm

Them dreaded saves twice in a row on exit rom it says don't have the space available n then makes me power cycle the Dreamcast

User avatar
Ian Micheal
Developer
Posts: 6005
Contact:

Re: Gens4All with Z80 Emulation

Post#150 » Sat Jan 01, 2022 5:29 pm

mistamontiel wrote:Them dreaded saves twice in a row on exit rom it says don't have the space available n then makes me power cycle the Dreamcast



have enff space on the vmu this does not happen..

  • Similar Topics
    Replies
    Views
    Last post

Return to “New Releases/Homebrew/Emulation”

Who is online

Users browsing this forum: No registered users