trunk/src/mame/drivers/sfcbox.c
r17550 | r17551 | |
117 | 117 | #include "cpu/spc700/spc700.h" |
118 | 118 | #include "cpu/g65816/g65816.h" |
119 | 119 | #include "cpu/z180/z180.h" |
| 120 | #include "video/mb90092.h" |
120 | 121 | #include "includes/snes.h" |
121 | 122 | #include "audio/snes_snd.h" |
| 123 | #include "rendlay.h" |
122 | 124 | |
123 | 125 | class sfcbox_state : public snes_state |
124 | 126 | { |
125 | 127 | public: |
126 | 128 | sfcbox_state(const machine_config &mconfig, device_type type, const char *tag) |
127 | 129 | : snes_state(mconfig, type, tag), |
128 | | m_bios(*this, "bios") |
| 130 | m_bios(*this, "bios"), |
| 131 | m_mb90092(*this,"mb90092") |
129 | 132 | { } |
130 | 133 | |
131 | 134 | required_device <cpu_device> m_bios; |
| 135 | required_device <mb90092_device> m_mb90092; |
132 | 136 | |
133 | | DECLARE_WRITE8_MEMBER(tx_w); |
| 137 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
134 | 138 | }; |
135 | 139 | |
| 140 | UINT32 sfcbox_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
| 141 | { |
| 142 | m_mb90092->screen_update(screen,bitmap,cliprect); |
| 143 | return 0; |
| 144 | } |
136 | 145 | |
137 | 146 | static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, sfcbox_state ) |
138 | 147 | AM_RANGE(0x000000, 0x2fffff) AM_READWRITE_LEGACY(snes_r_bank1, snes_w_bank1) /* I/O and ROM (repeats for each bank) */ |
r17550 | r17551 | |
171 | 180 | ADDRESS_MAP_END |
172 | 181 | |
173 | 182 | |
174 | | WRITE8_MEMBER( sfcbox_state::tx_w ) |
175 | | { |
176 | | printf("%02x\n",data); |
177 | | } |
178 | 183 | |
179 | 184 | static ADDRESS_MAP_START( sfcbox_io, AS_IO, 8, sfcbox_state ) |
180 | | AM_RANGE(0x0b, 0x0b) AM_WRITE(tx_w) |
| 185 | AM_RANGE(0x0b, 0x0b) AM_DEVWRITE("mb90092",mb90092_device,write) |
181 | 186 | AM_RANGE(0x00, 0x3f) AM_RAM // internal i/o |
182 | 187 | // AM_RANGE(0x80, 0x80) // Keyswitch and Button Inputs / SNES Transfer and Misc Output |
183 | 188 | // AM_RANGE(0x81, 0x81) // SNES Transfer and Misc Input / Misc Output |
r17550 | r17551 | |
343 | 348 | MCFG_CPU_PROGRAM_MAP(sfcbox_map) |
344 | 349 | MCFG_CPU_IO_MAP(sfcbox_io) |
345 | 350 | |
| 351 | MCFG_MB90092_ADD("mb90092",XTAL_12MHz / 2) /* TODO: pixel clock */ |
| 352 | |
| 353 | /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs for now */ |
| 354 | MCFG_DEFAULT_LAYOUT(layout_dualhsxs) |
| 355 | |
| 356 | MCFG_SCREEN_ADD("osd", RASTER) |
| 357 | MCFG_SCREEN_REFRESH_RATE(60) |
| 358 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 359 | // MCFG_SCREEN_SIZE(24*12+22, 12*18+22) |
| 360 | // MCFG_SCREEN_VISIBLE_AREA(0*8, 24*12-1, 0*8, 12*18-1) |
| 361 | MCFG_SCREEN_SIZE(24*16+22, 12*16+22) |
| 362 | MCFG_SCREEN_VISIBLE_AREA(0*8, 24*16-1, 0*8, 12*16-1) |
| 363 | MCFG_SCREEN_UPDATE_DRIVER(sfcbox_state,screen_update) |
346 | 364 | MACHINE_CONFIG_END |
347 | 365 | |
348 | 366 | /*************************************************************************** |
trunk/src/emu/video/mb90092.c
r0 | r17551 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Fujitsu MB90092 OSD |
| 4 | |
| 5 | preliminary device by Angelo Salese |
| 6 | |
| 7 | TODO: |
| 8 | - get a real charset ROM; |
| 9 | |
| 10 | ***************************************************************************/ |
| 11 | |
| 12 | #include "emu.h" |
| 13 | #include "video/mb90092.h" |
| 14 | |
| 15 | |
| 16 | |
| 17 | //************************************************************************** |
| 18 | // GLOBAL VARIABLES |
| 19 | //************************************************************************** |
| 20 | |
| 21 | // device type definition |
| 22 | const device_type MB90092 = &device_creator<mb90092_device>; |
| 23 | |
| 24 | static ADDRESS_MAP_START( mb90092_vram, AS_0, 16, mb90092_device ) |
| 25 | AM_RANGE(0x0000, 0x023f) AM_RAM // vram |
| 26 | ADDRESS_MAP_END |
| 27 | |
| 28 | /* charset is undumped, but apparently a normal ASCII one is enough for the time being (for example "fnt0808.x1" in Sharp X1) */ |
| 29 | ROM_START( mb90092 ) |
| 30 | ROM_REGION( 0x0800, "mb90092", 0 ) |
| 31 | ROM_LOAD("mb90092_char.bin", 0x0000, 0x0800, NO_DUMP ) |
| 32 | ROM_END |
| 33 | |
| 34 | //------------------------------------------------- |
| 35 | // rom_region - device-specific ROM region |
| 36 | //------------------------------------------------- |
| 37 | |
| 38 | const rom_entry *mb90092_device::device_rom_region() const |
| 39 | { |
| 40 | return ROM_NAME( mb90092 ); |
| 41 | } |
| 42 | |
| 43 | //------------------------------------------------- |
| 44 | // memory_space_config - return a description of |
| 45 | // any address spaces owned by this device |
| 46 | //------------------------------------------------- |
| 47 | |
| 48 | const address_space_config *mb90092_device::memory_space_config(address_spacenum spacenum) const |
| 49 | { |
| 50 | return (spacenum == AS_0) ? &m_space_config : NULL; |
| 51 | } |
| 52 | |
| 53 | //************************************************************************** |
| 54 | // INLINE HELPERS |
| 55 | //************************************************************************** |
| 56 | |
| 57 | //------------------------------------------------- |
| 58 | // readbyte - read a byte at the given address |
| 59 | //------------------------------------------------- |
| 60 | |
| 61 | inline UINT16 mb90092_device::read_word(offs_t address) |
| 62 | { |
| 63 | return space()->read_word(address << 1); |
| 64 | } |
| 65 | |
| 66 | //------------------------------------------------- |
| 67 | // writebyte - write a byte at the given address |
| 68 | //------------------------------------------------- |
| 69 | |
| 70 | inline void mb90092_device::write_word(offs_t address, UINT16 data) |
| 71 | { |
| 72 | space()->write_word(address << 1, data); |
| 73 | } |
| 74 | |
| 75 | //************************************************************************** |
| 76 | // LIVE DEVICE |
| 77 | //************************************************************************** |
| 78 | |
| 79 | //------------------------------------------------- |
| 80 | // mb90092_device - constructor |
| 81 | //------------------------------------------------- |
| 82 | |
| 83 | mb90092_device::mb90092_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 84 | : device_t(mconfig, MB90092, "mb90092", tag, owner, clock), |
| 85 | device_memory_interface(mconfig, *this), |
| 86 | m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, NULL, *ADDRESS_MAP_NAME(mb90092_vram)) |
| 87 | { |
| 88 | m_shortname = "mb90092"; |
| 89 | |
| 90 | } |
| 91 | |
| 92 | |
| 93 | //------------------------------------------------- |
| 94 | // device_validity_check - perform validity checks |
| 95 | // on this device |
| 96 | //------------------------------------------------- |
| 97 | |
| 98 | void mb90092_device::device_validity_check(validity_checker &valid) const |
| 99 | { |
| 100 | } |
| 101 | |
| 102 | |
| 103 | //------------------------------------------------- |
| 104 | // device_start - device-specific startup |
| 105 | //------------------------------------------------- |
| 106 | |
| 107 | void mb90092_device::device_start() |
| 108 | { |
| 109 | |
| 110 | } |
| 111 | |
| 112 | |
| 113 | //------------------------------------------------- |
| 114 | // device_reset - device-specific reset |
| 115 | //------------------------------------------------- |
| 116 | |
| 117 | void mb90092_device::device_reset() |
| 118 | { |
| 119 | int i; |
| 120 | m_cmd_ff = 0; |
| 121 | |
| 122 | for(i=0;i<0x120;i++) |
| 123 | write_word(i,0x00ff); |
| 124 | } |
| 125 | |
| 126 | |
| 127 | //************************************************************************** |
| 128 | // READ/WRITE HANDLERS |
| 129 | //************************************************************************** |
| 130 | |
| 131 | WRITE8_MEMBER( mb90092_device::write ) |
| 132 | { |
| 133 | UINT16 dat; |
| 134 | |
| 135 | switch(m_cmd_ff) |
| 136 | { |
| 137 | case OSD_COMMAND: |
| 138 | m_cmd = data & 0xf8; |
| 139 | m_cmd_param = data & 7; |
| 140 | //printf("cmd %02x\n",data); |
| 141 | break; |
| 142 | case OSD_DATA: |
| 143 | dat = ((m_cmd_param & 7)<<7) | (data & 0x7f); |
| 144 | switch(m_cmd) |
| 145 | { |
| 146 | case 0x80: // preset VRAM address |
| 147 | m_osd_addr = dat; |
| 148 | //printf("%04x %d %d\n",m_osd_addr,(m_osd_addr & 0x1f),(m_osd_addr & 0x1e0) >> 5); |
| 149 | break; |
| 150 | case 0x90: // write Character |
| 151 | int x,y; |
| 152 | x = (m_osd_addr & 0x1f); |
| 153 | y = (m_osd_addr & 0x1e0) >> 5; |
| 154 | //printf("%d %d\n",x,y); |
| 155 | write_word(x+y*24,dat); |
| 156 | |
| 157 | /* handle address increments */ |
| 158 | x = ((x + 1) % 24); |
| 159 | if(x == 0) |
| 160 | y = ((y + 1) % 12); |
| 161 | m_osd_addr = x + (y << 5); |
| 162 | |
| 163 | break; |
| 164 | |
| 165 | } |
| 166 | break; |
| 167 | } |
| 168 | |
| 169 | m_cmd_ff ^= 1; |
| 170 | } |
| 171 | |
| 172 | UINT32 mb90092_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 173 | { |
| 174 | int x,y; |
| 175 | UINT8 *pcg = memregion("mb90092")->base(); |
| 176 | UINT16 tile; |
| 177 | |
| 178 | for(y=0;y<12;y++) |
| 179 | { |
| 180 | for(x=0;x<24;x++) |
| 181 | { |
| 182 | int xi,yi; |
| 183 | |
| 184 | tile = read_word(x+y*24); |
| 185 | |
| 186 | /* TODO: charset hook-up is obviously WRONG so following mustn't be trusted at all */ |
| 187 | for(yi=0;yi<16;yi++) |
| 188 | { |
| 189 | for(xi=0;xi<16;xi++) |
| 190 | { |
| 191 | UINT8 pix; |
| 192 | UINT32 pen; |
| 193 | |
| 194 | pix = (pcg[(tile*8)+(yi >> 1)] >> (7-(xi >> 1))) & 1; |
| 195 | |
| 196 | pen = pix ? 0xffffff : 0; |
| 197 | if(tile == 0xff) |
| 198 | pen = 0; |
| 199 | |
| 200 | bitmap.pix32(y*16+yi,x*16+xi) = pen; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | return 0; |
| 207 | } |
trunk/src/emu/video/mb90092.h
r0 | r17551 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Template for skeleton device |
| 4 | |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #ifndef __MB90092DEV_H__ |
| 10 | #define __MB90092DEV_H__ |
| 11 | |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // INTERFACE CONFIGURATION MACROS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | #define MCFG_MB90092_ADD(_tag,_freq) \ |
| 19 | MCFG_DEVICE_ADD(_tag, MB90092, _freq) \ |
| 20 | |
| 21 | |
| 22 | //************************************************************************** |
| 23 | // TYPE DEFINITIONS |
| 24 | //************************************************************************** |
| 25 | |
| 26 | enum |
| 27 | { |
| 28 | OSD_COMMAND = 0, |
| 29 | OSD_DATA |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | // ======================> mb90092_device |
| 34 | |
| 35 | class mb90092_device : public device_t, |
| 36 | public device_memory_interface |
| 37 | { |
| 38 | public: |
| 39 | // construction/destruction |
| 40 | mb90092_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 41 | |
| 42 | // I/O operations |
| 43 | DECLARE_WRITE8_MEMBER( write ); |
| 44 | |
| 45 | UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 46 | virtual const rom_entry *device_rom_region() const; |
| 47 | |
| 48 | protected: |
| 49 | // device-level overrides |
| 50 | virtual void device_validity_check(validity_checker &valid) const; |
| 51 | virtual void device_start(); |
| 52 | virtual void device_reset(); |
| 53 | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; |
| 54 | |
| 55 | private: |
| 56 | UINT8 m_cmd_ff; |
| 57 | UINT8 m_cmd,m_cmd_param; |
| 58 | UINT16 m_osd_addr; |
| 59 | |
| 60 | inline UINT16 read_word(offs_t address); |
| 61 | inline void write_word(offs_t address, UINT16 data); |
| 62 | |
| 63 | const address_space_config m_space_config; |
| 64 | }; |
| 65 | |
| 66 | |
| 67 | // device type definition |
| 68 | extern const device_type MB90092; |
| 69 | |
| 70 | |
| 71 | |
| 72 | //************************************************************************** |
| 73 | // GLOBAL VARIABLES |
| 74 | //************************************************************************** |
| 75 | |
| 76 | |
| 77 | |
| 78 | #endif |