Page 105 of 106 FirstFirst ... 55595103104105106 LastLast
Results 1,041 to 1,050 of 1057

Thread: Chip 8

  1. #1041
    EmuTalk Member
    Join Date
    Aug 2016
    Posts
    25
    Mentioned
    0 Post(s)
    thats pretty weird... I've been through your code line by line and apart of type casting that i didn't do it seems good. Can you update your git so i can take a look at your updated efforts?
    btw at this point it would be wise to dump your registers and opcodes on a file to see if they are been called in the same order as other emulators

    Mine:

    a21e - Set I (0) = NNN (21e)
    c201 - Randomizer Code Vx = 0
    3201 - Skip if Vx(1) == NN(1) - True
    d014 - Drawing sprites
    7004 - Add Vx(0) += NN (4)
    3040 - Skip if Vx(4) == NN(40) - False
    1200 - Jump to Address - 1NNN(200)
    a2e1 - Set I (21e) = NNN(21e)
    c201 - Randomizer Code Vx = 1
    3201 - Skip if Vx(1) == NN(1) - True
    d014 - Drawing sprites

    That's mine maybe your randomizer will be different but, this is the order for 2 frames of mine



    I'm thinking maybe your vX variables are been overwriten at runtime so your Vx is always adding 0
    Last edited by ]-[ D X; June 8th, 2017 at 23:49.

  2. #1042
    EmuTalk Member
    Join Date
    Jun 2017
    Posts
    10
    Mentioned
    0 Post(s)
    The type casting comes from processing.

    I didn't update my git since I haven't made any progress so far.

    About the registers and opcodes, I compared them with other emulators (you can see all the println everywhere in my code)

    I was getting nervous since it's only the second program that I'm coding but you reassured me since you do seem to believe my reasoning is correct.

    This can't come from a subtlety of processing that we don't get ?

    I'm not a fan of processing, I feel like trying with c and SDL.

    What do you think ? Is it worth a try on something else that processing ?

    - - - Updated - - -

    I replied before seeing your updated post.

    I just checked the order of my opcodes, they're exactly like yours.

    I also checked the value of Vx, (I haven't thought about it at all) it alternates between 0 and 1 regularly.
    Last edited by Okabe; June 9th, 2017 at 00:08.

  3. #1043
    EmuTalk Member
    Join Date
    Aug 2016
    Posts
    25
    Mentioned
    0 Post(s)
    But you are getting output on a console window. Please verify you are getting different values for V[x] on your 0x7000 case
    get rid of those (char) casts and post your results please also on the

    case 0x7000:
    V[x] = char((V[x] + kk) & 0xFF);
    //println("Add kk to V[x] : ", hex(V[x]));
    break;

    //Already told you what bothered me with this one.. i hope you changed it to V[x] += V[x] + kk;

    case 0xC000:
    int randomNumber = int(random(255)) & kk;
    V[x] = char(randomNumber);
    println(randomNumber);
    //println(hex(kk));
    break;

    This one... I'm not familiar with random() used like that, maybe is your own function... and I don't know how it work but you strictly define it as int. try including <stdlib,h>
    and just using

    V[x] = (rand() % 255) & kk);
    let's see if that fix your issue

    It's remarkable this is only your second coding project keep it up.
    Last edited by ]-[ D X; June 9th, 2017 at 00:14.

  4. #1044
    EmuTalk Member
    Join Date
    Jun 2017
    Posts
    10
    Mentioned
    0 Post(s)
    I didn't know the console wasn't 100% reliable. Thank you for the info

    I've never heard about "dump" before, after a little research with the terms "dump java" on google I see "thread dump" and "heap dump" appearing a lot.

    Is that what you're talking about ?

    All the char cast are definitely a pain in the ass but the console of processing specificly told me to do so and won't "compile" if I don't.

    You are right about " V[x] += V[x] + kk;" I should have kept it, my bad :p

    The random() function comes from processing, I tried to include <stdlib,h> but the console give me the error "unexpected token: class"

    I really feel like my problem comes from my misunderstanding of processing.

    - - - Updated - - -

    Everytime I'm using bit shift or the & operator, it seems to come out as a int by default.

    For instance, if I try :

    char x = (opcode & 0x0F00) >> 8;

    the console says "Type mismatch, "int" doesn't match with "char"

    But I think I have to use "char" with registrers, memory and all of that since it's the only unsigned type in Java.

    Am I wrong ?
    Last edited by Okabe; June 9th, 2017 at 01:01.

  5. #1045
    EmuTalk Member
    Join Date
    Aug 2016
    Posts
    25
    Mentioned
    0 Post(s)
    Quote Originally Posted by Okabe View Post
    I didn't know the console wasn't 100% reliable. Thank you for the info

    I've never heard about "dump" before, after a little research with the terms "dump java" on google I see "thread dump" and "head dump" appearing a lot.

    Is that what you're talking about ?

    All the char cast are definitely a pain in the ass but the console of processing specificly told me to do so and won't "compile" if I don't.

    You are right about " V[x] += V[x] + kk;" I should have kept it, my bad :p

    the random() function comes from processing, I tried to include <stdlib,h> but the console give me the error "unexpected token: class"

    I really feel like my problem comes from my misunderstanding of processing.

    Ohh no a dump is just a text file where you log your instructions
    The IDE shouldn't dictate what you do. Type casting (forcing a variable type different that the one you originally declared) shouldn't be an issue.

    Type casting works like this. You say int var = 256;
    if you try to print the value it will be in fact be 256
    now if you cast it (char)var that will produce the ASCII character number 256 (which is an blank space)
    as far as i see that's your problem along with the adding on top. You can get rid of your

    it was dot on the include my bad try wth
    #include <stdlib.h>

  6. #1046
    EmuTalk Member
    Join Date
    Jun 2017
    Posts
    10
    Mentioned
    0 Post(s)
    After more research about the "dump" you were talking about I think I found what that is.

    Is that this ? https://msdn.microsoft.com/en-us/library/d5zhxt22.aspx

  7. #1047
    EmuTalk Member
    Join Date
    Aug 2016
    Posts
    25
    Mentioned
    0 Post(s)
    Wait a second! why are you using char for opcode!

  8. #1048
    EmuTalk Member
    Join Date
    Jun 2017
    Posts
    10
    Mentioned
    0 Post(s)
    Including the line "#include <stdlib.h>" gave me the error: unexpexted char: "i"

    Thank you for you explanation about type casting, I tried to change every "char" into "int" and it worked....but it didn't change my problem :p

    But at least, I know that I don't need to use "char" contrarely to what I thought.

  9. #1049
    EmuTalk Member
    Join Date
    Aug 2016
    Posts
    25
    Mentioned
    0 Post(s)
    I meant a dump like a log. just logging your println functions.
    Dude i'm concerned about your (char) all over your code are killing your functionality

    it's like declaring something and asking for other thing. that's why typecasting is dangerous. go back to the drawing board cause your code should work without needing it to typecast like that... i'm a little rusty as i'm currenlty working on gameboy, but let me see if i can find the resource doc i used

    - - - Updated - - -

    I mean you don't use (char) nor (int) at all... you just let the compiler work with your declared variable type

    - - - Updated - - -

    http://www.multigesture.net/articles...8-interpreter/ look at the Fetch opcode.
    If you use a char variable for opcode whenever you shift, you should be getting rid of a part of your actual opcode. The only reason you are getting away with it is cause your are type casting hard... like telling the compiler... "Nah dude just use whatever it fits" instead of what you intended. As a side effect it seems you are indeed catching the start of the opcode but not the rest of the content

    1201 a full opcode could be interpreted on your end as 1200 that's why i posted a log of my execution before.
    also the program counter should also be a short variable.

    btw dont use char use unsigned char and unsigned short to tell the compiler you are only allowing positive numbers
    Last edited by ]-[ D X; June 9th, 2017 at 01:27.

  10. #1050
    EmuTalk Member
    Join Date
    Jun 2017
    Posts
    10
    Mentioned
    0 Post(s)
    I don't know how to log my println in a file but I'll check that out.

    I used char for opcode because from what I remember of my research about chip8 emulation, I thought I had to use unsigned type for opcodes otherwise the bit shifting would possibly be more complex and because you could possibly get a value too high (above 255) that wouldn't be recognized by the chip8.

    But I tried to get rid of every char, since you told me that those type casting could be the problem.
    It didn't break my emulator, but it didn't solve the problem neither.

    I made a second folder with my chip8 emaulator without any char.
    https://github.com/Okarin85/Chip8-Pr..._2/Chip8_2.pde

    I couldn't get rid of the int cast at the line 38 because if I do, I get the error : unexpected token: int
    I couldn't get rid of the int cast at the line 75 because the random() function return a float, if I try without casting randomNumber in a int, it gives me the error : The operator & is undefined for the argument type(s) float, int

    If I use a short for the variable pc I got an error at the line 49.
    It says : "cannot convert from int to short"

    It's because at the line 49, I'm setting "pc" to the value of "nnn".
    pc = nnn;

    and the variable nnn can only be an int since it results from the operator "&"
    int n = opcode & 0x000F;

    I think you're right to be concerned about all of those type casting.
    it confuses me a lot but believe me, I didn't came out with all those type casting on my own.
    It's the results of all my attempts to fix the errors that processing is giving me.

    I greatly appreciate the time and the effort you gave to help me with this but I'm done with processing :p
    I going to try to make my emulator with c and sdl.
    Since you did a lot to help me, I'll keep you inform of my progress on this.

    Thank you very much ]-[ D X

Page 105 of 106 FirstFirst ... 55595103104105106 LastLast

Similar Threads

  1. Nintendo DS specifications leaked
    By Gorxon in forum Gaming
    Replies: 37
    Last Post: June 25th, 2004, 22:16
  2. C&T 69000 video chip
    By Knuckles in forum TechTalk
    Replies: 4
    Last Post: June 16th, 2003, 00:43
  3. Rice's Daedalus 5.0.0 source code
    By Rice in forum 1964
    Replies: 19
    Last Post: June 15th, 2003, 09:39
  4. Replies: 18
    Last Post: December 7th, 2002, 10:59

Posting Permissions

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