summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Tomasz Slanina <tomaszsl@mamedev.org>2010-07-14 11:24:58 +0000
committer Tomasz Slanina <tomaszsl@mamedev.org>2010-07-14 11:24:58 +0000
commitaedc1def70a146718f37f0b42023718686083c2a (patch)
tree660ca4edbb45d3254fd943fbad197b67b48bae0d
parent705583ede6a2c00eb3c226b72a4b37ec1899a97c (diff)
Rewrite of 'Wheels & Fire' driver [Tomasz Slanina]
- new rendering code - preliminary zooming (based on lookup table) - preliminary communication between main and sound cpu - scanline interrupts and scroll
-rw-r--r--src/mame/drivers/wheelfir.c1119
1 files changed, 657 insertions, 462 deletions
diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c
index 1ec6077a330..018450c28cd 100644
--- a/src/mame/drivers/wheelfir.c
+++ b/src/mame/drivers/wheelfir.c
@@ -1,12 +1,28 @@
-/* Wheels & Fire */
+/****************************************************************
-/* driver by
+Wheels & Fire
+
+driver by
David Haywood
Tomasz Slanina
-*/
+
+
+TODO:
+- sound comms
+- eeprom
+- various gfx size/pos glitches (gaps, extra rows of pixels here and there)
+- real gfx zoom, based on the zoom params, not lookup table
+- apply double buffering (sometimes gfx is displayed at y+256 every other frame (extra bits are currently masked out))
+- fix road/sky (extra bits in teh scroll reg. are there two bitmap buffers? )
+- bitmap layer clearing
+- fix wrong coords of sprites rendered into the bitmap layer (intro car)
+- is toggle_bit really a vblank bit ? or somethign else (blitter status ?)
+- implement(and find) layer enable/disable bits
+
-/*
+
+----------------------------------
Produttore TCH
N.revisione E133
@@ -44,355 +60,620 @@ level 5 interrupt = raster interrupt, used for road
level 3 interrupt = vblank interrupt
level 1 interrupt = blitter interrupt
-something is missing, currently needs a hack to boot
+
+Blitter data foramt ( offset in words, offset in bytes, offset inside ram data table )
+
+
+ fedcba9876543210
+
+0 0 0
+ --------76543210 dest_x0 bits 0-7
+ 76543210-------- src_x0 bits 0-7
+
+1 2 2
+ --------76543210 dest_x1 bits 0-7
+
+
+
+2 4 4
+ --------76543210 dest_y0 bits 0-7
+ 76543210-------- src_y0 bits 0-7
+3 6 6
+ --------76543210 dest_y1 bits 0-7
+
+4 8
+5 a
+6 c 8
+ ??------???????? image flags (directly copied from image info table, page and ?)
+ --3210---------- image page
+ -------8-------- src_x0 bit 8
+ ------8--------- src_y0 bit 8
+7 e a
+ ????????--?----- flags
+ ---------------X X direction (src?)
+ --------------Y- Y direction (src?)
+ ---------8------ dest_x0 bit 8
+ --------8------- dest_y0 bit 8
+ -----------L---- dest layer
+ ------------??-- unknown bits, set usually when rendering target = bitmap layer
+
+
+8 10 c
+ -------5-------- x scale data1 bit 5
+ ------5--------- y scale data1 bit 5
+ -----5---------- x scale data2 bit 5
+ ----5----------- y scala data2 bit 5
+ ---D------------ x scale >200%
+ --D------------- y scale >200%
+ -x-------------- X direction (dest?)
+ Y--------------- Y direction (dest?)
+ ---------8------ scroll x bit 8
+ --------8------- scroll y bit 8
+ ----------?----- set for road ? buffer num (is there double buffering ? or two bitmap layers?)
+
+9 12 e
+ ---------------H x scale < 50%
+ --------------H- y scale < 50%
+ -------------8-- dest_x1 bit 8
+ ------------8--- dest_y1 bit 8
+
+
+a 14 10
+ ---43210-------- x scale data1 bits 0-4
+ -4-------------- y scale data1 bit 4
+ --------76543210 scroll x of bitmap layer
+
+b 16 12
+ ---43210-------- x scale data2 bits 0-4
+ 10-------------- y scale data1 bits 0-1
+ --------76543210 scroll y of bitmap layer
+c 18 14
+ ---43210-------- y scale data2 bits 0-4
+ 32-------------- y scale data1 bits 2-3
+d 1a
+e 1c
+f 1e
+
+
+
+
+X Scale Table:
+76543210
+
+---ABCDE
+---FGHIJ
+--------
+---K-L-M
+-------N
+
+Y Scale Table:
+76543210
+
+-A------
+DE------
+BC-FGHIJ
+--K-L-M-
+------N-
+
+
+BITS ABCDE = DATA1 (0-31)
+BITS FGHIJ = DATA2 (0-31)
+BIT K - ( scale > 200% ) ? 1 : 0
+BIT L - ( DATA2 != 0) ? 1 : 0 (or DATA2 MSB)
+BIT M - ( DATA1 != 0) ? 1 : 0 (or DATA1 MSB)
+BIT N - ( scale < 50% ) ? 1 : 0
+
+
+pcb linking
+-----------
+
+suspicious code:
+
+
+(write/read (exchange data))
+
+0A535C: 48E7 6080 movem.l D1-D2/A0, -(A7)
+0A5360: 41F9 0078 0000 lea $780000.l, A0
+0A5366: D040 add.w D0, D0
+0A5368: 3181 0000 move.w D1, (A0,D0.w) ; write data
+
+0A536C: 3239 007E 0000 move.w $7e0000.l, D1
+0A5372: 0801 000D btst #$d, D1
+0A5376: 67F4 beq $a536c
+
+0A5378: 3230 0000 move.w (A0,D0.w), D1 ; read data
+0A537C: 0241 00FF andi.w #$ff, D1
+
+(unk., maybe sync or config ?)
+
+0A53C2: 2F08 move.l A0, -(A7)
+0A53C4: 3F01 move.w D1, -(A7)
+0A53C6: 41F9 0078 0000 lea $780000.l, A0
+0A53CC: D040 add.w D0, D0
+0A53CE: 3180 0000 move.w D0, (A0,D0.w) ; write offset
+0A53D2: 3180 0000 move.w D0, (A0,D0.w) ; again
+
+0A53D6: 3239 007E 0000 move.w $7e0000.l, D1
+0A53DC: 0801 000D btst #$d, D1 ; flag test
+0A53E0: 67F4 beq $a53d6
+
+0A53E2: 3030 0000 move.w (A0,D0.w), D0
+0A53E6: 0240 00FF andi.w #$ff, D0
+0A53EA: 321F move.w (A7)+, D1
+0A53EC: 205F movea.l (A7)+, A0
+0A53EE: 4E75 rts
+
*/
#include "emu.h"
+#include "machine/eeprom.h"
#include "cpu/m68000/m68000.h"
-#include "deprecat.h"
+#include "sound/dac.h"
-static int toggle_bit;
+static const int ZOOM_TABLE_SIZE=1<<14;
+static const int NUM_SCANLINES=256-8;
+static const int NUM_VBLANK_LINES=8;
+static const int LAYER_BG=0;
+static const int LAYER_FG=1;
+static const int NUM_COLORS=256;
-static READ16_HANDLER( wheelfir_rand1 )
+struct scroll_info
{
- return input_port_read(space->machine, "IN0") ^ toggle_bit; // mame_rand(space->machine);
-}
-
-static READ16_HANDLER( wheelfir_rand2 )
-{
- return input_port_read(space->machine, "IN1"); // mame_rand(space->machine);
-}
+ INT32 x,y,unkbits;
+};
-static READ16_HANDLER( wheelfir_rand4 )
+class wheelfir_state
{
- return mame_rand(space->machine);
-}
+public:
+ static void *alloc(running_machine &machine)
+ {
+ return auto_alloc_clear(&machine, wheelfir_state(machine));
+ }
-static UINT16 *wheelfir_myram;
-static UINT16 wheelfir_blitdata[16];
-static bitmap_t *wheelfir_tmp_bitmap[3];
+ wheelfir_state(running_machine &machine) { }
+
+ running_device *maincpu;
+ running_device *subcpu;
+ running_device *screen;
+ running_device *eeprom;
+
+ INT32 *zoom_table;
+ UINT16 *blitter_data;
+
+ UINT8 *palette;
+ INT32 palpos;
+
+ INT32 current_scanline;
+ scroll_info *scanlines;
+
+ INT32 soundlatch;
+
+ INT32 direct_write_x0;
+ INT32 direct_write_x1;
+ INT32 direct_write_y0;
+ INT32 direct_write_y1;
+ INT32 direct_write_idx;
+
+ INT32 toggle_bit;
+ INT16 scanline_cnt;
+
+
+ bitmap_t *tmp_bitmap[2];
+
+ INT32 get_scale(INT32 index)
+ {
+ while(index<ZOOM_TABLE_SIZE)
+ {
+ if(zoom_table[index]>=0)
+ {
+ return zoom_table[index];
+ }
+ ++index;
+ }
+ return 0;
+ }
+};
-/*
+static timer_device* scanline_timer;
-A 30f7 - 3150 - 0059 - 0d5c - 0066 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - A
-B
-C 48f7 - 4971 - 007a - 0d28 - 0032 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - C
-C 48f7 - 4945 - 004e - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - C
-D 54f7 - 559d - 00a6 - 0d76 - 0080 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - D
-E 1ff8 - 209d - 00a5 - 2728 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - E
-F
-G 60f7 - 6145 - 004e - 0d5c - 0066 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - G
-H 6cf7 - 6d7c - 0085 - 0d28 - 0032 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - H
-I 3efd - 3f5e - 0061 - 2d28 - 0032 - 0000 - 0000 - 3400 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - I
-I 3efd - 3f5e - 0061 - 2d42 - 004c - 0000 - 0000 - 3400 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - I
-I 3efd - 3fa0 - 00a3 - 2d42 - 004c - 0000 - 0000 - 3400 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - I
-J
-K
-L 40f8 - 415b - 0063 - 2776 - 0080 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - L
-M 3cf6 - 3d5a - 0064 - eac4 - 00ce - 0000 - 0000 - 3b00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - M
-N 84f7 - 8566 - 006f - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - N
-N 84f7 - 85b3 - 00bc - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - N
-O 90f7 - 9150 - 0059 - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - O
-O 90f7 - 917c - 0085 - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - O
-O 90f7 - 91a8 - 00b1 - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - O
-P f0f7 - f187 - 0090 - 0d42 - 004c - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - P
-Q
-R fcf7 - fd71 - 007a - 0d76 - 0080 - 0000 - 0000 - 3c00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - R
-S 4bf8 - 4c45 - 004d - 2728 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - S
-S 4bf8 - 4ca8 - 00b0 - 2728 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - S
-S 4bf8 - 4cbe - 00c6 - 2742 - 004c - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - S
-T 08f7 - 0966 - 006f - 0d28 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - T
-T 08f7 - 0992 - 009b - 0d28 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - T
-T 08f7 - 09b3 - 00bc - 0d28 - 0032 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - T
-T 08f7 - 0992 - 009b - 0d42 - 004c - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - T
-U 14f7 - 155b - 0064 - 0d90 - 009a - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - U
-V 20f7 - 21d4 - 00dd - 0d76 - 0080 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - V
-W 20f3 - 214e - 005b - b628 - 0032 - 0000 - 0000 - 3a00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - W
-X 2cf7 - 2d50 - 0059 - 0dde - 00e8 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - X
-Y 38f7 - 3921 - 002a - 0d76 - 0080 - 0000 - 0000 - 3d00 - 00d7 - c000 - 000c - 0000 - 0000 - 0000 - 00ff - ffff - ffff - Y
-Z
- extra test mode reads..
-
- ????
- GAME OPTIONS
- COIN OPTIONS
- COLOR AND CONVERGENCY
- SOUND
- STATISTICS
- COMUNICATION
- EXIT
-
-U 14f7 - 155b - 0064 - 0d90 - 009a - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - U
-V 20f7 - 21d4 - 00dd - 0d76 - 0080 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - V
-X 2cf7 - 2d50 - 0059 - 0dde - 00e8 - 0000 - 0000 - 3d00 - 0097 - c000 - 0008 - 0000 - 0000 - 0000 - 00ff - ffff - ffff - X
-Y 38f7 - 3921 - 002a - 0d76 - 0080 - 0000 - 0000 - 3d00 - 00d7 - c000 - 000c - 0000 - 0000 - 0000 - 00ff - ffff - ffff - Y
-
-by the grouping of the characters the test mode font should clearly be the one seen at the start of the last page. and
-scattered over the previous page. letters are 12x12, and U/V/X/Y are +0x0c00 from each other in this data.
-
-
-by using 0xffff at 0xf as the draw command we seem to lose some data.. maybe its not right.
+static READ16_HANDLER( wheelfir_status_r )
+{
+/*
+ fedcba9876543210
+ x--------------- vblank ?
+ --x------------- ? must be 1
+ --------------x- ? eeprom
+ ---------------x ? eeprom
*/
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ return state->toggle_bit| (mame_rand(space->machine)&0x2000);
+}
-/* each 512x512 page is
- 0x40000 bytes long
-
-therefore a 512x256 page is
- 0x20000 bytes...
-
-*/
+static WRITE16_HANDLER( wheelfir_scanline_cnt_w )
+{
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ COMBINE_DATA(&state->scanline_cnt);
+}
-/* it draws the background and road with direct writes to port 6... but where does this really go? an extra blit source page? */
-static int wheelfir_six_pos = 0;
-static bitmap_t* render_bitmap;
static WRITE16_HANDLER(wheelfir_blit_w)
{
- //wheelfir_blitdata[offset]=data;
- int width = space->machine->primary_screen->width();
- int height = space->machine->primary_screen->height();
- int vpage=0;
- COMBINE_DATA(&wheelfir_blitdata[offset]);
-
- /* a bit of a hack really .. */
- if(offset==0x6)
- {
- int sixdat = data&0xff;
- int x,y;
-
- x = wheelfir_six_pos % 512;
- y = wheelfir_six_pos / 512;
-
- x &= 511;
- y &= 511;
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
- wheelfir_six_pos++;
+ COMBINE_DATA(&state->blitter_data[offset]);
- *BITMAP_ADDR16(wheelfir_tmp_bitmap[2], y, x) = sixdat;
+ if(!ACCESSING_BITS_8_15 && offset==0x6) //LSB only!
+ {
+ int x,y;
+
+
+ int direct_width=state->direct_write_x1-state->direct_write_x0+1;
+ int direct_height=state->direct_write_y1-state->direct_write_y0+1;
+
+ int sixdat = data&0xff;
+
+ if(direct_width>0 && direct_height>0)
+ {
+ x= state->direct_write_idx % direct_width;
+ y = (state->direct_write_idx / direct_width) %direct_height;
+
+ x+=state->direct_write_x0;
+ y+=state->direct_write_y0;
+
+ if(x<512 && y <512)
+ {
+ *BITMAP_ADDR16(state->tmp_bitmap[LAYER_BG], y, x) = sixdat;
+ }
+ }
+
+ ++state->direct_write_idx;
+
return;
+
}
+ int yscroll=-1;
+ int xscroll=-1;
+
+ if(offset==0x0a && ACCESSING_BITS_0_7)
+ {
+ xscroll = (state->blitter_data[0xa]&0x00ff) | (state->blitter_data[0x8]&0x0040) << 2;
+ }
+
+ if(offset==0x0b && ACCESSING_BITS_0_7)
+ {
+ yscroll = (state->blitter_data[0xb]&0x00ff) | (state->blitter_data[0x8]&0x0080) << 1;
+ }
+
+ if(offset==0x8 && ACCESSING_BITS_0_7)
+ {
+ xscroll = (state->blitter_data[0xa]&0x00ff) | (state->blitter_data[0x8]&0x0040) << 2;
+ yscroll = (state->blitter_data[0xb]&0x00ff) | (state->blitter_data[0x8]&0x0080) << 1;
+ }
+
+ if(xscroll>=0)
+ {
+ int scl=state->current_scanline>=NUM_SCANLINES?0:state->current_scanline;
+ state->scanlines[scl].x=xscroll;
+ state->scanlines[scl].unkbits=state->blitter_data[0x8]&0xff;
+ }
+
+ if(yscroll>=0)
+ {
+ int scl=state->current_scanline>=NUM_SCANLINES?0:state->current_scanline;
+ state->scanlines[scl].y=yscroll;
+ state->scanlines[scl].unkbits=state->blitter_data[0x8]&0xff;
+ }
+
- /* probably wrong, see above! */
if(offset==0xf && data==0xffff)
{
-
- int x,y;
- int xsize,ysize;
- UINT8 *rom = memory_region(space->machine, "gfx1");
- int dir=0;
-
-
- wheelfir_six_pos = 0;
-
- mame_printf_debug("XX %.4x - ",wheelfir_blitdata[0]-wheelfir_blitdata[1]);
- mame_printf_debug("YY %.4x - ",wheelfir_blitdata[2]-wheelfir_blitdata[3]);
-
-
- for(x=0;x<16;x++)
- mame_printf_debug("%x-",wheelfir_blitdata[x]);
-
- mame_printf_debug("\n");
-
- xsize = ((wheelfir_blitdata[1]&0xff)-(wheelfir_blitdata[0]&0xff))&0xff;
- ysize = ((wheelfir_blitdata[3]&0xff)-(wheelfir_blitdata[2]&0xff))&0x0ff;
-
-
-
-
- if(wheelfir_blitdata[7]&0x1)
- dir=1;
- else
+ cputag_set_input_line(space->machine, "maincpu", 1, HOLD_LINE);
+
{
- dir=-1;
- xsize=0x100-xsize;
- }
-
- for(y=0;y<=ysize+1/*((wheelfir_blitdata[9]?wheelfir_blitdata[9]:16)*/;y++)
- for(x=0;x<=xsize+1/*(wheelfir_blitdata[9]?wheelfir_blitdata[9]:16)*/;x++)
+ UINT8 *rom = memory_region(space->machine, "gfx1");
+
+ int width = space->machine->primary_screen->width();
+ int height = space->machine->primary_screen->height();
+
+ int src_x0=(state->blitter_data[0]>>8)+((state->blitter_data[6]&0x100)?256:0);
+ int src_y0=(state->blitter_data[2]>>8)+((state->blitter_data[6]&0x200)?256:0);
+
+ int dst_x0=(state->blitter_data[0]&0xff)+((state->blitter_data[7]&0x40)?256:0);
+ int dst_y0=(state->blitter_data[2]&0xff)+((state->blitter_data[7]&0x80)?256:0);
+
+ int dst_x1=(state->blitter_data[1]&0xff)+((state->blitter_data[9]&4)?256:0);
+ int dst_y1=(state->blitter_data[3]&0xff)+((state->blitter_data[9]&8)?256:0);
+
+ int x_dst_step=(state->blitter_data[7]&0x1)?1:-1;
+ int y_dst_step=(state->blitter_data[7]&0x2)?1:-1;
+
+ int x_src_step=(state->blitter_data[8]&0x4000)?1:-1;
+ int y_src_step=(state->blitter_data[8]&0x8000)?1:-1;
+
+ int page=((state->blitter_data[6])>>10)*0x40000;
+
+
+ if(page>=0x400000) /* src set to unav. page before direct write to the framebuffer */
+ {
+
+ state->direct_write_x0=dst_x0;
+ state->direct_write_x1=dst_x1;
+ state->direct_write_y0=dst_y0;
+ state->direct_write_y1=dst_y1;
+ state->direct_write_idx=0;
+
+ }
+
+ if(x_dst_step<0)
{
- int destx=wheelfir_blitdata[0]&0xff;
- int desty=wheelfir_blitdata[2]&0xff;
-
- int pagenumber = (wheelfir_blitdata[6]&0x3e00)>>9;
- int gfxbase = pagenumber * 0x20000;
- int xbit = (wheelfir_blitdata[6]&0x0100)>>8;
-
-
- int offs;
- int pix;
- int diffx,diffy;
-
- if (wheelfir_blitdata[7]&0x0040)destx +=0x100;
- // if (wheelfir_blitdata[7]&0x0080) desty +=0x100;
-
-// if (wheelfir_blitdata[9]&0x0004) destx +=0x100;
-// if (wheelfir_blitdata[9]&0x0008) desty +=0x100;
-
- diffx=wheelfir_blitdata[0]>>8;
- diffy=wheelfir_blitdata[2]>>8;
-
- // diffx-=0xf700;
- // diffx&=511;
-
-
- // diffy-=0xf400;
-// diffy&=1023;
-
-
- diffx &= 0xff;
- diffy &= 0xff;
- if (xbit) diffx+=0x100;
-
- diffx+=x;
- diffy+=y;
-
-
- destx+=x*dir;
- desty+=y;
-
- offs=gfxbase+diffy*512+diffx;
-
- offs&=0x3fffff;
-
- pix = rom[offs];
+ if(dst_x0<=dst_x1)
+ {
+
+ return;
+ }
+
+ }
+ else
+ {
+
+ if(dst_x0>=dst_x1)
+ {
+ return;
+ }
+
+ }
+
+ if(y_dst_step<0)
+ {
+ if(dst_y0<=dst_y1)
+ {
+ return;
+ }
+ }
+ else
+ {
+
+ if(dst_y0>=dst_y1)
+ {
+ return;
+ }
+
+ }
+
+
+ //additional checks
+
+ int d1, d2, hflag, dflag, index;
+
+ d1=((state->blitter_data[0x0a]&0x1f00)>>8);
+
+ d2=((state->blitter_data[0x0b]&0x1f00)>>8);
+
+
+ d1|=((state->blitter_data[0x8]&0x100)>>3);
+ d2|=((state->blitter_data[0x8]&0x400)>>5);
+ hflag=(state->blitter_data[0x9]&0x1)?1:0;
+ dflag=(state->blitter_data[0x8]&0x1000)?1:0;
+ index=d1|(d2<<6)|(hflag<<12)|(dflag<<13);
+
+
+ float scale_x=state->get_scale(index);
+
+ d1=((state->blitter_data[0x0b]&0xc000)>>14) |
+ ((state->blitter_data[0x0c]&0xc000)>>12) |
+ ((state->blitter_data[0x0a]&0x4000)>>10);
+
+ d2=((state->blitter_data[0x0c]&0x1f00)>>8);
+
+
+ d1|=((state->blitter_data[0x8]&0x200)>>4);
+ d2|=((state->blitter_data[0x8]&0x800)>>6);
+
+ hflag=(state->blitter_data[0x9]&0x2)?1:0;
+ dflag=(state->blitter_data[0x8]&0x2000)?1:0;
+ index=d1|(d2<<6)|(hflag<<12)|(dflag<<13);
+
+
+ float scale_y=state->get_scale(index);
+
+
+ if(scale_x==0 || scale_y==0) return;
+
+
+ float scale_x_step=100.f/scale_x;
+ float scale_y_step=100.f/scale_y;
+
+
+
+ int x,y;
+ float idx_x,idx_y;
+
+ int vpage=LAYER_FG;
+ if(state->blitter_data[0x7]&0x10)
+ {
+ vpage=LAYER_BG;
+/*
+ printf("bg -> %d %d %d %d %d %d @ %x\n",dst_x0,dst_y0, dst_x1,dst_y1, dst_x1-dst_x0, dst_y1-dst_y0,cpu_get_pc(space->cpu));
+
+ for(int i=0;i<16;++i)
+ {
+ printf("%x = %.4x\n",i,state->blitter_data[i]);
+ }
+
+ printf("\n");
+*/
+ }
+
+ bool endx=false;
+ bool endy=false;
+
+ if(state->blitter_data[0x7]&0x0c)
+ {
+ //???
+ }
- if(pix && destx >0 && desty >0 && destx<width && desty <height)
- *BITMAP_ADDR16(wheelfir_tmp_bitmap[vpage], desty, destx) = pix;
+ for( x=dst_x0, idx_x=0 ; !endx;x+=x_dst_step, idx_x+=scale_x_step )
+ {
+ endy=false;
+ for( y=dst_y0, idx_y=0 ; !endy;y+=y_dst_step, idx_y+=scale_y_step)
+ {
+ endx=(x==dst_x1);
+ endy=(y==dst_y1);
+
+
+ int xx=src_x0+x_src_step*idx_x;
+ int yy=src_y0+y_src_step*idx_y;
+
+ int address=page+yy*512+xx;
+
+ int pix = rom[address&(0x1000000-1)];
+
+ int screen_x=x;
+ int screen_y=y;
+
+
+ if(page>=0x400000)
+ {
+ //hack for clear
+ if(screen_x >0 && screen_y >0 && screen_x < width && screen_y <height)
+ {
+ // *BITMAP_ADDR16(state->tmp_bitmap[vpage], screen_y , screen_x ) =0;
+ }
+ }
+ else
+ {
+ screen_y&=0xff;
+
+ if(pix && screen_x >0 && screen_y >0 && screen_x < width && screen_y <height)
+ {
+ *BITMAP_ADDR16(state->tmp_bitmap[vpage], screen_y , screen_x ) = pix;
+ }
+ }
+ }
}
+ }
}
-
-
-
}
static VIDEO_START(wheelfir)
{
-
- wheelfir_tmp_bitmap[0] = machine->primary_screen->alloc_compatible_bitmap();
- wheelfir_tmp_bitmap[1] = machine->primary_screen->alloc_compatible_bitmap();
- wheelfir_tmp_bitmap[2] = machine->primary_screen->alloc_compatible_bitmap();
-
- render_bitmap = machine->primary_screen->alloc_compatible_bitmap();
-
+ wheelfir_state *state = (wheelfir_state *)machine->driver_data;
+ state->tmp_bitmap[0] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
+ state->tmp_bitmap[1] = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
}
-static UINT8 wheelfir_palette[8192];
-static int wheelfir_palpos = 0;
-/* Press R to show a page of gfx, Q / E to move between pages, and W to clear the framebuffer */
static VIDEO_UPDATE(wheelfir)
{
-#if 0
- int x,y;
- static int base = 0;
+ wheelfir_state *state = (wheelfir_state *)screen->machine->driver_data;
+
+ bitmap_fill(bitmap, cliprect,0);
- if ( input_code_pressed_once(screen->machine, KEYCODE_E) )
- base += 512*512;
+ for(int y=0;y<NUM_SCANLINES;++y)
+ {
+ UINT16 *source = BITMAP_ADDR16(state->tmp_bitmap[LAYER_BG],( (state->scanlines[y].y)&511), 0);
+ UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
+
+ for (int x=0;x<336;x++)
+ {
- if ( input_code_pressed_once(screen->machine, KEYCODE_Q) )
- base -= 512*512;
+ dest[x] = source[ (x+(state->scanlines[y].x)) &511];
- if (base<0x000000) base = 0x000000;
- if (base>0x3c0000) base = 0x3c0000;
+ }
+ }
- copybitmap(bitmap, wheelfir_tmp_bitmap[2], 0, 0, 0, 0, cliprect);
- //copybitmap_trans(bitmap, wheelfir_tmp_bitmap[1], 0, 0, 0, 0, cliprect, 0);
- copybitmap_trans(bitmap, wheelfir_tmp_bitmap[0], 0, 0, 0, 0, cliprect, 0);
- bitmap_fill(wheelfir_tmp_bitmap[0], screen->visible_area(),0);
+ copybitmap_trans(bitmap, state->tmp_bitmap[LAYER_FG], 0, 0, 0, 0, cliprect, 0);
+
+/*
+ {
+ bitmap_fill(state->tmp_bitmap[LAYER_BG], &screen->visible_area(),0);
- if ( input_code_pressed(screen->machine, KEYCODE_R) )
- {
- const UINT8 *gfx = memory_region(machine, "gfx1");
- for (y=0;y<128;y++)
- {
- for (x=0;x<512;x++)
- {
- int romoffs;
- UINT8 romdata;
+ }
+*/
+
+ return 0;
+}
- romoffs = base+y*512+x;
+static VIDEO_EOF( wheelfir )
+{
+ wheelfir_state *state = (wheelfir_state *)machine->driver_data;
+ bitmap_fill(state->tmp_bitmap[LAYER_FG], &machine->primary_screen->visible_area(),0);
+}
- romdata = gfx[romoffs];
- *BITMAP_ADDR16(bitmap, y, x) = romdata;
- }
- }
- }
-#endif
+static WRITE16_HANDLER( pal_reset_pos_w )
+{
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ state->palpos = 0;
+}
- copybitmap(bitmap, render_bitmap, 0, 0, 0, 0, cliprect);
- copybitmap_trans(bitmap, wheelfir_tmp_bitmap[0], 0, 0, 0, 0, cliprect, 0);
+static WRITE16_HANDLER( pal_data_w )
+{
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ int color=state->palpos/3;
+ state->palette[state->palpos] = data & 0xff;
+ ++state->palpos;
+ state->palpos %=NUM_COLORS*3;
+
{
- int x;
- for (x=0;x<8192;x+=3)
- {
- //int paldat = (wheelfir_palette[x]<<8) | wheelfir_palette[x+1];
- int b,g,r;
-
- r = wheelfir_palette[x];
- g = wheelfir_palette[x+1];
- b = wheelfir_palette[x+2];
- palette_set_color(screen->machine,x/3,MAKE_RGB(r,g,b));
- }
+ int r = state->palette[color*3];
+ int g = state->palette[color*3+1];
+ int b = state->palette[color*3+2];
+ palette_set_color(space->machine, color, MAKE_RGB(r,g,b));
}
-#if 0
- {
- FILE* fp;
- fp=fopen("wheelfir_pal.dmp", "w+b");
- if (fp)
- {
- fwrite(wheelfir_palette, 1024, 1, fp);
- fclose(fp);
- }
- }
-#endif
- return 0;
}
-static WRITE16_HANDLER( pal_reset_pos_w )
+static WRITE16_HANDLER(wheelfir_7c0000_w)
{
- wheelfir_palpos = 0;
+ /* seems to be scanline width/2 (used for scanline int timing ? or real width of scanline ?) */
}
-static WRITE16_HANDLER( pal_data_w )
+static WRITE16_HANDLER(wheelfir_snd_w)
{
- wheelfir_palette[wheelfir_palpos] = data & 0xff;
- wheelfir_palpos ++;
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ COMBINE_DATA(&state->soundlatch);
+ cputag_set_input_line(space->machine, "subcpu", 1, HOLD_LINE); /* guess, tested also with periodic interrupts and latch clear*/
+ timer_call_after_resynch(space->machine, NULL, 0, 0);
+}
- wheelfir_palpos &=8191;
+static READ16_HANDLER( wheelfir_snd_r )
+{
+ wheelfir_state *state = (wheelfir_state *)space->machine->driver_data;
+ return state->soundlatch;
}
+static WRITE16_HANDLER(coin_cnt_w)
+{
+ /* bits 0/1 coin counters */
+ coin_counter_w(space->machine, 0, data & 0x01);
+ coin_counter_w(space->machine, 1, data & 0x02);
+}
static ADDRESS_MAP_START( wheelfir_main, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
- AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE (&wheelfir_myram)
+ AM_RANGE(0x200000, 0x20ffff) AM_RAM
- AM_RANGE(0x7c0000, 0x7c0001) AM_READ(wheelfir_rand1)
- AM_RANGE(0x780000, 0x780001) AM_READ(wheelfir_rand2)
+ AM_RANGE(0x700000, 0x70001f) AM_WRITE(wheelfir_blit_w)
+ AM_RANGE(0x720000, 0x720001) AM_WRITE(pal_reset_pos_w)
+ AM_RANGE(0x720002, 0x720003) AM_WRITE(pal_data_w)
+ AM_RANGE(0x720004, 0x720005) AM_WRITENOP // always ffff?
+ AM_RANGE(0x740000, 0x740001) AM_WRITE(wheelfir_snd_w)
+ AM_RANGE(0x780000, 0x78000f) AM_READNOP /* net comms ? */
+ AM_RANGE(0x760000, 0x760001) AM_WRITE(coin_cnt_w)
+ AM_RANGE(0x7a0000, 0x7a0001) AM_WRITE(wheelfir_scanline_cnt_w)
+ AM_RANGE(0x7c0000, 0x7c0001) AM_READWRITE(wheelfir_status_r, wheelfir_7c0000_w)
AM_RANGE(0x7e0000, 0x7e0001) AM_READ_PORT("P1")
AM_RANGE(0x7e0002, 0x7e0003) AM_READ_PORT("P2")
-
- AM_RANGE(0x700000, 0x70001f) AM_WRITE(wheelfir_blit_w) // blitter stuff
- AM_RANGE(0x720000, 0x720001) AM_WRITE(pal_reset_pos_w) // always 0?
- AM_RANGE(0x720002, 0x720003) AM_WRITE(pal_data_w) // lots of different values.. also blitter? palette?
-// AM_RANGE(0x720004, 0x720005) AM_WRITENOP // always ffff?
-
-// AM_RANGE(0x740000, 0x740001) AM_WRITENOP
-// AM_RANGE(0x760000, 0x760001) AM_WRITENOP
-// AM_RANGE(0x740000, 0x740001) AM_WRITENOP
-// AM_RANGE(0x7a0000, 0x7a0001) AM_WRITENOP
-// AM_RANGE(0x7c0000, 0x7c0001) AM_WRITENOP
-
ADDRESS_MAP_END
@@ -401,113 +682,14 @@ static ADDRESS_MAP_START( wheelfir_sub, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x200000, 0x20ffff) AM_RAM
- AM_RANGE(0x780000, 0x780001) AM_READ(wheelfir_rand4)
- AM_RANGE(0x700000, 0x700001) AM_WRITENOP
- AM_RANGE(0x740000, 0x740001) AM_WRITENOP
+ AM_RANGE(0x780000, 0x780001) AM_READ(wheelfir_snd_r)
+
+ AM_RANGE(0x700000, 0x700001) AM_DEVWRITE8("dac1", dac_w, 0xff00) //guess for now
+ AM_RANGE(0x740000, 0x740001) AM_DEVWRITE8("dac2", dac_w, 0xff00)
ADDRESS_MAP_END
static INPUT_PORTS_START( wheelfir )
- PORT_START("IN0") /* 16bit */
- PORT_DIPNAME( 0x0001, 0x0001, "0" )
- PORT_DIPSETTING( 0x0001, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0002, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0004, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0008, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0010, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0020, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0040, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0080, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0100, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0200, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0400, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0800, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x1000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x2000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x4000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x8000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
-
- PORT_START("IN1") /* 16bit */
- PORT_DIPNAME( 0x0001, 0x0001, "1" )
- PORT_DIPSETTING( 0x0001, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0002, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0004, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0008, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0010, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0020, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0040, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0080, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0100, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0200, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0400, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x0800, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x1000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x2000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x4000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
- PORT_DIPSETTING( 0x8000, DEF_STR( Off ) )
- PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
-
PORT_START("P1") /* 16bit */
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
@@ -522,9 +704,9 @@ static INPUT_PORTS_START( wheelfir )
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_DIPNAME( 0x1000, 0x1000, "Test / Game?" )
- PORT_DIPSETTING( 0x1000, DEF_STR( Off ) )
+ PORT_DIPSETTING( 0x1000, DEF_STR( Off ) )
PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
- PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED )
+ PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED ) /* net comm flag ? */
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED )
@@ -540,121 +722,133 @@ static INPUT_PORTS_START( wheelfir )
PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
INPUT_PORTS_END
-static timer_device* frame_timer;
-static timer_device* scanline_timer;
-
-static TIMER_DEVICE_CALLBACK( frame_timer_callback )
-{
- /* callback */
-}
-
-static int scanline_counter = 0;
-static int total_scanlines = 262;
-
-static void render_background_to_render_buffer(int scanline)
-{
- int x;
- UINT16 yscroll = (wheelfir_blitdata[0xb]&0x00ff) | (wheelfir_blitdata[0x8]&0x0080) << 1;
- UINT16 xscroll = (wheelfir_blitdata[0xa]&0x00ff) | (wheelfir_blitdata[0x8]&0x0040) << 2;
-
- UINT16 *source = BITMAP_ADDR16(wheelfir_tmp_bitmap[2], (scanline+yscroll)&511, 0);
- UINT16 *dest = BITMAP_ADDR16(render_bitmap, scanline, 0);
-
-// if (scanline==100)
-// printf("%04x %04x %04x %04x\n", wheelfir_blitdata[0x8],wheelfir_blitdata[0x9],wheelfir_blitdata[0xa],wheelfir_blitdata[0xb]);
-
- for (x=0;x<336;x++)
- {
- dest[x] = source[ (x+xscroll) &511];
- }
-
-}
-
static TIMER_DEVICE_CALLBACK( scanline_timer_callback )
{
+ wheelfir_state *state = (wheelfir_state *)timer.machine->driver_data;
timer_call_after_resynch(timer.machine, NULL, 0, 0);
+ state->current_scanline=param;
- if (scanline_counter != (total_scanlines - 1))
+ if(state->current_scanline<NUM_SCANLINES)
{
- scanline_counter++;
- cputag_set_input_line(timer.machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road
- timer.adjust(attotime_div(ATTOTIME_IN_HZ(60), total_scanlines));
-
- if (scanline_counter < 256)
+ //visible scanline
+
+ state->toggle_bit = 0x0000;
+
+ --state->scanline_cnt;
+
+ if(state->current_scanline>0)
{
- render_background_to_render_buffer(scanline_counter);
+ //copy scanline offset
+ state->scanlines[state->current_scanline].x=(state->scanlines[state->current_scanline-1].x);
+ state->scanlines[state->current_scanline].y=(state->scanlines[state->current_scanline-1].y+1);
+ state->scanlines[state->current_scanline].unkbits=state->scanlines[state->current_scanline-1].unkbits;
}
-
- if (scanline_counter == 256)
+
+ if(state->scanline_cnt==0) //<=0 ?
{
- cputag_set_input_line(timer.machine, "maincpu", 3, HOLD_LINE); // vblank IRQ?
- toggle_bit = 0x8000; // must toggle..
+ cputag_set_input_line(timer.machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road
}
-
- if (scanline_counter == 0)
- {
- toggle_bit = 0x0000; // must toggle..
- }
-
- // printf("scanline %d\n",scanline_counter);
+
}
- else /* pretend we're still on the same scanline to compensate for rounding errors */
+ else
{
- scanline_counter = total_scanlines-1;
+ if(state->current_scanline==NUM_SCANLINES) /* vblank */
+ {
+ state->toggle_bit = 0x8000;
+ cputag_set_input_line(timer.machine, "maincpu", 3, HOLD_LINE);
+ }
}
}
-static VIDEO_EOF( wheelfir )
-{
- scanline_counter = -1;
- bitmap_fill(wheelfir_tmp_bitmap[0], &machine->primary_screen->visible_area(),0);
-
- frame_timer->reset();
- scanline_timer->reset();
-}
static MACHINE_RESET(wheelfir)
{
- frame_timer = machine->device<timer_device>("frame_timer");
+
scanline_timer = machine->device<timer_device>("scan_timer");
- frame_timer->reset();
- scanline_timer->reset();
- scanline_counter = -1;
}
-static INTERRUPT_GEN( wheelfir_irq )
+static MACHINE_START( wheelfir )
{
- // we seem to need this interrupt at least once for every object drawn on the screen, otherwise things flicker + slowdown
- cpu_set_input_line(device, 1, HOLD_LINE); // blitter IRQ?
+ wheelfir_state *state = (wheelfir_state *)machine->driver_data;
+
+ state->maincpu = machine->device( "maincpu");
+ state->subcpu = machine->device( "subcpu");
+ state->screen = machine->device( "screen");
+ state->eeprom = machine->device( "eeprom");
+
+ state->zoom_table = auto_alloc_array(machine, INT32, ZOOM_TABLE_SIZE);
+ state->blitter_data = auto_alloc_array(machine, UINT16, 16);
+
+ state->scanlines = reinterpret_cast<scroll_info*>(auto_alloc_array(machine, UINT8, sizeof(scroll_info)*(NUM_SCANLINES+NUM_VBLANK_LINES)));
+ state->palette=auto_alloc_array(machine, UINT8, NUM_COLORS*3);
+
+
+ for(int i=0;i<(ZOOM_TABLE_SIZE);++i)
+ {
+ state->zoom_table[i]=-1;
+ }
+
+ UINT16 *ROM = (UINT16 *)memory_region(machine, "maincpu");
+
+ for(int j=0;j<400;++j)
+ {
+ int i=j<<3;
+ int d1=ROM[0x200+i]&0x1f;
+ int d0=(ROM[0x200+i]>>8)&0x1f;
+
+ d0|=(ROM[0x200+1+i]&1)?0x20:0;
+ d1|=(ROM[0x200+1+i]&4)?0x20:0;
+
+ int hflag=(ROM[0x200+2+i]&0x100)?1:0;
+ int dflag=(ROM[0x200+1+i]&0x10)?1:0;
+
+ int index=d0|(d1<<6)|(hflag<<12)|(dflag<<13);
+ state->zoom_table[index]=j;
+ }
}
static MACHINE_DRIVER_START( wheelfir )
- MDRV_CPU_ADD("maincpu", M68000, 32000000)
+ MDRV_DRIVER_DATA(wheelfir_state)
+
+ MDRV_CPU_ADD("maincpu", M68000, 32000000/2)
MDRV_CPU_PROGRAM_MAP(wheelfir_main)
- MDRV_CPU_VBLANK_INT_HACK(wheelfir_irq,256) // 1,3,5 valid
- MDRV_CPU_ADD("sub", M68000, 32000000/2)
+ MDRV_CPU_ADD("subcpu", M68000, 32000000/2)
MDRV_CPU_PROGRAM_MAP(wheelfir_sub)
- MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) // 1 valid
+ //MDRV_CPU_VBLANK_INT_HACK(irq1_line_hold,256)
+
+ MDRV_QUANTUM_TIME(HZ(12000))
MDRV_MACHINE_RESET (wheelfir)
- MDRV_TIMER_ADD("frame_timer", frame_timer_callback)
- MDRV_TIMER_ADD("scan_timer", scanline_timer_callback)
+ MDRV_TIMER_ADD_SCANLINE("scan_timer", scanline_timer_callback, "screen", 0, 1)
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
- MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
+
+
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
- MDRV_SCREEN_SIZE(64*8, 64*8)
- MDRV_SCREEN_VISIBLE_AREA(0*8, 42*8-1, 0*8, 32*8-1)
+ MDRV_SCREEN_SIZE(336, NUM_SCANLINES+NUM_VBLANK_LINES)
+ MDRV_SCREEN_VISIBLE_AREA(0,335, 0, NUM_SCANLINES-1)
- MDRV_PALETTE_LENGTH(8192)
+ MDRV_PALETTE_LENGTH(NUM_COLORS)
+
+ MDRV_EEPROM_93C46_ADD("eeprom")
+
+ MDRV_MACHINE_START(wheelfir)
MDRV_VIDEO_START(wheelfir)
MDRV_VIDEO_UPDATE(wheelfir)
MDRV_VIDEO_EOF(wheelfir)
+
+ /* sound hardware */
+ MDRV_SPEAKER_STANDARD_MONO("mono")
+
+ MDRV_SOUND_ADD("dac1", DAC, 0)
+ MDRV_SOUND_ADD("dac2", DAC, 0)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
+
MACHINE_DRIVER_END
@@ -663,11 +857,11 @@ ROM_START( wheelfir )
ROM_LOAD16_BYTE( "tch1.u19", 0x00001, 0x80000, CRC(33bbbc67) SHA1(c2ecc0ab522ee442076ea7b9536aee6e1fad0540) )
ROM_LOAD16_BYTE( "tch2.u21", 0x00000, 0x80000, CRC(ed6b9e8a) SHA1(214c5aaf55963a219db33dd5d530492e09ad5e07) )
- ROM_REGION( 0x100000, "sub", 0 ) /* 68000 Code + sound samples */
+ ROM_REGION( 0x100000, "subcpu", 0 ) /* 68000 Code + sound samples */
ROM_LOAD16_BYTE( "tch3.u83", 0x00001, 0x80000, CRC(43c014a6) SHA1(6c01a08dda204f36e8768795dd5d405576a49140) )
ROM_LOAD16_BYTE( "tch11.u65", 0x00000, 0x80000, CRC(fc894b2e) SHA1(ebe6d1adf889731fb6f53b4ce5f09c60e2aefb97) )
- ROM_REGION( 0x400000, "gfx1", 0 ) // 512x512 gfx pages
+ ROM_REGION( 0x1000000, "gfx1", ROMREGION_ERASE00 ) // 512x512 gfx pages
ROM_LOAD( "tch4.u52", 0x000000, 0x80000, CRC(fe4bc2c7) SHA1(33a2ef79cb13f9e7e7d513915c6e13c4e7fe0188) )
ROM_LOAD( "tch5.u53", 0x080000, 0x80000, CRC(a38b9ca5) SHA1(083c9f700b9df1039fb553e918e205c6d32057ad) )
ROM_LOAD( "tch6.u54", 0x100000, 0x80000, CRC(2733ae6b) SHA1(ebd91e123b670159f79be19a552d1ae0c8a0faff) )
@@ -675,13 +869,14 @@ ROM_START( wheelfir )
ROM_LOAD( "tch8.u56", 0x200000, 0x80000, CRC(22b661fe) SHA1(b6edf8e1e8b479ee8813502157615f54627dc7c1) )
ROM_LOAD( "tch9.u57", 0x280000, 0x80000, CRC(83c66de3) SHA1(50deaf3338d590340b928f891548c47ba8f3ca38) )
ROM_LOAD( "tch10.u58",0x300000, 0x80000, CRC(2036ed80) SHA1(910381e2ccdbc2d06f873021d8af02795d22f595) )
- ROM_LOAD( "tch12.u59",0x380000, 0x80000, CRC(cce2e675) SHA1(f3d8916077b2e057169d0f254005cd959789a3b3) ) // font is in here
+ ROM_LOAD( "tch12.u59",0x380000, 0x80000, CRC(cce2e675) SHA1(f3d8916077b2e057169d0f254005cd959789a3b3) )
ROM_END
static DRIVER_INIT(wheelfir)
{
UINT16 *RAM = (UINT16 *)memory_region(machine, "maincpu");
- RAM[0xdd3da/2] = 0x4e71; // hack!
+ RAM[0xdd3da/2] = 0x4e71; //hack
}
GAME( 199?, wheelfir, 0, wheelfir, wheelfir, wheelfir, ROT0, "TCH", "Wheels & Fire", GAME_NOT_WORKING|GAME_NO_SOUND )
+