Mercurial > repos > blastem
comparison sms.c @ 1696:956c1cce05e2 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 24 Jan 2019 19:15:59 -0800 |
parents | b7ecd0d6a77b 319d90025d50 |
children | 95e387e1d63c |
comparison
equal
deleted
inserted
replaced
1648:b7ecd0d6a77b | 1696:956c1cce05e2 |
---|---|
233 save_int8(buf, SMS_CART_RAM_SIZE / 1024); | 233 save_int8(buf, SMS_CART_RAM_SIZE / 1024); |
234 save_buffer8(buf, sms->cart_ram, SMS_CART_RAM_SIZE); | 234 save_buffer8(buf, sms->cart_ram, SMS_CART_RAM_SIZE); |
235 end_section(buf); | 235 end_section(buf); |
236 } | 236 } |
237 | 237 |
238 static uint8_t *serialize(system_header *sys, size_t *size_out) | |
239 { | |
240 sms_context *sms = (sms_context *)sys; | |
241 serialize_buffer state; | |
242 init_serialize(&state); | |
243 sms_serialize(sms, &state); | |
244 if (size_out) { | |
245 *size_out = state.size; | |
246 } | |
247 return state.data; | |
248 } | |
249 | |
238 static void ram_deserialize(deserialize_buffer *buf, void *vsms) | 250 static void ram_deserialize(deserialize_buffer *buf, void *vsms) |
239 { | 251 { |
240 sms_context *sms = vsms; | 252 sms_context *sms = vsms; |
241 uint32_t ram_size = load_int8(buf) * 1024; | 253 uint32_t ram_size = load_int8(buf) * 1024; |
242 if (ram_size > sizeof(sms->ram)) { | 254 if (ram_size > sizeof(sms->ram)) { |
288 z80_invalidate_code_range(sms->z80, 0xC000, 0x10000); | 300 z80_invalidate_code_range(sms->z80, 0xC000, 0x10000); |
289 if (sms->bank_regs[0] & 8) { | 301 if (sms->bank_regs[0] & 8) { |
290 //cart RAM is enabled, invalidate the region in case there is any code there | 302 //cart RAM is enabled, invalidate the region in case there is any code there |
291 z80_invalidate_code_range(sms->z80, 0x8000, 0xC000); | 303 z80_invalidate_code_range(sms->z80, 0x8000, 0xC000); |
292 } | 304 } |
305 free(buf->handlers); | |
306 buf->handlers = NULL; | |
307 } | |
308 | |
309 static void deserialize(system_header *sys, uint8_t *data, size_t size) | |
310 { | |
311 sms_context *sms = (sms_context *)sys; | |
312 deserialize_buffer buffer; | |
313 init_deserialize(&buffer, data, size); | |
314 sms_deserialize(&buffer, sms); | |
293 } | 315 } |
294 | 316 |
295 static void save_state(sms_context *sms, uint8_t slot) | 317 static void save_state(sms_context *sms, uint8_t slot) |
296 { | 318 { |
297 char *save_path = get_slot_name(&sms->header, slot, "state"); | 319 char *save_path = get_slot_name(&sms->header, slot, "state"); |
390 vdp_adjust_cycles(sms->vdp, adjust); | 412 vdp_adjust_cycles(sms->vdp, adjust); |
391 sms->psg->cycles -= adjust; | 413 sms->psg->cycles -= adjust; |
392 target_cycle -= adjust; | 414 target_cycle -= adjust; |
393 } | 415 } |
394 } | 416 } |
417 #ifndef IS_LIB | |
395 bindings_release_capture(); | 418 bindings_release_capture(); |
396 vdp_release_framebuffer(sms->vdp); | 419 vdp_release_framebuffer(sms->vdp); |
397 render_pause_source(sms->psg->audio); | 420 render_pause_source(sms->psg->audio); |
421 #endif | |
398 sms->should_return = 0; | 422 sms->should_return = 0; |
399 } | 423 } |
400 | 424 |
401 static void resume_sms(system_header *system) | 425 static void resume_sms(system_header *system) |
402 { | 426 { |
403 sms_context *sms = (sms_context *)system; | 427 sms_context *sms = (sms_context *)system; |
428 #ifndef IS_LIB | |
404 bindings_reacquire_capture(); | 429 bindings_reacquire_capture(); |
405 vdp_reacquire_framebuffer(sms->vdp); | 430 vdp_reacquire_framebuffer(sms->vdp); |
406 render_resume_source(sms->psg->audio); | 431 render_resume_source(sms->psg->audio); |
432 #endif | |
407 run_sms(system); | 433 run_sms(system); |
408 } | 434 } |
409 | 435 |
410 static void start_sms(system_header *system, char *statefile) | 436 static void start_sms(system_header *system, char *statefile) |
411 { | 437 { |
454 | 480 |
455 static void request_exit(system_header *system) | 481 static void request_exit(system_header *system) |
456 { | 482 { |
457 sms_context *sms = (sms_context *)system; | 483 sms_context *sms = (sms_context *)system; |
458 sms->should_return = 1; | 484 sms->should_return = 1; |
485 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->current_cycle; | |
459 } | 486 } |
460 | 487 |
461 static void inc_debug_mode(system_header *system) | 488 static void inc_debug_mode(system_header *system) |
462 { | 489 { |
463 sms_context *sms = (sms_context *)system; | 490 sms_context *sms = (sms_context *)system; |
606 sms->header.mouse_motion_absolute = mouse_motion_absolute; | 633 sms->header.mouse_motion_absolute = mouse_motion_absolute; |
607 sms->header.mouse_motion_relative = mouse_motion_relative; | 634 sms->header.mouse_motion_relative = mouse_motion_relative; |
608 sms->header.keyboard_down = keyboard_down; | 635 sms->header.keyboard_down = keyboard_down; |
609 sms->header.keyboard_up = keyboard_up; | 636 sms->header.keyboard_up = keyboard_up; |
610 sms->header.config_updated = config_updated; | 637 sms->header.config_updated = config_updated; |
638 sms->header.serialize = serialize; | |
639 sms->header.deserialize = deserialize; | |
611 sms->header.type = SYSTEM_SMS; | 640 sms->header.type = SYSTEM_SMS; |
612 | 641 |
613 return sms; | 642 return sms; |
614 } | 643 } |