A new MENU system for MMC/Gotek

bbc/electron apps, languages, utils, educational progs, demos + more
User avatar
tricky
Posts: 7716
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: A new MENU system for MMC/Gotek

Post by tricky »

Sure, I thought I had explained it in full, but can't find it!
I find the most common pair of letters and replace them with char 128 (may be 96), find the next most common pair which might include char 128 and replace them with char 129, repeat up to 253 or there abouts and the write out the twp half page table with which pair to replace each chara with.
Decompression requires a small stack as reading the next char might mean pushing one on the stack for later and decoding the first.

I can't remember if I posted the code, but someone else took the idea and extended the characters to replace pairs with to give a bit more compression.

In the menu system, I get all the game titles and publishers, compress and if it won;t fit in memory, repeat with title + publisher for the first in each series of publishers, leaving the rest of the games as just title and if that doesn't fir, just do titles, which does.
I also have some abreviations that I substitute and special characters that I replace.

The code was just a quick hack to see if it would work and I never went back to tidy it!

Code: Select all

	unsigned char dictionary[128+32][2];
	short pages[256];
	if (size_t bytes = dst - strings)//fread(strings, 1, sizeof(strings), f))
	{
		OutputDebugStringA("File: "); OutputDebugStringA(_itoa(int(bytes), num, 10));
		for (int replace = 0; replace < 128+32; ++replace)// if (replace != 13 && replace != 9)
		{
			std::map<unsigned short, int> occurences;
			for (int c = 0; c < int(bytes) - 1; ++c)
			{
				if (252 != strings[c + 0] && 252 != strings[c + 1])
				{
					++occurences[strings[c + 0] | strings[c + 1] << 8];
				}
			}
			unsigned short best = 0; int most = 0;
			for (auto n : occurences)
			{
				if (n.second > most)
				{
					best = n.first;
					most = n.second;
				}
			}
			p.c = dictionary[replace];
			*p.s = best;
			unsigned char * ch = p.c = strings;
			while (ch < strings + bytes - 1)
			{
				if (best == *p.s)
				{
					*ch++ = replace;
					p.c += 2;
					--bytes;
				}
				else
				{
					*ch++ = *p.c++;
				}
			}
			while (ch < strings + bytes)
			{
				*ch++ = *p.c++;
			}
		}
Looks like I start at 128 and wrap to 31 maybe!
It takes about a second iirc, so doesn;t really matter, which is the great thing about compressing for a beeb but not on a beeb, exaustive searches aren't usually exausting ;)

Much like the compressor I use for my games to fit them in ROM, it was good enough, fast enough and small enough so I kept it :)

Decompressor looks like this:

Code: Select all

	ldx #0
	ldy #0

.next_line
	jsr OSNEWL : lda #CRSR_RIGHT : jsr OSWRCH : jsr OSWRCH : jsr OSWRCH
.next_byte
	lda stack,x : cpx #0 : bne stack_not_empty
	lda (src,x) : inc src {bne pg : inc src+1 : .pg}
	dex
.stack_not_empty
	cmp #128+32 : bcs not_compressed
.pop_this
	tay : lda dict1,y : sta stack,x
	dex : lda dict0,y ;;: sta stack,x
	cmp #128+32 : bcc pop_this
.not_compressed
	cmp #254 : bcs end_string
	inx
	and #&7F : jsr OSWRCH
	jmp next_byte
.end_string
Looks like I or the char with &80 meaning that the first 160 are the compressed ones and the rest just get AND &7F before drawing.

I don't know how well other methods would work as the strings are relativly small (name or name + publisher, maybe author, I don't remember) but it would be easy to check I guess!

I was thinking about spitting out separate menus for B and Master as either you would have a disc for each machine, or at least two if you have multiple machines but I don;t think all the games are correctly labeled as to which systems they work on, so I just left it as try it, well it doesn;t take long to select another game especailly if you have an MMC.
mikeh_nz
Posts: 78
Joined: Wed Nov 30, 2022 3:24 am
Location: Seattle
Contact:

Re: A new MENU system for MMC/Gotek

Post by mikeh_nz »

tricky wrote: Wed Feb 14, 2024 9:24 pm Test versions with 512 byte sectors for GOTEK and drive selection instead of &80 (current drive, no checking). https://www.dropbox.com/scl/fo/q2o58ox8 ... 7fsy1&dl=0
Top post updated, only the GOTEK versions should have changed.
I’m not sure if I was meant to test the Experimental or Default. (I assume Experimental.)

Specifically, I’ve tested the Experimental/Curated/Gotek and it works fine. The menu works great & the dboot0’s on the other disks work great too!

I do like the small size of the decompression routine - very nice!
User avatar
tricky
Posts: 7716
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: A new MENU system for MMC/Gotek

Post by tricky »

Thanks for testing, the experimental ones are my attempt to make the menu and existing games tube copro compatible.
I like small decompressors although in this case because the data is large, a more sophisticated one might have been better.
Have you seen the one I use for my games to make them fit in a rom?
mikeh_nz
Posts: 78
Joined: Wed Nov 30, 2022 3:24 am
Location: Seattle
Contact:

Re: A new MENU system for MMC/Gotek

Post by mikeh_nz »

No - what’s the algorithm for that one? I’m interested.

I haven’t seen any of your games in rom form. I’ve
  • played your games (like asteroids where you’ve apppeared to “borrow” the arcade rom and cleverly patched the 6502)
  • burnt your diagnostic rom for when my beeb next craps out and I go around the loop again fixing it.
  • saw a video at some stage of your switching audio out jack & thought that was quite a good idea.
(So you’re doing well at earning “legendary status” points :P)

FYI: I did have a go at trying the default/Complete version on the Gotek. Findings:
  • The 571 .DSDs + FF.cfg files actually happily sit in the root directory of my fat32 formatted thumb drive. (I originally thought it was going to have problems with that.) The Gotek can see and access them all.
  • Other experiments showed that the Gotek doesn’t look in sub folders when in indexed mode. And you can’t set the disk index prefix (default=“DSKA”) to something like “A\DSKA” or “A/DSKA” and have it search a directory deeper. You also can’t set the folder name to DSKA0000.dsd and have a file in it.
  • Sadly your menu doesn’t work as it’s too big for my beeb’s memory. Loading in at &1700, the &79e3 program goes straight through the mode 7 screen buffer and out the other end! (When a coprocessor is installed, does your menu try to run in the beeb host, or parasite coprocessor? - I think it’s the host by the looks of the FF load address )
Keep up to good work & thanks for all the contributions the that you’ve made to the community.
User avatar
tricky
Posts: 7716
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: A new MENU system for MMC/Gotek

Post by tricky »

There is a great comparission thread here https://www.stardot.org.uk/forums/viewtopic.php?t=27861 with links.
I think it was something like lz77, but I didn't know that when I wrote it :)
I only wrote it to compress my games to fit in a 16K EPROM, or more if they use sideways RAM.
All my games, but not necessarily my "ports" from arcade ROMs can have their main "exe" loaded as a ROM or into SWRAM and launched from there, if they are in slot 0 on a master, they will auto boot, like a cartridge console.
I only need to compress about 17-20K into a 16K ROM with room for a ROM header to make the game load more quickly and fit in a ROM, so that is what it does with the minimum of space overhead. It is also position independent apart from the 5 bytes of ZP.
It is a shame that something similar wasn't built into the OS with a compressor on the Welcome disc.
It has been used by some games on here and all mine whether they need it or not as it is also used to move the game down on load.
It can completely overwrite the source data except a couple of bytes as long as it is moving down.
User avatar
danrolfe
Posts: 37
Joined: Thu Nov 19, 2020 8:36 pm
Contact:

Re: A new MENU system for MMC/Gotek

Post by danrolfe »

Hi,

I'm trying to use with with my newly acquired Gotek (from Mark at Retroclinic) which is working fine with the USB from Mark but I'm unable to make these GOTEK.zips work properly. Maybe I'm going something wrong? I've tried a few zips from your first post, including the latest and 512 byte sector. On some when I boot I get a Mode7 screen full of garbage, on some (your latest version and your 512b curated) I get the menu fine on boot, but when I select anything and then press return it shows "GOTEK din" on the screen, runs through to track 254 on disc then shows a message like "EXEC $.--009--" on the next line on the screen (the number vary).

The OLED on the Gotek says
*Direct Access*
000/436 T:254

and all I can do is press BREAK. This happens whether I have my PiTube enabled or not.

Have I missed something I am supposed to do?
Halifask
Posts: 19
Joined: Thu Feb 22, 2024 1:12 pm
Contact:

Re: A new MENU system for MMC/Gotek

Post by Halifask »

The same thing is happening to me.
User avatar
tricky
Posts: 7716
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: A new MENU system for MMC/Gotek

Post by tricky »

Test versions with 512 byte sectors for GOTEK and drive selection instead of &80 (current drive, no checking). https://www.dropbox.com/scl/fo/q2o58ox8 ... 7fsy1&dl=0 should work on all GOTEKs, but I don't have every possible model, infact mine are early models so I can't guarantee that they will.

As long as the root of your USB contains FF.CFG and a bunch of DSKA0000.ssd (or .DSD) files with 0000 and which ever file it tres to load when it does GOTEK din, it should work.

Unfortunatly, the producers of the GOTEK drives keep trimming pennies by changing things around and tweaking the simulation to where something no longer works.

The simplest test is to have FF.CFG and DSKA0000.ssd on the USB stick in the root folder and go down the list until you get to one that doesn't work. Now add and DSKA0001.ssd (or rename it from something else) and a few more should work. If not, the disc selection isn't working!

If the disc selction isn't working, somehow I need to know why to update the code again, but last time I tried, the debug firmwar didn't give any error and nor did the floppy controller, so it was only someone spotting a misimatch in the code to the FF docs (that worked fine until an earlier GOTEK revision) or someone spotting something that they can do to make it work like selecting a game while the disc was still "spinning" (another GOTEK revision break).

The corrupt screens etc sound like something else is wrong.
User avatar
danrolfe
Posts: 37
Joined: Thu Nov 19, 2020 8:36 pm
Contact:

Re: A new MENU system for MMC/Gotek

Post by danrolfe »

Thanks. That doesn't seem to help. Gives me the screen of junk on boot. I think I saw someone else on the thread suggesting something like that could be coming from data overflowing into screen memory. A page issue maybe?

I tried one which does at least show the menu and reducing to just the first DSK file but still no luck. Is there any other useful info I could provide?

I could bring the Gotek along with me to Revival next month for you to have a look if you like if you're keen to diagnose? Not sure I'll have space for the Beeb.
User avatar
tricky
Posts: 7716
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: A new MENU system for MMC/Gotek

Post by tricky »

The menu is *run so it ignores page.

We have seen disc doctor and other ROMs block the commands to the gotek.

Either way, disabling all unnecessary ROMs might help.

I'll see if I can get a beeb set up for a gotek for the show, the two I have are internal to a master and compact.

I think the newer goteks will need the 512B versions.
Post Reply

Return to “8-bit acorn software: other”