src/mess/video/upd7220.c
| r11221 | r11222 | |
| 38 | 38 | #include "emu.h" |
| 39 | 39 | #include "upd7220.h" |
| 40 | 40 | |
| 41 | | /*************************************************************************** |
| 42 | | PARAMETERS |
| 43 | | ***************************************************************************/ |
| 44 | 41 | |
| 42 | |
| 43 | //************************************************************************** |
| 44 | // MACROS / CONSTANTS |
| 45 | //************************************************************************** |
| 46 | |
| 45 | 47 | #define LOG 1 |
| 46 | 48 | |
| 49 | |
| 47 | 50 | // todo typedef |
| 48 | 51 | enum |
| 49 | 52 | { |
| r11221 | r11222 | |
| 125 | 128 | #define UPD7220_MODE_DISPLAY_CHARACTER 0x20 |
| 126 | 129 | #define UPD7220_MODE_DISPLAY_INVALID 0x22 |
| 127 | 130 | |
| 128 | | /*************************************************************************** |
| 129 | | TYPE DEFINITIONS |
| 130 | | ***************************************************************************/ |
| 131 | static const int x_dir[8] = { 0, 1, 1, 1, 0,-1,-1,-1}; |
| 132 | static const int y_dir[8] = { 1, 1, 0,-1,-1,-1, 0, 1}; |
| 133 | static const int x_dir_dot[8] = { 1, 1, 0,-1,-1,-1, 0, 1}; |
| 134 | static const int y_dir_dot[8] = { 0,-1,-1,-1, 0, 1, 1, 1}; |
| 131 | 135 | |
| 132 | | typedef void (*upd7220_command) (device_t *device); |
| 133 | 136 | |
| 134 | | typedef struct _upd7220_t upd7220_t; |
| 135 | | struct _upd7220_t |
| 136 | | { |
| 137 | | devcb_resolved_write_line out_drq_func; |
| 138 | | devcb_resolved_write_line out_hsync_func; |
| 139 | | devcb_resolved_write_line out_vsync_func; |
| 140 | | devcb_resolved_write_line out_blank_func; |
| 141 | | upd7220_display_pixels_func display_func; |
| 142 | | upd7220_draw_text_line draw_text_func; |
| 143 | 137 | |
| 144 | | screen_device *screen; /* screen */ |
| 138 | //************************************************************************** |
| 139 | // GLOBAL VARIABLES |
| 140 | //************************************************************************** |
| 145 | 141 | |
| 146 | | int clock; /* device clock */ |
| 142 | // devices |
| 143 | const device_type UPD7220 = upd7220_device_config::static_alloc_device_config; |
| 147 | 144 | |
| 148 | | UINT16 mask; /* mask register */ |
| 149 | | UINT8 pitch; /* number of word addresses in display memory in the horizontal direction */ |
| 150 | | UINT32 ead; /* execute word address */ |
| 151 | | UINT16 dad; /* dot address within the word */ |
| 152 | | UINT32 lad; /* light pen address */ |
| 153 | 145 | |
| 154 | | UINT8 ra[16]; /* parameter RAM */ |
| 155 | | int ra_addr; /* parameter RAM address */ |
| 146 | // default address map |
| 147 | static ADDRESS_MAP_START( upd7220_vram, AS_0, 8 ) |
| 148 | AM_RANGE(0x00000, 0x3ffff) AM_RAM |
| 149 | ADDRESS_MAP_END |
| 156 | 150 | |
| 157 | | UINT8 sr; /* status register */ |
| 158 | | UINT8 cr; /* command register */ |
| 159 | | UINT8 pr[17]; /* parameter byte register */ |
| 160 | | int param_ptr; /* parameter pointer */ |
| 161 | 151 | |
| 162 | | UINT8 fifo[16]; /* FIFO data queue */ |
| 163 | | int fifo_flag[16]; /* FIFO flag queue */ |
| 164 | | int fifo_ptr; /* FIFO pointer */ |
| 165 | | int fifo_dir; /* FIFO direction */ |
| 152 | // internal 128x14 control ROM |
| 153 | ROM_START( upd7220 ) |
| 154 | ROM_REGION( 0x100, "upd7220", 0 ) |
| 155 | ROM_LOAD( "upd7220.bin", 0x000, 0x100, NO_DUMP ) |
| 156 | ROM_END |
| 166 | 157 | |
| 167 | | UINT8 mode; /* mode of operation */ |
| 168 | | UINT8 draw_mode; /* mode of drawing */ |
| 169 | 158 | |
| 170 | | int de; /* display enabled */ |
| 171 | | int m; /* 0 = accept external vertical sync (slave mode) / 1 = generate & output vertical sync (master mode) */ |
| 172 | | int aw; /* active display words per line - 2 (must be even number with bit 0 = 0) */ |
| 173 | | int al; /* active display lines per video field */ |
| 174 | | int vs; /* vertical sync width - 1 */ |
| 175 | | int vfp; /* vertical front porch width - 1 */ |
| 176 | | int vbp; /* vertical back porch width - 1 */ |
| 177 | | int hs; /* horizontal sync width - 1 */ |
| 178 | | int hfp; /* horizontal front porch width - 1 */ |
| 179 | | int hbp; /* horizontal back porch width - 1 */ |
| 180 | 159 | |
| 181 | | int dc; /* display cursor */ |
| 182 | | int sc; /* 0 = blinking cursor / 1 = steady cursor */ |
| 183 | | int br; /* blink rate */ |
| 184 | | int ctop; /* cursor top line number in the row */ |
| 185 | | int cbot; /* cursor bottom line number in the row (CBOT < LR) */ |
| 186 | | int lr; /* lines per character row - 1 */ |
| 160 | //************************************************************************** |
| 161 | // DEVICE CONFIGURATION |
| 162 | //************************************************************************** |
| 187 | 163 | |
| 188 | | int disp; /* display zoom factor */ |
| 189 | | int gchr; /* zoom factor for graphics character writing and area filling */ |
| 164 | //------------------------------------------------- |
| 165 | // upd7220_device_config - constructor |
| 166 | //------------------------------------------------- |
| 190 | 167 | |
| 191 | | struct { |
| 192 | | UINT8 dir; /* figs param 0: drawing direction */ |
| 193 | | UINT8 figure_type; /* figs param 1: figure type */ |
| 194 | | UINT16 dc; /* figs param 2: */ |
| 195 | | UINT16 d; /* figs param 3: */ |
| 196 | | UINT16 d1; /* figs param 4: */ |
| 197 | | UINT16 d2; /* figs param 5: */ |
| 198 | | UINT16 dm; /* figs param 6: */ |
| 199 | | }figs; |
| 168 | upd7220_device_config::upd7220_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 169 | : device_config(mconfig, static_alloc_device_config, "uPD7220", tag, owner, clock), |
| 170 | device_config_memory_interface(mconfig, *this), |
| 171 | m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, NULL, *ADDRESS_MAP_NAME(upd7220_vram)) |
| 172 | { |
| 173 | m_shortname = "upd7220"; |
| 174 | } |
| 200 | 175 | |
| 201 | | /* timers */ |
| 202 | | emu_timer *vsync_timer; /* vertical sync timer */ |
| 203 | | emu_timer *hsync_timer; /* horizontal sync timer */ |
| 204 | | emu_timer *blank_timer; /* CRT blanking timer */ |
| 205 | 176 | |
| 206 | | UINT8 vram[0x40000]; |
| 207 | | UINT32 vram_bank; |
| 177 | //------------------------------------------------- |
| 178 | // static_alloc_device_config - allocate a new |
| 179 | // configuration object |
| 180 | //------------------------------------------------- |
| 208 | 181 | |
| 209 | | UINT8 bitmap_mod; |
| 210 | | }; |
| 182 | device_config *upd7220_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 183 | { |
| 184 | return global_alloc(upd7220_device_config(mconfig, tag, owner, clock)); |
| 185 | } |
| 211 | 186 | |
| 212 | | static const int x_dir[8] = { 0, 1, 1, 1, 0,-1,-1,-1}; |
| 213 | | static const int y_dir[8] = { 1, 1, 0,-1,-1,-1, 0, 1}; |
| 214 | | static const int x_dir_dot[8] = { 1, 1, 0,-1,-1,-1, 0, 1}; |
| 215 | | static const int y_dir_dot[8] = { 0,-1,-1,-1, 0, 1, 1, 1}; |
| 216 | 187 | |
| 217 | | /*************************************************************************** |
| 218 | | INLINE FUNCTIONS |
| 219 | | ***************************************************************************/ |
| 188 | //------------------------------------------------- |
| 189 | // alloc_device - allocate a new device object |
| 190 | //------------------------------------------------- |
| 220 | 191 | |
| 221 | | INLINE upd7220_t *get_safe_token(device_t *device) |
| 192 | device_t *upd7220_device_config::alloc_device(running_machine &machine) const |
| 222 | 193 | { |
| 223 | | assert(device != NULL); |
| 224 | | assert((device->type() == UPD7220)); |
| 225 | | return (upd7220_t *)downcast<legacy_device_base *>(device)->token(); |
| 194 | return auto_alloc(machine, upd7220_device(machine, *this)); |
| 226 | 195 | } |
| 227 | 196 | |
| 228 | | INLINE const upd7220_interface *get_interface(device_t *device) |
| 197 | |
| 198 | //------------------------------------------------- |
| 199 | // memory_space_config - return a description of |
| 200 | // any address spaces owned by this device |
| 201 | //------------------------------------------------- |
| 202 | |
| 203 | const address_space_config *upd7220_device_config::memory_space_config(address_spacenum spacenum) const |
| 229 | 204 | { |
| 230 | | assert(device != NULL); |
| 231 | | assert((device->type() == UPD7220)); |
| 232 | | return (const upd7220_interface *) device->baseconfig().static_config(); |
| 205 | return (spacenum == AS_0) ? &m_space_config : NULL; |
| 233 | 206 | } |
| 234 | 207 | |
| 235 | | INLINE void fifo_clear(upd7220_t *upd7220) |
| 208 | |
| 209 | //------------------------------------------------- |
| 210 | // rom_region - device-specific ROM region |
| 211 | //------------------------------------------------- |
| 212 | |
| 213 | const rom_entry *upd7220_device_config::device_rom_region() const |
| 236 | 214 | { |
| 237 | | int i; |
| 215 | return ROM_NAME( upd7220 ); |
| 216 | } |
| 238 | 217 | |
| 239 | | for (i = 0; i < 16; i++) |
| 218 | |
| 219 | //------------------------------------------------- |
| 220 | // device_config_complete - perform any |
| 221 | // operations now that the configuration is |
| 222 | // complete |
| 223 | //------------------------------------------------- |
| 224 | |
| 225 | void upd7220_device_config::device_config_complete() |
| 226 | { |
| 227 | // inherit a copy of the static data |
| 228 | const upd7220_interface *intf = reinterpret_cast<const upd7220_interface *>(static_config()); |
| 229 | if (intf != NULL) |
| 230 | *static_cast<upd7220_interface *>(this) = *intf; |
| 231 | |
| 232 | // or initialize to defaults if none provided |
| 233 | else |
| 240 | 234 | { |
| 241 | | upd7220->fifo[i] = 0; |
| 242 | | upd7220->fifo_flag[i] = FIFO_EMPTY; |
| 235 | memset(&m_out_drq_func, 0, sizeof(m_out_drq_func)); |
| 236 | memset(&m_out_hsync_func, 0, sizeof(m_out_hsync_func)); |
| 237 | memset(&m_out_vsync_func, 0, sizeof(m_out_vsync_func)); |
| 238 | memset(&m_out_blank_func, 0, sizeof(m_out_blank_func)); |
| 243 | 239 | } |
| 240 | } |
| 244 | 241 | |
| 245 | | upd7220->fifo_ptr = -1; |
| 246 | 242 | |
| 247 | | upd7220->sr &= ~UPD7220_SR_DATA_READY; |
| 248 | | upd7220->sr |= UPD7220_SR_FIFO_EMPTY; |
| 249 | | upd7220->sr &= ~UPD7220_SR_FIFO_FULL; |
| 243 | |
| 244 | //************************************************************************** |
| 245 | // INLINE HELPERS |
| 246 | //************************************************************************** |
| 247 | |
| 248 | //------------------------------------------------- |
| 249 | // fifo_clear - |
| 250 | //------------------------------------------------- |
| 251 | |
| 252 | inline void upd7220_device::fifo_clear() |
| 253 | { |
| 254 | for (int i = 0; i < 16; i++) |
| 255 | { |
| 256 | m_fifo[i] = 0; |
| 257 | m_fifo_flag[i] = FIFO_EMPTY; |
| 258 | } |
| 259 | |
| 260 | m_fifo_ptr = -1; |
| 261 | |
| 262 | m_sr &= ~UPD7220_SR_DATA_READY; |
| 263 | m_sr |= UPD7220_SR_FIFO_EMPTY; |
| 264 | m_sr &= ~UPD7220_SR_FIFO_FULL; |
| 250 | 265 | } |
| 251 | 266 | |
| 252 | | INLINE int fifo_param_count(upd7220_t *upd7220) |
| 267 | |
| 268 | //------------------------------------------------- |
| 269 | // fifo_param_count - |
| 270 | //------------------------------------------------- |
| 271 | |
| 272 | inline int upd7220_device::fifo_param_count() |
| 253 | 273 | { |
| 254 | 274 | int i; |
| 255 | 275 | |
| 256 | 276 | for (i = 0; i < 16; i++) |
| 257 | 277 | { |
| 258 | | if (upd7220->fifo_flag[i] != FIFO_PARAMETER) break; |
| 278 | if (m_fifo_flag[i] != FIFO_PARAMETER) break; |
| 259 | 279 | } |
| 260 | 280 | |
| 261 | 281 | return i; |
| 262 | 282 | } |
| 263 | 283 | |
| 264 | | INLINE void fifo_set_direction(upd7220_t *upd7220, int dir) |
| 284 | |
| 285 | //------------------------------------------------- |
| 286 | // fifo_set_direction - |
| 287 | //------------------------------------------------- |
| 288 | |
| 289 | inline void upd7220_device::fifo_set_direction(int dir) |
| 265 | 290 | { |
| 266 | | if (upd7220->fifo_dir != dir) |
| 291 | if (m_fifo_dir != dir) |
| 267 | 292 | { |
| 268 | | fifo_clear(upd7220); |
| 293 | fifo_clear(); |
| 269 | 294 | } |
| 270 | 295 | |
| 271 | | upd7220->fifo_dir = dir; |
| 296 | m_fifo_dir = dir; |
| 272 | 297 | } |
| 273 | 298 | |
| 274 | | INLINE void queue(upd7220_t *upd7220, UINT8 data, int flag) |
| 299 | |
| 300 | //------------------------------------------------- |
| 301 | // queue - |
| 302 | //------------------------------------------------- |
| 303 | |
| 304 | inline void upd7220_device::queue(UINT8 data, int flag) |
| 275 | 305 | { |
| 276 | | if (upd7220->fifo_ptr < 15) |
| 306 | if (m_fifo_ptr < 15) |
| 277 | 307 | { |
| 278 | | upd7220->fifo_ptr++; |
| 308 | m_fifo_ptr++; |
| 279 | 309 | |
| 280 | | upd7220->fifo[upd7220->fifo_ptr] = data; |
| 281 | | upd7220->fifo_flag[upd7220->fifo_ptr] = flag; |
| 310 | m_fifo[m_fifo_ptr] = data; |
| 311 | m_fifo_flag[m_fifo_ptr] = flag; |
| 282 | 312 | |
| 283 | | if (upd7220->fifo_ptr == 16) |
| 313 | if (m_fifo_ptr == 16) |
| 284 | 314 | { |
| 285 | | upd7220->sr |= UPD7220_SR_FIFO_FULL; |
| 315 | m_sr |= UPD7220_SR_FIFO_FULL; |
| 286 | 316 | } |
| 287 | 317 | |
| 288 | | upd7220->sr &= ~UPD7220_SR_FIFO_EMPTY; |
| 318 | m_sr &= ~UPD7220_SR_FIFO_EMPTY; |
| 289 | 319 | } |
| 290 | 320 | else |
| 291 | 321 | { |
| r11221 | r11222 | |
| 294 | 324 | } |
| 295 | 325 | } |
| 296 | 326 | |
| 297 | | INLINE void dequeue(upd7220_t *upd7220, UINT8 *data, int *flag) |
| 327 | |
| 328 | //------------------------------------------------- |
| 329 | // dequeue - |
| 330 | //------------------------------------------------- |
| 331 | |
| 332 | inline void upd7220_device::dequeue(UINT8 *data, int *flag) |
| 298 | 333 | { |
| 299 | | int i; |
| 334 | *data = m_fifo[0]; |
| 335 | *flag = m_fifo_flag[0]; |
| 300 | 336 | |
| 301 | | *data = upd7220->fifo[0]; |
| 302 | | *flag = upd7220->fifo_flag[0]; |
| 303 | | |
| 304 | | if (upd7220->fifo_ptr > -1) |
| 337 | if (m_fifo_ptr > -1) |
| 305 | 338 | { |
| 306 | | for (i = 0; i < 15; i++) |
| 339 | for (int i = 0; i < 15; i++) |
| 307 | 340 | { |
| 308 | | upd7220->fifo[i] = upd7220->fifo[i + 1]; |
| 309 | | upd7220->fifo_flag[i] = upd7220->fifo_flag[i + 1]; |
| 341 | m_fifo[i] = m_fifo[i + 1]; |
| 342 | m_fifo_flag[i] = m_fifo_flag[i + 1]; |
| 310 | 343 | } |
| 311 | 344 | |
| 312 | | upd7220->fifo[15] = 0; |
| 313 | | upd7220->fifo_flag[15] = 0; |
| 345 | m_fifo[15] = 0; |
| 346 | m_fifo_flag[15] = 0; |
| 314 | 347 | |
| 315 | | upd7220->fifo_ptr--; |
| 348 | m_fifo_ptr--; |
| 316 | 349 | |
| 317 | | if (upd7220->fifo_ptr == -1) |
| 350 | if (m_fifo_ptr == -1) |
| 318 | 351 | { |
| 319 | | upd7220->sr &= ~UPD7220_SR_DATA_READY; |
| 320 | | upd7220->sr |= UPD7220_SR_FIFO_EMPTY; |
| 352 | m_sr &= ~UPD7220_SR_DATA_READY; |
| 353 | m_sr |= UPD7220_SR_FIFO_EMPTY; |
| 321 | 354 | } |
| 322 | 355 | } |
| 323 | 356 | } |
| 324 | 357 | |
| 325 | | /*************************************************************************** |
| 326 | | IMPLEMENTATION |
| 327 | | ***************************************************************************/ |
| 328 | 358 | |
| 329 | | /*------------------------------------------------- |
| 330 | | update_vsync_timer - |
| 331 | | -------------------------------------------------*/ |
| 359 | //------------------------------------------------- |
| 360 | // update_vsync_timer - |
| 361 | //------------------------------------------------- |
| 332 | 362 | |
| 333 | | static void update_vsync_timer(upd7220_t *upd7220, int state) |
| 363 | inline void upd7220_device::update_vsync_timer(int state) |
| 334 | 364 | { |
| 335 | | int next_y = state ? upd7220->vs : 0; |
| 365 | int next_y = state ? m_vs : 0; |
| 336 | 366 | |
| 337 | | attotime duration = upd7220->screen->time_until_pos(next_y, 0); |
| 367 | attotime duration = m_screen->time_until_pos(next_y, 0); |
| 338 | 368 | |
| 339 | | upd7220->vsync_timer->adjust(duration, !state); |
| 369 | m_vsync_timer->adjust(duration, !state); |
| 340 | 370 | } |
| 341 | 371 | |
| 342 | | /*------------------------------------------------- |
| 343 | | TIMER_CALLBACK( vsync_tick ) |
| 344 | | -------------------------------------------------*/ |
| 345 | 372 | |
| 346 | | static TIMER_CALLBACK( vsync_tick ) |
| 347 | | { |
| 348 | | device_t *device = (device_t *)ptr; |
| 349 | | upd7220_t *upd7220 = get_safe_token(device); |
| 373 | //------------------------------------------------- |
| 374 | // update_hsync_timer - |
| 375 | //------------------------------------------------- |
| 350 | 376 | |
| 351 | | if (param) |
| 352 | | { |
| 353 | | upd7220->sr |= UPD7220_SR_VSYNC_ACTIVE; |
| 354 | | } |
| 355 | | else |
| 356 | | { |
| 357 | | upd7220->sr &= ~UPD7220_SR_VSYNC_ACTIVE; |
| 358 | | } |
| 359 | | |
| 360 | | devcb_call_write_line(&upd7220->out_vsync_func, param); |
| 361 | | |
| 362 | | update_vsync_timer(upd7220, param); |
| 363 | | } |
| 364 | | |
| 365 | | /*------------------------------------------------- |
| 366 | | update_hsync_timer - |
| 367 | | -------------------------------------------------*/ |
| 368 | | |
| 369 | | static void update_hsync_timer(upd7220_t *upd7220, int state) |
| 377 | inline void upd7220_device::update_hsync_timer(int state) |
| 370 | 378 | { |
| 371 | | int y = upd7220->screen->vpos(); |
| 379 | int y = m_screen->vpos(); |
| 372 | 380 | |
| 373 | | int next_x = state ? upd7220->hs : 0; |
| 374 | | int next_y = state ? y : ((y + 1) % upd7220->al); |
| 381 | int next_x = state ? m_hs : 0; |
| 382 | int next_y = state ? y : ((y + 1) % m_al); |
| 375 | 383 | |
| 376 | | attotime duration = upd7220->screen->time_until_pos(next_y, next_x); |
| 384 | attotime duration = m_screen->time_until_pos(next_y, next_x); |
| 377 | 385 | |
| 378 | | upd7220->hsync_timer->adjust(duration, !state); |
| 386 | m_hsync_timer->adjust(duration, !state); |
| 379 | 387 | } |
| 380 | 388 | |
| 381 | | /*------------------------------------------------- |
| 382 | | TIMER_CALLBACK( hsync_tick ) |
| 383 | | -------------------------------------------------*/ |
| 384 | 389 | |
| 385 | | static TIMER_CALLBACK( hsync_tick ) |
| 386 | | { |
| 387 | | device_t *device = (device_t *)ptr; |
| 388 | | upd7220_t *upd7220 = get_safe_token(device); |
| 390 | //------------------------------------------------- |
| 391 | // update_blank_timer - |
| 392 | //------------------------------------------------- |
| 389 | 393 | |
| 390 | | if (param) |
| 391 | | { |
| 392 | | upd7220->sr |= UPD7220_SR_HBLANK_ACTIVE; |
| 393 | | } |
| 394 | | else |
| 395 | | { |
| 396 | | upd7220->sr &= ~UPD7220_SR_HBLANK_ACTIVE; |
| 397 | | } |
| 398 | | |
| 399 | | devcb_call_write_line(&upd7220->out_hsync_func, param); |
| 400 | | |
| 401 | | update_hsync_timer(upd7220, param); |
| 402 | | } |
| 403 | | |
| 404 | | /*------------------------------------------------- |
| 405 | | update_blank_timer - |
| 406 | | -------------------------------------------------*/ |
| 407 | | |
| 408 | | static void update_blank_timer(upd7220_t *upd7220, int state) |
| 394 | inline void upd7220_device::update_blank_timer(int state) |
| 409 | 395 | { |
| 410 | | int y = upd7220->screen->vpos(); |
| 396 | int y = m_screen->vpos(); |
| 411 | 397 | |
| 412 | | int next_x = state ? (upd7220->hs + upd7220->hbp) : (upd7220->hs + upd7220->hbp + (upd7220->aw << 3)); |
| 413 | | int next_y = state ? ((y + 1) % (upd7220->vs + upd7220->vbp + upd7220->al + upd7220->vfp - 1)) : y; |
| 398 | int next_x = state ? (m_hs + m_hbp) : (m_hs + m_hbp + (m_aw << 3)); |
| 399 | int next_y = state ? ((y + 1) % (m_vs + m_vbp + m_al + m_vfp - 1)) : y; |
| 414 | 400 | |
| 415 | | attotime duration = upd7220->screen->time_until_pos(next_y, next_x); |
| 401 | attotime duration = m_screen->time_until_pos(next_y, next_x); |
| 416 | 402 | |
| 417 | | upd7220->hsync_timer->adjust(duration, !state); |
| 403 | m_hsync_timer->adjust(duration, !state); |
| 418 | 404 | } |
| 419 | 405 | |
| 420 | | /*------------------------------------------------- |
| 421 | | TIMER_CALLBACK( blank_tick ) |
| 422 | | -------------------------------------------------*/ |
| 423 | 406 | |
| 424 | | static TIMER_CALLBACK( blank_tick ) |
| 425 | | { |
| 426 | | device_t *device = (device_t *)ptr; |
| 427 | | upd7220_t *upd7220 = get_safe_token(device); |
| 407 | //------------------------------------------------- |
| 408 | // recompute_parameters - |
| 409 | //------------------------------------------------- |
| 428 | 410 | |
| 429 | | if (param) |
| 430 | | { |
| 431 | | upd7220->sr |= UPD7220_SR_HBLANK_ACTIVE; |
| 432 | | } |
| 433 | | else |
| 434 | | { |
| 435 | | upd7220->sr &= ~UPD7220_SR_HBLANK_ACTIVE; |
| 436 | | } |
| 437 | | |
| 438 | | devcb_call_write_line(&upd7220->out_blank_func, param); |
| 439 | | |
| 440 | | update_blank_timer(upd7220, param); |
| 441 | | } |
| 442 | | |
| 443 | | /*------------------------------------------------- |
| 444 | | recompute_parameters - |
| 445 | | -------------------------------------------------*/ |
| 446 | | |
| 447 | | static void recompute_parameters(device_t *device) |
| 411 | inline void upd7220_device::recompute_parameters() |
| 448 | 412 | { |
| 449 | | upd7220_t *upd7220 = get_safe_token(device); |
| 413 | int horiz_pix_total = (m_hs + m_hbp + m_aw + m_hfp) * 8; |
| 414 | int vert_pix_total = m_vs + m_vbp + m_al + m_vfp; |
| 450 | 415 | |
| 451 | | int horiz_pix_total = (upd7220->hs + upd7220->hbp + upd7220->aw + upd7220->hfp) * 8; |
| 452 | | int vert_pix_total = upd7220->vs + upd7220->vbp + upd7220->al + upd7220->vfp; |
| 416 | //printf("%d %d %d %d\n",m_hs,m_hbp,m_aw,m_hfp); |
| 417 | //printf("%d %d\n",m_aw * 8,m_pitch * 8); |
| 453 | 418 | |
| 454 | | //printf("%d %d %d %d\n",upd7220->hs,upd7220->hbp,upd7220->aw,upd7220->hfp); |
| 455 | | //printf("%d %d\n",upd7220->aw * 8,upd7220->pitch * 8); |
| 456 | | |
| 457 | | if(horiz_pix_total == 0 || vert_pix_total == 0) //bail out if screen params aren't valid |
| 419 | if (horiz_pix_total == 0 || vert_pix_total == 0) //bail out if screen params aren't valid |
| 458 | 420 | return; |
| 459 | 421 | |
| 460 | | attoseconds_t refresh = HZ_TO_ATTOSECONDS(60); //HZ_TO_ATTOSECONDS(device->clock() * 8) * horiz_pix_total * vert_pix_total; |
| 422 | attoseconds_t refresh = HZ_TO_ATTOSECONDS(60); //HZ_TO_ATTOSECONDS(clock() * 8) * horiz_pix_total * vert_pix_total; |
| 461 | 423 | |
| 462 | 424 | rectangle visarea; |
| 463 | 425 | |
| 464 | | visarea.min_x = 0; //(upd7220->hs + upd7220->hbp) * 8; |
| 465 | | visarea.min_y = 0; //upd7220->vs + upd7220->vbp; |
| 466 | | visarea.max_x = upd7220->aw * 8 - 1;//horiz_pix_total - (upd7220->hfp * 8) - 1; |
| 467 | | visarea.max_y = upd7220->al - 1;//vert_pix_total - upd7220->vfp - 1; |
| 426 | visarea.min_x = 0; //(m_hs + m_hbp) * 8; |
| 427 | visarea.min_y = 0; //m_vs + m_vbp; |
| 428 | visarea.max_x = m_aw * 8 - 1;//horiz_pix_total - (m_hfp * 8) - 1; |
| 429 | visarea.max_y = m_al - 1;//vert_pix_total - m_vfp - 1; |
| 468 | 430 | |
| 469 | 431 | |
| 470 | 432 | if (LOG) |
| 471 | 433 | { |
| 472 | | logerror("uPD7220 '%s' Screen: %u x %u @ %f Hz\n", device->tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 473 | | logerror("uPD7220 '%s' Visible Area: (%u, %u) - (%u, %u)\n", device->tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 434 | logerror("uPD7220 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); |
| 435 | logerror("uPD7220 '%s' Visible Area: (%u, %u) - (%u, %u)\n", tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y); |
| 474 | 436 | } |
| 475 | 437 | |
| 476 | | if (upd7220->m) |
| 438 | if (m_m) |
| 477 | 439 | { |
| 478 | | upd7220->screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh); |
| 440 | m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh); |
| 479 | 441 | |
| 480 | | update_hsync_timer(upd7220, 0); |
| 481 | | update_vsync_timer(upd7220, 0); |
| 442 | update_hsync_timer(0); |
| 443 | update_vsync_timer(0); |
| 482 | 444 | } |
| 483 | 445 | else |
| 484 | 446 | { |
| 485 | | upd7220->hsync_timer->enable(0); |
| 486 | | upd7220->vsync_timer->enable(0); |
| 447 | m_hsync_timer->enable(0); |
| 448 | m_vsync_timer->enable(0); |
| 487 | 449 | } |
| 488 | 450 | |
| 489 | | update_blank_timer(upd7220, 0); |
| 451 | update_blank_timer(0); |
| 490 | 452 | } |
| 491 | 453 | |
| 492 | | /*----------------------------------------------------- |
| 493 | | reset_figs_param - reset figs after each vram rmw |
| 494 | | -----------------------------------------------------*/ |
| 495 | 454 | |
| 496 | | static void reset_figs_param(upd7220_t *upd7220) |
| 455 | //------------------------------------------------- |
| 456 | // reset_figs_param - |
| 457 | //------------------------------------------------- |
| 458 | |
| 459 | inline void upd7220_device::reset_figs_param() |
| 497 | 460 | { |
| 498 | | upd7220->figs.dc = 0x0000; |
| 499 | | upd7220->figs.d = 0x0008; |
| 500 | | upd7220->figs.d1 = 0x0008; |
| 501 | | upd7220->figs.d2 = 0x0000; |
| 502 | | upd7220->figs.dm = 0x0000; |
| 461 | m_figs.m_dc = 0x0000; |
| 462 | m_figs.m_d = 0x0008; |
| 463 | m_figs.m_d1 = 0x0008; |
| 464 | m_figs.m_d2 = 0x0000; |
| 465 | m_figs.m_dm = 0x0000; |
| 503 | 466 | } |
| 504 | 467 | |
| 505 | | /*------------------------------------------------- |
| 506 | | advance_ead - advance EAD pointer |
| 507 | | -------------------------------------------------*/ |
| 508 | 468 | |
| 509 | | #define EAD upd7220->ead |
| 510 | | #define DAD upd7220->dad |
| 511 | | #define P x_dir[upd7220->figs.dir] + (y_dir[upd7220->figs.dir] * upd7220->pitch) |
| 512 | | #define MSB(value) (BIT(value, 15)) |
| 513 | | #define LSB(value) (BIT(value, 0)) |
| 514 | | #define LR(value) ((value << 1) | MSB(value)) |
| 515 | | #define RR(value) ((LSB(value) << 15) | (value >> 1)) |
| 469 | //------------------------------------------------- |
| 470 | // advance_ead - |
| 471 | //------------------------------------------------- |
| 516 | 472 | |
| 517 | | static void advance_ead(upd7220_t *upd7220) |
| 473 | inline void upd7220_device::advance_ead() |
| 518 | 474 | { |
| 519 | | switch (upd7220->draw_mode & 0x07) |
| 475 | #define EAD m_ead |
| 476 | #define DAD m_dad |
| 477 | #define P x_dir[m_figs.m_dir] + (y_dir[m_figs.m_dir] * m_pitch) |
| 478 | #define MSB(value) (BIT(value, 15)) |
| 479 | #define LSB(value) (BIT(value, 0)) |
| 480 | #define LR(value) ((value << 1) | MSB(value)) |
| 481 | #define RR(value) ((LSB(value) << 15) | (value >> 1)) |
| 482 | |
| 483 | switch (m_draw_mode & 0x07) |
| 520 | 484 | { |
| 521 | 485 | case 0: |
| 522 | 486 | EAD += P; |
| r11221 | r11222 | |
| 564 | 528 | EAD &= 0x3ffff; |
| 565 | 529 | } |
| 566 | 530 | |
| 567 | | /*------------------------------------------------- |
| 568 | | read_vram - read in the device memory space |
| 569 | | -------------------------------------------------*/ |
| 570 | 531 | |
| 571 | | static void read_vram(upd7220_t *upd7220,UINT8 type, UINT8 mod) |
| 532 | //------------------------------------------------- |
| 533 | // read_vram - |
| 534 | //------------------------------------------------- |
| 535 | |
| 536 | inline void upd7220_device::read_vram(UINT8 type, UINT8 mod) |
| 572 | 537 | { |
| 573 | | int i; |
| 574 | | |
| 575 | | if(type == 1) |
| 538 | if (type == 1) |
| 576 | 539 | { |
| 577 | 540 | logerror("uPD7220 invalid type 1 RDAT parameter\n"); |
| 578 | 541 | return; |
| 579 | 542 | } |
| 580 | 543 | |
| 581 | | if(mod) |
| 544 | if (mod) |
| 582 | 545 | logerror("uPD7220 RDAT used with mod = %02x?\n",mod); |
| 583 | 546 | |
| 584 | | for(i=0;i<upd7220->figs.dc;i++) |
| 547 | for (int i = 0; i < m_figs.m_dc; i++) |
| 585 | 548 | { |
| 586 | 549 | switch(type) |
| 587 | 550 | { |
| 588 | 551 | case 0: |
| 589 | | queue(upd7220, upd7220->vram[upd7220->ead*2], 0); |
| 590 | | queue(upd7220, upd7220->vram[upd7220->ead*2+1], 0); |
| 552 | queue(m_vram[m_ead*2], 0); |
| 553 | queue(m_vram[m_ead*2+1], 0); |
| 591 | 554 | break; |
| 592 | 555 | case 2: |
| 593 | | queue(upd7220, upd7220->vram[upd7220->ead*2], 0); |
| 556 | queue(m_vram[m_ead*2], 0); |
| 594 | 557 | break; |
| 595 | 558 | case 3: |
| 596 | | queue(upd7220, upd7220->vram[upd7220->ead*2+1], 0); |
| 559 | queue(m_vram[m_ead*2+1], 0); |
| 597 | 560 | break; |
| 598 | 561 | } |
| 599 | 562 | |
| 600 | | advance_ead(upd7220); |
| 563 | advance_ead(); |
| 601 | 564 | } |
| 602 | 565 | } |
| 603 | 566 | |
| 604 | | /*------------------------------------------------- |
| 605 | | write_vram - write in the device memory space |
| 606 | | -------------------------------------------------*/ |
| 607 | 567 | |
| 608 | | static void write_vram(upd7220_t *upd7220,UINT8 type, UINT8 mod) |
| 568 | //------------------------------------------------- |
| 569 | // write_vram - |
| 570 | //------------------------------------------------- |
| 571 | |
| 572 | inline void upd7220_device::write_vram(UINT8 type, UINT8 mod) |
| 609 | 573 | { |
| 610 | | int i; |
| 611 | 574 | UINT16 result; |
| 612 | | if(type == 1) |
| 575 | |
| 576 | if (type == 1) |
| 613 | 577 | { |
| 614 | 578 | printf("uPD7220 invalid type 1 WDAT parameter\n"); |
| 615 | 579 | return; |
| r11221 | r11222 | |
| 620 | 584 | switch(type) |
| 621 | 585 | { |
| 622 | 586 | case 0: |
| 623 | | result = (upd7220->pr[1] & 0xff); |
| 624 | | result |= (upd7220->pr[2] << 8); |
| 625 | | result &= upd7220->mask; |
| 587 | result = (m_pr[1] & 0xff); |
| 588 | result |= (m_pr[2] << 8); |
| 589 | result &= m_mask; |
| 626 | 590 | break; |
| 627 | 591 | case 2: |
| 628 | | result = (upd7220->pr[1] & 0xff); |
| 629 | | result &= (upd7220->mask & 0xff); |
| 592 | result = (m_pr[1] & 0xff); |
| 593 | result &= (m_mask & 0xff); |
| 630 | 594 | break; |
| 631 | 595 | case 3: |
| 632 | | result = (upd7220->pr[1] << 8); |
| 633 | | result &= (upd7220->mask & 0xff00); |
| 596 | result = (m_pr[1] << 8); |
| 597 | result &= (m_mask & 0xff00); |
| 634 | 598 | break; |
| 635 | 599 | } |
| 636 | 600 | |
| 637 | 601 | //if(result) |
| 638 | 602 | { |
| 639 | | //printf("%04x %02x %02x %04x %02x %02x\n",upd7220->vram[upd7220->ead],upd7220->pr[1],upd7220->pr[2],upd7220->mask,type,mod); |
| 640 | | //printf("%04x %02x %02x\n",upd7220->ead,upd7220->figs.dir,upd7220->pitch); |
| 641 | | //printf("%04x %04x %02x %04x\n",upd7220->ead,result,mod,upd7220->figs.dc); |
| 603 | //printf("%04x %02x %02x %04x %02x %02x\n",m_vram[m_ead],m_pr[1],m_pr[2],m_mask,type,mod); |
| 604 | //printf("%04x %02x %02x\n",m_ead,m_figs.m_dir,m_pitch); |
| 605 | //printf("%04x %04x %02x %04x\n",m_ead,result,mod,m_figs.m_dc); |
| 642 | 606 | } |
| 643 | 607 | |
| 644 | | for(i=0;i<upd7220->figs.dc + 1;i++) |
| 608 | for(int i = 0; i < m_figs.m_dc + 1; i++) |
| 645 | 609 | { |
| 646 | 610 | switch(mod & 3) |
| 647 | 611 | { |
| 648 | 612 | case 0x00: //replace |
| 649 | 613 | if(type == 0 || type == 2) |
| 650 | | upd7220->vram[upd7220->ead*2+0] = result & 0xff; |
| 614 | m_vram[m_ead*2+0] = result & 0xff; |
| 651 | 615 | if(type == 0 || type == 3) |
| 652 | | upd7220->vram[upd7220->ead*2+1] = result >> 8; |
| 616 | m_vram[m_ead*2+1] = result >> 8; |
| 653 | 617 | break; |
| 654 | 618 | case 0x01: //complement |
| 655 | 619 | if(type == 0 || type == 2) |
| 656 | | upd7220->vram[upd7220->ead*2+0] ^= result & 0xff; |
| 620 | m_vram[m_ead*2+0] ^= result & 0xff; |
| 657 | 621 | if(type == 0 || type == 3) |
| 658 | | upd7220->vram[upd7220->ead*2+1] ^= result >> 8; |
| 622 | m_vram[m_ead*2+1] ^= result >> 8; |
| 659 | 623 | break; |
| 660 | 624 | case 0x02: //reset to zero |
| 661 | 625 | if(type == 0 || type == 2) |
| 662 | | upd7220->vram[upd7220->ead*2+0] &= ~result; |
| 626 | m_vram[m_ead*2+0] &= ~result; |
| 663 | 627 | if(type == 0 || type == 3) |
| 664 | | upd7220->vram[upd7220->ead*2+1] &= ~(result >> 8); |
| 628 | m_vram[m_ead*2+1] &= ~(result >> 8); |
| 665 | 629 | break; |
| 666 | 630 | case 0x03: //set to one |
| 667 | 631 | if(type == 0 || type == 2) |
| 668 | | upd7220->vram[upd7220->ead*2+0] |= result; |
| 632 | m_vram[m_ead*2+0] |= result; |
| 669 | 633 | if(type == 0 || type == 3) |
| 670 | | upd7220->vram[upd7220->ead*2+1] |= (result >> 8); |
| 634 | m_vram[m_ead*2+1] |= (result >> 8); |
| 671 | 635 | break; |
| 672 | 636 | } |
| 673 | 637 | |
| 674 | | advance_ead(upd7220); |
| 638 | advance_ead(); |
| 675 | 639 | } |
| 676 | 640 | } |
| 677 | 641 | |
| 678 | | static UINT16 check_pattern(upd7220_t *upd7220, UINT16 pattern) |
| 642 | |
| 643 | //------------------------------------------------- |
| 644 | // check_pattern - |
| 645 | //------------------------------------------------- |
| 646 | |
| 647 | inline UINT16 upd7220_device::check_pattern(UINT16 pattern) |
| 679 | 648 | { |
| 680 | | UINT16 res; |
| 649 | UINT16 res = 0; |
| 681 | 650 | |
| 682 | | res = 0; |
| 683 | | |
| 684 | | switch(upd7220->bitmap_mod & 3) |
| 651 | switch (m_bitmap_mod & 3) |
| 685 | 652 | { |
| 686 | 653 | case 0: res = pattern; break; //replace |
| 687 | 654 | case 1: res = pattern; break; //complement |
| r11221 | r11222 | |
| 692 | 659 | return res; |
| 693 | 660 | } |
| 694 | 661 | |
| 695 | | static void draw_pixel(upd7220_t *upd7220,int x,int y,UINT16 tile_data) |
| 662 | |
| 663 | //------------------------------------------------- |
| 664 | // get_text_partition - |
| 665 | //------------------------------------------------- |
| 666 | |
| 667 | inline void upd7220_device::get_text_partition(int index, UINT32 *sad, UINT16 *len, int *im, int *wd) |
| 696 | 668 | { |
| 697 | | UINT32 addr = (y * upd7220->pitch * 2 + (x >> 3)) & 0x3ffff; |
| 698 | | int dad; |
| 669 | *sad = ((m_ra[(index * 4) + 1] & 0x1f) << 8) | m_ra[(index * 4) + 0]; |
| 670 | *len = ((m_ra[(index * 4) + 3] & 0x3f) << 4) | (m_ra[(index * 4) + 2] >> 4); |
| 671 | *im = BIT(m_ra[(index * 4) + 3], 6); |
| 672 | *wd = BIT(m_ra[(index * 4) + 3], 7); |
| 673 | } |
| 699 | 674 | |
| 700 | | dad = x & 0x7; |
| 701 | 675 | |
| 702 | | if((upd7220->bitmap_mod & 3) == 1) |
| 676 | //------------------------------------------------- |
| 677 | // get_graphics_partition - |
| 678 | //------------------------------------------------- |
| 679 | |
| 680 | inline void upd7220_device::get_graphics_partition(int index, UINT32 *sad, UINT16 *len, int *im, int *wd) |
| 681 | { |
| 682 | *sad = ((m_ra[(index * 4) + 2] & 0x03) << 16) | (m_ra[(index * 4) + 1] << 8) | m_ra[(index * 4) + 0]; |
| 683 | *len = ((m_ra[(index * 4) + 3] & 0x3f) << 4) | (m_ra[(index * 4) + 2] >> 4); |
| 684 | *im = BIT(m_ra[(index * 4) + 3], 6); |
| 685 | *wd = BIT(m_ra[(index * 4) + 3], 7); |
| 686 | } |
| 687 | |
| 688 | |
| 689 | |
| 690 | //************************************************************************** |
| 691 | // LIVE DEVICE |
| 692 | //************************************************************************** |
| 693 | |
| 694 | //------------------------------------------------- |
| 695 | // upd7220_device - constructor |
| 696 | //------------------------------------------------- |
| 697 | |
| 698 | upd7220_device::upd7220_device(running_machine &_machine, const upd7220_device_config &config) |
| 699 | : device_t(_machine, config), |
| 700 | device_memory_interface(_machine, config, *this), |
| 701 | m_mask(0), |
| 702 | m_pitch(0), |
| 703 | m_ead(0), |
| 704 | m_dad(0), |
| 705 | m_lad(0), |
| 706 | m_ra_addr(0), |
| 707 | m_sr(UPD7220_SR_FIFO_EMPTY), |
| 708 | m_cr(0), |
| 709 | m_param_ptr(0), |
| 710 | m_fifo_ptr(-1), |
| 711 | m_fifo_dir(0), |
| 712 | m_mode(0), |
| 713 | m_draw_mode(0), |
| 714 | m_de(0), |
| 715 | m_m(0), |
| 716 | m_aw(0), |
| 717 | m_al(0), |
| 718 | m_vs(0), |
| 719 | m_vfp(0), |
| 720 | m_vbp(0), |
| 721 | m_hs(0), |
| 722 | m_hfp(0), |
| 723 | m_hbp(0), |
| 724 | m_dc(0), |
| 725 | m_sc(0), |
| 726 | m_br(0), |
| 727 | m_ctop(0), |
| 728 | m_cbot(0), |
| 729 | m_lr(0), |
| 730 | m_disp(0), |
| 731 | m_gchr(0), |
| 732 | m_vram_bank(0), |
| 733 | m_bitmap_mod(0), |
| 734 | m_config(config) |
| 735 | { |
| 736 | for (int i = 0; i < 16; i++) |
| 703 | 737 | { |
| 704 | | upd7220->vram[addr + upd7220->vram_bank] ^= ((tile_data) & (0x80 >> (dad))); |
| 738 | m_fifo[i] = 0; |
| 739 | m_fifo_flag[i] = FIFO_EMPTY; |
| 740 | |
| 741 | m_ra[i] = 0; |
| 705 | 742 | } |
| 743 | |
| 744 | for (int i = 0; i < 17; i++) |
| 745 | { |
| 746 | m_pr[i] = 0; |
| 747 | } |
| 748 | |
| 749 | m_figs.m_dir = 0; |
| 750 | m_figs.m_figure_type = 0; |
| 751 | m_figs.m_dc = 0; |
| 752 | m_figs.m_d = 0; |
| 753 | m_figs.m_d1 = 0; |
| 754 | m_figs.m_d2 = 0; |
| 755 | m_figs.m_dm = 0; |
| 756 | } |
| 757 | |
| 758 | |
| 759 | //------------------------------------------------- |
| 760 | // device_start - device-specific startup |
| 761 | //------------------------------------------------- |
| 762 | |
| 763 | void upd7220_device::device_start() |
| 764 | { |
| 765 | // allocate timers |
| 766 | m_vsync_timer = timer_alloc(TIMER_VSYNC); |
| 767 | m_hsync_timer = timer_alloc(TIMER_HSYNC); |
| 768 | m_blank_timer = timer_alloc(TIMER_BLANK); |
| 769 | |
| 770 | // resolve callbacks |
| 771 | devcb_resolve_write_line(&m_out_drq_func, &m_config.m_out_drq_func, this); |
| 772 | devcb_resolve_write_line(&m_out_hsync_func, &m_config.m_out_hsync_func, this); |
| 773 | devcb_resolve_write_line(&m_out_vsync_func, &m_config.m_out_vsync_func, this); |
| 774 | devcb_resolve_write_line(&m_out_blank_func, &m_config.m_out_blank_func, this); |
| 775 | |
| 776 | // find screen |
| 777 | m_screen = m_machine.device<screen_device>(m_config.m_screen_tag); |
| 778 | |
| 779 | // register for state saving |
| 780 | save_item(NAME(m_ra)); |
| 781 | save_item(NAME(m_sr)); |
| 782 | save_item(NAME(m_mode)); |
| 783 | save_item(NAME(m_de)); |
| 784 | save_item(NAME(m_aw)); |
| 785 | save_item(NAME(m_al)); |
| 786 | save_item(NAME(m_vs)); |
| 787 | save_item(NAME(m_vfp)); |
| 788 | save_item(NAME(m_vbp)); |
| 789 | save_item(NAME(m_hs)); |
| 790 | save_item(NAME(m_hfp)); |
| 791 | save_item(NAME(m_hbp)); |
| 792 | save_item(NAME(m_m)); |
| 793 | save_item(NAME(m_dc)); |
| 794 | save_item(NAME(m_sc)); |
| 795 | save_item(NAME(m_br)); |
| 796 | save_item(NAME(m_lr)); |
| 797 | save_item(NAME(m_ctop)); |
| 798 | save_item(NAME(m_cbot)); |
| 799 | save_item(NAME(m_ead)); |
| 800 | save_item(NAME(m_dad)); |
| 801 | save_item(NAME(m_lad)); |
| 802 | save_item(NAME(m_disp)); |
| 803 | save_item(NAME(m_gchr)); |
| 804 | save_item(NAME(m_mask)); |
| 805 | save_item(NAME(m_pitch)); |
| 806 | } |
| 807 | |
| 808 | |
| 809 | //------------------------------------------------- |
| 810 | // device_reset - device-specific reset |
| 811 | //------------------------------------------------- |
| 812 | |
| 813 | void upd7220_device::device_reset() |
| 814 | { |
| 815 | devcb_call_write_line(&m_out_drq_func, CLEAR_LINE); |
| 816 | } |
| 817 | |
| 818 | |
| 819 | //------------------------------------------------- |
| 820 | // device_timer - handler timer events |
| 821 | //------------------------------------------------- |
| 822 | |
| 823 | void upd7220_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 824 | { |
| 825 | switch (id) |
| 826 | { |
| 827 | case TIMER_HSYNC: |
| 828 | if (param) |
| 829 | { |
| 830 | m_sr |= UPD7220_SR_HBLANK_ACTIVE; |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | m_sr &= ~UPD7220_SR_HBLANK_ACTIVE; |
| 835 | } |
| 836 | |
| 837 | devcb_call_write_line(&m_out_hsync_func, param); |
| 838 | |
| 839 | update_hsync_timer(param); |
| 840 | break; |
| 841 | |
| 842 | case TIMER_VSYNC: |
| 843 | if (param) |
| 844 | { |
| 845 | m_sr |= UPD7220_SR_VSYNC_ACTIVE; |
| 846 | } |
| 847 | else |
| 848 | { |
| 849 | m_sr &= ~UPD7220_SR_VSYNC_ACTIVE; |
| 850 | } |
| 851 | |
| 852 | devcb_call_write_line(&m_out_vsync_func, param); |
| 853 | |
| 854 | update_vsync_timer(param); |
| 855 | break; |
| 856 | |
| 857 | case TIMER_BLANK: |
| 858 | if (param) |
| 859 | { |
| 860 | m_sr |= UPD7220_SR_HBLANK_ACTIVE; |
| 861 | } |
| 862 | else |
| 863 | { |
| 864 | m_sr &= ~UPD7220_SR_HBLANK_ACTIVE; |
| 865 | } |
| 866 | |
| 867 | devcb_call_write_line(&m_out_blank_func, param); |
| 868 | |
| 869 | update_blank_timer(param); |
| 870 | break; |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | |
| 875 | //------------------------------------------------- |
| 876 | // draw_pixel - |
| 877 | //------------------------------------------------- |
| 878 | |
| 879 | void upd7220_device::draw_pixel(int x, int y, UINT16 tile_data) |
| 880 | { |
| 881 | UINT32 addr = (y * m_pitch * 2 + (x >> 3)) & 0x3ffff; |
| 882 | |
| 883 | int dad = x & 0x7; |
| 884 | |
| 885 | if((m_bitmap_mod & 3) == 1) |
| 886 | { |
| 887 | m_vram[addr + m_vram_bank] ^= ((tile_data) & (0x80 >> (dad))); |
| 888 | } |
| 706 | 889 | else |
| 707 | 890 | { |
| 708 | | upd7220->vram[addr + upd7220->vram_bank] &= ~(0x80 >> (dad)); |
| 709 | | upd7220->vram[addr + upd7220->vram_bank] |= ((tile_data) & (0x80 >> (dad))); |
| 891 | m_vram[addr + m_vram_bank] &= ~(0x80 >> (dad)); |
| 892 | m_vram[addr + m_vram_bank] |= ((tile_data) & (0x80 >> (dad))); |
| 710 | 893 | } |
| 711 | 894 | } |
| 712 | 895 | |
| 713 | | static void draw_line(upd7220_t *upd7220,int x,int y) |
| 896 | |
| 897 | //------------------------------------------------- |
| 898 | // draw_line - |
| 899 | //------------------------------------------------- |
| 900 | |
| 901 | void upd7220_device::draw_line(int x, int y) |
| 714 | 902 | { |
| 715 | 903 | int line_size,i; |
| 716 | 904 | const int line_x_dir[8] = { 0, 1, 1, 0, 0,-1,-1, 0}; |
| r11221 | r11222 | |
| 721 | 909 | int line_step = 0; |
| 722 | 910 | UINT8 dot; |
| 723 | 911 | |
| 724 | | line_size = upd7220->figs.dc + 1; |
| 725 | | line_pattern = check_pattern(upd7220,(upd7220->ra[8]) | (upd7220->ra[9]<<8)); |
| 912 | line_size = m_figs.m_dc + 1; |
| 913 | line_pattern = check_pattern((m_ra[8]) | (m_ra[9]<<8)); |
| 726 | 914 | |
| 727 | 915 | for(i = 0;i<line_size;i++) |
| 728 | 916 | { |
| 729 | | line_step = (upd7220->figs.d1 * i); |
| 730 | | line_step/= (upd7220->figs.dc + 1); |
| 917 | line_step = (m_figs.m_d1 * i); |
| 918 | line_step/= (m_figs.m_dc + 1); |
| 731 | 919 | line_step >>= 1; |
| 732 | 920 | dot = ((line_pattern >> (i & 0xf)) & 1) << 7; |
| 733 | | draw_pixel(upd7220,x + (line_step*line_x_step[upd7220->figs.dir]),y + (line_step*line_y_step[upd7220->figs.dir]),dot >> ((x + line_step*line_x_step[upd7220->figs.dir]) & 0x7)); |
| 734 | | x += line_x_dir[upd7220->figs.dir]; |
| 735 | | y += line_y_dir[upd7220->figs.dir]; |
| 921 | draw_pixel(x + (line_step*line_x_step[m_figs.m_dir]),y + (line_step*line_y_step[m_figs.m_dir]),dot >> ((x + line_step*line_x_step[m_figs.m_dir]) & 0x7)); |
| 922 | x += line_x_dir[m_figs.m_dir]; |
| 923 | y += line_y_dir[m_figs.m_dir]; |
| 736 | 924 | } |
| 737 | 925 | |
| 738 | 926 | /* TODO: check me*/ |
| 739 | | x += (line_step*line_x_step[upd7220->figs.dir]); |
| 740 | | y += (line_step*line_y_step[upd7220->figs.dir]); |
| 927 | x += (line_step*line_x_step[m_figs.m_dir]); |
| 928 | y += (line_step*line_y_step[m_figs.m_dir]); |
| 741 | 929 | |
| 742 | | upd7220->ead = (x >> 4) + (y * upd7220->pitch); |
| 743 | | upd7220->dad = x & 0x0f; |
| 930 | m_ead = (x >> 4) + (y * m_pitch); |
| 931 | m_dad = x & 0x0f; |
| 744 | 932 | } |
| 745 | 933 | |
| 746 | | static void draw_rectangle(upd7220_t *upd7220,int x,int y) |
| 934 | |
| 935 | //------------------------------------------------- |
| 936 | // draw_rectangle - |
| 937 | //------------------------------------------------- |
| 938 | |
| 939 | void upd7220_device::draw_rectangle(int x, int y) |
| 747 | 940 | { |
| 748 | 941 | int i; |
| 749 | 942 | const int rect_x_dir[8] = { 0, 1, 0,-1, 1, 1,-1,-1 }; |
| r11221 | r11222 | |
| 752 | 945 | UINT16 line_pattern; |
| 753 | 946 | UINT8 dot; |
| 754 | 947 | |
| 755 | | printf("uPD7220 rectangle check: %d %d %02x %08x\n",x,y,upd7220->figs.dir,upd7220->ead); |
| 948 | logerror("uPD7220 rectangle check: %d %d %02x %08x\n",x,y,m_figs.m_dir,m_ead); |
| 756 | 949 | |
| 757 | | line_pattern = check_pattern(upd7220,(upd7220->ra[8]) | (upd7220->ra[9]<<8)); |
| 758 | | rect_type = (upd7220->figs.dir & 1) << 2; |
| 759 | | rect_dir = rect_type | (((upd7220->figs.dir >> 1) + 0) & 3); |
| 950 | line_pattern = check_pattern((m_ra[8]) | (m_ra[9]<<8)); |
| 951 | rect_type = (m_figs.m_dir & 1) << 2; |
| 952 | rect_dir = rect_type | (((m_figs.m_dir >> 1) + 0) & 3); |
| 760 | 953 | |
| 761 | | for(i = 0;i < upd7220->figs.d;i++) |
| 954 | for(i = 0;i < m_figs.m_d;i++) |
| 762 | 955 | { |
| 763 | | dot = ((line_pattern >> ((i+upd7220->dad) & 0xf)) & 1) << 7; |
| 764 | | draw_pixel(upd7220,x,y,dot >> (x & 0x7)); |
| 956 | dot = ((line_pattern >> ((i+m_dad) & 0xf)) & 1) << 7; |
| 957 | draw_pixel(x,y,dot >> (x & 0x7)); |
| 765 | 958 | x+=rect_x_dir[rect_dir]; |
| 766 | 959 | y+=rect_y_dir[rect_dir]; |
| 767 | 960 | } |
| 768 | 961 | |
| 769 | | rect_dir = rect_type | (((upd7220->figs.dir >> 1) + 1) & 3); |
| 962 | rect_dir = rect_type | (((m_figs.m_dir >> 1) + 1) & 3); |
| 770 | 963 | |
| 771 | | for(i = 0;i < upd7220->figs.d2;i++) |
| 964 | for(i = 0;i < m_figs.m_d2;i++) |
| 772 | 965 | { |
| 773 | | dot = ((line_pattern >> ((i+upd7220->dad) & 0xf)) & 1) << 7; |
| 774 | | draw_pixel(upd7220,x,y,dot >> (x & 0x7)); |
| 966 | dot = ((line_pattern >> ((i+m_dad) & 0xf)) & 1) << 7; |
| 967 | draw_pixel(x,y,dot >> (x & 0x7)); |
| 775 | 968 | x+=rect_x_dir[rect_dir]; |
| 776 | 969 | y+=rect_y_dir[rect_dir]; |
| 777 | 970 | } |
| 778 | 971 | |
| 779 | | rect_dir = rect_type | (((upd7220->figs.dir >> 1) + 2) & 3); |
| 972 | rect_dir = rect_type | (((m_figs.m_dir >> 1) + 2) & 3); |
| 780 | 973 | |
| 781 | | for(i = 0;i < upd7220->figs.d;i++) |
| 974 | for(i = 0;i < m_figs.m_d;i++) |
| 782 | 975 | { |
| 783 | | dot = ((line_pattern >> ((i+upd7220->dad) & 0xf)) & 1) << 7; |
| 784 | | draw_pixel(upd7220,x,y,dot >> (x & 0x7)); |
| 976 | dot = ((line_pattern >> ((i+m_dad) & 0xf)) & 1) << 7; |
| 977 | draw_pixel(x,y,dot >> (x & 0x7)); |
| 785 | 978 | x+=rect_x_dir[rect_dir]; |
| 786 | 979 | y+=rect_y_dir[rect_dir]; |
| 787 | 980 | } |
| 788 | 981 | |
| 789 | | rect_dir = rect_type | (((upd7220->figs.dir >> 1) + 3) & 3); |
| 982 | rect_dir = rect_type | (((m_figs.m_dir >> 1) + 3) & 3); |
| 790 | 983 | |
| 791 | | for(i = 0;i < upd7220->figs.d2;i++) |
| 984 | for(i = 0;i < m_figs.m_d2;i++) |
| 792 | 985 | { |
| 793 | | dot = ((line_pattern >> ((i+upd7220->dad) & 0xf)) & 1) << 7; |
| 794 | | draw_pixel(upd7220,x,y,dot >> (x & 0x7)); |
| 986 | dot = ((line_pattern >> ((i+m_dad) & 0xf)) & 1) << 7; |
| 987 | draw_pixel(x,y,dot >> (x & 0x7)); |
| 795 | 988 | x+=rect_x_dir[rect_dir]; |
| 796 | 989 | y+=rect_y_dir[rect_dir]; |
| 797 | 990 | } |
| 798 | 991 | |
| 799 | | upd7220->ead = (x >> 4) + (y * upd7220->pitch); |
| 800 | | upd7220->dad = x & 0x0f; |
| 992 | m_ead = (x >> 4) + (y * m_pitch); |
| 993 | m_dad = x & 0x0f; |
| 801 | 994 | |
| 802 | 995 | } |
| 803 | 996 | |
| 804 | | /*------------------------------------------------- |
| 805 | | draw_char - put per-pixel VRAM data (charset) |
| 806 | | -------------------------------------------------*/ |
| 807 | 997 | |
| 808 | | static void draw_char(upd7220_t *upd7220,int x,int y) |
| 998 | //------------------------------------------------- |
| 999 | // draw_char - |
| 1000 | //------------------------------------------------- |
| 1001 | |
| 1002 | void upd7220_device::draw_char(int x, int y) |
| 809 | 1003 | { |
| 810 | 1004 | int xi,yi; |
| 811 | 1005 | int xsize,ysize; |
| r11221 | r11222 | |
| 817 | 1011 | { |
| 818 | 1012 | for(xi=0;xi<8;xi++) |
| 819 | 1013 | { |
| 820 | | printf("%d",(upd7220->ra[(yi & 7) | 8] >> xi) & 1); |
| 1014 | printf("%d",(m_ra[(yi & 7) | 8] >> xi) & 1); |
| 821 | 1015 | } |
| 822 | 1016 | printf("\n"); |
| 823 | 1017 | } |
| 824 | 1018 | #endif |
| 825 | 1019 | |
| 826 | | xsize = upd7220->figs.d & 0x3ff; |
| 1020 | xsize = m_figs.m_d & 0x3ff; |
| 827 | 1021 | /* Guess: D has presumably upper bits for ysize, QX-10 relies on this (TODO: check this on any real HW) */ |
| 828 | | ysize = ((upd7220->figs.d & 0x400) + upd7220->figs.dc) + 1; |
| 1022 | ysize = ((m_figs.m_d & 0x400) + m_figs.m_dc) + 1; |
| 829 | 1023 | |
| 830 | 1024 | /* TODO: internal direction, zooming, size stuff bigger than 8, rewrite using draw_pixel function */ |
| 831 | 1025 | for(yi=0;yi<ysize;yi++) |
| 832 | 1026 | { |
| 833 | | switch(upd7220->figs.dir & 7) |
| 1027 | switch(m_figs.m_dir & 7) |
| 834 | 1028 | { |
| 835 | | case 0: tile_data = BITSWAP8(upd7220->ra[((yi) & 7) | 8],0,1,2,3,4,5,6,7); break; // TODO |
| 836 | | case 2: tile_data = BITSWAP8(upd7220->ra[((yi) & 7) | 8],0,1,2,3,4,5,6,7); break; |
| 837 | | case 6: tile_data = BITSWAP8(upd7220->ra[((ysize-1-yi) & 7) | 8],7,6,5,4,3,2,1,0); break; |
| 838 | | default: tile_data = BITSWAP8(upd7220->ra[((yi) & 7) | 8],7,6,5,4,3,2,1,0); |
| 839 | | printf("%d %d %d\n",upd7220->figs.dir,xsize,ysize); |
| 1029 | case 0: tile_data = BITSWAP8(m_ra[((yi) & 7) | 8],0,1,2,3,4,5,6,7); break; // TODO |
| 1030 | case 2: tile_data = BITSWAP8(m_ra[((yi) & 7) | 8],0,1,2,3,4,5,6,7); break; |
| 1031 | case 6: tile_data = BITSWAP8(m_ra[((ysize-1-yi) & 7) | 8],7,6,5,4,3,2,1,0); break; |
| 1032 | default: tile_data = BITSWAP8(m_ra[((yi) & 7) | 8],7,6,5,4,3,2,1,0); |
| 1033 | printf("%d %d %d\n",m_figs.m_dir,xsize,ysize); |
| 840 | 1034 | break; |
| 841 | 1035 | } |
| 842 | 1036 | |
| 843 | 1037 | for(xi=0;xi<xsize;xi++) |
| 844 | 1038 | { |
| 845 | | UINT32 addr = ((y+yi) * upd7220->pitch * 2) + ((x+xi) >> 3); |
| 1039 | UINT32 addr = ((y+yi) * m_pitch * 2) + ((x+xi) >> 3); |
| 846 | 1040 | |
| 847 | | upd7220->vram[(addr + upd7220->vram_bank) & 0x3ffff] &= ~(1 << (xi & 7)); |
| 848 | | upd7220->vram[(addr + upd7220->vram_bank) & 0x3ffff] |= ((tile_data) & (1 << (xi & 7))); |
| 1041 | m_vram[(addr + m_vram_bank) & 0x3ffff] &= ~(1 << (xi & 7)); |
| 1042 | m_vram[(addr + m_vram_bank) & 0x3ffff] |= ((tile_data) & (1 << (xi & 7))); |
| 849 | 1043 | } |
| 850 | 1044 | } |
| 851 | 1045 | |
| 852 | | upd7220->ead = ((x+8*x_dir_dot[upd7220->figs.dir]) >> 4) + ((y+8*y_dir_dot[upd7220->figs.dir]) * upd7220->pitch); |
| 853 | | upd7220->dad = ((x+8*x_dir_dot[upd7220->figs.dir]) & 0xf); |
| 1046 | m_ead = ((x+8*x_dir_dot[m_figs.m_dir]) >> 4) + ((y+8*y_dir_dot[m_figs.m_dir]) * m_pitch); |
| 1047 | m_dad = ((x+8*x_dir_dot[m_figs.m_dir]) & 0xf); |
| 854 | 1048 | } |
| 855 | 1049 | |
| 856 | | /*------------------------------------------------- |
| 857 | | translate_command - translate command byte |
| 858 | | -------------------------------------------------*/ |
| 859 | 1050 | |
| 860 | | static int translate_command(UINT8 data) |
| 1051 | //------------------------------------------------- |
| 1052 | // translate_command - |
| 1053 | //------------------------------------------------- |
| 1054 | |
| 1055 | int upd7220_device::translate_command(UINT8 data) |
| 861 | 1056 | { |
| 862 | 1057 | int command = COMMAND_INVALID; |
| 863 | 1058 | |
| r11221 | r11222 | |
| 901 | 1096 | return command; |
| 902 | 1097 | } |
| 903 | 1098 | |
| 904 | | /*------------------------------------------------- |
| 905 | | process_fifo - process a single byte in FIFO |
| 906 | | -------------------------------------------------*/ |
| 907 | 1099 | |
| 908 | | static void process_fifo(device_t *device) |
| 1100 | //------------------------------------------------- |
| 1101 | // process_fifo - |
| 1102 | //------------------------------------------------- |
| 1103 | |
| 1104 | void upd7220_device::process_fifo() |
| 909 | 1105 | { |
| 910 | | upd7220_t *upd7220 = get_safe_token(device); |
| 911 | 1106 | UINT8 data; |
| 912 | 1107 | int flag; |
| 913 | 1108 | |
| 914 | | dequeue(upd7220, &data, &flag); |
| 1109 | dequeue(&data, &flag); |
| 915 | 1110 | |
| 916 | 1111 | if (flag == FIFO_COMMAND) |
| 917 | 1112 | { |
| 918 | | upd7220->cr = data; |
| 919 | | upd7220->param_ptr = 1; |
| 1113 | m_cr = data; |
| 1114 | m_param_ptr = 1; |
| 920 | 1115 | } |
| 921 | 1116 | else |
| 922 | 1117 | { |
| 923 | | upd7220->pr[upd7220->param_ptr] = data; |
| 924 | | upd7220->param_ptr++; |
| 1118 | m_pr[m_param_ptr] = data; |
| 1119 | m_param_ptr++; |
| 925 | 1120 | } |
| 926 | 1121 | |
| 927 | | switch (translate_command(upd7220->cr)) |
| 1122 | switch (translate_command(m_cr)) |
| 928 | 1123 | { |
| 929 | 1124 | case COMMAND_INVALID: |
| 930 | | printf("uPD7220 '%s' Invalid Command Byte %02x\n", device->tag(), upd7220->cr); |
| 1125 | printf("uPD7220 '%s' Invalid Command Byte %02x\n", tag(), m_cr); |
| 931 | 1126 | break; |
| 932 | 1127 | |
| 933 | 1128 | case COMMAND_5A: |
| 934 | | if (upd7220->param_ptr == 4) |
| 935 | | printf("uPD7220 '%s' Undocumented Command 0x5A Executed %02x %02x %02x\n", device->tag(),upd7220->pr[1],upd7220->pr[2],upd7220->pr[3] ); |
| 1129 | if (m_param_ptr == 4) |
| 1130 | printf("uPD7220 '%s' Undocumented Command 0x5A Executed %02x %02x %02x\n", tag(),m_pr[1],m_pr[2],m_pr[3] ); |
| 936 | 1131 | break; |
| 937 | 1132 | |
| 938 | 1133 | case COMMAND_RESET: /* reset */ |
| 939 | | switch (upd7220->param_ptr) |
| 1134 | switch (m_param_ptr) |
| 940 | 1135 | { |
| 941 | 1136 | case 0: |
| 942 | | if (LOG) logerror("uPD7220 '%s' RESET\n", device->tag()); |
| 1137 | if (LOG) logerror("uPD7220 '%s' RESET\n", tag()); |
| 943 | 1138 | |
| 944 | | upd7220->de = 0; |
| 945 | | upd7220->ra[0] = upd7220->ra[1] = upd7220->ra[2] = 0; |
| 946 | | upd7220->ra[3] = 0x19; |
| 947 | | upd7220->ead = 0; |
| 948 | | upd7220->dad = 0; |
| 949 | | upd7220->mask = 0; |
| 1139 | m_de = 0; |
| 1140 | m_ra[0] = m_ra[1] = m_ra[2] = 0; |
| 1141 | m_ra[3] = 0x19; |
| 1142 | m_ead = 0; |
| 1143 | m_dad = 0; |
| 1144 | m_mask = 0; |
| 950 | 1145 | break; |
| 951 | 1146 | |
| 952 | 1147 | case 9: |
| 953 | | upd7220->mode = upd7220->pr[1]; |
| 954 | | upd7220->aw = upd7220->pr[2] + 2; |
| 955 | | upd7220->hs = (upd7220->pr[3] & 0x1f) + 1; |
| 956 | | upd7220->vs = ((upd7220->pr[4] & 0x03) << 3) | (upd7220->pr[3] >> 5); |
| 957 | | upd7220->hfp = (upd7220->pr[4] >> 2) + 1; |
| 958 | | upd7220->hbp = (upd7220->pr[5] & 0x3f) + 1; |
| 959 | | upd7220->vfp = upd7220->pr[6] & 0x3f; |
| 960 | | upd7220->al = ((upd7220->pr[8] & 0x03) << 8) | upd7220->pr[7]; |
| 961 | | upd7220->vbp = upd7220->pr[8] >> 2; |
| 1148 | m_mode = m_pr[1]; |
| 1149 | m_aw = m_pr[2] + 2; |
| 1150 | m_hs = (m_pr[3] & 0x1f) + 1; |
| 1151 | m_vs = ((m_pr[4] & 0x03) << 3) | (m_pr[3] >> 5); |
| 1152 | m_hfp = (m_pr[4] >> 2) + 1; |
| 1153 | m_hbp = (m_pr[5] & 0x3f) + 1; |
| 1154 | m_vfp = m_pr[6] & 0x3f; |
| 1155 | m_al = ((m_pr[8] & 0x03) << 8) | m_pr[7]; |
| 1156 | m_vbp = m_pr[8] >> 2; |
| 962 | 1157 | |
| 963 | | upd7220->pitch = upd7220->aw; |
| 1158 | m_pitch = m_aw; |
| 964 | 1159 | |
| 965 | 1160 | if (LOG) |
| 966 | 1161 | { |
| 967 | | logerror("uPD7220 '%s' Mode: %02x\n", device->tag(), upd7220->mode); |
| 968 | | logerror("uPD7220 '%s' AW: %u\n", device->tag(), upd7220->aw); |
| 969 | | logerror("uPD7220 '%s' HS: %u\n", device->tag(), upd7220->hs); |
| 970 | | logerror("uPD7220 '%s' VS: %u\n", device->tag(), upd7220->vs); |
| 971 | | logerror("uPD7220 '%s' HFP: %u\n", device->tag(), upd7220->hfp); |
| 972 | | logerror("uPD7220 '%s' HBP: %u\n", device->tag(), upd7220->hbp); |
| 973 | | logerror("uPD7220 '%s' VFP: %u\n", device->tag(), upd7220->vfp); |
| 974 | | logerror("uPD7220 '%s' AL: %u\n", device->tag(), upd7220->al); |
| 975 | | logerror("uPD7220 '%s' VBP: %u\n", device->tag(), upd7220->vbp); |
| 976 | | logerror("uPD7220 '%s' PITCH: %u\n", device->tag(), upd7220->pitch); |
| 1162 | logerror("uPD7220 '%s' Mode: %02x\n", tag(), m_mode); |
| 1163 | logerror("uPD7220 '%s' AW: %u\n", tag(), m_aw); |
| 1164 | logerror("uPD7220 '%s' HS: %u\n", tag(), m_hs); |
| 1165 | logerror("uPD7220 '%s' VS: %u\n", tag(), m_vs); |
| 1166 | logerror("uPD7220 '%s' HFP: %u\n", tag(), m_hfp); |
| 1167 | logerror("uPD7220 '%s' HBP: %u\n", tag(), m_hbp); |
| 1168 | logerror("uPD7220 '%s' VFP: %u\n", tag(), m_vfp); |
| 1169 | logerror("uPD7220 '%s' AL: %u\n", tag(), m_al); |
| 1170 | logerror("uPD7220 '%s' VBP: %u\n", tag(), m_vbp); |
| 1171 | logerror("uPD7220 '%s' PITCH: %u\n", tag(), m_pitch); |
| 977 | 1172 | } |
| 978 | 1173 | |
| 979 | | recompute_parameters(device); |
| 1174 | recompute_parameters(); |
| 980 | 1175 | break; |
| 981 | 1176 | } |
| 982 | 1177 | break; |
| 983 | 1178 | |
| 984 | 1179 | case COMMAND_SYNC: /* sync format specify */ |
| 985 | | if (upd7220->param_ptr == 9) |
| 1180 | if (m_param_ptr == 9) |
| 986 | 1181 | { |
| 987 | | upd7220->mode = upd7220->pr[1]; |
| 988 | | upd7220->aw = upd7220->pr[2] + 2; |
| 989 | | upd7220->hs = (upd7220->pr[3] & 0x1f) + 1; |
| 990 | | upd7220->vs = ((upd7220->pr[4] & 0x03) << 3) | (upd7220->pr[3] >> 5); |
| 991 | | upd7220->hfp = (upd7220->pr[4] >> 2) + 1; |
| 992 | | upd7220->hbp = (upd7220->pr[5] & 0x3f) + 1; |
| 993 | | upd7220->vfp = upd7220->pr[6] & 0x3f; |
| 994 | | upd7220->al = ((upd7220->pr[8] & 0x03) << 8) | upd7220->pr[7]; |
| 995 | | upd7220->vbp = upd7220->pr[8] >> 2; |
| 1182 | m_mode = m_pr[1]; |
| 1183 | m_aw = m_pr[2] + 2; |
| 1184 | m_hs = (m_pr[3] & 0x1f) + 1; |
| 1185 | m_vs = ((m_pr[4] & 0x03) << 3) | (m_pr[3] >> 5); |
| 1186 | m_hfp = (m_pr[4] >> 2) + 1; |
| 1187 | m_hbp = (m_pr[5] & 0x3f) + 1; |
| 1188 | m_vfp = m_pr[6] & 0x3f; |
| 1189 | m_al = ((m_pr[8] & 0x03) << 8) | m_pr[7]; |
| 1190 | m_vbp = m_pr[8] >> 2; |
| 996 | 1191 | |
| 997 | | upd7220->pitch = upd7220->aw; |
| 1192 | m_pitch = m_aw; |
| 998 | 1193 | |
| 999 | 1194 | if (LOG) |
| 1000 | 1195 | { |
| 1001 | | logerror("uPD7220 '%s' Mode: %02x\n", device->tag(), upd7220->mode); |
| 1002 | | logerror("uPD7220 '%s' AW: %u\n", device->tag(), upd7220->aw); |
| 1003 | | logerror("uPD7220 '%s' HS: %u\n", device->tag(), upd7220->hs); |
| 1004 | | logerror("uPD7220 '%s' VS: %u\n", device->tag(), upd7220->vs); |
| 1005 | | logerror("uPD7220 '%s' HFP: %u\n", device->tag(), upd7220->hfp); |
| 1006 | | logerror("uPD7220 '%s' HBP: %u\n", device->tag(), upd7220->hbp); |
| 1007 | | logerror("uPD7220 '%s' VFP: %u\n", device->tag(), upd7220->vfp); |
| 1008 | | logerror("uPD7220 '%s' AL: %u\n", device->tag(), upd7220->al); |
| 1009 | | logerror("uPD7220 '%s' VBP: %u\n", device->tag(), upd7220->vbp); |
| 1010 | | logerror("uPD7220 '%s' PITCH: %u\n", device->tag(), upd7220->pitch); |
| 1196 | logerror("uPD7220 '%s' Mode: %02x\n", tag(), m_mode); |
| 1197 | logerror("uPD7220 '%s' AW: %u\n", tag(), m_aw); |
| 1198 | logerror("uPD7220 '%s' HS: %u\n", tag(), m_hs); |
| 1199 | logerror("uPD7220 '%s' VS: %u\n", tag(), m_vs); |
| 1200 | logerror("uPD7220 '%s' HFP: %u\n", tag(), m_hfp); |
| 1201 | logerror("uPD7220 '%s' HBP: %u\n", tag(), m_hbp); |
| 1202 | logerror("uPD7220 '%s' VFP: %u\n", tag(), m_vfp); |
| 1203 | logerror("uPD7220 '%s' AL: %u\n", tag(), m_al); |
| 1204 | logerror("uPD7220 '%s' VBP: %u\n", tag(), m_vbp); |
| 1205 | logerror("uPD7220 '%s' PITCH: %u\n", tag(), m_pitch); |
| 1011 | 1206 | } |
| 1012 | 1207 | |
| 1013 | | recompute_parameters(device); |
| 1208 | recompute_parameters(); |
| 1014 | 1209 | } |
| 1015 | 1210 | break; |
| 1016 | 1211 | |
| 1017 | 1212 | case COMMAND_VSYNC: /* vertical sync mode */ |
| 1018 | | upd7220->m = upd7220->cr & 0x01; |
| 1213 | m_m = m_cr & 0x01; |
| 1019 | 1214 | |
| 1020 | | if (LOG) logerror("uPD7220 '%s' M: %u\n", device->tag(), upd7220->m); |
| 1215 | if (LOG) logerror("uPD7220 '%s' M: %u\n", tag(), m_m); |
| 1021 | 1216 | |
| 1022 | | recompute_parameters(device); |
| 1217 | recompute_parameters(); |
| 1023 | 1218 | break; |
| 1024 | 1219 | |
| 1025 | 1220 | case COMMAND_CCHAR: /* cursor & character characteristics */ |
| 1026 | | if(upd7220->param_ptr == 2) |
| 1221 | if(m_param_ptr == 2) |
| 1027 | 1222 | { |
| 1028 | | upd7220->lr = (upd7220->pr[1] & 0x1f) + 1; |
| 1029 | | upd7220->dc = BIT(upd7220->pr[1], 7); |
| 1223 | m_lr = (m_pr[1] & 0x1f) + 1; |
| 1224 | m_dc = BIT(m_pr[1], 7); |
| 1225 | |
| 1226 | if (LOG) |
| 1227 | { |
| 1228 | logerror("uPD7220 '%s' LR: %u\n", tag(), m_lr); |
| 1229 | logerror("uPD7220 '%s' DC: %u\n", tag(), m_dc); |
| 1230 | } |
| 1030 | 1231 | } |
| 1031 | 1232 | |
| 1032 | | if(upd7220->param_ptr == 3) |
| 1233 | if(m_param_ptr == 3) |
| 1033 | 1234 | { |
| 1034 | | upd7220->ctop = upd7220->pr[2] & 0x1f; |
| 1035 | | upd7220->sc = BIT(upd7220->pr[2], 5); |
| 1235 | m_ctop = m_pr[2] & 0x1f; |
| 1236 | m_sc = BIT(m_pr[2], 5); |
| 1237 | |
| 1238 | if (LOG) |
| 1239 | { |
| 1240 | logerror("uPD7220 '%s' CTOP: %u\n", tag(), m_ctop); |
| 1241 | logerror("uPD7220 '%s' SC: %u\n", tag(), m_sc); |
| 1242 | } |
| 1036 | 1243 | } |
| 1037 | 1244 | |
| 1038 | | if(upd7220->param_ptr == 4) |
| 1245 | if(m_param_ptr == 4) |
| 1039 | 1246 | { |
| 1040 | | upd7220->br = ((upd7220->pr[3] & 0x07) << 2) | (upd7220->pr[2] >> 6); |
| 1041 | | upd7220->cbot = upd7220->pr[3] >> 3; |
| 1042 | | } |
| 1247 | m_br = ((m_pr[3] & 0x07) << 2) | (m_pr[2] >> 6); |
| 1248 | m_cbot = m_pr[3] >> 3; |
| 1043 | 1249 | |
| 1044 | | if (0) |
| 1045 | | { |
| 1046 | | logerror("uPD7220 '%s' LR: %u\n", device->tag(), upd7220->lr); |
| 1047 | | logerror("uPD7220 '%s' DC: %u\n", device->tag(), upd7220->dc); |
| 1048 | | logerror("uPD7220 '%s' CTOP: %u\n", device->tag(), upd7220->ctop); |
| 1049 | | logerror("uPD7220 '%s' SC: %u\n", device->tag(), upd7220->sc); |
| 1050 | | logerror("uPD7220 '%s' BR: %u\n", device->tag(), upd7220->br); |
| 1051 | | logerror("uPD7220 '%s' CBOT: %u\n", device->tag(), upd7220->cbot); |
| 1250 | if (LOG) |
| 1251 | { |
| 1252 | logerror("uPD7220 '%s' BR: %u\n", tag(), m_br); |
| 1253 | logerror("uPD7220 '%s' CBOT: %u\n", tag(), m_cbot); |
| 1254 | } |
| 1052 | 1255 | } |
| 1053 | 1256 | break; |
| 1054 | 1257 | |
| 1055 | 1258 | case COMMAND_START: /* start display & end idle mode */ |
| 1056 | | upd7220->de = 1; |
| 1259 | m_de = 1; |
| 1057 | 1260 | |
| 1058 | | if (LOG) logerror("uPD7220 '%s' DE: 1\n", device->tag()); |
| 1261 | if (LOG) logerror("uPD7220 '%s' DE: 1\n", tag()); |
| 1059 | 1262 | break; |
| 1060 | 1263 | |
| 1061 | 1264 | case COMMAND_BCTRL: /* display blanking control */ |
| 1062 | | upd7220->de = upd7220->cr & 0x01; |
| 1265 | m_de = m_cr & 0x01; |
| 1063 | 1266 | |
| 1064 | | if (LOG) logerror("uPD7220 '%s' DE: %u\n", device->tag(), upd7220->de); |
| 1267 | if (LOG) logerror("uPD7220 '%s' DE: %u\n", tag(), m_de); |
| 1065 | 1268 | break; |
| 1066 | 1269 | |
| 1067 | 1270 | case COMMAND_ZOOM: /* zoom factors specify */ |
| 1068 | 1271 | if (flag == FIFO_PARAMETER) |
| 1069 | 1272 | { |
| 1070 | | upd7220->gchr = upd7220->pr[1] & 0x0f; |
| 1071 | | upd7220->disp = upd7220->pr[1] >> 4; |
| 1273 | m_gchr = m_pr[1] & 0x0f; |
| 1274 | m_disp = m_pr[1] >> 4; |
| 1072 | 1275 | |
| 1073 | | if (LOG) logerror("uPD7220 '%s' GCHR: %01x\n", device->tag(), upd7220->gchr); |
| 1074 | | if (LOG) logerror("uPD7220 '%s' DISP: %01x\n", device->tag(), upd7220->disp); |
| 1276 | if (LOG) logerror("uPD7220 '%s' GCHR: %01x\n", tag(), m_gchr); |
| 1277 | if (LOG) logerror("uPD7220 '%s' DISP: %01x\n", tag(), m_disp); |
| 1075 | 1278 | } |
| 1076 | 1279 | break; |
| 1077 | 1280 | |
| 1078 | 1281 | case COMMAND_CURS: /* cursor position specify */ |
| 1079 | | if (upd7220->param_ptr >= 3) |
| 1282 | if (m_param_ptr >= 3) |
| 1080 | 1283 | { |
| 1081 | | UINT8 upper_addr; |
| 1284 | UINT8 upper_addr = (m_param_ptr == 3) ? 0 : (m_pr[3] & 0x03); |
| 1082 | 1285 | |
| 1083 | | upper_addr = (upd7220->param_ptr == 3) ? 0 : (upd7220->pr[3] & 0x03); |
| 1286 | m_ead = (upper_addr << 16) | (m_pr[2] << 8) | m_pr[1]; |
| 1084 | 1287 | |
| 1085 | | upd7220->ead = (upper_addr << 16) | (upd7220->pr[2] << 8) | upd7220->pr[1]; |
| 1288 | if (LOG) logerror("uPD7220 '%s' EAD: %06x\n", tag(), m_ead); |
| 1086 | 1289 | |
| 1087 | | if (LOG) logerror("uPD7220 '%s' EAD: %06x\n", device->tag(), upd7220->ead); |
| 1088 | | |
| 1089 | | if(upd7220->param_ptr == 4) |
| 1290 | if(m_param_ptr == 4) |
| 1090 | 1291 | { |
| 1091 | | upd7220->dad = upd7220->pr[3] >> 4; |
| 1092 | | if (LOG) logerror("uPD7220 '%s' DAD: %01x\n", device->tag(), upd7220->dad); |
| 1292 | m_dad = m_pr[3] >> 4; |
| 1293 | if (LOG) logerror("uPD7220 '%s' DAD: %01x\n", tag(), m_dad); |
| 1093 | 1294 | } |
| 1094 | 1295 | } |
| 1095 | 1296 | break; |
| r11221 | r11222 | |
| 1097 | 1298 | case COMMAND_PRAM: /* parameter RAM load */ |
| 1098 | 1299 | if (flag == FIFO_COMMAND) |
| 1099 | 1300 | { |
| 1100 | | upd7220->ra_addr = upd7220->cr & 0x0f; |
| 1301 | m_ra_addr = m_cr & 0x0f; |
| 1101 | 1302 | } |
| 1102 | 1303 | else |
| 1103 | 1304 | { |
| 1104 | | if (upd7220->ra_addr < 16) |
| 1305 | if (m_ra_addr < 16) |
| 1105 | 1306 | { |
| 1106 | | if (LOG) logerror("uPD7220 '%s' RA%u: %02x\n", device->tag(), upd7220->ra_addr, data); |
| 1307 | if (LOG) logerror("uPD7220 '%s' RA%u: %02x\n", tag(), m_ra_addr, data); |
| 1107 | 1308 | |
| 1108 | | upd7220->ra[upd7220->ra_addr] = data; |
| 1109 | | upd7220->ra_addr++; |
| 1309 | m_ra[m_ra_addr] = data; |
| 1310 | m_ra_addr++; |
| 1110 | 1311 | } |
| 1111 | 1312 | |
| 1112 | | upd7220->param_ptr = 0; |
| 1313 | m_param_ptr = 0; |
| 1113 | 1314 | } |
| 1114 | 1315 | break; |
| 1115 | 1316 | |
| 1116 | 1317 | case COMMAND_PITCH: /* pitch specification */ |
| 1117 | 1318 | if (flag == FIFO_PARAMETER) |
| 1118 | 1319 | { |
| 1119 | | upd7220->pitch = data; |
| 1320 | m_pitch = data; |
| 1120 | 1321 | |
| 1121 | | if (LOG) logerror("uPD7220 '%s' PITCH: %u\n", device->tag(), upd7220->pitch); |
| 1322 | if (LOG) logerror("uPD7220 '%s' PITCH: %u\n", tag(), m_pitch); |
| 1122 | 1323 | } |
| 1123 | 1324 | break; |
| 1124 | 1325 | |
| 1125 | 1326 | case COMMAND_WDAT: /* write data into display memory */ |
| 1126 | | upd7220->bitmap_mod = upd7220->cr & 3; |
| 1327 | m_bitmap_mod = m_cr & 3; |
| 1127 | 1328 | |
| 1128 | | if (upd7220->param_ptr == 3 || (upd7220->param_ptr == 2 && upd7220->cr & 0x10)) |
| 1329 | if (m_param_ptr == 3 || (m_param_ptr == 2 && m_cr & 0x10)) |
| 1129 | 1330 | { |
| 1130 | | //printf("%02x = %02x %02x (%c) %04x\n",upd7220->cr,upd7220->pr[2],upd7220->pr[1],upd7220->pr[1],EAD); |
| 1131 | | fifo_set_direction(upd7220, FIFO_WRITE); |
| 1331 | //printf("%02x = %02x %02x (%c) %04x\n",m_cr,m_pr[2],m_pr[1],m_pr[1],EAD); |
| 1332 | fifo_set_direction(FIFO_WRITE); |
| 1132 | 1333 | |
| 1133 | | write_vram(upd7220,(upd7220->cr & 0x18) >> 3,upd7220->cr & 3); |
| 1134 | | reset_figs_param(upd7220); |
| 1135 | | upd7220->param_ptr = 1; |
| 1334 | write_vram((m_cr & 0x18) >> 3,m_cr & 3); |
| 1335 | reset_figs_param(); |
| 1336 | m_param_ptr = 1; |
| 1136 | 1337 | } |
| 1137 | 1338 | break; |
| 1138 | 1339 | |
| 1139 | 1340 | case COMMAND_MASK: /* mask register load */ |
| 1140 | | if (upd7220->param_ptr == 3) |
| 1341 | if (m_param_ptr == 3) |
| 1141 | 1342 | { |
| 1142 | | upd7220->mask = (upd7220->pr[2] << 8) | upd7220->pr[1]; |
| 1343 | m_mask = (m_pr[2] << 8) | m_pr[1]; |
| 1143 | 1344 | |
| 1144 | | if (LOG) logerror("uPD7220 '%s' MASK: %04x\n", device->tag(), upd7220->mask); |
| 1345 | if (LOG) logerror("uPD7220 '%s' MASK: %04x\n", tag(), m_mask); |
| 1145 | 1346 | } |
| 1146 | 1347 | break; |
| 1147 | 1348 | |
| 1148 | 1349 | case COMMAND_FIGS: /* figure drawing parameters specify */ |
| 1149 | | if (upd7220->param_ptr == 2) |
| 1350 | if (m_param_ptr == 2) |
| 1150 | 1351 | { |
| 1151 | | upd7220->figs.dir = upd7220->pr[1] & 0x7; |
| 1152 | | upd7220->figs.figure_type = (upd7220->pr[1] & 0xf8) >> 3; |
| 1352 | m_figs.m_dir = m_pr[1] & 0x7; |
| 1353 | m_figs.m_figure_type = (m_pr[1] & 0xf8) >> 3; |
| 1153 | 1354 | |
| 1154 | | //if(upd7220->figs.dir != 2) |
| 1155 | | // printf("DIR %02x\n",upd7220->pr[1]); |
| 1355 | //if(m_figs.m_dir != 2) |
| 1356 | // printf("DIR %02x\n",m_pr[1]); |
| 1156 | 1357 | } |
| 1157 | 1358 | |
| 1158 | | if (upd7220->param_ptr == 4) |
| 1159 | | upd7220->figs.dc = (upd7220->pr[2]) | ((upd7220->pr[3] & 0x3f) << 8); |
| 1359 | if (m_param_ptr == 4) |
| 1360 | m_figs.m_dc = (m_pr[2]) | ((m_pr[3] & 0x3f) << 8); |
| 1160 | 1361 | |
| 1161 | | if (upd7220->param_ptr == 6) |
| 1162 | | upd7220->figs.d = (upd7220->pr[4]) | ((upd7220->pr[5] & 0x3f) << 8); |
| 1362 | if (m_param_ptr == 6) |
| 1363 | m_figs.m_d = (m_pr[4]) | ((m_pr[5] & 0x3f) << 8); |
| 1163 | 1364 | |
| 1164 | | if (upd7220->param_ptr == 8) |
| 1165 | | upd7220->figs.d2 = (upd7220->pr[6]) | ((upd7220->pr[7] & 0x3f) << 8); |
| 1365 | if (m_param_ptr == 8) |
| 1366 | m_figs.m_d2 = (m_pr[6]) | ((m_pr[7] & 0x3f) << 8); |
| 1166 | 1367 | |
| 1167 | | if (upd7220->param_ptr == 10) |
| 1168 | | upd7220->figs.d1 = (upd7220->pr[8]) | ((upd7220->pr[9] & 0x3f) << 8); |
| 1368 | if (m_param_ptr == 10) |
| 1369 | m_figs.m_d1 = (m_pr[8]) | ((m_pr[9] & 0x3f) << 8); |
| 1169 | 1370 | |
| 1170 | | if (upd7220->param_ptr == 12) |
| 1171 | | upd7220->figs.dm = (upd7220->pr[10]) | ((upd7220->pr[11] & 0x3f) << 8); |
| 1371 | if (m_param_ptr == 12) |
| 1372 | m_figs.m_dm = (m_pr[10]) | ((m_pr[11] & 0x3f) << 8); |
| 1172 | 1373 | |
| 1173 | 1374 | break; |
| 1174 | 1375 | |
| 1175 | 1376 | case COMMAND_FIGD: /* figure draw start */ |
| 1176 | | if(upd7220->figs.figure_type == 0) |
| 1377 | if(m_figs.m_figure_type == 0) |
| 1177 | 1378 | { |
| 1178 | | UINT16 line_pattern = check_pattern(upd7220,(upd7220->ra[8]) | (upd7220->ra[9]<<8)); |
| 1379 | UINT16 line_pattern = check_pattern((m_ra[8]) | (m_ra[9]<<8)); |
| 1179 | 1380 | UINT8 dot = ((line_pattern >> (0 & 0xf)) & 1) << 7; |
| 1180 | 1381 | |
| 1181 | | draw_pixel(upd7220,((upd7220->ead % upd7220->pitch) << 4) | (upd7220->dad & 0xf),(upd7220->ead / upd7220->pitch),dot); |
| 1382 | draw_pixel(((m_ead % m_pitch) << 4) | (m_dad & 0xf),(m_ead / m_pitch),dot); |
| 1182 | 1383 | } |
| 1183 | | else if(upd7220->figs.figure_type == 1) |
| 1184 | | draw_line(upd7220,((upd7220->ead % upd7220->pitch) << 4) | (upd7220->dad & 0xf),(upd7220->ead / upd7220->pitch)); |
| 1185 | | else if(upd7220->figs.figure_type == 8) |
| 1186 | | draw_rectangle(upd7220,((upd7220->ead % upd7220->pitch) << 4) | (upd7220->dad & 0xf),(upd7220->ead / upd7220->pitch)); |
| 1384 | else if(m_figs.m_figure_type == 1) |
| 1385 | draw_line(((m_ead % m_pitch) << 4) | (m_dad & 0xf),(m_ead / m_pitch)); |
| 1386 | else if(m_figs.m_figure_type == 8) |
| 1387 | draw_rectangle(((m_ead % m_pitch) << 4) | (m_dad & 0xf),(m_ead / m_pitch)); |
| 1187 | 1388 | else |
| 1188 | | printf("uPD7220 '%s' Unimplemented command FIGD %02x\n", device->tag(),upd7220->figs.figure_type); |
| 1389 | printf("uPD7220 '%s' Unimplemented command FIGD %02x\n", tag(),m_figs.m_figure_type); |
| 1189 | 1390 | |
| 1190 | | reset_figs_param(upd7220); |
| 1191 | | upd7220->sr |= UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1391 | reset_figs_param(); |
| 1392 | m_sr |= UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1192 | 1393 | break; |
| 1193 | 1394 | |
| 1194 | 1395 | case COMMAND_GCHRD: /* graphics character draw and area filling start */ |
| 1195 | | if(upd7220->figs.figure_type == 2) |
| 1196 | | draw_char(upd7220,((upd7220->ead % upd7220->pitch) << 4) | (upd7220->dad & 0xf),(upd7220->ead / upd7220->pitch)); |
| 1396 | if(m_figs.m_figure_type == 2) |
| 1397 | draw_char(((m_ead % m_pitch) << 4) | (m_dad & 0xf),(m_ead / m_pitch)); |
| 1197 | 1398 | else |
| 1198 | | printf("uPD7220 '%s' Unimplemented command GCHRD %02x\n", device->tag(),upd7220->figs.figure_type); |
| 1399 | printf("uPD7220 '%s' Unimplemented command GCHRD %02x\n", tag(),m_figs.m_figure_type); |
| 1199 | 1400 | |
| 1200 | | reset_figs_param(upd7220); |
| 1201 | | upd7220->sr |= UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1401 | reset_figs_param(); |
| 1402 | m_sr |= UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1202 | 1403 | break; |
| 1203 | 1404 | |
| 1204 | 1405 | case COMMAND_RDAT: /* read data from display memory */ |
| 1205 | | fifo_set_direction(upd7220, FIFO_READ); |
| 1406 | fifo_set_direction(FIFO_READ); |
| 1206 | 1407 | |
| 1207 | | read_vram(upd7220,(upd7220->cr & 0x18) >> 3,upd7220->cr & 3); |
| 1208 | | reset_figs_param(upd7220); |
| 1408 | read_vram((m_cr & 0x18) >> 3,m_cr & 3); |
| 1409 | reset_figs_param(); |
| 1209 | 1410 | |
| 1210 | | upd7220->sr |= UPD7220_SR_DATA_READY; |
| 1411 | m_sr |= UPD7220_SR_DATA_READY; |
| 1211 | 1412 | break; |
| 1212 | 1413 | |
| 1213 | 1414 | case COMMAND_CURD: /* cursor address read */ |
| 1214 | | fifo_set_direction(upd7220, FIFO_READ); |
| 1415 | fifo_set_direction(FIFO_READ); |
| 1215 | 1416 | |
| 1216 | | queue(upd7220, upd7220->ead & 0xff, 0); |
| 1217 | | queue(upd7220, (upd7220->ead >> 8) & 0xff, 0); |
| 1218 | | queue(upd7220, upd7220->ead >> 16, 0); |
| 1219 | | queue(upd7220, upd7220->dad & 0xff, 0); |
| 1220 | | queue(upd7220, upd7220->dad >> 8, 0); |
| 1417 | queue(m_ead & 0xff, 0); |
| 1418 | queue((m_ead >> 8) & 0xff, 0); |
| 1419 | queue(m_ead >> 16, 0); |
| 1420 | queue(m_dad & 0xff, 0); |
| 1421 | queue(m_dad >> 8, 0); |
| 1221 | 1422 | |
| 1222 | | upd7220->sr |= UPD7220_SR_DATA_READY; |
| 1423 | m_sr |= UPD7220_SR_DATA_READY; |
| 1223 | 1424 | break; |
| 1224 | 1425 | |
| 1225 | 1426 | case COMMAND_LPRD: /* light pen address read */ |
| 1226 | | fifo_set_direction(upd7220, FIFO_READ); |
| 1427 | fifo_set_direction(FIFO_READ); |
| 1227 | 1428 | |
| 1228 | | queue(upd7220, upd7220->lad & 0xff, 0); |
| 1229 | | queue(upd7220, (upd7220->lad >> 8) & 0xff, 0); |
| 1230 | | queue(upd7220, upd7220->lad >> 16, 0); |
| 1429 | queue(m_lad & 0xff, 0); |
| 1430 | queue((m_lad >> 8) & 0xff, 0); |
| 1431 | queue(m_lad >> 16, 0); |
| 1231 | 1432 | |
| 1232 | | upd7220->sr |= UPD7220_SR_DATA_READY; |
| 1233 | | upd7220->sr &= ~UPD7220_SR_LIGHT_PEN_DETECT; |
| 1433 | m_sr |= UPD7220_SR_DATA_READY; |
| 1434 | m_sr &= ~UPD7220_SR_LIGHT_PEN_DETECT; |
| 1234 | 1435 | break; |
| 1235 | 1436 | |
| 1236 | 1437 | case COMMAND_DMAR: /* DMA read request */ |
| 1237 | | printf("uPD7220 '%s' Unimplemented command DMAR\n", device->tag()); |
| 1438 | printf("uPD7220 '%s' Unimplemented command DMAR\n", tag()); |
| 1238 | 1439 | break; |
| 1239 | 1440 | |
| 1240 | 1441 | case COMMAND_DMAW: /* DMA write request */ |
| 1241 | | printf("uPD7220 '%s' Unimplemented command DMAW\n", device->tag()); |
| 1442 | printf("uPD7220 '%s' Unimplemented command DMAW\n", tag()); |
| 1242 | 1443 | break; |
| 1243 | 1444 | } |
| 1244 | 1445 | } |
| 1245 | 1446 | |
| 1246 | | /*------------------------------------------------- |
| 1247 | | upd7220_r - register read |
| 1248 | | -------------------------------------------------*/ |
| 1249 | 1447 | |
| 1250 | | READ8_DEVICE_HANDLER( upd7220_r ) |
| 1448 | //------------------------------------------------- |
| 1449 | // read - |
| 1450 | //------------------------------------------------- |
| 1451 | |
| 1452 | READ8_MEMBER( upd7220_device::read ) |
| 1251 | 1453 | { |
| 1252 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1253 | | |
| 1254 | 1454 | UINT8 data; |
| 1255 | 1455 | |
| 1256 | 1456 | if (offset & 1) |
| 1257 | 1457 | { |
| 1258 | 1458 | /* FIFO read */ |
| 1259 | 1459 | int flag; |
| 1260 | | fifo_set_direction(upd7220, FIFO_READ); |
| 1261 | | dequeue(upd7220, &data, &flag); |
| 1460 | fifo_set_direction(FIFO_READ); |
| 1461 | dequeue(&data, &flag); |
| 1262 | 1462 | } |
| 1263 | 1463 | else |
| 1264 | 1464 | { |
| 1265 | 1465 | /* status register */ |
| 1266 | | data = upd7220->sr; |
| 1466 | data = m_sr; |
| 1267 | 1467 | |
| 1268 | 1468 | /* TODO: timing of these */ |
| 1269 | | upd7220->sr &= ~UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1270 | | upd7220->sr &= ~UPD7220_SR_DMA_EXECUTE; |
| 1469 | m_sr &= ~UPD7220_SR_DRAWING_IN_PROGRESS; |
| 1470 | m_sr &= ~UPD7220_SR_DMA_EXECUTE; |
| 1271 | 1471 | } |
| 1272 | 1472 | |
| 1273 | 1473 | return data; |
| 1274 | 1474 | } |
| 1275 | 1475 | |
| 1276 | | /*------------------------------------------------- |
| 1277 | | upd7220_w - register write |
| 1278 | | -------------------------------------------------*/ |
| 1279 | 1476 | |
| 1280 | | WRITE8_DEVICE_HANDLER( upd7220_w ) |
| 1477 | //------------------------------------------------- |
| 1478 | // write - |
| 1479 | //------------------------------------------------- |
| 1480 | |
| 1481 | WRITE8_MEMBER( upd7220_device::write ) |
| 1281 | 1482 | { |
| 1282 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1283 | | |
| 1284 | 1483 | if (offset & 1) |
| 1285 | 1484 | { |
| 1286 | 1485 | /* command into FIFO */ |
| 1287 | | fifo_set_direction(upd7220, FIFO_WRITE); |
| 1288 | | queue(upd7220, data, 1); |
| 1486 | fifo_set_direction(FIFO_WRITE); |
| 1487 | queue(data, 1); |
| 1289 | 1488 | } |
| 1290 | 1489 | else |
| 1291 | 1490 | { |
| 1292 | 1491 | /* parameter into FIFO */ |
| 1293 | | // fifo_set_direction(upd7220, FIFO_WRITE); |
| 1294 | | queue(upd7220, data, 0); |
| 1492 | // fifo_set_direction(FIFO_WRITE); |
| 1493 | queue(data, 0); |
| 1295 | 1494 | } |
| 1296 | 1495 | |
| 1297 | | process_fifo(device); |
| 1496 | process_fifo(); |
| 1298 | 1497 | } |
| 1299 | 1498 | |
| 1300 | | WRITE8_DEVICE_HANDLER( upd7220_bank_w ) |
| 1301 | | { |
| 1302 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1303 | 1499 | |
| 1304 | | upd7220->vram_bank = 0x8000 * (data & 7); |
| 1305 | | } |
| 1500 | //------------------------------------------------- |
| 1501 | // dack_r - |
| 1502 | //------------------------------------------------- |
| 1306 | 1503 | |
| 1307 | | /*------------------------------------------------- |
| 1308 | | upd7220_dack_w - DMA acknowledge read |
| 1309 | | -------------------------------------------------*/ |
| 1310 | | |
| 1311 | | READ8_DEVICE_HANDLER( upd7220_dack_r ) |
| 1504 | READ8_MEMBER( upd7220_device::dack_r ) |
| 1312 | 1505 | { |
| 1313 | 1506 | return 0; |
| 1314 | 1507 | } |
| 1315 | 1508 | |
| 1316 | | /*------------------------------------------------- |
| 1317 | | upd7220_dack_w - DMA acknowledge write |
| 1318 | | -------------------------------------------------*/ |
| 1319 | 1509 | |
| 1320 | | WRITE8_DEVICE_HANDLER( upd7220_dack_w ) |
| 1510 | //------------------------------------------------- |
| 1511 | // dack_w - |
| 1512 | //------------------------------------------------- |
| 1513 | |
| 1514 | WRITE8_MEMBER( upd7220_device::dack_w ) |
| 1321 | 1515 | { |
| 1322 | 1516 | } |
| 1323 | 1517 | |
| 1324 | | /*------------------------------------------------- |
| 1325 | | upd7220_ext_sync_w - external synchronization |
| 1326 | | -------------------------------------------------*/ |
| 1327 | 1518 | |
| 1328 | | WRITE_LINE_DEVICE_HANDLER( upd7220_ext_sync_w ) |
| 1519 | //------------------------------------------------- |
| 1520 | // ext_sync_w - |
| 1521 | //------------------------------------------------- |
| 1522 | |
| 1523 | WRITE_LINE_MEMBER( upd7220_device::ext_sync_w ) |
| 1329 | 1524 | { |
| 1330 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1525 | //if (LOG) logerror("uPD7220 '%s' External Synchronization: %u\n", tag(), state); |
| 1331 | 1526 | |
| 1332 | | //if (LOG) logerror("uPD7220 '%s' External Synchronization: %u\n", device->tag(), state); |
| 1333 | | |
| 1334 | 1527 | if (state) |
| 1335 | 1528 | { |
| 1336 | | upd7220->sr |= UPD7220_SR_VSYNC_ACTIVE; |
| 1529 | m_sr |= UPD7220_SR_VSYNC_ACTIVE; |
| 1337 | 1530 | } |
| 1338 | 1531 | else |
| 1339 | 1532 | { |
| 1340 | | upd7220->sr &= ~UPD7220_SR_VSYNC_ACTIVE; |
| 1533 | m_sr &= ~UPD7220_SR_VSYNC_ACTIVE; |
| 1341 | 1534 | } |
| 1342 | 1535 | } |
| 1343 | 1536 | |
| 1344 | | /*------------------------------------------------- |
| 1345 | | upd7220_lpen_w - light pen strobe |
| 1346 | | -------------------------------------------------*/ |
| 1347 | 1537 | |
| 1348 | | WRITE_LINE_DEVICE_HANDLER( upd7220_lpen_w ) |
| 1538 | //------------------------------------------------- |
| 1539 | // ext_sync_w - |
| 1540 | //------------------------------------------------- |
| 1541 | |
| 1542 | WRITE_LINE_MEMBER( upd7220_device::lpen_w ) |
| 1349 | 1543 | { |
| 1350 | 1544 | /* only if 2 rising edges on the lpen input occur at the same |
| 1351 | 1545 | point during successive video fields are the pulses accepted */ |
| r11221 | r11222 | |
| 1360 | 1554 | */ |
| 1361 | 1555 | } |
| 1362 | 1556 | |
| 1363 | | INLINE void get_text_partition(upd7220_t *upd7220, int index, UINT32 *sad, UINT16 *len, int *im, int *wd) |
| 1364 | | { |
| 1365 | | *sad = ((upd7220->ra[(index * 4) + 1] & 0x1f) << 8) | upd7220->ra[(index * 4) + 0]; |
| 1366 | | *len = ((upd7220->ra[(index * 4) + 3] & 0x3f) << 4) | (upd7220->ra[(index * 4) + 2] >> 4); |
| 1367 | | *im = BIT(upd7220->ra[(index * 4) + 3], 6); |
| 1368 | | *wd = BIT(upd7220->ra[(index * 4) + 3], 7); |
| 1369 | | } |
| 1370 | 1557 | |
| 1371 | | /*------------------------------------------------- |
| 1372 | | update_text - update text mode screen |
| 1373 | | -------------------------------------------------*/ |
| 1558 | //------------------------------------------------- |
| 1559 | // update_text - |
| 1560 | //------------------------------------------------- |
| 1374 | 1561 | |
| 1375 | | static void update_text(device_t *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 1562 | void upd7220_device::update_text(bitmap_t *bitmap, const rectangle *cliprect) |
| 1376 | 1563 | { |
| 1377 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1378 | | |
| 1379 | 1564 | UINT32 addr, sad; |
| 1380 | 1565 | UINT16 len; |
| 1381 | | int im, wd, area; |
| 1566 | int im, wd; |
| 1382 | 1567 | int y, sy = 0; |
| 1383 | 1568 | |
| 1384 | | for (area = 0; area < 4; area++) |
| 1569 | for (int area = 0; area < 4; area++) |
| 1385 | 1570 | { |
| 1386 | | get_text_partition(upd7220, area, &sad, &len, &im, &wd); |
| 1571 | get_text_partition(area, &sad, &len, &im, &wd); |
| 1387 | 1572 | |
| 1388 | 1573 | for (y = sy; y < sy + len; y++) |
| 1389 | 1574 | { |
| 1390 | | addr = sad + (y * upd7220->pitch); |
| 1391 | | if (upd7220->draw_text_func) upd7220->draw_text_func(device, bitmap, upd7220->vram, addr, y, wd, upd7220->pitch,0,0,upd7220->aw * 8 - 1,upd7220->al - 1, upd7220->lr, upd7220->dc, upd7220->ead); |
| 1575 | addr = sad + (y * m_pitch); |
| 1576 | |
| 1577 | if (m_config.m_draw_text_func) |
| 1578 | m_config.m_draw_text_func(this, bitmap, m_vram, addr, y, wd, m_pitch, 0, 0, m_aw * 8 - 1, m_al - 1, m_lr, m_dc, m_ead); |
| 1392 | 1579 | } |
| 1393 | 1580 | |
| 1394 | 1581 | sy = y + 1; |
| 1395 | 1582 | } |
| 1396 | 1583 | } |
| 1397 | 1584 | |
| 1398 | | /*------------------------------------------------- |
| 1399 | | draw_graphics_line - draw graphics scanline |
| 1400 | | -------------------------------------------------*/ |
| 1401 | 1585 | |
| 1402 | | static void draw_graphics_line(device_t *device, bitmap_t *bitmap, UINT32 addr, int y, int wd) |
| 1586 | //------------------------------------------------- |
| 1587 | // draw_graphics_line - |
| 1588 | //------------------------------------------------- |
| 1589 | |
| 1590 | void upd7220_device::draw_graphics_line(bitmap_t *bitmap, UINT32 addr, int y, int wd) |
| 1403 | 1591 | { |
| 1404 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1405 | | address_space *space = device->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 1592 | address_space *space = m_machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 1406 | 1593 | int sx; |
| 1407 | 1594 | |
| 1408 | | for (sx = 0; sx < upd7220->pitch * 2; sx++) |
| 1595 | for (sx = 0; sx < m_pitch * 2; sx++) |
| 1409 | 1596 | { |
| 1410 | 1597 | UINT16 data = space->direct().read_raw_word(addr & 0x3ffff); //TODO: remove me |
| 1411 | 1598 | |
| 1412 | | if((sx << 3) < upd7220->aw * 16 && y < upd7220->al) |
| 1413 | | upd7220->display_func(device, bitmap, y, sx << 3, addr, data, upd7220->vram); |
| 1599 | if((sx << 3) < m_aw * 16 && y < m_al) |
| 1600 | m_config.m_display_func(this, bitmap, y, sx << 3, addr, data, m_vram); |
| 1414 | 1601 | |
| 1415 | 1602 | if (wd) addr += 2; else addr++; |
| 1416 | 1603 | } |
| 1417 | 1604 | } |
| 1418 | 1605 | |
| 1419 | | INLINE void get_graphics_partition(upd7220_t *upd7220, int index, UINT32 *sad, UINT16 *len, int *im, int *wd) |
| 1420 | | { |
| 1421 | | *sad = ((upd7220->ra[(index * 4) + 2] & 0x03) << 16) | (upd7220->ra[(index * 4) + 1] << 8) | upd7220->ra[(index * 4) + 0]; |
| 1422 | | *len = ((upd7220->ra[(index * 4) + 3] & 0x3f) << 4) | (upd7220->ra[(index * 4) + 2] >> 4); |
| 1423 | | *im = BIT(upd7220->ra[(index * 4) + 3], 6); |
| 1424 | | *wd = BIT(upd7220->ra[(index * 4) + 3], 7); |
| 1425 | | } |
| 1426 | 1606 | |
| 1427 | | /*------------------------------------------------- |
| 1428 | | update_graphics - update graphics mode screen |
| 1429 | | -------------------------------------------------*/ |
| 1607 | //------------------------------------------------- |
| 1608 | // update_graphics - |
| 1609 | //------------------------------------------------- |
| 1430 | 1610 | |
| 1431 | | static void update_graphics(device_t *device, bitmap_t *bitmap, const rectangle *cliprect, int force_bitmap) |
| 1611 | void upd7220_device::update_graphics(bitmap_t *bitmap, const rectangle *cliprect, int force_bitmap) |
| 1432 | 1612 | { |
| 1433 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1434 | | |
| 1435 | 1613 | UINT32 addr, sad; |
| 1436 | 1614 | UINT16 len; |
| 1437 | 1615 | int im, wd, area; |
| r11221 | r11222 | |
| 1439 | 1617 | |
| 1440 | 1618 | for (area = 0; area < 2; area++) |
| 1441 | 1619 | { |
| 1442 | | get_graphics_partition(upd7220, area, &sad, &len, &im, &wd); |
| 1620 | get_graphics_partition(area, &sad, &len, &im, &wd); |
| 1443 | 1621 | |
| 1444 | 1622 | for (y = 0; y < len; y++) |
| 1445 | 1623 | { |
| 1446 | 1624 | if (im || force_bitmap) |
| 1447 | 1625 | { |
| 1448 | | addr = (sad & 0x3ffff) + (y * upd7220->pitch * 2); |
| 1626 | addr = (sad & 0x3ffff) + (y * m_pitch * 2); |
| 1449 | 1627 | |
| 1450 | | if(upd7220->display_func) |
| 1451 | | draw_graphics_line(device, bitmap, addr, y + bsy, wd); |
| 1628 | if (m_config.m_display_func) |
| 1629 | draw_graphics_line(bitmap, addr, y + bsy, wd); |
| 1452 | 1630 | } |
| 1453 | 1631 | else |
| 1454 | 1632 | { |
| 1455 | 1633 | /* TODO: text params are more limited compared to graphics */ |
| 1456 | | addr = (sad & 0x3ffff) + (y * upd7220->pitch); |
| 1634 | addr = (sad & 0x3ffff) + (y * m_pitch); |
| 1457 | 1635 | |
| 1458 | | if (upd7220->draw_text_func) |
| 1459 | | upd7220->draw_text_func(device, bitmap, upd7220->vram, addr, y + tsy, wd, upd7220->pitch,0,0,upd7220->aw * 8 - 1,len + bsy - 1,upd7220->lr, upd7220->dc, upd7220->ead); |
| 1636 | if (m_config.m_draw_text_func) |
| 1637 | m_config.m_draw_text_func(this, bitmap, m_vram, addr, y + tsy, wd, m_pitch, 0, 0, m_aw * 8 - 1, len + bsy - 1, m_lr, m_dc, m_ead); |
| 1460 | 1638 | } |
| 1461 | 1639 | } |
| 1462 | 1640 | |
| 1463 | | if(upd7220->lr) |
| 1464 | | tsy += (y / upd7220->lr); |
| 1641 | if (m_lr) |
| 1642 | tsy += (y / m_lr); |
| 1465 | 1643 | bsy += y; |
| 1466 | 1644 | } |
| 1467 | 1645 | } |
| 1468 | 1646 | |
| 1469 | | /*------------------------------------------------- |
| 1470 | | upd7220_update - update screen |
| 1471 | | -------------------------------------------------*/ |
| 1472 | 1647 | |
| 1473 | | void upd7220_update(device_t *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 1648 | //------------------------------------------------- |
| 1649 | // update_screen - |
| 1650 | //------------------------------------------------- |
| 1651 | |
| 1652 | void upd7220_device::update_screen(bitmap_t *bitmap, const rectangle *cliprect) |
| 1474 | 1653 | { |
| 1475 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1476 | | |
| 1477 | | if (upd7220->de) |
| 1654 | if (m_de) |
| 1478 | 1655 | { |
| 1479 | | switch (upd7220->mode & UPD7220_MODE_DISPLAY_MASK) |
| 1656 | switch (m_mode & UPD7220_MODE_DISPLAY_MASK) |
| 1480 | 1657 | { |
| 1481 | 1658 | case UPD7220_MODE_DISPLAY_MIXED: |
| 1482 | | update_graphics(device, bitmap, cliprect,0); |
| 1659 | update_graphics(bitmap, cliprect, 0); |
| 1483 | 1660 | break; |
| 1484 | 1661 | |
| 1485 | 1662 | case UPD7220_MODE_DISPLAY_GRAPHICS: |
| 1486 | | update_graphics(device, bitmap, cliprect,1); |
| 1663 | update_graphics(bitmap, cliprect, 1); |
| 1487 | 1664 | break; |
| 1488 | 1665 | |
| 1489 | 1666 | case UPD7220_MODE_DISPLAY_CHARACTER: |
| 1490 | | update_text(device, bitmap, cliprect); |
| 1667 | update_text(bitmap, cliprect); |
| 1491 | 1668 | break; |
| 1492 | 1669 | |
| 1493 | 1670 | case UPD7220_MODE_DISPLAY_INVALID: |
| 1494 | | logerror("uPD7220 '%s' Invalid Display Mode!\n", device->tag()); |
| 1671 | logerror("uPD7220 '%s' Invalid Display Mode!\n", tag()); |
| 1495 | 1672 | } |
| 1496 | 1673 | } |
| 1497 | 1674 | } |
| 1498 | 1675 | |
| 1499 | | /*------------------------------------------------- |
| 1500 | | ROM( upd7220 ) |
| 1501 | | -------------------------------------------------*/ |
| 1502 | | |
| 1503 | | ROM_START( upd7220 ) |
| 1504 | | ROM_REGION( 0x100, "upd7220", ROMREGION_LOADBYNAME ) |
| 1505 | | ROM_LOAD( "upd7220.bin", 0x000, 0x100, NO_DUMP ) /* internal 128x14 control ROM */ |
| 1506 | | ROM_END |
| 1507 | | |
| 1508 | | /*------------------------------------------------- |
| 1509 | | ADDRESS_MAP( upd7220 ) |
| 1510 | | -------------------------------------------------*/ |
| 1511 | | |
| 1512 | | READ8_DEVICE_HANDLER( upd7220_vram_r ) |
| 1676 | WRITE8_MEMBER( upd7220_device::bank_w ) |
| 1513 | 1677 | { |
| 1514 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1515 | | |
| 1516 | | return upd7220->vram[offset]; |
| 1678 | m_vram_bank = 0x8000 * (data & 7); |
| 1517 | 1679 | } |
| 1518 | 1680 | |
| 1519 | | WRITE8_DEVICE_HANDLER( upd7220_vram_w ) |
| 1681 | READ8_MEMBER( upd7220_device::vram_r ) |
| 1520 | 1682 | { |
| 1521 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1522 | | |
| 1523 | | upd7220->vram[offset] = data; |
| 1683 | return m_vram[offset]; |
| 1524 | 1684 | } |
| 1525 | 1685 | |
| 1526 | | /*------------------------------------------------- |
| 1527 | | DEVICE_START( upd7220 ) |
| 1528 | | -------------------------------------------------*/ |
| 1529 | | |
| 1530 | | static DEVICE_START( upd7220 ) |
| 1686 | WRITE8_MEMBER( upd7220_device::vram_w ) |
| 1531 | 1687 | { |
| 1532 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1533 | | const upd7220_interface *intf = get_interface(device); |
| 1534 | | int i; |
| 1535 | | |
| 1536 | | /* resolve callbacks */ |
| 1537 | | devcb_resolve_write_line(&upd7220->out_drq_func, &intf->out_drq_func, device); |
| 1538 | | devcb_resolve_write_line(&upd7220->out_hsync_func, &intf->out_hsync_func, device); |
| 1539 | | devcb_resolve_write_line(&upd7220->out_vsync_func, &intf->out_vsync_func, device); |
| 1540 | | upd7220->display_func = intf->display_func; |
| 1541 | | upd7220->draw_text_func = intf->draw_text_func; |
| 1542 | | |
| 1543 | | /* get the screen device */ |
| 1544 | | upd7220->screen = device->machine().device<screen_device>(intf->screen_tag); |
| 1545 | | assert(upd7220->screen != NULL); |
| 1546 | | |
| 1547 | | /* create the timers */ |
| 1548 | | upd7220->vsync_timer = device->machine().scheduler().timer_alloc(FUNC(vsync_tick), (void *)device); |
| 1549 | | upd7220->hsync_timer = device->machine().scheduler().timer_alloc(FUNC(hsync_tick), (void *)device); |
| 1550 | | upd7220->blank_timer = device->machine().scheduler().timer_alloc(FUNC(blank_tick), (void *)device); |
| 1551 | | |
| 1552 | | /* set initial values */ |
| 1553 | | upd7220->fifo_ptr = -1; |
| 1554 | | upd7220->sr = UPD7220_SR_FIFO_EMPTY; |
| 1555 | | |
| 1556 | | for (i = 0; i < 16; i++) |
| 1557 | | { |
| 1558 | | upd7220->fifo[i] = 0; |
| 1559 | | upd7220->fifo_flag[i] = FIFO_EMPTY; |
| 1560 | | } |
| 1561 | | |
| 1562 | | /* register for state saving */ |
| 1563 | | device->save_item(NAME(upd7220->ra)); |
| 1564 | | device->save_item(NAME(upd7220->sr)); |
| 1565 | | device->save_item(NAME(upd7220->mode)); |
| 1566 | | device->save_item(NAME(upd7220->de)); |
| 1567 | | device->save_item(NAME(upd7220->aw)); |
| 1568 | | device->save_item(NAME(upd7220->al)); |
| 1569 | | device->save_item(NAME(upd7220->vs)); |
| 1570 | | device->save_item(NAME(upd7220->vfp)); |
| 1571 | | device->save_item(NAME(upd7220->vbp)); |
| 1572 | | device->save_item(NAME(upd7220->hs)); |
| 1573 | | device->save_item(NAME(upd7220->hfp)); |
| 1574 | | device->save_item(NAME(upd7220->hbp)); |
| 1575 | | device->save_item(NAME(upd7220->m)); |
| 1576 | | device->save_item(NAME(upd7220->dc)); |
| 1577 | | device->save_item(NAME(upd7220->sc)); |
| 1578 | | device->save_item(NAME(upd7220->br)); |
| 1579 | | device->save_item(NAME(upd7220->lr)); |
| 1580 | | device->save_item(NAME(upd7220->ctop)); |
| 1581 | | device->save_item(NAME(upd7220->cbot)); |
| 1582 | | device->save_item(NAME(upd7220->ead)); |
| 1583 | | device->save_item(NAME(upd7220->dad)); |
| 1584 | | device->save_item(NAME(upd7220->lad)); |
| 1585 | | device->save_item(NAME(upd7220->disp)); |
| 1586 | | device->save_item(NAME(upd7220->gchr)); |
| 1587 | | device->save_item(NAME(upd7220->mask)); |
| 1588 | | device->save_item(NAME(upd7220->pitch)); |
| 1688 | m_vram[offset] = data; |
| 1589 | 1689 | } |
| 1590 | | |
| 1591 | | /*------------------------------------------------- |
| 1592 | | DEVICE_RESET( upd7220 ) |
| 1593 | | -------------------------------------------------*/ |
| 1594 | | |
| 1595 | | static DEVICE_RESET( upd7220 ) |
| 1596 | | { |
| 1597 | | upd7220_t *upd7220 = get_safe_token(device); |
| 1598 | | |
| 1599 | | devcb_call_write_line(&upd7220->out_drq_func, CLEAR_LINE); |
| 1600 | | } |
| 1601 | | |
| 1602 | | /*------------------------------------------------- |
| 1603 | | DEVICE_GET_INFO( upd7220 ) |
| 1604 | | -------------------------------------------------*/ |
| 1605 | | |
| 1606 | | DEVICE_GET_INFO( upd7220 ) |
| 1607 | | { |
| 1608 | | switch (state) |
| 1609 | | { |
| 1610 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1611 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(upd7220_t); break; |
| 1612 | | case DEVINFO_INT_DATABUS_WIDTH_0: info->i = 8; break; |
| 1613 | | case DEVINFO_INT_ADDRBUS_WIDTH_0: info->i = 18; break; |
| 1614 | | case DEVINFO_INT_ADDRBUS_SHIFT_0: info->i = -1; break; |
| 1615 | | |
| 1616 | | /* --- the following bits of info are returned as pointers --- */ |
| 1617 | | case DEVINFO_PTR_ROM_REGION: info->romregion = ROM_NAME(upd7220); break; |
| 1618 | | |
| 1619 | | /* --- the following bits of info are returned as pointers to data --- */ |
| 1620 | | case DEVINFO_PTR_DEFAULT_MEMORY_MAP_0: info->default_map8 = NULL; break; |
| 1621 | | |
| 1622 | | /* --- the following bits of info are returned as pointers to functions --- */ |
| 1623 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(upd7220); break; |
| 1624 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1625 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(upd7220); break; |
| 1626 | | |
| 1627 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1628 | | case DEVINFO_STR_NAME: strcpy(info->s, "NEC uPD7220"); break; |
| 1629 | | case DEVINFO_STR_SHORTNAME: strcpy(info->s, "upd7220"); break; |
| 1630 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "NEC uPD7220"); break; |
| 1631 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1632 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1633 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 1634 | | } |
| 1635 | | } |
| 1636 | | |
| 1637 | | DEFINE_LEGACY_MEMORY_DEVICE(UPD7220, upd7220); |