JavaGear |
|
|
Java Sega Master System & Game Gear Emulator
Sections
Main Downloads Play Online Getting Started Documentation Links My Blog smspower.org JBenchmark Java Project Diary (Old) |
Thursday, August 30, 2001
I've just solved a significant problem with the joypad emulation, or rather the lack of it at this stage! I had assumed that the ports returned '0' when no buttons were pressed. However, after reading some documentation and studying the Tetris source code, I found that '0' actually meant that all buttons were pressed. This resulted in demos that checked for the reset button, continually resetting themselves. I changed the value to 0xFF, and the SMS Power demo ran without the shifted text I mentioned earlier (I've uploaded a new screenshot.) Additionally, the Good Advice demo now works correctly, with huge scrolling text. The leftmost column isn't blanked, as I haven't emulated that part of the VDP yet, which results in jagged scrolling. Tetris also exhibited different behaviour, and executed further into the code (this was the reason why it only showed the outline of the playing area beforehand). I emulated the remaining opcodes it needed, and after a bit of bugfixing, it all worked fine! Zoop's Damiana shooter also starts to run, although quickly crashes after the initial logos due to unimplemented opcodes. Hang-On, the first commercial ROM, is also showing signs of working and displays part of the title screen before it hits unimplemented opcodes. Oh and unrelated to the 'reset' bug, Charles McDonald's V Counter Test demo also runs. Overall, this has been a very successful day and loads of new stuff has started to work, and sets me in a good frame of mind before I go travelling! Zoop's SMS Power demo now runs! There were a number of problems that prevented this demo from running before: Firstly, the stack pointer isn't set in the code. The stack pointer in my Z80 emulator defaulted to 0x0000. This caused the emulator to crash, as the stack tried to grow downwards. The stack pointer now defaults to 0xDFFF which solved that problem. I wonder what the real SMS sets its stack pointer to? A further problem was that the demo was trying to write to VDP registers I hadn't bothered to emulate, as they didn't seem to be used by the SMS. The demo doesn't actually use these registers either, but the 'write' to them was also causing my emulator to crash. Anyhow, after emulating a number of new opcodes the demo ran. The only other problem I had to fix was the fact that all sprites were appearing with black backgrounds, as opposed to showing the true background colour using transparency. This was easy to solve, by not drawing the sprite layer pixel when it's colour was 16. Interestingly, the demo defaults to displaying the bouncing text shifted to the right hand side of the screen, as if the 'right' button had been pressed on the joypad. I'm assuming this is because the joypad port isn't returning any values yet, but I haven't bothered to investigate. It all runs a bit slowly, but optimisation isn't a priority at this stage. PFR Detect now runs! A few other demos struggle to run. The scroll demo looks a lot better than it did a week ago, but is still not entirely correct. Heliphobe's Tetris Release 2 displays the outline of the gamefield, but refuses to display any sprites. I haven't investigated this yet, but it's something I'll look at more carefully when I return from travelling. Tuesday, August 28, 2001
Well, today has been a good day. After getting sprites working (see below) I did some investigation into why the Palette Test demo was having problems. I was pretty sure it was either an interrupt or timing issue. Well, I read up on SMS interrupts and from what I can gather, only the VDP can cause an interrupt to be generated, (I'm not sure if this is a correct interpretation?) Nevertheless, I made some adjustments and the palette displayed. Screenshots are now posted. Sprites are now working! I corrected two major bugs that had been hindering the sprite rendering code up to this point. Firstly, I was reading the Sprite Attribute Table address incorrectly, due to a typo. Secondly, I was displaying sprites using the wrong palette (0-15) instead of (16-31). Simple mistakes, but it took a while to check everything out and discover these problems. I'll post a screenshot when I get home from work. Also, the Z80 core executed this demo correctly first time, so no debugging need there, which has got to be a good sign! Anyway, the end result is that Heliophobe's Sprite Demo is now working. Monday, August 27, 2001
Well, a few more opcodes are in place and the 6-Button Pad Demo is working. It's not much to look at, but it's allowed me to check some more Z80 opcodes. Charles' other demos use a lot of similar code, so they are also almost working, although there are still some graphical problems that I've got to solve. The Scroll demo now scrolls, but it looks naff - so some code tweaking will be needed. I started work on emulating the Scroll Test Program. Initially, the code simply hung. The program tried to read from Control Port (0xBF), which I hadn't emulated correctly yet. My code always returned '0' causing the program to run in an endless loop. I emulated Bit 7 of the status register, which is set when a vertical interrupt is pending and this solved the problem. After implementing some more opcodes the demo required, it stuck in a loop during the routine to make block tiles. Thinking this could be another VDP interrupt issue, I coded a routine to generate line interrupts. However, the problem was actually a result of buggy DEC instructions! Interestingly, Only Words was not affected by the bug, despite using the DEC instructions, which explained my initial confusion. Currently, the scroll demo runs - but no scrolling takes place yet! I'll work on this over the week. Also, the Pallete demo runs, but the pallete isn't properly displayed. I think this could be a timing issue relating to Port 7E, and the vertical position of the raster beam. If I alter the values this port returns I get different results. Friday, August 24, 2001
Only Words is now fully running with graphics, the results of which can be seen on the new screenshots page! I'm very pleased that I managed to get a demo running in such a short period of time. The bottom of the screen is chopped off at the moment, but it's not going to be a complex problem to fix, and as it's late I'll solve that tomorrow. The main part of the VDP that is not yet emulated is the interrupts. At the moment, I simply let the Z80 fill the VRAM and then call my display code. This is fine for Only Words, but obviously won't work with much else. Thursday, August 23, 2001
Well I decided to install JDK on my PC here at work. This has paid off as the VDP is now working and displaying the tiles for Only Words. Currently, the graphics are output as text (a white pixel is currently printed as a space, and the background as a '#'). This is simply for debugging purposes and it won't be hard to generate a graphical output now. I'll post some screenshots when I get home. I've worked out why I was having some trouble with the VDP code. It's funny how obvious these problems can seem when you come back to them (essentially I was passing the address of a sprite to a function as opposed to the number of the sprite duh!) I'll have to wait until I'm home from work to see if this solves the problem. Wednesday, August 22, 2001
I've finished the VDP work that is needed to get Only Words running, there's just some debugging to be done. I've also worked out how I'll output to the screen, using the MemoryImageSource class. My aim is to get Only Words running with graphics over the weekend. Monday, August 20, 2001
Carried on with VDP work. Progress is slow, but steady! I started implementing methods to draw pattern data from VRAM, display background tiles and pull colour information from CRAM. There is no actual screen output yet, as I've still got to actually display the representations. This will probably be an area that needs a lot of debugging, but I'll be putting the hours in! Sunday, August 19, 2001
I've implemented the VDP Control and Data ports (0xBE and 0xBF). VRAM and CRAM are now correctly setup and accessed. The VDP registers are also initialised and written to correctly. I've started writing code to decode the sprites and patterns. Tomorrow I'll continue with this, and research Java Graphics thoroughly. Friday, August 17, 2001
The Z80 Core now correctly executes all opcodes from 'Only Words'. I'm off to a wedding this weekend, but I'll try and get the VDP going on Sunday evening. Thursday, August 16, 2001
Last night, I downloaded and installed JDK 1.31 (I was using 1.21 beforehand), as I'll be needing some of its improved functionality at a later stage. The new Sound API looks particuarly nifty! Tonight I'm going to concentrate on the opcodes needed to get the 'Only Words' demo fully running. Once that's done, I'll start the VDP emulation. Well, some good progress made tonight with the Z80 emulator. Nearly all the opcodes for the 'Only Words' demo are working. The source code to this demo has given me the opportunity to double check they are all 100% correct. |