? Is Gameboy Emulation Possible? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
💀

Is Gameboy Emulation Possible?

  • #1 ✎ 3 Xeyler Hey, I've been thinking about trying to code a Gameboy emulator with SmileBASIC. Due to CPU limitations, I don't expect that it will be able to run in real time at all, but I hope that it can be at least some sort of playable with a N3DS. What I'm most worried about is memory usage: the original Gameboy had a 16-bit data bus(65,536 different addresses) which could retrieve 8-bit values(0-255). Although, thanks to bank switching, the addressable memory position grows to alarming sizes. Now, SmileBASIC uses 32-bit integers in arrays, so with some bit operations, I could fit four 8-bit Gameboy memory address values into one 32-bit number, but should I only do that until the value is accessed by the emulated CPU? Or should I code an 8-bit CPU around 32-bit ints(this makes me shudder, but I'll do what makes it work)? Or should I not try to optimize memory at all? Any clues on how to make this possible? Or if it even is? Posted Edited by Xeyler
  • #2 ✎ 1560 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website SB has more than enough memory to store 1 byte per integer. Posted Edited by 12Me21
  • #3 ✎ 3 Xeyler Are you sure about that? Maybe I should have been more detailed about the memory bank switching because with it, some games have reached 2MB in size with just the 16KB of addressable space. Can SmileBASIC really handle arrays that have upwards of 2,000,000 values? Posted
  • #4 ✎ 158 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    Are you sure about that? Maybe I should have been more detailed about the memory bank switching because with it, some games have reached 2MB in size with just the 16KB of addressable space. Can SmileBASIC really handle arrays that have upwards of 2,000,000 values?
    Yeah but its gotta be an integer array
    Posted
  • #5 ✎ 900 snail_ Helper Received for being very helpful around SmileBASIC Source Achievements OSP Contest 2 Contest Participant I participated in the second SmileBASIC Source OSP Contest! Night Person I like the quiet night and sleep late. Express Yourself You technically can store a 2 million element array but you're likely to run out of memory somewhere else. It might make more sense to store the ROMs packed so 4 bytes are to an int and unpack each specific 16K page to 1 byte per int on demand, per bank-switching. Less likely to run out of memory, but could be expensive for games which bank-switch often. Posted
  • #6 ✎ 69 calc84maniac OSP Contest 1 Winner I won the first SmileBASIC Source OSP Contest! Programming Contest Amazing Page Hidden Achievements Scholar Received for knowing a great deal about programming topics Achievements I think I thought about this before and concluded that depending on how you handle memory accesses, you could always store the ROM in packed form and read from it directly that way. Since it's read-only, extracting bytes is fairly cheap and you don't have to deal with modifying individual bytes. Posted
  • #7 ✎ 3 Xeyler Alright, I'm thinking I'll have a compressed ROM from which the emulated CPU can switch to, causing the program to decompress it into part of an array that represents the GameBoy's active memory(~16,000 of ~64,000 bytes). This will allow me to use an estimated 1,000,000 integers for emulation(ROM takes about 500,000 which leaves a generous 500,000 for everything else). Posted
  • #8 ✎ 14 SuperBeefJerkey Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Drawing I like to draw! Hobbies Avatar Embargo I didn't change my avatar for 90 days Website You're not the only one trying to do this, but still, I encourage you to try to get it to work. I really like the idea of playing GameBoy on my 2DS. (Come to think of it, that might not work. Willing to try it, though.) Posted