CHIP8 thread

Discussion in 'Web development / Programming' started by Dax, Nov 21, 2008.

  1. omegadox

    omegadox Code it the hard way :P

    Messages:
    1,267
    Likes Received:
    0
    [​IMG]

    :)

    I want to make a test unit some day:

    - Test Math results / Binary Coded Decimal
    - Test 0xF Flag on AND, OR, XOR, ADD, SUB, Collision
    - Test syscalls
    - Test Save/Load RPL flags
    - Test Call / Jump
    - Test for Vertical Wrap hack (Blitz was created on machines that didn't support vertical wrap)
    - Test for normal wrapping
    - Test fonts
    - Super Chip8 tests
    - maybe mega chip tests?


    Note about hybrid games: They are special chip8 programs containing native runtime code. Some are really whole native programs that doesn't use the chip8 interpreter at all (I wouldn't call them chip8 programs or hybrid :p). The normal [real] hybrids just use syscalls to call native CDP1802 code inside the rom itself which help chip8 games access any part of memory such as the video buffer, chip8 registers, stack memory, chip8 interpreter work memory. Also can read the cdp1802 register for some info such as pointers, PCs, and interrupt info. I also think its illegal in chip8 programming to have programs call code outside the rom such as interpreter code or the HW rom.
  2. BestCoder

    BestCoder Member

    Messages:
    46
    Likes Received:
    0
    Last edited: Jul 26, 2011
  3. xampf

    xampf New Member

    Messages:
    4
    Likes Received:
    0
    thanks for that great testroom helped me quite a lot :)

    Merci beacoup keep your good work up !

    Edit: finished my Chip-8 Emulator now, its entierly written in Java.
    Could upload it if someones is interested
    Last edited: Sep 10, 2011
  4. BestCoder

    BestCoder Member

    Messages:
    46
    Likes Received:
    0
    You're welcome.
  5. nondescript

    nondescript New Member

    Messages:
    11
    Likes Received:
    0
    confusion over SHR instruction

    hi guys,

    I am following cowgod's chip 8 documentation to code up my emulator in java and i am having problem understanding the following instruction

    8xy6 - SHR Vx {, Vy}
    Set Vx = Vx SHR 1.

    If the least-significant bit of Vx is 1, then VF is set to 1, otherwise 0. Then Vx is divided by 2.

    It says to shift by 1, if so, what is the use of y in the instruction 8xy6. Can anyone clarify that for me? Appreciate your help!:thumb:
  6. refraction

    refraction PCSX2 Coder Contributors Award Winner!

    Messages:
    10,102
    Likes Received:
    19
    there is no use for the Y, just ignore it :) It's probably just in there for opcode format purposes.
  7. nondescript

    nondescript New Member

    Messages:
    11
    Likes Received:
    0
    Thanks! refraction,

    I have another question. I am implementing the draw function. According to the specs, when writing new pixels the pixels are xored. That would mean if in a position there is a pixel written and if i write 0 then the pixel wont get cleared. Is that correct? I was assuming the sprite bits in the memory is what will be written in the screen.
  8. tykel

    tykel Sober coder

    Messages:
    462
    Likes Received:
    4
    Yeah: (old ^ new = ...)
    0 ^ 0 = 0
    1 ^ 1 = 0
    1 ^ 0 = 1
    0 ^ 1 = 1

    So basically, two set pixels cancel each other out.
  9. Stefonzo

    Stefonzo New Member

    Messages:
    2
    Likes Received:
    0
    Hello I'm new here and have been recently working on programming a chip-8 emulator in c++. I have split the code into three parts, chip8.h, chip8.cpp, and main.cpp. I have finished chip8.h and am working on chip8.cpp however have one question:
    What memory location is 'NN' or 'NNN' referring to? Sorry if this is in the wrong section.

    Thanks
    Stefonzo
  10. refraction

    refraction PCSX2 Coder Contributors Award Winner!

    Messages:
    10,102
    Likes Received:
    19

    NN literally refers to 2 numbers and 3 for NNN. So NN can be any number from 0x00 up to 0xFF and NNN can be anything from 0x000 up to 0xFFF
  11. Prads

    Prads New Member

    Messages:
    92
    Likes Received:
    0
    Just wanted post my dynarec chip8 emulator that I wrote in the past. Thought it might be helpful for people who wants to learn how write a dynarec cpu. I created this just for learning purpose, to teach myself about dynarec so the code isn't perfect.

    And no input and sound emulation, so it just shows the first screen. :p
    Link: http://www.pradsprojects.com/downloads/Chip 8 dynarec.7z
  12. xampf

    xampf New Member

    Messages:
    4
    Likes Received:
    0
    I didnt look into it yet, but does it handle self-modifying code? And how did you assign the registers?
    And it would be great if you would post it also over at emutalk, it looks very promising!
  13. Prads

    Prads New Member

    Messages:
    92
    Likes Received:
    0
    Nah it doesn't handle self modifying codes. I didn't want to make the code too complicated that it would scare people away. lol :p
    Last edited: Jun 19, 2012
  14. refraction

    refraction PCSX2 Coder Contributors Award Winner!

    Messages:
    10,102
    Likes Received:
    19
    It doesn't make it too much more complicated. In the recompiling code area, keep an array of memory and when you "read" a bit of memory for the opcode, write to this second array the block start address of that recompiled code, then when you do a write to memory, you can check that array to see if it has a value (you can even have a .isRecd bool on it if you want just incase 0 is the address written to :p) and if it has an address, clear that address in the recompiler cache so it needs to be recompiled.

    its more complicated to explain than implement >.< lol. This is what i did on my chip16 emu anyways :)
  15. Prads

    Prads New Member

    Messages:
    92
    Likes Received:
    0
    Yeah that makes sense. I can use that in my current emu project. Thanks! :)
  16. KrossX

    KrossX クロスエクス

    Messages:
    4,664
    Likes Received:
    125
    Because I had to give it a try too mostly to learn about video and sound output...
    After quite some work, then after a ton of more work to actually get some pictures I got this!

    [​IMG]

    Just to see I was reading the sprite bytes wrong and how it hangs right there... :dead:

    [​IMG]

    Now that looks more decent.
    Also, it requires a D3D11 GPU. :p

    #EDIT: Ooops, forgot... timers.

    #EDIT2: Yay! With a thousand FPS points! :x3:

    [​IMG]

    #EDIT3: Superrrr!

    [​IMG]
    Last edited: Sep 26, 2012
  17. KrossX

    KrossX クロスエクス

    Messages:
    4,664
    Likes Received:
    125
    Question! I gotta go, so I'll post this before that. I still haven't read the entire thread though, sorry if this has been answered.

    I was checking this demo/test...
    [​IMG]

    I previously simply scaled whether super8 stuff was enabled or not. If enabled, display works like at 128x64 otherwise 64x32. Buuuut! This demo calls 0x00FE on startup and at the end scrolls down 1. But, the scrolling function works at 128x64 even with Super8 disabled. It also let me know that n=0 with Super8 disabled is still a big sprite (8x16).

    So ma'question is, in the MegaChip, when this super/scroll functions are used, do they work at SuperChip resolution or MegaChip resolution? :dead:
  18. Hatorijr

    Hatorijr Emu Author

    Messages:
    613
    Likes Received:
    1
    been a while since i looked into megachip, last i looked there really was not nearly enough information available to emulate it, has that since changed?
  19. Shendo

    Shendo Moderator Staff Member Moderator

    Messages:
    5,154
    Likes Received:
    45
    Um? What is Super8? You mean Super Chip?
    And for MegaChip do you mean new extension (2007) or SuperChip?

    There are three different virtual machines:
    Chip8 (Original)
    SuperChip (Extension)
    MegaChip (Extension, but the author did not bother to release official emulator for 5 years, ignore it).
  20. KrossX

    KrossX クロスエクス

    Messages:
    4,664
    Likes Received:
    125
    My apologies for the terms used. When I used "super8" and "Super8" though I thought to refer to the SuperChip from the first post, I actually just refer to 0x00FE and 0x00FF of said SuperChip. When I mentioned MegaChip, I meant as the MEGAChip mentioned in the first post.

    I'll refrain from making such confusing and silly questions, my apologies again.

Share This Page