nesdev.comhttp://forums.nesdev.com/ WIP: Wizard of Worhttp://forums.nesdev.com/viewtopic.php?f=22&t=16172 Page 7 of 12

 Author: Omegamatrix [ Fri Aug 11, 2017 12:34 pm ] Post subject: Re: WIP: Wizard of Wor tschak909 wrote:The modulo is the problem here, given an integer divide by 24 such as:Code:;; void __fastcall__ div24(unsigned char d);_div24: lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr        rtsHow can I determine a modulo? Is it sitting here in temp at some point?-ThomModulo is easy, there are a few ways to do it. You'll have to figure out how to integerate it into C though. Here's a few ways:Long slow division does not take too long in this case as 24 is a big divisor.Code:;24-94 cycles_div24_mod24:        ldy   #\$FF        sec_div24:        iny        sbc   #24        bcs   _div24        adc   #24        rts   ; Y = integer division result, A = modulo resultUsing the unsigned integer division routine for div24, modulo24 can be found afterward with the help of a small look up table:Code:;54 cycles  _div24_mod24:         pha   ; save original value        lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr                tay   ; integer division result        pla   ; get original value        sec        sbc   _multiply24,Y        rts   ; Y = integer division result, A = modulo result_multiply24:        .db 0,24,48,72,96,120        .db 144,168,192,216,240If you don't want to trash Y, you could just multiply by 24 instead of using a look up table.Code:_div24_mod24:         pha   ; save original value        lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr                        ; C 76543210        sta   intDiv24  ; x 0000xxxx    integer division result (0-10 possible)                asl             ; 0 000xxxx0    x2        asl             ; 0 00xxxx00    x4        asl             ; 0 0xxxx000    x8        sta   TEMP        asl             ; 0 xxxx0000    x16 (carry is always clear at this point)        adc   TEMP      ;               x24        sta   TEMP        pla   ; get original value        sec        sbc   TEMP      ; A = modulo result, intDiv24 = integer division result        rtsHope that helps!

 Author: tschak909 [ Fri Aug 11, 2017 1:23 pm ] Post subject: Re: WIP: Wizard of Wor Omegamatrix wrote:tschak909 wrote:The modulo is the problem here, given an integer divide by 24 such as:Code:;; void __fastcall__ div24(unsigned char d);_div24: lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr        rtsHow can I determine a modulo? Is it sitting here in temp at some point?-ThomModulo is easy, there are a few ways to do it. You'll have to figure out how to integerate it into C though. Here's a few ways:Long slow division does not take too long in this case as 24 is a big divisor.Code:;24-94 cycles_div24_mod24:        ldy   #\$FF        sec_div24:        iny        sbc   #24        bcs   _div24        adc   #24        rts   ; Y = integer division result, A = modulo resultUsing the unsigned integer division routine for div24, modulo24 can be found afterward with the help of a small look up table:Code:;54 cycles  _div24_mod24:         pha   ; save original value        lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr                tay   ; integer division result        pla   ; get original value        sec        sbc   _multiply24,Y        rts   ; Y = integer division result, A = modulo result_multiply24:        .db 0,24,48,72,96,120        .db 144,168,192,216,240If you don't want to trash Y, you could just multiply by 24 instead of using a look up table.Code:_div24_mod24:         pha   ; save original value        lsr        lsr        lsr        sta   TEMP        lsr        lsr        adc   TEMP        ror        lsr        adc   TEMP        ror        lsr                        ; C 76543210        sta   intDiv24  ; x 0000xxxx    integer division result (0-10 possible)                asl             ; 0 000xxxx0    x2        asl             ; 0 00xxxx00    x4        asl             ; 0 0xxxx000    x8        sta   TEMP        asl             ; 0 xxxx0000    x16 (carry is always clear at this point)        adc   TEMP      ;               x24        sta   TEMP        pla   ; get original value        sec        sbc   TEMP      ; A = modulo result, intDiv24 = integer division result        rtsHope that helps!OMEGAMATRIX! How are you, man? Good to see you over here from AtariAge. I just signed up here for my first NES project. also, thanks for the fast divide routines. They're great. -Thom

 Author: Omegamatrix [ Fri Aug 11, 2017 2:47 pm ] Post subject: Re: WIP: Wizard of Wor I'm well. Looking for to see this homebrew develop.

 Author: tschak909 [ Fri Aug 11, 2017 11:31 pm ] Post subject: Re: WIP: Wizard of Wor Adding this block in the aligned condition improves the collision detection to the point where I am no longer going through any walls, BUT, The player tries to change direction one box before the actual corner, which causes the player to not go through the wall, but hit the preceeding wall early and stop trying to round the corner. urgh... Code:      if (PLAYER_PAD_RIGHT(i) && BOX_WALL_RIGHT(d))        stamps[STAMP_STATE(i)]=STATE_PLAYER_RIGHT_IDLE;      else if (PLAYER_PAD_LEFT(i) && BOX_WALL_LEFT(d))        stamps[STAMP_STATE(i)]=STATE_PLAYER_LEFT_IDLE;      else if (PLAYER_PAD_UP(i) && BOX_WALL_UP(d))        stamps[STAMP_STATE(i)]=STATE_PLAYER_UP_IDLE;      else if (PLAYER_PAD_DOWN(i) && BOX_WALL_DOWN(d))        stamps[STAMP_STATE(i)]=STATE_PLAYER_DOWN_IDLE;Attachment: wow-better-player-coll-2.nes [40.02 KiB] Downloaded 89 times Setting it to last state on each if, replicates the through wall behavior, so it looks like I need to dig into last state setting. -Thom

 Author: rainwarrior [ Sat Aug 12, 2017 12:09 am ] Post subject: Re: WIP: Wizard of Wor The lion-head enemies have a nice bounce to them.

 Author: tschak909 [ Sat Aug 12, 2017 12:13 am ] Post subject: Re: WIP: Wizard of Wor rainwarrior wrote:The lion-head enemies have a nice bounce to them.Thanks, I am doing occasional tests on a front loader attached to a cheapo AV upscaler which is just butchering the field output, and would love to see a pic of this running on a real CRT. The NTSC emulation in various emulators just doesn't feel right at all.I will say that it is on my list that the monsters will all eventually have have random frame starts, so they aren't all skipping in unison, but right now, I am trying to get player to wall collision happening correctly. It's almost there. grrrrr...-Thom

 Author: tschak909 [ Sat Aug 26, 2017 1:12 pm ] Post subject: Re: WIP: Wizard of Wor It's been quiet here, as I've been sidetracked on doing some Raspberry Pi work, but I'm continuing back on this, as soon as I hit a stopping point with the work I'm doing on the Pi.-Thom

 Author: tschak909 [ Mon Sep 04, 2017 9:55 pm ] Post subject: Re: WIP: Wizard of Wor is control okay for everybody? You should be able to move and round corners with ease. Let me know.-Thom

 Author: lidnariq [ Mon Sep 04, 2017 10:05 pm ] Post subject: Re: WIP: Wizard of Wor Feels good to me. The bit where trying to walk into a wall makes you continue walking in the previous direction until you can turn strikes me as "surprising, but useful".

 Author: rainwarrior [ Mon Sep 04, 2017 10:19 pm ] Post subject: Re: WIP: Wizard of Wor It's good. I like that you can hold diagonal and it will alternate. That's exactly how I'd want/expect it to work.The only thing that's maybe weird to me is if I press up just a little bit then stop, now pressing either left or right will move me upwards until the next grid, which feels a little weird, but maybe not something that needs to be addressed at all. (It's easy to learn this quirk, and it resolves itself pretty quickly anyway.)Like I think I'd probably make it so that you can't stop moving between grid points, only reverse direction, so there's never a situation where you could have stopped just a little bit out of grid and have left/right forced to move up/down. I don't know if you'd want to do that, though, I presume the original game did not. That's just what I'd do, because it seems like walking a little bit out of the grid is already a commitment to move in that direction, might as well complete it?Right now the sprite overlaps right-hand walls by one pixel.Also kinda wish that my feet didn't always point right when going up/down but that also seems to be that way in the original? (I suppose it would make just as much sense to be able to walk upside-down as well, but that one doesn't feel "missing".)Ejection from the starting point seems weird (immediate pop out, and then one frame of changed direction), but I'll assume that's something you haven't worked on yet.

 Author: Kasumi [ Mon Sep 04, 2017 10:19 pm ] Post subject: Re: WIP: Wizard of Wor The rounding corners is quite fine.But you've got some kind of serious glitch for the two players. When player 2 changes to facing up or down, occasionally it affects player one. Let me know if you need an fm2 or something for debugging.Edit: Oh, I appear to have missed the previous post saying there were problems with going through walls. Maybe the gif is useful for reproducing it, though.

 Author: tschak909 [ Tue Sep 05, 2017 7:58 am ] Post subject: Re: WIP: Wizard of Wor WOW, that's a neat bug. I'll try to squash that today. Thanks for finding it! -Thom

 Author: tschak909 [ Tue Sep 05, 2017 8:25 am ] Post subject: Re: WIP: Wizard of Wor Ok, it has to be here, is there something stupid that I'm doing with regards to reading the player pads?Code:/** * move_players() */void move_players(void){  for (i=0;i<2;++i)    {      get_current_box();      stamps[STAMP_XTRA_B(i)]=pad_poll(i);      if (stamps[STAMP_Y(i)]==PIXEL_BOX_Y(6)-1)        {          handle_player_in_box();        }      else        {          handle_player_in_field();        }    }}

 Page 7 of 12 All times are UTC - 7 hours Powered by phpBB® Forum Software © phpBB Grouphttp://www.phpbb.com/