Version 3.1 of Nabu Games ** FIXED in v3.3 **

The author of CPM Tetris and Snake.
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

Oh sorry I didn’t test in the metal. I’ll do that in a bit for ya. Stay tuned
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

When the save is attempted, do you receive an error message in the Internet adapter?
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Version 3.1 of Nabu Games ** FIXED **

Post by productiondave »

no - nothing at all. It just sits there.

When I reset the service, the log shows "Releasing 3 RetroNet file handles" (CPM, A and C:) I can tell because that's what it shows as opening again after the reset and I switch to C:


Have you seen any error messages or the same symptoms. It would be good to know if the problem happens on more than just my NABU machine.
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

The first time I ran it, there was an error about the drive image not being large enough - which was my issue. I'm not using a makefile, so my batch file didn't create the eight mb disk image.

I reran it with the correct image size and kept receiving the same error of a timeout with the internet adapter's connection. I didn't get a chance to look into it because the room I was in needed Visual Studio to be updated before loading the project. I set it to update, and I'll check tomorrow. We'll get it :) It's just zeros and ones, ha.
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Version 3.1 of Nabu Games ** FIXED **

Post by productiondave »

I did sometimes see a timeout in the IA. Not always though and in my most recent test, I did not see the timeout message.

Do you know where I can find the logs for the IA? Do they get recorded in a text file somewhere?
Also do you have more verbose logging that can be enabled when I start the adapter? Some kind of secret commandline switch maybe?

I saw you had updated the example project to include the DD command. I guess I should have mentioned this. It's also a gotcha for when these are in A: User Area 3. Folks who want to *keep* their high scores should move the game over to C:

*** UPDATE ***

So I have been working on my own here and decided to try moving the save function back to before the play crash sound. And would you know it, it's working again.

I have pushed this code into a branch: https://github.com/linuxplayground/nabu ... ke/snake.c

Have a look at the end of the game function.

Code: Select all

    /* We have crashed - update and save high score */
    if (high_score < score ) {
        high_score = score;
        setHighScore(high_score);
    }

    // play crash sound
    ayWrite(6,  0x0f);
    ayWrite(7,  0b11000111);
    ayWrite(8,  0x1f);
    ayWrite(9,  0x1f);
    ayWrite(10, 0x1f);
    ayWrite(11, 0xa0);
    ayWrite(12, 0x40);
    ayWrite(13, 0x00);

    /* NOTE XXX
    * If I try to save the high score here (after playing the crash sound) The game crashes.
    * It does not crash when I try to save the high score immediately before these
    * ayWrite() calls.
    * Which is a pain, because there is this short delay before the crash audio when the high
    * score is saved to disk.
    */
So is there something funky with the way z88dk handles these `out` instructions... I did try injecting a push iy and pop iy but that just broke everything. Or back to the serial handler on the IA, being funky with the bits.

Code: Select all

  1183                          ;	---------------------------------
  1184                          ; Function ayWrite
  1185                          ; ---------------------------------
  1186                          _ayWrite:
  1187  0170  fd210000          	ld	iy,2
  1188  0174  fd39              	add	iy, sp
  1189  0176  fd7e00            	ld	a,(iy+0)
  1190  0179  d300              	out	(_IO_AYLATCH), a
  1191  017b  fd7e00            	ld	a,(iy+0+1)
  1192  017e  d300              	out	(_IO_AYDATA), a
  1193  0180  c9                	ret
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

I didn’t review the code yet and I’m using my phone rn. But it looks like you’re talking to the ay directly. Can you verify the registers that you’re changing are not affecting the ioportA or ioportB in/out. I’m not in front of my computer so I can’t check for you. But there’s a reg that configured the ay I/o and if you accidentally disabled it, it would cause issues with using hcca
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Version 3.1 of Nabu Games ** FIXED **

Post by productiondave »

!!! I FOUND IT !!!

You have really helped - When you said I might be messing with the registers it got me thinking.

In order to generate a crash sound, I needed to enable the Noise channel. The way to do that is to write a bitmask to REGISTER 7 - The mixer.

Bits 7 and 6 are used to enable / disable IO PORTA and IO PORTB. I was just disabling them because I didn't need them.

When I had a look at the initNabuLibAudio() function in NABU-LIB, I see that you are leaving PORTA enabled. You have explained why in your previous reply and so I knew what I needed to do.

the reason things worked before when I was playing the crash sound after saving the high score was because I am calling initNABULIBAudio(); when I set up the game every time a player starts the game again.

Here was the offending line in my code:

Code: Select all

ayWrite(7,  0b11000111); //mixer DISABLE IOPORTA, DISABLE IOPORTB, ENABLE NOISE A, B and C, DISABLE TONE A,B and C
and the correction:

Code: Select all

ayWrite(7,  0b01000111); //mixer ENABLE IOPORTA, DISABLE IOPORTB, ENABLE NOISE A, B and C, DISABLE TONE A,B and C
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

yeah you got it! Port A should be set for output and port b is input.
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Version 3.1 of Nabu Games ** FIXED **

Post by productiondave »

Thanks DJ.

I have released a new version with this fix and made a different post. Happy Easter! (Sunday here already)
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Version 3.1 of Nabu Games ** FIXED **

Post by DJ Sures »

happy easter to you as well!
Post Reply