src/mess/drivers/supracan.c
| r6863 | r6864 | |
| 12 | 12 | |
| 13 | 13 | f00000 - bit 15 is probably vblank bit. |
| 14 | 14 | |
| 15 | Known unemulated graphical effects: |
| 16 | - The green blob of the A'Can logo should slide out from beneath the word |
| 17 | "A'Can" |
| 18 | - The A'Can logo should have a scrolling ROZ layer beneath it |
| 19 | - Sprites |
| 20 | |
| 15 | 21 | ***************************************************************************/ |
| 16 | 22 | |
| 17 | 23 | #include "driver.h" |
| r6863 | r6864 | |
| 19 | 25 | #include "cpu/m6502/m6502.h" |
| 20 | 26 | #include "devices/cartslot.h" |
| 21 | 27 | |
| 22 | | |
| 23 | 28 | static UINT16 supracan_m6502_reset; |
| 24 | 29 | static UINT8 *supracan_soundram; |
| 25 | 30 | static UINT16 *supracan_soundram_16; |
| 26 | 31 | static UINT16 supracan_video_regs[256]; |
| 27 | 32 | static emu_timer *supracan_video_timer; |
| 28 | | static UINT16 *supracan_charram, *supracan_vram; |
| 33 | static UINT16 *supracan_unk1_dma_ram; |
| 34 | static UINT16 *supracan_unk2_dma_ram; |
| 35 | static UINT16 *supracan_unk3_dma_ram; |
| 36 | static UINT16 *supracan_unk4_dma_ram; |
| 37 | static UINT16 *supracan_unk5_dma_ram; |
| 38 | static UINT16 *supracan_charram; |
| 39 | static UINT16 *supracan_vram; |
| 40 | static UINT16 *supracan_rram; |
| 41 | static UINT16 *supracan_rozpal; |
| 29 | 42 | |
| 30 | 43 | static READ16_HANDLER( supracan_unk1_r ); |
| 31 | 44 | static WRITE16_HANDLER( supracan_soundram_w ); |
| r6863 | r6864 | |
| 34 | 47 | static WRITE16_HANDLER( supracan_video_w ); |
| 35 | 48 | static WRITE16_HANDLER( supracan_char_w ); |
| 36 | 49 | |
| 50 | #define VERBOSE_LEVEL (99) |
| 51 | |
| 52 | #define ENABLE_VERBOSE_LOG (1) |
| 53 | |
| 54 | #if ENABLE_VERBOSE_LOG |
| 55 | INLINE void verboselog(running_machine *machine, int n_level, const char *s_fmt, ...) |
| 56 | { |
| 57 | if( VERBOSE_LEVEL >= n_level ) |
| 58 | { |
| 59 | va_list v; |
| 60 | char buf[ 32768 ]; |
| 61 | va_start( v, s_fmt ); |
| 62 | vsprintf( buf, s_fmt, v ); |
| 63 | va_end( v ); |
| 64 | logerror( "%06x: %s", cpu_get_pc(cputag_get_cpu(machine, "maincpu")), buf ); |
| 65 | } |
| 66 | } |
| 67 | #else |
| 68 | #define verboselog(x,y,z,...) |
| 69 | #endif |
| 70 | |
| 37 | 71 | static VIDEO_START( supracan ) |
| 38 | 72 | { |
| 39 | 73 | |
| r6863 | r6864 | |
| 46 | 80 | |
| 47 | 81 | count = 0; |
| 48 | 82 | |
| 83 | for (y=0;y<32;y++) |
| 84 | { |
| 85 | for (x=0;x<32;x += 4) |
| 86 | { |
| 87 | *BITMAP_ADDR16(bitmap, y, 128+x+0) = (supracan_rram[count] >> 12) & 0x000f; |
| 88 | *BITMAP_ADDR16(bitmap, y, 128+x+1) = (supracan_rram[count] >> 8) & 0x000f; |
| 89 | *BITMAP_ADDR16(bitmap, y, 128+x+2) = (supracan_rram[count] >> 4) & 0x000f; |
| 90 | *BITMAP_ADDR16(bitmap, y, 128+x+3) = (supracan_rram[count] >> 0) & 0x000f; |
| 91 | count++; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | count = 0; |
| 96 | |
| 49 | 97 | for (y=0;y<16;y++) |
| 50 | 98 | { |
| 51 | 99 | for (x=0;x<16;x++) |
| r6863 | r6864 | |
| 61 | 109 | return 0; |
| 62 | 110 | } |
| 63 | 111 | |
| 112 | typedef struct |
| 113 | { |
| 114 | UINT32 source; |
| 115 | UINT32 dest; |
| 116 | UINT16 count; |
| 117 | UINT16 control; |
| 118 | } _acan_dma_regs_t; |
| 119 | |
| 120 | static _acan_dma_regs_t acan_dma_regs; |
| 121 | |
| 122 | static WRITE16_HANDLER( supracan_dma_w ) |
| 123 | { |
| 124 | int i; |
| 125 | switch(offset) |
| 126 | { |
| 127 | case 0x00/2: // Source address MSW |
| 128 | acan_dma_regs.source &= 0x0000ffff; |
| 129 | acan_dma_regs.source |= data << 16; |
| 130 | break; |
| 131 | case 0x02/2: // Source address LSW |
| 132 | acan_dma_regs.source &= 0xffff0000; |
| 133 | acan_dma_regs.source |= data; |
| 134 | break; |
| 135 | case 0x04/2: // Destination address MSW |
| 136 | acan_dma_regs.dest &= 0x0000ffff; |
| 137 | acan_dma_regs.dest |= data << 16; |
| 138 | break; |
| 139 | case 0x06/2: // Destination address LSW |
| 140 | acan_dma_regs.dest &= 0xffff0000; |
| 141 | acan_dma_regs.dest |= data; |
| 142 | break; |
| 143 | case 0x08/2: // Byte count |
| 144 | acan_dma_regs.count = data; |
| 145 | break; |
| 146 | case 0x0a/2: // Control |
| 147 | if(data & 0x8800) |
| 148 | { |
| 149 | verboselog(space->machine, 0, "supracan_dma_w: Kicking off a DMA from %08x to %08x, %d bytes\n", acan_dma_regs.source, acan_dma_regs.dest, acan_dma_regs.count + 1); |
| 150 | for(i = 0; i <= acan_dma_regs.count; i++) |
| 151 | { |
| 152 | memory_write_byte(space, acan_dma_regs.dest++, memory_read_byte(space, acan_dma_regs.source++)); |
| 153 | } |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | verboselog(space->machine, 0, "supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n", data, acan_dma_regs.source, acan_dma_regs.dest, acan_dma_regs.count + 1); |
| 158 | } |
| 159 | break; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | static WRITE16_HANDLER( supracan_unk1_dma_w ) |
| 164 | { |
| 165 | COMBINE_DATA(&supracan_unk1_dma_ram[offset]); |
| 166 | } |
| 167 | |
| 168 | static WRITE16_HANDLER( supracan_unk2_dma_w ) |
| 169 | { |
| 170 | COMBINE_DATA(&supracan_unk2_dma_ram[offset]); |
| 171 | } |
| 172 | |
| 173 | static WRITE16_HANDLER( supracan_unk3_dma_w ) |
| 174 | { |
| 175 | COMBINE_DATA(&supracan_unk3_dma_ram[offset]); |
| 176 | } |
| 177 | |
| 178 | static WRITE16_HANDLER( supracan_unk4_dma_w ) |
| 179 | { |
| 180 | COMBINE_DATA(&supracan_unk4_dma_ram[offset]); |
| 181 | } |
| 182 | |
| 183 | static WRITE16_HANDLER( supracan_unk5_dma_w ) |
| 184 | { |
| 185 | COMBINE_DATA(&supracan_unk5_dma_ram[offset]); |
| 186 | } |
| 187 | |
| 64 | 188 | static ADDRESS_MAP_START( supracan_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 65 | 189 | AM_RANGE( 0x000000, 0x07ffff ) AM_ROM AM_REGION( "cart", 0 ) |
| 66 | 190 | AM_RANGE( 0xe80204, 0xe80205 ) AM_READ( supracan_unk1_r ) |
| 67 | 191 | AM_RANGE( 0xe80300, 0xe80301 ) AM_READ( supracan_unk1_r ) |
| 68 | | AM_RANGE( 0xe88400, 0xe88c87 ) AM_RAM /* Unknown, some data gets copied here during boot */ |
| 192 | AM_RANGE( 0xe88400, 0xe88bff ) AM_RAM /* Unknown, some data gets copied here during boot */ |
| 193 | AM_RANGE( 0xe88c00, 0xe88dff ) AM_RAM_WRITE(supracan_unk1_dma_w) AM_BASE(&supracan_unk1_dma_ram) /* Unknown DMA target, likely gfx-related */ |
| 194 | AM_RANGE( 0xe89000, 0xe897ff ) AM_RAM_WRITE(supracan_unk2_dma_w) AM_BASE(&supracan_unk2_dma_ram) /* Unknown DMA target, likely gfx-related */ |
| 195 | AM_RANGE( 0xe8a000, 0xe8afff ) AM_RAM_WRITE(supracan_unk3_dma_w) AM_BASE(&supracan_unk3_dma_ram) /* Unknown DMA target, likely gfx-related */ |
| 196 | AM_RANGE( 0xe8c000, 0xe8c7ff ) AM_RAM_WRITE(supracan_unk4_dma_w) AM_BASE(&supracan_unk4_dma_ram) /* Unknown DMA target, likely gfx-related */ |
| 197 | AM_RANGE( 0xe8d000, 0xe8d3ff ) AM_RAM_WRITE(supracan_unk5_dma_w) AM_BASE(&supracan_unk5_dma_ram) /* Unknown DMA target, likely gfx-related */ |
| 69 | 198 | AM_RANGE( 0xe8f000, 0xe8ffff ) AM_RAM_WRITE( supracan_soundram_w ) AM_BASE( &supracan_soundram_16 ) |
| 70 | 199 | AM_RANGE( 0xe90000, 0xe9001f ) AM_WRITE( supracan_sound_w ) |
| 200 | AM_RANGE( 0xe90020, 0xe9002b ) AM_WRITE( supracan_dma_w ) |
| 71 | 201 | AM_RANGE( 0xf00000, 0xf001ff ) AM_READWRITE( supracan_video_r, supracan_video_w ) |
| 72 | 202 | AM_RANGE( 0xf00200, 0xf003ff ) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) |
| 73 | 203 | AM_RANGE( 0xf40000, 0xf43fff ) AM_RAM_WRITE(supracan_char_w) AM_BASE(&supracan_charram) /* Unknown, some data gets copied here during boot */ |
| 74 | | AM_RANGE( 0xf44000, 0xf441ff ) AM_RAM /* Unknown */ |
| 75 | | AM_RANGE( 0xf44200, 0xf443ff ) AM_RAM AM_BASE(&supracan_vram) /* Unknown, some data gets copied here during boot. Possibly a tilemap?? */ |
| 76 | | AM_RANGE( 0xf44400, 0xf445ff ) AM_RAM /* Unknown, some data gets copied here during boot. Looks like the Functech logo is here */ |
| 204 | AM_RANGE( 0xf44000, 0xf441ff ) AM_RAM AM_BASE(&supracan_rozpal) /* Unknown */ |
| 205 | AM_RANGE( 0xf44200, 0xf443ff ) AM_RAM AM_BASE(&supracan_vram) /* Foreground tilemap layer */ |
| 206 | AM_RANGE( 0xf44400, 0xf445ff ) AM_RAM AM_BASE(&supracan_rram) /* ROZ layer tiles */ |
| 77 | 207 | AM_RANGE( 0xf44600, 0xf44fff ) AM_RAM /* Unknown, stuff gets written here. Zoom table?? */ |
| 78 | 208 | AM_RANGE( 0xfc0000, 0xfcffff ) AM_RAM /* System work ram */ |
| 79 | 209 | AM_RANGE( 0xff8000, 0xffffff ) AM_RAM /* System work ram */ |
| r6863 | r6864 | |
| 105 | 235 | |
| 106 | 236 | static PALETTE_INIT( supracan ) |
| 107 | 237 | { |
| 108 | | #if 0 |
| 238 | // Used for debugging purposes for now |
| 239 | //#if 0 |
| 109 | 240 | int i, r, g, b; |
| 110 | 241 | |
| 111 | 242 | for( i = 0; i < 32768; i++ ) |
| 112 | 243 | { |
| 113 | | /* TODO: Verfiy that we are taking the proper bits for r, g, and b. */ |
| 114 | 244 | r = (i & 0x1f) << 3; |
| 115 | 245 | g = ((i >> 5) & 0x1f) << 3; |
| 116 | 246 | b = ((i >> 10) & 0x1f) << 3; |
| 117 | 247 | palette_set_color_rgb( machine, i, r, g, b ); |
| 118 | 248 | } |
| 119 | | #endif |
| 249 | //#endif |
| 120 | 250 | } |
| 121 | 251 | |
| 122 | 252 | |
| r6863 | r6864 | |
| 168 | 298 | { |
| 169 | 299 | UINT16 data = supracan_video_regs[offset]; |
| 170 | 300 | |
| 301 | switch(offset) |
| 302 | { |
| 303 | case 0: // VBlank flag |
| 304 | break; |
| 305 | default: |
| 306 | verboselog(space->machine, 0, "supracan_video_r: Unknown register: %08x (%04x & %04x)\n", 0xf0000 + (offset << 1), data, mem_mask); |
| 307 | break; |
| 308 | } |
| 309 | |
| 171 | 310 | return data; |
| 172 | 311 | } |
| 173 | 312 | |
| r6863 | r6864 | |
| 192 | 331 | |
| 193 | 332 | static WRITE16_HANDLER( supracan_video_w ) |
| 194 | 333 | { |
| 334 | switch(offset) |
| 335 | { |
| 336 | default: |
| 337 | verboselog(space->machine, 0, "supracan_video_w: Unknown register: %08x = %04x & %04x\n", 0xf0000 + (offset << 1), data, mem_mask); |
| 338 | break; |
| 339 | } |
| 195 | 340 | supracan_video_regs[offset] = data; |
| 196 | 341 | } |
| 197 | 342 | |
| r6863 | r6864 | |
| 242 | 387 | |
| 243 | 388 | |
| 244 | 389 | static GFXDECODE_START( supracan ) |
| 245 | | GFXDECODE_ENTRY( "ram_gfx", 0, supracan_gfxlayout, 0, 1 ) |
| 390 | GFXDECODE_ENTRY( "ram_gfx", 0, supracan_gfxlayout, 0, 1 ) |
| 246 | 391 | GFXDECODE_END |
| 247 | 392 | |
| 248 | | |
| 249 | 393 | static MACHINE_DRIVER_START( supracan ) |
| 250 | 394 | MDRV_CPU_ADD( "maincpu", M68000, XTAL_10_738635MHz ) /* Correct frequency unknown */ |
| 251 | 395 | MDRV_CPU_PROGRAM_MAP( supracan_mem ) |