wolfenstein demo for sega genesis

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Thu Oct 03, 2013 10:04 pm

Sdw wrote:The test version (tfmsmd.rar) plays back correctly on my PAL Megadrive with using and Everydrive MD.
The latest Wolf3D build (wol3ddemo_b2.rar) however does not, sound effects sound fine, but the music is just some isolated blips and blops, nothing at all like the test version.
Thanks for trying this rom sdw, it uses the z80, but for my Wolf3D demos I use the code for "GCC" then I converted to asm, both drivers come with the tfm music maker, but I realized something: both have errors in the initialization of the YM2612 look at these codes:

Code: Select all

  gcc code:

  if(!TFCP.play) /* mute ym2612 */
 {
	 ym2612wr(0x2f,0,0); /* freq.scaler */
	 ym2612wr(0x2d,0,0);
	 ym2612wr(0x22,0,0); /* LFO off */
	 ym2612wr(0x2b,0,0); /* DAC off */
	 ym2612wr(0x27,0,0); /* CH3 normal mode */
	 ym2612wr(0x27,0,1); /* CH3 normal mode */
	 for(cc=0;cc<2;cc++)
	 {
		 for(aa=0;aa<3;aa++)
		 {
		  for(bb=0x30;bb<0x40;bb+=4) ym2612wr(aa+bb,0x00,cc); /* dt1/mul */
		  for(bb=0x40;bb<0x50;bb+=4) ym2612wr(aa+bb,0x7f,cc); /* tl */
		  for(bb=0x50;bb<0x60;bb+=4) ym2612wr(aa+bb,0x00,cc); /* rs/ar */
		  for(bb=0x60;bb<0x70;bb+=4) ym2612wr(aa+bb,0x00,cc); /* am/d1r */
		  for(bb=0x70;bb<0x80;bb+=4) ym2612wr(aa+bb,0x00,cc); /* d2r */
		  for(bb=0x80;bb<0x90;bb+=4) ym2612wr(aa+bb,0x0f,cc); /* d1l/rr */
		  for(bb=0x90;bb<0xa0;bb+=4) ym2612wr(aa+bb,0x00,cc); /* ssg-eg */
		  ym2612wr(0xb0+bb,0x00,cc); /* fb/algo */ ------->should be: ym2612wr(0xb0+aa,0x00,cc);<-----
		  ym2612wr(0xb4+bb,0x00,cc); /* ams/fms */ ------->should be: ym2612wr(0xb4+aa,0x00,cc);<-----
		  ym2612wr(0x28,aa+(cc<<2),0); /* keyoff */
		 }
	 }
 }

Code: Select all

 
   z80 code:

    ld ix,#4000     ;sel. bank #0
    CALL tfminiPP
    ld ix,#4002     ;sel. bank #1
    call tfminiPP

    ld bc,#0700      ;keyoff's
    ld a,3
tfmShK0
    cp c
    call nz,keyOff
    inc c
    djnz tfmShK0
    ret
 

tfminiPP
    ld bc,#1000
    ld de,#3000
    call ymWrPortFL ;dt1,mul=#00
    ld e,#7f
    ld b,#10
    call ymWrPortFL ;tl=#7f
    ld e,c
    ld b,#30
    call ymWrPortFL ;rs,ar,am,d1r,d2r=#00
    ld e,#0f
    ld b,#10
    call ymWrPortFL ;d1l,rr=#0f
    ld e,c
    ld b,#28        ;all other regs=#00

ymWrPortFL
    WaitStatus
    ld (ix),d
    inc d
    WaitStatus
    ld (ix),e       ;--------> should be: ld (ix+1),e <---------
    djnz ymWrPortFL
    ret
;---------------------------


;---------------------------
 
keyOff
    WaitStatus
    ld (iy),#28
    WaitStatus
    ld (iy+1),c
    ret
If you look at the version of GCC, where it is marked, the regs "fb/algo" and "ams/fms" are not initialized because instead of writing to 0XB0-0xB2 and 0xB4-0xb6, is always writing to 0x50 and 0x54.

In the version for z80 is even worse, most of the registers are not initialized because instead of writing to $4000($4002) and then to $4001($4003), it always writes to $4000($4002) and then again to $4000($4,002), but at least the regs #22, #2b, #2f, #2d, #27 (before this part of the code) and #28 (KeyOff) are initialized correctly.

Then I wonder: is necessary to initialize all the YM2612 regs?, Because this rom (tfmsmd.rar) uses the z80 and not initialized all regs, but works fine on real hardware.

I made two versions of the rom, one (wolf3ddemo_b2_posfix.bin), which fix the error in the regs. 0XB0 - 0xb6, and the other (wolf3ddemo_b2_zclr.bin) where only some registers are initialized as in the z80.
Here is the link to download:
http://www.mediafire.com/download/e2035 ... b2test.rar

TmEE co.(TM)
Very interested
Posts: 2388
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Oct 04, 2013 7:31 am

In theory the YM regs are cleared on reset. When Z80 is in reset the YM is also in reset (the line is shared).
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Oct 04, 2013 7:33 am

i don't know if it can help but i also remember experiencing issues with the TFM driver with SGDK, the way it was requesting the z80 bus could fault on real hardware (not waiting for acquired state)... i modified it to use my methods now and it work normally now :)

gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Fri Oct 04, 2013 10:02 pm

Stef wrote:i don't know if it can help but i also remember experiencing issues with the TFM driver with SGDK, the way it was requesting the z80 bus could fault on real hardware (not waiting for acquired state)... i modified it to use my methods now and it work normally now :)
You mean to do this? ...

Code: Select all

ym2612wr:
   ;d0 = reg,  d1 = val,  d2 = bank
   ;a0 = $a04000

   move.w #$100,$a11100    ;busreq on
   nop
   nop
   nop
z80notready:           ;\
   btst  #0,$a11100      ;<---------------this?
   bne.s z80notready   ;/

   tst.b $a01ff0
   beq.s wait1
   clr.w  $a11100     ;busreq off
   nop
   nop
   nop
   nop
   nop
   bra.s ym2612wr
wait1:
   tst.b  (a0)        ;waitstatus
   bmi.s wait1
   move.b d0,0(a0,d2)
wait2:
   tst.b  (a0)        ;waitstatus
   bmi.s wait2
   move.b d1,1(a0,d2)
   clr.w  $a11100      ;busreq off
   rts
I really hope this works :( .

About SGDK, I have seen that has support for EverDrive, with this is possible for me to build my own EverDrive?, Because I really need one and it is practically impossible to find one here. I have two versions of sega genesis and would like to see how it works on both models.

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Oct 04, 2013 10:33 pm

Yeah that is the part of code i was speaking about, just to be sure in SGDK i verify reset is ended as well. Here's the C code for the bus req command in SGDK :

Code: Select all

void Z80_requestBus(u16 wait)
{
    vu16 *pw_bus;
    vu16 *pw_reset;

    // request bus (need to end reset)
    pw_bus = (u16 *) Z80_HALT_PORT;
    pw_reset = (u16 *) Z80_RESET_PORT;

    // bus not yet taken ?
    if (*pw_bus & 0x100)
    {
        *pw_bus = 0x0100;
        *pw_reset = 0x0100;

        if (wait)
        {
            // wait for bus taken
            while (*pw_bus & 0x0100);
        }
    }
}
I guess in your case reset is always ended before requesting bus... anyway replacing old TFM driver Z80 control code with mine fixed the issues i got sometime on the real hardware.

Here are the others Z80 control methods just for info :

Code: Select all

void Z80_releaseBus()
{
    vu16 *pw;

    pw = (u16 *) Z80_HALT_PORT;
    *pw = 0x0000;
}


void Z80_startReset()
{
    vu16 *pw;

    pw = (u16 *) Z80_RESET_PORT;
    *pw = 0x0000;
}

void Z80_endReset()
{
    vu16 *pw;

    pw = (u16 *) Z80_RESET_PORT;
    *pw = 0x0100;
}
SGDK does include some everdrive command but building an everdrive from scratch and implement code to upload your rom is a huge piece of work ! You cannot buy it on some online website ? or you can try cheaper / easier upload solution like this ?

gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Sat Oct 05, 2013 3:20 am

stef wrote:I guess in your case reset is always ended before requesting bus...
Just in case I also added the reset off (works well in fusion and gens):

Code: Select all

ym2612wr:
   ;d0 = reg,  d1 = val,  d2 = bank
   ;a0 = $a04000

   move.w #$100,$a11100    ;busreq on
   move.w #$100,$A11200    ;reset off <-------------
   nop
   nop
   nop
z80notready:
   btst  #0,$a11100
   bne.s z80notready

   tst.b $a01ff0
   beq.s wait1
   clr.w  $a11100     ;busreq off
   nop
   nop
   nop
   nop
   nop
   bra.s ym2612wr
wait1:
   tst.b  (a0)        ;waitstatus
   bmi.s wait1
   move.b d0,0(a0,d2)
wait2:
   tst.b  (a0)        ;waitstatus
   bmi.s wait2
   move.b d1,1(a0,d2)
   clr.w  $a11100      ;busreq off
   rts
My best option would be to build a reprogrammable cartridge using flash memory, because the cost of shipping the EverDrive would be even greater than the cost of a EverDrive!

Well, I made the changes in the rom and I hope this time works well.
Here is the link to download:
http://www.mediafire.com/download/2zz95 ... o_b2_f.rar

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Oct 05, 2013 10:23 am

Good news, your last version seems to work perfectly, just tested on my MD1 :)

gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Sun Oct 06, 2013 3:28 am

Stef wrote:Good news, your last version seems to work perfectly, just tested on my MD1 :)
Thank you very much for helping me in this :D . I hope to hear the same news by others using different models of Sega Genesis/Megadrive.

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Oct 06, 2013 4:02 pm

You're welcome ! I think it will work the same for others models, at least i hope so... why is weird is why the music demo you posted worked fine while it was not "in game".

Sdw
Newbie
Posts: 8
Joined: Mon Oct 10, 2011 7:20 pm
Contact:

Post by Sdw » Sun Oct 06, 2013 8:02 pm

Well, sorry to be the bearer of bad news, but on my setup (PAL Megadrive II + Everdrive), music still does not play correctly.
I tried all three versions posted:
wolf3ddemo_b2_f.bin
wolf3ddemo_b2_posfix.bin
wolf3ddemo_b2_zclr.bin

None of them plays the music correctly. Sometimes I get almost nothing, other times I can hear something playing, but it is very distorted, notes and sounds seems way off.

tfmsmd.bin always works and plays correctly.

Don't know if my hardware is strange somehow, but since tfmsmd.bin works, it does seem probable that there still is some problem in the playback code.

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Oct 06, 2013 8:26 pm

Oh weird, I ill try to test on my others machine then...
I'm using an everdrive to test in case it makes a difference :-/

gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Mon Oct 07, 2013 4:54 am

Too bad!, Did not expect this :( .
I'm running out of ideas, but I could try something else.
I've been reading a "dissasembly" file of sonic1 I downloaded some time ago, and found this:

Code: Select all

sub_7272E:				; XREF: loc_71E6A
		move.b	($A04000).l,d2
		btst	#7,d2
		bne.s	sub_7272E
		move.b	d0,($A04000).l
		nop	
		nop	
		nop	

loc_72746:
		move.b	($A04000).l,d2
		btst	#7,d2
		bne.s	loc_72746

		move.b	d1,($A04001).l
		rts
Maybe I could change the "waitstatus" as they do in sonic1,
ie changing this:

Code: Select all

wait1:
   tst.b  (a0)        ;waitstatus
   bmi.s wait1
for this:

Code: Select all

wait1:
   move.b   ($A04000).l,d2
   btst  #7,d2
   bne.s wait1
Could be the way I do is too fast?
What do you think, worth making a version of the rom this way?

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Oct 07, 2013 8:14 am

You can try at least but i'm not sure it would make any change.
I remember bulletin notes mentioning that you need to take Z80 bus when polling controllers as it may affect Z80 execution but i think the problem is really rare and only affects a few very number of MD2... I did not had time to test on my others hardware yet (CDX and wondermega, i don't own any MD2) but i will do it when i will be back to home.

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Oct 07, 2013 6:01 pm

Tested on my CDX and indeed music does not play correctly, seems like a lot of notes are missing or played incorrectly :-/
Maybe a difference between the YM2612 and the YM3438 ? I remember something about the timer but nothing else special.

gasega68k
Very interested
Posts: 139
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas

Post by gasega68k » Mon Oct 07, 2013 9:10 pm

Maybe a difference between the YM2612 and the YM3438 ?
That's what I think.

Right now I'm building a cartridge with two ram chips 32Kx8 to test the demos in the two sega genesis that I have, but for this I made ​​a 61k version of the demo, removing most of the textures of the walls (has only 7 instead of 35 of the latest version), removing all the sprites, removing the hud and also removing the code to quickly draw the textures, changing by one shorter but slower.
Here is the rom to download:
http://www.mediafire.com/download/wvx1b ... mo_61k.rar
Still sounds bad music in this version? I hope yes :wink:

Post Reply