Exemplo n.º 1
0
	def create_search_page(mediawiki, basedir):
		meta = {
			"clear_screen": True,
			"links": {
				"0": "0"
			},
			"inputs": {
				"fields": [
					{
						"name": "search",
						"line": 18,
						"column": 9,
						"height": 1,
						"width": 31,
						"bgcolor": 0,
						"fgcolor": 15,
						"validate": "call:MediaWiki_UI.callback_validate_search:" + str(mediawiki.id)
					}
				],
				"confirm": False,
				"target": "call:MediaWiki_UI.callback_search:" + str(mediawiki.id)
			},
			"publisher_color": 0
		}

		data_cept = bytearray()
		data_cept.extend(Cept.parallel_mode())
		data_cept.extend(Cept.set_screen_bg_color(7))
		data_cept.extend(Cept.set_cursor(2, 1))
		data_cept.extend(Cept.set_line_bg_color(0))
		data_cept.extend(b'\n')
		data_cept.extend(Cept.set_line_bg_color(0))
		data_cept.extend(Cept.double_height())
		data_cept.extend(Cept.set_fg_color(7))
		data_cept.extend(Cept.from_str(mediawiki.title))
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.normal_size())
		data_cept.extend(b'\n')
		data_cept.extend(Cept.set_cursor(18, 1))
		data_cept.extend(Cept.set_fg_color(0))
		data_cept.extend(Cept.from_str(mediawiki.search_string))
		# trick: show cursor now so that user knows they can enter text, even though more
		# data is loading
		data_cept.extend(Cept.show_cursor())
		image = Image_UI(basedir + mediawiki.image, colors = 4)
#		image = Image_UI(basedir + "wikipedia.png", colors = 4)

		data_cept.extend(Cept.define_palette(image.palette))
		data_cept.extend(image.drcs)

		data_cept.extend(Cept.hide_cursor())

		y = 6
		for l in image.chars:
			data_cept.extend(Cept.set_cursor(y, int((41 - len(image.chars[0])) / 2)))
			data_cept.extend(Cept.load_g0_drcs())
			data_cept.extend(l)
			y += 1

		return (meta, data_cept)
Exemplo n.º 2
0
	def create_image_page():
#		filename = "/Users/mist/Desktop/RGB_24bits_palette_sample_image.jpg"
#		filename = "/Users/mist/Desktop/Lenna_(test_image).png"
#		filename = "/Users/mist/Desktop/Wikipedia_logo_593.jpg"
		filename = "/Users/mist/Desktop/220px-C64c_system.jpg"

		(palette, drcs, chars) = Image_UI.cept_from_image(filename)

		data_cept = bytearray()
		data_cept.extend(Cept.define_palette(palette))
		data_cept.extend(drcs)

		data_cept.extend(Cept.set_cursor(3, 1))
		data_cept.extend(Cept.load_g0_drcs())
		for l in chars:
			data_cept.extend(l)
			data_cept.extend(b'\r\n')

		meta = {
			"clear_screen": True,
			"links": {
				"0": "0"
			},
			"publisher_color": 0
		}

		return (meta, data_cept)
Exemplo n.º 3
0
def create_preamble(basedir, meta):
	global last_filename_include
	global last_filename_palette

	preamble = b''

	# define palette
	if "palette" in meta:
		palette = meta["palette"]
		filename_palette = basedir + meta["palette"] + ".pal"
		sys.stderr.write("filename_palette = " + filename_palette + "\n")
		sys.stderr.write("last_filename_palette = " + last_filename_palette + "\n")
		if filename_palette != last_filename_palette:
			last_filename_palette = filename_palette
			with open(filename_palette) as f:
				sys.stderr.write("loading: '" + filename_palette + "'\n")
				palette = json.load(f)
			palette_data = Cept.define_palette(palette["palette"], palette.get("start_color", 16))
			preamble += palette_data
		else:
			sys.stderr.write("skipping palette\n")
	else:
		last_filename_palette = ""

	if "include" in meta:
		if os.path.isfile( basedir + meta["include"] + ".inc"):
			filename_include_cm = basedir + meta["include"] + ".inc.cm"
			filename_include = basedir + meta["include"] + ".inc"
		else:
			filename_include_cm =""
			filename_include = basedir + meta["include"] + ".cept"
		sys.stderr.write("Filename_include="+filename_include+"\n");

		if ((filename_include != last_filename_include) or meta.get("clear_screen", False)):
			last_filename_include = filename_include
			if os.path.isfile(filename_include):
				with open(filename_include, mode='rb') as f:
					data_include = f.read()
					sys.stderr.write("loading: '" + filename_include + "'\n")
			elif os.path.isfile(filename_include_cm):
				data_include = CM.read(filename_include_cm)
			else:
				sys.stderr.write("include file not found.\n")
			# palette definition has to end with 0x1f; add one if
			# the include data doesn't start with one
			if data_include[0] != 0x1f:
				preamble += Cept.set_cursor(1, 1)
			preamble += data_include
	else:
		last_filename_include = ""

	b = baud if baud else 1200
	if len(preamble) > (b/9) * SH291_THRESHOLD_SEC:
		preamble = Util.create_system_message(291) + preamble

	return preamble