FANDOM


  • I want to create or port an NES emulator to PTC so I can load and play NES roms without an R4 cart. I've never coded an emulator before. What should I do to make, or port this emulator?

      Loading editor
    • PTC is way too limited to create an emulator. It's feasible to recreate your favorite games, but there's no way to actually create an entire emulator with this limited interface.

      Sorry about that...

        Loading editor
    • It would be quite hard to import the game ROM(s) into something Petit Computer can access, it would make more sense to port the games themselves, as Pixel also said, making an "emulator" unnecessary.

        Loading editor
    • I think it's possible. It'll probably be slow, but still possible.

      How the ROMs will be loaded are in PRG files with DATA commands.

        Loading editor
    • not possible

        Loading editor
    • ColeslawProd wrote:
      I think it's possible. It'll probably be slow, but still possible.

      How the ROMs will be loaded are in PRG files with DATA commands.


      I don't think you understand what we're saying at all.

        Loading editor
    • Lumage wrote:
      ColeslawProd wrote:
      I think it's possible. It'll probably be slow, but still possible.

      How the ROMs will be loaded are in PRG files with DATA commands.


      I don't think you understand what we're saying at all.

      Example:

      Original File

      ABC

      123



      In PTC

      DATA "ABC"

      DATA "123"

        Loading editor
    • How about a GameBoy Emulator?

        Loading editor
    • Here's an example that might help you understand.

      I have calculated that PTC can execute the instruction J=J+1 about 1115 times a second.

      The NES processor runs at approx. 1.7MHz, the Gameboy processor runs at approx. 4MHz.  Now, the rate at which instructions are executed is not the same as the clock speed, I don't have precise details, but I don't think it's as much as a factor of 10 difference.  This means the NES will execute a single increment instruction 170 times faster than PTC could, and the Gameboy, 400 times faster.

      And the emulator not only has to do the actual increment, it first has to fetch the instruction from memory, analyze it to see if it is an increment instruction, then find out which register gets incremented.  The PTC example had the instruction and variable already known, so that's much more overhead again.

      And that's not even taking into account the side-effects of the increment on the status register, or many many other considerations.

        Loading editor
    • PTC can't simulate emulation like that, nor can it make any type of emulator.

        Loading editor
    • You cannot edit or access PRG files from a program. Sorry.

        Loading editor
    • Programgamer wrote:
      You cannot edit or access PRG files from a program. Sorry.

      Oh, you're right. I thought it would use the EXEC command to go to the file, have all the DATA commands load the data, and EXEC again to go back to the emulator. I just found that when I use EXEC to switch, the data gets cleared, so that doesn't work. GRP files would, but you'd need 5-10 of those, though. 

        Loading editor
    • I'll just get an R4 cart and put emulators on that.

        Loading editor
    • ColeslawProd wrote:
      Programgamer wrote:
      You cannot edit or access PRG files from a program. Sorry.
      Oh, you're right. I thought it would use the EXEC command to go to the file, have all the DATA commands load the data, and EXEC again to go back to the emulator. I just found that when I use EXEC to switch, the data gets cleared, so that doesn't work. GRP files would, but you'd need 5-10 of those, though. 

      But, the EXEC command doesn't clear the memory...

        Loading editor
    • I just tested it and it looks like it does. I could've done something wrong, though.

        Loading editor
    • Maybe the program you EXEC has a CLEAR command at the top?

        Loading editor
    • ColeslawProd wrote:
      I just found that when I use EXEC to switch, the data gets cleared, so that doesn't work.

      The data memory does not get cleared; what does get cleared is the program memory containing DATA instructions.

        Loading editor
    • This is how I tested it:

      I saved a program named "READTEST" Here are the contents:

      READ I

      PRINT I

      Then, I wrote another program with this:

      DATA 1

      EXEC "READTEST"

      I ran it, and It returned:

      "Out of DATA (1,READ)"

        Loading editor
    • Would this be possible in PTC 3D?

        Loading editor
    • Right... the second program you show has a DATA instruction in program memory.  The EXEC removes everything from program memory, including the DATA, and instead puts "READTEST" in program memory.  In READTEST, PTC finds the instruction READ.  What this does is, it tells PTC to scan the current program memory for a DATA instruction.  There is none, so it gives an error.

      On the other hand, consider the following programs, which demonstrate that data memory is not cleared:

      'TEST1
      TESTVAR=1
      EXEC "DOTEST"
      
      'TEST2
      TESTVAR=2
      EXEC "DOTEST"
      
      'DOTEST
      PRINT TESTVAR
      

      Executing TEST1 will print 1, executing TEST2 will print 2. EXEC does not alter the values of variables, which is what is meant by "it does not clear data memory".

      It's very very doubtful PTC V3 will behave differently in this regard (with the DATA and READ instructions), but it may have other data and file manipulation facilities.

        Loading editor
    • SquareFingers wrote:
      Right... the second program you show has a DATA instruction in program memory.  The EXEC removes everything from program memory, including the DATA, and instead puts "READTEST" in program memory.  In READTEST, PTC finds the instruction READ.  What this does is, it tells PTC to scan the current program memory for a DATA instruction.  There is none, so it gives an error.

      On the other hand, consider the following programs, which demonstrate that data memory is not cleared:

      'TEST1
      TESTVAR=1
      EXEC "DOTEST"
      
      'TEST2
      TESTVAR=2
      EXEC "DOTEST"
      
      'DOTEST
      PRINT TESTVAR
      

      Executing TEST1 will print 1, executing TEST2 will print 2. EXEC does not alter the values of variables, which is what is meant by "it does not clear data memory".

      It's very very doubtful PTC V3 will behave differently in this regard (with the DATA and READ instructions), but it may have other data and file manipulation facilities.

      What I meant by  "Will this be possible" is the emulation. I should've elaborated.

        Loading editor
    • How about the Atari 2600?

        Loading editor
    • ColeslawProd wrote:
      What I meant by  "Will this be possible" is the emulation. I should've elaborated.

      Even if SmileBasic V3 does approach parity with NES in terms of how fast it can execute broadly the same operation, e.g. incrementing a register/variable, it will fall far short of the capacity to emulate (at least, in anything like a reasonably acceptable speed). Partly because an emulator needs not only to perform the same operations, but it needs to translate from one language (NES code) to another (PTC code) to find out what those operations are. That translation takes time. Once the translation is done, there will still not be a one-to-one correspondence because the details of the operations will be handled differently by the two systems (e.g. overflows), so one operation for NES will be one operation in PTC that does mostly the same thing, but then several more dealing with all the fiddly details that make it a bit different. And, while a processor is running code, it is also, in parallel, managing other things like interrupts. This takes no extra time in the processor, because it is using bits of the chip that are not used in executing instructions. It does take time in an emulator (unless the programming environment is lots more sophisticated than I expect SmileBasic V3 to be).

        Loading editor
    • I got an R4 ordered. I should be getting it by next week. I'll put my emulators on that.

        Loading editor
    • tl;dr Emulators are totally impossible. ROM files aren't simple text data you can store via DATA and load later on. Might as well play Virtual Console.

        Loading editor
    • I love how ColeslawProd insists. You can NOT take a rom then transfer it in PTC.

        Loading editor
    • Pokeyoshi19 wrote:
      I love how ColeslawProd insists. You can NOT take a rom then transfer it in PTC.

      I think it's possible, but transfer would be straaaange...

      Like running a PC program that takes the ROM file, and puts it in a program that you transfer to PTC via PTCUtilities. Then you run the program, and it unloads all the GRP files that store the game... This STILL wouldn't work though, would it?

        Loading editor
    • I didn't want to comment on this, but there's too much misinformation being thrown around in regards to ROM files (and files in general). Any file... literally any file at all, could technically be moved over to Petit Computer. Whether or not it means anything on PTC is up to the programmer. Remember, GRP files are just a series of bytes (0-255), which is exactly what a "computer" file is. It doesn't matter if the file is an executable, zip, picture, document, music, etc. All files are just series of bytes. It is technically possible to split any ROM file up into multiple GRPs and read the ROM file just as you would on a computer. It couldn't come anywhere close to the proper speed, but it's not impossible.

      Here's an example: you could actually convert a small x86 executable into a GRP by directly writing the bytes to the GRP, then create an emulated x86 environment on PTC and interpret the x86 GRP file to run "real computer" programs on Petit Computer (assuming the program doesn't make any operating system calls). Because Petit Computer is able to read and write to files and has a language which is turing complete, you can technically do anything you want (besides accessing hardware that you don't have access to or does not exist).

      All that being said, there's no way that Petit Computer will come close to emulating any other video game system at full speed. You're basically trying to run an emulator on an emulator, and one of the emulators (PTC) really cripples the system.

        Loading editor
    • Ok, that's what I thought.

        Loading editor
    • No PEEK or POKE

        Loading editor
    • Lumage wrote:
      No PEEK or POKE

      Not those keywords, no, but that's hardly relevant.  The functionality of PEEK and POKE can be expressed in other ways, so it's no different from all the rest of the 'translation' that needs to happen for an emulator.

        Loading editor
    • SquareFingers wrote:
      Lumage wrote:
      No PEEK or POKE
      Not those keywords, no, but that's hardly relevant.  The functionality of PEEK and POKE can be expressed in other ways, so it's no different from all the rest of the 'translation' that needs to happen for an emulator.

      True.

        Loading editor
    • Btw, if we could make emulators, trust me, alot of us would have already made one. :P

        Loading editor
    • Actually, you could make an emulator. BUT: It would not have any savestates or cheats. Code it like this: Everytime you get a game in PTC Code, add it to the database! 1-25 Print "------------" Print ">Mario" 'The games you already added to the database. Print " Megaman"

      51 @LOAD 52 EXEC "PRGNAME$"

        Loading editor
    • That's not an emulator...

        Loading editor
      • Facepalm*

      I know. I just realized that after I posted it. (Sigh)

        Loading editor
    • Here's my thoughts on the subject matter.

      Theoretically speaking, yes, PTC could emulate the NES, but realistically, it could not run games at a playable speed, possibly not even at 1 frame per second. This is due to the fact that this would be an emulator running under an interpreter, as well as many other factors.

        Loading editor
    • Really the only way to make something like an NES emulator on Petit Compter is to port some NES games to PTC, use the APPEND command to append them together and make a menu interface at the beginning of the code.

        Loading editor
    • That isn't emulation.

        Loading editor
    • I know. But thats the closest to an emulator in PTC can get.

        Loading editor
    • Except based on what has been said in this thread it isn't.  And that you said "Really the only way to make something like an NES emulator".  Your method has also been stated already.

        Loading editor
    • Okay, I think we should at least attempt some sort of old computer or game console emulation in the new PTC, even if it is slow.

        Loading editor
    •   Loading editor
    • Huh, how did I not notice that?

        Loading editor
    • Do you want the full list or just that I only know it because I had specifically looked for it in the past.

        Loading editor
    • I hate looking back on this thread because it makes me feel dumb now that CHIP8 exists.

        Loading editor
    • What if there's a PC program that takes an NES game, and ports it to run in SmileBASIC?

        Loading editor
    • The estimation I performed earlier still applies: "the NES will execute a single increment instruction 170 times faster than PTC could".  That's where a native NES instruction has a direct counterpart in the SmileBasic language, and not even counting that the SmileBasic numeric data type is different from the NES registers: they will overflow differently for some calculations, for instance.  Those instructions for the NES that would take several SmileBasic instructions to implement will of course be that much slower.

        Loading editor
    • ColeslawProd wrote:
      I want to create or port an NES emulator to PTC so I can load and play NES roms without an R4 cart.I've never coded an emulator before.

      What should I do to make, or port this emulator?

      Sadly, PTC is too limited to run a nes emulator, but you could ether recreate an nes game, find an nes game recreated (for example, someone recreated Mega Man 2 fully with a level editor and more). I think that PTC could run an Atari 2600 emulator, but if someone does, and it can, it's goig to be slow. The good thing is that Smilebasic (aka the 3ds remake of the original dsi version) is more likely to be able to run an emulator, we just have to wait and see someone make one.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message