src/mess/drivers/socrates.c
| r5323 | r5324 | |
| 104 | 104 | UINT8 data[8]; |
| 105 | 105 | UINT8 rom_bank; |
| 106 | 106 | UINT8 ram_bank; |
| 107 | UINT16 scroll_offset; |
| 108 | UINT8* videoram; |
| 107 | 109 | } socrates={ {0}}; |
| 108 | 110 | |
| 109 | 111 | static void socrates_set_rom_bank( running_machine *machine ) |
| r5323 | r5324 | |
| 160 | 162 | socrates_set_ram_bank( space->machine ); |
| 161 | 163 | } |
| 162 | 164 | |
| 165 | /* stuff below belongs in video/socrates.c */ |
| 166 | |
| 167 | WRITE8_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 | |
| 163 | 175 | /* NTSC-based Palette stuff */ |
| 164 | 176 | // max for I and Q |
| 165 | 177 | #define M_I 0.5957 |
| r5323 | r5324 | |
| 276 | 288 | palette_set_colors(machine, 0, socrates_palette, ARRAY_LENGTH(socrates_palette)); |
| 277 | 289 | } |
| 278 | 290 | |
| 291 | static 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 | |
| 298 | static 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 | |
| 279 | 322 | /****************************************************************************** |
| 280 | 323 | Address Maps |
| 281 | 324 | ******************************************************************************/ |
| r5323 | r5324 | |
| 293 | 336 | AM_RANGE(0x00, 0x00) AM_READWRITE(socrates_rom_bank_r, socrates_rom_bank_w) AM_MIRROR(0x7) /* rom bank select - RW - 8 bits */ |
| 294 | 337 | 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 */ |
| 295 | 338 | 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. |
| 301 | 344 | */ |
| 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: |
| 303 | 346 | 0x20 - W - lsb offset of screen display |
| 304 | 347 | 0x21 - W - msb offset of screen display |
| 305 | 348 | resulting screen line is one of 512 total offsets on 128-byte boundaries in the whole 64k ram |
| r5323 | r5324 | |
| 332 | 375 | MDRV_MACHINE_RESET(socrates) |
| 333 | 376 | |
| 334 | 377 | /* video hardware */ |
| 335 | | MDRV_DEFAULT_LAYOUT(layout_socrates) |
| 378 | //MDRV_DEFAULT_LAYOUT(layout_socrates) |
| 336 | 379 | MDRV_SCREEN_ADD("screen", RASTER) |
| 337 | 380 | MDRV_SCREEN_REFRESH_RATE(60) |
| 338 | 381 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| r5323 | r5324 | |
| 341 | 384 | MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 227) |
| 342 | 385 | MDRV_PALETTE_LENGTH(256) |
| 343 | 386 | MDRV_PALETTE_INIT(socrates) |
| 387 | MDRV_VIDEO_START(socrates) |
| 388 | MDRV_VIDEO_UPDATE(socrates) |
| 344 | 389 | |
| 345 | 390 | /* sound hardware */ |
| 346 | 391 | //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. */ |
| 348 | 393 | //MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 349 | 394 | |
| 350 | 395 | |