src/mess/drivers/supracan.c
| r6904 | r6905 | |
| 32 | 32 | static emu_timer *supracan_video_timer; |
| 33 | 33 | static UINT16 *supracan_vram; |
| 34 | 34 | static UINT16 spr_limit; |
| 35 | static UINT32 spr_base_addr; |
| 36 | static UINT8 spr_flags; |
| 37 | static UINT32 tilemap_base_addr[4]; |
| 38 | static int tilemap_scrollx[4],tilemap_scrolly[4]; |
| 39 | static UINT16 video_flags; |
| 35 | 40 | |
| 36 | 41 | static UINT16 supracan_video_regs[256]; |
| 37 | 42 | |
| r6904 | r6905 | |
| 76 | 81 | |
| 77 | 82 | } |
| 78 | 83 | |
| 84 | static void draw_tilemap(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,int layer) |
| 85 | { |
| 86 | UINT32 count; |
| 87 | int x,y; |
| 88 | int scrollx,scrolly; |
| 89 | |
| 90 | count = (tilemap_base_addr[layer]); |
| 91 | scrollx = tilemap_scrollx[layer]; |
| 92 | scrolly = tilemap_scrolly[layer]; |
| 93 | |
| 94 | for (y=0;y<32;y++) |
| 95 | { |
| 96 | for (x=0;x<32;x++) |
| 97 | { |
| 98 | int tile, flipx, flipy, pal; |
| 99 | tile = (supracan_vram[count] & 0x03ff); |
| 100 | flipx = (supracan_vram[count] & 0x0800) ? 1 : 0; |
| 101 | flipy = (supracan_vram[count] & 0x0400) ? 1 : 0; |
| 102 | pal = (supracan_vram[count] & 0xf000) >> 12; |
| 103 | |
| 104 | drawgfx_transpen(bitmap,cliprect,machine->gfx[1],tile,pal,flipx,flipy,(x*8)-scrollx,(y*8)-scrolly,0); |
| 105 | //todo: wrap-around, untested by the current game |
| 106 | count++; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 112 | { |
| 113 | int x, y; |
| 114 | int xtile, ytile; |
| 115 | int xsize, ysize; |
| 116 | int bank; |
| 117 | int spr_offs; |
| 118 | int col; |
| 119 | int i; |
| 120 | int spr_base; |
| 121 | int hflip; |
| 122 | int region; |
| 123 | //UINT8 *sprdata = (UINT8*)(&supracan_vram[0x1d000/2]); |
| 124 | |
| 125 | spr_base = spr_base_addr; |
| 126 | region = (spr_flags & 1) ? 0 : 1; //8bpp : 4bpp |
| 127 | |
| 128 | /* |
| 129 | [0] |
| 130 | ---h hhh- ---- ---- Y size |
| 131 | ---- ---- yyyy yyyy Y offset |
| 132 | [1] |
| 133 | bbbb ---- ---- ---- sprite offset bank |
| 134 | ---- d--- ---- ---- horizontal direction |
| 135 | ---- ---- ---- -www X size |
| 136 | [2] |
| 137 | ---- ---S xxxx xxxx X offset |
| 138 | [3] |
| 139 | oooo oooo oooo oooo sprite pointer |
| 140 | */ |
| 141 | |
| 142 | for(i=spr_base/2;i<(spr_base+(spr_limit*8))/2;i+=4) |
| 143 | { |
| 144 | x = supracan_vram[i+2] & 0x00ff; |
| 145 | y = supracan_vram[i+0] & 0x00ff; |
| 146 | spr_offs = supracan_vram[i+3] << 2; |
| 147 | bank = (supracan_vram[i+1] & 0xf000) >> 12; |
| 148 | hflip = (supracan_vram[i+1] & 0x0800) ? 1 : 0; |
| 149 | |
| 150 | if(supracan_vram[i+2] & 0x100) |
| 151 | x-=256; |
| 152 | |
| 153 | if(supracan_vram[i+3] != 0) |
| 154 | { |
| 155 | xsize = 1 << (supracan_vram[i+1] & 7); |
| 156 | ysize = ((supracan_vram[i+0] & 0x1e00) >> 9)+1; |
| 157 | |
| 158 | for(ytile = 0; ytile < ysize; ytile++) |
| 159 | { |
| 160 | if(hflip) |
| 161 | { |
| 162 | for(xtile = (xsize - 1); xtile >= 0; xtile--) |
| 163 | { |
| 164 | UINT16 data = supracan_vram[spr_offs/2+ytile*xsize+xtile]; |
| 165 | int tile = (bank * 0x200) + (data & 0x03ff); |
| 166 | int xflip = (data & 0x0800) ? 0 : 1; |
| 167 | int yflip = (data & 0x0400) ? 1 : 0; |
| 168 | col = (data & 0xf000) >> 12; |
| 169 | drawgfx_transpen(bitmap,cliprect,machine->gfx[region],tile,col,xflip,yflip,x+((xsize - 1) - xtile)*8,y+ytile*8,0); |
| 170 | } |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | for(xtile = 0; xtile < xsize; xtile++) |
| 175 | { |
| 176 | UINT16 data = supracan_vram[spr_offs/2+ytile*xsize+xtile]; |
| 177 | int tile = (bank * 0x200) + (data & 0x03ff); |
| 178 | int xflip = (data & 0x0800) ? 1 : 0; |
| 179 | int yflip = (data & 0x0400) ? 1 : 0; |
| 180 | col = (data & 0xf000) >> 12; |
| 181 | drawgfx_transpen(bitmap,cliprect,machine->gfx[region],tile,col,xflip,yflip,x+xtile*8,y+ytile*8,0); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 79 | 189 | /* FIXME: vram is currently hardcoded, but there's an high chance it's tied to some video registers */ |
| 80 | 190 | static VIDEO_UPDATE( supracan ) |
| 81 | 191 | { |
| 82 | | int x,y,map,count; |
| 83 | | |
| 84 | 192 | bitmap_fill(bitmap, cliprect, 0); |
| 85 | 193 | |
| 86 | 194 | #if 0 |
| r6904 | r6905 | |
| 133 | 241 | } |
| 134 | 242 | #endif |
| 135 | 243 | |
| 136 | | // Tilemaps |
| 137 | | for (map = 0; map < 3; map++) |
| 138 | | { |
| 139 | | count = (0x1e000 + map * 0x800) / 2; |
| 244 | if(video_flags & 0x80) |
| 245 | draw_tilemap(screen->machine,bitmap,cliprect,0); |
| 246 | if(video_flags & 0x40) |
| 247 | draw_tilemap(screen->machine,bitmap,cliprect,1); |
| 248 | if(video_flags & 0x20) //guess, not tested |
| 249 | draw_tilemap(screen->machine,bitmap,cliprect,2); |
| 250 | if(video_flags & 8) |
| 251 | draw_sprites(screen->machine,bitmap,cliprect); |
| 140 | 252 | |
| 141 | | for (y=0;y<30;y++) |
| 142 | | { |
| 143 | | for (x=0;x<32;x++) |
| 144 | | { |
| 145 | | int tile, flipx, flipy, pal; |
| 146 | | |
| 147 | | tile = (supracan_vram[count] & 0x03ff); |
| 148 | | flipx = (supracan_vram[count] & 0x0800) ? 1 : 0; |
| 149 | | flipy = (supracan_vram[count] & 0x0400) ? 1 : 0; |
| 150 | | pal = (supracan_vram[count] & 0xf000) >> 12; |
| 151 | | |
| 152 | | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],tile,pal,flipx,flipy,x*8,y*8,0); |
| 153 | | count++; |
| 154 | | } |
| 155 | | } |
| 156 | | } |
| 157 | | |
| 158 | | { |
| 159 | | int x, y; |
| 160 | | int xtile, ytile; |
| 161 | | int xsize, ysize; |
| 162 | | int bank; |
| 163 | | int spr_offs; |
| 164 | | int col; |
| 165 | | int i; |
| 166 | | int spr_base; |
| 167 | | int hflip; |
| 168 | | //UINT8 *sprdata = (UINT8*)(&supracan_vram[0x1d000/2]); |
| 169 | | |
| 170 | | spr_base = 0x1d000; |
| 171 | | |
| 172 | | /* |
| 173 | | [0] |
| 174 | | ---h hhh- ---- ---- Y size |
| 175 | | ---- ---- yyyy yyyy Y offset |
| 176 | | [1] |
| 177 | | bbbb ---- ---- ---- sprite offset bank |
| 178 | | ---- d--- ---- ---- horizontal direction |
| 179 | | ---- ---- ---- -www X size |
| 180 | | [2] |
| 181 | | ---- ---S xxxx xxxx X offset |
| 182 | | [3] |
| 183 | | oooo oooo oooo oooo sprite pointer |
| 184 | | */ |
| 185 | | |
| 186 | | for(i=spr_base/2;i<(spr_base+(spr_limit*8))/2;i+=4) |
| 187 | | { |
| 188 | | x = supracan_vram[i+2] & 0x00ff; |
| 189 | | y = supracan_vram[i+0] & 0x00ff; |
| 190 | | spr_offs = supracan_vram[i+3] << 2; |
| 191 | | bank = (supracan_vram[i+1] & 0xf000) >> 12; |
| 192 | | hflip = (supracan_vram[i+1] & 0x0800) ? 1 : 0; |
| 193 | | |
| 194 | | if(supracan_vram[i+2] & 0x100) |
| 195 | | x-=256; |
| 196 | | |
| 197 | | if(supracan_vram[i+3] != 0) |
| 198 | | { |
| 199 | | xsize = 1 << (supracan_vram[i+1] & 7); |
| 200 | | ysize = ((supracan_vram[i+0] & 0x1e00) >> 9)+1; |
| 201 | | |
| 202 | | for(ytile = 0; ytile < ysize; ytile++) |
| 203 | | { |
| 204 | | if(hflip) |
| 205 | | { |
| 206 | | for(xtile = (xsize - 1); xtile >= 0; xtile--) |
| 207 | | { |
| 208 | | UINT16 data = supracan_vram[spr_offs/2+ytile*xsize+xtile]; |
| 209 | | int tile = (bank * 0x200) + (data & 0x03ff); |
| 210 | | int xflip = (data & 0x0800) ? 0 : 1; |
| 211 | | int yflip = (data & 0x0400) ? 1 : 0; |
| 212 | | col = (data & 0xf000) >> 12; |
| 213 | | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],tile,col,xflip,yflip,x+((xsize - 1) - xtile)*8,y+ytile*8,0); |
| 214 | | } |
| 215 | | } |
| 216 | | else |
| 217 | | { |
| 218 | | for(xtile = 0; xtile < xsize; xtile++) |
| 219 | | { |
| 220 | | UINT16 data = supracan_vram[spr_offs/2+ytile*xsize+xtile]; |
| 221 | | int tile = (bank * 0x200) + (data & 0x03ff); |
| 222 | | int xflip = (data & 0x0800) ? 1 : 0; |
| 223 | | int yflip = (data & 0x0400) ? 1 : 0; |
| 224 | | col = (data & 0xf000) >> 12; |
| 225 | | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],tile,col,xflip,yflip,x+xtile*8,y+ytile*8,0); |
| 226 | | } |
| 227 | | } |
| 228 | | } |
| 229 | | } |
| 230 | | } |
| 231 | | } |
| 232 | | |
| 233 | 253 | return 0; |
| 234 | 254 | } |
| 235 | 255 | |
| r6904 | r6905 | |
| 534 | 554 | // ... |
| 535 | 555 | } |
| 536 | 556 | break; |
| 557 | case 0x08/2: |
| 558 | video_flags = data; |
| 559 | break; |
| 560 | case 0x20/2: |
| 561 | spr_base_addr = data << 2; |
| 562 | break; |
| 537 | 563 | case 0x22/2: |
| 538 | 564 | spr_limit = data+1; |
| 539 | 565 | break; |
| 566 | case 0x26/2: |
| 567 | spr_flags = data; |
| 568 | break; |
| 569 | case 0x104/2: tilemap_scrollx[0] = data; break; |
| 570 | case 0x106/2: tilemap_scrolly[0] = data; break; |
| 571 | case 0x108/2: tilemap_base_addr[0] = (data) << 1; break; |
| 572 | case 0x124/2: tilemap_scrollx[1] = data; break; |
| 573 | case 0x126/2: tilemap_scrolly[1] = data; break; |
| 574 | case 0x128/2: tilemap_base_addr[1] = (data) << 1; break; |
| 575 | case 0x144/2: tilemap_scrollx[2] = data; break; |
| 576 | case 0x146/2: tilemap_scrolly[2] = data; break; |
| 577 | case 0x148/2: tilemap_base_addr[2] = (data) << 1; break; |
| 540 | 578 | // Affine transforms of some sort? |
| 541 | 579 | case ACAN_VID_XFORM32A_H: |
| 542 | 580 | case ACAN_VID_XFORM32A_L: |