Previous 15994 Revisions Next

r15914 Thursday 16th August, 2012 at 01:19:38 UTC by Angelo Salese
Various changes / fixes, and preliminary implementation of the MOVBSU opcode
[src/emu/cpu/v810]v810.c
[src/mess/drivers]vboy.c

src/emu/cpu/v810/v810.c
r15913r15914
945945   return clkIF+1;
946946}
947947
948/* TODO: clocks */
949static void opMOVBSU(v810_state *cpustate,UINT32 op)
950{
951   UINT32 srcoff,dstoff,src,dst,size;
952   UINT32 tmp;
953
954//   printf("BDST %08x BSRC %08x SIZE %08x DST %08x SRC %08x\n",cpustate->R26,cpustate->R27,cpustate->R28,cpustate->R29,cpustate->R30);
955
956   dstoff = cpustate->R26;
957   srcoff = cpustate->R27;
958   size =  cpustate->R28;
959   dst = cpustate->R29 & ~3;
960   src = cpustate->R30 & ~3;
961
962   tmp = R_W(cpustate,src);
963   W_W(cpustate,dst,tmp);
964
965   srcoff++;
966   dstoff++;
967
968   srcoff&=0x1f;
969   dstoff&=0x1f;
970
971   if(srcoff == 0)
972      src+=4;
973
974   if(dstoff == 0)
975      dst+=4;
976
977   size --;
978
979   cpustate->R26 = dstoff;
980   cpustate->R27 = srcoff;
981   cpustate->R28 = size;
982   cpustate->R29 = dst;
983   cpustate->R30 = src;
984
985   if(size != 0)
986      cpustate->PC-=2;
987}
988
989static UINT32 opBSU(v810_state *cpustate,UINT32 op)
990{
991   if(!(op & 8))
992      fatalerror("V810: unknown BSU opcode %04x",op);
993
994   switch(op & 0xf)
995   {
996      case 0xb: opMOVBSU(cpustate,op); break;
997      default: fatalerror("V810: unemulated BSU opcode %04x\n",op);
998   }
999
1000   return clkIF+1; //TODO: correct?
1001}
1002
9481003static UINT32 (*const OpCodeTable[64])(v810_state *cpustate,UINT32 op) =
9491004{
9501005   /* 0x00 */ opMOVr,     // mov r1,r2            1
r15913r15914
9781033   /* 0x1c */ opLDSR,     // ldsr reg2,regID          2
9791034   /* 0x1d */ opSTSR,     // stsr regID,reg2          2
9801035   /* 0x1e */ opDI,   // DI               2
981   /* 0x1f */ opUNDEF,
1036   /* 0x1f */ opBSU,
9821037   /* 0x20 */ opB,    // Branch (7 bit opcode)
9831038   /* 0x21 */ opB,    // Branch (7 bit opcode)
9841039   /* 0x22 */ opB,    // Branch (7 bit opcode)
src/mess/drivers/vboy.c
r15913r15914
5858   UINT16 latch;
5959};
6060
61typedef struct _vboy_timer_t timer_t;
61typedef struct _vboy_timer_t vboy_timer_t;
6262
6363class vboy_state : public driver_device
6464{
r15913r15914
9999   UINT16 *m_objects;
100100   vboy_regs_t m_vboy_regs;
101101   vip_regs_t m_vip_regs;
102   timer_t m_vboy_timer;
102   vboy_timer_t m_vboy_timer;
103103   bitmap_ind16 m_bg_map[16];
104104   bitmap_ind16 m_screen_output;
105105   UINT16 m_frame_count;
106106   UINT8 m_displayfb;
107107   UINT8 m_display_count;
108   UINT8 m_row_num;
108109
109110   void m_timer_tick(UINT8 setting);
110111   void m_scanline_tick(int scanline, UINT8 screen_type);
111112   void m_set_irq(UINT16 irq_vector);
113
114   void m_pcg_debug(UINT16 offset,UINT16 data,UINT16 mem_mask);
115
112116};
113117
114118READ32_MEMBER( vboy_state::port_02_read )
r15913r15914
225229         UINT16 res;
226230
227231         res = m_vip_regs.DPCTRL & 0x0702;
228         if(m_vip_regs.DPCTRL & 2 && m_display_count & 1)
232
233         if(m_vip_regs.DPCTRL & 2)
229234         {
230            if(m_display_count & 2)
231               res |= 8 << (m_displayfb*2);
235            UINT8 DPBSY = machine().rand() & 3;
236
237            if(DPBSY & 2)
238               res |= 0x20;
239            else if(DPBSY & 1)
240               res |= 0x08;
232241         }
233242
234243         res |= 0x40;
244         //printf("%04x\n",res);
235245         return res;
236246      }
237247      case 0x22:   //DPCTRL
r15913r15914
254264         ---- ---- ---- x--- XPBSY1 (second framebuffer busy flag)
255265         ---- ---- ---- -x-- XPBSY0 (first framebfuffer busy flag)
256266         */
257         int frame_num = machine().primary_screen->frame_number() & 1;
258         //int row_num = (machine().primary_screen->vpos() / 8) & 0x1f;
267         UINT8 drawfb = ((m_displayfb ^ 1) + 1) << 2;
259268         UINT16 res;
260269
261270         //printf("%d\n",row_num);
262271
263272         res =  m_vip_regs.XPSTTS & 0x00f3; // empty ^^'
264         res |= frame_num ? 0x0c : 0x00;
265         //if(m_vip_regs.DPCTRL & 2) /* FIXME: this crashes emulation in boundh and some other games */
273         if(m_vip_regs.XPCTRL & 2 && m_row_num < 224/8) // screen active
274            res |= drawfb;
275
276         {
277            res |= 0x8000;
278            res |= m_row_num<<8;
279         }
280         //if(m_vip_regs.DPCTRL & 2)
266281         //   res |= ((row_num)<<8);
267282
268283         return res;
r15913r15914
375390               */
376391               m_vip_regs.XPCTRL = data & 0x1f02;
377392
378               if(data & 0x1f00)
379                  printf("%04x SBCMP\n",data);
393               //if(data & 0x1f00)
394               //   printf("%04x SBCMP\n",data);
380395
381396               if(data & 1)
382397               {
r15913r15914
432447   }
433448}
434449
450
451void vboy_state::m_pcg_debug(UINT16 offset,UINT16 data,UINT16 mem_mask)
452{
453   UINT8 *pcg_ram = memregion("pcg")->base();
454
455   if(mem_mask & 0x00ff)
456      pcg_ram[(offset<<1)+1] = (data & 0x00ff);
457
458   if(mem_mask & 0xff00)
459      pcg_ram[(offset<<1)+0] = (data & 0xff00) >> 8;
460
461   gfx_element_mark_dirty(machine().gfx[0], offset >> 4);
462}
463
435464WRITE16_MEMBER( vboy_state::vboy_font0_w )
436465{
437466   m_font[offset] = data | (m_font[offset] & (mem_mask ^ 0xffff));
467
468   if(1)
469      m_pcg_debug(offset,data,mem_mask);
438470}
439471
440472WRITE16_MEMBER( vboy_state::vboy_font1_w )
441473{
442474   m_font[offset + 0x1000] = data | (m_font[offset + 0x1000] & (mem_mask ^ 0xffff));
475
476   if(1)
477      m_pcg_debug(offset+0x1000,data,mem_mask);
443478}
444479
445480WRITE16_MEMBER( vboy_state::vboy_font2_w )
446481{
447482   m_font[offset + 0x2000] = data | (m_font[offset + 0x2000] & (mem_mask ^ 0xffff));
483
484   if(1)
485      m_pcg_debug(offset+0x2000,data,mem_mask);
448486}
449487
450488WRITE16_MEMBER( vboy_state::vboy_font3_w )
451489{
452490   m_font[offset + 0x3000] = data | (m_font[offset + 0x3000] & (mem_mask ^ 0xffff));
491
492   if(1)
493      m_pcg_debug(offset+0x3000,data,mem_mask);
453494}
454495
455496READ16_MEMBER( vboy_state::vboy_font0_r )
r15913r15914
664705
665706   vboy_paramtab = state->m_bgmap + param_base;
666707
708   if(def & 0x40) // END flag
709      return 1;
710
667711   if (mode < 2)
668712   {
669713      fill_bg_map(state, bg_map_num, state->m_bg_map[bg_map_num]);
r15913r15914
729773         INT16 jp = state->m_objects[start_ndx+1] & 0x3fff;
730774         INT16 jy = state->m_objects[start_ndx+2] & 0x1ff;
731775         UINT16 val = state->m_objects[start_ndx+3];
776         UINT8 jlon = (state->m_objects[start_ndx+1] & 0x8000) >> 15;
777         UINT8 jron = (state->m_objects[start_ndx+1] & 0x4000) >> 14;
732778
733         if (!right)
779         if (!right && jlon)
734780            put_char(state, bitmap, (jx-jp) & 0x1ff, jy, val & 0x7ff, BIT(val,13), BIT(val,12), 1, state->m_vip_regs.JPLT[(val>>14) & 3]);
735         else
781
782         if(right && jron)
736783            put_char(state, bitmap, (jx+jp) & 0x1ff, jy, val & 0x7ff, BIT(val,13), BIT(val,12), 1, state->m_vip_regs.JPLT[(val>>14) & 3]);
737784      }
738785   }
739   // Return END world status
740   return BIT(def,6);
786
787   return 0;
741788}
742789
743790static SCREEN_UPDATE_IND16( vboy_left )
r15913r15914
823870{
824871   //int frame_num = machine().primary_screen->frame_number();
825872
826   if(screen_type == 1)
827   {
828      if(scanline == 240)
829      {
830         m_set_irq(0x0004); // RFBEND
831      }
873   if(screen_type == 0)
874      m_row_num = (scanline / 8) & 0x1f;
832875
833      return;
834   }
835
836876   if(scanline == 0)
837877   {
838878      if(m_vip_regs.DPCTRL & 2)
r15913r15914
847887      {
848888         m_set_irq(0x0008); // GAME_START
849889         m_frame_count = 0;
850         if(m_vip_regs.XPCTRL & 2)
851         {
852            m_displayfb ^= 1;
853         }
854890      }
855   }
856891
857   if(scanline == 144)
858   {
859      // ...
892      if(m_vip_regs.XPCTRL & 2)
893         m_displayfb ^= 1;
860894   }
861895
862896   if(scanline == 224)
863897      m_set_irq(0x4000); // XPEND
864898
865899   if(scanline == 232)
866   {
867900      m_set_irq(0x0002); // LFBEND
868   }
869901
902   if(scanline == 240)
903      m_set_irq(0x0004); // RFBEND
904
870905   if(scanline == 248)
871906   {
872907      //m_set_irq(0x2000); // SBHIT
873908   }
874909
875   if(scanline == 256)
876   {
877      // ...
878   }
879910}
880911
881912static TIMER_DEVICE_CALLBACK( vboy_scanlineL )
r15913r15914
886917   state->m_scanline_tick(scanline,0);
887918}
888919
920#if 0
889921static TIMER_DEVICE_CALLBACK( vboy_scanlineR )
890922{
891923   vboy_state *state = timer.machine().driver_data<vboy_state>();
892924   int scanline = param;
893925
894   state->m_scanline_tick(scanline,1);
926   //state->m_scanline_tick(scanline,1);
895927}
928#endif
896929
930
931static const gfx_layout vboy_pcg_8x8 =
932{
933   8,8,
934   RGN_FRAC(1,1),
935   2,
936   { 0, 1 },
937   { 7*2, 6*2, 5*2, 4*2, 3*2, 2*2, 1*2, 0*2 },
938   { STEP8(0,8*2) },
939   8*8*2
940};
941
942/* decoded for debugging purpose, this will be nuked in the end... */
943static GFXDECODE_START( vboy )
944   GFXDECODE_ENTRY( "pcg",     0x00000, vboy_pcg_8x8,      0, 1 )
945GFXDECODE_END
946
947
897948static MACHINE_CONFIG_START( vboy, vboy_state )
898949
899950   /* basic machine hardware */
r15913r15914
901952   MCFG_CPU_PROGRAM_MAP(vboy_mem)
902953   MCFG_CPU_IO_MAP(vboy_io)
903954   MCFG_TIMER_ADD_SCANLINE("scantimer_l", vboy_scanlineL, "3dleft", 0, 1)
904   MCFG_TIMER_ADD_SCANLINE("scantimer_r", vboy_scanlineR, "3dright", 0, 1)
955   //MCFG_TIMER_ADD_SCANLINE("scantimer_r", vboy_scanlineR, "3dright", 0, 1)
905956
906957   MCFG_MACHINE_RESET(vboy)
907958
r15913r15914
936987   MCFG_CARTSLOT_MANDATORY
937988   MCFG_CARTSLOT_INTERFACE("vboy_cart")
938989
990   MCFG_GFXDECODE(vboy)
991
939992   /* software lists */
940993   MCFG_SOFTWARE_LIST_ADD("cart_list","vboy")
941994MACHINE_CONFIG_END
r15913r15914
944997ROM_START( vboy )
945998   ROM_REGION( 0x200000, "user1", 0 )
946999   ROM_CART_LOAD("cart", 0x0000, 0x200000, ROM_MIRROR)
1000
1001   ROM_REGION( 0x8000, "pcg", ROMREGION_ERASE00 )
9471002ROM_END
9481003
9491004/* Driver */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team