Previous 199869 Revisions Next

r32322 Tuesday 23rd September, 2014 at 18:04:12 UTC by Fabio Priuli
(MESS) ssem: converted the driver to use quickload for
mounting programs into memory, since this system
obviously uses no carts. nw.
[src/mess/drivers]ssem.c

trunk/src/mess/drivers/ssem.c
r32321r32322
77
88#include "emu.h"
99#include "cpu/ssem/ssem.h"
10#include "imagedev/cartslot.h"
11#include <stdarg.h>
10#include "imagedev/snapquik.h"
1211
1312class ssem_state : public driver_device
1413{
r32321r32322
2423   required_device<screen_device> m_screen;
2524
2625   UINT8 m_store_line;
26   virtual void machine_start();
2727   virtual void machine_reset();
2828   UINT32 screen_update_ssem(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
2929   DECLARE_INPUT_CHANGED_MEMBER(panel_check);
30   DECLARE_DEVICE_IMAGE_LOAD_MEMBER(ssem_store);
30   DECLARE_QUICKLOAD_LOAD_MEMBER(ssem_store);
3131   inline UINT32 reverse(UINT32 v);
3232   void glyph_print(bitmap_rgb32 &bitmap, INT32 x, INT32 y, const char *msg, ...) ATTR_PRINTF(5,6);
3333   void strlower(char *buf);
r32321r32322
4545// un-reversed before being used.
4646inline UINT32 ssem_state::reverse(UINT32 v)
4747{
48   // Taken from http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
48   // Taken from http://www.graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
4949   // swap odd and even bits
5050   v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1);
5151   // swap consecutive pairs
r32321r32322
518518* Image loading                                      *
519519\****************************************************/
520520
521DEVICE_IMAGE_LOAD_MEMBER(ssem_state,ssem_store)
521QUICKLOAD_LOAD_MEMBER(ssem_state, ssem_store)
522522{
523   const char* image_name = image.filename();
524   char image_ext[5] = { 0 };
523   address_space &space = m_maincpu->space(AS_PROGRAM);
525524   char image_line[100] = { 0 };
526525   char token_buf[100] = { 0 };
527526   int num_lines = 0;
528   int i = 0;
529527
530   // Isolate file extension and convert to lower-case
531   memcpy(image_ext, image_name + (strlen(image_name) - 4), 5);
532   strlower(image_ext);
533
534528   image.fgets(image_line, 99);
535529   sscanf(image_line, "%d", &num_lines);
536530
537   if(num_lines)
531   if (num_lines)
538532   {
539      for(i = 0; i < num_lines; i++)
533      for (int i = 0; i < num_lines; i++)
540534      {
541535         UINT32 line = 0;
542536         image.fgets(image_line, 99);
r32321r32322
546540         token_buf[4] = '\0';
547541         sscanf(token_buf, "%04d", &line);
548542
549         if(strcmp(image_ext, ".snp") == 0)
543         if (!core_stricmp(image.filetype(), "snp"))
550544         {
551545            UINT32 word = 0;
552            int b = 0;
553546
554547            // Parse a line such as: 0000:00000110101001000100000100000100
555            for(b = 0; b < 32; b++)
548            for (int b = 0; b < 32; b++)
556549            {
557               if(image_line[5 + b] == '1')
558               {
550               if (image_line[5 + b] == '1')
559551                  word |= 1 << (31 - b);
560               }
561552            }
562553
563            m_store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
564            m_store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
565            m_store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
566            m_store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
554            space.write_byte((line << 2) + 0, (word >> 24) & 0x000000ff);
555            space.write_byte((line << 2) + 1, (word >> 16) & 0x000000ff);
556            space.write_byte((line << 2) + 2, (word >>  8) & 0x000000ff);
557            space.write_byte((line << 2) + 3, (word >>  0) & 0x000000ff);
567558         }
568         else if(strcmp(image_ext, ".asm") == 0)
559         else if (!core_stricmp(image.filetype(), "asm"))
569560         {
570561            char op_buf[4] = { 0 };
571562            INT32 value = 0;
r32321r32322
581572            sscanf(image_line + 9, "%d", &value);
582573            unsigned_value = reverse((UINT32)value);
583574
584            if(strcmp(op_buf, "num") == 0)
585            {
575            if (!core_stricmp(op_buf, "num"))
586576               word = unsigned_value;
587            }
588            else if(strcmp(op_buf, "jmp") == 0)
589            {
577            else if (!core_stricmp(op_buf, "jmp"))
590578               word = 0x00000000 | unsigned_value ;
591            }
592            else if(strcmp(op_buf, "jrp") == 0)
593            {
579            else if (!core_stricmp(op_buf, "jrp"))
594580               word = 0x00040000 | unsigned_value;
595            }
596            else if(strcmp(op_buf, "ldn") == 0)
597            {
581            else if (!core_stricmp(op_buf, "ldn"))
598582               word = 0x00020000 | unsigned_value;
599            }
600            else if(strcmp(op_buf, "sto") == 0)
601            {
583            else if (!core_stricmp(op_buf, "sto"))
602584               word = 0x00060000 | unsigned_value;
603            }
604            else if(strcmp(op_buf, "sub") == 0)
605            {
585            else if (!core_stricmp(op_buf, "sub"))
606586               word = 0x00010000 | unsigned_value;
607            }
608            else if(strcmp(op_buf, "cmp") == 0)
609            {
587            else if (!core_stricmp(op_buf, "cmp"))
610588               word = 0x00030000 | unsigned_value;
611            }
612            else if(strcmp(op_buf, "stp") == 0)
613            {
589            else if (!core_stricmp(op_buf, "stp"))
614590               word = 0x00070000 | unsigned_value;
615            }
616591
617            m_store[(line << 2) + 0] = (word >> 24) & 0x000000ff;
618            m_store[(line << 2) + 1] = (word >> 16) & 0x000000ff;
619            m_store[(line << 2) + 2] = (word >>  8) & 0x000000ff;
620            m_store[(line << 2) + 3] = (word >>  0) & 0x000000ff;
592            space.write_byte((line << 2) + 0, (word >> 24) & 0x000000ff);
593            space.write_byte((line << 2) + 1, (word >> 16) & 0x000000ff);
594            space.write_byte((line << 2) + 2, (word >>  8) & 0x000000ff);
595            space.write_byte((line << 2) + 3, (word >>  0) & 0x000000ff);
621596         }
622597      }
623598   }
r32321r32322
629604* Machine definition                                 *
630605\****************************************************/
631606
607void ssem_state::machine_start()
608{
609   save_item(NAME(m_store_line));
610}
611
632612void ssem_state::machine_reset()
633613{
634614   m_store_line = 0;
r32321r32322
639619   MCFG_CPU_ADD("maincpu", SSEMCPU, 700)
640620   MCFG_CPU_PROGRAM_MAP(ssem_map)
641621
642
643622   /* video hardware */
644623   MCFG_SCREEN_ADD("screen", RASTER)
645624   MCFG_SCREEN_REFRESH_RATE(50)
r32321r32322
649628   MCFG_SCREEN_UPDATE_DRIVER(ssem_state, screen_update_ssem)
650629   MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette")
651630
652   /* cartridge */
653   MCFG_CARTSLOT_ADD("cart")
654   MCFG_CARTSLOT_EXTENSION_LIST("snp,asm")
655   MCFG_CARTSLOT_LOAD(ssem_state,ssem_store)
631   /* quickload */
632   MCFG_QUICKLOAD_ADD("quickload", ssem_state, ssem_store, "snp,asm", 1)
656633MACHINE_CONFIG_END
657634
635
658636ROM_START( ssem )
659637   ROM_REGION( 0x80, "maincpu", ROMREGION_ERASE00 )  /* Main Store */
660638ROM_END
661639
640
662641/*   YEAR  NAME     PARENT    COMPAT   MACHINE  INPUT  INIT        COMPANY                       FULLNAME */
663COMP(1948, ssem,    0,        0,       ssem,    ssem, driver_device,  0,   "Manchester University", "Small-Scale Experimental Machine (SSEM), 'Baby'", GAME_NO_SOUND_HW )
642COMP(1948, ssem,    0,        0,       ssem,    ssem, driver_device,  0,   "Manchester University", "Small-Scale Experimental Machine (SSEM), 'Baby'", GAME_NO_SOUND_HW | GAME_SUPPORTS_SAVE )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team