Page 4 of 25 FirstFirst ... 2345614 ... LastLast
Results 31 to 40 of 245

Thread: Nes

  1. #31
    PCSX2 Coder refraction's Avatar
    Join Date
    Apr 2004
    Location
    Sheffield, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Quote Originally Posted by aprentice
    i've copied and pasted that routine from my gameboy emu, guess its backwards on the nes

    is this correct?

    #define PUSH8(x) mem_write8(0x100+reg.sp,x); reg.sp++
    #define PUSH16(x) mem_write16(0x100+reg.sp,x); reg.sp+=2

    #define POP8() mem_read8(0x100+reg.sp-1); reg.sp--
    #define POP16() mem_read16(0x100+reg.sp-2); reg.sp-=2

    close

    yeh but itd require less maths if you did it like this

    #define PUSH8(x) mem_write8(0x100+reg.sp,x); reg.sp++
    #define PUSH16(x) mem_write16(0x100+reg.sp,x); reg.sp+=2

    #define POP8() reg.sp--; mem_read8(0x100+reg.sp)
    #define POP16() reg.sp-=2; mem_read16(0x100+reg.sp)


  2. #32
    EmuTalk Member hap's Avatar
    Join Date
    Jan 2005
    Posts
    188
    Mentioned
    0 Post(s)
    sorry, i was wrong in my explanation. this is how i have it:

    #define PUSH(x) WRITE_BYTE_RAM(0x100|cpu.S--,x)
    #define PULL() READ_BYTE_RAM(++cpu.S|0x100)

    so for you that would become:
    #define PUSH8(x) mem_write8(0x100+reg.sp,x); reg.sp--
    #define PUSH16(x) mem_write16(0x100+reg.sp,x); reg.sp-=2

    #define POP8() mem_read8(0x100+reg.sp+1); reg.sp++
    #define POP16() mem_read16(0x100+reg.sp+2); reg.sp+=2


    refraction: indeed, but now you can't do blah=POP8() anymore

  3. #33
    PCSX2 Coder refraction's Avatar
    Join Date
    Apr 2004
    Location
    Sheffield, UK
    Posts
    459
    Mentioned
    0 Post(s)
    yeh i did find that a bit odd there, he was incrementing the stack every time something was pushed on to it, i know on the gameboy the start address is 0xFFFE so it would have to stack downwards to avoid overwriting any important data.

    dont know what its like on the NES so i wasnt totally sure there

  4. #34
    EmuTalk Member hap's Avatar
    Join Date
    Jan 2005
    Posts
    188
    Mentioned
    0 Post(s)
    Hmm, i'll have to correct my earlier self on timing I've fixed some things and the mid-scanline test works much better now. One thing i did: making vblank hit at the end of scanline 242, and not at its hblank.

  5. #35
    Moderator aprentice's Avatar
    Join Date
    Nov 2001
    Posts
    1,337
    Mentioned
    0 Post(s)
    scrapped all my gfx code, its was all totally wrong, after reading the ppu docs over and over a few times i have come to this conclusion

    What baffles me the most is the usage of the attribute table, i dont understand why each attribute tables represents a group of 4x4 tiles and why.

  6. #36
    EmuTalk Member hap's Avatar
    Join Date
    Jan 2005
    Posts
    188
    Mentioned
    0 Post(s)
    Why ? to store colours as compact as possible; ppu only has 2kb internal nametable ram.
    How ? Well, the docs describe it very well, but maybe an example would help:

    Visualise Super Mario Bros, you can see that the world is built with many blocks sized 2x2 tiles (16x16 pixels). Each block is using 2 bits out of the attribute table. Take 4 of those blocks and form a square; 4x4 tiles, and you've got an attribute table byte.

    Visualise the top left corner of SMB, comprising 4 typical SMB blocks:
    block a, block b
    block c, block d
    Block a gets its high 2 bits for the palette colour at bits 0 and 1 of the attribute table byte. Block b from bits 2 and 3, block c from bits 4 and 5, block d from bits 6 and 7.

    Now 1 step further: tiles, from the same space:
    tile 1, tile 2, tile 3, tile 4, (5,6,7,8,9,10,etc)
    tile 33, tile 34, tile 35, tile 36, (...)
    tile 65, tile 66, tile 67, tile 68, (...)
    tile 97, tile 98, tile 99, tile 100, (...)
    Tile 1,2,33,34 get their high 2 bits for the palette colour at bits 0 and 1 of the attribute table byte, tile 3,4,35,36 get theirs at bits 2 and 3, etc.

    This specific attribute table byte is located at name_table_start+0x3c0 (ntstart=0x2000, 0x2400, 0x2800 or 0x2c00).


    *edit* can you boot games yet ? what i mean is running the cpu for a few frames without it calling bad opcodes

    *edit2* typo
    Last edited by hap; October 7th, 2005 at 11:50.

  7. #37
    EmuTalk Member hap's Avatar
    Join Date
    Jan 2005
    Posts
    188
    Mentioned
    0 Post(s)
    scrolling works, joypad 1 works, mmc1 works with a few problems, sprites work but no 8x16 mode or sprite overflow or overlapping yet (see zelda pic)
    Seems the shopkeeper owns a rockinghorse, too bad he won't sell that

    *edit* oh, and the emu's got a proper name now
    Last edited by hap; March 9th, 2005 at 03:42.

  8. #38
    Moderator aprentice's Avatar
    Join Date
    Nov 2001
    Posts
    1,337
    Mentioned
    0 Post(s)
    nice job, looking good. I took a few days off on mine, got kind of frustrated figuring out the gfx. Prolly getting back to work on it today or tomorrow

  9. #39
    EmuTalk Member hap's Avatar
    Join Date
    Jan 2005
    Posts
    188
    Mentioned
    0 Post(s)
    Poor Doc, looks like he could use a doctor himself, or maybe he's just ****** off at Glass Joe for stealing his bike

  10. #40
    Moderator aprentice's Avatar
    Join Date
    Nov 2001
    Posts
    1,337
    Mentioned
    0 Post(s)
    Quote Originally Posted by hap
    Poor Doc, looks like he could use a doctor himself, or maybe he's just ****** off at Glass Joe for stealing his bike
    How do you handle vram banking in your emu?

Page 4 of 25 FirstFirst ... 2345614 ... LastLast

Similar Threads

  1. How to make a Usb Nes controller.
    By Fender432 in forum Jnes
    Replies: 3
    Last Post: November 10th, 2004, 14:30
  2. Get 700+ games for nes
    By GlM in forum Jnes
    Replies: 5
    Last Post: July 23rd, 2004, 01:24
  3. Palm OS5 NES emulator?
    By jgyurkovitz in forum Jnes
    Replies: 0
    Last Post: January 5th, 2003, 08:53
  4. NES Emulation
    By mexican(Aus) in forum NES Emulation
    Replies: 4
    Last Post: September 8th, 2002, 02:25
  5. NES Gun Games
    By Tekken in forum NesterDC
    Replies: 0
    Last Post: January 1st, 2002, 18:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •