SNEeSe Demo Release #7 -> 3 September 1997 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= SNEeSe = Snes Emulation (For The Hell Of It) -------------------------------------------- Developed by Savoury Snax - (Silence all who disbelieve!) Optimisations and additional code by Dark Elf when he does it! Mega Greets : Yoshi - Thanks for all the help, sorry I confused the issue. Albert Lloyd Sawyers, Jr - Thanks for the Memory Map. Zachary Williams - Good look with that DSP info. Excellent SNES info Resource BTW! Lord ESNES - Thanks for convincing me to lower the memory requirements and congratulations on ESNES 0.14a !!!! Jonathan Turner - Its nice to know people keep interest even when better emu's available! Look, I've fixed your name ;-) W/\re\/\/0lf - Without you, my net access would be intolerable. James Cartrette - Thanks for the new home, lets hope all go's well from now on ;-) Greets : rRNA,Dark Claw,Poiple Shadow,Flash,Windwalker, Chris L. MaJiC + all at #babylon5 and #star_wars + all I have spoken to via email, too numerous to mention! Dedicated to Yoshi - The one without whom emulation would be just a dream. -------------! For True SNES Emulation Buy A SNES ;-) !-------------- Requirements To Run =-=-=-=-=-=-=-=-=-=-= Ok, here is a rough guide to the things you need to run this emulator : o - 8Mb of memory. o - A lot of patience, this emulator is lower than beta stage and is slow and incomplete. o - VGA graphics card capable of mode 13h, ie a VGA gfx card ;-) o - IBM PC Compatable.. you guessed didn't you? o - Some SNES Rom Images to try out, No images are given due to copyright laws etc. New For This Release (#7) 3 September 1997 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= o - Implemented TD register, now some bitplanes that were not visible before will be. o - Altered KB handler, that should fix problems with the keyboards filling the buffers. No longer a problem ;-) o - A rather crappy save picture function exists, it will save pictures into the current directory as filename PICCYxxx.PCX where xxx is replaced with a number. The pcx is saved uncompressed (not supported by all picture viewers!). The image saved is 256x256 (true? snes size). o - A simplistic interface, now you can load roms without exiting the emulator ;-) o - Implemented Screen Modes 5 & 6 (Thanks to Lord ESNES!). The New GUI =-=-=-=-=-=-= Please note the new gui works, but some roms leave the code in a non default state and this cannot be reset properly resulting in a problem when you try to load a new rom! If you encounter a problem, try exiting and loading the rom on the command line. Readme Or Dont Bother Emailing Me =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= When you attempt to run a rom you should take note of any information displayed on the screen. For instance if a rom just bombs back to dos and all the information displayed looked like rubbish the rom image format may not be supported by the emulator. Also if a rom is high rom, a warning will be displayed about the fact but the emulator will still run, these roms will not work, no matter what! To run the demonstration type SNEESE.EXE and then the file name of the rom to load (leave a space ie. SNEESE.EXE file).Once the rom title is displayed, press a key to start the emulation. To exit emulation press ESC. A new GUI will pop up and you should select exit using the cursor keys. If you have any obscure SNES information like DSP, FX chip etc. or would like to send me some constructive comments (NOT - are you gonna have sound etc!) please feel free to email me at: savoury.snax@usa.net Or you can visit the new SNEeSe homepage at : www.focused.simplenet.com/sneese/index.html Any email about obtaining copyright ROMs will be forwarded to the appropriate authorities, so dont even bother! Why another SNES emulator ? =-=-=-=-=-=-=-=-=-=-=-=-=-=-= Why the hell not! Seriously, this was developed because I wanted a new challenge, and emulation would seem to me to be a nice goal. I decided on SNES emulation because I knew nothing about it! This seems backwards but I did not want to code something that I had touched on before. I have used the 6502,Z80 and 68000 processors which kills most other consoles and computers (I actually began a Sinclair 48K emulator back in my amiga days). Besides most other emulators have now gotten very close to total emulation... SNES still lacks sound and stability, the amiga is the only other emulation nightmare (AGA) since Marcus got GENEM going again! Of course most of the above no longer applies, since genem was postponed, and now genecyst has took over, oh and snes9x and esnes have sound... What can SNEeSe do in this version of the program ? =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Implemented features follow : o - 254/256 opcodes (not instructions) implemented. The last two remain unimplemented since they do nothing too important and can help detect runaway roms! o - Memory mappings for lo-rom modes done including SRAM. o - DMA operations 0,1,2 & 4, all 8 channels. Mode 2 is a guess, the docs seem unclear on exactly what to do! o - Video Modes 0-6, tile flipping and palette mapping. NB: Mode 7 displays as corrupted garbage, just in case a rom uses mode 7 for something that can be skipped! like elitendo pacman! o - NMI interrupt running although timings may be a little out. o - Keyboard working as follows : Cursor Keys - joypad direction Q,W - L & R Buttons N,M - SELECT & START A,S - Y & X Buttons Z,X - B & A Buttons ESC - Exit Emulation 1-4 - Toggle BKG 1-4 5 - Toggle Sprites 0 - Save picture o - Only Joypad 1 is mapped to the keyboard so far, no joystick yet sorry! o - Plenty of other hardware registers done, like palette, scroll registers, divide and multiply and 16*8 multiply. o - Sprites now implemented, thats - 8x8,16x16,32x32,64x64 this code is in its early stages and may be completely wrong! o - Screen Sizes 32x32,64x32,32x64 & 64x64 supported. 16x16 tile support is not implemented in any mode but 32x32! o - Addition of a squashing copy routine so entire SNES screen is visible on a standard VGA mode screen.. this is a temporary addition until I add support for modex screens etc. o - Backgrounds can be disabled using keys 1-4 for BKGs 1-4, and sprites can be disabled using key 5. These are toggle controls. o - Its got a gui, for those who care. What is left to do in this emulator ? =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The following list contains things I know need fixing or adding, it may not be complete yet! STILL TO DO: HiRom Mode - Used by the majority of large snes carts, requires altering some of the memory mapper. Fast Rom - Not a mode as such (as I understand it), all that needs doing is to add an adjustable cycle counting scheme. Mode 7 - I will add this soon (Honest!), I just got other things more important to fix at present ;-( Mode 7 FX - This part of mode 7 (the spin enlargement thing) will not be added as soon as mode 7 is though. SPC Emu - The SPC is a secondary processor within the SNES, it is used to control the sound chip. I have begun work on its emulation, Not included!. Sound - Needs the SPC and even then, I only know how to code an SB 16 driver. HDMA - Used to control the snes hardware line by line, this is important since a number of roms wont display anything until it is supported. Windows - I have little information on these, I can only guess at there implementation.. sometime in the future. Colour +/- - This relies on windows, and allows overlaying bpls like the rain in zelda? TO FIX: Sprites need fixing, only decoding of the address to Vram Data tho? Problem with zelda, mario and many other carts, the screen displays only some of the bpls correctly, the rest are garbage! Problem with pushover, it seems to have a screwed up palette. Also it is only possible to complete the first level! Problems with every other cart under the sun, it just dont work correctly! Playable Roms ? =-=-=-=-=-=-=-=-= The following are a sample of game roms known to work to some extent (please dont laugh.. this is a SNES emu in its very early stages!): Zelda - Game works, but some maps are displayed incorrectly! Mario - Mario can now move, disable plane 3 and game is ok? Oh dear, mario has a severe problem, try head butting a question mark box! Pacman (The elitendo PD Rom) - Completely playable! SimCity - Seems ok to me (not tested thorughly). Captain America & The New Avengers - Playable.. completely? Whirlo - Seems ok! SD The Great Battle - Disable Plane 1 and you can play away ;-) Syonen - Playable, but no status information bar! Wheel Of Fortune - Works ok, but the wheel does not display ;-( Contra 3 - Allmost playable, but screen scrolls dodgy! Pushover - Playable, but cant go to second level! Super Valis - Sprites Ok, BKGs not! 64x64 ? History =-=-=-=-= 2 September: Added TD support, this fixes problems I had with missing planes in some roms, mario has a corrupted plane when it starts up (nintendo logo) this is due to a problem I am having with either the cpu or the dma? 1 September: Fixed? Keyboard code, unlike many emulators I am not using any libraries like allegro so bugs may still occur! 31 August: Implemented ability to save screen shots from the emu by pressing the 0 key. Implemented a nice simplistic user interface, this is to allow easy debugging and (ofcourse) the ability to load a rom from inside the emulator. 29 August: Implemented Modes 5 & 6, these are based on information from Lord ESNES, they seem rather simple probably available to increase time for displaying sprites on the original SNES? 20 August: Today is an important day, I have obtained a DECENT manual for the 65816 and will now try and fix all the cpu core problems. Tons of CPU core fixes implemented, mario and zelda now play a lot more accurately (although GFX corruption is still present!). 19 August: Played with the cpu addressing code, this may fix a few problems. Added 2 more opcodes (the last 2 that could potentially do something useful!). Now SimCity will run ;-) 18 August: Fixed Mode 7 Multiplication register. This has fixed a PD rom problem I was having. 17 August: I have seen the new screen rendering code (written by Dark Elf) and it is far faster than the current code. It will not be implemented in a release version due to the lack of support for other emulated features, once these are done however it will be included. Altered DMA 2 (again) to fix a palette problem with a pd rom. 15 August: Took a break for a few days (BSC Project), back now. Tried implementing hirom (but failed.. need more information I think). Fixed 64x64 screen mode (did not spot it before cos it occured only when all 4 screens where visible). Added Save Ram loading and saving. 11 August: Altered DMA operation 2 slightly and added DMA operation 4. 10 August: Fixed VBlank so roms dont go mental, when they use the HVBJOY to do VBlank timing instead of the RDNMI. Added 64x64 tile mode support, should fix scrolling bkgs in some roms. May not be behaving correctly yet, its difficult to know the sources of errors in this type of program theres so much of it! Added PAL,NTSC detection, and various information is now displayed about the rom being loaded. Added MVP opcode, cos I found a rom that used it. Added BKG and sprite toggling. 9 August: Fixed Bpl Priorities for mode 1 in new screen render code, captain america becomes playable with sprites fixed. 8 August: Fixed some addressing mode stuff, based on how addressing are built when addition is used. Fixed Bit instruction, did not realise N & V flags are set, I have done them on the basis of 6502 bit instruction, since 65816 docs do not give any information as usual! Fixed Sprite 32 byte table, I had the sprites numbered the wrong way! 7 August: Implemented some more hardware registers including the scan line location stuff so zelda no longer locks at start. Altered the screen render code so it squashes the screen, this allows your score to be seen in pacman by elitendo! Its a temp function here until 320x240 & 256x256 modex support is added. 6 August: Ah, it would seem that the DJGPP assembler does not handle btb instruction if an invalid operand set is given. It just generates btb ebp,x which is completely insane!!!! That should fix 64x32 screen mode. Implemented 32x64 screen mode. Only got to do 64x64 mode and 16x16 tile modes for non 32x32 screens. Fixed up the sprite code so it actually works! I kinda made a few major mistakes + that damned assembler bug caused a few! I Better release another version later today. 5 August: Continued to rework the screen render code, fixing some scrolling code on the way. Implemented 16x16 tile renderer in the new screen render code, fixing some palette mapping bugs that were present in the old version of the tile mappers! Implemented 64x32 screen mode, its a little buggy but works better than without it! 4 August: I have begun reworking the screen render code (the slowest part of the emulation as far as I can tell). The rework is simply to get the emulator to support sizable screens and solve sprite clipping off right hand and bottom boundaries! I will release the version prior to the screen changes, since it has sprites in it and will allow people to see my progress so far. The code is stable, but suffers from problems with all but the simplest roms, due to unimplemented HW stuff! 3 August: Ok, I bowed to pressure from myself to add sprite support, two reasons for this, first I want to see Pacman running on an emulator I have written (One of The few stable games at present ;(). Secondly, Dark Elf wanted to know how sprites work on the snes, and so do I! I spent today playing and got sprites going, although I may have the address decoding scheme for hardware register 0x2101 completely wrong.. it works for some of the pd stuff I have tried! Fixed mirroring in 16x16 tile modes. Fixed 24 Bit Multiply via mode 7 regs, not sure how well, but it seems a lot better now! 2 August: Finally I can release a new version (on monday 4th Aug), I have found the bug that caused the newer code to fail... I forgot to set the Program Bank register to 0 during interrupts etc! Found a program that has allowed me to guess that the GTE docs have mislead me about the JSR (a,x) instruction and probably JSR (a) and JMP. It would seem they take the current program bank not bank 0 as the high part of the address for the pointer! 1 August: Altered the method of addressing OAM and VRAM memory, this is due to the way some code uses the auto incrementing features! I have altered the point at which the screen is turned off and the palette is set, this prevents mad flickering in some roms and has got the INFINITY demo to behave as it should instead of fading out and then ramping the brightness to full! 31 July: While trying to find an elusive bug, I have implemented a new APU skipper which should fix all APU problems for 2140-2141, this fix will be slow though, so if the skippers dont react under the usual replies then the new method will begin. Implemented 249 opcodes now, if I can just find the cpu bug that is stopping the code running properly. Altered the joypad status byte and IRQ status byte so that code will work even though they are not supported properly yet! 29 July: Found bug in MVN, forgot to change the read/write to memory functions, so it was copying from and to PC memory not SNES memory! 28 July: Found numerous bugs (one of the problems of re-writing mass chunks of code!), cpu core should be more stable again.... ;-) 27 July: Got the CPU core running better, some bug keeps causing random crashing though! 26 July: During re-write spotted I had not implemented V flag, it was being checked but could never be set! This could be causing quite a few ROM problems! 25 July: Begun re-writting CPU core slightly, cleaning up code etc. The main reason for this being to allow the emulator to run on 8MB machines without virtual memory! 22 July: Implemented Decimal flag properly, now BCD adds & subs will take place hopefully! Captain America works barring sprites and scroll bug, your health acts correctly though! Squashed another CPU bug, ora [d] was acting as ora [d],y ! 21 July: Spent almost the whole day tracing mario and zelda to see if I could figure out what was going on. I implemented a wierd hack that has not destroyed any existing ROM compatability (that I know of!). Mario World now starts, shows a picture and you can play with the options and start the game.. However the display is garbage at present. The NINTENDO logo is not displayed... I have found out this is a sprite though! 221 of 256 opcodes now implemented, Captain America cartridge works barring the BCD addition/subtract instructions (not done) and the lack of sprites.. scroll bug etc! 20 July: Decided to hold off implementing the SPC code until I have searched the ROMs for a valid reason for failing. Found Pushover Rom works (by ocean). I have implemented 16x16 tiles for mode 1 because of this. It took a while to figure out the offsets but it seems to work.. palette is wierd though! Reorder the planes for mode 1 only. Now the planes should display correctly.. and BKG3 will be in front when it should be! Few more opcodes done to accomodate ROM. 195 / 256 opcodes are now implemented. Also found YS3 works to a point.. the emu breaks the screen at the start (mode 7 not implemented yet), and then once the game kicks in the screen is visible but only the border and large amounts of text floating... 19 July: Tracked down a problem with the NMI.. NMI is non maskable interrupt.. and yet for some reason I masked it! DOH! DOH! etc. More ROMs work now, it would seem to me that the CPU core is ok, so I have to try and find what causes the lock up in so many ROMs. Found a bug in the emulator.. It overwrote part of the ROM to make the ROM image name ASCIIZ. Unfortunately a number of ROMs use the name area to apply patches.. such as intros for commercial roms etc. Another bug bites the dust! 18 July: Started to look at implementing the SPC, I know the emulator still has problems running roms, but I would like to get the SPC running to prevent problems with ROMS and to give me a better idea of the final speed of the emulator. Spending the weekend redesigning the core of the emulation (CPU elements). This will ensure better operation while running on lo-mem machines.. might even get the memory requirements down and find some bugs? 17 July: After a short break, I have now implemented a correction to the memory mapper (in preperation for removing the 24MB memory requirements!). Now two demo roms actually display information they refused to (sine dots and a sine scroller), however its broken a couple of ROMS. Oh, the broken roms may have been an APU skipping problem. I added an altered skipper after some insperation, and forgot to check some older roms.. the new skipper is not as good! Merged new skipper with old one to form a super skipper, probably still wont work right but it should be back to its old self. New skipper is working on a few more PD roms now, if I could only find the problem with commercial roms. Found another rom that scrolls incorrectly, I`ll hopefully be able to fix the bug now. Its caused by a non implemented and rather important feature. The SNES can have variable sized screens, I just forgot to allow for this, so the render code is being adjusted by Dark Elf at this minute.. I hope! Implemented mode 4... provisional (like mode 2), cos my docs say theres a difference but not sure what. Fixed a couple of bugs, palette set to 0 when brightness 0 and screen handled properly when it is supposed to be off! This causes mad flickering in some ROMs due to the way in which they work... bloody demo coders ;-) 15 July: Addded proper handling of X & Y under pX=1, this has caused a couple of roms to work a little better... but no major improvements. Dark elf sent me some new code, dont know if I`ll implement it... He has not got the newer version of the code yet and its so different it would be easier for him to do it! Sounds like he's gonna implement the sprites for me though... 14 July: Squashed another bug in the cpu core. Humans problem is still present... 13 July: Another bug squashed in the dma routines. After implementing all channels I had forgotten to change some of the reads from DMAP0 to DMAPx! Found a ROM (Humans) that actually displays some output, looks like at least one commercial ROM may work (I was surprised at this!). No sprites means that whatever happens nothings gonna be playable yet! Fixed a few tile mapping problems, also put in support for screen mode 2. I have only sketchy info on this mode, I have put it in cos its similar to mode 1... but anything that uses it may freak out. Humans has shown me that a major flaw exists somewhere and its not the lack of HDMA. None of the backgrounds scroll, this leads me to think theres a cpu flaw.. cant find anything missing in the hardware that is used. 12 July: Hoorah! SBC should now work properly, got hold of a 6502 manual briefly and found SBC uses carry how I thought on the 10 July. It also flips its meaning after carry which has been sorted. Added the carry stuff to the cmp instruction... suddenly 90% of the pd roms stopped crashing and started producing pictures and stuff! Added tile flipping and palette mapping to the screen renderer. Oh dear, major speed decrease! Hmm, I think Dark Elf needs to do some work with the screen stuff! Implemented the entire 16MB address space for the CPU. This will cause problems for some people with low amounts of memory, but CWSDPMI does allow virtual memory, and this runs under win95 so I cant see too many probs. 11 July: Had a really bad night! Got struck down with some sort of bug (not the computing sort!) and spent the night being sick! Managed to implement mode 0 and a few opcodes, mostly between trips to the loo... Re-implemented the VRAM addressing registers. Now VRAM is taken as being words in size. This means that VRAM is double the size but it fixed the problem I was having with a certain rom at that time. 10 July: More bugs squashed, did I really write this mess? Hmmm, keyboard will work better now. And XBA will no longer cause problems. Anyone care to comment on the SBC instruction. It seems to work if you invert carry before execution.. but this must be wrong surely! Opcode count reached 111, I`m getting there if it was not for all these hardware problems.... 09 July: Middle of the night code session, loads done like Mode 3 implemented (Dark Elf may improve the routine yet..). AHA! I think I just found the most important bug yet, it must have been a fluke the demo cart ran! When XCE (set/clr processor emulation mode) is run the wrong information was being returned, causing instructions to operate incorrectly! Fixed DMA fixed address, Yoshi Docs had bits backwards. 08 July: Got a new memory map today, this one looks good its already shown me that I confused the issue over slots 0-1fff. Damn, back to the source code again. Found the stack bug and cured it, I dont know what I was thinking when I wrote the reset code, stack now initialised to 0x01FF. This may still be wrong, but its fixed the stack corruption problem. 07 July: Decided to release a small demonstration of the emulator, its completely useless as it is, only running one cartridge rom, but more proof I am serious. Holy cow, I screwed up bad, most of the addressing modes were completely wrong due to the use of DB for modes that wanted bank 0. I also correct JSR & JMP which use the current PB not the current DB! 06 July: Implemented much more complete DMA operations for mode 0 & 1, channel 0 only still. Now CPU->PPU,PPU->CPU,increment,decrement,and no adjustment are implemented, but not tested yet. Found nasty bug in a couple of addressing modes and fixed them. 05 July: CNN announced Babylon 5 to get a fifth season (not emulator news but definately worthy of a mention!). Dark Elf has gone to Germany for a few months, so I have to email him for stuff for a while, a pain but not too drastic. Implemented Palette (at last) and brightness controls, got the HW scroll registers working again, I'm almost back to the version I had running in C++. Implemented an APU skipper, I dont know if I have done it like everyone else (those who have'nt implemented the SPC) but it works on the test cartridge. EEEK, I messed up the memory mapping, banks 0-3f offset 0-1fff are the same as 7e:0-1fff. I only spotted it cos the Stack was corrupting the ram area (or vice versa), This has prompted me to put the stack in its own page (almost), if this is wrong ROMS will soon show it up. Yeah! The Demo cart runs 100% (without sound output), I`ll leave the SPC till l8r, I want to try and get some comercial carts running now. 04 July: Implemented a few more hardware addresses, another DMA mode and killed a few more mistakes in the code. Some ROMS may fail due to the way in which hardware is mapped.. not an issue.. only one ROM can work at present anyway! Well the screen is working (to my eyes anyway!), theres a whole heap of garbage and the palettes wrong but these are due to HW registers that are not setup yet. 2 out of 3 planes on the screen are running, the last is just a cut & paste away, I`ll worry about that l8r, since it aint used yet! 03 July: Quick DMA fix and code now runs, but without some more hardware addresses no legable output can be produced. 02 July: Dark Elf joined development with an assembler version of my screen render code, although it still needs installing into the new code, it has been tested under a C++ core. In an attempt to get the code running in the asm core, I spent an age getting hardware mapping implemented with DMA and the screen code. The screen code works without crashing.. DMA does not ;( 01 July: Redone 40 of the opcodes, only 210 to go! No Hardware mappings yet, so the emulator is a currant rather than a fly! 29 June: Hmm, decision to stop current work on CPU in c++, and move the code into assember for the basic reason that many opcodes would get a large benefit from assemblerisation. Arrg, conversion to assembler caused some problems (I never really tried on the PC before!). I ended up having a C file to declare variables that could be accessed by .ASM, .CC and the debugger! 27 June: Fixed JSL routine, was pushing the wrong PC onto the stack! Implemented more opcodes, implemented all 8 DMA channels (not H-DMA). 26 June: At last after screaming at the Yoshi Documentation set (Screen.TXT) I got Mode 1 up and running. Turns out the bit about tiles was completely wrong! Modes 3 & 0 are now running properly too. Fixed NMI bug (interrupt was being issued without checking 0x4200!!) 25 June: Finally got to the end of the Demo cartridge (without doing sound part!). RE-WRITE OF INITIAL EMULATION PROJECT BEGUN TUE 24 JUNE NO VERSION NUMBERS YET EXIST!!!