Previous 15994 Revisions Next

r5324 Friday 31st July, 2009 at 06:42:39 UTC by Jonathan Gevaryahu
[Socrates] implement graphics rendering
[src/mess/drivers]socrates.c

src/mess/drivers/socrates.c
r5323r5324
104104UINT8 data[8];
105105UINT8 rom_bank;
106106UINT8 ram_bank;
107UINT16 scroll_offset;
108UINT8* videoram;
107109} socrates={ {0}};
108110
109111static void socrates_set_rom_bank( running_machine *machine )
r5323r5324
160162 socrates_set_ram_bank( space->machine );
161163}
162164
165/* stuff below belongs in video/socrates.c */
166
167WRITE8_HANDLER( socrates_scroll_w )
168{
169 if (offset == 0)
170 socrates.scroll_offset = (socrates.scroll_offset&0x100) | data;
171 else
172 socrates.scroll_offset = (socrates.scroll_offset&0xFF) | ((data&1)<<8);
173}
174
163175/* NTSC-based Palette stuff */
164176// max for I and Q
165177#define M_I 0.5957
r5323r5324
276288   palette_set_colors(machine, 0, socrates_palette, ARRAY_LENGTH(socrates_palette));
277289}
278290
291static VIDEO_START( socrates )
292{
293// dunno what to do here if anything
294   socrates.videoram = memory_region(machine, "vram");
295   socrates.scroll_offset = 0;
296}
297
298static VIDEO_UPDATE( socrates )
299{
300   UINT8 fixedcolors[8] =
301   {
302   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0xF7
303   };
304   int x, y, colidx, color;
305   int lineoffset = 0; // if display ever tries to display data at 0xfxxx, offset line displayed by 0x1000
306   for (y = 0; y < 228; y++)
307   {
308      if ((((y+socrates.scroll_offset)*128)&0xffff) >= 0xf000) lineoffset = 0x1000; // see comment above
309      for (x = 0; x < 256; x++)
310      {
311         colidx = socrates.videoram[(((y+socrates.scroll_offset)*128)+(x>>1)+lineoffset)&0xffff];
312         if (x&1) colidx >>=4;
313         colidx &= 0xF;
314         if (colidx > 7) color=socrates.videoram[0xF000+(colidx<<8)+((y+socrates.scroll_offset)&0xFF)];
315         else color=fixedcolors[colidx];
316         *BITMAP_ADDR16(bitmap, y,  x) = color;
317      }
318   }
319   return 0;
320}
321
279322/******************************************************************************
280323 Address Maps
281324******************************************************************************/
r5323r5324
293336   AM_RANGE(0x00, 0x00) AM_READWRITE(socrates_rom_bank_r, socrates_rom_bank_w) AM_MIRROR(0x7) /* rom bank select - RW - 8 bits */
294337   AM_RANGE(0x08, 0x08) AM_READWRITE(socrates_ram_bank_r, socrates_ram_bank_w) AM_MIRROR(0x7) /* ram banks select - RW - 4 low bits; Format: 0b****HHLL where LL controls whether window 0 points at ram area: 0b00: 0x0000-0x3fff; 0b01: 0x4000-0x7fff; 0b10: 0x8000-0xbfff; 0b11: 0xc000-0xffff. HH controls the same thing for window 1 */
295338   AM_RANGE(0x10, 0x17) AM_NOP AM_MIRROR (0x8) /* sound section:
296        0x10 - W - frequency control for channel 1 (louder channel) - 01=high pitch, ff=low, write 0 to silence
297   0x11 - W - frequency control for channel 2 (softer channel) - 01=high pitch, ff=low, write 0 to silence
298   0x12 - volume control for channel 1
299   0x13 - volume control for channel 2
300   0x14-0x17 - ?DAC? related? makes noise when written to...
339        0x10 - W - frequency control for channel 1 (louder channel) - 01=high pitch, ff=low; time between 1->0/0->1 transitions = (XTAL_21_4772MHz/(512+256) / (freq_reg+1)) (note that this is double the actual frequency since each full low and high squarewave pulse is two transitions)
340   0x11 - W - frequency control for channel 2 (softer channel) - 01=high pitch, ff=low; same equation as above
341   0x12 - W - 0b****VVVV volume control for channel 1
342   0x13 - W - 0b****VVVV volume control for channel 2
343   0x14-0x17 - ?DAC? related? makes noise when written to... code implies 0x16 and 0x17 are mirrors of 0x14 and 0x15 respectively.
301344   */
302   AM_RANGE(0x20, 0x21) AM_NOP AM_MIRROR (0xe) /* graphics section:
345   AM_RANGE(0x20, 0x21) AM_WRITE(socrates_scroll_w) AM_MIRROR (0xe) /* graphics section:
303346   0x20 - W - lsb offset of screen display
304347   0x21 - W - msb offset of screen display
305348   resulting screen line is one of 512 total offsets on 128-byte boundaries in the whole 64k ram
r5323r5324
332375    MDRV_MACHINE_RESET(socrates)
333376
334377    /* video hardware */
335   MDRV_DEFAULT_LAYOUT(layout_socrates)
378   //MDRV_DEFAULT_LAYOUT(layout_socrates)
336379   MDRV_SCREEN_ADD("screen", RASTER)
337380   MDRV_SCREEN_REFRESH_RATE(60)
338381   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
r5323r5324
341384   MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 227)
342385   MDRV_PALETTE_LENGTH(256)
343386   MDRV_PALETTE_INIT(socrates)
387   MDRV_VIDEO_START(socrates)
388   MDRV_VIDEO_UPDATE(socrates)
344389
345390    /* sound hardware */
346391   //MDRV_SPEAKER_STANDARD_MONO("mono")
347   //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_4772MHz/(1024+512)) /* this is correct, as strange as it sounds. */
392   //MDRV_SOUND_ADD("soc_snd", SOCRATES, XTAL_21_4772MHz/(512+256)) /* this is correct, as strange as it sounds. */
348393   //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
349394
350395

Previous 15994 Revisions Next


© 1998-2018 The MESS Team