Taking SC5 snapshot of games

Page 3/5
1 | 2 | | 4 | 5

By NYYRIKKI

Enlighted (5396)

NYYRIKKI's picture

17-09-2012, 07:45

~mk~ wrote:

It seems only the first quarter of each sprite got saved.

In that case the line 10 should be:
10 SCREEN 2,2

By wouter_

Champion (418)

wouter_'s picture

17-09-2012, 22:14

I transformed NYYRIKKI's script to reuse existing openMSX utility functions (vdpreg and get_screen_mode), I factored out (most of) the duplicated code and did some general cleanups and I ended up with this version:

proc picsave {fname} {
	append fname ".SC" [get_screen_mode_number]

	set name_base        [expr  [vdpreg 2]        * 0x400]
	set name_base_80     [expr ([vdpreg 2] & 252) * 0x400]
	set name_base_bitmap [expr ([vdpreg 2] &  96) * 0x400]
	set color_base       [expr  [vdpreg 3]        * 0x40 + [vdpreg 10] * 0x4000]
	set color_base_2     [expr ([vdpreg 3] & 128) * 0x40 + [vdpreg 10] * 0x4000]
	set pattern_base     [expr  [vdpreg 4]        * 0x800]
	set pattern_base_2   [expr ([vdpreg 4] & 60)  * 0x800]
	set spr_att_base     [expr  [vdpreg 5]        * 0x80 + [vdpreg 11] * 0x8000]
	set spr_att_base_2   [expr ([vdpreg 5] & 252) * 0x80 + [vdpreg 11] * 0x8000 - 0x200]
	set spr_pat_base     [expr  [vdpreg 6]        * 0x800]

	switch [get_screen_mode] {
	"TEXT40" {
		lappend sections "VRAM" $name_base 0x400                    ;# BG Map
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $name_base + 0x420] 0x3E0     ;# Fill (BG Map)
		lappend sections "VRAM" $pattern_base 0x800                 ;# BG Tiles
	}
	"TEXT80" {
		lappend sections "VRAM" $name_base_80 0x800                 ;# BG Map
		lappend sections "VRAM" $color_base 0x700                   ;# Blink
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $name_base_80 + 0xF20] 0xE0   ;# Fill (BG Map)
		lappend sections "VRAM" $pattern_base 0x800                 ;# BG Tiles
	}
	"1" {
		lappend sections "VRAM" $pattern_base 0x1800                ;# BG Tiles
		lappend sections "VRAM" $name_base 0x300                    ;# BG Map
		lappend sections "VRAM" $spr_att_base 0x500                 ;# OBJ Attributes
		lappend sections "VRAM" $color_base 0x20                    ;# BG Colors
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $color_base + 0x40] 0x17C0    ;# Fill (BG Colors)
		lappend sections "VRAM" $spr_pat_base 0x800                 ;# OBJ Tiles
	}
	"2" {
		lappend sections "VRAM" $pattern_base_2 0x1800              ;# BG Tiles
		lappend sections "VRAM" $name_base 0x300                    ;# BG Map
		lappend sections "VRAM" $spr_att_base 0x80                  ;# OBJ Attributes
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $spr_att_base + 0xA0] 0x460   ;# Fill (OBJ Attributes)
		lappend sections "VRAM" $color_base_2 0x1800                ;# BG Colors
		lappend sections "VRAM" $spr_pat_base 0x800                 ;# OBJ Tiles
	}
	"3" {
		lappend sections "VRAM" $pattern_base 0x800                 ;# BG Tiles
		lappend sections "VRAM" $name_base 0x1300                   ;# BG Map
		lappend sections "VRAM" $spr_att_base 0x520                 ;# OBJ Attributes
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $spr_att_base + 0x540] 0x17C0 ;# Fill (OBJ Attributes)
		lappend sections "VRAM" $spr_pat_base 0x800                 ;# OBJ Tiles
	}
	"4" {
		lappend sections "VRAM" $pattern_base_2 0x1800              ;# BG Tiles
		lappend sections "VRAM" $name_base 0x380                    ;# BG Map
		lappend sections "VDP palette" 0 0x20                       ;# Palette
		lappend sections "VRAM" [expr $name_base + 0x3A0] 0x60      ;# Fill (BG Map)
		lappend sections "VRAM" $spr_att_base_2 0x400               ;# OBJ Attributes
		lappend sections "VRAM" $color_base_2                       ;# BG Colors
		lappend sections "VRAM" $spr_pat_base 0x800                 ;# OBJ Tiles
	}
	"5" -
	"6" {
		lappend sections "VRAM" $name_base_bitmap 0x7400                ;# Bitmap
		lappend sections "VRAM" $spr_att_base_2 0x280                   ;# Sprite colors + attributes
		lappend sections "VDP palette" 0 0x20                           ;# Palette
		lappend sections "VRAM" [expr $name_base_bitmap + 0x76A0] 0x160 ;# Fill (Bitmap)
		lappend sections "VRAM" $spr_pat_base 0x800                     ;# Sprite character patterns
	}
	"7" -
	"8" {
		lappend sections "VRAM" $name_base_bitmap 0xF000            ;# Bitmap
		lappend sections "VRAM" $spr_pat_base 0x800                 ;# Sprite character patterns
		lappend sections "VRAM" $spr_att_base_2 0x280               ;# Sprite colors + attributes
		lappend sections "VDP palette" 0 0x20                       ;# Palette
	}
	default {
		error "Unknown screenmode"
	}}

	# open file
	set out [open $fname w]
	fconfigure $out -translation binary

	# write header
	set end_addr -1
	foreach {type addr size} $sections {
		incr end_addr $size
	}
	set header [ 0xFE 0 0 [expr $end_addr & 255] [expr $end_addr / 256] 0 0]
	puts -nonewline $out [binary format c* $header]

	# write data sections
	foreach {type addr size} $sections {
		puts -nonewline $out [debug read_block $type $addr $size]
	}
	close $out
}

@NYYRIKKI: Can we include this script in openMSX?[/]

By NYYRIKKI

Enlighted (5396)

NYYRIKKI's picture

17-09-2012, 23:11

wouter_ wrote:

@NYYRIKKI: Can we include this script in openMSX?

Yes, sure... I was about to add support for .SCA and .SCC but I don't know for sure how to do that now in the current version of the script... Maybe something like hex([get_screen_mode_number]) in second line and "7"-"12" in switch

By hit9918

Prophet (2868)

hit9918's picture

18-09-2012, 00:00

@Manuel, with the array stuff I maybe was thinking too far, described at a higher level,
it would be extra comfort to have the screenshot command with an option for croping the border.

By ~mk~

Master (227)

~mk~'s picture

18-09-2012, 01:49

Nice refactoring wouter_
And NYYRIKKI, yes SCREEN 2,2 solved the problem, thanks!

By ~mk~

Master (227)

~mk~'s picture

18-09-2012, 03:11

wouter_ I had to remove the space before 0xFE otherwise the script fails with unknown command "0xFE"

By wouter_

Champion (418)

wouter_'s picture

18-09-2012, 09:52

~mk~ wrote:

wouter_ I had to remove the space before 0xFE otherwise the script fails with unknown command "0xFE"

I didn't notice this yet, but the MRC forum code doesn't show the code correctly, the line should be:
set header {opening-square-bracket}list 0xFE ...
I did type the code correctly, but apparently the MRC code formatting code eats up the 'list' keyword. Is this a bug in the MRC code or should certain constructs still be escaped in a code-block? (And if so, how should it be escaped?)

NYYRIKKI wrote:

I was about to add support for .SCA and .SCC but I don't know for sure how to do that now in the current version of the script... Maybe something like hex([get_screen_mode_number]) in second line and "7"-"12" in switch

Something like this?
set fname [format "%s.SC%X" $fname [get_screen_mode_number]]

By Manuel

Ascended (15807)

Manuel's picture

18-09-2012, 21:59

@hit9918: Ah, you are talking about the normal screenshot command now?

We've discussed a border cropping option before, IIRC... but no one created it.

By sd_snatcher

Prophet (3090)

sd_snatcher's picture

20-09-2012, 22:33

~mk~ wrote:

Hi everyone,
First, it must be an emulator which takes the snapshot at the exact resolution (256x212) otherwise I have to manually crop the relevant part of the snapshot.

BTW, this cropping issue remembers me of this feature request.

By Manuel

Ascended (15807)

Manuel's picture

20-09-2012, 22:34

Right, that's the one I added when we discussed it.

By the way, NYYRIKKI's script (after Wouter finished it) will be in next openMSX release. Smile Thanks NYYRIKKI!

Page 3/5
1 | 2 | | 4 | 5